File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 2
2
from numpy .random import default_rng , Generator
3
3
4
4
# Public interface.
5
- __all__ = ["GeneticOperator" ]
5
+ __all__ = ["GeneticOperator" , "increase_counter" ]
6
6
7
7
# Author.
8
8
__author__ = "Michalis Vrettas, PhD"
11
11
12
12
13
13
14
+ def increase_counter (method ):
15
+ """
16
+ Decorator function that is used in the derived
17
+ classes main operation to increase the counter
18
+ by one.
19
+
20
+ :param method: that we wrapp its functionality.
21
+
22
+ :return: the wrapper function.
23
+ """
24
+ def wrapper (self , * args , ** kwargs ):
25
+ # Increase the counter.
26
+ self .inc_counter ()
27
+
28
+ # Return the output of the wrapped method.
29
+ return method (self , * args , ** kwargs )
30
+ # _end_def_
31
+ return wrapper
32
+ # _end_def_
33
+
34
+
14
35
class GeneticOperator (object ):
15
36
"""
16
37
Description:
You can’t perform that action at this time.
0 commit comments