From 9b673231e0358e5042e98ac31b4d88f9ee4e6ae1 Mon Sep 17 00:00:00 2001 From: nikohansen Date: Fri, 8 Apr 2022 09:18:07 +0200 Subject: [PATCH] semifix when samplesize is not an int in pprldmany --- code-postprocessing/cocopp/compall/pprldmany.py | 15 +++++++++++++-- code-postprocessing/cocopp/genericsettings.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/code-postprocessing/cocopp/compall/pprldmany.py b/code-postprocessing/cocopp/compall/pprldmany.py index 52995cae7..1e3950496 100644 --- a/code-postprocessing/cocopp/compall/pprldmany.py +++ b/code-postprocessing/cocopp/compall/pprldmany.py @@ -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))): diff --git a/code-postprocessing/cocopp/genericsettings.py b/code-postprocessing/cocopp/genericsettings.py index d547f0a8d..dc0d76048 100644 --- a/code-postprocessing/cocopp/genericsettings.py +++ b/code-postprocessing/cocopp/genericsettings.py @@ -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. """