@@ -958,7 +958,12 @@ def fill_priors(
958
958
and fill out a NodeGridValues object with the prior values from the
959
959
gamma or lognormal distribution with those parameters.
960
960
961
+ The `population_size` can be a scalar, or an object with a `.to_natural_timescale`
962
+ method used to map from coalescent to generational timescale.
963
+
961
964
TODO - what if there is an internal fixed node? Should we truncate
965
+
966
+ TODO - support times scaled by generation length?
962
967
"""
963
968
if prior_distr == "lognorm" :
964
969
cdf_func = scipy .stats .lognorm .cdf
@@ -975,7 +980,10 @@ def fill_priors(
975
980
datable_nodes [ts .samples ()] = False
976
981
datable_nodes = np .where (datable_nodes )[0 ]
977
982
978
- # convert coalescent time grid to generations
983
+ if isinstance (population_size , (int , float , np .ndarray )):
984
+ population_size = demography .PopulationSizeHistory (population_size )
985
+
986
+ # convert coalescent time grid to generational time scale
979
987
prior_times = base .NodeGridValues (
980
988
ts .num_nodes ,
981
989
datable_nodes [np .argsort (ts .tables .nodes .time [datable_nodes ])].astype (np .int32 ),
@@ -1055,9 +1063,6 @@ def make_discretized_prior(self, population_size, timepoints=20, progress=False)
1055
1063
Calculate prior grid for a set of timepoints and a population size history
1056
1064
"""
1057
1065
1058
- if isinstance (population_size , (int , float , np .ndarray )):
1059
- population_size = demography .PopulationSizeHistory (population_size )
1060
-
1061
1066
if isinstance (timepoints , int ):
1062
1067
if timepoints < 2 :
1063
1068
raise ValueError ("You must have at least 2 time points" )
0 commit comments