Skip to content

Commit 1f0f37e

Browse files
authored
Initial commit
0 parents  commit 1f0f37e

File tree

72 files changed

+27514
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+27514
-0
lines changed

.github/workflows/lint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file will lint the specified files/directories.
2+
3+
name: lint
4+
5+
on:
6+
push:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Install python and dependencies
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.13'
22+
cache: 'pip'
23+
- run: pip install -r requirements.txt
24+
25+
- name: Lint
26+
run: |
27+
bash lint.sh

.github/workflows/tests.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# This file runs the tests in `tests/`
2+
# They will run in parallel, and run on three operating systems:
3+
# Ubuntu, Windows and Mac.
4+
5+
name: tests
6+
7+
on:
8+
push:
9+
branches: [main]
10+
workflow_dispatch:
11+
12+
jobs:
13+
14+
# Run tests on Ubuntu
15+
tests-on-ubuntu:
16+
runs-on: ubuntu-latest
17+
steps:
18+
19+
- name: Check out repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install python and dependencies
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.13'
26+
cache: 'pip'
27+
- run: pip install -r requirements.txt
28+
29+
- name: Run tests
30+
run: pytest
31+
32+
- name: List the environment variables
33+
run: env
34+
35+
# Run tests on Windows
36+
tests-on-windows:
37+
runs-on: windows-latest
38+
steps:
39+
40+
- name: Check out repository
41+
uses: actions/checkout@v4
42+
43+
- name: Install python and dependencies
44+
uses: actions/setup-python@v4
45+
with:
46+
python-version: '3.13'
47+
cache: 'pip'
48+
- run: python -m pip install -r requirements.txt
49+
50+
- name: Run tests
51+
run: pytest
52+
53+
- name: List the environment variables
54+
run: env
55+
56+
# Run tests on Mac
57+
tests-on-macos:
58+
runs-on: macos-latest
59+
steps:
60+
61+
- name: Check out repository
62+
uses: actions/checkout@v4
63+
64+
- name: Install python and dependencies
65+
uses: actions/setup-python@v4
66+
with:
67+
python-version: '3.13'
68+
cache: 'pip'
69+
- run: pip install -r requirements.txt
70+
71+
- name: Run tests
72+
run: pytest
73+
74+
- name: List the environment variables
75+
run: env

.gitignore

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
__pycache__
2+
.mypy_cache
3+
.pytest_cache
4+
.pytype
5+
6+
# Log messages, except the example one generated by logs.ipynb
7+
*.log
8+
!log_example.log
9+
10+
# vscode
11+
.vscode/*
12+
13+
# Jupyter book html
14+
_build/
15+
16+
# Byte-compiled / optimized / DLL files
17+
__pycache__/
18+
*.py[cod]
19+
*$py.class
20+
21+
# C extensions
22+
*.so
23+
24+
# Distribution / packaging
25+
.Python
26+
build/
27+
develop-eggs/
28+
dist/
29+
downloads/
30+
eggs/
31+
.eggs/
32+
lib/
33+
lib64/
34+
parts/
35+
sdist/
36+
var/
37+
wheels/
38+
share/python-wheels/
39+
*.egg-info/
40+
.installed.cfg
41+
*.egg
42+
MANIFEST
43+
44+
# PyInstaller
45+
# Usually these files are written by a python script from a template
46+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
47+
*.manifest
48+
*.spec
49+
50+
# Installer logs
51+
pip-log.txt
52+
pip-delete-this-directory.txt
53+
54+
# Unit test / coverage reports
55+
htmlcov/
56+
.tox/
57+
.nox/
58+
.coverage
59+
.coverage.*
60+
.cache
61+
nosetests.xml
62+
coverage.xml
63+
*.cover
64+
*.py,cover
65+
.hypothesis/
66+
.pytest_cache/
67+
cover/
68+
69+
# Translations
70+
*.mo
71+
*.pot
72+
73+
# Django stuff:
74+
*.log
75+
local_settings.py
76+
db.sqlite3
77+
db.sqlite3-journal
78+
79+
# Flask stuff:
80+
instance/
81+
.webassets-cache
82+
83+
# Scrapy stuff:
84+
.scrapy
85+
86+
# Sphinx documentation
87+
docs/_build/
88+
89+
# PyBuilder
90+
.pybuilder/
91+
target/
92+
93+
# Jupyter Notebook
94+
.ipynb_checkpoints
95+
96+
# IPython
97+
profile_default/
98+
ipython_config.py
99+
100+
# pyenv
101+
# For a library or package, you might want to ignore these files since the code is
102+
# intended to run in multiple environments; otherwise, check them in:
103+
# .python-version
104+
105+
# pipenv
106+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
107+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
108+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
109+
# install all needed dependencies.
110+
#Pipfile.lock
111+
112+
# poetry
113+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
114+
# This is especially recommended for binary packages to ensure reproducibility, and is more
115+
# commonly ignored for libraries.
116+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
117+
#poetry.lock
118+
119+
# pdm
120+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
121+
#pdm.lock
122+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
123+
# in version control.
124+
# https://pdm.fming.dev/#use-with-ide
125+
.pdm.toml
126+
127+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128+
__pypackages__/
129+
130+
# Celery stuff
131+
celerybeat-schedule
132+
celerybeat.pid
133+
134+
# SageMath parsed files
135+
*.sage.py
136+
137+
# Environments
138+
.env
139+
.venv
140+
env/
141+
venv/
142+
ENV/
143+
env.bak/
144+
venv.bak/
145+
146+
# Spyder project settings
147+
.spyderproject
148+
.spyproject
149+
150+
# Rope project settings
151+
.ropeproject
152+
153+
# mkdocs documentation
154+
/site
155+
156+
# mypy
157+
.mypy_cache/
158+
.dmypy.json
159+
dmypy.json
160+
161+
# Pyre type checker
162+
.pyre/
163+
164+
# pytype static type analyzer
165+
.pytype/
166+
167+
# Cython debug symbols
168+
cython_debug/
169+
170+
# PyCharm
171+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
172+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
173+
# and can be added to the global gitignore or merged into this file. For a more nuclear
174+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
175+
#.idea/
176+
177+
178+

.pylintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[FORMAT]
2+
max-line-length=79

CHANGELOG.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Dates formatted as YYYY-MM-DD as per [ISO standard](https://www.iso.org/iso-8601-date-and-time-format.html).
7+
8+
## v1.2.0 - 2025-03-26
9+
10+
Add tests, change from default inputs, rename some variables, and add a method which allows the solution of `ReplicationsAlgorithm` to be less than the `initial_replications` set.
11+
12+
### Added
13+
14+
* Add unit tests for `ReplicationsAlgorithm` when only 2 replications are run, and for the new `find_position()` method.
15+
* Add back test for scenario analysis.
16+
17+
### Changed
18+
19+
* Linting GitHub action no longer triggers on pull requests.
20+
* Renamed `count_unseen` and `q_time_unseen` to be resource-specific (i.e.g `count_unseen_nurse`).
21+
* Set default alpha to 0.05 for `OnlineStatistics`.
22+
* Accept instance of `Param` class as input for `run_scenarios()` rather than a dictionary.
23+
24+
### Fixed
25+
26+
* Add `find_position()` method to `ReplicationsAlgorithm`, allowing us to correct results if the solution was below the `initial_replications` set.
27+
28+
## v1.1.0 - 2025-03-21
29+
30+
Add a bash script for executing notebooks and new tests for warm-up patients and replication consistency. Fixes were made to correct notebook configurations, adjust test parameters, refine the replication algorithm, and ensure accurate calculations, such as correcting nurse time usage and setting appropriate values in the replication algorithm. Other changes include updates to default parameters and documentation.
31+
32+
### Added
33+
34+
* Bash script to execute all notebooks (with `nbconvert` add to environment for this).
35+
* Add test related to inclusion/exclusion of warm-up patients in certain metrics (`test_warmup_high_demand()`).
36+
* Add test for consistent `nreps` between replications methods.
37+
38+
### Changed
39+
40+
* Changed default warm-up length in `Param()`.
41+
* Add pylint line limit so it adheres to PEP-8.
42+
* Allow input of `Param()` to the objects in `replications.py` so we can specify parameter set for back tests (so they don't just change results when we change the model defaults).
43+
* Add specific parameters to `generate_exp_results.ipynb` for back tests.
44+
* Add acknowledgements to README and docstrings.
45+
* Lowered the default `min_rep` for both confidence_interval_method functions.
46+
47+
### Fixed
48+
49+
* Correct `choosing_warmup.ipynb` to use multiple replications and run length at least 5-10x actual.
50+
* Fix `test_waiting_time_utilisation()`
51+
* Correct `test_klimit()` to actually use the parametrize inputs.
52+
* Add correction to `nurse_time_used` for when patients span the warm-up and data collection period.
53+
* Allow `None` for the dashed line in `plotly_confidence_interval_method()`.
54+
* Allow a solution below `initial_replications` in `ReplicationsAlgorithm`.
55+
* Set `target_met` back to 0 in `ReplicationsAlgorithm` if precision is no longer achieved.
56+
* Set `test_consistent_outputs()` to have no lookahead.
57+
58+
## v1.0.0 - 2025-02-27
59+
60+
Lots and lots of changes! Many of these are a result of comments from peer review of code by Tom Monks.
61+
62+
### Added
63+
64+
* Virtual environment alternative to conda.
65+
* Bash script to lint repository.
66+
* Lots of new unit tests and functional tests!
67+
* GitHub actions to run tests and lint repository.
68+
* Add `MonitoredResource` and alternative warm-up results collection.
69+
* Time-weighted statistics - including relevant code (`replications.py`), documentation (`choosing_replications.ipynb`), and tests (`_replications` in tests).
70+
* User-controlled interactive histogram of results in `analysis.ipynb`.
71+
* Add metrics for unseen patients.
72+
73+
### Changed
74+
75+
* Changes to code and environment to accomodate new features (described in 'Added').
76+
* Import simulation as a local package.
77+
* Save all tables and figures.
78+
* Add Tom Monks to author list.
79+
* Expanded README.
80+
* Renaming classes and variables (e.g. `Trial` to `Runner`, `Defaults` to `Param`).
81+
* Improved log formatting.
82+
* Moved methods (e.g. from `analysis.ipynb` to `simulation/`).
83+
* Re-arranged tests into unit tests, back tests and functional tests.
84+
85+
### Fixed
86+
87+
* First arrival no longer at time 0.
88+
* Begin interval audit at start of data collection period (rather than start of warm-up period).
89+
* Correct logging message where wrong time was used.
90+
* Add error handling for invalid cores (in model + test) and error message for attempts to log when in parallel.
91+
* Resolved runtime warning with handling for variance 0 in `summary_stats()`.
92+
* Prevent output of standard deviation or confidence intervals from `summary_stats()` when n<3.
93+
* Add error handling for results processing when there are no arrivals.
94+
* Add error handling for invalid mean in `Exponential`.
95+
96+
## v0.1.0 - 2025-01-09
97+
98+
🌱 First release of the python DES template.

0 commit comments

Comments
 (0)