diff --git a/Framework/Indexing/src/IndexInfo.cpp b/Framework/Indexing/src/IndexInfo.cpp index db12c33e2f0ba9273e8a1607d046f09406b3435f..27d4bc0701c23ba4edf86b7abbcf7fde88f4cb74 100644 --- a/Framework/Indexing/src/IndexInfo.cpp +++ b/Framework/Indexing/src/IndexInfo.cpp @@ -229,9 +229,8 @@ SpectrumIndexSet IndexInfo::makeIndexSet( /** Map a vector of detector indices to a vector of global spectrum indices. * * The mapping is based on the held spectrum definitions. Throws if any spectrum - * maps to more than one detectors. Throws if there is no 1:1 mapping from - * detectors to spectra, such as when some of the detectors have no matching - * spectrum. */ + * maps to more than one detectors. Throws when some of the detectors have no + * matching spectrum. */ std::vector<GlobalSpectrumIndex> IndexInfo::globalSpectrumIndicesFromDetectorIndices( const std::vector<size_t> &detectorIndices) const { @@ -290,12 +289,10 @@ IndexInfo::globalSpectrumIndicesFromDetectorIndices( const auto detectorIndex = static_cast<size_t>(spectrumDefinition); if (detectorMap.size() > detectorIndex && detectorMap[detectorIndex] != 0) { - if (detectorMap[detectorIndex] > 1) - throw std::runtime_error( - "Multiple spectra correspond to the same detector"); - // Increment flag to catch two spectra mapping to same detector. - ++detectorMap[detectorIndex]; spectrumIndices.push_back(i); + if (detectorMap[detectorIndex] == 1) { + ++detectorMap[detectorIndex]; + } } } if (spectrumDefinition == -2) @@ -309,6 +306,11 @@ IndexInfo::globalSpectrumIndicesFromDetectorIndices( auto bytes = static_cast<int>(sizeof(int64_t) * spectrumIndices.size()); communicator().send(rank, tag, buffer, bytes); } + if (std::any_of(detectorMap.begin(), detectorMap.end(), + [](char c) { return c == 1; })) { + throw std::runtime_error("Some of the requested detectors do not have a " + "corresponding spectrum"); + } } else { auto buffer = reinterpret_cast<char *>(thisRankSpectrumDefinitions.data()); auto bytes = static_cast<int>(sizeof(int64_t) * size()); @@ -320,7 +322,7 @@ IndexInfo::globalSpectrumIndicesFromDetectorIndices( spectrumIndices.resize(*status.count<int64_t>()); } - if (detectorIndices.size() != spectrumIndices.size()) + if (detectorIndices.size() > spectrumIndices.size()) throw std::runtime_error("Some of the requested detectors do not have a " "corresponding spectrum"); return spectrumIndices; diff --git a/Framework/Indexing/test/IndexInfoTest.h b/Framework/Indexing/test/IndexInfoTest.h index b93e0660da5f062d06737e377ba7c207303772d8..ec1ce581e17bc8ede1de58f7822bc07febfe3ba7 100644 --- a/Framework/Indexing/test/IndexInfoTest.h +++ b/Framework/Indexing/test/IndexInfoTest.h @@ -333,19 +333,17 @@ public: "Some of the requested detectors do not have a corresponding spectrum"); } - void test_globalSpectrumIndicesFromDetectorIndices_fails_conflict() { + void test_globalSpectrumIndicesFromDetectorIndices_scanning() { IndexInfo info(3); std::vector<size_t> detectorIndices{6, 8}; std::vector<SpectrumDefinition> specDefs(3); - // Two indices map to same detector. + // Two indices map to same detector; typical for time-indexed workspaces. specDefs[0].add(6); specDefs[1].add(6); specDefs[2].add(8); info.setSpectrumDefinitions(specDefs); - TS_ASSERT_THROWS_EQUALS( - info.globalSpectrumIndicesFromDetectorIndices(detectorIndices), - const std::runtime_error &e, std::string(e.what()), - "Multiple spectra correspond to the same detector"); + TS_ASSERT_THROWS_NOTHING( + info.globalSpectrumIndicesFromDetectorIndices(detectorIndices)); } void test_globalSpectrumIndicesFromDetectorIndices_fails_conflict_miss() { @@ -359,7 +357,8 @@ public: TS_ASSERT_THROWS_EQUALS( info.globalSpectrumIndicesFromDetectorIndices(detectorIndices), const std::runtime_error &e, std::string(e.what()), - "Multiple spectra correspond to the same detector"); + "Some of the requested detectors do not have a " + "corresponding spectrum"); } void test_globalSpectrumIndicesFromDetectorIndices() { diff --git a/docs/source/release/v3.13.0/framework.rst b/docs/source/release/v3.13.0/framework.rst index b41bb85a368c5c56f8d7d241607904cec3e46714..836a303796c75de80447d3d7da991676af2b4ced 100644 --- a/docs/source/release/v3.13.0/framework.rst +++ b/docs/source/release/v3.13.0/framework.rst @@ -15,30 +15,17 @@ Instrument Definition Updates - The ALF IDF has been updated following a detector array alteration. - The LARMOR IDF has been updated following the addition of a new detector to the instrument. -Stability ---------- - -- Mantid now handles poor network stability better when reading live data from the ISIS DAE. Mantid will now timeout after a couple of minutes of loss of network connectivity and remains responsive during this time. You can alter the duration of this timeout by adding a line to the mantid.user.properties file like: - -``` -ISISDAE.Timeout = 100 #seconds -``` -- The error reporter now catches hard crashes to desktop. - - Algorithms ---------- -New -### - New Features -************ +############ - A list of Related Algorithms has been added to each algorithm, and is displayed in the documentation page of each algorithm as part of it's summary. +- The error reporter now catches hard crashes to desktop. New Algorithms -************** +############## - :ref:`LoadSampleShape <algm-LoadSampleShape>` loads a shape into the sample in a workspace from an ASCII `STL <https://en.wikipedia.org/wiki/STL_(file_format)>`_ file, @@ -60,21 +47,20 @@ New Algorithms - :ref:`SaveGEMMAUDParamFile <algm-SaveGEMMAUDParamFile>`, which acts as a partner to :ref:`SaveGDA <algm-SaveGDA>`, saves a MAUD calibration file to convert the output of **SaveGDA** back to d-spacing -- Algorithm :ref:`FitPeaks <algm-FitPeaks>` is implemented as a generalized multiple-spectrum multiple-peak fitting algorithm. - -Improvements -############ +Improved +######## - :ref:`LoadMcStas <algm-LoadMcStas>` new alg property which controls the granularity of event data returned. - :ref:`Maxent <algm-Maxent>` when outputting the results of the iterations, it no longer pads with zeroes but returns as many items as iterations done for each spectrum, making the iterations easy to count. -- XError values (Dx) can now be treated by the following algorithms: :ref:`ConjoinXRuns <algm-ConjoinXRuns>`, :ref:`ConvertToHistogram <algm-ConvertToHistogram>`, :ref:`ConvertToPointData <algm-ConvertToPointData>`, :ref:`CreateWorkspace <algm-CreateWorkspace>`, :ref:`SortXAxis <algm-SortXAxis>`, :ref:`algm-Stitch1D` and :ref:`algm-Stitch1DMany` (both with respect to point data). +- XError values (Dx) can now be treated by the following algorithms: :ref:`ConjoinXRuns <algm-ConjoinXRuns>`, :ref:`ConvertToHistogram <algm-ConvertToHistogram>`, :ref:`ConvertToPointData <algm-ConvertToPointData>`, :ref:`CreateWorkspace <algm-CreateWorkspace>`, :ref:`SortXAxis <algm-SortXAxis>`, :ref:`algm-Stitch1D` and :ref:`algm-Stitch1DMany` (both with repect to point data). - :ref:`Stitch1D <algm-Stitch1D>` can treat point data. - The algorithm :ref:`SortXAxis <algm-SortXAxis>` has a new input option that allows ascending (default) and descending sorting. The documentation needed to be corrected in general. -- :ref:`LoadNexusMonitors <algm-LoadNexusMonitors>` has changed its properties for clarification. This has also propagated to :ref:`LoadEventNexus <algm-LoadEventNexus>` and :ref:`LoadEventAndCompress <algm-LoadEventAndCompress>` +- :ref:`LoadNexusMonitors <algm-LoadNexusMonitors>` has changed its properties for clarification. This has also propogated to :ref:`LoadEventNexus <algm-LoadEventNexus>` and :ref:`LoadEventAndCompress <algm-LoadEventAndCompress>` +- :ref:`CropToComponent <algm-CropToComponent>` now works also for scanning workspaces. -Bugfixes -######## +Bug fixes +######### - In :ref:`LoadMcStas <algm-LoadMcStas>` internally reduce number of event workspaces created. If n mcstas event components now create n*(n-1) fewer. - The documentation of the algorithm :ref:`algm-CreateSampleWorkspace` did not match its implementation. The axis in beam direction will now be correctly described as Z instead of X. @@ -84,11 +70,16 @@ Bugfixes - Fixed :ref:`SumSpectra <algm-SumSpectra>` to avoid a crash when validation of inputs was called with a WorkspaceGroup. - Fixed a bug in TableWorkspaces where vector column data was set to 0 when the table was viewed - The output workspace of :ref:`LineProfile <algm-LineProfile>` now has correct sample logs, instrument and history. -- TimeSeriesProperty::splitByTimeVector's behavior on a boundary condition is changed. In the set of splitters toward a same target split workspace, if a splitter's beginning time is after the last entry of the TimeSeriesProperty to be split, then this last entry shall be included in its output TimeSeriesProperty. +- TimeSeriesProperty::splitByTimeVector's behavior on a boundary condition is changed. In the set of splitters toward a same target splitted workspace, if there is a splitter's beginning time is after the last entry of the TimeSeriesProperty to be split, then this last entry shall be included in its output TimeSeriesProperty. - Fixed a bug in :ref:`MergeRuns <algm-MergeRuns>` which could cause the runs to be merged in a different sequence than indicated in the *InputWorkspaces* property. - Fixed a bug where the values entered for basis vector properties in :ref:`BinMD <algm-BinMD>` were not being remembered. - Fixed a bug which prevented :ref:`Load <algm-Load>` and :ref:`LoadAndMerge <algm-Load>` from parsing advanced run ranges such as ``1-3+5-7+10+15-20``. +New +### + +- Algorithm :ref:`FitPeaks <algm-FitPeaks>` is implemented as a generalized multiple-spectra multiple-peak fitting algorithm. + Python ------ @@ -98,8 +89,8 @@ New - Added a new ``MDFrameValidator`` which can check that a MD workspace passed to a python algorithm has the expected MD frame (e.g. HKL, QLab, QSample etc.). -Improvements -############ +Improved +######## - Python fit functions that use from ``IPeakFunction`` as a base no longer require a ``functionDeriveLocal`` method to compute an analytical derivative. If the method is absent then a numerical derivative is calculate. @@ -109,9 +100,15 @@ Bugfixes - Checks on the structure of Python fit function classes have been improved to avoid scenarios, such as writing ``function1d`` rather than ``function1D``, which would previously have resulted in a hard crash. -- Fit functions defined in a python script can be used with the new fit function API right after subscription. +- Fit functions defined in a python script can be used with the new fit function API right after sibscription. - Child algorithms now respect their parent algorithm's ``EnableLogging`` setting when invoked using the function-style calling. Previously, some messages could appear in the log even though ``EnableLogging`` was set to ``False``. -- Fixed a bug in ``detectorSignedTwoTheta`` method in ``MatrixWorkspace`` where the sign of the angle depended on the axis pointing up, not on the actual theta-sing axis defined in the IDF. +Python +------ + +Bug fixes +######### + +- Fixed a bug in ``detectorSignedTwoTheta`` method in ``MatrixWorkspace`` where the sign of the angle depended on the axis pointing up, not on the actual theta-sing axis defined in the IDF. :ref:`Release 3.13.0 <v3.13.0>`