Skip to content

Commit b8799dc

Browse files
author
Balaji Veeramani
committed
Address review comments
1 parent 522333b commit b8799dc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/sagemaker/serializers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ def serialize(self, data):
6363
if hasattr(data, "read"):
6464
return data.read()
6565

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])
7168

7269
if is_mutable_sequence_like and has_multiple_rows:
7370
return "\n".join([self._serialize_row(row) for row in data])
@@ -99,6 +96,10 @@ def _serialize_row(self, data):
9996

10097
raise ValueError("Unable to handle input format: ", type(data))
10198

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+
102103

103104
class NumpySerializer(BaseSerializer):
104105
"""Serialize data to a buffer using the .npy format."""

0 commit comments

Comments
 (0)