Skip to content

Commit

Permalink
Fix the CLI test runner
Browse files Browse the repository at this point in the history
* 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?
  • Loading branch information
1fish2 committed Dec 7, 2024
1 parent 3589de1 commit 8a8c67a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 68 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ clean:
compile:
USE_CYTHON=1 python -m pip install -e .

test: clean compile
pytest test

dist:
USE_CYTHON=1 python -m build --sdist
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,32 +91,43 @@ from stochastic_arrow import reenact_events
history = reenact_events(stoichiometric_matrix, result['events'], state)
```

## Testing

`stochastic_arrow` uses [pytest](https://docs.pytest.org/en/latest/). To test it:
## Building

> make clean compile
> pytest

This builds the extension package and installs it in editable mode.

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

There are more command line features in test_arrow:
## Testing

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

> python -m stochastic_arrow.test.test_arrow --plot
> make test

> python -m stochastic_arrow.test.test_arrow --obsidian
or

> python -m stochastic_arrow.test.test_arrow --memory
> pytest

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

More examples:
> python -m test.test_arrow --help
> python -m test.test_arrow --complexation
> python -m test.test_arrow --complexation --runs 3
> python -m test.test_arrow --obsidian
> python -m test.test_arrow --memory
> python -m test.test_arrow --time
> python -m test.test_arrow --pickle
> python -m test.test_arrow --test-fail-flagella
> python -m test.test_arrow --test-fail-stdout
> python -m test.test_hang

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

> pytest -m stochastic_arrow/test/test_arrow.py
> python -m test.test_arrow --plot

More examples:

> pytest -k flagella

Expand Down
2 changes: 1 addition & 1 deletion optional_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
matplotlib==2.2.3
matplotlib
50 changes: 0 additions & 50 deletions release.sh

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _last_where(bool_array):
if __name__ == '__main__':
import matplotlib.pyplot as plt

from stochastic_arrow.analysis.plotting import plot_full_history
from .plotting import plot_full_history

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

Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions test/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def check_gillespie_reference():
system()
else:
import matplotlib.pyplot as plt
from stochastic_arrow.analysis.plotting import plot_full_history
from .analysis.plotting import plot_full_history

n_systems = len(systems)

Expand Down Expand Up @@ -412,9 +412,10 @@ def check_gillespie_reference():

if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Run one of these tests')
description='Run the specified test or some default tests')
parser.add_argument('--complexation', action='store_true')
parser.add_argument('--runs', type=int, default=1)
parser.add_argument('--runs', type=int, default=1,
help='an option for complexation')
parser.add_argument('--plot', action='store_true')
parser.add_argument('--obsidian', action='store_true')
parser.add_argument('--memory', action='store_true')
Expand Down

0 comments on commit 8a8c67a

Please sign in to comment.