Skip to content

Commit 71cf738

Browse files
author
Balaji Veeramani
committed
Address review comments
1 parent 1f7f103 commit 71cf738

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/sagemaker/serializers.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,32 @@ def serialize(self, data):
6464
file, or buffer.
6565
6666
Returns:
67-
_io.BytesIO: A buffer containing data serialzied in the .npy format.
67+
io.BytesIO: A buffer containing data serialzied in the .npy format.
6868
"""
6969
if isinstance(data, np.ndarray):
7070
if not data.size > 0:
7171
raise ValueError("Cannot serialize empty array.")
72-
return self.serialize_array(data)
72+
return self._serialize_array(data)
7373

7474
if isinstance(data, list):
7575
if not len(data) > 0:
76-
raise ValueError("empty array can't be serialized")
77-
return self.serialize_array(np.array(data, self.dtype))
76+
raise ValueError("Cannot serialize empty array.")
77+
return self._serialize_array(np.array(data, self.dtype))
7878

7979
# files and buffers. Assumed to hold npy-formatted data.
8080
if hasattr(data, "read"):
8181
return data.read()
8282

83-
return self.serialize_array(np.array(data))
83+
return self._serialize_array(np.array(data))
8484

85-
@staticmethod
86-
def serialize_array(array):
85+
def _serialize_array(self, array):
8786
"""Saves a NumPy array in a buffer.
8887
8988
Args:
9089
array (numpy.ndarray): The array to serialize.
9190
9291
Returns:
93-
_io.BytesIO: A buffer containing the serialized array.
92+
io.BytesIO: A buffer containing the serialized array.
9493
"""
9594
buffer = io.BytesIO()
9695
np.save(buffer, array)

0 commit comments

Comments
 (0)