Minor updates #229
GitHub Actions / JUnit Test Report
failed
Sep 25, 2024 in 0s
21 tests run, 20 passed, 0 skipped, 1 failed.
Annotations
Check failure on line 196 in .tox/py310/lib/python3.10/site-packages/dask/tests/test_cli.py
github-actions / JUnit Test Report
test_cli.test_adapt
AssertionError:
Not equal to tolerance rtol=1e-05, atol=0
Mismatched elements: 2 / 2 (100%)
Max absolute difference: 72.841806
Max relative difference: 1.
x: array([0., 0.])
y: array([-72.841806, -71.32893 ])
Raw output
cli_runner = <click.testing.CliRunner object at 0x7f0fd8025030>
tmpdir = local('/home/runner/work/emodel-generalisation/emodel-generalisation/.tox/py310/tmp/test_adapt0')
def test_adapt(cli_runner, tmpdir):
"""Test cli adapt."""
# fmt: off
response = cli_runner.invoke(
tested.cli,
[
"-v", "adapt",
"--input-node-path", str(DATA / "sonata_v6.h5"),
"--output-node-path", str(tmpdir / "sonata_v6_adapted.h5"),
"--morphology-path", str(DATA / "morphologies"),
"--config-path", str(DATA / "config"),
"--final-path", str(DATA / "final.json"),
"--local-dir", str(tmpdir / 'local'),
"--output-hoc-path", str(tmpdir / "hoc"),
"--min-scale", 0.9,
"--max-scale", 1.1,
],
)
# fmt: on
assert response.exit_code == 0
df = pd.read_csv(tmpdir / "local" / "adapt_df.csv")
# df.drop(columns=["path"]).to_csv(DATA / "adapt_df.csv", index=None)
expected_df = pd.read_csv(DATA / "adapt_df.csv")
assert df.loc[0, "ais_scaler"] == expected_df.loc[0, "ais_scaler"]
assert df.loc[0, "soma_scaler"] == expected_df.loc[0, "soma_scaler"]
assert df.loc[0, "ais_model"] == expected_df.loc[0, "ais_model"]
assert df.loc[0, "soma_model"] == expected_df.loc[0, "soma_model"]
# retest evaluate with ais and soma scalers
# fmt: off
response = cli_runner.invoke(
tested.cli,
[
"-v", "evaluate",
"--input-path", str(tmpdir / "sonata_v6_adapted.h5"),
"--output-path", str(tmpdir / "adapted_evaluation_df.csv"),
"--morphology-path", str(DATA / "morphologies"),
"--config-path", str(DATA / "config"),
"--local-dir", str(tmpdir / 'local'),
"--final-path", str(DATA / "final.json"),
],
)
# fmt: on
assert response.exit_code == 0
df = pd.read_csv(tmpdir / "adapted_evaluation_df.csv")
# df.drop(columns=["path"]).to_csv(DATA / "adapted_evaluation_df.csv", index=None)
expected_df = pd.read_csv(DATA / "adapted_evaluation_df.csv")
for f, f_exp in zip(
json.loads(df.loc[0, "features"]).values(),
json.loads(expected_df.loc[0, "features"]).values(),
):
npt.assert_allclose(f, f_exp, rtol=1e-1)
for f, f_exp in zip(
json.loads(df.loc[1, "features"]).values(),
json.loads(expected_df.loc[1, "features"]).values(),
):
npt.assert_allclose(f, f_exp, rtol=1e-1)
for f, f_exp in zip(
json.loads(df.loc[0, "scores"]).values(), json.loads(expected_df.loc[0, "scores"]).values()
):
npt.assert_allclose(f, f_exp, rtol=1e-1)
for f, f_exp in zip(
json.loads(df.loc[1, "scores"]).values(), json.loads(expected_df.loc[1, "scores"]).values()
):
npt.assert_allclose(f, f_exp, rtol=1e-1)
# fmt: off
response = cli_runner.invoke(
tested.cli,
[
"-v", "compute_currents",
"--input-path", str(tmpdir / "sonata_v6_adapted.h5"),
"--output-path", str(tmpdir / "sonata_currents_adapted.h5"),
"--morphology-path", str(DATA / "morphologies"),
"--protocol-config-path", str(DATA / "protocol_config.yaml"),
"--hoc-path", str(tmpdir / "hoc"),
],
)
# fmt: on
assert response.exit_code == 0
df = CellCollection().load_sonata(tmpdir / "sonata_currents_adapted.h5").as_dataframe()
> npt.assert_allclose(
df["@dynamics:resting_potential"].to_list(),
[-72.841806, -71.32893],
rtol=1e-5,
)
tests/test_cli.py:196:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<function assert_allclose.<locals>.compare at 0x7f0fd782a7a0>, array([0., 0.]), array([-72.841806, -71.32893 ]))
kwds = {'equal_nan': True, 'err_msg': '', 'header': 'Not equal to tolerance rtol=1e-05, atol=0', 'verbose': True}
@wraps(func)
def inner(*args, **kwds):
with self._recreate_cm():
> return func(*args, **kwds)
E AssertionError:
E Not equal to tolerance rtol=1e-05, atol=0
E
E Mismatched elements: 2 / 2 (100%)
E Max absolute difference: 72.841806
E Max relative difference: 1.
E x: array([0., 0.])
E y: array([-72.841806, -71.32893 ])
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/contextlib.py:79: AssertionError
Loading