Exemple #1
0
def test_dataframe_passed_to_Tensor_creates_tensor(data: List[List[primitive_types]]) -> None:
    dataframe = pd.DataFrame(columns=['A', 'B'], data=data)
    t = Tensor(dataframe)

    tensor_value = Tensor._to_ndarray(t.unwrap())
    dataframe_value = dataframe.values

    assert np.array_equal(tensor_value, dataframe_value)
Exemple #2
0
def test_series_passed_to_Tensor_creates_tensor(data: List[primitive_types]) -> None:
    series = pd.Series(data)
    t = Tensor(series)

    tensor_value = Tensor._to_ndarray(t.unwrap())
    series_value = series.values

    assert len(tensor_value) == len(series_value)
    assert tensor_value.shape == (len(series_value),)
    assert series_value.shape == (len(series_value),)

    assert np.array_equal(tensor_value.flatten(), series_value.flatten())
Exemple #3
0
def test_convert_java_tensor_to_ndarray(value: numpy_types) -> None:
    t = Tensor(value)
    ndarray = Tensor._to_ndarray(t.unwrap())

    assert type(ndarray) == np.ndarray
    assert (value == ndarray).all()
Exemple #4
0
def test_you_can_create_tensors(dtype):
    ones = np.ones((1, 1), dtype)
    t = Tensor(ones)
    ndarray = Tensor._to_ndarray(t.unwrap())
    assert (ones == ndarray).all()
Exemple #5
0
def test_you_can_create_boolean_tensor(value):
    bools = np.array(value)
    t = Tensor(bools)
    ndarray = Tensor._to_ndarray(t.unwrap())
    assert (bools == ndarray).all()