You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the signatures of all process runtime methods are implicitly fixed. Among these, only .run_step(self, dt) accepts one more argument than just self (it corresponds to the current time step duration).
However, in other (potentially many) cases, additional runtime information (such as, e.g., the current time t) may be needed too. This information might be needed in other methods like .finalize_step() as well.
So, how to make available this information as additional method arguments in next releases without breaking the signatures of all methods in existing users' codes? How to be more flexible in the signature of those methods?
I see two options:
A. Always use **kwargs, e.g.,
@xsimlab.processclassDiffusion(object):
defrun_step(self, **kwargs):
# use kwargs['time_step'] and/or kwargs['time']
B. Provide an optional decorator to clarify the signature, e.g.,
@xsimlab.processclassDiffusion(object):
@xsimlab.runtime_args('time,time_step')defrun_step(self, t, dt):
# use t or dt
IMO option B looks better. By default, if a method is not decorated then it should not accept any other argument than self. As a temporary exception (with depreciation warning), .run_step would still accept a default signature (self, dt).
The text was updated successfully, but these errors were encountered:
Currently, the signatures of all process runtime methods are implicitly fixed. Among these, only
.run_step(self, dt)
accepts one more argument than justself
(it corresponds to the current time step duration).However, in other (potentially many) cases, additional runtime information (such as, e.g., the current time
t
) may be needed too. This information might be needed in other methods like.finalize_step()
as well.So, how to make available this information as additional method arguments in next releases without breaking the signatures of all methods in existing users' codes? How to be more flexible in the signature of those methods?
I see two options:
**kwargs
, e.g.,IMO option B looks better. By default, if a method is not decorated then it should not accept any other argument than
self
. As a temporary exception (with depreciation warning),.run_step
would still accept a default signature(self, dt)
.The text was updated successfully, but these errors were encountered: