Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests with fixtures #499

Merged
merged 15 commits into from
Nov 20, 2024
Merged

Refactor tests with fixtures #499

merged 15 commits into from
Nov 20, 2024

Conversation

jnsbck
Copy link
Contributor

@jnsbck jnsbck commented Nov 14, 2024

This PR adds test fixtures for the modules that have to be re initialized again and again during testing. This should reduce overhead and make tests more readable. The fixtures are such that if i.e. Branch(nseg=4) was already used by a prev test, the fixture returns a copy of it, if not it is build from scratch and cached. Higher order modules, i.e. Cell([Branch(nseg=4)], [-1,0,0]) that are build later can also make use of the pre-build submodules via the fixtures.

This compliments #479 and contributes towards #449.

@jnsbck
Copy link
Contributor Author

jnsbck commented Nov 14, 2024

PR is currently WIP. Might also try to reduce test runtime.

@jnsbck jnsbck force-pushed the refactor_test_w_fixtures branch 2 times, most recently from a5303ed to 1e0f515 Compare November 15, 2024 20:58
@jnsbck
Copy link
Contributor Author

jnsbck commented Nov 19, 2024

PR introduces simpler test primitives, adds slow markers for tests that take longer than 10s to run and also standardizes the test-cases a bit more, see conftest.py for fixtures. Also reduced the simulation times as much as possible by reducing t_max in the stimuli. However, I can see no major speed improvements. Feedback would be greatly appreciated.

The following I am unsure about:

  • Should we shorten integration time of some hardcoded testcases, i.e.
    def test_compartment(voltage_solver: str):
  • Should we standardize test currents even more? I.e. short_pulse, long_pulse, dummy
  • I noticed while playing around with the currents that test_type_optimizer is extremely brittle w.r.t. changing t_max. Any ideas why? Could we make it more robust?

EDIT: These are the currently used stimuli.

  • 24: i_delay=0.1, i_dur=1.0, i_amp=0.1, t_max=2.0
  • 8: i_delay=0.5, i_dur=1.0, i_amp=0.02, t_max=5.0 # -> shorten?
  • 3: i_delay=0.0, i_dur=0.0, i_amp=0.0, t_max=0.1 # dummy current
  • 2: i_delay=0.5, i_dur=0.5, i_amp=0.1, t_max=10.0 # -> shorten?
  • 2: i_delay=0.5, i_dur=1.0, i_amp=0.2, t_max=5.0 # -> shorten?
  • 1: i_delay=0.1, i_dur=1.0, i_amp=0.1, t_max=5.0 # -> brittle test?
  • 1: i_delay=0.5, i_dur=1.0, i_amp=0.1, t_max=5.0 # -> shorten?
  • 1: i_delay=0.5, i_dur=1.0, i_amp=2.0, t_max=10.0 # -> shorten?

@jnsbck jnsbck linked an issue Nov 20, 2024 that may be closed by this pull request
Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

tests/conftest.py Show resolved Hide resolved
tests/test_fixtures.py Show resolved Hide resolved
@jnsbck jnsbck force-pushed the refactor_test_w_fixtures branch from c1e7fc6 to 3f77697 Compare November 20, 2024 16:06
@jnsbck jnsbck merged commit 57eda7e into main Nov 20, 2024
1 check passed
@jnsbck jnsbck deleted the refactor_test_w_fixtures branch November 20, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor tests
2 participants