Skip to content

Commit

Permalink
PEP8 fixes in preparation of new release
Browse files Browse the repository at this point in the history
  • Loading branch information
dkriegner committed Oct 31, 2022
1 parent 8c7e3eb commit 48bf0f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions lib/xrayutilities/materials/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ def index_map_ijkl2ij(i, j):
def index_map_ij2ijkl(ij):
return map_ij2ijkl["%i" % ij]


def check_symmetric(matrix):
return numpy.allclose(matrix, matrix.T, rtol=1e-05, atol=1e-08)


def Cij2Cijkl(cij):
"""
Converts the elastic constants matrix (tensor of rank 2) to
Expand Down Expand Up @@ -321,7 +323,7 @@ def GetStrain(self, sig):
stress matrix (3x3) in N/m^2
"""
if isinstance(sig, (list, tuple)):
if check_symmetric(sig) == True:
if check_symmetric(sig):
sig = numpy.asarray(sig, dtype=numpy.double)
else:
raise InputError("GetStrain needs a symmetric matrix")
Expand Down Expand Up @@ -351,7 +353,7 @@ def GetStress(self, eps):
strain matrix (3x3)
"""
if isinstance(eps, (list, tuple)):
if check_symmetric(eps) == True:
if check_symmetric(eps):
eps = numpy.asarray(eps, dtype=numpy.double)
else:
raise InputError("GetStress needs a symmetric matrix")
Expand Down
6 changes: 3 additions & 3 deletions lib/xrayutilities/math/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def fsignal(p, x):
if numpy.any(bmask):
k, d = numpy.polyfit(lx[bmask], ldata[bmask], 1)
else:
if(config.VERBOSITY >= config.DEBUG):
if config.VERBOSITY >= config.DEBUG:
print("XU.math.multPeakFit: no data outside peak regions!")
k, d = (0, ldata.min())

Expand All @@ -630,7 +630,7 @@ def fsignal(p, x):
# background parameters
p += [k, d]

if(config.VERBOSITY >= config.DEBUG):
if config.VERBOSITY >= config.DEBUG:
print("XU.math.multPeakFit: intial parameters")
print(p)

Expand All @@ -643,7 +643,7 @@ def fsignal(p, x):
my_odr.set_job(fit_type=2)
fit = my_odr.run()

if(config.VERBOSITY >= config.DEBUG):
if config.VERBOSITY >= config.DEBUG:
print("XU.math.multPeakFit: fitted parameters")
print(fit.beta)
try:
Expand Down
3 changes: 2 additions & 1 deletion lib/xrayutilities/simpack/powdermodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def __init__(self, *args, **kwargs):
-----
In particular interesting keys in the fpsettings dictionary might be:
'displacement':
{'specimen_displacement': sample's z-displacement from the rotation center
{'specimen_displacement': sample's z-displacement from the rotation
center
'zero_error_deg': zero error of the 2theta angle}
'absorption':
Expand Down
4 changes: 2 additions & 2 deletions lib/xrayutilities/utilities_noconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ def set_bit(f, offset):
sets the bit at an offset
"""
mask = 1 << offset
return(f | mask)
return (f | mask)


def clear_bit(f, offset):
"""
clears the bet at an offset
"""
mask = ~(1 << offset)
return(f & mask)
return (f & mask)


def lam2en(inp):
Expand Down

0 comments on commit 48bf0f8

Please sign in to comment.