Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion sdcflows/tests/test_fieldmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions sdcflows/utils/bimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""A bidirectional hashmap."""

import re
import warnings

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

Expand Down Expand Up @@ -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)
Expand Down
Loading