phylogenie 2.0.10__py3-none-any.whl → 2.0.12__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/generators/configs.py +8 -15
- phylogenie/generators/dataset.py +11 -8
- phylogenie/generators/factories.py +3 -8
- phylogenie/generators/typeguards.py +9 -12
- {phylogenie-2.0.10.dist-info → phylogenie-2.0.12.dist-info}/METADATA +1 -1
- {phylogenie-2.0.10.dist-info → phylogenie-2.0.12.dist-info}/RECORD +9 -9
- {phylogenie-2.0.10.dist-info → phylogenie-2.0.12.dist-info}/LICENSE.txt +0 -0
- {phylogenie-2.0.10.dist-info → phylogenie-2.0.12.dist-info}/WHEEL +0 -0
- {phylogenie-2.0.10.dist-info → phylogenie-2.0.12.dist-info}/entry_points.txt +0 -0
phylogenie/generators/configs.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
from pydantic import BaseModel, ConfigDict
|
|
2
2
|
|
|
3
3
|
import phylogenie.typings as pgt
|
|
4
|
-
from phylogenie.skyline import SkylineMatrix as _SkylineMatrix
|
|
5
|
-
from phylogenie.skyline import SkylineParameter as _SkylineParameter
|
|
6
|
-
from phylogenie.skyline import SkylineVector as _SkylineVector
|
|
7
4
|
|
|
8
5
|
|
|
9
6
|
class Distribution(BaseModel):
|
|
@@ -13,9 +10,9 @@ class Distribution(BaseModel):
|
|
|
13
10
|
|
|
14
11
|
Integer = str | int
|
|
15
12
|
Scalar = str | pgt.Scalar
|
|
16
|
-
ManyScalars = str |
|
|
17
|
-
OneOrManyScalars = Scalar |
|
|
18
|
-
OneOrMany2DScalars = Scalar |
|
|
13
|
+
ManyScalars = str | pgt.Many[Scalar]
|
|
14
|
+
OneOrManyScalars = Scalar | pgt.Many[Scalar]
|
|
15
|
+
OneOrMany2DScalars = Scalar | pgt.Many2D[Scalar]
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
class StrictBaseModel(BaseModel):
|
|
@@ -28,19 +25,15 @@ class SkylineParameterModel(StrictBaseModel):
|
|
|
28
25
|
|
|
29
26
|
|
|
30
27
|
class SkylineVectorModel(StrictBaseModel):
|
|
31
|
-
value: str |
|
|
28
|
+
value: str | pgt.Many[OneOrManyScalars]
|
|
32
29
|
change_times: ManyScalars
|
|
33
30
|
|
|
34
31
|
|
|
35
32
|
class SkylineMatrixModel(StrictBaseModel):
|
|
36
|
-
value: str |
|
|
33
|
+
value: str | pgt.Many[OneOrMany2DScalars]
|
|
37
34
|
change_times: ManyScalars
|
|
38
35
|
|
|
39
36
|
|
|
40
|
-
SkylineParameter = Scalar | SkylineParameterModel
|
|
41
|
-
SkylineVector =
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
SkylineMatrix = (
|
|
45
|
-
str | pgt.Scalar | list[SkylineVector] | SkylineMatrixModel | None | _SkylineMatrix
|
|
46
|
-
)
|
|
37
|
+
SkylineParameter = Scalar | SkylineParameterModel
|
|
38
|
+
SkylineVector = str | pgt.Scalar | pgt.Many[SkylineParameter] | SkylineVectorModel
|
|
39
|
+
SkylineMatrix = str | pgt.Scalar | pgt.Many[SkylineVector] | SkylineMatrixModel | None
|
phylogenie/generators/dataset.py
CHANGED
|
@@ -41,21 +41,24 @@ class DatasetGenerator(ABC, cfg.StrictBaseModel):
|
|
|
41
41
|
self._generate_one(filename=filename, rng=default_rng(seed), data=data)
|
|
42
42
|
|
|
43
43
|
def _generate(self, rng: Generator, n_samples: int, output_dir: str) -> None:
|
|
44
|
+
if os.path.exists(output_dir):
|
|
45
|
+
print(f"Output directory {output_dir} already exists. Skipping.")
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
data_dir = (
|
|
49
|
+
output_dir
|
|
50
|
+
if self.context is None
|
|
51
|
+
else os.path.join(output_dir, DATA_DIRNAME)
|
|
52
|
+
)
|
|
53
|
+
os.makedirs(data_dir)
|
|
54
|
+
|
|
44
55
|
data: list[dict[str, Any]] = [{} for _ in range(n_samples)]
|
|
45
56
|
if self.context is not None:
|
|
46
|
-
data_dir = os.path.join(output_dir, DATA_DIRNAME)
|
|
47
57
|
for d, (k, v) in product(data, self.context.items()):
|
|
48
58
|
args = v.model_extra if v.model_extra is not None else {}
|
|
49
59
|
d[k] = np.array(getattr(rng, v.type)(**args)).tolist()
|
|
50
60
|
df = pd.DataFrame([{"file_id": str(i), **d} for i, d in enumerate(data)])
|
|
51
61
|
df.to_csv(os.path.join(output_dir, METADATA_FILENAME), index=False)
|
|
52
|
-
else:
|
|
53
|
-
data_dir = output_dir
|
|
54
|
-
|
|
55
|
-
if os.path.exists(data_dir):
|
|
56
|
-
print(f"Output directory {data_dir} already exists. Skipping.")
|
|
57
|
-
return
|
|
58
|
-
os.makedirs(data_dir)
|
|
59
62
|
|
|
60
63
|
joblib.Parallel(n_jobs=self.n_jobs)(
|
|
61
64
|
joblib.delayed(self.generate_one)(
|
|
@@ -80,8 +80,6 @@ def one_or_many_scalars(
|
|
|
80
80
|
def skyline_parameter(
|
|
81
81
|
x: cfg.SkylineParameter, data: dict[str, Any]
|
|
82
82
|
) -> SkylineParameterLike:
|
|
83
|
-
if isinstance(x, SkylineParameter):
|
|
84
|
-
return x
|
|
85
83
|
if isinstance(x, cfg.Scalar):
|
|
86
84
|
return scalar(x, data)
|
|
87
85
|
return SkylineParameter(
|
|
@@ -93,8 +91,6 @@ def skyline_parameter(
|
|
|
93
91
|
def skyline_vector(
|
|
94
92
|
x: cfg.SkylineVector, data: dict[str, Any]
|
|
95
93
|
) -> SkylineVectorCoercible:
|
|
96
|
-
if isinstance(x, SkylineVector):
|
|
97
|
-
return x
|
|
98
94
|
if isinstance(x, str):
|
|
99
95
|
e = _eval_expression(x, data)
|
|
100
96
|
if tg.is_one_or_many_scalars(e):
|
|
@@ -104,7 +100,7 @@ def skyline_vector(
|
|
|
104
100
|
)
|
|
105
101
|
if isinstance(x, pgt.Scalar):
|
|
106
102
|
return x
|
|
107
|
-
if ctg.
|
|
103
|
+
if ctg.is_many_skyline_parameter_configs(x):
|
|
108
104
|
return [skyline_parameter(p, data) for p in x]
|
|
109
105
|
|
|
110
106
|
assert isinstance(x, cfg.SkylineVectorModel)
|
|
@@ -155,8 +151,7 @@ def skyline_matrix(
|
|
|
155
151
|
) -> SkylineMatrixCoercible | None:
|
|
156
152
|
if x is None:
|
|
157
153
|
return None
|
|
158
|
-
|
|
159
|
-
return x
|
|
154
|
+
|
|
160
155
|
if isinstance(x, str):
|
|
161
156
|
e = _eval_expression(x, data)
|
|
162
157
|
if tg.is_one_or_many_2D_scalars(e):
|
|
@@ -166,7 +161,7 @@ def skyline_matrix(
|
|
|
166
161
|
)
|
|
167
162
|
if isinstance(x, pgt.Scalar):
|
|
168
163
|
return x
|
|
169
|
-
if ctg.
|
|
164
|
+
if ctg.is_many_skyline_vector_configs(x):
|
|
170
165
|
return [skyline_vector(v, data) for v in x]
|
|
171
166
|
|
|
172
167
|
assert isinstance(x, cfg.SkylineMatrixModel)
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
from typing import Any, TypeGuard
|
|
2
2
|
|
|
3
3
|
import phylogenie.generators.configs as cfg
|
|
4
|
+
import phylogenie.typeguards as tg
|
|
4
5
|
import phylogenie.typings as pgt
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
def
|
|
8
|
-
return isinstance(
|
|
8
|
+
def is_many_scalar_configs(x: Any) -> TypeGuard[pgt.Many[cfg.Scalar]]:
|
|
9
|
+
return tg.is_many(x) and all(isinstance(v, cfg.Scalar) for v in x)
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
def
|
|
12
|
-
return is_list(x) and all(isinstance(v, cfg.Scalar) for v in x)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def is_list_of_skyline_parameter_configs(
|
|
12
|
+
def is_many_skyline_parameter_configs(
|
|
16
13
|
x: Any,
|
|
17
|
-
) -> TypeGuard[
|
|
18
|
-
return
|
|
14
|
+
) -> TypeGuard[pgt.Many[cfg.SkylineParameter]]:
|
|
15
|
+
return tg.is_many(x) and all(isinstance(v, cfg.SkylineParameter) for v in x)
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
def is_skyline_vector_config(x: Any) -> TypeGuard[cfg.SkylineVector]:
|
|
22
19
|
return isinstance(
|
|
23
20
|
x, str | pgt.Scalar | cfg.SkylineVectorModel
|
|
24
|
-
) or
|
|
21
|
+
) or is_many_skyline_parameter_configs(x)
|
|
25
22
|
|
|
26
23
|
|
|
27
|
-
def
|
|
28
|
-
return
|
|
24
|
+
def is_many_skyline_vector_configs(x: Any) -> TypeGuard[pgt.Many[cfg.SkylineVector]]:
|
|
25
|
+
return tg.is_many(x) and all(is_skyline_vector_config(v) for v in x)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
phylogenie/__init__.py,sha256=1w_0H9lg7hI3b-NLjKuzc34GbJJGyjLq9LrlogecTzI,1759
|
|
2
2
|
phylogenie/generators/__init__.py,sha256=zsOxy28-9j9alOQLIgrOAFfmM58NNHO_NEtW-KXQXAY,888
|
|
3
3
|
phylogenie/generators/alisim.py,sha256=dDqlSwLDbRE2u5SZlsq1mArobTBtuk0aeXY3m1N-bWA,2374
|
|
4
|
-
phylogenie/generators/configs.py,sha256=
|
|
5
|
-
phylogenie/generators/dataset.py,sha256=
|
|
6
|
-
phylogenie/generators/factories.py,sha256=
|
|
4
|
+
phylogenie/generators/configs.py,sha256=4jSBUZiFo2GacXWed5dy7lUEkaOWZkZG-KY9vHfhqGU,993
|
|
5
|
+
phylogenie/generators/dataset.py,sha256=hbkN5McM4BKY7D0hLNaxdoAGsLHac6O-D4sgnZ0wFX4,2618
|
|
6
|
+
phylogenie/generators/factories.py,sha256=0ckeAsKnPy69Vbdoi1rIyf6zRcqamz9VfSi0mAiTzds,6938
|
|
7
7
|
phylogenie/generators/trees.py,sha256=jukaVXGcPGzDBEYMGJ1MKqWt4XbAB5EEfuHXDpwKTqM,9173
|
|
8
|
-
phylogenie/generators/typeguards.py,sha256=
|
|
8
|
+
phylogenie/generators/typeguards.py,sha256=yj4VkhOaUXJ2OrY-6zhOeY9C4yKIQxjZtk2d-vIxttQ,828
|
|
9
9
|
phylogenie/io.py,sha256=ZXlofnSh7FX5UJiP0svRHrTraMSNgKa1GiAv0bMz7jU,2854
|
|
10
10
|
phylogenie/main.py,sha256=vtvSpQxBNlYABoFQ25czl-l3fIr4QRo3svWVd-jcArw,1170
|
|
11
11
|
phylogenie/msa.py,sha256=JDGyZUsAq6-m-SQjoCDjAkAZIxfgyl_PDIhdYn5HOow,2064
|
|
@@ -21,8 +21,8 @@ phylogenie/treesimulator/gillespie.py,sha256=4uMt_-Rr3cRXWGKC8veBIB-uqtKtN-dLbAH
|
|
|
21
21
|
phylogenie/treesimulator/model.py,sha256=XpzAicmg2O6K0Trk5YolH-B_HJZxoSauF2wZOMqp-Iw,5559
|
|
22
22
|
phylogenie/typeguards.py,sha256=JtqmbEWJZBRHbWgCvcl6nrWm3VcBfzRbklbTBYHItn0,1325
|
|
23
23
|
phylogenie/typings.py,sha256=O1X6lGKTjJ2YJz3ApQ-rYb_tEJNUIcHdUIeYlSM4s5o,500
|
|
24
|
-
phylogenie-2.0.
|
|
25
|
-
phylogenie-2.0.
|
|
26
|
-
phylogenie-2.0.
|
|
27
|
-
phylogenie-2.0.
|
|
28
|
-
phylogenie-2.0.
|
|
24
|
+
phylogenie-2.0.12.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
|
|
25
|
+
phylogenie-2.0.12.dist-info/METADATA,sha256=sZ7bmfmNAYLAlx1_cUAGzIBEnAGhS6yhFcfzgknh_BQ,5473
|
|
26
|
+
phylogenie-2.0.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
27
|
+
phylogenie-2.0.12.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
|
|
28
|
+
phylogenie-2.0.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|