diff --git a/sdcflows/tests/test_fieldmaps.py b/sdcflows/tests/test_fieldmaps.py index 383376b988..9ecef796df 100644 --- a/sdcflows/tests/test_fieldmaps.py +++ b/sdcflows/tests/test_fieldmaps.py @@ -120,7 +120,7 @@ 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): + with pytest.warns(UserWarning, match=r'is already .* in mapping'): fm.FieldmapEstimation(sources, bids_id=f'my{fe.bids_id}') # Exercise workflow creation diff --git a/sdcflows/utils/bimap.py b/sdcflows/utils/bimap.py index bb360daea3..a907b6745d 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,8 +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): - 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, + stacklevel=2, ) super().__setitem__(key, value)