[cig-commits] [commit] master: style fixes (93d70b6)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Fri Dec 12 14:05:06 PST 2014
Repository : https://github.com/geodynamics/burnman
On branch : master
Link : https://github.com/geodynamics/burnman/compare/53964ef9adcc1f8b89f9e48ae774c2ecb51f216a...6f75d3766c3c8e3bf6599b894e7bbe2993f57419
>---------------------------------------------------------------
commit 93d70b675dcc01c657cc803b9db8c6e4fa24e12c
Author: Timo Heister <timo.heister at gmail.com>
Date: Thu Dec 11 10:06:22 2014 -0800
style fixes
>---------------------------------------------------------------
93d70b675dcc01c657cc803b9db8c6e4fa24e12c
burnman/averaging_schemes.py | 10 +++++-----
burnman/composite.py | 6 +++---
burnman/material.py | 2 +-
burnman/seismic.py | 6 +++---
examples/example_inv_murakami.py | 2 +-
misc/paper_incorrect_averaging.py | 1 -
misc/paper_opt_pv.py | 4 ++--
misc/paper_opt_pv_old.py | 4 ++--
misc/paper_uncertain.py | 2 +-
misc/paper_uncertainty.py | 2 +-
misc/pyrolite_uncertainty.py | 15 +++++++--------
tutorial/step_3.py | 13 ++++++-------
12 files changed, 32 insertions(+), 35 deletions(-)
diff --git a/burnman/averaging_schemes.py b/burnman/averaging_schemes.py
index ff78dc8..5b0d71a 100644
--- a/burnman/averaging_schemes.py
+++ b/burnman/averaging_schemes.py
@@ -369,8 +369,8 @@ class HashinShtrikmanUpper(AveragingScheme):
alpha_n = -3. / (3.*K_n+4.*G_n)
A_n = 0
for i in range(len(vol_frac)):
- if bulk_moduli[i] != K_n:
- A_n = A_n + vol_frac[i]/(1./(bulk_moduli[i] - K_n) - alpha_n)
+ if bulk_moduli[i] != K_n:
+ A_n += vol_frac[i] / (1. / (bulk_moduli[i] - K_n) - alpha_n)
K_upper = K_n + A_n/(1. + alpha_n*A_n)
return K_upper
@@ -405,7 +405,7 @@ class HashinShtrikmanUpper(AveragingScheme):
B_n = 0
for i in range(len(vol_frac)):
if shear_moduli[i] != G_n:
- B_n = B_n + vol_frac[i]/(1./(2.*(shear_moduli[i] - G_n)) - beta_n)
+ B_n += vol_frac[i] / (1. / (2. * (shear_moduli[i] - G_n)) - beta_n)
G_upper = G_n + (0.5)*B_n/(1. + beta_n*B_n)
return G_upper
@@ -452,7 +452,7 @@ class HashinShtrikmanLower(AveragingScheme):
A_1 = 0
for i in range(len(vol_frac)):
if bulk_moduli[i] != K_1:
- A_1 = A_1 + vol_frac[i]/(1./(bulk_moduli[i] - K_1) - alpha_1)
+ A_1 += vol_frac[i] / (1. / (bulk_moduli[i] - K_1) - alpha_1)
K_lower = K_1 + A_1/(1. + alpha_1*A_1)
return K_lower
@@ -487,7 +487,7 @@ class HashinShtrikmanLower(AveragingScheme):
B_1 = 0
for i in range(len(vol_frac)):
if shear_moduli[i] != G_1:
- B_1 = B_1 + vol_frac[i]/(1./(2.*(shear_moduli[i] - G_1)) - beta_1)
+ B_1 += vol_frac[i] / (1. / (2. * (shear_moduli[i] - G_1)) - beta_1)
G_lower = G_1 + (0.5)*B_1/(1. + beta_1*B_1)
return G_lower
diff --git a/burnman/composite.py b/burnman/composite.py
index 9c5c109..c7521d8 100644
--- a/burnman/composite.py
+++ b/burnman/composite.py
@@ -4,13 +4,13 @@
import numpy as np
import warnings
-from collections import namedtuple
from burnman.material import Material
from burnman.mineral import Mineral
+
def check_pairs(fractions, minerals):
- if len(fractions)<1:
+ if len(fractions) < 1:
raise Exception('ERROR: we need at least one mineral')
if len(fractions) != len(minerals):
@@ -20,7 +20,7 @@ def check_pairs(fractions, minerals):
if abs(total-1.0)>1e-10:
raise Exception('ERROR: list of molar fractions does not add up to one')
for p in minerals:
- if not isinstance(p,Mineral):
+ if not isinstance(p, Mineral):
raise Exception('ERROR: object of type ''%s'' is not of type material' % (type(p)))
diff --git a/burnman/material.py b/burnman/material.py
index f49d9a9..5bf4b90 100644
--- a/burnman/material.py
+++ b/burnman/material.py
@@ -97,7 +97,7 @@ class Material(object):
List of minerals.
"""
raise NotImplementedError("need to implement unroll() in derived class!")
- return ()
+ return ([], [])
def density(self):
"""
diff --git a/burnman/seismic.py b/burnman/seismic.py
index 319160f..e7720b4 100644
--- a/burnman/seismic.py
+++ b/burnman/seismic.py
@@ -366,9 +366,9 @@ def attenuation_correction(v_p,v_s,v_phi,Qs,Qphi):
cot=1./np.tan(beta*np.pi/2.)
- v_p = v_p*(1.-1./2.*cot*1./Qp) # Matas et al. (2007) page 1
- v_s = v_s*(1.-1./2.*cot*1./Qs)
- v_phi= v_phi*(1.-1./2.*cot*1./Qphi)
+ v_p *= 1. - 1. / 2. * cot * 1. / Qp # Matas et al. (2007) page 1
+ v_s *= 1. - 1. / 2. * cot * 1. / Qs
+ v_phi *= 1. - 1. / 2. * cot * 1. / Qphi
return v_p, v_s, v_phi
"""
diff --git a/examples/example_inv_murakami.py b/examples/example_inv_murakami.py
index 74de0cb..a815761 100644
--- a/examples/example_inv_murakami.py
+++ b/examples/example_inv_murakami.py
@@ -192,7 +192,7 @@ if __name__ == "__main__":
l = plt.plot(bins, y, 'r--', linewidth=2)
plt.title("%s, mean: %.3e, std dev.: %.3e" % (t,mu,sigma),fontsize='small')
- plot_idx=plot_idx+1
+ plot_idx += 1
plt.savefig("output_figures/example_inv_murakami.png")
plt.show()
diff --git a/misc/paper_incorrect_averaging.py b/misc/paper_incorrect_averaging.py
index 07ef97d..05f07f4 100644
--- a/misc/paper_incorrect_averaging.py
+++ b/misc/paper_incorrect_averaging.py
@@ -22,7 +22,6 @@ import burnman
from burnman import minerals
from burnman.mineral_helpers import HelperSolidSolution
import matplotlib.image as mpimg
-import numpy as np
import colors
if __name__ == "__main__":
diff --git a/misc/paper_opt_pv.py b/misc/paper_opt_pv.py
index 0604c9b..7f97ac3 100644
--- a/misc/paper_opt_pv.py
+++ b/misc/paper_opt_pv.py
@@ -112,8 +112,8 @@ if __name__ == "__main__":
vs_average_prem = sum(seis_vs)/len(seis_vs)
vphi_average_prem = sum(seis_vphi)/len(seis_vphi)
print vs_average_prem, vphi_average_prem
- yy_vs=yy_vs/vs_average_prem
- yy_vphi=yy_vphi/vphi_average_prem
+ yy_vs /= vs_average_prem
+ yy_vphi /= vphi_average_prem
yy_sum = (yy_vs+yy_vphi) #we scale by a factor so it fits in the plot
# plt.figure(dpi=100,figsize=figsize)
plt.subplot(2,2,1)
diff --git a/misc/paper_opt_pv_old.py b/misc/paper_opt_pv_old.py
index a6ec7fe..d16a7a3 100644
--- a/misc/paper_opt_pv_old.py
+++ b/misc/paper_opt_pv_old.py
@@ -104,8 +104,8 @@ if __name__ == "__main__":
vs_average_prem = sum(seis_vs)/len(seis_vs)
vphi_average_prem = sum(seis_vphi)/len(seis_vphi)
print vs_average_prem, vphi_average_prem
- yy_vs=yy_vs/vs_average_prem
- yy_vphi=yy_vphi/vphi_average_prem
+ yy_vs /= vs_average_prem
+ yy_vphi /= vphi_average_prem
yy_sum = (yy_vs+yy_vphi) #we scale by a factor so it fits in the plot
# plt.figure(dpi=100,figsize=figsize)
plt.subplot(2,2,1)
diff --git a/misc/paper_uncertain.py b/misc/paper_uncertain.py
index 58fd033..e56306e 100644
--- a/misc/paper_uncertain.py
+++ b/misc/paper_uncertain.py
@@ -92,7 +92,7 @@ if __name__ == "__main__":
for x in testrange:
print i, names[i], x
uncertain = np.ones(len)
- uncertain[i]=uncertain[i]+spread[i]*x
+ uncertain[i] += spread[i] * x
_, vs, vphi, _ = eval(uncertain)
vsmin = np.minimum(vs,vsmin)
vsmax = np.maximum(vs,vsmax)
diff --git a/misc/paper_uncertainty.py b/misc/paper_uncertainty.py
index b6b37f3..1f42b59 100644
--- a/misc/paper_uncertainty.py
+++ b/misc/paper_uncertainty.py
@@ -88,7 +88,7 @@ if __name__ == "__main__":
for x in testrange:
print i, names[i], x
uncertain = np.ones(len)
- uncertain[i]=uncertain[i]+spread[i]*x
+ uncertain[i] += spread[i] * x
_, vs, vphi, _ = eval(uncertain)
vsmin = np.minimum(vs,vsmin)
vsmax = np.maximum(vs,vsmax)
diff --git a/misc/pyrolite_uncertainty.py b/misc/pyrolite_uncertainty.py
index df23723..2a63aca 100644
--- a/misc/pyrolite_uncertainty.py
+++ b/misc/pyrolite_uncertainty.py
@@ -209,7 +209,7 @@ if whattodo=="plotgood":
trace = []
if shortname.startswith("err"):
- shortname = shortname + "(log)"
+ shortname += "(log)"
for entry in goodfits:
trace.append(np.log(entry[i])/np.log(10))
else:
@@ -582,13 +582,12 @@ elif whattodo=="plot":
vs_hist,vs_xedge,vs_yedge = np.histogram2d(pressure_list, vs_list, bins=len(pressures_sampled), normed = True)
vphi_hist,vphi_xedge,vphi_yedge = np.histogram2d(pressure_list, vphi_list, bins=len(pressures_sampled), normed = True)
-
- vs_xedge = vs_xedge/1.e9
- vphi_xedge = vphi_xedge/1.e9
- rho_xedge = rho_xedge/1.e9
- vs_yedge = vs_yedge/1.e3
- vphi_yedge = vphi_yedge/1.e3
- rho_yedge = rho_yedge/1.e3
+ vs_xedge /= 1.e9
+ vphi_xedge /= 1.e9
+ rho_xedge /= 1.e9
+ vs_yedge /= 1.e3
+ vphi_yedge /= 1.e3
+ rho_yedge /= 1.e3
left_edge = min(vs_xedge[0], vphi_xedge[0], rho_xedge[0])
right_edge = max(vs_xedge[-1], vphi_xedge[-1], rho_xedge[-1])
diff --git a/tutorial/step_3.py b/tutorial/step_3.py
index 29249fe..a27dd39 100644
--- a/tutorial/step_3.py
+++ b/tutorial/step_3.py
@@ -183,13 +183,12 @@ if __name__=='__main__':
vs_hist,vs_xedge,vs_yedge = np.histogram2d(pressure_list, vs_list, bins=len(pressures_sampled), normed = True)
vphi_hist,vphi_xedge,vphi_yedge = np.histogram2d(pressure_list, vphi_list, bins=len(pressures_sampled), normed = True)
-
- vs_xedge = vs_xedge/1.e9
- vphi_xedge = vphi_xedge/1.e9
- rho_xedge = rho_xedge/1.e9
- vs_yedge = vs_yedge/1.e3
- vphi_yedge = vphi_yedge/1.e3
- rho_yedge = rho_yedge/1.e3
+ vs_xedge /= 1.e9
+ vphi_xedge /= 1.e9
+ rho_xedge /= 1.e9
+ vs_yedge /= 1.e3
+ vphi_yedge /= 1.e3
+ rho_yedge /= 1.e3
left_edge = min(vs_xedge[0], vphi_xedge[0], rho_xedge[0])
right_edge = max(vs_xedge[-1], vphi_xedge[-1], rho_xedge[-1])
More information about the CIG-COMMITS
mailing list