Skip to content

Commit

Permalink
Merge pull request #1077 from vasole/np2toml
Browse files Browse the repository at this point in the history
Adapt pyproject.toml
  • Loading branch information
vasole authored May 7, 2024
2 parents a06cfd9 + c22a821 commit 6c8ea6d
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 82 deletions.
12 changes: 6 additions & 6 deletions PyMca5/PyMcaCore/McaStackExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2020-2023 European Synchrotron Radiation Facility
# Copyright (c) 2020-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -182,17 +182,17 @@ def exportStack(stack, h5object, path, channels=None, calibration=None):
# get the calibration
if calibration is None:
calibration = info.get('McaCalib', [0.0, 1.0, 0.0])
h5g["calibration"] = numpy.array(calibration, copy=False)
h5g["calibration"] = numpy.asarray(calibration)

# get the time
for key in ["McaLiveTime", "live_time"]:
if key in info and info[key] is not None:
# TODO: live time can actually be elapsed time!!!
h5g["live_time"] = numpy.array(info[key], copy=False)
h5g["live_time"] = numpy.asarray(info[key])

for key in ["preset_time", "elapsed_time"]:
if key in info and info[key] is not None:
h5g[key] = numpy.array(info[key], copy=False)
h5g[key] = numpy.asarray(info[key])

# get the channels
if channels is None:
Expand All @@ -202,7 +202,7 @@ def exportStack(stack, h5object, path, channels=None, calibration=None):
channels = stack.x[0]

if channels is not None:
h5g["channels"] = numpy.array(channels, copy=False)
h5g["channels"] = numpy.asarray(channels)

# the positioners
posKey = "positioners"
Expand All @@ -214,7 +214,7 @@ def exportStack(stack, h5object, path, channels=None, calibration=None):
posGroup.attrs[att] = u"NXcollection"
for key in info[posKey]:
if key not in posGroup:
posGroup[key] = numpy.array(info[posKey][key], copy=False)
posGroup[key] = numpy.asarray(info[posKey][key])

# the scales for the common rectangular map case
if "xScale" in info and "yScale" in info:
Expand Down
12 changes: 9 additions & 3 deletions PyMca5/PyMcaCore/StackBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
# Copyright (c) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -292,7 +292,10 @@ def stackUpdated(self, positioners=None):
self._stackImageData = numpy.zeros((shape[0], shape[1]),
dtype=numpy.float64)
mcaData0 = numpy.zeros((shape[2],), numpy.float64)
mcaMax = mcaData0 + numpy.NINF
if hasattr(numpy, "NINF"):
mcaMax = mcaData0 + numpy.NINF
else:
mcaMax = mcaData0 - numpy.inf
step = 1
for i in range(shape[0]):
tmpData = self._stack.data[i:i+step,:,:]
Expand All @@ -307,7 +310,10 @@ def stackUpdated(self, positioners=None):
self._stackImageData = numpy.zeros((shape[1], shape[2]),
dtype=numpy.float64)
mcaData0 = numpy.zeros((shape[0],), numpy.float64)
mcaMax = mcaData0 + numpy.NINF
if hasattr(numpy, "NINF"):
mcaMax = mcaData0 + numpy.NINF
else:
mcaMax = mcaData0 - numpy.inf
step = 1
for i in range(shape[0]):
tmpData = self._stack.data[i:i+step,:,:]
Expand Down
4 changes: 2 additions & 2 deletions PyMca5/PyMcaCore/StackROIBatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
# Copyright (c) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -170,7 +170,7 @@ def idxmin(i): return i + 3 * nRois
rawSum = 0.0
netSum = 0.0
else:
roichunk = numpy.array(chunk[:, idx[j]], copy=False, dtype=numpy.float64)
roichunk = numpy.asarray(chunk[:, idx[j]], dtype=numpy.float64)
rawSum = roichunk.sum(axis=1, dtype=numpy.float64)
deltaX = xw[j][iXMaxList[j]] - xw[j][iXMinList[j]]
left = roichunk[:, iXMinList[j]]
Expand Down
2 changes: 1 addition & 1 deletion PyMca5/PyMcaGraph/backends/GLSupport/GLPlotFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ def _buildVerticesAndLabels(self):
if not self.isY2Axis:
extraVertices += self._y2Axis.displayCoords

extraVertices = np.array(extraVertices, copy=False, dtype=np.float32)
extraVertices = np.asarray(extraVertices, dtype=np.float32)
vertices = np.append(vertices, extraVertices, axis=0)

self._renderResources = (vertices, gridVertices, labels)
4 changes: 2 additions & 2 deletions PyMca5/PyMcaGraph/backends/GLSupport/GLSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2014 European Synchrotron Radiation Facility
# Copyright (c) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
Expand Down Expand Up @@ -117,7 +117,7 @@ class Shape2D(object):
def __init__(self, points, fill='solid', stroke=True,
fillColor=(0., 0., 0., 1.), strokeColor=(0., 0., 0., 1.),
strokeClosed=True):
self.vertices = np.array(points, dtype=np.float32, copy=False)
self.vertices = np.asarray(points, dtype=np.float32)
self.strokeClosed = strokeClosed

self._indices = buildFillMaskIndices(len(self.vertices))
Expand Down
12 changes: 6 additions & 6 deletions PyMca5/PyMcaGraph/backends/MatplotlibBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
# Copyright (c) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -46,15 +46,15 @@
# Problem on debian6 numpy version 1.4.1 unsigned longs give infinity
#from numpy import nanmax, nanmin
def nanmax(x):
x = numpy.array(x, copy=False)
x = numpy.asarray(x)
x = x[numpy.isfinite(x)]
if len(x):
return x.max()
else:
return 0

def nanmin(x):
x = numpy.array(x, copy=False)
x = numpy.asarray(x)
x = x[numpy.isfinite(x)]
if len(x):
return x.min()
Expand Down Expand Up @@ -635,7 +635,7 @@ def _getDrawingColor(self):
return color

def onMouseMoved(self, event):
if DEBUG:
if 1 or DEBUG:
print("onMouseMoved, event = ",event.xdata, event.ydata)
if event.inaxes != self.ax:
if DEBUG:
Expand Down Expand Up @@ -1700,8 +1700,8 @@ def addItem(self, x, y, legend, info=None, replace=False, replot=True, **kw):
label = kw.get('label', legend)
color = kw.get('color', 'black')
fill = kw.get('fill', True)
xView = numpy.array(x, copy=False)
yView = numpy.array(y, copy=False)
xView = numpy.asarray(x)
yView = numpy.asarray(y)
label = "__ITEM__" + label
if shape in ["line", "hline", "vline"]:
print("Not implemented")
Expand Down
16 changes: 8 additions & 8 deletions PyMca5/PyMcaGraph/backends/_OpenGLPlotCanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2015 European Synchrotron Radiation Facility
# Copyright (c) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
Expand Down Expand Up @@ -1323,7 +1323,7 @@ def addImage(self, data, legend=None, info=None,
RuntimeWarning)
data = np.array(data, dtype=np.float32, order='C')
else:
data = np.array(data, copy=False, order='C')
data = np.asarray(data, order='C')
assert data.dtype in (np.float32, np.uint8, np.uint16)

if colormap is None:
Expand Down Expand Up @@ -1447,8 +1447,8 @@ def addItem(self, xList, yList, legend=None, info=None,
yMin, yMax = yList
yList = np.array((yMin, yMax, yMax, yMin))
else:
xList = np.array(xList, copy=False)
yList = np.array(yList, copy=False)
xList = np.asarray(xList)
yList = np.asarray(yList)

if self._plotFrame.xAxis.isLog and xList.min() <= 0.:
raise RuntimeError(
Expand Down Expand Up @@ -1501,13 +1501,13 @@ def addCurve(self, x, y, legend=None, info=None,
if legend is None:
legend = self._UNNAMED_ITEM

x = np.array(x, dtype=np.float32, copy=False, order='C')
y = np.array(y, dtype=np.float32, copy=False, order='C')
x = np.asarray(x, dtype=np.float32, order='C')
y = np.asarray(y, dtype=np.float32, order='C')
if xerror is not None:
xerror = np.array(xerror, dtype=np.float32, copy=False, order='C')
xerror = np.asarray(xerror, dtype=np.float32, order='C')
assert np.all(xerror >= 0.)
if yerror is not None:
yerror = np.array(yerror, dtype=np.float32, copy=False, order='C')
yerror = np.asarray(yerror, dtype=np.float32, order='C')
assert np.all(yerror >= 0.)

behaviors = set()
Expand Down
6 changes: 3 additions & 3 deletions PyMca5/PyMcaGui/misc/NumpyArrayTableModel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -230,13 +230,13 @@ def setArrayColors(self, bgcolors=None, fgcolors=None):
errmsg = "Inconsistent shape for color array, should be %s or %s" % valid_shapes

if bgcolors is not None:
bgcolors = numpy.array(bgcolors, copy=False)
bgcolors = numpy.asarray(bgcolors)
assert bgcolors.shape in valid_shapes, errmsg

self._bgcolors = bgcolors

if fgcolors is not None:
fgcolors = numpy.array(fgcolors, copy=False)
fgcolors = numpy.asarray(fgcolors)
assert fgcolors.shape in valid_shapes, errmsg

self._fgcolors = fgcolors
Expand Down
4 changes: 2 additions & 2 deletions PyMca5/PyMcaGui/physics/xas/XASNormalizationWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2023 European Synchrotron Radiation Facility
# Copyright (c) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -280,7 +280,7 @@ def __init__(self, parent, spectrum, energy=None):
self.energy = numpy.arange(len(spectrum)).astype(numpy.float64)
else:
self.energy = energy
self.spectrum = numpy.array(spectrum, dtype=numpy.float64, copy=False)
self.spectrum = numpy.asarray(spectrum, dtype=numpy.float64)
self.parametersWidget = XASNormalizationParametersWidget(self)
self.graph = PlotWindow.PlotWindow(self, backend=backend,
plugins=False, newplot=False)
Expand Down
12 changes: 8 additions & 4 deletions PyMca5/PyMcaGui/plotting/ImageView.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2016 European Synchrotron Radiation Facility
# Copyright (c) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
# the ESRF.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,7 +26,7 @@
# THE SOFTWARE.
#
# ###########################################################################*/
__author__ = "T. Vincent - ESRF Data Analysis"
__author__ = "T. Vincent - ESRF"
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
Expand Down Expand Up @@ -754,7 +754,11 @@ def setImage(self, image, origin=(0, 0), scale=(1., 1.),
self._imagePlot.removeImage(self._imageLegend, replot=False)
return

data = np.array(image, order='C', copy=copy)
if copy:
data = np.array(image, order='C', copy=True)
else:
data = np.asarray(image, order='C')

assert data.size != 0
assert len(data.shape) == 2
height, width = data.shape
Expand Down
4 changes: 2 additions & 2 deletions PyMca5/PyMcaGui/plotting/MaskScatterWidget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -383,7 +383,7 @@ def setSelectionMask(self, mask=None, plot=True):
self._selectionMask = mask
else:
x, y = selectionCurve[0:2]
x = numpy.array(x, copy=False)
x = numpy.asarray(x)
if hasattr(mask, "size"):
if mask.size == x.size:
if self._selectionMask is None:
Expand Down
11 changes: 7 additions & 4 deletions PyMca5/PyMcaGui/plotting/ScatterPlotCorrelatorWidget.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#/*##########################################################################
# Copyright (C) 2004-2015 V.A. Sole, European Synchrotron Radiation Facility
# Copyright (C) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
# the ESRF.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -23,7 +23,7 @@
# THE SOFTWARE.
#
#############################################################################*/
__author__ = "V.A. Sole - ESRF Data Analysis"
__author__ = "V.A. Sole - ESRF"
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
Expand Down Expand Up @@ -87,7 +87,10 @@ def setSelectableItemList(self, items, labels=None, copy=True):

def addSelectableItem(self, item, label=None, copy=True):
# we always keep a copy by default
item = numpy.array(item, dtype=numpy.float32, copy=copy)
if copy:
item = numpy.array(item, dtype=numpy.float32, copy=True)
else:
item = numpy.asarray(item, dtype=numpy.float32)
if label is None:
label = "Unnamed 00"
i = 0
Expand Down
4 changes: 2 additions & 2 deletions PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# /*#########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -142,7 +142,7 @@ def setSelectionMask(self, mask, copy=True):
The mask can be cropped or padded to fit active image,
the returned shape is that of the active image.
"""
mask = numpy.array(mask, copy=False, dtype=numpy.uint8)
mask = numpy.asarray(mask, dtype=numpy.uint8)
if len(mask.shape) != 2:
# _logger.error('Not an image, shape: %d', len(mask.shape))
return None
Expand Down
6 changes: 3 additions & 3 deletions PyMca5/PyMcaGui/pymca/QPyMcaMatplotlibSave1D.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -482,8 +482,8 @@ def addDataToPlot(self, x, y, legend = None,
linestyle = None,
marker=None,
alias = None,**kw):
x = numpy.array(x, copy=False)
y = numpy.array(y, copy=False)
x = numpy.asarray(x)
y = numpy.asarray(y)
if self.limitsSet is not None:
n = self._filterData(x, y)
if not len(n):
Expand Down
Loading

0 comments on commit 6c8ea6d

Please sign in to comment.