oh-my-batch 0.4.3__tar.gz → 0.4.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oh-my-batch
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary:
5
5
  License: GPL
6
6
  Author: weihong.xu
@@ -33,7 +33,7 @@ class ComboMaker:
33
33
  self.add_var(key, *args)
34
34
  return self
35
35
 
36
- def add_randint(self, key: str, n: int, a: int, b: int, seed=None):
36
+ def add_randint(self, key: str, n: int, a: int, b: int, uniq=False, seed=None):
37
37
  """
38
38
  Add a variable with random integer values
39
39
 
@@ -41,11 +41,17 @@ class ComboMaker:
41
41
  :param n: Number of values
42
42
  :param a: Lower bound
43
43
  :param b: Upper bound
44
+ :param uniq: If True, values are unique, default is False
44
45
  :param seed: Seed for random number generator
45
46
  """
46
47
  if seed is not None:
47
48
  random.seed(seed)
48
- args = [random.randint(a, b) for _ in range(n)]
49
+ if uniq:
50
+ if b - a + 1 < n:
51
+ raise ValueError("Not enough unique values")
52
+ args = random.sample(range(a, b + 1), n)
53
+ else:
54
+ args = [random.randint(a, b) for _ in range(n)]
49
55
  self.add_var(key, *args)
50
56
  return self
51
57
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "oh-my-batch"
3
- version = "0.4.3"
3
+ version = "0.4.4"
4
4
  description = ""
5
5
  authors = ["weihong.xu <xuweihong.cn@gmail.com>"]
6
6
  license = "GPL"
File without changes
File without changes