Skip to content

Support Exponentiation in WfSpec DSL #2240

Description

@Snarr

Background

  1. In WfSpecs, we allow users to work with numeric VariableValues of type INT, DOUBLE
  2. We allow users to perform a few different VariableMutationTypes on numeric VariableValues: ADD, SUBTRACT, MULTIPLY, DIVIDE

Proposal

We should support an exponentiation VariableMutationType that allows you to perform expressions such as:

x² -> x.pow(2)
sqrt(x) -> x.pow(0.5)

Acceptance Criteria

  1. Add an exponentiation POW VariableMutationType enum
  2. Add .pow() to LHExpression
  3. Support POW only for numeric VariableValue cases
  4. A few special cases that come to mind:
# Exponent Base Result
1 0 x 1
2 1 x x
3 NaN x Exception
4 x NaN Exception
5 0 y < 0 Exception
  1. Exceptions should be thrown as early as possible; for example if we know that the Exponent or Base are not numbers at PutWfSpec time, we should reject the request. If they can't be determined at PutWfSpec time, like Case 5, we should throw a VAR_SUB_ERROR if the case is reached.

Out of Scope

No response

Implementation

Documentation

No response

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions