diff --git a/pycbc/events/coinc.py b/pycbc/events/coinc.py index 9b348bd80a3..f4949e33817 100644 --- a/pycbc/events/coinc.py +++ b/pycbc/events/coinc.py @@ -948,12 +948,16 @@ def from_cli(cls, args, num_templates, analysis_chunk, ifos): # Allow None inputs stat_files = args.statistic_files or [] + stat_features = args.statistic_features or [] stat_keywords = args.statistic_keywords or [] # flatten the list of lists of filenames to a single list (may be empty) stat_files = sum(stat_files, []) - kwargs = stat.parse_statistic_feature_options(stat_keywords) + kwargs = stat.parse_statistic_feature_options( + stat_features, + stat_keywords, + ) return cls(num_templates, analysis_chunk, args.ranking_statistic, diff --git a/pycbc/events/stat.py b/pycbc/events/stat.py index 13c9576bf51..d5e661ce46a 100644 --- a/pycbc/events/stat.py +++ b/pycbc/events/stat.py @@ -1568,7 +1568,7 @@ def insert_statistic_option_group(parser, default_ranking_statistic=None): return statistic_opt_group -def parse_statistic_feature_options(opts): +def parse_statistic_feature_options(stat_features, stat_kwarg_list): """ Parse the list of statistic keywords into an appropriate dictionary. @@ -1586,7 +1586,17 @@ def parse_statistic_feature_options(opts): Statistic keywords in dict format """ stat_kwarg_dict = {} - stat_kwarg_list = opts.statistic_keywords + + # Check that the statistic keywords are allowed + for feature in stat_features: + if feature not in _allowed_statistic_features: + err_msg = f"--statistic-feature {feature} not recognised" + raise NotImplementedError(err_msg) + + # Set values for each feature key to a boolean of whether we want them + for feature in _allowed_statistic_features: + stat_kwarg_dict[feature] = feature in stat_features + for inputstr in stat_kwarg_list: try: key, value = inputstr.split(':') @@ -1597,16 +1607,6 @@ def parse_statistic_feature_options(opts): "Received {}".format(' '.join(stat_kwarg_list)) raise ValueError(err_txt) - # Check that the statistic keywords are allowed - for feature in opts.statistic_features: - if feature not in _allowed_statistic_features: - err_msg = f"--statistic-feature {feature} not recognised" - raise NotImplementedError(err_msg) - - # Set values for each feature key to a boolean of whether we want them - for feature in _allowed_statistic_features: - stat_kwarg_dict[feature] = feature in opts.statistic_features - return stat_kwarg_dict @@ -1639,7 +1639,10 @@ def get_statistic_from_opts(opts, ifos): # flatten the list of lists of filenames to a single list (may be empty) opts.statistic_files = sum(opts.statistic_files, []) - extra_kwargs = parse_statistic_feature_options(opts) + extra_kwargs = parse_statistic_feature_options( + opts.statistic_features, + opts.statistic_keywords, + ) stat_class = get_statistic(opts.ranking_statistic)( opts.sngl_ranking, diff --git a/test/test_live_coinc_compare.py b/test/test_live_coinc_compare.py index 9c42d68b999..3615f858f11 100644 --- a/test/test_live_coinc_compare.py +++ b/test/test_live_coinc_compare.py @@ -71,6 +71,7 @@ def setUp(self, *args): ranking_statistic="phasetd", statistic_files=[stat_file_paths], statistic_keywords=None, + statistic_features=None, timeslide_interval=0.1, background_ifar_limit=100, store_background=True