salabim 24.0.9.post0__tar.gz → 24.0.10.post0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/PKG-INFO +3 -3
  2. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/README.md +64 -64
  3. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/pyproject.toml +1 -1
  4. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim/salabim.py +75 -43
  5. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim.egg-info/PKG-INFO +3 -3
  6. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim/DejaVuSansMono.ttf +0 -0
  7. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim/LICENSE.txt +0 -0
  8. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim/__init__.py +0 -0
  9. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim/calibri.ttf +0 -0
  10. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim/mplus-1m-regular.ttf +0 -0
  11. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim.egg-info/SOURCES.txt +0 -0
  12. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim.egg-info/dependency_links.txt +0 -0
  13. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/salabim.egg-info/top_level.txt +0 -0
  14. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/setup.cfg +0 -0
  15. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test salabim.py +0 -0
  16. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_cap_now.py +0 -0
  17. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_componentgenerator.py +0 -0
  18. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_datetime.py +0 -0
  19. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_distributions.py +0 -0
  20. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_misc.py +0 -0
  21. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_monitor.py +0 -0
  22. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_process.py +0 -0
  23. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_queue.py +0 -0
  24. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_state.py +0 -0
  25. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_store.py +0 -0
  26. {salabim-24.0.9.post0 → salabim-24.0.10.post0}/tests/test_timeunit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: salabim
3
- Version: 24.0.9.post0
3
+ Version: 24.0.10.post0
4
4
  Summary: salabim - discrete event simulation in Python
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://salabim.org
@@ -46,11 +46,11 @@ In contrast to some other Python DES packages, salabim does not require the use
46
46
  ### Features and documentation
47
47
 
48
48
  - Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
49
- - Comprehensive documentation: Visit https://www.salabim.org/manual for detailed documentation.
49
+ - Comprehensive documentation: Visit [www.salabim.org/manual](www.salabim.org/manual) for detailed documentation.
50
50
 
51
51
  ### Resources
52
52
 
53
- The salabim package can be found on GitHub: https://www.github.com/salabim/salabim
53
+ The salabim package can be found on GitHub: www.github.com/salabim/salabim
54
54
 
55
55
  And on PyPI: https://pypi.org/project/salabim/
56
56
 
@@ -1,64 +1,64 @@
1
- <img src="https://www.salabim.org/salabim_logo_payoff.png" width=400 />
2
-
3
- Salabim is a Python library for object-oriented discrete event simulation (DES) and animation.
4
-
5
- ### Introduction
6
-
7
- Discrete event simulation (DES) finds applications in various logistical domains including production facilities, warehousing, airports, hospitals, mining, materials handling, steel mills, and computer network analysis.
8
-
9
- Salabim follows a well-proven and intuitive process description method similar to Tomas and Must.</br>The package provides:
10
-
11
- - Components
12
- - Queues
13
- - Resources
14
- - Stores
15
- - States
16
- - Monitors for data collection and presentation
17
- - 2D and 3D animation (including video production) (see below)
18
- - Tracing facilities
19
- - Advanced statistical sampling
20
-
21
- In contrast to some other Python DES packages, salabim does not require the use of yield statements for process control, making it more straightforward to use. Salabim has minimal requirements, especially when animation is disabled.
22
-
23
-
24
-
25
- ### Some salabim animations
26
-
27
- <img src="https://www.salabim.org/cymulation3d.gif" width=700 />
28
-
29
- <img src="https://www.salabim.org/elevator.gif" width=700 />
30
-
31
- <img src="https://www.salabim.org/lights-3d.gif" width=700 />
32
-
33
- ### Features and documentation
34
-
35
- - Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
36
- - Comprehensive documentation: Visit https://www.salabim.org/manual for detailed documentation.
37
-
38
- ### Resources
39
-
40
- The salabim package can be found on GitHub: https://www.github.com/salabim/salabim
41
-
42
- And on PyPI: https://pypi.org/project/salabim/
43
-
44
- ### Contributing and Reporting Issues
45
-
46
- Contributions to salabim are highly appreciated! You can contribute by issuing a pull request or submitting an issue on [GitHub](https://github.com/salabim/salabim). Alternatively, you can use the [salabim Google user group](https://groups.google.com/g/salabim) for discussions and reporting issues.
47
-
48
- ### License
49
-
50
- Salabim is licensed under the MIT License. For details, please refer to the [LICENSE](LICENSE) file.
51
-
52
- ### Support
53
-
54
- Ruud van der Ham, the core developer, is available and willing to help users with issues related to the package and modeling in general. He also provides services such as code and model reviews, consultancy, and training.
55
-
56
- ### Getting Started
57
-
58
- To start using salabim, visit [www.salabim.org](www.salabim.org) for installation instructions and further details.
59
-
60
- ### Badges
61
-
62
- ![PyPI](https://img.shields.io/pypi/v/salabim) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/salabim) ![PyPI - Implementation](https://img.shields.io/pypi/implementation/salabim)
63
- ![PyPI - License](https://img.shields.io/pypi/l/salabim) ![Black](https://img.shields.io/badge/code%20style-black-000000.svg)
64
- ![GitHub last commit](https://img.shields.io/github/last-commit/salabim/salabim)
1
+ <img src="https://www.salabim.org/salabim_logo_payoff.png" width=400 />
2
+
3
+ Salabim is a Python library for object-oriented discrete event simulation (DES) and animation.
4
+
5
+ ### Introduction
6
+
7
+ Discrete event simulation (DES) finds applications in various logistical domains including production facilities, warehousing, airports, hospitals, mining, materials handling, steel mills, and computer network analysis.
8
+
9
+ Salabim follows a well-proven and intuitive process description method similar to Tomas and Must.</br>The package provides:
10
+
11
+ - Components
12
+ - Queues
13
+ - Resources
14
+ - Stores
15
+ - States
16
+ - Monitors for data collection and presentation
17
+ - 2D and 3D animation (including video production) (see below)
18
+ - Tracing facilities
19
+ - Advanced statistical sampling
20
+
21
+ In contrast to some other Python DES packages, salabim does not require the use of yield statements for process control, making it more straightforward to use. Salabim has minimal requirements, especially when animation is disabled.
22
+
23
+
24
+
25
+ ### Some salabim animations
26
+
27
+ <img src="https://www.salabim.org/cymulation3d.gif" width=700 />
28
+
29
+ <img src="https://www.salabim.org/elevator.gif" width=700 />
30
+
31
+ <img src="https://www.salabim.org/lights-3d.gif" width=700 />
32
+
33
+ ### Features and documentation
34
+
35
+ - Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
36
+ - Comprehensive documentation: Visit [www.salabim.org/manual](www.salabim.org/manual) for detailed documentation.
37
+
38
+ ### Resources
39
+
40
+ The salabim package can be found on GitHub: www.github.com/salabim/salabim
41
+
42
+ And on PyPI: https://pypi.org/project/salabim/
43
+
44
+ ### Contributing and Reporting Issues
45
+
46
+ Contributions to salabim are highly appreciated! You can contribute by issuing a pull request or submitting an issue on [GitHub](https://github.com/salabim/salabim). Alternatively, you can use the [salabim Google user group](https://groups.google.com/g/salabim) for discussions and reporting issues.
47
+
48
+ ### License
49
+
50
+ Salabim is licensed under the MIT License. For details, please refer to the [LICENSE](LICENSE) file.
51
+
52
+ ### Support
53
+
54
+ Ruud van der Ham, the core developer, is available and willing to help users with issues related to the package and modeling in general. He also provides services such as code and model reviews, consultancy, and training.
55
+
56
+ ### Getting Started
57
+
58
+ To start using salabim, visit [www.salabim.org](www.salabim.org) for installation instructions and further details.
59
+
60
+ ### Badges
61
+
62
+ ![PyPI](https://img.shields.io/pypi/v/salabim) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/salabim) ![PyPI - Implementation](https://img.shields.io/pypi/implementation/salabim)
63
+ ![PyPI - License](https://img.shields.io/pypi/l/salabim) ![Black](https://img.shields.io/badge/code%20style-black-000000.svg)
64
+ ![GitHub last commit](https://img.shields.io/github/last-commit/salabim/salabim)
@@ -8,7 +8,7 @@ authors = [
8
8
  {name = "Ruud van der Ham", email = "rt.van.der.ham@gmail.com"}
9
9
  ]
10
10
  description = "salabim - discrete event simulation in Python"
11
- version = "24.0.9-0"
11
+ version = "24.0.10-0"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.7"
14
14
  dependencies = [
@@ -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.9"
10
+ __version__ = "24.0.10"
11
11
 
12
12
  import heapq
13
13
  import random
@@ -59,7 +59,7 @@ Windows = sys.platform.startswith("win")
59
59
  PyDroid = sys.platform == "linux" and any("pydroid" in v for v in os.environ.values())
60
60
  PyPy = platform.python_implementation() == "PyPy"
61
61
  Chromebook = "penguin" in platform.uname()
62
- PythonInExcel = not ("__file__" in globals())
62
+ PythonInExcel = not ("__file__" in globals()) or ("REF" in globals()) # REF is for AnacondaCode
63
63
 
64
64
 
65
65
  def a_log(*args):
@@ -445,10 +445,8 @@ class Monitor:
445
445
  *args,
446
446
  **kwargs,
447
447
  ):
448
- if env is None:
449
- self.env = g.default_env
450
- else:
451
- self.env = env
448
+ self.env = _set_env(env)
449
+
452
450
  if isinstance(self.env, Environment):
453
451
  _set_name(name, self.env._nameserializeMonitor, self)
454
452
  else:
@@ -855,8 +853,10 @@ class Monitor:
855
853
  else:
856
854
  stop += self.env._offset
857
855
  stop_action = "b" # non inclusive
858
-
859
- stop = min(stop, self.env._now - self.env._offset) # not self.now() in order to support frozen monitors
856
+ if self.env._animate:
857
+ stop=min(stop,self.env._t)
858
+ else:
859
+ stop = min(stop, self.env._now - self.env._offset) # not self.now() in order to support frozen monitors
860
860
  actions.append((start, "a", 0, 0))
861
861
  actions.append((stop, stop_action, 0, 0))
862
862
  else:
@@ -888,8 +888,33 @@ class Monitor:
888
888
  new._x.append(curx)
889
889
 
890
890
  enabled = False
891
+ if self.env._animate:
892
+ _x=self._x[:]
893
+ _t=self._t[:]
894
+ if self._x:
895
+ _x.append(self._x[-1])
896
+ _t.append(self.env._t)
897
+ if isinstance(self._weight,bool):
898
+ _weight=self._weight
899
+ else:
900
+ _weight=self._weight[:]
901
+ _weight.append(self._weight[-1])
902
+ else:
903
+ _x=self._x
904
+ _t=self._t
905
+ _weight=self._weight
906
+
907
+
908
+ if self.env._animate:
909
+ if self._x:
910
+ _x.append(_x[-1])
911
+ _t.append(self.env._t)
912
+ try:
913
+ _weight.append(self.weight[-1])
914
+ except AttributeError:
915
+ ... # ignore if bool
891
916
  for t, type, x, weight in heapq.merge(
892
- actions, zip(self._t, itertools.repeat("c"), self._x, self._weight if (self._weight and not self._level) else (1,) * len(self._x))
917
+ actions, zip(self._t, itertools.repeat("c"), _x, _weight if (_weight and not self._level) else (1,) * len(_x))
893
918
  ):
894
919
  if new._level:
895
920
  if type == "a":
@@ -4293,10 +4318,8 @@ class Queue:
4293
4318
  """
4294
4319
 
4295
4320
  def __init__(self, name: str = None, monitor: Any = True, fill: Iterable = None, capacity: float = inf, env: "Environment" = None, *args, **kwargs) -> None:
4296
- if env is None:
4297
- self.env = g.default_env
4298
- else:
4299
- self.env = env
4321
+ self.env = _set_env(env)
4322
+
4300
4323
  _set_name(name, self.env._nameserializeQueue, self)
4301
4324
  self._head = Qmember()
4302
4325
  self._tail = Qmember()
@@ -5819,7 +5842,8 @@ class Animate3dBase(DynamicClass):
5819
5842
  self, visible: bool = True, keep: bool = True, arg: Any = None, layer: float = 0, parent: "Component" = None, env: "Environment" = None, **kwargs
5820
5843
  ) -> None:
5821
5844
  super().__init__()
5822
- self.env = g.default_env if env is None else env
5845
+ self.env = _set_env(env)
5846
+
5823
5847
  self.visible = visible
5824
5848
  self.keep = keep
5825
5849
  self.arg = self if arg is None else arg
@@ -7063,10 +7087,8 @@ class Component:
7063
7087
  env: "Environment" = None,
7064
7088
  **kwargs,
7065
7089
  ):
7066
- if env is None:
7067
- self.env = g.default_env
7068
- else:
7069
- self.env = env
7090
+ self.env = _set_env(env)
7091
+
7070
7092
  _set_name(name, self.env._nameserializeComponent, self)
7071
7093
  self._qmembers = {}
7072
7094
  self._process = None
@@ -14673,7 +14695,7 @@ class Environment:
14673
14695
  if self._last_animate != self._animate or self._last_paused != self._paused:
14674
14696
  for key in self._ui_window.key_dict:
14675
14697
  field = self._ui_window[key]
14676
- if type(field) != sg.PySimpleGUI.HorizontalSeparator:
14698
+ if type(field) != sg.HorizontalSeparator:
14677
14699
  if self._paused:
14678
14700
  field.update(visible=True)
14679
14701
  else:
@@ -14850,9 +14872,10 @@ class Animate2dBase(DynamicClass):
14850
14872
  screen_coordinates = locals_["screen_coordinates"]
14851
14873
  over3d = locals_["over3d"]
14852
14874
 
14853
- self.env = g.default_env if env is None else env
14875
+ self.env = _set_env(env)
14876
+
14854
14877
  self.sequence = self.env.serialize()
14855
- self.arg = self if arg in (None, object) else arg
14878
+ self.arg = self if arg in (None, object) else arg
14856
14879
  self.over3d = _default_over3d if over3d is None else over3d
14857
14880
  self.screen_coordinates = screen_coordinates
14858
14881
  self.attached_to = attached_to
@@ -15930,7 +15953,8 @@ class Animate:
15930
15953
  animation_to: float = inf,
15931
15954
  env: "Environment" = None,
15932
15955
  ):
15933
- self.env = g.default_env if env is None else env
15956
+ self.env = _set_env(env)
15957
+
15934
15958
  self._image_ident = None # denotes no image yet
15935
15959
  self._image = None
15936
15960
  self._image_x = 0
@@ -17052,7 +17076,8 @@ class AnimateEntry:
17052
17076
  env: "Environment" = None,
17053
17077
  xy_anchor: str = "sw",
17054
17078
  ):
17055
- self.env = g.default_env if env is None else env
17079
+ self.env = _set_env(env)
17080
+
17056
17081
  self.env.ui_objects.append(self)
17057
17082
  self.type = "entry"
17058
17083
  self.value = value
@@ -17197,7 +17222,8 @@ class AnimateButton:
17197
17222
  env: "Environment" = None,
17198
17223
  xy_anchor: str = "sw",
17199
17224
  ):
17200
- self.env = g.default_env if env is None else env
17225
+ self.env = _set_env(env)
17226
+
17201
17227
  self.type = "button"
17202
17228
  self.t0 = -inf
17203
17229
  self.t1 = inf
@@ -17378,7 +17404,7 @@ class AnimateSlider:
17378
17404
  labelcolor: ColorType = None, # only for backward compatibility
17379
17405
  layer: float = None, # only for backward compatibility
17380
17406
  ):
17381
- self.env = g.default_env if env is None else env
17407
+ self.env = _set_env(env)
17382
17408
  n = round((vmax - vmin) / resolution) + 1
17383
17409
  self.vmin = vmin
17384
17410
  self.vmax = vmin + (n - 1) * resolution
@@ -22640,10 +22666,7 @@ class State:
22640
22666
  """
22641
22667
 
22642
22668
  def __init__(self, name: str = None, value: Any = False, type: str = "any", monitor: bool = True, env: "Environment" = None, *args, **kwargs):
22643
- if env is None:
22644
- self.env = g.default_env
22645
- else:
22646
- self.env = env
22669
+ self.env = _set_env(env)
22647
22670
  _set_name(name, self.env._nameserializeState, self)
22648
22671
  self._value = value
22649
22672
  with self.env.suppress_trace():
@@ -23118,11 +23141,7 @@ class Resource:
23118
23141
  *args,
23119
23142
  **kwargs,
23120
23143
  ):
23121
- if env is None:
23122
- self.env = g.default_env
23123
- else:
23124
- self.env = env
23125
-
23144
+ self.env = _set_env(env)
23126
23145
  if initial_claimed_quantity != 0:
23127
23146
  if not anonymous:
23128
23147
  raise ValueError("initial_claimed_quantity != 0 only allowed for anonymous resources")
@@ -23651,10 +23670,8 @@ class PeriodMonitor:
23651
23670
 
23652
23671
  def __init__(self, parent_monitor: "Monitor", periods: Iterable = None, period_monitor_names: Iterable = None, env: "Environment" = None):
23653
23672
  self.pc = _PeriodComponent(pm=self, skip_standby=True, suppress_trace=True)
23654
- if env is None:
23655
- self.env = g.default_env
23656
- else:
23657
- self.env = env
23673
+ self.env = _set_env(env)
23674
+
23658
23675
  if periods is None:
23659
23676
  periods = 24 * [1]
23660
23677
  self.periods = periods
@@ -26931,6 +26948,21 @@ def reset() -> None:
26931
26948
  random_seed() # always start with seed 1234567
26932
26949
 
26933
26950
 
26951
+ def _set_env(env):
26952
+ """
26953
+ returns g._default_env if env is None
26954
+ returns env, otherwise
26955
+
26956
+ will raise a ValueError if g.default_env is None (nit initialized)
26957
+ """
26958
+
26959
+ if env is None:
26960
+ if g.default_env is None:
26961
+ raise ValueError("no default environment. Did yout forget to call sim.Environment()?")
26962
+ return g.default_env
26963
+ return env
26964
+
26965
+
26934
26966
  App = Environment
26935
26967
 
26936
26968
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: salabim
3
- Version: 24.0.9.post0
3
+ Version: 24.0.10.post0
4
4
  Summary: salabim - discrete event simulation in Python
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://salabim.org
@@ -46,11 +46,11 @@ In contrast to some other Python DES packages, salabim does not require the use
46
46
  ### Features and documentation
47
47
 
48
48
  - Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
49
- - Comprehensive documentation: Visit https://www.salabim.org/manual for detailed documentation.
49
+ - Comprehensive documentation: Visit [www.salabim.org/manual](www.salabim.org/manual) for detailed documentation.
50
50
 
51
51
  ### Resources
52
52
 
53
- The salabim package can be found on GitHub: https://www.github.com/salabim/salabim
53
+ The salabim package can be found on GitHub: www.github.com/salabim/salabim
54
54
 
55
55
  And on PyPI: https://pypi.org/project/salabim/
56
56