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

Simplify the rcparams deprecation machinery. #15329

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 23, 2019

Just have a single kind of deprecated rcParams, which emit a
DeprecationWarning on get and on set.

... which caught the fact that we were previously not warning on
access to text.latex.unicode, now we do but need to avoid triggering the
warnings internally.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer force-pushed the rcdeprecation branch 4 times, most recently from 7b27bc4 to f0bec85 Compare September 23, 2019 15:35
@anntzer anntzer force-pushed the rcdeprecation branch 2 times, most recently from 5207deb to 4cc64ce Compare November 21, 2019 10:33
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

I'm 👎. Usage of dict.__getitem__(rcParams, par) for working around deprecation warnings is really a crude hack. I don't want to see this all over the code. Related: #12577.

@anntzer
Copy link
Contributor Author

anntzer commented Nov 24, 2019

Right now read access on deprecated rcParams does not warn, which is quite clearly a bug. I think it is reasonable to say that rcParams["deprecated.key"] should warn both on read and on write. However additionally during the deprecation period we still need to be internally able to access the deprecated rcParams, so it's just a matter of how you want to spell that access -- dict.__getitem__(rcParams, "deprecated.key") currently works, so I think adding a rcParams._getitem_ignore_deprecation("deprecated.key") is not worth it, but I can do that, too... or we can also wrap each internal access with cbook._suppress_matplotlib_deprecation_warning() but again that seems slightly overly verbose (and would be slower).

@timhoffm
Copy link
Member

I'd go with rcParams._getitem_ignore_deprecation("deprecated.key"). This at least communicates it's purpose clearly. A little less clear but also less verbose would be something like rcParams._data["deprecated.key"].

@anntzer
Copy link
Contributor Author

anntzer commented Nov 24, 2019

Sure, added such a helper.

@timhoffm
Copy link
Member

Actually I'm not sure if it's wise to throw away the parameter mapping capabilities. While we don't have any pararmeters in there right know, I can imagine that we may want to rename parameters in the future.

@anntzer
Copy link
Contributor Author

anntzer commented Nov 28, 2019

We can always restore it if the need shows up, but right now it's quite a bit of complexity in the rcParams implementation for no use.

@timhoffm
Copy link
Member

Hm, but fiddling that complexity back in is cumbersome as well and the present code doesn't hurt too much (or do you plan larger work on that part?). I'd llke to hear thoughts of the other devs on this.

@anntzer
Copy link
Contributor Author

anntzer commented Nov 28, 2019

I don't plan to fiddle too much with it, but the complexity was such that the basic goal of this code (warning on access to deprecated rcParams, e.g. rcParams["text.latex.unicode"]) wasn't actually working... (Do the other cases work accurately? I don't know, and don't really want to write tests for them either.)

Just have a single kind of deprecated rcParams, which emit a
DeprecationWarning on get and on set.

... which caught the fact that we were previously *not* warning on
access to text.latex.unicode, now we do but need to avoid triggering the
warnings internally.
@tacaswell
Copy link
Member

I am inclined to decline this PR.

@anntzer
Copy link
Contributor Author

anntzer commented Dec 15, 2022

At least the problem that _deprecated_remains_as_none entries (e.g. text.latex.unicode -- now removed -- which is mentioned in the original post) did not trigger a warning on getitem remains.
In fact, now that I revisit this, I wonder if the right solution is not to completely get rid of deprecated{map,ignore_map,remain_as_none} and just write custom deprecation logic into setitem/getitem and add corresponding tests whenever we want to deprecate a rcparam...

@tacaswell
Copy link
Member

... I wonder if the right solution is not to completely get rid of deprecated{map,ignore_map,remain_as_none} and just write custom deprecation logic into setitem/getitem and add corresponding tests whenever we want to deprecate a rcparam...

I think that this is a compelling position. We do it rarely enough and simply writing the code for it would likely be simpler and easier to read.

@github-actions
Copy link

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Jun 26, 2023
@anntzer
Copy link
Contributor Author

anntzer commented Jun 26, 2023

@timhoffm Thoughts about just killing off the rc entire deprecation machinery (#15329 (comment)) and writing ad hoc code as needed?
If you're against it we should just close off this PR.

@timhoffm
Copy link
Member

I support throwing out the whole machinery and write the code as needed.

@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label Jun 28, 2023
@github-actions
Copy link

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: inactive Marked by the “Stale” Github Action status: needs rebase topic: rcparams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants