Skip to content

Commit

Permalink
Merge pull request #190 from jonwright/master
Browse files Browse the repository at this point in the history
appveyor is green again
  • Loading branch information
jonwright authored Dec 1, 2023
2 parents 634ce97 + c162c90 commit e79549b
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 63 deletions.
19 changes: 12 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@

image: Visual Studio 2015

build: false


environment:
matrix:
- CONDA: C:\Miniconda
- CONDA: C:\Miniconda-x64
- CONDA: C:\Miniconda36
- CONDA: C:\Miniconda36-x64
- CONDA: C:\Python27
- CONDA: C:\Python27-x64
- CONDA: C:\Python38-x64
# Meson errors, no binaries for 32-bits - CONDA: C:\Python38

init:
- "ECHO %CONDA%"

install:
- "SET PATH=%CONDA%;%CONDA%\\Scripts;%CONDA%\\Library\\bin;%CONDA%\\DLLS;%PATH%"
- conda config --set always_yes yes --set changeps1 no
- conda info -a
- "mkdir C:\\tmp"
- "set TMPDIR=C:\\tmp"
- python -c "import sys; print(sys.executable, sys.version)"
- python -m pip install --upgrade pip setuptools
- python -m pip install pytest numpy
- python -m pip install --ignore-installed certifi --upgrade-strategy only-if-needed --only-binary=h5py --editable .
- python -m pip install --ignore-installed certifi --upgrade-strategy only-if-needed --only-binary=h5py --only-binary=scipy --only-binary=hdf5plugin .


test_script:
- cd test
- python -m pytest

10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def build_extension(self, ext):
# note that the pyf must come first
cnames = "_cImageD11.pyf blobs.c cdiffraction.c cimaged11utils.c"+\
" closest.c connectedpixels.c darkflat.c localmaxlabel.c sparse_image.c "+\
" splat.c"
" splat.c"

csources = [os.path.join('src',c) for c in cnames.split()]

Expand Down Expand Up @@ -147,22 +147,24 @@ def build_extension(self, ext):
]

useful = [ # stuff you probably want, and should be able to get easily
"fabio",
'fabio==0.2.2 ; python_version < "3" and sys_platform == "win32" ',
'fabio ; python_version >= "3" or sys_platform != "win32" ',
"xfab>=0.0.4", #
# comes from xfab : "PyCifRW",
"matplotlib", # tkGui
"pyopengltk", # plot3d in tkGui
"scipy", #
'hdf5plugin==1.4.1 ; python_version < "3" and sys_platform == "win32" ',
'hdf5plugin ; python_version >= "3" ',
'h5py',
'pyyaml',
"pytest", # for the CI
'numba==0.46.0 ; python_version < "3" ', # for some test cases
'llvmlite==0.30.0 ; python_version < "3" ', # for some test cases
'numba ; python_version > "3" ', # for some test cases
'numba ; python_version >= "3" ', # for some test cases
"bslz4_to_sparse",
"fast_histogram",
"scikit-image",
"hdf5plugin",
"tqdm",
]

Expand Down
70 changes: 36 additions & 34 deletions test/demo/qtsplat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from timeit import default_timer as timer
import numpy as np
from scipy.spatial.transform import Rotation
if not hasattr( Rotation, 'as_matrix' ):
Rotation.as_matrix = Rotation.as_dcm
from ImageD11 import columnfile, transform, grain, cImageD11
import nbsplat

Expand All @@ -31,33 +33,33 @@ def __init__(self,
def loadcolf(self, colfilename):
self.colf = columnfile.columnfile( colfilename )
self.nrows = self.colf.nrows

def loadpars(self, fname):
self.colf.parameters.loadparameters( fname )
self.colf.updateGeometry()

def loadgrains(self, fname):
self.grains = grain.read_grain_file( fname )
if len(self.grains)>0:
self.resetlabels()
self.assignlabels()

def get(self, name):
if name in self.colf.titles:
return self.colf.getcolumn(name)
else:
raise Exception("name "+name+" not found")

def xyz(self):
return [self.colf.getcolumn(name) for name in self.names]

def grain_drlv2(self, grainid):
x,y,z = self.xyz()
hkl = np.dot( self.grains[grainid].ubi, self.xyz )
dhkl = np.round(hkl)-hkl
drlv2 = (dhkl*dhkl).sum(axis=0)
self.colf.addcolumn("drlv2_%d"%(grainid))

def resetlabels(self):
self.labels = np.empty( self.nrows, 'i')
self.labels.fill(-1)
Expand All @@ -71,7 +73,7 @@ def resetlabels(self):
self.colf.zl ) ).T.copy()
self.colf.addcolumn( self.labels, "labels" )
self.colf.addcolumn( self.drlv2, "drlv2" )

def assignlabels( self ):
self.resetlabels()
nr = self.nrows
Expand Down Expand Up @@ -102,7 +104,7 @@ def assignlabels( self ):
self.colf.labels[:]= self.labels
self.colf.drlv2[:] = self.drlv2


class splat3dview:
def __init__(self, w=2000, h=1500):
self.w = self.h = None
Expand Down Expand Up @@ -137,12 +139,12 @@ def resetrot(self):
self.need_redraw = True
self.u0 = np.dot(self.u, self.u0)
self.u = np.eye(3, dtype=float)

def matrix(self):
return self.scale*np.dot(self.u, self.u0)



def drawPixMapOnWidget(self, datas, target ):
if self.need_redraw:
start = timer()
Expand All @@ -167,7 +169,7 @@ def drawPixMapOnWidget(self, datas, target ):
# order should be here too.
# print("draw",timer()-start)
# fixme - can we write on i.bits() directly ?
p = rgbtopm( self.rgba )
p = rgbtopm( self.rgba )
target.setPixmap( p )
if DOPROF:
x.disable()
Expand All @@ -185,8 +187,8 @@ def rgbtopm( rgb ):
i = QtGui.QImage(rgb, rgb.shape[1], rgb.shape[0],
QtGui.QImage.Format_RGB32 )
return QtGui.QPixmap.fromImage(i)


def colormap(x, colors):
# fixme: load save or matplotlib or select
xmin = x.min()
Expand All @@ -198,12 +200,12 @@ def colormap(x, colors):
colors[:,1] = np.interp( x, [ xmin, xcen, xmax ], [ 64, 255, 64]) # G
colors[:,2] = np.interp( x, [ xmin, xcen, xmax ], [255, 64, 64]) # B
colors[:,3] = 0 # alpha










class Example( QtWidgets.QWidget ):
def __init__(self, vu, da):
QtWidgets.QWidget.__init__(self)
Expand All @@ -217,30 +219,30 @@ def __init__(self, vu, da):
self.doRot = False
self.animate()
self.show()

def mousePressEvent(self, e):
#print('down', e.x(),e.y(),e.button() )
self.doRot = True
self.resetrot( e.x(), e.y())

def resetrot(self, x0, y0 ):
self.x0 = x0
self.y0 = y0
self.vu.resetrot()

def mouseReleaseEvent(self, e):
self.mouseMoveEvent(e)
#print('up', e.x(),e.y())
self.vu.resetrot( )
self.doRot = False

def mouseMoveEvent(self,e):
# print('move',e.x(),e.y())
axes = "XYZ"
if e.modifiers() == QtCore.Qt.ShiftModifier:
axes="ZYX"
axes="ZYX"
if e.modifiers() == QtCore.Qt.ControlModifier:
axes="XZY"
axes="XZY"
self.rotateview( e.x(), e.y(), axes )

def rotateview(self, ex, ey, axes="XYZ"):
Expand All @@ -249,7 +251,7 @@ def rotateview(self, ex, ey, axes="XYZ"):
dx = (self.x0 - self.ex)/10. # 0.1 deg/px
dy = (self.y0 - self.ey)/10.
self.vu.rotate( dy, -dx, axes )

rotateactions = {
QtCore.Qt.Key_X : ( 90, 0, "XYZ"),
QtCore.Qt.Key_Y : ( 90, 0, "YZX"),
Expand Down Expand Up @@ -289,7 +291,7 @@ def hlp(self):
#qmb.setText(h)
#qmb.show()


def keyPressEvent(self,e):
k = e.key()
print("Got key",k)
Expand Down Expand Up @@ -326,23 +328,23 @@ def keyPressEvent(self,e):
else:
self.status.setText("No column %s"%(self.coloractions[k]))
self.vu.need_redraw=True

def keyReleaseEvent(self,e):
if self.doRot and e.key() == QtCore.Qt.Key_Shift:
self.x0 = self.ex
self.y0 = self.ey
self.vu.resetrot()


def initUI(self):

self.layout = QtWidgets.QVBoxLayout()

self.lbl = QtWidgets.QLabel(self)
self.lbl.resize( self.vu.w, self.vu.h )
self.lbl.setMinimumSize( 128, 128 )
e = QtWidgets.QSizePolicy.Expanding
self.lbl.setSizePolicy( e, e )
self.lbl.setSizePolicy( e, e )
self.layout.addWidget( self.lbl )

self.status = QtWidgets.QLabel(self)
Expand All @@ -356,11 +358,11 @@ def initUI(self):
qb= QtWidgets.QPushButton("Quit", self)
qb.clicked.connect( self.close )
self.buttons.addWidget(qb)

self.layout.addLayout( self.buttons )
self.setLayout( self.layout )


def animate(self):
self.vu.drawPixMapOnWidget( self.da, self.lbl)
QtCore.QTimer.singleShot(1000//24, self.animate )
Expand All @@ -369,7 +371,7 @@ def animate(self):
def resizeEvent(self, evt):
self.vu.need_redraw=True




def run( colf, pars, grains):
Expand All @@ -393,4 +395,4 @@ def run( colf, pars, grains):
pass

run( colf, pars, grains )

Loading

0 comments on commit e79549b

Please sign in to comment.