Skip to content

BUG: Fix IntervalIndex constructor and copy with non-default closed #18340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2017

Conversation

jschendel
Copy link
Member

Lumped the two issues together since they're dealing with the same thing, and the fixes are identical/small. Rewrote relevant tests to be parametrized over closed.

I also went through unrelated IntervalIndex tests and where it was straighforward parametrized over closed. Didn't include those in the initial commit though. Not sure if it was best to include them here, or do them separately.

@codecov
Copy link

codecov bot commented Nov 17, 2017

Codecov Report

Merging #18340 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18340      +/-   ##
==========================================
- Coverage   91.38%   91.36%   -0.03%     
==========================================
  Files         164      164              
  Lines       49790    49792       +2     
==========================================
- Hits        45501    45492       -9     
- Misses       4289     4300      +11
Flag Coverage Δ
#multiple 89.16% <100%> (-0.01%) ⬇️
#single 39.49% <0%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/interval.py 92.52% <100%> (-0.34%) ⬇️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.8% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfad581...c3b6f53. Read the comment docs.

@jreback jreback added Bug Interval Interval data type labels Nov 17, 2017
@jreback
Copy link
Contributor

jreback commented Nov 17, 2017

I also went through unrelated IntervalIndex tests and where it was straighforward parametrized over closed. Didn't include those in the initial commit though. Not sure if it was best to include them here, or do them separately

happy to have this. (inline adding tests is almost always ok)

tm.assert_index_equal(result, expected)

# idempotent
tm.assert_index_equal(IntervalIndex(expected), expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also exercise .from_breaks and .from_arrays (can be in another test).

from pandas.tseries.offsets import Day
from pandas._libs.interval import IntervalTree
from pandas.tests.indexes.common import Base
import pandas.util.testing as tm
import pandas as pd


@pytest.fixture(scope='class', params=['left', 'right', 'both', 'neither'])
def closed(request):
return request.param
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this fixture to avoid having @pytest.mark.parametrize('closed', ['left', 'right', 'both', 'neither']) decorators everywhere. This should be picked up by any test that has closed as an argument, without needing an explicit decorator.

@jreback jreback modified the milestones: 0.22.0, 0.21.1 Nov 19, 2017
@jreback
Copy link
Contributor

jreback commented Nov 19, 2017

lgtm.

@shoyer can you give this a once over

Copy link
Member

@shoyer shoyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@jreback jreback merged commit 1915ffc into pandas-dev:master Nov 20, 2017
@jreback
Copy link
Contributor

jreback commented Nov 20, 2017

thanks @jschendel nice PRs as always. keep em coming!

@jschendel jschendel deleted the iv-idx-closed branch December 4, 2017 20:43
TomAugspurger pushed a commit to TomAugspurger/pandas that referenced this pull request Dec 8, 2017
TomAugspurger pushed a commit that referenced this pull request Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Interval Interval data type
Projects
None yet
3 participants