@@ -73,7 +73,7 @@ def test_properties(self, closed):
73
73
tm .assert_numpy_array_equal (np .asarray (index ), expected )
74
74
75
75
@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 ],
77
77
[- np .inf , - 100 , - 10 , 0.5 , 1 , 1.5 , 3.8 , 101 , 202 , np .inf ],
78
78
pd .to_datetime (['20170101' , '20170202' , '20170303' , '20170404' ]),
79
79
pd .to_timedelta (['1ns' , '2ms' , '3s' , '4M' , '5H' , '6D' ])])
@@ -90,6 +90,22 @@ def test_length(self, closed, breaks):
90
90
expected = Index (iv .length if notna (iv ) else iv for iv in index )
91
91
tm .assert_index_equal (result , expected )
92
92
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
+
93
109
def test_with_nans (self , closed ):
94
110
index = self .create_index (closed = closed )
95
111
assert index .hasnans is False
0 commit comments