ABS
The ABS node take a numeric array, a vector, or a scalar as input and returns its absolute value.Params:default : OrderedPair|Vector|ScalarThe input to apply the absolute value to.Returns:out : OrderedPairx: the x-axis of the input.
y: the absolute value of the input.
Python Code
import numpy as np
from flojoy import OrderedPair, Scalar, Vector, flojoy
@flojoy
def ABS(default: OrderedPair | Vector | Scalar) -> OrderedPair:
"""The ABS node take a numeric array, a vector, or a scalar as input and returns its absolute value.
Parameters
----------
default : OrderedPair|Vector|Scalar
The input to apply the absolute value to.
Returns
-------
OrderedPair
x: the x-axis of the input.
y: the absolute value of the input.
"""
match default:
case OrderedPair():
x = default.x
y = np.abs(default.y)
case Scalar():
x = default.c
y = np.abs(x)
case Vector():
x = default.v
y = np.abs(x)
return OrderedPair(x=x, y=y)
Example
Having problem with this example app? Join our Discord community and we will help you out!
In this example, LINSPACE
generates a line of values from -10 to 10.
We pass those values to ABS
which takes the absolute value of its input. In the end, we observe that all the values have been converted to positive.