Numeric functions - Data360_Analyze - Latest

Data360 Analyze Server Help

Product type
Software
Portfolio
Verify
Product family
Data360
Product
Data360 Analyze
Version
Latest
ft:locale
en-US
Product name
Data360 Analyze
ft:title
Data360 Analyze Server Help
Copyright
2025
First publish date
2016
ft:lastEdition
2025-02-20
ft:lastPublication
2025-02-20T11:13:02.494000

If you used BRAINscript numeric functions in LAE, the following examples show how to complete the same task in the Python-based nodes.

You can test the following examples by taking a Create Data node, connecting it to a Transform node, then copy and pasting the examples into the ConfigureFields and ProcessRecords properties of the Transform node.

Note: When copying code from the examples, ensure that you include any indentations.

For more information about the Python functions, see the Python documentation, for example: https://docs.python.org/2/library/math.html

Tip: You will need to import the Python math module to use some of the following functions. See the examples below for more details.
BRAINscript Python
  • abs()

abs(x)

  • ceil()
math.ceil(x)
  • double()
float()
  • floor()
math.floor(x)
  • int()
int(x)
  • isNumber()
Custom function
  • long()
long()
  • round()
round(x)
  • pow()
  • square()
math.pow()
  • sqrt()
math.sqrt()

abs(x)

Output the values of a numeric field as absolute numbers, e.g. the input value -27959 is output as 27959:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped 
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]
#Specify the new field as a floating point 'double' type
outputs[0]['abs_rand'] = float
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['abs_rand'] = abs(inputs[0]['rand'])
    

math.ceil(x)

Output the values of the IOU field as long data types, and round up the values to the nearest integer:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]
# Specify the new field as a long type
outputs[0]['ceil_IOU'] = long
# The math module is not automatically imported
from math import ceil
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['ceil_IOU'] = ceil(inputs[0]['IOU'])
    

float()

Convert numeric values to floating point numbers:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]
# Specify the new field as a floating point 'double' type
outputs[0]['double_rand'] = float
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['double_rand'] = float(inputs[0]['rand'])
    

math.floor(x)

Output the values of the IOU field as long data types, and round down the values to the nearest integer:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]
# Specify the new field as a long type
outputs[0]['floor_IOU'] = long
# The math module is not automatically imported
from math import floor
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['floor_IOU'] = floor(inputs[0]['IOU'])
    

int(x)

Convert values to int data types:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]
# Specify the new field as a floating point 'double' type
outputs[0]['int_IOU'] = int
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['int_IOU'] = int(inputs[0]['IOU'])
    

Custom function

Output a new Boolean field (True/False) which indicates whether a value is a number or not:

ConfigureFields


      # Output the fields being tested
outputs[0] += inputs[0]['IOU']
outputs[0] += inputs[0]['junk']

# Specify the new fields as a boolean type
outputs[0]['is_number_IOU'] = bool
outputs[0]['is_number_junk'] = bool

# Define a custom function
def is_number(s):
    if s is Null:
      return False
    else:
        try:
            float(s)
            return True
        except ValueError:
            return False
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['is_number_IOU'] = is_number(inputs[0]['IOU'])
outputs[0]['is_number_junk'] = is_number(inputs[0]['junk'])
    

long()

Convert values to long data types:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]


# Specify the new field as an long type
outputs[0]['long_rand'] = long
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['long_rand'] = long(inputs[0]['rand'])
    

round(x)

Take the floating point values of the IOU field and round the values to the nearest decimal point:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]


# Specify the new field as a floating point 'double' type
outputs[0]['round_IOU'] = float
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]


# Round to one DP
outputs[0]['round_IOU'] = round(inputs[0]['IOU'], 1)
    

math.pow()

Create a new field that contains the square value of the records in the id field:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]

# Specify the new field as a floating point 'double' type
outputs[0]['squared_id'] = float


# The math module is not automatically imported
from math import pow
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['squared_id'] = pow(inputs[0]['id'], 2)
    

math.sqrt()

Output the square root of all records in the IOU field:

ConfigureFields


      #Configure all fields from input 'inputs[0]' to be mapped
#to the corresponding fields on the output 'outputs[0]'
outputs[0] += inputs[0]

# Specify the new field as a floating point 'double' type
outputs[0]['sqrt_IOU'] = float


# The math module is not automatically imported
from math import sqrt
    

ProcessRecords


      #Copy all fields from input 'inputs[0]' to the 
#corresponding output fields in output 'outputs[0]'. 
#Copies the values of the fields that have been setup
#in the mapping defined in the ConfigureFields property
outputs[0] += inputs[0]
outputs[0]['sqrt_IOU'] = sqrt(inputs[0]['IOU'])