From 22033c4918fec4cc08412f58fa60cfa9053ffd9e Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Fri, 22 Nov 2024 16:33:56 -0500 Subject: [PATCH 01/17] Add function for ostream --- Framework/Indexing/inc/MantidIndexing/IndexType.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Framework/Indexing/inc/MantidIndexing/IndexType.h b/Framework/Indexing/inc/MantidIndexing/IndexType.h index 21ae6d734388..708860b11b82 100644 --- a/Framework/Indexing/inc/MantidIndexing/IndexType.h +++ b/Framework/Indexing/inc/MantidIndexing/IndexType.h @@ -41,6 +41,12 @@ class IndexType { Int m_data; }; +template ::value>::type> +std::ostream &operator<<(std::ostream &ostr, const IndexType object) { + ostr << object.str(); + return ostr; +} + } // namespace detail } // namespace Indexing } // namespace Mantid From 48751e19571df166a7a160ba621726dffc41a89c Mon Sep 17 00:00:00 2001 From: Jonathan Haigh Date: Mon, 4 Nov 2024 15:40:19 +0000 Subject: [PATCH 02/17] Update numpy version in conda build config This is all of the changes from #38420 Co-authored-by: Thomas Hampson envoke ruff rule NPY201 additional numpy 2 fixes Avoid passing None to cbook.safe_masked_invalid To be compatible wiht Numpy 2, avoid giving None to mpl's safe_masked_invalid method which constructs a numpy array x = np.array(x, subok=True, copy=copy), producing an error with a None type in Numpy 2. Update pystog to v0.5.0 added release note --- .../PythonInterface/mantid/plots/datafunctions.py | 2 +- Framework/PythonInterface/mantid/plots/mantidaxes.py | 3 ++- .../WorkflowAlgorithms/FindPeaksAutomatic.py | 2 +- .../algorithms/WorkflowAlgorithms/FitGaussianPeaks.py | 2 +- .../ReflectometryILLSumForeground.py | 6 +++--- .../test/python/mantid/utils/nomad/diagnosticsTest.py | 10 +++++----- .../test/python/plugins/algorithms/SaveP2DTest.py | 2 +- .../WorkflowAlgorithms/FitGaussianPeaksTest.py | 2 +- buildconfig/CMake/PyStoG.cmake | 4 ++-- conda/recipes/conda_build_config.yaml | 2 +- conda/recipes/mantid-developer/meta.yaml | 2 +- conda/recipes/mantid/meta.yaml | 2 +- .../v6.12.0/Diffraction/Powder/New_features/38404.rst | 2 +- .../Framework/Dependencies/New_features/38420.rst | 1 + pyproject.toml | 2 +- .../widgets/codeeditor/test/test_completion.py | 4 +++- .../PeriodicTable/PeakSelector/peak_selector_view.py | 8 ++++---- scripts/Inelastic/CrystalField/normalisation.py | 2 +- scripts/Inelastic/Direct/PropertiesDescriptors.py | 4 ++-- scripts/Muon/MaxentTools/opus.py | 2 +- scripts/Muon/MaxentTools/tropus.py | 2 +- scripts/Muon/MaxentTools/zft.py | 2 +- scripts/pychop/Instruments.py | 2 +- scripts/test/Abins/AbinsBroadeningTest.py | 2 +- 24 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 docs/source/release/v6.12.0/Framework/Dependencies/New_features/38420.rst diff --git a/Framework/PythonInterface/mantid/plots/datafunctions.py b/Framework/PythonInterface/mantid/plots/datafunctions.py index fa4ae0692dc3..93ad4f41a69e 100644 --- a/Framework/PythonInterface/mantid/plots/datafunctions.py +++ b/Framework/PythonInterface/mantid/plots/datafunctions.py @@ -398,7 +398,7 @@ def get_bin_indices(workspace): else: # the following two lines can be replaced by np.isin when > version 1.7.0 is used on RHEL7 total_range = np.asarray(range(total_range)) - indices = np.where(np.in1d(total_range, monitors_indices, invert=True).reshape(total_range.shape)) + indices = np.where(np.isin(total_range, monitors_indices, invert=True).reshape(total_range.shape)) # this check is necessary as numpy may return a tuple or a plain array based on platform. indices = indices[0] if isinstance(indices, tuple) else indices return indices diff --git a/Framework/PythonInterface/mantid/plots/mantidaxes.py b/Framework/PythonInterface/mantid/plots/mantidaxes.py index c7ea09e01428..420ba56d220f 100644 --- a/Framework/PythonInterface/mantid/plots/mantidaxes.py +++ b/Framework/PythonInterface/mantid/plots/mantidaxes.py @@ -1526,7 +1526,8 @@ def plot_surface(self, *args, **kwargs): # This is a bit of a hack, should be able to remove # when matplotlib supports plotting masked arrays - poly_c._A = safe_masked_invalid(poly_c._A) + if poly_c._A is not None: + poly_c._A = safe_masked_invalid(poly_c._A) # Create a copy of the original data points because data are set to nan when the axis limits are changed. self.original_data_surface = copy.deepcopy(poly_c._vec) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py index 371f52a45ec2..c1c56635bcca 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py @@ -44,7 +44,7 @@ def PyInit(self): # Input parameters self.declareProperty("SpectrumNumber", 1, doc="Spectrum number to use", validator=IntBoundedValidator(lower=0)) self.declareProperty("StartXValue", 0.0, doc="Value of X to start the search from") - self.declareProperty("EndXValue", np.Inf, doc="Value of X to stop the search to") + self.declareProperty("EndXValue", np.inf, doc="Value of X to stop the search to") self.declareProperty( "AcceptanceThreshold", 0.01, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py index 937ece9e37b4..a1fbf7df5553 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py @@ -261,7 +261,7 @@ def poisson_cost(self, y_data, y_fit): y_fit = y_fit[np.nonzero(y_data)] y_data = y_data[np.nonzero(y_data)] if len(y_fit) < 1: - return -np.Inf + return -np.inf y_log = np.log(np.abs(y_fit)) return np.sum(-y_fit + y_data * y_log) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py index d4edd8a87d97..dcf8a48dc7ac 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py @@ -285,9 +285,9 @@ def _correct_for_fractional_foreground_centre(self, ws: MatrixWorkspace, summed_ if dist != 0.0: det_point_1 = ws.spectrumInfo().position(0) det_point_2 = ws.spectrumInfo().position(20) - beta = numpy.math.atan2((det_point_2[0] - det_point_1[0]), (det_point_2[2] - det_point_1[2])) - x_vs_y = numpy.math.sin(beta) * dist - mz = numpy.math.cos(beta) * dist + beta = numpy.atan2((det_point_2[0] - det_point_1[0]), (det_point_2[2] - det_point_1[2])) + x_vs_y = numpy.sin(beta) * dist + mz = numpy.cos(beta) * dist if instr == "D17": mx = x_vs_y my = 0.0 diff --git a/Framework/PythonInterface/test/python/mantid/utils/nomad/diagnosticsTest.py b/Framework/PythonInterface/test/python/mantid/utils/nomad/diagnosticsTest.py index f99c5cebf7f0..ca1b2ac3ebba 100644 --- a/Framework/PythonInterface/test/python/mantid/utils/nomad/diagnosticsTest.py +++ b/Framework/PythonInterface/test/python/mantid/utils/nomad/diagnosticsTest.py @@ -434,12 +434,12 @@ def test_tube_collevel(self): levels = tester.tube_collevel # shape = (TUBE_COUNT,) assert len(levels) == tester.TUBE_COUNT first1, last1 = tester.TUBES_IN_EIGHTPACK * 77, tester.TUBES_IN_EIGHTPACK * 78 - assert np.all(levels[:first1]) == CollimationLevel.Empty - assert np.all(levels[first1:last1]) == CollimationLevel.Half + assert np.all(levels[:first1] == CollimationLevel.Empty) + assert np.all(levels[first1:last1] == CollimationLevel.Half) first2, last2 = tester.TUBES_IN_EIGHTPACK * 95, tester.TUBES_IN_EIGHTPACK * 96 - assert np.all(levels[last1:first2]) == CollimationLevel.Empty - assert np.all(levels[first2:last2]) == CollimationLevel.Full - assert np.all(levels[last2:]) == CollimationLevel.Empty + assert np.all(levels[last1:first2] == CollimationLevel.Empty) + assert np.all(levels[first2:last2] == CollimationLevel.Full) + assert np.all(levels[last2:] == CollimationLevel.Empty) def test_panel_median(self): tester = self.tester1 diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SaveP2DTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SaveP2DTest.py index 849c80bb0687..6b0695cb47bf 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SaveP2DTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SaveP2DTest.py @@ -33,7 +33,7 @@ def _create_workspace(self): """Create a dummy workspace for testing purposes""" 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) yData = ["1", "2", "3"] # dPerpendicular binedges - zData = [1.0, 2.0, 3.0, -1.0, 0.0, np.NaN, 3.0, 1.0, 4.0] # intensity values + zData = [1.0, 2.0, 3.0, -1.0, 0.0, np.nan, 3.0, 1.0, 4.0] # intensity values eData = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] # error values # used to join all spectra diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py index 327caf3c3cc3..2a83545322cc 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py @@ -172,7 +172,7 @@ def test_parse_fit_table_correctly_formats_the_table(self): def test_parse_fit_table_marks_peaks_for_refitting_if_error_larger_than_value(self): peaks = [(35.2, 0.4), (25.03, 0.1), (10.03, 0.05)] - peaks += [(20.003, 40.22), (75.15, 0.2), (5.2, np.NaN)] + peaks += [(20.003, 40.22), (75.15, 0.2), (5.2, np.nan)] fit_table = self.simulate_fit_parameter_output(peaks, 100.034) data_table = CreateEmptyTableWorkspace() diff --git a/buildconfig/CMake/PyStoG.cmake b/buildconfig/CMake/PyStoG.cmake index 051ca31fee79..f9cdf372b4ad 100644 --- a/buildconfig/CMake/PyStoG.cmake +++ b/buildconfig/CMake/PyStoG.cmake @@ -1,8 +1,8 @@ include(ExternalProject) -set(_PyStoG_VERSION f184ebf9a72aae48ae0d5267fd6ab2e7df0988f6) # v0.4.7 +set(_PyStoG_VERSION 7b5492d98817024f2b62867bc2a82fc23184b777) # v0.5.0 set(_PyStoG_download_dir ${CMAKE_CURRENT_BINARY_DIR}/../PyStoG-download) -set(_PyStoG_source_dir ${_PyStoG_download_dir}/src/PyStoG/pystog) +set(_PyStoG_source_dir ${_PyStoG_download_dir}/src/PyStoG/src/pystog) set(_PyStoG_source_test_dir ${_PyStoG_download_dir}/src/PyStoG/tests) set(_PyStoG_scripts_dir ${CMAKE_CURRENT_BINARY_DIR}/pystog) set(_PyStoG_test_root_dir ${CMAKE_CURRENT_BINARY_DIR}/test/pystog) diff --git a/conda/recipes/conda_build_config.yaml b/conda/recipes/conda_build_config.yaml index c313dbf23fea..6a87355fd9b9 100644 --- a/conda/recipes/conda_build_config.yaml +++ b/conda/recipes/conda_build_config.yaml @@ -63,7 +63,7 @@ nexus: - 4.4.* # We follow conda-forge and build with the lowest supported version of numpy for forward compatibility. numpy: - - 1.24.* + - 2.0.* matplotlib: - 3.8.* diff --git a/conda/recipes/mantid-developer/meta.yaml b/conda/recipes/mantid-developer/meta.yaml index 9bf19088befb..d5616bcf6ef2 100644 --- a/conda/recipes/mantid-developer/meta.yaml +++ b/conda/recipes/mantid-developer/meta.yaml @@ -28,7 +28,7 @@ requirements: - muparser {{ muparser }} - nexus {{ nexus }} - ninja {{ ninja }} - - numpy>=1.24,<1.27 # This is intentionally different to conda_build_config.yaml, will address later. + - numpy>=2.0,<2.2 # This is intentionally different to conda_build_config.yaml, will address later. - occt {{ occt }} - pip {{ pip }} - poco {{ poco }} diff --git a/conda/recipes/mantid/meta.yaml b/conda/recipes/mantid/meta.yaml index 7a682c6434b2..c3331e63036d 100644 --- a/conda/recipes/mantid/meta.yaml +++ b/conda/recipes/mantid/meta.yaml @@ -63,7 +63,7 @@ requirements: - lib3mf # [win] - mkl {{ mkl }} # [win] - nexus {{ nexus }} - - {{ pin_compatible("numpy", upper_bound="1.27") }} + - {{ pin_compatible("numpy", upper_bound="2.2") }} - occt {{ occt }} - pycifrw - python diff --git a/docs/source/release/v6.12.0/Diffraction/Powder/New_features/38404.rst b/docs/source/release/v6.12.0/Diffraction/Powder/New_features/38404.rst index 497ac229c8fb..0c64fbad9f2f 100644 --- a/docs/source/release/v6.12.0/Diffraction/Powder/New_features/38404.rst +++ b/docs/source/release/v6.12.0/Diffraction/Powder/New_features/38404.rst @@ -1 +1 @@ -- Move `pystog `_ from v0.2.7 to v0.4.7 +- Move `pystog `_ from v0.2.7 to v0.5.0 which supports numpy v2 diff --git a/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38420.rst b/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38420.rst new file mode 100644 index 000000000000..067b795f2a9d --- /dev/null +++ b/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38420.rst @@ -0,0 +1 @@ +- Drop support for NumPy version 1. We now build against NumPy v2.0 and support up to v2.1. `Read about the changes `_. **Users should note that NumPy 2 introduces some breaking API changes. See the `NumPy 2 Migration Guide `_ for more details** diff --git a/pyproject.toml b/pyproject.toml index bcb26947130c..370105bdaece 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.ruff] line-length = 140 # https://beta.ruff.rs/docs/rules/ -lint.select = ["C90", "E", "F", "RUF100", "W"] +lint.select = ["C90", "E", "F", "RUF100", "W", "NPY201"] lint.ignore = ["E722", # bare except ] exclude = [ diff --git a/qt/python/mantidqt/mantidqt/widgets/codeeditor/test/test_completion.py b/qt/python/mantidqt/mantidqt/widgets/codeeditor/test/test_completion.py index 69ef0e3e02f3..97b5efd766a1 100644 --- a/qt/python/mantidqt/mantidqt/widgets/codeeditor/test/test_completion.py +++ b/qt/python/mantidqt/mantidqt/widgets/codeeditor/test/test_completion.py @@ -54,7 +54,9 @@ def test_numpy_call_tips_generated_if_numpy_imported_in_script(self): self._run_check_call_tip_generated("import numpy as np\n# My code", r"np\.asarray\(a, \[dtype\], .*\)") def test_numpy_call_tips_generated_handling_wildcards_properly_if_numpy_imported_in_script(self): - self._run_check_call_tip_generated("import numpy as np\n# My code", r"np\.asarray\(a, \[dtype\], \[order\], \*, \[like\]\)") + self._run_check_call_tip_generated( + "import numpy as np\n# My code", r"np\.asarray\(a, \[dtype\], \[order\], \*, \[device\], \[copy\], \[like\]\)" + ) def test_call_tips_generated_if_syntax_errors_in_script(self): self._run_check_call_tip_generated("from mantid.simpleapi import *\n print 'Hello', 'World'", "Rebin") diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py index 38d633a8552f..6c51aeaed1f9 100644 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py @@ -34,19 +34,19 @@ def valid_data(peak_data): return False if peak_data["Primary"] is not None: for x_pos in peak_data["Primary"].values(): - if not value_in_bounds(x_pos, 0.0, np.Inf): + if not value_in_bounds(x_pos, 0.0, np.inf): return False if peak_data["Secondary"] is not None: for x_pos in peak_data["Secondary"].values(): - if not value_in_bounds(x_pos, 0.0, np.Inf): + if not value_in_bounds(x_pos, 0.0, np.inf): return False if "Gammas" in data_label and peak_data["Gammas"] is not None: for x_pos in peak_data["Gammas"].values(): - if not value_in_bounds(x_pos, 0.0, np.Inf): + if not value_in_bounds(x_pos, 0.0, np.inf): return False if "Electrons" in data_label and peak_data["Electrons"] is not None: for x_pos in peak_data["Electrons"].values(): - if not value_in_bounds(x_pos, 0.0, np.Inf): + if not value_in_bounds(x_pos, 0.0, np.inf): return False return True diff --git a/scripts/Inelastic/CrystalField/normalisation.py b/scripts/Inelastic/CrystalField/normalisation.py index 47123afefdd3..a4fccf67b5b5 100644 --- a/scripts/Inelastic/CrystalField/normalisation.py +++ b/scripts/Inelastic/CrystalField/normalisation.py @@ -37,7 +37,7 @@ def _get_normalisation(nre, bnames): for bname in bnames: bdict = {bname: 1} ee, vv, ham = CFEnergy(nre, **bdict) - Omat = np.mat(ham) + Omat = np.asmatrix(ham) norm = np.trace(np.real(Omat * np.conj(Omat))) / (2 * J + 1) retval[bname] = np.sqrt(np.abs(norm)) * np.sign(norm) return retval diff --git a/scripts/Inelastic/Direct/PropertiesDescriptors.py b/scripts/Inelastic/Direct/PropertiesDescriptors.py index e9711b3bda19..146b98650e74 100644 --- a/scripts/Inelastic/Direct/PropertiesDescriptors.py +++ b/scripts/Inelastic/Direct/PropertiesDescriptors.py @@ -1685,10 +1685,10 @@ def read_psi_from_workspace(self, workspace): # pylint: disable=protected-access offset = self._mot_offset._offset if offset is None: - return np.NaN + return np.nan log_val = self._read_ws_logs(workspace) if log_val is None: - return np.NaN + return np.nan else: return offset + log_val diff --git a/scripts/Muon/MaxentTools/opus.py b/scripts/Muon/MaxentTools/opus.py index f2307c92bf48..08e1259f0783 100644 --- a/scripts/Muon/MaxentTools/opus.py +++ b/scripts/Muon/MaxentTools/opus.py @@ -10,7 +10,7 @@ def OPUS(x, SAVETIME_i2, PULSESHAPE_convol, DETECT_a, DETECT_b, DETECT_e): npts = DETECT_e.shape[0] n = x.shape[0] - y = np.zeros([SAVETIME_i2], dtype=np.complex_) + y = np.zeros([SAVETIME_i2], dtype=np.complex128) y[:n] = x * PULSESHAPE_convol y2 = np.fft.ifft(y) * SAVETIME_i2 # SN=+1, inverse FFT without the 1/N ox = (np.outer(np.real(y2[:npts]), DETECT_a) + np.outer(np.imag(y2[:npts]), DETECT_b)) * DETECT_e[:, np.newaxis] diff --git a/scripts/Muon/MaxentTools/tropus.py b/scripts/Muon/MaxentTools/tropus.py index 20e8a592e348..789c8ebb0db0 100644 --- a/scripts/Muon/MaxentTools/tropus.py +++ b/scripts/Muon/MaxentTools/tropus.py @@ -10,7 +10,7 @@ def TROPUS(ox, SAVETIME_i2, PULSESHAPE_convol, DETECT_a, DETECT_b, DETECT_e): npts, ngroups = ox.shape n = PULSESHAPE_convol.shape[0] - y = np.zeros([SAVETIME_i2], dtype=np.complex_) + y = np.zeros([SAVETIME_i2], dtype=np.complex128) y[:npts] = np.dot(ox, DETECT_a) * DETECT_e + 1.0j * np.dot(ox, DETECT_b) * DETECT_e y2 = np.fft.fft(y) # SN=-1 meaning forward fft, scale is OK x = np.real(y2)[:n] * np.real(PULSESHAPE_convol) + np.imag(y2)[:n] * np.imag(PULSESHAPE_convol) diff --git a/scripts/Muon/MaxentTools/zft.py b/scripts/Muon/MaxentTools/zft.py index aa91e6b6e907..3fdfd9c1602f 100644 --- a/scripts/Muon/MaxentTools/zft.py +++ b/scripts/Muon/MaxentTools/zft.py @@ -16,7 +16,7 @@ def ZFT(f, PULSESHAPE_convol, DETECT_e, SAVETIME_i2): n = f.shape[0] npts = DETECT_e.shape[0] - y = np.zeros([SAVETIME_i2], dtype=np.complex_) + y = np.zeros([SAVETIME_i2], dtype=np.complex128) y[:n] = f * PULSESHAPE_convol y2 = np.fft.ifft(y) * SAVETIME_i2 # SN=+1 meaning inverse FFT without the 1/N scale factor return np.real(y2[:npts]) * DETECT_e, np.imag(y2[:npts]) * DETECT_e diff --git a/scripts/pychop/Instruments.py b/scripts/pychop/Instruments.py index 1552312d055e..4c932566559e 100644 --- a/scripts/pychop/Instruments.py +++ b/scripts/pychop/Instruments.py @@ -1001,7 +1001,7 @@ def calculate(cls, *args, **kwargs): try: etrans = float(etrans) except TypeError: - etrans = np.asfarray(etrans) + etrans = np.asarray(etrans, dtype=float) res = obj.getResolution(etrans) if return_polynomial: diff --git a/scripts/test/Abins/AbinsBroadeningTest.py b/scripts/test/Abins/AbinsBroadeningTest.py index 34cb26fd417d..fffe4271c685 100644 --- a/scripts/test/Abins/AbinsBroadeningTest.py +++ b/scripts/test/Abins/AbinsBroadeningTest.py @@ -140,7 +140,7 @@ def sigma_func(frequencies): # Normal scheme reproduces area as well as total; freq_points, full_spectrum = broadening.broaden_spectrum(frequencies, bins, s_dft, sigma, scheme="normal") self.assertAlmostEqual( - np.trapz(spectrum, x=freq_points), + np.trapezoid(spectrum, x=freq_points), pre_broadening_total * (bins[1] - bins[0]), ) self.assertAlmostEqual(sum(spectrum), pre_broadening_total) From f0e4bfb3f6d608aee2acb52be9737c990b308c6e Mon Sep 17 00:00:00 2001 From: James Clarke Date: Fri, 1 Nov 2024 13:27:14 +0000 Subject: [PATCH 03/17] Update gcc to version 13 This is a squashed version of #38351 There were a number of places that triggered a dangling-reference warning, but a lot look like false positives to me.. Also several places had unnecessary std::move() on a string argument in a constructor that was being passed by reference. Fix cppcheck warnings I fixed two warnings and deleted the suppressions, but the unusedScopedObject warning wasn't obvious how to fix. Fix maybe-uninitialized warnings from gcc 13 Disable warnings from gcc 13 In gcc 12, any use of _ in Google Mock would generate a maybe-uninitialized warning, but now it generates an uninitialized warning, so I've changed over the cmake that disables those warnings. --- Framework/API/test/CMakeLists.txt | 2 +- Framework/Algorithms/src/FitPeaks.cpp | 5 +++++ Framework/Algorithms/src/SofQWCentre.cpp | 5 +++++ Framework/Algorithms/test/CMakeLists.txt | 2 +- .../test/CalculateCarpenterSampleCorrectionTest.h | 5 +++++ Framework/Algorithms/test/CarpenterSampleCorrectionTest.h | 5 +++++ Framework/Algorithms/test/FitPeaksTest.h | 3 +++ Framework/Algorithms/test/NormaliseToMonitorTest.h | 5 +++++ Framework/Crystal/test/CMakeLists.txt | 2 +- .../inc/MantidDataHandling/LoadANSTOEventFile.h | 4 ++-- Framework/DataObjects/src/Workspace2D.cpp | 2 +- Framework/DataObjects/test/CMakeLists.txt | 2 +- Framework/Geometry/test/CMakeLists.txt | 2 +- .../Kernel/inc/MantidKernel/EnumeratedStringProperty.hxx | 3 +-- Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc | 2 +- Framework/Kernel/test/ConfigPropertyObserverTest.h | 2 +- Framework/LiveData/test/CMakeLists.txt | 2 +- Framework/MDAlgorithms/test/CMakeLists.txt | 2 +- Framework/NexusGeometry/src/JSONGeometryParser.cpp | 2 +- Framework/NexusGeometry/test/CMakeLists.txt | 2 +- Framework/Parallel/src/IO/Chunker.cpp | 7 +++++++ .../inc/MantidPythonInterface/core/StlExportDefinitions.h | 3 +++ .../mantid/api/src/Exports/AlgorithmObserver.cpp | 3 +++ .../mantid/dataobjects/src/Exports/Workspace2D.cpp | 4 ++++ .../mantid/kernel/src/Exports/StlContainers.cpp | 3 +++ Framework/SINQ/test/CMakeLists.txt | 2 +- buildconfig/CMake/CppCheck_Suppressions.txt.in | 6 +----- buildconfig/CMake/QtTargetFunctions.cmake | 2 +- conda/recipes/conda_build_config.yaml | 4 ++-- .../v6.12.0/Framework/Dependencies/New_features/38336.rst | 1 + .../GUI/Experiment/ExperimentOptionDefaults.cpp | 2 +- qt/widgets/common/src/FitScriptGeneratorDataTable.cpp | 5 ++--- 32 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 docs/source/release/v6.12.0/Framework/Dependencies/New_features/38336.rst diff --git a/Framework/API/test/CMakeLists.txt b/Framework/API/test/CMakeLists.txt index 0c2aaff2974a..adad1beb0480 100644 --- a/Framework/API/test/CMakeLists.txt +++ b/Framework/API/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/Algorithms/src/FitPeaks.cpp b/Framework/Algorithms/src/FitPeaks.cpp index b6dcae2ed01d..dafe19d67b2d 100644 --- a/Framework/Algorithms/src/FitPeaks.cpp +++ b/Framework/Algorithms/src/FitPeaks.cpp @@ -34,6 +34,7 @@ #include "MantidKernel/ListValidator.h" #include "MantidKernel/StartsWithValidator.h" #include "MantidKernel/VectorHelper.h" +#include "MantidKernel/WarningSuppressions.h" #include "boost/algorithm/string.hpp" #include "boost/algorithm/string/trim.hpp" @@ -2118,6 +2119,8 @@ size_t FitPeaks::histRangeToDataPointCount(size_t iws, const std::pair &range, std::copy(orig_e.begin() + left_index, orig_e.begin() + left_index + num_datapoints, vec_e.begin()); } +GNU_DIAG_ON("dangling-reference") + //---------------------------------------------------------------------------------------------- /** Calculate signal-to-noise ratio in a histogram range * @param iws :: histogram index in workspace diff --git a/Framework/Algorithms/src/SofQWCentre.cpp b/Framework/Algorithms/src/SofQWCentre.cpp index 9c78752b4bc7..7e737a844b93 100644 --- a/Framework/Algorithms/src/SofQWCentre.cpp +++ b/Framework/Algorithms/src/SofQWCentre.cpp @@ -13,6 +13,7 @@ #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/PhysicalConstants.h" +#include "MantidKernel/WarningSuppressions.h" namespace Mantid::Algorithms { @@ -27,6 +28,8 @@ using namespace API; */ void SofQWCentre::init() { SofQW::createCommonInputProperties(*this); } +GNU_DIAG_OFF("dangling-reference") + void SofQWCentre::exec() { using namespace Geometry; using PhysicalConstants::E_mev_toNeutronWavenumberSq; @@ -150,6 +153,8 @@ void SofQWCentre::exec() { prog.report(); } + GNU_DIAG_ON("dangling-reference") + // If the input workspace was a distribution, need to divide by q bin width if (inputWorkspace->isDistribution()) this->makeDistribution(*outputWorkspace, verticalAxis); diff --git a/Framework/Algorithms/test/CMakeLists.txt b/Framework/Algorithms/test/CMakeLists.txt index 8be88ef62d67..b20be3f86136 100644 --- a/Framework/Algorithms/test/CMakeLists.txt +++ b/Framework/Algorithms/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/Algorithms/test/CalculateCarpenterSampleCorrectionTest.h b/Framework/Algorithms/test/CalculateCarpenterSampleCorrectionTest.h index 6c215f238794..cf439e471dcf 100644 --- a/Framework/Algorithms/test/CalculateCarpenterSampleCorrectionTest.h +++ b/Framework/Algorithms/test/CalculateCarpenterSampleCorrectionTest.h @@ -18,6 +18,7 @@ #include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h" #include "MantidHistogramData/LinearGenerator.h" #include "MantidIndexing/IndexInfo.h" +#include "MantidKernel/WarningSuppressions.h" using namespace Mantid; using namespace Mantid::API; @@ -189,6 +190,8 @@ class CalculateCarpenterSampleCorrectionTest : public CxxTest::TestSuite { AnalysisDataService::Instance().remove("TestOutputWS"); } + GNU_DIAG_OFF("dangling-reference") + void testCalculationEvent() { const std::string outName("CalculateCarpenterSampleCorrectionEventOutput"); @@ -255,6 +258,8 @@ class CalculateCarpenterSampleCorrectionTest : public CxxTest::TestSuite { AnalysisDataService::Instance().remove(outName); } + GNU_DIAG_ON("dangling-reference") + private: Mantid::Algorithms::CalculateCarpenterSampleCorrection algorithm; }; diff --git a/Framework/Algorithms/test/CarpenterSampleCorrectionTest.h b/Framework/Algorithms/test/CarpenterSampleCorrectionTest.h index 2b6a519739bf..eb75a38004ab 100644 --- a/Framework/Algorithms/test/CarpenterSampleCorrectionTest.h +++ b/Framework/Algorithms/test/CarpenterSampleCorrectionTest.h @@ -18,6 +18,7 @@ #include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h" #include "MantidHistogramData/LinearGenerator.h" #include "MantidIndexing/IndexInfo.h" +#include "MantidKernel/WarningSuppressions.h" using namespace Mantid; using namespace Mantid::API; @@ -64,6 +65,8 @@ class CarpenterSampleCorrectionTest : public CxxTest::TestSuite { TS_ASSERT(dynamic_cast *>(props[5])); } + GNU_DIAG_OFF("dangling-reference") + void testCalculationHist() { using namespace Mantid::HistogramData; auto wksp = DataObjects::create( @@ -154,6 +157,8 @@ class CarpenterSampleCorrectionTest : public CxxTest::TestSuite { TS_ASSERT_LESS_THAN(y_actual[i], 6.66480); } + GNU_DIAG_ON("dangling-reference") + // cleanup AnalysisDataService::Instance().remove(outName); } diff --git a/Framework/Algorithms/test/FitPeaksTest.h b/Framework/Algorithms/test/FitPeaksTest.h index 846f376ed27d..ccd13412e2ac 100644 --- a/Framework/Algorithms/test/FitPeaksTest.h +++ b/Framework/Algorithms/test/FitPeaksTest.h @@ -20,6 +20,7 @@ #include "MantidFrameworkTestHelpers/WorkspaceCreationHelper.h" #include "MantidKernel/Logger.h" #include "MantidKernel/UnitFactory.h" +#include "MantidKernel/WarningSuppressions.h" using Mantid::Algorithms::FitPeaks; @@ -34,6 +35,8 @@ using Mantid::HistogramData::Counts; using Mantid::HistogramData::CountStandardDeviations; using Mantid::HistogramData::Points; +GNU_DIAG_OFF("dangling-reference") + namespace { /// static Logger definition Logger g_log("FitPeaksTest"); diff --git a/Framework/Algorithms/test/NormaliseToMonitorTest.h b/Framework/Algorithms/test/NormaliseToMonitorTest.h index f29bb6783754..36e2e30c3cce 100644 --- a/Framework/Algorithms/test/NormaliseToMonitorTest.h +++ b/Framework/Algorithms/test/NormaliseToMonitorTest.h @@ -20,6 +20,7 @@ #include "MantidHistogramData/LinearGenerator.h" #include "MantidIndexing/IndexInfo.h" #include "MantidKernel/UnitFactory.h" +#include "MantidKernel/WarningSuppressions.h" using namespace Mantid; using namespace Mantid::Kernel; @@ -404,6 +405,8 @@ class NormaliseToMonitorTest : public CxxTest::TestSuite { TS_ASSERT(alg.isExecuted()) } + GNU_DIAG_OFF("dangling-reference") + void test_with_scanning_workspace_bin_by_bin() { auto testWS = makeTestDetectorScanWorkspace(); @@ -504,6 +507,8 @@ class NormaliseToMonitorTest : public CxxTest::TestSuite { } } + GNU_DIAG_ON("dangling-reference") + private: MatrixWorkspace_sptr makeTestDetectorScanWorkspace() { const size_t N_DET = 10; diff --git a/Framework/Crystal/test/CMakeLists.txt b/Framework/Crystal/test/CMakeLists.txt index aa62ba0edde6..484545905d72 100644 --- a/Framework/Crystal/test/CMakeLists.txt +++ b/Framework/Crystal/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOEventFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOEventFile.h index e5a76d708be6..9ae4bf14328e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOEventFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOEventFile.h @@ -155,8 +155,8 @@ void ReadEventFile(IReader &loader, IEventHandler &handler, IProgress &progress, // total frame duration, and this can be used to recover the absolute // timestamp of all events in the DAQ, if desired (e.g. for accurate timing // during long term kinematic experiments). - int32_t dt; // , t = 0 dt may be negative occasionally for some DAE types, - // therefore dt and t are signed ints. + int32_t dt = 0; // , t = 0 dt may be negative occasionally for some DAE types, + // therefore dt and t are signed ints. int32_t nbits_val_oob[NVAL] = {}; diff --git a/Framework/DataObjects/src/Workspace2D.cpp b/Framework/DataObjects/src/Workspace2D.cpp index cc83f836c928..9548becf83bb 100644 --- a/Framework/DataObjects/src/Workspace2D.cpp +++ b/Framework/DataObjects/src/Workspace2D.cpp @@ -88,7 +88,7 @@ void Workspace2D::init(const HistogramData::Histogram &histogram) { Histogram1D spec(initializedHistogram.xMode(), initializedHistogram.yMode()); spec.setHistogram(initializedHistogram); std::transform(data.begin(), data.end(), data.begin(), - [&spec](const auto &) { return std::move(std::make_unique(spec)); }); + [&spec](const auto &) { return std::make_unique(spec); }); // Add axes that reference the data m_axes.resize(2); diff --git a/Framework/DataObjects/test/CMakeLists.txt b/Framework/DataObjects/test/CMakeLists.txt index 4fadb455a0c9..66f67fa91e6c 100644 --- a/Framework/DataObjects/test/CMakeLists.txt +++ b/Framework/DataObjects/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/Geometry/test/CMakeLists.txt b/Framework/Geometry/test/CMakeLists.txt index e1197f1ffd4c..6056f3046b14 100644 --- a/Framework/Geometry/test/CMakeLists.txt +++ b/Framework/Geometry/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/Kernel/inc/MantidKernel/EnumeratedStringProperty.hxx b/Framework/Kernel/inc/MantidKernel/EnumeratedStringProperty.hxx index 38d01033a3e0..f2067e8ef72a 100644 --- a/Framework/Kernel/inc/MantidKernel/EnumeratedStringProperty.hxx +++ b/Framework/Kernel/inc/MantidKernel/EnumeratedStringProperty.hxx @@ -29,8 +29,7 @@ namespace Mantid::Kernel { template const *const names> EnumeratedStringProperty::EnumeratedStringProperty(std::string const &name, ENUMSTRING const &defaultValue, Direction::Type const direction) - : Property(std::move(name), typeid(ENUMSTRING), direction), m_value(defaultValue), - m_initialValue(std::move(defaultValue)) {} + : Property(name, typeid(ENUMSTRING), direction), m_value(defaultValue), m_initialValue(std::move(defaultValue)) {} /** Copy Constructor * @param right :: a copy diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc index d6e94c1faeb3..5f08fc4ff709 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc @@ -76,7 +76,7 @@ template PropertyWithValue::PropertyWithValue(const std::string &name, TYPE defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, unsigned int direction) - : Property(std::move(name), typeid(TYPE), direction), m_value(extractToValueVector(defaultValueStr)), + : Property(name, typeid(TYPE), direction), m_value(extractToValueVector(defaultValueStr)), m_initialValue(m_value), m_validator(std::move(validator)) { UNUSED_ARG(defaultValue); } diff --git a/Framework/Kernel/test/ConfigPropertyObserverTest.h b/Framework/Kernel/test/ConfigPropertyObserverTest.h index 2ca2bf204fe1..5640aa50180e 100644 --- a/Framework/Kernel/test/ConfigPropertyObserverTest.h +++ b/Framework/Kernel/test/ConfigPropertyObserverTest.h @@ -16,7 +16,7 @@ using namespace Mantid::Kernel; template class MockObserver : ConfigPropertyObserver { public: MockObserver(const std::string &propertyName, Callback callback) - : ConfigPropertyObserver(std::move(propertyName)), m_callback(callback) {} + : ConfigPropertyObserver(propertyName), m_callback(callback) {} protected: void onPropertyValueChanged(const std::string &newValue, const std::string &prevValue) override { diff --git a/Framework/LiveData/test/CMakeLists.txt b/Framework/LiveData/test/CMakeLists.txt index 7a93debfaf35..478fc4a0e8d3 100644 --- a/Framework/LiveData/test/CMakeLists.txt +++ b/Framework/LiveData/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/MDAlgorithms/test/CMakeLists.txt b/Framework/MDAlgorithms/test/CMakeLists.txt index e0be02aef2e4..5b8435f16c27 100644 --- a/Framework/MDAlgorithms/test/CMakeLists.txt +++ b/Framework/MDAlgorithms/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/NexusGeometry/src/JSONGeometryParser.cpp b/Framework/NexusGeometry/src/JSONGeometryParser.cpp index 42d685aa8060..5fc08bf9dbf3 100644 --- a/Framework/NexusGeometry/src/JSONGeometryParser.cpp +++ b/Framework/NexusGeometry/src/JSONGeometryParser.cpp @@ -272,7 +272,7 @@ std::string extractInstrumentName(const Json::Value &instrument) { std::vector> moveToUniquePtrVec(std::vector &jsonVector) { std::vector> ret; std::transform(jsonVector.cbegin(), jsonVector.cend(), std::back_inserter(ret), - [](const auto &val) { return std::move(std::make_unique(std::move(val))); }); + [](const auto &val) { return std::make_unique(std::move(val)); }); return ret; } diff --git a/Framework/NexusGeometry/test/CMakeLists.txt b/Framework/NexusGeometry/test/CMakeLists.txt index f64f313d9643..a075e418e261 100644 --- a/Framework/NexusGeometry/test/CMakeLists.txt +++ b/Framework/NexusGeometry/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/Framework/Parallel/src/IO/Chunker.cpp b/Framework/Parallel/src/IO/Chunker.cpp index 5127a10c28f6..409a1c36daed 100644 --- a/Framework/Parallel/src/IO/Chunker.cpp +++ b/Framework/Parallel/src/IO/Chunker.cpp @@ -5,8 +5,10 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include +#include #include #include +#include #include #include @@ -124,6 +126,11 @@ std::vector Chunker::makeLoadRanges() const { break; firstWorkerSharingOurPartition += workersInPartition; } + + if (partitionIndex >= m_partitioning.size()) { + throw std::runtime_error("No workers sharing the partition"); + } + const auto workersSharingOurPartition = m_partitioning[partitionIndex].first; const auto &ourBanks = m_partitioning[partitionIndex].second; diff --git a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/StlExportDefinitions.h b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/StlExportDefinitions.h index 04c0719cd504..d80fa0561550 100644 --- a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/StlExportDefinitions.h +++ b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/StlExportDefinitions.h @@ -8,6 +8,9 @@ /** This file contains the export definitions for various stl containers. */ +#include "MantidKernel/WarningSuppressions.h" +GNU_DIAG_OFF("maybe-uninitialized") + #include #include #ifdef _MSC_VER diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp index 532bf723828c..9ddfcffa3567 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp @@ -4,6 +4,7 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include "MantidKernel/WarningSuppressions.h" #include "MantidPythonInterface/api/Algorithms/AlgorithmObserverAdapter.h" #include "MantidPythonInterface/core/GetPointer.h" @@ -14,6 +15,8 @@ using namespace Mantid::API; using namespace Mantid::PythonInterface; using namespace boost::python; +GNU_DIAG_OFF("dangling-reference") + void observeFinish(AlgorithmObserver &self, const boost::python::object &alg) { const IAlgorithm_sptr &calg = boost::python::extract(alg); self.observeFinish(calg); diff --git a/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp b/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp index 9754806c8b9a..0c510a15ec93 100644 --- a/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp +++ b/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp @@ -17,6 +17,7 @@ #include "MantidKernel/Logger.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/Unit.h" +#include "MantidKernel/WarningSuppressions.h" #include "MantidPythonInterface/api/RegisterWorkspacePtrToPython.h" #include "MantidPythonInterface/core/Converters/CloneToNDArray.h" #include "MantidPythonInterface/core/Converters/NDArrayToVector.h" @@ -42,6 +43,7 @@ GET_POINTER_SPECIALIZATION(Workspace2D) class Workspace2DPickleSuite : public boost::python::pickle_suite { public: + GNU_DIAG_OFF("dangling-reference") static dict getstate(const Workspace2D &ws) { using namespace Mantid::PythonInterface::Converters; @@ -98,6 +100,8 @@ class Workspace2DPickleSuite : public boost::python::pickle_suite { return state; } + GNU_DIAG_ON("dangling-reference") + static void setstate(Workspace2D &ws, dict state) { using namespace Mantid::PythonInterface::Converters; diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp index a13377e42c28..062655f60351 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp @@ -9,6 +9,9 @@ #include "MantidKernel/DateAndTime.h" #include "MantidKernel/Quat.h" #include "MantidKernel/V3D.h" +#include "MantidKernel/WarningSuppressions.h" + +GNU_DIAG_OFF("maybe-uninitialized") using Mantid::PythonInterface::std_set_exporter; using Mantid::PythonInterface::std_vector_exporter; diff --git a/Framework/SINQ/test/CMakeLists.txt b/Framework/SINQ/test/CMakeLists.txt index f1aedd6f0ff8..a4c27dd55b05 100644 --- a/Framework/SINQ/test/CMakeLists.txt +++ b/Framework/SINQ/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Wno-maybe-uninitialized) + add_compile_options(-Wno-uninitialized) endif() if(CXXTEST_FOUND) diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index 52481dbe1bb5..d855768de276 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -94,8 +94,6 @@ constParameterPointer:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/TopicInfo.cpp:38 returnStdMoveLocal:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/FilteredTimeSeriesProperty.cpp:408 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/PropertyManagerProperty.cpp:149 returnByReference:${CMAKE_SOURCE_DIR}/Framework/Kernel/inc/MantidKernel/UsageService.h:63 -containerOutOfBounds:${CMAKE_SOURCE_DIR}/Framework/Parallel/src/IO/Chunker.cpp:127 -containerOutOfBounds:${CMAKE_SOURCE_DIR}/Framework/Parallel/src/IO/Chunker.cpp:128 returnStdMoveLocal:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/LogParser.cpp:256 missingOverride:${CMAKE_SOURCE_DIR}/Framework/Parallel/inc/MantidParallel/IO/EventsListsShmemStorage.h:32 returnByReference:${CMAKE_SOURCE_DIR}/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h:133 @@ -1017,9 +1015,7 @@ passedByValue:${CMAKE_SOURCE_DIR}/Framework/TestHelpers/src/ComponentCreationHel unreadVariable:${CMAKE_SOURCE_DIR}/Framework/TestHelpers/src/ComponentCreationHelper.cpp:412 unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/dataobjects/src/Exports/OffsetsWorkspace.cpp:23 unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/dataobjects/src/Exports/GroupingWorkspace.cpp:42 -unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp:173 -constParameterReference:${CMAKE_SOURCE_DIR}/Framework/Reflectometry/src/FindReflectometryLines2.cpp:213 -constParameterReference:${CMAKE_SOURCE_DIR}/Framework/Reflectometry/src/FindReflectometryLines2.cpp:235 +unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp:177 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Reflectometry/src/CreateTransmissionWorkspace2.cpp:176 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Reflectometry/src/CreateTransmissionWorkspace2.cpp:177 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Reflectometry/src/CreateTransmissionWorkspace2.cpp:178 diff --git a/buildconfig/CMake/QtTargetFunctions.cmake b/buildconfig/CMake/QtTargetFunctions.cmake index b77dddf935e7..5163b093cc9a 100644 --- a/buildconfig/CMake/QtTargetFunctions.cmake +++ b/buildconfig/CMake/QtTargetFunctions.cmake @@ -304,7 +304,7 @@ function(mtd_add_qt_test_executable) target_link_libraries(${_target_name} LINK_PRIVATE ${LINK_LIBS} ${_link_libs} ${_mtd_qt_libs}) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(${_target_name} PRIVATE -Wno-maybe-uninitialized) + target_compile_options(${_target_name} PRIVATE -Wno-uninitialized) endif() # Add dependency to any parents diff --git a/conda/recipes/conda_build_config.yaml b/conda/recipes/conda_build_config.yaml index 6a87355fd9b9..010978684f89 100644 --- a/conda/recipes/conda_build_config.yaml +++ b/conda/recipes/conda_build_config.yaml @@ -6,14 +6,14 @@ c_compiler: - vs2019 # [win] c_compiler_version: # [unix] - 16 # [osx] - - 12 # [linux] + - 13 # [linux] cxx_compiler: - gxx # [linux] - clangxx # [osx] - vs2019 # [win] cxx_compiler_version: # [unix] - 16 # [osx] - - 12 # [linux] + - 13 # [linux] llvm_openmp: # [osx] - 16 # [osx] diff --git a/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38336.rst b/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38336.rst new file mode 100644 index 000000000000..f9a5f3a8c884 --- /dev/null +++ b/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38336.rst @@ -0,0 +1 @@ +- Updated compiler on Linux to gcc version 13, which should improve performance in some circumstances. The release notes can be found here https://gcc.gnu.org/gcc-13/changes.html diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp index 887782e6c314..942558380960 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp @@ -111,7 +111,7 @@ Experiment getExperimentDefaults(Mantid::Geometry::Instrument_const_sptr instrum return Experiment(analysisMode, reductionType, summationType, includePartialBins, debug, backgroundSubtraction, polarizationCorrections, std::move(floodCorrections), std::move(transmissionStitchOptions), - std::move(stitchParameters), lookupTableValidationResult.assertValid()); + stitchParameters, lookupTableValidationResult.assertValid()); } } // unnamed namespace diff --git a/qt/widgets/common/src/FitScriptGeneratorDataTable.cpp b/qt/widgets/common/src/FitScriptGeneratorDataTable.cpp index bcb6a1adc760..e70933ed06b2 100644 --- a/qt/widgets/common/src/FitScriptGeneratorDataTable.cpp +++ b/qt/widgets/common/src/FitScriptGeneratorDataTable.cpp @@ -198,9 +198,8 @@ std::vector FitScriptGeneratorDataTable::selectedRows() const { auto const selectionModel = this->selectionModel(); if (selectionModel->hasSelection()) { const auto rows = selectionModel->selectedRows(); - std::transform(rows.cbegin(), rows.cend(), std::back_inserter(rowIndices), [](const auto &rowIndex) { - return std::move(FitDomainIndex(static_cast(rowIndex.row()))); - }); + std::transform(rows.cbegin(), rows.cend(), std::back_inserter(rowIndices), + [](const auto &rowIndex) { return FitDomainIndex(static_cast(rowIndex.row())); }); std::reverse(rowIndices.begin(), rowIndices.end()); } return rowIndices; From 2ee4f8f0f00d0adc193c7e4f2d03bb65a1000d8d Mon Sep 17 00:00:00 2001 From: James Clarke Date: Fri, 27 Sep 2024 12:00:44 +0100 Subject: [PATCH 04/17] Coverity fixes This is a squashed version of #38100 Fix accummulate blunder from 5 years ago See 6b99e159f8489fb58279418aaa7c15006506f5cd for where the old code was broken in a refactor. Added release note Fix cppcheck warnings about const parameters Use new method for type checking a cast Instead of using the same code everywhere to check that a cast is not null, use a new generic method that can do this. Add tests for new DynamicPointerCastHelper method Remove unnecessary __declspec on method On Windows with msbuild you cannot define the function implementation with a __declspec, but it works fine with Clang and gcc. Use helper method to check for null cast --- Framework/Beamline/src/ComponentInfo.cpp | 2 +- Framework/Crystal/src/SCDPanelErrors.cpp | 17 ++++---- .../DataHandling/src/LoadILLReflectometry.cpp | 8 ++-- .../inc/MantidDataObjects/EventList.h | 2 +- Framework/DataObjects/src/EventList.cpp | 2 +- Framework/DataObjects/src/TableWorkspace.cpp | 2 +- Framework/Kernel/CMakeLists.txt | 2 + .../MantidKernel/DynamicPointerCastHelper.h | 32 ++++++++++++++ .../test/DynamicPointerCastHelperTest.h | 42 +++++++++++++++++++ Framework/Muon/src/CalculateMuonAsymmetry.cpp | 38 +++++++++-------- .../ConvertFitFunctionForMuonTFAsymmetry.cpp | 7 +++- .../FindReflectometryLines2.h | 6 +-- .../src/FindReflectometryLines2.cpp | 13 +++--- Framework/WorkflowAlgorithms/src/StepScan.cpp | 3 +- .../Framework/Data_Objects/Bugfixes/38100.rst | 1 + 15 files changed, 132 insertions(+), 45 deletions(-) create mode 100644 Framework/Kernel/inc/MantidKernel/DynamicPointerCastHelper.h create mode 100644 Framework/Kernel/test/DynamicPointerCastHelperTest.h create mode 100644 docs/source/release/v6.12.0/Framework/Data_Objects/Bugfixes/38100.rst diff --git a/Framework/Beamline/src/ComponentInfo.cpp b/Framework/Beamline/src/ComponentInfo.cpp index 0441ff9c67e3..17bef1276ba5 100644 --- a/Framework/Beamline/src/ComponentInfo.cpp +++ b/Framework/Beamline/src/ComponentInfo.cpp @@ -314,7 +314,7 @@ void ComponentInfo::doScaleComponent(const std::pair &index, con const size_t offsetIndex = compOffsetIndex(subIndex); Eigen::Vector3d oldPos = position({subIndex, timeIndex}); Eigen::Vector3d newPos = scalingMatrix * oldPos + (Eigen::Matrix3d::Identity() - scalingMatrix) * compPos; - m_positions.access()[linearIndex({offsetIndex, timeIndex})] = newPos; + m_positions.access()[linearIndex({offsetIndex, timeIndex})] = std::move(newPos); } } diff --git a/Framework/Crystal/src/SCDPanelErrors.cpp b/Framework/Crystal/src/SCDPanelErrors.cpp index 4d30afb8a0e2..fbdf9838bbe7 100644 --- a/Framework/Crystal/src/SCDPanelErrors.cpp +++ b/Framework/Crystal/src/SCDPanelErrors.cpp @@ -17,6 +17,7 @@ #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Component.h" #include "MantidGeometry/Instrument/RectangularDetector.h" +#include "MantidKernel/DynamicPointerCastHelper.h" #include "MantidKernel/FileValidator.h" #include #include @@ -76,7 +77,9 @@ void SCDPanelErrors::moveDetector(double x, double y, double z, double rotx, dou if (detname.compare("none") == 0.0) return; // CORELLI has sixteenpack under bank - DataObjects::PeaksWorkspace_sptr inputP = std::dynamic_pointer_cast(inputW); + DataObjects::PeaksWorkspace_sptr inputP = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( + inputW); Geometry::Instrument_sptr inst = std::const_pointer_cast(inputP->getInstrument()); if (inst->getName().compare("CORELLI") == 0.0 && detname != "moderator") detname.append("/sixteenpack"); @@ -175,15 +178,9 @@ void SCDPanelErrors::eval(double xshift, double yshift, double zshift, double xr std::shared_ptr cloned = m_workspace->clone(); moveDetector(xshift, yshift, zshift, xrotate, yrotate, zrotate, scalex, scaley, m_bank, cloned); - auto inputP = std::dynamic_pointer_cast(cloned); - // IAlgorithm_sptr alg = - // Mantid::API::AlgorithmFactory::Instance().create("IndexPeaks", -1); - // alg->initialize(); - // alg->setChild(true); - // alg->setLogging(false); - // alg->setProperty("PeaksWorkspace", inputP); - // alg->setProperty("Tolerance", 0.15); - // alg->execute(); + auto inputP = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( + cloned); auto inst = inputP->getInstrument(); Geometry::OrientedLattice lattice = inputP->mutableSample().getOrientedLattice(); for (int i = 0; i < inputP->getNumberPeaks(); i++) { diff --git a/Framework/DataHandling/src/LoadILLReflectometry.cpp b/Framework/DataHandling/src/LoadILLReflectometry.cpp index 294bd24b9bdd..1429c6d3b93b 100644 --- a/Framework/DataHandling/src/LoadILLReflectometry.cpp +++ b/Framework/DataHandling/src/LoadILLReflectometry.cpp @@ -5,7 +5,6 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "MantidDataHandling/LoadILLReflectometry.h" - #include "MantidAPI/Axis.h" #include "MantidAPI/CompositeFunction.h" #include "MantidAPI/FileProperty.h" @@ -23,6 +22,7 @@ #include "MantidGeometry/Instrument/RectangularDetector.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/DeltaEMode.h" +#include "MantidKernel/DynamicPointerCastHelper.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/PropertyManagerProperty.h" #include "MantidKernel/Quat.h" @@ -585,9 +585,11 @@ double LoadILLReflectometry::reflectometryPeak() { const auto fwhm = static_cast(std::distance(revMaxFwhmIt, revMinFwhmIt) + 1); // generate Gaussian auto func = API::FunctionFactory::Instance().createFunction("CompositeFunction"); - auto sum = std::dynamic_pointer_cast(func); + auto sum = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(func); func = API::FunctionFactory::Instance().createFunction("Gaussian"); - auto gaussian = std::dynamic_pointer_cast(func); + auto gaussian = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(func); gaussian->setHeight(height); gaussian->setCentre(centreByMax); gaussian->setFwhm(fwhm); diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventList.h b/Framework/DataObjects/inc/MantidDataObjects/EventList.h index 272d76c61ea6..20c9c9a68273 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventList.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventList.h @@ -205,7 +205,7 @@ class MANTID_DATAOBJECTS_DLL EventList : public Mantid::API::IEventList { void compressEvents(double tolerance, EventList *destination); void compressEvents(double tolerance, EventList *destination, - std::shared_ptr> histogram_bin_edges); + const std::shared_ptr> histogram_bin_edges); void compressFatEvents(const double tolerance, const Types::Core::DateAndTime &timeStart, const double seconds, EventList *destination); // get EventType declaration diff --git a/Framework/DataObjects/src/EventList.cpp b/Framework/DataObjects/src/EventList.cpp index c9e0662c9a43..229e3732618d 100644 --- a/Framework/DataObjects/src/EventList.cpp +++ b/Framework/DataObjects/src/EventList.cpp @@ -1927,7 +1927,7 @@ inline void EventList::processWeightedEvents(const std::vector &events, std:: } void EventList::compressEvents(double tolerance, EventList *destination, - std::shared_ptr> histogram_bin_edges) { + const std::shared_ptr> histogram_bin_edges) { if (this->empty()) { // allocate memory in correct vector if (eventType != WEIGHTED_NOTIME) diff --git a/Framework/DataObjects/src/TableWorkspace.cpp b/Framework/DataObjects/src/TableWorkspace.cpp index ab794f23b57a..02c1306c20f5 100644 --- a/Framework/DataObjects/src/TableWorkspace.cpp +++ b/Framework/DataObjects/src/TableWorkspace.cpp @@ -47,7 +47,7 @@ TableWorkspace::TableWorkspace(const TableWorkspace &other) size_t TableWorkspace::getMemorySize() const { size_t data_size = std::accumulate(m_columns.cbegin(), m_columns.cend(), static_cast(0), - [](size_t sum, const auto &column) { return sum = column->sizeOfData(); }); + [](size_t sum, const auto &column) { return sum + column->sizeOfData(); }); data_size += m_LogManager->getMemorySize(); return data_size; } diff --git a/Framework/Kernel/CMakeLists.txt b/Framework/Kernel/CMakeLists.txt index b99204db7405..8791c80a219c 100644 --- a/Framework/Kernel/CMakeLists.txt +++ b/Framework/Kernel/CMakeLists.txt @@ -166,6 +166,7 @@ set(INC_FILES inc/MantidKernel/DllOpen.h inc/MantidKernel/DocumentationHeader.h inc/MantidKernel/DynamicFactory.h + inc/MantidKernel/DynamicPointerCastHelper.h inc/MantidKernel/EigenConversionHelpers.h inc/MantidKernel/EmptyValues.h inc/MantidKernel/EnabledWhenProperty.h @@ -337,6 +338,7 @@ set(TEST_FILES DiskBufferTest.h DllOpenTest.h DynamicFactoryTest.h + DynamicPointerCastHelperTest.h EigenConversionHelpersTest.h EnabledWhenPropertyTest.h EnumeratedStringTest.h diff --git a/Framework/Kernel/inc/MantidKernel/DynamicPointerCastHelper.h b/Framework/Kernel/inc/MantidKernel/DynamicPointerCastHelper.h new file mode 100644 index 000000000000..f7f989cce128 --- /dev/null +++ b/Framework/Kernel/inc/MantidKernel/DynamicPointerCastHelper.h @@ -0,0 +1,32 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source, +// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include +#include + +namespace Mantid { +namespace Kernel { +namespace DynamicPointerCastHelper { + +/* +Will cast a shared_ptr of type U to one of type T using std::dynamic_pointer_cast. If the cast +is invalid then it will throw an exception. This is useful for avoiding warnings about +potential null objects coming out of std::dynamic_pointer_cast. +*/ +template +std::shared_ptr dynamicPointerCastWithCheck(std::shared_ptr sharedPtr, const std::string &error = "") { + auto result = std::dynamic_pointer_cast(sharedPtr); + if (result == nullptr) { + throw std::invalid_argument(error.empty() ? "Invalid cast" : error); + } + return result; +} + +} // namespace DynamicPointerCastHelper +} // namespace Kernel +} // namespace Mantid diff --git a/Framework/Kernel/test/DynamicPointerCastHelperTest.h b/Framework/Kernel/test/DynamicPointerCastHelperTest.h new file mode 100644 index 000000000000..5aecd4bef698 --- /dev/null +++ b/Framework/Kernel/test/DynamicPointerCastHelperTest.h @@ -0,0 +1,42 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source, +// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "MantidKernel/DynamicPointerCastHelper.h" + +#include + +#include + +using namespace Mantid::Kernel::DynamicPointerCastHelper; + +class DynamicPointerCastHelperTest : public CxxTest::TestSuite { + +public: + void test_correctCast() { + auto derivedClass = std::make_shared(); + std::shared_ptr baseClass = + dynamicPointerCastWithCheck(derivedClass); + } + + void test_incorrectCast() { + const auto errorString = "Oops"; + std::shared_ptr nullDerivedPtr; + TS_ASSERT_THROWS_EQUALS(convertDerivedToBaseClass(nullDerivedPtr, errorString), const std::invalid_argument &e, + std::string(e.what()), errorString); + } + + class EmptyBaseClass {}; + + class EmptyDerivedClass : public EmptyBaseClass {}; + +private: + std::shared_ptr convertDerivedToBaseClass(std::shared_ptr derived, + const std::string &errorMsg = "") { + return dynamicPointerCastWithCheck(derived, errorMsg); + } +}; diff --git a/Framework/Muon/src/CalculateMuonAsymmetry.cpp b/Framework/Muon/src/CalculateMuonAsymmetry.cpp index 38f99b4a1822..f691c9bb79ca 100644 --- a/Framework/Muon/src/CalculateMuonAsymmetry.cpp +++ b/Framework/Muon/src/CalculateMuonAsymmetry.cpp @@ -9,6 +9,7 @@ //---------------------------------------------------------------------- #include "MantidMuon/CalculateMuonAsymmetry.h" +#include "MantidKernel/DynamicPointerCastHelper.h" #include "MantidMuon/MuonAsymmetryHelper.h" #include "MantidAPI/ADSValidator.h" @@ -115,7 +116,9 @@ std::map CalculateMuonAsymmetry::validateInputs() { } API::IFunction_sptr tmp = getProperty("InputFunction"); auto function = std::dynamic_pointer_cast(tmp); - if (function->getNumberDomains() != normWS.size()) { + if (function == nullptr) { + validationOutput["InputFunction"] = "The fitting function is not the correct type"; + } else if (function->getNumberDomains() != normWS.size()) { validationOutput["InputFunction"] = "The Fitting function does not have " "the same number of domains as the " "number of domains to fit."; @@ -350,25 +353,26 @@ std::vector CalculateMuonAsymmetry::getNormConstants(const std::vector( + tmp, wrongFunctionFormError); + norms.emplace_back(getNormValue(TFFunc)); + } else { + auto result = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( + tmp, wrongFunctionFormError); + for (size_t j = 0; j < wsNames.size(); j++) { + // get domain + auto TFFunc = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( + result->getFunction(j), wrongFunctionFormError); // N(1+g) + exp - auto TFFunc = std::dynamic_pointer_cast(tmp); norms.emplace_back(getNormValue(TFFunc)); - } else { - auto result = std::dynamic_pointer_cast(tmp); - for (size_t j = 0; j < wsNames.size(); j++) { - // get domain - auto TFFunc = std::dynamic_pointer_cast(result->getFunction(j)); - // N(1+g) + exp - TFFunc = std::dynamic_pointer_cast(TFFunc); - norms.emplace_back(getNormValue(TFFunc)); - } } - } catch (...) { - throw std::invalid_argument("The fitting function is not of the expected " - "form. Try using " - "ConvertFitFunctionForMuonTFAsymmetry"); } return norms; } diff --git a/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp b/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp index 8e9ec9fef836..af1204055e26 100644 --- a/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp +++ b/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp @@ -23,6 +23,7 @@ #include "MantidAPI/AnalysisDataService.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/CompositeValidator.h" +#include "MantidKernel/DynamicPointerCastHelper.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/PhysicalConstants.h" @@ -193,7 +194,8 @@ void ConvertFitFunctionForMuonTFAsymmetry::setOutput(const Mantid::API::IFunctio const std::vector wsNames = getProperty("WorkspaceList"); if (wsNames.size() == 1) { // if single domain func, strip off multi domain - auto TFFunc = std::dynamic_pointer_cast(function); + auto TFFunc = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(function); outputFitFunction = TFFunc->getFunction(0); } setProperty("OutputFunction", outputFitFunction); @@ -211,8 +213,9 @@ ConvertFitFunctionForMuonTFAsymmetry::extractFromTFAsymmFitFunction(const Mantid IFunction_sptr tmp = original; size_t numDomains = original->getNumberDomains(); + auto TFFunc = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(original); for (size_t j = 0; j < numDomains; j++) { - auto TFFunc = std::dynamic_pointer_cast(original); if (numDomains > 1) { // get correct domain tmp = TFFunc->getFunction(j); diff --git a/Framework/Reflectometry/inc/MantidReflectometry/FindReflectometryLines2.h b/Framework/Reflectometry/inc/MantidReflectometry/FindReflectometryLines2.h index 2ac75ba562bd..0c447aef36ae 100644 --- a/Framework/Reflectometry/inc/MantidReflectometry/FindReflectometryLines2.h +++ b/Framework/Reflectometry/inc/MantidReflectometry/FindReflectometryLines2.h @@ -26,9 +26,9 @@ class MANTID_REFLECTOMETRY_DLL FindReflectometryLines2 final : public API::Algor void init() override; std::map validateInputs() override; void exec() override; - double findPeak(API::MatrixWorkspace_sptr &ws); - API::MatrixWorkspace_sptr integrate(API::MatrixWorkspace_sptr &ws); - API::MatrixWorkspace_sptr transpose(API::MatrixWorkspace_sptr &ws); + double findPeak(const API::MatrixWorkspace_sptr &ws); + API::MatrixWorkspace_sptr integrate(const API::MatrixWorkspace_sptr &ws); + API::MatrixWorkspace_sptr transpose(const API::MatrixWorkspace_sptr &ws); }; } // namespace Reflectometry diff --git a/Framework/Reflectometry/src/FindReflectometryLines2.cpp b/Framework/Reflectometry/src/FindReflectometryLines2.cpp index 80e27ad408be..b7385c6f5630 100644 --- a/Framework/Reflectometry/src/FindReflectometryLines2.cpp +++ b/Framework/Reflectometry/src/FindReflectometryLines2.cpp @@ -13,6 +13,7 @@ #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidDataObjects/WorkspaceSingleValue.h" #include "MantidKernel/BoundedValidator.h" +#include "MantidKernel/DynamicPointerCastHelper.h" #include "MantidKernel/Statistics.h" namespace { @@ -142,7 +143,7 @@ void FindReflectometryLines2::exec() { * @return fractional workspace index of the peak: Gaussian fit and position * of the maximum */ -double FindReflectometryLines2::findPeak(API::MatrixWorkspace_sptr &ws) { +double FindReflectometryLines2::findPeak(const API::MatrixWorkspace_sptr &ws) { auto integralWS = integrate(ws); // integralWS may be ragged due to different integration limits for each // histogram. We don't really care but Transpose does. @@ -176,9 +177,11 @@ double FindReflectometryLines2::findPeak(API::MatrixWorkspace_sptr &ws) { auto const fwhm = static_cast(std::distance(revMaxFwhmIt, revMinFwhmIt) + 1); g_log.debug() << "Initial fwhm (full width at half maximum): " << fwhm << '\n'; auto func = API::FunctionFactory::Instance().createFunction("CompositeFunction"); - auto sum = std::dynamic_pointer_cast(func); + auto sum = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(func); func = API::FunctionFactory::Instance().createFunction("Gaussian"); - auto gaussian = std::dynamic_pointer_cast(func); + auto gaussian = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(func); gaussian->setHeight(height); gaussian->setCentre(centreIndex); gaussian->setFwhm(fwhm); @@ -210,7 +213,7 @@ double FindReflectometryLines2::findPeak(API::MatrixWorkspace_sptr &ws) { * @param ws a workspace to integrate * @return a workspace containing the integrals */ -API::MatrixWorkspace_sptr FindReflectometryLines2::integrate(API::MatrixWorkspace_sptr &ws) { +API::MatrixWorkspace_sptr FindReflectometryLines2::integrate(const API::MatrixWorkspace_sptr &ws) { int const startIndex = getProperty(Prop::START_INDEX); int const endIndex = getProperty(Prop::END_INDEX); double const startX = getProperty(Prop::RANGE_LOWER); @@ -232,7 +235,7 @@ API::MatrixWorkspace_sptr FindReflectometryLines2::integrate(API::MatrixWorkspac * @param ws a workspace to transpos * @return a transposed workspace */ -API::MatrixWorkspace_sptr FindReflectometryLines2::transpose(API::MatrixWorkspace_sptr &ws) { +API::MatrixWorkspace_sptr FindReflectometryLines2::transpose(const API::MatrixWorkspace_sptr &ws) { auto transpose = createChildAlgorithm("Transpose"); transpose->initialize(); transpose->setProperty("InputWorkspace", ws); diff --git a/Framework/WorkflowAlgorithms/src/StepScan.cpp b/Framework/WorkflowAlgorithms/src/StepScan.cpp index 98c768f33466..686d452a0b38 100644 --- a/Framework/WorkflowAlgorithms/src/StepScan.cpp +++ b/Framework/WorkflowAlgorithms/src/StepScan.cpp @@ -7,6 +7,7 @@ #include "MantidWorkflowAlgorithms/StepScan.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidKernel/DynamicPointerCastHelper.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/UnitFactory.h" @@ -88,7 +89,7 @@ void StepScan::exec() { sumEvents->executeAsChildAlg(); Workspace_sptr outputWS = sumEvents->getProperty("OutputWorkspace"); - auto table = std::dynamic_pointer_cast(outputWS); + auto table = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(outputWS); // Remove the scan_index=0 entry from the resulting table (unless it's the // only one) if (table->rowCount() > 1 && table->Int(0, 0) == 0) { diff --git a/docs/source/release/v6.12.0/Framework/Data_Objects/Bugfixes/38100.rst b/docs/source/release/v6.12.0/Framework/Data_Objects/Bugfixes/38100.rst new file mode 100644 index 000000000000..20489c186f43 --- /dev/null +++ b/docs/source/release/v6.12.0/Framework/Data_Objects/Bugfixes/38100.rst @@ -0,0 +1 @@ +- Fixed bug in `TableWorkspace::getMemorySize()` where the calculation was not summing memory correctly, leading to an underestimate of memory use.. From d8ddefa85974426dbffed114cd452454cdb4462f Mon Sep 17 00:00:00 2001 From: Jimoh Yusuf Date: Tue, 12 Nov 2024 12:11:28 +0000 Subject: [PATCH 05/17] fix coverity issue in findreflectomeryline --- Framework/Reflectometry/src/FindReflectometryLines2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Reflectometry/src/FindReflectometryLines2.cpp b/Framework/Reflectometry/src/FindReflectometryLines2.cpp index b7385c6f5630..7d45bd262015 100644 --- a/Framework/Reflectometry/src/FindReflectometryLines2.cpp +++ b/Framework/Reflectometry/src/FindReflectometryLines2.cpp @@ -134,7 +134,7 @@ void FindReflectometryLines2::exec() { setProperty(Prop::LINE_CENTRE, peakWSIndex); if (!isDefault(Prop::OUTPUT_WS)) { auto outputWS = makeOutput(peakWSIndex); - setProperty(Prop::OUTPUT_WS, outputWS); + setProperty(Prop::OUTPUT_WS, std::move(outputWS)); } } @@ -189,7 +189,7 @@ double FindReflectometryLines2::findPeak(const API::MatrixWorkspace_sptr &ws) { func = API::FunctionFactory::Instance().createFunction("LinearBackground"); func->setParameter("A0", medianY); func->setParameter("A1", 0.); - sum->addFunction(func); + sum->addFunction(std::move(func)); // call Fit child algorithm auto fit = createChildAlgorithm("Fit"); fit->initialize(); From 0aacae398a462302aa5b2a097d9de752a712de30 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Mon, 25 Nov 2024 13:03:12 -0500 Subject: [PATCH 06/17] Remove unused import and minor reformat --- Framework/Indexing/src/IndexInfo.cpp | 32 ++++++++++------------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/Framework/Indexing/src/IndexInfo.cpp b/Framework/Indexing/src/IndexInfo.cpp index ff55fd8823b6..3d2854f543e6 100644 --- a/Framework/Indexing/src/IndexInfo.cpp +++ b/Framework/Indexing/src/IndexInfo.cpp @@ -12,7 +12,6 @@ #include "MantidTypes/SpectrumDefinition.h" #include -#include #include namespace Mantid::Indexing { @@ -100,10 +99,8 @@ const std::vector &IndexInfo::spectrumNumbers() const { /// Set a spectrum number for each index. void IndexInfo::setSpectrumNumbers(std::vector &&spectrumNumbers) { if (m_spectrumNumberTranslator->globalSize() != spectrumNumbers.size()) - throw std::runtime_error("IndexInfo::setSpectrumNumbers: Size mismatch. " - "The vector must contain a spectrum number for " - "each spectrum (not just for the local " - "partition)."); + throw std::runtime_error("IndexInfo::setSpectrumNumbers: Size mismatch. The vector must contain a spectrum number " + "for each spectrum (not just for the local partition)."); makeSpectrumNumberTranslator(std::move(spectrumNumbers)); } @@ -111,10 +108,8 @@ void IndexInfo::setSpectrumNumbers(std::vector &&spectrumNumbers void IndexInfo::setSpectrumNumbers(const SpectrumNumber min, const SpectrumNumber max) { auto newSize = static_cast(max) - static_cast(min) + 1; if (static_cast(m_spectrumNumberTranslator->globalSize()) != newSize) - throw std::runtime_error("IndexInfo::setSpectrumNumbers: Size mismatch. " - "The range of spectrum numbers must provide a " - "spectrum number for each spectrum (not just for " - "the local partition)."); + throw std::runtime_error("IndexInfo::setSpectrumNumbers: Size mismatch. The range of spectrum numbers must provide " + "a spectrum number for each spectrum (not just for the local partition)."); std::vector specNums(newSize); std::iota(specNums.begin(), specNums.end(), static_cast(min)); makeSpectrumNumberTranslator(std::move(specNums)); @@ -197,9 +192,8 @@ SpectrumIndexSet IndexInfo::makeIndexSet(const std::vector std::vector IndexInfo::globalSpectrumIndicesFromDetectorIndices(const std::vector &detectorIndices) const { if (!m_spectrumDefinitions) - throw std::runtime_error("IndexInfo::" - "globalSpectrumIndicesFromDetectorIndices -- no " - "spectrum definitions available"); + throw std::runtime_error( + "IndexInfo::globalSpectrumIndicesFromDetectorIndices -- no spectrum definitions available"); /* * We need some way of keeping track of which time indices of given detector * have a matching mapping. detectorMap holds pairs; first in the pair @@ -260,26 +254,22 @@ IndexInfo::globalSpectrumIndicesFromDetectorIndices(const std::vector &d } } if (spectrumDefinition.first == -2) - throw std::runtime_error("SpectrumDefinition contains multiple entries. " - "No unique mapping from detector to spectrum " - "possible"); + throw std::runtime_error( + "SpectrumDefinition contains multiple entries. No unique mapping from detector to spectrum possible"); } if (std::any_of(detectorMap.begin(), detectorMap.end(), [](const std::pair> &p) { return p.first == 1; })) { - throw std::runtime_error("Some of the requested detectors do not have a " - "corresponding spectrum"); + throw std::runtime_error("Some of the requested detectors do not have a corresponding spectrum"); } if (std::any_of(detectorMap.begin(), detectorMap.end(), [](const std::pair> &p) { return std::any_of(p.second.begin(), p.second.end(), [](char c) { return c > 1; }); })) { - throw std::runtime_error("Some of the spectra map to the same detector " - "at the same time index"); + throw std::runtime_error("Some of the spectra map to the same detector at the same time index"); } if (detectorIndices.size() > spectrumIndices.size()) - throw std::runtime_error("Some of the requested detectors do not have a " - "corresponding spectrum"); + throw std::runtime_error("Some of the requested detectors do not have a corresponding spectrum"); return spectrumIndices; } From 74464d1fee61233ec262e03fdd5400a2f4f5a223 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Mon, 25 Nov 2024 14:35:58 -0500 Subject: [PATCH 07/17] Fix bug with detector-ids that do not increase in a component This affects VULCAN from 2021 on when loading a single bank of data. Since the detector ids do not increase with components, there was an implicit assumption that was being violated. --- .../src/LoadEventNexusIndexSetup.cpp | 60 ++++++++++++------- .../test/LoadEventNexusIndexSetupTest.h | 18 ++++++ 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp b/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp index 60a1d4fa014a..1f7ab8823c6d 100644 --- a/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp +++ b/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp @@ -25,18 +25,41 @@ namespace Mantid::DataHandling { namespace { void setupConsistentSpectrumNumbers(IndexInfo &filtered, const std::vector &detIDs) { + // get the filtered information and sort the ids to make the main loop run faster + auto spectrumNumbersFiltered = filtered.spectrumNumbers(); // what it is at the beginning + if (!std::is_sorted(spectrumNumbersFiltered.cbegin(), spectrumNumbersFiltered.cend())) { + std::sort(spectrumNumbersFiltered.begin(), spectrumNumbersFiltered.end()); + } + + // Temporary spectrum number in `filtered` was detector ID, now translate to spectrum number, starting at 1. Note that + // we use detIDs and not DetectorInfo for translation since we need to match the unfiltered spectrum numbers, which + // are based on skipping monitors (which would be included in DetectorInfo). std::vector spectrumNumbers; - // Temporary spectrum number in `filtered` was detector ID, now translate - // to spectrum number, starting at 1. Note that we use detIDs and not - // DetectorInfo for translation since we need to match the unfiltered - // spectrum numbers, which are based on skipping monitors (which would be - // included in DetectorInfo). - for (int32_t i = 0; i < static_cast(detIDs.size()); ++i) { - if (filtered.spectrumNumber(spectrumNumbers.size()) == detIDs[i]) + const auto NUM_DETIDS = static_cast(detIDs.size()); + auto specFilterIter = spectrumNumbersFiltered.cbegin(); + auto specFilterIterEnd = spectrumNumbersFiltered.cend(); + for (int32_t i = 0; i < NUM_DETIDS; ++i) { + auto specFilterIterTemp = std::find(specFilterIter, specFilterIterEnd, detIDs[i]); + if (specFilterIterTemp != specFilterIterEnd) { spectrumNumbers.emplace_back(i + 1); - if (filtered.size() == spectrumNumbers.size()) - break; + + // finish early if everything was found + if (filtered.size() == spectrumNumbers.size()) + break; + + // advance to the element after the one found to start next search + specFilterIter = std::next(specFilterIterTemp); + } + } + + // error check the results + if (filtered.size() != spectrumNumbers.size()) { + std::stringstream msg; + msg << "Not all detectors were found in the instrumen. Requested filtered=" << filtered.size() + << " found=" << spectrumNumbers.size(); + throw std::runtime_error(msg.str()); } + filtered.setSpectrumNumbers(std::move(spectrumNumbers)); } } // namespace @@ -48,24 +71,22 @@ LoadEventNexusIndexSetup::LoadEventNexusIndexSetup(MatrixWorkspace_const_sptr in std::pair LoadEventNexusIndexSetup::eventIDLimits() const { return {m_min, m_max}; } IndexInfo LoadEventNexusIndexSetup::makeIndexInfo() { - // The default 1:1 will suffice but exclude the monitors as they are always in - // a separate workspace - auto detIDs = m_instrumentWorkspace->getInstrument()->getDetectorIDs(true); + // The default 1:1 will suffice but exclude the monitors as they are always in a separate workspace + const auto detIDs = m_instrumentWorkspace->getInstrument()->getDetectorIDs(true); const auto &detectorInfo = m_instrumentWorkspace->detectorInfo(); std::vector specDefs; specDefs.reserve(detIDs.size()); std::transform(detIDs.cbegin(), detIDs.cend(), std::back_inserter(specDefs), [&detectorInfo](const auto detID) { return SpectrumDefinition(detectorInfo.indexOf(detID)); }); - // We need to filter based on detector IDs, but use IndexInfo for filtering - // for a unified filtering mechanism. Thus we set detector IDs as (temporary) - // spectrum numbers. + // We need to filter based on detector IDs, but use IndexInfo for filtering for a unified filtering mechanism. Thus we + // set detector IDs as (temporary) spectrum numbers. IndexInfo indexInfo(std::vector(detIDs.begin(), detIDs.end())); indexInfo.setSpectrumDefinitions(specDefs); auto filtered = filterIndexInfo(indexInfo); - // Spectrum numbers are continuous and start at 1. If there is a filter, - // spectrum numbers are set up to be consistent with the unfiltered case. + // Spectrum numbers are continuous and start at 1. If there is a filter, spectrum numbers are set up to be consistent + // with the unfiltered case. if (filtered.size() == indexInfo.size()) { filtered.setSpectrumNumbers(1, static_cast(filtered.size())); } else { @@ -96,9 +117,8 @@ IndexInfo LoadEventNexusIndexSetup::makeIndexInfo(const std::vector } if (dets.empty()) throw std::runtime_error("Could not find the bank named '" + bankName + - "' as a component assembly in the instrument " - "tree; or it did not contain any detectors. Try " - "unchecking SingleBankPixelsOnly."); + "' as a component assembly in the instrument tree; or it did not contain any detectors. " + "Try unchecking SingleBankPixelsOnly."); } Indexing::IndexInfo indexInfo(std::move(spectrumNumbers)); indexInfo.setSpectrumDefinitions(std::move(spectrumDefinitions)); diff --git a/Framework/DataHandling/test/LoadEventNexusIndexSetupTest.h b/Framework/DataHandling/test/LoadEventNexusIndexSetupTest.h index 3395a4d616e8..2acbe65f7dfe 100644 --- a/Framework/DataHandling/test/LoadEventNexusIndexSetupTest.h +++ b/Framework/DataHandling/test/LoadEventNexusIndexSetupTest.h @@ -190,6 +190,24 @@ class LoadEventNexusIndexSetupTest : public CxxTest::TestSuite { TS_ASSERT_EQUALS(specDefs->at(1), SpectrumDefinition(3)); } + /* compare this test body with test_makeIndexInfo_from_bank. The main difference is that the instrument components are + * specifed backwards. This is consistent with VULCAN IDF */ + void test_makeIndexInfo_from_bank_backwards() { + LoadEventNexusIndexSetup indexSetup(m_ws, EMPTY_INT(), EMPTY_INT(), {}); + const auto indexInfo = indexSetup.makeIndexInfo({"det-12", "det-2"}); // intentionally backwards + TS_ASSERT_EQUALS(indexSetup.eventIDLimits().first, EMPTY_INT()); + TS_ASSERT_EQUALS(indexSetup.eventIDLimits().second, EMPTY_INT()); + TS_ASSERT_EQUALS(indexInfo.size(), 2); + // these match the spectrum numbers of the full instrument + TS_ASSERT_EQUALS(indexInfo.spectrumNumber(0), SpectrumNumber(2)); + TS_ASSERT_EQUALS(indexInfo.spectrumNumber(1), SpectrumNumber(4)); + // this may actually be wrong, but it appears as though the order of the spectrum definitions match the way they + // were requested while the spectrum numbers (just above) are always in increasing order + const auto specDefs = indexInfo.spectrumDefinitions(); + TS_ASSERT_EQUALS(specDefs->at(0), SpectrumDefinition(3)); + TS_ASSERT_EQUALS(specDefs->at(1), SpectrumDefinition(1)); + } + void test_makeIndexInfo_from_bank_filter_ignored() { LoadEventNexusIndexSetup indexSetup(m_ws, 12, EMPTY_INT(), {1}); // This variant ignores any filter in the index/workspace setup phase, From 7903e84cf081114b79269c306e47ab9770a24e32 Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Mon, 25 Nov 2024 15:01:04 -0500 Subject: [PATCH 08/17] Add release notes --- .../release/v6.12.0/Diffraction/Engineering/Bugfixes/.gitkeep | 0 .../release/v6.12.0/Diffraction/Engineering/Bugfixes/38444.rst | 1 + 2 files changed, 1 insertion(+) delete mode 100644 docs/source/release/v6.12.0/Diffraction/Engineering/Bugfixes/.gitkeep create mode 100644 docs/source/release/v6.12.0/Diffraction/Engineering/Bugfixes/38444.rst diff --git a/docs/source/release/v6.12.0/Diffraction/Engineering/Bugfixes/.gitkeep b/docs/source/release/v6.12.0/Diffraction/Engineering/Bugfixes/.gitkeep deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/docs/source/release/v6.12.0/Diffraction/Engineering/Bugfixes/38444.rst b/docs/source/release/v6.12.0/Diffraction/Engineering/Bugfixes/38444.rst new file mode 100644 index 000000000000..cd87c024617d --- /dev/null +++ b/docs/source/release/v6.12.0/Diffraction/Engineering/Bugfixes/38444.rst @@ -0,0 +1 @@ +- Fix issue with :ref:`LoadEventNexus ` loading banks 1, 5, 6 as single banks From f9cc61201e071590b1bf299bc3534b0319d084f6 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Fri, 1 Nov 2024 10:53:21 +0000 Subject: [PATCH 09/17] Update Clang to version 18 on macOS This brings #38342 into ornl-next In Clang 17 a new optimisation was introduced that breaks some of our tests, e.g. SplineSmoothingTest, so I've disabled that option. Use smart pointers instead of raw pointers Disable compiler extensions This should give us more consistent behaviour across different compilers. --- Framework/CurveFitting/src/Functions/BSpline.cpp | 6 +++--- buildconfig/CMake/CommonSetup.cmake | 1 + buildconfig/CMake/GNUSetup.cmake | 1 + conda/recipes/conda_build_config.yaml | 6 +++--- .../source/release/v6.12.0/Workbench/New_features/38335.rst | 1 + 5 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 docs/source/release/v6.12.0/Workbench/New_features/38335.rst diff --git a/Framework/CurveFitting/src/Functions/BSpline.cpp b/Framework/CurveFitting/src/Functions/BSpline.cpp index 9f66436b7594..2bae127de715 100644 --- a/Framework/CurveFitting/src/Functions/BSpline.cpp +++ b/Framework/CurveFitting/src/Functions/BSpline.cpp @@ -61,14 +61,14 @@ void BSpline::resetValidators() { auto attStartX = getAttribute("StartX"); auto attEndX = getAttribute("EndX"); - auto startXValidator = dynamic_cast *>(attStartX.getValidator().get()); + auto startXValidator = std::dynamic_pointer_cast>(attStartX.getValidator()); startXValidator->setUpper(attEndX.asDouble()); - auto endXValidator = dynamic_cast *>(attEndX.getValidator().get()); + auto endXValidator = std::dynamic_pointer_cast>(attEndX.getValidator()); endXValidator->setLower(attStartX.asDouble()); auto breakPointsValidator = - dynamic_cast *>(getAttribute("BreakPoints").getValidator().get()); + std::dynamic_pointer_cast>(getAttribute("BreakPoints").getValidator()); breakPointsValidator->setLower(attStartX.asDouble()); breakPointsValidator->setUpper(attEndX.asDouble()); } diff --git a/buildconfig/CMake/CommonSetup.cmake b/buildconfig/CMake/CommonSetup.cmake index 71fce2d78928..484a66b12634 100644 --- a/buildconfig/CMake/CommonSetup.cmake +++ b/buildconfig/CMake/CommonSetup.cmake @@ -130,6 +130,7 @@ endif() # ###################################################################################################################### set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # ###################################################################################################################### # Setup ccache diff --git a/buildconfig/CMake/GNUSetup.cmake b/buildconfig/CMake/GNUSetup.cmake index 44a7f33d3e70..f954775330d9 100644 --- a/buildconfig/CMake/GNUSetup.cmake +++ b/buildconfig/CMake/GNUSetup.cmake @@ -72,6 +72,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") add_definitions(-D_LIBCPP_DISABLE_AVAILABILITY) # Keep C++14 alignment behaviour while older macOS C++ ABI does not contain the required symbols. Minimum=macos 10.14 add_compile_options(-fno-aligned-new) + add_compile_options(-fno-assume-unique-vtables) endif() # Add some options for debug build to help the Zoom profiler diff --git a/conda/recipes/conda_build_config.yaml b/conda/recipes/conda_build_config.yaml index 010978684f89..4535c9778e89 100644 --- a/conda/recipes/conda_build_config.yaml +++ b/conda/recipes/conda_build_config.yaml @@ -5,17 +5,17 @@ c_compiler: - clang # [osx] - vs2019 # [win] c_compiler_version: # [unix] - - 16 # [osx] + - 18 # [osx] - 13 # [linux] cxx_compiler: - gxx # [linux] - clangxx # [osx] - vs2019 # [win] cxx_compiler_version: # [unix] - - 16 # [osx] + - 18 # [osx] - 13 # [linux] llvm_openmp: # [osx] - - 16 # [osx] + - 18 # [osx] python: - 3.10 diff --git a/docs/source/release/v6.12.0/Workbench/New_features/38335.rst b/docs/source/release/v6.12.0/Workbench/New_features/38335.rst new file mode 100644 index 000000000000..40ac46c8dab9 --- /dev/null +++ b/docs/source/release/v6.12.0/Workbench/New_features/38335.rst @@ -0,0 +1 @@ +- Updated compiler on macOS from version 16 to version 18, which should result in performance improvements. See https://releases.llvm.org for release notes. From 00850b77ad9450b0309de5b9c65a79b85ef6e751 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 3 Oct 2024 16:07:34 +0100 Subject: [PATCH 10/17] Coverity fixes This gets the changes from #38142 into ornl-next Most fixes were for copying in instead of moving in to a method that I've recently added to fix Coverity warnings about null objects. The changes in FindPeaksConvolve were because m_pdf was being either read or written to without the lock. Refactor to avoid potential null cast This refactor will protect against a null cast in the case of a non-MultiDomainFunction being passed in. --- .../Algorithms/src/FindPeaksConvolve.cpp | 10 +++- Framework/Crystal/src/SCDPanelErrors.cpp | 2 +- .../ConvertFitFunctionForMuonTFAsymmetry.h | 3 + Framework/Muon/src/CalculateMuonAsymmetry.cpp | 4 +- .../ConvertFitFunctionForMuonTFAsymmetry.cpp | 60 ++++++++++--------- .../src/FindReflectometryLines2.cpp | 2 +- Framework/WorkflowAlgorithms/src/StepScan.cpp | 3 +- 7 files changed, 49 insertions(+), 35 deletions(-) diff --git a/Framework/Algorithms/src/FindPeaksConvolve.cpp b/Framework/Algorithms/src/FindPeaksConvolve.cpp index 7318c8b3a454..381761fb1bac 100644 --- a/Framework/Algorithms/src/FindPeaksConvolve.cpp +++ b/Framework/Algorithms/src/FindPeaksConvolve.cpp @@ -336,14 +336,18 @@ size_t FindPeaksConvolve::findPeakInRawData(const int xIndex, const TensorMap_co unweightedYData.maxCoeff(&maxIndex); } else { generateNormalPDF(static_cast(peakExtentBinNumber)); - const auto weightedYData = EigenMap_const(yData.data() + sliceStart, adjPeakExtentBinNumber) - .cwiseProduct(EigenMap_const(m_pdf.data() + startAdj, adjPeakExtentBinNumber)); - weightedYData.maxCoeff(&maxIndex); + const auto yDataMap = EigenMap_const(yData.data() + sliceStart, adjPeakExtentBinNumber); + { + std::lock_guard lock(m_mtx); + const auto weightedYData = yDataMap.cwiseProduct(EigenMap_const(m_pdf.data() + startAdj, adjPeakExtentBinNumber)); + weightedYData.maxCoeff(&maxIndex); + } } return static_cast(maxIndex) + sliceStart; } void FindPeaksConvolve::generateNormalPDF(const int peakExtentBinNumber) { + std::lock_guard lock(m_mtx); if (m_pdf.size() == 0) { m_pdf.resize(peakExtentBinNumber); boost::math::normal_distribution<> dist(0.0, diff --git a/Framework/Crystal/src/SCDPanelErrors.cpp b/Framework/Crystal/src/SCDPanelErrors.cpp index fbdf9838bbe7..334d8d110b47 100644 --- a/Framework/Crystal/src/SCDPanelErrors.cpp +++ b/Framework/Crystal/src/SCDPanelErrors.cpp @@ -180,7 +180,7 @@ void SCDPanelErrors::eval(double xshift, double yshift, double zshift, double xr auto inputP = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( - cloned); + std::move(cloned)); auto inst = inputP->getInstrument(); Geometry::OrientedLattice lattice = inputP->mutableSample().getOrientedLattice(); for (int i = 0; i < inputP->getNumberPeaks(); i++) { diff --git a/Framework/Muon/inc/MantidMuon/ConvertFitFunctionForMuonTFAsymmetry.h b/Framework/Muon/inc/MantidMuon/ConvertFitFunctionForMuonTFAsymmetry.h index bc2a8497f16c..31894b2f2c43 100644 --- a/Framework/Muon/inc/MantidMuon/ConvertFitFunctionForMuonTFAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/ConvertFitFunctionForMuonTFAsymmetry.h @@ -11,6 +11,7 @@ //---------------------------------------------------------------------- #include "MantidAPI/Algorithm.h" #include "MantidAPI/IFunction.h" +#include "MantidAPI/MultiDomainFunction.h" #include "MantidMuon/DllConfig.h" namespace Mantid { @@ -64,6 +65,8 @@ class MANTID_MUON_DLL ConvertFitFunctionForMuonTFAsymmetry final : public API::A Mantid::API::IFunction_sptr extractUserFunction(const Mantid::API::IFunction_sptr &TFFunc); void setOutput(const Mantid::API::IFunction_sptr &function); std::vector getNorms(); + void configureMultiDomainFunction(std::shared_ptr multiDomainFunction, + const Mantid::API::IFunction_sptr &userFunc, const double normValue); }; } // namespace Muon diff --git a/Framework/Muon/src/CalculateMuonAsymmetry.cpp b/Framework/Muon/src/CalculateMuonAsymmetry.cpp index f691c9bb79ca..08f912d367be 100644 --- a/Framework/Muon/src/CalculateMuonAsymmetry.cpp +++ b/Framework/Muon/src/CalculateMuonAsymmetry.cpp @@ -359,12 +359,12 @@ std::vector CalculateMuonAsymmetry::getNormConstants(const std::vector( - tmp, wrongFunctionFormError); + std::move(tmp), wrongFunctionFormError); norms.emplace_back(getNormValue(TFFunc)); } else { auto result = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( - tmp, wrongFunctionFormError); + std::move(tmp), wrongFunctionFormError); for (size_t j = 0; j < wsNames.size(); j++) { // get domain auto TFFunc = diff --git a/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp b/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp index af1204055e26..ac4a9dfdeabc 100644 --- a/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp +++ b/Framework/Muon/src/ConvertFitFunctionForMuonTFAsymmetry.cpp @@ -14,7 +14,6 @@ #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/FunctionProperty.h" #include "MantidAPI/ITableWorkspace.h" -#include "MantidAPI/MultiDomainFunction.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/MatrixWorkspace.h" @@ -326,36 +325,19 @@ Mantid::API::IFunction_sptr ConvertFitFunctionForMuonTFAsymmetry::getTFAsymmFitFunction(const Mantid::API::IFunction_sptr &original, const std::vector &norms) { auto multi = std::make_shared(); - auto tmp = std::dynamic_pointer_cast(original); size_t numDomains = original->getNumberDomains(); - for (size_t j = 0; j < numDomains; j++) { - IFunction_sptr userFunc; - auto constant = FunctionFactory::Instance().createInitialized("name = FlatBackground, A0 = 1.0, ties=(A0=1)"); - if (numDomains == 1) { - userFunc = original; - } else { - userFunc = tmp->getFunction(j); + if (numDomains == 1) { + configureMultiDomainFunction(multi, original, norms[0]); + } else { + auto tmp = + Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(original); + for (size_t j = 0; j < numDomains; j++) { + IFunction_sptr userFunc = tmp->getFunction(j); multi->setDomainIndex(j, j); + configureMultiDomainFunction(multi, userFunc, norms[j]); } - auto inBrace = std::make_shared(); - inBrace->addFunction(constant); - inBrace->addFunction(userFunc); - auto norm = FunctionFactory::Instance().createInitialized("name = FlatBackground, A0 " - "=" + - std::to_string(norms[j])); - auto product = - std::dynamic_pointer_cast(FunctionFactory::Instance().createFunction("ProductFunction")); - product->addFunction(norm); - product->addFunction(inBrace); - auto composite = - std::dynamic_pointer_cast(FunctionFactory::Instance().createFunction("CompositeFunction")); - constant = FunctionFactory::Instance().createInitialized( - "name = ExpDecayMuon, A = 0.0, Lambda = -" + std::to_string(MUON_LIFETIME_MICROSECONDS) + - ",ties = (A = 0.0, Lambda = -" + std::to_string(MUON_LIFETIME_MICROSECONDS) + ")"); - composite->addFunction(product); - composite->addFunction(constant); - multi->addFunction(composite); } + // if multi data set we need to do the ties manually bool copyTies = getProperty("CopyTies"); if (numDomains > 1 && copyTies) { @@ -379,4 +361,28 @@ ConvertFitFunctionForMuonTFAsymmetry::getTFAsymmFitFunction(const Mantid::API::I return std::dynamic_pointer_cast(multi); } + +void ConvertFitFunctionForMuonTFAsymmetry::configureMultiDomainFunction( + std::shared_ptr multiDomainFunction, const Mantid::API::IFunction_sptr &userFunc, + const double normValue) { + auto constant = FunctionFactory::Instance().createInitialized("name = FlatBackground, A0 = 1.0, ties=(A0=1)"); + auto inBrace = std::make_shared(); + inBrace->addFunction(constant); + inBrace->addFunction(userFunc); + auto norm = FunctionFactory::Instance().createInitialized("name = FlatBackground, A0 " + "=" + + std::to_string(normValue)); + auto product = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( + FunctionFactory::Instance().createFunction("ProductFunction")); + product->addFunction(norm); + product->addFunction(inBrace); + auto composite = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( + FunctionFactory::Instance().createFunction("CompositeFunction")); + constant = FunctionFactory::Instance().createInitialized( + "name = ExpDecayMuon, A = 0.0, Lambda = -" + std::to_string(MUON_LIFETIME_MICROSECONDS) + + ",ties = (A = 0.0, Lambda = -" + std::to_string(MUON_LIFETIME_MICROSECONDS) + ")"); + composite->addFunction(product); + composite->addFunction(constant); + multiDomainFunction->addFunction(composite); +} } // namespace Mantid::Muon diff --git a/Framework/Reflectometry/src/FindReflectometryLines2.cpp b/Framework/Reflectometry/src/FindReflectometryLines2.cpp index 7d45bd262015..b441cf9148ad 100644 --- a/Framework/Reflectometry/src/FindReflectometryLines2.cpp +++ b/Framework/Reflectometry/src/FindReflectometryLines2.cpp @@ -193,7 +193,7 @@ double FindReflectometryLines2::findPeak(const API::MatrixWorkspace_sptr &ws) { // call Fit child algorithm auto fit = createChildAlgorithm("Fit"); fit->initialize(); - fit->setProperty("Function", std::dynamic_pointer_cast(sum)); + fit->setProperty("Function", std::dynamic_pointer_cast(std::move(sum))); fit->setProperty("InputWorkspace", transposedWS); fit->setProperty("StartX", centreIndex - 3 * fwhm); fit->setProperty("EndX", centreIndex + 3 * fwhm); diff --git a/Framework/WorkflowAlgorithms/src/StepScan.cpp b/Framework/WorkflowAlgorithms/src/StepScan.cpp index 686d452a0b38..6ff7ea938c71 100644 --- a/Framework/WorkflowAlgorithms/src/StepScan.cpp +++ b/Framework/WorkflowAlgorithms/src/StepScan.cpp @@ -89,7 +89,8 @@ void StepScan::exec() { sumEvents->executeAsChildAlg(); Workspace_sptr outputWS = sumEvents->getProperty("OutputWorkspace"); - auto table = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck(outputWS); + auto table = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck( + std::move(outputWS)); // Remove the scan_index=0 entry from the resulting table (unless it's the // only one) if (table->rowCount() > 1 && table->Int(0, 0) == 0) { From 6a7020402a98f7d06feb9010544b4ec4e46fc85b Mon Sep 17 00:00:00 2001 From: Jonathan Haigh Date: Thu, 14 Nov 2024 09:57:04 +0000 Subject: [PATCH 11/17] remove some cppcheck unusedVariable errors This brings #38397 into ornl-next constVariablePointer cppcheck fixes --- Framework/API/src/NumericAxis.cpp | 2 +- .../CalculateCarpenterSampleCorrection.cpp | 2 -- Framework/Algorithms/src/GroupWorkspaces.cpp | 1 - .../Algorithms/src/InterpolatingRebin.cpp | 2 +- Framework/Algorithms/src/SmoothNeighbours.cpp | 3 +- Framework/Algorithms/src/Stitch.cpp | 4 --- .../src/WeightedMeanOfWorkspace.cpp | 3 +- .../src/GoniometerAnglesFromPhiRotation.cpp | 1 - .../DataHandling/src/LoadANSTOHelper.cpp | 8 ++---- Framework/DataHandling/src/LoadTBL.cpp | 2 +- Framework/DataHandling/src/SavePHX.cpp | 5 +--- Framework/Kernel/src/LogFilter.cpp | 4 --- .../LiveData/src/ISIS/DAE/isisds_command.cpp | 1 - .../CMake/CppCheck_Suppressions.txt.in | 28 +------------------ .../common/src/AlgorithmPropertiesWidget.cpp | 7 ++--- qt/widgets/common/src/RepoModel.cpp | 24 ++++++---------- 16 files changed, 22 insertions(+), 75 deletions(-) diff --git a/Framework/API/src/NumericAxis.cpp b/Framework/API/src/NumericAxis.cpp index 8bd9b32d5daa..9cb5ba50118e 100644 --- a/Framework/API/src/NumericAxis.cpp +++ b/Framework/API/src/NumericAxis.cpp @@ -163,7 +163,7 @@ std::string NumericAxis::formatLabel(const double value) const { if (*it == '0') { it = numberLabel.erase(it); } else if (*it == '.') { - it = numberLabel.erase(it); + numberLabel.erase(it); break; } else { break; diff --git a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp index 281535b354ec..4d6609983080 100644 --- a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp +++ b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp @@ -159,8 +159,6 @@ void CalculateCarpenterSampleCorrection::exec() { // Initialize progress reporting. Progress prog(this, 0.0, 1.0, NUM_HIST); - EventWorkspace_sptr inputWkspEvent = std::dynamic_pointer_cast(inputWksp); - // Create the new correction workspaces MatrixWorkspace_sptr absWksp = createOutputWorkspace(inputWksp, "Attenuation factor"); MatrixWorkspace_sptr msWksp = createOutputWorkspace(inputWksp, "Multiple scattering factor"); diff --git a/Framework/Algorithms/src/GroupWorkspaces.cpp b/Framework/Algorithms/src/GroupWorkspaces.cpp index ab08768469a5..21db5e037cff 100644 --- a/Framework/Algorithms/src/GroupWorkspaces.cpp +++ b/Framework/Algorithms/src/GroupWorkspaces.cpp @@ -58,7 +58,6 @@ std::map GroupWorkspaces::validateInputs() { std::map results; const std::vector inputWorkspaces = getProperty("InputWorkspaces"); std::string globExpression = getProperty("GlobExpression"); - std::string outputWorkspace = getProperty("OutputWorkspace"); for (auto it = globExpression.begin(); it < globExpression.end(); ++it) { if (*it == '\\') { diff --git a/Framework/Algorithms/src/InterpolatingRebin.cpp b/Framework/Algorithms/src/InterpolatingRebin.cpp index 795ec81ab2f7..d1b1bae45532 100644 --- a/Framework/Algorithms/src/InterpolatingRebin.cpp +++ b/Framework/Algorithms/src/InterpolatingRebin.cpp @@ -66,7 +66,7 @@ std::map InterpolatingRebin::validateInputs() { MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace"); std::vector rbParams = getProperty("Params"); try { - std::vector validParams = Rebin::rebinParamsFromInput(rbParams, *inputWS, g_log); + Rebin::rebinParamsFromInput(rbParams, *inputWS, g_log); } catch (std::exception &err) { helpMessages["Params"] = err.what(); } diff --git a/Framework/Algorithms/src/SmoothNeighbours.cpp b/Framework/Algorithms/src/SmoothNeighbours.cpp index 7d2e8a24c7c8..744bac2c971e 100644 --- a/Framework/Algorithms/src/SmoothNeighbours.cpp +++ b/Framework/Algorithms/src/SmoothNeighbours.cpp @@ -314,7 +314,6 @@ void SmoothNeighbours::findNeighboursUbiquitous() { m_progress->resetNumSteps(m_inWS->getNumberHistograms(), 0.2, 0.5); this->progress(0.2, "Building Neighbour Map"); - Instrument_const_sptr inst = m_inWS->getInstrument(); const spec2index_map spec2index = m_inWS->getSpectrumToWorkspaceIndexMap(); // Resize the vector we are setting @@ -379,7 +378,7 @@ void SmoothNeighbours::findNeighboursUbiquitous() { std::vector neighbours; // Convert from spectrum numbers to workspace indices - for (auto &specDistance : neighbSpectra) { + for (const auto &specDistance : neighbSpectra) { specnum_t spec = specDistance.first; // Use the weighting strategy to calculate the weight. diff --git a/Framework/Algorithms/src/Stitch.cpp b/Framework/Algorithms/src/Stitch.cpp index ed3afd0aeef0..e99c63edfe95 100644 --- a/Framework/Algorithms/src/Stitch.cpp +++ b/Framework/Algorithms/src/Stitch.cpp @@ -26,7 +26,6 @@ using namespace Mantid::Kernel; namespace { static const std::string INPUT_WORKSPACE_PROPERTY = "InputWorkspaces"; static const std::string REFERENCE_WORKSPACE_PROPERTY = "ReferenceWorkspace"; -static const std::string COMBINATION_BEHAVIOUR_PROPERTY = "CombinationBehaviour"; static const std::string SCALE_FACTOR_CALCULATION_PROPERTY = "ScaleFactorCalculation"; static const std::string MANUAL_SCALE_FACTORS_PROPERTY = "ManualScaleFactors"; static const std::string TIE_SCALE_FACTORS_PROPERTY = "TieScaleFactors"; @@ -241,8 +240,6 @@ void Stitch::init() { "that is, the one that will not be scaled. If left blank, " "stitching will be performed left to right in the order of x-axes ascending, " "no matter the order of workspaces names in the input."); - declareProperty(COMBINATION_BEHAVIOUR_PROPERTY, "Interleave", - std::make_unique>(std::array{"Interleave"})); declareProperty(SCALE_FACTOR_CALCULATION_PROPERTY, "MedianOfRatios", std::make_unique>(std::array{"MedianOfRatios", "Manual"})); declareProperty(std::make_unique>(MANUAL_SCALE_FACTORS_PROPERTY), @@ -264,7 +261,6 @@ void Stitch::init() { */ void Stitch::exec() { const auto referenceName = getPropertyValue(REFERENCE_WORKSPACE_PROPERTY); - const auto combinationBehaviour = getPropertyValue(COMBINATION_BEHAVIOUR_PROPERTY); const auto scaleFactorCalculation = getPropertyValue(SCALE_FACTOR_CALCULATION_PROPERTY); const auto inputs = RunCombinationHelper::unWrapGroups(getProperty(INPUT_WORKSPACE_PROPERTY)); MatrixWorkspace_sptr scaleFactorsWorkspace; diff --git a/Framework/Algorithms/src/WeightedMeanOfWorkspace.cpp b/Framework/Algorithms/src/WeightedMeanOfWorkspace.cpp index ab4526fe5184..112b4903cdc6 100644 --- a/Framework/Algorithms/src/WeightedMeanOfWorkspace.cpp +++ b/Framework/Algorithms/src/WeightedMeanOfWorkspace.cpp @@ -60,10 +60,9 @@ void WeightedMeanOfWorkspace::exec() { continue; auto &y = inputWS->y(i); auto &e = inputWS->e(i); - double weight = 0.0; for (std::size_t j = 0; j < y.size(); ++j) { if (std::isfinite(y[j]) && std::isfinite(e[j])) { - weight = 1.0 / (e[j] * e[j]); + double weight = 1.0 / (e[j] * e[j]); averageValue += (y[j] * weight); weightSum += weight; } diff --git a/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp b/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp index 3a2e1f4070e0..122ce2684ba3 100644 --- a/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp +++ b/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp @@ -303,7 +303,6 @@ void GoniometerAnglesFromPhiRotation::exec() { double deg, ax1, ax2, ax3; Q1.getAngleAxis(deg, ax1, ax2, ax3); if (dphi * deg < 0) { - deg = -deg; ax1 = -ax1; ax2 = -ax2; ax3 = -ax3; diff --git a/Framework/DataHandling/src/LoadANSTOHelper.cpp b/Framework/DataHandling/src/LoadANSTOHelper.cpp index feff0c921030..2a3c0738a7bb 100644 --- a/Framework/DataHandling/src/LoadANSTOHelper.cpp +++ b/Framework/DataHandling/src/LoadANSTOHelper.cpp @@ -432,15 +432,13 @@ bool File::append(const std::string &path, const std::string &name, const void * else if (targetPosition != -1) throw std::runtime_error("format exception"); // it has to be the last file in the archive - FileInfo fileInfo; - fileInfo.Offset = position; - fileInfo.Size = header.readFileSize(); + auto fileSize = header.readFileSize(); - auto offset = static_cast(fileInfo.Size % 512); + auto offset = static_cast(fileSize % 512); if (offset != 0) offset = 512 - offset; - fileStatus &= 0 == fseek(handle.get(), static_cast(fileInfo.Size + offset), SEEK_CUR); + fileStatus &= 0 == fseek(handle.get(), static_cast(fileSize + offset), SEEK_CUR); } if (targetPosition < 0) diff --git a/Framework/DataHandling/src/LoadTBL.cpp b/Framework/DataHandling/src/LoadTBL.cpp index 2b46703476d6..657f9b24dbc5 100644 --- a/Framework/DataHandling/src/LoadTBL.cpp +++ b/Framework/DataHandling/src/LoadTBL.cpp @@ -160,7 +160,7 @@ void LoadTBL::csvParse(const std::string &line, std::vector &cols, firstCell = false; } else { auto colVal = line.substr(lastComma + 1, pos - (lastComma + 1)); - cols.emplace_back(line.substr(lastComma + 1, pos - (lastComma + 1))); + cols.emplace_back(colVal); } } lastComma = pos; diff --git a/Framework/DataHandling/src/SavePHX.cpp b/Framework/DataHandling/src/SavePHX.cpp index 1157f565fbf9..df900d396eb8 100644 --- a/Framework/DataHandling/src/SavePHX.cpp +++ b/Framework/DataHandling/src/SavePHX.cpp @@ -46,9 +46,6 @@ void SavePHX::exec() { // Retrieve the filename from the properties const std::string filename = getProperty("Filename"); - // Get a pointer to the sample - IComponent_const_sptr sample = inputWorkspace->getInstrument()->getSample(); - std::ofstream outPHX_file(filename.c_str()); if (!outPHX_file) { @@ -74,7 +71,7 @@ void SavePHX::exec() { }*/ spCalcDetPar->execute(); // - auto *pCalcDetPar = dynamic_cast(spCalcDetPar.get()); + const auto *pCalcDetPar = dynamic_cast(spCalcDetPar.get()); if (!pCalcDetPar) { // "can not get pointer to FindDetectorsPar algorithm" throw(std::bad_cast()); } diff --git a/Framework/Kernel/src/LogFilter.cpp b/Framework/Kernel/src/LogFilter.cpp index b03b387dd514..e6b9ab12bde6 100644 --- a/Framework/Kernel/src/LogFilter.cpp +++ b/Framework/Kernel/src/LogFilter.cpp @@ -89,10 +89,6 @@ void LogFilter::addFilter(const TimeSeriesProperty &filter) { } else { // determine if the current version of things are open-ended filterOpenEnded = (m_filter->lastValue() && filter.lastValue()); - DateAndTime firstTime = std::min(m_filter->firstTime(), filter.firstTime()); - if (m_prop && (m_prop->size() > 0)) { - firstTime = std::min(firstTime, m_prop->firstTime()); - } // create a local copy of both filters to add extra values to auto filter1 = m_filter.get(); diff --git a/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp b/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp index 9d3c10b87d00..56eba42ebfb5 100644 --- a/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp +++ b/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp @@ -313,7 +313,6 @@ static int isisds_recv_command_helper(SOCKET s, char **command, void **data, ISI free(*data); *data = nullptr; } - len_data = 0; return -1; } /* only update values if changed ... allows Read only parameters to be passed diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index d855768de276..ea3a14ace08f 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -60,7 +60,6 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/EnabledWhenPropert constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/EnabledWhenProperty.cpp:151 constParameterReference:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/DiskBuffer.cpp:363 iterateByValue:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/MultiFileValidator.cpp:65 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/LogFilter.cpp:94 nullPointerRedundantCheck:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/InternetHelper.cpp:148 nullPointerRedundantCheck:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/InternetHelper.cpp:149 nullPointerRedundantCheck:${CMAKE_SOURCE_DIR}/Framework/Kernel/src/InternetHelper.cpp:150 @@ -163,7 +162,6 @@ knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/AbsorptionC knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/AbsorptionCorrection.cpp:445 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/CalculateEfficiency.cpp:158 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/CalculateEfficiency.cpp:159 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp:162 missingOverride:${CMAKE_SOURCE_DIR}/Framework/Algorithms/inc/MantidAlgorithms/SpectrumAlgorithm.h:97 returnByReference:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/FunctionDomain1D.h:89 returnByReference:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/FunctionValues.h:86 @@ -209,7 +207,6 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/EQSANSTofStruc constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/EQSANSTofStructure.cpp:81 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FilterByLogValue.cpp:82 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/EstimateResolutionDiffraction.cpp:188 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GroupWorkspaces.cpp:61 uninitMemberVarPrivate:${CMAKE_SOURCE_DIR}/Framework/Algorithms/inc/MantidAlgorithms/FindPeaksConvolve.h:62 uninitMemberVarPrivate:${CMAKE_SOURCE_DIR}/Framework/Algorithms/inc/MantidAlgorithms/FindPeaksConvolve.h:63 uninitMemberVarPrivate:${CMAKE_SOURCE_DIR}/Framework/Algorithms/inc/MantidAlgorithms/FindPeaksConvolve.h:64 @@ -239,7 +236,6 @@ constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GeneratePeak shadowVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/He3TubeEfficiency.cpp:374 knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FindPeaks.cpp:892 knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/FindPeaks.cpp:999 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/InterpolatingRebin.cpp:69 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GetEi2.cpp:213 missingOverride:${CMAKE_SOURCE_DIR}/Framework/Algorithms/inc/MantidAlgorithms/GetAllEi.h:32 passedByValue:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp:277 @@ -307,13 +303,10 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/ShiftLogTime.c constParameterPointer:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/SofQCommon.cpp:25 containerOutOfBounds:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/SampleCorrections/SparseWorkspace.cpp:32 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/SpatialGrouping.cpp:214 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/Stitch.cpp:267 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/UpdateScriptRepository.cpp:51 uselessOverride:${CMAKE_SOURCE_DIR}/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h:55 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/AlgorithmHasProperty.cpp:36 -constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/SmoothNeighbours.cpp:382 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/SumEventsByLogValue.cpp:409 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/SmoothNeighbours.cpp:317 constParameterReference:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/Stitch1DMany.cpp:291 missingOverride:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/IAlgorithmRuntimeProps.h:16 missingOverride:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/AlgorithmRuntimeProps.h:21 @@ -353,11 +346,9 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/IPeaksWorkspace.cpp:5 knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/API/src/FunctionFactory.cpp:267 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/ITableWorkspace.cpp:118 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/IMDHistoWorkspace.cpp:54 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/WeightedMeanOfWorkspace.cpp:63 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/API/src/IMDEventWorkspace.cpp:50 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/IMDEventWorkspace.cpp:85 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/IMDEventWorkspace.cpp:92 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/API/src/NumericAxis.cpp:166 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/API/src/ParameterReference.cpp:52 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/API/src/MultiDomainFunction.cpp:135 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/API/src/MultiDomainFunction.cpp:174 @@ -442,7 +433,6 @@ uselessCallsSubstr:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/PeakHKLErrors.cpp:6 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/CentroidPeaks.cpp:75 passedByValue:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/LoadIsawSpectrum.cpp:190 passedByValue:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/LoadIsawSpectrum.cpp:191 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/GoniometerAnglesFromPhiRotation.cpp:306 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/FindSXPeaks.cpp:223 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/SCDCalibratePanels2ObjFunc.cpp:286 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Crystal/src/SelectCellWithForm.cpp:134 @@ -627,7 +617,6 @@ uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandlin passedByValue:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/BitStream.h:30 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadANSTOHelper.cpp:210 variableScope:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/DetermineChunking.cpp:163 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadANSTOHelper.cpp:436 uselessCallsSubstr:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadFITS.cpp:547 uninitMemberVarPrivate:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadHFIRSANS.h:124 uninitMemberVarPrivate:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadHFIRSANS.h:125 @@ -684,7 +673,6 @@ constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNe constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:641 constParameterReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:661 constParameterReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadTBL.cpp:133 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadTBL.cpp:162 constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadPreNexus.cpp:244 returnByReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h:30 returnByReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h:31 @@ -741,8 +729,6 @@ knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/CoordTrans constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/CoordTransformAffine.cpp:277 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/CoordTransformAffine.cpp:357 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/CoordTransformAffine.cpp:368 -constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/SavePHX.cpp:77 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/SavePHX.cpp:50 missingOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/SaveOpenGenieAscii.h:23 uninitMemberVarPrivate:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h:79 internalError:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/MDBoxSaveable.cpp:0 @@ -870,7 +856,6 @@ invalidPointerCast:${CMAKE_SOURCE_DIR}/Framework/LiveData/inc/MantidLiveData/ADA invalidPointerCast:${CMAKE_SOURCE_DIR}/Framework/LiveData/inc/MantidLiveData/ADARA/ADARAPackets.h:679 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp:170 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp:126 -unreadVariable:${CMAKE_SOURCE_DIR}/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp:316 badBitmaskCheck:${CMAKE_SOURCE_DIR}/Framework/LiveData/inc/MantidLiveData/ISIS/TCPEventStreamDefs.h:70 unsignedPositive:${CMAKE_SOURCE_DIR}/Framework/LiveData/inc/MantidLiveData/ISIS/TCPEventStreamDefs.h:61 identicalInnerCondition:${CMAKE_SOURCE_DIR}/Framework/LiveData/src/ADARA/ADARAPackets.cpp:220 @@ -1157,9 +1142,6 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/AlgorithmDialog.c constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/AlgorithmDialog.cpp:902 constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/AlgorithmDialog.cpp:904 returnByReference:${CMAKE_SOURCE_DIR}/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h:50 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp:299 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp:404 -unreadVariable:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp:294 returnByReference:${CMAKE_SOURCE_DIR}/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h:45 missingOverride:${CMAKE_SOURCE_DIR}/qt/widgets/common/inc/MantidQtWidgets/Common/ConfiguredAlgorithm.h:19 returnByReference:${CMAKE_SOURCE_DIR}/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h:73 @@ -1248,16 +1230,8 @@ virtualCallInConstructor:${CMAKE_SOURCE_DIR}/qt/widgets/common/inc/MantidQtWidge returnByReference:${CMAKE_SOURCE_DIR}/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptEditor.h:63 constVariableReference:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/ScriptRepositoryView.cpp:113 constParameterPointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:107 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:394 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:634 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:674 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:698 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:711 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:728 -constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:966 +constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:960 unassignedVariable:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:50 -unreadVariable:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:506 -unreadVariable:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/RepoModel.cpp:514 constVariablePointer:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/TextPropertyWidget.cpp:39 virtualCallInConstructor:${CMAKE_SOURCE_DIR}/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h:107 useStlAlgorithm:${CMAKE_SOURCE_DIR}/qt/widgets/common/src/FunctionTreeView.cpp:974 diff --git a/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp b/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp index 7bf6d1f0785f..f4ab15341217 100644 --- a/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp +++ b/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp @@ -291,16 +291,15 @@ void AlgorithmPropertiesWidget::replaceWSClicked(const QString &propName) { using CollectionOfPropertyWidget = std::vector; CollectionOfPropertyWidget candidateReplacementSources; // Find the name to put in the spot - QString wsName(""); for (auto it = m_propWidgets.begin(); it != m_propWidgets.end(); it++) { // Only look at workspace properties PropertyWidget *otherWidget = it.value(); Property *prop = it.value()->getProperty(); - IWorkspaceProperty *wsProp = dynamic_cast(prop); + const IWorkspaceProperty *wsProp = dynamic_cast(prop); if (otherWidget && wsProp) { if (prop->direction() == Direction::Input) { // Input workspace property. Get the text typed in. - wsName = otherWidget->getValue(); + QString wsName = otherWidget->getValue(); if (!wsName.isEmpty()) { // Add the candidate to the list of candidates. candidateReplacementSources.emplace_back(otherWidget); @@ -401,7 +400,7 @@ void AlgorithmPropertiesWidget::hideOrDisableProperties(const QString &changedPr // set Visible and Enabled as appropriate for (auto &widget : m_propWidgets) { Mantid::Kernel::Property *prop = widget->getProperty(); - IPropertySettings *settings = prop->getSettings(); + const IPropertySettings *settings = prop->getSettings(); const auto &propName = QString::fromStdString(prop->name()); // Set the enabled and visible flags based on what the validators say. diff --git a/qt/widgets/common/src/RepoModel.cpp b/qt/widgets/common/src/RepoModel.cpp index 8d76d9360f35..6ff2b560bf3b 100644 --- a/qt/widgets/common/src/RepoModel.cpp +++ b/qt/widgets/common/src/RepoModel.cpp @@ -391,7 +391,7 @@ bool RepoModel::setData(const QModelIndex &index, const QVariant &value, int rol // the path can not be changed return false; int count_changed = 0; - auto *item = static_cast(index.internalPointer()); + const auto *item = static_cast(index.internalPointer()); std::string path = item->path().toStdString(); bool ret = false; @@ -498,21 +498,15 @@ bool RepoModel::setData(const QModelIndex &index, const QVariant &value, int rol return false; } // query the user if he wants to delete only locally or remote as well. - auto *box = new DeleteQueryBox(QString::fromStdString(path), father); + auto box = DeleteQueryBox(QString::fromStdString(path), father); - if (box->exec() != QMessageBox::Yes) { + if (box.exec() != QMessageBox::Yes) { // the user gave up deleting this entry, release memory - delete box; - box = nullptr; return false; } // get the options from the user - QString comment(box->comment()); - { // release memory - delete box; - box = nullptr; - } + QString comment(box.comment()); // remove from central repository // currently, directories can not be deleted recursively @@ -631,7 +625,7 @@ QModelIndex RepoModel::index(int row, int column, const QModelIndex &parent) con if (!hasIndex(row, column, parent)) return QModelIndex(); // retrieve the pointer ot the RepoItem from the parent - RepoItem *parentItem; + const RepoItem *parentItem; if (!parent.isValid()) parentItem = rootItem; else @@ -671,7 +665,7 @@ QModelIndex RepoModel::parent(const QModelIndex &index) const { * @return the number of children of the given folder. */ int RepoModel::rowCount(const QModelIndex &parent) const { - RepoItem *parentItem; + const RepoItem *parentItem; if (parent.column() > 0) return 0; // there are rows defined only of the column 0 @@ -695,7 +689,7 @@ int RepoModel::columnCount(const QModelIndex & /*parent*/) const { return 4; } /** Return the description of the file for a defined entry **/ QString RepoModel::fileDescription(const QModelIndex &index) { - auto *item = static_cast(index.internalPointer()); + const auto *item = static_cast(index.internalPointer()); if (!item) return ""; QString desc; @@ -708,7 +702,7 @@ QString RepoModel::fileDescription(const QModelIndex &index) { } QString RepoModel::author(const QModelIndex &index) { - auto *item = static_cast(index.internalPointer()); + const auto *item = static_cast(index.internalPointer()); QString author = "Not defined"; if (!item) return author; @@ -725,7 +719,7 @@ QString RepoModel::author(const QModelIndex &index) { @return The operative system path or empty string */ QString RepoModel::filePath(const QModelIndex &index) { - auto *item = static_cast(index.internalPointer()); + const auto *item = static_cast(index.internalPointer()); // qDebug() << "Get file path from : " << item->path()<< '\n'; Mantid::API::SCRIPTSTATUS state = repo_ptr->fileStatus(item->path().toStdString()); From 33e797e8852159f6a9c1c8058939aa825bf57399 Mon Sep 17 00:00:00 2001 From: Waruna Wickramasingha Date: Thu, 12 Sep 2024 12:21:56 +0100 Subject: [PATCH 12/17] Fixed FindPeaksConvolve's racing condition to fix the test failure This is a squashed version of #38092 Release notes added --- .../inc/MantidAlgorithms/FindPeaksConvolve.h | 2 +- Framework/Algorithms/src/FindPeaksConvolve.cpp | 15 ++++++++------- Framework/Algorithms/test/FindPeaksConvolveTest.h | 9 ++++++--- .../Framework/Algorithms/Bugfixes/37752.rst | 1 + 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/37752.rst diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaksConvolve.h b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaksConvolve.h index ae5121b0668c..6f95cd3c6983 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaksConvolve.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaksConvolve.h @@ -66,7 +66,7 @@ class MANTID_ALGORITHMS_DLL FindPeaksConvolve : public API::Algorithm { bool m_centreBins; Eigen::VectorXd m_pdf; std::vector m_intermediateWsNames; - std::mutex mtx; + std::mutex m_mtx; void init() override; void exec() override; diff --git a/Framework/Algorithms/src/FindPeaksConvolve.cpp b/Framework/Algorithms/src/FindPeaksConvolve.cpp index 381761fb1bac..0f23b8a57329 100644 --- a/Framework/Algorithms/src/FindPeaksConvolve.cpp +++ b/Framework/Algorithms/src/FindPeaksConvolve.cpp @@ -88,8 +88,12 @@ void FindPeaksConvolve::exec() { } PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputDataWS)) for (int i = 0; i < static_cast(m_specCount); i++) { + PARALLEL_START_INTERRUPT_REGION performConvolution(i); + PARALLEL_END_INTERRUPT_REGION } + PARALLEL_CHECK_INTERRUPT_REGION + outputResults(); } @@ -186,7 +190,6 @@ void FindPeaksConvolve::performConvolution(const size_t dataIndex) { " exceeds the range of the x axis. Please reduce the peak extent."); } else { const Tensor1D kernel{createKernel(static_cast(kernelBinCount.first))}; - const auto binCount{m_inputDataWS->getNumberBins(specNum)}; // Edge handling is performed by padding the input data with 0 values. Each convolution requires a padding of kernel // size + 1. The 1st conv is performed with a kernel of size n, the second size n/2. The resultant pad is split @@ -198,20 +201,16 @@ void FindPeaksConvolve::performConvolution(const size_t dataIndex) { const auto yData_padded{yData.pad(paddings)}; const Eigen::array dims({0}); const Tensor1D yConvOutput{yData_padded.convolve(kernel, dims)}; - const auto eData{TensorMap_const{&m_inputDataWS->e(specNum).front(), binCount}.pad(paddings)}; const Tensor1D eConvOutput{eData.square().convolve(kernel.square(), dims).sqrt()}; - const Tensor1D smoothKernel{ createSmoothKernel(static_cast(std::ceil(static_cast(kernelBinCount.first) / 2.0)))}; Tensor1D iOverSig{(yConvOutput / eConvOutput).unaryExpr([](double val) { return std::isfinite(val) ? val : 0.0; })}; const Tensor1D iOverSigConvOutput{iOverSig.convolve(smoothKernel, dims)}; - extractPeaks(dataIndex, iOverSigConvOutput, xData, yData, kernelBinCount.first / 2); - if (m_createIntermediateWorkspaces) { auto wsNames = createIntermediateWorkspaces(dataIndex, kernel, iOverSigConvOutput, xData); - std::lock_guard lock(mtx); + std::lock_guard lock(m_mtx); m_intermediateWsNames.insert(m_intermediateWsNames.end(), wsNames.cbegin(), wsNames.cend()); } } @@ -310,6 +309,7 @@ void FindPeaksConvolve::storePeakResults(const size_t dataIndex, if (peakCount > m_maxPeakCount) { m_maxPeakCount = peakCount; } + std::lock_guard lock(m_mtx); m_peakResults[dataIndex] = std::move(peakCentres); } } @@ -349,6 +349,7 @@ size_t FindPeaksConvolve::findPeakInRawData(const int xIndex, const TensorMap_co void FindPeaksConvolve::generateNormalPDF(const int peakExtentBinNumber) { std::lock_guard lock(m_mtx); if (m_pdf.size() == 0) { + std::lock_guard lock(m_mtx); m_pdf.resize(peakExtentBinNumber); boost::math::normal_distribution<> dist(0.0, peakExtentBinNumber / 2.0); // assures 2 stddevs in the resultant vector @@ -459,7 +460,7 @@ std::string FindPeaksConvolve::populateOutputWorkspaces( row << m_specNums[i]; for (size_t peak_i{0}; peak_i < m_maxPeakCount; peak_i++) { if (peak_i < spec.size()) { - auto peak = spec[peak_i]; + const auto &peak = spec[peak_i]; row << peak.getAttribute(outputTblName); } else { row << std::nan(""); diff --git a/Framework/Algorithms/test/FindPeaksConvolveTest.h b/Framework/Algorithms/test/FindPeaksConvolveTest.h index 10c5867cc4e1..6d6501e9350d 100644 --- a/Framework/Algorithms/test/FindPeaksConvolveTest.h +++ b/Framework/Algorithms/test/FindPeaksConvolveTest.h @@ -10,6 +10,7 @@ #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/FrameworkManager.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidAlgorithms/FindPeaksConvolve.h" @@ -69,11 +70,13 @@ class FindPeaksConvolveTest : public CxxTest::TestSuite { static FindPeaksConvolveTest *createSuite() { return new FindPeaksConvolveTest(); } static void destroySuite(FindPeaksConvolveTest *suite) { delete suite; } + FindPeaksConvolveTest() { Mantid::API::FrameworkManager::Instance(); } + void setUp() override { // Load data file into ADS once - loadNexusProcessed("ENGINX_277208_focused_bank_2.nxs", INPUT_TEST_WS_NAME); - loadNexusProcessed("VesuvioCalibSpec177.nxs", INPUT_TEST_WS_NAME + "_noisy"); - loadNexusProcessed("focussed.nxs", INPUT_TEST_WS_NAME + "_focussed"); + TS_ASSERT_THROWS_NOTHING(loadNexusProcessed("ENGINX_277208_focused_bank_2.nxs", INPUT_TEST_WS_NAME)); + TS_ASSERT_THROWS_NOTHING(loadNexusProcessed("VesuvioCalibSpec177.nxs", INPUT_TEST_WS_NAME + "_noisy")); + TS_ASSERT_THROWS_NOTHING(loadNexusProcessed("focussed.nxs", INPUT_TEST_WS_NAME + "_focussed")); } void test_exec() { diff --git a/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/37752.rst b/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/37752.rst new file mode 100644 index 000000000000..398bf51084f0 --- /dev/null +++ b/docs/source/release/v6.12.0/Framework/Algorithms/Bugfixes/37752.rst @@ -0,0 +1 @@ +- Fixed a segmentation fault in :ref:`FindPeaksConvolve ` algorithm due to a racing condition in the parallel loop. The issue was first observed as a flaky unit test failure in the CI. From c88453e1badaa271affd1c21d282ddabac6ef94b Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Thu, 21 Nov 2024 10:34:19 -0500 Subject: [PATCH 13/17] Move to matplotlib v3.9 This is a squash of #38435 Modify test that bounding box is bigger than the shape The other checks that the 3d view is cubic remain Fix IntegratePeaksSkew 'x must be a sequence' Change listed in mpl 3.9 release notes https://matplotlib.org/3.9.0/api/prev_api_changes/api_changes_3.9.0.html#line2d Update release note to include link for matplotlib 3.9 --- .../plugins/algorithms/IntegratePeaksSkew.py | 12 ++++++------ conda/recipes/conda_build_config.yaml | 2 +- .../Framework/Dependencies/New_features/38077.rst | 2 +- .../mantidqt/plotting/test/test_sample_shape.py | 4 ++-- .../mantidqt/widgets/plotconfigdialog/__init__.py | 2 +- .../plotconfigdialog/curvestabwidget/__init__.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksSkew.py b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksSkew.py index 48bdc5c4242b..4a6adfeaa0d4 100644 --- a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksSkew.py +++ b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksSkew.py @@ -651,16 +651,16 @@ def plot_integrated_peak(self, fig, ax, ipk, norm_func): xmask, ymask = np.where(self.peak_mask.T) ax[0].lines[0].set_xdata(xmask) ax[0].lines[0].set_ydata(ymask) - ax[0].lines[1].set_xdata(self.icol) - ax[0].lines[1].set_ydata(self.irow) + ax[0].lines[1].set_xdata([self.icol]) + ax[0].lines[1].set_ydata([self.irow]) img.set_extent([-0.5, self.x_integrated_data.shape[1] - 0.5, self.x_integrated_data.shape[0] - 0.5, -0.5]) # update 1D focused spectrum # vlines xmin_line, xmax_line, data, xpos_line, xmin_init_line, xmax_init_line, y0 = ax[1].lines - xmin_line.set_xdata(self.xmin_opt) - xmax_line.set_xdata(self.xmax_opt) - xmin_init_line.set_xdata(self.xmin) - xmax_init_line.set_xdata(self.xmax) + xmin_line.set_xdata([self.xmin_opt]) + xmax_line.set_xdata([self.xmax_opt]) + xmin_init_line.set_xdata([self.xmin]) + xmax_init_line.set_xdata([self.xmax]) xpos_line.set_xdata([self.xpos]) # spectrum yerr = np.sqrt(self.epk_sq[istart:iend]) diff --git a/conda/recipes/conda_build_config.yaml b/conda/recipes/conda_build_config.yaml index 4535c9778e89..3d6e62039169 100644 --- a/conda/recipes/conda_build_config.yaml +++ b/conda/recipes/conda_build_config.yaml @@ -66,7 +66,7 @@ numpy: - 2.0.* matplotlib: - - 3.8.* + - 3.9.* ninja: - '>=1.10.2' diff --git a/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38077.rst b/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38077.rst index 0e63b094dbab..1216a6c2376d 100644 --- a/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38077.rst +++ b/docs/source/release/v6.12.0/Framework/Dependencies/New_features/38077.rst @@ -1 +1 @@ -- Updated Matplotlib from version 3.7 to version 3.8. The release notes for version 3.8 can be found `here `_ . +- Updated Matplotlib from version 3.7 to version 3.9. The release notes for `version 3.8 `_ and `version 3.9 `_ diff --git a/qt/python/mantidqt/mantidqt/plotting/test/test_sample_shape.py b/qt/python/mantidqt/mantidqt/plotting/test/test_sample_shape.py index 20e735d4469c..7c37722b8604 100644 --- a/qt/python/mantidqt/mantidqt/plotting/test/test_sample_shape.py +++ b/qt/python/mantidqt/mantidqt/plotting/test/test_sample_shape.py @@ -8,7 +8,7 @@ # # -from numpy.testing import assert_array_equal, assert_allclose, assert_almost_equal +from numpy.testing import assert_array_equal, assert_allclose, assert_array_less from os import path, remove from tempfile import gettempdir from unittest import TestCase, main @@ -268,7 +268,7 @@ def test_set_axes_to_largest_mesh(self, mock_call_overall_limits_for_all_meshes) xlim = axes.get_xlim() ylim = axes.get_ylim() zlim = axes.get_zlim() - assert_almost_equal(xlim, (-0.165, 0.165), 5) # extra 5% + assert_array_less((0.15, 0.15), np.abs(xlim)) # window is bigger than object 15cm assert_allclose(xlim, ylim, rtol=self.RELATIVE_TOLERANCE) assert_allclose(xlim, zlim, rtol=self.RELATIVE_TOLERANCE) diff --git a/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/__init__.py b/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/__init__.py index 387d6bb9294d..1108f02bb03c 100644 --- a/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/__init__.py +++ b/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/__init__.py @@ -7,7 +7,7 @@ # This file is part of the mantid workbench. from mantid.plots.utility import row_num, col_num -from matplotlib.axes import ErrorbarContainer +from matplotlib.container import ErrorbarContainer from matplotlib.collections import QuadMesh from mpl_toolkits.mplot3d.art3d import Poly3DCollection diff --git a/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py b/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py index fe50bf9959e4..6a03cc822d72 100644 --- a/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py +++ b/qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py @@ -7,7 +7,7 @@ # This file is part of the mantid workbench. from matplotlib import rcParams -from matplotlib.axes import ErrorbarContainer +from matplotlib.container import ErrorbarContainer from matplotlib.lines import Line2D from numpy import isclose from qtpy.QtCore import Qt From 551fc1606cc1c86a5a870dec4f26a1338a78500d Mon Sep 17 00:00:00 2001 From: Pete Peterson Date: Tue, 26 Nov 2024 11:44:10 -0500 Subject: [PATCH 14/17] Copy file from main --- Framework/Algorithms/src/FindPeaksConvolve.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Framework/Algorithms/src/FindPeaksConvolve.cpp b/Framework/Algorithms/src/FindPeaksConvolve.cpp index 0f23b8a57329..e41aeaeed4bf 100644 --- a/Framework/Algorithms/src/FindPeaksConvolve.cpp +++ b/Framework/Algorithms/src/FindPeaksConvolve.cpp @@ -349,7 +349,6 @@ size_t FindPeaksConvolve::findPeakInRawData(const int xIndex, const TensorMap_co void FindPeaksConvolve::generateNormalPDF(const int peakExtentBinNumber) { std::lock_guard lock(m_mtx); if (m_pdf.size() == 0) { - std::lock_guard lock(m_mtx); m_pdf.resize(peakExtentBinNumber); boost::math::normal_distribution<> dist(0.0, peakExtentBinNumber / 2.0); // assures 2 stddevs in the resultant vector From 8c2df39d6e4b1f9c25f16fd17396b9d8b05c238e Mon Sep 17 00:00:00 2001 From: Silke Schomann Date: Fri, 25 Oct 2024 08:37:36 +0100 Subject: [PATCH 15/17] Use Mslice as conda package instead of an external interface This is a squashed versino of #38299 Moved mslice from mantid to mantidworkbench recipe Add mantid channel to conda build command Only pass channel to mantid-developer and mantidworkbench Removed quotation marks from channel option Added space after debug option back Use classic solver with mamba Corrected solver argument Install classic solver Add mantid channel via conda config Add conda-forge after mantid for higher priority Use Mslice with seperate_mslice_test label Updated copyright year Only install mslice for workbench Added release note Use mantid/label/main instead of mantid Updated installers and pinned mslice to 2.10 Check for correct MSlice version before building release of Mantid Updated mslice interface Update dev-docs/source/ReleaseChecklist.rst Co-authored-by: Jonathan Haigh <35813666+jhaigh0@users.noreply.github.com> Update installers/conda/win/create_package.sh Co-authored-by: thomashampson --- buildconfig/Jenkins/Conda/package-conda | 2 +- conda/recipes/conda_build_config.yaml | 3 ++ conda/recipes/mantidworkbench/meta.yaml | 1 + dev-docs/source/ReleaseChecklist.rst | 7 ++- .../MSlice/New_features/38299.rst | 1 + installers/conda/linux/create_tarball.sh | 2 +- installers/conda/osx/create_bundle.sh | 2 +- installers/conda/win/create_package.sh | 2 +- .../mantidqtinterfaces/MSlice.py | 20 ++++++--- scripts/CMakeLists.txt | 5 --- scripts/ExternalInterfaces/CMakeLists.txt | 45 ------------------- 11 files changed, 26 insertions(+), 64 deletions(-) create mode 100644 docs/source/release/v6.12.0/Direct_Geometry/MSlice/New_features/38299.rst delete mode 100644 scripts/ExternalInterfaces/CMakeLists.txt diff --git a/buildconfig/Jenkins/Conda/package-conda b/buildconfig/Jenkins/Conda/package-conda index 72650a3a42ae..55ed9edd059e 100755 --- a/buildconfig/Jenkins/Conda/package-conda +++ b/buildconfig/Jenkins/Conda/package-conda @@ -142,7 +142,7 @@ if [[ $ENABLE_BUILD_WORKBENCH == true ]]; then if [[ $BUILD_WORKBENCH_WITH_DOCS == false ]]; then export INCLUDE_MANTIDDOCS=False fi - conda mambabuild ./mantidworkbench/ $EXTRA_BUILD_OPTIONS + conda mambabuild ./mantidworkbench/ -c mantid/label/main $EXTRA_BUILD_OPTIONS fi # elapsed time with second resolution diff --git a/conda/recipes/conda_build_config.yaml b/conda/recipes/conda_build_config.yaml index 3d6e62039169..49ddc8254b99 100644 --- a/conda/recipes/conda_build_config.yaml +++ b/conda/recipes/conda_build_config.yaml @@ -68,6 +68,9 @@ numpy: matplotlib: - 3.9.* +mslice: + - '2.10' + ninja: - '>=1.10.2' diff --git a/conda/recipes/mantidworkbench/meta.yaml b/conda/recipes/mantidworkbench/meta.yaml index 9ec8fb21a0c1..d371bc47edf9 100644 --- a/conda/recipes/mantidworkbench/meta.yaml +++ b/conda/recipes/mantidworkbench/meta.yaml @@ -41,6 +41,7 @@ requirements: - psutil {{ psutil }} - {{ pin_compatible("python", max_pin="x.x") }} - matplotlib {{ matplotlib }} + - mslice {{ mslice }} - python.app # [osx] - qtconsole {{ qtconsole }} - {{ pin_compatible("setuptools", max_pin="x.x") }} diff --git a/dev-docs/source/ReleaseChecklist.rst b/dev-docs/source/ReleaseChecklist.rst index 8167c4382253..08d44a3071ce 100644 --- a/dev-docs/source/ReleaseChecklist.rst +++ b/dev-docs/source/ReleaseChecklist.rst @@ -480,9 +480,6 @@ have been fixed. Then: * Check the release notes and verify that the "Under Construction" paragraph on the main index page has been removed. Remove the paragraph if it still exists. * Ensure that all changes, including release notes, have been merged into the ``release-next`` branch. -* On the ``release-next`` branch, check whether the `git SHA - `__ - for MSlice is up to date. If not, create a PR to update it and ask a gatekeeper to merge it. * Make sure the ``release-next`` branch is fully merged into ``main``. If required, manually run the `GitHub workflow `__ using the ``release-next`` branch to merge the changes. @@ -523,7 +520,9 @@ Create Final Release Candidates ############################### Check with the Quality Assurance Manager that the Smoke testing has been completed, and any issues -have been fixed. The release candidates must now be recreated with their final version numbers. To do this, build the +have been fixed. Additionally, ensure that the version of the ``mslice`` package in ``conda_build_config.yaml`` is correct. +If there have been any updates to MSlice since the last release, it must be released first. The release candidates must +now be recreated with their final version numbers. To do this, build the `release-next_nightly_deployment Jenkins pipeline `__ with the following parameters (most are already defaulted to the correct values): diff --git a/docs/source/release/v6.12.0/Direct_Geometry/MSlice/New_features/38299.rst b/docs/source/release/v6.12.0/Direct_Geometry/MSlice/New_features/38299.rst new file mode 100644 index 000000000000..8d03377f9b57 --- /dev/null +++ b/docs/source/release/v6.12.0/Direct_Geometry/MSlice/New_features/38299.rst @@ -0,0 +1 @@ +- MSlice is now installed via Conda as part of Mantid workbench and not compiled as an external project anymore. diff --git a/installers/conda/linux/create_tarball.sh b/installers/conda/linux/create_tarball.sh index f2916665d61a..eb9e1f24757a 100755 --- a/installers/conda/linux/create_tarball.sh +++ b/installers/conda/linux/create_tarball.sh @@ -134,7 +134,7 @@ bundle_conda_prefix="$bundle_contents" echo "Creating Conda environment in '$bundle_conda_prefix'" "$CONDA_EXE" create --quiet --prefix "$bundle_conda_prefix" --copy \ - --channel "$conda_channel" --channel conda-forge --yes \ + --channel "$conda_channel" --channel conda-forge --channel mantid --yes \ mantidworkbench \ jq # used for processing the version string echo diff --git a/installers/conda/osx/create_bundle.sh b/installers/conda/osx/create_bundle.sh index 790642365403..cc2f24583ec1 100755 --- a/installers/conda/osx/create_bundle.sh +++ b/installers/conda/osx/create_bundle.sh @@ -203,7 +203,7 @@ bundle_conda_prefix="$bundle_contents"/Resources echo "Creating Conda environment in '$bundle_conda_prefix'" "$CONDA_EXE" create --quiet --prefix "$bundle_conda_prefix" --copy --platform osx-64 \ - --channel "$conda_channel" --channel conda-forge --yes \ + --channel "$conda_channel" --channel conda-forge --channel mantid --yes \ mantidworkbench \ jq # used for processing the version string echo diff --git a/installers/conda/win/create_package.sh b/installers/conda/win/create_package.sh index e2d733d2a282..2225f4a93395 100755 --- a/installers/conda/win/create_package.sh +++ b/installers/conda/win/create_package.sh @@ -74,7 +74,7 @@ mkdir $COPY_DIR echo "Creating conda env from mantidworkbench and jq" "$CONDA_EXE" create --prefix $CONDA_ENV_PATH \ - --copy --channel $CONDA_CHANNEL --channel conda-forge -y \ + --copy --channel $CONDA_CHANNEL --channel conda-forge --channel mantid -y \ mantidworkbench \ m2w64-jq echo "Conda env created" diff --git a/qt/python/mantidqtinterfaces/mantidqtinterfaces/MSlice.py b/qt/python/mantidqtinterfaces/mantidqtinterfaces/MSlice.py index 77eb5ac96f72..94b52b115692 100755 --- a/qt/python/mantidqtinterfaces/mantidqtinterfaces/MSlice.py +++ b/qt/python/mantidqtinterfaces/mantidqtinterfaces/MSlice.py @@ -1,15 +1,23 @@ #!/usr/bin/python # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import sys -from mslice.app import show_gui from mantidqt.gui_helper import get_qapplication -app, within_mantid = get_qapplication() -show_gui() -if not within_mantid: - sys.exit(app.exec_()) +try: + from mslice.app import show_gui +except ImportError: + from mantid.kernel import logger + + logger.warning("MSlice is not available") + show_gui = None + +if show_gui is not None: + app, within_mantid = get_qapplication() + show_gui() + if not within_mantid: + sys.exit(app.exec_()) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 776e1e522de5..112610d4ff88 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,6 +1,3 @@ -# External GUIs -add_subdirectory(ExternalInterfaces) - # External projects include(PyStoG) @@ -29,8 +26,6 @@ foreach(_dir ${_pth_dirs}) list(APPEND _pth_list_install "${_scripts_rel_path}/${_dir}") endforeach() list(APPEND _pth_list_dev ${CMAKE_CURRENT_BINARY_DIR}) -list(APPEND _pth_list_dev ${MSLICE_DEV}) -list(APPEND _pth_list_install "${_scripts_rel_path}/ExternalInterfaces") # development copy set(_scripts_pth_src "${CMAKE_CURRENT_BINARY_DIR}/mantid-scripts.pth.src") diff --git a/scripts/ExternalInterfaces/CMakeLists.txt b/scripts/ExternalInterfaces/CMakeLists.txt deleted file mode 100644 index eebefb879b98..000000000000 --- a/scripts/ExternalInterfaces/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# Fetch any externally-managed interfaces -include(ExternalProject) - -# mslice -set(_mslice_external_root ${CMAKE_CURRENT_BINARY_DIR}/src/mslice) -externalproject_add( - mslice - PREFIX ${_mslice_external_root} - UPDATE_DISCONNECTED "false" - GIT_REPOSITORY "https://github.com/mantidproject/mslice.git" - GIT_TAG 94705e4fd83f15548d230fee6f2df76b350fc815 - EXCLUDE_FROM_ALL 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - TEST_COMMAND "" - INSTALL_COMMAND "" -) -message(STATUS "Fetching/updating mslice") -execute_process( - COMMAND ${CMAKE_COMMAND} ARGS -P ${_mslice_external_root}/tmp/mslice-gitclone.cmake RESULT_VARIABLE _exit_code -) -if(_exit_code EQUAL 0) - execute_process( - COMMAND ${CMAKE_COMMAND} ARGS -P ${_mslice_external_root}/tmp/mslice-gitupdate.cmake RESULT_VARIABLE _exit_code - ) - if(NOT _exit_code EQUAL 0) - message(FATAL_ERROR "Unable to update mslice.") - endif() -else() - message(FATAL_ERROR "Unable to clone mslice") -endif() -# Let the parent lists file know where dev copy of mslice is -set(MSLICE_DEV - ${_mslice_external_root}/src/mslice/src - PARENT_SCOPE -) - -# Installation MSLICE_DEV is only set in PARENT_SCOPE! so don't use it here -foreach(_bundle ${BUNDLES}) - install( - DIRECTORY ${_mslice_external_root}/src/mslice/src/mslice/ - DESTINATION ${_bundle}scripts/ExternalInterfaces/mslice - COMPONENT Runtime - ) -endforeach() From 1c27e7f48af17e7a30ff399898032a737e9616ce Mon Sep 17 00:00:00 2001 From: Caila Finn <47181718+cailafinn@users.noreply.github.com> Date: Mon, 2 Dec 2024 09:40:00 +0000 Subject: [PATCH 16/17] Pin Poco away from 1.14.0 Breaking change to HTTPSClientSession in latest Poco version. --- conda/recipes/conda_build_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/conda_build_config.yaml b/conda/recipes/conda_build_config.yaml index 49ddc8254b99..a8d6e5d98ca7 100644 --- a/conda/recipes/conda_build_config.yaml +++ b/conda/recipes/conda_build_config.yaml @@ -85,7 +85,7 @@ orsopy: # 1.12.2 introduced an unguarded #define NOMINMAX which causes a compiler warning. # It's resolved on their devel branch but not yet included in a release, as of 1.12.5. poco: - - 1.12.1|>=1.12.6 + - '1.12.1|>=1.12.6,!=1.14.0' psutil: - '>=5.8.0' From f7128fcbc081832cdc7368b36aa26f91f99f206c Mon Sep 17 00:00:00 2001 From: James Clarke Date: Mon, 2 Dec 2024 10:52:11 +0000 Subject: [PATCH 17/17] Switch to available constructor in Poco 1.14 This is a squash of #38461 Remove 1.14 Poco pin Remove old Poco CMake code These bits of CMake were preventing the solution compiling on Windows. 1.4.6 is around 10 years old. Remove old Poco pin The latest version is 1.14, so no need to keep bit of the pin for 1.12.1 Update pin and comment The new HTTPSClientSession API won't work with Poco < 1.14, so we need to pin it to at least 1.14 --- Framework/API/test/FileFinderTest.h | 6 +++--- Framework/ICat/src/CatalogDownloadDataFiles.cpp | 4 +--- buildconfig/CMake/CommonSetup.cmake | 3 +-- conda/recipes/conda_build_config.yaml | 5 ++--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Framework/API/test/FileFinderTest.h b/Framework/API/test/FileFinderTest.h index ddcc8b37de8c..73934c643a6c 100644 --- a/Framework/API/test/FileFinderTest.h +++ b/Framework/API/test/FileFinderTest.h @@ -477,9 +477,9 @@ class FileFinderTest : public CxxTest::TestSuite { TS_ASSERT(fileOn3.exists()); TS_ASSERT(fileOn4.exists()); #else - TS_ASSERT_THROWS_ANYTHING(fileOn2.exists()); - TS_ASSERT_THROWS_ANYTHING(fileOn3.exists()); - TS_ASSERT_THROWS_ANYTHING(fileOn4.exists()); + TS_ASSERT(!fileOn2.exists()); + TS_ASSERT(!fileOn3.exists()); + TS_ASSERT(!fileOn4.exists()); #endif fileFinder.setCaseSensitive(startingCaseOption); diff --git a/Framework/ICat/src/CatalogDownloadDataFiles.cpp b/Framework/ICat/src/CatalogDownloadDataFiles.cpp index 5892a56cf825..4dde18fe5900 100644 --- a/Framework/ICat/src/CatalogDownloadDataFiles.cpp +++ b/Framework/ICat/src/CatalogDownloadDataFiles.cpp @@ -155,9 +155,7 @@ std::string CatalogDownloadDataFiles::doDownloadandSavetoLocalDrive(const std::s // Session takes ownership of socket Poco::Net::SecureStreamSocket socket{context}; - Poco::Net::HTTPSClientSession session{socket}; - session.setHost(uri.getHost()); - session.setPort(uri.getPort()); + Poco::Net::HTTPSClientSession session{socket, uri.getHost(), uri.getPort()}; Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, path, Poco::Net::HTTPMessage::HTTP_1_1); session.sendRequest(request); diff --git a/buildconfig/CMake/CommonSetup.cmake b/buildconfig/CMake/CommonSetup.cmake index 484a66b12634..24c39a5deaf5 100644 --- a/buildconfig/CMake/CommonSetup.cmake +++ b/buildconfig/CMake/CommonSetup.cmake @@ -82,8 +82,7 @@ if(BUILD_MANTIDFRAMEWORK OR BUILD_MANTIDQT) # The new interface is not available in Clang yet so we haven't migrated add_definitions(-D_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING) - find_package(Poco 1.4.6 REQUIRED) - add_definitions(-DPOCO_ENABLE_CPP11) + find_package(Poco REQUIRED) find_package(TBB REQUIRED) find_package(OpenSSL REQUIRED) endif() diff --git a/conda/recipes/conda_build_config.yaml b/conda/recipes/conda_build_config.yaml index a8d6e5d98ca7..77415f3bee79 100644 --- a/conda/recipes/conda_build_config.yaml +++ b/conda/recipes/conda_build_config.yaml @@ -82,10 +82,9 @@ occt: orsopy: - 1.2.1 -# 1.12.2 introduced an unguarded #define NOMINMAX which causes a compiler warning. -# It's resolved on their devel branch but not yet included in a release, as of 1.12.5. +# An API change to HTTPSClientSession was introduced in 1.14.0 poco: - - '1.12.1|>=1.12.6,!=1.14.0' + - '>=1.14' psutil: - '>=5.8.0'