Resolve "Devise a simple mathematical expression parser for DAG transformations"
requested to merge 149-devise-a-simple-mathematical-expression-parser-for-dag-transformations into master
This MR:
- adds the
expression
operation, which evaluates a symbolic math expression using sympy - adds
operation
-specific syntax parsers to the DAG syntax parser - adds an
expression
-operation parser that automatically usesDAGTag
s for unspecified symbols
Subsequently, it makes the following syntax possible:
transform:
- mean: [[1, 2, 3]] # something more complicated, typically
tag: a
- np.array: [[2,3,4]] # something more complicated, typically
tag: b
- operation: some_other_complicated_operation
args: [foo, bar]
tag: c
- float: 2.5
- expression: (a + b)**c - 1.23 * exp(prev)
tag: result
... where a
, b
, c
are converted to DAGTag(..)
and prev
is converted to DAGNode(-1)
(equivalent of !dag_prev
).
Of course, in real use cases, all DAG references will be more complicated expressions than the ones given here.
Anything to double-check?
-
Should the convert_xor
transformation be given by default?- If yes: Does not allow XOR operations using the
^
operator;^
will behave the same as**
. - If not: Allows XOR operations, but could be confusing because one can only use
**
for powers. (We chose this option!)
- If yes: Does not allow XOR operations using the
-
Documentation sufficient? -
There are a number of pitfalls with using the symbolic expression parser... is this whole feature too complicated perhaps? Nope, fine. It's a bit of an advanced feature anyway.
Can this MR be accepted?
-
Implementation ready -
Tests added or adjusted -
Documentation extended or updated
-
Code quality -
Changes follow coding guidelines -
Checked code coverage on new and adjusted code
-
-
Ready for merging -
Pipeline passes without warnings -
History cleaned-up or squash option set -
Changelog entry added -
Version number bumped -
%Version 0.12 finished, i.e. v0.12.5
released (after !158 (merged) is merged) -
Reviewed & approved by @herdeanu
-
Related issues
Closes #149 (closed)
Edited by Utopia Developers