finesse.symbols.Function

Overview

class finesse.symbols.Function(name, operation, *args)[source]

Bases: Symbol

This is a symbol to represent a mathematical function. This could be a simple addition, or a more complicated multi-argument function.

It supports creating new mathematical operations:

import math
import cmath

cos   = lambda x: finesse.symbols.Function("cos", math.cos, x)
sin   = lambda x: finesse.symbols.Function("sin", math.sin, x)
atan2 = lambda y, x: finesse.symbols.Function("atan2", math.atan2, y, x)

Complex math can also be used:

import numpy as np
angle = lambda x: finesse.symbols.Function("angle", np.angle, x)
print(f"{angle(1+1j)} = {angle(1+1j).eval()}")
Parameters:
namestr

The operation name. This is used for dumping operations to kat script.

operationcallable

The function to pass the arguments of this operation to.

Other Parameters:
*args

The arguments to pass to operation during a call.

Properties

Function.contains_unresolved_symbol

Whether the operation contains any unresolved symbols.

Methods

Function.__init__(name, operation, *args)

Function.eval(**kwargs)

Evaluates the operation.