cellarr-array 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cellarr-array might be problematic. Click here for more details.
- cellarr_array/CellArray.py +16 -3
- cellarr_array/DenseCellArray.py +6 -1
- cellarr_array/SparseCellArray.py +6 -1
- cellarr_array/__init__.py +1 -1
- cellarr_array/helpers.py +9 -1
- {cellarr_array-0.0.2.dist-info → cellarr_array-0.0.3.dist-info}/METADATA +3 -2
- cellarr_array-0.0.3.dist-info/RECORD +11 -0
- {cellarr_array-0.0.2.dist-info → cellarr_array-0.0.3.dist-info}/WHEEL +1 -1
- cellarr_array-0.0.2.dist-info/RECORD +0 -11
- {cellarr_array-0.0.2.dist-info → cellarr_array-0.0.3.dist-info/licenses}/LICENSE.txt +0 -0
- {cellarr_array-0.0.2.dist-info → cellarr_array-0.0.3.dist-info}/top_level.txt +0 -0
cellarr_array/CellArray.py
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
from contextlib import contextmanager
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
from types import EllipsisType
|
|
6
|
+
except ImportError:
|
|
7
|
+
# TODO: This is required for Python <3.10. Remove once Python 3.9 reaches EOL in October 2025
|
|
8
|
+
EllipsisType = type(...)
|
|
3
9
|
from typing import List, Literal, Optional, Tuple, Union
|
|
4
10
|
|
|
5
11
|
import numpy as np
|
|
@@ -70,6 +76,7 @@ class CellArray(ABC):
|
|
|
70
76
|
self._ndim = None
|
|
71
77
|
self._dim_names = None
|
|
72
78
|
self._attr_names = None
|
|
79
|
+
self._nonempty_domain = None
|
|
73
80
|
|
|
74
81
|
if validate:
|
|
75
82
|
self._validate(attr=attr)
|
|
@@ -159,7 +166,7 @@ class CellArray(ABC):
|
|
|
159
166
|
finally:
|
|
160
167
|
array.close()
|
|
161
168
|
|
|
162
|
-
def __getitem__(self, key: Union[slice, Tuple[Union[slice, List[int]], ...]]):
|
|
169
|
+
def __getitem__(self, key: Union[slice, EllipsisType, Tuple[Union[slice, List[int]], ...], EllipsisType]):
|
|
163
170
|
"""Get item implementation that routes to either direct slicing or multi_index
|
|
164
171
|
based on the type of indices provided.
|
|
165
172
|
|
|
@@ -176,16 +183,22 @@ class CellArray(ABC):
|
|
|
176
183
|
# Normalize all indices
|
|
177
184
|
normalized_key = tuple(SliceHelper.normalize_index(idx, self.shape[i]) for i, idx in enumerate(key))
|
|
178
185
|
|
|
186
|
+
num_ellipsis = sum(isinstance(i, EllipsisType) for i in normalized_key)
|
|
187
|
+
if num_ellipsis > 1:
|
|
188
|
+
raise IndexError(f"Found more than 1 Ellipsis (...) in key: {normalized_key}")
|
|
189
|
+
|
|
179
190
|
# Check if we can use direct slicing
|
|
180
|
-
use_direct = all(isinstance(idx, slice) for idx in normalized_key)
|
|
191
|
+
use_direct = all(isinstance(idx, (slice, EllipsisType)) for idx in normalized_key)
|
|
181
192
|
|
|
182
193
|
if use_direct:
|
|
183
194
|
return self._direct_slice(normalized_key)
|
|
184
195
|
else:
|
|
196
|
+
if num_ellipsis > 0:
|
|
197
|
+
raise IndexError(f"tiledb does not support ellipsis in multi-index access: {normalized_key}")
|
|
185
198
|
return self._multi_index(normalized_key)
|
|
186
199
|
|
|
187
200
|
@abstractmethod
|
|
188
|
-
def _direct_slice(self, key: Tuple[slice, ...]) -> np.ndarray:
|
|
201
|
+
def _direct_slice(self, key: Tuple[Union[slice, EllipsisType], ...]) -> np.ndarray:
|
|
189
202
|
"""Implementation for direct slicing."""
|
|
190
203
|
pass
|
|
191
204
|
|
cellarr_array/DenseCellArray.py
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from types import EllipsisType
|
|
3
|
+
except ImportError:
|
|
4
|
+
# TODO: This is required for Python <3.10. Remove once Python 3.9 reaches EOL in October 2025
|
|
5
|
+
EllipsisType = type(...)
|
|
1
6
|
from typing import List, Tuple, Union
|
|
2
7
|
|
|
3
8
|
import numpy as np
|
|
@@ -13,7 +18,7 @@ __license__ = "MIT"
|
|
|
13
18
|
class DenseCellArray(CellArray):
|
|
14
19
|
"""Implementation for dense TileDB arrays."""
|
|
15
20
|
|
|
16
|
-
def _direct_slice(self, key: Tuple[slice, ...]) -> np.ndarray:
|
|
21
|
+
def _direct_slice(self, key: Tuple[Union[slice, EllipsisType], ...]) -> np.ndarray:
|
|
17
22
|
"""Implementation for direct slicing of dense arrays.
|
|
18
23
|
|
|
19
24
|
Args:
|
cellarr_array/SparseCellArray.py
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from types import EllipsisType
|
|
3
|
+
except ImportError:
|
|
4
|
+
# TODO: This is required for Python <3.10. Remove once Python 3.9 reaches EOL in October 2025
|
|
5
|
+
EllipsisType = type(...)
|
|
1
6
|
from typing import Dict, List, Optional, Tuple, Union
|
|
2
7
|
|
|
3
8
|
import numpy as np
|
|
@@ -118,7 +123,7 @@ class SparseCellArray(CellArray):
|
|
|
118
123
|
|
|
119
124
|
return sliced[key]
|
|
120
125
|
|
|
121
|
-
def _direct_slice(self, key: Tuple[slice, ...]) -> Union[np.ndarray, sparse.coo_matrix]:
|
|
126
|
+
def _direct_slice(self, key: Tuple[Union[slice, EllipsisType], ...]) -> Union[np.ndarray, sparse.coo_matrix]:
|
|
122
127
|
"""Implementation for direct slicing of sparse arrays."""
|
|
123
128
|
with self.open_array(mode="r") as array:
|
|
124
129
|
result = array[key]
|
cellarr_array/__init__.py
CHANGED
cellarr_array/helpers.py
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from types import EllipsisType
|
|
3
|
+
except ImportError:
|
|
4
|
+
# TODO: This is required for Python <3.10. Remove once Python 3.9 reaches EOL in October 2025
|
|
5
|
+
EllipsisType = type(...)
|
|
1
6
|
from typing import List, Optional, Tuple, Union
|
|
2
7
|
|
|
3
8
|
import numpy as np
|
|
@@ -150,9 +155,12 @@ class SliceHelper:
|
|
|
150
155
|
return None
|
|
151
156
|
|
|
152
157
|
@staticmethod
|
|
153
|
-
def normalize_index(idx: Union[int, slice, List[int]], dim_size: int) -> Union[slice, List[int]]:
|
|
158
|
+
def normalize_index(idx: Union[int, slice, List[int]], dim_size: int) -> Union[slice, List[int], EllipsisType]:
|
|
154
159
|
"""Normalize index to handle negative indices and ensure consistency."""
|
|
155
160
|
|
|
161
|
+
if isinstance(idx, EllipsisType):
|
|
162
|
+
return idx
|
|
163
|
+
|
|
156
164
|
# Convert ranges to slices
|
|
157
165
|
if isinstance(idx, range):
|
|
158
166
|
idx = slice(idx.start, idx.stop, idx.step)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cellarr-array
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Base class for handling TileDB backed arrays.
|
|
5
5
|
Home-page: https://github.com/cellarr/cellarr-array
|
|
6
6
|
Author: Jayaram Kancherla
|
|
@@ -20,6 +20,7 @@ Provides-Extra: testing
|
|
|
20
20
|
Requires-Dist: setuptools; extra == "testing"
|
|
21
21
|
Requires-Dist: pytest; extra == "testing"
|
|
22
22
|
Requires-Dist: pytest-cov; extra == "testing"
|
|
23
|
+
Dynamic: license-file
|
|
23
24
|
|
|
24
25
|
[](https://pypi.org/project/cellarr-array/)
|
|
25
26
|

|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
cellarr_array/CellArray.py,sha256=vc_6oDLCpVgUaP8HsQz4vE0ZyJ1SPdX43s7VQyh7gF0,8204
|
|
2
|
+
cellarr_array/DenseCellArray.py,sha256=rlu2xq8SONwIswqe0TzRNCwM5f0HYgxr4QBtvbBe8ro,3953
|
|
3
|
+
cellarr_array/SparseCellArray.py,sha256=cOIbs_97j5u13FU7FfEfRNqAZi8rHUkypgLgRcubXrU,7304
|
|
4
|
+
cellarr_array/__init__.py,sha256=IUE9wMDISgRkWp-Fc0KJpDiezCJ61kzuTqS9HdK-JeE,779
|
|
5
|
+
cellarr_array/config.py,sha256=67zBxpYY9N_v6TMdyljUIZmckbwOBcuLC99aJooGmfA,2917
|
|
6
|
+
cellarr_array/helpers.py,sha256=ZqK_josEzKzTMP62P9pb4qBiOTisFofTCnu1LETYJT4,6449
|
|
7
|
+
cellarr_array-0.0.3.dist-info/licenses/LICENSE.txt,sha256=qI2hRZobcUlj8gqFqXwqt522HeYyWvHLF00zCSZofHA,1084
|
|
8
|
+
cellarr_array-0.0.3.dist-info/METADATA,sha256=1KgSZEEF2i9aCr4mkkyAmuPXht4y5ZG2-YdH4dBELpQ,4120
|
|
9
|
+
cellarr_array-0.0.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
10
|
+
cellarr_array-0.0.3.dist-info/top_level.txt,sha256=oErp0D8ABZV-QPtTiXT8_F2z36Ic7ykuDg_1Y84HLZM,14
|
|
11
|
+
cellarr_array-0.0.3.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
cellarr_array/CellArray.py,sha256=sFD258mPp4w-8-xmjAgoicKo0Nbu0GGa-1gMXxt5cZ0,7570
|
|
2
|
-
cellarr_array/DenseCellArray.py,sha256=iPrjFtGolnHB0BTi4A8ncEpoFI9FWe6oZHhA1Men3Wo,3745
|
|
3
|
-
cellarr_array/SparseCellArray.py,sha256=8bajVOvUMaQhWU-_pZY0Cg9sD6kWRAJCu2G45uY-W4Q,7096
|
|
4
|
-
cellarr_array/__init__.py,sha256=8m0_shRPKNNaNab5tGBL2l0K5XgkKCFuLAh7QGogfYo,778
|
|
5
|
-
cellarr_array/config.py,sha256=67zBxpYY9N_v6TMdyljUIZmckbwOBcuLC99aJooGmfA,2917
|
|
6
|
-
cellarr_array/helpers.py,sha256=O0RgDLIdYbWc01yp2Cw0EmjJ3g_uzlz2JnYE8W7PZEE,6182
|
|
7
|
-
cellarr_array-0.0.2.dist-info/LICENSE.txt,sha256=qI2hRZobcUlj8gqFqXwqt522HeYyWvHLF00zCSZofHA,1084
|
|
8
|
-
cellarr_array-0.0.2.dist-info/METADATA,sha256=-VmLQZQmbUhNkD_Y9ZLeZkBgLf4H5YIXgO_rDj7zKmw,4098
|
|
9
|
-
cellarr_array-0.0.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
10
|
-
cellarr_array-0.0.2.dist-info/top_level.txt,sha256=oErp0D8ABZV-QPtTiXT8_F2z36Ic7ykuDg_1Y84HLZM,14
|
|
11
|
-
cellarr_array-0.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|