Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake8 preparation and ci fixes #145

Merged
merged 7 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ImageD11/blobcorrector.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ def __init__(self,
assert self.dx.shape == self.dy.shape

def __call__(self, pks):
si = np.round(pks['s_raw']).astype(int)
fi = np.round(pks['f_raw']).astype(int)
si = numpy.round(pks['s_raw']).astype(int)
fi = numpy.round(pks['f_raw']).astype(int)
pks['fc'] = self.dx[ si, fi ] + pks['f_raw']
pks['sc'] = self.dy[ si, fi ] + pks['s_raw']
return pks
Expand Down
2 changes: 1 addition & 1 deletion ImageD11/compute_fazit.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, splinefile = None,
for key in self.required_pars:

if key not in self.pars.parameters:
raise Exception("Missing parameter "+str(par))
raise Exception("Missing parameter "+str(key))

def compute_tth_eta(self, dims):
"""
Expand Down
2 changes: 1 addition & 1 deletion ImageD11/fft_index_refac.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def test(options):
#sys.stdout.flush()
#ubinew = go.reduce(go.UBIALL)
#print "After reduction", len(ubinew)
go.UBIALL = ubinew
#go.UBIALL = ubinew
go.slow_score()
#from matplotlib.pylab import imshow, show
#imshow(im)
Expand Down
2 changes: 1 addition & 1 deletion ImageD11/project/h5demo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ def writesino(h5name, omegas, dtys, filenames):
else:
print('debug please')
print(fab.shape,fab)
print(h5v.shape,h5e)
print(h5v.shape,h5v)
14 changes: 7 additions & 7 deletions ImageD11/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Scan( object ):
edges = which nodes are adjacent to this node
"""
def __init__(self,
nodes = None, # type: List[]
edges = None, # type: List[[int,]]
nodes = None, # a List[]
edges = None, # a List[[int,]]
):
"""
nodes = measurement points in the scan
Expand Down Expand Up @@ -96,9 +96,9 @@ def neighbors( self, node ):
node = scan point (Image, Omega, etc)
node = integer
"""
if isinstance( i, int ):
return self.edges[i]
if isinstance( i, tuple):
if isinstance( node, int ):
return self.edges[node]
if isinstance( node, tuple):
i = self.node_index[ node ]
return self.edges[i]
raise TypeError("node not understood, want tuple or int row index")
Expand Down Expand Up @@ -211,8 +211,8 @@ def mergeScans( scan1, scan2 ):
n2 = len(scan2)
# "+" joins lists:
nodes = scan1.nodes + scan2.nodes
edges = scan1.edges + [ (i + n1, j + n1) for i,j in edges ]
return Scan( nodes, edge )
edges = scan1.edges + [ (i + n1, j + n1) for i,j in nodes ]
return Scan( nodes, edges )


class Project( object ):
Expand Down
2 changes: 1 addition & 1 deletion ImageD11/saintraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def parsedocs(self):
Parse the saint documentation for the Bruker format
"""
self.titles = []
title = None
title = help = format = None
for line in self.doc.split("\n"):
if len(line.rstrip()) == 0:
if title is not None:
Expand Down
4 changes: 2 additions & 2 deletions ImageD11/sparseframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def to_hdf_group( frame, group ):
dtype=px.dtype,
**opts )
group[pxname][:] = px
if pxname in self.meta:
group[pxname].attrs = dict( self.meta[pxname] )
if pxname in frame.meta:
group[pxname].attrs = dict( frame.meta[pxname] )


class SparseScan( object ):
Expand Down
82 changes: 0 additions & 82 deletions ImageD11/threshold_image.py

This file was deleted.

8 changes: 4 additions & 4 deletions ImageD11/tkGui/twodplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ def on_up(self,event):
import numpy as np
from math import pi
x=np.arange(0.0,3.0,0.01)
dat=epffile.powderdata(x,
np.sin(2*pi*x)+5,
np.sqrt(sin(2*pi*x)+5),
{ "title":"sin x" })
dat=data(x,
np.sin(2*pi*x)+5,
np.sqrt(np.sin(2*pi*x)+5),
{ "title":"sin x" })

root = Tk.Tk()
root.wm_title("Two dimensional plotting")
Expand Down
5 changes: 3 additions & 2 deletions ImageD11/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def sinth2_sqrt_deriv(xyz):
x,y,z = xyz
R = z*z + y*y
Q = R + x*x
SQ = sqrt(Q)
SQ = np.sqrt(Q)
R2 = R/2
# at x==y==0 this is undefined. ac
rQ_xSQ = 1/(Q + x*SQ)
Expand Down Expand Up @@ -686,9 +686,10 @@ def __init__( self, pars ):
self.sc = slow + self.ds
self.fc = fast + self.df
elif 'spline' in pars: # need to test this...
from ImageD11 import blobcorrector
b = blobcorrector.correctorclass( self.pars['spline'] )
s = int(b.ymax - b.ymin), int(b.xmax - b.xmin)
if shape in self.pars: # override. Probabl
if 'shape' in self.pars: # override. Probabl
s = self.pars['shape']
self.shape = s
self.fc, self.sc = b.make_pixel_lut( s )
Expand Down
48 changes: 0 additions & 48 deletions fixprint.py

This file was deleted.

1 change: 1 addition & 0 deletions sandbox/abonnin/fix_omega_angles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ImageD11.columnfile import columnfile
from pylab import plot
c = columnfile("mainphase.flt")
c.addcolumn(c.omega.copy(), "image_number")
c.omega[:] = (c.image_number/147).astype(int)
Expand Down
2 changes: 1 addition & 1 deletion sandbox/abonnin/make_point_sino.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from __future__ import print_function

import numpy as np
import numpy as np, pylab as pl


def read_log(fname):
Expand Down
14 changes: 7 additions & 7 deletions sandbox/bravias.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ def ferraris_and_ivaldi(ubi, tol = 0.001):
Tolerance is for grouping vector lengths.
"""
cpar = ubitocellpars(ubi)
cell = unitcell( cp )
cell = unitcell( cpar )
dlim = cell.ds( np.array( [7,7,7] ))
u.makerings( dlim , tol)
cell.makerings( dlim , tol)
mult = [ len(cell.ringhkls[d]) for d in cell.ringds ]
mx = max(mult)
mn = min(mult)
cases = {
(2, 2) : fi_triclinic,
(4, 2) : fi_monoclinic,
(8, 2) : fi_orthorhombic,
(12, 2) : fi_rhombohedral,
(16, 2) : fi_tetragonal,
(24, 2) : fi_hexagonal,
(48, 2) : fi_cubic
# (8, 2) : fi_orthorhombic,
# (12, 2) : fi_rhombohedral,
# (16, 2) : fi_tetragonal,
# (24, 2) : fi_hexagonal,
# (48, 2) : fi_cubic
}

def vecang( v1, v2 ):
Expand Down
14 changes: 2 additions & 12 deletions sandbox/ev78/integrate_them.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def edffilenameseries(stem, first=None, last=None, glob=False, extn=".edf"):
"""
if glob:
import glob, os
files = glob.glob("%s*%s"%(stem,extn))
files = glob.glob("%s*%s"%(stem,extn))
filesdone = glob.glob("%s*%s"%(stem,".dat"))
filesdone = [f.replace(".dat",extn) for f in filesdone]
filesdone = [f.replace(".dat",extn) for f in filesdone]
for f in files:
if f not in filesdone:
yield f
Expand Down Expand Up @@ -382,16 +382,6 @@ def check_pars( o ):



def polstuff():
# Now look for the polarisation component
stth = numpy.sin(integrator.twoThetaArray(data.shape))
cchi = numpy.cos( integrator.chiArray(data.shape)*2 )
pfac = cchi*stth*stth
#print p.min(),p.max(),stth.min(),stth.max()
#numpy.divide( calcimage, p , calcimage )
t.bench("computed image")
poldifference = (data - calcimage)*mask*pfac


if __name__ == "__main__":
from optparse import OptionParser
Expand Down
2 changes: 1 addition & 1 deletion sandbox/ev78/makevols.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def readtxt(fname):
Reads txt file written by spec and fills in table of:
filenumber, diffty, diffrz, pico3, current
"""
cnext = None
cnext = cindex = None
h = {}
vals = []
ctrs = "diffty pico3 notsrcu".split()
Expand Down
18 changes: 9 additions & 9 deletions sandbox/find_pseudo_twins.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

tol = 2.35*angtol*np.pi/180.0
tol2 = tol*tol
print "#",
print( "#", end = ' ')
for i,g1 in enumerate(gl):
np.dot( g1.ub, hkls, out=gv1 )
for j in range(i+1, len(gl)):
Expand All @@ -80,22 +80,22 @@
dist = np.sqrt( ((g1.translation-g2.translation)**2).sum() )
if dist > 500:
continue
print "\n# grains %d %d frac %.3f scor %.3f"%(i,j,tscor,scor.sum()),
print("\n# grains %d %d frac %.3f scor %.3f"%(i,j,tscor,scor.sum()),end=' ')
rotangs = xfab.symmetry.Umis( g1.u, g2.u, 7 )
angs = [a[1] for a in rotangs]
dist = np.sqrt( ((g1.translation-g2.translation)**2).sum() )
print " misori %.3f dist %.1f"%(np.min(angs), dist)
print "# g1.t % 7.3f % 7.3f % 7.3f"%tuple(g1.translation)
print "# g2.t % 7.3f % 7.3f % 7.3f"%tuple(g2.translation)
print "# i (h k l) -> (h k l) Angle Scor "
print(" misori %.3f dist %.1f"%(np.min(angs), dist))
print("# g1.t % 7.3f % 7.3f % 7.3f"%tuple(g1.translation))
print("# g2.t % 7.3f % 7.3f % 7.3f"%tuple(g2.translation))
print("# i (h k l) -> (h k l) Angle Scor ")
ip = 0
order = np.argsort(scor)
for k in order[::-1]:
if scor[k] > 0.001:
h1,k1,l1 = hkls.T[k]
h2,k2,l2 = hklr.T[k]
ip += 1
print "%d ( % d % d % d ) -> ( % .3f % .3f % .3f ) %.3f %.5f"%( ip,
h1,k1,l1, h2,k2,l2, np.degrees(np.sqrt(angerr2[k])),scor[k])
print "#",
print( "%d ( % d % d % d ) -> ( % .3f % .3f % .3f ) %.3f %.5f"%( ip,
h1,k1,l1, h2,k2,l2, np.degrees(np.sqrt(angerr2[k])),scor[k]))
print("#",end=' ')

2 changes: 1 addition & 1 deletion sandbox/grid_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def domap( OmFloat, OmSlop,
o.scandata["internal"] = colfile
o.tolerance = tol
o.readubis( grainsfile )
if symmetry is not "triclinic":
if symmetry != "triclinic":
o.makeuniq( symmetry )
o.generate_grains()
o.refinepositions()
Expand Down
2 changes: 1 addition & 1 deletion sandbox/newpeaksearch3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def dict_to_colfile( c ):
colf.set_bigarray( [ c[t] for t in titles ] )
return colf


# /data/id11/jon/inhouse/jon/mar10/segment2d
hdffile = "fe3o4_peaks.hdf"
folder = "entry"
parfile = "avg.par"
Expand Down
Loading