pykappa.expression

Represents Kappa arithmetic expressions.

class pykappa.expression.Expression(type, **attrs)[source]

Algebraic expressions as specified by the Kappa language.

classmethod from_kappa(kappa_str)[source]

Parse an Expression from a Kappa string.

Raises:

AssertionError – If the string doesn’t represent a valid expression.

Parameters:

kappa_str (str)

Return type:

Expression

property kappa_str: str

Raises: ValueError: If expression type is not supported for string conversion.

evaluate(system=None)[source]

Evaluate the expression to get its value.

Parameters:

system (System | None) – System context for variable evaluation (required for variables).

Raises:

ValueError – If evaluation fails due to missing context or unsupported type.

Return type:

int | float