Coverage for install/scipp/core/logical.py: 33%

12 statements  

« 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 Jan-Lukas Wynen 

4from __future__ import annotations 

5 

6from .._scipp import core as _cpp 

7from ..typing import VariableLike 

8from ._cpp_wrapper_util import call_func as _call_cpp_func 

9 

10 

11def logical_not(x: VariableLike) -> VariableLike: 

12 """Element-wise logical negation. 

13 

14 Equivalent to:: 

15 

16 ~a 

17 

18 Parameters 

19 ---------- 

20 x: 

21 Input data. 

22 

23 Returns 

24 ------- 

25 : 

26 The logical inverse of ``x``. 

27 """ 

28 return _call_cpp_func(_cpp.logical_not, x) 

29 

30 

31def logical_and(a: VariableLike, b: VariableLike) -> VariableLike: 

32 """Element-wise logical and. 

33 

34 Equivalent to:: 

35 

36 a & b 

37 

38 Parameters 

39 ---------- 

40 a: 

41 First input. 

42 b: 

43 Second input. 

44 

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) 

51 

52 

53def logical_or(a: VariableLike, b: VariableLike) -> VariableLike: 

54 """Element-wise logical or. 

55 

56 Equivalent to:: 

57 

58 a | b 

59 

60 Parameters 

61 ---------- 

62 a: 

63 First input. 

64 b: 

65 Second input. 

66 

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) 

73 

74 

75def logical_xor(a: VariableLike, b: VariableLike) -> VariableLike: 

76 """Element-wise logical exclusive-or. 

77 

78 Equivalent to:: 

79 

80 a ^ b 

81 

82 Parameters 

83 ---------- 

84 a: 

85 First input. 

86 b: 

87 Second input. 

88 

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)