@@ -26,9 +26,11 @@ class test_numpy_msgpack(TestCase):
26
26
def setUp (self ):
27
27
patch ()
28
28
29
- def encode_decode (self , x , use_bin_type = False , raw = True ):
29
+ def encode_decode (self , x , use_bin_type = False , raw = True ,
30
+ use_list = True , max_bin_len = - 1 ):
30
31
x_enc = msgpack .packb (x , use_bin_type = use_bin_type )
31
- return msgpack .unpackb (x_enc , raw = raw )
32
+ return msgpack .unpackb (x_enc , raw = raw , use_list = use_list ,
33
+ max_bin_len = max_bin_len )
32
34
33
35
def encode_thirdparty (self , obj ):
34
36
return dict (__thirdparty__ = True , foo = obj .foo )
@@ -38,10 +40,13 @@ def decode_thirdparty(self, obj):
38
40
return ThirdParty (foo = obj [b'foo' ])
39
41
return obj
40
42
41
- def encode_decode_thirdparty (self , x , use_bin_type = False , raw = True ):
43
+ def encode_decode_thirdparty (self , x , use_bin_type = False , raw = True ,
44
+ use_list = True , max_bin_len = - 1 ):
42
45
x_enc = msgpack .packb (x , default = self .encode_thirdparty ,
43
46
use_bin_type = use_bin_type )
44
- return msgpack .unpackb (x_enc , raw = raw , object_hook = self .decode_thirdparty )
47
+ return msgpack .unpackb (x_enc , raw = raw ,
48
+ object_hook = self .decode_thirdparty ,
49
+ use_list = use_list , max_bin_len = max_bin_len )
45
50
46
51
def test_bin (self ):
47
52
# Since bytes == str in Python 2.7, the following
@@ -195,6 +200,16 @@ def test_numpy_array_float_2d(self):
195
200
assert_array_equal (x , x_rec )
196
201
assert_equal (x .dtype , x_rec .dtype )
197
202
203
+ def test_numpy_array_float_2d_macos (self ):
204
+ """
205
+ Unit test for weird data loss error on MacOS (#35).
206
+ """
207
+ x = np .random .rand (5 ,5 ).astype (np .float32 )
208
+ x_rec = self .encode_decode (x , use_bin_type = True , raw = False ,
209
+ use_list = False , max_bin_len = 50000000 )
210
+ assert_array_equal (x , x_rec )
211
+ assert_equal (x .dtype , x_rec .dtype )
212
+
198
213
def test_numpy_array_str (self ):
199
214
x = np .array ([b'aaa' , b'bbbb' , b'ccccc' ])
200
215
x_rec = self .encode_decode (x )
0 commit comments