From 9bb5dc21ca2ca49dd82dc7f90c94816f49b30f61 Mon Sep 17 00:00:00 2001 From: Noam Bernstein Date: Thu, 3 Oct 2024 14:10:20 -0400 Subject: [PATCH 1/3] Overload '+' operator to concatenate ConfigSet objects --- wfl/configset.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wfl/configset.py b/wfl/configset.py index 3974c611..c1a6c74a 100644 --- a/wfl/configset.py +++ b/wfl/configset.py @@ -388,6 +388,12 @@ def _flat_iter(items): yield at + def __add__(self, other): + if not isinstance(other, ConfigSet): + raise TypeError(f"unsupported operand type(s) for +: 'ConfigSet' and '{type(other)}'") + return ConfigSet([self, other]) + + class OutputSpec: """Abstraction for writing to a ConfigSet, preserving tree structure. From b2735e12f280facee238baaaa0e3b073fe3b8b2b Mon Sep 17 00:00:00 2001 From: Noam Bernstein Date: Thu, 3 Oct 2024 14:14:33 -0400 Subject: [PATCH 2/3] Add pytest for ConfigSet + operator --- tests/test_configset.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_configset.py b/tests/test_configset.py index 60eace59..5cf101bd 100644 --- a/tests/test_configset.py +++ b/tests/test_configset.py @@ -263,6 +263,9 @@ def test_from_mult_ConfigSets(tmp_path, ats): locs = [f" / {i0} / {i1}" for i0 in range(3) for i1 in range(3)] check_ConfigSet(ConfigSet([cs_01, cs_2]), locs, gather_numbers([ats_i_0, ats_i_1, ats_i_2])) + # same check for overloaded + operator + check_ConfigSet(cs_01 + cs_2, locs, gather_numbers([ats_i_0, ats_i_1, ats_i_2])) + def test_from_ConfigSets_mixed_0(tmp_path, ats): ats_i_0 = ats[0:3] ats_i_1 = ats[3:6] From 17226f1c605e27235497b2e7191dd29fbc96b027 Mon Sep 17 00:00:00 2001 From: Noam Bernstein Date: Thu, 3 Oct 2024 14:18:01 -0400 Subject: [PATCH 3/3] newer version of actions/upload-artifact in pytests workflow --- .github/workflows/pytests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytests.yml b/.github/workflows/pytests.yml index ceec692d..d93699f3 100644 --- a/.github/workflows/pytests.yml +++ b/.github/workflows/pytests.yml @@ -281,7 +281,7 @@ jobs: mpirun -n 2 pytest --cov=wfl --cov-report term --cov-config=tests/.coveragerc --cov-report term-missing --cov-report term:skip-covered --with-mpi -k mpi --cov-append - name: 'Upload Coverage Data' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: env.coverage-on-version == matrix.python-version with: name: coverage-html-${{ matrix.python-version }}