Skip to content

Commit 0ca15a0

Browse files
committed
Removed dropped_extent, now extent keeps integer indexes, shape reflects 'true' size
1 parent 1ba10e9 commit 0ca15a0

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

arraypartition/partition.py

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,8 @@ def _smooth_extent(self, extent):
150150
Replace values of None within each provided slice of the extent with integer
151151
values derived from the current shape.
152152
"""
153-
if len(extent) != self.ndim:
154-
# Ignore dimensions that have already been dropped
155-
extent = [e for e in extent if isinstance(e,slice)]
156153

157-
if len(extent) != self.ndim:
154+
if len(extent) < self.ndim:
158155
raise ValueError(
159156
'Direct assignment of truncated extent is not supported.'
160157
)
@@ -208,7 +205,6 @@ def __init__(self,
208205
position: Union[tuple,None] = None,
209206
extent: Union[tuple,None] = None,
210207
format: Union[str,None] = None,
211-
dropped_extent: Union[tuple,None] = None,
212208
**kwargs
213209
):
214210

@@ -261,15 +257,11 @@ def __init__(self,
261257

262258
super().__init__(shape, **kwargs)
263259

264-
self._dropped_extent = dropped_extent or [None for i in shape]
265-
266260
if extent:
267-
for x, ext in enumerate(extent):
268-
if isinstance(ext, int):
269-
self._dropped_extent[x] = ext
270-
271261
# Apply a specific extent if given by the initiator
272262
self.set_extent(extent)
263+
264+
pass
273265

274266
def __array__(self, *args, **kwargs):
275267
"""
@@ -296,18 +288,13 @@ def __array__(self, *args, **kwargs):
296288
if hasattr(array, 'units'):
297289
self.units = array.units
298290

299-
apply_ext = self._extent
300291
if len(array.shape) != len(self._extent):
301-
apply_ext = self._correct_slice(array.dimensions)
302-
303-
print(f'Applying Extent {apply_ext} to {self.address}')
304-
print(array)
305-
print(self.filename)
292+
self._correct_slice(array.dimensions)
306293

307294
try:
308295
# Still allowed to request a specific dtype
309296
# Otherwise dtype casting prevented
310-
var = np.array(array[tuple(apply_ext)], dtype=dtype)
297+
var = np.array(array[tuple(self._extent)], dtype=dtype)
311298
except IndexError:
312299
raise ValueError(
313300
f"Unable to select required 'extent' of {self.extent} "
@@ -362,20 +349,15 @@ def _correct_slice(self, array_dims: tuple):
362349
set in ``named_dims`` then this function is used to remove extra
363350
dimensions from the ``extent`` if possible.
364351
"""
352+
return
365353
extent = []
366-
dimcount = 0
367-
for dim in range(len(self._dropped_extent)):
368-
369-
if self._dropped_extent[dim] is not None:
370-
extent.append(self._dropped_extent[dim])
371-
continue
354+
for dim in range(len(self.named_dims)):
372355

373356
named_dim = self.named_dims[dim]
374357
if named_dim in array_dims:
375-
extent.append(self._extent[dimcount])
358+
extent.append(self._extent[dim])
376359

377-
dimcount += 1
378-
return extent
360+
self._extent = extent
379361

380362
def _post_process_data(self, data: np.array):
381363
"""
@@ -427,7 +409,6 @@ def get_kwargs(self):
427409
'position': self.position,
428410
'extent': self._extent,
429411
'format': self.format,
430-
'dropped_extent':self._dropped_extent
431412
} | super().get_kwargs()
432413

433414
def copy(self, extent: Union[tuple,None] = None):

0 commit comments

Comments
 (0)