Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def find_executable(target):
# scripts from project configuration
if "scripts" in config:
for script_name in config["scripts"]:
if os.path.basename(script) == target:
if os.path.basename(script_name) == target:
return ("path", os.path.abspath(script_name))
# entry-points from project configuration
if "entry_points" in config:
Expand Down
1 change: 1 addition & 0 deletions src/PyMca5/PyMcaCore/LegacyStackROIBatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def main(args):
images = result["images"]
nImages = images.shape[0]

fileRoot = args.fileRoot
if not fileRoot:
fileRoot = "images"

Expand Down
5 changes: 1 addition & 4 deletions src/PyMca5/PyMcaCore/McaStackExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
HAS_NEXUS_UTILS = False
_logger.info("PyMca5.PyMcaIO.NexusUtils could not be imported")

if sys.version_info < (3,):
strdtype = h5py.special_dtype(vlen=unicode)
else:
strdtype = h5py.special_dtype(vlen=str)
strdtype = h5py.special_dtype(vlen=str)

def exportStackList(stackList, filename, channels=None, calibration=None):
if hasattr(stackList, "data") and hasattr(stackList, "info"):
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaCore/NexusTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import posixpath
try:
# try to import hdf5plugin
if hdf5plugin not in sys.modules:
if "hdf5plugin" not in sys.modules:
import hdf5plugin
except Exception:
# but do not crash just because of it
Expand Down
8 changes: 3 additions & 5 deletions src/PyMca5/PyMcaCore/StackBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import sys
import glob
import logging
import copy

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -167,11 +168,8 @@ def getPlugins(self):
del self.pluginInstanceDict[plugin]
if plugin in sys.modules:
if hasattr(sys.modules[plugin], targetMethod):
if sys.version < '3.0':
reload(sys.modules[plugin])
else:
import imp
imp.reload(sys.modules[plugin])
import importlib
importlib.reload(sys.modules[plugin])
else:
try:
__import__(plugin)
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaCore/XiaEdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def reset(self):
try:
self.__readStat()
except Exception:
raise XiaEdfError("Cannot parse header in <%s>"%filename)
raise XiaEdfError("Cannot parse header in <%s>" % self.filename)

def __readStat(self):
self.header= self.edf.GetHeader(0)
Expand Down
7 changes: 2 additions & 5 deletions src/PyMca5/PyMcaGraph/PluginLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,8 @@ def getPlugins(self, method=None, directoryList=None, exceptions=False):
del self.pluginInstanceDict[plugin]
if plugin in sys.modules:
if hasattr(sys.modules[plugin], targetMethod):
if sys.version.startswith('3'):
import importlib
importlib.reload(sys.modules[plugin])
else:
reload(sys.modules[plugin])
import importlib
importlib.reload(sys.modules[plugin])
else:
__import__(plugin)
if hasattr(sys.modules[plugin], targetMethod):
Expand Down
7 changes: 5 additions & 2 deletions src/PyMca5/PyMcaGraph/backends/MatplotlibBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,11 @@ def addImage(self, data, legend=None, info=None,
shape = data.shape
if 0:
# this supports non regularly spaced coordenates!!!!

if colormap is None:
Comment thread
woutdenolf marked this conversation as resolved.
colormap = self.getDefaultColormap()
cmap = self.__getColormap(colormap['name'])

x = xmin + numpy.arange(w) * xScale[1]
y = ymin + numpy.arange(h) * yScale[1]
image = NonUniformImage(self.ax,
Expand All @@ -2505,8 +2510,6 @@ def addImage(self, data, legend=None, info=None,
picker=picker,
cmap=cmap)



image.set_data(x, y, data)
xmin, xmax = self.getGraphXLimits()
ymin, ymax = self.getGraphYLimits()
Expand Down
3 changes: 2 additions & 1 deletion src/PyMca5/PyMcaGui/io/QEdfFileWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,8 @@ def closeFile(self, filename=None):
#print self.selection
if (self.selection is not None) and filename in self.selection:
nmca = 0
for key in self.selection[filename].keys():
mcakeys = list(self.selection[filename].keys())
for key in mcakeys:
nmca += len(self.selection[filename][key]['rows']) + len(self.selection[filename][key]['cols'])
if nmca:
msg= "%d mca are linked to that EdfFile source.\n"% nmca
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/io/QSpsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ def getSelection(self):
def __refreshSelection(self):
return
_logger.debug("__refreshSelection(self) called")
_logger.debug(selection)
_logger.debug(self.selection)
if self.selection is not None:
sel = self.selection.get(self.data.SourceName, {})
selkeys = []
Expand Down
4 changes: 2 additions & 2 deletions src/PyMca5/PyMcaGui/io/hdf5/DataViewerSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def _emitSignal(self, action="ADD"):
ddict = {}
ddict["action"] = action
ddict["slice"] = self.getSelection()
shape = self.__data.shape
ddict["index"] = sel
# shape = self.__data.shape
# ddict["index"] = sel
self.sigSliceSelectorSignal.emit(ddict)

def setData(self, data, mode=None):
Expand Down
5 changes: 2 additions & 3 deletions src/PyMca5/PyMcaGui/io/hdf5/HDF5McaTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def setMcaSelection(self, ddict):
if 0:
if 'aliaslist' in keys:
aliaslist = ddict['aliaslist']
elif len(self.aliasList) == len(cntlist):
elif len(self.aliasList) == len(self.mcaList):
Comment thread
woutdenolf marked this conversation as resolved.
Outdated
aliaslist = self.aliasList * 1
else:
aliaslist = self.mcaList * 1
Expand All @@ -404,8 +404,7 @@ def setMcaSelection(self, ddict):
self.mcaSelection = []
self.mcaSelectionType = []
for i in range(len(selection)):
idx = selection[idx]
if idx < len(mcalist):
if selection[i] < len(mcalist):
self.mcaSelection.append(selection[i])
self.mcaSelectionType.append(selectionType[i])
self._update()
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/math/NNMAWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def setParameters(self, ddict):
if "method" in ddict:
self.buttonGroup.buttons()[ddict["method"]].setChecked(True)
if "regions" in ddict:
self.regionsWidget.setRegions(regions)
self.regionsWidget.setRegions(ddict["regions"])
return

def getParameters(self):
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/math/PCAWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def setParameters(self, ddict):
else:
self.binningCombo.setEnabled(False)
if "regions" in ddict:
self.regionsWidget.setRegions(regions)
self.regionsWidget.setRegions(ddict["regions"])
return

def getParameters(self):
Expand Down
4 changes: 2 additions & 2 deletions src/PyMca5/PyMcaGui/math/fitting/QScriptOption.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def setdefaults(self, ddict):
return

def test():
a = qt.QApplication(sys.argv)
app = qt.QApplication(sys.argv)
app.lastWindowClosed.connect(app.quit)
#w = FieldSheet(fields=(["TextField",'Simple Entry'],
# ["EntryField",'entry','MyLabel'],
Expand All @@ -317,7 +317,7 @@ def test():
w=QScriptOption(name='QScriptOptions',sheets=(sheet1,sheet2),
default={'radio':1,'entry':'type here','label':1})
w.show()
a.exec()
app.exec()
print(w.output)

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/physics/xrf/QPeriodicTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def __init__(self, master=None, name=None, fl=0, detailed=1, single=0):
self.detailed= (detailed==1)

try:
strlist= QStringList()
strlist= qt.QStringList()
except Exception:
strlist= []
strlist.append("Z")
Expand Down
4 changes: 3 additions & 1 deletion src/PyMca5/PyMcaGui/plotting/PlotWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ def __init__(self, parent=None, backend=None,
self.setGraphYLabel("Y")
self.setCallback(callback)

self._legends = legends

def showLegends(self, flag=True):
if legends:
if self._legends:
_logger.warning("Legends widget to be implemented")

def graphCallback(self, ddict=None):
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/ImageListStatsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def setImageList(self, images, image_names=None):
self.imageList = images
if image_names is None:
self.imageNames = []
for i in range(nimages):
for i in range(len(images)):
self.imageNames.append("Image %02d" % i)
else:
self.imageNames = image_names
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/LegacyPyMcaBatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def __getFileType(self,inputfile):
except Exception:
qt.QMessageBox.critical(self,
sys.exc_info()[0],
'I do not know what to do with file\n %s' % ffile)
'I do not know what to do with file\n %s' % inputfile)
self.raise_()
return None

Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/McaWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def mcaSimpleFitSignal(self):
self.__simplefitcalibration = calib
calibrationOrder = curveinfo.get('McaCalibOrder', 2)
if calibrationOrder == 'TOF':
x = calib[2] + calib[0] / pow(x - alib[1],2)
x = calib[2] + calib[0] / pow(x - calib[1],2)
else:
x = calib[0] + calib[1] * x + calib[2] * x * x
self.simplefit.setdata(x=x,y=y,
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/PyMcaBatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ def __getFileType(self,inputfile):
except Exception:
qt.QMessageBox.critical(self,
sys.exc_info()[0],
'I do not know what to do with file\n %s' % ffile)
'I do not know what to do with file\n %s' % inputfile)
self.raise_()
return None

Expand Down
11 changes: 9 additions & 2 deletions src/PyMca5/PyMcaGui/pymca/PyMcaMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
from PyMca5.PyMcaGui.io import PyMcaFileDialogs
QTVERSION = qt.qVersion()

try:
import silx
# try to import silx prior to importing matplotlib to prevent
# unnecessary warning
import silx.gui.plot
except Exception:
pass

from PyMca5.PyMcaGui.pymca import PyMcaMdi
IconDict = PyMcaMdi.IconDict
IconDict0 = PyMcaMdi.IconDict0
Expand Down Expand Up @@ -167,12 +175,11 @@
from PyMca5.PyMcaIO import ConfigDict
from PyMca5 import PyMcaDirs

XIA_CORRECT = False
try:
from PyMca5.PyMcaCore import XiaCorrect
XIA_CORRECT = True
except Exception:
pass
XIA_CORRECT = False

SOURCESLIST = QDispatcher.QDataSource.source_types.keys()

Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/PyMcaMdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def onWinToolMenu(self, idx):
self.onWinToolAction()

def onWinToolAction(self):
apply(self.winToolMenuAction, ())
apply(self.winToolMenuAction, ())

#
# Mdi windows geometry
Expand Down
1 change: 1 addition & 0 deletions src/PyMca5/PyMcaGui/pymca/QDispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def _addSelectionSlot(self, sel_list, event=None):
#the clients will be able to retrieve the data
#the problem is that 10 clients will requiere
#10 read outs
import weakref
ddict["sourcereference"] = weakref.ref(source)
selectionList.append(ddict)
if lastEvent != event:
Expand Down
4 changes: 2 additions & 2 deletions src/PyMca5/PyMcaGui/pymca/QStackWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,9 @@ def loadSecondaryStack(self):
for i in range(len(stack)):
if stack[i] is not None:
secondary = QStackWidget(primary=False,
rgbwidget=widget.rgbWidget)
rgbwidget=self.rgbWidget)
secondary.setStack(stack[i])
widget.addSecondary(secondary)
self.addSecondary(secondary)
stack[i] = None
else:
secondary = QStackWidget(rgbwidget=self.rgbWidget,
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/SilxScanWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def getPrintPreviewTitle(self):
# no need to add a second one
return title
except Exception:
logger.warning('Problem accessing ScanWindow plot title')
_logger.warning('Problem accessing ScanWindow plot title')
if self.scanWindowInfoWidget is not None:
if not self.infoDockWidget.isHidden():
info = self.scanWindowInfoWidget.getInfo()
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/SilxScatterWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _addSelection(self, selectionlist):
break
if not gotIt:
raise ValueError("Unmatched dimensions following C order")
data = data.reshape(xsize, *oldDataShape[i+1:])
data = data.reshape(x.size, *oldDataShape[i+1:])
nscatter = data.shape[0]
else:
raise ValueError("Unmatched dimensions among axes and signals")
Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaGui/pymca/StackPluginResultsWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def setStackPluginResults(
self.imageList = images
if image_names is None:
self.imageNames = []
for i in range(nimages):
for i in range(len(images)):
self.imageNames.append("Image %02d" % i)
else:
self.imageNames = image_names
Expand Down
5 changes: 1 addition & 4 deletions src/PyMca5/PyMcaIO/ArraySave.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@
HDF5 = True
try:
import h5py
if sys.version_info < (3, ):
text_dtype = h5py.special_dtype(vlen=unicode)
else:
text_dtype = h5py.special_dtype(vlen=str)
text_dtype = h5py.special_dtype(vlen=str)
except ImportError:
HDF5 = False

Expand Down
2 changes: 1 addition & 1 deletion src/PyMca5/PyMcaIO/BAXSCSVFileParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def scanno(self):
"""
Gives back the number of scans in the file
"""
return len(self_scan)
return len(self._scan)

def list(self):
return "1:1"
Expand Down
9 changes: 5 additions & 4 deletions src/PyMca5/PyMcaIO/MarCCD.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@

class MarCCD(object):
def __init__(self, filename):
if isinstance(filename, file):
fd = filename
else:
if isinstance(filename, str):
# make sure we work with bytes
fd = open(filename, 'rb')
else:
fd = filename

order = fd.read(2)
if order == "II":
#intel, little endian
Expand Down Expand Up @@ -74,7 +75,7 @@ def __init__(self, filename):
data = data.reshape(info["nfast"], info["nslow"])
self.__data = data
self.__info = info
if not isinstance(filename, file):
if isinstance(filename, str):
fd.close()

def getData(self, *var, **kw):
Expand Down
Loading