salabim 24.0.5__tar.gz → 24.0.7__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {salabim-24.0.5 → salabim-24.0.7}/PKG-INFO +1 -1
- {salabim-24.0.5 → salabim-24.0.7}/pyproject.toml +1 -1
- {salabim-24.0.5 → salabim-24.0.7}/salabim/LICENSE.txt +1 -1
- {salabim-24.0.5 → salabim-24.0.7}/salabim/salabim.py +32 -7
- {salabim-24.0.5 → salabim-24.0.7}/salabim.egg-info/PKG-INFO +1 -1
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_monitor.py +5 -1
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_state.py +11 -0
- {salabim-24.0.5 → salabim-24.0.7}/README.md +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/salabim/DejaVuSansMono.ttf +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/salabim/__init__.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/salabim/calibri.ttf +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/salabim/mplus-1m-regular.ttf +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/salabim.egg-info/SOURCES.txt +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/salabim.egg-info/dependency_links.txt +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/salabim.egg-info/top_level.txt +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/setup.cfg +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test salabim.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_cap_now.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_componentgenerator.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_datetime.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_distributions.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_misc.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_process.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_queue.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_store.py +0 -0
- {salabim-24.0.5 → salabim-24.0.7}/tests/test_timeunit.py +0 -0
@@ -17,4 +17,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
17
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
18
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
19
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,13 +1,13 @@
|
|
1
|
-
# _ _ _ ____ _ _ ___
|
2
|
-
# ___ __ _ | | __ _ | |__ (_) _ __ ___ |___ \ | || | / _ \ |
|
3
|
-
# / __| / _` || | / _` || '_ \ | || '_ ` _ \ __) || || |_ | | | |
|
4
|
-
# \__ \| (_| || || (_| || |_) || || | | | | | / __/ |__ _| _ | |_| | _
|
5
|
-
# |___/ \__,_||_| \__,_||_.__/ |_||_| |_| |_| |_____| |_| (_) \___/ (_)
|
1
|
+
# _ _ _ ____ _ _ ___ _____
|
2
|
+
# ___ __ _ | | __ _ | |__ (_) _ __ ___ |___ \ | || | / _ \ |___ |
|
3
|
+
# / __| / _` || | / _` || '_ \ | || '_ ` _ \ __) || || |_ | | | | / /
|
4
|
+
# \__ \| (_| || || (_| || |_) || || | | | | | / __/ |__ _| _ | |_| | _ / /
|
5
|
+
# |___/ \__,_||_| \__,_||_.__/ |_||_| |_| |_| |_____| |_| (_) \___/ (_) /_/
|
6
6
|
# discrete event simulation
|
7
7
|
#
|
8
8
|
# see www.salabim.org for more information, the documentation and license information
|
9
9
|
|
10
|
-
__version__ = "24.0.
|
10
|
+
__version__ = "24.0.7"
|
11
11
|
|
12
12
|
import heapq
|
13
13
|
import random
|
@@ -3375,6 +3375,15 @@ class _StateMonitor(Monitor):
|
|
3375
3375
|
def _value(self, value: Any) -> None:
|
3376
3376
|
self.parent.set(value)
|
3377
3377
|
|
3378
|
+
@property
|
3379
|
+
def value(self) -> Any:
|
3380
|
+
return self.parent.get()
|
3381
|
+
|
3382
|
+
@value.setter
|
3383
|
+
def value(self, value: Any) -> None:
|
3384
|
+
self.parent.set(value)
|
3385
|
+
|
3386
|
+
|
3378
3387
|
|
3379
3388
|
class _SystemMonitor(Monitor):
|
3380
3389
|
@property
|
@@ -10048,6 +10057,9 @@ class Environment:
|
|
10048
10057
|
This is particularly useful when running a simulation on a server.
|
10049
10058
|
Note that this will show a slight performance increase, when creating videos.
|
10050
10059
|
|
10060
|
+
Any valid parameter for Environment.animation_parameters() will be forwarded to animation_parameters(), e.g.
|
10061
|
+
env = sim.Environment(trace=True, animation=True, speed=5)
|
10062
|
+
|
10051
10063
|
Note
|
10052
10064
|
----
|
10053
10065
|
The trace may be switched on/off later with trace
|
@@ -10080,6 +10092,7 @@ class Environment:
|
|
10080
10092
|
if isdefault_env:
|
10081
10093
|
name = "default environment"
|
10082
10094
|
_set_name(name, Environment._nameserialize, self)
|
10095
|
+
|
10083
10096
|
self._nameserializeMonitor = {} # required here for to_freeze functionality
|
10084
10097
|
self._time_unit = _time_unit_lookup(time_unit)
|
10085
10098
|
self._time_unit_name = time_unit
|
@@ -10230,6 +10243,15 @@ class Environment:
|
|
10230
10243
|
|
10231
10244
|
self.an_clocktext()
|
10232
10245
|
|
10246
|
+
ap_parameters= [parameter for parameter in inspect.signature(self.animation_parameters).parameters]
|
10247
|
+
ap_kwargs={}
|
10248
|
+
for k,v in list(kwargs.items()):
|
10249
|
+
if k in ap_parameters:
|
10250
|
+
del kwargs[k]
|
10251
|
+
ap_kwargs[k]=v
|
10252
|
+
if ap_kwargs:
|
10253
|
+
self.animation_parameters(**ap_kwargs)
|
10254
|
+
|
10233
10255
|
self.setup(*args, **kwargs)
|
10234
10256
|
|
10235
10257
|
# ENVIRONMENT ANNOTATION START
|
@@ -26655,7 +26677,10 @@ class ImageContainer:
|
|
26655
26677
|
|
26656
26678
|
def init(self, spec):
|
26657
26679
|
can_animate(try_only=True) # to load PIL
|
26680
|
+
|
26658
26681
|
if isinstance(spec, (str, Path)):
|
26682
|
+
spec=str(spec) # to process Path correctly
|
26683
|
+
|
26659
26684
|
if spec == "":
|
26660
26685
|
im = Image.new("RGBA", (1, 1), (0, 0, 0, 0))
|
26661
26686
|
# (0, 0) raises an error on some platforms
|
@@ -27093,7 +27118,7 @@ reset()
|
|
27093
27118
|
set_environment_aliases()
|
27094
27119
|
|
27095
27120
|
if __name__ == "__main__":
|
27096
|
-
sys.path.insert(0, str(Path
|
27121
|
+
sys.path.insert(0, str(Path(__file__).parent / ".." / "misc"))
|
27097
27122
|
try:
|
27098
27123
|
import salabim_exp
|
27099
27124
|
except Exception as e:
|
@@ -635,10 +635,14 @@ def test_as_dataframe_use_datetime0():
|
|
635
635
|
df0=pd.DataFrame({"t": [d(2023,1,3),d(2023,1,5)], "level monitor0.x":[11,12]})
|
636
636
|
assert df0.equals(df)
|
637
637
|
df = level_monitor0.as_dataframe(use_datetime0=True)
|
638
|
-
df0=pd.DataFrame({"t":[d(2023,1,1), d(2023,1,2,7,12),d(2023,1,3,12),d(2023,1,5,19,12)], "level monitor0.x": [0,11,12,14.5]})
|
638
|
+
df0=pd.DataFrame({"t":[d(2023,1,1), d(2023,1,2,7,12),d(2023,1,3,12),d(2023,1,5,19,12),d(2023,1,6,0,0)], "level monitor0.x": [0,11,12,14.5,14.5]})
|
639
639
|
assert df0.equals(df)
|
640
640
|
df = level_monitor0.as_dataframe()
|
641
|
+
df0=pd.DataFrame({"t":[0,1.3,2.5,4.8,5.0], "level monitor0.x": [0,11,12,14.5,14.5]})
|
642
|
+
assert df0.equals(df)
|
643
|
+
df = level_monitor0.as_dataframe(add_now=False)
|
641
644
|
df0=pd.DataFrame({"t":[0,1.3,2.5,4.8], "level monitor0.x": [0,11,12,14.5]})
|
642
645
|
assert df0.equals(df)
|
646
|
+
|
643
647
|
if __name__ == "__main__":
|
644
648
|
pytest.main(["-vv", "-s", "-x", __file__])
|
@@ -110,6 +110,17 @@ def test_urgent_and_priority(capsys):
|
|
110
110
|
with pytest.raises(TypeError):
|
111
111
|
X(process="", priority=1)
|
112
112
|
|
113
|
+
def test_value():
|
114
|
+
env = sim.Environment(trace=False)
|
115
|
+
s1 = sim.State(name="s.", value=0)
|
116
|
+
env.run(1)
|
117
|
+
s1.value.value+=1
|
118
|
+
env.run(1)
|
119
|
+
s1.value.value+=1
|
120
|
+
env.run(1)
|
121
|
+
|
122
|
+
assert s1()==2
|
123
|
+
|
113
124
|
|
114
125
|
if __name__ == "__main__":
|
115
126
|
pytest.main(["-vv", "-s", __file__])
|
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
|
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
|
File without changes
|