Change how both node's parameters are stored in the ParameterizedNode objects and how they are access. Instead of storing each parameter as an object attribute (and using getattr() and setattr()), we now store the parameter values in a dictionary called parameters.
Why? Being able to access the parameter's directly could lead to confusion during chaining and accidental setting of attributes. For example doing something like source.ra = 10.0 could cause a problem is the source's RA is supposed to be set from the host. Similarly saying x1=HostmassX1Func(host.hostmass) would set x1 as the current value of the hostmass instead of linking to the object's parameter.
Practically this means that now parameters are referenced via the parameter dictionary within a node
where old_object has a parameter value1 and other_object has a parameter sum_of_values. The code will now do the correct thing and link the objects instead of capturing only those parameter's current values.
Change how both node's parameters are stored in the
ParameterizedNode
objects and how they are access. Instead of storing each parameter as an object attribute (and usinggetattr()
andsetattr()
), we now store the parameter values in a dictionary calledparameters
.Why? Being able to access the parameter's directly could lead to confusion during chaining and accidental setting of attributes. For example doing something like
source.ra = 10.0
could cause a problem is the source's RA is supposed to be set from the host. Similarly sayingx1=HostmassX1Func(host.hostmass)
would setx1
as the current value of the hostmass instead of linking to the object's parameter.Practically this means that now parameters are referenced via the
parameter
dictionary within a nodeOLD:
becomes.
NEW:
while this is more verbose, it is a lot less accident prone.
A
__getitem__()
function is also provided so the parameters can be accessed from outside the object as if it were a dictionary.OLD:
becomes.
NEW:
Finally we create an accessor function with the same name as the parameter so
automatically creates a function
node.x()
which will access the value. This allows us to use a natural short hand when chaining attributes, such as:where
old_object
has a parametervalue1
andother_object
has a parametersum_of_values
. The code will now do the correct thing and link the objects instead of capturing only those parameter's current values.