Skip to content
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

BUG: Fix infinite recursion loop when pivot of IntervalTree is ±inf #46664

Conversation

johannes-mueller
Copy link
Contributor

@johannes-mueller johannes-mueller commented Apr 6, 2022

When the pivot of an IntervalTree becomes ±inf the construction of the
IntervalTree comes to an infinite loop recursion. This patch tries to fix that
by catching those cases and set the pivot to a reasonable value.

@johannes-mueller johannes-mueller force-pushed the 46658-bugfix-inf-pivot-infinite-recursion branch 2 times, most recently from 8a9514b to c82d0fb Compare April 7, 2022 06:47
@jreback jreback added Bug Interval Interval data type labels Apr 9, 2022
@jreback jreback added this to the 1.5 milestone Apr 9, 2022
@jreback
Copy link
Contributor

jreback commented Apr 9, 2022

looks good. if you make non-draft can merge.

@johannes-mueller johannes-mueller marked this pull request as ready for review April 10, 2022 08:08
@johannes-mueller johannes-mueller force-pushed the 46658-bugfix-inf-pivot-infinite-recursion branch from c82d0fb to c0ba6cf Compare April 10, 2022 08:09
@johannes-mueller
Copy link
Contributor Author

johannes-mueller commented Apr 14, 2022

looks good. if you make non-draft can merge.

Please also see my comment to the issue. I am in particular stuck with what to do about the CI failure.

@johannes-mueller johannes-mueller force-pushed the 46658-bugfix-inf-pivot-infinite-recursion branch 2 times, most recently from 93d50c4 to 4a11347 Compare April 26, 2022 06:54
@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label May 27, 2022
@johannes-mueller johannes-mueller force-pushed the 46658-bugfix-inf-pivot-infinite-recursion branch 2 times, most recently from de9e54a to 157d836 Compare May 31, 2022 07:47
@johannes-mueller
Copy link
Contributor Author

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

Skipping now the newly introduced tests on 32-bit like other tests of test_interval_tree.py.

@@ -207,3 +207,21 @@ def test_interval_tree_error_and_warning(self):
):
left, right = np.arange(10), [np.iinfo(np.int64).max] * 10
IntervalTree(left, right, closed="both")

@pytest.mark.skipif(not IS64, reason="GH 23440")
Copy link
Member

Choose a reason for hiding this comment

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

Prefer xfail over skipif just in case this gets fixed in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean like this?

@pytest.mark.xfail(not IS64, strict=False, reason="GH 23440")

That would be inconsistent with the other skipifs in the file. So maybe we should change all of them?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but without the strict=False (unless you know this test is specifically flaky and passes sometimes)

Generally we use xfail if a test has a chance to be fixed in the future and skipif if the test is never expected to pass/covered somewhere else.

Can change the skipif in another PR if it meets the above criteria for xfailing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done.

@johannes-mueller johannes-mueller force-pushed the 46658-bugfix-inf-pivot-infinite-recursion branch from 157d836 to d792429 Compare June 2, 2022 06:52
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

One more item otherwise LGTM

Attempts to fix pandas-dev#46658.

When the pivot of an IntervalTree becomes ±inf the construction of the
IntervalTree comes to an infinite loop recursion.  This patch tries to fix that
by catching those cases and set the pivot to a reasonable value.

Note that the tests are skipped on 32-bit systems (see pandas-dev#23440)
@johannes-mueller johannes-mueller force-pushed the 46658-bugfix-inf-pivot-infinite-recursion branch from d792429 to f2c75c3 Compare June 2, 2022 18:24
@mroeschke mroeschke removed the Stale label Jun 2, 2022
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm

@jreback
Copy link
Contributor

jreback commented Jun 5, 2022

cc @mroeschke when you are good

@mroeschke mroeschke merged commit 5f72083 into pandas-dev:main Jun 6, 2022
@mroeschke
Copy link
Member

Thanks @johannes-mueller

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
…andas-dev#46664)

Attempts to fix pandas-dev#46658.

When the pivot of an IntervalTree becomes ±inf the construction of the
IntervalTree comes to an infinite loop recursion.  This patch tries to fix that
by catching those cases and set the pivot to a reasonable value.

Note that the tests are skipped on 32-bit systems (see pandas-dev#23440)
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.

BUG: infinite recursion loop when inf interval bounds lead to inf pivot values in an IntervalTree
3 participants