Skip to content

Commit

Permalink
Merge pull request #54 from CSchoel/ci_with_extras
Browse files Browse the repository at this point in the history
Also runs the CI with extras and disables regression tests with RANSAC if scipy is not available
  • Loading branch information
CSchoel authored Sep 30, 2024
2 parents 2df84fe + c5a99da commit 9a6a506
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
on:
push:
branches: ["main", "dev", "v*"]
pull_request:

name: build

Expand All @@ -9,14 +10,17 @@ jobs:
strategy:
matrix:
python: ["3.7", "3.10"]
extras: ["", "[RANSAC, qrandom, plots]"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- run: pip install .
- run: pip install ".${{ matrix.extras }}"
- run: pip install codecov .
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- run: coverage run -m unittest nolds.test_measures
- run: codecov
if: ${{ matrix.python == '3.10' }}
if: ${{ matrix.python == '3.10' && matrix.extras != '' }}
6 changes: 6 additions & 0 deletions nolds/test_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ def test_corr_dim(self):
cd = nolds.corr_dim(data, emb_dim=5, lag=1, rvals=None, dist=nolds.rowwise_euclidean, fit="poly")
self.assertAlmostEqual(1.303252839255068, cd, places=15)

@unittest.skipUnless(SCIPY_AVAILABLE, "Tests with RANSAC require scipy.")
def test_corr_dim_RANSAC(self):
"""Test hypothesis: The exact output of corr_dim() with `fit=RANSAC` on random data hasn't changed since the last version."""
data = datasets.load_qrandom()[:1000]
Expand All @@ -589,6 +590,7 @@ def test_lyap_r(self):
expected = 0.094715945307378
self.assertAlmostEqual(expected, le, places=15)

@unittest.skipUnless(SCIPY_AVAILABLE, "Tests with RANSAC require scipy.")
def test_lyap_r_RANSAC(self):
"""Test hypothesis: The exact output of lyap_r() with `fit=RANSAC` on random data hasn't changed since the last version."""
data = datasets.load_qrandom()[:1000]
Expand All @@ -606,6 +608,7 @@ def test_hurst_rs(self):
expected = 0.5123887964986258
self.assertAlmostEqual(expected, rs, places=15)

@unittest.skipUnless(SCIPY_AVAILABLE, "Tests with RANSAC require scipy.")
def test_hurst_rs_RANSAC(self):
"""Test hypothesis: The exact output of hurst_rs() with `fit=RANSAC` on random data hasn't changed since the last version."""
data = datasets.load_qrandom()[:1000]
Expand All @@ -623,6 +626,7 @@ def test_dfa(self):
expected = 0.5450874638765073
self.assertAlmostEqual(expected, h, places=15)

@unittest.skipUnless(SCIPY_AVAILABLE, "Tests with RANSAC require scipy.")
def test_dfa_RANSAC(self):
"""Test hypothesis: The exact output of dfa() with `fit_exp=RANSAC` on random data hasn't changed since the last version."""
# adds trend to data to introduce a less clear line for fitting
Expand All @@ -641,6 +645,7 @@ def test_mfhurst_b(self):
expected = [-0.00559398934417339]
self.assertAlmostEqual(expected[0], h[0], places=15)

@unittest.skipUnless(SCIPY_AVAILABLE, "Tests with RANSAC require scipy.")
def test_mfhurst_b_RANSAC(self):
"""Test hypothesis: The exact output of mfhurst_b() with `fit=RANSAC` on random data hasn't changed since the last version."""
data = datasets.load_qrandom()[:1000]
Expand All @@ -656,6 +661,7 @@ def test_mfhurst_dm(self):
expected = [0.008762803881203145]
self.assertAlmostEqual(expected[0], h[0], places=15)

@unittest.skipUnless(SCIPY_AVAILABLE, "Tests with RANSAC require scipy.")
def test_mfhurst_dm_RANSAC(self):
"""Test hypothesis: The exact output of mfhurst_dm() with `fit=RANSAC` on random data hasn't changed since the last version."""
data = datasets.load_qrandom()[:1000]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def run(self):
'setuptools'
],
extras_require={
'RANSAC': ['sklearn>=0.19'],
'RANSAC': ['scikit-learn>=0.19'],
'qrandom': ['quantumrandom'],
'plots': ['matplotlib']
},
Expand Down

0 comments on commit 9a6a506

Please sign in to comment.