Skip to content

Commit

Permalink
Use asarray
Browse files Browse the repository at this point in the history
  • Loading branch information
vasole committed May 7, 2024
1 parent 68d26e8 commit b2588fe
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 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
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

0 comments on commit b2588fe

Please sign in to comment.