diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e9a471c --- /dev/null +++ b/.gitignore @@ -0,0 +1,112 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# version file +**_version.py + +# Input/Output files +*.bp +*.xdmf +*.h5 \ No newline at end of file diff --git a/src/hisp/__init__.py b/src/hisp/__init__.py new file mode 100644 index 0000000..e7c053e --- /dev/null +++ b/src/hisp/__init__.py @@ -0,0 +1 @@ +from .helpers import PulsedSource, Scenario diff --git a/helpers.py b/src/hisp/helpers.py similarity index 100% rename from helpers.py rename to src/hisp/helpers.py diff --git a/scenario_test.txt b/test/scenario_test.txt similarity index 100% rename from scenario_test.txt rename to test/scenario_test.txt diff --git a/test/test_scenario.py b/test/test_scenario.py new file mode 100644 index 0000000..7fdc624 --- /dev/null +++ b/test/test_scenario.py @@ -0,0 +1,27 @@ +from hisp.helpers import Scenario +import os +import pytest + +current_dir = os.path.dirname(__file__) +scenario_path = os.path.join(current_dir, "scenario_test.txt") + + +def test_maximum_time(): + # BUILD + my_scenario = Scenario(scenario_path) + expected_maximum_time = 2 * (455 + 455 + 650 + 1000) + 2 * (36 + 36 + 180 + 1000) + + # RUN + computed_maximum_time = my_scenario.get_maximum_time() + + # TEST + assert computed_maximum_time == expected_maximum_time + + +@pytest.mark.parametrize("t, expected_row", [(0, 0), (6000, 1)]) +def test_get_pulse_row(t, expected_row): + my_scenario = Scenario(scenario_path) + + pulse_row = my_scenario.get_row(t=t) + + assert pulse_row == expected_row