salabim 24.0.15__py3-none-any.whl → 24.0.16__py3-none-any.whl

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.
salabim/salabim.py CHANGED
@@ -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.15"
10
+ __version__ = "24.0.16"
11
11
 
12
12
  import heapq
13
13
  import random
@@ -7879,11 +7879,11 @@ by adding:
7879
7879
 
7880
7880
  Note
7881
7881
  ----
7882
- The component has to be scheduled.
7882
+ The component has to be scheduled or interrupted.
7883
7883
 
7884
7884
  Use resume() to resume
7885
7885
  """
7886
- if self.status.value != scheduled:
7886
+ if self.status.value not in (scheduled, interrupted):
7887
7887
  raise ValueError(self.name() + " component not scheduled")
7888
7888
  self.set_mode(mode)
7889
7889
  if self.status.value == interrupted:
@@ -11725,14 +11725,20 @@ class Environment:
11725
11725
  format="GIF",
11726
11726
  )
11727
11727
  else:
11728
- self._images[0].save(
11729
- self._video_name,
11730
- disposal=2,
11731
- save_all=True,
11732
- append_images=self._images[1:],
11733
- duration=round(1000 / self._real_fps),
11734
- optimize=False,
11735
- )
11728
+ for _ in range(2): # normally runs only once
11729
+ try:
11730
+ self._images[0].save(
11731
+ self._video_name,
11732
+ disposal=2,
11733
+ save_all=True,
11734
+ append_images=self._images[1:],
11735
+ duration=round(1000 / self._real_fps),
11736
+ optimize=False,
11737
+ )
11738
+ break
11739
+ except ValueError: # prevent bug in Python 3.13
11740
+ self._images=[image.convert("RGB") for image in self._images]
11741
+
11736
11742
  else:
11737
11743
  if PythonInExcel or AnacondaCode:
11738
11744
  with b64_file_handler(self._video_name, mode="b", result=_pie_result) as f:
@@ -11747,15 +11753,20 @@ class Environment:
11747
11753
  format="GIF",
11748
11754
  )
11749
11755
  else:
11750
- self._images[0].save(
11751
- self._video_name,
11752
- disposal=2,
11753
- save_all=True,
11754
- append_images=self._images[1:],
11755
- loop=self._video_repeat,
11756
- duration=round(1000 / self._real_fps),
11757
- optimize=False,
11758
- )
11756
+ for _ in range(2): # normally runs only once
11757
+ try:
11758
+
11759
+ self._images[0].save(
11760
+ self._video_name,
11761
+ disposal=2,
11762
+ save_all=True,
11763
+ append_images=self._images[1:],
11764
+ loop=self._video_repeat,
11765
+ duration=round(1000 / self._real_fps),
11766
+ optimize=False,
11767
+ )
11768
+ except ValueError: # prevent bug in Python 3.13
11769
+ self._images=[image.convert("RGB") for image in self._images]
11759
11770
 
11760
11771
  del self._images
11761
11772
  elif self._video_out == "png":
@@ -11804,7 +11815,6 @@ class Environment:
11804
11815
  ao.make_pil_image(self.t())
11805
11816
  if ao._image_visible and (include_topleft or not ao.getattr("in_topleft", False)):
11806
11817
  image.paste(ao._image, (int(ao._image_x), int(self._height - ao._image_y - ao._image.size[1])), ao._image.convert("RGBA"))
11807
-
11808
11818
  return image.convert(mode)
11809
11819
 
11810
11820
  def insert_frame(self, image: Any, number_of_frames: int = 1) -> None:
@@ -11819,6 +11829,8 @@ class Environment:
11819
11829
  nuumber_of_frames: int
11820
11830
  Number of 1/30 second long frames to be inserted
11821
11831
  """
11832
+
11833
+
11822
11834
  if self._video_out is None:
11823
11835
  raise ValueError("video not set")
11824
11836
  if isinstance(image, (Path, str)):
@@ -11844,6 +11856,7 @@ class Environment:
11844
11856
  open_cv_image = cv2.cvtColor(numpy.array(image), cv2.COLOR_RGB2BGR)
11845
11857
  self._video_out.write(open_cv_image)
11846
11858
 
11859
+
11847
11860
  def _save_frame(self):
11848
11861
  self._exclude_from_animation = "not in video"
11849
11862
  image = self._capture_image("RGBA", self._video_mode)
@@ -25118,7 +25131,7 @@ def resize_with_pad(im, target_width, target_height):
25118
25131
  """
25119
25132
  Resize PIL image keeping ratio and using black background.
25120
25133
  """
25121
- if im.height == target_width and im.width == target_height:
25134
+ if im.height == target_height and im.width == target_width:
25122
25135
  return im
25123
25136
  target_ratio = target_height / target_width
25124
25137
  im_ratio = im.height / im.width
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: salabim
3
- Version: 24.0.15
3
+ Version: 24.0.16
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
@@ -3,8 +3,8 @@ salabim/LICENSE.txt,sha256=qHlBa-POyexatCxDTjSKMlYtkBFQDn9lu-YV_1L6V0U,1106
3
3
  salabim/__init__.py,sha256=r7qPLvlmX0dkZDyjuTo8Jo3ex3sD1L4pmK6K5ib9vyw,56
4
4
  salabim/calibri.ttf,sha256=RWpf8Uo31RfvGGNaSt9-2sXSuN87AVE_NFMRsV3LhBk,1330156
5
5
  salabim/mplus-1m-regular.ttf,sha256=EuFHr90BJjuAn_r5MleJFN-WfkeWJ4tf7DweI5zr8tU,289812
6
- salabim/salabim.py,sha256=mSulf-mB7H9OocRoFMqbDL-KTQv7oshI_JhcKWZUddA,1114881
7
- salabim-24.0.15.dist-info/METADATA,sha256=QxxotPONZu3h5lJcdunPQX1xbq8H9tL9OA19ZX91Bs0,3458
8
- salabim-24.0.15.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
9
- salabim-24.0.15.dist-info/top_level.txt,sha256=UE6zVlbi3F6T5ma1a_5TrojMaF21GYKDt9svvm0U4cQ,8
10
- salabim-24.0.15.dist-info/RECORD,,
6
+ salabim/salabim.py,sha256=VwDD1blpoFir2EYTfcAt0_EGuvwDnbup3RcNyc7v7hI,1115673
7
+ salabim-24.0.16.dist-info/METADATA,sha256=FY3hDeBvxppeETZEjWRUerghxNtRYadYrCElZjy-dD0,3458
8
+ salabim-24.0.16.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
9
+ salabim-24.0.16.dist-info/top_level.txt,sha256=UE6zVlbi3F6T5ma1a_5TrojMaF21GYKDt9svvm0U4cQ,8
10
+ salabim-24.0.16.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.5.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5