Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #781 from mantidproject/feature/11814_set_recursio…
…n_depth_for_top_level_split_to_1 Set recursion depth for top level split to 1
- Loading branch information
Showing
6 changed files
with
179 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef MANTID_VATESAPI_BOXINFO_H | ||
#define MANTID_VATESAPI_BOXINFO_H | ||
|
||
#include "MantidKernel/System.h" | ||
#include <iostream> | ||
#include <boost/optional.hpp> | ||
|
||
namespace Mantid | ||
{ | ||
namespace VATES | ||
{ | ||
/** | ||
Collection of functions related to box information | ||
@date 21/05/2015 | ||
Copyright © 2010 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://github.com/mantidproject/mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
|
||
/** | ||
* Function for finding an appropriate initial recursion depth. | ||
* @param workspaceName :: name of the workspace | ||
* @returns the appropriate recursion depth or nothing | ||
*/ | ||
boost::optional<int> DLLExport findRecursionDepthForTopLevelSplitting(const std::string &workspaceName); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "MantidVatesAPI/BoxInfo.h" | ||
#include "MantidVatesAPI/ADSWorkspaceProvider.h" | ||
#include "MantidAPI/IMDEventWorkspace.h" | ||
|
||
using namespace Mantid::API; | ||
|
||
namespace Mantid { | ||
namespace VATES { | ||
boost::optional<int> findRecursionDepthForTopLevelSplitting(const std::string &workspaceName) { | ||
const int topLevelRecursionDepth = 1; | ||
boost::optional<int> recursionDepth; | ||
Mantid::VATES::ADSWorkspaceProvider<Mantid::API::IMDEventWorkspace> | ||
workspaceProvider; | ||
if (workspaceProvider.canProvideWorkspace(workspaceName)) { | ||
auto workspace = | ||
boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>( | ||
workspaceProvider.fetchWorkspace(workspaceName)); | ||
auto boxController = workspace->getBoxController(); | ||
boost::optional<std::vector<size_t>> topLevelSplits = | ||
boxController->getSplitTopInto(); | ||
if (boxController->getSplitTopInto()) { | ||
recursionDepth = topLevelRecursionDepth; | ||
} | ||
} | ||
return recursionDepth; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#ifndef VATES_API_BOX_INFO_TEST_H_ | ||
#define VATES_API_BOX_INFO_TEST_H_ | ||
|
||
|
||
|
||
#include <cxxtest/TestSuite.h> | ||
|
||
#include "MantidKernel/WarningSuppressions.h" | ||
#include "MantidVatesAPI/BoxInfo.h" | ||
#include "MantidAPI/AnalysisDataService.h" | ||
#include "MantidAPI/BoxController.h" | ||
#include "MantidKernel/PropertyWithValue.h" | ||
#include "MantidTestHelpers/MDEventsTestHelper.h" | ||
#include "MantidDataObjects/MDLeanEvent.h" | ||
|
||
|
||
|
||
using namespace Mantid::API; | ||
using namespace Mantid::DataObjects; | ||
using namespace Mantid::DataObjects::MDEventsTestHelper; | ||
using namespace Mantid::Kernel; | ||
|
||
class BoxInfoTest : public CxxTest::TestSuite { | ||
public: | ||
void test_initial_recursion_depth_is_empty_for_MD_Histo() { | ||
// Arrange | ||
const std::string wsName = "MD_HISTO_WS"; | ||
auto ws = makeFakeMDHistoWorkspace(1.0, 4, 5, 1.0, 0.1, wsName); | ||
|
||
// Act + Assert | ||
TSM_ASSERT("Should have no recursion depth for top level splitting.", | ||
boost::none == Mantid::VATES::findRecursionDepthForTopLevelSplitting(wsName)); | ||
|
||
// Clean up | ||
AnalysisDataService::Instance().remove(wsName); | ||
} | ||
|
||
void test_initial_recursion_depth_is_empty_for_MD_Event_wo_split() { | ||
// Arrange | ||
const std::string wsName = "MD_EVENT_WS"; | ||
auto ws = makeAnyMDEW<MDLeanEvent<3>, 3>(10, 0.0, 10.0, 1, wsName); | ||
|
||
// Act + Assert | ||
TSM_ASSERT("Should have no recursion depth for top level splitting.", | ||
boost::none == Mantid::VATES::findRecursionDepthForTopLevelSplitting(wsName)); | ||
|
||
// Clean up | ||
AnalysisDataService::Instance().remove(wsName); | ||
} | ||
|
||
GCC_DIAG_OFF(strict-aliasing) | ||
void test_initial_recursion_depth_is_1_for_MD_Event_w_split() { | ||
// Arrange | ||
const std::string wsName = "MD_EVENT_WS_WITH_SPLITTING"; | ||
auto ws = makeAnyMDEW<MDLeanEvent<3>, 3>(10, 0.0, 10.0, 1, wsName); | ||
BoxController_sptr boxController = ws->getBoxController(); | ||
boxController->setSplitTopInto(0,10); | ||
boxController->setSplitTopInto(1, 20); | ||
boxController->setSplitTopInto(2,30); | ||
|
||
// Act | ||
auto result = Mantid::VATES::findRecursionDepthForTopLevelSplitting(wsName); | ||
// Assert | ||
|
||
TSM_ASSERT("Should have recursion depth of 1 for top level splitting.", | ||
result.get() == 1); | ||
|
||
// Clean up | ||
AnalysisDataService::Instance().remove(wsName); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters