ZTWHHH commited on
Commit
261779a
·
verified ·
1 Parent(s): a86708f

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 +4 -0
  2. videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/nattype.cpython-310-x86_64-linux-gnu.so +3 -0
  3. videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/period.cpython-310-x86_64-linux-gnu.so +3 -0
  4. videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/timedeltas.cpython-310-x86_64-linux-gnu.so +3 -0
  5. videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/timestamps.cpython-310-x86_64-linux-gnu.so +3 -0
  6. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/__init__.cpython-310.pyc +0 -0
  7. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/masked_shared.cpython-310.pyc +0 -0
  8. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_array.cpython-310.pyc +0 -0
  9. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimelike.cpython-310.pyc +0 -0
  10. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimes.cpython-310.pyc +0 -0
  11. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_ndarray_backed.cpython-310.pyc +0 -0
  12. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_period.cpython-310.pyc +0 -0
  13. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_timedeltas.cpython-310.pyc +0 -0
  14. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/__init__.py +0 -0
  15. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/test_constructors.py +170 -0
  16. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/test_cumulative.py +46 -0
  17. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/test_reductions.py +183 -0
  18. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/__init__.cpython-310.pyc +0 -0
  19. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/conftest.cpython-310.pyc +0 -0
  20. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_comparison.cpython-310.pyc +0 -0
  21. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_concat.cpython-310.pyc +0 -0
  22. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_construction.cpython-310.pyc +0 -0
  23. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_dtypes.cpython-310.pyc +0 -0
  24. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_indexing.cpython-310.pyc +0 -0
  25. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__init__.py +0 -0
  26. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/__init__.cpython-310.pyc +0 -0
  27. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arithmetic.cpython-310.pyc +0 -0
  28. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arrow_compat.cpython-310.pyc +0 -0
  29. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_function.cpython-310.pyc +0 -0
  30. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_indexing.cpython-310.pyc +0 -0
  31. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_arithmetic.py +248 -0
  32. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_arrow_compat.py +195 -0
  33. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_function.py +57 -0
  34. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_indexing.py +60 -0
  35. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__init__.py +0 -0
  36. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/__init__.cpython-310.pyc +0 -0
  37. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_indexing.cpython-310.pyc +0 -0
  38. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_numpy.cpython-310.pyc +0 -0
  39. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/test_indexing.py +41 -0
  40. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/test_numpy.py +324 -0
  41. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__init__.py +0 -0
  42. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/__init__.cpython-310.pyc +0 -0
  43. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_arrow_compat.cpython-310.pyc +0 -0
  44. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_astype.cpython-310.pyc +0 -0
  45. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_constructors.cpython-310.pyc +0 -0
  46. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_reductions.cpython-310.pyc +0 -0
  47. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_arrow_compat.py +124 -0
  48. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_astype.py +67 -0
  49. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_constructors.py +123 -0
  50. videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_reductions.py +42 -0
.gitattributes CHANGED
@@ -1262,3 +1262,7 @@ videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/parsing.cpython-310-
1262
  videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/tzconversion.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1263
  videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/dtypes.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1264
  videochat2/bin/python3.1 filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
1262
  videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/tzconversion.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1263
  videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/dtypes.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1264
  videochat2/bin/python3.1 filter=lfs diff=lfs merge=lfs -text
1265
+ videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/timedeltas.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1266
+ videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/nattype.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1267
+ videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/timestamps.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1268
+ videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/period.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/nattype.cpython-310-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ccf1c237f74113fe9e565bc3d85d003faa1100e8d576c5e280d79e814db22cc
3
+ size 203488
videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/period.cpython-310-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d2919145926039b690a5a33da3aa2ac929290eaf03ef00e2796d0daec8db4ba
3
+ size 466568
videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/timedeltas.cpython-310-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5f9cec08991aeefb285df3cda3889d29e2aecad622185c023e2d303535ca2ee
3
+ size 589160
videochat2/lib/python3.10/site-packages/pandas/_libs/tslibs/timestamps.cpython-310-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6568e1b7a044569a320a3a68cf6ec2a2c2bb3661eb5f87ce1df14c047f4610e
3
+ size 584232
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (175 Bytes). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/masked_shared.cpython-310.pyc ADDED
Binary file (4.32 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_array.cpython-310.pyc ADDED
Binary file (8.82 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimelike.cpython-310.pyc ADDED
Binary file (36.7 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimes.cpython-310.pyc ADDED
Binary file (22 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_ndarray_backed.cpython-310.pyc ADDED
Binary file (2.28 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_period.cpython-310.pyc ADDED
Binary file (5.58 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_timedeltas.cpython-310.pyc ADDED
Binary file (9.93 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/__init__.py ADDED
File without changes
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/test_constructors.py ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from pandas.core.dtypes.dtypes import DatetimeTZDtype
5
+
6
+ import pandas as pd
7
+ import pandas._testing as tm
8
+ from pandas.core.arrays import DatetimeArray
9
+ from pandas.core.arrays.datetimes import _sequence_to_dt64ns
10
+
11
+
12
+ class TestDatetimeArrayConstructor:
13
+ def test_from_sequence_invalid_type(self):
14
+ mi = pd.MultiIndex.from_product([np.arange(5), np.arange(5)])
15
+ with pytest.raises(TypeError, match="Cannot create a DatetimeArray"):
16
+ DatetimeArray._from_sequence(mi)
17
+
18
+ def test_only_1dim_accepted(self):
19
+ arr = np.array([0, 1, 2, 3], dtype="M8[h]").astype("M8[ns]")
20
+
21
+ with pytest.raises(ValueError, match="Only 1-dimensional"):
22
+ # 3-dim, we allow 2D to sneak in for ops purposes GH#29853
23
+ DatetimeArray(arr.reshape(2, 2, 1))
24
+
25
+ with pytest.raises(ValueError, match="Only 1-dimensional"):
26
+ # 0-dim
27
+ DatetimeArray(arr[[0]].squeeze())
28
+
29
+ def test_freq_validation(self):
30
+ # GH#24623 check that invalid instances cannot be created with the
31
+ # public constructor
32
+ arr = np.arange(5, dtype=np.int64) * 3600 * 10**9
33
+
34
+ msg = (
35
+ "Inferred frequency H from passed values does not "
36
+ "conform to passed frequency W-SUN"
37
+ )
38
+ with pytest.raises(ValueError, match=msg):
39
+ DatetimeArray(arr, freq="W")
40
+
41
+ @pytest.mark.parametrize(
42
+ "meth",
43
+ [
44
+ DatetimeArray._from_sequence,
45
+ _sequence_to_dt64ns,
46
+ pd.to_datetime,
47
+ pd.DatetimeIndex,
48
+ ],
49
+ )
50
+ def test_mixing_naive_tzaware_raises(self, meth):
51
+ # GH#24569
52
+ arr = np.array([pd.Timestamp("2000"), pd.Timestamp("2000", tz="CET")])
53
+
54
+ msg = (
55
+ "Cannot mix tz-aware with tz-naive values|"
56
+ "Tz-aware datetime.datetime cannot be converted "
57
+ "to datetime64 unless utc=True"
58
+ )
59
+
60
+ for obj in [arr, arr[::-1]]:
61
+ # check that we raise regardless of whether naive is found
62
+ # before aware or vice-versa
63
+ with pytest.raises(ValueError, match=msg):
64
+ meth(obj)
65
+
66
+ def test_from_pandas_array(self):
67
+ arr = pd.array(np.arange(5, dtype=np.int64)) * 3600 * 10**9
68
+
69
+ result = DatetimeArray._from_sequence(arr)._with_freq("infer")
70
+
71
+ expected = pd.date_range("1970-01-01", periods=5, freq="H")._data
72
+ tm.assert_datetime_array_equal(result, expected)
73
+
74
+ def test_mismatched_timezone_raises(self):
75
+ arr = DatetimeArray(
76
+ np.array(["2000-01-01T06:00:00"], dtype="M8[ns]"),
77
+ dtype=DatetimeTZDtype(tz="US/Central"),
78
+ )
79
+ dtype = DatetimeTZDtype(tz="US/Eastern")
80
+ msg = r"dtype=datetime64\[ns.*\] does not match data dtype datetime64\[ns.*\]"
81
+ with pytest.raises(TypeError, match=msg):
82
+ DatetimeArray(arr, dtype=dtype)
83
+
84
+ # also with mismatched tzawareness
85
+ with pytest.raises(TypeError, match=msg):
86
+ DatetimeArray(arr, dtype=np.dtype("M8[ns]"))
87
+ with pytest.raises(TypeError, match=msg):
88
+ DatetimeArray(arr.tz_localize(None), dtype=arr.dtype)
89
+
90
+ def test_non_array_raises(self):
91
+ with pytest.raises(ValueError, match="list"):
92
+ DatetimeArray([1, 2, 3])
93
+
94
+ def test_bool_dtype_raises(self):
95
+ arr = np.array([1, 2, 3], dtype="bool")
96
+
97
+ msg = "Unexpected value for 'dtype': 'bool'. Must be"
98
+ with pytest.raises(ValueError, match=msg):
99
+ DatetimeArray(arr)
100
+
101
+ msg = r"dtype bool cannot be converted to datetime64\[ns\]"
102
+ with pytest.raises(TypeError, match=msg):
103
+ DatetimeArray._from_sequence(arr)
104
+
105
+ with pytest.raises(TypeError, match=msg):
106
+ _sequence_to_dt64ns(arr)
107
+
108
+ with pytest.raises(TypeError, match=msg):
109
+ pd.DatetimeIndex(arr)
110
+
111
+ with pytest.raises(TypeError, match=msg):
112
+ pd.to_datetime(arr)
113
+
114
+ def test_incorrect_dtype_raises(self):
115
+ with pytest.raises(ValueError, match="Unexpected value for 'dtype'."):
116
+ DatetimeArray(np.array([1, 2, 3], dtype="i8"), dtype="category")
117
+
118
+ def test_freq_infer_raises(self):
119
+ with pytest.raises(ValueError, match="Frequency inference"):
120
+ DatetimeArray(np.array([1, 2, 3], dtype="i8"), freq="infer")
121
+
122
+ def test_copy(self):
123
+ data = np.array([1, 2, 3], dtype="M8[ns]")
124
+ arr = DatetimeArray(data, copy=False)
125
+ assert arr._ndarray is data
126
+
127
+ arr = DatetimeArray(data, copy=True)
128
+ assert arr._ndarray is not data
129
+
130
+ @pytest.mark.parametrize("unit", ["s", "ms", "us", "ns"])
131
+ def test_numpy_datetime_unit(self, unit):
132
+ data = np.array([1, 2, 3], dtype=f"M8[{unit}]")
133
+ arr = DatetimeArray(data)
134
+ assert arr.unit == unit
135
+ assert arr[0].unit == unit
136
+
137
+
138
+ class TestSequenceToDT64NS:
139
+ def test_tz_dtype_mismatch_raises(self):
140
+ arr = DatetimeArray._from_sequence(
141
+ ["2000"], dtype=DatetimeTZDtype(tz="US/Central")
142
+ )
143
+ with pytest.raises(TypeError, match="data is already tz-aware"):
144
+ DatetimeArray._from_sequence_not_strict(
145
+ arr, dtype=DatetimeTZDtype(tz="UTC")
146
+ )
147
+
148
+ def test_tz_dtype_matches(self):
149
+ dtype = DatetimeTZDtype(tz="US/Central")
150
+ arr = DatetimeArray._from_sequence(["2000"], dtype=dtype)
151
+ result = DatetimeArray._from_sequence_not_strict(arr, dtype=dtype)
152
+ tm.assert_equal(arr, result)
153
+
154
+ @pytest.mark.parametrize("order", ["F", "C"])
155
+ def test_2d(self, order):
156
+ dti = pd.date_range("2016-01-01", periods=6, tz="US/Pacific")
157
+ arr = np.array(dti, dtype=object).reshape(3, 2)
158
+ if order == "F":
159
+ arr = arr.T
160
+
161
+ res = _sequence_to_dt64ns(arr)
162
+ expected = _sequence_to_dt64ns(arr.ravel())
163
+
164
+ tm.assert_numpy_array_equal(res[0].ravel(), expected[0])
165
+ assert res[1] == expected[1]
166
+ assert res[2] == expected[2]
167
+
168
+ res = DatetimeArray._from_sequence(arr)
169
+ expected = DatetimeArray._from_sequence(arr.ravel()).reshape(arr.shape)
170
+ tm.assert_datetime_array_equal(res, expected)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/test_cumulative.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ import pandas._testing as tm
4
+ from pandas.core.arrays import DatetimeArray
5
+
6
+
7
+ class TestAccumulator:
8
+ def test_accumulators_freq(self):
9
+ # GH#50297
10
+ arr = DatetimeArray._from_sequence_not_strict(
11
+ [
12
+ "2000-01-01",
13
+ "2000-01-02",
14
+ "2000-01-03",
15
+ ],
16
+ freq="D",
17
+ )
18
+ result = arr._accumulate("cummin")
19
+ expected = DatetimeArray._from_sequence_not_strict(
20
+ ["2000-01-01"] * 3, freq=None
21
+ )
22
+ tm.assert_datetime_array_equal(result, expected)
23
+
24
+ result = arr._accumulate("cummax")
25
+ expected = DatetimeArray._from_sequence_not_strict(
26
+ [
27
+ "2000-01-01",
28
+ "2000-01-02",
29
+ "2000-01-03",
30
+ ],
31
+ freq=None,
32
+ )
33
+ tm.assert_datetime_array_equal(result, expected)
34
+
35
+ @pytest.mark.parametrize("func", ["cumsum", "cumprod"])
36
+ def test_accumulators_disallowed(self, func):
37
+ # GH#50297
38
+ arr = DatetimeArray._from_sequence_not_strict(
39
+ [
40
+ "2000-01-01",
41
+ "2000-01-02",
42
+ ],
43
+ freq="D",
44
+ )
45
+ with pytest.raises(TypeError, match=f"Accumulation {func}"):
46
+ arr._accumulate(func)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/datetimes/test_reductions.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from pandas.core.dtypes.dtypes import DatetimeTZDtype
5
+
6
+ import pandas as pd
7
+ from pandas import NaT
8
+ import pandas._testing as tm
9
+ from pandas.core.arrays import DatetimeArray
10
+
11
+
12
+ class TestReductions:
13
+ @pytest.fixture(params=["s", "ms", "us", "ns"])
14
+ def unit(self, request):
15
+ return request.param
16
+
17
+ @pytest.fixture
18
+ def arr1d(self, tz_naive_fixture):
19
+ """Fixture returning DatetimeArray with parametrized timezones"""
20
+ tz = tz_naive_fixture
21
+ dtype = DatetimeTZDtype(tz=tz) if tz is not None else np.dtype("M8[ns]")
22
+ arr = DatetimeArray._from_sequence(
23
+ [
24
+ "2000-01-03",
25
+ "2000-01-03",
26
+ "NaT",
27
+ "2000-01-02",
28
+ "2000-01-05",
29
+ "2000-01-04",
30
+ ],
31
+ dtype=dtype,
32
+ )
33
+ return arr
34
+
35
+ def test_min_max(self, arr1d, unit):
36
+ arr = arr1d
37
+ arr = arr.as_unit(unit)
38
+ tz = arr.tz
39
+
40
+ result = arr.min()
41
+ expected = pd.Timestamp("2000-01-02", tz=tz).as_unit(unit)
42
+ assert result == expected
43
+ assert result.unit == expected.unit
44
+
45
+ result = arr.max()
46
+ expected = pd.Timestamp("2000-01-05", tz=tz).as_unit(unit)
47
+ assert result == expected
48
+ assert result.unit == expected.unit
49
+
50
+ result = arr.min(skipna=False)
51
+ assert result is NaT
52
+
53
+ result = arr.max(skipna=False)
54
+ assert result is NaT
55
+
56
+ @pytest.mark.parametrize("tz", [None, "US/Central"])
57
+ @pytest.mark.parametrize("skipna", [True, False])
58
+ def test_min_max_empty(self, skipna, tz):
59
+ dtype = DatetimeTZDtype(tz=tz) if tz is not None else np.dtype("M8[ns]")
60
+ arr = DatetimeArray._from_sequence([], dtype=dtype)
61
+ result = arr.min(skipna=skipna)
62
+ assert result is NaT
63
+
64
+ result = arr.max(skipna=skipna)
65
+ assert result is NaT
66
+
67
+ @pytest.mark.parametrize("tz", [None, "US/Central"])
68
+ @pytest.mark.parametrize("skipna", [True, False])
69
+ def test_median_empty(self, skipna, tz):
70
+ dtype = DatetimeTZDtype(tz=tz) if tz is not None else np.dtype("M8[ns]")
71
+ arr = DatetimeArray._from_sequence([], dtype=dtype)
72
+ result = arr.median(skipna=skipna)
73
+ assert result is NaT
74
+
75
+ arr = arr.reshape(0, 3)
76
+ result = arr.median(axis=0, skipna=skipna)
77
+ expected = type(arr)._from_sequence([NaT, NaT, NaT], dtype=arr.dtype)
78
+ tm.assert_equal(result, expected)
79
+
80
+ result = arr.median(axis=1, skipna=skipna)
81
+ expected = type(arr)._from_sequence([], dtype=arr.dtype)
82
+ tm.assert_equal(result, expected)
83
+
84
+ def test_median(self, arr1d):
85
+ arr = arr1d
86
+
87
+ result = arr.median()
88
+ assert result == arr[0]
89
+ result = arr.median(skipna=False)
90
+ assert result is NaT
91
+
92
+ result = arr.dropna().median(skipna=False)
93
+ assert result == arr[0]
94
+
95
+ result = arr.median(axis=0)
96
+ assert result == arr[0]
97
+
98
+ def test_median_axis(self, arr1d):
99
+ arr = arr1d
100
+ assert arr.median(axis=0) == arr.median()
101
+ assert arr.median(axis=0, skipna=False) is NaT
102
+
103
+ msg = r"abs\(axis\) must be less than ndim"
104
+ with pytest.raises(ValueError, match=msg):
105
+ arr.median(axis=1)
106
+
107
+ @pytest.mark.filterwarnings("ignore:All-NaN slice encountered:RuntimeWarning")
108
+ def test_median_2d(self, arr1d):
109
+ arr = arr1d.reshape(1, -1)
110
+
111
+ # axis = None
112
+ assert arr.median() == arr1d.median()
113
+ assert arr.median(skipna=False) is NaT
114
+
115
+ # axis = 0
116
+ result = arr.median(axis=0)
117
+ expected = arr1d
118
+ tm.assert_equal(result, expected)
119
+
120
+ # Since column 3 is all-NaT, we get NaT there with or without skipna
121
+ result = arr.median(axis=0, skipna=False)
122
+ expected = arr1d
123
+ tm.assert_equal(result, expected)
124
+
125
+ # axis = 1
126
+ result = arr.median(axis=1)
127
+ expected = type(arr)._from_sequence([arr1d.median()])
128
+ tm.assert_equal(result, expected)
129
+
130
+ result = arr.median(axis=1, skipna=False)
131
+ expected = type(arr)._from_sequence([NaT], dtype=arr.dtype)
132
+ tm.assert_equal(result, expected)
133
+
134
+ def test_mean(self, arr1d):
135
+ arr = arr1d
136
+
137
+ # manually verified result
138
+ expected = arr[0] + 0.4 * pd.Timedelta(days=1)
139
+
140
+ result = arr.mean()
141
+ assert result == expected
142
+ result = arr.mean(skipna=False)
143
+ assert result is NaT
144
+
145
+ result = arr.dropna().mean(skipna=False)
146
+ assert result == expected
147
+
148
+ result = arr.mean(axis=0)
149
+ assert result == expected
150
+
151
+ def test_mean_2d(self):
152
+ dti = pd.date_range("2016-01-01", periods=6, tz="US/Pacific")
153
+ dta = dti._data.reshape(3, 2)
154
+
155
+ result = dta.mean(axis=0)
156
+ expected = dta[1]
157
+ tm.assert_datetime_array_equal(result, expected)
158
+
159
+ result = dta.mean(axis=1)
160
+ expected = dta[:, 0] + pd.Timedelta(hours=12)
161
+ tm.assert_datetime_array_equal(result, expected)
162
+
163
+ result = dta.mean(axis=None)
164
+ expected = dti.mean()
165
+ assert result == expected
166
+
167
+ @pytest.mark.parametrize("skipna", [True, False])
168
+ def test_mean_empty(self, arr1d, skipna):
169
+ arr = arr1d[:0]
170
+
171
+ assert arr.mean(skipna=skipna) is NaT
172
+
173
+ arr2d = arr.reshape(0, 3)
174
+ result = arr2d.mean(axis=0, skipna=skipna)
175
+ expected = DatetimeArray._from_sequence([NaT, NaT, NaT], dtype=arr.dtype)
176
+ tm.assert_datetime_array_equal(result, expected)
177
+
178
+ result = arr2d.mean(axis=1, skipna=skipna)
179
+ expected = arr # i.e. 1D, empty
180
+ tm.assert_datetime_array_equal(result, expected)
181
+
182
+ result = arr2d.mean(axis=None, skipna=skipna)
183
+ assert result is NaT
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (183 Bytes). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/conftest.cpython-310.pyc ADDED
Binary file (1.78 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_comparison.cpython-310.pyc ADDED
Binary file (1.43 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_concat.cpython-310.pyc ADDED
Binary file (1.83 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_construction.cpython-310.pyc ADDED
Binary file (6.53 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_dtypes.cpython-310.pyc ADDED
Binary file (7.17 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_indexing.cpython-310.pyc ADDED
Binary file (792 Bytes). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__init__.py ADDED
File without changes
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (182 Bytes). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arithmetic.cpython-310.pyc ADDED
Binary file (6.47 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arrow_compat.cpython-310.pyc ADDED
Binary file (5.95 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_function.cpython-310.pyc ADDED
Binary file (1.88 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_indexing.cpython-310.pyc ADDED
Binary file (2.06 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_arithmetic.py ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ import numpy as np
6
+ import pytest
7
+
8
+ import pandas as pd
9
+ import pandas._testing as tm
10
+
11
+ # integer dtypes
12
+ arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
13
+ scalars: list[Any] = [2] * len(arrays)
14
+ # floating dtypes
15
+ arrays += [pd.array([0.1, 0.2, 0.3, None], dtype=dtype) for dtype in tm.FLOAT_EA_DTYPES]
16
+ scalars += [0.2, 0.2]
17
+ # boolean
18
+ arrays += [pd.array([True, False, True, None], dtype="boolean")]
19
+ scalars += [False]
20
+
21
+
22
+ @pytest.fixture(params=zip(arrays, scalars), ids=[a.dtype.name for a in arrays])
23
+ def data(request):
24
+ """Fixture returning parametrized (array, scalar) tuple.
25
+
26
+ Used to test equivalence of scalars, numpy arrays with array ops, and the
27
+ equivalence of DataFrame and Series ops.
28
+ """
29
+ return request.param
30
+
31
+
32
+ def check_skip(data, op_name):
33
+ if isinstance(data.dtype, pd.BooleanDtype) and "sub" in op_name:
34
+ pytest.skip("subtract not implemented for boolean")
35
+
36
+
37
+ def is_bool_not_implemented(data, op_name):
38
+ # match non-masked behavior
39
+ return data.dtype.kind == "b" and op_name.strip("_").lstrip("r") in [
40
+ "pow",
41
+ "truediv",
42
+ "floordiv",
43
+ ]
44
+
45
+
46
+ # Test equivalence of scalars, numpy arrays with array ops
47
+ # -----------------------------------------------------------------------------
48
+
49
+
50
+ def test_array_scalar_like_equivalence(data, all_arithmetic_operators):
51
+ data, scalar = data
52
+ op = tm.get_op_from_name(all_arithmetic_operators)
53
+ check_skip(data, all_arithmetic_operators)
54
+
55
+ scalar_array = pd.array([scalar] * len(data), dtype=data.dtype)
56
+
57
+ # TODO also add len-1 array (np.array([scalar], dtype=data.dtype.numpy_dtype))
58
+ for scalar in [scalar, data.dtype.type(scalar)]:
59
+ if is_bool_not_implemented(data, all_arithmetic_operators):
60
+ msg = "operator '.*' not implemented for bool dtypes"
61
+ with pytest.raises(NotImplementedError, match=msg):
62
+ op(data, scalar)
63
+ with pytest.raises(NotImplementedError, match=msg):
64
+ op(data, scalar_array)
65
+ else:
66
+ result = op(data, scalar)
67
+ expected = op(data, scalar_array)
68
+ tm.assert_extension_array_equal(result, expected)
69
+
70
+
71
+ def test_array_NA(data, all_arithmetic_operators):
72
+ data, _ = data
73
+ op = tm.get_op_from_name(all_arithmetic_operators)
74
+ check_skip(data, all_arithmetic_operators)
75
+
76
+ scalar = pd.NA
77
+ scalar_array = pd.array([pd.NA] * len(data), dtype=data.dtype)
78
+
79
+ mask = data._mask.copy()
80
+
81
+ if is_bool_not_implemented(data, all_arithmetic_operators):
82
+ msg = "operator '.*' not implemented for bool dtypes"
83
+ with pytest.raises(NotImplementedError, match=msg):
84
+ op(data, scalar)
85
+ # GH#45421 check op doesn't alter data._mask inplace
86
+ tm.assert_numpy_array_equal(mask, data._mask)
87
+ return
88
+
89
+ result = op(data, scalar)
90
+ # GH#45421 check op doesn't alter data._mask inplace
91
+ tm.assert_numpy_array_equal(mask, data._mask)
92
+
93
+ expected = op(data, scalar_array)
94
+ tm.assert_numpy_array_equal(mask, data._mask)
95
+
96
+ tm.assert_extension_array_equal(result, expected)
97
+
98
+
99
+ def test_numpy_array_equivalence(data, all_arithmetic_operators):
100
+ data, scalar = data
101
+ op = tm.get_op_from_name(all_arithmetic_operators)
102
+ check_skip(data, all_arithmetic_operators)
103
+
104
+ numpy_array = np.array([scalar] * len(data), dtype=data.dtype.numpy_dtype)
105
+ pd_array = pd.array(numpy_array, dtype=data.dtype)
106
+
107
+ if is_bool_not_implemented(data, all_arithmetic_operators):
108
+ msg = "operator '.*' not implemented for bool dtypes"
109
+ with pytest.raises(NotImplementedError, match=msg):
110
+ op(data, numpy_array)
111
+ with pytest.raises(NotImplementedError, match=msg):
112
+ op(data, pd_array)
113
+ return
114
+
115
+ result = op(data, numpy_array)
116
+ expected = op(data, pd_array)
117
+ tm.assert_extension_array_equal(result, expected)
118
+
119
+
120
+ # Test equivalence with Series and DataFrame ops
121
+ # -----------------------------------------------------------------------------
122
+
123
+
124
+ def test_frame(data, all_arithmetic_operators):
125
+ data, scalar = data
126
+ op = tm.get_op_from_name(all_arithmetic_operators)
127
+ check_skip(data, all_arithmetic_operators)
128
+
129
+ # DataFrame with scalar
130
+ df = pd.DataFrame({"A": data})
131
+
132
+ if is_bool_not_implemented(data, all_arithmetic_operators):
133
+ msg = "operator '.*' not implemented for bool dtypes"
134
+ with pytest.raises(NotImplementedError, match=msg):
135
+ op(df, scalar)
136
+ with pytest.raises(NotImplementedError, match=msg):
137
+ op(data, scalar)
138
+ return
139
+
140
+ result = op(df, scalar)
141
+ expected = pd.DataFrame({"A": op(data, scalar)})
142
+ tm.assert_frame_equal(result, expected)
143
+
144
+
145
+ def test_series(data, all_arithmetic_operators):
146
+ data, scalar = data
147
+ op = tm.get_op_from_name(all_arithmetic_operators)
148
+ check_skip(data, all_arithmetic_operators)
149
+
150
+ ser = pd.Series(data)
151
+
152
+ others = [
153
+ scalar,
154
+ np.array([scalar] * len(data), dtype=data.dtype.numpy_dtype),
155
+ pd.array([scalar] * len(data), dtype=data.dtype),
156
+ pd.Series([scalar] * len(data), dtype=data.dtype),
157
+ ]
158
+
159
+ for other in others:
160
+ if is_bool_not_implemented(data, all_arithmetic_operators):
161
+ msg = "operator '.*' not implemented for bool dtypes"
162
+ with pytest.raises(NotImplementedError, match=msg):
163
+ op(ser, other)
164
+
165
+ else:
166
+ result = op(ser, other)
167
+ expected = pd.Series(op(data, other))
168
+ tm.assert_series_equal(result, expected)
169
+
170
+
171
+ # Test generic characteristics / errors
172
+ # -----------------------------------------------------------------------------
173
+
174
+
175
+ def test_error_invalid_object(data, all_arithmetic_operators):
176
+ data, _ = data
177
+
178
+ op = all_arithmetic_operators
179
+ opa = getattr(data, op)
180
+
181
+ # 2d -> return NotImplemented
182
+ result = opa(pd.DataFrame({"A": data}))
183
+ assert result is NotImplemented
184
+
185
+ msg = r"can only perform ops with 1-d structures"
186
+ with pytest.raises(NotImplementedError, match=msg):
187
+ opa(np.arange(len(data)).reshape(-1, len(data)))
188
+
189
+
190
+ def test_error_len_mismatch(data, all_arithmetic_operators):
191
+ # operating with a list-like with non-matching length raises
192
+ data, scalar = data
193
+ op = tm.get_op_from_name(all_arithmetic_operators)
194
+
195
+ other = [scalar] * (len(data) - 1)
196
+
197
+ err = ValueError
198
+ msg = "|".join(
199
+ [
200
+ r"operands could not be broadcast together with shapes \(3,\) \(4,\)",
201
+ r"operands could not be broadcast together with shapes \(4,\) \(3,\)",
202
+ ]
203
+ )
204
+ if data.dtype.kind == "b" and all_arithmetic_operators.strip("_") in [
205
+ "sub",
206
+ "rsub",
207
+ ]:
208
+ err = TypeError
209
+ msg = (
210
+ r"numpy boolean subtract, the `\-` operator, is not supported, use "
211
+ r"the bitwise_xor, the `\^` operator, or the logical_xor function instead"
212
+ )
213
+ elif is_bool_not_implemented(data, all_arithmetic_operators):
214
+ msg = "operator '.*' not implemented for bool dtypes"
215
+ err = NotImplementedError
216
+
217
+ for other in [other, np.array(other)]:
218
+ with pytest.raises(err, match=msg):
219
+ op(data, other)
220
+
221
+ s = pd.Series(data)
222
+ with pytest.raises(err, match=msg):
223
+ op(s, other)
224
+
225
+
226
+ @pytest.mark.parametrize("op", ["__neg__", "__abs__", "__invert__"])
227
+ def test_unary_op_does_not_propagate_mask(data, op):
228
+ # https://github.com/pandas-dev/pandas/issues/39943
229
+ data, _ = data
230
+ ser = pd.Series(data)
231
+
232
+ if op == "__invert__" and data.dtype.kind == "f":
233
+ # we follow numpy in raising
234
+ msg = "ufunc 'invert' not supported for the input types"
235
+ with pytest.raises(TypeError, match=msg):
236
+ getattr(ser, op)()
237
+ with pytest.raises(TypeError, match=msg):
238
+ getattr(data, op)()
239
+ with pytest.raises(TypeError, match=msg):
240
+ # Check that this is still the numpy behavior
241
+ getattr(data._data, op)()
242
+
243
+ return
244
+
245
+ result = getattr(ser, op)()
246
+ expected = result.copy(deep=True)
247
+ ser[0] = None
248
+ tm.assert_series_equal(result, expected)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_arrow_compat.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+
7
+ pa = pytest.importorskip("pyarrow", minversion="1.0.1")
8
+
9
+ from pandas.core.arrays.arrow._arrow_utils import pyarrow_array_to_numpy_and_mask
10
+
11
+ arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
12
+ arrays += [pd.array([0.1, 0.2, 0.3, None], dtype=dtype) for dtype in tm.FLOAT_EA_DTYPES]
13
+ arrays += [pd.array([True, False, True, None], dtype="boolean")]
14
+
15
+
16
+ @pytest.fixture(params=arrays, ids=[a.dtype.name for a in arrays])
17
+ def data(request):
18
+ """
19
+ Fixture returning parametrized array from given dtype, including integer,
20
+ float and boolean
21
+ """
22
+ return request.param
23
+
24
+
25
+ def test_arrow_array(data):
26
+ arr = pa.array(data)
27
+ expected = pa.array(
28
+ data.to_numpy(object, na_value=None),
29
+ type=pa.from_numpy_dtype(data.dtype.numpy_dtype),
30
+ )
31
+ assert arr.equals(expected)
32
+
33
+
34
+ def test_arrow_roundtrip(data):
35
+ df = pd.DataFrame({"a": data})
36
+ table = pa.table(df)
37
+ assert table.field("a").type == str(data.dtype.numpy_dtype)
38
+ result = table.to_pandas()
39
+ assert result["a"].dtype == data.dtype
40
+ tm.assert_frame_equal(result, df)
41
+
42
+
43
+ def test_dataframe_from_arrow_types_mapper():
44
+ def types_mapper(arrow_type):
45
+ if pa.types.is_boolean(arrow_type):
46
+ return pd.BooleanDtype()
47
+ elif pa.types.is_integer(arrow_type):
48
+ return pd.Int64Dtype()
49
+
50
+ bools_array = pa.array([True, None, False], type=pa.bool_())
51
+ ints_array = pa.array([1, None, 2], type=pa.int64())
52
+ small_ints_array = pa.array([-1, 0, 7], type=pa.int8())
53
+ record_batch = pa.RecordBatch.from_arrays(
54
+ [bools_array, ints_array, small_ints_array], ["bools", "ints", "small_ints"]
55
+ )
56
+ result = record_batch.to_pandas(types_mapper=types_mapper)
57
+ bools = pd.Series([True, None, False], dtype="boolean")
58
+ ints = pd.Series([1, None, 2], dtype="Int64")
59
+ small_ints = pd.Series([-1, 0, 7], dtype="Int64")
60
+ expected = pd.DataFrame({"bools": bools, "ints": ints, "small_ints": small_ints})
61
+ tm.assert_frame_equal(result, expected)
62
+
63
+
64
+ def test_arrow_load_from_zero_chunks(data):
65
+ # GH-41040
66
+
67
+ df = pd.DataFrame({"a": data[0:0]})
68
+ table = pa.table(df)
69
+ assert table.field("a").type == str(data.dtype.numpy_dtype)
70
+ table = pa.table(
71
+ [pa.chunked_array([], type=table.field("a").type)], schema=table.schema
72
+ )
73
+ result = table.to_pandas()
74
+ assert result["a"].dtype == data.dtype
75
+ tm.assert_frame_equal(result, df)
76
+
77
+
78
+ def test_arrow_from_arrow_uint():
79
+ # https://github.com/pandas-dev/pandas/issues/31896
80
+ # possible mismatch in types
81
+
82
+ dtype = pd.UInt32Dtype()
83
+ result = dtype.__from_arrow__(pa.array([1, 2, 3, 4, None], type="int64"))
84
+ expected = pd.array([1, 2, 3, 4, None], dtype="UInt32")
85
+
86
+ tm.assert_extension_array_equal(result, expected)
87
+
88
+
89
+ def test_arrow_sliced(data):
90
+ # https://github.com/pandas-dev/pandas/issues/38525
91
+
92
+ df = pd.DataFrame({"a": data})
93
+ table = pa.table(df)
94
+ result = table.slice(2, None).to_pandas()
95
+ expected = df.iloc[2:].reset_index(drop=True)
96
+ tm.assert_frame_equal(result, expected)
97
+
98
+ # no missing values
99
+ df2 = df.fillna(data[0])
100
+ table = pa.table(df2)
101
+ result = table.slice(2, None).to_pandas()
102
+ expected = df2.iloc[2:].reset_index(drop=True)
103
+ tm.assert_frame_equal(result, expected)
104
+
105
+
106
+ @pytest.fixture
107
+ def np_dtype_to_arrays(any_real_numpy_dtype):
108
+ """
109
+ Fixture returning actual and expected dtype, pandas and numpy arrays and
110
+ mask from a given numpy dtype
111
+ """
112
+ np_dtype = np.dtype(any_real_numpy_dtype)
113
+ pa_type = pa.from_numpy_dtype(np_dtype)
114
+
115
+ # None ensures the creation of a bitmask buffer.
116
+ pa_array = pa.array([0, 1, 2, None], type=pa_type)
117
+ # Since masked Arrow buffer slots are not required to contain a specific
118
+ # value, assert only the first three values of the created np.array
119
+ np_expected = np.array([0, 1, 2], dtype=np_dtype)
120
+ mask_expected = np.array([True, True, True, False])
121
+ return np_dtype, pa_array, np_expected, mask_expected
122
+
123
+
124
+ def test_pyarrow_array_to_numpy_and_mask(np_dtype_to_arrays):
125
+ """
126
+ Test conversion from pyarrow array to numpy array.
127
+
128
+ Modifies the pyarrow buffer to contain padding and offset, which are
129
+ considered valid buffers by pyarrow.
130
+
131
+ Also tests empty pyarrow arrays with non empty buffers.
132
+ See https://github.com/pandas-dev/pandas/issues/40896
133
+ """
134
+ np_dtype, pa_array, np_expected, mask_expected = np_dtype_to_arrays
135
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array, np_dtype)
136
+ tm.assert_numpy_array_equal(data[:3], np_expected)
137
+ tm.assert_numpy_array_equal(mask, mask_expected)
138
+
139
+ mask_buffer = pa_array.buffers()[0]
140
+ data_buffer = pa_array.buffers()[1]
141
+ data_buffer_bytes = pa_array.buffers()[1].to_pybytes()
142
+
143
+ # Add trailing padding to the buffer.
144
+ data_buffer_trail = pa.py_buffer(data_buffer_bytes + b"\x00")
145
+ pa_array_trail = pa.Array.from_buffers(
146
+ type=pa_array.type,
147
+ length=len(pa_array),
148
+ buffers=[mask_buffer, data_buffer_trail],
149
+ offset=pa_array.offset,
150
+ )
151
+ pa_array_trail.validate()
152
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array_trail, np_dtype)
153
+ tm.assert_numpy_array_equal(data[:3], np_expected)
154
+ tm.assert_numpy_array_equal(mask, mask_expected)
155
+
156
+ # Add offset to the buffer.
157
+ offset = b"\x00" * (pa_array.type.bit_width // 8)
158
+ data_buffer_offset = pa.py_buffer(offset + data_buffer_bytes)
159
+ mask_buffer_offset = pa.py_buffer(b"\x0E")
160
+ pa_array_offset = pa.Array.from_buffers(
161
+ type=pa_array.type,
162
+ length=len(pa_array),
163
+ buffers=[mask_buffer_offset, data_buffer_offset],
164
+ offset=pa_array.offset + 1,
165
+ )
166
+ pa_array_offset.validate()
167
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array_offset, np_dtype)
168
+ tm.assert_numpy_array_equal(data[:3], np_expected)
169
+ tm.assert_numpy_array_equal(mask, mask_expected)
170
+
171
+ # Empty array
172
+ np_expected_empty = np.array([], dtype=np_dtype)
173
+ mask_expected_empty = np.array([], dtype=np.bool_)
174
+
175
+ pa_array_offset = pa.Array.from_buffers(
176
+ type=pa_array.type,
177
+ length=0,
178
+ buffers=[mask_buffer, data_buffer],
179
+ offset=pa_array.offset,
180
+ )
181
+ pa_array_offset.validate()
182
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array_offset, np_dtype)
183
+ tm.assert_numpy_array_equal(data[:3], np_expected_empty)
184
+ tm.assert_numpy_array_equal(mask, mask_expected_empty)
185
+
186
+
187
+ def test_from_arrow_type_error(data):
188
+ # ensure that __from_arrow__ returns a TypeError when getting a wrong
189
+ # array type
190
+
191
+ arr = pa.array(data).cast("string")
192
+ with pytest.raises(TypeError, match=None):
193
+ # we don't test the exact error message, only the fact that it raises
194
+ # a TypeError is relevant
195
+ data.dtype.__from_arrow__(arr)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_function.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from pandas.core.dtypes.common import is_integer_dtype
5
+
6
+ import pandas as pd
7
+ import pandas._testing as tm
8
+
9
+ arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
10
+ arrays += [
11
+ pd.array([0.141, -0.268, 5.895, None], dtype=dtype) for dtype in tm.FLOAT_EA_DTYPES
12
+ ]
13
+
14
+
15
+ @pytest.fixture(params=arrays, ids=[a.dtype.name for a in arrays])
16
+ def data(request):
17
+ """
18
+ Fixture returning parametrized 'data' array with different integer and
19
+ floating point types
20
+ """
21
+ return request.param
22
+
23
+
24
+ @pytest.fixture()
25
+ def numpy_dtype(data):
26
+ """
27
+ Fixture returning numpy dtype from 'data' input array.
28
+ """
29
+ # For integer dtype, the numpy conversion must be done to float
30
+ if is_integer_dtype(data):
31
+ numpy_dtype = float
32
+ else:
33
+ numpy_dtype = data.dtype.type
34
+ return numpy_dtype
35
+
36
+
37
+ def test_round(data, numpy_dtype):
38
+ # No arguments
39
+ result = data.round()
40
+ expected = pd.array(
41
+ np.round(data.to_numpy(dtype=numpy_dtype, na_value=None)), dtype=data.dtype
42
+ )
43
+ tm.assert_extension_array_equal(result, expected)
44
+
45
+ # Decimals argument
46
+ result = data.round(decimals=2)
47
+ expected = pd.array(
48
+ np.round(data.to_numpy(dtype=numpy_dtype, na_value=None), decimals=2),
49
+ dtype=data.dtype,
50
+ )
51
+ tm.assert_extension_array_equal(result, expected)
52
+
53
+
54
+ def test_tolist(data):
55
+ result = data.tolist()
56
+ expected = list(data)
57
+ tm.assert_equal(result, expected)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_indexing.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ import numpy as np
4
+ import pytest
5
+
6
+ import pandas as pd
7
+
8
+
9
+ class TestSetitemValidation:
10
+ def _check_setitem_invalid(self, arr, invalid):
11
+ msg = f"Invalid value '{str(invalid)}' for dtype {arr.dtype}"
12
+ msg = re.escape(msg)
13
+ with pytest.raises(TypeError, match=msg):
14
+ arr[0] = invalid
15
+
16
+ with pytest.raises(TypeError, match=msg):
17
+ arr[:] = invalid
18
+
19
+ with pytest.raises(TypeError, match=msg):
20
+ arr[[0]] = invalid
21
+
22
+ # FIXME: don't leave commented-out
23
+ # with pytest.raises(TypeError):
24
+ # arr[[0]] = [invalid]
25
+
26
+ # with pytest.raises(TypeError):
27
+ # arr[[0]] = np.array([invalid], dtype=object)
28
+
29
+ # Series non-coercion, behavior subject to change
30
+ ser = pd.Series(arr)
31
+ with pytest.raises(TypeError, match=msg):
32
+ ser[0] = invalid
33
+ # TODO: so, so many other variants of this...
34
+
35
+ _invalid_scalars = [
36
+ 1 + 2j,
37
+ "True",
38
+ "1",
39
+ "1.0",
40
+ pd.NaT,
41
+ np.datetime64("NaT"),
42
+ np.timedelta64("NaT"),
43
+ ]
44
+
45
+ @pytest.mark.parametrize(
46
+ "invalid", _invalid_scalars + [1, 1.0, np.int64(1), np.float64(1)]
47
+ )
48
+ def test_setitem_validation_scalar_bool(self, invalid):
49
+ arr = pd.array([True, False, None], dtype="boolean")
50
+ self._check_setitem_invalid(arr, invalid)
51
+
52
+ @pytest.mark.parametrize("invalid", _invalid_scalars + [True, 1.5, np.float64(1.5)])
53
+ def test_setitem_validation_scalar_int(self, invalid, any_int_ea_dtype):
54
+ arr = pd.array([1, 2, None], dtype=any_int_ea_dtype)
55
+ self._check_setitem_invalid(arr, invalid)
56
+
57
+ @pytest.mark.parametrize("invalid", _invalid_scalars + [True])
58
+ def test_setitem_validation_scalar_float(self, invalid, float_ea_dtype):
59
+ arr = pd.array([1, 2, None], dtype=float_ea_dtype)
60
+ self._check_setitem_invalid(arr, invalid)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__init__.py ADDED
File without changes
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (182 Bytes). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_indexing.cpython-310.pyc ADDED
Binary file (1.94 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_numpy.cpython-310.pyc ADDED
Binary file (8.2 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/test_indexing.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ from pandas.core.dtypes.common import is_scalar
4
+
5
+ import pandas as pd
6
+ import pandas._testing as tm
7
+
8
+
9
+ class TestSearchsorted:
10
+ def test_searchsorted_string(self, string_dtype):
11
+ arr = pd.array(["a", "b", "c"], dtype=string_dtype)
12
+
13
+ result = arr.searchsorted("a", side="left")
14
+ assert is_scalar(result)
15
+ assert result == 0
16
+
17
+ result = arr.searchsorted("a", side="right")
18
+ assert is_scalar(result)
19
+ assert result == 1
20
+
21
+ def test_searchsorted_numeric_dtypes_scalar(self, any_real_numpy_dtype):
22
+ arr = pd.array([1, 3, 90], dtype=any_real_numpy_dtype)
23
+ result = arr.searchsorted(30)
24
+ assert is_scalar(result)
25
+ assert result == 2
26
+
27
+ result = arr.searchsorted([30])
28
+ expected = np.array([2], dtype=np.intp)
29
+ tm.assert_numpy_array_equal(result, expected)
30
+
31
+ def test_searchsorted_numeric_dtypes_vector(self, any_real_numpy_dtype):
32
+ arr = pd.array([1, 3, 90], dtype=any_real_numpy_dtype)
33
+ result = arr.searchsorted([2, 30])
34
+ expected = np.array([1, 2], dtype=np.intp)
35
+ tm.assert_numpy_array_equal(result, expected)
36
+
37
+ def test_searchsorted_sorter(self, any_real_numpy_dtype):
38
+ arr = pd.array([3, 1, 2], dtype=any_real_numpy_dtype)
39
+ result = arr.searchsorted([0, 3], sorter=np.argsort(arr))
40
+ expected = np.array([0, 2], dtype=np.intp)
41
+ tm.assert_numpy_array_equal(result, expected)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/test_numpy.py ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Additional tests for PandasArray that aren't covered by
3
+ the interface tests.
4
+ """
5
+ import numpy as np
6
+ import pytest
7
+
8
+ from pandas.core.dtypes.dtypes import PandasDtype
9
+
10
+ import pandas as pd
11
+ import pandas._testing as tm
12
+ from pandas.arrays import PandasArray
13
+
14
+
15
+ @pytest.fixture(
16
+ params=[
17
+ np.array(["a", "b"], dtype=object),
18
+ np.array([0, 1], dtype=float),
19
+ np.array([0, 1], dtype=int),
20
+ np.array([0, 1 + 2j], dtype=complex),
21
+ np.array([True, False], dtype=bool),
22
+ np.array([0, 1], dtype="datetime64[ns]"),
23
+ np.array([0, 1], dtype="timedelta64[ns]"),
24
+ ]
25
+ )
26
+ def any_numpy_array(request):
27
+ """
28
+ Parametrized fixture for NumPy arrays with different dtypes.
29
+
30
+ This excludes string and bytes.
31
+ """
32
+ return request.param
33
+
34
+
35
+ # ----------------------------------------------------------------------------
36
+ # PandasDtype
37
+
38
+
39
+ @pytest.mark.parametrize(
40
+ "dtype, expected",
41
+ [
42
+ ("bool", True),
43
+ ("int", True),
44
+ ("uint", True),
45
+ ("float", True),
46
+ ("complex", True),
47
+ ("str", False),
48
+ ("bytes", False),
49
+ ("datetime64[ns]", False),
50
+ ("object", False),
51
+ ("void", False),
52
+ ],
53
+ )
54
+ def test_is_numeric(dtype, expected):
55
+ dtype = PandasDtype(dtype)
56
+ assert dtype._is_numeric is expected
57
+
58
+
59
+ @pytest.mark.parametrize(
60
+ "dtype, expected",
61
+ [
62
+ ("bool", True),
63
+ ("int", False),
64
+ ("uint", False),
65
+ ("float", False),
66
+ ("complex", False),
67
+ ("str", False),
68
+ ("bytes", False),
69
+ ("datetime64[ns]", False),
70
+ ("object", False),
71
+ ("void", False),
72
+ ],
73
+ )
74
+ def test_is_boolean(dtype, expected):
75
+ dtype = PandasDtype(dtype)
76
+ assert dtype._is_boolean is expected
77
+
78
+
79
+ def test_repr():
80
+ dtype = PandasDtype(np.dtype("int64"))
81
+ assert repr(dtype) == "PandasDtype('int64')"
82
+
83
+
84
+ def test_constructor_from_string():
85
+ result = PandasDtype.construct_from_string("int64")
86
+ expected = PandasDtype(np.dtype("int64"))
87
+ assert result == expected
88
+
89
+
90
+ def test_dtype_univalent(any_numpy_dtype):
91
+ dtype = PandasDtype(any_numpy_dtype)
92
+
93
+ result = PandasDtype(dtype)
94
+ assert result == dtype
95
+
96
+
97
+ # ----------------------------------------------------------------------------
98
+ # Construction
99
+
100
+
101
+ def test_constructor_no_coercion():
102
+ with pytest.raises(ValueError, match="NumPy array"):
103
+ PandasArray([1, 2, 3])
104
+
105
+
106
+ def test_series_constructor_with_copy():
107
+ ndarray = np.array([1, 2, 3])
108
+ ser = pd.Series(PandasArray(ndarray), copy=True)
109
+
110
+ assert ser.values is not ndarray
111
+
112
+
113
+ def test_series_constructor_with_astype():
114
+ ndarray = np.array([1, 2, 3])
115
+ result = pd.Series(PandasArray(ndarray), dtype="float64")
116
+ expected = pd.Series([1.0, 2.0, 3.0], dtype="float64")
117
+ tm.assert_series_equal(result, expected)
118
+
119
+
120
+ def test_from_sequence_dtype():
121
+ arr = np.array([1, 2, 3], dtype="int64")
122
+ result = PandasArray._from_sequence(arr, dtype="uint64")
123
+ expected = PandasArray(np.array([1, 2, 3], dtype="uint64"))
124
+ tm.assert_extension_array_equal(result, expected)
125
+
126
+
127
+ def test_constructor_copy():
128
+ arr = np.array([0, 1])
129
+ result = PandasArray(arr, copy=True)
130
+
131
+ assert not tm.shares_memory(result, arr)
132
+
133
+
134
+ def test_constructor_with_data(any_numpy_array):
135
+ nparr = any_numpy_array
136
+ arr = PandasArray(nparr)
137
+ assert arr.dtype.numpy_dtype == nparr.dtype
138
+
139
+
140
+ # ----------------------------------------------------------------------------
141
+ # Conversion
142
+
143
+
144
+ def test_to_numpy():
145
+ arr = PandasArray(np.array([1, 2, 3]))
146
+ result = arr.to_numpy()
147
+ assert result is arr._ndarray
148
+
149
+ result = arr.to_numpy(copy=True)
150
+ assert result is not arr._ndarray
151
+
152
+ result = arr.to_numpy(dtype="f8")
153
+ expected = np.array([1, 2, 3], dtype="f8")
154
+ tm.assert_numpy_array_equal(result, expected)
155
+
156
+
157
+ # ----------------------------------------------------------------------------
158
+ # Setitem
159
+
160
+
161
+ def test_setitem_series():
162
+ ser = pd.Series([1, 2, 3])
163
+ ser.array[0] = 10
164
+ expected = pd.Series([10, 2, 3])
165
+ tm.assert_series_equal(ser, expected)
166
+
167
+
168
+ def test_setitem(any_numpy_array):
169
+ nparr = any_numpy_array
170
+ arr = PandasArray(nparr, copy=True)
171
+
172
+ arr[0] = arr[1]
173
+ nparr[0] = nparr[1]
174
+
175
+ tm.assert_numpy_array_equal(arr.to_numpy(), nparr)
176
+
177
+
178
+ # ----------------------------------------------------------------------------
179
+ # Reductions
180
+
181
+
182
+ def test_bad_reduce_raises():
183
+ arr = np.array([1, 2, 3], dtype="int64")
184
+ arr = PandasArray(arr)
185
+ msg = "cannot perform not_a_method with type int"
186
+ with pytest.raises(TypeError, match=msg):
187
+ arr._reduce(msg)
188
+
189
+
190
+ def test_validate_reduction_keyword_args():
191
+ arr = PandasArray(np.array([1, 2, 3]))
192
+ msg = "the 'keepdims' parameter is not supported .*all"
193
+ with pytest.raises(ValueError, match=msg):
194
+ arr.all(keepdims=True)
195
+
196
+
197
+ def test_np_max_nested_tuples():
198
+ # case where checking in ufunc.nout works while checking for tuples
199
+ # does not
200
+ vals = [
201
+ (("j", "k"), ("l", "m")),
202
+ (("l", "m"), ("o", "p")),
203
+ (("o", "p"), ("j", "k")),
204
+ ]
205
+ ser = pd.Series(vals)
206
+ arr = ser.array
207
+
208
+ assert arr.max() is arr[2]
209
+ assert ser.max() is arr[2]
210
+
211
+ result = np.maximum.reduce(arr)
212
+ assert result == arr[2]
213
+
214
+ result = np.maximum.reduce(ser)
215
+ assert result == arr[2]
216
+
217
+
218
+ def test_np_reduce_2d():
219
+ raw = np.arange(12).reshape(4, 3)
220
+ arr = PandasArray(raw)
221
+
222
+ res = np.maximum.reduce(arr, axis=0)
223
+ tm.assert_extension_array_equal(res, arr[-1])
224
+
225
+ alt = arr.max(axis=0)
226
+ tm.assert_extension_array_equal(alt, arr[-1])
227
+
228
+
229
+ # ----------------------------------------------------------------------------
230
+ # Ops
231
+
232
+
233
+ @pytest.mark.parametrize("ufunc", [np.abs, np.negative, np.positive])
234
+ def test_ufunc_unary(ufunc):
235
+ arr = PandasArray(np.array([-1.0, 0.0, 1.0]))
236
+ result = ufunc(arr)
237
+ expected = PandasArray(ufunc(arr._ndarray))
238
+ tm.assert_extension_array_equal(result, expected)
239
+
240
+ # same thing but with the 'out' keyword
241
+ out = PandasArray(np.array([-9.0, -9.0, -9.0]))
242
+ ufunc(arr, out=out)
243
+ tm.assert_extension_array_equal(out, expected)
244
+
245
+
246
+ def test_ufunc():
247
+ arr = PandasArray(np.array([-1.0, 0.0, 1.0]))
248
+
249
+ r1, r2 = np.divmod(arr, np.add(arr, 2))
250
+ e1, e2 = np.divmod(arr._ndarray, np.add(arr._ndarray, 2))
251
+ e1 = PandasArray(e1)
252
+ e2 = PandasArray(e2)
253
+ tm.assert_extension_array_equal(r1, e1)
254
+ tm.assert_extension_array_equal(r2, e2)
255
+
256
+
257
+ def test_basic_binop():
258
+ # Just a basic smoke test. The EA interface tests exercise this
259
+ # more thoroughly.
260
+ x = PandasArray(np.array([1, 2, 3]))
261
+ result = x + x
262
+ expected = PandasArray(np.array([2, 4, 6]))
263
+ tm.assert_extension_array_equal(result, expected)
264
+
265
+
266
+ @pytest.mark.parametrize("dtype", [None, object])
267
+ def test_setitem_object_typecode(dtype):
268
+ arr = PandasArray(np.array(["a", "b", "c"], dtype=dtype))
269
+ arr[0] = "t"
270
+ expected = PandasArray(np.array(["t", "b", "c"], dtype=dtype))
271
+ tm.assert_extension_array_equal(arr, expected)
272
+
273
+
274
+ def test_setitem_no_coercion():
275
+ # https://github.com/pandas-dev/pandas/issues/28150
276
+ arr = PandasArray(np.array([1, 2, 3]))
277
+ with pytest.raises(ValueError, match="int"):
278
+ arr[0] = "a"
279
+
280
+ # With a value that we do coerce, check that we coerce the value
281
+ # and not the underlying array.
282
+ arr[0] = 2.5
283
+ assert isinstance(arr[0], (int, np.integer)), type(arr[0])
284
+
285
+
286
+ def test_setitem_preserves_views():
287
+ # GH#28150, see also extension test of the same name
288
+ arr = PandasArray(np.array([1, 2, 3]))
289
+ view1 = arr.view()
290
+ view2 = arr[:]
291
+ view3 = np.asarray(arr)
292
+
293
+ arr[0] = 9
294
+ assert view1[0] == 9
295
+ assert view2[0] == 9
296
+ assert view3[0] == 9
297
+
298
+ arr[-1] = 2.5
299
+ view1[-1] = 5
300
+ assert arr[-1] == 5
301
+
302
+
303
+ @pytest.mark.parametrize("dtype", [np.int64, np.uint64])
304
+ def test_quantile_empty(dtype):
305
+ # we should get back np.nans, not -1s
306
+ arr = PandasArray(np.array([], dtype=dtype))
307
+ idx = pd.Index([0.0, 0.5])
308
+
309
+ result = arr._quantile(idx, interpolation="linear")
310
+ expected = PandasArray(np.array([np.nan, np.nan]))
311
+ tm.assert_extension_array_equal(result, expected)
312
+
313
+
314
+ def test_factorize_unsigned():
315
+ # don't raise when calling factorize on unsigned int PandasArray
316
+ arr = np.array([1, 2, 3], dtype=np.uint64)
317
+ obj = PandasArray(arr)
318
+
319
+ res_codes, res_unique = obj.factorize()
320
+ exp_codes, exp_unique = pd.factorize(arr)
321
+
322
+ tm.assert_numpy_array_equal(res_codes, exp_codes)
323
+
324
+ tm.assert_extension_array_equal(res_unique, PandasArray(exp_unique))
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__init__.py ADDED
File without changes
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (182 Bytes). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_arrow_compat.cpython-310.pyc ADDED
Binary file (3.57 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_astype.cpython-310.pyc ADDED
Binary file (2.35 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_constructors.cpython-310.pyc ADDED
Binary file (4.16 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/__pycache__/test_reductions.cpython-310.pyc ADDED
Binary file (1.21 kB). View file
 
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_arrow_compat.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from pandas.compat.pyarrow import pa_version_under10p0
4
+
5
+ from pandas.core.dtypes.dtypes import PeriodDtype
6
+
7
+ import pandas as pd
8
+ import pandas._testing as tm
9
+ from pandas.core.arrays import (
10
+ PeriodArray,
11
+ period_array,
12
+ )
13
+
14
+ pa = pytest.importorskip("pyarrow", minversion="1.0.1")
15
+
16
+
17
+ def test_arrow_extension_type():
18
+ from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
19
+
20
+ p1 = ArrowPeriodType("D")
21
+ p2 = ArrowPeriodType("D")
22
+ p3 = ArrowPeriodType("M")
23
+
24
+ assert p1.freq == "D"
25
+ assert p1 == p2
26
+ assert p1 != p3
27
+ assert hash(p1) == hash(p2)
28
+ assert hash(p1) != hash(p3)
29
+
30
+
31
+ @pytest.mark.xfail(not pa_version_under10p0, reason="Wrong behavior with pyarrow 10")
32
+ @pytest.mark.parametrize(
33
+ "data, freq",
34
+ [
35
+ (pd.date_range("2017", periods=3), "D"),
36
+ (pd.date_range("2017", periods=3, freq="A"), "A-DEC"),
37
+ ],
38
+ )
39
+ def test_arrow_array(data, freq):
40
+ from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
41
+
42
+ periods = period_array(data, freq=freq)
43
+ result = pa.array(periods)
44
+ assert isinstance(result.type, ArrowPeriodType)
45
+ assert result.type.freq == freq
46
+ expected = pa.array(periods.asi8, type="int64")
47
+ assert result.storage.equals(expected)
48
+
49
+ # convert to its storage type
50
+ result = pa.array(periods, type=pa.int64())
51
+ assert result.equals(expected)
52
+
53
+ # unsupported conversions
54
+ msg = "Not supported to convert PeriodArray to 'double' type"
55
+ with pytest.raises(TypeError, match=msg):
56
+ pa.array(periods, type="float64")
57
+
58
+ with pytest.raises(TypeError, match="different 'freq'"):
59
+ pa.array(periods, type=ArrowPeriodType("T"))
60
+
61
+
62
+ def test_arrow_array_missing():
63
+ from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
64
+
65
+ arr = PeriodArray([1, 2, 3], freq="D")
66
+ arr[1] = pd.NaT
67
+
68
+ result = pa.array(arr)
69
+ assert isinstance(result.type, ArrowPeriodType)
70
+ assert result.type.freq == "D"
71
+ expected = pa.array([1, None, 3], type="int64")
72
+ assert result.storage.equals(expected)
73
+
74
+
75
+ def test_arrow_table_roundtrip():
76
+ from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
77
+
78
+ arr = PeriodArray([1, 2, 3], freq="D")
79
+ arr[1] = pd.NaT
80
+ df = pd.DataFrame({"a": arr})
81
+
82
+ table = pa.table(df)
83
+ assert isinstance(table.field("a").type, ArrowPeriodType)
84
+ result = table.to_pandas()
85
+ assert isinstance(result["a"].dtype, PeriodDtype)
86
+ tm.assert_frame_equal(result, df)
87
+
88
+ table2 = pa.concat_tables([table, table])
89
+ result = table2.to_pandas()
90
+ expected = pd.concat([df, df], ignore_index=True)
91
+ tm.assert_frame_equal(result, expected)
92
+
93
+
94
+ def test_arrow_load_from_zero_chunks():
95
+ # GH-41040
96
+
97
+ from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
98
+
99
+ arr = PeriodArray([], freq="D")
100
+ df = pd.DataFrame({"a": arr})
101
+
102
+ table = pa.table(df)
103
+ assert isinstance(table.field("a").type, ArrowPeriodType)
104
+ table = pa.table(
105
+ [pa.chunked_array([], type=table.column(0).type)], schema=table.schema
106
+ )
107
+ result = table.to_pandas()
108
+ assert isinstance(result["a"].dtype, PeriodDtype)
109
+ tm.assert_frame_equal(result, df)
110
+
111
+
112
+ def test_arrow_table_roundtrip_without_metadata():
113
+ arr = PeriodArray([1, 2, 3], freq="H")
114
+ arr[1] = pd.NaT
115
+ df = pd.DataFrame({"a": arr})
116
+
117
+ table = pa.table(df)
118
+ # remove the metadata
119
+ table = table.replace_schema_metadata()
120
+ assert table.schema.metadata is None
121
+
122
+ result = table.to_pandas()
123
+ assert isinstance(result["a"].dtype, PeriodDtype)
124
+ tm.assert_frame_equal(result, df)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_astype.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from pandas.core.dtypes.dtypes import PeriodDtype
5
+
6
+ import pandas as pd
7
+ import pandas._testing as tm
8
+ from pandas.core.arrays import period_array
9
+
10
+
11
+ @pytest.mark.parametrize("dtype", [int, np.int32, np.int64, "uint32", "uint64"])
12
+ def test_astype_int(dtype):
13
+ # We choose to ignore the sign and size of integers for
14
+ # Period/Datetime/Timedelta astype
15
+ arr = period_array(["2000", "2001", None], freq="D")
16
+
17
+ if np.dtype(dtype) != np.int64:
18
+ with pytest.raises(TypeError, match=r"Do obj.astype\('int64'\)"):
19
+ arr.astype(dtype)
20
+ return
21
+
22
+ result = arr.astype(dtype)
23
+ expected = arr._ndarray.view("i8")
24
+ tm.assert_numpy_array_equal(result, expected)
25
+
26
+
27
+ def test_astype_copies():
28
+ arr = period_array(["2000", "2001", None], freq="D")
29
+ result = arr.astype(np.int64, copy=False)
30
+
31
+ # Add the `.base`, since we now use `.asi8` which returns a view.
32
+ # We could maybe override it in PeriodArray to return ._ndarray directly.
33
+ assert result.base is arr._ndarray
34
+
35
+ result = arr.astype(np.int64, copy=True)
36
+ assert result is not arr._ndarray
37
+ tm.assert_numpy_array_equal(result, arr._ndarray.view("i8"))
38
+
39
+
40
+ def test_astype_categorical():
41
+ arr = period_array(["2000", "2001", "2001", None], freq="D")
42
+ result = arr.astype("category")
43
+ categories = pd.PeriodIndex(["2000", "2001"], freq="D")
44
+ expected = pd.Categorical.from_codes([0, 1, 1, -1], categories=categories)
45
+ tm.assert_categorical_equal(result, expected)
46
+
47
+
48
+ def test_astype_period():
49
+ arr = period_array(["2000", "2001", None], freq="D")
50
+ result = arr.astype(PeriodDtype("M"))
51
+ expected = period_array(["2000", "2001", None], freq="M")
52
+ tm.assert_period_array_equal(result, expected)
53
+
54
+
55
+ @pytest.mark.parametrize("other", ["datetime64[ns]", "timedelta64[ns]"])
56
+ def test_astype_datetime(other):
57
+ arr = period_array(["2000", "2001", None], freq="D")
58
+ # slice off the [ns] so that the regex matches.
59
+ if other == "timedelta64[ns]":
60
+ with pytest.raises(TypeError, match=other[:-4]):
61
+ arr.astype(other)
62
+
63
+ else:
64
+ # GH#45038 allow period->dt64 because we allow dt64->period
65
+ result = arr.astype(other)
66
+ expected = pd.DatetimeIndex(["2000", "2001", pd.NaT])._data
67
+ tm.assert_datetime_array_equal(result, expected)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_constructors.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from pandas._libs.tslibs import iNaT
5
+ from pandas._libs.tslibs.period import IncompatibleFrequency
6
+
7
+ import pandas as pd
8
+ import pandas._testing as tm
9
+ from pandas.core.arrays import (
10
+ PeriodArray,
11
+ period_array,
12
+ )
13
+
14
+
15
+ @pytest.mark.parametrize(
16
+ "data, freq, expected",
17
+ [
18
+ ([pd.Period("2017", "D")], None, [17167]),
19
+ ([pd.Period("2017", "D")], "D", [17167]),
20
+ ([2017], "D", [17167]),
21
+ (["2017"], "D", [17167]),
22
+ ([pd.Period("2017", "D")], pd.tseries.offsets.Day(), [17167]),
23
+ ([pd.Period("2017", "D"), None], None, [17167, iNaT]),
24
+ (pd.Series(pd.date_range("2017", periods=3)), None, [17167, 17168, 17169]),
25
+ (pd.date_range("2017", periods=3), None, [17167, 17168, 17169]),
26
+ (pd.period_range("2017", periods=4, freq="Q"), None, [188, 189, 190, 191]),
27
+ ],
28
+ )
29
+ def test_period_array_ok(data, freq, expected):
30
+ result = period_array(data, freq=freq).asi8
31
+ expected = np.asarray(expected, dtype=np.int64)
32
+ tm.assert_numpy_array_equal(result, expected)
33
+
34
+
35
+ def test_period_array_readonly_object():
36
+ # https://github.com/pandas-dev/pandas/issues/25403
37
+ pa = period_array([pd.Period("2019-01-01")])
38
+ arr = np.asarray(pa, dtype="object")
39
+ arr.setflags(write=False)
40
+
41
+ result = period_array(arr)
42
+ tm.assert_period_array_equal(result, pa)
43
+
44
+ result = pd.Series(arr)
45
+ tm.assert_series_equal(result, pd.Series(pa))
46
+
47
+ result = pd.DataFrame({"A": arr})
48
+ tm.assert_frame_equal(result, pd.DataFrame({"A": pa}))
49
+
50
+
51
+ def test_from_datetime64_freq_changes():
52
+ # https://github.com/pandas-dev/pandas/issues/23438
53
+ arr = pd.date_range("2017", periods=3, freq="D")
54
+ result = PeriodArray._from_datetime64(arr, freq="M")
55
+ expected = period_array(["2017-01-01", "2017-01-01", "2017-01-01"], freq="M")
56
+ tm.assert_period_array_equal(result, expected)
57
+
58
+
59
+ @pytest.mark.parametrize(
60
+ "data, freq, msg",
61
+ [
62
+ (
63
+ [pd.Period("2017", "D"), pd.Period("2017", "A")],
64
+ None,
65
+ "Input has different freq",
66
+ ),
67
+ ([pd.Period("2017", "D")], "A", "Input has different freq"),
68
+ ],
69
+ )
70
+ def test_period_array_raises(data, freq, msg):
71
+ with pytest.raises(IncompatibleFrequency, match=msg):
72
+ period_array(data, freq)
73
+
74
+
75
+ def test_period_array_non_period_series_raies():
76
+ ser = pd.Series([1, 2, 3])
77
+ with pytest.raises(TypeError, match="dtype"):
78
+ PeriodArray(ser, freq="D")
79
+
80
+
81
+ def test_period_array_freq_mismatch():
82
+ arr = period_array(["2000", "2001"], freq="D")
83
+ with pytest.raises(IncompatibleFrequency, match="freq"):
84
+ PeriodArray(arr, freq="M")
85
+
86
+ with pytest.raises(IncompatibleFrequency, match="freq"):
87
+ PeriodArray(arr, freq=pd.tseries.offsets.MonthEnd())
88
+
89
+
90
+ def test_from_sequence_disallows_i8():
91
+ arr = period_array(["2000", "2001"], freq="D")
92
+
93
+ msg = str(arr[0].ordinal)
94
+ with pytest.raises(TypeError, match=msg):
95
+ PeriodArray._from_sequence(arr.asi8, dtype=arr.dtype)
96
+
97
+ with pytest.raises(TypeError, match=msg):
98
+ PeriodArray._from_sequence(list(arr.asi8), dtype=arr.dtype)
99
+
100
+
101
+ def test_from_td64nat_sequence_raises():
102
+ # GH#44507
103
+ td = pd.NaT.to_numpy("m8[ns]")
104
+
105
+ dtype = pd.period_range("2005-01-01", periods=3, freq="D").dtype
106
+
107
+ arr = np.array([None], dtype=object)
108
+ arr[0] = td
109
+
110
+ msg = "Value must be Period, string, integer, or datetime"
111
+ with pytest.raises(ValueError, match=msg):
112
+ PeriodArray._from_sequence(arr, dtype=dtype)
113
+
114
+ with pytest.raises(ValueError, match=msg):
115
+ pd.PeriodIndex(arr, dtype=dtype)
116
+ with pytest.raises(ValueError, match=msg):
117
+ pd.Index(arr, dtype=dtype)
118
+ with pytest.raises(ValueError, match=msg):
119
+ pd.array(arr, dtype=dtype)
120
+ with pytest.raises(ValueError, match=msg):
121
+ pd.Series(arr, dtype=dtype)
122
+ with pytest.raises(ValueError, match=msg):
123
+ pd.DataFrame(arr, dtype=dtype)
videochat2/lib/python3.10/site-packages/pandas/tests/arrays/period/test_reductions.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ import pandas as pd
4
+ from pandas.core.arrays import period_array
5
+
6
+
7
+ class TestReductions:
8
+ def test_min_max(self):
9
+ arr = period_array(
10
+ [
11
+ "2000-01-03",
12
+ "2000-01-03",
13
+ "NaT",
14
+ "2000-01-02",
15
+ "2000-01-05",
16
+ "2000-01-04",
17
+ ],
18
+ freq="D",
19
+ )
20
+
21
+ result = arr.min()
22
+ expected = pd.Period("2000-01-02", freq="D")
23
+ assert result == expected
24
+
25
+ result = arr.max()
26
+ expected = pd.Period("2000-01-05", freq="D")
27
+ assert result == expected
28
+
29
+ result = arr.min(skipna=False)
30
+ assert result is pd.NaT
31
+
32
+ result = arr.max(skipna=False)
33
+ assert result is pd.NaT
34
+
35
+ @pytest.mark.parametrize("skipna", [True, False])
36
+ def test_min_max_empty(self, skipna):
37
+ arr = period_array([], freq="D")
38
+ result = arr.min(skipna=skipna)
39
+ assert result is pd.NaT
40
+
41
+ result = arr.max(skipna=skipna)
42
+ assert result is pd.NaT