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

Provide programmatic access valid interp options #3682

Closed
wants to merge 1 commit into from
Closed

Provide programmatic access valid interp options #3682

wants to merge 1 commit into from

Conversation

ericdill
Copy link
Contributor

Summary
Added an attribute to the imshow function in _axes.py that is named the same as the keyword argument 'interpolation' so that the valid options for interpolation can be accessed programmatically.

Purpose
I spoke with @tacaswell offline and he was unaware of any place in mpl where the valid options for the interpolation kwarg in axes.imshow() were available, thus this PR (which is probably the first of many, but I thought I'd see how this goes over before I do this in other places in mpl source). Such programmatic access to these kwargs is incredibly useful when constructing GUI widgets so that the valid options can be provided via a combo box.

I can see a few different mechanisms by which these sorts of options can be provided programmatically, depending on how much you guys hate this change 😄.

  1. Functions can have attributes added to them whose variable name matches the kwarg for that function.

    1. The previous point doesn't work that well with classes, as classes can and do actually have attributes.
  2. These options can be created in each module where they're useful with the template _opts_funcname_kwarg.

    1. So something like
    _opts_imshow_interpolation = ['none', 'nearest', 'bilinear', 'bicubic',
                                  'spline16', 'spline36', 'hanning', 'hamming',
                                  'hermite', 'kaiser', 'quadric', 'catrom',
                                  'gaussian', 'bessel', 'mitchell', 'sinc',
                                  'lanczos']

- Added an attribute to the imshow function in _axes.py that is
  named the same as the keyword argument 'interpolation'.  This is
  so that the valid options for interpolation can be accessed
  programmatically.
@tacaswell tacaswell added this to the v1.5.x milestone Oct 20, 2014
@tacaswell
Copy link
Member

cc @efiring @mdboom

Note, Eric is one of my co-workers at BNL.

[edit to make comment in English]

@mdboom
Copy link
Member

mdboom commented Oct 20, 2014

Definitely a good idea in principle. Does it make any sense to then generate the docstring from this list? As it stands, there are (at least) 3 places where this list exists: here, in the docstring, and in the C++ code. These are the kinds of things that can get out-of-sync over time if we ever add more interpolation methods/filters in the future.

@tacaswell
Copy link
Member

Yes, we should take a look at how numpy does it. iirc, they have a decorator that re-writes the docstrings at import time.

@tacaswell tacaswell modified the milestones: proposed next point release, next point release Feb 19, 2015
@tacaswell
Copy link
Member

@ellisonbg Can you get things like this out of traitlets?

@ellisonbg
Copy link

traitlets has an Enum type that you can use to list a discrete set of
allowable options. I don't remember the API for programmatically retrieving
the options, but that should be possible. Worse case, we could add a
convenience method to getting the information.

On Tue, Jun 16, 2015 at 10:21 PM, Thomas A Caswell <notifications@github.com

wrote:

@ellisonbg https://github.com/ellisonbg Can you get things like this
out of traitlets?


Reply to this email directly or view it on GitHub
#3682 (comment)
.

Brian E. Granger
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@tacaswell
Copy link
Member

Punting to wait for traitlets, overlaps with #4718

@tacaswell tacaswell modified the milestones: proposed next point release, next point release Jul 17, 2015
@tacaswell
Copy link
Member

Closing as duplicated by #4718 which has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants