bug fixing.

This commit is contained in:
Philip Eisenlohr 2016-03-21 08:51:56 -04:00
parent 01a5343ca2
commit 8cd1f027b3
2 changed files with 21 additions and 20 deletions

View File

@ -540,5 +540,4 @@ class ASCIItable():
microstructure[i:i+s] = items[:s] microstructure[i:i+s] = items[:s]
i += len(items) i += len(items)
return (microstructure, i == N and not self.data_read() if strict # check for proper point count and end of file return (microstructure, i == N and not self.data_read()) if strict else microstructure # check for proper point count and end of file
else microstructure)

View File

@ -58,6 +58,24 @@ def emph(what):
"""emphasizes string on screen""" """emphasizes string on screen"""
return bcolors.BOLD+srepr(what)+bcolors.ENDC return bcolors.BOLD+srepr(what)+bcolors.ENDC
# -----------------------------
def execute(cmd,
streamIn = None,
wd = './'):
"""executes a command in given directory and returns stdout and stderr for optional stdin"""
initialPath = os.getcwd()
os.chdir(wd)
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('{} failed with returncode {}'.format(cmd,process.returncode))
return out,error
# ----------------------------- # -----------------------------
# Matlab like trigonometric functions that take and return angles in degrees. # Matlab like trigonometric functions that take and return angles in degrees.
# ----------------------------- # -----------------------------
@ -75,7 +93,7 @@ def gridLocation(idx,res):
# ----------------------------- # -----------------------------
def gridIndex(location,res): def gridIndex(location,res):
return ( location[0] % res[0] + \ return ( location[0] % res[0] + \
( location[1] % res[1]) * res[0] + \ ( location[1] % res[1]) * res[0] + \
( location[2] % res[2]) * res[1] * res[0] ) ( location[2] % res[2]) * res[1] * res[0] )
@ -432,20 +450,4 @@ def curve_fit_bound(f, xdata, ydata, p0=None, sigma=None, bounds=None, **kw):
else: else:
pcov = np.inf pcov = np.inf
return popt, pcov, infodict, errmsg, ier if return_full else popt, pcov return (popt, pcov, infodict, errmsg, ier) if return_full else (popt, pcov)
def execute(cmd,streamIn = None,wd = './'):
"""executes a command in given directory and returns stdout and stderr for optional stdin"""
initialPath = os.getcwd()
os.chdir(wd)
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('{} failed with returncode {}'.format(cmd,process.returncode))
return out,error