@@ -43,7 +43,9 @@ def serialize(self, data):
4343 """Convert the array data to a serialized binary format"""
4444 if isinstance (data .flatten ()[0 ], np .floating ):
4545 use_dtype = '<f4'
46- assert np .allclose (data .astype (use_dtype ), data , equal_nan = True ), \
46+ nan_mask = ~ np .isnan (data )
47+ assert np .allclose (
48+ data .astype (use_dtype )[nan_mask ], data [nan_mask ]), \
4749 'Converting the type should not screw things up.'
4850 elif isinstance (data .flatten ()[0 ], np .integer ):
4951 use_dtype = '<i4'
@@ -98,15 +100,25 @@ def validator(self, instance, proposed):
98100 proposed = np .array (proposed )
99101 if (proposed .dtype .kind == 'i' and
100102 len (set (self .dtype ).intersection (six .integer_types )) == 0 ):
101- raise ValueError ('{}: Array type must be int' .format (self .name ))
103+ raise ValueError (
104+ '{name}: Array type must be {type}' .format (
105+ name = self .name ,
106+ type = ', ' .join ([str (t ) for t in self .dtype ])
107+ )
108+ )
102109 if proposed .dtype .kind == 'f' and float not in self .dtype :
103- raise ValueError ('{}: Array type must be '
104- 'float' .format (self .name ))
110+ raise ValueError (
111+ '{name}: Array type must be {type}' .format (
112+ name = self .name ,
113+ type = ', ' .join ([str (t ) for t in self .dtype ])
114+ )
115+ )
105116 if len (self .shape ) != proposed .ndim :
106117 raise ValueError (
107118 '{}: Array must have {:d} dimensions ' '(shape: {})' .format (
108119 self .name , len (self .shape ), self .shape
109- ))
120+ )
121+ )
110122 for i , s in enumerate (self .shape ):
111123 if s != '*' and proposed .shape [i ] != s :
112124 raise ValueError ('{}: Array dimension {:d} must be '
0 commit comments