Sign inSign up

beetaone/math-operations

By beetaone

Updated almost 2 years ago

Image
0

133

beetaone/math-operations repository overview

Math Operations

NameMath Operations
Versionv1.0.2
DockerHubbeetaone/math-operations
AuthorsJakub Grzelak

Description

This module enables performing math operations on the data. Supported operations: + - * / % ^ ceil abs floor sqrt sin cos tan exp. Negative numbers must be put in brackets, i.e. (-9) or (-1.34). If you want to use received data, then refer to them in your calculations formula by placing their label in double curly brackets, i.e. if your data is { 'temperature': 12, 'volume': 3 } and want to use temperature in your calculations then refer to it as {{temperature}}

Sample calculations:

  • {{temperature}} * 9 / 5 + 32
  • 1/2 + (2 + 3) / (sin((-9) - 2)^2 - 6/7) - cos(1) + {{temperature}}
  • {{temperature}} * {{volume}} / (-12)

Supported Operations

OperandDescription
+Sum of two numbers.
-Subtraction of two numbers.
*Multiplication of two numbers.
/Division of two numbers.
%Modulus.
^Power.
ceil(x)Return the ceiling of x, the smallest integer greater than or equal to x.
abs(x)Return the absolute value of x.
floor(x)Return the floor of x, the largest integer less than or equal to x.
sqrt(x)Return the square root of x.
sin(x)Return the sine of x radians.
cos(x)Return the cosine of x radians.
tan(x)Return the tangent of x radians.
exp(x)Return e raised to the power x, where e = 2.718281… is the base of natural logarithms.

Environment Variables

Module Specific

The following module configurations can be provided in a data service designer section on beetaone platform:

NameEnvironment VariablestypeDescription
FormulaFORMULAstringBuild a mathematics formula using supported operations. To use data in your calculations refer to their labels in double curly brackets {{...}}.
Result LabelRESULT_LABELstringAssign calculations results to this label.
Action on ResultNEW_RESULTstringWhat to do with the calculated results? Update result label? Output as stand alone data? Options: update or stand-alone. If selected update then calculated value will update value assigned to Result Label or append to the data object received by the module if Result Label is not present. If selected stand-alone then data received by the module will be disregarded and the module will output a new JSON object holding calculated value and assigned to Result Label
Set by the beetaone Agent on the edge-node

Other features required for establishing the inter-container communication between modules in a data service are set by beetaone agent.

Environment VariablestypeDescription
MODULE_NAMEstringName of the module
MODULE_TYPEstringType of the module (Input, Processing, Output)
EGRESS_URLSstringHTTP ReST endpoints for the next module
INGRESS_HOSTstringHost to which data will be received
INGRESS_PORTstringPort to which data will be received

Dependencies

bottle
requests

Input

Input to this module is:

  • JSON body single object, example:
{
    "temperature": 12,
    "volume": 3
}
  • array of JSON body objects, example:
[
    {
        "temperature": 12,
        "volume": 3
    },
    {
        "temperature": 10,
        "volume": 4
    },
    {
        "temperature": 1.3234,
        "volume": 3
    }
]

Output

If the following module configuration is provided FORMULA = {{temperature}} * 9/5 + 32, RESULT_LABEL = temperatureFahrenheit, NEW_RESULT = update then output of this module to the above input data will be:

  • JSON body single object, example:
{
    "temperature": 12,
    "volume": 3,
    "temperatureFahrenheit": 53.6
}
  • array of JSON body objects, example:
[
    {
        "temperature": 12,
        "volume": 3,
        "temperatureFahrenheit": 53.6
    },
    {
        "temperature": 10,
        "volume": 4,
        "temperatureFahrenheit": 50
    },
    {
        "temperature": 1.3234,
        "volume": 3,
        "temperatureFahrenheit": 34.38212
    }
]

Tag summary

Content type

Image

Digest

sha256:274775e3d

Size

49.1 MB

Last updated

almost 2 years ago

docker pull beetaone/math-operations:v1.0.2