Skip to content

Commit 4ec63e9

Browse files
Merge pull request #38420 from mantidproject/numpy_2
Numpy 2 update
2 parents adb07df + 6afb1b0 commit 4ec63e9

File tree

24 files changed

+38
-34
lines changed

24 files changed

+38
-34
lines changed

Framework/PythonInterface/mantid/plots/datafunctions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def get_bin_indices(workspace):
398398
else:
399399
# the following two lines can be replaced by np.isin when > version 1.7.0 is used on RHEL7
400400
total_range = np.asarray(range(total_range))
401-
indices = np.where(np.in1d(total_range, monitors_indices, invert=True).reshape(total_range.shape))
401+
indices = np.where(np.isin(total_range, monitors_indices, invert=True).reshape(total_range.shape))
402402
# this check is necessary as numpy may return a tuple or a plain array based on platform.
403403
indices = indices[0] if isinstance(indices, tuple) else indices
404404
return indices

Framework/PythonInterface/mantid/plots/mantidaxes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,8 @@ def plot_surface(self, *args, **kwargs):
15261526

15271527
# This is a bit of a hack, should be able to remove
15281528
# when matplotlib supports plotting masked arrays
1529-
poly_c._A = safe_masked_invalid(poly_c._A)
1529+
if poly_c._A is not None:
1530+
poly_c._A = safe_masked_invalid(poly_c._A)
15301531

15311532
# Create a copy of the original data points because data are set to nan when the axis limits are changed.
15321533
self.original_data_surface = copy.deepcopy(poly_c._vec)

Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def PyInit(self):
4444
# Input parameters
4545
self.declareProperty("SpectrumNumber", 1, doc="Spectrum number to use", validator=IntBoundedValidator(lower=0))
4646
self.declareProperty("StartXValue", 0.0, doc="Value of X to start the search from")
47-
self.declareProperty("EndXValue", np.Inf, doc="Value of X to stop the search to")
47+
self.declareProperty("EndXValue", np.inf, doc="Value of X to stop the search to")
4848
self.declareProperty(
4949
"AcceptanceThreshold",
5050
0.01,

Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def poisson_cost(self, y_data, y_fit):
261261
y_fit = y_fit[np.nonzero(y_data)]
262262
y_data = y_data[np.nonzero(y_data)]
263263
if len(y_fit) < 1:
264-
return -np.Inf
264+
return -np.inf
265265
y_log = np.log(np.abs(y_fit))
266266
return np.sum(-y_fit + y_data * y_log)
267267

Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ def _correct_for_fractional_foreground_centre(self, ws: MatrixWorkspace, summed_
285285
if dist != 0.0:
286286
det_point_1 = ws.spectrumInfo().position(0)
287287
det_point_2 = ws.spectrumInfo().position(20)
288-
beta = numpy.math.atan2((det_point_2[0] - det_point_1[0]), (det_point_2[2] - det_point_1[2]))
289-
x_vs_y = numpy.math.sin(beta) * dist
290-
mz = numpy.math.cos(beta) * dist
288+
beta = numpy.atan2((det_point_2[0] - det_point_1[0]), (det_point_2[2] - det_point_1[2]))
289+
x_vs_y = numpy.sin(beta) * dist
290+
mz = numpy.cos(beta) * dist
291291
if instr == "D17":
292292
mx = x_vs_y
293293
my = 0.0

Framework/PythonInterface/test/python/mantid/utils/nomad/diagnosticsTest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ def test_tube_collevel(self):
434434
levels = tester.tube_collevel # shape = (TUBE_COUNT,)
435435
assert len(levels) == tester.TUBE_COUNT
436436
first1, last1 = tester.TUBES_IN_EIGHTPACK * 77, tester.TUBES_IN_EIGHTPACK * 78
437-
assert np.all(levels[:first1]) == CollimationLevel.Empty
438-
assert np.all(levels[first1:last1]) == CollimationLevel.Half
437+
assert np.all(levels[:first1] == CollimationLevel.Empty)
438+
assert np.all(levels[first1:last1] == CollimationLevel.Half)
439439
first2, last2 = tester.TUBES_IN_EIGHTPACK * 95, tester.TUBES_IN_EIGHTPACK * 96
440-
assert np.all(levels[last1:first2]) == CollimationLevel.Empty
441-
assert np.all(levels[first2:last2]) == CollimationLevel.Full
442-
assert np.all(levels[last2:]) == CollimationLevel.Empty
440+
assert np.all(levels[last1:first2] == CollimationLevel.Empty)
441+
assert np.all(levels[first2:last2] == CollimationLevel.Full)
442+
assert np.all(levels[last2:] == CollimationLevel.Empty)
443443

444444
def test_panel_median(self):
445445
tester = self.tester1

Framework/PythonInterface/test/python/plugins/algorithms/SaveP2DTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _create_workspace(self):
3333
"""Create a dummy workspace for testing purposes"""
3434
xData = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] # d values for one spectrum (one dPerpendicular value)
3535
yData = ["1", "2", "3"] # dPerpendicular binedges
36-
zData = [1.0, 2.0, 3.0, -1.0, 0.0, np.NaN, 3.0, 1.0, 4.0] # intensity values
36+
zData = [1.0, 2.0, 3.0, -1.0, 0.0, np.nan, 3.0, 1.0, 4.0] # intensity values
3737
eData = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] # error values
3838

3939
# used to join all spectra

Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_parse_fit_table_correctly_formats_the_table(self):
172172

173173
def test_parse_fit_table_marks_peaks_for_refitting_if_error_larger_than_value(self):
174174
peaks = [(35.2, 0.4), (25.03, 0.1), (10.03, 0.05)]
175-
peaks += [(20.003, 40.22), (75.15, 0.2), (5.2, np.NaN)]
175+
peaks += [(20.003, 40.22), (75.15, 0.2), (5.2, np.nan)]
176176
fit_table = self.simulate_fit_parameter_output(peaks, 100.034)
177177
data_table = CreateEmptyTableWorkspace()
178178

buildconfig/CMake/PyStoG.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
include(ExternalProject)
22

3-
set(_PyStoG_VERSION f184ebf9a72aae48ae0d5267fd6ab2e7df0988f6) # v0.4.7
3+
set(_PyStoG_VERSION 7b5492d98817024f2b62867bc2a82fc23184b777) # v0.5.0
44
set(_PyStoG_download_dir ${CMAKE_CURRENT_BINARY_DIR}/../PyStoG-download)
5-
set(_PyStoG_source_dir ${_PyStoG_download_dir}/src/PyStoG/pystog)
5+
set(_PyStoG_source_dir ${_PyStoG_download_dir}/src/PyStoG/src/pystog)
66
set(_PyStoG_source_test_dir ${_PyStoG_download_dir}/src/PyStoG/tests)
77
set(_PyStoG_scripts_dir ${CMAKE_CURRENT_BINARY_DIR}/pystog)
88
set(_PyStoG_test_root_dir ${CMAKE_CURRENT_BINARY_DIR}/test/pystog)

conda/recipes/conda_build_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ nexus:
6363
- 4.4.*
6464
# We follow conda-forge and build with the lowest supported version of numpy for forward compatibility.
6565
numpy:
66-
- 1.24.*
66+
- 2.0.*
6767

6868
matplotlib:
6969
- 3.8.*

0 commit comments

Comments
 (0)