Coverage for tests / tests_library / tests_functions / test_trigonometric_functions.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-09 16:40 +0100

1# SPDX-FileCopyrightText: Copyright INRIA 

2# 

3# SPDX-License-Identifier: LGPL-3.0-only 

4# 

5# Copyright INRIA 

6# 

7# This file is part of PhysioBlocks, a library mostly developed by the 

8# [Ananke project-team](https://team.inria.fr/ananke) at INRIA. 

9# 

10# Authors: 

11# - Colin Drieu 

12# - Dominique Chapelle 

13# - François Kimmig 

14# - Philippe Moireau 

15# 

16# PhysioBlocks is free software: you can redistribute it and/or modify it under the 

17# terms of the GNU Lesser General Public License as published by the Free Software 

18# Foundation, version 3 of the License. 

19# 

20# PhysioBlocks is distributed in the hope that it will be useful, but WITHOUT ANY 

21# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 

22# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 

23# 

24# You should have received a copy of the GNU Lesser General Public License along with 

25# PhysioBlocks. If not, see <https://www.gnu.org/licenses/>. 

26 

27import numpy as np 

28import pytest 

29 

30from physioblocks.library.functions.trigonometric import SinusOffset 

31 

32 

33@pytest.fixture 

34def amplitude(): 

35 return 32.3 

36 

37 

38@pytest.fixture 

39def offset_value(): 

40 return 15.6 

41 

42 

43@pytest.fixture 

44def frequency(): 

45 return 2.1 

46 

47 

48@pytest.fixture 

49def phase_shift(): 

50 return np.pi / 5 

51 

52 

53class TestSinusOffset: 

54 def test_eval(self, offset_value, amplitude, frequency, phase_shift): 

55 function_ref = SinusOffset(offset_value, amplitude, frequency, phase_shift) 

56 assert function_ref.eval(0.0) == pytest.approx(34.58546364904688) 

57 assert function_ref.eval(0.5) == pytest.approx(41.73124891831079) 

58 assert function_ref.eval(0.25) == pytest.approx(-7.239549032325483) 

59 assert function_ref.eval(0.75) == pytest.approx(-13.179510731284259) 

60 assert function_ref.eval(1.5) == pytest.approx(47.9) 

61 assert function_ref.eval(2.25) == pytest.approx(-13.179510731284283)