Scikit-learn
human-activity-recognition
wearable
wrist
time-series
cpu
scikit-learn
WISP / tests /test_installed.py
Zipeng365's picture
wisp-har 0.4.0: WISP-Funnel search and the adaptive HMM switch (default decoder)
93a9282 verified
Raw History Blame Contribute Delete
1.63 kB
"""When run against an installed wheel (WISP_EXPECT_INSTALLED=1), check what is imported."""
import importlib.util
import os
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
@pytest.mark.skipif(os.environ.get("WISP_EXPECT_INSTALLED") != "1", reason="only for installed-wheel runs")
def test_imports_resolve_outside_source_tree():
import wisp
import wisp_fast
import wisp_release
for mod in (wisp, wisp_fast, wisp_release):
assert ROOT / "src" not in Path(mod.__file__).resolve().parents, mod.__file__
assert wisp.__version__ == "0.4.0"
@pytest.mark.skipif(os.environ.get("WISP_EXPECT_NATIVE") not in ("0", "1"), reason="native expectation not set")
def test_native_kernels_presence():
names = ("_kernels", "_family_kernels", "_cis_intervals", "_cis_conv",
"funnel._kernels", "funnel._family_kernels", "funnel._cis_intervals", "funnel._cis_lite")
found = [importlib.util.find_spec(f"wisp_fast.{n}") is not None for n in names]
if os.environ["WISP_EXPECT_NATIVE"] == "1":
assert all(found), found
else:
assert not any(found), found
def test_public_names():
import wisp
for name in ("WISPClassifier", "WISPRepresentation", "HMMSmoother", "WISPSelect", "WISPSearch",
"recipes", "blocks", "adapters", "datasets", "hub", "metrics"):
assert getattr(wisp, name) is not None
with pytest.raises(NotImplementedError):
wisp.hub.load_pretrained(method="random", dataset="adl", fold=0, seed=42)
from wisp.cli import main
assert main(["recipes", "--source", "fixed"]) == 0