tslearn
tslearn copied to clipboard
Contributing.MD no longer contains instructions to run tests locally
It seems that the Contributing.MD file has been updated, but no longer includes a section that explains how to run the tests locally. I think that is an important section for new contributors in order to test their code locally first before pushing it to the main branch.
I am somewhat struggling to run the tests locally with pytest as well. In order to make it work, I somehow had to delete the init files in the tslearn/
and tslearn/tests
directories.
I guess a good start would be to take inspiration from the Azure Pipeline YAML file, no ?
Yes that's what I did indeed, but just running pytest from the root directory gave me ModuleNotFoundError
s. They were all related to importing cydist_sax:
_____________________________________________________________________________ ERROR collecting tslearn/tests/test_serialize_models.py _____________________________________________________________________________
ImportError while importing test module '/home/gilles/Projects/tslearn/tslearn/tests/test_serialize_models.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tslearn/tests/test_serialize_models.py:9: in <module>
from tslearn.neighbors import KNeighborsTimeSeries, \
tslearn/neighbors/__init__.py:6: in <module>
from .neighbors import (
tslearn/neighbors/neighbors.py:9: in <module>
from tslearn.metrics import cdist_dtw, cdist_ctw, cdist_soft_dtw, \
tslearn/metrics/__init__.py:18: in <module>
from .sax import cdist_sax
tslearn/metrics/sax.py:2: in <module>
from .cysax import cydist_sax
E ModuleNotFoundError: No module named 'tslearn.metrics.cysax'
__________________________________________________________________
Only after deleting the init file in both tslearn/
and tslearn/tests
, this issue was resolved. I'm not sure if that is because of my environment, or something everyone will have to do...
@GillesVandewiele @rtavenar I think I am getting the same issue #413
@rtavenar @GillesVandewiele After banging my head several times to a wall, I think the following steps helped me solve the issue!
$pip install pytest-cython
$CC=gcc python setup.py build_ext --inplace
And, then:
$pytest tslearn/tests/test_metrics.py
============================= test session starts =============================
platform win32 -- Python 3.8.5, pytest-7.1.2, pluggy-1.0.0
rootdir: E:\+Machine_Learning_Journey\contributions\tslearn, configfile: setup.cfg
plugins: anyio-3.5.0, cython-0.2.0
collected 16 items
tslearn\tests\test_metrics.py ................ [100%]
============================== warnings summary ===============================
<frozen importlib._bootstrap>:219
<frozen importlib._bootstrap>:219: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 80 from C header, got 88 from PyObject
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 16 passed, 1 warning in 7.56s ========================
I saw this github issue and tried out the steps above. I was wondering if someone else can try it out and see if it works or not.