Skip to content

Commit 8a8c67a

Browse files
committed
Fix the CLI test runner
* Fix the clunky CLI test runner. * Update the README about it. * The `--plot` test requires installing matplotlib, in particular, one that's compatible with the installed numpy. * Moved the `analysis/` directory into the `test/` directory for the tests to import. * TODO: Fix the `--memory` test, which fails `assert memory_increases <= 10` on macOS. * TODO: Fix the `--plot` test, which raises `ValueError: x and y must have same first dimension, but have shapes (115,) and (114, 2469)` from matplotlib. * Delete `release.sh` which would be risky to run now and has been supplanted by GitHub Actions. Actually my process was to copy/paste from this script rather than run it as is. Q. Do *.pxd header files need `freethreading_compatible = True` or is it sufficient in the .pyx module?
1 parent 3589de1 commit 8a8c67a

File tree

8 files changed

+33
-68
lines changed

8 files changed

+33
-68
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ clean:
1313
compile:
1414
USE_CYTHON=1 python -m pip install -e .
1515

16+
test: clean compile
17+
pytest test
18+
1619
dist:
1720
USE_CYTHON=1 python -m build --sdist

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,43 @@ from stochastic_arrow import reenact_events
9191
history = reenact_events(stoichiometric_matrix, result['events'], state)
9292
```
9393

94-
## Testing
95-
96-
`stochastic_arrow` uses [pytest](https://docs.pytest.org/en/latest/). To test it:
94+
## Building
9795

9896
> make clean compile
99-
> pytest
97+
98+
This builds the extension package and installs it in editable mode.
10099

101100
**NOTE:** `make compile` without an explicit `clean` might not fully build the extension.
102101

103-
There are more command line features in test_arrow:
102+
## Testing
104103

105-
> python -m stochastic_arrow.test.test_arrow --complexation
104+
`stochastic_arrow` uses [pytest](https://docs.pytest.org/en/latest/).
105+
To run the main tests, in the source tree:
106106

107-
> python -m stochastic_arrow.test.test_arrow --plot
107+
> make test
108108

109-
> python -m stochastic_arrow.test.test_arrow --obsidian
109+
or
110110

111-
> python -m stochastic_arrow.test.test_arrow --memory
111+
> pytest
112112

113-
> python -m stochastic_arrow.test.test_arrow --time
113+
There are additional command line features in test_arrow:
114114

115-
More examples:
115+
> python -m test.test_arrow --help
116+
> python -m test.test_arrow --complexation
117+
> python -m test.test_arrow --complexation --runs 3
118+
> python -m test.test_arrow --obsidian
119+
> python -m test.test_arrow --memory
120+
> python -m test.test_arrow --time
121+
> python -m test.test_arrow --pickle
122+
> python -m test.test_arrow --test-fail-flagella
123+
> python -m test.test_arrow --test-fail-stdout
124+
> python -m test.test_hang
116125

117-
> python -m stochastic_arrow.test.test_hang
126+
This test requires installing a version of matplotlib that's compatible with the installed numpy:
118127

119-
> pytest -m stochastic_arrow/test/test_arrow.py
128+
> python -m test.test_arrow --plot
129+
130+
More examples:
120131

121132
> pytest -k flagella
122133

optional_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
matplotlib==2.2.3
1+
matplotlib

release.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def _last_where(bool_array):
9696
if __name__ == '__main__':
9797
import matplotlib.pyplot as plt
9898

99-
from stochastic_arrow.analysis.plotting import plot_full_history
99+
from .plotting import plot_full_history
100100

101101
(fig, axes) = plt.subplots(constrained_layout = True)
102102

test/test_arrow.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def check_gillespie_reference():
378378
system()
379379
else:
380380
import matplotlib.pyplot as plt
381-
from stochastic_arrow.analysis.plotting import plot_full_history
381+
from .analysis.plotting import plot_full_history
382382

383383
n_systems = len(systems)
384384

@@ -412,9 +412,10 @@ def check_gillespie_reference():
412412

413413
if __name__ == '__main__':
414414
parser = argparse.ArgumentParser(
415-
description='Run one of these tests')
415+
description='Run the specified test or some default tests')
416416
parser.add_argument('--complexation', action='store_true')
417-
parser.add_argument('--runs', type=int, default=1)
417+
parser.add_argument('--runs', type=int, default=1,
418+
help='an option for complexation')
418419
parser.add_argument('--plot', action='store_true')
419420
parser.add_argument('--obsidian', action='store_true')
420421
parser.add_argument('--memory', action='store_true')

0 commit comments

Comments
 (0)