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 b2588fe commit 6bf187c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
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

0 comments on commit 6bf187c

Please sign in to comment.