Skip to content

Commit f57d2c6

Browse files
suggestion of a fix
1 parent 52209e4 commit f57d2c6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

sdcflows/tests/test_fieldmaps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def test_FieldmapEstimation(dsA_dir, inputfiles, method, nsources):
120120
fm.FieldmapEstimation(sources, bids_id=fe.bids_id)
121121

122122
# Ensure we can't instantiate one more estimation with same sources
123-
with pytest.raises(ValueError):
124-
fm.FieldmapEstimation(sources, bids_id=f'my{fe.bids_id}')
123+
with pytest.warns(UserWarning, match=r"is already .* in mapping"):
124+
fm.FieldmapEstimation(sources, bids_id=f"my{fe.bids_id}")
125125

126126
# Exercise workflow creation
127127
wf = fe.get_workflow()

sdcflows/utils/bimap.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"""A bidirectional hashmap."""
2424

2525
import re
26+
import warnings
2627

2728
_autokey_pat = re.compile(r'^auto_(\d+)$')
2829

@@ -144,9 +145,7 @@ def __setitem__(self, key, value):
144145
if self.__contains__(key):
145146
raise KeyError(f"'{key}' is already {'a value' * (key in self._inverse)} in mapping")
146147
if self.__contains__(value):
147-
raise ValueError(
148-
f"'{value}' is already {'a key' * (value not in self._inverse)} in mapping"
149-
)
148+
warnings.warn( f"'{value}' is already {'a key' * (value not in self._inverse)} in mapping", UserWarning )
150149

151150
super().__setitem__(key, value)
152151
self._inverse[value] = key

0 commit comments

Comments
 (0)