Skip to content

DEP: Deprecate the axis argument to masked_rows and masked_cols - #14996

Merged
seberg merged 1 commit into
numpy:masterfrom
eric-wieser:masked_rows-bad-argument
Dec 2, 2019
Merged

seberg merged 1 commit into
numpy:masterfrom
eric-wieser:masked_rows-bad-argument

Conversation

@eric-wieser

Copy link
Copy Markdown
Member

This argument isn't used, and is confusing.

Is this worth a deprecation, or should I just outright remove it as I do here?

@eric-wieser eric-wieser added 07 - Deprecation 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified. component: numpy.ma masked arrays labels Nov 27, 2019
@eric-wieser
eric-wieser force-pushed the masked_rows-bad-argument branch from ee75155 to 675edcf Compare November 27, 2019 23:22
@seberg

seberg commented Nov 28, 2019

Copy link
Copy Markdown
Member

I feel like it is probably fine to do without a deprecation. But generally speaking, the deprecation is also pretty simple here. So it is a bit annoying, but I think I would just be +0 on going through a short deprecation. It is just the simple decision...

Comment thread numpy/ma/extras.py Outdated

@eric-wieser eric-wieser Nov 28, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The alternative would be to add something like:

if axis in (None, 1, -(np.ndim(a)-1)):
    deprecate()
else:
    raise TypeError("The axis argument should not be passed, and the value you passed is not what is being used")

But this doesn't seem worth it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, you can just change to np._NoValue and if axis is not np._NoValue: deprecate()?

@eric-wieser eric-wieser Nov 28, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is skipping the deprecation warning for cases when the code is actively wrong - when the axis being used is different to the one the user requested

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is your plan to delete axis or to change its meaning in the future?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Delete it

@eric-wieser

eric-wieser commented Nov 28, 2019 •

Copy link
Copy Markdown
Member Author

Another question: Should this have:

.. versionchanged:: 1.18.0
   The previously-ignored axis argument has been removed, attempting to pass it will raise TypeError

(also, 18 or 19? (related: gh-14999))

@seberg

seberg commented Nov 28, 2019

Copy link
Copy Markdown
Member

We still have a few days for 18, if you want to get rid of this quickly, I am willing to put it in. Its simple enough.

Do we need the version changed? I feel like its mostly for people writing for the new NumPy version, but wanting compatibility with old ones. But since the kwarg is removed, they cannot write incompatible code at all.

@eric-wieser

eric-wieser commented Nov 28, 2019 •

Copy link
Copy Markdown
Member Author

I feel like its mostly for people writing for the new NumPy version, but wanting compatibility with old ones.

It was more intended for users thinking "did I go mad, why did this use to work".

Perhaps the release notes are fine for that.

I am willing to put it in

Sans deprecation?

@seberg

seberg commented Nov 28, 2019

Copy link
Copy Markdown
Member

If we rush it into 1.18, then please with deprecation. I do not care about the versionchanged tag, either way works. It seems to me a simple undiscriminate deprecation warning is good enough, users need to delete it anyway whether it was wrong or not.

@eric-wieser eric-wieser removed the 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified. label Nov 28, 2019
@eric-wieser
eric-wieser force-pushed the masked_rows-bad-argument branch from 675edcf to 85cfe87 Compare November 28, 2019 22:49
@eric-wieser eric-wieser changed the title API: Remove axis argument to masked_rows and masked_cols DEP: Deprecate the axis argument to masked_rows and masked_cols Nov 28, 2019
@eric-wieser

Copy link
Copy Markdown
Member Author

Updated to be a deprecation

@eric-wieser eric-wieser added this to the 1.18.0 release milestone Nov 28, 2019
@seberg

seberg commented Nov 30, 2019

Copy link
Copy Markdown
Member

Thanks, this looks good to me. I suppose out of principle some test might be good, although also not vital. I might add one and merge in a bit (if Chuck wants to merge it quicker for 1.18, please go ahead).

@eric-wieser

Copy link
Copy Markdown
Member Author

I think mostly the deprecation tests are important for C code, where we have to check that exceptions are propagated correctly,

I probably won't get around to adding one, so would appreciate if you added it yourself. Doesn't seem particularly important, but not harmful either.

It would be nice to get this in 1.18 just so we can remove this code one release sooner.

This argument isn't used, and is confusing. (Small test added by
seberg)
@seberg
seberg force-pushed the masked_rows-bad-argument branch from 85cfe87 to 14bcfd9 Compare December 2, 2019 18:40
@seberg

seberg commented Dec 2, 2019

Copy link
Copy Markdown
Member

Thanks Eric. Lets put this in, the test is minimal (and as you said, not very important in any case).

@seberg
seberg merged commit 5992098 into numpy:master Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants