GeoPard Tutorials
Ask or search…
K

74. Mutation: Verify "Equation"

Mutation to verify the Equation code. The Equation engine is built on top of python language with the support of common Math operations.
The list of supported operations:
  1. 1.
    Python basic module: abs, all, any, bin, bool, bytearray, bytes, chr, complex, dict, dir, divmod, enumerate, filter, float, format, frozenset, hash, hex, id, int, isinstance, len, list, map, max, min, oct, ord, pow, range, repr, reversed, round, set, slice, sorted, str, sum, tuple, type, zip.
  2. 2.
    Python math module: acos, acosh, asin, asinh, atan, atan2, atanh, ceil, copysign, cos, cosh, degrees, e, exp, fabs, factorial, floor, fmod, frexp, fsum, hypot, isinf, isnan, ldexp, log, log10, log1p, modf, pi, pow, radians, sin, sinh, sqrt, tan, tanh, trunc.
  3. 3.
    Python conditions: if, elif, else.
  4. 4.
    Python loops: for, while.
equationAsText must be wrapped into """<equation>""" and the code must be python-based styled.
Keep only necessary tabulation and spacing.
1
mutation VerifyEquation {
2
verifyEquation(input: {
3
dataVariables: [{
4
variable: "yield_vol"
5
sampleValue: 1.1
6
}, {
7
variable: "prod"
8
sampleValue: 2.2
9
}]
10
equationAsText: """calculated = yield_vol/prod + 3.5
11
if calculated >= 30:
12
result = 35
13
elif calculated >= 20 and calculated < 30:
14
result = 25
15
else:
16
result = 15
17
"""
18
equationResultVariable: "result"
19
}) {
20
executed
21
result
22
errorMessage
23
}
24
}