mafw.examples.sum_processor
The module provides some examples for the user to develop their own processors.
Those implemented here are mainly used in the test suit.
Classes
|
A processor to calculate the sum of the first n values via a looping approach. |
|
A processor to calculate the sum of the first n values via the so called Gauss formula. |
- class mafw.examples.sum_processor.AccumulatorProcessor(*args: Any, **kwargs: Any)[source]
Bases:
ProcessorA processor to calculate the sum of the first n values via a looping approach.
In mathematical terms, this processor solves this easy equation:
\[N = \sum_{i=0}^{n}{i}\]by looping. It is a terribly inefficient approach, but it works as a demonstration of the looping structure.
The user can get the results by retrieving the accumulated_value parameter at the end of the processor execution.
Processor parameters
last_value: Last value of the series (default: 100)
Constructor parameters:
- Parameters:
last_value (int) – The n in the equation above. Defaults to 100
accumulated_value (int) – The N in the equation above at the end of the process.
- class mafw.examples.sum_processor.GaussAdder(*args: Any, **kwargs: Any)[source]
Bases:
ProcessorA processor to calculate the sum of the first n values via the so called Gauss formula.
In mathematical terms, this processor solves this easy equation:
\[N = \frac{n * (n - 1)}{2}\]without any looping
The user can get the results by retrieving the sum_value parameter at the end of the processor execution.
Processor parameters
last_value: Last value of the series. (default: 100)
Constructor parameters:
- Parameters:
last_value (int) – The n in the equation above. Defaults to 100
sum_value (int) – The N in the equation above.