Skip to content

Commit

Permalink
semifix when samplesize is not an int in pprldmany
Browse files Browse the repository at this point in the history
  • Loading branch information
nikohansen committed Apr 8, 2022
1 parent 3b81d0b commit 9b67323
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions code-postprocessing/cocopp/compall/pprldmany.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,25 @@ def main(dictAlg, order=None, outputdir='.', info='default',
try: lcm = np.lcm.reduce(run_numbers) # lowest common multiplier
except: lcm = max(run_numbers) # fallback for old numpy versions
# slight abuse of bootstrap_sample_size to avoid a huge number
samplesize = min((genericsettings.simulated_runlength_bootstrap_sample_size, lcm))
samplesize = min((int(genericsettings.simulated_runlength_bootstrap_sample_size), lcm))
if testbedsettings.current_testbed.instances_are_uniform:
samplesize = max((genericsettings.simulated_runlength_bootstrap_sample_size,
samplesize = max((int(genericsettings.simulated_runlength_bootstrap_sample_size),
samplesize)) # maybe more bootstrapping with unsuccessful trials
if samplesize > 1e4:
warntxt = ("Sample size equals {} which may take very long. "
"This is likely to be unintended, hence a bug.".format(samplesize))
warnings.warn(warntxt)
if not isinstance(samplesize, int):
warntxt = ("samplesize={} was of type {}. This must be considered a bug."
"\n run_numbers={} \n lcm={}"
"\n genericsettings.simulated_runlength_bootstrap_sample_size={}".format(
samplesize,
type(samplesize),
run_numbers,
lcm if 'lcm' in locals() else '"not computed"',
genericsettings.simulated_runlength_bootstrap_sample_size))
warnings.warn(warntxt)
samplesize = int(samplesize)
for f, dictAlgperFunc in sorted(dictFunc.items()):
# print(target_values((f, dim)))
for j, t in enumerate(target_values((f, dim))):
Expand Down
2 changes: 1 addition & 1 deletion code-postprocessing/cocopp/genericsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

simulated_runlength_bootstrap_sample_size = 30 + int(970 / (1 + 10 * max((0, in_a_hurry))))
"""bootstrap samples, 30 is a multiple of 10 and 15.
Used for tables and plots. 1e4 would be preferable
Used for tables and plots. `int(1e4)` would be preferable
for a final camera-ready paper version.
"""

Expand Down

0 comments on commit 9b67323

Please sign in to comment.