From f57d2c6bca92cde0b89c5b1ba1421acc8a52e386 Mon Sep 17 00:00:00 2001 From: "milton.camachocamach" Date: Wed, 15 Oct 2025 12:32:38 -0600 Subject: [PATCH 1/3] suggestion of a fix --- sdcflows/tests/test_fieldmaps.py | 4 ++-- sdcflows/utils/bimap.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sdcflows/tests/test_fieldmaps.py b/sdcflows/tests/test_fieldmaps.py index 383376b988..59f3b164d7 100644 --- a/sdcflows/tests/test_fieldmaps.py +++ b/sdcflows/tests/test_fieldmaps.py @@ -120,8 +120,8 @@ def test_FieldmapEstimation(dsA_dir, inputfiles, method, nsources): fm.FieldmapEstimation(sources, bids_id=fe.bids_id) # Ensure we can't instantiate one more estimation with same sources - with pytest.raises(ValueError): - fm.FieldmapEstimation(sources, bids_id=f'my{fe.bids_id}') + with pytest.warns(UserWarning, match=r"is already .* in mapping"): + fm.FieldmapEstimation(sources, bids_id=f"my{fe.bids_id}") # Exercise workflow creation wf = fe.get_workflow() diff --git a/sdcflows/utils/bimap.py b/sdcflows/utils/bimap.py index bb360daea3..ed329ad95c 100644 --- a/sdcflows/utils/bimap.py +++ b/sdcflows/utils/bimap.py @@ -23,6 +23,7 @@ """A bidirectional hashmap.""" import re +import warnings _autokey_pat = re.compile(r'^auto_(\d+)$') @@ -144,9 +145,7 @@ def __setitem__(self, key, value): if self.__contains__(key): raise KeyError(f"'{key}' is already {'a value' * (key in self._inverse)} in mapping") if self.__contains__(value): - raise ValueError( - f"'{value}' is already {'a key' * (value not in self._inverse)} in mapping" - ) + warnings.warn( f"'{value}' is already {'a key' * (value not in self._inverse)} in mapping", UserWarning ) super().__setitem__(key, value) self._inverse[value] = key From 425bb0af9b6e74f65bd9027a0d699e8f3d596123 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 18:39:01 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sdcflows/tests/test_fieldmaps.py | 4 ++-- sdcflows/utils/bimap.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sdcflows/tests/test_fieldmaps.py b/sdcflows/tests/test_fieldmaps.py index 59f3b164d7..9ecef796df 100644 --- a/sdcflows/tests/test_fieldmaps.py +++ b/sdcflows/tests/test_fieldmaps.py @@ -120,8 +120,8 @@ def test_FieldmapEstimation(dsA_dir, inputfiles, method, nsources): fm.FieldmapEstimation(sources, bids_id=fe.bids_id) # Ensure we can't instantiate one more estimation with same sources - with pytest.warns(UserWarning, match=r"is already .* in mapping"): - fm.FieldmapEstimation(sources, bids_id=f"my{fe.bids_id}") + with pytest.warns(UserWarning, match=r'is already .* in mapping'): + fm.FieldmapEstimation(sources, bids_id=f'my{fe.bids_id}') # Exercise workflow creation wf = fe.get_workflow() diff --git a/sdcflows/utils/bimap.py b/sdcflows/utils/bimap.py index ed329ad95c..120a2c7744 100644 --- a/sdcflows/utils/bimap.py +++ b/sdcflows/utils/bimap.py @@ -145,7 +145,10 @@ def __setitem__(self, key, value): if self.__contains__(key): raise KeyError(f"'{key}' is already {'a value' * (key in self._inverse)} in mapping") if self.__contains__(value): - warnings.warn( f"'{value}' is already {'a key' * (value not in self._inverse)} in mapping", UserWarning ) + warnings.warn( + f"'{value}' is already {'a key' * (value not in self._inverse)} in mapping", + UserWarning, + ) super().__setitem__(key, value) self._inverse[value] = key From 24f803a49a3f20d7dc201f5a2738ae84c7190f5c Mon Sep 17 00:00:00 2001 From: "milton.camachocamach" Date: Wed, 22 Oct 2025 10:27:24 -0600 Subject: [PATCH 3/3] fix add stacklevel=2 --- sdcflows/utils/bimap.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sdcflows/utils/bimap.py b/sdcflows/utils/bimap.py index 120a2c7744..a907b6745d 100644 --- a/sdcflows/utils/bimap.py +++ b/sdcflows/utils/bimap.py @@ -148,6 +148,7 @@ def __setitem__(self, key, value): warnings.warn( f"'{value}' is already {'a key' * (value not in self._inverse)} in mapping", UserWarning, + stacklevel=2, ) super().__setitem__(key, value)