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 monai/transforms/adaptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def must_be_types(variable_name, variable, types):
raise TypeError(f"'{variable_name}' must be one of {types} but is {type(variable)}")

def map_names(ditems, input_map):
return {input_map(k, k): v for k, v in ditems.items()}
return {input_map.get(k, k): v for k, v in ditems.items()}

def map_only_names(ditems, input_map):
return {v: ditems[k] for k, v in input_map.items()}
Expand Down
9 changes: 9 additions & 0 deletions tests/transforms/test_adaptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ def foo(a):
dres = adaptor(foo, {"a": "b"}, {"b": "a"})(d)
self.assertEqual(dres["b"], 4)

def test_kwargs_with_dict_inputs(self):

def foo(**kwargs):
return {k: v * 2 for k, v in kwargs.items()}

d = {"x": 3}
dres = adaptor(foo, {"out": "out"}, {"x": "out"})(d)
self.assertEqual(dres["out"], 6)


class TestApplyAlias(unittest.TestCase):

Expand Down
Loading