Coverage for install/scipp/core/logical.py: 33%
12 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-24 01:51 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-24 01:51 +0000
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3# @author Jan-Lukas Wynen
4from __future__ import annotations
6from .._scipp import core as _cpp
7from ..typing import VariableLikeType
8from ._cpp_wrapper_util import call_func as _call_cpp_func
11def logical_not(x: VariableLikeType) -> VariableLikeType:
12 """Element-wise logical negation.
14 Equivalent to::
16 ~a
18 Parameters
19 ----------
20 x:
21 Input data.
23 Returns
24 -------
25 :
26 The logical inverse of ``x``.
27 """
28 return _call_cpp_func(_cpp.logical_not, x) # type: ignore[return-value]
31def logical_and(a: VariableLikeType, b: VariableLikeType) -> VariableLikeType:
32 """Element-wise logical and.
34 Equivalent to::
36 a & b
38 Parameters
39 ----------
40 a:
41 First input.
42 b:
43 Second input.
45 Returns
46 -------
47 :
48 The logical and of the elements of ``a`` and ``b``.
49 """
50 return _call_cpp_func(_cpp.logical_and, a, b) # type: ignore[return-value]
53def logical_or(a: VariableLikeType, b: VariableLikeType) -> VariableLikeType:
54 """Element-wise logical or.
56 Equivalent to::
58 a | b
60 Parameters
61 ----------
62 a:
63 First input.
64 b:
65 Second input.
67 Returns
68 -------
69 :
70 The logical or of the elements of ``a`` and ``b``.
71 """
72 return _call_cpp_func(_cpp.logical_or, a, b) # type: ignore[return-value]
75def logical_xor(a: VariableLikeType, b: VariableLikeType) -> VariableLikeType:
76 """Element-wise logical exclusive-or.
78 Equivalent to::
80 a ^ b
82 Parameters
83 ----------
84 a:
85 First input.
86 b:
87 Second input.
89 Returns
90 -------
91 :
92 The logical exclusive-or of the elements of ``a`` and ``b``.
93 """
94 return _call_cpp_func(_cpp.logical_xor, a, b) # type: ignore[return-value]