Skip to content

Add back __array_wrap__ for dask compatibility #45451

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 5 commits into from
Jan 20, 2022

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche added this to the 1.4 milestone Jan 18, 2022
# (https://github.com/dask/dask/issues/8580).
# This test is a small dummy ensuring coverage
orig = Series([1, 2, 3], index=["a", "b", "c"])
result = orig.__array_wrap__(np.array([2, 4, 6]))
Copy link
Member

Choose a reason for hiding this comment

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

is there an actual use case where this gets called organically?

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 suppose only with old numpy? (not really an idea though) But so in dask's case they are calling it explicitly / manually (like this test does)

Copy link
Member

Choose a reason for hiding this comment

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

then wouldn't the reasonable thing to do be either a) see if they really need to call it or b) add a "real" test in test_downstream?

Copy link
Member Author

Choose a reason for hiding this comment

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

see if they really need to call it

They don't need to, and are already fixing it (but we should still do this PR to not directly break released dask IMO, and I can open an issue to remove it in a year or so, or we can first deprecate it)

add a "real" test in test_downstream?

I would say that the "real" test is downstream in dask's test suite :)
In the end I don't really care where the test is put, but I think putting it here without usage of dask is useful (I think the dowstream tests are much easier to miss while developing)

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a downstream dask test, but also kept this one.

Will do a follow-up PR to add a deprecation warning for 1.5

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Follow-up PR to deprecate it -> #45517

@jreback jreback added the Compat pandas objects compatability with Numpy or Python functions label Jan 18, 2022
@jreback
Copy link
Contributor

jreback commented Jan 19, 2022

lots of things failing here, can you merge master

@@ -55,6 +55,30 @@ def test_dask(df):
pd.set_option("compute.use_numexpr", olduse)


@pytest.mark.filterwarnings("ignore:.*64Index is deprecated:FutureWarning")
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 use the import decorator here e.g. @td.skip_if_no("xarray" (and can you fix the L39 one

i also don't know why we have a special import_module here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This seems to be done on purpose:

def import_module(name):
# we *only* want to skip if the module is truly not available
# and NOT just an actual import error because of pandas changes
try:
return importlib.import_module(name)
except ModuleNotFoundError:
pytest.skip(f"skipping as {name} not available")

Copy link
Contributor

Choose a reason for hiding this comment

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

ok really this should be cleaned up cc @jbrockmendel

@jreback jreback merged commit 04f5721 into pandas-dev:main Jan 20, 2022
@jreback
Copy link
Contributor

jreback commented Jan 20, 2022

@meeseeksdev backport 1.4.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jan 20, 2022

Something went wrong ... Please have a look at my logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants