@@ -125,66 +125,6 @@ def shape(self):
125125 @shape .setter
126126 def shape (self , value ):
127127 self ._shape = value
128-
129- def _combine_slices (self , newslice ):
130- """
131- Combine existing ``extent`` attribute with a new set of slices.
132-
133- :param newslice: (tuple) A set of slices to apply to the data
134- 'Super-Lazily', i.e the slices will be combined with existing information
135- and applied later in the process.
136-
137- :returns: The combined set of slices.
138- """
139-
140- if len (newslice ) != len (self .shape ):
141- if hasattr (self , 'active' ):
142- # Mean has already been computed. Raise an error here
143- # since we should be down to dealing with numpy arrays now.
144- raise ValueError (
145- "Active chain broken - mean has already been accomplished."
146- )
147-
148- else :
149- raise ValueError (
150- "Compute chain broken - dimensions have been reduced already."
151- )
152-
153- def combine_sliced_dim (old , new , dim ):
154-
155- ostart = old .start or 0
156- ostop = old .stop or self .shape [dim ]
157- ostep = old .step or 1
158-
159- osize = (ostop - ostart )/ ostep
160-
161- nstart = new .start or 0
162- nstop = new .stop or self .shape [dim ]
163- nstep = new .step or 1
164-
165- nsize = (nstop - nstart )/ nstep
166-
167- if nsize > osize :
168- raise IndexError (
169- f'Attempted to slice dimension "{ dim } " with new slice "({ nstart } ,{ nstop } ,{ nstep } )'
170- f'but the dimension size is limited to { osize } .'
171- )
172-
173- start = ostart + ostep * nstart
174- step = ostep * nstep
175- stop = start + step * (nstop - nstart )
176-
177- return slice (start , stop , step )
178-
179-
180- if not self ._extent :
181- return newslice
182- else :
183- extent = list (self .get_extent ())
184- for dim in range (len (newslice )):
185- if not _identical_extents (extent [dim ], newslice [dim ], self .shape [dim ]):
186- extent [dim ] = combine_sliced_dim (extent [dim ], newslice [dim ], dim )
187- return extent
188128
189129 def get_extent (self ):
190130 return tuple (self ._extent )
@@ -198,7 +138,7 @@ def copy(self, extent=None):
198138 """
199139 kwargs = self .get_kwargs ()
200140 if extent :
201- kwargs ['extent' ] = self ._combine_slices ( extent )
141+ kwargs ['extent' ] = combine_slices ( self .shape , list ( self . get_extent ()), extent )
202142
203143 new_instance = SuperLazyArrayLike (
204144 self .shape ,
@@ -423,7 +363,7 @@ def copy(self, extent=None):
423363 """
424364 kwargs = self .get_kwargs ()
425365 if extent :
426- kwargs ['extent' ] = self ._combine_slices ( extent )
366+ kwargs ['extent' ] = combine_slices ( self .shape , list ( self . get_extent ()), extent )
427367
428368 new_instance = ArrayPartition (
429369 self .filename ,
0 commit comments