phylogenie 1.0.2__tar.gz → 1.0.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.
- {phylogenie-1.0.2 → phylogenie-1.0.4}/PKG-INFO +1 -1
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/factories.py +10 -14
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/skyline/matrix.py +9 -9
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/skyline/parameter.py +22 -11
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/skyline/vector.py +10 -10
- {phylogenie-1.0.2 → phylogenie-1.0.4}/pyproject.toml +1 -1
- {phylogenie-1.0.2 → phylogenie-1.0.4}/LICENSE.txt +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/README.md +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/backend/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/backend/remaster/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/backend/remaster/generate.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/backend/remaster/reactions.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/backend/treesimulator.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/configs.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/configs.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/context/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/context/configs.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/context/distributions.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/context/factories.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/dataset.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/msas/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/msas/alisim.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/msas/base.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/trees/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/trees/base.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/trees/remaster/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/trees/remaster/configs.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/trees/remaster/factories.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/trees/remaster/generator.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/trees/treesimulator.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/core/typeguards.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/main.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/py.typed +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/skyline/__init__.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/typeguards.py +0 -0
- {phylogenie-1.0.2 → phylogenie-1.0.4}/phylogenie/typings.py +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, overload
|
|
1
|
+
from typing import Any, Literal, overload
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
|
|
@@ -23,10 +23,9 @@ def _eval_expression(expression: str, data: pgt.Data) -> Any:
|
|
|
23
23
|
expression,
|
|
24
24
|
{
|
|
25
25
|
"__builtins__": __builtins__,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
"np": np,
|
|
27
|
+
**{k: np.array(v) for k, v in data.items()},
|
|
28
28
|
},
|
|
29
|
-
{k: np.array(v) for k, v in data.items()},
|
|
30
29
|
)
|
|
31
30
|
).tolist()
|
|
32
31
|
|
|
@@ -101,20 +100,17 @@ def skyline_parameter_like_factory(
|
|
|
101
100
|
)
|
|
102
101
|
|
|
103
102
|
|
|
104
|
-
from typing import Literal
|
|
105
|
-
|
|
106
|
-
|
|
107
103
|
@overload
|
|
108
104
|
def _parse_skyline_vector_value_model(
|
|
109
105
|
x: cfg.SkylineVectorValueModel, data: pgt.Data, coercible: Literal[True]
|
|
110
|
-
) ->
|
|
106
|
+
) -> SkylineVectorCoercible: ...
|
|
111
107
|
@overload
|
|
112
108
|
def _parse_skyline_vector_value_model(
|
|
113
109
|
x: cfg.SkylineVectorValueModel, data: pgt.Data, coercible: Literal[False]
|
|
114
|
-
) ->
|
|
110
|
+
) -> SkylineVectorLike: ...
|
|
115
111
|
def _parse_skyline_vector_value_model(
|
|
116
112
|
x: cfg.SkylineVectorValueModel, data: pgt.Data, coercible: bool
|
|
117
|
-
) ->
|
|
113
|
+
) -> SkylineVectorCoercible:
|
|
118
114
|
change_times = many_scalars_factory(x.change_times, data)
|
|
119
115
|
if isinstance(x.value, str):
|
|
120
116
|
e = _eval_expression(x.value, data)
|
|
@@ -132,13 +128,13 @@ def _parse_skyline_vector_value_model(
|
|
|
132
128
|
return SkylineParameter(value=value, change_times=change_times)
|
|
133
129
|
else:
|
|
134
130
|
raise ValueError(
|
|
135
|
-
f"Parsing SkylineVector
|
|
131
|
+
f"Parsing SkylineVector config {x.value} yielded a sequence of scalars {value} when a nested (2D) sequence of scalars was expected."
|
|
136
132
|
)
|
|
137
133
|
|
|
138
134
|
Ns = {len(elem) for elem in value if tg.is_many(elem)}
|
|
139
135
|
if len(Ns) > 1:
|
|
140
136
|
raise ValueError(
|
|
141
|
-
f"All elements in the value of a SkylineVector config must be scalars or have the same length (
|
|
137
|
+
f"All elements in the value of a SkylineVector config must be scalars or have the same length (config {x.value} yielded value={value} with inconsistent lengths {Ns})."
|
|
142
138
|
)
|
|
143
139
|
(N,) = Ns
|
|
144
140
|
value = [[p] * N if isinstance(p, pgt.Scalar) else p for p in value]
|
|
@@ -238,13 +234,13 @@ def skyline_matrix_coercible_factory(
|
|
|
238
234
|
n_rows = len(elem)
|
|
239
235
|
if any(len(row) != n_rows for row in elem):
|
|
240
236
|
raise ValueError(
|
|
241
|
-
f"All elements in the value of a SkylineMatrix config must be scalars or square matrices (
|
|
237
|
+
f"All elements in the value of a SkylineMatrix config must be scalars or square matrices (config {x.value} yeilded a non-square matrix: {elem})."
|
|
242
238
|
)
|
|
243
239
|
Ns.add(n_rows)
|
|
244
240
|
|
|
245
241
|
if len(Ns) > 1:
|
|
246
242
|
raise ValueError(
|
|
247
|
-
f"All elements in the value of a SkylineMatrix config must be scalars or have the same square shape (
|
|
243
|
+
f"All elements in the value of a SkylineMatrix config must be scalars or have the same square shape (config {x.value} yielded value={value} with inconsistent lengths {Ns})."
|
|
248
244
|
)
|
|
249
245
|
(N,) = Ns
|
|
250
246
|
value = [[[p] * N] * N if isinstance(p, pgt.Scalar) else p for p in value]
|
|
@@ -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":
|
|
@@ -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)
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|