Exemple #1
0
def test_is_shape():
    shape = 10, 2
    df = pd.DataFrame(np.random.randn(*shape))
    tm.assert_frame_equal(df, ck.is_shape(df, shape))
    result = dc.is_shape(shape=shape)(_add_n)(df)
    tm.assert_frame_equal(result, df + 1)

    with pytest.raises(AssertionError):
        ck.is_shape(df, (9, 2))
    with pytest.raises(AssertionError):
        dc.is_shape((9, 2))(_add_n)(df)
Exemple #2
0
def test_is_shape():
    shape = 10, 2
    ig_0 = -1, 2
    ig_1 = 10, -1
    ig_2 = None, 2
    ig_3 = 10, None
    shapes = [shape, ig_0, ig_1, ig_2, ig_3]
    df = pd.DataFrame(np.random.randn(*shape))
    for shp in shapes:
        tm.assert_frame_equal(df, ck.is_shape(df, shp))
    for shp in shapes:
        result = dc.is_shape(shape=shp)(_add_n)(df)
        tm.assert_frame_equal(result, df + 1)

    with pytest.raises(AssertionError):
        ck.is_shape(df, (9, 2))
    with pytest.raises(AssertionError):
        dc.is_shape((9, 2))(_add_n)(df)
Exemple #3
0
def test_is_shape():
    shape = 10, 2
    ig_0 = -1, 2
    ig_1 = 10, -1
    ig_2 = None, 2
    ig_3 = 10, None
    shapes = [shape, ig_0, ig_1, ig_2, ig_3]
    df = pd.DataFrame(np.random.randn(*shape))
    for shp in shapes:
        tm.assert_frame_equal(df, ck.is_shape(df, shp))
    for shp in shapes:
        result = dc.is_shape(shape=shp)(_add_n)(df)
        tm.assert_frame_equal(result, df + 1)

    with pytest.raises(AssertionError):
        ck.is_shape(df, (9, 2))
    with pytest.raises(AssertionError):
        dc.is_shape((9, 2))(_add_n)(df)
def read_file(file_path):
    if file_path.lower().endswith(".json"):
        feedback = pd.read_json(file_path)
        ec.is_shape(feedback, (-1, 5))
    elif file_path.lower().endswith(".csv"):
        feedback = pd.read_csv(file_path)
        ec.is_shape(feedback, (-1, 6))
    else:
        raise ValueError("This file format is not supported yet.")

    try:
        ec.none_missing(feedback, [
            "message", "airline_code", "number_of_fellow_passengers",
            "did_receive_compensation", "total_compensation_amount"
        ])
    except AssertionError:
        print("Missing values")

    return feedback
Exemple #5
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     ck.is_shape(result, shape)
     return result
Exemple #6
0
 def wrapper(*args, **kwargs):
     result = func(*args, **kwargs)
     ck.is_shape(result, shape)
     return result