@@ -998,32 +998,30 @@ def test_header_growth_axis():
998
998
999
999
assert len (fp .getvalue ()) == expected_header_length
1000
1000
1001
- @pytest .mark .parametrize ('dt, fail ' , [
1002
- ( np .dtype ({'names' : ['a' , 'b' ], 'formats' : [float , np .dtype ('S3' ,
1003
- metadata = {'some' : 'stuff' })]}), True ),
1004
- ( np .dtype (int , metadata = {'some' : 'stuff' }), False ),
1005
- ( np .dtype ([('subarray' , (int , (2 ,)))], metadata = {'some' : 'stuff' }), False ),
1001
+ @pytest .mark .parametrize ('dt' , [
1002
+ np .dtype ({'names' : ['a' , 'b' ], 'formats' : [float , np .dtype ('S3' ,
1003
+ metadata = {'some' : 'stuff' })]}),
1004
+ np .dtype (int , metadata = {'some' : 'stuff' }),
1005
+ np .dtype ([('subarray' , (int , (2 ,)))], metadata = {'some' : 'stuff' }),
1006
1006
# recursive: metadata on the field of a dtype
1007
- ( np .dtype ({'names' : ['a' , 'b' ], 'formats' : [
1007
+ np .dtype ({'names' : ['a' , 'b' ], 'formats' : [
1008
1008
float , np .dtype ({'names' : ['c' ], 'formats' : [np .dtype (int , metadata = {})]})
1009
- ]}), False )
1009
+ ]}),
1010
1010
])
1011
1011
@pytest .mark .skipif (IS_PYPY and sys .implementation .version <= (7 , 3 , 8 ),
1012
1012
reason = "PyPy bug in error formatting" )
1013
- def test_metadata_dtype (dt , fail ):
1013
+ def test_metadata_dtype (dt ):
1014
1014
# gh-14142
1015
1015
arr = np .ones (10 , dtype = dt )
1016
1016
buf = BytesIO ()
1017
1017
with assert_warns (UserWarning ):
1018
1018
np .save (buf , arr )
1019
1019
buf .seek (0 )
1020
- if fail :
1021
- with assert_raises (ValueError ):
1022
- np .load (buf )
1023
- else :
1024
- arr2 = np .load (buf )
1025
- # BUG: assert_array_equal does not check metadata
1026
- from numpy .lib ._utils_impl import drop_metadata
1027
- assert_array_equal (arr , arr2 )
1028
- assert drop_metadata (arr .dtype ) is not arr .dtype
1029
- assert drop_metadata (arr2 .dtype ) is arr2 .dtype
1020
+
1021
+ # Loading should work (metadata was stripped):
1022
+ arr2 = np .load (buf )
1023
+ # BUG: assert_array_equal does not check metadata
1024
+ from numpy .lib ._utils_impl import drop_metadata
1025
+ assert_array_equal (arr , arr2 )
1026
+ assert drop_metadata (arr .dtype ) is not arr .dtype
1027
+ assert drop_metadata (arr2 .dtype ) is arr2 .dtype
0 commit comments