From 918bf837a884c664d729fadab9091d26773afc49 Mon Sep 17 00:00:00 2001 From: Per A Brodtkorb Date: Sun, 28 Feb 2016 03:47:12 +0100 Subject: [PATCH] Simplified delete_text_object --- wafo/graphutil.py | 27 +++++++++++---------------- wafo/sg_filter.py | 3 ++- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/wafo/graphutil.py b/wafo/graphutil.py index 3f0a223..0dfcd53 100644 --- a/wafo/graphutil.py +++ b/wafo/graphutil.py @@ -43,22 +43,17 @@ def delete_text_object(gidtxt, figure=None, axis=None, verbose=False): def lmatchfun(x): return _matchfun(x, gidtxt) - objs = axis.findobj(lmatchfun) - for obj in objs: - try: - axis.texts.remove(obj) - except: - if verbose: - warnings.warn( - 'Tried to delete a non-existing %s from axis' % gidtxt) - objs = figure.findobj(lmatchfun) - for obj in objs: - try: - figure.texts.remove(obj) - except: - if verbose: - warnings.warn( - 'Tried to delete a non-existing %s from figure' % gidtxt) + for handle in [axis, figure]: + objs = handle.findobj(lmatchfun) + name = handle.__name__ + msg = "Tried to delete a non-existing {0} from {1}".format(gidtxt, + name) + for obj in objs: + try: + handle.texts.remove(obj) + except: + if verbose: + warnings.warn(msg) def cltext(levels, percent=False, n=4, xs=0.036, ys=0.94, zs=0, figure=None, diff --git a/wafo/sg_filter.py b/wafo/sg_filter.py index 61a8c21..40dfa10 100644 --- a/wafo/sg_filter.py +++ b/wafo/sg_filter.py @@ -464,7 +464,8 @@ class _Filter(object): # Search the smoothing parameter s that minimizes the GCV score s = 10.0 ** p Gamma = self.gamma(s) - if aow > 0.9: # aow = 1 means that all of the data are equally weighted + if aow > 0.9: + # aow = 1 means that all of the data are equally weighted # very much faster: does not require any inverse DCT residual = DCTy.ravel() * (Gamma.ravel() - 1) else: