ZTWHHH commited on
Commit
5535acc
·
verified ·
1 Parent(s): 2182997

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 +1 -0
  2. vllm/lib/python3.10/site-packages/pandas/io/formats/__pycache__/style.cpython-310.pyc +3 -0
  3. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/__init__.cpython-310.pyc +0 -0
  4. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/masked_shared.cpython-310.pyc +0 -0
  5. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_array.cpython-310.pyc +0 -0
  6. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimelike.cpython-310.pyc +0 -0
  7. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimes.cpython-310.pyc +0 -0
  8. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_ndarray_backed.cpython-310.pyc +0 -0
  9. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_period.cpython-310.pyc +0 -0
  10. vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_timedeltas.cpython-310.pyc +0 -0
  11. vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/__init__.cpython-310.pyc +0 -0
  12. vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_comparison.cpython-310.pyc +0 -0
  13. vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_construction.cpython-310.pyc +0 -0
  14. vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_indexing.cpython-310.pyc +0 -0
  15. vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_logical.cpython-310.pyc +0 -0
  16. vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_reduction.cpython-310.pyc +0 -0
  17. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__init__.py +0 -0
  18. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/__init__.cpython-310.pyc +0 -0
  19. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/conftest.cpython-310.pyc +0 -0
  20. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_comparison.cpython-310.pyc +0 -0
  21. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_concat.cpython-310.pyc +0 -0
  22. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_construction.cpython-310.pyc +0 -0
  23. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_dtypes.cpython-310.pyc +0 -0
  24. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_function.cpython-310.pyc +0 -0
  25. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_indexing.cpython-310.pyc +0 -0
  26. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_reduction.cpython-310.pyc +0 -0
  27. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_repr.cpython-310.pyc +0 -0
  28. vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/test_reduction.py +125 -0
  29. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__init__.py +0 -0
  30. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/__init__.cpython-310.pyc +0 -0
  31. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/test_formats.cpython-310.pyc +0 -0
  32. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/test_interval.cpython-310.pyc +0 -0
  33. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/test_interval_pyarrow.cpython-310.pyc +0 -0
  34. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/test_astype.py +28 -0
  35. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py +160 -0
  36. vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/test_overlaps.py +93 -0
  37. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__init__.py +0 -0
  38. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/__init__.cpython-310.pyc +0 -0
  39. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arithmetic.cpython-310.pyc +0 -0
  40. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arrow_compat.cpython-310.pyc +0 -0
  41. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_function.cpython-310.pyc +0 -0
  42. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_indexing.cpython-310.pyc +0 -0
  43. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_arithmetic.py +248 -0
  44. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_arrow_compat.py +209 -0
  45. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_function.py +74 -0
  46. vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_indexing.py +60 -0
  47. vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__init__.py +0 -0
  48. vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/__init__.cpython-310.pyc +0 -0
  49. vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_indexing.cpython-310.pyc +0 -0
  50. vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_numpy.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -934,3 +934,4 @@ vllm/lib/python3.10/site-packages/pandas/core/__pycache__/frame.cpython-310.pyc
934
  vllm/lib/python3.10/site-packages/pandas/core/__pycache__/series.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
935
  vllm/lib/python3.10/site-packages/pandas/io/__pycache__/pytables.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
936
  vllm/lib/python3.10/site-packages/pandas/core/__pycache__/generic.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
 
 
934
  vllm/lib/python3.10/site-packages/pandas/core/__pycache__/series.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
935
  vllm/lib/python3.10/site-packages/pandas/io/__pycache__/pytables.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
936
  vllm/lib/python3.10/site-packages/pandas/core/__pycache__/generic.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
937
+ vllm/lib/python3.10/site-packages/pandas/io/formats/__pycache__/style.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
vllm/lib/python3.10/site-packages/pandas/io/formats/__pycache__/style.cpython-310.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:815c2f1c7a022ecdd920ef4b0c380d7bd5c9e738e5cb09f3c24a258ed285d0b7
3
+ size 137381
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (169 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/masked_shared.cpython-310.pyc ADDED
Binary file (4.32 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_array.cpython-310.pyc ADDED
Binary file (9.3 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimelike.cpython-310.pyc ADDED
Binary file (35.5 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_datetimes.cpython-310.pyc ADDED
Binary file (24.8 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_ndarray_backed.cpython-310.pyc ADDED
Binary file (2.28 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_period.cpython-310.pyc ADDED
Binary file (5.69 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/__pycache__/test_timedeltas.cpython-310.pyc ADDED
Binary file (10.3 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (177 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_comparison.cpython-310.pyc ADDED
Binary file (2.28 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_construction.cpython-310.pyc ADDED
Binary file (8.28 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_indexing.cpython-310.pyc ADDED
Binary file (624 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_logical.cpython-310.pyc ADDED
Binary file (6.78 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/boolean/__pycache__/test_reduction.cpython-310.pyc ADDED
Binary file (1.73 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__init__.py ADDED
File without changes
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (177 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/conftest.cpython-310.pyc ADDED
Binary file (1.77 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_comparison.cpython-310.pyc ADDED
Binary file (1.47 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_concat.cpython-310.pyc ADDED
Binary file (1.82 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_construction.cpython-310.pyc ADDED
Binary file (6.79 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_dtypes.cpython-310.pyc ADDED
Binary file (7.16 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_function.cpython-310.pyc ADDED
Binary file (5.88 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_indexing.cpython-310.pyc ADDED
Binary file (786 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_reduction.cpython-310.pyc ADDED
Binary file (2.93 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/__pycache__/test_repr.cpython-310.pyc ADDED
Binary file (1.92 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/integer/test_reduction.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ from pandas import (
6
+ DataFrame,
7
+ Series,
8
+ array,
9
+ )
10
+ import pandas._testing as tm
11
+
12
+
13
+ @pytest.mark.parametrize(
14
+ "op, expected",
15
+ [
16
+ ["sum", np.int64(3)],
17
+ ["prod", np.int64(2)],
18
+ ["min", np.int64(1)],
19
+ ["max", np.int64(2)],
20
+ ["mean", np.float64(1.5)],
21
+ ["median", np.float64(1.5)],
22
+ ["var", np.float64(0.5)],
23
+ ["std", np.float64(0.5**0.5)],
24
+ ["skew", pd.NA],
25
+ ["kurt", pd.NA],
26
+ ["any", True],
27
+ ["all", True],
28
+ ],
29
+ )
30
+ def test_series_reductions(op, expected):
31
+ ser = Series([1, 2], dtype="Int64")
32
+ result = getattr(ser, op)()
33
+ tm.assert_equal(result, expected)
34
+
35
+
36
+ @pytest.mark.parametrize(
37
+ "op, expected",
38
+ [
39
+ ["sum", Series([3], index=["a"], dtype="Int64")],
40
+ ["prod", Series([2], index=["a"], dtype="Int64")],
41
+ ["min", Series([1], index=["a"], dtype="Int64")],
42
+ ["max", Series([2], index=["a"], dtype="Int64")],
43
+ ["mean", Series([1.5], index=["a"], dtype="Float64")],
44
+ ["median", Series([1.5], index=["a"], dtype="Float64")],
45
+ ["var", Series([0.5], index=["a"], dtype="Float64")],
46
+ ["std", Series([0.5**0.5], index=["a"], dtype="Float64")],
47
+ ["skew", Series([pd.NA], index=["a"], dtype="Float64")],
48
+ ["kurt", Series([pd.NA], index=["a"], dtype="Float64")],
49
+ ["any", Series([True], index=["a"], dtype="boolean")],
50
+ ["all", Series([True], index=["a"], dtype="boolean")],
51
+ ],
52
+ )
53
+ def test_dataframe_reductions(op, expected):
54
+ df = DataFrame({"a": array([1, 2], dtype="Int64")})
55
+ result = getattr(df, op)()
56
+ tm.assert_series_equal(result, expected)
57
+
58
+
59
+ @pytest.mark.parametrize(
60
+ "op, expected",
61
+ [
62
+ ["sum", array([1, 3], dtype="Int64")],
63
+ ["prod", array([1, 3], dtype="Int64")],
64
+ ["min", array([1, 3], dtype="Int64")],
65
+ ["max", array([1, 3], dtype="Int64")],
66
+ ["mean", array([1, 3], dtype="Float64")],
67
+ ["median", array([1, 3], dtype="Float64")],
68
+ ["var", array([pd.NA], dtype="Float64")],
69
+ ["std", array([pd.NA], dtype="Float64")],
70
+ ["skew", array([pd.NA], dtype="Float64")],
71
+ ["any", array([True, True], dtype="boolean")],
72
+ ["all", array([True, True], dtype="boolean")],
73
+ ],
74
+ )
75
+ def test_groupby_reductions(op, expected):
76
+ df = DataFrame(
77
+ {
78
+ "A": ["a", "b", "b"],
79
+ "B": array([1, None, 3], dtype="Int64"),
80
+ }
81
+ )
82
+ result = getattr(df.groupby("A"), op)()
83
+ expected = DataFrame(expected, index=pd.Index(["a", "b"], name="A"), columns=["B"])
84
+
85
+ tm.assert_frame_equal(result, expected)
86
+
87
+
88
+ @pytest.mark.parametrize(
89
+ "op, expected",
90
+ [
91
+ ["sum", Series([4, 4], index=["B", "C"], dtype="Float64")],
92
+ ["prod", Series([3, 3], index=["B", "C"], dtype="Float64")],
93
+ ["min", Series([1, 1], index=["B", "C"], dtype="Float64")],
94
+ ["max", Series([3, 3], index=["B", "C"], dtype="Float64")],
95
+ ["mean", Series([2, 2], index=["B", "C"], dtype="Float64")],
96
+ ["median", Series([2, 2], index=["B", "C"], dtype="Float64")],
97
+ ["var", Series([2, 2], index=["B", "C"], dtype="Float64")],
98
+ ["std", Series([2**0.5, 2**0.5], index=["B", "C"], dtype="Float64")],
99
+ ["skew", Series([pd.NA, pd.NA], index=["B", "C"], dtype="Float64")],
100
+ ["kurt", Series([pd.NA, pd.NA], index=["B", "C"], dtype="Float64")],
101
+ ["any", Series([True, True, True], index=["A", "B", "C"], dtype="boolean")],
102
+ ["all", Series([True, True, True], index=["A", "B", "C"], dtype="boolean")],
103
+ ],
104
+ )
105
+ def test_mixed_reductions(op, expected, using_infer_string):
106
+ if op in ["any", "all"] and using_infer_string:
107
+ expected = expected.astype("bool")
108
+ df = DataFrame(
109
+ {
110
+ "A": ["a", "b", "b"],
111
+ "B": [1, None, 3],
112
+ "C": array([1, None, 3], dtype="Int64"),
113
+ }
114
+ )
115
+
116
+ # series
117
+ result = getattr(df.C, op)()
118
+ tm.assert_equal(result, expected["C"])
119
+
120
+ # frame
121
+ if op in ["any", "all"]:
122
+ result = getattr(df, op)()
123
+ else:
124
+ result = getattr(df, op)(numeric_only=True)
125
+ tm.assert_series_equal(result, expected)
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__init__.py ADDED
File without changes
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (178 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/test_formats.cpython-310.pyc ADDED
Binary file (528 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/test_interval.cpython-310.pyc ADDED
Binary file (7.51 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/__pycache__/test_interval_pyarrow.cpython-310.pyc ADDED
Binary file (4.4 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/test_astype.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from pandas import (
4
+ Categorical,
5
+ CategoricalDtype,
6
+ Index,
7
+ IntervalIndex,
8
+ )
9
+ import pandas._testing as tm
10
+
11
+
12
+ class TestAstype:
13
+ @pytest.mark.parametrize("ordered", [True, False])
14
+ def test_astype_categorical_retains_ordered(self, ordered):
15
+ index = IntervalIndex.from_breaks(range(5))
16
+ arr = index._data
17
+
18
+ dtype = CategoricalDtype(None, ordered=ordered)
19
+
20
+ expected = Categorical(list(arr), ordered=ordered)
21
+ result = arr.astype(dtype)
22
+ assert result.ordered is ordered
23
+ tm.assert_categorical_equal(result, expected)
24
+
25
+ # test IntervalIndex.astype while we're at it.
26
+ result = index.astype(dtype)
27
+ expected = Index(expected)
28
+ tm.assert_index_equal(result, expected)
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+ from pandas.core.arrays import IntervalArray
7
+
8
+
9
+ def test_arrow_extension_type():
10
+ pa = pytest.importorskip("pyarrow")
11
+
12
+ from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
13
+
14
+ p1 = ArrowIntervalType(pa.int64(), "left")
15
+ p2 = ArrowIntervalType(pa.int64(), "left")
16
+ p3 = ArrowIntervalType(pa.int64(), "right")
17
+
18
+ assert p1.closed == "left"
19
+ assert p1 == p2
20
+ assert p1 != p3
21
+ assert hash(p1) == hash(p2)
22
+ assert hash(p1) != hash(p3)
23
+
24
+
25
+ def test_arrow_array():
26
+ pa = pytest.importorskip("pyarrow")
27
+
28
+ from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
29
+
30
+ intervals = pd.interval_range(1, 5, freq=1).array
31
+
32
+ result = pa.array(intervals)
33
+ assert isinstance(result.type, ArrowIntervalType)
34
+ assert result.type.closed == intervals.closed
35
+ assert result.type.subtype == pa.int64()
36
+ assert result.storage.field("left").equals(pa.array([1, 2, 3, 4], type="int64"))
37
+ assert result.storage.field("right").equals(pa.array([2, 3, 4, 5], type="int64"))
38
+
39
+ expected = pa.array([{"left": i, "right": i + 1} for i in range(1, 5)])
40
+ assert result.storage.equals(expected)
41
+
42
+ # convert to its storage type
43
+ result = pa.array(intervals, type=expected.type)
44
+ assert result.equals(expected)
45
+
46
+ # unsupported conversions
47
+ with pytest.raises(TypeError, match="Not supported to convert IntervalArray"):
48
+ pa.array(intervals, type="float64")
49
+
50
+ with pytest.raises(TypeError, match="Not supported to convert IntervalArray"):
51
+ pa.array(intervals, type=ArrowIntervalType(pa.float64(), "left"))
52
+
53
+
54
+ def test_arrow_array_missing():
55
+ pa = pytest.importorskip("pyarrow")
56
+
57
+ from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
58
+
59
+ arr = IntervalArray.from_breaks([0.0, 1.0, 2.0, 3.0])
60
+ arr[1] = None
61
+
62
+ result = pa.array(arr)
63
+ assert isinstance(result.type, ArrowIntervalType)
64
+ assert result.type.closed == arr.closed
65
+ assert result.type.subtype == pa.float64()
66
+
67
+ # fields have missing values (not NaN)
68
+ left = pa.array([0.0, None, 2.0], type="float64")
69
+ right = pa.array([1.0, None, 3.0], type="float64")
70
+ assert result.storage.field("left").equals(left)
71
+ assert result.storage.field("right").equals(right)
72
+
73
+ # structarray itself also has missing values on the array level
74
+ vals = [
75
+ {"left": 0.0, "right": 1.0},
76
+ {"left": None, "right": None},
77
+ {"left": 2.0, "right": 3.0},
78
+ ]
79
+ expected = pa.StructArray.from_pandas(vals, mask=np.array([False, True, False]))
80
+ assert result.storage.equals(expected)
81
+
82
+
83
+ @pytest.mark.filterwarnings(
84
+ "ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
85
+ )
86
+ @pytest.mark.parametrize(
87
+ "breaks",
88
+ [[0.0, 1.0, 2.0, 3.0], pd.date_range("2017", periods=4, freq="D")],
89
+ ids=["float", "datetime64[ns]"],
90
+ )
91
+ def test_arrow_table_roundtrip(breaks):
92
+ pa = pytest.importorskip("pyarrow")
93
+
94
+ from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
95
+
96
+ arr = IntervalArray.from_breaks(breaks)
97
+ arr[1] = None
98
+ df = pd.DataFrame({"a": arr})
99
+
100
+ table = pa.table(df)
101
+ assert isinstance(table.field("a").type, ArrowIntervalType)
102
+ result = table.to_pandas()
103
+ assert isinstance(result["a"].dtype, pd.IntervalDtype)
104
+ tm.assert_frame_equal(result, df)
105
+
106
+ table2 = pa.concat_tables([table, table])
107
+ result = table2.to_pandas()
108
+ expected = pd.concat([df, df], ignore_index=True)
109
+ tm.assert_frame_equal(result, expected)
110
+
111
+ # GH#41040
112
+ table = pa.table(
113
+ [pa.chunked_array([], type=table.column(0).type)], schema=table.schema
114
+ )
115
+ result = table.to_pandas()
116
+ tm.assert_frame_equal(result, expected[0:0])
117
+
118
+
119
+ @pytest.mark.filterwarnings(
120
+ "ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
121
+ )
122
+ @pytest.mark.parametrize(
123
+ "breaks",
124
+ [[0.0, 1.0, 2.0, 3.0], pd.date_range("2017", periods=4, freq="D")],
125
+ ids=["float", "datetime64[ns]"],
126
+ )
127
+ def test_arrow_table_roundtrip_without_metadata(breaks):
128
+ pa = pytest.importorskip("pyarrow")
129
+
130
+ arr = IntervalArray.from_breaks(breaks)
131
+ arr[1] = None
132
+ df = pd.DataFrame({"a": arr})
133
+
134
+ table = pa.table(df)
135
+ # remove the metadata
136
+ table = table.replace_schema_metadata()
137
+ assert table.schema.metadata is None
138
+
139
+ result = table.to_pandas()
140
+ assert isinstance(result["a"].dtype, pd.IntervalDtype)
141
+ tm.assert_frame_equal(result, df)
142
+
143
+
144
+ def test_from_arrow_from_raw_struct_array():
145
+ # in case pyarrow lost the Interval extension type (eg on parquet roundtrip
146
+ # with datetime64[ns] subtype, see GH-45881), still allow conversion
147
+ # from arrow to IntervalArray
148
+ pa = pytest.importorskip("pyarrow")
149
+
150
+ arr = pa.array([{"left": 0, "right": 1}, {"left": 1, "right": 2}])
151
+ dtype = pd.IntervalDtype(np.dtype("int64"), closed="neither")
152
+
153
+ result = dtype.__from_arrow__(arr)
154
+ expected = IntervalArray.from_breaks(
155
+ np.array([0, 1, 2], dtype="int64"), closed="neither"
156
+ )
157
+ tm.assert_extension_array_equal(result, expected)
158
+
159
+ result = dtype.__from_arrow__(pa.chunked_array([arr]))
160
+ tm.assert_extension_array_equal(result, expected)
vllm/lib/python3.10/site-packages/pandas/tests/arrays/interval/test_overlaps.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for Interval-Interval operations, such as overlaps, contains, etc."""
2
+ import numpy as np
3
+ import pytest
4
+
5
+ from pandas import (
6
+ Interval,
7
+ IntervalIndex,
8
+ Timedelta,
9
+ Timestamp,
10
+ )
11
+ import pandas._testing as tm
12
+ from pandas.core.arrays import IntervalArray
13
+
14
+
15
+ @pytest.fixture(params=[IntervalArray, IntervalIndex])
16
+ def constructor(request):
17
+ """
18
+ Fixture for testing both interval container classes.
19
+ """
20
+ return request.param
21
+
22
+
23
+ @pytest.fixture(
24
+ params=[
25
+ (Timedelta("0 days"), Timedelta("1 day")),
26
+ (Timestamp("2018-01-01"), Timedelta("1 day")),
27
+ (0, 1),
28
+ ],
29
+ ids=lambda x: type(x[0]).__name__,
30
+ )
31
+ def start_shift(request):
32
+ """
33
+ Fixture for generating intervals of different types from a start value
34
+ and a shift value that can be added to start to generate an endpoint.
35
+ """
36
+ return request.param
37
+
38
+
39
+ class TestOverlaps:
40
+ def test_overlaps_interval(self, constructor, start_shift, closed, other_closed):
41
+ start, shift = start_shift
42
+ interval = Interval(start, start + 3 * shift, other_closed)
43
+
44
+ # intervals: identical, nested, spanning, partial, adjacent, disjoint
45
+ tuples = [
46
+ (start, start + 3 * shift),
47
+ (start + shift, start + 2 * shift),
48
+ (start - shift, start + 4 * shift),
49
+ (start + 2 * shift, start + 4 * shift),
50
+ (start + 3 * shift, start + 4 * shift),
51
+ (start + 4 * shift, start + 5 * shift),
52
+ ]
53
+ interval_container = constructor.from_tuples(tuples, closed)
54
+
55
+ adjacent = interval.closed_right and interval_container.closed_left
56
+ expected = np.array([True, True, True, True, adjacent, False])
57
+ result = interval_container.overlaps(interval)
58
+ tm.assert_numpy_array_equal(result, expected)
59
+
60
+ @pytest.mark.parametrize("other_constructor", [IntervalArray, IntervalIndex])
61
+ def test_overlaps_interval_container(self, constructor, other_constructor):
62
+ # TODO: modify this test when implemented
63
+ interval_container = constructor.from_breaks(range(5))
64
+ other_container = other_constructor.from_breaks(range(5))
65
+ with pytest.raises(NotImplementedError, match="^$"):
66
+ interval_container.overlaps(other_container)
67
+
68
+ def test_overlaps_na(self, constructor, start_shift):
69
+ """NA values are marked as False"""
70
+ start, shift = start_shift
71
+ interval = Interval(start, start + shift)
72
+
73
+ tuples = [
74
+ (start, start + shift),
75
+ np.nan,
76
+ (start + 2 * shift, start + 3 * shift),
77
+ ]
78
+ interval_container = constructor.from_tuples(tuples)
79
+
80
+ expected = np.array([True, False, False])
81
+ result = interval_container.overlaps(interval)
82
+ tm.assert_numpy_array_equal(result, expected)
83
+
84
+ @pytest.mark.parametrize(
85
+ "other",
86
+ [10, True, "foo", Timedelta("1 day"), Timestamp("2018-01-01")],
87
+ ids=lambda x: type(x).__name__,
88
+ )
89
+ def test_overlaps_invalid_type(self, constructor, other):
90
+ interval_container = constructor.from_breaks(range(5))
91
+ msg = f"`other` must be Interval-like, got {type(other).__name__}"
92
+ with pytest.raises(TypeError, match=msg):
93
+ interval_container.overlaps(other)
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__init__.py ADDED
File without changes
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (176 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arithmetic.cpython-310.pyc ADDED
Binary file (6.47 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_arrow_compat.cpython-310.pyc ADDED
Binary file (6.33 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_function.cpython-310.pyc ADDED
Binary file (2.52 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/__pycache__/test_indexing.cpython-310.pyc ADDED
Binary file (2.05 kB). View file
 
vllm/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)
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_arrow_compat.py ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import pandas as pd
5
+ import pandas._testing as tm
6
+
7
+ pytestmark = pytest.mark.filterwarnings(
8
+ "ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
9
+ )
10
+
11
+ pa = pytest.importorskip("pyarrow")
12
+
13
+ from pandas.core.arrays.arrow._arrow_utils import pyarrow_array_to_numpy_and_mask
14
+
15
+ arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
16
+ arrays += [pd.array([0.1, 0.2, 0.3, None], dtype=dtype) for dtype in tm.FLOAT_EA_DTYPES]
17
+ arrays += [pd.array([True, False, True, None], dtype="boolean")]
18
+
19
+
20
+ @pytest.fixture(params=arrays, ids=[a.dtype.name for a in arrays])
21
+ def data(request):
22
+ """
23
+ Fixture returning parametrized array from given dtype, including integer,
24
+ float and boolean
25
+ """
26
+ return request.param
27
+
28
+
29
+ def test_arrow_array(data):
30
+ arr = pa.array(data)
31
+ expected = pa.array(
32
+ data.to_numpy(object, na_value=None),
33
+ type=pa.from_numpy_dtype(data.dtype.numpy_dtype),
34
+ )
35
+ assert arr.equals(expected)
36
+
37
+
38
+ def test_arrow_roundtrip(data):
39
+ df = pd.DataFrame({"a": data})
40
+ table = pa.table(df)
41
+ assert table.field("a").type == str(data.dtype.numpy_dtype)
42
+
43
+ result = table.to_pandas()
44
+ assert result["a"].dtype == data.dtype
45
+ tm.assert_frame_equal(result, df)
46
+
47
+
48
+ def test_dataframe_from_arrow_types_mapper():
49
+ def types_mapper(arrow_type):
50
+ if pa.types.is_boolean(arrow_type):
51
+ return pd.BooleanDtype()
52
+ elif pa.types.is_integer(arrow_type):
53
+ return pd.Int64Dtype()
54
+
55
+ bools_array = pa.array([True, None, False], type=pa.bool_())
56
+ ints_array = pa.array([1, None, 2], type=pa.int64())
57
+ small_ints_array = pa.array([-1, 0, 7], type=pa.int8())
58
+ record_batch = pa.RecordBatch.from_arrays(
59
+ [bools_array, ints_array, small_ints_array], ["bools", "ints", "small_ints"]
60
+ )
61
+ result = record_batch.to_pandas(types_mapper=types_mapper)
62
+ bools = pd.Series([True, None, False], dtype="boolean")
63
+ ints = pd.Series([1, None, 2], dtype="Int64")
64
+ small_ints = pd.Series([-1, 0, 7], dtype="Int64")
65
+ expected = pd.DataFrame({"bools": bools, "ints": ints, "small_ints": small_ints})
66
+ tm.assert_frame_equal(result, expected)
67
+
68
+
69
+ def test_arrow_load_from_zero_chunks(data):
70
+ # GH-41040
71
+
72
+ df = pd.DataFrame({"a": data[0:0]})
73
+ table = pa.table(df)
74
+ assert table.field("a").type == str(data.dtype.numpy_dtype)
75
+ table = pa.table(
76
+ [pa.chunked_array([], type=table.field("a").type)], schema=table.schema
77
+ )
78
+ result = table.to_pandas()
79
+ assert result["a"].dtype == data.dtype
80
+ tm.assert_frame_equal(result, df)
81
+
82
+
83
+ def test_arrow_from_arrow_uint():
84
+ # https://github.com/pandas-dev/pandas/issues/31896
85
+ # possible mismatch in types
86
+
87
+ dtype = pd.UInt32Dtype()
88
+ result = dtype.__from_arrow__(pa.array([1, 2, 3, 4, None], type="int64"))
89
+ expected = pd.array([1, 2, 3, 4, None], dtype="UInt32")
90
+
91
+ tm.assert_extension_array_equal(result, expected)
92
+
93
+
94
+ def test_arrow_sliced(data):
95
+ # https://github.com/pandas-dev/pandas/issues/38525
96
+
97
+ df = pd.DataFrame({"a": data})
98
+ table = pa.table(df)
99
+ result = table.slice(2, None).to_pandas()
100
+ expected = df.iloc[2:].reset_index(drop=True)
101
+ tm.assert_frame_equal(result, expected)
102
+
103
+ # no missing values
104
+ df2 = df.fillna(data[0])
105
+ table = pa.table(df2)
106
+ result = table.slice(2, None).to_pandas()
107
+ expected = df2.iloc[2:].reset_index(drop=True)
108
+ tm.assert_frame_equal(result, expected)
109
+
110
+
111
+ @pytest.fixture
112
+ def np_dtype_to_arrays(any_real_numpy_dtype):
113
+ """
114
+ Fixture returning actual and expected dtype, pandas and numpy arrays and
115
+ mask from a given numpy dtype
116
+ """
117
+ np_dtype = np.dtype(any_real_numpy_dtype)
118
+ pa_type = pa.from_numpy_dtype(np_dtype)
119
+
120
+ # None ensures the creation of a bitmask buffer.
121
+ pa_array = pa.array([0, 1, 2, None], type=pa_type)
122
+ # Since masked Arrow buffer slots are not required to contain a specific
123
+ # value, assert only the first three values of the created np.array
124
+ np_expected = np.array([0, 1, 2], dtype=np_dtype)
125
+ mask_expected = np.array([True, True, True, False])
126
+ return np_dtype, pa_array, np_expected, mask_expected
127
+
128
+
129
+ def test_pyarrow_array_to_numpy_and_mask(np_dtype_to_arrays):
130
+ """
131
+ Test conversion from pyarrow array to numpy array.
132
+
133
+ Modifies the pyarrow buffer to contain padding and offset, which are
134
+ considered valid buffers by pyarrow.
135
+
136
+ Also tests empty pyarrow arrays with non empty buffers.
137
+ See https://github.com/pandas-dev/pandas/issues/40896
138
+ """
139
+ np_dtype, pa_array, np_expected, mask_expected = np_dtype_to_arrays
140
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array, np_dtype)
141
+ tm.assert_numpy_array_equal(data[:3], np_expected)
142
+ tm.assert_numpy_array_equal(mask, mask_expected)
143
+
144
+ mask_buffer = pa_array.buffers()[0]
145
+ data_buffer = pa_array.buffers()[1]
146
+ data_buffer_bytes = pa_array.buffers()[1].to_pybytes()
147
+
148
+ # Add trailing padding to the buffer.
149
+ data_buffer_trail = pa.py_buffer(data_buffer_bytes + b"\x00")
150
+ pa_array_trail = pa.Array.from_buffers(
151
+ type=pa_array.type,
152
+ length=len(pa_array),
153
+ buffers=[mask_buffer, data_buffer_trail],
154
+ offset=pa_array.offset,
155
+ )
156
+ pa_array_trail.validate()
157
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array_trail, np_dtype)
158
+ tm.assert_numpy_array_equal(data[:3], np_expected)
159
+ tm.assert_numpy_array_equal(mask, mask_expected)
160
+
161
+ # Add offset to the buffer.
162
+ offset = b"\x00" * (pa_array.type.bit_width // 8)
163
+ data_buffer_offset = pa.py_buffer(offset + data_buffer_bytes)
164
+ mask_buffer_offset = pa.py_buffer(b"\x0E")
165
+ pa_array_offset = pa.Array.from_buffers(
166
+ type=pa_array.type,
167
+ length=len(pa_array),
168
+ buffers=[mask_buffer_offset, data_buffer_offset],
169
+ offset=pa_array.offset + 1,
170
+ )
171
+ pa_array_offset.validate()
172
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array_offset, np_dtype)
173
+ tm.assert_numpy_array_equal(data[:3], np_expected)
174
+ tm.assert_numpy_array_equal(mask, mask_expected)
175
+
176
+ # Empty array
177
+ np_expected_empty = np.array([], dtype=np_dtype)
178
+ mask_expected_empty = np.array([], dtype=np.bool_)
179
+
180
+ pa_array_offset = pa.Array.from_buffers(
181
+ type=pa_array.type,
182
+ length=0,
183
+ buffers=[mask_buffer, data_buffer],
184
+ offset=pa_array.offset,
185
+ )
186
+ pa_array_offset.validate()
187
+ data, mask = pyarrow_array_to_numpy_and_mask(pa_array_offset, np_dtype)
188
+ tm.assert_numpy_array_equal(data[:3], np_expected_empty)
189
+ tm.assert_numpy_array_equal(mask, mask_expected_empty)
190
+
191
+
192
+ @pytest.mark.parametrize(
193
+ "arr", [pa.nulls(10), pa.chunked_array([pa.nulls(4), pa.nulls(6)])]
194
+ )
195
+ def test_from_arrow_null(data, arr):
196
+ res = data.dtype.__from_arrow__(arr)
197
+ assert res.isna().all()
198
+ assert len(res) == 10
199
+
200
+
201
+ def test_from_arrow_type_error(data):
202
+ # ensure that __from_arrow__ returns a TypeError when getting a wrong
203
+ # array type
204
+
205
+ arr = pa.array(data).cast("string")
206
+ with pytest.raises(TypeError, match=None):
207
+ # we don't test the exact error message, only the fact that it raises
208
+ # a TypeError is relevant
209
+ data.dtype.__from_arrow__(arr)
vllm/lib/python3.10/site-packages/pandas/tests/arrays/masked/test_function.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from pandas.core.arrays import BaseMaskedArray
9
+
10
+ arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
11
+ arrays += [
12
+ pd.array([0.141, -0.268, 5.895, None], dtype=dtype) for dtype in tm.FLOAT_EA_DTYPES
13
+ ]
14
+
15
+
16
+ @pytest.fixture(params=arrays, ids=[a.dtype.name for a in arrays])
17
+ def data(request):
18
+ """
19
+ Fixture returning parametrized 'data' array with different integer and
20
+ floating point types
21
+ """
22
+ return request.param
23
+
24
+
25
+ @pytest.fixture()
26
+ def numpy_dtype(data):
27
+ """
28
+ Fixture returning numpy dtype from 'data' input array.
29
+ """
30
+ # For integer dtype, the numpy conversion must be done to float
31
+ if is_integer_dtype(data):
32
+ numpy_dtype = float
33
+ else:
34
+ numpy_dtype = data.dtype.type
35
+ return numpy_dtype
36
+
37
+
38
+ def test_round(data, numpy_dtype):
39
+ # No arguments
40
+ result = data.round()
41
+ expected = pd.array(
42
+ np.round(data.to_numpy(dtype=numpy_dtype, na_value=None)), dtype=data.dtype
43
+ )
44
+ tm.assert_extension_array_equal(result, expected)
45
+
46
+ # Decimals argument
47
+ result = data.round(decimals=2)
48
+ expected = pd.array(
49
+ np.round(data.to_numpy(dtype=numpy_dtype, na_value=None), decimals=2),
50
+ dtype=data.dtype,
51
+ )
52
+ tm.assert_extension_array_equal(result, expected)
53
+
54
+
55
+ def test_tolist(data):
56
+ result = data.tolist()
57
+ expected = list(data)
58
+ tm.assert_equal(result, expected)
59
+
60
+
61
+ def test_to_numpy():
62
+ # GH#56991
63
+
64
+ class MyStringArray(BaseMaskedArray):
65
+ dtype = pd.StringDtype()
66
+ _dtype_cls = pd.StringDtype
67
+ _internal_fill_value = pd.NA
68
+
69
+ arr = MyStringArray(
70
+ values=np.array(["a", "b", "c"]), mask=np.array([False, True, False])
71
+ )
72
+ result = arr.to_numpy()
73
+ expected = np.array(["a", pd.NA, "c"])
74
+ tm.assert_numpy_array_equal(result, expected)
vllm/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)
vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__init__.py ADDED
File without changes
vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (176 Bytes). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_indexing.cpython-310.pyc ADDED
Binary file (1.94 kB). View file
 
vllm/lib/python3.10/site-packages/pandas/tests/arrays/numpy_/__pycache__/test_numpy.cpython-310.pyc ADDED
Binary file (8.22 kB). View file