Beispiel #1
0
def test_check_1d_series():
    x = pd.Series([1, 2, 3])
    assert check_1d(x)
    y = pd.Series([1, [2, 3]])
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
    y = pd.Series([[1], [2, 3]])
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
Beispiel #2
0
def test_check_1d_array():
    x = np.array([1, 2, 3])
    assert check_1d(x)
    y = np.array([[1, 2], [1, 2, 3]])
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
    y = np.array([0, [1, 2, 3]])
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
Beispiel #3
0
def test_check_1d_dataframe():
    x = pd.DataFrame({'x': [1, 2, 3]})
    assert check_1d(x)
    y = pd.DataFrame({'x': [1, 2, 3], 'y': [1, 2, 3]})
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
    y = pd.DataFrame({'x': [1, 2, 3, [4, 5]]})
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
Beispiel #4
0
def test_check_1d_list():
    x = [1, 2, 3]
    assert check_1d(x)
    y = [[1, 2], [1, 2, 3]]
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
    y = [1, [1, 2, 3]]
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
Beispiel #5
0
def test_check_1d_dataframe():
    """
    Test.
    """
    x = pd.DataFrame({"x": [1, 2, 3]})
    assert check_1d(x)
    y = pd.DataFrame({"x": [1, 2, 3], "y": [1, 2, 3]})
    with pytest.raises(DimensionalityError):
        assert check_1d(y)
    y = pd.DataFrame({"x": [1, 2, 3, [4, 5]]})
    with pytest.raises(DimensionalityError):
        assert check_1d(y)