Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of test for missing aggregation function when require_all_aggregators=True #4770

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions testsuite/MDAnalysisTests/analysis/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from MDAnalysis.analysis import results as results_module
from numpy.testing import assert_equal
from itertools import cycle


class Test_Results:
Expand Down Expand Up @@ -155,8 +156,6 @@ def merger(self):

@pytest.mark.parametrize("n", [1, 2, 5, 14])
def test_all_results(self, results_0, results_1, merger, n):
from itertools import cycle

objects = [obj for obj, _ in zip(cycle([results_0, results_1]), range(n))]

arr = [i for _, i in zip(range(n), cycle([0, 1]))]
Expand All @@ -171,3 +170,13 @@ def test_all_results(self, results_0, results_1, merger, n):
results = merger.merge(objects)
for attr, merged_value in results.items():
assert_equal(merged_value, answers.get(attr), err_msg=f"{attr=}, {merged_value=}, {arr=}, {objects=}")

def test_missing_aggregator(self, results_0, results_1, merger):
original_float_lookup = merger._lookup.get("float")
merger._lookup["float"] = None

with pytest.raises(ValueError,
match="No aggregation function for key='float'"):
merger.merge([results_0, results_1], require_all_aggregators=True)

merger._lookup["float"] = original_float_lookup
Loading