ZhengyangZhang commited on
Commit
7db01aa
·
verified ·
1 Parent(s): 8a46d75

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. lib/python3.12/site-packages/pandas/tests/api/__init__.py +0 -0
  2. lib/python3.12/site-packages/pandas/tests/api/__pycache__/__init__.cpython-312.pyc +0 -0
  3. lib/python3.12/site-packages/pandas/tests/api/__pycache__/test_types.cpython-312.pyc +0 -0
  4. lib/python3.12/site-packages/pandas/tests/api/test_api.py +383 -0
  5. lib/python3.12/site-packages/pandas/tests/api/test_types.py +62 -0
  6. lib/python3.12/site-packages/pandas/tests/construction/__init__.py +0 -0
  7. lib/python3.12/site-packages/pandas/tests/construction/__pycache__/__init__.cpython-312.pyc +0 -0
  8. lib/python3.12/site-packages/pandas/tests/construction/__pycache__/test_extract_array.cpython-312.pyc +0 -0
  9. lib/python3.12/site-packages/pandas/tests/construction/test_extract_array.py +18 -0
  10. lib/python3.12/site-packages/pandas/tests/extension/__init__.py +0 -0
  11. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/__init__.cpython-312.pyc +0 -0
  12. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/conftest.cpython-312.pyc +0 -0
  13. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_categorical.cpython-312.pyc +0 -0
  14. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_common.cpython-312.pyc +0 -0
  15. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_datetime.cpython-312.pyc +0 -0
  16. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_extension.cpython-312.pyc +0 -0
  17. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_interval.cpython-312.pyc +0 -0
  18. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_masked.cpython-312.pyc +0 -0
  19. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_numpy.cpython-312.pyc +0 -0
  20. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_period.cpython-312.pyc +0 -0
  21. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_sparse.cpython-312.pyc +0 -0
  22. lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_string.cpython-312.pyc +0 -0
  23. lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__init__.py +6 -0
  24. lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__pycache__/__init__.cpython-312.pyc +0 -0
  25. lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__pycache__/array.cpython-312.pyc +0 -0
  26. lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__pycache__/test_array_with_attr.cpython-312.pyc +0 -0
  27. lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/array.py +89 -0
  28. lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py +33 -0
  29. lib/python3.12/site-packages/pandas/tests/extension/base/__init__.py +131 -0
  30. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/__init__.cpython-312.pyc +0 -0
  31. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/accumulate.cpython-312.pyc +0 -0
  32. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/base.cpython-312.pyc +0 -0
  33. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/casting.cpython-312.pyc +0 -0
  34. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/constructors.cpython-312.pyc +0 -0
  35. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/dim2.cpython-312.pyc +0 -0
  36. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/dtype.cpython-312.pyc +0 -0
  37. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/getitem.cpython-312.pyc +0 -0
  38. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/groupby.cpython-312.pyc +0 -0
  39. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/index.cpython-312.pyc +0 -0
  40. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/interface.cpython-312.pyc +0 -0
  41. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/io.cpython-312.pyc +0 -0
  42. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/methods.cpython-312.pyc +0 -0
  43. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/missing.cpython-312.pyc +0 -0
  44. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/ops.cpython-312.pyc +0 -0
  45. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/printing.cpython-312.pyc +0 -0
  46. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/reduce.cpython-312.pyc +0 -0
  47. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/reshaping.cpython-312.pyc +0 -0
  48. lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/setitem.cpython-312.pyc +0 -0
  49. lib/python3.12/site-packages/pandas/tests/extension/base/accumulate.py +39 -0
  50. lib/python3.12/site-packages/pandas/tests/extension/base/base.py +2 -0
lib/python3.12/site-packages/pandas/tests/api/__init__.py ADDED
File without changes
lib/python3.12/site-packages/pandas/tests/api/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (195 Bytes). View file
 
lib/python3.12/site-packages/pandas/tests/api/__pycache__/test_types.cpython-312.pyc ADDED
Binary file (2.24 kB). View file
 
lib/python3.12/site-packages/pandas/tests/api/test_api.py ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import pytest
4
+
5
+ import pandas as pd
6
+ from pandas import api
7
+ import pandas._testing as tm
8
+ from pandas.api import (
9
+ extensions as api_extensions,
10
+ indexers as api_indexers,
11
+ interchange as api_interchange,
12
+ types as api_types,
13
+ typing as api_typing,
14
+ )
15
+
16
+
17
+ class Base:
18
+ def check(self, namespace, expected, ignored=None):
19
+ # see which names are in the namespace, minus optional
20
+ # ignored ones
21
+ # compare vs the expected
22
+
23
+ result = sorted(
24
+ f for f in dir(namespace) if not f.startswith("__") and f != "annotations"
25
+ )
26
+ if ignored is not None:
27
+ result = sorted(set(result) - set(ignored))
28
+
29
+ expected = sorted(expected)
30
+ tm.assert_almost_equal(result, expected)
31
+
32
+
33
+ class TestPDApi(Base):
34
+ # these are optionally imported based on testing
35
+ # & need to be ignored
36
+ ignored = ["tests", "locale", "conftest", "_version_meson"]
37
+
38
+ # top-level sub-packages
39
+ public_lib = [
40
+ "api",
41
+ "arrays",
42
+ "options",
43
+ "test",
44
+ "testing",
45
+ "errors",
46
+ "plotting",
47
+ "io",
48
+ "tseries",
49
+ ]
50
+ private_lib = ["compat", "core", "pandas", "util", "_built_with_meson"]
51
+
52
+ # misc
53
+ misc = ["IndexSlice", "NaT", "NA"]
54
+
55
+ # top-level classes
56
+ classes = [
57
+ "ArrowDtype",
58
+ "Categorical",
59
+ "CategoricalIndex",
60
+ "DataFrame",
61
+ "DateOffset",
62
+ "DatetimeIndex",
63
+ "ExcelFile",
64
+ "ExcelWriter",
65
+ "Flags",
66
+ "Grouper",
67
+ "HDFStore",
68
+ "Index",
69
+ "MultiIndex",
70
+ "Period",
71
+ "PeriodIndex",
72
+ "RangeIndex",
73
+ "Series",
74
+ "SparseDtype",
75
+ "StringDtype",
76
+ "Timedelta",
77
+ "TimedeltaIndex",
78
+ "Timestamp",
79
+ "Interval",
80
+ "IntervalIndex",
81
+ "CategoricalDtype",
82
+ "PeriodDtype",
83
+ "IntervalDtype",
84
+ "DatetimeTZDtype",
85
+ "BooleanDtype",
86
+ "Int8Dtype",
87
+ "Int16Dtype",
88
+ "Int32Dtype",
89
+ "Int64Dtype",
90
+ "UInt8Dtype",
91
+ "UInt16Dtype",
92
+ "UInt32Dtype",
93
+ "UInt64Dtype",
94
+ "Float32Dtype",
95
+ "Float64Dtype",
96
+ "NamedAgg",
97
+ ]
98
+
99
+ # these are already deprecated; awaiting removal
100
+ deprecated_classes: list[str] = []
101
+
102
+ # external modules exposed in pandas namespace
103
+ modules: list[str] = []
104
+
105
+ # top-level functions
106
+ funcs = [
107
+ "array",
108
+ "bdate_range",
109
+ "concat",
110
+ "crosstab",
111
+ "cut",
112
+ "date_range",
113
+ "interval_range",
114
+ "eval",
115
+ "factorize",
116
+ "get_dummies",
117
+ "from_dummies",
118
+ "infer_freq",
119
+ "isna",
120
+ "isnull",
121
+ "lreshape",
122
+ "melt",
123
+ "notna",
124
+ "notnull",
125
+ "offsets",
126
+ "merge",
127
+ "merge_ordered",
128
+ "merge_asof",
129
+ "period_range",
130
+ "pivot",
131
+ "pivot_table",
132
+ "qcut",
133
+ "show_versions",
134
+ "timedelta_range",
135
+ "unique",
136
+ "value_counts",
137
+ "wide_to_long",
138
+ ]
139
+
140
+ # top-level option funcs
141
+ funcs_option = [
142
+ "reset_option",
143
+ "describe_option",
144
+ "get_option",
145
+ "option_context",
146
+ "set_option",
147
+ "set_eng_float_format",
148
+ ]
149
+
150
+ # top-level read_* funcs
151
+ funcs_read = [
152
+ "read_clipboard",
153
+ "read_csv",
154
+ "read_excel",
155
+ "read_fwf",
156
+ "read_gbq",
157
+ "read_hdf",
158
+ "read_html",
159
+ "read_xml",
160
+ "read_json",
161
+ "read_pickle",
162
+ "read_sas",
163
+ "read_sql",
164
+ "read_sql_query",
165
+ "read_sql_table",
166
+ "read_stata",
167
+ "read_table",
168
+ "read_feather",
169
+ "read_parquet",
170
+ "read_orc",
171
+ "read_spss",
172
+ ]
173
+
174
+ # top-level json funcs
175
+ funcs_json = ["json_normalize"]
176
+
177
+ # top-level to_* funcs
178
+ funcs_to = ["to_datetime", "to_numeric", "to_pickle", "to_timedelta"]
179
+
180
+ # top-level to deprecate in the future
181
+ deprecated_funcs_in_future: list[str] = []
182
+
183
+ # these are already deprecated; awaiting removal
184
+ deprecated_funcs: list[str] = []
185
+
186
+ # private modules in pandas namespace
187
+ private_modules = [
188
+ "_config",
189
+ "_libs",
190
+ "_is_numpy_dev",
191
+ "_pandas_datetime_CAPI",
192
+ "_pandas_parser_CAPI",
193
+ "_testing",
194
+ "_typing",
195
+ ]
196
+ if not pd._built_with_meson:
197
+ private_modules.append("_version")
198
+
199
+ def test_api(self):
200
+ checkthese = (
201
+ self.public_lib
202
+ + self.private_lib
203
+ + self.misc
204
+ + self.modules
205
+ + self.classes
206
+ + self.funcs
207
+ + self.funcs_option
208
+ + self.funcs_read
209
+ + self.funcs_json
210
+ + self.funcs_to
211
+ + self.private_modules
212
+ )
213
+ self.check(namespace=pd, expected=checkthese, ignored=self.ignored)
214
+
215
+ def test_api_all(self):
216
+ expected = set(
217
+ self.public_lib
218
+ + self.misc
219
+ + self.modules
220
+ + self.classes
221
+ + self.funcs
222
+ + self.funcs_option
223
+ + self.funcs_read
224
+ + self.funcs_json
225
+ + self.funcs_to
226
+ ) - set(self.deprecated_classes)
227
+ actual = set(pd.__all__)
228
+
229
+ extraneous = actual - expected
230
+ assert not extraneous
231
+
232
+ missing = expected - actual
233
+ assert not missing
234
+
235
+ def test_depr(self):
236
+ deprecated_list = (
237
+ self.deprecated_classes
238
+ + self.deprecated_funcs
239
+ + self.deprecated_funcs_in_future
240
+ )
241
+ for depr in deprecated_list:
242
+ with tm.assert_produces_warning(FutureWarning):
243
+ _ = getattr(pd, depr)
244
+
245
+
246
+ class TestApi(Base):
247
+ allowed_api_dirs = [
248
+ "types",
249
+ "extensions",
250
+ "indexers",
251
+ "interchange",
252
+ "typing",
253
+ ]
254
+ allowed_typing = [
255
+ "DataFrameGroupBy",
256
+ "DatetimeIndexResamplerGroupby",
257
+ "Expanding",
258
+ "ExpandingGroupby",
259
+ "ExponentialMovingWindow",
260
+ "ExponentialMovingWindowGroupby",
261
+ "JsonReader",
262
+ "NaTType",
263
+ "NAType",
264
+ "PeriodIndexResamplerGroupby",
265
+ "Resampler",
266
+ "Rolling",
267
+ "RollingGroupby",
268
+ "SeriesGroupBy",
269
+ "StataReader",
270
+ "TimedeltaIndexResamplerGroupby",
271
+ "TimeGrouper",
272
+ "Window",
273
+ ]
274
+ allowed_api_types = [
275
+ "is_any_real_numeric_dtype",
276
+ "is_array_like",
277
+ "is_bool",
278
+ "is_bool_dtype",
279
+ "is_categorical_dtype",
280
+ "is_complex",
281
+ "is_complex_dtype",
282
+ "is_datetime64_any_dtype",
283
+ "is_datetime64_dtype",
284
+ "is_datetime64_ns_dtype",
285
+ "is_datetime64tz_dtype",
286
+ "is_dict_like",
287
+ "is_dtype_equal",
288
+ "is_extension_array_dtype",
289
+ "is_file_like",
290
+ "is_float",
291
+ "is_float_dtype",
292
+ "is_hashable",
293
+ "is_int64_dtype",
294
+ "is_integer",
295
+ "is_integer_dtype",
296
+ "is_interval",
297
+ "is_interval_dtype",
298
+ "is_iterator",
299
+ "is_list_like",
300
+ "is_named_tuple",
301
+ "is_number",
302
+ "is_numeric_dtype",
303
+ "is_object_dtype",
304
+ "is_period_dtype",
305
+ "is_re",
306
+ "is_re_compilable",
307
+ "is_scalar",
308
+ "is_signed_integer_dtype",
309
+ "is_sparse",
310
+ "is_string_dtype",
311
+ "is_timedelta64_dtype",
312
+ "is_timedelta64_ns_dtype",
313
+ "is_unsigned_integer_dtype",
314
+ "pandas_dtype",
315
+ "infer_dtype",
316
+ "union_categoricals",
317
+ "CategoricalDtype",
318
+ "DatetimeTZDtype",
319
+ "IntervalDtype",
320
+ "PeriodDtype",
321
+ ]
322
+ allowed_api_interchange = ["from_dataframe", "DataFrame"]
323
+ allowed_api_indexers = [
324
+ "check_array_indexer",
325
+ "BaseIndexer",
326
+ "FixedForwardWindowIndexer",
327
+ "VariableOffsetWindowIndexer",
328
+ ]
329
+ allowed_api_extensions = [
330
+ "no_default",
331
+ "ExtensionDtype",
332
+ "register_extension_dtype",
333
+ "register_dataframe_accessor",
334
+ "register_index_accessor",
335
+ "register_series_accessor",
336
+ "take",
337
+ "ExtensionArray",
338
+ "ExtensionScalarOpsMixin",
339
+ ]
340
+
341
+ def test_api(self):
342
+ self.check(api, self.allowed_api_dirs)
343
+
344
+ def test_api_typing(self):
345
+ self.check(api_typing, self.allowed_typing)
346
+
347
+ def test_api_types(self):
348
+ self.check(api_types, self.allowed_api_types)
349
+
350
+ def test_api_interchange(self):
351
+ self.check(api_interchange, self.allowed_api_interchange)
352
+
353
+ def test_api_indexers(self):
354
+ self.check(api_indexers, self.allowed_api_indexers)
355
+
356
+ def test_api_extensions(self):
357
+ self.check(api_extensions, self.allowed_api_extensions)
358
+
359
+
360
+ class TestTesting(Base):
361
+ funcs = [
362
+ "assert_frame_equal",
363
+ "assert_series_equal",
364
+ "assert_index_equal",
365
+ "assert_extension_array_equal",
366
+ ]
367
+
368
+ def test_testing(self):
369
+ from pandas import testing
370
+
371
+ self.check(testing, self.funcs)
372
+
373
+ def test_util_in_top_level(self):
374
+ with pytest.raises(AttributeError, match="foo"):
375
+ pd.util.foo
376
+
377
+
378
+ def test_pandas_array_alias():
379
+ msg = "PandasArray has been renamed NumpyExtensionArray"
380
+ with tm.assert_produces_warning(FutureWarning, match=msg):
381
+ res = pd.arrays.PandasArray
382
+
383
+ assert res is pd.arrays.NumpyExtensionArray
lib/python3.12/site-packages/pandas/tests/api/test_types.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import pandas._testing as tm
4
+ from pandas.api import types
5
+ from pandas.tests.api.test_api import Base
6
+
7
+
8
+ class TestTypes(Base):
9
+ allowed = [
10
+ "is_any_real_numeric_dtype",
11
+ "is_bool",
12
+ "is_bool_dtype",
13
+ "is_categorical_dtype",
14
+ "is_complex",
15
+ "is_complex_dtype",
16
+ "is_datetime64_any_dtype",
17
+ "is_datetime64_dtype",
18
+ "is_datetime64_ns_dtype",
19
+ "is_datetime64tz_dtype",
20
+ "is_dtype_equal",
21
+ "is_float",
22
+ "is_float_dtype",
23
+ "is_int64_dtype",
24
+ "is_integer",
25
+ "is_integer_dtype",
26
+ "is_number",
27
+ "is_numeric_dtype",
28
+ "is_object_dtype",
29
+ "is_scalar",
30
+ "is_sparse",
31
+ "is_string_dtype",
32
+ "is_signed_integer_dtype",
33
+ "is_timedelta64_dtype",
34
+ "is_timedelta64_ns_dtype",
35
+ "is_unsigned_integer_dtype",
36
+ "is_period_dtype",
37
+ "is_interval",
38
+ "is_interval_dtype",
39
+ "is_re",
40
+ "is_re_compilable",
41
+ "is_dict_like",
42
+ "is_iterator",
43
+ "is_file_like",
44
+ "is_list_like",
45
+ "is_hashable",
46
+ "is_array_like",
47
+ "is_named_tuple",
48
+ "pandas_dtype",
49
+ "union_categoricals",
50
+ "infer_dtype",
51
+ "is_extension_array_dtype",
52
+ ]
53
+ deprecated: list[str] = []
54
+ dtypes = ["CategoricalDtype", "DatetimeTZDtype", "PeriodDtype", "IntervalDtype"]
55
+
56
+ def test_types(self):
57
+ self.check(types, self.allowed + self.dtypes + self.deprecated)
58
+
59
+ def test_deprecated_from_api_types(self):
60
+ for t in self.deprecated:
61
+ with tm.assert_produces_warning(FutureWarning):
62
+ getattr(types, t)(1)
lib/python3.12/site-packages/pandas/tests/construction/__init__.py ADDED
File without changes
lib/python3.12/site-packages/pandas/tests/construction/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (204 Bytes). View file
 
lib/python3.12/site-packages/pandas/tests/construction/__pycache__/test_extract_array.cpython-312.pyc ADDED
Binary file (1.11 kB). View file
 
lib/python3.12/site-packages/pandas/tests/construction/test_extract_array.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pandas import Index
2
+ import pandas._testing as tm
3
+ from pandas.core.construction import extract_array
4
+
5
+
6
+ def test_extract_array_rangeindex():
7
+ ri = Index(range(5))
8
+
9
+ expected = ri._values
10
+ res = extract_array(ri, extract_numpy=True, extract_range=True)
11
+ tm.assert_numpy_array_equal(res, expected)
12
+ res = extract_array(ri, extract_numpy=False, extract_range=True)
13
+ tm.assert_numpy_array_equal(res, expected)
14
+
15
+ res = extract_array(ri, extract_numpy=True, extract_range=False)
16
+ tm.assert_index_equal(res, ri)
17
+ res = extract_array(ri, extract_numpy=False, extract_range=False)
18
+ tm.assert_index_equal(res, ri)
lib/python3.12/site-packages/pandas/tests/extension/__init__.py ADDED
File without changes
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (201 Bytes). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/conftest.cpython-312.pyc ADDED
Binary file (7.99 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_categorical.cpython-312.pyc ADDED
Binary file (10.7 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_common.cpython-312.pyc ADDED
Binary file (5.88 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_datetime.cpython-312.pyc ADDED
Binary file (7.93 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_extension.cpython-312.pyc ADDED
Binary file (1.53 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_interval.cpython-312.pyc ADDED
Binary file (5.06 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_masked.cpython-312.pyc ADDED
Binary file (18.7 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_numpy.cpython-312.pyc ADDED
Binary file (23.2 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_period.cpython-312.pyc ADDED
Binary file (6.19 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_sparse.cpython-312.pyc ADDED
Binary file (30.1 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/__pycache__/test_string.cpython-312.pyc ADDED
Binary file (12.3 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__init__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from pandas.tests.extension.array_with_attr.array import (
2
+ FloatAttrArray,
3
+ FloatAttrDtype,
4
+ )
5
+
6
+ __all__ = ["FloatAttrArray", "FloatAttrDtype"]
lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (370 Bytes). View file
 
lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__pycache__/array.cpython-312.pyc ADDED
Binary file (4.62 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/__pycache__/test_array_with_attr.cpython-312.pyc ADDED
Binary file (2.44 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/array.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Test extension array that has custom attribute information (not stored on the dtype).
3
+
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import numbers
8
+ from typing import TYPE_CHECKING
9
+
10
+ import numpy as np
11
+
12
+ from pandas.core.dtypes.base import ExtensionDtype
13
+
14
+ import pandas as pd
15
+ from pandas.core.arrays import ExtensionArray
16
+
17
+ if TYPE_CHECKING:
18
+ from pandas._typing import type_t
19
+
20
+
21
+ class FloatAttrDtype(ExtensionDtype):
22
+ type = float
23
+ name = "float_attr"
24
+ na_value = np.nan
25
+
26
+ @classmethod
27
+ def construct_array_type(cls) -> type_t[FloatAttrArray]:
28
+ """
29
+ Return the array type associated with this dtype.
30
+
31
+ Returns
32
+ -------
33
+ type
34
+ """
35
+ return FloatAttrArray
36
+
37
+
38
+ class FloatAttrArray(ExtensionArray):
39
+ dtype = FloatAttrDtype()
40
+ __array_priority__ = 1000
41
+
42
+ def __init__(self, values, attr=None) -> None:
43
+ if not isinstance(values, np.ndarray):
44
+ raise TypeError("Need to pass a numpy array of float64 dtype as values")
45
+ if not values.dtype == "float64":
46
+ raise TypeError("Need to pass a numpy array of float64 dtype as values")
47
+ self.data = values
48
+ self.attr = attr
49
+
50
+ @classmethod
51
+ def _from_sequence(cls, scalars, *, dtype=None, copy=False):
52
+ if not copy:
53
+ data = np.asarray(scalars, dtype="float64")
54
+ else:
55
+ data = np.array(scalars, dtype="float64", copy=copy)
56
+ return cls(data)
57
+
58
+ def __getitem__(self, item):
59
+ if isinstance(item, numbers.Integral):
60
+ return self.data[item]
61
+ else:
62
+ # slice, list-like, mask
63
+ item = pd.api.indexers.check_array_indexer(self, item)
64
+ return type(self)(self.data[item], self.attr)
65
+
66
+ def __len__(self) -> int:
67
+ return len(self.data)
68
+
69
+ def isna(self):
70
+ return np.isnan(self.data)
71
+
72
+ def take(self, indexer, allow_fill=False, fill_value=None):
73
+ from pandas.api.extensions import take
74
+
75
+ data = self.data
76
+ if allow_fill and fill_value is None:
77
+ fill_value = self.dtype.na_value
78
+
79
+ result = take(data, indexer, fill_value=fill_value, allow_fill=allow_fill)
80
+ return type(self)(result, self.attr)
81
+
82
+ def copy(self):
83
+ return type(self)(self.data.copy(), self.attr)
84
+
85
+ @classmethod
86
+ def _concat_same_type(cls, to_concat):
87
+ data = np.concatenate([x.data for x in to_concat])
88
+ attr = to_concat[0].attr if len(to_concat) else None
89
+ return cls(data, attr)
lib/python3.12/site-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ import pandas as pd
4
+ import pandas._testing as tm
5
+ from pandas.tests.extension.array_with_attr import FloatAttrArray
6
+
7
+
8
+ def test_concat_with_all_na():
9
+ # https://github.com/pandas-dev/pandas/pull/47762
10
+ # ensure that attribute of the column array is preserved (when it gets
11
+ # preserved in reindexing the array) during merge/concat
12
+ arr = FloatAttrArray(np.array([np.nan, np.nan], dtype="float64"), attr="test")
13
+
14
+ df1 = pd.DataFrame({"col": arr, "key": [0, 1]})
15
+ df2 = pd.DataFrame({"key": [0, 1], "col2": [1, 2]})
16
+ result = pd.merge(df1, df2, on="key")
17
+ expected = pd.DataFrame({"col": arr, "key": [0, 1], "col2": [1, 2]})
18
+ tm.assert_frame_equal(result, expected)
19
+ assert result["col"].array.attr == "test"
20
+
21
+ df1 = pd.DataFrame({"col": arr, "key": [0, 1]})
22
+ df2 = pd.DataFrame({"key": [0, 2], "col2": [1, 2]})
23
+ result = pd.merge(df1, df2, on="key")
24
+ expected = pd.DataFrame({"col": arr.take([0]), "key": [0], "col2": [1]})
25
+ tm.assert_frame_equal(result, expected)
26
+ assert result["col"].array.attr == "test"
27
+
28
+ result = pd.concat([df1.set_index("key"), df2.set_index("key")], axis=1)
29
+ expected = pd.DataFrame(
30
+ {"col": arr.take([0, 1, -1]), "col2": [1, np.nan, 2], "key": [0, 1, 2]}
31
+ ).set_index("key")
32
+ tm.assert_frame_equal(result, expected)
33
+ assert result["col"].array.attr == "test"
lib/python3.12/site-packages/pandas/tests/extension/base/__init__.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Base test suite for extension arrays.
3
+
4
+ These tests are intended for third-party libraries to subclass to validate
5
+ that their extension arrays and dtypes satisfy the interface. Moving or
6
+ renaming the tests should not be done lightly.
7
+
8
+ Libraries are expected to implement a few pytest fixtures to provide data
9
+ for the tests. The fixtures may be located in either
10
+
11
+ * The same module as your test class.
12
+ * A ``conftest.py`` in the same directory as your test class.
13
+
14
+ The full list of fixtures may be found in the ``conftest.py`` next to this
15
+ file.
16
+
17
+ .. code-block:: python
18
+
19
+ import pytest
20
+ from pandas.tests.extension.base import BaseDtypeTests
21
+
22
+
23
+ @pytest.fixture
24
+ def dtype():
25
+ return MyDtype()
26
+
27
+
28
+ class TestMyDtype(BaseDtypeTests):
29
+ pass
30
+
31
+
32
+ Your class ``TestDtype`` will inherit all the tests defined on
33
+ ``BaseDtypeTests``. pytest's fixture discover will supply your ``dtype``
34
+ wherever the test requires it. You're free to implement additional tests.
35
+
36
+ """
37
+ from pandas.tests.extension.base.accumulate import BaseAccumulateTests
38
+ from pandas.tests.extension.base.casting import BaseCastingTests
39
+ from pandas.tests.extension.base.constructors import BaseConstructorsTests
40
+ from pandas.tests.extension.base.dim2 import ( # noqa: F401
41
+ Dim2CompatTests,
42
+ NDArrayBacked2DTests,
43
+ )
44
+ from pandas.tests.extension.base.dtype import BaseDtypeTests
45
+ from pandas.tests.extension.base.getitem import BaseGetitemTests
46
+ from pandas.tests.extension.base.groupby import BaseGroupbyTests
47
+ from pandas.tests.extension.base.index import BaseIndexTests
48
+ from pandas.tests.extension.base.interface import BaseInterfaceTests
49
+ from pandas.tests.extension.base.io import BaseParsingTests
50
+ from pandas.tests.extension.base.methods import BaseMethodsTests
51
+ from pandas.tests.extension.base.missing import BaseMissingTests
52
+ from pandas.tests.extension.base.ops import ( # noqa: F401
53
+ BaseArithmeticOpsTests,
54
+ BaseComparisonOpsTests,
55
+ BaseOpsUtil,
56
+ BaseUnaryOpsTests,
57
+ )
58
+ from pandas.tests.extension.base.printing import BasePrintingTests
59
+ from pandas.tests.extension.base.reduce import BaseReduceTests
60
+ from pandas.tests.extension.base.reshaping import BaseReshapingTests
61
+ from pandas.tests.extension.base.setitem import BaseSetitemTests
62
+
63
+
64
+ # One test class that you can inherit as an alternative to inheriting all the
65
+ # test classes above.
66
+ # Note 1) this excludes Dim2CompatTests and NDArrayBacked2DTests.
67
+ # Note 2) this uses BaseReduceTests and and _not_ BaseBooleanReduceTests,
68
+ # BaseNoReduceTests, or BaseNumericReduceTests
69
+ class ExtensionTests(
70
+ BaseAccumulateTests,
71
+ BaseCastingTests,
72
+ BaseConstructorsTests,
73
+ BaseDtypeTests,
74
+ BaseGetitemTests,
75
+ BaseGroupbyTests,
76
+ BaseIndexTests,
77
+ BaseInterfaceTests,
78
+ BaseParsingTests,
79
+ BaseMethodsTests,
80
+ BaseMissingTests,
81
+ BaseArithmeticOpsTests,
82
+ BaseComparisonOpsTests,
83
+ BaseUnaryOpsTests,
84
+ BasePrintingTests,
85
+ BaseReduceTests,
86
+ BaseReshapingTests,
87
+ BaseSetitemTests,
88
+ Dim2CompatTests,
89
+ ):
90
+ pass
91
+
92
+
93
+ def __getattr__(name: str):
94
+ import warnings
95
+
96
+ if name == "BaseNoReduceTests":
97
+ warnings.warn(
98
+ "BaseNoReduceTests is deprecated and will be removed in a "
99
+ "future version. Use BaseReduceTests and override "
100
+ "`_supports_reduction` instead.",
101
+ FutureWarning,
102
+ )
103
+ from pandas.tests.extension.base.reduce import BaseNoReduceTests
104
+
105
+ return BaseNoReduceTests
106
+
107
+ elif name == "BaseNumericReduceTests":
108
+ warnings.warn(
109
+ "BaseNumericReduceTests is deprecated and will be removed in a "
110
+ "future version. Use BaseReduceTests and override "
111
+ "`_supports_reduction` instead.",
112
+ FutureWarning,
113
+ )
114
+ from pandas.tests.extension.base.reduce import BaseNumericReduceTests
115
+
116
+ return BaseNumericReduceTests
117
+
118
+ elif name == "BaseBooleanReduceTests":
119
+ warnings.warn(
120
+ "BaseBooleanReduceTests is deprecated and will be removed in a "
121
+ "future version. Use BaseReduceTests and override "
122
+ "`_supports_reduction` instead.",
123
+ FutureWarning,
124
+ )
125
+ from pandas.tests.extension.base.reduce import BaseBooleanReduceTests
126
+
127
+ return BaseBooleanReduceTests
128
+
129
+ raise AttributeError(
130
+ f"module 'pandas.tests.extension.base' has no attribute '{name}'"
131
+ )
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (4.13 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/accumulate.cpython-312.pyc ADDED
Binary file (2.37 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/base.cpython-312.pyc ADDED
Binary file (382 Bytes). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/casting.cpython-312.pyc ADDED
Binary file (6.1 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/constructors.cpython-312.pyc ADDED
Binary file (10.3 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/dim2.cpython-312.pyc ADDED
Binary file (18.6 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/dtype.cpython-312.pyc ADDED
Binary file (7.64 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/getitem.cpython-312.pyc ADDED
Binary file (27 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/groupby.cpython-312.pyc ADDED
Binary file (10.1 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/index.cpython-312.pyc ADDED
Binary file (1.4 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/interface.cpython-312.pyc ADDED
Binary file (6.66 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/io.cpython-312.pyc ADDED
Binary file (2.37 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/methods.cpython-312.pyc ADDED
Binary file (43.2 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/missing.cpython-312.pyc ADDED
Binary file (11 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/ops.cpython-312.pyc ADDED
Binary file (14.1 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/printing.cpython-312.pyc ADDED
Binary file (2.7 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/reduce.cpython-312.pyc ADDED
Binary file (7.08 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/reshaping.cpython-312.pyc ADDED
Binary file (23 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/__pycache__/setitem.cpython-312.pyc ADDED
Binary file (27 kB). View file
 
lib/python3.12/site-packages/pandas/tests/extension/base/accumulate.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ import pandas as pd
4
+ import pandas._testing as tm
5
+
6
+
7
+ class BaseAccumulateTests:
8
+ """
9
+ Accumulation specific tests. Generally these only
10
+ make sense for numeric/boolean operations.
11
+ """
12
+
13
+ def _supports_accumulation(self, ser: pd.Series, op_name: str) -> bool:
14
+ # Do we expect this accumulation to be supported for this dtype?
15
+ # We default to assuming "no"; subclass authors should override here.
16
+ return False
17
+
18
+ def check_accumulate(self, ser: pd.Series, op_name: str, skipna: bool):
19
+ try:
20
+ alt = ser.astype("float64")
21
+ except TypeError:
22
+ # e.g. Period can't be cast to float64
23
+ alt = ser.astype(object)
24
+
25
+ result = getattr(ser, op_name)(skipna=skipna)
26
+ expected = getattr(alt, op_name)(skipna=skipna)
27
+ tm.assert_series_equal(result, expected, check_dtype=False)
28
+
29
+ @pytest.mark.parametrize("skipna", [True, False])
30
+ def test_accumulate_series(self, data, all_numeric_accumulations, skipna):
31
+ op_name = all_numeric_accumulations
32
+ ser = pd.Series(data)
33
+
34
+ if self._supports_accumulation(ser, op_name):
35
+ self.check_accumulate(ser, op_name, skipna)
36
+ else:
37
+ with pytest.raises((NotImplementedError, TypeError)):
38
+ # TODO: require TypeError for things that will _never_ work?
39
+ getattr(ser, op_name)(skipna=skipna)
lib/python3.12/site-packages/pandas/tests/extension/base/base.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ class BaseExtensionTests:
2
+ pass