ukaea/ReMKiT1D-Python

Calculation tree evaluation on numpy arrays

SMijin opened this issue · 1 comments

SMijin commented

Previously, calculation trees and nodes have only been used to build the corresponding derivations for use in the Fortran codebase. However, examples have appeared where it would be preferable to have a function produce both a node/calculation tree for the Fortran code as well as something that could be evaluated in the Python environment.

As such, the following syntax is desirable.

a = Node("a")
b = Node("b")
c = a + sin(b)
c.evaluate(variables) # -> np.ndarray

where variables would be of type Dict[str,np.ndarray] and would contain the keys for the leafVariables a and b.

To support different custom UnaryTransformations that could exist in the Fortran code, the UnaryTransformation class should have an additional optional component of type Callable[[List[float], List[int], List[bool], np.ndarray], np.ndarray]. For basic functions, this should be provided by the calculation_tree_support module.

SMijin commented

Added in PR #8