This is a follow-up on #59 towards a less invasive framework.
@process is now a thin wrapper around attr.s. Applied on a class A, it returns the class (almost) just as it was decorated with attr.s. The more invasive modifications (custom properties, etc.) are now in a subclass of A that is created programmatically and accessible from A.__xsimlab_cls__ (Model objects use the latter subclass instead of A directly).
The great advantage is that it is now possible to use instances of process-decorated classes independently of any Model, which is IMO a better solution than the approach proposed in #50 for testing the logic implemented in those classes.
Variables declared with intent='in' or intent='inout' are now included in__init__ generated by attr.
An alternative approach would be to stick with one single class and customize its __init__ to circumvent the limitation of read-only properties created for input variables (see, e.g., https://github.com/python-attrs/attrs/issues/393#issuecomment-510148031). This is maybe less complicated than the approach used here, but it still alters the class significantly.
TODO:
[x] check if this approach works with #45 (subclass).
[x] set init=True and repr=True for all input variables
This is a follow-up on #59 towards a less invasive framework.
@process
is now a thin wrapper aroundattr.s
. Applied on a classA
, it returns the class (almost) just as it was decorated withattr.s
. The more invasive modifications (custom properties, etc.) are now in a subclass ofA
that is created programmatically and accessible fromA.__xsimlab_cls__
(Model objects use the latter subclass instead ofA
directly).The great advantage is that it is now possible to use instances of process-decorated classes independently of any Model, which is IMO a better solution than the approach proposed in #50 for testing the logic implemented in those classes.
Variables declared with
intent='in'
orintent='inout'
are now included in__init__
generated by attr.An alternative approach would be to stick with one single class and customize its
__init__
to circumvent the limitation of read-only properties created for input variables (see, e.g., https://github.com/python-attrs/attrs/issues/393#issuecomment-510148031). This is maybe less complicated than the approach used here, but it still alters the class significantly.TODO:
init=True
andrepr=True
for all input variables