Skip to content

Commit 0be573e

Browse files
jschendeljreback
authored andcommitted
CLN: Remove int32 and float32 dtypes from IntervalTree (#30598)
1 parent f146632 commit 0be573e

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

pandas/_libs/intervaltree.pxi.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ from pandas._libs.algos import is_monotonic
88

99
ctypedef fused int_scalar_t:
1010
int64_t
11-
int32_t
1211
float64_t
13-
float32_t
1412

1513
ctypedef fused uint_scalar_t:
1614
uint64_t
1715
float64_t
18-
float32_t
1916

2017
ctypedef fused scalar_t:
2118
int_scalar_t
@@ -212,7 +209,7 @@ cdef sort_values_and_indices(all_values, all_indices, subset):
212209
{{py:
213210

214211
nodes = []
215-
for dtype in ['float32', 'float64', 'int32', 'int64', 'uint64']:
212+
for dtype in ['float64', 'int64', 'uint64']:
216213
for closed, cmp_left, cmp_right in [
217214
('left', '<=', '<'),
218215
('right', '<', '<='),

pandas/tests/indexes/interval/test_interval_tree.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def skipif_32bit(param):
2020
return pytest.param(param, marks=marks)
2121

2222

23-
@pytest.fixture(
24-
scope="class", params=["int32", "int64", "float32", "float64", "uint64"]
25-
)
23+
@pytest.fixture(scope="class", params=["int64", "float64", "uint64"])
2624
def dtype(request):
2725
return request.param
2826

@@ -39,12 +37,9 @@ def leaf_size(request):
3937
@pytest.fixture(
4038
params=[
4139
np.arange(5, dtype="int64"),
42-
np.arange(5, dtype="int32"),
4340
np.arange(5, dtype="uint64"),
4441
np.arange(5, dtype="float64"),
45-
np.arange(5, dtype="float32"),
4642
np.array([0, 1, 2, 3, 4, np.nan], dtype="float64"),
47-
np.array([0, 1, 2, 3, 4, np.nan], dtype="float32"),
4843
]
4944
)
5045
def tree(request, leaf_size):
@@ -64,13 +59,14 @@ def test_get_indexer(self, tree):
6459
tree.get_indexer(np.array([3.0]))
6560

6661
@pytest.mark.parametrize(
67-
"dtype, target_value", [("int64", 2 ** 63 + 1), ("uint64", -1)]
62+
"dtype, target_value, target_dtype",
63+
[("int64", 2 ** 63 + 1, "uint64"), ("uint64", -1, "int64")],
6864
)
69-
def test_get_indexer_overflow(self, dtype, target_value):
65+
def test_get_indexer_overflow(self, dtype, target_value, target_dtype):
7066
left, right = np.array([0, 1], dtype=dtype), np.array([1, 2], dtype=dtype)
7167
tree = IntervalTree(left, right)
7268

73-
result = tree.get_indexer(np.array([target_value]))
69+
result = tree.get_indexer(np.array([target_value], dtype=target_dtype))
7470
expected = np.array([-1], dtype="intp")
7571
tm.assert_numpy_array_equal(result, expected)
7672

@@ -94,12 +90,13 @@ def test_get_indexer_non_unique(self, tree):
9490
tm.assert_numpy_array_equal(result, expected)
9591

9692
@pytest.mark.parametrize(
97-
"dtype, target_value", [("int64", 2 ** 63 + 1), ("uint64", -1)]
93+
"dtype, target_value, target_dtype",
94+
[("int64", 2 ** 63 + 1, "uint64"), ("uint64", -1, "int64")],
9895
)
99-
def test_get_indexer_non_unique_overflow(self, dtype, target_value):
96+
def test_get_indexer_non_unique_overflow(self, dtype, target_value, target_dtype):
10097
left, right = np.array([0, 2], dtype=dtype), np.array([1, 3], dtype=dtype)
10198
tree = IntervalTree(left, right)
102-
target = np.array([target_value])
99+
target = np.array([target_value], dtype=target_dtype)
103100

104101
result_indexer, result_missing = tree.get_indexer_non_unique(target)
105102
expected_indexer = np.array([-1], dtype="intp")
@@ -146,10 +143,10 @@ def test_get_indexer_closed(self, closed, leaf_size):
146143
@pytest.mark.parametrize(
147144
"left, right, expected",
148145
[
149-
(np.array([0, 1, 4]), np.array([2, 3, 5]), True),
150-
(np.array([0, 1, 2]), np.array([5, 4, 3]), True),
146+
(np.array([0, 1, 4], dtype="int64"), np.array([2, 3, 5]), True),
147+
(np.array([0, 1, 2], dtype="int64"), np.array([5, 4, 3]), True),
151148
(np.array([0, 1, np.nan]), np.array([5, 4, np.nan]), True),
152-
(np.array([0, 2, 4]), np.array([1, 3, 5]), False),
149+
(np.array([0, 2, 4], dtype="int64"), np.array([1, 3, 5]), False),
153150
(np.array([0, 2, np.nan]), np.array([1, 3, np.nan]), False),
154151
],
155152
)
@@ -164,7 +161,7 @@ def test_is_overlapping(self, closed, order, left, right, expected):
164161
def test_is_overlapping_endpoints(self, closed, order):
165162
"""shared endpoints are marked as overlapping"""
166163
# GH 23309
167-
left, right = np.arange(3), np.arange(1, 4)
164+
left, right = np.arange(3, dtype="int64"), np.arange(1, 4)
168165
tree = IntervalTree(left[order], right[order], closed=closed)
169166
result = tree.is_overlapping
170167
expected = closed == "both"
@@ -187,7 +184,7 @@ def test_is_overlapping_trivial(self, closed, left, right):
187184
@pytest.mark.skipif(compat.is_platform_32bit(), reason="GH 23440")
188185
def test_construction_overflow(self):
189186
# GH 25485
190-
left, right = np.arange(101), [np.iinfo(np.int64).max] * 101
187+
left, right = np.arange(101, dtype="int64"), [np.iinfo(np.int64).max] * 101
191188
tree = IntervalTree(left, right)
192189

193190
# pivot should be average of left/right medians

0 commit comments

Comments
 (0)