File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -63,11 +63,8 @@ def serialize(self, data):
63
63
if hasattr (data , "read" ):
64
64
return data .read ()
65
65
66
- def is_sequence_like (obj ):
67
- return hasattr (obj , "__iter__" ) and hasattr (obj , "__getitem__" )
68
-
69
- is_mutable_sequence_like = is_sequence_like (data ) and hasattr (data , "__setitem__" )
70
- has_multiple_rows = len (data ) > 0 and is_sequence_like (data [0 ])
66
+ is_mutable_sequence_like = self ._is_sequence_like (data ) and hasattr (data , "__setitem__" )
67
+ has_multiple_rows = len (data ) > 0 and self ._is_sequence_like (data [0 ])
71
68
72
69
if is_mutable_sequence_like and has_multiple_rows :
73
70
return "\n " .join ([self ._serialize_row (row ) for row in data ])
@@ -99,6 +96,10 @@ def _serialize_row(self, data):
99
96
100
97
raise ValueError ("Unable to handle input format: " , type (data ))
101
98
99
+ def _is_sequence_like (self , data ):
100
+ """Returns true if obj is iterable and subscriptable."""
101
+ return hasattr (data , "__iter__" ) and hasattr (data , "__getitem__" )
102
+
102
103
103
104
class NumpySerializer (BaseSerializer ):
104
105
"""Serialize data to a buffer using the .npy format."""
You can’t perform that action at this time.
0 commit comments