sim-tools 0.3.2__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sim_tools-0.4.0/.gitignore +112 -0
- {sim-tools-0.3.2/sim_tools.egg-info → sim_tools-0.4.0}/PKG-INFO +12 -11
- sim_tools-0.4.0/pyproject.toml +40 -0
- sim_tools-0.4.0/sim_tools/__init__.py +4 -0
- sim_tools-0.4.0/sim_tools/data/nspp_example1.csv +10 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/distributions.py +7 -1
- sim-tools-0.3.2/PKG-INFO +0 -84
- sim-tools-0.3.2/setup.cfg +0 -4
- sim-tools-0.3.2/setup.py +0 -41
- sim-tools-0.3.2/sim_tools/__init__.py +0 -4
- sim-tools-0.3.2/sim_tools.egg-info/SOURCES.txt +0 -20
- sim-tools-0.3.2/sim_tools.egg-info/dependency_links.txt +0 -1
- sim-tools-0.3.2/sim_tools.egg-info/requires.txt +0 -5
- sim-tools-0.3.2/sim_tools.egg-info/top_level.txt +0 -2
- sim-tools-0.3.2/tests/__init__.py +0 -0
- sim-tools-0.3.2/tests/test_dists.py +0 -151
- sim-tools-0.3.2/tests/test_time_dep.py +0 -26
- {sim-tools-0.3.2 → sim_tools-0.4.0}/LICENSE +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/README.md +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/datasets.py +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/ovs/__init__.py +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/ovs/evaluation.py +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/ovs/fixed_budget.py +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/ovs/indifference_zone.py +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/ovs/toy_models.py +0 -0
- {sim-tools-0.3.2 → sim_tools-0.4.0}/sim_tools/time_dependent.py +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# jupyter-book build folder for docs
|
|
2
|
+
docs/_build/*
|
|
3
|
+
|
|
4
|
+
# vscode
|
|
5
|
+
.vscode/
|
|
6
|
+
|
|
7
|
+
*.md.backup
|
|
8
|
+
|
|
9
|
+
# Byte-compiled / optimized / DLL files
|
|
10
|
+
__pycache__/
|
|
11
|
+
*.py[cod]
|
|
12
|
+
*$py.class
|
|
13
|
+
|
|
14
|
+
# C extensions
|
|
15
|
+
*.so
|
|
16
|
+
|
|
17
|
+
# Distribution / packaging
|
|
18
|
+
.Python
|
|
19
|
+
build/
|
|
20
|
+
develop-eggs/
|
|
21
|
+
dist/
|
|
22
|
+
downloads/
|
|
23
|
+
eggs/
|
|
24
|
+
.eggs/
|
|
25
|
+
lib/
|
|
26
|
+
lib64/
|
|
27
|
+
parts/
|
|
28
|
+
sdist/
|
|
29
|
+
var/
|
|
30
|
+
wheels/
|
|
31
|
+
*.egg-info/
|
|
32
|
+
.installed.cfg
|
|
33
|
+
*.egg
|
|
34
|
+
MANIFEST
|
|
35
|
+
|
|
36
|
+
# PyInstaller
|
|
37
|
+
# Usually these files are written by a python script from a template
|
|
38
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
39
|
+
*.manifest
|
|
40
|
+
*.spec
|
|
41
|
+
|
|
42
|
+
# Installer logs
|
|
43
|
+
pip-log.txt
|
|
44
|
+
pip-delete-this-directory.txt
|
|
45
|
+
|
|
46
|
+
# Unit test / coverage reports
|
|
47
|
+
htmlcov/
|
|
48
|
+
.tox/
|
|
49
|
+
.coverage
|
|
50
|
+
.coverage.*
|
|
51
|
+
.cache
|
|
52
|
+
nosetests.xml
|
|
53
|
+
coverage.xml
|
|
54
|
+
*.cover
|
|
55
|
+
.hypothesis/
|
|
56
|
+
.pytest_cache/
|
|
57
|
+
|
|
58
|
+
# Translations
|
|
59
|
+
*.mo
|
|
60
|
+
*.pot
|
|
61
|
+
|
|
62
|
+
# Django stuff:
|
|
63
|
+
*.log
|
|
64
|
+
local_settings.py
|
|
65
|
+
db.sqlite3
|
|
66
|
+
|
|
67
|
+
# Flask stuff:
|
|
68
|
+
instance/
|
|
69
|
+
.webassets-cache
|
|
70
|
+
|
|
71
|
+
# Scrapy stuff:
|
|
72
|
+
.scrapy
|
|
73
|
+
|
|
74
|
+
# Sphinx documentation
|
|
75
|
+
docs/_build/
|
|
76
|
+
|
|
77
|
+
# PyBuilder
|
|
78
|
+
target/
|
|
79
|
+
|
|
80
|
+
# Jupyter Notebook
|
|
81
|
+
.ipynb_checkpoints
|
|
82
|
+
|
|
83
|
+
# pyenv
|
|
84
|
+
.python-version
|
|
85
|
+
|
|
86
|
+
# celery beat schedule file
|
|
87
|
+
celerybeat-schedule
|
|
88
|
+
|
|
89
|
+
# SageMath parsed files
|
|
90
|
+
*.sage.py
|
|
91
|
+
|
|
92
|
+
# Environments
|
|
93
|
+
.env
|
|
94
|
+
.venv
|
|
95
|
+
env/
|
|
96
|
+
venv/
|
|
97
|
+
ENV/
|
|
98
|
+
env.bak/
|
|
99
|
+
venv.bak/
|
|
100
|
+
|
|
101
|
+
# Spyder project settings
|
|
102
|
+
.spyderproject
|
|
103
|
+
.spyproject
|
|
104
|
+
|
|
105
|
+
# Rope project settings
|
|
106
|
+
.ropeproject
|
|
107
|
+
|
|
108
|
+
# mkdocs documentation
|
|
109
|
+
/site
|
|
110
|
+
|
|
111
|
+
# mypy
|
|
112
|
+
.mypy_cache/
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: sim-tools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Simulation Tools for Education and Practice
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Project-URL: Homepage, https://github.com/TomMonks/sim-tools
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/TomMonks/sim-tools/issues
|
|
7
|
+
Project-URL: Documentation, https://tommonks.github.io/sim-tools
|
|
8
|
+
Author-email: Thomas Monks <t.m.w.monks@exeter.ac.uk>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
15
|
Requires-Python: >=3.10
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
16
|
Requires-Dist: matplotlib>=3.1.3
|
|
17
17
|
Requires-Dist: numpy>=1.18.1
|
|
18
18
|
Requires-Dist: pandas>=2.0.0
|
|
19
|
-
Requires-Dist: scipy>=1.4.1
|
|
20
19
|
Requires-Dist: scikit-learn>=1.0.0
|
|
20
|
+
Requires-Dist: scipy>=1.4.1
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
21
22
|
|
|
22
23
|
# sim-tools: tools to support the simulation process in python.
|
|
23
24
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sim-tools"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Simulation Tools for Education and Practice"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Thomas Monks", email = "t.m.w.monks@exeter.ac.uk" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"matplotlib>=3.1.3",
|
|
23
|
+
"numpy>=1.18.1",
|
|
24
|
+
"pandas>=2.0.0",
|
|
25
|
+
"scikit-learn>=1.0.0",
|
|
26
|
+
"scipy>=1.4.1",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/TomMonks/sim-tools"
|
|
31
|
+
"Bug Tracker" = "https://github.com/TomMonks/sim-tools/issues"
|
|
32
|
+
Documentation = "https://tommonks.github.io/sim-tools"
|
|
33
|
+
|
|
34
|
+
[tool.hatch.version]
|
|
35
|
+
path = "sim_tools/__init__.py"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.sdist]
|
|
38
|
+
include = [
|
|
39
|
+
"/sim_tools",
|
|
40
|
+
]
|
|
@@ -813,7 +813,13 @@ class Discrete(Distribution):
|
|
|
813
813
|
Number of samples to return. If integer then
|
|
814
814
|
numpy array returned.
|
|
815
815
|
"""
|
|
816
|
-
|
|
816
|
+
sample = self.rng.choice(self.values, p=self.probabilities, size=size)
|
|
817
|
+
|
|
818
|
+
if size is None:
|
|
819
|
+
return sample.item()
|
|
820
|
+
else:
|
|
821
|
+
return sample
|
|
822
|
+
|
|
817
823
|
|
|
818
824
|
|
|
819
825
|
class TruncatedDistribution(Distribution):
|
sim-tools-0.3.2/PKG-INFO
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: sim-tools
|
|
3
|
-
Version: 0.3.2
|
|
4
|
-
Summary: Simulation Tools for Education and Practice
|
|
5
|
-
Home-page: https://github.com/TomMonks/sim-tools
|
|
6
|
-
Author: Thomas Monks
|
|
7
|
-
Author-email: t.m.w.monks@exeter.ac.uk
|
|
8
|
-
License: The MIT License (MIT)
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.10
|
|
14
|
-
Description-Content-Type: text/markdown
|
|
15
|
-
License-File: LICENSE
|
|
16
|
-
Requires-Dist: matplotlib>=3.1.3
|
|
17
|
-
Requires-Dist: numpy>=1.18.1
|
|
18
|
-
Requires-Dist: pandas>=2.0.0
|
|
19
|
-
Requires-Dist: scipy>=1.4.1
|
|
20
|
-
Requires-Dist: scikit-learn>=1.0.0
|
|
21
|
-
|
|
22
|
-
# sim-tools: tools to support the simulation process in python.
|
|
23
|
-
|
|
24
|
-
[](https://mybinder.org/v2/gh/TomMonks/sim-tools/HEAD)
|
|
25
|
-
[](https://zenodo.org/badge/latestdoi/225608065)
|
|
26
|
-
[](https://pypi.python.org/pypi/sim-tools/)
|
|
27
|
-
[](https://tommonks.github.io/sim-tools)
|
|
28
|
-
[](https://opensource.org/licenses/MIT)
|
|
29
|
-
[](https://www.python.org/downloads/release/python-360+/)
|
|
30
|
-
[](https://orcid.org/0000-0003-2631-4481)
|
|
31
|
-
|
|
32
|
-
sim-tools is being developed to support simulation education and applied simulation research. It is MIT licensed and freely available to practitioners, students and researchers via PyPi. There is a longer term plan to make sim-tools available via conda-forge.
|
|
33
|
-
|
|
34
|
-
# Vision for sim-tools
|
|
35
|
-
|
|
36
|
-
1. Deliver high quality reliable code for simulation education and practice with full documentation.
|
|
37
|
-
2. Provide a simple to use pythonic interface.
|
|
38
|
-
3. To improve the quality of simulation education and encourage the use of best practice.
|
|
39
|
-
|
|
40
|
-
# Features:
|
|
41
|
-
|
|
42
|
-
1. Implementation of classic optimisation via Simulation procedures such as KN, KN++, OBCA and OBCA-m
|
|
43
|
-
2. Distributions module that includes classes that encapsulate a random number stream, seed, and distribution parameters.
|
|
44
|
-
3. Implementation of Thinning to sample from Non-stationary poisson processes in a discrete-event simulation
|
|
45
|
-
|
|
46
|
-
## Three simple ways to explore sim-tools
|
|
47
|
-
|
|
48
|
-
1. `pip install sim-tools`
|
|
49
|
-
2. Click on the launch-binder at the top of this readme. This will open example Jupyter notebooks in the cloud via Binder.
|
|
50
|
-
3. Oneline documentation: https://tommonks.github.io/sim-tools
|
|
51
|
-
|
|
52
|
-
## Citation
|
|
53
|
-
|
|
54
|
-
If you use sim0tools for research, a practical report, education or any reason please include the following citation.
|
|
55
|
-
|
|
56
|
-
> Monks, Thomas. (2021). sim-tools: tools to support the forecasting process in python. Zenodo. http://doi.org/10.5281/zenodo.4553642
|
|
57
|
-
|
|
58
|
-
```tex
|
|
59
|
-
@software{sim_tools,
|
|
60
|
-
author = {Thomas Monks},
|
|
61
|
-
title = {sim-tools: fundamental tools to support the simulation process in python},
|
|
62
|
-
year = {2021},
|
|
63
|
-
publisher = {Zenodo},
|
|
64
|
-
doi = {10.5281/zenodo.4553642},
|
|
65
|
-
url = {http://doi.org/10.5281/zenodo.4553642}
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
# Online Tutorials
|
|
70
|
-
|
|
71
|
-
* Optimisation Via Simulation [](https://colab.research.google.com/github/TomMonks/sim-tools/blob/master/examples/sw21_tutorial.ipynb)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
## Contributing to sim-tools
|
|
75
|
-
|
|
76
|
-
Please fork Dev, make your modifications, run the unit tests and submit a pull request for review.
|
|
77
|
-
|
|
78
|
-
Development environment:
|
|
79
|
-
|
|
80
|
-
* `conda env create -f binder/environment.yml`
|
|
81
|
-
|
|
82
|
-
* `conda activate sim_tools`
|
|
83
|
-
|
|
84
|
-
**All contributions are welcome!**
|
sim-tools-0.3.2/setup.cfg
DELETED
sim-tools-0.3.2/setup.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import setuptools
|
|
2
|
-
|
|
3
|
-
# patch ed - build error due to imporing numpy into __init__
|
|
4
|
-
# from sim_tools import __version__
|
|
5
|
-
VERSION = "0.3.2"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Read in the requirements.txt file
|
|
9
|
-
with open("requirements.txt") as f:
|
|
10
|
-
requirements = []
|
|
11
|
-
for library in f.read().splitlines():
|
|
12
|
-
requirements.append(library)
|
|
13
|
-
|
|
14
|
-
with open("README.md", "r") as fh:
|
|
15
|
-
long_description = fh.read()
|
|
16
|
-
|
|
17
|
-
setuptools.setup(
|
|
18
|
-
name="sim-tools",
|
|
19
|
-
version=VERSION,
|
|
20
|
-
author="Thomas Monks",
|
|
21
|
-
author_email="t.m.w.monks@exeter.ac.uk",
|
|
22
|
-
license="The MIT License (MIT)",
|
|
23
|
-
description="Simulation Tools for Education and Practice",
|
|
24
|
-
long_description=long_description,
|
|
25
|
-
long_description_content_type="text/markdown",
|
|
26
|
-
url="https://github.com/TomMonks/sim-tools",
|
|
27
|
-
packages=setuptools.find_packages(),
|
|
28
|
-
#if true look in MANIFEST.in for data files to include
|
|
29
|
-
include_package_data=False,
|
|
30
|
-
#2nd approach to include data is include_package_data=False
|
|
31
|
-
#package_data={"test_package": ["data/*.csv"]},
|
|
32
|
-
#these are for documentation
|
|
33
|
-
classifiers=[
|
|
34
|
-
"Programming Language :: Python :: 3.10",
|
|
35
|
-
"Programming Language :: Python :: 3.11",
|
|
36
|
-
"License :: OSI Approved :: MIT License",
|
|
37
|
-
"Operating System :: OS Independent",
|
|
38
|
-
],
|
|
39
|
-
python_requires='>=3.10',
|
|
40
|
-
install_requires=requirements,
|
|
41
|
-
)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
setup.py
|
|
4
|
-
sim_tools/__init__.py
|
|
5
|
-
sim_tools/datasets.py
|
|
6
|
-
sim_tools/distributions.py
|
|
7
|
-
sim_tools/time_dependent.py
|
|
8
|
-
sim_tools.egg-info/PKG-INFO
|
|
9
|
-
sim_tools.egg-info/SOURCES.txt
|
|
10
|
-
sim_tools.egg-info/dependency_links.txt
|
|
11
|
-
sim_tools.egg-info/requires.txt
|
|
12
|
-
sim_tools.egg-info/top_level.txt
|
|
13
|
-
sim_tools/ovs/__init__.py
|
|
14
|
-
sim_tools/ovs/evaluation.py
|
|
15
|
-
sim_tools/ovs/fixed_budget.py
|
|
16
|
-
sim_tools/ovs/indifference_zone.py
|
|
17
|
-
sim_tools/ovs/toy_models.py
|
|
18
|
-
tests/__init__.py
|
|
19
|
-
tests/test_dists.py
|
|
20
|
-
tests/test_time_dep.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
basic smoke tests
|
|
3
|
-
Create objects to check all okay
|
|
4
|
-
"""
|
|
5
|
-
import sim_tools.distributions as dists
|
|
6
|
-
import pytest
|
|
7
|
-
|
|
8
|
-
SEED_1 = 42
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_exponential():
|
|
12
|
-
d = dists.Exponential(10, random_seed=SEED_1)
|
|
13
|
-
assert type(d.sample()) == float
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_lognormal():
|
|
17
|
-
d = dists.Lognormal(10, 1, random_seed=SEED_1)
|
|
18
|
-
assert type(d.sample()) == float
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_normal():
|
|
22
|
-
d = dists.Normal(10, 1, random_seed=SEED_1)
|
|
23
|
-
assert type(d.sample()) == float
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def test_uniform():
|
|
27
|
-
d = dists.Uniform(1, 10, random_seed=SEED_1)
|
|
28
|
-
assert type(d.sample()) == float
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def test_tri():
|
|
32
|
-
d = dists.Triangular(1.0, 10.0, 25.0, random_seed=SEED_1)
|
|
33
|
-
assert type(d.sample()) == float
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def test_bernoulli():
|
|
37
|
-
d = dists.Bernoulli(0.3, random_seed=SEED_1)
|
|
38
|
-
assert type(d.sample()) == int
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def test_fixed_type():
|
|
42
|
-
d = dists.FixedDistribution(5.0)
|
|
43
|
-
assert type(d.sample()) == float
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def test_fixed_value():
|
|
47
|
-
d = dists.FixedDistribution(5.0)
|
|
48
|
-
assert d.sample() == 5.0
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def test_combination():
|
|
52
|
-
foo = dists.Exponential(10, random_seed=SEED_1)
|
|
53
|
-
bar = dists.Normal(10, 1, random_seed=SEED_1)
|
|
54
|
-
d = dists.CombinationDistribution(foo, bar)
|
|
55
|
-
sample = d.sample()
|
|
56
|
-
assert type(sample) == float
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_erlang():
|
|
60
|
-
d = dists.Erlang(10.0, 2.8, random_seed=SEED_1)
|
|
61
|
-
assert type(d.sample()) == float
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def test_erlangk():
|
|
65
|
-
d = dists.ErlangK(1, 2.8, random_seed=SEED_1)
|
|
66
|
-
assert type(d.sample()) == float
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def test_gamma():
|
|
70
|
-
d = dists.Gamma(1.2, 2.8, random_seed=SEED_1)
|
|
71
|
-
assert type(d.sample()) == float
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def test_weibull():
|
|
75
|
-
d = dists.Weibull(1.2, 2.8, random_seed=SEED_1)
|
|
76
|
-
assert type(d.sample()) == float
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def test_beta():
|
|
80
|
-
d = dists.Beta(1.2, 2.8, random_seed=SEED_1)
|
|
81
|
-
assert type(d.sample()) == float
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def test_pearsonv():
|
|
85
|
-
d = dists.PearsonV(1.2, 2.8, random_seed=SEED_1)
|
|
86
|
-
assert type(d.sample()) == float
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def test_pearsonvi():
|
|
90
|
-
d = dists.PearsonVI(1.2, 1.2, 2.8, random_seed=SEED_1)
|
|
91
|
-
assert type(d.sample()) == float
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def test_poisson():
|
|
95
|
-
d = dists.Poisson(5.5, random_seed=SEED_1)
|
|
96
|
-
assert type(d.sample()) == int
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def test_continuous_empirical():
|
|
100
|
-
dist = dists.ContinuousEmpirical(
|
|
101
|
-
lower_bounds=[0, 5, 10, 15, 30, 45, 60, 120, 180, 240, 480],
|
|
102
|
-
upper_bounds=[5, 10, 15, 30, 45, 60, 120, 180, 240, 480, 2880],
|
|
103
|
-
freq=[34, 4, 8, 13, 15, 13, 19, 13, 9, 12, 73],
|
|
104
|
-
random_seed=SEED_1,
|
|
105
|
-
)
|
|
106
|
-
assert type(dist.sample()) == float
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def test_continous_empirical_length():
|
|
110
|
-
dist = dists.ContinuousEmpirical(
|
|
111
|
-
lower_bounds=[0, 5, 10, 15, 30, 45, 60, 120, 180, 240, 480],
|
|
112
|
-
upper_bounds=[5, 10, 15, 30, 45, 60, 120, 180, 240, 480, 2880],
|
|
113
|
-
freq=[34, 4, 8, 13, 15, 13, 19, 13, 9, 12, 73],
|
|
114
|
-
random_seed=SEED_1,
|
|
115
|
-
)
|
|
116
|
-
expected_size = 10
|
|
117
|
-
|
|
118
|
-
assert len(dist.sample(expected_size)) == expected_size
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def test_discrete():
|
|
122
|
-
d = dists.Discrete(values=[1, 2, 3], freq=[95, 3, 2], random_seed=SEED_1)
|
|
123
|
-
assert type(d.sample()) == int
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def test_discrete():
|
|
127
|
-
d = dists.Discrete(values=[1, 2, 3], freq=[95, 3, 2], random_seed=SEED_1)
|
|
128
|
-
assert type(d.sample()) == int
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def test_truncated_type():
|
|
132
|
-
d1 = dists.Normal(10, 1, random_seed=SEED_1)
|
|
133
|
-
d2 = dists.TruncatedDistribution(d1, lower_bound=10.0)
|
|
134
|
-
assert type(d2.sample()) == float
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
@pytest.mark.parametrize(
|
|
138
|
-
"n, expected",
|
|
139
|
-
[
|
|
140
|
-
(1, 10.0),
|
|
141
|
-
(10, 10.0),
|
|
142
|
-
(100, 10.0),
|
|
143
|
-
(10_000_000, 10.0),
|
|
144
|
-
(10_000_000, 0.0),
|
|
145
|
-
(10_000_000, 0.01),
|
|
146
|
-
],
|
|
147
|
-
)
|
|
148
|
-
def test_truncated_min(n, expected):
|
|
149
|
-
d1 = dists.Normal(10, 1, random_seed=SEED_1)
|
|
150
|
-
d2 = dists.TruncatedDistribution(d1, lower_bound=expected)
|
|
151
|
-
assert min(d2.sample(size=n)) >= expected
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
basic tests for time dependent module
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import sim_tools.time_dependent as td
|
|
6
|
-
from sim_tools.datasets import load_banks_et_al_nspp
|
|
7
|
-
import pytest
|
|
8
|
-
|
|
9
|
-
SEED_1 = 42
|
|
10
|
-
SEED_2 = 101
|
|
11
|
-
|
|
12
|
-
@pytest.mark.parametrize(
|
|
13
|
-
"simulation_time",
|
|
14
|
-
[
|
|
15
|
-
(0.0),
|
|
16
|
-
(10.0),
|
|
17
|
-
(55.0),
|
|
18
|
-
(10.5),
|
|
19
|
-
(2_000.00),
|
|
20
|
-
(10_000.00),
|
|
21
|
-
],
|
|
22
|
-
)
|
|
23
|
-
def test_sample_from_nsppthinning(simulation_time):
|
|
24
|
-
data = load_banks_et_al_nspp()
|
|
25
|
-
d = td.NSPPThinning(data, SEED_1, SEED_2)
|
|
26
|
-
assert type(d.sample(simulation_time)) == float
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|