Coverage for D:\Ralf Gerlich\git\modypy\modypy\blocks\discont.py: 0%

# Coverage for D:\Ralf Gerlich\git\modypy\modypy\blocks\discont.py : 0%

## 7 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1"""Blocks for modelling discontinuities"""

2 from functools import partial

3

4 import numpy as np

5

6 from modypy.model import Signal

7

8

9 def _saturation_function(input_signal, lower_limit, upper_limit, data):

10 """Function to return a saturated signal"""

11

12 return np.minimum(np.maximum(input_signal(data), lower_limit), upper_limit)

13

14

15 def saturation(input_signal, lower_limit, upper_limit):

16 """

17 Limit a signal to lower and upper limits.

18

19 Args:

20 input_signal: The input signal

21 lower_limit: The lower limit

22 upper_limit: The upper limit

23

24 Returns:

25 The output signal with the limited value

26 """

27

28 return Signal(shape=input_signal.shape,

29 value=partial(_saturation_function,

30 input_signal,

31 lower_limit,

32 upper_limit))