nmoo.callbacks.timer_callback

Timer callback

 1"""
 2Timer callback
 3"""
 4__docformat__ = "google"
 5
 6from typing import List
 7
 8from pymoo.core.callback import Callback
 9
10import pandas as pd
11
12
13class TimerCallback(Callback):
14    """
15    A simple callback that register a timedelta (from the time it was
16    instanciated) everytime it is notified.
17    """
18
19    _deltas: List[pd.Timedelta]
20    """Timedeltas"""
21
22    _initial_time: pd.Timestamp
23    """Timestamp of when this instance has been created"""
24
25    def __init__(self):
26        super().__init__()
27        self._deltas = []
28        self._initial_time = pd.Timestamp.now()
29
30    # pylint: disable=unused-argument
31    def notify(self, algorithm, **kwargs):
32        """
33        See the `pymoo documentation
34        <https://pymoo.org/interface/callback.html>`_
35        """
36        self._deltas.append(pd.Timestamp.now() - self._initial_time)
class TimerCallback(pymoo.core.callback.Callback):
14class TimerCallback(Callback):
15    """
16    A simple callback that register a timedelta (from the time it was
17    instanciated) everytime it is notified.
18    """
19
20    _deltas: List[pd.Timedelta]
21    """Timedeltas"""
22
23    _initial_time: pd.Timestamp
24    """Timestamp of when this instance has been created"""
25
26    def __init__(self):
27        super().__init__()
28        self._deltas = []
29        self._initial_time = pd.Timestamp.now()
30
31    # pylint: disable=unused-argument
32    def notify(self, algorithm, **kwargs):
33        """
34        See the `pymoo documentation
35        <https://pymoo.org/interface/callback.html>`_
36        """
37        self._deltas.append(pd.Timestamp.now() - self._initial_time)

A simple callback that register a timedelta (from the time it was instanciated) everytime it is notified.

TimerCallback()
26    def __init__(self):
27        super().__init__()
28        self._deltas = []
29        self._initial_time = pd.Timestamp.now()
def notify(self, algorithm, **kwargs):
32    def notify(self, algorithm, **kwargs):
33        """
34        See the `pymoo documentation
35        <https://pymoo.org/interface/callback.html>`_
36        """
37        self._deltas.append(pd.Timestamp.now() - self._initial_time)