-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
175 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[run] | ||
branch = True | ||
|
||
omit = | ||
frequenpy/version.py | ||
frequenpy/constants.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
__pycache__ | ||
test*.py | ||
dist | ||
build | ||
*egg-info* | ||
|
||
.venv | ||
workdir | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
flake8<7 | ||
pytest-cov<5 | ||
|
||
-e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
|
||
from matplotlib import pyplot | ||
|
||
from frequenpy.loaded_string.animation import LoadedStringAnimation | ||
|
||
|
||
def test_animation(monkeypatch, tmp_path): | ||
anim = LoadedStringAnimation.build(N=5, modes=[1, 2], boundary=0, n_frames=1, folder=tmp_path) | ||
monkeypatch.setattr(pyplot, "show", lambda *x, **y: 0) | ||
anim.start() | ||
|
||
filepath = anim.start(save=True) | ||
assert os.path.exists(filepath) | ||
|
||
folder = os.path.join(tmp_path, 'new') | ||
anim = LoadedStringAnimation.build(N=30, modes=[1], boundary=0, n_frames=1, folder=folder) | ||
anim.start(save=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
import numpy as np | ||
|
||
from frequenpy.loaded_string import loaded_string_factory | ||
|
||
|
||
def test_loaded_string_factory(): | ||
|
||
loaded_string_factory.create(N=5, modes=[1, 2], boundary=0) | ||
loaded_string_factory.create(N=5, modes=[1, 2], boundary=1) | ||
loaded_string_factory.create(N=5, modes=[1, 2], boundary=2) | ||
|
||
with pytest.raises(ValueError): | ||
loaded_string_factory.create(N=5, modes=[1, 2], boundary=3) | ||
|
||
with pytest.raises(ValueError): | ||
loaded_string_factory.create(N=7, modes=[1, 2], boundary=0) | ||
|
||
with pytest.raises(ValueError): | ||
loaded_string_factory.create(N=2, modes=[1, 2, 3], boundary=0) | ||
|
||
with pytest.raises(ValueError): | ||
loaded_string_factory.create(N=2, modes=[1, 3], boundary=0) | ||
|
||
with pytest.raises(ValueError): | ||
loaded_string_factory.create(N=2, modes=[0, 2], boundary=0) | ||
|
||
|
||
def test_loaded_string(): | ||
ls = loaded_string_factory.create(N=5, modes=[1, 2], boundary=0) | ||
|
||
assert len(ls) == 5 | ||
assert ls.modes == '1-2' | ||
|
||
ls.position_at_time_t(1) | ||
|
||
ls.apply_speed(2) | ||
|
||
_, Y = ls.rest_position | ||
assert np.all(Y == 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from frequenpy import cli | ||
from frequenpy.loaded_string.animation import LoadedStringAnimation | ||
|
||
|
||
class AnimationMock: | ||
def start(self, *args, **kwargs): | ||
pass | ||
|
||
|
||
def test_cli(monkeypatch): | ||
monkeypatch.setattr(LoadedStringAnimation, 'build', lambda *args, **kwargs: AnimationMock()) | ||
|
||
cli.run([ | ||
'loaded_string', '--masses', '5', '--modes', '1', '2', '--speed', '0.1', '--boundary', '0' | ||
]) | ||
|
||
with pytest.raises(SystemExit): | ||
cli.run([]) | ||
|
||
with pytest.raises(ValueError): | ||
cli.parse_args(['invalid']) | ||
|
||
with pytest.raises(AssertionError): | ||
cli.run(['loaded_string']) |