74. Mutation: Verifiera ekvation
Mutation för att verifiera Equation-koden. Equation-motorn är byggd ovanpå python språket med stöd för vanliga matematiska operationer.
Listan över stödja operationer:
Pythons grundläggande modul: 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.
Pythons math-modul: 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.
Pythons villkor: if, elif, else.
Pythons loopar: for, while.
equationAsText måste omslutas av """<equation>""" och koden måste ha python-stil.
Behåll endast nödvändig indragning och mellanslag.
mutation VerifyEquation {
verifyEquation(input: {
dataVariables: [{
variabel: "yield_vol"
sampleValue: 1.1
}, {
variabel: "prod"
sampleValue: 2.2
}]
equationAsText: """calculated = yield_vol/prod + 3.5
if calculated >= 30:
result = 35
elif calculated >= 20 and calculated < 30:
result = 25
else:
result = 15
"""
equationResultVariable: "result"
}) {
executed
result
errorMessage
}
}Senast uppdaterad
Var detta till hjälp?