sim-tools 1.2.0__tar.gz → 1.3.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-1.2.0 → sim_tools-1.3.0}/.gitignore +9 -0
- {sim_tools-1.2.0 → sim_tools-1.3.0}/PKG-INFO +3 -33
- {sim_tools-1.2.0 → sim_tools-1.3.0}/README.md +2 -32
- {sim_tools-1.2.0 → sim_tools-1.3.0}/pyproject.toml +33 -0
- sim_tools-1.3.0/sim_tools/__init__.py +13 -0
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/_validation.py +14 -22
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/datasets.py +3 -4
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/distributions.py +117 -122
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/output_analysis.py +43 -44
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/ovs/evaluation.py +14 -33
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/ovs/fixed_budget.py +21 -25
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/ovs/indifference_zone.py +20 -21
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/ovs/toy_models.py +10 -12
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/time_dependent.py +25 -28
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/trace.py +47 -46
- sim_tools-1.2.0/sim_tools/__init__.py +0 -5
- {sim_tools-1.2.0 → sim_tools-1.3.0}/LICENSE +0 -0
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/data/nspp_example1.csv +0 -0
- {sim_tools-1.2.0 → sim_tools-1.3.0}/sim_tools/ovs/__init__.py +0 -0
|
@@ -114,3 +114,12 @@ venv.bak/
|
|
|
114
114
|
|
|
115
115
|
# mypy
|
|
116
116
|
.mypy_cache/
|
|
117
|
+
|
|
118
|
+
# Great Docs build directory (ephemeral, do not commit)
|
|
119
|
+
great-docs/
|
|
120
|
+
|
|
121
|
+
# Great Docs versioned-build artifacts
|
|
122
|
+
_great_docs_build/
|
|
123
|
+
.great-docs-build/
|
|
124
|
+
.great-docs-cache/
|
|
125
|
+
.great-docs/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sim-tools
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Simulation Tools for Education and Practice
|
|
5
5
|
Project-URL: Homepage, https://github.com/sim-tools/sim-tools
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/sim-tools/sim-tools/issues
|
|
@@ -24,7 +24,7 @@ Requires-Dist: scikit-learn>=1.0.0
|
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
|
|
26
26
|
<h1 align="center">
|
|
27
|
-
<a href="https://github.com/
|
|
27
|
+
<a href="https://github.com/sim-tools/sim-tools"><img src="./assets/simtools_logo_purple.png" alt="Sim-tools" width="300"></a>
|
|
28
28
|
</h1>
|
|
29
29
|
|
|
30
30
|
<p align="center">
|
|
@@ -121,34 +121,4 @@ If you use sim-tools for research, a practical report, education or any reason p
|
|
|
121
121
|
|
|
122
122
|
## Contributing to sim-tools
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Development environment:
|
|
127
|
-
|
|
128
|
-
* `conda env create -f binder/environment.yml`
|
|
129
|
-
|
|
130
|
-
* `conda activate sim_tools`
|
|
131
|
-
|
|
132
|
-
**All contributions are welcome!**
|
|
133
|
-
|
|
134
|
-
## Tips
|
|
135
|
-
|
|
136
|
-
Once in the `sim_tools` environment, you can run tests using the following command:
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
pytest
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
To view the documentation, navigate to the top level directory of the code repository in your terminal and issue the following command to build the Jupyter Book:
|
|
143
|
-
|
|
144
|
-
```
|
|
145
|
-
jb build docs/
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
To lint the repository, run:
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
bash lint.sh
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
NumPy style docstrings are used.
|
|
124
|
+
**All contributions are welcome!** Please see `CONTRIBUTING.md` for instructions on how to contribute.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<a href="https://github.com/
|
|
2
|
+
<a href="https://github.com/sim-tools/sim-tools"><img src="./assets/simtools_logo_purple.png" alt="Sim-tools" width="300"></a>
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
@@ -96,34 +96,4 @@ If you use sim-tools for research, a practical report, education or any reason p
|
|
|
96
96
|
|
|
97
97
|
## Contributing to sim-tools
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Development environment:
|
|
102
|
-
|
|
103
|
-
* `conda env create -f binder/environment.yml`
|
|
104
|
-
|
|
105
|
-
* `conda activate sim_tools`
|
|
106
|
-
|
|
107
|
-
**All contributions are welcome!**
|
|
108
|
-
|
|
109
|
-
## Tips
|
|
110
|
-
|
|
111
|
-
Once in the `sim_tools` environment, you can run tests using the following command:
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
pytest
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
To view the documentation, navigate to the top level directory of the code repository in your terminal and issue the following command to build the Jupyter Book:
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
jb build docs/
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
To lint the repository, run:
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
bash lint.sh
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
NumPy style docstrings are used.
|
|
99
|
+
**All contributions are welcome!** Please see `CONTRIBUTING.md` for instructions on how to contribute.
|
|
@@ -32,6 +32,16 @@ dependencies = [
|
|
|
32
32
|
|
|
33
33
|
]
|
|
34
34
|
|
|
35
|
+
[dependency-groups]
|
|
36
|
+
dev = [
|
|
37
|
+
"great-docs",
|
|
38
|
+
"lintquarto",
|
|
39
|
+
"pytest",
|
|
40
|
+
"ruff",
|
|
41
|
+
"simpy",
|
|
42
|
+
"treat-sim"
|
|
43
|
+
]
|
|
44
|
+
|
|
35
45
|
[project.urls]
|
|
36
46
|
Homepage = "https://github.com/sim-tools/sim-tools"
|
|
37
47
|
"Bug Tracker" = "https://github.com/sim-tools/sim-tools/issues"
|
|
@@ -47,3 +57,26 @@ include = [
|
|
|
47
57
|
|
|
48
58
|
[[tool.hatch.envs.hatch-test.matrix]]
|
|
49
59
|
python = ["3.10", "3.11", "3.12", "3.13"]
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
line-length=88
|
|
63
|
+
format.quote-style="double"
|
|
64
|
+
lint.select = [
|
|
65
|
+
"F", # pyflakes
|
|
66
|
+
"E", # pycodestyle
|
|
67
|
+
"I", # isort
|
|
68
|
+
]
|
|
69
|
+
lint.per-file-ignores."user_guide/*" = [
|
|
70
|
+
"F811", # Redefinition of unused {name} from {row}
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
[tool.lintquarto]
|
|
74
|
+
linters = [
|
|
75
|
+
"ruff",
|
|
76
|
+
]
|
|
77
|
+
paths = [
|
|
78
|
+
"user_guide",
|
|
79
|
+
]
|
|
80
|
+
exclude = [
|
|
81
|
+
"great-docs"
|
|
82
|
+
]
|
|
@@ -39,6 +39,7 @@ Validation functions raise appropriate exceptions with descriptive messages:
|
|
|
39
39
|
"""
|
|
40
40
|
|
|
41
41
|
from typing import Any, Callable
|
|
42
|
+
|
|
42
43
|
import numpy as np
|
|
43
44
|
|
|
44
45
|
# Type for validator functions
|
|
@@ -48,41 +49,31 @@ ValidatorFunc = Callable[[Any, str], None]
|
|
|
48
49
|
def is_numeric(value: Any, name: str) -> None:
|
|
49
50
|
"""Validates that a value is a number (int or float)."""
|
|
50
51
|
if not isinstance(value, (int, float)):
|
|
51
|
-
raise TypeError(
|
|
52
|
-
f"{name} must be a number, got {type(value).__name__}"
|
|
53
|
-
)
|
|
52
|
+
raise TypeError(f"{name} must be a number, got {type(value).__name__}")
|
|
54
53
|
|
|
55
54
|
|
|
56
55
|
def is_positive(value: Any, name: str) -> None:
|
|
57
56
|
"""Validates that a value is positive (> 0)."""
|
|
58
57
|
if not value > 0:
|
|
59
|
-
raise ValueError(
|
|
60
|
-
f"{name} must be positive, got {value}"
|
|
61
|
-
)
|
|
58
|
+
raise ValueError(f"{name} must be positive, got {value}")
|
|
62
59
|
|
|
63
60
|
|
|
64
61
|
def is_non_negative(value: Any, name: str) -> None:
|
|
65
62
|
"""Validates that a value is greater than or equal to 0."""
|
|
66
63
|
if not value >= 0:
|
|
67
|
-
raise ValueError(
|
|
68
|
-
f"{name} must be greater than or equal to 0, got {value}"
|
|
69
|
-
)
|
|
64
|
+
raise ValueError(f"{name} must be greater than or equal to 0, got {value}")
|
|
70
65
|
|
|
71
66
|
|
|
72
67
|
def is_probability(value: Any, name: str) -> None:
|
|
73
68
|
"""Validates that a value is a valid probability (between 0 and 1)."""
|
|
74
69
|
if not 0 <= value <= 1:
|
|
75
|
-
raise ValueError(
|
|
76
|
-
f"{name} must be between 0 and 1, got {value}"
|
|
77
|
-
)
|
|
70
|
+
raise ValueError(f"{name} must be between 0 and 1, got {value}")
|
|
78
71
|
|
|
79
72
|
|
|
80
73
|
def is_integer(value: Any, name: str) -> None:
|
|
81
74
|
"""Validates that a value is an integer."""
|
|
82
75
|
if not isinstance(value, int):
|
|
83
|
-
raise TypeError(
|
|
84
|
-
f"{name} must be an integer, got {type(value).__name__}"
|
|
85
|
-
)
|
|
76
|
+
raise TypeError(f"{name} must be an integer, got {type(value).__name__}")
|
|
86
77
|
|
|
87
78
|
|
|
88
79
|
def validate(value: Any, name: str, *validators: ValidatorFunc) -> None:
|
|
@@ -101,21 +92,22 @@ def is_ordered_pair(
|
|
|
101
92
|
)
|
|
102
93
|
|
|
103
94
|
|
|
104
|
-
# pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
105
95
|
def is_ordered_triplet(
|
|
106
|
-
low: Any,
|
|
107
|
-
|
|
96
|
+
low: Any,
|
|
97
|
+
middle: Any,
|
|
98
|
+
high: Any,
|
|
99
|
+
low_name: str = "low",
|
|
100
|
+
middle_name: str = "middle",
|
|
101
|
+
high_name: str = "high",
|
|
108
102
|
) -> None:
|
|
109
103
|
"""Validates that three values are in ascending order."""
|
|
110
104
|
if not low < middle:
|
|
111
105
|
raise ValueError(
|
|
112
|
-
f"{low_name} must be less than {middle_name}, " +
|
|
113
|
-
f"got {low} >= {middle}"
|
|
106
|
+
f"{low_name} must be less than {middle_name}, " + f"got {low} >= {middle}"
|
|
114
107
|
)
|
|
115
108
|
if not middle < high:
|
|
116
109
|
raise ValueError(
|
|
117
|
-
f"{middle_name} must be less than {high_name}, " +
|
|
118
|
-
f"got {middle} >= {high}"
|
|
110
|
+
f"{middle_name} must be less than {high_name}, " + f"got {middle} >= {high}"
|
|
119
111
|
)
|
|
120
112
|
|
|
121
113
|
|
|
@@ -9,13 +9,12 @@ from pathlib import Path
|
|
|
9
9
|
|
|
10
10
|
import pandas as pd
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
FILE_NAME_NSPP_1 = "nspp_example1.csv"
|
|
14
13
|
PATH_NSPP_1 = Path(__file__).parent.joinpath("data", FILE_NAME_NSPP_1)
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
def load_banks_et_al_nspp() -> pd.DataFrame:
|
|
18
|
-
|
|
17
|
+
"""
|
|
19
18
|
Load example Non-stationary poisson process data from Banks et al.
|
|
20
19
|
|
|
21
20
|
The function reads in the mean inter-arrival times by interval.
|
|
@@ -24,7 +23,7 @@ def load_banks_et_al_nspp() -> pd.DataFrame:
|
|
|
24
23
|
Returns
|
|
25
24
|
-------
|
|
26
25
|
pandas.DataFrame
|
|
27
|
-
|
|
26
|
+
"""
|
|
28
27
|
arrivals = pd.read_csv(PATH_NSPP_1)
|
|
29
|
-
arrivals[
|
|
28
|
+
arrivals["arrival_rate"] = 1 / arrivals["mean_iat"]
|
|
30
29
|
return arrivals
|