Esempio n. 1
0
def test_numpy_deser_from_npy():
    array = np.ones((2, 3))
    stream = io.BytesIO()
    np.save(stream, array)
    stream.seek(0)

    result = numpy_deserializer(stream)

    assert np.array_equal(array, result)
Esempio n. 2
0
def test_numpy_deser_from_npy_object_array():
    array = np.array(["one", "two"])
    stream = io.BytesIO()
    np.save(stream, array)
    stream.seek(0)

    result = numpy_deserializer(stream)

    assert np.array_equal(array, result)
def test_numpy_deser_from_npy_object_array():
    array = np.array(['one', 'two'])
    stream = io.BytesIO()
    np.save(stream, array)
    stream.seek(0)

    result = numpy_deserializer(stream)

    assert np.array_equal(array, result)
def test_numpy_deser_from_npy():
    array = np.ones((2, 3))
    stream = io.BytesIO()
    np.save(stream, array)
    stream.seek(0)

    result = numpy_deserializer(stream)

    assert np.array_equal(array, result)
Esempio n. 5
0
def test_numpy_deser_from_json_ragged():
    arr = numpy_deserializer(io.BytesIO(b"[[1,2,3],\n[4,5,6,7]]"),
                             "application/json")
    assert np.array_equal(arr, np.array([[1, 2, 3], [4, 5, 6, 7]]))
Esempio n. 6
0
def test_numpy_deser_from_csv_ragged():
    with pytest.raises(ValueError) as error:
        numpy_deserializer(io.BytesIO(b"1,2,3\n4,5,6,7"), "text/csv")
    assert "errors were detected" in str(error)
Esempio n. 7
0
def test_numpy_deser_from_csv():
    arr = numpy_deserializer(io.BytesIO(b"1,2,3\n4,5,6"), "text/csv")
    assert np.array_equal(arr, np.array([[1, 2, 3], [4, 5, 6]]))
Esempio n. 8
0
def test_numpy_deser_from_json():
    arr = numpy_deserializer(io.BytesIO(b'[[1,2,3],\n[4,5,6]]'), 'application/json')
    assert np.array_equal(arr, np.array([[1, 2, 3], [4, 5, 6]]))
def test_numpy_deser_from_json_ragged():
    arr = numpy_deserializer(io.BytesIO(b'[[1,2,3],\n[4,5,6,7]]'), 'application/json')
    assert np.array_equal(arr, np.array([[1, 2, 3], [4, 5, 6, 7]]))
def test_numpy_deser_from_csv_ragged():
    with pytest.raises(ValueError) as error:
        numpy_deserializer(io.BytesIO(b'1,2,3\n4,5,6,7'), 'text/csv')
    assert "errors were detected" in str(error)
def test_numpy_deser_from_csv():
    arr = numpy_deserializer(io.BytesIO(b'1,2,3\n4,5,6'), 'text/csv')
    assert np.array_equal(arr, np.array([[1, 2, 3], [4, 5, 6]]))