Skip to content

Commit 2cfa9cc

Browse files
authored
#38487 Sibling - Bugfix: isDistribution After Divide of Two RaggedWorkspaces (#38494)
Post main-merge
1 parent 15eb461 commit 2cfa9cc

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

Framework/Algorithms/src/Divide.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ void Divide::performBinaryOperation(const HistogramData::Histogram &lhs, const d
7676

7777
void Divide::setOutputUnits(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs,
7878
API::MatrixWorkspace_sptr out) {
79+
80+
if (lhs->isRaggedWorkspace() && rhs->isRaggedWorkspace()) {
81+
// if both workspaces are ragged, output workspace `isDistribution` flag will be true
82+
out->setDistribution(true);
83+
}
7984
if (rhs->YUnit().empty() || !WorkspaceHelpers::matchingBins(*lhs, *rhs, true)) {
8085
// Do nothing
8186
}
87+
8288
// If the Y units match, then the output will be a distribution and will be
8389
// dimensionless
8490
else if (lhs->YUnit() == rhs->YUnit() && m_rhsBlocksize > 1) {

Framework/Algorithms/src/Multiply.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ void Multiply::performBinaryOperation(const HistogramData::Histogram &lhs, const
5454

5555
void Multiply::setOutputUnits(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs,
5656
API::MatrixWorkspace_sptr out) {
57-
if (!lhs->isDistribution() || !rhs->isDistribution())
57+
if (!lhs->isDistribution() || !rhs->isDistribution()) {
5858
out->setDistribution(false);
59+
}
5960
}
6061

6162
// ===================================== EVENT LIST BINARY OPERATIONS

Framework/Algorithms/test/MultiplyDivideTest.in.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,8 @@ class @MULTIPLYDIVIDETEST_CLASS@ : public CxxTest::TestSuite
10501050
auto rhs = create_RaggedWorkspace();
10511051
auto result = performTest(lhs, rhs, false, DO_DIVIDE ? 1.0 : 4.0, DO_DIVIDE ? 1.4142135625 : 5.6568542436);
10521052
TS_ASSERT(result->isRaggedWorkspace());
1053+
TS_ASSERT_EQUALS(result->isDistribution(), DO_DIVIDE ? true : false);
1054+
TS_ASSERT(result->YUnit().empty());
10531055
}
10541056

10551057
void test_RaggedWorkspace_and_single_value()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Corrects `isDistribution` property of result of division of two ragged workspaces, now `true`

0 commit comments

Comments
 (0)