pathsim.utils.register module
- class pathsim.utils.register.Register(size=1)[source]
Bases:
objectThis class is a intended to be used for the inputs and outputs of blocks.
Its basic functionality is similar to a dict but with some additional methods. The core functionality is that values can be added dynamically and the size of the register doesnt have to be specified. It also implements some methods to interact with numpy arrays and to streamline convergence checks.
- Parameters:
size (int, optional) – initial size of the register
- _sorted_keys
internal sorted list of port keys for fast ordered iterations of _values
- to_array()[source]
Convert the register to a numpy array with entries sorted by ports.
Note
This method is performance critical, since it gets called A LOT and makes up a siginificant portion of all function calls during the main simulation loop! Its already profiled and optimized, so be careful with premature improvements.
- Returns:
arr – converted register as array
- Return type:
- update_from_array(arr)[source]
Update the register values from an array in place.
Note
This method is performance critical, since it gets called A LOT and makes up a siginificant portion of all function calls during the main simulation loop! Its already profiled and optimized, so be careful with premature improvements.
- Parameters:
arr (numpy.ndarray, float) – array or scalar that is used to update internal register values