ADAPT-Chase commited on
Commit
e16198d
·
verified ·
1 Parent(s): e66ec39

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +6 -0
  2. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/api/__pycache__/__init__.cpython-312.pyc +0 -0
  3. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/api/__pycache__/test_api.cpython-312.pyc +0 -0
  4. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/api/__pycache__/test_types.cpython-312.pyc +0 -0
  5. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/__init__.cpython-312.pyc +0 -0
  6. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/common.cpython-312.pyc +0 -0
  7. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/conftest.cpython-312.pyc +0 -0
  8. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_frame_apply.cpython-312.pyc +0 -0
  9. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_frame_apply_relabeling.cpython-312.pyc +0 -0
  10. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_frame_transform.cpython-312.pyc +0 -0
  11. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_invalid_arg.cpython-312.pyc +0 -0
  12. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_series_apply.cpython-312.pyc +0 -0
  13. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_series_apply_relabeling.cpython-312.pyc +0 -0
  14. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_series_transform.cpython-312.pyc +0 -0
  15. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_str.cpython-312.pyc +0 -0
  16. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/__init__.cpython-312.pyc +0 -0
  17. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/masked_shared.cpython-312.pyc +0 -0
  18. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_array.cpython-312.pyc +0 -0
  19. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_datetimelike.cpython-312.pyc +0 -0
  20. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_datetimes.cpython-312.pyc +0 -0
  21. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_ndarray_backed.cpython-312.pyc +0 -0
  22. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_period.cpython-312.pyc +0 -0
  23. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_timedeltas.cpython-312.pyc +0 -0
  24. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__init__.py +0 -0
  25. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/__init__.cpython-312.pyc +0 -0
  26. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_arithmetic.cpython-312.pyc +0 -0
  27. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_astype.cpython-312.pyc +0 -0
  28. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_comparison.cpython-312.pyc +0 -0
  29. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_construction.cpython-312.pyc +0 -0
  30. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_function.cpython-312.pyc +0 -0
  31. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_indexing.cpython-312.pyc +0 -0
  32. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_logical.cpython-312.pyc +0 -0
  33. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_ops.cpython-312.pyc +0 -0
  34. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_reduction.cpython-312.pyc +0 -0
  35. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_repr.cpython-312.pyc +0 -0
  36. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_arithmetic.py +129 -0
  37. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_astype.py +53 -0
  38. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_comparison.py +60 -0
  39. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_construction.py +326 -0
  40. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_function.py +126 -0
  41. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_indexing.py +13 -0
  42. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_logical.py +254 -0
  43. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_ops.py +27 -0
  44. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_reduction.py +62 -0
  45. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_repr.py +13 -0
  46. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__init__.py +0 -0
  47. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/__init__.cpython-312.pyc +0 -0
  48. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/conftest.cpython-312.pyc +0 -0
  49. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/test_algos.cpython-312.pyc +0 -0
  50. platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/test_analytics.cpython-312.pyc +0 -0
.gitattributes CHANGED
@@ -3472,3 +3472,9 @@ platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arithmetic/
3472
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arithmetic/__pycache__/test_timedelta64.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3473
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/computation/__pycache__/test_eval.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3474
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/groupby/__pycache__/test_groupby.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
3472
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arithmetic/__pycache__/test_timedelta64.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3473
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/computation/__pycache__/test_eval.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3474
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/groupby/__pycache__/test_groupby.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3475
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/indexing/__pycache__/test_loc.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3476
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_arrow.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3477
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/io/__pycache__/test_sql.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3478
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/io/__pycache__/test_stata.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3479
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/io/json/__pycache__/test_pandas.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3480
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/io/formats/__pycache__/test_format.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/api/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (195 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/api/__pycache__/test_api.cpython-312.pyc ADDED
Binary file (10.4 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/api/__pycache__/test_types.cpython-312.pyc ADDED
Binary file (2.25 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (197 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/common.cpython-312.pyc ADDED
Binary file (572 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/conftest.cpython-312.pyc ADDED
Binary file (897 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_frame_apply.cpython-312.pyc ADDED
Binary file (89.7 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_frame_apply_relabeling.cpython-312.pyc ADDED
Binary file (6.63 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_frame_transform.cpython-312.pyc ADDED
Binary file (14 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_invalid_arg.cpython-312.pyc ADDED
Binary file (19.2 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_series_apply.cpython-312.pyc ADDED
Binary file (41.9 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_series_apply_relabeling.cpython-312.pyc ADDED
Binary file (2.62 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_series_transform.cpython-312.pyc ADDED
Binary file (4.99 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/apply/__pycache__/test_str.cpython-312.pyc ADDED
Binary file (13.9 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (198 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/masked_shared.cpython-312.pyc ADDED
Binary file (8.09 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_array.cpython-312.pyc ADDED
Binary file (20.4 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_datetimelike.cpython-312.pyc ADDED
Binary file (67.8 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_datetimes.cpython-312.pyc ADDED
Binary file (42.5 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_ndarray_backed.cpython-312.pyc ADDED
Binary file (3.93 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_period.cpython-312.pyc ADDED
Binary file (9.42 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/__pycache__/test_timedeltas.cpython-312.pyc ADDED
Binary file (19 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__init__.py ADDED
File without changes
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (206 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_arithmetic.cpython-312.pyc ADDED
Binary file (5.59 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_astype.cpython-312.pyc ADDED
Binary file (2.97 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_comparison.cpython-312.pyc ADDED
Binary file (3.76 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_construction.cpython-312.pyc ADDED
Binary file (18.4 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_function.cpython-312.pyc ADDED
Binary file (7.53 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_indexing.cpython-312.pyc ADDED
Binary file (939 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_logical.cpython-312.pyc ADDED
Binary file (13.5 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_ops.cpython-312.pyc ADDED
Binary file (1.77 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_reduction.cpython-312.pyc ADDED
Binary file (3.74 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/__pycache__/test_repr.cpython-312.pyc ADDED
Binary file (933 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_arithmetic.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import operator
2
+
3
+ import numpy as np
4
+ import pytest
5
+
6
+ import pandas as pd
7
+ import pandas._testing as tm
8
+
9
+
10
+ @pytest.fixture
11
+ def data():
12
+ """Fixture returning boolean array with valid and missing values."""
13
+ return pd.array(
14
+ [True, False] * 4 + [np.nan] + [True, False] * 44 + [np.nan] + [True, False],
15
+ dtype="boolean",
16
+ )
17
+
18
+
19
+ @pytest.fixture
20
+ def left_array():
21
+ """Fixture returning boolean array with valid and missing values."""
22
+ return pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
23
+
24
+
25
+ @pytest.fixture
26
+ def right_array():
27
+ """Fixture returning boolean array with valid and missing values."""
28
+ return pd.array([True, False, None] * 3, dtype="boolean")
29
+
30
+
31
+ # Basic test for the arithmetic array ops
32
+ # -----------------------------------------------------------------------------
33
+
34
+
35
+ @pytest.mark.parametrize(
36
+ "opname, exp",
37
+ [
38
+ ("add", [True, True, None, True, False, None, None, None, None]),
39
+ ("mul", [True, False, None, False, False, None, None, None, None]),
40
+ ],
41
+ ids=["add", "mul"],
42
+ )
43
+ def test_add_mul(left_array, right_array, opname, exp):
44
+ op = getattr(operator, opname)
45
+ result = op(left_array, right_array)
46
+ expected = pd.array(exp, dtype="boolean")
47
+ tm.assert_extension_array_equal(result, expected)
48
+
49
+
50
+ def test_sub(left_array, right_array):
51
+ msg = (
52
+ r"numpy boolean subtract, the `-` operator, is (?:deprecated|not supported), "
53
+ r"use the bitwise_xor, the `\^` operator, or the logical_xor function instead\."
54
+ )
55
+ with pytest.raises(TypeError, match=msg):
56
+ left_array - right_array
57
+
58
+
59
+ def test_div(left_array, right_array):
60
+ msg = "operator '.*' not implemented for bool dtypes"
61
+ with pytest.raises(NotImplementedError, match=msg):
62
+ # check that we are matching the non-masked Series behavior
63
+ pd.Series(left_array._data) / pd.Series(right_array._data)
64
+
65
+ with pytest.raises(NotImplementedError, match=msg):
66
+ left_array / right_array
67
+
68
+
69
+ @pytest.mark.parametrize(
70
+ "opname",
71
+ [
72
+ "floordiv",
73
+ "mod",
74
+ "pow",
75
+ ],
76
+ )
77
+ def test_op_int8(left_array, right_array, opname):
78
+ op = getattr(operator, opname)
79
+ if opname != "mod":
80
+ msg = "operator '.*' not implemented for bool dtypes"
81
+ with pytest.raises(NotImplementedError, match=msg):
82
+ result = op(left_array, right_array)
83
+ return
84
+ result = op(left_array, right_array)
85
+ expected = op(left_array.astype("Int8"), right_array.astype("Int8"))
86
+ tm.assert_extension_array_equal(result, expected)
87
+
88
+
89
+ # Test generic characteristics / errors
90
+ # -----------------------------------------------------------------------------
91
+
92
+
93
+ def test_error_invalid_values(data, all_arithmetic_operators):
94
+ # invalid ops
95
+
96
+ op = all_arithmetic_operators
97
+ s = pd.Series(data)
98
+ ops = getattr(s, op)
99
+
100
+ # invalid scalars
101
+ msg = (
102
+ "did not contain a loop with signature matching types|"
103
+ "BooleanArray cannot perform the operation|"
104
+ "not supported for the input types, and the inputs could not be safely coerced "
105
+ "to any supported types according to the casting rule ''safe''"
106
+ )
107
+ with pytest.raises(TypeError, match=msg):
108
+ ops("foo")
109
+ msg = "|".join(
110
+ [
111
+ r"unsupported operand type\(s\) for",
112
+ "Concatenation operation is not implemented for NumPy arrays",
113
+ ]
114
+ )
115
+ with pytest.raises(TypeError, match=msg):
116
+ ops(pd.Timestamp("20180101"))
117
+
118
+ # invalid array-likes
119
+ if op not in ("__mul__", "__rmul__"):
120
+ # TODO(extension) numpy's mul with object array sees booleans as numbers
121
+ msg = "|".join(
122
+ [
123
+ r"unsupported operand type\(s\) for",
124
+ "can only concatenate str",
125
+ "not all arguments converted during string formatting",
126
+ ]
127
+ )
128
+ with pytest.raises(TypeError, match=msg):
129
+ ops(pd.Series("foo", index=s.index))
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_astype.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+
7
+
8
+ def test_astype():
9
+ # with missing values
10
+ arr = pd.array([True, False, None], dtype="boolean")
11
+
12
+ with pytest.raises(ValueError, match="cannot convert NA to integer"):
13
+ arr.astype("int64")
14
+
15
+ with pytest.raises(ValueError, match="cannot convert float NaN to"):
16
+ arr.astype("bool")
17
+
18
+ result = arr.astype("float64")
19
+ expected = np.array([1, 0, np.nan], dtype="float64")
20
+ tm.assert_numpy_array_equal(result, expected)
21
+
22
+ result = arr.astype("str")
23
+ expected = np.array(["True", "False", "<NA>"], dtype=f"{tm.ENDIAN}U5")
24
+ tm.assert_numpy_array_equal(result, expected)
25
+
26
+ # no missing values
27
+ arr = pd.array([True, False, True], dtype="boolean")
28
+ result = arr.astype("int64")
29
+ expected = np.array([1, 0, 1], dtype="int64")
30
+ tm.assert_numpy_array_equal(result, expected)
31
+
32
+ result = arr.astype("bool")
33
+ expected = np.array([True, False, True], dtype="bool")
34
+ tm.assert_numpy_array_equal(result, expected)
35
+
36
+
37
+ def test_astype_to_boolean_array():
38
+ # astype to BooleanArray
39
+ arr = pd.array([True, False, None], dtype="boolean")
40
+
41
+ result = arr.astype("boolean")
42
+ tm.assert_extension_array_equal(result, arr)
43
+ result = arr.astype(pd.BooleanDtype())
44
+ tm.assert_extension_array_equal(result, arr)
45
+
46
+
47
+ def test_astype_to_integer_array():
48
+ # astype to IntegerArray
49
+ arr = pd.array([True, False, None], dtype="boolean")
50
+
51
+ result = arr.astype("Int64")
52
+ expected = pd.array([1, 0, None], dtype="Int64")
53
+ tm.assert_extension_array_equal(result, expected)
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_comparison.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+ from pandas.arrays import BooleanArray
7
+ from pandas.tests.arrays.masked_shared import ComparisonOps
8
+
9
+
10
+ @pytest.fixture
11
+ def data():
12
+ """Fixture returning boolean array with valid and missing data"""
13
+ return pd.array(
14
+ [True, False] * 4 + [np.nan] + [True, False] * 44 + [np.nan] + [True, False],
15
+ dtype="boolean",
16
+ )
17
+
18
+
19
+ @pytest.fixture
20
+ def dtype():
21
+ """Fixture returning BooleanDtype"""
22
+ return pd.BooleanDtype()
23
+
24
+
25
+ class TestComparisonOps(ComparisonOps):
26
+ def test_compare_scalar(self, data, comparison_op):
27
+ self._compare_other(data, comparison_op, True)
28
+
29
+ def test_compare_array(self, data, comparison_op):
30
+ other = pd.array([True] * len(data), dtype="boolean")
31
+ self._compare_other(data, comparison_op, other)
32
+ other = np.array([True] * len(data))
33
+ self._compare_other(data, comparison_op, other)
34
+ other = pd.Series([True] * len(data))
35
+ self._compare_other(data, comparison_op, other)
36
+
37
+ @pytest.mark.parametrize("other", [True, False, pd.NA])
38
+ def test_scalar(self, other, comparison_op, dtype):
39
+ ComparisonOps.test_scalar(self, other, comparison_op, dtype)
40
+
41
+ def test_array(self, comparison_op):
42
+ op = comparison_op
43
+ a = pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
44
+ b = pd.array([True, False, None] * 3, dtype="boolean")
45
+
46
+ result = op(a, b)
47
+
48
+ values = op(a._data, b._data)
49
+ mask = a._mask | b._mask
50
+ expected = BooleanArray(values, mask)
51
+ tm.assert_extension_array_equal(result, expected)
52
+
53
+ # ensure we haven't mutated anything inplace
54
+ result[0] = None
55
+ tm.assert_extension_array_equal(
56
+ a, pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
57
+ )
58
+ tm.assert_extension_array_equal(
59
+ b, pd.array([True, False, None] * 3, dtype="boolean")
60
+ )
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_construction.py ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+ from pandas.arrays import BooleanArray
7
+ from pandas.core.arrays.boolean import coerce_to_array
8
+
9
+
10
+ def test_boolean_array_constructor():
11
+ values = np.array([True, False, True, False], dtype="bool")
12
+ mask = np.array([False, False, False, True], dtype="bool")
13
+
14
+ result = BooleanArray(values, mask)
15
+ expected = pd.array([True, False, True, None], dtype="boolean")
16
+ tm.assert_extension_array_equal(result, expected)
17
+
18
+ with pytest.raises(TypeError, match="values should be boolean numpy array"):
19
+ BooleanArray(values.tolist(), mask)
20
+
21
+ with pytest.raises(TypeError, match="mask should be boolean numpy array"):
22
+ BooleanArray(values, mask.tolist())
23
+
24
+ with pytest.raises(TypeError, match="values should be boolean numpy array"):
25
+ BooleanArray(values.astype(int), mask)
26
+
27
+ with pytest.raises(TypeError, match="mask should be boolean numpy array"):
28
+ BooleanArray(values, None)
29
+
30
+ with pytest.raises(ValueError, match="values.shape must match mask.shape"):
31
+ BooleanArray(values.reshape(1, -1), mask)
32
+
33
+ with pytest.raises(ValueError, match="values.shape must match mask.shape"):
34
+ BooleanArray(values, mask.reshape(1, -1))
35
+
36
+
37
+ def test_boolean_array_constructor_copy():
38
+ values = np.array([True, False, True, False], dtype="bool")
39
+ mask = np.array([False, False, False, True], dtype="bool")
40
+
41
+ result = BooleanArray(values, mask)
42
+ assert result._data is values
43
+ assert result._mask is mask
44
+
45
+ result = BooleanArray(values, mask, copy=True)
46
+ assert result._data is not values
47
+ assert result._mask is not mask
48
+
49
+
50
+ def test_to_boolean_array():
51
+ expected = BooleanArray(
52
+ np.array([True, False, True]), np.array([False, False, False])
53
+ )
54
+
55
+ result = pd.array([True, False, True], dtype="boolean")
56
+ tm.assert_extension_array_equal(result, expected)
57
+ result = pd.array(np.array([True, False, True]), dtype="boolean")
58
+ tm.assert_extension_array_equal(result, expected)
59
+ result = pd.array(np.array([True, False, True], dtype=object), dtype="boolean")
60
+ tm.assert_extension_array_equal(result, expected)
61
+
62
+ # with missing values
63
+ expected = BooleanArray(
64
+ np.array([True, False, True]), np.array([False, False, True])
65
+ )
66
+
67
+ result = pd.array([True, False, None], dtype="boolean")
68
+ tm.assert_extension_array_equal(result, expected)
69
+ result = pd.array(np.array([True, False, None], dtype=object), dtype="boolean")
70
+ tm.assert_extension_array_equal(result, expected)
71
+
72
+
73
+ def test_to_boolean_array_all_none():
74
+ expected = BooleanArray(np.array([True, True, True]), np.array([True, True, True]))
75
+
76
+ result = pd.array([None, None, None], dtype="boolean")
77
+ tm.assert_extension_array_equal(result, expected)
78
+ result = pd.array(np.array([None, None, None], dtype=object), dtype="boolean")
79
+ tm.assert_extension_array_equal(result, expected)
80
+
81
+
82
+ @pytest.mark.parametrize(
83
+ "a, b",
84
+ [
85
+ ([True, False, None, np.nan, pd.NA], [True, False, None, None, None]),
86
+ ([True, np.nan], [True, None]),
87
+ ([True, pd.NA], [True, None]),
88
+ ([np.nan, np.nan], [None, None]),
89
+ (np.array([np.nan, np.nan], dtype=float), [None, None]),
90
+ ],
91
+ )
92
+ def test_to_boolean_array_missing_indicators(a, b):
93
+ result = pd.array(a, dtype="boolean")
94
+ expected = pd.array(b, dtype="boolean")
95
+ tm.assert_extension_array_equal(result, expected)
96
+
97
+
98
+ @pytest.mark.parametrize(
99
+ "values",
100
+ [
101
+ ["foo", "bar"],
102
+ ["1", "2"],
103
+ # "foo",
104
+ [1, 2],
105
+ [1.0, 2.0],
106
+ pd.date_range("20130101", periods=2),
107
+ np.array(["foo"]),
108
+ np.array([1, 2]),
109
+ np.array([1.0, 2.0]),
110
+ [np.nan, {"a": 1}],
111
+ ],
112
+ )
113
+ def test_to_boolean_array_error(values):
114
+ # error in converting existing arrays to BooleanArray
115
+ msg = "Need to pass bool-like value"
116
+ with pytest.raises(TypeError, match=msg):
117
+ pd.array(values, dtype="boolean")
118
+
119
+
120
+ def test_to_boolean_array_from_integer_array():
121
+ result = pd.array(np.array([1, 0, 1, 0]), dtype="boolean")
122
+ expected = pd.array([True, False, True, False], dtype="boolean")
123
+ tm.assert_extension_array_equal(result, expected)
124
+
125
+ # with missing values
126
+ result = pd.array(np.array([1, 0, 1, None]), dtype="boolean")
127
+ expected = pd.array([True, False, True, None], dtype="boolean")
128
+ tm.assert_extension_array_equal(result, expected)
129
+
130
+
131
+ def test_to_boolean_array_from_float_array():
132
+ result = pd.array(np.array([1.0, 0.0, 1.0, 0.0]), dtype="boolean")
133
+ expected = pd.array([True, False, True, False], dtype="boolean")
134
+ tm.assert_extension_array_equal(result, expected)
135
+
136
+ # with missing values
137
+ result = pd.array(np.array([1.0, 0.0, 1.0, np.nan]), dtype="boolean")
138
+ expected = pd.array([True, False, True, None], dtype="boolean")
139
+ tm.assert_extension_array_equal(result, expected)
140
+
141
+
142
+ def test_to_boolean_array_integer_like():
143
+ # integers of 0's and 1's
144
+ result = pd.array([1, 0, 1, 0], dtype="boolean")
145
+ expected = pd.array([True, False, True, False], dtype="boolean")
146
+ tm.assert_extension_array_equal(result, expected)
147
+
148
+ # with missing values
149
+ result = pd.array([1, 0, 1, None], dtype="boolean")
150
+ expected = pd.array([True, False, True, None], dtype="boolean")
151
+ tm.assert_extension_array_equal(result, expected)
152
+
153
+
154
+ def test_coerce_to_array():
155
+ # TODO this is currently not public API
156
+ values = np.array([True, False, True, False], dtype="bool")
157
+ mask = np.array([False, False, False, True], dtype="bool")
158
+ result = BooleanArray(*coerce_to_array(values, mask=mask))
159
+ expected = BooleanArray(values, mask)
160
+ tm.assert_extension_array_equal(result, expected)
161
+ assert result._data is values
162
+ assert result._mask is mask
163
+ result = BooleanArray(*coerce_to_array(values, mask=mask, copy=True))
164
+ expected = BooleanArray(values, mask)
165
+ tm.assert_extension_array_equal(result, expected)
166
+ assert result._data is not values
167
+ assert result._mask is not mask
168
+
169
+ # mixed missing from values and mask
170
+ values = [True, False, None, False]
171
+ mask = np.array([False, False, False, True], dtype="bool")
172
+ result = BooleanArray(*coerce_to_array(values, mask=mask))
173
+ expected = BooleanArray(
174
+ np.array([True, False, True, True]), np.array([False, False, True, True])
175
+ )
176
+ tm.assert_extension_array_equal(result, expected)
177
+ result = BooleanArray(*coerce_to_array(np.array(values, dtype=object), mask=mask))
178
+ tm.assert_extension_array_equal(result, expected)
179
+ result = BooleanArray(*coerce_to_array(values, mask=mask.tolist()))
180
+ tm.assert_extension_array_equal(result, expected)
181
+
182
+ # raise errors for wrong dimension
183
+ values = np.array([True, False, True, False], dtype="bool")
184
+ mask = np.array([False, False, False, True], dtype="bool")
185
+
186
+ # passing 2D values is OK as long as no mask
187
+ coerce_to_array(values.reshape(1, -1))
188
+
189
+ with pytest.raises(ValueError, match="values.shape and mask.shape must match"):
190
+ coerce_to_array(values.reshape(1, -1), mask=mask)
191
+
192
+ with pytest.raises(ValueError, match="values.shape and mask.shape must match"):
193
+ coerce_to_array(values, mask=mask.reshape(1, -1))
194
+
195
+
196
+ def test_coerce_to_array_from_boolean_array():
197
+ # passing BooleanArray to coerce_to_array
198
+ values = np.array([True, False, True, False], dtype="bool")
199
+ mask = np.array([False, False, False, True], dtype="bool")
200
+ arr = BooleanArray(values, mask)
201
+ result = BooleanArray(*coerce_to_array(arr))
202
+ tm.assert_extension_array_equal(result, arr)
203
+ # no copy
204
+ assert result._data is arr._data
205
+ assert result._mask is arr._mask
206
+
207
+ result = BooleanArray(*coerce_to_array(arr), copy=True)
208
+ tm.assert_extension_array_equal(result, arr)
209
+ assert result._data is not arr._data
210
+ assert result._mask is not arr._mask
211
+
212
+ with pytest.raises(ValueError, match="cannot pass mask for BooleanArray input"):
213
+ coerce_to_array(arr, mask=mask)
214
+
215
+
216
+ def test_coerce_to_numpy_array():
217
+ # with missing values -> object dtype
218
+ arr = pd.array([True, False, None], dtype="boolean")
219
+ result = np.array(arr)
220
+ expected = np.array([True, False, pd.NA], dtype="object")
221
+ tm.assert_numpy_array_equal(result, expected)
222
+
223
+ # also with no missing values -> object dtype
224
+ arr = pd.array([True, False, True], dtype="boolean")
225
+ result = np.array(arr)
226
+ expected = np.array([True, False, True], dtype="object")
227
+ tm.assert_numpy_array_equal(result, expected)
228
+
229
+ # force bool dtype
230
+ result = np.array(arr, dtype="bool")
231
+ expected = np.array([True, False, True], dtype="bool")
232
+ tm.assert_numpy_array_equal(result, expected)
233
+ # with missing values will raise error
234
+ arr = pd.array([True, False, None], dtype="boolean")
235
+ msg = (
236
+ "cannot convert to 'bool'-dtype NumPy array with missing values. "
237
+ "Specify an appropriate 'na_value' for this dtype."
238
+ )
239
+ with pytest.raises(ValueError, match=msg):
240
+ np.array(arr, dtype="bool")
241
+
242
+
243
+ def test_to_boolean_array_from_strings():
244
+ result = BooleanArray._from_sequence_of_strings(
245
+ np.array(["True", "False", "1", "1.0", "0", "0.0", np.nan], dtype=object)
246
+ )
247
+ expected = BooleanArray(
248
+ np.array([True, False, True, True, False, False, False]),
249
+ np.array([False, False, False, False, False, False, True]),
250
+ )
251
+
252
+ tm.assert_extension_array_equal(result, expected)
253
+
254
+
255
+ def test_to_boolean_array_from_strings_invalid_string():
256
+ with pytest.raises(ValueError, match="cannot be cast"):
257
+ BooleanArray._from_sequence_of_strings(["donkey"])
258
+
259
+
260
+ @pytest.mark.parametrize("box", [True, False], ids=["series", "array"])
261
+ def test_to_numpy(box):
262
+ con = pd.Series if box else pd.array
263
+ # default (with or without missing values) -> object dtype
264
+ arr = con([True, False, True], dtype="boolean")
265
+ result = arr.to_numpy()
266
+ expected = np.array([True, False, True], dtype="object")
267
+ tm.assert_numpy_array_equal(result, expected)
268
+
269
+ arr = con([True, False, None], dtype="boolean")
270
+ result = arr.to_numpy()
271
+ expected = np.array([True, False, pd.NA], dtype="object")
272
+ tm.assert_numpy_array_equal(result, expected)
273
+
274
+ arr = con([True, False, None], dtype="boolean")
275
+ result = arr.to_numpy(dtype="str")
276
+ expected = np.array([True, False, pd.NA], dtype=f"{tm.ENDIAN}U5")
277
+ tm.assert_numpy_array_equal(result, expected)
278
+
279
+ # no missing values -> can convert to bool, otherwise raises
280
+ arr = con([True, False, True], dtype="boolean")
281
+ result = arr.to_numpy(dtype="bool")
282
+ expected = np.array([True, False, True], dtype="bool")
283
+ tm.assert_numpy_array_equal(result, expected)
284
+
285
+ arr = con([True, False, None], dtype="boolean")
286
+ with pytest.raises(ValueError, match="cannot convert to 'bool'-dtype"):
287
+ result = arr.to_numpy(dtype="bool")
288
+
289
+ # specify dtype and na_value
290
+ arr = con([True, False, None], dtype="boolean")
291
+ result = arr.to_numpy(dtype=object, na_value=None)
292
+ expected = np.array([True, False, None], dtype="object")
293
+ tm.assert_numpy_array_equal(result, expected)
294
+
295
+ result = arr.to_numpy(dtype=bool, na_value=False)
296
+ expected = np.array([True, False, False], dtype="bool")
297
+ tm.assert_numpy_array_equal(result, expected)
298
+
299
+ result = arr.to_numpy(dtype="int64", na_value=-99)
300
+ expected = np.array([1, 0, -99], dtype="int64")
301
+ tm.assert_numpy_array_equal(result, expected)
302
+
303
+ result = arr.to_numpy(dtype="float64", na_value=np.nan)
304
+ expected = np.array([1, 0, np.nan], dtype="float64")
305
+ tm.assert_numpy_array_equal(result, expected)
306
+
307
+ # converting to int or float without specifying na_value raises
308
+ with pytest.raises(ValueError, match="cannot convert to 'int64'-dtype"):
309
+ arr.to_numpy(dtype="int64")
310
+ with pytest.raises(ValueError, match="cannot convert to 'float64'-dtype"):
311
+ arr.to_numpy(dtype="float64")
312
+
313
+
314
+ def test_to_numpy_copy():
315
+ # to_numpy can be zero-copy if no missing values
316
+ arr = pd.array([True, False, True], dtype="boolean")
317
+ result = arr.to_numpy(dtype=bool)
318
+ result[0] = False
319
+ tm.assert_extension_array_equal(
320
+ arr, pd.array([False, False, True], dtype="boolean")
321
+ )
322
+
323
+ arr = pd.array([True, False, True], dtype="boolean")
324
+ result = arr.to_numpy(dtype=bool, copy=True)
325
+ result[0] = False
326
+ tm.assert_extension_array_equal(arr, pd.array([True, False, True], dtype="boolean"))
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_function.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+
7
+
8
+ @pytest.mark.parametrize(
9
+ "ufunc", [np.add, np.logical_or, np.logical_and, np.logical_xor]
10
+ )
11
+ def test_ufuncs_binary(ufunc):
12
+ # two BooleanArrays
13
+ a = pd.array([True, False, None], dtype="boolean")
14
+ result = ufunc(a, a)
15
+ expected = pd.array(ufunc(a._data, a._data), dtype="boolean")
16
+ expected[a._mask] = np.nan
17
+ tm.assert_extension_array_equal(result, expected)
18
+
19
+ s = pd.Series(a)
20
+ result = ufunc(s, a)
21
+ expected = pd.Series(ufunc(a._data, a._data), dtype="boolean")
22
+ expected[a._mask] = np.nan
23
+ tm.assert_series_equal(result, expected)
24
+
25
+ # Boolean with numpy array
26
+ arr = np.array([True, True, False])
27
+ result = ufunc(a, arr)
28
+ expected = pd.array(ufunc(a._data, arr), dtype="boolean")
29
+ expected[a._mask] = np.nan
30
+ tm.assert_extension_array_equal(result, expected)
31
+
32
+ result = ufunc(arr, a)
33
+ expected = pd.array(ufunc(arr, a._data), dtype="boolean")
34
+ expected[a._mask] = np.nan
35
+ tm.assert_extension_array_equal(result, expected)
36
+
37
+ # BooleanArray with scalar
38
+ result = ufunc(a, True)
39
+ expected = pd.array(ufunc(a._data, True), dtype="boolean")
40
+ expected[a._mask] = np.nan
41
+ tm.assert_extension_array_equal(result, expected)
42
+
43
+ result = ufunc(True, a)
44
+ expected = pd.array(ufunc(True, a._data), dtype="boolean")
45
+ expected[a._mask] = np.nan
46
+ tm.assert_extension_array_equal(result, expected)
47
+
48
+ # not handled types
49
+ msg = r"operand type\(s\) all returned NotImplemented from __array_ufunc__"
50
+ with pytest.raises(TypeError, match=msg):
51
+ ufunc(a, "test")
52
+
53
+
54
+ @pytest.mark.parametrize("ufunc", [np.logical_not])
55
+ def test_ufuncs_unary(ufunc):
56
+ a = pd.array([True, False, None], dtype="boolean")
57
+ result = ufunc(a)
58
+ expected = pd.array(ufunc(a._data), dtype="boolean")
59
+ expected[a._mask] = np.nan
60
+ tm.assert_extension_array_equal(result, expected)
61
+
62
+ ser = pd.Series(a)
63
+ result = ufunc(ser)
64
+ expected = pd.Series(ufunc(a._data), dtype="boolean")
65
+ expected[a._mask] = np.nan
66
+ tm.assert_series_equal(result, expected)
67
+
68
+
69
+ def test_ufunc_numeric():
70
+ # np.sqrt on np.bool_ returns float16, which we upcast to Float32
71
+ # bc we do not have Float16
72
+ arr = pd.array([True, False, None], dtype="boolean")
73
+
74
+ res = np.sqrt(arr)
75
+
76
+ expected = pd.array([1, 0, None], dtype="Float32")
77
+ tm.assert_extension_array_equal(res, expected)
78
+
79
+
80
+ @pytest.mark.parametrize("values", [[True, False], [True, None]])
81
+ def test_ufunc_reduce_raises(values):
82
+ arr = pd.array(values, dtype="boolean")
83
+
84
+ res = np.add.reduce(arr)
85
+ if arr[-1] is pd.NA:
86
+ expected = pd.NA
87
+ else:
88
+ expected = arr._data.sum()
89
+ tm.assert_almost_equal(res, expected)
90
+
91
+
92
+ def test_value_counts_na():
93
+ arr = pd.array([True, False, pd.NA], dtype="boolean")
94
+ result = arr.value_counts(dropna=False)
95
+ expected = pd.Series([1, 1, 1], index=arr, dtype="Int64", name="count")
96
+ assert expected.index.dtype == arr.dtype
97
+ tm.assert_series_equal(result, expected)
98
+
99
+ result = arr.value_counts(dropna=True)
100
+ expected = pd.Series([1, 1], index=arr[:-1], dtype="Int64", name="count")
101
+ assert expected.index.dtype == arr.dtype
102
+ tm.assert_series_equal(result, expected)
103
+
104
+
105
+ def test_value_counts_with_normalize():
106
+ ser = pd.Series([True, False, pd.NA], dtype="boolean")
107
+ result = ser.value_counts(normalize=True)
108
+ expected = pd.Series([1, 1], index=ser[:-1], dtype="Float64", name="proportion") / 2
109
+ assert expected.index.dtype == "boolean"
110
+ tm.assert_series_equal(result, expected)
111
+
112
+
113
+ def test_diff():
114
+ a = pd.array(
115
+ [True, True, False, False, True, None, True, None, False], dtype="boolean"
116
+ )
117
+ result = pd.core.algorithms.diff(a, 1)
118
+ expected = pd.array(
119
+ [None, False, True, False, True, None, None, None, None], dtype="boolean"
120
+ )
121
+ tm.assert_extension_array_equal(result, expected)
122
+
123
+ ser = pd.Series(a)
124
+ result = ser.diff()
125
+ expected = pd.Series(expected)
126
+ tm.assert_series_equal(result, expected)
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_indexing.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+
7
+
8
+ @pytest.mark.parametrize("na", [None, np.nan, pd.NA])
9
+ def test_setitem_missing_values(na):
10
+ arr = pd.array([True, False, None], dtype="boolean")
11
+ expected = pd.array([True, None, None], dtype="boolean")
12
+ arr[1] = na
13
+ tm.assert_extension_array_equal(arr, expected)
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_logical.py ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import operator
2
+
3
+ import numpy as np
4
+ import pytest
5
+
6
+ import pandas as pd
7
+ import pandas._testing as tm
8
+ from pandas.arrays import BooleanArray
9
+ from pandas.core.ops.mask_ops import (
10
+ kleene_and,
11
+ kleene_or,
12
+ kleene_xor,
13
+ )
14
+ from pandas.tests.extension.base import BaseOpsUtil
15
+
16
+
17
+ class TestLogicalOps(BaseOpsUtil):
18
+ def test_numpy_scalars_ok(self, all_logical_operators):
19
+ a = pd.array([True, False, None], dtype="boolean")
20
+ op = getattr(a, all_logical_operators)
21
+
22
+ tm.assert_extension_array_equal(op(True), op(np.bool_(True)))
23
+ tm.assert_extension_array_equal(op(False), op(np.bool_(False)))
24
+
25
+ def get_op_from_name(self, op_name):
26
+ short_opname = op_name.strip("_")
27
+ short_opname = short_opname if "xor" in short_opname else short_opname + "_"
28
+ try:
29
+ op = getattr(operator, short_opname)
30
+ except AttributeError:
31
+ # Assume it is the reverse operator
32
+ rop = getattr(operator, short_opname[1:])
33
+ op = lambda x, y: rop(y, x)
34
+
35
+ return op
36
+
37
+ def test_empty_ok(self, all_logical_operators):
38
+ a = pd.array([], dtype="boolean")
39
+ op_name = all_logical_operators
40
+ result = getattr(a, op_name)(True)
41
+ tm.assert_extension_array_equal(a, result)
42
+
43
+ result = getattr(a, op_name)(False)
44
+ tm.assert_extension_array_equal(a, result)
45
+
46
+ result = getattr(a, op_name)(pd.NA)
47
+ tm.assert_extension_array_equal(a, result)
48
+
49
+ @pytest.mark.parametrize(
50
+ "other", ["a", pd.Timestamp(2017, 1, 1, 12), np.timedelta64(4)]
51
+ )
52
+ def test_eq_mismatched_type(self, other):
53
+ # GH-44499
54
+ arr = pd.array([True, False])
55
+ result = arr == other
56
+ expected = pd.array([False, False])
57
+ tm.assert_extension_array_equal(result, expected)
58
+
59
+ result = arr != other
60
+ expected = pd.array([True, True])
61
+ tm.assert_extension_array_equal(result, expected)
62
+
63
+ def test_logical_length_mismatch_raises(self, all_logical_operators):
64
+ op_name = all_logical_operators
65
+ a = pd.array([True, False, None], dtype="boolean")
66
+ msg = "Lengths must match"
67
+
68
+ with pytest.raises(ValueError, match=msg):
69
+ getattr(a, op_name)([True, False])
70
+
71
+ with pytest.raises(ValueError, match=msg):
72
+ getattr(a, op_name)(np.array([True, False]))
73
+
74
+ with pytest.raises(ValueError, match=msg):
75
+ getattr(a, op_name)(pd.array([True, False], dtype="boolean"))
76
+
77
+ def test_logical_nan_raises(self, all_logical_operators):
78
+ op_name = all_logical_operators
79
+ a = pd.array([True, False, None], dtype="boolean")
80
+ msg = "Got float instead"
81
+
82
+ with pytest.raises(TypeError, match=msg):
83
+ getattr(a, op_name)(np.nan)
84
+
85
+ @pytest.mark.parametrize("other", ["a", 1])
86
+ def test_non_bool_or_na_other_raises(self, other, all_logical_operators):
87
+ a = pd.array([True, False], dtype="boolean")
88
+ with pytest.raises(TypeError, match=str(type(other).__name__)):
89
+ getattr(a, all_logical_operators)(other)
90
+
91
+ def test_kleene_or(self):
92
+ # A clear test of behavior.
93
+ a = pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
94
+ b = pd.array([True, False, None] * 3, dtype="boolean")
95
+ result = a | b
96
+ expected = pd.array(
97
+ [True, True, True, True, False, None, True, None, None], dtype="boolean"
98
+ )
99
+ tm.assert_extension_array_equal(result, expected)
100
+
101
+ result = b | a
102
+ tm.assert_extension_array_equal(result, expected)
103
+
104
+ # ensure we haven't mutated anything inplace
105
+ tm.assert_extension_array_equal(
106
+ a, pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
107
+ )
108
+ tm.assert_extension_array_equal(
109
+ b, pd.array([True, False, None] * 3, dtype="boolean")
110
+ )
111
+
112
+ @pytest.mark.parametrize(
113
+ "other, expected",
114
+ [
115
+ (pd.NA, [True, None, None]),
116
+ (True, [True, True, True]),
117
+ (np.bool_(True), [True, True, True]),
118
+ (False, [True, False, None]),
119
+ (np.bool_(False), [True, False, None]),
120
+ ],
121
+ )
122
+ def test_kleene_or_scalar(self, other, expected):
123
+ # TODO: test True & False
124
+ a = pd.array([True, False, None], dtype="boolean")
125
+ result = a | other
126
+ expected = pd.array(expected, dtype="boolean")
127
+ tm.assert_extension_array_equal(result, expected)
128
+
129
+ result = other | a
130
+ tm.assert_extension_array_equal(result, expected)
131
+
132
+ # ensure we haven't mutated anything inplace
133
+ tm.assert_extension_array_equal(
134
+ a, pd.array([True, False, None], dtype="boolean")
135
+ )
136
+
137
+ def test_kleene_and(self):
138
+ # A clear test of behavior.
139
+ a = pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
140
+ b = pd.array([True, False, None] * 3, dtype="boolean")
141
+ result = a & b
142
+ expected = pd.array(
143
+ [True, False, None, False, False, False, None, False, None], dtype="boolean"
144
+ )
145
+ tm.assert_extension_array_equal(result, expected)
146
+
147
+ result = b & a
148
+ tm.assert_extension_array_equal(result, expected)
149
+
150
+ # ensure we haven't mutated anything inplace
151
+ tm.assert_extension_array_equal(
152
+ a, pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
153
+ )
154
+ tm.assert_extension_array_equal(
155
+ b, pd.array([True, False, None] * 3, dtype="boolean")
156
+ )
157
+
158
+ @pytest.mark.parametrize(
159
+ "other, expected",
160
+ [
161
+ (pd.NA, [None, False, None]),
162
+ (True, [True, False, None]),
163
+ (False, [False, False, False]),
164
+ (np.bool_(True), [True, False, None]),
165
+ (np.bool_(False), [False, False, False]),
166
+ ],
167
+ )
168
+ def test_kleene_and_scalar(self, other, expected):
169
+ a = pd.array([True, False, None], dtype="boolean")
170
+ result = a & other
171
+ expected = pd.array(expected, dtype="boolean")
172
+ tm.assert_extension_array_equal(result, expected)
173
+
174
+ result = other & a
175
+ tm.assert_extension_array_equal(result, expected)
176
+
177
+ # ensure we haven't mutated anything inplace
178
+ tm.assert_extension_array_equal(
179
+ a, pd.array([True, False, None], dtype="boolean")
180
+ )
181
+
182
+ def test_kleene_xor(self):
183
+ a = pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
184
+ b = pd.array([True, False, None] * 3, dtype="boolean")
185
+ result = a ^ b
186
+ expected = pd.array(
187
+ [False, True, None, True, False, None, None, None, None], dtype="boolean"
188
+ )
189
+ tm.assert_extension_array_equal(result, expected)
190
+
191
+ result = b ^ a
192
+ tm.assert_extension_array_equal(result, expected)
193
+
194
+ # ensure we haven't mutated anything inplace
195
+ tm.assert_extension_array_equal(
196
+ a, pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
197
+ )
198
+ tm.assert_extension_array_equal(
199
+ b, pd.array([True, False, None] * 3, dtype="boolean")
200
+ )
201
+
202
+ @pytest.mark.parametrize(
203
+ "other, expected",
204
+ [
205
+ (pd.NA, [None, None, None]),
206
+ (True, [False, True, None]),
207
+ (np.bool_(True), [False, True, None]),
208
+ (np.bool_(False), [True, False, None]),
209
+ ],
210
+ )
211
+ def test_kleene_xor_scalar(self, other, expected):
212
+ a = pd.array([True, False, None], dtype="boolean")
213
+ result = a ^ other
214
+ expected = pd.array(expected, dtype="boolean")
215
+ tm.assert_extension_array_equal(result, expected)
216
+
217
+ result = other ^ a
218
+ tm.assert_extension_array_equal(result, expected)
219
+
220
+ # ensure we haven't mutated anything inplace
221
+ tm.assert_extension_array_equal(
222
+ a, pd.array([True, False, None], dtype="boolean")
223
+ )
224
+
225
+ @pytest.mark.parametrize("other", [True, False, pd.NA, [True, False, None] * 3])
226
+ def test_no_masked_assumptions(self, other, all_logical_operators):
227
+ # The logical operations should not assume that masked values are False!
228
+ a = pd.arrays.BooleanArray(
229
+ np.array([True, True, True, False, False, False, True, False, True]),
230
+ np.array([False] * 6 + [True, True, True]),
231
+ )
232
+ b = pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
233
+ if isinstance(other, list):
234
+ other = pd.array(other, dtype="boolean")
235
+
236
+ result = getattr(a, all_logical_operators)(other)
237
+ expected = getattr(b, all_logical_operators)(other)
238
+ tm.assert_extension_array_equal(result, expected)
239
+
240
+ if isinstance(other, BooleanArray):
241
+ other._data[other._mask] = True
242
+ a._data[a._mask] = False
243
+
244
+ result = getattr(a, all_logical_operators)(other)
245
+ expected = getattr(b, all_logical_operators)(other)
246
+ tm.assert_extension_array_equal(result, expected)
247
+
248
+
249
+ @pytest.mark.parametrize("operation", [kleene_or, kleene_xor, kleene_and])
250
+ def test_error_both_scalar(operation):
251
+ msg = r"Either `left` or `right` need to be a np\.ndarray."
252
+ with pytest.raises(TypeError, match=msg):
253
+ # masks need to be non-None, otherwise it ends up in an infinite recursion
254
+ operation(True, True, np.zeros(1), np.zeros(1))
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_ops.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import pandas._testing as tm
3
+
4
+
5
+ class TestUnaryOps:
6
+ def test_invert(self):
7
+ a = pd.array([True, False, None], dtype="boolean")
8
+ expected = pd.array([False, True, None], dtype="boolean")
9
+ tm.assert_extension_array_equal(~a, expected)
10
+
11
+ expected = pd.Series(expected, index=["a", "b", "c"], name="name")
12
+ result = ~pd.Series(a, index=["a", "b", "c"], name="name")
13
+ tm.assert_series_equal(result, expected)
14
+
15
+ df = pd.DataFrame({"A": a, "B": [True, False, False]}, index=["a", "b", "c"])
16
+ result = ~df
17
+ expected = pd.DataFrame(
18
+ {"A": expected, "B": [False, True, True]}, index=["a", "b", "c"]
19
+ )
20
+ tm.assert_frame_equal(result, expected)
21
+
22
+ def test_abs(self):
23
+ # matching numpy behavior, abs is the identity function
24
+ arr = pd.array([True, False, None], dtype="boolean")
25
+ result = abs(arr)
26
+
27
+ tm.assert_extension_array_equal(result, arr)
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_reduction.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+
6
+
7
+ @pytest.fixture
8
+ def data():
9
+ """Fixture returning boolean array, with valid and missing values."""
10
+ return pd.array(
11
+ [True, False] * 4 + [np.nan] + [True, False] * 44 + [np.nan] + [True, False],
12
+ dtype="boolean",
13
+ )
14
+
15
+
16
+ @pytest.mark.parametrize(
17
+ "values, exp_any, exp_all, exp_any_noskip, exp_all_noskip",
18
+ [
19
+ ([True, pd.NA], True, True, True, pd.NA),
20
+ ([False, pd.NA], False, False, pd.NA, False),
21
+ ([pd.NA], False, True, pd.NA, pd.NA),
22
+ ([], False, True, False, True),
23
+ # GH-33253: all True / all False values buggy with skipna=False
24
+ ([True, True], True, True, True, True),
25
+ ([False, False], False, False, False, False),
26
+ ],
27
+ )
28
+ def test_any_all(values, exp_any, exp_all, exp_any_noskip, exp_all_noskip):
29
+ # the methods return numpy scalars
30
+ exp_any = pd.NA if exp_any is pd.NA else np.bool_(exp_any)
31
+ exp_all = pd.NA if exp_all is pd.NA else np.bool_(exp_all)
32
+ exp_any_noskip = pd.NA if exp_any_noskip is pd.NA else np.bool_(exp_any_noskip)
33
+ exp_all_noskip = pd.NA if exp_all_noskip is pd.NA else np.bool_(exp_all_noskip)
34
+
35
+ for con in [pd.array, pd.Series]:
36
+ a = con(values, dtype="boolean")
37
+ assert a.any() is exp_any
38
+ assert a.all() is exp_all
39
+ assert a.any(skipna=False) is exp_any_noskip
40
+ assert a.all(skipna=False) is exp_all_noskip
41
+
42
+ assert np.any(a.any()) is exp_any
43
+ assert np.all(a.all()) is exp_all
44
+
45
+
46
+ @pytest.mark.parametrize("dropna", [True, False])
47
+ def test_reductions_return_types(dropna, data, all_numeric_reductions):
48
+ op = all_numeric_reductions
49
+ s = pd.Series(data)
50
+ if dropna:
51
+ s = s.dropna()
52
+
53
+ if op in ("sum", "prod"):
54
+ assert isinstance(getattr(s, op)(), np.int_)
55
+ elif op == "count":
56
+ # Oddly on the 32 bit build (but not Windows), this is intc (!= intp)
57
+ assert isinstance(getattr(s, op)(), np.integer)
58
+ elif op in ("min", "max"):
59
+ assert isinstance(getattr(s, op)(), np.bool_)
60
+ else:
61
+ # "mean", "std", "var", "median", "kurt", "skew"
62
+ assert isinstance(getattr(s, op)(), np.float64)
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/boolean/test_repr.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+
3
+
4
+ def test_repr():
5
+ df = pd.DataFrame({"A": pd.array([True, False, None], dtype="boolean")})
6
+ expected = " A\n0 True\n1 False\n2 <NA>"
7
+ assert repr(df) == expected
8
+
9
+ expected = "0 True\n1 False\n2 <NA>\nName: A, dtype: boolean"
10
+ assert repr(df.A) == expected
11
+
12
+ expected = "<BooleanArray>\n[True, False, <NA>]\nLength: 3, dtype: boolean"
13
+ assert repr(df.A.array) == expected
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__init__.py ADDED
File without changes
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (210 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/conftest.cpython-312.pyc ADDED
Binary file (853 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/test_algos.cpython-312.pyc ADDED
Binary file (5.38 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/pandas/tests/arrays/categorical/__pycache__/test_analytics.cpython-312.pyc ADDED
Binary file (20.6 kB). View file