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

Sign up to get free protection for your applications and to get access to all the features.
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.17"
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:
@@ -7956,7 +7956,6 @@ by adding:
7956
7956
  lineno = self.lineno_txt(add_at=True)
7957
7957
  self.env.print_trace("", "", self.name() + " resume (" + self.status() + ")", merge_blanks(lineno, self._modetxt()))
7958
7958
  if self.status.value == scheduled:
7959
- reason = "hold"
7960
7959
  self._reschedule(self.env._now + self._remaining_duration, priority, urgent, "hold", False)
7961
7960
  else:
7962
7961
  raise Exception(self.name() + " unexpected interrupted_status", self.status.value())
@@ -9066,7 +9065,7 @@ by adding:
9066
9065
  honored = False
9067
9066
  break
9068
9067
  elif valuetype == 1:
9069
- if eval(value.replace("$", "state._value")):
9068
+ if not eval(value.replace("$", "state._value")):
9070
9069
  honored = False
9071
9070
  break
9072
9071
  elif valuetype == 2:
@@ -11725,14 +11724,20 @@ class Environment:
11725
11724
  format="GIF",
11726
11725
  )
11727
11726
  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
- )
11727
+ for _ in range(2): # normally runs only once
11728
+ try:
11729
+ self._images[0].save(
11730
+ self._video_name,
11731
+ disposal=2,
11732
+ save_all=True,
11733
+ append_images=self._images[1:],
11734
+ duration=round(1000 / self._real_fps),
11735
+ optimize=False,
11736
+ )
11737
+ break
11738
+ except ValueError: # prevent bug in Python 3.13
11739
+ self._images=[image.convert("RGB") for image in self._images]
11740
+
11736
11741
  else:
11737
11742
  if PythonInExcel or AnacondaCode:
11738
11743
  with b64_file_handler(self._video_name, mode="b", result=_pie_result) as f:
@@ -11747,15 +11752,20 @@ class Environment:
11747
11752
  format="GIF",
11748
11753
  )
11749
11754
  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
- )
11755
+ for _ in range(2): # normally runs only once
11756
+ try:
11757
+
11758
+ self._images[0].save(
11759
+ self._video_name,
11760
+ disposal=2,
11761
+ save_all=True,
11762
+ append_images=self._images[1:],
11763
+ loop=self._video_repeat,
11764
+ duration=round(1000 / self._real_fps),
11765
+ optimize=False,
11766
+ )
11767
+ except ValueError: # prevent bug in Python 3.13
11768
+ self._images=[image.convert("RGB") for image in self._images]
11759
11769
 
11760
11770
  del self._images
11761
11771
  elif self._video_out == "png":
@@ -11804,7 +11814,6 @@ class Environment:
11804
11814
  ao.make_pil_image(self.t())
11805
11815
  if ao._image_visible and (include_topleft or not ao.getattr("in_topleft", False)):
11806
11816
  image.paste(ao._image, (int(ao._image_x), int(self._height - ao._image_y - ao._image.size[1])), ao._image.convert("RGBA"))
11807
-
11808
11817
  return image.convert(mode)
11809
11818
 
11810
11819
  def insert_frame(self, image: Any, number_of_frames: int = 1) -> None:
@@ -11819,6 +11828,8 @@ class Environment:
11819
11828
  nuumber_of_frames: int
11820
11829
  Number of 1/30 second long frames to be inserted
11821
11830
  """
11831
+
11832
+
11822
11833
  if self._video_out is None:
11823
11834
  raise ValueError("video not set")
11824
11835
  if isinstance(image, (Path, str)):
@@ -11844,6 +11855,7 @@ class Environment:
11844
11855
  open_cv_image = cv2.cvtColor(numpy.array(image), cv2.COLOR_RGB2BGR)
11845
11856
  self._video_out.write(open_cv_image)
11846
11857
 
11858
+
11847
11859
  def _save_frame(self):
11848
11860
  self._exclude_from_animation = "not in video"
11849
11861
  image = self._capture_image("RGBA", self._video_mode)
@@ -25118,7 +25130,7 @@ def resize_with_pad(im, target_width, target_height):
25118
25130
  """
25119
25131
  Resize PIL image keeping ratio and using black background.
25120
25132
  """
25121
- if im.height == target_width and im.width == target_height:
25133
+ if im.height == target_height and im.width == target_width:
25122
25134
  return im
25123
25135
  target_ratio = target_height / target_width
25124
25136
  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.17
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=-u4nEmv4kHg0im9ZC_yL31bvXNBuJNWFLuBf_FYhCpE,1115641
7
+ salabim-24.0.17.dist-info/METADATA,sha256=1ZtRaop2jcG8-kTv1-viuasV_UnkXuT46PuvMG6uGDs,3458
8
+ salabim-24.0.17.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
9
+ salabim-24.0.17.dist-info/top_level.txt,sha256=UE6zVlbi3F6T5ma1a_5TrojMaF21GYKDt9svvm0U4cQ,8
10
+ salabim-24.0.17.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