@@ -194,13 +194,23 @@ def reshape(self, shape):
194
194
``np.reshape(array_proxy, shape)``
195
195
'''
196
196
size = np .prod (self ._shape )
197
- if np .prod (shape ) != size :
197
+
198
+ # Calculate new shape if not fully specified
199
+ shape_arr = np .asarray (shape )
200
+ unknowns = shape_arr == - 1
201
+ if len (unknowns ) > 1 :
202
+ raise ValueError ("can only specify one unknown dimension" )
203
+ elif len (unknowns ) == 1 :
204
+ uk_val = size // np .prod (shape_arr [~ unknowns ])
205
+ shape_arr [unknowns ] = uk_val
206
+
207
+ if shape_arr .prod () != size :
198
208
raise ValueError ("cannot reshape array of size {:d} into shape "
199
209
"{!s}" .format (size , shape ))
200
- return ArrayProxy (file_like = self .file_like ,
201
- spec = (shape , self ._dtype , self ._offset ,
202
- self ._slope , self ._inter ),
203
- mmap = self ._mmap )
210
+ return self . __class__ (file_like = self .file_like ,
211
+ spec = (shape , self ._dtype , self ._offset ,
212
+ self ._slope , self ._inter ),
213
+ mmap = self ._mmap )
204
214
205
215
206
216
def is_proxy (obj ):
0 commit comments