Skip to content

WIP: overlaps handling of empty intervals in Interval and IntervalArray #26937

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

Closed
wants to merge 1 commit into from
Closed

Conversation

ghost
Copy link

@ghost ghost commented Jun 19, 2019

This supercedes #26894, which made Interval() raise an exception on attempts to create of the form [x,x) or (x,x].

Discussion in #26893 suggests we may want to treat empty intervals as Singletons in the future. But for now, just fix overlaps.

update: IntervalArray has its own vectorized implementation of overlaps, fixed and now shares the new test cases I added for Interval.overlaps.

@ghost ghost changed the title BUG: :meth:Interval.overlaps handling of empty intervals WIP: :meth:Interval.overlaps handling of empty intervals Jun 19, 2019
@pep8speaks
Copy link

pep8speaks commented Jun 19, 2019

Hello @pilkibun! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-06-20 04:49:01 UTC

@codecov
Copy link

codecov bot commented Jun 19, 2019

Codecov Report

Merging #26937 into master will decrease coverage by 50.76%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #26937       +/-   ##
===========================================
- Coverage   91.87%    41.1%   -50.77%     
===========================================
  Files         180      180               
  Lines       50743    50747        +4     
===========================================
- Hits        46620    20860    -25760     
- Misses       4123    29887    +25764
Flag Coverage Δ
#multiple ?
#single 41.1% <0%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/core/arrays/interval.py 37.71% <0%> (-55.35%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/plotting/_matplotlib/__init__.py 0% <0%> (-100%) ⬇️
pandas/io/gcs.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/core/groupby/categorical.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/io/s3.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-99.37%) ⬇️
pandas/io/sas/sas7bdat.py 0% <0%> (-91.16%) ⬇️
... and 133 more

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 d47947a...95e3cc0. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 19, 2019

Codecov Report

Merging #26937 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26937      +/-   ##
==========================================
- Coverage   91.87%   91.87%   -0.01%     
==========================================
  Files         180      180              
  Lines       50746    50752       +6     
==========================================
+ Hits        46623    46626       +3     
- Misses       4123     4126       +3
Flag Coverage Δ
#multiple 90.46% <100%> (ø) ⬆️
#single 41.09% <0%> (-0.1%) ⬇️
Impacted Files Coverage Δ
pandas/core/arrays/interval.py 93.18% <100%> (+0.11%) ⬆️
pandas/io/gbq.py 88.88% <0%> (-11.12%) ⬇️
pandas/core/frame.py 96.89% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.94% <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 cfd65e9...95fe2cd. Read the comment docs.

@ghost ghost changed the title WIP: :meth:Interval.overlaps handling of empty intervals WIP: overlaps handling of empty intervals in INterval and IntervalArray Jun 19, 2019
@ghost ghost changed the title WIP: overlaps handling of empty intervals in INterval and IntervalArray WIP: overlaps handling of empty intervals in Interval and IntervalArray Jun 19, 2019
@ghost
Copy link
Author

ghost commented Jun 19, 2019

I would have liked to have an is_empty method on Interval/IntervalArray. But IntervalIndex already has a different empty method, and seems to inherit IntervalMixin so adding is_empty can get confusing.Leaving it for now.

@ghost
Copy link
Author

ghost commented Jun 19, 2019

ready for review. CC @TomAugspurger , @jschendel .

Copy link
Member

@jschendel jschendel left a comment

Choose a reason for hiding this comment

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

Thanks, looks good overall!

@jschendel jschendel added Bug Interval Interval data type labels Jun 20, 2019
@jschendel jschendel added this to the 0.25.0 milestone Jun 20, 2019
@@ -423,7 +423,15 @@ cdef class Interval(IntervalMixin):
msg = '`other` must be an Interval, got {other}'
raise TypeError(msg.format(other=type(other).__name__))

# TODO:: use Interval.is_empty() if/when implemented
def is_empty(intv):
Copy link
Contributor

Choose a reason for hiding this comment

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

needs a doc-string / typing. I think we should just make this a proper method, with proper tests in this PR.

@@ -1074,14 +1074,26 @@ def overlaps(self, other):
msg = '`other` must be Interval-like, got {other}'
raise TypeError(msg.format(other=type(other).__name__))

# TODO:: use Interval.is_empty() if/when implemented
Copy link
Contributor

Choose a reason for hiding this comment

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

see above

((0, 1, "both"), (0.4, 0.6, "neither"), True),
((0, 1, "neither"), (0.4, 0.6, "neither"), True),
])
def overlaps_cases(request):
Copy link
Contributor

Choose a reason for hiding this comment

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

needs a doc-string

import pandas.util.testing as tm

# silence "imported but unused" warning by flake8
overlaps_cases

Copy link
Contributor

Choose a reason for hiding this comment

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

you are missing the point, you need to move the conftest to a higher level to avoid this import smell

Copy link
Author

@ghost ghost Jun 20, 2019

Choose a reason for hiding this comment

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

Shit. Here we go again.

@jreback , this is the second time you've told me "I'm missing the point", assuming I'm a moron, and been monumentally dead wrong in both times and on both counts. It's also the second PR I'm going to abandon because of your patronizing and offensive manner.

I've asked for you to stay away from my PRs and leave review to saner team members. But here we are again, with you talking shit, and me not willing to take it.

There is no sane place to put the conftest because of the way the test hierarchy is built.
To share a conftest between pandas/tests/arrays/interval and pandas/tests/scalar/interval
It would have to be placed in pandas/tests and then be loaded by dozens of unrelated modules. That's far worse than these silly two lines. But for you its obvious that other developers couldn't possibly apply any judgment, and you have have to micromanage them to the point of disgust.

The hell with this.

@pandas-dev Your project has a problem. jreback should not be allowed near contributors.

@ghost ghost closed this Jun 20, 2019
@jreback
Copy link
Contributor

jreback commented Jun 20, 2019

@pilkibun your attitude is about the worst I have ever seen in open source. Just because you don't like my comments does not reward behavior like this. good luck.

@ghost ghost deleted the fix_point_interval2 branch June 28, 2019 18:59
This pull request was closed.
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
Development

Successfully merging this pull request may close these issues.

interval.overlaps() mishandles empty intervals
3 participants