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.
- phylogenie/skyline/matrix.py +9 -9
- phylogenie/skyline/parameter.py +22 -11
- phylogenie/skyline/vector.py +10 -10
- {phylogenie-1.0.3.dist-info → phylogenie-1.0.4.dist-info}/METADATA +1 -1
- {phylogenie-1.0.3.dist-info → phylogenie-1.0.4.dist-info}/RECORD +8 -8
- {phylogenie-1.0.3.dist-info → phylogenie-1.0.4.dist-info}/LICENSE.txt +0 -0
- {phylogenie-1.0.3.dist-info → phylogenie-1.0.4.dist-info}/WHEEL +0 -0
- {phylogenie-1.0.3.dist-info → phylogenie-1.0.4.dist-info}/entry_points.txt +0 -0
phylogenie/skyline/matrix.py
CHANGED
|
@@ -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
|
|
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.
|
|
100
|
+
return self._operate(operand, lambda x, y: x + y)
|
|
101
101
|
|
|
102
102
|
def __radd__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
|
|
103
|
-
return self.
|
|
103
|
+
return self._operate(operand, lambda x, y: y + x)
|
|
104
104
|
|
|
105
105
|
def __sub__(self, operand: SkylineMatrixOperand) -> "SkylineMatrix":
|
|
106
|
-
return self.
|
|
106
|
+
return self._operate(operand, lambda x, y: x - y)
|
|
107
107
|
|
|
108
108
|
def __rsub__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
|
|
109
|
-
return self.
|
|
109
|
+
return self._operate(operand, lambda x, y: y - x)
|
|
110
110
|
|
|
111
111
|
def __mul__(self, operand: SkylineMatrixOperand) -> "SkylineMatrix":
|
|
112
|
-
return self.
|
|
112
|
+
return self._operate(operand, lambda x, y: x * y)
|
|
113
113
|
|
|
114
114
|
def __rmul__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
|
|
115
|
-
return self.
|
|
115
|
+
return self._operate(operand, lambda x, y: y * x)
|
|
116
116
|
|
|
117
117
|
def __truediv__(self, operand: SkylineMatrixOperand) -> "SkylineMatrix":
|
|
118
|
-
return self.
|
|
118
|
+
return self._operate(operand, lambda x, y: x / y)
|
|
119
119
|
|
|
120
120
|
def __rtruediv__(self, operand: SkylineVectorOperand) -> "SkylineMatrix":
|
|
121
|
-
return self.
|
|
121
|
+
return self._operate(operand, lambda x, y: y / x)
|
|
122
122
|
|
|
123
123
|
@property
|
|
124
124
|
def T(self) -> "SkylineMatrix":
|
phylogenie/skyline/parameter.py
CHANGED
|
@@ -23,7 +23,7 @@ class SkylineParameter:
|
|
|
23
23
|
self,
|
|
24
24
|
value: pgt.OneOrManyScalars,
|
|
25
25
|
change_times: pgt.ManyScalars | None = None,
|
|
26
|
-
)
|
|
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.
|
|
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
|
|
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.
|
|
81
|
+
return self._operate(other, lambda x, y: x + y)
|
|
71
82
|
|
|
72
83
|
def __radd__(self, other: pgt.Scalar) -> "SkylineParameter":
|
|
73
|
-
return self.
|
|
84
|
+
return self._operate(other, lambda x, y: y + x)
|
|
74
85
|
|
|
75
86
|
def __sub__(self, other: SkylineParameterLike) -> "SkylineParameter":
|
|
76
|
-
return self.
|
|
87
|
+
return self._operate(other, lambda x, y: x - y)
|
|
77
88
|
|
|
78
89
|
def __rsub__(self, other: pgt.Scalar) -> "SkylineParameter":
|
|
79
|
-
return self.
|
|
90
|
+
return self._operate(other, lambda x, y: y - x)
|
|
80
91
|
|
|
81
92
|
def __mul__(self, other: SkylineParameterLike) -> "SkylineParameter":
|
|
82
|
-
return self.
|
|
93
|
+
return self._operate(other, lambda x, y: x * y)
|
|
83
94
|
|
|
84
95
|
def __rmul__(self, other: pgt.Scalar) -> "SkylineParameter":
|
|
85
|
-
return self.
|
|
96
|
+
return self._operate(other, lambda x, y: y * x)
|
|
86
97
|
|
|
87
98
|
def __truediv__(self, other: SkylineParameterLike) -> "SkylineParameter":
|
|
88
|
-
return self.
|
|
99
|
+
return self._operate(other, lambda x, y: x / y)
|
|
89
100
|
|
|
90
101
|
def __rtruediv__(self, other: pgt.Scalar) -> "SkylineParameter":
|
|
91
|
-
return self.
|
|
102
|
+
return self._operate(other, lambda x, y: y / x)
|
|
92
103
|
|
|
93
104
|
def __bool__(self) -> bool:
|
|
94
105
|
return any(self.value)
|
phylogenie/skyline/vector.py
CHANGED
|
@@ -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
|
-
)
|
|
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
|
|
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.
|
|
93
|
+
return self._operate(operand, lambda x, y: x + y)
|
|
94
94
|
|
|
95
95
|
def __radd__(self, operand: SkylineParameterLike) -> "SkylineVector":
|
|
96
|
-
return self.
|
|
96
|
+
return self._operate(operand, lambda x, y: y + x)
|
|
97
97
|
|
|
98
98
|
def __sub__(self, operand: SkylineVectorOperand) -> "SkylineVector":
|
|
99
|
-
return self.
|
|
99
|
+
return self._operate(operand, lambda x, y: x - y)
|
|
100
100
|
|
|
101
101
|
def __rsub__(self, operand: SkylineParameterLike) -> "SkylineVector":
|
|
102
|
-
return self.
|
|
102
|
+
return self._operate(operand, lambda x, y: y - x)
|
|
103
103
|
|
|
104
104
|
def __mul__(self, operand: SkylineVectorOperand) -> "SkylineVector":
|
|
105
|
-
return self.
|
|
105
|
+
return self._operate(operand, lambda x, y: x * y)
|
|
106
106
|
|
|
107
107
|
def __rmul__(self, operand: SkylineParameterLike) -> "SkylineVector":
|
|
108
|
-
return self.
|
|
108
|
+
return self._operate(operand, lambda x, y: y * x)
|
|
109
109
|
|
|
110
110
|
def __truediv__(self, operand: SkylineVectorOperand) -> "SkylineVector":
|
|
111
|
-
return self.
|
|
111
|
+
return self._operate(operand, lambda x, y: x / y)
|
|
112
112
|
|
|
113
113
|
def __rtruediv__(self, operand: SkylineParameterLike) -> "SkylineVector":
|
|
114
|
-
return self.
|
|
114
|
+
return self._operate(operand, lambda x, y: y / x)
|
|
115
115
|
|
|
116
116
|
def __len__(self) -> int:
|
|
117
117
|
return self.N
|
|
@@ -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=
|
|
31
|
-
phylogenie/skyline/parameter.py,sha256=
|
|
32
|
-
phylogenie/skyline/vector.py,sha256=
|
|
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.
|
|
36
|
-
phylogenie-1.0.
|
|
37
|
-
phylogenie-1.0.
|
|
38
|
-
phylogenie-1.0.
|
|
39
|
-
phylogenie-1.0.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|