def test_numpy_deserializer_from_npy_object_array_with_allow_pickle_false(): numpy_deserializer = NumpyDeserializer(allow_pickle=False) array = np.array([{"a": "", "b": ""}, {"c": "", "d": ""}]) stream = io.BytesIO() np.save(stream, array) stream.seek(0) with pytest.raises(ValueError): numpy_deserializer.deserialize(stream, "application/x-npy")
def test_numpy_deserializer_from_json_alpha(): numpy_deserializer = NumpyDeserializer(dtype="U5") stream = io.BytesIO(b'[["hello",2,3],\n[4,5,6]]') array = numpy_deserializer.deserialize(stream, "application/json") assert np.array_equal(array, np.array([["hello", 2, 3], [4, 5, 6]]))
def test_numpy_deserializer_from_csv_alpha(): numpy_deserializer = NumpyDeserializer(dtype="U5") stream = io.BytesIO(b"hello,2,3\n4,5,6") array = numpy_deserializer.deserialize(stream, "text/csv") assert np.array_equal(array, np.array([["hello", 2, 3], [4, 5, 6]]))