-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Basically there are two issues remaining with response arguments:
-
Modules don't support keyword arguments in the
response(), but only positional arguments. This is due to the inconvenience of constructing a dictionary when returning the sensitivities. If a dict would be returned, this should be possible. -
It is a bit cumbersome to obtain the values passed to the response function, especially for optional arguments not passed by the user. No signal exists for these inputs and when using
get_input_states, only the inputs defined bysig_inare returned. Workaround for now:
class MyModule(pym.Module):
default_b: float = 1.0
default_c: float = 1/np.sqrt(2)
def __call__(self, a, b=None, c=None):
if b is None:
b = self.default_b
if cis None:
c = self.default_c
...
def _sensitivity(self, dy):
b, c = self.default_b, self.default_c
if self.n_in == 1:
a= self.get_input_states()
elif self.n_in == 2:
a, b = self.get_input_states()
elif self.n_in == 3:
a, b, c = self.get_input_states()
else:
raise ValueError("Wrong number of inputs")
....Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request