Пример #1
0
def test_read_markers(
    usecols,
    shape_val,
    first_last_val,
    mean_val,
    median_val,
    sum_val,
    nans_val,
    extension,
):
    if extension == "csv":
        data = Markers.from_csv(**markers_csv_kwargs, usecols=usecols)
        decimal = 0
    elif extension == "c3d":
        data = Markers.from_c3d(MARKERS_ANALOGS_C3D,
                                prefix_delimiter=":",
                                usecols=usecols)
        decimal = 4
    else:
        raise ValueError("wrong extension provided")

    if usecols and isinstance(usecols[0], str):
        np.testing.assert_array_equal(x=data.channel, y=usecols)

    is_expected_array(
        data,
        shape_val,
        first_last_val,
        mean_val,
        median_val,
        sum_val,
        nans_val,
        decimal=decimal,
    )
Пример #2
0
def test_csv_without_header():
    is_expected_array(
        Analogs.from_csv(ANALOGS_CSV, first_row=5, first_column=2),
        **EXPECTED_VALUES[59],
    )

    is_expected_array(
        Markers.from_csv(MARKERS_CSV_WITHOUT_HEADER, first_column=2),
        **EXPECTED_VALUES[58],
    )
Пример #3
0
def test_read_catch_error(
    usecols,
    extension,
):
    with pytest.raises(IndexError):
        Markers.from_csv(MARKERS_CSV)

    if extension == "csv":
        with pytest.raises(ValueError):
            Analogs.from_csv(**analogs_csv_kwargs, usecols=usecols)
        with pytest.raises(ValueError):
            Markers.from_csv(**markers_csv_kwargs, usecols=usecols)
    elif extension == "c3d":
        with pytest.raises(ValueError):
            Analogs.from_c3d(MARKERS_ANALOGS_C3D, usecols=usecols)

    reader = getattr(Markers, f"from_{extension}")
    with pytest.raises(ValueError):
        reader(MARKERS_ANALOGS_C3D, usecols=usecols)