phylogenie 2.0.11__tar.gz → 2.0.12__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.
Potentially problematic release.
This version of phylogenie might be problematic. Click here for more details.
- {phylogenie-2.0.11 → phylogenie-2.0.12}/PKG-INFO +1 -1
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/generators/configs.py +7 -7
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/generators/dataset.py +11 -8
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/generators/factories.py +2 -2
- phylogenie-2.0.12/phylogenie/generators/typeguards.py +25 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/pyproject.toml +1 -1
- phylogenie-2.0.11/phylogenie/generators/typeguards.py +0 -28
- {phylogenie-2.0.11 → phylogenie-2.0.12}/LICENSE.txt +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/README.md +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/__init__.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/generators/__init__.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/generators/alisim.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/generators/trees.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/io.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/main.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/msa.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/py.typed +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/skyline/__init__.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/skyline/matrix.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/skyline/parameter.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/skyline/vector.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/tree.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/treesimulator/__init__.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/treesimulator/events.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/treesimulator/gillespie.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/treesimulator/model.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/typeguards.py +0 -0
- {phylogenie-2.0.11 → phylogenie-2.0.12}/phylogenie/typings.py +0 -0
|
@@ -10,9 +10,9 @@ class Distribution(BaseModel):
|
|
|
10
10
|
|
|
11
11
|
Integer = str | int
|
|
12
12
|
Scalar = str | pgt.Scalar
|
|
13
|
-
ManyScalars = str |
|
|
14
|
-
OneOrManyScalars = Scalar |
|
|
15
|
-
OneOrMany2DScalars = Scalar |
|
|
13
|
+
ManyScalars = str | pgt.Many[Scalar]
|
|
14
|
+
OneOrManyScalars = Scalar | pgt.Many[Scalar]
|
|
15
|
+
OneOrMany2DScalars = Scalar | pgt.Many2D[Scalar]
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class StrictBaseModel(BaseModel):
|
|
@@ -25,15 +25,15 @@ class SkylineParameterModel(StrictBaseModel):
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class SkylineVectorModel(StrictBaseModel):
|
|
28
|
-
value: str |
|
|
28
|
+
value: str | pgt.Many[OneOrManyScalars]
|
|
29
29
|
change_times: ManyScalars
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class SkylineMatrixModel(StrictBaseModel):
|
|
33
|
-
value: str |
|
|
33
|
+
value: str | pgt.Many[OneOrMany2DScalars]
|
|
34
34
|
change_times: ManyScalars
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
SkylineParameter = Scalar | SkylineParameterModel
|
|
38
|
-
SkylineVector = str | pgt.Scalar |
|
|
39
|
-
SkylineMatrix = str | pgt.Scalar |
|
|
38
|
+
SkylineVector = str | pgt.Scalar | pgt.Many[SkylineParameter] | SkylineVectorModel
|
|
39
|
+
SkylineMatrix = str | pgt.Scalar | pgt.Many[SkylineVector] | SkylineMatrixModel | None
|
|
@@ -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)(
|
|
@@ -100,7 +100,7 @@ def skyline_vector(
|
|
|
100
100
|
)
|
|
101
101
|
if isinstance(x, pgt.Scalar):
|
|
102
102
|
return x
|
|
103
|
-
if ctg.
|
|
103
|
+
if ctg.is_many_skyline_parameter_configs(x):
|
|
104
104
|
return [skyline_parameter(p, data) for p in x]
|
|
105
105
|
|
|
106
106
|
assert isinstance(x, cfg.SkylineVectorModel)
|
|
@@ -161,7 +161,7 @@ def skyline_matrix(
|
|
|
161
161
|
)
|
|
162
162
|
if isinstance(x, pgt.Scalar):
|
|
163
163
|
return x
|
|
164
|
-
if ctg.
|
|
164
|
+
if ctg.is_many_skyline_vector_configs(x):
|
|
165
165
|
return [skyline_vector(v, data) for v in x]
|
|
166
166
|
|
|
167
167
|
assert isinstance(x, cfg.SkylineMatrixModel)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from typing import Any, TypeGuard
|
|
2
|
+
|
|
3
|
+
import phylogenie.generators.configs as cfg
|
|
4
|
+
import phylogenie.typeguards as tg
|
|
5
|
+
import phylogenie.typings as pgt
|
|
6
|
+
|
|
7
|
+
|
|
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)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def is_many_skyline_parameter_configs(
|
|
13
|
+
x: Any,
|
|
14
|
+
) -> TypeGuard[pgt.Many[cfg.SkylineParameter]]:
|
|
15
|
+
return tg.is_many(x) and all(isinstance(v, cfg.SkylineParameter) for v in x)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def is_skyline_vector_config(x: Any) -> TypeGuard[cfg.SkylineVector]:
|
|
19
|
+
return isinstance(
|
|
20
|
+
x, str | pgt.Scalar | cfg.SkylineVectorModel
|
|
21
|
+
) or is_many_skyline_parameter_configs(x)
|
|
22
|
+
|
|
23
|
+
|
|
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,28 +0,0 @@
|
|
|
1
|
-
from typing import Any, TypeGuard
|
|
2
|
-
|
|
3
|
-
import phylogenie.generators.configs as cfg
|
|
4
|
-
import phylogenie.typings as pgt
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def is_list(x: Any) -> TypeGuard[list[Any]]:
|
|
8
|
-
return isinstance(x, list)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def is_list_of_scalar_configs(x: Any) -> TypeGuard[list[cfg.Scalar]]:
|
|
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(
|
|
16
|
-
x: Any,
|
|
17
|
-
) -> TypeGuard[list[cfg.SkylineParameter]]:
|
|
18
|
-
return is_list(x) and all(isinstance(v, cfg.SkylineParameter) for v in x)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def is_skyline_vector_config(x: Any) -> TypeGuard[cfg.SkylineVector]:
|
|
22
|
-
return isinstance(
|
|
23
|
-
x, str | pgt.Scalar | cfg.SkylineVectorModel
|
|
24
|
-
) or is_list_of_skyline_parameter_configs(x)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def is_list_of_skyline_vector_configs(x: Any) -> TypeGuard[list[cfg.SkylineVector]]:
|
|
28
|
-
return is_list(x) and all(is_skyline_vector_config(v) for v in x)
|
|
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
|