@@ -152,21 +152,19 @@ def test_numpy_persistence(tmpdir, compress):
152
152
# And finally, check that all the values are equal.
153
153
np .testing .assert_array_equal (np .array (obj ), np .array (obj_ ))
154
154
155
- # Now test with array subclasses
156
- for obj in (np .matrix (np .zeros (10 )),
157
- np .memmap (filename + 'mmap' ,
158
- mode = 'w+' , shape = 4 , dtype = np .float64 )):
159
- filenames = numpy_pickle .dump (obj , filename , compress = compress )
160
- # All is cached in one file
161
- assert len (filenames ) == 1
155
+ # Now test with an array subclass
156
+ obj = np .memmap (filename + 'mmap' , mode = 'w+' , shape = 4 , dtype = np .float64 )
157
+ filenames = numpy_pickle .dump (obj , filename , compress = compress )
158
+ # All is cached in one file
159
+ assert len (filenames ) == 1
162
160
163
- obj_ = numpy_pickle .load (filename )
164
- if (type (obj ) is not np .memmap and
165
- hasattr (obj , '__array_prepare__' )):
166
- # We don't reconstruct memmaps
167
- assert isinstance (obj_ , type (obj ))
161
+ obj_ = numpy_pickle .load (filename )
162
+ if (type (obj ) is not np .memmap and
163
+ hasattr (obj , '__array_prepare__' )):
164
+ # We don't reconstruct memmaps
165
+ assert isinstance (obj_ , type (obj ))
168
166
169
- np .testing .assert_array_equal (obj_ , obj )
167
+ np .testing .assert_array_equal (obj_ , obj )
170
168
171
169
# Test with an object containing multiple numpy arrays
172
170
obj = ComplexTestObject ()
@@ -320,10 +318,8 @@ def test_memory_usage(tmpdir, compress):
320
318
filename = tmpdir .join ('test.pkl' ).strpath
321
319
small_array = np .ones ((10 , 10 ))
322
320
big_array = np .ones (shape = 100 * int (1e6 ), dtype = np .uint8 )
323
- small_matrix = np .matrix (small_array )
324
- big_matrix = np .matrix (big_array )
325
321
326
- for obj in (small_array , big_array , small_matrix , big_matrix ):
322
+ for obj in (small_array , big_array ):
327
323
size = obj .nbytes / 1e6
328
324
obj_filename = filename + str (np .random .randint (0 , 1000 ))
329
325
mem_used = memory_used (numpy_pickle .dump ,
@@ -349,11 +345,6 @@ def test_compressed_pickle_dump_and_load(tmpdir):
349
345
np .arange (5 , dtype = np .dtype ('>f8' )),
350
346
np .array ([1 , 'abc' , {'a' : 1 , 'b' : 2 }], dtype = 'O' ),
351
347
np .arange (256 , dtype = np .uint8 ).tobytes (),
352
- # np.matrix is a subclass of np.ndarray, here we want
353
- # to verify this type of object is correctly unpickled
354
- # among versions.
355
- np .matrix ([0 , 1 , 2 ], dtype = np .dtype ('<i8' )),
356
- np .matrix ([0 , 1 , 2 ], dtype = np .dtype ('>i8' )),
357
348
u"C'est l'\xe9 t\xe9 !" ]
358
349
359
350
fname = tmpdir .join ('temp.pkl.gz' ).strpath
@@ -686,9 +677,7 @@ def test_compression_using_file_extension(tmpdir, extension, cmethod):
686
677
687
678
@with_numpy
688
679
def test_file_handle_persistence (tmpdir ):
689
- objs = [np .random .random ((10 , 10 )),
690
- "some data" ,
691
- np .matrix ([0 , 1 , 2 ])]
680
+ objs = [np .random .random ((10 , 10 )), "some data" ]
692
681
fobjs = [bz2 .BZ2File , gzip .GzipFile ]
693
682
if lzma is not None :
694
683
fobjs += [lzma .LZMAFile ]
@@ -719,9 +708,7 @@ def test_file_handle_persistence(tmpdir):
719
708
720
709
@with_numpy
721
710
def test_in_memory_persistence ():
722
- objs = [np .random .random ((10 , 10 )),
723
- "some data" ,
724
- np .matrix ([0 , 1 , 2 ])]
711
+ objs = [np .random .random ((10 , 10 )), "some data" ]
725
712
for obj in objs :
726
713
f = io .BytesIO ()
727
714
numpy_pickle .dump (obj , f )
0 commit comments