# finesse.symbols.Operation¶

Overview

class finesse.symbols.Operation(name, operation, *args)

This is a symbol to represent a mathematical operation. 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.Operation("cos", math.cos, x)
sin   = lambda x: finesse.symbols.Operation("sin", math.sin, x)
atan2 = lambda y, x: finesse.symbols.Operation("atan2", math.atan2, y, x)


Complex math can also be used:

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


The equality operator is overridden to provide a very basic symbolic equality test. It only tests whether two symbolic statements are exactly the same, e.g.:

>>> y+x == y+x # True
>>> y+x == x+y # False


This could be fixed by making operators more

Parameters

name : str

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

operation : callable

The function to pass the arguments of this operation to.

Other Parameters

*args

The arguments to pass to operation during a call.

Methods

 Operation.__init__(self, name, operation, *args) Operation.eval(self, **kwargs) Evaluates the operation.