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)
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)
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)
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)
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)