Skip to content

validation of pivot in quiver #3951

Closed

Description

@tacaswell

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.

Activity

  1. added
    API: changesChanges to the public API, typically requiring deprecation.
    on Dec 28, 2014
  2. added this to the milestone on Dec 28, 2014
  3. efiring commented on Dec 28, 2014

    @efiring
    Member

    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.

  4. tacaswell commented on Dec 28, 2014

    @tacaswell
    MemberAuthor

    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).

  5. added a commit that references this issue on Dec 28, 2014
    c7c4287
  6. self-assigned this
    on Dec 28, 2014
  7. added a commit that references this issue on Dec 30, 2014
    af17051
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

API: changesChanges to the public API, typically requiring deprecation.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions