Coverage for src/algolib/numerics/trig.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-20 19:37 +0000

1from __future__ import annotations 

2from typing import Any 

3from ._backend import get_backend 

4 

5def sin(x: Any) -> float: 

6 """ 

7 Sine of an angle (system backend). 

8 

9 Parameters 

10 ---------- 

11 x : float 

12 Input angle in radians. 

13 

14 Returns 

15 ------- 

16 float 

17 ``sin(x)`` evaluated by the active numerics backend. 

18 """ 

19 return get_backend().sin(x) 

20 

21def cos(x: Any) -> float: 

22 """ 

23 Cosine of an angle (system backend). 

24 

25 Parameters 

26 ---------- 

27 x : float 

28 Input angle in radians. 

29 

30 Returns 

31 ------- 

32 float 

33 ``cos(x)`` evaluated by the active numerics backend. 

34 """ 

35 return get_backend().cos(x) 

36 

37def tan(x: Any) -> float: 

38 """ 

39 Tangent of an angle (system backend). 

40 

41 Notes 

42 ----- 

43 Argument-reduction and non-finite handling are performed inside the 

44 active backend (see ``_backend.SystemTrigBackend.tan``). Keeping this 

45 wrapper free of extra reduction ensures consistent periodicity tests. 

46 

47 Parameters 

48 ---------- 

49 x : float 

50 Input angle in radians. 

51 

52 Returns 

53 ------- 

54 float 

55 ``tan(x)`` evaluated by the active numerics backend. 

56 """ 

57 return get_backend().tan(x)