From 01a5343ca20ec2c38449afc8137413b6a7135a62 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sun, 20 Mar 2016 20:58:10 -0400 Subject: [PATCH] added another backgroundMessage animation. generally cleaned code a slight bit. --- lib/damask/util.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/damask/util.py b/lib/damask/util.py index 9ce42759a..c64a8cd00 100644 --- a/lib/damask/util.py +++ b/lib/damask/util.py @@ -106,6 +106,7 @@ class backgroundMessage(threading.Thread): choices = {'bounce': ['_', 'o', 'O', u'\u00B0', u'\u203e',u'\u203e',u'\u00B0','O','o','_'], + 'spin': [u'\u25dc',u'\u25dd',u'\u25de',u'\u25df'], 'circle': [u'\u25f4',u'\u25f5',u'\u25f6',u'\u25f7'], 'hexagon': [u'\u2b22',u'\u2b23'], 'square': [u'\u2596',u'\u2598',u'\u259d',u'\u2597'], @@ -229,7 +230,7 @@ def leastsqBound(func, x0, args=(), bounds=None, Dfun=None, full_output=0, return shape(res), dt def _int2extGrad(p_int, bounds): - """Calculate the gradients of transforming the internal (unconstrained) to external (constained) parameter.""" + """Calculate the gradients of transforming the internal (unconstrained) to external (constrained) parameter.""" grad = np.empty_like(p_int) for i, (x, bound) in enumerate(zip(p_int, bounds)): lower, upper = bound @@ -431,22 +432,20 @@ def curve_fit_bound(f, xdata, ydata, p0=None, sigma=None, bounds=None, **kw): else: pcov = np.inf - if return_full: - return popt, pcov, infodict, errmsg, ier - else: - return popt, pcov + return popt, pcov, infodict, errmsg, ier if return_full else popt, pcov -def execute(cmd,streamIn=None,wd='./'): +def execute(cmd,streamIn = None,wd = './'): """executes a command in given directory and returns stdout and stderr for optional stdin""" - initialPath=os.getcwd() + initialPath = os.getcwd() os.chdir(wd) - process = subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr = subprocess.PIPE,stdin=subprocess.PIPE) - if streamIn is not None: - out,error = [i.replace("\x08","") for i in process.communicate(streamIn.read())] - else: - out,error =[i.replace("\x08","") for i in process.communicate()] + process = subprocess.Popen(shlex.split(cmd), + stdout = subprocess.PIPE, + stderr = subprocess.PIPE, + stdin = subprocess.PIPE) + out,error = [i.replace("\x08","") for i in (process.communicate if streamIn is None + else process.communicate(streamIn.read()))] os.chdir(initialPath) - if process.returncode !=0: raise RuntimeError(cmd+' failed with returncode '+str(process.returncode)) + if process.returncode != 0: raise RuntimeError('{} failed with returncode {}'.format(cmd,process.returncode)) return out,error