21
21
RecordDeserializer ,
22
22
write_numpy_to_dense_tensor ,
23
23
read_recordio ,
24
- numpy_to_record_serializer ,
24
+ RecordSerializer ,
25
25
write_spmatrix_to_sparse_tensor ,
26
26
)
27
27
from sagemaker .amazon .record_pb2 import Record
28
28
29
29
30
30
def test_serializer ():
31
- s = numpy_to_record_serializer ()
31
+ s = RecordSerializer ()
32
32
array_data = [[1.0 , 2.0 , 3.0 ], [10.0 , 20.0 , 30.0 ]]
33
- buf = s (np .array (array_data ))
33
+ buf = s . serialize (np .array (array_data ))
34
34
for record_data , expected in zip (read_recordio (buf ), array_data ):
35
35
record = Record ()
36
36
record .ParseFromString (record_data )
37
37
assert record .features ["values" ].float64_tensor .values == expected
38
38
39
39
40
40
def test_serializer_accepts_one_dimensional_array ():
41
- s = numpy_to_record_serializer ()
41
+ s = RecordSerializer ()
42
42
array_data = [1.0 , 2.0 , 3.0 ]
43
- buf = s (np .array (array_data ))
43
+ buf = s . serialize (np .array (array_data ))
44
44
record_data = next (read_recordio (buf ))
45
45
record = Record ()
46
46
record .ParseFromString (record_data )
@@ -49,8 +49,8 @@ def test_serializer_accepts_one_dimensional_array():
49
49
50
50
def test_deserializer ():
51
51
array_data = [[1.0 , 2.0 , 3.0 ], [10.0 , 20.0 , 30.0 ]]
52
- s = numpy_to_record_serializer ()
53
- buf = s (np .array (array_data ))
52
+ s = RecordSerializer ()
53
+ buf = s . serialize (np .array (array_data ))
54
54
d = RecordDeserializer ()
55
55
for record , expected in zip (d .deserialize (buf , "who cares" ), array_data ):
56
56
assert record .features ["values" ].float64_tensor .values == expected
0 commit comments