1+ from typing import Optional
2+
13import numpy as np
24
35from waveform_editor .tendencies .periodic .periodic_base import PeriodicBaseTendency
68class SquareWaveTendency (PeriodicBaseTendency ):
79 """A tendency representing a square wave."""
810
9- def generate (self , time = None ):
11+ def get_value (
12+ self , time : Optional [np .ndarray ] = None
13+ ) -> tuple [np .ndarray , np .ndarray ]:
1014 """Generate time and values based on the tendency. If no time array is provided,
1115 a time array will be created from the start to the end of the tendency, where
1216 time points are defined for every peak and trough in the tendency.
@@ -24,21 +28,17 @@ def generate(self, time=None):
2428 values = self ._calc_square_wave (time )
2529 return time , values
2630
27- def get_start_value (self ) -> float :
28- """Returns the value of the tendency at the start."""
29- return self ._calc_square_wave (self .start )
30-
31- def get_end_value (self ) -> float :
32- """Returns the value of the tendency at the end."""
33- return self ._calc_square_wave (self .end )
31+ def get_derivative (self , time : np .ndarray ) -> np .ndarray :
32+ """Get the derivative values on the provided time array.
3433
35- def get_derivative_start (self ) -> float :
36- """Returns the derivative of the tendency at the start."""
37- return 0
34+ Args:
35+ time: The time array on which to generate points.
3836
39- def get_derivative_end (self ) -> float :
40- """Returns the derivative of the tendency at the end."""
41- return 0
37+ Returns:
38+ numpy array containing the derivatives
39+ """
40+ derivatives = np .zeros (len (time ))
41+ return derivatives
4242
4343 def _calc_square_wave (self , time ):
4444 """Calculates the point of the square wave at a given time point or
0 commit comments