Skip to content

Commit 9327e00

Browse files
committed
eps argument to build grid does nothing, drop docstring and keep as placeholder
1 parent d706941 commit 9327e00

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
hooks:
2222
- id: black
2323
language_version: python3
24-
- repo: https://gitlab.com/pycqa/flake8
24+
- repo: https://github.com/pycqa/flake8
2525
rev: 3.9.2
2626
hooks:
2727
- id: flake8

tsdate/prior.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,10 +1008,19 @@ def fill_priors(
10081008

10091009
class MixturePrior:
10101010
"""
1011-
Maps ConditionalCoalescentPrior onto nodes in a tree sequence and creates time-discretized priors
1011+
Maps ConditionalCoalescentPrior onto nodes in a tree sequence and creates
1012+
time-discretized priors
10121013
"""
10131014

1014-
def __init__(self, tree_sequence, approximate_priors=False, approx_prior_size=None, prior_distribution="lognorm", allow_unary=False, progress=False):
1015+
def __init__(
1016+
self,
1017+
tree_sequence,
1018+
approximate_priors=False,
1019+
approx_prior_size=None,
1020+
prior_distribution="lognorm",
1021+
allow_unary=False,
1022+
progress=False,
1023+
):
10151024

10161025
if approximate_priors:
10171026
if not approx_prior_size:
@@ -1028,15 +1037,18 @@ def __init__(self, tree_sequence, approximate_priors=False, approx_prior_size=No
10281037
"Passed tree sequence is not simplified and/or contains "
10291038
"noncontemporaneous samples"
10301039
)
1031-
span_data = SpansBySamples(contmpr_ts, progress=progress, allow_unary=allow_unary)
1040+
span_data = SpansBySamples(
1041+
contmpr_ts, progress=progress, allow_unary=allow_unary
1042+
)
10321043

10331044
base_priors = ConditionalCoalescentTimes(
10341045
approx_prior_size, prior_distribution, progress=progress
10351046
)
10361047

10371048
base_priors.add(contmpr_ts.num_samples, approximate_priors)
10381049
for total_fixed in span_data.total_fixed_at_0_counts:
1039-
# For missing data: trees vary in total fixed node count => have different priors
1050+
# For missing data: trees vary in total fixed node count =>
1051+
# have different priors
10401052
if total_fixed > 0:
10411053
base_priors.add(total_fixed, approximate_priors)
10421054
prior_params_contmpr = base_priors.get_mixture_prior_params(span_data)
@@ -1047,7 +1059,6 @@ def __init__(self, tree_sequence, approximate_priors=False, approx_prior_size=No
10471059
self.tree_sequence = tree_sequence
10481060
self.prior_distribution = prior_distribution
10491061

1050-
10511062
def make_discretized_prior(self, population_size, timepoints=20, progress=False):
10521063
"""
10531064
Calculate prior grid for a set of timepoints and a population size history
@@ -1080,7 +1091,9 @@ def make_discretized_prior(self, population_size, timepoints=20, progress=False)
10801091
timepoints = create_timepoints(self.base_priors, timepoints + 1)
10811092
elif isinstance(timepoints, np.ndarray):
10821093
try:
1083-
timepoints = np.sort(timepoints.astype(base.FLOAT_DTYPE, casting="safe"))
1094+
timepoints = np.sort(
1095+
timepoints.astype(base.FLOAT_DTYPE, casting="safe")
1096+
)
10841097
except TypeError:
10851098
raise TypeError("Timepoints array cannot be converted to float dtype")
10861099
if len(timepoints) < 2:
@@ -1090,7 +1103,9 @@ def make_discretized_prior(self, population_size, timepoints=20, progress=False)
10901103
elif np.any(np.unique(timepoints, return_counts=True)[1] > 1):
10911104
raise ValueError("Timepoints cannot have duplicate values")
10921105
else:
1093-
raise ValueError("time_slices must be an integer or a numpy array of floats")
1106+
raise ValueError(
1107+
"time_slices must be an integer or a numpy array of floats"
1108+
)
10941109

10951110
# Set all fixed nodes (i.e. samples) to have 0 variance
10961111
priors = fill_priors(
@@ -1113,6 +1128,7 @@ def build_grid(
11131128
approx_prior_size=None,
11141129
prior_distribution="lognorm",
11151130
# Parameters below undocumented
1131+
eps=1e-6, # placeholder
11161132
progress=False,
11171133
allow_unary=False,
11181134
):
@@ -1147,7 +1163,11 @@ def build_grid(
11471163
"""
11481164

11491165
mixture_prior = MixturePrior(
1150-
tree_sequence, approximate_priors, approx_prior_size, prior_distribution, allow_unary, progress
1166+
tree_sequence,
1167+
approximate_priors,
1168+
approx_prior_size,
1169+
prior_distribution,
1170+
allow_unary,
1171+
progress,
11511172
)
11521173
return mixture_prior.make_discretized_prior(population_size, timepoints)
1153-

0 commit comments

Comments
 (0)