From 8b3a215dcf02bc04012cf46b14cc86f2c9dab430 Mon Sep 17 00:00:00 2001 From: Samuel Jones <samuel.jones@stfc.ac.uk> Date: Tue, 30 Mar 2021 17:01:46 +0100 Subject: [PATCH] Clang-format 11 changes --- .../API/inc/MantidAPI/AnalysisDataService.h | 122 +++---- .../API/inc/MantidAPI/MultiDomainFunction.h | 23 +- .../API/inc/MantidAPI/RegisterFileLoader.h | 34 +- Framework/API/src/MultiPeriodGroupWorker.cpp | 83 ++--- Framework/API/test/FileFinderTest.h | 298 +++++++----------- .../inc/MantidAlgorithms/SumRowColumn.h | 8 +- .../test/TimeAtSampleStrategyDirectTest.h | 14 +- .../Crystal/inc/MantidCrystal/PeakHKLErrors.h | 45 +-- Framework/Crystal/src/FindUBUsingMinMaxD.cpp | 42 +-- .../Functions/Bk2BkExpConvPV.h | 21 +- .../CurveFitting/src/Functions/BSpline.cpp | 34 +- .../Functions/CrystalFieldMagnetisation.cpp | 37 +-- .../inc/MantidDataHandling/SaveDiffCal.h | 9 +- .../inc/MantidDataHandling/SaveNXcanSAS.h | 11 +- Framework/DataHandling/src/XmlHandler.cpp | 17 +- .../test/LoadEventPreNexus2Test.h | 54 ++-- Framework/DataObjects/src/MDBoxFlatTree.cpp | 185 ++++------- Framework/Geometry/test/ConeTest.h | 3 +- Framework/Kernel/src/ISaveable.cpp | 24 +- Framework/Kernel/test/EqualBinsCheckerTest.h | 11 +- .../src/Kafka/KafkaHistoStreamDecoder.cpp | 56 ++-- .../ConvertToMDMinMaxGlobal.h | 4 +- .../test/ConvertToMDMinMaxGlobalTest.h | 78 ++--- .../NexusGeometryUtilities.h | 18 +- .../src/Exports/OffsetsWorkspace.cpp | 3 +- .../geometry/src/Exports/OrientedLattice.cpp | 74 ++--- Framework/SINQ/src/PoldiAutoCorrelation5.cpp | 77 ++--- .../ScriptRepositoryImpl.h | 37 +-- .../TestHelpers/src/ReflectometryHelper.cpp | 95 ++---- qt/scientific_interfaces/Indirect/ResNorm.cpp | 120 +++---- .../Muon/ALCDataLoadingPresenter.cpp | 89 ++---- .../AlgorithmProgressPresenterBase.cpp | 26 +- 32 files changed, 624 insertions(+), 1128 deletions(-) diff --git a/Framework/API/inc/MantidAPI/AnalysisDataService.h b/Framework/API/inc/MantidAPI/AnalysisDataService.h index 7729a772cdb..5d8af186a02 100644 --- a/Framework/API/inc/MantidAPI/AnalysisDataService.h +++ b/Framework/API/inc/MantidAPI/AnalysisDataService.h @@ -40,8 +40,7 @@ class WorkspaceGroup; Modified to inherit from DataService */ -class MANTID_API_DLL AnalysisDataServiceImpl final - : public Kernel::DataService<API::Workspace> { +class MANTID_API_DLL AnalysisDataServiceImpl final : public Kernel::DataService<API::Workspace> { public: /** @name Extra notifications only applicable to the ADS */ //@{ @@ -50,12 +49,9 @@ public: public: /// Constructor GroupWorkspacesNotification(const std::vector<std::string> &wsnames) - : DataServiceNotification("", std::shared_ptr<API::Workspace>()), - m_wsnames(wsnames) {} + : DataServiceNotification("", std::shared_ptr<API::Workspace>()), m_wsnames(wsnames) {} /// returns the workspace names - const std::vector<std::string> &inputworkspacenames() const { - return m_wsnames; - } + const std::vector<std::string> &inputworkspacenames() const { return m_wsnames; } private: std::vector<std::string> m_wsnames; ///< cache of ws names @@ -66,8 +62,7 @@ public: class UnGroupingWorkspaceNotification : public DataServiceNotification { public: /// Constructor - UnGroupingWorkspaceNotification(const std::string &name, - const std::shared_ptr<Workspace> &obj) + UnGroupingWorkspaceNotification(const std::string &name, const std::shared_ptr<Workspace> &obj) : DataServiceNotification(name, obj) {} }; @@ -95,12 +90,10 @@ public: const std::string isValid(const std::string &name) const; /// Overridden add member to attach the name to the workspace when a /// workspace object is added to the service - void add(const std::string &name, - const std::shared_ptr<API::Workspace> &workspace) override; + void add(const std::string &name, const std::shared_ptr<API::Workspace> &workspace) override; /// Overridden addOrReplace member to attach the name to the workspace when /// a workspace object is added to the service - void addOrReplace(const std::string &name, - const std::shared_ptr<API::Workspace> &workspace) override; + void addOrReplace(const std::string &name, const std::shared_ptr<API::Workspace> &workspace) override; /// Overridden rename member to attach the new name to the workspace when a /// workspace object is renamed virtual void rename(const std::string &oldName, const std::string &newName); @@ -114,22 +107,19 @@ public: * Workspace * @return a shared pointer of WSTYPE */ - template <typename WSTYPE> - std::shared_ptr<WSTYPE> retrieveWS(const std::string &name) const { + template <typename WSTYPE> std::shared_ptr<WSTYPE> retrieveWS(const std::string &name) const { // Get as a bare workspace try { // Cast to the desired type and return that. - return std::dynamic_pointer_cast<WSTYPE>( - Kernel::DataService<API::Workspace>::retrieve(name)); + return std::dynamic_pointer_cast<WSTYPE>(Kernel::DataService<API::Workspace>::retrieve(name)); } catch (Kernel::Exception::NotFoundError &) { throw; } } - std::vector<Workspace_sptr> - retrieveWorkspaces(const std::vector<std::string> &names, - bool unrollGroups = false) const; + std::vector<Workspace_sptr> retrieveWorkspaces(const std::vector<std::string> &names, + bool unrollGroups = false) const; /** @name Methods to work with workspace groups */ //@{ @@ -145,8 +135,7 @@ public: private: /// Checks the name is valid, throwing if not - void verifyName(const std::string &name, - const std::shared_ptr<API::WorkspaceGroup> &workspace); + void verifyName(const std::string &name, const std::shared_ptr<API::WorkspaceGroup> &workspace); friend struct Mantid::Kernel::CreateUsingNew<AnalysisDataServiceImpl>; /// Constructor @@ -162,69 +151,52 @@ private: std::string m_illegalChars; }; -using AnalysisDataService = - Mantid::Kernel::SingletonHolder<AnalysisDataServiceImpl>; +using AnalysisDataService = Mantid::Kernel::SingletonHolder<AnalysisDataServiceImpl>; -using WorkspaceAddNotification = - Mantid::Kernel::DataService<Mantid::API::Workspace>::AddNotification; -using WorkspaceAddNotification_ptr = const Poco::AutoPtr< - Mantid::Kernel::DataService<Mantid::API::Workspace>::AddNotification> &; +using WorkspaceAddNotification = Mantid::Kernel::DataService<Mantid::API::Workspace>::AddNotification; +using WorkspaceAddNotification_ptr = + const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::AddNotification> &; -using WorkspaceBeforeReplaceNotification = Mantid::Kernel::DataService< - Mantid::API::Workspace>::BeforeReplaceNotification; +using WorkspaceBeforeReplaceNotification = + Mantid::Kernel::DataService<Mantid::API::Workspace>::BeforeReplaceNotification; using WorkspaceBeforeReplaceNotification_ptr = - const Poco::AutoPtr<Mantid::Kernel::DataService< - Mantid::API::Workspace>::BeforeReplaceNotification> &; + const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::BeforeReplaceNotification> &; -using WorkspaceAfterReplaceNotification = Mantid::Kernel::DataService< - Mantid::API::Workspace>::AfterReplaceNotification; +using WorkspaceAfterReplaceNotification = Mantid::Kernel::DataService<Mantid::API::Workspace>::AfterReplaceNotification; using WorkspaceAfterReplaceNotification_ptr = - const Poco::AutoPtr<Mantid::Kernel::DataService< - Mantid::API::Workspace>::AfterReplaceNotification> &; - -using WorkspacePreDeleteNotification = - Mantid::Kernel::DataService<Mantid::API::Workspace>::PreDeleteNotification; -using WorkspacePreDeleteNotification_ptr = const Poco::AutoPtr< - Mantid::Kernel::DataService<Mantid::API::Workspace>::PreDeleteNotification> - &; - -using WorkspacePostDeleteNotification = - Mantid::Kernel::DataService<Mantid::API::Workspace>::PostDeleteNotification; -using WorkspacePostDeleteNotification_ptr = const Poco::AutoPtr< - Mantid::Kernel::DataService<Mantid::API::Workspace>::PostDeleteNotification> - &; - -using ClearADSNotification = - Mantid::Kernel::DataService<Mantid::API::Workspace>::ClearNotification; -using ClearADSNotification_ptr = const Poco::AutoPtr< - Mantid::Kernel::DataService<Mantid::API::Workspace>::ClearNotification> &; - -using WorkspaceRenameNotification = - Mantid::Kernel::DataService<Mantid::API::Workspace>::RenameNotification; -using WorkspaceRenameNotification_ptr = const Poco::AutoPtr< - Mantid::Kernel::DataService<Mantid::API::Workspace>::RenameNotification> &; - -using WorkspacesGroupedNotification = - AnalysisDataServiceImpl::GroupWorkspacesNotification; -using WorkspacesGroupedNotification_ptr = - const Poco::AutoPtr<AnalysisDataServiceImpl::GroupWorkspacesNotification> &; - -using WorkspaceUnGroupingNotification = - AnalysisDataServiceImpl::UnGroupingWorkspaceNotification; -using WorkspaceUnGroupingNotification_ptr = const Poco::AutoPtr< - AnalysisDataServiceImpl::UnGroupingWorkspaceNotification> &; - -using GroupUpdatedNotification = - AnalysisDataServiceImpl::GroupUpdatedNotification; -using GroupUpdatedNotification_ptr = - const Poco::AutoPtr<AnalysisDataServiceImpl::GroupUpdatedNotification> &; + const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::AfterReplaceNotification> &; + +using WorkspacePreDeleteNotification = Mantid::Kernel::DataService<Mantid::API::Workspace>::PreDeleteNotification; +using WorkspacePreDeleteNotification_ptr = + const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::PreDeleteNotification> &; + +using WorkspacePostDeleteNotification = Mantid::Kernel::DataService<Mantid::API::Workspace>::PostDeleteNotification; +using WorkspacePostDeleteNotification_ptr = + const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::PostDeleteNotification> &; + +using ClearADSNotification = Mantid::Kernel::DataService<Mantid::API::Workspace>::ClearNotification; +using ClearADSNotification_ptr = + const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::ClearNotification> &; + +using WorkspaceRenameNotification = Mantid::Kernel::DataService<Mantid::API::Workspace>::RenameNotification; +using WorkspaceRenameNotification_ptr = + const Poco::AutoPtr<Mantid::Kernel::DataService<Mantid::API::Workspace>::RenameNotification> &; + +using WorkspacesGroupedNotification = AnalysisDataServiceImpl::GroupWorkspacesNotification; +using WorkspacesGroupedNotification_ptr = const Poco::AutoPtr<AnalysisDataServiceImpl::GroupWorkspacesNotification> &; + +using WorkspaceUnGroupingNotification = AnalysisDataServiceImpl::UnGroupingWorkspaceNotification; +using WorkspaceUnGroupingNotification_ptr = + const Poco::AutoPtr<AnalysisDataServiceImpl::UnGroupingWorkspaceNotification> &; + +using GroupUpdatedNotification = AnalysisDataServiceImpl::GroupUpdatedNotification; +using GroupUpdatedNotification_ptr = const Poco::AutoPtr<AnalysisDataServiceImpl::GroupUpdatedNotification> &; } // Namespace API } // Namespace Mantid namespace Mantid { namespace Kernel { -EXTERN_MANTID_API template class MANTID_API_DLL - Mantid::Kernel::SingletonHolder<Mantid::API::AnalysisDataServiceImpl>; +EXTERN_MANTID_API template class MANTID_API_DLL Mantid::Kernel::SingletonHolder<Mantid::API::AnalysisDataServiceImpl>; } } // namespace Mantid diff --git a/Framework/API/inc/MantidAPI/MultiDomainFunction.h b/Framework/API/inc/MantidAPI/MultiDomainFunction.h index e430787d23b..82d287be64c 100644 --- a/Framework/API/inc/MantidAPI/MultiDomainFunction.h +++ b/Framework/API/inc/MantidAPI/MultiDomainFunction.h @@ -36,8 +36,7 @@ public: /// @param domain :: The input domain over which the function is to be /// calculated /// @param values :: A storage object for the calculated values - void function(const FunctionDomain &domain, - FunctionValues &values) const override; + void function(const FunctionDomain &domain, FunctionValues &values) const override; /// Derivatives of function with respect to active parameters void functionDeriv(const FunctionDomain &domain, Jacobian &jacobian) override; /// Called at the start of each iteration @@ -48,15 +47,13 @@ public: /// Associate a function and a domain void setDomainIndex(size_t funIndex, size_t domainIndex); /// Associate a function and a list of domains - void setDomainIndices(size_t funIndex, - const std::vector<size_t> &domainIndices); + void setDomainIndices(size_t funIndex, const std::vector<size_t> &domainIndices); /// Clear all domain indices void clearDomainIndices(); /// Get the largest domain index size_t getMaxIndex() const { return m_maxIndex; } /// Get domain indices for a member function - void getDomainIndices(size_t i, size_t nDomains, - std::vector<size_t> &domains) const; + void getDomainIndices(size_t i, size_t nDomains, std::vector<size_t> &domains) const; /// Get number of domains required by this function size_t getNumberDomains() const override; /// Create a list of equivalent functions @@ -68,19 +65,13 @@ public: /// of individual member functions. size_t nLocalAttributes() const override { return 1; } /// Returns a list of attribute names - std::vector<std::string> getLocalAttributeNames() const override { - return std::vector<std::string>(1, "domains"); - } + std::vector<std::string> getLocalAttributeNames() const override { return std::vector<std::string>(1, "domains"); } /// Return a value of attribute attName - Attribute getLocalAttribute(size_t i, - const std::string &attName) const override; + Attribute getLocalAttribute(size_t i, const std::string &attName) const override; /// Set a value to attribute attName - void setLocalAttribute(size_t i, const std::string &attName, - const Attribute &) override; + void setLocalAttribute(size_t i, const std::string &attName, const Attribute &) override; /// Check if attribute attName exists - bool hasLocalAttribute(const std::string &attName) const override { - return attName == "domains"; - } + bool hasLocalAttribute(const std::string &attName) const override { return attName == "domains"; } protected: /// Counts number of the domains diff --git a/Framework/API/inc/MantidAPI/RegisterFileLoader.h b/Framework/API/inc/MantidAPI/RegisterFileLoader.h index ff4ed68da97..e8908dc2ff1 100644 --- a/Framework/API/inc/MantidAPI/RegisterFileLoader.h +++ b/Framework/API/inc/MantidAPI/RegisterFileLoader.h @@ -16,12 +16,11 @@ * It both registers the algorithm as usual and subscribes it to the * registry. */ -#define DECLARE_FILELOADER_ALGORITHM(classname) \ - namespace { \ - Mantid::Kernel::RegistrationHelper reg_loader_##classname( \ - (Mantid::API::FileLoaderRegistry::Instance().subscribe<classname>( \ - Mantid::API::FileLoaderRegistryImpl::Generic), \ - 0)); \ +#define DECLARE_FILELOADER_ALGORITHM(classname) \ + namespace { \ + Mantid::Kernel::RegistrationHelper reg_loader_##classname( \ + (Mantid::API::FileLoaderRegistry::Instance().subscribe<classname>(Mantid::API::FileLoaderRegistryImpl::Generic), \ + 0)); \ } /** @@ -31,12 +30,11 @@ * It both registers the algorithm as usual and subscribes it to the * registry. */ -#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname) \ - namespace { \ - Mantid::Kernel::RegistrationHelper reg_hdf_loader_##classname( \ - (Mantid::API::FileLoaderRegistry::Instance().subscribe<classname>( \ - Mantid::API::FileLoaderRegistryImpl::Nexus), \ - 0)); \ +#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname) \ + namespace { \ + Mantid::Kernel::RegistrationHelper reg_hdf_loader_##classname( \ + (Mantid::API::FileLoaderRegistry::Instance().subscribe<classname>(Mantid::API::FileLoaderRegistryImpl::Nexus), \ + 0)); \ } /** @@ -46,10 +44,10 @@ * It both registers the algorithm as usual and subscribes it to the * registry. */ -#define DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM(classname) \ - namespace { \ - Mantid::Kernel::RegistrationHelper reg_hdf_loader_##classname( \ - (Mantid::API::FileLoaderRegistry::Instance().subscribe<classname>( \ - Mantid::API::FileLoaderRegistryImpl::NexusHDF5), \ - 0)); \ +#define DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM(classname) \ + namespace { \ + Mantid::Kernel::RegistrationHelper \ + reg_hdf_loader_##classname((Mantid::API::FileLoaderRegistry::Instance().subscribe<classname>( \ + Mantid::API::FileLoaderRegistryImpl::NexusHDF5), \ + 0)); \ } diff --git a/Framework/API/src/MultiPeriodGroupWorker.cpp b/Framework/API/src/MultiPeriodGroupWorker.cpp index 305a276a4e4..122756934ac 100644 --- a/Framework/API/src/MultiPeriodGroupWorker.cpp +++ b/Framework/API/src/MultiPeriodGroupWorker.cpp @@ -24,8 +24,7 @@ namespace API { * @param workspacePropertyName : Property name to treat as source of * multiperiod workspaces. */ -MultiPeriodGroupWorker::MultiPeriodGroupWorker( - const std::string &workspacePropertyName) +MultiPeriodGroupWorker::MultiPeriodGroupWorker(const std::string &workspacePropertyName) : m_workspacePropertyName(workspacePropertyName) {} /** @@ -36,11 +35,9 @@ MultiPeriodGroupWorker::MultiPeriodGroupWorker( * @param vecWorkspaceGroups: Vector of non-multi period workspace groups. */ void MultiPeriodGroupWorker::tryAddInputWorkspaceToInputGroups( - const Workspace_sptr &ws, - MultiPeriodGroupWorker::VecWSGroupType &vecMultiPeriodWorkspaceGroups, + const Workspace_sptr &ws, MultiPeriodGroupWorker::VecWSGroupType &vecMultiPeriodWorkspaceGroups, MultiPeriodGroupWorker::VecWSGroupType &vecWorkspaceGroups) const { - WorkspaceGroup_sptr inputGroup = - std::dynamic_pointer_cast<WorkspaceGroup>(ws); + WorkspaceGroup_sptr inputGroup = std::dynamic_pointer_cast<WorkspaceGroup>(ws); if (inputGroup) { if (inputGroup->isMultiperiod()) { vecMultiPeriodWorkspaceGroups.emplace_back(inputGroup); @@ -51,8 +48,7 @@ void MultiPeriodGroupWorker::tryAddInputWorkspaceToInputGroups( } MultiPeriodGroupWorker::VecWSGroupType -MultiPeriodGroupWorker::findMultiPeriodGroups( - Algorithm const *const sourceAlg) const { +MultiPeriodGroupWorker::findMultiPeriodGroups(Algorithm const *const sourceAlg) const { if (!sourceAlg->isInitialized()) { throw std::invalid_argument("Algorithm must be initialized"); } @@ -67,8 +63,7 @@ MultiPeriodGroupWorker::findMultiPeriodGroups( using WorkspaceNameType = std::vector<std::string>; // Perform a check that the input property is the correct type. - Property *inputProperty = - sourceAlg->getProperty(this->m_workspacePropertyName); + Property *inputProperty = sourceAlg->getProperty(this->m_workspacePropertyName); if (!dynamic_cast<ArrayProperty<std::string> *>(inputProperty)) { throw std::runtime_error("Support for custom input workspaces that are " @@ -78,8 +73,7 @@ MultiPeriodGroupWorker::findMultiPeriodGroups( * types if required, but we don't need that funtionality now.*/ } - WorkspaceNameType workspaces = - sourceAlg->getProperty(this->m_workspacePropertyName); + WorkspaceNameType workspaces = sourceAlg->getProperty(this->m_workspacePropertyName); // Inspect all the input workspaces in the ArrayProperty input. for (auto &workspace : workspaces) { @@ -87,22 +81,19 @@ MultiPeriodGroupWorker::findMultiPeriodGroups( if (!ws) { throw Kernel::Exception::NotFoundError("Workspace", workspace); } - tryAddInputWorkspaceToInputGroups(ws, vecMultiPeriodWorkspaceGroups, - vecWorkspaceGroups); + tryAddInputWorkspaceToInputGroups(ws, vecMultiPeriodWorkspaceGroups, vecWorkspaceGroups); } } else { using WorkspaceVector = std::vector<std::shared_ptr<Workspace>>; WorkspaceVector inWorkspaces; sourceAlg->findWorkspaces(inWorkspaces, Direction::Input); for (auto &inWorkspace : inWorkspaces) { - tryAddInputWorkspaceToInputGroups( - inWorkspace, vecMultiPeriodWorkspaceGroups, vecWorkspaceGroups); + tryAddInputWorkspaceToInputGroups(inWorkspace, vecMultiPeriodWorkspaceGroups, vecWorkspaceGroups); } } if (!vecMultiPeriodWorkspaceGroups.empty() && !vecWorkspaceGroups.empty()) { - throw std::invalid_argument( - "The input contains a mix of multi-period and other workspaces."); + throw std::invalid_argument("The input contains a mix of multi-period and other workspaces."); } validateMultiPeriodGroupInputs(vecMultiPeriodWorkspaceGroups); @@ -110,9 +101,7 @@ MultiPeriodGroupWorker::findMultiPeriodGroups( return vecMultiPeriodWorkspaceGroups; } -bool MultiPeriodGroupWorker::useCustomWorkspaceProperty() const { - return !this->m_workspacePropertyName.empty(); -} +bool MultiPeriodGroupWorker::useCustomWorkspaceProperty() const { return !this->m_workspacePropertyName.empty(); } /** * Creates a list of input workspaces as a string for a given period using all @@ -134,13 +123,12 @@ bool MultiPeriodGroupWorker::useCustomWorkspaceProperty() const { * @param vecWorkspaceGroups : Vector of workspace groups * @return comma separated string of input workspaces. */ -std::string MultiPeriodGroupWorker::createFormattedInputWorkspaceNames( - const size_t &periodIndex, const VecWSGroupType &vecWorkspaceGroups) const { +std::string MultiPeriodGroupWorker::createFormattedInputWorkspaceNames(const size_t &periodIndex, + const VecWSGroupType &vecWorkspaceGroups) const { std::string prefix; std::string inputWorkspaces; for (const auto &vecWorkspaceGroup : vecWorkspaceGroups) { - inputWorkspaces += - prefix + vecWorkspaceGroup->getItem(periodIndex)->getName(); + inputWorkspaces += prefix + vecWorkspaceGroup->getItem(periodIndex)->getName(); prefix = ","; } return inputWorkspaces; @@ -159,21 +147,16 @@ std::string MultiPeriodGroupWorker::createFormattedInputWorkspaceNames( * @param periodNumber: The relevant period number used to index into the group * workspaces */ -void MultiPeriodGroupWorker::copyInputWorkspaceProperties( - IAlgorithm *targetAlg, IAlgorithm *sourceAlg, - const int &periodNumber) const { +void MultiPeriodGroupWorker::copyInputWorkspaceProperties(IAlgorithm *targetAlg, IAlgorithm *sourceAlg, + const int &periodNumber) const { std::vector<Property *> props = sourceAlg->getProperties(); for (auto prop : props) { if (prop) { if (prop->direction() == Direction::Input) { - if (const IWorkspaceProperty *wsProp = - dynamic_cast<IWorkspaceProperty *>(prop)) { - if (WorkspaceGroup_sptr inputws = - std::dynamic_pointer_cast<WorkspaceGroup>( - wsProp->getWorkspace())) { + if (const IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop)) { + if (WorkspaceGroup_sptr inputws = std::dynamic_pointer_cast<WorkspaceGroup>(wsProp->getWorkspace())) { if (inputws->isMultiperiod()) { - targetAlg->setProperty(prop->name(), - inputws->getItem(periodNumber - 1)); + targetAlg->setProperty(prop->name(), inputws->getItem(periodNumber - 1)); } } } @@ -198,9 +181,8 @@ void MultiPeriodGroupWorker::copyInputWorkspaceProperties( * @param vecMultiPeriodGroups : Vector of pre-identified multiperiod groups. * @return true - if all the workspace members are executed. */ -bool MultiPeriodGroupWorker::processGroups( - Algorithm *const sourceAlg, - const VecWSGroupType &vecMultiPeriodGroups) const { +bool MultiPeriodGroupWorker::processGroups(Algorithm *const sourceAlg, + const VecWSGroupType &vecMultiPeriodGroups) const { // If we are not processing multiperiod groups, use the base behaviour. if (vecMultiPeriodGroups.empty()) { return false; // Indicates that this is not a multiperiod group workspace. @@ -218,10 +200,9 @@ bool MultiPeriodGroupWorker::processGroups( for (size_t i = 0; i < nPeriods; ++i) { const auto periodNumber = static_cast<int>(i + 1); // use create Child Algorithm that look like this one - Algorithm_sptr alg = sourceAlg->createChildAlgorithm( - sourceAlg->name(), progress_proportion * periodNumber, - progress_proportion * (1 + periodNumber), sourceAlg->isLogging(), - sourceAlg->version()); + Algorithm_sptr alg = sourceAlg->createChildAlgorithm(sourceAlg->name(), progress_proportion * periodNumber, + progress_proportion * (1 + periodNumber), + sourceAlg->isLogging(), sourceAlg->version()); if (!alg) { throw std::runtime_error("Algorithm creation failed."); } @@ -234,8 +215,7 @@ bool MultiPeriodGroupWorker::processGroups( sourceAlg->copyNonWorkspaceProperties(alg.get(), periodNumber); if (this->useCustomWorkspaceProperty()) { - const std::string inputWorkspaces = - createFormattedInputWorkspaceNames(i, vecMultiPeriodGroups); + const std::string inputWorkspaces = createFormattedInputWorkspaceNames(i, vecMultiPeriodGroups); // Set the input workspace property. alg->setPropertyValue(this->m_workspacePropertyName, inputWorkspaces); } else { @@ -246,8 +226,7 @@ bool MultiPeriodGroupWorker::processGroups( alg->setPropertyValue("OutputWorkspace", outName_i); // Run the spawned algorithm. if (!alg->execute()) { - throw std::runtime_error("Execution of " + sourceAlg->name() + - " for group entry " + Strings::toString(i + 1) + + throw std::runtime_error("Execution of " + sourceAlg->name() + " for group entry " + Strings::toString(i + 1) + " failed."); } // Add the output workpace from the spawned algorithm to the group. @@ -264,8 +243,7 @@ bool MultiPeriodGroupWorker::processGroups( * processing if things don't look right. * @param vecMultiPeriodGroups : vector of multiperiod groups. */ -void MultiPeriodGroupWorker::validateMultiPeriodGroupInputs( - const VecWSGroupType &vecMultiPeriodGroups) const { +void MultiPeriodGroupWorker::validateMultiPeriodGroupInputs(const VecWSGroupType &vecMultiPeriodGroups) const { const size_t multiPeriodGroupsSize = vecMultiPeriodGroups.size(); if (multiPeriodGroupsSize > 0) { @@ -278,18 +256,15 @@ void MultiPeriodGroupWorker::validateMultiPeriodGroupInputs( } for (size_t j = 0; j < currentGroup->size(); ++j) { MatrixWorkspace_const_sptr currentNestedWS = - std::dynamic_pointer_cast<const MatrixWorkspace>( - currentGroup->getItem(j)); - Property *nPeriodsProperty = - currentNestedWS->run().getLogData("nperiods"); + std::dynamic_pointer_cast<const MatrixWorkspace>(currentGroup->getItem(j)); + Property *nPeriodsProperty = currentNestedWS->run().getLogData("nperiods"); size_t nPeriods = std::stoul(nPeriodsProperty->value()); if (nPeriods != benchMarkGroupSize) { throw std::runtime_error("Missmatch between nperiods log and the " "number of workspaces in the input group: " + vecMultiPeriodGroups[i]->getName()); } - Property *currentPeriodProperty = - currentNestedWS->run().getLogData("current_period"); + Property *currentPeriodProperty = currentNestedWS->run().getLogData("current_period"); size_t currentPeriod = std::stoul(currentPeriodProperty->value()); if (currentPeriod != (j + 1)) { throw std::runtime_error("Multiperiod group workspaces must be " diff --git a/Framework/API/test/FileFinderTest.h b/Framework/API/test/FileFinderTest.h index f4133d7c4ff..1201b78f3fe 100644 --- a/Framework/API/test/FileFinderTest.h +++ b/Framework/API/test/FileFinderTest.h @@ -34,69 +34,68 @@ public: if (m_facFile.exists()) m_facFile.remove(); - const std::string xmlStr = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" - "<facilities>" - " <facility name=\"ISIS\" zeropadding=\"5\" " - "FileExtensions=\".nxs,.raw,.sav,.n*,.s*\">" - " <archive>" - " <archiveSearch plugin=\"ISISDataSearch\" />" - " </archive>" - " <instrument name=\"HRPD\" shortname=\"HRP\">" - " <technique>Powder Diffraction</technique>" - " </instrument>" - " <instrument name=\"ABCD\" shortname=\"ABC\" >" - " <zeropadding size=\"8\"/>" - " <technique>Powder Diffraction</technique>" - " </instrument>" - " <instrument name=\"EFG2H\" shortname=\"EFG2H\">" - " <zeropadding size=\"8\"/>" - " <technique>Powder Diffraction</technique>" - " </instrument>" - " <instrument name=\"CRISP\" shortname=\"CSP\">" - " <technique>Technique</technique>" - " </instrument>" - " <instrument name=\"MUSR\">" - " <zeropadding size=\"8\"/>" - " <technique>Powder Diffraction</technique>" - " </instrument>" - " <instrument name=\"LOQ\">" - " <zeropadding size=\"5\"/>" - " <technique>Small Angle Scattering</technique>" - " </instrument>" - " <instrument name=\"OFFSPEC\">" - " <zeropadding size=\"8\"/>" - " <technique>Reflectometer</technique>" - " </instrument>" - " <instrument name=\"SANS2D\">" - " <zeropadding size=\"8\"/>" - " <technique>Small Angle Scattering</technique>" - " </instrument>" - " </facility>" - " <facility name=\"SNS\" delimiter=\"_\" " - "FileExtensions=\"_event.nxs,.nxs,.dat\">" - " <archive>" - " <archiveSearch plugin=\"ORNLDataSearch\" />" - " </archive>" - " <instrument name=\"SEQUOIA\" shortname=\"SEQ\">" - " <technique>Inelastic Spectroscopy</technique>" - " </instrument>" - " <instrument name=\"CNCS\" shortname=\"CNCS\">" - " <technique>Inelastic Spectroscopy</technique>" - " </instrument>" - " <instrument name=\"REF_L\" shortname=\"REF_L\">" - " <technique>Reflectometer</technique>" - " </instrument>" - " <instrument name=\"POWGEN\" shortname=\"PG3\">" - " <technique>Reflectometer</technique>" - " </instrument>" - " </facility>" - " <facility name=\"ILL\" delimiter=\"_\" FileExtensions=\".nxs,.dat\">" - " <instrument name=\"IN5\" shortname=\"IN5\">" - " <technique>Inelastic Spectroscopy</technique>" - " </instrument>" - " </facility>" - "</facilities>"; + const std::string xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<facilities>" + " <facility name=\"ISIS\" zeropadding=\"5\" " + "FileExtensions=\".nxs,.raw,.sav,.n*,.s*\">" + " <archive>" + " <archiveSearch plugin=\"ISISDataSearch\" />" + " </archive>" + " <instrument name=\"HRPD\" shortname=\"HRP\">" + " <technique>Powder Diffraction</technique>" + " </instrument>" + " <instrument name=\"ABCD\" shortname=\"ABC\" >" + " <zeropadding size=\"8\"/>" + " <technique>Powder Diffraction</technique>" + " </instrument>" + " <instrument name=\"EFG2H\" shortname=\"EFG2H\">" + " <zeropadding size=\"8\"/>" + " <technique>Powder Diffraction</technique>" + " </instrument>" + " <instrument name=\"CRISP\" shortname=\"CSP\">" + " <technique>Technique</technique>" + " </instrument>" + " <instrument name=\"MUSR\">" + " <zeropadding size=\"8\"/>" + " <technique>Powder Diffraction</technique>" + " </instrument>" + " <instrument name=\"LOQ\">" + " <zeropadding size=\"5\"/>" + " <technique>Small Angle Scattering</technique>" + " </instrument>" + " <instrument name=\"OFFSPEC\">" + " <zeropadding size=\"8\"/>" + " <technique>Reflectometer</technique>" + " </instrument>" + " <instrument name=\"SANS2D\">" + " <zeropadding size=\"8\"/>" + " <technique>Small Angle Scattering</technique>" + " </instrument>" + " </facility>" + " <facility name=\"SNS\" delimiter=\"_\" " + "FileExtensions=\"_event.nxs,.nxs,.dat\">" + " <archive>" + " <archiveSearch plugin=\"ORNLDataSearch\" />" + " </archive>" + " <instrument name=\"SEQUOIA\" shortname=\"SEQ\">" + " <technique>Inelastic Spectroscopy</technique>" + " </instrument>" + " <instrument name=\"CNCS\" shortname=\"CNCS\">" + " <technique>Inelastic Spectroscopy</technique>" + " </instrument>" + " <instrument name=\"REF_L\" shortname=\"REF_L\">" + " <technique>Reflectometer</technique>" + " </instrument>" + " <instrument name=\"POWGEN\" shortname=\"PG3\">" + " <technique>Reflectometer</technique>" + " </instrument>" + " </facility>" + " <facility name=\"ILL\" delimiter=\"_\" FileExtensions=\".nxs,.dat\">" + " <instrument name=\"IN5\" shortname=\"IN5\">" + " <technique>Inelastic Spectroscopy</technique>" + " </instrument>" + " </facility>" + "</facilities>"; std::ofstream fil(m_facFile.path().c_str()); fil << xmlStr; @@ -157,13 +156,11 @@ public: // Set the facility ConfigService::Instance().setString("default.facility", "ISIS"); - const FacilityInfo &facility = - ConfigService::Instance().getFacility("ISIS"); + const FacilityInfo &facility = ConfigService::Instance().getFacility("ISIS"); const InstrumentInfo &instrument = facility.instrument("HRPD"); // Set the default instrument - ConfigService::Instance().setString("default.instrument", - instrument.shortName()); + ConfigService::Instance().setString("default.instrument", instrument.shortName()); std::string fName = FileFinder::Instance().makeFileName("123", instrument); TS_ASSERT_EQUALS(fName, "HRP00123"); @@ -174,18 +171,13 @@ public: fName = FileFinder::Instance().makeFileName("ABCD123", instrument); TS_ASSERT_EQUALS(fName, "ABC00000123"); - TS_ASSERT_THROWS( - fName = FileFinder::Instance().makeFileName("ABCD", instrument), - const std::invalid_argument &); - TS_ASSERT_THROWS( - fName = FileFinder::Instance().makeFileName("123456", instrument), - const std::invalid_argument &); + TS_ASSERT_THROWS(fName = FileFinder::Instance().makeFileName("ABCD", instrument), const std::invalid_argument &); + TS_ASSERT_THROWS(fName = FileFinder::Instance().makeFileName("123456", instrument), const std::invalid_argument &); fName = FileFinder::Instance().makeFileName("0", instrument); TS_ASSERT_EQUALS(fName, "HRP00000"); - TS_ASSERT_EQUALS("EFG2H00000123", FileFinder::Instance().makeFileName( - "EFG2H123", instrument)); + TS_ASSERT_EQUALS("EFG2H00000123", FileFinder::Instance().makeFileName("EFG2H123", instrument)); ConfigService::Instance().setString("default.facility", " "); } @@ -198,26 +190,20 @@ public: const InstrumentInfo &instrument = facility.instrument("CNCS"); // Set the default instrument - ConfigService::Instance().setString("default.instrument", - instrument.shortName()); + ConfigService::Instance().setString("default.instrument", instrument.shortName()); // Check that we remove any leading zeros - TS_ASSERT_EQUALS("CNCS_123", - FileFinder::Instance().makeFileName("0123", instrument)); + TS_ASSERT_EQUALS("CNCS_123", FileFinder::Instance().makeFileName("0123", instrument)); // Test using long and short name - TS_ASSERT_EQUALS( - "SEQ_21", FileFinder::Instance().makeFileName("SEQUOIA21", instrument)); - TS_ASSERT_EQUALS("SEQ_21", - FileFinder::Instance().makeFileName("SEQ21", instrument)); + TS_ASSERT_EQUALS("SEQ_21", FileFinder::Instance().makeFileName("SEQUOIA21", instrument)); + TS_ASSERT_EQUALS("SEQ_21", FileFinder::Instance().makeFileName("SEQ21", instrument)); // Test for POWGEN with a trailing number in the instrument name. - TS_ASSERT_EQUALS("PG3_333", - FileFinder::Instance().makeFileName("PG3333", instrument)); + TS_ASSERT_EQUALS("PG3_333", FileFinder::Instance().makeFileName("PG3333", instrument)); // Test for REF_L (to check that the extra _ doesn't upset anything) - TS_ASSERT_EQUALS("REF_L_666", FileFinder::Instance().makeFileName( - "REF_L666", instrument)); + TS_ASSERT_EQUALS("REF_L_666", FileFinder::Instance().makeFileName("REF_L666", instrument)); ConfigService::Instance().setString("default.facility", " "); } @@ -227,32 +213,16 @@ public: ConfigService::Instance().setString("default.instrument", "HRPD"); TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("").name(), "HRPD"); - TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("PG31234").name(), - "POWGEN"); - TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("PG3_1234").name(), - "POWGEN"); - TS_ASSERT_EQUALS( - FileFinder::Instance().getInstrument("PG3_1234_event.nxs").name(), - "POWGEN"); - TS_ASSERT_EQUALS( - FileFinder::Instance() - .getInstrument("/home/user123/CNCS_234_neutron_event.dat") - .name(), - "CNCS"); - TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("REF_L1234").name(), - "REF_L"); - TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("REF_L_1234").name(), - "REF_L"); - TS_ASSERT_EQUALS( - FileFinder::Instance().getInstrument("REF_L_1234.nxs.h5").name(), - "REF_L"); - TS_ASSERT_EQUALS( - FileFinder::Instance().getInstrument("LOQ16613.n001").name(), "LOQ"); - TS_ASSERT_EQUALS( - FileFinder::Instance().getInstrument("LOQ16613.s01").name(), "LOQ"); - TS_ASSERT_EQUALS( - FileFinder::Instance().getInstrument("SANS2D00032676.nxs").name(), - "SANS2D"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("PG31234").name(), "POWGEN"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("PG3_1234").name(), "POWGEN"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("PG3_1234_event.nxs").name(), "POWGEN"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("/home/user123/CNCS_234_neutron_event.dat").name(), "CNCS"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("REF_L1234").name(), "REF_L"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("REF_L_1234").name(), "REF_L"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("REF_L_1234.nxs.h5").name(), "REF_L"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("LOQ16613.n001").name(), "LOQ"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("LOQ16613.s01").name(), "LOQ"); + TS_ASSERT_EQUALS(FileFinder::Instance().getInstrument("SANS2D00032676.nxs").name(), "SANS2D"); } void testGetExtension() { @@ -261,23 +231,14 @@ public: TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("", exts), ""); TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("PG31234", exts), ""); TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("PG3_1234", exts), ""); - TS_ASSERT_EQUALS( - FileFinder::Instance().getExtension("PG3_1234_event.nxs", exts), - "_event.nxs"); - TS_ASSERT_EQUALS(FileFinder::Instance().getExtension( - "/home/user123/CNCS_234_neutron_event.dat", exts), + TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("PG3_1234_event.nxs", exts), "_event.nxs"); + TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("/home/user123/CNCS_234_neutron_event.dat", exts), ".dat"); // doesn't know about full extension - TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("REF_L1234", exts), - ""); - TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("REF_L_1234", exts), - ""); - TS_ASSERT_EQUALS( - FileFinder::Instance().getExtension("REF_L_1234.nxs.h5", exts), - ".nxs.h5"); - TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("LOQ16613.n001", exts), - ".n001"); - TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("LOQ16613.s01", exts), - ".s01"); + TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("REF_L1234", exts), ""); + TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("REF_L_1234", exts), ""); + TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("REF_L_1234.nxs.h5", exts), ".nxs.h5"); + TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("LOQ16613.n001", exts), ".n001"); + TS_ASSERT_EQUALS(FileFinder::Instance().getExtension("LOQ16613.s01", exts), ".s01"); } void testFindRunForSNS() { @@ -299,8 +260,7 @@ public: TS_ASSERT(path.find("CSP78173.raw") != std::string::npos); Poco::File file(path); TS_ASSERT(file.exists()); - path = FileFinder::Instance().findRun("CSP74683", - std::vector<std::string>(1, ".s02")); + path = FileFinder::Instance().findRun("CSP74683", std::vector<std::string>(1, ".s02")); TS_ASSERT(path.size() > 3); TS_ASSERT_EQUALS(path.substr(path.size() - 3), "s02"); @@ -314,23 +274,12 @@ public: void testFindFiles() { ConfigService::Instance().setString("default.facility", "ISIS"); std::vector<std::string> files; - TS_ASSERT_THROWS(files = - FileFinder::Instance().findRuns("MUSR15189-n15193"), - const std::invalid_argument &); - TS_ASSERT_THROWS(files = - FileFinder::Instance().findRuns("MUSR15189n-15193"), - const std::invalid_argument &); - TS_ASSERT_THROWS(files = - FileFinder::Instance().findRuns("MUSR15189-15193n"), - const std::invalid_argument &); - TS_ASSERT_THROWS(files = - FileFinder::Instance().findRuns("MUSR15189-151n93"), - const std::invalid_argument &); - TS_ASSERT_THROWS(files = - FileFinder::Instance().findRuns("MUSR15n189-151n93"), - const Exception::NotFoundError &); - TS_ASSERT_THROWS_NOTHING( - files = FileFinder::Instance().findRuns("MUSR15189-15193")); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189-n15193"), const std::invalid_argument &); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189n-15193"), const std::invalid_argument &); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189-15193n"), const std::invalid_argument &); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15189-151n93"), const std::invalid_argument &); + TS_ASSERT_THROWS(files = FileFinder::Instance().findRuns("MUSR15n189-151n93"), const Exception::NotFoundError &); + TS_ASSERT_THROWS_NOTHING(files = FileFinder::Instance().findRuns("MUSR15189-15193")); TS_ASSERT_EQUALS(files.size(), 5); std::vector<std::string>::iterator it = files.begin(); @@ -349,10 +298,8 @@ public: const std::vector<std::string> extensions2 = {".a", ".raw", ".txt"}; std::vector<std::string> uniqueExts = {".log"}; - const std::vector<std::string> expectedExts1 = {".log", ".raw", ".b", - ".txt"}; - const std::vector<std::string> expectedExts2 = {".log", ".raw", ".b", - ".txt", ".a"}; + const std::vector<std::string> expectedExts1 = {".log", ".raw", ".b", ".txt"}; + const std::vector<std::string> expectedExts2 = {".log", ".raw", ".b", ".txt", ".a"}; fileFinder.getUniqueExtensions(extensions1, uniqueExts); TS_ASSERT_EQUALS(uniqueExts.size(), expectedExts1.size()); @@ -376,10 +323,8 @@ public: const std::vector<std::string> extensions2 = {".a", ".raw", ".txt"}; std::vector<std::string> uniqueExts = {".log"}; - const std::vector<std::string> expectedExts1 = {".log", ".RAW", ".b", - ".txt"}; - const std::vector<std::string> expectedExts2 = {".log", ".RAW", ".b", - ".txt", ".a", ".raw"}; + const std::vector<std::string> expectedExts1 = {".log", ".RAW", ".b", ".txt"}; + const std::vector<std::string> expectedExts2 = {".log", ".RAW", ".b", ".txt", ".a", ".raw"}; fileFinder.getUniqueExtensions(extensions1, uniqueExts); TS_ASSERT_EQUALS(uniqueExts.size(), expectedExts1.size()); @@ -400,8 +345,7 @@ public: // This file is .nxs or .RAW const std::vector<std::string> incorrect_extension = {".txt"}; - path = - FileFinder::Instance().findRun("MUSR15189", incorrect_extension, true); + path = FileFinder::Instance().findRun("MUSR15189", incorrect_extension, true); TS_ASSERT_EQUALS(path, ""); } @@ -427,8 +371,7 @@ public: fil.close(); ConfigService::Instance().setString("default.facility", "ISIS"); - std::vector<std::string> files = - FileFinder::Instance().findRuns("LOQ111-add"); + std::vector<std::string> files = FileFinder::Instance().findRuns("LOQ111-add"); TS_ASSERT_EQUALS(files.size(), 1); file.remove(); @@ -459,8 +402,7 @@ public: void testFindRunsDefaultInst() { ConfigService::Instance().setString("default.instrument", "MUSR"); - std::vector<std::string> paths = - FileFinder::Instance().findRuns("15189-15190"); + std::vector<std::string> paths = FileFinder::Instance().findRuns("15189-15190"); TS_ASSERT(paths.size() == 2); } @@ -480,8 +422,7 @@ public: #endif Poco::File file(path); TS_ASSERT(file.exists()); - std::string path2 = - fileFinder.getFullPath("UNiT_TESTiNG/IDF_for_UNiT_TESTiNG.xMl"); + std::string path2 = fileFinder.getFullPath("UNiT_TESTiNG/IDF_for_UNiT_TESTiNG.xMl"); Poco::File file2(path2); TS_ASSERT(file2.exists()); @@ -490,12 +431,10 @@ public: std::string pathOn = fileFinder.findRun("CSp78173.Raw"); Poco::File fileOn(pathOn); - std::string pathOn2 = FileFinder::Instance().getFullPath( - "unit_TeSTinG/IDF_for_UNiT_TESTiNG.xMl"); + std::string pathOn2 = FileFinder::Instance().getFullPath("unit_TeSTinG/IDF_for_UNiT_TESTiNG.xMl"); Poco::File fileOn2(pathOn2); - std::string pathOn3 = FileFinder::Instance().getFullPath( - "unit_testing/IDF_for_UNiT_TESTiNG.xMl"); + std::string pathOn3 = FileFinder::Instance().getFullPath("unit_testing/IDF_for_UNiT_TESTiNG.xMl"); Poco::File fileOn3(pathOn3); std::string pathOn4 = FileFinder::Instance().getFullPath("CSp78173.Raw"); @@ -528,14 +467,11 @@ class FileFinderTestPerformance : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically // This means the constructor isn't called when running other tests - static FileFinderTestPerformance *createSuite() { - return new FileFinderTestPerformance(); - } + static FileFinderTestPerformance *createSuite() { return new FileFinderTestPerformance(); } static void destroySuite(FileFinderTestPerformance *suite) { delete suite; } FileFinderTestPerformance() - : m_oldDataSearchDirectories(), - m_dirPath("_FileFinderTestPerformanceDummyData"), + : m_oldDataSearchDirectories(), m_dirPath("_FileFinderTestPerformanceDummyData"), // Keeping these as low as possible so as to keep the time of the test // down, but users with 70,000+ files // in a single folder looking for a range of hundreds of files are not @@ -566,24 +502,19 @@ public: } // Set TOSCA as default instrument. - Mantid::Kernel::ConfigService::Instance().setString("default.instrument", - "TSC"); + Mantid::Kernel::ConfigService::Instance().setString("default.instrument", "TSC"); // Add dummy directory to search path, saving old search paths to be put // back later. Poco::Path path(dir.path()); path = path.makeAbsolute(); - m_oldDataSearchDirectories = - Mantid::Kernel::ConfigService::Instance().getString( - "datasearch.directories"); - Mantid::Kernel::ConfigService::Instance().setString( - "datasearch.directories", path.toString()); + m_oldDataSearchDirectories = Mantid::Kernel::ConfigService::Instance().getString("datasearch.directories"); + Mantid::Kernel::ConfigService::Instance().setString("datasearch.directories", path.toString()); } ~FileFinderTestPerformance() override { // Put back the old search paths. - Mantid::Kernel::ConfigService::Instance().setString( - "datasearch.directories", m_oldDataSearchDirectories); + Mantid::Kernel::ConfigService::Instance().setString("datasearch.directories", m_oldDataSearchDirectories); // Destroy dummy folder and files. // Use Poco here so removing works on multiple platforms. Recursive @@ -623,8 +554,7 @@ public: // could reintroduce this problem. std::vector<std::string> files; std::stringstream range; - std::string startOfRange = - boost::lexical_cast<std::string>(m_filesInDir - 10); + std::string startOfRange = boost::lexical_cast<std::string>(m_filesInDir - 10); std::string accidentalEndOfRange = "99999"; range << startOfRange << "-" << accidentalEndOfRange; TS_ASSERT_THROWS(files = fileFinder.findRuns(range.str().c_str()), diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h b/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h index c68729d56ec..2edfcf6058f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h @@ -59,13 +59,9 @@ public: /// Algorithm's version int version() const override { return (1); } - const std::vector<std::string> seeAlso() const override { - return {"SumSpectra", "SumNeighbours"}; - } + const std::vector<std::string> seeAlso() const override { return {"SumSpectra", "SumNeighbours"}; } /// Algorithm's category for identification - const std::string category() const override { - return "SANS;Transforms\\Grouping"; - } + const std::string category() const override { return "SANS;Transforms\\Grouping"; } private: /// Initialisation code diff --git a/Framework/Algorithms/test/TimeAtSampleStrategyDirectTest.h b/Framework/Algorithms/test/TimeAtSampleStrategyDirectTest.h index 08f33e4748b..6f6d7f89566 100644 --- a/Framework/Algorithms/test/TimeAtSampleStrategyDirectTest.h +++ b/Framework/Algorithms/test/TimeAtSampleStrategyDirectTest.h @@ -23,19 +23,14 @@ class TimeAtSampleStrategyDirectTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically // This means the constructor isn't called when running other tests - static TimeAtSampleStrategyDirectTest *createSuite() { - return new TimeAtSampleStrategyDirectTest(); - } - static void destroySuite(TimeAtSampleStrategyDirectTest *suite) { - delete suite; - } + static TimeAtSampleStrategyDirectTest *createSuite() { return new TimeAtSampleStrategyDirectTest(); } + static void destroySuite(TimeAtSampleStrategyDirectTest *suite) { delete suite; } void test_L2_detector() { using namespace Mantid; using namespace Mantid::Geometry; - auto ws = - WorkspaceCreationHelper::create2DWorkspaceWithReflectometryInstrument(); + auto ws = WorkspaceCreationHelper::create2DWorkspaceWithReflectometryInstrument(); auto instrument = ws->getInstrument(); @@ -53,8 +48,7 @@ public: const double shift = correction.factor; - double expectedShift = L1 / std::sqrt(ei * 2. * PhysicalConstants::meV / - PhysicalConstants::NeutronMass); + double expectedShift = L1 / std::sqrt(ei * 2. * PhysicalConstants::meV / PhysicalConstants::NeutronMass); TSM_ASSERT_DELTA("L1 / (L1 + L2)", expectedShift, shift, 0.0000001); } diff --git a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h index b9d701e97d3..41e9634cfa9 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h @@ -31,8 +31,7 @@ namespace Crystal { @author Ruth Mikkelson, SNS,ORNL @date 01/26/2013 */ -class MANTID_CRYSTAL_DLL PeakHKLErrors : public API::ParamFunction, - public API::IFunction1D { +class MANTID_CRYSTAL_DLL PeakHKLErrors : public API::ParamFunction, public API::IFunction1D { public: PeakHKLErrors(); @@ -42,11 +41,9 @@ public: const std::string category() const override { return "Calibration"; }; - void function1D(double *out, const double *xValues, - const size_t nData) const override; + void function1D(double *out, const double *xValues, const size_t nData) const override; - void functionDeriv1D(Mantid::API::Jacobian *out, const double *xValues, - const size_t nData) override; + void functionDeriv1D(Mantid::API::Jacobian *out, const double *xValues, const size_t nData) override; void init() override; @@ -67,33 +64,24 @@ public: * @return The new peak with the new instrument( adjusted with the *parameters) and time adjusted. */ - static DataObjects::Peak - createNewPeak(const DataObjects::Peak &peak_old, - const Geometry::Instrument_sptr &instrNew, double T0, - double L0); - - static void - cLone(std::shared_ptr<Geometry::ParameterMap> &pmap, - const std::shared_ptr<const Geometry::IComponent> &component, - std::shared_ptr<const Geometry::ParameterMap> &pmapSv); - - void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks, - const std::string &OptRuns, + static DataObjects::Peak createNewPeak(const DataObjects::Peak &peak_old, const Geometry::Instrument_sptr &instrNew, + double T0, double L0); + + static void cLone(std::shared_ptr<Geometry::ParameterMap> &pmap, + const std::shared_ptr<const Geometry::IComponent> &component, + std::shared_ptr<const Geometry::ParameterMap> &pmapSv); + + void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks, const std::string &OptRuns, std::map<int, Mantid::Kernel::Matrix<double>> &Res) const; size_t nAttributes() const override { return (size_t)2; } - static Kernel::Matrix<double> DerivRotationMatrixAboutRegAxis(double theta, - char axis); + static Kernel::Matrix<double> DerivRotationMatrixAboutRegAxis(double theta, char axis); - static Kernel::Matrix<double> RotationMatrixAboutRegAxis(double theta, - char axis); + static Kernel::Matrix<double> RotationMatrixAboutRegAxis(double theta, char axis); - std::shared_ptr<Geometry::Instrument> - getNewInstrument(const DataObjects::PeaksWorkspace_sptr &Peaks) const; + std::shared_ptr<Geometry::Instrument> getNewInstrument(const DataObjects::PeaksWorkspace_sptr &Peaks) const; - std::vector<std::string> getAttributeNames() const override { - return {"OptRuns", "PeakWorkspaceName"}; - } + std::vector<std::string> getAttributeNames() const override { return {"OptRuns", "PeakWorkspaceName"}; } IFunction::Attribute getAttribute(const std::string &attName) const override { if (attName == "OptRuns") @@ -105,8 +93,7 @@ public: throw std::invalid_argument("Not a valid attribute name"); } - void setAttribute(const std::string &attName, - const IFunction::Attribute &value) override { + void setAttribute(const std::string &attName, const IFunction::Attribute &value) override { if (attName == "OptRuns") { OptRuns = value.asString(); diff --git a/Framework/Crystal/src/FindUBUsingMinMaxD.cpp b/Framework/Crystal/src/FindUBUsingMinMaxD.cpp index 87631d2bca7..e524108d79b 100644 --- a/Framework/Crystal/src/FindUBUsingMinMaxD.cpp +++ b/Framework/Crystal/src/FindUBUsingMinMaxD.cpp @@ -30,21 +30,16 @@ FindUBUsingMinMaxD::FindUBUsingMinMaxD() { deprecatedDate("2013-06-03"); } -const std::string FindUBUsingMinMaxD::name() const { - return "FindUBUsingMinMaxD"; -} +const std::string FindUBUsingMinMaxD::name() const { return "FindUBUsingMinMaxD"; } int FindUBUsingMinMaxD::version() const { return 1; } -const std::string FindUBUsingMinMaxD::category() const { - return "Crystal\\UBMatrix"; -} +const std::string FindUBUsingMinMaxD::category() const { return "Crystal\\UBMatrix"; } /** Initialize the algorithm's properties. */ void FindUBUsingMinMaxD::init() { - this->declareProperty(std::make_unique<WorkspaceProperty<IPeaksWorkspace>>( - "PeaksWorkspace", "", Direction::InOut), + this->declareProperty(std::make_unique<WorkspaceProperty<IPeaksWorkspace>>("PeaksWorkspace", "", Direction::InOut), "Input Peaks Workspace"); auto mustBePositive = std::make_shared<BoundedValidator<double>>(); @@ -54,21 +49,17 @@ void FindUBUsingMinMaxD::init() { atLeast3Int->setLower(3); // use negative values, force user to input all parameters - this->declareProperty(std::make_unique<PropertyWithValue<double>>( - "MinD", -1.0, mustBePositive, Direction::Input), + this->declareProperty(std::make_unique<PropertyWithValue<double>>("MinD", -1.0, mustBePositive, Direction::Input), "Lower Bound on Lattice Parameters a, b, c"); - this->declareProperty(std::make_unique<PropertyWithValue<double>>( - "MaxD", -1.0, mustBePositive, Direction::Input), + this->declareProperty(std::make_unique<PropertyWithValue<double>>("MaxD", -1.0, mustBePositive, Direction::Input), "Upper Bound on Lattice Parameters a, b, c"); - this->declareProperty(std::make_unique<PropertyWithValue<int>>( - "NumInitial", 20, atLeast3Int, Direction::Input), + this->declareProperty(std::make_unique<PropertyWithValue<int>>("NumInitial", 20, atLeast3Int, Direction::Input), "Number of Peaks to Use on First Pass(20)"); this->declareProperty( - std::make_unique<PropertyWithValue<double>>( - "Tolerance", 0.15, mustBePositive, Direction::Input), + std::make_unique<PropertyWithValue<double>>("Tolerance", 0.15, mustBePositive, Direction::Input), "Indexing Tolerance (0.15)"); } @@ -98,16 +89,14 @@ void FindUBUsingMinMaxD::exec() { Matrix<double> UB(3, 3, false); double error = - IndexingUtils::Find_UB(UB, q_vectors, min_d, max_d, tolerance, base_index, - num_initial, degrees_per_step); + IndexingUtils::Find_UB(UB, q_vectors, min_d, max_d, tolerance, base_index, num_initial, degrees_per_step); std::cout << "Error = " << error << '\n'; std::cout << "UB = " << UB << '\n'; if (!IndexingUtils::CheckUB(UB)) // UB not found correctly { - g_log.notice(std::string( - "Found Invalid UB...peaks used might not be linearly independent")); + g_log.notice(std::string("Found Invalid UB...peaks used might not be linearly independent")); g_log.notice(std::string("UB NOT SAVED.")); } else // tell user how many would be indexed { // and save the UB in the sample @@ -118,23 +107,18 @@ void FindUBUsingMinMaxD::exec() { double fit_error; miller_ind.reserve(q_vectors.size()); indexed_qs.reserve(q_vectors.size()); - IndexingUtils::GetIndexedPeaks(UB, q_vectors, tolerance, miller_ind, - indexed_qs, fit_error); + IndexingUtils::GetIndexedPeaks(UB, q_vectors, tolerance, miller_ind, indexed_qs, fit_error); IndexingUtils::Optimize_UB(UB, miller_ind, indexed_qs, sigabc); char logInfo[200]; int num_indexed = IndexingUtils::NumberIndexed(UB, q_vectors, tolerance); - sprintf(logInfo, - std::string( - "New UB will index %1d Peaks out of %1d with tolerance %5.3f") - .c_str(), - num_indexed, n_peaks, tolerance); + sprintf(logInfo, std::string("New UB will index %1d Peaks out of %1d with tolerance %5.3f").c_str(), num_indexed, + n_peaks, tolerance); g_log.notice(std::string(logInfo)); auto lattice = std::make_unique<OrientedLattice>(); lattice->setUB(UB); - lattice->setError(sigabc[0], sigabc[1], sigabc[2], sigabc[3], sigabc[4], - sigabc[5]); + lattice->setError(sigabc[0], sigabc[1], sigabc[2], sigabc[3], sigabc[4], sigabc[5]); // Show the modified lattice parameters g_log.notice() << *lattice << "\n"; ws->mutableSample().setOrientedLattice(std::move(lattice)); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/Bk2BkExpConvPV.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/Bk2BkExpConvPV.h index b63140478d7..dce49eddef3 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/Bk2BkExpConvPV.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/Bk2BkExpConvPV.h @@ -22,9 +22,7 @@ namespace Functions { @date 2012-06-06 */ -class MANTID_CURVEFITTING_DLL Bk2BkExpConvPV - : virtual public API::IPeakFunction, - virtual public API::IFunctionMW { +class MANTID_CURVEFITTING_DLL Bk2BkExpConvPV : virtual public API::IPeakFunction, virtual public API::IFunctionMW { public: Bk2BkExpConvPV(); @@ -47,16 +45,13 @@ public: /// void resetFWHM(); - void setMatrixWorkspace(std::shared_ptr<const API::MatrixWorkspace> workspace, - size_t wi, double startX, double endX) override; + void setMatrixWorkspace(std::shared_ptr<const API::MatrixWorkspace> workspace, size_t wi, double startX, + double endX) override; protected: - void functionLocal(double *out, const double *xValues, - const size_t nData) const override; - void functionDerivLocal(API::Jacobian *out, const double *xValues, - const size_t nData) override; - void functionDeriv(const API::FunctionDomain &domain, - API::Jacobian &jacobian) override; + void functionLocal(double *out, const double *xValues, const size_t nData) const override; + void functionDerivLocal(API::Jacobian *out, const double *xValues, const size_t nData) override; + void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override; /// overwrite IFunction base class method, which declare function parameters void init() override; @@ -65,8 +60,8 @@ private: /// container for storing wavelength values for each data point mutable std::vector<double> m_dtt1; - double calOmega(double x, double eta, double N, double alpha, double beta, - double H, double sigma2, double invert_sqrt2sigma) const; + double calOmega(double x, double eta, double N, double alpha, double beta, double H, double sigma2, + double invert_sqrt2sigma) const; std::complex<double> E1(std::complex<double> z) const; diff --git a/Framework/CurveFitting/src/Functions/BSpline.cpp b/Framework/CurveFitting/src/Functions/BSpline.cpp index 4d1df4280ca..b5a69bcdaea 100644 --- a/Framework/CurveFitting/src/Functions/BSpline.cpp +++ b/Framework/CurveFitting/src/Functions/BSpline.cpp @@ -32,9 +32,7 @@ struct ReleaseBSplineWorkspace { #if GSL_MAJOR_VERSION < 2 // shared pointer deleter for bspline derivative workspace struct ReleaseBSplineDerivativeWorkspace { - void operator()(gsl_bspline_deriv_workspace *ws) { - gsl_bspline_deriv_free(ws); - } + void operator()(gsl_bspline_deriv_workspace *ws) { gsl_bspline_deriv_free(ws); } }; #endif } // namespace @@ -63,8 +61,7 @@ BSpline::BSpline() { * @param xValues :: The array of x values to interpolate * @param nData :: The size of the arrays */ -void BSpline::function1D(double *out, const double *xValues, - const size_t nData) const { +void BSpline::function1D(double *out, const double *xValues, const size_t nData) const { size_t np = nParams(); GSLVector B(np); double startX = getAttribute("StartX").asDouble(); @@ -96,16 +93,14 @@ void BSpline::function1D(double *out, const double *xValues, * @param nData :: The size of the arrays * @param order :: The order of the derivatives o calculate */ -void BSpline::derivative1D(double *out, const double *xValues, size_t nData, - const size_t order) const { +void BSpline::derivative1D(double *out, const double *xValues, size_t nData, const size_t order) const { int splineOrder = getAttribute("Order").asInt(); auto k = static_cast<size_t>(splineOrder); #if GSL_MAJOR_VERSION < 2 if (!m_bsplineDerivWorkspace) { gsl_bspline_deriv_workspace *ws = gsl_bspline_deriv_alloc(k); - m_bsplineDerivWorkspace = std::shared_ptr<gsl_bspline_deriv_workspace>( - ws, ReleaseBSplineDerivativeWorkspace()); + m_bsplineDerivWorkspace = std::shared_ptr<gsl_bspline_deriv_workspace>(ws, ReleaseBSplineDerivativeWorkspace()); } #endif @@ -125,12 +120,10 @@ void BSpline::derivative1D(double *out, const double *xValues, size_t nData, size_t jstart(0); size_t jend(0); #if GSL_MAJOR_VERSION < 2 - gsl_bspline_deriv_eval_nonzero(x, order, B.gsl(), &jstart, &jend, - m_bsplineWorkspace.get(), + gsl_bspline_deriv_eval_nonzero(x, order, B.gsl(), &jstart, &jend, m_bsplineWorkspace.get(), m_bsplineDerivWorkspace.get()); #else - gsl_bspline_deriv_eval_nonzero(x, order, B.gsl(), &jstart, &jend, - m_bsplineWorkspace.get()); + gsl_bspline_deriv_eval_nonzero(x, order, B.gsl(), &jstart, &jend, m_bsplineWorkspace.get()); #endif double val = 0.0; for (size_t j = jstart; j <= jend; ++j) { @@ -146,14 +139,12 @@ void BSpline::derivative1D(double *out, const double *xValues, size_t nData, * @param attName :: The name of the attribute to set * @param att :: The attribute to set */ -void BSpline::setAttribute(const std::string &attName, - const API::IFunction::Attribute &att) { +void BSpline::setAttribute(const std::string &attName, const API::IFunction::Attribute &att) { bool isUniform = attName == "Uniform" && att.asBool(); storeAttributeValue(attName, att); - if (attName == "BreakPoints" || isUniform || attName == "StartX" || - attName == "EndX") { + if (attName == "BreakPoints" || isUniform || attName == "StartX" || attName == "EndX") { resetKnots(); } else if (attName == "NBreak" || attName == "Order") { resetGSLObjects(); @@ -181,10 +172,8 @@ void BSpline::resetGSLObjects() { if (nbreak < 2) { throw std::invalid_argument("BSpline: NBreak must be at least 2."); } - gsl_bspline_workspace *ws = gsl_bspline_alloc(static_cast<size_t>(order), - static_cast<size_t>(nbreak)); - m_bsplineWorkspace = - std::shared_ptr<gsl_bspline_workspace>(ws, ReleaseBSplineWorkspace()); + gsl_bspline_workspace *ws = gsl_bspline_alloc(static_cast<size_t>(order), static_cast<size_t>(nbreak)); + m_bsplineWorkspace = std::shared_ptr<gsl_bspline_workspace>(ws, ReleaseBSplineWorkspace()); #if GSL_MAJOR_VERSION < 2 m_bsplineDerivWorkspace.reset(); #endif @@ -234,8 +223,7 @@ void BSpline::resetKnots() { int nbreaks = getAttribute("NBreak").asInt(); // if number of break points change do necessary updates if (static_cast<size_t>(nbreaks) != breakPoints.size()) { - storeAttributeValue("NBreak", - Attribute(static_cast<int>(breakPoints.size()))); + storeAttributeValue("NBreak", Attribute(static_cast<int>(breakPoints.size()))); resetGSLObjects(); resetParameters(); } diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp index 6989124844d..cb727c4c2df 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp @@ -26,10 +26,8 @@ namespace Functions { namespace { // Does the actual calculation of the magnetisation -void calculate(double *out, const double *xValues, const size_t nData, - const ComplexFortranMatrix &ham, const int nre, - const DoubleFortranVector &Hmag, const double T, - const double convfact, const bool iscgs) { +void calculate(double *out, const double *xValues, const size_t nData, const ComplexFortranMatrix &ham, const int nre, + const DoubleFortranVector &Hmag, const double T, const double convfact, const bool iscgs) { const double beta = 1 / (PhysicalConstants::BoltzmannConstant * T); // x-data is the applied field magnitude. We need to recalculate // the Zeeman term and diagonalise the Hamiltonian at each x-point. @@ -58,9 +56,8 @@ void calculate(double *out, const double *xValues, const size_t nData, } // Calculate powder average - Mpowder = (Mx + My + Mz)/3 -void calculate_powder(double *out, const double *xValues, const size_t nData, - const ComplexFortranMatrix &ham, const int nre, - const double T, const double convfact, const bool cgs) { +void calculate_powder(double *out, const double *xValues, const size_t nData, const ComplexFortranMatrix &ham, + const int nre, const double T, const double convfact, const bool cgs) { for (size_t j = 0; j < nData; j++) { out[j] = 0.; } @@ -81,8 +78,7 @@ void calculate_powder(double *out, const double *xValues, const size_t nData, } } // namespace -CrystalFieldMagnetisationBase::CrystalFieldMagnetisationBase() - : API::IFunction1D(), m_nre(0) { +CrystalFieldMagnetisationBase::CrystalFieldMagnetisationBase() : API::IFunction1D(), m_nre(0) { declareAttribute("Hdir", Attribute(std::vector<double>{0., 0., 1.})); declareAttribute("Temperature", Attribute(1.0)); declareAttribute("Unit", Attribute("bohr")); // others = "SI", "cgs" @@ -90,9 +86,7 @@ CrystalFieldMagnetisationBase::CrystalFieldMagnetisationBase() declareAttribute("ScaleFactor", Attribute(1.0)); // Only for multi-site use } -void CrystalFieldMagnetisationBase::function1D(double *out, - const double *xValues, - const size_t nData) const { +void CrystalFieldMagnetisationBase::function1D(double *out, const double *xValues, const size_t nData) const { // Get the field direction auto Hdir = getAttribute("Hdir").asVector(); if (Hdir.size() != 3) { @@ -100,8 +94,7 @@ void CrystalFieldMagnetisationBase::function1D(double *out, } auto T = getAttribute("Temperature").asDouble(); auto powder = getAttribute("powder").asBool(); - double Hnorm = - sqrt(Hdir[0] * Hdir[0] + Hdir[1] * Hdir[1] + Hdir[2] * Hdir[2]); + double Hnorm = sqrt(Hdir[0] * Hdir[0] + Hdir[1] * Hdir[1] + Hdir[2] * Hdir[2]); DoubleFortranVector H(1, 3); if (fabs(Hnorm) > 1.e-6) { for (auto i = 0; i < 3; i++) { @@ -114,9 +107,7 @@ void CrystalFieldMagnetisationBase::function1D(double *out, // cgs is in erg/Gauss/mol (emu/mol). The value of uB in erg/G is 1000x in J/T // NB. Atomic ("bohr") units gives magnetisation in uB/ion, but other units // give the molar magnetisation. - double convfact = boost::iequals(unit, "SI") - ? NAMUB - : (boost::iequals(unit, "cgs") ? NAMUB * 1000. : 1.); + double convfact = boost::iequals(unit, "SI") ? NAMUB : (boost::iequals(unit, "cgs") ? NAMUB * 1000. : 1.); const bool iscgs = boost::iequals(unit, "cgs"); // Use stored values if (powder) { @@ -135,19 +126,16 @@ void CrystalFieldMagnetisationBase::function1D(double *out, DECLARE_FUNCTION(CrystalFieldMagnetisation) CrystalFieldMagnetisation::CrystalFieldMagnetisation() - : CrystalFieldPeaksBase(), CrystalFieldMagnetisationBase(), - m_setDirect(false) {} + : CrystalFieldPeaksBase(), CrystalFieldMagnetisationBase(), m_setDirect(false) {} // Sets the base crystal field Hamiltonian matrix -void CrystalFieldMagnetisation::setHamiltonian(const ComplexFortranMatrix &ham, - const int nre) { +void CrystalFieldMagnetisation::setHamiltonian(const ComplexFortranMatrix &ham, const int nre) { m_setDirect = true; m_ham = ham; m_nre = nre; } -void CrystalFieldMagnetisation::function1D(double *out, const double *xValues, - const size_t nData) const { +void CrystalFieldMagnetisation::function1D(double *out, const double *xValues, const size_t nData) const { if (!m_setDirect) { DoubleFortranVector en; ComplexFortranMatrix wf; @@ -162,8 +150,7 @@ CrystalFieldMagnetisationCalculation::CrystalFieldMagnetisationCalculation() : API::ParamFunction(), CrystalFieldMagnetisationBase() {} // Sets the base crystal field Hamiltonian matrix -void CrystalFieldMagnetisationCalculation::setHamiltonian( - const ComplexFortranMatrix &ham, const int nre) { +void CrystalFieldMagnetisationCalculation::setHamiltonian(const ComplexFortranMatrix &ham, const int nre) { m_ham = ham; m_nre = nre; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h index 3ea592a1fd0..933410bea3e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h @@ -24,9 +24,7 @@ class DLLExport SaveDiffCal : public API::Algorithm { public: const std::string name() const override; int version() const override; - const std::vector<std::string> seeAlso() const override { - return {"LoadDiffCal"}; - } + const std::vector<std::string> seeAlso() const override { return {"LoadDiffCal"}; } const std::string category() const override; const std::string summary() const override; @@ -37,9 +35,8 @@ private: void writeDoubleFieldFromTable(H5::Group &group, const std::string &name); void writeIntFieldFromTable(H5::Group &group, const std::string &name); - void - writeIntFieldFromSVWS(H5::Group &group, const std::string &name, - const DataObjects::SpecialWorkspace2D_const_sptr &ws); + void writeIntFieldFromSVWS(H5::Group &group, const std::string &name, + const DataObjects::SpecialWorkspace2D_const_sptr &ws); void generateDetidToIndex(); bool tableHasColumn(const std::string &ColumnName) const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h index 8dcceff7f8f..3fe184be1db 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h @@ -23,15 +23,11 @@ public: ~SaveNXcanSAS() override {} const std::string name() const override { return "SaveNXcanSAS"; } /// Summary of algorithms purpose - const std::string summary() const override { - return "Writes a MatrixWorkspace to a file in the NXcanSAS format."; - } + const std::string summary() const override { return "Writes a MatrixWorkspace to a file in the NXcanSAS format."; } /// Algorithm's version int version() const override { return (1); } - const std::vector<std::string> seeAlso() const override { - return {"SaveCanSAS1D", "LoadNXcanSAS"}; - } + const std::vector<std::string> seeAlso() const override { return {"SaveCanSAS1D", "LoadNXcanSAS"}; } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Nexus"; } @@ -44,8 +40,7 @@ private: void exec() override; }; -std::string MANTID_DATAHANDLING_DLL -makeCanSASRelaxedName(const std::string &input); +std::string MANTID_DATAHANDLING_DLL makeCanSASRelaxedName(const std::string &input); } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/src/XmlHandler.cpp b/Framework/DataHandling/src/XmlHandler.cpp index 4c4c2ae194e..d9cb0712894 100644 --- a/Framework/DataHandling/src/XmlHandler.cpp +++ b/Framework/DataHandling/src/XmlHandler.cpp @@ -35,8 +35,7 @@ XmlHandler::XmlHandler(const std::string &filename) { * Composed tags: / replaced by _ * */ -std::map<std::string, std::string> -XmlHandler::get_metadata(const std::vector<std::string> &tags_to_ignore) { +std::map<std::string, std::string> XmlHandler::get_metadata(const std::vector<std::string> &tags_to_ignore) { std::map<std::string, std::string> metadata; Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT); @@ -44,11 +43,9 @@ XmlHandler::get_metadata(const std::vector<std::string> &tags_to_ignore) { while (pNode) { Poco::AutoPtr<Poco::XML::NodeList> children = pNode->childNodes(); - if (children->length() == 1 && - std::find(std::begin(tags_to_ignore), std::end(tags_to_ignore), - pNode->nodeName()) == std::end(tags_to_ignore)) { - std::string key = - pNode->parentNode()->nodeName() + "/" + pNode->nodeName(); + if (children->length() == 1 && std::find(std::begin(tags_to_ignore), std::end(tags_to_ignore), pNode->nodeName()) == + std::end(tags_to_ignore)) { + std::string key = pNode->parentNode()->nodeName() + "/" + pNode->nodeName(); std::string value = pNode->innerText(); boost::algorithm::trim(value); metadata.emplace(key, value); @@ -68,15 +65,13 @@ std::string XmlHandler::get_text_from_tag(const std::string &xpath) { return value; } -std::map<std::string, std::string> -XmlHandler::get_attributes_from_tag(const std::string &xpath) { +std::map<std::string, std::string> XmlHandler::get_attributes_from_tag(const std::string &xpath) { std::map<std::string, std::string> attributes_map; Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ELEMENT); Poco::XML::Node *pNode = it.nextNode(); Poco::XML::Node *detectorNode = pNode->getNodeByPath(xpath); if (detectorNode) { - Poco::AutoPtr<Poco::XML::NamedNodeMap> attributes = - detectorNode->attributes(); + Poco::AutoPtr<Poco::XML::NamedNodeMap> attributes = detectorNode->attributes(); for (unsigned int i = 0; i < attributes->length(); i++) { Poco::XML::Node *attribute = attributes->item(i); attributes_map.emplace(attribute->nodeName(), attribute->nodeValue()); diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index 014d80567dd..03e1cd474b9 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -43,9 +43,7 @@ class LoadEventPreNexus2Test : public CxxTest::TestSuite { public: std::unique_ptr<LoadEventPreNexus2> eventLoader; - static LoadEventPreNexus2Test *createSuite() { - return new LoadEventPreNexus2Test(); - } + static LoadEventPreNexus2Test *createSuite() { return new LoadEventPreNexus2Test(); } static void destroySuite(LoadEventPreNexus2Test *suite) { delete suite; } LoadEventPreNexus2Test() {} @@ -56,8 +54,7 @@ public: } void test_file_not_found() { - TS_ASSERT_THROWS(eventLoader->setPropertyValue( - "EventFilename", "this_file_doesnt_exist.blabla.data"), + TS_ASSERT_THROWS(eventLoader->setPropertyValue("EventFilename", "this_file_doesnt_exist.blabla.data"), const std::invalid_argument &); // Execute fails since the properties aren't set correctly. TS_ASSERT_THROWS(eventLoader->execute(), const std::runtime_error &); @@ -69,14 +66,12 @@ public: TS_ASSERT_EQUALS(sizeof(DasEvent), 8); } - void checkWorkspace(const std::string &eventfile, const std::string &WSName, - int numpixels_with_events) { + void checkWorkspace(const std::string &eventfile, const std::string &WSName, int numpixels_with_events) { // Get the event file size struct stat filestatus; stat(eventfile.c_str(), &filestatus); - EventWorkspace_sptr ew = - AnalysisDataService::Instance().retrieveWS<EventWorkspace>(WSName); + EventWorkspace_sptr ew = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(WSName); // The # of events = size of the file / 8 bytes (per event) TS_ASSERT_EQUALS(ew->getNumberEvents(), filestatus.st_size / 8); @@ -119,13 +114,12 @@ public: // std::cout << "***** executing *****\n"; TS_ASSERT(eventLoader->execute()); - EventWorkspace_sptr ew = std::dynamic_pointer_cast<EventWorkspace>( - AnalysisDataService::Instance().retrieve("LoadPreNexus2_cncs")); + EventWorkspace_sptr ew = + std::dynamic_pointer_cast<EventWorkspace>(AnalysisDataService::Instance().retrieve("LoadPreNexus2_cncs")); // Get the start time of all pulses Kernel::TimeSeriesProperty<double> *log = - dynamic_cast<Kernel::TimeSeriesProperty<double> *>( - ew->mutableRun().getProperty("proton_charge")); + dynamic_cast<Kernel::TimeSeriesProperty<double> *>(ew->mutableRun().getProperty("proton_charge")); std::map<DateAndTime, double> logMap = log->valueAsMap(); std::map<DateAndTime, double>::iterator it, it2; it = logMap.begin(); @@ -139,9 +133,7 @@ public: void test_LoadPreNeXus_CNCS() { do_test_LoadPreNeXus_CNCS("Serial"); } - void test_LoadPreNeXus_CNCS_parallel() { - do_test_LoadPreNeXus_CNCS("Parallel"); - } + void test_LoadPreNeXus_CNCS_parallel() { do_test_LoadPreNeXus_CNCS("Parallel"); } void do_test_LoadPreNeXus_CNCS(const std::string ¶llel) { std::string eventfile("CNCS_7860_neutron_event.dat"); @@ -157,8 +149,8 @@ public: // std::cout << "***** executing *****\n"; TS_ASSERT(eventLoader->execute()); - EventWorkspace_sptr ew = std::dynamic_pointer_cast<EventWorkspace>( - AnalysisDataService::Instance().retrieve("LoadPreNexus2_cncs")); + EventWorkspace_sptr ew = + std::dynamic_pointer_cast<EventWorkspace>(AnalysisDataService::Instance().retrieve("LoadPreNexus2_cncs")); /* * LoadEventPreNexusTest.h * @@ -192,8 +184,7 @@ public: // Bunch of checks TS_ASSERT_EQUALS(outputWS->getNumberEvents(), inputWS->getNumberEvents()); - TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), - inputWS->getNumberHistograms()); + TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), inputWS->getNumberHistograms()); TS_ASSERT_EQUALS(outputWS->getInstrument()->getName(), "CNCS"); std::size_t wkspIndex = 4348; // a good workspace index (with events) @@ -218,8 +209,7 @@ public: // Check the run_start property exists and is right. Property *p = nullptr; TS_ASSERT(outputWS->mutableRun().hasProperty("run_start")); - TS_ASSERT_THROWS_NOTHING( - p = outputWS->mutableRun().getProperty("run_start");) + TS_ASSERT_THROWS_NOTHING(p = outputWS->mutableRun().getProperty("run_start");) if (p) { TS_ASSERT_EQUALS(p->value(), "2010-03-25T16:08:37.457381666"); } @@ -229,8 +219,7 @@ public: std::string eventfile("CNCS_7860_neutron_event.dat"); eventLoader->setPropertyValue("EventFilename", eventfile); eventLoader->setPropertyValue("MappingFilename", "CNCS_TS_2008_08_18.dat"); - eventLoader->setPropertyValue("OutputWorkspace", - "LoadPreNexus2_cncs_skipped"); + eventLoader->setPropertyValue("OutputWorkspace", "LoadPreNexus2_cncs_skipped"); // Load just 2 pixels eventLoader->setProperty("SpectrumList", "45, 110"); @@ -261,8 +250,7 @@ public: } void test_invalid_chunk_number() { - eventLoader->setPropertyValue("EventFilename", - "CNCS_7860_neutron_event.dat"); + eventLoader->setPropertyValue("EventFilename", "CNCS_7860_neutron_event.dat"); eventLoader->setPropertyValue("ChunkNumber", "3"); eventLoader->setPropertyValue("TotalChunks", "2"); TS_ASSERT_THROWS(eventLoader->execute(), const std::runtime_error &); @@ -270,24 +258,22 @@ public: void test_loading_chunks() { // Load chunk 1 of 2 - eventLoader->setPropertyValue("EventFilename", - "CNCS_7860_neutron_event.dat"); + eventLoader->setPropertyValue("EventFilename", "CNCS_7860_neutron_event.dat"); eventLoader->setPropertyValue("ChunkNumber", "1"); eventLoader->setPropertyValue("TotalChunks", "2"); eventLoader->setPropertyValue("OutputWorkspace", "LoadPreNexus2_chunk1"); TS_ASSERT(eventLoader->execute()); - EventWorkspace_sptr chunk1 = std::dynamic_pointer_cast<EventWorkspace>( - AnalysisDataService::Instance().retrieve("LoadPreNexus2_chunk1")); + EventWorkspace_sptr chunk1 = + std::dynamic_pointer_cast<EventWorkspace>(AnalysisDataService::Instance().retrieve("LoadPreNexus2_chunk1")); // Load chunk 2 of 2 - eventLoader->setPropertyValue("EventFilename", - "CNCS_7860_neutron_event.dat"); + eventLoader->setPropertyValue("EventFilename", "CNCS_7860_neutron_event.dat"); eventLoader->setPropertyValue("ChunkNumber", "2"); eventLoader->setPropertyValue("TotalChunks", "2"); eventLoader->setPropertyValue("OutputWorkspace", "LoadPreNexus2_chunk2"); TS_ASSERT(eventLoader->execute()); - EventWorkspace_sptr chunk2 = std::dynamic_pointer_cast<EventWorkspace>( - AnalysisDataService::Instance().retrieve("LoadPreNexus2_chunk2")); + EventWorkspace_sptr chunk2 = + std::dynamic_pointer_cast<EventWorkspace>(AnalysisDataService::Instance().retrieve("LoadPreNexus2_chunk2")); // The number of events should be roughly equal and the sum should be 112266 TS_ASSERT_EQUALS(chunk1->getNumberEvents(), 56139) diff --git a/Framework/DataObjects/src/MDBoxFlatTree.cpp b/Framework/DataObjects/src/MDBoxFlatTree.cpp index a8aac541862..ed79a033afd 100644 --- a/Framework/DataObjects/src/MDBoxFlatTree.cpp +++ b/Framework/DataObjects/src/MDBoxFlatTree.cpp @@ -35,8 +35,7 @@ MDBoxFlatTree::MDBoxFlatTree() : m_nDim(-1) {} * @param fileName -- the name of the file, where this structure should be *written. TODO: It is here for the case of file based workspaces */ -void MDBoxFlatTree::initFlatStructure(const API::IMDEventWorkspace_sptr &pws, - const std::string &fileName) { +void MDBoxFlatTree::initFlatStructure(const API::IMDEventWorkspace_sptr &pws, const std::string &fileName) { m_bcXMLDescr = pws->getBoxController()->toXMLString(); m_FileName = fileName; @@ -169,8 +168,7 @@ void MDBoxFlatTree::setBoxesFilePositions(bool setFileBacked) { void MDBoxFlatTree::saveBoxStructure(const std::string &fileName) { m_FileName = fileName; bool old_group; - auto hFile = file_holder_type(createOrOpenMDWSgroup( - fileName, m_nDim, m_Boxes[0]->getEventType(), false, old_group)); + auto hFile = file_holder_type(createOrOpenMDWSgroup(fileName, m_nDim, m_Boxes[0]->getEventType(), false, old_group)); // Save box structure; this->saveBoxStructure(hFile.get()); @@ -189,8 +187,7 @@ void MDBoxFlatTree::saveBoxStructure(::NeXus::File *hFile) { hFile->getEntries(groupEntries); bool create(false); - if (groupEntries.find("box_structure") == - groupEntries.end()) // dimensions dataset exist + if (groupEntries.find("box_structure") == groupEntries.end()) // dimensions dataset exist create = true; // Start the box data group @@ -226,13 +223,9 @@ void MDBoxFlatTree::saveBoxStructure(::NeXus::File *hFile) { hFile->writeExtendibleData("depth", m_Depth); hFile->writeExtendibleData("inverse_volume", m_InverseVolume); hFile->writeExtendibleData("extents", m_Extents, exents_dims, exents_chunk); - hFile->writeExtendibleData("box_children", m_BoxChildren, box_2_dims, - box_2_chunk); - hFile->writeExtendibleData("box_signal_errorsquared", - m_BoxSignalErrorsquared, box_2_dims, - box_2_chunk); - hFile->writeExtendibleData("box_event_index", m_BoxEventIndex, box_2_dims, - box_2_chunk); + hFile->writeExtendibleData("box_children", m_BoxChildren, box_2_dims, box_2_chunk); + hFile->writeExtendibleData("box_signal_errorsquared", m_BoxSignalErrorsquared, box_2_dims, box_2_chunk); + hFile->writeExtendibleData("box_event_index", m_BoxEventIndex, box_2_dims, box_2_chunk); } else { // Update the expendable data sets hFile->writeUpdatedData("box_type", m_BoxType); @@ -240,8 +233,7 @@ void MDBoxFlatTree::saveBoxStructure(::NeXus::File *hFile) { hFile->writeUpdatedData("inverse_volume", m_InverseVolume); hFile->writeUpdatedData("extents", m_Extents, exents_dims); hFile->writeUpdatedData("box_children", m_BoxChildren, box_2_dims); - hFile->writeUpdatedData("box_signal_errorsquared", m_BoxSignalErrorsquared, - box_2_dims); + hFile->writeUpdatedData("box_signal_errorsquared", m_BoxSignalErrorsquared, box_2_dims); hFile->writeUpdatedData("box_event_index", m_BoxEventIndex, box_2_dims); } // close the box group. @@ -262,10 +254,8 @@ void MDBoxFlatTree::saveBoxStructure(::NeXus::File *hFile) { locations -- do not restore boxes themselves @param restoreExperimentInfo :: load also experiment information */ -void MDBoxFlatTree::loadBoxStructure(const std::string &fileName, int &nDim, - const std::string &EventType, - bool onlyEventInfo, - bool restoreExperimentInfo) { +void MDBoxFlatTree::loadBoxStructure(const std::string &fileName, int &nDim, const std::string &EventType, + bool onlyEventInfo, bool restoreExperimentInfo) { m_FileName = fileName; m_nDim = nDim; @@ -273,12 +263,9 @@ void MDBoxFlatTree::loadBoxStructure(const std::string &fileName, int &nDim, bool old_group; // open the file and the MD workspace group. - auto hFile = file_holder_type( - createOrOpenMDWSgroup(fileName, nDim, m_eventType, true, old_group)); + auto hFile = file_holder_type(createOrOpenMDWSgroup(fileName, nDim, m_eventType, true, old_group)); if (!old_group) - throw Kernel::Exception::FileError( - "MD workspace box structure data are not present in the file", - fileName); + throw Kernel::Exception::FileError("MD workspace box structure data are not present in the file", fileName); m_nDim = nDim; @@ -286,8 +273,7 @@ void MDBoxFlatTree::loadBoxStructure(const std::string &fileName, int &nDim, if (restoreExperimentInfo) { if (!m_mEI) - m_mEI = std::make_shared<Mantid::API::MultipleExperimentInfos>( - Mantid::API::MultipleExperimentInfos()); + m_mEI = std::make_shared<Mantid::API::MultipleExperimentInfos>(Mantid::API::MultipleExperimentInfos()); loadExperimentInfos(hFile.get(), fileName, m_mEI); } @@ -343,8 +329,7 @@ void MDBoxFlatTree::loadBoxStructure(::NeXus::File *hFile, bool onlyEventInfo) { if (m_BoxEventIndex.size() != numBoxes * 2) throw std::runtime_error("Incompatible size for data: box_event_index."); if (m_BoxSignalErrorsquared.size() != numBoxes * 2) - throw std::runtime_error( - "Incompatible size for data: box_signal_errorsquared."); + throw std::runtime_error("Incompatible size for data: box_signal_errorsquared."); hFile->closeGroup(); } @@ -355,8 +340,7 @@ void MDBoxFlatTree::loadBoxStructure(::NeXus::File *hFile, bool onlyEventInfo) { *@param ws -- the shared pointer to the workspace with experiment infos to *write. */ -void MDBoxFlatTree::saveExperimentInfos( - ::NeXus::File *const file, const API::IMDEventWorkspace_const_sptr &ws) { +void MDBoxFlatTree::saveExperimentInfos(::NeXus::File *const file, const API::IMDEventWorkspace_const_sptr &ws) { std::map<std::string, std::string> entries; file->getEntries(entries); @@ -406,9 +390,8 @@ void MDBoxFlatTree::saveExperimentInfos( * @param lazy :: If true, use the FileBackedExperimentInfo class to only load * the data from the file when it is requested */ -void MDBoxFlatTree::loadExperimentInfos( - ::NeXus::File *const file, const std::string &filename, - std::shared_ptr<Mantid::API::MultipleExperimentInfos> mei, bool lazy) { +void MDBoxFlatTree::loadExperimentInfos(::NeXus::File *const file, const std::string &filename, + std::shared_ptr<Mantid::API::MultipleExperimentInfos> mei, bool lazy) { // First, find how many experimentX blocks there are std::map<std::string, std::string> entries; file->getEntries(entries); @@ -417,8 +400,7 @@ void MDBoxFlatTree::loadExperimentInfos( const std::string &name = entry.first; if (boost::starts_with(name, "experiment")) { try { - auto num = - boost::lexical_cast<uint16_t>(name.substr(10, name.size() - 10)); + auto num = boost::lexical_cast<uint16_t>(name.substr(10, name.size() - 10)); if (num < std::numeric_limits<uint16_t>::max() - 1) { // dublicated experiment info names are impossible due to the // structure of the nexus file but missing -- can be found. @@ -438,8 +420,7 @@ void MDBoxFlatTree::loadExperimentInfos( if (*itr != ic) { for (size_t i = ic + 1; i < *itr; i++) { std::string groupName = "experiment" + Kernel::Strings::toString(i); - g_log.warning() << "NXS file is missing a ExperimentInfo block " - << groupName + g_log.warning() << "NXS file is missing a ExperimentInfo block " << groupName << ". Workspace will be missing ExperimentInfo.\n"; } } @@ -451,8 +432,7 @@ void MDBoxFlatTree::loadExperimentInfos( for (; itr != ExperimentBlockNum.end(); itr++) { std::string groupName = "experiment" + Kernel::Strings::toString(*itr); if (lazy) { - auto ei = std::make_shared<API::FileBackedExperimentInfo>( - filename, file->getPath() + "/" + groupName); + auto ei = std::make_shared<API::FileBackedExperimentInfo>(filename, file->getPath() + "/" + groupName); // And add it to the mutliple experiment info. mei->addExperimentInfo(ei); } else { @@ -471,8 +451,7 @@ void MDBoxFlatTree::loadExperimentInfos( // And add it to the mutliple experiment info. mei->addExperimentInfo(ei); } catch (std::exception &e) { - g_log.information("Error loading section '" + groupName + - "' of nxs file."); + g_log.information("Error loading section '" + groupName + "' of nxs file."); g_log.information(e.what()); } file->closeGroup(); @@ -481,8 +460,7 @@ void MDBoxFlatTree::loadExperimentInfos( } /**Export existing experiment info defined in the box structure to target * workspace (or other experiment info as workspace is an experiment info) */ -void MDBoxFlatTree::exportExperiment( - Mantid::API::IMDEventWorkspace_sptr &targetWS) { +void MDBoxFlatTree::exportExperiment(Mantid::API::IMDEventWorkspace_sptr &targetWS) { // copy experiment infos targetWS->copyExperimentInfos(*m_mEI); // free this Experiment info as it has been already exported @@ -506,10 +484,8 @@ void MDBoxFlatTree::exportExperiment( @returns totalNumEvents :: total number of events the box structure should contain and allocated memory for. */ -uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, - API::BoxController_sptr &bc, - bool FileBackEnd, - bool BoxStructureOnly) { +uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, API::BoxController_sptr &bc, + bool FileBackEnd, bool BoxStructureOnly) { size_t numBoxes = this->getNBoxes(); Boxes.assign(numBoxes, nullptr); @@ -518,8 +494,7 @@ uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, m_nDim = static_cast<int>(bc->getNDims()); auto maxNdim = int(MDEventFactory::getMaxNumDim()); if (m_nDim <= 0 || m_nDim > maxNdim) - throw std::runtime_error( - "Workspace dimesnions are not defined properly in the box controller"); + throw std::runtime_error("Workspace dimesnions are not defined properly in the box controller"); int iEventType(0); if (m_eventType == "MDLeanEvent") @@ -527,8 +502,7 @@ uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, else if (m_eventType == "MDEvent") iEventType = 2; else - throw std::invalid_argument( - " Unknown event type provided for MDBoxFlatTree::restoreBoxTree"); + throw std::invalid_argument(" Unknown event type provided for MDBoxFlatTree::restoreBoxTree"); for (size_t i = 0; i < numBoxes; i++) { @@ -539,12 +513,10 @@ uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, API::IMDNode *ibox = nullptr; // Extents of the box, as a vector - std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> extentsVector( - m_nDim); + std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> extentsVector(m_nDim); for (size_t d = 0; d < size_t(m_nDim); d++) - extentsVector[d].setExtents( - static_cast<double>(m_Extents[i * m_nDim * 2 + d * 2]), - static_cast<double>(m_Extents[i * m_nDim * 2 + d * 2 + 1])); + extentsVector[d].setExtents(static_cast<double>(m_Extents[i * m_nDim * 2 + d * 2]), + static_cast<double>(m_Extents[i * m_nDim * 2 + d * 2 + 1])); // retrieve initial and file location and the numner of the events which // belong to this box stored on the HDD @@ -557,29 +529,25 @@ uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, if (BoxStructureOnly) { // create box with undefined numer of events -- // differs from 0 number of events by not calling // reserve(0) on underlying vectors. - ibox = MDEventFactory::createBox(size_t(m_nDim), - MDEventFactory::BoxType(iEventType), - bc, extentsVector, m_Depth[i]); + ibox = MDEventFactory::createBox(size_t(m_nDim), MDEventFactory::BoxType(iEventType), bc, extentsVector, + m_Depth[i]); } else // !BoxStructureOnly) { if (FileBackEnd) { - ibox = MDEventFactory::createBox(size_t(m_nDim), - MDEventFactory::BoxType(iEventType), - bc, extentsVector, m_Depth[i]); + ibox = MDEventFactory::createBox(size_t(m_nDim), MDEventFactory::BoxType(iEventType), bc, extentsVector, + m_Depth[i]); // Mark the box as file backed and indicate that the box was saved ibox->setFileBacked(indexStart, numEvents, true); } else { - ibox = MDEventFactory::createBox( - size_t(m_nDim), MDEventFactory::BoxType(iEventType), bc, - extentsVector, m_Depth[i], numEvents); + ibox = MDEventFactory::createBox(size_t(m_nDim), MDEventFactory::BoxType(iEventType), bc, extentsVector, + m_Depth[i], numEvents); } } // ifBoxStructureOnly } else if (box_type == 2) { // --- Make a MDGridBox ----- - ibox = MDEventFactory::createBox(size_t(m_nDim), - MDEventFactory::BoxType(iEventType + 1), - bc, extentsVector, m_Depth[i]); + ibox = MDEventFactory::createBox(size_t(m_nDim), MDEventFactory::BoxType(iEventType + 1), bc, extentsVector, + m_Depth[i]); } else continue; // Force correct ID @@ -590,10 +558,8 @@ uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, if (vol <= FLT_EPSILON) vol = 1; if (std::fabs((ibox->getInverseVolume() - vol) / vol) > 1.e-5) { - g_log.debug() << " Accuracy warning for box N " << i - << " as stored inverse volume is : " << m_InverseVolume[i] - << " and calculated from extents: " - << ibox->getInverseVolume() << '\n'; + g_log.debug() << " Accuracy warning for box N " << i << " as stored inverse volume is : " << m_InverseVolume[i] + << " and calculated from extents: " << ibox->getInverseVolume() << '\n'; ibox->setInverseVolume(coord_t(m_InverseVolume[i])); } @@ -633,16 +599,14 @@ uint64_t MDBoxFlatTree::restoreBoxTree(std::vector<API::IMDNode *> &Boxes, read-only or if the existing file parameters are not equal to the input parameters. */ -::NeXus::File * -MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, - const std::string &WSEventType, - bool readOnly, bool &alreadyExists) { +::NeXus::File *MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, + const std::string &WSEventType, bool readOnly, + bool &alreadyExists) { alreadyExists = false; Poco::File oldFile(fileName); bool fileExists = oldFile.exists(); if (!fileExists && readOnly) - throw Kernel::Exception::FileError( - "Attempt to open non-existing file in read-only mode", fileName); + throw Kernel::Exception::FileError("Attempt to open non-existing file in read-only mode", fileName); NXaccess access(NXACC_RDWR); if (readOnly) @@ -661,8 +625,7 @@ MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, std::map<std::string, std::string> groupEntries; hFile->getEntries(groupEntries); - if (groupEntries.find("MDEventWorkspace") != - groupEntries.end()) // WS group exist + if (groupEntries.find("MDEventWorkspace") != groupEntries.end()) // WS group exist { // Open and check ws group // -------------------------------------------------------------------------------->>> @@ -674,25 +637,22 @@ MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, hFile->getAttr("event_type", eventType); if (eventType != WSEventType) - throw Kernel::Exception::FileError( - "Trying to open MDWorkspace nexus file with the the events: " + - eventType + "\n different from workspace type: " + WSEventType, - fileName); + throw Kernel::Exception::FileError("Trying to open MDWorkspace nexus file with the the events: " + eventType + + "\n different from workspace type: " + WSEventType, + fileName); } else // it is possible that workspace group has been created by somebody // else and there are no this kind of attribute attached to it. { if (readOnly) - throw Kernel::Exception::FileError( - "The NXdata group: MDEventWorkspace opened in read-only mode but \n" - " does not have necessary attribute describing the event type used", - fileName); + throw Kernel::Exception::FileError("The NXdata group: MDEventWorkspace opened in read-only mode but \n" + " does not have necessary attribute describing the event type used", + fileName); hFile->putAttr("event_type", WSEventType); } // check dimensions dataset bool dimDatasetExist(false); hFile->getEntries(groupEntries); - if (groupEntries.find("dimensions") != - groupEntries.end()) // dimensions dataset exist + if (groupEntries.find("dimensions") != groupEntries.end()) // dimensions dataset exist dimDatasetExist = true; if (dimDatasetExist) { @@ -701,10 +661,9 @@ MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, if (nDims != 0) // check against dimensions provided { if (nFileDims != static_cast<int32_t>(nDims)) - throw Kernel::Exception::FileError( - "The NXdata group: MDEventWorkspace initiated for different " - "number of dimensions then requested ", - fileName); + throw Kernel::Exception::FileError("The NXdata group: MDEventWorkspace initiated for different " + "number of dimensions then requested ", + fileName); } else // read what is already there { nDims = static_cast<int>(nFileDims); @@ -738,8 +697,7 @@ MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, // Write out # of dimensions hFile->writeData("dimensions", nDim); } catch (...) { - throw Kernel::Exception::FileError( - "Can not create new NXdata group: MDEventWorkspace", fileName); + throw Kernel::Exception::FileError("Can not create new NXdata group: MDEventWorkspace", fileName); } // END create new WS group // -------------------------------------------------------------------------------<<< @@ -749,11 +707,9 @@ MDBoxFlatTree::createOrOpenMDWSgroup(const std::string &fileName, int &nDims, /**Save workspace generic info like dimension structure, history, title * dimensions etc.*/ -void MDBoxFlatTree::saveWSGenericInfo(::NeXus::File *const file, - const API::IMDWorkspace_const_sptr &ws) { +void MDBoxFlatTree::saveWSGenericInfo(::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws) { // Write out the coordinate system - file->writeData("coordinate_system", - static_cast<uint32_t>(ws->getSpecialCoordinateSystem())); + file->writeData("coordinate_system", static_cast<uint32_t>(ws->getSpecialCoordinateSystem())); // Write out the Qconvention // ki-kf for Inelastic convention; kf-ki for Crystallography convention @@ -761,20 +717,17 @@ void MDBoxFlatTree::saveWSGenericInfo(::NeXus::File *const file, file->putAttr("QConvention", m_QConvention); // Write out the set display normalization - file->writeData("visual_normalization", - static_cast<uint32_t>(ws->displayNormalization())); + file->writeData("visual_normalization", static_cast<uint32_t>(ws->displayNormalization())); // Write out the set display normalization carried for spawned histo // workspaces. - file->writeData("visual_normalization_histo", - static_cast<uint32_t>(ws->displayNormalizationHisto())); + file->writeData("visual_normalization_histo", static_cast<uint32_t>(ws->displayNormalizationHisto())); // Save the algorithm history under "process" ws->getHistory().saveNexus(file); // Write out the affine matrices - saveAffineTransformMatricies( - file, std::dynamic_pointer_cast<const API::IMDWorkspace>(ws)); + saveAffineTransformMatricies(file, std::dynamic_pointer_cast<const API::IMDWorkspace>(ws)); // Save some info as attributes. (Note: need to use attributes, not data sets // because those cannot be resized). @@ -795,17 +748,14 @@ void MDBoxFlatTree::saveWSGenericInfo(::NeXus::File *const file, * @param file : pointer to the NeXus file * @param ws : workspace to get matrix from */ -void MDBoxFlatTree::saveAffineTransformMatricies( - ::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws) { +void MDBoxFlatTree::saveAffineTransformMatricies(::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws) { try { - saveAffineTransformMatrix(file, ws->getTransformToOriginal(), - "transform_to_orig"); + saveAffineTransformMatrix(file, ws->getTransformToOriginal(), "transform_to_orig"); } catch (std::runtime_error &) { // Do nothing } try { - saveAffineTransformMatrix(file, ws->getTransformFromOriginal(), - "transform_from_orig"); + saveAffineTransformMatrix(file, ws->getTransformFromOriginal(), "transform_from_orig"); } catch (std::runtime_error &) { // Do nothing } @@ -816,15 +766,13 @@ void MDBoxFlatTree::saveAffineTransformMatricies( * @param transform : the object to extract the affine matrix from * @param entry_name : the tag in the NeXus file to save under */ -void MDBoxFlatTree::saveAffineTransformMatrix( - ::NeXus::File *const file, API::CoordTransform const *transform, - const std::string &entry_name) { +void MDBoxFlatTree::saveAffineTransformMatrix(::NeXus::File *const file, API::CoordTransform const *transform, + const std::string &entry_name) { if (!transform) return; Kernel::Matrix<coord_t> matrix = transform->makeAffineMatrix(); g_log.debug() << "TRFM: " << matrix.str() << '\n'; - saveMatrix<coord_t>(file, std::move(entry_name), matrix, ::NeXus::FLOAT32, - transform->id()); + saveMatrix<coord_t>(file, std::move(entry_name), matrix, ::NeXus::FLOAT32, transform->id()); } /** @@ -836,8 +784,7 @@ void MDBoxFlatTree::saveAffineTransformMatrix( * @param tag : id for an affine matrix conversion */ template <typename T> -void saveMatrix(::NeXus::File *const file, const std::string &name, - Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, +void saveMatrix(::NeXus::File *const file, const std::string &name, Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, const std::string &tag) { std::vector<T> v = m.getVector(); // Number of data points diff --git a/Framework/Geometry/test/ConeTest.h b/Framework/Geometry/test/ConeTest.h index 426fdbaaa41..16253c61fb6 100644 --- a/Framework/Geometry/test/ConeTest.h +++ b/Framework/Geometry/test/ConeTest.h @@ -109,8 +109,7 @@ public: double val = 0.1 * M_SQRT1_2; TS_ASSERT_DELTA(A.distance(V3D(0.1, val, val)), 0.0, 0.00001); // Inside - TS_ASSERT_DELTA(A.distance(V3D(0.0, val * 10, val * 10)), M_SQRT1_2, - 0.00001); + TS_ASSERT_DELTA(A.distance(V3D(0.0, val * 10, val * 10)), M_SQRT1_2, 0.00001); TS_ASSERT_DELTA(A.distance(V3D(1, 0.0, 0.0)), -1 * M_SQRT1_2, 0.00001); } diff --git a/Framework/Kernel/src/ISaveable.cpp b/Framework/Kernel/src/ISaveable.cpp index 8e9b2f8d3ce..78ed9f6dd13 100644 --- a/Framework/Kernel/src/ISaveable.cpp +++ b/Framework/Kernel/src/ISaveable.cpp @@ -12,22 +12,17 @@ namespace Kernel { /** Constructor */ ISaveable::ISaveable() - : m_Busy(false), m_dataChanged(false), m_wasSaved(false), m_isLoaded(false), - m_BufMemorySize(0), - m_fileIndexStart(std::numeric_limits<uint64_t>::max()), - m_fileNumEvents(0) {} + : m_Busy(false), m_dataChanged(false), m_wasSaved(false), m_isLoaded(false), m_BufMemorySize(0), + m_fileIndexStart(std::numeric_limits<uint64_t>::max()), m_fileNumEvents(0) {} //---------------------------------------------------------------------------------------------- /** Copy constructor --> needed for std containers and not to copy mutexes Note setting isLoaded to false to break connection with the file object which is not copyale */ ISaveable::ISaveable(const ISaveable &other) - : m_Busy(other.m_Busy), m_dataChanged(other.m_dataChanged), - m_wasSaved(other.m_wasSaved), m_isLoaded(false), - m_BufPosition(other.m_BufPosition), - m_BufMemorySize(other.m_BufMemorySize), - m_fileIndexStart(other.m_fileIndexStart), - m_fileNumEvents(other.m_fileNumEvents) + : m_Busy(other.m_Busy), m_dataChanged(other.m_dataChanged), m_wasSaved(other.m_wasSaved), m_isLoaded(false), + m_BufPosition(other.m_BufPosition), m_BufMemorySize(other.m_BufMemorySize), + m_fileIndexStart(other.m_fileIndexStart), m_fileNumEvents(other.m_fileNumEvents) {} @@ -38,8 +33,7 @@ ISaveable::ISaveable(const ISaveable &other) * @param newSize :: number of events in the file * @param wasSaved :: flag to mark if the info was saved, by default it does */ -void ISaveable::setFilePosition(uint64_t newPos, size_t newSize, - bool wasSaved) { +void ISaveable::setFilePosition(uint64_t newPos, size_t newSize, bool wasSaved) { std::lock_guard<std::mutex> lock(m_setter); this->m_fileIndexStart = newPos; this->m_fileNumEvents = static_cast<uint64_t>(newSize); @@ -73,11 +67,9 @@ void ISaveable::saveAt(uint64_t newPos, uint64_t newSize) { * @returns the size of the object it currently occupies in memory. This size is * also stored by the object itself for further references */ -size_t -ISaveable::setBufferPosition(std::list<ISaveable *>::iterator bufPosition) { +size_t ISaveable::setBufferPosition(std::list<ISaveable *>::iterator bufPosition) { std::lock_guard<std::mutex> lock(m_setter); - m_BufPosition = - boost::optional<std::list<ISaveable *>::iterator>(bufPosition); + m_BufPosition = boost::optional<std::list<ISaveable *>::iterator>(bufPosition); m_BufMemorySize = this->getDataMemorySize(); return m_BufMemorySize; diff --git a/Framework/Kernel/test/EqualBinsCheckerTest.h b/Framework/Kernel/test/EqualBinsCheckerTest.h index 1d812556a6c..8f9d2b4142b 100644 --- a/Framework/Kernel/test/EqualBinsCheckerTest.h +++ b/Framework/Kernel/test/EqualBinsCheckerTest.h @@ -17,21 +17,16 @@ using Mantid::Kernel::EqualBinsChecker; */ class TestEqualBinsChecker : public EqualBinsChecker { public: - TestEqualBinsChecker(const Mantid::MantidVec &xData, const double errorLevel) - : EqualBinsChecker(xData, errorLevel){}; + TestEqualBinsChecker(const Mantid::MantidVec &xData, const double errorLevel) : EqualBinsChecker(xData, errorLevel){}; double wrapGetReferenceDx() const { return this->getReferenceDx(); } - double wrapGetDifference(const size_t bin, const double dx) const { - return this->getDifference(bin, dx); - } + double wrapGetDifference(const size_t bin, const double dx) const { return this->getDifference(bin, dx); } }; class EqualBinsCheckerTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically // This means the constructor isn't called when running other tests - static EqualBinsCheckerTest *createSuite() { - return new EqualBinsCheckerTest(); - } + static EqualBinsCheckerTest *createSuite() { return new EqualBinsCheckerTest(); } static void destroySuite(EqualBinsCheckerTest *suite) { delete suite; } void test_validate_pass() { diff --git a/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp index 474e1966294..2803bac2655 100644 --- a/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp @@ -56,12 +56,10 @@ namespace LiveData { * @param histoTopic The name of the topic streaming the histo data * run mapping */ -KafkaHistoStreamDecoder::KafkaHistoStreamDecoder( - std::shared_ptr<IKafkaBroker> broker, const std::string &histoTopic, - const std::string &runInfoTopic, const std::string &sampleEnvTopic, - const std::string &chopperTopic) - : IKafkaStreamDecoder(std::move(broker), histoTopic, runInfoTopic, - sampleEnvTopic, chopperTopic, ""), +KafkaHistoStreamDecoder::KafkaHistoStreamDecoder(std::shared_ptr<IKafkaBroker> broker, const std::string &histoTopic, + const std::string &runInfoTopic, const std::string &sampleEnvTopic, + const std::string &chopperTopic) + : IKafkaStreamDecoder(std::move(broker), histoTopic, runInfoTopic, sampleEnvTopic, chopperTopic, ""), m_workspace() {} /** @@ -70,8 +68,7 @@ KafkaHistoStreamDecoder::KafkaHistoStreamDecoder( */ KafkaHistoStreamDecoder::~KafkaHistoStreamDecoder() = default; -KafkaHistoStreamDecoder::KafkaHistoStreamDecoder( - KafkaHistoStreamDecoder &&rval) noexcept +KafkaHistoStreamDecoder::KafkaHistoStreamDecoder(KafkaHistoStreamDecoder &&rval) noexcept : IKafkaStreamDecoder(std::move(rval)) { { std::lock_guard lck(m_mutex); @@ -120,8 +117,7 @@ API::Workspace_sptr KafkaHistoStreamDecoder::extractDataImpl() { auto *bindata = xbins->data(); HistogramData::BinEdges binedges(&bindata[0], &bindata[xbins->size()]); - API::MatrixWorkspace_sptr ws{DataObjects::create<DataObjects::Workspace2D>( - *m_workspace, nspectra, binedges)}; + API::MatrixWorkspace_sptr ws{DataObjects::create<DataObjects::Workspace2D>(*m_workspace, nspectra, binedges)}; ws->setIndexInfo(m_workspace->indexInfo()); auto data = histoMsg->data_as_ArrayDouble()->value(); @@ -185,8 +181,7 @@ void KafkaHistoStreamDecoder::captureImplExcept() { } if (checkOffsets) { - checkRunEnd(topicName, checkOffsets, offset, partition, stopOffsets, - reachedEnd); + checkRunEnd(topicName, checkOffsets, offset, partition, stopOffsets, reachedEnd); if (offset > stopOffsets[topicName][static_cast<size_t>(partition)]) { // If the offset is beyond the end of the current run, then skip to // the next iteration and don't process the message @@ -197,9 +192,8 @@ void KafkaHistoStreamDecoder::captureImplExcept() { // Check if we have a histo message // Most will be event messages so we check for this type first - if (flatbuffers::BufferHasIdentifier( - reinterpret_cast<const uint8_t *>(buffer.c_str()), - HISTO_MESSAGE_ID.c_str())) { + if (flatbuffers::BufferHasIdentifier(reinterpret_cast<const uint8_t *>(buffer.c_str()), + HISTO_MESSAGE_ID.c_str())) { // Data being accumulated before being streamed so no need to store // messages. m_buffer = buffer; @@ -213,8 +207,7 @@ void KafkaHistoStreamDecoder::captureImplExcept() { g_log.debug("Histo capture finished"); } -void KafkaHistoStreamDecoder::initLocalCaches( - const RunStartStruct &runStartData) { +void KafkaHistoStreamDecoder::initLocalCaches(const RunStartStruct &runStartData) { m_runId = runStartData.runId; const auto jsonGeometry = runStartData.nexusStructure; @@ -230,28 +223,23 @@ void KafkaHistoStreamDecoder::initLocalCaches( // Create buffer histoBuffer = std::static_pointer_cast<DataObjects::Workspace2D>( API::WorkspaceFactory::Instance().create("Workspace2D", nspec, 2, 1)); - histoBuffer->getAxis(0)->unit() = - Kernel::UnitFactory::Instance().create("TOF"); + histoBuffer->getAxis(0)->unit() = Kernel::UnitFactory::Instance().create("TOF"); histoBuffer->setYUnit("Counts"); /* Need a mapping with spectra numbers starting at zero */ histoBuffer->rebuildSpectraMapping(true, 0); - histoBuffer->getAxis(0)->unit() = - Kernel::UnitFactory::Instance().create("TOF"); + histoBuffer->getAxis(0)->unit() = Kernel::UnitFactory::Instance().create("TOF"); histoBuffer->setYUnit("Counts"); } else { // Create buffer histoBuffer = createBufferWorkspace<DataObjects::Workspace2D>( - "Workspace2D", runStartData.numberOfSpectra, - runStartData.spectrumNumbers.data(), runStartData.detectorIDs.data(), - static_cast<uint32_t>(runStartData.detectorIDs.size())); + "Workspace2D", runStartData.numberOfSpectra, runStartData.spectrumNumbers.data(), + runStartData.detectorIDs.data(), static_cast<uint32_t>(runStartData.detectorIDs.size())); } // Load the instrument if possible but continue if we can't - if (!loadInstrument<DataObjects::Workspace2D>(instName, histoBuffer, - jsonGeometry)) - g_log.warning( - "Instrument could not be loaded. Continuing without instrument"); + if (!loadInstrument<DataObjects::Workspace2D>(instName, histoBuffer, jsonGeometry)) + g_log.warning("Instrument could not be loaded. Continuing without instrument"); auto &mutableRun = histoBuffer->mutableRun(); // Run start. Cache locally for computing frame times @@ -263,18 +251,15 @@ void KafkaHistoStreamDecoder::initLocalCaches( mutableRun.addProperty(RUN_START_PROPERTY, std::string(timeString)); mutableRun.addProperty(RUN_NUMBER_PROPERTY, runStartData.runId); // Create the proton charge property - mutableRun.addProperty( - new Kernel::TimeSeriesProperty<double>(PROTON_CHARGE_PROPERTY)); + mutableRun.addProperty(new Kernel::TimeSeriesProperty<double>(PROTON_CHARGE_PROPERTY)); // Cache spec->index mapping. We assume it is the same across all periods - m_specToIdx = - histoBuffer->getSpectrumToWorkspaceIndexVector(m_specToIdxOffset); + m_specToIdx = histoBuffer->getSpectrumToWorkspaceIndexVector(m_specToIdxOffset); // Buffers for each period const size_t nperiods = runStartData.nPeriods; if (nperiods > 1) { - throw std::runtime_error( - "KafkaHistoStreamDecoder - Does not support multi-period data."); + throw std::runtime_error("KafkaHistoStreamDecoder - Does not support multi-period data."); } // New caches so LoadLiveData's output workspace needs to be replaced m_dataReset = true; @@ -282,8 +267,7 @@ void KafkaHistoStreamDecoder::initLocalCaches( m_workspace = histoBuffer; } -void KafkaHistoStreamDecoder::sampleDataFromMessage( - const std::string & /*buffer*/) { +void KafkaHistoStreamDecoder::sampleDataFromMessage(const std::string & /*buffer*/) { throw Kernel::Exception::NotImplementedError("This method will require " "implementation when processing " "sample environment messages."); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h index 5ad0430fde1..544bb57eb81 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h @@ -27,9 +27,7 @@ public: } int version() const override; - const std::vector<std::string> seeAlso() const override { - return {"ConvertToMD"}; - } + const std::vector<std::string> seeAlso() const override { return {"ConvertToMD"}; } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h b/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h index 89d41083f0a..9fd49ab623b 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h @@ -23,13 +23,10 @@ using Mantid::MDAlgorithms::ConvertToMDMinMaxGlobal; namespace { -Mantid::API::MatrixWorkspace_sptr MakeWorkspace(double xmin, double dx, - bool deltaEUnits, double Ei, - double Ef, int nHist = 1, - int nBins = 100) { +Mantid::API::MatrixWorkspace_sptr MakeWorkspace(double xmin, double dx, bool deltaEUnits, double Ei, double Ef, + int nHist = 1, int nBins = 100) { - Mantid::API::MatrixWorkspace_sptr ws = - WorkspaceCreationHelper::create2DWorkspaceBinned(nHist, nBins, xmin, dx); + Mantid::API::MatrixWorkspace_sptr ws = WorkspaceCreationHelper::create2DWorkspaceBinned(nHist, nBins, xmin, dx); if ((Ei > 0 || Ef > 0) && deltaEUnits) { ws->getAxis(0)->setUnit("DeltaE"); @@ -40,22 +37,20 @@ Mantid::API::MatrixWorkspace_sptr MakeWorkspace(double xmin, double dx, Mantid::Geometry::Instrument_sptr testInst(new Mantid::Geometry::Instrument); // Define a source and sample position // Define a source component - Mantid::Geometry::ObjComponent *source = new Mantid::Geometry::ObjComponent( - "moderator", Mantid::Geometry::IObject_sptr(), testInst.get()); + Mantid::Geometry::ObjComponent *source = + new Mantid::Geometry::ObjComponent("moderator", Mantid::Geometry::IObject_sptr(), testInst.get()); source->setPos(Mantid::Kernel::V3D(0, 0.0, -15.)); testInst->add(source); testInst->markAsSource(source); // Define a sample as a simple sphere - Mantid::Geometry::Component *sample = - new Mantid::Geometry::Component("samplePos", testInst.get()); + Mantid::Geometry::Component *sample = new Mantid::Geometry::Component("samplePos", testInst.get()); testInst->setPos(0.0, 0.0, 0.0); testInst->add(sample); testInst->markAsSamplePos(sample); // Detectors for (int i = 0; i < nHist; i++) { - Mantid::Geometry::Detector *physicalPixel = - new Mantid::Geometry::Detector("pixel", i + 1, testInst.get()); + Mantid::Geometry::Detector *physicalPixel = new Mantid::Geometry::Detector("pixel", i + 1, testInst.get()); physicalPixel->setPos(0.5, 0, 5.0); testInst->add(physicalPixel); testInst->markAsDetector(physicalPixel); @@ -77,15 +72,12 @@ Mantid::API::MatrixWorkspace_sptr MakeWorkspace(double xmin, double dx, } if (Ei > 0) { - ws->mutableRun().addProperty( - new Mantid::Kernel::PropertyWithValue<double>("Ei", Ei)); + ws->mutableRun().addProperty(new Mantid::Kernel::PropertyWithValue<double>("Ei", Ei)); } - ws->mutableSample().setOrientedLattice( - std::make_unique<Mantid::Geometry::OrientedLattice>(2, 3, 4, 90, 90, 90)); + ws->mutableSample().setOrientedLattice(std::make_unique<Mantid::Geometry::OrientedLattice>(2, 3, 4, 90, 90, 90)); - Mantid::Kernel::TimeSeriesProperty<double> *p = - new Mantid::Kernel::TimeSeriesProperty<double>("doubleProp"); + Mantid::Kernel::TimeSeriesProperty<double> *p = new Mantid::Kernel::TimeSeriesProperty<double>("doubleProp"); TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:00", 9.99)); TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:10", 7.55)); TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:20", 5.55)); @@ -101,9 +93,7 @@ class ConvertToMDMinMaxGlobalTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically // This means the constructor isn't called when running other tests - static ConvertToMDMinMaxGlobalTest *createSuite() { - return new ConvertToMDMinMaxGlobalTest(); - } + static ConvertToMDMinMaxGlobalTest *createSuite() { return new ConvertToMDMinMaxGlobalTest(); } static void destroySuite(ConvertToMDMinMaxGlobalTest *suite) { delete suite; } ConvertToMDMinMaxGlobalTest() : WSName("CMDHTest") {} @@ -152,10 +142,8 @@ public: TS_ASSERT_THROWS_NOTHING(alg.execute();); TS_ASSERT(alg.isExecuted()); // Check the results - TS_ASSERT_EQUALS(alg.getPropertyValue("MinValues"), - "-12.667,-12.667,-12.667,-50"); - TS_ASSERT_EQUALS(alg.getPropertyValue("MaxValues"), - "12.667,12.667,12.667,50"); + TS_ASSERT_EQUALS(alg.getPropertyValue("MinValues"), "-12.667,-12.667,-12.667,-50"); + TS_ASSERT_EQUALS(alg.getPropertyValue("MaxValues"), "12.667,12.667,12.667,50"); // Remove workspace from the data service. Mantid::API::AnalysisDataService::Instance().remove(WSName); } @@ -176,10 +164,8 @@ public: TS_ASSERT_THROWS_NOTHING(alg.execute();); TS_ASSERT(alg.isExecuted()); // Check the results - TS_ASSERT_EQUALS(alg.getPropertyValue("MinValues"), - "-4.03205,-6.04807,-8.06409,-50"); - TS_ASSERT_EQUALS(alg.getPropertyValue("MaxValues"), - "4.03205,6.04807,8.06409,50"); + TS_ASSERT_EQUALS(alg.getPropertyValue("MinValues"), "-4.03205,-6.04807,-8.06409,-50"); + TS_ASSERT_EQUALS(alg.getPropertyValue("MaxValues"), "4.03205,6.04807,8.06409,50"); // Remove workspace from the data service. Mantid::API::AnalysisDataService::Instance().remove(WSName); } @@ -188,16 +174,14 @@ public: Mantid::API::FrameworkManager::Instance(); ConvertToMDMinMaxGlobal alg; - Mantid::API::MatrixWorkspace_sptr ws = - MakeWorkspace(-2.5, 0.05, true, 0, 5); + Mantid::API::MatrixWorkspace_sptr ws = MakeWorkspace(-2.5, 0.05, true, 0, 5); WorkspaceCreationHelper::storeWS(WSName, ws); TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputWorkspace", WSName)); TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("QDimensions", "|Q|")); - TS_ASSERT_THROWS_NOTHING( - alg.setPropertyValue("dEAnalysisMode", "Indirect")); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("dEAnalysisMode", "Indirect")); TS_ASSERT_THROWS_NOTHING(alg.execute();); TS_ASSERT(alg.isExecuted()); // Check the results @@ -212,8 +196,7 @@ public: Mantid::API::FrameworkManager::Instance(); ConvertToMDMinMaxGlobal alg; - Mantid::API::MatrixWorkspace_sptr ws = - MakeWorkspace(25000, 10, false, 0, 0); + Mantid::API::MatrixWorkspace_sptr ws = MakeWorkspace(25000, 10, false, 0, 0); WorkspaceCreationHelper::storeWS(WSName, ws); TS_ASSERT_THROWS_NOTHING(alg.initialize()) @@ -235,8 +218,7 @@ public: Mantid::API::FrameworkManager::Instance(); ConvertToMDMinMaxGlobal alg; - Mantid::API::MatrixWorkspace_sptr ws = - MakeWorkspace(25000, 10, false, 0, 0); + Mantid::API::MatrixWorkspace_sptr ws = MakeWorkspace(25000, 10, false, 0, 0); WorkspaceCreationHelper::storeWS(WSName, ws); TS_ASSERT_THROWS_NOTHING(alg.initialize()) @@ -244,8 +226,7 @@ public: TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputWorkspace", WSName)); TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("QDimensions", "|Q|")); TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("dEAnalysisMode", "Elastic")); - TS_ASSERT_THROWS_NOTHING( - alg.setPropertyValue("OtherDimensions", "doubleProp")); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OtherDimensions", "doubleProp")); TS_ASSERT_THROWS_NOTHING(alg.execute();); TS_ASSERT(alg.isExecuted()); // Check the results @@ -262,17 +243,12 @@ private: class ConvertToMDMinMaxGlobalTestPerformance : public CxxTest::TestSuite { public: - static ConvertToMDMinMaxGlobalTestPerformance *createSuite() { - return new ConvertToMDMinMaxGlobalTestPerformance(); - } - static void destroySuite(ConvertToMDMinMaxGlobalTestPerformance *suite) { - delete suite; - } + static ConvertToMDMinMaxGlobalTestPerformance *createSuite() { return new ConvertToMDMinMaxGlobalTestPerformance(); } + static void destroySuite(ConvertToMDMinMaxGlobalTestPerformance *suite) { delete suite; } void setUp() override { Mantid::API::FrameworkManager::Instance(); - Mantid::API::MatrixWorkspace_sptr ws = - MakeWorkspace(-2.5, 0.05, true, 0, 5, 10000, 100); + Mantid::API::MatrixWorkspace_sptr ws = MakeWorkspace(-2.5, 0.05, true, 0, 5, 10000, 100); WorkspaceCreationHelper::storeWS(WSName, ws); alg.initialize(); @@ -282,13 +258,9 @@ public: alg.setPropertyValue("dEAnalysisMode", "Indirect"); } - void tearDown() override { - Mantid::API::AnalysisDataService::Instance().remove(WSName); - } + void tearDown() override { Mantid::API::AnalysisDataService::Instance().remove(WSName); } - void testNormaliseVanadiumPerformance() { - TS_ASSERT_THROWS_NOTHING(alg.execute()); - } + void testNormaliseVanadiumPerformance() { TS_ASSERT_THROWS_NOTHING(alg.execute()); } private: ConvertToMDMinMaxGlobal alg; diff --git a/Framework/NexusGeometry/inc/MantidNexusGeometry/NexusGeometryUtilities.h b/Framework/NexusGeometry/inc/MantidNexusGeometry/NexusGeometryUtilities.h index 86fe3e0b5ed..8becc6a50fe 100644 --- a/Framework/NexusGeometry/inc/MantidNexusGeometry/NexusGeometryUtilities.h +++ b/Framework/NexusGeometry/inc/MantidNexusGeometry/NexusGeometryUtilities.h @@ -16,8 +16,7 @@ namespace NexusGeometry { // Utilities common for parsing and saving namespace utilities { -template <typename T, typename R> -std::vector<R> convertVector(const std::vector<T> &toConvert) { +template <typename T, typename R> std::vector<R> convertVector(const std::vector<T> &toConvert) { std::vector<R> target(toConvert.size()); for (size_t i = 0; i < target.size(); ++i) { target[i] = R(toConvert[i]); @@ -25,20 +24,15 @@ std::vector<R> convertVector(const std::vector<T> &toConvert) { return target; } -boost::optional<H5::DataSet> findDataset(const H5::Group &parentGroup, - const H5std_string &name); +boost::optional<H5::DataSet> findDataset(const H5::Group &parentGroup, const H5std_string &name); -boost::optional<H5::Group> findGroup(const H5::Group &parentGroup, - const H5std_string &classType); +boost::optional<H5::Group> findGroup(const H5::Group &parentGroup, const H5std_string &classType); -H5::Group findGroupOrThrow(const H5::Group &parentGroup, - const H5std_string &classType); +H5::Group findGroupOrThrow(const H5::Group &parentGroup, const H5std_string &classType); -std::vector<H5::Group> findGroups(const H5::Group &parentGroup, - const H5std_string &classType); +std::vector<H5::Group> findGroups(const H5::Group &parentGroup, const H5std_string &classType); -boost::optional<H5::Group> findGroupByName(const H5::Group &parentGroup, - const H5std_string &name); +boost::optional<H5::Group> findGroupByName(const H5::Group &parentGroup, const H5std_string &name); bool hasNXAttribute(const H5::Group &group, const std::string &attributeValue); bool isNamed(const H5::H5Object &obj, const std::string &name); } // namespace utilities diff --git a/Framework/PythonInterface/mantid/dataobjects/src/Exports/OffsetsWorkspace.cpp b/Framework/PythonInterface/mantid/dataobjects/src/Exports/OffsetsWorkspace.cpp index 64ffa087d93..eeeefde1fdd 100644 --- a/Framework/PythonInterface/mantid/dataobjects/src/Exports/OffsetsWorkspace.cpp +++ b/Framework/PythonInterface/mantid/dataobjects/src/Exports/OffsetsWorkspace.cpp @@ -17,8 +17,7 @@ using namespace boost::python; GET_POINTER_SPECIALIZATION(OffsetsWorkspace) void export_OffsetsWorkspace() { - class_<OffsetsWorkspace, bases<SpecialWorkspace2D>, boost::noncopyable>( - "OffsetsWorkspace", no_init); + class_<OffsetsWorkspace, bases<SpecialWorkspace2D>, boost::noncopyable>("OffsetsWorkspace", no_init); // register pointers RegisterWorkspacePtrToPython<OffsetsWorkspace>(); diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/OrientedLattice.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/OrientedLattice.cpp index ff7e5ed28a6..51e0e1fca63 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/OrientedLattice.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/OrientedLattice.cpp @@ -27,23 +27,17 @@ void setU(OrientedLattice &self, const object &data, const bool force) { } /// Set the U vector via a numpy array -void setUB(OrientedLattice &self, const object &data) { - self.setUB(Converters::PyObjectToMatrix(data)()); -} +void setUB(OrientedLattice &self, const object &data) { self.setUB(Converters::PyObjectToMatrix(data)()); } /// Set the U matrix from 2 Python objects representing a V3D type. This can be /// Set the U vector via a numpy array -void setModUB(OrientedLattice &self, const object &data) { - self.setModUB(Converters::PyObjectToMatrix(data)()); -} +void setModUB(OrientedLattice &self, const object &data) { self.setModUB(Converters::PyObjectToMatrix(data)()); } /// Set the U matrix from 2 Python objects representing a V3D type. This can be /// a V3D object, a list /// or a numpy array. If the arrays are used they must be of length 3 -void setUFromVectors(OrientedLattice &self, const object &vec1, - const object &vec2) { - self.setUFromVectors(Converters::PyObjectToV3D(vec1)(), - Converters::PyObjectToV3D(vec2)()); +void setUFromVectors(OrientedLattice &self, const object &vec1, const object &vec2) { + self.setUFromVectors(Converters::PyObjectToV3D(vec1)(), Converters::PyObjectToV3D(vec2)()); } Mantid::Kernel::V3D qFromHKL(OrientedLattice &self, const object &vec) { @@ -57,34 +51,28 @@ Mantid::Kernel::V3D hklFromQ(OrientedLattice &self, const object &vec) { void export_OrientedLattice() { /// return_value_policy for read-only numpy array - using return_readonly_numpy = - return_value_policy<Policies::MatrixRefToNumpy<Converters::WrapReadOnly>>; + using return_readonly_numpy = return_value_policy<Policies::MatrixRefToNumpy<Converters::WrapReadOnly>>; - class_<OrientedLattice, bases<UnitCell>>( - "OrientedLattice", - init<>("Default constructor, with " - ":math:`a=b=c=1 \\rm{\\AA}, \\alpha = \\beta = \\gamma = " - "90^\\circ`. The :math:`U` matrix is set to the identity matrix.")) - .def(init<OrientedLattice const &>( - (arg("other")), - "Copy constructor for creating a new oriented lattice.")) - .def(init<double, double, double>( - (arg("_a"), arg("_b"), arg("_c")), - "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), " - ":math:`\\alpha=\\beta=\\gamma=90^\\circ`. The :math:`U` matrix is " - "set to the identity matrix.")) + class_<OrientedLattice, bases<UnitCell>>("OrientedLattice", + init<>("Default constructor, with " + ":math:`a=b=c=1 \\rm{\\AA}, \\alpha = \\beta = \\gamma = " + "90^\\circ`. The :math:`U` matrix is set to the identity matrix.")) + .def(init<OrientedLattice const &>((arg("other")), "Copy constructor for creating a new oriented lattice.")) + .def(init<double, double, double>((arg("_a"), arg("_b"), arg("_c")), + "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), " + ":math:`\\alpha=\\beta=\\gamma=90^\\circ`. The :math:`U` matrix is " + "set to the identity matrix.")) .def(init<double, double, double, double, double, double, optional<int>>( - (arg("_a"), arg("_b"), arg("_c"), arg("_alpha"), arg("_beta"), - arg("_gamma"), arg("Unit") = static_cast<int>(angDegrees)), + (arg("_a"), arg("_b"), arg("_c"), arg("_alpha"), arg("_beta"), arg("_gamma"), + arg("Unit") = static_cast<int>(angDegrees)), "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), " ":math:`\\alpha, \\beta, " "\\gamma` (in degrees or radians). The optional parameter ``Unit`` " "controls the " "units for the angles, and can have the value of ``Degrees`` or " "``Radians``. By default ``Unit`` = ``Degrees``.")) - .def(init<UnitCell>( - arg("uc"), "Constructor from a :class:`~mantid.geometry.UnitCell`. " - "The :math:`U` matrix is set to the identity matrix.")) + .def(init<UnitCell>(arg("uc"), "Constructor from a :class:`~mantid.geometry.UnitCell`. " + "The :math:`U` matrix is set to the identity matrix.")) .def("getuVector", (&OrientedLattice::getuVector), arg("self"), "Returns the vector along the beam direction when " ":class:`~mantid.geometry.Goniometer` s are at 0. ") @@ -98,8 +86,7 @@ void export_OrientedLattice() { .def("setU", &setU, (arg("self"), arg("newU"), arg("force") = true), "Set the :math:`U` rotation matrix. This method expects a " ":class:`numpy.ndarray` with shape ``(3,3)``.") - .def("getUB", &OrientedLattice::getUB, arg("self"), - return_readonly_numpy(), + .def("getUB", &OrientedLattice::getUB, arg("self"), return_readonly_numpy(), "Returns the :math:`UB` matrix for this oriented lattice. This will " "return " "a :class:`numpy.ndarray` with shape ``(3,3)``.") @@ -108,27 +95,22 @@ void export_OrientedLattice() { "lattice parameters, then the :math:`B` matrix, and then :math:`U`. " "This method expects a " ":class:`numpy.ndarray` with shape ``(3,3)``. ") - .def("getModUB", &OrientedLattice::getModUB, arg("self"), - return_readonly_numpy(), + .def("getModUB", &OrientedLattice::getModUB, arg("self"), return_readonly_numpy(), "Returns the :math:`ModUB` matrix for this oriented lattice. This " "will " "return " "a :class:`numpy.ndarray` with shape ``(3,3)``.") - .def( - "setModUB", &setModUB, (arg("self"), arg("newModUB")), - "Set the :math:`ModUB` matrix. This methiod will calculate first the " - "lattice parameters, then the :math:`B` matrix, and then :math:`U`. " - "This method expects a " - ":class:`numpy.ndarray` with shape ``(3,3)``. ") - .def("setUFromVectors", &setUFromVectors, - (arg("self"), arg("u"), arg("v")), + .def("setModUB", &setModUB, (arg("self"), arg("newModUB")), + "Set the :math:`ModUB` matrix. This methiod will calculate first the " + "lattice parameters, then the :math:`B` matrix, and then :math:`U`. " + "This method expects a " + ":class:`numpy.ndarray` with shape ``(3,3)``. ") + .def("setUFromVectors", &setUFromVectors, (arg("self"), arg("u"), arg("v")), "Set the :math:`U` rotation matrix using two vectors to define a " "new " "coordinate system. This method with return the new :math:`U` " "matrix " "as a :class:`numpy.ndarray` with shape ``(3,3)``. ") - .def("qFromHKL", &qFromHKL, (arg("self"), arg("vec")), - ":math:`Q` vector from :math:`HKL` vector") - .def("hklFromQ", &hklFromQ, (arg("self"), arg("vec")), - ":math:`HKL` value from :math:`Q` vector"); + .def("qFromHKL", &qFromHKL, (arg("self"), arg("vec")), ":math:`Q` vector from :math:`HKL` vector") + .def("hklFromQ", &hklFromQ, (arg("self"), arg("vec")), ":math:`HKL` value from :math:`Q` vector"); } diff --git a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp index a4334b5a1da..afaefe05cdf 100644 --- a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp +++ b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp @@ -33,29 +33,25 @@ using namespace Geometry; void PoldiAutoCorrelation5::init() { // Input workspace containing the raw data. - declareProperty(std::make_unique<WorkspaceProperty<DataObjects::Workspace2D>>( - "InputWorkspace", "", Direction::InOut), + declareProperty(std::make_unique<WorkspaceProperty<DataObjects::Workspace2D>>("InputWorkspace", "", Direction::InOut), "Input workspace containing raw POLDI data."); // the minimal value of the wavelength to consider - declareProperty("wlenmin", 1.1, "Minimum wavelength considered", - Direction::Input); + declareProperty("wlenmin", 1.1, "Minimum wavelength considered", Direction::Input); // the maximal value of the wavelength to consider - declareProperty("wlenmax", 5.0, "Maximum wavelength considered", - Direction::Input); + declareProperty("wlenmax", 5.0, "Maximum wavelength considered", Direction::Input); // The output Workspace2D containing the Poldi data autocorrelation function. - declareProperty(std::make_unique<WorkspaceProperty<DataObjects::Workspace2D>>( - "OutputWorkspace", "", Direction::Output), - "Output workspace containing the correlation spectrum."); + declareProperty( + std::make_unique<WorkspaceProperty<DataObjects::Workspace2D>>("OutputWorkspace", "", Direction::Output), + "Output workspace containing the correlation spectrum."); /* Auto correlation core object which performs the actual calculation. * In future versions this will be replaced by a factory to cater for * slightly different variants of the algorithm as they are implemented * in the original fortran analysis software. */ - m_core = std::shared_ptr<PoldiAutoCorrelationCore>( - new PoldiAutoCorrelationCore(g_log)); + m_core = std::shared_ptr<PoldiAutoCorrelationCore>(new PoldiAutoCorrelationCore(g_log)); } /** Executes the algorithm. Reading in the file and creating and populating @@ -74,8 +70,7 @@ void PoldiAutoCorrelation5::exec() { * - POLDI instrument definition * - Some data from the "Log" (for example chopper-speed) */ - DataObjects::Workspace2D_sptr localWorkspace = - this->getProperty("InputWorkspace"); + DataObjects::Workspace2D_sptr localWorkspace = this->getProperty("InputWorkspace"); g_log.information() << "_Poldi ws loaded -------------- \n"; @@ -97,11 +92,9 @@ void PoldiAutoCorrelation5::exec() { m_core->setWavelengthRange(wlen_min, wlen_max); try { - Mantid::DataObjects::Workspace2D_sptr outputws = - m_core->calculate(localWorkspace); + Mantid::DataObjects::Workspace2D_sptr outputws = m_core->calculate(localWorkspace); - setProperty("OutputWorkspace", - std::dynamic_pointer_cast<Workspace>(outputws)); + setProperty("OutputWorkspace", std::dynamic_pointer_cast<Workspace>(outputws)); } catch (Mantid::Kernel::Exception::NotFoundError &) { throw std::runtime_error("Error when saving the PoldiIPP Results data to " @@ -112,48 +105,32 @@ void PoldiAutoCorrelation5::exec() { } } -void PoldiAutoCorrelation5::logConfigurationInformation( - const std::shared_ptr<PoldiDeadWireDecorator> &cleanDetector, - const PoldiAbstractChopper_sptr &chopper) { +void PoldiAutoCorrelation5::logConfigurationInformation(const std::shared_ptr<PoldiDeadWireDecorator> &cleanDetector, + const PoldiAbstractChopper_sptr &chopper) { if (cleanDetector && chopper) { - g_log.information() - << "____________________________________________________ \n"; - g_log.information() - << "_Poldi chopper conf ------------------------------ \n"; - g_log.information() << "_Poldi - Chopper speed: " - << chopper->rotationSpeed() << " rpm\n"; - g_log.information() << "_Poldi - Number of slits: " - << chopper->slitPositions().size() << '\n'; - g_log.information() << "_Poldi - Cycle time: " - << chopper->cycleTime() << " µs\n"; - g_log.information() << "_Poldi - Zero offset: " - << chopper->zeroOffset() << " µs\n"; - g_log.information() << "_Poldi - Distance: " - << chopper->distanceFromSample() << " mm\n"; + g_log.information() << "____________________________________________________ \n"; + g_log.information() << "_Poldi chopper conf ------------------------------ \n"; + g_log.information() << "_Poldi - Chopper speed: " << chopper->rotationSpeed() << " rpm\n"; + g_log.information() << "_Poldi - Number of slits: " << chopper->slitPositions().size() << '\n'; + g_log.information() << "_Poldi - Cycle time: " << chopper->cycleTime() << " µs\n"; + g_log.information() << "_Poldi - Zero offset: " << chopper->zeroOffset() << " µs\n"; + g_log.information() << "_Poldi - Distance: " << chopper->distanceFromSample() << " mm\n"; if (g_log.is(Poco::Message::PRIO_DEBUG)) { for (size_t i = 0; i < chopper->slitPositions().size(); ++i) { - g_log.information() - << "_Poldi - Slits: " << i - << ": Position = " << chopper->slitPositions()[i] - << "\t Time = " << chopper->slitTimes()[i] << " µs\n"; + g_log.information() << "_Poldi - Slits: " << i << ": Position = " << chopper->slitPositions()[i] + << "\t Time = " << chopper->slitTimes()[i] << " µs\n"; } } - g_log.information() - << "_Poldi detector conf ------------------------------ \n"; - g_log.information() << "_Poldi - Element count: " - << cleanDetector->elementCount() << '\n'; - g_log.information() << "_Poldi - Central element: " - << cleanDetector->centralElement() << '\n'; - g_log.information() << "_Poldi - 2Theta(central): " - << cleanDetector->twoTheta(199) / M_PI * 180.0 << "°\n"; - g_log.information() << "_Poldi - Distance(central): " - << cleanDetector->distanceFromSample(199) << " mm\n"; + g_log.information() << "_Poldi detector conf ------------------------------ \n"; + g_log.information() << "_Poldi - Element count: " << cleanDetector->elementCount() << '\n'; + g_log.information() << "_Poldi - Central element: " << cleanDetector->centralElement() << '\n'; + g_log.information() << "_Poldi - 2Theta(central): " << cleanDetector->twoTheta(199) / M_PI * 180.0 << "°\n"; + g_log.information() << "_Poldi - Distance(central): " << cleanDetector->distanceFromSample(199) << " mm\n"; std::set<int> deadWires = cleanDetector->deadWires(); - g_log.information() << "_Poldi - Number of dead wires: " - << deadWires.size() << '\n'; + g_log.information() << "_Poldi - Number of dead wires: " << deadWires.size() << '\n'; g_log.information() << "_Poldi - Wire indices: "; for (auto deadWire : deadWires) { g_log.information() << deadWire << " "; diff --git a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h index c6a68c63058..226d770a2fe 100644 --- a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h +++ b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h @@ -15,14 +15,11 @@ namespace Mantid { namespace API { -void writeJsonFile(const std::string &filename, const Json::Value &json, - const std::string &error); +void writeJsonFile(const std::string &filename, const Json::Value &json, const std::string &error); Json::Value readJsonFile(const std::string &filename, const std::string &error); -void writeStringFile(const std::string &filename, - const std::string &stringToWrite, - const std::string &error); +void writeStringFile(const std::string &filename, const std::string &stringToWrite, const std::string &error); bool fileExists(const std::string &filename); @@ -68,12 +65,10 @@ class SCRIPT_DLL_EXPORT ScriptRepositoryImpl : public ScriptRepository { SCRIPTSTATUS status; /// provide a constructor, to set the default values. RepositoryEntry() - : remote(false), local(false), directory(false), - current_date(Types::Core::DateAndTime::defaultTime()), - downloaded_date(Types::Core::DateAndTime::defaultTime()), - pub_date(Types::Core::DateAndTime::defaultTime()), description(""), - downloaded_pubdate(Types::Core::DateAndTime::defaultTime()), - auto_update(false), author(""), status(BOTH_UNCHANGED){}; + : remote(false), local(false), directory(false), current_date(Types::Core::DateAndTime::defaultTime()), + downloaded_date(Types::Core::DateAndTime::defaultTime()), pub_date(Types::Core::DateAndTime::defaultTime()), + description(""), downloaded_pubdate(Types::Core::DateAndTime::defaultTime()), auto_update(false), author(""), + status(BOTH_UNCHANGED){}; }; using Repository = std::map<std::string, RepositoryEntry>; @@ -81,8 +76,7 @@ class SCRIPT_DLL_EXPORT ScriptRepositoryImpl : public ScriptRepository { Repository repo; public: - ScriptRepositoryImpl(const std::string &local_rep = std::string(), - const std::string &remote = std::string()); + ScriptRepositoryImpl(const std::string &local_rep = std::string(), const std::string &remote = std::string()); void connect(const std::string &server) override; @@ -97,11 +91,11 @@ public: SCRIPTSTATUS fileStatus(const std::string &input_path) override; - void upload(const std::string &file_path, const std::string &comment, - const std::string &author, const std::string &email) override; + void upload(const std::string &file_path, const std::string &comment, const std::string &author, + const std::string &email) override; // remove file from the central repository and from local folder - void remove(const std::string &file_path, const std::string &comment, - const std::string &author, const std::string &email) override; + void remove(const std::string &file_path, const std::string &comment, const std::string &author, + const std::string &email) override; /* Return true if there is a local repository installed*/ bool isValid() override; @@ -117,13 +111,10 @@ public: /// @deprecated Should avoid this, it is not in the design file. std::string localRepository() const { return local_repository; } - virtual void doDownloadFile(const std::string &url_file, - const std::string &local_file_path = ""); + virtual void doDownloadFile(const std::string &url_file, const std::string &local_file_path = ""); // convenient method to allow to perform the unit tests on remove files. - virtual std::string doDeleteRemoteFile(const std::string &url, - const std::string &file_path, - const std::string &author, - const std::string &email, + virtual std::string doDeleteRemoteFile(const std::string &url, const std::string &file_path, + const std::string &author, const std::string &email, const std::string &comment); protected: diff --git a/Framework/TestHelpers/src/ReflectometryHelper.cpp b/Framework/TestHelpers/src/ReflectometryHelper.cpp index 295b5fd4ecc..f812f6738d0 100644 --- a/Framework/TestHelpers/src/ReflectometryHelper.cpp +++ b/Framework/TestHelpers/src/ReflectometryHelper.cpp @@ -30,20 +30,17 @@ using namespace Kernel; namespace TestHelpers { -MatrixWorkspace_sptr createHistoWS(size_t nBins, double startX, double endX, - std::vector<double> const &values, +MatrixWorkspace_sptr createHistoWS(size_t nBins, double startX, double endX, std::vector<double> const &values, std::string const &unitX = "TOF") { double const dX = (endX - startX) / double(nBins); BinEdges xVals(nBins + 1, LinearGenerator(startX, dX)); size_t nSpec = values.size(); std::vector<double> yVals(nSpec * nBins); for (size_t i = 0; i < nSpec; ++i) { - std::fill(yVals.begin() + i * nBins, yVals.begin() + (i + 1) * nBins, - values[i]); + std::fill(yVals.begin() + i * nBins, yVals.begin() + (i + 1) * nBins, values[i]); } - auto creator = - AlgorithmManager::Instance().createUnmanaged("CreateWorkspace"); + auto creator = AlgorithmManager::Instance().createUnmanaged("CreateWorkspace"); creator->setChild(true); creator->initialize(); creator->setProperty("DataX", xVals.rawData()); @@ -56,29 +53,22 @@ MatrixWorkspace_sptr createHistoWS(size_t nBins, double startX, double endX, return workspace; } -MatrixWorkspace_sptr createREFL_WS(size_t nBins, double startX, double endX, - std::vector<double> const &values, - std::string const ¶msType, - std::string const &instrumentSuffix) { +MatrixWorkspace_sptr createREFL_WS(size_t nBins, double startX, double endX, std::vector<double> const &values, + std::string const ¶msType, std::string const &instrumentSuffix) { MatrixWorkspace_sptr workspace = createHistoWS(nBins, startX, endX, values); auto filePrefix = std::string("unit_testing/REFL") + instrumentSuffix; - auto instrumentLoader = - AlgorithmManager::Instance().createUnmanaged("LoadInstrument"); + auto instrumentLoader = AlgorithmManager::Instance().createUnmanaged("LoadInstrument"); instrumentLoader->initialize(); - instrumentLoader->setPropertyValue( - "Filename", filePrefix + std::string("_Definition.xml")); + instrumentLoader->setPropertyValue("Filename", filePrefix + std::string("_Definition.xml")); instrumentLoader->setProperty("Workspace", workspace); instrumentLoader->setProperty("RewriteSpectraMap", OptionalBool(true)); instrumentLoader->execute(); if (!paramsType.empty()) { - auto paramLoader = - AlgorithmManager::Instance().createUnmanaged("LoadParameterFile"); + auto paramLoader = AlgorithmManager::Instance().createUnmanaged("LoadParameterFile"); paramLoader->initialize(); - paramLoader->setPropertyValue("Filename", filePrefix + - std::string("_Parameters_") + - paramsType + ".xml"); + paramLoader->setPropertyValue("Filename", filePrefix + std::string("_Parameters_") + paramsType + ".xml"); paramLoader->setProperty("Workspace", workspace); paramLoader->execute(); } @@ -86,9 +76,8 @@ MatrixWorkspace_sptr createREFL_WS(size_t nBins, double startX, double endX, return workspace; } -void prepareInputGroup(std::string const &name, std::string const ¶msType, - size_t size, double const startX, double const endX, - size_t const nBins) { +void prepareInputGroup(std::string const &name, std::string const ¶msType, size_t size, double const startX, + double const endX, size_t const nBins) { double monitorValue = 99.0; double detectorValue = 0.9; std::string names; @@ -98,8 +87,7 @@ void prepareInputGroup(std::string const &name, std::string const ¶msType, for (size_t i = 0; i < size; ++i) { std::vector<double> values(257, detectorValue); values[0] = monitorValue; - MatrixWorkspace_sptr ws = - createREFL_WS(nBins, startX, endX, values, paramsType); + MatrixWorkspace_sptr ws = createREFL_WS(nBins, startX, endX, values, paramsType); std::string const name1 = name + "_" + std::to_string(i + 1); ADS.addOrReplace(name1, ws); monitorValue -= 1.0; @@ -109,20 +97,17 @@ void prepareInputGroup(std::string const &name, std::string const ¶msType, names.append(name1); } - auto mkGroup = - AlgorithmManager::Instance().createUnmanaged("GroupWorkspaces"); + auto mkGroup = AlgorithmManager::Instance().createUnmanaged("GroupWorkspaces"); mkGroup->initialize(); mkGroup->setProperty("InputWorkspaces", names); mkGroup->setProperty("OutputWorkspace", name); mkGroup->execute(); } -std::vector<MatrixWorkspace_sptr> -groupToVector(const WorkspaceGroup_sptr &group) { +std::vector<MatrixWorkspace_sptr> groupToVector(const WorkspaceGroup_sptr &group) { std::vector<MatrixWorkspace_sptr> out; for (size_t i = 0; i < group->size(); ++i) { - out.emplace_back( - std::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(i))); + out.emplace_back(std::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(i))); } return out; } @@ -149,25 +134,17 @@ void applyPolarizationEfficiencies(const WorkspaceGroup_sptr &ws) { auto Pa = createHistoWS(nBins, startX, endX, {0.7}); auto Aa = createHistoWS(nBins, startX, endX, {0.6}); - auto Ipp = (Rpp * (Pp + 1.0) * (Ap + 1.0) + - Raa * (Pp * (-1.0) + 1.0) * (Ap * (-1.0) + 1.0) + - Rpa * (Pp + 1.0) * (Ap * (-1.0) + 1.0) + - Rap * (Pp * (-1.0) + 1.0) * (Ap + 1.0)) / + auto Ipp = (Rpp * (Pp + 1.0) * (Ap + 1.0) + Raa * (Pp * (-1.0) + 1.0) * (Ap * (-1.0) + 1.0) + + Rpa * (Pp + 1.0) * (Ap * (-1.0) + 1.0) + Rap * (Pp * (-1.0) + 1.0) * (Ap + 1.0)) / 4.; - auto Iaa = (Raa * (Pa + 1.0) * (Aa + 1.0) + - Rpp * (Pa * (-1.0) + 1.0) * (Aa * (-1.0) + 1.0) + - Rap * (Pa + 1.0) * (Aa * (-1.0) + 1.0) + - Rpa * (Pa * (-1.0) + 1.0) * (Aa + 1.0)) / + auto Iaa = (Raa * (Pa + 1.0) * (Aa + 1.0) + Rpp * (Pa * (-1.0) + 1.0) * (Aa * (-1.0) + 1.0) + + Rap * (Pa + 1.0) * (Aa * (-1.0) + 1.0) + Rpa * (Pa * (-1.0) + 1.0) * (Aa + 1.0)) / 4.; - auto Ipa = (Rpa * (Pp + 1.0) * (Aa + 1.0) + - Rap * (Pp * (-1.0) + 1.0) * (Aa * (-1.0) + 1.0) + - Rpp * (Pp + 1.0) * (Aa * (-1.0) + 1.0) + - Raa * (Pp * (-1.0) + 1.0) * (Aa + 1.0)) / + auto Ipa = (Rpa * (Pp + 1.0) * (Aa + 1.0) + Rap * (Pp * (-1.0) + 1.0) * (Aa * (-1.0) + 1.0) + + Rpp * (Pp + 1.0) * (Aa * (-1.0) + 1.0) + Raa * (Pp * (-1.0) + 1.0) * (Aa + 1.0)) / 4.; - auto Iap = (Rap * (Pa + 1.0) * (Ap + 1.0) + - Rpa * (Pa * (-1.0) + 1.0) * (Ap * (-1.0) + 1.0) + - Raa * (Pa + 1.0) * (Ap * (-1.0) + 1.0) + - Rpp * (Pa * (-1.0) + 1.0) * (Ap + 1.0)) / + auto Iap = (Rap * (Pa + 1.0) * (Ap + 1.0) + Rpa * (Pa * (-1.0) + 1.0) * (Ap * (-1.0) + 1.0) + + Raa * (Pa + 1.0) * (Ap * (-1.0) + 1.0) + Rpp * (Pa * (-1.0) + 1.0) * (Ap + 1.0)) / 4.; auto &ADS = AnalysisDataService::Instance(); @@ -188,15 +165,12 @@ void applyPolarizationEfficiencies(std::string const &name) { applyPolarizationEfficiencies(group); } -MatrixWorkspace_sptr createWorkspaceSingle(const double startX, const int nBins, - const double deltaX, +MatrixWorkspace_sptr createWorkspaceSingle(const double startX, const int nBins, const double deltaX, const std::vector<double> &yValues) { - auto ws = WorkspaceCreationHelper:: - create2DWorkspaceWithReflectometryInstrumentMultiDetector( - startX, 0.0, Mantid::Kernel::V3D(0, 0, 0), - Mantid::Kernel::V3D(0, 0, 1), 0.5, 1.0, Mantid::Kernel::V3D(0, 0, 0), - Mantid::Kernel::V3D(14, 0, 0), Mantid::Kernel::V3D(15, 0, 0), - Mantid::Kernel::V3D(20, (20 - 15), 0), 2, nBins, deltaX); + auto ws = WorkspaceCreationHelper::create2DWorkspaceWithReflectometryInstrumentMultiDetector( + startX, 0.0, Mantid::Kernel::V3D(0, 0, 0), Mantid::Kernel::V3D(0, 0, 1), 0.5, 1.0, Mantid::Kernel::V3D(0, 0, 0), + Mantid::Kernel::V3D(14, 0, 0), Mantid::Kernel::V3D(15, 0, 0), Mantid::Kernel::V3D(20, (20 - 15), 0), 2, nBins, + deltaX); for (auto i = 0u; i < ws->y(0).size(); ++i) { ws->mutableY(0)[i] = yValues[i]; @@ -207,14 +181,11 @@ MatrixWorkspace_sptr createWorkspaceSingle(const double startX, const int nBins, return ws; } -MatrixWorkspace_sptr createWorkspaceSingle(const double startX, const int nBins, - const double deltaX) { - auto ws = WorkspaceCreationHelper:: - create2DWorkspaceWithReflectometryInstrumentMultiDetector( - startX, 0.0, Mantid::Kernel::V3D(0, 0, 0), - Mantid::Kernel::V3D(0, 0, 1), 0.5, 1.0, Mantid::Kernel::V3D(0, 0, 0), - Mantid::Kernel::V3D(14, 0, 0), Mantid::Kernel::V3D(15, 0, 0), - Mantid::Kernel::V3D(20, (20 - 15), 0), 2, nBins, deltaX); +MatrixWorkspace_sptr createWorkspaceSingle(const double startX, const int nBins, const double deltaX) { + auto ws = WorkspaceCreationHelper::create2DWorkspaceWithReflectometryInstrumentMultiDetector( + startX, 0.0, Mantid::Kernel::V3D(0, 0, 0), Mantid::Kernel::V3D(0, 0, 1), 0.5, 1.0, Mantid::Kernel::V3D(0, 0, 0), + Mantid::Kernel::V3D(14, 0, 0), Mantid::Kernel::V3D(15, 0, 0), Mantid::Kernel::V3D(20, (20 - 15), 0), 2, nBins, + deltaX); ws->mutableRun().addProperty<std::string>("run_number", "1234"); return ws; diff --git a/qt/scientific_interfaces/Indirect/ResNorm.cpp b/qt/scientific_interfaces/Indirect/ResNorm.cpp index 21b982a8ac9..39e73d7f59a 100644 --- a/qt/scientific_interfaces/Indirect/ResNorm.cpp +++ b/qt/scientific_interfaces/Indirect/ResNorm.cpp @@ -19,18 +19,15 @@ namespace { Mantid::Kernel::Logger g_log("ResNorm"); MatrixWorkspace_sptr getADSMatrixWorkspace(std::string const &workspaceName) { - return AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( - workspaceName); + return AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(workspaceName); } WorkspaceGroup_sptr getADSGroupWorkspace(std::string const &workspaceName) { - return AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( - workspaceName); + return AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(workspaceName); } ITableWorkspace_sptr getADSTableWorkspace(std::string const &workspaceName) { - return AnalysisDataService::Instance().retrieveWS<ITableWorkspace>( - workspaceName); + return AnalysisDataService::Instance().retrieveWS<ITableWorkspace>(workspaceName); } } // namespace @@ -42,10 +39,8 @@ ResNorm::ResNorm(QWidget *parent) : IndirectBayesTab(parent), m_previewSpec(0) { // Create range selector auto eRangeSelector = m_uiForm.ppPlot->addRangeSelector("ResNormERange"); - connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, - SLOT(minValueChanged(double))); - connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, - SLOT(maxValueChanged(double))); + connect(eRangeSelector, SIGNAL(minValueChanged(double)), this, SLOT(minValueChanged(double))); + connect(eRangeSelector, SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double))); // Add the properties browser to the ui form m_uiForm.treeSpace->addWidget(m_propTree); @@ -68,18 +63,15 @@ ResNorm::ResNorm(QWidget *parent) : IndirectBayesTab(parent), m_previewSpec(0) { SLOT(handleResolutionInputReady(const QString &))); // Connect the preview spectrum selector - connect(m_uiForm.spPreviewSpectrum, SIGNAL(valueChanged(int)), this, - SLOT(previewSpecChanged(int))); + connect(m_uiForm.spPreviewSpectrum, SIGNAL(valueChanged(int)), this, SLOT(previewSpecChanged(int))); - connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, - SLOT(handleAlgorithmComplete(bool))); + connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(handleAlgorithmComplete(bool))); // Post Plot and Save connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(runClicked())); connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked())); connect(m_uiForm.pbPlot, SIGNAL(clicked()), this, SLOT(plotClicked())); - connect(m_uiForm.pbPlotCurrent, SIGNAL(clicked()), this, - SLOT(plotCurrentPreview())); + connect(m_uiForm.pbPlotCurrent, SIGNAL(clicked()), this, SLOT(plotCurrentPreview())); // Allows empty workspace selector when initially selected m_uiForm.dsVanadium->isOptional(true); @@ -89,14 +81,10 @@ ResNorm::ResNorm(QWidget *parent) : IndirectBayesTab(parent), m_previewSpec(0) { void ResNorm::setFileExtensionsByName(bool filter) { QStringList const noSuffixes{""}; auto const tabName("ResNorm"); - m_uiForm.dsVanadium->setFBSuffixes(filter ? getVanadiumFBSuffixes(tabName) - : getExtensions(tabName)); - m_uiForm.dsVanadium->setWSSuffixes(filter ? getVanadiumWSSuffixes(tabName) - : noSuffixes); - m_uiForm.dsResolution->setFBSuffixes(filter ? getResolutionFBSuffixes(tabName) - : getExtensions(tabName)); - m_uiForm.dsResolution->setWSSuffixes(filter ? getResolutionWSSuffixes(tabName) - : noSuffixes); + m_uiForm.dsVanadium->setFBSuffixes(filter ? getVanadiumFBSuffixes(tabName) : getExtensions(tabName)); + m_uiForm.dsVanadium->setWSSuffixes(filter ? getVanadiumWSSuffixes(tabName) : noSuffixes); + m_uiForm.dsResolution->setFBSuffixes(filter ? getResolutionFBSuffixes(tabName) : getExtensions(tabName)); + m_uiForm.dsResolution->setWSSuffixes(filter ? getResolutionWSSuffixes(tabName) : noSuffixes); } void ResNorm::setup() {} @@ -110,10 +98,8 @@ bool ResNorm::validate() { UserInputValidator uiv; QString errors(""); - bool const vanValid = - uiv.checkDataSelectorIsValid("Vanadium", m_uiForm.dsVanadium); - bool const resValid = - uiv.checkDataSelectorIsValid("Resolution", m_uiForm.dsResolution); + bool const vanValid = uiv.checkDataSelectorIsValid("Vanadium", m_uiForm.dsVanadium); + bool const resValid = uiv.checkDataSelectorIsValid("Resolution", m_uiForm.dsResolution); if (vanValid) { // Check vanadium input is _red or _sqw workspace @@ -126,8 +112,7 @@ bool ResNorm::validate() { // Check Res and Vanadium are the same Run if (resValid) { // Check that Res file is still in ADS if not, load it - auto const resolutionWs = getADSMatrixWorkspace( - m_uiForm.dsResolution->getCurrentDataName().toStdString()); + auto const resolutionWs = getADSMatrixWorkspace(m_uiForm.dsResolution->getCurrentDataName().toStdString()); auto const vanadiumWs = getADSMatrixWorkspace(vanName.toStdString()); int const resRun = resolutionWs->getRunNumber(); @@ -177,8 +162,7 @@ void ResNorm::run() { resNorm->setProperty("EnergyMax", eMax); resNorm->setProperty("CreateOutput", true); resNorm->setProperty("OutputWorkspace", outputWsName.toStdString()); - resNorm->setProperty("OutputWorkspaceTable", - (outputWsName + "_Fit").toStdString()); + resNorm->setProperty("OutputWorkspaceTable", (outputWsName + "_Fit").toStdString()); m_batchAlgoRunner->addAlgorithm(resNorm); m_pythonExportWsName = outputWsName.toStdString(); m_batchAlgoRunner->executeBatchAsync(); @@ -207,8 +191,7 @@ void ResNorm::handleAlgorithmComplete(bool error) { void ResNorm::processLogs() { auto const resWsName(m_uiForm.dsResolution->getCurrentDataName()); auto const outputWsName = getWorkspaceBasename(resWsName) + "_ResNorm"; - auto const resolutionWorkspace = - getADSMatrixWorkspace(resWsName.toStdString()); + auto const resolutionWorkspace = getADSMatrixWorkspace(resWsName.toStdString()); auto const resultWorkspace = getADSGroupWorkspace(outputWsName.toStdString()); copyLogs(resolutionWorkspace, resultWorkspace); @@ -243,10 +226,8 @@ void ResNorm::addAdditionalLogs(const Workspace_sptr &resultWorkspace) const { std::map<std::string, std::string> ResNorm::getAdditionalLogStrings() const { auto logs = std::map<std::string, std::string>(); - logs["sample_filename"] = - m_uiForm.dsVanadium->getCurrentDataName().toStdString(); - logs["resolution_filename"] = - m_uiForm.dsResolution->getCurrentDataName().toStdString(); + logs["sample_filename"] = m_uiForm.dsVanadium->getCurrentDataName().toStdString(); + logs["resolution_filename"] = m_uiForm.dsResolution->getCurrentDataName().toStdString(); logs["fit_program"] = "ResNorm"; logs["create_output"] = "true"; return logs; @@ -254,10 +235,8 @@ std::map<std::string, std::string> ResNorm::getAdditionalLogStrings() const { std::map<std::string, std::string> ResNorm::getAdditionalLogNumbers() const { auto logs = std::map<std::string, std::string>(); - logs["e_min"] = - boost::lexical_cast<std::string>(getDoubleManagerProperty("EMin")); - logs["e_max"] = - boost::lexical_cast<std::string>(getDoubleManagerProperty("EMax")); + logs["e_min"] = boost::lexical_cast<std::string>(getDoubleManagerProperty("EMin")); + logs["e_max"] = boost::lexical_cast<std::string>(getDoubleManagerProperty("EMax")); return logs; } @@ -265,14 +244,12 @@ double ResNorm::getDoubleManagerProperty(QString const &propName) const { return m_dblManager->value(m_properties[propName]); } -void ResNorm::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, - const WorkspaceGroup_sptr &resultGroup) const { +void ResNorm::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, const WorkspaceGroup_sptr &resultGroup) const { for (auto const &workspace : *resultGroup) copyLogs(resultWorkspace, workspace); } -void ResNorm::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, - const Workspace_sptr &workspace) const { +void ResNorm::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, const Workspace_sptr &workspace) const { auto logCopier = AlgorithmManager::Instance().create("CopyLogs"); logCopier->setProperty("InputWorkspace", resultWorkspace->getName()); logCopier->setProperty("OutputWorkspace", workspace->getName()); @@ -313,8 +290,7 @@ void ResNorm::handleVanadiumInputReady(const QString &filename) { auto const vanWs = getADSMatrixWorkspace(filename.toStdString()); if (vanWs) - m_uiForm.spPreviewSpectrum->setMaximum( - static_cast<int>(vanWs->getNumberHistograms()) - 1); + m_uiForm.spPreviewSpectrum->setMaximum(static_cast<int>(vanWs->getNumberHistograms()) - 1); auto eRangeSelector = m_uiForm.ppPlot->getRangeSelector("ResNormERange"); @@ -325,15 +301,12 @@ void ResNorm::handleVanadiumInputReady(const QString &filename) { res.first = res.first * 10; res.second = res.second * 10; - setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], - res); + setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], res); } else { - setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], - range); + setRangeSelector(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); } - setPlotPropertyRange(eRangeSelector, m_properties["EMin"], - m_properties["EMax"], range); + setPlotPropertyRange(eRangeSelector, m_properties["EMin"], m_properties["EMax"], range); // Set the current values of the range bars eRangeSelector->setMinimum(range.first); @@ -365,8 +338,7 @@ void ResNorm::minValueChanged(double min) { disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double))); m_dblManager->setValue(m_properties["EMin"], min); - connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, - SLOT(updateProperties(QtProperty *, double))); + connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double))); } /** @@ -378,8 +350,7 @@ void ResNorm::maxValueChanged(double max) { disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double))); m_dblManager->setValue(m_properties["EMax"], max); - connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, - SLOT(updateProperties(QtProperty *, double))); + connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double))); } /** @@ -395,15 +366,12 @@ void ResNorm::updateProperties(QtProperty *prop, double val) { SLOT(updateProperties(QtProperty *, double))); if (prop == m_properties["EMin"]) { - setRangeSelectorMin(m_properties["EMin"], m_properties["EMax"], - eRangeSelector, val); + setRangeSelectorMin(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val); } else if (prop == m_properties["EMax"]) { - setRangeSelectorMax(m_properties["EMin"], m_properties["EMax"], - eRangeSelector, val); + setRangeSelectorMax(m_properties["EMin"], m_properties["EMax"], eRangeSelector, val); } - connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, - SLOT(updateProperties(QtProperty *, double))); + connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, SLOT(updateProperties(QtProperty *, double))); } /** @@ -419,11 +387,8 @@ void ResNorm::previewSpecChanged(int value) { // Update vanadium plot if (m_uiForm.dsVanadium->isValid()) try { - m_uiForm.ppPlot->addSpectrum( - "Vanadium", m_uiForm.dsVanadium->getCurrentDataName(), m_previewSpec); - m_uiForm.ppPlot->addSpectrum("Resolution", - m_uiForm.dsResolution->getCurrentDataName(), - 0, Qt::blue); + m_uiForm.ppPlot->addSpectrum("Vanadium", m_uiForm.dsVanadium->getCurrentDataName(), m_previewSpec); + m_uiForm.ppPlot->addSpectrum("Resolution", m_uiForm.dsResolution->getCurrentDataName(), 0, Qt::blue); } catch (std::exception const &ex) { g_log.warning(ex.what()); } @@ -452,8 +417,7 @@ void ResNorm::previewSpecChanged(int value) { g_log.warning(ex.what()); } - AnalysisDataService::Instance().addOrReplace( - "__" + fitWsGroupName + "_scaled", fit); + AnalysisDataService::Instance().addOrReplace("__" + fitWsGroupName + "_scaled", fit); } } } @@ -468,13 +432,11 @@ void ResNorm::plotCurrentPreview() { std::vector<int> plotIndices; if (m_uiForm.ppPlot->hasCurve("Vanadium")) { - plotWorkspaces.emplace_back( - m_uiForm.dsVanadium->getCurrentDataName().toStdString()); + plotWorkspaces.emplace_back(m_uiForm.dsVanadium->getCurrentDataName().toStdString()); plotIndices.emplace_back(m_previewSpec); } if (m_uiForm.ppPlot->hasCurve("Resolution")) { - plotWorkspaces.emplace_back( - m_uiForm.dsResolution->getCurrentDataName().toStdString()); + plotWorkspaces.emplace_back(m_uiForm.dsResolution->getCurrentDataName().toStdString()); plotIndices.emplace_back(0); } if (m_uiForm.ppPlot->hasCurve("Fit")) { @@ -524,18 +486,14 @@ void ResNorm::plotClicked() { setPlotResultIsPlotting(false); } -void ResNorm::setRunEnabled(bool enabled) { - m_uiForm.pbRun->setEnabled(enabled); -} +void ResNorm::setRunEnabled(bool enabled) { m_uiForm.pbRun->setEnabled(enabled); } void ResNorm::setPlotResultEnabled(bool enabled) { m_uiForm.pbPlot->setEnabled(enabled); m_uiForm.cbPlot->setEnabled(enabled); } -void ResNorm::setSaveResultEnabled(bool enabled) { - m_uiForm.pbSave->setEnabled(enabled); -} +void ResNorm::setSaveResultEnabled(bool enabled) { m_uiForm.pbSave->setEnabled(enabled); } void ResNorm::setButtonsEnabled(bool enabled) { setRunEnabled(enabled); diff --git a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp index 9b2aae5fa15..6b4b92f3415 100644 --- a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp +++ b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp @@ -38,26 +38,20 @@ using namespace MantidQt::API; namespace MantidQt { namespace CustomInterfaces { ALCDataLoadingPresenter::ALCDataLoadingPresenter(IALCDataLoadingView *view) - : m_view(view), m_numDetectors(0), m_loadingData(false), - m_directoryChanged(false), m_timerID(), m_lastRunLoadedAuto(-2), - m_filesLoaded(), m_wasLastAutoRange(false), m_previousFirstRun("") {} + : m_view(view), m_numDetectors(0), m_loadingData(false), m_directoryChanged(false), m_timerID(), + m_lastRunLoadedAuto(-2), m_filesLoaded(), m_wasLastAutoRange(false), m_previousFirstRun("") {} void ALCDataLoadingPresenter::initialize() { m_view->initialize(); connect(m_view, SIGNAL(loadRequested()), SLOT(handleLoadRequested())); - connect(m_view, SIGNAL(instrumentChangedSignal(std::string)), - SLOT(handleInstrumentChanged(std::string))); + connect(m_view, SIGNAL(instrumentChangedSignal(std::string)), SLOT(handleInstrumentChanged(std::string))); connect(m_view, SIGNAL(runsEditingSignal()), SLOT(handleRunsEditing())); - connect(m_view, SIGNAL(runsEditingFinishedSignal()), - SLOT(handleRunsEditingFinished())); - connect(m_view, SIGNAL(manageDirectoriesClicked()), - SLOT(handleManageDirectories())); + connect(m_view, SIGNAL(runsEditingFinishedSignal()), SLOT(handleRunsEditingFinished())); + connect(m_view, SIGNAL(manageDirectoriesClicked()), SLOT(handleManageDirectories())); connect(m_view, SIGNAL(runsFoundSignal()), SLOT(handleRunsFound())); - connect(m_view, SIGNAL(autoAddToggledSignal(bool)), - SLOT(startWatching(bool))); - connect(&m_watcher, SIGNAL(directoryChanged(const QString &)), - SLOT(updateDirectoryChangedFlag(const QString &))); + connect(m_view, SIGNAL(autoAddToggledSignal(bool)), SLOT(startWatching(bool))); + connect(&m_watcher, SIGNAL(directoryChanged(const QString &)), SLOT(updateDirectoryChangedFlag(const QString &))); } void ALCDataLoadingPresenter::handleRunsEditing() { @@ -69,8 +63,7 @@ void ALCDataLoadingPresenter::handleRunsEditingFinished() { // Make sure everything is reset m_view->enableRunsAutoAdd(false); - m_view->setLoadStatus( - "Finding " + m_view->getInstrument() + m_view->getRunsText(), "orange"); + m_view->setLoadStatus("Finding " + m_view->getInstrument() + m_view->getRunsText(), "orange"); m_view->enableAlpha(false); m_view->setAlphaValue(""); m_view->showAlphaMessage(false); @@ -94,11 +87,8 @@ void ALCDataLoadingPresenter::handleRunsFound() { try { updateAvailableInfo(); m_view->enableLoad(true); - m_view->setLoadStatus("Successfully found " + m_view->getInstrument() + - m_view->getRunsText(), - "green"); - m_previousFirstRun = - m_view->getInstrument() + m_view->getRunsFirstRunText(); + m_view->setLoadStatus("Successfully found " + m_view->getInstrument() + m_view->getRunsText(), "green"); + m_previousFirstRun = m_view->getInstrument() + m_view->getRunsFirstRunText(); } catch (const std::runtime_error &errroUpdateInfo) { m_view->setLoadStatus("Error", "red"); m_view->displayError(errroUpdateInfo.what()); @@ -123,21 +113,17 @@ void ALCDataLoadingPresenter::handleLoadRequested() { // Warning message if trying to load excessive number of files if (files.size() > RUNS_WARNING_LIMIT) { - auto continueLoad = m_view->displayWarning( - "You are attempting to load " + std::to_string(files.size()) + - " runs, are you sure you want to do this?"); + auto continueLoad = m_view->displayWarning("You are attempting to load " + std::to_string(files.size()) + + " runs, are you sure you want to do this?"); if (!continueLoad) return; } - m_view->setLoadStatus( - "Loading " + m_view->getInstrument() + m_view->getRunsText(), "orange"); + m_view->setLoadStatus("Loading " + m_view->getInstrument() + m_view->getRunsText(), "orange"); try { load(files); m_filesLoaded = files; - m_view->setLoadStatus("Successfully loaded " + m_view->getInstrument() + - m_view->getRunsText(), - "green"); + m_view->setLoadStatus("Successfully loaded " + m_view->getInstrument() + m_view->getRunsText(), "green"); m_view->enableRunsAutoAdd(true); // If alpha empty, default used is 1 so update interface @@ -167,8 +153,7 @@ int ALCDataLoadingPresenter::extractRunNumber(const std::string &file) { returnVal = returnVal.substr(found + 1); // Remove all non-digits - returnVal.erase(std::remove_if(returnVal.begin(), returnVal.end(), - [](auto c) { return !std::isdigit(c); }), + returnVal.erase(std::remove_if(returnVal.begin(), returnVal.end(), [](auto c) { return !std::isdigit(c); }), returnVal.end()); // Return run number as int (removes leading 0's) @@ -186,13 +171,11 @@ void ALCDataLoadingPresenter::load(const std::vector<std::string> &files) { // Before loading, check custom grouping (if used) is sensible const bool groupingOK = checkCustomGrouping(); if (!groupingOK) { - throw std::runtime_error( - "Custom grouping not valid (bad format or detector numbers)"); + throw std::runtime_error("Custom grouping not valid (bad format or detector numbers)"); } try { - IAlgorithm_sptr alg = - AlgorithmManager::Instance().create("PlotAsymmetryByLogValue"); + IAlgorithm_sptr alg = AlgorithmManager::Instance().create("PlotAsymmetryByLogValue"); alg->setAlwaysStoreInADS(false); // Don't want workspaces in the ADS // Change first last run to WorkspaceNames @@ -286,8 +269,7 @@ void ALCDataLoadingPresenter::updateAvailableInfo() { try //... to load the first run { - IAlgorithm_sptr loadAlg = - AlgorithmManager::Instance().create("LoadMuonNexus"); + IAlgorithm_sptr loadAlg = AlgorithmManager::Instance().create("LoadMuonNexus"); loadAlg->setChild(true); // Don't want workspaces in the ADS // We need logs only but we have to use LoadMuonNexus @@ -307,7 +289,8 @@ void ALCDataLoadingPresenter::updateAvailableInfo() { auto path = loadAlg->getPropertyValue("Filename"); path = path.substr(0, path.find_last_of("/\\")); m_view->setPath(path); - } catch (const std::exception &error) { + } + catch (const std::exception &error) { m_view->setAvailableInfoToEmpty(); throw std::runtime_error(error.what()); } @@ -328,13 +311,10 @@ void ALCDataLoadingPresenter::updateAvailableInfo() { // compare logs char by char and return pair of non-equal elements const auto result = std::mismatch(log1.cbegin(), log1.cend(), log2.cbegin(), log2.cend(), - [](const auto &lhs, const auto &rhs) { - return std::tolower(lhs) == std::tolower(rhs); - }); + [](const auto &lhs, const auto &rhs) { return std::tolower(lhs) == std::tolower(rhs); }); // compare the two elements to decide which log should go first return result.second != log2.cend() && - (result.first == log1.cend() || - std::tolower(*result.first) < std::tolower(*result.second)); + (result.first == log1.cend() || std::tolower(*result.first) < std::tolower(*result.second)); }); m_view->setAvailableLogs(logs); @@ -361,8 +341,7 @@ void ALCDataLoadingPresenter::updateAvailableInfo() { // Set time limits if this is the first data loaded (will both be zero) if (auto timeLimits = m_view->timeRange()) { - if (std::abs(timeLimits->first) < 0.0001 && - std::abs(timeLimits->second) < 0.0001) { + if (std::abs(timeLimits->first) < 0.0001 && std::abs(timeLimits->second) < 0.0001) { m_view->setTimeLimits(firstGoodData - timeZero, ws->x(0).back()); } } @@ -397,18 +376,16 @@ void ALCDataLoadingPresenter::setData(const MatrixWorkspace_sptr &data) { bool ALCDataLoadingPresenter::checkCustomGrouping() { bool groupingOK = true; if (m_view->detectorGroupingType() == "Custom") { - auto detectors = Mantid::Kernel::Strings::parseRange( - isCustomGroupingValid(m_view->getForwardGrouping(), groupingOK)); - const auto backward = Mantid::Kernel::Strings::parseRange( - isCustomGroupingValid(m_view->getBackwardGrouping(), groupingOK)); + auto detectors = + Mantid::Kernel::Strings::parseRange(isCustomGroupingValid(m_view->getForwardGrouping(), groupingOK)); + const auto backward = + Mantid::Kernel::Strings::parseRange(isCustomGroupingValid(m_view->getBackwardGrouping(), groupingOK)); if (!groupingOK) { return false; } detectors.insert(detectors.end(), backward.begin(), backward.end()); if (std::any_of(detectors.cbegin(), detectors.cend(), - [this](const auto det) { - return det < 0 || det > static_cast<int>(m_numDetectors); - })) { + [this](const auto det) { return det < 0 || det > static_cast<int>(m_numDetectors); })) { groupingOK = false; } } @@ -421,11 +398,8 @@ bool ALCDataLoadingPresenter::checkCustomGrouping() { * @param isValid :: bool to say if the string is valid * @returns :: True if grouping OK, false if bad */ -std::string -ALCDataLoadingPresenter::isCustomGroupingValid(const std::string &group, - bool &isValid) { - if (!std::isdigit(group[0]) || - std::any_of(std::begin(group), std::end(group), ::isalpha)) { +std::string ALCDataLoadingPresenter::isCustomGroupingValid(const std::string &group, bool &isValid) { + if (!std::isdigit(group[0]) || std::any_of(std::begin(group), std::end(group), ::isalpha)) { isValid = false; return ""; } @@ -515,8 +489,7 @@ void ALCDataLoadingPresenter::timerEvent(QTimerEvent *timeup) { if (!isLoading()) { // add to list set text with search const auto oldRuns = m_view->getFiles(); - if (std::find(oldRuns.begin(), oldRuns.end(), latestFile) == - oldRuns.end()) { + if (std::find(oldRuns.begin(), oldRuns.end(), latestFile) == oldRuns.end()) { // Get old text auto newText = m_view->getRunsText(); diff --git a/qt/widgets/common/src/AlgorithmProgress/AlgorithmProgressPresenterBase.cpp b/qt/widgets/common/src/AlgorithmProgress/AlgorithmProgressPresenterBase.cpp index 2cb5d4f8a6c..010c6b22c51 100644 --- a/qt/widgets/common/src/AlgorithmProgress/AlgorithmProgressPresenterBase.cpp +++ b/qt/widgets/common/src/AlgorithmProgress/AlgorithmProgressPresenterBase.cpp @@ -10,8 +10,7 @@ namespace MantidQt { namespace MantidWidgets { -AlgorithmProgressPresenterBase::AlgorithmProgressPresenterBase(QObject *parent) - : QObject(parent) { +AlgorithmProgressPresenterBase::AlgorithmProgressPresenterBase(QObject *parent) : QObject(parent) { const auto connection = Qt::QueuedConnection; connect(this, &AlgorithmProgressPresenterBase::algorithmStartedSignal, this, &AlgorithmProgressPresenterBase::algorithmStartedSlot, connection); @@ -27,18 +26,14 @@ AlgorithmProgressPresenterBase::AlgorithmProgressPresenterBase(QObject *parent) /// started signal, which is allows the GUIs to be updated, by triggering the /// slot in the GUI thread. It is safe to call this function from any thread /// @param alg The ID of the algorithm that has started executing -void AlgorithmProgressPresenterBase::algorithmStarted( - Mantid::API::AlgorithmID alg) { +void AlgorithmProgressPresenterBase::algorithmStarted(Mantid::API::AlgorithmID alg) { emit algorithmStartedSignal(alg); } /// This function is called whenever an algorithm ended. It emits a signal /// triggering the slot inside the GUI thread. It is safe to call this function /// from any thread /// @param alg The ID of the algorithm that has started executing -void AlgorithmProgressPresenterBase::algorithmEnded( - Mantid::API::AlgorithmID alg) { - emit algorithmEndedSignal(alg); -} +void AlgorithmProgressPresenterBase::algorithmEnded(Mantid::API::AlgorithmID alg) { emit algorithmEndedSignal(alg); } /// Updates the parameter progress bar to display the progress. If there is a /// message, the progress bar format is changed to display it as well. /// @param progressBar The progress bar that will be updated @@ -47,9 +42,9 @@ void AlgorithmProgressPresenterBase::algorithmEnded( /// already have been copied into the GUI thread, so it is safe to receive it by /// @param estimatedTime :: estimated time to completion in seconds /// @param progressPrecision :: number of digits after the decimal -void AlgorithmProgressPresenterBase::setProgressBar( - QProgressBar *progressBar, const double progress, const QString &message, - const double estimatedTime, const int progressPrecision) { +void AlgorithmProgressPresenterBase::setProgressBar(QProgressBar *progressBar, const double progress, + const QString &message, const double estimatedTime, + const int progressPrecision) { progressBar->setValue(static_cast<int>(progress * 100)); // Make the progress string std::ostringstream mess; @@ -85,11 +80,10 @@ void AlgorithmProgressPresenterBase::setProgressBar( /// @param msg The message that the algorithm has sent /// @param estimatedTime :: estimated time to completion in seconds /// @param progressPrecision :: number of digits after the decimal -void AlgorithmProgressPresenterBase::updateProgressBar( - Mantid::API::AlgorithmID alg, double progress, const std::string &msg, - const double estimatedTime, const int progressPrecision) { - emit updateProgressBarSignal(alg, progress, QString::fromStdString(msg), - estimatedTime, progressPrecision); +void AlgorithmProgressPresenterBase::updateProgressBar(Mantid::API::AlgorithmID alg, double progress, + const std::string &msg, const double estimatedTime, + const int progressPrecision) { + emit updateProgressBarSignal(alg, progress, QString::fromStdString(msg), estimatedTime, progressPrecision); } } // namespace MantidWidgets } // namespace MantidQt \ No newline at end of file -- GitLab