Commit
ENH : check existence of arbitrarily named figures Closes #2880
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Updated fignum_exists to take figure name | ||
------------------------------------------- | ||
Added the ability to check the existence of a figure using it's name | ||
instead of just the figure number. | ||
Example: | ||
figure('figure') | ||
fignum_exists('figure') #true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,7 +460,9 @@ def gcf(): | |
else: | ||
return figure() | ||
|
||
fignum_exists = _pylab_helpers.Gcf.has_fignum | ||
def fignum_exists(num): | ||
allLabels = get_figlabels() | ||
return _pylab_helpers.Gcf.has_fignum(num) or num in allLabels | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tacaswell
Author
Member
|
||
|
||
|
||
def get_fignums(): | ||
|
Why create an intermediate variable
allLabels
for something which is used once, and more importantly, why callget_figlabels()
when it can be unnecessary (because theor
can match the old_pylab…()
). I am not submitting a patch because there might be a reason that you experts out there can immediately find. :) Unless there is some side-effect to theget_figlabels()
call, this would definitely be better asreturn _pylab_helpers.Gcf.has_fignum(num) or num in get_figlabels()
(with noallLabels
variable).