Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: first draft of ensure_ax decorator#4488

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
ENH: add registration function
  • Loading branch information
@tacaswell
tacaswell committedAug 30, 2015
commita7918be843024df85e322f48c93b8c8f17db0cfd
27 changes: 27 additions & 0 deletionslib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -261,6 +261,33 @@ def inner(*args, **kwargs):
return inner


def register_func(func):
"""
Registers a function to be wrapped and made available in the
pyplot namespace for convenient interactive command line use.
Copy link
Member

Choose a reason for hiding this comment

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

command-line use? Might be misleading. Would probably be better as just "interactive use".

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I want to keep something in there so we don't encourage people to use these
functions in other functions.

I am a bit hesitant to include this at all for exactly that reason.

On Tue, Jul 7, 2015, 3:06 PM Benjamin Rootnotifications@github.com wrote:

In lib/matplotlib/pyplot.py
#4488 (comment):

  •    else:
  •        ax = gca()
  •    return func(s, ax, _args, *_kwargs)
  • pre_doc = inner.doc
  • if pre_doc is None:
  •    pre_doc = ''
  • else:
  •    pre_doc = dedent(pre_doc)
  • inner.doc = _ENSURE_AX_DOC + pre_doc
  • return inner

+def register_func(func):

  • """
  • Registers a function to be wrapped and made available in the
  • pyplot namespace for convenient interactive command line use.

command-line use? Might be misleading. Would probably be better as just
"interactive use".


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/4488/files#r34083841.


Parameters
----------
func : callable

First parameter of function must be an `Axes` object. Will
be wrapped by `ensure_ax`

Returns
-------
callable

The wrapped function.
"""
mod = sys.modules[__name__]
f_name = func.__name__
if hasattr(mod, f_name):
raise RuntimeError("Function already exists with that name")
setattr(mod, f_name, ensure_ax(func))

return getattr(mod, f_name)


@docstring.copy_dedent(Artist.findobj)
def findobj(o=None, match=None, include_self=True):
if o is None:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp