-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
CI: update tests for numpy 1.20 change to floordiv #38172
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
Changes from 1 commit
cb85bb8
dec6413
804aa46
075eecb
e3090df
9d096b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
import pandas as pd | ||
import pandas._testing as tm | ||
from pandas.core import ops | ||
from pandas.core.arrays.sparse import SparseArray, SparseDtype | ||
from pandas.core.arrays.sparse import IntIndex, SparseArray, SparseDtype | ||
|
||
|
||
@pytest.fixture(params=["integer", "block"]) | ||
|
@@ -31,7 +31,7 @@ class TestSparseArrayArithmetics: | |
def _assert(self, a, b): | ||
tm.assert_numpy_array_equal(a, b) | ||
|
||
def _check_numeric_ops(self, a, b, a_dense, b_dense, mix, op): | ||
def _check_numeric_ops(self, a, b, a_dense, b_dense, mix, op, flag=False): | ||
with np.errstate(invalid="ignore", divide="ignore"): | ||
if mix: | ||
result = op(a, b_dense).to_dense() | ||
|
@@ -46,7 +46,22 @@ def _check_numeric_ops(self, a, b, a_dense, b_dense, mix, op): | |
|
||
if op in [operator.floordiv, ops.rfloordiv]: | ||
# Series sets 1//0 to np.inf, which SparseArray does not do (yet) | ||
if _np_version_under1p20: | ||
condition = _np_version_under1p20 | ||
if isinstance(a_dense, np.ndarray) and isinstance(b_dense, np.ndarray): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add some comments here on what is changed, it is non-obvious from inspection what is changing (e.g. what is true in prior version and what is true now) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yah as mentioned above, i have no frikkin idea what the underlying logic is here |
||
condition = True | ||
if a_dense.dtype == np.float64 and np.isnan(a.fill_value): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems really fragile |
||
# NB: these conditions are just guess-and-check | ||
# to find what passes, no idea why these particular | ||
# conditions are necessary. | ||
if b_dense.dtype == np.int64 and mix: | ||
condition = False | ||
|
||
if a.sp_index.equals(b.sp_index): | ||
if not mix: | ||
condition = False | ||
elif isinstance(a.sp_index, IntIndex): | ||
condition = False | ||
if condition: | ||
# numpy 1.20 updated floordiv, matching the behavior | ||
# in core.ops. See https://github.com/numpy/numpy/pull/16161 | ||
mask = np.isinf(expected) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is flag for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover from previous attempt at a fix, will remove