python_project_template_AS.calculator#
Calculator utilities for applying and composing operations.
The Calculator provides a thin layer over OperationRegistry.
It supports applying named operations, composing unary operations into a
callable, and a small ‘chain’ helper for mixed sequences of unary/binary
operations used by the examples and tests.
Keep the behaviour minimal: methods raise OperationError for
operation-related failures.
Classes
|
Calculator using an OperationRegistry. |
- class python_project_template_AS.calculator.Calculator(registry=None)[source]#
Bases:
objectCalculator using an OperationRegistry.
- Parameters:
registry (OperationRegistry | None)
- apply(op_name, *args)[source]#
Apply a named operation with arguments.
- Return type:
Any- Parameters:
op_name (str)
args (Any)
- chain(sequence, initial)[source]#
Apply a sequence of operations and values starting from initial.
- Return type:
Any- Parameters:
sequence (Iterable[str | int])
initial (Any)