@@ -152,21 +152,19 @@ def test_numpy_persistence(tmpdir, compress):
152152 # And finally, check that all the values are equal.
153153 np .testing .assert_array_equal (np .array (obj ), np .array (obj_ ))
154154
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
162160
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 ))
168166
169- np .testing .assert_array_equal (obj_ , obj )
167+ np .testing .assert_array_equal (obj_ , obj )
170168
171169 # Test with an object containing multiple numpy arrays
172170 obj = ComplexTestObject ()
@@ -320,10 +318,8 @@ def test_memory_usage(tmpdir, compress):
320318 filename = tmpdir .join ('test.pkl' ).strpath
321319 small_array = np .ones ((10 , 10 ))
322320 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 )
325321
326- for obj in (small_array , big_array , small_matrix , big_matrix ):
322+ for obj in (small_array , big_array ):
327323 size = obj .nbytes / 1e6
328324 obj_filename = filename + str (np .random .randint (0 , 1000 ))
329325 mem_used = memory_used (numpy_pickle .dump ,
@@ -349,11 +345,6 @@ def test_compressed_pickle_dump_and_load(tmpdir):
349345 np .arange (5 , dtype = np .dtype ('>f8' )),
350346 np .array ([1 , 'abc' , {'a' : 1 , 'b' : 2 }], dtype = 'O' ),
351347 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' )),
357348 u"C'est l'\xe9 t\xe9 !" ]
358349
359350 fname = tmpdir .join ('temp.pkl.gz' ).strpath
@@ -686,9 +677,7 @@ def test_compression_using_file_extension(tmpdir, extension, cmethod):
686677
687678@with_numpy
688679def 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" ]
692681 fobjs = [bz2 .BZ2File , gzip .GzipFile ]
693682 if lzma is not None :
694683 fobjs += [lzma .LZMAFile ]
@@ -719,9 +708,7 @@ def test_file_handle_persistence(tmpdir):
719708
720709@with_numpy
721710def 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" ]
725712 for obj in objs :
726713 f = io .BytesIO ()
727714 numpy_pickle .dump (obj , f )
0 commit comments