Skip to content

Commit

Permalink
* nemo/utils.py (MultiSetter): Test non-callable arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
bje- committed Dec 15, 2024
1 parent e3b5163 commit 85a4bd0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nemo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,20 @@ class MultiSetter:
>>> ms.set_capacity(1.2)
one 1.2
two 1.2
>>> setter1 = (None, 0, 40) # not callable
>>> ms = MultiSetter(setter1)
Traceback (most recent call last):
...
TypeError: setter not callable
"""

def __init__(self, *args):
"""Initialise a MultiSetter with any number of setters."""
self.setters = [setter[0] for setter in args]
for setter in self.setters:
if not callable(setter):
raise TypeError
raise TypeError("setter not callable")

def set_capacity(self, value):
"""Broadcast value to all setters."""
Expand Down

0 comments on commit 85a4bd0

Please sign in to comment.