Ejemplo n.º 1
0
def test_convert_data(data):
    assert np.allclose(data, dcst_private._convert_data(data), atol=atol)

    df = pd.DataFrame({"test": data})
    assert np.allclose(data,
                       dcst_private._convert_data(df.loc[:, "test"]),
                       atol=atol)
    with pytest.raises(RuntimeError) as excinfo:
        dcst_private._convert_data(df)
    excinfo.match("Input must be a 1D array or Pandas series.")

    s = pd.Series(data)
    assert np.allclose(data, dcst_private._convert_data(s), atol=atol)
Ejemplo n.º 2
0
def test_convert_data_edge():
    x = np.array([1, 2, np.nan, 4])
    x_correct = np.array([1, 2, 4])
    x = dcst_private._convert_data(x)
    assert np.allclose(x, x_correct, atol=atol)

    x = np.array([1, 2, np.inf, 4])
    with pytest.raises(RuntimeError) as excinfo:
        dcst_private._convert_data(x, inf_ok=False)
    excinfo.match("All entries must be finite.")

    x_correct = np.array([1, 2, np.inf, 4])
    x = dcst_private._convert_data(x_correct, inf_ok=True)
    assert np.allclose(x, x_correct, atol=atol)
Ejemplo n.º 3
0
def test_convert_data_scalar(data):
    conv_data = dcst_private._convert_data(data)
    assert type(conv_data) == np.ndarray
    assert len(conv_data) == 1
    assert np.isclose(conv_data[0], data, atol=atol)