engforge.system_reference.Ref
- class Ref(comp, key, use_call=True, allow_set=True, eval_f=None)[source]
Bases:
objectA way to create portable references to system’s and their component’s properties, ref can also take a key to a zero argument function which will be evald. This is useful for creating an adhoc optimization problems dynamically between variables. However use must be carefully controlled to avoid circular references, and understanding the safe use of the refset_input and refset_get methods (changing state on actual system).
A dictionary can be used as a component, and the key will be used to access the value in the dictionary.
The key can be a callable of (*args,**kw) only in which case Ref.value(*args,**kw) will take input, and the ref will be evaluated as the result of the callable (allow_set=False), this renders the component unused, and disables the ability to set the value of the reference.
The ability to set this ref with another on key input allows for creating a reference that is identical to another reference except for the component provided if it is not None.
Methods
copy the reference, and make changes to the copy
refset_getchange a set of refs with a dictionary of values.
setset_valuecaches anonymous functions for value and logging speedup
valueAttributes
compkeyuse_calluse_dictallow_seteval_fkey_overridehxdattr_typefull_key- refset_input(delta_dict, chk=True, fail=True, warn=True, scope='ref')
change a set of refs with a dictionary of values. If chk is True k will be checked for membership in refs