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

validation of pivot in quiver #3951

Closed
tacaswell opened this issue Dec 28, 2014 · 2 comments · Fixed by #3955
Closed

validation of pivot in quiver #3951

tacaswell opened this issue Dec 28, 2014 · 2 comments · Fixed by #3955
Assignees
Milestone

Comments

@tacaswell
Copy link
Member

Noted as part of #3907, the inputs on pivot for quiver is very permissive and will take 'mid' or 'middle', however it will also work with out exception with any string input (by just silently falling back to 'tail'):

X, Y = np.meshgrid(np.linspace(-np.pi, np.pi, 16), np.linspace(-np.pi, np.pi, 16))
v = np.sin(X)
u = np.cos(Y)
plt.quiver(X, Y, u, v)
plt.quiver(X, Y, u, v, color='b', pivot='ardvaark', alpha=.5)

I propose that a) we validate the input to be in {'tip', 'tail', 'mid', 'middle'} and accept but warn anything else down to tail for one version before raising.

@tacaswell tacaswell added this to the v1.5.x milestone Dec 28, 2014
@efiring
Copy link
Member

efiring commented Dec 28, 2014

The present situation is the result of my minimalist approach when I wrote it. In the history of mpl, strict validation of inputs has been inconsistent, to say the least.
For 1.5, I think that your proposed "accept but warn" is overkill; do we really need to warn every time we tighten the validation a bit to match the longstanding documentation and reasonable expectations? It's a question of a tradeoff between safety on one side and effort/clutter on the other. I think that in this case, it is OK to keep it simple: add the validation and note it in the changelog. No warning, no test.

@tacaswell
Copy link
Member Author

Fair enough.

This is all sort of balled up with how we auto-fleshout the docstrings as well.

I am working on a proposal to piggy back on the mechanism that function annotations use in pythen3 (http://python-future.org/func_annotations.html) to put the information used for validation and for building the docstrings in exactly one place (and my working on I need to figure out if it will work).

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Dec 28, 2014
only accept {'mid', 'middle', 'tip', 'tail'} instead of
being super permissive.

Closes matplotlib#3951
@tacaswell tacaswell self-assigned this Dec 28, 2014
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Dec 30, 2014
only accept {'mid', 'middle', 'tip', 'tail'} instead of
being super permissive.

Closes matplotlib#3951
cyeh015 added a commit to acroucher/PyTOUGH that referenced this issue Aug 17, 2017
…aused error using matplotlib 1.5+.

Matplotlib tightened validation of pivot in quiver, 'start' is no longer allowed, which was wrong and default of 'tail' was used.  See matplotlib/matplotlib#3951
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants