Coverage for install/scipp/core/trigonometry.py: 37%
19 statements
« prev ^ index » next coverage.py v7.4.0, created at 2024-04-28 01:28 +0000
« prev ^ index » next coverage.py v7.4.0, created at 2024-04-28 01:28 +0000
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3# @author Simon Heybrock
5from __future__ import annotations
7from typing import Optional
9from .._scipp import core as _cpp
10from ..typing import VariableLikeType
11from ._cpp_wrapper_util import call_func as _call_cpp_func
14def sin(
15 x: VariableLikeType, *, out: Optional[VariableLikeType] = None
16) -> VariableLikeType:
17 """Element-wise sine.
19 The input must have a plane-angle unit, i.e. ``rad``, ``deg``.
21 Parameters
22 ----------
23 x: scipp.typing.VariableLike
24 Input data.
25 out:
26 Optional output buffer.
28 Returns
29 -------
30 : Same type as input
31 The sine values of the input.
32 """
33 return _call_cpp_func(_cpp.sin, x, out=out)
36def cos(
37 x: VariableLikeType, *, out: Optional[VariableLikeType] = None
38) -> VariableLikeType:
39 """Element-wise cosine.
41 The input must have a plane-angle unit, i.e. ``rad``, ``deg``.
43 Parameters
44 ----------
45 x: scipp.typing.VariableLike
46 Input data.
47 out:
48 Optional output buffer.
50 Returns
51 -------
52 : Same type as input
53 The cosine values of the input.
54 """
55 return _call_cpp_func(_cpp.cos, x, out=out)
58def tan(
59 x: VariableLikeType, *, out: Optional[VariableLikeType] = None
60) -> VariableLikeType:
61 """Element-wise tangent.
63 The input must have a plane-angle unit, i.e. ``rad``, ``deg``.
65 Parameters
66 ----------
67 x: scipp.typing.VariableLike
68 Input data.
69 out:
70 Optional output buffer.
72 Returns
73 -------
74 : Same type as input
75 The tangent values of the input.
76 """
77 return _call_cpp_func(_cpp.tan, x, out=out)
80def asin(
81 x: VariableLikeType, *, out: Optional[VariableLikeType] = None
82) -> VariableLikeType:
83 """Element-wise inverse sine.
85 Parameters
86 ----------
87 x: scipp.typing.VariableLike
88 Input data.
89 out:
90 Optional output buffer.
92 Returns
93 -------
94 : Same type as input
95 The inverse sine values of the input in radians.
96 """
97 return _call_cpp_func(_cpp.asin, x, out=out)
100def acos(
101 x: VariableLikeType, *, out: Optional[VariableLikeType] = None
102) -> VariableLikeType:
103 """Element-wise inverse cosine.
105 Parameters
106 ----------
107 x: scipp.typing.VariableLike
108 Input data.
109 out:
110 Optional output buffer.
112 Returns
113 -------
114 : Same type as input
115 The inverse cosine values of the input in radians.
116 """
117 return _call_cpp_func(_cpp.acos, x, out=out)
120def atan(
121 x: VariableLikeType, *, out: Optional[VariableLikeType] = None
122) -> VariableLikeType:
123 """Element-wise inverse tangent.
125 Parameters
126 ----------
127 x: scipp.typing.VariableLike
128 Input data.
129 out:
130 Optional output buffer.
132 Returns
133 -------
134 : Same type as input
135 The inverse tangent values of the input in radians.
136 """
137 return _call_cpp_func(_cpp.atan, x, out=out)
140def atan2(
141 *, y: _cpp.Variable, x: _cpp.Variable, out: Optional[_cpp.Variable] = None
142) -> _cpp.Variable:
143 """Element-wise inverse tangent of y/x determining the correct quadrant.
145 Parameters
146 ----------
147 y:
148 Input y values.
149 x:
150 Input x values.
151 out:
152 Optional output buffer.
154 Returns
155 -------
156 :
157 The signed inverse tangent values of y/x in the range [-π, π].
159 See Also
160 --------
161 `<https://en.cppreference.com/w/c/numeric/math/atan2>`_:
162 Documentation of all edge cases.
163 Note that domain errors are *not* propagated to Python.
164 numpy.arctan2:
165 The equivalent in NumPy with additional explanations.
166 """
167 return _call_cpp_func(_cpp.atan2, y=y, x=x, out=out)