phylogenie 1.0.3__py3-none-any.whl → 1.0.4__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.
@@ -80,7 +80,7 @@ class SkylineMatrix:
80
80
  def get_value_at_time(self, time: pgt.Scalar) -> pgt.Vector2D:
81
81
  return [param.get_value_at_time(time) for param in self.params]
82
82
 
83
- def operate(
83
+ def _operate(
84
84
  self,
85
85
  other: SkylineMatrixOperand,
86
86
  func: Callable[
@@ -97,28 +97,28 @@ class SkylineMatrix:
97
97
  )
98
98
 
99
99
  def __add__(self, operand: SkylineMatrixOperand) -> "SkylineMatrix":
100
- return self.operate(operand, lambda x, y: x + y)
100
+ return self._operate(operand, lambda x, y: x + y)
101
101
 
102
102
  def __radd__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
103
- return self.operate(operand, lambda x, y: y + x)
103
+ return self._operate(operand, lambda x, y: y + x)
104
104
 
105
105
  def __sub__(self, operand: SkylineMatrixOperand) -> "SkylineMatrix":
106
- return self.operate(operand, lambda x, y: x - y)
106
+ return self._operate(operand, lambda x, y: x - y)
107
107
 
108
108
  def __rsub__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
109
- return self.operate(operand, lambda x, y: y - x)
109
+ return self._operate(operand, lambda x, y: y - x)
110
110
 
111
111
  def __mul__(self, operand: SkylineMatrixOperand) -> "SkylineMatrix":
112
- return self.operate(operand, lambda x, y: x * y)
112
+ return self._operate(operand, lambda x, y: x * y)
113
113
 
114
114
  def __rmul__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
115
- return self.operate(operand, lambda x, y: y * x)
115
+ return self._operate(operand, lambda x, y: y * x)
116
116
 
117
117
  def __truediv__(self, operand: SkylineMatrixOperand) -> "SkylineMatrix":
118
- return self.operate(operand, lambda x, y: x / y)
118
+ return self._operate(operand, lambda x, y: x / y)
119
119
 
120
120
  def __rtruediv__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
121
- return self.operate(operand, lambda x, y: y / x)
121
+ return self._operate(operand, lambda x, y: y / x)
122
122
 
123
123
  @property
124
124
  def T(self) -> "SkylineMatrix":
@@ -23,7 +23,7 @@ class SkylineParameter:
23
23
  self,
24
24
  value: pgt.OneOrManyScalars,
25
25
  change_times: pgt.ManyScalars | None = None,
26
- ) -> None:
26
+ ):
27
27
  if isinstance(value, pgt.Scalar):
28
28
  value = [value]
29
29
  elif not tg.is_many_scalars(value):
@@ -42,18 +42,29 @@ class SkylineParameter:
42
42
  raise ValueError(
43
43
  f"`value` must have exactly one more element than `change_times` (got value={value} of length {len(value)} and change_times={change_times} of length {len(change_times)})."
44
44
  )
45
+ if any(t1 >= t2 for t1, t2 in zip(change_times, change_times[1:])):
46
+ raise ValueError(
47
+ f"`change_times` must be sorted in strictly increasing order "
48
+ f"(got change_times={change_times})."
49
+ )
50
+ if any(t < 0 for t in change_times):
51
+ raise ValueError(
52
+ f"`change_times` must be non-negative (got change_times={change_times})."
53
+ )
45
54
 
46
55
  self.value = [value[0]]
47
56
  self.change_times: list[pgt.Scalar] = []
48
57
  for i in range(1, len(value)):
49
58
  if value[i] != value[i - 1]:
50
59
  self.value.append(value[i])
51
- self.value.append(change_times[i - 1])
60
+ self.change_times.append(change_times[i - 1])
52
61
 
53
62
  def get_value_at_time(self, t: pgt.Scalar) -> pgt.Scalar:
63
+ if t < 0:
64
+ raise ValueError(f"Time cannot be negative (got t={t}).")
54
65
  return self.value[bisect_right(self.change_times, t)]
55
66
 
56
- def operate(
67
+ def _operate(
57
68
  self,
58
69
  other: SkylineParameterLike,
59
70
  f: Callable[[pgt.Scalar, pgt.Scalar], pgt.Scalar],
@@ -67,28 +78,28 @@ class SkylineParameter:
67
78
  return SkylineParameter(value, change_times)
68
79
 
69
80
  def __add__(self, other: SkylineParameterLike) -> "SkylineParameter":
70
- return self.operate(other, lambda x, y: x + y)
81
+ return self._operate(other, lambda x, y: x + y)
71
82
 
72
83
  def __radd__(self, other: pgt.Scalar) -> "SkylineParameter":
73
- return self.operate(other, lambda x, y: y + x)
84
+ return self._operate(other, lambda x, y: y + x)
74
85
 
75
86
  def __sub__(self, other: SkylineParameterLike) -> "SkylineParameter":
76
- return self.operate(other, lambda x, y: x - y)
87
+ return self._operate(other, lambda x, y: x - y)
77
88
 
78
89
  def __rsub__(self, other: pgt.Scalar) -> "SkylineParameter":
79
- return self.operate(other, lambda x, y: y - x)
90
+ return self._operate(other, lambda x, y: y - x)
80
91
 
81
92
  def __mul__(self, other: SkylineParameterLike) -> "SkylineParameter":
82
- return self.operate(other, lambda x, y: x * y)
93
+ return self._operate(other, lambda x, y: x * y)
83
94
 
84
95
  def __rmul__(self, other: pgt.Scalar) -> "SkylineParameter":
85
- return self.operate(other, lambda x, y: y * x)
96
+ return self._operate(other, lambda x, y: y * x)
86
97
 
87
98
  def __truediv__(self, other: SkylineParameterLike) -> "SkylineParameter":
88
- return self.operate(other, lambda x, y: x / y)
99
+ return self._operate(other, lambda x, y: x / y)
89
100
 
90
101
  def __rtruediv__(self, other: pgt.Scalar) -> "SkylineParameter":
91
- return self.operate(other, lambda x, y: y / x)
102
+ return self._operate(other, lambda x, y: y / x)
92
103
 
93
104
  def __bool__(self) -> bool:
94
105
  return any(self.value)
@@ -34,7 +34,7 @@ class SkylineVector:
34
34
  params: pgt.Many[SkylineParameterLike] | None = None,
35
35
  value: pgt.Many2DScalars | None = None,
36
36
  change_times: pgt.ManyScalars | None = None,
37
- ) -> None:
37
+ ):
38
38
  if params is not None and value is None and change_times is None:
39
39
  if is_many_skyline_parameters_like(params):
40
40
  self.params = [skyline_parameter(param) for param in params]
@@ -77,7 +77,7 @@ class SkylineVector:
77
77
  def get_value_at_time(self, t: pgt.Scalar) -> pgt.Vector1D:
78
78
  return [param.get_value_at_time(t) for param in self.params]
79
79
 
80
- def operate(
80
+ def _operate(
81
81
  self,
82
82
  other: SkylineVectorOperand,
83
83
  func: Callable[[SkylineParameter, SkylineParameter], SkylineParameter],
@@ -90,28 +90,28 @@ class SkylineVector:
90
90
  )
91
91
 
92
92
  def __add__(self, operand: SkylineVectorOperand) -> "SkylineVector":
93
- return self.operate(operand, lambda x, y: x + y)
93
+ return self._operate(operand, lambda x, y: x + y)
94
94
 
95
95
  def __radd__(self, operand: SkylineParameterLike) -> "SkylineVector":
96
- return self.operate(operand, lambda x, y: y + x)
96
+ return self._operate(operand, lambda x, y: y + x)
97
97
 
98
98
  def __sub__(self, operand: SkylineVectorOperand) -> "SkylineVector":
99
- return self.operate(operand, lambda x, y: x - y)
99
+ return self._operate(operand, lambda x, y: x - y)
100
100
 
101
101
  def __rsub__(self, operand: SkylineParameterLike) -> "SkylineVector":
102
- return self.operate(operand, lambda x, y: y - x)
102
+ return self._operate(operand, lambda x, y: y - x)
103
103
 
104
104
  def __mul__(self, operand: SkylineVectorOperand) -> "SkylineVector":
105
- return self.operate(operand, lambda x, y: x * y)
105
+ return self._operate(operand, lambda x, y: x * y)
106
106
 
107
107
  def __rmul__(self, operand: SkylineParameterLike) -> "SkylineVector":
108
- return self.operate(operand, lambda x, y: y * x)
108
+ return self._operate(operand, lambda x, y: y * x)
109
109
 
110
110
  def __truediv__(self, operand: SkylineVectorOperand) -> "SkylineVector":
111
- return self.operate(operand, lambda x, y: x / y)
111
+ return self._operate(operand, lambda x, y: x / y)
112
112
 
113
113
  def __rtruediv__(self, operand: SkylineParameterLike) -> "SkylineVector":
114
- return self.operate(operand, lambda x, y: y / x)
114
+ return self._operate(operand, lambda x, y: y / x)
115
115
 
116
116
  def __len__(self) -> int:
117
117
  return self.N
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phylogenie
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: Generate phylogenetic datasets with minimal setup effort
5
5
  Author: Gabriele Marino
6
6
  Author-email: gabmarino.8601@gmail.com
@@ -27,13 +27,13 @@ phylogenie/core/typeguards.py,sha256=yxTdE4G_1gjBFqplyei-GKz4KZo2KFh8qsEsPQ2Z5OQ
27
27
  phylogenie/main.py,sha256=n_joau3dWJIq0ZMHe4a_1_2GigTFagkfzUFuQEMlyRI,1158
28
28
  phylogenie/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  phylogenie/skyline/__init__.py,sha256=7pF4CUb4ZCLzNYJNhOjpuTOLTRhlK7L6ugfccNqjIGo,620
30
- phylogenie/skyline/matrix.py,sha256=WH1aT23hv4QYuH4GDwcJgahrqcgB4mulfzKLGUx3R6M,7091
31
- phylogenie/skyline/parameter.py,sha256=wrtvQDho3OC5tzrMnnFTy95GXaYN20KN8P5Gwyf-rHI,4023
32
- phylogenie/skyline/vector.py,sha256=NgmVbWjWG_itZ9a57q9QqSybvG9-Cr9X264RGPVyp_Q,6399
30
+ phylogenie/skyline/matrix.py,sha256=8C8jFmIFbxYWmmfnPwi6qaew4oErQznvZN8JuvkD8kQ,7100
31
+ phylogenie/skyline/parameter.py,sha256=RXZoaC46FFGTjD8rNb0dkWAZH4Pfxfn2dFGID3l0dMs,4551
32
+ phylogenie/skyline/vector.py,sha256=VuCnIq9aIlKZIiqHWIbrpiOdwSDKXNPuIPunlULaYaQ,6400
33
33
  phylogenie/typeguards.py,sha256=WBOSJSaOC8VDtrYoA2w_AYEXTpyKdCfmsM29KaKXl3A,1350
34
34
  phylogenie/typings.py,sha256=93VRedBxrpzXkT4uaNu_1JiMzsOjp7fUy4kLv_eYxUE,565
35
- phylogenie-1.0.3.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
36
- phylogenie-1.0.3.dist-info/METADATA,sha256=JVGcZNn6O2Wuuek_ZTQp5CBdw5_xoSHzvSyTmENmxNw,6251
37
- phylogenie-1.0.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
38
- phylogenie-1.0.3.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
39
- phylogenie-1.0.3.dist-info/RECORD,,
35
+ phylogenie-1.0.4.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
36
+ phylogenie-1.0.4.dist-info/METADATA,sha256=Ly88IxdRijacsz4-TglRG5GbjjcDkxQxLf5U0kLEj-c,6251
37
+ phylogenie-1.0.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
38
+ phylogenie-1.0.4.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
39
+ phylogenie-1.0.4.dist-info/RECORD,,