Skip to content

Commit 7234906

Browse files
author
pilkibun
committed
TST: Fix some interval tests
1 parent d133fd4 commit 7234906

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pandas/tests/indexes/interval/test_interval.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_properties(self, closed):
7373
tm.assert_numpy_array_equal(np.asarray(index), expected)
7474

7575
@pytest.mark.parametrize('breaks', [
76-
[1, 1, 2, 5, 15, 53, 217, 1014, 5335, 31240, 201608],
76+
[1, 2, 5, 15, 53, 217, 1014, 5335, 31240, 201608],
7777
[-np.inf, -100, -10, 0.5, 1, 1.5, 3.8, 101, 202, np.inf],
7878
pd.to_datetime(['20170101', '20170202', '20170303', '20170404']),
7979
pd.to_timedelta(['1ns', '2ms', '3s', '4M', '5H', '6D'])])
@@ -90,6 +90,22 @@ def test_length(self, closed, breaks):
9090
expected = Index(iv.length if notna(iv) else iv for iv in index)
9191
tm.assert_index_equal(result, expected)
9292

93+
@pytest.mark.parametrize('breaks', [
94+
[1, 1, 2, 2]])
95+
@pytest.mark.parametrize('closed', ['neither', 'both'])
96+
def test_length_with_point_intervals(self, closed, breaks):
97+
# GH 18789
98+
index = IntervalIndex.from_breaks(breaks, closed=closed)
99+
result = index.length
100+
expected = Index(iv.length for iv in index)
101+
tm.assert_index_equal(result, expected)
102+
103+
# with NA
104+
index = index.insert(1, np.nan)
105+
result = index.length
106+
expected = Index(iv.length if notna(iv) else iv for iv in index)
107+
tm.assert_index_equal(result, expected)
108+
93109
def test_with_nans(self, closed):
94110
index = self.create_index(closed=closed)
95111
assert index.hasnans is False

0 commit comments

Comments
 (0)