Skip to content

Fold _make_nseq_validator into _listify_validator. #17464

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 2 commits into from
May 21, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 20, 2020

It's easy to also check the length of the value in _listify_validator;
no need to have a second nearly identical "list-validator". Also
deprecate validate_nseq_int and validate_nseq_float as a result.

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

It's easy to also check the length of the value in _listify_validator;
no need to have a second nearly identical "list-validator".  Also
deprecate validate_nseq_int and validate_nseq_float as a result.
@@ -81,18 +81,19 @@ def __call__(self, s):
raise ValueError(msg)


def _listify_validator(scalar_validator, allow_stringlist=False, *, doc=None):
@lru_cache()
Copy link
Member

Choose a reason for hiding this comment

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

Does this get called so much that this cache has an effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I doubt it really matters performance-wise, but e.g. validate_whiskers and validate_sketch create a new listified_validator every time they are called.

@QuLogic QuLogic added this to the v3.3.0 milestone May 21, 2020
@QuLogic
Copy link
Member

QuLogic commented May 21, 2020

Only marginally related, but as I was looking over usage, I noticed that validate_stringlist has a doc of return a list or strings. That 'or' should be 'of', right?

@anntzer
Copy link
Contributor Author

anntzer commented May 21, 2020

yup, fixed as a separate commit

@tacaswell tacaswell merged commit e689289 into matplotlib:master May 21, 2020
@anntzer anntzer deleted the unnseq branch May 21, 2020 23:58
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.

3 participants