diff options
57 files changed, 329 insertions, 259 deletions
@@ -1,12 +1,12 @@ Metadata-Version: 1.1 Name: PyMca5 -Version: 5.5.1 +Version: 5.5.2 Summary: Mapping and X-Ray Fluorescence Analysis Home-page: http://pymca.sourceforge.net Author: V. Armando Sole Author-email: sole@esrf.fr License: MIT -Download-URL: https://github.com/vasole/pymca/archive/v5.5.1.tar.gz +Download-URL: https://github.com/vasole/pymca/archive/v5.5.2.tar.gz Description: Stand-alone application and Python tools for interactive and/or batch processing analysis of X-Ray Fluorescence Spectra. Graphical user interface (GUI) and batch processing capabilities provided Platform: any diff --git a/PyMca5.egg-info/PKG-INFO b/PyMca5.egg-info/PKG-INFO index 2c2d135..fbcbfa2 100755 --- a/PyMca5.egg-info/PKG-INFO +++ b/PyMca5.egg-info/PKG-INFO @@ -1,12 +1,12 @@ Metadata-Version: 1.1 Name: PyMca5 -Version: 5.5.1 +Version: 5.5.2 Summary: Mapping and X-Ray Fluorescence Analysis Home-page: http://pymca.sourceforge.net Author: V. Armando Sole Author-email: sole@esrf.fr License: MIT -Download-URL: https://github.com/vasole/pymca/archive/v5.5.1.tar.gz +Download-URL: https://github.com/vasole/pymca/archive/v5.5.2.tar.gz Description: Stand-alone application and Python tools for interactive and/or batch processing analysis of X-Ray Fluorescence Spectra. Graphical user interface (GUI) and batch processing capabilities provided Platform: any diff --git a/PyMca5/EPDL97/EADLParser.py b/PyMca5/EPDL97/EADLParser.py index 72fb885..7057c51 100644 --- a/PyMca5/EPDL97/EADLParser.py +++ b/PyMca5/EPDL97/EADLParser.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2015 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -746,8 +746,8 @@ def getFluorescenceYields(z, lines=None): def getCosterKronigYields(z, shell='L1', lines=None): """ getCosterKronigYields(z, shell='L1') - Returns the non-zero Coster-Kronig yields as keys of a dictionnary - or just an empty dictionnary. + Returns the non-zero Coster-Kronig yields as keys of a dictionary + or just an empty dictionary. """ if lines is None: lines = EADL97_DATA @@ -773,7 +773,7 @@ def getLShellCosterKronigYields(z, lines=None): """ getLShellCosterKronigYields(z) Returns the L-shell Coster-Kronig yields of an element as keys of a - dictionnary + dictionary """ ddict = {} ddict['f12'] = 0.0 @@ -791,7 +791,7 @@ def getMShellCosterKronigYields(z, lines=None): """ getMShellCosterKronigYields(z) Returns the M-shell Coster-Kronig yields of an element as keys of a - dictionnary. It does not check for physical meaning. So, it will give + dictionary. It does not check for physical meaning. So, it will give zeroes when needed. """ ddict = {} diff --git a/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py b/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py index 5a79d3c..f731630 100644 --- a/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py +++ b/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py @@ -69,9 +69,8 @@ def getObject3DInstance(config=None): #file index is irrelevant in case of an actual 3D stack. filename = fileList[0] legend = os.path.basename(filename) - f = h5py.File(filename) - stack = f['Image']['data'].value - f = None + with h5py.File(filename, mode='r') as f: + stack = f['Image']['data'][()] if stack is None: raise IOError("Problem reading stack.") object3D = ChimeraStack(name=legend) @@ -121,8 +120,8 @@ if __name__ == "__main__": if not os.path.exists(filename): print("File does not exists") sys.exit(1) - f = h5py.File(filename) - stack = f['Image']['data'].value + with h5py.File(filename, mode='r') as f: + stack = f['Image']['data'][()] if stack is None: raise IOError("Problem reading stack.") object3D = ChimeraStack(name=os.path.basename(filename)) diff --git a/PyMca5/PyMcaCore/DataObject.py b/PyMca5/PyMcaCore/DataObject.py index d330440..315f09d 100644 --- a/PyMca5/PyMcaCore/DataObject.py +++ b/PyMca5/PyMcaCore/DataObject.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2014 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -36,7 +36,7 @@ class DataObject(object): ''' Simple container of an array and associated information. Basically it has the members: - info: A dictionnary + info: A dictionary data: An array, usually 2D, 3D, ... In the past also incorporated selection methods. @@ -54,7 +54,7 @@ class DataObject(object): def __init__(self): ''' - Defaut Constructor + Default Constructor ''' self.info = {} self.data = numpy.array([]) diff --git a/PyMca5/PyMcaCore/EdfFileDataSource.py b/PyMca5/PyMcaCore/EdfFileDataSource.py index 72b3cf3..e8cd23b 100644 --- a/PyMca5/PyMcaCore/EdfFileDataSource.py +++ b/PyMca5/PyMcaCore/EdfFileDataSource.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2014 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -154,7 +154,7 @@ class EdfFileDataSource(object): def getDataObject(self,key,selection=None): """ - selection: a dictionnary with the keys pos and size: (x), (x,y) or (x,y,z) + selection: a dictionary with the keys pos and size: (x), (x,y) or (x,y,z) tuples defining a roi If not defined, takes full array """ diff --git a/PyMca5/PyMcaCore/LegacyStackROIBatch.py b/PyMca5/PyMcaCore/LegacyStackROIBatch.py index e651a31..7d333f4 100644 --- a/PyMca5/PyMcaCore/LegacyStackROIBatch.py +++ b/PyMca5/PyMcaCore/LegacyStackROIBatch.py @@ -73,7 +73,7 @@ class StackROIBatch(object): :param xAtMinMax: if True, calculate X at maximum and minimum Y . Default is false. :param index: Index of dimension where to apply the ROIs. :param xLabel: Type of ROI to be used. - :return: A dictionnary with the images and the image names as keys. + :return: A dictionary with the images and the image names as keys. """ if y is None: raise RuntimeError("y keyword argument is mandatory!") diff --git a/PyMca5/PyMcaCore/NexusDataSource.py b/PyMca5/PyMcaCore/NexusDataSource.py index d24ecca..d175930 100644 --- a/PyMca5/PyMcaCore/NexusDataSource.py +++ b/PyMca5/PyMcaCore/NexusDataSource.py @@ -48,6 +48,36 @@ from . import NexusTools SOURCE_TYPE = "HDF5" +try: + from silx.io import open as silxh5open + logging.getLogger("silx.io.fabioh5").setLevel(logging.CRITICAL) +except: + silxh5open = None + +def h5open(filename): + try: + # try to open as usual using h5py + return h5py.File(filename, "r") + except: + try: + if h5py.version.hdf5_version_tuple < (1, 10): + # no reason to try SWMR mode + raise + elif h5py.is_hdf5(filename): + _logger.info("Cannot open %s. Trying in SWMR mode" % filename) + return h5py.File(filename, "r", libver='latest', swmr=True) + else: + raise + except: + if silxh5open: + try: + _logger.info("Trying to open %s using silx" % filename) + return silxh5open(filename) + except: + _logger.info("Cannot open %s using silx" % filename) + # give back the original error + return h5py.File(filename, "r") + _logger = logging.getLogger(__name__) #sorting method @@ -152,7 +182,7 @@ class NexusDataSource(object): self.sourceName = [] for name in nameList: if not isinstance(name, basestring): - if not isinstance(name, phynx.File): + if not isinstance(name, h5py.File): text = "Constructor needs string as first argument" raise TypeError(text) else: @@ -170,17 +200,17 @@ class NexusDataSource(object): self._sourceObjectList=[] FAMILY = False for name in self.__sourceNameList: - if isinstance(name, phynx.File): + if isinstance(name, h5py.File): self._sourceObjectList.append(name) continue if not os.path.exists(name): if '%' in name: - phynxInstance = phynx.File(name, 'r', + phynxInstance = h5py.File(name, 'r', driver='family') else: raise IOError("File %s does not exists" % name) try: - phynxInstance = phynx.File(name, 'r') + phynxInstance = h5open(name) except IOError: if 'FAMILY DRIVER' in sys.exc_info()[1].args[0].upper(): FAMILY = True @@ -188,7 +218,7 @@ class NexusDataSource(object): raise except TypeError: try: - phynxInstance = phynx.File(name, 'r') + phynxInstance = h5open(name) except IOError: if 'FAMILY DRIVER' in sys.exc_info()[1].args[0].upper(): FAMILY = True @@ -204,7 +234,7 @@ class NexusDataSource(object): if FAMILY: pattern = get_family_pattern(self.__sourceNameList) if '%' in pattern: - phynxInstance = phynx.File(pattern, 'r', + phynxInstance = h5py.File(pattern, 'r', driver='family') else: raise IOError("Cannot read set of HDF5 files") @@ -268,7 +298,7 @@ class NexusDataSource(object): """ key: a string of the form %d.%d indicating the file and the entry starting by 1. - selection: a dictionnary generated via QNexusWidget + selection: a dictionary generated via QNexusWidget """ _logger.debug("getDataObject selection = %s", selection) if selection is not None: @@ -333,7 +363,7 @@ class NexusDataSource(object): elif "::" in mcaDatasetObjectPath: fileName, path = mcaDatasetObjectPath.split() if os.path.exists(fileName): - with h5py.File(fileName, "r") as h5: + with h5open(fileName) as h5: if path in h5: dataset = h5[path][()] if dataset is None: @@ -384,7 +414,7 @@ class NexusDataSource(object): output.info["McaLiveTime"] = \ output.info["McaLiveTime"].sum() if selection['mcaselectiontype'].lower() != "sum": - output.info["McaLiveTime"] /= divider + output.info["McaLiveTime"] /= divider except: # import traceback _logger.error("%s", sys.exc_info()) @@ -460,7 +490,7 @@ class NexusDataSource(object): # calculate the average _logger.debug("AVERAGE") data /= nSpectra - else: + else: _logger.warning("Unsupported selection type %s", mcaselectiontype) _logger.warning("Calculating average") diff --git a/PyMca5/PyMcaCore/NexusTools.py b/PyMca5/PyMcaCore/NexusTools.py index 289ace1..c082261 100644 --- a/PyMca5/PyMcaCore/NexusTools.py +++ b/PyMca5/PyMcaCore/NexusTools.py @@ -35,6 +35,15 @@ from operator import itemgetter import re import posixpath from h5py import File, Dataset, Group +try: + from silx.io import is_dataset, is_group +except: + def is_dataset(something): + return False + + def is_group(something): + return False + import logging _logger = logging.getLogger(__name__) @@ -106,12 +115,16 @@ def isGroup(item): return True elif hasattr(item, "keys"): return True + elif is_group(item): + return True else: return False def isDataset(item): if isinstance(item, Dataset): return True + elif is_dataset(item): + return True else: return False @@ -216,7 +229,7 @@ def getMcaList(h5file, path, dataset=False, ignore=None): "energy"] datasetList =[] def visit_function(name, obj): - if isDataset(obj): + if is_dataset(obj): append = False forget = False namebased = False @@ -548,7 +561,11 @@ if __name__ == "__main__": except: print("Usage: NexusTools <file> <key>") sys.exit() - h5 = h5py.File(sourcename, 'r') + try: + from silx.io import open as h5open + h5 = h5open(sourcename) + except: + h5 = h5py.File(sourcename, 'r') entries = getNXClassGroups(h5, "/", ["NXentry", b"NXentry"], single=False) if not len(entries): entries = [item for name, item in h5["/"].items() if isGroup(item)] diff --git a/PyMca5/PyMcaCore/PyMcaBatchBuildOutput.py b/PyMca5/PyMcaCore/PyMcaBatchBuildOutput.py index 497ced5..a68942e 100644 --- a/PyMca5/PyMcaCore/PyMcaBatchBuildOutput.py +++ b/PyMca5/PyMcaCore/PyMcaBatchBuildOutput.py @@ -131,13 +131,13 @@ class PyMcaBatchBuildOutput(object): def _mergeH5(self, parts, outfilename): shutil.copy(parts[0], outfilename) - with h5py.File(outfilename) as fout: + with h5py.File(outfilename, mode='a') as fout: for entry in NexusTools.getNXClassGroups(fout, '/', [u'NXentry']): for process in NexusTools.getNXClassGroups(fout, entry.name, [u'NXprocess']): for results in NexusTools.getNXClassGroups(fout, process.name, [u'NXcollection']): for dataout in NexusTools.getNXClassGroups(fout, results.name, [u'NXdata']): for part in parts[1:]: - with h5py.File(part) as fin: + with h5py.File(part, mode='r') as fin: try: datain = fin[dataout.name] except KeyError: diff --git a/PyMca5/PyMcaCore/StackBase.py b/PyMca5/PyMcaCore/StackBase.py index 1a226fb..78db490 100644 --- a/PyMca5/PyMcaCore/StackBase.py +++ b/PyMca5/PyMcaCore/StackBase.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2018 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -1044,7 +1044,7 @@ class StackBase(object): Default output has the form: xvalues, yvalues, legend, dict - where dict is a dictionnary containing curve info. + where dict is a dictionary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel. diff --git a/PyMca5/PyMcaCore/StackPluginBase.py b/PyMca5/PyMcaCore/StackPluginBase.py index ecaa0f4..0e82f7f 100644 --- a/PyMca5/PyMcaCore/StackPluginBase.py +++ b/PyMca5/PyMcaCore/StackPluginBase.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2018 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -189,7 +189,7 @@ class StackPluginBase(object): xvalues, yvalues, legend, dict - where dict is a dictionnary containing curve info. + where dict is a dictionary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel. diff --git a/PyMca5/PyMcaDataDir.py b/PyMca5/PyMcaDataDir.py index 584070a..b2f78ee 100644 --- a/PyMca5/PyMcaDataDir.py +++ b/PyMca5/PyMcaDataDir.py @@ -73,7 +73,7 @@ if PYMCA_DOC_DIR_ENV is not None: raise IOError('%s directory set from environent not found' % \ PYMCA_DATA_DIR) else: - txt = "WARNING: Taking PYMCA_DOC_DIR from environement.\n" + txt = "WARNING: Taking PYMCA_DOC_DIR from environment.\n" txt += "Use it at your own risk." print(txt) diff --git a/PyMca5/PyMcaGraph/Plot.py b/PyMca5/PyMcaGraph/Plot.py index 5a7ecd6..afd6afb 100644 --- a/PyMca5/PyMcaGraph/Plot.py +++ b/PyMca5/PyMcaGraph/Plot.py @@ -237,7 +237,7 @@ class Plot(PlotBase.PlotBase): def graphCallback(self, ddict=None): """ This callback is foing to receive all the events from the plot. - Those events will consist on a dictionnary and among the dictionnary + Those events will consist on a dictionary and among the dictionary keys the key 'event' is mandatory to describe the type of event. This default implementation only handles setting the active curve. """ @@ -370,7 +370,7 @@ class Plot(PlotBase.PlotBase): def getDrawMode(self): """ - Return a dictionnary (or None) with the parameters passed when setting + Return a dictionary (or None) with the parameters passed when setting the draw mode. :key shape: The shape being drawn :key label: Associated text (or None) @@ -441,7 +441,7 @@ class Plot(PlotBase.PlotBase): 'plot_linestyle', linestyle) else: self._curveList.append(key) - #print("TODO: Here we can add properties to the info dictionnary") + #print("TODO: Here we can add properties to the info dictionary") #print("For instance, color, symbol, style and width if not present") #print("They could come in **kw") #print("The actual plotting stuff should only take care of handling") @@ -571,7 +571,7 @@ class Plot(PlotBase.PlotBase): :param draggable: Flag to indicate if the image can be moved :type draggable: boolean, default False :param colormap: Dictionary describing the colormap to use (or None) - :type colormap: Dictionnary or None (default). Ignored if data is RGB(A) + :type colormap: Dictionary or None (default). Ignored if data is RGB(A) :param pixmap: Pixmap representation of the data (if any) :type pixmap: (nrows, ncolumns, RGBA) ubyte array or None (default) :returns: The legend/handle used by the backend to univocally access it. @@ -690,7 +690,7 @@ class Plot(PlotBase.PlotBase): Default output has the form: xvalues, yvalues, legend, dict - where dict is a dictionnary containing curve info. + where dict is a dictionary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel. @@ -715,7 +715,7 @@ class Plot(PlotBase.PlotBase): Default output has the form: data, legend, dict, pixmap - where dict is a dictionnary containing image info. + where dict is a dictionary containing image info. For the time being, only the plot labels associated to the image are warranted to be present under the keys xlabel, ylabel. @@ -780,7 +780,7 @@ class Plot(PlotBase.PlotBase): Default output has the form: xvalues, yvalues, legend, info - where info is a dictionnary containing curve info. + where info is a dictionary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel. """ @@ -801,7 +801,7 @@ class Plot(PlotBase.PlotBase): Default output has the form: image, legend, info, pixmap - where info is a dictionnary containing image information. + where info is a dictionary containing image information. """ if legend in self._imageDict: return self._imageDict[legend] * 1 @@ -1335,7 +1335,7 @@ class Plot(PlotBase.PlotBase): """ Return the colormap that will be applied by the backend to an image if no colormap is applied to it. - A colormap is a dictionnary with the keys: + A colormap is a dictionary with the keys: :type name: string :type normalization: string (linear, log) :type autoscale: boolean @@ -1349,7 +1349,7 @@ class Plot(PlotBase.PlotBase): """ Sets the colormap that will be applied by the backend to an image if no colormap is applied to it. - A colormap is a dictionnary with the keys: + A colormap is a dictionary with the keys: :type name: string :type normalization: string (linear, log) :type autoscale: boolean diff --git a/PyMca5/PyMcaGraph/PlotBackend.py b/PyMca5/PyMcaGraph/PlotBackend.py index ee7dad5..dff430c 100644 --- a/PyMca5/PyMcaGraph/PlotBackend.py +++ b/PyMca5/PyMcaGraph/PlotBackend.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2015 European Synchrotron Radiation Facility +# Copyright (c) 2004-2018 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -93,7 +93,7 @@ PlotBackend "signals/events" All the events pass via the callback_function supplied. -They consist on a dictionnary in which the 'event' key is mandatory. +They consist on a dictionary in which the 'event' key is mandatory. The following keys will be present or not depending on the type of event, but if present, their meaning should be: @@ -181,7 +181,7 @@ class PlotBackend(object): COLORDICT = Colors.COLORDICT """ - Dictionnary of predefined colors + Dictionary of predefined colors """ def __init__(self, parent=None): @@ -287,7 +287,7 @@ class PlotBackend(object): :param draggable: Flag to indicate if the image can be moved :type draggable: boolean, default False :param colormap: Dictionary describing the colormap to use (or None) - :type colormap: Dictionnary or None (default). Ignored if data is RGB(A) + :type colormap: Dictionary or None (default). Ignored if data is RGB(A) :returns: The legend/handle used by the backend to univocally access it. """ print("PlotBackend addImage not implemented") @@ -386,7 +386,7 @@ class PlotBackend(object): Return the colormap that will be applied by the backend to an image if no colormap is applied to it. - A colormap is a dictionnary with the keys: + A colormap is a dictionary with the keys: - name: string - normalization: string (linear, log) @@ -402,7 +402,7 @@ class PlotBackend(object): def getDrawMode(self): """ - Return a dictionnary (or None) with the parameters passed when setting + Return a dictionary (or None) with the parameters passed when setting the draw mode. - shape: The shape being drawn @@ -763,7 +763,7 @@ class PlotBackend(object): def setCallback(self, callback_function): """ - :param callback_function: function accepting a dictionnary as input to handle the graph events + :param callback_function: function accepting a dictionary as input to handle the graph events :type callback_function: callable """ self._callback = callback_function @@ -798,7 +798,7 @@ class PlotBackend(object): Sets the colormap that will be applied by the backend to an image if no colormap is applied to it. - A colormap is a dictionnary with the keys: + A colormap is a dictionary with the keys: :type name: string :type normalization: string (linear, log) diff --git a/PyMca5/PyMcaGraph/PlotBase.py b/PyMca5/PyMcaGraph/PlotBase.py index 962e3fd..96425ef 100644 --- a/PyMca5/PyMcaGraph/PlotBase.py +++ b/PyMca5/PyMcaGraph/PlotBase.py @@ -90,7 +90,7 @@ class PlotBase(PlotBackend.PlotBackend, PluginLoader.PluginLoader): Default output has the form: xvalues, yvalues, legend, dict - where dict is a dictionnary containing curve info. + where dict is a dictionary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel. @@ -141,7 +141,7 @@ class PlotBase(PlotBackend.PlotBackend, PluginLoader.PluginLoader): Default output has the form: xvalues, yvalues, legend, info - where info is a dictionnary containing curve info. + where info is a dictionary containing curve info. For the time being, only the plot labels associated to the curve are warranted to be present under the keys xlabel, ylabel. """ @@ -159,7 +159,7 @@ class PlotBase(PlotBackend.PlotBackend, PluginLoader.PluginLoader): Default output has the form: image, legend, info, pixmap - where info is a dictionnary containing image information. + where info is a dictionary containing image information. """ print("PlotBase getImage not implemented") return [] diff --git a/PyMca5/PyMcaGraph/backends/MatplotlibBackend.py b/PyMca5/PyMcaGraph/backends/MatplotlibBackend.py index 45818de..3759cb7 100644 --- a/PyMca5/PyMcaGraph/backends/MatplotlibBackend.py +++ b/PyMca5/PyMcaGraph/backends/MatplotlibBackend.py @@ -2547,7 +2547,7 @@ class MatplotlibBackend(PlotBackend.PlotBackend): :param draggable: Flag to indicate if the image can be moved :type draggable: boolean, default False :param colormap: Dictionary describing the colormap to use (or None) - :type colormap: Dictionnary or None (default). Ignored if data is RGB(A) + :type colormap: Dictionary or None (default). Ignored if data is RGB(A) :returns: The legend/handle used by the backend to univocally access it. """ # Non-uniform image diff --git a/PyMca5/PyMcaGui/io/hdf5/HDF5Info.py b/PyMca5/PyMcaGui/io/hdf5/HDF5Info.py index d2b7045..187ceb7 100644 --- a/PyMca5/PyMcaGui/io/hdf5/HDF5Info.py +++ b/PyMca5/PyMcaGui/io/hdf5/HDF5Info.py @@ -96,7 +96,7 @@ class SimpleInfoGroupBox(qt.QGroupBox): ddict[actualKeys[dictKeys.index(l)]]) def _getMappedDict(self, ddict): - #Default implementation returns a copy of the input dictionnary + #Default implementation returns a copy of the input dictionary return copy.deepcopy(ddict) def _fillKey(self, key, value): diff --git a/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py b/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py index e8ebffd..2be0603 100644 --- a/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py +++ b/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py @@ -505,6 +505,8 @@ class QNexusWidget(qt.QWidget): # handle a right click on a group or a dataset of string type _hdf5WidgetDatasetMenu.addAction(QString("Show Information"), self._showInfoWidgetSlot) + _hdf5WidgetDatasetMenu.addAction(QString("Copy Path to Clipboard"), + self._copyPathSlot) _hdf5WidgetDatasetMenu.exec_(qt.QCursor.pos()) else: #handle a right click on a numeric dataset @@ -520,6 +522,8 @@ class QNexusWidget(qt.QWidget): else: _hdf5WidgetDatasetMenu.addAction(QString("Show Information"), self._showInfoWidgetSlot) + _hdf5WidgetDatasetMenu.addAction(QString("Copy Path to Clipboard"), + self._copyPathSlot) _hdf5WidgetDatasetMenu.exec_(qt.QCursor.pos()) self._lastItemDict = None return @@ -542,6 +546,15 @@ class QNexusWidget(qt.QWidget): ddict['name'], dset=is_numeric_dataset) + def _copyPathSlot(self, ddict=None): + if ddict is None: + ddict = self._lastItemDict + try: + clipboard = qt.QApplication.clipboard() + clipboard.setText(ddict["name"]) + except: + _logger.warning("Unsuccessful copy to clipboard") + def _openDataset(self, ddict=None): if ddict is None: ddict = self._lastItemDict diff --git a/PyMca5/PyMcaGui/misc/CalculationThread.py b/PyMca5/PyMcaGui/misc/CalculationThread.py index 0879623..4c3a05f 100644 --- a/PyMca5/PyMcaGui/misc/CalculationThread.py +++ b/PyMca5/PyMcaGui/misc/CalculationThread.py @@ -1,5 +1,5 @@ #/*########################################################################## -# Copyright (C) 2004-2014 V.A. Sole, European Synchrotron Radiation Facility +# Copyright (C) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -214,7 +214,7 @@ def waitingMessageDialog(thread, message=None, parent=None, parent - The parent QWidget. It is used just to provide a convenient localtion modal - Default is True. The dialog will prevent user from using other widgets update_callback - The function to be called to provide progress feedback. It is expected - to return a dictionnary. The recognized key words are: + to return a dictionary. The recognized key words are: message: The updated message to be displayed. title: The title of the window title. progress: A number between 0 and 100 indicating the progress of the task. diff --git a/PyMca5/PyMcaGui/physics/xrf/McaAdvancedFit.py b/PyMca5/PyMcaGui/physics/xrf/McaAdvancedFit.py index e368edc..0dc5a40 100644 --- a/PyMca5/PyMcaGui/physics/xrf/McaAdvancedFit.py +++ b/PyMca5/PyMcaGui/physics/xrf/McaAdvancedFit.py @@ -1848,7 +1848,7 @@ class McaAdvancedFit(qt.QWidget): Interactive use - It returns a dictionnary containing the fit results or None in case of + It returns a dictionary containing the fit results or None in case of unsuccessfull fit. Embedded use diff --git a/PyMca5/PyMcaGui/pymca/PyMcaBatch.py b/PyMca5/PyMcaGui/pymca/PyMcaBatch.py index 45dd652..6e5ae77 100644 --- a/PyMca5/PyMcaGui/pymca/PyMcaBatch.py +++ b/PyMca5/PyMcaGui/pymca/PyMcaBatch.py @@ -289,7 +289,7 @@ def launchThread(thread, window): window.pauseButton.setText("Continue") window.pauseButton.clicked.connect(pause) window.abortButton.clicked.connect(cleanup) - #qApp.aboutToQuit[()].connect(cleanup) + qt.QApplication.instance().aboutToQuit[()].connect(cleanup) window.show() thread.start() diff --git a/PyMca5/PyMcaGui/pymca/PyMcaMain.py b/PyMca5/PyMcaGui/pymca/PyMcaMain.py index 5f5c438..df1030f 100644 --- a/PyMca5/PyMcaGui/pymca/PyMcaMain.py +++ b/PyMca5/PyMcaGui/pymca/PyMcaMain.py @@ -555,9 +555,9 @@ class PyMcaMain(PyMcaMdi.PyMcaMdi): legend = ddict['legend'] if legend not in self.imageWindowDict.keys(): if OPENGL_DRIVERS_OK: - scatter_backend = "gl" + backend = "gl" else: - scatter_backend = "mpl" + backend = "mpl" imageWindow = SilxScatterWindow.SilxScatterWindow(backend=backend) self.imageWindowDict[legend] = imageWindow self.imageWindowDict[legend].setPlotEnabled(True) diff --git a/PyMca5/PyMcaGui/pymca/PyMcaNexusWidget.py b/PyMca5/PyMcaGui/pymca/PyMcaNexusWidget.py index f75be9f..ef1341c 100644 --- a/PyMca5/PyMcaGui/pymca/PyMcaNexusWidget.py +++ b/PyMca5/PyMcaGui/pymca/PyMcaNexusWidget.py @@ -63,6 +63,8 @@ class PyMcaNexusWidget(QNexusWidget.QNexusWidget): # handle a right click on a group or on a dataset of string type _hdf5WidgetDatasetMenu.addAction(QString("Show Information"), self._showInfoWidgetSlot) + _hdf5WidgetDatasetMenu.addAction(QString("Copy Path to Clipboard"), + self._copyPathSlot) else: # handle a right click on a numeric dataset _hdf5WidgetDatasetMenu.addAction(QString("Add to selection table"), @@ -71,6 +73,9 @@ class PyMcaNexusWidget(QNexusWidget.QNexusWidget): _hdf5WidgetDatasetMenu.addAction(QString("Show Information"), self._showInfoWidgetSlot) + _hdf5WidgetDatasetMenu.addAction(QString("Copy Path to Clipboard"), + self._copyPathSlot) + info = self.getInfo(phynxFile, ddict['name']) interpretation = info.get('interpretation', "") stack1D = False diff --git a/PyMca5/PyMcaGui/pymca/QSource.py b/PyMca5/PyMcaGui/pymca/QSource.py index 1f2be17..01296ff 100644 --- a/PyMca5/PyMcaGui/pymca/QSource.py +++ b/PyMca5/PyMcaGui/pymca/QSource.py @@ -1,5 +1,5 @@ #/*########################################################################## -# Copyright (C) 2004-2016 V.A. Sole, European Synchrotron Radiation Facility +# Copyright (C) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -125,7 +125,7 @@ class QSource(qt.QObject): #print "RUN" while len(self.surveyDict) > 0: #for key in self.surveyDict is dangerous - # runtime error: dictionnary changed during iteration + # runtime error: dictionary changed during iteration # a mutex is needed _logger.debug("In loop") dummy = list(self.surveyDict.keys()) diff --git a/PyMca5/PyMcaGui/pymca/SilxGLWindow.py b/PyMca5/PyMcaGui/pymca/SilxGLWindow.py index d1b0380..5fe074a 100644 --- a/PyMca5/PyMcaGui/pymca/SilxGLWindow.py +++ b/PyMca5/PyMcaGui/pymca/SilxGLWindow.py @@ -153,7 +153,7 @@ def getChimeraStack(): if not fileList: return None, None filename = fileList[0] - with h5py.File(filename) as f: + with h5py.File(filename, mode='r') as f: stack = f['Image/data'][...] if not isinstance(stack, numpy.ndarray) or stack.ndim != 3: raise IOError("Problem reading stack.") diff --git a/PyMca5/PyMcaIO/ConfigDict.py b/PyMca5/PyMcaIO/ConfigDict.py index 5b764b3..956e221 100644 --- a/PyMca5/PyMcaIO/ConfigDict.py +++ b/PyMca5/PyMcaIO/ConfigDict.py @@ -67,7 +67,7 @@ class ConfigDict(dict): self.update(self.default) def clear(self): - """ Clear dictionnary + """ Clear dictionary """ dict.clear(self) self.filelist = [] @@ -135,10 +135,17 @@ class ConfigDict(dict): """ cfg = ConfigParser.ConfigParser() cfg.optionxform = self.__convert - cfg.readfp(filelike) + #readfp was deprecated in Python 3.2 + if hasattr(cfg, "read_file"): + cfg.read_file(filelike) + else: + cfg.readfp(filelike) self.__read(cfg, sections) self._check() + def read_file(self, *var, **kw): + return self.readfp(*var, **kw) + def __read(self, cfg, sections=None): cfgsect = cfg.sections() diff --git a/PyMca5/PyMcaIO/EdfFile.py b/PyMca5/PyMcaIO/EdfFile.py index 901655b..b49f291 100644 --- a/PyMca5/PyMcaIO/EdfFile.py +++ b/PyMca5/PyMcaIO/EdfFile.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2018 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -75,7 +75,7 @@ __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" - There are some fields in the header that are required for this implementation. If any of these is missing, or inconsistent, it will be generated an error: Size: Represents size of data block - Dim_1: size of x coordinates (Dim_2 for 2-dimentional images, and also Dim_3 for 3d) + Dim_1: size of x coordinates (Dim_2 for 2-dimensional images, and also Dim_3 for 3d) DataType ByteOrder - For the written images, these fields are automatically genereted: @@ -905,7 +905,7 @@ class EdfFile(object): self.__GetSizeNumpyType__(Data.dtype)) self.Images[Index].NumDim = 3 elif len(Data.shape) > 3: - raise TypeError("EdfFile: Data dimension not suported") + raise TypeError("EdfFile: Data dimension not supported") if DataType == "": diff --git a/PyMca5/PyMcaIO/LispixMap.py b/PyMca5/PyMcaIO/LispixMap.py index 79e0b94..3f4a6a8 100644 --- a/PyMca5/PyMcaIO/LispixMap.py +++ b/PyMca5/PyMcaIO/LispixMap.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2018 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -228,7 +228,7 @@ def _getDataAndDescriptionFileName(filename): def _parseHeaderFile(headerFile): """ - Given the input header file describing the data, returns a dictionnary + Given the input header file describing the data, returns a dictionary with the description of the binary data: key value diff --git a/PyMca5/PyMcaIO/LuciaMap.py b/PyMca5/PyMcaIO/LuciaMap.py index a49cbf5..dd7c0cd 100644 --- a/PyMca5/PyMcaIO/LuciaMap.py +++ b/PyMca5/PyMcaIO/LuciaMap.py @@ -3,7 +3,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2014 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -137,7 +137,7 @@ class LuciaMap(DataObject.DataObject): def _getInfo(self, filename): ''' - This dictionnary is to be internally normalized for the time + This dictionary is to be internally normalized for the time being no I0 nor dead time ''' exp = re.compile('(-?[0-9]+\.?[0-9]*)') diff --git a/PyMca5/PyMcaIO/NexusUtils.py b/PyMca5/PyMcaIO/NexusUtils.py index 95f190c..8486d3a 100644 --- a/PyMca5/PyMcaIO/NexusUtils.py +++ b/PyMca5/PyMcaIO/NexusUtils.py @@ -490,7 +490,7 @@ def nxDetector(parent, name): :param str name: :returns h5py.Group: """ - nxClassInit(parent, name, u'nxDetector', parentclasses=(u'NXinstrument',)) + nxClassInit(parent, name, u'NXdetector', parentclasses=(u'NXinstrument',)) return parent[name] diff --git a/PyMca5/PyMcaIO/OmnicMap.py b/PyMca5/PyMcaIO/OmnicMap.py index bb0f845..2a6f089 100644 --- a/PyMca5/PyMcaIO/OmnicMap.py +++ b/PyMca5/PyMcaIO/OmnicMap.py @@ -199,7 +199,7 @@ class OmnicMap(DataObject.DataObject): Returns: -------- - A dictionnary with acquisition information + A dictionary with acquisition information ''' #additional information fmt = "I" # unsigned long in 32-bit @@ -245,7 +245,7 @@ class OmnicMap(DataObject.DataObject): Returns: -------- - Dictionnary with map gemoetrical acquisition parameters + Dictionary with map gemoetrical acquisition parameters ''' #look for the chain 'Position' if sys.version < '3.0': @@ -279,7 +279,7 @@ class OmnicMap(DataObject.DataObject): def getOmnicInfo(self): """ - Returns a dictionnary with the parsed OMNIC information + Returns a dictionary with the parsed OMNIC information """ return copy.deepcopy(self.info['OmnicInfo']) @@ -291,7 +291,7 @@ class OmnicMap(DataObject.DataObject): ----------- index : int Index of spectrum - info : Dictionnary + info : Dictionary Information recovered with _getOmnicInfo Returns: -------- diff --git a/PyMca5/PyMcaIO/PilatusCBF.py b/PyMca5/PyMcaIO/PilatusCBF.py index 10d8f8a..8cc7efa 100644 --- a/PyMca5/PyMcaIO/PilatusCBF.py +++ b/PyMca5/PyMcaIO/PilatusCBF.py @@ -251,7 +251,7 @@ class PilatusCBF(object): class CIF(dict): """ - This is the CIF class, it represents the CIF dictionnary as a a python dictionnary thus inherits from the dict built in class. + This is the CIF class, it represents the CIF dictionary as a a python dictionary thus inherits from the dict built in class. """ if sys.version < '3.0': EOL = ["\r", "\n", "\r\n", "\n\r"] @@ -282,7 +282,7 @@ class CIF(dict): def readCIF(self, _strFilename): """ Just call loadCIF: - Load the CIF file and sets the CIF dictionnary into the object + Load the CIF file and sets the CIF dictionary into the object @param _strFilename: the name of the file to open @type _strFilename: string @@ -290,7 +290,7 @@ class CIF(dict): self.loadCIF(_strFilename) def loadCIF(self, _strFilename, _bKeepComment=False): - """Load the CIF file and returns the CIF dictionnary into the object + """Load the CIF file and returns the CIF dictionary into the object @param _strFilename: the name of the file to open @type _strFilename: string @param _strFilename: the name of the file to open @@ -365,8 +365,8 @@ class CIF(dict): @param sText: the content of the CIF-file @type sText: string - @return: Nothing, the data are incorporated at the CIF object dictionnary - @rtype: dictionnary + @return: Nothing, the data are incorporated at the CIF object dictionary + @rtype: dictionary """ loopidx = [] looplen = [] @@ -492,8 +492,8 @@ class CIF(dict): @type lFields: list @param iStart: the starting index corresponding to the "loop_" key @type iStart: integer - @return: the list of loop dictionnaries, the length of the data extracted from the lFields and the list of all the keys of the loop. - @rtype: tupple + @return: the list of loop dictionaries, the length of the data extracted from the lFields and the list of all the keys of the loop. + @rtype: tuple """ # in earch loop we first search the length of the loop # print lFields @@ -580,7 +580,7 @@ class CIF(dict): def _cif2str(self, _strFilename): - """converts a cif dictionnary to a string according to the CIF syntax + """converts a cif dictionary to a string according to the CIF syntax @param _strFilename: the name of the filename to be apppended in the header of the CIF file @type _strFilename: string @return : a sting that corresponds to the content of the CIF-file. @@ -647,8 +647,8 @@ class CIF(dict): Check if the key exists in the CIF and is non empty. @param sKey: CIF key @type sKey: string - @param cif: CIF dictionnary - @return: True if the key exists in the CIF dictionnary and is non empty + @param cif: CIF dictionary + @return: True if the key exists in the CIF dictionary and is non empty @rtype: boolean """ bExists = False @@ -660,11 +660,11 @@ class CIF(dict): def existsInLoop(self, sKey): """ - Check if the key exists in the CIF dictionnary. + Check if the key exists in the CIF dictionary. @param sKey: CIF key @type sKey: string - @param cif: CIF dictionnary - @return: True if the key exists in the CIF dictionnary and is non empty + @param cif: CIF dictionary + @return: True if the key exists in the CIF dictionary and is non empty @rtype: boolean """ if not self.exists("loop_"): @@ -678,11 +678,11 @@ class CIF(dict): return bExists def loadCHIPLOT(self, _strFilename): - """Load the powder diffraction CHIPLOT file and returns the pd_CIF dictionnary in the object + """Load the powder diffraction CHIPLOT file and returns the pd_CIF dictionary in the object @param _strFilename: the name of the file to open @type _strFilename: string @return: the CIF object corresponding to the powder diffraction - @rtype: dictionnary + @rtype: dictionary """ if not os.path.isfile(_strFilename): _logger.error("I cannot find the file %s", _strFilename) diff --git a/PyMca5/PyMcaMath/fitting/SimpleFitAll.py b/PyMca5/PyMcaMath/fitting/SimpleFitAll.py index d469c04..bd3943d 100644 --- a/PyMca5/PyMcaMath/fitting/SimpleFitAll.py +++ b/PyMca5/PyMcaMath/fitting/SimpleFitAll.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2017-2018 European Synchrotron Radiation Facility +# Copyright (c) 2017-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -97,7 +97,7 @@ class SimpleFitAll(object): def progressUpdate(self): """ - This method returns a dictionnary with the keys + This method returns a dictionary with the keys progress: A number between 0 and 100 indicating the fit progress status: Status of the calculation thread. """ diff --git a/PyMca5/PyMcaMath/fitting/StackSimpleFit.py b/PyMca5/PyMcaMath/fitting/StackSimpleFit.py index 1f5a50a..4887aed 100644 --- a/PyMca5/PyMcaMath/fitting/StackSimpleFit.py +++ b/PyMca5/PyMcaMath/fitting/StackSimpleFit.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2017 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -67,7 +67,7 @@ class StackSimpleFit(object): def progressUpdate(self): """ - This methos returns a dictionnary with the keys + This methos returns a dictionary with the keys progress: A number between 0 and 100 indicating the fit progress status: Status of the calculation thread. """ diff --git a/PyMca5/PyMcaMath/linalg.py b/PyMca5/PyMcaMath/linalg.py index 6f0698e..04f7f94 100644 --- a/PyMca5/PyMcaMath/linalg.py +++ b/PyMca5/PyMcaMath/linalg.py @@ -184,7 +184,7 @@ def lstsq(a, b, rcond=None, sigma_b=None, weight=False, covariances: If True, an array of covariance matrix/matrices will be returned. - digested_output: If True, returns a dictionnary with explicit keys + digested_output: If True, returns a dictionary with explicit keys Returns ------- diff --git a/PyMca5/PyMcaMath/mva/PCATools.py b/PyMca5/PyMcaMath/mva/PCATools.py index 85261ef..25a7e78 100644 --- a/PyMca5/PyMcaMath/mva/PCATools.py +++ b/PyMca5/PyMcaMath/mva/PCATools.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2016 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -85,17 +85,17 @@ def getCovarianceMatrix(stack, :type spatial_mask: Numpy array of unsigned bytes (numpy.uint8) or None (default). :returns: The covMatrix, the average spectrum and the number of used pixels. """ - #the 1D mask = weights should correspond to the values, before or after - #sampling? it could be handled as weigths to be applied to the - #spectra. That would allow two uses, as mask and as weights, at - #the cost of a multiplication. + # the 1D mask = weights should correspond to the values, before or after + # sampling? it could be handled as weights to be applied to the + # spectra. That would allow two uses, as mask and as weights, at + # the cost of a multiplication. - #the spatial_mask accounts for pixels to be considered. It allows - #to calculate the covariance matrix of a subset or to deal with - #non finite data (NaN, +inf, -inf, ...). The calling program - #should set the mask. + # the spatial_mask accounts for pixels to be considered. It allows + # to calculate the covariance matrix of a subset or to deal with + # non finite data (NaN, +inf, -inf, ...). The calling program + # should set the mask. - #recover the actual data to work with + # recover the actual data to work with if hasattr(stack, "info") and hasattr(stack, "data"): #we are dealing with a PyMca data object data = stack.data @@ -117,18 +117,18 @@ def getCovarianceMatrix(stack, else: actualIndex = index - #the number of spatial pixels + # the number of spatial pixels nPixels = 1 for i in range(len(oldShape)): if i != actualIndex: nPixels *= oldShape[i] - #remove inf or nan + # remove inf or nan #image_data = data.sum(axis=actualIndex) #spatial_mask = numpy.isfinite(image_data) # - #the starting number of channels or of images + # the starting number of channels or of images N = oldShape[actualIndex] # our binning (better said sampling) is spectral, in order not to @@ -156,7 +156,7 @@ def getCovarianceMatrix(stack, else: cleanWeights = weights[::binning] - #end of checking part + # end of checking part eigenvectorLength = nChannels if (not force)and isinstance(data, numpy.ndarray): @@ -198,7 +198,7 @@ def getCovarianceMatrix(stack, averageMatrix = None return covMatrix, sumSpectrum / usedPixels, usedPixels - #we are dealing with dynamically loaded data + # we are dealing with dynamically loaded data _logger.debug("DYNAMICALLY LOADED DATA") #create the needed storage space for the covariance matrix try: @@ -213,15 +213,15 @@ def getCovarianceMatrix(stack, data = None raise - #workaround a problem with h5py + # workaround a problem with h5py try: if actualIndex in [0]: testException = data[0:1] else: if len(data.shape) == 2: - testException = data[0:1,-1] + testException = data[0:1, -1] elif len(data.shape) == 3: - testException = data[0:1,0:1,-1] + testException = data[0:1, 0:1, -1] except AttributeError: txt = "%s" % type(data) if 'h5py' in txt: @@ -232,13 +232,13 @@ def getCovarianceMatrix(stack, raise if actualIndex in [0]: - #divider is used to decide the fraction of images to keep in memory - #in order to limit file access on dynamically loaded data. - #Since two chunks of the same size are used, the amount of memory - #needed is twice the data size divided by the divider. - #For instance, divider = 10 implies the data to be read 5.5 times - #from disk while having a memory footprint of about one fifth of - #the dataset size. + # divider is used to decide the fraction of images to keep in memory + # in order to limit file access on dynamically loaded data. + # Since two chunks of the same size are used, the amount of memory + # needed is twice the data size divided by the divider. + # For instance, divider = 10 implies the data to be read 5.5 times + # from disk while having a memory footprint of about one fifth of + # the dataset size. step = 0 divider = 10 while step < 1: @@ -284,12 +284,12 @@ def getCovarianceMatrix(stack, #get step images for the second chunk jToRead = min(step, nChannels - j) - #with loop: + # with loop: #for k in range(0, jToRead): # chunk2[:,k] = data[(j+k):(j+k+1)].reshape(1,-1) # if spatial_mask is not None: # chunk2[badMask[(j+k):(j+k+1),k]] = 0 - #equivalent without loop: + # equivalent without loop: chunk2[:, 0:jToRead] =\ data[j:(j + jToRead)].reshape(jToRead, -1).T if spatial_mask is not None: @@ -303,7 +303,7 @@ def getCovarianceMatrix(stack, if spatial_mask is not None: chunk2[badMask, 0:jToRead] = 0 - #dot product + # dot product if (iToRead != step) or (jToRead != step): covMatrix[i: (i + iToRead), j: (j + jToRead)] =\ dotblas.dot(chunk1[:iToRead, :nPixels], @@ -316,7 +316,7 @@ def getCovarianceMatrix(stack, covMatrix[j: (j + jToRead), i: (i + iToRead)] =\ covMatrix[i: (i + iToRead), j: (j + jToRead)].T - #increment j + # increment j j += jToRead i += iToRead chunk1 = None @@ -331,7 +331,7 @@ def getCovarianceMatrix(stack, spectrumIndex = 0 nImagesRead = 0 while i < N: - #fill chunk1 + # fill chunk1 jj = 0 for iToRead in range(0, int(min(step * binning, N - i)), binning): @@ -349,12 +349,12 @@ def getCovarianceMatrix(stack, iToRead = jj j = 0 while j <= i: - #get step images for the second chunk + # get step images for the second chunk if j == i: jToRead = iToRead chunk2[:, 0:jToRead] = chunk1[0:jToRead, :].T else: - #get step images for the second chunk + # get step images for the second chunk jj = 0 for jToRead in range(0, int(min(step * binning, N - j)), @@ -369,7 +369,7 @@ def getCovarianceMatrix(stack, average.shape = 1, jj chunk2 -= average jToRead = jj - #dot product + # dot product if (iToRead != step) or (jToRead != step): covMatrix[i:(i + iToRead), j:(j + jToRead)] =\ dotblas.dot(chunk1[:iToRead, :nPixels], @@ -382,7 +382,7 @@ def getCovarianceMatrix(stack, covMatrix[j:(j + jToRead), i:(i + iToRead)] =\ covMatrix[i:(i + iToRead), j:(j + jToRead)].T - #increment j + # increment j j += jToRead * step i += iToRead * step chunk1 = None @@ -390,17 +390,17 @@ def getCovarianceMatrix(stack, else: raise ValueError("PCATools.getCovarianceMatrix: Unhandled case") - #should one divide by N or by N-1 ?? if we use images, we - #assume the observables are the images, not the spectra!!! - #so, covMatrix /= nChannels is wrong and one has to use: + # should one divide by N or by N-1 ?? if we use images, we + # assume the observables are the images, not the spectra!!! + # so, covMatrix /= nChannels is wrong and one has to use: covMatrix /= usedPixels else: - #the data are already arranged as (nPixels, nChannels) and we - #basically have to return data.T * data to get back the covariance - #matrix as (nChannels, nChannels) - #if someone had the bad idea to store the data in HDF5 with a chunk - #size based on the pixels and not on the spectra a loop based on - #reading spectrum per spectrum can be very slow + # the data are already arranged as (nPixels, nChannels) and we + # basically have to return data.T * data to get back the covariance + # matrix as (nChannels, nChannels) + # if someone had the bad idea to store the data in HDF5 with a chunk + # size based on the pixels and not on the spectra a loop based on + # reading spectrum per spectrum can be very slow step = 0 divider = 10 while step < 1: @@ -450,7 +450,7 @@ def getCovarianceMatrix(stack, k += kToRead tmpData = None elif oldShape[1] == 1: - #almost identical to the previous case + # almost identical to the previous case tmpData = numpy.zeros((step, nChannels), numpy.float64) if cleanMask is not None: badMask.shape = data.shape[0], data.shape[1] @@ -489,16 +489,16 @@ def getCovarianceMatrix(stack, k += kToRead tmpData = None else: - #I should choose the sizes in terms of the size - #of the dataset + # I should choose the sizes in terms of the size + # of the dataset if oldShape[0] < 41: - #divide by 10 + # divide by 10 deltaRow = 4 elif oldShape[0] < 101: - #divide by 10 + # divide by 10 deltaRow = 10 else: - #take pieces of one tenth + # take pieces of one tenth deltaRow = int(oldShape[0] / 10) deltaCol = oldShape[1] tmpData = numpy.zeros((deltaRow, deltaCol, nChannels), @@ -522,10 +522,10 @@ def getCovarianceMatrix(stack, covMatrix += dotblas.dot(a.T, a) a = None i += iToRead - #should one divide by N or by N-1 ?? + # should one divide by N or by N-1 ?? covMatrix /= usedPixels - 1 if center: - #the n-1 appears again here + # the n-1 appears again here averageMatrix = numpy.outer(sumSpectrum, sumSpectrum)\ / (usedPixels * (usedPixels - 1)) covMatrix -= averageMatrix @@ -539,7 +539,7 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, _logger.debug("index = %d", index) _logger.debug("center = %s", center) _logger.debug("scale = %s", scale) - #recover the actual data to work with + # recover the actual data to work with if hasattr(stack, "info") and hasattr(stack, "data"): #we are dealing with a PyMca data object data = stack.data @@ -558,7 +558,7 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, else: actualIndex = index - #workaround a problem with h5py + # workaround a problem with h5py try: if actualIndex in [0]: testException = data[0:1] @@ -576,13 +576,13 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, else: raise - #the number of spatial pixels + # the number of spatial pixels nPixels = 1 for i in range(len(oldShape)): if i != actualIndex: nPixels *= oldShape[i] - #the number of channels + # the number of channels nChannels = oldShape[actualIndex] if binning is None: binning = 1 @@ -602,7 +602,7 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, spatial_mask=mask, weights=spectral_mask) - #the total variance is the sum of the elements of the diagonal + # the total variance is the sum of the elements of the diagonal totalVariance = numpy.diag(cov) standardDeviation = numpy.sqrt(totalVariance) standardDeviation = standardDeviation + (standardDeviation == 0) @@ -635,7 +635,7 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, images = numpy.zeros((ncomponents, nPixels), dtype) eigenvectors = numpy.zeros((ncomponents, N), dtype) eigenvalues = numpy.zeros((ncomponents,), dtype) - #sort eigenvalues + # sort eigenvalues if 1: a = [(evalues[i], i) for i in range(len(evalues))] a.sort() @@ -658,7 +658,7 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, eigenvalues[:] = evalues[idx] eigenvectors[:, :] = evectors[:, idx].T - #calculate the projections + # calculate the projections # Subtracting the average and normalizing to standard deviation gives worse results. # Versions 5.0.0 to 5.1.0 implemented that behavior as default. # When dealing with the CH1777 test dataset the Sb signal was less contrasted against @@ -675,13 +675,12 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, for j in range(ncomponents): images[j:j + 1, :] += tmpData * eigenvectors[j, i] if len(oldShape) == 3: - #reshape the images + # reshape the images images.shape = ncomponents, oldShape[1], oldShape[2] else: - #array of spectra + # array of spectra if len(oldShape) == 2: for i in range(nPixels): - #print i tmpData = data[i, :] tmpData.shape = 1, nChannels if subtractAndNormalize: @@ -690,13 +689,12 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, tmpData = tmpData[:, ::binning] for j in range(ncomponents): images[j, i] = numpy.dot(tmpData, eigenvectors[j]) - #reshape the images + # reshape the images images.shape = ncomponents, nPixels elif len(oldShape) == 3: i = 0 for r in range(oldShape[0]): for c in range(oldShape[1]): - #print i tmpData = data[r, c, :] tmpData.shape = 1, nChannels if subtractAndNormalize: @@ -706,7 +704,7 @@ def numpyPCA(stack, index=-1, ncomponents=10, binning=None, for j in range(ncomponents): images[j, i] = numpy.dot(tmpData, eigenvectors[j]) i += 1 - #reshape the images + # reshape the images images.shape = ncomponents, oldShape[0], oldShape[1] if legacy: return images, eigenvalues, eigenvectors diff --git a/PyMca5/PyMcaPhysics/xas/XASClass.py b/PyMca5/PyMcaPhysics/xas/XASClass.py index 66c2649..38cfac3 100644 --- a/PyMca5/PyMcaPhysics/xas/XASClass.py +++ b/PyMca5/PyMcaPhysics/xas/XASClass.py @@ -1264,7 +1264,7 @@ class XASClass(object): else: raise ValueError("Method <%s> not implemented" % method) - # Returning dictionnary can contain: + # Returning dictionary can contain: # The edge energy (mandatory) # The interpolated spectrum (if any) # The derivative spectrum (if any) diff --git a/PyMca5/PyMcaPhysics/xas/XASStackBatch.py b/PyMca5/PyMcaPhysics/xas/XASStackBatch.py index da80eaa..12a951f 100644 --- a/PyMca5/PyMcaPhysics/xas/XASStackBatch.py +++ b/PyMca5/PyMcaPhysics/xas/XASStackBatch.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2015 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -81,7 +81,7 @@ class XASStackBatch(object): :param x: 1D array containing the x axis (usually the channels) of the spectra. :param y: 3D array containing the spectra as [nrows, ncolumns, nchannels] :param weight: 0 Means no weight, 1 Use an average weight, 2 Individual weights (slow) - :return: A dictionnary with the results as keys. + :return: A dictionary with the results as keys. """ t0 = time.time() diff --git a/PyMca5/PyMcaPhysics/xrf/ClassMcaTheory.py b/PyMca5/PyMcaPhysics/xrf/ClassMcaTheory.py index 354c105..edc6bd2 100644 --- a/PyMca5/PyMcaPhysics/xrf/ClassMcaTheory.py +++ b/PyMca5/PyMcaPhysics/xrf/ClassMcaTheory.py @@ -2259,7 +2259,7 @@ class McaTheory(object): def imagingDigestResult(self): """ - minimalist dictionnary for imaging purposes + minimalist dictionary for imaging purposes """ i = 0 result = {} diff --git a/PyMca5/PyMcaPhysics/xrf/Elements.py b/PyMca5/PyMcaPhysics/xrf/Elements.py index 0683074..c66171f 100644 --- a/PyMca5/PyMcaPhysics/xrf/Elements.py +++ b/PyMca5/PyMcaPhysics/xrf/Elements.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2018 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -179,7 +179,7 @@ ElementBinding = BindingEnergies.ElementBinding from . import KShell from . import LShell from . import MShell -#Scofield's photoelectric dictionnary +#Scofield's photoelectric dictionary from . import Scofield1973 ElementShellTransitions = [KShell.ElementKShellTransitions, @@ -754,7 +754,7 @@ def getEscape(matrix, energy, ethreshold=None, ithreshold=None, nthreshold = Non #get material elements and concentrations eleDict = getMaterialMassFractions([matrix[0]], [1.0]) if eleDict == {}: return {} - #sort the elements according to atomic number (not needed because the output will be a dictionnary) + #sort the elements according to atomic number (not needed because the output will be a dictionary) keys = eleDict.keys() elementsList = [[getz(x),x] for x in keys] elementsList.sort() @@ -763,7 +763,7 @@ def getEscape(matrix, energy, ethreshold=None, ithreshold=None, nthreshold = Non outputDict = {} shelllist = ['K', 'L1', 'L2', 'L3','M1', 'M2', 'M3', 'M4', 'M5'] for z,ele in elementsList: - #use own unfiltered dictionnary + #use own unfiltered dictionary elementDict = _getUnfilteredElementDict(ele, energy) outputDict[ele] ={} outputDict[ele]['mass fraction'] = eleDict[ele] @@ -1296,7 +1296,7 @@ def getMultilayerFluorescence(multilayer0, result.append({}) continue - #here I could recalculate the dictionnary + #here I could recalculate the dictionary if optimized: userElementDict = _getAttFilteredElementDict(newelementsList, attenuators= origattenuators, @@ -1606,7 +1606,7 @@ def getScattering(matrix, energy, attenuators = None, alphain = None, alphaout = #get material elements and concentrations eleDict = getMaterialMassFractions([matrix[0]], [1.0]) if eleDict == {}: return {} - #sort the elements according to atomic number (not needed because the output will be a dictionnary) + #sort the elements according to atomic number (not needed because the output will be a dictionary) keys = eleDict.keys() elementsList = [[getz(x),x] for x in keys] elementsList.sort() @@ -1791,7 +1791,7 @@ def getFluorescence(matrix, energy, attenuators = None, alphain = None, alphaout eleDict = getMaterialMassFractions([matrix[0]], [1.0]) if eleDict == {}: return {} #sort the elements according to atomic number - #(not needed because the output will be a dictionnary) + #(not needed because the output will be a dictionary) keys = eleDict.keys() elementsList = [[getz(x),x] for x in keys] elementsList.sort() @@ -1818,7 +1818,7 @@ def getFluorescence(matrix, energy, attenuators = None, alphain = None, alphaout outputDict = {} shelllist = ['K', 'L1', 'L2', 'L3','M1', 'M2', 'M3', 'M4', 'M5'] for z,ele in elementsList: - #use own unfiltered dictionnary + #use own unfiltered dictionary if ele in userElementDict: elementDict = userElementDict[ele] else: @@ -2880,7 +2880,7 @@ def _getUnfilteredElementDict(symbol, energy, photoweights=None): ele = symbol[0].upper() + symbol[1].lower() else: ele = symbol.upper() - #fill the dictionnary + #fill the dictionary ddict['rays']=[] z = getz(ele) for n in range(len(ElementXrays)): @@ -2930,7 +2930,7 @@ def _updateElementDict(symbol, dict, energy=None, minenergy=MINENERGY, minrate=0 ele = symbol[0].upper() + symbol[1].lower() else: ele = symbol[0].upper() - #reset existing dictionnary + #reset existing dictionary if 'rays' in dict: for rays in dict['rays']: for transition in dict[rays]: @@ -2938,7 +2938,7 @@ def _updateElementDict(symbol, dict, energy=None, minenergy=MINENERGY, minrate=0 del dict[transition] #print "rays deleted = ",rays del dict[rays] - #fill the dictionnary + #fill the dictionary dict['rays']=[] z = getz(ele) for n in range(len(ElementXrays)): diff --git a/PyMca5/PyMcaPhysics/xrf/LegacyFastXRFLinearFit.py b/PyMca5/PyMcaPhysics/xrf/LegacyFastXRFLinearFit.py index 9e7fb7f..8a0b160 100644 --- a/PyMca5/PyMcaPhysics/xrf/LegacyFastXRFLinearFit.py +++ b/PyMca5/PyMcaPhysics/xrf/LegacyFastXRFLinearFit.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2018 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -83,7 +83,7 @@ class FastXRFLinearFit(object): :livetime: It will be used if not different from None and concentrations are to be calculated by using fundamental parameters with automatic time. The default is None. - :return: A dictionnary with the parameters, uncertainties, concentrations and names as keys. + :return: A dictionary with the parameters, uncertainties, concentrations and names as keys. """ if y is None: raise RuntimeError("y keyword argument is mandatory!") diff --git a/PyMca5/PyMcaPhysics/xrf/PyMcaEPDL97.py b/PyMca5/PyMcaPhysics/xrf/PyMcaEPDL97.py index dfc6daa..ec7e7b7 100644 --- a/PyMca5/PyMcaPhysics/xrf/PyMcaEPDL97.py +++ b/PyMca5/PyMcaPhysics/xrf/PyMcaEPDL97.py @@ -2,7 +2,7 @@ # # The PyMca X-Ray Fluorescence Toolkit # -# Copyright (c) 2004-2016 European Synchrotron Radiation Facility +# Copyright (c) 2004-2019 European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -61,7 +61,7 @@ EPDL97_DICT = {} for element in ElementList: EPDL97_DICT[element] = {} -#initialize the dictionnary, for the time being compatible with PyMca 4.3.0 +#initialize the dictionary, for the time being compatible with PyMca 4.3.0 EPDL97_DICT = {} for element in ElementList: EPDL97_DICT[element] = {} @@ -69,7 +69,7 @@ for element in ElementList: EPDL97_DICT[element]['EPDL97'] = {} EPDL97_DICT[element]['original'] = True -#fill the dictionnary with the binding energies +#fill the dictionary with the binding energies def _initializeBindingEnergies(): #read the specfile data sf = specfile.Specfile(EADL97_FILE) @@ -114,7 +114,7 @@ def _initializeElement(element): _initializeElement(element) Supposed to be of internal use. Reads the file and loads all the relevant element information contained - int the EPDL97 file into the internal dictionnary. + int the EPDL97 file into the internal dictionary. """ #read the specfile data sf = specfile.Specfile(EPDL97_FILE) @@ -128,7 +128,7 @@ def _initializeElement(element): data = scan.data() scan = None - #fill the information into the dictionnary + #fill the information into the dictionary i = -1 for label0 in labels: i += 1 @@ -328,7 +328,7 @@ def getPhotoelectricWeights(element, shelllist, energy, normalize = None, totals 'K', 'L1', 'L2', 'L3', 'M1', 'M2', 'M3', 'M4', 'M5', 'all other' For instance, for the K shell, it is the equivalent of (Jk-1)/Jk where Jk is the k jump. If normalize is None or True, normalizes the output to the shells given in shelllist. - If totals is True, gives back the a dictionnary with all the mass attenuation coefficients + If totals is True, gives back the dictionary with all the mass attenuation coefficients used in the calculations. """ if normalize is None: diff --git a/PyMca5/PyMcaPlugins/__init__.py b/PyMca5/PyMcaPlugins/__init__.py index 1c4bb10..3129f94 100644 --- a/PyMca5/PyMcaPlugins/__init__.py +++ b/PyMca5/PyMcaPlugins/__init__.py @@ -1,5 +1,5 @@ #/*########################################################################## -# Copyright (C) 2004-2014 V.A. Sole, European Synchrotron Radiation Facility +# Copyright (C) 2004-2019 V.A. Sole, European Synchrotron Radiation Facility # # This file is part of the PyMca X-ray Fluorescence Toolkit developed at # the ESRF by the Software group. @@ -32,7 +32,7 @@ PyMca5.PyMcaPlugins contains plugins associated to PyMca. They import either from Plugin1DBase (for instances of classes respecting the Plot1DBase interface) or from StackPluginBase (for -instances repecting the StackBase interface) +instances respecting the StackBase interface) See :mod:`PyMca5.PyMcaCore.Plugin1DBase` for more information about 1D plugins and :mod:`PyMca5.PyMcaCore.StackPluginBase` for information about stack plugins. diff --git a/PyMca5/__init__.py b/PyMca5/__init__.py index 7ec042e..426d738 100644 --- a/PyMca5/__init__.py +++ b/PyMca5/__init__.py @@ -27,7 +27,7 @@ __author__ = "V.A. Sole - ESRF Data Analysis" __contact__ = "sole@esrf.fr" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__version__ = "5.5.1" +__version__ = "5.5.2" import os import sys diff --git a/PyMca5/tests/ConfigDictTest.py b/PyMca5/tests/ConfigDictTest.py index 4202189..b37e9a3 100644 --- a/PyMca5/tests/ConfigDictTest.py +++ b/PyMca5/tests/ConfigDictTest.py @@ -72,7 +72,7 @@ class testConfigDict(unittest.TestCase): "Unsuccessful PyMca.ConfigDict import") def testConfigDictIO(self): - # create a dictionnary + # create a dictionary from PyMca5.PyMcaIO import ConfigDict testDict = {} testDict['simple_types'] = {} @@ -124,7 +124,7 @@ class testConfigDict(unittest.TestCase): @unittest.skipIf(not HAS_H5PY, "skipped h5py missing") def testHdf5Uri(self): - # create a dictionnary + # create a dictionary from PyMca5.PyMcaIO import ConfigDict testDict = {} testDict['simple_types'] = {} diff --git a/PyMca5/tests/PyMcaBatchTest.py b/PyMca5/tests/PyMcaBatchTest.py index ca7d98c..c1e33be 100644 --- a/PyMca5/tests/PyMcaBatchTest.py +++ b/PyMca5/tests/PyMcaBatchTest.py @@ -692,5 +692,5 @@ if __name__ == '__main__': auto = True app = qt.QApplication([]) result = test(auto) + app = None sys.exit(not result.wasSuccessful()) - app.quit() diff --git a/PyMca5/tests/XRFBatchFitOutputTest.py b/PyMca5/tests/XRFBatchFitOutputTest.py index 59f017f..26b47ea 100644 --- a/PyMca5/tests/XRFBatchFitOutputTest.py +++ b/PyMca5/tests/XRFBatchFitOutputTest.py @@ -166,7 +166,7 @@ class testXRFBatchFitOutput(unittest.TestCase): def _verifyHdf5(self, filename, outdata, outlabels, outaxes): outlabels = outlabels['h5'] - with h5py.File(filename) as f: + with h5py.File(filename, mode='a') as f: nxprocess = f['sample_dataset']['test'] self.assertEqual(set(nxprocess.keys()), {'configuration', 'date', 'program', 'version', 'results'}) diff --git a/changelog.txt b/changelog.txt index baefa5b..ad51665 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +VERSION 5.5.2 +------------- + +- HDF5: Make the code compatible with new h5py default file opening mode. + VERSION 5.5.1 ------------- diff --git a/debian/changelog b/debian/changelog index f881295..00e5735 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,18 @@ +pymca (5.5.2+dfsg-1) unstable; urgency=medium + + * New upstream version 5.5.2+dfsg + * d/control: + - Move silx to Recommends (Closes: #941002) + - Added Rules-Requires-Root: no + * d/patches: + - Removed fix_numpy_tests_0ed4a39.patch (applyed upstream) + - Removed 0002-silx-is-an-optional-dependency.patch (requested by upstream) + - Added 0002-fix-syntax-error.patch + * d/rules: + - Activated hardening + + -- Picca Frédéric-Emmanuel <picca@debian.org> Sun, 06 Oct 2019 11:23:23 +0200 + pymca (5.5.1+dfsg-2) unstable; urgency=medium * Team upload. diff --git a/debian/control b/debian/control index 9359f24..0fdbf5a 100644 --- a/debian/control +++ b/debian/control @@ -3,6 +3,7 @@ Maintainer: Debian Science Maintainers <debian-science-maintainers@lists.alioth. Uploaders: Picca Frédéric-Emmanuel <picca@debian.org> Section: science Priority: optional +Rules-Requires-Root: no Build-Depends: cython, cython-dbg, cython3, @@ -30,7 +31,6 @@ Build-Depends: cython, python-pyqt5.qtopengl-dbg <!nodoc>, python-qtconsole, python-setuptools, - python-silx, python-sphinx, python3-all-dbg, python3-all-dev, @@ -50,10 +50,9 @@ Build-Depends: cython, python3-pyqt5.qtopengl-dbg <!nodoc>, python3-qtconsole, python3-setuptools, - python3-silx, python3-sphinx, - xauth, - xvfb, + xauth, + xvfb Standards-Version: 4.4.0 Vcs-Browser: https://salsa.debian.org/science-team/pymca Vcs-Git: https://salsa.debian.org/science-team/pymca.git @@ -92,7 +91,7 @@ Depends: pymca-data (= ${source:Version}), ${misc:Depends}, ${python:Depends}, ${shlibs:Depends} -Recommends: python-h5py, python-mdp +Recommends: python-mdp, python-silx Description: Applications and toolkit for X-ray fluorescence analysis -- Python 2 PyMca is set of applications and Python libraries for analysis of X-ray fluorescence spectra. @@ -124,11 +123,10 @@ Depends: python-fisx-dbg (>= 1.1.6-1~), python-pymca5 (= ${binary:Version}), python-pyqt5-dbg, python-pyqt5.qtopengl-dbg, - python-silx-dbg, ${misc:Depends}, ${python:Depends}, ${shlibs:Depends} -Recommends: python-dbg, python-mdp +Recommends: python-dbg, python-mdp, python-silx-dbg Description: Applications and toolkit for X-ray fluorescence analysis -- Python 2 debug PyMca is set of applications and Python libraries for analysis of X-ray fluorescence spectra. @@ -156,7 +154,7 @@ Depends: pymca-data (= ${source:Version}), ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends} -Recommends: python3-h5py, python3-mdp +Recommends: python3-mdp, python3-silx Description: Applications and toolkit for X-ray fluorescence analysis -- Python 3 PyMca is set of applications and Python libraries for analysis of X-ray fluorescence spectra. @@ -187,11 +185,10 @@ Depends: python3-fisx-dbg (>= 1.1.6-1~), python3-pymca5 (= ${binary:Version}), python3-pyqt5-dbg, python3-pyqt5.qtopengl-dbg, - python3-silx-dbg, ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends} -Recommends: python3-dbg, python3-mdp +Recommends: python3-dbg, python3-mdp, python3-silx-dbg Description: Applications and toolkit for X-ray fluorescence analysis -- Python 3 debug PyMca is set of applications and Python libraries for analysis of X-ray fluorescence spectra. diff --git a/debian/patches/0002-fix-syntax-error.patch b/debian/patches/0002-fix-syntax-error.patch new file mode 100644 index 0000000..3665dcf --- /dev/null +++ b/debian/patches/0002-fix-syntax-error.patch @@ -0,0 +1,31 @@ +From: =?utf-8?q?Picca_Fr=C3=A9d=C3=A9ric-Emmanuel?= + <picca@synchrotron-soleil.fr> +Date: Sun, 6 Oct 2019 10:02:57 +0200 +Subject: fix syntax error + +--- + PyMca5/Object3D/Object3DPlugins/ChimeraStack.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py b/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py +index 4df3aa1..f731630 100644 +--- a/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py ++++ b/PyMca5/Object3D/Object3DPlugins/ChimeraStack.py +@@ -69,7 +69,7 @@ def getObject3DInstance(config=None): + #file index is irrelevant in case of an actual 3D stack. + filename = fileList[0] + legend = os.path.basename(filename) +- with h5py.File(filename, mode='r') as f ++ with h5py.File(filename, mode='r') as f: + stack = f['Image']['data'][()] + if stack is None: + raise IOError("Problem reading stack.") +@@ -120,7 +120,7 @@ if __name__ == "__main__": + if not os.path.exists(filename): + print("File does not exists") + sys.exit(1) +- with h5py.File(filename, mode='r') as f ++ with h5py.File(filename, mode='r') as f: + stack = f['Image']['data'][()] + if stack is None: + raise IOError("Problem reading stack.") diff --git a/debian/patches/0002-silx-is-an-optional-dependency.patch b/debian/patches/0002-silx-is-an-optional-dependency.patch deleted file mode 100644 index 15089e9..0000000 --- a/debian/patches/0002-silx-is-an-optional-dependency.patch +++ /dev/null @@ -1,20 +0,0 @@ -From: =?utf-8?q?Picca_Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org> -Date: Thu, 18 Jul 2019 15:29:07 +0200 -Subject: silx is an optional dependency - ---- - setup.py | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/setup.py b/setup.py -index 367f19f..69abca5 100644 ---- a/setup.py -+++ b/setup.py -@@ -904,6 +904,7 @@ if use_gui(): - install_requires += ["PyOpenGL", - "qtconsole", - "PyQt5", # either PyQt4 or PySide supported too -+ "silx", - ] - - setup_requires = ["numpy"] diff --git a/debian/patches/fix_numpy_tests_0ed4a39.patch b/debian/patches/fix_numpy_tests_0ed4a39.patch deleted file mode 100644 index dca64c7..0000000 --- a/debian/patches/fix_numpy_tests_0ed4a39.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0ed4a397bccedbfed03d14380d47ea9b6fd36050 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?V=2E=20Armando=20Sol=C3=A9?= - <vasole@users.noreply.github.com> -Date: Thu, 12 Sep 2019 16:52:13 +0200 -Subject: [PATCH] Workaround numpy issue - -The problem solved in https://github.com/numpy/numpy/pull/13715 was appearing during the debian tests in debug mode. ---- - PyMca5/tests/PyMcaBatchTest.py | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/PyMca5/tests/PyMcaBatchTest.py b/PyMca5/tests/PyMcaBatchTest.py -index d6a7c3ae..ca7d98c8 100644 ---- a/PyMca5/tests/PyMcaBatchTest.py -+++ b/PyMca5/tests/PyMcaBatchTest.py -@@ -489,7 +489,10 @@ def _convertLegacyLabels(self, labels, data): - excluded_labels = 'row', 'column', 'point' - included = [label.lower() not in excluded_labels for label in labels] - if not all(included): -- data = data[included, ...] -+ # woraround numpy issue https://github.com/numpy/numpy/pull/13715 -+ # by creating an intermediate array -+ # data = data[included, ...] -+ data = data[numpy.array(included, copy=True), ...] - labels = [label for label, b in zip(labels, included) if b] - return labels, data - diff --git a/debian/patches/series b/debian/patches/series index 354393d..4521bb8 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,2 @@ 0002-use-the-local-mathjax.patch -0002-silx-is-an-optional-dependency.patch -fix_numpy_tests_0ed4a39.patch +0002-fix-syntax-error.patch diff --git a/debian/rules b/debian/rules index c06c449..01709ee 100755 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,8 @@ #!/usr/bin/make -f export DH_VERBOSE=1 +export DEB_BUILD_MAINT_OPTIONS=hardening=+all + export HOME=/tmp export SPECFILE_USE_GNU_SOURCE=1 export WITH_CYTHON=1 @@ -904,7 +904,6 @@ if use_gui(): install_requires += ["PyOpenGL", "qtconsole", "PyQt5", # either PyQt4 or PySide supported too - "silx", ] setup_requires = ["numpy"] |