axiom-official/simple-math
v0.1.0PythonThe simple-math package provides a set of basic mathematical operations including addition, subtraction, multiplication, and division. It is primarily used for performing fundamental arithmetic calculations in Python applications.
Use cases
- •Perform basic calculations in a calculator application
- •Automate arithmetic operations in data processing scripts
- •Integrate simple math functions into educational software
Nodes (4)
The Add node performs the addition of two numerical inputs and returns the resulting sum as output.
View source
from gen.messages_pb2 import AddInput, MathOutput
from gen.axiom_logger import AxiomLogger, AxiomSecrets
def add(log: AxiomLogger, secrets: AxiomSecrets, input: AddInput) -> MathOutput:
"""Adds two numbers together and returns the sum."""
try:
log.info(f"Adding {input.a} + {input.b}")
result = input.a + input.b
log.info(f"Result: {result}")
return MathOutput(result=result)
except Exception as e:
log.error(f"Error adding numbers: {e}")
return MathOutput(result=0.0)The Divide node performs division of two numbers, returning the quotient of the first number divided by the second. It handles division by zero by raising an error.
View source
from gen.messages_pb2 import DivideInput, MathOutput
from gen.axiom_logger import AxiomLogger, AxiomSecrets
def divide(log: AxiomLogger, secrets: AxiomSecrets, input: DivideInput) -> MathOutput:
"""Divides the first number by the second and returns the quotient."""
try:
log.info(f"Dividing {input.a} by {input.b}")
if input.b == 0:
log.error("Division by zero attempted")
raise ValueError("Cannot divide by zero")
result = input.a / input.b
log.info(f"Division result: {result}")
return MathOutput(result=result)
except Exception as e:
log.error(f"Error during division: {str(e)}")
raiseThe Multiply node takes two numerical inputs and computes their product, returning the result as output.
View source
from gen.messages_pb2 import MultiplyInput, MathOutput
from gen.axiom_logger import AxiomLogger, AxiomSecrets
def multiply(log: AxiomLogger, secrets: AxiomSecrets, input: MultiplyInput) -> MathOutput:
"""Multiplies two numbers together and returns the product."""
try:
log.info(f"Multiplying {input.a} and {input.b}")
result = input.a * input.b
log.info(f"Result: {result}")
return MathOutput(result=result)
except Exception as e:
log.error(f"Error during multiplication: {str(e)}")
raiseThe Subtract node performs a subtraction operation by taking two input numbers and returning the difference between them.
View source
from gen.messages_pb2 import SubtractInput, MathOutput
from gen.axiom_logger import AxiomLogger, AxiomSecrets
def subtract(log: AxiomLogger, secrets: AxiomSecrets, input: SubtractInput) -> MathOutput:
"""Subtracts the second number from the first and returns the difference."""
try:
log.info(f"Subtracting {input.b} from {input.a}")
result = input.a - input.b
log.info(f"Subtraction result: {result}")
return MathOutput(result=result)
except Exception as e:
log.error(f"Error during subtraction: {str(e)}")
raiseMessages (5)
Download .protoThe first number to be added.
The second number to be added.
The numerator, the first number to be divided.
The denominator, the second number by which the first number is divided.
The sum of the two input numbers.
The first number to be multiplied.
The second number to be multiplied.
The first number from which the second number will be subtracted.
The second number that will be subtracted from the first number.
Use this package
Sign in to import axiom-official/simple-math into the graph editor — drop it into a flow and hit run. Or call it directly via the API Reference with your API key.
Sign in to useOpen editorLinks
Thin client
A single self-contained file — no dependencies, no ZIP. Drop it in your project and call nodes with your API key.
Or via the CLI: axiom client axiom-official/simple-math@0.1.0 --lang python
Generate client
Download a typed API client generated from this package's OpenAPI spec. Drop it in your project and call the node with full type safety.