diff --git a/analysis/data/loaders.py b/analysis/data/loaders.py index 702561ca46aab3310bd90fa7eba1fd20d7db613f..32e428e7a2a076d87cd0734af34983739fa0654c 100644 --- a/analysis/data/loaders.py +++ b/analysis/data/loaders.py @@ -119,8 +119,7 @@ def _get_root_from_dataframe(frame, kwargs): # Variables var_list = list(frame.columns) # Raise an error if some weights are not loaded. - if not set(weights_to_normalize+weights_not_to_normalize).issubset(set(var_list)): - print + if var_list and not set(weights_to_normalize+weights_not_to_normalize).issubset(set(var_list)): raise ValueError("Missing weights in the list of variables read from input file.") acc_var = '' # Acceptance specified diff --git a/tests/test_data.py b/tests/test_data.py index febc18c0c04442f25c750f8a54e7b7a229ca6469..08ef32ab11dc41efa5e7c1bd679df0883736d352 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -47,7 +47,7 @@ def test_load_with_weights(pandas_weights): 'tree': 'ds', 'output-format': 'root', 'input-type': 'pandas', - 'weights': 'half'}) + 'weights-to-normalize': 'half'}) assert data.isWeighted() assert data.sumEntries() == 1000.0 # Correct normalization data.get(0) @@ -58,32 +58,18 @@ def test_load_with_weights(pandas_weights): 'tree': 'ds', 'output-format': 'root', 'input-type': 'pandas', - 'weights': ['half', 'quarter'], - 'weight_var': 'weight'}) + 'weights-to-normalize': ['half', 'quarter']}) assert data.isWeighted() assert data.sumEntries() == 1000.0 # Correct normalization data.get(0) assert data.weight() == 1.0 # Since all weights are equal - # This should fail - try: - data = get_data({'name': 'Test', - 'source': file_name, - 'tree': 'ds', - 'output-format': 'root', - 'input-type': 'pandas', - 'weights': ['half', 'quarter']}) - except KeyError: - pass - else: - assert False # And now product of the three to make sure it's not chance data = get_data({'name': 'Test', 'source': file_name, 'tree': 'ds', 'output-format': 'root', 'input-type': 'pandas', - 'weights': ['half', 'quarter', 'asym'], - 'weight_var': 'weight'}) + 'weights-to-normalize': ['half', 'quarter', 'asym']}) if not data.isWeighted(): return False # Correct normalization