Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +17 -0
- deepseek/lib/python3.10/site-packages/nvidia/curand/lib/libcurand.so.10 +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/internals.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/interval.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/lib.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/missing.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/ops.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/reshape.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/sparse.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/testing.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslib.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/dtypes.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/fields.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/nattype.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/period.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/timestamps.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/tzconversion.cpython-310-x86_64-linux-gnu.so +3 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/construction/__init__.py +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/construction/__pycache__/__init__.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/construction/__pycache__/test_extract_array.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/construction/test_extract_array.py +18 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__init__.py +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/__init__.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_common.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_concat.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_dtypes.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_generic.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_inference.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_missing.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__init__.py +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/__init__.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_can_hold_element.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_construct_from_scalar.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_construct_ndarray.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_construct_object_arr.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_dict_compat.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_downcast.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_find_common_type.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_infer_datetimelike.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_infer_dtype.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_maybe_box_native.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_promote.cpython-310.pyc +0 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_can_hold_element.py +79 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py +55 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py +36 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py +20 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_dict_compat.py +14 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_downcast.py +97 -0
- infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_find_common_type.py +175 -0
.gitattributes
CHANGED
|
@@ -2153,3 +2153,20 @@ infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/groupby.cpython-310-x86_6
|
|
| 2153 |
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/hashing.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2154 |
infer_4_30_0/lib/python3.10/site-packages/altair/vegalite/v5/schema/__pycache__/core.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 2155 |
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2153 |
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/hashing.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2154 |
infer_4_30_0/lib/python3.10/site-packages/altair/vegalite/v5/schema/__pycache__/core.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 2155 |
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/index.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2156 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslib.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2157 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/missing.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2158 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/sparse.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2159 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/lib.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2160 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/testing.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2161 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/internals.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2162 |
+
deepseek/lib/python3.10/site-packages/nvidia/curand/lib/libcurand.so.10 filter=lfs diff=lfs merge=lfs -text
|
| 2163 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/interval.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2164 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/tzconversion.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2165 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2166 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/reshape.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2167 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/ops.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2168 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/fields.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2169 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/period.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2170 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/timestamps.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2171 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/dtypes.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 2172 |
+
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/nattype.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
deepseek/lib/python3.10/site-packages/nvidia/curand/lib/libcurand.so.10
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dab8074b610b82a863a42eceda788e9b08364b545bab948509306b48c46018cf
|
| 3 |
+
size 96525744
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4cc2ad0a28ef26e4e23045485710310dcf84e73fee57d8c23fb5f7d47e2855a
|
| 3 |
+
size 2162216
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/internals.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6703cc1493b6d1ddd5d017acd97b822a3050a7b5939242111b8db20e3fc61cff
|
| 3 |
+
size 415592
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/interval.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:55d89065c918f5d8eae09cc25b7b21479c288e1b5c7b1b4d0ef83bf08af8d521
|
| 3 |
+
size 1528808
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/lib.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:524c92ee2ccb5583f8ca8adac91ae0afa3f43db0ea0456ab0aece9ccacb87273
|
| 3 |
+
size 933480
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/missing.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fe110ce6b3b10095c1c4c2f7745c02223aec6fcd4aa6cbc6782f83df72e77620
|
| 3 |
+
size 211400
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/ops.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c89028f0caa0df725cb3e89514edf7e8a4f4abdaace336d8bdf4040db291928
|
| 3 |
+
size 270472
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/reshape.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:379e0968c40307a1dd2ee93593b0ef888b1fcdffc9e7b4def9b6d41bcff80ce1
|
| 3 |
+
size 309608
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/sparse.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d9d4b81d1da2d284b1f61370c3e87b54de10f249a3debb14f7ad7bbf2c100523
|
| 3 |
+
size 988968
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/testing.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f5f7c4ecc85c1d9b0452ec4b031757c5e9aa0a893d46f47caead6a32115ffb73
|
| 3 |
+
size 127456
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslib.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f28ec212e94a75d6066e383be4243e1317de1339e61ad445b8a79f0aed216136
|
| 3 |
+
size 340264
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/dtypes.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a7bfd05b7ddda111668cc65264b433f64bca56626e8f077954f53cbbe4423319
|
| 3 |
+
size 202624
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/fields.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec8574945550f774a538695ccb3dac25ade35c419ec191d195dbe4919b73e2df
|
| 3 |
+
size 345064
|
infer_4_30_0/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:c6669ad3ce3c3efbda83d69097e963e85f8617d91a388da39b12bea940048b58
|
| 3 |
+
size 237184
|
infer_4_30_0/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:b08d39a4fb6d3dd4d20d5043a2029f6b4f1c380ef9c8b8a60322c919af50c687
|
| 3 |
+
size 532232
|
infer_4_30_0/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:fe91ba0e49ec3818ec96f0dd02eef9cb95774573e2ff136b47dba565e35c0105
|
| 3 |
+
size 660840
|
infer_4_30_0/lib/python3.10/site-packages/pandas/_libs/tslibs/tzconversion.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7b587802ccc8a49d5c0bb70c1fc96c45915d6a2705787de833db44fb9860db90
|
| 3 |
+
size 340840
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/construction/__init__.py
ADDED
|
File without changes
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/construction/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (183 Bytes). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/construction/__pycache__/test_extract_array.cpython-310.pyc
ADDED
|
Binary file (729 Bytes). View file
|
|
|
infer_4_30_0/lib/python3.10/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)
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__init__.py
ADDED
|
File without changes
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (177 Bytes). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_common.cpython-310.pyc
ADDED
|
Binary file (23.9 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_concat.cpython-310.pyc
ADDED
|
Binary file (2.08 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_dtypes.cpython-310.pyc
ADDED
|
Binary file (40.1 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_generic.cpython-310.pyc
ADDED
|
Binary file (4.63 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_inference.cpython-310.pyc
ADDED
|
Binary file (58.4 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/__pycache__/test_missing.cpython-310.pyc
ADDED
|
Binary file (23.3 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__init__.py
ADDED
|
File without changes
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (182 Bytes). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_can_hold_element.cpython-310.pyc
ADDED
|
Binary file (1.81 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_construct_from_scalar.cpython-310.pyc
ADDED
|
Binary file (1.85 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_construct_ndarray.cpython-310.pyc
ADDED
|
Binary file (1.6 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_construct_object_arr.cpython-310.pyc
ADDED
|
Binary file (968 Bytes). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_dict_compat.cpython-310.pyc
ADDED
|
Binary file (671 Bytes). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_downcast.cpython-310.pyc
ADDED
|
Binary file (2.56 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_find_common_type.cpython-310.pyc
ADDED
|
Binary file (4.11 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_infer_datetimelike.cpython-310.pyc
ADDED
|
Binary file (887 Bytes). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_infer_dtype.cpython-310.pyc
ADDED
|
Binary file (5.68 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_maybe_box_native.cpython-310.pyc
ADDED
|
Binary file (1.08 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/__pycache__/test_promote.cpython-310.pyc
ADDED
|
Binary file (10.6 kB). View file
|
|
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_can_hold_element.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
from pandas.core.dtypes.cast import can_hold_element
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def test_can_hold_element_range(any_int_numpy_dtype):
|
| 7 |
+
# GH#44261
|
| 8 |
+
dtype = np.dtype(any_int_numpy_dtype)
|
| 9 |
+
arr = np.array([], dtype=dtype)
|
| 10 |
+
|
| 11 |
+
rng = range(2, 127)
|
| 12 |
+
assert can_hold_element(arr, rng)
|
| 13 |
+
|
| 14 |
+
# negatives -> can't be held by uint dtypes
|
| 15 |
+
rng = range(-2, 127)
|
| 16 |
+
if dtype.kind == "i":
|
| 17 |
+
assert can_hold_element(arr, rng)
|
| 18 |
+
else:
|
| 19 |
+
assert not can_hold_element(arr, rng)
|
| 20 |
+
|
| 21 |
+
rng = range(2, 255)
|
| 22 |
+
if dtype == "int8":
|
| 23 |
+
assert not can_hold_element(arr, rng)
|
| 24 |
+
else:
|
| 25 |
+
assert can_hold_element(arr, rng)
|
| 26 |
+
|
| 27 |
+
rng = range(-255, 65537)
|
| 28 |
+
if dtype.kind == "u":
|
| 29 |
+
assert not can_hold_element(arr, rng)
|
| 30 |
+
elif dtype.itemsize < 4:
|
| 31 |
+
assert not can_hold_element(arr, rng)
|
| 32 |
+
else:
|
| 33 |
+
assert can_hold_element(arr, rng)
|
| 34 |
+
|
| 35 |
+
# empty
|
| 36 |
+
rng = range(-(10**10), -(10**10))
|
| 37 |
+
assert len(rng) == 0
|
| 38 |
+
# assert can_hold_element(arr, rng)
|
| 39 |
+
|
| 40 |
+
rng = range(10**10, 10**10)
|
| 41 |
+
assert len(rng) == 0
|
| 42 |
+
assert can_hold_element(arr, rng)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def test_can_hold_element_int_values_float_ndarray():
|
| 46 |
+
arr = np.array([], dtype=np.int64)
|
| 47 |
+
|
| 48 |
+
element = np.array([1.0, 2.0])
|
| 49 |
+
assert can_hold_element(arr, element)
|
| 50 |
+
|
| 51 |
+
assert not can_hold_element(arr, element + 0.5)
|
| 52 |
+
|
| 53 |
+
# integer but not losslessly castable to int64
|
| 54 |
+
element = np.array([3, 2**65], dtype=np.float64)
|
| 55 |
+
assert not can_hold_element(arr, element)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def test_can_hold_element_int8_int():
|
| 59 |
+
arr = np.array([], dtype=np.int8)
|
| 60 |
+
|
| 61 |
+
element = 2
|
| 62 |
+
assert can_hold_element(arr, element)
|
| 63 |
+
assert can_hold_element(arr, np.int8(element))
|
| 64 |
+
assert can_hold_element(arr, np.uint8(element))
|
| 65 |
+
assert can_hold_element(arr, np.int16(element))
|
| 66 |
+
assert can_hold_element(arr, np.uint16(element))
|
| 67 |
+
assert can_hold_element(arr, np.int32(element))
|
| 68 |
+
assert can_hold_element(arr, np.uint32(element))
|
| 69 |
+
assert can_hold_element(arr, np.int64(element))
|
| 70 |
+
assert can_hold_element(arr, np.uint64(element))
|
| 71 |
+
|
| 72 |
+
element = 2**9
|
| 73 |
+
assert not can_hold_element(arr, element)
|
| 74 |
+
assert not can_hold_element(arr, np.int16(element))
|
| 75 |
+
assert not can_hold_element(arr, np.uint16(element))
|
| 76 |
+
assert not can_hold_element(arr, np.int32(element))
|
| 77 |
+
assert not can_hold_element(arr, np.uint32(element))
|
| 78 |
+
assert not can_hold_element(arr, np.int64(element))
|
| 79 |
+
assert not can_hold_element(arr, np.uint64(element))
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import pytest
|
| 3 |
+
|
| 4 |
+
from pandas.core.dtypes.cast import construct_1d_arraylike_from_scalar
|
| 5 |
+
from pandas.core.dtypes.dtypes import CategoricalDtype
|
| 6 |
+
|
| 7 |
+
from pandas import (
|
| 8 |
+
Categorical,
|
| 9 |
+
Timedelta,
|
| 10 |
+
)
|
| 11 |
+
import pandas._testing as tm
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def test_cast_1d_array_like_from_scalar_categorical():
|
| 15 |
+
# see gh-19565
|
| 16 |
+
#
|
| 17 |
+
# Categorical result from scalar did not maintain
|
| 18 |
+
# categories and ordering of the passed dtype.
|
| 19 |
+
cats = ["a", "b", "c"]
|
| 20 |
+
cat_type = CategoricalDtype(categories=cats, ordered=False)
|
| 21 |
+
expected = Categorical(["a", "a"], categories=cats)
|
| 22 |
+
|
| 23 |
+
result = construct_1d_arraylike_from_scalar("a", len(expected), cat_type)
|
| 24 |
+
tm.assert_categorical_equal(result, expected)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def test_cast_1d_array_like_from_timestamp(fixed_now_ts):
|
| 28 |
+
# check we dont lose nanoseconds
|
| 29 |
+
ts = fixed_now_ts + Timedelta(1)
|
| 30 |
+
res = construct_1d_arraylike_from_scalar(ts, 2, np.dtype("M8[ns]"))
|
| 31 |
+
assert res[0] == ts
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def test_cast_1d_array_like_from_timedelta():
|
| 35 |
+
# check we dont lose nanoseconds
|
| 36 |
+
td = Timedelta(1)
|
| 37 |
+
res = construct_1d_arraylike_from_scalar(td, 2, np.dtype("m8[ns]"))
|
| 38 |
+
assert res[0] == td
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def test_cast_1d_array_like_mismatched_datetimelike():
|
| 42 |
+
td = np.timedelta64("NaT", "ns")
|
| 43 |
+
dt = np.datetime64("NaT", "ns")
|
| 44 |
+
|
| 45 |
+
with pytest.raises(TypeError, match="Cannot cast"):
|
| 46 |
+
construct_1d_arraylike_from_scalar(td, 2, dt.dtype)
|
| 47 |
+
|
| 48 |
+
with pytest.raises(TypeError, match="Cannot cast"):
|
| 49 |
+
construct_1d_arraylike_from_scalar(np.timedelta64(4, "ns"), 2, dt.dtype)
|
| 50 |
+
|
| 51 |
+
with pytest.raises(TypeError, match="Cannot cast"):
|
| 52 |
+
construct_1d_arraylike_from_scalar(dt, 2, td.dtype)
|
| 53 |
+
|
| 54 |
+
with pytest.raises(TypeError, match="Cannot cast"):
|
| 55 |
+
construct_1d_arraylike_from_scalar(np.datetime64(4, "ns"), 2, td.dtype)
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import pytest
|
| 3 |
+
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import pandas._testing as tm
|
| 6 |
+
from pandas.core.construction import sanitize_array
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@pytest.mark.parametrize(
|
| 10 |
+
"values, dtype, expected",
|
| 11 |
+
[
|
| 12 |
+
([1, 2, 3], None, np.array([1, 2, 3], dtype=np.int64)),
|
| 13 |
+
(np.array([1, 2, 3]), None, np.array([1, 2, 3])),
|
| 14 |
+
(["1", "2", None], None, np.array(["1", "2", None])),
|
| 15 |
+
(["1", "2", None], np.dtype("str"), np.array(["1", "2", None])),
|
| 16 |
+
([1, 2, None], np.dtype("str"), np.array(["1", "2", None])),
|
| 17 |
+
],
|
| 18 |
+
)
|
| 19 |
+
def test_construct_1d_ndarray_preserving_na(
|
| 20 |
+
values, dtype, expected, using_infer_string
|
| 21 |
+
):
|
| 22 |
+
result = sanitize_array(values, index=None, dtype=dtype)
|
| 23 |
+
if using_infer_string and expected.dtype == object and dtype is None:
|
| 24 |
+
tm.assert_extension_array_equal(result, pd.array(expected))
|
| 25 |
+
else:
|
| 26 |
+
tm.assert_numpy_array_equal(result, expected)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
@pytest.mark.parametrize("dtype", ["m8[ns]", "M8[ns]"])
|
| 30 |
+
def test_construct_1d_ndarray_preserving_na_datetimelike(dtype):
|
| 31 |
+
arr = np.arange(5, dtype=np.int64).view(dtype)
|
| 32 |
+
expected = np.array(list(arr), dtype=object)
|
| 33 |
+
assert all(isinstance(x, type(arr[0])) for x in expected)
|
| 34 |
+
|
| 35 |
+
result = sanitize_array(arr, index=None, dtype=np.dtype(object))
|
| 36 |
+
tm.assert_numpy_array_equal(result, expected)
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
@pytest.mark.parametrize("datum1", [1, 2.0, "3", (4, 5), [6, 7], None])
|
| 7 |
+
@pytest.mark.parametrize("datum2", [8, 9.0, "10", (11, 12), [13, 14], None])
|
| 8 |
+
def test_cast_1d_array(datum1, datum2):
|
| 9 |
+
data = [datum1, datum2]
|
| 10 |
+
result = construct_1d_object_array_from_listlike(data)
|
| 11 |
+
|
| 12 |
+
# Direct comparison fails: https://github.com/numpy/numpy/issues/10218
|
| 13 |
+
assert result.dtype == "object"
|
| 14 |
+
assert list(result) == data
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
@pytest.mark.parametrize("val", [1, 2.0, None])
|
| 18 |
+
def test_cast_1d_array_invalid_scalar(val):
|
| 19 |
+
with pytest.raises(TypeError, match="has no len()"):
|
| 20 |
+
construct_1d_object_array_from_listlike(val)
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_dict_compat.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
from pandas.core.dtypes.cast import dict_compat
|
| 4 |
+
|
| 5 |
+
from pandas import Timestamp
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def test_dict_compat():
|
| 9 |
+
data_datetime64 = {np.datetime64("1990-03-15"): 1, np.datetime64("2015-03-15"): 2}
|
| 10 |
+
data_unchanged = {1: 2, 3: 4, 5: 6}
|
| 11 |
+
expected = {Timestamp("1990-3-15"): 1, Timestamp("2015-03-15"): 2}
|
| 12 |
+
assert dict_compat(data_datetime64) == expected
|
| 13 |
+
assert dict_compat(expected) == expected
|
| 14 |
+
assert dict_compat(data_unchanged) == data_unchanged
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_downcast.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import decimal
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
|
| 7 |
+
|
| 8 |
+
from pandas import (
|
| 9 |
+
Series,
|
| 10 |
+
Timedelta,
|
| 11 |
+
)
|
| 12 |
+
import pandas._testing as tm
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@pytest.mark.parametrize(
|
| 16 |
+
"arr,dtype,expected",
|
| 17 |
+
[
|
| 18 |
+
(
|
| 19 |
+
np.array([8.5, 8.6, 8.7, 8.8, 8.9999999999995]),
|
| 20 |
+
"infer",
|
| 21 |
+
np.array([8.5, 8.6, 8.7, 8.8, 8.9999999999995]),
|
| 22 |
+
),
|
| 23 |
+
(
|
| 24 |
+
np.array([8.0, 8.0, 8.0, 8.0, 8.9999999999995]),
|
| 25 |
+
"infer",
|
| 26 |
+
np.array([8, 8, 8, 8, 9], dtype=np.int64),
|
| 27 |
+
),
|
| 28 |
+
(
|
| 29 |
+
np.array([8.0, 8.0, 8.0, 8.0, 9.0000000000005]),
|
| 30 |
+
"infer",
|
| 31 |
+
np.array([8, 8, 8, 8, 9], dtype=np.int64),
|
| 32 |
+
),
|
| 33 |
+
(
|
| 34 |
+
# This is a judgement call, but we do _not_ downcast Decimal
|
| 35 |
+
# objects
|
| 36 |
+
np.array([decimal.Decimal(0.0)]),
|
| 37 |
+
"int64",
|
| 38 |
+
np.array([decimal.Decimal(0.0)]),
|
| 39 |
+
),
|
| 40 |
+
(
|
| 41 |
+
# GH#45837
|
| 42 |
+
np.array([Timedelta(days=1), Timedelta(days=2)], dtype=object),
|
| 43 |
+
"infer",
|
| 44 |
+
np.array([1, 2], dtype="m8[D]").astype("m8[ns]"),
|
| 45 |
+
),
|
| 46 |
+
# TODO: similar for dt64, dt64tz, Period, Interval?
|
| 47 |
+
],
|
| 48 |
+
)
|
| 49 |
+
def test_downcast(arr, expected, dtype):
|
| 50 |
+
result = maybe_downcast_to_dtype(arr, dtype)
|
| 51 |
+
tm.assert_numpy_array_equal(result, expected)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def test_downcast_booleans():
|
| 55 |
+
# see gh-16875: coercing of booleans.
|
| 56 |
+
ser = Series([True, True, False])
|
| 57 |
+
result = maybe_downcast_to_dtype(ser, np.dtype(np.float64))
|
| 58 |
+
|
| 59 |
+
expected = ser.values
|
| 60 |
+
tm.assert_numpy_array_equal(result, expected)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def test_downcast_conversion_no_nan(any_real_numpy_dtype):
|
| 64 |
+
dtype = any_real_numpy_dtype
|
| 65 |
+
expected = np.array([1, 2])
|
| 66 |
+
arr = np.array([1.0, 2.0], dtype=dtype)
|
| 67 |
+
|
| 68 |
+
result = maybe_downcast_to_dtype(arr, "infer")
|
| 69 |
+
tm.assert_almost_equal(result, expected, check_dtype=False)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def test_downcast_conversion_nan(float_numpy_dtype):
|
| 73 |
+
dtype = float_numpy_dtype
|
| 74 |
+
data = [1.0, 2.0, np.nan]
|
| 75 |
+
|
| 76 |
+
expected = np.array(data, dtype=dtype)
|
| 77 |
+
arr = np.array(data, dtype=dtype)
|
| 78 |
+
|
| 79 |
+
result = maybe_downcast_to_dtype(arr, "infer")
|
| 80 |
+
tm.assert_almost_equal(result, expected)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def test_downcast_conversion_empty(any_real_numpy_dtype):
|
| 84 |
+
dtype = any_real_numpy_dtype
|
| 85 |
+
arr = np.array([], dtype=dtype)
|
| 86 |
+
result = maybe_downcast_to_dtype(arr, np.dtype("int64"))
|
| 87 |
+
tm.assert_numpy_array_equal(result, np.array([], dtype=np.int64))
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
@pytest.mark.parametrize("klass", [np.datetime64, np.timedelta64])
|
| 91 |
+
def test_datetime_likes_nan(klass):
|
| 92 |
+
dtype = klass.__name__ + "[ns]"
|
| 93 |
+
arr = np.array([1, 2, np.nan])
|
| 94 |
+
|
| 95 |
+
exp = np.array([1, 2, klass("NaT")], dtype)
|
| 96 |
+
res = maybe_downcast_to_dtype(arr, dtype)
|
| 97 |
+
tm.assert_numpy_array_equal(res, exp)
|
infer_4_30_0/lib/python3.10/site-packages/pandas/tests/dtypes/cast/test_find_common_type.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import pytest
|
| 3 |
+
|
| 4 |
+
from pandas.core.dtypes.cast import find_common_type
|
| 5 |
+
from pandas.core.dtypes.common import pandas_dtype
|
| 6 |
+
from pandas.core.dtypes.dtypes import (
|
| 7 |
+
CategoricalDtype,
|
| 8 |
+
DatetimeTZDtype,
|
| 9 |
+
IntervalDtype,
|
| 10 |
+
PeriodDtype,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
from pandas import (
|
| 14 |
+
Categorical,
|
| 15 |
+
Index,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@pytest.mark.parametrize(
|
| 20 |
+
"source_dtypes,expected_common_dtype",
|
| 21 |
+
[
|
| 22 |
+
((np.int64,), np.int64),
|
| 23 |
+
((np.uint64,), np.uint64),
|
| 24 |
+
((np.float32,), np.float32),
|
| 25 |
+
((object,), object),
|
| 26 |
+
# Into ints.
|
| 27 |
+
((np.int16, np.int64), np.int64),
|
| 28 |
+
((np.int32, np.uint32), np.int64),
|
| 29 |
+
((np.uint16, np.uint64), np.uint64),
|
| 30 |
+
# Into floats.
|
| 31 |
+
((np.float16, np.float32), np.float32),
|
| 32 |
+
((np.float16, np.int16), np.float32),
|
| 33 |
+
((np.float32, np.int16), np.float32),
|
| 34 |
+
((np.uint64, np.int64), np.float64),
|
| 35 |
+
((np.int16, np.float64), np.float64),
|
| 36 |
+
((np.float16, np.int64), np.float64),
|
| 37 |
+
# Into others.
|
| 38 |
+
((np.complex128, np.int32), np.complex128),
|
| 39 |
+
((object, np.float32), object),
|
| 40 |
+
((object, np.int16), object),
|
| 41 |
+
# Bool with int.
|
| 42 |
+
((np.dtype("bool"), np.int64), object),
|
| 43 |
+
((np.dtype("bool"), np.int32), object),
|
| 44 |
+
((np.dtype("bool"), np.int16), object),
|
| 45 |
+
((np.dtype("bool"), np.int8), object),
|
| 46 |
+
((np.dtype("bool"), np.uint64), object),
|
| 47 |
+
((np.dtype("bool"), np.uint32), object),
|
| 48 |
+
((np.dtype("bool"), np.uint16), object),
|
| 49 |
+
((np.dtype("bool"), np.uint8), object),
|
| 50 |
+
# Bool with float.
|
| 51 |
+
((np.dtype("bool"), np.float64), object),
|
| 52 |
+
((np.dtype("bool"), np.float32), object),
|
| 53 |
+
(
|
| 54 |
+
(np.dtype("datetime64[ns]"), np.dtype("datetime64[ns]")),
|
| 55 |
+
np.dtype("datetime64[ns]"),
|
| 56 |
+
),
|
| 57 |
+
(
|
| 58 |
+
(np.dtype("timedelta64[ns]"), np.dtype("timedelta64[ns]")),
|
| 59 |
+
np.dtype("timedelta64[ns]"),
|
| 60 |
+
),
|
| 61 |
+
(
|
| 62 |
+
(np.dtype("datetime64[ns]"), np.dtype("datetime64[ms]")),
|
| 63 |
+
np.dtype("datetime64[ns]"),
|
| 64 |
+
),
|
| 65 |
+
(
|
| 66 |
+
(np.dtype("timedelta64[ms]"), np.dtype("timedelta64[ns]")),
|
| 67 |
+
np.dtype("timedelta64[ns]"),
|
| 68 |
+
),
|
| 69 |
+
((np.dtype("datetime64[ns]"), np.dtype("timedelta64[ns]")), object),
|
| 70 |
+
((np.dtype("datetime64[ns]"), np.int64), object),
|
| 71 |
+
],
|
| 72 |
+
)
|
| 73 |
+
def test_numpy_dtypes(source_dtypes, expected_common_dtype):
|
| 74 |
+
source_dtypes = [pandas_dtype(x) for x in source_dtypes]
|
| 75 |
+
assert find_common_type(source_dtypes) == expected_common_dtype
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def test_raises_empty_input():
|
| 79 |
+
with pytest.raises(ValueError, match="no types given"):
|
| 80 |
+
find_common_type([])
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
@pytest.mark.parametrize(
|
| 84 |
+
"dtypes,exp_type",
|
| 85 |
+
[
|
| 86 |
+
([CategoricalDtype()], "category"),
|
| 87 |
+
([object, CategoricalDtype()], object),
|
| 88 |
+
([CategoricalDtype(), CategoricalDtype()], "category"),
|
| 89 |
+
],
|
| 90 |
+
)
|
| 91 |
+
def test_categorical_dtype(dtypes, exp_type):
|
| 92 |
+
assert find_common_type(dtypes) == exp_type
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def test_datetimetz_dtype_match():
|
| 96 |
+
dtype = DatetimeTZDtype(unit="ns", tz="US/Eastern")
|
| 97 |
+
assert find_common_type([dtype, dtype]) == "datetime64[ns, US/Eastern]"
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
@pytest.mark.parametrize(
|
| 101 |
+
"dtype2",
|
| 102 |
+
[
|
| 103 |
+
DatetimeTZDtype(unit="ns", tz="Asia/Tokyo"),
|
| 104 |
+
np.dtype("datetime64[ns]"),
|
| 105 |
+
object,
|
| 106 |
+
np.int64,
|
| 107 |
+
],
|
| 108 |
+
)
|
| 109 |
+
def test_datetimetz_dtype_mismatch(dtype2):
|
| 110 |
+
dtype = DatetimeTZDtype(unit="ns", tz="US/Eastern")
|
| 111 |
+
assert find_common_type([dtype, dtype2]) == object
|
| 112 |
+
assert find_common_type([dtype2, dtype]) == object
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def test_period_dtype_match():
|
| 116 |
+
dtype = PeriodDtype(freq="D")
|
| 117 |
+
assert find_common_type([dtype, dtype]) == "period[D]"
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
@pytest.mark.parametrize(
|
| 121 |
+
"dtype2",
|
| 122 |
+
[
|
| 123 |
+
DatetimeTZDtype(unit="ns", tz="Asia/Tokyo"),
|
| 124 |
+
PeriodDtype(freq="2D"),
|
| 125 |
+
PeriodDtype(freq="h"),
|
| 126 |
+
np.dtype("datetime64[ns]"),
|
| 127 |
+
object,
|
| 128 |
+
np.int64,
|
| 129 |
+
],
|
| 130 |
+
)
|
| 131 |
+
def test_period_dtype_mismatch(dtype2):
|
| 132 |
+
dtype = PeriodDtype(freq="D")
|
| 133 |
+
assert find_common_type([dtype, dtype2]) == object
|
| 134 |
+
assert find_common_type([dtype2, dtype]) == object
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
interval_dtypes = [
|
| 138 |
+
IntervalDtype(np.int64, "right"),
|
| 139 |
+
IntervalDtype(np.float64, "right"),
|
| 140 |
+
IntervalDtype(np.uint64, "right"),
|
| 141 |
+
IntervalDtype(DatetimeTZDtype(unit="ns", tz="US/Eastern"), "right"),
|
| 142 |
+
IntervalDtype("M8[ns]", "right"),
|
| 143 |
+
IntervalDtype("m8[ns]", "right"),
|
| 144 |
+
]
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
@pytest.mark.parametrize("left", interval_dtypes)
|
| 148 |
+
@pytest.mark.parametrize("right", interval_dtypes)
|
| 149 |
+
def test_interval_dtype(left, right):
|
| 150 |
+
result = find_common_type([left, right])
|
| 151 |
+
|
| 152 |
+
if left is right:
|
| 153 |
+
assert result is left
|
| 154 |
+
|
| 155 |
+
elif left.subtype.kind in ["i", "u", "f"]:
|
| 156 |
+
# i.e. numeric
|
| 157 |
+
if right.subtype.kind in ["i", "u", "f"]:
|
| 158 |
+
# both numeric -> common numeric subtype
|
| 159 |
+
expected = IntervalDtype(np.float64, "right")
|
| 160 |
+
assert result == expected
|
| 161 |
+
else:
|
| 162 |
+
assert result == object
|
| 163 |
+
|
| 164 |
+
else:
|
| 165 |
+
assert result == object
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
@pytest.mark.parametrize("dtype", interval_dtypes)
|
| 169 |
+
def test_interval_dtype_with_categorical(dtype):
|
| 170 |
+
obj = Index([], dtype=dtype)
|
| 171 |
+
|
| 172 |
+
cat = Categorical([], categories=obj)
|
| 173 |
+
|
| 174 |
+
result = find_common_type([dtype, cat.dtype])
|
| 175 |
+
assert result == dtype
|