diff --git a/.gitignore b/.gitignore index 7d9b761d440253359d89a5aba7cc921cdb4877bf..c273e6b394bcb67138260238537960713c1c1d53 100644 --- a/.gitignore +++ b/.gitignore @@ -166,6 +166,7 @@ Desktop.ini # VSCode .vscode/ +.clangd/ XDG_CACHE_HOME/ # The file that contains metadata for VSCode Workspace *.code-workspace diff --git a/CMakeLists.txt b/CMakeLists.txt index e23e0975193001e7365b3b0798cf3550511fb741..4841c27ce97940a5515f27e10676cc138523b9a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,10 @@ option(ENABLE_WORKBENCH "Enable Qt5-based gui & components" ON) set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR}" "Mantid" "ALL" "/") +# Ensure that if we are running any sanitizers the compiler options are +# known in sub targets +include(Sanitizers) + # Quick exit if we only want data targets if(DATA_TARGETS_ONLY) include(SetupDataTargets) diff --git a/Framework/API/inc/MantidAPI/Algorithm.h b/Framework/API/inc/MantidAPI/Algorithm.h index 044cb68477079e55ff46b814f0aeee8d1df304ce..b92a36024ec8a509b62f672e6b9ced601420e985 100644 --- a/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Framework/API/inc/MantidAPI/Algorithm.h @@ -288,7 +288,7 @@ public: const std::string &name, const double startProgress = -1., const double endProgress = -1., const bool enableLogging = true, const int &version = -1); - void setupAsChildAlgorithm(boost::shared_ptr<Algorithm> algorithm, + void setupAsChildAlgorithm(const boost::shared_ptr<Algorithm> &algorithm, const double startProgress = -1., const double endProgress = -1., const bool enableLogging = true); diff --git a/Framework/API/inc/MantidAPI/AlgorithmFactory.h b/Framework/API/inc/MantidAPI/AlgorithmFactory.h index af81adc43d9d6397bee92a7dec26e34272363c52..0bbcea94b8ab9bad420414f6dbe55ece8ab0f456 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmFactory.h +++ b/Framework/API/inc/MantidAPI/AlgorithmFactory.h @@ -129,9 +129,9 @@ private: /// Extract the name of an algorithm const std::string - extractAlgName(const boost::shared_ptr<IAlgorithm> alg) const; + extractAlgName(const boost::shared_ptr<IAlgorithm> &alg) const; /// Extract the version of an algorithm - int extractAlgVersion(const boost::shared_ptr<IAlgorithm> alg) const; + int extractAlgVersion(const boost::shared_ptr<IAlgorithm> &alg) const; /// Create an algorithm object with the specified name boost::shared_ptr<Algorithm> createAlgorithm(const std::string &name, diff --git a/Framework/API/inc/MantidAPI/AlgorithmHistory.h b/Framework/API/inc/MantidAPI/AlgorithmHistory.h index 28c95f5a2470971cfc5b2038d434fcc79407214f..9da3a963252551ad9640aa8874f7d7bedbc5b6ed 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmHistory.h +++ b/Framework/API/inc/MantidAPI/AlgorithmHistory.h @@ -63,7 +63,7 @@ public: bool isdefault, const unsigned int &direction = 99); /// add a child algorithm history record to this history object - void addChildHistory(AlgorithmHistory_sptr childHist); + void addChildHistory(const AlgorithmHistory_sptr &childHist); // get functions /// get name of algorithm in history const const std::string &name() const { return m_name; } diff --git a/Framework/API/inc/MantidAPI/AlgorithmManager.h b/Framework/API/inc/MantidAPI/AlgorithmManager.h index a881c7dab3c09dc34b66deabb3fa85927b93322d..652795dd2ac45ca16480cbd93a7c6fd83ad1e4ce 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmManager.h +++ b/Framework/API/inc/MantidAPI/AlgorithmManager.h @@ -17,6 +17,7 @@ #include <deque> #include <mutex> #include <string> +#include <utility> namespace Mantid { namespace API { @@ -26,7 +27,7 @@ namespace API { class AlgorithmStartingNotification : public Poco::Notification { public: AlgorithmStartingNotification(IAlgorithm_sptr alg) - : Poco::Notification(), m_alg(alg) {} + : Poco::Notification(), m_alg(std::move(alg)) {} /// Returns the algorithm that is starting IAlgorithm_sptr getAlgorithm() const { return m_alg; } @@ -48,7 +49,6 @@ public: const int &version = -1) const; std::size_t size() const; - void setMaxAlgorithms(int n); IAlgorithm_sptr getAlgorithm(AlgorithmID id) const; void removeById(AlgorithmID id); @@ -78,8 +78,9 @@ private: /// Unimplemented assignment operator AlgorithmManagerImpl &operator=(const AlgorithmManagerImpl &); - /// The maximum size of the algorithm store - int m_max_no_algs; + /// Removes any finished algorithms from the list of managed algorithms + size_t removeFinishedAlgorithms(); + /// The list of managed algorithms std::deque<IAlgorithm_sptr> m_managed_algs; ///< pointers to managed algorithms [policy???] diff --git a/Framework/API/inc/MantidAPI/AlgorithmObserver.h b/Framework/API/inc/MantidAPI/AlgorithmObserver.h index 699204626d874a3f7ee78ec9331ea3096ff70aa6..3de449bd9cc157cc36b618951baea51553516e93 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmObserver.h +++ b/Framework/API/inc/MantidAPI/AlgorithmObserver.h @@ -23,17 +23,17 @@ Hides Poco::Notification API from the user. class MANTID_API_DLL AlgorithmObserver { public: AlgorithmObserver(); - AlgorithmObserver(IAlgorithm_const_sptr alg); + AlgorithmObserver(const IAlgorithm_const_sptr &alg); virtual ~AlgorithmObserver(); - void observeAll(IAlgorithm_const_sptr alg); - void observeProgress(IAlgorithm_const_sptr alg); + void observeAll(const IAlgorithm_const_sptr &alg); + void observeProgress(const IAlgorithm_const_sptr &alg); void observeStarting(); - void observeStart(IAlgorithm_const_sptr alg); - void observeFinish(IAlgorithm_const_sptr alg); - void observeError(IAlgorithm_const_sptr alg); + void observeStart(const IAlgorithm_const_sptr &alg); + void observeFinish(const IAlgorithm_const_sptr &alg); + void observeError(const IAlgorithm_const_sptr &alg); - void stopObserving(IAlgorithm_const_sptr alg); + void stopObserving(const IAlgorithm_const_sptr &alg); void stopObserving(const Mantid::API::IAlgorithm *alg); void stopObservingManager(); diff --git a/Framework/API/inc/MantidAPI/AlgorithmProxy.h b/Framework/API/inc/MantidAPI/AlgorithmProxy.h index face35a487563e518e31b28e781ff402517b30d6..45490f3bcb7167232b937cf1df29b8dbcb575f88 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmProxy.h +++ b/Framework/API/inc/MantidAPI/AlgorithmProxy.h @@ -50,7 +50,7 @@ http://proj-gaudi.web.cern.ch/proj-gaudi/) class MANTID_API_DLL AlgorithmProxy : public IAlgorithm, public Kernel::PropertyManagerOwner { public: - AlgorithmProxy(Algorithm_sptr alg); + AlgorithmProxy(const Algorithm_sptr &alg); AlgorithmProxy(const AlgorithmProxy &) = delete; AlgorithmProxy &operator=(const AlgorithmProxy &) = delete; ~AlgorithmProxy() override; diff --git a/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h b/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h index 15e7c685f887d8b6d9570c094dde1ce3e7808912..39af124f01c44922a82a2e0068345fbab9dced95 100644 --- a/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h +++ b/Framework/API/inc/MantidAPI/BoostOptionalToAlgorithmProperty.h @@ -36,8 +36,9 @@ value of type boost::optional<T> will be returned. */ template <typename T> T checkForMandatoryInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getNumberParameter(idf_name); @@ -68,8 +69,9 @@ T checkForMandatoryInstrumentDefault( */ template <typename T> boost::optional<T> checkForOptionalInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getNumberParameter(idf_name); @@ -90,12 +92,14 @@ boost::optional<T> checkForOptionalInstrumentDefault( */ template <> MANTID_API_DLL std::string checkForMandatoryInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name); + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name); template <> MANTID_API_DLL boost::optional<std::string> checkForOptionalInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name); + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name); } // namespace API } // namespace Mantid diff --git a/Framework/API/inc/MantidAPI/BoxController.h b/Framework/API/inc/MantidAPI/BoxController.h index 0a2b93a421e481b3a2efa9580f16290f6bd6bad1..9c52e87a400d197b29c6fa9a83fe45e1cb463a3b 100644 --- a/Framework/API/inc/MantidAPI/BoxController.h +++ b/Framework/API/inc/MantidAPI/BoxController.h @@ -399,7 +399,7 @@ public: IBoxControllerIO *getFileIO() { return m_fileIO.get(); } /// makes box controller file based by providing class, responsible for /// fileIO. - void setFileBacked(boost::shared_ptr<IBoxControllerIO> newFileIO, + void setFileBacked(const boost::shared_ptr<IBoxControllerIO> &newFileIO, const std::string &fileName = ""); void clearFileBacked(); //----------------------------------------------------------------------------------- diff --git a/Framework/API/inc/MantidAPI/CompositeCatalog.h b/Framework/API/inc/MantidAPI/CompositeCatalog.h index 630d9c37419e66667fd6a74e1cfcb70c13eb8dfb..b4ebf7022f981e57079ddab9bd6167edba3713b9 100644 --- a/Framework/API/inc/MantidAPI/CompositeCatalog.h +++ b/Framework/API/inc/MantidAPI/CompositeCatalog.h @@ -25,7 +25,7 @@ public: /// Constructor CompositeCatalog(); /// Adds a catalog to the list of catalogs (m_catalogs) - void add(const ICatalog_sptr catalog); + void add(const ICatalog_sptr &catalog); /// Log the user into the catalog system. CatalogSession_sptr login(const std::string &username, const std::string &password, diff --git a/Framework/API/inc/MantidAPI/CompositeDomainMD.h b/Framework/API/inc/MantidAPI/CompositeDomainMD.h index fb48245da0d522359b09568ce9582b7d08f4f767..0ef223294d2acd1febee0f5a92ee25abe798d1be 100644 --- a/Framework/API/inc/MantidAPI/CompositeDomainMD.h +++ b/Framework/API/inc/MantidAPI/CompositeDomainMD.h @@ -27,7 +27,7 @@ class FunctionDomainMD; */ class MANTID_API_DLL CompositeDomainMD : public CompositeDomain { public: - CompositeDomainMD(IMDWorkspace_const_sptr ws, size_t maxDomainSize); + CompositeDomainMD(const IMDWorkspace_const_sptr &ws, size_t maxDomainSize); ~CompositeDomainMD() override; /// Return the total number of arguments in the domain size_t size() const override { return m_totalSize; } diff --git a/Framework/API/inc/MantidAPI/CompositeFunction.h b/Framework/API/inc/MantidAPI/CompositeFunction.h index 602389ba1a056fbf0c024b85c919f2186654b6cb..d7034583b1de25f7cb6a899d8452267c94685c49 100644 --- a/Framework/API/inc/MantidAPI/CompositeFunction.h +++ b/Framework/API/inc/MantidAPI/CompositeFunction.h @@ -148,9 +148,10 @@ public: /// Remove a function void removeFunction(size_t i); /// Replace a function - void replaceFunction(size_t i, IFunction_sptr f); + void replaceFunction(size_t i, const IFunction_sptr &f); /// Replace a function - void replaceFunctionPtr(const IFunction_sptr f_old, IFunction_sptr f_new); + void replaceFunctionPtr(const IFunction_sptr &f_old, + const IFunction_sptr &f_new); /// Get the function index std::size_t functionIndex(std::size_t i) const; /// Returns the index of parameter i as it declared in its function diff --git a/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h b/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h index 49db7621c3d62e9426743b37e5e25e6513f93919..ae1dfeb7cb6b7f0949853938934b92e5ea3f6172 100644 --- a/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h +++ b/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h @@ -45,7 +45,7 @@ protected: void setPropManagerPropName(const std::string &propName); void mapPropertyName(const std::string &nameInProp, const std::string &nameInPropManager); - void copyProperty(API::Algorithm_sptr alg, const std::string &name); + void copyProperty(const API::Algorithm_sptr &alg, const std::string &name); virtual ITableWorkspace_sptr determineChunk(const std::string &filename); virtual MatrixWorkspace_sptr loadChunk(const size_t rowIndex); Workspace_sptr load(const std::string &inputData, diff --git a/Framework/API/inc/MantidAPI/DetectorSearcher.h b/Framework/API/inc/MantidAPI/DetectorSearcher.h index 22af6d76cfedd300f574c2d38addf24c8fe3396e..27c4a4f7b2c328c5b5c80250f8fccac67b62a8bc 100644 --- a/Framework/API/inc/MantidAPI/DetectorSearcher.h +++ b/Framework/API/inc/MantidAPI/DetectorSearcher.h @@ -43,7 +43,7 @@ public: using DetectorSearchResult = std::tuple<bool, size_t>; /// Create a new DetectorSearcher with the given instrument & detectors - DetectorSearcher(Geometry::Instrument_const_sptr instrument, + DetectorSearcher(const Geometry::Instrument_const_sptr &instrument, const Geometry::DetectorInfo &detInfo); /// Find a detector that intsects with the given Qlab vector DetectorSearchResult findDetectorIndex(const Kernel::V3D &q); diff --git a/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h b/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h index 30160436a5c2e304b10a1cfe5f64365f76e93414..a849731c9ff0b40f705049907931d981704495f9 100644 --- a/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h +++ b/Framework/API/inc/MantidAPI/EnabledWhenWorkspaceIsType.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Workspace_fwd.h" #include "MantidKernel/DataService.h" @@ -35,7 +37,7 @@ public: */ EnabledWhenWorkspaceIsType(std::string otherPropName, bool enabledSetting = true) - : IPropertySettings(), m_otherPropName(otherPropName), + : IPropertySettings(), m_otherPropName(std::move(otherPropName)), m_enabledSetting(enabledSetting) {} //-------------------------------------------------------------------------------------------- diff --git a/Framework/API/inc/MantidAPI/ExperimentInfo.h b/Framework/API/inc/MantidAPI/ExperimentInfo.h index fd15de6045e6431a6c2a72021a6ee336c10eba30..4d3134e9e43b522603e5027801d9abed8ec84d8c 100644 --- a/Framework/API/inc/MantidAPI/ExperimentInfo.h +++ b/Framework/API/inc/MantidAPI/ExperimentInfo.h @@ -107,9 +107,9 @@ public: /// Easy access to the efixed value for this run & detector ID double getEFixed(const detid_t detID) const; /// Easy access to the efixed value for this run & optional detector - double getEFixed(const boost::shared_ptr<const Geometry::IDetector> detector = - boost::shared_ptr<const Geometry::IDetector>{ - nullptr}) const; + double + getEFixed(const boost::shared_ptr<const Geometry::IDetector> &detector = + boost::shared_ptr<const Geometry::IDetector>{nullptr}) const; /// Set the efixed value for a given detector ID void setEFixed(const detid_t detID, const double value); diff --git a/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h b/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h index 333bfd46ac3858233f7aa90658135e0f7a75a5e0..d87f3d7c9d5cbfb9221805de9309a5d85e039d9a 100644 --- a/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h +++ b/Framework/API/inc/MantidAPI/FunctionDomainGeneral.h @@ -25,7 +25,7 @@ public: /// Get the number of columns size_t columnCount() const; /// Add a new column. All columns must have the same size. - void addColumn(boost::shared_ptr<Column> column); + void addColumn(const boost::shared_ptr<Column> &column); /// Get i-th column boost::shared_ptr<Column> getColumn(size_t i) const; diff --git a/Framework/API/inc/MantidAPI/FunctionDomainMD.h b/Framework/API/inc/MantidAPI/FunctionDomainMD.h index d1641310378773cea9a64923a39e5bb3f97782e8..43ebc9efa049ac4ea93b8f8593986d6f8fa01790 100644 --- a/Framework/API/inc/MantidAPI/FunctionDomainMD.h +++ b/Framework/API/inc/MantidAPI/FunctionDomainMD.h @@ -22,7 +22,7 @@ namespace API { class MANTID_API_DLL FunctionDomainMD : public FunctionDomain { public: /// Constructor. - FunctionDomainMD(IMDWorkspace_const_sptr ws, size_t start = 0, + FunctionDomainMD(const IMDWorkspace_const_sptr &ws, size_t start = 0, size_t length = 0); /// Destructor. ~FunctionDomainMD() override; diff --git a/Framework/API/inc/MantidAPI/FunctionFactory.h b/Framework/API/inc/MantidAPI/FunctionFactory.h index b77dd2a80be5ecedca10d20adcf74a0320b45aad..bfb3b208013176d2586d9ba89ad8d17fdf7688d7 100644 --- a/Framework/API/inc/MantidAPI/FunctionFactory.h +++ b/Framework/API/inc/MantidAPI/FunctionFactory.h @@ -90,19 +90,21 @@ private: /// Throw an exception void inputError(const std::string &str = "") const; /// Add constraints to the created function - void addConstraints(boost::shared_ptr<IFunction> fun, + void addConstraints(const boost::shared_ptr<IFunction> &fun, const Expression &expr) const; /// Add a single constraint to the created function - void addConstraint(boost::shared_ptr<IFunction> fun, + void addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &expr) const; /// Add a single constraint to the created function with non-default penalty - void addConstraint(boost::shared_ptr<IFunction> fun, + void addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &constraint_expr, const Expression &penalty_expr) const; /// Add ties to the created function - void addTies(boost::shared_ptr<IFunction> fun, const Expression &expr) const; + void addTies(const boost::shared_ptr<IFunction> &fun, + const Expression &expr) const; /// Add a tie to the created function - void addTie(boost::shared_ptr<IFunction> fun, const Expression &expr) const; + void addTie(const boost::shared_ptr<IFunction> &fun, + const Expression &expr) const; mutable std::map<std::string, std::vector<std::string>> m_cachedFunctionNames; mutable std::mutex m_mutex; diff --git a/Framework/API/inc/MantidAPI/FunctionGenerator.h b/Framework/API/inc/MantidAPI/FunctionGenerator.h index 61bdc373d3a8dc121e6b6be46e7c6267d58317de..68fafe0b7a0808c401e389862bcf5c4c854978c9 100644 --- a/Framework/API/inc/MantidAPI/FunctionGenerator.h +++ b/Framework/API/inc/MantidAPI/FunctionGenerator.h @@ -31,7 +31,7 @@ belongs to. By default if a name has the signature of a composite function class MANTID_API_DLL FunctionGenerator : public IFunction { public: /// Constructor - FunctionGenerator(IFunction_sptr source); + FunctionGenerator(const IFunction_sptr &source); /// @name Overrides implementing composition of two functions: /// m_source and m_target. diff --git a/Framework/API/inc/MantidAPI/GridDomain1D.h b/Framework/API/inc/MantidAPI/GridDomain1D.h index b0d95f18ce8b087f510fbed4db259c7e56aec05e..2ba4ac5047bc3fa24565d5901653d0825a5367cb 100644 --- a/Framework/API/inc/MantidAPI/GridDomain1D.h +++ b/Framework/API/inc/MantidAPI/GridDomain1D.h @@ -26,7 +26,8 @@ namespace API { class MANTID_API_DLL GridDomain1D : public API::GridDomain { public: /// initialize - void initialize(double &startX, double &endX, size_t &n, std::string scaling); + void initialize(double &startX, double &endX, size_t &n, + const std::string &scaling); /// number of grid point s size_t size() const override { return m_points.size(); } /// number of dimensions in the grid diff --git a/Framework/API/inc/MantidAPI/GroupingLoader.h b/Framework/API/inc/MantidAPI/GroupingLoader.h index ed18239a7e16ec493a5f21a8cc88038e357a756f..622e9090e26362b8179ab297b5003c0189549d75 100644 --- a/Framework/API/inc/MantidAPI/GroupingLoader.h +++ b/Framework/API/inc/MantidAPI/GroupingLoader.h @@ -33,7 +33,7 @@ public: ~Grouping(); /// Construct a Grouping from a table - Grouping(ITableWorkspace_sptr table); + Grouping(const ITableWorkspace_sptr &table); /// Convert to grouping table ITableWorkspace_sptr toTable() const; diff --git a/Framework/API/inc/MantidAPI/IAlgorithm.h b/Framework/API/inc/MantidAPI/IAlgorithm.h index 1baf1b5e395b57243342ca5198d9016b25b31a02..9b22aeaa403a35904c47c304c99f68b1bad32d24 100644 --- a/Framework/API/inc/MantidAPI/IAlgorithm.h +++ b/Framework/API/inc/MantidAPI/IAlgorithm.h @@ -122,7 +122,7 @@ public: /// Check whether the algorithm is initialized properly virtual bool isInitialized() const = 0; - /// Check whether the algorithm has already been executed + /// Check whether the algorithm has been executed sucessfully virtual bool isExecuted() const = 0; /// Raises the cancel flag. interuption_point() method if called inside exec() diff --git a/Framework/API/inc/MantidAPI/IFunction.h b/Framework/API/inc/MantidAPI/IFunction.h index 36a5f4032921a76766630fb7aac3ef7c37d05b84..327f1c190a4de2328f89d4bf41d837e4fd3f50e4 100644 --- a/Framework/API/inc/MantidAPI/IFunction.h +++ b/Framework/API/inc/MantidAPI/IFunction.h @@ -24,6 +24,8 @@ #endif #include <string> +#include <utility> + #include <vector> #ifdef _WIN32 @@ -521,7 +523,8 @@ public: /// Calculate numerical derivatives void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian); /// Set the covariance matrix - void setCovarianceMatrix(boost::shared_ptr<Kernel::Matrix<double>> covar); + void + setCovarianceMatrix(const boost::shared_ptr<Kernel::Matrix<double>> &covar); /// Get the covariance matrix boost::shared_ptr<const Kernel::Matrix<double>> getCovarianceMatrix() const { return m_covar; @@ -562,11 +565,11 @@ protected: /// Convert a value from one unit (inUnit) to unit defined in workspace (ws) double convertValue(double value, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, + const boost::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const; void convertValue(std::vector<double> &values, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, + const boost::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const; /// Override to declare function attributes @@ -635,7 +638,7 @@ using IFunction_const_sptr = boost::shared_ptr<const IFunction>; class FunctionHandler { public: /// Constructor - FunctionHandler(IFunction_sptr fun) : m_fun(fun) {} + FunctionHandler(IFunction_sptr fun) : m_fun(std::move(fun)) {} /// Virtual destructor virtual ~FunctionHandler() = default; /// abstract init method. It is called after setting handler to the function diff --git a/Framework/API/inc/MantidAPI/ITableWorkspace.h b/Framework/API/inc/MantidAPI/ITableWorkspace.h index 9beba0fae1d344a39010a446daf16a8b1f8975b3..74a11149ce6c455800b18a3cf58bfdfab475b35d 100644 --- a/Framework/API/inc/MantidAPI/ITableWorkspace.h +++ b/Framework/API/inc/MantidAPI/ITableWorkspace.h @@ -22,6 +22,7 @@ #endif #include <sstream> +#include <utility> namespace Mantid { @@ -349,7 +350,7 @@ public: } } /// Construct directly from column - ColumnVector(Column_sptr column) : m_column(column) { + ColumnVector(Column_sptr column) : m_column(std::move(column)) { if (!m_column->isType<T>()) { std::stringstream mess; mess << "Type mismatch when creating a ColumnVector<" << typeid(T).name() @@ -387,7 +388,7 @@ public: } } /// Construct directly from column - ConstColumnVector(Column_const_sptr column) : m_column(column) { + ConstColumnVector(Column_const_sptr column) : m_column(std::move(column)) { if (!m_column->isType<T>()) { std::stringstream mess; mess << "Type mismatch when creating a ColumnVector<" << typeid(T).name() diff --git a/Framework/API/inc/MantidAPI/IndexProperty.h b/Framework/API/inc/MantidAPI/IndexProperty.h index 99918f926eb21c78322fefdefe505eaa2e32ea9b..f6261fe2e2397d073874d1e06a1e97971bee2deb 100644 --- a/Framework/API/inc/MantidAPI/IndexProperty.h +++ b/Framework/API/inc/MantidAPI/IndexProperty.h @@ -32,7 +32,7 @@ public: IndexProperty(const std::string &name, const IWorkspaceProperty &workspaceProp, const IndexTypeProperty &indexTypeProp, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); IndexProperty *clone() const override; diff --git a/Framework/API/inc/MantidAPI/JointDomain.h b/Framework/API/inc/MantidAPI/JointDomain.h index b027938aeae8f8b986652736685100b3af140d49..1fd5eb6b4ee714148c21989e09e79368b2650038 100644 --- a/Framework/API/inc/MantidAPI/JointDomain.h +++ b/Framework/API/inc/MantidAPI/JointDomain.h @@ -31,7 +31,7 @@ public: size_t getNParts() const override; /// Return i-th domain const FunctionDomain &getDomain(size_t i) const override; - void addDomain(FunctionDomain_sptr domain); + void addDomain(const FunctionDomain_sptr &domain); protected: /// Vector with member domains. diff --git a/Framework/API/inc/MantidAPI/MDGeometry.h b/Framework/API/inc/MantidAPI/MDGeometry.h index d46ecaf20003a11c9949743f713d0d9b2ce6cd48..d97cbfbe2feb2d04fc4469e99db7989ec835679d 100644 --- a/Framework/API/inc/MantidAPI/MDGeometry.h +++ b/Framework/API/inc/MantidAPI/MDGeometry.h @@ -64,7 +64,8 @@ public: std::string getGeometryXML() const; - void addDimension(boost::shared_ptr<Mantid::Geometry::IMDDimension> dim); + void + addDimension(const boost::shared_ptr<Mantid::Geometry::IMDDimension> &dim); void addDimension(Mantid::Geometry::IMDDimension *dim); // -------------------------------------------------------------------------------------------- diff --git a/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h b/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h index 8a68f6fa3d6d30c54bf5bebbeaf6b6dc9d70b087..e787848a1b6675d7b77e1e0f4230341089f1b385 100644 --- a/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h +++ b/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h @@ -52,7 +52,7 @@ private: /// Try ot add a workspace to the group of input workspaces. void tryAddInputWorkspaceToInputGroups( - Workspace_sptr ws, VecWSGroupType &vecMultiPeriodWorkspaceGroups, + const Workspace_sptr &ws, VecWSGroupType &vecMultiPeriodWorkspaceGroups, VecWSGroupType &vecWorkspaceGroups) const; /// Copy input workspace properties to spawned algorithm. diff --git a/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h b/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h index db9b5c2e68d088a70be46230d89ca4eb664a3675..58a11c8c6b0f89f339edfdc6db07d244ff9f3629 100644 --- a/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h +++ b/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h @@ -27,7 +27,7 @@ public: ExperimentInfo_const_sptr getExperimentInfo(const uint16_t runIndex) const; - uint16_t addExperimentInfo(ExperimentInfo_sptr ei); + uint16_t addExperimentInfo(const ExperimentInfo_sptr &ei); void setExperimentInfo(const uint16_t runIndex, ExperimentInfo_sptr ei); diff --git a/Framework/API/inc/MantidAPI/NotebookBuilder.h b/Framework/API/inc/MantidAPI/NotebookBuilder.h index fcd244028726bc032c2a2c5ee97a605f8de41717..5e620037130aaef9aaa1d11d1e62374883f57ebc 100644 --- a/Framework/API/inc/MantidAPI/NotebookBuilder.h +++ b/Framework/API/inc/MantidAPI/NotebookBuilder.h @@ -26,20 +26,21 @@ namespace API { class MANTID_API_DLL NotebookBuilder { public: - NotebookBuilder(boost::shared_ptr<HistoryView> view, + NotebookBuilder(const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity = "old"); virtual ~NotebookBuilder() = default; /// build an ipython notebook from the history view - const std::string build(std::string ws_name, std::string ws_title, - std::string ws_comment); + const std::string build(const std::string &ws_name, + const std::string &ws_title, + const std::string &ws_comment); private: void writeHistoryToStream(std::vector<HistoryItem>::const_iterator &iter); void buildChildren(std::vector<HistoryItem>::const_iterator &iter); const std::string - buildAlgorithmString(AlgorithmHistory_const_sptr algHistory); - const std::string - buildPropertyString(Mantid::Kernel::PropertyHistory_const_sptr propHistory); + buildAlgorithmString(const AlgorithmHistory_const_sptr &algHistory); + const std::string buildPropertyString( + const Mantid::Kernel::PropertyHistory_const_sptr &propHistory); const std::vector<HistoryItem> m_historyItems; std::string m_output; diff --git a/Framework/API/inc/MantidAPI/NotebookWriter.h b/Framework/API/inc/MantidAPI/NotebookWriter.h index 039b58c2af15b15a505d03d01116b6b4e1bb483d..d9d914f17e230284a77b67f52a1d7cbf2445d598 100644 --- a/Framework/API/inc/MantidAPI/NotebookWriter.h +++ b/Framework/API/inc/MantidAPI/NotebookWriter.h @@ -24,8 +24,8 @@ class MANTID_API_DLL NotebookWriter { public: NotebookWriter(); virtual ~NotebookWriter() = default; - std::string markdownCell(std::string string_text); - std::string codeCell(std::string string_code); + std::string markdownCell(const std::string &string_text); + std::string codeCell(const std::string &string_code); std::string writeNotebook(); private: diff --git a/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h b/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h index 30a18555469505addb870aab9797395828b6dc5a..5646d0da63e9e3347c68f2594f504319bbf5c9da 100644 --- a/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h +++ b/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h @@ -47,8 +47,8 @@ public: /// alternative (lower level) create where the specific type of /// manager and base URL are directly given - IRemoteJobManager_sptr create(const std::string baseURL, - const std::string jobManagerType) const; + IRemoteJobManager_sptr create(const std::string &baseURL, + const std::string &jobManagerType) const; private: /// So that the singleton can be created (cons/destructor are private) diff --git a/Framework/API/inc/MantidAPI/Sample.h b/Framework/API/inc/MantidAPI/Sample.h index 5004a47d8e0113b9576d3e8f1797c65dd66e2cf7..dc70c2391fa669bfebce66789eef89b700e5092b 100644 --- a/Framework/API/inc/MantidAPI/Sample.h +++ b/Framework/API/inc/MantidAPI/Sample.h @@ -45,7 +45,7 @@ public: /// the number of samples std::size_t size() const; /// Adds a sample to the list - void addSample(boost::shared_ptr<Sample> childSample); + void addSample(const boost::shared_ptr<Sample> &childSample); /// Returns the name of the sample const std::string &getName() const; diff --git a/Framework/API/inc/MantidAPI/ScopedWorkspace.h b/Framework/API/inc/MantidAPI/ScopedWorkspace.h index e8e513de799d7dc4cafcf8dfe9ad4c4dd4b5b14b..00ddb510e2beb391d963c5e1405f7c180a19ba15 100644 --- a/Framework/API/inc/MantidAPI/ScopedWorkspace.h +++ b/Framework/API/inc/MantidAPI/ScopedWorkspace.h @@ -37,7 +37,7 @@ public: ScopedWorkspace(); /// Workspace constructor - ScopedWorkspace(Workspace_sptr ws); + ScopedWorkspace(const Workspace_sptr &ws); /// Destructor virtual ~ScopedWorkspace(); @@ -61,7 +61,7 @@ public: operator bool() const; /// Make ADS entry to point to the given workspace - void set(Workspace_sptr newWS); + void set(const Workspace_sptr &newWS); private: /// ADS name of the workspace diff --git a/Framework/API/inc/MantidAPI/ScriptBuilder.h b/Framework/API/inc/MantidAPI/ScriptBuilder.h index e852d99d7dac3fb5f7007fd7ea79dfdf7e24f29d..eba2f95a206f56e822ab8a9f2b44fa8c17a47cbe 100644 --- a/Framework/API/inc/MantidAPI/ScriptBuilder.h +++ b/Framework/API/inc/MantidAPI/ScriptBuilder.h @@ -31,7 +31,7 @@ namespace API { class MANTID_API_DLL ScriptBuilder { public: ScriptBuilder( - boost::shared_ptr<HistoryView> view, + const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity = "old", bool appendTimestamp = false, std::vector<std::string> ignoreTheseAlgs = {}, std::vector<std::vector<std::string>> ignoreTheseAlgProperties = {}, diff --git a/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h b/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h index 2f2b218194e8b23d700802bbb083d20f75a15c55..08885eb4bc9ea62cf770966d60717cf0a2abdff3 100644 --- a/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h +++ b/Framework/API/inc/MantidAPI/SpectrumDetectorMapping.h @@ -31,7 +31,7 @@ class MANTID_API_DLL SpectrumDetectorMapping { using sdmap = std::unordered_map<specnum_t, std::set<detid_t>>; public: - explicit SpectrumDetectorMapping(MatrixWorkspace_const_sptr workspace, + explicit SpectrumDetectorMapping(const MatrixWorkspace_const_sptr &workspace, const bool useSpecNoIndex = true); SpectrumDetectorMapping( const std::vector<specnum_t> &spectrumNumbers, diff --git a/Framework/API/inc/MantidAPI/WorkspaceHistory.h b/Framework/API/inc/MantidAPI/WorkspaceHistory.h index cc7097afbf995655e3894e46f834ecffa09e31c2..153651206cce5e7707e6db53a5578dd0ec6f6001 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceHistory.h +++ b/Framework/API/inc/MantidAPI/WorkspaceHistory.h @@ -79,9 +79,9 @@ public: private: /// Recursive function to load the algorithm history tree from file - void loadNestedHistory( - ::NeXus::File *file, - AlgorithmHistory_sptr parent = boost::shared_ptr<AlgorithmHistory>()); + void loadNestedHistory(::NeXus::File *file, + const AlgorithmHistory_sptr &parent = + boost::shared_ptr<AlgorithmHistory>()); /// Parse an algorithm history string loaded from file AlgorithmHistory_sptr parseAlgorithmHistory(const std::string &rawData); /// Find the history entries at this level in the file. diff --git a/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h b/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h index 06eaa10debe52e82f781ef5dc39f76e7b8d90c64..f40c7b19dbea0f2c6a3030caa43a5c787b00dc76 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h +++ b/Framework/API/inc/MantidAPI/WorkspaceOpOverloads.h @@ -22,51 +22,51 @@ DLLExport ResultType executeBinaryOperation( bool rethrow = false); } // namespace OperatorOverloads -bool MANTID_API_DLL equals(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs, +bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs, double tolerance = 0.0); // Workspace operator overloads -MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs, const double &rhsValue); MatrixWorkspace_sptr MANTID_API_DLL operator-(const double &lhsValue, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs, const double &rhsValue); MatrixWorkspace_sptr MANTID_API_DLL operator*(const double &lhsValue, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs, const double &rhsValue); MatrixWorkspace_sptr MANTID_API_DLL operator/(const double &lhsValue, - const MatrixWorkspace_sptr rhs); + const MatrixWorkspace_sptr &rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); +MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs); -MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); -MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, const double &rhsValue); /** A collection of static functions for use with workspaces @@ -83,7 +83,7 @@ struct MANTID_API_DLL WorkspaceHelpers { static bool sharedXData(const MatrixWorkspace &WS); // Divides the data in a workspace by the bin width to make it a distribution // (or the reverse) - static void makeDistribution(MatrixWorkspace_sptr workspace, + static void makeDistribution(const MatrixWorkspace_sptr &workspace, const bool forwards = true); }; diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.h b/Framework/API/inc/MantidAPI/WorkspaceProperty.h index 487b29032f5ce1506243b7834842eaeab9a76ed1..0b0a32d2c3b0fc09ee3365e5b98d8b261ac5b63c 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceProperty.h +++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.h @@ -59,20 +59,20 @@ public: explicit WorkspaceProperty( const std::string &name, const std::string &wsName, const unsigned int direction, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); explicit WorkspaceProperty( const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); explicit WorkspaceProperty( const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, const LockMode::Type locking, - Kernel::IValidator_sptr validator = + const Kernel::IValidator_sptr &validator = Kernel::IValidator_sptr(new Kernel::NullValidator)); WorkspaceProperty(const WorkspaceProperty &right); @@ -118,7 +118,8 @@ public: void setIsMasterRank(bool isMasterRank) override; private: - std::string isValidGroup(boost::shared_ptr<WorkspaceGroup> wsGroup) const; + std::string + isValidGroup(const boost::shared_ptr<WorkspaceGroup> &wsGroup) const; std::string isValidOutputWs() const; diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc index b60627596e43036bb11b3859cb5d5e2f1d964a92..6908bc7a6c25efeac00301d96c1a643f119d7b95 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc +++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc @@ -29,10 +29,9 @@ namespace API { * Direction enum (i.e. 0-2) */ template <typename TYPE> -WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, - const std::string &wsName, - const unsigned int direction, - Kernel::IValidator_sptr validator) +WorkspaceProperty<TYPE>::WorkspaceProperty( + const std::string &name, const std::string &wsName, + const unsigned int direction, const Kernel::IValidator_sptr &validator) : Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>( name, boost::shared_ptr<TYPE>(), validator, direction), m_workspaceName(wsName), m_initialWSName(wsName), @@ -51,11 +50,10 @@ WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, * Direction enum (i.e. 0-2) */ template <typename TYPE> -WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, - const std::string &wsName, - const unsigned int direction, - const PropertyMode::Type optional, - Kernel::IValidator_sptr validator) +WorkspaceProperty<TYPE>::WorkspaceProperty( + const std::string &name, const std::string &wsName, + const unsigned int direction, const PropertyMode::Type optional, + const Kernel::IValidator_sptr &validator) : Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>( name, boost::shared_ptr<TYPE>(), validator, direction), m_workspaceName(wsName), m_initialWSName(wsName), m_optional(optional), @@ -78,12 +76,10 @@ WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, * Direction enum (i.e. 0-2) */ template <typename TYPE> -WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name, - const std::string &wsName, - const unsigned int direction, - const PropertyMode::Type optional, - const LockMode::Type locking, - Kernel::IValidator_sptr validator) +WorkspaceProperty<TYPE>::WorkspaceProperty( + const std::string &name, const std::string &wsName, + const unsigned int direction, const PropertyMode::Type optional, + const LockMode::Type locking, const Kernel::IValidator_sptr &validator) : Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>( name, boost::shared_ptr<TYPE>(), validator, direction), m_workspaceName(wsName), m_initialWSName(wsName), m_optional(optional), @@ -410,7 +406,7 @@ void WorkspaceProperty<TYPE>::setIsMasterRank(bool isMasterRank) { */ template <typename TYPE> std::string WorkspaceProperty<TYPE>::isValidGroup( - boost::shared_ptr<WorkspaceGroup> wsGroup) const { + const boost::shared_ptr<WorkspaceGroup> &wsGroup) const { g_log.debug() << " Input WorkspaceGroup found \n"; std::vector<std::string> wsGroupNames = wsGroup->getNames(); diff --git a/Framework/API/src/Algorithm.cpp b/Framework/API/src/Algorithm.cpp index 3420f7b7aff1e89c7478cedee108827c4cf2eb76..f76b90be2ee3db4a413cd4a91257dceb6ddbc174 100644 --- a/Framework/API/src/Algorithm.cpp +++ b/Framework/API/src/Algorithm.cpp @@ -39,6 +39,7 @@ #include <json/json.h> #include <map> +#include <utility> // Index property handling template definitions #include "MantidAPI/Algorithm.tcc" @@ -141,7 +142,7 @@ bool Algorithm::isInitialized() const { return (m_executionState != ExecutionState::Uninitialized); } -/// Has the Algorithm already been executed +/// Has the Algorithm already been executed successfully bool Algorithm::isExecuted() const { return ((executionState() == ExecutionState::Finished) && (resultState() == ResultState::Success)); @@ -845,7 +846,7 @@ Algorithm_sptr Algorithm::createChildAlgorithm(const std::string &name, * Can also be used manually for algorithms created otherwise. This allows * running algorithms that are not declared into the factory as child * algorithms. */ -void Algorithm::setupAsChildAlgorithm(Algorithm_sptr alg, +void Algorithm::setupAsChildAlgorithm(const Algorithm_sptr &alg, const double startProgress, const double endProgress, const bool enableLogging) { @@ -1077,7 +1078,7 @@ void Algorithm::linkHistoryWithLastChild() { void Algorithm::trackAlgorithmHistory( boost::shared_ptr<AlgorithmHistory> parentHist) { enableHistoryRecordingForChild(true); - m_parentHistory = parentHist; + m_parentHistory = std::move(parentHist); } /** Check if we are tracking history for this algorithm @@ -1569,6 +1570,7 @@ void Algorithm::copyNonWorkspaceProperties(IAlgorithm *alg, int periodNum) { const auto &props = this->getProperties(); for (const auto &prop : props) { if (prop) { + auto *wsProp = dynamic_cast<IWorkspaceProperty *>(prop); // Copy the property using the string if (!wsProp) diff --git a/Framework/API/src/AlgorithmFactory.cpp b/Framework/API/src/AlgorithmFactory.cpp index 778a83eba0638eec7e82ff942bf92496be4786b7..5379a1b6dfc67d9d11645d3c62e50c4671647dea 100644 --- a/Framework/API/src/AlgorithmFactory.cpp +++ b/Framework/API/src/AlgorithmFactory.cpp @@ -406,7 +406,7 @@ void AlgorithmFactoryImpl::fillHiddenCategories( * @returns the name of the algroithm */ const std::string AlgorithmFactoryImpl::extractAlgName( - const boost::shared_ptr<IAlgorithm> alg) const { + const boost::shared_ptr<IAlgorithm> &alg) const { return alg->name(); } @@ -415,7 +415,7 @@ const std::string AlgorithmFactoryImpl::extractAlgName( * @returns the version of the algroithm */ int AlgorithmFactoryImpl::extractAlgVersion( - const boost::shared_ptr<IAlgorithm> alg) const { + const boost::shared_ptr<IAlgorithm> &alg) const { return alg->version(); } diff --git a/Framework/API/src/AlgorithmHistory.cpp b/Framework/API/src/AlgorithmHistory.cpp index 388b498f0303fd410f4c47867a1a13479214d1da..fd4208da5e549e1061a3d2c1a56aaf42c63ebaaa 100644 --- a/Framework/API/src/AlgorithmHistory.cpp +++ b/Framework/API/src/AlgorithmHistory.cpp @@ -21,6 +21,7 @@ #include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_io.hpp> #include <sstream> +#include <utility> namespace Mantid { namespace API { @@ -85,7 +86,7 @@ AlgorithmHistory::AlgorithmHistory(const std::string &name, int vers, std::size_t uexeccount) : m_name(name), m_version(vers), m_executionDate(start), m_executionDuration(duration), m_execCount(uexeccount), - m_childHistories(), m_uuid(uuid) {} + m_childHistories(), m_uuid(std::move(uuid)) {} /** * Set the history properties for an algorithm pointer @@ -162,7 +163,7 @@ void AlgorithmHistory::addProperty(const std::string &name, /** Add a child algorithm history to history * @param childHist :: The child history */ -void AlgorithmHistory::addChildHistory(AlgorithmHistory_sptr childHist) { +void AlgorithmHistory::addChildHistory(const AlgorithmHistory_sptr &childHist) { // Don't copy one's own history onto oneself if (this == &(*childHist)) { return; diff --git a/Framework/API/src/AlgorithmManager.cpp b/Framework/API/src/AlgorithmManager.cpp index 8c2d63386975bc5e2e61b6aef3193ebec355d305..2d657d81c4ffd3abba445d1597ce12ae57755968 100644 --- a/Framework/API/src/AlgorithmManager.cpp +++ b/Framework/API/src/AlgorithmManager.cpp @@ -22,15 +22,6 @@ Kernel::Logger g_log("AlgorithmManager"); /// Private Constructor for singleton class AlgorithmManagerImpl::AlgorithmManagerImpl() : m_managed_algs() { - auto max_no_algs = - Kernel::ConfigService::Instance().getValue<int>("algorithms.retained"); - - m_max_no_algs = max_no_algs.get_value_or(0); - - if (m_max_no_algs < 1) { - m_max_no_algs = 100; // Default to keeping 100 algorithms if not specified - } - g_log.debug() << "Algorithm Manager created.\n"; } @@ -82,39 +73,15 @@ IAlgorithm_sptr AlgorithmManagerImpl::create(const std::string &algName, else alg = unmanagedAlg; - // If this takes us beyond the maximum size, then remove the oldest one(s) - while (m_managed_algs.size() >= - static_cast<std::deque<IAlgorithm_sptr>::size_type>(m_max_no_algs)) { - std::deque<IAlgorithm_sptr>::iterator it; - it = m_managed_algs.begin(); - - // Look for the first (oldest) algo that is NOT running right now. - while (it != m_managed_algs.end()) { - if (!(*it)->isRunning()) - break; - ++it; - } - - if (it == m_managed_algs.end()) { - // Unusual case where ALL algorithms are running - g_log.warning() - << "All algorithms in the AlgorithmManager are running. " - << "Cannot pop oldest algorithm. " - << "You should increase your 'algorithms.retained' value. " - << m_managed_algs.size() << " in queue.\n"; - break; - } else { - // Normal; erase that algorithm - g_log.debug() << "Popping out oldest algorithm " << (*it)->name() - << '\n'; - m_managed_algs.erase(it); - } - } + auto count = removeFinishedAlgorithms(); + g_log.debug() + << count + << " Finished algorithms removed from the managed algorithms list. " + << m_managed_algs.size() << " remaining.\n"; // Add to list of managed ones m_managed_algs.emplace_back(alg); alg->initialize(); - } catch (std::runtime_error &ex) { g_log.error() << "AlgorithmManager:: Unable to create algorithm " << algName << ' ' << ex.what() << '\n'; @@ -140,19 +107,6 @@ void AlgorithmManagerImpl::clear() { std::size_t AlgorithmManagerImpl::size() const { return m_managed_algs.size(); } -/** - * Set new maximum number of algorithms that can be stored. - * - * @param n :: The new maximum. - */ -void AlgorithmManagerImpl::setMaxAlgorithms(int n) { - if (n < 0) { - throw std::runtime_error("Maximum number of algorithms stored in " - "AlgorithmManager cannot be negative."); - } - m_max_no_algs = n; -} - /** * Returns a shared pointer by algorithm id * @param id :: The ID of the algorithm @@ -241,6 +195,28 @@ void AlgorithmManagerImpl::cancelAll() { } } +/// Removes all of the finished algorithms +/// this does not lock the mutex as the locking is already assumed to be in +/// place +size_t AlgorithmManagerImpl::removeFinishedAlgorithms() { + std::vector<IAlgorithm_const_sptr> theCompletedInstances; + std::copy_if( + m_managed_algs.cbegin(), m_managed_algs.cend(), + std::back_inserter(theCompletedInstances), [](const auto &algorithm) { + return (algorithm->executionState() == ExecutionState::Finished); + }); + for (auto completedAlg : theCompletedInstances) { + auto itend = m_managed_algs.end(); + for (auto it = m_managed_algs.begin(); it != itend; ++it) { + if ((**it).getAlgorithmID() == completedAlg->getAlgorithmID()) { + m_managed_algs.erase(it); + break; + } + } + } + return theCompletedInstances.size(); +} + void AlgorithmManagerImpl::shutdown() { clear(); } } // namespace API } // namespace Mantid diff --git a/Framework/API/src/AlgorithmObserver.cpp b/Framework/API/src/AlgorithmObserver.cpp index d8bd534c9201ac7aaed0004700d8bff284245144..5fb257a1a9a2b8f1353d60106fc7bceb95b87d29 100644 --- a/Framework/API/src/AlgorithmObserver.cpp +++ b/Framework/API/src/AlgorithmObserver.cpp @@ -7,8 +7,10 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidAPI/AlgorithmObserver.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AlgorithmObserver.h" namespace Mantid { namespace API { @@ -26,13 +28,13 @@ AlgorithmObserver::AlgorithmObserver() alg. @param alg :: Algorithm to be observed */ -AlgorithmObserver::AlgorithmObserver(IAlgorithm_const_sptr alg) +AlgorithmObserver::AlgorithmObserver(const IAlgorithm_const_sptr &alg) : m_progressObserver(*this, &AlgorithmObserver::_progressHandle), m_startObserver(*this, &AlgorithmObserver::_startHandle), m_finishObserver(*this, &AlgorithmObserver::_finishHandle), m_errorObserver(*this, &AlgorithmObserver::_errorHandle), m_startingObserver(*this, &AlgorithmObserver::_startingHandle) { - observeAll(alg); + observeAll(std::move(alg)); } /// Virtual destructor @@ -41,7 +43,7 @@ AlgorithmObserver::~AlgorithmObserver() = default; /** Connect to algorithm alg and observe all its notifications @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeAll(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeAll(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_progressObserver); alg->addObserver(m_startObserver); alg->addObserver(m_finishObserver); @@ -51,7 +53,7 @@ void AlgorithmObserver::observeAll(IAlgorithm_const_sptr alg) { /** Connect to algorithm alg and observe its progress notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeProgress(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeProgress(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_progressObserver); } @@ -65,21 +67,21 @@ void AlgorithmObserver::observeStarting() { /** Connect to algorithm alg and observe its start notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeStart(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeStart(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_startObserver); } /** Connect to algorithm alg and observe its finish notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeFinish(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeFinish(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_finishObserver); } /** Connect to algorithm alg and observe its error notification @param alg :: Algorithm to be observed */ -void AlgorithmObserver::observeError(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::observeError(const IAlgorithm_const_sptr &alg) { alg->addObserver(m_errorObserver); } @@ -87,7 +89,7 @@ void AlgorithmObserver::observeError(IAlgorithm_const_sptr alg) { inherited classes. @param alg :: Algorithm to be disconnected */ -void AlgorithmObserver::stopObserving(IAlgorithm_const_sptr alg) { +void AlgorithmObserver::stopObserving(const IAlgorithm_const_sptr &alg) { this->stopObserving(alg.get()); } diff --git a/Framework/API/src/AlgorithmProperty.cpp b/Framework/API/src/AlgorithmProperty.cpp index 31e3f471c899de26e11693896114b67c054314a7..512ae7a5bfef738a0f1db92e7eadb45b6a6d4af9 100644 --- a/Framework/API/src/AlgorithmProperty.cpp +++ b/Framework/API/src/AlgorithmProperty.cpp @@ -12,6 +12,8 @@ #include <json/value.h> +#include <utility> + namespace Mantid { namespace API { @@ -29,8 +31,8 @@ namespace API { AlgorithmProperty::AlgorithmProperty(const std::string &propName, Kernel::IValidator_sptr validator, unsigned int direction) - : Kernel::PropertyWithValue<HeldType>(propName, HeldType(), validator, - direction), + : Kernel::PropertyWithValue<HeldType>(propName, HeldType(), + std::move(validator), direction), m_algmStr() {} /** diff --git a/Framework/API/src/AlgorithmProxy.cpp b/Framework/API/src/AlgorithmProxy.cpp index 4730a275f43568c6ad7720db257256b3f65801f8..876a9b51d1b1b2504dd0b0551f8f9870860d3b5c 100644 --- a/Framework/API/src/AlgorithmProxy.cpp +++ b/Framework/API/src/AlgorithmProxy.cpp @@ -21,7 +21,7 @@ namespace Mantid { namespace API { /// Constructor -AlgorithmProxy::AlgorithmProxy(Algorithm_sptr alg) +AlgorithmProxy::AlgorithmProxy(const Algorithm_sptr &alg) : PropertyManagerOwner(), m_executeAsync(new Poco::ActiveMethod<bool, Poco::Void, AlgorithmProxy>( this, &AlgorithmProxy::executeAsyncImpl)), diff --git a/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp b/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp index 109e56d0a3a75da9bd287dea64304784c222b0ac..ca6898c604e185cb9f9b3252aec7145f25743c84 100644 --- a/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp +++ b/Framework/API/src/BoostOptionalToAlgorithmProperty.cpp @@ -10,8 +10,9 @@ namespace Mantid { namespace API { template <> std::string checkForMandatoryInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getStringParameter(idf_name); @@ -28,8 +29,9 @@ std::string checkForMandatoryInstrumentDefault( template <> boost::optional<std::string> checkForOptionalInstrumentDefault( - Mantid::API::Algorithm *const alg, std::string propName, - Mantid::Geometry::Instrument_const_sptr instrument, std::string idf_name) { + Mantid::API::Algorithm *const alg, const std::string &propName, + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string &idf_name) { auto algProperty = alg->getPointerToProperty(propName); if (algProperty->isDefault()) { auto defaults = instrument->getStringParameter(idf_name); diff --git a/Framework/API/src/BoxController.cpp b/Framework/API/src/BoxController.cpp index 16e8a31e11b9c626a89a522f12215322038c217c..1590696cb4cac060808f12cca60badaec360afb4 100644 --- a/Framework/API/src/BoxController.cpp +++ b/Framework/API/src/BoxController.cpp @@ -296,8 +296,9 @@ void BoxController::clearFileBacked() { *@param fileName -- if newFileIO comes without opened file, this is the file *name to open for the file based IO operations */ -void BoxController::setFileBacked(boost::shared_ptr<IBoxControllerIO> newFileIO, - const std::string &fileName) { +void BoxController::setFileBacked( + const boost::shared_ptr<IBoxControllerIO> &newFileIO, + const std::string &fileName) { if (!newFileIO->isOpened()) newFileIO->openFile(fileName, "w"); diff --git a/Framework/API/src/CatalogManager.cpp b/Framework/API/src/CatalogManager.cpp index 9dd38cd2f511a10bf38fe7cbed39b2df8417e68f..e5dd10da271aa856cf809573765d4cd6923235c0 100644 --- a/Framework/API/src/CatalogManager.cpp +++ b/Framework/API/src/CatalogManager.cpp @@ -7,6 +7,7 @@ #include "MantidAPI/CatalogManager.h" #include "MantidAPI/CatalogFactory.h" #include "MantidAPI/CompositeCatalog.h" +#include "MantidAPI/FunctionFactory.h" #include "MantidKernel/ConfigService.h" #include "MantidKernel/FacilityInfo.h" @@ -105,9 +106,10 @@ void CatalogManagerImpl::destroyCatalog(const std::string &sessionID) { std::vector<CatalogSession_sptr> CatalogManagerImpl::getActiveSessions() { std::vector<CatalogSession_sptr> sessions; sessions.reserve(m_activeCatalogs.size()); - for (const auto &activeCatalog : m_activeCatalogs) { - sessions.emplace_back(activeCatalog.first); - } + + std::transform(m_activeCatalogs.begin(), m_activeCatalogs.end(), + std::back_inserter(sessions), + [](const auto &activeCatalog) { return activeCatalog.first; }); return sessions; } diff --git a/Framework/API/src/CompositeCatalog.cpp b/Framework/API/src/CompositeCatalog.cpp index d6e50e3b97d59f19146487aa80c2b9c013bb6025..f838b719ca0c8c51905710f78fba0bcebee01ce4 100644 --- a/Framework/API/src/CompositeCatalog.cpp +++ b/Framework/API/src/CompositeCatalog.cpp @@ -16,7 +16,7 @@ CompositeCatalog::CompositeCatalog() : m_catalogs() {} * Add a catalog to the catalog container. * @param catalog :: The catalog to add to the container. */ -void CompositeCatalog::add(const ICatalog_sptr catalog) { +void CompositeCatalog::add(const ICatalog_sptr &catalog) { m_catalogs.emplace_back(catalog); } diff --git a/Framework/API/src/CompositeDomainMD.cpp b/Framework/API/src/CompositeDomainMD.cpp index 1a549852bc55e99aae1b385f5ab8168d5938b464..6762e9be597c90814b65cba3a8147223193a11fa 100644 --- a/Framework/API/src/CompositeDomainMD.cpp +++ b/Framework/API/src/CompositeDomainMD.cpp @@ -21,11 +21,18 @@ namespace API { * @param ws :: Pointer to a workspace. * @param maxDomainSize :: The maximum size each domain can have. */ -CompositeDomainMD::CompositeDomainMD(IMDWorkspace_const_sptr ws, +CompositeDomainMD::CompositeDomainMD(const IMDWorkspace_const_sptr &ws, size_t maxDomainSize) : m_iterator(ws->createIterator()) { m_totalSize = m_iterator->getDataSize(); - size_t nParts = m_totalSize / maxDomainSize + 1; + + size_t maxDomainSizeDiv = maxDomainSize + 1; + if (maxDomainSizeDiv == 0) { + throw std::runtime_error( + "Attempted to use a maximum domain size that equals 0"); + } + size_t nParts = m_totalSize / maxDomainSizeDiv; + m_domains.resize(nParts); for (size_t i = 0; i < nParts - 1; ++i) { size_t start = i * maxDomainSize; diff --git a/Framework/API/src/CompositeFunction.cpp b/Framework/API/src/CompositeFunction.cpp index ec17675164b006a70fbba23ad0879387cdbb19cf..39c4976ea00adaa57409e58eb98048ca756b2474 100644 --- a/Framework/API/src/CompositeFunction.cpp +++ b/Framework/API/src/CompositeFunction.cpp @@ -19,6 +19,7 @@ #include <boost/lexical_cast.hpp> #include <boost/shared_array.hpp> #include <sstream> +#include <utility> namespace Mantid { namespace API { @@ -468,21 +469,21 @@ void CompositeFunction::removeFunction(size_t i) { * a member of this composite function nothing happens * @param f_new :: A pointer to the new function */ -void CompositeFunction::replaceFunctionPtr(const IFunction_sptr f_old, - IFunction_sptr f_new) { +void CompositeFunction::replaceFunctionPtr(const IFunction_sptr &f_old, + const IFunction_sptr &f_new) { std::vector<IFunction_sptr>::const_iterator it = std::find(m_functions.begin(), m_functions.end(), f_old); if (it == m_functions.end()) return; std::vector<IFunction_sptr>::difference_type iFun = it - m_functions.begin(); - replaceFunction(iFun, f_new); + replaceFunction(iFun, std::move(f_new)); } /** Replace a function with a new one. The old function is deleted. * @param i :: The index of the function to replace * @param f :: A pointer to the new function */ -void CompositeFunction::replaceFunction(size_t i, IFunction_sptr f) { +void CompositeFunction::replaceFunction(size_t i, const IFunction_sptr &f) { if (i >= nFunctions()) { throw std::out_of_range("Function index (" + std::to_string(i) + ") out of range (" + std::to_string(nFunctions()) + diff --git a/Framework/API/src/DataProcessorAlgorithm.cpp b/Framework/API/src/DataProcessorAlgorithm.cpp index 4f82c06e981672c2229587c83695dd2847d28c95..ebd21763b9c7e1e444324b5317e4aff75978a652 100644 --- a/Framework/API/src/DataProcessorAlgorithm.cpp +++ b/Framework/API/src/DataProcessorAlgorithm.cpp @@ -19,6 +19,8 @@ #include "MantidKernel/System.h" #include "Poco/Path.h" #include <stdexcept> +#include <utility> + #ifdef MPI_BUILD #include <boost/mpi.hpp> #endif @@ -135,7 +137,7 @@ void GenericDataProcessorAlgorithm<Base>::mapPropertyName( */ template <class Base> void GenericDataProcessorAlgorithm<Base>::copyProperty( - API::Algorithm_sptr alg, const std::string &name) { + const API::Algorithm_sptr &alg, const std::string &name) { if (!alg->existsProperty(name)) { std::stringstream msg; msg << "Algorithm \"" << alg->name() << "\" does not have property \"" @@ -232,7 +234,7 @@ GenericDataProcessorAlgorithm<Base>::loadChunk(const size_t rowIndex) { template <class Base> Workspace_sptr GenericDataProcessorAlgorithm<Base>::assemble(Workspace_sptr partialWS) { - Workspace_sptr outputWS = partialWS; + Workspace_sptr outputWS = std::move(partialWS); #ifdef MPI_BUILD IAlgorithm_sptr gatherAlg = createChildAlgorithm("GatherWorkspaces"); gatherAlg->setLogging(true); diff --git a/Framework/API/src/DetectorSearcher.cpp b/Framework/API/src/DetectorSearcher.cpp index a183c4841f6145d61a5b2a1180e377a94dc421d2..cd25bce0e98fc5cc3caa06aef7d12a31c0394379 100644 --- a/Framework/API/src/DetectorSearcher.cpp +++ b/Framework/API/src/DetectorSearcher.cpp @@ -30,8 +30,9 @@ double getQSign() { * @param instrument :: the instrument to find detectors in * @param detInfo :: the Geometry::DetectorInfo object for this instrument */ -DetectorSearcher::DetectorSearcher(Geometry::Instrument_const_sptr instrument, - const Geometry::DetectorInfo &detInfo) +DetectorSearcher::DetectorSearcher( + const Geometry::Instrument_const_sptr &instrument, + const Geometry::DetectorInfo &detInfo) : m_usingFullRayTrace(instrument->containsRectDetectors() == Geometry::Instrument::ContainsState::Full), m_crystallography_convention(getQSign()), m_detInfo(detInfo), diff --git a/Framework/API/src/ExperimentInfo.cpp b/Framework/API/src/ExperimentInfo.cpp index 8b351649ca603cf0a2884e49ea63e6db640898cc..5310526a330bf1496b4808dd2d838595f0fa5f2b 100644 --- a/Framework/API/src/ExperimentInfo.cpp +++ b/Framework/API/src/ExperimentInfo.cpp @@ -711,7 +711,7 @@ double ExperimentInfo::getEFixed(const detid_t detID) const { * @return The current efixed value */ double ExperimentInfo::getEFixed( - const boost::shared_ptr<const Geometry::IDetector> detector) const { + const boost::shared_ptr<const Geometry::IDetector> &detector) const { populateIfNotLoaded(); Kernel::DeltaEMode::Type emode = getEMode(); if (emode == Kernel::DeltaEMode::Direct) { @@ -944,8 +944,10 @@ std::vector<std::string> ExperimentInfo::getResourceFilenames( std::vector<std::string> pathNames; if (!matchingFiles.empty()) { pathNames.reserve(matchingFiles.size()); - for (auto &elem : matchingFiles) - pathNames.emplace_back(std::move(elem.second)); + + std::transform(matchingFiles.begin(), matchingFiles.end(), + std::back_inserter(pathNames), + [](const auto &elem) { return elem.second; }); } else { pathNames.emplace_back(std::move(mostRecentFile)); } diff --git a/Framework/API/src/Expression.cpp b/Framework/API/src/Expression.cpp index 67df10cc2af04decf18d62663aed50dd0abcf56e..5308ca5283ba369cc646dd73151157d8c03bec93 100644 --- a/Framework/API/src/Expression.cpp +++ b/Framework/API/src/Expression.cpp @@ -117,8 +117,8 @@ Expression &Expression::operator=(const Expression &expr) { m_funct = expr.m_funct; m_op = expr.m_op; m_terms = expr.m_terms; - // m_expr = expr.m_expr; - // m_tokens = expr.m_tokens; + m_expr = expr.m_expr; + m_tokens = expr.m_tokens; return *this; } diff --git a/Framework/API/src/FunctionDomainGeneral.cpp b/Framework/API/src/FunctionDomainGeneral.cpp index 6be66bafb29538278b7edcbd50bc541c1b84c97d..7000ed1580f542480c395fbc9dd9c65dfdd5b42a 100644 --- a/Framework/API/src/FunctionDomainGeneral.cpp +++ b/Framework/API/src/FunctionDomainGeneral.cpp @@ -22,7 +22,7 @@ size_t FunctionDomainGeneral::size() const { size_t FunctionDomainGeneral::columnCount() const { return m_columns.size(); } /// Add a new column. All columns must have the same size. -void FunctionDomainGeneral::addColumn(boost::shared_ptr<Column> column) { +void FunctionDomainGeneral::addColumn(const boost::shared_ptr<Column> &column) { if (!column) { throw std::runtime_error( "Cannot add null column to FunctionDomainGeneral."); diff --git a/Framework/API/src/FunctionDomainMD.cpp b/Framework/API/src/FunctionDomainMD.cpp index 4dab31a2fae950f503b4be0c25e205b9831ef5c3..51cf298b927935a356f514a04d026627daa0e297 100644 --- a/Framework/API/src/FunctionDomainMD.cpp +++ b/Framework/API/src/FunctionDomainMD.cpp @@ -21,8 +21,8 @@ namespace API { * @param start :: Index of the first iterator in this domain. * @param length :: Size of this domain. If 0 use all workspace. */ -FunctionDomainMD::FunctionDomainMD(IMDWorkspace_const_sptr ws, size_t start, - size_t length) +FunctionDomainMD::FunctionDomainMD(const IMDWorkspace_const_sptr &ws, + size_t start, size_t length) : m_iterator(ws->createIterator()), m_startIndex(start), m_currentIndex(0), m_justReset(true), m_workspace(ws) { size_t dataSize = m_iterator->getDataSize(); diff --git a/Framework/API/src/FunctionFactory.cpp b/Framework/API/src/FunctionFactory.cpp index 79936f3668d00fe95f26eb3b4d28cd55201a410d..9ada8ccf36c5515052cacfa808779f896a212dad 100644 --- a/Framework/API/src/FunctionFactory.cpp +++ b/Framework/API/src/FunctionFactory.cpp @@ -271,7 +271,7 @@ void FunctionFactoryImpl::inputError(const std::string &str) const { * separated by commas ',' * and enclosed in brackets "(...)" . */ -void FunctionFactoryImpl::addConstraints(IFunction_sptr fun, +void FunctionFactoryImpl::addConstraints(const IFunction_sptr &fun, const Expression &expr) const { if (expr.name() == ",") { for (auto it = expr.begin(); it != expr.end(); ++it) { @@ -305,7 +305,7 @@ void FunctionFactoryImpl::addConstraints(IFunction_sptr fun, * @param fun :: The function * @param expr :: The constraint expression. */ -void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, +void FunctionFactoryImpl::addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &expr) const { auto c = std::unique_ptr<IConstraint>( ConstraintFactory::Instance().createInitialized(fun.get(), expr)); @@ -319,7 +319,7 @@ void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, * @param constraint_expr :: The constraint expression. * @param penalty_expr :: The penalty expression. */ -void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, +void FunctionFactoryImpl::addConstraint(const boost::shared_ptr<IFunction> &fun, const Expression &constraint_expr, const Expression &penalty_expr) const { auto c = std::unique_ptr<IConstraint>( @@ -335,7 +335,7 @@ void FunctionFactoryImpl::addConstraint(boost::shared_ptr<IFunction> fun, * @param expr :: The tie expression: either parName = TieString or a list * of name = string pairs */ -void FunctionFactoryImpl::addTies(IFunction_sptr fun, +void FunctionFactoryImpl::addTies(const IFunction_sptr &fun, const Expression &expr) const { if (expr.name() == "=") { addTie(fun, expr); @@ -350,7 +350,7 @@ void FunctionFactoryImpl::addTies(IFunction_sptr fun, * @param fun :: The function * @param expr :: The tie expression: parName = TieString */ -void FunctionFactoryImpl::addTie(IFunction_sptr fun, +void FunctionFactoryImpl::addTie(const IFunction_sptr &fun, const Expression &expr) const { if (expr.size() > 1) { // if size > 2 it is interpreted as setting a tie (last // expr.term) to multiple parameters, e.g diff --git a/Framework/API/src/FunctionGenerator.cpp b/Framework/API/src/FunctionGenerator.cpp index 5a601242606cc5c92d3cb8af33a8c44635af30b7..a5b08fe53618f43f57d0f0b94922293fb9be7704 100644 --- a/Framework/API/src/FunctionGenerator.cpp +++ b/Framework/API/src/FunctionGenerator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidAPI/FunctionGenerator.h" #include "MantidAPI/IConstraint.h" #include "MantidAPI/ParameterTie.h" @@ -14,7 +16,7 @@ namespace API { using namespace Kernel; /// Constructor -FunctionGenerator::FunctionGenerator(IFunction_sptr source) +FunctionGenerator::FunctionGenerator(const IFunction_sptr &source) : m_source(source), m_dirty(true) { if (source) { m_nOwnParams = source->nParams(); @@ -27,7 +29,7 @@ void FunctionGenerator::init() {} /// Set the source function /// @param source :: New source function. void FunctionGenerator::setSource(IFunction_sptr source) const { - m_source = source; + m_source = std::move(source); } /// Set i-th parameter diff --git a/Framework/API/src/GridDomain1D.cpp b/Framework/API/src/GridDomain1D.cpp index b177e7c0d10bd43fda81d4b36062fd80c015a7de..3f076e75acaccff830558fb19ce019053d38c821 100644 --- a/Framework/API/src/GridDomain1D.cpp +++ b/Framework/API/src/GridDomain1D.cpp @@ -17,7 +17,7 @@ namespace Mantid { namespace API { void GridDomain1D::initialize(double &startX, double &endX, size_t &n, - const std::string scaling) { + const std::string &scaling) { m_points.resize(n); m_points.front() = startX; m_points.back() = endX; diff --git a/Framework/API/src/GroupingLoader.cpp b/Framework/API/src/GroupingLoader.cpp index 527ad4d151b26269239388af22713524ac675f25..d34c9b75864d048ac16a798dc72555797326c83a 100644 --- a/Framework/API/src/GroupingLoader.cpp +++ b/Framework/API/src/GroupingLoader.cpp @@ -16,6 +16,7 @@ #include <Poco/DOM/Document.h> #include <Poco/DOM/NodeList.h> #include <boost/make_shared.hpp> +#include <utility> using namespace Poco::XML; @@ -27,7 +28,7 @@ namespace API { * @param instrument :: [input] Instrument */ GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument) - : m_instrument(instrument) {} + : m_instrument(std::move(instrument)) {} /** Constructor with field direction * @param instrument :: [input] Instrument @@ -35,7 +36,8 @@ GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument) */ GroupingLoader::GroupingLoader(Geometry::Instrument_const_sptr instrument, const std::string &mainFieldDirection) - : m_instrument(instrument), m_mainFieldDirection(mainFieldDirection) {} + : m_instrument(std::move(instrument)), + m_mainFieldDirection(mainFieldDirection) {} //---------------------------------------------------------------------------------------------- /** Destructor @@ -248,7 +250,7 @@ boost::shared_ptr<Grouping> GroupingLoader::getDummyGrouping() { * Construct a Grouping from a table * @param table :: [input] Table to construct from */ -Grouping::Grouping(ITableWorkspace_sptr table) { +Grouping::Grouping(const ITableWorkspace_sptr &table) { for (size_t row = 0; row < table->rowCount(); ++row) { std::vector<int> detectors = table->cell<std::vector<int>>(row, 0); diff --git a/Framework/API/src/HistoryItem.cpp b/Framework/API/src/HistoryItem.cpp index 917e1d076ea490bb2f49cac713823841331d643e..34208d196c36e70196457d07265f97fc87015613 100644 --- a/Framework/API/src/HistoryItem.cpp +++ b/Framework/API/src/HistoryItem.cpp @@ -7,13 +7,15 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- +#include <utility> + #include "MantidAPI/HistoryItem.h" namespace Mantid { namespace API { HistoryItem::HistoryItem(AlgorithmHistory_const_sptr algHist) - : m_algorithmHistory(algHist), m_unrolled(false) {} + : m_algorithmHistory(std::move(algHist)), m_unrolled(false) {} } // namespace API } // namespace Mantid diff --git a/Framework/API/src/IFunction.cpp b/Framework/API/src/IFunction.cpp index 425ca89b111463ebfe5389cb6a8ba54f668103b3..887b5dd17896885fcabad0bf52c40aa99abc9d43 100644 --- a/Framework/API/src/IFunction.cpp +++ b/Framework/API/src/IFunction.cpp @@ -38,6 +38,7 @@ #include <algorithm> #include <limits> #include <sstream> +#include <utility> namespace Mantid { namespace API { @@ -87,7 +88,7 @@ boost::shared_ptr<IFunction> IFunction::clone() const { */ void IFunction::setProgressReporter( boost::shared_ptr<Kernel::ProgressBase> reporter) { - m_progReporter = reporter; + m_progReporter = std::move(reporter); m_progReporter->setNotifyStep(0.01); } @@ -558,10 +559,11 @@ std::vector<std::string> IFunction::getParameterNames() const { * @param handler :: A new handler */ void IFunction::setHandler(std::unique_ptr<FunctionHandler> handler) { - m_handler = std::move(handler); if (handler && handler->function().get() != this) { throw std::runtime_error("Function handler points to a different function"); } + + m_handler = std::move(handler); m_handler->init(); } @@ -1241,9 +1243,10 @@ void IFunction::setMatrixWorkspace( * @param wsIndex :: workspace index * @return converted value */ -double IFunction::convertValue(double value, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, - size_t wsIndex) const { +double +IFunction::convertValue(double value, Kernel::Unit_sptr &outUnit, + const boost::shared_ptr<const MatrixWorkspace> &ws, + size_t wsIndex) const { // only required if formula or look-up-table different from ws unit const auto &wsUnit = ws->getAxis(0)->unit(); if (outUnit->unitID() == wsUnit->unitID()) @@ -1271,7 +1274,7 @@ double IFunction::convertValue(double value, Kernel::Unit_sptr &outUnit, */ void IFunction::convertValue(std::vector<double> &values, Kernel::Unit_sptr &outUnit, - boost::shared_ptr<const MatrixWorkspace> ws, + const boost::shared_ptr<const MatrixWorkspace> &ws, size_t wsIndex) const { // only required if formula or look-up-table different from ws unit const auto &wsUnit = ws->getAxis(0)->unit(); @@ -1361,9 +1364,10 @@ IFunction_sptr IFunction::getFunction(std::size_t) const { std::vector<std::string> IFunction::getAttributeNames() const { std::vector<std::string> names; names.reserve(m_attrs.size()); - for (const auto &attr : m_attrs) { - names.emplace_back(attr.first); - } + + std::transform(m_attrs.begin(), m_attrs.end(), std::back_inserter(names), + [](const auto &attr) { return attr.first; }); + return names; } @@ -1447,7 +1451,7 @@ void IFunction::storeReadOnlyAttribute( * @param covar :: A matrix to set. */ void IFunction::setCovarianceMatrix( - boost::shared_ptr<Kernel::Matrix<double>> covar) { + const boost::shared_ptr<Kernel::Matrix<double>> &covar) { // the matrix shouldn't be empty if (!covar) { throw std::invalid_argument( diff --git a/Framework/API/src/IMDWorkspace.cpp b/Framework/API/src/IMDWorkspace.cpp index 4933089184a59665a7e9003060eb2178335b303c..4e84206a2f8bab302f14d857b61751c1cfc0a740 100644 --- a/Framework/API/src/IMDWorkspace.cpp +++ b/Framework/API/src/IMDWorkspace.cpp @@ -12,6 +12,7 @@ #include "MantidKernel/VMD.h" #include <sstream> +#include <utility> using Mantid::Kernel::VMD; @@ -53,7 +54,7 @@ std::string IMDWorkspace::getConvention() const { return m_convention; } /** @return the convention */ void IMDWorkspace::setConvention(std::string convention) { - m_convention = convention; + m_convention = std::move(convention); } //--------------------------------------------------------------------------------------------- diff --git a/Framework/API/src/IndexProperty.cpp b/Framework/API/src/IndexProperty.cpp index d3dece746261a4de72336c16fd5091ba2d86ebb0..9ea0c194546d58b1beba0c1e5d4b7cd06feb5616 100644 --- a/Framework/API/src/IndexProperty.cpp +++ b/Framework/API/src/IndexProperty.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidAPI/IndexProperty.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidIndexing/GlobalSpectrumIndex.h" @@ -16,9 +18,10 @@ namespace API { IndexProperty::IndexProperty(const std::string &name, const IWorkspaceProperty &workspaceProp, const IndexTypeProperty &indexTypeProp, - Kernel::IValidator_sptr validator) - : ArrayProperty(name, "", validator), m_workspaceProp(workspaceProp), - m_indexTypeProp(indexTypeProp), m_indices(0), m_indicesExtracted(false) {} + const Kernel::IValidator_sptr &validator) + : ArrayProperty(name, "", std::move(validator)), + m_workspaceProp(workspaceProp), m_indexTypeProp(indexTypeProp), + m_indices(0), m_indicesExtracted(false) {} IndexProperty *IndexProperty::clone() const { return new IndexProperty(*this); } diff --git a/Framework/API/src/JointDomain.cpp b/Framework/API/src/JointDomain.cpp index b77efd802930226720e2d2c256b2b20548f98ef3..f6b6490db31bf4bc277be1cfea7b35ce73b5591b 100644 --- a/Framework/API/src/JointDomain.cpp +++ b/Framework/API/src/JointDomain.cpp @@ -33,7 +33,7 @@ const FunctionDomain &JointDomain::getDomain(size_t i) const { * Add a new domain. * @param domain :: A shared pointer to a domain. */ -void JointDomain::addDomain(FunctionDomain_sptr domain) { +void JointDomain::addDomain(const FunctionDomain_sptr &domain) { m_domains.emplace_back(domain); } diff --git a/Framework/API/src/MDGeometry.cpp b/Framework/API/src/MDGeometry.cpp index 8c0291e077c1b25e1587a90fa4409abbdc76a0ed..08de2f9e6dd324482c192b15656bfacf38f9cdd7 100644 --- a/Framework/API/src/MDGeometry.cpp +++ b/Framework/API/src/MDGeometry.cpp @@ -14,6 +14,7 @@ #include <Poco/NObserver.h> #include <boost/make_shared.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -244,7 +245,7 @@ size_t MDGeometry::getDimensionIndexById(const std::string &id) const { /** Add a dimension * @param dim :: shared pointer to the dimension object */ void MDGeometry::addDimension( - boost::shared_ptr<Mantid::Geometry::IMDDimension> dim) { + const boost::shared_ptr<Mantid::Geometry::IMDDimension> &dim) { m_dimensions.emplace_back(dim); } @@ -382,7 +383,7 @@ void MDGeometry::setOriginalWorkspace(boost::shared_ptr<Workspace> ws, size_t index) { if (index >= m_originalWorkspaces.size()) m_originalWorkspaces.resize(index + 1); - m_originalWorkspaces[index] = ws; + m_originalWorkspaces[index] = std::move(ws); m_notificationHelper->watchForWorkspaceDeletions(); } diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index 41d8c4fe152b2954eea2687cdd00fb1c22b14d15..931023650ac4fefae7823f772d9242242ac184e0 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -1237,9 +1237,10 @@ MatrixWorkspace::maskedBinsIndices(const size_t &workspaceIndex) const { auto maskedBins = it->second; std::vector<size_t> maskedIds; maskedIds.reserve(maskedBins.size()); - for (const auto &mb : maskedBins) { - maskedIds.emplace_back(mb.first); - } + + std::transform(maskedBins.begin(), maskedBins.end(), + std::back_inserter(maskedIds), + [](const auto &mb) { return mb.first; }); return maskedIds; } @@ -1939,7 +1940,6 @@ MatrixWorkspace::findY(double value, if (std::isnan(value)) { for (int64_t i = idx.first; i < numHists; ++i) { const auto &Y = this->y(i); - // cppcheck-suppress syntaxError if (auto it = std::find_if(std::next(Y.begin(), idx.second), Y.end(), [](double v) { return std::isnan(v); }); it != Y.end()) { diff --git a/Framework/API/src/MultiPeriodGroupWorker.cpp b/Framework/API/src/MultiPeriodGroupWorker.cpp index 0631fe5d508960782034edfbcc24be48f1893ed4..19e2b1ba6e4cbfd3196b0b34d68dcc45e283acac 100644 --- a/Framework/API/src/MultiPeriodGroupWorker.cpp +++ b/Framework/API/src/MultiPeriodGroupWorker.cpp @@ -36,7 +36,7 @@ MultiPeriodGroupWorker::MultiPeriodGroupWorker( * @param vecWorkspaceGroups: Vector of non-multi period workspace groups. */ void MultiPeriodGroupWorker::tryAddInputWorkspaceToInputGroups( - Workspace_sptr ws, + const Workspace_sptr &ws, MultiPeriodGroupWorker::VecWSGroupType &vecMultiPeriodWorkspaceGroups, MultiPeriodGroupWorker::VecWSGroupType &vecWorkspaceGroups) const { WorkspaceGroup_sptr inputGroup = diff --git a/Framework/API/src/MultipleExperimentInfos.cpp b/Framework/API/src/MultipleExperimentInfos.cpp index 9906877314c69a2655beed6ec75bb9cea5d317bc..7433e6efa12965ef5f8f4c9059fcf3a5f22db27e 100644 --- a/Framework/API/src/MultipleExperimentInfos.cpp +++ b/Framework/API/src/MultipleExperimentInfos.cpp @@ -11,6 +11,7 @@ #include <boost/make_shared.hpp> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -62,7 +63,8 @@ MultipleExperimentInfos::getExperimentInfo(const uint16_t runIndex) const { * @return the runIndex at which it was added * @throw std::runtime_error if you reach the limit of 65536 entries. */ -uint16_t MultipleExperimentInfos::addExperimentInfo(ExperimentInfo_sptr ei) { +uint16_t +MultipleExperimentInfos::addExperimentInfo(const ExperimentInfo_sptr &ei) { m_expInfos.emplace_back(ei); if (m_expInfos.size() >= static_cast<size_t>(std::numeric_limits<uint16_t>::max())) @@ -82,7 +84,7 @@ void MultipleExperimentInfos::setExperimentInfo(const uint16_t runIndex, if (size_t(runIndex) >= m_expInfos.size()) throw std::invalid_argument( "MDEventWorkspace::setExperimentInfo(): runIndex is out of range."); - m_expInfos[runIndex] = ei; + m_expInfos[runIndex] = std::move(ei); } //----------------------------------------------------------------------------------------------- diff --git a/Framework/API/src/NotebookBuilder.cpp b/Framework/API/src/NotebookBuilder.cpp index f74ac2867491e6f51fb5bd18acd070b94acfecaf..e3f2bcc48ddd6a6ccef2a1834f235bc54c08ac5e 100644 --- a/Framework/API/src/NotebookBuilder.cpp +++ b/Framework/API/src/NotebookBuilder.cpp @@ -14,6 +14,7 @@ #include "MantidKernel/Property.h" #include <boost/utility.hpp> +#include <utility> namespace Mantid { namespace API { @@ -25,10 +26,10 @@ namespace { Mantid::Kernel::Logger g_log("NotebookBuilder"); } -NotebookBuilder::NotebookBuilder(boost::shared_ptr<HistoryView> view, +NotebookBuilder::NotebookBuilder(const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity) : m_historyItems(view->getAlgorithmsList()), m_output(), - m_versionSpecificity(versionSpecificity), + m_versionSpecificity(std::move(versionSpecificity)), m_nb_writer(new NotebookWriter()) {} /** @@ -39,9 +40,9 @@ NotebookBuilder::NotebookBuilder(boost::shared_ptr<HistoryView> view, * @param ws_comment :: workspace comment * @return a formatted ipython notebook string of the history */ -const std::string NotebookBuilder::build(std::string ws_name, - std::string ws_title, - std::string ws_comment) { +const std::string NotebookBuilder::build(const std::string &ws_name, + const std::string &ws_title, + const std::string &ws_comment) { // record workspace details in notebook std::string workspace_details; workspace_details = "Workspace History: " + ws_name + "\n"; @@ -109,8 +110,8 @@ void NotebookBuilder::buildChildren( * @param algHistory :: pointer to an algorithm history object * @returns std::string to run this algorithm */ -const std::string -NotebookBuilder::buildAlgorithmString(AlgorithmHistory_const_sptr algHistory) { +const std::string NotebookBuilder::buildAlgorithmString( + const AlgorithmHistory_const_sptr &algHistory) { std::ostringstream properties; const std::string name = algHistory->name(); std::string prop; @@ -159,8 +160,8 @@ NotebookBuilder::buildAlgorithmString(AlgorithmHistory_const_sptr algHistory) { * @param propHistory :: reference to a property history object * @returns std::string for this property */ -const std::string -NotebookBuilder::buildPropertyString(PropertyHistory_const_sptr propHistory) { +const std::string NotebookBuilder::buildPropertyString( + const PropertyHistory_const_sptr &propHistory) { using Mantid::Kernel::Direction; // Create a vector of all non workspace property type names diff --git a/Framework/API/src/NotebookWriter.cpp b/Framework/API/src/NotebookWriter.cpp index e61de82600f8e4fdb9fbe79aadfff6401e87aeb5..25d7e80de99609a6ab251a631dd0a8077906199e 100644 --- a/Framework/API/src/NotebookWriter.cpp +++ b/Framework/API/src/NotebookWriter.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidAPI/NotebookWriter.h" #include "MantidKernel/Logger.h" #include "MantidKernel/MantidVersion.h" @@ -34,7 +36,7 @@ void NotebookWriter::codeCell(Json::Value array_code) { cell_data["cell_type"] = "code"; cell_data["collapsed"] = false; - cell_data["input"] = array_code; + cell_data["input"] = std::move(array_code); cell_data["language"] = "python"; cell_data["metadata"] = empty; cell_data["outputs"] = Json::Value(Json::arrayValue); @@ -47,7 +49,7 @@ void NotebookWriter::codeCell(Json::Value array_code) { * * @param string_code :: string containing the python for the code cell */ -std::string NotebookWriter::codeCell(std::string string_code) { +std::string NotebookWriter::codeCell(const std::string &string_code) { Json::Value cell_data; const Json::Value empty = Json::Value(Json::ValueType::objectValue); @@ -77,7 +79,7 @@ void NotebookWriter::markdownCell(Json::Value string_array) { cell_data["cell_type"] = "markdown"; cell_data["metadata"] = empty; - cell_data["source"] = string_array; + cell_data["source"] = std::move(string_array); m_cell_buffer.append(cell_data); } @@ -87,7 +89,7 @@ void NotebookWriter::markdownCell(Json::Value string_array) { * * @param string_text :: string containing the python code for the code cell */ -std::string NotebookWriter::markdownCell(std::string string_text) { +std::string NotebookWriter::markdownCell(const std::string &string_text) { Json::Value cell_data; const Json::Value empty = Json::Value(Json::ValueType::objectValue); diff --git a/Framework/API/src/ParamFunction.cpp b/Framework/API/src/ParamFunction.cpp index b59894b305c8775e11ffa596aa3b09c0d3a61fd3..66b2b282edab56dc13d64b68a5df86d1a99562b2 100644 --- a/Framework/API/src/ParamFunction.cpp +++ b/Framework/API/src/ParamFunction.cpp @@ -150,7 +150,7 @@ double ParamFunction::getParameter(const std::string &name) const { */ bool ParamFunction::hasParameter(const std::string &name) const { return std::find(m_parameterNames.cbegin(), m_parameterNames.cend(), name) != - m_parameterNames.end(); + m_parameterNames.cend(); } /** diff --git a/Framework/API/src/ParameterTie.cpp b/Framework/API/src/ParameterTie.cpp index eddfb788399e34daa2a097335f1155d880795ef5..a3ae0083301c80f15270d9edd7d041937ddc9a3c 100644 --- a/Framework/API/src/ParameterTie.cpp +++ b/Framework/API/src/ParameterTie.cpp @@ -202,9 +202,8 @@ bool ParameterTie::isConstant() const { return m_varMap.empty(); } std::vector<ParameterReference> ParameterTie::getRHSParameters() const { std::vector<ParameterReference> out; out.reserve(m_varMap.size()); - for (auto &&varPair : m_varMap) { - out.emplace_back(varPair.second); - } + std::transform(m_varMap.begin(), m_varMap.end(), std::back_inserter(out), + [](auto &&varPair) { return varPair.second; }); return out; } diff --git a/Framework/API/src/RemoteJobManagerFactory.cpp b/Framework/API/src/RemoteJobManagerFactory.cpp index 08709cac5ca74d31426f9f98ea143ccad311b076..1231e13dde9fb50d64bb5c2bbff418c128f850c2 100644 --- a/Framework/API/src/RemoteJobManagerFactory.cpp +++ b/Framework/API/src/RemoteJobManagerFactory.cpp @@ -65,8 +65,8 @@ IRemoteJobManager_sptr RemoteJobManagerFactoryImpl::create( * the type (for example the type is not recognized). */ Mantid::API::IRemoteJobManager_sptr -RemoteJobManagerFactoryImpl::create(const std::string baseURL, - const std::string jobManagerType) const { +RemoteJobManagerFactoryImpl::create(const std::string &baseURL, + const std::string &jobManagerType) const { Mantid::API::IRemoteJobManager_sptr jm; // use the inherited/generic create method diff --git a/Framework/API/src/Sample.cpp b/Framework/API/src/Sample.cpp index 36b92ab36b62be70764b1249a2e47bdf18c4ca87..b26a1a04bafcfe80d37d1636cde7ddfa7e3900b1 100644 --- a/Framework/API/src/Sample.cpp +++ b/Framework/API/src/Sample.cpp @@ -284,7 +284,7 @@ std::size_t Sample::size() const { return m_samples.size() + 1; } * Adds a sample to the sample collection * @param childSample The child sample to be added */ -void Sample::addSample(boost::shared_ptr<Sample> childSample) { +void Sample::addSample(const boost::shared_ptr<Sample> &childSample) { m_samples.emplace_back(childSample); } diff --git a/Framework/API/src/ScopedWorkspace.cpp b/Framework/API/src/ScopedWorkspace.cpp index 177288a3f3ad39adad0e8f7dc664573ad844de7d..58a5085d27558f07c3e26bf369f540fc6d972e87 100644 --- a/Framework/API/src/ScopedWorkspace.cpp +++ b/Framework/API/src/ScopedWorkspace.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAPI/ScopedWorkspace.h" +#include <utility> + #include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/ScopedWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" namespace Mantid { @@ -22,9 +24,9 @@ ScopedWorkspace::ScopedWorkspace() : m_name(generateUniqueName()) {} /** * Workspace constructor */ -ScopedWorkspace::ScopedWorkspace(Workspace_sptr ws) +ScopedWorkspace::ScopedWorkspace(const Workspace_sptr &ws) : m_name(generateUniqueName()) { - set(ws); + set(std::move(ws)); } //---------------------------------------------------------------------------------------------- @@ -77,7 +79,7 @@ void ScopedWorkspace::remove() { /** * Make ADS entry to point to the given workspace. */ -void ScopedWorkspace::set(Workspace_sptr newWS) { +void ScopedWorkspace::set(const Workspace_sptr &newWS) { AnalysisDataServiceImpl &ads = AnalysisDataService::Instance(); if (!newWS->getName().empty() && ads.doesExist(newWS->getName())) diff --git a/Framework/API/src/ScriptBuilder.cpp b/Framework/API/src/ScriptBuilder.cpp index 127f9380be24eb4d0249442c256941ca503db093..07d800bebdf57a329d6e3adc186deee14d2cc080 100644 --- a/Framework/API/src/ScriptBuilder.cpp +++ b/Framework/API/src/ScriptBuilder.cpp @@ -22,6 +22,7 @@ #include <boost/range/algorithm/remove_if.hpp> #include <boost/utility.hpp> #include <set> +#include <utility> namespace Mantid { namespace API { @@ -36,14 +37,15 @@ Mantid::Kernel::Logger g_log("ScriptBuilder"); const std::string COMMENT_ALG = "Comment"; ScriptBuilder::ScriptBuilder( - boost::shared_ptr<HistoryView> view, std::string versionSpecificity, + const boost::shared_ptr<HistoryView> &view, std::string versionSpecificity, bool appendTimestamp, std::vector<std::string> ignoreTheseAlgs, std::vector<std::vector<std::string>> ignoreTheseAlgProperties, bool appendExecCount) : m_historyItems(view->getAlgorithmsList()), m_output(), - m_versionSpecificity(versionSpecificity), - m_timestampCommands(appendTimestamp), m_algsToIgnore(ignoreTheseAlgs), - m_propertiesToIgnore(ignoreTheseAlgProperties), + m_versionSpecificity(std::move(versionSpecificity)), + m_timestampCommands(appendTimestamp), + m_algsToIgnore(std::move(ignoreTheseAlgs)), + m_propertiesToIgnore(std::move(ignoreTheseAlgProperties)), m_execCount(appendExecCount) {} /** diff --git a/Framework/API/src/SpectrumDetectorMapping.cpp b/Framework/API/src/SpectrumDetectorMapping.cpp index 6a1213489a939970ec232de5115c7c414f57a988..c05ed206e8dba917df65d38bf14327ece602e6f1 100644 --- a/Framework/API/src/SpectrumDetectorMapping.cpp +++ b/Framework/API/src/SpectrumDetectorMapping.cpp @@ -15,7 +15,7 @@ namespace API { * @throws std::invalid_argument if a null workspace pointer is passed in */ SpectrumDetectorMapping::SpectrumDetectorMapping( - MatrixWorkspace_const_sptr workspace, const bool useSpecNoIndex) + const MatrixWorkspace_const_sptr &workspace, const bool useSpecNoIndex) : m_indexIsSpecNo(useSpecNoIndex) { if (!workspace) { throw std::invalid_argument( diff --git a/Framework/API/src/WorkspaceGroup.cpp b/Framework/API/src/WorkspaceGroup.cpp index a251a3b2ed37650f2ecb5dc1a92e78bc34cf3dad..3db1116e68bca7aec5af9a50d1b96f8ba1c448c0 100644 --- a/Framework/API/src/WorkspaceGroup.cpp +++ b/Framework/API/src/WorkspaceGroup.cpp @@ -191,9 +191,11 @@ std::vector<std::string> WorkspaceGroup::getNames() const { std::vector<std::string> out; std::lock_guard<std::recursive_mutex> _lock(m_mutex); out.reserve(m_workspaces.size()); - for (const auto &workspace : m_workspaces) { - out.emplace_back(workspace->getName()); - } + + std::transform(m_workspaces.begin(), m_workspaces.end(), + std::back_inserter(out), + [](const auto &ws) { return ws->getName(); }); + return out; } diff --git a/Framework/API/src/WorkspaceHistory.cpp b/Framework/API/src/WorkspaceHistory.cpp index 167409dbd6c23d9bb57748ccbc8db5c89537f4cf..dfa12b0cafccbc78c015afeb0b69a69e6521b93c 100644 --- a/Framework/API/src/WorkspaceHistory.cpp +++ b/Framework/API/src/WorkspaceHistory.cpp @@ -317,7 +317,7 @@ void WorkspaceHistory::loadNexus(::NeXus::File *file) { * the workspace history. */ void WorkspaceHistory::loadNestedHistory(::NeXus::File *file, - AlgorithmHistory_sptr parent) { + const AlgorithmHistory_sptr &parent) { // historyNumbers should be sorted by number std::set<int> historyNumbers = findHistoryEntries(file); for (auto historyNumber : historyNumbers) { diff --git a/Framework/API/src/WorkspaceOpOverloads.cpp b/Framework/API/src/WorkspaceOpOverloads.cpp index 770c1b8b9b2273dd87e29b31c7945c6d36a86f82..e640abf0cdde4500de7899c1d26178be7d609411 100644 --- a/Framework/API/src/WorkspaceOpOverloads.cpp +++ b/Framework/API/src/WorkspaceOpOverloads.cpp @@ -141,7 +141,7 @@ template MANTID_API_DLL IMDHistoWorkspace_sptr executeBinaryOperation( * @param tolerance :: acceptable difference for floating point numbers * @return bool, true if workspaces match */ -bool equals(const MatrixWorkspace_sptr lhs, const MatrixWorkspace_sptr rhs, +bool equals(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs, double tolerance) { IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("CompareWorkspaces"); @@ -180,8 +180,8 @@ using OperatorOverloads::executeBinaryOperation; * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Plus", lhs, rhs); } @@ -191,7 +191,7 @@ MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -203,8 +203,8 @@ MatrixWorkspace_sptr operator+(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Minus", lhs, rhs); } @@ -214,7 +214,7 @@ MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -227,7 +227,7 @@ MatrixWorkspace_sptr operator-(const MatrixWorkspace_sptr lhs, * @return The result in a workspace shared pointer */ MatrixWorkspace_sptr operator-(const double &lhsValue, - const MatrixWorkspace_sptr rhs) { + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( "Minus", createWorkspaceSingleValue(lhsValue), rhs); @@ -237,8 +237,8 @@ MatrixWorkspace_sptr operator-(const double &lhsValue, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Multiply", lhs, rhs); } @@ -248,7 +248,7 @@ MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -262,7 +262,7 @@ MatrixWorkspace_sptr operator*(const MatrixWorkspace_sptr lhs, * @return The result in a workspace shared pointer */ MatrixWorkspace_sptr operator*(const double &lhsValue, - const MatrixWorkspace_sptr rhs) { + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( "Multiply", createWorkspaceSingleValue(lhsValue), rhs); @@ -273,8 +273,8 @@ MatrixWorkspace_sptr operator*(const double &lhsValue, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Divide", lhs, rhs); } @@ -284,7 +284,7 @@ MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -298,7 +298,7 @@ MatrixWorkspace_sptr operator/(const MatrixWorkspace_sptr lhs, * @return The result in a workspace shared pointer */ MatrixWorkspace_sptr operator/(const double &lhsValue, - const MatrixWorkspace_sptr rhs) { + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( "Divide", createWorkspaceSingleValue(lhsValue), rhs); @@ -309,8 +309,8 @@ MatrixWorkspace_sptr operator/(const double &lhsValue, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Plus", lhs, rhs, true); } @@ -320,7 +320,7 @@ MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -332,8 +332,8 @@ MatrixWorkspace_sptr operator+=(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Minus", lhs, rhs, true); } @@ -343,7 +343,7 @@ MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -355,8 +355,8 @@ MatrixWorkspace_sptr operator-=(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Multiply", lhs, rhs, true); @@ -367,7 +367,7 @@ MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -379,8 +379,8 @@ MatrixWorkspace_sptr operator*=(const MatrixWorkspace_sptr lhs, * @param rhs :: right hand side workspace shared pointer * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs) { +MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>("Divide", lhs, rhs, true); } @@ -390,7 +390,7 @@ MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr lhs, * @param rhsValue :: the single value * @return The result in a workspace shared pointer */ -MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr lhs, +MatrixWorkspace_sptr operator/=(const MatrixWorkspace_sptr &lhs, const double &rhsValue) { return executeBinaryOperation<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>( @@ -490,7 +490,7 @@ bool WorkspaceHelpers::sharedXData(const MatrixWorkspace &WS) { * @param forwards :: If true (the default) divides by bin width, if false * multiplies */ -void WorkspaceHelpers::makeDistribution(MatrixWorkspace_sptr workspace, +void WorkspaceHelpers::makeDistribution(const MatrixWorkspace_sptr &workspace, const bool forwards) { // If we're not able to get a writable reference to Y, then this is an event // workspace, which we can't operate on. diff --git a/Framework/API/test/AlgorithmFactoryTest.h b/Framework/API/test/AlgorithmFactoryTest.h index cb2bfc1dd6433704ed4b06cc95cf092e09c3789a..4dea1a5f303d1e1f3b6981985fcc5ec8b7eb8eed 100644 --- a/Framework/API/test/AlgorithmFactoryTest.h +++ b/Framework/API/test/AlgorithmFactoryTest.h @@ -186,7 +186,7 @@ public: foundAlg = ("Cat" == descItr->category) && ("ToyAlgorithm" == descItr->name) && ("Dog" == descItr->alias) && (1 == descItr->version); - descItr++; + ++descItr; } TS_ASSERT(foundAlg); diff --git a/Framework/API/test/AlgorithmHistoryTest.h b/Framework/API/test/AlgorithmHistoryTest.h index f3025039cdb106bf302337fa0f8dcd85f29f4449..735c71f5fa40df0e2f3f60991194130fb2ecb820 100644 --- a/Framework/API/test/AlgorithmHistoryTest.h +++ b/Framework/API/test/AlgorithmHistoryTest.h @@ -239,7 +239,7 @@ private: return AlgorithmHistory(&alg, execTime, 14.0, m_execCount++); } - AlgorithmHistory createFromTestAlg(std::string paramValue) { + AlgorithmHistory createFromTestAlg(const std::string ¶mValue) { Algorithm *testInput = new testalg; testInput->initialize(); testInput->setPropertyValue("arg1_param", paramValue); diff --git a/Framework/API/test/AlgorithmManagerTest.h b/Framework/API/test/AlgorithmManagerTest.h index e20adb182f740bde8237960592d144271caf213a..e33bd369e99f41f277ef33a6cdebb86d6f341424 100644 --- a/Framework/API/test/AlgorithmManagerTest.h +++ b/Framework/API/test/AlgorithmManagerTest.h @@ -106,12 +106,6 @@ public: } static void destroySuite(AlgorithmManagerTest *suite) { delete suite; } - AlgorithmManagerTest() { - // A test fails unless algorithms.retained is big enough - Mantid::Kernel::ConfigService::Instance().setString("algorithms.retained", - "5"); - } - void testVersionFail() { const size_t nalgs = AlgorithmFactory::Instance().getKeys().size(); TS_ASSERT_THROWS(AlgorithmFactory::Instance().subscribe<AlgTestFail>(), @@ -217,97 +211,6 @@ public: AlgorithmManager::Instance().notificationCenter.removeObserver(my_observer); } - /** Keep the right number of algorithms in the list. - * This also tests setMaxAlgorithms(). - */ - void testDroppingOldOnes() { - AlgorithmManager::Instance().setMaxAlgorithms(5); - AlgorithmManager::Instance().clear(); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 0); - - IAlgorithm_sptr first = AlgorithmManager::Instance().create("AlgTest"); - // Fill up the list - for (size_t i = 1; i < 5; i++) - AlgorithmManager::Instance().create("AlgTest"); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 5); - - // The first one is still in the list - TS_ASSERT(AlgorithmManager::Instance().getAlgorithm( - first->getAlgorithmID()) == first); - - // Add one more, drops the oldest one - AlgorithmManager::Instance().create("AlgTest"); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 5); - TS_ASSERT( - !AlgorithmManager::Instance().getAlgorithm(first->getAlgorithmID())); - } - - /** Keep one algorithm running, drop the second-oldest one etc. */ - void testDroppingOldOnes_whenAnAlgorithmIsStillRunning() { - AlgorithmManager::Instance().clear(); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 0); - - // Create one algorithm that appears never to stop - IAlgorithm_sptr first = - AlgorithmManager::Instance().create("AlgRunsForever"); - - IAlgorithm_sptr second = AlgorithmManager::Instance().create("AlgTest"); - - // Another long-running algo - IAlgorithm_sptr third = - AlgorithmManager::Instance().create("AlgRunsForever"); - - for (size_t i = 3; i < 5; i++) - AlgorithmManager::Instance().create("AlgTest"); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 5); - - // The first three created are in the list - TS_ASSERT(AlgorithmManager::Instance().getAlgorithm( - first->getAlgorithmID()) == first); - TS_ASSERT(AlgorithmManager::Instance().getAlgorithm( - second->getAlgorithmID()) == second); - TS_ASSERT(AlgorithmManager::Instance().getAlgorithm( - third->getAlgorithmID()) == third); - - // Add one more, drops the SECOND oldest one - AlgorithmManager::Instance().create("AlgTest"); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 5); - - TSM_ASSERT("The oldest algorithm (is still running) so it is still there", - AlgorithmManager::Instance().getAlgorithm( - first->getAlgorithmID()) == first); - TSM_ASSERT( - "The second oldest was popped, so trying to get it should return null", - !AlgorithmManager::Instance().getAlgorithm(second->getAlgorithmID())); - - // One more time - AlgorithmManager::Instance().create("AlgTest"); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 5); - - // The right ones are at the front - TSM_ASSERT("The oldest algorithm (is still running) so it is still there", - AlgorithmManager::Instance().getAlgorithm( - first->getAlgorithmID()) == first); - TSM_ASSERT("The third algorithm (is still running) so it is still there", - AlgorithmManager::Instance().getAlgorithm( - third->getAlgorithmID()) == third); - AlgorithmManager::Instance().cancelAll(); - } - - void testDroppingOldOnes_extremeCase() { - /** Extreme case where your queue fills up and all algos are running */ - AlgorithmManager::Instance().clear(); - for (size_t i = 0; i < 5; i++) { - AlgorithmManager::Instance().create("AlgRunsForever"); - } - - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 5); - // Create another that takes it past the normal max size (of 5) - AlgorithmManager::Instance().create("AlgTest"); - TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 6); - AlgorithmManager::Instance().cancelAll(); - } - void testThreadSafety() { PARALLEL_FOR_NO_WSP_CHECK() for (int i = 0; i < 5000; i++) { @@ -317,7 +220,6 @@ public: void testRemovingByIdRemovesCorrectObject() { auto &mgr = AlgorithmManager::Instance(); - mgr.setMaxAlgorithms(10); const size_t initialManagerSize = mgr.size(); // 2 different ids for same named algorithm auto alg1 = mgr.create("AlgTest"); @@ -329,8 +231,6 @@ public: // the right one? auto foundAlg = mgr.getAlgorithm(alg2->getAlgorithmID()); TS_ASSERT(foundAlg); - - mgr.setMaxAlgorithms(5); } void test_runningInstancesOf() { diff --git a/Framework/API/test/AlgorithmProxyTest.h b/Framework/API/test/AlgorithmProxyTest.h index 8dc5017571a8a8141e80adde264ebe7f4ae010a9..bff605adc012261bb356f7708ac5b2d8b8d5d7e2 100644 --- a/Framework/API/test/AlgorithmProxyTest.h +++ b/Framework/API/test/AlgorithmProxyTest.h @@ -17,6 +17,7 @@ #include <Poco/Thread.h> #include <boost/lexical_cast.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -121,7 +122,8 @@ public: TestProxyObserver() : AlgorithmObserver(), start(false), progress(false), finish(false) {} TestProxyObserver(IAlgorithm_const_sptr alg) - : AlgorithmObserver(alg), start(false), progress(false), finish(false) {} + : AlgorithmObserver(std::move(alg)), start(false), progress(false), + finish(false) {} void startHandle(const IAlgorithm *) override { start = true; } void progressHandle(const IAlgorithm *, double p, const std::string &msg) override { diff --git a/Framework/API/test/AlgorithmTest.h b/Framework/API/test/AlgorithmTest.h index cc5350719e3d039c446f9d0bc68fc8172a9ab8cd..e0d91c1adc03f77bef83b83464e5e92f75d51912 100644 --- a/Framework/API/test/AlgorithmTest.h +++ b/Framework/API/test/AlgorithmTest.h @@ -27,6 +27,7 @@ #include "MantidTestHelpers/FakeObjects.h" #include "PropertyManagerHelper.h" #include <map> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -511,8 +512,9 @@ public: /** Test of setting read and/or write locks * for various combinations of input/output workspaces. */ - void do_test_locking(std::string in1, std::string in2, std::string inout, - std::string out1, std::string out2) { + void do_test_locking(const std::string &in1, const std::string &in2, + const std::string &inout, const std::string &out1, + const std::string &out2) { for (size_t i = 0; i < 6; i++) { boost::shared_ptr<WorkspaceTester> ws = boost::make_shared<WorkspaceTester>(); @@ -586,7 +588,8 @@ public: * Make no group if blank, just 1 workspace * @return The new WorkspaceGroup object */ - Workspace_sptr makeWorkspaceGroup(std::string group1, std::string contents1) { + Workspace_sptr makeWorkspaceGroup(const std::string &group1, + std::string contents1) { auto &ads = AnalysisDataService::Instance(); if (contents1.empty()) { if (group1.empty()) @@ -614,14 +617,14 @@ public: } //------------------------------------------------------------------------ - WorkspaceGroup_sptr do_test_groups(std::string group1, std::string contents1, - std::string group2, std::string contents2, - std::string group3, std::string contents3, - bool expectFail = false, - int expectedNumber = 3) { - makeWorkspaceGroup(group1, contents1); - makeWorkspaceGroup(group2, contents2); - makeWorkspaceGroup(group3, contents3); + WorkspaceGroup_sptr + do_test_groups(const std::string &group1, std::string contents1, + const std::string &group2, std::string contents2, + const std::string &group3, std::string contents3, + bool expectFail = false, int expectedNumber = 3) { + makeWorkspaceGroup(group1, std::move(contents1)); + makeWorkspaceGroup(group2, std::move(contents2)); + makeWorkspaceGroup(group3, std::move(contents3)); StubbedWorkspaceAlgorithm alg; alg.initialize(); diff --git a/Framework/API/test/AnalysisDataServiceObserverTest.h b/Framework/API/test/AnalysisDataServiceObserverTest.h index 11240363aeb8f2b1d13fd77046b37b333a2b6f6b..46bbbee62718ee3357cdb86157f84a048bd3a140 100644 --- a/Framework/API/test/AnalysisDataServiceObserverTest.h +++ b/Framework/API/test/AnalysisDataServiceObserverTest.h @@ -109,7 +109,7 @@ public: m_mockInheritingClass = std::make_unique<FakeAnalysisDataServiceObserver>(); } - void addWorkspaceToADS(std::string name = "dummy") { + void addWorkspaceToADS(const std::string &name = "dummy") { IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "CreateSampleWorkspace"); diff --git a/Framework/API/test/ExperimentInfoTest.h b/Framework/API/test/ExperimentInfoTest.h index c7bb1f79bb94bfcdd7b0266a16541fbd3b9bafee..09cef48c58a4bb6a460faecbb51acc1fd84a5e0d 100644 --- a/Framework/API/test/ExperimentInfoTest.h +++ b/Framework/API/test/ExperimentInfoTest.h @@ -880,14 +880,14 @@ private: } Instrument_sptr - addInstrumentWithIndirectEmodeParameter(ExperimentInfo_sptr exptInfo) { + addInstrumentWithIndirectEmodeParameter(const ExperimentInfo_sptr &exptInfo) { Instrument_sptr inst = addInstrument(exptInfo); exptInfo->instrumentParameters().addString(inst.get(), "deltaE-mode", "indirect"); return inst; } - Instrument_sptr addInstrument(ExperimentInfo_sptr exptInfo) { + Instrument_sptr addInstrument(const ExperimentInfo_sptr &exptInfo) { Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(1); exptInfo->setInstrument(inst); diff --git a/Framework/API/test/FileFinderTest.h b/Framework/API/test/FileFinderTest.h index 2d909d37393d8e7071f18331fc9e6ca7fd055a39..3c90bb3aca00b611b883ddab72207bad589f0d32 100644 --- a/Framework/API/test/FileFinderTest.h +++ b/Framework/API/test/FileFinderTest.h @@ -215,7 +215,6 @@ public: } void testGetInstrument() { - std::string name; // place to put results ConfigService::Instance().setFacility("ISIS"); ConfigService::Instance().setString("default.instrument", "HRPD"); diff --git a/Framework/API/test/FunctionFactoryTest.h b/Framework/API/test/FunctionFactoryTest.h index 520179ff17a046a69dfafe53e1134e555c2ca4c0..71f77b73cceea6c06c0e101112edae00ed9c3e96 100644 --- a/Framework/API/test/FunctionFactoryTest.h +++ b/Framework/API/test/FunctionFactoryTest.h @@ -476,7 +476,7 @@ public: TS_ASSERT(second); // test each individual function - auto testFunc = [](CompositeFunction_sptr f) { + auto testFunc = [](const CompositeFunction_sptr &f) { if (f) { TS_ASSERT_EQUALS(f->nFunctions(), 2); TS_ASSERT_EQUALS(f->getFunction(0)->name(), diff --git a/Framework/API/test/FunctionPropertyTest.h b/Framework/API/test/FunctionPropertyTest.h index 3667910809dca09da6661632275d2680d3238d13..92b15eb6192ac8e7e17e49d229e87d41521d6a63 100644 --- a/Framework/API/test/FunctionPropertyTest.h +++ b/Framework/API/test/FunctionPropertyTest.h @@ -87,7 +87,6 @@ public: void test_Assignment_By_SharedPtr() { FunctionProperty prop("fun"); - std::string error; auto fun_p = FunctionFactory::Instance().createInitialized( createTestFunctionString()); TS_ASSERT(fun_p); @@ -105,7 +104,6 @@ public: void test_Shared_Pointer() { FunctionProperty prop("fun"); - std::string error; boost::shared_ptr<FunctionPropertyTest_Function> fun_p( new FunctionPropertyTest_Function); TS_ASSERT(fun_p); diff --git a/Framework/API/test/LiveListenerFactoryTest.h b/Framework/API/test/LiveListenerFactoryTest.h index 6bcf7bf29dddd2ac1db3c6fe674a4b3ab52f6e1b..c3fa9bdc09557cdad7fca627fb9d44a034bc218f 100644 --- a/Framework/API/test/LiveListenerFactoryTest.h +++ b/Framework/API/test/LiveListenerFactoryTest.h @@ -14,6 +14,8 @@ #include <Poco/Path.h> #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::API; @@ -29,7 +31,7 @@ class MockLiveListenerInstantiator public: MockLiveListenerInstantiator( boost::shared_ptr<Mantid::API::ILiveListener> product) - : product(product) {} + : product(std::move(product)) {} boost::shared_ptr<Mantid::API::ILiveListener> createInstance() const override { diff --git a/Framework/API/test/LogManagerTest.h b/Framework/API/test/LogManagerTest.h index aa677c3e04e495f0f9d8439a6ed68a791b6dd65d..c047bd8e1e057e7196d78b95760644e810fd1ff1 100644 --- a/Framework/API/test/LogManagerTest.h +++ b/Framework/API/test/LogManagerTest.h @@ -63,7 +63,8 @@ void addTestTimeSeries(LogManager &run, const std::string &name) { } } // namespace -void addTimeSeriesEntry(LogManager &runInfo, std::string name, double val) { +void addTimeSeriesEntry(LogManager &runInfo, const std::string &name, + double val) { TimeSeriesProperty<double> *tsp; tsp = new TimeSeriesProperty<double>(name); tsp->addValue("2011-05-24T00:00:00", val); @@ -554,8 +555,7 @@ private: LogManager runInfo; const std::string name = "T_prop"; runInfo.addProperty<T>(name, value); - int result(-1); - result = runInfo.getPropertyAsIntegerValue(name); + int result = runInfo.getPropertyAsIntegerValue(name); TS_ASSERT_THROWS_NOTHING(result = runInfo.getPropertyAsIntegerValue(name)); TS_ASSERT_EQUALS(value, static_cast<T>(result)); } @@ -579,12 +579,11 @@ public: } void test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times() { - double value(0.0); for (size_t i = 0; i < 20000; ++i) { - value = m_testRun.getPropertyAsSingleValue(m_propName); + // This has an observable side-effect of calling, so we don't need + // to store its return value + m_testRun.getPropertyAsSingleValue(m_propName); } - // Enure variable is used so that it is not optimised away by the compiler - value += 1.0; } LogManager m_testRun; diff --git a/Framework/API/test/MultiDomainFunctionTest.h b/Framework/API/test/MultiDomainFunctionTest.h index 3b87ef057f3de1a23c4f852345f77b9a1e2342ba..31f604a5c32308830875da2e9ddbf8e00eb70e4a 100644 --- a/Framework/API/test/MultiDomainFunctionTest.h +++ b/Framework/API/test/MultiDomainFunctionTest.h @@ -324,7 +324,6 @@ public: void test_attribute_domain_range() { multi.clearDomainIndices(); multi.setLocalAttributeValue(0, "domains", "0-2"); - return; multi.setLocalAttributeValue(1, "domains", "i"); multi.setLocalAttributeValue(2, "domains", "i"); @@ -336,7 +335,7 @@ public: const FunctionDomain1D &d0 = static_cast<const FunctionDomain1D &>(domain.getDomain(0)); for (size_t i = 0; i < 9; ++i) { - TS_ASSERT_EQUALS(values.getCalculated(i), A + B * d0[i]); + TS_ASSERT_DELTA(values.getCalculated(i), A + B * d0[i], 1e-6); } A = multi.getFunction(0)->getParameter("A") + @@ -346,7 +345,7 @@ public: const FunctionDomain1D &d1 = static_cast<const FunctionDomain1D &>(domain.getDomain(1)); for (size_t i = 9; i < 19; ++i) { - TS_ASSERT_EQUALS(values.getCalculated(i), A + B * d1[i - 9]); + TS_ASSERT_DELTA(values.getCalculated(i), A + B * d1[i - 9], 1e-6); } A = multi.getFunction(0)->getParameter("A") + @@ -356,7 +355,7 @@ public: const FunctionDomain1D &d2 = static_cast<const FunctionDomain1D &>(domain.getDomain(2)); for (size_t i = 19; i < 30; ++i) { - TS_ASSERT_EQUALS(values.getCalculated(i), A + B * d2[i - 19]); + TS_ASSERT_DELTA(values.getCalculated(i), A + B * d2[i - 19], 1e-6); } } diff --git a/Framework/API/test/MultiPeriodGroupTestBase.h b/Framework/API/test/MultiPeriodGroupTestBase.h index a164ac160814f489e12977880755bf2a977074be..6a27600bb90b7afe45c1591bf4d0722278d80375 100644 --- a/Framework/API/test/MultiPeriodGroupTestBase.h +++ b/Framework/API/test/MultiPeriodGroupTestBase.h @@ -28,7 +28,7 @@ class MultiPeriodGroupTestBase { protected: // Helper method to add multiperiod logs to make a workspacegroup look like a // real multiperiod workspace group. - void add_periods_logs(WorkspaceGroup_sptr ws) { + void add_periods_logs(const WorkspaceGroup_sptr &ws) { int nperiods = static_cast<int>(ws->size()); for (size_t i = 0; i < ws->size(); ++i) { MatrixWorkspace_sptr currentWS = @@ -45,7 +45,7 @@ protected: /// Helper to fabricate a workspace group consisting of equal sized /// matrixworkspaces. WorkspaceGroup_sptr - create_good_multiperiod_workspace_group(const std::string name) { + create_good_multiperiod_workspace_group(const std::string &name) { MatrixWorkspace_sptr a = MatrixWorkspace_sptr(new WorkspaceTester); MatrixWorkspace_sptr b = MatrixWorkspace_sptr(new WorkspaceTester); diff --git a/Framework/API/test/PeakFunctionIntegratorTest.h b/Framework/API/test/PeakFunctionIntegratorTest.h index 6c5730fc3bcec746bb14342f213384e1815d42c7..e6a3303cd4dde48305482f92f8dfd85be6222659 100644 --- a/Framework/API/test/PeakFunctionIntegratorTest.h +++ b/Framework/API/test/PeakFunctionIntegratorTest.h @@ -84,7 +84,8 @@ private: return gaussian; } - double getGaussianAnalyticalInfiniteIntegral(IPeakFunction_sptr gaussian) { + double + getGaussianAnalyticalInfiniteIntegral(const IPeakFunction_sptr &gaussian) { return gaussian->height() * gaussian->fwhm() / (2.0 * sqrt(M_LN2)) * sqrt(M_PI); } diff --git a/Framework/API/test/RunTest.h b/Framework/API/test/RunTest.h index e74db89faf05dbdb6c5a9362270d17e233e63e57..a41f319a7eae852b0a4d9b5ebdca618e2a06d844 100644 --- a/Framework/API/test/RunTest.h +++ b/Framework/API/test/RunTest.h @@ -427,7 +427,7 @@ public: TS_ASSERT_EQUALS(runCopy.getGoniometer().getNumberAxes(), 3); } - void addTimeSeriesEntry(Run &runInfo, std::string name, double val) { + void addTimeSeriesEntry(Run &runInfo, const std::string &name, double val) { TimeSeriesProperty<double> *tsp; tsp = new TimeSeriesProperty<double>(name); tsp->addValue("2011-05-24T00:00:00", val); @@ -630,12 +630,9 @@ public: } void test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times() { - double value(0.0); for (size_t i = 0; i < 20000; ++i) { - value = m_testRun.getPropertyAsSingleValue(m_propName); + m_testRun.getPropertyAsSingleValue(m_propName); } - // Enure variable is used so that it is not optimised away by the compiler - value += 1.0; } Run m_testRun; diff --git a/Framework/API/test/WorkspaceGroupTest.h b/Framework/API/test/WorkspaceGroupTest.h index 953000c8b23d5f4212ed0a57c8e311ed68bf83a9..37565ec2f0125c450b9ee63d35d6096932c8e2a9 100644 --- a/Framework/API/test/WorkspaceGroupTest.h +++ b/Framework/API/test/WorkspaceGroupTest.h @@ -50,7 +50,7 @@ public: class WorkspaceGroupTest : public CxxTest::TestSuite { private: /// Helper method to add an 'nperiods' log value to each workspace in a group. - void add_periods_logs(WorkspaceGroup_sptr ws, int nperiods = -1) { + void add_periods_logs(const WorkspaceGroup_sptr &ws, int nperiods = -1) { for (size_t i = 0; i < ws->size(); ++i) { MatrixWorkspace_sptr currentWS = boost::dynamic_pointer_cast<MatrixWorkspace>(ws->getItem(i)); diff --git a/Framework/API/test/WorkspaceNearestNeighboursTest.h b/Framework/API/test/WorkspaceNearestNeighboursTest.h index 763903a9d9dcc75654b31e7e9e2d5dba44d98111..d5ec89e9485439b67fac4f776dd7ee075f22e499 100644 --- a/Framework/API/test/WorkspaceNearestNeighboursTest.h +++ b/Framework/API/test/WorkspaceNearestNeighboursTest.h @@ -59,7 +59,7 @@ private: : public Mantid::API::WorkspaceNearestNeighbours { public: ExposedNearestNeighbours(const SpectrumInfo &spectrumInfo, - const std::vector<specnum_t> spectrumNumbers, + const std::vector<specnum_t> &spectrumNumbers, bool ignoreMasked = false) : WorkspaceNearestNeighbours(8, spectrumInfo, spectrumNumbers, ignoreMasked) {} diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h index fd2709dfec96be20c80c94a00dc98814d746a693..5f59e620a7bdc08bb02724ffd93db19a9fb84560 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h @@ -76,21 +76,22 @@ private: Types::Core::DateAndTime getRunStart(API::Run &run_obj); /// get value vector of the integer TimeSeriesProperty entries - std::vector<int> getIntValues(API::MatrixWorkspace_const_sptr dataws, + std::vector<int> getIntValues(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index); /// get value vector of the double TimeSeriesProperty entries - std::vector<double> getDblValues(API::MatrixWorkspace_const_sptr dataws, - int workspace_index); + std::vector<double> + getDblValues(const API::MatrixWorkspace_const_sptr &dataws, + int workspace_index); /// get the vector of times of the TimeSeriesProperty entries std::vector<Types::Core::DateAndTime> - getTimes(API::MatrixWorkspace_const_sptr dataws, int workspace_index, + getTimes(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index, bool is_epoch, bool is_second, API::Run &run_obj); /// get meta data from input workspace or user input - void getMetaData(API::MatrixWorkspace_const_sptr dataws, bool &epochtime, - std::string &timeunit); + void getMetaData(const API::MatrixWorkspace_const_sptr &dataws, + bool &epochtime, std::string &timeunit); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h index 262863c52e947411830ed47ae158706d82e5f61c..b2dba6d8716db4b3252f7a350b47245f59f04e81 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h @@ -73,9 +73,9 @@ private: void align(const ConversionFactors &converter, API::Progress &progress, DataObjects::EventWorkspace &outputWS); - void loadCalFile(API::MatrixWorkspace_sptr inputWS, + void loadCalFile(const API::MatrixWorkspace_sptr &inputWS, const std::string &filename); - void getCalibrationWS(API::MatrixWorkspace_sptr inputWS); + void getCalibrationWS(const API::MatrixWorkspace_sptr &inputWS); Mantid::API::ITableWorkspace_sptr m_calibrationWS; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h b/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h index 8df86f65df339ee7a04969faf1ffe6c1d78bf2c2..5bd4f7d1bd5c6c8f3df6faa7f27c8c33f25b3342 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h @@ -47,7 +47,7 @@ private: DataObjects::EventWorkspace_sptr m_inputWS; ///< Pointer to the input event workspace int m_numberOfSpectra; ///< The number of spectra in the workspace - void normalizeToBinArea(API::MatrixWorkspace_sptr outWS); + void normalizeToBinArea(const API::MatrixWorkspace_sptr &outWS); }; double calcD(double wavelength, double sintheta); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h b/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h index 095d6e2c18ac7f2ed3722f7ab4d53578a45ad7f7..f8598c52cdf2b22216541b3d9968a09f78db9c47 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperation.h @@ -193,7 +193,7 @@ protected: (void)ans; }; - OperandType getOperandType(const API::MatrixWorkspace_const_sptr ws); + OperandType getOperandType(const API::MatrixWorkspace_const_sptr &ws); virtual void checkRequirements(); @@ -255,8 +255,8 @@ private: void doSingleColumn(); void do2D(bool mismatchedSpectra); - void propagateBinMasks(const API::MatrixWorkspace_const_sptr rhs, - API::MatrixWorkspace_sptr out); + void propagateBinMasks(const API::MatrixWorkspace_const_sptr &rhs, + const API::MatrixWorkspace_sptr &out); /// Progress reporting std::unique_ptr<API::Progress> m_progress = nullptr; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h index 3342d463b0fd87b4240ace76f93037d308cb5e03..f1be5292a6be993923b03832422a9cfcb6faa734 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h @@ -61,10 +61,10 @@ private: API::MatrixWorkspace_sptr createOutputWorkspace(const API::MatrixWorkspace_sptr &inputWS, - const std::string) const; - void deleteWorkspace(API::MatrixWorkspace_sptr workspace); + const std::string &) const; + void deleteWorkspace(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr - setUncertainties(API::MatrixWorkspace_sptr workspace); + setUncertainties(const API::MatrixWorkspace_sptr &workspace); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h index 4af1002d855fe118c045ed9ca9117065836b000a..bdf3f4a5bfc4b05ce5f77be4098d99f77dfcfefa 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateDynamicRange.h @@ -25,8 +25,8 @@ public: private: void init() override; void exec() override; - void calculateQMinMax(API::MatrixWorkspace_sptr, const std::vector<size_t> &, - const std::string &); + void calculateQMinMax(const API::MatrixWorkspace_sptr &, + const std::vector<size_t> &, const std::string &); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h index a781121fb442011680b1d63f3c64a13334e92f5a..b88b74a74fa40b7352af657a57d96e7a6672a7a7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateEfficiency.h @@ -70,19 +70,19 @@ private: void exec() override; /// Sum all detectors, excluding monitors and masked detectors - void sumUnmaskedDetectors(API::MatrixWorkspace_sptr rebinnedWS, double &sum, - double &error, int &nPixels); + void sumUnmaskedDetectors(const API::MatrixWorkspace_sptr &rebinnedWS, + double &sum, double &error, int &nPixels); /// Normalize all detectors to get the relative efficiency - void normalizeDetectors(API::MatrixWorkspace_sptr rebinnedWS, - API::MatrixWorkspace_sptr outputWS, double sum, + void normalizeDetectors(const API::MatrixWorkspace_sptr &rebinnedWS, + const API::MatrixWorkspace_sptr &outputWS, double sum, double error, int nPixels, double min_eff, double max_eff); void maskComponent(API::MatrixWorkspace &ws, const std::string &componentName); - void maskEdges(API::MatrixWorkspace_sptr ws, int high, int low, int left, - int right, const std::string &componentName); + void maskEdges(const API::MatrixWorkspace_sptr &ws, int high, int low, + int left, int right, const std::string &componentName); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h index c2267bea170ee245cc0796c20acb6653142d1f5e..e060732d340ebfb03447639628ab3a4925add227 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h @@ -28,24 +28,26 @@ private: std::map<std::string, std::string> validateInputs() override; std::string rebinParamsAsString(); API::MatrixWorkspace_sptr - monteCarloErrorCalculation(API::MatrixWorkspace_sptr sample, - API::MatrixWorkspace_sptr resolution, + monteCarloErrorCalculation(const API::MatrixWorkspace_sptr &sample, + const API::MatrixWorkspace_sptr &resolution, const std::string &rebinParams, const int seed, const bool calculateErrors, const int nIterations); - API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr workspace, + API::MatrixWorkspace_sptr rebin(const API::MatrixWorkspace_sptr &workspace, const std::string ¶ms); - API::MatrixWorkspace_sptr integration(API::MatrixWorkspace_sptr workspace); API::MatrixWorkspace_sptr - convertToPointData(API::MatrixWorkspace_sptr workspace); + integration(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr - extractFFTSpectrum(API::MatrixWorkspace_sptr workspace); - API::MatrixWorkspace_sptr divide(API::MatrixWorkspace_sptr lhsWorkspace, - API::MatrixWorkspace_sptr rhsWorkspace); - API::MatrixWorkspace_sptr cropWorkspace(API::MatrixWorkspace_sptr workspace, - const double xMax); + convertToPointData(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr - replaceSpecialValues(API::MatrixWorkspace_sptr workspace); + extractFFTSpectrum(const API::MatrixWorkspace_sptr &workspace); + API::MatrixWorkspace_sptr + divide(const API::MatrixWorkspace_sptr &lhsWorkspace, + const API::MatrixWorkspace_sptr &rhsWorkspace); + API::MatrixWorkspace_sptr + cropWorkspace(const API::MatrixWorkspace_sptr &workspace, const double xMax); + API::MatrixWorkspace_sptr + replaceSpecialValues(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr removeInvalidData(API::MatrixWorkspace_sptr workspace); @@ -54,7 +56,7 @@ private: const std::string &rebinParams); API::MatrixWorkspace_sptr calculateIqt(API::MatrixWorkspace_sptr workspace, - API::MatrixWorkspace_sptr resolutionWorkspace, + const API::MatrixWorkspace_sptr &resolutionWorkspace, const std::string &rebinParams); API::MatrixWorkspace_sptr doSimulation(API::MatrixWorkspace_sptr sample, API::MatrixWorkspace_sptr resolution, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h index bd42d4ffaa665286b117432efb7d25420a6627ac..1a9c176f94447ceee85a412531eae1a93e600160 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h @@ -80,27 +80,27 @@ private: void exec() override; /// Pull out a single spectrum from a 2D workspace - API::MatrixWorkspace_sptr extractSpectra(API::MatrixWorkspace_sptr ws, + API::MatrixWorkspace_sptr extractSpectra(const API::MatrixWorkspace_sptr &ws, const std::vector<size_t> &indices); /// Returns a workspace with the evaulation of the fit to the calculated /// transmission fraction - API::MatrixWorkspace_sptr fit(API::MatrixWorkspace_sptr raw, + API::MatrixWorkspace_sptr fit(const API::MatrixWorkspace_sptr &raw, const std::vector<double> &rebinParams, - const std::string fitMethod); + const std::string &fitMethod); /// Call the Linear fitting algorithm as a child algorithm - API::MatrixWorkspace_sptr fitData(API::MatrixWorkspace_sptr WS, double &grad, - double &offset); + API::MatrixWorkspace_sptr fitData(const API::MatrixWorkspace_sptr &WS, + double &grad, double &offset); /// Call the Polynomial fitting algorithm as a child algorithm - API::MatrixWorkspace_sptr fitPolynomial(API::MatrixWorkspace_sptr WS, + API::MatrixWorkspace_sptr fitPolynomial(const API::MatrixWorkspace_sptr &WS, int order, std::vector<double> &coeficients); /// Calls the rebin algorithm API::MatrixWorkspace_sptr rebin(const std::vector<double> &binParams, - API::MatrixWorkspace_sptr ws); + const API::MatrixWorkspace_sptr &ws); /// Outpus message to log if the detector at the given index is not a monitor /// in both input workspaces. - void logIfNotMonitor(API::MatrixWorkspace_sptr sampleWS, - API::MatrixWorkspace_sptr directWS, size_t index); + void logIfNotMonitor(const API::MatrixWorkspace_sptr &sampleWS, + const API::MatrixWorkspace_sptr &directWS, size_t index); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h index 1e59400328374843dea53c76bb5d4487e08f31b7..ed1123c24199e4b23405f5550a290c26533c0c3c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h @@ -85,12 +85,12 @@ private: void exec() override; /// Pull out a single spectrum from a 2D workspace - API::MatrixWorkspace_sptr extractSpectrum(API::MatrixWorkspace_sptr WS, + API::MatrixWorkspace_sptr extractSpectrum(const API::MatrixWorkspace_sptr &WS, const size_t index); /// Call the Linear fitting algorithm as a child algorithm - API::MatrixWorkspace_sptr fitToData(API::MatrixWorkspace_sptr WS); + API::MatrixWorkspace_sptr fitToData(const API::MatrixWorkspace_sptr &WS); /// Sum the total detector, excluding masked pixels and monitors - API::MatrixWorkspace_sptr sumSpectra(API::MatrixWorkspace_sptr WS); + API::MatrixWorkspace_sptr sumSpectra(const API::MatrixWorkspace_sptr &WS); bool logFit = false; ///< If true, will take log of transmission curve before fitting diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h index a2f95dfe92304354fd27ee9afcbd40e3b9b332f8..3077f12a103e26b77a9359fcf93507127650c4af 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h @@ -58,10 +58,10 @@ private: double coeff1, double coeff2, double coeff3, bool doAbs, bool doMS); - API::MatrixWorkspace_sptr multiply(const API::MatrixWorkspace_sptr lhsWS, - const API::MatrixWorkspace_sptr rhsWS); - API::MatrixWorkspace_sptr minus(const API::MatrixWorkspace_sptr lhsWS, - const API::MatrixWorkspace_sptr rhsWS); + API::MatrixWorkspace_sptr multiply(const API::MatrixWorkspace_sptr &lhsWS, + const API::MatrixWorkspace_sptr &rhsWS); + API::MatrixWorkspace_sptr minus(const API::MatrixWorkspace_sptr &lhsWS, + const API::MatrixWorkspace_sptr &rhsWS); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h b/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h index f2ce91329617827298a636d03c386c9fe8fbb174..ec2099ea8f25d8d51eec5fd3b5c8e1ecf41a8d12 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h @@ -39,23 +39,24 @@ private: void exec() override; /// Create the output workspace Mantid::API::MatrixWorkspace_sptr - createOutputWS(Mantid::API::MatrixWorkspace_sptr input, double startProgress, - double stopProgress); + createOutputWS(const Mantid::API::MatrixWorkspace_sptr &input, + double startProgress, double stopProgress); /// Get the time shift - double getTimeShift(API::MatrixWorkspace_sptr ws) const; + double getTimeShift(const API::MatrixWorkspace_sptr &ws) const; /// Shift the time of the logs - void shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, double timeShift, - double startProgress, double stopProgress); + void shiftTimeOfLogs(const Mantid::API::MatrixWorkspace_sptr &ws, + double timeShift, double startProgress, + double stopProgress); /// Get the date and time of the first good frame of a workspace Mantid::Types::Core::DateAndTime - getStartTimeFromWorkspace(Mantid::API::MatrixWorkspace_sptr ws) const; + getStartTimeFromWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws) const; /// Can the string be transformed to double - bool checkForDouble(std::string val) const; + bool checkForDouble(const std::string &val) const; /// Can the string be transformed to a DateTime bool checkForDateTime(const std::string &val) const; /// Time shift the log of a double series property - void shiftTimeInLogForTimeSeries(Mantid::API::MatrixWorkspace_sptr ws, + void shiftTimeInLogForTimeSeries(const Mantid::API::MatrixWorkspace_sptr &ws, Mantid::Kernel::Property *prop, double timeShift) const; /// Time shift the log of a string property @@ -63,7 +64,7 @@ private: Mantid::Kernel::PropertyWithValue<std::string> *logEntry, double timeShift) const; // Shift the time of the neutrons - void shiftTimeOfNeutrons(Mantid::API::MatrixWorkspace_sptr ws, + void shiftTimeOfNeutrons(const Mantid::API::MatrixWorkspace_sptr &ws, double timeShift, double startProgress, double stopProgress); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h b/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h index 67af3faa165aca2f426339ed4bed5a6b7a74e38a..107db8a58bf43e244442a0e9206bf911c0a12f58 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h @@ -95,28 +95,30 @@ private: bool processGroups() override; /// Process the two groups - void processGroups(boost::shared_ptr<const API::WorkspaceGroup> groupOne, - boost::shared_ptr<const API::WorkspaceGroup> groupTwo); + void + processGroups(const boost::shared_ptr<const API::WorkspaceGroup> &groupOne, + const boost::shared_ptr<const API::WorkspaceGroup> &groupTwo); void doComparison(); void doPeaksComparison(DataObjects::PeaksWorkspace_sptr tws1, DataObjects::PeaksWorkspace_sptr tws2); - void doTableComparison(API::ITableWorkspace_const_sptr tws1, - API::ITableWorkspace_const_sptr tws2); - void doMDComparison(API::Workspace_sptr w1, API::Workspace_sptr w2); + void doTableComparison(const API::ITableWorkspace_const_sptr &tws1, + const API::ITableWorkspace_const_sptr &tws2); + void doMDComparison(const API::Workspace_sptr &w1, + const API::Workspace_sptr &w2); bool compareEventWorkspaces(const DataObjects::EventWorkspace &ews1, const DataObjects::EventWorkspace &ews2); - bool checkData(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkAxes(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkSpectraMap(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkInstrument(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); - bool checkMasking(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); + bool checkData(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkAxes(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkSpectraMap(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkInstrument(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); + bool checkMasking(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); bool checkSample(const API::Sample &sample1, const API::Sample &sample2); bool checkRunProperties(const API::Run &run1, const API::Run &run2); @@ -130,7 +132,7 @@ private: size_t &numdiffweight) const; /// Records a mismatch in the Messages workspace and sets Result to false - void recordMismatch(std::string msg, std::string ws1 = "", + void recordMismatch(const std::string &msg, std::string ws1 = "", std::string ws2 = ""); bool relErr(double x1, double x2, double errorVal) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h b/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h index 382d9012d01b942a710d3381679a1a62343dde63..bd95f9d9988782ed3962573994b3df313135b119 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConjoinXRuns.h @@ -42,8 +42,8 @@ private: void init() override; void exec() override; - std::string checkLogEntry(API::MatrixWorkspace_sptr) const; - std::vector<double> getXAxis(API::MatrixWorkspace_sptr) const; + std::string checkLogEntry(const API::MatrixWorkspace_sptr &) const; + std::vector<double> getXAxis(const API::MatrixWorkspace_sptr &) const; void joinSpectrum(int64_t); /// Sample log entry name diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h index 064281492b0f2012cd1801fc49d42f5c2ca0c51a..ddb8efc44bf35ece27d37adfcc5d33717e50dbd7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertEmptyToTof.h @@ -58,7 +58,8 @@ private: bool areEqual(double, double, double); int roundUp(double); std::vector<double> makeTofAxis(int, double, size_t, double); - void setTofInWS(const std::vector<double> &, API::MatrixWorkspace_sptr); + void setTofInWS(const std::vector<double> &, + const API::MatrixWorkspace_sptr &); DataObjects::Workspace2D_sptr m_inputWS; API::MatrixWorkspace_sptr m_outputWS; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h index 16370d79ad3d2b4897690b1e8f7bc5f0625c448c..c901152c2a8bbceaf409ec0f41fdd1c4869e49d6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis.h @@ -61,7 +61,8 @@ private: void exec() override; /// Getting Efixed double getEfixed(const Mantid::Geometry::IDetector &detector, - API::MatrixWorkspace_const_sptr inputWS, int emode) const; + const API::MatrixWorkspace_const_sptr &inputWS, + int emode) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h index 77ee90c93e77f18069c463f97d8133fe3b634096..0b7263119f73b4f0dae996dce28a484d827496bf 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h @@ -51,8 +51,8 @@ private: void init() override; void exec() override; void initWorkspaces(); - double getRunProperty(std::string); - double getInstrumentProperty(std::string); + double getRunProperty(const std::string &); + double getInstrumentProperty(const std::string &); double calculateTOF(double); /// The user selected (input) workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h index 44ae9d412ba3a00bad84de8b5f52b7922bae531b..aef3ddfa017ab62fa36e41e4a8270af7d220f1f9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h @@ -69,12 +69,12 @@ public: protected: /// Reverses the workspace if X values are in descending order - void reverse(API::MatrixWorkspace_sptr WS); + void reverse(const API::MatrixWorkspace_sptr &WS); /// For conversions to energy transfer, removes bins corresponding to /// inaccessible values API::MatrixWorkspace_sptr - removeUnphysicalBins(const API::MatrixWorkspace_const_sptr workspace); + removeUnphysicalBins(const API::MatrixWorkspace_const_sptr &workspace); const std::string workspaceMethodName() const override { return "convertUnits"; @@ -87,21 +87,21 @@ protected: void init() override; void exec() override; - void setupMemberVariables(const API::MatrixWorkspace_const_sptr inputWS); + void setupMemberVariables(const API::MatrixWorkspace_const_sptr &inputWS); virtual void storeEModeOnWorkspace(API::MatrixWorkspace_sptr outputWS); API::MatrixWorkspace_sptr - setupOutputWorkspace(const API::MatrixWorkspace_const_sptr inputWS); + setupOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWS); /// Executes the main part of the algorithm that handles the conversion of the /// units API::MatrixWorkspace_sptr - executeUnitConversion(const API::MatrixWorkspace_sptr inputWS); + executeUnitConversion(const API::MatrixWorkspace_sptr &inputWS); /// Convert the workspace units according to a simple output = a * (input^b) /// relationship API::MatrixWorkspace_sptr - convertQuickly(API::MatrixWorkspace_const_sptr inputWS, const double &factor, - const double &power); + convertQuickly(const API::MatrixWorkspace_const_sptr &inputWS, + const double &factor, const double &power); /// Internal function to gather detector specific L2, theta and efixed values bool getDetectorValues(const API::SpectrumInfo &spectrumInfo, @@ -118,11 +118,11 @@ protected: // Calls Rebin as a Child Algorithm to align the bins of the output workspace API::MatrixWorkspace_sptr - alignBins(const API::MatrixWorkspace_sptr workspace); + alignBins(const API::MatrixWorkspace_sptr &workspace); const std::vector<double> - calculateRebinParams(const API::MatrixWorkspace_const_sptr workspace) const; + calculateRebinParams(const API::MatrixWorkspace_const_sptr &workspace) const; - void putBackBinWidth(const API::MatrixWorkspace_sptr outputWS); + void putBackBinWidth(const API::MatrixWorkspace_sptr &outputWS); std::size_t m_numberOfSpectra{ 0}; ///< The number of spectra in the input workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h b/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h index b6d92fc6624b8da2ada6db00e8d603d7fb067b84..3d802a8f70a232898e1ca7c767ec3a3145f724e0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CorrectKiKf.h @@ -75,7 +75,7 @@ private: */ template <class T> void correctKiKfEventHelper(std::vector<T> &wevector, double efixed, - const std::string emodeStr); + const std::string &emodeStr); void getEfixedFromParameterMap(double &Efi, int64_t i, const Mantid::API::SpectrumInfo &spectrumInfo, const Mantid::Geometry::ParameterMap &pmap); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h b/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h index 487e6eeefc09854e9d260198342be2d2cbbd2ecc..cc380fc5809a251fc2e578b4d8f5cb45918a897d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h @@ -43,8 +43,8 @@ private: void init() override; std::map<std::string, std::string> validateInputs() override; void exec() override; - void useReferenceWorkspace(API::MatrixWorkspace_sptr outputWs); - void correctManually(API::MatrixWorkspace_sptr outputWs); + void useReferenceWorkspace(const API::MatrixWorkspace_sptr &outputWs); + void correctManually(const API::MatrixWorkspace_sptr &outputWs); double averageL2(const API::SpectrumInfo &spectrumInfo); void averageL2AndEPP(const API::SpectrumInfo &spectrumInfo, double &l2, double &epp); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h b/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h index b460a19d2ed7d4138bda54529641a937ae8dffa9..345a4d5f1c95aad8ebb2dd55ac9b5ebfec2f7215 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CorrectToFile.h @@ -54,8 +54,9 @@ private: /// Load in the RKH file for that has the correction information API::MatrixWorkspace_sptr loadInFile(const std::string &corrFile); /// Multiply or divide the input workspace as specified by the user - void doWkspAlgebra(API::MatrixWorkspace_sptr lhs, - API::MatrixWorkspace_sptr rhs, const std::string &algName, + void doWkspAlgebra(const API::MatrixWorkspace_sptr &lhs, + const API::MatrixWorkspace_sptr &rhs, + const std::string &algName, API::MatrixWorkspace_sptr &result); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h index 0a6222f000c052be4e199c4c82c2722d82cb209b..5ee9bb5ebaae98f5eea734a5c109ca21b6387b32 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateFloodWorkspace.h @@ -30,8 +30,8 @@ private: void exec() override; API::MatrixWorkspace_sptr getInputWorkspace(); std::string getBackgroundFunction(); - API::MatrixWorkspace_sptr integrate(API::MatrixWorkspace_sptr ws); - API::MatrixWorkspace_sptr transpose(API::MatrixWorkspace_sptr ws); + API::MatrixWorkspace_sptr integrate(const API::MatrixWorkspace_sptr &ws); + API::MatrixWorkspace_sptr transpose(const API::MatrixWorkspace_sptr &ws); bool shouldRemoveBackground(); void collectExcludedSpectra(); bool isExcludedSpectrum(double spec) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h index 1b5ac646c72b1b09a18cd77e84d82064486061d5..3b394e4a005198b9dbf42a54f27579fb1335e6d3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h @@ -65,7 +65,7 @@ private: const std::vector<double> &corrections) const; /// Write correction map to a text file - void writeCorrectionToFile(const std::string filename, + void writeCorrectionToFile(const std::string &filename, const Geometry::DetectorInfo &detectorInfo, const std::vector<double> &corrections) const; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h b/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h index 983716706a5bd137f8474349813ea5d8aaa8ab85..eef18d270f10da0133c6f46b6e8be189bf21a7e4 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h @@ -53,11 +53,11 @@ private: /// Process a tube bool performBleedTest(const std::vector<int> &tubeIndices, - API::MatrixWorkspace_const_sptr inputWS, double maxRate, - int numIgnoredPixels); + const API::MatrixWorkspace_const_sptr &inputWS, + double maxRate, int numIgnoredPixels); /// Mask a tube with the given workspace indices void maskTube(const std::vector<int> &tubeIndices, - API::MatrixWorkspace_sptr workspace); + const API::MatrixWorkspace_sptr &workspace); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h index ca5266bb9224c437b1d7dc0732126260835930cf..31f7422b0e544e75548d900e2f0a7fa423ece1ef 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h @@ -42,16 +42,18 @@ private: DataObjects::EventWorkspace_sptr createEventWorkspace(int numPixels, int numBins, int numMonitors, int numEvents, double x0, double binDelta, - Geometry::Instrument_sptr inst, + const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom); API::MatrixWorkspace_sptr createHistogramWorkspace(int numPixels, int numBins, int numMonitors, double x0, double binDelta, - Geometry::Instrument_sptr inst, + const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom); - API::MatrixWorkspace_sptr createScanningWorkspace( - int numBins, double x0, double binDelta, Geometry::Instrument_sptr inst, - const std::string &functionString, bool isRandom, int numScanPoints); + API::MatrixWorkspace_sptr + createScanningWorkspace(int numBins, double x0, double binDelta, + const Geometry::Instrument_sptr &inst, + const std::string &functionString, bool isRandom, + int numScanPoints); Geometry::Instrument_sptr createTestInstrumentRectangular( API::Progress &progress, int numBanks, int numMonitors, int pixels, double pixelSpacing, const double bankDistanceFromSample, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h index 5d9c55fece6d12ee925720de802f93f1fbd1fcdf..2b0f5b58f403202174edacae001f9e066299ac5b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace.h @@ -35,7 +35,7 @@ private: const OptionalMinMax &wavelengthMonitorBackgroundInterval, const OptionalMinMax &wavelengthMonitorIntegrationInterval, const OptionalInteger &i0MonitorIndex, - API::MatrixWorkspace_sptr firstTransmissionRun, + const API::MatrixWorkspace_sptr &firstTransmissionRun, OptionalMatrixWorkspace_sptr secondTransmissionRun, const OptionalDouble &stitchingStart, const OptionalDouble &stitchingDelta, const OptionalDouble &stitchingEnd, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h index 5bb0688750848bdde85b1f9cb4f201985f1e17af..b277f7a731506e1228c68a030bd760ab495e1f22 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h @@ -36,15 +36,15 @@ private: /// Normalize by monitors API::MatrixWorkspace_sptr - normalizeDetectorsByMonitors(API::MatrixWorkspace_sptr IvsTOF); + normalizeDetectorsByMonitors(const API::MatrixWorkspace_sptr &IvsTOF); /// Get the run numbers of the input workspaces void getRunNumbers(); /// Get the run number of a given workspace std::string getRunNumber(std::string const &propertyName); /// Store a transition run in ADS - void setOutputTransmissionRun(int which, API::MatrixWorkspace_sptr ws); + void setOutputTransmissionRun(int which, const API::MatrixWorkspace_sptr &ws); /// Store the stitched transition workspace run in ADS - void setOutputWorkspace(API::MatrixWorkspace_sptr ws); + void setOutputWorkspace(const API::MatrixWorkspace_sptr &ws); /// Run numbers for the first/second transmission run std::string m_firstTransmissionRunNumber; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h index 471625df43a38e23d90ceec5d3c588d90e6eec60..75546c2e0858a3ec1d51a7809506bc73962eb8e6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto.h @@ -36,7 +36,8 @@ private: void init() override; void exec() override; - template <typename T> boost::optional<T> isSet(std::string propName) const; + template <typename T> + boost::optional<T> isSet(const std::string &propName) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h index e0b95553eaf857d03a82d0792285cbb88ef5ac69..612883192212260bbadda9a33632d8098cb44849 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h @@ -54,21 +54,21 @@ private: void init() override; void exec() override; /// Apply a given mask - void applyMask(API::MatrixWorkspace_sptr inputWS, - API::MatrixWorkspace_sptr maskWS); + void applyMask(const API::MatrixWorkspace_sptr &inputWS, + const API::MatrixWorkspace_sptr &maskWS); /// Perform checks on detector vanadium - API::MatrixWorkspace_sptr doDetVanTest(API::MatrixWorkspace_sptr inputWS, - int &nFails); + API::MatrixWorkspace_sptr + doDetVanTest(const API::MatrixWorkspace_sptr &inputWS, int &nFails); protected: /// Get the total counts for each spectra API::MatrixWorkspace_sptr - integrateSpectra(API::MatrixWorkspace_sptr inputWS, const int indexMin, + integrateSpectra(const API::MatrixWorkspace_sptr &inputWS, const int indexMin, const int indexMax, const double lower, const double upper, const bool outputWorkspace2D = false); DataObjects::MaskWorkspace_sptr - generateEmptyMask(API::MatrixWorkspace_const_sptr inputWS); + generateEmptyMask(const API::MatrixWorkspace_const_sptr &inputWS); /// Calculate the median of the given workspace. This assumes that the input /// workspace contains @@ -80,7 +80,8 @@ protected: API::MatrixWorkspace_sptr convertToRate(API::MatrixWorkspace_sptr workspace); /// method to check which spectra should be grouped when calculating the /// median - std::vector<std::vector<size_t>> makeMap(API::MatrixWorkspace_sptr countsWS); + std::vector<std::vector<size_t>> + makeMap(const API::MatrixWorkspace_sptr &countsWS); /// method to create the map with all spectra std::vector<std::vector<size_t>> makeInstrumentMap(const API::MatrixWorkspace &countsWS); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h index 45618d558710456b6ada8eb1f6813b8280169979..205ada7ea22361b0f31514d046f73933cc9fe95c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h @@ -72,8 +72,8 @@ protected: API::MatrixWorkspace_sptr &whiteBeam2, double &variation, int &minSpec, int &maxSpec); /// Apply the detector test criterion - int doDetectorTests(API::MatrixWorkspace_const_sptr counts1, - API::MatrixWorkspace_const_sptr counts2, + int doDetectorTests(const API::MatrixWorkspace_const_sptr &counts1, + const API::MatrixWorkspace_const_sptr &counts2, const double average, double variation); private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h index 059a5714105c44fa0e900952fdd24b8af1c9c279..1bf164a22f2f4725dc88258b22b027f51b689441 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h @@ -49,12 +49,13 @@ public: } /// Function to optimize double intensity(double x, double y, double z, double rotx, double roty, - double rotz, std::string detname, std::string inname, - std::string outname, std::string peakOpt, - std::string rb_param, std::string groupWSName); + double rotz, const std::string &detname, + const std::string &inname, const std::string &outname, + const std::string &peakOpt, const std::string &rb_param, + const std::string &groupWSName); void movedetector(double x, double y, double z, double rotx, double roty, - double rotz, std::string detname, - Mantid::DataObjects::EventWorkspace_sptr inputW); + double rotz, const std::string &detname, + const Mantid::DataObjects::EventWorkspace_sptr &inputW); private: // Overridden Algorithm methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h index 8795383fb3a05c2a48ae13c7d624d3b5ed2b05f3..ffe71bb24d0e090bd83f7d0c350ce684a70ad231 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing.h @@ -78,7 +78,7 @@ private: void calculateRebinParams(const API::MatrixWorkspace_const_sptr &workspace, double &min, double &max, double &step); std::multimap<int64_t, int64_t> - readGroupingFile(std::string groupingFileName); + readGroupingFile(const std::string &groupingFileName); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h b/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h index 65a3f8b9730479a233bd231ccad83cf10a9dcd39..3b131ab4ed52a5c9974261f237786bef68a667cb 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/EQSANSTofStructure.h @@ -60,12 +60,12 @@ private: void exec() override; // void execEvent(Mantid::DataObjects::EventWorkspace_sptr inputWS, bool // frame_skipping); - void execEvent(Mantid::DataObjects::EventWorkspace_sptr inputWS, + void execEvent(const Mantid::DataObjects::EventWorkspace_sptr &inputWS, double threshold, double frame_offset, double tof_frame_width, double tmp_frame_width, bool frame_skipping); /// Compute TOF offset - double getTofOffset(DataObjects::EventWorkspace_const_sptr inputWS, + double getTofOffset(const DataObjects::EventWorkspace_const_sptr &inputWS, bool frame_skipping); double frame_tof0; bool flight_path_correction; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h index 53771879bf564de1dcd993f605f5bbbf74991f6c..e2e3a903912d35914e64ec547ae4231ce9263a94 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h @@ -58,7 +58,7 @@ private: const double &rel_start_time, size_t &i_start, const double &rel_stop_time, size_t &i_stop, const double &time_factor); - void exportLog(const std::string &logname, const std::string timeunit, + void exportLog(const std::string &logname, const std::string &timeunit, const double &starttime, const double &stoptime, const bool exportepoch, bool outputeventws, int numentries, bool cal_first_deriv); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h index 51caf074ea83d835478ade61e6f1234b5528771f..7c0173f5e99ec2fb0a521e2b91156649c7d3c82b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h @@ -54,11 +54,11 @@ private: /// Parse input TableWorkspace to get a list of detectors IDs of which /// detector are already masked std::vector<detid_t> - parseMaskTable(DataObjects::TableWorkspace_sptr masktablews); + parseMaskTable(const DataObjects::TableWorkspace_sptr &masktablews); /// Parse a string containing list in format (x, xx-yy, x, x, ...) to a vector /// of detid_t - std::vector<detid_t> parseStringToVector(std::string liststr); + std::vector<detid_t> parseStringToVector(const std::string &liststr); /// Extract mask from a workspace to a list of detectors std::vector<detid_t> extractMaskFromMatrixWorkspace(); @@ -67,11 +67,12 @@ private: std::vector<detid_t> extractMaskFromMaskWorkspace(); /// Copy table workspace content from one workspace to another - void copyTableWorkspaceContent(DataObjects::TableWorkspace_sptr sourceWS, - DataObjects::TableWorkspace_sptr targetWS); + void + copyTableWorkspaceContent(const DataObjects::TableWorkspace_sptr &sourceWS, + const DataObjects::TableWorkspace_sptr &targetWS); /// Add a list of spectra (detector IDs) to the output table workspace - void addToTableWorkspace(DataObjects::TableWorkspace_sptr outws, + void addToTableWorkspace(const DataObjects::TableWorkspace_sptr &outws, std::vector<detid_t> maskeddetids, double xmin, double xmax, std::vector<detid_t> prevmaskedids); }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h index a91db4d2de5ab05abeeb8ae2c21a69d04755af07..95f0cedf2c8b31da6635ae8100bc297ff576cba2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h @@ -170,8 +170,8 @@ private: /// Fit peak by calling 'FitPeak' double callFitPeak(const API::MatrixWorkspace_sptr &dataws, int wsindex, - const API::IPeakFunction_sptr peakfunction, - const API::IBackgroundFunction_sptr backgroundfunction, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &backgroundfunction, const std::vector<double> &vec_fitwindow, const std::vector<double> &vec_peakrange, int minGuessFWHM, int maxGuessFWHM, int guessedFWHMStep, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h b/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h index 2cf6b455d0cfa5bf7915d167dca9ae6065d5ae7c..692741c7a35052c6f5c57739356aac9ab3660c9b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h @@ -38,14 +38,14 @@ public: } /// Set workspaces - void setWorskpace(API::MatrixWorkspace_sptr dataws, size_t wsindex); + void setWorskpace(const API::MatrixWorkspace_sptr &dataws, size_t wsindex); /// Set fitting method - void setFittingMethod(std::string minimizer, std::string costfunction); + void setFittingMethod(std::string minimizer, const std::string &costfunction); /// Set functions - void setFunctions(API::IPeakFunction_sptr peakfunc, - API::IBackgroundFunction_sptr bkgdfunc); + void setFunctions(const API::IPeakFunction_sptr &peakfunc, + const API::IBackgroundFunction_sptr &bkgdfunc); /// Set fit range void setFitWindow(double leftwindow, double rightwindow); @@ -95,52 +95,52 @@ private: bool hasSetupToFitPeak(std::string &errmsg); /// Estimate the peak height from a set of data containing pure peaks - double estimatePeakHeight(API::IPeakFunction_const_sptr peakfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - size_t ixmin, size_t ixmax); + double estimatePeakHeight(const API::IPeakFunction_const_sptr &peakfunc, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, size_t ixmin, size_t ixmax); /// Check a peak function whether it is valid comparing to user specified /// criteria - double checkFittedPeak(API::IPeakFunction_sptr peakfunc, double costfuncvalue, - std::string &errorreason); + double checkFittedPeak(const API::IPeakFunction_sptr &peakfunc, + double costfuncvalue, std::string &errorreason); /// Fit peak function (flexible) - double fitPeakFunction(API::IPeakFunction_sptr peakfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - double startx, double endx); + double fitPeakFunction(const API::IPeakFunction_sptr &peakfunc, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, double startx, double endx); /// Fit function in single domain double fitFunctionSD(API::IFunction_sptr fitfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax); /// Calculate chi-square of a single domain function - double calChiSquareSD(API::IFunction_sptr fitfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + double calChiSquareSD(const API::IFunction_sptr &fitfunc, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax); /// Fit peak and background composite function - double fitCompositeFunction(API::IPeakFunction_sptr peakfunc, - API::IBackgroundFunction_sptr bkgdfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - double startx, double endx); + double fitCompositeFunction(const API::IPeakFunction_sptr &peakfunc, + const API::IBackgroundFunction_sptr &bkgdfunc, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, double startx, double endx); /// Fit function in multiple-domain - double fitFunctionMD(API::IFunction_sptr fitfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + double fitFunctionMD(const API::IFunction_sptr &fitfunc, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, std::vector<double> vec_xmin, std::vector<double> vec_xmax); /// remove background - void removeBackground(API::MatrixWorkspace_sptr purePeakWS); + void removeBackground(const API::MatrixWorkspace_sptr &purePeakWS); /// Process and store fit result void processNStoreFitResult(double rwp, bool storebkgd); /// Back up fit result - std::map<std::string, double> backup(API::IFunction_const_sptr func); + std::map<std::string, double> backup(const API::IFunction_const_sptr &func); void pop(const std::map<std::string, double> &funcparammap, - API::IFunction_sptr func); + const API::IFunction_sptr &func); /// Store function fitting error std::map<std::string, double> @@ -316,14 +316,14 @@ private: /// Generate table workspace DataObjects::TableWorkspace_sptr - genOutputTableWS(API::IPeakFunction_sptr peakfunc, + genOutputTableWS(const API::IPeakFunction_sptr &peakfunc, std::map<std::string, double> peakerrormap, - API::IBackgroundFunction_sptr bkgdfunc, + const API::IBackgroundFunction_sptr &bkgdfunc, std::map<std::string, double> bkgderrormap); /// Add function's parameter names after peak function name std::vector<std::string> - addFunctionParameterNames(std::vector<std::string> funcnames); + addFunctionParameterNames(const std::vector<std::string> &funcnames); /// Parse peak type from full peak type/parameter names string std::string parseFunctionTypeFull(const std::string &fullstring, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h index 44374d1f0733b41310d03a73c0db476d5db14098..286faf480dbb79b8440686e56a7caf196a3c8b8c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FitPeaks.h @@ -43,7 +43,7 @@ public: double getParameterValue(size_t ipeak, size_t iparam) const; double getParameterError(size_t ipeak, size_t iparam) const; void setRecord(size_t ipeak, const double cost, const double peak_position, - const FitFunction fit_functions); + const FitFunction &fit_functions); void setBadRecord(size_t ipeak, const double peak_position); void setFunctionParameters(size_t ipeak, std::vector<double> ¶m_values); @@ -122,46 +122,45 @@ private: /// fit peaks in a same spectrum void fitSpectrumPeaks( size_t wi, const std::vector<double> &expected_peak_centers, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result); + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result); /// fit background bool fitBackground(const size_t &ws_index, const std::pair<double, double> &fit_window, const double &expected_peak_pos, - API::IBackgroundFunction_sptr bkgd_func); + const API::IBackgroundFunction_sptr &bkgd_func); // Peak fitting suite - double fitIndividualPeak(size_t wi, API::IAlgorithm_sptr fitter, + double fitIndividualPeak(size_t wi, const API::IAlgorithm_sptr &fitter, const double expected_peak_center, const std::pair<double, double> &fitwindow, const bool observe_peak_params, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc); + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc); /// Methods to fit functions (general) - double fitFunctionSD(API::IAlgorithm_sptr fit, - API::IPeakFunction_sptr peak_function, - API::IBackgroundFunction_sptr bkgd_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + double fitFunctionSD(const API::IAlgorithm_sptr &fit, + const API::IPeakFunction_sptr &peak_function, + const API::IBackgroundFunction_sptr &bkgd_function, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax, const double &expected_peak_center, bool observe_peak_shape, bool estimate_background); double fitFunctionMD(API::IFunction_sptr fit_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, std::vector<double> &vec_xmin, std::vector<double> &vec_xmax); /// fit a single peak with high background - double fitFunctionHighBackground(API::IAlgorithm_sptr fit, - const std::pair<double, double> &fit_window, - const size_t &ws_index, - const double &expected_peak_center, - bool observe_peak_shape, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc); - - void setupParameterTableWorkspace(API::ITableWorkspace_sptr table_ws, + double fitFunctionHighBackground( + const API::IAlgorithm_sptr &fit, + const std::pair<double, double> &fit_window, const size_t &ws_index, + const double &expected_peak_center, bool observe_peak_shape, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc); + + void setupParameterTableWorkspace(const API::ITableWorkspace_sptr &table_ws, const std::vector<std::string> ¶m_names, bool with_chi2); @@ -171,7 +170,7 @@ private: std::vector<double> &vec_e); /// Reduce background - void reduceByBackground(API::IBackgroundFunction_sptr bkgd_func, + void reduceByBackground(const API::IBackgroundFunction_sptr &bkgd_func, const std::vector<double> &vec_x, std::vector<double> &vec_y); @@ -183,7 +182,7 @@ private: /// Esitmate background by 'observation' void estimateBackground(const HistogramData::Histogram &histogram, const std::pair<double, double> &peak_window, - API::IBackgroundFunction_sptr bkgd_function); + const API::IBackgroundFunction_sptr &bkgd_function); /// estimate linear background void estimateLinearBackground(const HistogramData::Histogram &histogram, double left_window_boundary, @@ -193,12 +192,12 @@ private: /// Estimate peak parameters by 'observation' int estimatePeakParameters(const HistogramData::Histogram &histogram, const std::pair<double, double> &peak_window, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunction, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunction, bool observe_peak_width); bool decideToEstimatePeakParams(const bool firstPeakInSpectrum, - API::IPeakFunction_sptr peak_function); + const API::IPeakFunction_sptr &peak_function); /// observe peak center int observePeakCenter(const HistogramData::Histogram &histogram, @@ -215,8 +214,8 @@ private: void processSinglePeakFitResult( size_t wsindex, size_t peakindex, const double cost, const std::vector<double> &expected_peak_positions, - FitPeaksAlgorithm::FitFunction fitfunction, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result); + const FitPeaksAlgorithm::FitFunction &fitfunction, + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result); /// calculate peak+background for fitted void calculateFittedPeaks( @@ -224,8 +223,8 @@ private: fit_results); /// Get the parameter name for peak height (I or height or etc) - std::string - getPeakHeightParameterName(API::IPeakFunction_const_sptr peak_function); + std::string getPeakHeightParameterName( + const API::IPeakFunction_const_sptr &peak_function); /// Set the workspaces and etc to output properties void processOutputs( @@ -235,7 +234,7 @@ private: /// Write result of peak fit per spectrum to output analysis workspaces void writeFitResult( size_t wi, const std::vector<double> &expected_positions, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result); + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result); /// check whether FitPeaks supports observation on a certain peak profile's /// parameters (width!) diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h index bb65b15ab66cf8f2166c511e7ce15afbe706a9c3..5326180be0858270ae48fda558b1d3caf5978f80 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h @@ -76,7 +76,7 @@ private: void processInputTime(); void setFilterByTimeOnly(); - void setFilterByLogValue(std::string logname); + void setFilterByLogValue(const std::string &logname); void processSingleValueFilter(double minvalue, double maxvalue, bool filterincrease, bool filterdecrease); @@ -93,7 +93,7 @@ private: /// Make multiple-log-value filters in serial void makeMultipleFiltersByValues(std::map<size_t, int> indexwsindexmap, - std::vector<double> logvalueranges, + const std::vector<double> &logvalueranges, bool centre, bool filterIncrease, bool filterDecrease, Types::Core::DateAndTime startTime, @@ -101,17 +101,19 @@ private: /// Make multiple-log-value filters in serial in parallel void makeMultipleFiltersByValuesParallel( - std::map<size_t, int> indexwsindexmap, std::vector<double> logvalueranges, - bool centre, bool filterIncrease, bool filterDecrease, + const std::map<size_t, int> &indexwsindexmap, + const std::vector<double> &logvalueranges, bool centre, + bool filterIncrease, bool filterDecrease, Types::Core::DateAndTime startTime, Types::Core::DateAndTime stopTime); /// Generate event splitters for partial sample log (serial) void makeMultipleFiltersByValuesPartialLog( int istart, int iend, std::vector<Types::Core::DateAndTime> &vecSplitTime, std::vector<int> &vecSplitGroup, std::map<size_t, int> indexwsindexmap, - const std::vector<double> &logvalueranges, Types::Core::time_duration tol, - bool filterIncrease, bool filterDecrease, - Types::Core::DateAndTime startTime, Types::Core::DateAndTime stopTime); + const std::vector<double> &logvalueranges, + const Types::Core::time_duration &tol, bool filterIncrease, + bool filterDecrease, Types::Core::DateAndTime startTime, + Types::Core::DateAndTime stopTime); /// Generate event filters for integer sample log void processIntegerValueFilter(int minvalue, int maxvalue, @@ -124,7 +126,7 @@ private: /// Add a splitter void addNewTimeFilterSplitter(Types::Core::DateAndTime starttime, Types::Core::DateAndTime stoptime, int wsindex, - std::string info); + const std::string &info); /// Create a splitter and add to the vector of time splitters Types::Core::DateAndTime diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h index 68e1fad7954bebd42c28aaa8659ed5fdbb06cafd..b10f8c3c6deaa673b2e50db2477f4e4630440489 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h @@ -69,10 +69,11 @@ private: const std::map<specnum_t, std::vector<std::pair<double, API::IFunction_sptr>>> &functionmap, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); /// Check whether function has a certain parameter - bool hasParameter(API::IFunction_sptr function, std::string paramname); + bool hasParameter(const API::IFunction_sptr &function, + const std::string ¶mname); /// Create output workspace API::MatrixWorkspace_sptr createOutputWorkspace(); @@ -82,14 +83,15 @@ private: void createFunction(std::string &peaktype, std::string &bkgdtype); - void getSpectraSet(DataObjects::TableWorkspace_const_sptr peakParmsWS); + void getSpectraSet(const DataObjects::TableWorkspace_const_sptr &peakParmsWS); /// Get the IPeakFunction part in the input function - API::IPeakFunction_sptr getPeakFunction(API::IFunction_sptr infunction); + API::IPeakFunction_sptr + getPeakFunction(const API::IFunction_sptr &infunction); /// Add function parameter names to std::vector<std::string> - addFunctionParameterNames(std::vector<std::string> funcnames); + addFunctionParameterNames(const std::vector<std::string> &funcnames); /// Peak function API::IPeakFunction_sptr m_peakFunction; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h index 455a940dc7bac78582519abdec29a2feaad16335..acdd85574617520b751566f61ebcc953c164bcd1 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h @@ -80,11 +80,11 @@ private: /// Main function to calculate all detectors' offsets void calculateDetectorsOffsets(); - void - importFitWindowTableWorkspace(DataObjects::TableWorkspace_sptr windowtablews); + void importFitWindowTableWorkspace( + const DataObjects::TableWorkspace_sptr &windowtablews); /// Call Gaussian as a Child Algorithm to fit the peak in a spectrum - int fitSpectra(const int64_t wi, API::MatrixWorkspace_sptr inputW, + int fitSpectra(const int64_t wi, const API::MatrixWorkspace_sptr &inputW, const std::vector<double> &peakPositions, const std::vector<double> &fitWindows, size_t &nparams, double &minD, double &maxD, std::vector<double> &peakPosToFit, @@ -94,7 +94,7 @@ private: /// Add peak fitting and offset calculation information to information table /// workspaces per spectrum - void addInfoToReportWS(int wi, FitPeakOffsetResult offsetresult, + void addInfoToReportWS(int wi, const FitPeakOffsetResult &offsetresult, const std::vector<double> &tofitpeakpositions, const std::vector<double> &fittedpeakpositions); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h b/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h index d9733304bb1c61175a294d568ba36ee2b0f03b10..424499f333ca434da570da36447f62e1522bfa1a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetEi.h @@ -68,15 +68,15 @@ private: void init() override; void exec() override; - void getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, - specnum_t mon1Spec, double &monitor0Dist, + void getGeometry(const API::MatrixWorkspace_const_sptr &WS, + specnum_t mon0Spec, specnum_t mon1Spec, double &monitor0Dist, double &monitor1Dist) const; - std::vector<size_t> getMonitorWsIndexs(API::MatrixWorkspace_const_sptr WS, - specnum_t specNum1, - specnum_t specNum2) const; + std::vector<size_t> + getMonitorWsIndexs(const API::MatrixWorkspace_const_sptr &WS, + specnum_t specNum1, specnum_t specNum2) const; double timeToFly(double s, double E_KE) const; - double getPeakCentre(API::MatrixWorkspace_const_sptr WS, const size_t monitIn, - const double peakTime); + double getPeakCentre(const API::MatrixWorkspace_const_sptr &WS, + const size_t monitIn, const double peakTime); void extractSpec(int wsInd, double start, double end); void getPeakEstimates(double &height, int64_t ¢reInd, double &background) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h b/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h index 56e478e4349cdea2015c3a68e9cadba714556d44..ac6fc8d9d710a35e248f6b4c98c345b17e785c29 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h @@ -84,16 +84,15 @@ private: API::MatrixWorkspace_sptr extractSpectrum(const size_t ws_index, const double start, const double end); /// Calculate peak width - double calculatePeakWidthAtHalfHeight(API::MatrixWorkspace_sptr data_ws, - const double prominence, - std::vector<double> &peak_x, - std::vector<double> &peak_y, - std::vector<double> &peak_e) const; + double calculatePeakWidthAtHalfHeight( + const API::MatrixWorkspace_sptr &data_ws, const double prominence, + std::vector<double> &peak_x, std::vector<double> &peak_y, + std::vector<double> &peak_e) const; /// Calculate the value of the first moment of the given spectrum - double calculateFirstMoment(API::MatrixWorkspace_sptr monitor_ws, + double calculateFirstMoment(const API::MatrixWorkspace_sptr &monitor_ws, const double prominence); /// Rebin the given workspace using the given parameters - API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr monitor_ws, + API::MatrixWorkspace_sptr rebin(const API::MatrixWorkspace_sptr &monitor_ws, const double first, const double width, const double end); /// Integrate the point data diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h b/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h index d552b35ae5d714b91372ca197e3012d5f38856b1..26243e70c43f716e130e70b2ad97171444df3b70 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetQsInQENSData.h @@ -53,7 +53,7 @@ private: void exec() override; /// Extracts Q-values from the specified matrix workspace - MantidVec extractQValues(const Mantid::API::MatrixWorkspace_sptr workspace); + MantidVec extractQValues(const Mantid::API::MatrixWorkspace_sptr &workspace); }; } // namespace Algorithms } // namespace Mantid diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h index 9ab9912083ee6583456e41b6261c878521a5bf30..d271bef466daa0e90fe6014a0c9bef0ab5e5e84b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h @@ -89,7 +89,7 @@ private: void execQuickStatistics(); - void exportErrorLog(API::MatrixWorkspace_sptr ws, + void exportErrorLog(const API::MatrixWorkspace_sptr &ws, std::vector<Types::Core::DateAndTime> abstimevec, double dts); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h b/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h index d9dcc5139400a8a0f25ddd80919d6eb6a83b5c9b..77c6a08bdd537237e1983d03cdb81c92b9b69119 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h @@ -94,8 +94,9 @@ private: /// Log any errors with spectra that occurred void logErrors() const; /// Retrieve the detector parameters from workspace or detector properties - double getParameter(std::string wsPropName, std::size_t currentIndex, - std::string detPropName, const Geometry::IDetector &idet); + double getParameter(const std::string &wsPropName, std::size_t currentIndex, + const std::string &detPropName, + const Geometry::IDetector &idet); /// Helper for event handling template <class T> void eventHelper(std::vector<T> &events, double expval); /// Function to calculate exponential contribution diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h b/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h index e58b10754e764de26db396807b62ec536646a19e..6343d9f8392b6f216995ec9c7d1d4479507ea42b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IQTransform.h @@ -67,10 +67,11 @@ private: void exec() override; inline API::MatrixWorkspace_sptr - subtractBackgroundWS(API::MatrixWorkspace_sptr ws, - API::MatrixWorkspace_sptr background); + subtractBackgroundWS(const API::MatrixWorkspace_sptr &ws, + const API::MatrixWorkspace_sptr &background); - using TransformFunc = void (IQTransform::*)(API::MatrixWorkspace_sptr); + using TransformFunc = + void (IQTransform::*)(const API::MatrixWorkspace_sptr &); using TransformMap = std::map<std::string, TransformFunc>; TransformMap m_transforms; ///< A map of transformation name and function pointers @@ -78,16 +79,16 @@ private: boost::shared_ptr<Kernel::Units::Label> m_label; // A function for each transformation - void guinierSpheres(API::MatrixWorkspace_sptr ws); - void guinierRods(API::MatrixWorkspace_sptr ws); - void guinierSheets(API::MatrixWorkspace_sptr ws); - void zimm(API::MatrixWorkspace_sptr ws); - void debyeBueche(API::MatrixWorkspace_sptr ws); - void kratky(API::MatrixWorkspace_sptr ws); - void porod(API::MatrixWorkspace_sptr ws); - void holtzer(API::MatrixWorkspace_sptr ws); - void logLog(API::MatrixWorkspace_sptr ws); - void general(API::MatrixWorkspace_sptr ws); + void guinierSpheres(const API::MatrixWorkspace_sptr &ws); + void guinierRods(const API::MatrixWorkspace_sptr &ws); + void guinierSheets(const API::MatrixWorkspace_sptr &ws); + void zimm(const API::MatrixWorkspace_sptr &ws); + void debyeBueche(const API::MatrixWorkspace_sptr &ws); + void kratky(const API::MatrixWorkspace_sptr &ws); + void porod(const API::MatrixWorkspace_sptr &ws); + void holtzer(const API::MatrixWorkspace_sptr &ws); + void logLog(const API::MatrixWorkspace_sptr &ws); + void general(const API::MatrixWorkspace_sptr &ws); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h index 611e4f3f4de5da9a4ddc3d7ab0a56068081ef9a9..39b39f5bec5857b77cca4e9180cc60090fba3782 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h @@ -49,8 +49,8 @@ private: void exec() override; ///< Executes the algorithm. void getStdDev(API::Progress &progress, - Mantid::API::MatrixWorkspace_sptr valid, - Mantid::API::MatrixWorkspace_sptr values); + const Mantid::API::MatrixWorkspace_sptr &valid, + const Mantid::API::MatrixWorkspace_sptr &values); }; } // namespace Algorithms } // namespace Mantid diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h b/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h index 637e829e118822c084c902cf457849e4dc489a84..526d705d2a85e6f54f2c6eaee7279fb0759973aa 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h @@ -34,11 +34,11 @@ private: void exec() override; /// method to check which spectra should be averaged - std::vector<std::vector<size_t>> makeMap(API::MatrixWorkspace_sptr countsWS, - int parents); + std::vector<std::vector<size_t>> + makeMap(const API::MatrixWorkspace_sptr &countsWS, int parents); /// method to create the map with all spectra std::vector<std::vector<size_t>> - makeInstrumentMap(API::MatrixWorkspace_sptr countsWS); + makeInstrumentMap(const API::MatrixWorkspace_sptr &countsWS); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Integration.h b/Framework/Algorithms/inc/MantidAlgorithms/Integration.h index b8265a5ed03a858160c447ef827bc9cfa780fc0e..d35d07f4742377db50ebd2cc1a0144d599ee70f0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Integration.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Integration.h @@ -66,7 +66,7 @@ private: void exec() override; API::MatrixWorkspace_sptr - rangeFilterEventWorkspace(API::MatrixWorkspace_sptr workspace, + rangeFilterEventWorkspace(const API::MatrixWorkspace_sptr &workspace, double minRange, double maxRange); /// Get the input workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h b/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h index ea1e72ecefbce15186dfabaf8c8f4bc9c9094ede..fb5c7d267364d0dc7a1bbf475991b6c653c65f03 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h @@ -78,9 +78,9 @@ protected: void init() override; void exec() override; - void outputYandEValues(API::MatrixWorkspace_const_sptr inputW, + void outputYandEValues(const API::MatrixWorkspace_const_sptr &inputW, const HistogramData::BinEdges &XValues_new, - API::MatrixWorkspace_sptr outputW); + const API::MatrixWorkspace_sptr &outputW); HistogramData::Histogram cubicInterpolation(const HistogramData::Histogram &oldHistogram, const HistogramData::BinEdges &xNew) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h b/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h index 33628ee864ea601da3b294292d60d74f75293891..e5db169d12f3de85b4771f87f5e82c107ef697f3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h @@ -43,14 +43,15 @@ private: void exec() override; /// Process input Mask bin TableWorkspace. - void processMaskBinWorkspace(DataObjects::TableWorkspace_sptr masktblws, - API::MatrixWorkspace_sptr dataws); + void + processMaskBinWorkspace(const DataObjects::TableWorkspace_sptr &masktblws, + const API::MatrixWorkspace_sptr &dataws); /// Call MaskBins - void maskBins(API::MatrixWorkspace_sptr dataws); + void maskBins(const API::MatrixWorkspace_sptr &dataws); /// Convert a list of detector IDs list (string) to a list of /// spectra/workspace indexes list - std::string convertToSpectraList(API::MatrixWorkspace_sptr dataws, - std::string detidliststr); + std::string convertToSpectraList(const API::MatrixWorkspace_sptr &dataws, + const std::string &detidliststr); /// Column indexes of XMin, XMax, SpectraList, DetectorIDsList int id_xmin, id_xmax, id_spec, id_dets; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h index 3c3e7a6ce5ea9731d32780c23f936455bdb2d58f..970b3a383e905b272c60c64e4c603216901ab70e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h @@ -67,7 +67,7 @@ private: /// Updates the image std::vector<double> updateImage(const std::vector<double> &image, const std::vector<double> &delta, - const std::vector<std::vector<double>> dirs); + const std::vector<std::vector<double>> &dirs); /// Populates the output workspace containing the reconstructed data void populateDataWS(API::MatrixWorkspace_const_sptr &inWS, size_t spec, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h index 1c3d348bab8f011bb842e6b842aee4d967210a81..69d1ac3e34c91faf04fc6d0ab807670faceedb15 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h @@ -36,7 +36,7 @@ public: // Deleted default constructor MaxentTransformMultiFourier() = delete; // Constructor - MaxentTransformMultiFourier(MaxentSpaceComplex_sptr dataSpace, + MaxentTransformMultiFourier(const MaxentSpaceComplex_sptr &dataSpace, MaxentSpace_sptr imageSpace, size_t numSpec); // Transfoms form image space to data space std::vector<double> imageToData(const std::vector<double> &image) override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h b/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h index a4bb40b58ab51df96bbcc24faa52a4b5d7b95b51..e1ab2d7c02cbb80b844512d486c71fadca709df0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h @@ -76,14 +76,14 @@ private: /// Calculates the sum of solid angles of detectors for each histogram API::MatrixWorkspace_sptr getSolidAngles(int firstSpec, int lastSpec); /// Mask the outlier values to get a better median value - int maskOutliers(const std::vector<double> medianvec, - API::MatrixWorkspace_sptr countsWS, + int maskOutliers(const std::vector<double> &medianvec, + const API::MatrixWorkspace_sptr &countsWS, std::vector<std::vector<size_t>> indexmap); /// Do the tests and mask those that fail - int doDetectorTests(const API::MatrixWorkspace_sptr countsWS, - const std::vector<double> medianvec, + int doDetectorTests(const API::MatrixWorkspace_sptr &countsWS, + const std::vector<double> &medianvec, std::vector<std::vector<size_t>> indexmap, - API::MatrixWorkspace_sptr maskWS); + const API::MatrixWorkspace_sptr &maskWS); API::MatrixWorkspace_sptr m_inputWS; /// The proportion of the median value below which a detector is considered diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Minus.h b/Framework/Algorithms/inc/MantidAlgorithms/Minus.h index f685724e2e73b9fdad1fa13241705898728b94fc..8dd896560879f1fcc343b22b789b7cbcab5035d7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Minus.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Minus.h @@ -66,8 +66,8 @@ private: std::string checkSizeCompatibility( const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override; - bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const; + bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const; bool checkCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h index 017061aa36962b172a86afbe63dfd2c80214c723..3fbe4eb3e86e867ea17e1153f57257a94effeab3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h @@ -55,8 +55,9 @@ private: void init() override; void exec() override; // Extract the charge value from the logs. - double extractCharge(boost::shared_ptr<Mantid::API::MatrixWorkspace> inputWS, - const bool integratePCharge) const; + double + extractCharge(const boost::shared_ptr<Mantid::API::MatrixWorkspace> &inputWS, + const bool integratePCharge) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h index d7459788ebed7b6650bf07868313376d8b255ea4..6a9a6febdb011c353e63291f9525077eff5cad49 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h @@ -48,16 +48,16 @@ private: /// Try to parse a function parameter and extract the correctly typed /// parameter. const Mantid::Geometry::FitParameter - tryParseFunctionParameter(Mantid::Geometry::Parameter_sptr parameter, + tryParseFunctionParameter(const Mantid::Geometry::Parameter_sptr ¶meter, const Geometry::IDetector &det); /// Block to process histograms. - boost::shared_ptr<Mantid::API::MatrixWorkspace> - processHistograms(boost::shared_ptr<Mantid::API::MatrixWorkspace> inWS); + boost::shared_ptr<Mantid::API::MatrixWorkspace> processHistograms( + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &inWS); /// Process indivdual histogram. void processHistogram( size_t wsIndex, - boost::shared_ptr<const Mantid::API::MatrixWorkspace> inWS, - boost::shared_ptr<Mantid::API::MatrixWorkspace> denominatorWS, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &inWS, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &denominatorWS, Mantid::API::Progress &prog); void init() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h index ca162015c75cf861ce6e5732ada82ab71e171c73..c36d200e4f4e137d9f5eee9e94a2b716b06d4521 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h @@ -166,7 +166,7 @@ private: mutable bool is_enabled; // auxiliary function to obtain list of monitor's ID-s (allowed_values) from a // workspace; - bool monitorIdReader(API::MatrixWorkspace_const_sptr inputWS) const; + bool monitorIdReader(const API::MatrixWorkspace_const_sptr &inputWS) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h b/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h index 5cfd7e9ef811464c3a55817c3add6ed448a4f41e..aa46946a5183c933090ac4b8875ef41a146e7a8f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h @@ -40,7 +40,7 @@ private: void exec() override; API::MatrixWorkspace_sptr loadAndBin(); API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr wksp); - API::MatrixWorkspace_sptr load(const std::string filename); + API::MatrixWorkspace_sptr load(const std::string &filename); void createCalTableFromExisting(); void createCalTableNew(); void createInformationWorkspaces(); @@ -59,8 +59,9 @@ private: /// NEW: convert peak positions in dSpacing to peak centers workspace std::pair<API::MatrixWorkspace_sptr, API::MatrixWorkspace_sptr> - createTOFPeakCenterFitWindowWorkspaces(API::MatrixWorkspace_sptr dataws, - const double peakWindowMaxInDSpacing); + createTOFPeakCenterFitWindowWorkspaces( + const API::MatrixWorkspace_sptr &dataws, + const double peakWindowMaxInDSpacing); API::ITableWorkspace_sptr sortTableWorkspace(API::ITableWorkspace_sptr &table); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h b/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h index a047a942567a2e67895d05150804a81bfbf3cb64..748cb88668927fa071f43fadc974f6d688b24a80 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PaddingAndApodization.h @@ -53,7 +53,7 @@ private: void init() override; void exec() override; using fptr = double (*)(const double, const double); - fptr getApodizationFunction(const std::string method); + fptr getApodizationFunction(const std::string &method); HistogramData::Histogram applyApodizationFunction(const HistogramData::Histogram &histogram, const double decayConstant, fptr function); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h index 6eab498ba75fe8dd80d32b4eca443a4fb38dbeec..d3d2bf817b965adad15b72e899cff4309ef3ebda 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ParallaxCorrection.h @@ -25,8 +25,9 @@ public: private: void init() override; void exec() override; - void performCorrection(API::MatrixWorkspace_sptr, const std::vector<size_t> &, - const std::string &, const std::string &); + void performCorrection(const API::MatrixWorkspace_sptr &, + const std::vector<size_t> &, const std::string &, + const std::string &); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Plus.h b/Framework/Algorithms/inc/MantidAlgorithms/Plus.h index 3f850d029a9d0d3c6f6d768e517cf89764496b4d..c6c7a6d1b4f9f9a4477a913d24f6a96fa26b1f54 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Plus.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Plus.h @@ -75,8 +75,8 @@ private: API::Run &ans) const override; // Overridden event-specific operation - bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const; + bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h index 92674758de7406046ad71f0c78a64074a65def45..e6586dbb8051a84ccd2389ca4279237d92925d8b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrectionFredrikze.h @@ -41,9 +41,9 @@ private: boost::shared_ptr<Mantid::API::MatrixWorkspace> getEfficiencyWorkspace(const std::string &label); boost::shared_ptr<Mantid::API::WorkspaceGroup> - execPA(boost::shared_ptr<Mantid::API::WorkspaceGroup> inWS); + execPA(const boost::shared_ptr<Mantid::API::WorkspaceGroup> &inWS); boost::shared_ptr<Mantid::API::WorkspaceGroup> - execPNR(boost::shared_ptr<Mantid::API::WorkspaceGroup> inWS); + execPNR(const boost::shared_ptr<Mantid::API::WorkspaceGroup> &inWS); boost::shared_ptr<Mantid::API::MatrixWorkspace> add(boost::shared_ptr<Mantid::API::MatrixWorkspace> &lhsWS, const double &rhs); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h index aa9679f544639a8466595cb737fd1bdf8e172278..46d3da8102a5b0fdbca9f8ff6cbe785ffcc51ab9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h @@ -45,8 +45,9 @@ private: API::MatrixWorkspace const &inWS) const; API::MatrixWorkspace_sptr convertToHistogram(API::MatrixWorkspace_sptr efficiencies); - API::MatrixWorkspace_sptr interpolate(API::MatrixWorkspace_sptr efficiencies, - API::MatrixWorkspace_sptr inWS); + API::MatrixWorkspace_sptr + interpolate(const API::MatrixWorkspace_sptr &efficiencies, + const API::MatrixWorkspace_sptr &inWS); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h b/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h index 386d8278273f295c96ca8802944ead770d3a69c3..a930255c0c5f7f5daf548b1c637190a6438bdaa6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h @@ -63,13 +63,13 @@ private: // these are the steps that are run on each individual spectrum void calculateNormalization(const size_t wavStart, const size_t wsIndex, - API::MatrixWorkspace_const_sptr pixelAdj, - API::MatrixWorkspace_const_sptr wavePixelAdj, + const API::MatrixWorkspace_const_sptr &pixelAdj, + const API::MatrixWorkspace_const_sptr &wavePixelAdj, double const *const binNorms, double const *const binNormEs, HistogramData::HistogramY::iterator norm, HistogramData::HistogramY::iterator normETo2) const; - void pixelWeight(API::MatrixWorkspace_const_sptr pixelAdj, + void pixelWeight(const API::MatrixWorkspace_const_sptr &pixelAdj, const size_t wsIndex, double &weight, double &error) const; void addWaveAdj(const double *c, const double *Dc, HistogramData::HistogramY::iterator bInOut, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h b/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h index 7404e96a708c556b9920cc92904ba3cafedbebed..a542b5ee4fc74137f0c3ae7ad33764d1bc82ca4a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h @@ -70,12 +70,12 @@ public: private: /// Create an output workspace API::MatrixWorkspace_sptr - createOutputWorkspace(API::MatrixWorkspace_const_sptr, const size_t, + createOutputWorkspace(const API::MatrixWorkspace_const_sptr &, const size_t, const std::vector<double> &); - void bootstrap(API::MatrixWorkspace_const_sptr); - void calculate(API::MatrixWorkspace_const_sptr); - void finalize(API::MatrixWorkspace_const_sptr); + void bootstrap(const API::MatrixWorkspace_const_sptr &); + void calculate(const API::MatrixWorkspace_const_sptr &); + void finalize(const API::MatrixWorkspace_const_sptr &); std::vector<std::vector<std::vector<double>>> m_intensities; std::vector<std::vector<std::vector<double>>> m_errors; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h b/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h index 53ade307e5cd607081c2e0d22875e80f7da7fbfe..30d9028be9c94cffcae53adc3909abe6684d1f43 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Qhelper.h @@ -19,22 +19,23 @@ namespace Algorithms { */ class Qhelper { public: - void examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj, - API::MatrixWorkspace_const_sptr qResolution); + void examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj, + const API::MatrixWorkspace_const_sptr &qResolution); - void examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj); + void examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj); - size_t waveLengthCutOff(API::MatrixWorkspace_const_sptr dataWS, + size_t waveLengthCutOff(const API::MatrixWorkspace_const_sptr &dataWS, const API::SpectrumInfo &spectrumInfo, const double RCut, const double WCut, const size_t wsInd) const; - void outputParts(API::Algorithm *alg, API::MatrixWorkspace_sptr sumOfCounts, - API::MatrixWorkspace_sptr sumOfNormFactors); + void outputParts(API::Algorithm *alg, + const API::MatrixWorkspace_sptr &sumOfCounts, + const API::MatrixWorkspace_sptr &sumOfNormFactors); private: /// the experimental workspace with counts across the detector diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h b/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h index f290e9fe824a963e8a292f94e866ea830072e589..49b1cef9c863c4f1c37343cc4536fcfa0292701e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h @@ -55,7 +55,7 @@ private: std::vector<double> logBinning(double min, double max, int num); API::MatrixWorkspace_sptr - setUpOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace); + setUpOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWorkspace); double getQminFromWs(const API::MatrixWorkspace &inputWorkspace); }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h b/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h index 0e216e6066955300b0e96d3c95e3d1f8d47d7bdd..1a10f80ca0ec3e26a07770a0962f7be7f2e01272 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h @@ -35,13 +35,14 @@ public: } const std::string category() const override; - static bool inputWorkspaceHasInstrumentAssociated(API::MatrixWorkspace_sptr); + static bool + inputWorkspaceHasInstrumentAssociated(const API::MatrixWorkspace_sptr &); static std::vector<double> - getBoundariesOfNumericImage(API::MatrixWorkspace_sptr); + getBoundariesOfNumericImage(const API::MatrixWorkspace_sptr &); static std::vector<double> - getBoundariesOfInstrument(API::MatrixWorkspace_sptr); + getBoundariesOfInstrument(const API::MatrixWorkspace_sptr &); static void centerIsInsideLimits(const std::vector<double> ¢re, const std::vector<double> &boundaries); @@ -71,8 +72,8 @@ private: API::MatrixWorkspace_sptr inputWS; double min_radius = 0.0, max_radius = 0.0; - double getMinBinSizeForInstrument(API::MatrixWorkspace_sptr); - double getMinBinSizeForNumericImage(API::MatrixWorkspace_sptr); + double getMinBinSizeForInstrument(const API::MatrixWorkspace_sptr &); + double getMinBinSizeForNumericImage(const API::MatrixWorkspace_sptr &); /** Return the bin position for a given distance * From the input, it is defined the limits of distances as: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h b/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h index 3c2e64c67dc51e552672a943020d0a0c04104426..d46fda033bb8af861c4b9d98804629cf29a22b9e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h @@ -76,8 +76,8 @@ protected: void init() override; void exec() override; - void propagateMasks(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, int hist); + void propagateMasks(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, int hist); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h index 78d3cef28277803663ef5a14ef6717e970daab6f..c24eb84ccb91e0b76d719ac95bec1a4240d6a300 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBackgroundSubtraction.h @@ -27,13 +27,13 @@ public: private: void - calculateAverageSpectrumBackground(API::MatrixWorkspace_sptr inputWS, + calculateAverageSpectrumBackground(const API::MatrixWorkspace_sptr &inputWS, const std::vector<specnum_t> &spectraList); void calculatePolynomialBackground(API::MatrixWorkspace_sptr inputWS, const std::vector<double> &spectrumRanges); std::vector<double> findSpectrumRanges(const std::vector<specnum_t> &spectraList); - void calculatePixelBackground(API::MatrixWorkspace_sptr inputWS, + void calculatePixelBackground(const API::MatrixWorkspace_sptr &inputWS, const std::vector<double> &indexRanges); /** Overridden Algorithm methods **/ diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h index 459e89e6862017df4caa023fa088f1f993a2fe18..9f995f2f39e101f43f4f4188f789e1bb9fdde718 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryBeamStatistics.h @@ -26,9 +26,9 @@ public: const static std::string SAMPLE_WAVINESS; const static std::string SECOND_SLIT_ANGULAR_SPREAD; }; - static double slitSeparation(Geometry::Instrument_const_sptr instrument, - const std::string &slit1Name, - const std::string &slit2Name); + static double + slitSeparation(const Geometry::Instrument_const_sptr &instrument, + const std::string &slit1Name, const std::string &slit2Name); const std::string name() const override; int version() const override; const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h index 17cc0d6f69a41441d2768f9b289d1f72cc6f2b3c..4c720c38d542fffdd6f4f3662e1164bc79462cbf 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h @@ -66,30 +66,30 @@ private: directBeamCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS); // Performs transmission or algorithm correction Mantid::API::MatrixWorkspace_sptr - transOrAlgCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS, + transOrAlgCorrection(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced); // Performs background subtraction Mantid::API::MatrixWorkspace_sptr backgroundSubtraction(Mantid::API::MatrixWorkspace_sptr detectorWS); // Performs transmission corrections Mantid::API::MatrixWorkspace_sptr - transmissionCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS, + transmissionCorrection(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced); // Performs transmission corrections using alternative correction algorithms Mantid::API::MatrixWorkspace_sptr - algorithmicCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS); + algorithmicCorrection(const Mantid::API::MatrixWorkspace_sptr &detectorWS); // Performs monitor corrections Mantid::API::MatrixWorkspace_sptr monitorCorrection(Mantid::API::MatrixWorkspace_sptr detectorWS); // convert to momentum transfer Mantid::API::MatrixWorkspace_sptr - convertToQ(Mantid::API::MatrixWorkspace_sptr inputWS); + convertToQ(const Mantid::API::MatrixWorkspace_sptr &inputWS); // Get the twoTheta width of a given detector double getDetectorTwoThetaRange(const size_t spectrumIdx); // Utility function to create name for diagnostic workspaces std::string createDebugWorkspaceName(const std::string &inputName); // Utility function to output a diagnostic workspace to the ADS - void outputDebugWorkspace(API::MatrixWorkspace_sptr ws, + void outputDebugWorkspace(const API::MatrixWorkspace_sptr &ws, const std::string &wsName, const std::string &wsSuffix, const bool debug, int &step); @@ -97,7 +97,7 @@ private: Mantid::API::MatrixWorkspace_sptr makeIvsLam(); // Do the reduction by summation in Q Mantid::API::MatrixWorkspace_sptr - sumInQ(API::MatrixWorkspace_sptr detectorWS); + sumInQ(const API::MatrixWorkspace_sptr &detectorWS); // Do the summation in Q for a single input value void sumInQProcessValue(const int inputIdx, const double twoTheta, const double bTwoTheta, @@ -106,23 +106,23 @@ private: const HistogramData::HistogramE &inputE, const std::vector<size_t> &detectors, const size_t outSpecIdx, - API::MatrixWorkspace_sptr IvsLam, + const API::MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE); // Share counts to a projected value for summation in Q void sumInQShareCounts(const double inputCounts, const double inputErr, const double bLambda, const double lambdaMin, const double lambdaMax, const size_t outSpecIdx, - API::MatrixWorkspace_sptr IvsLam, + const API::MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE); - void findWavelengthMinMax(API::MatrixWorkspace_sptr inputWS); + void findWavelengthMinMax(const API::MatrixWorkspace_sptr &inputWS); // Construct the output workspace - void findIvsLamRange(API::MatrixWorkspace_sptr detectorWS, + void findIvsLamRange(const API::MatrixWorkspace_sptr &detectorWS, const std::vector<size_t> &detectors, const double lambdaMin, const double lambdaMax, double &projectedMin, double &projectedMax); // Construct the output workspace Mantid::API::MatrixWorkspace_sptr - constructIvsLamWS(API::MatrixWorkspace_sptr detectorWS); + constructIvsLamWS(const API::MatrixWorkspace_sptr &detectorWS); // Whether summation should be done in Q or the default lambda bool summingInQ(); // Get projected coordinates onto twoThetaR @@ -132,8 +132,8 @@ private: double &lambdaTop, double &lambdaBot, const bool outerCorners = true); // Check whether two spectrum maps match - void verifySpectrumMaps(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2); + void verifySpectrumMaps(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2); // Find and cache constants void findDetectorGroups(); @@ -149,10 +149,10 @@ private: double wavelengthMax() { return m_wavelengthMax; }; size_t findIvsLamRangeMinDetector(const std::vector<size_t> &detectors); size_t findIvsLamRangeMaxDetector(const std::vector<size_t> &detectors); - double findIvsLamRangeMin(Mantid::API::MatrixWorkspace_sptr detectorWS, + double findIvsLamRangeMin(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const std::vector<size_t> &detectors, const double lambda); - double findIvsLamRangeMax(Mantid::API::MatrixWorkspace_sptr detectorWS, + double findIvsLamRangeMax(const Mantid::API::MatrixWorkspace_sptr &detectorWS, const std::vector<size_t> &detectors, const double lambda); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h index 57a153afa8a3e379759d771474e83276f4c27ec4..e769ba96ff556e4bc69d5498504155aa40b1fee2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h @@ -47,7 +47,7 @@ private: class RebinParams { public: RebinParams(const double qMin, const bool qMinIsDefault, const double qMax, - const bool qMaxIsDefault, const boost::optional<double> qStep) + const bool qMaxIsDefault, const boost::optional<double> &qStep) : m_qMin(qMin), m_qMinIsDefault(qMinIsDefault), m_qMax(qMax), m_qMaxIsDefault(qMaxIsDefault), m_qStep(qStep){}; @@ -72,33 +72,34 @@ private: void init() override; void exec() override; std::string - getRunNumberForWorkspaceGroup(WorkspaceGroup_const_sptr workspace); + getRunNumberForWorkspaceGroup(const WorkspaceGroup_const_sptr &workspace); WorkspaceNames getOutputWorkspaceNames(); void setDefaultOutputWorkspaceNames(); /// Get the name of the detectors of interest based on processing instructions std::vector<std::string> - getDetectorNames(Mantid::API::MatrixWorkspace_sptr inputWS); + getDetectorNames(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Correct detector positions vertically Mantid::API::MatrixWorkspace_sptr correctDetectorPositions(Mantid::API::MatrixWorkspace_sptr inputWS, const double twoTheta); /// Calculate theta - double calculateTheta(Mantid::API::MatrixWorkspace_sptr inputWS); + double calculateTheta(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Find cropping and binning parameters - RebinParams getRebinParams(MatrixWorkspace_sptr inputWS, const double theta); - boost::optional<double> getQStep(MatrixWorkspace_sptr inputWS, + RebinParams getRebinParams(const MatrixWorkspace_sptr &inputWS, + const double theta); + boost::optional<double> getQStep(const MatrixWorkspace_sptr &inputWS, const double theta); /// Rebin and scale a workspace in Q Mantid::API::MatrixWorkspace_sptr - rebinAndScale(Mantid::API::MatrixWorkspace_sptr inputWS, + rebinAndScale(const Mantid::API::MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms); /// Crop a workspace in Q - MatrixWorkspace_sptr cropQ(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr cropQ(const MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms); /// Populate algorithmic correction properties void populateAlgorithmicCorrectionProperties( - Mantid::API::IAlgorithm_sptr alg, - Mantid::Geometry::Instrument_const_sptr instrument); + const Mantid::API::IAlgorithm_sptr &alg, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Get a polarization efficiencies workspace. std::tuple<API::MatrixWorkspace_sptr, std::string, std::string> getPolarizationEfficiencies(); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h index 61b931ff3751ea0ce503196e59b3cbb535b6658d..7c0193309122668aab971e68b207638c5c5bd2f3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto3.h @@ -58,35 +58,37 @@ private: void init() override; void exec() override; std::string - getRunNumberForWorkspaceGroup(WorkspaceGroup_const_sptr workspace); + getRunNumberForWorkspaceGroup(const WorkspaceGroup_const_sptr &workspace); WorkspaceNames getOutputWorkspaceNames(); void setDefaultOutputWorkspaceNames(); /// Get the name of the detectors of interest based on processing instructions std::vector<std::string> - getDetectorNames(Mantid::API::MatrixWorkspace_sptr inputWS); + getDetectorNames(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Correct detector positions vertically Mantid::API::MatrixWorkspace_sptr correctDetectorPositions(Mantid::API::MatrixWorkspace_sptr inputWS, const double twoTheta); /// Calculate theta - double calculateTheta(Mantid::API::MatrixWorkspace_sptr inputWS); + double calculateTheta(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Find cropping and binning parameters - RebinParams getRebinParams(MatrixWorkspace_sptr inputWS, const double theta); - boost::optional<double> getQStep(MatrixWorkspace_sptr inputWS, + RebinParams getRebinParams(const MatrixWorkspace_sptr &inputWS, + const double theta); + boost::optional<double> getQStep(const MatrixWorkspace_sptr &inputWS, const double theta); // Optionally scale a workspace Mantid::API::MatrixWorkspace_sptr scale(Mantid::API::MatrixWorkspace_sptr inputWS); /// Rebin a workspace in Q Mantid::API::MatrixWorkspace_sptr - rebin(Mantid::API::MatrixWorkspace_sptr inputWS, const RebinParams ¶ms); + rebin(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const RebinParams ¶ms); /// Optionally crop a workspace in Q MatrixWorkspace_sptr cropQ(MatrixWorkspace_sptr inputWS, const RebinParams ¶ms); /// Populate algorithmic correction properties void populateAlgorithmicCorrectionProperties( - Mantid::API::IAlgorithm_sptr alg, - Mantid::Geometry::Instrument_const_sptr instrument); + const Mantid::API::IAlgorithm_sptr &alg, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Get a polarization efficiencies workspace. std::tuple<API::MatrixWorkspace_sptr, std::string, std::string> getPolarizationEfficiencies(); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h index 81d13a755d15f347d9890f7dd3edbbced3ee6515..f79bd7b6713a48af8941276f98d1fb4e83e4fb1d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase.h @@ -44,9 +44,9 @@ public: /// Convert the input workspace to wavelength, splitting according to the /// properties provided. DetectorMonitorWorkspacePair - toLam(Mantid::API::MatrixWorkspace_sptr toConvert, + toLam(const Mantid::API::MatrixWorkspace_sptr &toConvert, const std::string &processingCommands, - const OptionalInteger monitorIndex, const MinMax &wavelengthMinMax, + const OptionalInteger &monitorIndex, const MinMax &wavelengthMinMax, const OptionalMinMax &backgroundMinMax); /// Convert the detector spectrum of the input workspace to wavelength @@ -70,12 +70,11 @@ protected: /// Get the min/max property values MinMax getMinMax(const std::string &minProperty, const std::string &maxProperty) const; - OptionalMinMax getOptionalMinMax(Mantid::API::Algorithm *const alg, - const std::string &minProperty, - const std::string &maxProperty, - Mantid::Geometry::Instrument_const_sptr inst, - std::string minIdfName, - std::string maxIdfName) const; + OptionalMinMax getOptionalMinMax( + Mantid::API::Algorithm *const alg, const std::string &minProperty, + const std::string &maxProperty, + const Mantid::Geometry::Instrument_const_sptr &inst, + const std::string &minIdfName, const std::string &maxIdfName) const; /// Get the transmission correction properties void getTransmissionRunInfo( OptionalMatrixWorkspace_sptr &firstTransmissionRun, @@ -102,7 +101,7 @@ private: /// Convert the monitor parts of the input workspace to wavelength API::MatrixWorkspace_sptr toLamMonitor(const API::MatrixWorkspace_sptr &toConvert, - const OptionalInteger monitorIndex, + const OptionalInteger &monitorIndex, const OptionalMinMax &backgroundMinMax); /// Make a unity workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h index 9962e1cb063bbff0ed7c498595b8b20172e31371..6b28e816c9d2eef0bc15a76b301c471e22de9571 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryWorkflowBase2.h @@ -54,10 +54,10 @@ protected: std::map<std::string, std::string> validateWavelengthRanges() const; /// Convert a workspace from TOF to wavelength Mantid::API::MatrixWorkspace_sptr - convertToWavelength(Mantid::API::MatrixWorkspace_sptr inputWS); + convertToWavelength(const Mantid::API::MatrixWorkspace_sptr &inputWS); /// Crop a workspace in wavelength Mantid::API::MatrixWorkspace_sptr - cropWavelength(Mantid::API::MatrixWorkspace_sptr inputWS, + cropWavelength(const Mantid::API::MatrixWorkspace_sptr &inputWS, const bool useArgs = false, const double argMin = 0.0, const double argMax = 0.0); // Create a detector workspace from input workspace in wavelength @@ -66,43 +66,44 @@ protected: const bool convert = true, const bool sum = true); // Create a monitor workspace from input workspace in wavelength Mantid::API::MatrixWorkspace_sptr - makeMonitorWS(Mantid::API::MatrixWorkspace_sptr inputWS, + makeMonitorWS(const Mantid::API::MatrixWorkspace_sptr &inputWS, bool integratedMonitors); // Rebin detectors to monitors Mantid::API::MatrixWorkspace_sptr - rebinDetectorsToMonitors(Mantid::API::MatrixWorkspace_sptr detectorWS, - Mantid::API::MatrixWorkspace_sptr monitorWS); + rebinDetectorsToMonitors(const Mantid::API::MatrixWorkspace_sptr &detectorWS, + const Mantid::API::MatrixWorkspace_sptr &monitorWS); // Read monitor properties from instrument - void - populateMonitorProperties(Mantid::API::IAlgorithm_sptr alg, - Mantid::Geometry::Instrument_const_sptr instrument); + void populateMonitorProperties( + const Mantid::API::IAlgorithm_sptr &alg, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Populate processing instructions - std::string - findProcessingInstructions(Mantid::Geometry::Instrument_const_sptr instrument, - Mantid::API::MatrixWorkspace_sptr inputWS) const; + std::string findProcessingInstructions( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const Mantid::API::MatrixWorkspace_sptr &inputWS) const; /// Populate transmission properties - bool populateTransmissionProperties(Mantid::API::IAlgorithm_sptr alg) const; + bool + populateTransmissionProperties(const Mantid::API::IAlgorithm_sptr &alg) const; /// Find theta from a named log value - double getThetaFromLogs(Mantid::API::MatrixWorkspace_sptr inputWs, + double getThetaFromLogs(const Mantid::API::MatrixWorkspace_sptr &inputWs, const std::string &logName); // Retrieve the run number from the logs of the input workspace. std::string getRunNumber(Mantid::API::MatrixWorkspace const &ws) const; - void convertProcessingInstructions(Instrument_const_sptr instrument, - MatrixWorkspace_sptr inputWS); - void convertProcessingInstructions(MatrixWorkspace_sptr inputWS); + void convertProcessingInstructions(const Instrument_const_sptr &instrument, + const MatrixWorkspace_sptr &inputWS); + void convertProcessingInstructions(const MatrixWorkspace_sptr &inputWS); std::string m_processingInstructionsWorkspaceIndex; std::string m_processingInstructions; protected: - std::string - convertToSpectrumNumber(const std::string &workspaceIndex, - Mantid::API::MatrixWorkspace_const_sptr ws) const; + std::string convertToSpectrumNumber( + const std::string &workspaceIndex, + const Mantid::API::MatrixWorkspace_const_sptr &ws) const; std::string convertProcessingInstructionsToSpectrumNumbers( const std::string &instructions, - Mantid::API::MatrixWorkspace_const_sptr ws) const; + const Mantid::API::MatrixWorkspace_const_sptr &ws) const; - void setWorkspacePropertyFromChild(Algorithm_sptr alg, + void setWorkspacePropertyFromChild(const Algorithm_sptr &alg, std::string const &propertyName); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h b/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h index c07cf9fd8902e86dbf103d80a6c45e1956b24f6e..f39ddda72208170fb41dcb6aaf871cb725fb3632 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ResetNegatives.h @@ -30,11 +30,12 @@ public: private: void init() override; void exec() override; - void pushMinimum(API::MatrixWorkspace_const_sptr minWS, - API::MatrixWorkspace_sptr wksp, API::Progress &prog); - void changeNegatives(API::MatrixWorkspace_const_sptr minWS, + void pushMinimum(const API::MatrixWorkspace_const_sptr &minWS, + const API::MatrixWorkspace_sptr &wksp, API::Progress &prog); + void changeNegatives(const API::MatrixWorkspace_const_sptr &minWS, const double spectrumNegativeValues, - API::MatrixWorkspace_sptr wksp, API::Progress &prog); + const API::MatrixWorkspace_sptr &wksp, + API::Progress &prog); }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h b/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h index b22d34fdca63943cc502059d1337626c5b1930c0..40d04682f612dee3e4636f4a9330105366e72938 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h @@ -47,17 +47,18 @@ private: /// get the bin position for the given angle int fromAngleToBin(double angle, bool degree = true); /// validate the inputs of the algorithm for instrument based workspace - void checkInputsForSpectraWorkspace(const API::MatrixWorkspace_sptr); + void checkInputsForSpectraWorkspace(const API::MatrixWorkspace_sptr &); /// validate the inputs of the algorithm for 2d matrix based instrument - void checkInputsForNumericWorkspace(const API::MatrixWorkspace_sptr); + void checkInputsForNumericWorkspace(const API::MatrixWorkspace_sptr &); /// process ring profile for instrument based workspace - void processInstrumentRingProfile(const API::MatrixWorkspace_sptr inputWS, + void processInstrumentRingProfile(const API::MatrixWorkspace_sptr &inputWS, std::vector<double> &output_bins); /// process ring profile for image based workspace - void processNumericImageRingProfile(const API::MatrixWorkspace_sptr inputWS, + void processNumericImageRingProfile(const API::MatrixWorkspace_sptr &inputWS, std::vector<double> &output_bins); /// identify the bin position for the given pixel in the image based workspace - void getBinForPixel(const API::MatrixWorkspace_sptr, int, std::vector<int> &); + void getBinForPixel(const API::MatrixWorkspace_sptr &, int, + std::vector<int> &); //// identify the bin position for the pixel related to the given detector int getBinForPixel(const Kernel::V3D &position); /// copy of the minRadius input diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h index f4ba79010032905efcc778984225c96c8cbb8cdf..5f9c62603467ef292a74ee3260a2bc4477a748e3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h @@ -30,9 +30,9 @@ static const std::string FAIL_BEHAVIOUR = "Fail"; class MANTID_ALGORITHMS_DLL RunCombinationHelper { public: - std::string checkCompatibility(API::MatrixWorkspace_sptr, + std::string checkCompatibility(const API::MatrixWorkspace_sptr &, bool checkNumberHistograms = false); - void setReferenceProperties(API::MatrixWorkspace_sptr); + void setReferenceProperties(const API::MatrixWorkspace_sptr &); static std::vector<std::string> unWrapGroups(const std::vector<std::string> &); std::list<API::MatrixWorkspace_sptr> diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h index ef7f695bb9b2563163a724cf5efe3ba52da7bada..81a1e521e5d13da19156cec65f9c3233243e9dd1 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h @@ -69,17 +69,18 @@ public: std::string sampleLogsFailTolerances; }; - SampleLogsBehaviour(API::MatrixWorkspace_sptr ws, Kernel::Logger &logger, + SampleLogsBehaviour(const API::MatrixWorkspace_sptr &ws, + Kernel::Logger &logger, const SampleLogNames &logEntries = {}, const ParameterName &parName = {}); /// Create and update sample logs according to instrument parameters - void mergeSampleLogs(API::MatrixWorkspace_sptr addeeWS, - API::MatrixWorkspace_sptr outWS); - void setUpdatedSampleLogs(API::MatrixWorkspace_sptr outWS); - void removeSampleLogsFromWorkspace(API::MatrixWorkspace_sptr addeeWS); - void readdSampleLogToWorkspace(API::MatrixWorkspace_sptr addeeWS); - void resetSampleLogs(API::MatrixWorkspace_sptr ws); + void mergeSampleLogs(const API::MatrixWorkspace_sptr &addeeWS, + const API::MatrixWorkspace_sptr &outWS); + void setUpdatedSampleLogs(const API::MatrixWorkspace_sptr &outWS); + void removeSampleLogsFromWorkspace(const API::MatrixWorkspace_sptr &addeeWS); + void readdSampleLogToWorkspace(const API::MatrixWorkspace_sptr &addeeWS); + void resetSampleLogs(const API::MatrixWorkspace_sptr &ws); private: Kernel::Logger &m_logger; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h b/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h index 384b5ef152aeef38e70c1be9dc453950efa30c90..77290e6f4783f4aef90e6e05524bb7862e2e7e2f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SANSCollimationLengthEstimator.h @@ -15,11 +15,12 @@ namespace Mantid { namespace Algorithms { class MANTID_ALGORITHMS_DLL SANSCollimationLengthEstimator { public: - double provideCollimationLength(Mantid::API::MatrixWorkspace_sptr workspace); + double + provideCollimationLength(const Mantid::API::MatrixWorkspace_sptr &workspace); private: double getCollimationLengthWithGuides( - Mantid::API::MatrixWorkspace_sptr inOutWS, const double L1, + const Mantid::API::MatrixWorkspace_sptr &inOutWS, const double L1, const double collimationLengthCorrection) const; double getGuideValue(Mantid::Kernel::Property *prop) const; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h b/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h index 620b2eefde7be7054fedc57a6067fa268e86798c..f418bb49411b822eb7609310e82b8e07efc09d04 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MCAbsorptionStrategy.h @@ -47,7 +47,8 @@ public: Kernel::Logger &logger); void calculate(Kernel::PseudoRandomNumberGenerator &rng, const Kernel::V3D &finalPos, - Mantid::HistogramData::Points lambdas, double lambdaFixed, + const Mantid::HistogramData::Points &lambdas, + double lambdaFixed, Mantid::API::ISpectrum &attenuationFactorsSpectrum); private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h b/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h index 24e1bc56b2e064d2ae831c98db533c724aa02178..3faf5a6651ce9102e482a5bfdeeda69586ce9042 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h @@ -105,7 +105,7 @@ private: void setupNewInstrument(API::MatrixWorkspace &outws) const; /// Build the instrument/detector setup in workspace - void spreadPixels(API::MatrixWorkspace_sptr outws); + void spreadPixels(const API::MatrixWorkspace_sptr &outws); /// Non rectangular detector group name static const std::string NON_UNIFORM_GROUP; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h b/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h index aaab8d15c76b8c01e1ceb72696bb5b21405c97a2..7bcad9d82b43a12c091fa675c2757554ffb7bb7f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h @@ -65,7 +65,7 @@ private: /// Run the algorithm void exec() override; /// Init variables cache base on the given workspace - void initCachedValues(API::MatrixWorkspace_const_sptr workspace); + void initCachedValues(const API::MatrixWorkspace_const_sptr &workspace); /// Init the theta index void initThetaCache(const API::MatrixWorkspace &workspace); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h b/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h index 138f3a768338ad0c409f79af36526fd1c7b33818..c55bd2ba79f83a12ad06d1e26d8b86708628b20f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SortXAxis.h @@ -34,7 +34,7 @@ private: std::vector<std::size_t> createIndexes(const size_t); void sortIndicesByX(std::vector<std::size_t> &workspaceIndecies, - std::string order, + const std::string &order, const Mantid::API::MatrixWorkspace &inputWorkspace, unsigned int specNum); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h index 2203dc9218367fe1f487e702fb10bd4c3cb9d9e6..2a5b2f7fa4cec9b428e47cd924e6ebb1d534bd0f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionAlgorithm.h @@ -25,12 +25,12 @@ protected: SpecularReflectionAlgorithm() = default; /// Get the surface sample component - Mantid::Geometry::IComponent_const_sptr - getSurfaceSampleComponent(Mantid::Geometry::Instrument_const_sptr inst) const; + Mantid::Geometry::IComponent_const_sptr getSurfaceSampleComponent( + const Mantid::Geometry::Instrument_const_sptr &inst) const; /// Get the detector component Mantid::Geometry::IComponent_const_sptr - getDetectorComponent(Mantid::API::MatrixWorkspace_sptr workspace, + getDetectorComponent(const Mantid::API::MatrixWorkspace_sptr &workspace, const bool isPointDetector) const; /// Does the property have a default value. diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h index b3801e1e06263bd960a3ab4df37a8c77dc6a89c3..06fb59bbfaf030cff78c5e1869eab2fece74ed24 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect.h @@ -34,15 +34,15 @@ private: void exec() override; /// Correct detector positions. - void correctPosition(API::MatrixWorkspace_sptr toCorrect, + void correctPosition(const API::MatrixWorkspace_sptr &toCorrect, const double &twoThetaInDeg, - Geometry::IComponent_const_sptr sample, - Geometry::IComponent_const_sptr detector); + const Geometry::IComponent_const_sptr &sample, + const Geometry::IComponent_const_sptr &detector); /// Move detectors. - void moveDetectors(API::MatrixWorkspace_sptr toCorrect, + void moveDetectors(const API::MatrixWorkspace_sptr &toCorrect, Geometry::IComponent_const_sptr detector, - Geometry::IComponent_const_sptr sample, + const Geometry::IComponent_const_sptr &sample, const double &upOffset, const double &acrossOffset, const Mantid::Kernel::V3D &detectorPosition); }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h index f7d3b702ebcd76a1912ead03c884f612a42f4ec6..bd3f19787a9a214239eec539335f34557f5d5585 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h @@ -84,7 +84,7 @@ private: /// Mask out everything but the data in the ranges, but do it inplace. void maskInPlace(int a1, int a2, Mantid::API::MatrixWorkspace_sptr &source); /// Add back in any special values - void reinsertSpecialValues(Mantid::API::MatrixWorkspace_sptr ws); + void reinsertSpecialValues(const Mantid::API::MatrixWorkspace_sptr &ws); /// Range tolerance static const double range_tolerance; /// Scaling factors diff --git a/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h index 90e588a8845653466cd343997093f2e4da87abf5..6e5db58f75b305c5e5e2ba6ee5660377755ae11e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h @@ -62,9 +62,10 @@ private: /// Execution code void exec() override; - API::ITableWorkspace_sptr findPeaks(API::MatrixWorkspace_sptr WS); - API::MatrixWorkspace_sptr removePeaks(API::MatrixWorkspace_const_sptr input, - API::ITableWorkspace_sptr peakslist); + API::ITableWorkspace_sptr findPeaks(const API::MatrixWorkspace_sptr &WS); + API::MatrixWorkspace_sptr + removePeaks(const API::MatrixWorkspace_const_sptr &input, + const API::ITableWorkspace_sptr &peakslist); double m_maxChiSq{0.0}; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h b/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h index 81709e58b400e6bddf4acfb476a7774ffa0ee985..fc92892ce814bd106f8c7f4fa47e8a188bb95985 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h @@ -55,7 +55,7 @@ private: const int maxVal, const Kernel::TimeSeriesProperty<int> *log, std::vector<int> &Y); - void addMonitorCounts(API::ITableWorkspace_sptr outputWorkspace, + void addMonitorCounts(const API::ITableWorkspace_sptr &outputWorkspace, const Kernel::TimeSeriesProperty<int> *log, const int minVal, const int maxVal); std::vector<std::pair<std::string, const Kernel::ITimeSeriesProperty *>> diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h index cddb3e3e886a0f35101621c92b74bc80ed53b556..1c5e291c7b37bcded8ce6448e6a827a8ede5fbb3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h @@ -60,21 +60,22 @@ public: private: /// Handle logic for RebinnedOutput workspaces - void doFractionalSum(API::MatrixWorkspace_sptr outputWorkspace, + void doFractionalSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros); /// Handle logic for Workspace2D workspaces - void doSimpleSum(API::MatrixWorkspace_sptr outputWorkspace, + void doSimpleSum(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros); // Overridden Algorithm methods void init() override; void exec() override; - void execEvent(API::MatrixWorkspace_sptr outputWorkspace, + void execEvent(const API::MatrixWorkspace_sptr &outputWorkspace, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros); - specnum_t getOutputSpecNo(API::MatrixWorkspace_const_sptr localworkspace); + specnum_t + getOutputSpecNo(const API::MatrixWorkspace_const_sptr &localworkspace); API::MatrixWorkspace_sptr replaceSpecialValues(); void determineIndices(const size_t numberOfSpectra); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h index dc97f7594f4b6ce6c320a743b76ffddeab4c1747..7ab48b1ff4783dcc31ff3656b1a51b188136f941 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h @@ -58,13 +58,13 @@ private: double provideDefaultLCollimationLength( Mantid::API::MatrixWorkspace_sptr inWS) const; /// Check input - void checkInput(Mantid::API::MatrixWorkspace_sptr inWS); + void checkInput(const Mantid::API::MatrixWorkspace_sptr &inWS); /// Get the moderator workspace - Mantid::API::MatrixWorkspace_sptr - getModeratorWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace); + Mantid::API::MatrixWorkspace_sptr getModeratorWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWorkspace); /// Create an output workspace Mantid::API::MatrixWorkspace_sptr - setupOutputWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace); + setupOutputWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace); /// Wavelength resolution (constant for all wavelengths) double m_wl_resolution; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h b/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h index 595d6efe549abb41fa73f371b929b03e3d411077..6ba3418f9a37bd195bb44c8a16d4321182cb7f5e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/TimeAtSampleStrategyDirect.h @@ -23,7 +23,8 @@ class MANTID_ALGORITHMS_DLL TimeAtSampleStrategyDirect : public TimeAtSampleStrategy { public: TimeAtSampleStrategyDirect( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws, double ei); + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws, + double ei); Correction calculate(const size_t &workspace_index) const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h b/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h index 00640af1f88a275ffe82bf7a9b9f65c067c22a77..db1e2c7b70fbbc935b34627e6c516dbfcce4a3f3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h @@ -56,9 +56,10 @@ private: void exec() override; /// Create the output workspace API::MatrixWorkspace_sptr - createOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace); + createOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWorkspace); /// Return the vertical axis on the workspace, throwing if it is not valid - API::Axis *getVerticalAxis(API::MatrixWorkspace_const_sptr workspace) const; + API::Axis * + getVerticalAxis(const API::MatrixWorkspace_const_sptr &workspace) const; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h b/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h index 49c7772d6eb25cda965922d69db556ffdb3a7e06..f7888fff4df99aaee5c4645e69ebe6f9d7c484e0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h @@ -35,7 +35,7 @@ private: std::pair<double, double> getStartEnd(const Mantid::HistogramData::HistogramX &X, bool isHistogram) const; - API::MatrixWorkspace_sptr copyInput(API::MatrixWorkspace_sptr inputWS, + API::MatrixWorkspace_sptr copyInput(const API::MatrixWorkspace_sptr &inputWS, size_t wsIndex); API::MatrixWorkspace_sptr smoothSingleSpectrum(API::MatrixWorkspace_sptr inputWS, size_t wsIndex); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h b/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h index 2f6cdc8cf15749a3ed700a7d5cb1ead32a82d844..b15e66e66bc674f306118ab2f5fa4d514c3e13a0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h @@ -51,11 +51,11 @@ private: /// Override exec void exec() override; - std::size_t getNewYSize(const API::MatrixWorkspace_sptr inputWS); + std::size_t getNewYSize(const API::MatrixWorkspace_sptr &inputWS); /// Set the X data on given spectra - void setXData(API::MatrixWorkspace_sptr outputWS, - const API::MatrixWorkspace_sptr inputWS, const int index); + void setXData(const API::MatrixWorkspace_sptr &outputWS, + const API::MatrixWorkspace_sptr &inputWS, const int index); /// Flag if the X data is shared bool m_sharedX; diff --git a/Framework/Algorithms/src/AddLogDerivative.cpp b/Framework/Algorithms/src/AddLogDerivative.cpp index 2e9dc599a61f3637d6b243497cb58b128f6b94aa..a30db421d6543f1f68c0f169dfa7c5e939eb632f 100644 --- a/Framework/Algorithms/src/AddLogDerivative.cpp +++ b/Framework/Algorithms/src/AddLogDerivative.cpp @@ -103,8 +103,9 @@ Mantid::Kernel::TimeSeriesProperty<double> *AddLogDerivative::makeDerivative( DateAndTime start = input->nthTime(0); std::vector<DateAndTime> timeFull; timeFull.reserve(times.size()); - for (const double time : times) - timeFull.emplace_back(start + time); + + std::transform(times.begin(), times.end(), std::back_inserter(timeFull), + [&start](const double time) { return start + time; }); // Create the TSP out of it auto out = new TimeSeriesProperty<double>(name); diff --git a/Framework/Algorithms/src/AddSampleLog.cpp b/Framework/Algorithms/src/AddSampleLog.cpp index 3227abe3460adfbd29c90f1994a791999f79311f..4f49a04355892b673ce1e94e99a3be27d8ed30b3 100644 --- a/Framework/Algorithms/src/AddSampleLog.cpp +++ b/Framework/Algorithms/src/AddSampleLog.cpp @@ -369,7 +369,7 @@ void AddSampleLog::setTimeSeriesData(Run &run_obj, * @return */ std::vector<Types::Core::DateAndTime> -AddSampleLog::getTimes(API::MatrixWorkspace_const_sptr dataws, +AddSampleLog::getTimes(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index, bool is_epoch, bool is_second, API::Run &run_obj) { // get run start time @@ -421,7 +421,7 @@ Types::Core::DateAndTime AddSampleLog::getRunStart(API::Run &run_obj) { * @return */ std::vector<double> -AddSampleLog::getDblValues(API::MatrixWorkspace_const_sptr dataws, +AddSampleLog::getDblValues(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index) { std::vector<double> valuevec; size_t vecsize = dataws->readY(workspace_index).size(); @@ -439,7 +439,7 @@ AddSampleLog::getDblValues(API::MatrixWorkspace_const_sptr dataws, * @return */ std::vector<int> -AddSampleLog::getIntValues(API::MatrixWorkspace_const_sptr dataws, +AddSampleLog::getIntValues(const API::MatrixWorkspace_const_sptr &dataws, int workspace_index) { std::vector<int> valuevec; size_t vecsize = dataws->readY(workspace_index).size(); @@ -455,7 +455,7 @@ AddSampleLog::getIntValues(API::MatrixWorkspace_const_sptr dataws, * @param epochtime * @param timeunit */ -void AddSampleLog::getMetaData(API::MatrixWorkspace_const_sptr dataws, +void AddSampleLog::getMetaData(const API::MatrixWorkspace_const_sptr &dataws, bool &epochtime, std::string &timeunit) { bool auto_meta = getProperty("AutoMetaData"); if (auto_meta) { diff --git a/Framework/Algorithms/src/AlignDetectors.cpp b/Framework/Algorithms/src/AlignDetectors.cpp index 60d3cea2e8c0792eb6bffe881a95a55fef964619..5df9f9c859b0d9a20e38502de988ef05935727d3 100644 --- a/Framework/Algorithms/src/AlignDetectors.cpp +++ b/Framework/Algorithms/src/AlignDetectors.cpp @@ -24,6 +24,7 @@ #include <fstream> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -41,7 +42,7 @@ namespace { // anonymous namespace class ConversionFactors { public: - explicit ConversionFactors(ITableWorkspace_const_sptr table) + explicit ConversionFactors(const ITableWorkspace_const_sptr &table) : m_difcCol(table->getColumn("difc")), m_difaCol(table->getColumn("difa")), m_tzeroCol(table->getColumn("tzero")) { @@ -70,7 +71,7 @@ public: } private: - void generateDetidToRow(ITableWorkspace_const_sptr table) { + void generateDetidToRow(const ITableWorkspace_const_sptr &table) { ConstColumnVector<int> detIDs = table->getVector("detid"); const size_t numDets = detIDs.size(); for (size_t i = 0; i < numDets; ++i) { @@ -188,7 +189,7 @@ std::map<std::string, std::string> AlignDetectors::validateInputs() { return result; } -void AlignDetectors::loadCalFile(MatrixWorkspace_sptr inputWS, +void AlignDetectors::loadCalFile(const MatrixWorkspace_sptr &inputWS, const std::string &filename) { IAlgorithm_sptr alg = createChildAlgorithm("LoadDiffCal"); alg->setProperty("InputWorkspace", inputWS); @@ -202,7 +203,7 @@ void AlignDetectors::loadCalFile(MatrixWorkspace_sptr inputWS, m_calibrationWS = alg->getProperty("OutputCalWorkspace"); } -void AlignDetectors::getCalibrationWS(MatrixWorkspace_sptr inputWS) { +void AlignDetectors::getCalibrationWS(const MatrixWorkspace_sptr &inputWS) { m_calibrationWS = getProperty("CalibrationWorkspace"); if (m_calibrationWS) return; // nothing more to do @@ -220,14 +221,14 @@ void AlignDetectors::getCalibrationWS(MatrixWorkspace_sptr inputWS) { const std::string calFileName = getPropertyValue("CalibrationFile"); if (!calFileName.empty()) { progress(0.0, "Reading calibration file"); - loadCalFile(inputWS, calFileName); + loadCalFile(std::move(inputWS), calFileName); return; } throw std::runtime_error("Failed to determine calibration information"); } -void setXAxisUnits(API::MatrixWorkspace_sptr outputWS) { +void setXAxisUnits(const API::MatrixWorkspace_sptr &outputWS) { outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("dSpacing"); } diff --git a/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp b/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp index 2b555c68c0f0a059288211a2d7956ac2caa9c30f..1ec74a6976e6d04afe727f5273ea7efb658cb900 100644 --- a/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp +++ b/Framework/Algorithms/src/Bin2DPowderDiffraction.cpp @@ -365,7 +365,8 @@ size_t Bin2DPowderDiffraction::UnifyXBins( return max_size; } -void Bin2DPowderDiffraction::normalizeToBinArea(MatrixWorkspace_sptr outWS) { +void Bin2DPowderDiffraction::normalizeToBinArea( + const MatrixWorkspace_sptr &outWS) { NumericAxis *verticalAxis = dynamic_cast<NumericAxis *>(outWS->getAxis(1)); const std::vector<double> &yValues = verticalAxis->getValues(); auto nhist = outWS->getNumberHistograms(); diff --git a/Framework/Algorithms/src/BinaryOperation.cpp b/Framework/Algorithms/src/BinaryOperation.cpp index 62954e801bb067ef3d3f707004e305be19309015..df4143ea17c09bf4446ceb68024cdc061394f1ba 100644 --- a/Framework/Algorithms/src/BinaryOperation.cpp +++ b/Framework/Algorithms/src/BinaryOperation.cpp @@ -795,7 +795,8 @@ void BinaryOperation::do2D(bool mismatchedSpectra) { * @param out :: The result workspace */ void BinaryOperation::propagateBinMasks( - const API::MatrixWorkspace_const_sptr rhs, API::MatrixWorkspace_sptr out) { + const API::MatrixWorkspace_const_sptr &rhs, + const API::MatrixWorkspace_sptr &out) { const int64_t outHists = out->getNumberHistograms(); const int64_t rhsHists = rhs->getNumberHistograms(); for (int64_t i = 0; i < outHists; ++i) { @@ -876,7 +877,7 @@ void BinaryOperation::performEventBinaryOperation(DataObjects::EventList &lhs, * @return OperandType describing what type of workspace it will be operated as. */ OperandType -BinaryOperation::getOperandType(const API::MatrixWorkspace_const_sptr ws) { +BinaryOperation::getOperandType(const API::MatrixWorkspace_const_sptr &ws) { // An event workspace? EventWorkspace_const_sptr ews = boost::dynamic_pointer_cast<const EventWorkspace>(ws); diff --git a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp index c0d62145aa1d349217515905cb8c8a6151453a19..7d2997186d538952750887c6f703510d5d6b2332 100644 --- a/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp +++ b/Framework/Algorithms/src/CalculateCarpenterSampleCorrection.cpp @@ -413,7 +413,7 @@ void CalculateCarpenterSampleCorrection::calculate_ms_correction( } MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::createOutputWorkspace( - const MatrixWorkspace_sptr &inputWksp, const std::string ylabel) const { + const MatrixWorkspace_sptr &inputWksp, const std::string &ylabel) const { MatrixWorkspace_sptr outputWS = create<HistoWorkspace>(*inputWksp); // The algorithm computes the signal values at bin centres so they should // be treated as a distribution @@ -424,7 +424,7 @@ MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::createOutputWorkspace( } MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::setUncertainties( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto alg = this->createChildAlgorithm("SetUncertainties"); alg->initialize(); alg->setProperty("InputWorkspace", workspace); @@ -433,7 +433,7 @@ MatrixWorkspace_sptr CalculateCarpenterSampleCorrection::setUncertainties( } void CalculateCarpenterSampleCorrection::deleteWorkspace( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto alg = this->createChildAlgorithm("DeleteWorkspace"); alg->initialize(); alg->setChild(true); diff --git a/Framework/Algorithms/src/CalculateDynamicRange.cpp b/Framework/Algorithms/src/CalculateDynamicRange.cpp index f7a871d6b2cb0eaf7ec522a1db329a50fc2f9a44..c379339928254015cf5f4e413036607dd335d62f 100644 --- a/Framework/Algorithms/src/CalculateDynamicRange.cpp +++ b/Framework/Algorithms/src/CalculateDynamicRange.cpp @@ -73,9 +73,9 @@ void CalculateDynamicRange::init() { * @param indices : the list of workspace indices * @param compName : the name of the detector component */ -void CalculateDynamicRange::calculateQMinMax(MatrixWorkspace_sptr workspace, - const std::vector<size_t> &indices, - const std::string &compName = "") { +void CalculateDynamicRange::calculateQMinMax( + const MatrixWorkspace_sptr &workspace, const std::vector<size_t> &indices, + const std::string &compName = "") { const auto &spectrumInfo = workspace->spectrumInfo(); double min = std::numeric_limits<double>::max(), max = std::numeric_limits<double>::min(); @@ -146,9 +146,9 @@ void CalculateDynamicRange::exec() { } if (!dets.empty()) { detIDs.reserve(dets.size()); - for (const auto &det : dets) { - detIDs.emplace_back(det->getID()); - } + std::transform(dets.begin(), dets.end(), std::back_inserter(detIDs), + [](const auto &det) { return det->getID(); }); + const auto indices = workspace->getIndicesFromDetectorIDs(detIDs); calculateQMinMax(workspace, indices, compName); } diff --git a/Framework/Algorithms/src/CalculateEfficiency.cpp b/Framework/Algorithms/src/CalculateEfficiency.cpp index 84a379264dbaa8b6d0255e71e1590ce980faac7e..97d115ef78c156580aab0089f12d3389b9eae123 100644 --- a/Framework/Algorithms/src/CalculateEfficiency.cpp +++ b/Framework/Algorithms/src/CalculateEfficiency.cpp @@ -156,9 +156,9 @@ void CalculateEfficiency::exec() { * @param error: error on sum (counts) * @param nPixels: number of unmasked detector pixels that contributed to sum */ -void CalculateEfficiency::sumUnmaskedDetectors(MatrixWorkspace_sptr rebinnedWS, - double &sum, double &error, - int &nPixels) { +void CalculateEfficiency::sumUnmaskedDetectors( + const MatrixWorkspace_sptr &rebinnedWS, double &sum, double &error, + int &nPixels) { // Number of spectra const auto numberOfSpectra = static_cast<int>(rebinnedWS->getNumberHistograms()); @@ -200,11 +200,10 @@ void CalculateEfficiency::sumUnmaskedDetectors(MatrixWorkspace_sptr rebinnedWS, * @param nPixels: number of unmasked detector pixels that contributed to sum */ -void CalculateEfficiency::normalizeDetectors(MatrixWorkspace_sptr rebinnedWS, - MatrixWorkspace_sptr outputWS, - double sum, double error, - int nPixels, double min_eff, - double max_eff) { +void CalculateEfficiency::normalizeDetectors( + const MatrixWorkspace_sptr &rebinnedWS, + const MatrixWorkspace_sptr &outputWS, double sum, double error, int nPixels, + double min_eff, double max_eff) { // Number of spectra const size_t numberOfSpectra = rebinnedWS->getNumberHistograms(); @@ -337,7 +336,7 @@ void CalculateEfficiency::maskComponent(MatrixWorkspace &ws, * @param low :: number of rows to mask Bottom * @param componentName :: Must be a RectangularDetector */ -void CalculateEfficiency::maskEdges(MatrixWorkspace_sptr ws, int left, +void CalculateEfficiency::maskEdges(const MatrixWorkspace_sptr &ws, int left, int right, int high, int low, const std::string &componentName) { diff --git a/Framework/Algorithms/src/CalculateIqt.cpp b/Framework/Algorithms/src/CalculateIqt.cpp index ee3a5012c42545563e6f591fc888211a60a30327..6d18d84ed86bd681ed5024a77f975136b646a952 100644 --- a/Framework/Algorithms/src/CalculateIqt.cpp +++ b/Framework/Algorithms/src/CalculateIqt.cpp @@ -15,6 +15,7 @@ #include <boost/numeric/conversion/cast.hpp> #include <cmath> #include <functional> +#include <utility> using namespace Mantid::Algorithms; using namespace Mantid::API; @@ -90,7 +91,7 @@ allYValuesAtIndex(const std::vector<MatrixWorkspace_sptr> &workspaces, return yValues; } -int getWorkspaceNumberOfHistograms(MatrixWorkspace_sptr workspace) { +int getWorkspaceNumberOfHistograms(const MatrixWorkspace_sptr &workspace) { return boost::numeric_cast<int>(workspace->getNumberHistograms()); } @@ -172,7 +173,7 @@ std::string CalculateIqt::rebinParamsAsString() { } MatrixWorkspace_sptr CalculateIqt::monteCarloErrorCalculation( - MatrixWorkspace_sptr sample, MatrixWorkspace_sptr resolution, + const MatrixWorkspace_sptr &sample, const MatrixWorkspace_sptr &resolution, const std::string &rebinParams, const int seed, const bool calculateErrors, const int nIterations) { auto outputWorkspace = calculateIqt(sample, resolution, rebinParams); @@ -211,7 +212,7 @@ std::map<std::string, std::string> CalculateIqt::validateInputs() { return issues; } -MatrixWorkspace_sptr CalculateIqt::rebin(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr CalculateIqt::rebin(const MatrixWorkspace_sptr &workspace, const std::string ¶ms) { IAlgorithm_sptr rebinAlgorithm = this->createChildAlgorithm("Rebin"); rebinAlgorithm->initialize(); @@ -222,7 +223,8 @@ MatrixWorkspace_sptr CalculateIqt::rebin(MatrixWorkspace_sptr workspace, return rebinAlgorithm->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CalculateIqt::integration(MatrixWorkspace_sptr workspace) { +MatrixWorkspace_sptr +CalculateIqt::integration(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr integrationAlgorithm = this->createChildAlgorithm("Integration"); integrationAlgorithm->initialize(); @@ -233,7 +235,7 @@ MatrixWorkspace_sptr CalculateIqt::integration(MatrixWorkspace_sptr workspace) { } MatrixWorkspace_sptr -CalculateIqt::convertToPointData(MatrixWorkspace_sptr workspace) { +CalculateIqt::convertToPointData(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr pointDataAlgorithm = this->createChildAlgorithm("ConvertToPointData"); pointDataAlgorithm->initialize(); @@ -244,7 +246,7 @@ CalculateIqt::convertToPointData(MatrixWorkspace_sptr workspace) { } MatrixWorkspace_sptr -CalculateIqt::extractFFTSpectrum(MatrixWorkspace_sptr workspace) { +CalculateIqt::extractFFTSpectrum(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr FFTAlgorithm = this->createChildAlgorithm("ExtractFFTSpectrum"); FFTAlgorithm->initialize(); @@ -255,8 +257,9 @@ CalculateIqt::extractFFTSpectrum(MatrixWorkspace_sptr workspace) { return FFTAlgorithm->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CalculateIqt::divide(MatrixWorkspace_sptr lhsWorkspace, - MatrixWorkspace_sptr rhsWorkspace) { +MatrixWorkspace_sptr +CalculateIqt::divide(const MatrixWorkspace_sptr &lhsWorkspace, + const MatrixWorkspace_sptr &rhsWorkspace) { IAlgorithm_sptr divideAlgorithm = this->createChildAlgorithm("Divide"); divideAlgorithm->initialize(); divideAlgorithm->setProperty("LHSWorkspace", lhsWorkspace); @@ -266,8 +269,9 @@ MatrixWorkspace_sptr CalculateIqt::divide(MatrixWorkspace_sptr lhsWorkspace, return divideAlgorithm->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CalculateIqt::cropWorkspace(MatrixWorkspace_sptr workspace, - const double xMax) { +MatrixWorkspace_sptr +CalculateIqt::cropWorkspace(const MatrixWorkspace_sptr &workspace, + const double xMax) { IAlgorithm_sptr cropAlgorithm = this->createChildAlgorithm("CropWorkspace"); cropAlgorithm->initialize(); cropAlgorithm->setProperty("InputWorkspace", workspace); @@ -278,7 +282,7 @@ MatrixWorkspace_sptr CalculateIqt::cropWorkspace(MatrixWorkspace_sptr workspace, } MatrixWorkspace_sptr -CalculateIqt::replaceSpecialValues(MatrixWorkspace_sptr workspace) { +CalculateIqt::replaceSpecialValues(const MatrixWorkspace_sptr &workspace) { IAlgorithm_sptr specialValuesAlgorithm = this->createChildAlgorithm("ReplaceSpecialValues"); specialValuesAlgorithm->initialize(); @@ -311,18 +315,19 @@ CalculateIqt::normalizedFourierTransform(MatrixWorkspace_sptr workspace, MatrixWorkspace_sptr CalculateIqt::calculateIqt(MatrixWorkspace_sptr workspace, - MatrixWorkspace_sptr resolutionWorkspace, + const MatrixWorkspace_sptr &resolutionWorkspace, const std::string &rebinParams) { workspace = normalizedFourierTransform(workspace, rebinParams); - return divide(workspace, resolutionWorkspace); + return divide(workspace, std::move(resolutionWorkspace)); } MatrixWorkspace_sptr CalculateIqt::doSimulation(MatrixWorkspace_sptr sample, MatrixWorkspace_sptr resolution, const std::string &rebinParams, MersenneTwister &mTwister) { - auto simulatedWorkspace = randomizeWorkspaceWithinError(sample, mTwister); - return calculateIqt(simulatedWorkspace, resolution, rebinParams); + auto simulatedWorkspace = + randomizeWorkspaceWithinError(std::move(sample), mTwister); + return calculateIqt(simulatedWorkspace, std::move(resolution), rebinParams); } MatrixWorkspace_sptr CalculateIqt::setErrorsToStandardDeviation( diff --git a/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp b/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp index a6cf141beb0d8bf0bed171f8bebccf26c20c58b4..9db3a1f2615d036badab8c2af2e4ab020c746f40 100644 --- a/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp +++ b/Framework/Algorithms/src/CalculatePlaczekSelfScattering.cpp @@ -21,7 +21,7 @@ namespace Mantid { namespace Algorithms { std::map<std::string, std::map<std::string, double>> -getSampleSpeciesInfo(const API::MatrixWorkspace_const_sptr ws) { +getSampleSpeciesInfo(const API::MatrixWorkspace_const_sptr &ws) { // get sample information : mass, total scattering length, and concentration // of each species double totalStoich = 0.0; @@ -91,7 +91,6 @@ CalculatePlaczekSelfScattering::validateInputs() { void CalculatePlaczekSelfScattering::exec() { const API::MatrixWorkspace_sptr inWS = getProperty("InputWorkspace"); const API::MatrixWorkspace_sptr incidentWS = getProperty("IncidentSpecta"); - API::MatrixWorkspace_sptr outWS = getProperty("OutputWorkspace"); constexpr double factor = 1.0 / 1.66053906660e-27; // atomic mass unit-kilogram relationship constexpr double neutronMass = factor * 1.674927471e-27; // neutron mass @@ -99,11 +98,15 @@ void CalculatePlaczekSelfScattering::exec() { // of each species auto atomSpecies = getSampleSpeciesInfo(inWS); // calculate summation term w/ neutron mass over molecular mass ratio - double summationTerm = 0.0; - for (auto atom : atomSpecies) { - summationTerm += atom.second["concentration"] * atom.second["bSqrdBar"] * + + auto sumLambda = [&neutronMass](double sum, auto &atom) { + return sum + atom.second["concentration"] * atom.second["bSqrdBar"] * neutronMass / atom.second["mass"]; - } + }; + + double summationTerm = + std::accumulate(atomSpecies.begin(), atomSpecies.end(), 0.0, sumLambda); + // get incident spectrum and 1st derivative const MantidVec xLambda = incidentWS->readX(0); const MantidVec incident = incidentWS->readY(0); diff --git a/Framework/Algorithms/src/CalculateTransmission.cpp b/Framework/Algorithms/src/CalculateTransmission.cpp index a4534b3209f2c7b0e99310004a63eadebef37dd5..e2269b9791d5418b9ec30b5cae0413a0fe357a35 100644 --- a/Framework/Algorithms/src/CalculateTransmission.cpp +++ b/Framework/Algorithms/src/CalculateTransmission.cpp @@ -25,6 +25,7 @@ #include <boost/algorithm/string/join.hpp> #include <boost/lexical_cast.hpp> +#include <utility> namespace Mantid { namespace Algorithms { @@ -264,7 +265,7 @@ void CalculateTransmission::exec() { *execution */ API::MatrixWorkspace_sptr -CalculateTransmission::extractSpectra(API::MatrixWorkspace_sptr ws, +CalculateTransmission::extractSpectra(const API::MatrixWorkspace_sptr &ws, const std::vector<size_t> &indices) { // Compile a comma separated list of indices that we can pass to SumSpectra. std::vector<std::string> indexStrings(indices.size()); @@ -301,11 +302,11 @@ CalculateTransmission::extractSpectra(API::MatrixWorkspace_sptr ws, * execution */ API::MatrixWorkspace_sptr -CalculateTransmission::fit(API::MatrixWorkspace_sptr raw, +CalculateTransmission::fit(const API::MatrixWorkspace_sptr &raw, const std::vector<double> &rebinParams, - const std::string fitMethod) { + const std::string &fitMethod) { MatrixWorkspace_sptr output = - this->extractSpectra(raw, std::vector<size_t>(1, 0)); + this->extractSpectra(std::move(raw), std::vector<size_t>(1, 0)); Progress progress(this, m_done, 1.0, 4); progress.report("CalculateTransmission: Performing fit"); @@ -403,8 +404,8 @@ CalculateTransmission::fit(API::MatrixWorkspace_sptr raw, * @throw runtime_error if the Linear algorithm fails during execution */ API::MatrixWorkspace_sptr -CalculateTransmission::fitData(API::MatrixWorkspace_sptr WS, double &grad, - double &offset) { +CalculateTransmission::fitData(const API::MatrixWorkspace_sptr &WS, + double &grad, double &offset) { g_log.information("Fitting the experimental transmission curve"); double start = m_done; IAlgorithm_sptr childAlg = createChildAlgorithm("Fit", start, m_done + 0.9); @@ -436,7 +437,8 @@ CalculateTransmission::fitData(API::MatrixWorkspace_sptr WS, double &grad, * @param[out] coeficients of the polynomial. c[0] + c[1]x + c[2]x^2 + ... */ API::MatrixWorkspace_sptr -CalculateTransmission::fitPolynomial(API::MatrixWorkspace_sptr WS, int order, +CalculateTransmission::fitPolynomial(const API::MatrixWorkspace_sptr &WS, + int order, std::vector<double> &coeficients) { g_log.notice("Fitting the experimental transmission curve fitpolyno"); double start = m_done; @@ -473,7 +475,7 @@ CalculateTransmission::fitPolynomial(API::MatrixWorkspace_sptr WS, int order, */ API::MatrixWorkspace_sptr CalculateTransmission::rebin(const std::vector<double> &binParams, - API::MatrixWorkspace_sptr ws) { + const API::MatrixWorkspace_sptr &ws) { double start = m_done; IAlgorithm_sptr childAlg = createChildAlgorithm("Rebin", start, m_done += 0.05); @@ -493,9 +495,9 @@ CalculateTransmission::rebin(const std::vector<double> &binParams, * @param directWS :: the input direct workspace * @param index :: the index of the detector to checked */ -void CalculateTransmission::logIfNotMonitor(API::MatrixWorkspace_sptr sampleWS, - API::MatrixWorkspace_sptr directWS, - size_t index) { +void CalculateTransmission::logIfNotMonitor( + const API::MatrixWorkspace_sptr &sampleWS, + const API::MatrixWorkspace_sptr &directWS, size_t index) { const std::string message = "The detector at index " + std::to_string(index) + " is not a monitor in the "; if (!sampleWS->spectrumInfo().isMonitor(index)) diff --git a/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp b/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp index 19df98df700a5cb4e0270c17fd3b92e6e9fd60c5..2fde4715f04155e90ec6e462f9e1faf3aaac0797 100644 --- a/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp +++ b/Framework/Algorithms/src/CalculateTransmissionBeamSpreader.cpp @@ -240,8 +240,8 @@ void CalculateTransmissionBeamSpreader::exec() { * @param WS :: The workspace containing the spectrum to sum * @return A Workspace2D containing the sum */ -API::MatrixWorkspace_sptr -CalculateTransmissionBeamSpreader::sumSpectra(API::MatrixWorkspace_sptr WS) { +API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::sumSpectra( + const API::MatrixWorkspace_sptr &WS) { Algorithm_sptr childAlg = createChildAlgorithm("SumSpectra"); childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS); childAlg->setProperty<bool>("IncludeMonitors", false); @@ -255,9 +255,8 @@ CalculateTransmissionBeamSpreader::sumSpectra(API::MatrixWorkspace_sptr WS) { * @param index :: The workspace index of the spectrum to extract * @return A Workspace2D containing the extracted spectrum */ -API::MatrixWorkspace_sptr -CalculateTransmissionBeamSpreader::extractSpectrum(API::MatrixWorkspace_sptr WS, - const size_t index) { +API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::extractSpectrum( + const API::MatrixWorkspace_sptr &WS, const size_t index) { // Check that given spectra are monitors if (!WS->spectrumInfo().isMonitor(index)) { g_log.information( @@ -277,8 +276,8 @@ CalculateTransmissionBeamSpreader::extractSpectrum(API::MatrixWorkspace_sptr WS, * @param WS :: The single-spectrum workspace to fit * @return A workspace containing the fit */ -API::MatrixWorkspace_sptr -CalculateTransmissionBeamSpreader::fitToData(API::MatrixWorkspace_sptr WS) { +API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::fitToData( + const API::MatrixWorkspace_sptr &WS) { g_log.information("Fitting the experimental transmission curve"); Algorithm_sptr childAlg = createChildAlgorithm("Linear", 0.6, 1.0); childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS); diff --git a/Framework/Algorithms/src/CarpenterSampleCorrection.cpp b/Framework/Algorithms/src/CarpenterSampleCorrection.cpp index 87e2af3caa1bd3a3e7cbbd7f530cc31ec5d78f07..404c19988b3dafda7b0afa4420f5d2d7f5df965c 100644 --- a/Framework/Algorithms/src/CarpenterSampleCorrection.cpp +++ b/Framework/Algorithms/src/CarpenterSampleCorrection.cpp @@ -131,8 +131,8 @@ WorkspaceGroup_sptr CarpenterSampleCorrection::calculateCorrection( } MatrixWorkspace_sptr -CarpenterSampleCorrection::minus(const MatrixWorkspace_sptr lhsWS, - const MatrixWorkspace_sptr rhsWS) { +CarpenterSampleCorrection::minus(const MatrixWorkspace_sptr &lhsWS, + const MatrixWorkspace_sptr &rhsWS) { auto minus = this->createChildAlgorithm("Minus", 0.5, 0.75); minus->setProperty("LHSWorkspace", lhsWS); minus->setProperty("RHSWorkspace", rhsWS); @@ -142,8 +142,8 @@ CarpenterSampleCorrection::minus(const MatrixWorkspace_sptr lhsWS, } MatrixWorkspace_sptr -CarpenterSampleCorrection::multiply(const MatrixWorkspace_sptr lhsWS, - const MatrixWorkspace_sptr rhsWS) { +CarpenterSampleCorrection::multiply(const MatrixWorkspace_sptr &lhsWS, + const MatrixWorkspace_sptr &rhsWS) { auto multiply = this->createChildAlgorithm("Multiply", 0.75, 1.0); multiply->setProperty("LHSWorkspace", lhsWS); multiply->setProperty("RHSWorkspace", rhsWS); diff --git a/Framework/Algorithms/src/ChangeBinOffset.cpp b/Framework/Algorithms/src/ChangeBinOffset.cpp index aecd1761eae3c6516cba39019e888bfdd513c73f..869acd987f53bdeffead33ced7b1d1027880a323 100644 --- a/Framework/Algorithms/src/ChangeBinOffset.cpp +++ b/Framework/Algorithms/src/ChangeBinOffset.cpp @@ -54,8 +54,8 @@ void ChangeBinOffset::exec() { this->for_each<Indices::FromProperty>( *outputW, std::make_tuple(MatrixWorkspaceAccess::x), [offset](std::vector<double> &dataX) { - for (auto &x : dataX) - x += offset; + std::transform(dataX.begin(), dataX.end(), dataX.begin(), + [offset](double x) { return x + offset; }); }); } } diff --git a/Framework/Algorithms/src/ChangeTimeZero.cpp b/Framework/Algorithms/src/ChangeTimeZero.cpp index 83a54079d4d12efc0479aa87796d96612037b09e..f8375d2062a6071b66c89b2b04e28786fd13db92 100644 --- a/Framework/Algorithms/src/ChangeTimeZero.cpp +++ b/Framework/Algorithms/src/ChangeTimeZero.cpp @@ -20,6 +20,7 @@ #include <boost/lexical_cast.hpp> #include <boost/shared_ptr.hpp> +#include <utility> namespace Mantid { namespace Algorithms { @@ -82,12 +83,11 @@ void ChangeTimeZero::exec() { // Set up remaining progress points const double progressStartShiftTimeLogs = progressStopCreateOutputWs; - double progressStopShiftTimeLogs = progressStartShiftTimeLogs; - if (boost::dynamic_pointer_cast<Mantid::API::IEventWorkspace>(out_ws)) { - progressStopShiftTimeLogs = progressStartShiftTimeLogs + 0.1; - } else { - progressStopShiftTimeLogs = 1.0; - } + + double progressStopShiftTimeLogs = + boost::dynamic_pointer_cast<Mantid::API::IEventWorkspace>(out_ws) + ? progressStartShiftTimeLogs + 0.1 + : 1.0; const double progressStartShiftNeutrons = progressStopShiftTimeLogs; const double progressStopShiftNeutrons = 1.0; @@ -112,7 +112,7 @@ void ChangeTimeZero::exec() { * @returns :: pointer to the outputworkspace */ API::MatrixWorkspace_sptr -ChangeTimeZero::createOutputWS(API::MatrixWorkspace_sptr input, +ChangeTimeZero::createOutputWS(const API::MatrixWorkspace_sptr &input, double startProgress, double stopProgress) { MatrixWorkspace_sptr output = getProperty("OutputWorkspace"); // Check whether input == output to see whether a new workspace is required. @@ -135,13 +135,13 @@ ChangeTimeZero::createOutputWS(API::MatrixWorkspace_sptr input, * @param ws :: a workspace with time stamp information * @returns A time shift in seconds */ -double ChangeTimeZero::getTimeShift(API::MatrixWorkspace_sptr ws) const { +double ChangeTimeZero::getTimeShift(const API::MatrixWorkspace_sptr &ws) const { auto timeShift = m_defaultTimeShift; // Check if we are dealing with an absolute time std::string timeOffset = getProperty("AbsoluteTimeOffset"); if (isAbsoluteTimeShift(timeOffset)) { DateAndTime desiredTime(timeOffset); - DateAndTime originalTime(getStartTimeFromWorkspace(ws)); + DateAndTime originalTime(getStartTimeFromWorkspace(std::move(ws))); timeShift = DateAndTime::secondsFromDuration(desiredTime - originalTime); } else { timeShift = getProperty("RelativeTimeOffset"); @@ -156,9 +156,9 @@ double ChangeTimeZero::getTimeShift(API::MatrixWorkspace_sptr ws) const { * @param startProgress :: start point of the progress * @param stopProgress :: end point of the progress */ -void ChangeTimeZero::shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, - double timeShift, double startProgress, - double stopProgress) { +void ChangeTimeZero::shiftTimeOfLogs( + const Mantid::API::MatrixWorkspace_sptr &ws, double timeShift, + double startProgress, double stopProgress) { // We need to change the entries for each log which can be: // 1. any time series: here we change the time values // 2. string properties: here we change the values if they are ISO8601 times @@ -184,7 +184,7 @@ void ChangeTimeZero::shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, * @param timeShift :: the time shift in seconds */ void ChangeTimeZero::shiftTimeInLogForTimeSeries( - Mantid::API::MatrixWorkspace_sptr ws, Mantid::Kernel::Property *prop, + const Mantid::API::MatrixWorkspace_sptr &ws, Mantid::Kernel::Property *prop, double timeShift) const { if (auto timeSeries = dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(prop)) { @@ -216,9 +216,9 @@ void ChangeTimeZero::shiftTimeOfLogForStringProperty( * @param startProgress :: start point of the progress * @param stopProgress :: end point of the progress */ -void ChangeTimeZero::shiftTimeOfNeutrons(Mantid::API::MatrixWorkspace_sptr ws, - double timeShift, double startProgress, - double stopProgress) { +void ChangeTimeZero::shiftTimeOfNeutrons( + const Mantid::API::MatrixWorkspace_sptr &ws, double timeShift, + double startProgress, double stopProgress) { if (auto eventWs = boost::dynamic_pointer_cast<Mantid::API::IEventWorkspace>(ws)) { // Use the change pulse time algorithm to change the neutron time stamp @@ -237,8 +237,8 @@ void ChangeTimeZero::shiftTimeOfNeutrons(Mantid::API::MatrixWorkspace_sptr ws, * @param ws :: a workspace * @returns the date and time of the first good frame */ -DateAndTime -ChangeTimeZero::getStartTimeFromWorkspace(API::MatrixWorkspace_sptr ws) const { +DateAndTime ChangeTimeZero::getStartTimeFromWorkspace( + const API::MatrixWorkspace_sptr &ws) const { auto run = ws->run(); // Check for the first good frame in the log Mantid::Kernel::TimeSeriesProperty<double> *goodFrame = nullptr; @@ -318,7 +318,7 @@ std::map<std::string, std::string> ChangeTimeZero::validateInputs() { * @param val :: value to check * @return True if the string can be cast to double and otherwise false. */ -bool ChangeTimeZero::checkForDouble(std::string val) const { +bool ChangeTimeZero::checkForDouble(const std::string &val) const { auto isDouble = false; try { boost::lexical_cast<double>(val); diff --git a/Framework/Algorithms/src/CompareWorkspaces.cpp b/Framework/Algorithms/src/CompareWorkspaces.cpp index abeba3b054afba854555568e88629217ac4852e5..156043256c193b0c8571b16a52999a0a4764181e 100644 --- a/Framework/Algorithms/src/CompareWorkspaces.cpp +++ b/Framework/Algorithms/src/CompareWorkspaces.cpp @@ -262,8 +262,8 @@ bool CompareWorkspaces::processGroups() { * @param groupTwo */ void CompareWorkspaces::processGroups( - boost::shared_ptr<const API::WorkspaceGroup> groupOne, - boost::shared_ptr<const API::WorkspaceGroup> groupTwo) { + const boost::shared_ptr<const API::WorkspaceGroup> &groupOne, + const boost::shared_ptr<const API::WorkspaceGroup> &groupTwo) { // Check their sizes const auto totalNum = static_cast<size_t>(groupOne->getNumberOfEntries()); @@ -618,8 +618,8 @@ bool CompareWorkspaces::compareEventWorkspaces( * @retval true The data matches * @retval false The data does not matches */ -bool CompareWorkspaces::checkData(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkData(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { // Cache a few things for later use const size_t numHists = ws1->getNumberHistograms(); const size_t numBins = ws1->blocksize(); @@ -712,8 +712,8 @@ bool CompareWorkspaces::checkData(API::MatrixWorkspace_const_sptr ws1, * @retval true The axes match * @retval false The axes do not match */ -bool CompareWorkspaces::checkAxes(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkAxes(const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { const int numAxes = ws1->axes(); if (numAxes != ws2->axes()) { @@ -790,8 +790,8 @@ bool CompareWorkspaces::checkAxes(API::MatrixWorkspace_const_sptr ws1, /// @param ws2 :: the second sp det map /// @retval true The maps match /// @retval false The maps do not match -bool CompareWorkspaces::checkSpectraMap(MatrixWorkspace_const_sptr ws1, - MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkSpectraMap(const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { if (ws1->getNumberHistograms() != ws2->getNumberHistograms()) { recordMismatch("Number of spectra mismatch"); return false; @@ -832,8 +832,9 @@ bool CompareWorkspaces::checkSpectraMap(MatrixWorkspace_const_sptr ws1, /// @param ws2 :: the second workspace /// @retval true The instruments match /// @retval false The instruments do not match -bool CompareWorkspaces::checkInstrument(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkInstrument( + const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { // First check the name matches if (ws1->getInstrument()->getName() != ws2->getInstrument()->getName()) { g_log.debug() << "Instrument names: WS1 = " @@ -871,8 +872,9 @@ bool CompareWorkspaces::checkInstrument(API::MatrixWorkspace_const_sptr ws1, /// @param ws2 :: the second workspace /// @retval true The masking matches /// @retval false The masking does not match -bool CompareWorkspaces::checkMasking(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2) { +bool CompareWorkspaces::checkMasking( + const API::MatrixWorkspace_const_sptr &ws1, + const API::MatrixWorkspace_const_sptr &ws2) { const auto numHists = static_cast<int>(ws1->getNumberHistograms()); for (int i = 0; i < numHists; ++i) { @@ -1111,8 +1113,8 @@ void CompareWorkspaces::doPeaksComparison(PeaksWorkspace_sptr tws1, //------------------------------------------------------------------------------------------------ void CompareWorkspaces::doTableComparison( - API::ITableWorkspace_const_sptr tws1, - API::ITableWorkspace_const_sptr tws2) { + const API::ITableWorkspace_const_sptr &tws1, + const API::ITableWorkspace_const_sptr &tws2) { // First the easy things const auto numCols = tws1->columnCount(); if (numCols != tws2->columnCount()) { @@ -1177,7 +1179,8 @@ void CompareWorkspaces::doTableComparison( } //------------------------------------------------------------------------------------------------ -void CompareWorkspaces::doMDComparison(Workspace_sptr w1, Workspace_sptr w2) { +void CompareWorkspaces::doMDComparison(const Workspace_sptr &w1, + const Workspace_sptr &w2) { IMDWorkspace_sptr mdws1, mdws2; mdws1 = boost::dynamic_pointer_cast<IMDWorkspace>(w1); mdws2 = boost::dynamic_pointer_cast<IMDWorkspace>(w2); @@ -1204,7 +1207,7 @@ void CompareWorkspaces::doMDComparison(Workspace_sptr w1, Workspace_sptr w2) { * @param ws1 Name of first workspace being compared * @param ws2 Name of second workspace being compared */ -void CompareWorkspaces::recordMismatch(std::string msg, std::string ws1, +void CompareWorkspaces::recordMismatch(const std::string &msg, std::string ws1, std::string ws2) { // Workspace names default to the workspaces currently being compared if (ws1.empty()) { diff --git a/Framework/Algorithms/src/ConjoinXRuns.cpp b/Framework/Algorithms/src/ConjoinXRuns.cpp index 6af9ed086e1d9e74263b9372839a4b1535ac6de0..aa1ef64161227ec8ee7f330b940102d32d64689b 100644 --- a/Framework/Algorithms/src/ConjoinXRuns.cpp +++ b/Framework/Algorithms/src/ConjoinXRuns.cpp @@ -198,7 +198,7 @@ std::map<std::string, std::string> ConjoinXRuns::validateInputs() { * @return : empty if the log exists, is numeric, and matches the size of the * workspace, error message otherwise */ -std::string ConjoinXRuns::checkLogEntry(MatrixWorkspace_sptr ws) const { +std::string ConjoinXRuns::checkLogEntry(const MatrixWorkspace_sptr &ws) const { std::string result; if (!m_logEntry.empty()) { @@ -250,7 +250,8 @@ std::string ConjoinXRuns::checkLogEntry(MatrixWorkspace_sptr ws) const { * @param ws : the input workspace * @return : the x-axis to use for the output workspace */ -std::vector<double> ConjoinXRuns::getXAxis(MatrixWorkspace_sptr ws) const { +std::vector<double> +ConjoinXRuns::getXAxis(const MatrixWorkspace_sptr &ws) const { std::vector<double> axis; axis.reserve(ws->y(0).size()); @@ -403,7 +404,7 @@ void ConjoinXRuns::exec() { << ". Reason: \"" << e.what() << "\". Skipping.\n"; sampleLogsBehaviour.resetSampleLogs(temp); // remove the skipped one from the list - m_inputWS.erase(it); + it = m_inputWS.erase(it); --it; } else { throw std::invalid_argument(e); diff --git a/Framework/Algorithms/src/ConvertDiffCal.cpp b/Framework/Algorithms/src/ConvertDiffCal.cpp index 988c023d2488a7f7717c2f1a5a52af530feb8839..a8c0718a3f566b5c161565732086765b6e9f0b1d 100644 --- a/Framework/Algorithms/src/ConvertDiffCal.cpp +++ b/Framework/Algorithms/src/ConvertDiffCal.cpp @@ -69,7 +69,8 @@ void ConvertDiffCal::init() { * @param index * @return The proper detector id. */ -detid_t getDetID(OffsetsWorkspace_const_sptr offsetsWS, const size_t index) { +detid_t getDetID(const OffsetsWorkspace_const_sptr &offsetsWS, + const size_t index) { auto detIDs = offsetsWS->getSpectrum(index).getDetectorIDs(); if (detIDs.size() != 1) { std::stringstream msg; @@ -86,7 +87,8 @@ detid_t getDetID(OffsetsWorkspace_const_sptr offsetsWS, const size_t index) { * @param detid * @return The offset value or zero if not specified. */ -double getOffset(OffsetsWorkspace_const_sptr offsetsWS, const detid_t detid) { +double getOffset(const OffsetsWorkspace_const_sptr &offsetsWS, + const detid_t detid) { const double offset = offsetsWS->getValue(detid, 0.0); if (offset <= -1.) { // non-physical std::stringstream msg; @@ -104,7 +106,8 @@ double getOffset(OffsetsWorkspace_const_sptr offsetsWS, const detid_t detid) { * @param spectrumInfo * @return The offset adjusted value of DIFC */ -double calculateDIFC(OffsetsWorkspace_const_sptr offsetsWS, const size_t index, +double calculateDIFC(const OffsetsWorkspace_const_sptr &offsetsWS, + const size_t index, const Mantid::API::SpectrumInfo &spectrumInfo) { const detid_t detid = getDetID(offsetsWS, index); const double offset = getOffset(offsetsWS, detid); diff --git a/Framework/Algorithms/src/ConvertEmptyToTof.cpp b/Framework/Algorithms/src/ConvertEmptyToTof.cpp index 2a462a7bd7503969c2bfef90189716ef914d9885..70dd3af9bf6a278de0d8eed1fdd2a9983b08f7e7 100644 --- a/Framework/Algorithms/src/ConvertEmptyToTof.cpp +++ b/Framework/Algorithms/src/ConvertEmptyToTof.cpp @@ -500,7 +500,7 @@ std::vector<double> ConvertEmptyToTof::makeTofAxis(int epp, double epTof, } void ConvertEmptyToTof::setTofInWS(const std::vector<double> &tofAxis, - API::MatrixWorkspace_sptr outputWS) { + const API::MatrixWorkspace_sptr &outputWS) { const size_t numberOfSpectra = m_inputWS->getNumberHistograms(); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp index a3d5eda58629a8b568bbf0a36bfd2899f06a7678..4445fa6829efb517574a111caec27dd2628a7f95 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp @@ -186,7 +186,7 @@ void ConvertSpectrumAxis::exec() { double ConvertSpectrumAxis::getEfixed(const Mantid::Geometry::IDetector &detector, - MatrixWorkspace_const_sptr inputWS, + const MatrixWorkspace_const_sptr &inputWS, int emode) const { double efixed(0); double efixedProp = getProperty("Efixed"); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp index eaba2ca93a9f32bcf79ae8607132532aa28f0808..f224599c47acf85b47b190ed7c49cbdf9b3885c5 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp @@ -238,9 +238,10 @@ MatrixWorkspace_sptr ConvertSpectrumAxis2::createOutputWorkspace( create<MatrixWorkspace>(*inputWS, m_indexMap.size(), hist); std::vector<double> axis; axis.reserve(m_indexMap.size()); - for (const auto &it : m_indexMap) { - axis.emplace_back(it.first); - } + std::transform(m_indexMap.begin(), m_indexMap.end(), + std::back_inserter(axis), + [](const auto &it) { return it.first; }); + newAxis = std::make_unique<NumericAxis>(std::move(axis)); } else { // If there is no reordering we can simply clone. diff --git a/Framework/Algorithms/src/ConvertToConstantL2.cpp b/Framework/Algorithms/src/ConvertToConstantL2.cpp index d49e9e967504774b4d6b4b670e4468297d786376..d863ded28228c97068ed78e99a214fa2e8bd0f7e 100644 --- a/Framework/Algorithms/src/ConvertToConstantL2.cpp +++ b/Framework/Algorithms/src/ConvertToConstantL2.cpp @@ -141,7 +141,7 @@ void ConvertToConstantL2::exec() { * @s - input property name * */ -double ConvertToConstantL2::getRunProperty(std::string s) { +double ConvertToConstantL2::getRunProperty(const std::string &s) { const auto &run = m_inputWS->run(); if (!run.hasProperty(s)) { throw Exception::NotFoundError("Sample log property not found", s); @@ -160,7 +160,7 @@ double ConvertToConstantL2::getRunProperty(std::string s) { * @s - input property name * */ -double ConvertToConstantL2::getInstrumentProperty(std::string s) { +double ConvertToConstantL2::getInstrumentProperty(const std::string &s) { std::vector<std::string> prop = m_instrument->getStringParameter(s); if (prop.empty()) { const std::string mesg = "Property <" + s + "> doesn't exist!"; diff --git a/Framework/Algorithms/src/ConvertUnits.cpp b/Framework/Algorithms/src/ConvertUnits.cpp index df6cb856adb21f062998de1318052a535cc33c05..fd8d9fbe29039bdcb683ca6a7f24e4884432f50d 100644 --- a/Framework/Algorithms/src/ConvertUnits.cpp +++ b/Framework/Algorithms/src/ConvertUnits.cpp @@ -186,7 +186,7 @@ void ConvertUnits::exec() { * @return A pointer to a MatrixWorkspace_sptr that contains the converted units */ MatrixWorkspace_sptr -ConvertUnits::executeUnitConversion(const API::MatrixWorkspace_sptr inputWS) { +ConvertUnits::executeUnitConversion(const API::MatrixWorkspace_sptr &inputWS) { // A WS holding BinEdges cannot have less than 2 values, as a bin has // 2 edges, having less than 2 values would mean that the WS contains Points @@ -251,7 +251,7 @@ ConvertUnits::executeUnitConversion(const API::MatrixWorkspace_sptr inputWS) { * @param inputWS The input workspace */ void ConvertUnits::setupMemberVariables( - const API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { m_numberOfSpectra = inputWS->getNumberHistograms(); // In the context of this algorithm, we treat things as a distribution if // the flag is set AND the data are not dimensionless @@ -271,7 +271,7 @@ void ConvertUnits::setupMemberVariables( * @param inputWS The input workspace */ API::MatrixWorkspace_sptr ConvertUnits::setupOutputWorkspace( - const API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace"); // If input and output workspaces are NOT the same, create a new workspace @@ -328,7 +328,7 @@ void ConvertUnits::storeEModeOnWorkspace(API::MatrixWorkspace_sptr outputWS) { * @returns A shared pointer to the output workspace */ MatrixWorkspace_sptr -ConvertUnits::convertQuickly(API::MatrixWorkspace_const_sptr inputWS, +ConvertUnits::convertQuickly(const API::MatrixWorkspace_const_sptr &inputWS, const double &factor, const double &power) { Progress prog(this, 0.2, 1.0, m_numberOfSpectra); auto numberOfSpectra_i = @@ -603,7 +603,7 @@ ConvertUnits::convertViaTOF(Kernel::Unit_const_sptr fromUnit, /// Calls Rebin as a Child Algorithm to align the bins API::MatrixWorkspace_sptr -ConvertUnits::alignBins(API::MatrixWorkspace_sptr workspace) { +ConvertUnits::alignBins(const API::MatrixWorkspace_sptr &workspace) { if (communicator().size() != 1) throw std::runtime_error( "ConvertUnits: Parallel support for aligning bins not implemented."); @@ -623,7 +623,7 @@ ConvertUnits::alignBins(API::MatrixWorkspace_sptr workspace) { /// The Rebin parameters should cover the full range of the converted unit, /// with the same number of bins const std::vector<double> ConvertUnits::calculateRebinParams( - const API::MatrixWorkspace_const_sptr workspace) const { + const API::MatrixWorkspace_const_sptr &workspace) const { const auto &spectrumInfo = workspace->spectrumInfo(); // Need to loop round and find the full range double XMin = DBL_MAX, XMax = DBL_MIN; @@ -650,7 +650,7 @@ const std::vector<double> ConvertUnits::calculateRebinParams( /** Reverses the workspace if X values are in descending order * @param WS The workspace to operate on */ -void ConvertUnits::reverse(API::MatrixWorkspace_sptr WS) { +void ConvertUnits::reverse(const API::MatrixWorkspace_sptr &WS) { EventWorkspace_sptr eventWS = boost::dynamic_pointer_cast<EventWorkspace>(WS); auto isInputEvents = static_cast<bool>(eventWS); size_t numberOfSpectra = WS->getNumberHistograms(); @@ -700,7 +700,7 @@ void ConvertUnits::reverse(API::MatrixWorkspace_sptr WS) { * @return The workspace after bins have been removed */ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins( - const Mantid::API::MatrixWorkspace_const_sptr workspace) { + const Mantid::API::MatrixWorkspace_const_sptr &workspace) { MatrixWorkspace_sptr result; const auto &spectrumInfo = workspace->spectrumInfo(); @@ -786,7 +786,7 @@ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins( /** Divide by the bin width if workspace is a distribution * @param outputWS The workspace to operate on */ -void ConvertUnits::putBackBinWidth(const API::MatrixWorkspace_sptr outputWS) { +void ConvertUnits::putBackBinWidth(const API::MatrixWorkspace_sptr &outputWS) { const size_t outSize = outputWS->blocksize(); for (size_t i = 0; i < m_numberOfSpectra; ++i) { diff --git a/Framework/Algorithms/src/CopyDataRange.cpp b/Framework/Algorithms/src/CopyDataRange.cpp index f7d36388c84a8458600780d3b960aaa2388b71ae..1697ef5f70d78264c65b6b1c2b41a93fc3f5a932 100644 --- a/Framework/Algorithms/src/CopyDataRange.cpp +++ b/Framework/Algorithms/src/CopyDataRange.cpp @@ -11,6 +11,7 @@ #include "MantidKernel/BoundedValidator.h" #include <algorithm> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -18,9 +19,9 @@ using namespace Mantid::HistogramData; namespace { -void copyDataRange(MatrixWorkspace_const_sptr inputWorkspace, - MatrixWorkspace_sptr destWorkspace, int const &specMin, - int const &specMax, int const &xMinIndex, +void copyDataRange(const MatrixWorkspace_const_sptr &inputWorkspace, + const MatrixWorkspace_sptr &destWorkspace, + int const &specMin, int const &specMax, int const &xMinIndex, int const &xMaxIndex, int yInsertionIndex, int const &xInsertionIndex) { for (auto specIndex = specMin; specIndex <= specMax; ++specIndex) { @@ -36,17 +37,18 @@ void copyDataRange(MatrixWorkspace_const_sptr inputWorkspace, } } -void copyDataRange(MatrixWorkspace_const_sptr inputWorkspace, - MatrixWorkspace_sptr destWorkspace, int const &specMin, - int const &specMax, double const &xMin, double const &xMax, - int yInsertionIndex, int const &xInsertionIndex) { +void copyDataRange(const MatrixWorkspace_const_sptr &inputWorkspace, + const MatrixWorkspace_sptr &destWorkspace, + int const &specMin, int const &specMax, double const &xMin, + double const &xMax, int yInsertionIndex, + int const &xInsertionIndex) { auto const xMinIndex = static_cast<int>(inputWorkspace->yIndexOfX(xMin, 0, 0.000001)); auto const xMaxIndex = static_cast<int>(inputWorkspace->yIndexOfX(xMax, 0, 0.000001)); - copyDataRange(inputWorkspace, destWorkspace, specMin, specMax, xMinIndex, - xMaxIndex, yInsertionIndex, xInsertionIndex); + copyDataRange(inputWorkspace, std::move(destWorkspace), specMin, specMax, + xMinIndex, xMaxIndex, yInsertionIndex, xInsertionIndex); } } // namespace diff --git a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp index 5ee37f06a77ae99bb2a378a176af7e29262c2332..2916214366385107feb4465ffc8f55176c51b85a 100644 --- a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp +++ b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp @@ -157,8 +157,9 @@ void CorelliCrossCorrelate::exec() { int offset_int = getProperty("TimingOffset"); const auto offset = static_cast<int64_t>(offset_int); - for (auto &timing : tdc) - timing += offset; + + std::transform(tdc.begin(), tdc.end(), tdc.begin(), + [offset](auto timing) { return timing + offset; }); // Determine period from chopper frequency. auto motorSpeed = dynamic_cast<TimeSeriesProperty<double> *>( diff --git a/Framework/Algorithms/src/CorrectKiKf.cpp b/Framework/Algorithms/src/CorrectKiKf.cpp index 4c7d5f401a2700cb5e8a91a3181ff25b94f3dd09..c4b97099dc2fc3dc5c0859667971677049fc0ba6 100644 --- a/Framework/Algorithms/src/CorrectKiKf.cpp +++ b/Framework/Algorithms/src/CorrectKiKf.cpp @@ -220,11 +220,10 @@ void CorrectKiKf::execEvent() { PARALLEL_FOR_IF(Kernel::threadSafe(*outputWS)) for (int64_t i = 0; i < numHistograms; ++i) { PARALLEL_START_INTERUPT_REGION - - double Efi = 0; // Now get the detector object for this histogram to check if monitor // or to get Ef for indirect geometry if (emodeStr == "Indirect") { + double Efi = 0; if (efixedProp != EMPTY_DBL()) { Efi = efixedProp; // If a DetectorGroup is present should provide a value as a property @@ -279,7 +278,7 @@ void CorrectKiKf::execEvent() { template <class T> void CorrectKiKf::correctKiKfEventHelper(std::vector<T> &wevector, double efixed, - const std::string emodeStr) { + const std::string &emodeStr) { double Ei, Ef; float kioverkf; typename std::vector<T>::iterator it; diff --git a/Framework/Algorithms/src/CorrectTOFAxis.cpp b/Framework/Algorithms/src/CorrectTOFAxis.cpp index 804ec046dd07a2821332b116511fdd2d90bec2ca..c6840afcdee04eb9d86d19c62e35dc39694a7480 100644 --- a/Framework/Algorithms/src/CorrectTOFAxis.cpp +++ b/Framework/Algorithms/src/CorrectTOFAxis.cpp @@ -105,7 +105,7 @@ template <typename Map> size_t mapIndex(const int index, const Map &indexMap) { * @return A workspace index corresponding to index. */ size_t toWorkspaceIndex(const int index, const std::string &indexType, - API::MatrixWorkspace_const_sptr ws) { + const API::MatrixWorkspace_const_sptr &ws) { if (indexType == IndexTypes::DETECTOR_ID) { const auto indexMap = ws->getDetectorIDToWorkspaceIndexMap(); return mapIndex(index, indexMap); @@ -345,7 +345,8 @@ void CorrectTOFAxis::exec() { * corrected workspace. * @param outputWs The corrected workspace */ -void CorrectTOFAxis::useReferenceWorkspace(API::MatrixWorkspace_sptr outputWs) { +void CorrectTOFAxis::useReferenceWorkspace( + const API::MatrixWorkspace_sptr &outputWs) { const auto histogramCount = static_cast<int64_t>(m_referenceWs->getNumberHistograms()); PARALLEL_FOR_IF(threadSafe(*m_referenceWs, *outputWs)) @@ -377,7 +378,8 @@ void CorrectTOFAxis::useReferenceWorkspace(API::MatrixWorkspace_sptr outputWs) { * specifically, also adjusts the 'Ei' and 'wavelength' sample logs. * @param outputWs The corrected workspace */ -void CorrectTOFAxis::correctManually(API::MatrixWorkspace_sptr outputWs) { +void CorrectTOFAxis::correctManually( + const API::MatrixWorkspace_sptr &outputWs) { const auto &spectrumInfo = m_inputWs->spectrumInfo(); const double l1 = spectrumInfo.l1(); double l2 = 0; diff --git a/Framework/Algorithms/src/CorrectToFile.cpp b/Framework/Algorithms/src/CorrectToFile.cpp index a45c30bfadf39337a78ca9105230a41641145f92..8c426ffa0f5a0121d24041ff1ae316ff8b079137 100644 --- a/Framework/Algorithms/src/CorrectToFile.cpp +++ b/Framework/Algorithms/src/CorrectToFile.cpp @@ -186,8 +186,8 @@ MatrixWorkspace_sptr CorrectToFile::loadInFile(const std::string &corrFile) { * @throw NotFoundError if requested algorithm requested doesn't exist * @throw runtime_error if algorithm encounters an error */ -void CorrectToFile::doWkspAlgebra(API::MatrixWorkspace_sptr lhs, - API::MatrixWorkspace_sptr rhs, +void CorrectToFile::doWkspAlgebra(const API::MatrixWorkspace_sptr &lhs, + const API::MatrixWorkspace_sptr &rhs, const std::string &algName, API::MatrixWorkspace_sptr &result) { g_log.information() << "Initalising the algorithm " << algName << '\n'; diff --git a/Framework/Algorithms/src/CreateDummyCalFile.cpp b/Framework/Algorithms/src/CreateDummyCalFile.cpp index 5fd56a26e748e37008789383501d5c43a461ad4d..afa35e62f7bdbe3bc9c14a3b6eae47a8a534512d 100644 --- a/Framework/Algorithms/src/CreateDummyCalFile.cpp +++ b/Framework/Algorithms/src/CreateDummyCalFile.cpp @@ -110,9 +110,6 @@ void CreateDummyCalFile::exec() { std::string filename = getProperty("CalFilename"); - // Plan to overwrite file, so do not check if it exists - const bool overwrite = false; - int number = 0; Progress prog(this, 0.0, 0.8, assemblies.size()); while (!assemblies.empty()) // Travel the tree from the instrument point @@ -128,12 +125,7 @@ void CreateDummyCalFile::exec() { currentIComp); if (currentDet.get()) // Is detector { - if (overwrite) // Map will contains udet as the key - instrcalib[currentDet->getID()] = - std::make_pair(number++, top_group); - else // Map will contains the entry number as the key - instrcalib[number++] = - std::make_pair(currentDet->getID(), top_group); + instrcalib[number++] = std::make_pair(currentDet->getID(), top_group); } else // Is an assembly, push in the queue { currentchild = @@ -151,6 +143,8 @@ void CreateDummyCalFile::exec() { prog.report(); } // Write the results in a file + // Plan to overwrite file, so do not check if it exists + const bool overwrite = false; saveGroupingFile(filename, overwrite); progress(0.2); } diff --git a/Framework/Algorithms/src/CreateEPP.cpp b/Framework/Algorithms/src/CreateEPP.cpp index 285b6743a131fa0308f5f455c4d0142f35e34f9a..0efb5dc39549f1133941f5dec5dece08eeb8ed12 100644 --- a/Framework/Algorithms/src/CreateEPP.cpp +++ b/Framework/Algorithms/src/CreateEPP.cpp @@ -49,7 +49,7 @@ const static std::string STATUS("FitStatus"); * * @param ws The TableWorkspace to add the columns to. */ -void addEPPColumns(API::ITableWorkspace_sptr ws) { +void addEPPColumns(const API::ITableWorkspace_sptr &ws) { ws->addColumn("int", ColumnNames::WS_INDEX); ws->addColumn("double", ColumnNames::PEAK_CENTRE); ws->addColumn("double", ColumnNames::PEAK_CENTRE_ERR); diff --git a/Framework/Algorithms/src/CreateFloodWorkspace.cpp b/Framework/Algorithms/src/CreateFloodWorkspace.cpp index 6d281c5b536574024d7c94fb1d90bbfea6a8b6ef..c7099c8ccc6226ccfbe99f822c20cc99ac38ceee 100644 --- a/Framework/Algorithms/src/CreateFloodWorkspace.cpp +++ b/Framework/Algorithms/src/CreateFloodWorkspace.cpp @@ -129,7 +129,8 @@ std::string CreateFloodWorkspace::getBackgroundFunction() { return funMap.at(getPropertyValue(Prop::BACKGROUND)); } -MatrixWorkspace_sptr CreateFloodWorkspace::integrate(MatrixWorkspace_sptr ws) { +MatrixWorkspace_sptr +CreateFloodWorkspace::integrate(const MatrixWorkspace_sptr &ws) { auto alg = createChildAlgorithm("Integration"); alg->setProperty("InputWorkspace", ws); alg->setProperty("OutputWorkspace", "dummy"); @@ -145,7 +146,8 @@ MatrixWorkspace_sptr CreateFloodWorkspace::integrate(MatrixWorkspace_sptr ws) { return alg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CreateFloodWorkspace::transpose(MatrixWorkspace_sptr ws) { +MatrixWorkspace_sptr +CreateFloodWorkspace::transpose(const MatrixWorkspace_sptr &ws) { auto alg = createChildAlgorithm("Transpose"); alg->setProperty("InputWorkspace", ws); alg->setProperty("OutputWorkspace", "dummy"); diff --git a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp index 05cfbd7ce3a6808e63216e1b539e08ea55a47a39..14db984fea74fc7e7ca82163aa94aa3494488eb7 100644 --- a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp +++ b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp @@ -19,6 +19,7 @@ #include <boost/algorithm/string/trim.hpp> #include <fstream> #include <queue> +#include <utility> namespace { Mantid::Kernel::Logger g_log("CreateGroupingWorkspace"); @@ -207,10 +208,9 @@ std::map<detid_t, int> readGroupingFile(const std::string &groupingFileName, * @param prog Progress reporter * @returns :: Map of detector IDs to group number */ -std::map<detid_t, int> makeGroupingByNumGroups(const std::string compName, - int numGroups, - Instrument_const_sptr inst, - Progress &prog) { +std::map<detid_t, int> +makeGroupingByNumGroups(const std::string &compName, int numGroups, + const Instrument_const_sptr &inst, Progress &prog) { std::map<detid_t, int> detIDtoGroup; // Get detectors for given instument component @@ -250,14 +250,14 @@ std::map<detid_t, int> makeGroupingByNumGroups(const std::string compName, bool groupnumber(std::string groupi, std::string groupj) { int i = 0; - std::string groupName = groupi; + std::string groupName = std::move(groupi); // Take out the "group" part of the group name and convert to an int groupName.erase( remove_if(groupName.begin(), groupName.end(), std::not_fn(::isdigit)), groupName.end()); Strings::convert(groupName, i); int j = 0; - groupName = groupj; + groupName = std::move(groupj); // Take out the "group" part of the group name and convert to an int groupName.erase( remove_if(groupName.begin(), groupName.end(), std::not_fn(::isdigit)), @@ -276,7 +276,7 @@ bool groupnumber(std::string groupi, std::string groupj) { * @returns:: map of detID to group number */ std::map<detid_t, int> makeGroupingByNames(std::string GroupNames, - Instrument_const_sptr inst, + const Instrument_const_sptr &inst, Progress &prog, bool sortnames) { // This will contain the grouping std::map<detid_t, int> detIDtoGroup; @@ -432,7 +432,6 @@ void CreateGroupingWorkspace::exec() { sortnames = true; GroupNames = ""; int maxRecurseDepth = this->getProperty("MaxRecursionDepth"); - // cppcheck-suppress syntaxError PRAGMA_OMP(parallel for schedule(dynamic, 1) ) for (int num = 0; num < 300; ++num) { diff --git a/Framework/Algorithms/src/CreateLogPropertyTable.cpp b/Framework/Algorithms/src/CreateLogPropertyTable.cpp index 7b67c9e232b3f0fbd2f740f30c5b3f687041c4af..ab9cda98e3862ba327ba05bdab86b5418123cd9f 100644 --- a/Framework/Algorithms/src/CreateLogPropertyTable.cpp +++ b/Framework/Algorithms/src/CreateLogPropertyTable.cpp @@ -195,9 +195,12 @@ retrieveMatrixWsList(const std::vector<std::string> &wsNames, // Retrieve pointers to all the child workspaces. std::vector<MatrixWorkspace_sptr> childWsList; childWsList.reserve(childNames.size()); - for (const auto &childName : childNames) { - childWsList.emplace_back(ADS.retrieveWS<MatrixWorkspace>(childName)); - } + + std::transform(childNames.begin(), childNames.end(), + std::back_inserter(childWsList), + [&ADS](const auto &childName) { + return ADS.retrieveWS<MatrixWorkspace>(childName); + }); // Deal with child workspaces according to policy. switch (groupPolicy) { diff --git a/Framework/Algorithms/src/CreateLogTimeCorrection.cpp b/Framework/Algorithms/src/CreateLogTimeCorrection.cpp index 98618d4b31c737972dfa16c4722359cf12dc0c4c..9eed0c6079e0788f992f916f424545ff9b7a7d81 100644 --- a/Framework/Algorithms/src/CreateLogTimeCorrection.cpp +++ b/Framework/Algorithms/src/CreateLogTimeCorrection.cpp @@ -149,7 +149,7 @@ TableWorkspace_sptr CreateLogTimeCorrection::generateCorrectionTable( /** Write correction map to a text file */ void CreateLogTimeCorrection::writeCorrectionToFile( - const string filename, const Geometry::DetectorInfo &detectorInfo, + const string &filename, const Geometry::DetectorInfo &detectorInfo, const std::vector<double> &corrections) const { ofstream ofile; ofile.open(filename.c_str()); diff --git a/Framework/Algorithms/src/CreatePSDBleedMask.cpp b/Framework/Algorithms/src/CreatePSDBleedMask.cpp index 66f62ba851ffddbae94c7cbaeea06835aedad295..8b1aba621f7c5bdfa0ab9d455f1c90e87e9d528c 100644 --- a/Framework/Algorithms/src/CreatePSDBleedMask.cpp +++ b/Framework/Algorithms/src/CreatePSDBleedMask.cpp @@ -201,7 +201,7 @@ void CreatePSDBleedMask::exec() { */ bool CreatePSDBleedMask::performBleedTest( const std::vector<int> &tubeIndices, - API::MatrixWorkspace_const_sptr inputWS, double maxRate, + const API::MatrixWorkspace_const_sptr &inputWS, double maxRate, int numIgnoredPixels) { // Require ordered pixels so that we can define the centre. @@ -263,7 +263,7 @@ bool CreatePSDBleedMask::performBleedTest( * @param workspace :: The workspace to accumulate the masking */ void CreatePSDBleedMask::maskTube(const std::vector<int> &tubeIndices, - API::MatrixWorkspace_sptr workspace) { + const API::MatrixWorkspace_sptr &workspace) { const double deadValue(1.0); // delete the data for (auto tubeIndice : tubeIndices) { workspace->mutableY(tubeIndice)[0] = deadValue; diff --git a/Framework/Algorithms/src/CreateSampleWorkspace.cpp b/Framework/Algorithms/src/CreateSampleWorkspace.cpp index 42352e54aceb39f1958d23c79e828be2612b1e93..300a2842a67df0f4f8795979075a0ff3345ff693 100644 --- a/Framework/Algorithms/src/CreateSampleWorkspace.cpp +++ b/Framework/Algorithms/src/CreateSampleWorkspace.cpp @@ -309,7 +309,7 @@ void CreateSampleWorkspace::addChopperParameters( */ MatrixWorkspace_sptr CreateSampleWorkspace::createHistogramWorkspace( int numPixels, int numBins, int numMonitors, double x0, double binDelta, - Geometry::Instrument_sptr inst, const std::string &functionString, + const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom) { BinEdges x(numBins + 1, LinearGenerator(x0, binDelta)); @@ -330,8 +330,9 @@ MatrixWorkspace_sptr CreateSampleWorkspace::createHistogramWorkspace( /** Create scanning histogram workspace */ MatrixWorkspace_sptr CreateSampleWorkspace::createScanningWorkspace( - int numBins, double x0, double binDelta, Geometry::Instrument_sptr inst, - const std::string &functionString, bool isRandom, int numScanPoints) { + int numBins, double x0, double binDelta, + const Geometry::Instrument_sptr &inst, const std::string &functionString, + bool isRandom, int numScanPoints) { auto builder = ScanningWorkspaceBuilder(inst, numScanPoints, numBins); auto angles = std::vector<double>(); @@ -359,7 +360,7 @@ MatrixWorkspace_sptr CreateSampleWorkspace::createScanningWorkspace( */ EventWorkspace_sptr CreateSampleWorkspace::createEventWorkspace( int numPixels, int numBins, int numMonitors, int numEvents, double x0, - double binDelta, Geometry::Instrument_sptr inst, + double binDelta, const Geometry::Instrument_sptr &inst, const std::string &functionString, bool isRandom) { DateAndTime run_start("2010-01-01T00:00:00"); diff --git a/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp b/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp index 1a51af9c5f506c85fe783215ef6542eb52917a47..a4332c2603fa162fd8a4e7fc64ecc3c7053f0e6e 100644 --- a/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp +++ b/Framework/Algorithms/src/CreateTransmissionWorkspace.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/CreateTransmissionWorkspace.h" +#include <utility> + #include "MantidAPI/BoostOptionalToAlgorithmProperty.h" +#include "MantidAlgorithms/CreateTransmissionWorkspace.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/WorkspaceUnitValidator.h" @@ -154,7 +156,7 @@ MatrixWorkspace_sptr CreateTransmissionWorkspace::makeTransmissionCorrection( const OptionalMinMax &wavelengthMonitorBackgroundInterval, const OptionalMinMax &wavelengthMonitorIntegrationInterval, const OptionalInteger &i0MonitorIndex, - MatrixWorkspace_sptr firstTransmissionRun, + const MatrixWorkspace_sptr &firstTransmissionRun, OptionalMatrixWorkspace_sptr secondTransmissionRun, const OptionalDouble &stitchingStart, const OptionalDouble &stitchingDelta, const OptionalDouble &stitchingEnd, @@ -163,7 +165,7 @@ MatrixWorkspace_sptr CreateTransmissionWorkspace::makeTransmissionCorrection( /*make struct of optional inputs to refactor method arguments*/ /*make a using statements defining OptionalInteger for MonitorIndex*/ auto trans1InLam = - toLam(firstTransmissionRun, processingCommands, i0MonitorIndex, + toLam(std::move(firstTransmissionRun), processingCommands, i0MonitorIndex, wavelengthInterval, wavelengthMonitorBackgroundInterval); MatrixWorkspace_sptr trans1Detector = trans1InLam.get<0>(); MatrixWorkspace_sptr trans1Monitor = trans1InLam.get<1>(); diff --git a/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp b/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp index 5010dbffc411acf4e0c3251357f0de21919d4b6d..bf6b018ee136954709a06d22ac9d7b870ace1616 100644 --- a/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp +++ b/Framework/Algorithms/src/CreateTransmissionWorkspace2.cpp @@ -183,7 +183,7 @@ void CreateTransmissionWorkspace2::exec() { * @return :: the normalized workspace in Wavelength */ MatrixWorkspace_sptr CreateTransmissionWorkspace2::normalizeDetectorsByMonitors( - const MatrixWorkspace_sptr IvsTOF) { + const MatrixWorkspace_sptr &IvsTOF) { // Detector workspace MatrixWorkspace_sptr detectorWS = makeDetectorWS(IvsTOF); @@ -249,7 +249,7 @@ CreateTransmissionWorkspace2::getRunNumber(std::string const &propertyName) { * @param ws A workspace to store. */ void CreateTransmissionWorkspace2::setOutputTransmissionRun( - int which, MatrixWorkspace_sptr ws) { + int which, const MatrixWorkspace_sptr &ws) { bool const isDebug = getProperty("Debug"); if (!isDebug) return; @@ -291,7 +291,7 @@ void CreateTransmissionWorkspace2::setOutputTransmissionRun( * be found */ void CreateTransmissionWorkspace2::setOutputWorkspace( - API::MatrixWorkspace_sptr ws) { + const API::MatrixWorkspace_sptr &ws) { // If the user provided an output name, just set the value if (!isDefault("OutputWorkspace")) { setProperty("OutputWorkspace", ws); diff --git a/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp b/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp index 8ada727d00476c6646852d37ac65f5d9bb51911b..132efa67800b69173914c73520fef9b296d7ae90 100644 --- a/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp +++ b/Framework/Algorithms/src/CreateTransmissionWorkspaceAuto.cpp @@ -240,7 +240,7 @@ void CreateTransmissionWorkspaceAuto::exec() { template <typename T> boost::optional<T> -CreateTransmissionWorkspaceAuto::isSet(std::string propName) const { +CreateTransmissionWorkspaceAuto::isSet(const std::string &propName) const { auto algProperty = this->getPointerToProperty(propName); if (algProperty->isDefault()) { return boost::optional<T>(); diff --git a/Framework/Algorithms/src/DetectorDiagnostic.cpp b/Framework/Algorithms/src/DetectorDiagnostic.cpp index e46cd0743cea4dba5dbf07d9f8aa3c980eb9d959..816779e650d9caf470a175c147bc72aa836a483f 100644 --- a/Framework/Algorithms/src/DetectorDiagnostic.cpp +++ b/Framework/Algorithms/src/DetectorDiagnostic.cpp @@ -376,8 +376,8 @@ void DetectorDiagnostic::exec() { * @param inputWS : the workspace to mask * @param maskWS : the workspace containing the masking information */ -void DetectorDiagnostic::applyMask(API::MatrixWorkspace_sptr inputWS, - API::MatrixWorkspace_sptr maskWS) { +void DetectorDiagnostic::applyMask(const API::MatrixWorkspace_sptr &inputWS, + const API::MatrixWorkspace_sptr &maskWS) { IAlgorithm_sptr maskAlg = createChildAlgorithm("MaskDetectors"); // should set progress bar maskAlg->setProperty("Workspace", inputWS); @@ -394,7 +394,7 @@ void DetectorDiagnostic::applyMask(API::MatrixWorkspace_sptr inputWS, * @return : the resulting mask from the checks */ API::MatrixWorkspace_sptr -DetectorDiagnostic::doDetVanTest(API::MatrixWorkspace_sptr inputWS, +DetectorDiagnostic::doDetVanTest(const API::MatrixWorkspace_sptr &inputWS, int &nFails) { MatrixWorkspace_sptr localMask; @@ -483,7 +483,7 @@ DetectorDiagnostic::DetectorDiagnostic() * @returns A workspace containing the integrated counts */ MatrixWorkspace_sptr DetectorDiagnostic::integrateSpectra( - MatrixWorkspace_sptr inputWS, const int indexMin, const int indexMax, + const MatrixWorkspace_sptr &inputWS, const int indexMin, const int indexMax, const double lower, const double upper, const bool outputWorkspace2D) { g_log.debug() << "Integrating input spectra.\n"; // If the input spectra only has one bin, assume it has been integrated @@ -525,8 +525,8 @@ MatrixWorkspace_sptr DetectorDiagnostic::integrateSpectra( * @param inputWS The workspace to initialize from. The instrument is copied *from this. */ -DataObjects::MaskWorkspace_sptr -DetectorDiagnostic::generateEmptyMask(API::MatrixWorkspace_const_sptr inputWS) { +DataObjects::MaskWorkspace_sptr DetectorDiagnostic::generateEmptyMask( + const API::MatrixWorkspace_const_sptr &inputWS) { // Create a new workspace for the results, copy from the input to ensure that // we copy over the instrument and current masking auto maskWS = @@ -547,7 +547,7 @@ DetectorDiagnostic::makeInstrumentMap(const API::MatrixWorkspace &countsWS) { * */ std::vector<std::vector<size_t>> -DetectorDiagnostic::makeMap(API::MatrixWorkspace_sptr countsWS) { +DetectorDiagnostic::makeMap(const API::MatrixWorkspace_sptr &countsWS) { std::multimap<Mantid::Geometry::ComponentID, size_t> mymap; Geometry::Instrument_const_sptr instrument = countsWS->getInstrument(); diff --git a/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp b/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp index 6192db26833a047ddd1ec0080ed8a24c037bd02e..cba50b3442bef9daebb8d77a581afc220e176cff 100644 --- a/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp +++ b/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp @@ -187,8 +187,8 @@ void DetectorEfficiencyVariation::retrieveProperties( * @return number of detectors for which tests failed */ int DetectorEfficiencyVariation::doDetectorTests( - API::MatrixWorkspace_const_sptr counts1, - API::MatrixWorkspace_const_sptr counts2, const double average, + const API::MatrixWorkspace_const_sptr &counts1, + const API::MatrixWorkspace_const_sptr &counts2, const double average, double variation) { // DIAG in libISIS did this. A variation of less than 1 doesn't make sense in // this algorithm diff --git a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp index be8054b8933e2ccc4f4deb43781d2c7123c16a0e..de4557eec625df285d7391efc920046c35d6705a 100644 --- a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp +++ b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp @@ -84,7 +84,7 @@ static double gsl_costFunction(const gsl_vector *v, void *params) { void DiffractionEventCalibrateDetectors::movedetector( double x, double y, double z, double rotx, double roty, double rotz, - std::string detname, EventWorkspace_sptr inputW) { + const std::string &detname, const EventWorkspace_sptr &inputW) { IAlgorithm_sptr alg1 = createChildAlgorithm("MoveInstrumentComponent"); alg1->setProperty<EventWorkspace_sptr>("Workspace", inputW); @@ -145,8 +145,9 @@ void DiffractionEventCalibrateDetectors::movedetector( double DiffractionEventCalibrateDetectors::intensity( double x, double y, double z, double rotx, double roty, double rotz, - std::string detname, std::string inname, std::string outname, - std::string peakOpt, std::string rb_param, std::string groupWSName) { + const std::string &detname, const std::string &inname, + const std::string &outname, const std::string &peakOpt, + const std::string &rb_param, const std::string &groupWSName) { EventWorkspace_sptr inputW = boost::dynamic_pointer_cast<EventWorkspace>( AnalysisDataService::Instance().retrieve(inname)); diff --git a/Framework/Algorithms/src/DiffractionFocussing.cpp b/Framework/Algorithms/src/DiffractionFocussing.cpp index 7afe73b2de87d698c371b4032961288b7bfbda32..94c575cc38c61dedb943269f0443cce7d80724b5 100644 --- a/Framework/Algorithms/src/DiffractionFocussing.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing.cpp @@ -241,7 +241,7 @@ void DiffractionFocussing::calculateRebinParams( * @throws FileError if can't read the file */ std::multimap<int64_t, int64_t> -DiffractionFocussing::readGroupingFile(std::string groupingFileName) { +DiffractionFocussing::readGroupingFile(const std::string &groupingFileName) { std::ifstream grFile(groupingFileName.c_str()); if (!grFile) { g_log.error() << "Unable to open grouping file " << groupingFileName diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index 8c204e9af1314722ed368c1d36617d2fbda4dc55..9444e68fa4a1f5bafa614f234e02e9047297eeae 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -590,11 +590,10 @@ void DiffractionFocussing2::determineRebinParameters() { nGroups = group2minmax.size(); // Number of unique groups - double Xmin, Xmax, step; const int64_t xPoints = nPoints + 1; - // Iterator over all groups to create the new X vectors - for (gpit = group2minmax.begin(); gpit != group2minmax.end(); gpit++) { + for (gpit = group2minmax.begin(); gpit != group2minmax.end(); ++gpit) { + double Xmin, Xmax, step; Xmin = (gpit->second).first; Xmax = (gpit->second).second; diff --git a/Framework/Algorithms/src/EQSANSCorrectFrame.cpp b/Framework/Algorithms/src/EQSANSCorrectFrame.cpp index 58b64d47ad6e9ccb13b0de4ed246874a091bc9e1..b7cebbb4dec62beba0e4382b054a5078f1db1ed2 100644 --- a/Framework/Algorithms/src/EQSANSCorrectFrame.cpp +++ b/Framework/Algorithms/src/EQSANSCorrectFrame.cpp @@ -95,11 +95,11 @@ void EQSANSCorrectFrame::exec() { double newTOF = tof + m_framesOffsetTime; // TOF values smaller than that of the fastest neutrons have been // 'folded' by the data acquisition system. They must be shifted - double minTOF = m_minTOF * pathToPixelFactor; - if (newTOF < minTOF) + double scaledMinTOF = m_minTOF * pathToPixelFactor; + if (newTOF < scaledMinTOF) newTOF += m_frameWidth; // Events from the skipped pulse are delayed by one pulse period - if (m_isFrameSkipping && newTOF > minTOF + m_pulsePeriod) + if (m_isFrameSkipping && newTOF > scaledMinTOF + m_pulsePeriod) newTOF += m_pulsePeriod; return newTOF; } diff --git a/Framework/Algorithms/src/EQSANSTofStructure.cpp b/Framework/Algorithms/src/EQSANSTofStructure.cpp index 4f03cdac926b30d04a497a991def598ea2dcba07..b7c89f3708e672944c39092f05946a29a03f28e8 100644 --- a/Framework/Algorithms/src/EQSANSTofStructure.cpp +++ b/Framework/Algorithms/src/EQSANSTofStructure.cpp @@ -118,7 +118,7 @@ void EQSANSTofStructure::exec() { } void EQSANSTofStructure::execEvent( - Mantid::DataObjects::EventWorkspace_sptr inputWS, double threshold, + const Mantid::DataObjects::EventWorkspace_sptr &inputWS, double threshold, double frame_offset, double tof_frame_width, double tmp_frame_width, bool frame_skipping) { const size_t numHists = inputWS->getNumberHistograms(); @@ -190,8 +190,9 @@ void EQSANSTofStructure::execEvent( PARALLEL_CHECK_INTERUPT_REGION } -double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, - bool frame_skipping) { +double +EQSANSTofStructure::getTofOffset(const EventWorkspace_const_sptr &inputWS, + bool frame_skipping) { //# Storage for chopper information read from the logs double chopper_set_phase[4] = {0, 0, 0, 0}; double chopper_speed[4] = {0, 0, 0, 0}; diff --git a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp index 7efca9a462b0c7fc0fece03b652cf87cef0fb43d..8b373182922ca145651ee606d0a179d342707147 100644 --- a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp +++ b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp @@ -131,7 +131,7 @@ void ExportTimeSeriesLog::exec() { * @param cal_first_deriv :: flag to calcualte the first derivative */ void ExportTimeSeriesLog::exportLog(const std::string &logname, - const std::string timeunit, + const std::string &timeunit, const double &starttime, const double &stoptime, const bool exportepoch, bool outputeventws, diff --git a/Framework/Algorithms/src/ExtractMaskToTable.cpp b/Framework/Algorithms/src/ExtractMaskToTable.cpp index 112ea04cd6be0ae6aa7f01125498a77c539459b9..d3fbe14f280df1eefe255a5e907734678c30a64e 100644 --- a/Framework/Algorithms/src/ExtractMaskToTable.cpp +++ b/Framework/Algorithms/src/ExtractMaskToTable.cpp @@ -124,7 +124,7 @@ void ExtractMaskToTable::exec() { * @returns :: vector of detector IDs that are masked */ std::vector<detid_t> ExtractMaskToTable::parseMaskTable( - DataObjects::TableWorkspace_sptr masktablews) { + const DataObjects::TableWorkspace_sptr &masktablews) { // Output vector std::vector<detid_t> maskeddetectorids; @@ -174,7 +174,7 @@ std::vector<detid_t> ExtractMaskToTable::parseMaskTable( * @returns :: vector genrated from input string containing the list */ std::vector<detid_t> -ExtractMaskToTable::parseStringToVector(std::string liststr) { +ExtractMaskToTable::parseStringToVector(const std::string &liststr) { std::vector<detid_t> detidvec; // Use ArrayProperty to parse the list @@ -264,7 +264,7 @@ std::vector<detid_t> ExtractMaskToTable::extractMaskFromMaskWorkspace() { * @param targetWS :: table workspace to which the content is copied; */ void ExtractMaskToTable::copyTableWorkspaceContent( - TableWorkspace_sptr sourceWS, TableWorkspace_sptr targetWS) { + const TableWorkspace_sptr &sourceWS, const TableWorkspace_sptr &targetWS) { // Compare the column names. They must be exactly the same vector<string> sourcecolnames = sourceWS->getColumnNames(); vector<string> targetcolnames = targetWS->getColumnNames(); @@ -310,7 +310,7 @@ void ExtractMaskToTable::copyTableWorkspaceContent( * @param xmax :: maximum x * @param prevmaskedids :: vector of previous masked detector IDs */ -void ExtractMaskToTable::addToTableWorkspace(TableWorkspace_sptr outws, +void ExtractMaskToTable::addToTableWorkspace(const TableWorkspace_sptr &outws, vector<detid_t> maskeddetids, double xmin, double xmax, vector<detid_t> prevmaskedids) { diff --git a/Framework/Algorithms/src/FindPeaks.cpp b/Framework/Algorithms/src/FindPeaks.cpp index 726c8055ad69f1bae83c8b749133bd7d65f41ae3..f3e7414505010263d2773512fc243ac38eb61595 100644 --- a/Framework/Algorithms/src/FindPeaks.cpp +++ b/Framework/Algorithms/src/FindPeaks.cpp @@ -1508,8 +1508,8 @@ void FindPeaks::createFunctions() { */ double FindPeaks::callFitPeak(const MatrixWorkspace_sptr &dataws, int wsindex, - const API::IPeakFunction_sptr peakfunction, - const API::IBackgroundFunction_sptr backgroundfunction, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &backgroundfunction, const std::vector<double> &vec_fitwindow, const std::vector<double> &vec_peakrange, int minGuessFWHM, int maxGuessFWHM, int guessedFWHMStep, diff --git a/Framework/Algorithms/src/FitPeak.cpp b/Framework/Algorithms/src/FitPeak.cpp index 7710091f923cff2128aebdab3e2b3b580a9bf8d1..98a8764daf55ae1b5fd8590e5d721425961cd5c2 100644 --- a/Framework/Algorithms/src/FitPeak.cpp +++ b/Framework/Algorithms/src/FitPeak.cpp @@ -7,7 +7,8 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidAlgorithms/FitPeak.h" +#include <utility> + #include "MantidAPI/CompositeFunction.h" #include "MantidAPI/CostFunctionFactory.h" #include "MantidAPI/FuncMinimizerFactory.h" @@ -17,6 +18,7 @@ #include "MantidAPI/MultiDomainFunction.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceProperty.h" +#include "MantidAlgorithms/FitPeak.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceCreation.h" @@ -62,7 +64,7 @@ FitOneSinglePeak::FitOneSinglePeak() //---------------------------------------------------------------------------------------------- /** Set workspaces */ -void FitOneSinglePeak::setWorskpace(API::MatrixWorkspace_sptr dataws, +void FitOneSinglePeak::setWorskpace(const API::MatrixWorkspace_sptr &dataws, size_t wsindex) { if (dataws) { m_dataWS = dataws; @@ -80,8 +82,8 @@ void FitOneSinglePeak::setWorskpace(API::MatrixWorkspace_sptr dataws, //---------------------------------------------------------------------------------------------- /** Set peaks */ -void FitOneSinglePeak::setFunctions(IPeakFunction_sptr peakfunc, - IBackgroundFunction_sptr bkgdfunc) { +void FitOneSinglePeak::setFunctions(const IPeakFunction_sptr &peakfunc, + const IBackgroundFunction_sptr &bkgdfunc) { if (peakfunc) m_peakFunc = peakfunc; @@ -129,8 +131,8 @@ void FitOneSinglePeak::setPeakRange(double xpeakleft, double xpeakright) { * @param costfunction :: string of the name of the cost function */ void FitOneSinglePeak::setFittingMethod(std::string minimizer, - std::string costfunction) { - m_minimizer = minimizer; + const std::string &costfunction) { + m_minimizer = std::move(minimizer); if (costfunction == "Chi-Square") { m_costFunction = "Least squares"; } else if (costfunction == "Rwp") { @@ -387,8 +389,9 @@ API::MatrixWorkspace_sptr FitOneSinglePeak::genFitWindowWS() { /** Estimate the peak height from a set of data containing pure peaks */ double FitOneSinglePeak::estimatePeakHeight( - API::IPeakFunction_const_sptr peakfunc, MatrixWorkspace_sptr dataws, - size_t wsindex, size_t ixmin, size_t ixmax) { + const API::IPeakFunction_const_sptr &peakfunc, + const MatrixWorkspace_sptr &dataws, size_t wsindex, size_t ixmin, + size_t ixmax) { // Get current peak height: from current peak centre (previously setup) double peakcentre = peakfunc->centre(); vector<double> svvec(1, peakcentre); @@ -424,7 +427,8 @@ double FitOneSinglePeak::estimatePeakHeight( /** Make a pure peak WS in the fit window region from m_background_function * @param purePeakWS :: workspace containing pure peak (w/ background removed) */ -void FitOneSinglePeak::removeBackground(MatrixWorkspace_sptr purePeakWS) { +void FitOneSinglePeak::removeBackground( + const MatrixWorkspace_sptr &purePeakWS) { // Calculate background // FIXME - This can be costly to use FunctionDomain and FunctionValue auto &vecX = purePeakWS->x(0); @@ -449,10 +453,10 @@ void FitOneSinglePeak::removeBackground(MatrixWorkspace_sptr purePeakWS) { * some fit with unphysical result. * @return :: chi-square/Rwp */ -double FitOneSinglePeak::fitPeakFunction(API::IPeakFunction_sptr peakfunc, - MatrixWorkspace_sptr dataws, - size_t wsindex, double startx, - double endx) { +double +FitOneSinglePeak::fitPeakFunction(const API::IPeakFunction_sptr &peakfunc, + const MatrixWorkspace_sptr &dataws, + size_t wsindex, double startx, double endx) { // Check validity and debug output if (!peakfunc) throw std::runtime_error( @@ -461,7 +465,8 @@ double FitOneSinglePeak::fitPeakFunction(API::IPeakFunction_sptr peakfunc, m_sstream << "Function (to fit): " << peakfunc->asString() << " From " << startx << " to " << endx << ".\n"; - double goodness = fitFunctionSD(peakfunc, dataws, wsindex, startx, endx); + double goodness = + fitFunctionSD(peakfunc, std::move(dataws), wsindex, startx, endx); return goodness; } @@ -574,7 +579,7 @@ void FitOneSinglePeak::highBkgdFit() { * @returns :: map to store function parameter's names and value */ std::map<std::string, double> -FitOneSinglePeak::backup(IFunction_const_sptr func) { +FitOneSinglePeak::backup(const IFunction_const_sptr &func) { std::map<std::string, double> funcparammap; // Set up @@ -614,7 +619,7 @@ FitOneSinglePeak::storeFunctionError(const IFunction_const_sptr &func) { /** Restore the parameters value to a function from a string/double map */ void FitOneSinglePeak::pop(const std::map<std::string, double> &funcparammap, - API::IFunction_sptr func) { + const API::IFunction_sptr &func) { std::map<std::string, double>::const_iterator miter; for (miter = funcparammap.begin(); miter != funcparammap.end(); ++miter) { string parname = miter->first; @@ -633,8 +638,8 @@ void FitOneSinglePeak::pop(const std::map<std::string, double> &funcparammap, * @param xmax * @return */ -double FitOneSinglePeak::calChiSquareSD(IFunction_sptr fitfunc, - MatrixWorkspace_sptr dataws, +double FitOneSinglePeak::calChiSquareSD(const IFunction_sptr &fitfunc, + const MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax) { // Set up sub algorithm fit @@ -675,7 +680,7 @@ double FitOneSinglePeak::calChiSquareSD(IFunction_sptr fitfunc, * return DBL_MAX */ double FitOneSinglePeak::fitFunctionSD(IFunction_sptr fitfunc, - MatrixWorkspace_sptr dataws, + const MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, double xmax) { // Set up sub algorithm fit @@ -733,8 +738,8 @@ double FitOneSinglePeak::fitFunctionSD(IFunction_sptr fitfunc, * @param vec_xmin :: minimin values of domains * @param vec_xmax :: maximim values of domains */ -double FitOneSinglePeak::fitFunctionMD(IFunction_sptr fitfunc, - MatrixWorkspace_sptr dataws, +double FitOneSinglePeak::fitFunctionMD(const IFunction_sptr &fitfunc, + const MatrixWorkspace_sptr &dataws, size_t wsindex, vector<double> vec_xmin, vector<double> vec_xmax) { // Validate @@ -823,8 +828,9 @@ double FitOneSinglePeak::fitFunctionMD(IFunction_sptr fitfunc, * @return :: Rwp/chi2 */ double FitOneSinglePeak::fitCompositeFunction( - API::IPeakFunction_sptr peakfunc, API::IBackgroundFunction_sptr bkgdfunc, - API::MatrixWorkspace_sptr dataws, size_t wsindex, double startx, + const API::IPeakFunction_sptr &peakfunc, + const API::IBackgroundFunction_sptr &bkgdfunc, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double startx, double endx) { // Construct composit function boost::shared_ptr<CompositeFunction> compfunc = @@ -883,7 +889,7 @@ double FitOneSinglePeak::fitCompositeFunction( /** Check the fitted peak value to see whether it is valid * @return :: Rwp/chi2 */ -double FitOneSinglePeak::checkFittedPeak(IPeakFunction_sptr peakfunc, +double FitOneSinglePeak::checkFittedPeak(const IPeakFunction_sptr &peakfunc, double costfuncvalue, std::string &errorreason) { if (costfuncvalue < DBL_MAX) { @@ -1234,7 +1240,7 @@ void FitPeak::exec() { /** Add function's parameter names after peak function name */ std::vector<std::string> -FitPeak::addFunctionParameterNames(std::vector<std::string> funcnames) { +FitPeak::addFunctionParameterNames(const std::vector<std::string> &funcnames) { vector<string> vec_funcparnames; for (auto &funcname : funcnames) { @@ -1599,9 +1605,11 @@ size_t getIndex(const HistogramX &vecx, double x) { //---------------------------------------------------------------------------------------------- /** Generate table workspace */ -TableWorkspace_sptr FitPeak::genOutputTableWS( - IPeakFunction_sptr peakfunc, map<string, double> peakerrormap, - IBackgroundFunction_sptr bkgdfunc, map<string, double> bkgderrormap) { +TableWorkspace_sptr +FitPeak::genOutputTableWS(const IPeakFunction_sptr &peakfunc, + map<string, double> peakerrormap, + const IBackgroundFunction_sptr &bkgdfunc, + map<string, double> bkgderrormap) { // Empty table TableWorkspace_sptr outtablews = boost::make_shared<TableWorkspace>(); outtablews->addColumn("str", "Name"); diff --git a/Framework/Algorithms/src/FitPeaks.cpp b/Framework/Algorithms/src/FitPeaks.cpp index 3db4f98a3d2589b55507c51209d63f1ee68a445e..17a439ef3d196662fdb83562f5fc85ece8f2e052 100644 --- a/Framework/Algorithms/src/FitPeaks.cpp +++ b/Framework/Algorithms/src/FitPeaks.cpp @@ -34,6 +34,7 @@ #include "boost/algorithm/string.hpp" #include "boost/algorithm/string/trim.hpp" #include <limits> +#include <utility> using namespace Mantid; using namespace Mantid::API; @@ -148,7 +149,7 @@ double PeakFitResult::getCost(size_t ipeak) const { return m_costs[ipeak]; } /// set the peak fitting record/parameter for one peak void PeakFitResult::setRecord(size_t ipeak, const double cost, const double peak_position, - const FitFunction fit_functions) { + const FitFunction &fit_functions) { // check input if (ipeak >= m_costs.size()) throw std::runtime_error("Peak index is out of range."); @@ -1026,7 +1027,7 @@ double numberCounts(const Histogram &histogram, const double xmin, */ void FitPeaks::fitSpectrumPeaks( size_t wi, const std::vector<double> &expected_peak_centers, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result) { + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result) { if (numberCounts(m_inputMatrixWS->histogram(wi)) <= m_minPeakHeight) { for (size_t i = 0; i < fit_result->getNumberPeaks(); ++i) fit_result->setBadRecord(i, -1.); @@ -1131,7 +1132,8 @@ void FitPeaks::fitSpectrumPeaks( * @return :: flag whether the peak width shall be observed */ bool FitPeaks::decideToEstimatePeakParams( - const bool firstPeakInSpectrum, API::IPeakFunction_sptr peak_function) { + const bool firstPeakInSpectrum, + const API::IPeakFunction_sptr &peak_function) { // should observe the peak width if the user didn't supply all of the peak // function parameters bool observe_peak_shape(m_initParamIndexes.size() != @@ -1173,8 +1175,8 @@ bool FitPeaks::decideToEstimatePeakParams( void FitPeaks::processSinglePeakFitResult( size_t wsindex, size_t peakindex, const double cost, const std::vector<double> &expected_peak_positions, - FitPeaksAlgorithm::FitFunction fitfunction, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result) { + const FitPeaksAlgorithm::FitFunction &fitfunction, + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result) { // determine peak position tolerance double postol(DBL_MAX); bool case23(false); @@ -1403,9 +1405,9 @@ vector<double> calculateMomentsAboutMean(const Histogram &histogram, * First, algorithm FindPeakBackground will be tried; * If it fails, then a linear background estimator will be called. */ -void FitPeaks::estimateBackground(const Histogram &histogram, - const std::pair<double, double> &peak_window, - API::IBackgroundFunction_sptr bkgd_function) { +void FitPeaks::estimateBackground( + const Histogram &histogram, const std::pair<double, double> &peak_window, + const API::IBackgroundFunction_sptr &bkgd_function) { if (peak_window.first >= peak_window.second) throw std::runtime_error("Invalid peak window"); @@ -1440,8 +1442,9 @@ void FitPeaks::estimateBackground(const Histogram &histogram, */ int FitPeaks::estimatePeakParameters( const Histogram &histogram, const std::pair<double, double> &peak_window, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunction, bool observe_peak_width) { + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunction, + bool observe_peak_width) { // get the range of start and stop to construct a function domain const auto &vector_x = histogram.points(); @@ -1608,7 +1611,7 @@ double FitPeaks::observePeakWidth(const Histogram &histogram, bool FitPeaks::fitBackground(const size_t &ws_index, const std::pair<double, double> &fit_window, const double &expected_peak_pos, - API::IBackgroundFunction_sptr bkgd_func) { + const API::IBackgroundFunction_sptr &bkgd_func) { // find out how to fit background const auto &points = m_inputMatrixWS->histogram(ws_index).points(); @@ -1656,12 +1659,13 @@ bool FitPeaks::fitBackground(const size_t &ws_index, //---------------------------------------------------------------------------------------------- /** Fit an individual peak */ -double FitPeaks::fitIndividualPeak(size_t wi, API::IAlgorithm_sptr fitter, - const double expected_peak_center, - const std::pair<double, double> &fitwindow, - const bool observe_peak_params, - API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc) { +double +FitPeaks::fitIndividualPeak(size_t wi, const API::IAlgorithm_sptr &fitter, + const double expected_peak_center, + const std::pair<double, double> &fitwindow, + const bool observe_peak_params, + const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc) { double cost(DBL_MAX); // confirm that there is something to fit @@ -1690,14 +1694,12 @@ double FitPeaks::fitIndividualPeak(size_t wi, API::IAlgorithm_sptr fitter, * This is the core fitting algorithm to deal with the simplest situation * @exception :: Fit.isExecuted is false (cannot be executed) */ -double FitPeaks::fitFunctionSD(IAlgorithm_sptr fit, - API::IPeakFunction_sptr peak_function, - API::IBackgroundFunction_sptr bkgd_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - double xmin, double xmax, - const double &expected_peak_center, - bool observe_peak_shape, - bool estimate_background) { +double FitPeaks::fitFunctionSD( + const IAlgorithm_sptr &fit, const API::IPeakFunction_sptr &peak_function, + const API::IBackgroundFunction_sptr &bkgd_function, + const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double xmin, + double xmax, const double &expected_peak_center, bool observe_peak_shape, + bool estimate_background) { std::stringstream errorid; errorid << "(WorkspaceIndex=" << wsindex << " PeakCentre=" << expected_peak_center << ")"; @@ -1769,7 +1771,6 @@ double FitPeaks::fitFunctionSD(IAlgorithm_sptr fit, errorid << ": " << e.what(); g_log.warning() << "While fitting " + errorid.str(); return DBL_MAX; // probably the wrong thing to do - throw std::runtime_error("While fitting " + errorid.str()); } // Retrieve result @@ -1784,8 +1785,8 @@ double FitPeaks::fitFunctionSD(IAlgorithm_sptr fit, //---------------------------------------------------------------------------------------------- double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function, - API::MatrixWorkspace_sptr dataws, size_t wsindex, - std::vector<double> &vec_xmin, + const API::MatrixWorkspace_sptr &dataws, + size_t wsindex, std::vector<double> &vec_xmin, std::vector<double> &vec_xmax) { // Validate if (vec_xmin.size() != vec_xmax.size()) @@ -1845,7 +1846,6 @@ double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function, double chi2 = DBL_MAX; if (fitStatus == "success") { chi2 = fit->getProperty("OutputChi2overDoF"); - fit_function = fit->getProperty("Function"); } return chi2; @@ -1854,10 +1854,10 @@ double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function, //---------------------------------------------------------------------------------------------- /// Fit peak with high background double FitPeaks::fitFunctionHighBackground( - IAlgorithm_sptr fit, const std::pair<double, double> &fit_window, + const IAlgorithm_sptr &fit, const std::pair<double, double> &fit_window, const size_t &ws_index, const double &expected_peak_center, - bool observe_peak_shape, API::IPeakFunction_sptr peakfunction, - API::IBackgroundFunction_sptr bkgdfunc) { + bool observe_peak_shape, const API::IPeakFunction_sptr &peakfunction, + const API::IBackgroundFunction_sptr &bkgdfunc) { // high background to reduce API::IBackgroundFunction_sptr high_bkgd_function(nullptr); if (m_linearBackgroundFunction) @@ -1881,9 +1881,8 @@ double FitPeaks::fitFunctionHighBackground( createMatrixWorkspace(vec_x, vec_y, vec_e); // Fit peak with background - double cost = fitFunctionSD(fit, peakfunction, bkgdfunc, reduced_bkgd_ws, 0, - vec_x.front(), vec_x.back(), expected_peak_center, - observe_peak_shape, false); + fitFunctionSD(fit, peakfunction, bkgdfunc, reduced_bkgd_ws, 0, vec_x.front(), + vec_x.back(), expected_peak_center, observe_peak_shape, false); // add the reduced background back bkgdfunc->setParameter(0, bkgdfunc->getParameter(0) + @@ -1891,9 +1890,9 @@ double FitPeaks::fitFunctionHighBackground( bkgdfunc->setParameter(1, bkgdfunc->getParameter(1) + high_bkgd_function->getParameter(1)); - cost = fitFunctionSD(fit, peakfunction, bkgdfunc, m_inputMatrixWS, ws_index, - vec_x.front(), vec_x.back(), expected_peak_center, false, - false); + double cost = fitFunctionSD(fit, peakfunction, bkgdfunc, m_inputMatrixWS, + ws_index, vec_x.front(), vec_x.back(), + expected_peak_center, false, false); return cost; } @@ -1954,7 +1953,7 @@ void FitPeaks::generateOutputPeakPositionWS() { * @param with_chi2:: flag to append chi^2 to the table */ void FitPeaks::setupParameterTableWorkspace( - API::ITableWorkspace_sptr table_ws, + const API::ITableWorkspace_sptr &table_ws, const std::vector<std::string> ¶m_names, bool with_chi2) { // add columns @@ -2063,7 +2062,7 @@ void FitPeaks::processOutputs( // optional if (m_fittedPeakWS && m_fittedParamTable) { g_log.debug("about to calcualte fitted peaks"); - calculateFittedPeaks(fit_result_vec); + calculateFittedPeaks(std::move(fit_result_vec)); setProperty(PropertyNames::OUTPUT_WKSP_MODEL, m_fittedPeakWS); } } @@ -2215,9 +2214,9 @@ void FitPeaks::getRangeData(size_t iws, * @param vec_x :: vector of X valye * @param vec_y :: (input/output) vector Y to be reduced by background function */ -void FitPeaks::reduceByBackground(API::IBackgroundFunction_sptr bkgd_func, - const std::vector<double> &vec_x, - std::vector<double> &vec_y) { +void FitPeaks::reduceByBackground( + const API::IBackgroundFunction_sptr &bkgd_func, + const std::vector<double> &vec_x, std::vector<double> &vec_y) { // calculate the background FunctionDomain1DVector vectorx(vec_x.begin(), vec_x.end()); FunctionValues vector_bkgd(vectorx); @@ -2278,7 +2277,7 @@ void FitPeaks::estimateLinearBackground(const Histogram &histogram, */ void FitPeaks::writeFitResult( size_t wi, const std::vector<double> &expected_positions, - boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> fit_result) { + const boost::shared_ptr<FitPeaksAlgorithm::PeakFitResult> &fit_result) { // convert to size_t out_wi = wi - m_startWorkspaceIndex; if (out_wi >= m_outputPeakPositionWorkspace->getNumberHistograms()) { @@ -2395,7 +2394,7 @@ void FitPeaks::writeFitResult( //---------------------------------------------------------------------------------------------- std::string FitPeaks::getPeakHeightParameterName( - API::IPeakFunction_const_sptr peak_function) { + const API::IPeakFunction_const_sptr &peak_function) { std::string height_name(""); std::vector<std::string> peak_parameters = peak_function->getParameterNames(); diff --git a/Framework/Algorithms/src/GenerateEventsFilter.cpp b/Framework/Algorithms/src/GenerateEventsFilter.cpp index 653f4cfb2c8e91df2c5fe40399845b40fd76e7ad..2e0de3025f26870196ec34f3889188d602cddaa4 100644 --- a/Framework/Algorithms/src/GenerateEventsFilter.cpp +++ b/Framework/Algorithms/src/GenerateEventsFilter.cpp @@ -18,6 +18,7 @@ #include "MantidKernel/VisibleWhenProperty.h" #include <boost/math/special_functions/round.hpp> +#include <utility> using namespace Mantid; using namespace Mantid::Kernel; @@ -455,10 +456,9 @@ void GenerateEventsFilter::setFilterByTimeOnly() { int64_t curtime_ns = m_startTime.totalNanoseconds(); int wsindex = 0; while (curtime_ns < m_stopTime.totalNanoseconds()) { - int64_t deltatime_ns; for (size_t id = 0; id < numtimeintervals; ++id) { // get next time interval value - deltatime_ns = vec_dtimens[id]; + int64_t deltatime_ns = vec_dtimens[id]; // Calculate next.time int64_t nexttime_ns = curtime_ns + deltatime_ns; bool breaklater = false; @@ -500,7 +500,7 @@ void GenerateEventsFilter::setFilterByTimeOnly() { /** Generate filters by log values. * @param logname :: name of the log to filter with */ -void GenerateEventsFilter::setFilterByLogValue(std::string logname) { +void GenerateEventsFilter::setFilterByLogValue(const std::string &logname) { // Obtain reference of sample log to filter with m_dblLog = dynamic_cast<TimeSeriesProperty<double> *>( m_dataWS->run().getProperty(logname)); @@ -830,7 +830,6 @@ void GenerateEventsFilter::makeFilterBySingleValue( // Initialize control parameters bool lastGood = false; - bool isGood = false; time_duration tol = DateAndTime::durationFromSeconds(TimeTolerance); int numgood = 0; DateAndTime lastTime, currT; @@ -843,8 +842,8 @@ void GenerateEventsFilter::makeFilterBySingleValue( currT = m_dblLog->nthTime(i); // A good value? - isGood = identifyLogEntry(i, currT, lastGood, min, max, startTime, stopTime, - filterIncrease, filterDecrease); + bool isGood = identifyLogEntry(i, currT, lastGood, min, max, startTime, + stopTime, filterIncrease, filterDecrease); if (isGood) numgood++; @@ -962,7 +961,7 @@ bool GenerateEventsFilter::identifyLogEntry( * @param stopTime :: Stop time. */ void GenerateEventsFilter::makeMultipleFiltersByValues( - map<size_t, int> indexwsindexmap, vector<double> logvalueranges, + map<size_t, int> indexwsindexmap, const vector<double> &logvalueranges, bool centre, bool filterIncrease, bool filterDecrease, DateAndTime startTime, DateAndTime stopTime) { g_log.notice("Starting method 'makeMultipleFiltersByValues'. "); @@ -994,8 +993,9 @@ void GenerateEventsFilter::makeMultipleFiltersByValues( auto iend = static_cast<int>(logsize - 1); makeMultipleFiltersByValuesPartialLog( - istart, iend, m_vecSplitterTime, m_vecSplitterGroup, indexwsindexmap, - logvalueranges, tol, filterIncrease, filterDecrease, startTime, stopTime); + istart, iend, m_vecSplitterTime, m_vecSplitterGroup, + std::move(indexwsindexmap), logvalueranges, tol, filterIncrease, + filterDecrease, startTime, stopTime); progress(1.0); } @@ -1018,9 +1018,9 @@ void GenerateEventsFilter::makeMultipleFiltersByValues( * @param stopTime :: Stop time. */ void GenerateEventsFilter::makeMultipleFiltersByValuesParallel( - map<size_t, int> indexwsindexmap, vector<double> logvalueranges, - bool centre, bool filterIncrease, bool filterDecrease, - DateAndTime startTime, DateAndTime stopTime) { + const map<size_t, int> &indexwsindexmap, + const vector<double> &logvalueranges, bool centre, bool filterIncrease, + bool filterDecrease, DateAndTime startTime, DateAndTime stopTime) { // Return if the log is empty. int logsize = m_dblLog->size(); if (logsize == 0) { @@ -1178,7 +1178,7 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesParallel( void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( int istart, int iend, std::vector<Types::Core::DateAndTime> &vecSplitTime, std::vector<int> &vecSplitGroup, map<size_t, int> indexwsindexmap, - const vector<double> &logvalueranges, time_duration tol, + const vector<double> &logvalueranges, const time_duration &tol, bool filterIncrease, bool filterDecrease, DateAndTime startTime, DateAndTime stopTime) { // Check @@ -1217,7 +1217,6 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( double currValue = m_dblLog->nthValue(i); // Filter out by time and direction (optional) - bool intime = true; if (currTime < startTime) { // case i. Too early, do nothing createsplitter = false; @@ -1252,130 +1251,127 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( prevDirection = direction; // Examine log value for filter - if (intime) { - // Determine whether direction is fine - bool correctdir = true; - if (filterIncrease && filterDecrease) { - // Both direction is fine + // Determine whether direction is fine + bool correctdir = true; + if (filterIncrease && filterDecrease) { + // Both direction is fine + correctdir = true; + } else { + // Filter out one direction + if (filterIncrease && direction > 0) correctdir = true; - } else { - // Filter out one direction - if (filterIncrease && direction > 0) - correctdir = true; - else if (filterDecrease && direction < 0) - correctdir = true; - else if (direction == 0) - throw runtime_error("Direction is not determined."); - else - correctdir = false; - } // END-IF-ELSE: Direction - - // Treat the log entry based on: changing direction (+ time range) - if (correctdir) { - // Check this value whether it falls into any range - size_t index = searchValue(logvalueranges, currValue); - - bool valueWithinMinMax = true; - if (index > logvalueranges.size()) { - // Out of range - valueWithinMinMax = false; - } + else if (filterDecrease && direction < 0) + correctdir = true; + else if (direction == 0) + throw runtime_error("Direction is not determined."); + else + correctdir = false; + } // END-IF-ELSE: Direction + + // Treat the log entry based on: changing direction (+ time range) + if (correctdir) { + // Check this value whether it falls into any range + size_t index = searchValue(logvalueranges, currValue); + + bool valueWithinMinMax = true; + if (index > logvalueranges.size()) { + // Out of range + valueWithinMinMax = false; + } - if (g_log.is(Logger::Priority::PRIO_DEBUG)) { - stringstream dbss; - dbss << "[DBx257] Examine Log Index " << i - << ", Value = " << currValue << ", Data Range Index = " << index - << "; " - << "Group Index = " << indexwsindexmap[index / 2] - << " (log value range vector size = " << logvalueranges.size() - << "): "; - if (index == 0) - dbss << logvalueranges[index] << ", " << logvalueranges[index + 1]; - else if (index == logvalueranges.size()) - dbss << logvalueranges[index - 1] << ", " << logvalueranges[index]; - else if (valueWithinMinMax) - dbss << logvalueranges[index - 1] << ", " << logvalueranges[index] - << ", " << logvalueranges[index + 1]; - g_log.debug(dbss.str()); - } + if (g_log.is(Logger::Priority::PRIO_DEBUG)) { + stringstream dbss; + dbss << "[DBx257] Examine Log Index " << i << ", Value = " << currValue + << ", Data Range Index = " << index << "; " + << "Group Index = " << indexwsindexmap[index / 2] + << " (log value range vector size = " << logvalueranges.size() + << "): "; + if (index == 0) + dbss << logvalueranges[index] << ", " << logvalueranges[index + 1]; + else if (index == logvalueranges.size()) + dbss << logvalueranges[index - 1] << ", " << logvalueranges[index]; + else if (valueWithinMinMax) + dbss << logvalueranges[index - 1] << ", " << logvalueranges[index] + << ", " << logvalueranges[index + 1]; + g_log.debug(dbss.str()); + } - if (valueWithinMinMax) { - if (index % 2 == 0) { - // [Situation] Falls in the interval - currindex = indexwsindexmap[index / 2]; - - if (currindex != lastindex && start.totalNanoseconds() == 0) { - // Group index is different from last and start is not set up: new - // a region! - newsplitter = true; - } else if (currindex != lastindex && start.totalNanoseconds() > 0) { - // Group index is different from last and start is set up: close - // a region and new a region + if (valueWithinMinMax) { + if (index % 2 == 0) { + // [Situation] Falls in the interval + currindex = indexwsindexmap[index / 2]; + + if (currindex != lastindex && start.totalNanoseconds() == 0) { + // Group index is different from last and start is not set up: new + // a region! + newsplitter = true; + } else if (currindex != lastindex && start.totalNanoseconds() > 0) { + // Group index is different from last and start is set up: close + // a region and new a region + stop = currTime; + createsplitter = true; + newsplitter = true; + } else if (currindex == lastindex && start.totalNanoseconds() > 0) { + // Still of the group index + if (i == iend) { + // Last entry in this section of log. Need to flag to close the + // pair stop = currTime; createsplitter = true; - newsplitter = true; - } else if (currindex == lastindex && start.totalNanoseconds() > 0) { - // Still of the group index - if (i == iend) { - // Last entry in this section of log. Need to flag to close the - // pair - stop = currTime; - createsplitter = true; - newsplitter = false; - } else { - // Do nothing - ; - } + newsplitter = false; } else { - // An impossible situation - std::stringstream errmsg; - double lastvalue = m_dblLog->nthValue(i - 1); - errmsg << "Impossible to have currindex == lastindex == " - << currindex - << ", while start is not init. Log Index = " << i - << "\t value = " << currValue << "\t, Index = " << index - << " in range " << logvalueranges[index] << ", " - << logvalueranges[index + 1] - << "; Last value = " << lastvalue; - throw std::runtime_error(errmsg.str()); + // Do nothing + ; } - } // [In-bound: Inside interval] - else { - // [Situation] Fall between interval (which is not likley happen) - currindex = -1; - g_log.warning() - << "Not likely to happen! Current value = " << currValue - << " is within value range but its index = " << index - << " has no map to group index. " - << "\n"; - if (start.totalNanoseconds() > 0) { - // Close the interval pair if it has been started. - stop = currTime; - createsplitter = true; - } - } // [In-bound: Between interval] - } else { - // Out of a range: check whether there is a splitter started + } else { + // An impossible situation + std::stringstream errmsg; + double lastvalue = m_dblLog->nthValue(i - 1); + errmsg << "Impossible to have currindex == lastindex == " + << currindex + << ", while start is not init. Log Index = " << i + << "\t value = " << currValue << "\t, Index = " << index + << " in range " << logvalueranges[index] << ", " + << logvalueranges[index + 1] + << "; Last value = " << lastvalue; + throw std::runtime_error(errmsg.str()); + } + } // [In-bound: Inside interval] + else { + // [Situation] Fall between interval (which is not likley happen) currindex = -1; + g_log.warning() << "Not likely to happen! Current value = " + << currValue + << " is within value range but its index = " << index + << " has no map to group index. " + << "\n"; if (start.totalNanoseconds() > 0) { - // End situation + // Close the interval pair if it has been started. stop = currTime; createsplitter = true; } - } // [Out-bound] - - } // [CORRECT DIRECTION] - else { - // Log Index i falls out b/c out of wrong direction + } // [In-bound: Between interval] + } else { + // Out of a range: check whether there is a splitter started currindex = -1; - - // Condition to generate a Splitter (close parenthesis) - if (!correctdir && start.totalNanoseconds() > 0) { + if (start.totalNanoseconds() > 0) { + // End situation stop = currTime; createsplitter = true; } + } // [Out-bound] + + } // [CORRECT DIRECTION] + else { + // Log Index i falls out b/c out of wrong direction + currindex = -1; + + // Condition to generate a Splitter (close parenthesis) + if (!correctdir && start.totalNanoseconds() > 0) { + stop = currTime; + createsplitter = true; } - } // ENDIF (log entry in specified time) + } // d) Create Splitter if (createsplitter) { @@ -1662,7 +1658,7 @@ int GenerateEventsFilter::determineChangingDirection(int startindex) { */ void GenerateEventsFilter::addNewTimeFilterSplitter( Types::Core::DateAndTime starttime, Types::Core::DateAndTime stoptime, - int wsindex, string info) { + int wsindex, const string &info) { if (m_forFastLog) { // For MatrixWorkspace splitter // Start of splitter diff --git a/Framework/Algorithms/src/GeneratePeaks.cpp b/Framework/Algorithms/src/GeneratePeaks.cpp index 5cdb134dad8cbfa9f465f6df97125a92eebee683..d694db8a4a7920e575acf5abe5d854f3eda04369 100644 --- a/Framework/Algorithms/src/GeneratePeaks.cpp +++ b/Framework/Algorithms/src/GeneratePeaks.cpp @@ -429,7 +429,7 @@ void GeneratePeaks::generatePeaks( const std::map<specnum_t, std::vector<std::pair<double, API::IFunction_sptr>>> &functionmap, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { // Calcualte function std::map<specnum_t, std::vector<std::pair<double, API::IFunction_sptr>>>::const_iterator @@ -627,7 +627,7 @@ void GeneratePeaks::processTableColumnNames() { * Algorithm supports multiple peaks in multiple spectra */ void GeneratePeaks::getSpectraSet( - DataObjects::TableWorkspace_const_sptr peakParmsWS) { + const DataObjects::TableWorkspace_const_sptr &peakParmsWS) { size_t numpeaks = peakParmsWS->rowCount(); API::Column_const_sptr col = peakParmsWS->getColumn("spectrum"); @@ -652,7 +652,7 @@ void GeneratePeaks::getSpectraSet( /** Get the IPeakFunction part in the input function */ API::IPeakFunction_sptr -GeneratePeaks::getPeakFunction(API::IFunction_sptr infunction) { +GeneratePeaks::getPeakFunction(const API::IFunction_sptr &infunction) { // Not a composite function API::CompositeFunction_sptr compfunc = boost::dynamic_pointer_cast<API::CompositeFunction>(infunction); @@ -678,8 +678,8 @@ GeneratePeaks::getPeakFunction(API::IFunction_sptr infunction) { //---------------------------------------------------------------------------------------------- /** Find out whether a function has a certain parameter */ -bool GeneratePeaks::hasParameter(API::IFunction_sptr function, - std::string paramname) { +bool GeneratePeaks::hasParameter(const API::IFunction_sptr &function, + const std::string ¶mname) { std::vector<std::string> parnames = function->getParameterNames(); std::vector<std::string>::iterator piter; piter = std::find(parnames.begin(), parnames.end(), paramname); @@ -793,8 +793,8 @@ GeneratePeaks::createDataWorkspace(std::vector<double> binparameters) { /** Add function's parameter names after peak function name */ -std::vector<std::string> -GeneratePeaks::addFunctionParameterNames(std::vector<std::string> funcnames) { +std::vector<std::string> GeneratePeaks::addFunctionParameterNames( + const std::vector<std::string> &funcnames) { std::vector<std::string> vec_funcparnames; for (auto &funcname : funcnames) { diff --git a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp index 6dfb4ce07d7c669f831da820e0d5205fa716fd64..d0aae901fc3ad91d3e187ad89837cad9e9043fd7 100644 --- a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp +++ b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp @@ -399,7 +399,7 @@ void GetDetOffsetsMultiPeaks::processProperties() { * @throw Exception::RuntimeError If ... ... */ void GetDetOffsetsMultiPeaks::importFitWindowTableWorkspace( - TableWorkspace_sptr windowtablews) { + const TableWorkspace_sptr &windowtablews) { // Check number of columns matches number of peaks size_t numcols = windowtablews->columnCount(); size_t numpeaks = m_peakPositions.size(); @@ -721,7 +721,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( // Set up GSL minimzer const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex; - gsl_multimin_fminimizer *s = nullptr; + gsl_vector *ss, *x; gsl_multimin_function minex_func; @@ -729,7 +729,6 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( size_t nopt = 1; size_t iter = 0; int status = 0; - double size; /* Starting point */ x = gsl_vector_alloc(nopt); @@ -744,7 +743,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( minex_func.f = &gsl_costFunction; minex_func.params = ¶ms; - s = gsl_multimin_fminimizer_alloc(T, nopt); + gsl_multimin_fminimizer *s = gsl_multimin_fminimizer_alloc(T, nopt); gsl_multimin_fminimizer_set(s, &minex_func, x, ss); do { @@ -753,7 +752,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( if (status) break; - size = gsl_multimin_fminimizer_size(s); + double size = gsl_multimin_fminimizer_size(s); status = gsl_multimin_test_size(size, 1e-4); } while (status == GSL_CONTINUE && iter < 50); @@ -831,7 +830,7 @@ void deletePeaks(std::vector<size_t> &banned, std::vector<double> &peakPosToFit, * @return The number of peaks in range */ int GetDetOffsetsMultiPeaks::fitSpectra( - const int64_t wi, MatrixWorkspace_sptr inputW, + const int64_t wi, const MatrixWorkspace_sptr &inputW, const std::vector<double> &peakPositions, const std::vector<double> &fitWindows, size_t &nparams, double &minD, double &maxD, std::vector<double> &peakPosToFit, @@ -1178,7 +1177,7 @@ void GetDetOffsetsMultiPeaks::createInformationWorkspaces() { * (thread-safe) */ void GetDetOffsetsMultiPeaks::addInfoToReportWS( - int wi, FitPeakOffsetResult offsetresult, + int wi, const FitPeakOffsetResult &offsetresult, const std::vector<double> &tofitpeakpositions, const std::vector<double> &fittedpeakpositions) { // Offset calculation status diff --git a/Framework/Algorithms/src/GetEi.cpp b/Framework/Algorithms/src/GetEi.cpp index 4887378a71892a477d22e65b733330c2782d66c5..0484e539f0343fe4da0c48a01ef760842df84fd1 100644 --- a/Framework/Algorithms/src/GetEi.cpp +++ b/Framework/Algorithms/src/GetEi.cpp @@ -163,9 +163,9 @@ void GetEi::exec() { * passed to this function second * @throw NotFoundError if no detector is found for the detector ID given */ -void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, - specnum_t mon1Spec, double &monitor0Dist, - double &monitor1Dist) const { +void GetEi::getGeometry(const API::MatrixWorkspace_const_sptr &WS, + specnum_t mon0Spec, specnum_t mon1Spec, + double &monitor0Dist, double &monitor1Dist) const { const IComponent_const_sptr source = WS->getInstrument()->getSource(); // retrieve a pointer to the first detector and get its distance @@ -220,7 +220,7 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, * in the workspace */ std::vector<size_t> GetEi::getMonitorWsIndexs( - API::MatrixWorkspace_const_sptr WS, specnum_t specNum1, + const API::MatrixWorkspace_const_sptr &WS, specnum_t specNum1, specnum_t specNum2) const { // getting spectra numbers from detector IDs is // hard because the map works the other way, // getting index numbers from spectra numbers has @@ -285,7 +285,7 @@ double GetEi::timeToFly(double s, double E_KE) const { * @throw out_of_range if the peak runs off the edge of the histogram * @throw runtime_error a Child Algorithm just falls over */ -double GetEi::getPeakCentre(API::MatrixWorkspace_const_sptr WS, +double GetEi::getPeakCentre(const API::MatrixWorkspace_const_sptr &WS, const size_t monitIn, const double peakTime) { const auto ×Array = WS->x(monitIn); // we search for the peak only inside some window because there are often more diff --git a/Framework/Algorithms/src/GetEi2.cpp b/Framework/Algorithms/src/GetEi2.cpp index 794f6078f7faecf549d707226627f790c6bc26b5..205a6222d5eb9b4ae0fd15aae05e85aa9a5ea0fd 100644 --- a/Framework/Algorithms/src/GetEi2.cpp +++ b/Framework/Algorithms/src/GetEi2.cpp @@ -24,6 +24,7 @@ #include <boost/lexical_cast.hpp> #include <cmath> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -395,7 +396,7 @@ GetEi2::extractSpectrum(size_t ws_index, const double start, const double end) { * @returns The width of the peak at half height */ double GetEi2::calculatePeakWidthAtHalfHeight( - API::MatrixWorkspace_sptr data_ws, const double prominence, + const API::MatrixWorkspace_sptr &data_ws, const double prominence, std::vector<double> &peak_x, std::vector<double> &peak_y, std::vector<double> &peak_e) const { // Use WS->points() to create a temporary vector of bin_centre values to work @@ -622,11 +623,11 @@ double GetEi2::calculatePeakWidthAtHalfHeight( * considered a "real" peak * @return The calculated first moment */ -double GetEi2::calculateFirstMoment(API::MatrixWorkspace_sptr monitor_ws, +double GetEi2::calculateFirstMoment(const API::MatrixWorkspace_sptr &monitor_ws, const double prominence) { std::vector<double> peak_x, peak_y, peak_e; - calculatePeakWidthAtHalfHeight(monitor_ws, prominence, peak_x, peak_y, - peak_e); + calculatePeakWidthAtHalfHeight(std::move(monitor_ws), prominence, peak_x, + peak_y, peak_e); // Area double area(0.0), dummy(0.0); @@ -649,9 +650,9 @@ double GetEi2::calculateFirstMoment(API::MatrixWorkspace_sptr monitor_ws, * @param end :: The maximum value for the new bin range * @returns The rebinned workspace */ -API::MatrixWorkspace_sptr GetEi2::rebin(API::MatrixWorkspace_sptr monitor_ws, - const double first, const double width, - const double end) { +API::MatrixWorkspace_sptr +GetEi2::rebin(const API::MatrixWorkspace_sptr &monitor_ws, const double first, + const double width, const double end) { IAlgorithm_sptr childAlg = createChildAlgorithm("Rebin"); childAlg->setProperty("InputWorkspace", monitor_ws); std::ostringstream binParams; diff --git a/Framework/Algorithms/src/GetQsInQENSData.cpp b/Framework/Algorithms/src/GetQsInQENSData.cpp index 090cf53942b5e49a658501c483cb0dfdf510df3e..1d70e67da631b9624a0cdcfab13f5b2ab2a2e5de 100644 --- a/Framework/Algorithms/src/GetQsInQENSData.cpp +++ b/Framework/Algorithms/src/GetQsInQENSData.cpp @@ -88,7 +88,7 @@ void GetQsInQENSData::exec() { * @return The extracted Q-values as a vector. */ MantidVec GetQsInQENSData::extractQValues( - const Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { size_t numSpectra = workspace->getNumberHistograms(); Axis *qAxis; diff --git a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp index 25e22a3ce72a8deb41efb693db9d362a9be509da..531e79371687406d82ed0fec125bb6d733bd3dc1 100644 --- a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp +++ b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp @@ -299,7 +299,7 @@ TableWorkspace_sptr GetTimeSeriesLogInformation::generateStatisticTable() { * * This algorithm should be reconsidered how to work with it. */ -void GetTimeSeriesLogInformation::exportErrorLog(MatrixWorkspace_sptr ws, +void GetTimeSeriesLogInformation::exportErrorLog(const MatrixWorkspace_sptr &ws, vector<DateAndTime> abstimevec, double dts) { std::string outputdir = getProperty("OutputDirectory"); diff --git a/Framework/Algorithms/src/He3TubeEfficiency.cpp b/Framework/Algorithms/src/He3TubeEfficiency.cpp index 8303b71d23fa16364c4e34b159dd6335d4f0fd17..2c71546a9c36d506b20ce5311a9b17e6c7aaae60 100644 --- a/Framework/Algorithms/src/He3TubeEfficiency.cpp +++ b/Framework/Algorithms/src/He3TubeEfficiency.cpp @@ -381,9 +381,9 @@ void He3TubeEfficiency::logErrors() const { * @param idet :: the current detector * @return the value of the detector property */ -double He3TubeEfficiency::getParameter(std::string wsPropName, +double He3TubeEfficiency::getParameter(const std::string &wsPropName, std::size_t currentIndex, - std::string detPropName, + const std::string &detPropName, const Geometry::IDetector &idet) { std::vector<double> wsProp = this->getProperty(wsPropName); diff --git a/Framework/Algorithms/src/IQTransform.cpp b/Framework/Algorithms/src/IQTransform.cpp index a3418b84c13d232fe7f77380fd4bfbef29fc2c5a..4f289f16ee27a142c19425ccf7ab99008382ad10 100644 --- a/Framework/Algorithms/src/IQTransform.cpp +++ b/Framework/Algorithms/src/IQTransform.cpp @@ -7,12 +7,14 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidAlgorithms/IQTransform.h" +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/IncreasingAxisValidator.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/RawCountValidator.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidAlgorithms/IQTransform.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceCreation.h" @@ -157,11 +159,11 @@ void IQTransform::exec() { * @param background The workspace containing the background values */ API::MatrixWorkspace_sptr -IQTransform::subtractBackgroundWS(API::MatrixWorkspace_sptr ws, - API::MatrixWorkspace_sptr background) { +IQTransform::subtractBackgroundWS(const API::MatrixWorkspace_sptr &ws, + const API::MatrixWorkspace_sptr &background) { g_log.debug() << "Subtracting the workspace " << background->getName() << " from the input workspace.\n"; - return ws - background; + return std::move(ws) - background; } /** @name Available transformation functions */ @@ -172,7 +174,7 @@ IQTransform::subtractBackgroundWS(API::MatrixWorkspace_sptr ws, * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::guinierSpheres(API::MatrixWorkspace_sptr ws) { +void IQTransform::guinierSpheres(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -192,7 +194,7 @@ void IQTransform::guinierSpheres(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::guinierRods(API::MatrixWorkspace_sptr ws) { +void IQTransform::guinierRods(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -215,7 +217,7 @@ void IQTransform::guinierRods(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::guinierSheets(API::MatrixWorkspace_sptr ws) { +void IQTransform::guinierSheets(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -237,7 +239,7 @@ void IQTransform::guinierSheets(API::MatrixWorkspace_sptr ws) { * The output is set to zero for negative input Y values * @param ws The workspace to be transformed */ -void IQTransform::zimm(API::MatrixWorkspace_sptr ws) { +void IQTransform::zimm(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -261,7 +263,7 @@ void IQTransform::zimm(API::MatrixWorkspace_sptr ws) { * The output is set to zero for negative input Y values * @param ws The workspace to be transformed */ -void IQTransform::debyeBueche(API::MatrixWorkspace_sptr ws) { +void IQTransform::debyeBueche(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -284,7 +286,7 @@ void IQTransform::debyeBueche(API::MatrixWorkspace_sptr ws) { /** Performs the Holtzer transformation: IQ v Q * @param ws The workspace to be transformed */ -void IQTransform::holtzer(API::MatrixWorkspace_sptr ws) { +void IQTransform::holtzer(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -299,7 +301,7 @@ void IQTransform::holtzer(API::MatrixWorkspace_sptr ws) { /** Performs the Kratky transformation: IQ^2 v Q * @param ws The workspace to be transformed */ -void IQTransform::kratky(API::MatrixWorkspace_sptr ws) { +void IQTransform::kratky(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -317,7 +319,7 @@ void IQTransform::kratky(API::MatrixWorkspace_sptr ws) { /** Performs the Porod transformation: IQ^4 v Q * @param ws The workspace to be transformed */ -void IQTransform::porod(API::MatrixWorkspace_sptr ws) { +void IQTransform::porod(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -337,7 +339,7 @@ void IQTransform::porod(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::logLog(API::MatrixWorkspace_sptr ws) { +void IQTransform::logLog(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); @@ -360,7 +362,7 @@ void IQTransform::logLog(API::MatrixWorkspace_sptr ws) { * @throw std::range_error if an attempt is made to take log of a negative * number */ -void IQTransform::general(API::MatrixWorkspace_sptr ws) { +void IQTransform::general(const API::MatrixWorkspace_sptr &ws) { auto &X = ws->mutableX(0); auto &Y = ws->mutableY(0); auto &E = ws->mutableE(0); diff --git a/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp b/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp index 68ff265fb3f7e863cd9592c93cea708af64a1b96..a60e373cc3918313aaea2ff815afff2435a2363a 100644 --- a/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp +++ b/Framework/Algorithms/src/IdentifyNoisyDetectors.cpp @@ -149,8 +149,8 @@ void IdentifyNoisyDetectors::exec() { * @param values :: stddeviations of each spectra (I think) */ void IdentifyNoisyDetectors::getStdDev(API::Progress &progress, - MatrixWorkspace_sptr valid, - MatrixWorkspace_sptr values) { + const MatrixWorkspace_sptr &valid, + const MatrixWorkspace_sptr &values) { const auto nhist = static_cast<int>(valid->getNumberHistograms()); int count = 0; double mean = 0.0; diff --git a/Framework/Algorithms/src/IntegrateByComponent.cpp b/Framework/Algorithms/src/IntegrateByComponent.cpp index 23676f58d092e7829ba2225604ab27b75cf4fd17..f0da9938dff934b73e7fb7b3b3d05d9d2a26cc7c 100644 --- a/Framework/Algorithms/src/IntegrateByComponent.cpp +++ b/Framework/Algorithms/src/IntegrateByComponent.cpp @@ -158,8 +158,8 @@ void IntegrateByComponent::exec() { * @return vector of vectors, containing each spectrum that belongs to each * group */ -std::vector<std::vector<size_t>> -IntegrateByComponent::makeInstrumentMap(API::MatrixWorkspace_sptr countsWS) { +std::vector<std::vector<size_t>> IntegrateByComponent::makeInstrumentMap( + const API::MatrixWorkspace_sptr &countsWS) { std::vector<std::vector<size_t>> mymap; std::vector<size_t> single; @@ -178,7 +178,8 @@ IntegrateByComponent::makeInstrumentMap(API::MatrixWorkspace_sptr countsWS) { * group */ std::vector<std::vector<size_t>> -IntegrateByComponent::makeMap(API::MatrixWorkspace_sptr countsWS, int parents) { +IntegrateByComponent::makeMap(const API::MatrixWorkspace_sptr &countsWS, + int parents) { std::unordered_multimap<Mantid::Geometry::ComponentID, size_t> mymap; if (parents == 0) // this should not happen in this file, but if one reuses diff --git a/Framework/Algorithms/src/Integration.cpp b/Framework/Algorithms/src/Integration.cpp index 2dcdd1121383359e76b0d4d96a0e6fc92d58a952..0db822108e6a91eaaddb5bc5f53c74aa6a61dc12 100644 --- a/Framework/Algorithms/src/Integration.cpp +++ b/Framework/Algorithms/src/Integration.cpp @@ -349,9 +349,9 @@ void Integration::exec() { /** * Uses rebin to reduce event workspaces to a single bin histogram */ -API::MatrixWorkspace_sptr -Integration::rangeFilterEventWorkspace(API::MatrixWorkspace_sptr workspace, - double minRange, double maxRange) { +API::MatrixWorkspace_sptr Integration::rangeFilterEventWorkspace( + const API::MatrixWorkspace_sptr &workspace, double minRange, + double maxRange) { bool childLog = g_log.is(Logger::Priority::PRIO_DEBUG); auto childAlg = createChildAlgorithm("Rebin", 0, 0.5, childLog); childAlg->setProperty("InputWorkspace", workspace); diff --git a/Framework/Algorithms/src/InterpolatingRebin.cpp b/Framework/Algorithms/src/InterpolatingRebin.cpp index 83d372c4125570f61744b191b03a33bda85997df..05466d4790c93ac2603e41b6c27ec219a2a16e96 100644 --- a/Framework/Algorithms/src/InterpolatingRebin.cpp +++ b/Framework/Algorithms/src/InterpolatingRebin.cpp @@ -144,9 +144,9 @@ void InterpolatingRebin::exec() { * the histograms must corrospond with the number of x-values in XValues_new */ void InterpolatingRebin::outputYandEValues( - API::MatrixWorkspace_const_sptr inputW, + const API::MatrixWorkspace_const_sptr &inputW, const HistogramData::BinEdges &XValues_new, - API::MatrixWorkspace_sptr outputW) { + const API::MatrixWorkspace_sptr &outputW) { g_log.debug() << "Preparing to calculate y-values using splines and estimate errors\n"; diff --git a/Framework/Algorithms/src/MagFormFactorCorrection.cpp b/Framework/Algorithms/src/MagFormFactorCorrection.cpp index 5cd00fbdf356ede05c09d2dfbd00c3b13215d0fe..d49836999fcbb4cecfe60c19affbdf2d9764ea44 100644 --- a/Framework/Algorithms/src/MagFormFactorCorrection.cpp +++ b/Framework/Algorithms/src/MagFormFactorCorrection.cpp @@ -96,9 +96,11 @@ void MagFormFactorCorrection::exec() { // Gets the vector of form factor values std::vector<double> FF; FF.reserve(Qvals.size()); - for (double Qval : Qvals) { - FF.emplace_back(ion.analyticalFormFactor(Qval * Qval)); - } + + std::transform( + Qvals.begin(), Qvals.end(), std::back_inserter(FF), + [&ion](double qval) { return ion.analyticalFormFactor(qval * qval); }); + if (!ffwsStr.empty()) { HistogramBuilder builder; builder.setX(Qvals.size()); diff --git a/Framework/Algorithms/src/MaskBinsFromTable.cpp b/Framework/Algorithms/src/MaskBinsFromTable.cpp index 6ad76da2d7f7e597cd859eb3a8aab010e8e1ea2a..e951b48c5bf1c21f124a9448507793c0c05269f4 100644 --- a/Framework/Algorithms/src/MaskBinsFromTable.cpp +++ b/Framework/Algorithms/src/MaskBinsFromTable.cpp @@ -68,7 +68,7 @@ void MaskBinsFromTable::exec() { /** Call MaskBins * @param dataws :: MatrixWorkspace to mask bins for */ -void MaskBinsFromTable::maskBins(API::MatrixWorkspace_sptr dataws) { +void MaskBinsFromTable::maskBins(const API::MatrixWorkspace_sptr &dataws) { bool firstloop = true; API::MatrixWorkspace_sptr outputws; @@ -134,7 +134,8 @@ void MaskBinsFromTable::maskBins(API::MatrixWorkspace_sptr dataws) { * @param dataws :: MatrixWorkspace to mask */ void MaskBinsFromTable::processMaskBinWorkspace( - TableWorkspace_sptr masktblws, API::MatrixWorkspace_sptr dataws) { + const TableWorkspace_sptr &masktblws, + const API::MatrixWorkspace_sptr &dataws) { // Check input if (!masktblws) throw std::invalid_argument("Input workspace is not a table workspace."); @@ -213,8 +214,8 @@ void MaskBinsFromTable::processMaskBinWorkspace( * @return :: list of spectra/workspace index IDs in string format */ std::string -MaskBinsFromTable::convertToSpectraList(API::MatrixWorkspace_sptr dataws, - std::string detidliststr) { +MaskBinsFromTable::convertToSpectraList(const API::MatrixWorkspace_sptr &dataws, + const std::string &detidliststr) { // Use array property to get a list of detectors vector<int> detidvec; ArrayProperty<int> parser("detids", detidliststr); diff --git a/Framework/Algorithms/src/MaxEnt.cpp b/Framework/Algorithms/src/MaxEnt.cpp index 4807fa4ecb75266e580209bdb8dac7b7ac0a87ac..bfbf95127907bc20710ec00d24315ace441bd0aa 100644 --- a/Framework/Algorithms/src/MaxEnt.cpp +++ b/Framework/Algorithms/src/MaxEnt.cpp @@ -826,7 +826,7 @@ std::vector<double> MaxEnt::applyDistancePenalty( std::vector<double> MaxEnt::updateImage(const std::vector<double> &image, const std::vector<double> &delta, - const std::vector<std::vector<double>> dirs) { + const std::vector<std::vector<double>> &dirs) { if (image.empty() || dirs.empty() || (delta.size() != dirs.size())) { throw std::runtime_error("Cannot calculate new image"); diff --git a/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp b/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp index 412b37d2bb3e6f91ff7e86e529040c1c48953ff4..4b9603e8f2b861bd3a2d4493ef45d1b6121b79f1 100644 --- a/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp +++ b/Framework/Algorithms/src/MaxEnt/MaxentCalculator.cpp @@ -6,6 +6,7 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/MaxEnt/MaxentCalculator.h" #include <cmath> +#include <utility> namespace Mantid { namespace Algorithms { @@ -21,7 +22,7 @@ MaxentCalculator::MaxentCalculator(MaxentEntropy_sptr entropy, MaxentTransform_sptr transform) : m_data(), m_errors(), m_image(), m_dataCalc(), m_background(1.0), m_angle(-1.), m_chisq(-1.), m_directionsIm(), m_coeffs(), - m_entropy(entropy), m_transform(transform) {} + m_entropy(std::move(entropy)), m_transform(std::move(transform)) {} /** * Calculates the gradient of chi-square using the experimental data, calculated diff --git a/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp b/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp index 560af008dbe233d6b8e581080f29f37a966d1503..ed0aabea5546a4eaadc44f1c60548a702c1c728a 100644 --- a/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp +++ b/Framework/Algorithms/src/MaxEnt/MaxentTransformFourier.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidAlgorithms/MaxEnt/MaxentTransformFourier.h" #include <boost/shared_array.hpp> +#include <utility> + #include <gsl/gsl_fft_complex.h> namespace Mantid { @@ -14,7 +16,7 @@ namespace Algorithms { /** Constructor */ MaxentTransformFourier::MaxentTransformFourier(MaxentSpace_sptr dataSpace, MaxentSpace_sptr imageSpace) - : m_dataSpace(dataSpace), m_imageSpace(imageSpace) {} + : m_dataSpace(std::move(dataSpace)), m_imageSpace(std::move(imageSpace)) {} /** * Transforms a 1D signal from image space to data space, performing an diff --git a/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp b/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp index 19dac6d580ffa24554925e7ef936d3e5fe03954c..7b9e4f392cf82279089da2617ef269244ff7731e 100644 --- a/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp +++ b/Framework/Algorithms/src/MaxEnt/MaxentTransformMultiFourier.cpp @@ -7,15 +7,17 @@ #include "MantidAlgorithms/MaxEnt/MaxentTransformMultiFourier.h" #include <gsl/gsl_fft_complex.h> +#include <utility> + namespace Mantid { namespace Algorithms { /** Constructor */ MaxentTransformMultiFourier::MaxentTransformMultiFourier( - MaxentSpaceComplex_sptr dataSpace, MaxentSpace_sptr imageSpace, + const MaxentSpaceComplex_sptr &dataSpace, MaxentSpace_sptr imageSpace, size_t numSpec) - : MaxentTransformFourier(dataSpace, imageSpace), m_numSpec(numSpec), - m_linearAdjustments(), m_constAdjustments() {} + : MaxentTransformFourier(dataSpace, std::move(imageSpace)), + m_numSpec(numSpec), m_linearAdjustments(), m_constAdjustments() {} /** * Transforms a 1D signal from image space to data space, performing an @@ -40,9 +42,7 @@ MaxentTransformMultiFourier::imageToData(const std::vector<double> &image) { std::vector<double> data; data.reserve(m_numSpec * dataOneSpec.size()); for (size_t s = 0; s < m_numSpec; s++) { - for (const double &data_item : dataOneSpec) { - data.emplace_back(data_item); - } + std::copy(dataOneSpec.begin(), dataOneSpec.end(), std::back_inserter(data)); } // Apply adjustments (we assume there are sufficient adjustments supplied) diff --git a/Framework/Algorithms/src/MedianDetectorTest.cpp b/Framework/Algorithms/src/MedianDetectorTest.cpp index c86b91516d201c4bea0e99e32c04ef3b1a6ac5ab..e385cbf6f9e4301f93ed55c0af35c1f9281f0152 100644 --- a/Framework/Algorithms/src/MedianDetectorTest.cpp +++ b/Framework/Algorithms/src/MedianDetectorTest.cpp @@ -238,7 +238,8 @@ API::MatrixWorkspace_sptr MedianDetectorTest::getSolidAngles(int firstSpec, * @returns The number failed. */ int MedianDetectorTest::maskOutliers( - const std::vector<double> medianvec, API::MatrixWorkspace_sptr countsWS, + const std::vector<double> &medianvec, + const API::MatrixWorkspace_sptr &countsWS, std::vector<std::vector<size_t>> indexmap) { // Fractions of the median @@ -300,10 +301,10 @@ int MedianDetectorTest::maskOutliers( * skipped. */ int MedianDetectorTest::doDetectorTests( - const API::MatrixWorkspace_sptr countsWS, - const std::vector<double> medianvec, + const API::MatrixWorkspace_sptr &countsWS, + const std::vector<double> &medianvec, std::vector<std::vector<size_t>> indexmap, - API::MatrixWorkspace_sptr maskWS) { + const API::MatrixWorkspace_sptr &maskWS) { g_log.debug("Applying the criteria to find failing detectors"); // A spectra can't fail if the statistics show its value is consistent with diff --git a/Framework/Algorithms/src/Minus.cpp b/Framework/Algorithms/src/Minus.cpp index 08319d1e2e88f92419f51f5d1734cdc1041afcfe..12999ca54492af943a544ab43cf462b8c8d49c5f 100644 --- a/Framework/Algorithms/src/Minus.cpp +++ b/Framework/Algorithms/src/Minus.cpp @@ -137,8 +137,8 @@ void Minus::checkRequirements() { * @return workspace unit compatibility flag */ bool Minus::checkUnitCompatibility( - const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const { + const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const { if (lhs->size() > 1 && rhs->size() > 1) { if (lhs->YUnit() != rhs->YUnit()) { g_log.error("The two workspaces are not compatible because they have " diff --git a/Framework/Algorithms/src/ModeratorTzero.cpp b/Framework/Algorithms/src/ModeratorTzero.cpp index 6960ca6d2d9b4c943182b2d9bc607f10da85bb22..67e1a3395f14356c10f7f78dcde053f8499ba141 100644 --- a/Framework/Algorithms/src/ModeratorTzero.cpp +++ b/Framework/Algorithms/src/ModeratorTzero.cpp @@ -354,9 +354,9 @@ void ModeratorTzero::execEvent(const std::string &emode) { evlist.mutableX() -= t0_direct; MantidVec tofs = evlist.getTofs(); - for (double &tof : tofs) { - tof -= t0_direct; - } + + std::transform(tofs.begin(), tofs.end(), tofs.begin(), + [&t0_direct](double tof) { return tof - t0_direct; }); evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); } // end of else if(emode=="Direct") diff --git a/Framework/Algorithms/src/NormaliseByCurrent.cpp b/Framework/Algorithms/src/NormaliseByCurrent.cpp index b563a9730096cf1e5d1f148e1c127c87f6425e93..fce8815e6c6d02bcfc7a2450a5edf127c6c3abb8 100644 --- a/Framework/Algorithms/src/NormaliseByCurrent.cpp +++ b/Framework/Algorithms/src/NormaliseByCurrent.cpp @@ -45,7 +45,7 @@ void NormaliseByCurrent::init() { * workspace logs or if the values are invalid (0) */ double NormaliseByCurrent::extractCharge( - boost::shared_ptr<Mantid::API::MatrixWorkspace> inputWS, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &inputWS, const bool integratePCharge) const { // Get the good proton charge and check it's valid double charge(-1.0); diff --git a/Framework/Algorithms/src/NormaliseByDetector.cpp b/Framework/Algorithms/src/NormaliseByDetector.cpp index db0469b3fb0873be0a7e48f5adeb419c23c13fe4..a118ba7e13e61db4d457783f18513ad89b6e9750 100644 --- a/Framework/Algorithms/src/NormaliseByDetector.cpp +++ b/Framework/Algorithms/src/NormaliseByDetector.cpp @@ -73,7 +73,7 @@ void NormaliseByDetector::init() { } const Geometry::FitParameter NormaliseByDetector::tryParseFunctionParameter( - Geometry::Parameter_sptr parameter, const Geometry::IDetector &det) { + const Geometry::Parameter_sptr ¶meter, const Geometry::IDetector &det) { if (parameter == nullptr) { std::stringstream stream; stream << det.getName() @@ -99,10 +99,9 @@ normalisation routine. use. @param prog: progress reporting object. */ -void NormaliseByDetector::processHistogram(size_t wsIndex, - MatrixWorkspace_const_sptr inWS, - MatrixWorkspace_sptr denominatorWS, - Progress &prog) { +void NormaliseByDetector::processHistogram( + size_t wsIndex, const MatrixWorkspace_const_sptr &inWS, + const MatrixWorkspace_sptr &denominatorWS, Progress &prog) { const auto ¶mMap = inWS->constInstrumentParameters(); const auto &spectrumInfo = inWS->spectrumInfo(); const auto &det = spectrumInfo.detector(wsIndex); @@ -164,7 +163,7 @@ sequentially. use. */ MatrixWorkspace_sptr -NormaliseByDetector::processHistograms(MatrixWorkspace_sptr inWS) { +NormaliseByDetector::processHistograms(const MatrixWorkspace_sptr &inWS) { const size_t nHistograms = inWS->getNumberHistograms(); const auto progress_items = static_cast<size_t>(double(nHistograms) * 1.2); Progress prog(this, 0.0, 1.0, progress_items); diff --git a/Framework/Algorithms/src/NormaliseToMonitor.cpp b/Framework/Algorithms/src/NormaliseToMonitor.cpp index 5be68fb0999742662affed31fb1d9a7c2ec4aad1..bad96c37993a3e24f3bacb9263c0d2ecc818b242 100644 --- a/Framework/Algorithms/src/NormaliseToMonitor.cpp +++ b/Framework/Algorithms/src/NormaliseToMonitor.cpp @@ -102,7 +102,7 @@ void MonIDPropChanger::applyChanges(const IPropertyManager *algo, // read the monitors list from the workspace and try to do it once for any // particular ws; bool MonIDPropChanger::monitorIdReader( - MatrixWorkspace_const_sptr inputWS) const { + const MatrixWorkspace_const_sptr &inputWS) const { // no workspace if (!inputWS) return false; diff --git a/Framework/Algorithms/src/PDCalibration.cpp b/Framework/Algorithms/src/PDCalibration.cpp index 3edaa4e0f412c559ec5e5dd5dfd8bcdb9baab135..a5de2509c4725be4aa58f533c5bfa965497156f3 100644 --- a/Framework/Algorithms/src/PDCalibration.cpp +++ b/Framework/Algorithms/src/PDCalibration.cpp @@ -70,7 +70,7 @@ const auto isNonZero = [](const double value) { return value != 0.; }; /// private inner class class PDCalibration::FittedPeaks { public: - FittedPeaks(API::MatrixWorkspace_const_sptr wksp, + FittedPeaks(const API::MatrixWorkspace_const_sptr &wksp, const std::size_t wkspIndex) { this->wkspIndex = wkspIndex; @@ -108,7 +108,7 @@ public: void setPositions(const std::vector<double> &peaksInD, const std::vector<double> &peaksInDWindows, - std::function<double(double)> toTof) { + const std::function<double(double)> &toTof) { // clear out old values inDPos.clear(); inTofPos.clear(); @@ -307,7 +307,7 @@ std::map<std::string, std::string> PDCalibration::validateInputs() { namespace { -bool hasDasIDs(API::ITableWorkspace_const_sptr table) { +bool hasDasIDs(const API::ITableWorkspace_const_sptr &table) { const auto columnNames = table->getColumnNames(); return (std::find(columnNames.begin(), columnNames.end(), std::string("dasid")) != columnNames.end()); @@ -755,14 +755,13 @@ double fitDIFCtZeroDIFA(std::vector<double> &peaks, double &difc, double &t0, size_t iter = 0; // number of iterations const size_t MAX_ITER = 75 * numParams; int status = 0; - double size; do { iter++; status = gsl_multimin_fminimizer_iterate(minimizer); if (status) break; - size = gsl_multimin_fminimizer_size(minimizer); + double size = gsl_multimin_fminimizer_size(minimizer); status = gsl_multimin_test_size(size, 1e-4); } while (status == GSL_CONTINUE && iter < MAX_ITER); @@ -939,7 +938,7 @@ vector<double> PDCalibration::getTOFminmax(const double difc, const double difa, return tofminmax; } -MatrixWorkspace_sptr PDCalibration::load(const std::string filename) { +MatrixWorkspace_sptr PDCalibration::load(const std::string &filename) { // TODO this assumes that all files are event-based const double maxChunkSize = getProperty("MaxChunkSize"); const double filterBadPulses = getProperty("FilterBadPulses"); @@ -1186,7 +1185,8 @@ PDCalibration::sortTableWorkspace(API::ITableWorkspace_sptr &table) { /// NEW: convert peak positions in dSpacing to peak centers workspace std::pair<API::MatrixWorkspace_sptr, API::MatrixWorkspace_sptr> PDCalibration::createTOFPeakCenterFitWindowWorkspaces( - API::MatrixWorkspace_sptr dataws, const double peakWindowMaxInDSpacing) { + const API::MatrixWorkspace_sptr &dataws, + const double peakWindowMaxInDSpacing) { // calculate from peaks in dpsacing to peak fit window in dspacing const auto windowsInDSpacing = diff --git a/Framework/Algorithms/src/PaddingAndApodization.cpp b/Framework/Algorithms/src/PaddingAndApodization.cpp index a2975167ee49ae280e564c40c15837cde913e625..c4222210c4b5a5beaed425bdcd6808e4841971fb 100644 --- a/Framework/Algorithms/src/PaddingAndApodization.cpp +++ b/Framework/Algorithms/src/PaddingAndApodization.cpp @@ -115,7 +115,6 @@ void PaddingAndApodization::exec() { fptr apodizationFunction = getApodizationFunction(method); // Do the specified spectra only auto specLength = static_cast<int>(spectra.size()); - std::vector<double> norm(specLength, 0.0); PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < specLength; ++i) { PARALLEL_START_INTERUPT_REGION @@ -145,7 +144,7 @@ using fptr = double (*)(const double, const double); * @param method :: [input] The name of the chosen function * @returns :: pointer to the function */ -fptr PaddingAndApodization::getApodizationFunction(const std::string method) { +fptr PaddingAndApodization::getApodizationFunction(const std::string &method) { if (method == "None") { return ApodizationFunctions::none; } else if (method == "Lorentz") { diff --git a/Framework/Algorithms/src/ParallaxCorrection.cpp b/Framework/Algorithms/src/ParallaxCorrection.cpp index 040288fdf7553a5b92695983b5e15e0c6c6e18c2..7d93a5df9d6aa57f81ac55b2784398ddbab1573c 100644 --- a/Framework/Algorithms/src/ParallaxCorrection.cpp +++ b/Framework/Algorithms/src/ParallaxCorrection.cpp @@ -104,10 +104,9 @@ void ParallaxCorrection::init() { * @param parallax : the correction formula for the bank * @param direction : the tube direction in the bank */ -void ParallaxCorrection::performCorrection(API::MatrixWorkspace_sptr outWS, - const std::vector<size_t> &indices, - const std::string ¶llax, - const std::string &direction) { +void ParallaxCorrection::performCorrection( + const API::MatrixWorkspace_sptr &outWS, const std::vector<size_t> &indices, + const std::string ¶llax, const std::string &direction) { double t; mu::Parser muParser; muParser.DefineVar("t", &t); diff --git a/Framework/Algorithms/src/PerformIndexOperations.cpp b/Framework/Algorithms/src/PerformIndexOperations.cpp index 13f8589c3e94d33d661e67c86d21c835b98806fd..9ba817654d218e7e3464a0c17d70b11871b31d34 100644 --- a/Framework/Algorithms/src/PerformIndexOperations.cpp +++ b/Framework/Algorithms/src/PerformIndexOperations.cpp @@ -10,6 +10,7 @@ #include "MantidKernel/Strings.h" #include <boost/algorithm/string.hpp> #include <boost/regex.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -31,7 +32,7 @@ public: if (!this->isValid()) { return toAppend; } else { - MatrixWorkspace_sptr current = this->execute(inputWS); + MatrixWorkspace_sptr current = this->execute(std::move(inputWS)); Mantid::API::AlgorithmManagerImpl &factory = Mantid::API::AlgorithmManager::Instance(); auto conjoinWorkspaceAlg = factory.create("ConjoinWorkspaces"); diff --git a/Framework/Algorithms/src/Plus.cpp b/Framework/Algorithms/src/Plus.cpp index b23ee7b1397d7275496bb7094e3d4f742081204b..94d98002c264b3e558a13eca2b56b46dad987c4d 100644 --- a/Framework/Algorithms/src/Plus.cpp +++ b/Framework/Algorithms/src/Plus.cpp @@ -145,8 +145,8 @@ void Plus::checkRequirements() { * @return workspace unit compatibility flag */ bool Plus::checkUnitCompatibility( - const API::MatrixWorkspace_const_sptr lhs, - const API::MatrixWorkspace_const_sptr rhs) const { + const API::MatrixWorkspace_const_sptr &lhs, + const API::MatrixWorkspace_const_sptr &rhs) const { if (lhs->size() > 1 && rhs->size() > 1) { if (lhs->YUnit() != rhs->YUnit()) { g_log.error("The two workspaces are not compatible because they have " diff --git a/Framework/Algorithms/src/PointByPointVCorrection.cpp b/Framework/Algorithms/src/PointByPointVCorrection.cpp index ee0591db07a0e92d28469261d5a65cf5c1114893..96fc5e9a6e90cd55431adc9efaf6b22b628852fc 100644 --- a/Framework/Algorithms/src/PointByPointVCorrection.cpp +++ b/Framework/Algorithms/src/PointByPointVCorrection.cpp @@ -125,10 +125,10 @@ void PointByPointVCorrection::exec() { // builds which caused the unit tests // to sometimes fail. Maybe this is some compiler bug to do with // using bind2nd within the parrallel macros. - for (double &rY : resultY) { - // Now result is s_i/v_i*Dlam_i*(sum_i s_i)/(sum_i S_i/v_i*Dlam_i) - rY *= factor; - } + + // Now result is s_i/v_i*Dlam_i*(sum_i s_i)/(sum_i S_i/v_i*Dlam_i) + std::transform(resultY.begin(), resultY.end(), resultY.begin(), + [&factor](double rY) { return rY * factor; }); // Finally get the normalized errors for (int j = 0; j < size - 1; j++) diff --git a/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp b/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp index ae19aba09686296600756d1e6c96d9c96a3222eb..12e68df35d18d8aa05e345170d69fc7d36db9fbf 100644 --- a/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp +++ b/Framework/Algorithms/src/PolarizationCorrectionFredrikze.cpp @@ -206,7 +206,7 @@ void PolarizationCorrectionFredrikze::init() { } WorkspaceGroup_sptr -PolarizationCorrectionFredrikze::execPA(WorkspaceGroup_sptr inWS) { +PolarizationCorrectionFredrikze::execPA(const WorkspaceGroup_sptr &inWS) { size_t itemIndex = 0; MatrixWorkspace_sptr Ipp = @@ -276,7 +276,7 @@ PolarizationCorrectionFredrikze::execPA(WorkspaceGroup_sptr inWS) { } WorkspaceGroup_sptr -PolarizationCorrectionFredrikze::execPNR(WorkspaceGroup_sptr inWS) { +PolarizationCorrectionFredrikze::execPNR(const WorkspaceGroup_sptr &inWS) { size_t itemIndex = 0; MatrixWorkspace_sptr Ip = boost::dynamic_pointer_cast<MatrixWorkspace>(inWS->getItem(itemIndex++)); diff --git a/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp b/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp index 8547cdd06f82748820348291ab80f8f794eba15f..95cb7c112f6b7b999c5db21c7b929323d6e0b8dd 100644 --- a/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp +++ b/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp @@ -98,6 +98,7 @@ void fourInputsCorrectedAndErrors( Eigen::Matrix4d F1m; F1m << 1., 0., 0., 0., 0., 1., 0., 0., off1, 0., diag1, 0., 0., off1, 0., diag1; + const auto diag2 = 1. / f2; const auto off2 = (f2 - 1.) / f2; Eigen::Matrix4d F2m; @@ -357,8 +358,8 @@ double twoInputsErrorEstimate10(const double i00, const double e00, return std::sqrt(e10_I00 + e10_I11 + e10_F1 + e10_F2 + e10_P1 + e10_P2); } -Mantid::API::MatrixWorkspace_sptr -createWorkspaceWithHistory(Mantid::API::MatrixWorkspace_const_sptr inputWS) { +Mantid::API::MatrixWorkspace_sptr createWorkspaceWithHistory( + const Mantid::API::MatrixWorkspace_const_sptr &inputWS) { Mantid::API::MatrixWorkspace_sptr outputWS = Mantid::DataObjects::create<Mantid::DataObjects::Workspace2D>(*inputWS); outputWS->history().addHistory(inputWS->getHistory()); diff --git a/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp b/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp index 17af8f92b7768636bc1c443c4c934474fc90e3ab..fb26c987fcb8afa48ab48c626def7e27f11f8252 100644 --- a/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp +++ b/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp @@ -309,8 +309,8 @@ MatrixWorkspace_sptr PolarizationEfficiencyCor::convertToHistogram( //---------------------------------------------------------------------------------------------- /// Convert the efficiencies to histogram MatrixWorkspace_sptr -PolarizationEfficiencyCor::interpolate(MatrixWorkspace_sptr efficiencies, - MatrixWorkspace_sptr inWS) { +PolarizationEfficiencyCor::interpolate(const MatrixWorkspace_sptr &efficiencies, + const MatrixWorkspace_sptr &inWS) { efficiencies->setDistribution(true); auto alg = createChildAlgorithm("RebinToWorkspace"); diff --git a/Framework/Algorithms/src/Q1D2.cpp b/Framework/Algorithms/src/Q1D2.cpp index 2689b26c7d9f2269ca09483ce3fb5b891b8aad36..8a09881898619db57aaee4d2e15f9485202dbb24 100644 --- a/Framework/Algorithms/src/Q1D2.cpp +++ b/Framework/Algorithms/src/Q1D2.cpp @@ -4,7 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/Q1D2.h" +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/CommonBinsValidator.h" #include "MantidAPI/HistogramValidator.h" @@ -14,6 +15,7 @@ #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceUnitValidator.h" #include "MantidAlgorithms/GravitySANSHelper.h" +#include "MantidAlgorithms/Q1D2.h" #include "MantidAlgorithms/Qhelper.h" #include "MantidDataObjects/Histogram1D.h" #include "MantidDataObjects/Workspace2D.h" @@ -409,12 +411,13 @@ Q1D2::setUpOutputWorkspace(const std::vector<double> &binParams) const { */ void Q1D2::calculateNormalization( const size_t wavStart, const size_t wsIndex, - API::MatrixWorkspace_const_sptr pixelAdj, - API::MatrixWorkspace_const_sptr wavePixelAdj, double const *const binNorms, - double const *const binNormEs, HistogramData::HistogramY::iterator norm, + const API::MatrixWorkspace_const_sptr &pixelAdj, + const API::MatrixWorkspace_const_sptr &wavePixelAdj, + double const *const binNorms, double const *const binNormEs, + HistogramData::HistogramY::iterator norm, HistogramData::HistogramY::iterator normETo2) const { double detectorAdj, detAdjErr; - pixelWeight(pixelAdj, wsIndex, detectorAdj, detAdjErr); + pixelWeight(std::move(pixelAdj), wsIndex, detectorAdj, detAdjErr); // use that the normalization array ends at the start of the error array for (auto n = norm, e = normETo2; n != normETo2; ++n, ++e) { *n = detectorAdj; @@ -444,7 +447,7 @@ void Q1D2::calculateNormalization( * @param[out] error the error on the weight, only non-zero if pixelAdj * @throw LogicError if the solid angle is tiny or negative */ -void Q1D2::pixelWeight(API::MatrixWorkspace_const_sptr pixelAdj, +void Q1D2::pixelWeight(const API::MatrixWorkspace_const_sptr &pixelAdj, const size_t wsIndex, double &weight, double &error) const { const auto &detectorInfo = m_dataWS->detectorInfo(); diff --git a/Framework/Algorithms/src/Q1DWeighted.cpp b/Framework/Algorithms/src/Q1DWeighted.cpp index a01bcbade6732348b70f589fcc08af5edc488ed1..84c54c709cd8100fd0943dc7f7bb098ed4a3de64 100644 --- a/Framework/Algorithms/src/Q1DWeighted.cpp +++ b/Framework/Algorithms/src/Q1DWeighted.cpp @@ -105,7 +105,7 @@ void Q1DWeighted::exec() { * initializes the user inputs * @param inputWS : input workspace */ -void Q1DWeighted::bootstrap(MatrixWorkspace_const_sptr inputWS) { +void Q1DWeighted::bootstrap(const MatrixWorkspace_const_sptr &inputWS) { // Get pixel size and pixel sub-division m_pixelSizeX = getProperty("PixelSizeX"); m_pixelSizeY = getProperty("PixelSizeY"); @@ -167,7 +167,7 @@ void Q1DWeighted::bootstrap(MatrixWorkspace_const_sptr inputWS) { * Performs the azimuthal averaging for each wavelength bin * @param inputWS : the input workspace */ -void Q1DWeighted::calculate(MatrixWorkspace_const_sptr inputWS) { +void Q1DWeighted::calculate(const MatrixWorkspace_const_sptr &inputWS) { // Set up the progress Progress progress(this, 0.0, 1.0, m_nSpec * m_nLambda); @@ -313,7 +313,7 @@ void Q1DWeighted::calculate(MatrixWorkspace_const_sptr inputWS) { * performs final averaging and sets the output workspaces * @param inputWS : the input workspace */ -void Q1DWeighted::finalize(MatrixWorkspace_const_sptr inputWS) { +void Q1DWeighted::finalize(const MatrixWorkspace_const_sptr &inputWS) { MatrixWorkspace_sptr outputWS = createOutputWorkspace(inputWS, m_nQ, m_qBinEdges); setProperty("OutputWorkspace", outputWS); @@ -383,7 +383,7 @@ void Q1DWeighted::finalize(MatrixWorkspace_const_sptr inputWS) { * @return output I(Q) workspace */ MatrixWorkspace_sptr -Q1DWeighted::createOutputWorkspace(MatrixWorkspace_const_sptr parent, +Q1DWeighted::createOutputWorkspace(const MatrixWorkspace_const_sptr &parent, const size_t nBins, const std::vector<double> &binEdges) { diff --git a/Framework/Algorithms/src/Qhelper.cpp b/Framework/Algorithms/src/Qhelper.cpp index 00a6d9d05cce97ac6d4c5baf57c712aed55506fe..d827741972e5227a653007d5a348e085d5982089 100644 --- a/Framework/Algorithms/src/Qhelper.cpp +++ b/Framework/Algorithms/src/Qhelper.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/Qhelper.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" +#include "MantidAlgorithms/Qhelper.h" namespace Mantid { namespace Algorithms { @@ -25,13 +27,13 @@ using namespace Geometry; @param qResolution: the QResolution workspace @throw invalid_argument if the workspaces are not mututially compatible */ -void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj, - API::MatrixWorkspace_const_sptr qResolution) { +void Qhelper::examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj, + const API::MatrixWorkspace_const_sptr &qResolution) { // Check the compatibility of dataWS, binAdj and detectAdj - examineInput(dataWS, binAdj, detectAdj); + examineInput(dataWS, std::move(binAdj), std::move(detectAdj)); // Check the compatibility of the QResolution workspace if (qResolution) { @@ -64,9 +66,9 @@ void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, one bin @throw invalid_argument if the workspaces are not mututially compatible */ -void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, - API::MatrixWorkspace_const_sptr binAdj, - API::MatrixWorkspace_const_sptr detectAdj) { +void Qhelper::examineInput(const API::MatrixWorkspace_const_sptr &dataWS, + const API::MatrixWorkspace_const_sptr &binAdj, + const API::MatrixWorkspace_const_sptr &detectAdj) { if (dataWS->getNumberHistograms() < 1) { throw std::invalid_argument( "Empty data workspace passed, can not continue"); @@ -152,7 +154,7 @@ void Qhelper::examineInput(API::MatrixWorkspace_const_sptr dataWS, * @param wsInd spectrum that is being analysed * @return index number of the first bin to include in the calculation */ -size_t Qhelper::waveLengthCutOff(API::MatrixWorkspace_const_sptr dataWS, +size_t Qhelper::waveLengthCutOff(const API::MatrixWorkspace_const_sptr &dataWS, const SpectrumInfo &spectrumInfo, const double RCut, const double WCut, const size_t wsInd) const { @@ -188,8 +190,8 @@ sumOfCounts/sumOfNormFactors equals the * @param sumOfNormFactors sum of normalisation factors */ void Qhelper::outputParts(API::Algorithm *alg, - API::MatrixWorkspace_sptr sumOfCounts, - API::MatrixWorkspace_sptr sumOfNormFactors) { + const API::MatrixWorkspace_sptr &sumOfCounts, + const API::MatrixWorkspace_sptr &sumOfNormFactors) { std::string baseName = alg->getPropertyValue("OutputWorkspace"); alg->declareProperty( diff --git a/Framework/Algorithms/src/Qxy.cpp b/Framework/Algorithms/src/Qxy.cpp index 91cf49b61f8b3bd7225006e313695c326d9aba17..72923aa7c0de8b9c9bbfdc35829705d07166988a 100644 --- a/Framework/Algorithms/src/Qxy.cpp +++ b/Framework/Algorithms/src/Qxy.cpp @@ -402,8 +402,8 @@ double Qxy::getQminFromWs(const API::MatrixWorkspace &inputWorkspace) { * Qx. * @return A pointer to the newly-created workspace */ -API::MatrixWorkspace_sptr -Qxy::setUpOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace) { +API::MatrixWorkspace_sptr Qxy::setUpOutputWorkspace( + const API::MatrixWorkspace_const_sptr &inputWorkspace) { const double max = getProperty("MaxQxy"); const double delta = getProperty("DeltaQ"); const bool log_binning = getProperty("IQxQyLogBinning"); diff --git a/Framework/Algorithms/src/RadiusSum.cpp b/Framework/Algorithms/src/RadiusSum.cpp index 3000143742d1260aa29fff73ec373b2b86da2054..1eb1c907f7253402874001b9bda592cafb2c0f50 100644 --- a/Framework/Algorithms/src/RadiusSum.cpp +++ b/Framework/Algorithms/src/RadiusSum.cpp @@ -272,7 +272,7 @@ void RadiusSum::inputValidationSanityCheck() { * @return True if it is an instrument related workspace. */ bool RadiusSum::inputWorkspaceHasInstrumentAssociated( - API::MatrixWorkspace_sptr inWS) { + const API::MatrixWorkspace_sptr &inWS) { return inWS->getAxis(1)->isSpectra(); } @@ -302,7 +302,7 @@ std::vector<double> RadiusSum::getBoundariesOfInputWorkspace() { *Xmin, Xmax, Ymin, Ymax */ std::vector<double> -RadiusSum::getBoundariesOfNumericImage(API::MatrixWorkspace_sptr inWS) { +RadiusSum::getBoundariesOfNumericImage(const API::MatrixWorkspace_sptr &inWS) { // horizontal axis @@ -359,7 +359,7 @@ RadiusSum::getBoundariesOfNumericImage(API::MatrixWorkspace_sptr inWS) { *Xmin, Xmax, Ymin, Ymax, Zmin, Zmax */ std::vector<double> -RadiusSum::getBoundariesOfInstrument(API::MatrixWorkspace_sptr inWS) { +RadiusSum::getBoundariesOfInstrument(const API::MatrixWorkspace_sptr &inWS) { // This function is implemented based in the following assumption: // - The workspace is composed by spectrum with associated spectrum No which @@ -521,7 +521,8 @@ void RadiusSum::numBinsIsReasonable() { << '\n'; } -double RadiusSum::getMinBinSizeForInstrument(API::MatrixWorkspace_sptr inWS) { +double +RadiusSum::getMinBinSizeForInstrument(const API::MatrixWorkspace_sptr &inWS) { // Assumption made: the detectors are placed one after the other, so the // minimum // reasonalbe size for the bin is the width of one detector. @@ -538,7 +539,8 @@ double RadiusSum::getMinBinSizeForInstrument(API::MatrixWorkspace_sptr inWS) { throw std::invalid_argument("Did not find any non monitor detector position"); } -double RadiusSum::getMinBinSizeForNumericImage(API::MatrixWorkspace_sptr inWS) { +double +RadiusSum::getMinBinSizeForNumericImage(const API::MatrixWorkspace_sptr &inWS) { // The pixel dimensions: // - width: image width/ number of pixels in one row // - height: image height/ number of pixels in one column diff --git a/Framework/Algorithms/src/Rebin.cpp b/Framework/Algorithms/src/Rebin.cpp index 5e8993c4a931899c18926a9f76d92a7f4ea9eda2..7343535d6f43cc138787aadb5442ed3587b7678b 100644 --- a/Framework/Algorithms/src/Rebin.cpp +++ b/Framework/Algorithms/src/Rebin.cpp @@ -309,8 +309,9 @@ void Rebin::exec() { * @param outputWS :: The output workspace * @param hist :: The index of the current histogram */ -void Rebin::propagateMasks(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, int hist) { +void Rebin::propagateMasks(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, + int hist) { // Not too happy with the efficiency of this way of doing it, but it's a lot // simpler to use the // existing rebin algorithm to distribute the weights than to re-implement it diff --git a/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp b/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp index 28e19f92abc2fdffd4cb7c92b3b90b22c84d276b..76639056586c9ab9dee093d3ccee69a19bac62dd 100644 --- a/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp +++ b/Framework/Algorithms/src/ReflectometryBackgroundSubtraction.cpp @@ -50,7 +50,8 @@ const std::string ReflectometryBackgroundSubtraction::summary() const { * background */ void ReflectometryBackgroundSubtraction::calculateAverageSpectrumBackground( - MatrixWorkspace_sptr inputWS, const std::vector<specnum_t> &spectraList) { + const MatrixWorkspace_sptr &inputWS, + const std::vector<specnum_t> &spectraList) { auto alg = this->createChildAlgorithm("GroupDetectors"); alg->setProperty("InputWorkspace", inputWS); @@ -156,7 +157,7 @@ void ReflectometryBackgroundSubtraction::calculatePolynomialBackground( * @param indexList :: the ranges of the background region */ void ReflectometryBackgroundSubtraction::calculatePixelBackground( - MatrixWorkspace_sptr inputWS, const std::vector<double> &indexList) { + const MatrixWorkspace_sptr &inputWS, const std::vector<double> &indexList) { const std::vector<int> backgroundRange{static_cast<int>(indexList.front()), static_cast<int>(indexList.back())}; diff --git a/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp b/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp index 38ddb2048d437c96b797b71e0a15085ed06e839d..5ccc81e765e4a1dd5a9dde6253562e8fbd92b272 100644 --- a/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp +++ b/Framework/Algorithms/src/ReflectometryBeamStatistics.cpp @@ -66,8 +66,8 @@ const std::string * @return the slit gap, in meters */ double ReflectometryBeamStatistics::slitSeparation( - Geometry::Instrument_const_sptr instrument, const std::string &slit1Name, - const std::string &slit2Name) { + const Geometry::Instrument_const_sptr &instrument, + const std::string &slit1Name, const std::string &slit2Name) { auto slit1 = instrument->getComponentByName(slit1Name); auto slit2 = instrument->getComponentByName(slit2Name); return (slit1->getPos() - slit2->getPos()).norm(); diff --git a/Framework/Algorithms/src/ReflectometryReductionOne2.cpp b/Framework/Algorithms/src/ReflectometryReductionOne2.cpp index 4a30b192f8a6e961602527e4cb68fdce6134bc20..b78e1286933688d1afa5ec3399aecfc88c88a633 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOne2.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOne2.cpp @@ -25,6 +25,7 @@ #include "MantidKernel/UnitFactory.h" #include <algorithm> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -344,7 +345,7 @@ std::string ReflectometryReductionOne2::createDebugWorkspaceName( * and is incremented after the workspace is output */ void ReflectometryReductionOne2::outputDebugWorkspace( - MatrixWorkspace_sptr ws, const std::string &wsName, + const MatrixWorkspace_sptr &ws, const std::string &wsName, const std::string &wsSuffix, const bool debug, int &step) { // Nothing to do if debug is not enabled if (debug) { @@ -503,7 +504,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::backgroundSubtraction( * @return : corrected workspace */ MatrixWorkspace_sptr ReflectometryReductionOne2::transOrAlgCorrection( - MatrixWorkspace_sptr detectorWS, const bool detectorWSReduced) { + const MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced) { MatrixWorkspace_sptr normalized; MatrixWorkspace_sptr transRun = getProperty("FirstTransmissionRun"); @@ -526,7 +527,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::transOrAlgCorrection( * @return :: the input workspace normalized by transmission */ MatrixWorkspace_sptr ReflectometryReductionOne2::transmissionCorrection( - MatrixWorkspace_sptr detectorWS, const bool detectorWSReduced) { + const MatrixWorkspace_sptr &detectorWS, const bool detectorWSReduced) { MatrixWorkspace_sptr transmissionWS = getProperty("FirstTransmissionRun"); auto transmissionWSName = transmissionWS->getName(); @@ -615,7 +616,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::transmissionCorrection( * @return : corrected workspace */ MatrixWorkspace_sptr ReflectometryReductionOne2::algorithmicCorrection( - MatrixWorkspace_sptr detectorWS) { + const MatrixWorkspace_sptr &detectorWS) { const std::string corrAlgName = getProperty("CorrectionAlgorithm"); @@ -643,7 +644,7 @@ MatrixWorkspace_sptr ReflectometryReductionOne2::algorithmicCorrection( * @return : output workspace in Q */ MatrixWorkspace_sptr -ReflectometryReductionOne2::convertToQ(MatrixWorkspace_sptr inputWS) { +ReflectometryReductionOne2::convertToQ(const MatrixWorkspace_sptr &inputWS) { bool const moreThanOneDetector = inputWS->getDetector(0)->nDets() > 1; bool const shouldCorrectAngle = !(*getProperty("ThetaIn")).isDefault() && !summingInQ(); @@ -709,7 +710,7 @@ void ReflectometryReductionOne2::findDetectorGroups() { // Sort the groups by the first spectrum number in the group (to give the same // output order as GroupDetectors) std::sort(m_detectorGroups.begin(), m_detectorGroups.end(), - [](const std::vector<size_t> a, const std::vector<size_t> b) { + [](const std::vector<size_t> &a, const std::vector<size_t> &b) { return a.front() < b.front(); }); @@ -807,7 +808,7 @@ size_t ReflectometryReductionOne2::twoThetaRDetectorIdx( } void ReflectometryReductionOne2::findWavelengthMinMax( - MatrixWorkspace_sptr inputWS) { + const MatrixWorkspace_sptr &inputWS) { // Get the max/min wavelength of region of interest const double lambdaMin = getProperty("WavelengthMin"); @@ -879,8 +880,8 @@ size_t ReflectometryReductionOne2::findIvsLamRangeMaxDetector( } double ReflectometryReductionOne2::findIvsLamRangeMin( - MatrixWorkspace_sptr detectorWS, const std::vector<size_t> &detectors, - const double lambda) { + const MatrixWorkspace_sptr &detectorWS, + const std::vector<size_t> &detectors, const double lambda) { double projectedMin = 0.0; const size_t spIdx = findIvsLamRangeMinDetector(detectors); @@ -898,8 +899,8 @@ double ReflectometryReductionOne2::findIvsLamRangeMin( } double ReflectometryReductionOne2::findIvsLamRangeMax( - MatrixWorkspace_sptr detectorWS, const std::vector<size_t> &detectors, - const double lambda) { + const MatrixWorkspace_sptr &detectorWS, + const std::vector<size_t> &detectors, const double lambda) { double projectedMax = 0.0; const size_t spIdx = findIvsLamRangeMaxDetector(detectors); @@ -928,9 +929,9 @@ double ReflectometryReductionOne2::findIvsLamRangeMax( * @param projectedMax [out] : the end of the resulting projected range */ void ReflectometryReductionOne2::findIvsLamRange( - MatrixWorkspace_sptr detectorWS, const std::vector<size_t> &detectors, - const double lambdaMin, const double lambdaMax, double &projectedMin, - double &projectedMax) { + const MatrixWorkspace_sptr &detectorWS, + const std::vector<size_t> &detectors, const double lambdaMin, + const double lambdaMax, double &projectedMin, double &projectedMax) { // Get the new max and min X values of the projected (virtual) lambda range projectedMin = findIvsLamRangeMin(detectorWS, detectors, lambdaMin); @@ -952,8 +953,8 @@ void ReflectometryReductionOne2::findIvsLamRange( * * @return : a 1D workspace where y values are all zero */ -MatrixWorkspace_sptr -ReflectometryReductionOne2::constructIvsLamWS(MatrixWorkspace_sptr detectorWS) { +MatrixWorkspace_sptr ReflectometryReductionOne2::constructIvsLamWS( + const MatrixWorkspace_sptr &detectorWS) { // There is one output spectrum for each detector group const size_t numGroups = detectorGroups().size(); @@ -1001,7 +1002,7 @@ ReflectometryReductionOne2::constructIvsLamWS(MatrixWorkspace_sptr detectorWS) { * @return :: the output workspace in wavelength */ MatrixWorkspace_sptr -ReflectometryReductionOne2::sumInQ(MatrixWorkspace_sptr detectorWS) { +ReflectometryReductionOne2::sumInQ(const MatrixWorkspace_sptr &detectorWS) { // Construct the output array in virtual lambda MatrixWorkspace_sptr IvsLam = constructIvsLamWS(detectorWS); @@ -1078,7 +1079,7 @@ void ReflectometryReductionOne2::sumInQProcessValue( const int inputIdx, const double twoTheta, const double bTwoTheta, const HistogramX &inputX, const HistogramY &inputY, const HistogramE &inputE, const std::vector<size_t> &detectors, - const size_t outSpecIdx, MatrixWorkspace_sptr IvsLam, + const size_t outSpecIdx, const MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE) { // Check whether there are any counts (if not, nothing to share) @@ -1097,7 +1098,7 @@ void ReflectometryReductionOne2::sumInQProcessValue( lambdaVMin, lambdaVMax); // Share the input counts into the output array sumInQShareCounts(inputCounts, inputE[inputIdx], bLambda, lambdaVMin, - lambdaVMax, outSpecIdx, IvsLam, outputE); + lambdaVMax, outSpecIdx, std::move(IvsLam), outputE); } /** @@ -1118,7 +1119,7 @@ void ReflectometryReductionOne2::sumInQProcessValue( void ReflectometryReductionOne2::sumInQShareCounts( const double inputCounts, const double inputErr, const double bLambda, const double lambdaMin, const double lambdaMax, const size_t outSpecIdx, - MatrixWorkspace_sptr IvsLam, std::vector<double> &outputE) { + const MatrixWorkspace_sptr &IvsLam, std::vector<double> &outputE) { // Check that we have histogram data const auto &outputX = IvsLam->dataX(outSpecIdx); auto &outputY = IvsLam->dataY(outSpecIdx); @@ -1239,7 +1240,8 @@ Check whether the spectra for the given workspaces are the same. exception. Otherwise a warning is generated. */ void ReflectometryReductionOne2::verifySpectrumMaps( - MatrixWorkspace_const_sptr ws1, MatrixWorkspace_const_sptr ws2) { + const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { bool mismatch = false; // Check that the number of histograms is the same diff --git a/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp b/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp index 2ee23048c2b4f470fe0e9364b375447c73537e0c..d9bfc3dae5c648098682c7c0ee5dc985e166668f 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOneAuto2.cpp @@ -172,7 +172,7 @@ ReflectometryReductionOneAuto2::validateInputs() { } std::string ReflectometryReductionOneAuto2::getRunNumberForWorkspaceGroup( - WorkspaceGroup_const_sptr group) { + const WorkspaceGroup_const_sptr &group) { // Return the run number for the first child workspace if (!group) throw std::runtime_error("Invalid workspace group type"); @@ -495,8 +495,8 @@ void ReflectometryReductionOneAuto2::exec() { * @param inputWS :: the input workspace * @return :: the names of the detectors of interest */ -std::vector<std::string> -ReflectometryReductionOneAuto2::getDetectorNames(MatrixWorkspace_sptr inputWS) { +std::vector<std::string> ReflectometryReductionOneAuto2::getDetectorNames( + const MatrixWorkspace_sptr &inputWS) { std::vector<std::string> wsIndices; boost::split(wsIndices, m_processingInstructionsWorkspaceIndex, @@ -572,8 +572,8 @@ MatrixWorkspace_sptr ReflectometryReductionOneAuto2::correctDetectorPositions( * @param inputWS :: the input workspace * @return :: the angle of the detector (only the first detector is considered) */ -double -ReflectometryReductionOneAuto2::calculateTheta(MatrixWorkspace_sptr inputWS) { +double ReflectometryReductionOneAuto2::calculateTheta( + const MatrixWorkspace_sptr &inputWS) { const auto detectorsOfInterest = getDetectorNames(inputWS); @@ -600,7 +600,7 @@ ReflectometryReductionOneAuto2::calculateTheta(MatrixWorkspace_sptr inputWS) { * @param instrument :: The instrument attached to the workspace */ void ReflectometryReductionOneAuto2::populateAlgorithmicCorrectionProperties( - IAlgorithm_sptr alg, Instrument_const_sptr instrument) { + const IAlgorithm_sptr &alg, const Instrument_const_sptr &instrument) { // With algorithmic corrections, monitors should not be integrated, see below @@ -664,7 +664,7 @@ void ReflectometryReductionOneAuto2::populateAlgorithmicCorrectionProperties( } auto ReflectometryReductionOneAuto2::getRebinParams( - MatrixWorkspace_sptr inputWS, const double theta) -> RebinParams { + const MatrixWorkspace_sptr &inputWS, const double theta) -> RebinParams { bool qMinIsDefault = true, qMaxIsDefault = true; auto const qMin = getPropertyOrDefault("MomentumTransferMin", inputWS->x(0).front(), qMinIsDefault); @@ -681,7 +681,7 @@ auto ReflectometryReductionOneAuto2::getRebinParams( * @return :: the rebin step in Q, or none if it could not be found */ boost::optional<double> -ReflectometryReductionOneAuto2::getQStep(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto2::getQStep(const MatrixWorkspace_sptr &inputWS, const double theta) { Property *qStepProp = getProperty("MomentumTransferStep"); double qstep; @@ -718,9 +718,8 @@ ReflectometryReductionOneAuto2::getQStep(MatrixWorkspace_sptr inputWS, * and max) * @return :: the output workspace */ -MatrixWorkspace_sptr -ReflectometryReductionOneAuto2::rebinAndScale(MatrixWorkspace_sptr inputWS, - RebinParams const ¶ms) { +MatrixWorkspace_sptr ReflectometryReductionOneAuto2::rebinAndScale( + const MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms) { // Rebin IAlgorithm_sptr algRebin = createChildAlgorithm("Rebin"); algRebin->initialize(); @@ -747,7 +746,7 @@ ReflectometryReductionOneAuto2::rebinAndScale(MatrixWorkspace_sptr inputWS, } MatrixWorkspace_sptr -ReflectometryReductionOneAuto2::cropQ(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto2::cropQ(const MatrixWorkspace_sptr &inputWS, RebinParams const ¶ms) { IAlgorithm_sptr algCrop = createChildAlgorithm("CropWorkspace"); algCrop->initialize(); diff --git a/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp b/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp index c4c447f983dc160be2b04453d4ed6db827a3c1f6..365b8b41fa14cc318b3e3180b4fefaddd4e9bae0 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOneAuto3.cpp @@ -163,7 +163,7 @@ ReflectometryReductionOneAuto3::validateInputs() { } std::string ReflectometryReductionOneAuto3::getRunNumberForWorkspaceGroup( - WorkspaceGroup_const_sptr group) { + const WorkspaceGroup_const_sptr &group) { // Return the run number for the first child workspace if (!group) throw std::runtime_error("Invalid workspace group type"); @@ -471,8 +471,8 @@ void ReflectometryReductionOneAuto3::exec() { * @param inputWS :: the input workspace * @return :: the names of the detectors of interest */ -std::vector<std::string> -ReflectometryReductionOneAuto3::getDetectorNames(MatrixWorkspace_sptr inputWS) { +std::vector<std::string> ReflectometryReductionOneAuto3::getDetectorNames( + const MatrixWorkspace_sptr &inputWS) { std::vector<std::string> wsIndices; boost::split(wsIndices, m_processingInstructionsWorkspaceIndex, boost::is_any_of(":,-+")); @@ -546,8 +546,8 @@ MatrixWorkspace_sptr ReflectometryReductionOneAuto3::correctDetectorPositions( * @param inputWS :: the input workspace * @return :: the angle of the detector (only the first detector is considered) */ -double -ReflectometryReductionOneAuto3::calculateTheta(MatrixWorkspace_sptr inputWS) { +double ReflectometryReductionOneAuto3::calculateTheta( + const MatrixWorkspace_sptr &inputWS) { const auto detectorsOfInterest = getDetectorNames(inputWS); // Detectors of interest may be empty. This happens for instance when we input @@ -573,7 +573,7 @@ ReflectometryReductionOneAuto3::calculateTheta(MatrixWorkspace_sptr inputWS) { * @param instrument :: The instrument attached to the workspace */ void ReflectometryReductionOneAuto3::populateAlgorithmicCorrectionProperties( - IAlgorithm_sptr alg, Instrument_const_sptr instrument) { + const IAlgorithm_sptr &alg, const Instrument_const_sptr &instrument) { // With algorithmic corrections, monitors should not be integrated, see below const std::string correctionAlgorithm = getProperty("CorrectionAlgorithm"); @@ -635,7 +635,7 @@ void ReflectometryReductionOneAuto3::populateAlgorithmicCorrectionProperties( } auto ReflectometryReductionOneAuto3::getRebinParams( - MatrixWorkspace_sptr inputWS, const double theta) -> RebinParams { + const MatrixWorkspace_sptr &inputWS, const double theta) -> RebinParams { bool qMinIsDefault = true, qMaxIsDefault = true; auto const qMin = getPropertyOrDefault("MomentumTransferMin", inputWS->x(0).front(), qMinIsDefault); @@ -652,7 +652,7 @@ auto ReflectometryReductionOneAuto3::getRebinParams( * @return :: the rebin step in Q, or none if it could not be found */ boost::optional<double> -ReflectometryReductionOneAuto3::getQStep(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto3::getQStep(const MatrixWorkspace_sptr &inputWS, const double theta) { Property *qStepProp = getProperty("MomentumTransferStep"); double qstep; @@ -690,7 +690,7 @@ ReflectometryReductionOneAuto3::getQStep(MatrixWorkspace_sptr inputWS, * @return :: the output workspace */ MatrixWorkspace_sptr -ReflectometryReductionOneAuto3::rebin(MatrixWorkspace_sptr inputWS, +ReflectometryReductionOneAuto3::rebin(const MatrixWorkspace_sptr &inputWS, const RebinParams ¶ms) { IAlgorithm_sptr algRebin = createChildAlgorithm("Rebin"); algRebin->initialize(); diff --git a/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp b/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp index 5712e3db69121acccbe6441ea4f428bb8c7f18d9..7753d5f99c8b0175951189386e5665bf838978bb 100644 --- a/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp +++ b/Framework/Algorithms/src/ReflectometryWorkflowBase.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/ReflectometryWorkflowBase.h" +#include <utility> + #include "MantidAPI/BoostOptionalToAlgorithmProperty.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidAlgorithms/ReflectometryWorkflowBase.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CompositeValidator.h" @@ -196,12 +198,12 @@ ReflectometryWorkflowBase::OptionalMinMax ReflectometryWorkflowBase::getOptionalMinMax( Mantid::API::Algorithm *const alg, const std::string &minProperty, const std::string &maxProperty, - Mantid::Geometry::Instrument_const_sptr inst, std::string minIdfName, - std::string maxIdfName) const { - const auto min = checkForOptionalInstrumentDefault<double>(alg, minProperty, - inst, minIdfName); - const auto max = checkForOptionalInstrumentDefault<double>(alg, maxProperty, - inst, maxIdfName); + const Mantid::Geometry::Instrument_const_sptr &inst, + const std::string &minIdfName, const std::string &maxIdfName) const { + const auto min = checkForOptionalInstrumentDefault<double>( + alg, minProperty, inst, std::move(minIdfName)); + const auto max = checkForOptionalInstrumentDefault<double>( + alg, maxProperty, inst, std::move(maxIdfName)); if (min.is_initialized() && max.is_initialized()) { MinMax result = getMinMax(minProperty, maxProperty); return OptionalMinMax(result); @@ -361,7 +363,7 @@ void ReflectometryWorkflowBase::getTransmissionRunInfo( * @return The cropped and corrected monitor workspace. */ MatrixWorkspace_sptr ReflectometryWorkflowBase::toLamMonitor( - const MatrixWorkspace_sptr &toConvert, const OptionalInteger monitorIndex, + const MatrixWorkspace_sptr &toConvert, const OptionalInteger &monitorIndex, const OptionalMinMax &backgroundMinMax) { // Convert Units. auto convertUnitsAlg = this->createChildAlgorithm("ConvertUnits"); @@ -473,9 +475,9 @@ ReflectometryWorkflowBase::makeUnityWorkspace(const HistogramX &x) { * @return Tuple of detector and monitor workspaces */ ReflectometryWorkflowBase::DetectorMonitorWorkspacePair -ReflectometryWorkflowBase::toLam(MatrixWorkspace_sptr toConvert, +ReflectometryWorkflowBase::toLam(const MatrixWorkspace_sptr &toConvert, const std::string &processingCommands, - const OptionalInteger monitorIndex, + const OptionalInteger &monitorIndex, const MinMax &wavelengthMinMax, const OptionalMinMax &backgroundMinMax) { // Detector Workspace Processing diff --git a/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp b/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp index a789763307e9991cfd728329c1ab7e159b56f082..5336598c54277c201e94de6cf533ae9ef8d06971 100644 --- a/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp +++ b/Framework/Algorithms/src/ReflectometryWorkflowBase2.cpp @@ -4,12 +4,14 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/ReflectometryWorkflowBase2.h" +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/BoostOptionalToAlgorithmProperty.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidAlgorithms/ReflectometryWorkflowBase2.h" #include "MantidGeometry/Instrument.h" #include "MantidIndexing/IndexInfo.h" #include "MantidKernel/ArrayProperty.h" @@ -40,16 +42,15 @@ int convertStringNumToInt(const std::string &string) { } std::string convertToWorkspaceIndex(const std::string &spectrumNumber, - MatrixWorkspace_const_sptr ws) { + const MatrixWorkspace_const_sptr &ws) { auto specNum = convertStringNumToInt(spectrumNumber); std::string wsIdx = std::to_string( ws->getIndexFromSpectrumNumber(static_cast<Mantid::specnum_t>(specNum))); return wsIdx; } -std::string -convertProcessingInstructionsToWorkspaceIndices(const std::string &instructions, - MatrixWorkspace_const_sptr ws) { +std::string convertProcessingInstructionsToWorkspaceIndices( + const std::string &instructions, const MatrixWorkspace_const_sptr &ws) { std::string converted = ""; std::string currentNumber = ""; std::string ignoreThese = "-,:+"; @@ -79,7 +80,7 @@ convertProcessingInstructionsToWorkspaceIndices(const std::string &instructions, */ std::vector<size_t> getProcessingInstructionsAsIndices(std::string const &instructions, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto instructionsInWSIndex = convertProcessingInstructionsToWorkspaceIndices(instructions, workspace); auto groups = @@ -517,8 +518,8 @@ ReflectometryWorkflowBase2::validateWavelengthRanges() const { * @param inputWS :: the workspace to convert * @return :: the workspace in wavelength */ -MatrixWorkspace_sptr -ReflectometryWorkflowBase2::convertToWavelength(MatrixWorkspace_sptr inputWS) { +MatrixWorkspace_sptr ReflectometryWorkflowBase2::convertToWavelength( + const MatrixWorkspace_sptr &inputWS) { auto convertUnitsAlg = createChildAlgorithm("ConvertUnits"); convertUnitsAlg->initialize(); @@ -541,8 +542,8 @@ ReflectometryWorkflowBase2::convertToWavelength(MatrixWorkspace_sptr inputWS) { * @return :: the cropped workspace */ MatrixWorkspace_sptr ReflectometryWorkflowBase2::cropWavelength( - MatrixWorkspace_sptr inputWS, const bool useArgs, const double argMin, - const double argMax) { + const MatrixWorkspace_sptr &inputWS, const bool useArgs, + const double argMin, const double argMax) { double wavelengthMin = 0.0; double wavelengthMax = 0.0; @@ -584,7 +585,7 @@ MatrixWorkspace_sptr ReflectometryWorkflowBase2::cropWavelength( MatrixWorkspace_sptr ReflectometryWorkflowBase2::makeDetectorWS(MatrixWorkspace_sptr inputWS, const bool convert, const bool sum) { - auto detectorWS = inputWS; + auto detectorWS = std::move(inputWS); if (sum) { // Use GroupDetectors to extract and sum the detectors of interest @@ -635,7 +636,7 @@ ReflectometryWorkflowBase2::makeDetectorWS(MatrixWorkspace_sptr inputWS, * @return :: the monitor workspace in wavelength */ MatrixWorkspace_sptr -ReflectometryWorkflowBase2::makeMonitorWS(MatrixWorkspace_sptr inputWS, +ReflectometryWorkflowBase2::makeMonitorWS(const MatrixWorkspace_sptr &inputWS, const bool integratedMonitors) { // Extract the monitor workspace @@ -697,7 +698,8 @@ ReflectometryWorkflowBase2::makeMonitorWS(MatrixWorkspace_sptr inputWS, * @return :: the rebinned detector workspace */ MatrixWorkspace_sptr ReflectometryWorkflowBase2::rebinDetectorsToMonitors( - MatrixWorkspace_sptr detectorWS, MatrixWorkspace_sptr monitorWS) { + const MatrixWorkspace_sptr &detectorWS, + const MatrixWorkspace_sptr &monitorWS) { auto rebin = createChildAlgorithm("RebinToWorkspace"); rebin->initialize(); @@ -715,7 +717,7 @@ MatrixWorkspace_sptr ReflectometryWorkflowBase2::rebinDetectorsToMonitors( * @param instrument :: the instrument attached to the workspace */ void ReflectometryWorkflowBase2::populateMonitorProperties( - IAlgorithm_sptr alg, Instrument_const_sptr instrument) { + const IAlgorithm_sptr &alg, const Instrument_const_sptr &instrument) { const auto startOverlap = checkForOptionalInstrumentDefault<double>( this, "StartOverlap", instrument, "TransRunStartOverlap"); @@ -769,7 +771,8 @@ void ReflectometryWorkflowBase2::populateMonitorProperties( * @return :: processing instructions as a string */ std::string ReflectometryWorkflowBase2::findProcessingInstructions( - Instrument_const_sptr instrument, MatrixWorkspace_sptr inputWS) const { + const Instrument_const_sptr &instrument, + const MatrixWorkspace_sptr &inputWS) const { const std::string analysisMode = getProperty("AnalysisMode"); @@ -815,7 +818,7 @@ std::string ReflectometryWorkflowBase2::findProcessingInstructions( * @return Boolean, whether or not any transmission runs were found */ bool ReflectometryWorkflowBase2::populateTransmissionProperties( - IAlgorithm_sptr alg) const { + const IAlgorithm_sptr &alg) const { bool transRunsExist = false; @@ -845,9 +848,8 @@ bool ReflectometryWorkflowBase2::populateTransmissionProperties( * @return :: the value of theta found from the logs * @throw :: NotFoundError if the log value was not found */ -double -ReflectometryWorkflowBase2::getThetaFromLogs(MatrixWorkspace_sptr inputWs, - const std::string &logName) { +double ReflectometryWorkflowBase2::getThetaFromLogs( + const MatrixWorkspace_sptr &inputWs, const std::string &logName) { double theta = -1.; const Mantid::API::Run &run = inputWs->run(); Property *logData = run.getLogData(logName); @@ -884,7 +886,7 @@ ReflectometryWorkflowBase2::getRunNumber(MatrixWorkspace const &ws) const { std::string ReflectometryWorkflowBase2::convertProcessingInstructionsToSpectrumNumbers( const std::string &instructions, - Mantid::API::MatrixWorkspace_const_sptr ws) const { + const Mantid::API::MatrixWorkspace_const_sptr &ws) const { std::string converted = ""; std::string currentNumber = ""; std::string ignoreThese = "-,:+"; @@ -905,7 +907,7 @@ ReflectometryWorkflowBase2::convertProcessingInstructionsToSpectrumNumbers( } std::string ReflectometryWorkflowBase2::convertToSpectrumNumber( const std::string &workspaceIndex, - Mantid::API::MatrixWorkspace_const_sptr ws) const { + const Mantid::API::MatrixWorkspace_const_sptr &ws) const { auto wsIndx = convertStringNumToInt(workspaceIndex); std::string specId = std::to_string( static_cast<int32_t>(ws->indexInfo().spectrumNumber(wsIndx))); @@ -913,7 +915,8 @@ std::string ReflectometryWorkflowBase2::convertToSpectrumNumber( } void ReflectometryWorkflowBase2::convertProcessingInstructions( - Instrument_const_sptr instrument, MatrixWorkspace_sptr inputWS) { + const Instrument_const_sptr &instrument, + const MatrixWorkspace_sptr &inputWS) { m_processingInstructions = getPropertyValue("ProcessingInstructions"); if (!getPointerToProperty("ProcessingInstructions")->isDefault()) { m_processingInstructionsWorkspaceIndex = @@ -921,14 +924,14 @@ void ReflectometryWorkflowBase2::convertProcessingInstructions( m_processingInstructions, inputWS); } else { m_processingInstructionsWorkspaceIndex = - findProcessingInstructions(instrument, inputWS); + findProcessingInstructions(std::move(instrument), inputWS); m_processingInstructions = convertProcessingInstructionsToSpectrumNumbers( m_processingInstructionsWorkspaceIndex, inputWS); } } void ReflectometryWorkflowBase2::convertProcessingInstructions( - MatrixWorkspace_sptr inputWS) { + const MatrixWorkspace_sptr &inputWS) { m_processingInstructions = getPropertyValue("ProcessingInstructions"); m_processingInstructionsWorkspaceIndex = convertProcessingInstructionsToWorkspaceIndices(m_processingInstructions, @@ -938,7 +941,7 @@ void ReflectometryWorkflowBase2::convertProcessingInstructions( // Create an on-the-fly property to set an output workspace from a child // algorithm, if the child has that output value set void ReflectometryWorkflowBase2::setWorkspacePropertyFromChild( - Algorithm_sptr alg, std::string const &propertyName) { + const Algorithm_sptr &alg, std::string const &propertyName) { if (alg->isDefault(propertyName)) return; diff --git a/Framework/Algorithms/src/RemovePromptPulse.cpp b/Framework/Algorithms/src/RemovePromptPulse.cpp index 07e0a8bed958896ed2ad87e2f71b76f4250ce0c1..412802216b0d4e35c37ddf646ef60bf1ddcbf3cb 100644 --- a/Framework/Algorithms/src/RemovePromptPulse.cpp +++ b/Framework/Algorithms/src/RemovePromptPulse.cpp @@ -68,7 +68,8 @@ double getMedian(const API::Run &run, const std::string &name) { return stats.median; } -void getTofRange(MatrixWorkspace_const_sptr wksp, double &tmin, double &tmax) { +void getTofRange(const MatrixWorkspace_const_sptr &wksp, double &tmin, + double &tmax) { DataObjects::EventWorkspace_const_sptr eventWksp = boost::dynamic_pointer_cast<const DataObjects::EventWorkspace>(wksp); if (eventWksp == nullptr) { diff --git a/Framework/Algorithms/src/ResampleX.cpp b/Framework/Algorithms/src/ResampleX.cpp index ddd7344106f9ddbcfa802e56387c061f70768d93..4a686c0ec29a545a4594bfc0af26f4effb60f706 100644 --- a/Framework/Algorithms/src/ResampleX.cpp +++ b/Framework/Algorithms/src/ResampleX.cpp @@ -117,8 +117,8 @@ map<string, string> ResampleX::validateInputs() { *everything * went according to plan. */ -string determineXMinMax(MatrixWorkspace_sptr inputWS, vector<double> &xmins, - vector<double> &xmaxs) { +string determineXMinMax(const MatrixWorkspace_sptr &inputWS, + vector<double> &xmins, vector<double> &xmaxs) { const size_t numSpectra = inputWS->getNumberHistograms(); // pad out the ranges by copying the first value to the rest that are needed diff --git a/Framework/Algorithms/src/ResetNegatives.cpp b/Framework/Algorithms/src/ResetNegatives.cpp index 93fda48e7f8c86687806fe3cd479dc19a125017a..88f4fedbe3ded49e42ba201063a922ee2514a379 100644 --- a/Framework/Algorithms/src/ResetNegatives.cpp +++ b/Framework/Algorithms/src/ResetNegatives.cpp @@ -141,8 +141,9 @@ inline double fixZero(const double value) { * @param wksp The workspace to modify. * @param prog The progress. */ -void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, - MatrixWorkspace_sptr wksp, Progress &prog) { +void ResetNegatives::pushMinimum(const MatrixWorkspace_const_sptr &minWS, + const MatrixWorkspace_sptr &wksp, + Progress &prog) { int64_t nHist = minWS->getNumberHistograms(); PARALLEL_FOR_IF(Kernel::threadSafe(*wksp, *minWS)) for (int64_t i = 0; i < nHist; i++) { @@ -151,9 +152,9 @@ void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, if (minValue <= 0) { minValue *= -1.; auto &y = wksp->mutableY(i); - for (double &value : y) { - value = fixZero(value + minValue); - } + std::transform(y.begin(), y.end(), y.begin(), [minValue](double value) { + return fixZero(value + minValue); + }); } prog.report(); PARALLEL_END_INTERUPT_REGION @@ -171,9 +172,9 @@ void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, * @param wksp The workspace to modify. * @param prog The progress. */ -void ResetNegatives::changeNegatives(MatrixWorkspace_const_sptr minWS, +void ResetNegatives::changeNegatives(const MatrixWorkspace_const_sptr &minWS, const double spectrumNegativeValues, - MatrixWorkspace_sptr wksp, + const MatrixWorkspace_sptr &wksp, Progress &prog) { int64_t nHist = wksp->getNumberHistograms(); PARALLEL_FOR_IF(Kernel::threadSafe(*minWS, *wksp)) diff --git a/Framework/Algorithms/src/RingProfile.cpp b/Framework/Algorithms/src/RingProfile.cpp index 83f078ed350f3833d6c3a794dad3df001e753c37..e7647dc7c8275448d1ea0d2e4e887390bbd722db 100644 --- a/Framework/Algorithms/src/RingProfile.cpp +++ b/Framework/Algorithms/src/RingProfile.cpp @@ -215,7 +215,7 @@ void RingProfile::exec() { * @param inputWS: the input workspace */ void RingProfile::checkInputsForSpectraWorkspace( - const API::MatrixWorkspace_sptr inputWS) { + const API::MatrixWorkspace_sptr &inputWS) { try { // finding the limits of the instrument const auto &spectrumInfo = inputWS->spectrumInfo(); @@ -325,7 +325,7 @@ void RingProfile::checkInputsForSpectraWorkspace( * @param inputWS: pointer to the input workspace */ void RingProfile::checkInputsForNumericWorkspace( - const API::MatrixWorkspace_sptr inputWS) { + const API::MatrixWorkspace_sptr &inputWS) { g_log.notice() << "CheckingInputs For Numeric Workspace\n"; // The Axis0 is defined by the values of readX inside the spectra of the @@ -396,7 +396,8 @@ void RingProfile::checkInputsForNumericWorkspace( *integration values */ void RingProfile::processInstrumentRingProfile( - const API::MatrixWorkspace_sptr inputWS, std::vector<double> &output_bins) { + const API::MatrixWorkspace_sptr &inputWS, + std::vector<double> &output_bins) { const auto &spectrumInfo = inputWS->spectrumInfo(); for (int i = 0; i < static_cast<int>(inputWS->getNumberHistograms()); i++) { @@ -485,7 +486,8 @@ int RingProfile::getBinForPixel(const Kernel::V3D &position) { *integration values */ void RingProfile::processNumericImageRingProfile( - const API::MatrixWorkspace_sptr inputWS, std::vector<double> &output_bins) { + const API::MatrixWorkspace_sptr &inputWS, + std::vector<double> &output_bins) { // allocate the bin positions vector std::vector<int> bin_n(inputWS->dataY(0).size(), -1); @@ -538,7 +540,7 @@ void RingProfile::processNumericImageRingProfile( * @param bins_pos: bin positions (for each column inside the spectrum, the *correspondent bin_pos) */ -void RingProfile::getBinForPixel(const API::MatrixWorkspace_sptr ws, +void RingProfile::getBinForPixel(const API::MatrixWorkspace_sptr &ws, int spectrum_index, std::vector<int> &bins_pos) { diff --git a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp index 493c2497f9938a291544b22a0fd79d46b63ae1a3..6bc22fdb6582ac73e4c9324f4d888d1c6531f1f1 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp @@ -59,7 +59,8 @@ RunCombinationHelper::unWrapGroups(const std::vector<std::string> &inputs) { * to later check the compatibility of the others with the reference * @param ref : the reference workspace */ -void RunCombinationHelper::setReferenceProperties(MatrixWorkspace_sptr ref) { +void RunCombinationHelper::setReferenceProperties( + const MatrixWorkspace_sptr &ref) { m_numberSpectra = ref->getNumberHistograms(); m_numberDetectors = ref->detectorInfo().size(); m_xUnit = ref->getAxis(0)->unit()->unitID(); @@ -82,7 +83,7 @@ void RunCombinationHelper::setReferenceProperties(MatrixWorkspace_sptr ref) { * @return : empty if compatible, error message otherwises */ std::string -RunCombinationHelper::checkCompatibility(MatrixWorkspace_sptr ws, +RunCombinationHelper::checkCompatibility(const MatrixWorkspace_sptr &ws, bool checkNumberHistograms) { std::string errors; if (ws->getNumberHistograms() != m_numberSpectra && checkNumberHistograms) diff --git a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp index 4115dbbff7378f60c99a307eb6cff523ad2aee5e..03a6bf849742076c03dbb30636c356afaaa3c0cd 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp @@ -91,7 +91,7 @@ const std::string SampleLogsBehaviour::SUM_DOC = * @param parName the parameter names which specify the sample log sames to * merge given be the IPF */ -SampleLogsBehaviour::SampleLogsBehaviour(MatrixWorkspace_sptr ws, +SampleLogsBehaviour::SampleLogsBehaviour(const MatrixWorkspace_sptr &ws, Logger &logger, const SampleLogNames &logEntries, const ParameterName &parName) @@ -416,8 +416,8 @@ bool SampleLogsBehaviour::setNumericValue(const std::string &item, * @param addeeWS the workspace being merged * @param outWS the workspace the others are merged into */ -void SampleLogsBehaviour::mergeSampleLogs(MatrixWorkspace_sptr addeeWS, - MatrixWorkspace_sptr outWS) { +void SampleLogsBehaviour::mergeSampleLogs(const MatrixWorkspace_sptr &addeeWS, + const MatrixWorkspace_sptr &outWS) { for (const auto &item : m_logMap) { const std::string &logName = item.first.first; @@ -625,7 +625,8 @@ bool SampleLogsBehaviour::stringPropertiesMatch( * * @param outWS the merged workspace */ -void SampleLogsBehaviour::setUpdatedSampleLogs(MatrixWorkspace_sptr outWS) { +void SampleLogsBehaviour::setUpdatedSampleLogs( + const MatrixWorkspace_sptr &outWS) { for (auto &item : m_logMap) { std::string propertyToReset = item.first.first; @@ -647,7 +648,7 @@ void SampleLogsBehaviour::setUpdatedSampleLogs(MatrixWorkspace_sptr outWS) { * @param addeeWS the workspace being merged */ void SampleLogsBehaviour::removeSampleLogsFromWorkspace( - MatrixWorkspace_sptr addeeWS) { + const MatrixWorkspace_sptr &addeeWS) { for (const auto &prop : m_addeeLogMap) { const auto &propName = prop->name(); addeeWS->mutableRun().removeProperty(propName); @@ -663,7 +664,7 @@ void SampleLogsBehaviour::removeSampleLogsFromWorkspace( * @param addeeWS the workspace being merged */ void SampleLogsBehaviour::readdSampleLogToWorkspace( - MatrixWorkspace_sptr addeeWS) { + const MatrixWorkspace_sptr &addeeWS) { for (const auto &item : m_addeeLogMap) { auto property = std::unique_ptr<Kernel::Property>(item->clone()); addeeWS->mutableRun().addProperty(std::move(property)); @@ -676,7 +677,7 @@ void SampleLogsBehaviour::readdSampleLogToWorkspace( * * @param ws the merged workspace to reset the sample logs for */ -void SampleLogsBehaviour::resetSampleLogs(MatrixWorkspace_sptr ws) { +void SampleLogsBehaviour::resetSampleLogs(const MatrixWorkspace_sptr &ws) { for (auto const &item : m_logMap) { std::string const &propertyToReset = item.first.first; diff --git a/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp b/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp index 370940870bcce904641686be08bcb4bda0efaf4d..fdf2f1b04448db1c06ff293ef4b78330fddc0c3d 100644 --- a/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp +++ b/Framework/Algorithms/src/SANSCollimationLengthEstimator.cpp @@ -22,7 +22,7 @@ Mantid::Kernel::Logger g_log("SANSCollimationLengthEstimator"); * @param val: a value as a string * @returns true if it is convertible else false */ -bool checkForDouble(std::string val) { +bool checkForDouble(const std::string &val) { auto isDouble = false; try { boost::lexical_cast<double>(val); @@ -45,7 +45,7 @@ using namespace API; * @returns the collimation length */ double SANSCollimationLengthEstimator::provideCollimationLength( - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { // If the instrument does not have a correction specified then set the length // to 4 const double defaultLColim = 4.0; @@ -104,7 +104,7 @@ double SANSCollimationLengthEstimator::provideCollimationLength( * length */ double SANSCollimationLengthEstimator::getCollimationLengthWithGuides( - MatrixWorkspace_sptr inOutWS, const double L1, + const MatrixWorkspace_sptr &inOutWS, const double L1, const double collimationLengthCorrection) const { auto lCollim = L1 - collimationLengthCorrection; diff --git a/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp b/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp index 068b0e8ceb3ced189384c3cffbda5ec1660fdb48..41b007239b44cf0b732c44c1d2950b61eb512b7f 100644 --- a/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp +++ b/Framework/Algorithms/src/SampleCorrections/MCAbsorptionStrategy.cpp @@ -64,7 +64,7 @@ MCAbsorptionStrategy::MCAbsorptionStrategy( */ void MCAbsorptionStrategy::calculate( Kernel::PseudoRandomNumberGenerator &rng, const Kernel::V3D &finalPos, - Mantid::HistogramData::Points lambdas, double lambdaFixed, + const Mantid::HistogramData::Points &lambdas, double lambdaFixed, Mantid::API::ISpectrum &attenuationFactorsSpectrum) { const auto scatterBounds = m_scatterVol.getBoundingBox(); const auto nbins = static_cast<int>(lambdas.size()); diff --git a/Framework/Algorithms/src/SetUncertainties.cpp b/Framework/Algorithms/src/SetUncertainties.cpp index a7aefc2ae5e3ed1903ee4146c376371aa29e472e..c652e851177251d3b3866023630a50a512c2cea8 100644 --- a/Framework/Algorithms/src/SetUncertainties.cpp +++ b/Framework/Algorithms/src/SetUncertainties.cpp @@ -8,6 +8,7 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/EventWorkspace.h" #include "MantidGeometry/IDetector.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/BoundedValidator.h" @@ -111,6 +112,10 @@ void SetUncertainties::init() { void SetUncertainties::exec() { MatrixWorkspace_const_sptr inputWorkspace = getProperty("InputWorkspace"); + auto inputEventWorkspace = + boost::dynamic_pointer_cast<const DataObjects::EventWorkspace>( + inputWorkspace); + MatrixWorkspace_sptr outputWorkspace = getProperty("OutputWorkspace"); std::string errorType = getProperty("SetError"); bool zeroError = (errorType == ZERO); bool takeSqrt = ((errorType == SQRT) || (errorType == SQRT_OR_ONE)); @@ -120,32 +125,45 @@ void SetUncertainties::exec() { double valueToSet = resetOne ? 1.0 : getProperty("SetErrorTo"); double valueToCompare = resetOne ? 0.0 : getProperty("IfEqualTo"); int precision = getProperty("Precision"); - double tolerance = resetOne ? 1E-10 : std::pow(10.0, precision * (-1)); + double tolerance = resetOne ? 1E-10 : std::pow(10.0, -1. * precision); // Create the output workspace. This will copy many aspects from the input // one. - MatrixWorkspace_sptr outputWorkspace = - WorkspaceFactory::Instance().create(inputWorkspace); - // ...but not the data, so do that here. + const int64_t numHists = + static_cast<int64_t>(inputWorkspace->getNumberHistograms()); + if (inputEventWorkspace) { + if (inputWorkspace == outputWorkspace && errorType == SQRT && + inputEventWorkspace->getEventType() == Mantid::API::EventType::TOF) { + // Uncertainty is already square root of the y value + return; + } + // Copy the histogram representation over to a Workspace2D + outputWorkspace = WorkspaceFactory::Instance().create(inputWorkspace); + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace)) + for (int64_t i = 0; i < numHists; ++i) { + PARALLEL_START_INTERUPT_REGION + // copy X/Y/E + outputWorkspace->setSharedX(i, inputWorkspace->sharedX(i)); + outputWorkspace->setSharedY(i, inputWorkspace->sharedY(i)); + outputWorkspace->setSharedE(i, inputWorkspace->sharedE(i)); + PARALLEL_END_INTERUPT_REGION + } + PARALLEL_CHECK_INTERUPT_REGION + } else if (inputWorkspace != outputWorkspace) { + outputWorkspace = inputWorkspace->clone(); + } + const auto &spectrumInfo = inputWorkspace->spectrumInfo(); - const size_t numHists = inputWorkspace->getNumberHistograms(); Progress prog(this, 0.0, 1.0, numHists); - PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace)) - for (int64_t i = 0; i < int64_t(numHists); ++i) { + for (int64_t i = 0; i < numHists; ++i) { PARALLEL_START_INTERUPT_REGION - - // copy the X/Y - outputWorkspace->setSharedX(i, inputWorkspace->sharedX(i)); - outputWorkspace->setSharedY(i, inputWorkspace->sharedY(i)); // copy the E or set to zero depending on the mode if (errorType == ONE_IF_ZERO || customError) { - outputWorkspace->setSharedE(i, inputWorkspace->sharedE(i)); } else { outputWorkspace->mutableE(i) = 0.0; } - // ZERO mode doesn't calculate anything further if ((!zeroError) && (!(spectrumInfo.hasDetectors(i) && spectrumInfo.isMasked(i)))) { @@ -159,13 +177,10 @@ void SetUncertainties::exec() { SetError(valueToSet, valueToCompare, tolerance)); } } - prog.report(); - PARALLEL_END_INTERUPT_REGION } PARALLEL_CHECK_INTERUPT_REGION - setProperty("OutputWorkspace", outputWorkspace); } diff --git a/Framework/Algorithms/src/SmoothData.cpp b/Framework/Algorithms/src/SmoothData.cpp index b7ed93f3449e2d373eda30e3a600e3a0f9c10728..8893838585b9463e78f63b89be388df82924a679 100644 --- a/Framework/Algorithms/src/SmoothData.cpp +++ b/Framework/Algorithms/src/SmoothData.cpp @@ -73,11 +73,12 @@ void SmoothData::exec() { int npts = nptsGroup[0]; if (groupWS) { const int group = validateSpectrumInGroup(static_cast<size_t>(i)); - if (group < 0) + if (group == -1) { npts = 3; - else - // group is never 0. We can safely subtract. + } else { + assert(group != 0); npts = nptsGroup[group - 1]; + } } if (npts >= vecSize) { g_log.error("The number of averaging points requested is larger than the " @@ -103,7 +104,7 @@ void SmoothData::exec() { // Set the output workspace to its property setProperty("OutputWorkspace", outputWorkspace); -} +} // namespace Algorithms //============================================================================= /** Verify that all the contributing detectors to a spectrum belongs to the same * group diff --git a/Framework/Algorithms/src/SmoothNeighbours.cpp b/Framework/Algorithms/src/SmoothNeighbours.cpp index 68b04181ff44a1e9448746dd3b56ba360a8a3d35..8689b4a52377abd36d7604d4d483c4c0fbd34473 100644 --- a/Framework/Algorithms/src/SmoothNeighbours.cpp +++ b/Framework/Algorithms/src/SmoothNeighbours.cpp @@ -685,7 +685,7 @@ void SmoothNeighbours::setupNewInstrument(MatrixWorkspace &outws) const { //-------------------------------------------------------------------------------------------- /** Spread the average over all the pixels */ -void SmoothNeighbours::spreadPixels(MatrixWorkspace_sptr outws) { +void SmoothNeighbours::spreadPixels(const MatrixWorkspace_sptr &outws) { // Get some stuff from the input workspace const size_t numberOfSpectra = inWS->getNumberHistograms(); diff --git a/Framework/Algorithms/src/SofQWPolygon.cpp b/Framework/Algorithms/src/SofQWPolygon.cpp index f0825ef817df61f3840884cbc3f03d078af2def5..2cbaed6f6286c7a34c6a1f7e5b2bf875b557fe3e 100644 --- a/Framework/Algorithms/src/SofQWPolygon.cpp +++ b/Framework/Algorithms/src/SofQWPolygon.cpp @@ -146,7 +146,8 @@ void SofQWPolygon::exec() { * Init variables caches * @param workspace :: Workspace pointer */ -void SofQWPolygon::initCachedValues(API::MatrixWorkspace_const_sptr workspace) { +void SofQWPolygon::initCachedValues( + const API::MatrixWorkspace_const_sptr &workspace) { m_EmodeProperties.initCachedValues(*workspace, this); // Index theta cache initThetaCache(*workspace); diff --git a/Framework/Algorithms/src/SortXAxis.cpp b/Framework/Algorithms/src/SortXAxis.cpp index 9838aba48e14f89d604ebbccf35aed3f163eab0f..e20d1ac5deb590e1c07943ecb1538b529fcd0ec4 100644 --- a/Framework/Algorithms/src/SortXAxis.cpp +++ b/Framework/Algorithms/src/SortXAxis.cpp @@ -118,7 +118,7 @@ void sortByXValue(std::vector<std::size_t> &workspaceIndicies, } void SortXAxis::sortIndicesByX( - std::vector<std::size_t> &workspaceIndicies, std::string order, + std::vector<std::size_t> &workspaceIndicies, const std::string &order, const Mantid::API::MatrixWorkspace &inputWorkspace, unsigned int specNum) { if (order == "Ascending") { sortByXValue(workspaceIndicies, inputWorkspace, specNum, diff --git a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp index b8ccafe418699f0e3ac795e524bb5d48dba0c121..843e097cba6f8554f1af3e0ab1aa5881105a68e3 100644 --- a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp +++ b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp @@ -123,7 +123,7 @@ void SpecularReflectionAlgorithm::initCommonProperties() { */ Mantid::Geometry::IComponent_const_sptr SpecularReflectionAlgorithm::getSurfaceSampleComponent( - Mantid::Geometry::Instrument_const_sptr inst) const { + const Mantid::Geometry::Instrument_const_sptr &inst) const { std::string sampleComponent = "some-surface-holder"; if (!isPropertyDefault("SampleComponentName")) { sampleComponent = this->getPropertyValue("SampleComponentName"); @@ -148,7 +148,7 @@ SpecularReflectionAlgorithm::getSurfaceSampleComponent( */ boost::shared_ptr<const Mantid::Geometry::IComponent> SpecularReflectionAlgorithm::getDetectorComponent( - MatrixWorkspace_sptr workspace, const bool isPointDetector) const { + const MatrixWorkspace_sptr &workspace, const bool isPointDetector) const { boost::shared_ptr<const IComponent> searchResult; if (!isPropertyDefault("SpectrumNumbersOfDetectors")) { const std::vector<int> spectrumNumbers = diff --git a/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp b/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp index 8af2c852b46011c6196f1926db323f7f192f85cb..5d0e86593514e0284e78222695d28b1a47dd6878 100644 --- a/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp +++ b/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp @@ -138,8 +138,8 @@ void SpecularReflectionPositionCorrect::exec() { * @param detectorPosition: Actual detector or detector group position. */ void SpecularReflectionPositionCorrect::moveDetectors( - API::MatrixWorkspace_sptr toCorrect, IComponent_const_sptr detector, - IComponent_const_sptr sample, const double &upOffset, + const API::MatrixWorkspace_sptr &toCorrect, IComponent_const_sptr detector, + const IComponent_const_sptr &sample, const double &upOffset, const double &acrossOffset, const V3D &detectorPosition) { auto instrument = toCorrect->getInstrument(); const V3D samplePosition = sample->getPos(); @@ -203,8 +203,9 @@ void SpecularReflectionPositionCorrect::moveDetectors( * @param detector : Pointer to a given detector */ void SpecularReflectionPositionCorrect::correctPosition( - API::MatrixWorkspace_sptr toCorrect, const double &twoThetaInDeg, - IComponent_const_sptr sample, IComponent_const_sptr detector) { + const API::MatrixWorkspace_sptr &toCorrect, const double &twoThetaInDeg, + const IComponent_const_sptr &sample, + const IComponent_const_sptr &detector) { auto instrument = toCorrect->getInstrument(); diff --git a/Framework/Algorithms/src/Stitch1D.cpp b/Framework/Algorithms/src/Stitch1D.cpp index b0de3825d0bcdc20c302cf41875ee19e8cea8110..fc882cff79683705453c2c5e26a4fd5401192a86 100644 --- a/Framework/Algorithms/src/Stitch1D.cpp +++ b/Framework/Algorithms/src/Stitch1D.cpp @@ -644,7 +644,7 @@ void Stitch1D::exec() { /** Put special values back. * @param ws : MatrixWorkspace to resinsert special values into. */ -void Stitch1D::reinsertSpecialValues(MatrixWorkspace_sptr ws) { +void Stitch1D::reinsertSpecialValues(const MatrixWorkspace_sptr &ws) { auto histogramCount = static_cast<int>(ws->getNumberHistograms()); PARALLEL_FOR_IF(Kernel::threadSafe(*ws)) for (int i = 0; i < histogramCount; ++i) { diff --git a/Framework/Algorithms/src/Stitch1DMany.cpp b/Framework/Algorithms/src/Stitch1DMany.cpp index d89ceb8c802bc68e17b54b37eeaae9df4af7cd3e..bc582d28486ec715abf1847d4caf8f77056159a5 100644 --- a/Framework/Algorithms/src/Stitch1DMany.cpp +++ b/Framework/Algorithms/src/Stitch1DMany.cpp @@ -269,8 +269,10 @@ void Stitch1DMany::exec() { for (size_t i = 0; i < m_inputWSMatrix.front().size(); ++i) { std::vector<MatrixWorkspace_sptr> inMatrix; inMatrix.reserve(m_inputWSMatrix.size()); - for (const auto &ws : m_inputWSMatrix) - inMatrix.emplace_back(ws[i]); + + std::transform(m_inputWSMatrix.begin(), m_inputWSMatrix.end(), + std::back_inserter(inMatrix), + [i](const auto &ws) { return ws[i]; }); outName = groupName; Workspace_sptr outStitchedWS; diff --git a/Framework/Algorithms/src/StripPeaks.cpp b/Framework/Algorithms/src/StripPeaks.cpp index 18b48d1042edfa4726f72e9fc3ed3a93438715c7..cc52ce60bd926761063fb5cca0b8051a2bc34188 100644 --- a/Framework/Algorithms/src/StripPeaks.cpp +++ b/Framework/Algorithms/src/StripPeaks.cpp @@ -107,7 +107,8 @@ void StripPeaks::exec() { * @param WS :: The workspace to search * @return list of found peaks */ -API::ITableWorkspace_sptr StripPeaks::findPeaks(API::MatrixWorkspace_sptr WS) { +API::ITableWorkspace_sptr +StripPeaks::findPeaks(const API::MatrixWorkspace_sptr &WS) { g_log.debug("Calling FindPeaks as a Child Algorithm"); // Read from properties @@ -172,8 +173,8 @@ API::ITableWorkspace_sptr StripPeaks::findPeaks(API::MatrixWorkspace_sptr WS) { * @return A workspace containing the peak-subtracted data */ API::MatrixWorkspace_sptr -StripPeaks::removePeaks(API::MatrixWorkspace_const_sptr input, - API::ITableWorkspace_sptr peakslist) { +StripPeaks::removePeaks(const API::MatrixWorkspace_const_sptr &input, + const API::ITableWorkspace_sptr &peakslist) { g_log.debug("Subtracting peaks"); // Create an output workspace - same size as input one MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create(input); diff --git a/Framework/Algorithms/src/SumEventsByLogValue.cpp b/Framework/Algorithms/src/SumEventsByLogValue.cpp index de12e5beec5bd804e43a4572ab6cf4f1a5bd7dde..a6f0eb8f8adcddf27422379d75870015519becc7 100644 --- a/Framework/Algorithms/src/SumEventsByLogValue.cpp +++ b/Framework/Algorithms/src/SumEventsByLogValue.cpp @@ -302,9 +302,9 @@ void SumEventsByLogValue::filterEventList( * @param minVal The minimum value of the log * @param maxVal The maximum value of the log */ -void SumEventsByLogValue::addMonitorCounts(ITableWorkspace_sptr outputWorkspace, - const TimeSeriesProperty<int> *log, - const int minVal, const int maxVal) { +void SumEventsByLogValue::addMonitorCounts( + const ITableWorkspace_sptr &outputWorkspace, + const TimeSeriesProperty<int> *log, const int minVal, const int maxVal) { DataObjects::EventWorkspace_const_sptr monitorWorkspace = getProperty("MonitorWorkspace"); // If no monitor workspace was given, there's nothing to do diff --git a/Framework/Algorithms/src/SumSpectra.cpp b/Framework/Algorithms/src/SumSpectra.cpp index c08a7a0891a4dfae28920bb020ea9faf3da8e0dc..4b0e1b3edfbebb8fd0284e18bb213d8f57d7c665 100644 --- a/Framework/Algorithms/src/SumSpectra.cpp +++ b/Framework/Algorithms/src/SumSpectra.cpp @@ -324,7 +324,7 @@ void SumSpectra::determineIndices(const size_t numberOfSpectra) { * @return The minimum spectrum No for all the spectra being summed. */ specnum_t -SumSpectra::getOutputSpecNo(MatrixWorkspace_const_sptr localworkspace) { +SumSpectra::getOutputSpecNo(const MatrixWorkspace_const_sptr &localworkspace) { // initial value - any included spectrum will do specnum_t specId = localworkspace->getSpectrum(*(m_indices.begin())).getSpectrumNo(); @@ -435,7 +435,7 @@ bool useSpectrum(const SpectrumInfo &spectrumInfo, const size_t wsIndex, * @param numZeros The number of zero bins in histogram workspace or empty * spectra for event workspace. */ -void SumSpectra::doSimpleSum(MatrixWorkspace_sptr outputWorkspace, +void SumSpectra::doSimpleSum(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros) { // Clean workspace of any NANs or Inf values @@ -510,7 +510,7 @@ void SumSpectra::doSimpleSum(MatrixWorkspace_sptr outputWorkspace, * @param numZeros The number of zero bins in histogram workspace or empty * spectra for event workspace. */ -void SumSpectra::doFractionalSum(MatrixWorkspace_sptr outputWorkspace, +void SumSpectra::doFractionalSum(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros) { // First, we need to clean the input workspace for nan's and inf's in order @@ -608,7 +608,7 @@ void SumSpectra::doFractionalSum(MatrixWorkspace_sptr outputWorkspace, * @param numZeros The number of zero bins in histogram workspace or empty * spectra for event workspace. */ -void SumSpectra::execEvent(MatrixWorkspace_sptr outputWorkspace, +void SumSpectra::execEvent(const MatrixWorkspace_sptr &outputWorkspace, Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros) { MatrixWorkspace_const_sptr localworkspace = getProperty("InputWorkspace"); diff --git a/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp b/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp index 92327c6020d2bd5e56b9fcd4d5912491445450be..a5862b2866bf8cbe9625b432190474a028c3d686 100644 --- a/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp +++ b/Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp @@ -209,7 +209,7 @@ void TOFSANSResolutionByPixel::exec() { * @returns a copy of the input workspace */ MatrixWorkspace_sptr TOFSANSResolutionByPixel::setupOutputWorkspace( - MatrixWorkspace_sptr inputWorkspace) { + const MatrixWorkspace_sptr &inputWorkspace) { IAlgorithm_sptr duplicate = createChildAlgorithm("CloneWorkspace"); duplicate->initialize(); duplicate->setProperty<Workspace_sptr>("InputWorkspace", inputWorkspace); @@ -224,7 +224,7 @@ MatrixWorkspace_sptr TOFSANSResolutionByPixel::setupOutputWorkspace( * @returns the moderator workspace wiht the correct wavelength binning */ MatrixWorkspace_sptr TOFSANSResolutionByPixel::getModeratorWorkspace( - Mantid::API::MatrixWorkspace_sptr inputWorkspace) { + const Mantid::API::MatrixWorkspace_sptr &inputWorkspace) { MatrixWorkspace_sptr sigmaModerator = getProperty("SigmaModerator"); IAlgorithm_sptr rebinned = createChildAlgorithm("RebinToWorkspace"); @@ -242,7 +242,7 @@ MatrixWorkspace_sptr TOFSANSResolutionByPixel::getModeratorWorkspace( * @param inWS: the input workspace */ void TOFSANSResolutionByPixel::checkInput( - Mantid::API::MatrixWorkspace_sptr inWS) { + const Mantid::API::MatrixWorkspace_sptr &inWS) { // Make sure that input workspace has an instrument as we rely heavily on // thisa auto inst = inWS->getInstrument(); diff --git a/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp b/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp index 028f495e81e425191f517c7f67ab0a3f7ce9e9d2..e40755b92c351ce3e5db4d154d7e11255486f069 100644 --- a/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp +++ b/Framework/Algorithms/src/TimeAtSampleStrategyDirect.cpp @@ -27,7 +27,7 @@ namespace Algorithms { /** Constructor */ TimeAtSampleStrategyDirect::TimeAtSampleStrategyDirect( - MatrixWorkspace_const_sptr ws, double ei) + const MatrixWorkspace_const_sptr &ws, double ei) : m_constShift(0) { // A constant among all spectra diff --git a/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp b/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp index 46ecee6753c3f74004984b483345e1b376684933..d8ba32fbadaee01dcd130590ad7f8a69c6ed94ef 100644 --- a/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp +++ b/Framework/Algorithms/src/TimeAtSampleStrategyElastic.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidAlgorithms/TimeAtSampleStrategyElastic.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" +#include "MantidAlgorithms/TimeAtSampleStrategyElastic.h" #include "MantidGeometry/IComponent.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/ReferenceFrame.h" @@ -22,7 +24,7 @@ namespace Algorithms { */ TimeAtSampleStrategyElastic::TimeAtSampleStrategyElastic( Mantid::API::MatrixWorkspace_const_sptr ws) - : m_ws(ws), m_spectrumInfo(m_ws->spectrumInfo()), + : m_ws(std::move(ws)), m_spectrumInfo(m_ws->spectrumInfo()), m_beamDir( m_ws->getInstrument()->getReferenceFrame()->vecPointingAlongBeam()) {} diff --git a/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp b/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp index e173a5e3568f272e35b2f38f55c7eebab3ac7a2a..1084de35630bd11f226445f06e5360f189680cab 100644 --- a/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp +++ b/Framework/Algorithms/src/TimeAtSampleStrategyIndirect.cpp @@ -18,6 +18,7 @@ #include <boost/shared_ptr.hpp> #include <cmath> #include <sstream> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::Geometry; @@ -30,7 +31,7 @@ namespace Algorithms { */ TimeAtSampleStrategyIndirect::TimeAtSampleStrategyIndirect( MatrixWorkspace_const_sptr ws) - : m_ws(ws), m_spectrumInfo(m_ws->spectrumInfo()) {} + : m_ws(std::move(ws)), m_spectrumInfo(m_ws->spectrumInfo()) {} Correction TimeAtSampleStrategyIndirect::calculate(const size_t &workspace_index) const { diff --git a/Framework/Algorithms/src/Transpose.cpp b/Framework/Algorithms/src/Transpose.cpp index edf886f726a8df8c98cff4202b06e60dfcab2ff5..ac7f1807bb9f779a8513cf16944f97e1107261fd 100644 --- a/Framework/Algorithms/src/Transpose.cpp +++ b/Framework/Algorithms/src/Transpose.cpp @@ -98,7 +98,7 @@ void Transpose::exec() { * @return A pointer to the output workspace. */ API::MatrixWorkspace_sptr Transpose::createOutputWorkspace( - API::MatrixWorkspace_const_sptr inputWorkspace) { + const API::MatrixWorkspace_const_sptr &inputWorkspace) { Mantid::API::Axis *yAxis = getVerticalAxis(inputWorkspace); const size_t oldNhist = inputWorkspace->getNumberHistograms(); const auto &inX = inputWorkspace->x(0); @@ -138,8 +138,8 @@ API::MatrixWorkspace_sptr Transpose::createOutputWorkspace( * @param workspace :: A pointer to a workspace * @return An axis pointer for the vertical axis of the input workspace */ -API::Axis * -Transpose::getVerticalAxis(API::MatrixWorkspace_const_sptr workspace) const { +API::Axis *Transpose::getVerticalAxis( + const API::MatrixWorkspace_const_sptr &workspace) const { API::Axis *yAxis; try { yAxis = workspace->getAxis(1); diff --git a/Framework/Algorithms/src/WienerSmooth.cpp b/Framework/Algorithms/src/WienerSmooth.cpp index 3b28573c8696ebc7e067d20eeb5f8bbca21065ab..a2c56911f3b3cbb784669301468ac6abaf7b3f93 100644 --- a/Framework/Algorithms/src/WienerSmooth.cpp +++ b/Framework/Algorithms/src/WienerSmooth.cpp @@ -420,7 +420,8 @@ WienerSmooth::getStartEnd(const Mantid::HistogramData::HistogramX &X, * @return :: Workspace with the copied spectrum. */ API::MatrixWorkspace_sptr -WienerSmooth::copyInput(API::MatrixWorkspace_sptr inputWS, size_t wsIndex) { +WienerSmooth::copyInput(const API::MatrixWorkspace_sptr &inputWS, + size_t wsIndex) { auto alg = createChildAlgorithm("ExtractSingleSpectrum"); alg->initialize(); alg->setProperty("InputWorkspace", inputWS); diff --git a/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp b/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp index 5cad33ea450c240aa7224eb0f8d19e5b1f9ae399..4262dd66ef98633aad357f1077bcb83eaa302e70 100644 --- a/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp +++ b/Framework/Algorithms/src/WorkflowAlgorithmRunner.cpp @@ -59,7 +59,8 @@ std::string tidyWorkspaceName(const std::string &s) { * @throw std::runtime_error in case of errorneous entries in `table` */ template <typename MAP> -void cleanPropertyTable(ITableWorkspace_sptr table, const MAP &ioMapping) { +void cleanPropertyTable(const ITableWorkspace_sptr &table, + const MAP &ioMapping) { // Some output columns may be processed several times, but this should // not be a serious performance hit. for (const auto &ioPair : ioMapping) { diff --git a/Framework/Algorithms/src/XDataConverter.cpp b/Framework/Algorithms/src/XDataConverter.cpp index 54aacafa83cab9047cde3e17af6fa4b2dc769214..b656ca879a0962a0227f56ddbd8b16931e384341 100644 --- a/Framework/Algorithms/src/XDataConverter.cpp +++ b/Framework/Algorithms/src/XDataConverter.cpp @@ -90,7 +90,7 @@ void XDataConverter::exec() { } std::size_t -XDataConverter::getNewYSize(const API::MatrixWorkspace_sptr inputWS) { +XDataConverter::getNewYSize(const API::MatrixWorkspace_sptr &inputWS) { // this is the old behavior of MatrixWorkspace::blocksize() return inputWS->y(0).size(); } @@ -101,8 +101,8 @@ XDataConverter::getNewYSize(const API::MatrixWorkspace_sptr inputWS) { * @param inputWS :: The input workspace * @param index :: The index */ -void XDataConverter::setXData(API::MatrixWorkspace_sptr outputWS, - const API::MatrixWorkspace_sptr inputWS, +void XDataConverter::setXData(const API::MatrixWorkspace_sptr &outputWS, + const API::MatrixWorkspace_sptr &inputWS, const int index) { if (m_sharedX) { PARALLEL_CRITICAL(XDataConverter_para) { diff --git a/Framework/Algorithms/test/AddNoteTest.h b/Framework/Algorithms/test/AddNoteTest.h index 547493876e9581ef288c90c274550ad9753af0e2..57338460fd0bfd680e407c6f0869fd5290df74de 100644 --- a/Framework/Algorithms/test/AddNoteTest.h +++ b/Framework/Algorithms/test/AddNoteTest.h @@ -88,9 +88,9 @@ public: } private: - void executeAlgorithm(Mantid::API::MatrixWorkspace_sptr testWS, + void executeAlgorithm(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logTime, - const std::string logValue, + const std::string &logValue, const UpdateType update = Update) { Mantid::Algorithms::AddNote alg; @@ -110,11 +110,11 @@ private: } template <typename T> - void checkLogWithEntryExists(Mantid::API::MatrixWorkspace_sptr testWS, + void checkLogWithEntryExists(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logStartTime, const int &logEndTime, - const std::string logValue, + const std::string &logValue, const size_t position) { using Mantid::Kernel::TimeSeriesProperty; using Mantid::Types::Core::DateAndTime; diff --git a/Framework/Algorithms/test/AddSampleLogTest.h b/Framework/Algorithms/test/AddSampleLogTest.h index f929806e824ced1e1f076b7b1fb3fddb2b560e55..45d9bec83ff41af98f380b695ccc88368ed91ac5 100644 --- a/Framework/Algorithms/test/AddSampleLogTest.h +++ b/Framework/Algorithms/test/AddSampleLogTest.h @@ -170,11 +170,12 @@ public: } template <typename T> - void - ExecuteAlgorithm(MatrixWorkspace_sptr testWS, std::string LogName, - std::string LogType, std::string LogText, T expectedValue, - bool fails = false, std::string LogUnit = "", - std::string NumberType = "AutoDetect", bool throws = false) { + void ExecuteAlgorithm(const MatrixWorkspace_sptr &testWS, + const std::string &LogName, const std::string &LogType, + const std::string &LogText, T expectedValue, + bool fails = false, const std::string &LogUnit = "", + const std::string &NumberType = "AutoDetect", + bool throws = false) { // add the workspace to the ADS AnalysisDataService::Instance().addOrReplace("AddSampleLogTest_Temporary", testWS); diff --git a/Framework/Algorithms/test/AddTimeSeriesLogTest.h b/Framework/Algorithms/test/AddTimeSeriesLogTest.h index 8811ed1163c8c8e5f73751e88e6f93b964a96bdb..7a7fb480e888134123079dab752fa71926faf422 100644 --- a/Framework/Algorithms/test/AddTimeSeriesLogTest.h +++ b/Framework/Algorithms/test/AddTimeSeriesLogTest.h @@ -134,7 +134,7 @@ public: } private: - void executeAlgorithm(Mantid::API::MatrixWorkspace_sptr testWS, + void executeAlgorithm(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logTime, const double logValue, const LogType type = Double, const UpdateType update = Update) { @@ -157,7 +157,7 @@ private: } template <typename T> - void checkLogWithEntryExists(Mantid::API::MatrixWorkspace_sptr testWS, + void checkLogWithEntryExists(const Mantid::API::MatrixWorkspace_sptr &testWS, const std::string &logName, const std::string &logTime, const T logValue, const size_t position) { diff --git a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h index 89f511c9ebf2443a269e06e937c7b91e30807ad2..00416e4ad487fde80e1613c6d4b4ea7b5d32e804 100644 --- a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h +++ b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h @@ -257,7 +257,6 @@ public: constexpr double WL_DELTA = (2.9 - WL_MIN) / static_cast<double>(NUM_VALS); // create the input workspace - const std::string IN_WS{"AbsorptionCorrection_Input"}; auto inputWS = WorkspaceCreationHelper::create2DWorkspaceBinned( 1, NUM_VALS, WL_MIN, WL_DELTA); auto testInst = diff --git a/Framework/Algorithms/test/AppendSpectraTest.h b/Framework/Algorithms/test/AppendSpectraTest.h index 1e584609848c81afcbce6a83c4d7252a3a28c15a..261eb100c1fb797034f42f05e8cd230c4d29ef16 100644 --- a/Framework/Algorithms/test/AppendSpectraTest.h +++ b/Framework/Algorithms/test/AppendSpectraTest.h @@ -432,9 +432,9 @@ private: } /** Creates a 2D workspace with 5 histograms */ - void createWorkspaceWithAxisAndLabel(const std::string outputName, + void createWorkspaceWithAxisAndLabel(const std::string &outputName, const std::string &axisType, - const std::string axisValue) { + const std::string &axisValue) { int nspec = 5; std::vector<std::string> YVals; std::vector<double> dataX; diff --git a/Framework/Algorithms/test/ApplyCalibrationTest.h b/Framework/Algorithms/test/ApplyCalibrationTest.h index c666885b977991da9672de2b0e2ac0c41591055a..fb596ef039a72c7add3b78fe715ad46eff55ef56 100644 --- a/Framework/Algorithms/test/ApplyCalibrationTest.h +++ b/Framework/Algorithms/test/ApplyCalibrationTest.h @@ -82,11 +82,9 @@ public: TS_ASSERT(appCalib.isExecuted()); const auto &spectrumInfo = ws->spectrumInfo(); - const auto &componentInfo = ws->componentInfo(); int id = spectrumInfo.detector(0).getID(); V3D newPos = spectrumInfo.position(0); - V3D scaleFactor = componentInfo.scaleFactor(0); TS_ASSERT_EQUALS(id, 1); TS_ASSERT_DELTA(newPos.X(), 1.0, 0.0001); @@ -95,7 +93,6 @@ public: id = spectrumInfo.detector(ndets - 1).getID(); newPos = spectrumInfo.position(ndets - 1); - scaleFactor = componentInfo.scaleFactor(0); TS_ASSERT_EQUALS(id, ndets); TS_ASSERT_DELTA(newPos.X(), 1.0, 0.0001); diff --git a/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h b/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h index aa6663deaabd64a8eda53875a22e14d0f6f1d5ff..513fa13adac8800cf9c17631ce33d53889596373 100644 --- a/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h +++ b/Framework/Algorithms/test/ApplyFloodWorkspaceTest.h @@ -65,9 +65,9 @@ public: } private: - MatrixWorkspace_sptr - createFloodWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &xUnit = "TOF") { + MatrixWorkspace_sptr createFloodWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &xUnit = "TOF") { MatrixWorkspace_sptr flood = create2DWorkspace(4, 1); flood->mutableY(0)[0] = 0.7; flood->mutableY(1)[0] = 1.0; diff --git a/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h b/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h index bcfff101bcac39ab2c05ed39c09d991278619a8a..d3e34e2f6d227f8fee16fb107e51dfd768b65b43 100644 --- a/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h +++ b/Framework/Algorithms/test/Bin2DPowderDiffractionTest.h @@ -284,7 +284,7 @@ private: } // creates test file with bins description - void createBinFile(std::string fname) { + void createBinFile(const std::string &fname) { std::ofstream binfile; binfile.open(fname); binfile << "#dp_min #dp_max\n"; diff --git a/Framework/Algorithms/test/BinaryOperationTest.h b/Framework/Algorithms/test/BinaryOperationTest.h index b7fc31ca5216eb8cf84fb994f3a38107f23e78e0..fb694bd5b81f19abc45df13f9f5faa9cead4496f 100644 --- a/Framework/Algorithms/test/BinaryOperationTest.h +++ b/Framework/Algorithms/test/BinaryOperationTest.h @@ -7,6 +7,8 @@ #pragma once #include <cmath> +#include <utility> + #include <cxxtest/TestSuite.h> #include "MantidAPI/AnalysisDataService.h" @@ -42,8 +44,8 @@ public: /// is provided. const std::string summary() const override { return "Summary of this test."; } - std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr ws1, - const MatrixWorkspace_const_sptr ws2) { + std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { m_lhs = ws1; m_rhs = ws2; m_lhsBlocksize = ws1->blocksize(); @@ -297,9 +299,11 @@ public: std::vector<std::vector<int>> rhs, bool expect_throw = false) { EventWorkspace_sptr lhsWS = - WorkspaceCreationHelper::createGroupedEventWorkspace(lhs, 50, 1.0); + WorkspaceCreationHelper::createGroupedEventWorkspace(std::move(lhs), 50, + 1.0); EventWorkspace_sptr rhsWS = - WorkspaceCreationHelper::createGroupedEventWorkspace(rhs, 50, 1.0); + WorkspaceCreationHelper::createGroupedEventWorkspace(std::move(rhs), 50, + 1.0); BinaryOperation::BinaryOperationTable_sptr table; Mantid::Kernel::Timer timer1; if (expect_throw) { diff --git a/Framework/Algorithms/test/CalculateDIFCTest.h b/Framework/Algorithms/test/CalculateDIFCTest.h index 8e15a35d9c4c45f260f61cd7f2512d7d2236c908..509a4925d6572ffec033bd3d26fe837dd4b25ad5 100644 --- a/Framework/Algorithms/test/CalculateDIFCTest.h +++ b/Framework/Algorithms/test/CalculateDIFCTest.h @@ -39,8 +39,8 @@ public: TS_ASSERT(alg.isInitialized()) } - void runTest(Workspace2D_sptr inputWS, OffsetsWorkspace_sptr offsetsWS, - std::string &outWSName) { + void runTest(const Workspace2D_sptr &inputWS, + const OffsetsWorkspace_sptr &offsetsWS, std::string &outWSName) { CalculateDIFC alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h index 8fb91e7509e52aa4b8aba7f6d6ac67b0763800d7..7c65acff010c91d5b4600d49e7bbc0c1f47f6966 100644 --- a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h +++ b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h @@ -763,6 +763,7 @@ private: AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( "Removed1"); for (size_t j = 0; j < spectraCount; ++j) { + // cppcheck-suppress unreadVariable const double expected = (movingAverageSpecialY(j) + (static_cast<double>(windowWidth) - 1) * movingAverageStandardY(j)) / @@ -839,7 +840,8 @@ private: } void compareSubtractedAndBackgroundWorkspaces( - MatrixWorkspace_sptr originalWS, const std::string &subtractedWSName, + const MatrixWorkspace_sptr &originalWS, + const std::string &subtractedWSName, const std::string &backgroundWSName) { const std::string minusWSName("minused"); MatrixWorkspace_sptr backgroundWS = diff --git a/Framework/Algorithms/test/CalculateIqtTest.h b/Framework/Algorithms/test/CalculateIqtTest.h index 132ac4c142c5e48ec4ea3647cc8bbaebd16b507b..c0eb3d2d8f9a70a7a80eabceb64ea2087246192d 100644 --- a/Framework/Algorithms/test/CalculateIqtTest.h +++ b/Framework/Algorithms/test/CalculateIqtTest.h @@ -54,8 +54,8 @@ Mantid::API::MatrixWorkspace_sptr setUpResolutionWorkspace() { return createWorkspace->getProperty("OutputWorkspace"); } -IAlgorithm_sptr calculateIqtAlgorithm(MatrixWorkspace_sptr sample, - MatrixWorkspace_sptr resolution, +IAlgorithm_sptr calculateIqtAlgorithm(const MatrixWorkspace_sptr &sample, + const MatrixWorkspace_sptr &resolution, const double EnergyMin = -0.5, const double EnergyMax = 0.5, const double EnergyWidth = 0.1, diff --git a/Framework/Algorithms/test/CalculateTransmissionTest.h b/Framework/Algorithms/test/CalculateTransmissionTest.h index 238ab958c5f0683bd41b4a8abc6cb8fa44ba0511..f440374c3394b48968779ce29a492e780b275fcb 100644 --- a/Framework/Algorithms/test/CalculateTransmissionTest.h +++ b/Framework/Algorithms/test/CalculateTransmissionTest.h @@ -361,10 +361,9 @@ public: auto &fitted_x = fitted->x(0); // TS_ASSERT_EQUALS(fitted_y.size(), unfitted_y.size()); - double x; for (unsigned int i = 0; i < fitted_y.size(); ++i) { - x = fitted_x[i]; //(fitted_x[i] + fitted_x[i+1])* 0.5; + double x = fitted_x[i]; //(fitted_x[i] + fitted_x[i+1])* 0.5; TS_ASSERT_DELTA(fitted_y[i], 26.6936 - 9.31494 * x + 1.11532 * x * x - 0.044502 * x * x * x, @@ -405,10 +404,9 @@ public: auto &fitted_x = fitted->x(0); // TS_ASSERT_EQUALS(fitted_y.size(), unfitted_y.size()); - double x; for (unsigned int i = 0; i < fitted_y.size(); ++i) { - x = (fitted_x[i] + fitted_x[i + 1]) * 0.5; + double x = (fitted_x[i] + fitted_x[i + 1]) * 0.5; TS_ASSERT_DELTA(fitted_y[i], 26.6936 - 9.31494 * x + 1.11532 * x * x - 0.044502 * x * x * x, diff --git a/Framework/Algorithms/test/ChainedOperatorTest.h b/Framework/Algorithms/test/ChainedOperatorTest.h index 4e51d242ecd5ef003050e00557b4f18972fa94b5..36ecc1c4749602673c2a75bb540d91fd1b61221a 100644 --- a/Framework/Algorithms/test/ChainedOperatorTest.h +++ b/Framework/Algorithms/test/ChainedOperatorTest.h @@ -70,8 +70,8 @@ public: performTest(work_in1, work_in2); } - void performTest(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_in2) { + void performTest(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2) { ComplexOpTest alg; std::string wsNameIn1 = "testChainedOperator_in21"; @@ -98,9 +98,9 @@ public: } private: - void checkData(const MatrixWorkspace_sptr work_in1, - const MatrixWorkspace_sptr work_in2, - const MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1) { size_t ws2LoopCount = 0; if (work_in2->size() > 0) { ws2LoopCount = work_in1->size() / work_in2->size(); @@ -112,9 +112,9 @@ private: } } - void checkDataItem(const MatrixWorkspace_sptr work_in1, - const MatrixWorkspace_sptr work_in2, - const MatrixWorkspace_sptr work_out1, size_t i, + void checkDataItem(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, size_t i, size_t ws2Index) { double sig1 = work_in1->readY(i / work_in1->blocksize())[i % work_in1->blocksize()]; diff --git a/Framework/Algorithms/test/ChangeLogTimeTest.h b/Framework/Algorithms/test/ChangeLogTimeTest.h index b923e8da0f2c16989e6c56be133342f48bf1b872..e7007c0f3046126c0a3ecda4ba5ae8e8dd062fd4 100644 --- a/Framework/Algorithms/test/ChangeLogTimeTest.h +++ b/Framework/Algorithms/test/ChangeLogTimeTest.h @@ -52,7 +52,7 @@ private: * @param in_name Name of the input workspace. * @param out_name Name of the output workspace. */ - void verify(const std::string in_name, const std::string out_name) { + void verify(const std::string &in_name, const std::string &out_name) { DateAndTime start(start_str); // create a workspace to mess with diff --git a/Framework/Algorithms/test/ChangePulsetime2Test.h b/Framework/Algorithms/test/ChangePulsetime2Test.h index 383501bfa2a87b3f9a8be3077cc06aeff3e694b8..5e39d09bfcf7ca0597d0872b2ca4efc58e9f8287 100644 --- a/Framework/Algorithms/test/ChangePulsetime2Test.h +++ b/Framework/Algorithms/test/ChangePulsetime2Test.h @@ -22,8 +22,9 @@ using Mantid::Types::Core::DateAndTime; namespace { EventWorkspace_sptr -execute_change_of_pulse_times(EventWorkspace_sptr in_ws, std::string timeOffset, - std::string workspaceIndexList) { +execute_change_of_pulse_times(const EventWorkspace_sptr &in_ws, + const std::string &timeOffset, + const std::string &workspaceIndexList) { // Create and run the algorithm ChangePulsetime2 alg; alg.initialize(); @@ -53,8 +54,8 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string in_ws_name, std::string out_ws_name, - std::string WorkspaceIndexList) { + void do_test(const std::string &in_ws_name, const std::string &out_ws_name, + const std::string &WorkspaceIndexList) { ChangePulsetime2 alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/Algorithms/test/ChangePulsetimeTest.h b/Framework/Algorithms/test/ChangePulsetimeTest.h index 6ecb5b9e5a450506fba46043b54dacadaf22fd29..22500e9fc344b6056fee0d93165acbdaf3fa5a11 100644 --- a/Framework/Algorithms/test/ChangePulsetimeTest.h +++ b/Framework/Algorithms/test/ChangePulsetimeTest.h @@ -21,8 +21,9 @@ using Mantid::Types::Core::DateAndTime; namespace { EventWorkspace_sptr -execute_change_of_pulse_times(EventWorkspace_sptr in_ws, std::string timeOffset, - std::string workspaceIndexList) { +execute_change_of_pulse_times(const EventWorkspace_sptr &in_ws, + const std::string &timeOffset, + const std::string &workspaceIndexList) { // Create and run the algorithm ChangePulsetime alg; alg.initialize(); @@ -51,8 +52,8 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string in_ws_name, std::string out_ws_name, - std::string WorkspaceIndexList) { + void do_test(const std::string &in_ws_name, const std::string &out_ws_name, + const std::string &WorkspaceIndexList) { ChangePulsetime alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/Algorithms/test/ChangeTimeZeroTest.h b/Framework/Algorithms/test/ChangeTimeZeroTest.h index 81e7d68a053f390bbe759cb448424f0cff504930..8c69978f19eb48a2887e3dcf4bc861c1e1604fe1 100644 --- a/Framework/Algorithms/test/ChangeTimeZeroTest.h +++ b/Framework/Algorithms/test/ChangeTimeZeroTest.h @@ -9,6 +9,8 @@ #include "MantidKernel/Timer.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/ScopedWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" @@ -36,8 +38,8 @@ DateAndTime stringPropertyTime("2010-01-01T00:10:00"); enum LogType { STANDARD, NOPROTONCHARGE }; template <typename T> -void addTimeSeriesLogToWorkspace(Mantid::API::MatrixWorkspace_sptr ws, - std::string id, DateAndTime startTime, +void addTimeSeriesLogToWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &id, DateAndTime startTime, T defaultValue, int length) { auto timeSeries = new TimeSeriesProperty<T>(id); timeSeries->setUnits("mm"); @@ -48,15 +50,15 @@ void addTimeSeriesLogToWorkspace(Mantid::API::MatrixWorkspace_sptr ws, } template <typename T> -void addProperyWithValueToWorkspace(Mantid::API::MatrixWorkspace_sptr ws, - std::string id, T value) { +void addProperyWithValueToWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &id, T value) { auto propWithVal = new PropertyWithValue<T>(id, value); propWithVal->setUnits("mm"); ws->mutableRun().addProperty(propWithVal, true); } // Provide the logs for matrix workspaces -void provideLogs(LogType logType, Mantid::API::MatrixWorkspace_sptr ws, +void provideLogs(LogType logType, const Mantid::API::MatrixWorkspace_sptr &ws, DateAndTime startTime, int length) { switch (logType) { case (STANDARD): @@ -96,7 +98,7 @@ void provideLogs(LogType logType, Mantid::API::MatrixWorkspace_sptr ws, // Provides a 2D workspace with a log Mantid::API::MatrixWorkspace_sptr provideWorkspace2D(LogType logType, - std::string wsName, + const std::string &wsName, DateAndTime startTime, int length) { Workspace2D_sptr ws(new Workspace2D); @@ -140,9 +142,9 @@ provideEventWorkspace(LogType logType, DateAndTime startTime, int length) { return provideEventWorkspaceCustom(logType, startTime, length, 100, 100, 100); } -MatrixWorkspace_sptr execute_change_time(MatrixWorkspace_sptr in_ws, +MatrixWorkspace_sptr execute_change_time(const MatrixWorkspace_sptr &in_ws, double relativeTimeOffset, - std::string absolutTimeOffset) { + const std::string &absolutTimeOffset) { // Create and run the algorithm ChangeTimeZero alg; alg.initialize(); @@ -441,8 +443,9 @@ private: int m_length; // act and assert - void act_and_assert(double relativeTimeShift, std::string absoluteTimeShift, - MatrixWorkspace_sptr in_ws, + void act_and_assert(double relativeTimeShift, + const std::string &absoluteTimeShift, + const MatrixWorkspace_sptr &in_ws, bool inputEqualsOutputWorkspace) { // Create a duplicate workspace EventWorkspace_sptr duplicate_ws; @@ -484,8 +487,8 @@ private: } // perform the verification - void do_test_shift(MatrixWorkspace_sptr ws, const double timeShift, - MatrixWorkspace_sptr duplicate) const { + void do_test_shift(const MatrixWorkspace_sptr &ws, const double timeShift, + const MatrixWorkspace_sptr &duplicate) const { // Check the logs TS_ASSERT(ws); @@ -501,7 +504,7 @@ private: // Check the neutrons if (auto outWs = boost::dynamic_pointer_cast<EventWorkspace>(ws)) { - do_check_workspace(outWs, timeShift, duplicate); + do_check_workspace(outWs, timeShift, std::move(duplicate)); } } @@ -536,8 +539,8 @@ private: } // Check contents of an event workspace. We compare the time stamps to the // time stamps of the duplicate workspace - void do_check_workspace(EventWorkspace_sptr ws, double timeShift, - MatrixWorkspace_sptr duplicate) const { + void do_check_workspace(const EventWorkspace_sptr &ws, double timeShift, + const MatrixWorkspace_sptr &duplicate) const { // Get the duplicate input workspace for comparison reasons auto duplicateWs = boost::dynamic_pointer_cast<EventWorkspace>(duplicate); @@ -562,7 +565,7 @@ private: // Create comparison workspace EventWorkspace_sptr - createComparisonWorkspace(EventWorkspace_sptr inputWorkspace) { + createComparisonWorkspace(const EventWorkspace_sptr &inputWorkspace) { CloneWorkspace alg; alg.setChild(true); TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/Algorithms/test/CheckWorkspacesMatchTest.h b/Framework/Algorithms/test/CheckWorkspacesMatchTest.h index 716105ed1a88be94a9142d4283e9ee6966f264c4..87630794e631474e0411e9ac6b5c6c09d79a696d 100644 --- a/Framework/Algorithms/test/CheckWorkspacesMatchTest.h +++ b/Framework/Algorithms/test/CheckWorkspacesMatchTest.h @@ -1140,7 +1140,7 @@ private: TS_ASSERT_EQUALS(matcher.getPropertyValue("Result"), expectedResult); } - void cleanupGroup(const WorkspaceGroup_sptr group) { + void cleanupGroup(const WorkspaceGroup_sptr &group) { // group->deepRemoveAll(); const std::string name = group->getName(); Mantid::API::AnalysisDataService::Instance().deepRemoveGroup(name); diff --git a/Framework/Algorithms/test/ClearCacheTest.h b/Framework/Algorithms/test/ClearCacheTest.h index 73069ee0a44b853209439068ea8668614a494a63..d6f1a2a7a2a41f1d1ea6ca178d005513dc60cff8 100644 --- a/Framework/Algorithms/test/ClearCacheTest.h +++ b/Framework/Algorithms/test/ClearCacheTest.h @@ -49,7 +49,7 @@ public: createDirectory(GeomPath); } - void createDirectory(Poco::Path path) { + void createDirectory(const Poco::Path &path) { Poco::File file(path); if (file.createDirectory()) { m_directoriesToRemove.emplace_back(file); diff --git a/Framework/Algorithms/test/ClearInstrumentParametersTest.h b/Framework/Algorithms/test/ClearInstrumentParametersTest.h index cd866bdc40acc55cf06b4e1e9da0f4c2baf688da..2e8d40202a598a925faf87f32b48d9824fab1852 100644 --- a/Framework/Algorithms/test/ClearInstrumentParametersTest.h +++ b/Framework/Algorithms/test/ClearInstrumentParametersTest.h @@ -47,21 +47,23 @@ public: TS_ASSERT_EQUALS(oldPos, m_ws->detectorInfo().position(0)); } - void setParam(std::string cName, std::string pName, std::string value) { + void setParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addString(comp->getComponentID(), pName, value); } - void setParam(std::string cName, std::string pName, double value) { + void setParam(const std::string &cName, const std::string &pName, + double value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addDouble(comp->getComponentID(), pName, value); } - void checkEmpty(std::string cName, std::string pName) { + void checkEmpty(const std::string &cName, const std::string &pName) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); diff --git a/Framework/Algorithms/test/CommutativeBinaryOperationTest.h b/Framework/Algorithms/test/CommutativeBinaryOperationTest.h index 24eb4aaa6fff32a55c8f6988f04af2ca5253a003..a7c834710b1fa98356809efef6257143045949fc 100644 --- a/Framework/Algorithms/test/CommutativeBinaryOperationTest.h +++ b/Framework/Algorithms/test/CommutativeBinaryOperationTest.h @@ -33,8 +33,8 @@ public: return "Commutative binary operation helper."; } - std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr ws1, - const MatrixWorkspace_const_sptr ws2) { + std::string checkSizeCompatibility(const MatrixWorkspace_const_sptr &ws1, + const MatrixWorkspace_const_sptr &ws2) { m_lhs = ws1; m_rhs = ws2; m_lhsBlocksize = ws1->blocksize(); diff --git a/Framework/Algorithms/test/CompareWorkspacesTest.h b/Framework/Algorithms/test/CompareWorkspacesTest.h index fe15a2ed1e00a56af6781180ca8ed86131ba5669..a2d907d86fa79e55636705aa119eea1e125c192a 100644 --- a/Framework/Algorithms/test/CompareWorkspacesTest.h +++ b/Framework/Algorithms/test/CompareWorkspacesTest.h @@ -1351,7 +1351,7 @@ private: } } - void cleanupGroup(const WorkspaceGroup_sptr group) { + void cleanupGroup(const WorkspaceGroup_sptr &group) { // group->deepRemoveAll(); const std::string name = group->getName(); Mantid::API::AnalysisDataService::Instance().deepRemoveGroup(name); diff --git a/Framework/Algorithms/test/ConjoinWorkspacesTest.h b/Framework/Algorithms/test/ConjoinWorkspacesTest.h index 27d90dde12a1a75d31f0f48672e319be6f7d16fd..2485feebb729076714020c5f41df507c15974e38 100644 --- a/Framework/Algorithms/test/ConjoinWorkspacesTest.h +++ b/Framework/Algorithms/test/ConjoinWorkspacesTest.h @@ -37,7 +37,7 @@ public: : ws1Name("ConjoinWorkspacesTest_grp1"), ws2Name("ConjoinWorkspacesTest_grp2") {} - MatrixWorkspace_sptr getWSFromADS(std::string wsName) { + MatrixWorkspace_sptr getWSFromADS(const std::string &wsName) { auto out = boost::dynamic_pointer_cast<MatrixWorkspace>( AnalysisDataService::Instance().retrieve(wsName)); TS_ASSERT(out); diff --git a/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h b/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h index 3fad5cfc7c86596740a815439162c61369d4e984..56ae17def050ad508e455c8b1b11db6116f4f23d 100644 --- a/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h +++ b/Framework/Algorithms/test/ConvertAxesToRealSpaceTest.h @@ -55,10 +55,10 @@ public: do_algorithm_run(baseWSName, "phi", "signed2theta", 100, 200); } - MatrixWorkspace_sptr do_algorithm_run(std::string baseWSName, - std::string verticalAxis, - std::string horizontalAxis, int nHBins, - int nVBins) { + MatrixWorkspace_sptr do_algorithm_run(const std::string &baseWSName, + const std::string &verticalAxis, + const std::string &horizontalAxis, + int nHBins, int nVBins) { std::string inWSName(baseWSName + "_InputWS"); std::string outWSName(baseWSName + "_OutputWS"); diff --git a/Framework/Algorithms/test/ConvertAxisByFormulaTest.h b/Framework/Algorithms/test/ConvertAxisByFormulaTest.h index df3e41b59caffe07ff3707835435d78877116be6..6b55ecffeb14beef33741b690ca9bb8ef7543442 100644 --- a/Framework/Algorithms/test/ConvertAxisByFormulaTest.h +++ b/Framework/Algorithms/test/ConvertAxisByFormulaTest.h @@ -197,8 +197,9 @@ public: cleanupWorkspaces(std::vector<std::string>{inputWs}); } - bool runConvertAxisByFormula(std::string testName, std::string formula, - std::string axis, std::string &inputWs, + bool runConvertAxisByFormula(const std::string &testName, + const std::string &formula, + const std::string &axis, std::string &inputWs, std::string &resultWs) { Mantid::Algorithms::ConvertAxisByFormula alg; alg.initialize(); diff --git a/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h b/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h index 595e8c4b8f5d926a29955aaab0503fb764ce0bcc..78f9b1605ab800b91551c52857cc2d310665b88d 100644 --- a/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h +++ b/Framework/Algorithms/test/ConvertSpectrumAxis2Test.h @@ -23,8 +23,8 @@ using namespace Mantid::HistogramData::detail; class ConvertSpectrumAxis2Test : public CxxTest::TestSuite { private: - void do_algorithm_run(std::string target, std::string inputWS, - std::string outputWS, bool startYNegative = true, + void do_algorithm_run(const std::string &target, const std::string &inputWS, + const std::string &outputWS, bool startYNegative = true, bool isHistogram = true) { auto testWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument( 3, 1, false, startYNegative, isHistogram); @@ -45,7 +45,7 @@ private: } void check_output_values_for_signed_theta_conversion( - std::string outputWSSignedTheta) { + const std::string &outputWSSignedTheta) { MatrixWorkspace_const_sptr outputSignedTheta; TS_ASSERT_THROWS_NOTHING( outputSignedTheta = @@ -69,8 +69,9 @@ private: TS_ASSERT_DELTA((*thetaAxis)(2), 1.1458, 0.0001); } - void check_output_values_for_theta_conversion(std::string inputWSTheta, - std::string outputWSTheta) { + void + check_output_values_for_theta_conversion(const std::string &inputWSTheta, + const std::string &outputWSTheta) { MatrixWorkspace_const_sptr input, output; TS_ASSERT_THROWS_NOTHING( input = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -101,8 +102,8 @@ private: const Mantid::Kernel::Exception::IndexError &); } - void clean_up_workspaces(const std::string inputWS, - const std::string outputWS) { + void clean_up_workspaces(const std::string &inputWS, + const std::string &outputWS) { AnalysisDataService::Instance().remove(inputWS); AnalysisDataService::Instance().remove(outputWS); } diff --git a/Framework/Algorithms/test/ConvertSpectrumAxisTest.h b/Framework/Algorithms/test/ConvertSpectrumAxisTest.h index 46c3ebe3539433e909e34d82020fc160d8f0f676..fcab91851b1cd6322fa37ee7400e873442b0c2f6 100644 --- a/Framework/Algorithms/test/ConvertSpectrumAxisTest.h +++ b/Framework/Algorithms/test/ConvertSpectrumAxisTest.h @@ -19,8 +19,8 @@ using namespace Mantid::HistogramData::detail; class ConvertSpectrumAxisTest : public CxxTest::TestSuite { private: - void do_algorithm_run(std::string target, std::string inputWS, - std::string outputWS) { + void do_algorithm_run(const std::string &target, const std::string &inputWS, + const std::string &outputWS) { Mantid::Algorithms::ConvertSpectrumAxis conv; conv.initialize(); diff --git a/Framework/Algorithms/test/ConvertToConstantL2Test.h b/Framework/Algorithms/test/ConvertToConstantL2Test.h index e224874b82f18d43a5cac7c59cc2346da938eacd..4937686131866414685542e4d665e7585869d3f6 100644 --- a/Framework/Algorithms/test/ConvertToConstantL2Test.h +++ b/Framework/Algorithms/test/ConvertToConstantL2Test.h @@ -58,7 +58,7 @@ public: do_test_move(inputWS); } - void do_test_move(MatrixWorkspace_sptr inputWS) { + void do_test_move(const MatrixWorkspace_sptr &inputWS) { // BEFORE - check the L2 values differ const auto &spectrumInfoInput = inputWS->spectrumInfo(); for (size_t i = 0; i < inputWS->getNumberHistograms(); i++) { @@ -169,7 +169,7 @@ private: return inputWS; } - void addSampleLogs(MatrixWorkspace_sptr inputWS) { + void addSampleLogs(const MatrixWorkspace_sptr &inputWS) { inputWS->mutableRun().addProperty( "wavelength", boost::lexical_cast<std::string>(m_wavelength)); diff --git a/Framework/Algorithms/test/ConvertToHistogramTest.h b/Framework/Algorithms/test/ConvertToHistogramTest.h index d6696e74329a7ec92fb1c4cdfd3ec74cd76b4820..a693111185bbc58238bd5aa1e6513a66e560eb30 100644 --- a/Framework/Algorithms/test/ConvertToHistogramTest.h +++ b/Framework/Algorithms/test/ConvertToHistogramTest.h @@ -110,7 +110,7 @@ public: } private: - MatrixWorkspace_sptr runAlgorithm(Workspace2D_sptr inputWS) { + MatrixWorkspace_sptr runAlgorithm(const Workspace2D_sptr &inputWS) { IAlgorithm_sptr alg(new ConvertToHistogram()); alg->initialize(); alg->setRethrows(true); diff --git a/Framework/Algorithms/test/ConvertToPointDataTest.h b/Framework/Algorithms/test/ConvertToPointDataTest.h index 6fe2a97daca71de1b9839624ebf1ed2996ca8726..10b4868b4d2bb28179ec4cdba88aee189d2e83f2 100644 --- a/Framework/Algorithms/test/ConvertToPointDataTest.h +++ b/Framework/Algorithms/test/ConvertToPointDataTest.h @@ -171,7 +171,7 @@ public: } private: - MatrixWorkspace_sptr runAlgorithm(Workspace2D_sptr inputWS) { + MatrixWorkspace_sptr runAlgorithm(const Workspace2D_sptr &inputWS) { IAlgorithm_sptr alg(new ConvertToPointData()); alg->initialize(); alg->setRethrows(true); diff --git a/Framework/Algorithms/test/ConvertUnitsTest.h b/Framework/Algorithms/test/ConvertUnitsTest.h index c8fbf020f81aa98f95131de76be56b91f662f133..ca345e3cb59181f7c47f22c8156c30b648183ecc 100644 --- a/Framework/Algorithms/test/ConvertUnitsTest.h +++ b/Framework/Algorithms/test/ConvertUnitsTest.h @@ -713,7 +713,7 @@ public: * sorting flips the direction */ void do_testExecEvent_RemainsSorted(EventSortType sortType, - std::string targetUnit) { + const std::string &targetUnit) { EventWorkspace_sptr ws = WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(1, 10, false); diff --git a/Framework/Algorithms/test/CopyDataRangeTest.h b/Framework/Algorithms/test/CopyDataRangeTest.h index b0dbf373b55819704e0977a934c3742cfbc5109d..da41285003b3912b140abe268fcc32dea7a4c98b 100644 --- a/Framework/Algorithms/test/CopyDataRangeTest.h +++ b/Framework/Algorithms/test/CopyDataRangeTest.h @@ -37,8 +37,8 @@ MatrixWorkspace_sptr getADSMatrixWorkspace(std::string const &workspaceName) { workspaceName); } -IAlgorithm_sptr setUpAlgorithm(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr destWorkspace, +IAlgorithm_sptr setUpAlgorithm(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &destWorkspace, int const &specMin, int const &specMax, double const &xMin, double const &xMax, int const &yInsertionIndex, @@ -68,7 +68,7 @@ IAlgorithm_sptr setUpAlgorithm(std::string const &inputName, xMax, yInsertionIndex, xInsertionIndex, outputName); } -void populateSpectrum(MatrixWorkspace_sptr workspace, +void populateSpectrum(const MatrixWorkspace_sptr &workspace, std::size_t const &spectrum, std::vector<double> const &yData, std::vector<double> const &xData, @@ -78,7 +78,7 @@ void populateSpectrum(MatrixWorkspace_sptr workspace, workspace->mutableE(spectrum) = HistogramE(eData); } -void populateWorkspace(MatrixWorkspace_sptr workspace, +void populateWorkspace(const MatrixWorkspace_sptr &workspace, std::vector<double> const &yData, std::vector<double> const &xData, std::vector<double> const &eData) { @@ -94,7 +94,7 @@ constructHistogramData(Mantid::MantidVec::const_iterator fromIterator, return histogram; } -void populateOutputWorkspace(MatrixWorkspace_sptr workspace, +void populateOutputWorkspace(const MatrixWorkspace_sptr &workspace, std::vector<double> const &yData, std::vector<double> const &eData) { std::vector<double> const xData = {2.1, 2.2, 2.3, 2.4, 2.5, 2.6}; @@ -111,8 +111,8 @@ void populateOutputWorkspace(MatrixWorkspace_sptr workspace, } } -ITableWorkspace_sptr compareWorkspaces(MatrixWorkspace_sptr workspace1, - MatrixWorkspace_sptr workspace2, +ITableWorkspace_sptr compareWorkspaces(const MatrixWorkspace_sptr &workspace1, + const MatrixWorkspace_sptr &workspace2, double tolerance = 0.000001) { auto compareAlg = AlgorithmManager::Instance().create("CompareWorkspaces"); compareAlg->setProperty("Workspace1", workspace1); diff --git a/Framework/Algorithms/test/CopyLogsTest.h b/Framework/Algorithms/test/CopyLogsTest.h index 0f2292f8ea65a4550fa19fc91d9199faae4a561a..c67a5903e17e7c01ee5d680e085aeac88ca9dec7 100644 --- a/Framework/Algorithms/test/CopyLogsTest.h +++ b/Framework/Algorithms/test/CopyLogsTest.h @@ -136,7 +136,7 @@ public: } // Run the Copy Logs algorithm - void runAlg(MatrixWorkspace_sptr in, MatrixWorkspace_sptr out, + void runAlg(const MatrixWorkspace_sptr &in, const MatrixWorkspace_sptr &out, const std::string &mode) { CopyLogs alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) @@ -149,14 +149,14 @@ public: } // Add a string sample log to the workspace - void addSampleLog(MatrixWorkspace_sptr ws, const std::string &name, + void addSampleLog(const MatrixWorkspace_sptr &ws, const std::string &name, const std::string &value) { Run &run = ws->mutableRun(); run.addLogData(new PropertyWithValue<std::string>(name, value)); } // Add a double sample log to the workspace - void addSampleLog(MatrixWorkspace_sptr ws, const std::string &name, + void addSampleLog(const MatrixWorkspace_sptr &ws, const std::string &name, const double value) { Run &run = ws->mutableRun(); run.addLogData(new PropertyWithValue<double>(name, value)); diff --git a/Framework/Algorithms/test/CorrectTOFAxisTest.h b/Framework/Algorithms/test/CorrectTOFAxisTest.h index 23ccaedf78dd4c952284c8ca0065cc05b66b3322..6f376bda675306b70e982f85493ffcea34da9383 100644 --- a/Framework/Algorithms/test/CorrectTOFAxisTest.h +++ b/Framework/Algorithms/test/CorrectTOFAxisTest.h @@ -323,7 +323,7 @@ public: } private: - static void addSampleLogs(MatrixWorkspace_sptr ws, const double TOF) { + static void addSampleLogs(const MatrixWorkspace_sptr &ws, const double TOF) { const double length = flightLengthIN4(ws); const double Ei = incidentEnergy(TOF, length); ws->mutableRun().addProperty("EI", Ei); @@ -331,8 +331,8 @@ private: ws->mutableRun().addProperty("wavelength", lambda); } - static void assertTOFShift(MatrixWorkspace_sptr shiftedWs, - MatrixWorkspace_sptr ws, const double ei, + static void assertTOFShift(const MatrixWorkspace_sptr &shiftedWs, + const MatrixWorkspace_sptr &ws, const double ei, const double wavelength, const double shift) { TS_ASSERT(shiftedWs); TS_ASSERT_EQUALS(shiftedWs->run().getPropertyAsSingleValue("EI"), ei); @@ -412,7 +412,7 @@ private: } } - static double flightLengthIN4(MatrixWorkspace_const_sptr ws) { + static double flightLengthIN4(const MatrixWorkspace_const_sptr &ws) { const double l1 = ws->spectrumInfo().l1(); const double l2 = ws->spectrumInfo().l2(1); return l1 + l2; diff --git a/Framework/Algorithms/test/CorrectToFileTest.h b/Framework/Algorithms/test/CorrectToFileTest.h index 6d052370c9b4029d540de06090e9fa4f4f4e2de4..532a0c8fdeb8f7948ed9db9e65e1a4899d01174e 100644 --- a/Framework/Algorithms/test/CorrectToFileTest.h +++ b/Framework/Algorithms/test/CorrectToFileTest.h @@ -142,7 +142,7 @@ public: AnalysisDataService::Instance().remove(data->getName()); } - MatrixWorkspace_sptr executeAlgorithm(MatrixWorkspace_sptr testInput, + MatrixWorkspace_sptr executeAlgorithm(const MatrixWorkspace_sptr &testInput, const std::string &unit, const std::string &operation, bool newWksp = true) { diff --git a/Framework/Algorithms/test/CreateEPPTest.h b/Framework/Algorithms/test/CreateEPPTest.h index 7938d581ad0cc1b15571b2a6c43796b0d217ceb8..2ed9d6e0c6da0fd7052f1a377b71532b324d381f 100644 --- a/Framework/Algorithms/test/CreateEPPTest.h +++ b/Framework/Algorithms/test/CreateEPPTest.h @@ -177,7 +177,7 @@ private: return false; } for (const auto &columnName : columnNames) { - if (std::find(names.cbegin(), names.cend(), columnName) == names.end()) { + if (std::find(names.cbegin(), names.cend(), columnName) == names.cend()) { return false; } } diff --git a/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h b/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h index 0dc96dc50c0922f2845b12e4aa7b1829dea98d73..79cd24af8cb0243ba5620f5d8da59a1ce06b1c4d 100644 --- a/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateGroupingWorkspaceTest.h @@ -25,7 +25,7 @@ public: TS_ASSERT(alg.isInitialized()) } - void doTest(std::string outWSName) { + void doTest(const std::string &outWSName) { // Retrieve the workspace from data service. GroupingWorkspace_sptr ws; TS_ASSERT_THROWS_NOTHING( diff --git a/Framework/Algorithms/test/CreateLogPropertyTableTest.h b/Framework/Algorithms/test/CreateLogPropertyTableTest.h index 269b7bea7fd313442ded0a408620dfb70bf2d1c8..5f3639ce2f1e41e8fc02c09235e21865c7f3633c 100644 --- a/Framework/Algorithms/test/CreateLogPropertyTableTest.h +++ b/Framework/Algorithms/test/CreateLogPropertyTableTest.h @@ -110,7 +110,7 @@ public: private: void createSampleWorkspace( - std::string wsName = "__CreateLogPropertyTable__TestWorkspace", + const std::string &wsName = "__CreateLogPropertyTable__TestWorkspace", int runNumber = 12345, int64_t runStart = 3000000000) { using namespace WorkspaceCreationHelper; diff --git a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h index 73fcede99c031b32a7a12ab8bebf97eee20c5841..3e0e5f37ba44b75122a2e3fe6972f9a8faafd78a 100644 --- a/Framework/Algorithms/test/CreateSampleWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateSampleWorkspaceTest.h @@ -46,9 +46,10 @@ public: } MatrixWorkspace_sptr createSampleWorkspace( - std::string outWSName, std::string wsType = "", std::string function = "", - std::string userFunction = "", int numBanks = 2, int bankPixelWidth = 10, - int numEvents = 1000, bool isRandom = false, std::string xUnit = "TOF", + const std::string &outWSName, const std::string &wsType = "", + const std::string &function = "", const std::string &userFunction = "", + int numBanks = 2, int bankPixelWidth = 10, int numEvents = 1000, + bool isRandom = false, const std::string &xUnit = "TOF", double xMin = 0.0, double xMax = 20000.0, double binWidth = 200.0, int numScanPoints = 1) { diff --git a/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h b/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h index bde02a3160fca645785343c636d6bd255a0778b5..cda64d11d6f629869c034d9c72c01daea3ed837c 100644 --- a/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h +++ b/Framework/Algorithms/test/CreateTransmissionWorkspace2Test.h @@ -617,7 +617,7 @@ private: } } - void check_lambda_workspace(MatrixWorkspace_sptr ws) { + void check_lambda_workspace(const MatrixWorkspace_sptr &ws) { TS_ASSERT(ws); if (!ws) return; diff --git a/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h b/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h index e5f4c4b2f2f4d5a943197fb23b43e3b5df04a162..aa502c2dd8662e258191ce336b324b4b0431ade5 100644 --- a/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h +++ b/Framework/Algorithms/test/CreateUserDefinedBackgroundTest.h @@ -330,8 +330,8 @@ private: } /// Compare workspaces - bool workspacesEqual(const MatrixWorkspace_sptr lhs, - const MatrixWorkspace_sptr rhs, double tolerance, + bool workspacesEqual(const MatrixWorkspace_sptr &lhs, + const MatrixWorkspace_sptr &rhs, double tolerance, bool relativeError = false) { auto alg = Mantid::API::AlgorithmFactory::Instance().create( "CompareWorkspaces", 1); diff --git a/Framework/Algorithms/test/CropToComponentTest.h b/Framework/Algorithms/test/CropToComponentTest.h index 731380ea725ef564bb736526fe0e0a44cbf01045..1a6ae411b1fc2d86ae8ba2e44cf96141d234ff0e 100644 --- a/Framework/Algorithms/test/CropToComponentTest.h +++ b/Framework/Algorithms/test/CropToComponentTest.h @@ -242,7 +242,7 @@ private: numberOfBanks, numbersOfPixelPerBank, 2); } - void doAsssert(Mantid::API::MatrixWorkspace_sptr workspace, + void doAsssert(const Mantid::API::MatrixWorkspace_sptr &workspace, std::vector<Mantid::detid_t> &expectedIDs, size_t expectedNumberOfHistograms) { // Assert diff --git a/Framework/Algorithms/test/CropWorkspaceTest.h b/Framework/Algorithms/test/CropWorkspaceTest.h index 3fa04b6059029bbfa72a96f7ccd70d97fa1f0e1c..f5ab1f14d02305118681d59f17f93d4507e97503 100644 --- a/Framework/Algorithms/test/CropWorkspaceTest.h +++ b/Framework/Algorithms/test/CropWorkspaceTest.h @@ -103,7 +103,7 @@ public: TS_ASSERT(!crop.isExecuted()); } - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace(36, 50, 50, 0.0, 2., 2); diff --git a/Framework/Algorithms/test/CrossCorrelateTest.h b/Framework/Algorithms/test/CrossCorrelateTest.h index 4904a2f1f60319aa6d7f590d7d635b6c40eb91c3..8b60401adffd881de42f2f09cbe373a713cef12e 100644 --- a/Framework/Algorithms/test/CrossCorrelateTest.h +++ b/Framework/Algorithms/test/CrossCorrelateTest.h @@ -161,7 +161,7 @@ private: // Run the algorithm and do some basic checks. Returns the output workspace. MatrixWorkspace_const_sptr - runAlgorithm(CrossCorrelate &alg, const MatrixWorkspace_const_sptr inWS) { + runAlgorithm(CrossCorrelate &alg, const MatrixWorkspace_const_sptr &inWS) { // run the algorithm TS_ASSERT_THROWS_NOTHING(alg.execute()); TS_ASSERT(alg.isExecuted()); diff --git a/Framework/Algorithms/test/CylinderAbsorptionTest.h b/Framework/Algorithms/test/CylinderAbsorptionTest.h index 0950fb2082923018c5a55e466e429fb2118b6d83..ec2b9109b2c57695a387a7f0c534b0054f3b596d 100644 --- a/Framework/Algorithms/test/CylinderAbsorptionTest.h +++ b/Framework/Algorithms/test/CylinderAbsorptionTest.h @@ -305,9 +305,9 @@ private: void configureAbsCommon(Mantid::Algorithms::CylinderAbsorption &alg, MatrixWorkspace_sptr &inputWS, const std::string &outputWSname, - std::string numberOfSlices = "2", - std::string numberOfAnnuli = "2", - std::string cylinderAxis = "0,1,0") { + const std::string &numberOfSlices = "2", + const std::string &numberOfAnnuli = "2", + const std::string &cylinderAxis = "0,1,0") { if (!alg.isInitialized()) alg.initialize(); diff --git a/Framework/Algorithms/test/DeleteWorkspacesTest.h b/Framework/Algorithms/test/DeleteWorkspacesTest.h index 70fc055b60afd4dc8962e9b449d5e9686cac1d12..99d0d42a5931169cb5a6e27fe9246e2713313696 100644 --- a/Framework/Algorithms/test/DeleteWorkspacesTest.h +++ b/Framework/Algorithms/test/DeleteWorkspacesTest.h @@ -118,7 +118,7 @@ public: TS_ASSERT_EQUALS(dataStore.size(), storeSizeAtStart); } - void createAndStoreWorkspace(std::string name, int ylength = 10) { + void createAndStoreWorkspace(const std::string &name, int ylength = 10) { using namespace Mantid::API; using namespace Mantid::DataObjects; diff --git a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h index 4c851cdcf73b865dc4e5040cfb8d6d1820f3b7a5..9bf3cae230d0ba3431ad16f87655a3bb3e5d2150 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h @@ -41,7 +41,6 @@ public: WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(2, 1); dummyWS->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("DeltaE"); - const std::string inputWS = "testInput"; Mantid::Algorithms::DetectorEfficiencyCor corrector; TS_ASSERT_THROWS_NOTHING(corrector.initialize()); diff --git a/Framework/Algorithms/test/EditInstrumentGeometryTest.h b/Framework/Algorithms/test/EditInstrumentGeometryTest.h index 0ec972211148c925a94ff9e235af63b3532334c9..25b3d79ee97257da2ed47da555a25ea43221442f 100644 --- a/Framework/Algorithms/test/EditInstrumentGeometryTest.h +++ b/Framework/Algorithms/test/EditInstrumentGeometryTest.h @@ -158,7 +158,7 @@ public: //---------------------------------------------------------------------------------------------- /** Check detector parameter */ - void checkDetectorParameters(API::MatrixWorkspace_sptr workspace, + void checkDetectorParameters(const API::MatrixWorkspace_sptr &workspace, size_t wsindex, double realr, double realtth, double realphi) { @@ -175,8 +175,8 @@ public: //---------------------------------------------------------------------------------------------- /** Check detector parameter */ - void checkDetectorID(API::MatrixWorkspace_sptr workspace, size_t wsindex, - detid_t detid) { + void checkDetectorID(const API::MatrixWorkspace_sptr &workspace, + size_t wsindex, detid_t detid) { const auto &spectrumInfo = workspace->spectrumInfo(); TS_ASSERT_EQUALS(spectrumInfo.hasUniqueDetector(wsindex), true); diff --git a/Framework/Algorithms/test/ElasticWindowTest.h b/Framework/Algorithms/test/ElasticWindowTest.h index e00979fc42d7861c6d92134c08d8502ad1aaf27a..65328ac0a40b6cb25a8b9e1d9a197392bb4ce04b 100644 --- a/Framework/Algorithms/test/ElasticWindowTest.h +++ b/Framework/Algorithms/test/ElasticWindowTest.h @@ -201,7 +201,7 @@ private: * * @param ws Workspace to test */ - void verifyQworkspace(MatrixWorkspace_sptr ws) { + void verifyQworkspace(const MatrixWorkspace_sptr &ws) { std::string unitID = ws->getAxis(0)->unit()->unitID(); TS_ASSERT_EQUALS(unitID, "MomentumTransfer"); } @@ -211,7 +211,7 @@ private: * * @param ws Workspace to test */ - void verifyQ2workspace(MatrixWorkspace_sptr ws) { + void verifyQ2workspace(const MatrixWorkspace_sptr &ws) { std::string unitID = ws->getAxis(0)->unit()->unitID(); TS_ASSERT_EQUALS(unitID, "QSquared"); } diff --git a/Framework/Algorithms/test/ExponentialTest.h b/Framework/Algorithms/test/ExponentialTest.h index 9a682293ff8893c691aa691d11eccd5acc36e48b..28eec221b8561c92bbecb9741f7882f4e5cbb823 100644 --- a/Framework/Algorithms/test/ExponentialTest.h +++ b/Framework/Algorithms/test/ExponentialTest.h @@ -98,8 +98,8 @@ public: private: // loopOrientation 0=Horizontal, 1=Vertical - void checkData(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_out1) { for (size_t i = 0; i < work_out1->size(); i++) { double sig1 = @@ -123,7 +123,7 @@ private: } } // loopOrientation 0=Horizontal, 1=Vertical - void setError(MatrixWorkspace_sptr work_in1) { + void setError(const MatrixWorkspace_sptr &work_in1) { for (size_t i = 0; i < work_in1->size(); i++) { double sig1 = diff --git a/Framework/Algorithms/test/ExtractMaskTest.h b/Framework/Algorithms/test/ExtractMaskTest.h index 638cd418e87d327e90e73938d44d6c21bb532821..33bf6460081c9f3b2e38e6fa144954add847f140 100644 --- a/Framework/Algorithms/test/ExtractMaskTest.h +++ b/Framework/Algorithms/test/ExtractMaskTest.h @@ -163,8 +163,8 @@ private: return detectorList; } - void doTest(MatrixWorkspace_const_sptr inputWS, - MaskWorkspace_const_sptr outputWS) { + void doTest(const MatrixWorkspace_const_sptr &inputWS, + const MaskWorkspace_const_sptr &outputWS) { TS_ASSERT_EQUALS(outputWS->blocksize(), 1); size_t nOutputHists(outputWS->getNumberHistograms()); TS_ASSERT_EQUALS(nOutputHists, inputWS->getNumberHistograms()); diff --git a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h index 70c11883dcc5d1bd529baf941cb5a76839945b85..467ff4a4f5952ec7afc7dfbd460ce60be7217241 100644 --- a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h +++ b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h @@ -88,7 +88,7 @@ public: } private: - MatrixWorkspace_sptr runAlgorithm(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr runAlgorithm(const MatrixWorkspace_sptr &inputWS, const int index) { ExtractSingleSpectrum extractor; extractor.initialize(); @@ -106,8 +106,8 @@ private: return extractor.getProperty("OutputWorkspace"); } - void do_Spectrum_Tests(MatrixWorkspace_sptr outputWS, const specnum_t specID, - const detid_t detID) { + void do_Spectrum_Tests(const MatrixWorkspace_sptr &outputWS, + const specnum_t specID, const detid_t detID) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1); TS_ASSERT_THROWS_NOTHING(outputWS->getSpectrum(0)); const auto &spectrum = outputWS->getSpectrum(0); diff --git a/Framework/Algorithms/test/ExtractSpectraTest.h b/Framework/Algorithms/test/ExtractSpectraTest.h index daf981ab6c9860e5505fc25857797e4a74e73775..25c661dcaea660bd067781f9f0dfbbe62e892cb0 100644 --- a/Framework/Algorithms/test/ExtractSpectraTest.h +++ b/Framework/Algorithms/test/ExtractSpectraTest.h @@ -544,7 +544,7 @@ private: } MatrixWorkspace_sptr - createInputWithDetectors(std::string workspaceType) const { + createInputWithDetectors(const std::string &workspaceType) const { MatrixWorkspace_sptr ws; // Set the type of underlying workspace diff --git a/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h b/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h index 74486994886c34ee3446c2ea31ded0f57a72d1e1..769c8d1fef74d18c71e0a4720a9e3ff48f49ff0a 100644 --- a/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h +++ b/Framework/Algorithms/test/ExtractUnmaskedSpectraTest.h @@ -133,7 +133,7 @@ private: } Mantid::API::MatrixWorkspace_sptr - createMask(Mantid::API::MatrixWorkspace_sptr inputWS) { + createMask(const Mantid::API::MatrixWorkspace_sptr &inputWS) { auto maskWS = Mantid::DataObjects::MaskWorkspace_sptr( new Mantid::DataObjects::MaskWorkspace(inputWS)); size_t n = inputWS->getNumberHistograms(); @@ -146,8 +146,8 @@ private: } Mantid::API::MatrixWorkspace_sptr - runAlgorithm(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr maskedWS = + runAlgorithm(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &maskedWS = Mantid::API::MatrixWorkspace_sptr()) { ExtractUnmaskedSpectra alg; alg.setChild(true); diff --git a/Framework/Algorithms/test/FFTSmooth2Test.h b/Framework/Algorithms/test/FFTSmooth2Test.h index 8f3ad38eead8f38cc21bc03134472c3b3628b30a..ffae4ce2e45f2d8b32393fe359b2adb78fffa89e 100644 --- a/Framework/Algorithms/test/FFTSmooth2Test.h +++ b/Framework/Algorithms/test/FFTSmooth2Test.h @@ -169,8 +169,9 @@ public: } //------------------------------------------------------------------------------------------------- - void performTest(bool event, std::string filter, std::string params, - bool AllSpectra, int WorkspaceIndex, bool inPlace = false) { + void performTest(bool event, const std::string &filter, + const std::string ¶ms, bool AllSpectra, + int WorkspaceIndex, bool inPlace = false) { MatrixWorkspace_sptr ws1, out; int numPixels = 10; int numBins = 20; @@ -276,9 +277,11 @@ public: } if (!AllSpectra) { + bool allSpectraGtZero = false; + for (int WorkspaceIndex = 0; WorkspaceIndex < 10; WorkspaceIndex++) { - performTest((event > 0), filter, params, (AllSpectra > 0), + performTest((event > 0), filter, params, allSpectraGtZero, WorkspaceIndex, (inPlace > 0)); } } else { diff --git a/Framework/Algorithms/test/FFTTest.h b/Framework/Algorithms/test/FFTTest.h index a439134be667a11608f1b5a5012cf404b690708e..904716b6be11c5c0dbe7fe5c09f5e9b75ca2a8f6 100644 --- a/Framework/Algorithms/test/FFTTest.h +++ b/Framework/Algorithms/test/FFTTest.h @@ -717,7 +717,7 @@ public: } private: - MatrixWorkspace_sptr doRebin(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr doRebin(const MatrixWorkspace_sptr &inputWS, const std::string ¶ms) { auto rebin = FrameworkManager::Instance().createAlgorithm("Rebin"); rebin->initialize(); @@ -729,8 +729,8 @@ private: return rebin->getProperty("OutputWorkspace"); } - MatrixWorkspace_sptr doFFT(MatrixWorkspace_sptr inputWS, const bool complex, - const bool phaseShift) { + MatrixWorkspace_sptr doFFT(const MatrixWorkspace_sptr &inputWS, + const bool complex, const bool phaseShift) { auto fft = FrameworkManager::Instance().createAlgorithm("FFT"); fft->initialize(); fft->setChild(true); @@ -747,7 +747,7 @@ private: return fft->getProperty("OutputWorkspace"); } - void doPhaseTest(MatrixWorkspace_sptr inputWS, bool complex) { + void doPhaseTest(const MatrixWorkspace_sptr &inputWS, bool complex) { // Offset the input workspace const auto offsetWS = offsetWorkspace(inputWS); @@ -803,7 +803,7 @@ private: return ws; } - MatrixWorkspace_sptr offsetWorkspace(MatrixWorkspace_sptr workspace) { + MatrixWorkspace_sptr offsetWorkspace(const MatrixWorkspace_sptr &workspace) { auto scaleX = FrameworkManager::Instance().createAlgorithm("ScaleX"); scaleX->initialize(); scaleX->setChild(true); @@ -936,7 +936,7 @@ private: return create->getProperty("OutputWorkspace"); } - MatrixWorkspace_sptr doCrop(MatrixWorkspace_sptr inputWS, double lower, + MatrixWorkspace_sptr doCrop(const MatrixWorkspace_sptr &inputWS, double lower, double higher) { auto crop = FrameworkManager::Instance().createAlgorithm("CropWorkspace"); crop->initialize(); diff --git a/Framework/Algorithms/test/FilterByLogValueTest.h b/Framework/Algorithms/test/FilterByLogValueTest.h index 19b20c56e69f2652dfaa8cd9a968737a4de97dc8..25b241d1021ec87d7bdea75383c9eb30de7dbafd 100644 --- a/Framework/Algorithms/test/FilterByLogValueTest.h +++ b/Framework/Algorithms/test/FilterByLogValueTest.h @@ -174,7 +174,7 @@ public: * @param do_in_place * @param PulseFilter :: PulseFilter parameter */ - void do_test_fake(std::string log_name, double min, double max, + void do_test_fake(const std::string &log_name, double min, double max, int seconds_kept, bool add_proton_charge = true, bool do_in_place = false, bool PulseFilter = false) { EventWorkspace_sptr ew = createInputWS(add_proton_charge); diff --git a/Framework/Algorithms/test/FilterEventsTest.h b/Framework/Algorithms/test/FilterEventsTest.h index 62120ef732583da28d48689c166db0fad142f620..b657f88b3d53ff936be937a54499a7fd232a71d4 100644 --- a/Framework/Algorithms/test/FilterEventsTest.h +++ b/Framework/Algorithms/test/FilterEventsTest.h @@ -1753,7 +1753,8 @@ public: //---------------------------------------------------------------------------------------------- /** Create the time correction table */ - TableWorkspace_sptr createTimeCorrectionTable(MatrixWorkspace_sptr inpws) { + TableWorkspace_sptr + createTimeCorrectionTable(const MatrixWorkspace_sptr &inpws) { // 1. Generate an empty table auto corrtable = boost::make_shared<TableWorkspace>(); corrtable->addColumn("int", "DetectorID"); diff --git a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h index 31e925bc196f2003ad4eb837e77b7098413b16e6..b914e7e6c0ff804c0fd79d320df11ec938498118 100644 --- a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h +++ b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h @@ -58,7 +58,7 @@ public: // Set tube extrema to special values if (iy == 0 || iy == SANSInstrumentCreationHelper::nBins - 1) Y[0] = - iy % 2 ? std::nan("") : std::numeric_limits<double>::infinity(); + (iy % 2) ? std::nan("") : std::numeric_limits<double>::infinity(); E[0] = 1; } } diff --git a/Framework/Algorithms/test/FindEPPTest.h b/Framework/Algorithms/test/FindEPPTest.h index 3f9ef8197a23a46a67fa892fbdd385c2ae5fdae1..a84315c99f436a8c8650e61e64b3ee1b58265c3f 100644 --- a/Framework/Algorithms/test/FindEPPTest.h +++ b/Framework/Algorithms/test/FindEPPTest.h @@ -223,7 +223,7 @@ public: } private: - void _check_table(ITableWorkspace_sptr ws, size_t nSpectra) { + void _check_table(const ITableWorkspace_sptr &ws, size_t nSpectra) { TS_ASSERT_EQUALS(ws->rowCount(), nSpectra); TS_ASSERT_EQUALS(ws->columnCount(), 9); TS_ASSERT_EQUALS(ws->getColumnNames(), m_columnNames); diff --git a/Framework/Algorithms/test/FindPeaksTest.h b/Framework/Algorithms/test/FindPeaksTest.h index 104ea75cf06eb28e2dbee683837e64cbb4d78266..eef5f327f104d5963b1e018ecfaf27eaf46aca58 100644 --- a/Framework/Algorithms/test/FindPeaksTest.h +++ b/Framework/Algorithms/test/FindPeaksTest.h @@ -190,7 +190,7 @@ public: /** Parse a row in output parameter tableworkspace to a string/double * parameter name/value map */ - void getParameterMap(TableWorkspace_sptr tablews, size_t rowindex, + void getParameterMap(const TableWorkspace_sptr &tablews, size_t rowindex, map<string, double> ¶mmap) { parammap.clear(); diff --git a/Framework/Algorithms/test/FitPeakTest.h b/Framework/Algorithms/test/FitPeakTest.h index fda649e543a5e51936542ab6f4f092f6e42fd402..836e206fadd5cbd3fe826b594b598366076e08d3 100644 --- a/Framework/Algorithms/test/FitPeakTest.h +++ b/Framework/Algorithms/test/FitPeakTest.h @@ -358,8 +358,6 @@ public: /** Generate a workspace contains PG3_4866 5-th peak */ MatrixWorkspace_sptr gen_PG3DiamondData() { - vector<double> vecx, vecy, vece; - size_t NVectors = 1; size_t size = 53; MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( diff --git a/Framework/Algorithms/test/FitPeaksTest.h b/Framework/Algorithms/test/FitPeaksTest.h index 2af2633483f38bd7589b3070747a55ffb8976901..f4849daa7e74041dc0f17b229c559538138714aa 100644 --- a/Framework/Algorithms/test/FitPeaksTest.h +++ b/Framework/Algorithms/test/FitPeaksTest.h @@ -411,7 +411,6 @@ public: // std::string input_ws_name = loadVulcanHighAngleData(); // Generate peak and background parameters - std::vector<string> peakparnames{"Mixing"}; std::vector<double> peakparvalues{0.5}; // Initialize FitPeak diff --git a/Framework/Algorithms/test/FixGSASInstrumentFileTest.h b/Framework/Algorithms/test/FixGSASInstrumentFileTest.h index 7ff6c56f089602cdbe2cd1905fc074605885e54e..7d5a650d5d2f4e34eb5b4b195c538fba408f2685 100644 --- a/Framework/Algorithms/test/FixGSASInstrumentFileTest.h +++ b/Framework/Algorithms/test/FixGSASInstrumentFileTest.h @@ -67,7 +67,7 @@ public: file.remove(); } - void createFaultFile(std::string prmfilename) { + void createFaultFile(const std::string &prmfilename) { ofstream ofile; ofile.open(prmfilename.c_str(), ios::out); ofile << " " diff --git a/Framework/Algorithms/test/GenerateEventsFilterTest.h b/Framework/Algorithms/test/GenerateEventsFilterTest.h index bd5c7d8a22c74e9ad4c7342da233926ce52387da..8c6cdc750d876bed66921e027a01c3dd8e2e1e50 100644 --- a/Framework/Algorithms/test/GenerateEventsFilterTest.h +++ b/Framework/Algorithms/test/GenerateEventsFilterTest.h @@ -1145,7 +1145,7 @@ public: * SplittingInterval objects */ size_t convertMatrixSplitterToSplitters( - API::MatrixWorkspace_const_sptr matrixws, + const API::MatrixWorkspace_const_sptr &matrixws, std::vector<Kernel::SplittingInterval> &splitters) { splitters.clear(); size_t numsplitters = 0; diff --git a/Framework/Algorithms/test/GetAllEiTest.h b/Framework/Algorithms/test/GetAllEiTest.h index d431d7d9245ebb843d3f6556dd61b018751cd18c..108f38febb734e6a6d62a0c567d79f0f7c1b6506 100644 --- a/Framework/Algorithms/test/GetAllEiTest.h +++ b/Framework/Algorithms/test/GetAllEiTest.h @@ -503,7 +503,7 @@ public: TS_ASSERT_DELTA(zeros[2], 7.85, 1.e-3); } void test_binRanges() { - std::vector<size_t> bin_min, bin_max, zeros; + std::vector<size_t> bin_min, bin_max; // Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 double debin[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15}; std::vector<double> ebin(debin, debin + sizeof(debin) / sizeof(double)); diff --git a/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h b/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h index 6adbaedc2a78560469809db114c046e1902173e8..97c55f0ee4135394c0f9808dc7689e8c789d5dfc 100644 --- a/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h +++ b/Framework/Algorithms/test/GetDetOffsetsMultiPeaksTest.h @@ -430,7 +430,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate noisy data in a workspace */ - void generateNoisyData(MatrixWorkspace_sptr WS) { + void generateNoisyData(const MatrixWorkspace_sptr &WS) { auto &Y = WS->mutableY(0); Y.assign(Y.size(), static_cast<double>(rand() % 5)); diff --git a/Framework/Algorithms/test/GetEiMonDet3Test.h b/Framework/Algorithms/test/GetEiMonDet3Test.h index c5cf0ac1f5cb090ca8c5f0d351d15987ffb1b430..111ea70a6a4ae3f542210aca8e1260339f611469 100644 --- a/Framework/Algorithms/test/GetEiMonDet3Test.h +++ b/Framework/Algorithms/test/GetEiMonDet3Test.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAlgorithms/ExtractSpectra2.h" @@ -157,7 +159,7 @@ public: } private: - static void attachInstrument(MatrixWorkspace_sptr targetWs) { + static void attachInstrument(const MatrixWorkspace_sptr &targetWs) { // The reference frame used by createInstrumentForWorkspaceWithDistances // is left handed with y pointing up, x along beam. @@ -170,8 +172,8 @@ private: detectorRs.emplace_back(-MONITOR_DISTANCE, 0., 0.); // Add more detectors --- these should be treated as the real ones. detectorRs.emplace_back(0., 0., DETECTOR_DISTANCE); - createInstrumentForWorkspaceWithDistances(targetWs, sampleR, sourceR, - detectorRs); + createInstrumentForWorkspaceWithDistances(std::move(targetWs), sampleR, + sourceR, detectorRs); } static MatrixWorkspace_sptr @@ -215,7 +217,8 @@ private: } // Mininum setup for GetEiMonDet3. - static void setupSimple(MatrixWorkspace_sptr ws, GetEiMonDet3 &algorithm) { + static void setupSimple(const MatrixWorkspace_sptr &ws, + GetEiMonDet3 &algorithm) { algorithm.setRethrows(true); TS_ASSERT_THROWS_NOTHING(algorithm.initialize()) TS_ASSERT(algorithm.isInitialized()) diff --git a/Framework/Algorithms/test/He3TubeEfficiencyTest.h b/Framework/Algorithms/test/He3TubeEfficiencyTest.h index 8488bb39b1e99a50be2c7b2735044cf54427e3b3..6db24d8af3fc433346fc81a4095b1ec9cd903c1a 100644 --- a/Framework/Algorithms/test/He3TubeEfficiencyTest.h +++ b/Framework/Algorithms/test/He3TubeEfficiencyTest.h @@ -30,7 +30,7 @@ using Mantid::HistogramData::Counts; using Mantid::HistogramData::CountStandardDeviations; namespace He3TubeEffeciencyHelper { -void createWorkspace2DInADS(const std::string inputWS) { +void createWorkspace2DInADS(const std::string &inputWS) { const int nspecs(4); const int nbins(5); @@ -58,7 +58,7 @@ void createWorkspace2DInADS(const std::string inputWS) { loader.execute(); } -void createEventWorkspaceInADS(const std::string inputEvWS) { +void createEventWorkspaceInADS(const std::string &inputEvWS) { EventWorkspace_sptr event = WorkspaceCreationHelper::createEventWorkspace(4, 5, 5, 0, 0.9, 3, 0); event->getAxis(0)->unit() = UnitFactory::Instance().create("Wavelength"); diff --git a/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h b/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h index a3037f1d0cecc51eecb35969c0df925a0bfb4d08..d4fc9f315599719e67e44dbdb1c9c3f21eb6eb22 100644 --- a/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h +++ b/Framework/Algorithms/test/IndirectFitDataCreationHelperTest.h @@ -24,7 +24,7 @@ std::vector<std::string> getTextAxisLabels() { std::vector<double> getNumericAxisLabels() { return {2.2, 3.3, 4.4}; } void storeWorkspaceInADS(std::string const &workspaceName, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { SetUpADSWithWorkspace ads(workspaceName, workspace); } diff --git a/Framework/Algorithms/test/IntegrateByComponentTest.h b/Framework/Algorithms/test/IntegrateByComponentTest.h index 83f579d6e567645a282d253832e80631b6405c0b..efb8aa33fce4686639b6525cee86823dcecce109 100644 --- a/Framework/Algorithms/test/IntegrateByComponentTest.h +++ b/Framework/Algorithms/test/IntegrateByComponentTest.h @@ -240,7 +240,7 @@ public: } private: - void ABCtestWorkspace(std::string inputWSname, bool mask) { + void ABCtestWorkspace(const std::string &inputWSname, bool mask) { int nSpectra(12); Workspace2D_sptr ws2D = WorkspaceCreationHelper::create2DWorkspaceWhereYIsWorkspaceIndex( diff --git a/Framework/Algorithms/test/IntegrationTest.h b/Framework/Algorithms/test/IntegrationTest.h index 9fa007b15c79c6de1e00059657d1091bae155cad..e99316d0e09a15906a1f0558b9652a4745136661 100644 --- a/Framework/Algorithms/test/IntegrationTest.h +++ b/Framework/Algorithms/test/IntegrationTest.h @@ -166,7 +166,7 @@ public: assertRangeWithPartialBins(input); } - void doTestEvent(std::string inName, std::string outName, + void doTestEvent(const std::string &inName, const std::string &outName, int StartWorkspaceIndex, int EndWorkspaceIndex) { int numPixels = 100; int numBins = 50; @@ -229,8 +229,8 @@ public: doTestEvent("inWS", "inWS", 10, 29); } - void doTestRebinned(const std::string RangeLower, - const std::string RangeUpper, + void doTestRebinned(const std::string &RangeLower, + const std::string &RangeUpper, const int StartWorkspaceIndex, const int EndWorkspaceIndex, const bool IncludePartialBins, const int expectedNumHists, @@ -290,7 +290,7 @@ public: doTestRebinned("-1.5", "1.75", 0, 3, true, 4, truth); } - void makeRealBinBoundariesWorkspace(const std::string inWsName) { + void makeRealBinBoundariesWorkspace(const std::string &inWsName) { const unsigned int lenX = 11, lenY = 10, lenE = lenY; Workspace_sptr wsAsWs = @@ -326,9 +326,9 @@ public: AnalysisDataService::Instance().add(inWsName, ws); } - void doTestRealBinBoundaries(const std::string inWsName, - const std::string rangeLower, - const std::string rangeUpper, + void doTestRealBinBoundaries(const std::string &inWsName, + const std::string &rangeLower, + const std::string &rangeUpper, const double expectedVal, const bool checkRanges = false, const bool IncPartialBins = false) { @@ -707,7 +707,7 @@ public: } template <typename F> - void wsBoundsTest(std::string workspace, int startIndex, int endIndex, + void wsBoundsTest(const std::string &workspace, int startIndex, int endIndex, F boundsAssert) { MatrixWorkspace_sptr input; TS_ASSERT_THROWS_NOTHING( @@ -732,8 +732,9 @@ public: } void testStartWsIndexOutOfBounds() { - auto boundsAssert = [](MatrixWorkspace_sptr, MatrixWorkspace_sptr output, - int, int endIndex) { + auto boundsAssert = [](const MatrixWorkspace_sptr &, + const MatrixWorkspace_sptr &output, int, + int endIndex) { TS_ASSERT_EQUALS(output->getNumberHistograms(), endIndex + 1); }; @@ -741,8 +742,9 @@ public: } void testStartWSIndexGreaterThanEnd() { - auto boundsAssert = [](MatrixWorkspace_sptr input, - MatrixWorkspace_sptr output, int startIndex, int) { + auto boundsAssert = [](const MatrixWorkspace_sptr &input, + const MatrixWorkspace_sptr &output, int startIndex, + int) { TS_ASSERT_EQUALS(output->getNumberHistograms(), input->getNumberHistograms() - startIndex); }; @@ -751,8 +753,8 @@ public: } void testStartWSIndexEqualsEnd() { - auto boundsAssert = [](MatrixWorkspace_sptr, MatrixWorkspace_sptr output, - int, int) { + auto boundsAssert = [](const MatrixWorkspace_sptr &, + const MatrixWorkspace_sptr &output, int, int) { TS_ASSERT_EQUALS(output->getNumberHistograms(), 1); }; @@ -780,7 +782,7 @@ public: } private: - void assertRangeWithPartialBins(Workspace_sptr input) { + void assertRangeWithPartialBins(const Workspace_sptr &input) { Integration alg; alg.setRethrows(false); TS_ASSERT_THROWS_NOTHING(alg.initialize()); diff --git a/Framework/Algorithms/test/LineProfileTest.h b/Framework/Algorithms/test/LineProfileTest.h index 1ceace8fe27a54997b72cf366a13598b8f35d3ac..61fda4391b0f455b5a6a7c34919b96f61510610f 100644 --- a/Framework/Algorithms/test/LineProfileTest.h +++ b/Framework/Algorithms/test/LineProfileTest.h @@ -568,9 +568,9 @@ public: TS_ASSERT_EQUALS(axis->getMax(), edges.back()) const auto binHeight = axis->getMax() - axis->getMin(); TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1) - const auto &Xs = outputWS->x(0); + // cppcheck-suppress unreadVariable const std::vector<double> profilePoints{{1., 2., 3., 4.}}; - TS_ASSERT_EQUALS(Xs.rawData(), profilePoints) + TS_ASSERT_EQUALS(outputWS->x(0).rawData(), profilePoints) const auto &Ys = outputWS->y(0); const auto horizontalIntegral = (3. * 0.1 + 2. * 1. + 1. * 10.) / binHeight; for (const auto y : Ys) { @@ -584,9 +584,9 @@ public: } private: - MatrixWorkspace_sptr profileOverTwoSpectra(MatrixWorkspace_sptr inputWS, - const int start, const int end, - const std::string &mode) { + MatrixWorkspace_sptr + profileOverTwoSpectra(const MatrixWorkspace_sptr &inputWS, const int start, + const int end, const std::string &mode) { LineProfile alg; // Don't put output in ADS by default alg.setChild(true); diff --git a/Framework/Algorithms/test/MCInteractionVolumeTest.h b/Framework/Algorithms/test/MCInteractionVolumeTest.h index cb97ba7658a2c1f63234047ac78edecc8136d8a9..199fa0f9c2716b3dae098704a14c84b6a8569e32 100644 --- a/Framework/Algorithms/test/MCInteractionVolumeTest.h +++ b/Framework/Algorithms/test/MCInteractionVolumeTest.h @@ -358,7 +358,8 @@ private: Mantid::Kernel::Logger g_log{"MCInteractionVolumeTest"}; void TestGeneratedTracks(const V3D startPos, const V3D endPos, - const Track beforeScatter, const Track afterScatter, + const Track &beforeScatter, + const Track &afterScatter, const Mantid::Geometry::IObject &shape) { // check the generated tracks share the same start point (the scatter point) TS_ASSERT_EQUALS(beforeScatter.startPoint(), afterScatter.startPoint()); diff --git a/Framework/Algorithms/test/MagFormFactorCorrectionTest.h b/Framework/Algorithms/test/MagFormFactorCorrectionTest.h index 8f2cdb2d61f76124f2ce91633708e3c5b59f1871..2ec64fbbb6c507956aa771f2d5ee42746d238fc1 100644 --- a/Framework/Algorithms/test/MagFormFactorCorrectionTest.h +++ b/Framework/Algorithms/test/MagFormFactorCorrectionTest.h @@ -91,7 +91,7 @@ private: std::string formFactorWSname; // Creates a fake workspace - void createWorkspaceMag(bool isHistogram, std::string wsname) { + void createWorkspaceMag(bool isHistogram, const std::string &wsname) { const int nspecs(10); const int nbins(50); const double invfourPiSqr = 1. / (16. * M_PI * M_PI); @@ -116,8 +116,9 @@ private: } // Checks that all the workspaces are consistent (in = out*ff) - double checkWorkspaces(MatrixWorkspace_sptr in, MatrixWorkspace_sptr out, - MatrixWorkspace_sptr ff) { + double checkWorkspaces(const MatrixWorkspace_sptr &in, + const MatrixWorkspace_sptr &out, + const MatrixWorkspace_sptr &ff) { const int64_t nbins = in->blocksize(); const int64_t nspecs = in->getNumberHistograms(); double df2 = 0., df; diff --git a/Framework/Algorithms/test/MergeLogsTest.h b/Framework/Algorithms/test/MergeLogsTest.h index 535868d98a41d1bc49bb761b4aacdda2e66da9d9..624b44238ef28a8358c067a6405b66ed5853a5f1 100644 --- a/Framework/Algorithms/test/MergeLogsTest.h +++ b/Framework/Algorithms/test/MergeLogsTest.h @@ -116,7 +116,7 @@ public: return log; } - void testLogValues(MatrixWorkspace_sptr ws, const std::string &name, + void testLogValues(const MatrixWorkspace_sptr &ws, const std::string &name, const int msize, double value) { TimeSeriesProperty<double> *log = ws->run().getTimeSeriesProperty<double>(name); @@ -131,7 +131,7 @@ public: } // msize1 < msize2! - void testLogValues(MatrixWorkspace_sptr ws, const std::string &name, + void testLogValues(const MatrixWorkspace_sptr &ws, const std::string &name, const int msize1, const int msize2, const double v1, const double v2) { TimeSeriesProperty<double> *log = diff --git a/Framework/Algorithms/test/MergeRunsTest.h b/Framework/Algorithms/test/MergeRunsTest.h index a5e92fe227bdf676e322430c3e4f8ff5f308b814..8bead92a85e57b3350a4ca4aed4cb394c45ab109 100644 --- a/Framework/Algorithms/test/MergeRunsTest.h +++ b/Framework/Algorithms/test/MergeRunsTest.h @@ -40,8 +40,8 @@ private: MergeRuns merge; /// Helper method to add an 'nperiods' log value to each workspace in a group. - void add_periods_logs(WorkspaceGroup_sptr ws, bool calculateNPeriods = true, - int nperiods = -1) { + void add_periods_logs(const WorkspaceGroup_sptr &ws, + bool calculateNPeriods = true, int nperiods = -1) { if (calculateNPeriods) { nperiods = static_cast<int>(ws->size()); } @@ -268,7 +268,7 @@ private: return c; } - void do_test_treat_as_non_period_groups(WorkspaceGroup_sptr input) { + void do_test_treat_as_non_period_groups(const WorkspaceGroup_sptr &input) { MatrixWorkspace_sptr sampleInputWorkspace = boost::dynamic_pointer_cast<MatrixWorkspace>(input->getItem(0)); const double uniformSignal = sampleInputWorkspace->y(0)[0]; @@ -320,7 +320,7 @@ public: "in6", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 3, 2., 2.)); } - void checkOutput(std::string wsname) { + void checkOutput(const std::string &wsname) { EventWorkspace_sptr output; TimeSeriesProperty<double> *log; int log1, log2, logTot; @@ -373,6 +373,7 @@ public: va_start(vl, num); for (int i = 0; i < num; i++) retVal.emplace_back(va_arg(vl, int)); + va_end(vl); return retVal; } @@ -874,7 +875,8 @@ public: AnalysisDataService::Instance().remove("outer"); } - void do_test_validation_throws(WorkspaceGroup_sptr a, WorkspaceGroup_sptr b) { + void do_test_validation_throws(const WorkspaceGroup_sptr &a, + const WorkspaceGroup_sptr &b) { MergeRuns alg; alg.setRethrows(true); alg.initialize(); @@ -911,7 +913,7 @@ public: do_test_validation_throws(aCorrupted, a); } - void do_test_with_multiperiod_data(WorkspaceGroup_sptr input) { + void do_test_with_multiperiod_data(const WorkspaceGroup_sptr &input) { // Extract some internal information from the nested workspaces in order to // run test asserts later. const size_t expectedNumHistograms = @@ -1356,8 +1358,8 @@ public: 3); } - void do_test_merge_two_workspaces_then_third(std::string mergeType, - std::string result) { + void do_test_merge_two_workspaces_then_third(const std::string &mergeType, + const std::string &result) { auto ws = create_group_workspace_with_sample_logs<double>( mergeType, "prop1", 1.0, 2.0, 3.0, 4.0); @@ -1391,8 +1393,8 @@ public: "1, 2, 5"); } - void do_test_merging_two_workspaces_both_already_merged(std::string mergeType, - std::string result) { + void do_test_merging_two_workspaces_both_already_merged( + const std::string &mergeType, const std::string &result) { auto ws = create_group_workspace_with_sample_logs<double>( mergeType, "prop1", 1.0, 2.0, 3.0, 4.0); diff --git a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h index 011ea38cf3b000aee198a45936230aaf07498a09..5c07a2aba506181fe25d027cb156f6386d5f147b 100644 --- a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h @@ -26,7 +26,7 @@ using Mantid::HistogramData::LinearGenerator; using Mantid::Types::Event::TofEvent; namespace { -void addToInstrument(MatrixWorkspace_sptr testWS, +void addToInstrument(const MatrixWorkspace_sptr &testWS, const bool &add_deltaE_mode = false, const bool &add_t0_formula = false) { const double evalue(2.082); // energy corresponding to the first order Bragg diff --git a/Framework/Algorithms/test/MonteCarloAbsorptionTest.h b/Framework/Algorithms/test/MonteCarloAbsorptionTest.h index e9dde8bff9bacee37b7b2f7fd5e4364d9c128d2c..bff3d16341a5d6ef07ad65287aefc93667f8fa21 100644 --- a/Framework/Algorithms/test/MonteCarloAbsorptionTest.h +++ b/Framework/Algorithms/test/MonteCarloAbsorptionTest.h @@ -40,7 +40,7 @@ struct TestWorkspaceDescriptor { double beamHeight; }; -void addSample(Mantid::API::MatrixWorkspace_sptr ws, +void addSample(const Mantid::API::MatrixWorkspace_sptr &ws, const Environment environment, double beamWidth = 0., double beamHeight = 0.) { using namespace Mantid::API; @@ -87,7 +87,6 @@ void addSample(Mantid::API::MatrixWorkspace_sptr ws, ws->mutableSample().setShape(sampleShape); if (environment == Environment::SamplePlusContainer) { - const std::string id("container"); constexpr double containerWallThickness{0.002}; constexpr double containerInnerRadius{1.2 * sampleHeight}; constexpr double containerOuterRadius{containerInnerRadius + @@ -403,7 +402,7 @@ private: } Mantid::API::MatrixWorkspace_const_sptr - getOutputWorkspace(Mantid::API::IAlgorithm_sptr alg) { + getOutputWorkspace(const Mantid::API::IAlgorithm_sptr &alg) { using Mantid::API::MatrixWorkspace_sptr; MatrixWorkspace_sptr output = alg->getProperty("OutputWorkspace"); TS_ASSERT(output); @@ -412,8 +411,9 @@ private: return output; } - void verifyDimensions(TestWorkspaceDescriptor wsProps, - Mantid::API::MatrixWorkspace_const_sptr outputWS) { + void + verifyDimensions(TestWorkspaceDescriptor wsProps, + const Mantid::API::MatrixWorkspace_const_sptr &outputWS) { TS_ASSERT_EQUALS(wsProps.nspectra, outputWS->getNumberHistograms()); TS_ASSERT_EQUALS(wsProps.nbins, outputWS->blocksize()); } diff --git a/Framework/Algorithms/test/MultiplyDivideTest.in.h b/Framework/Algorithms/test/MultiplyDivideTest.in.h index 44f71c607c1a82d1fc1b924b24c69fd1675a1773..2a2c6270760499f02ed155b95fe6fd9c004edd1e 100644 --- a/Framework/Algorithms/test/MultiplyDivideTest.in.h +++ b/Framework/Algorithms/test/MultiplyDivideTest.in.h @@ -9,6 +9,7 @@ #include <cxxtest/TestSuite.h> #include <cmath> +#include <stdexcept> #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidAlgorithms/Divide.h" @@ -602,6 +603,10 @@ public: mess << "; RHS: grouping=" << rhs_grouping << ", 2D=" << rhs2D; message = mess.str(); + if (lhs_grouping == 0 || rhs_grouping == 0){ + throw std::runtime_error("Attempted div by zero in test"); + } + int numpix = 12; std::vector< std::vector<int> > lhs(numpix/lhs_grouping), rhs(numpix/rhs_grouping); for (int i=0; i<numpix; i++) diff --git a/Framework/Algorithms/test/NormaliseByCurrentTest.h b/Framework/Algorithms/test/NormaliseByCurrentTest.h index 766db44fb1bfee8f2ec4efdc248cf14992fa73a9..6b3ca7a62904d41fa37a06cb7efc23367d82791f 100644 --- a/Framework/Algorithms/test/NormaliseByCurrentTest.h +++ b/Framework/Algorithms/test/NormaliseByCurrentTest.h @@ -9,6 +9,8 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" #include "MantidAPI/WorkspaceGroup.h" @@ -25,9 +27,10 @@ using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; namespace { -MatrixWorkspace_const_sptr doTest(MatrixWorkspace_sptr inWS, - std::string wsNameOut, double expectedY, - double expectedE, bool calcPcharge = false, +MatrixWorkspace_const_sptr doTest(const MatrixWorkspace_sptr &inWS, + const std::string &wsNameOut, + double expectedY, double expectedE, + bool calcPcharge = false, bool performance = false) { NormaliseByCurrent norm1; if (!norm1.isInitialized()) @@ -87,7 +90,8 @@ MatrixWorkspace_const_sptr doTest(MatrixWorkspace_sptr inWS, return output; } -MatrixWorkspace_const_sptr doTest(std::string wsNameIn, std::string wsNameOut, +MatrixWorkspace_const_sptr doTest(const std::string &wsNameIn, + const std::string &wsNameOut, const double pCharge, double expectedY, double expectedE, bool performance = false) { MatrixWorkspace_sptr inWS = @@ -99,13 +103,14 @@ MatrixWorkspace_const_sptr doTest(std::string wsNameIn, std::string wsNameOut, Mantid::Kernel::UnitFactory::Instance().create("TOF"); inWS->setYUnit("Counts"); - return doTest(inWS, wsNameOut, expectedY, expectedE, true, performance); + return doTest(inWS, std::move(wsNameOut), expectedY, expectedE, true, + performance); } /// Helper method to add necessary log values to simulate multi-period data. /// The algorithm uses these logs to determien how to normalise by the /// current. -void addMultiPeriodLogsTo(MatrixWorkspace_sptr ws, int period, +void addMultiPeriodLogsTo(const MatrixWorkspace_sptr &ws, int period, const std::string &protonCharges) { ArrayProperty<double> *chargeProp = new ArrayProperty<double>("proton_charge_by_period", protonCharges); @@ -119,7 +124,8 @@ void addMultiPeriodLogsTo(MatrixWorkspace_sptr ws, int period, ws->mutableRun().addLogData(currentPeriodProp); } -void addPChargeLogTo(MatrixWorkspace_sptr ws, const double pChargeAccum) { +void addPChargeLogTo(const MatrixWorkspace_sptr &ws, + const double pChargeAccum) { auto pchargeLog = std::make_unique<Kernel::TimeSeriesProperty<double>>("proton_charge"); diff --git a/Framework/Algorithms/test/NormaliseByDetectorTest.h b/Framework/Algorithms/test/NormaliseByDetectorTest.h index feb1b287d0433233d2b485d710807ad93c9874f9..be35738086039d1563ae01164aed81b963a18421 100644 --- a/Framework/Algorithms/test/NormaliseByDetectorTest.h +++ b/Framework/Algorithms/test/NormaliseByDetectorTest.h @@ -28,8 +28,8 @@ using ScopedFileHelper::ScopedFile; Helper function. Runs LoadParameterAlg, to get an instrument parameter definition from a file onto a workspace. */ -void apply_instrument_parameter_file_to_workspace(MatrixWorkspace_sptr ws, - const ScopedFile &file) { +void apply_instrument_parameter_file_to_workspace( + const MatrixWorkspace_sptr &ws, const ScopedFile &file) { // Load the Instrument Parameter file over the existing test workspace + // instrument. using DataHandling::LoadParameterFile; @@ -46,7 +46,7 @@ Helper method for running the algorithm and simply verifying that it runs without exception producing an output workspace.. */ MatrixWorkspace_sptr -do_test_doesnt_throw_on_execution(MatrixWorkspace_sptr inputWS, +do_test_doesnt_throw_on_execution(const MatrixWorkspace_sptr &inputWS, bool parallel = true) { NormaliseByDetector alg(parallel); alg.setRethrows(true); @@ -102,7 +102,7 @@ private: The fit function is set at the instrument level. */ MatrixWorkspace_sptr create_workspace_with_fitting_functions( - const std::string result_unit = "Wavelength") { + const std::string &result_unit = "Wavelength") { // Create a default workspace with no-fitting functions. MatrixWorkspace_sptr ws = create_workspace_with_no_fitting_functions(); const std::string instrumentName = ws->getInstrument()->getName(); @@ -228,7 +228,8 @@ private: */ MatrixWorkspace_sptr create_workspace_with_incomplete_detector_level_only_fit_functions( - MatrixWorkspace_sptr original = boost::shared_ptr<MatrixWorkspace>()) { + const MatrixWorkspace_sptr &original = + boost::shared_ptr<MatrixWorkspace>()) { MatrixWorkspace_sptr ws = original; if (original == nullptr) { // Create a default workspace with no-fitting functions. @@ -274,9 +275,8 @@ private: Helper method for running the algorithm and testing for invalid argument on execution. */ - void - do_test_throws_invalid_argument_on_execution(MatrixWorkspace_sptr inputWS, - bool parallel = false) { + void do_test_throws_invalid_argument_on_execution( + const MatrixWorkspace_sptr &inputWS, bool parallel = false) { NormaliseByDetector alg(parallel); alg.setRethrows(true); alg.initialize(); @@ -400,10 +400,11 @@ public: MatrixWorkspace_sptr inputWS = create_workspace_with_fitting_functions(); // Extract the output workspace so that we can verify the normalisation. const bool parallel = true; + const bool sequential = false; MatrixWorkspace_sptr outWS_parallel = do_test_doesnt_throw_on_execution( inputWS, parallel); // EXECUTES THE ALG IN PARALLEL. MatrixWorkspace_sptr outWS_sequential = do_test_doesnt_throw_on_execution( - inputWS, !parallel); // EXECUTES THE ALG SEQUENTIALLY. + inputWS, sequential); // EXECUTES THE ALG SEQUENTIALLY. // Output workspaces should have same number of histograms. TS_ASSERT_EQUALS(2, outWS_parallel->getNumberHistograms()); @@ -651,7 +652,7 @@ public: private: /// Helper method to run common sanity checks. - void do_basic_checks(MatrixWorkspace_sptr normalisedWS) { + void do_basic_checks(const MatrixWorkspace_sptr &normalisedWS) { TS_ASSERT(normalisedWS != nullptr); TS_ASSERT(ws->getNumberHistograms() == normalisedWS->getNumberHistograms()); TS_ASSERT(ws->x(0).size() == normalisedWS->x(0).size()); diff --git a/Framework/Algorithms/test/NormaliseToMonitorTest.h b/Framework/Algorithms/test/NormaliseToMonitorTest.h index b3a9a9c345bd44bed43f805fa52a194c9a4d69ad..1642311c5f7f475c8fed8ecf1a88e6aaf571a0c8 100644 --- a/Framework/Algorithms/test/NormaliseToMonitorTest.h +++ b/Framework/Algorithms/test/NormaliseToMonitorTest.h @@ -468,10 +468,11 @@ public: for (size_t i = 0; i < specOutInfo.size(); ++i) { const auto &yValues = outWS->histogram(i).y(); for (size_t j = 0; j < yValues.size(); ++j) { - if (specOutInfo.isMonitor(i)) + if (specOutInfo.isMonitor(i)) { TS_ASSERT_DELTA(yValues[j], 3.0, 1e-12) - else + } else { TS_ASSERT_DELTA(yValues[j], 6.0 / double(j + 1), 1e-12) + } } } } @@ -497,6 +498,7 @@ public: const auto &yValues = outWS->histogram(i).y(); for (size_t j = 0; j < yValues.size(); ++j) { if (specOutInfo.isMonitor(i)) + // cppcheck-suppress syntaxError TS_ASSERT_DELTA(yValues[j], double(j + 1) / 15.0, 1e-12) else TS_ASSERT_DELTA(yValues[j], 2.0 / 15.0, 1e-12) diff --git a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h index 0f2fea3fef97ed0e109a6a0fd3395f5daa686171..f79748f75c1c2c86c4d1805a37c5486881ffd000 100644 --- a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h +++ b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h @@ -82,8 +82,8 @@ public: } } - void addRow(ITableWorkspace_sptr wksp, const double freq, const double wl, - const int bank, const std::string &van, + void addRow(const ITableWorkspace_sptr &wksp, const double freq, + const double wl, const int bank, const std::string &van, const std::string &van_back, const std::string &can, const std::string &empty_env, const std::string &empty_inst, const std::string &dmin, const std::string &dmax, @@ -209,8 +209,8 @@ public: return expectedInfo; } - void compareResult(PropertyManager_sptr expected, - PropertyManager_sptr observed) { + void compareResult(const PropertyManager_sptr &expected, + const PropertyManager_sptr &observed) { TS_ASSERT_EQUALS(expected->propertyCount(), observed->propertyCount()); const std::vector<Property *> &expectedProps = expected->getProperties(); diff --git a/Framework/Algorithms/test/PDFFourierTransformTest.h b/Framework/Algorithms/test/PDFFourierTransformTest.h index ecf820a006954bfef77e04e55e4d2cb69fa53d60..8b39d78f74853f5ff1bdf57d557305490824ba06 100644 --- a/Framework/Algorithms/test/PDFFourierTransformTest.h +++ b/Framework/Algorithms/test/PDFFourierTransformTest.h @@ -32,7 +32,7 @@ namespace { */ Mantid::API::MatrixWorkspace_sptr createWS(size_t n, double dx, const std::string &name, - const std::string unitlabel, + const std::string &unitlabel, const bool withBadValues = false) { Mantid::API::FrameworkManager::Instance(); diff --git a/Framework/Algorithms/test/ParallaxCorrectionTest.h b/Framework/Algorithms/test/ParallaxCorrectionTest.h index b6cdeb9e46e834df0385ccc3701e2cc70cdc3869..36b63cf846c3c0e61a2ce17f3353c72927beb801 100644 --- a/Framework/Algorithms/test/ParallaxCorrectionTest.h +++ b/Framework/Algorithms/test/ParallaxCorrectionTest.h @@ -27,7 +27,7 @@ using Mantid::Geometry::DetectorInfo; using Mantid::Kernel::V3D; namespace { -bool compare(MatrixWorkspace_sptr w1, MatrixWorkspace_sptr w2) { +bool compare(const MatrixWorkspace_sptr &w1, const MatrixWorkspace_sptr &w2) { CompareWorkspaces comparator; comparator.initialize(); comparator.setChild(true); diff --git a/Framework/Algorithms/test/PerformIndexOperationsTest.h b/Framework/Algorithms/test/PerformIndexOperationsTest.h index 1502a093f78138e316fc1f1012e632863c8300d6..0a0a02992723e10d9f71b4b2a3170a44fa09a214 100644 --- a/Framework/Algorithms/test/PerformIndexOperationsTest.h +++ b/Framework/Algorithms/test/PerformIndexOperationsTest.h @@ -16,7 +16,7 @@ using Mantid::Algorithms::PerformIndexOperations; using namespace Mantid::API; MatrixWorkspace_const_sptr -doExecute(MatrixWorkspace_sptr inWS, +doExecute(const MatrixWorkspace_sptr &inWS, const std::string &processingInstructions) { // Name of the output workspace. std::string outWSName("PerformIndexOperationsTest_OutputWS"); diff --git a/Framework/Algorithms/test/PlusMinusTest.in.h b/Framework/Algorithms/test/PlusMinusTest.in.h index e264d7048f50e004d1b7c1f2ce5fe0218269cec7..68a6515f889fa24b782667cd68ef98bec308a93e 100644 --- a/Framework/Algorithms/test/PlusMinusTest.in.h +++ b/Framework/Algorithms/test/PlusMinusTest.in.h @@ -392,7 +392,7 @@ public: MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; // You have to specify the expected output value because in1 gets changed. performTest(work_in1,work_in2, true, false /*not event out*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_2D() @@ -468,7 +468,7 @@ public: MatrixWorkspace_sptr work_in1 = eventWS_5x10_50; MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, false /*inPlace*/, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_Event_inPlace() @@ -477,7 +477,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, true, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_EventSingleSpectrum_fails() @@ -502,7 +502,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -514,7 +514,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,1,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -525,7 +525,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(5,1,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -537,7 +537,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -567,7 +567,7 @@ public: TS_ASSERT( work_in2->getSpectrum(0).hasDetectorID(100) ); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 3.0 : -1.0, DO_PLUS ? 1.7320 : 1.7320); + DO_PLUS ? 3.0 : -1.0, 1.7320); //Ya, its an event workspace TS_ASSERT(work_out); diff --git a/Framework/Algorithms/test/PoissonErrorsTest.h b/Framework/Algorithms/test/PoissonErrorsTest.h index 4967c3533d84b1d3808330cb9eaa9c0b8904cdfb..1651bc0bdefa202e1839498487218acfb80a3b73 100644 --- a/Framework/Algorithms/test/PoissonErrorsTest.h +++ b/Framework/Algorithms/test/PoissonErrorsTest.h @@ -7,6 +7,8 @@ #pragma once #include <cmath> +#include <utility> + #include <cxxtest/TestSuite.h> #include "MantidAPI/AnalysisDataService.h" @@ -238,15 +240,18 @@ public: } private: - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1) { // default to a horizontal loop orientation - checkData(work_in1, work_in2, work_out1, 0); + checkData(std::move(work_in1), std::move(work_in2), std::move(work_out1), + 0); } // loopOrientation 0=Horizontal, 1=Vertical - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, int loopOrientation) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, int loopOrientation) { size_t ws2LoopCount = 0; if (work_in2->size() > 0) { ws2LoopCount = work_in1->size() / work_in2->size(); @@ -267,9 +272,9 @@ private: } } - void checkDataItem(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, size_t i, + void checkDataItem(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, size_t i, size_t ws2Index) { // printf("I=%d\tws2Index=%d\n",i,ws2Index); double sig1 = diff --git a/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h b/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h index 4af539c20c9306d9e1ad7026f6169140b769b3c0..b558ac16662702b1aa0773d8f2bd80026b7b2376 100644 --- a/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h +++ b/Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h @@ -79,7 +79,7 @@ public: return group; } - MatrixWorkspace_sptr makeEfficiencies(Workspace_sptr inWS, + MatrixWorkspace_sptr makeEfficiencies(const Workspace_sptr &inWS, const std::string &rho, const std::string &pp, const std::string &alpha = "", @@ -214,7 +214,8 @@ public: } } - void setInstrument(Workspace_sptr ws, const std::string &instrument_name) { + void setInstrument(const Workspace_sptr &ws, + const std::string &instrument_name) { auto alg = AlgorithmManager::Instance().createUnmanaged("LoadInstrument"); AnalysisDataService::Instance().addOrReplace("dummy", ws); alg->initialize(); diff --git a/Framework/Algorithms/test/Rebin2DTest.h b/Framework/Algorithms/test/Rebin2DTest.h index 3d458558e089b177118982efacd355e7f27a64e7..3326dbccec4812e03c241097a00ba6701fd0b064 100644 --- a/Framework/Algorithms/test/Rebin2DTest.h +++ b/Framework/Algorithms/test/Rebin2DTest.h @@ -76,7 +76,7 @@ MatrixWorkspace_sptr makeInputWS(const bool distribution, return ws; } -MatrixWorkspace_sptr runAlgorithm(MatrixWorkspace_sptr inputWS, +MatrixWorkspace_sptr runAlgorithm(const MatrixWorkspace_sptr &inputWS, const std::string &axis1Params, const std::string &axis2Params, const bool UseFractionalArea = false) { @@ -273,9 +273,9 @@ public: } private: - void checkData(MatrixWorkspace_const_sptr outputWS, const size_t nxvalues, - const size_t nhist, const bool dist, const bool onAxis1, - const bool small_bins = false) { + void checkData(const MatrixWorkspace_const_sptr &outputWS, + const size_t nxvalues, const size_t nhist, const bool dist, + const bool onAxis1, const bool small_bins = false) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), nhist); TS_ASSERT_EQUALS(outputWS->isDistribution(), dist); // Axis sizes diff --git a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h index f3e8e41787b8a1f06e7941a0a9e9cb33488cab64..1c79b75e5dd4d31d3fc878343669733291f93799 100644 --- a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h +++ b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h @@ -119,8 +119,7 @@ public: TS_ASSERT_EQUALS(outXs.size(), inXs.size()) TS_ASSERT(outputWS->hasDx(0)) const auto &inYs = inputWS->y(0); - const auto &outYs = outputWS->y(0); - TS_ASSERT_EQUALS(outYs.rawData(), inYs.rawData()) + TS_ASSERT_EQUALS(outputWS->y(0).rawData(), inYs.rawData()) const auto &inEs = inputWS->e(0); const auto &outEs = outputWS->e(0); TS_ASSERT_EQUALS(outEs.rawData(), inEs.rawData()) @@ -283,7 +282,7 @@ private: TS_ASSERT(!alg->isExecuted()) } - static API::Algorithm_sptr make_alg(API::MatrixWorkspace_sptr inputWS, + static API::Algorithm_sptr make_alg(const API::MatrixWorkspace_sptr &inputWS, const std::string &sumType, const std::vector<int> &foreground) { auto alg = boost::make_shared<Algorithms::ReflectometryMomentumTransfer>(); diff --git a/Framework/Algorithms/test/ReflectometryReductionOne2Test.h b/Framework/Algorithms/test/ReflectometryReductionOne2Test.h index 382dec5feae141945268d8d4082af78b40841948..e0d381d65367af75e6305dc47df6a211c8580508 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOne2Test.h +++ b/Framework/Algorithms/test/ReflectometryReductionOne2Test.h @@ -964,7 +964,7 @@ private: const double wavelengthMin, const double wavelengthMax, const std::string &procInstr, - MatrixWorkspace_sptr transWS, + const MatrixWorkspace_sptr &transWS, const bool multiple_runs) { setupAlgorithm(alg, wavelengthMin, wavelengthMax, procInstr); alg.setProperty("FirstTransmissionRun", transWS); @@ -981,7 +981,7 @@ private: const double wavelengthMin, const double wavelengthMax, const std::string &procInstr, - MatrixWorkspace_sptr inputWS, + const MatrixWorkspace_sptr &inputWS, const bool integrate) { setupAlgorithm(alg, wavelengthMin, wavelengthMax, procInstr); alg.setProperty("InputWorkspace", inputWS); @@ -997,8 +997,9 @@ private: } } - void setupAlgorithmForBackgroundSubtraction(ReflectometryReductionOne2 &alg, - MatrixWorkspace_sptr inputWS) { + void + setupAlgorithmForBackgroundSubtraction(ReflectometryReductionOne2 &alg, + const MatrixWorkspace_sptr &inputWS) { setupAlgorithm(alg, 0, 5, "3"); alg.setChild(false); // required to get history alg.setProperty("InputWorkspace", inputWS); @@ -1105,7 +1106,7 @@ private: return ws; } - void checkWorkspaceHistory(MatrixWorkspace_sptr ws, + void checkWorkspaceHistory(const MatrixWorkspace_sptr &ws, std::vector<std::string> const &expected, bool const unroll = true) { auto wsHistory = ws->getHistory(); @@ -1116,19 +1117,20 @@ private: auto childHistories = lastAlgHistory->getChildHistories(); std::transform(childHistories.cbegin(), childHistories.cend(), std::back_inserter(algNames), - [](AlgorithmHistory_const_sptr childAlg) { + [](const AlgorithmHistory_const_sptr &childAlg) { return childAlg->name(); }); } else if (!unroll) { - std::transform(algHistories.cbegin(), algHistories.cend(), - std::back_inserter(algNames), - [](AlgorithmHistory_sptr alg) { return alg->name(); }); + std::transform( + algHistories.cbegin(), algHistories.cend(), + std::back_inserter(algNames), + [](const AlgorithmHistory_sptr &alg) { return alg->name(); }); } TS_ASSERT_EQUALS(algNames, expected); } void checkHistoryAlgorithmProperties( - MatrixWorkspace_sptr ws, size_t toplevelIdx, size_t childIdx, + const MatrixWorkspace_sptr &ws, size_t toplevelIdx, size_t childIdx, std::map<std::string, std::string> const &expected) { auto parentHist = ws->getHistory().getAlgorithmHistory(toplevelIdx); auto childHistories = parentHist->getChildHistories(); diff --git a/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h b/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h index 7c41d3fbc7bf35b28ba83de2c06a4692398423e5..38595e0e82eb20039485c8cbfea9e3543f023e0f 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h +++ b/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h @@ -1680,9 +1680,8 @@ public: } private: - MatrixWorkspace_sptr - createFloodWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - size_t n = 4) { + MatrixWorkspace_sptr createFloodWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, size_t n = 4) { size_t detid = 1; auto flood = create2DWorkspace(int(n), 1); if (n == 4) { diff --git a/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h b/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h index 23b0201f6bf53bd95e3131456b2c1b2de82eb581..2041bcb2bf2b65226eecb16d0747376d0f861f87 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h +++ b/Framework/Algorithms/test/ReflectometryReductionOneAuto3Test.h @@ -1594,9 +1594,8 @@ public: } private: - MatrixWorkspace_sptr - createFloodWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - size_t n = 4) { + MatrixWorkspace_sptr createFloodWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, size_t n = 4) { size_t detid = 1; auto flood = create2DWorkspace(int(n), 1); if (n == 4) { diff --git a/Framework/Algorithms/test/ReflectometrySumInQTest.h b/Framework/Algorithms/test/ReflectometrySumInQTest.h index 0dd4fdcb4d0253625e75efdece79c551ff88b4c8..08f40af60478f3ca42e6dd8387a404ba060a8bff 100644 --- a/Framework/Algorithms/test/ReflectometrySumInQTest.h +++ b/Framework/Algorithms/test/ReflectometrySumInQTest.h @@ -29,7 +29,7 @@ public: static void destroySuite(ReflectometrySumInQTest *suite) { delete suite; } static Mantid::API::MatrixWorkspace_sptr - convertToWavelength(Mantid::API::MatrixWorkspace_sptr ws) { + convertToWavelength(const Mantid::API::MatrixWorkspace_sptr &ws) { using namespace Mantid; auto toWavelength = API::AlgorithmManager::Instance().createUnmanaged("ConvertUnits"); @@ -44,7 +44,7 @@ public: } static Mantid::API::MatrixWorkspace_sptr - detectorsOnly(Mantid::API::MatrixWorkspace_sptr ws) { + detectorsOnly(const Mantid::API::MatrixWorkspace_sptr &ws) { using namespace Mantid; auto &specturmInfo = ws->spectrumInfo(); std::vector<size_t> detectorIndices; diff --git a/Framework/Algorithms/test/RemoveLowResTOFTest.h b/Framework/Algorithms/test/RemoveLowResTOFTest.h index 5e7b3aab3fd83f01cb5446c035acc2d0dedad20c..d332578bed373a603676f13a03bbd1c1946f3f69 100644 --- a/Framework/Algorithms/test/RemoveLowResTOFTest.h +++ b/Framework/Algorithms/test/RemoveLowResTOFTest.h @@ -31,7 +31,7 @@ private: int NUMPIXELS; int NUMBINS; - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace( NUMPIXELS, NUMBINS, NUMBINS, 0.0, BIN_DELTA, 2); diff --git a/Framework/Algorithms/test/RemoveMaskedSpectraTest.h b/Framework/Algorithms/test/RemoveMaskedSpectraTest.h index 9bda9c5894ae54cb149bd2d2418b1eced31a5a00..8d182e7a87aca95db1efb99421d37029b032bbf1 100644 --- a/Framework/Algorithms/test/RemoveMaskedSpectraTest.h +++ b/Framework/Algorithms/test/RemoveMaskedSpectraTest.h @@ -106,7 +106,7 @@ private: return space; } - void maskWorkspace(MatrixWorkspace_sptr ws) { + void maskWorkspace(const MatrixWorkspace_sptr &ws) { std::vector<int> spectra(3); spectra[0] = 1; spectra[1] = 3; @@ -119,8 +119,8 @@ private: } MatrixWorkspace_sptr - runAlgorithm(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr maskedWS = MatrixWorkspace_sptr()) { + runAlgorithm(const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &maskedWS = MatrixWorkspace_sptr()) { // Name of the output workspace. std::string outWSName("RemoveMaskedSpectraTest_OutputWS"); diff --git a/Framework/Algorithms/test/RemovePromptPulseTest.h b/Framework/Algorithms/test/RemovePromptPulseTest.h index 83f907853a6762b4d301a83da0d8652530c1f243..e21a5651c8c481332d79589bc8c4b8b70a93e06b 100644 --- a/Framework/Algorithms/test/RemovePromptPulseTest.h +++ b/Framework/Algorithms/test/RemovePromptPulseTest.h @@ -32,7 +32,7 @@ private: std::string inWSName; std::string outWSName; - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace( NUMPIXELS, NUMBINS, NUMEVENTS, 1000., BIN_DELTA, 2); diff --git a/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h b/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h index 7ca2bdcfd94cea892ce1673b944c19657b08f885..81ff558e5e32928516f89fbb1e7f8ac6df267579 100644 --- a/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h +++ b/Framework/Algorithms/test/RemoveWorkspaceHistoryTest.h @@ -64,7 +64,7 @@ private: } }; - void createWorkspace(std::string wsName) { + void createWorkspace(const std::string &wsName) { // create a fake workspace for testing boost::shared_ptr<WorkspaceTester> input = boost::make_shared<WorkspaceTester>(); diff --git a/Framework/Algorithms/test/ReplaceSpecialValuesTest.h b/Framework/Algorithms/test/ReplaceSpecialValuesTest.h index 322e88fbf98e476ddbeb2af118a1b5d7178174f8..ff1ef4fe38df6dde1db5ca7edd60c9a1fda377fd 100644 --- a/Framework/Algorithms/test/ReplaceSpecialValuesTest.h +++ b/Framework/Algorithms/test/ReplaceSpecialValuesTest.h @@ -247,8 +247,9 @@ public: AnalysisDataService::Instance().remove("InputWS"); } - void checkValues(MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr result, - bool naNCheck, bool infCheck) { + void checkValues(const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &result, bool naNCheck, + bool infCheck) { for (size_t i = 0; i < result->getNumberHistograms(); ++i) { for (int j = 1; j < 5; ++j) { diff --git a/Framework/Algorithms/test/ResampleXTest.h b/Framework/Algorithms/test/ResampleXTest.h index 10eca45e800be2f7659d376bde8deccfee183d00..bb64a2500391e63add5f7ab23d0c17b0ca0125db 100644 --- a/Framework/Algorithms/test/ResampleXTest.h +++ b/Framework/Algorithms/test/ResampleXTest.h @@ -221,7 +221,6 @@ public: vector<double> xmins = alg.getProperty("XMin"); vector<double> xmaxs = alg.getProperty("XMax"); int nBins = alg.getProperty("NumberBins"); - double deltaBin; // Define tolerance for ASSERT_DELTA double tolerance = 1.0e-10; @@ -230,7 +229,8 @@ public: for (int yIndex = 0; yIndex < ylen; ++yIndex) { // The bin width for the current spectrum - deltaBin = (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); + double deltaBin = + (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); // Check the axes lengths TS_ASSERT_EQUALS(outWS->x(yIndex).size(), nBins + 1); @@ -344,7 +344,6 @@ public: vector<double> xmins = alg.getProperty("XMin"); vector<double> xmaxs = alg.getProperty("XMax"); int nBins = alg.getProperty("NumberBins"); - double deltaBin; // Define tolerance for ASSERT_DELTA double tolerance = 1.0e-10; @@ -354,7 +353,8 @@ public: for (int yIndex = 0; yIndex < ylen; ++yIndex) { // The bin width for the current spectrum - deltaBin = (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); + double deltaBin = + (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); // Check the axes lengths TS_ASSERT_EQUALS(outWS->x(yIndex).size(), nBins + 1); diff --git a/Framework/Algorithms/test/RingProfileTest.h b/Framework/Algorithms/test/RingProfileTest.h index 725ed7fbb384b73fa7518e28af1960f9f2493edc..3580725c7c232e49a8c2d9a46b817019a8aa22ef 100644 --- a/Framework/Algorithms/test/RingProfileTest.h +++ b/Framework/Algorithms/test/RingProfileTest.h @@ -41,12 +41,12 @@ public: // centre must be 2 or 3 values (x,y) or (x,y,z) std::vector<double> justOne(1); justOne[0] = -0.35; - // TS_ASSERT_THROWS(alg.setProperty("Centre",justOne), - // const std::invalid_argument &); + TS_ASSERT_THROWS(alg.setProperty("Centre", justOne), + const std::invalid_argument &); std::vector<double> fourInputs(4, -0.45); - // TS_ASSERT_THROWS(alg.setProperty("Centre", fourInputs), - // const std::invalid_argument &); + TS_ASSERT_THROWS(alg.setProperty("Centre", fourInputs), + const std::invalid_argument &); TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWSName)); diff --git a/Framework/Algorithms/test/RunCombinationHelperTest.h b/Framework/Algorithms/test/RunCombinationHelperTest.h index f969377a6ea794d3b75619e10ec31f72c9412c8d..e2319d0eefe4615a7ed86f452a11d99cc47e104f 100644 --- a/Framework/Algorithms/test/RunCombinationHelperTest.h +++ b/Framework/Algorithms/test/RunCombinationHelperTest.h @@ -187,7 +187,7 @@ public: } private: - void setUnits(MatrixWorkspace_sptr ws) { + void setUnits(const MatrixWorkspace_sptr &ws) { ws->getAxis(0)->unit() = UnitFactory::Instance().create("TOF"); ws->getAxis(1)->unit() = UnitFactory::Instance().create("Momentum"); ws->setYUnit("Counts"); diff --git a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h index a950bb69a8582eda616f6f203e5ea70c109c5748..8ee9edd6fa851d536185c2a73151e19067b511e8 100644 --- a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h +++ b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h @@ -9,6 +9,8 @@ #include "MantidAlgorithms/SANSCollimationLengthEstimator.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Objects/CSGObject.h" @@ -71,8 +73,8 @@ createTestInstrument(const Mantid::detid_t id, * Set the instrument parameters */ void setInstrumentParametersForTOFSANS( - const Mantid::API::MatrixWorkspace_sptr ws, std::string methodType = "", - double collimationLengthCorrection = 20, + const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &methodType = "", double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5) { auto &pmap = ws->instrumentParameters(); @@ -106,8 +108,8 @@ void setInstrumentParametersForTOFSANS( /* * Add a timer series sample log */ -void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, - std::string sampleLogName, double value, +void addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, + const std::string &sampleLogName, double value, unsigned int length) { auto timeSeries = new Mantid::Kernel::TimeSeriesProperty<double>(sampleLogName); @@ -124,7 +126,7 @@ void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, */ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( const size_t nhist, const double x0, const double x1, const double dx, - std::string methodType = "", double collimationLengthCorrection = 20, + const std::string &methodType = "", double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5, V3D sourcePosition = V3D(0.0, 0.0, -25.0), V3D samplePosition = V3D(0.0, 0.0, 0.0), @@ -142,8 +144,8 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( // Set the instrument parameters setInstrumentParametersForTOFSANS( - ws2d, methodType, collimationLengthCorrection, collimationLengthIncrement, - guideCutoff, numberOfGuides); + ws2d, std::move(methodType), collimationLengthCorrection, + collimationLengthIncrement, guideCutoff, numberOfGuides); // Add sample log details if (!guideLogDetails.empty()) { diff --git a/Framework/Algorithms/test/SampleLogsBehaviourTest.h b/Framework/Algorithms/test/SampleLogsBehaviourTest.h index 6feaafde477818b56b4ca77f6af31d1fe579a142..3cc82415ad85894cd16e19cfb99b924ee337d026 100644 --- a/Framework/Algorithms/test/SampleLogsBehaviourTest.h +++ b/Framework/Algorithms/test/SampleLogsBehaviourTest.h @@ -221,7 +221,7 @@ public: return ws; } - void testLogUnits(MatrixWorkspace_sptr ws) { + void testLogUnits(const MatrixWorkspace_sptr &ws) { // All units must not have changed: TS_ASSERT_EQUALS(ws->getLog("A")->units(), "A_unit") TS_ASSERT_EQUALS(ws->getLog("B")->units(), "B_unit") diff --git a/Framework/Algorithms/test/SassenaFFTTest.h b/Framework/Algorithms/test/SassenaFFTTest.h index 02725308399d37568b37fa9f3652ea1f7f16c211..575614655df6803eaef1c98dc986764b04012675 100644 --- a/Framework/Algorithms/test/SassenaFFTTest.h +++ b/Framework/Algorithms/test/SassenaFFTTest.h @@ -176,7 +176,6 @@ private: const double frErr = 1E-03; // allowed fractional error const size_t nspectra = ws->getNumberHistograms(); MantidVec yv, xv; - double factor; // remove the detailed balance condition for (size_t i = 0; i < nspectra; i++) { double goldStandard = ps2meV * (1 + static_cast<double>(i)) * @@ -186,7 +185,7 @@ private: size_t index = nbins / 2; // This position should yield ws->readX(i).at(index)==0.0 double x = ws->readX(i).at(index); - factor = exp(exponentFactor * x); + double factor = exp(exponentFactor * x); double h = yv.at(index) * exp(x); xv = ws->readX(i); MantidVec::iterator itx = xv.begin(); @@ -212,9 +211,8 @@ private: */ void Gaussian(MantidVec &xv, MantidVec &yv, const double &Heigth, const double &sigma) { - double z; for (size_t i = 0; i < xv.size(); i++) { - z = xv[i] / sigma; + double z = xv[i] / sigma; yv[i] = Heigth * exp(-z * z / 2.0); } } // void Gaussian @@ -250,12 +248,11 @@ private: xv.emplace_back(dt * static_cast<double>(j)); } - double sigma; MantidVec yv(nbins); // each spectra is a gaussian of same Height but different stdev for (size_t i = 0; i < nspectra; i++) { ws->mutableX(i) = xv; - sigma = sigma0 / (1 + static_cast<double>(i)); + double sigma = sigma0 / (1 + static_cast<double>(i)); this->Gaussian(xv, yv, Heigth, sigma); ws->mutableY(i) = yv; } diff --git a/Framework/Algorithms/test/ScaleTest.h b/Framework/Algorithms/test/ScaleTest.h index 08df28cbaef79bdc53831ab0ee166814e9da4da9..973f48ebc645eca819f5c1a5bb9843aa42906f0e 100644 --- a/Framework/Algorithms/test/ScaleTest.h +++ b/Framework/Algorithms/test/ScaleTest.h @@ -127,7 +127,7 @@ private: } } - void doTestScaleWithDx(std::string type, bool outIsIn = false) { + void doTestScaleWithDx(const std::string &type, bool outIsIn = false) { // Arrange const double xValue = 1.222; const double value = 5; diff --git a/Framework/Algorithms/test/SetInstrumentParameterTest.h b/Framework/Algorithms/test/SetInstrumentParameterTest.h index b718fba691a09e3d44024824a3e4101b07720310..7da3ec3c0c43653401003b55f3346ae955e678ca 100644 --- a/Framework/Algorithms/test/SetInstrumentParameterTest.h +++ b/Framework/Algorithms/test/SetInstrumentParameterTest.h @@ -173,10 +173,10 @@ public: } MatrixWorkspace_sptr - ExecuteAlgorithm(MatrixWorkspace_sptr testWS, std::string cmptName, - std::string detList, std::string paramName, - std::string paramValue, std::string paramType = "", - bool fails = false) { + ExecuteAlgorithm(MatrixWorkspace_sptr testWS, const std::string &cmptName, + const std::string &detList, const std::string ¶mName, + const std::string ¶mValue, + const std::string ¶mType = "", bool fails = false) { // add the workspace to the ADS AnalysisDataService::Instance().addOrReplace( "SetInstrumentParameter_Temporary", testWS); diff --git a/Framework/Algorithms/test/SetUncertaintiesTest.h b/Framework/Algorithms/test/SetUncertaintiesTest.h index c9f1cbab774b9923156a2f35c3f4e55c35138600..02ac7f9fbac25d88d2d3f24a0727cb857d9c0b99 100644 --- a/Framework/Algorithms/test/SetUncertaintiesTest.h +++ b/Framework/Algorithms/test/SetUncertaintiesTest.h @@ -55,6 +55,38 @@ public: return outWS; } + /** + * Create and execute the algorithm in the specified mode. + * @param mode The name of the SetError property SetUncertainties + * @return The name that the output workspace will be registered as. + */ + API::MatrixWorkspace_sptr runAlgInPlace(const std::string &mode) { + // random data mostly works + auto inWksp = WorkspaceCreationHelper::create1DWorkspaceRand(30, true); + // Ensure first elements of random workspace are zero so test don't + // pass randomly + auto &E = inWksp->mutableE(0); + E[0] = 0.; + auto &Y = inWksp->mutableY(0); + Y[1] = 0.; // stress sqrtOrOne + + std::string outWSname = "SetUncertainties_" + mode; + WorkspaceCreationHelper::storeWS(outWSname, inWksp); + SetUncertainties alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + alg.setProperty("InputWorkspace", inWksp); + alg.setProperty("SetError", mode); + alg.setProperty("OutputWorkspace", outWSname); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + TS_ASSERT(alg.isExecuted()); + + const auto outWS = + API::AnalysisDataService::Instance().retrieveWS<API::MatrixWorkspace>( + outWSname); + TS_ASSERT(bool(outWS)); // non-null pointer + return outWS; + } + API::MatrixWorkspace_sptr runAlgCustom(const double toSet, const double toReplace, const double errorVal, const int precision, const int position) { @@ -97,6 +129,17 @@ public: API::AnalysisDataService::Instance().remove(outWS->getName()); } + void test_zero_in_place() { + const auto outWS = runAlgInPlace("zero"); + + const auto &E = outWS->e(0); + for (const auto item : E) { + TS_ASSERT_EQUALS(item, 0.); + } + + API::AnalysisDataService::Instance().remove(outWS->getName()); + } + void test_sqrt() { const auto outWS = runAlg("sqrt"); @@ -109,6 +152,18 @@ public: API::AnalysisDataService::Instance().remove(outWS->getName()); } + void test_sqrt_in_place() { + const auto outWS = runAlgInPlace("sqrt"); + + const auto &E = outWS->e(0); + const auto &Y = outWS->y(0); + for (size_t i = 0; i < E.size(); ++i) { + TS_ASSERT_DELTA(Y[i], E[i] * E[i], .001); + } + + API::AnalysisDataService::Instance().remove(outWS->getName()); + } + void test_oneIfZero() { const auto outWS = runAlg("oneIfZero"); @@ -119,6 +174,16 @@ public: API::AnalysisDataService::Instance().remove(outWS->getName()); } + void test_oneIfZero_in_place() { + const auto outWS = runAlgInPlace("oneIfZero"); + + const auto &E = outWS->e(0); + for (const auto item : E) { + TS_ASSERT(item > 0.); + } + API::AnalysisDataService::Instance().remove(outWS->getName()); + } + void test_sqrtOrOne() { const auto outWS = runAlg("sqrtOrOne"); @@ -131,7 +196,21 @@ public: TS_ASSERT_DELTA(Y[i], E[i] * E[i], .001); } } + API::AnalysisDataService::Instance().remove(outWS->getName()); + } + + void test_sqrtOrOne_in_place() { + const auto outWS = runAlgInPlace("sqrtOrOne"); + const auto &E = outWS->e(0); + const auto &Y = outWS->y(0); + for (size_t i = 0; i < E.size(); ++i) { + if (Y[i] == 0.) { + TS_ASSERT_EQUALS(E[i], 1.); + } else { + TS_ASSERT_DELTA(Y[i], E[i] * E[i], .001); + } + } API::AnalysisDataService::Instance().remove(outWS->getName()); } @@ -201,6 +280,42 @@ public: } API::AnalysisDataService::Instance().remove(outWS->getName()); } + + /** + * Create and execute the algorithm in the specified mode. + * @param mode The name of the SetError property SetUncertainties + * @return The name that the output workspace will be registered as. + */ + void test_EventWorkspacePlace() { + // random data mostly works + auto inWksp = + WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument2(10, + 10); + std::string outWSname = "SetUncertainties_oneIfZero"; + WorkspaceCreationHelper::storeWS(outWSname, inWksp); + SetUncertainties alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + alg.setProperty("InputWorkspace", inWksp); + alg.setProperty("SetError", "oneIfZero"); + alg.setProperty("OutputWorkspace", outWSname); + TS_ASSERT_THROWS_NOTHING(alg.execute()); + TS_ASSERT(alg.isExecuted()); + + const auto outWS = + API::AnalysisDataService::Instance().retrieveWS<API::MatrixWorkspace>( + outWSname); + TS_ASSERT(bool(outWS)); // non-null pointer + + const auto &E = outWS->e(0); + const auto &Y = outWS->y(0); + for (size_t i = 0; i < E.size(); ++i) { + if (Y[i] == 0.) { + TS_ASSERT_EQUALS(E[i], 1.); + } else { + TS_ASSERT_DELTA(Y[i], E[i] * E[i], .001); + } + } + } }; class SetUncertaintiesTestPerformance : public CxxTest::TestSuite { diff --git a/Framework/Algorithms/test/ShiftLogTimeTest.h b/Framework/Algorithms/test/ShiftLogTimeTest.h index b827da4744f2ff01b52a3b9a42ca2cfdd32b1043..64a2111fe9bc2436c6c01a0e780e7fbea9b3640c 100644 --- a/Framework/Algorithms/test/ShiftLogTimeTest.h +++ b/Framework/Algorithms/test/ShiftLogTimeTest.h @@ -61,7 +61,7 @@ private: * @param in_name Name of the input workspace. * @param out_name Name of the output workspace. */ - void verify(const std::string in_name, const std::string out_name, + void verify(const std::string &in_name, const std::string &out_name, const int shift) { DateAndTime start(start_str); diff --git a/Framework/Algorithms/test/SmoothNeighboursTest.h b/Framework/Algorithms/test/SmoothNeighboursTest.h index 317f8eb0442d7068020e2601ba1408d2cad2eca8..39ede25745d951215e9a66babd91ad89e57189ea 100644 --- a/Framework/Algorithms/test/SmoothNeighboursTest.h +++ b/Framework/Algorithms/test/SmoothNeighboursTest.h @@ -21,7 +21,7 @@ using namespace Mantid::Algorithms; class SmoothNeighboursTest : public CxxTest::TestSuite { public: - void doTestWithNumberOfNeighbours(std::string WeightedSum = "Flat") { + void doTestWithNumberOfNeighbours(const std::string &WeightedSum = "Flat") { MatrixWorkspace_sptr inWS = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(100, 10); @@ -75,7 +75,7 @@ public: } void do_test_non_uniform(EventType type, double *expectedY, - std::string WeightedSum = "Parabolic", + const std::string &WeightedSum = "Parabolic", bool PreserveEvents = true, double Radius = 0.001, bool ConvertTo2D = false, int numberOfNeighbours = 8) { @@ -158,7 +158,7 @@ public: } void do_test_rectangular(EventType type, double *expectedY, - std::string WeightedSum = "Parabolic", + const std::string &WeightedSum = "Parabolic", bool PreserveEvents = true, bool ConvertTo2D = false) { // Pixels will be spaced 0.008 apart. diff --git a/Framework/Algorithms/test/SofQCommonTest.h b/Framework/Algorithms/test/SofQCommonTest.h index 46ee0e873b8545b8f652aebfcd97ef34ee11c6be..d2aae6161915092f9bd60b6a3703590489e4ae7a 100644 --- a/Framework/Algorithms/test/SofQCommonTest.h +++ b/Framework/Algorithms/test/SofQCommonTest.h @@ -257,7 +257,7 @@ private: return std::sqrt(ki * ki + kf * kf - 2. * ki * kf * std::cos(twoTheta)); } - static void setEFixed(Mantid::API::MatrixWorkspace_sptr ws, + static void setEFixed(const Mantid::API::MatrixWorkspace_sptr &ws, const std::string &component, const double eFixed) { using namespace Mantid; auto alg = API::AlgorithmManager::Instance().createUnmanaged( diff --git a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h index eaa457965e3c10e72098c8f847b74959a5f1bb4f..88c965eb97bc846e232c37df3b48f81cd5eba9c1 100644 --- a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h +++ b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h @@ -236,6 +236,7 @@ public: TS_ASSERT_THROWS_NOTHING(alg.setProperty("EMode", "Indirect")) TS_ASSERT_THROWS_NOTHING(alg.setProperty("EFixed", 1.84)) const double dE{0.3}; + // cppcheck-suppress unreadVariable const std::vector<double> eBinParams{dE}; std::vector<double> expectedEBinEdges; const auto firstEdge = inWS->x(0).front(); @@ -364,9 +365,10 @@ public: * @param twoThetaRanges input table workspace * @return the algorithm object */ - IAlgorithm_sptr setUpAlg( - Mantid::API::MatrixWorkspace_sptr const inputWS, - boost::shared_ptr<Mantid::DataObjects::TableWorkspace> twoThetaRanges) { + IAlgorithm_sptr + setUpAlg(Mantid::API::MatrixWorkspace_sptr const &inputWS, + const boost::shared_ptr<Mantid::DataObjects::TableWorkspace> + &twoThetaRanges) { const std::vector<double> qBinParams{0.023}; IAlgorithm_sptr alg = AlgorithmManager::Instance().create("SofQWNormalisedPolygon"); @@ -384,7 +386,7 @@ public: * @return A pointer to the table workspace */ boost::shared_ptr<Mantid::DataObjects::TableWorkspace> - createTableWorkspace(const std::vector<std::string> dataTypes, + createTableWorkspace(const std::vector<std::string> &dataTypes, const int rowCount) { auto twoThetaRanges = boost::make_shared<TableWorkspace>(); std::vector<std::string> names = {"Detector ID", "Max two theta", diff --git a/Framework/Algorithms/test/SolidAngleTest.h b/Framework/Algorithms/test/SolidAngleTest.h index 649d35707bb3a2fd7cff740ca3ac5207a276c9ac..dc64b47dd9d8f3e508f2be42440b17c5824b4f40 100644 --- a/Framework/Algorithms/test/SolidAngleTest.h +++ b/Framework/Algorithms/test/SolidAngleTest.h @@ -213,7 +213,7 @@ public: auto spectrumInfo2 = output2D_2->spectrumInfo(); for (size_t i = 0; i < numberOfSpectra1; i++) { // all values after the start point of the second workspace should match - if (!(spectrumInfo2.isMasked(i) || spectrumInfo2.isMasked(i))) { + if (!(spectrumInfo1.isMasked(i) || spectrumInfo2.isMasked(i))) { TS_ASSERT_EQUALS(output2D_1->y(i)[0], output2D_2->y(i)[0]); } } diff --git a/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h b/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h index 740e27ac27c6ba60f10dd80db5d9db26e40bf103..45e7009a10f72edace3376620e0d9c15e88fc0a8 100644 --- a/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h +++ b/Framework/Algorithms/test/SpecularReflectionAlgorithmTest.h @@ -68,7 +68,8 @@ protected: } VerticalHorizontalOffsetType determine_vertical_and_horizontal_offsets( - MatrixWorkspace_sptr ws, std::string detectorName = "point-detector") { + const MatrixWorkspace_sptr &ws, + const std::string &detectorName = "point-detector") { auto instrument = ws->getInstrument(); const V3D pointDetector = instrument->getComponentByName(detectorName)->getPos(); diff --git a/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h b/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h index d2d7c5edc44f58dd61f37000c13a13d701a4b149..3f91a26dd6d820dc23b0d9a1250ef29b080285d3 100644 --- a/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h +++ b/Framework/Algorithms/test/SpecularReflectionPositionCorrectTest.h @@ -15,6 +15,7 @@ #include "MantidKernel/V3D.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cmath> +#include <utility> using Mantid::Algorithms::SpecularReflectionPositionCorrect; using namespace Mantid::API; @@ -181,9 +182,9 @@ public: sampleToDetectorBeamOffset, 1e-6); } - void - do_test_correct_point_detector_position(std::string detectorFindProperty = "", - std::string stringValue = "") { + void do_test_correct_point_detector_position( + const std::string &detectorFindProperty = "", + const std::string &stringValue = "") { MatrixWorkspace_sptr toConvert = pointDetectorWS; const double thetaInDegrees = 10.0; // Desired theta in degrees. @@ -240,8 +241,8 @@ public: } double do_test_correct_line_detector_position( - std::vector<int> specNumbers, double thetaInDegrees, - std::string detectorName = "lineardetector", + const std::vector<int> &specNumbers, double thetaInDegrees, + const std::string &detectorName = "lineardetector", bool strictSpectrumCheck = true) { auto toConvert = this->linearDetectorWS; @@ -258,7 +259,7 @@ public: VerticalHorizontalOffsetType offsetTupleCorrected = determine_vertical_and_horizontal_offsets( - corrected, detectorName); // Positions after correction + corrected, std::move(detectorName)); // Positions after correction const double sampleToDetectorVerticalOffsetCorrected = offsetTupleCorrected.get<0>(); diff --git a/Framework/Algorithms/test/Stitch1DManyTest.h b/Framework/Algorithms/test/Stitch1DManyTest.h index 5b0252dabdc76cf51ec4aa39efc128ab8e216507..bacff25f1164adbcd032ea793de476dd7b8626e7 100644 --- a/Framework/Algorithms/test/Stitch1DManyTest.h +++ b/Framework/Algorithms/test/Stitch1DManyTest.h @@ -45,7 +45,7 @@ private: * @param outWSName :: output workspace name used if running CreateWorkspace */ void createUniformWorkspace(double xstart, double deltax, double value1, - double value2, std::string outWSName, + double value2, const std::string &outWSName, bool runAlg = false) { const int nbins = 10; @@ -108,7 +108,8 @@ private: * @param inputWSNames :: input workspaces names * @param outputWSName :: output workspace name */ - void doGroupWorkspaces(std::string inputWSNames, std::string outWSName) { + void doGroupWorkspaces(const std::string &inputWSNames, + const std::string &outWSName) { GroupWorkspaces gw; gw.initialize(); gw.setProperty("InputWorkspaces", inputWSNames); @@ -123,7 +124,7 @@ private: * @param inputWS :: the input workspace * @return vector of names of algorithm histories */ - std::vector<std::string> getHistory(MatrixWorkspace_sptr inputWS) { + std::vector<std::string> getHistory(const MatrixWorkspace_sptr &inputWS) { std::vector<std::string> histNames; auto histories = inputWS->history().getAlgorithmHistories(); for (auto &hist : histories) { diff --git a/Framework/Algorithms/test/SumOverlappingTubesTest.h b/Framework/Algorithms/test/SumOverlappingTubesTest.h index f64ce4b756266372c56920e08cf77be489884c9a..af23cd66dd389bfadb652d3b4a486ed105a7e09c 100644 --- a/Framework/Algorithms/test/SumOverlappingTubesTest.h +++ b/Framework/Algorithms/test/SumOverlappingTubesTest.h @@ -34,8 +34,8 @@ using namespace Mantid::Types::Core; namespace { MatrixWorkspace_sptr createTestScanningWS(size_t nTubes, size_t nPixelsPerTube, - std::vector<double> rotations, - std::string name = "testWS") { + const std::vector<double> &rotations, + const std::string &name = "testWS") { const auto instrument = ComponentCreationHelper::createInstrumentWithPSDTubes( nTubes, nPixelsPerTube, true); size_t nTimeIndexes = rotations.size(); @@ -131,7 +131,7 @@ public: TS_ASSERT_DELTA(yAxis->getValue(i), 0.003 * double(i), 1e-6) } - void verifySpectraHaveSameCounts(MatrixWorkspace_sptr outWS, + void verifySpectraHaveSameCounts(const MatrixWorkspace_sptr &outWS, double expectedCounts = 2.0, double expectedErrors = sqrt(2.0), bool checkErrors = true) { @@ -143,7 +143,7 @@ public: } } - void verifySpectraCountsForScan(MatrixWorkspace_sptr outWS) { + void verifySpectraCountsForScan(const MatrixWorkspace_sptr &outWS) { size_t bin = 0; for (size_t j = 0; j < N_PIXELS_PER_TUBE; ++j) { TS_ASSERT_DELTA(outWS->getSpectrum(j).y()[bin], 2.0, 1e-6) @@ -697,9 +697,8 @@ public: auto outWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( AnalysisDataService::Instance().retrieve("outWS")); - const auto &xAxis = outWS->getAxis(0); - TS_ASSERT_EQUALS(xAxis->length(), 296) - const auto &yAxis = outWS->getAxis(1); + auto yAxis = outWS->getAxis(1); + TS_ASSERT_EQUALS(outWS->getAxis(0)->length(), 296) TS_ASSERT_EQUALS(yAxis->length(), 256) for (size_t i = 0; i < 256; i++) { @@ -735,9 +734,8 @@ public: auto outWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( AnalysisDataService::Instance().retrieve("outWS")); - const auto &xAxis = outWS->getAxis(0); - TS_ASSERT_EQUALS(xAxis->length(), 296) - const auto &yAxis = outWS->getAxis(1); + auto yAxis = outWS->getAxis(1); + TS_ASSERT_EQUALS(outWS->getAxis(0)->length(), 296) TS_ASSERT_EQUALS(yAxis->length(), 256) for (size_t i = 0; i < 256; i++) { diff --git a/Framework/Algorithms/test/SumSpectraTest.h b/Framework/Algorithms/test/SumSpectraTest.h index 1e8066de1e9149e9ea58bad086a83d883806c6cc..664c39b90ea42fbdb745a723d4a78c058fc439cc 100644 --- a/Framework/Algorithms/test/SumSpectraTest.h +++ b/Framework/Algorithms/test/SumSpectraTest.h @@ -277,8 +277,8 @@ public: const std::runtime_error &); } - void dotestExecEvent(std::string inName, std::string outName, - std::string indices_list) { + void dotestExecEvent(const std::string &inName, const std::string &outName, + const std::string &indices_list) { int numPixels = 100; int numBins = 20; int numEvents = 20; @@ -568,7 +568,6 @@ public: testSig = std::sqrt(testSig); // Set the properties alg2.setProperty("InputWorkspace", tws); - const std::string outputSpace2 = "SumSpectraOut2"; alg2.setPropertyValue("OutputWorkspace", outName); alg2.setProperty("IncludeMonitors", false); alg2.setProperty("WeightedSum", true); diff --git a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h index 5c5c039c30cfa9378ed5f391d20dccafa24a5f1e..38dee4681567ffd99cd9f40ca7186b98cd16e888 100644 --- a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h +++ b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h @@ -22,6 +22,7 @@ #include "boost/shared_ptr.hpp" #include <stdexcept> +#include <utility> using namespace Mantid::Algorithms; using Mantid::Kernel::V3D; @@ -82,8 +83,8 @@ createTestInstrument(const Mantid::detid_t id, * Set the instrument parameters */ void setInstrumentParametersForTOFSANS( - const Mantid::API::MatrixWorkspace_sptr ws, std::string methodType = "", - double collimationLengthCorrection = 20, + const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &methodType = "", double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5) { auto &pmap = ws->instrumentParameters(); @@ -117,8 +118,8 @@ void setInstrumentParametersForTOFSANS( /* * Add a timer series sample log */ -void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, - std::string sampleLogName, double value, +void addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, + const std::string &sampleLogName, double value, unsigned int length) { auto timeSeries = new Mantid::Kernel::TimeSeriesProperty<double>(sampleLogName); @@ -135,7 +136,7 @@ void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, */ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( const size_t nhist, const double x0, const double x1, const double dx, - std::string methodType = "", bool isModerator = false, + const std::string &methodType = "", bool isModerator = false, double collimationLengthCorrection = 20, double collimationLengthIncrement = 2, double guideCutoff = 130, double numberOfGuides = 5, V3D sourcePosition = V3D(0.0, 0.0, -25.0), @@ -163,8 +164,8 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( // Set the instrument parameters setInstrumentParametersForTOFSANS( - ws2d, methodType, collimationLengthCorrection, collimationLengthIncrement, - guideCutoff, numberOfGuides); + ws2d, std::move(methodType), collimationLengthCorrection, + collimationLengthIncrement, guideCutoff, numberOfGuides); // Add sample log details if (!guideLogDetails.empty()) { diff --git a/Framework/Algorithms/test/UnwrapMonitorTest.h b/Framework/Algorithms/test/UnwrapMonitorTest.h index 009a150a6b0960ad2fcb165fb30ebe8ea1ccd6c0..dd1193aae0da8bc5e38e149f241df72fae125dbb 100644 --- a/Framework/Algorithms/test/UnwrapMonitorTest.h +++ b/Framework/Algorithms/test/UnwrapMonitorTest.h @@ -175,7 +175,7 @@ private: // Run the algorithm and do some basic checks. Returns the output workspace. MatrixWorkspace_const_sptr - runAlgorithm(UnwrapMonitor &algo, const MatrixWorkspace_const_sptr inWS) { + runAlgorithm(UnwrapMonitor &algo, const MatrixWorkspace_const_sptr &inWS) { // run the algorithm TS_ASSERT(algo.execute()); TS_ASSERT(algo.isExecuted()); diff --git a/Framework/Algorithms/test/UnwrapSNSTest.h b/Framework/Algorithms/test/UnwrapSNSTest.h index 9afb0ca1ecf5fff37d41f6de90f77fb7af97a29b..15838fe963cf43899a1deaf80e9bc02ee88e5912 100644 --- a/Framework/Algorithms/test/UnwrapSNSTest.h +++ b/Framework/Algorithms/test/UnwrapSNSTest.h @@ -29,7 +29,7 @@ private: int NUMPIXELS; int NUMBINS; - void makeFakeEventWorkspace(std::string wsName) { + void makeFakeEventWorkspace(const std::string &wsName) { // Make an event workspace with 2 events in each bin. EventWorkspace_sptr test_in = WorkspaceCreationHelper::createEventWorkspace( NUMPIXELS, NUMBINS, NUMBINS, 0.0, BIN_DELTA, 2); diff --git a/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h b/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h index f0c1650de4afdf1bc4e58dfb7727455658047e7a..df7d1c9d9030d020c1cb70d4eacf8a0a0dc6fef6 100644 --- a/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h +++ b/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h @@ -159,7 +159,7 @@ public: } private: - void validateFullResolutionWorkspace(MatrixWorkspace_sptr ws) { + void validateFullResolutionWorkspace(const MatrixWorkspace_sptr &ws) { NumericAxis *xAxis = dynamic_cast<NumericAxis *>(ws->getAxis(0)); TS_ASSERT(xAxis); if (xAxis) { @@ -177,7 +177,7 @@ private: } } - void validateFullDistributionWorkspace(MatrixWorkspace_sptr ws, + void validateFullDistributionWorkspace(const MatrixWorkspace_sptr &ws, const std::string &label) { NumericAxis *xAxis = dynamic_cast<NumericAxis *>(ws->getAxis(0)); TS_ASSERT(xAxis); diff --git a/Framework/Algorithms/test/WienerSmoothTest.h b/Framework/Algorithms/test/WienerSmoothTest.h index ceea1b67bf7015cb1ca60b06636c4a474769e37d..621d07e59b06ab0b71d6efe333887ba9a080a2cd 100644 --- a/Framework/Algorithms/test/WienerSmoothTest.h +++ b/Framework/Algorithms/test/WienerSmoothTest.h @@ -580,7 +580,7 @@ private: } } - MatrixWorkspace_sptr runWienerSmooth(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr runWienerSmooth(const MatrixWorkspace_sptr &inputWS, const std::vector<int> &wsIndexList) { // Name of the output workspace. std::string outWSName("WienerSmoothTest_OutputWS"); diff --git a/Framework/Algorithms/test/WorkspaceGroupTest.h b/Framework/Algorithms/test/WorkspaceGroupTest.h index 6842062876a001a1814bab43f0c0e1c6534db808..f37adda4f3efba15d618576c4b4d94d0e6352597 100644 --- a/Framework/Algorithms/test/WorkspaceGroupTest.h +++ b/Framework/Algorithms/test/WorkspaceGroupTest.h @@ -19,6 +19,7 @@ #include <Poco/File.h> #include <fstream> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -30,15 +31,18 @@ using Mantid::HistogramData::CountStandardDeviations; class WorkspaceGroupTest : public CxxTest::TestSuite { private: - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1) { // default to a horizontal loop orientation - checkData(work_in1, work_in2, work_out1, 0); + checkData(std::move(work_in1), std::move(work_in2), std::move(work_out1), + 0); } // loopOrientation 0=Horizontal, 1=Vertical - void checkData(MatrixWorkspace_sptr work_in1, MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, int loopOrientation) { + void checkData(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, int loopOrientation) { if (!work_in1 || !work_in2 || !work_out1) { TSM_ASSERT("One or more empty workspace pointers.", 0); return; @@ -63,9 +67,9 @@ private: } } - void checkDataItem(MatrixWorkspace_sptr work_in1, - MatrixWorkspace_sptr work_in2, - MatrixWorkspace_sptr work_out1, size_t i, + void checkDataItem(const MatrixWorkspace_sptr &work_in1, + const MatrixWorkspace_sptr &work_in2, + const MatrixWorkspace_sptr &work_out1, size_t i, size_t ws2Index) { double sig1 = work_in1->dataY(i / work_in1->blocksize())[i % work_in1->blocksize()]; diff --git a/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h b/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h index c886831e0ab3ac5551d4e56ebd88ede851ed4dd8..a2bf815d0ddf5a5bedbe2d2e1052190f971f1dc7 100644 --- a/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h +++ b/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h @@ -112,11 +112,11 @@ private: void BuildLamdaWeights(); double absor_sphere(double &twoth, double &wl); void scale_init(const Geometry::IDetector &det, - Geometry::Instrument_const_sptr inst, double &L2, + const Geometry::Instrument_const_sptr &inst, double &L2, double &depth, double &pathlength, std::string &bankName); void scale_exec(std::string &bankName, double &lambda, double &depth, - Geometry::Instrument_const_sptr inst, double &pathlength, - double &value); + const Geometry::Instrument_const_sptr &inst, + double &pathlength, double &value); double m_smu; ///< linear scattering coefficient in 1/cm double m_amu; ///< linear absoprtion coefficient in 1/cm diff --git a/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h b/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h index 8aef4a4dbb9a36d1cbea07aa867b4ab33066dc5c..8743887900901e9cab780c0c3e319661a67dcab5 100644 --- a/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h @@ -45,7 +45,7 @@ private: void exec() override; void integrate(); void integrateEvent(); - int findPixelID(std::string bankName, int col, int row); + int findPixelID(const std::string &bankName, int col, int row); void removeEdgePeaks(Mantid::DataObjects::PeaksWorkspace &peakWS); void sizeBanks(const std::string &bankName, int &nCols, int &nRows); Geometry::Instrument_const_sptr inst; diff --git a/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h b/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h index 4a8becae3d7f5f26e4b21a8f487da3b61af3db8f..f1eca3a25e337651c35edb51d7fb312974dcb2ac 100644 --- a/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h +++ b/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h @@ -49,8 +49,9 @@ class MANTID_CRYSTAL_DLL ConnectedComponentLabeling { public: /// Constructor - ConnectedComponentLabeling(const size_t &startId = 1, - const boost::optional<int> nThreads = boost::none); + ConnectedComponentLabeling( + const size_t &startId = 1, + const boost::optional<int> &nThreads = boost::none); /// Getter for the start label id size_t getStartLabelId() const; @@ -79,7 +80,7 @@ private: /// Calculate the disjoint element tree across the image. ConnectedComponentMappingTypes::ClusterMap - calculateDisjointTree(Mantid::API::IMDHistoWorkspace_sptr ws, + calculateDisjointTree(const Mantid::API::IMDHistoWorkspace_sptr &ws, BackgroundStrategy *const baseStrategy, Mantid::API::Progress &progress) const; diff --git a/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h index 632130b4b9287a240c839200c6b47136b3203c0f..9fe6c3a4ba0c7ec81a274ef36d4b15c751843f33 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h @@ -96,7 +96,7 @@ private: /// Check what x units this workspace has FindSXPeaksHelper::XAxisUnit getWorkspaceXAxisUnit( - Mantid::API::MatrixWorkspace_const_sptr workspace) const; + const Mantid::API::MatrixWorkspace_const_sptr &workspace) const; /// The value in X to start the search from double m_MinRange; diff --git a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h index 2cb20904b9f2dac28c596c1d47e1f34c569d00f1..1698015e4c99d208f0af9536a9e0c1d0e81a0a5b 100644 --- a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h @@ -99,10 +99,10 @@ public: std::set<index> s1; std::set<index> s2; for (it1 = _hkls.begin(); it1 != _hkls.end(); - it1++) // All possible vectors for hkl on current instance + ++it1) // All possible vectors for hkl on current instance { for (it2 = rhs._hkls.begin(); it2 != rhs._hkls.end(); - it2++) // All possible vectors for hkl on other + ++it2) // All possible vectors for hkl on other { const index &index1 = *it1; const index &index2 = *it2; diff --git a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h index 59da17f824f782bbc22dc69332d39a92b3812fc3..4d12afaf42927217f7f374608967d6ff83d2d576 100644 --- a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h +++ b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h @@ -271,14 +271,14 @@ private: void SetUpData(API::MatrixWorkspace_sptr &Data, API::MatrixWorkspace_const_sptr const &inpWkSpace, - boost::shared_ptr<Geometry::IComponent> comp, + const boost::shared_ptr<Geometry::IComponent> &comp, const int chanMin, const int chanMax, double CentX, double CentY, Kernel::V3D &CentNghbr, double &neighborRadius, // from CentDet double Radius, std::string &spec_idList); - bool getNeighborPixIDs(boost::shared_ptr<Geometry::IComponent> comp, + bool getNeighborPixIDs(const boost::shared_ptr<Geometry::IComponent> &comp, Kernel::V3D &Center, double &Radius, int *&ArryofID); int CalculateTimeChannelSpan(Geometry::IPeak const &peak, const double dQ, diff --git a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h index c76fdde23948148b43cdbd12400e193bf48cec0a..a98c1ce1e658346f6694d23c61016c9396d3fb76 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h @@ -61,16 +61,16 @@ private: void exec() override; /// Reads first line of peaks file and returns first word of next line - std::string readHeader(Mantid::DataObjects::PeaksWorkspace_sptr outWS, + std::string readHeader(const Mantid::DataObjects::PeaksWorkspace_sptr &outWS, std::ifstream &in, double &T0); /// Read a single peak from peaks file - DataObjects::Peak readPeak(DataObjects::PeaksWorkspace_sptr outWS, + DataObjects::Peak readPeak(const DataObjects::PeaksWorkspace_sptr &outWS, std::string &lastStr, std::ifstream &in, int &seqNum, std::string bankName, double qSign); - int findPixelID(Geometry::Instrument_const_sptr inst, std::string bankName, - int col, int row); + int findPixelID(const Geometry::Instrument_const_sptr &inst, + const std::string &bankName, int col, int row); /// Read the header of a peak block section, returns first word of next line std::string readPeakBlockHeader(std::string lastStr, std::ifstream &in, @@ -78,20 +78,20 @@ private: double &phi, double &omega, double &monCount); /// Append peaks from given file to given workspace - void appendFile(Mantid::DataObjects::PeaksWorkspace_sptr outWS, - std::string filename); + void appendFile(const Mantid::DataObjects::PeaksWorkspace_sptr &outWS, + const std::string &filename); /// Compare number of peaks in given file to given workspace /// Throws std::length_error on mismatch - void checkNumberPeaks(Mantid::DataObjects::PeaksWorkspace_sptr outWS, - std::string filename); + void checkNumberPeaks(const Mantid::DataObjects::PeaksWorkspace_sptr &outWS, + const std::string &filename); /// Local cache of bank IComponents used in file std::map<std::string, boost::shared_ptr<const Geometry::IComponent>> m_banks; /// Retrieve cached bank (or load and cache for next time) boost::shared_ptr<const Geometry::IComponent> getCachedBankByName( - std::string bankname, + const std::string &bankname, const boost::shared_ptr<const Geometry::Instrument> &inst); }; diff --git a/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h index 5528d979322150004dcad129d052e1af7ac1272c..74a48aa5d575dadbae4cf83dc061f683c0d20698 100644 --- a/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h @@ -48,11 +48,11 @@ private: void init() override; void exec() override; std::size_t getWkspIndex(const detid2index_map &pixel_to_wi, - Geometry::IComponent_const_sptr comp, const int x, - const int y); + const Geometry::IComponent_const_sptr &comp, + const int x, const int y); void getTofRange(double &tofMin, double &tofMax, const double tofPeak, const HistogramData::HistogramX &tof); - int findPixelID(std::string bankName, int col, int row); + int findPixelID(const std::string &bankName, int col, int row); /// Read in all the input parameters void retrieveProperties(); diff --git a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h index 04a1acf43812914aef27219968773963ccd4212a..2bdf5f3d66249a07a264b36b13fde81b7671a79a 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakHKLErrors.h @@ -67,13 +67,15 @@ public: * @return The new peak with the new instrument( adjusted with the *parameters) and time adjusted. */ - static DataObjects::Peak createNewPeak(const Geometry::IPeak &peak_old, - Geometry::Instrument_sptr instrNew, - double T0, double L0); + static DataObjects::Peak + createNewPeak(const Geometry::IPeak &peak_old, + const Geometry::Instrument_sptr &instrNew, double T0, + double L0); - static void cLone(boost::shared_ptr<Geometry::ParameterMap> &pmap, - boost::shared_ptr<const Geometry::IComponent> component, - boost::shared_ptr<const Geometry::ParameterMap> &pmapSv); + static void + cLone(boost::shared_ptr<Geometry::ParameterMap> &pmap, + const boost::shared_ptr<const Geometry::IComponent> &component, + boost::shared_ptr<const Geometry::ParameterMap> &pmapSv); void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks, const std::string &OptRuns, @@ -87,7 +89,7 @@ public: char axis); boost::shared_ptr<Geometry::Instrument> - getNewInstrument(DataObjects::PeaksWorkspace_sptr Peaks) const; + getNewInstrument(const DataObjects::PeaksWorkspace_sptr &Peaks) const; std::vector<std::string> getAttributeNames() const override { return {"OptRuns", "PeakWorkspaceName"}; diff --git a/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h b/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h index 23a6d3a115a0828fce87866319301e52d7386adb..23df95e6d247e3563d872693e27c4d3f93de56d3 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h @@ -48,8 +48,9 @@ private: void fitSpectra(const int s, double TOFPeakd, double &I, double &sigI); /// Read in all the input parameters void retrieveProperties(); - int fitneighbours(int ipeak, std::string det_name, int x0, int y0, int idet, - double qspan, DataObjects::PeaksWorkspace_sptr &Peaks, + int fitneighbours(int ipeak, const std::string &det_name, int x0, int y0, + int idet, double qspan, + DataObjects::PeaksWorkspace_sptr &Peaks, const detid2index_map &pixel_to_wi); bool m_IC = false; ///< Ikeida Carpenter fit of TOF diff --git a/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h b/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h index f9d21ad88a2cc758d584aec64a7e8f7d2208fc36..b02fd282c7118ba1b044e6b2e4d310cf95ff88cf 100644 --- a/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h +++ b/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h @@ -48,19 +48,20 @@ public: private: void saveIsawDetCal(boost::shared_ptr<Geometry::Instrument> &instrument, boost::container::flat_set<std::string> &AllBankName, - double T0, std::string filename); + double T0, const std::string &filename); /// Function to calculate U - void findU(DataObjects::PeaksWorkspace_sptr peaksWs); + void findU(const DataObjects::PeaksWorkspace_sptr &peaksWs); /// save workspaces - void saveNexus(std::string outputFile, API::MatrixWorkspace_sptr outputWS); + void saveNexus(const std::string &outputFile, + const API::MatrixWorkspace_sptr &outputWS); /// Function to optimize L1 - void findL1(int nPeaks, DataObjects::PeaksWorkspace_sptr peaksWs); + void findL1(int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs); /// Function to optimize L2 void findL2(boost::container::flat_set<std::string> MyBankNames, - DataObjects::PeaksWorkspace_sptr peaksWs); + const DataObjects::PeaksWorkspace_sptr &peaksWs); /// Function to optimize T0 - void findT0(int nPeaks, DataObjects::PeaksWorkspace_sptr peaksWs); + void findT0(int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs); void exec() override; diff --git a/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h b/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h index cba356c85889b3c5e9671382a70c9c792aa19a59..2419d33d087c92f0a57c832cfa3948da34aa9444 100644 --- a/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h +++ b/Framework/Crystal/inc/MantidCrystal/SCDPanelErrors.h @@ -44,7 +44,8 @@ public: /// Move detectors with parameters void moveDetector(double x, double y, double z, double rotx, double roty, double rotz, double scalex, double scaley, - std::string detname, API::Workspace_sptr inputW) const; + std::string detname, + const API::Workspace_sptr &inputW) const; private: /// Call the appropriate load function diff --git a/Framework/Crystal/inc/MantidCrystal/SaveHKL.h b/Framework/Crystal/inc/MantidCrystal/SaveHKL.h index 411eeeda179bc3c16084edb8e0625b7ccc6a561e..cd708f0c4e04e29fd017aafec80d0871fe98ccf7 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveHKL.h @@ -49,7 +49,7 @@ private: double spectrumCalc(double TOF, int iSpec, std::vector<std::vector<double>> time, std::vector<std::vector<double>> spectra, size_t id); - void sizeBanks(std::string bankName, int &nCols, int &nRows); + void sizeBanks(const std::string &bankName, int &nCols, int &nRows); DataObjects::PeaksWorkspace_sptr m_ws; double m_smu = 0.0; // in 1/cm diff --git a/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h b/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h index d3c853b43cd8d8c9512453d79924a9d5cfc907d6..9e0bad59d5d7d9a636a5b750ed4849b8acd379e9 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h @@ -48,10 +48,10 @@ private: /// Run the algorithm void exec() override; /// find position for rectangular and non-rectangular - Kernel::V3D findPixelPos(std::string bankName, int col, int row); - void sizeBanks(std::string bankName, int &NCOLS, int &NROWS, double &xsize, - double &ysize); - bool bankMasked(Geometry::IComponent_const_sptr parent, + Kernel::V3D findPixelPos(const std::string &bankName, int col, int row); + void sizeBanks(const std::string &bankName, int &NCOLS, int &NROWS, + double &xsize, double &ysize); + bool bankMasked(const Geometry::IComponent_const_sptr &parent, const Geometry::DetectorInfo &detectorInfo); void writeOffsets(std::ofstream &out, double qSign, std::vector<double> offset); diff --git a/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h b/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h index 9d2885ae95f6e4ff58f52f7ac0a9c26d1d7ae82a..b84323bcaa1fe1a9be295fd31d22b251781d7584 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveLauenorm.h @@ -44,7 +44,7 @@ private: void exec() override; DataObjects::PeaksWorkspace_sptr ws; - void sizeBanks(std::string bankName, int &nCols, int &nRows); + void sizeBanks(const std::string &bankName, int &nCols, int &nRows); const std::vector<std::string> m_typeList{ "TRICLINIC", "MONOCLINIC", "ORTHORHOMBIC", "TETRAGONAL", diff --git a/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h b/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h index 43799f83cb34bdaca13275bc09c62a84aebca80b..274a92a1757f93be9912c3a00fe57fd43730893b 100644 --- a/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h +++ b/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h @@ -48,13 +48,13 @@ private: static const std::string QSampleOption(); static const std::string HKLOption(); bool writeCoordinatesToMDEventWorkspace( - Mantid::API::Workspace_sptr inWS, + const Mantid::API::Workspace_sptr &inWS, Mantid::Kernel::SpecialCoordinateSystem coordinateSystem); bool writeCoordinatesToMDHistoWorkspace( - Mantid::API::Workspace_sptr inWS, + const Mantid::API::Workspace_sptr &inWS, Mantid::Kernel::SpecialCoordinateSystem coordinateSystem); bool writeCoordinatesToPeaksWorkspace( - Mantid::API::Workspace_sptr inWS, + const Mantid::API::Workspace_sptr &inWS, Mantid::Kernel::SpecialCoordinateSystem coordinateSystem); }; diff --git a/Framework/Crystal/inc/MantidCrystal/SortHKL.h b/Framework/Crystal/inc/MantidCrystal/SortHKL.h index 1a60a9a270ee9902e0d33cd93b29758d5ae30581..afd51cc4fb28ff2dbf337855f8177ababf84e3c0 100644 --- a/Framework/Crystal/inc/MantidCrystal/SortHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/SortHKL.h @@ -78,7 +78,8 @@ private: DataObjects::PeaksWorkspace_sptr getOutputPeaksWorkspace( const DataObjects::PeaksWorkspace_sptr &inputPeaksWorkspace) const; - void sortOutputPeaksByHKL(API::IPeaksWorkspace_sptr outputPeaksWorkspace); + void + sortOutputPeaksByHKL(const API::IPeaksWorkspace_sptr &outputPeaksWorkspace); /// Point Groups possible std::vector<Mantid::Geometry::PointGroup_sptr> m_pointGroups; diff --git a/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h index 8d2d3667c092605aa1dec4673cbb6ededa7c29ea..061d0bd973eb111d739c254c34c01dc7d95e327b 100644 --- a/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h @@ -49,7 +49,8 @@ private: /// Run the algorithm void exec() override; /// Runs SortHKL on workspace - void doSortHKL(Mantid::API::Workspace_sptr ws, std::string runName); + void doSortHKL(const Mantid::API::Workspace_sptr &ws, + const std::string &runName); DataObjects::PeaksWorkspace_sptr ws; }; diff --git a/Framework/Crystal/src/AnvredCorrection.cpp b/Framework/Crystal/src/AnvredCorrection.cpp index 6b788c91761bce06ca7b98ae834ef7726bb9c5d1..56bfbe9f06367294df4b53777dc108359239c04b 100644 --- a/Framework/Crystal/src/AnvredCorrection.cpp +++ b/Framework/Crystal/src/AnvredCorrection.cpp @@ -522,7 +522,7 @@ void AnvredCorrection::BuildLamdaWeights() { } void AnvredCorrection::scale_init(const IDetector &det, - Instrument_const_sptr inst, double &L2, + const Instrument_const_sptr &inst, double &L2, double &depth, double &pathlength, std::string &bankName) { bankName = det.getParent()->getParent()->getName(); @@ -542,7 +542,8 @@ void AnvredCorrection::scale_init(const IDetector &det, } void AnvredCorrection::scale_exec(std::string &bankName, double &lambda, - double &depth, Instrument_const_sptr inst, + double &depth, + const Instrument_const_sptr &inst, double &pathlength, double &value) { // correct for the slant path throught the scintillator glass double mu = (9.614 * lambda) + 0.266; // mu for GS20 glass diff --git a/Framework/Crystal/src/CentroidPeaks.cpp b/Framework/Crystal/src/CentroidPeaks.cpp index 29c1b15f547420792bf7c171203fd8eb105466ec..a6dad7263f33b1ff870d6fb618b62a2756a51159 100644 --- a/Framework/Crystal/src/CentroidPeaks.cpp +++ b/Framework/Crystal/src/CentroidPeaks.cpp @@ -323,7 +323,7 @@ void CentroidPeaks::exec() { } } -int CentroidPeaks::findPixelID(std::string bankName, int col, int row) { +int CentroidPeaks::findPixelID(const std::string &bankName, int col, int row) { boost::shared_ptr<const IComponent> parent = inst->getComponentByName(bankName); if (parent->type() == "RectangularDetector") { diff --git a/Framework/Crystal/src/ConnectedComponentLabeling.cpp b/Framework/Crystal/src/ConnectedComponentLabeling.cpp index 46894fbf7fcf4e1ea3ddf18de0b3cc6931ae45c5..04ed2e230a755c6770df6477b5f7a48b77d1d678 100644 --- a/Framework/Crystal/src/ConnectedComponentLabeling.cpp +++ b/Framework/Crystal/src/ConnectedComponentLabeling.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidCrystal/ConnectedComponentLabeling.h" #include "MantidAPI/FrameworkManager.h" @@ -226,7 +228,7 @@ void memoryCheck(size_t nPoints) { * @param nThreads : Optional argument of number of threads to use. */ ConnectedComponentLabeling::ConnectedComponentLabeling( - const size_t &startId, const boost::optional<int> nThreads) + const size_t &startId, const boost::optional<int> &nThreads) : m_startId(startId), m_nThreads(nThreads) { if (m_nThreads.is_initialized() && m_nThreads.get() < 0) { throw std::invalid_argument( @@ -278,7 +280,7 @@ int ConnectedComponentLabeling::getNThreads() const { * @return : Map of label ids to clusters. */ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( - IMDHistoWorkspace_sptr ws, BackgroundStrategy *const baseStrategy, + const IMDHistoWorkspace_sptr &ws, BackgroundStrategy *const baseStrategy, Progress &progress) const { std::map<size_t, boost::shared_ptr<ICluster>> clusterMap; VecElements neighbourElements(ws->getNPoints()); @@ -407,7 +409,8 @@ boost::shared_ptr<Mantid::API::IMDHistoWorkspace> ConnectedComponentLabeling::execute(IMDHistoWorkspace_sptr ws, BackgroundStrategy *const strategy, Progress &progress) const { - ClusterTuple result = executeAndFetchClusters(ws, strategy, progress); + ClusterTuple result = + executeAndFetchClusters(std::move(ws), strategy, progress); IMDHistoWorkspace_sptr outWS = result.get<0>(); // Get the workspace, but discard cluster objects. return outWS; diff --git a/Framework/Crystal/src/FindClusterFaces.cpp b/Framework/Crystal/src/FindClusterFaces.cpp index 9ee0817ae63f7037b61c3b8f105fdee99b16bac7..97fddf346f6e3c4f6699cdb3758a26235960f6e4 100644 --- a/Framework/Crystal/src/FindClusterFaces.cpp +++ b/Framework/Crystal/src/FindClusterFaces.cpp @@ -43,7 +43,7 @@ using OptionalLabelPeakIndexMap = boost::optional<LabelMap>; */ OptionalLabelPeakIndexMap createOptionalLabelFilter(size_t dimensionality, int emptyLabelId, - IPeaksWorkspace_sptr filterWorkspace, + const IPeaksWorkspace_sptr &filterWorkspace, IMDHistoWorkspace_sptr &clusterImage) { OptionalLabelPeakIndexMap optionalAllowedLabels; diff --git a/Framework/Crystal/src/FindSXPeaks.cpp b/Framework/Crystal/src/FindSXPeaks.cpp index 301be49ce7449d35a61a8ce5ae9f5a00cb155e97..c478ebbd9d5678f78e08a848d2a8ea2d192c4743 100644 --- a/Framework/Crystal/src/FindSXPeaks.cpp +++ b/Framework/Crystal/src/FindSXPeaks.cpp @@ -369,8 +369,8 @@ void FindSXPeaks::reducePeakList(const peakvector &pcv, Progress &progress) { * @param workspace :: the workspace to check x-axis units on * @return enum of type XAxisUnit with the value of TOF or DSPACING */ -XAxisUnit -FindSXPeaks::getWorkspaceXAxisUnit(MatrixWorkspace_const_sptr workspace) const { +XAxisUnit FindSXPeaks::getWorkspaceXAxisUnit( + const MatrixWorkspace_const_sptr &workspace) const { const auto xAxis = workspace->getAxis(0); const auto unitID = xAxis->unit()->unitID(); diff --git a/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp b/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp index 7cbe615d2f9b0e36060e99216d212cc8458e4cf0..4d9444bffeaf18dcaab73dcf945e89051a590007 100644 --- a/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp +++ b/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp @@ -108,9 +108,9 @@ void FindUBUsingIndexedPeaks::exec() { { // from the full list of peaks, and q_vectors.clear(); // save the UB in the sample q_vectors.reserve(n_peaks); - for (const auto &peak : peaks) { - q_vectors.emplace_back(peak.getQSampleFrame()); - } + + std::transform(peaks.begin(), peaks.end(), std::back_inserter(q_vectors), + [](const auto &peak) { return peak.getQSampleFrame(); }); int num_indexed = IndexingUtils::NumberIndexed(UB, q_vectors, tolerance); int sate_indexed = 0; diff --git a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp index a210b733ff1706fd1edf3cff94c8c3008f87a5e1..e9d2bb3c35c511c4e69a89e76b02c3e0ef174c1f 100644 --- a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp +++ b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp @@ -26,6 +26,7 @@ #include "MantidHistogramData/BinEdges.h" #include <boost/math/special_functions/round.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -657,7 +658,7 @@ void IntegratePeakTimeSlices::exec() { * the center may be included. */ bool IntegratePeakTimeSlices::getNeighborPixIDs( - boost::shared_ptr<Geometry::IComponent> comp, Kernel::V3D &Center, + const boost::shared_ptr<Geometry::IComponent> &comp, Kernel::V3D &Center, double &Radius, int *&ArryofID) { int N = ArryofID[1]; @@ -1417,7 +1418,7 @@ void DataModeHandler::setHeightHalfWidthInfo( */ void IntegratePeakTimeSlices::SetUpData( MatrixWorkspace_sptr &Data, MatrixWorkspace_const_sptr const &inpWkSpace, - boost::shared_ptr<Geometry::IComponent> comp, const int chanMin, + const boost::shared_ptr<Geometry::IComponent> &comp, const int chanMin, const int chanMax, double CentX, double CentY, Kernel::V3D &CentNghbr, double &neighborRadius, // from CentDetspec double Radius, string &spec_idList) { @@ -1468,7 +1469,7 @@ void IntegratePeakTimeSlices::SetUpData( m_NeighborIDs[1] = 2; neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius; CentNghbr = CentPos; - getNeighborPixIDs(comp, CentPos, neighborRadius, m_NeighborIDs); + getNeighborPixIDs(std::move(comp), CentPos, neighborRadius, m_NeighborIDs); } else // big enough neighborhood so neighborRadius -= DD; @@ -2526,7 +2527,8 @@ int IntegratePeakTimeSlices::UpdateOutputWS( m_AttributeValues->StatBaseVals(INCol) - 1; TabWS->getRef<double>(std::string("TotIntensityError"), TableRow) = SQRT(m_AttributeValues->StatBaseVals(IVariance)); - TabWS->getRef<string>(std::string("SpecIDs"), TableRow) = spec_idList; + TabWS->getRef<string>(std::string("SpecIDs"), TableRow) = + std::move(spec_idList); return newRowIndex; } diff --git a/Framework/Crystal/src/LoadIsawPeaks.cpp b/Framework/Crystal/src/LoadIsawPeaks.cpp index 4ce06b8fed3cef15135779a5355711eed86d3d73..dce2c0b5ff8dfe9e0a6cbe3422c34d0f6d8094cf 100644 --- a/Framework/Crystal/src/LoadIsawPeaks.cpp +++ b/Framework/Crystal/src/LoadIsawPeaks.cpp @@ -21,6 +21,7 @@ #include "MantidKernel/Strings.h" #include "MantidKernel/Unit.h" #include <boost/algorithm/string/trim.hpp> +#include <utility> using Mantid::Kernel::Strings::getWord; using Mantid::Kernel::Strings::readToEndOfLine; @@ -67,8 +68,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const { throw std::logic_error(std::string("No Version for Peaks file")); getWord(in, false); // tag - // cppcheck-suppress unreadVariable - std::string C_Facility = getWord(in, false); + getWord(in, false); // C_Facility getWord(in, false); // tag std::string C_Instrument = getWord(in, false); @@ -125,7 +125,7 @@ void LoadIsawPeaks::exec() { * @param T0 :: Time offset * @return the first word on the next line */ -std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, +std::string LoadIsawPeaks::readHeader(const PeaksWorkspace_sptr &outWS, std::ifstream &in, double &T0) { std::string tag; std::string r = getWord(in, false); @@ -142,8 +142,7 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, throw std::logic_error(std::string("No Version for Peaks file")); getWord(in, false); // tag - // cppcheck-suppress unreadVariable - std::string C_Facility = getWord(in, false); + getWord(in, false); // C_Facility getWord(in, false); // tag std::string C_Instrument = getWord(in, false); @@ -262,7 +261,7 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, * @param qSign :: For inelastic this is 1; for crystallography this is -1 * @return the Peak the Peak object created */ -DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, +DataObjects::Peak LoadIsawPeaks::readPeak(const PeaksWorkspace_sptr &outWS, std::string &lastStr, std::ifstream &in, int &seqNum, std::string bankName, double qSign) { @@ -341,8 +340,8 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, if (!inst) throw std::runtime_error("No instrument in PeaksWorkspace!"); - int pixelID = - findPixelID(inst, bankName, static_cast<int>(col), static_cast<int>(row)); + int pixelID = findPixelID(inst, std::move(bankName), static_cast<int>(col), + static_cast<int>(row)); // Create the peak object Peak peak(outWS->getInstrument(), pixelID, wl); @@ -358,10 +357,10 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, } //---------------------------------------------------------------------------------------------- -int LoadIsawPeaks::findPixelID(Instrument_const_sptr inst, std::string bankName, - int col, int row) { +int LoadIsawPeaks::findPixelID(const Instrument_const_sptr &inst, + const std::string &bankName, int col, int row) { boost::shared_ptr<const IComponent> parent = - getCachedBankByName(bankName, inst); + getCachedBankByName(std::move(bankName), inst); if (!parent) return -1; // peak not in any detector. @@ -406,7 +405,7 @@ std::string LoadIsawPeaks::readPeakBlockHeader(std::string lastStr, int &detName, double &chi, double &phi, double &omega, double &monCount) { - std::string s = lastStr; + std::string s = std::move(lastStr); if (s.length() < 1 && in.good()) // blank line { @@ -447,8 +446,8 @@ std::string LoadIsawPeaks::readPeakBlockHeader(std::string lastStr, * @param outWS :: the workspace in which to place the information * @param filename :: path to the .peaks file */ -void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS, - std::string filename) { +void LoadIsawPeaks::appendFile(const PeaksWorkspace_sptr &outWS, + const std::string &filename) { // HKL's are flipped by -1 because of the internal Q convention // unless Crystallography convention double qSign = -1.0; @@ -566,8 +565,8 @@ void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS, * @param outWS :: the workspace in which to place the information * @param filename :: path to the .peaks file */ -void LoadIsawPeaks::checkNumberPeaks(PeaksWorkspace_sptr outWS, - std::string filename) { +void LoadIsawPeaks::checkNumberPeaks(const PeaksWorkspace_sptr &outWS, + const std::string &filename) { // Open the file std::ifstream in(filename.c_str()); @@ -603,7 +602,7 @@ void LoadIsawPeaks::checkNumberPeaks(PeaksWorkspace_sptr outWS, *found) */ boost::shared_ptr<const IComponent> LoadIsawPeaks::getCachedBankByName( - std::string bankname, + const std::string &bankname, const boost::shared_ptr<const Geometry::Instrument> &inst) { if (m_banks.count(bankname) == 0) m_banks[bankname] = inst->getComponentByName(bankname); diff --git a/Framework/Crystal/src/LoadIsawSpectrum.cpp b/Framework/Crystal/src/LoadIsawSpectrum.cpp index 3e24646201ae706d86547ae61b2887bb5af42c9a..9263a6de4d3bcf7f6c75369dfc5a3839b2f6fad1 100644 --- a/Framework/Crystal/src/LoadIsawSpectrum.cpp +++ b/Framework/Crystal/src/LoadIsawSpectrum.cpp @@ -56,7 +56,6 @@ void LoadIsawSpectrum::exec() { const V3D pos = inst->getSource()->getPos() - samplePos; double l1 = pos.norm(); - std::vector<double> spec(11); std::string STRING; std::ifstream infile; std::string spectraFile = getPropertyValue("SpectraFile"); diff --git a/Framework/Crystal/src/MaskPeaksWorkspace.cpp b/Framework/Crystal/src/MaskPeaksWorkspace.cpp index 36bec054374a986571e93b0589069f1d1cdc0302..676c6abeb362528fd005d3ef84ce4008831d7855 100644 --- a/Framework/Crystal/src/MaskPeaksWorkspace.cpp +++ b/Framework/Crystal/src/MaskPeaksWorkspace.cpp @@ -200,9 +200,10 @@ void MaskPeaksWorkspace::retrieveProperties() { } } -size_t MaskPeaksWorkspace::getWkspIndex(const detid2index_map &pixel_to_wi, - Geometry::IComponent_const_sptr comp, - const int x, const int y) { +size_t +MaskPeaksWorkspace::getWkspIndex(const detid2index_map &pixel_to_wi, + const Geometry::IComponent_const_sptr &comp, + const int x, const int y) { Geometry::RectangularDetector_const_sptr det = boost::dynamic_pointer_cast<const Geometry::RectangularDetector>(comp); if (det) { @@ -270,7 +271,8 @@ void MaskPeaksWorkspace::getTofRange(double &tofMin, double &tofMax, tofMax = tofPeak + m_tofMax; } } -int MaskPeaksWorkspace::findPixelID(std::string bankName, int col, int row) { +int MaskPeaksWorkspace::findPixelID(const std::string &bankName, int col, + int row) { Geometry::Instrument_const_sptr Iptr = m_inputW->getInstrument(); boost::shared_ptr<const IComponent> parent = Iptr->getComponentByName(bankName); diff --git a/Framework/Crystal/src/PeakAlgorithmHelpers.cpp b/Framework/Crystal/src/PeakAlgorithmHelpers.cpp index 493f447ec2acf7acbbd49af508fd35849c2e8c38..684e7601304f58702079624c55c1ecc7c4ca30a7 100644 --- a/Framework/Crystal/src/PeakAlgorithmHelpers.cpp +++ b/Framework/Crystal/src/PeakAlgorithmHelpers.cpp @@ -200,12 +200,13 @@ generateOffsetVectors(const std::vector<double> &hOffsets, std::vector<MNPOffset> offsets; for (double hOffset : hOffsets) { for (double kOffset : kOffsets) { - for (double lOffset : lOffsets) { - // mnp = 0, 0, 0 as - // it's not quite clear how to interpret them as mnp indices - offsets.emplace_back( - std::make_tuple(0, 0, 0, V3D(hOffset, kOffset, lOffset))); - } + std::transform( + lOffsets.begin(), lOffsets.end(), std::back_inserter(offsets), + [&hOffset, &kOffset](double lOffset) { + // it's not quite clear how to interpret them as mnp + // indices so set to 0, 0, 0 + return std::make_tuple(0, 0, 0, V3D(hOffset, kOffset, lOffset)); + }); } } return offsets; diff --git a/Framework/Crystal/src/PeakBackground.cpp b/Framework/Crystal/src/PeakBackground.cpp index 7d5ad73b744303d9a7634270675dd2f67c7db93c..e1415c17a77e74badd4ce38bc8875f0a2c1cfd79 100644 --- a/Framework/Crystal/src/PeakBackground.cpp +++ b/Framework/Crystal/src/PeakBackground.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidCrystal/PeakBackground.h" +#include <utility> + #include "MantidAPI/IPeaksWorkspace.h" +#include "MantidCrystal/PeakBackground.h" #include "MantidGeometry/Crystal/IPeak.h" using namespace Mantid::API; @@ -24,7 +26,7 @@ PeakBackground::PeakBackground(IPeaksWorkspace_const_sptr peaksWS, const Mantid::API::MDNormalization normalisation, const SpecialCoordinateSystem coordinates) : HardThresholdBackground(thresholdSignal, normalisation), - m_peaksWS(peaksWS), m_radiusEstimate(radiusEstimate), + m_peaksWS(std::move(peaksWS)), m_radiusEstimate(radiusEstimate), m_mdCoordinates(coordinates) { if (m_mdCoordinates == QLab) { diff --git a/Framework/Crystal/src/PeakHKLErrors.cpp b/Framework/Crystal/src/PeakHKLErrors.cpp index 2a6807dfdd0490dd0f5a3da38eb446509462104e..8d4e7eebca125e46dca243481a149e6048c35cc0 100644 --- a/Framework/Crystal/src/PeakHKLErrors.cpp +++ b/Framework/Crystal/src/PeakHKLErrors.cpp @@ -117,7 +117,7 @@ void PeakHKLErrors::setUpOptRuns() { */ void PeakHKLErrors::cLone( boost::shared_ptr<Geometry::ParameterMap> &pmap, - boost::shared_ptr<const Geometry::IComponent> component, + const boost::shared_ptr<const Geometry::IComponent> &component, boost::shared_ptr<const Geometry::ParameterMap> &pmapSv) { if (!component) return; @@ -187,7 +187,7 @@ void PeakHKLErrors::cLone( * NOTE: All the peaks in the PeaksWorkspace must use the same instrument. */ boost::shared_ptr<Geometry::Instrument> -PeakHKLErrors::getNewInstrument(PeaksWorkspace_sptr Peaks) const { +PeakHKLErrors::getNewInstrument(const PeaksWorkspace_sptr &Peaks) const { Geometry::Instrument_const_sptr instSave = Peaks->getPeak(0).getInstrument(); auto pmap = boost::make_shared<Geometry::ParameterMap>(); @@ -643,8 +643,8 @@ void PeakHKLErrors::functionDeriv1D(Jacobian *out, const double *xValues, } Peak PeakHKLErrors::createNewPeak(const Geometry::IPeak &peak_old, - Geometry::Instrument_sptr instrNew, double T0, - double L0) { + const Geometry::Instrument_sptr &instrNew, + double T0, double L0) { Geometry::Instrument_const_sptr inst = peak_old.getInstrument(); if (inst->getComponentID() != instrNew->getComponentID()) { g_log.error("All peaks must have the same instrument"); diff --git a/Framework/Crystal/src/PeakIntegration.cpp b/Framework/Crystal/src/PeakIntegration.cpp index cae56ddc0deb6b269df30b2d04920961324458ea..da992cb6dbfe2183cab67edff372121513647510 100644 --- a/Framework/Crystal/src/PeakIntegration.cpp +++ b/Framework/Crystal/src/PeakIntegration.cpp @@ -301,8 +301,8 @@ void PeakIntegration::retrieveProperties() { } } -int PeakIntegration::fitneighbours(int ipeak, std::string det_name, int x0, - int y0, int idet, double qspan, +int PeakIntegration::fitneighbours(int ipeak, const std::string &det_name, + int x0, int y0, int idet, double qspan, PeaksWorkspace_sptr &Peaks, const detid2index_map &pixel_to_wi) { UNUSED_ARG(ipeak); diff --git a/Framework/Crystal/src/SCDCalibratePanels.cpp b/Framework/Crystal/src/SCDCalibratePanels.cpp index 7eefa117a69a893c8ac810b4ff8711f56141ee51..72bdeb27f5b57cfdd9746e477579ee47aa2b7126 100644 --- a/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -280,16 +280,16 @@ void SCDCalibratePanels::exec() { saveNexus(tofFilename, TofWksp); } -void SCDCalibratePanels::saveNexus(std::string outputFile, - MatrixWorkspace_sptr outputWS) { +void SCDCalibratePanels::saveNexus(const std::string &outputFile, + const MatrixWorkspace_sptr &outputWS) { IAlgorithm_sptr save = this->createChildAlgorithm("SaveNexus"); save->setProperty("InputWorkspace", outputWS); save->setProperty("FileName", outputFile); save->execute(); } -void SCDCalibratePanels::findL1(int nPeaks, - DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findL1( + int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs) { MatrixWorkspace_sptr L1WS = boost::dynamic_pointer_cast<MatrixWorkspace>( API::WorkspaceFactory::Instance().create("Workspace2D", 1, 3 * nPeaks, 3 * nPeaks)); @@ -329,8 +329,8 @@ void SCDCalibratePanels::findL1(int nPeaks, << fitL1Status << " Chi2overDoF " << chisqL1 << "\n"; } -void SCDCalibratePanels::findT0(int nPeaks, - DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findT0( + int nPeaks, const DataObjects::PeaksWorkspace_sptr &peaksWs) { MatrixWorkspace_sptr T0WS = boost::dynamic_pointer_cast<MatrixWorkspace>( API::WorkspaceFactory::Instance().create("Workspace2D", 1, 3 * nPeaks, 3 * nPeaks)); @@ -385,7 +385,8 @@ void SCDCalibratePanels::findT0(int nPeaks, } } -void SCDCalibratePanels::findU(DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findU( + const DataObjects::PeaksWorkspace_sptr &peaksWs) { IAlgorithm_sptr ub_alg; try { ub_alg = createChildAlgorithm("CalculateUMatrix", -1, -1, false); @@ -442,7 +443,7 @@ void SCDCalibratePanels::findU(DataObjects::PeaksWorkspace_sptr peaksWs) { void SCDCalibratePanels::saveIsawDetCal( boost::shared_ptr<Instrument> &instrument, boost::container::flat_set<string> &AllBankName, double T0, - string filename) { + const string &filename) { // having a filename triggers doing the work if (filename.empty()) return; @@ -633,8 +634,9 @@ void SCDCalibratePanels::saveXmlFile( oss3.flush(); oss3.close(); } -void SCDCalibratePanels::findL2(boost::container::flat_set<string> MyBankNames, - DataObjects::PeaksWorkspace_sptr peaksWs) { +void SCDCalibratePanels::findL2( + boost::container::flat_set<string> MyBankNames, + const DataObjects::PeaksWorkspace_sptr &peaksWs) { bool changeSize = getProperty("ChangePanelSize"); Geometry::Instrument_const_sptr inst = peaksWs->getInstrument(); diff --git a/Framework/Crystal/src/SCDPanelErrors.cpp b/Framework/Crystal/src/SCDPanelErrors.cpp index 7c53a3b8699b55c6c480d13e122920235eb5b9c5..e22beeaeede971ed058ac9319d09721b621b5ce0 100644 --- a/Framework/Crystal/src/SCDPanelErrors.cpp +++ b/Framework/Crystal/src/SCDPanelErrors.cpp @@ -23,6 +23,7 @@ #include <cmath> #include <fstream> #include <sstream> +#include <utility> namespace Mantid { namespace Crystal { @@ -74,7 +75,7 @@ SCDPanelErrors::SCDPanelErrors() : m_setupFinished(false) { void SCDPanelErrors::moveDetector(double x, double y, double z, double rotx, double roty, double rotz, double scalex, double scaley, std::string detname, - Workspace_sptr inputW) const { + const Workspace_sptr &inputW) const { if (detname.compare("none") == 0.0) return; // CORELLI has sixteenpack under bank @@ -340,7 +341,7 @@ void SCDPanelErrors::loadWorkspace(const std::string &wsName) const { * @param ws :: The workspace to load from */ void SCDPanelErrors::loadWorkspace(boost::shared_ptr<API::Workspace> ws) const { - m_workspace = ws; + m_workspace = std::move(ws); m_setupFinished = false; } diff --git a/Framework/Crystal/src/SaveHKL.cpp b/Framework/Crystal/src/SaveHKL.cpp index 03a11e22ca418b43a9f1469511180d1f372b1b0c..c031b73732ebf8e9830976910f4f37bf6be11875 100644 --- a/Framework/Crystal/src/SaveHKL.cpp +++ b/Framework/Crystal/src/SaveHKL.cpp @@ -747,7 +747,7 @@ double SaveHKL::spectrumCalc(double TOF, int iSpec, return spect; } -void SaveHKL::sizeBanks(std::string bankName, int &nCols, int &nRows) { +void SaveHKL::sizeBanks(const std::string &bankName, int &nCols, int &nRows) { if (bankName == "None") return; boost::shared_ptr<const IComponent> parent = diff --git a/Framework/Crystal/src/SaveIsawPeaks.cpp b/Framework/Crystal/src/SaveIsawPeaks.cpp index deed32269bb1f344a758cdf66bce2024cfd04a12..82685646a586135a12c208e0ba9868c20083c7ff 100644 --- a/Framework/Crystal/src/SaveIsawPeaks.cpp +++ b/Framework/Crystal/src/SaveIsawPeaks.cpp @@ -318,7 +318,6 @@ void SaveIsawPeaks::exec() { const int run = runBankMap.first; const auto &bankMap = runBankMap.second; - bankMap_t::iterator bankMap_it; for (const auto &bankIDs : bankMap) { // Start of a new bank. const int bank = bankIDs.first; @@ -461,7 +460,7 @@ void SaveIsawPeaks::exec() { out.close(); } -bool SaveIsawPeaks::bankMasked(IComponent_const_sptr parent, +bool SaveIsawPeaks::bankMasked(const IComponent_const_sptr &parent, const Geometry::DetectorInfo &detectorInfo) { std::vector<Geometry::IComponent_const_sptr> children; auto asmb = @@ -494,7 +493,7 @@ bool SaveIsawPeaks::bankMasked(IComponent_const_sptr parent, return true; } -V3D SaveIsawPeaks::findPixelPos(std::string bankName, int col, int row) { +V3D SaveIsawPeaks::findPixelPos(const std::string &bankName, int col, int row) { auto parent = inst->getComponentByName(bankName); if (parent->type() == "RectangularDetector") { const auto RDet = @@ -524,8 +523,8 @@ V3D SaveIsawPeaks::findPixelPos(std::string bankName, int col, int row) { return first->getPos(); } } -void SaveIsawPeaks::sizeBanks(std::string bankName, int &NCOLS, int &NROWS, - double &xsize, double &ysize) { +void SaveIsawPeaks::sizeBanks(const std::string &bankName, int &NCOLS, + int &NROWS, double &xsize, double &ysize) { if (bankName == "None") return; const auto parent = inst->getComponentByName(bankName); diff --git a/Framework/Crystal/src/SaveLauenorm.cpp b/Framework/Crystal/src/SaveLauenorm.cpp index 0512f5fb3bfd714d73f9607545b3a369b443f42c..1c930b37b47e82bbb130bba2d193b2c50a359d57 100644 --- a/Framework/Crystal/src/SaveLauenorm.cpp +++ b/Framework/Crystal/src/SaveLauenorm.cpp @@ -499,7 +499,8 @@ void SaveLauenorm::exec() { out.flush(); out.close(); } -void SaveLauenorm::sizeBanks(std::string bankName, int &nCols, int &nRows) { +void SaveLauenorm::sizeBanks(const std::string &bankName, int &nCols, + int &nRows) { if (bankName == "None") return; boost::shared_ptr<const IComponent> parent = diff --git a/Framework/Crystal/src/SetSpecialCoordinates.cpp b/Framework/Crystal/src/SetSpecialCoordinates.cpp index ec7453d20440dbcf5e94dad078a783f798bc4c7a..8d661d43fecf6f6fd01882395c8902fe8d012462 100644 --- a/Framework/Crystal/src/SetSpecialCoordinates.cpp +++ b/Framework/Crystal/src/SetSpecialCoordinates.cpp @@ -93,9 +93,9 @@ void SetSpecialCoordinates::init() { } bool SetSpecialCoordinates::writeCoordinatesToMDEventWorkspace( - Workspace_sptr inWS, SpecialCoordinateSystem /*unused*/) { + const Workspace_sptr &inWS, SpecialCoordinateSystem /*unused*/) { bool written = false; - if (auto mdEventWS = boost::dynamic_pointer_cast<IMDEventWorkspace>(inWS)) { + if (boost::dynamic_pointer_cast<IMDEventWorkspace>(inWS)) { g_log.warning("SetSpecialCoordinates: This algorithm cannot set the " "special coordinate system for an MDEvent workspace any " "longer."); @@ -105,9 +105,9 @@ bool SetSpecialCoordinates::writeCoordinatesToMDEventWorkspace( } bool SetSpecialCoordinates::writeCoordinatesToMDHistoWorkspace( - Workspace_sptr inWS, SpecialCoordinateSystem /*unused*/) { + const Workspace_sptr &inWS, SpecialCoordinateSystem /*unused*/) { bool written = false; - if (auto mdHistoWS = boost::dynamic_pointer_cast<IMDHistoWorkspace>(inWS)) { + if (boost::dynamic_pointer_cast<IMDHistoWorkspace>(inWS)) { g_log.warning("SetSpecialCoordinates: This algorithm cannot set the " "special coordinate system for an MDHisto workspace any " "longer."); @@ -117,7 +117,7 @@ bool SetSpecialCoordinates::writeCoordinatesToMDHistoWorkspace( } bool SetSpecialCoordinates::writeCoordinatesToPeaksWorkspace( - Workspace_sptr inWS, SpecialCoordinateSystem coordinateSystem) { + const Workspace_sptr &inWS, SpecialCoordinateSystem coordinateSystem) { bool written = false; if (auto peaksWS = boost::dynamic_pointer_cast<IPeaksWorkspace>(inWS)) { peaksWS->setCoordinateSystem(coordinateSystem); diff --git a/Framework/Crystal/src/SortHKL.cpp b/Framework/Crystal/src/SortHKL.cpp index ead61efa5e63ad9625b9a1afab04df1b2c079f4b..c5d7122c42bcf36284ec6847ae2f79db09ca01de 100644 --- a/Framework/Crystal/src/SortHKL.cpp +++ b/Framework/Crystal/src/SortHKL.cpp @@ -412,7 +412,8 @@ PeaksWorkspace_sptr SortHKL::getOutputPeaksWorkspace( } /// Sorts the peaks in the workspace by H, K and L. -void SortHKL::sortOutputPeaksByHKL(IPeaksWorkspace_sptr outputPeaksWorkspace) { +void SortHKL::sortOutputPeaksByHKL( + const IPeaksWorkspace_sptr &outputPeaksWorkspace) { // Sort by HKL std::vector<std::pair<std::string, bool>> criteria{ {"H", true}, {"K", true}, {"L", true}}; diff --git a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp index c5f46c9a5e9c0a90bca1e002e557ba1bbc761756..a93bf28a13e12ce7cd7a02ccbee524feda20e719 100644 --- a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp +++ b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp @@ -198,8 +198,8 @@ void StatisticsOfPeaksWorkspace::exec() { * @param ws :: any PeaksWorkspace * @param runName :: string to put in statistics table */ -void StatisticsOfPeaksWorkspace::doSortHKL(Mantid::API::Workspace_sptr ws, - std::string runName) { +void StatisticsOfPeaksWorkspace::doSortHKL( + const Mantid::API::Workspace_sptr &ws, const std::string &runName) { std::string pointGroup = getPropertyValue("PointGroup"); std::string latticeCentering = getPropertyValue("LatticeCentering"); std::string wkspName = getPropertyValue("OutputWorkspace"); diff --git a/Framework/Crystal/test/AnvredCorrectionTest.h b/Framework/Crystal/test/AnvredCorrectionTest.h index 399979d1d8706676e6de43bb712371615a3fe91e..ea03f23516a20d2f64c62d45b65584a9f17f8893 100644 --- a/Framework/Crystal/test/AnvredCorrectionTest.h +++ b/Framework/Crystal/test/AnvredCorrectionTest.h @@ -69,7 +69,7 @@ EventWorkspace_sptr createDiffractionEventWorkspace(int numBanks = 1, return retVal; } -void do_test_events(MatrixWorkspace_sptr workspace, bool ev, +void do_test_events(const MatrixWorkspace_sptr &workspace, bool ev, bool performance = false) { workspace->getAxis(0)->setUnit("Wavelength"); diff --git a/Framework/Crystal/test/CalculateUMatrixTest.h b/Framework/Crystal/test/CalculateUMatrixTest.h index 94648dd3234161b7135752700842239d49376ad5..49ac4859da994b80e4106e548bd12bb066a09ce8 100644 --- a/Framework/Crystal/test/CalculateUMatrixTest.h +++ b/Framework/Crystal/test/CalculateUMatrixTest.h @@ -181,7 +181,7 @@ private: return atan2(-QYUB(H, K, L), -QXUB(H, K, L)); } - void generatePeaks(std::string WSName) { + void generatePeaks(const std::string &WSName) { setupUB(); double Hpeaks[9] = {0, 1, 1, 0, -1, -1, 1, -3, -2}; diff --git a/Framework/Crystal/test/ClusterIntegrationBaseTest.h b/Framework/Crystal/test/ClusterIntegrationBaseTest.h index bb3d0b04dbc32f1ffb788547a54796cb1534b7f7..51331a53e63c47bb8c2b61b481312c5b30a1b4a5 100644 --- a/Framework/Crystal/test/ClusterIntegrationBaseTest.h +++ b/Framework/Crystal/test/ClusterIntegrationBaseTest.h @@ -50,9 +50,9 @@ protected: } // Add a fake peak to an MDEventWorkspace - void add_fake_md_peak(IMDEventWorkspace_sptr mdws, const size_t &nEvents, - const double &h, const double &k, const double &l, - const double &radius) { + void add_fake_md_peak(const IMDEventWorkspace_sptr &mdws, + const size_t &nEvents, const double &h, const double &k, + const double &l, const double &radius) { auto fakeMDEventDataAlg = AlgorithmManager::Instance().createUnmanaged("FakeMDEventData"); fakeMDEventDataAlg->setChild(true); diff --git a/Framework/Crystal/test/FilterPeaksTest.h b/Framework/Crystal/test/FilterPeaksTest.h index b20b55387dcd5a31f838e88b0f49a7b5e1fc6fb2..40bcf59a5d2a3a9dc9f141319f852f56fc4aee3e 100644 --- a/Framework/Crystal/test/FilterPeaksTest.h +++ b/Framework/Crystal/test/FilterPeaksTest.h @@ -39,7 +39,7 @@ private: /* * Helper method to run the algorithm and return the output workspace. */ - IPeaksWorkspace_sptr runAlgorithm(PeaksWorkspace_sptr inWS, + IPeaksWorkspace_sptr runAlgorithm(const PeaksWorkspace_sptr &inWS, const std::string &filterVariable, const double filterValue, const std::string &filterOperator) { diff --git a/Framework/Crystal/test/FindClusterFacesTest.h b/Framework/Crystal/test/FindClusterFacesTest.h index cd84d02fe7f719025dbabcb8ced8cc295eba02bd..86ca859c71298efbe72a3f36daad117e41965104 100644 --- a/Framework/Crystal/test/FindClusterFacesTest.h +++ b/Framework/Crystal/test/FindClusterFacesTest.h @@ -26,7 +26,7 @@ using Mantid::Crystal::FindClusterFaces; namespace { // Helper function to create a peaks workspace. -IPeaksWorkspace_sptr create_peaks_WS(Instrument_sptr inst) { +IPeaksWorkspace_sptr create_peaks_WS(const Instrument_sptr &inst) { PeaksWorkspace *pPeaksWS = new PeaksWorkspace(); pPeaksWS->setCoordinateSystem(Mantid::Kernel::HKL); IPeaksWorkspace_sptr peakWS(pPeaksWS); diff --git a/Framework/Crystal/test/FindSXPeaksTest.h b/Framework/Crystal/test/FindSXPeaksTest.h index 6c50a2ac6484a18170e5171fc33f49c6d2c89a6d..727ecad6df1ecae24f8a6542ddb878ffc62ddc9f 100644 --- a/Framework/Crystal/test/FindSXPeaksTest.h +++ b/Framework/Crystal/test/FindSXPeaksTest.h @@ -24,7 +24,7 @@ using namespace Mantid::Crystal; using namespace Mantid::DataObjects; // Helper method to overwrite spectra. -void overWriteSpectraY(size_t histo, Workspace2D_sptr workspace, +void overWriteSpectraY(size_t histo, const Workspace2D_sptr &workspace, const std::vector<double> &Yvalues) { workspace->dataY(histo) = Yvalues; @@ -32,7 +32,7 @@ void overWriteSpectraY(size_t histo, Workspace2D_sptr workspace, // Helper method to make what will be recognised as a single peak. void makeOnePeak(size_t histo, double peak_intensity, size_t at_bin, - Workspace2D_sptr workspace) { + const Workspace2D_sptr &workspace) { size_t nBins = workspace->y(0).size(); std::vector<double> peaksInY(nBins); @@ -53,7 +53,8 @@ void makeOnePeak(size_t histo, double peak_intensity, size_t at_bin, * @param startIndex :: the workspace index to start searching from * @param endIndex :: the workspace index to stop searching from */ -std::unique_ptr<FindSXPeaks> createFindSXPeaks(Workspace2D_sptr workspace) { +std::unique_ptr<FindSXPeaks> +createFindSXPeaks(const Workspace2D_sptr &workspace) { auto alg = std::make_unique<FindSXPeaks>(); alg->setRethrows(true); alg->initialize(); diff --git a/Framework/Crystal/test/IndexPeaksTest.h b/Framework/Crystal/test/IndexPeaksTest.h index c6a798a96276aa5eb7350d79deb5c7a84236f30d..296e2194246cbba945b89584fed84d3ecc0c2eea 100644 --- a/Framework/Crystal/test/IndexPeaksTest.h +++ b/Framework/Crystal/test/IndexPeaksTest.h @@ -112,7 +112,7 @@ PeaksWorkspace_sptr createTestPeaksWorkspaceWithSatellites( } std::unique_ptr<IndexPeaks> -indexPeaks(PeaksWorkspace_sptr peaksWS, +indexPeaks(const PeaksWorkspace_sptr &peaksWS, const std::unordered_map<std::string, std::string> &arguments) { auto alg = std::make_unique<IndexPeaks>(); alg->setChild(true); diff --git a/Framework/Crystal/test/IndexSXPeaksTest.h b/Framework/Crystal/test/IndexSXPeaksTest.h index d4b1d78460fe2ff83574e41f1fc51b33f1dc47e9..4adba996f3523d9cba6ba15435775a90d9625718 100644 --- a/Framework/Crystal/test/IndexSXPeaksTest.h +++ b/Framework/Crystal/test/IndexSXPeaksTest.h @@ -56,9 +56,9 @@ public: AnalysisDataService::Instance().remove("master_peaks"); } - void doTest(int nPixels, std::string peakIndexes, double a, double b, + void doTest(int nPixels, const std::string &peakIndexes, double a, double b, double c, double alpha, double beta, double gamma, - std::string searchExtents = "-20,20,-20,20,-20,20", + const std::string &searchExtents = "-20,20,-20,20,-20,20", double dTolerance = 0.01) { // Take a copy of the original peaks workspace. diff --git a/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h b/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h index 9b9e0ed455169371daf13c8f98e62eaaf9fb6438..9cb2a3db13146b64d6255509d328d5a70f15c667 100644 --- a/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h +++ b/Framework/Crystal/test/IntegratePeakTimeSlicesTest.h @@ -238,7 +238,7 @@ private: /** * Calculates Q */ - double calcQ(RectangularDetector_const_sptr bankP, + double calcQ(const RectangularDetector_const_sptr &bankP, const DetectorInfo &detectorInfo, int row, int col, double time) { boost::shared_ptr<Detector> detP = bankP->getAtXY(col, row); diff --git a/Framework/Crystal/test/PeakClusterProjectionTest.h b/Framework/Crystal/test/PeakClusterProjectionTest.h index 2ed35dfa0d4f8f56dbec336ee757c48ce660125a..ee5af061ef4e153b039823e36ab81451df398706 100644 --- a/Framework/Crystal/test/PeakClusterProjectionTest.h +++ b/Framework/Crystal/test/PeakClusterProjectionTest.h @@ -32,7 +32,7 @@ class PeakClusterProjectionTest : public CxxTest::TestSuite { private: // Helper function to create a peaks workspace. - IPeaksWorkspace_sptr create_peaks_WS(Instrument_sptr inst) const { + IPeaksWorkspace_sptr create_peaks_WS(const Instrument_sptr &inst) const { PeaksWorkspace *pPeaksWS = new PeaksWorkspace(); pPeaksWS->setCoordinateSystem(Mantid::Kernel::HKL); IPeaksWorkspace_sptr peakWS(pPeaksWS); diff --git a/Framework/Crystal/test/PeakIntensityVsRadiusTest.h b/Framework/Crystal/test/PeakIntensityVsRadiusTest.h index 2c6884af5fd46b62be31a85243f2d98b3ff60a38..493af63e3238695960c93aa7f3eb4816517845c4 100644 --- a/Framework/Crystal/test/PeakIntensityVsRadiusTest.h +++ b/Framework/Crystal/test/PeakIntensityVsRadiusTest.h @@ -210,12 +210,12 @@ public: assertFlatAfter1(ws); } - void assertFlatAfter1(MatrixWorkspace_sptr ws) { + void assertFlatAfter1(const MatrixWorkspace_sptr &ws) { TSM_ASSERT_DELTA("After 1.0, the signal is flat", ws->y(0)[12], 1000, 1e-6); TSM_ASSERT_DELTA("After 1.0, the signal is flat", ws->y(0)[15], 1000, 1e-6) } - void assertFirstFourYValuesCloseToZero(MatrixWorkspace_sptr ws) { + void assertFirstFourYValuesCloseToZero(const MatrixWorkspace_sptr &ws) { TS_ASSERT_DELTA(ws->y(0)[0], 0, 10); TS_ASSERT_DELTA(ws->y(0)[1], 0, 10); TS_ASSERT_DELTA(ws->y(0)[2], 0, 10); diff --git a/Framework/Crystal/test/PeaksInRegionTest.h b/Framework/Crystal/test/PeaksInRegionTest.h index 70f472cbe4001dd272f9ba809e2621630be0dae8..e3bca14a6c9f2e8d90f69b80bbcf639c9c9650cb 100644 --- a/Framework/Crystal/test/PeaksInRegionTest.h +++ b/Framework/Crystal/test/PeaksInRegionTest.h @@ -31,7 +31,7 @@ private: Helper function. Creates a peaksworkspace with a single peak */ PeakWorkspaceWithExtents - createPeaksWorkspace(const std::string coordFrame, double xMinFromPeak, + createPeaksWorkspace(const std::string &coordFrame, double xMinFromPeak, double xMaxFromPeak, double yMinFromPeak, double yMaxFromPeak, double zMinFromPeak, double zMaxFromPeak) { @@ -267,7 +267,7 @@ public: -0.5); // outside zmax } - void do_test_bounds_check_extents(const std::string coordFrame, + void do_test_bounds_check_extents(const std::string &coordFrame, double xMinFromPeak, double xMaxFromPeak, double yMinFromPeak, double yMaxFromPeak, double zMinFromPeak, double zMaxFromPeak, @@ -304,14 +304,12 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, -wallDistanceFromPeakCenter, - 1, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + 1, 1, 1, 1, 1, peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, -wallDistanceFromPeakCenter, - 1, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + 1, 1, 1, 1, 1, peakRadius, true); } void test_peak_intersects_xmax_boundary_when_radius_large_enough() { @@ -320,15 +318,15 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure - do_test_bounds_check_extents( - coordinateFrame, 1, -wallDistanceFromPeakCenter, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, 1, + peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. - do_test_bounds_check_extents( - coordinateFrame, 1, -wallDistanceFromPeakCenter, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, 1, + peakRadius, true); } void test_peak_intersects_ymin_boundary_when_radius_large_enough() { @@ -337,15 +335,15 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure - do_test_bounds_check_extents( - coordinateFrame, 1, 1, -wallDistanceFromPeakCenter, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, + peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. - do_test_bounds_check_extents( - coordinateFrame, 1, 1, -wallDistanceFromPeakCenter, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, + peakRadius, true); } void test_peak_intersects_ymax_boundary_when_radius_large_enough() { @@ -356,13 +354,13 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, -wallDistanceFromPeakCenter, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, -wallDistanceFromPeakCenter, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + true); } void test_peak_intersects_zmin_boundary_when_radius_large_enough() { @@ -373,13 +371,13 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, -wallDistanceFromPeakCenter, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, -wallDistanceFromPeakCenter, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + true); } void test_peak_intersects_zmax_boundary_when_radius_large_enough() { @@ -390,13 +388,12 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, 1, -wallDistanceFromPeakCenter, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, 1, - -wallDistanceFromPeakCenter, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + -wallDistanceFromPeakCenter, peakRadius, true); } void test_false_intersection_when_check_peak_extents() { diff --git a/Framework/Crystal/test/PeaksOnSurfaceTest.h b/Framework/Crystal/test/PeaksOnSurfaceTest.h index 1231b76c911fc1c817cdf95ef92787290fafeac9..884e15f42c32e87a389bee198517b668a953fd15 100644 --- a/Framework/Crystal/test/PeaksOnSurfaceTest.h +++ b/Framework/Crystal/test/PeaksOnSurfaceTest.h @@ -27,7 +27,7 @@ private: Helper function. Creates a peaksworkspace with a single peak */ PeaksWorkspace_sptr - createPeaksWorkspace(const std::string coordFrame, + createPeaksWorkspace(const std::string &coordFrame, const Mantid::Kernel::V3D &peakPosition) { PeaksWorkspace_sptr ws = WorkspaceCreationHelper::createPeaksWorkspace(1); auto detectorIds = ws->getInstrument()->getDetectorIDs(); diff --git a/Framework/Crystal/test/PredictPeaksTest.h b/Framework/Crystal/test/PredictPeaksTest.h index 49527be7c592861867a09665fb761e39dc66dc07..9935199443f85d6dc90a1adc0b725c6733c659ac 100644 --- a/Framework/Crystal/test/PredictPeaksTest.h +++ b/Framework/Crystal/test/PredictPeaksTest.h @@ -20,6 +20,8 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Crystal; using namespace Mantid::API; @@ -37,8 +39,8 @@ public: } /** Make a HKL peaks workspace */ - PeaksWorkspace_sptr getHKLpw(Instrument_sptr inst, std::vector<V3D> hkls, - detid_t detid) { + PeaksWorkspace_sptr getHKLpw(const Instrument_sptr &inst, + const std::vector<V3D> &hkls, detid_t detid) { PeaksWorkspace_sptr hklPW; if (hkls.size() > 0) { hklPW = PeaksWorkspace_sptr(new PeaksWorkspace()); @@ -51,9 +53,9 @@ public: return hklPW; } - void do_test_exec(std::string reflectionCondition, size_t expectedNumber, - std::vector<V3D> hkls, int convention = 1, - bool useExtendedDetectorSpace = false, + void do_test_exec(const std::string &reflectionCondition, + size_t expectedNumber, const std::vector<V3D> &hkls, + int convention = 1, bool useExtendedDetectorSpace = false, bool addExtendedDetectorDefinition = false, int edge = 0) { // Name of the output workspace. std::string outWSName("PredictPeaksTest_OutputWS"); @@ -78,7 +80,7 @@ public: WorkspaceCreationHelper::setOrientedLattice(inWS, 12.0, 12.0, 12.0); WorkspaceCreationHelper::setGoniometer(inWS, 0., 0., 0.); - PeaksWorkspace_sptr hklPW = getHKLpw(inst, hkls, 10000); + PeaksWorkspace_sptr hklPW = getHKLpw(inst, std::move(hkls), 10000); PredictPeaks alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/Crystal/test/SaveIsawUBTest.h b/Framework/Crystal/test/SaveIsawUBTest.h index 2f3394f32adf258721b14e3cd155ed25f7805944..e7cbf2bd73192d9a9382bfa6808208b3441283d0 100644 --- a/Framework/Crystal/test/SaveIsawUBTest.h +++ b/Framework/Crystal/test/SaveIsawUBTest.h @@ -90,15 +90,13 @@ public: F1.open(File1.c_str()); F2.open(File2.c_str()); - int line = 1; std::string s; - double val1, val2; - double tolerance; - if (F1.good() && F2.good()) + if (F1.good() && F2.good()) { + int line = 1; for (int row = 0; row < 5; row++) { int NNums = 3; - tolerance = .0000003; + double tolerance = .0000003; if (line > 3) { NNums = 7; tolerance = .0003; @@ -107,6 +105,7 @@ public: for (int N = 0; N < NNums; N++) { s = Mantid::Kernel::Strings::getWord(F1, false); + double val1, val2; if (!Mantid::Kernel::Strings::convert<double>(s, val1)) { stringstream message; message << "Characters on line " << line << " word " << N; @@ -128,7 +127,7 @@ public: Mantid::Kernel::Strings::readToEndOfLine(F2, true); line++; } - else { + } else { TS_ASSERT(F1.good()); TS_ASSERT(F2.good()); remove(File2.c_str()); diff --git a/Framework/Crystal/test/SetGoniometerTest.h b/Framework/Crystal/test/SetGoniometerTest.h index 7646f706be010c9c6b209b41149e5a0f3c8ee89d..1fd24eeefb748ed9d69fa6d20b6df33423a793b7 100644 --- a/Framework/Crystal/test/SetGoniometerTest.h +++ b/Framework/Crystal/test/SetGoniometerTest.h @@ -193,7 +193,7 @@ public: * @param axis0 :: string to pass * @param numExpected :: how many axes should be created (0 or 1) */ - void do_test_param(std::string axis0, size_t numExpected = 0) { + void do_test_param(const std::string &axis0, size_t numExpected = 0) { Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); AnalysisDataService::Instance().addOrReplace("SetGoniometerTest_ws", ws); FrameworkManager::Instance().exec( diff --git a/Framework/Crystal/test/SortPeaksWorkspaceTest.h b/Framework/Crystal/test/SortPeaksWorkspaceTest.h index 5f31efbb3aeea9b94889016314430f0083e824f9..3dac4e70097fa8cf84ac11f679276c0e0ce074ca 100644 --- a/Framework/Crystal/test/SortPeaksWorkspaceTest.h +++ b/Framework/Crystal/test/SortPeaksWorkspaceTest.h @@ -25,7 +25,8 @@ private: * @param inWS : Input workspace to sort * @param columnName : Column name to sort by */ - void doExecute(IPeaksWorkspace_sptr inWS, const std::string &columnName, + void doExecute(const IPeaksWorkspace_sptr &inWS, + const std::string &columnName, const bool sortAscending = true) { std::string outWSName("SortPeaksWorkspaceTest_OutputWS"); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h index 382b647c796fb57f463c7c271c14dd7fd194aa04..d20969b16a4aa626ab03e055f14807804487cc4a 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h @@ -72,7 +72,7 @@ private: void processInputProperties(); /// Generate peaks from input table workspace - void genPeaksFromTable(DataObjects::TableWorkspace_sptr peakparamws); + void genPeaksFromTable(const DataObjects::TableWorkspace_sptr &peakparamws); /// Generate a peak Functions::BackToBackExponential_sptr @@ -86,11 +86,11 @@ private: /// Import instrument parameters from (input) table workspace void importInstrumentParameterFromTable( - DataObjects::TableWorkspace_sptr parameterWS); + const DataObjects::TableWorkspace_sptr ¶meterWS); /// Import Bragg peak table workspace void - parseBraggPeakTable(DataObjects::TableWorkspace_sptr peakws, + parseBraggPeakTable(const DataObjects::TableWorkspace_sptr &peakws, std::vector<std::map<std::string, double>> ¶mmaps, std::vector<std::map<std::string, int>> &hklmaps); @@ -108,27 +108,26 @@ private: //--------------------------------------------------------------------------- /// Fit single peak in robust mode (no hint) - bool - fitSinglePeakRobust(Functions::BackToBackExponential_sptr peak, - Functions::BackgroundFunction_sptr backgroundfunction, - double peakleftbound, double peakrightbound, - std::map<std::string, double> rightpeakparammap, - double &finalchi2); + bool fitSinglePeakRobust( + const Functions::BackToBackExponential_sptr &peak, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double peakleftbound, double peakrightbound, + const std::map<std::string, double> &rightpeakparammap, + double &finalchi2); /// Fit signle peak by Monte Carlo/simulated annealing - bool - fitSinglePeakSimulatedAnnealing(Functions::BackToBackExponential_sptr peak, - std::vector<std::string> paramtodomc); + bool fitSinglePeakSimulatedAnnealing( + const Functions::BackToBackExponential_sptr &peak, + const std::vector<std::string> ¶mtodomc); /// Fit peak with confidence of the centre bool fitSinglePeakConfidentX(Functions::BackToBackExponential_sptr peak); /// Fit peak with trustful peak parameters - bool - fitSinglePeakConfident(Functions::BackToBackExponential_sptr peak, - Functions::BackgroundFunction_sptr backgroundfunction, - double leftbound, double rightbound, double &chi2, - bool &annhilatedpeak); + bool fitSinglePeakConfident( + const Functions::BackToBackExponential_sptr &peak, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double leftbound, double rightbound, double &chi2, bool &annhilatedpeak); /// Fit peak with confident parameters bool fitSinglePeakConfidentY(DataObjects::Workspace2D_sptr dataws, @@ -136,33 +135,32 @@ private: double dampingfactor); /// Fit peaks with confidence in fwhm and etc. - bool - fitOverlappedPeaks(std::vector<Functions::BackToBackExponential_sptr> peaks, - Functions::BackgroundFunction_sptr backgroundfunction, - double gfwhm); + bool fitOverlappedPeaks( + std::vector<Functions::BackToBackExponential_sptr> peaks, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double gfwhm); /// Fit multiple (overlapped) peaks bool doFitMultiplePeaks( - DataObjects::Workspace2D_sptr dataws, size_t wsindex, - API::CompositeFunction_sptr peaksfunc, + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, + const API::CompositeFunction_sptr &peaksfunc, std::vector<Functions::BackToBackExponential_sptr> peakfuncs, std::vector<bool> &vecfitgood, std::vector<double> &vecchi2s); /// Use Le Bail method to estimate and set the peak heights void estimatePeakHeightsLeBail( - DataObjects::Workspace2D_sptr dataws, size_t wsindex, + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, std::vector<Functions::BackToBackExponential_sptr> peaks); /// Set constraints on a group of overlapped peaks for fitting void setOverlappedPeaksConstraints( - std::vector<Functions::BackToBackExponential_sptr> peaks); + const std::vector<Functions::BackToBackExponential_sptr> &peaks); /// Fit 1 peak by 1 minimizer of 1 call of minimzer (simple version) - bool doFit1PeakSimple(DataObjects::Workspace2D_sptr dataws, - size_t workspaceindex, - Functions::BackToBackExponential_sptr peakfunction, - std::string minimzername, size_t maxiteration, - double &chi2); + bool doFit1PeakSimple( + const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, + const Functions::BackToBackExponential_sptr &peakfunction, + const std::string &minimzername, size_t maxiteration, double &chi2); /// Fit 1 peak and background // bool doFit1PeakBackgroundSimple(DataObjects::Workspace2D_sptr dataws, @@ -172,33 +170,32 @@ private: // string minimzername, size_t maxiteration, double &chi2); /// Fit single peak with background to raw data - bool - doFit1PeakBackground(DataObjects::Workspace2D_sptr dataws, size_t wsindex, - Functions::BackToBackExponential_sptr peak, - Functions::BackgroundFunction_sptr backgroundfunction, - double &chi2); + bool doFit1PeakBackground( + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, + const Functions::BackToBackExponential_sptr &peak, + const Functions::BackgroundFunction_sptr &backgroundfunction, + double &chi2); /// Fit 1 peak by using a sequential of minimizer - bool doFit1PeakSequential(DataObjects::Workspace2D_sptr dataws, - size_t workspaceindex, - Functions::BackToBackExponential_sptr peakfunction, - std::vector<std::string> minimzernames, - std::vector<size_t> maxiterations, - std::vector<double> dampfactors, double &chi2); + bool doFit1PeakSequential( + const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, + const Functions::BackToBackExponential_sptr &peakfunction, + std::vector<std::string> minimzernames, std::vector<size_t> maxiterations, + const std::vector<double> &dampfactors, double &chi2); /// Fit N overlapped peaks in a simple manner bool doFitNPeaksSimple( - DataObjects::Workspace2D_sptr dataws, size_t wsindex, - API::CompositeFunction_sptr peaksfunc, - std::vector<Functions::BackToBackExponential_sptr> peakfuncs, - std::string minimizername, size_t maxiteration, double &chi2); + const DataObjects::Workspace2D_sptr &dataws, size_t wsindex, + const API::CompositeFunction_sptr &peaksfunc, + const std::vector<Functions::BackToBackExponential_sptr> &peakfuncs, + const std::string &minimizername, size_t maxiteration, double &chi2); /// Store the function's parameter values to a map - void storeFunctionParameters(API::IFunction_sptr function, + void storeFunctionParameters(const API::IFunction_sptr &function, std::map<std::string, double> ¶mmaps); /// Restore the function's parameter values from a map - void restoreFunctionParameters(API::IFunction_sptr function, + void restoreFunctionParameters(const API::IFunction_sptr &function, std::map<std::string, double> parammap); /// Calculate the range to fit peak/peaks group @@ -225,7 +222,8 @@ private: void cropWorkspace(double tofmin, double tofmax); /// Parse Fit() output parameter workspace - std::string parseFitParameterWorkspace(API::ITableWorkspace_sptr paramws); + std::string + parseFitParameterWorkspace(const API::ITableWorkspace_sptr ¶mws); /// Build a partial workspace from source // DataObjects::Workspace2D_sptr @@ -240,8 +238,8 @@ private: double &chi2); /// Observe peak range with hint from right peak's properties - void observePeakRange(Functions::BackToBackExponential_sptr thispeak, - Functions::BackToBackExponential_sptr rightpeak, + void observePeakRange(const Functions::BackToBackExponential_sptr &thispeak, + const Functions::BackToBackExponential_sptr &rightpeak, double refpeakshift, double &peakleftbound, double &peakrightbound); @@ -268,12 +266,12 @@ private: bool calchi2); std::pair<bool, double> - doFitPeak(DataObjects::Workspace2D_sptr dataws, - Functions::BackToBackExponential_sptr peakfunction, + doFitPeak(const DataObjects::Workspace2D_sptr &dataws, + const Functions::BackToBackExponential_sptr &peakfunction, double guessedfwhm); /// Fit background-removed peak by Gaussian - bool doFitGaussianPeak(DataObjects::Workspace2D_sptr dataws, + bool doFitGaussianPeak(const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, double in_center, double leftfwhm, double rightfwhm, double ¢er, double &sigma, double &height); @@ -288,28 +286,28 @@ private: Functions::BackgroundFunction_sptr background); /// Parse the fitting result - std::string parseFitResult(API::IAlgorithm_sptr fitalg, double &chi2, + std::string parseFitResult(const API::IAlgorithm_sptr &fitalg, double &chi2, bool &fitsuccess); /// Calculate a Bragg peak's centre in TOF from its Miller indices double calculatePeakCentreTOF(int h, int k, int l); /// Get parameter value from m_instrumentParameters - double getParameter(std::string parname); + double getParameter(const std::string &parname); /// Fit peaks in the same group (i.e., single peak or overlapped peaks) void fitPeaksGroup(std::vector<size_t> peakindexes); /// Build partial workspace for fitting DataObjects::Workspace2D_sptr - buildPartialWorkspace(API::MatrixWorkspace_sptr sourcews, + buildPartialWorkspace(const API::MatrixWorkspace_sptr &sourcews, size_t workspaceindex, double leftbound, double rightbound); /// Plot a single peak to output vector - void plotFunction(API::IFunction_sptr peakfunction, - Functions::BackgroundFunction_sptr background, - API::FunctionDomain1DVector domain); + void plotFunction(const API::IFunction_sptr &peakfunction, + const Functions::BackgroundFunction_sptr &background, + const API::FunctionDomain1DVector &domain); //----------------------------------------------------------------------------------------------- @@ -411,25 +409,25 @@ inline double linearInterpolateY(double x0, double xf, double y0, double yf, } /// Estimate background for a pattern in a coarse mode -void estimateBackgroundCoarse(DataObjects::Workspace2D_sptr dataws, - Functions::BackgroundFunction_sptr background, - size_t wsindexraw, size_t wsindexbkgd, - size_t wsindexpeak); +void estimateBackgroundCoarse( + const DataObjects::Workspace2D_sptr &dataws, + const Functions::BackgroundFunction_sptr &background, size_t wsindexraw, + size_t wsindexbkgd, size_t wsindexpeak); /// Estimate peak parameters; -bool observePeakParameters(DataObjects::Workspace2D_sptr dataws, size_t wsindex, - double ¢re, double &height, double &fwhm, - std::string &errmsg); +bool observePeakParameters(const DataObjects::Workspace2D_sptr &dataws, + size_t wsindex, double ¢re, double &height, + double &fwhm, std::string &errmsg); /// Find maximum value size_t findMaxValue(const std::vector<double> &Y); /// Find maximum value -size_t findMaxValue(API::MatrixWorkspace_sptr dataws, size_t wsindex, +size_t findMaxValue(const API::MatrixWorkspace_sptr &dataws, size_t wsindex, double leftbound, double rightbound); /// Get function parameter name, value and etc information in string -std::string getFunctionInfo(API::IFunction_sptr function); +std::string getFunctionInfo(const API::IFunction_sptr &function); } // namespace Algorithms } // namespace CurveFitting diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h index a0c846385dbe8ac6d2f09350d1904a12eab57e5c..0d881f945b04203bf9be092a08c0bb5d18836f70 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h @@ -37,26 +37,26 @@ namespace Algorithms { struct Parameter { // Regular std::string name; - double curvalue; - double prevalue; - double minvalue; - double maxvalue; - bool fit; - double stepsize; - double fiterror; + double curvalue = 0; + double prevalue = 0; + double minvalue = 0; + double maxvalue = 0; + bool fit = false; + double stepsize = 0; + double fiterror = 0; // Monte Carlo - bool nonnegative; - double mcA0; - double mcA1; + bool nonnegative = false; + double mcA0 = 0; + double mcA1 = 0; // Monte Carlo record - double sumstepsize; - double maxabsstepsize; - double maxrecordvalue; - double minrecordvalue; - size_t numpositivemove; - size_t numnegativemove; - size_t numnomove; - int movedirection; + double sumstepsize = 0; + double maxabsstepsize = 0; + double maxrecordvalue = 0; + double minrecordvalue = 0; + size_t numpositivemove = 0; + size_t numnegativemove = 0; + size_t numnomove = 0; + int movedirection = 0; }; class MANTID_CURVEFITTING_DLL LeBailFit : public API::Algorithm { @@ -103,8 +103,8 @@ private: void createLeBailFunction(); /// Crop the workspace for better usage - API::MatrixWorkspace_sptr cropWorkspace(API::MatrixWorkspace_sptr inpws, - size_t wsindex); + API::MatrixWorkspace_sptr + cropWorkspace(const API::MatrixWorkspace_sptr &inpws, size_t wsindex); /// Process and calculate input background void processInputBackground(); @@ -123,10 +123,10 @@ private: void parseBraggPeaksParametersTable(); /// Parse content in a table workspace to vector for background parameters - void - parseBackgroundTableWorkspace(DataObjects::TableWorkspace_sptr bkgdparamws, - std::vector<std::string> &bkgdparnames, - std::vector<double> &bkgdorderparams); + void parseBackgroundTableWorkspace( + const DataObjects::TableWorkspace_sptr &bkgdparamws, + std::vector<std::string> &bkgdparnames, + std::vector<double> &bkgdorderparams); /// Create and set up output table workspace for peaks void exportBraggPeakParameterToTable(); @@ -153,12 +153,12 @@ private: /// Set up Monte Carlo random walk strategy void setupBuiltInRandomWalkStrategy(); - void - setupRandomWalkStrategyFromTable(DataObjects::TableWorkspace_sptr tablews); + void setupRandomWalkStrategyFromTable( + const DataObjects::TableWorkspace_sptr &tablews); /// Add parameter (to a vector of string/name) for MC random walk void addParameterToMCMinimize(std::vector<std::string> &parnamesforMC, - std::string parname); + const std::string &parname); /// Calculate diffraction pattern in Le Bail algorithm for MC Random walk bool calculateDiffractionPattern( @@ -171,7 +171,8 @@ private: bool acceptOrDeny(Kernel::Rfactor currR, Kernel::Rfactor newR); /// Propose new parameters - bool proposeNewValues(std::vector<std::string> mcgroup, Kernel::Rfactor r, + bool proposeNewValues(const std::vector<std::string> &mcgroup, + Kernel::Rfactor r, std::map<std::string, Parameter> &curparammap, std::map<std::string, Parameter> &newparammap, bool prevBetterRwp); @@ -308,7 +309,7 @@ private: /// Write a set of (XY) data to a column file void writeRfactorsToFile(std::vector<double> vecX, std::vector<Kernel::Rfactor> vecR, - std::string filename); + const std::string &filename); } // namespace Algorithms } // namespace CurveFitting diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h index b4a9afb28203e59ec4f25681bec2313af9dff09b..754025d1c0d588d147f649f92b34db3df7f8c50a 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFunction.h @@ -34,7 +34,7 @@ it is rewritten. class MANTID_CURVEFITTING_DLL LeBailFunction { public: /// Constructor - LeBailFunction(std::string peaktype); + LeBailFunction(const std::string &peaktype); /// Destructor virtual ~LeBailFunction(); @@ -43,14 +43,14 @@ public: void setProfileParameterValues(std::map<std::string, double> parammap); /// Set up a parameter to fit but tied among all peaks - void setFitProfileParameter(std::string paramname, double minvalue, + void setFitProfileParameter(const std::string ¶mname, double minvalue, double maxvalue); /// Function - void setPeakHeights(std::vector<double> inheights); + void setPeakHeights(const std::vector<double> &inheights); /// Check whether a parameter is a profile parameter - bool hasProfileParameter(std::string paramname); + bool hasProfileParameter(const std::string ¶mname); /// Check whether the newly set parameters are correct, i.e., all peaks are /// physical @@ -63,7 +63,7 @@ public: void addPeaks(std::vector<std::vector<int>> peakhkls); /// Add background function - void addBackgroundFunction(std::string backgroundtype, + void addBackgroundFunction(const std::string &backgroundtype, const unsigned int &order, const std::vector<std::string> &vecparnames, const std::vector<double> &vecparvalues, @@ -91,13 +91,14 @@ public: void calPeaksParameters(); /// Get peak parameters (calculated) - double getPeakParameter(size_t index, std::string parname) const; + double getPeakParameter(size_t index, const std::string &parname) const; /// Get peak parameters (calculated) - double getPeakParameter(std::vector<int> hkl, std::string parname) const; + double getPeakParameter(std::vector<int> hkl, + const std::string &parname) const; /// Set up a parameter to be fixed - void fixPeakParameter(std::string paramname, double paramvalue); + void fixPeakParameter(const std::string ¶mname, double paramvalue); /// Fix all background parameters void fixBackgroundParameters(); @@ -116,13 +117,13 @@ public: private: /// Set peak parameters - void setPeakParameters(API::IPowderDiffPeakFunction_sptr peak, - std::map<std::string, double> parammap, + void setPeakParameters(const API::IPowderDiffPeakFunction_sptr &peak, + const std::map<std::string, double> ¶mmap, double peakheight, bool setpeakheight); /// Retrieve peak's parameter. may be native or calculated - double getPeakParameterValue(API::IPowderDiffPeakFunction_sptr peak, - std::string parname) const; + double getPeakParameterValue(const API::IPowderDiffPeakFunction_sptr &peak, + const std::string &parname) const; /// Calculate all peaks' parameter value void calculatePeakParameterValues() const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h index 37df79315c5ba5367ba53740125b17756660d081..6e6e97f2d6b2739b5d9f640f618eb5c459f9beb9 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h @@ -64,7 +64,8 @@ private: void exec() override; /// Set any WorkspaceIndex attributes in the fitting function - void setWorkspaceIndexAttribute(API::IFunction_sptr fun, int wsIndex) const; + void setWorkspaceIndexAttribute(const API::IFunction_sptr &fun, + int wsIndex) const; boost::shared_ptr<Algorithm> runSingleFit(bool createFitOutput, bool outputCompositeMembers, @@ -72,7 +73,8 @@ private: const API::IFunction_sptr &ifun, const InputSpectraToFit &data); - double calculateLogValue(std::string logName, const InputSpectraToFit &data); + double calculateLogValue(const std::string &logName, + const InputSpectraToFit &data); API::ITableWorkspace_sptr createResultsTable(const std::string &logName, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h index 68fbe1598766d91b068c3e7a28582f6ac713a066..f83cabaeb310fa25d0154a6b7de8e7c80762ffc8 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValueHelper.h @@ -42,7 +42,7 @@ getWorkspace(const std::string &name, int period); /// Create a list of input workspace names MANTID_CURVEFITTING_DLL std::vector<InputSpectraToFit> -makeNames(std::string inputList, int default_wi, int default_spec); +makeNames(const std::string &inputList, int default_wi, int default_spec); enum SpecialIndex { NOT_SET = -1, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h index dc0a910b53f81ab94c0fabc29799659df0ccc26d..32f8dfa3c1c9c47b1d73b68236d989947df35f62 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSequential.h @@ -46,8 +46,8 @@ private: API::ITableWorkspace_sptr performFit(const std::string &input, const std::string &output); void deleteTemporaryWorkspaces(const std::string &outputBaseName); - void addAdditionalLogs(API::WorkspaceGroup_sptr resultWorkspace); - void addAdditionalLogs(API::Workspace_sptr result); + void addAdditionalLogs(const API::WorkspaceGroup_sptr &resultWorkspace); + void addAdditionalLogs(const API::Workspace_sptr &result); virtual bool throwIfElasticQConversionFails() const; virtual bool isFitParameter(const std::string ¶meterName) const; @@ -57,9 +57,9 @@ private: const std::vector<API::MatrixWorkspace_sptr> &workspaces) const; std::vector<std::size_t> getDatasetGrouping( const std::vector<API::MatrixWorkspace_sptr> &workspaces) const; - API::WorkspaceGroup_sptr - processIndirectFitParameters(API::ITableWorkspace_sptr parameterWorkspace, - const std::vector<std::size_t> &grouping); + API::WorkspaceGroup_sptr processIndirectFitParameters( + const API::ITableWorkspace_sptr ¶meterWorkspace, + const std::vector<std::size_t> &grouping); std::vector<API::MatrixWorkspace_sptr> convertInputToElasticQ( const std::vector<API::MatrixWorkspace_sptr> &workspaces) const; @@ -77,20 +77,20 @@ private: std::vector<std::string> const &spectra, std::string const &outputBaseName, std::string const &endOfSuffix); - void copyLogs(API::WorkspaceGroup_sptr resultWorkspaces, + void copyLogs(const API::WorkspaceGroup_sptr &resultWorkspaces, std::vector<API::MatrixWorkspace_sptr> const &workspaces); - void copyLogs(API::Workspace_sptr resultWorkspace, + void copyLogs(const API::Workspace_sptr &resultWorkspace, std::vector<API::MatrixWorkspace_sptr> const &workspaces); - void copyLogs(API::MatrixWorkspace_sptr resultWorkspace, - API::WorkspaceGroup_sptr resultGroup); - void copyLogs(API::MatrixWorkspace_sptr resultWorkspace, - API::Workspace_sptr resultGroup); - void extractMembers(API::WorkspaceGroup_sptr resultGroupWs, + void copyLogs(const API::MatrixWorkspace_sptr &resultWorkspace, + const API::WorkspaceGroup_sptr &resultGroup); + void copyLogs(const API::MatrixWorkspace_sptr &resultWorkspace, + const API::Workspace_sptr &resultGroup); + void extractMembers(const API::WorkspaceGroup_sptr &resultGroupWs, const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName); API::IAlgorithm_sptr - extractMembersAlgorithm(API::WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const API::WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const; std::string getTemporaryName() const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h index 67075de0d749e849c84ce5ecfada6900df137aac..d6af7bbfa52c4bc7d43e5c901a58f537aab3bd4b 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitSimultaneous.h @@ -47,27 +47,27 @@ private: std::pair<API::ITableWorkspace_sptr, API::Workspace_sptr> performFit(const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &output); - API::WorkspaceGroup_sptr - processIndirectFitParameters(API::ITableWorkspace_sptr parameterWorkspace, - const std::vector<std::size_t> &grouping); - void copyLogs(API::WorkspaceGroup_sptr resultWorkspace, + API::WorkspaceGroup_sptr processIndirectFitParameters( + const API::ITableWorkspace_sptr ¶meterWorkspace, + const std::vector<std::size_t> &grouping); + void copyLogs(const API::WorkspaceGroup_sptr &resultWorkspace, const std::vector<API::MatrixWorkspace_sptr> &workspaces); - void copyLogs(API::MatrixWorkspace_sptr resultWorkspace, - API::WorkspaceGroup_sptr resultGroup); - void extractMembers(API::WorkspaceGroup_sptr resultGroupWs, + void copyLogs(const API::MatrixWorkspace_sptr &resultWorkspace, + const API::WorkspaceGroup_sptr &resultGroup); + void extractMembers(const API::WorkspaceGroup_sptr &resultGroupWs, const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName); - void addAdditionalLogs(API::WorkspaceGroup_sptr group); - void addAdditionalLogs(API::Workspace_sptr result); + void addAdditionalLogs(const API::WorkspaceGroup_sptr &group); + void addAdditionalLogs(const API::Workspace_sptr &result); API::IAlgorithm_sptr - extractMembersAlgorithm(API::WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const API::WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const; std::string getOutputBaseName() const; std::vector<std::string> getWorkspaceNames() const; std::vector<std::string> getWorkspaceIndices() const; - void renameWorkspaces(API::WorkspaceGroup_sptr outputGroup, + void renameWorkspaces(const API::WorkspaceGroup_sptr &outputGroup, std::vector<std::string> const &spectra, std::string const &outputBaseName, std::string const &endOfSuffix, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h index 33e822287227570a0bcc5b6c1cd7833ec0834292..4972f7be065693fe668557f9c998f53ec9e32ba5 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/QENSFitUtilities.h @@ -16,7 +16,7 @@ namespace API { void renameWorkspacesInQENSFit( Algorithm *qensFit, IAlgorithm_sptr renameAlgorithm, - WorkspaceGroup_sptr outputGroup, std::string const &outputBaseName, + const WorkspaceGroup_sptr &outputGroup, std::string const &outputBaseName, std::string const &groupSuffix, std::function<std::string(std::size_t)> const &getNameSuffix); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h index c30d735b846aae5cb23f661b7a48ffb924f4aa11..7afd36cdd810a0b6f916552b6106acbebc453177 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h @@ -67,20 +67,22 @@ private: //---------------- Processing Input --------------------- /// Import instrument parameter from table (workspace) - void importParametersFromTable(DataObjects::TableWorkspace_sptr parameterWS, - std::map<std::string, double> ¶meters); + void + importParametersFromTable(const DataObjects::TableWorkspace_sptr ¶meterWS, + std::map<std::string, double> ¶meters); /// Import the Monte Carlo related parameters from table void importMonteCarloParametersFromTable( - DataObjects::TableWorkspace_sptr tablews, - std::vector<std::string> parameternames, std::vector<double> &stepsizes, - std::vector<double> &lowerbounds, std::vector<double> &upperbounds); + const DataObjects::TableWorkspace_sptr &tablews, + const std::vector<std::string> ¶meternames, + std::vector<double> &stepsizes, std::vector<double> &lowerbounds, + std::vector<double> &upperbounds); /// Generate (output) workspace of peak centers void genPeakCentersWorkspace(bool montecarlo, size_t numbestfit); /// Generate peaks from table (workspace) - void genPeaksFromTable(DataObjects::TableWorkspace_sptr peakparamws); + void genPeaksFromTable(const DataObjects::TableWorkspace_sptr &peakparamws); //--------------- Processing Output ------------------ /// Generate (output) table worksspace for instrument parameters @@ -94,12 +96,12 @@ private: void fitInstrumentParameters(); /// Calculate function's statistic - double calculateFunctionStatistic(API::IFunction_sptr func, - API::MatrixWorkspace_sptr dataws, + double calculateFunctionStatistic(const API::IFunction_sptr &func, + const API::MatrixWorkspace_sptr &dataws, size_t workspaceindex); /// Fit function to data - bool fitFunction(API::IFunction_sptr func, double &gslchi2); + bool fitFunction(const API::IFunction_sptr &func, double &gslchi2); /// Parse Fit() output parameter workspace std::string parseFitParameterWorkspace(API::ITableWorkspace_sptr paramws); @@ -108,9 +110,8 @@ private: std::string parseFitResult(API::IAlgorithm_sptr fitalg, double &chi2); /// Set up and run a monte carlo simulation to refine the peak parameters - void - refineInstrumentParametersMC(DataObjects::TableWorkspace_sptr parameterWS, - bool fit2 = false); + void refineInstrumentParametersMC( + const DataObjects::TableWorkspace_sptr ¶meterWS, bool fit2 = false); /// Core Monte Carlo random walk on parameter-space void doParameterSpaceRandomWalk(std::vector<std::string> parnames, @@ -124,8 +125,8 @@ private: void getD2TOFFuncParamNames(std::vector<std::string> &parnames); /// Calculate the value and chi2 - double calculateD2TOFFunction(API::IFunction_sptr func, - API::FunctionDomain1DVector domain, + double calculateD2TOFFunction(const API::IFunction_sptr &func, + const API::FunctionDomain1DVector &domain, API::FunctionValues &values, const Mantid::HistogramData::HistogramY &rawY, const Mantid::HistogramData::HistogramE &rawE); @@ -135,7 +136,7 @@ private: /// Calculate value n for thermal neutron peak profile void - calculateThermalNeutronSpecial(API::IFunction_sptr m_Function, + calculateThermalNeutronSpecial(const API::IFunction_sptr &m_Function, const Mantid::HistogramData::HistogramX &xVals, std::vector<double> &vec_n); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h index 22fc3367b2ee22da0bcc0c335ad3b6e595628c2f..bab383a92adf26d2cc43bea5bb075e9f2c99e6d2 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h @@ -68,11 +68,11 @@ private: /// Add parameter (to a vector of string/name) for MC random walk void addParameterToMCMinimize(std::vector<std::string> &parnamesforMC, - std::string parname, + const std::string &parname, std::map<std::string, Parameter> parammap); /// Propose new parameters - void proposeNewValues(std::vector<std::string> mcgroup, + void proposeNewValues(const std::vector<std::string> &mcgroup, std::map<std::string, Parameter> &curparammap, std::map<std::string, Parameter> &newparammap, double currchisq); @@ -88,23 +88,23 @@ private: // maxnumresults); /// Implement parameter values, calculate function and its chi square. - double calculateFunction(std::map<std::string, Parameter> parammap, + double calculateFunction(const std::map<std::string, Parameter> ¶mmap, std::vector<double> &vecY); /// Calculate Chi^2 of the a function with all parameters are fixed - double calculateFunctionError(API::IFunction_sptr function, - DataObjects::Workspace2D_sptr dataws, + double calculateFunctionError(const API::IFunction_sptr &function, + const DataObjects::Workspace2D_sptr &dataws, int wsindex); /// Fit function by non MC minimzer(s) - double fitFunction(API::IFunction_sptr function, - DataObjects::Workspace2D_sptr dataws, int wsindex, + double fitFunction(const API::IFunction_sptr &function, + const DataObjects::Workspace2D_sptr &dataws, int wsindex, bool powerfit); /// Fit function (single step) - bool doFitFunction(API::IFunction_sptr function, - DataObjects::Workspace2D_sptr dataws, int wsindex, - std::string minimizer, int numiters, double &chi2, + bool doFitFunction(const API::IFunction_sptr &function, + const DataObjects::Workspace2D_sptr &dataws, int wsindex, + const std::string &minimizer, int numiters, double &chi2, std::string &fitstatus); /// Process input properties @@ -114,11 +114,11 @@ private: void parseTableWorkspaces(); /// Parse table workspace to a map of Parameters - void parseTableWorkspace(DataObjects::TableWorkspace_sptr tablews, + void parseTableWorkspace(const DataObjects::TableWorkspace_sptr &tablews, std::map<std::string, Parameter> ¶mmap); /// Set parameter values to function from Parameter map - void setFunctionParameterValues(API::IFunction_sptr function, + void setFunctionParameterValues(const API::IFunction_sptr &function, std::map<std::string, Parameter> params); /// Update parameter values to Parameter map from fuction map @@ -127,13 +127,13 @@ private: /// Set parameter fitting setup (boundary, fix or unfix) to function from /// Parameter map - void setFunctionParameterFitSetups(API::IFunction_sptr function, + void setFunctionParameterFitSetups(const API::IFunction_sptr &function, std::map<std::string, Parameter> params); /// Construct output DataObjects::Workspace2D_sptr - genOutputWorkspace(API::FunctionDomain1DVector domain, - API::FunctionValues rawvalues); + genOutputWorkspace(const API::FunctionDomain1DVector &domain, + const API::FunctionValues &rawvalues); /// Construct an output TableWorkspace for refined peak profile parameters DataObjects::TableWorkspace_sptr @@ -143,7 +143,7 @@ private: /// Add a parameter to parameter map. If this parametere does exist, then /// replace the value of it void addOrReplace(std::map<std::string, Parameter> ¶meters, - std::string parname, double parvalue); + const std::string &parname, double parvalue); //-------- Variables ------------------------------------------------------ /// Data workspace containg peak positions @@ -189,17 +189,19 @@ void convertToDict(std::vector<std::string> strvec, std::map<std::string, size_t> &lookupdict); /// Get the index from lookup dictionary (map) -int getStringIndex(std::map<std::string, size_t> lookupdict, std::string key); +int getStringIndex(std::map<std::string, size_t> lookupdict, + const std::string &key); /// Store function parameter values to a map void storeFunctionParameterValue( - API::IFunction_sptr function, + const API::IFunction_sptr &function, std::map<std::string, std::pair<double, double>> &parvaluemap); /// Restore function parameter values to a map void restoreFunctionParameterValue( std::map<std::string, std::pair<double, double>> parvaluemap, - API::IFunction_sptr function, std::map<std::string, Parameter> ¶mmap); + const API::IFunction_sptr &function, + std::map<std::string, Parameter> ¶mmap); /// Copy parameters from source to target void duplicateParameters(std::map<std::string, Parameter> source, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h index dd85faa45c48b3593c1d722d64b23a86349bafa6..f88a7ee49f1d1008e7c5858cd59035c4ae9042ac 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h @@ -67,8 +67,8 @@ private: /// Gets the values from the fitted GSL, and creates a clone of input /// workspace with new values - API::MatrixWorkspace_sptr saveSplineOutput(const API::MatrixWorkspace_sptr ws, - const size_t spec); + API::MatrixWorkspace_sptr + saveSplineOutput(const API::MatrixWorkspace_sptr &ws, const size_t spec); /// Sets up the splines for later fitting void setupSpline(double xMin, double xMax, int numBins, int ncoeff); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h index f083aef2a5e86091d87bdd1417187022ddfaa438..74f9b50009991ff95a5688e5b02db5d884df66bf 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h @@ -50,8 +50,8 @@ private: /// setup an output workspace using meta data from inws and taking a number of /// spectra API::MatrixWorkspace_sptr - setupOutputWorkspace(API::MatrixWorkspace_sptr mws, - API::MatrixWorkspace_sptr iws) const; + setupOutputWorkspace(const API::MatrixWorkspace_sptr &mws, + const API::MatrixWorkspace_sptr &iws) const; /// convert a binned workspace to point data using ConvertToPointData API::MatrixWorkspace_sptr @@ -59,28 +59,32 @@ private: /// set the points that define the spline used for interpolation of a /// workspace - void setInterpolationPoints(API::MatrixWorkspace_const_sptr inputWorkspace, - const size_t row) const; + void + setInterpolationPoints(const API::MatrixWorkspace_const_sptr &inputWorkspace, + const size_t row) const; /// Calculate the interpolation of the input workspace against the spline and /// store it in outputWorkspace - void calculateSpline(API::MatrixWorkspace_const_sptr inputWorkspace, - API::MatrixWorkspace_sptr outputWorkspace, + void calculateSpline(const API::MatrixWorkspace_const_sptr &inputWorkspace, + const API::MatrixWorkspace_sptr &outputWorkspace, const size_t row) const; /// Calculate the derivatives of the input workspace from the spline. - void calculateDerivatives(API::MatrixWorkspace_const_sptr inputWorkspace, - API::MatrixWorkspace_sptr outputWorkspace, - const size_t order) const; + void + calculateDerivatives(const API::MatrixWorkspace_const_sptr &inputWorkspace, + const API::MatrixWorkspace_sptr &outputWorkspace, + const size_t order) const; /// Find the the interpolation range std::pair<size_t, size_t> - findInterpolationRange(API::MatrixWorkspace_const_sptr iwspt, - API::MatrixWorkspace_sptr mwspt, const size_t row); + findInterpolationRange(const API::MatrixWorkspace_const_sptr &iwspt, + const API::MatrixWorkspace_sptr &mwspt, + const size_t row); /// Extrapolates flat for the points outside the x-range - void extrapolateFlat(API::MatrixWorkspace_sptr ows, - API::MatrixWorkspace_const_sptr iwspt, const size_t row, + void extrapolateFlat(const API::MatrixWorkspace_sptr &ows, + const API::MatrixWorkspace_const_sptr &iwspt, + const size_t row, const std::pair<size_t, size_t> &indices, const bool doDerivs, std::vector<API::MatrixWorkspace_sptr> &derivs) const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h index 044afc59ba7b56844f47d60a76e4a998ec210484..122244214cc8484c970af6a281c85d20607fc472 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h @@ -87,7 +87,8 @@ private: const double *ysmooth) const; /// Use an existing fit function to tidy smoothing - void performAdditionalFitting(API::MatrixWorkspace_sptr ws, const int row); + void performAdditionalFitting(const API::MatrixWorkspace_sptr &ws, + const int row); /// Converts histogram data to point data later processing /// convert a binned workspace to point data. Uses mean of the bins as point diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h b/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h index 06e2bdf740111eca52ce6268d2ee7b6ca655100d..5a83c4b628ed43a92d79188b51484cda40db48e3 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Constraints/BoundaryConstraint.h @@ -35,12 +35,12 @@ public: BoundaryConstraint(const std::string ¶mName); /// Constructor with boundary arguments - BoundaryConstraint(API::IFunction *fun, const std::string paramName, + BoundaryConstraint(API::IFunction *fun, const std::string ¶mName, const double lowerBound, const double upperBound, bool isDefault = false); /// Constructor with lower boundary argument - BoundaryConstraint(API::IFunction *fun, const std::string paramName, + BoundaryConstraint(API::IFunction *fun, const std::string ¶mName, const double lowerBound, bool isDefault = false); /// Initialize the constraint from an expression diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h b/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h index 4b63b8d74e3b2028f3577130940b6b01c9eafda2..044d739a2ee15774a6c3c64037b46a7c2aab8e7b 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/CostFunctions/CostFuncRwp.h @@ -65,12 +65,12 @@ private: getFitWeights(API::FunctionValues_sptr values) const override; /// Get weight (1/sigma) - double getWeight(API::FunctionValues_sptr values, size_t i, + double getWeight(const API::FunctionValues_sptr &values, size_t i, double sqrtW = 1.0) const; /// Calcualte sqrt(W). Final cost function = sum_i [ (obs_i - cal_i) / (sigma /// * sqrt(W))]**2 - double calSqrtW(API::FunctionValues_sptr values) const; + double calSqrtW(const API::FunctionValues_sptr &values) const; friend class CurveFitting::SeqDomain; friend class CurveFitting::ParDomain; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h index 7e0abc27ffda2a67775139ac820464a664866e92..29f6560aeef34db60eb850c3f7a7ea2507d1724f 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ChebfunBase.h @@ -149,7 +149,7 @@ private: void calcIntegrationWeights() const; /// Calculate function values at odd-valued indices of the base x-points - std::vector<double> fitOdd(ChebfunFunctionType f, + std::vector<double> fitOdd(const ChebfunFunctionType &f, std::vector<double> &p) const; /// Calculate function values at odd-valued indices of the base x-points std::vector<double> fitOdd(const API::IFunction &f, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h index fa533e4bd7576c9dcc0c3ae1e9eb6c032b2121c7..4074de02293556ab543ad486556838515f7eaa04 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/IkedaCarpenterPV.h @@ -72,7 +72,7 @@ private: double &eta) const; /// constrain all parameters to be non-negative - void lowerConstraint0(std::string paramName); + void lowerConstraint0(const std::string ¶mName); }; } // namespace Functions diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h index bfa8e696ab8696d993ed9d98c00091e8597e4926..04a22d80889ba4de376403386dcff7ee3edb1e88 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/PawleyFunction.h @@ -134,7 +134,7 @@ public: PawleyParameterFunction_sptr getPawleyParameterFunction() const; protected: - void setPeakPositions(std::string centreName, double zeroShift, + void setPeakPositions(const std::string ¢reName, double zeroShift, const Geometry::UnitCell &cell) const; size_t calculateFunctionValues(const API::IPeakFunction_sptr &peak, diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h index 84387d058d436ec698564d34519c1a95ef54e2ae..e6c9144c2403f4d540f23714ee10220f24479a65 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ProcessBackground.h @@ -22,17 +22,18 @@ namespace Functions { class RemovePeaks { public: - void setup(DataObjects::TableWorkspace_sptr peaktablews); + void setup(const DataObjects::TableWorkspace_sptr &peaktablews); DataObjects::Workspace2D_sptr - removePeaks(API::MatrixWorkspace_const_sptr dataws, int wsindex, + removePeaks(const API::MatrixWorkspace_const_sptr &dataws, int wsindex, double numfwhm); private: /// Parse peak centre and FWHM from a table workspace - void parsePeakTableWorkspace(DataObjects::TableWorkspace_sptr peaktablews, - std::vector<double> &vec_peakcentre, - std::vector<double> &vec_peakfwhm); + void + parsePeakTableWorkspace(const DataObjects::TableWorkspace_sptr &peaktablews, + std::vector<double> &vec_peakcentre, + std::vector<double> &vec_peakfwhm); /// Exclude peak regions size_t excludePeaks(std::vector<double> v_inX, std::vector<bool> &v_useX, @@ -83,15 +84,15 @@ private: /// Select background points automatically DataObjects::Workspace2D_sptr - autoBackgroundSelection(DataObjects::Workspace2D_sptr bkgdWS); + autoBackgroundSelection(const DataObjects::Workspace2D_sptr &bkgdWS); /// Create a background function from input properties BackgroundFunction_sptr - createBackgroundFunction(const std::string backgroundtype); + createBackgroundFunction(const std::string &backgroundtype); /// Filter non-background data points out and create a background workspace DataObjects::Workspace2D_sptr - filterForBackground(BackgroundFunction_sptr bkgdfunction); + filterForBackground(const BackgroundFunction_sptr &bkgdfunction); DataObjects::Workspace2D_const_sptr m_dataWS; DataObjects::Workspace2D_sptr m_outputWS; @@ -119,7 +120,7 @@ private: /// Add a certain region from a reference workspace void addRegion(); - void fitBackgroundFunction(std::string bkgdfunctiontype); + void fitBackgroundFunction(const std::string &bkgdfunctiontype); }; } // namespace Functions diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h index 5f7a4a5a543f71d11692994f24f65fb78543b857..b8888d9eac2e6bde875b5f70448c70b4b1e6ba9f 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/SimpleChebfun.h @@ -25,7 +25,7 @@ public: /// Constructor. SimpleChebfun(size_t n, const API::IFunction &fun, double start, double end); /// Constructor. - SimpleChebfun(ChebfunFunctionType fun, double start, double end, + SimpleChebfun(const ChebfunFunctionType &fun, double start, double end, double accuracy = 0.0, size_t badSize = 10); /// Constructor. SimpleChebfun(const API::IFunction &fun, double start, double end, @@ -67,11 +67,11 @@ public: /// Integrate the function on its interval double integrate() const; /// Add a C++ function to the function - SimpleChebfun &operator+=(ChebfunFunctionType fun); + SimpleChebfun &operator+=(const ChebfunFunctionType &fun); private: /// Constructor - SimpleChebfun(ChebfunBase_sptr base); + SimpleChebfun(const ChebfunBase_sptr &base); /// Underlying base that does actual job. ChebfunBase_sptr m_base; /// Function values at the chebfun x-points. diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h index 2b92d63f49a64ec1839b47c993603f2f46237bae..f9a3e219759782efce5c8be4a7cdb1bc7d6abd15 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/ThermalNeutronDtoTOFFunction.h @@ -40,7 +40,7 @@ public: /// Calculate function values void function1D(std::vector<double> &out, - const std::vector<double> xValues) const; + const std::vector<double> &xValues) const; protected: /// overwrite IFunction base class method, which declare function parameters diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h b/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h index 7729f450edc98bf0b158acce88f47172fab96736..25c64ab84184e7732b532fda0be7505110a59dd3 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/GSLFunctions.h @@ -27,7 +27,7 @@ Various GSL specific functions used GSL specific minimizers /// Structure to contain least squares data and used by GSL struct GSL_FitData { /// Constructor - GSL_FitData(boost::shared_ptr<CostFunctions::CostFuncLeastSquares> cf); + GSL_FitData(const boost::shared_ptr<CostFunctions::CostFuncLeastSquares> &cf); /// Destructor ~GSL_FitData(); /// number of points to be fitted (size of X, Y and sqrtWeightData arrays) diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h b/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h index 52bc6422ba7c0dfd48640896148f76464603ebfa..fb1fca9f1d183e0f57e720a0291601d5dbaa865e 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/IMWDomainCreator.h @@ -15,6 +15,7 @@ #include <boost/weak_ptr.hpp> #include <list> +#include <utility> namespace Mantid { namespace API { @@ -53,7 +54,7 @@ public: /// Set the workspace /// @param ws :: workspace to set. void setWorkspace(boost::shared_ptr<API::MatrixWorkspace> ws) { - m_matrixWorkspace = ws; + m_matrixWorkspace = std::move(ws); } /// Set the workspace index /// @param wi :: workspace index to set. @@ -92,7 +93,7 @@ protected: const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const; + const boost::shared_ptr<API::FunctionValues> &resultValues) const; /// Store workspace property name std::string m_workspacePropertyName; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h index 8fe95df9b20ae34f15f42c4f49f93cdb155b8919..7fcffd154851a3d6e092f584083e744f6a84c5cf 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomain.h @@ -38,7 +38,7 @@ public: virtual void getDomainAndValues(size_t i, API::FunctionDomain_sptr &domain, API::FunctionValues_sptr &values) const; /// Add new domain creator - void addCreator(API::IDomainCreator_sptr creator); + void addCreator(const API::IDomainCreator_sptr &creator); /// Calculate the value of an additive cost function virtual void additiveCostFunctionVal(const CostFunctions::CostFuncFitting &costFunction); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h index 419c8b1f2d2ec4f4cb70785921aba4b076ab6f1f..4a2d4bcc73c4391f0513474fbeb7388f1990b78b 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/SeqDomainSpectrumCreator.h @@ -49,7 +49,7 @@ public: protected: void setParametersFromPropertyManager(); - void setMatrixWorkspace(API::MatrixWorkspace_sptr matrixWorkspace); + void setMatrixWorkspace(const API::MatrixWorkspace_sptr &matrixWorkspace); bool histogramIsUsable(size_t i) const; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h b/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h index b656b1ece051dcfda721c3be6227bc887a702de4..3cb41d153268d38c2c2ade83187a4a1a2a4081f4 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/TableWorkspaceDomainCreator.h @@ -16,6 +16,7 @@ #include <boost/weak_ptr.hpp> #include <list> +#include <utility> namespace Mantid { namespace API { @@ -55,7 +56,9 @@ public: /// Set the workspace /// @param ws :: workspace to set. - void setWorkspace(API::ITableWorkspace_sptr ws) { m_tableWorkspace = ws; } + void setWorkspace(API::ITableWorkspace_sptr ws) { + m_tableWorkspace = std::move(ws); + } /// Set the startX and endX /// @param startX :: Start of the domain /// @param endX :: End of the domain @@ -88,7 +91,7 @@ private: /// Set all parameters void setParameters() const; /// Set the names of the X, Y and Error columns - void setXYEColumnNames(API::ITableWorkspace_sptr ws) const; + void setXYEColumnNames(const API::ITableWorkspace_sptr &ws) const; /// Creates the blank output workspace of the correct size boost::shared_ptr<API::MatrixWorkspace> createEmptyResultWS(const size_t nhistograms, const size_t nyvalues); @@ -109,9 +112,9 @@ private: const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const; + const boost::shared_ptr<API::FunctionValues> &resultValues) const; /// Check workspace is in the correct form - void setAndValidateWorkspace(API::Workspace_sptr ws) const; + void setAndValidateWorkspace(const API::Workspace_sptr &ws) const; /// Store workspace property name std::string m_workspacePropertyName; diff --git a/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp b/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp index 922def0043a672818ed576def4413b12afe5770e..0467eb66c2534f18e08e4f99a6b00cd2efaf9df9 100644 --- a/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/ConvolutionFit.cpp @@ -27,16 +27,17 @@ #include <algorithm> #include <cmath> +#include <utility> namespace { using namespace Mantid::API; using namespace Mantid::Kernel; using Mantid::MantidVec; -std::size_t numberOfFunctions(IFunction_sptr function, +std::size_t numberOfFunctions(const IFunction_sptr &function, const std::string &functionName); -std::size_t numberOfFunctions(CompositeFunction_sptr composite, +std::size_t numberOfFunctions(const CompositeFunction_sptr &composite, const std::string &functionName) { std::size_t count = 0; for (auto i = 0u; i < composite->nFunctions(); ++i) @@ -44,7 +45,7 @@ std::size_t numberOfFunctions(CompositeFunction_sptr composite, return count; } -std::size_t numberOfFunctions(IFunction_sptr function, +std::size_t numberOfFunctions(const IFunction_sptr &function, const std::string &functionName) { const auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); @@ -53,9 +54,10 @@ std::size_t numberOfFunctions(IFunction_sptr function, return function->name() == functionName ? 1 : 0; } -bool containsFunction(IFunction_sptr function, const std::string &functionName); +bool containsFunction(const IFunction_sptr &function, + const std::string &functionName); -bool containsFunction(CompositeFunction_sptr composite, +bool containsFunction(const CompositeFunction_sptr &composite, const std::string &functionName) { for (auto i = 0u; i < composite->nFunctions(); ++i) { if (containsFunction(composite->getFunction(i), functionName)) @@ -64,7 +66,7 @@ bool containsFunction(CompositeFunction_sptr composite, return false; } -bool containsFunction(IFunction_sptr function, +bool containsFunction(const IFunction_sptr &function, const std::string &functionName) { const auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); @@ -125,7 +127,7 @@ std::vector<T, Ts...> squareRootVector(const std::vector<T, Ts...> &vec) { IFunction_sptr extractFirstBackground(IFunction_sptr function); -IFunction_sptr extractFirstBackground(CompositeFunction_sptr composite) { +IFunction_sptr extractFirstBackground(const CompositeFunction_sptr &composite) { for (auto i = 0u; i < composite->nFunctions(); ++i) { auto background = extractFirstBackground(composite->getFunction(i)); if (background) @@ -145,7 +147,7 @@ IFunction_sptr extractFirstBackground(IFunction_sptr function) { } std::string extractBackgroundType(IFunction_sptr function) { - auto background = extractFirstBackground(function); + auto background = extractFirstBackground(std::move(function)); if (!background) return "None"; @@ -164,7 +166,7 @@ std::string extractBackgroundType(IFunction_sptr function) { std::vector<std::size_t> searchForFitParameters(const std::string &suffix, - ITableWorkspace_sptr tableWorkspace) { + const ITableWorkspace_sptr &tableWorkspace) { auto indices = std::vector<std::size_t>(); for (auto i = 0u; i < tableWorkspace->columnCount(); ++i) { diff --git a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp index 00cbc81571d621fe7b1c710ab4c0c6b8f1c6e09c..1c9273de67940701987a74ddcff37af9814db1a5 100644 --- a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp +++ b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp @@ -138,9 +138,8 @@ public: std::vector<GSLVector> getParams() const { std::vector<GSLVector> res; res.reserve(m_params.size()); - for (auto &it : m_params) { - res.emplace_back(it.second); - } + std::transform(m_params.begin(), m_params.end(), std::back_inserter(res), + [](const auto &it) { return it.second; }); return res; } }; @@ -383,12 +382,12 @@ void EstimateFitParameters::execConcrete() { continue; } auto constraint = func->getConstraint(i); - if (constraint == nullptr) { + if (!constraint) { func->fix(i); continue; } auto boundary = dynamic_cast<Constraints::BoundaryConstraint *>(constraint); - if (boundary == nullptr) { + if (!boundary) { throw std::runtime_error("Parameter " + func->parameterName(i) + " must have a boundary constraint. "); } diff --git a/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp b/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp index bcb3d9f203c734b1080c9c7977a0e3420e5d9742..6a877355610cd870d92d49b448a515f9b6231c15 100644 --- a/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp +++ b/Framework/CurveFitting/src/Algorithms/EstimatePeakErrors.cpp @@ -91,7 +91,7 @@ GSLMatrix makeJacobian(IPeakFunction &peak, double ¢re, double &height, /// @param covariance :: The covariance matrix for the parameters of the peak. /// @param prefix :: A prefix for the parameter names. void calculatePeakValues(IPeakFunction &peak, ITableWorkspace &results, - const GSLMatrix covariance, + const GSLMatrix &covariance, const std::string &prefix) { double centre, height, fwhm, intensity; GSLMatrix J = makeJacobian(peak, centre, height, fwhm, intensity); diff --git a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp index 16f1357a3fe5f7e00504b2b24d6c64f51a092f48..06bd9665443a40cf43cff10463e9ddb680d4d365 100644 --- a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp +++ b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp @@ -36,6 +36,8 @@ #include <fstream> #include <cmath> +#include <utility> + #include <gsl/gsl_sf_erf.h> /// Factor on FWHM for fitting a peak @@ -520,11 +522,10 @@ void FitPowderDiffPeaks::fitPeaksRobust() { /** Observe peak range with hint from right peak's properties * Assumption: the background is reasonably flat within peak range */ -void FitPowderDiffPeaks::observePeakRange(BackToBackExponential_sptr thispeak, - BackToBackExponential_sptr rightpeak, - double refpeakshift, - double &peakleftbound, - double &peakrightbound) { +void FitPowderDiffPeaks::observePeakRange( + const BackToBackExponential_sptr &thispeak, + const BackToBackExponential_sptr &rightpeak, double refpeakshift, + double &peakleftbound, double &peakrightbound) { double predictcentre = thispeak->centre(); double rightfwhm = rightpeak->fwhm(); @@ -607,9 +608,10 @@ void FitPowderDiffPeaks::observePeakRange(BackToBackExponential_sptr thispeak, * Return: chi2 ... all the other parameter should be just in peak */ bool FitPowderDiffPeaks::fitSinglePeakRobust( - BackToBackExponential_sptr peak, BackgroundFunction_sptr backgroundfunction, - double peakleftbound, double peakrightbound, - map<string, double> rightpeakparammap, double &finalchi2) { + const BackToBackExponential_sptr &peak, + const BackgroundFunction_sptr &backgroundfunction, double peakleftbound, + double peakrightbound, const map<string, double> &rightpeakparammap, + double &finalchi2) { // 1. Build partial workspace Workspace2D_sptr peakws = buildPartialWorkspace(m_dataWS, m_wsIndex, peakleftbound, peakrightbound); @@ -836,8 +838,9 @@ bool FitPowderDiffPeaks::fitSinglePeakRobust( * Note 1: in a limited range (4*FWHM) */ bool FitPowderDiffPeaks::doFit1PeakBackground( - Workspace2D_sptr dataws, size_t wsindex, BackToBackExponential_sptr peak, - BackgroundFunction_sptr backgroundfunction, double &chi2) { + const Workspace2D_sptr &dataws, size_t wsindex, + const BackToBackExponential_sptr &peak, + const BackgroundFunction_sptr &backgroundfunction, double &chi2) { // 0. Set fit parameters string minimzername("Levenberg-MarquardtMD"); double startx = peak->centre() - 3.0 * peak->fwhm(); @@ -904,7 +907,7 @@ bool FitPowderDiffPeaks::doFit1PeakBackground( /** Fit signle peak by Monte Carlo/simulated annealing */ bool FitPowderDiffPeaks::fitSinglePeakSimulatedAnnealing( - BackToBackExponential_sptr peak, vector<string> paramtodomc) { + const BackToBackExponential_sptr &peak, const vector<string> ¶mtodomc) { UNUSED_ARG(peak); UNUSED_ARG(paramtodomc); throw runtime_error("To Be Implemented Soon!"); @@ -1218,8 +1221,9 @@ void FitPowderDiffPeaks::fitPeaksWithGoodStartingValues() { * @param annhilatedpeak :: (output) annhilatedpeak */ bool FitPowderDiffPeaks::fitSinglePeakConfident( - BackToBackExponential_sptr peak, BackgroundFunction_sptr backgroundfunction, - double leftbound, double rightbound, double &chi2, bool &annhilatedpeak) { + const BackToBackExponential_sptr &peak, + const BackgroundFunction_sptr &backgroundfunction, double leftbound, + double rightbound, double &chi2, bool &annhilatedpeak) { // 1. Build the partial workspace // a) Determine boundary if necessary if (leftbound < 0 || leftbound >= peak->centre()) @@ -1518,8 +1522,8 @@ void FitPowderDiffPeaks::calculatePeakFitBoundary(size_t ileftpeak, *negative, then no constraint */ std::pair<bool, double> -FitPowderDiffPeaks::doFitPeak(Workspace2D_sptr dataws, - BackToBackExponential_sptr peakfunction, +FitPowderDiffPeaks::doFitPeak(const Workspace2D_sptr &dataws, + const BackToBackExponential_sptr &peakfunction, double guessedfwhm) { // 1. Set up boundary if (guessedfwhm > 0) { @@ -1624,7 +1628,7 @@ FitPowderDiffPeaks::doFitPeak(Workspace2D_sptr dataws, /** Store the function's parameter values to a map */ void FitPowderDiffPeaks::storeFunctionParameters( - IFunction_sptr function, std::map<string, double> ¶mmaps) { + const IFunction_sptr &function, std::map<string, double> ¶mmaps) { vector<string> paramnames = function->getParameterNames(); parammaps.clear(); for (auto ¶mname : paramnames) @@ -1635,7 +1639,7 @@ void FitPowderDiffPeaks::storeFunctionParameters( /** Restore the function's parameter values from a map */ void FitPowderDiffPeaks::restoreFunctionParameters( - IFunction_sptr function, map<string, double> parammap) { + const IFunction_sptr &function, map<string, double> parammap) { vector<string> paramnames = function->getParameterNames(); for (auto &parname : paramnames) { auto miter = parammap.find(parname); @@ -1658,8 +1662,8 @@ void FitPowderDiffPeaks::restoreFunctionParameters( * 2. chi2 */ bool FitPowderDiffPeaks::doFit1PeakSimple( - Workspace2D_sptr dataws, size_t workspaceindex, - BackToBackExponential_sptr peakfunction, string minimzername, + const Workspace2D_sptr &dataws, size_t workspaceindex, + const BackToBackExponential_sptr &peakfunction, const string &minimzername, size_t maxiteration, double &chi2) { stringstream dbss; dbss << peakfunction->asString() << '\n'; @@ -1728,9 +1732,10 @@ bool FitPowderDiffPeaks::doFit1PeakSimple( * @param chi2 :: The chi squared value (output) */ bool FitPowderDiffPeaks::doFit1PeakSequential( - Workspace2D_sptr dataws, size_t workspaceindex, - BackToBackExponential_sptr peakfunction, vector<string> minimzernames, - vector<size_t> maxiterations, vector<double> dampfactors, double &chi2) { + const Workspace2D_sptr &dataws, size_t workspaceindex, + const BackToBackExponential_sptr &peakfunction, + vector<string> minimzernames, vector<size_t> maxiterations, + const vector<double> &dampfactors, double &chi2) { // 1. Check if (minimzernames.size() != maxiterations.size() && minimzernames.size() != dampfactors.size()) { @@ -1789,11 +1794,10 @@ bool FitPowderDiffPeaks::doFit1PeakSequential( //---------------------------------------------------------------------------- /** Fit background-removed peak by Gaussian */ -bool FitPowderDiffPeaks::doFitGaussianPeak(DataObjects::Workspace2D_sptr dataws, - size_t workspaceindex, - double in_center, double leftfwhm, - double rightfwhm, double ¢er, - double &sigma, double &height) { +bool FitPowderDiffPeaks::doFitGaussianPeak( + const DataObjects::Workspace2D_sptr &dataws, size_t workspaceindex, + double in_center, double leftfwhm, double rightfwhm, double ¢er, + double &sigma, double &height) { // 1. Estimate const auto &X = dataws->x(workspaceindex); const auto &Y = dataws->y(workspaceindex); @@ -1873,7 +1877,7 @@ bool FitPowderDiffPeaks::doFitGaussianPeak(DataObjects::Workspace2D_sptr dataws, */ bool FitPowderDiffPeaks::fitOverlappedPeaks( vector<BackToBackExponential_sptr> peaks, - BackgroundFunction_sptr backgroundfunction, double gfwhm) { + const BackgroundFunction_sptr &backgroundfunction, double gfwhm) { // 1. Sort peak if necessary vector<pair<double, BackToBackExponential_sptr>> tofpeakpairs(peaks.size()); for (size_t i = 0; i < peaks.size(); ++i) @@ -1951,7 +1955,8 @@ bool FitPowderDiffPeaks::fitOverlappedPeaks( /** Fit multiple (overlapped) peaks */ bool FitPowderDiffPeaks::doFitMultiplePeaks( - Workspace2D_sptr dataws, size_t wsindex, CompositeFunction_sptr peaksfunc, + const Workspace2D_sptr &dataws, size_t wsindex, + const CompositeFunction_sptr &peaksfunc, vector<BackToBackExponential_sptr> peakfuncs, vector<bool> &vecfitgood, vector<double> &vecchi2s) { // 0. Pre-debug output @@ -2062,7 +2067,7 @@ bool FitPowderDiffPeaks::doFitMultiplePeaks( * @param peaks :: A vector of instances of BackToBackExponential function */ void FitPowderDiffPeaks::estimatePeakHeightsLeBail( - Workspace2D_sptr dataws, size_t wsindex, + const Workspace2D_sptr &dataws, size_t wsindex, vector<BackToBackExponential_sptr> peaks) { // 1. Build data structures FunctionDomain1DVector domain(dataws->x(wsindex).rawData()); @@ -2110,7 +2115,7 @@ void FitPowderDiffPeaks::estimatePeakHeightsLeBail( /** Set constraints on a group of overlapped peaks for fitting */ void FitPowderDiffPeaks::setOverlappedPeaksConstraints( - vector<BackToBackExponential_sptr> peaks) { + const vector<BackToBackExponential_sptr> &peaks) { for (const auto &thispeak : peaks) { // 1. Set constraint on X. double fwhm = thispeak->fwhm(); @@ -2128,9 +2133,10 @@ void FitPowderDiffPeaks::setOverlappedPeaksConstraints( /** Fit N overlapped peaks in a simple manner */ bool FitPowderDiffPeaks::doFitNPeaksSimple( - Workspace2D_sptr dataws, size_t wsindex, CompositeFunction_sptr peaksfunc, - vector<BackToBackExponential_sptr> peakfuncs, string minimizername, - size_t maxiteration, double &chi2) { + const Workspace2D_sptr &dataws, size_t wsindex, + const CompositeFunction_sptr &peaksfunc, + const vector<BackToBackExponential_sptr> &peakfuncs, + const string &minimizername, size_t maxiteration, double &chi2) { // 1. Debug output stringstream dbss0; dbss0 << "Starting Value: "; @@ -2190,8 +2196,9 @@ bool FitPowderDiffPeaks::doFitNPeaksSimple( //---------------------------------------------------------------------------------------------- /** Parse fit result */ -std::string FitPowderDiffPeaks::parseFitResult(API::IAlgorithm_sptr fitalg, - double &chi2, bool &fitsuccess) { +std::string +FitPowderDiffPeaks::parseFitResult(const API::IAlgorithm_sptr &fitalg, + double &chi2, bool &fitsuccess) { stringstream rss; chi2 = fitalg->getProperty("OutputChi2overDoF"); @@ -2209,7 +2216,7 @@ std::string FitPowderDiffPeaks::parseFitResult(API::IAlgorithm_sptr fitalg, /** Parse parameter workspace returned from Fit() */ std::string FitPowderDiffPeaks::parseFitParameterWorkspace( - API::ITableWorkspace_sptr paramws) { + const API::ITableWorkspace_sptr ¶mws) { // 1. Check if (!paramws) { g_log.warning() << "Input table workspace is NULL. \n"; @@ -2239,7 +2246,7 @@ std::string FitPowderDiffPeaks::parseFitParameterWorkspace( * the diffrotometer geometry parameters */ void FitPowderDiffPeaks::importInstrumentParameterFromTable( - DataObjects::TableWorkspace_sptr parameterWS) { + const DataObjects::TableWorkspace_sptr ¶meterWS) { // 1. Check column orders std::vector<std::string> colnames = parameterWS->getColumnNames(); if (colnames.size() < 2) { @@ -2284,7 +2291,7 @@ void FitPowderDiffPeaks::importInstrumentParameterFromTable( /** Import Bragg peak table workspace */ void FitPowderDiffPeaks::parseBraggPeakTable( - TableWorkspace_sptr peakws, vector<map<string, double>> ¶mmaps, + const TableWorkspace_sptr &peakws, vector<map<string, double>> ¶mmaps, vector<map<string, int>> &hklmaps) { // 1. Get columns' types and names vector<string> paramnames = peakws->getColumnNames(); @@ -2584,7 +2591,8 @@ FitPowderDiffPeaks::genPeakParametersWorkspace() { * Each peak within requirement will put into both (1) m_peaks and (2) * m_peaksmap */ -void FitPowderDiffPeaks::genPeaksFromTable(TableWorkspace_sptr peakparamws) { +void FitPowderDiffPeaks::genPeaksFromTable( + const TableWorkspace_sptr &peakparamws) { // Check and clear input and output if (!peakparamws) { stringstream errss; @@ -2729,7 +2737,7 @@ FitPowderDiffPeaks::genPeak(map<string, int> hklmap, newpeakptr->initialize(); // Check miller index (HKL) is a valid value in a miller indexes pool (hklmap) - good = getHKLFromMap(hklmap, hkl); + good = getHKLFromMap(std::move(hklmap), hkl); if (!good) { // Ignore and return return newpeakptr; @@ -2909,9 +2917,9 @@ FitPowderDiffPeaks::genPeak(map<string, int> hklmap, * @param peakfunction: function to plot * @param background: background of the peak */ -void FitPowderDiffPeaks::plotFunction(IFunction_sptr peakfunction, - BackgroundFunction_sptr background, - FunctionDomain1DVector domain) { +void FitPowderDiffPeaks::plotFunction(const IFunction_sptr &peakfunction, + const BackgroundFunction_sptr &background, + const FunctionDomain1DVector &domain) { // 1. Determine range const auto &vecX = m_dataWS->x(m_wsIndex); double x0 = domain[0]; @@ -3010,7 +3018,7 @@ void FitPowderDiffPeaks::cropWorkspace(double tofmin, double tofmax) { * Exception: throw runtime error if there is no such parameter * @param parname: parameter name to get from m_instrumentParameters */ -double FitPowderDiffPeaks::getParameter(string parname) { +double FitPowderDiffPeaks::getParameter(const string &parname) { map<string, double>::iterator mapiter; mapiter = m_instrumentParmaeters.find(parname); @@ -3033,10 +3041,9 @@ double FitPowderDiffPeaks::getParameter(string parname) { * @param leftbound: lower boundary of the source data * @param rightbound: upper boundary of the source data */ -Workspace2D_sptr -FitPowderDiffPeaks::buildPartialWorkspace(API::MatrixWorkspace_sptr sourcews, - size_t workspaceindex, - double leftbound, double rightbound) { +Workspace2D_sptr FitPowderDiffPeaks::buildPartialWorkspace( + const API::MatrixWorkspace_sptr &sourcews, size_t workspaceindex, + double leftbound, double rightbound) { // 1. Check const auto &X = sourcews->x(workspaceindex); const auto &Y = sourcews->y(workspaceindex); @@ -3093,7 +3100,7 @@ FitPowderDiffPeaks::buildPartialWorkspace(API::MatrixWorkspace_sptr sourcews, /** Get function parameter values information and returned as a string * @param function: function to have information written out */ -string getFunctionInfo(IFunction_sptr function) { +string getFunctionInfo(const IFunction_sptr &function) { stringstream outss; vector<string> parnames = function->getParameterNames(); size_t numpars = parnames.size(); @@ -3117,8 +3124,8 @@ string getFunctionInfo(IFunction_sptr function) { * @param wsindexpeak: workspace index of spectrum holding pure peak data (with * background removed) */ -void estimateBackgroundCoarse(DataObjects::Workspace2D_sptr dataws, - BackgroundFunction_sptr background, +void estimateBackgroundCoarse(const DataObjects::Workspace2D_sptr &dataws, + const BackgroundFunction_sptr &background, size_t wsindexraw, size_t wsindexbkgd, size_t wsindexpeak) { // 1. Get prepared @@ -3192,7 +3199,7 @@ void estimateBackgroundCoarse(DataObjects::Workspace2D_sptr dataws, * @param fwhm :: (output) peak FWHM * @param errmsg :: (output) error message */ -bool observePeakParameters(Workspace2D_sptr dataws, size_t wsindex, +bool observePeakParameters(const Workspace2D_sptr &dataws, size_t wsindex, double ¢re, double &height, double &fwhm, string &errmsg) { // 1. Get the value of the Max Height @@ -3306,7 +3313,7 @@ size_t findMaxValue(const std::vector<double> &Y) { * @param rightbound :: upper constraint for check * @return the index of the maximum value */ -size_t findMaxValue(MatrixWorkspace_sptr dataws, size_t wsindex, +size_t findMaxValue(const MatrixWorkspace_sptr &dataws, size_t wsindex, double leftbound, double rightbound) { const auto &X = dataws->x(wsindex); const auto &Y = dataws->y(wsindex); diff --git a/Framework/CurveFitting/src/Algorithms/IqtFit.cpp b/Framework/CurveFitting/src/Algorithms/IqtFit.cpp index a07141bd11e6ba5f4e999c81e6ab736c77ccb731..698f4868b3f1f330b45f6a417e6cf8bba1fff3d3 100644 --- a/Framework/CurveFitting/src/Algorithms/IqtFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/IqtFit.cpp @@ -17,7 +17,7 @@ using namespace Mantid::API; namespace { Mantid::Kernel::Logger g_log("IqtFit"); -MatrixWorkspace_sptr cropWorkspace(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr cropWorkspace(const MatrixWorkspace_sptr &workspace, double startX, double endX) { auto cropper = AlgorithmManager::Instance().create("CropWorkspace"); cropper->setLogging(false); @@ -30,7 +30,7 @@ MatrixWorkspace_sptr cropWorkspace(MatrixWorkspace_sptr workspace, return cropper->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr convertToHistogram(MatrixWorkspace_sptr workspace) { +MatrixWorkspace_sptr convertToHistogram(const MatrixWorkspace_sptr &workspace) { auto converter = AlgorithmManager::Instance().create("ConvertToHistogram"); converter->setLogging(false); converter->setAlwaysStoreInADS(false); @@ -43,8 +43,8 @@ MatrixWorkspace_sptr convertToHistogram(MatrixWorkspace_sptr workspace) { struct HistogramConverter { explicit HistogramConverter() : m_converted() {} - MatrixWorkspace_sptr operator()(MatrixWorkspace_sptr workspace, double startX, - double endX) const { + MatrixWorkspace_sptr operator()(const MatrixWorkspace_sptr &workspace, + double startX, double endX) const { auto it = m_converted.find(workspace.get()); if (it != m_converted.end()) return it->second; diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp index e793fecd3a4f41d158b1d6c408c6ea8904ebfa07..38b2f5b3f91c4788d2956868534211255cff763c 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp @@ -763,7 +763,8 @@ void LeBailFit::createLeBailFunction() { * @param wsindex: workspace index of the data to fit against */ API::MatrixWorkspace_sptr -LeBailFit::cropWorkspace(API::MatrixWorkspace_sptr inpws, size_t wsindex) { +LeBailFit::cropWorkspace(const API::MatrixWorkspace_sptr &inpws, + size_t wsindex) { // Process input property 'FitRegion' for range of data to fit/calculate std::vector<double> fitrange = this->getProperty("FitRegion"); @@ -1143,9 +1144,9 @@ void LeBailFit::parseBraggPeaksParametersTable() { /** Parse table workspace (from Fit()) containing background parameters to a * vector */ -void LeBailFit::parseBackgroundTableWorkspace(TableWorkspace_sptr bkgdparamws, - vector<string> &bkgdparnames, - vector<double> &bkgdorderparams) { +void LeBailFit::parseBackgroundTableWorkspace( + const TableWorkspace_sptr &bkgdparamws, vector<string> &bkgdparnames, + vector<double> &bkgdorderparams) { g_log.debug() << "DB1105A Parsing background TableWorkspace.\n"; // Clear (output) map @@ -1746,7 +1747,7 @@ void LeBailFit::doMarkovChain( * @param tablews :: TableWorkspace containing the Monte Carlo setup */ void LeBailFit::setupRandomWalkStrategyFromTable( - DataObjects::TableWorkspace_sptr tablews) { + const DataObjects::TableWorkspace_sptr &tablews) { g_log.information("Set up random walk strategy from table."); // Scan the table @@ -1941,7 +1942,7 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { *list */ void LeBailFit::addParameterToMCMinimize(vector<string> &parnamesforMC, - string parname) { + const string &parname) { map<string, Parameter>::iterator pariter; pariter = m_funcParameters.find(parname); if (pariter == m_funcParameters.end()) { @@ -2094,7 +2095,7 @@ bool LeBailFit::calculateDiffractionPattern(const HistogramX &vecX, *proposed new values in * this group */ -bool LeBailFit::proposeNewValues(vector<string> mcgroup, Rfactor r, +bool LeBailFit::proposeNewValues(const vector<string> &mcgroup, Rfactor r, map<string, Parameter> &curparammap, map<string, Parameter> &newparammap, bool prevBetterRwp) { @@ -2414,7 +2415,7 @@ LeBailFit::convertToDoubleMap(std::map<std::string, Parameter> &inmap) { /** Write a set of (XY) data to a column file */ void writeRfactorsToFile(vector<double> vecX, vector<Rfactor> vecR, - string filename) { + const string &filename) { ofstream ofile; ofile.open(filename.c_str()); diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp index 8f87924d8e51706ff5ac83a85024b8d4331fa7ff..8488fa549072ed1db630d781f2cc06a21f717be7 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp @@ -14,6 +14,7 @@ #include "MantidKernel/System.h" #include <sstream> +#include <utility> #include <gsl/gsl_sf_erf.h> @@ -42,7 +43,7 @@ Kernel::Logger g_log("LeBailFunction"); //---------------------------------------------------------------------------------------------- /** Constructor */ -LeBailFunction::LeBailFunction(std::string peaktype) { +LeBailFunction::LeBailFunction(const std::string &peaktype) { // Set initial values to some class variables CompositeFunction_sptr m_function(new CompositeFunction()); m_compsiteFunction = m_function; @@ -169,7 +170,7 @@ HistogramY LeBailFunction::calPeak(size_t ipk, /** Check whether a parameter is a profile parameter * @param paramname :: parameter name to check with */ -bool LeBailFunction::hasProfileParameter(std::string paramname) { +bool LeBailFunction::hasProfileParameter(const std::string ¶mname) { auto fiter = lower_bound(m_orderedProfileParameterNames.cbegin(), m_orderedProfileParameterNames.cend(), paramname); @@ -619,8 +620,8 @@ bool LeBailFunction::calculateGroupPeakIntensities( * @param peakheight: height of the peak * @param setpeakheight: boolean as the option to set peak height or not. */ -void LeBailFunction::setPeakParameters(IPowderDiffPeakFunction_sptr peak, - map<string, double> parammap, +void LeBailFunction::setPeakParameters(const IPowderDiffPeakFunction_sptr &peak, + const map<string, double> ¶mmap, double peakheight, bool setpeakheight) { UNUSED_ARG(peak); UNUSED_ARG(parammap); @@ -855,7 +856,7 @@ void LeBailFunction::groupPeaks( * @param endx :: background's EndX. Used by Chebyshev */ void LeBailFunction::addBackgroundFunction( - string backgroundtype, const unsigned int &order, + const string &backgroundtype, const unsigned int &order, const std::vector<std::string> &vecparnames, const std::vector<double> &vecparvalues, double startx, double endx) { // Check @@ -911,8 +912,8 @@ void LeBailFunction::addBackgroundFunction( * @param minvalue :: lower boundary * @param maxvalue :: upper boundary */ -void LeBailFunction::setFitProfileParameter(string paramname, double minvalue, - double maxvalue) { +void LeBailFunction::setFitProfileParameter(const string ¶mname, + double minvalue, double maxvalue) { // Make ties in composition function for (size_t ipk = 1; ipk < m_numPeaks; ++ipk) { stringstream ss1, ss2; @@ -939,7 +940,8 @@ void LeBailFunction::setFitProfileParameter(string paramname, double minvalue, * @param paramname :: name of parameter * @param paramvalue :: value of parameter to be fixed to */ -void LeBailFunction::fixPeakParameter(string paramname, double paramvalue) { +void LeBailFunction::fixPeakParameter(const string ¶mname, + double paramvalue) { for (size_t ipk = 0; ipk < m_numPeaks; ++ipk) { stringstream ss1, ss2; ss1 << "f" << ipk << "." << paramname; @@ -987,7 +989,7 @@ void LeBailFunction::setFixPeakHeights() { /** Reset all peaks' height * @param inheights :: list of peak heights corresponding to each peak */ -void LeBailFunction::setPeakHeights(std::vector<double> inheights) { +void LeBailFunction::setPeakHeights(const std::vector<double> &inheights) { UNUSED_ARG(inheights); throw runtime_error("It is not implemented properly."); /* @@ -1026,7 +1028,7 @@ IPowderDiffPeakFunction_sptr LeBailFunction::getPeak(size_t peakindex) { /** Get value of one specific peak's parameter */ double LeBailFunction::getPeakParameter(std::vector<int> hkl, - std::string parname) const { + const std::string &parname) const { // Search peak in map map<vector<int>, IPowderDiffPeakFunction_sptr>::const_iterator fiter; fiter = m_mapHKLPeak.find(hkl); @@ -1040,7 +1042,7 @@ double LeBailFunction::getPeakParameter(std::vector<int> hkl, IPowderDiffPeakFunction_sptr peak = fiter->second; - double parvalue = getPeakParameterValue(peak, parname); + double parvalue = getPeakParameterValue(peak, std::move(parname)); return parvalue; } @@ -1049,7 +1051,7 @@ double LeBailFunction::getPeakParameter(std::vector<int> hkl, /** Get value of one specific peak's parameter */ double LeBailFunction::getPeakParameter(size_t index, - std::string parname) const { + const std::string &parname) const { if (index >= m_numPeaks) { stringstream errss; errss << "getPeakParameter() tries to reach a peak with index " << index @@ -1060,7 +1062,7 @@ double LeBailFunction::getPeakParameter(size_t index, } IPowderDiffPeakFunction_sptr peak = m_vecPeaks[index]; - double value = getPeakParameterValue(peak, parname); + double value = getPeakParameterValue(peak, std::move(parname)); return value; } @@ -1070,9 +1072,9 @@ double LeBailFunction::getPeakParameter(size_t index, * @param peak :: shared pointer to peak function * @param parname :: name of the peak parameter */ -double -LeBailFunction::getPeakParameterValue(API::IPowderDiffPeakFunction_sptr peak, - std::string parname) const { +double LeBailFunction::getPeakParameterValue( + const API::IPowderDiffPeakFunction_sptr &peak, + const std::string &parname) const { // Locate the category of the parameter name auto vsiter = lower_bound(m_orderedProfileParameterNames.cbegin(), m_orderedProfileParameterNames.cend(), parname); diff --git a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp index 844d1b3418a1b824134a251b91f5c724b4f55762..d051738dae1ea455805dea2a0b51e4fddb5c937e 100644 --- a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp +++ b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp @@ -431,7 +431,7 @@ boost::shared_ptr<Algorithm> PlotPeakByLogValue::runSingleFit( return fit; } -double PlotPeakByLogValue::calculateLogValue(std::string logName, +double PlotPeakByLogValue::calculateLogValue(const std::string &logName, const InputSpectraToFit &data) { double logValue = 0; if (logName.empty() || logName == "axis-1") { @@ -457,7 +457,7 @@ double PlotPeakByLogValue::calculateLogValue(std::string logName, return logValue; } -void PlotPeakByLogValue::setWorkspaceIndexAttribute(IFunction_sptr fun, +void PlotPeakByLogValue::setWorkspaceIndexAttribute(const IFunction_sptr &fun, int wsIndex) const { const std::string attName = "WorkspaceIndex"; if (fun->hasAttribute(attName)) { diff --git a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp index 3382a04eaa3d10649e82e51198b365fd20d31ed2..3e92ea95565d37ae9b5bbf56f36b51fda612e20e 100644 --- a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp +++ b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValueHelper.cpp @@ -85,8 +85,8 @@ void addMatrixworkspace( const boost::optional<API::Workspace_sptr> &workspaceOptional, const boost::shared_ptr<API::MatrixWorkspace> &wsMatrix); /// Create a list of input workspace names -std::vector<InputSpectraToFit> makeNames(std::string inputList, int default_wi, - int default_spec) { +std::vector<InputSpectraToFit> makeNames(const std::string &inputList, + int default_wi, int default_spec) { std::vector<InputSpectraToFit> nameList; double start = 0; @@ -212,7 +212,6 @@ std::vector<int> getWorkspaceIndicesFromAxes(API::MatrixWorkspace &ws, } } } else { // numeric axis - spectrumNumber = SpecialIndex::NOT_SET; if (workspaceIndex >= 0) { out.clear(); } else { diff --git a/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp b/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp index 2af32db01fe357eaed5c235e51b8175419dec99e..2e901f05f84296d1921ab532c09759670abc5759 100644 --- a/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp +++ b/Framework/CurveFitting/src/Algorithms/QENSFitSequential.cpp @@ -24,6 +24,7 @@ #include <sstream> #include <stdexcept> #include <unordered_map> +#include <utility> namespace { using namespace Mantid::API; @@ -39,8 +40,9 @@ MatrixWorkspace_sptr getADSMatrixWorkspace(const std::string &workspaceName) { workspaceName); } -MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace, - const std::string &outputName) { +MatrixWorkspace_sptr +convertSpectrumAxis(const MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputName) { auto convSpec = AlgorithmManager::Instance().create("ConvertSpectrumAxis"); convSpec->setLogging(false); convSpec->setProperty("InputWorkspace", inputWorkspace); @@ -53,16 +55,16 @@ MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace, return getADSMatrixWorkspace(outputName); } -MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr inputWorkspace, +MatrixWorkspace_sptr cloneWorkspace(const MatrixWorkspace_sptr &inputWorkspace, const std::string &outputName) { Workspace_sptr workspace = inputWorkspace->clone(); AnalysisDataService::Instance().addOrReplace(outputName, workspace); return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } -MatrixWorkspace_sptr convertToElasticQ(MatrixWorkspace_sptr inputWorkspace, - const std::string &outputName, - bool doThrow) { +MatrixWorkspace_sptr +convertToElasticQ(const MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputName, bool doThrow) { auto axis = inputWorkspace->getAxis(1); if (axis->isSpectra()) return convertSpectrumAxis(inputWorkspace, outputName); @@ -80,8 +82,8 @@ struct ElasticQAppender { explicit ElasticQAppender(std::vector<MatrixWorkspace_sptr> &elasticInput) : m_elasticInput(elasticInput), m_converted() {} - void operator()(MatrixWorkspace_sptr workspace, const std::string &outputBase, - bool doThrow) { + void operator()(const MatrixWorkspace_sptr &workspace, + const std::string &outputBase, bool doThrow) { auto it = m_converted.find(workspace.get()); if (it != m_converted.end()) m_elasticInput.emplace_back(it->second); @@ -111,13 +113,13 @@ convertToElasticQ(const std::vector<MatrixWorkspace_sptr> &workspaces, return elasticInput; } -void extractFunctionNames(CompositeFunction_sptr composite, +void extractFunctionNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) names.emplace_back(composite->getFunction(i)->name()); } -void extractFunctionNames(IFunction_sptr function, +void extractFunctionNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) @@ -126,16 +128,16 @@ void extractFunctionNames(IFunction_sptr function, names.emplace_back(function->name()); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names); -void extractConvolvedNames(CompositeFunction_sptr composite, +void extractConvolvedNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) extractConvolvedNames(composite->getFunction(i), names); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) { @@ -147,8 +149,8 @@ void extractConvolvedNames(IFunction_sptr function, } } -std::string constructInputString(MatrixWorkspace_sptr workspace, int specMin, - int specMax) { +std::string constructInputString(const MatrixWorkspace_sptr &workspace, + int specMin, int specMax) { std::ostringstream input; for (auto i = specMin; i < specMax + 1; ++i) input << workspace->getName() << ",i" << std::to_string(i) << ";"; @@ -170,9 +172,10 @@ std::vector<MatrixWorkspace_sptr> extractWorkspaces(const std::string &input) { std::vector<MatrixWorkspace_sptr> workspaces; - for (const auto &wsName : workspaceNames) { - workspaces.emplace_back(getADSMatrixWorkspace(wsName)); - } + std::transform(workspaceNames.begin(), workspaceNames.end(), + std::back_inserter(workspaces), [](const auto &wsName) { + return getADSMatrixWorkspace(wsName); + }); return workspaces; } @@ -203,14 +206,16 @@ replaceWorkspaces(const std::string &input, return newInput.str(); } -void renameWorkspace(IAlgorithm_sptr renamer, Workspace_sptr workspace, +void renameWorkspace(const IAlgorithm_sptr &renamer, + const Workspace_sptr &workspace, const std::string &newName) { renamer->setProperty("InputWorkspace", workspace); renamer->setProperty("OutputWorkspace", newName); renamer->executeAsChildAlg(); } -void deleteTemporaries(IAlgorithm_sptr deleter, const std::string &base) { +void deleteTemporaries(const IAlgorithm_sptr &deleter, + const std::string &base) { auto name = base + std::to_string(1); std::size_t i = 2; @@ -233,8 +238,8 @@ bool containsMultipleData(const std::vector<MatrixWorkspace_sptr> &workspaces) { } template <typename F, typename Renamer> -void renameWorkspacesWith(WorkspaceGroup_sptr groupWorkspace, F const &getName, - Renamer const &renamer) { +void renameWorkspacesWith(const WorkspaceGroup_sptr &groupWorkspace, + F const &getName, Renamer const &renamer) { std::unordered_map<std::string, std::size_t> nameCount; for (auto i = 0u; i < groupWorkspace->size(); ++i) { const auto name = getName(i); @@ -251,7 +256,7 @@ void renameWorkspacesWith(WorkspaceGroup_sptr groupWorkspace, F const &getName, template <typename F> void renameWorkspacesInQENSFit(Algorithm *qensFit, - IAlgorithm_sptr renameAlgorithm, + const IAlgorithm_sptr &renameAlgorithm, WorkspaceGroup_sptr outputGroup, std::string const &outputBaseName, std::string const &groupSuffix, @@ -263,8 +268,8 @@ void renameWorkspacesInQENSFit(Algorithm *qensFit, return outputBaseName + "_" + getNameSuffix(i); }; - auto renamer = [&](Workspace_sptr workspace, const std::string &name) { - renameWorkspace(renameAlgorithm, workspace, name); + auto renamer = [&](const Workspace_sptr &workspace, const std::string &name) { + renameWorkspace(renameAlgorithm, std::move(workspace), name); renamerProg.report("Renamed workspace in group."); }; renameWorkspacesWith(outputGroup, getName, renamer); @@ -541,9 +546,9 @@ void QENSFitSequential::exec() { getPropertyValue("OutputWorkspace"), resultWs); if (containsMultipleData(workspaces)) { - const auto inputString = getPropertyValue("Input"); + const auto inputStringProp = getPropertyValue("Input"); renameWorkspaces(groupWs, spectra, outputBaseName, "_Workspace", - extractWorkspaceNames(inputString)); + extractWorkspaceNames(inputStringProp)); } else { renameWorkspaces(groupWs, spectra, outputBaseName, "_Workspace"); } @@ -594,12 +599,14 @@ QENSFitSequential::getAdditionalLogNumbers() const { return logs; } -void QENSFitSequential::addAdditionalLogs(WorkspaceGroup_sptr resultWorkspace) { +void QENSFitSequential::addAdditionalLogs( + const WorkspaceGroup_sptr &resultWorkspace) { for (const auto &workspace : *resultWorkspace) addAdditionalLogs(workspace); } -void QENSFitSequential::addAdditionalLogs(Workspace_sptr resultWorkspace) { +void QENSFitSequential::addAdditionalLogs( + const Workspace_sptr &resultWorkspace) { auto logAdder = createChildAlgorithm("AddSampleLog", -1.0, -1.0, false); logAdder->setProperty("Workspace", resultWorkspace); @@ -678,7 +685,7 @@ std::vector<std::size_t> QENSFitSequential::getDatasetGrouping( } WorkspaceGroup_sptr QENSFitSequential::processIndirectFitParameters( - ITableWorkspace_sptr parameterWorkspace, + const ITableWorkspace_sptr ¶meterWorkspace, const std::vector<std::size_t> &grouping) { std::string const columnX = getProperty("LogName"); std::string const xAxisUnit = getProperty("ResultXAxisUnit"); @@ -708,8 +715,9 @@ void QENSFitSequential::renameWorkspaces( inputWorkspaceNames[i] + "_" + spectra[i] + endOfSuffix; return workspaceName; }; - return renameWorkspacesInQENSFit(this, rename, outputGroup, outputBaseName, - endOfSuffix + "s", getNameSuffix); + return renameWorkspacesInQENSFit(this, rename, std::move(outputGroup), + outputBaseName, endOfSuffix + "s", + getNameSuffix); } void QENSFitSequential::renameWorkspaces( @@ -717,8 +725,9 @@ void QENSFitSequential::renameWorkspaces( std::string const &outputBaseName, std::string const &endOfSuffix) { auto rename = createChildAlgorithm("RenameWorkspace", -1.0, -1.0, false); auto getNameSuffix = [&](std::size_t i) { return spectra[i] + endOfSuffix; }; - return renameWorkspacesInQENSFit(this, rename, outputGroup, outputBaseName, - endOfSuffix + "s", getNameSuffix); + return renameWorkspacesInQENSFit(this, rename, std::move(outputGroup), + outputBaseName, endOfSuffix + "s", + getNameSuffix); } void QENSFitSequential::renameGroupWorkspace( @@ -793,28 +802,31 @@ std::vector<MatrixWorkspace_sptr> QENSFitSequential::convertInputToElasticQ( } void QENSFitSequential::extractMembers( - WorkspaceGroup_sptr resultGroupWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<API::MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName) { std::vector<std::string> workspaceNames; - std::transform( - workspaces.begin(), workspaces.end(), std::back_inserter(workspaceNames), - [](API::MatrixWorkspace_sptr workspace) { return workspace->getName(); }); - - auto extractAlgorithm = extractMembersAlgorithm(resultGroupWs, outputWsName); + std::transform(workspaces.begin(), workspaces.end(), + std::back_inserter(workspaceNames), + [](const API::MatrixWorkspace_sptr &workspace) { + return workspace->getName(); + }); + + auto extractAlgorithm = + extractMembersAlgorithm(std::move(resultGroupWs), outputWsName); extractAlgorithm->setProperty("InputWorkspaces", workspaceNames); extractAlgorithm->execute(); } void QENSFitSequential::copyLogs( - WorkspaceGroup_sptr resultWorkspaces, + const WorkspaceGroup_sptr &resultWorkspaces, std::vector<MatrixWorkspace_sptr> const &workspaces) { for (auto const &resultWorkspace : *resultWorkspaces) copyLogs(resultWorkspace, workspaces); } void QENSFitSequential::copyLogs( - Workspace_sptr resultWorkspace, + const Workspace_sptr &resultWorkspace, std::vector<MatrixWorkspace_sptr> const &workspaces) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); logCopier->setProperty("OutputWorkspace", resultWorkspace->getName()); @@ -825,14 +837,14 @@ void QENSFitSequential::copyLogs( } } -void QENSFitSequential::copyLogs(MatrixWorkspace_sptr resultWorkspace, - WorkspaceGroup_sptr resultGroup) { +void QENSFitSequential::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const WorkspaceGroup_sptr &resultGroup) { for (auto const &workspace : *resultGroup) copyLogs(resultWorkspace, workspace); } -void QENSFitSequential::copyLogs(MatrixWorkspace_sptr resultWorkspace, - Workspace_sptr resultGroup) { +void QENSFitSequential::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const Workspace_sptr &resultGroup) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); logCopier->setProperty("InputWorkspace", resultWorkspace); logCopier->setProperty("OutputWorkspace", resultGroup->getName()); @@ -840,7 +852,8 @@ void QENSFitSequential::copyLogs(MatrixWorkspace_sptr resultWorkspace, } IAlgorithm_sptr QENSFitSequential::extractMembersAlgorithm( - WorkspaceGroup_sptr resultGroupWs, const std::string &outputWsName) const { + const WorkspaceGroup_sptr &resultGroupWs, + const std::string &outputWsName) const { const bool convolved = getProperty("ConvolveMembers"); std::vector<std::string> convolvedMembers; IFunction_sptr function = getProperty("Function"); diff --git a/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp b/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp index bf2d04b5dcc5377a6eee205aa3da9df51acde537..fd6aed132d21060a2a8f6a7db2f3a98bdb02ceba 100644 --- a/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp +++ b/Framework/CurveFitting/src/Algorithms/QENSFitSimultaneous.cpp @@ -24,19 +24,20 @@ #include "MantidKernel/UnitFactory.h" #include <boost/algorithm/string/join.hpp> +#include <utility> namespace { Mantid::Kernel::Logger g_log("QENSFit"); using namespace Mantid::API; -void extractFunctionNames(CompositeFunction_sptr composite, +void extractFunctionNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) names.emplace_back(composite->getFunction(i)->name()); } -void extractFunctionNames(IFunction_sptr function, +void extractFunctionNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) @@ -45,16 +46,16 @@ void extractFunctionNames(IFunction_sptr function, names.emplace_back(function->name()); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names); -void extractConvolvedNames(CompositeFunction_sptr composite, +void extractConvolvedNames(const CompositeFunction_sptr &composite, std::vector<std::string> &names) { for (auto i = 0u; i < composite->nFunctions(); ++i) extractConvolvedNames(composite->getFunction(i), names); } -void extractConvolvedNames(IFunction_sptr function, +void extractConvolvedNames(const IFunction_sptr &function, std::vector<std::string> &names) { auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); if (composite) { @@ -66,7 +67,8 @@ void extractConvolvedNames(IFunction_sptr function, } } -MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace) { +MatrixWorkspace_sptr +convertSpectrumAxis(const MatrixWorkspace_sptr &inputWorkspace) { auto convSpec = AlgorithmManager::Instance().create("ConvertSpectrumAxis"); convSpec->setLogging(false); convSpec->setChild(true); @@ -78,8 +80,8 @@ MatrixWorkspace_sptr convertSpectrumAxis(MatrixWorkspace_sptr inputWorkspace) { return convSpec->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr convertToElasticQ(MatrixWorkspace_sptr inputWorkspace, - bool doThrow) { +MatrixWorkspace_sptr +convertToElasticQ(const MatrixWorkspace_sptr &inputWorkspace, bool doThrow) { auto axis = inputWorkspace->getAxis(1); if (axis->isSpectra()) return convertSpectrumAxis(inputWorkspace); @@ -97,7 +99,7 @@ struct ElasticQAppender { explicit ElasticQAppender(std::vector<MatrixWorkspace_sptr> &elasticInput) : m_elasticInput(elasticInput), m_converted() {} - void operator()(MatrixWorkspace_sptr workspace, bool doThrow) { + void operator()(const MatrixWorkspace_sptr &workspace, bool doThrow) { auto it = m_converted.find(workspace.get()); if (it != m_converted.end()) m_elasticInput.emplace_back(it->second); @@ -130,7 +132,7 @@ std::string shortParameterName(const std::string &longName) { } void setMultiDataProperties(const IAlgorithm &qensFit, IAlgorithm &fit, - MatrixWorkspace_sptr workspace, + const MatrixWorkspace_sptr &workspace, const std::string &suffix) { fit.setProperty("InputWorkspace" + suffix, workspace); @@ -163,7 +165,7 @@ IFunction_sptr convertToSingleDomain(IFunction_sptr function) { return function; } -WorkspaceGroup_sptr makeGroup(Workspace_sptr workspace) { +WorkspaceGroup_sptr makeGroup(const Workspace_sptr &workspace) { auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(workspace); if (group) return group; @@ -172,7 +174,7 @@ WorkspaceGroup_sptr makeGroup(Workspace_sptr workspace) { return group; } -ITableWorkspace_sptr transposeFitTable(ITableWorkspace_sptr table, +ITableWorkspace_sptr transposeFitTable(const ITableWorkspace_sptr &table, const IFunction &function, const std::string &yAxisType) { auto transposed = WorkspaceFactory::Instance().createTable(); @@ -496,7 +498,7 @@ QENSFitSimultaneous::performFit( } WorkspaceGroup_sptr QENSFitSimultaneous::processIndirectFitParameters( - ITableWorkspace_sptr parameterWorkspace, + const ITableWorkspace_sptr ¶meterWorkspace, const std::vector<std::size_t> &grouping) { std::string const xAxisUnit = getProperty("ResultXAxisUnit"); auto pifp = @@ -511,7 +513,7 @@ WorkspaceGroup_sptr QENSFitSimultaneous::processIndirectFitParameters( } void QENSFitSimultaneous::copyLogs( - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, const std::vector<MatrixWorkspace_sptr> &workspaces) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); for (auto &&result : *resultWorkspace) { @@ -525,8 +527,8 @@ void QENSFitSimultaneous::copyLogs( } } -void QENSFitSimultaneous::copyLogs(MatrixWorkspace_sptr resultWorkspace, - WorkspaceGroup_sptr resultGroup) { +void QENSFitSimultaneous::copyLogs(const MatrixWorkspace_sptr &resultWorkspace, + const WorkspaceGroup_sptr &resultGroup) { auto logCopier = createChildAlgorithm("CopyLogs", -1.0, -1.0, false); logCopier->setProperty("InputWorkspace", resultWorkspace); @@ -539,7 +541,7 @@ void QENSFitSimultaneous::copyLogs(MatrixWorkspace_sptr resultWorkspace, } void QENSFitSimultaneous::extractMembers( - WorkspaceGroup_sptr resultGroupWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<MatrixWorkspace_sptr> &workspaces, const std::string &outputWsName) { std::vector<std::string> workspaceNames; @@ -549,7 +551,8 @@ void QENSFitSimultaneous::extractMembers( workspaceNames.emplace_back(name); } - auto extractAlgorithm = extractMembersAlgorithm(resultGroupWs, outputWsName); + auto extractAlgorithm = + extractMembersAlgorithm(std::move(resultGroupWs), outputWsName); extractAlgorithm->setProperty("InputWorkspaces", workspaceNames); extractAlgorithm->execute(); @@ -557,12 +560,14 @@ void QENSFitSimultaneous::extractMembers( AnalysisDataService::Instance().remove(workspaceName); } -void QENSFitSimultaneous::addAdditionalLogs(API::WorkspaceGroup_sptr group) { +void QENSFitSimultaneous::addAdditionalLogs( + const API::WorkspaceGroup_sptr &group) { for (auto &&workspace : *group) addAdditionalLogs(workspace); } -void QENSFitSimultaneous::addAdditionalLogs(Workspace_sptr resultWorkspace) { +void QENSFitSimultaneous::addAdditionalLogs( + const Workspace_sptr &resultWorkspace) { auto logAdder = createChildAlgorithm("AddSampleLog", -1.0, -1.0, false); logAdder->setProperty("Workspace", resultWorkspace); @@ -585,7 +590,8 @@ void QENSFitSimultaneous::addAdditionalLogs(Workspace_sptr resultWorkspace) { } IAlgorithm_sptr QENSFitSimultaneous::extractMembersAlgorithm( - WorkspaceGroup_sptr resultGroupWs, const std::string &outputWsName) const { + const WorkspaceGroup_sptr &resultGroupWs, + const std::string &outputWsName) const { const bool convolved = getProperty("ConvolveMembers"); std::vector<std::string> convolvedMembers; IFunction_sptr function = getProperty("Function"); @@ -697,7 +703,7 @@ ITableWorkspace_sptr QENSFitSimultaneous::processParameterTable( } void QENSFitSimultaneous::renameWorkspaces( - API::WorkspaceGroup_sptr outputGroup, + const API::WorkspaceGroup_sptr &outputGroup, std::vector<std::string> const &spectra, std::string const &outputBaseName, std::string const &endOfSuffix, std::vector<std::string> const &inputWorkspaceNames) { @@ -707,8 +713,9 @@ void QENSFitSimultaneous::renameWorkspaces( inputWorkspaceNames[i] + "_" + spectra[i] + endOfSuffix; return workspaceName; }; - return renameWorkspacesInQENSFit(this, rename, outputGroup, outputBaseName, - endOfSuffix + "s", getNameSuffix); + return renameWorkspacesInQENSFit(this, rename, std::move(outputGroup), + outputBaseName, endOfSuffix + "s", + getNameSuffix); } } // namespace Algorithms diff --git a/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp b/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp index 171b3c5c71a3e115d9c8858c4208533d3bbd02f5..cee9bf1ef7245029624ce5c8956e9d801e8bd3b2 100644 --- a/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp +++ b/Framework/CurveFitting/src/Algorithms/QENSFitUtilities.cpp @@ -6,11 +6,13 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "MantidCurveFitting/Algorithms/QENSFitUtilities.h" #include <unordered_map> +#include <utility> + namespace Mantid { namespace API { void renameWorkspacesWith( - WorkspaceGroup_sptr groupWorkspace, + const WorkspaceGroup_sptr &groupWorkspace, std::function<std::string(std::size_t)> const &getName, std::function<void(Workspace_sptr, const std::string &)> const &renamer) { std::unordered_map<std::string, std::size_t> nameCount; @@ -27,7 +29,8 @@ void renameWorkspacesWith( } } -void renameWorkspace(IAlgorithm_sptr renamer, Workspace_sptr workspace, +void renameWorkspace(const IAlgorithm_sptr &renamer, + const Workspace_sptr &workspace, const std::string &newName) { renamer->setProperty("InputWorkspace", workspace); renamer->setProperty("OutputWorkspace", newName); @@ -43,7 +46,7 @@ bool containsMultipleData(const std::vector<MatrixWorkspace_sptr> &workspaces) { void renameWorkspacesInQENSFit( Algorithm *qensFit, IAlgorithm_sptr renameAlgorithm, - WorkspaceGroup_sptr outputGroup, std::string const &outputBaseName, + const WorkspaceGroup_sptr &outputGroup, std::string const &outputBaseName, std::string const &, std::function<std::string(std::size_t)> const &getNameSuffix) { Progress renamerProg(qensFit, 0.98, 1.0, outputGroup->size() + 1); @@ -54,8 +57,8 @@ void renameWorkspacesInQENSFit( return name; }; - auto renamer = [&](Workspace_sptr workspace, const std::string &name) { - renameWorkspace(renameAlgorithm, workspace, name); + auto renamer = [&](const Workspace_sptr &workspace, const std::string &name) { + renameWorkspace(renameAlgorithm, std::move(workspace), name); renamerProg.report("Renamed workspace in group."); }; renameWorkspacesWith(outputGroup, getName, renamer); diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp index 6fde7cc57b5b92f46d11242805f54a35ad1d225d..4672c0352d7b97db014456fd2da21fb784b735ff 100644 --- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp +++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp @@ -34,6 +34,7 @@ #include <fstream> #include <iomanip> +#include <utility> #include <gsl/gsl_sf_erf.h> @@ -383,7 +384,7 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() { /** Fit function to data */ -bool RefinePowderInstrumentParameters::fitFunction(IFunction_sptr func, +bool RefinePowderInstrumentParameters::fitFunction(const IFunction_sptr &func, double &gslchi2) { API::IAlgorithm_sptr fitalg = createChildAlgorithm("Fit", 0.0, 0.2, true); fitalg->initialize(); @@ -417,7 +418,8 @@ bool RefinePowderInstrumentParameters::fitFunction(IFunction_sptr func, /** Calculate function's statistic */ double RefinePowderInstrumentParameters::calculateFunctionStatistic( - IFunction_sptr func, MatrixWorkspace_sptr dataws, size_t workspaceindex) { + const IFunction_sptr &func, const MatrixWorkspace_sptr &dataws, + size_t workspaceindex) { // 1. Fix all parameters of the function vector<string> funcparameters = func->getParameterNames(); size_t numparams = funcparameters.size(); @@ -456,14 +458,15 @@ double RefinePowderInstrumentParameters::calculateFunctionStatistic( /** Refine instrument parameters by Monte Carlo method */ void RefinePowderInstrumentParameters::refineInstrumentParametersMC( - TableWorkspace_sptr parameterWS, bool fit2) { + const TableWorkspace_sptr ¶meterWS, bool fit2) { // 1. Get function's parameter names getD2TOFFuncParamNames(m_PeakFunctionParameterNames); // 2. Parse parameter (table) workspace vector<double> stepsizes, lowerbounds, upperbounds; - importMonteCarloParametersFromTable(parameterWS, m_PeakFunctionParameterNames, - stepsizes, lowerbounds, upperbounds); + importMonteCarloParametersFromTable(std::move(parameterWS), + m_PeakFunctionParameterNames, stepsizes, + lowerbounds, upperbounds); stringstream dbss; for (size_t i = 0; i < m_PeakFunctionParameterNames.size(); ++i) { @@ -779,7 +782,7 @@ void RefinePowderInstrumentParameters::getD2TOFFuncParamNames( /** Calculate the function */ double RefinePowderInstrumentParameters::calculateD2TOFFunction( - API::IFunction_sptr func, API::FunctionDomain1DVector domain, + const API::IFunction_sptr &func, const API::FunctionDomain1DVector &domain, API::FunctionValues &values, const Mantid::HistogramData::HistogramY &rawY, const Mantid::HistogramData::HistogramE &rawE) { // 1. Check validity @@ -814,7 +817,7 @@ double RefinePowderInstrumentParameters::calculateD2TOFFunction( * m_Peaks are stored in a map. (HKL) is the key */ void RefinePowderInstrumentParameters::genPeaksFromTable( - DataObjects::TableWorkspace_sptr peakparamws) { + const DataObjects::TableWorkspace_sptr &peakparamws) { // 1. Check and clear input and output if (!peakparamws) { g_log.error() << "Input tableworkspace for peak parameters is invalid!\n"; @@ -902,7 +905,7 @@ void RefinePowderInstrumentParameters::genPeaksFromTable( * the diffrotometer geometry parameters */ void RefinePowderInstrumentParameters::importParametersFromTable( - DataObjects::TableWorkspace_sptr parameterWS, + const DataObjects::TableWorkspace_sptr ¶meterWS, std::map<std::string, double> ¶meters) { // 1. Check column orders std::vector<std::string> colnames = parameterWS->getColumnNames(); @@ -945,7 +948,7 @@ void RefinePowderInstrumentParameters::importParametersFromTable( * Arguments */ void RefinePowderInstrumentParameters::importMonteCarloParametersFromTable( - TableWorkspace_sptr tablews, vector<string> parameternames, + const TableWorkspace_sptr &tablews, const vector<string> ¶meternames, vector<double> &stepsizes, vector<double> &lowerbounds, vector<double> &upperbounds) { // 1. Get column information @@ -1054,7 +1057,8 @@ hkl, double lattice) /** Calculate value n for thermal neutron peak profile */ void RefinePowderInstrumentParameters::calculateThermalNeutronSpecial( - IFunction_sptr m_Function, const HistogramX &xVals, vector<double> &vec_n) { + const IFunction_sptr &m_Function, const HistogramX &xVals, + vector<double> &vec_n) { if (m_Function->name() != "ThermalNeutronDtoTOFFunction") { g_log.warning() << "Function (" << m_Function->name() << " is not ThermalNeutronDtoTOFFunction. And it is not " diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp index e29bf935259831db9c174ae92860189605c10ee7..06e64a0c28016ec224b8e37ee6d89cb1d5cc430f 100644 --- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp +++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp @@ -13,6 +13,7 @@ #include "MantidKernel/ListValidator.h" #include <iomanip> +#include <utility> using namespace Mantid::API; using namespace Mantid::CurveFitting; @@ -231,7 +232,7 @@ void RefinePowderInstrumentParameters3::parseTableWorkspaces() { /** Parse table workspace to a map of Parameters */ void RefinePowderInstrumentParameters3::parseTableWorkspace( - TableWorkspace_sptr tablews, map<string, Parameter> ¶mmap) { + const TableWorkspace_sptr &tablews, map<string, Parameter> ¶mmap) { // 1. Process Table column names std::vector<std::string> colnames = tablews->getColumnNames(); map<string, size_t> colnamedict; @@ -505,7 +506,7 @@ double RefinePowderInstrumentParameters3::doSimulatedAnnealing( * @param newparammap: parameters map containing new/proposed value */ void RefinePowderInstrumentParameters3::proposeNewValues( - vector<string> mcgroup, map<string, Parameter> &curparammap, + const vector<string> &mcgroup, map<string, Parameter> &curparammap, map<string, Parameter> &newparammap, double currchisq) { for (const auto ¶mname : mcgroup) { // random number between -1 and 1 @@ -652,7 +653,7 @@ void RefinePowderInstrumentParameters3::bookKeepMCResult( // 2. Record for the best parameters if (bestparammap.empty()) { // No record yet - duplicateParameters(parammap, bestparammap); + duplicateParameters(std::move(parammap), bestparammap); } else if (recordparameter) { // Replace the record } @@ -752,7 +753,7 @@ void RefinePowderInstrumentParameters3::setupRandomWalkStrategy( * @param parammap :: parammap */ void RefinePowderInstrumentParameters3::addParameterToMCMinimize( - vector<string> &parnamesforMC, string parname, + vector<string> &parnamesforMC, const string &parname, map<string, Parameter> parammap) { map<string, Parameter>::iterator pariter; pariter = parammap.find(parname); @@ -776,7 +777,7 @@ void RefinePowderInstrumentParameters3::addParameterToMCMinimize( * Return: chi^2 */ double RefinePowderInstrumentParameters3::calculateFunction( - map<string, Parameter> parammap, vector<double> &vecY) { + const map<string, Parameter> ¶mmap, vector<double> &vecY) { // 1. Implement parameter values to m_positionFunc if (!parammap.empty()) setFunctionParameterValues(m_positionFunc, parammap); @@ -823,7 +824,8 @@ double calculateFunctionChiSquare(const vector<double> &modelY, /** Calculate Chi^2 of the a function with all parameters are fixed */ double RefinePowderInstrumentParameters3::calculateFunctionError( - IFunction_sptr function, Workspace2D_sptr dataws, int wsindex) { + const IFunction_sptr &function, const Workspace2D_sptr &dataws, + int wsindex) { // 1. Record the fitting information vector<string> parnames = function->getParameterNames(); vector<bool> vecFix(parnames.size(), false); @@ -839,8 +841,8 @@ double RefinePowderInstrumentParameters3::calculateFunctionError( double chi2; string fitstatus; const std::string minimizer = "Levenberg-MarquardtMD"; - bool fitOK = - doFitFunction(function, dataws, wsindex, minimizer, 0, chi2, fitstatus); + bool fitOK = doFitFunction(function, std::move(dataws), wsindex, minimizer, 0, + chi2, fitstatus); if (!fitOK) { g_log.warning() << "Fit by " << minimizer @@ -868,10 +870,10 @@ double RefinePowderInstrumentParameters3::calculateFunctionError( * Return: double chi2 of the final (best) solution. If fitting fails, chi2 *wil be maximum double */ -double RefinePowderInstrumentParameters3::fitFunction(IFunction_sptr function, - Workspace2D_sptr dataws, - int wsindex, - bool powerfit) { +double +RefinePowderInstrumentParameters3::fitFunction(const IFunction_sptr &function, + const Workspace2D_sptr &dataws, + int wsindex, bool powerfit) { // 1. Store original map<string, pair<double, double>> start_paramvaluemap, paramvaluemap1, paramvaluemap2, paramvaluemap3; @@ -972,8 +974,8 @@ double RefinePowderInstrumentParameters3::fitFunction(IFunction_sptr function, * Minimizer: "Levenberg-MarquardtMD"/"Simplex" */ bool RefinePowderInstrumentParameters3::doFitFunction( - IFunction_sptr function, Workspace2D_sptr dataws, int wsindex, - string minimizer, int numiters, double &chi2, string &fitstatus) { + const IFunction_sptr &function, const Workspace2D_sptr &dataws, int wsindex, + const string &minimizer, int numiters, double &chi2, string &fitstatus) { // 0. Debug output stringstream outss; outss << "Fit function: " << m_positionFunc->asString() @@ -1074,7 +1076,8 @@ TableWorkspace_sptr RefinePowderInstrumentParameters3::genOutputProfileTable( * @param parvalue: double, parameter value */ void RefinePowderInstrumentParameters3::addOrReplace( - map<string, Parameter> ¶meters, string parname, double parvalue) { + map<string, Parameter> ¶meters, const string &parname, + double parvalue) { auto pariter = parameters.find(parname); if (pariter != parameters.end()) { parameters[parname].curvalue = parvalue; @@ -1090,7 +1093,7 @@ void RefinePowderInstrumentParameters3::addOrReplace( /** Construct output */ Workspace2D_sptr RefinePowderInstrumentParameters3::genOutputWorkspace( - FunctionDomain1DVector domain, FunctionValues rawvalues) { + const FunctionDomain1DVector &domain, const FunctionValues &rawvalues) { // 1. Create and set up output workspace size_t lenx = m_dataWS->x(m_wsIndex).size(); size_t leny = m_dataWS->y(m_wsIndex).size(); @@ -1138,7 +1141,7 @@ Workspace2D_sptr RefinePowderInstrumentParameters3::genOutputWorkspace( /** Set parameter values to function from Parameter map */ void RefinePowderInstrumentParameters3::setFunctionParameterValues( - IFunction_sptr function, map<string, Parameter> params) { + const IFunction_sptr &function, map<string, Parameter> params) { // 1. Prepare vector<string> funparamnames = function->getParameterNames(); @@ -1210,7 +1213,7 @@ Parameter>& params) * Parameter map */ void RefinePowderInstrumentParameters3::setFunctionParameterFitSetups( - IFunction_sptr function, map<string, Parameter> params) { + const IFunction_sptr &function, map<string, Parameter> params) { // 1. Prepare vector<string> funparamnames = m_positionFunc->getParameterNames(); @@ -1315,7 +1318,7 @@ void convertToDict(vector<string> strvec, map<string, size_t> &lookupdict) { //---------------------------------------------------------------------------------------------- /** Get the index from lookup dictionary (map) */ -int getStringIndex(map<string, size_t> lookupdict, string key) { +int getStringIndex(map<string, size_t> lookupdict, const string &key) { map<string, size_t>::iterator fiter; fiter = lookupdict.find(key); @@ -1336,7 +1339,8 @@ int getStringIndex(map<string, size_t> lookupdict, string key) { /** Store function parameter values to a map */ void storeFunctionParameterValue( - IFunction_sptr function, map<string, pair<double, double>> &parvaluemap) { + const IFunction_sptr &function, + map<string, pair<double, double>> &parvaluemap) { parvaluemap.clear(); vector<string> parnames = function->getParameterNames(); @@ -1354,8 +1358,8 @@ void storeFunctionParameterValue( * and a (string, Parameter) map */ void restoreFunctionParameterValue( - map<string, pair<double, double>> parvaluemap, IFunction_sptr function, - map<string, Parameter> ¶mmap) { + map<string, pair<double, double>> parvaluemap, + const IFunction_sptr &function, map<string, Parameter> ¶mmap) { vector<string> parnames = function->getParameterNames(); for (auto &parname : parnames) { diff --git a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp index d638847df532074cf858104e004b609b74ce6b57..df09ed43a17ae3cd29846741aeb43239e0c1ef58 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp @@ -247,7 +247,7 @@ void SplineBackground::freeBSplinePointers() { * @return:: A shared pointer to the output workspace */ MatrixWorkspace_sptr -SplineBackground::saveSplineOutput(const API::MatrixWorkspace_sptr ws, +SplineBackground::saveSplineOutput(const API::MatrixWorkspace_sptr &ws, const size_t spec) { const auto &xInputVals = ws->x(spec); const auto &yInputVals = ws->y(spec); diff --git a/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp b/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp index 00b4d7cb584aba107f527f9b07a7f30228e47083..99c4f26e976fc4a3a9b1aa8ae04562f477f3ef8b 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp @@ -258,9 +258,9 @@ void SplineInterpolation::exec() { * @param iws :: The input workspace to interpolate * @return The pointer to the newly created workspace */ -API::MatrixWorkspace_sptr -SplineInterpolation::setupOutputWorkspace(API::MatrixWorkspace_sptr mws, - API::MatrixWorkspace_sptr iws) const { +API::MatrixWorkspace_sptr SplineInterpolation::setupOutputWorkspace( + const API::MatrixWorkspace_sptr &mws, + const API::MatrixWorkspace_sptr &iws) const { const size_t numSpec = iws->getNumberHistograms(); MatrixWorkspace_sptr outputWorkspace = WorkspaceFactory::Instance().create(mws, numSpec); @@ -300,7 +300,7 @@ SplineInterpolation::convertBinnedData(MatrixWorkspace_sptr workspace) { * @param row :: The row of spectra to use */ void SplineInterpolation::setInterpolationPoints( - MatrixWorkspace_const_sptr inputWorkspace, const size_t row) const { + const MatrixWorkspace_const_sptr &inputWorkspace, const size_t row) const { const auto &xIn = inputWorkspace->x(row); const auto &yIn = inputWorkspace->y(row); const size_t size = xIn.size(); @@ -321,8 +321,9 @@ void SplineInterpolation::setInterpolationPoints( * @param order :: The order of derivatives to calculate */ void SplineInterpolation::calculateDerivatives( - API::MatrixWorkspace_const_sptr inputWorkspace, - API::MatrixWorkspace_sptr outputWorkspace, const size_t order) const { + const API::MatrixWorkspace_const_sptr &inputWorkspace, + const API::MatrixWorkspace_sptr &outputWorkspace, + const size_t order) const { // get x and y parameters from workspaces const size_t nData = inputWorkspace->y(0).size(); const double *xValues = &(inputWorkspace->x(0)[0]); @@ -339,8 +340,8 @@ void SplineInterpolation::calculateDerivatives( * @param row :: The row of spectra to use */ void SplineInterpolation::calculateSpline( - MatrixWorkspace_const_sptr inputWorkspace, - MatrixWorkspace_sptr outputWorkspace, const size_t row) const { + const MatrixWorkspace_const_sptr &inputWorkspace, + const MatrixWorkspace_sptr &outputWorkspace, const size_t row) const { // setup input parameters const size_t nData = inputWorkspace->y(0).size(); const double *xValues = &(inputWorkspace->x(0)[0]); @@ -360,7 +361,7 @@ void SplineInterpolation::calculateSpline( * @param derivs : the vector of derivative workspaces */ void SplineInterpolation::extrapolateFlat( - MatrixWorkspace_sptr ows, MatrixWorkspace_const_sptr iwspt, + const MatrixWorkspace_sptr &ows, const MatrixWorkspace_const_sptr &iwspt, const size_t row, const std::pair<size_t, size_t> &indices, const bool doDerivs, std::vector<MatrixWorkspace_sptr> &derivs) const { @@ -393,10 +394,9 @@ void SplineInterpolation::extrapolateFlat( * @param row : the workspace index * @return : pair of indices for representing the interpolation range */ -std::pair<size_t, size_t> -SplineInterpolation::findInterpolationRange(MatrixWorkspace_const_sptr iwspt, - MatrixWorkspace_sptr mwspt, - const size_t row) { +std::pair<size_t, size_t> SplineInterpolation::findInterpolationRange( + const MatrixWorkspace_const_sptr &iwspt, const MatrixWorkspace_sptr &mwspt, + const size_t row) { auto xAxisIn = iwspt->x(row).rawData(); std::sort(xAxisIn.begin(), xAxisIn.end()); diff --git a/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp b/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp index b0b09aab49c9105475d7a84ed7a0d680be637207..d906ded7b5e398337bae71f9e96a37e54c1b431b 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp @@ -158,7 +158,7 @@ void SplineSmoothing::calculateSpectrumDerivatives(const int index, * @param ws :: The input workspace * @param row :: The row of spectra to use */ -void SplineSmoothing::performAdditionalFitting(MatrixWorkspace_sptr ws, +void SplineSmoothing::performAdditionalFitting(const MatrixWorkspace_sptr &ws, const int row) { // perform additional fitting of the points auto fit = createChildAlgorithm("Fit"); @@ -306,9 +306,10 @@ void SplineSmoothing::addSmoothingPoints(const std::set<int> &points, std::vector<double> breakPoints; breakPoints.reserve(num_points); // set each of the x and y points to redefine the spline - for (auto const &point : points) { - breakPoints.emplace_back(xs[point]); - } + + std::transform(points.begin(), points.end(), std::back_inserter(breakPoints), + [&xs](const auto &point) { return xs[point]; }); + m_cspline->setAttribute("BreakPoints", API::IFunction::Attribute(breakPoints)); @@ -367,7 +368,7 @@ void SplineSmoothing::selectSmoothingPoints( break; } - } else if (!incBreaks) { + } else { if (smoothPts.size() >= xs.size() - 1) { break; } diff --git a/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp b/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp index edbeff12fe177e8639e8898644ee4cafff5aab7c..2b325168c3c2d276f47fc55d6b54d42425e3d8d8 100644 --- a/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp +++ b/Framework/CurveFitting/src/AugmentedLagrangianOptimizer.cpp @@ -137,7 +137,7 @@ void AugmentedLagrangianOptimizer::minimize(std::vector<double> &xv) const { assert(numParameters() == xv.size()); double ICM(HUGE_VAL), minf_penalty(HUGE_VAL), rho(0.0); - double fcur(0.0), minf(HUGE_VAL), penalty(0.0); + double minf(HUGE_VAL), penalty(0.0); std::vector<double> xcur(xv), lambda(numEqualityConstraints(), 0), mu(numInequalityConstraints()); int minfIsFeasible = 0; @@ -149,7 +149,7 @@ void AugmentedLagrangianOptimizer::minimize(std::vector<double> &xv) const { if (numEqualityConstraints() > 0 || numInequalityConstraints() > 0) { double con2 = 0; - fcur = m_userfunc(numParameters(), xcur.data()); + double fcur = m_userfunc(numParameters(), xcur.data()); int feasible = 1; for (size_t i = 0; i < numEqualityConstraints(); ++i) { double hi = evaluateConstraint(m_eq, i, numParameters(), xcur.data()); @@ -177,7 +177,7 @@ void AugmentedLagrangianOptimizer::minimize(std::vector<double> &xv) const { unconstrainedOptimization(lambda, mu, rho, xcur); - fcur = m_userfunc(numParameters(), xcur.data()); + double fcur = m_userfunc(numParameters(), xcur.data()); ICM = 0.0; penalty = 0.0; int feasible = 1; diff --git a/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp b/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp index 348dd6e25cbf6b3a2ca3e7ee86479518ec06d7db..12b3c9ac613905c0114ad1d27d68cbe1fb2535b1 100644 --- a/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp +++ b/Framework/CurveFitting/src/Constraints/BoundaryConstraint.cpp @@ -51,7 +51,7 @@ BoundaryConstraint::BoundaryConstraint(const std::string ¶mName) * a tie or a constraint. */ BoundaryConstraint::BoundaryConstraint(API::IFunction *fun, - const std::string paramName, + const std::string ¶mName, const double lowerBound, const double upperBound, bool isDefault) : m_penaltyFactor(getDefaultPenaltyFactor()), m_hasLowerBound(true), @@ -61,7 +61,7 @@ BoundaryConstraint::BoundaryConstraint(API::IFunction *fun, } BoundaryConstraint::BoundaryConstraint(API::IFunction *fun, - const std::string paramName, + const std::string ¶mName, const double lowerBound, bool isDefault) : m_penaltyFactor(getDefaultPenaltyFactor()), m_hasLowerBound(true), m_hasUpperBound(false), m_lowerBound(lowerBound), m_upperBound(-DBL_MAX) { diff --git a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp index d5163767645a8f9f3b14789aa4e7c7a140e9cbda..9e8effe85843fa83c130c278c0f6ebdb2306fd01 100644 --- a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp +++ b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp @@ -15,6 +15,7 @@ #include <gsl/gsl_multifit_nlin.h> #include <limits> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -81,9 +82,9 @@ size_t CostFuncFitting::nParams() const { void CostFuncFitting::setFittingFunction(API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) { - m_function = function; - m_domain = domain; - m_values = values; + m_function = std::move(function); + m_domain = std::move(domain); + m_values = std::move(values); reset(); } @@ -127,14 +128,15 @@ void CostFuncFitting::calActiveCovarianceMatrix(GSLMatrix &covar, // construct the jacobian GSLJacobian J(*m_function, m_values->size()); size_t na = this->nParams(); // number of active parameters - assert(J.getJ()->size2 == na); + auto j = J.getJ(); + assert(j->size2 == na); covar.resize(na, na); // calculate the derivatives m_function->functionDeriv(*m_domain, J); // let the GSL to compute the covariance matrix - gsl_multifit_covar(J.getJ(), epsrel, covar.gsl()); + gsl_multifit_covar(j, epsrel, covar.gsl()); } /** Calculates covariance matrix @@ -418,9 +420,7 @@ double CostFuncFitting::valDerivHessian(bool evalDeriv, } } m_dirtyDeriv = false; - } - if (evalDeriv) { if (m_includePenalty) { size_t i = 0; for (size_t ip = 0; ip < np; ++ip) { diff --git a/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp b/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp index 6c0905074835e9c27c7a96703e45172face66def..ab616ca25b9dfe05af338ad39471bcf640cee5e2 100644 --- a/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp +++ b/Framework/CurveFitting/src/CostFunctions/CostFuncRwp.cpp @@ -47,7 +47,7 @@ CostFuncRwp::getFitWeights(API::FunctionValues_sptr values) const { //---------------------------------------------------------------------------------------------- /** Get weight of data point i(1/sigma) */ -double CostFuncRwp::getWeight(API::FunctionValues_sptr values, size_t i, +double CostFuncRwp::getWeight(const API::FunctionValues_sptr &values, size_t i, double sqrtW) const { return (values->getFitWeight(i) / sqrtW); } @@ -55,7 +55,7 @@ double CostFuncRwp::getWeight(API::FunctionValues_sptr values, size_t i, //---------------------------------------------------------------------------------------------- /** Get square root of normalization weight (W) */ -double CostFuncRwp::calSqrtW(API::FunctionValues_sptr values) const { +double CostFuncRwp::calSqrtW(const API::FunctionValues_sptr &values) const { double weight = 0.0; // FIXME : This might give a wrong answer in case of multiple-domain diff --git a/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp b/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp index 2db929f691489cfecf372afe1306f2372021ceb4..8be493174ac62ec966d410d82f2873a440cbae60 100644 --- a/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp +++ b/Framework/CurveFitting/src/FunctionDomain1DSpectrumCreator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidCurveFitting/FunctionDomain1DSpectrumCreator.h" #include "MantidHistogramData/BinEdges.h" #include "MantidHistogramData/Points.h" @@ -29,7 +31,7 @@ FunctionDomain1DSpectrumCreator::FunctionDomain1DSpectrumCreator() */ void FunctionDomain1DSpectrumCreator::setMatrixWorkspace( MatrixWorkspace_sptr matrixWorkspace) { - m_matrixWorkspace = matrixWorkspace; + m_matrixWorkspace = std::move(matrixWorkspace); } /** diff --git a/Framework/CurveFitting/src/Functions/ChebfunBase.cpp b/Framework/CurveFitting/src/Functions/ChebfunBase.cpp index 4b538ddad9e4d6c16b17e6cf8408c2108965a799..989655b8989f01f1437a59a125d697d1e8a4d1e5 100644 --- a/Framework/CurveFitting/src/Functions/ChebfunBase.cpp +++ b/Framework/CurveFitting/src/Functions/ChebfunBase.cpp @@ -22,6 +22,7 @@ #include <limits> #include <numeric> #include <sstream> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -465,7 +466,7 @@ ChebfunBase_sptr ChebfunBase::bestFit(double start, double end, std::vector<double> &p, std::vector<double> &a, double maxA, double tolerance, size_t maxSize) { - return bestFitTempl(start, end, f, p, a, maxA, tolerance, maxSize); + return bestFitTempl(start, end, std::move(f), p, a, maxA, tolerance, maxSize); } /// Template specialization for IFunction @@ -603,7 +604,7 @@ std::vector<double> ChebfunBase::calcP(const std::vector<double> &a) const { */ std::vector<double> ChebfunBase::fit(ChebfunFunctionType f) const { std::vector<double> res(size()); - std::transform(m_x.begin(), m_x.end(), res.begin(), f); + std::transform(m_x.begin(), m_x.end(), res.begin(), std::move(f)); return res; } @@ -626,7 +627,7 @@ std::vector<double> ChebfunBase::fit(const API::IFunction &f) const { * @param f :: Function to calculate. * @param p :: Values of function f at the even-valued indices of m_x. */ -std::vector<double> ChebfunBase::fitOdd(ChebfunFunctionType f, +std::vector<double> ChebfunBase::fitOdd(const ChebfunFunctionType &f, std::vector<double> &p) const { assert(size() == p.size() * 2 - 1); assert(size() % 2 == 1); diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp index e4692b5c89273b06643ff52687436d42362613ff..f1177591bae3e842f477ab5ec1ef924061cdf94a 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldFunction.cpp @@ -26,6 +26,7 @@ #include <boost/optional.hpp> #include <boost/regex.hpp> #include <limits> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -122,7 +123,7 @@ void CrystalFieldFunction::function(const FunctionDomain &domain, /// Set the source function /// @param source :: New source function. void CrystalFieldFunction::setSource(IFunction_sptr source) const { - m_source = source; + m_source = std::move(source); } size_t CrystalFieldFunction::getNumberDomains() const { diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp index a5d7c2427002afcf41fb09371257a61bd8519be0..6989124844d42feeea7bcbabe93646837cb2b5a4 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMagnetisation.cpp @@ -28,7 +28,7 @@ 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 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 diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp index f18a27668c3ab35ff7159c5d4954446bb03dfa41..808f0725dc645df75a979f51e9d229ce683f20ad 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMoment.cpp @@ -28,7 +28,7 @@ namespace { // Does the actual calculation of the magnetic moment void calculate(double *out, const double *xValues, const size_t nData, const ComplexFortranMatrix &ham, const int nre, - const DoubleFortranVector Hdir, const double Hmag, + const DoubleFortranVector &Hdir, const double Hmag, const double convfact) { const double k_B = PhysicalConstants::BoltzmannConstant; DoubleFortranVector en; diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp index 2841d4b75ba02744dde0531f394d78408982060e..2134f11c7727fd4e4624199baa65cf7eee1ab698 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp @@ -125,10 +125,12 @@ CrystalFieldMultiSpectrum::CrystalFieldMultiSpectrum() size_t CrystalFieldMultiSpectrum::getNumberDomains() const { if (!m_target) { buildTargetFunction(); + + if (!m_target) { + throw std::runtime_error("Failed to build target function."); + } } - if (!m_target) { - throw std::runtime_error("Failed to build target function."); - } + return m_target->getNumberDomains(); } diff --git a/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp b/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp index e6a0bd71e1c674a5d820208f77c80b9917faa24d..21e693426a71998d0951bd2ab9364de071c30374 100644 --- a/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp +++ b/Framework/CurveFitting/src/Functions/IkedaCarpenterPV.cpp @@ -128,7 +128,7 @@ void IkedaCarpenterPV::init() { this->lowerConstraint0("X0"); } -void IkedaCarpenterPV::lowerConstraint0(std::string paramName) { +void IkedaCarpenterPV::lowerConstraint0(const std::string ¶mName) { auto mixingConstraint = std::make_unique<BoundaryConstraint>(this, paramName, 0.0, true); mixingConstraint->setPenaltyFactor(1e9); diff --git a/Framework/CurveFitting/src/Functions/PawleyFunction.cpp b/Framework/CurveFitting/src/Functions/PawleyFunction.cpp index be54a4e856f9ef91a63ee36e5d092277c5d23a4f..1e86a37b92dcf1fd2f0c283a9990d214e46ee70d 100644 --- a/Framework/CurveFitting/src/Functions/PawleyFunction.cpp +++ b/Framework/CurveFitting/src/Functions/PawleyFunction.cpp @@ -405,7 +405,8 @@ double PawleyFunction::getTransformedCenter(double d) const { return d; } -void PawleyFunction::setPeakPositions(std::string centreName, double zeroShift, +void PawleyFunction::setPeakPositions(const std::string ¢reName, + double zeroShift, const UnitCell &cell) const { for (size_t i = 0; i < m_hkls.size(); ++i) { double centre = getTransformedCenter(cell.d(m_hkls[i])); diff --git a/Framework/CurveFitting/src/Functions/ProcessBackground.cpp b/Framework/CurveFitting/src/Functions/ProcessBackground.cpp index bbced88b361e2a919b37521efccced067662a313..cf4d6c442941cd0e8ffef66436252b251b88d4de 100644 --- a/Framework/CurveFitting/src/Functions/ProcessBackground.cpp +++ b/Framework/CurveFitting/src/Functions/ProcessBackground.cpp @@ -22,6 +22,7 @@ #include <boost/algorithm/string.hpp> #include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> using namespace Mantid; @@ -583,7 +584,7 @@ void ProcessBackground::selectFromGivenFunction() { /** Select background automatically */ DataObjects::Workspace2D_sptr -ProcessBackground::autoBackgroundSelection(Workspace2D_sptr bkgdWS) { +ProcessBackground::autoBackgroundSelection(const Workspace2D_sptr &bkgdWS) { // Get background type and create bakground function BackgroundFunction_sptr bkgdfunction = createBackgroundFunction(m_bkgdType); @@ -649,7 +650,7 @@ ProcessBackground::autoBackgroundSelection(Workspace2D_sptr bkgdWS) { /** Create a background function from input properties */ BackgroundFunction_sptr -ProcessBackground::createBackgroundFunction(const string backgroundtype) { +ProcessBackground::createBackgroundFunction(const string &backgroundtype) { Functions::BackgroundFunction_sptr bkgdfunction; if (backgroundtype == "Polynomial") { @@ -679,8 +680,8 @@ ProcessBackground::createBackgroundFunction(const string backgroundtype) { //---------------------------------------------------------------------------------------------- /** Filter non-background data points out and create a background workspace */ -Workspace2D_sptr -ProcessBackground::filterForBackground(BackgroundFunction_sptr bkgdfunction) { +Workspace2D_sptr ProcessBackground::filterForBackground( + const BackgroundFunction_sptr &bkgdfunction) { double posnoisetolerance = getProperty("NoiseTolerance"); double negnoisetolerance = getProperty("NegativeNoiseTolerance"); if (isEmpty(negnoisetolerance)) @@ -751,7 +752,8 @@ ProcessBackground::filterForBackground(BackgroundFunction_sptr bkgdfunction) { //---------------------------------------------------------------------------------------------- /** Fit background function */ -void ProcessBackground::fitBackgroundFunction(std::string bkgdfunctiontype) { +void ProcessBackground::fitBackgroundFunction( + const std::string &bkgdfunctiontype) { // Get background type and create bakground function BackgroundFunction_sptr bkgdfunction = createBackgroundFunction(bkgdfunctiontype); @@ -884,9 +886,10 @@ void ProcessBackground::removePeaks() { //---------------------------------------------------------------------------------------------- /** Set up: parse peak workspace to vectors */ -void RemovePeaks::setup(TableWorkspace_sptr peaktablews) { +void RemovePeaks::setup(const TableWorkspace_sptr &peaktablews) { // Parse table workspace - parsePeakTableWorkspace(peaktablews, m_vecPeakCentre, m_vecPeakFWHM); + parsePeakTableWorkspace(std::move(peaktablews), m_vecPeakCentre, + m_vecPeakFWHM); // Check if (m_vecPeakCentre.size() != m_vecPeakFWHM.size()) @@ -900,8 +903,8 @@ void RemovePeaks::setup(TableWorkspace_sptr peaktablews) { /** Remove peaks from a input workspace */ Workspace2D_sptr -RemovePeaks::removePeaks(API::MatrixWorkspace_const_sptr dataws, int wsindex, - double numfwhm) { +RemovePeaks::removePeaks(const API::MatrixWorkspace_const_sptr &dataws, + int wsindex, double numfwhm) { // Check if (m_vecPeakCentre.empty()) throw runtime_error("RemovePeaks has not been setup yet. "); @@ -956,9 +959,9 @@ RemovePeaks::removePeaks(API::MatrixWorkspace_const_sptr dataws, int wsindex, //---------------------------------------------------------------------------------------------- /** Parse table workspace */ -void RemovePeaks::parsePeakTableWorkspace(TableWorkspace_sptr peaktablews, - vector<double> &vec_peakcentre, - vector<double> &vec_peakfwhm) { +void RemovePeaks::parsePeakTableWorkspace( + const TableWorkspace_sptr &peaktablews, vector<double> &vec_peakcentre, + vector<double> &vec_peakfwhm) { // Get peak table workspace information vector<string> colnames = peaktablews->getColumnNames(); int index_centre = -1; diff --git a/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp b/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp index aad46b07eaa898c9083975afa0a3d37e480344c3..bb5562a1a1263a8ce610c82f041df4b06eeef7a3 100644 --- a/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp +++ b/Framework/CurveFitting/src/Functions/SimpleChebfun.cpp @@ -8,6 +8,7 @@ #include "MantidAPI/IFunction.h" #include <boost/make_shared.hpp> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -27,7 +28,7 @@ SimpleChebfun::SimpleChebfun(size_t n, ChebfunFunctionType fun, double start, double end) : m_badFit(false) { m_base = boost::make_shared<ChebfunBase>(n, start, end); - m_P = m_base->fit(fun); + m_P = m_base->fit(std::move(fun)); } SimpleChebfun::SimpleChebfun(size_t n, const API::IFunction &fun, double start, @@ -49,8 +50,8 @@ SimpleChebfun::SimpleChebfun(size_t n, const API::IFunction &fun, double start, /// @param accuracy :: The accuracy of the approximation. /// @param badSize :: If automatic approxiamtion fails the base will have this /// size. -SimpleChebfun::SimpleChebfun(ChebfunFunctionType fun, double start, double end, - double accuracy, size_t badSize) +SimpleChebfun::SimpleChebfun(const ChebfunFunctionType &fun, double start, + double end, double accuracy, size_t badSize) : m_badFit(false) { m_base = ChebfunBase::bestFitAnyTolerance<ChebfunFunctionType>( start, end, fun, m_P, m_A, accuracy); @@ -84,7 +85,7 @@ SimpleChebfun::SimpleChebfun(const std::vector<double> &x, } /// Construct an empty SimpleChebfun with shared base. -SimpleChebfun::SimpleChebfun(ChebfunBase_sptr base) : m_badFit(false) { +SimpleChebfun::SimpleChebfun(const ChebfunBase_sptr &base) : m_badFit(false) { assert(base); m_base = base; m_P.resize(base->size()); @@ -169,7 +170,7 @@ double SimpleChebfun::integrate() const { return m_base->integrate(m_P); } /// Add a C++ function to the function /// @param fun :: A function to add. -SimpleChebfun &SimpleChebfun::operator+=(ChebfunFunctionType fun) { +SimpleChebfun &SimpleChebfun::operator+=(const ChebfunFunctionType &fun) { auto &x = xPoints(); for (size_t i = 0; i < x.size(); ++i) { m_P[i] += fun(x[i]); diff --git a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp index a6a0ad67d4740d1b8ad32c7c123e09f8548f7ee0..f4f3d938c5ce63719fd00620d6da9993349511f0 100644 --- a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp +++ b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp @@ -18,6 +18,7 @@ #include <cmath> #include <fstream> #include <sstream> +#include <utility> namespace Mantid { namespace CurveFitting { @@ -315,7 +316,7 @@ void TabulatedFunction::loadWorkspace(const std::string &wsName) const { */ void TabulatedFunction::loadWorkspace( boost::shared_ptr<API::MatrixWorkspace> ws) const { - m_workspace = ws; + m_workspace = std::move(ws); m_setupFinished = false; } diff --git a/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp b/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp index 43e30a119cd832743aa301eb617f04f339b0f54e..89be09148de6cd15feb694229a3094b68ed377e1 100644 --- a/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp +++ b/Framework/CurveFitting/src/Functions/ThermalNeutronDtoTOFFunction.cpp @@ -67,7 +67,7 @@ void ThermalNeutronDtoTOFFunction::function1D(double *out, * xValues containing the d-space value of peaks centres */ void ThermalNeutronDtoTOFFunction::function1D( - vector<double> &out, const vector<double> xValues) const { + vector<double> &out, const vector<double> &xValues) const { double dtt1 = getParameter(0); double dtt1t = getParameter(1); double dtt2t = getParameter(2); diff --git a/Framework/CurveFitting/src/GSLFunctions.cpp b/Framework/CurveFitting/src/GSLFunctions.cpp index 9600b1f0df213d3beef80c8a699df3257c357b65..cfa30cce795b97ddccb4c621e6e038c5fa7a2cc9 100644 --- a/Framework/CurveFitting/src/GSLFunctions.cpp +++ b/Framework/CurveFitting/src/GSLFunctions.cpp @@ -163,7 +163,7 @@ int gsl_fdf(const gsl_vector *x, void *params, gsl_vector *f, gsl_matrix *J) { * @param cf :: ICostFunction */ GSL_FitData::GSL_FitData( - boost::shared_ptr<CostFunctions::CostFuncLeastSquares> cf) + const boost::shared_ptr<CostFunctions::CostFuncLeastSquares> &cf) : function(cf->getFittingFunction()), costFunction(cf) { gsl_set_error_handler_off(); // number of active parameters diff --git a/Framework/CurveFitting/src/GSLVector.cpp b/Framework/CurveFitting/src/GSLVector.cpp index 03f6450610349824e7184c228544b34e2a9e534b..87bdc8c1f11562ebacae17784617b581078fdef7 100644 --- a/Framework/CurveFitting/src/GSLVector.cpp +++ b/Framework/CurveFitting/src/GSLVector.cpp @@ -168,18 +168,16 @@ GSLVector &GSLVector::operator*=(const GSLVector &v) { /// Multiply by a number /// @param d :: The number GSLVector &GSLVector::operator*=(const double d) { - for (auto &x : m_data) { - x *= d; - } + std::transform(m_data.begin(), m_data.end(), m_data.begin(), + [d](double x) { return x * d; }); return *this; } /// Add a number /// @param d :: The number GSLVector &GSLVector::operator+=(const double d) { - for (auto &x : m_data) { - x += d; - } + std::transform(m_data.begin(), m_data.end(), m_data.begin(), + [d](double x) { return x + d; }); return *this; } diff --git a/Framework/CurveFitting/src/IMWDomainCreator.cpp b/Framework/CurveFitting/src/IMWDomainCreator.cpp index 710fcddc429b9e390dfb5e085cbf1bc6ba225836..6cbb4304fe0b8dea4e541582c411c60f0576aa04 100644 --- a/Framework/CurveFitting/src/IMWDomainCreator.cpp +++ b/Framework/CurveFitting/src/IMWDomainCreator.cpp @@ -409,7 +409,7 @@ void IMWDomainCreator::addFunctionValuesToWS( const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const { + const boost::shared_ptr<API::FunctionValues> &resultValues) const { const size_t nData = resultValues->size(); resultValues->zeroCalculated(); diff --git a/Framework/CurveFitting/src/MultiDomainCreator.cpp b/Framework/CurveFitting/src/MultiDomainCreator.cpp index 977cc3f0e5515924528b4b3c9fdface768991680..6e3f69ff2d8d7de395867537350733211e81b77f 100644 --- a/Framework/CurveFitting/src/MultiDomainCreator.cpp +++ b/Framework/CurveFitting/src/MultiDomainCreator.cpp @@ -15,6 +15,7 @@ #include "MantidAPI/WorkspaceProperty.h" #include "MantidKernel/Logger.h" +#include <memory> #include <sstream> #include <stdexcept> @@ -46,11 +47,12 @@ void MultiDomainCreator::createDomain( "Cannot create JointDomain: number of workspaces does not match " "the number of creators"); } - auto jointDomain = new API::JointDomain; + auto jointDomain = std::make_unique<API::JointDomain>(); API::FunctionValues_sptr values; i0 = 0; for (auto &creator : m_creators) { if (!creator) { + throw std::runtime_error("Missing domain creator"); } API::FunctionDomain_sptr domain; @@ -58,7 +60,7 @@ void MultiDomainCreator::createDomain( jointDomain->addDomain(domain); i0 += domain->size(); } - domain.reset(jointDomain); + domain.reset(jointDomain.release()); ivalues = values; } diff --git a/Framework/CurveFitting/src/SeqDomain.cpp b/Framework/CurveFitting/src/SeqDomain.cpp index f7a48a563f7cea74f07a65fc650eacb4d24fee05..e5539de7cb20c20bc668e3a84ebf2ce5eba40c35 100644 --- a/Framework/CurveFitting/src/SeqDomain.cpp +++ b/Framework/CurveFitting/src/SeqDomain.cpp @@ -50,7 +50,7 @@ void SeqDomain::getDomainAndValues(size_t i, API::FunctionDomain_sptr &domain, * Add new domain creator * @param creator :: A shared pointer to a new creator. */ -void SeqDomain::addCreator(API::IDomainCreator_sptr creator) { +void SeqDomain::addCreator(const API::IDomainCreator_sptr &creator) { m_creators.emplace_back(creator); m_domain.emplace_back(API::FunctionDomain_sptr()); m_values.emplace_back(API::FunctionValues_sptr()); diff --git a/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp b/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp index ba7674dd923ca5712bb74c48df7f9ea164ce7437..e93e0e1bd1a92aa83838a408356b50abe15ecced 100644 --- a/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp +++ b/Framework/CurveFitting/src/SeqDomainSpectrumCreator.cpp @@ -208,7 +208,7 @@ void SeqDomainSpectrumCreator::setParametersFromPropertyManager() { /// Sets the MatrixWorkspace the created domain is based on. void SeqDomainSpectrumCreator::setMatrixWorkspace( - MatrixWorkspace_sptr matrixWorkspace) { + const MatrixWorkspace_sptr &matrixWorkspace) { if (!matrixWorkspace) { throw std::invalid_argument( "InputWorkspace must be a valid MatrixWorkspace."); diff --git a/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp b/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp index 566167061b75800fc3126c25ee09be20b077eb20..d419d2f76fb3f202187b11daea4bc157e71dd84a 100644 --- a/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp +++ b/Framework/CurveFitting/src/TableWorkspaceDomainCreator.cpp @@ -174,8 +174,6 @@ void TableWorkspaceDomainCreator::declareDatasetProperties( "(default the highest value of x)"); if (m_domainType != Simple && !m_manager->existsProperty(m_maxSizePropertyName)) { - auto mustBePositive = boost::make_shared<BoundedValidator<int>>(); - mustBePositive->setLower(0); declareProperty( new PropertyWithValue<int>(m_maxSizePropertyName, 1, mustBePositive), "The maximum number of values per a simple domain."); @@ -463,7 +461,7 @@ void TableWorkspaceDomainCreator::addFunctionValuesToWS( const API::IFunction_sptr &function, boost::shared_ptr<API::MatrixWorkspace> &ws, const size_t wsIndex, const boost::shared_ptr<API::FunctionDomain> &domain, - boost::shared_ptr<API::FunctionValues> resultValues) const { + const boost::shared_ptr<API::FunctionValues> &resultValues) const { const size_t nData = resultValues->size(); resultValues->zeroCalculated(); @@ -728,7 +726,7 @@ void TableWorkspaceDomainCreator::setParameters() const { */ void TableWorkspaceDomainCreator::setXYEColumnNames( - API::ITableWorkspace_sptr ws) const { + const API::ITableWorkspace_sptr &ws) const { auto columnNames = ws->getColumnNames(); @@ -784,7 +782,7 @@ void TableWorkspaceDomainCreator::setXYEColumnNames( * entries. */ void TableWorkspaceDomainCreator::setAndValidateWorkspace( - API::Workspace_sptr ws) const { + const API::Workspace_sptr &ws) const { auto tableWorkspace = boost::dynamic_pointer_cast<API::ITableWorkspace>(ws); if (!tableWorkspace) { throw std::invalid_argument("InputWorkspace must be a TableWorkspace."); diff --git a/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h b/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h index 1ca7b820ddf4262227badf5fea5216f27a5699e5..eab6d230eaa657691c85d7d2dc2a1deacfe13448 100644 --- a/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h +++ b/Framework/CurveFitting/test/Algorithms/ConvolutionFitSequentialTest.h @@ -328,8 +328,9 @@ public: return AnalysisDataService::Instance().retrieveWS<T>(name); } - MatrixWorkspace_sptr getMatrixWorkspace(WorkspaceGroup_const_sptr group, - std::size_t index) { + MatrixWorkspace_sptr + getMatrixWorkspace(const WorkspaceGroup_const_sptr &group, + std::size_t index) { return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(index)); } diff --git a/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h b/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h index dc71f9854a7068419ceae972090beaf758925eb5..5272a2ec933730c50354e7efaa8adfee00e4d381 100644 --- a/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h +++ b/Framework/CurveFitting/test/Algorithms/FitPowderDiffPeaksTest.h @@ -32,7 +32,8 @@ namespace { //---------------------------------------------------------------------------------------------- /** Import data from a column data file by calling LoadAscii */ -void importDataFromColumnFile(string filename, string datawsname) { +void importDataFromColumnFile(const string &filename, + const string &datawsname) { // 1. Call LoadAscii DataHandling::LoadAscii2 loader; loader.initialize(); @@ -96,7 +97,7 @@ API::MatrixWorkspace_sptr createInputDataWorkspace(int option) { //---------------------------------------------------------------------------------------------- /** Create the Bragg peak parameters table for LaB6, PG3, Bank1 */ -void createLaB6PG3Bank1BraggPeaksTable(TableWorkspace_sptr tablews) { +void createLaB6PG3Bank1BraggPeaksTable(const TableWorkspace_sptr &tablews) { TableRow newrow0 = tablews->appendRow(); newrow0 << 6 << 3 << 1 << .6129000 << 13962.47 << 0.20687 << 0.10063 << 62.64174 << 0.00000; @@ -266,7 +267,7 @@ DataObjects::TableWorkspace_sptr createReflectionWorkspace(int option) { //---------------------------------------------------------------------------------------------- /** Add rows for input table workspace for PG3 bank1 */ -void createPG3Bank1ParameterTable(TableWorkspace_sptr tablews) { +void createPG3Bank1ParameterTable(const TableWorkspace_sptr &tablews) { TableRow newrow0 = tablews->appendRow(); newrow0 << "Alph0" << 2.708; TableRow newrow1 = tablews->appendRow(); diff --git a/Framework/CurveFitting/test/Algorithms/FitTest.h b/Framework/CurveFitting/test/Algorithms/FitTest.h index e0b16441c01ce1ca18cbb2fc6a29a384300ea5c8..48a3e74d71ce679d4ce7e2cc324b71070baebfcb 100644 --- a/Framework/CurveFitting/test/Algorithms/FitTest.h +++ b/Framework/CurveFitting/test/Algorithms/FitTest.h @@ -1029,7 +1029,6 @@ public: TS_ASSERT(alg2.isInitialized()); // create mock data to test against - const std::string wsName = "ExpDecayMockData"; const int histogramNumber = 1; const int timechannels = 20; Workspace_sptr ws = WorkspaceFactory::Instance().create( diff --git a/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h b/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h index 50624ce827dd18593f9bfb43f259f84324ce8cea..e1c8c657f7ee5d3054914a1d6c7c16224bcc4bf1 100644 --- a/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h +++ b/Framework/CurveFitting/test/Algorithms/FitTestHelpers.h @@ -26,8 +26,8 @@ static API::MatrixWorkspace_sptr generateSmoothCurveWorkspace(); /// Run fit on a (single spectrum) matrix workspace, using the given type /// of function and minimizer option static Mantid::API::IAlgorithm_sptr -runFitAlgorithm(MatrixWorkspace_sptr dataToFit, CurveBenchmarks ctype, - const std::string minimizer = "Levenberg-MarquardtMD") { +runFitAlgorithm(const MatrixWorkspace_sptr &dataToFit, CurveBenchmarks ctype, + const std::string &minimizer = "Levenberg-MarquardtMD") { auto fit = AlgorithmManager::Instance().create("Fit"); fit->initialize(); diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h index b9ce6ac8ca8c0683181f3c72aacb78352c2e401f..b43f134bd99af16ab150437afcc38ca9e24d8cd2 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h @@ -424,46 +424,6 @@ API::MatrixWorkspace_sptr generateArgSiPeak220() { return dataws; } -//---------------------------------------------------------------------------------------------- -/** Import data from a column data file - */ -void importDataFromColumnFile(std::string filename, std::string wsname) { - DataHandling::LoadAscii2 load; - load.initialize(); - - load.setProperty("FileName", filename); - load.setProperty("OutputWorkspace", wsname); - load.setProperty("Separator", "Automatic"); - load.setProperty("Unit", "TOF"); - - load.execute(); - if (!load.isExecuted()) { - stringstream errss; - errss << "Data file " << filename << " cannot be opened. "; - std::cout << errss.str() << '\n'; - throw std::runtime_error(errss.str()); - } - - MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>( - AnalysisDataService::Instance().retrieve(wsname)); - if (!ws) { - stringstream errss; - errss << "LoadAscii failed to generate workspace"; - std::cout << errss.str() << '\n'; - throw std::runtime_error(errss.str()); - } - - // Set error - const MantidVec &vecY = ws->readY(0); - MantidVec &vecE = ws->dataE(0); - size_t numpts = vecY.size(); - for (size_t i = 0; i < numpts; ++i) { - vecE[i] = std::max(1.0, sqrt(vecY[i])); - } - - return; -} - //---------------------------------------------------------------------------------------------- /** Create data workspace without background */ @@ -499,17 +459,9 @@ API::MatrixWorkspace_sptr createInputDataWorkspace(int option) { break; } - } else if (option == 4) { + } else { // Load from column file throw runtime_error("Using .dat file is not allowed for committing. "); - string datafilename("PG3_4862_Bank7.dat"); - string wsname("Data"); - importDataFromColumnFile(datafilename, wsname); - dataws = boost::dynamic_pointer_cast<MatrixWorkspace>( - AnalysisDataService::Instance().retrieve(wsname)); - } else { - // not supported - throw std::invalid_argument("Logic error. "); } return dataws; @@ -1295,7 +1247,7 @@ public: * Parse parameter table workspace to 2 map */ void - parseParameterTableWorkspace(DataObjects::TableWorkspace_sptr paramws, + parseParameterTableWorkspace(const DataObjects::TableWorkspace_sptr ¶mws, std::map<std::string, double> ¶mvalues, std::map<std::string, char> ¶mfitstatus) { diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h index 2529fbea830587d7d99fbcda036d880ce84ba612..b8b8ab8d8a392ef556ec797d1e665d4de0a639d8 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h @@ -216,7 +216,7 @@ public: << imax111 << "-th points.\n"; // Calculate diffraction patters - auto out = lebailfunction.function(vecX, true, false); + lebailfunction.function(vecX, true, false); TS_ASSERT_THROWS_ANYTHING(lebailfunction.function(vecX, true, true)); vector<string> vecbkgdparnames(2); @@ -228,7 +228,7 @@ public: lebailfunction.addBackgroundFunction("Polynomial", 2, vecbkgdparnames, bkgdvec, vecX.front(), vecX.back()); - out = lebailfunction.function(vecX, true, true); + auto out = lebailfunction.function(vecX, true, true); double v1 = out[imax111]; double v2 = out[imax110]; @@ -428,7 +428,8 @@ public: return ws; } - void importDataFromColumnFile(std::string filename, std::vector<double> &vecX, + void importDataFromColumnFile(const std::string &filename, + std::vector<double> &vecX, std::vector<double> &vecY, std::vector<double> &vecE) { std::ifstream ins; @@ -440,7 +441,6 @@ public: if (line[0] != '#') { double x, y; std::stringstream ss; - std::string dataline(line); ss.str(line); ss >> x >> y; vecX.emplace_back(x); diff --git a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h index 97aada54a131dd93a517d0ddf38e61a19c82c736..5376a94005d77960d582dfee9c40685925a068fa 100644 --- a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h +++ b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h @@ -29,6 +29,7 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <algorithm> #include <sstream> +#include <utility> using namespace Mantid; using namespace Mantid::API; @@ -67,9 +68,9 @@ DECLARE_FUNCTION(PLOTPEAKBYLOGVALUETEST_Fun) class PropertyNameIs { public: - PropertyNameIs(std::string name) : m_name(name){}; + PropertyNameIs(std::string name) : m_name(std::move(name)){}; - bool operator()(Mantid::Kernel::PropertyHistory_sptr p) { + bool operator()(const Mantid::Kernel::PropertyHistory_sptr &p) { return p->name() == m_name; } @@ -624,8 +625,6 @@ private: ws->setSharedX(1, ws->sharedX(0)); ws->setSharedX(2, ws->sharedX(0)); - std::vector<double> amps{20.0, 30.0, 25.0}; - std::vector<double> cents{0.0, 0.1, -1.0}; std::vector<double> fwhms{1.0, 1.1, 0.6}; for (size_t i = 0; i < 3; ++i) { std::string fun = "name=FlatBackground,A0=" + std::to_string(fwhms[i]); diff --git a/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h b/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h index ab36a4758d4107057bdfa60df56f86984954f2bf..b2361e2145b0842a902cde68bd98b59a85394d5b 100644 --- a/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h +++ b/Framework/CurveFitting/test/Algorithms/QENSFitSequentialTest.h @@ -79,8 +79,8 @@ public: } private: - std::string runConvolutionFit(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr resolution) { + std::string runConvolutionFit(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &resolution) { QENSFitSequential alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); @@ -207,7 +207,7 @@ private: return resolution; } - void addBinsAndCountsToWorkspace(Workspace2D_sptr workspace, + void addBinsAndCountsToWorkspace(const Workspace2D_sptr &workspace, std::size_t totalBinEdges, std::size_t totalCounts, double binValue, double countValue) const { diff --git a/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h b/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h index 1974772d73faf83d9a8b5cd6649e55409a2e2894..bb53acfbbe53e89e0575d388cf89d72e1e9f1583 100644 --- a/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h +++ b/Framework/CurveFitting/test/Algorithms/QENSFitSimultaneousTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/Axis.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/FunctionFactory.h" @@ -84,8 +86,8 @@ public: } private: - std::string runConvolutionFit(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr resolution) { + std::string runConvolutionFit(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &resolution) { QENSFitSimultaneous alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); @@ -107,12 +109,12 @@ private: std::string runMultiDatasetFit( const std::vector<Mantid::API::MatrixWorkspace_sptr> &workspaces, - IFunction_sptr function) { + const IFunction_sptr &function) { QENSFitSimultaneous alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); - alg.setProperty("Function", - createMultiDomainFunction(function, workspaces.size())); + alg.setProperty("Function", createMultiDomainFunction(std::move(function), + workspaces.size())); setMultipleInput(alg, workspaces, 0.0, 10.0); alg.setProperty("ConvolveMembers", true); alg.setProperty("Minimizer", "Levenberg-Marquardt"); @@ -197,7 +199,7 @@ private: return resolution; } - void addBinsAndCountsToWorkspace(Workspace2D_sptr workspace, + void addBinsAndCountsToWorkspace(const Workspace2D_sptr &workspace, std::size_t totalBinEdges, std::size_t totalCounts, double binValue, double countValue) const { @@ -232,7 +234,7 @@ private: } } - IFunction_sptr createMultiDomainFunction(IFunction_sptr function, + IFunction_sptr createMultiDomainFunction(const IFunction_sptr &function, std::size_t numberOfDomains) { auto multiDomainFunction = boost::make_shared<MultiDomainFunction>(); diff --git a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h index cb863647b2fff387c1faa4f47a0dce2ded890d96..c7f8debc5a0f9b21f80fa5ba2848479d8e18e7a2 100644 --- a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h +++ b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParameters3Test.h @@ -117,7 +117,7 @@ TableWorkspace_sptr generateInstrumentProfileTableBank1() { //---------------------------------------------------------------------------------------------- /** Parse Table Workspace to a map of string, double pair */ -void parseParameterTableWorkspace(TableWorkspace_sptr paramws, +void parseParameterTableWorkspace(const TableWorkspace_sptr ¶mws, map<string, double> ¶mvalues) { for (size_t irow = 0; irow < paramws->rowCount(); ++irow) { Mantid::API::TableRow row = paramws->getRow(irow); diff --git a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h index fdfffc3524ed304763e8428f1fddb3c3d2dc3a12..487a1b787c4d1637629e03648415c6916b6081b4 100644 --- a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h +++ b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h @@ -327,7 +327,7 @@ public: * BETA, ... */ void - importPeakParametersFile(std::string filename, + importPeakParametersFile(const std::string &filename, std::vector<std::vector<int>> &hkls, std::vector<std::vector<double>> &peakparameters) { // 1. Open file @@ -441,7 +441,7 @@ public: * Input: a text based file * Output: a map for (parameter name, parameter value) */ - void importInstrumentTxtFile(std::string filename, + void importInstrumentTxtFile(const std::string &filename, std::map<std::string, double> ¶meters, std::map<string, vector<double>> ¶metermcs) { // 1. Open file @@ -462,14 +462,14 @@ public: while (ins.getline(line, 256)) { if (line[0] != '#') { std::string parname; - double parvalue, parmin, parmax, parstepsize; - + double parvalue; std::stringstream ss; ss.str(line); ss >> parname >> parvalue; parameters.emplace(parname, parvalue); try { + double parmin, parmax, parstepsize; ss >> parmin >> parmax >> parstepsize; vector<double> mcpars; mcpars.emplace_back(parmin); @@ -488,9 +488,9 @@ public: } /// ================= Check Output ================ /// - void - parseParameterTableWorkspace(Mantid::DataObjects::TableWorkspace_sptr paramws, - std::map<std::string, double> ¶mvalues) { + void parseParameterTableWorkspace( + const Mantid::DataObjects::TableWorkspace_sptr ¶mws, + std::map<std::string, double> ¶mvalues) { for (size_t irow = 0; irow < paramws->rowCount(); ++irow) { Mantid::API::TableRow row = paramws->getRow(irow); diff --git a/Framework/CurveFitting/test/FitMWTest.h b/Framework/CurveFitting/test/FitMWTest.h index b4c0ff6af9e7148b97dead62a86f68932a760ea6..7e170fb5a74d035901b9797dd0ccb050eb719ed6 100644 --- a/Framework/CurveFitting/test/FitMWTest.h +++ b/Framework/CurveFitting/test/FitMWTest.h @@ -63,7 +63,7 @@ API::MatrixWorkspace_sptr createTestWorkspace(const bool histogram, return ws2; } -void doTestExecPointData(API::MatrixWorkspace_sptr ws2, +void doTestExecPointData(const API::MatrixWorkspace_sptr &ws2, bool performance = false) { API::IFunction_sptr fun(new ExpDecay); fun->setParameter("Height", 1.); @@ -169,7 +169,7 @@ void doTestExecPointData(API::MatrixWorkspace_sptr ws2, TS_ASSERT_DELTA(fun->getParameter("Lifetime"), 1.0, 1e-4); } } -void doTestExecHistogramData(API::MatrixWorkspace_sptr ws2, +void doTestExecHistogramData(const API::MatrixWorkspace_sptr &ws2, bool performance = false) { API::IFunction_sptr fun(new ExpDecay); fun->setParameter("Height", 1.); @@ -497,8 +497,6 @@ public: test_Composite_Function_With_SeparateMembers_Option_On_FitMW_Outputs_Composite_Values_Plus_Each_Member() { const bool histogram = true; auto ws2 = createTestWorkspace(histogram); - const std::string inputWSName = "FitMWTest_CompositeTest"; - // AnalysisDataService::Instance().add(inputWSName, ws2); auto composite = boost::make_shared<API::CompositeFunction>(); API::IFunction_sptr expDecay(new ExpDecay); diff --git a/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h b/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h index 34b24d12fd5a644940986cc5d08ea932d611abf6..75543a266a9714190e91c26739fd97eba152e9ae 100644 --- a/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h +++ b/Framework/CurveFitting/test/FuncMinimizers/FABADAMinimizerTest.h @@ -46,7 +46,7 @@ MatrixWorkspace_sptr createTestWorkspace(size_t NVectors = 2, return ws2; } -void doTestExpDecay(MatrixWorkspace_sptr ws2) { +void doTestExpDecay(const MatrixWorkspace_sptr &ws2) { Mantid::API::IFunction_sptr fun(new ExpDecay); fun->setParameter("Height", 8.); diff --git a/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h b/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h index feef3b422ef9baedd3dc5ad4057593ea6e390eb0..32e6baf1132f497965762f302a5734c5bac787c5 100644 --- a/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h +++ b/Framework/CurveFitting/test/FuncMinimizers/LevenbergMarquardtMDTest.h @@ -468,7 +468,8 @@ public: } private: - double fitBSpline(boost::shared_ptr<IFunction> bsp, std::string func) { + double fitBSpline(const boost::shared_ptr<IFunction> &bsp, + const std::string &func) { const double startx = bsp->getAttribute("StartX").asDouble(); const double endx = bsp->getAttribute("EndX").asDouble(); diff --git a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h index ec23cc49c22307b29720ffa79bcb5739e6fb504b..5552bf2677df3bf6f5809ce1b0e627827a49b81b 100644 --- a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h +++ b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h @@ -10,6 +10,7 @@ #include "MantidCurveFitting/Functions/ChebfunBase.h" #include <cmath> +#include <utility> using namespace Mantid; using namespace Mantid::API; @@ -115,8 +116,8 @@ public: void test_roots_SinCos() { do_test_roots(SinCos, -M_PI, M_PI, 2, 1e-5); } private: - void do_test_eval(std::function<double(double)> fun, double start, double end, - size_t n) { + void do_test_eval(const std::function<double(double)> &fun, double start, + double end, size_t n) { ChebfunBase base(n, start, end); auto p = base.fit(fun); auto x = base.linspace(2 * n); @@ -132,7 +133,7 @@ private: x.assign(xarr, xarr + narr); ChebfunBase base(n, start, end); - auto p = base.fit(fun); + auto p = base.fit(std::move(fun)); auto y = base.evalVector(x, p); TS_ASSERT_EQUALS(y.size(), x.size()); for (size_t i = 0; i < x.size(); ++i) { @@ -147,7 +148,7 @@ private: } } - void do_test_bestFit(std::function<double(double)> fun, double start, + void do_test_bestFit(const std::function<double(double)> &fun, double start, double end, size_t expected_n) { std::vector<double> p, a; auto base = ChebfunBase::bestFit(start, end, fun, p, a); @@ -161,14 +162,15 @@ private: void do_test_integrate(std::function<double(double)> fun, double start, double end, double expected_integral) { std::vector<double> p, a; - auto base = ChebfunBase::bestFit(start, end, fun, p, a); + auto base = ChebfunBase::bestFit(start, end, std::move(fun), p, a); TS_ASSERT_DELTA(base->integrate(p), expected_integral, 1e-14); } void do_test_derivative(std::function<double(double)> fun, double start, - double end, std::function<double(double)> deriv) { + double end, + const std::function<double(double)> &deriv) { std::vector<double> p, a, dp, da; - auto base = ChebfunBase::bestFit(start, end, fun, p, a); + auto base = ChebfunBase::bestFit(start, end, std::move(fun), p, a); base->derivative(a, da); dp = base->calcP(da); auto x = base->linspace(2 * base->size()); @@ -181,7 +183,7 @@ private: void do_test_roots(std::function<double(double)> fun, double start, double end, size_t n_roots, double tol = 1e-13) { std::vector<double> p, a; - auto base = ChebfunBase::bestFit(start, end, fun, p, a); + auto base = ChebfunBase::bestFit(start, end, std::move(fun), p, a); auto roots = base->roots(a); TS_ASSERT_EQUALS(n_roots, roots.size()); for (double root : roots) { diff --git a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h index 04247920fe6b37a572a9c2f9ad9f5c9c9340d5d9..26dde36728e84ed9d9850b243b84898b2b6107a6 100644 --- a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h @@ -31,13 +31,13 @@ public: void test_initialized_object_has_expected_attributes() { auto profile = createFunction(); static const size_t nattrs(3); - const char *expectedAttrs[nattrs] = {"WorkspaceIndex", "Mass", - "VoigtEnergyCutOff"}; TS_ASSERT_EQUALS(nattrs, profile->nAttributes()); // Test names as they are used in scripts if (profile->nAttributes() > 0) { + const char *expectedAttrs[nattrs] = {"WorkspaceIndex", "Mass", + "VoigtEnergyCutOff"}; std::unordered_set<std::string> expectedAttrSet(expectedAttrs, expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); diff --git a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h index 2e4458bacbd7f6eb1edb2fe850e1d6a3b62a9637..cadb3838c6a86b4a9e095993dffaa2a7b2928dc2 100644 --- a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h @@ -30,12 +30,12 @@ public: void test_initialized_object_has_expected_parameters() { auto profile = createFunction(); static const size_t nparams(1); - const char *expectedParams[nparams] = {"Mass"}; TS_ASSERT_EQUALS(nparams, profile->nParams()); // Test names as they are used in scripts if (profile->nParams() > 0) { + const char *expectedParams[nparams] = {"Mass"}; std::unordered_set<std::string> expectedParamStr( expectedParams, expectedParams + nparams); std::vector<std::string> actualNames = profile->getParameterNames(); diff --git a/Framework/CurveFitting/test/Functions/ConvolutionTest.h b/Framework/CurveFitting/test/Functions/ConvolutionTest.h index a3c0ecac4f951103b1c209eae9059900eefd60b9..22e235d588f81cf1fd7be2a2f4d06e0fcc4e49a6 100644 --- a/Framework/CurveFitting/test/Functions/ConvolutionTest.h +++ b/Framework/CurveFitting/test/Functions/ConvolutionTest.h @@ -180,8 +180,7 @@ public: linear->setParameter(0, 0.1); linear->setParameter(1, 0.2); - size_t iFun = 10000; - iFun = conv.addFunction(linear); + size_t iFun = conv.addFunction(linear); TS_ASSERT_EQUALS(iFun, 0); iFun = conv.addFunction(gauss1); TS_ASSERT_EQUALS(iFun, 1); diff --git a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h index c3e722502b5f1f03591bd802095a473346a0f5be..805d3b956f9de8bcf9a2b5decdd4b12d7323ebe1 100644 --- a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h @@ -33,12 +33,13 @@ public: void test_Initialized_Function_Has_Expected_Parameters_In_Right_Order() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nparams(3); - const char *expectedParams[nparams] = {"Mass", "Width", "Intensity"}; auto currentNames = profile->getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_EQUALS(nparams, nnames); + if (nnames == nparams) { + const char *expectedParams[nparams] = {"Mass", "Width", "Intensity"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } diff --git a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h index 1ca51c7a7ca236916e227fb1d504da9f6c11a866..5a03d55af9c25b45b38d3cd347728896fa03826e 100644 --- a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h @@ -152,12 +152,12 @@ private: void checkDefaultParametersExist(const Mantid::API::IFunction &profile) { static const size_t nparams(3); - const char *expectedParams[nparams] = {"Mass", "Width", "FSECoeff"}; auto currentNames = profile.getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_LESS_THAN_EQUALS(nparams, nnames); if (nnames <= nparams) { + const char *expectedParams[nparams] = {"Mass", "Width", "FSECoeff"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } diff --git a/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h b/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h index 6a05454222ed3e6066dab20e16dd2d59e51531cb..aa73d35207f35a8368c210c8585e6094da5efeb4 100644 --- a/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h @@ -33,12 +33,12 @@ public: void test_Initialized_Function_Has_Expected_Parameters_In_Right_Order() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nparams(5); - const char *expectedParams[nparams] = {"Mass", "Intensity", "SigmaX", - "SigmaY", "SigmaZ"}; auto currentNames = profile->getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_EQUALS(nparams, nnames); if (nnames == nparams) { + const char *expectedParams[nparams] = {"Mass", "Intensity", "SigmaX", + "SigmaY", "SigmaZ"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } @@ -48,12 +48,12 @@ public: void test_Initialized_Function_Has_Expected_Attributes() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nattrs(1); - const char *expectedAttrs[nattrs] = {"IntegrationSteps"}; TS_ASSERT_EQUALS(nattrs, profile->nAttributes()); // Test names as they are used in scripts if (profile->nAttributes() > 0) { + const char *expectedAttrs[nattrs] = {"IntegrationSteps"}; std::set<std::string> expectedAttrSet(expectedAttrs, expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); diff --git a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h index 3811aa907ade7f87d51ca12833d7fba2f697b79d..9c5dc429d06d0dd7a6b6e4982f3171a8c4d6604b 100644 --- a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h +++ b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h @@ -17,6 +17,7 @@ #include "MantidKernel/MersenneTwister.h" #include <fstream> +#include <utility> using Mantid::CurveFitting::Functions::ProcessBackground; using namespace Mantid; @@ -26,7 +27,8 @@ using namespace Mantid::DataObjects; using namespace HistogramData; namespace { -Workspace2D_sptr createInputWS(std::string name, size_t sizex, size_t sizey) { +Workspace2D_sptr createInputWS(const std::string &name, size_t sizex, + size_t sizey) { Workspace2D_sptr inputWS = boost::dynamic_pointer_cast<Workspace2D>( WorkspaceFactory::Instance().create("Workspace2D", 1, sizex, sizey)); AnalysisDataService::Instance().addOrReplace(name, inputWS); @@ -294,9 +296,9 @@ public: //---------------------------------------------------------------------------------------------- /** Read column file to create a workspace2D */ - Workspace2D_sptr createWorkspace2D(std::string filename) { + Workspace2D_sptr createWorkspace2D(const std::string &filename) { // 1. Read data - auto data = importDataFromColumnFile(filename); + auto data = importDataFromColumnFile(std::move(filename)); // 2. Create workspace size_t datasize = data.x().size(); @@ -314,7 +316,7 @@ public: /** Import data from a column data file */ - Histogram importDataFromColumnFile(std::string filename) { + Histogram importDataFromColumnFile(const std::string &filename) { // 1. Open file std::ifstream ins; ins.open(filename.c_str()); diff --git a/Framework/CurveFitting/test/Functions/ProductFunctionTest.h b/Framework/CurveFitting/test/Functions/ProductFunctionTest.h index b6c4459276e2b73dd2ea4cdd03d16eb79474b8d7..8596d48dad3f5b078384f26a78c6af78bf8d393e 100644 --- a/Framework/CurveFitting/test/Functions/ProductFunctionTest.h +++ b/Framework/CurveFitting/test/Functions/ProductFunctionTest.h @@ -116,8 +116,7 @@ public: linear->setParameter(0, 0.1); linear->setParameter(1, 0.2); - size_t iFun = 100000; - iFun = prodF.addFunction(linear); + size_t iFun = prodF.addFunction(linear); TS_ASSERT_EQUALS(iFun, 0); iFun = prodF.addFunction(gauss1); TS_ASSERT_EQUALS(iFun, 1); diff --git a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h index 6faf11ee57fa7479da7ae12db9137d48a03036ca..fec05d704cb2b5a6f4a7bc53e2c5fab46171025d 100644 --- a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h +++ b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h @@ -221,8 +221,8 @@ public: private: void do_test_values(const SimpleChebfun &cheb, - std::function<double(double)> fun, double accur1 = 1e-14, - double accur2 = 1e-14) { + const std::function<double(double)> &fun, + double accur1 = 1e-14, double accur2 = 1e-14) { TS_ASSERT(cheb.size() > 0); TS_ASSERT(cheb.width() > 0.0); if (cheb.isGood()) { diff --git a/Framework/CurveFitting/test/HistogramDomainCreatorTest.h b/Framework/CurveFitting/test/HistogramDomainCreatorTest.h index 75853f8cee7ca5357216c09f9430b9018cc6a256..a09450e0550a6e90852599ec757b5fc0d4a493af 100644 --- a/Framework/CurveFitting/test/HistogramDomainCreatorTest.h +++ b/Framework/CurveFitting/test/HistogramDomainCreatorTest.h @@ -463,8 +463,9 @@ private: return ws2; } - MatrixWorkspace_sptr createFitWorkspace(const size_t ny, - std::function<double(double)> fun) { + MatrixWorkspace_sptr + createFitWorkspace(const size_t ny, + const std::function<double(double)> &fun) { MatrixWorkspace_sptr ws(new WorkspaceTester); size_t nx = ny + 1; double x0 = -1.0; diff --git a/Framework/CurveFitting/test/MultiDomainCreatorTest.h b/Framework/CurveFitting/test/MultiDomainCreatorTest.h index ef6499accc9173a80385643f4c1f8606a6cbdcb7..146991f53f43eaa89eb392b6f937c8a064bacf9a 100644 --- a/Framework/CurveFitting/test/MultiDomainCreatorTest.h +++ b/Framework/CurveFitting/test/MultiDomainCreatorTest.h @@ -302,7 +302,7 @@ public: } private: - void doTestOutputSpectrum(MatrixWorkspace_sptr ws, size_t index) { + void doTestOutputSpectrum(const MatrixWorkspace_sptr &ws, size_t index) { TS_ASSERT(ws); TS_ASSERT_EQUALS(ws->getNumberHistograms(), 3); auto &data = ws->readY(0); diff --git a/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h b/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h index 5cecdb61ba482f381a559d86834b135d02e77717..743bac005d50c13b182e8e049207ffb4e01d1394 100644 --- a/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h +++ b/Framework/CurveFitting/test/TableWorkspaceDomainCreatorTest.h @@ -770,8 +770,8 @@ private: } boost::shared_ptr<Fit> - setupBasicFitPropertiesAlgorithm(API::IFunction_sptr fun, - API::Workspace_sptr ws, + setupBasicFitPropertiesAlgorithm(const API::IFunction_sptr &fun, + const API::Workspace_sptr &ws, bool createOutput = true) { auto fit = boost::make_shared<Fit>(); fit->initialize(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h b/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h index 918e89694bb78617d293a47138ea171957785619..971696c075357790711f54d7e5cdca4262d16f48 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h @@ -49,12 +49,12 @@ private: /// Run LoadInstrument as a Child Algorithm bool runLoadInstrument(const std::string &idf_filename, - API::MatrixWorkspace_sptr localWorkspace, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg); /// Load logs from the NeXus file static bool runLoadNexusLogs(const std::string &nexusFileName, - API::MatrixWorkspace_sptr localWorkspace, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg); /// Are we going to make a copy of the NeXus file to operate on ? diff --git a/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h b/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h index 8cdc32656f8dd9f07990182dc3e9fc78e14c7dba..5edb30b89ebc93495d86522931ac795789434154 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h +++ b/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h @@ -32,7 +32,7 @@ public: ~BankPulseTimes(); /// Equals - bool equals(size_t otherNumPulse, std::string otherStartTime); + bool equals(size_t otherNumPulse, const std::string &otherStartTime); /// String describing the start time std::string startTime; diff --git a/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h b/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h index c8129c6e205948dee0cfb1d8d443b64701dca82e..e8d09ae03001d2fc5cd7686788788a343b8043d1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h +++ b/Framework/DataHandling/inc/MantidDataHandling/CreateSimulationWorkspace.h @@ -54,7 +54,7 @@ private: /// Apply any instrument adjustments from the file void adjustInstrument(const std::string &filename); /// Set start date for dummy workspace - void setStartDate(API::MatrixWorkspace_sptr workspace); + void setStartDate(const API::MatrixWorkspace_sptr &workspace); /// Pointer to a progress object boost::shared_ptr<API::Progress> m_progress; diff --git a/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h b/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h index 41a791773fed785fd958164f5f1ede95b240c363..307d7b84caf8fbac1b4ac4071009b7dacb99fe13 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DataBlockComposite.h @@ -33,7 +33,7 @@ public: bool operator==(const DataBlockComposite &other) const; // DataBlockComposite only mehtods - void addDataBlock(DataBlock dataBlock); + void addDataBlock(const DataBlock &dataBlock); std::vector<DataBlock> getDataBlocks(); DataBlockComposite operator+(const DataBlockComposite &other); void removeSpectra(DataBlockComposite &toRemove); diff --git a/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h b/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h index 8dd99ed92b0a17139baa4d0d8bbd63ea2ee83925..5df1afc8758a885cd2641bdcdca2a96043b76509 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DetermineChunking.h @@ -57,7 +57,7 @@ public: private: void init() override; void exec() override; - std::string setTopEntryName(std::string filename); + std::string setTopEntryName(const std::string &filename); FileType getFileType(const std::string &filename); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h index 6b0d8bebcebed593d62dd1457ae0ab13789452c5..7e2dcfc33bbd9857fe1f0d2091b3fc1b5d1595b5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h +++ b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h @@ -59,7 +59,7 @@ public: void setThickness(const float flag); void setHeight(const float flag); void setWidth(const float flag); - void setSpectrumNumbersFromUniqueSpectra(const std::set<int> uniqueSpectra); + void setSpectrumNumbersFromUniqueSpectra(const std::set<int> &uniqueSpectra); void setSpectrumNumberForAllPeriods(const size_t spectrumNumber, const specnum_t specid); void setDetectorIdsForAllPeriods(const size_t spectrumNumber, @@ -88,8 +88,9 @@ public: void setMonitorWorkspace(const boost::shared_ptr<API::MatrixWorkspace> &monitorWS); void updateSpectraUsing(const API::SpectrumDetectorMapping &map); - void setTitle(std::string title); - void applyFilter(boost::function<void(API::MatrixWorkspace_sptr)> func); + void setTitle(const std::string &title); + void + applyFilter(const boost::function<void(API::MatrixWorkspace_sptr)> &func); virtual bool threadSafe() const; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h index e40324effba448213744cf3202f8f4a15a8779bb..9a6d5d706a6e78d9eb423b49efb50bfe7d3fd96b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h @@ -122,7 +122,7 @@ private: void readPulseidFile(const std::string &filename, const bool throwError); void runLoadInstrument(const std::string &eventfilename, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); void procEvents(DataObjects::EventWorkspace_sptr &workspace); @@ -133,15 +133,15 @@ private: void setProtonCharge(DataObjects::EventWorkspace_sptr &workspace); - void addToWorkspaceLog(std::string logtitle, size_t mindex); + void addToWorkspaceLog(const std::string &logtitle, size_t mindex); void processEventLogs(); /// Pad out empty pixel - size_t padOutEmptyPixels(DataObjects::EventWorkspace_sptr eventws); + size_t padOutEmptyPixels(const DataObjects::EventWorkspace_sptr &eventws); /// Set up spectrum/detector ID map inside a workspace - void setupPixelSpectrumMap(DataObjects::EventWorkspace_sptr eventws); + void setupPixelSpectrumMap(const DataObjects::EventWorkspace_sptr &eventws); /// void filterEvents(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h index 91f15dbf33c7c04d5a8a9d4bbc84d2ad24948db6..fc590b50ef0a3c2305400075a71b9649e037af6f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h @@ -151,23 +151,23 @@ private: void execEvent(); /// read in the input parameters and see what findout what will be to grouped - void getGroups(API::MatrixWorkspace_const_sptr workspace, + void getGroups(const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); /// gets the list of spectra _index_ _numbers_ from a file of _spectra_ /// _numbers_ void processFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); /// gets groupings from XML file void processXMLFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); - void - processGroupingWorkspace(DataObjects::GroupingWorkspace_const_sptr groupWS, - API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec); - void processMatrixWorkspace(API::MatrixWorkspace_const_sptr groupWS, - API::MatrixWorkspace_const_sptr workspace, + void processGroupingWorkspace( + const DataObjects::GroupingWorkspace_const_sptr &groupWS, + const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec); + void processMatrixWorkspace(const API::MatrixWorkspace_const_sptr &groupWS, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec); /// used while reading the file turns the string into an integer number (if /// possible), white space and # comments ignored @@ -193,14 +193,15 @@ private: /// Copy the and combine the histograms that the user requested from the input /// into the output workspace - size_t formGroups(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, const double prog4Copy, - const bool keepAll, const std::set<int64_t> &unGroupedSet, + size_t formGroups(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, + const double prog4Copy, const bool keepAll, + const std::set<int64_t> &unGroupedSet, Indexing::IndexInfo &indexInfo); /// Copy the and combine the event lists that the user requested from the /// input into the output workspace - size_t formGroupsEvent(DataObjects::EventWorkspace_const_sptr inputWS, - DataObjects::EventWorkspace_sptr outputWS, + size_t formGroupsEvent(const DataObjects::EventWorkspace_const_sptr &inputWS, + const DataObjects::EventWorkspace_sptr &outputWS, const double prog4Copy); /// Copy the ungrouped spectra from the input workspace to the output diff --git a/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h b/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h index b3b794ea2c98cbc9b292ac6beeccfb39e80bcdad..61d2de494c1f0b1c71350307947fbc38663abd61 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h +++ b/Framework/DataHandling/inc/MantidDataHandling/JoinISISPolarizationEfficiencies.h @@ -33,10 +33,10 @@ private: std::vector<API::MatrixWorkspace_sptr> interpolateWorkspaces( std::vector<API::MatrixWorkspace_sptr> const &workspaces); API::MatrixWorkspace_sptr - interpolatePointDataWorkspace(API::MatrixWorkspace_sptr ws, + interpolatePointDataWorkspace(const API::MatrixWorkspace_sptr &ws, size_t const maxSize); API::MatrixWorkspace_sptr - interpolateHistogramWorkspace(API::MatrixWorkspace_sptr ws, + interpolateHistogramWorkspace(const API::MatrixWorkspace_sptr &ws, size_t const maxSize); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/Load.h b/Framework/DataHandling/inc/MantidDataHandling/Load.h index dc91b538d0fa54f50531b4d574037789216fcacc..2fa6eb936de13d88971f8ba12e230c223ab37e5b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/Load.h +++ b/Framework/DataHandling/inc/MantidDataHandling/Load.h @@ -88,7 +88,8 @@ private: API::Workspace_sptr loadFileToWs(const std::string &fileName, const std::string &wsName); /// Plus two workspaces together, "in place". - API::Workspace_sptr plusWs(API::Workspace_sptr ws1, API::Workspace_sptr ws2); + API::Workspace_sptr plusWs(API::Workspace_sptr ws1, + const API::Workspace_sptr &ws2); /// Manually group workspaces. API::WorkspaceGroup_sptr groupWsList(const std::vector<API::Workspace_sptr> &wsList); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h b/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h index 4e24a8d4f844cc7f834542e2892249e4b9793a93..d955e90fec6acf00fd7e6139351b3e02406a2b1c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadAsciiStl.h @@ -7,6 +7,8 @@ #pragma once #include "MantidDataHandling/LoadStl.h" #include <iosfwd> +#include <utility> + namespace Mantid { namespace Kernel { @@ -21,12 +23,12 @@ namespace DataHandling { class DLLExport LoadAsciiStl : public LoadStl { public: LoadAsciiStl(std::string filename, ScaleUnits scaleType) - : LoadStl(filename, scaleType) {} + : LoadStl(std::move(filename), scaleType) {} LoadAsciiStl(std::string filename, ScaleUnits scaleType, ReadMaterial::MaterialParameters params) - : LoadStl(filename, scaleType, params) {} + : LoadStl(std::move(filename), scaleType, std::move(params)) {} std::unique_ptr<Geometry::MeshObject> readStl() override; - static bool isAsciiSTL(std::string filename); + static bool isAsciiSTL(const std::string &filename); private: int m_lineNumber = 0; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h b/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h index 802951c614d5da26ca9c8723ffb984b3e0c73c00..c69730cd169127a3069bce82e31b3b9bebc5078f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadBinaryStl.h @@ -5,6 +5,10 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + +#include <utility> + #include "MantidDataHandling/LoadStl.h" namespace Mantid { @@ -24,12 +28,13 @@ public: static constexpr uint32_t TRIANGLE_COUNT_DATA_SIZE = 4; static constexpr uint32_t VECTOR_DATA_SIZE = 12; LoadBinaryStl(std::string filename, ScaleUnits scaleType) - : LoadStl(filename, scaleType) {} + : LoadStl(std::move(std::move(filename)), scaleType) {} LoadBinaryStl(std::string filename, ScaleUnits scaleType, ReadMaterial::MaterialParameters params) - : LoadStl(filename, scaleType, params) {} + : LoadStl(std::move(std::move(filename)), scaleType, + std::move(std::move(params))) {} std::unique_ptr<Geometry::MeshObject> readStl() override; - static bool isBinarySTL(std::string filename); + static bool isBinarySTL(const std::string &filename); private: void readTriangle(Kernel::BinaryStreamReader, uint32_t &vertexCount); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h index 318a41a699557405fff23f1993c010aa1e66442a..cec536b2ac4ed02aed40d42bc6cf821dee07ff50 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h @@ -53,10 +53,11 @@ public: getInstrument3Ways(API::Algorithm *alg); static bool instrumentIsSpecified(API::Algorithm *alg); - static void readCalFile(const std::string &calFileName, - Mantid::DataObjects::GroupingWorkspace_sptr groupWS, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - Mantid::DataObjects::MaskWorkspace_sptr maskWS); + static void + readCalFile(const std::string &calFileName, + const Mantid::DataObjects::GroupingWorkspace_sptr &groupWS, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const Mantid::DataObjects::MaskWorkspace_sptr &maskWS); protected: Parallel::ExecutionMode getParallelExecutionMode( @@ -70,7 +71,7 @@ private: void exec() override; /// Checks if a detector ID is for a monitor on a given instrument - static bool idIsMonitor(Mantid::Geometry::Instrument_const_sptr inst, + static bool idIsMonitor(const Mantid::Geometry::Instrument_const_sptr &inst, int detID); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h b/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h index 885a8014233a9f6674af8feec46ac0d1fbcfa101..398a393a94fe92dce3e260d1798b73a7df21b3d3 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D.h @@ -76,18 +76,19 @@ protected: const std::string &name) const; /// Appends the new data workspace creating a workspace group if there was /// existing data - void appendDataToOutput(API::MatrixWorkspace_sptr newWork, + void appendDataToOutput(const API::MatrixWorkspace_sptr &newWork, const std::string &newWorkName, - API::WorkspaceGroup_sptr container); + const API::WorkspaceGroup_sptr &container); /// Run LoadInstrument Child Algorithm void runLoadInstrument(const std::string &inst_name, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); /// Loads data into the run log void createLogs(const Poco::XML::Element *const sasEntry, - API::MatrixWorkspace_sptr wSpace) const; + const API::MatrixWorkspace_sptr &wSpace) const; /// Loads the information about hhe sample - void createSampleInformation(const Poco::XML::Element *const sasEntry, - Mantid::API::MatrixWorkspace_sptr wSpace) const; + void createSampleInformation( + const Poco::XML::Element *const sasEntry, + const Mantid::API::MatrixWorkspace_sptr &wSpace) const; }; } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h index 802b74dd7760a93a342a8bce34c027018e0a9711..ca091548c58af7966b865e004ef7410f80090db8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h @@ -102,7 +102,7 @@ private: * * @param workspace handle to the workspace to to load data into */ - void getData(API::MatrixWorkspace_sptr workspace); + void getData(const API::MatrixWorkspace_sptr &workspace); /** * Function to setup the workspace ready for data to be loaded into it @@ -118,7 +118,7 @@ private: * @param xAxis the x axis data * @param yAxis the y axis data */ - void setWorkspaceAxes(API::MatrixWorkspace_sptr workspace, + void setWorkspaceAxes(const API::MatrixWorkspace_sptr &workspace, const std::vector<double> &xAxis, const std::vector<double> &yAxis) const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h index bfc0bf2d36240291ab1bb6181f3603045279724e..66ba3fca07f27f50a888ad3221bc8973d2eca4de 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h @@ -107,7 +107,7 @@ class DLLExport LoadGroupXMLFile { public: LoadGroupXMLFile(); - void loadXMLFile(std::string xmlfilename); + void loadXMLFile(const std::string &xmlfilename); void setDefaultStartingGroupID(int startgroupid) { m_startGroupID = startgroupid; } @@ -167,7 +167,7 @@ private: void parseXML(); /// Get attribute value from an XML node static std::string getAttributeValueByName(Poco::XML::Node *pNode, - std::string attributename, + const std::string &attributename, bool &found); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h index d835ca613f0a9bf9f4f39eaa1bf11a3b5e7fd44a..fe0f2ea36148a5bb42f820ff13a74a54115a778b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDspacemap.h @@ -48,12 +48,12 @@ private: std::map<detid_t, double> &vulcan); void CalculateOffsetsFromDSpacemapFile( - const std::string DFileName, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS); + const std::string &DFileName, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS); void CalculateOffsetsFromVulcanFactors( std::map<detid_t, double> &vulcan, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS); + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h index 8dbc0304175c51ea862e97835ef585796f6aea6e..3c2c8141cb82c705f1039663f4d50bed02e735b8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h @@ -206,8 +206,8 @@ private: void createSpectraMapping( const std::string &nxsfile, const bool monitorsOnly, const std::vector<std::string> &bankNames = std::vector<std::string>()); - void deleteBanks(EventWorkspaceCollection_sptr workspace, - std::vector<std::string> bankNames); + void deleteBanks(const EventWorkspaceCollection_sptr &workspace, + const std::vector<std::string> &bankNames); bool hasEventMonitors(); void runLoadMonitors(); /// Set the filters on TOF. @@ -223,7 +223,7 @@ private: void setTopEntryName(); /// to open the nexus file with specific exception handling/message - void safeOpenFile(const std::string fname); + void safeOpenFile(const std::string &fname); /// Was the instrument loaded? bool m_instrument_loaded_correctly; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h index 60feb2504cbd8c7e7a14c8fba398147d1d706359..a653534a18cd997ad2d7730614b602f1d2857832 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexusIndexSetup.h @@ -28,7 +28,7 @@ class MANTID_DATAHANDLING_DLL LoadEventNexusIndexSetup { public: LoadEventNexusIndexSetup( API::MatrixWorkspace_const_sptr instrumentWorkspace, const int32_t min, - const int32_t max, const std::vector<int32_t> range, + const int32_t max, const std::vector<int32_t> &range, const Parallel::Communicator &communicator = Parallel::Communicator()); std::pair<int32_t, int32_t> eventIDLimits() const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h index e6a43703b1af39036de35f41071ea712bb1526ab..cb2b3b406b9d4056fa60823408b943728cd56014 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h @@ -188,7 +188,7 @@ private: void readPulseidFile(const std::string &filename, const bool throwError); void runLoadInstrument(const std::string &eventfilename, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); inline void fixPixelId(PixelType &pixel, uint32_t &period) const; @@ -202,7 +202,7 @@ private: void setProtonCharge(DataObjects::EventWorkspace_sptr &workspace); - void addToWorkspaceLog(std::string logtitle, size_t mindex); + void addToWorkspaceLog(const std::string &logtitle, size_t mindex); void processImbedLogs(); @@ -212,7 +212,7 @@ private: API::MatrixWorkspace_sptr generateEventDistribtionWorkspace(); - void createOutputWorkspace(const std::string event_filename); + void createOutputWorkspace(const std::string &event_filename); /// Processing the input properties for purpose of investigation void processInvestigationInputs(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h index c4a46f6f1f89c513ef33d6d243637774e7729647..c1720745222adb9c475b30ab537c636253e3a077 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h @@ -91,15 +91,16 @@ private: DataObjects::Workspace2D_sptr makeWorkspace( const FITSInfo &fileInfo, size_t &newFileNumber, std::vector<char> &buffer, API::MantidImage &imageY, - API::MantidImage &imageE, const DataObjects::Workspace2D_sptr parent, + API::MantidImage &imageE, const DataObjects::Workspace2D_sptr &parent, bool loadAsRectImg = false, int binSize = 1, double noiseThresh = false); - void addAxesInfoAndLogs(DataObjects::Workspace2D_sptr ws, bool loadAsRectImg, - const FITSInfo &fileInfo, int binSize, double cmpp); + void addAxesInfoAndLogs(const DataObjects::Workspace2D_sptr &ws, + bool loadAsRectImg, const FITSInfo &fileInfo, + int binSize, double cmpp); // Reads the data from a single FITS file into a workspace (directly, fast) void readDataToWorkspace(const FITSInfo &fileInfo, double cmpp, - DataObjects::Workspace2D_sptr ws, + const DataObjects::Workspace2D_sptr &ws, std::vector<char> &buffer); // Reads the data from a single FITS file into image objects (Y and E) that diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h b/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h index 0719e71aeaa6df686dcc6581d09dfc254b5b210c..0796c67a633fb32f7c52e4b9ca49a60489704fe1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h @@ -51,48 +51,48 @@ public: std::map<std::string, size_t> ¶mmap); /// Put parameters into a matrix workspace - static void putParametersIntoWorkspace(const API::Column_const_sptr, - API::MatrixWorkspace_sptr ws, + static void putParametersIntoWorkspace(const API::Column_const_sptr &, + const API::MatrixWorkspace_sptr &ws, int nProf, std::string ¶meterXMLString); /// Add an Ikeda-Carpenter PV ALFBE parameter - static void addALFBEParameter(const API::Column_const_sptr, + static void addALFBEParameter(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent, const std::string ¶mName); /// Add set of Ikeda-Carpenter PV Sigma parameters - static void addSigmaParameters(const API::Column_const_sptr, + static void addSigmaParameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of Ikeda-Carpenter PV Gamma parameters - static void addGammaParameters(const API::Column_const_sptr, + static void addGammaParameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of BackToBackExponential S parameters - static void addBBX_S_Parameters(const API::Column_const_sptr, + static void addBBX_S_Parameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of BackToBackExponential A parameters - static void addBBX_A_Parameters(const API::Column_const_sptr, + static void addBBX_A_Parameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Add set of BackToBackExponential B parameters - static void addBBX_B_Parameters(const API::Column_const_sptr, + static void addBBX_B_Parameters(const API::Column_const_sptr &, Poco::XML::Document *mDoc, Poco::XML::Element *parent); /// Get value for XML eq attribute for parameter - static std::string getXMLEqValue(const API::Column_const_sptr, + static std::string getXMLEqValue(const API::Column_const_sptr &, const std::string &name); /// Get value for XML eq attribute for squared parameter - static std::string getXMLSquaredEqValue(const API::Column_const_sptr column, + static std::string getXMLSquaredEqValue(const API::Column_const_sptr &column, const std::string &name); // Translate a parameter name from as it appears in the table workspace to its @@ -114,7 +114,7 @@ private: void exec() override; /// Load file to a vector of strings - void loadFile(std::string filename, std::vector<std::string> &lines); + void loadFile(const std::string &filename, std::vector<std::string> &lines); /// Get the NPROF number int getProfNumber(const std::vector<std::string> &lines); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h index bafa82c0063f7f5c2706baf268bd16a1ed64cb58..da15be2dc473984baadb9ec6a0fb53d566958b10 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h @@ -49,7 +49,7 @@ private: void exec() override; /// Load file to a vector of strings - void loadFile(std::string filename, std::vector<std::string> &lines); + void loadFile(const std::string &filename, std::vector<std::string> &lines); /// Get Histogram type std::string getHistogramType(const std::vector<std::string> &lines); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h index 683863dc673ef481c00dc23af23073f0e531518f..cefa59b10e4c8305ff0a36a3a76e287513ddc6d0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h @@ -63,7 +63,7 @@ private: double convertToDouble(std::string inputstring); /// Create an instrument geometry. - void createInstrumentGeometry(API::MatrixWorkspace_sptr workspace, + void createInstrumentGeometry(const API::MatrixWorkspace_sptr &workspace, const std::string &instrumentname, const double &primaryflightpath, const std::vector<int> &detectorids, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h b/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h index 6d61d25ce6781085de33d93e240feeb10ad07416..e1d76e61361236dfe290af9096dcacfe1718bd56 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h @@ -35,18 +35,19 @@ public: static double calculateStandardError(double in) { return sqrt(in); } double calculateEnergy(double); double calculateTOF(double, double); - double getInstrumentProperty(const API::MatrixWorkspace_sptr &, std::string); + double getInstrumentProperty(const API::MatrixWorkspace_sptr &, + const std::string &); void addNexusFieldsToWsRun(NXhandle nxfileID, API::Run &runDetails); void dumpNexusAttributes(NXhandle nxfileID, std::string &indentStr); - std::string dateTimeInIsoFormat(std::string); + std::string dateTimeInIsoFormat(const std::string &); - void moveComponent(API::MatrixWorkspace_sptr ws, + void moveComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::V3D &newPos); - void rotateComponent(API::MatrixWorkspace_sptr ws, + void rotateComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::Quat &rot); - Kernel::V3D getComponentPosition(API::MatrixWorkspace_sptr ws, + Kernel::V3D getComponentPosition(const API::MatrixWorkspace_sptr &ws, const std::string &componentName); private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h index 5da9cae6b1aacc765959225c9767158333e48bf3..b1e0389853c021cb04d8d3dd61fa0d830bc67983 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadIDFFromNexus.h @@ -59,7 +59,7 @@ public: /// Load the parameters from Nexus file if possible, else from parameter file, /// into workspace void LoadParameters(::NeXus::File *nxfile, - const API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } @@ -77,7 +77,7 @@ private: /// Load Parameter File specified by full pathname into given workspace, /// return success bool loadParameterFile(const std::string &fullPathName, - const API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h index d1f7f1456799c8c2c1e7ad5d72eaea2c10f95bfa..5e62681ceae7f0caa121214a7e2303a489327e9d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidAPI/IFileLoader.h" #include "MantidDataHandling/DllConfig.h" #include "MantidDataHandling/LoadHelper.h" @@ -45,7 +47,8 @@ private: std::string unit; ScannedVariables(std::string n, std::string p, std::string u) - : axis(0), scanned(0), name(n), property(p), unit(u) {} + : axis(0), scanned(0), name(std::move(n)), property(std::move(p)), + unit(std::move(u)) {} void setAxis(int a) { axis = a; } void setScanned(int s) { scanned = s; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h index c495fe9c1e58107a42e3bd734e8a9d41fe756bc6..961712138804b2ffb89b6dab068706f4807b39d3 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h @@ -44,7 +44,7 @@ private: void initWorkSpace(); void setInstrumentName(const NeXus::NXEntry &firstEntry, const std::string &instrumentNamePath); - void loadNexusEntriesIntoProperties(std::string nexusfilename); + void loadNexusEntriesIntoProperties(const std::string &nexusfilename); void loadDataIntoTheWorkSpace(NeXus::NXEntry &entry); void runLoadInstrument(); void moveComponent(const std::string &, double); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h index 16f8fabe5d99aa9f00398b8361500cc5588fba43..464d3ebe2a9ccabd431351d1e709cfee8b01d506 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h @@ -129,7 +129,7 @@ private: void createPeriodLogs(int64_t period, DataObjects::Workspace2D_sptr &local_workspace); // Validate multi-period logs - void validateMultiPeriodLogs(Mantid::API::MatrixWorkspace_sptr); + void validateMultiPeriodLogs(const Mantid::API::MatrixWorkspace_sptr &); // build the list of spectra numbers to load and include in the spectra list void buildSpectraInd2SpectraNumMap(bool range_supplied, bool hasSpectraList, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h index f806e3f60e3383c0f4742907fbc2b13035d928de..af8bcd4fb77fb0e86a76188e6a1d7181b9b2fbd2 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h @@ -82,12 +82,12 @@ private: /// Run the Child Algorithm LoadParameters void runLoadParameterFile(const boost::shared_ptr<API::MatrixWorkspace> &ws, - std::string filename); + const std::string &filename); /// Search directory for Parameter file, return full path name if found, else /// "". - std::string getFullPathParamIDF(std::string directoryName, - std::string filename); + std::string getFullPathParamIDF(const std::string &directoryName, + const std::string &filename); /// Mutex to avoid simultaneous access static std::recursive_mutex m_mutex; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h b/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h index c7ba4675acc8ee47c92ce410af2d2851c66a2d2d..a9692c495fc22e48163add0679c910485aae26c0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h @@ -66,15 +66,15 @@ private: /// Set the center of the supplied detector name void center(const double x, const double y, const double z, - const std::string &detname, API::Workspace_sptr ws, + const std::string &detname, const API::Workspace_sptr &ws, Geometry::ComponentInfo &componentInfo); - Geometry::Instrument_sptr getCheckInst(API::Workspace_sptr ws); + Geometry::Instrument_sptr getCheckInst(const API::Workspace_sptr &ws); std::vector<std::string> getFilenames(); void doRotation(Kernel::V3D rX, Kernel::V3D rY, Geometry::ComponentInfo &componentInfo, - boost::shared_ptr<const Geometry::IComponent> comp, + const boost::shared_ptr<const Geometry::IComponent> &comp, bool doWishCorrection = false); void applyScalings( API::Workspace_sptr &ws, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h b/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h index 4649af305d46deb3d59f6a4280f29b6f009bf168..34112bb1bc4fe64eb146ece830f5aba4cb597753 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h @@ -114,7 +114,7 @@ private: /// Create timeseries property from .log file and adds that to sample object void loadThreeColumnLogFile(std::ifstream &logFileStream, - std::string logFileName, API::Run &run); + const std::string &logFileName, API::Run &run); /// Loads two column log file data into local workspace void loadTwoColumnLogFile(std::ifstream &logFileStream, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h index d945e813eabe981d03c4878aaceb2050483a25ac..b447ebc7abb4f9d607e76e9d37648bb6e8667062 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus.h @@ -75,7 +75,7 @@ public: protected: virtual void runLoadInstrumentFromNexus(DataObjects::Workspace2D_sptr) {} void checkOptionalProperties(); - void runLoadInstrument(DataObjects::Workspace2D_sptr); + void runLoadInstrument(const DataObjects::Workspace2D_sptr &); /// The name and path of the input file std::string m_filename; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h index b6bd27025c9fe16edab6a9c2e114507eeb2520f2..a79a1ff9070a78daeed6b09623035444e5112c16 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h @@ -84,13 +84,13 @@ protected: private: void loadData(size_t hist, specnum_t &i, specnum_t specNo, MuonNexusReader &nxload, const int64_t lengthIn, - DataObjects::Workspace2D_sptr localWorkspace); + const DataObjects::Workspace2D_sptr &localWorkspace); void runLoadMappingTable(DataObjects::Workspace2D_sptr); - void runLoadLog(DataObjects::Workspace2D_sptr); - void loadRunDetails(DataObjects::Workspace2D_sptr localWorkspace); - void addPeriodLog(DataObjects::Workspace2D_sptr localWorkspace, + void runLoadLog(const DataObjects::Workspace2D_sptr &); + void loadRunDetails(const DataObjects::Workspace2D_sptr &localWorkspace); + void addPeriodLog(const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period); - void addGoodFrames(DataObjects::Workspace2D_sptr localWorkspace, + void addGoodFrames(const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period, int nperiods); /// Loads dead time table for the detector @@ -104,7 +104,7 @@ private: /// Loads detector grouping information API::Workspace_sptr loadDetectorGrouping(Mantid::NeXus::NXRoot &root, - Mantid::Geometry::Instrument_const_sptr inst); + const Mantid::Geometry::Instrument_const_sptr &inst); /// Creates Detector Grouping Table using all the data from the range DataObjects::TableWorkspace_sptr diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h index 027ca711809cdf3cc67126655002bff2b55459f2..0b43a3c127de6bde6f27095e1c3bfdb74352984c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h @@ -79,9 +79,9 @@ private: HistogramData::Histogram loadData(const Mantid::HistogramData::BinEdges &edges, const Mantid::NeXus::NXInt &counts, int period, int spec); - void loadLogs(API::MatrixWorkspace_sptr ws, Mantid::NeXus::NXEntry &entry, - int period); - void loadRunDetails(DataObjects::Workspace2D_sptr localWorkspace); + void loadLogs(const API::MatrixWorkspace_sptr &ws, + Mantid::NeXus::NXEntry &entry, int period); + void loadRunDetails(const DataObjects::Workspace2D_sptr &localWorkspace); std::map<int, std::set<int>> loadDetectorMapping(const Mantid::NeXus::NXInt &spectrumIndex); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h index 16888c9d70be2683a014d9f31f7c0f6fb5045936..27d649c53b28bf725932bf3f41af037c2edd2b2f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h @@ -62,18 +62,22 @@ private: /// Load log data from a group void loadLogs(::NeXus::File &file, const std::string &entry_name, const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; /// Load an NXlog entry - void loadNXLog(::NeXus::File &file, const std::string &entry_name, - const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; + void + loadNXLog(::NeXus::File &file, const std::string &entry_name, + const std::string &entry_class, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; /// Load an IXseblock entry - void loadSELog(::NeXus::File &file, const std::string &entry_name, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; - void loadVetoPulses(::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; - void loadNPeriods(::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const; + void + loadSELog(::NeXus::File &file, const std::string &entry_name, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; + void loadVetoPulses( + ::NeXus::File &file, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; + void + loadNPeriods(::NeXus::File &file, + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const; /// Progress reporting object boost::shared_ptr<API::Progress> m_progress; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h index 069b37ed9cacad5266e600bcef2594d905362b29..f1ef867e40190d6bcd5f399daf9ed1e665e9927e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h @@ -82,8 +82,8 @@ private: void fixUDets(::NeXus::File &file); /// Load the logs - void runLoadLogs(const std::string filename, - API::MatrixWorkspace_sptr localWorkspace); + void runLoadLogs(const std::string &filename, + const API::MatrixWorkspace_sptr &localWorkspace); /// is it possible to open the file? bool canOpenAsNeXus(const std::string &fname); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h index 230499affc16be9454db1929d73d20b652bf3530..48b3d6ffa83f69b253f2d6c06d81a1f8de4b0361 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h @@ -160,7 +160,7 @@ private: /// Read the bin masking information void readBinMasking(Mantid::NeXus::NXData &wksp_cls, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load a block of data into the workspace where it is assumed that the x /// bins have already been cached @@ -169,7 +169,7 @@ private: Mantid::NeXus::NXDataSetTyped<double> &farea, bool hasFArea, Mantid::NeXus::NXDouble &xErrors, bool hasXErrors, int blocksize, int nchannels, int &hist, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load a block of data into the workspace where it is assumed that the x /// bins have already been cached @@ -178,7 +178,7 @@ private: Mantid::NeXus::NXDataSetTyped<double> &farea, bool hasFArea, Mantid::NeXus::NXDouble &xErrors, bool hasXErrors, int blocksize, int nchannels, int &hist, int &wsIndex, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load a block of data into the workspace void loadBlock(Mantid::NeXus::NXDataSetTyped<double> &data, Mantid::NeXus::NXDataSetTyped<double> &errors, @@ -186,10 +186,10 @@ private: Mantid::NeXus::NXDouble &xErrors, bool hasXErrors, Mantid::NeXus::NXDouble &xbins, int blocksize, int nchannels, int &hist, int &wsIndex, - API::MatrixWorkspace_sptr local_workspace); + const API::MatrixWorkspace_sptr &local_workspace); /// Load the data from a non-spectra axis (Numeric/Text) into the workspace - void loadNonSpectraAxis(API::MatrixWorkspace_sptr local_workspace, + void loadNonSpectraAxis(const API::MatrixWorkspace_sptr &local_workspace, Mantid::NeXus::NXData &data); /// Validates the optional 'spectra to read' properties, if they have been set @@ -232,8 +232,8 @@ private: std::unique_ptr<::NeXus::File> m_nexusFile; }; /// to sort the algorithmhistory vector -bool UDlesserExecCount(Mantid::NeXus::NXClassInfo elem1, - Mantid::NeXus::NXClassInfo elem2); +bool UDlesserExecCount(const Mantid::NeXus::NXClassInfo &elem1, + const Mantid::NeXus::NXClassInfo &elem2); } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h b/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h index a13fc65d74938e7e8b25190268c6abcb0ea2749e..eb30b111e84a9187ccd9cb9d75aa8fa6938bb812 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadOff.h @@ -25,7 +25,7 @@ Mantid::Kernel::Logger g_log("LoadOff"); } class DLLExport LoadOff : public MeshFileIO { public: - LoadOff(std::string filename, ScaleUnits scaleType); + LoadOff(const std::string &filename, ScaleUnits scaleType); std::unique_ptr<Geometry::MeshObject> readOFFshape(); private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h index 4d569896a9a6e3fc8c74fbbc4643c913abffd074..315da9cc9f64a04425765649b11cec586cf09237 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h @@ -46,7 +46,7 @@ private: int confidence(Kernel::FileDescriptor &descriptor) const override; /// Parse PDFgetN data file - void parseDataFile(std::string filename); + void parseDataFile(const std::string &filename); /// Check whether a string starts from a specified sub-string bool startsWith(const std::string &s, const std::string &header) const; @@ -70,7 +70,7 @@ private: void generateDataWorkspace(); /// Set X and Y axis unit and lebel - void setUnit(DataObjects::Workspace2D_sptr ws); + void setUnit(const DataObjects::Workspace2D_sptr &ws); void checkSameSize(const std::vector<size_t> &numptsvec, size_t numsets); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h index 113ec9642bf6c33d03c6c14ebe57fa42347d2f44..05e96c92574a8e8fd922c58ed046bd3ca5fd2656 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h @@ -77,7 +77,8 @@ public: private: void init() override; void exec() override; - std::string getFormattedDateTime(std::string date, std::string time); + std::string getFormattedDateTime(const std::string &date, + const std::string &time); void assignOutputWorkspaceParticulars( DataObjects::Workspace2D_sptr &outputWorkspace); void readSingleVariables(Mantid::Kernel::BinaryStreamReader &streamReader); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h index 5684f3fd53453c0090a1e7b571e7473ef923c3e9..40e77ebfef29bd30e43dadd12989fcb2e67d4b79 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h @@ -55,7 +55,7 @@ private: bool instrument_loaded_correctly; void runLoadInstrument(const std::string &instrument, - API::MatrixWorkspace_sptr localWorkspace); + const API::MatrixWorkspace_sptr &localWorkspace); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h index 79c99457f429da52a7dfd44ceb27b824abfc59f6..14fa413ddb7dc5bc09e1c9fd4f79852276a4da1d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h @@ -74,7 +74,7 @@ private: MantidVec &axis0Data); const std::string readUnit(const std::string &line); void readNumEntrys(const int nEntries, MantidVec &output); - void binCenter(const MantidVec oldBoundaries, MantidVec &toCenter) const; + void binCenter(const MantidVec &oldBoundaries, MantidVec &toCenter) const; // Remove lines from an input stream void skipLines(std::istream &strm, int nlines); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h index 71f95e5c32cff1d8d08659b3458e45a936b6c3f7..b8d7830f511bc39be6264aabf2252be16d500dbd 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h @@ -67,18 +67,18 @@ private: /// creates output workspace, monitors excluded from this workspace void excludeMonitors(FILE *file, const int &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr); + const DataObjects::Workspace2D_sptr &ws_sptr); /// creates output workspace whcih includes monitors void includeMonitors(FILE *file, const int64_t &period, - DataObjects::Workspace2D_sptr ws_sptr); + const DataObjects::Workspace2D_sptr &ws_sptr); /// creates two output workspaces none normal workspace and separate one for /// monitors void separateMonitors(FILE *file, const int64_t &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr, - DataObjects::Workspace2D_sptr mws_sptr); + const DataObjects::Workspace2D_sptr &ws_sptr, + const DataObjects::Workspace2D_sptr &mws_sptr); /// skip all spectra in a period void skipPeriod(FILE *file, const int64_t &period); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h index bb1d04fec7a716cbedaa0cc5903ac80f7f756798..a58f0d23642f491bbd0656c1bebe2415df625bd6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h @@ -53,7 +53,7 @@ public: /// Opens Raw File FILE *openRawFile(const std::string &fileName); /// Read in run parameters Public so that LoadRaw2 can use it - void loadRunParameters(API::MatrixWorkspace_sptr localWorkspace, + void loadRunParameters(const API::MatrixWorkspace_sptr &localWorkspace, ISISRAW *const = nullptr) const; /// Returns a confidence value that this algorithm can load a file @@ -77,14 +77,15 @@ public: API::WorkspaceGroup_sptr &mongrp_sptr, const int64_t mwsSpecs, const int64_t nwsSpecs, const int64_t numberOfPeriods, const int64_t lengthIn, - std::string title, API::Algorithm *const pAlg); + const std::string &title, API::Algorithm *const pAlg); /// creates shared pointer to group workspace static API::WorkspaceGroup_sptr createGroupWorkspace(); /// creates shared pointer to workspace from parent workspace static DataObjects::Workspace2D_sptr - createWorkspace(DataObjects::Workspace2D_sptr ws_sptr, int64_t nVectors = -1, - int64_t xLengthIn = -1, int64_t yLengthIn = -1); + createWorkspace(const DataObjects::Workspace2D_sptr &ws_sptr, + int64_t nVectors = -1, int64_t xLengthIn = -1, + int64_t yLengthIn = -1); /// overloaded method to create shared pointer to workspace static DataObjects::Workspace2D_sptr @@ -94,14 +95,14 @@ public: /// sets the workspace property static void setWorkspaceProperty(const std::string &propertyName, const std::string &title, - API::WorkspaceGroup_sptr grpws_sptr, - DataObjects::Workspace2D_sptr ws_sptr, + const API::WorkspaceGroup_sptr &grpws_sptr, + const DataObjects::Workspace2D_sptr &ws_sptr, int64_t numberOfPeriods, bool bMonitor, API::Algorithm *const pAlg); /// overloaded method to set the workspace property - static void setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr, - API::WorkspaceGroup_sptr grpws_sptr, + static void setWorkspaceProperty(const DataObjects::Workspace2D_sptr &ws_sptr, + const API::WorkspaceGroup_sptr &grpws_sptr, const int64_t period, bool bmonitors, API::Algorithm *const pAlg); @@ -138,20 +139,20 @@ protected: getTimeChannels(const int64_t ®imes, const int64_t &lengthIn); /// loadinstrument Child Algorithm void runLoadInstrument(const std::string &fileName, - DataObjects::Workspace2D_sptr, double, double); + const DataObjects::Workspace2D_sptr &, double, double); /// loadinstrumentfromraw algorithm void runLoadInstrumentFromRaw(const std::string &fileName, - DataObjects::Workspace2D_sptr); + const DataObjects::Workspace2D_sptr &); /// loadinstrumentfromraw Child Algorithm void runLoadMappingTable(const std::string &fileName, - DataObjects::Workspace2D_sptr); + const DataObjects::Workspace2D_sptr &); /// load log algorithm - void runLoadLog(const std::string &fileName, DataObjects::Workspace2D_sptr, - double, double); + void runLoadLog(const std::string &fileName, + const DataObjects::Workspace2D_sptr &, double, double); /// Create the period specific logs void createPeriodLogs(int64_t period, - DataObjects::Workspace2D_sptr local_workspace); + const DataObjects::Workspace2D_sptr &local_workspace); /// gets the monitor spectrum list from the workspace std::vector<specnum_t> @@ -159,7 +160,7 @@ protected: /// This method sets the raw file data to workspace vectors void setWorkspaceData( - DataObjects::Workspace2D_sptr newWorkspace, + const DataObjects::Workspace2D_sptr &newWorkspace, const std::vector<boost::shared_ptr<HistogramData::HistogramX>> &timeChannelsVec, int64_t wsIndex, specnum_t nspecNum, int64_t noTimeRegimes, @@ -191,9 +192,10 @@ protected: specnum_t &normalwsSpecs, specnum_t &monitorwsSpecs); /// load the spectra - void loadSpectra(FILE *file, const int &period, const int &total_specs, - DataObjects::Workspace2D_sptr ws_sptr, - std::vector<boost::shared_ptr<HistogramData::HistogramX>>); + void loadSpectra( + FILE *file, const int &period, const int &total_specs, + const DataObjects::Workspace2D_sptr &ws_sptr, + const std::vector<boost::shared_ptr<HistogramData::HistogramX>> &); /// Has the spectrum_list property been set? bool m_list; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h index e0988a1b984e403fab515eb95908c775ae078579..2625e5f3a2f27d94952103d84f7c2843cc1b709f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h @@ -53,7 +53,7 @@ private: // Execution code void exec() override; - void readHistogram(FILE *speFile, API::MatrixWorkspace_sptr workspace, + void readHistogram(FILE *speFile, const API::MatrixWorkspace_sptr &workspace, size_t index); void reportFormatError(const std::string &what); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h index 3e6c44698d9f77b8848a2f7a632eae85f8d45020..c14c313e1f73e9bc1ee54e01690752e95f716ea6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSampleShape.h @@ -51,7 +51,7 @@ private: void exec() override; }; void DLLExport rotate(Geometry::MeshObject &sampleMesh, - API::MatrixWorkspace_const_sptr inputWS); + const API::MatrixWorkspace_const_sptr &inputWS); } // namespace DataHandling } // namespace Mantid \ No newline at end of file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h index a096ef48ae13878c266c8a73819811aa63410fbc..868bf2eaeec30b4ddc855ef3f1590450b15862ed 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSassena.h @@ -62,26 +62,27 @@ public: protected: /// Add a workspace to the group and register in the analysis data service - void registerWorkspace(API::WorkspaceGroup_sptr gws, const std::string wsName, - DataObjects::Workspace2D_sptr ws, + void registerWorkspace(const API::WorkspaceGroup_sptr &gws, + const std::string &wsName, + const DataObjects::Workspace2D_sptr &ws, const std::string &description); /// Read info about one HDF5 dataset, log if error - herr_t dataSetInfo(const hid_t &h5file, const std::string setName, + herr_t dataSetInfo(const hid_t &h5file, const std::string &setName, hsize_t *dims) const; /// Read dataset data to a buffer ot type double - herr_t dataSetDouble(const hid_t &h5file, const std::string setName, + herr_t dataSetDouble(const hid_t &h5file, const std::string &setName, std::vector<double> &buf); /// Load qvectors dataset, calculate modulus of vectors HistogramData::Points loadQvectors(const hid_t &h5file, - API::WorkspaceGroup_sptr gws, + const API::WorkspaceGroup_sptr &gws, std::vector<int> &sorting_indexes); /// Load structure factor asa function of q-vector modulus - void loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, const HistogramData::Points &qvmod, + void loadFQ(const hid_t &h5file, const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes); /// Load time-dependent structure factor - void loadFQT(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, const HistogramData::Points &qvmod, + void loadFQT(const hid_t &h5file, const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes); private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h index d88b9cb7b75203a720af4bd415a0f6582d34be15..44282d49fa10f11bfe453f968b15056b3b50e5c2 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h @@ -93,7 +93,7 @@ private: const std::string &fileName); /// Run LoadInstrument Child Algorithm void runLoadInstrument(const std::string &inst_name, - DataObjects::Workspace2D_sptr localWorkspace); + const DataObjects::Workspace2D_sptr &localWorkspace); void setInputPropertiesAsMemberProperties(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h index 921e9c70de08d57b806794e619461f597f9b1009..933ba795ff60126f514a5691a8b5010ba9d8c01b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h @@ -63,13 +63,13 @@ private: const std::string &timeformat); /// Set up run start time - void setupRunStartTime(API::MatrixWorkspace_sptr runinfows, + void setupRunStartTime(const API::MatrixWorkspace_sptr &runinfows, const std::vector<std::string> &datetimeprop); /// Add property to workspace template <typename T> - void addProperty(API::MatrixWorkspace_sptr ws, const std::string &pname, - T pvalue); + void addProperty(const API::MatrixWorkspace_sptr &ws, + const std::string &pname, T pvalue); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h index d94532db83bbe5f5f348fe41cded5e335e24b5a9..16779c563688f8f2c7c01d6dd91b6ad32f42aff5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h @@ -96,22 +96,25 @@ private: /// Set up sample logs from table workspace loaded where SPICE data file is /// loaded - void setupSampleLogFromSpiceTable(API::MatrixWorkspace_sptr matrixws, - API::ITableWorkspace_sptr spicetablews, - int ptnumber); + void + setupSampleLogFromSpiceTable(const API::MatrixWorkspace_sptr &matrixws, + const API::ITableWorkspace_sptr &spicetablews, + int ptnumber); /// Set up sample logs in the output workspace - bool setupSampleLogs(API::MatrixWorkspace_sptr outws); + bool setupSampleLogs(const API::MatrixWorkspace_sptr &outws); /// Load instrument void loadInstrument(API::MatrixWorkspace_sptr matrixws, const std::string &idffilename); /// Get wavelength from workspace - bool getHB3AWavelength(API::MatrixWorkspace_sptr dataws, double &wavelength); + bool getHB3AWavelength(const API::MatrixWorkspace_sptr &dataws, + double &wavelength); /// Set output workspace's X-axs as lab-frame Q space - void setXtoLabQ(API::MatrixWorkspace_sptr dataws, const double &wavelength); + void setXtoLabQ(const API::MatrixWorkspace_sptr &dataws, + const double &wavelength); /// SPICE detector XML file std::string m_detXMLFileName; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h b/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h index 49241fa4bb8cd7f27626df2844e6d6370aa56a54..70f438c3e3f1dea953944c28d549a71232615ca4 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadStl.h @@ -14,6 +14,10 @@ #include <boost/functional/hash.hpp> #include <functional> #include <unordered_set> +#include <utility> + +#include <utility> + namespace { Mantid::Kernel::Logger g_logstl("LoadStl"); } @@ -45,11 +49,12 @@ struct V3DTrueComparator { class DLLExport LoadStl : public MeshFileIO { public: LoadStl(std::string filename, ScaleUnits scaleType) - : MeshFileIO(scaleType), m_filename(filename), m_setMaterial(false) {} + : MeshFileIO(scaleType), m_filename(std::move(std::move(filename))), + m_setMaterial(false) {} LoadStl(std::string filename, ScaleUnits scaleType, ReadMaterial::MaterialParameters params) - : MeshFileIO(scaleType), m_filename(filename), m_setMaterial(true), - m_params(params) {} + : MeshFileIO(scaleType), m_filename(std::move(std::move(filename))), + m_setMaterial(true), m_params(std::move(std::move(params))) {} virtual std::unique_ptr<Geometry::MeshObject> readStl() = 0; virtual ~LoadStl() = default; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h b/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h index 07d00e4119f4b49ccf81dba90c03d72533eaea0a..5fa31d720d3dcbb732459b9554e0a53947eebd95 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadStlFactory.h @@ -15,7 +15,7 @@ namespace DataHandling { class MANTID_DATAHANDLING_DLL LoadStlFactory { public: - static std::unique_ptr<LoadStl> createReader(std::string filename, + static std::unique_ptr<LoadStl> createReader(const std::string &filename, ScaleUnits scaleType) { std::unique_ptr<LoadStl> reader = nullptr; if (LoadBinaryStl::isBinarySTL(filename)) { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h b/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h index f0735d097a4b17e2f3420d4a3800e4703a54430f..b0b805b2b947dbca71aeb88e49ac3779d1fd06d0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h @@ -52,13 +52,13 @@ private: size_t getCells(std::string line, std::vector<std::string> &cols, size_t expectedCommas, bool isOldTBL) const; /// count the number of commas in the line - size_t countCommas(std::string line) const; + size_t countCommas(const std::string &line) const; /// find all pairs of quotes in the line - size_t findQuotePairs(std::string line, + size_t findQuotePairs(const std::string &line, std::vector<std::vector<size_t>> "eBounds) const; /// Parse more complex CSV, used when the data involves commas in the data and /// quoted values - void csvParse(std::string line, std::vector<std::string> &cols, + void csvParse(const std::string &line, std::vector<std::string> &cols, std::vector<std::vector<size_t>> "eBounds, size_t expectedCommas) const; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h index e2275e1142d8692c3c84175dbf88699d0bdf6d82..2bced73be98aa817733b6259fb46fee170cabd58 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h @@ -79,7 +79,8 @@ protected: Mantid::NeXus::NXEntry &entry); void loadBank(const std::string &nexusfilename, const std::string &entry_name, - const std::string &bankName, API::MatrixWorkspace_sptr WS, + const std::string &bankName, + const API::MatrixWorkspace_sptr &WS, const detid2index_map &id_to_wi); /// List of the absolute time of each pulse diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h index 348d60b27da180164b5fede1104ac1fe6e76811c..bed7624a812692c2b1450e279b5ee90863542302 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h @@ -78,41 +78,42 @@ private: /// Choose how to mask given that we have a mask workspace void - handleMaskByMaskWorkspace(const DataObjects::MaskWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, + handleMaskByMaskWorkspace(const DataObjects::MaskWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, std::vector<detid_t> &detectorList, std::vector<size_t> &indexList, const RangeInfo &rangeInfo); /// Choose how to mask given that we have a matrix workspace - void handleMaskByMatrixWorkspace(const API::MatrixWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, - std::vector<detid_t> &detectorList, - std::vector<size_t> &indexList, - const RangeInfo &rangeInfo); + void + handleMaskByMatrixWorkspace(const API::MatrixWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, + std::vector<detid_t> &detectorList, + std::vector<size_t> &indexList, + const RangeInfo &rangeInfo); - void execPeaks(DataObjects::PeaksWorkspace_sptr WS); + void execPeaks(const DataObjects::PeaksWorkspace_sptr &WS); void fillIndexListFromSpectra(std::vector<size_t> &indexList, std::vector<Indexing::SpectrumNumber> spectraList, - const API::MatrixWorkspace_sptr WS, + const API::MatrixWorkspace_sptr &WS, const RangeInfo &range_info); void appendToDetectorListFromComponentList( std::vector<detid_t> &detectorList, const std::vector<std::string> &componentList, - const API::MatrixWorkspace_const_sptr WS); - void - appendToIndexListFromWS(std::vector<size_t> &indexList, - const API::MatrixWorkspace_const_sptr maskedWorkspace, - const RangeInfo &range_info); + const API::MatrixWorkspace_const_sptr &WS); + void appendToIndexListFromWS( + std::vector<size_t> &indexList, + const API::MatrixWorkspace_const_sptr &maskedWorkspace, + const RangeInfo &range_info); void appendToDetectorListFromWS( std::vector<detid_t> &detectorList, - const API::MatrixWorkspace_const_sptr inputWs, - const API::MatrixWorkspace_const_sptr maskWs, + const API::MatrixWorkspace_const_sptr &inputWs, + const API::MatrixWorkspace_const_sptr &maskWs, const std::tuple<size_t, size_t, bool> &range_info); void appendToIndexListFromMaskWS( std::vector<size_t> &indexList, - const DataObjects::MaskWorkspace_const_sptr maskedWorkspace, + const DataObjects::MaskWorkspace_const_sptr &maskedWorkspace, const std::tuple<size_t, size_t, bool> &range_info); void extractMaskedWSDetIDs(std::vector<detid_t> &detectorList, diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h index 3cfa902ea957396d54e65ac5a5c55302501313d0..470d7a07065bac5024d3115dabde625150032913 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h @@ -58,11 +58,12 @@ private: void exec() override; // internal functions - std::vector<int> runFindDetectorsInShape(API::MatrixWorkspace_sptr workspace, - const std::string shapeXML, - const bool includeMonitors); + std::vector<int> + runFindDetectorsInShape(const API::MatrixWorkspace_sptr &workspace, + const std::string &shapeXML, + const bool includeMonitors); /// Calls MaskDetectors as a Child Algorithm - void runMaskDetectors(API::MatrixWorkspace_sptr workspace, + void runMaskDetectors(const API::MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIds); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h b/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h index cfaecf881b60414ed185bb25bcba592a0a795fab..836cbfa262b5f165b998d815893bc4b6cd596e03 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MeshFileIO.h @@ -4,6 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + +#include <utility> + #include "MantidGeometry/Objects/MeshObject.h" #include "MantidKernel/Logger.h" #include "MantidKernel/Matrix.h" @@ -32,7 +36,7 @@ public: boost::shared_ptr<Geometry::MeshObject> translate(boost::shared_ptr<Geometry::MeshObject> environmentMesh, - const std::vector<double> translationVector); + const std::vector<double> &translationVector); Kernel::V3D createScaledV3D(double xVal, double yVal, double zVal); @@ -40,7 +44,8 @@ protected: MeshFileIO(ScaleUnits scaleType) : m_scaleType(scaleType) {} MeshFileIO(ScaleUnits scaleType, std::vector<uint32_t> triangles, std::vector<Kernel::V3D> vertices) - : m_scaleType(scaleType), m_triangle(triangles), m_vertices(vertices) {} + : m_scaleType(scaleType), m_triangle(std::move(std::move(triangles))), + m_vertices(std::move(std::move(vertices))) {} double scaleValue(double val) { switch (m_scaleType) { case ScaleUnits::centimetres: diff --git a/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h b/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h index 269124451da6e5d60d1e3f70c9ab15b44103399c..0a56541102e2d0c9cf0912ec3e2820b1524aec08 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h +++ b/Framework/DataHandling/inc/MantidDataHandling/PDLoadCharacterizations.h @@ -32,7 +32,7 @@ private: void init() override; void exec() override; std::vector<std::string> getFilenames(); - int readFocusInfo(std::ifstream &file, const std::string filename); + int readFocusInfo(std::ifstream &file, const std::string &filename); void readCharInfo(std::ifstream &file, API::ITableWorkspace_sptr &wksp, const std::string &filename, int linenum); void readVersion0(const std::string &filename, diff --git a/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h b/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h index 8333dba7bdaaba21336e122b020442c7c4cd2d30..5b9e50cf67c841f6f145b4e341906287fb627bd5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h +++ b/Framework/DataHandling/inc/MantidDataHandling/ReadMaterial.h @@ -88,7 +88,7 @@ private: */ Kernel::MaterialBuilder builder; - void setMaterial(const std::string chemicalSymbol, const int atomicNumber, + void setMaterial(const std::string &chemicalSymbol, const int atomicNumber, const int massNumber); void diff --git a/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h b/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h index c33a6590a50ccd2992d05fa3681b648fa7e1d506..78c8749ad34f366c0b06e7c4004a57b271b7595b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SampleEnvironmentSpecParser.h @@ -55,10 +55,10 @@ private: boost::shared_ptr<Geometry::MeshObject> loadMeshFromSTL(Poco::XML::Element *stlfile) const; void LoadOptionalDoubleFromXML(Poco::XML::Element *componentElement, - std::string elementName, + const std::string &elementName, double &targetVariable) const; std::vector<double> - parseTranslationVector(std::string translationVectorStr) const; + parseTranslationVector(const std::string &translationVectorStr) const; // Members MaterialsIndex m_materials; std::string m_filepath; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h b/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h index 42390a7540bfcb0fd61674df709e044400b4195c..f8200d93c8dd6ff7825c0b7b4a031b8b5a63c218 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h @@ -71,7 +71,7 @@ private: void init() override; /// Overwrites Algorithm method void exec() override; - void writeTableWorkspace(API::ITableWorkspace_const_sptr tws, + void writeTableWorkspace(const API::ITableWorkspace_const_sptr &tws, const std::string &filename, bool appendToFile, bool writeHeader, int prec, bool scientific, const std::string &comment); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h index d5cc8447598607ebd7a5f3775130bf5ff87f87e7..90f55bf118cd0c9d65a482245ca45288594bb8cd 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h @@ -93,7 +93,7 @@ private: /// Saves out x errors void saveXerrors(std::ofstream &stream, - const Mantid::DataObjects::Workspace2D_sptr workspace, + const Mantid::DataObjects::Workspace2D_sptr &workspace, const size_t numberOfHist); /// The name of the file used for storing the workspace diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h index 00a1032d55f1b05b373e55b4cec183a5147d0914..4517ae2f2110875514cc96bc4156c7321acda561 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h @@ -46,9 +46,9 @@ public: } void saveCalFile(const std::string &calFileName, - Mantid::DataObjects::GroupingWorkspace_sptr groupWS, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - Mantid::DataObjects::MaskWorkspace_sptr maskWS); + const Mantid::DataObjects::GroupingWorkspace_sptr &groupWS, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const Mantid::DataObjects::MaskWorkspace_sptr &maskWS); private: /// Initialise the properties diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h index fc19656f86a96c247cb9fc298a3e9d8d350d7e89..c074c823132132df31cad6ab4b0f6f90fae5237c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h @@ -53,8 +53,8 @@ private: std::map<int, std::vector<detid_t>> &groupdetidrangemap); /// Print Grouping to XML file - void printToXML(std::map<int, std::vector<detid_t>> groupdetidrangemap, - std::string xmlfilename); + void printToXML(const std::map<int, std::vector<detid_t>> &groupdetidrangemap, + const std::string &xmlfilename); // GroupingWorkspace DataObjects::GroupingWorkspace_const_sptr mGroupWS; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h index 89bdadbcf618ab3bf33535e7168cacccb74d6153..31208c7163e9e419bf0a499bc6759d1b05b6d1c1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h @@ -37,8 +37,9 @@ 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, - 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/SaveDiffFittingAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h index ed595087a6c93394be00c5b86d401869b8133545..3c21f96289b1ec337303fc1b647c54dbfc5786e6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h @@ -57,7 +57,7 @@ private: std::map<std::string, std::string> validateInputs() override; /// Main exec routine, called for group or individual workspace processing. - void processAll(const std::vector<API::ITableWorkspace_sptr> input_ws); + void processAll(const std::vector<API::ITableWorkspace_sptr> &input_ws); std::vector<std::string> splitList(std::string strList); @@ -67,8 +67,8 @@ private: void writeHeader(const std::vector<std::string> &columnHeadings, std::ofstream &file); - void writeData(const API::ITableWorkspace_sptr workspace, std::ofstream &file, - const size_t columnSize); + void writeData(const API::ITableWorkspace_sptr &workspace, + std::ofstream &file, const size_t columnSize); void writeVal(const std::string &val, std::ofstream &file, const bool endline); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h index 8a8bffd0901741cc6e348c397dc56772b6ae30f7..37581742e89b42152724fe74d9c98fff69f98b3e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDspacemap.h @@ -39,9 +39,9 @@ private: /// Run the algorithm void exec() override; - void - CalculateDspaceFromCal(Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - std::string DFileName); + void CalculateDspaceFromCal( + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const std::string &DFileName); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h b/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h index 9542b929f17b50ee990dd21e951e90c4553bddf0..9c4afe889aa51f62ada4f52cc0566480b75a3860 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h @@ -36,20 +36,20 @@ private: std::map<std::string, std::string> validateInputs() override; - void saveFITSImage(const API::MatrixWorkspace_sptr img, + void saveFITSImage(const API::MatrixWorkspace_sptr &img, const std::string &filename); - void writeFITSHeaderBlock(const API::MatrixWorkspace_sptr img, + void writeFITSHeaderBlock(const API::MatrixWorkspace_sptr &img, std::ofstream &file); - void writeFITSImageMatrix(const API::MatrixWorkspace_sptr img, + void writeFITSImageMatrix(const API::MatrixWorkspace_sptr &img, std::ofstream &file); void writeFITSHeaderEntry(const std::string &hdr, std::ofstream &file); std::string makeBitDepthHeader(size_t depth) const; - void writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr img, + void writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr &img, std::ofstream &file); void writePaddingFITSHeaders(size_t count, std::ofstream &file); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h b/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h index 5dd4317b12db6decdf26f19a0fc493ba8e22662c..2ce04b6bce0901256770d5a44200a1d6385aeb9d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h @@ -57,7 +57,7 @@ private: void parseTableWorkspace(); /// Check wether a profile parameter map has the parameter - bool has_key(std::map<std::string, double> profmap, std::string key); + bool has_key(std::map<std::string, double> profmap, const std::string &key); /// Map containing the name of value of each parameter required by .irf file std::map<std::string, double> m_profileParamMap; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h index 0ac855d14a38f79832e15ecef497c1876a518cd1..a0024f2f5b488a04c6ca1c29173206c24250c426 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h @@ -66,7 +66,7 @@ private: /// Parse profile table workspace to a map void parseProfileTableWorkspace( - API::ITableWorkspace_sptr ws, + const API::ITableWorkspace_sptr &ws, std::map<unsigned int, std::map<std::string, double>> &profilemap); /// Convert to GSAS instrument file @@ -113,7 +113,7 @@ private: const std::string ¶mname); /// Load fullprof resolution file. - void loadFullprofResolutionFile(std::string irffilename); + void loadFullprofResolutionFile(const std::string &irffilename); /// Calcualte d-space value. double calDspRange(double dtt1, double zero, double tof); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h b/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h index e3a928646e4c779fd26df3e789de7d2f4a5b402b..2589c5a0b3971398f99f09cdf63f9fce0f6e9044 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h @@ -46,9 +46,9 @@ private: /// Run the algorithm void exec() override; /// find position for rectangular and non-rectangular - Kernel::V3D findPixelPos(std::string bankName, int col, int row); - void sizeBanks(std::string bankName, int &NCOLS, int &NROWS, double &xsize, - double &ysize); + Kernel::V3D findPixelPos(const std::string &bankName, int col, int row); + void sizeBanks(const std::string &bankName, int &NCOLS, int &NROWS, + double &xsize, double &ysize); Geometry::Instrument_const_sptr inst; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h index 8bef56681d2a08de8f7beda2377cebd929aed092..7a681a780a2138c96418980a8fa2952f7d9471f8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h @@ -87,16 +87,16 @@ private: ::NeXus::File setupFile(); /// Writes a single workspace into the file - void writeSingleWorkspace(const DataObjects::Workspace2D_sptr workspace, + void writeSingleWorkspace(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile); /// Write various pieces of data from the workspace log with checks on the /// structure of the nexus file - void writeLogValues(const DataObjects::Workspace2D_sptr workspace, + void writeLogValues(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd); - void writeIntensityValue(const DataObjects::Workspace2D_sptr workspace, + void writeIntensityValue(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd); - void writeImageKeyValue(const DataObjects::Workspace2D_sptr workspace, + void writeImageKeyValue(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd); /// Main exec routine, called for group or individual workspace processing. diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h index 9f918dd374be63f0115a72deaa175d7bffc5d79a..89c4f0f0f537281717fd740805302f391213bf03 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h @@ -74,8 +74,9 @@ protected: void exec() override; private: - void getWSIndexList(std::vector<int> &indices, - Mantid::API::MatrixWorkspace_const_sptr matrixWorkspace); + void getWSIndexList( + std::vector<int> &indices, + const Mantid::API::MatrixWorkspace_const_sptr &matrixWorkspace); template <class T> static void appendEventListData(const std::vector<T> &events, size_t offset, @@ -88,7 +89,7 @@ private: void setOtherProperties(IAlgorithm *alg, const std::string &propertyName, const std::string &propertyValue, int perioidNum) override; - void doExec(Mantid::API::Workspace_sptr inputWorkspace, + void doExec(const Mantid::API::Workspace_sptr &inputWorkspace, boost::shared_ptr<Mantid::NeXus::NexusFileIO> &nexusFile, const bool keepFile = false, boost::optional<size_t> entryNumber = boost::optional<size_t>()); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h b/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h index 8450d6896e798286e7b49855f60f4ad61ec066db..8c95297a31f7e4eb6ee34fef995387927cb75f83 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h @@ -36,8 +36,9 @@ private: void init() override; void exec() override; void writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS); - void writeWSData(std::ofstream &out, API::MatrixWorkspace_const_sptr inputWS); + const API::MatrixWorkspace_const_sptr &inputWS); + void writeWSData(std::ofstream &out, + const API::MatrixWorkspace_const_sptr &inputWS); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h index eeb3cb7e7218dc58c63cc32167c6b541e77cea80..c8c67ab28d4d6f8b48a9e08c2330854e5e0b39da 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveRMCProfile.h @@ -36,8 +36,9 @@ private: void init() override; void exec() override; void writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS); - void writeWSData(std::ofstream &out, API::MatrixWorkspace_const_sptr inputWS); + const API::MatrixWorkspace_const_sptr &inputWS); + void writeWSData(std::ofstream &out, + const API::MatrixWorkspace_const_sptr &inputWS); }; } // namespace DataHandling diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h index 3bc16d6fc8034312767f5cde4e66cae11187c0bd..f809ddceca51b9438212b2f84ae448c6d4d5df70 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveReflectometryAscii.h @@ -49,22 +49,22 @@ private: /// Algorithm execution for WorkspaceGroups bool processGroups() override; /// Check file validity - void checkFile(const std::string filename); + void checkFile(const std::string &filename); /// Write the data void data(); /// Print a double value to file void outputval(double val); /// Write a string value - bool writeString(bool write, std::string s); + bool writeString(bool write, const std::string &s); /// Print a string value to file - void outputval(std::string val); + void outputval(const std::string &val); /// Retrieve sample log value std::string sampleLogValue(const std::string &logName); /// Retrieve sample log unit std::string sampleLogUnit(const std::string &logName); /// Write one header line - void writeInfo(const std::string logName, - const std::string logNameFixed = ""); + void writeInfo(const std::string &logName, + const std::string &logNameFixed = ""); /// Write header void header(); /// Determine the separator diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h b/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h index 52ff3ccbfa93054f69619816b3851ec3041d7cc2..e755e6695aa0169d528674bcb44822fb2a620fcd 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h @@ -82,9 +82,9 @@ private: void writeSPEFile(FILE *outSPEFile, const API::MatrixWorkspace_const_sptr &inputWS); - void writeHists(const API::MatrixWorkspace_const_sptr WS, + void writeHists(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile); - void writeHist(const API::MatrixWorkspace_const_sptr WS, FILE *const outFile, + void writeHist(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile, const int wsIn) const; void writeMaskFlags(FILE *const outFile) const; void writeBins(const std::vector<double> &Vs, FILE *const outFile) const; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h b/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h index bfcfd68fe13c406130e0c2c96aa898d13a0fe39d..5ef1d1bac0110cc3801a65aff138e5374fdf2d4a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveStl.h @@ -6,6 +6,10 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + +#include <utility> + #include "MantidDataHandling/MeshFileIO.h" #include "MantidKernel/BinaryStreamWriter.h" #include "MantidKernel/Logger.h" @@ -25,9 +29,10 @@ enum class ScaleUnits; */ class DLLExport SaveStl : public MeshFileIO { public: - SaveStl(const std::string &filename, const std::vector<uint32_t> triangle, + SaveStl(const std::string &filename, const std::vector<uint32_t> &triangle, std::vector<Kernel::V3D> vertices, ScaleUnits scaleType) - : MeshFileIO(scaleType, triangle, vertices), m_filename(filename) {} + : MeshFileIO(scaleType, triangle, std::move(std::move(vertices))), + m_filename(filename) {} void writeStl(); diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h index dd647e3b3ac44efb80009848c8ebe19c3893301d..8e47983f277944003fedfabdbe693790772bd82f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h @@ -53,7 +53,7 @@ private: /// the separator const char m_sep; // populates the map and vector containing grouping information - void findGroups(API::ITableWorkspace_sptr ws); + void findGroups(const API::ITableWorkspace_sptr &ws); /// Map the separator options to their string equivalents std::map<int, std::vector<size_t>> m_stichgroups; std::vector<size_t> m_nogroup; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h b/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h index 95eac01ee17e7a692cfbbb5639a6ec61aac535bd..4d581a2352b5ce644c545fa88743735050e60d42 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h @@ -95,12 +95,13 @@ private: int copy_file(const char *inFile, int nx_read_access, const char *outFile, int nx_write_access); - int WriteOutDataOrErrors(Geometry::RectangularDetector_const_sptr det, + int WriteOutDataOrErrors(const Geometry::RectangularDetector_const_sptr &det, int x_pixel_slab, const char *field_name, const char *errors_field_name, bool doErrors, - bool doBoth, int is_definition, std::string bank); + bool doBoth, int is_definition, + const std::string &bank); - int WriteDataGroup(std::string bank, int is_definition); + int WriteDataGroup(const std::string &bank, int is_definition); // // // For iterating through the HDF file... diff --git a/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h b/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h index d177bea3bfe1e32d625a10db9a15953a3c144664..55c7170d7b40f49e606b805779ef2276851848b6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SetScalingPSD.h @@ -86,7 +86,8 @@ private: std::map<int, Kernel::V3D> &posMap, std::map<int, double> &scaleMap); /// read the positions of detectors defined in the raw file - void getDetPositionsFromRaw(std::string rawfile, std::vector<int> &detID, + void getDetPositionsFromRaw(const std::string &rawfile, + std::vector<int> &detID, std::vector<Kernel::V3D> &pos); }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h b/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h index b40b4c2f7dceb2d217262423f89bc809e565d9a7..3042711456f481c32cba6d5c76def87301d18567 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h +++ b/Framework/DataHandling/inc/MantidDataHandling/XmlHandler.h @@ -21,7 +21,7 @@ namespace DataHandling { class MANTID_DATAHANDLING_DLL XmlHandler { public: XmlHandler() = default; - XmlHandler(std::string); + XmlHandler(const std::string &); std::map<std::string, std::string> get_metadata(const std::vector<std::string> &tags_to_ignore); diff --git a/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp b/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp index 9a5ac5075e1915679a34020f3a12e06a04a791e7..762cf3c6eccd687c8b0ee502ff1aa617a5b1e2b5 100644 --- a/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp +++ b/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp @@ -360,8 +360,8 @@ AppendGeometryToSNSNexus::getInstrumentName(const std::string &nxfilename) { */ bool AppendGeometryToSNSNexus::runLoadInstrument( - const std::string &idf_filename, API::MatrixWorkspace_sptr localWorkspace, - Algorithm *alg) { + const std::string &idf_filename, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument", 0, 1, true); // Execute the Child Algorithm. @@ -399,8 +399,8 @@ bool AppendGeometryToSNSNexus::runLoadInstrument( * @return true if successful. */ bool AppendGeometryToSNSNexus::runLoadNexusLogs( - const std::string &nexusFileName, API::MatrixWorkspace_sptr localWorkspace, - Algorithm *alg) { + const std::string &nexusFileName, + const API::MatrixWorkspace_sptr &localWorkspace, Algorithm *alg) { IAlgorithm_sptr loadLogs = alg->createChildAlgorithm("LoadNexusLogs", 0, 1, true); diff --git a/Framework/DataHandling/src/BankPulseTimes.cpp b/Framework/DataHandling/src/BankPulseTimes.cpp index 0340ff8d403cb5a8e7313529ea6157103f60a8d4..02e4ed4436baa0e6d38140e73dfaa9c127f8c7bd 100644 --- a/Framework/DataHandling/src/BankPulseTimes.cpp +++ b/Framework/DataHandling/src/BankPulseTimes.cpp @@ -98,7 +98,8 @@ BankPulseTimes::~BankPulseTimes() { delete[] this->pulseTimes; } * @return true if the pulse times are the same and so don't need to be * reloaded. */ -bool BankPulseTimes::equals(size_t otherNumPulse, std::string otherStartTime) { +bool BankPulseTimes::equals(size_t otherNumPulse, + const std::string &otherStartTime) { return ((this->startTime == otherStartTime) && (this->numPulses == otherNumPulse)); } diff --git a/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp b/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp index 95001bd039db4ad76fc1745c82a4c294e446778c..aa449170b9d58550882ee1aa65f64eff387cda65 100644 --- a/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp +++ b/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp @@ -216,7 +216,7 @@ bool startsWith(const string &str, const string &prefix) { * @return The correct parent name. This is an empty string if the name * isn't found. */ -string parentName(IComponent_const_sptr comp, const string &prefix) { +string parentName(const IComponent_const_sptr &comp, const string &prefix) { // handle the special case of the component has the name if (startsWith(comp->getName(), prefix)) return comp->getName(); @@ -242,7 +242,8 @@ string parentName(IComponent_const_sptr comp, const string &prefix) { * @return The correct parent name. This is an empty string if the name * isn't found. */ -string parentName(IComponent_const_sptr comp, const vector<string> &names) { +string parentName(const IComponent_const_sptr &comp, + const vector<string> &names) { // handle the special case of the component has the name for (const auto &name : names) if (name == comp->getName()) diff --git a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp index d22473db9395b00b85b2addb7c41bf7e71eddc52..e0866c6462a1c5280972e50dc2e1c1519b170d18 100644 --- a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp +++ b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp @@ -38,7 +38,7 @@ struct StartAndEndTime { Mantid::Types::Core::DateAndTime endTime; }; -StartAndEndTime getStartAndEndTimesFromRawFile(std::string filename) { +StartAndEndTime getStartAndEndTimesFromRawFile(const std::string &filename) { FILE *rawFile = fopen(filename.c_str(), "rb"); if (!rawFile) throw std::runtime_error("Cannot open RAW file for reading: " + filename); @@ -58,7 +58,7 @@ StartAndEndTime getStartAndEndTimesFromRawFile(std::string filename) { } StartAndEndTime getStartAndEndTimesFromNexusFile( - std::string filename, + const std::string &filename, const Mantid::Types::Core::DateAndTime &startTimeDefault, const Mantid::Types::Core::DateAndTime &endTimeDefault) { StartAndEndTime startAndEndTime; @@ -411,7 +411,7 @@ void CreateSimulationWorkspace::adjustInstrument(const std::string &filename) { * @param workspace: dummy workspace */ void CreateSimulationWorkspace::setStartDate( - API::MatrixWorkspace_sptr workspace) { + const API::MatrixWorkspace_sptr &workspace) { const std::string detTableFile = getProperty("DetectorTableFilename"); auto hasDetTableFile = !detTableFile.empty(); auto &run = workspace->mutableRun(); diff --git a/Framework/DataHandling/src/DataBlockComposite.cpp b/Framework/DataHandling/src/DataBlockComposite.cpp index 6560c92166de8de041a708c5719142018abe619c..fe4c1e8bb4e21cc02a1bf6024bdba2ac89230569 100644 --- a/Framework/DataHandling/src/DataBlockComposite.cpp +++ b/Framework/DataHandling/src/DataBlockComposite.cpp @@ -208,9 +208,12 @@ std::vector<std::pair<int64_t, int64_t>> spectrumIDIntervals( const std::vector<Mantid::DataHandling::DataBlock> &blocks) { std::vector<std::pair<int64_t, int64_t>> intervals; intervals.reserve(blocks.size()); - for (const auto &block : blocks) { - intervals.emplace_back(block.getMinSpectrumID(), block.getMaxSpectrumID()); - } + + std::transform(blocks.begin(), blocks.end(), std::back_inserter(intervals), + [](const auto &block) { + return std::make_pair(block.getMinSpectrumID(), + block.getMaxSpectrumID()); + }); return intervals; } } // namespace @@ -253,7 +256,7 @@ std::unique_ptr<DataBlockGenerator> DataBlockComposite::getGenerator() const { return std::make_unique<DataBlockGenerator>(intervals); } -void DataBlockComposite::addDataBlock(DataBlock dataBlock) { +void DataBlockComposite::addDataBlock(const DataBlock &dataBlock) { // Set the number of periods, number of spectra and number of channel m_numberOfPeriods = dataBlock.getNumberOfPeriods(); m_numberOfChannels = dataBlock.getNumberOfChannels(); diff --git a/Framework/DataHandling/src/DetermineChunking.cpp b/Framework/DataHandling/src/DetermineChunking.cpp index bb1455036aa919f8f09287f9ab880e8ad536cc5e..fe074a28eee6d1a81f006fb22cd4b681e4691486 100644 --- a/Framework/DataHandling/src/DetermineChunking.cpp +++ b/Framework/DataHandling/src/DetermineChunking.cpp @@ -292,7 +292,7 @@ void DetermineChunking::exec() { } /// set the name of the top level NXentry m_top_entry_name -std::string DetermineChunking::setTopEntryName(std::string filename) { +std::string DetermineChunking::setTopEntryName(const std::string &filename) { std::string top_entry_name; using string_map_t = std::map<std::string, std::string>; try { diff --git a/Framework/DataHandling/src/EventWorkspaceCollection.cpp b/Framework/DataHandling/src/EventWorkspaceCollection.cpp index 860edfe1f730e8276774d32f7d852c8a442dc25a..459a890bd5be949b4bd29d62fd9c19dfbcb6085b 100644 --- a/Framework/DataHandling/src/EventWorkspaceCollection.cpp +++ b/Framework/DataHandling/src/EventWorkspaceCollection.cpp @@ -162,7 +162,7 @@ EventWorkspaceCollection::getSpectrum(const size_t index) const { return m_WsVec[0]->getSpectrum(index); } void EventWorkspaceCollection::setSpectrumNumbersFromUniqueSpectra( - const std::set<int> uniqueSpectra) { + const std::set<int> &uniqueSpectra) { // For each workspace, update all the spectrum numbers for (auto &ws : m_WsVec) { size_t counter = 0; @@ -279,14 +279,14 @@ void EventWorkspaceCollection::setWidth(const float flag) { } } -void EventWorkspaceCollection::setTitle(std::string title) { +void EventWorkspaceCollection::setTitle(const std::string &title) { for (auto &ws : m_WsVec) { ws->setTitle(title); } } void EventWorkspaceCollection::applyFilter( - boost::function<void(MatrixWorkspace_sptr)> func) { + const boost::function<void(MatrixWorkspace_sptr)> &func) { for (auto &ws : m_WsVec) { func(ws); } diff --git a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp index 1ace0758f27de18ab26765cb1ab00903b2df1771..b1ee58199cd933414d235b1e1e19863538ef326a 100644 --- a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp +++ b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp @@ -671,8 +671,8 @@ void FilterEventsByLogValuePreNexus::processEventLogs() { * @param logtitle :: title of the log to be inserted to workspace * @param mindex :: index of the the series in the wrong detectors map */ -void FilterEventsByLogValuePreNexus::addToWorkspaceLog(std::string logtitle, - size_t mindex) { +void FilterEventsByLogValuePreNexus::addToWorkspaceLog( + const std::string &logtitle, size_t mindex) { // Create TimeSeriesProperty auto property = new TimeSeriesProperty<double>(logtitle); @@ -770,7 +770,8 @@ void FilterEventsByLogValuePreNexus::doStatToEventLog(size_t mindex) { * geometry */ void FilterEventsByLogValuePreNexus::runLoadInstrument( - const std::string &eventfilename, MatrixWorkspace_sptr localWorkspace) { + const std::string &eventfilename, + const MatrixWorkspace_sptr &localWorkspace) { // start by getting just the filename string instrument = Poco::Path(eventfilename).getFileName(); @@ -930,7 +931,6 @@ void FilterEventsByLogValuePreNexus::procEvents( << " threads" << " in " << numBlocks << " blocks. " << "\n"; - // cppcheck-suppress syntaxError PRAGMA_OMP( parallel for schedule(dynamic, 1) if (m_parallelProcessing) ) for (int i = 0; i < int(numThreads); i++) { @@ -954,7 +954,7 @@ void FilterEventsByLogValuePreNexus::procEvents( // value = pointer to the events vector eventVectors[i] = new EventVector_pt[m_detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < m_detid_max + 1; j++) { + for (detid_t j = 0; j < m_detid_max + 1; ++j) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> theseEventVectors[j] = &partWS->getSpectrum(wi).getEvents(); @@ -1133,15 +1133,13 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( << m_maxNumEvents << "\n"; maxeventid = m_maxNumEvents + 1; - size_t numbadeventindex = 0; - int numeventswritten = 0; // Declare local statistic parameters size_t local_numErrorEvents = 0; size_t local_numBadEvents = 0; - size_t local_numWrongdetidEvents = 0; size_t local_numIgnoredEvents = 0; + size_t local_numWrongdetidEvents = 0; size_t local_numGoodEvents = 0; double local_m_shortestTof = static_cast<double>(MAX_TOF_UINT32) * TOF_CONVERSION; @@ -1161,8 +1159,6 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( int64_t i_pulse = 0; for (size_t ievent = 0; ievent < current_event_buffer_size; ++ievent) { - bool iswrongdetid = false; - // Load DasEvent DasEvent &tempevent = *(event_buffer + ievent); @@ -1186,6 +1182,7 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( pixelid = this->m_pixelmap[unmapped_pid]; } + bool iswrongdetid = false; // Check special/wrong pixel IDs against max Detector ID if (pixelid > static_cast<PixelType>(m_detid_max)) { // Record the wrong/special ID @@ -1367,12 +1364,6 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( if (local_m_longestTof > m_longestTof) m_longestTof = local_m_longestTof; } - - if (numbadeventindex > 0) { - g_log.notice() << "Single block: Encountered " << numbadeventindex - << " bad event indexes" - << "\n"; - } } //---------------------------------------------------------------------------------------------- @@ -1558,7 +1549,7 @@ void FilterEventsByLogValuePreNexus::filterEvents() { // value = pointer to the events vector eventVectors[i] = new EventVector_pt[m_detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < m_detid_max + 1; j++) { + for (detid_t j = 0; j < m_detid_max + 1; ++j) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> if (wi != static_cast<size_t>(-1)) @@ -1737,8 +1728,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( << m_maxNumEvents << "\n"; maxeventid = m_maxNumEvents + 1; - size_t numbadeventindex = 0; - // Declare local statistic parameters size_t local_numErrorEvents = 0; size_t local_numBadEvents = 0; @@ -1824,8 +1813,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( g_log.notice() << "[DB] L1 = " << l1 << "\n"; for (size_t ievent = 0; ievent < current_event_buffer_size; ++ievent) { - bool iswrongdetid = false; - bool islogevent = false; // Load DasEvent DasEvent &tempevent = *(event_buffer + ievent); @@ -1840,6 +1827,9 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( local_numBadEvents++; continue; } else { + bool islogevent = false; + bool iswrongdetid = false; + // Covert DAS Pixel ID to Mantid Pixel ID if (pixelid == 1073741843) { // downstream monitor pixel for SNAP @@ -2107,8 +2097,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( m_longestTof = local_m_longestTof; } - g_log.notice() << "Encountered " << numbadeventindex << " bad event indexes" - << "\n"; } // FilterEventsLinearly //---------------------------------------------------------------------------------------------- @@ -2118,7 +2106,7 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( * We want to pad out empty pixels: monitor */ size_t FilterEventsByLogValuePreNexus::padOutEmptyPixels( - DataObjects::EventWorkspace_sptr eventws) { + const DataObjects::EventWorkspace_sptr &eventws) { const auto &detectorInfo = eventws->detectorInfo(); const auto &detIDs = detectorInfo.detectorIDs(); @@ -2158,7 +2146,7 @@ size_t FilterEventsByLogValuePreNexus::padOutEmptyPixels( * pixel-spectrum map */ void FilterEventsByLogValuePreNexus::setupPixelSpectrumMap( - DataObjects::EventWorkspace_sptr eventws) { + const DataObjects::EventWorkspace_sptr &eventws) { const auto &detectorInfo = eventws->detectorInfo(); const auto &detIDs = detectorInfo.detectorIDs(); @@ -2368,8 +2356,6 @@ void FilterEventsByLogValuePreNexus::readPulseidFile( } } - double temp; - if (m_numPulses > 0) { DateAndTime lastPulseDateTime(0, 0); this->pulsetimes.reserve(m_numPulses); @@ -2384,7 +2370,7 @@ void FilterEventsByLogValuePreNexus::readPulseidFile( else lastPulseDateTime = pulseDateTime; - temp = pulse.pCurrent; + double temp = pulse.pCurrent; this->m_protonCharge.emplace_back(temp); if (temp < 0.) this->g_log.warning("Individual proton charge < 0 being ignored"); diff --git a/Framework/DataHandling/src/GroupDetectors2.cpp b/Framework/DataHandling/src/GroupDetectors2.cpp index 82af6435fdab81ca7317cc7114e3ec811958a49a..85655ee45d91a091f8557b1146c8a514bfbee58c 100644 --- a/Framework/DataHandling/src/GroupDetectors2.cpp +++ b/Framework/DataHandling/src/GroupDetectors2.cpp @@ -311,8 +311,9 @@ void GroupDetectors2::execEvent() { * @param workspace :: the user selected input workspace * @param unUsedSpec :: spectra indexes that are not members of any group */ -void GroupDetectors2::getGroups(API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec) { +void GroupDetectors2::getGroups( + const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec) { // this is the map that we are going to fill m_GroupWsInds.clear(); @@ -454,9 +455,9 @@ void GroupDetectors2::getGroups(API::MatrixWorkspace_const_sptr workspace, * a group (so far) * @throw FileError if there's any problem with the file or its format */ -void GroupDetectors2::processFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec) { +void GroupDetectors2::processFile( + const std::string &fname, const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec) { // tring to open the file the user told us exists, skip down 20 lines to find // out what happens if we can read from it g_log.debug() << "Opening input file ... " << fname; @@ -545,9 +546,9 @@ void GroupDetectors2::processFile(const std::string &fname, * a group (so far) * @throw FileError if there's any problem with the file or its format */ -void GroupDetectors2::processXMLFile(const std::string &fname, - API::MatrixWorkspace_const_sptr workspace, - std::vector<int64_t> &unUsedSpec) { +void GroupDetectors2::processXMLFile( + const std::string &fname, const API::MatrixWorkspace_const_sptr &workspace, + std::vector<int64_t> &unUsedSpec) { // 1. Get maps for spectrum No and detector ID spec2index_map specs2index; const SpectraAxis *axis = @@ -589,9 +590,7 @@ void GroupDetectors2::processXMLFile(const std::string &fname, if (ind != detIdToWiMap.end()) { size_t wsid = ind->second; wsindexes.emplace_back(wsid); - if (unUsedSpec[wsid] != (USED)) { - unUsedSpec[wsid] = (USED); - } + unUsedSpec[wsid] = (USED); } else { g_log.error() << "Detector with ID " << detid << " is not found in instrument \n"; @@ -615,9 +614,7 @@ void GroupDetectors2::processXMLFile(const std::string &fname, if (ind != specs2index.end()) { size_t wsid = ind->second; wsindexes.emplace_back(wsid); - if (unUsedSpec[wsid] != (USED)) { - unUsedSpec[wsid] = (USED); - } + unUsedSpec[wsid] = (USED); } else { g_log.error() << "Spectrum with ID " << specNum << " is not found in instrument \n"; @@ -634,8 +631,8 @@ void GroupDetectors2::processXMLFile(const std::string &fname, * in a group (so far) */ void GroupDetectors2::processGroupingWorkspace( - GroupingWorkspace_const_sptr groupWS, - API::MatrixWorkspace_const_sptr workspace, + const GroupingWorkspace_const_sptr &groupWS, + const API::MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec) { detid2index_map detIdToWiMap = workspace->getDetectorIDToWorkspaceIndexMap(); @@ -662,9 +659,7 @@ void GroupDetectors2::processGroupingWorkspace( detIdToWiMap[detectorIDs[spectrumDefinition.first]]; targetWSIndexSet.insert(targetWSIndex); // mark as used - if (unUsedSpec[targetWSIndex] != (USED)) { - unUsedSpec[targetWSIndex] = (USED); - } + unUsedSpec[targetWSIndex] = (USED); } } } @@ -688,7 +683,8 @@ void GroupDetectors2::processGroupingWorkspace( * a group (so far) */ void GroupDetectors2::processMatrixWorkspace( - MatrixWorkspace_const_sptr groupWS, MatrixWorkspace_const_sptr workspace, + const MatrixWorkspace_const_sptr &groupWS, + const MatrixWorkspace_const_sptr &workspace, std::vector<int64_t> &unUsedSpec) { detid2index_map detIdToWiMap = workspace->getDetectorIDToWorkspaceIndexMap(); @@ -700,7 +696,6 @@ void GroupDetectors2::processMatrixWorkspace( for (size_t i = 0; i < spectrumInfo.size(); ++i) { // read spectra from groupingws size_t groupid = i; - if (group2WSIndexSetmap.find(groupid) == group2WSIndexSetmap.end()) { // not found - create an empty set group2WSIndexSetmap.emplace(groupid, std::set<size_t>()); @@ -716,9 +711,7 @@ void GroupDetectors2::processMatrixWorkspace( detIdToWiMap[detectorIDs[spectrumDefinition.first]]; targetWSIndexSet.insert(targetWSIndex); // mark as used - if (unUsedSpec[targetWSIndex] != (USED)) { - unUsedSpec[targetWSIndex] = (USED); - } + unUsedSpec[targetWSIndex] = (USED); } } } @@ -939,11 +932,12 @@ double GroupDetectors2::fileReadProg( * indexing after grouping * @return number of new grouped spectra */ -size_t GroupDetectors2::formGroups(API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, - const double prog4Copy, const bool keepAll, - const std::set<int64_t> &unGroupedSet, - Indexing::IndexInfo &indexInfo) { +size_t +GroupDetectors2::formGroups(const API::MatrixWorkspace_const_sptr &inputWS, + const API::MatrixWorkspace_sptr &outputWS, + const double prog4Copy, const bool keepAll, + const std::set<int64_t> &unGroupedSet, + Indexing::IndexInfo &indexInfo) { const std::string behaviourChoice = getProperty("Behaviour"); const auto behaviour = behaviourChoice == "Sum" ? Behaviour::SUM : Behaviour::AVERAGE; @@ -1062,10 +1056,9 @@ size_t GroupDetectors2::formGroups(API::MatrixWorkspace_const_sptr inputWS, * a single spectra * @return number of new grouped spectra */ -size_t -GroupDetectors2::formGroupsEvent(DataObjects::EventWorkspace_const_sptr inputWS, - DataObjects::EventWorkspace_sptr outputWS, - const double prog4Copy) { +size_t GroupDetectors2::formGroupsEvent( + const DataObjects::EventWorkspace_const_sptr &inputWS, + const DataObjects::EventWorkspace_sptr &outputWS, const double prog4Copy) { if (inputWS->detectorInfo().isScanning()) throw std::runtime_error("GroupDetectors does not currently support " "EventWorkspaces with detector scans."); diff --git a/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp b/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp index 366841e5fe9ac1a3b680d0c7a35dd0f3fd6277a3..53b7b63f955b45373c4410082c51b345e29c6326 100644 --- a/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp +++ b/Framework/DataHandling/src/JoinISISPolarizationEfficiencies.cpp @@ -196,7 +196,7 @@ JoinISISPolarizationEfficiencies::interpolateWorkspaces( MatrixWorkspace_sptr JoinISISPolarizationEfficiencies::interpolatePointDataWorkspace( - MatrixWorkspace_sptr ws, size_t const maxSize) { + const MatrixWorkspace_sptr &ws, size_t const maxSize) { auto const &x = ws->x(0); auto const startX = x.front(); auto const endX = x.back(); @@ -213,7 +213,7 @@ JoinISISPolarizationEfficiencies::interpolatePointDataWorkspace( MatrixWorkspace_sptr JoinISISPolarizationEfficiencies::interpolateHistogramWorkspace( - MatrixWorkspace_sptr ws, size_t const maxSize) { + const MatrixWorkspace_sptr &ws, size_t const maxSize) { ws->setDistribution(true); auto const &x = ws->x(0); auto const dX = (x.back() - x.front()) / double(maxSize); diff --git a/Framework/DataHandling/src/Load.cpp b/Framework/DataHandling/src/Load.cpp index 9f3aca7aed9625a9b6831918867c026d19fddd60..3dccfb9b1d7d8a9ff72b2b8a7907d765e4af1078 100644 --- a/Framework/DataHandling/src/Load.cpp +++ b/Framework/DataHandling/src/Load.cpp @@ -54,7 +54,8 @@ bool isSingleFile(const std::vector<std::vector<std::string>> &fileNames) { * @returns a string containing a suggested ws name based on the given file *names. */ -std::string generateWsNameFromFileNames(std::vector<std::string> filenames) { +std::string +generateWsNameFromFileNames(const std::vector<std::string> &filenames) { std::string wsName; for (auto &filename : filenames) { @@ -678,7 +679,8 @@ API::Workspace_sptr Load::loadFileToWs(const std::string &fileName, * * @returns a pointer to the result (the first workspace). */ -API::Workspace_sptr Load::plusWs(Workspace_sptr ws1, Workspace_sptr ws2) { +API::Workspace_sptr Load::plusWs(Workspace_sptr ws1, + const Workspace_sptr &ws2) { WorkspaceGroup_sptr group1 = boost::dynamic_pointer_cast<WorkspaceGroup>(ws1); WorkspaceGroup_sptr group2 = boost::dynamic_pointer_cast<WorkspaceGroup>(ws2); diff --git a/Framework/DataHandling/src/LoadAsciiStl.cpp b/Framework/DataHandling/src/LoadAsciiStl.cpp index 5fe2fea8a012a1d639beb68c881b9fc7d682994f..6babcfa54c05091fe578325794aa6b6cc6327b3e 100644 --- a/Framework/DataHandling/src/LoadAsciiStl.cpp +++ b/Framework/DataHandling/src/LoadAsciiStl.cpp @@ -11,7 +11,7 @@ namespace Mantid { namespace DataHandling { -bool LoadAsciiStl::isAsciiSTL(std::string filename) { +bool LoadAsciiStl::isAsciiSTL(const std::string &filename) { std::ifstream file(filename.c_str()); if (!file) { // if the file cannot be read then it is not a valid asciiStl File diff --git a/Framework/DataHandling/src/LoadBBY.cpp b/Framework/DataHandling/src/LoadBBY.cpp index 3fe7461a573831b527ff2914ad46ef511bb326e9..1a35f3da47bea2bd01c6c1da30ef90b4435bdfa3 100644 --- a/Framework/DataHandling/src/LoadBBY.cpp +++ b/Framework/DataHandling/src/LoadBBY.cpp @@ -305,7 +305,7 @@ void LoadBBY::exec() { eventAssigner); } - auto getParam = [&allParams](std::string tag, double defValue) { + auto getParam = [&allParams](const std::string &tag, double defValue) { try { return std::stod(allParams[tag]); } catch (const std::invalid_argument &) { diff --git a/Framework/DataHandling/src/LoadBinaryStl.cpp b/Framework/DataHandling/src/LoadBinaryStl.cpp index 0b05cdd15ed8f743d200ac57b9a863bfa586c780..a43550ec716d1cece46d4f138e8f81eb8ebde543 100644 --- a/Framework/DataHandling/src/LoadBinaryStl.cpp +++ b/Framework/DataHandling/src/LoadBinaryStl.cpp @@ -24,7 +24,7 @@ uint32_t getNumberTriangles(Kernel::BinaryStreamReader streamReader, } } // namespace -bool LoadBinaryStl::isBinarySTL(std::string filename) { +bool LoadBinaryStl::isBinarySTL(const std::string &filename) { Poco::File stlFile = Poco::File(filename); if (!stlFile.exists()) { // if the file cannot be read then it is not a valid binary Stl File diff --git a/Framework/DataHandling/src/LoadCalFile.cpp b/Framework/DataHandling/src/LoadCalFile.cpp index c2ca3f78e0356ad67e92612459ad24452392d5c5..3062ed3fa00c59cf91a7608745425e0d82c79c7e 100644 --- a/Framework/DataHandling/src/LoadCalFile.cpp +++ b/Framework/DataHandling/src/LoadCalFile.cpp @@ -237,9 +237,9 @@ void LoadCalFile::exec() { *initialized to the right instrument. */ void LoadCalFile::readCalFile(const std::string &calFileName, - GroupingWorkspace_sptr groupWS, - OffsetsWorkspace_sptr offsetsWS, - MaskWorkspace_sptr maskWS) { + const GroupingWorkspace_sptr &groupWS, + const OffsetsWorkspace_sptr &offsetsWS, + const MaskWorkspace_sptr &maskWS) { auto doGroup = bool(groupWS); auto doOffsets = bool(offsetsWS); auto doMask = bool(maskWS); @@ -360,7 +360,7 @@ void LoadCalFile::readCalFile(const std::string &calFileName, * @param detID Detector ID to check * @return True if a monitor, false otherwise */ -bool LoadCalFile::idIsMonitor(Instrument_const_sptr inst, int detID) { +bool LoadCalFile::idIsMonitor(const Instrument_const_sptr &inst, int detID) { auto monitorList = inst->getMonitors(); auto it = std::find(monitorList.begin(), monitorList.end(), detID); return (it != monitorList.end()); diff --git a/Framework/DataHandling/src/LoadCanSAS1D.cpp b/Framework/DataHandling/src/LoadCanSAS1D.cpp index 75c723269e51eacdcd4983601e0c6cf104b32821..49edd128199eaafd36aae0fdbe5b94f3d1162951 100644 --- a/Framework/DataHandling/src/LoadCanSAS1D.cpp +++ b/Framework/DataHandling/src/LoadCanSAS1D.cpp @@ -297,9 +297,9 @@ void LoadCanSAS1D::check(const Poco::XML::Element *const toCheck, * @param[out] container the data will be added to this group * @throw ExistsError if a workspace with this name had already been added */ -void LoadCanSAS1D::appendDataToOutput(API::MatrixWorkspace_sptr newWork, - const std::string &newWorkName, - API::WorkspaceGroup_sptr container) { +void LoadCanSAS1D::appendDataToOutput( + const API::MatrixWorkspace_sptr &newWork, const std::string &newWorkName, + const API::WorkspaceGroup_sptr &container) { // the name of the property, like the workspace name must be different for // each workspace. Add "_run" at the end to stop problems with names like // "outputworkspace" @@ -317,8 +317,9 @@ void LoadCanSAS1D::appendDataToOutput(API::MatrixWorkspace_sptr newWork, * @param inst_name :: The name written in the Nexus file * @param localWorkspace :: The workspace to insert the instrument into */ -void LoadCanSAS1D::runLoadInstrument(const std::string &inst_name, - API::MatrixWorkspace_sptr localWorkspace) { +void LoadCanSAS1D::runLoadInstrument( + const std::string &inst_name, + const API::MatrixWorkspace_sptr &localWorkspace) { API::IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); @@ -342,7 +343,7 @@ void LoadCanSAS1D::runLoadInstrument(const std::string &inst_name, * @param[in] wSpace the log will be created in this workspace */ void LoadCanSAS1D::createLogs(const Poco::XML::Element *const sasEntry, - API::MatrixWorkspace_sptr wSpace) const { + const API::MatrixWorkspace_sptr &wSpace) const { API::Run &run = wSpace->mutableRun(); Element *runText = sasEntry->getChildElement("Run"); check(runText, "Run"); @@ -369,7 +370,7 @@ void LoadCanSAS1D::createLogs(const Poco::XML::Element *const sasEntry, void LoadCanSAS1D::createSampleInformation( const Poco::XML::Element *const sasEntry, - Mantid::API::MatrixWorkspace_sptr wSpace) const { + const Mantid::API::MatrixWorkspace_sptr &wSpace) const { auto &sample = wSpace->mutableSample(); // Get the thickness information diff --git a/Framework/DataHandling/src/LoadDaveGrp.cpp b/Framework/DataHandling/src/LoadDaveGrp.cpp index 6f62cd3e9e95d0500e8002eb1ff3a16637169ae6..840a1fb136d79519d7fae632caa14ddabe91dffe 100644 --- a/Framework/DataHandling/src/LoadDaveGrp.cpp +++ b/Framework/DataHandling/src/LoadDaveGrp.cpp @@ -176,7 +176,7 @@ API::MatrixWorkspace_sptr LoadDaveGrp::setupWorkspace() const { return outputWorkspace; } -void LoadDaveGrp::setWorkspaceAxes(API::MatrixWorkspace_sptr workspace, +void LoadDaveGrp::setWorkspaceAxes(const API::MatrixWorkspace_sptr &workspace, const std::vector<double> &xAxis, const std::vector<double> &yAxis) const { @@ -231,7 +231,7 @@ void LoadDaveGrp::getAxisValues(std::vector<double> &axis, } } -void LoadDaveGrp::getData(API::MatrixWorkspace_sptr workspace) { +void LoadDaveGrp::getData(const API::MatrixWorkspace_sptr &workspace) { double data_val = 0.0; double err_val = 0.0; diff --git a/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp b/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp index cf823778e64e3391505a9330bda154ad3a832d71..b2ccf757b1cea94807d4e8db93b0b10cb4f83e87 100644 --- a/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp +++ b/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp @@ -409,7 +409,7 @@ LoadGroupXMLFile::LoadGroupXMLFile() m_pDoc(), m_groupComponentsMap(), m_groupDetectorsMap(), m_groupSpectraMap(), m_startGroupID(1), m_groupNamesMap() {} -void LoadGroupXMLFile::loadXMLFile(std::string xmlfilename) { +void LoadGroupXMLFile::loadXMLFile(const std::string &xmlfilename) { this->initializeXMLParser(xmlfilename); this->parseXML(); @@ -604,9 +604,8 @@ void LoadGroupXMLFile::parseXML() { /* * Get attribute's value by name from a Node */ -std::string LoadGroupXMLFile::getAttributeValueByName(Poco::XML::Node *pNode, - std::string attributename, - bool &found) { +std::string LoadGroupXMLFile::getAttributeValueByName( + Poco::XML::Node *pNode, const std::string &attributename, bool &found) { // 1. Init Poco::AutoPtr<Poco::XML::NamedNodeMap> att = pNode->attributes(); found = false; diff --git a/Framework/DataHandling/src/LoadDiffCal.cpp b/Framework/DataHandling/src/LoadDiffCal.cpp index ff6b617b3bb62a865fd430c6ee72625c6e8a264a..a75167db988a85a08dd7744d051363411fe98ccc 100644 --- a/Framework/DataHandling/src/LoadDiffCal.cpp +++ b/Framework/DataHandling/src/LoadDiffCal.cpp @@ -132,7 +132,7 @@ bool endswith(const std::string &str, const std::string &ending) { } void setGroupWSProperty(API::Algorithm *alg, const std::string &prefix, - GroupingWorkspace_sptr wksp) { + const GroupingWorkspace_sptr &wksp) { alg->declareProperty( std::make_unique<WorkspaceProperty<DataObjects::GroupingWorkspace>>( "OutputGroupingWorkspace", prefix + "_group", Direction::Output), @@ -141,7 +141,7 @@ void setGroupWSProperty(API::Algorithm *alg, const std::string &prefix, } void setMaskWSProperty(API::Algorithm *alg, const std::string &prefix, - MaskWorkspace_sptr wksp) { + const MaskWorkspace_sptr &wksp) { alg->declareProperty( std::make_unique<WorkspaceProperty<DataObjects::MaskWorkspace>>( "OutputMaskWorkspace", prefix + "_mask", Direction::Output), @@ -150,7 +150,7 @@ void setMaskWSProperty(API::Algorithm *alg, const std::string &prefix, } void setCalWSProperty(API::Algorithm *alg, const std::string &prefix, - ITableWorkspace_sptr wksp) { + const ITableWorkspace_sptr &wksp) { alg->declareProperty( std::make_unique<WorkspaceProperty<ITableWorkspace>>( "OutputCalWorkspace", prefix + "_cal", Direction::Output), diff --git a/Framework/DataHandling/src/LoadDspacemap.cpp b/Framework/DataHandling/src/LoadDspacemap.cpp index ef2ed7bdf70a80d9c75edcf1bbc7703d5dd94c7b..6a5e8ac1596e0eaba40523dbd2684cf02addf649 100644 --- a/Framework/DataHandling/src/LoadDspacemap.cpp +++ b/Framework/DataHandling/src/LoadDspacemap.cpp @@ -95,8 +95,8 @@ void LoadDspacemap::exec() { * @param offsetsWS :: OffsetsWorkspace to be filled. */ void LoadDspacemap::CalculateOffsetsFromDSpacemapFile( - const std::string DFileName, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS) { + const std::string &DFileName, + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS) { // Get a pointer to the instrument contained in the workspace const auto &detectorInfo = offsetsWS->detectorInfo(); @@ -150,7 +150,7 @@ const double CONSTANT = (PhysicalConstants::h * 1e10) / */ void LoadDspacemap::CalculateOffsetsFromVulcanFactors( std::map<detid_t, double> &vulcan, - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS) { + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS) { // Get a pointer to the instrument contained in the workspace // At this point, instrument VULCAN has been created? Instrument_const_sptr instrument = offsetsWS->getInstrument(); diff --git a/Framework/DataHandling/src/LoadEMU.cpp b/Framework/DataHandling/src/LoadEMU.cpp index 3389e0ab82cd6bf644eb939dcb9d5b846459d0d1..24443dec1cbed536bb6d8059bee27b62f3896c84 100644 --- a/Framework/DataHandling/src/LoadEMU.cpp +++ b/Framework/DataHandling/src/LoadEMU.cpp @@ -680,7 +680,7 @@ void LoadEMU<FD>::exec(const std::string &hdfFile, // lambda to simplify loading instrument parameters auto instr = m_localWorkspace->getInstrument(); - auto iparam = [&instr](std::string tag) { + auto iparam = [&instr](const std::string &tag) { return instr->getNumberParameter(tag)[0]; }; @@ -690,7 +690,7 @@ void LoadEMU<FD>::exec(const std::string &hdfFile, // double sampleAnalyser = iparam("SampleAnalyser"); auto endID = static_cast<detid_t>(DETECTOR_TUBES * PIXELS_PER_TUBE); - for (detid_t detID = 0; detID < endID; detID++) + for (detid_t detID = 0; detID < endID; ++detID) updateNeutronicPostions(detID, sampleAnalyser); // get the detector map from raw input to a physical detector diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index e19bcd8f634774dd3af4903940fa5da8ddd0382b..61db89516575f4fe66cc477f89452e79a674ad10 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -1177,8 +1177,8 @@ bool LoadEventNexus::runLoadInstrument<EventWorkspaceCollection_sptr>( * @param workspace :: The workspace to contain the spectra mapping * @param bankNames :: Bank names that are in Nexus file */ -void LoadEventNexus::deleteBanks(EventWorkspaceCollection_sptr workspace, - std::vector<std::string> bankNames) { +void LoadEventNexus::deleteBanks(const EventWorkspaceCollection_sptr &workspace, + const std::vector<std::string> &bankNames) { Instrument_sptr inst = boost::const_pointer_cast<Instrument>( workspace->getInstrument()->baseInstrument()); // Build a list of Rectangular Detectors @@ -1537,7 +1537,7 @@ void LoadEventNexus::loadSampleDataISIScompatibility( * * @param fname name of the nexus file to open */ -void LoadEventNexus::safeOpenFile(const std::string fname) { +void LoadEventNexus::safeOpenFile(const std::string &fname) { try { m_file = std::make_unique<::NeXus::File>(m_filename, NXACC_READ); } catch (std::runtime_error &e) { diff --git a/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp b/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp index 0e7a6f4e212d75d84ccc97997d3565474ec724d8..6a3d324202792265dac3304d609c690b890fab27 100644 --- a/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp +++ b/Framework/DataHandling/src/LoadEventNexusIndexSetup.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataHandling/LoadEventNexusIndexSetup.h" +#include <utility> + #include "MantidAPI/SpectrumDetectorMapping.h" +#include "MantidDataHandling/LoadEventNexusIndexSetup.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Instrument/DetectorInfo.h" @@ -42,10 +44,10 @@ void setupConsistentSpectrumNumbers(IndexInfo &filtered, LoadEventNexusIndexSetup::LoadEventNexusIndexSetup( MatrixWorkspace_const_sptr instrumentWorkspace, const int32_t min, - const int32_t max, const std::vector<int32_t> range, + const int32_t max, const std::vector<int32_t> &range, const Parallel::Communicator &communicator) - : m_instrumentWorkspace(instrumentWorkspace), m_min(min), m_max(max), - m_range(range), m_communicator(communicator) {} + : m_instrumentWorkspace(std::move(instrumentWorkspace)), m_min(min), + m_max(max), m_range(range), m_communicator(communicator) {} std::pair<int32_t, int32_t> LoadEventNexusIndexSetup::eventIDLimits() const { return {m_min, m_max}; diff --git a/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Framework/DataHandling/src/LoadEventPreNexus2.cpp index 04eaff0ec070db6cbef202ef701c1b4259741606..447ae3efef5c428fc26df9a69020bdf5283c27c6 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -405,7 +405,7 @@ void LoadEventPreNexus2::exec() { /** Create and set up output Event Workspace */ void LoadEventPreNexus2::createOutputWorkspace( - const std::string event_filename) { + const std::string &event_filename) { // Create the output workspace localWorkspace = EventWorkspace_sptr(new EventWorkspace()); @@ -570,7 +570,7 @@ void LoadEventPreNexus2::processImbedLogs() { * @param mindex :: index of the log in pulse time ... * - mindex: index of the the series in the list */ -void LoadEventPreNexus2::addToWorkspaceLog(std::string logtitle, +void LoadEventPreNexus2::addToWorkspaceLog(const std::string &logtitle, size_t mindex) { // Create TimeSeriesProperty auto property = new TimeSeriesProperty<double>(logtitle); @@ -601,7 +601,8 @@ void LoadEventPreNexus2::addToWorkspaceLog(std::string logtitle, * geometry */ void LoadEventPreNexus2::runLoadInstrument( - const std::string &eventfilename, MatrixWorkspace_sptr localWorkspace) { + const std::string &eventfilename, + const MatrixWorkspace_sptr &localWorkspace) { // start by getting just the filename string instrument = Poco::Path(eventfilename).getFileName(); @@ -757,7 +758,6 @@ void LoadEventPreNexus2::procEvents( partWorkspaces.resize(numThreads); buffers.resize(numThreads); eventVectors = new EventVector_pt *[numThreads]; - // cppcheck-suppress syntaxError PRAGMA_OMP( parallel for if (parallelProcessing) ) for (int i = 0; i < int(numThreads); i++) { @@ -780,7 +780,7 @@ void LoadEventPreNexus2::procEvents( // value = pointer to the events vector eventVectors[i] = new EventVector_pt[detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < detid_max + 1; j++) { + for (detid_t j = 0; j < detid_max + 1; ++j) { size_t wi = pixel_to_wkspindex[j]; // Save a POINTER to the vector<tofEvent> if (wi != static_cast<size_t>(-1)) @@ -1322,7 +1322,6 @@ void LoadEventPreNexus2::readPulseidFile(const std::string &filename, } if (num_pulses > 0) { - double temp; DateAndTime lastPulseDateTime(0, 0); this->pulsetimes.reserve(num_pulses); for (const auto &pulse : pulses) { @@ -1336,7 +1335,7 @@ void LoadEventPreNexus2::readPulseidFile(const std::string &filename, else lastPulseDateTime = pulseDateTime; - temp = pulse.pCurrent; + double temp = pulse.pCurrent; this->proton_charge.emplace_back(temp); if (temp < 0.) this->g_log.warning("Individual proton charge < 0 being ignored"); diff --git a/Framework/DataHandling/src/LoadFITS.cpp b/Framework/DataHandling/src/LoadFITS.cpp index deb8a6f3a818fd27e9459de6576b86b14c9ef23d..57f2df40ce813f0c338daed43f07fa5eca0716d4 100644 --- a/Framework/DataHandling/src/LoadFITS.cpp +++ b/Framework/DataHandling/src/LoadFITS.cpp @@ -678,7 +678,7 @@ void LoadFITS::parseHeader(FITSInfo &headerInfo) { Workspace2D_sptr LoadFITS::makeWorkspace(const FITSInfo &fileInfo, size_t &newFileNumber, std::vector<char> &buffer, MantidImage &imageY, - MantidImage &imageE, const Workspace2D_sptr parent, + MantidImage &imageE, const Workspace2D_sptr &parent, bool loadAsRectImg, int binSize, double noiseThresh) { // Create workspace (taking into account already here if rebinning is // going to happen) @@ -763,9 +763,9 @@ LoadFITS::makeWorkspace(const FITSInfo &fileInfo, size_t &newFileNumber, * @param cmpp centimeters per pixel (already taking into account * possible rebinning) */ -void LoadFITS::addAxesInfoAndLogs(Workspace2D_sptr ws, bool loadAsRectImg, - const FITSInfo &fileInfo, int binSize, - double cmpp) { +void LoadFITS::addAxesInfoAndLogs(const Workspace2D_sptr &ws, + bool loadAsRectImg, const FITSInfo &fileInfo, + int binSize, double cmpp) { // add axes size_t width = fileInfo.axisPixelLengths[0] / binSize; size_t height = fileInfo.axisPixelLengths[1] / binSize; @@ -848,7 +848,7 @@ void LoadFITS::addAxesInfoAndLogs(Workspace2D_sptr ws, bool loadAsRectImg, * @throws std::runtime_error if there are file input issues */ void LoadFITS::readDataToWorkspace(const FITSInfo &fileInfo, double cmpp, - Workspace2D_sptr ws, + const Workspace2D_sptr &ws, std::vector<char> &buffer) { const size_t bytespp = (fileInfo.bitsPerPixel / 8); const size_t len = m_pixelCount * bytespp; diff --git a/Framework/DataHandling/src/LoadFullprofResolution.cpp b/Framework/DataHandling/src/LoadFullprofResolution.cpp index 5095dcb4e6b61d95e7fbd118082070f87243be05..085341074867ca897a0942efc1d6b0687ba5d347 100644 --- a/Framework/DataHandling/src/LoadFullprofResolution.cpp +++ b/Framework/DataHandling/src/LoadFullprofResolution.cpp @@ -240,7 +240,8 @@ void LoadFullprofResolution::exec() { * @param filename :: string for name of the .irf file * @param lines :: vector of strings for each non-empty line in .irf file */ -void LoadFullprofResolution::loadFile(string filename, vector<string> &lines) { +void LoadFullprofResolution::loadFile(const string &filename, + vector<string> &lines) { string line; // the variable of type ifstream: @@ -773,8 +774,8 @@ void LoadFullprofResolution::createBankToWorkspaceMap( * stored */ void LoadFullprofResolution::putParametersIntoWorkspace( - API::Column_const_sptr column, API::MatrixWorkspace_sptr ws, int nProf, - std::string ¶meterXMLString) { + const API::Column_const_sptr &column, const API::MatrixWorkspace_sptr &ws, + int nProf, std::string ¶meterXMLString) { // Get instrument name from matrix workspace std::string instrumentName = ws->getInstrument()->getName(); @@ -833,7 +834,7 @@ void LoadFullprofResolution::putParametersIntoWorkspace( * paramName is the name of the parameter as it appears in the table workspace */ void LoadFullprofResolution::addALFBEParameter( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Element *parent, const std::string ¶mName) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", getXMLParameterName(paramName)); @@ -856,7 +857,7 @@ void LoadFullprofResolution::addALFBEParameter( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addSigmaParameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "IkedaCarpenterPV:SigmaSquared"); @@ -878,7 +879,7 @@ void LoadFullprofResolution::addSigmaParameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addGammaParameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "IkedaCarpenterPV:Gamma"); @@ -899,7 +900,7 @@ void LoadFullprofResolution::addGammaParameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addBBX_S_Parameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "BackToBackExponential:S"); @@ -923,7 +924,7 @@ void LoadFullprofResolution::addBBX_S_Parameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addBBX_A_Parameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "BackToBackExponential:A"); @@ -948,7 +949,7 @@ void LoadFullprofResolution::addBBX_A_Parameters( * for the bank at the given column of the table workspace */ void LoadFullprofResolution::addBBX_B_Parameters( - const API::Column_const_sptr column, Poco::XML::Document *mDoc, + const API::Column_const_sptr &column, Poco::XML::Document *mDoc, Poco::XML::Element *parent) { AutoPtr<Element> parameterElem = mDoc->createElement("parameter"); parameterElem->setAttribute("name", "BackToBackExponential:B"); @@ -992,7 +993,7 @@ LoadFullprofResolution::getXMLParameterName(const std::string &name) { * given the name of the parameter in the table workspace. */ std::string -LoadFullprofResolution::getXMLEqValue(const API::Column_const_sptr column, +LoadFullprofResolution::getXMLEqValue(const API::Column_const_sptr &column, const std::string &name) { size_t paramNumber = LoadFullprofResolution::m_rowNumbers[name]; // API::Column_const_sptr column = tablews->getColumn( columnIndex ); @@ -1006,7 +1007,7 @@ LoadFullprofResolution::getXMLEqValue(const API::Column_const_sptr column, * given the name of the parameter in the table workspace. */ std::string LoadFullprofResolution::getXMLSquaredEqValue( - const API::Column_const_sptr column, const std::string &name) { + const API::Column_const_sptr &column, const std::string &name) { size_t paramNumber = LoadFullprofResolution::m_rowNumbers[name]; // API::Column_const_sptr column = tablews->getColumn( columnIndex ); double eqValue = column->cell<double>(paramNumber); diff --git a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp index aadb1e848b522c141a1b37ac30301631168909af..e5174ebb212284c9e6c338c5620b925fcc701482 100644 --- a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp +++ b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp @@ -214,7 +214,8 @@ void LoadGSASInstrumentFile::exec() { * @param filename :: string for name of the .prm file * @param lines :: vector of strings for each non-empty line in .prm file */ -void LoadGSASInstrumentFile::loadFile(string filename, vector<string> &lines) { +void LoadGSASInstrumentFile::loadFile(const string &filename, + vector<string> &lines) { string line; // the variable of type ifstream: @@ -254,7 +255,7 @@ LoadGSASInstrumentFile::getHistogramType(const vector<string> &lines) { // We assume there is just one HTYPE line, look for it from beginning and // return its value. std::string lookFor = "INS HTYPE"; - for (size_t i = 0; i <= lines.size(); ++i) { + for (size_t i = 0; i < lines.size(); ++i) { if (lines[i].substr(0, lookFor.size()) == lookFor) { if (lines[i].size() < lookFor.size() + 7) { // line too short @@ -274,7 +275,7 @@ size_t LoadGSASInstrumentFile::getNumberOfBanks(const vector<string> &lines) { // We assume there is just one BANK line, look for it from beginning and // return its value. std::string lookFor = "INS BANK"; - for (size_t i = 0; i <= lines.size(); ++i) { + for (size_t i = 0; i < lines.size(); ++i) { if (lines[i].substr(0, lookFor.size()) == lookFor) { if (lines[i].size() < lookFor.size() + 3) { // line too short diff --git a/Framework/DataHandling/src/LoadGSS.cpp b/Framework/DataHandling/src/LoadGSS.cpp index 9f04a4b9a02f46226cb24039b33e6135a41a9758..4456422c817533eb8153a6675f21cb9e1d74e3e4 100644 --- a/Framework/DataHandling/src/LoadGSS.cpp +++ b/Framework/DataHandling/src/LoadGSS.cpp @@ -488,7 +488,7 @@ double LoadGSS::convertToDouble(std::string inputstring) { /** Create the instrument geometry with Instrument */ void LoadGSS::createInstrumentGeometry( - MatrixWorkspace_sptr workspace, const std::string &instrumentname, + const MatrixWorkspace_sptr &workspace, const std::string &instrumentname, const double &primaryflightpath, const std::vector<int> &detectorids, const std::vector<double> &totalflightpaths, const std::vector<double> &twothetas) { diff --git a/Framework/DataHandling/src/LoadHelper.cpp b/Framework/DataHandling/src/LoadHelper.cpp index 0527c865d70cf696dc02c2f3dba4e64a69c33bdf..6461e0fa1ecee7e18c16136c0dd3847c87c9d370 100644 --- a/Framework/DataHandling/src/LoadHelper.cpp +++ b/Framework/DataHandling/src/LoadHelper.cpp @@ -119,7 +119,7 @@ double LoadHelper::calculateTOF(double distance, double wavelength) { */ double LoadHelper::getInstrumentProperty(const API::MatrixWorkspace_sptr &workspace, - std::string s) { + const std::string &s) { std::vector<std::string> prop = workspace->getInstrument()->getStringParameter(s); if (prop.empty()) { @@ -509,7 +509,7 @@ void LoadHelper::dumpNexusAttributes(NXhandle nxfileID, * @param dateToParse :: date as string * @return date as required in Mantid */ -std::string LoadHelper::dateTimeInIsoFormat(std::string dateToParse) { +std::string LoadHelper::dateTimeInIsoFormat(const std::string &dateToParse) { namespace bt = boost::posix_time; // parsing format const std::locale format = std::locale( @@ -535,7 +535,7 @@ std::string LoadHelper::dateTimeInIsoFormat(std::string dateToParse) { * @param componentName The name of the component of the instrument * @param newPos New position of the component */ -void LoadHelper::moveComponent(API::MatrixWorkspace_sptr ws, +void LoadHelper::moveComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const V3D &newPos) { Geometry::IComponent_const_sptr component = @@ -557,7 +557,7 @@ void LoadHelper::moveComponent(API::MatrixWorkspace_sptr ws, * @param rot Rotations defined by setting a quaternion from an angle in degrees * and an axis */ -void LoadHelper::rotateComponent(API::MatrixWorkspace_sptr ws, +void LoadHelper::rotateComponent(const API::MatrixWorkspace_sptr &ws, const std::string &componentName, const Kernel::Quat &rot) { Geometry::IComponent_const_sptr component = @@ -578,7 +578,7 @@ void LoadHelper::rotateComponent(API::MatrixWorkspace_sptr ws, * @param componentName The Name of the component of the instrument * @return The position of the component */ -V3D LoadHelper::getComponentPosition(API::MatrixWorkspace_sptr ws, +V3D LoadHelper::getComponentPosition(const API::MatrixWorkspace_sptr &ws, const std::string &componentName) { Geometry::IComponent_const_sptr component = ws->getInstrument()->getComponentByName(componentName); diff --git a/Framework/DataHandling/src/LoadIDFFromNexus.cpp b/Framework/DataHandling/src/LoadIDFFromNexus.cpp index 5d52c316f66b8d855bf5dc8f874ed61b77f05c0c..e4110c861240910b55f90ff5f918f46c64ee40c7 100644 --- a/Framework/DataHandling/src/LoadIDFFromNexus.cpp +++ b/Framework/DataHandling/src/LoadIDFFromNexus.cpp @@ -271,7 +271,7 @@ void LoadIDFFromNexus::readParameterCorrectionFile( * @throw FileError Thrown if unable to parse XML file */ void LoadIDFFromNexus::LoadParameters( - ::NeXus::File *nxfile, const MatrixWorkspace_sptr localWorkspace) { + ::NeXus::File *nxfile, const MatrixWorkspace_sptr &localWorkspace) { std::string parameterString; @@ -314,7 +314,7 @@ void LoadIDFFromNexus::LoadParameters( // given workspace, returning success. bool LoadIDFFromNexus::loadParameterFile( const std::string &fullPathName, - const MatrixWorkspace_sptr localWorkspace) { + const MatrixWorkspace_sptr &localWorkspace) { try { // load and also populate instrument parameters from this 'fallback' diff --git a/Framework/DataHandling/src/LoadILLIndirect2.cpp b/Framework/DataHandling/src/LoadILLIndirect2.cpp index c4d0b384b01989ea0e5e2fb9ff69fda60d63e527..80aa732d8839dcef9dd7d69eba521e956598ef69 100644 --- a/Framework/DataHandling/src/LoadILLIndirect2.cpp +++ b/Framework/DataHandling/src/LoadILLIndirect2.cpp @@ -271,7 +271,7 @@ void LoadILLIndirect2::loadDataIntoTheWorkSpace(NeXus::NXEntry &entry) { * @param nexusfilename */ void LoadILLIndirect2::loadNexusEntriesIntoProperties( - std::string nexusfilename) { + const std::string &nexusfilename) { API::Run &runDetails = m_localWorkspace->mutableRun(); diff --git a/Framework/DataHandling/src/LoadISISNexus2.cpp b/Framework/DataHandling/src/LoadISISNexus2.cpp index 63ccf5fb638974a4e9c6ea535d902a1c921ed43c..abebe9c0e77ed172113684b4e6c01ec485b49294 100644 --- a/Framework/DataHandling/src/LoadISISNexus2.cpp +++ b/Framework/DataHandling/src/LoadISISNexus2.cpp @@ -459,7 +459,7 @@ Check for a set of synthetic logs associated with multi-period log data. Raise warnings where necessary. */ void LoadISISNexus2::validateMultiPeriodLogs( - Mantid::API::MatrixWorkspace_sptr ws) { + const Mantid::API::MatrixWorkspace_sptr &ws) { const Run &run = ws->run(); if (!run.hasProperty("current_period")) { g_log.warning("Workspace has no current_period log."); diff --git a/Framework/DataHandling/src/LoadInstrument.cpp b/Framework/DataHandling/src/LoadInstrument.cpp index 9451dbb3183029e495432295c579bc6b8e53eb88..4274685e262fcc20afe59aec5d0192e266ee2834 100644 --- a/Framework/DataHandling/src/LoadInstrument.cpp +++ b/Framework/DataHandling/src/LoadInstrument.cpp @@ -255,7 +255,8 @@ void LoadInstrument::exec() { //----------------------------------------------------------------------------------------------------------------------- /// Run the Child Algorithm LoadInstrument (or LoadInstrumentFromRaw) void LoadInstrument::runLoadParameterFile( - const boost::shared_ptr<API::MatrixWorkspace> &ws, std::string filename) { + const boost::shared_ptr<API::MatrixWorkspace> &ws, + const std::string &filename) { g_log.debug("Loading the parameter definition..."); // First search for XML parameter file in same folder as IDF file @@ -311,8 +312,9 @@ void LoadInstrument::runLoadParameterFile( /// Search the directory for the Parameter IDF file and return full path name if /// found, else return "". // directoryName must include a final '/'. -std::string LoadInstrument::getFullPathParamIDF(std::string directoryName, - std::string filename) { +std::string +LoadInstrument::getFullPathParamIDF(const std::string &directoryName, + const std::string &filename) { Poco::Path directoryPath(directoryName); directoryPath.makeDirectory(); // Remove the path from the filename diff --git a/Framework/DataHandling/src/LoadIsawDetCal.cpp b/Framework/DataHandling/src/LoadIsawDetCal.cpp index a531b2645f3ede3199ea94772c0398b3ccbd1c4c..4c8e0c67a366277621c990efbbcf8e4be04e5b72 100644 --- a/Framework/DataHandling/src/LoadIsawDetCal.cpp +++ b/Framework/DataHandling/src/LoadIsawDetCal.cpp @@ -29,6 +29,7 @@ #include <fstream> #include <numeric> #include <sstream> +#include <utility> namespace Mantid { namespace DataHandling { @@ -74,7 +75,7 @@ std::string getBankName(const std::string &bankPart, const int idnum) { } } -std::string getInstName(API::Workspace_const_sptr wksp) { +std::string getInstName(const API::Workspace_const_sptr &wksp) { MatrixWorkspace_const_sptr matrixWksp = boost::dynamic_pointer_cast<const MatrixWorkspace>(wksp); if (matrixWksp) { @@ -352,10 +353,11 @@ void LoadIsawDetCal::exec() { * @param componentInfo :: The component info object for the workspace */ void LoadIsawDetCal::center(const double x, const double y, const double z, - const std::string &detname, API::Workspace_sptr ws, + const std::string &detname, + const API::Workspace_sptr &ws, Geometry::ComponentInfo &componentInfo) { - Instrument_sptr inst = getCheckInst(ws); + Instrument_sptr inst = getCheckInst(std::move(ws)); IComponent_const_sptr comp = inst->getComponentByName(detname); if (comp == nullptr) { @@ -378,7 +380,7 @@ void LoadIsawDetCal::center(const double x, const double y, const double z, * @throw std::runtime_error if there's any problem with the workspace or it is * not possible to get an instrument object from it */ -Instrument_sptr LoadIsawDetCal::getCheckInst(API::Workspace_sptr ws) { +Instrument_sptr LoadIsawDetCal::getCheckInst(const API::Workspace_sptr &ws) { MatrixWorkspace_sptr inputW = boost::dynamic_pointer_cast<MatrixWorkspace>(ws); PeaksWorkspace_sptr inputP = boost::dynamic_pointer_cast<PeaksWorkspace>(ws); @@ -432,7 +434,7 @@ std::vector<std::string> LoadIsawDetCal::getFilenames() { * @param doWishCorrection if true apply a special correction for WISH */ void LoadIsawDetCal::doRotation(V3D rX, V3D rY, ComponentInfo &componentInfo, - boost::shared_ptr<const IComponent> comp, + const boost::shared_ptr<const IComponent> &comp, bool doWishCorrection) { // These are the ISAW axes rX.normalize(); diff --git a/Framework/DataHandling/src/LoadLog.cpp b/Framework/DataHandling/src/LoadLog.cpp index 6f528b5b844fa1cd4f32c70bb931d7420e246193..c771655cb7074ad72a821c71a55a2f2ba7b81172 100644 --- a/Framework/DataHandling/src/LoadLog.cpp +++ b/Framework/DataHandling/src/LoadLog.cpp @@ -28,6 +28,7 @@ #include <boost/algorithm/string.hpp> #include <fstream> // used to get ifstream #include <sstream> +#include <utility> using Mantid::Types::Core::DateAndTime; @@ -202,8 +203,8 @@ void LoadLog::loadTwoColumnLogFile(std::ifstream &logFileStream, } try { - Property *log = - LogParser::createLogProperty(m_filename, stringToLower(logFileName)); + Property *log = LogParser::createLogProperty( + m_filename, stringToLower(std::move(logFileName))); if (log) { run.addLogData(log); } @@ -220,7 +221,8 @@ void LoadLog::loadTwoColumnLogFile(std::ifstream &logFileStream, * @param run :: The run information object */ void LoadLog::loadThreeColumnLogFile(std::ifstream &logFileStream, - std::string logFileName, API::Run &run) { + const std::string &logFileName, + API::Run &run) { std::string str; std::string propname; std::map<std::string, std::unique_ptr<Kernel::TimeSeriesProperty<double>>> diff --git a/Framework/DataHandling/src/LoadMuonNexus.cpp b/Framework/DataHandling/src/LoadMuonNexus.cpp index 7a7b005de06ac7b29ddb1569afb42d0beb01fd46..214b258eb14a4fd68fb99f1dff7e599ef112ccc0 100644 --- a/Framework/DataHandling/src/LoadMuonNexus.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus.cpp @@ -152,7 +152,7 @@ void LoadMuonNexus::checkOptionalProperties() { /// Run the Child Algorithm LoadInstrument void LoadMuonNexus::runLoadInstrument( - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); diff --git a/Framework/DataHandling/src/LoadMuonNexus1.cpp b/Framework/DataHandling/src/LoadMuonNexus1.cpp index 86ae6243d307d52f40b57eb70f16328dd9edc175..77aac4add36dd6b1ac04b5939ccd21f36d4c1a35 100644 --- a/Framework/DataHandling/src/LoadMuonNexus1.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus1.cpp @@ -448,9 +448,8 @@ void LoadMuonNexus1::loadDeadTimes(NXRoot &root) { * @param inst :: Pointer to instrument (to use if IDF needed) * @returns :: Grouping table - or tables, if per period */ -Workspace_sptr -LoadMuonNexus1::loadDetectorGrouping(NXRoot &root, - Geometry::Instrument_const_sptr inst) { +Workspace_sptr LoadMuonNexus1::loadDetectorGrouping( + NXRoot &root, const Geometry::Instrument_const_sptr &inst) { NXEntry dataEntry = root.openEntry("run/histogram_data_1"); NXInfo infoGrouping = dataEntry.getDataSetInfo("grouping"); @@ -660,9 +659,10 @@ LoadMuonNexus1::createDetectorGroupingTable(std::vector<int> specToLoad, * @param localWorkspace :: A pointer to the workspace in which the data will * be stored */ -void LoadMuonNexus1::loadData(size_t hist, specnum_t &i, specnum_t specNo, - MuonNexusReader &nxload, const int64_t lengthIn, - DataObjects::Workspace2D_sptr localWorkspace) { +void LoadMuonNexus1::loadData( + size_t hist, specnum_t &i, specnum_t specNo, MuonNexusReader &nxload, + const int64_t lengthIn, + const DataObjects::Workspace2D_sptr &localWorkspace) { // Read in a spectrum // Put it into a vector, discarding the 1st entry, which is rubbish // But note that the last (overflow) bin is kept @@ -689,7 +689,7 @@ void LoadMuonNexus1::loadData(size_t hist, specnum_t &i, specnum_t specNo, * @param localWorkspace :: The workspace details to use */ void LoadMuonNexus1::loadRunDetails( - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { API::Run &runDetails = localWorkspace->mutableRun(); runDetails.addProperty("run_title", localWorkspace->getTitle(), true); @@ -737,7 +737,8 @@ void LoadMuonNexus1::loadRunDetails( } /// Run the LoadLog Child Algorithm -void LoadMuonNexus1::runLoadLog(DataObjects::Workspace2D_sptr localWorkspace) { +void LoadMuonNexus1::runLoadLog( + const DataObjects::Workspace2D_sptr &localWorkspace) { IAlgorithm_sptr loadLog = createChildAlgorithm("LoadMuonLog"); // Pass through the same input filename loadLog->setPropertyValue("Filename", m_filename); @@ -791,8 +792,8 @@ void LoadMuonNexus1::runLoadLog(DataObjects::Workspace2D_sptr localWorkspace) { * @param localWorkspace A workspace to add the log to. * @param period A period for this workspace. */ -void LoadMuonNexus1::addPeriodLog(DataObjects::Workspace2D_sptr localWorkspace, - int64_t period) { +void LoadMuonNexus1::addPeriodLog( + const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period) { auto &run = localWorkspace->mutableRun(); ISISRunLogs runLogs(run); if (period == 0) { @@ -803,8 +804,9 @@ void LoadMuonNexus1::addPeriodLog(DataObjects::Workspace2D_sptr localWorkspace, } } -void LoadMuonNexus1::addGoodFrames(DataObjects::Workspace2D_sptr localWorkspace, - int64_t period, int nperiods) { +void LoadMuonNexus1::addGoodFrames( + const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period, + int nperiods) { // Get handle to nexus file ::NeXus::File handle(m_filename, NXACC_READ); diff --git a/Framework/DataHandling/src/LoadMuonNexus2.cpp b/Framework/DataHandling/src/LoadMuonNexus2.cpp index 7238470ca9ed5fd13cc890616e8ed2b8f6e62413..d1e1ba3e54aa154699164c648b60bfefa5332301 100644 --- a/Framework/DataHandling/src/LoadMuonNexus2.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus2.cpp @@ -335,8 +335,8 @@ Histogram LoadMuonNexus2::loadData(const BinEdges &edges, * @param entry :: The Nexus entry * @param period :: The period of this workspace */ -void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry, - int period) { +void LoadMuonNexus2::loadLogs(const API::MatrixWorkspace_sptr &ws, + NXEntry &entry, int period) { // Avoid compiler warning (void)period; @@ -373,7 +373,7 @@ void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry, * @param localWorkspace :: The workspace details to use */ void LoadMuonNexus2::loadRunDetails( - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { API::Run &runDetails = localWorkspace->mutableRun(); runDetails.addProperty("run_title", localWorkspace->getTitle(), true); diff --git a/Framework/DataHandling/src/LoadNXSPE.cpp b/Framework/DataHandling/src/LoadNXSPE.cpp index 3835e25d6ad81e2c1813830c369207072e8d0362..d574160974ec110053d45bc50f15e4d6f149e02a 100644 --- a/Framework/DataHandling/src/LoadNXSPE.cpp +++ b/Framework/DataHandling/src/LoadNXSPE.cpp @@ -353,10 +353,13 @@ void LoadNXSPE::exec() { boost::shared_ptr<Geometry::CSGObject> LoadNXSPE::createCuboid(double dx, double dy, double dz) { + UNUSED_ARG(dx) + UNUSED_ARG(dy) + UNUSED_ARG(dz) - dx = 0.5 * std::fabs(dx); - dy = 0.5 * std::fabs(dy); - dz = 0.5 * std::fabs(dz); + // dx = 0.5 * std::fabs(dx); + // dy = 0.5 * std::fabs(dy); + // dz = 0.5 * std::fabs(dz); /* std::stringstream planeName; diff --git a/Framework/DataHandling/src/LoadNXcanSAS.cpp b/Framework/DataHandling/src/LoadNXcanSAS.cpp index c288e53514ce9debfec62f0a68348533e827a6a7..b1cc42fb7c8f0167dcb990305bd0e32ee707788c 100644 --- a/Framework/DataHandling/src/LoadNXcanSAS.cpp +++ b/Framework/DataHandling/src/LoadNXcanSAS.cpp @@ -106,7 +106,8 @@ createWorkspaceForHistogram(H5::DataSet &dataSet) { // ----- LOGS -void loadLogs(H5::Group &entry, Mantid::API::MatrixWorkspace_sptr workspace) { +void loadLogs(H5::Group &entry, + const Mantid::API::MatrixWorkspace_sptr &workspace) { auto &run = workspace->mutableRun(); // Load UserFile (optional) @@ -133,7 +134,7 @@ void loadLogs(H5::Group &entry, Mantid::API::MatrixWorkspace_sptr workspace) { } // ----- INSTRUMENT -std::string extractIdfFileOnCurrentSystem(std::string idf) { +std::string extractIdfFileOnCurrentSystem(const std::string &idf) { // If the idf is is not empty extract the last element from the file if (idf.empty()) { return ""; @@ -161,7 +162,7 @@ std::string extractIdfFileOnCurrentSystem(std::string idf) { } void loadInstrument(H5::Group &entry, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { auto instrument = entry.openGroup(sasInstrumentGroupName); // Get instrument name @@ -232,7 +233,7 @@ bool hasQDev(H5::Group &dataGroup) { } void loadData1D(H5::Group &dataGroup, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { // General workspace->setDistribution(true); @@ -268,7 +269,7 @@ void loadData1D(H5::Group &dataGroup, template <typename Functor> void read2DWorkspace(H5::DataSet &dataSet, Mantid::API::MatrixWorkspace_sptr workspace, Functor func, - H5::DataType memoryDataType) { + const H5::DataType &memoryDataType) { using namespace Mantid::DataHandling::NXcanSAS; auto dimInfo = getDataSpaceInfo(dataSet); @@ -297,8 +298,8 @@ void read2DWorkspace(H5::DataSet &dataSet, } void readQyInto2DWorkspace(H5::DataSet &dataSet, - Mantid::API::MatrixWorkspace_sptr workspace, - H5::DataType memoryDataType) { + const Mantid::API::MatrixWorkspace_sptr &workspace, + const H5::DataType &memoryDataType) { using namespace Mantid::DataHandling::NXcanSAS; // Get info about the data set @@ -342,13 +343,13 @@ void readQyInto2DWorkspace(H5::DataSet &dataSet, } void loadData2D(H5::Group &dataGroup, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { // General workspace->setDistribution(true); //----------------------------------------- // Load the I value. auto iDataSet = dataGroup.openDataSet(sasDataI); - auto iExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, + auto iExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, size_t index) -> HistogramY & { return ws->mutableY(index); }; @@ -360,7 +361,7 @@ void loadData2D(H5::Group &dataGroup, //----------------------------------------- // Load the Idev value auto eDataSet = dataGroup.openDataSet(sasDataIdev); - auto eExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, + auto eExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, size_t index) -> HistogramE & { return ws->mutableE(index); }; @@ -369,7 +370,7 @@ void loadData2D(H5::Group &dataGroup, //----------------------------------------- // Load the Qx value + units auto qxDataSet = dataGroup.openDataSet(sasDataQx); - auto qxExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, + auto qxExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, size_t index) -> HistogramX & { return ws->mutableX(index); }; @@ -384,7 +385,8 @@ void loadData2D(H5::Group &dataGroup, readQyInto2DWorkspace(qyDataSet, workspace, qyDataType); } -void loadData(H5::Group &entry, Mantid::API::MatrixWorkspace_sptr workspace) { +void loadData(H5::Group &entry, + const Mantid::API::MatrixWorkspace_sptr &workspace) { auto dataGroup = entry.openGroup(sasDataGroupName); auto dimensionality = getWorkspaceDimensionality(dataGroup); switch (dimensionality) { @@ -433,7 +435,7 @@ bool hasTransmissionEntry(H5::Group &entry, const std::string &name) { } void loadTransmissionData(H5::Group &transmission, - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { //----------------------------------------- // Load T workspace->mutableY(0) = diff --git a/Framework/DataHandling/src/LoadNexusLogs.cpp b/Framework/DataHandling/src/LoadNexusLogs.cpp index 3e44d7f2aba8a9af6ac34e194aeb2bb940963164..5e328a533e060bf7c39a579f742fa008ae86e623 100644 --- a/Framework/DataHandling/src/LoadNexusLogs.cpp +++ b/Framework/DataHandling/src/LoadNexusLogs.cpp @@ -549,7 +549,7 @@ void LoadNexusLogs::exec() { */ void LoadNexusLogs::loadVetoPulses( ::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { try { file.openGroup("Veto_pulse", "NXgroup"); } catch (::NeXus::Exception &) { @@ -583,7 +583,7 @@ void LoadNexusLogs::loadVetoPulses( void LoadNexusLogs::loadNPeriods( ::NeXus::File &file, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { int value = 1; // Default to 1-period unless try { file.openGroup("periods", "IXperiods"); @@ -648,7 +648,7 @@ void LoadNexusLogs::loadNPeriods( void LoadNexusLogs::loadLogs( ::NeXus::File &file, const std::string &entry_name, const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { file.openGroup(entry_name, entry_class); std::map<std::string, std::string> entries = file.getEntries(); std::map<std::string, std::string>::const_iterator iend = entries.end(); @@ -677,7 +677,7 @@ void LoadNexusLogs::loadLogs( void LoadNexusLogs::loadNXLog( ::NeXus::File &file, const std::string &entry_name, const std::string &entry_class, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { g_log.debug() << "processing " << entry_name << ":" << entry_class << "\n"; file.openGroup(entry_name, entry_class); @@ -715,7 +715,7 @@ void LoadNexusLogs::loadNXLog( */ void LoadNexusLogs::loadSELog( ::NeXus::File &file, const std::string &entry_name, - boost::shared_ptr<API::MatrixWorkspace> workspace) const { + const boost::shared_ptr<API::MatrixWorkspace> &workspace) const { // Open the entry file.openGroup(entry_name, "IXseblock"); std::string propName = entry_name; diff --git a/Framework/DataHandling/src/LoadNexusMonitors2.cpp b/Framework/DataHandling/src/LoadNexusMonitors2.cpp index 494bf5036de70680747e9d2c955310c091b65bee..8abcaf1e5414537d323b58731dc580afdfe75f5e 100644 --- a/Framework/DataHandling/src/LoadNexusMonitors2.cpp +++ b/Framework/DataHandling/src/LoadNexusMonitors2.cpp @@ -47,7 +47,7 @@ DECLARE_ALGORITHM(LoadNexusMonitors2) namespace { void loadSampleDataISIScompatibilityInfo( - ::NeXus::File &file, Mantid::API::MatrixWorkspace_sptr const WS) { + ::NeXus::File &file, Mantid::API::MatrixWorkspace_sptr const &WS) { try { file.openGroup("isis_vms_compat", "IXvms"); } catch (::NeXus::Exception &) { @@ -403,8 +403,9 @@ void LoadNexusMonitors2::fixUDets(::NeXus::File &file) { } } -void LoadNexusMonitors2::runLoadLogs(const std::string filename, - API::MatrixWorkspace_sptr localWorkspace) { +void LoadNexusMonitors2::runLoadLogs( + const std::string &filename, + const API::MatrixWorkspace_sptr &localWorkspace) { // do the actual work API::IAlgorithm_sptr loadLogs = createChildAlgorithm("LoadNexusLogs"); diff --git a/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Framework/DataHandling/src/LoadNexusProcessed.cpp index 270d6e2edd89b7c3203467e7f2e2aba9890524c8..beb8c91a4dc5412d098c51e5f0e088aeeba48cbc 100644 --- a/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -156,7 +156,7 @@ SpectraInfo extractMappingInfo(NXEntry &mtd_entry, Logger &logger) { * @param log : Information logger object * @return True only if multiperiod. */ -bool isMultiPeriodFile(int nWorkspaceEntries, Workspace_sptr sampleWS, +bool isMultiPeriodFile(int nWorkspaceEntries, const Workspace_sptr &sampleWS, Logger &log) { bool isMultiPeriod = false; if (ExperimentInfo_sptr expInfo = @@ -1736,7 +1736,7 @@ std::map<std::string, std::string> LoadNexusProcessed::validateInputs() { * @param data :: reference to the NeXuS data for the axis */ void LoadNexusProcessed::loadNonSpectraAxis( - API::MatrixWorkspace_sptr local_workspace, NXData &data) { + const API::MatrixWorkspace_sptr &local_workspace, NXData &data) { Axis *axis = local_workspace->getAxis(1); if (axis->isNumeric()) { @@ -1773,7 +1773,7 @@ void LoadNexusProcessed::loadNonSpectraAxis( * @param elem1 :: first element in the vector * @param elem2 :: second element in the vecor */ -bool UDlesserExecCount(NXClassInfo elem1, NXClassInfo elem2) { +bool UDlesserExecCount(const NXClassInfo &elem1, const NXClassInfo &elem2) { std::string::size_type index1, index2; std::string num1, num2; // find the number after "_" in algorithm name ( eg:MantidAlogorthm_1) @@ -1859,7 +1859,7 @@ void LoadNexusProcessed::getWordsInString(const std::string &words4, * @param local_workspace :: The workspace to read into */ void LoadNexusProcessed::readBinMasking( - NXData &wksp_cls, API::MatrixWorkspace_sptr local_workspace) { + NXData &wksp_cls, const API::MatrixWorkspace_sptr &local_workspace) { if (wksp_cls.getDataSetInfo("masked_spectra").stat == NX_ERROR) { return; } @@ -1897,12 +1897,11 @@ void LoadNexusProcessed::readBinMasking( * @param hist :: The workspace index to start reading into * @param local_workspace :: A pointer to the workspace */ -void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, - NXDataSetTyped<double> &errors, - NXDataSetTyped<double> &farea, bool hasFArea, - NXDouble &xErrors, bool hasXErrors, - int blocksize, int nchannels, int &hist, - API::MatrixWorkspace_sptr local_workspace) { +void LoadNexusProcessed::loadBlock( + NXDataSetTyped<double> &data, NXDataSetTyped<double> &errors, + NXDataSetTyped<double> &farea, bool hasFArea, NXDouble &xErrors, + bool hasXErrors, int blocksize, int nchannels, int &hist, + const API::MatrixWorkspace_sptr &local_workspace) { data.load(blocksize, hist); errors.load(blocksize, hist); double *data_start = data(); @@ -1979,13 +1978,11 @@ void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, * @param local_workspace :: A pointer to the workspace */ -void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, - NXDataSetTyped<double> &errors, - NXDataSetTyped<double> &farea, bool hasFArea, - NXDouble &xErrors, bool hasXErrors, - int blocksize, int nchannels, int &hist, - int &wsIndex, - API::MatrixWorkspace_sptr local_workspace) { +void LoadNexusProcessed::loadBlock( + NXDataSetTyped<double> &data, NXDataSetTyped<double> &errors, + NXDataSetTyped<double> &farea, bool hasFArea, NXDouble &xErrors, + bool hasXErrors, int blocksize, int nchannels, int &hist, int &wsIndex, + const API::MatrixWorkspace_sptr &local_workspace) { data.load(blocksize, hist); errors.load(blocksize, hist); double *data_start = data(); @@ -2062,13 +2059,11 @@ void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, * @param wsIndex :: The workspace index to save data into * @param local_workspace :: A pointer to the workspace */ -void LoadNexusProcessed::loadBlock(NXDataSetTyped<double> &data, - NXDataSetTyped<double> &errors, - NXDataSetTyped<double> &farea, bool hasFArea, - NXDouble &xErrors, bool hasXErrors, - NXDouble &xbins, int blocksize, - int nchannels, int &hist, int &wsIndex, - API::MatrixWorkspace_sptr local_workspace) { +void LoadNexusProcessed::loadBlock( + NXDataSetTyped<double> &data, NXDataSetTyped<double> &errors, + NXDataSetTyped<double> &farea, bool hasFArea, NXDouble &xErrors, + bool hasXErrors, NXDouble &xbins, int blocksize, int nchannels, int &hist, + int &wsIndex, const API::MatrixWorkspace_sptr &local_workspace) { data.load(blocksize, hist); double *data_start = data(); double *data_end = data_start + nchannels; diff --git a/Framework/DataHandling/src/LoadOff.cpp b/Framework/DataHandling/src/LoadOff.cpp index 1ef80513f9ff17d0ebca2d6d41056671af8fe5d6..f67ce2dacaa1c14629d2ca915f350c2b6ce1ae06 100644 --- a/Framework/DataHandling/src/LoadOff.cpp +++ b/Framework/DataHandling/src/LoadOff.cpp @@ -15,7 +15,7 @@ namespace Mantid { namespace DataHandling { -LoadOff::LoadOff(std::string filename, ScaleUnits scaleType) +LoadOff::LoadOff(const std::string &filename, ScaleUnits scaleType) : MeshFileIO(scaleType) { m_file = std::ifstream(filename.c_str()); if (!m_file) { diff --git a/Framework/DataHandling/src/LoadPDFgetNFile.cpp b/Framework/DataHandling/src/LoadPDFgetNFile.cpp index 2a934c4cfb37ac4c26a19f85444d6a8d9ef97dc5..6f6fec0ad9add2cdb6b6ba94b1d07ceccca9749e 100644 --- a/Framework/DataHandling/src/LoadPDFgetNFile.cpp +++ b/Framework/DataHandling/src/LoadPDFgetNFile.cpp @@ -106,7 +106,7 @@ void LoadPDFgetNFile::exec() { * 1. a 2D vector for column data * 2. a 1D string vector for column name */ -void LoadPDFgetNFile::parseDataFile(std::string filename) { +void LoadPDFgetNFile::parseDataFile(const std::string &filename) { // 1. Open file std::ifstream ifile; ifile.open((filename.c_str())); @@ -257,7 +257,7 @@ void LoadPDFgetNFile::parseDataLine(string line) { } //---------------------------------------------------------------------------------------------- -void LoadPDFgetNFile::setUnit(Workspace2D_sptr ws) { +void LoadPDFgetNFile::setUnit(const Workspace2D_sptr &ws) { // 1. Set X string xcolname = mColumnNames[0]; diff --git a/Framework/DataHandling/src/LoadPSIMuonBin.cpp b/Framework/DataHandling/src/LoadPSIMuonBin.cpp index e720abdfb82f0e6796fa4acb6ac46f3bcbd0b20a..c0895643e2b450325011680d68cee27c632c16a2 100644 --- a/Framework/DataHandling/src/LoadPSIMuonBin.cpp +++ b/Framework/DataHandling/src/LoadPSIMuonBin.cpp @@ -234,8 +234,8 @@ void LoadPSIMuonBin::makeDeadTimeTable(const size_t &numSpec) { setProperty("DeadTimeTable", deadTimeTable); } -std::string LoadPSIMuonBin::getFormattedDateTime(std::string date, - std::string time) { +std::string LoadPSIMuonBin::getFormattedDateTime(const std::string &date, + const std::string &time) { std::string year; if (date.size() == 11) { year = date.substr(7, 4); diff --git a/Framework/DataHandling/src/LoadPreNexusMonitors.cpp b/Framework/DataHandling/src/LoadPreNexusMonitors.cpp index d674efbbbee724610fe4e1feded2defb73e9c32e..29dd9cca6fb69bdac16d481d8f35ba12b6e03f21 100644 --- a/Framework/DataHandling/src/LoadPreNexusMonitors.cpp +++ b/Framework/DataHandling/src/LoadPreNexusMonitors.cpp @@ -226,7 +226,7 @@ void LoadPreNexusMonitors::exec() { * geometry */ void LoadPreNexusMonitors::runLoadInstrument( - const std::string &instrument, MatrixWorkspace_sptr localWorkspace) { + const std::string &instrument, const MatrixWorkspace_sptr &localWorkspace) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); diff --git a/Framework/DataHandling/src/LoadRKH.cpp b/Framework/DataHandling/src/LoadRKH.cpp index 2e31b6cb0f8db6551f6e87828395734d33925742..dcaa1c1d5847562c917e8a894f87c3bd71be710f 100644 --- a/Framework/DataHandling/src/LoadRKH.cpp +++ b/Framework/DataHandling/src/LoadRKH.cpp @@ -585,7 +585,7 @@ void LoadRKH::skipLines(std::istream &strm, int nlines) { * @param[out] toCenter an array that is one shorter than oldBoundaries, the * values of the means of pairs of values from the input */ -void LoadRKH::binCenter(const MantidVec oldBoundaries, +void LoadRKH::binCenter(const MantidVec &oldBoundaries, MantidVec &toCenter) const { VectorHelper::convertToBinCentre(oldBoundaries, toCenter); } diff --git a/Framework/DataHandling/src/LoadRaw/isisraw.cpp b/Framework/DataHandling/src/LoadRaw/isisraw.cpp index 60ed63f04b248c1f47b97bec4858b1089fa28c07..4f583929f01245a5ec2bea5a8cde64a08f63934f 100644 --- a/Framework/DataHandling/src/LoadRaw/isisraw.cpp +++ b/Framework/DataHandling/src/LoadRaw/isisraw.cpp @@ -715,10 +715,10 @@ int ISISRAW::ioRAW(FILE *file, LOG_STRUCT *s, int len, bool from_file) { int ISISRAW::ioRAW(FILE *file, LOG_LINE *s, int len, bool from_file) { char padding[5]; memset(padding, ' ', sizeof(padding)); - int i, nbytes_rounded; + int i; for (i = 0; i < len; i++) { ioRAW(file, &(s[i].len), 1, from_file); - nbytes_rounded = 4 * (1 + (s[i].len - 1) / 4); + int nbytes_rounded = 4 * (1 + (s[i].len - 1) / 4); ioRAW(file, &(s[i].data), s[i].len, from_file); ioRAW(file, padding, nbytes_rounded - s[i].len, from_file); } @@ -731,12 +731,11 @@ int ISISRAW::ioRAW(FILE *file, char *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(char), len, file); + size_t n = fread(s, sizeof(char), len, file); return static_cast<int>(n - len); } else { - n = fwrite(s, sizeof(char), len, file); + fwrite(s, sizeof(char), len, file); } return 0; @@ -748,12 +747,11 @@ int ISISRAW::ioRAW(FILE *file, int *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(int), len, file); + size_t n = fread(s, sizeof(int), len, file); return static_cast<int>(n - len); } else { - n = fwrite(s, sizeof(int), len, file); + fwrite(s, sizeof(int), len, file); } return 0; @@ -765,12 +763,11 @@ int ISISRAW::ioRAW(FILE *file, uint32_t *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(uint32_t), len, file); + size_t n = fread(s, sizeof(uint32_t), len, file); return static_cast<int>(n - len); } else { - n = fwrite(s, sizeof(uint32_t), len, file); + fwrite(s, sizeof(uint32_t), len, file); } return 0; } @@ -782,14 +779,13 @@ int ISISRAW::ioRAW(FILE *file, float *s, int len, bool from_file) { return 0; } - size_t n; if (from_file) { - n = fread(s, sizeof(float), len, file); + size_t n = fread(s, sizeof(float), len, file); vaxf_to_local(s, &len, &errcode); return static_cast<int>(n - len); } else { local_to_vaxf(s, &len, &errcode); - n = fwrite(s, sizeof(float), len, file); + fwrite(s, sizeof(float), len, file); vaxf_to_local(s, &len, &errcode); } return 0; @@ -942,6 +938,7 @@ int ISISRAW::vmstime(char *timbuf, int len, time_t time_value) { * get time in VMS format 01-JAN-1970 00:00:00 */ size_t i, n; + // cppcheck-suppress redundantAssignment struct tm *tmstruct = nullptr; #ifdef MS_VISUAL_STUDIO errno_t err = localtime_s(tmstruct, &time_value); diff --git a/Framework/DataHandling/src/LoadRaw3.cpp b/Framework/DataHandling/src/LoadRaw3.cpp index 13f5d13647f9625ab0453a0fc74b40dee68d33fe..a964ca6db5f6d4c947247cf905541e57dffdbeac 100644 --- a/Framework/DataHandling/src/LoadRaw3.cpp +++ b/Framework/DataHandling/src/LoadRaw3.cpp @@ -311,7 +311,7 @@ void LoadRaw3::exec() { */ void LoadRaw3::excludeMonitors(FILE *file, const int &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr) { + const DataObjects::Workspace2D_sptr &ws_sptr) { int64_t histCurrent = -1; int64_t wsIndex = 0; auto histTotal = static_cast<double>(m_total_specs * m_numberOfPeriods); @@ -358,7 +358,7 @@ void LoadRaw3::excludeMonitors(FILE *file, const int &period, *@param ws_sptr :: shared pointer to workspace */ void LoadRaw3::includeMonitors(FILE *file, const int64_t &period, - DataObjects::Workspace2D_sptr ws_sptr) { + const DataObjects::Workspace2D_sptr &ws_sptr) { int64_t histCurrent = -1; int64_t wsIndex = 0; @@ -404,8 +404,8 @@ void LoadRaw3::includeMonitors(FILE *file, const int64_t &period, void LoadRaw3::separateMonitors(FILE *file, const int64_t &period, const std::vector<specnum_t> &monitorList, - DataObjects::Workspace2D_sptr ws_sptr, - DataObjects::Workspace2D_sptr mws_sptr) { + const DataObjects::Workspace2D_sptr &ws_sptr, + const DataObjects::Workspace2D_sptr &mws_sptr) { int64_t histCurrent = -1; int64_t wsIndex = 0; int64_t mwsIndex = 0; diff --git a/Framework/DataHandling/src/LoadRawHelper.cpp b/Framework/DataHandling/src/LoadRawHelper.cpp index 83682479d5d30ec5d87b9e74ec490bcea3dc4e3d..49410e7ce21bf7ac8ee03675c71922ed6d050338 100644 --- a/Framework/DataHandling/src/LoadRawHelper.cpp +++ b/Framework/DataHandling/src/LoadRawHelper.cpp @@ -216,7 +216,7 @@ void LoadRawHelper::readworkspaceParameters(specnum_t &numberOfSpectra, * @return an empty workspace of the given parameters */ DataObjects::Workspace2D_sptr -LoadRawHelper::createWorkspace(DataObjects::Workspace2D_sptr ws_sptr, +LoadRawHelper::createWorkspace(const DataObjects::Workspace2D_sptr &ws_sptr, int64_t nVectors, int64_t xLengthIn, int64_t yLengthIn) { DataObjects::Workspace2D_sptr empty; @@ -270,7 +270,7 @@ void LoadRawHelper::createMonitorWorkspace( DataObjects::Workspace2D_sptr &normalws_sptr, WorkspaceGroup_sptr &mongrp_sptr, const int64_t mwsSpecs, const int64_t nwsSpecs, const int64_t numberOfPeriods, - const int64_t lengthIn, const std::string title, + const int64_t lengthIn, const std::string &title, API::Algorithm *const pAlg) { try { // create monitor group workspace @@ -328,10 +328,10 @@ void LoadRawHelper::exec() {} * @param bmonitors :: boolean flag to name the workspaces * @param pAlg :: pointer to algorithm this method works with. */ -void LoadRawHelper::setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr, - WorkspaceGroup_sptr grpws_sptr, - const int64_t period, bool bmonitors, - API::Algorithm *const pAlg) { +void LoadRawHelper::setWorkspaceProperty( + const DataObjects::Workspace2D_sptr &ws_sptr, + const WorkspaceGroup_sptr &grpws_sptr, const int64_t period, bool bmonitors, + API::Algorithm *const pAlg) { if (!ws_sptr) return; if (!grpws_sptr) @@ -366,12 +366,11 @@ void LoadRawHelper::setWorkspaceProperty(DataObjects::Workspace2D_sptr ws_sptr, * workspace * @param pAlg :: pointer to algorithm this method works with. */ -void LoadRawHelper::setWorkspaceProperty(const std::string &propertyName, - const std::string &title, - WorkspaceGroup_sptr grpws_sptr, - DataObjects::Workspace2D_sptr ws_sptr, - int64_t numberOfPeriods, bool bMonitor, - API::Algorithm *const pAlg) { +void LoadRawHelper::setWorkspaceProperty( + const std::string &propertyName, const std::string &title, + const WorkspaceGroup_sptr &grpws_sptr, + const DataObjects::Workspace2D_sptr &ws_sptr, int64_t numberOfPeriods, + bool bMonitor, API::Algorithm *const pAlg) { UNUSED_ARG(bMonitor); Property *ws = pAlg->getProperty("OutputWorkspace"); if (!ws) @@ -401,7 +400,7 @@ void LoadRawHelper::setWorkspaceProperty(const std::string &propertyName, * @param binStart :: start of bin */ void LoadRawHelper::setWorkspaceData( - DataObjects::Workspace2D_sptr newWorkspace, + const DataObjects::Workspace2D_sptr &newWorkspace, const std::vector<boost::shared_ptr<HistogramData::HistogramX>> &timeChannelsVec, int64_t wsIndex, specnum_t nspecNum, int64_t noTimeRegimes, @@ -544,8 +543,9 @@ LoadRawHelper::getTimeChannels(const int64_t ®imes, /// @param progStart :: progress at start /// @param progEnd :: progress at end void LoadRawHelper::runLoadInstrument( - const std::string &fileName, DataObjects::Workspace2D_sptr localWorkspace, - double progStart, double progEnd) { + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace, double progStart, + double progEnd) { g_log.debug("Loading the instrument definition..."); m_prog = progStart; progress(m_prog, "Loading the instrument geometry..."); @@ -631,7 +631,8 @@ void LoadRawHelper::runLoadInstrument( /// @param fileName :: the raw file filename /// @param localWorkspace :: The workspace to load the instrument for void LoadRawHelper::runLoadInstrumentFromRaw( - const std::string &fileName, DataObjects::Workspace2D_sptr localWorkspace) { + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace) { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrumentFromRaw"); loadInst->setPropertyValue("Filename", fileName); // Set the workspace property to be the same one filled above @@ -659,7 +660,8 @@ void LoadRawHelper::runLoadInstrumentFromRaw( /// @param fileName :: the raw file filename /// @param localWorkspace :: The workspace to load the mapping table for void LoadRawHelper::runLoadMappingTable( - const std::string &fileName, DataObjects::Workspace2D_sptr localWorkspace) { + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace) { g_log.debug("Loading the spectra-detector mapping..."); progress(m_prog, "Loading the spectra-detector mapping..."); // Now determine the spectra to detector map calling Child Algorithm @@ -685,9 +687,10 @@ void LoadRawHelper::runLoadMappingTable( /// @param localWorkspace :: The workspace to load the logs for /// @param progStart :: starting progress fraction /// @param progEnd :: ending progress fraction -void LoadRawHelper::runLoadLog(const std::string &fileName, - DataObjects::Workspace2D_sptr localWorkspace, - double progStart, double progEnd) { +void LoadRawHelper::runLoadLog( + const std::string &fileName, + const DataObjects::Workspace2D_sptr &localWorkspace, double progStart, + double progEnd) { // search for the log file to load, and save their names in a set. std::list<std::string> logFiles = searchForLogFiles(fileName); @@ -773,7 +776,7 @@ std::string LoadRawHelper::extractLogName(const std::string &path) { * @param local_workspace :: workspace to add period log data to. */ void LoadRawHelper::createPeriodLogs( - int64_t period, DataObjects::Workspace2D_sptr local_workspace) { + int64_t period, const DataObjects::Workspace2D_sptr &local_workspace) { m_logCreator->addPeriodLogs(static_cast<int>(period), local_workspace->mutableRun()); } @@ -785,8 +788,9 @@ void LoadRawHelper::createPeriodLogs( * @param localWorkspace :: The workspace to attach the information to * @param rawFile :: The handle to an ISIS Raw file */ -void LoadRawHelper::loadRunParameters(API::MatrixWorkspace_sptr localWorkspace, - ISISRAW *const rawFile) const { +void LoadRawHelper::loadRunParameters( + const API::MatrixWorkspace_sptr &localWorkspace, + ISISRAW *const rawFile) const { ISISRAW &localISISRaw = [this, rawFile]() -> ISISRAW & { if (rawFile) return *rawFile; @@ -1098,8 +1102,9 @@ void LoadRawHelper::calculateWorkspacesizes( void LoadRawHelper::loadSpectra( FILE *file, const int &period, const int &total_specs, - DataObjects::Workspace2D_sptr ws_sptr, - std::vector<boost::shared_ptr<HistogramData::HistogramX>> timeChannelsVec) { + const DataObjects::Workspace2D_sptr &ws_sptr, + const std::vector<boost::shared_ptr<HistogramData::HistogramX>> + &timeChannelsVec) { double progStart = m_prog; double progEnd = 1.0; // Assume this function is called last diff --git a/Framework/DataHandling/src/LoadSPE.cpp b/Framework/DataHandling/src/LoadSPE.cpp index 11218db3a9ad05f93c688993d9468ad8d966e1f6..791b44ecdf01f8d7179d9e6c3f28ecb5b7d913ce 100644 --- a/Framework/DataHandling/src/LoadSPE.cpp +++ b/Framework/DataHandling/src/LoadSPE.cpp @@ -185,7 +185,8 @@ void LoadSPE::exec() { * @param workspace :: The output workspace * @param index :: The index of the current spectrum */ -void LoadSPE::readHistogram(FILE *speFile, API::MatrixWorkspace_sptr workspace, +void LoadSPE::readHistogram(FILE *speFile, + const API::MatrixWorkspace_sptr &workspace, size_t index) { // First, there should be a comment line char comment[100]; diff --git a/Framework/DataHandling/src/LoadSampleShape.cpp b/Framework/DataHandling/src/LoadSampleShape.cpp index 7e438fe4976fdefdc9225aad6a6772faa65aa685..1ab9f5ac533c4e64934fd78f45845e251020280d 100644 --- a/Framework/DataHandling/src/LoadSampleShape.cpp +++ b/Framework/DataHandling/src/LoadSampleShape.cpp @@ -99,7 +99,7 @@ void LoadSampleShape::exec() { * @param inputWS The workspace to get the rotation from * @returns a shared pointer to the newly rotated Shape */ -void rotate(MeshObject &sampleMesh, MatrixWorkspace_const_sptr inputWS) { +void rotate(MeshObject &sampleMesh, const MatrixWorkspace_const_sptr &inputWS) { const std::vector<double> rotationMatrix = inputWS->run().getGoniometer().getR(); sampleMesh.rotate(rotationMatrix); diff --git a/Framework/DataHandling/src/LoadSassena.cpp b/Framework/DataHandling/src/LoadSassena.cpp index 95ebc7333d7514046aa51934505d7a0d5bc5c130..0635840afa17101d9d464afeec450e8e34fe8e27 100644 --- a/Framework/DataHandling/src/LoadSassena.cpp +++ b/Framework/DataHandling/src/LoadSassena.cpp @@ -20,6 +20,8 @@ #include <hdf5_hl.h> +#include <utility> + namespace Mantid { namespace DataHandling { @@ -47,9 +49,9 @@ int LoadSassena::confidence(Kernel::NexusDescriptor &descriptor) const { * @param ws pointer to workspace to be added and registered * @param description */ -void LoadSassena::registerWorkspace(API::WorkspaceGroup_sptr gws, - const std::string wsName, - DataObjects::Workspace2D_sptr ws, +void LoadSassena::registerWorkspace(const API::WorkspaceGroup_sptr &gws, + const std::string &wsName, + const DataObjects::Workspace2D_sptr &ws, const std::string &description) { UNUSED_ARG(description); API::AnalysisDataService::Instance().add(wsName, ws); @@ -63,7 +65,7 @@ void LoadSassena::registerWorkspace(API::WorkspaceGroup_sptr gws, * @param dims storing dimensionality */ -herr_t LoadSassena::dataSetInfo(const hid_t &h5file, const std::string setName, +herr_t LoadSassena::dataSetInfo(const hid_t &h5file, const std::string &setName, hsize_t *dims) const { H5T_class_t class_id; size_t type_size; @@ -82,7 +84,7 @@ herr_t LoadSassena::dataSetInfo(const hid_t &h5file, const std::string setName, * @param buf storing dataset */ herr_t LoadSassena::dataSetDouble(const hid_t &h5file, - const std::string setName, + const std::string &setName, std::vector<double> &buf) { herr_t errorcode = H5LTread_dataset_double(h5file, setName.c_str(), buf.data()); @@ -110,7 +112,8 @@ bool compare(const mypair &left, const mypair &right) { * increasing order of momemtum transfer */ HistogramData::Points -LoadSassena::loadQvectors(const hid_t &h5file, API::WorkspaceGroup_sptr gws, +LoadSassena::loadQvectors(const hid_t &h5file, + const API::WorkspaceGroup_sptr &gws, std::vector<int> &sorting_indexes) { // store the modulus of the vector @@ -169,7 +172,8 @@ LoadSassena::loadQvectors(const hid_t &h5file, API::WorkspaceGroup_sptr gws, "MomentumTransfer"); // Set the Units this->registerWorkspace( - gws, wsName, ws, "X-axis: origin of Q-vectors; Y-axis: tip of Q-vectors"); + std::move(gws), wsName, ws, + "X-axis: origin of Q-vectors; Y-axis: tip of Q-vectors"); return HistogramData::Points(std::move(qvmod)); } @@ -184,8 +188,9 @@ LoadSassena::loadQvectors(const hid_t &h5file, API::WorkspaceGroup_sptr gws, * @param sorting_indexes permutation of qvmod indexes to render it in * increasing order of momemtum transfer */ -void LoadSassena::loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, +void LoadSassena::loadFQ(const hid_t &h5file, + const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes) { @@ -221,7 +226,7 @@ void LoadSassena::loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, Kernel::UnitFactory::Instance().create("MomentumTransfer"); this->registerWorkspace( - gws, wsName, ws, + std::move(gws), wsName, ws, "X-axis: Q-vector modulus; Y-axis: intermediate structure factor"); } @@ -238,8 +243,9 @@ void LoadSassena::loadFQ(const hid_t &h5file, API::WorkspaceGroup_sptr gws, * @param sorting_indexes permutation of qvmod indexes to render it in * increasing order of momemtum transfer */ -void LoadSassena::loadFQT(const hid_t &h5file, API::WorkspaceGroup_sptr gws, - const std::string setName, +void LoadSassena::loadFQT(const hid_t &h5file, + const API::WorkspaceGroup_sptr &gws, + const std::string &setName, const HistogramData::Points &qvmod, const std::vector<int> &sorting_indexes) { diff --git a/Framework/DataHandling/src/LoadSpice2D.cpp b/Framework/DataHandling/src/LoadSpice2D.cpp index 34287f8771884a5a17f872282cc687e15f6003f2..0b71b10809625963f8b46093e64cab6cc372cc79 100644 --- a/Framework/DataHandling/src/LoadSpice2D.cpp +++ b/Framework/DataHandling/src/LoadSpice2D.cpp @@ -80,8 +80,9 @@ bool from_string(T &t, const std::string &s, * @param wavelength: wavelength value [Angstrom] * @param dwavelength: error on the wavelength [Angstrom] */ -void store_value(DataObjects::Workspace2D_sptr ws, int specID, double value, - double error, double wavelength, double dwavelength) { +void store_value(const DataObjects::Workspace2D_sptr &ws, int specID, + double value, double error, double wavelength, + double dwavelength) { auto &X = ws->mutableX(specID); auto &Y = ws->mutableY(specID); auto &E = ws->mutableE(specID); @@ -659,7 +660,7 @@ void LoadSpice2D::detectorTranslation( */ void LoadSpice2D::runLoadInstrument( const std::string &inst_name, - DataObjects::Workspace2D_sptr localWorkspace) { + const DataObjects::Workspace2D_sptr &localWorkspace) { API::IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); diff --git a/Framework/DataHandling/src/LoadSpiceAscii.cpp b/Framework/DataHandling/src/LoadSpiceAscii.cpp index a2ddfae114427b84875c396b3a2e34552d2981eb..d95e776cdeb1d5d3f0be6b480b9ef259b9312f79 100644 --- a/Framework/DataHandling/src/LoadSpiceAscii.cpp +++ b/Framework/DataHandling/src/LoadSpiceAscii.cpp @@ -436,7 +436,7 @@ LoadSpiceAscii::createRunInfoWS(std::map<std::string, std::string> runinfodict, * @param datetimeprop */ void LoadSpiceAscii::setupRunStartTime( - API::MatrixWorkspace_sptr runinfows, + const API::MatrixWorkspace_sptr &runinfows, const std::vector<std::string> &datetimeprop) { // Check if no need to process run start time if (datetimeprop.empty()) { @@ -596,7 +596,7 @@ std::string LoadSpiceAscii::processTimeString(const std::string &rawtime, * @param pvalue */ template <typename T> -void LoadSpiceAscii::addProperty(API::MatrixWorkspace_sptr ws, +void LoadSpiceAscii::addProperty(const API::MatrixWorkspace_sptr &ws, const std::string &pname, T pvalue) { ws->mutableRun().addLogData(new PropertyWithValue<T>(pname, pvalue)); } diff --git a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp index 5ccd00dee3a0f1c87021638ad836b75e7ccd2d06..d1d6d36bc5cb1a99486c6cde3a45e57180ee2a8d 100644 --- a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp +++ b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp @@ -283,7 +283,8 @@ void LoadSpiceXML2DDet::processInputs() { * @param outws :: workspace to have sample logs to set up * @return */ -bool LoadSpiceXML2DDet::setupSampleLogs(API::MatrixWorkspace_sptr outws) { +bool LoadSpiceXML2DDet::setupSampleLogs( + const API::MatrixWorkspace_sptr &outws) { // With given spice scan table, 2-theta is read from there. if (m_hasScanTable) { ITableWorkspace_sptr spicetablews = getProperty("SpiceTableWorkspace"); @@ -938,8 +939,8 @@ API::MatrixWorkspace_sptr LoadSpiceXML2DDet::xmlParseDetectorNode( * @param ptnumber */ void LoadSpiceXML2DDet::setupSampleLogFromSpiceTable( - MatrixWorkspace_sptr matrixws, ITableWorkspace_sptr spicetablews, - int ptnumber) { + const MatrixWorkspace_sptr &matrixws, + const ITableWorkspace_sptr &spicetablews, int ptnumber) { size_t numrows = spicetablews->rowCount(); std::vector<std::string> colnames = spicetablews->getColumnNames(); // FIXME - Shouldn't give a better value? @@ -978,7 +979,7 @@ void LoadSpiceXML2DDet::setupSampleLogFromSpiceTable( * @param wavelength * @return */ -bool LoadSpiceXML2DDet::getHB3AWavelength(MatrixWorkspace_sptr dataws, +bool LoadSpiceXML2DDet::getHB3AWavelength(const MatrixWorkspace_sptr &dataws, double &wavelength) { bool haswavelength(false); wavelength = -1.; @@ -1043,7 +1044,7 @@ bool LoadSpiceXML2DDet::getHB3AWavelength(MatrixWorkspace_sptr dataws, * @param dataws * @param wavelength */ -void LoadSpiceXML2DDet::setXtoLabQ(API::MatrixWorkspace_sptr dataws, +void LoadSpiceXML2DDet::setXtoLabQ(const API::MatrixWorkspace_sptr &dataws, const double &wavelength) { size_t numspec = dataws->getNumberHistograms(); @@ -1075,9 +1076,7 @@ void LoadSpiceXML2DDet::loadInstrument(API::MatrixWorkspace_sptr matrixws, loadinst->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(true)); loadinst->execute(); - if (loadinst->isExecuted()) - matrixws = loadinst->getProperty("Workspace"); - else + if (!loadinst->isExecuted()) g_log.error("Unable to load instrument to output workspace"); } diff --git a/Framework/DataHandling/src/LoadTBL.cpp b/Framework/DataHandling/src/LoadTBL.cpp index 5f8d2412c644d9ca236eb308f79490eeef08c1f2..32b8778f367e9e648c7ffa43de25c71e8545daca 100644 --- a/Framework/DataHandling/src/LoadTBL.cpp +++ b/Framework/DataHandling/src/LoadTBL.cpp @@ -81,7 +81,7 @@ int LoadTBL::confidence(Kernel::FileDescriptor &descriptor) const { * @param line the line to count from * @returns a size_t of how many commas were in line */ -size_t LoadTBL::countCommas(std::string line) const { +size_t LoadTBL::countCommas(const std::string &line) const { size_t found = 0; size_t pos = line.find(',', 0); if (pos != std::string::npos) { @@ -104,7 +104,7 @@ size_t LoadTBL::countCommas(std::string line) const { * @returns a size_t of how many pairs of quotes were in line */ size_t -LoadTBL::findQuotePairs(std::string line, +LoadTBL::findQuotePairs(const std::string &line, std::vector<std::vector<size_t>> "eBounds) const { size_t quoteOne = 0; size_t quoteTwo = 0; @@ -137,7 +137,7 @@ LoadTBL::findQuotePairs(std::string line, * @throws std::length_error if anything other than 17 columns (or 16 * cell-delimiting commas) is found */ -void LoadTBL::csvParse(std::string line, std::vector<std::string> &cols, +void LoadTBL::csvParse(const std::string &line, std::vector<std::string> &cols, std::vector<std::vector<size_t>> "eBounds, size_t expectedCommas) const { size_t pairID = 0; diff --git a/Framework/DataHandling/src/LoadTOFRawNexus.cpp b/Framework/DataHandling/src/LoadTOFRawNexus.cpp index 6e4674f1c1c054da97d1a59354cd7a4b0365b6e2..70e95229d386aa2235aa911d7854350fdd623fa3 100644 --- a/Framework/DataHandling/src/LoadTOFRawNexus.cpp +++ b/Framework/DataHandling/src/LoadTOFRawNexus.cpp @@ -20,6 +20,7 @@ #include <boost/algorithm/string/detail/classification.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> namespace Mantid { namespace DataHandling { @@ -267,7 +268,7 @@ namespace { // Check the numbers supplied are not in the range and erase the ones that are struct range_check { range_check(specnum_t min, specnum_t max, detid2index_map id_to_wi) - : m_min(min), m_max(max), m_id_to_wi(id_to_wi) {} + : m_min(min), m_max(max), m_id_to_wi(std::move(id_to_wi)) {} bool operator()(specnum_t x) { auto wi = static_cast<specnum_t>((m_id_to_wi)[x]); @@ -292,7 +293,7 @@ private: void LoadTOFRawNexus::loadBank(const std::string &nexusfilename, const std::string &entry_name, const std::string &bankName, - API::MatrixWorkspace_sptr WS, + const API::MatrixWorkspace_sptr &WS, const detid2index_map &id_to_wi) { g_log.debug() << "Loading bank " << bankName << '\n'; // To avoid segfaults on RHEL5/6 and Fedora diff --git a/Framework/DataHandling/src/MaskDetectors.cpp b/Framework/DataHandling/src/MaskDetectors.cpp index 6e361b54a98b2dc6e579a0515558a69a03c4817a..1661e4a4605111cc81bbb257a0248d27493cd18a 100644 --- a/Framework/DataHandling/src/MaskDetectors.cpp +++ b/Framework/DataHandling/src/MaskDetectors.cpp @@ -244,8 +244,8 @@ void MaskDetectors::exec() { * @param rangeInfo :: information about the spectrum range to use when masking */ void MaskDetectors::handleMaskByMaskWorkspace( - const MaskWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, + const MaskWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, std::vector<detid_t> &detectorList, std::vector<size_t> &indexList, const RangeInfo &rangeInfo) { @@ -280,8 +280,8 @@ void MaskDetectors::handleMaskByMaskWorkspace( * @param rangeInfo :: information about the spectrum range to use when masking */ void MaskDetectors::handleMaskByMatrixWorkspace( - const API::MatrixWorkspace_const_sptr maskWs, - const API::MatrixWorkspace_const_sptr WS, + const API::MatrixWorkspace_const_sptr &maskWs, + const API::MatrixWorkspace_const_sptr &WS, std::vector<detid_t> &detectorList, std::vector<size_t> &indexList, const RangeInfo &rangeInfo) { @@ -395,7 +395,7 @@ void MaskDetectors::extractMaskedWSDetIDs( * Peaks exec body * @param WS :: The input peaks workspace to be masked */ -void MaskDetectors::execPeaks(PeaksWorkspace_sptr WS) { +void MaskDetectors::execPeaks(const PeaksWorkspace_sptr &WS) { std::vector<detid_t> detectorList = getProperty("DetectorList"); const MatrixWorkspace_sptr prevMasking = getProperty("MaskedWorkspace"); @@ -455,7 +455,7 @@ void MaskDetectors::execPeaks(PeaksWorkspace_sptr WS) { void MaskDetectors::fillIndexListFromSpectra( std::vector<size_t> &indexList, std::vector<Indexing::SpectrumNumber> spectraList, - const API::MatrixWorkspace_sptr WS, + const API::MatrixWorkspace_sptr &WS, const std::tuple<size_t, size_t, bool> &range_info) { std::vector<size_t> tmp_index; @@ -494,7 +494,7 @@ void MaskDetectors::fillIndexListFromSpectra( * Boolean indicating if these ranges are defined */ void MaskDetectors::appendToIndexListFromWS( - std::vector<size_t> &indexList, const MatrixWorkspace_const_sptr sourceWS, + std::vector<size_t> &indexList, const MatrixWorkspace_const_sptr &sourceWS, const std::tuple<size_t, size_t, bool> &range_info) { std::vector<size_t> tmp_index; @@ -537,8 +537,8 @@ void MaskDetectors::appendToIndexListFromWS( */ void MaskDetectors::appendToDetectorListFromWS( std::vector<detid_t> &detectorList, - const MatrixWorkspace_const_sptr inputWs, - const MatrixWorkspace_const_sptr maskWs, + const MatrixWorkspace_const_sptr &inputWs, + const MatrixWorkspace_const_sptr &maskWs, const std::tuple<size_t, size_t, bool> &range_info) { const auto startIndex = std::get<0>(range_info); const auto endIndex = std::get<1>(range_info); @@ -567,7 +567,7 @@ void MaskDetectors::appendToDetectorListFromWS( */ void MaskDetectors::appendToIndexListFromMaskWS( std::vector<size_t> &indexList, - const DataObjects::MaskWorkspace_const_sptr maskedWorkspace, + const DataObjects::MaskWorkspace_const_sptr &maskedWorkspace, const std::tuple<size_t, size_t, bool> &range_info) { std::vector<size_t> tmp_index; @@ -610,7 +610,7 @@ void MaskDetectors::appendToIndexListFromMaskWS( void MaskDetectors::appendToDetectorListFromComponentList( std::vector<detid_t> &detectorList, const std::vector<std::string> &componentList, - const API::MatrixWorkspace_const_sptr WS) { + const API::MatrixWorkspace_const_sptr &WS) { const auto instrument = WS->getInstrument(); if (!instrument) { g_log.error() diff --git a/Framework/DataHandling/src/MaskDetectorsInShape.cpp b/Framework/DataHandling/src/MaskDetectorsInShape.cpp index af163e494079726a30572e4b7b58dba6ec9eac0a..08b2a090d9deccb5f9e997d58dd43ccdadf24b86 100644 --- a/Framework/DataHandling/src/MaskDetectorsInShape.cpp +++ b/Framework/DataHandling/src/MaskDetectorsInShape.cpp @@ -53,7 +53,7 @@ void MaskDetectorsInShape::exec() { /// Run the FindDetectorsInShape Child Algorithm std::vector<int> MaskDetectorsInShape::runFindDetectorsInShape( - API::MatrixWorkspace_sptr workspace, const std::string shapeXML, + const API::MatrixWorkspace_sptr &workspace, const std::string &shapeXML, const bool includeMonitors) { IAlgorithm_sptr alg = createChildAlgorithm("FindDetectorsInShape"); alg->setPropertyValue("IncludeMonitors", includeMonitors ? "1" : "0"); @@ -76,7 +76,8 @@ std::vector<int> MaskDetectorsInShape::runFindDetectorsInShape( } void MaskDetectorsInShape::runMaskDetectors( - API::MatrixWorkspace_sptr workspace, const std::vector<int> &detectorIds) { + const API::MatrixWorkspace_sptr &workspace, + const std::vector<int> &detectorIds) { auto &detectorInfo = workspace->mutableDetectorInfo(); for (const auto &id : detectorIds) detectorInfo.setMasked(detectorInfo.indexOf(id), true); diff --git a/Framework/DataHandling/src/MeshFileIO.cpp b/Framework/DataHandling/src/MeshFileIO.cpp index 6d481549fd9aa4d9bb888cf340f5df62869b2a78..6b899115961f763a04bcdd3b85edabb69d0deb27 100644 --- a/Framework/DataHandling/src/MeshFileIO.cpp +++ b/Framework/DataHandling/src/MeshFileIO.cpp @@ -88,7 +88,7 @@ Kernel::Matrix<double> MeshFileIO::generateZRotation(double zRotation) { */ boost::shared_ptr<Geometry::MeshObject> MeshFileIO::translate(boost::shared_ptr<Geometry::MeshObject> environmentMesh, - const std::vector<double> translationVector) { + const std::vector<double> &translationVector) { std::vector<double> checkVector = std::vector<double>(3, 0.0); if (translationVector != checkVector) { if (translationVector.size() != 3) { diff --git a/Framework/DataHandling/src/PDLoadCharacterizations.cpp b/Framework/DataHandling/src/PDLoadCharacterizations.cpp index 091ccc71d933bedf091be597790642dd028ba31b..6bccfcb4b5f6224e29ae90466eeefc478b456a2c 100644 --- a/Framework/DataHandling/src/PDLoadCharacterizations.cpp +++ b/Framework/DataHandling/src/PDLoadCharacterizations.cpp @@ -298,7 +298,7 @@ std::vector<std::string> PDLoadCharacterizations::getFilenames() { * @returns line number that file was read to */ int PDLoadCharacterizations::readFocusInfo(std::ifstream &file, - const std::string filename) { + const std::string &filename) { // end early if already at the end of the file if (file.eof()) return 0; diff --git a/Framework/DataHandling/src/ProcessBankData.cpp b/Framework/DataHandling/src/ProcessBankData.cpp index 323529fe143041d93bd7fb25ace369c31185b1c3..120fcf64becde776c121ddcb8baebed4e5c9d95d 100644 --- a/Framework/DataHandling/src/ProcessBankData.cpp +++ b/Framework/DataHandling/src/ProcessBankData.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataHandling/ProcessBankData.h" +#include <utility> + #include "MantidDataHandling/DefaultEventLoader.h" #include "MantidDataHandling/LoadEventNexus.h" +#include "MantidDataHandling/ProcessBankData.h" using namespace Mantid::DataObjects; @@ -21,14 +23,16 @@ ProcessBankData::ProcessBankData( boost::shared_ptr<BankPulseTimes> thisBankPulseTimes, bool have_weight, boost::shared_array<float> event_weight, detid_t min_event_id, detid_t max_event_id) - : Task(), m_loader(m_loader), entry_name(entry_name), + : Task(), m_loader(m_loader), entry_name(std::move(entry_name)), pixelID_to_wi_vector(m_loader.pixelID_to_wi_vector), pixelID_to_wi_offset(m_loader.pixelID_to_wi_offset), prog(prog), - event_id(event_id), event_time_of_flight(event_time_of_flight), - numEvents(numEvents), startAt(startAt), event_index(event_index), - thisBankPulseTimes(thisBankPulseTimes), have_weight(have_weight), - event_weight(event_weight), m_min_id(min_event_id), - m_max_id(max_event_id) { + event_id(std::move(event_id)), + event_time_of_flight(std::move(event_time_of_flight)), + numEvents(numEvents), startAt(startAt), + event_index(std::move(event_index)), + thisBankPulseTimes(std::move(thisBankPulseTimes)), + have_weight(have_weight), event_weight(std::move(event_weight)), + m_min_id(min_event_id), m_max_id(max_event_id) { // Cost is approximately proportional to the number of events to process. m_cost = static_cast<double>(numEvents); } @@ -88,7 +92,7 @@ void ProcessBankData::run() { // override { // Now we pre-allocate (reserve) the vectors of events in each pixel // counted const size_t numEventLists = outputWS.getNumberHistograms(); - for (detid_t pixID = m_min_id; pixID <= m_max_id; pixID++) { + for (detid_t pixID = m_min_id; pixID <= m_max_id; ++pixID) { if (counts[pixID - m_min_id] > 0) { size_t wi = getWorkspaceIndexFromPixelID(pixID); // Find the the workspace index corresponding to that pixel ID @@ -220,7 +224,7 @@ void ProcessBankData::run() { // override { //------------ Compress Events (or set sort order) ------------------ // Do it on all the detector IDs we touched if (compress) { - for (detid_t pixID = m_min_id; pixID <= m_max_id; pixID++) { + for (detid_t pixID = m_min_id; pixID <= m_max_id; ++pixID) { if (usedDetIds[pixID - m_min_id]) { // Find the the workspace index corresponding to that pixel ID size_t wi = getWorkspaceIndexFromPixelID(pixID); diff --git a/Framework/DataHandling/src/ReadMaterial.cpp b/Framework/DataHandling/src/ReadMaterial.cpp index cf3da641202e9ec18896f7f1f64401b1431df264..b65fb49728f9292cc93344f159c4c3ed27d813af 100644 --- a/Framework/DataHandling/src/ReadMaterial.cpp +++ b/Framework/DataHandling/src/ReadMaterial.cpp @@ -79,8 +79,6 @@ ReadMaterial::validateInputs(const MaterialParameters ¶ms) { if (canCalculateMassDensity) { result["SampleMassDensity"] = "Cannot give SampleMassDensity with SampleNumberDensity set"; - result["SampleMassDensity"] = - "Cannot give SampleMassDensity with SampleNumberDensity set"; } } return result; @@ -118,7 +116,7 @@ std::unique_ptr<Kernel::Material> ReadMaterial::buildMaterial() { return std::make_unique<Kernel::Material>(builder.build()); } -void ReadMaterial::setMaterial(const std::string chemicalSymbol, +void ReadMaterial::setMaterial(const std::string &chemicalSymbol, const int atomicNumber, const int massNumber) { if (!chemicalSymbol.empty()) { builder.setFormula(chemicalSymbol); diff --git a/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp b/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp index 332c391333ceeb9aac25765abf6cb248306260ee..b3a10b949a19ce026b54559d8941e4f869a8c1d3 100644 --- a/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp +++ b/Framework/DataHandling/src/SampleEnvironmentSpecParser.cpp @@ -258,7 +258,7 @@ SampleEnvironmentSpecParser::parseContainer(Element *element) const { * @param targetVariable Value read from element attribute */ void SampleEnvironmentSpecParser::LoadOptionalDoubleFromXML( - Poco::XML::Element *componentElement, std::string attributeName, + Poco::XML::Element *componentElement, const std::string &attributeName, double &targetVariable) const { auto attributeText = componentElement->getAttribute(attributeName); @@ -279,7 +279,7 @@ void SampleEnvironmentSpecParser::LoadOptionalDoubleFromXML( * @return vector containing translations */ std::vector<double> SampleEnvironmentSpecParser::parseTranslationVector( - std::string translationVectorStr) const { + const std::string &translationVectorStr) const { std::vector<double> translationVector; diff --git a/Framework/DataHandling/src/SaveAscii2.cpp b/Framework/DataHandling/src/SaveAscii2.cpp index 3462bc44c134633c2b6017fe12f3463fba8c5b79..b4b20cc7d6e9a4f138f9ff3b48bec7da738f17b9 100644 --- a/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Framework/DataHandling/src/SaveAscii2.cpp @@ -473,7 +473,7 @@ bool SaveAscii2::findElementInUnorderedStringVector( return std::find(vector.cbegin(), vector.cend(), toFind) != vector.cend(); } -void SaveAscii2::writeTableWorkspace(ITableWorkspace_const_sptr tws, +void SaveAscii2::writeTableWorkspace(const ITableWorkspace_const_sptr &tws, const std::string &filename, bool appendToFile, bool writeHeader, int prec, bool scientific, diff --git a/Framework/DataHandling/src/SaveCSV.cpp b/Framework/DataHandling/src/SaveCSV.cpp index f96198738c78e38b4b8d7c36d4ccbc27ebdc1b2b..ffe7c857944f8f5a1ac4003333d01c9ca6bd691c 100644 --- a/Framework/DataHandling/src/SaveCSV.cpp +++ b/Framework/DataHandling/src/SaveCSV.cpp @@ -184,9 +184,10 @@ void SaveCSV::exec() { outCSV_File.close(); } -void SaveCSV::saveXerrors(std::ofstream &stream, - const Mantid::DataObjects::Workspace2D_sptr workspace, - const size_t numberOfHist) { +void SaveCSV::saveXerrors( + std::ofstream &stream, + const Mantid::DataObjects::Workspace2D_sptr &workspace, + const size_t numberOfHist) { // If there isn't a dx values present in the first entry then return if (!workspace->hasDx(0)) { return; diff --git a/Framework/DataHandling/src/SaveCalFile.cpp b/Framework/DataHandling/src/SaveCalFile.cpp index 4efc4101662b6b2b89bb1946804c3422dd63b19d..ddf6721fe4b616a169974c9d214f3bf81d2499c6 100644 --- a/Framework/DataHandling/src/SaveCalFile.cpp +++ b/Framework/DataHandling/src/SaveCalFile.cpp @@ -80,9 +80,9 @@ void SaveCalFile::exec() { *(selected) if not specified. */ void SaveCalFile::saveCalFile(const std::string &calFileName, - GroupingWorkspace_sptr groupWS, - OffsetsWorkspace_sptr offsetsWS, - MaskWorkspace_sptr maskWS) { + const GroupingWorkspace_sptr &groupWS, + const OffsetsWorkspace_sptr &offsetsWS, + const MaskWorkspace_sptr &maskWS) { Instrument_const_sptr inst; bool doGroup = false; diff --git a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp index 17feffa71b4924f55b4de1248175569752ce39a2..33f3f59cda0925b4cec88dc58809f9fcdeb1d8ab 100644 --- a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp +++ b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp @@ -143,8 +143,8 @@ void SaveDetectorsGrouping::convertToDetectorsRanges( } void SaveDetectorsGrouping::printToXML( - std::map<int, std::vector<detid_t>> groupdetidrangemap, - std::string xmlfilename) { + const std::map<int, std::vector<detid_t>> &groupdetidrangemap, + const std::string &xmlfilename) { // 1. Get Instrument information const auto &instrument = mGroupWS->getInstrument(); diff --git a/Framework/DataHandling/src/SaveDiffCal.cpp b/Framework/DataHandling/src/SaveDiffCal.cpp index 3e3a42fce5dfc526999ab2c2d81b13f22c9a1b2a..1911d8a18894b7cd8dbb9279dc9f9617ca1ea520 100644 --- a/Framework/DataHandling/src/SaveDiffCal.cpp +++ b/Framework/DataHandling/src/SaveDiffCal.cpp @@ -107,6 +107,7 @@ std::map<std::string, std::string> SaveDiffCal::validateInputs() { void SaveDiffCal::writeDoubleFieldFromTable(H5::Group &group, const std::string &name) { auto column = m_calibrationWS->getColumn(name); + // cppcheck-suppress compareBoolExpressionWithInt auto data = column->numeric_fill<>(m_numValues); H5Util::writeArray1D(group, name, data); } @@ -121,7 +122,7 @@ void SaveDiffCal::writeIntFieldFromTable(H5::Group &group, // TODO should flip for mask void SaveDiffCal::writeIntFieldFromSVWS( H5::Group &group, const std::string &name, - DataObjects::SpecialWorkspace2D_const_sptr ws) { + const DataObjects::SpecialWorkspace2D_const_sptr &ws) { const bool isMask = (name == "use"); // output array defaults to all one (one group, use the pixel) diff --git a/Framework/DataHandling/src/SaveDiffFittingAscii.cpp b/Framework/DataHandling/src/SaveDiffFittingAscii.cpp index cbc35b9c2138863319729b9b7b6dbc3f2f8a43bc..855f18b005d43ab8dc3b8bc6820ce4e8b37cb540 100644 --- a/Framework/DataHandling/src/SaveDiffFittingAscii.cpp +++ b/Framework/DataHandling/src/SaveDiffFittingAscii.cpp @@ -111,7 +111,7 @@ bool SaveDiffFittingAscii::processGroups() { } void SaveDiffFittingAscii::processAll( - const std::vector<API::ITableWorkspace_sptr> input_ws) { + const std::vector<API::ITableWorkspace_sptr> &input_ws) { const std::string filename = getProperty("Filename"); const std::string outMode = getProperty("OutMode"); @@ -208,7 +208,7 @@ void SaveDiffFittingAscii::writeHeader( } } -void SaveDiffFittingAscii::writeData(const API::ITableWorkspace_sptr workspace, +void SaveDiffFittingAscii::writeData(const API::ITableWorkspace_sptr &workspace, std::ofstream &file, const size_t columnSize) { diff --git a/Framework/DataHandling/src/SaveDspacemap.cpp b/Framework/DataHandling/src/SaveDspacemap.cpp index fd45f8af640a6daf74030c95012caa7ab31a0031..aec81df61090cf12ca9c730e716a1da2bb74b9dd 100644 --- a/Framework/DataHandling/src/SaveDspacemap.cpp +++ b/Framework/DataHandling/src/SaveDspacemap.cpp @@ -56,8 +56,8 @@ void SaveDspacemap::exec() { * @param offsetsWS :: OffsetsWorkspace with instrument and offsets */ void SaveDspacemap::CalculateDspaceFromCal( - Mantid::DataObjects::OffsetsWorkspace_sptr offsetsWS, - std::string DFileName) { + const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, + const std::string &DFileName) { const char *filename = DFileName.c_str(); // Get a pointer to the instrument contained in the workspace Instrument_const_sptr instrument = offsetsWS->getInstrument(); @@ -87,7 +87,7 @@ void SaveDspacemap::CalculateDspaceFromCal( std::ofstream fout(filename, std::ios_base::out | std::ios_base::binary); Progress prog(this, 0.0, 1.0, maxdetID); - for (detid_t i = 0; i != maxdetID; i++) { + for (detid_t i = 0; i != maxdetID; ++i) { // Compute the factor double factor; Geometry::IDetector_const_sptr det; diff --git a/Framework/DataHandling/src/SaveFITS.cpp b/Framework/DataHandling/src/SaveFITS.cpp index df21ad55193701ee80a450466eb6a46afa9e0537..a1ed7eb99a111a11ae7f74d9ab9d25f48077de78 100644 --- a/Framework/DataHandling/src/SaveFITS.cpp +++ b/Framework/DataHandling/src/SaveFITS.cpp @@ -143,7 +143,7 @@ void SaveFITS::exec() { * @param img matrix workspace (one spectrum per row) * @param filename relative or full path, should be already checked */ -void SaveFITS::saveFITSImage(const API::MatrixWorkspace_sptr img, +void SaveFITS::saveFITSImage(const API::MatrixWorkspace_sptr &img, const std::string &filename) { std::ofstream outfile(filename, std::ofstream::binary); @@ -151,7 +151,7 @@ void SaveFITS::saveFITSImage(const API::MatrixWorkspace_sptr img, writeFITSImageMatrix(img, outfile); } -void SaveFITS::writeFITSHeaderBlock(const API::MatrixWorkspace_sptr img, +void SaveFITS::writeFITSHeaderBlock(const API::MatrixWorkspace_sptr &img, std::ofstream &file) { // minimal sequence of standard headers writeFITSHeaderEntry(g_FITSHdrFirst, file); @@ -169,7 +169,7 @@ void SaveFITS::writeFITSHeaderBlock(const API::MatrixWorkspace_sptr img, writePaddingFITSHeaders(entriesPerHDU - 9, file); } -void SaveFITS::writeFITSImageMatrix(const API::MatrixWorkspace_sptr img, +void SaveFITS::writeFITSImageMatrix(const API::MatrixWorkspace_sptr &img, std::ofstream &file) { const size_t sizeX = img->blocksize(); const size_t sizeY = img->getNumberHistograms(); @@ -213,7 +213,7 @@ void SaveFITS::writeFITSHeaderEntry(const std::string &hdr, file.write(blanks.data(), g_maxLenHdr - count); } -void SaveFITS::writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr img, +void SaveFITS::writeFITSHeaderAxesSizes(const API::MatrixWorkspace_sptr &img, std::ofstream &file) { const std::string sizeX = std::to_string(img->blocksize()); const std::string sizeY = std::to_string(img->getNumberHistograms()); diff --git a/Framework/DataHandling/src/SaveFullprofResolution.cpp b/Framework/DataHandling/src/SaveFullprofResolution.cpp index 0b71d7030b7b0d7a445e7f3ed19a6ac8be7a9380..b0fe14c72c8aa6f8be85871ef322d92fc22b42bd 100644 --- a/Framework/DataHandling/src/SaveFullprofResolution.cpp +++ b/Framework/DataHandling/src/SaveFullprofResolution.cpp @@ -480,7 +480,7 @@ std::string SaveFullprofResolution::toProf9IrfString() { /** Check wether a profile parameter map has the parameter */ bool SaveFullprofResolution::has_key(std::map<std::string, double> profmap, - std::string key) { + const std::string &key) { map<string, double>::iterator fiter; fiter = profmap.find(key); bool exist = true; diff --git a/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp b/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp index 9167a981b42ca9085d05294a345ecf141ceda360..940ca4ab246527012b02f557c0ea07d04a08040e 100644 --- a/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp +++ b/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp @@ -505,7 +505,7 @@ void SaveGSASInstrumentFile::initConstants( /** Parse profile table workspace to a map (the new ... */ void SaveGSASInstrumentFile::parseProfileTableWorkspace( - ITableWorkspace_sptr ws, + const ITableWorkspace_sptr &ws, map<unsigned int, map<string, double>> &profilemap) { size_t numbanks = ws->columnCount() - 1; size_t numparams = ws->rowCount(); @@ -896,74 +896,74 @@ void SaveGSASInstrumentFile::writePRMSingleBank( throw runtime_error(errss.str()); } - fprintf(pFile, "INS %2d ICONS%10.3f%10.3f%10.3f %10.3f%5d%10.3f\n", + fprintf(pFile, "INS %2u ICONS%10.3f%10.3f%10.3f %10.3f%5d%10.3f\n", bankid, instC * 1.00009, 0.0, zero, 0.0, 0, 0.0); - fprintf(pFile, "INS %2dBNKPAR%10.3f%10.3f%10.3f%10.3f%10.3f%5d%5d\n", bankid, + fprintf(pFile, "INS %2uBNKPAR%10.3f%10.3f%10.3f%10.3f%10.3f%5d%5d\n", bankid, m_L2, twotheta, 0., 0., 0.2, 1, 1); - fprintf(pFile, "INS %2dBAKGD 1 4 Y 0 Y\n", bankid); - fprintf(pFile, "INS %2dI HEAD %s\n", bankid, titleline.c_str()); - fprintf(pFile, "INS %2dI ITYP%5d%10.4f%10.4f%10i\n", bankid, 0, + fprintf(pFile, "INS %2uBAKGD 1 4 Y 0 Y\n", bankid); + fprintf(pFile, "INS %2uI HEAD %s\n", bankid, titleline.c_str()); + fprintf(pFile, "INS %2uI ITYP%5d%10.4f%10.4f%10i\n", bankid, 0, mindsp * 0.001 * instC, maxtof, randint); - fprintf(pFile, "INS %2dINAME %s \n", bankid, m_instrument.c_str()); - fprintf(pFile, "INS %2dPRCF1 %5d%5d%10.5f\n", bankid, -3, 21, 0.002); - fprintf(pFile, "INS %2dPRCF11%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uINAME %s \n", bankid, m_instrument.c_str()); + fprintf(pFile, "INS %2uPRCF1 %5d%5d%10.5f\n", bankid, -3, 21, 0.002); + fprintf(pFile, "INS %2uPRCF11%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig0); - fprintf(pFile, "INS %2dPRCF12%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, + fprintf(pFile, "INS %2uPRCF12%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, gam0, gam1); - fprintf(pFile, "INS %2dPRCF13%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, + fprintf(pFile, "INS %2uPRCF13%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF14%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF14%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF15%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF15%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF16%15.6f\n", bankid, 0.0); - fprintf(pFile, "INS %2dPAB3 %3d\n", bankid, 90); + fprintf(pFile, "INS %2uPRCF16%15.6f\n", bankid, 0.0); + fprintf(pFile, "INS %2uPAB3 %3d\n", bankid, 90); for (size_t k = 0; k < 90; ++k) { - fprintf(pFile, "INS %2dPAB3%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB3%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } - fprintf(pFile, "INS %2dPRCF2 %5i%5i%10.5f\n", bankid, -4, 27, 0.002); - fprintf(pFile, "INS %2dPRCF21%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF2 %5i%5i%10.5f\n", bankid, -4, 27, 0.002); + fprintf(pFile, "INS %2uPRCF21%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig1); - fprintf(pFile, "INS %2dPRCF22%15.6f%15.6f%15.6f%15.6f\n", bankid, sig2, gam2, + fprintf(pFile, "INS %2uPRCF22%15.6f%15.6f%15.6f%15.6f\n", bankid, sig2, gam2, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF23%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF23%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF24%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF24%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF25%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF25%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF26%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF26%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF27%15.6f%15.6f%15.6f \n", bankid, 0.0, 0.0, 0.0); + fprintf(pFile, "INS %2uPRCF27%15.6f%15.6f%15.6f \n", bankid, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPAB4 %3i\n", bankid, 90); + fprintf(pFile, "INS %2uPAB4 %3i\n", bankid, 90); for (size_t k = 0; k < 90; ++k) { - fprintf(pFile, "INS %2dPAB4%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB4%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } - fprintf(pFile, "INS %2dPRCF3 %5i%5i%10.5f\n", bankid, -5, 21, 0.002); - fprintf(pFile, "INS %2dPRCF31%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF3 %5i%5i%10.5f\n", bankid, -5, 21, 0.002); + fprintf(pFile, "INS %2uPRCF31%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig0); - fprintf(pFile, "INS %2dPRCF32%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, + fprintf(pFile, "INS %2uPRCF32%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, gam0, gam1); - fprintf(pFile, "INS %2dPRCF33%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, + fprintf(pFile, "INS %2uPRCF33%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF34%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF34%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF35%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF35%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF36%15.6f\n", bankid, 0.0); + fprintf(pFile, "INS %2uPRCF36%15.6f\n", bankid, 0.0); - fprintf(pFile, "INS %2dPAB5 %3i\n", bankid, + fprintf(pFile, "INS %2uPAB5 %3i\n", bankid, 90); // 90 means there will be 90 lines of table for (size_t k = 0; k < 90; k++) { - fprintf(pFile, "INS %2dPAB5%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB5%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } @@ -1086,7 +1086,7 @@ double SaveGSASInstrumentFile::calDspRange(double dtt1, double zero, * @param irffilename */ void SaveGSASInstrumentFile::loadFullprofResolutionFile( - std::string irffilename) { + const std::string &irffilename) { IAlgorithm_sptr loadfpirf; try { loadfpirf = createChildAlgorithm("LoadFullprofResolution"); diff --git a/Framework/DataHandling/src/SaveIsawDetCal.cpp b/Framework/DataHandling/src/SaveIsawDetCal.cpp index f2bfbc93b7a90beb612656a923034381b9e86e91..87374bdf19a85da55beb4cc4ad530f38b1e1135c 100644 --- a/Framework/DataHandling/src/SaveIsawDetCal.cpp +++ b/Framework/DataHandling/src/SaveIsawDetCal.cpp @@ -227,7 +227,8 @@ void SaveIsawDetCal::exec() { out.close(); } -V3D SaveIsawDetCal::findPixelPos(std::string bankName, int col, int row) { +V3D SaveIsawDetCal::findPixelPos(const std::string &bankName, int col, + int row) { boost::shared_ptr<const IComponent> parent = inst->getComponentByName(bankName); if (parent->type() == "RectangularDetector") { @@ -261,8 +262,8 @@ V3D SaveIsawDetCal::findPixelPos(std::string bankName, int col, int row) { } } -void SaveIsawDetCal::sizeBanks(std::string bankName, int &NCOLS, int &NROWS, - double &xsize, double &ysize) { +void SaveIsawDetCal::sizeBanks(const std::string &bankName, int &NCOLS, + int &NROWS, double &xsize, double &ysize) { if (bankName == "None") return; boost::shared_ptr<const IComponent> parent = diff --git a/Framework/DataHandling/src/SaveNXTomo.cpp b/Framework/DataHandling/src/SaveNXTomo.cpp index 0a5d24977c62272815f7b054fbec240c585c5e02..435d1e504a3fea4f863fe3bbfcbb3fb68b676bd8 100644 --- a/Framework/DataHandling/src/SaveNXTomo.cpp +++ b/Framework/DataHandling/src/SaveNXTomo.cpp @@ -304,7 +304,7 @@ void SaveNXTomo::processAll() { * @param workspace the workspace to get data from * @param nxFile the nexus file to save data into */ -void SaveNXTomo::writeSingleWorkspace(const Workspace2D_sptr workspace, +void SaveNXTomo::writeSingleWorkspace(const Workspace2D_sptr &workspace, ::NeXus::File &nxFile) { try { nxFile.openPath("/entry1/tomo_entry/data"); @@ -372,7 +372,7 @@ void SaveNXTomo::writeSingleWorkspace(const Workspace2D_sptr workspace, } void SaveNXTomo::writeImageKeyValue( - const DataObjects::Workspace2D_sptr workspace, ::NeXus::File &nxFile, + const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd) { // Add ImageKey to instrument/image_key if present, use 0 if not try { @@ -401,7 +401,7 @@ void SaveNXTomo::writeImageKeyValue( nxFile.closeGroup(); } -void SaveNXTomo::writeLogValues(const DataObjects::Workspace2D_sptr workspace, +void SaveNXTomo::writeLogValues(const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd) { // Add Log information (minus special values - Rotation, ImageKey, Intensity) // Unable to add multidimensional string data, storing strings as @@ -446,7 +446,7 @@ void SaveNXTomo::writeLogValues(const DataObjects::Workspace2D_sptr workspace, } void SaveNXTomo::writeIntensityValue( - const DataObjects::Workspace2D_sptr workspace, ::NeXus::File &nxFile, + const DataObjects::Workspace2D_sptr &workspace, ::NeXus::File &nxFile, int thisFileInd) { // Add Intensity to control if present, use 1 if not try { diff --git a/Framework/DataHandling/src/SaveNXcanSAS.cpp b/Framework/DataHandling/src/SaveNXcanSAS.cpp index 094314b590c104b57f2199f5f0189fded5b4dcdf..1fdff8ad829b488b8f9b816b6e56393c937d0b29 100644 --- a/Framework/DataHandling/src/SaveNXcanSAS.cpp +++ b/Framework/DataHandling/src/SaveNXcanSAS.cpp @@ -34,6 +34,7 @@ #include <cctype> #include <functional> #include <iterator> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::Geometry; @@ -56,9 +57,9 @@ void removeSpecialCharacters(std::string &input) { input = boost::regex_replace(input, toReplace, replaceWith); } -std::string -makeCompliantName(const std::string &input, bool isStrict, - std::function<void(std::string &)> captializeStrategy) { +std::string makeCompliantName( + const std::string &input, bool isStrict, + const std::function<void(std::string &)> &captializeStrategy) { auto output = input; // Check if input is compliant if (!isCanSASCompliant(isStrict, output)) { @@ -173,7 +174,7 @@ std::vector<std::string> splitDetectorNames(std::string detectorNames) { * @return the sasEntry */ H5::Group addSasEntry(H5::H5File &file, - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &suffix) { using namespace Mantid::DataHandling::NXcanSAS; const std::string sasEntryName = sasEntryGroupName + suffix; @@ -201,18 +202,20 @@ H5::Group addSasEntry(H5::H5File &file, } //------- SASinstrument -std::string getInstrumentName(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string +getInstrumentName(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto instrument = workspace->getInstrument(); return instrument->getFullName(); } -std::string getIDF(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string getIDF(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto date = workspace->getWorkspaceStartDate(); auto instrumentName = getInstrumentName(workspace); return workspace->getInstrumentFilename(instrumentName, date); } -void addDetectors(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace, +void addDetectors(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace, const std::vector<std::string> &detectorNames) { // If the group is empty then don't add anything if (!detectorNames.empty()) { @@ -256,7 +259,7 @@ void addDetectors(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace, * @param detectorNames: the names of the detectors to store */ void addInstrument(H5::Group &group, - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &radiationSource, const std::vector<std::string> &detectorNames) { // Setup instrument @@ -301,7 +304,8 @@ std::string getDate() { * @param group: the sasEntry * @param workspace: the workspace which is being stored */ -void addProcess(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { +void addProcess(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace) { // Setup process const std::string sasProcessNameForGroup = sasProcessGroupName; auto process = Mantid::DataHandling::H5Util::createGroupCanSAS( @@ -334,8 +338,9 @@ void addProcess(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { * @param group: the sasEntry * @param workspace: the workspace which is being stored */ -void addProcess(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace, - Mantid::API::MatrixWorkspace_sptr canWorkspace) { +void addProcess(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace, + const Mantid::API::MatrixWorkspace_sptr &canWorkspace) { // Setup process const std::string sasProcessNameForGroup = sasProcessGroupName; auto process = Mantid::DataHandling::H5Util::createGroupCanSAS( @@ -401,7 +406,7 @@ void addNoteToProcess(H5::Group &group, const std::string &firstEntryName, } WorkspaceDimensionality -getWorkspaceDimensionality(Mantid::API::MatrixWorkspace_sptr workspace) { +getWorkspaceDimensionality(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto numberOfHistograms = workspace->getNumberHistograms(); WorkspaceDimensionality dimensionality(WorkspaceDimensionality::other); if (numberOfHistograms == 1) { @@ -422,7 +427,8 @@ std::string getIntensityUnitLabel(std::string intensityUnitLabel) { } } -std::string getIntensityUnit(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string +getIntensityUnit(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto iUnit = workspace->YUnit(); if (iUnit.empty()) { iUnit = workspace->YUnitLabel(); @@ -438,13 +444,14 @@ std::string getMomentumTransferLabel(std::string momentumTransferLabel) { } } -std::string -getUnitFromMDDimension(Mantid::Geometry::IMDDimension_const_sptr dimension) { +std::string getUnitFromMDDimension( + const Mantid::Geometry::IMDDimension_const_sptr &dimension) { const auto unitLabel = dimension->getMDUnits().getUnitLabel(); return unitLabel.ascii(); } -void addData1D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { +void addData1D(H5::Group &data, + const Mantid::API::MatrixWorkspace_sptr &workspace) { // Add attributes for @signal, @I_axes, @Q_indices, Mantid::DataHandling::H5Util::writeStrAttribute(data, sasSignal, sasDataI); Mantid::DataHandling::H5Util::writeStrAttribute(data, sasDataIAxesAttr, @@ -512,7 +519,7 @@ void addData1D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { } } -bool areAxesNumeric(Mantid::API::MatrixWorkspace_sptr workspace) { +bool areAxesNumeric(const Mantid::API::MatrixWorkspace_sptr &workspace) { const unsigned indices[] = {0, 1}; for (const auto index : indices) { auto axis = workspace->getAxis(index); @@ -527,12 +534,12 @@ class SpectrumAxisValueProvider { public: explicit SpectrumAxisValueProvider( Mantid::API::MatrixWorkspace_sptr workspace) - : m_workspace(workspace) { + : m_workspace(std::move(workspace)) { setSpectrumAxisValues(); } Mantid::MantidVec::value_type * - operator()(Mantid::API::MatrixWorkspace_sptr /*unused*/, int index) { + operator()(const Mantid::API::MatrixWorkspace_sptr & /*unused*/, int index) { auto isPointData = m_workspace->getNumberHistograms() == m_spectrumAxisValues.size(); double value = 0; @@ -566,7 +573,7 @@ private: */ template <typename T> class QxExtractor { public: - T *operator()(Mantid::API::MatrixWorkspace_sptr ws, int index) { + T *operator()(const Mantid::API::MatrixWorkspace_sptr &ws, int index) { if (ws->isHistogramData()) { qxPointData.clear(); Mantid::Kernel::VectorHelper::convertToBinCentre(ws->dataX(index), @@ -620,7 +627,8 @@ public: * . * QxN QxN ... QxN */ -void addData2D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { +void addData2D(H5::Group &data, + const Mantid::API::MatrixWorkspace_sptr &workspace) { if (!areAxesNumeric(workspace)) { std::invalid_argument("SaveNXcanSAS: The provided 2D workspace needs " "to have 2 numeric axes."); @@ -664,7 +672,7 @@ void addData2D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { iAttributes.emplace(sasUncertaintyAttr, sasDataIdev); iAttributes.emplace(sasUncertaintiesAttr, sasDataIdev); - auto iExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, int index) { + auto iExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, int index) { return ws->dataY(index).data(); }; write2DWorkspace(data, workspace, sasDataI, iExtractor, iAttributes); @@ -674,13 +682,13 @@ void addData2D(H5::Group &data, Mantid::API::MatrixWorkspace_sptr workspace) { eAttributes.insert( std::make_pair(sasUnitAttr, iUnit)); // same units as intensity - auto iDevExtractor = [](Mantid::API::MatrixWorkspace_sptr ws, int index) { - return ws->dataE(index).data(); - }; + auto iDevExtractor = [](const Mantid::API::MatrixWorkspace_sptr &ws, + int index) { return ws->dataE(index).data(); }; write2DWorkspace(data, workspace, sasDataIdev, iDevExtractor, eAttributes); } -void addData(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { +void addData(H5::Group &group, + const Mantid::API::MatrixWorkspace_sptr &workspace) { const std::string sasDataName = sasDataGroupName; auto data = Mantid::DataHandling::H5Util::createGroupCanSAS( group, sasDataName, nxDataClassAttr, sasDataClassAttr); @@ -701,8 +709,8 @@ void addData(H5::Group &group, Mantid::API::MatrixWorkspace_sptr workspace) { //------- SAStransmission_spectrum void addTransmission(H5::Group &group, - Mantid::API::MatrixWorkspace_const_sptr workspace, - std::string transmissionName) { + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + const std::string &transmissionName) { // Setup process const std::string sasTransmissionName = sasTransmissionSpectrumGroupName + "_" + transmissionName; @@ -856,8 +864,9 @@ std::map<std::string, std::string> SaveNXcanSAS::validateInputs() { Mantid::API::MatrixWorkspace_sptr transmissionCan = getProperty("TransmissionCan"); - auto checkTransmission = [&result](Mantid::API::MatrixWorkspace_sptr trans, - std::string propertyName) { + auto checkTransmission = [&result]( + const Mantid::API::MatrixWorkspace_sptr &trans, + const std::string &propertyName) { if (trans->getNumberHistograms() != 1) { result.emplace(propertyName, "The input workspaces for transmissions have to be 1D."); diff --git a/Framework/DataHandling/src/SaveNexusProcessed.cpp b/Framework/DataHandling/src/SaveNexusProcessed.cpp index 4e51d730bfac3d942152df0ba9e7bc8c55669631..d3f73902802631589e0b5ae833ee7f6a24010ed4 100644 --- a/Framework/DataHandling/src/SaveNexusProcessed.cpp +++ b/Framework/DataHandling/src/SaveNexusProcessed.cpp @@ -21,6 +21,7 @@ #include "MantidKernel/BoundedValidator.h" #include "MantidNexus/NexusFileIO.h" #include <boost/shared_ptr.hpp> +#include <utility> using namespace Mantid::API; @@ -168,7 +169,8 @@ void SaveNexusProcessed::init() { * @param matrixWorkspace :: pointer to a MatrixWorkspace */ void SaveNexusProcessed::getWSIndexList( - std::vector<int> &indices, MatrixWorkspace_const_sptr matrixWorkspace) { + std::vector<int> &indices, + const MatrixWorkspace_const_sptr &matrixWorkspace) { const std::vector<int> spec_list = getProperty("WorkspaceIndexList"); int spec_min = getProperty("WorkspaceIndexMin"); int spec_max = getProperty("WorkspaceIndexMax"); @@ -217,7 +219,7 @@ void SaveNexusProcessed::getWSIndexList( } void SaveNexusProcessed::doExec( - Workspace_sptr inputWorkspace, + const Workspace_sptr &inputWorkspace, boost::shared_ptr<Mantid::NeXus::NexusFileIO> &nexusFile, const bool keepFile, optional_size_t entryNumber) { // TODO: Remove? @@ -291,7 +293,8 @@ void SaveNexusProcessed::doExec( const bool append_to_file = getProperty("Append"); nexusFile->resetProgress(&prog_init); - nexusFile->openNexusWrite(filename, entryNumber, append_to_file || keepFile); + nexusFile->openNexusWrite(filename, std::move(entryNumber), + append_to_file || keepFile); // Equivalent C++ API handle ::NeXus::File cppFile(nexusFile->fileID); diff --git a/Framework/DataHandling/src/SavePDFGui.cpp b/Framework/DataHandling/src/SavePDFGui.cpp index bf84bd4dab1e1ef1319726a283e81a6133c88253..019c3242ffa8dc9f262b1e2dd58a37a95bc070c2 100644 --- a/Framework/DataHandling/src/SavePDFGui.cpp +++ b/Framework/DataHandling/src/SavePDFGui.cpp @@ -92,7 +92,7 @@ void SavePDFGui::exec() { } void SavePDFGui::writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { out << "#Comment: neutron"; auto run = inputWS->run(); if (run.hasProperty("Qmin")) { @@ -120,7 +120,7 @@ void SavePDFGui::writeMetaData(std::ofstream &out, } void SavePDFGui::writeWSData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { + const API::MatrixWorkspace_const_sptr &inputWS) { const auto &x = inputWS->points(0); const auto &y = inputWS->y(0); const auto &dy = inputWS->e(0); diff --git a/Framework/DataHandling/src/SaveRMCProfile.cpp b/Framework/DataHandling/src/SaveRMCProfile.cpp index 70ca4d7f5e7d64cf5ebb674f213ef8f94e7f7476..5d545763d6efba2b2bc8cbd369f1218c72ba88ab 100644 --- a/Framework/DataHandling/src/SaveRMCProfile.cpp +++ b/Framework/DataHandling/src/SaveRMCProfile.cpp @@ -96,8 +96,8 @@ void SaveRMCProfile::exec() { out.close(); } -void SaveRMCProfile::writeMetaData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { +void SaveRMCProfile::writeMetaData( + std::ofstream &out, const API::MatrixWorkspace_const_sptr &inputWS) { const auto &y = inputWS->y(0); const std::string title = getProperty("Title"); const std::string inputType = getProperty("InputType"); @@ -107,8 +107,8 @@ void SaveRMCProfile::writeMetaData(std::ofstream &out, std::cout << "rmc " << inputType << " # " << title << std::endl; } -void SaveRMCProfile::writeWSData(std::ofstream &out, - API::MatrixWorkspace_const_sptr inputWS) { +void SaveRMCProfile::writeWSData( + std::ofstream &out, const API::MatrixWorkspace_const_sptr &inputWS) { const auto &x = inputWS->points(0); const auto &y = inputWS->y(0); for (size_t i = 0; i < x.size(); ++i) { diff --git a/Framework/DataHandling/src/SaveReflectometryAscii.cpp b/Framework/DataHandling/src/SaveReflectometryAscii.cpp index 46d5f045216381738934ed54f8b795a8cb9d2c5c..c87a19371d4ca200c562e01bb42d99e84e55e7a2 100644 --- a/Framework/DataHandling/src/SaveReflectometryAscii.cpp +++ b/Framework/DataHandling/src/SaveReflectometryAscii.cpp @@ -141,7 +141,7 @@ void SaveReflectometryAscii::separator() { * @param write :: if true, write string * @param s :: string */ -bool SaveReflectometryAscii::writeString(bool write, std::string s) { +bool SaveReflectometryAscii::writeString(bool write, const std::string &s) { if (write) { if (m_ext == "custom" || m_ext == ".txt") m_file << m_sep << s; @@ -172,7 +172,7 @@ void SaveReflectometryAscii::outputval(double val) { /** Write formatted line of data * @param val :: a string value to be written */ -void SaveReflectometryAscii::outputval(std::string val) { +void SaveReflectometryAscii::outputval(const std::string &val) { m_file << std::setw(28) << val; } @@ -201,8 +201,8 @@ std::string SaveReflectometryAscii::sampleLogUnit(const std::string &logName) { * @param logName :: the name of a SampleLog entry to get its value from * @param logNameFixed :: the name of the SampleLog entry defined by the header */ -void SaveReflectometryAscii::writeInfo(const std::string logName, - const std::string logNameFixed) { +void SaveReflectometryAscii::writeInfo(const std::string &logName, + const std::string &logNameFixed) { const std::string logValue = sampleLogValue(logName); const std::string logUnit = sampleLogUnit(logName); if (!logNameFixed.empty()) { @@ -255,7 +255,7 @@ void SaveReflectometryAscii::header() { } /// Check file -void SaveReflectometryAscii::checkFile(const std::string filename) { +void SaveReflectometryAscii::checkFile(const std::string &filename) { if (Poco::File(filename).exists()) { g_log.warning("File already exists and will be overwritten"); try { diff --git a/Framework/DataHandling/src/SaveSPE.cpp b/Framework/DataHandling/src/SaveSPE.cpp index f0641f9f0c6a0739ace24dc6adfa2b4ad137219b..9c18c1f701d28feebe03d0209ed6866fc45ef9ec 100644 --- a/Framework/DataHandling/src/SaveSPE.cpp +++ b/Framework/DataHandling/src/SaveSPE.cpp @@ -210,7 +210,7 @@ void SaveSPE::writeSPEFile(FILE *outSPEFile, * @param WS :: the workspace to be saved * @param outFile :: the file object to write to */ -void SaveSPE::writeHists(const API::MatrixWorkspace_const_sptr WS, +void SaveSPE::writeHists(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile) { // We write out values NUM_PER_LINE at a time, so will need to do extra work // if nBins isn't a factor of NUM_PER_LINE @@ -286,7 +286,7 @@ void SaveSPE::check_and_copy_spectra(const HistogramData::HistogramY &inSignal, * @param outFile :: the file object to write to * @param wsIn :: the index number of the histogram to write */ -void SaveSPE::writeHist(const API::MatrixWorkspace_const_sptr WS, +void SaveSPE::writeHist(const API::MatrixWorkspace_const_sptr &WS, FILE *const outFile, const int wsIn) const { check_and_copy_spectra(WS->y(wsIn), WS->e(wsIn), m_tSignal, m_tError); FPRINTF_WITH_EXCEPTION(outFile, "%s", Y_HEADER); diff --git a/Framework/DataHandling/src/SaveTBL.cpp b/Framework/DataHandling/src/SaveTBL.cpp index 4eff4fdf561021d1755af52a0b7a1816fbd26dfe..bc27ecab0d18a8965ce016bfb6fec9bfb9951cdb 100644 --- a/Framework/DataHandling/src/SaveTBL.cpp +++ b/Framework/DataHandling/src/SaveTBL.cpp @@ -44,7 +44,7 @@ void SaveTBL::init() { * Finds the stitch groups that need to be on the same line * @param ws : a pointer to a tableworkspace */ -void SaveTBL::findGroups(ITableWorkspace_sptr ws) { +void SaveTBL::findGroups(const ITableWorkspace_sptr &ws) { size_t rowCount = ws->rowCount(); for (size_t i = 0; i < rowCount; ++i) { TableRow row = ws->getRow(i); diff --git a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp index 40200da9b2c12eb83d25749d11351492976b54a7..1543210a0ef79414636258d77c1b395b370cc0f4 100644 --- a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp +++ b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp @@ -187,9 +187,9 @@ int SaveToSNSHistogramNexus::copy_file(const char *inFile, int nx__access, * @return error code */ int SaveToSNSHistogramNexus::WriteOutDataOrErrors( - Geometry::RectangularDetector_const_sptr det, int x_pixel_slab, + const Geometry::RectangularDetector_const_sptr &det, int x_pixel_slab, const char *field_name, const char *errors_field_name, bool doErrors, - bool doBoth, int is_definition, std::string bank) { + bool doBoth, int is_definition, const std::string &bank) { int dataRank, dataDimensions[NX_MAXRANK]; int slabDimensions[NX_MAXRANK], slabStartIndices[NX_MAXRANK]; @@ -412,7 +412,7 @@ int SaveToSNSHistogramNexus::WriteOutDataOrErrors( * @param is_definition * @return error code */ -int SaveToSNSHistogramNexus::WriteDataGroup(std::string bank, +int SaveToSNSHistogramNexus::WriteDataGroup(const std::string &bank, int is_definition) { int dataType, dataRank, dataDimensions[NX_MAXRANK]; NXname name; diff --git a/Framework/DataHandling/src/SetScalingPSD.cpp b/Framework/DataHandling/src/SetScalingPSD.cpp index af5f8c78c625824806eb0aa7b970fa776170da28..c0c85e120cb29a4ee79faac5d93adca13cf915b0 100644 --- a/Framework/DataHandling/src/SetScalingPSD.cpp +++ b/Framework/DataHandling/src/SetScalingPSD.cpp @@ -293,7 +293,7 @@ void SetScalingPSD::movePos(API::MatrixWorkspace_sptr &WS, * @param detID :: Vector of detector numbers * @param pos :: V3D of detector positions corresponding to detID */ -void SetScalingPSD::getDetPositionsFromRaw(std::string rawfile, +void SetScalingPSD::getDetPositionsFromRaw(const std::string &rawfile, std::vector<int> &detID, std::vector<Kernel::V3D> &pos) { (void)rawfile; // Avoid compiler warning diff --git a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp index a3a7281afcda34eb46217c796c5f731dac9ab840..02254b4f3e8210f30f7e9968358990bc2f53b198 100644 --- a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp +++ b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp @@ -24,8 +24,8 @@ namespace DataHandling { enum class NexusType { Muon, Processed, ISIS, TofRaw }; enum class TimeType : unsigned char { StartTime, EndTime }; -Mantid::Types::Core::DateAndTime handleMuonNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +handleMuonNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime(root.getString("run/start_time")); @@ -35,7 +35,7 @@ Mantid::Types::Core::DateAndTime handleMuonNexusFile(TimeType type, } Mantid::Types::Core::DateAndTime -handleProcessedNexusFile(TimeType type, std::string filename) { +handleProcessedNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime( @@ -46,8 +46,8 @@ handleProcessedNexusFile(TimeType type, std::string filename) { } } -Mantid::Types::Core::DateAndTime handleISISNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +handleISISNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime( @@ -58,8 +58,8 @@ Mantid::Types::Core::DateAndTime handleISISNexusFile(TimeType type, } } -Mantid::Types::Core::DateAndTime handleTofRawNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +handleTofRawNexusFile(TimeType type, const std::string &filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { return Mantid::Types::Core::DateAndTime(root.getString("entry/start_time")); @@ -68,7 +68,7 @@ Mantid::Types::Core::DateAndTime handleTofRawNexusFile(TimeType type, } } -NexusType whichNexusType(std::string filename) { +NexusType whichNexusType(const std::string &filename) { std::vector<std::string> entryName; std::vector<std::string> definition; auto count = @@ -112,8 +112,8 @@ NexusType whichNexusType(std::string filename) { return nexusType; } -Mantid::Types::Core::DateAndTime extractDateAndTime(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime +extractDateAndTime(TimeType type, const std::string &filename) { auto fullFileName = Mantid::API::FileFinder::Instance().getFullPath(filename); // Figure out the type of the Nexus file. We need to handle them individually // since they store the datetime differently diff --git a/Framework/DataHandling/src/XmlHandler.cpp b/Framework/DataHandling/src/XmlHandler.cpp index 43346b9174de10f83b21e427faf4857cfea707e0..4c4c2ae194e54dab1ae1ee4fd2e4582ebd098d2e 100644 --- a/Framework/DataHandling/src/XmlHandler.cpp +++ b/Framework/DataHandling/src/XmlHandler.cpp @@ -23,7 +23,7 @@ namespace Mantid { namespace DataHandling { -XmlHandler::XmlHandler(std::string filename) { +XmlHandler::XmlHandler(const std::string &filename) { std::ifstream in(filename); Poco::XML::InputSource src(in); Poco::XML::DOMParser parser; diff --git a/Framework/DataHandling/test/CheckMantidVersionTest.h b/Framework/DataHandling/test/CheckMantidVersionTest.h index fe257da737d67ac0675d1454bdb1ad72186774a9..085fa054352d2e26ba6dbb02a2a6bc147facf70b 100644 --- a/Framework/DataHandling/test/CheckMantidVersionTest.h +++ b/Framework/DataHandling/test/CheckMantidVersionTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidDataHandling/CheckMantidVersion.h" using Mantid::DataHandling::CheckMantidVersion; @@ -21,8 +23,8 @@ class MockedCheckMantidVersion : public CheckMantidVersion { public: MockedCheckMantidVersion(std::string currentVersion, std::string gitHubVersion) - : CheckMantidVersion(), CurrentVersion(currentVersion), - GitHubVersion(gitHubVersion) {} + : CheckMantidVersion(), CurrentVersion(std::move(currentVersion)), + GitHubVersion(std::move(gitHubVersion)) {} std::string CurrentVersion; std::string GitHubVersion; @@ -117,8 +119,7 @@ public: std::string currentVersion = alg.PropertyManagerOwner::getProperty("CurrentVersion"); - std::string mostRecentVersion = - alg.PropertyManagerOwner::getProperty("MostRecentVersion"); + alg.PropertyManagerOwner::getProperty("MostRecentVersion"); bool isNewVersionAvailable = alg.PropertyManagerOwner::getProperty("IsNewVersionAvailable"); diff --git a/Framework/DataHandling/test/CompressEventsTest.h b/Framework/DataHandling/test/CompressEventsTest.h index 8132d6f914e9456b35d9d79e9950e677b457f522..4d5ce1d84e74e3087d627902b1cdeb27b043c8e3 100644 --- a/Framework/DataHandling/test/CompressEventsTest.h +++ b/Framework/DataHandling/test/CompressEventsTest.h @@ -37,8 +37,9 @@ public: TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Tolerance", "0.0")); } - void doTest(std::string inputName, std::string outputName, double tolerance, - int numPixels = 50, double wallClockTolerance = 0.) { + void doTest(const std::string &inputName, const std::string &outputName, + double tolerance, int numPixels = 50, + double wallClockTolerance = 0.) { EventWorkspace_sptr input, output; EventType eventType = WEIGHTED_NOTIME; if (wallClockTolerance > 0.) diff --git a/Framework/DataHandling/test/CreateSampleShapeTest.h b/Framework/DataHandling/test/CreateSampleShapeTest.h index 0c3b29677ca4a3bc658892291b494e406f4f67d2..96d71c38a39838cdaa32874a977aae9d5feb9cad 100644 --- a/Framework/DataHandling/test/CreateSampleShapeTest.h +++ b/Framework/DataHandling/test/CreateSampleShapeTest.h @@ -83,8 +83,8 @@ public: TS_ASSERT_DELTA(2.6989, material.numberDensity(), 1e-04); } - void runStandardTest(std::string xmlShape, double x, double y, double z, - bool inside) { + void runStandardTest(const std::string &xmlShape, double x, double y, + double z, bool inside) { // Need a test workspace Mantid::API::AnalysisDataService::Instance().add( "TestWorkspace", diff --git a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h index 6ed9df97dd63605c455fa568fb4813f3aca3e483..f523688c52b2171b21b7ec27a477c532d326032e 100644 --- a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h +++ b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h @@ -178,7 +178,7 @@ private: .retrieveWS<MatrixWorkspace>(m_wsName); } - void doBinCheck(Mantid::API::MatrixWorkspace_sptr outputWS, + void doBinCheck(const Mantid::API::MatrixWorkspace_sptr &outputWS, const size_t expectedSize) { TS_ASSERT_EQUALS(outputWS->readX(0).size(), expectedSize); // Check bins are correct @@ -189,7 +189,7 @@ private: } } - void doInstrumentCheck(Mantid::API::MatrixWorkspace_sptr outputWS, + void doInstrumentCheck(const Mantid::API::MatrixWorkspace_sptr &outputWS, const std::string &name, const size_t ndets) { Mantid::Geometry::Instrument_const_sptr instr = outputWS->getInstrument(); @@ -208,7 +208,7 @@ private: } void compareSimulationWorkspaceIDFWithFileIDF( - Mantid::API::MatrixWorkspace_sptr simulationWorkspace, + const Mantid::API::MatrixWorkspace_sptr &simulationWorkspace, const std::string &filename, const std::string &algorithmName) { std::string outputWSName = "outWSIDFCompareNexus"; auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( @@ -235,10 +235,6 @@ private: class CreateSimulationWorkspaceTestPerformance : public CxxTest::TestSuite { public: void setUp() override { - - // Starting bin, bin width, last bin - const std::string binParams("-30,3,279"); - alg.initialize(); alg.setPropertyValue("Instrument", "HET"); diff --git a/Framework/DataHandling/test/DataBlockGeneratorTest.h b/Framework/DataHandling/test/DataBlockGeneratorTest.h index c450c1ed9f7581125b91eca1fd2c70c2361c497e..8abd5cb4dc21feab966cb7d3c0acf288978542d2 100644 --- a/Framework/DataHandling/test/DataBlockGeneratorTest.h +++ b/Framework/DataHandling/test/DataBlockGeneratorTest.h @@ -96,8 +96,9 @@ public: } private: - void do_test_interval(std::vector<std::pair<int64_t, int64_t>> interval, - std::vector<int64_t> expectedOutput) { + void + do_test_interval(const std::vector<std::pair<int64_t, int64_t>> &interval, + std::vector<int64_t> expectedOutput) { Mantid::DataHandling::DataBlockGenerator generator(interval); TSM_ASSERT("Should be done", !generator.isDone()); diff --git a/Framework/DataHandling/test/DownloadFileTest.h b/Framework/DataHandling/test/DownloadFileTest.h index 10dca14ca826d41795ea13fa45a2ca3f094ec0fa..e86c96762ec53b9328f52c5e08cac926a39b24f9 100644 --- a/Framework/DataHandling/test/DownloadFileTest.h +++ b/Framework/DataHandling/test/DownloadFileTest.h @@ -73,8 +73,8 @@ public: exec_alg(url, tmpFile.path(), "http://" + url); } - void exec_alg(std::string address, std::string filename, - std::string newAddress = "") { + void exec_alg(const std::string &address, const std::string &filename, + const std::string &newAddress = "") { MockedDownloadFile alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/DownloadInstrumentTest.h b/Framework/DataHandling/test/DownloadInstrumentTest.h index 25258805ac2646346e7bc15785a2429c6a89b2b6..5572bb93725bf144bf11f86c3c9f5e6edcd24a70 100644 --- a/Framework/DataHandling/test/DownloadInstrumentTest.h +++ b/Framework/DataHandling/test/DownloadInstrumentTest.h @@ -105,7 +105,7 @@ public: } static void destroySuite(DownloadInstrumentTest *suite) { delete suite; } - void createDirectory(Poco::Path path) { + void createDirectory(const Poco::Path &path) { Poco::File file(path); if (file.createDirectory()) { m_directoriesToRemove.emplace_back(file); @@ -190,9 +190,6 @@ public: } int runDownloadInstrument() { - // Name of the output workspace. - std::string outWSName("DownloadInstrumentTest_OutputWS"); - MockedDownloadInstrument alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h b/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h index c3b35941369342675c4266fb5b204e4a2cedf6aa..520f80cc285848289c8c6511ef3c720c40f2a008 100644 --- a/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h +++ b/Framework/DataHandling/test/ExtractMonitorWorkspaceTest.h @@ -45,7 +45,8 @@ public: TS_ASSERT(!alg.isExecuted()); } - void doTest(MatrixWorkspace_sptr inws, MatrixWorkspace_sptr monws) { + void doTest(const MatrixWorkspace_sptr &inws, + const MatrixWorkspace_sptr &monws) { inws->setMonitorWorkspace(monws); TS_ASSERT_EQUALS(inws->monitorWorkspace(), monws); diff --git a/Framework/DataHandling/test/FindDetectorsInShapeTest.h b/Framework/DataHandling/test/FindDetectorsInShapeTest.h index 43386547f82c0db77a1053bfa9c1818e101e8494..0ff8b16016839ea982196c523e4df1e3bd65c6d5 100644 --- a/Framework/DataHandling/test/FindDetectorsInShapeTest.h +++ b/Framework/DataHandling/test/FindDetectorsInShapeTest.h @@ -117,7 +117,7 @@ public: runTest(xmlShape, "320,340,360,380", false); } - void runTest(std::string xmlShape, std::string expectedHits, + void runTest(const std::string &xmlShape, std::string expectedHits, bool includeMonitors = true) { Mantid::DataHandling::FindDetectorsInShape alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); diff --git a/Framework/DataHandling/test/GroupDetectors2Test.h b/Framework/DataHandling/test/GroupDetectors2Test.h index 9143e2e5ee809b4771204fba0c4d14818ecafd8d..d97897e4d44842fea9cf599b2341a8f754ef4513 100644 --- a/Framework/DataHandling/test/GroupDetectors2Test.h +++ b/Framework/DataHandling/test/GroupDetectors2Test.h @@ -560,21 +560,21 @@ public: TS_ASSERT_EQUALS(*specDet, 2); specDet = output2D1->getSpectrum(2).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 3); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 4); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 5); specDet = output2D1->getSpectrum(3).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 2); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 8); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 9); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 11); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 12); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 13); AnalysisDataService::Instance().remove(outputSpace); @@ -631,6 +631,7 @@ public: const auto &y = output->y(0); const auto &e = output->e(0); for (size_t i = 0; i < y.size(); ++i) { + // cppcheck-suppress unreadVariable const double expectedSignal = i == 0 ? 2. : (1. + 2.) / 2.; TS_ASSERT_EQUALS(y[i], expectedSignal) const double expectedError = i == 0 ? 1. : std::sqrt(2.) / 2.; @@ -659,6 +660,7 @@ public: const auto &y = output->y(0); const auto &e = output->e(0); for (size_t i = 0; i < y.size(); ++i) { + // cppcheck-suppress unreadVariable const double expectedSignal = i == 0 ? 2. : 1. + 2.; TS_ASSERT_EQUALS(y[i], expectedSignal) const double expectedError = i == 0 ? 1. : std::sqrt(2.); @@ -1122,7 +1124,7 @@ private: } Instrument_sptr instr(new Instrument); - for (detid_t i = 0; i < NHIST; i++) { + for (detid_t i = 0; i < NHIST; ++i) { Detector *d = new Detector("det", i, nullptr); d->setPos(1. + static_cast<double>(i) * 0.1, 0., 1.); instr->add(d); diff --git a/Framework/DataHandling/test/GroupDetectorsTest.h b/Framework/DataHandling/test/GroupDetectorsTest.h index 62d438f6607989152363c80844871759627d1f22..47ff0be4fca32510e463c54c48adf788896180c0 100644 --- a/Framework/DataHandling/test/GroupDetectorsTest.h +++ b/Framework/DataHandling/test/GroupDetectorsTest.h @@ -52,7 +52,7 @@ public: space2D->getSpectrum(j).setDetectorID(j); } Instrument_sptr instr(new Instrument); - for (detid_t i = 0; i < 5; i++) { + for (detid_t i = 0; i < 5; ++i) { Detector *d = new Detector("det", i, nullptr); instr->add(d); instr->markAsDetector(d); diff --git a/Framework/DataHandling/test/InstrumentRayTracerTest.h b/Framework/DataHandling/test/InstrumentRayTracerTest.h index 563241b26f2576f2501226946475c86e5f913106..7ec49b9084a3838c01638a9bc69bd99555c39016 100644 --- a/Framework/DataHandling/test/InstrumentRayTracerTest.h +++ b/Framework/DataHandling/test/InstrumentRayTracerTest.h @@ -98,9 +98,9 @@ public: } private: - void showResults(Links &results, Instrument_const_sptr inst) { + void showResults(Links &results, const Instrument_const_sptr &inst) { Links::const_iterator resultItr = results.begin(); - for (; resultItr != results.end(); resultItr++) { + for (; resultItr != results.end(); ++resultItr) { IComponent_const_sptr component = inst->getComponentByID(resultItr->componentID); std::cout << component->getName() << ", "; diff --git a/Framework/DataHandling/test/LoadAscii2Test.h b/Framework/DataHandling/test/LoadAscii2Test.h index 12d510c2a88baa134150aeb145c01d4653859116..85b348f697c9e0ebe4ea73992857223e578db3ff 100644 --- a/Framework/DataHandling/test/LoadAscii2Test.h +++ b/Framework/DataHandling/test/LoadAscii2Test.h @@ -434,7 +434,7 @@ private: return save.getPropertyValue("Filename"); } - void checkTableData(const Mantid::API::ITableWorkspace_sptr outputWS) { + void checkTableData(const Mantid::API::ITableWorkspace_sptr &outputWS) { const std::string name = "Compare_SaveAsciiWS"; auto wsToCompare = SaveAscii2Test::writeTableWS(name); @@ -590,7 +590,7 @@ private: return outputWS; } - void checkData(const Mantid::API::MatrixWorkspace_sptr outputWS, + void checkData(const Mantid::API::MatrixWorkspace_sptr &outputWS, const int cols) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 5); TS_ASSERT_EQUALS(outputWS->blocksize(), 4); diff --git a/Framework/DataHandling/test/LoadAsciiStlTest.h b/Framework/DataHandling/test/LoadAsciiStlTest.h index 57ebd4ec3fc8057a9b30ff78583f44a50cb84e0b..f07ca0e9dc976b26043fd8f02bad866768f6a57f 100644 --- a/Framework/DataHandling/test/LoadAsciiStlTest.h +++ b/Framework/DataHandling/test/LoadAsciiStlTest.h @@ -53,7 +53,7 @@ public: loadFailureTest("invalid_triangle.stl"); } - void loadFailureTest(const std::string filename) { + void loadFailureTest(const std::string &filename) { std::string path = FileFinder::Instance().getFullPath(filename); auto Loader = LoadAsciiStl(path, units); TS_ASSERT_THROWS_ANYTHING(Loader.readStl()); diff --git a/Framework/DataHandling/test/LoadAsciiTest.h b/Framework/DataHandling/test/LoadAsciiTest.h index f970361193ae41865c454bdc4794d1f5fef804f0..efacceca2097553fdfc39f109c69d6ec627c3b82 100644 --- a/Framework/DataHandling/test/LoadAsciiTest.h +++ b/Framework/DataHandling/test/LoadAsciiTest.h @@ -275,7 +275,7 @@ private: return outputWS; } - void checkData(const Mantid::API::MatrixWorkspace_sptr outputWS, + void checkData(const Mantid::API::MatrixWorkspace_sptr &outputWS, const bool threeColumn) { if (threeColumn) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1); diff --git a/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h b/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h index e39ea1170adb1abed722e26c05ae322dd16f45c6..3ec153753df288da1f1ad1051877395e237c40e9 100644 --- a/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h +++ b/Framework/DataHandling/test/LoadDetectorsGroupingFileTest.h @@ -124,7 +124,7 @@ public: API::AnalysisDataService::Instance().remove(ws); } - ScopedFile generateAutoGroupIDGroupXMLFile(std::string xmlfilename) { + ScopedFile generateAutoGroupIDGroupXMLFile(const std::string &xmlfilename) { std::ostringstream os; os << "<?xml version=\"1.0\"?>\n"; @@ -173,7 +173,7 @@ public: API::AnalysisDataService::Instance().remove(ws); } - ScopedFile generateSpectrumIDXMLFile(std::string xmlfilename) { + ScopedFile generateSpectrumIDXMLFile(const std::string &xmlfilename) { std::ostringstream os; os << "<?xml version=\"1.0\"?>\n"; @@ -222,7 +222,7 @@ public: API::AnalysisDataService::Instance().remove(ws); } - ScopedFile generateOldSpectrumIDXMLFile(std::string xmlfilename) { + ScopedFile generateOldSpectrumIDXMLFile(const std::string &xmlfilename) { std::ostringstream os; os << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; diff --git a/Framework/DataHandling/test/LoadDspacemapTest.h b/Framework/DataHandling/test/LoadDspacemapTest.h index 7af2fc113de04340e09228f352af08a0039301ff..c6b72d53cd1540c8eff1463efb9a7dcb3408bad3 100644 --- a/Framework/DataHandling/test/LoadDspacemapTest.h +++ b/Framework/DataHandling/test/LoadDspacemapTest.h @@ -58,9 +58,8 @@ public: TS_ASSERT_DELTA(offsetsWS->dataY(0)[0], -0.6162, 0.0001); } - void doTestVulcan(std::string dspaceFile, std::string fileType) { - std::string outputFile = "./VULCAN_dspacemaptocal_test.cal"; - + void doTestVulcan(const std::string &dspaceFile, + const std::string &fileType) { LoadDspacemap testerDSP; TS_ASSERT_THROWS_NOTHING(testerDSP.initialize()); TS_ASSERT_THROWS_NOTHING(testerDSP.isInitialized()); diff --git a/Framework/DataHandling/test/LoadEMUauTest.h b/Framework/DataHandling/test/LoadEMUauTest.h index 29a0ca3a9d53c24e66a9bc4605bd96cf363ef8d4..53e348f516e74d0a2b898aa52edb2df77406e11f 100644 --- a/Framework/DataHandling/test/LoadEMUauTest.h +++ b/Framework/DataHandling/test/LoadEMUauTest.h @@ -82,7 +82,7 @@ public: run.getProperty("end_time")->value().find("2018-07-26T10:17:12.6") == 0) // test some data properties - auto logpm = [&run](std::string tag) { + auto logpm = [&run](const std::string &tag) { return dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty(tag)) ->firstValue(); }; @@ -91,7 +91,7 @@ public: // test some instrument parameters auto instr = output->getInstrument(); - auto iparam = [&instr](std::string tag) { + auto iparam = [&instr](const std::string &tag) { return instr->getNumberParameter(tag)[0]; }; TS_ASSERT_DELTA(iparam("AnalysedV2"), 630.866, 1.0e-3); diff --git a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h index 95f12043a6c82b64ee4a392df90169b9be3e12ea..fa8b7b2b450e96d90a0f8e1cbe656693ddc21764 100644 --- a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h +++ b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h @@ -38,7 +38,7 @@ public: static void destroySuite(LoadEmptyInstrumentTest *suite) { delete suite; } /// Helper that checks that each spectrum has one detector - void check_workspace_detectors(MatrixWorkspace_sptr output, + void check_workspace_detectors(const MatrixWorkspace_sptr &output, size_t numberDetectors) { TS_ASSERT_EQUALS(output->getNumberHistograms(), numberDetectors); for (size_t i = 0; i < output->getNumberHistograms(); i++) { diff --git a/Framework/DataHandling/test/LoadEventNexusTest.h b/Framework/DataHandling/test/LoadEventNexusTest.h index bfdd472c443c56e43c4af128065833e991b8b1ba..893761b6f34538fa96195443ce94400b123a2192 100644 --- a/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Framework/DataHandling/test/LoadEventNexusTest.h @@ -106,7 +106,7 @@ load_reference_workspace(const std::string &filename) { return boost::dynamic_pointer_cast<const EventWorkspace>(out); } void run_MPI_load(const Parallel::Communicator &comm, - boost::shared_ptr<std::mutex> mutex, + const boost::shared_ptr<std::mutex> &mutex, const std::string &filename) { boost::shared_ptr<const EventWorkspace> reference; boost::shared_ptr<const EventWorkspace> eventWS; @@ -736,7 +736,7 @@ public: } void doTestSingleBank(bool SingleBankPixelsOnly, bool Precount, - std::string BankName = "bank36", + const std::string &BankName = "bank36", bool willFail = false) { Mantid::API::FrameworkManager::Instance(); LoadEventNexus ld; diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index b2c80def986a4e603f7d8fd8c02964cddec39e85..795fe4a2878e38d2e7a738cc8e1bd38cebb85c33 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -69,7 +69,7 @@ public: TS_ASSERT_EQUALS(sizeof(DasEvent), 8); } - void checkWorkspace(std::string eventfile, std::string WSName, + void checkWorkspace(const std::string &eventfile, const std::string &WSName, int numpixels_with_events) { // Get the event file size struct stat filestatus; @@ -143,7 +143,7 @@ public: do_test_LoadPreNeXus_CNCS("Parallel"); } - void do_test_LoadPreNeXus_CNCS(std::string parallel) { + void do_test_LoadPreNeXus_CNCS(const std::string ¶llel) { std::string eventfile("CNCS_7860_neutron_event.dat"); eventLoader->setPropertyValue("EventFilename", eventfile); eventLoader->setPropertyValue("MappingFilename", "CNCS_TS_2008_08_18.dat"); diff --git a/Framework/DataHandling/test/LoadFullprofResolutionTest.h b/Framework/DataHandling/test/LoadFullprofResolutionTest.h index 475dc3a427abe7312a9371a8575bcaad3ac40cb0..975766df8d4eb8e165961fb282630fb24d410a89 100644 --- a/Framework/DataHandling/test/LoadFullprofResolutionTest.h +++ b/Framework/DataHandling/test/LoadFullprofResolutionTest.h @@ -747,7 +747,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace to a map */ - void parseTableWorkspace(TableWorkspace_sptr tablews, + void parseTableWorkspace(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -766,7 +766,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace's 2nd bank to a map */ - void parseTableWorkspace2(TableWorkspace_sptr tablews, + void parseTableWorkspace2(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -785,7 +785,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a GEM workspace group with specified number of workspaces. */ - void load_GEM(size_t numberOfWorkspaces, std::string workspaceName) { + void load_GEM(size_t numberOfWorkspaces, const std::string &workspaceName) { LoadInstrument loaderGEM; TS_ASSERT_THROWS_NOTHING(loaderGEM.initialize()); @@ -818,7 +818,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .irf file */ - void generate1BankIrfFile(string filename) { + void generate1BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -879,7 +879,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 2 bank .irf file */ - void generate2BankIrfFile(string filename) { + void generate2BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -977,7 +977,7 @@ public: /** Generate a 3 bank .irf file */ - void generate3BankIrfFile(string filename) { + void generate3BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -1116,7 +1116,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .irf file for BackToBackExponential fitting function */ - void generate1BankIrfBBXFile(string filename) { + void generate1BankIrfBBXFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); diff --git a/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h b/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h index 88434aeb4885b7bfa70d4cfabc8540eda72dcca6..e7e65b5ee5304332d6139900c436e704d673bf5a 100644 --- a/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h +++ b/Framework/DataHandling/test/LoadGSASInstrumentFileTest.h @@ -322,7 +322,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace to a map */ - void parseTableWorkspace(TableWorkspace_sptr tablews, + void parseTableWorkspace(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -341,7 +341,7 @@ public: //---------------------------------------------------------------------------------------------- /** Parse a TableWorkspace's 2nd bank to a map */ - void parseTableWorkspace2(TableWorkspace_sptr tablews, + void parseTableWorkspace2(const TableWorkspace_sptr &tablews, map<string, double> ¶mmap) { parammap.clear(); @@ -360,7 +360,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .prm file */ - void generate1BankPrmFile(string filename) { + void generate1BankPrmFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -402,7 +402,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 2 bank .irf file */ - void generate2BankPrmFile(string filename) { + void generate2BankPrmFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -456,7 +456,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 1 bank .prm file */ - void generateBadHistogramTypePrmFile(string filename) { + void generateBadHistogramTypePrmFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -497,7 +497,7 @@ public: /** Create a workspace group with specified number of workspaces. */ void createWorkspaceGroup(size_t numberOfWorkspaces, - std::string workspaceName) { + const std::string &workspaceName) { // create a workspace with some sample data WorkspaceGroup_sptr gws(new API::WorkspaceGroup); diff --git a/Framework/DataHandling/test/LoadILLDiffractionTest.h b/Framework/DataHandling/test/LoadILLDiffractionTest.h index 4f4c89268a99cb566b00fadec9fb976740e6330b..1f43b32b0c1a26a2f071fff1a27b8871c9cae268 100644 --- a/Framework/DataHandling/test/LoadILLDiffractionTest.h +++ b/Framework/DataHandling/test/LoadILLDiffractionTest.h @@ -325,7 +325,7 @@ public: TS_ASSERT_DELTA(theta, 147.55, 0.001) } - void do_test_D2B_single_file(std::string dataType) { + void do_test_D2B_single_file(const std::string &dataType) { // Test a D2B detector scan file with 25 detector positions const int NUMBER_OF_TUBES = 128; diff --git a/Framework/DataHandling/test/LoadILLReflectometryTest.h b/Framework/DataHandling/test/LoadILLReflectometryTest.h index 1b1265d21baa908d810d4c11e9c47c77ca96c275..e282244fd77ce2e225e7860a0642270d60997648 100644 --- a/Framework/DataHandling/test/LoadILLReflectometryTest.h +++ b/Framework/DataHandling/test/LoadILLReflectometryTest.h @@ -34,7 +34,7 @@ private: // Name of the default output workspace const std::string m_outWSName{"LoadILLReflectometryTest_OutputWS"}; - static void commonProperties(MatrixWorkspace_sptr output, + static void commonProperties(const MatrixWorkspace_sptr &output, const std::string &instrName) { TS_ASSERT(output->isHistogramData()) const auto &spectrumInfo = output->spectrumInfo(); @@ -59,7 +59,7 @@ private: "degree") } - static double detCounts(MatrixWorkspace_sptr output) { + static double detCounts(const MatrixWorkspace_sptr &output) { // sum of detector counts double counts{0.0}; for (size_t i = 0; i < output->getNumberHistograms(); ++i) { @@ -696,10 +696,12 @@ public: auto instrument = output->getInstrument(); auto slit1 = instrument->getComponentByName("slit2"); auto slit2 = instrument->getComponentByName("slit3"); + // cppcheck-suppress unreadVariable const double S2z = -output->run().getPropertyValueAsType<double>("Distance.S2toSample") * 1e-3; TS_ASSERT_EQUALS(slit1->getPos(), V3D(0.0, 0.0, S2z)) + // cppcheck-suppress unreadVariable const double S3z = -output->run().getPropertyValueAsType<double>("Distance.S3toSample") * 1e-3; diff --git a/Framework/DataHandling/test/LoadILLTOF2Test.h b/Framework/DataHandling/test/LoadILLTOF2Test.h index aee5df882ccf3377b57cca4ef458156ed2cd17d9..9a2b9dcd7b92b3528bf7c95fed32dce57d57c414 100644 --- a/Framework/DataHandling/test/LoadILLTOF2Test.h +++ b/Framework/DataHandling/test/LoadILLTOF2Test.h @@ -46,7 +46,7 @@ public: * The elastic peak is obtained on the fly from the sample data. */ MatrixWorkspace_sptr - loadDataFile(const std::string dataFile, const size_t numberOfHistograms, + loadDataFile(const std::string &dataFile, const size_t numberOfHistograms, const size_t numberOfMonitors, const size_t numberOfChannels, const double tofDelay, const double tofChannelWidth) { LoadILLTOF2 loader; diff --git a/Framework/DataHandling/test/LoadILLTest.h b/Framework/DataHandling/test/LoadILLTest.h index cd4ff3f0ddb7dea15927e4521f23659911f67fa7..5a70735944f9894c2c18dddeb99bcaa4a65301e2 100644 --- a/Framework/DataHandling/test/LoadILLTest.h +++ b/Framework/DataHandling/test/LoadILLTest.h @@ -27,7 +27,7 @@ public: void tearDown() override { AnalysisDataService::Instance().clear(); } - void checkLoader(std::string filename, std::string resultLoader) { + void checkLoader(const std::string &filename, std::string resultLoader) { Load alg; alg.setChild(true); alg.initialize(); diff --git a/Framework/DataHandling/test/LoadISISNexusTest.h b/Framework/DataHandling/test/LoadISISNexusTest.h index 83f8223fe7179da79d4542f4dcf5b6ca86f13d92..8179ec60a6eb7a37ff892464fbcf9c79ae8bd158 100644 --- a/Framework/DataHandling/test/LoadISISNexusTest.h +++ b/Framework/DataHandling/test/LoadISISNexusTest.h @@ -27,7 +27,7 @@ using namespace Mantid::DataHandling; class LoadISISNexusTest : public CxxTest::TestSuite { private: // Helper method to fetch the log property entry corresponding to period. - Property *fetchPeriodLog(MatrixWorkspace_sptr workspace, + Property *fetchPeriodLog(const MatrixWorkspace_sptr &workspace, int expectedPeriodNumber) { std::stringstream period_number_stream; period_number_stream << expectedPeriodNumber; @@ -38,14 +38,14 @@ private: // Helper method to fetch the log property entry corresponding to the current // period. - Property *fetchCurrentPeriodLog(MatrixWorkspace_sptr workspace) { + Property *fetchCurrentPeriodLog(const MatrixWorkspace_sptr &workspace) { Property *p = workspace->run().getLogData("current_period"); return p; } // Helper method to check that the log data contains a specific period number // entry. - void checkPeriodLogData(MatrixWorkspace_sptr workspace, + void checkPeriodLogData(const MatrixWorkspace_sptr &workspace, int expectedPeriodNumber) { Property *p = nullptr; TS_ASSERT_THROWS_NOTHING( diff --git a/Framework/DataHandling/test/LoadInstrumentTest.h b/Framework/DataHandling/test/LoadInstrumentTest.h index 4278629f6e06559dd5b7b6b074fdaf3b13f6da8c..8dd42e1c98a50c6f5b618d607fca1fa1d483eb77 100644 --- a/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Framework/DataHandling/test/LoadInstrumentTest.h @@ -418,7 +418,7 @@ public: } /// Common initialisation for Nexus loading tests - MatrixWorkspace_sptr doLoadNexus(const std::string filename) { + MatrixWorkspace_sptr doLoadNexus(const std::string &filename) { LoadInstrument nexusLoader; nexusLoader.initialize(); nexusLoader.setChild(true); @@ -860,9 +860,9 @@ private: // @param paramFilename Expected parameter file to be loaded as part of // LoadInstrument // @param par A specific parameter to check if have been loaded - void doTestParameterFileSelection(std::string filename, - std::string paramFilename, - std::string par) { + void doTestParameterFileSelection(const std::string &filename, + const std::string ¶mFilename, + const std::string &par) { InstrumentDataService::Instance().clear(); LoadInstrument loader; @@ -914,7 +914,7 @@ public: ws = WorkspaceCreationHelper::create2DWorkspace(1, 2); } - void doTest(std::string filename, size_t numTimes = 1) { + void doTest(const std::string &filename, size_t numTimes = 1) { for (size_t i = 0; i < numTimes; ++i) { // Remove any existing instruments, so each time they are loaded. InstrumentDataService::Instance().clear(); diff --git a/Framework/DataHandling/test/LoadIsawDetCalTest.h b/Framework/DataHandling/test/LoadIsawDetCalTest.h index 8274c8d9bfefda9f08bd688a0a351af069834f58..0b4d947c3555b98ed4423f7955b646d62be82aca 100644 --- a/Framework/DataHandling/test/LoadIsawDetCalTest.h +++ b/Framework/DataHandling/test/LoadIsawDetCalTest.h @@ -48,8 +48,8 @@ void loadEmptyInstrument(const std::string &filename, class LoadIsawDetCalTest : public CxxTest::TestSuite { public: - void checkPosition(IComponent_const_sptr det, const double x, const double y, - const double z) { + void checkPosition(const IComponent_const_sptr &det, const double x, + const double y, const double z) { if (det != nullptr) { const auto detPos = det->getPos(); const V3D testPos(x, y, z); @@ -59,8 +59,8 @@ public: } } - void checkRotation(IComponent_const_sptr det, const double w, const double a, - const double b, const double c) { + void checkRotation(const IComponent_const_sptr &det, const double w, + const double a, const double b, const double c) { if (det != nullptr) { const auto detRot = det->getRotation(); const Quat testRot(w, a, b, c); diff --git a/Framework/DataHandling/test/LoadLogTest.h b/Framework/DataHandling/test/LoadLogTest.h index 6e960d5315cf5f297aecf9137d73504771148ac3..58dcad0cf3c002eb32cf94408b3a5dd05cb3e8b5 100644 --- a/Framework/DataHandling/test/LoadLogTest.h +++ b/Framework/DataHandling/test/LoadLogTest.h @@ -173,8 +173,8 @@ public: TS_ASSERT(ws->run().hasProperty("str3")); } - void do_test_SNSTextFile(std::string names, std::string units, bool willFail, - bool createWorkspace = true, + void do_test_SNSTextFile(const std::string &names, const std::string &units, + bool willFail, bool createWorkspace = true, std::string expectedLastUnit = "Furlongs") { // Create an empty workspace and put it in the AnalysisDataService diff --git a/Framework/DataHandling/test/LoadMappingTableTest.h b/Framework/DataHandling/test/LoadMappingTableTest.h index 7c1fa34fb1e8192014bbb58d3fca20a13a171d81..9459270a3e8745cfc06b3a23b3a4d008ff70235e 100644 --- a/Framework/DataHandling/test/LoadMappingTableTest.h +++ b/Framework/DataHandling/test/LoadMappingTableTest.h @@ -80,7 +80,7 @@ public: detectorgroup = work1->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); AnalysisDataService::Instance().remove(outputSpace); diff --git a/Framework/DataHandling/test/LoadMaskTest.h b/Framework/DataHandling/test/LoadMaskTest.h index e574bbcd0d301387e77d6abd0cb7697b011133ba..3dff548e4ac24aa802e25bea3c80b5a9662bb8bb 100644 --- a/Framework/DataHandling/test/LoadMaskTest.h +++ b/Framework/DataHandling/test/LoadMaskTest.h @@ -515,9 +515,9 @@ public: /* * Create a masking file */ - ScopedFileHelper::ScopedFile genMaskingFile(std::string maskfilename, + ScopedFileHelper::ScopedFile genMaskingFile(const std::string &maskfilename, std::vector<int> detids, - std::vector<int> banks) { + const std::vector<int> &banks) { std::stringstream ss; // 1. Header @@ -551,8 +551,8 @@ public: * Create an ISIS format masking file */ ScopedFileHelper::ScopedFile - genISISMaskingFile(std::string maskfilename, - std::vector<specnum_t> singlespectra, + genISISMaskingFile(const std::string &maskfilename, + const std::vector<specnum_t> &singlespectra, std::vector<specnum_t> pairspectra) { std::stringstream ss; diff --git a/Framework/DataHandling/test/LoadMcStasTest.h b/Framework/DataHandling/test/LoadMcStasTest.h index c383eed70df58f93d79b847afe4da6a40bf76d9c..986f30afe83125f7cd7fa3bcb5f7a99f6cb8b380 100644 --- a/Framework/DataHandling/test/LoadMcStasTest.h +++ b/Framework/DataHandling/test/LoadMcStasTest.h @@ -164,7 +164,7 @@ public: } private: - double extractSumAndTest(MatrixWorkspace_sptr workspace, + double extractSumAndTest(const MatrixWorkspace_sptr &workspace, const double &expectedSum) { TS_ASSERT_EQUALS(workspace->getNumberHistograms(), 8192); auto sum = 0.0; @@ -175,8 +175,8 @@ private: return sum; } - boost::shared_ptr<WorkspaceGroup> load_test(std::string fileName, - std::string outputName) { + boost::shared_ptr<WorkspaceGroup> load_test(const std::string &fileName, + const std::string &outputName) { // specify name of file to load workspace from algToBeTested.setProperty("Filename", fileName); diff --git a/Framework/DataHandling/test/LoadMuonNexus2Test.h b/Framework/DataHandling/test/LoadMuonNexus2Test.h index c3ea63efbd5f875ba9e2c0c3816fe279fef58dca..4b9c1947e22e2c3a39e9dad0ebf90d0976b3a6d5 100644 --- a/Framework/DataHandling/test/LoadMuonNexus2Test.h +++ b/Framework/DataHandling/test/LoadMuonNexus2Test.h @@ -33,7 +33,7 @@ using Mantid::Types::Core::DateAndTime; class LoadMuonNexus2Test : public CxxTest::TestSuite { public: - void check_spectra_and_detectors(MatrixWorkspace_sptr output) { + void check_spectra_and_detectors(const MatrixWorkspace_sptr &output) { //---------------------------------------------------------------------- // Tests to check that spectra-detector mapping is done correctly diff --git a/Framework/DataHandling/test/LoadNXcanSASTest.h b/Framework/DataHandling/test/LoadNXcanSASTest.h index 908c0b7b2d95c8c5566e92db1dce38a4c98037ac..033734375592a3701800865d0f057eab86112f6c 100644 --- a/Framework/DataHandling/test/LoadNXcanSASTest.h +++ b/Framework/DataHandling/test/LoadNXcanSASTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" @@ -266,7 +268,7 @@ public: } private: - void removeWorkspaceFromADS(const std::string toRemove) { + void removeWorkspaceFromADS(const std::string &toRemove) { if (AnalysisDataService::Instance().doesExist(toRemove)) { AnalysisDataService::Instance().remove(toRemove); } @@ -296,10 +298,11 @@ private: return ws; } - void save_file_no_issues(MatrixWorkspace_sptr workspace, - NXcanSASTestParameters ¶meters, - MatrixWorkspace_sptr transmission = nullptr, - MatrixWorkspace_sptr transmissionCan = nullptr) { + void + save_file_no_issues(const MatrixWorkspace_sptr &workspace, + NXcanSASTestParameters ¶meters, + const MatrixWorkspace_sptr &transmission = nullptr, + const MatrixWorkspace_sptr &transmissionCan = nullptr) { auto saveAlg = AlgorithmManager::Instance().createUnmanaged("SaveNXcanSAS"); saveAlg->initialize(); saveAlg->setProperty("Filename", parameters.filename); @@ -342,7 +345,8 @@ private: } } - void do_assert_units(MatrixWorkspace_sptr wsIn, MatrixWorkspace_sptr wsOut) { + void do_assert_units(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { // Ensure that units of axis 0 are matching auto unit0In = wsIn->getAxis(0)->unit()->label().ascii(); auto unit0Out = wsOut->getAxis(0)->unit()->label().ascii(); @@ -361,8 +365,8 @@ private: TSM_ASSERT_EQUALS("Should have the same y unit", unitYIn, unitYOut); } - void do_assert_axis1_values_are_the_same(MatrixWorkspace_sptr wsIn, - MatrixWorkspace_sptr wsOut) { + void do_assert_axis1_values_are_the_same(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { if (!wsOut->getAxis(1)->isNumeric()) { return; } @@ -391,8 +395,8 @@ private: } } - void do_assert_sample_logs(MatrixWorkspace_sptr wsIn, - MatrixWorkspace_sptr wsOut) { + void do_assert_sample_logs(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { auto &runIn = wsIn->mutableRun(); auto &runOut = wsOut->mutableRun(); @@ -413,16 +417,17 @@ private: } } - void do_assert_instrument(MatrixWorkspace_sptr wsIn, - MatrixWorkspace_sptr wsOut) { - auto idfIn = getIDFfromWorkspace(wsIn); - auto idfOut = getIDFfromWorkspace(wsOut); + void do_assert_instrument(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut) { + auto idfIn = getIDFfromWorkspace(std::move(wsIn)); + auto idfOut = getIDFfromWorkspace(std::move(wsOut)); TSM_ASSERT_EQUALS("Should have the same instrument", idfIn, idfOut); } - void do_assert_transmission(MatrixWorkspace_sptr mainWorkspace, - MatrixWorkspace_sptr transIn, - NXcanSASTestTransmissionParameters parameters) { + void + do_assert_transmission(const MatrixWorkspace_sptr &mainWorkspace, + const MatrixWorkspace_sptr &transIn, + const NXcanSASTestTransmissionParameters ¶meters) { if (!parameters.usesTransmission || !transIn) { return; } @@ -435,32 +440,34 @@ private: AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(transName); // Ensure that both have the same Y data - auto readDataY = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataY = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->y(index); }; do_assert_data(transIn, transOut, readDataY); // Ensure that both have the same E data - auto readDataE = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataE = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->e(index); }; do_assert_data(transIn, transOut, readDataE); // Ensure that both have the same X data - auto readDataX = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataX = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->x(index); }; do_assert_data(transIn, transOut, readDataX); } - void do_assert_load(MatrixWorkspace_sptr wsIn, MatrixWorkspace_sptr wsOut, - NXcanSASTestParameters ¶meters, - MatrixWorkspace_sptr transmission = nullptr, - MatrixWorkspace_sptr transmissionCan = nullptr, - NXcanSASTestTransmissionParameters sampleParameters = - NXcanSASTestTransmissionParameters(), - NXcanSASTestTransmissionParameters canParameters = - NXcanSASTestTransmissionParameters()) { + void + do_assert_load(const MatrixWorkspace_sptr &wsIn, + const MatrixWorkspace_sptr &wsOut, + NXcanSASTestParameters ¶meters, + const MatrixWorkspace_sptr &transmission = nullptr, + const MatrixWorkspace_sptr &transmissionCan = nullptr, + const NXcanSASTestTransmissionParameters &sampleParameters = + NXcanSASTestTransmissionParameters(), + const NXcanSASTestTransmissionParameters &canParameters = + NXcanSASTestTransmissionParameters()) { // Ensure that both have the same units do_assert_units(wsIn, wsOut); @@ -468,26 +475,26 @@ private: TSM_ASSERT("Should be a point workspace", !wsOut->isHistogramData()); // Ensure that both have the same Y data - auto readDataY = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataY = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->y(index); }; do_assert_data(wsIn, wsOut, readDataY); // Ensure that both have the same E data - auto readDataE = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataE = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->e(index); }; do_assert_data(wsIn, wsOut, readDataE); // Ensure that both have the same X data - auto readDataX = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataX = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->x(index); }; do_assert_data(wsIn, wsOut, readDataX); // If applicable, ensure that both have the same Xdev data if (parameters.hasDx) { - auto readDataDX = [](MatrixWorkspace_sptr ws, size_t index) { + auto readDataDX = [](const MatrixWorkspace_sptr &ws, size_t index) { return ws->dataDx(index); }; do_assert_data(wsIn, wsOut, readDataDX); @@ -503,8 +510,10 @@ private: do_assert_instrument(wsIn, wsOut); // Test transmission workspaces - do_assert_transmission(wsOut, transmission, sampleParameters); - do_assert_transmission(wsOut, transmissionCan, canParameters); + do_assert_transmission(wsOut, std::move(transmission), + std::move(sampleParameters)); + do_assert_transmission(wsOut, std::move(transmissionCan), + std::move(canParameters)); } }; @@ -537,7 +546,7 @@ private: NXcanSASTestParameters parameters1D; NXcanSASTestParameters parameters2D; - void save_no_assert(MatrixWorkspace_sptr ws, + void save_no_assert(const MatrixWorkspace_sptr &ws, NXcanSASTestParameters ¶meters) { auto saveAlg = AlgorithmManager::Instance().createUnmanaged("SaveNXcanSAS"); saveAlg->initialize(); diff --git a/Framework/DataHandling/test/LoadNexusLogsTest.h b/Framework/DataHandling/test/LoadNexusLogsTest.h index 579a1a79d202a533323a31565fe6c6090b22afd3..85aa8487e0ed19f07443919a42b354249279e6fd 100644 --- a/Framework/DataHandling/test/LoadNexusLogsTest.h +++ b/Framework/DataHandling/test/LoadNexusLogsTest.h @@ -272,7 +272,6 @@ public: void test_last_time_series_log_entry_equals_end_time() { LoadNexusLogs ld; - std::string outws_name = "REF_L_instrument"; ld.initialize(); ld.setPropertyValue("Filename", "REF_L_32035.nxs"); MatrixWorkspace_sptr ws = createTestWorkspace(); diff --git a/Framework/DataHandling/test/LoadNexusProcessed2Test.h b/Framework/DataHandling/test/LoadNexusProcessed2Test.h index 3ece0dffb833afdea8634199e15a8a13481f720e..b63a4ed5c8a937597c901153cf827508f57bfbeb 100644 --- a/Framework/DataHandling/test/LoadNexusProcessed2Test.h +++ b/Framework/DataHandling/test/LoadNexusProcessed2Test.h @@ -52,7 +52,7 @@ Mantid::API::MatrixWorkspace_sptr do_load_v1(const std::string &filename) { } namespace test_utility { -template <typename T> void save(const std::string filename, T &ws) { +template <typename T> void save(const std::string &filename, T &ws) { SaveNexusESS alg; alg.setChild(true); alg.setRethrows(true); diff --git a/Framework/DataHandling/test/LoadNexusProcessedTest.h b/Framework/DataHandling/test/LoadNexusProcessedTest.h index 4a1d3d41dd15f7d10f27ff5c34e2bad69032c9d2..f501fc6c6639c50127dae9f2d713d1fa8c4d1d73 100644 --- a/Framework/DataHandling/test/LoadNexusProcessedTest.h +++ b/Framework/DataHandling/test/LoadNexusProcessedTest.h @@ -1110,7 +1110,7 @@ public: } private: - void doHistoryTest(MatrixWorkspace_sptr matrix_ws) { + void doHistoryTest(const MatrixWorkspace_sptr &matrix_ws) { const WorkspaceHistory history = matrix_ws->getHistory(); int nalgs = static_cast<int>(history.size()); TS_ASSERT_EQUALS(nalgs, 4); @@ -1201,7 +1201,7 @@ private: * be present */ void doSpectrumListTests(LoadNexusProcessed &alg, - const std::vector<int> expectedSpectra) { + const std::vector<int> &expectedSpectra) { TS_ASSERT_THROWS_NOTHING(alg.execute()); TS_ASSERT(alg.isExecuted()); diff --git a/Framework/DataHandling/test/LoadPLNTest.h b/Framework/DataHandling/test/LoadPLNTest.h index ed193864a0754e4a465d4589ff5f22732a461668..80d8d067d5464e7a0d863df5fad343649d24d20c 100644 --- a/Framework/DataHandling/test/LoadPLNTest.h +++ b/Framework/DataHandling/test/LoadPLNTest.h @@ -74,7 +74,7 @@ public: run.getProperty("end_time")->value().find("2018-11-12T11:45:06.6") == 0) // test some data properties - auto logpm = [&run](std::string tag) { + auto logpm = [&run](const std::string &tag) { return dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty(tag)) ->firstValue(); }; @@ -129,7 +129,7 @@ public: run.getProperty("end_time")->value().find("2018-11-12T11:45:06.6") == 0) // test some data properties - auto logpm = [&run](std::string tag) { + auto logpm = [&run](const std::string &tag) { return dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty(tag)) ->firstValue(); }; diff --git a/Framework/DataHandling/test/LoadRaw3Test.h b/Framework/DataHandling/test/LoadRaw3Test.h index 9038d686ebadccc817cdc188b76c84cb1b298070..19f298d7286d2601c15d6c37b854f92a88b385bb 100644 --- a/Framework/DataHandling/test/LoadRaw3Test.h +++ b/Framework/DataHandling/test/LoadRaw3Test.h @@ -153,7 +153,7 @@ public: detectorgroup = output2D->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); AnalysisDataService::Instance().remove(outputSpace); @@ -375,7 +375,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -385,7 +385,7 @@ public: std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 4; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -581,7 +581,7 @@ public: detectorgroup = output2D->getSpectrum(2079).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); // Test if filename log is found in both monitor and sata workspace @@ -626,7 +626,7 @@ public: monitorsptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = monitorwsNamevec.begin(); - for (; it != monitorwsNamevec.end(); it++) { + for (; it != monitorwsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_monitors_" + count.str(); @@ -634,7 +634,7 @@ public: period++; } std::vector<std::string>::const_iterator itr1 = monitorwsNamevec.begin(); - for (; itr1 != monitorwsNamevec.end(); itr1++) { + for (; itr1 != monitorwsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -674,7 +674,7 @@ public: const std::vector<std::string> wsNamevec = sptrWSGrp->getNames(); period = 1; it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -684,7 +684,7 @@ public: itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 2; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -1151,7 +1151,7 @@ public: private: /// Helper method to run common set of tests on a workspace in a multi-period /// group. - void doTestMultiPeriodWorkspace(MatrixWorkspace_sptr workspace, + void doTestMultiPeriodWorkspace(const MatrixWorkspace_sptr &workspace, const size_t &nHistograms, int expected_period) { // Check the number of histograms. @@ -1173,8 +1173,8 @@ private: } /// Check that two matrix workspaces match - std::string checkWorkspacesMatch(Workspace_sptr workspace1, - Workspace_sptr workspace2) { + std::string checkWorkspacesMatch(const Workspace_sptr &workspace1, + const Workspace_sptr &workspace2) { auto ws1 = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace1); auto ws2 = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace2); if (!ws1 || !ws2) { diff --git a/Framework/DataHandling/test/LoadRawBin0Test.h b/Framework/DataHandling/test/LoadRawBin0Test.h index 82884027b2e1da2778ce1b308765f65daeeb0e61..b1c314f1c7aacf32c87eeedb8302d56e5425d2a8 100644 --- a/Framework/DataHandling/test/LoadRawBin0Test.h +++ b/Framework/DataHandling/test/LoadRawBin0Test.h @@ -108,7 +108,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -118,7 +118,7 @@ public: std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 4; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -149,7 +149,7 @@ public: private: /// Helper method to run common set of tests on a workspace in a multi-period /// group. - void doTestMultiPeriodWorkspace(MatrixWorkspace_sptr workspace, + void doTestMultiPeriodWorkspace(const MatrixWorkspace_sptr &workspace, const size_t &nHistograms, int expected_period) { // Check the number of histograms. diff --git a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h index 101fc484ffa9f4c965e946c0043893d2098d3c6a..7af33edb978501176d9265d130fa18bb3d3b0302 100644 --- a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h +++ b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h @@ -72,7 +72,6 @@ public: // specify name of file to save workspace to outputFile = "testSaveLoadrawCSP.nxs"; remove(outputFile.c_str()); - std::string dataName = "spectra"; std::string title = "Workspace from Loadraw CSP78173"; saveNexusP.setPropertyValue("FileName", outputFile); outputFile = saveNexusP.getPropertyValue("Filename"); diff --git a/Framework/DataHandling/test/LoadRawSpectrum0Test.h b/Framework/DataHandling/test/LoadRawSpectrum0Test.h index 51bee7ca53f1662189004e0d7afdfa48cac367ab..96a7f376aa8c278c2d8adf6c7e1e3062d381fd90 100644 --- a/Framework/DataHandling/test/LoadRawSpectrum0Test.h +++ b/Framework/DataHandling/test/LoadRawSpectrum0Test.h @@ -110,7 +110,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -119,7 +119,7 @@ public: } std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int expectedPeriod = 0; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -146,7 +146,7 @@ public: private: /// Helper method to run common set of tests on a workspace in a multi-period /// group. - void doTestMultiPeriodWorkspace(MatrixWorkspace_sptr workspace, + void doTestMultiPeriodWorkspace(const MatrixWorkspace_sptr &workspace, int expected_period) { // Check the current period property. const Mantid::API::Run &run = workspace->run(); diff --git a/Framework/DataHandling/test/LoadSampleShapeTest.h b/Framework/DataHandling/test/LoadSampleShapeTest.h index 8481575cf209f81f5ccc689236cb6a8a46cdabe9..62b10eaac5e0c7cadfe15bfee5d30b09a3dc3e5d 100644 --- a/Framework/DataHandling/test/LoadSampleShapeTest.h +++ b/Framework/DataHandling/test/LoadSampleShapeTest.h @@ -217,7 +217,7 @@ private: const MeshObject *loadMeshObject(LoadSampleShape &alg, bool outputWsSameAsInputWs, - const std::string filename) { + const std::string &filename) { alg.initialize(); alg.setPropertyValue("Filename", filename); prepareWorkspaces(alg, outputWsSameAsInputWs); @@ -226,7 +226,7 @@ private: return getMeshObject(alg); } - void loadFailureTest(LoadSampleShape &alg, const std::string filename) { + void loadFailureTest(LoadSampleShape &alg, const std::string &filename) { alg.initialize(); alg.setPropertyValue("Filename", filename); prepareWorkspaces(alg, true); @@ -276,7 +276,7 @@ private: std::unique_ptr<LoadSampleShape> alg; const int numberOfIterations = 5; - std::unique_ptr<LoadSampleShape> setupAlg(Workspace2D_sptr inputWS) { + std::unique_ptr<LoadSampleShape> setupAlg(const Workspace2D_sptr &inputWS) { auto loadAlg = std::make_unique<LoadSampleShape>(); loadAlg->initialize(); loadAlg->setChild(true); diff --git a/Framework/DataHandling/test/LoadSpice2dTest.h b/Framework/DataHandling/test/LoadSpice2dTest.h index 53d177e394c0ea58c0df6b71a611c8a022878a74..3f44d326e21df75d7b134475c5b5452cd3e88235 100644 --- a/Framework/DataHandling/test/LoadSpice2dTest.h +++ b/Framework/DataHandling/test/LoadSpice2dTest.h @@ -222,7 +222,8 @@ public: TS_ASSERT_DELTA(ws2d->x(192 + nmon)[0], 4.5, tolerance); } - void assertDetectorDistances(Mantid::DataObjects::Workspace2D_sptr ws2d) { + void + assertDetectorDistances(const Mantid::DataObjects::Workspace2D_sptr &ws2d) { Mantid::Kernel::Property *prop = ws2d->run().getProperty("sample-detector-distance"); Mantid::Kernel::PropertyWithValue<double> *sdd = diff --git a/Framework/DataHandling/test/MaskDetectorsInShapeTest.h b/Framework/DataHandling/test/MaskDetectorsInShapeTest.h index d2227555c13db7ec5a09c6c79176b0e323411318..c675b30f5b874ce8dccf40e107baf6dd619663f2 100644 --- a/Framework/DataHandling/test/MaskDetectorsInShapeTest.h +++ b/Framework/DataHandling/test/MaskDetectorsInShapeTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FrameworkManager.h" #include "MantidDataHandling/LoadEmptyInstrument.h" @@ -59,7 +61,7 @@ public: runTest(xmlShape, "320,340,360,380", false); } - void runTest(std::string xmlShape, std::string expectedHits, + void runTest(const std::string &xmlShape, std::string expectedHits, bool includeMonitors = true) { using namespace Mantid::API; @@ -80,21 +82,21 @@ public: MatrixWorkspace_const_sptr outWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName); - checkDeadDetectors(outWS, expectedHits); + checkDeadDetectors(outWS, std::move(expectedHits)); } - void checkDeadDetectors(Mantid::API::MatrixWorkspace_const_sptr outWS, - std::string expectedHits) { + void checkDeadDetectors(const Mantid::API::MatrixWorkspace_const_sptr &outWS, + const std::string &expectedHits) { // check that the detectors have actually been marked dead std::vector<int> expectedDetectorArray = - convertStringToVector(expectedHits); + convertStringToVector(std::move(expectedHits)); const auto &detectorInfo = outWS->detectorInfo(); for (const auto detID : expectedDetectorArray) { TS_ASSERT(detectorInfo.isMasked(detectorInfo.indexOf(detID))); } } - std::vector<int> convertStringToVector(const std::string input) { + std::vector<int> convertStringToVector(const std::string &input) { Mantid::Kernel::ArrayProperty<int> arrayProp("name", input); return arrayProp(); } diff --git a/Framework/DataHandling/test/MaskDetectorsTest.h b/Framework/DataHandling/test/MaskDetectorsTest.h index 826fefab82959e6af67d138cfe4a739d95e3fa68..747f7e786ad4ab4ce7bf82ba074404283aba0d93 100644 --- a/Framework/DataHandling/test/MaskDetectorsTest.h +++ b/Framework/DataHandling/test/MaskDetectorsTest.h @@ -649,9 +649,9 @@ public: void test_MaskWithWorkspaceWithDetectorIDs() { auto &ads = AnalysisDataService::Instance(); - const std::string inputWSName("inputWS"), existingMaskName("existingMask"); const int numInputSpec(90); + const std::string inputWSName("inputWS"); setUpWS(false, inputWSName, false, numInputSpec); auto inputWS = ads.retrieveWS<MatrixWorkspace>(inputWSName); @@ -717,7 +717,7 @@ public: void test_MaskWithWorkspaceWithDetectorIDsAndWsIndexRange() { auto &ads = AnalysisDataService::Instance(); - const std::string inputWSName("inputWS"), existingMaskName("existingMask"); + const std::string inputWSName("inputWS"); const int numInputSpec(90); setUpWS(false, inputWSName, false, numInputSpec); diff --git a/Framework/DataHandling/test/MaskSpectraTest.h b/Framework/DataHandling/test/MaskSpectraTest.h index 92d3d7ce3be8d92630fdf4f634f067f17bf8c42c..3fb4c93b10e2c4ab8671f97a37ed15075e55799d 100644 --- a/Framework/DataHandling/test/MaskSpectraTest.h +++ b/Framework/DataHandling/test/MaskSpectraTest.h @@ -47,7 +47,7 @@ void checkWorkspace(const MatrixWorkspace &ws) { TS_ASSERT_EQUALS(ws.e(3)[0], 0.0); } -MatrixWorkspace_sptr runMaskSpectra(MatrixWorkspace_sptr inputWS) { +MatrixWorkspace_sptr runMaskSpectra(const MatrixWorkspace_sptr &inputWS) { MaskSpectra alg; alg.setChild(true); alg.initialize(); diff --git a/Framework/DataHandling/test/NXcanSASTestHelper.cpp b/Framework/DataHandling/test/NXcanSASTestHelper.cpp index 6504a1ae60f3cc6e088850ca9aa42930d4593314..a1a2381f0f47e6be2e550681a35cf3dbed3085ba 100644 --- a/Framework/DataHandling/test/NXcanSASTestHelper.cpp +++ b/Framework/DataHandling/test/NXcanSASTestHelper.cpp @@ -18,7 +18,8 @@ namespace NXcanSASTestHelper { -std::string concatenateStringVector(std::vector<std::string> stringVector) { +std::string +concatenateStringVector(const std::vector<std::string> &stringVector) { std::ostringstream os; for (auto &element : stringVector) { os << element; @@ -28,7 +29,8 @@ std::string concatenateStringVector(std::vector<std::string> stringVector) { return os.str(); } -std::string getIDFfromWorkspace(Mantid::API::MatrixWorkspace_sptr workspace) { +std::string +getIDFfromWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace) { auto instrument = workspace->getInstrument(); auto name = instrument->getFullName(); auto date = workspace->getWorkspaceStartDate(); @@ -36,7 +38,8 @@ std::string getIDFfromWorkspace(Mantid::API::MatrixWorkspace_sptr workspace) { } void setXValuesOn1DWorkspaceWithPointData( - Mantid::API::MatrixWorkspace_sptr workspace, double xmin, double xmax) { + const Mantid::API::MatrixWorkspace_sptr &workspace, double xmin, + double xmax) { auto &xValues = workspace->dataX(0); auto size = xValues.size(); double binWidth = (xmax - xmin) / static_cast<double>(size - 1); @@ -46,7 +49,7 @@ void setXValuesOn1DWorkspaceWithPointData( } } -void add_sample_log(Mantid::API::MatrixWorkspace_sptr workspace, +void add_sample_log(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &logName, const std::string &logValue) { auto logAlg = Mantid::API::AlgorithmManager::Instance().createUnmanaged("AddSampleLog"); @@ -58,7 +61,7 @@ void add_sample_log(Mantid::API::MatrixWorkspace_sptr workspace, logAlg->execute(); } -void set_logs(Mantid::API::MatrixWorkspace_sptr workspace, +void set_logs(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &runNumber, const std::string &userFile) { if (!runNumber.empty()) { add_sample_log(workspace, "run_number", runNumber); @@ -69,7 +72,7 @@ void set_logs(Mantid::API::MatrixWorkspace_sptr workspace, } } -void set_instrument(Mantid::API::MatrixWorkspace_sptr workspace, +void set_instrument(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &instrumentName) { auto instAlg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "LoadInstrument"); @@ -205,7 +208,7 @@ provide2DWorkspace(NXcanSASTestParameters ¶meters) { return ws; } -void set2DValues(Mantid::API::MatrixWorkspace_sptr ws) { +void set2DValues(const Mantid::API::MatrixWorkspace_sptr &ws) { const auto numberOfHistograms = ws->getNumberHistograms(); for (size_t index = 0; index < numberOfHistograms; ++index) { @@ -214,7 +217,7 @@ void set2DValues(Mantid::API::MatrixWorkspace_sptr ws) { } } -void removeFile(std::string filename) { +void removeFile(const std::string &filename) { if (Poco::File(filename).exists()) Poco::File(filename).remove(); } diff --git a/Framework/DataHandling/test/NXcanSASTestHelper.h b/Framework/DataHandling/test/NXcanSASTestHelper.h index 1d8ec808ea9ee2d811cddfaf30b3aa89af02884b..aec86f5708d92f56494687531d4a9db492c41339 100644 --- a/Framework/DataHandling/test/NXcanSASTestHelper.h +++ b/Framework/DataHandling/test/NXcanSASTestHelper.h @@ -92,20 +92,23 @@ struct NXcanSASTestTransmissionParameters { bool usesTransmission; }; -std::string concatenateStringVector(std::vector<std::string> stringVector); +std::string +concatenateStringVector(const std::vector<std::string> &stringVector); -std::string getIDFfromWorkspace(Mantid::API::MatrixWorkspace_sptr workspace); +std::string +getIDFfromWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace); void setXValuesOn1DWorkspaceWithPointData( - Mantid::API::MatrixWorkspace_sptr workspace, double xmin, double xmax); + const Mantid::API::MatrixWorkspace_sptr &workspace, double xmin, + double xmax); -void add_sample_log(Mantid::API::MatrixWorkspace_sptr workspace, +void add_sample_log(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &logName, const std::string &logValue); -void set_logs(Mantid::API::MatrixWorkspace_sptr workspace, +void set_logs(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &runNumber, const std::string &userFile); -void set_instrument(Mantid::API::MatrixWorkspace_sptr workspace, +void set_instrument(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &instrumentName); Mantid::API::MatrixWorkspace_sptr @@ -117,7 +120,7 @@ getTransmissionWorkspace(NXcanSASTestTransmissionParameters ¶meters); Mantid::API::MatrixWorkspace_sptr provide2DWorkspace(NXcanSASTestParameters ¶meters); -void set2DValues(Mantid::API::MatrixWorkspace_sptr ws); +void set2DValues(const Mantid::API::MatrixWorkspace_sptr &ws); -void removeFile(std::string filename); +void removeFile(const std::string &filename); } // namespace NXcanSASTestHelper \ No newline at end of file diff --git a/Framework/DataHandling/test/RenameLogTest.h b/Framework/DataHandling/test/RenameLogTest.h index 66913b9a2371cb2ec552edae83ec1293a3fe7e58..013170d6a27e6ae24312e6c0db7227ed7f1c797b 100644 --- a/Framework/DataHandling/test/RenameLogTest.h +++ b/Framework/DataHandling/test/RenameLogTest.h @@ -124,8 +124,8 @@ private: return testWS; } - void verifyLog(API::MatrixWorkspace_sptr resultWS, - const std::string logName) { + void verifyLog(const API::MatrixWorkspace_sptr &resultWS, + const std::string &logName) { Kernel::TimeSeriesProperty<double> *rp; TS_ASSERT_THROWS_NOTHING( rp = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( diff --git a/Framework/DataHandling/test/SaveAscii2Test.h b/Framework/DataHandling/test/SaveAscii2Test.h index a13dba15dc31e09688656460bfef1cdfb81bccb5..d9f1c18952fa87ca84964ff883952d9bf2d615d5 100644 --- a/Framework/DataHandling/test/SaveAscii2Test.h +++ b/Framework/DataHandling/test/SaveAscii2Test.h @@ -114,7 +114,7 @@ public: } AnalysisDataService::Instance().add(m_name, wsToSave); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING(save.setPropertyValue("WriteXError", "1")); TS_ASSERT_THROWS_ANYTHING(save.execute()); AnalysisDataService::Instance().remove(m_name); @@ -530,7 +530,7 @@ public: writeSampleWS(wsToSave, false); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING( save.setProperty("SpectrumMetaData", "SpectrumNumber")); @@ -836,7 +836,7 @@ public: writeSampleWS(wsToSave); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING( save.setPropertyValue("SpectrumMetaData", "NotAValidChoice")); diff --git a/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h b/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h index 45e667a4933e129be9f0dc8f22e59e7abc2dc5bb..ab924856da4df1c1aa5826f1d67ae087ed8a389a 100644 --- a/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h +++ b/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h @@ -62,9 +62,9 @@ public: std::ifstream file(tempFileName); std::string line; - int numLines = 0; if (file.is_open()) { + int numLines = 0; while (std::getline(file, line)) { numLines++; } diff --git a/Framework/DataHandling/test/SaveCSVTest.h b/Framework/DataHandling/test/SaveCSVTest.h index 894dca2524c11282984c9fcde8bfa59a40169e83..21c841e809974d36e6b9527411f1dc7f3cd5fb7e 100644 --- a/Framework/DataHandling/test/SaveCSVTest.h +++ b/Framework/DataHandling/test/SaveCSVTest.h @@ -169,7 +169,8 @@ private: Poco::File(fileName).remove(); } - void evaluateFileWithDX(std::string fileName, const size_t nSpec) const { + void evaluateFileWithDX(const std::string &fileName, + const size_t nSpec) const { std::ifstream stream(fileName.c_str()); std::istringstream dataStream; std::string line; diff --git a/Framework/DataHandling/test/SaveCalFileTest.h b/Framework/DataHandling/test/SaveCalFileTest.h index c00ec9eb1604624f1d97cc86ada45e06c5c569d5..d8ffb94aec8834a46a081466e5adeba6b079e1b5 100644 --- a/Framework/DataHandling/test/SaveCalFileTest.h +++ b/Framework/DataHandling/test/SaveCalFileTest.h @@ -51,9 +51,6 @@ public: maskWS->getSpectrum(0).clearData(); maskWS->mutableSpectrumInfo().setMasked(0, true); - // Name of the output workspace. - std::string outWSName("SaveCalFileTest_OutputWS"); - SaveCalFile alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/SaveFullprofResolutionTest.h b/Framework/DataHandling/test/SaveFullprofResolutionTest.h index 15d97bff2199743a10b80bd1cba85ab4d4e05448..8b088df4b745ee8d900aa7c0cd3457c3184ac9ad 100644 --- a/Framework/DataHandling/test/SaveFullprofResolutionTest.h +++ b/Framework/DataHandling/test/SaveFullprofResolutionTest.h @@ -184,7 +184,7 @@ public: //---------------------------------------------------------------------------------------------- /** Find out number of lines in a text file */ - int getFileLines(std::string filename) { + int getFileLines(const std::string &filename) { ifstream infile; infile.open(filename.c_str()); @@ -206,7 +206,7 @@ public: /** Write out a TableWorkspace contain 2 banks' parameters * ISIS HRPD Data */ - void create2BankProf9Table(string workspacename) { + void create2BankProf9Table(const string &workspacename) { TableWorkspace_sptr partablews = boost::make_shared<TableWorkspace>(); partablews->addColumn("str", "Name"); partablews->addColumn("double", "Value_1"); @@ -261,7 +261,7 @@ public: * 10 * Source data is from POWGEN's bank 1 calibrated */ - void createProfile10TableWS(std::string wsname) { + void createProfile10TableWS(const std::string &wsname) { // Create a map of string/double for parameters of profile 10 std::map<std::string, double> parammap{ {"BANK", 1.}, {"Alph0", 1.88187}, {"Alph0t", 64.4102}, diff --git a/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h b/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h index 02ba90e4e9eb4a2e32480dbdf12af3e06e95adaf..641319f16a8906c980d4a8dab1df33863ba0040d 100644 --- a/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h +++ b/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h @@ -186,7 +186,7 @@ public: //---------------------------------------------------------------------------------------------- /** Load table workspace containing instrument parameters */ - void loadProfileTable(string wsname) { + void loadProfileTable(const string &wsname) { // The data befow is from Bank1 in pg60_2011B.irf auto tablews = boost::make_shared<TableWorkspace>(); @@ -266,7 +266,7 @@ public: //---------------------------------------------------------------------------------------------- /** Generate a 3 bank .irf file */ - void generate3BankIrfFile(string filename) { + void generate3BankIrfFile(const string &filename) { ofstream ofile; ofile.open(filename.c_str()); @@ -457,7 +457,8 @@ public: } // Compare 2 files - bool compare2Files(std::string filename1, std::string filename2) { + bool compare2Files(const std::string &filename1, + const std::string &filename2) { ifstream file1(filename1.c_str(), std::ifstream::in); ifstream file2(filename2.c_str(), std::ifstream::in); @@ -496,7 +497,6 @@ public: while (!file2.eof()) { getline(file2, str); - c2++; } // Reset file stream pointer diff --git a/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h b/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h index 0669e1eed2a76c35242eaa815c2f24466852864c..865a4120f72e304172115e8982b68abac3d42523 100644 --- a/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h +++ b/Framework/DataHandling/test/SaveILLCosmosAsciiTest.h @@ -228,7 +228,8 @@ public: private: void headingsTests(std::ifstream &in, std::string &fullline, - bool propertiesLogs = false, std::string sep = "\t") { + bool propertiesLogs = false, + const std::string &sep = "\t") { getline(in, fullline); TS_ASSERT_EQUALS(fullline, "MFT"); getline(in, fullline); diff --git a/Framework/DataHandling/test/SaveNXSPETest.h b/Framework/DataHandling/test/SaveNXSPETest.h index fb569bdb7ca107e5eb7ddd0254a512d5e8c3e646..fe41ac1a3d787fad738385e1c24877e96cedbff2 100644 --- a/Framework/DataHandling/test/SaveNXSPETest.h +++ b/Framework/DataHandling/test/SaveNXSPETest.h @@ -175,7 +175,7 @@ private: boost::tuple<boost::shared_array<hsize_t>, boost::shared_array<double>, boost::shared_array<double>>; - DataHolder saveAndReloadWorkspace(const MatrixWorkspace_sptr inputWS) { + DataHolder saveAndReloadWorkspace(const MatrixWorkspace_sptr &inputWS) { SaveNXSPE saver; saver.initialize(); saver.setChild(true); diff --git a/Framework/DataHandling/test/SaveNXcanSASTest.h b/Framework/DataHandling/test/SaveNXcanSASTest.h index 7fba40a62ae0ef2820c903443c8562077660158b..46bdbabd14ebec8da4d43704c48d5307f23d798b 100644 --- a/Framework/DataHandling/test/SaveNXcanSASTest.h +++ b/Framework/DataHandling/test/SaveNXcanSASTest.h @@ -373,10 +373,10 @@ public: private: void save_file_no_issues( - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, NXcanSASTestParameters ¶meters, - Mantid::API::MatrixWorkspace_sptr transmission = nullptr, - Mantid::API::MatrixWorkspace_sptr transmissionCan = nullptr) { + const Mantid::API::MatrixWorkspace_sptr &transmission = nullptr, + const Mantid::API::MatrixWorkspace_sptr &transmissionCan = nullptr) { auto saveAlg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "SaveNXcanSAS"); saveAlg->initialize(); @@ -472,7 +472,7 @@ private: } void do_assert_detector(H5::Group &instrument, - std::vector<std::string> detectors) { + const std::vector<std::string> &detectors) { for (auto &detector : detectors) { std::string detectorName = sasInstrumentDetectorGroupName + detector; auto detectorNameSanitized = @@ -616,7 +616,7 @@ private: void do_assert_process_note(H5::Group ¬e, const bool &hasSampleRuns, const bool &hasCanRuns, const std::string &sampleDirectRun, - const std::string canDirectRun) { + const std::string &canDirectRun) { auto numAttributes = note.getNumAttrs(); TSM_ASSERT_EQUALS("Should have 2 attributes", 2, numAttributes); diff --git a/Framework/DataHandling/test/SaveNexusESSTest.h b/Framework/DataHandling/test/SaveNexusESSTest.h index 969ec56471a22fedf93f940e1c54b11e7fb29eb9..4bbeb8a86e7a756438af1095e7f0aebc3c5b325b 100644 --- a/Framework/DataHandling/test/SaveNexusESSTest.h +++ b/Framework/DataHandling/test/SaveNexusESSTest.h @@ -33,7 +33,7 @@ using namespace Mantid::DataHandling; using namespace Mantid::API; namespace { -template <typename T> void do_execute(const std::string filename, T &ws) { +template <typename T> void do_execute(const std::string &filename, T &ws) { SaveNexusESS alg; alg.setChild(true); alg.setRethrows(true); diff --git a/Framework/DataHandling/test/SaveNexusProcessedTest.h b/Framework/DataHandling/test/SaveNexusProcessedTest.h index 955c1419f7bb2522f85dfda9f6d50481596c9488..44bf634212da801aff15160c70ee12b2ffb74efd 100644 --- a/Framework/DataHandling/test/SaveNexusProcessedTest.h +++ b/Framework/DataHandling/test/SaveNexusProcessedTest.h @@ -228,7 +228,7 @@ public: * @return */ static EventWorkspace_sptr - do_testExec_EventWorkspaces(std::string filename_root, EventType type, + do_testExec_EventWorkspaces(const std::string &filename_root, EventType type, std::string &outputFile, bool makeDifferentTypes, bool clearfiles, bool PreserveEvents = true, bool CompressNexus = false) { diff --git a/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h b/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h index f5c4a3daaee22902588332b904efa32d9a8e4619..cf19f1e0ba05191663bf916e2f19417fb5e05707 100644 --- a/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h +++ b/Framework/DataHandling/test/SaveOpenGenieAsciiTest.h @@ -82,7 +82,7 @@ private: const std::string m_inputNexusFile{"SaveOpenGenieAsciiInput.nxs"}; std::unique_ptr<SaveOpenGenieAscii> - createAlg(MatrixWorkspace_sptr ws, const std::string &tempFilePath) { + createAlg(const MatrixWorkspace_sptr &ws, const std::string &tempFilePath) { auto alg = std::make_unique<SaveOpenGenieAscii>(); alg->initialize(); diff --git a/Framework/DataHandling/test/SavePDFGuiTest.h b/Framework/DataHandling/test/SavePDFGuiTest.h index 640d806e5c5159fe1e4bea05de68eecb6786d424..adea18d2e1b0ce8f715607b46b6a73a32e715d87 100644 --- a/Framework/DataHandling/test/SavePDFGuiTest.h +++ b/Framework/DataHandling/test/SavePDFGuiTest.h @@ -59,7 +59,7 @@ public: return n; } - bool loadWorkspace(const std::string &filename, const std::string wsName) { + bool loadWorkspace(const std::string &filename, const std::string &wsName) { LoadNexusProcessed load; load.initialize(); load.setProperty("Filename", filename); @@ -112,9 +112,6 @@ public: grpAlg->setPropertyValue("OutputWorkspace", groupName); grpAlg->execute(); - // name of the output file - const std::string outFilename("SavePDFGUIGroup.gr"); - // run the algorithm with a group SavePDFGui alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); diff --git a/Framework/DataHandling/test/SaveParameterFileTest.h b/Framework/DataHandling/test/SaveParameterFileTest.h index 503862706e651bf68bd6db02695c4e5b7816d84c..69616ee7242286f6a1717248a65d00869b484701 100644 --- a/Framework/DataHandling/test/SaveParameterFileTest.h +++ b/Framework/DataHandling/test/SaveParameterFileTest.h @@ -77,21 +77,23 @@ public: "linear ; TOF ; TOF"); } - void setParam(std::string cName, std::string pName, std::string value) { + void setParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addString(comp->getComponentID(), pName, value); } - void setParam(std::string cName, std::string pName, double value) { + void setParam(const std::string &cName, const std::string &pName, + double value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); paramMap.addDouble(comp->getComponentID(), pName, value); } - void setParamByDetID(int id, std::string pName, double value) { + void setParamByDetID(int id, const std::string &pName, double value) { ParameterMap ¶mMap = m_ws->instrumentParameters(); const auto &detectorInfo = m_ws->detectorInfo(); const auto detectorIndex = detectorInfo.indexOf(id); @@ -99,7 +101,8 @@ public: paramMap.addDouble(detector.getComponentID(), pName, value); } - void setFitParam(std::string cName, std::string pName, std::string value) { + void setFitParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -108,7 +111,8 @@ public: paramMap.add(comp.get(), param); } - void checkParam(std::string cName, std::string pName, std::string value) { + void checkParam(const std::string &cName, const std::string &pName, + std::string value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -116,7 +120,8 @@ public: TS_ASSERT_EQUALS(value, param); } - void checkParam(std::string cName, std::string pName, double value) { + void checkParam(const std::string &cName, const std::string &pName, + double value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -124,7 +129,7 @@ public: TS_ASSERT_DELTA(value, values.front(), 0.0001); } - void checkParamByDetID(int id, std::string pName, double value) { + void checkParamByDetID(int id, const std::string &pName, double value) { ParameterMap ¶mMap = m_ws->instrumentParameters(); const auto &detectorInfo = m_ws->detectorInfo(); const auto &detector = detectorInfo.detector(detectorInfo.indexOf(id)); @@ -133,7 +138,8 @@ public: TS_ASSERT_DELTA(value, pValue, 0.0001); } - void checkFitParam(std::string cName, std::string pName, std::string value) { + void checkFitParam(const std::string &cName, const std::string &pName, + const std::string &value) { Instrument_const_sptr inst = m_ws->getInstrument(); ParameterMap ¶mMap = m_ws->instrumentParameters(); boost::shared_ptr<const IComponent> comp = inst->getComponentByName(cName); @@ -150,7 +156,7 @@ public: TS_ASSERT_EQUALS(fitParam.getFormulaUnit(), values[8]); } - void loadParams(std::string filename) { + void loadParams(const std::string &filename) { LoadParameterFile loaderPF; TS_ASSERT_THROWS_NOTHING(loaderPF.initialize()); loaderPF.setPropertyValue("Filename", filename); @@ -159,7 +165,7 @@ public: TS_ASSERT(loaderPF.isExecuted()); } - void saveParams(std::string filename) { + void saveParams(const std::string &filename) { SaveParameterFile saverPF; TS_ASSERT_THROWS_NOTHING(saverPF.initialize()); saverPF.setPropertyValue("Filename", filename); diff --git a/Framework/DataHandling/test/SaveRMCProfileTest.h b/Framework/DataHandling/test/SaveRMCProfileTest.h index 5f46b3353c120b6d5ed0f13e9e2baeb1b5ac8572..89765159bfe1f60db60794c2ec88dbf8b2b5961b 100644 --- a/Framework/DataHandling/test/SaveRMCProfileTest.h +++ b/Framework/DataHandling/test/SaveRMCProfileTest.h @@ -59,7 +59,7 @@ public: return n; } - bool loadWorkspace(const std::string &filename, const std::string wsName) { + bool loadWorkspace(const std::string &filename, const std::string &wsName) { LoadNexusProcessed load; load.initialize(); load.setProperty("Filename", filename); diff --git a/Framework/DataHandling/test/SetSampleTest.h b/Framework/DataHandling/test/SetSampleTest.h index 62c3e08cf6dcc517ca29ef8bb9f117df56e847bd..8a7e80e2801fa9a8799b86215084b5e68bd0b84a 100644 --- a/Framework/DataHandling/test/SetSampleTest.h +++ b/Framework/DataHandling/test/SetSampleTest.h @@ -576,7 +576,8 @@ private: return false; } - void setTestReferenceFrame(Mantid::API::MatrixWorkspace_sptr workspace) { + void + setTestReferenceFrame(const Mantid::API::MatrixWorkspace_sptr &workspace) { using Mantid::Geometry::Instrument; using Mantid::Geometry::ReferenceFrame; // Use Z=up,Y=across,X=beam so we test it listens to the reference frame diff --git a/Framework/DataHandling/test/SetScalingPSDTest.h b/Framework/DataHandling/test/SetScalingPSDTest.h index 8494437615d762942c71e2c692636e6867dc5c03..63db0e059384b003d13116bcd19468331330692b 100644 --- a/Framework/DataHandling/test/SetScalingPSDTest.h +++ b/Framework/DataHandling/test/SetScalingPSDTest.h @@ -128,7 +128,7 @@ public: } private: - std::string createTestScalingFile(Workspace2D_sptr testWS) { + std::string createTestScalingFile(const Workspace2D_sptr &testWS) { // NOTE: The only values read by the algorithm are the number of detectors // and then from each detector line // det no., (l2,theta,phi). All other values will be set to -1 here diff --git a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h index d00bc48e599920c6f1b3e393cef63b783a113b57..f7ae6029178db8ecd996a98c8491064889e306eb 100644 --- a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h +++ b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h @@ -137,7 +137,6 @@ public: void test_DAT_Extension_Without_Header_Assumes_Detector_Calibration_File_And_Fails_If_Number_Of_Columns_Incorrect() { - const std::string colNames = "spectrum,theta,t0,-,R"; const std::string contents = "plik det t0 l0 l1\n" " 3 130.4653 -0.4157 11.0050 0.6708\n" " 4 131.9319 -0.5338 11.0050 0.6545"; diff --git a/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h b/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h index cb12678d079c8fdac9dcf5c01be3c81ba43f14f1..39c06e04c2c4987d13c85199f3f12b80a29ee18f 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h +++ b/Framework/DataObjects/inc/MantidDataObjects/AffineMatrixParameter.h @@ -29,7 +29,7 @@ public: bool isValid() const override; std::string toXMLString() const override; AffineMatrixParameter *clone() const override; - void setMatrix(const AffineMatrixType newMatrix); + void setMatrix(const AffineMatrixType &newMatrix); AffineMatrixParameter(size_t outD, size_t inD); AffineMatrixParameter(const AffineMatrixParameter &); AffineMatrixParameter &operator=(const AffineMatrixParameter &other); diff --git a/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h b/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h index 7c60f5c5befa1d542a8542f0a994c58a53b0caa5..1832b1dda3f5e086221ec4d0b86df0370ba7d3b1 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h +++ b/Framework/DataObjects/inc/MantidDataObjects/BoxControllerNeXusIO.h @@ -129,7 +129,7 @@ private: // get the event type from event name static EventType TypeFromString(const std::vector<std::string> &typesSupported, - const std::string typeName); + const std::string &typeName); /// the enum, which suggests the way (currently)two possible data types are /// converted to each other enum CoordConversion { diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventList.h b/Framework/DataObjects/inc/MantidDataObjects/EventList.h index a43e81ea0c950c5d45e3e9942ac8e65c6d00301c..f751a4e62955bf0061c48b416ccfc911486e43ce 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventList.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventList.h @@ -447,7 +447,7 @@ private: const double maxX, const bool entireRange); template <class T> void convertTofHelper(std::vector<T> &events, - std::function<double(double)> func); + const std::function<double(double)> &func); template <class T> void convertTofHelper(std::vector<T> &events, const double factor, diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h index b28ca1aab25bc87fcfb6ec0f986b4bdcfc3c631b..89d4c4fe1f736d4b3f2bfcbf95ac5d30449c1be4 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspaceHelpers.h @@ -20,7 +20,7 @@ namespace DataObjects { struct DLLExport EventWorkspaceHelpers { /// Converts an EventWorkspace to an equivalent Workspace2D. static API::MatrixWorkspace_sptr - convertEventTo2D(API::MatrixWorkspace_sptr inputMatrixW); + convertEventTo2D(const API::MatrixWorkspace_sptr &inputMatrixW); }; } // namespace DataObjects diff --git a/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h b/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h index 7f20411296476be893711eace572fe8dc2e01f74..2a3c9fdc44ef36b030237af44178b3a6726d9681 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h +++ b/Framework/DataObjects/inc/MantidDataObjects/FakeMD.h @@ -25,7 +25,7 @@ public: const std::vector<double> &peakParams, const int randomSeed, const bool randomizeSignal); - void fill(API::IMDEventWorkspace_sptr workspace); + void fill(const API::IMDEventWorkspace_sptr &workspace); private: void setupDetectorCache(const API::IMDEventWorkspace &workspace); diff --git a/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h b/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h index 266435f63a0eba132f77371ef883320651d318db..10f5d984973f784d655f8318ccccf53c33ea047f 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h +++ b/Framework/DataObjects/inc/MantidDataObjects/FractionalRebinning.h @@ -42,8 +42,8 @@ getIntersectionRegion(const std::vector<double> &xAxis, /// Compute sqrt of errors and put back in bin width division if necessary MANTID_DATAOBJECTS_DLL void -normaliseOutput(API::MatrixWorkspace_sptr outputWS, - API::MatrixWorkspace_const_sptr inputWS, +normaliseOutput(const API::MatrixWorkspace_sptr &outputWS, + const API::MatrixWorkspace_const_sptr &inputWS, API::Progress *progress = nullptr); /// Rebin the input quadrilateral to to output grid diff --git a/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h index 065866dd4bfbd4ea1a09c33c618a0bf5968adf7e..75c6291d90146383baa3f2cb8a44cb78fcdef80f 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/GroupingWorkspace.h @@ -25,7 +25,7 @@ namespace DataObjects { */ class DLLExport GroupingWorkspace : public SpecialWorkspace2D { public: - GroupingWorkspace(Geometry::Instrument_const_sptr inst); + GroupingWorkspace(const Geometry::Instrument_const_sptr &inst); GroupingWorkspace() = default; GroupingWorkspace(size_t numvectors); GroupingWorkspace &operator=(const GroupingWorkspace &) = delete; diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h b/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h index 8f7cf396a7d940d772bcb0ed281d48e03ec3da39..3527cca7f74aa0e9b07966bcf89532c9d181be79 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDBoxFlatTree.h @@ -47,7 +47,7 @@ public: //--------------------------------------------------------------------------------------------------------------------- /// convert MDWS box structure into flat structure used for saving/loading on /// hdd - void initFlatStructure(API::IMDEventWorkspace_sptr pws, + void initFlatStructure(const API::IMDEventWorkspace_sptr &pws, const std::string &fileName); uint64_t restoreBoxTree(std::vector<API::IMDNode *> &Boxes, @@ -118,26 +118,28 @@ public: // save each experiment info into its own NeXus group within an existing // opened group static void saveExperimentInfos(::NeXus::File *const file, - API::IMDEventWorkspace_const_sptr ws); + const API::IMDEventWorkspace_const_sptr &ws); // load experiment infos, previously saved through the the saveExperimentInfo // function - static void - loadExperimentInfos(::NeXus::File *const file, const std::string &filename, - boost::shared_ptr<API::MultipleExperimentInfos> mei, - bool lazy = false); + static void loadExperimentInfos( + ::NeXus::File *const file, const std::string &filename, + const boost::shared_ptr<API::MultipleExperimentInfos> &mei, + bool lazy = false); - static void saveAffineTransformMatricies(::NeXus::File *const file, - API::IMDWorkspace_const_sptr ws); + static void + saveAffineTransformMatricies(::NeXus::File *const file, + const API::IMDWorkspace_const_sptr &ws); static void saveAffineTransformMatrix(::NeXus::File *const file, API::CoordTransform const *transform, - std::string entry_name); + const std::string &entry_name); static void saveWSGenericInfo(::NeXus::File *const file, - API::IMDWorkspace_const_sptr ws); + const API::IMDWorkspace_const_sptr &ws); }; template <typename T> -void saveMatrix(::NeXus::File *const file, std::string name, - Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, std::string tag); +void saveMatrix(::NeXus::File *const file, const std::string &name, + Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, + const std::string &tag); } // namespace DataObjects } // namespace Mantid \ No newline at end of file diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h b/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h index 813ae7a9d2d88b674e73b2c1d1ab036c8335825a..c6e9884b53da8170e4c03ef6eeaf2d93a2e5e4bf 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDFramesToSpecialCoordinateSystem.h @@ -27,8 +27,8 @@ private: Mantid::Kernel::SpecialCoordinateSystem specialCoordinateSystem, boost::optional<Mantid::Kernel::SpecialCoordinateSystem> qFrameType) const; - bool - isUnknownFrame(Mantid::Geometry::IMDDimension_const_sptr dimension) const; + bool isUnknownFrame( + const Mantid::Geometry::IMDDimension_const_sptr &dimension) const; }; } // namespace DataObjects diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h index 6d46b5ea36f42041cc773f0b1c70c8a1c50870e8..4271118b885f973ab3513f6bbb54c33f12dcf291 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h @@ -91,7 +91,8 @@ public: const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const override; - void checkWorkspaceSize(const MDHistoWorkspace &other, std::string operation); + void checkWorkspaceSize(const MDHistoWorkspace &other, + const std::string &operation); // -------------------------------------------------------------------------------------------- MDHistoWorkspace &operator+=(const MDHistoWorkspace &b); diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h index ff5dab5ccea0f42e730d6db79dfbe7968ee5eafa..6b0bd4ee5debcad7b572334d399a0bc6bdd115de 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h @@ -38,7 +38,8 @@ using VecMDExtents = std::vector<MDExtentPair>; class DLLExport MDHistoWorkspaceIterator : public Mantid::API::IMDIterator { public: MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, SkippingPolicy *skippingPolicy, + const MDHistoWorkspace_const_sptr &workspace, + SkippingPolicy *skippingPolicy, Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0, size_t endPos = size_t(-1)); MDHistoWorkspaceIterator( @@ -46,7 +47,7 @@ public: Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0, size_t endPos = size_t(-1)); MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, + const MDHistoWorkspace_const_sptr &workspace, Mantid::Geometry::MDImplicitFunction *function = nullptr, size_t beginPos = 0, size_t endPos = size_t(-1)); MDHistoWorkspaceIterator( diff --git a/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h index 001d798283b2aaceff967da83ceda741ccb5ce58..590f0f050c5def9c2291277865ed56ba6b179a35 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MaskWorkspace.h @@ -20,9 +20,9 @@ class DLLExport MaskWorkspace : public SpecialWorkspace2D, public: MaskWorkspace() = default; MaskWorkspace(std::size_t numvectors); - MaskWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, + MaskWorkspace(const Mantid::Geometry::Instrument_const_sptr &instrument, const bool includeMonitors = false); - MaskWorkspace(const API::MatrixWorkspace_const_sptr parent); + MaskWorkspace(const API::MatrixWorkspace_const_sptr &parent); /// Returns a clone of the workspace std::unique_ptr<MaskWorkspace> clone() const { diff --git a/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h index 081f2361573c7af25db9f6f347644de1dabd9679..cc57d2f8a04c95b68097ab7e399019d196e51819 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MementoTableWorkspace.h @@ -48,8 +48,8 @@ private: return new MementoTableWorkspace(); } - static bool expectedColumn(Mantid::API::Column_const_sptr expected, - Mantid::API::Column_const_sptr candidate); + static bool expectedColumn(const Mantid::API::Column_const_sptr &expected, + const Mantid::API::Column_const_sptr &candidate); }; } // namespace DataObjects } // namespace Mantid diff --git a/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h index 26094b9a5e8a02d7b971a451bfeb58ee92b5117b..9e6418697e9f63f2e6641ada3f8e9ff784e73088 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/OffsetsWorkspace.h @@ -24,7 +24,7 @@ namespace DataObjects { class DLLExport OffsetsWorkspace : public SpecialWorkspace2D { public: OffsetsWorkspace() = default; - OffsetsWorkspace(Geometry::Instrument_const_sptr inst); + OffsetsWorkspace(const Geometry::Instrument_const_sptr &inst); /// Returns a clone of the workspace std::unique_ptr<OffsetsWorkspace> clone() const { diff --git a/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h b/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h index fd2eb58b025d08bd5aa633f284911a063c28f20c..5a80a5b485e857d69f9c61d08e4e840125ac1848 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h +++ b/Framework/DataObjects/inc/MantidDataObjects/ReflectometryTransform.h @@ -58,29 +58,30 @@ protected: mutable std::vector<double> m_thetaWidths; boost::shared_ptr<DataObjects::MDEventWorkspace2Lean> - createMDWorkspace(Geometry::IMDDimension_sptr, Geometry::IMDDimension_sptr, - API::BoxController_sptr boxController) const; + createMDWorkspace(const Geometry::IMDDimension_sptr &, + const Geometry::IMDDimension_sptr &, + const API::BoxController_sptr &boxController) const; public: // Execute the strategy to produce a transformed, output MDWorkspace Mantid::API::IMDEventWorkspace_sptr - executeMD(Mantid::API::MatrixWorkspace_const_sptr inputWs, - Mantid::API::BoxController_sptr boxController, + executeMD(const Mantid::API::MatrixWorkspace_const_sptr &inputWs, + const Mantid::API::BoxController_sptr &boxController, Mantid::Geometry::MDFrame_uptr frame) const; // Execute the strategy to produce a transformed, output group of Matrix (2D) // Workspaces Mantid::API::MatrixWorkspace_sptr - execute(Mantid::API::MatrixWorkspace_const_sptr inputWs) const; + execute(const Mantid::API::MatrixWorkspace_const_sptr &inputWs) const; /// Execuate transformation using normalised polynomial binning Mantid::API::MatrixWorkspace_sptr executeNormPoly( const Mantid::API::MatrixWorkspace_const_sptr &inputWS, boost::shared_ptr<Mantid::DataObjects::TableWorkspace> &vertexes, - bool dumpVertexes, std::string outputDimensions) const; + bool dumpVertexes, const std::string &outputDimensions) const; - Mantid::API::IMDHistoWorkspace_sptr - executeMDNormPoly(Mantid::API::MatrixWorkspace_const_sptr inputWs) const; + Mantid::API::IMDHistoWorkspace_sptr executeMDNormPoly( + const Mantid::API::MatrixWorkspace_const_sptr &inputWs) const; virtual ~ReflectometryTransform() = default; ReflectometryTransform(const std::string &d0Label, const std::string &d0ID, double d0Min, double d0Max, const std::string &d1Label, diff --git a/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h b/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h index 511f05d599a54ee2fbd284b02b524771e966d0b1..a27600d5cd9fdb73ade236179c0a4c7f698f5eee 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h +++ b/Framework/DataObjects/inc/MantidDataObjects/SpecialWorkspace2D.h @@ -31,9 +31,9 @@ public: class DLLExport SpecialWorkspace2D : public Workspace2D { public: SpecialWorkspace2D() = default; - SpecialWorkspace2D(Geometry::Instrument_const_sptr inst, + SpecialWorkspace2D(const Geometry::Instrument_const_sptr &inst, const bool includeMonitors = false); - SpecialWorkspace2D(API::MatrixWorkspace_const_sptr parent); + SpecialWorkspace2D(const API::MatrixWorkspace_const_sptr &parent); /// Returns a clone of the workspace std::unique_ptr<SpecialWorkspace2D> clone() const { @@ -73,7 +73,7 @@ private: SpecialWorkspace2D *doCloneEmpty() const override { return new SpecialWorkspace2D(); } - bool isCompatible(boost::shared_ptr<const SpecialWorkspace2D> ws); + bool isCompatible(const boost::shared_ptr<const SpecialWorkspace2D> &ws); protected: /// Protected copy constructor. May be used by childs for cloning. @@ -86,9 +86,9 @@ protected: /// Return human-readable string const std::string toString() const override; - void binaryAND(boost::shared_ptr<const SpecialWorkspace2D> ws); - void binaryOR(boost::shared_ptr<const SpecialWorkspace2D> ws); - void binaryXOR(boost::shared_ptr<const SpecialWorkspace2D> ws); + void binaryAND(const boost::shared_ptr<const SpecialWorkspace2D> &ws); + void binaryOR(const boost::shared_ptr<const SpecialWorkspace2D> &ws); + void binaryXOR(const boost::shared_ptr<const SpecialWorkspace2D> &ws); void binaryNOT(); /// Map with key = detector ID, and value = workspace index. diff --git a/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h b/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h index 212b83118e4a1514413af057ed81528ce3c13492..3a9ab90425009e934f9872764dbed5af69a59863 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h +++ b/Framework/DataObjects/inc/MantidDataObjects/TableColumn.h @@ -556,7 +556,7 @@ public: /** Constructor @param c :: Shared pointer to a column */ - TableColumn_ptr(boost::shared_ptr<API::Column> c) + TableColumn_ptr(const boost::shared_ptr<API::Column> &c) : TableColumn_ptr<API::Boolean>(c) { if (!this->get()) { std::string str = "Data type of column " + c->name() + diff --git a/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h index 0298ac46efd0097b68f5411d952eb167ca178715..026ccd6688f9659566560ea4250493c061c4bae5 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/TableWorkspace.h @@ -17,6 +17,21 @@ #include "MantidKernel/V3D.h" #include <boost/shared_ptr.hpp> #include <boost/tuple/tuple.hpp> +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> + +#include <utility> namespace Mantid { @@ -321,7 +336,7 @@ private: } } - void addColumn(boost::shared_ptr<API::Column> column); + void addColumn(const boost::shared_ptr<API::Column> &column); /** This method finds the row and column index of an integer cell value in a * table workspace @@ -339,7 +354,9 @@ private: * @param col column number of the value searched */ virtual void find(std::string value, size_t &row, size_t &col) { - findValue(value, row, col); + findValue(std::move(std::move(std::move(std::move( + std::move(std::move(std::move(std::move(value)))))))), + row, col); } /** This method finds the row and column index of an float value in a table * workspace diff --git a/Framework/DataObjects/src/AffineMatrixParameter.cpp b/Framework/DataObjects/src/AffineMatrixParameter.cpp index a4d7c95a0666ef3d4c1b8cc4ee6ae61f941222cf..5cc5b9c7b5cb928866d69678986fe7c37a431668 100644 --- a/Framework/DataObjects/src/AffineMatrixParameter.cpp +++ b/Framework/DataObjects/src/AffineMatrixParameter.cpp @@ -162,7 +162,7 @@ AffineMatrixParameter::AffineMatrixParameter(const AffineMatrixParameter &other) * * @param newMatrix : new matrix to use. */ -void AffineMatrixParameter::setMatrix(const AffineMatrixType newMatrix) { +void AffineMatrixParameter::setMatrix(const AffineMatrixType &newMatrix) { if (newMatrix.numRows() != this->m_affineMatrix.numRows()) throw std::runtime_error("setMatrix(): Number of rows must match!"); if (newMatrix.numCols() != this->m_affineMatrix.numCols()) diff --git a/Framework/DataObjects/src/BoxControllerNeXusIO.cpp b/Framework/DataObjects/src/BoxControllerNeXusIO.cpp index aec923188e338fd99e9805e07ea8284183943f51..25d6f75416e3bd7f704a4561914190c9113d53f8 100644 --- a/Framework/DataObjects/src/BoxControllerNeXusIO.cpp +++ b/Framework/DataObjects/src/BoxControllerNeXusIO.cpp @@ -48,7 +48,7 @@ BoxControllerNeXusIO::BoxControllerNeXusIO(API::BoxController *const bc) /**get event type form its string representation*/ BoxControllerNeXusIO::EventType BoxControllerNeXusIO::TypeFromString( const std::vector<std::string> &typesSupported, - const std::string typeName) { + const std::string &typeName) { auto it = std::find(typesSupported.begin(), typesSupported.end(), typeName); if (it == typesSupported.end()) throw std::invalid_argument("Unsupported event type: " + typeName + diff --git a/Framework/DataObjects/src/EventList.cpp b/Framework/DataObjects/src/EventList.cpp index 8cbaf1a19d17bb44709ab56480ad6c2e7b0d3464..918f0d08e849259247c968e22a15c7630ec892e7 100644 --- a/Framework/DataObjects/src/EventList.cpp +++ b/Framework/DataObjects/src/EventList.cpp @@ -2555,7 +2555,7 @@ void EventList::convertTof(std::function<double(double)> func, */ template <class T> void EventList::convertTofHelper(std::vector<T> &events, - std::function<double(double)> func) { + const std::function<double(double)> &func) { // iterate through all events for (auto &ev : events) ev.m_tof = func(ev.m_tof); diff --git a/Framework/DataObjects/src/EventWorkspaceHelpers.cpp b/Framework/DataObjects/src/EventWorkspaceHelpers.cpp index 54ebeea522d100788e987e1b54af4f355965f8d3..edcc382d398d66eb02bd9c5d08facbf135ee1e06 100644 --- a/Framework/DataObjects/src/EventWorkspaceHelpers.cpp +++ b/Framework/DataObjects/src/EventWorkspaceHelpers.cpp @@ -20,8 +20,8 @@ namespace DataObjects { * @param inputMatrixW :: input event workspace * @return a MatrixWorkspace_sptr */ -MatrixWorkspace_sptr -EventWorkspaceHelpers::convertEventTo2D(MatrixWorkspace_sptr inputMatrixW) { +MatrixWorkspace_sptr EventWorkspaceHelpers::convertEventTo2D( + const MatrixWorkspace_sptr &inputMatrixW) { EventWorkspace_sptr inputW = boost::dynamic_pointer_cast<EventWorkspace>(inputMatrixW); if (!inputW) diff --git a/Framework/DataObjects/src/FakeMD.cpp b/Framework/DataObjects/src/FakeMD.cpp index a47360524f4fdbd196a2480321f3a3b500135974..bd3ffa4ae22199f46953d644fb216a2845733721 100644 --- a/Framework/DataObjects/src/FakeMD.cpp +++ b/Framework/DataObjects/src/FakeMD.cpp @@ -49,7 +49,7 @@ FakeMD::FakeMD(const std::vector<double> &uniformParams, * @param workspace A pointer to MD event workspace to fill using the object * parameters */ -void FakeMD::fill(API::IMDEventWorkspace_sptr workspace) { +void FakeMD::fill(const API::IMDEventWorkspace_sptr &workspace) { setupDetectorCache(*workspace); CALL_MDEVENT_FUNCTION(this->addFakePeak, workspace) diff --git a/Framework/DataObjects/src/FractionalRebinning.cpp b/Framework/DataObjects/src/FractionalRebinning.cpp index f2b3a3057f17e6c3d99d866a7de22f40250d598c..0b5aee3aec784ae5146cafddbe061e8f30821125 100644 --- a/Framework/DataObjects/src/FractionalRebinning.cpp +++ b/Framework/DataObjects/src/FractionalRebinning.cpp @@ -495,8 +495,9 @@ void calcGeneralIntersections(const std::vector<double> &xAxis, * @param inputWS The input workspace used for testing distribution state * @param progress An optional progress object. Reported to once per bin. */ -void normaliseOutput(MatrixWorkspace_sptr outputWS, - MatrixWorkspace_const_sptr inputWS, Progress *progress) { +void normaliseOutput(const MatrixWorkspace_sptr &outputWS, + const MatrixWorkspace_const_sptr &inputWS, + Progress *progress) { const bool removeBinWidth(inputWS->isDistribution() && outputWS->id() != "RebinnedOutput"); for (size_t i = 0; i < outputWS->getNumberHistograms(); ++i) { diff --git a/Framework/DataObjects/src/GroupingWorkspace.cpp b/Framework/DataObjects/src/GroupingWorkspace.cpp index 872c9b182cd3f2160c6490ff6f294719d7b80ede..ee76a32caaa78a62e39e56d0befc47027b115131 100644 --- a/Framework/DataObjects/src/GroupingWorkspace.cpp +++ b/Framework/DataObjects/src/GroupingWorkspace.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataObjects/GroupingWorkspace.h" +#include <utility> + #include "MantidAPI/SpectraAxis.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/GroupingWorkspace.h" #include "MantidKernel/IPropertyManager.h" #include "MantidKernel/System.h" @@ -33,8 +35,9 @@ GroupingWorkspace::GroupingWorkspace(size_t numvectors) { * @param inst :: input instrument that is the base for this workspace * @return created GroupingWorkspace */ -GroupingWorkspace::GroupingWorkspace(Geometry::Instrument_const_sptr inst) - : SpecialWorkspace2D(inst) {} +GroupingWorkspace::GroupingWorkspace( + const Geometry::Instrument_const_sptr &inst) + : SpecialWorkspace2D(std::move(inst)) {} //---------------------------------------------------------------------------------------------- /** Fill a map with key = detector ID, value = group number diff --git a/Framework/DataObjects/src/MDBoxFlatTree.cpp b/Framework/DataObjects/src/MDBoxFlatTree.cpp index 06520cb314cdf4eefd6046fc643e9f57972224b9..7984ef15c55648e66a3bd5056ff76f7d1501e6b9 100644 --- a/Framework/DataObjects/src/MDBoxFlatTree.cpp +++ b/Framework/DataObjects/src/MDBoxFlatTree.cpp @@ -14,6 +14,8 @@ #include "MantidKernel/Strings.h" #include <Poco/File.h> +#include <utility> + using file_holder_type = std::unique_ptr<::NeXus::File>; namespace Mantid { @@ -33,7 +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(API::IMDEventWorkspace_sptr pws, +void MDBoxFlatTree::initFlatStructure(const API::IMDEventWorkspace_sptr &pws, const std::string &fileName) { m_bcXMLDescr = pws->getBoxController()->toXMLString(); m_FileName = fileName; @@ -353,8 +355,8 @@ 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, - 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,7 +408,8 @@ void MDBoxFlatTree::saveExperimentInfos(::NeXus::File *const file, */ void MDBoxFlatTree::loadExperimentInfos( ::NeXus::File *const file, const std::string &filename, - boost::shared_ptr<Mantid::API::MultipleExperimentInfos> mei, bool lazy) { + const boost::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); @@ -748,7 +751,7 @@ 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, - API::IMDWorkspace_const_sptr ws) { + const API::IMDWorkspace_const_sptr &ws) { // Write out the coordinate system file->writeData("coordinate_system", static_cast<uint32_t>(ws->getSpecialCoordinateSystem())); @@ -794,7 +797,7 @@ void MDBoxFlatTree::saveWSGenericInfo(::NeXus::File *const file, * @param ws : workspace to get matrix from */ void MDBoxFlatTree::saveAffineTransformMatricies( - ::NeXus::File *const file, API::IMDWorkspace_const_sptr ws) { + ::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws) { try { saveAffineTransformMatrix(file, ws->getTransformToOriginal(), "transform_to_orig"); @@ -816,12 +819,12 @@ void MDBoxFlatTree::saveAffineTransformMatricies( */ void MDBoxFlatTree::saveAffineTransformMatrix( ::NeXus::File *const file, API::CoordTransform const *transform, - std::string entry_name) { + 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, entry_name, matrix, ::NeXus::FLOAT32, + saveMatrix<coord_t>(file, std::move(entry_name), matrix, ::NeXus::FLOAT32, transform->id()); } @@ -834,9 +837,9 @@ void MDBoxFlatTree::saveAffineTransformMatrix( * @param tag : id for an affine matrix conversion */ template <typename T> -void saveMatrix(::NeXus::File *const file, std::string name, +void saveMatrix(::NeXus::File *const file, const std::string &name, Kernel::Matrix<T> &m, ::NeXus::NXnumtype type, - std::string tag) { + const std::string &tag) { std::vector<T> v = m.getVector(); // Number of data points auto nPoints = static_cast<int>(v.size()); diff --git a/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp b/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp index 397258fde7584b7582662e09a478e36d1b0738fc..2f1fd3fe91c0cee5e1e1f126145c902e9af1098d 100644 --- a/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp +++ b/Framework/DataObjects/src/MDFramesToSpecialCoordinateSystem.cpp @@ -92,7 +92,7 @@ void MDFramesToSpecialCoordinateSystem::checkQCompatibility( * @returns true if the MDFrame is of UnknownFrame type. */ bool MDFramesToSpecialCoordinateSystem::isUnknownFrame( - Mantid::Geometry::IMDDimension_const_sptr dimension) const { + const Mantid::Geometry::IMDDimension_const_sptr &dimension) const { Mantid::Geometry::MDFrame_uptr replica(dimension->getMDFrame().clone()); auto isUnknown = false; if (dynamic_cast<Mantid::Geometry::UnknownFrame *>(replica.get())) { diff --git a/Framework/DataObjects/src/MDHistoWorkspace.cpp b/Framework/DataObjects/src/MDHistoWorkspace.cpp index 847ab87165e3715b1f05152851446d81d4330953..b26d2cae3ff61712a88974828c8d130bdd127ea3 100644 --- a/Framework/DataObjects/src/MDHistoWorkspace.cpp +++ b/Framework/DataObjects/src/MDHistoWorkspace.cpp @@ -737,7 +737,7 @@ MDHistoWorkspace::getBinBoundariesOnLine(const VMD &start, const VMD &end, * @throw an error if they don't match */ void MDHistoWorkspace::checkWorkspaceSize(const MDHistoWorkspace &other, - std::string operation) { + const std::string &operation) { if (other.getNumDims() != this->getNumDims()) throw std::invalid_argument("Cannot perform the " + operation + " operation on this MDHistoWorkspace. The " diff --git a/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp b/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp index 43f529b3fee1c934029768591c8aa36d7b1176f2..d93a52bb004c59e7f80947ae4840a1dae3d38fea 100644 --- a/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp +++ b/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp @@ -90,7 +90,7 @@ namespace DataObjects { * @param endPos :: end position */ MDHistoWorkspaceIterator::MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, + const MDHistoWorkspace_const_sptr &workspace, Mantid::Geometry::MDImplicitFunction *function, size_t beginPos, size_t endPos) : m_skippingPolicy(new SkipMaskedBins(this)) { @@ -123,7 +123,8 @@ MDHistoWorkspaceIterator::MDHistoWorkspaceIterator( * @param endPos :: End position */ MDHistoWorkspaceIterator::MDHistoWorkspaceIterator( - MDHistoWorkspace_const_sptr workspace, SkippingPolicy *skippingPolicy, + const MDHistoWorkspace_const_sptr &workspace, + SkippingPolicy *skippingPolicy, Mantid::Geometry::MDImplicitFunction *function, size_t beginPos, size_t endPos) : m_skippingPolicy(skippingPolicy) { diff --git a/Framework/DataObjects/src/MaskWorkspace.cpp b/Framework/DataObjects/src/MaskWorkspace.cpp index d2a3828e70abc36fa78fd6ca9f2985152fa8367a..07944ba17974fa461c3c9e843cd23a724f9b712c 100644 --- a/Framework/DataObjects/src/MaskWorkspace.cpp +++ b/Framework/DataObjects/src/MaskWorkspace.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataObjects/MaskWorkspace.h" +#include <utility> + #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/MaskWorkspace.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/IPropertyManager.h" #include "MantidKernel/System.h" @@ -51,9 +53,10 @@ MaskWorkspace::MaskWorkspace(std::size_t numvectors) { * workspace. * @return MaskWorkspace */ -MaskWorkspace::MaskWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, - const bool includeMonitors) - : SpecialWorkspace2D(instrument, includeMonitors) { +MaskWorkspace::MaskWorkspace( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const bool includeMonitors) + : SpecialWorkspace2D(std::move(instrument), includeMonitors) { this->clearMask(); } @@ -63,7 +66,7 @@ MaskWorkspace::MaskWorkspace(Mantid::Geometry::Instrument_const_sptr instrument, * It must have an instrument. * @return MaskWorkspace */ -MaskWorkspace::MaskWorkspace(const API::MatrixWorkspace_const_sptr parent) +MaskWorkspace::MaskWorkspace(const API::MatrixWorkspace_const_sptr &parent) : SpecialWorkspace2D(parent) { this->clearMask(); } diff --git a/Framework/DataObjects/src/MementoTableWorkspace.cpp b/Framework/DataObjects/src/MementoTableWorkspace.cpp index 6340f564daaf931deb360a419d5e6db5722fc3b2..432172802dad8cfa6f04e3cd754514dc78a3f729 100644 --- a/Framework/DataObjects/src/MementoTableWorkspace.cpp +++ b/Framework/DataObjects/src/MementoTableWorkspace.cpp @@ -22,8 +22,8 @@ Determines whether the provided column has the same name and type as expected. @return true if all expectations are met. */ bool MementoTableWorkspace::expectedColumn( - Mantid::API::Column_const_sptr expected, - Mantid::API::Column_const_sptr candidate) { + const Mantid::API::Column_const_sptr &expected, + const Mantid::API::Column_const_sptr &candidate) { if (expected->name() != candidate->name()) { return false; } else if (expected->type() != candidate->type()) { diff --git a/Framework/DataObjects/src/OffsetsWorkspace.cpp b/Framework/DataObjects/src/OffsetsWorkspace.cpp index 59ce23307836f43a6d526a7d2dfac145a9e0a6c7..c053f57c95ee98c28706255f3652fa96f109e611 100644 --- a/Framework/DataObjects/src/OffsetsWorkspace.cpp +++ b/Framework/DataObjects/src/OffsetsWorkspace.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidDataObjects/OffsetsWorkspace.h" +#include <utility> + #include "MantidAPI/SpectraAxis.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidDataObjects/OffsetsWorkspace.h" #include "MantidKernel/IPropertyManager.h" #include "MantidKernel/System.h" @@ -21,8 +23,8 @@ DECLARE_WORKSPACE(OffsetsWorkspace) * @param inst :: input instrument that is the base for this workspace * @return created OffsetsWorkspace */ -OffsetsWorkspace::OffsetsWorkspace(Geometry::Instrument_const_sptr inst) - : SpecialWorkspace2D(inst) {} +OffsetsWorkspace::OffsetsWorkspace(const Geometry::Instrument_const_sptr &inst) + : SpecialWorkspace2D(std::move(inst)) {} } // namespace DataObjects } // namespace Mantid diff --git a/Framework/DataObjects/src/Peak.cpp b/Framework/DataObjects/src/Peak.cpp index 26a71c49d41cb1cbf64772049d1a0639bdf48f79..a4829a2c3c936d5c8e0733813131526e0212ac31 100644 --- a/Framework/DataObjects/src/Peak.cpp +++ b/Framework/DataObjects/src/Peak.cpp @@ -20,6 +20,7 @@ #include <algorithm> #include <cctype> #include <string> +#include <utility> using namespace Mantid; using namespace Mantid::Kernel; @@ -60,7 +61,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); - this->setQLabFrame(QLabFrame, detectorDistance); + this->setQLabFrame(QLabFrame, std::move(detectorDistance)); } //---------------------------------------------------------------------------------------------- @@ -90,7 +91,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, throw std::invalid_argument( "Peak::ctor(): Goniometer matrix must non-singular."); this->setInstrument(m_inst); - this->setQSampleFrame(QSampleFrame, detectorDistance); + this->setQSampleFrame(QSampleFrame, std::move(detectorDistance)); } //---------------------------------------------------------------------------------------------- @@ -779,7 +780,7 @@ void Peak::setL(double m_L) { this->m_L = m_L; } /** Set the BankName of this peak * @param m_bankName :: index to set */ void Peak::setBankName(std::string m_bankName) { - this->m_bankName = m_bankName; + this->m_bankName = std::move(m_bankName); } /** Set all three H,K,L indices of the peak */ diff --git a/Framework/DataObjects/src/PeakShapeBase.cpp b/Framework/DataObjects/src/PeakShapeBase.cpp index d70e2601c6252c9fba5233b9a539b73d09df60c4..8845e3b7d64fb03190128c0d000bf684476149ee 100644 --- a/Framework/DataObjects/src/PeakShapeBase.cpp +++ b/Framework/DataObjects/src/PeakShapeBase.cpp @@ -8,12 +8,14 @@ #include "MantidKernel/SpecialCoordinateSystem.h" #include <json/json.h> +#include <utility> + namespace Mantid { namespace DataObjects { PeakShapeBase::PeakShapeBase(Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : m_frame(frame), m_algorithmName(algorithmName), + : m_frame(frame), m_algorithmName(std::move(algorithmName)), m_algorithmVersion(algorithmVersion) {} /** diff --git a/Framework/DataObjects/src/PeakShapeEllipsoid.cpp b/Framework/DataObjects/src/PeakShapeEllipsoid.cpp index 08dadf5172e5df47a344fd33acdafbfa0bdc8ecb..07ece5fe3ccafddee39e548b8605555190eb0d1b 100644 --- a/Framework/DataObjects/src/PeakShapeEllipsoid.cpp +++ b/Framework/DataObjects/src/PeakShapeEllipsoid.cpp @@ -8,6 +8,8 @@ #include "MantidKernel/cow_ptr.h" #include <json/json.h> +#include <utility> + namespace Mantid { namespace DataObjects { @@ -18,7 +20,7 @@ PeakShapeEllipsoid::PeakShapeEllipsoid( const std::vector<double> &abcRadiiBackgroundOuter, Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : PeakShapeBase(frame, algorithmName, algorithmVersion), + : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_directions(directions), m_abc_radii(abcRadii), m_abc_radiiBackgroundInner(abcRadiiBackgroundInner), m_abc_radiiBackgroundOuter(abcRadiiBackgroundOuter) { diff --git a/Framework/DataObjects/src/PeakShapeSpherical.cpp b/Framework/DataObjects/src/PeakShapeSpherical.cpp index b8c0b52801c5f3abf7dbe096ca4db4955a84307f..b81814575802d1535ca5299197e001352950a214 100644 --- a/Framework/DataObjects/src/PeakShapeSpherical.cpp +++ b/Framework/DataObjects/src/PeakShapeSpherical.cpp @@ -7,6 +7,7 @@ #include "MantidDataObjects/PeakShapeSpherical.h" #include <json/json.h> #include <stdexcept> +#include <utility> namespace Mantid { namespace DataObjects { @@ -22,7 +23,7 @@ PeakShapeSpherical::PeakShapeSpherical(const double &peakRadius, Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : PeakShapeBase(frame, algorithmName, algorithmVersion), + : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_radius(peakRadius) {} /** @@ -40,7 +41,7 @@ PeakShapeSpherical::PeakShapeSpherical(const double &peakRadius, Kernel::SpecialCoordinateSystem frame, std::string algorithmName, int algorithmVersion) - : PeakShapeBase(frame, algorithmName, algorithmVersion), + : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_radius(peakRadius), m_backgroundInnerRadius(peakInnerRadius), m_backgroundOuterRadius(peakOuterRadius) { if (peakRadius == m_backgroundInnerRadius) { diff --git a/Framework/DataObjects/src/ReflectometryTransform.cpp b/Framework/DataObjects/src/ReflectometryTransform.cpp index 22dbfe514bdb92a206908ae5094c1a4bbd765909..ff876f436d7840effe4a666d11b67e0f4c0be90e 100644 --- a/Framework/DataObjects/src/ReflectometryTransform.cpp +++ b/Framework/DataObjects/src/ReflectometryTransform.cpp @@ -31,6 +31,7 @@ #include "MantidKernel/VectorHelper.h" #include <boost/shared_ptr.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -125,13 +126,13 @@ ReflectometryTransform::ReflectometryTransform( */ boost::shared_ptr<MDEventWorkspace2Lean> ReflectometryTransform::createMDWorkspace( - Mantid::Geometry::IMDDimension_sptr a, - Mantid::Geometry::IMDDimension_sptr b, - BoxController_sptr boxController) const { + const Mantid::Geometry::IMDDimension_sptr &a, + const Mantid::Geometry::IMDDimension_sptr &b, + const BoxController_sptr &boxController) const { auto ws = boost::make_shared<MDEventWorkspace2Lean>(); - ws->addDimension(a); - ws->addDimension(b); + ws->addDimension(std::move(a)); + ws->addDimension(std::move(b)); BoxController_sptr wsbc = ws->getBoxController(); // Get the box controller wsbc->setSplitInto(boxController->getSplitInto(0)); @@ -280,8 +281,8 @@ DetectorAngularCache initAngularCaches(const MatrixWorkspace *const workspace) { * @returns An MDWorkspace based on centre-point rebinning of the inputWS */ Mantid::API::IMDEventWorkspace_sptr ReflectometryTransform::executeMD( - Mantid::API::MatrixWorkspace_const_sptr inputWs, - BoxController_sptr boxController, + const Mantid::API::MatrixWorkspace_const_sptr &inputWs, + const BoxController_sptr &boxController, Mantid::Geometry::MDFrame_uptr frame) const { auto dim0 = boost::make_shared<MDHistoDimension>( m_d0Label, m_d0ID, *frame, static_cast<Mantid::coord_t>(m_d0Min), @@ -290,7 +291,7 @@ Mantid::API::IMDEventWorkspace_sptr ReflectometryTransform::executeMD( m_d1Label, m_d1ID, *frame, static_cast<Mantid::coord_t>(m_d1Min), static_cast<Mantid::coord_t>(m_d1Max), m_d1NumBins); - auto ws = createMDWorkspace(dim0, dim1, boxController); + auto ws = createMDWorkspace(dim0, dim1, std::move(boxController)); auto spectraAxis = inputWs->getAxis(1); for (size_t index = 0; index < inputWs->getNumberHistograms(); ++index) { @@ -324,7 +325,7 @@ Mantid::API::IMDEventWorkspace_sptr ReflectometryTransform::executeMD( * @return workspace group containing output matrix workspaces of ki and kf */ Mantid::API::MatrixWorkspace_sptr ReflectometryTransform::execute( - Mantid::API::MatrixWorkspace_const_sptr inputWs) const { + const Mantid::API::MatrixWorkspace_const_sptr &inputWs) const { auto ws = boost::make_shared<Mantid::DataObjects::Workspace2D>(); ws->initialize(m_d1NumBins, m_d0NumBins, @@ -380,7 +381,7 @@ Mantid::API::MatrixWorkspace_sptr ReflectometryTransform::execute( } IMDHistoWorkspace_sptr ReflectometryTransform::executeMDNormPoly( - MatrixWorkspace_const_sptr inputWs) const { + const MatrixWorkspace_const_sptr &inputWs) const { auto input_x_dim = inputWs->getXDimension(); @@ -428,7 +429,7 @@ IMDHistoWorkspace_sptr ReflectometryTransform::executeMDNormPoly( MatrixWorkspace_sptr ReflectometryTransform::executeNormPoly( const MatrixWorkspace_const_sptr &inputWS, boost::shared_ptr<Mantid::DataObjects::TableWorkspace> &vertexes, - bool dumpVertexes, std::string outputDimensions) const { + bool dumpVertexes, const std::string &outputDimensions) const { MatrixWorkspace_sptr temp = WorkspaceFactory::Instance().create( "RebinnedOutput", m_d1NumBins, m_d0NumBins + 1, m_d0NumBins); RebinnedOutput_sptr outWS = boost::static_pointer_cast<RebinnedOutput>(temp); diff --git a/Framework/DataObjects/src/SpecialWorkspace2D.cpp b/Framework/DataObjects/src/SpecialWorkspace2D.cpp index b347bdbcc43228a69811246729278d402956858b..915bffb65a17304a95fdcf0066b65ee6b51b4a0a 100644 --- a/Framework/DataObjects/src/SpecialWorkspace2D.cpp +++ b/Framework/DataObjects/src/SpecialWorkspace2D.cpp @@ -32,8 +32,8 @@ DECLARE_WORKSPACE(SpecialWorkspace2D) * @param includeMonitors :: If false the monitors are not included * @return created SpecialWorkspace2D */ -SpecialWorkspace2D::SpecialWorkspace2D(Geometry::Instrument_const_sptr inst, - const bool includeMonitors) { +SpecialWorkspace2D::SpecialWorkspace2D( + const Geometry::Instrument_const_sptr &inst, const bool includeMonitors) { // Init the Workspace2D with one spectrum per detector, in the same order. this->initialize(inst->getNumberDetectors(!includeMonitors), 1, 1); @@ -59,7 +59,8 @@ SpecialWorkspace2D::SpecialWorkspace2D(Geometry::Instrument_const_sptr inst, * @param parent :: input workspace that is the base for this workspace * @return created SpecialWorkspace2D */ -SpecialWorkspace2D::SpecialWorkspace2D(API::MatrixWorkspace_const_sptr parent) { +SpecialWorkspace2D::SpecialWorkspace2D( + const API::MatrixWorkspace_const_sptr &parent) { this->initialize(parent->getNumberHistograms(), 1, 1); API::WorkspaceFactory::Instance().initializeFromParent(*parent, *this, false); // Make the mapping, which will be used for speed later. @@ -263,7 +264,7 @@ void SpecialWorkspace2D::binaryOperation(const unsigned int operatortype) { * */ void SpecialWorkspace2D::binaryAND( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { for (size_t i = 0; i < this->getNumberHistograms(); i++) { double y1 = this->dataY(i)[0]; @@ -281,7 +282,7 @@ void SpecialWorkspace2D::binaryAND( * */ void SpecialWorkspace2D::binaryOR( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { for (size_t i = 0; i < this->getNumberHistograms(); i++) { double y1 = this->dataY(i)[0]; @@ -307,7 +308,7 @@ if (y1 < 1.0E-10 && y2 < 1.0E-10){ * */ void SpecialWorkspace2D::binaryXOR( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { for (size_t i = 0; i < this->getNumberHistograms(); i++) { double y1 = this->dataY(i)[0]; @@ -343,7 +344,7 @@ void SpecialWorkspace2D::binaryNOT() { * @ return */ bool SpecialWorkspace2D::isCompatible( - boost::shared_ptr<const SpecialWorkspace2D> ws) { + const boost::shared_ptr<const SpecialWorkspace2D> &ws) { // 1. Check number of histogram size_t numhist1 = this->getNumberHistograms(); diff --git a/Framework/DataObjects/src/TableWorkspace.cpp b/Framework/DataObjects/src/TableWorkspace.cpp index c74dcc66a590a019d47d966ba74febecb282d1de..8b871aa20e73fd593b6175fe3ba083140f4fc361 100644 --- a/Framework/DataObjects/src/TableWorkspace.cpp +++ b/Framework/DataObjects/src/TableWorkspace.cpp @@ -200,7 +200,7 @@ std::vector<std::string> TableWorkspace::getColumnNames() const { return nameList; } -void TableWorkspace::addColumn(boost::shared_ptr<API::Column> column) { +void TableWorkspace::addColumn(const boost::shared_ptr<API::Column> &column) { auto ci = std::find_if(m_columns.begin(), m_columns.end(), FindName(column->name())); if (ci != m_columns.end()) { diff --git a/Framework/DataObjects/test/AffineMatrixParameterTest.h b/Framework/DataObjects/test/AffineMatrixParameterTest.h index 74ca40581095fd1e44674a89e5da1254ec3b150c..58da4a15d11fc3ed309a41537df6a91c2b97cb57 100644 --- a/Framework/DataObjects/test/AffineMatrixParameterTest.h +++ b/Framework/DataObjects/test/AffineMatrixParameterTest.h @@ -111,7 +111,6 @@ public: } param.setMatrix(transform); - std::string result = param.toXMLString(); TSM_ASSERT_EQUALS( "Serialization of CoordTransform has not worked correctly.", "<Parameter><Type>AffineMatrixParameter</" diff --git a/Framework/DataObjects/test/EventWorkspaceTest.h b/Framework/DataObjects/test/EventWorkspaceTest.h index a0536611e9bdb116e30eb52e40d0ebc8fbed703f..24fa648b83f372c14a45593fc4dd61dc9adc6df3 100644 --- a/Framework/DataObjects/test/EventWorkspaceTest.h +++ b/Framework/DataObjects/test/EventWorkspaceTest.h @@ -421,7 +421,7 @@ public: const std::range_error &); } - void do_test_binning(EventWorkspace_sptr ws, const BinEdges &axis, + void do_test_binning(const EventWorkspace_sptr &ws, const BinEdges &axis, size_t expected_occupancy_per_bin) { MantidVec Y(NUMBINS - 1); MantidVec E(NUMBINS - 1); diff --git a/Framework/DataObjects/test/MDBoxSaveableTest.h b/Framework/DataObjects/test/MDBoxSaveableTest.h index 8a9992cb61feb1f255c966dd4441fbce62554ee2..5f298769abc70e5711e0456b4443f407998537c8 100644 --- a/Framework/DataObjects/test/MDBoxSaveableTest.h +++ b/Framework/DataObjects/test/MDBoxSaveableTest.h @@ -24,6 +24,7 @@ #include <map> #include <memory> #include <nexus/NeXusFile.hpp> +#include <utility> using namespace Mantid; using namespace Mantid::Geometry; @@ -43,7 +44,7 @@ class MDBoxSaveableTest : public CxxTest::TestSuite { /** Deletes the file created by do_saveNexus */ static std::string - do_deleteNexusFile(std::string barefilename = "MDBoxTest.nxs") { + do_deleteNexusFile(const std::string &barefilename = "MDBoxTest.nxs") { std::string filename( ConfigService::Instance().getString("defaultsave.directory") + barefilename); @@ -69,11 +70,12 @@ public: * @return ptr to the NeXus file object * */ void do_createNeXusBackedBox(MDBox<MDLeanEvent<3>, 3> &box, - BoxController_sptr bc, + const BoxController_sptr &bc, std::string barefilename = "MDBoxTest.nxs", bool goofyWeights = true) { // Create the NXS file - std::string filename = do_createNexus(goofyWeights, barefilename); + std::string filename = + do_createNexus(goofyWeights, std::move(barefilename)); // Must get ready to load in the data auto loader = boost::shared_ptr<API::IBoxControllerIO>( @@ -100,8 +102,9 @@ public: * @param barefilename :: file to save to (no path) * @return filename with full path that was saved. * */ - std::string do_createNexus(bool goofyWeights = true, - std::string barefilename = "MDBoxTest.nxs") { + std::string + do_createNexus(bool goofyWeights = true, + const std::string &barefilename = "MDBoxTest.nxs") { // Box with 1000 events evenly spread MDBox<MDLeanEvent<3>, 3> b(sc.get()); MDEventsTestHelper::feedMDBox(&b, 1, 10, 0.5, 1.0); @@ -118,7 +121,7 @@ public: auto Saver = new BoxControllerNeXusIO(sc.get()); Saver->setDataType(b.getCoordType(), b.getEventType()); - std::string filename = do_deleteNexusFile(barefilename); + std::string filename = do_deleteNexusFile(std::move(barefilename)); Saver->openFile(filename, "w"); diff --git a/Framework/DataObjects/test/MDEventWorkspaceTest.h b/Framework/DataObjects/test/MDEventWorkspaceTest.h index 3511ed772c791b9d0a54283014f87a926beae3b0..3f1d9a598ee544da4169d50e25e7a0a5d98cbcbc 100644 --- a/Framework/DataObjects/test/MDEventWorkspaceTest.h +++ b/Framework/DataObjects/test/MDEventWorkspaceTest.h @@ -40,7 +40,7 @@ class MDEventWorkspaceTest : public CxxTest::TestSuite { private: /// Helper function to return the number of masked bins in a workspace. TODO: /// move helper into test helpers - size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws) { + size_t getNumberMasked(const Mantid::API::IMDWorkspace_sptr &ws) { auto it = ws->createIterator(nullptr); size_t numberMasked = 0; size_t counter = 0; @@ -479,7 +479,7 @@ public: TS_ASSERT_DELTA(ext[1].getMax(), ymax, 1e-4); } - void addEvent(MDEventWorkspace2Lean::sptr b, double x, double y) { + void addEvent(const MDEventWorkspace2Lean::sptr &b, double x, double y) { coord_t centers[2] = {static_cast<coord_t>(x), static_cast<coord_t>(y)}; b->addEvent(MDLeanEvent<2>(2.0, 2.0, centers)); } diff --git a/Framework/DataObjects/test/MDGridBoxTest.h b/Framework/DataObjects/test/MDGridBoxTest.h index b424ddcef7959ad0ea6082d9ccf11f87ebba99ed..500e4f3c403ab1f0988823391a33c6904370986a 100644 --- a/Framework/DataObjects/test/MDGridBoxTest.h +++ b/Framework/DataObjects/test/MDGridBoxTest.h @@ -1205,7 +1205,8 @@ public: */ void do_check_integrateSphere(MDGridBox<MDLeanEvent<2>, 2> &box, double x, double y, const double radius, - double numExpected, std::string message) { + double numExpected, + const std::string &message) { // The sphere transformation bool dimensionsUsed[2] = {true, true}; coord_t center[2] = {static_cast<coord_t>(x), static_cast<coord_t>(y)}; @@ -1336,7 +1337,8 @@ public: */ void do_check_integrateSphere3d(MDGridBox<MDLeanEvent<3>, 3> &box, double x, double y, double z, const double radius, - double numExpected, std::string message) { + double numExpected, + const std::string &message) { // The sphere transformation bool dimensionsUsed[3] = {true, true, true}; coord_t center[3] = {static_cast<coord_t>(x), static_cast<coord_t>(y), @@ -1394,7 +1396,7 @@ public: void do_check_centroidSphere(MDGridBox<MDLeanEvent<2>, 2> &box, double x, double y, const double radius, double numExpected, double xExpected, - double yExpected, std::string message) { + double yExpected, const std::string &message) { // The sphere transformation bool dimensionsUsed[2] = {true, true}; coord_t center[2] = {static_cast<coord_t>(x), static_cast<coord_t>(y)}; diff --git a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h index c11dcdce2cd0e448672b75c4863c9550c5089721..37a9635c1505237544603a38c04670b66f0044c9 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h @@ -17,6 +17,8 @@ #include "MantidTestHelpers/MDEventsTestHelper.h" #include <boost/scoped_ptr.hpp> #include <cmath> +#include <utility> + #include <cxxtest/TestSuite.h> using namespace Mantid; @@ -36,7 +38,7 @@ private: class WritableHistoWorkspace : public Mantid::DataObjects::MDHistoWorkspace { public: WritableHistoWorkspace(MDHistoDimension_sptr x) - : Mantid::DataObjects::MDHistoWorkspace(x) {} + : Mantid::DataObjects::MDHistoWorkspace(std::move(x)) {} void setMaskValueAt(size_t at, bool value) { m_masks[at] = value; } }; @@ -366,8 +368,8 @@ public: } void do_test_neighbours_1d( - boost::function<std::vector<size_t>(MDHistoWorkspaceIterator *)> - findNeighbourMemberFunction) { + const boost::function<std::vector<size_t>(MDHistoWorkspaceIterator *)> + &findNeighbourMemberFunction) { const size_t nd = 1; MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, nd, 10); diff --git a/Framework/DataObjects/test/MDHistoWorkspaceTest.h b/Framework/DataObjects/test/MDHistoWorkspaceTest.h index b61710991258ca8ae738dadedd8f35834690cbcc..4225ef8039248a2700faa4308ef0e1ed8f20c264 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceTest.h @@ -37,7 +37,7 @@ class MDHistoWorkspaceTest : public CxxTest::TestSuite { private: /// Helper function to return the number of masked bins in a workspace. TODO: /// move helper into test helpers - size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws) { + size_t getNumberMasked(const Mantid::API::IMDWorkspace_sptr &ws) { auto it = ws->createIterator(nullptr); size_t numberMasked = 0; size_t counter = 0; @@ -93,7 +93,7 @@ public: } /** Check that a workspace has the right signal/error*/ - void checkWorkspace(MDHistoWorkspace_sptr ws, double expectedSignal, + void checkWorkspace(const MDHistoWorkspace_sptr &ws, double expectedSignal, double expectedErrorSquared, double expectedNumEvents = 1.0) { for (size_t i = 0; i < ws->getNPoints(); i++) { diff --git a/Framework/DataObjects/test/PeaksWorkspaceTest.h b/Framework/DataObjects/test/PeaksWorkspaceTest.h index 41edfbeef31db35c3698535b5dbdf9d32dfcfe83..da1044841203748e52fb814c0c1107b0a39558d7 100644 --- a/Framework/DataObjects/test/PeaksWorkspaceTest.h +++ b/Framework/DataObjects/test/PeaksWorkspaceTest.h @@ -140,9 +140,6 @@ public: } void test_Save_Unmodified_PeaksWorkspace_Nexus() { - - const std::string filename = - "test_Save_Unmodified_PeaksWorkspace_Nexus.nxs"; auto testPWS = createSaveTestPeaksWorkspace(); NexusTestHelper nexusHelper(true); nexusHelper.createFile("testSavePeaksWorkspace.nxs"); diff --git a/Framework/DataObjects/test/WeightedEventTest.h b/Framework/DataObjects/test/WeightedEventTest.h index 7c22aa630fb8a34f9bcd7dc86b2318906276a845..621d22978ef0873674d6dc30e42fcc84f6f1c172 100644 --- a/Framework/DataObjects/test/WeightedEventTest.h +++ b/Framework/DataObjects/test/WeightedEventTest.h @@ -62,6 +62,7 @@ public: // Copy constructor we = WeightedEvent(); we2 = WeightedEvent(456, 789, 2.5, 1.5 * 1.5); + // cppcheck-suppress redundantAssignment we = we2; TS_ASSERT_EQUALS(we.tof(), 456); TS_ASSERT_EQUALS(we.pulseTime(), 789); diff --git a/Framework/DataObjects/test/WorkspaceCreationTest.h b/Framework/DataObjects/test/WorkspaceCreationTest.h index 9f7e009d7cfef3888534df964cfa34b1ca58c401..fb3c4f964ddaf9e9bf671304ab8a20eaecdd4602 100644 --- a/Framework/DataObjects/test/WorkspaceCreationTest.h +++ b/Framework/DataObjects/test/WorkspaceCreationTest.h @@ -78,7 +78,7 @@ void run_create_partitioned_parent(const Parallel::Communicator &comm) { void run_create_partitioned_with_instrument( const Parallel::Communicator &comm, - boost::shared_ptr<Geometry::Instrument> instrument) { + const boost::shared_ptr<Geometry::Instrument> &instrument) { IndexInfo indices(4, Parallel::StorageMode::Distributed, comm); // should a nullptr spectrum definitions vector indicate building default // defs? diff --git a/Framework/Doxygen/make_header.py b/Framework/Doxygen/make_header.py index 44edaf67920aabc0cd32df85c7f3fd886f88bef7..c87976c431edb8da75b49e044f0fb59e6eb2b707 100644 --- a/Framework/Doxygen/make_header.py +++ b/Framework/Doxygen/make_header.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -from six.moves import range #pylint: disable=redefined-builtin import sys tracking = """<script> diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h b/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h index 00ce398a372b3daf2422c412f2f86552d1f60dc9..d3ac30bf65e1c8ea237abfb10225d2b77792fb25 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/EdgePixel.h @@ -12,9 +12,9 @@ namespace Mantid { namespace Geometry { /// Function to find peaks near detector edge -MANTID_GEOMETRY_DLL bool edgePixel(Geometry::Instrument_const_sptr inst, - std::string bankName, int col, int row, - int Edge); +MANTID_GEOMETRY_DLL bool edgePixel(const Geometry::Instrument_const_sptr &inst, + const std::string &bankName, int col, + int row, int Edge); } // namespace Geometry } // namespace Mantid diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h b/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h index e9692b677e2ef62532df0803ca10a21ef0ed5465..1bdbb3d855840e9e54265edeab1f352779bd3967 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/IndexingUtils.h @@ -238,8 +238,8 @@ public: /// Choose the direction in a list of directions, that is most nearly /// perpendicular to planes with the specified spacing in reciprocal space. static int SelectDirection(Kernel::V3D &best_direction, - const std::vector<Kernel::V3D> q_vectors, - const std::vector<Kernel::V3D> direction_list, + const std::vector<Kernel::V3D> &q_vectors, + const std::vector<Kernel::V3D> &direction_list, double plane_spacing, double required_tolerance); /// Get the lattice parameters for the specified orientation matrix diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h b/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h index 16d7c98c0e7a37d840aa29e12ce684cfeff2aca4..12cfb9f9ecf42dcde44aab5ac24401342f5f7de2 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/PeakTransformSelector.h @@ -21,15 +21,15 @@ public: /// Constructor PeakTransformSelector(); /// Register a candidate factory - void registerCandidate(PeakTransformFactory_sptr candidate); + void registerCandidate(const PeakTransformFactory_sptr &candidate); /// Make choice - PeakTransformFactory_sptr makeChoice(const std::string labelX, - const std::string labelY) const; + PeakTransformFactory_sptr makeChoice(const std::string &labelX, + const std::string &labelY) const; /// Make default choice PeakTransformFactory_sptr makeDefaultChoice() const; /// Has a factory capable of the requested transform. - bool hasFactoryForTransform(const std::string labelX, - const std::string labelY) const; + bool hasFactoryForTransform(const std::string &labelX, + const std::string &labelY) const; /// Get the number of registered factories size_t numberRegistered() const; diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h b/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h index 06ac79c29864723597f2d3ddbfef4c78aed691fa..e1f62dd93cd1d823ed5f2b718583602fb4e0a9a1 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/ReflectionGenerator.h @@ -105,12 +105,12 @@ public: std::vector<Kernel::V3D> getHKLs(double dMin, double dMax) const; std::vector<Kernel::V3D> getHKLs(double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const; + const HKLFilter_const_sptr &reflectionConditionFilter) const; std::vector<Kernel::V3D> getUniqueHKLs(double dMin, double dMax) const; std::vector<Kernel::V3D> getUniqueHKLs(double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const; + const HKLFilter_const_sptr &reflectionConditionFilter) const; std::vector<double> getDValues(const std::vector<Kernel::V3D> &hkls) const; std::vector<double> getFsSquared(const std::vector<Kernel::V3D> &hkls) const; diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h b/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h index 8b82398ae824f4c6520f359284e7719508e06386..d0c4ffcef036fe5cb17149494d5ac4b07938fa50 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/SpaceGroupFactory.h @@ -236,7 +236,7 @@ protected: SpaceGroup_const_sptr getPrototype(const std::string &hmSymbol); void subscribe(const AbstractSpaceGroupGenerator_sptr &generator); SpaceGroup_const_sptr - constructFromPrototype(const SpaceGroup_const_sptr prototype) const; + constructFromPrototype(const SpaceGroup_const_sptr &prototype) const; void fillPointGroupMap(); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument.h b/Framework/Geometry/inc/MantidGeometry/Instrument.h index 0f8bb0a2dbbc5c1a61ac004304897d9b99eb7be5..48fcfc2fc8c0c27c4cf6bc190565e8286b1a4ce0 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument.h @@ -48,8 +48,8 @@ public: /// String description of the type of component std::string type() const override { return "Instrument"; } - Instrument(const boost::shared_ptr<const Instrument> instr, - boost::shared_ptr<ParameterMap> map); + Instrument(const boost::shared_ptr<const Instrument> &instr, + const boost::shared_ptr<ParameterMap> &map); Instrument(); Instrument(const std::string &name); Instrument(const Instrument &); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h b/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h index 26b94a73de8a0d5e8aff17cc171c0a8d1e5a0e03..640bcd5bc6bcebf2376eb0c01ce6700ca2ebdd96 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h @@ -34,8 +34,8 @@ public: std::string type() const override { return "DetectorComponent"; } Detector(const std::string &name, int id, IComponent *parent); - Detector(const std::string &name, int id, boost::shared_ptr<IObject> shape, - IComponent *parent); + Detector(const std::string &name, int id, + const boost::shared_ptr<IObject> &shape, IComponent *parent); // functions inherited from IObjectComponent Component *clone() const override { return new Detector(*this); } diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h b/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h index 317403878ad926bfb5264d31a7ffa8798a1b1104..1dcaa928b670281591db005cbca3944f692c04a3 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorGroup.h @@ -30,7 +30,7 @@ public: DetectorGroup(); DetectorGroup(const std::vector<IDetector_const_sptr> &dets); - void addDetector(IDetector_const_sptr det); + void addDetector(const IDetector_const_sptr &det); // IDetector methods IDetector *cloneParameterized(const ParameterMap *) const override { diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h b/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h index 609b51e4e840e6c1ac341b62245594ba2a1de898..e09c1b7301e6ba95ea4f81b8f1150747d972a45f 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/Goniometer.h @@ -11,6 +11,7 @@ #include "MantidKernel/V3D.h" #include <nexus/NeXusFile.hpp> #include <string> +#include <utility> namespace Mantid { namespace Geometry { @@ -43,8 +44,8 @@ struct GoniometerAxis { /// Constructor GoniometerAxis(std::string initname, Kernel::V3D initrotationaxis, double initangle, int initsense, int initangleunit) - : name(initname), rotationaxis(initrotationaxis), angle(initangle), - sense(initsense), angleunit(initangleunit) {} + : name(std::move(initname)), rotationaxis(initrotationaxis), + angle(initangle), sense(initsense), angleunit(initangleunit) {} GoniometerAxis() : name(""), rotationaxis(), angle(0.), sense(0), angleunit(0) {} @@ -57,7 +58,7 @@ public: // Default constructor Goniometer(); // Constructor from a rotation matrix - Goniometer(Kernel::DblMatrix rot); + Goniometer(const Kernel::DblMatrix &rot); // Default destructor virtual ~Goniometer() = default; // Return rotation matrix @@ -67,11 +68,12 @@ public: // Return information about axes std::string axesInfo(); // Add axis to goniometer - void pushAxis(std::string name, double axisx, double axisy, double axisz, - double angle = 0., int sense = CCW, int angUnit = angDegrees); + void pushAxis(const std::string &name, double axisx, double axisy, + double axisz, double angle = 0., int sense = CCW, + int angUnit = angDegrees); // Set rotation angle for an axis in the units the angle is set (default -- // degrees) - void setRotationAngle(std::string name, double value); + void setRotationAngle(const std::string &name, double value); // Set rotation angle for an axis in the units the angle is set (default -- // degrees) void setRotationAngle(size_t axisnumber, double value); @@ -83,13 +85,13 @@ public: // Get axis object const GoniometerAxis &getAxis(size_t axisnumber) const; // Get axis object - const GoniometerAxis &getAxis(std::string axisname) const; + const GoniometerAxis &getAxis(const std::string &axisname) const; // Return the number of axes size_t getNumberAxes() const; // Make a default universal goniometer void makeUniversalGoniometer(); // Return Euler angles acording to a convention - std::vector<double> getEulerAngles(std::string convention = "YZX"); + std::vector<double> getEulerAngles(const std::string &convention = "YZX"); void saveNexus(::NeXus::File *file, const std::string &group) const; void loadNexus(::NeXus::File *file, const std::string &group); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h b/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h index c98e4fdbd7fd598dd5b90d10e56b1a9bab8a64fa..6d638a04a11c62e990f3c7f62725fcdc8540e09f 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/GridDetectorPixel.h @@ -34,7 +34,7 @@ public: virtual std::string type() const override { return "GridDetectorPixel"; } GridDetectorPixel(const std::string &name, int id, - boost::shared_ptr<IObject> shape, IComponent *parent, + const boost::shared_ptr<IObject> &shape, IComponent *parent, const GridDetector *panel, size_t col, size_t row, size_t layer); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h index e8d10918a2dbf4e07d79ada5b1dca1d7cc8d7620..216f9883eab3dfa57c560a4ff11dac9b1db65fa8 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentDefinitionParser.h @@ -47,8 +47,8 @@ public: InstrumentDefinitionParser(const std::string &filename, const std::string &instName, const std::string &xmlText); - InstrumentDefinitionParser(const IDFObject_const_sptr xmlFile, - const IDFObject_const_sptr expectedCacheFile, + InstrumentDefinitionParser(const IDFObject_const_sptr &xmlFile, + const IDFObject_const_sptr &expectedCacheFile, const std::string &instName, const std::string &xmlText); ~InstrumentDefinitionParser() = default; @@ -153,7 +153,7 @@ private: const Poco::XML::Element *pCompElem, IdList &idList); /// Return true if assembly, false if not assembly and throws exception if /// string not in assembly - bool isAssembly(std::string) const; + bool isAssembly(const std::string &) const; /// Add XML element to parent assuming the element contains no other component /// elements @@ -263,7 +263,7 @@ private: Poco::XML::Element *pRootElem); /// Check IdList - void checkIdListExistsAndDefinesEnoughIDs(IdList idList, + void checkIdListExistsAndDefinesEnoughIDs(const IdList &idList, Poco::XML::Element *pElem, const std::string &filename) const; @@ -290,7 +290,7 @@ public: // for testing private: /// Reads from a cache file. - void applyCache(IDFObject_const_sptr cacheToApply); + void applyCache(const IDFObject_const_sptr &cacheToApply); /// Write out a cache file. CachingOption writeAndApplyCache(IDFObject_const_sptr firstChoiceCache, diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h b/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h index 31ca5b2f1441ecaded68dba5949668014e1cab9a..572eba65c9037f634364935e9770935bc93504bc 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/ParComponentFactory.h @@ -44,7 +44,8 @@ public: /// Create a parameterized component from the given base component and /// ParameterMap static boost::shared_ptr<IComponent> - create(boost::shared_ptr<const IComponent> base, const ParameterMap *map); + create(const boost::shared_ptr<const IComponent> &base, + const ParameterMap *map); }; } // Namespace Geometry diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h b/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h index 8091db541cfd43b020e1fd063fa511e0b971b44d..e813f64165f1af3013386a4b71487501ba56a4c9 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/SampleEnvironment.h @@ -25,7 +25,7 @@ class Track; */ class MANTID_GEOMETRY_DLL SampleEnvironment { public: - SampleEnvironment(std::string name, Container_const_sptr getContainer); + SampleEnvironment(std::string name, const Container_const_sptr &getContainer); /// @return The name of kit inline const std::string name() const { return m_name; } diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h index a6207bb04d1198c033c16d5a479e9082bbaea568..8d40acfdbfe4bae85382bd8b1f9212d252794244 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/CompositeImplicitFunction.h @@ -38,8 +38,8 @@ public: using MDImplicitFunction::isPointContained; //----------------------------------------------------------------- - bool - addFunction(Mantid::Geometry::MDImplicitFunction_sptr constituentFunction); + bool addFunction( + const Mantid::Geometry::MDImplicitFunction_sptr &constituentFunction); std::string getName() const override; std::string toXMLString() const override; int getNFunctions() const; diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h index c4a67ea306874f3ae071b364bcc25d6b1c7247b7..e5a4a0f408b5fc8f1e91cdc22f2cdbee4de9107c 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h @@ -41,19 +41,19 @@ public: bool addOrdinaryDimension(IMDDimension_const_sptr dimensionToAdd) const; /// Add many ordinary dimensions. - void addManyOrdinaryDimensions(VecIMDDimension_sptr manyDims) const; + void addManyOrdinaryDimensions(const VecIMDDimension_sptr &manyDims) const; /// Add x dimension. - bool addXDimension(IMDDimension_const_sptr dimension) const; + bool addXDimension(const IMDDimension_const_sptr &dimension) const; /// Add y dimension. - bool addYDimension(IMDDimension_const_sptr dimension) const; + bool addYDimension(const IMDDimension_const_sptr &dimension) const; /// Add z dimension. - bool addZDimension(IMDDimension_const_sptr dimension) const; + bool addZDimension(const IMDDimension_const_sptr &dimension) const; /// Add t dimension. - bool addTDimension(IMDDimension_const_sptr dimension) const; + bool addTDimension(const IMDDimension_const_sptr &dimension) const; /// Copy constructor MDGeometryBuilderXML(const MDGeometryBuilderXML &); diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h index 63d314d3a6929cccb6ed69670d071ab7d934cc6c..5ee60ef9f817acd0b40598af9841912d848bd86e 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDGeometryXMLParser.h @@ -78,13 +78,13 @@ public: bool hasTDimension() const; - bool isXDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isXDimension(const Mantid::Geometry::IMDDimension_sptr &) const; - bool isYDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isYDimension(const Mantid::Geometry::IMDDimension_sptr &) const; - bool isZDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isZDimension(const Mantid::Geometry::IMDDimension_sptr &) const; - bool isTDimension(Mantid::Geometry::IMDDimension_sptr) const; + bool isTDimension(const Mantid::Geometry::IMDDimension_sptr &) const; void SetRootNodeCheck(std::string elementName); diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h index ba3af9311f5d43f65452ace43c2d4ab709b0a3b2..9db0adde02d2d60f43ca766c73858cb53c9b77a2 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimension.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidGeometry/DllConfig.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" #include "MantidGeometry/MDGeometry/MDFrame.h" @@ -38,8 +40,8 @@ public: */ MDHistoDimension(std::string name, std::string ID, const MDFrame &frame, coord_t min, coord_t max, size_t numBins) - : m_name(name), m_dimensionId(ID), m_frame(frame.clone()), m_min(min), - m_max(max), m_numBins(numBins), + : m_name(std::move(name)), m_dimensionId(std::move(ID)), + m_frame(frame.clone()), m_min(min), m_max(max), m_numBins(numBins), m_binWidth((max - min) / static_cast<coord_t>(numBins)) { if (max < min) { throw std::invalid_argument("Error making MDHistoDimension. Cannot have " diff --git a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h index ebaa932eeb26df327426360650084abdfcfab807..7443fdb7b7d6415374b8f73f4db5fcdc714fdacb 100644 --- a/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h +++ b/Framework/Geometry/inc/MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h @@ -50,7 +50,7 @@ public: } MDHistoDimensionBuilder(); - void setName(std::string name); + void setName(const std::string &name); void setId(std::string id); void setUnits(const Kernel::UnitLabel &units); void setMin(double min); diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h index eda75d48203f0e5e9c3c6f06f6e46996ce82fe0f..31e0e3af432d6431bf7ac8ad50ee8e28bc0b6747 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h @@ -179,7 +179,7 @@ public: // Get Geometry Handler boost::shared_ptr<GeometryHandler> getGeometryHandler() const override; /// Set Geometry Handler - void setGeometryHandler(boost::shared_ptr<GeometryHandler> h); + void setGeometryHandler(const boost::shared_ptr<GeometryHandler> &h); /// set vtkGeometryCache writer void setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>); diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h index 737d5ba3145bb92f7d63829bfcb7d510e1d973e8..1fd45dfea1bbc325ac5d736dbc8f96e5673c6bd4 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h @@ -51,7 +51,7 @@ public: /// Constructor MeshObject(const std::vector<uint32_t> &faces, const std::vector<Kernel::V3D> &vertices, - const Kernel::Material material); + const Kernel::Material &material); /// Constructor MeshObject(std::vector<uint32_t> &&faces, std::vector<Kernel::V3D> &&vertices, const Kernel::Material &&material); @@ -126,7 +126,7 @@ public: // Get Geometry Handler boost::shared_ptr<GeometryHandler> getGeometryHandler() const override; /// Set Geometry Handler - void setGeometryHandler(boost::shared_ptr<GeometryHandler> h); + void setGeometryHandler(const boost::shared_ptr<GeometryHandler> &h); detail::ShapeInfo::GeometryShape shape() const override; const detail::ShapeInfo &shapeInfo() const override; diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h index 639670b7ad5c4d4c0ecf60b622fda3a153ec1e78..33b28379aab1ebe207310f9947ab52cf9d850064 100644 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h @@ -76,9 +76,9 @@ protected: nullptr; ///< ObjComponent that uses this geometry handler CSGObject *m_csgObj = nullptr; ///< Object that uses this geometry handler public: - GeometryHandler(IObjComponent *comp); ///< Constructor - GeometryHandler(boost::shared_ptr<CSGObject> obj); ///< Constructor - GeometryHandler(CSGObject *obj); ///< Constructor + GeometryHandler(IObjComponent *comp); ///< Constructor + GeometryHandler(const boost::shared_ptr<CSGObject> &obj); ///< Constructor + GeometryHandler(CSGObject *obj); ///< Constructor GeometryHandler(const MeshObject &obj); GeometryHandler(const MeshObject2D &obj); GeometryHandler(const GeometryHandler &handler); diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h b/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h index 1f99fc99567c8f396a74db74ba318e5c7c14578f..7cee8e07227fc51c0ed7d23e6cb3b2b49c89d06e 100644 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h @@ -37,7 +37,7 @@ private: std::string mFileName; ///< The file name // Private Methods void Init(); - Poco::XML::Element *getElementByObjectName(std::string name); + Poco::XML::Element *getElementByObjectName(const std::string &name); void readPoints(Poco::XML::Element *pEle, int noOfPoints, std::vector<double> &points); void readTriangles(Poco::XML::Element *pEle, int noOfTriangles, diff --git a/Framework/Geometry/src/Crystal/EdgePixel.cpp b/Framework/Geometry/src/Crystal/EdgePixel.cpp index e62018bb6b9b89db33a16468d8ec31ce8edfda5d..807ef1678c116ff466d5e19cc62091f90d9f1a94 100644 --- a/Framework/Geometry/src/Crystal/EdgePixel.cpp +++ b/Framework/Geometry/src/Crystal/EdgePixel.cpp @@ -20,8 +20,8 @@ namespace Geometry { @param Edge Number of edge points for each bank @return True if peak is on edge */ -bool edgePixel(Mantid::Geometry::Instrument_const_sptr inst, - std::string bankName, int col, int row, int Edge) { +bool edgePixel(const Mantid::Geometry::Instrument_const_sptr &inst, + const std::string &bankName, int col, int row, int Edge) { if (bankName == "None") return false; boost::shared_ptr<const Geometry::IComponent> parent = diff --git a/Framework/Geometry/src/Crystal/IndexingUtils.cpp b/Framework/Geometry/src/Crystal/IndexingUtils.cpp index adc2ac568b96f09faee51f9b9e0d1ab0d9cac41c..ba096aaa319b5a61edeaaa00d3153e26efb3b4bd 100644 --- a/Framework/Geometry/src/Crystal/IndexingUtils.cpp +++ b/Framework/Geometry/src/Crystal/IndexingUtils.cpp @@ -2854,8 +2854,8 @@ std::vector<V3D> IndexingUtils::MakeCircleDirections(int n_steps, specified. */ int IndexingUtils::SelectDirection(V3D &best_direction, - const std::vector<V3D> q_vectors, - const std::vector<V3D> direction_list, + const std::vector<V3D> &q_vectors, + const std::vector<V3D> &direction_list, double plane_spacing, double required_tolerance) { if (q_vectors.empty()) { diff --git a/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp b/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp index 97fb701e35409643c637c88112048e71b3d56bc4..4eb89198f83c1b61d38384b3dfb9e2131864486b 100644 --- a/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp +++ b/Framework/Geometry/src/Crystal/PeakTransformSelector.cpp @@ -17,7 +17,7 @@ Register a peak transform factory as a candidate. @param candidate : candidate peak transform factory */ void PeakTransformSelector::registerCandidate( - PeakTransformFactory_sptr candidate) { + const PeakTransformFactory_sptr &candidate) { m_candidateFactories.insert(candidate); } @@ -62,8 +62,8 @@ Make a choice for the peak transform factory. @return selected factory */ PeakTransformFactory_sptr -PeakTransformSelector::makeChoice(const std::string labelX, - const std::string labelY) const { +PeakTransformSelector::makeChoice(const std::string &labelX, + const std::string &labelY) const { if (labelX.empty()) { throw std::invalid_argument("labelX is empty"); } @@ -102,7 +102,7 @@ transformation. @return TRUE only if such a factory is available. */ bool PeakTransformSelector::hasFactoryForTransform( - const std::string labelX, const std::string labelY) const { + const std::string &labelX, const std::string &labelY) const { bool hasFactoryForTransform = true; try { this->makeChoice(labelX, labelY); diff --git a/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp b/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp index c64adeba704ffcf653af09feaee65334267e7a7d..39446f2ddda5bde7b67115c135bdb0c2795d5456 100644 --- a/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp +++ b/Framework/Geometry/src/Crystal/ReflectionGenerator.cpp @@ -76,7 +76,7 @@ std::vector<V3D> ReflectionGenerator::getHKLs(double dMin, double dMax) const { /// filter. If the pointer is null, it's ignored. std::vector<Kernel::V3D> ReflectionGenerator::getHKLs( double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const { + const HKLFilter_const_sptr &reflectionConditionFilter) const { HKLGenerator generator(m_crystalStructure.cell(), dMin); HKLFilter_const_sptr filter = getDRangeFilter(dMin, dMax); @@ -103,7 +103,7 @@ std::vector<V3D> ReflectionGenerator::getUniqueHKLs(double dMin, /// d-limits using the specified reflection condition filter. std::vector<V3D> ReflectionGenerator::getUniqueHKLs( double dMin, double dMax, - HKLFilter_const_sptr reflectionConditionFilter) const { + const HKLFilter_const_sptr &reflectionConditionFilter) const { HKLGenerator generator(m_crystalStructure.cell(), dMin); HKLFilter_const_sptr filter = getDRangeFilter(dMin, dMax); diff --git a/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp b/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp index 4459809313ddbb8ee69cdf5c04e630ec6d38e281..6d6e4bfd014e79b37e2e26165092984d7e716585 100644 --- a/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp +++ b/Framework/Geometry/src/Crystal/SpaceGroupFactory.cpp @@ -405,7 +405,7 @@ std::string SpaceGroupFactoryImpl::getTransformedSymbolOrthorhombic( /// Returns a copy-constructed instance of the supplied space group prototype /// object. SpaceGroup_const_sptr SpaceGroupFactoryImpl::constructFromPrototype( - const SpaceGroup_const_sptr prototype) const { + const SpaceGroup_const_sptr &prototype) const { return boost::make_shared<const SpaceGroup>(*prototype); } diff --git a/Framework/Geometry/src/Instrument.cpp b/Framework/Geometry/src/Instrument.cpp index e5ed3e3a697c2d732e882b28b28065f87483e6f7..0b79e7780a543f5d9b3b23fb69f99fa65bd5ba81 100644 --- a/Framework/Geometry/src/Instrument.cpp +++ b/Framework/Geometry/src/Instrument.cpp @@ -24,6 +24,7 @@ #include <boost/make_shared.hpp> #include <nexus/NeXusFile.hpp> #include <queue> +#include <utility> using namespace Mantid::Kernel; using Mantid::Kernel::Exception::InstrumentDefinitionError; @@ -59,8 +60,8 @@ Instrument::Instrument(const std::string &name) * @param instr :: instrument for parameter inclusion * @param map :: parameter map to include */ -Instrument::Instrument(const boost::shared_ptr<const Instrument> instr, - boost::shared_ptr<ParameterMap> map) +Instrument::Instrument(const boost::shared_ptr<const Instrument> &instr, + const boost::shared_ptr<ParameterMap> &map) : CompAssembly(instr.get(), map.get()), m_sourceCache(instr->m_sourceCache), m_sampleCache(instr->m_sampleCache), m_defaultView(instr->m_defaultView), m_defaultViewAxis(instr->m_defaultViewAxis), m_instr(instr), @@ -1037,7 +1038,7 @@ Setter for the reference frame. @param frame : reference frame object to use. */ void Instrument::setReferenceFrame(boost::shared_ptr<ReferenceFrame> frame) { - m_referenceFrame = frame; + m_referenceFrame = std::move(frame); } /** diff --git a/Framework/Geometry/src/Instrument/Container.cpp b/Framework/Geometry/src/Instrument/Container.cpp index 86dcc73b9506a0d7473b5ee01ed425fde1197e88..85a74621aa406dc6262761619d47ee501407063d 100644 --- a/Framework/Geometry/src/Instrument/Container.cpp +++ b/Framework/Geometry/src/Instrument/Container.cpp @@ -16,6 +16,7 @@ #include "Poco/SAX/InputSource.h" #include "Poco/SAX/SAXException.h" #include <boost/make_shared.hpp> +#include <utility> namespace Mantid { namespace Geometry { @@ -55,7 +56,7 @@ void updateTreeValues(Poco::XML::Element *root, //------------------------------------------------------------------------------ Container::Container() : m_shape(boost::make_shared<CSGObject>()) {} -Container::Container(IObject_sptr shape) : m_shape(shape) {} +Container::Container(IObject_sptr shape) : m_shape(std::move(shape)) {} Container::Container(const Container &container) : m_shape(IObject_sptr(container.m_shape->clone())), diff --git a/Framework/Geometry/src/Instrument/Detector.cpp b/Framework/Geometry/src/Instrument/Detector.cpp index fee86e8d666b5a50385c24a3495bec1a5e3340b8..377b462a2763bab2e5ff1a92a71d5f0b0ba2463e 100644 --- a/Framework/Geometry/src/Instrument/Detector.cpp +++ b/Framework/Geometry/src/Instrument/Detector.cpp @@ -45,7 +45,7 @@ Detector::Detector(const std::string &name, int id, IComponent *parent) * @param parent :: The parent component */ Detector::Detector(const std::string &name, int id, - boost::shared_ptr<IObject> shape, IComponent *parent) + const boost::shared_ptr<IObject> &shape, IComponent *parent) : IDetector(), ObjComponent(name, shape, parent), m_id(id) {} /** Gets the detector id diff --git a/Framework/Geometry/src/Instrument/DetectorGroup.cpp b/Framework/Geometry/src/Instrument/DetectorGroup.cpp index a8623247a6c8c496698a8069556c4a474af27afd..11d099398512065632201a4459ada11fa9d4b765 100644 --- a/Framework/Geometry/src/Instrument/DetectorGroup.cpp +++ b/Framework/Geometry/src/Instrument/DetectorGroup.cpp @@ -49,7 +49,7 @@ DetectorGroup::DetectorGroup(const std::vector<IDetector_const_sptr> &dets) /** Add a detector to the collection * @param det :: A pointer to the detector to add */ -void DetectorGroup::addDetector(IDetector_const_sptr det) { +void DetectorGroup::addDetector(const IDetector_const_sptr &det) { // the topology of the group become undefined and needs recalculation if new // detector has been added to the group group_topology = undef; diff --git a/Framework/Geometry/src/Instrument/DetectorInfo.cpp b/Framework/Geometry/src/Instrument/DetectorInfo.cpp index 07f32908474b0797acdf5cbe587f82b5d3963eac..992682287becb3c0531d0bb1809873b1172d5861 100644 --- a/Framework/Geometry/src/Instrument/DetectorInfo.cpp +++ b/Framework/Geometry/src/Instrument/DetectorInfo.cpp @@ -4,10 +4,12 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidGeometry/Instrument/DetectorInfo.h" +#include <utility> + #include "MantidBeamline/DetectorInfo.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Detector.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/DetectorInfoIterator.h" #include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidKernel/EigenConversionHelpers.h" @@ -27,8 +29,10 @@ DetectorInfo::DetectorInfo( boost::shared_ptr<const std::vector<detid_t>> detectorIds, boost::shared_ptr<const std::unordered_map<detid_t, size_t>> detIdToIndexMap) - : m_detectorInfo(std::move(detectorInfo)), m_instrument(instrument), - m_detectorIDs(detectorIds), m_detIDToIndex(detIdToIndexMap), + : m_detectorInfo(std::move(detectorInfo)), + m_instrument(std::move(instrument)), + m_detectorIDs(std::move(detectorIds)), + m_detIDToIndex(std::move(detIdToIndexMap)), m_lastDetector(PARALLEL_GET_MAX_THREADS), m_lastIndex(PARALLEL_GET_MAX_THREADS, -1) { diff --git a/Framework/Geometry/src/Instrument/Goniometer.cpp b/Framework/Geometry/src/Instrument/Goniometer.cpp index 15b7efd2f212480b64025221d294b5682993932e..e2dd92bd4764f54b2ec037d0586a12a739f0c9fe 100644 --- a/Framework/Geometry/src/Instrument/Goniometer.cpp +++ b/Framework/Geometry/src/Instrument/Goniometer.cpp @@ -14,6 +14,8 @@ #include <sstream> #include <stdexcept> #include <string> +#include <utility> + #include <vector> using namespace Mantid::Kernel; @@ -64,7 +66,7 @@ Goniometer::Goniometer() : R(3, 3, true), initFromR(false) {} /// Constructor from a rotation matrix /// @param rot :: DblMatrix matrix that is going to be the internal rotation /// matrix of the goniometer. Cannot push additional axes -Goniometer::Goniometer(DblMatrix rot) { +Goniometer::Goniometer(const DblMatrix &rot) { DblMatrix ide(3, 3), rtr(3, 3); rtr = rot.Tprime() * rot; ide.identityMatrix(); @@ -83,7 +85,7 @@ const Kernel::DblMatrix &Goniometer::getR() const { return R; } /// @param rot :: DblMatrix matrix that is going to be the internal rotation /// matrix of the goniometer. void Goniometer::setR(Kernel::DblMatrix rot) { - R = rot; + R = std::move(rot); initFromR = true; } @@ -129,7 +131,7 @@ std::string Goniometer::axesInfo() { @param sense :: rotation sense (CW or CCW), CCW by default @param angUnit :: units for angle of type#AngleUnit, angDegrees by default */ -void Goniometer::pushAxis(std::string name, double axisx, double axisy, +void Goniometer::pushAxis(const std::string &name, double axisx, double axisy, double axisz, double angle, int sense, int angUnit) { if (initFromR) { throw std::runtime_error( @@ -160,7 +162,7 @@ void Goniometer::pushAxis(std::string name, double axisx, double axisy, @param name :: GoniometerAxis name @param value :: value in the units that the axis is set */ -void Goniometer::setRotationAngle(std::string name, double value) { +void Goniometer::setRotationAngle(const std::string &name, double value) { bool changed = false; std::vector<GoniometerAxis>::iterator it; for (it = motors.begin(); it < motors.end(); ++it) { @@ -255,7 +257,7 @@ const GoniometerAxis &Goniometer::getAxis(size_t axisnumber) const { /// Get GoniometerAxis object using motor name /// @param axisname :: axis name -const GoniometerAxis &Goniometer::getAxis(std::string axisname) const { +const GoniometerAxis &Goniometer::getAxis(const std::string &axisname) const { for (auto it = motors.begin(); it < motors.end(); ++it) { if (axisname == it->name) { return (*it); @@ -288,7 +290,7 @@ void Goniometer::makeUniversalGoniometer() { * @param convention :: the convention used to calculate Euler Angles. The * UniversalGoniometer is YZY, a triple axis goniometer at HFIR is YZX */ -std::vector<double> Goniometer::getEulerAngles(std::string convention) { +std::vector<double> Goniometer::getEulerAngles(const std::string &convention) { return Quat(getR()).getEulerAngles(convention); } diff --git a/Framework/Geometry/src/Instrument/GridDetector.cpp b/Framework/Geometry/src/Instrument/GridDetector.cpp index cefb9052583ceb751134e3b4f5e2db667b2a66d2..6acabcbfc1c8b972b2eb500cc69bbb03c40b4d55 100644 --- a/Framework/Geometry/src/Instrument/GridDetector.cpp +++ b/Framework/Geometry/src/Instrument/GridDetector.cpp @@ -23,6 +23,7 @@ #include <boost/regex.hpp> #include <ostream> #include <stdexcept> +#include <utility> namespace Mantid { namespace Geometry { @@ -548,7 +549,7 @@ void GridDetector::initializeValues(boost::shared_ptr<IObject> shape, m_xstep = xstep; m_ystep = ystep; m_zstep = zstep; - m_shape = shape; + m_shape = std::move(shape); /// IDs start here m_idstart = idstart; @@ -609,9 +610,9 @@ void GridDetector::initialize(boost::shared_ptr<IObject> shape, int xpixels, throw std::runtime_error("GridDetector::initialize() called for a " "parametrized GridDetector"); - initializeValues(shape, xpixels, xstart, xstep, ypixels, ystart, ystep, - zpixels, zstart, zstep, idstart, idFillOrder, idstepbyrow, - idstep); + initializeValues(std::move(shape), xpixels, xstart, xstep, ypixels, ystart, + ystep, zpixels, zstart, zstep, idstart, idFillOrder, + idstepbyrow, idstep); std::string name = this->getName(); int minDetId = idstart, maxDetId = idstart; diff --git a/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp b/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp index 065c74b89a104d4665b440abc6cb0742f6889d21..0f1f8ac41be4f08f3e04b3311b724cf2244bf54d 100644 --- a/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp +++ b/Framework/Geometry/src/Instrument/GridDetectorPixel.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidGeometry/Instrument/GridDetectorPixel.h" +#include <utility> + #include "MantidGeometry/Instrument/GridDetector.h" +#include "MantidGeometry/Instrument/GridDetectorPixel.h" #include "MantidKernel/System.h" #include "MantidKernel/V3D.h" @@ -36,12 +38,12 @@ GridDetectorPixel::GridDetectorPixel(const GridDetectorPixel *base, * @param layer :: layer of the pixel in the panel */ GridDetectorPixel::GridDetectorPixel(const std::string &name, int id, - boost::shared_ptr<IObject> shape, + const boost::shared_ptr<IObject> &shape, IComponent *parent, const GridDetector *panel, size_t col, size_t row, size_t layer) - : Detector(name, id, shape, parent), m_panel(panel), m_col(col), m_row(row), - m_layer(layer) { + : Detector(name, id, std::move(shape), parent), m_panel(panel), m_col(col), + m_row(row), m_layer(layer) { if (!m_panel) throw std::runtime_error("GridDetectorPixel::ctor(): pixel " + name + " has no valid GridDetector parent."); diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index aec5c955e3dbabc5ea302141bdef4e5c80a7e0ad..cce5e6cb36fd924e67a59339dd0c1008bfac9eed 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -39,6 +39,7 @@ #include <boost/make_shared.hpp> #include <boost/regex.hpp> #include <unordered_set> +#include <utility> using namespace Mantid; using namespace Mantid::Kernel; @@ -95,8 +96,8 @@ InstrumentDefinitionParser::InstrumentDefinitionParser( * @param xmlText :: XML contents of IDF */ InstrumentDefinitionParser::InstrumentDefinitionParser( - const IDFObject_const_sptr xmlFile, - const IDFObject_const_sptr expectedCacheFile, const std::string &instName, + const IDFObject_const_sptr &xmlFile, + const IDFObject_const_sptr &expectedCacheFile, const std::string &instName, const std::string &xmlText) : m_xmlFile(boost::make_shared<NullIDFObject>()), m_cacheFile(boost::make_shared<NullIDFObject>()), m_pDoc(nullptr), @@ -414,7 +415,7 @@ void InstrumentDefinitionParser::checkComponentContainsLocationElement( * @param filename :: Name of the IDF, for exception message */ void InstrumentDefinitionParser::checkIdListExistsAndDefinesEnoughIDs( - IdList idList, Element *pElem, const std::string &filename) const { + const IdList &idList, Element *pElem, const std::string &filename) const { if (idList.counted != static_cast<int>(idList.vec.size())) { std::stringstream ss1, ss2; ss1 << idList.vec.size(); @@ -1990,7 +1991,7 @@ void InstrumentDefinitionParser::populateIdList(Poco::XML::Element *pE, * @throw InstrumentDefinitionError Thrown if type not defined in XML *definition */ -bool InstrumentDefinitionParser::isAssembly(std::string type) const { +bool InstrumentDefinitionParser::isAssembly(const std::string &type) const { const std::string filename = m_xmlFile->getFileFullPathStr(); auto it = isTypeAssembly.find(type); @@ -2580,7 +2581,8 @@ void InstrumentDefinitionParser::setComponentLinks( Apply the cache. @param cacheToApply : Cache file object to use the the geometries. */ -void InstrumentDefinitionParser::applyCache(IDFObject_const_sptr cacheToApply) { +void InstrumentDefinitionParser::applyCache( + const IDFObject_const_sptr &cacheToApply) { const std::string cacheFullPath = cacheToApply->getFileFullPathStr(); g_log.information("Loading geometry cache from " + cacheFullPath); // create a vtk reader @@ -2605,14 +2607,14 @@ Write the cache file from the IDF file and apply it. InstrumentDefinitionParser::CachingOption InstrumentDefinitionParser::writeAndApplyCache( IDFObject_const_sptr firstChoiceCache, IDFObject_const_sptr fallBackCache) { - IDFObject_const_sptr usedCache = firstChoiceCache; + IDFObject_const_sptr usedCache = std::move(firstChoiceCache); auto cachingOption = WroteGeomCache; g_log.notice("Geometry cache is not available"); try { Poco::File dir = usedCache->getParentDirectory(); if (dir.path().empty() || !dir.exists() || !dir.canWrite()) { - usedCache = fallBackCache; + usedCache = std::move(fallBackCache); cachingOption = WroteCacheTemp; g_log.information() << "Geometrycache directory is read only, writing cache " diff --git a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp index aeaa34b846ddf8522c736605e5e21861453624dd..13c327d53751caf48d17ca4777d730936b53c6b5 100644 --- a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp +++ b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp @@ -16,6 +16,7 @@ #include <algorithm> #include <ostream> #include <stdexcept> +#include <utility> namespace { Mantid::Kernel::Logger g_log("ObjCompAssembly"); @@ -408,12 +409,12 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // find the 'moments of inertia' of the assembly double Ixx = 0, Iyy = 0, Izz = 0, Ixy = 0, Ixz = 0, Iyz = 0; V3D Cmass; // 'center of mass' of the assembly - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { V3D p = (**it).getRelativePos(); Cmass += p; } Cmass /= nelements(); - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { V3D p = (**it).getRelativePos(); double x = p.X() - Cmass.X(), x2 = x * x; double y = p.Y() - Cmass.Y(), y2 = y * y; @@ -475,7 +476,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // positive displacements are positive numbers and negative ones are negative double hxn = 0, hyn = 0, hzn = 0; double hxp = 0, hyp = 0, hzp = 0; - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { // displacement vector of a detector V3D p = (**it).getRelativePos() - Cmass; // its projection on the vx axis @@ -609,7 +610,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { * @param obj :: The outline shape created previously fith createOutline() */ void ObjCompAssembly::setOutline(boost::shared_ptr<const IObject> obj) { - m_shape = obj; + m_shape = std::move(obj); } /** Print information about elements in the assembly to a stream diff --git a/Framework/Geometry/src/Instrument/ObjComponent.cpp b/Framework/Geometry/src/Instrument/ObjComponent.cpp index 4fe26facc6576a3cec0b5d2b0a4ad8795cb86886..f24ae4316de4c441f280d236d9a3cf7e9f81aed2 100644 --- a/Framework/Geometry/src/Instrument/ObjComponent.cpp +++ b/Framework/Geometry/src/Instrument/ObjComponent.cpp @@ -15,6 +15,7 @@ #include "MantidKernel/Exception.h" #include "MantidKernel/Material.h" #include <cfloat> +#include <utility> namespace Mantid { namespace Geometry { @@ -44,7 +45,7 @@ ObjComponent::ObjComponent(const std::string &name, IComponent *parent) ObjComponent::ObjComponent(const std::string &name, boost::shared_ptr<const IObject> shape, IComponent *parent) - : IObjComponent(), Component(name, parent), m_shape(shape) {} + : IObjComponent(), Component(name, parent), m_shape(std::move(shape)) {} /** Return the shape of the component */ @@ -65,7 +66,7 @@ void ObjComponent::setShape(boost::shared_ptr<const IObject> newShape) { throw std::runtime_error("ObjComponent::setShape - Cannot change the shape " "of a parameterized object"); else - m_shape = newShape; + m_shape = std::move(newShape); } /** diff --git a/Framework/Geometry/src/Instrument/ParComponentFactory.cpp b/Framework/Geometry/src/Instrument/ParComponentFactory.cpp index 4bcc922dceea39a0284564af05d27b725be85f91..c37cc266ef74152829bf44cd9c8fd2d39e2053fb 100644 --- a/Framework/Geometry/src/Instrument/ParComponentFactory.cpp +++ b/Framework/Geometry/src/Instrument/ParComponentFactory.cpp @@ -58,7 +58,7 @@ ParComponentFactory::createInstrument(boost::shared_ptr<const Instrument> base, * @returns A pointer to a parameterized component */ IComponent_sptr -ParComponentFactory::create(boost::shared_ptr<const IComponent> base, +ParComponentFactory::create(const boost::shared_ptr<const IComponent> &base, const ParameterMap *map) { boost::shared_ptr<const IDetector> det_sptr = boost::dynamic_pointer_cast<const IDetector>(base); diff --git a/Framework/Geometry/src/Instrument/RectangularDetector.cpp b/Framework/Geometry/src/Instrument/RectangularDetector.cpp index 42cb3d0ce8e2db8646b9fdf2131c500cff0f128d..03359db991e8be4f8957b51cb4af0b8738a76609 100644 --- a/Framework/Geometry/src/Instrument/RectangularDetector.cpp +++ b/Framework/Geometry/src/Instrument/RectangularDetector.cpp @@ -22,6 +22,7 @@ #include <boost/regex.hpp> #include <ostream> #include <stdexcept> +#include <utility> namespace { /** @@ -180,8 +181,8 @@ void RectangularDetector::initialize(boost::shared_ptr<IObject> shape, int idstepbyrow, int idstep) { GridDetector::initialize( - shape, xpixels, xstart, xstep, ypixels, ystart, ystep, 0, 0, 0, idstart, - idfillbyfirst_y ? "yxz" : "xyz", idstepbyrow, idstep); + std::move(shape), xpixels, xstart, xstep, ypixels, ystart, ystep, 0, 0, 0, + idstart, idfillbyfirst_y ? "yxz" : "xyz", idstepbyrow, idstep); } //------------------------------------------------------------------------------------------------ diff --git a/Framework/Geometry/src/Instrument/SampleEnvironment.cpp b/Framework/Geometry/src/Instrument/SampleEnvironment.cpp index 96261b30070f48492a0c7715109a60abedbce466..4684a6319e196f5216bb3e2ae43279659c2c19e4 100644 --- a/Framework/Geometry/src/Instrument/SampleEnvironment.cpp +++ b/Framework/Geometry/src/Instrument/SampleEnvironment.cpp @@ -29,7 +29,7 @@ using Kernel::V3D; * @param container The object that represents the can */ SampleEnvironment::SampleEnvironment(std::string name, - Container_const_sptr container) + const Container_const_sptr &container) : m_name(std::move(name)), m_components(1, container) {} const IObject &SampleEnvironment::getComponent(const size_t index) const { diff --git a/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp b/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp index 1de3d75e75f4ca2524b6033b88a0c825be84bc63..154f5adbb2b1b977bb510dca339ddd72b27f6b0f 100644 --- a/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp +++ b/Framework/Geometry/src/MDGeometry/CompositeImplicitFunction.cpp @@ -23,7 +23,7 @@ namespace Mantid { namespace Geometry { bool CompositeImplicitFunction::addFunction( - Mantid::Geometry::MDImplicitFunction_sptr constituentFunction) { + const Mantid::Geometry::MDImplicitFunction_sptr &constituentFunction) { bool bSuccess = false; if (constituentFunction.get() != nullptr) { this->m_Functions.emplace_back(constituentFunction); diff --git a/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp b/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp index 5d1e231ddf8b8412cc3d495426c07caa50f9f730..85b59c805d944f4fbb032e2c14ad320eb9d07fa9 100644 --- a/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp +++ b/Framework/Geometry/src/MDGeometry/MDGeometryXMLBuilder.cpp @@ -53,7 +53,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addOrdinaryDimension( */ template <typename CheckDimensionPolicy> void MDGeometryBuilderXML<CheckDimensionPolicy>::addManyOrdinaryDimensions( - VecIMDDimension_sptr manyDims) const { + const VecIMDDimension_sptr &manyDims) const { for (auto &manyDim : manyDims) { addOrdinaryDimension(manyDim); } @@ -106,7 +106,7 @@ void MDGeometryBuilderXML<CheckDimensionPolicy>::applyPolicyChecking( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addXDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { @@ -126,7 +126,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addXDimension( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addYDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { @@ -146,7 +146,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addYDimension( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addZDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { applyPolicyChecking(*dimension); @@ -165,7 +165,7 @@ bool MDGeometryBuilderXML<CheckDimensionPolicy>::addZDimension( */ template <typename CheckDimensionPolicy> bool MDGeometryBuilderXML<CheckDimensionPolicy>::addTDimension( - IMDDimension_const_sptr dimension) const { + const IMDDimension_const_sptr &dimension) const { bool bAdded = false; if (dimension) { diff --git a/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp b/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp index 00dee415aaf4d42c6d927a27bf8f89730ba547fb..26735df1cc4775edc651bc091452840547f0be7f 100644 --- a/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp +++ b/Framework/Geometry/src/MDGeometry/MDGeometryXMLParser.cpp @@ -5,6 +5,7 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include <algorithm> +#include <utility> #include "MantidGeometry/MDGeometry/IMDDimensionFactory.h" #include "MantidGeometry/MDGeometry/MDGeometryXMLDefinitions.h" @@ -23,14 +24,14 @@ struct findID { const std::string m_id; explicit findID(const std::string &id) : m_id(id) {} - bool operator()(const Mantid::Geometry::IMDDimension_sptr obj) const { + bool operator()(const Mantid::Geometry::IMDDimension_sptr &obj) const { return m_id == obj->getDimensionId(); } }; /// Helper unary comparison type for finding non-integrated dimensions. struct findIntegrated { - bool operator()(const Mantid::Geometry::IMDDimension_sptr obj) const { + bool operator()(const Mantid::Geometry::IMDDimension_sptr &obj) const { return obj->getIsIntegrated(); } }; @@ -307,7 +308,7 @@ Setter for the root element. "Dimensions" unless xml snippet passed in directly, in which case do not set. */ void MDGeometryXMLParser::SetRootNodeCheck(std::string elementName) { - m_rootNodeName = elementName; + m_rootNodeName = std::move(elementName); } /** @@ -346,7 +347,7 @@ Determines whether query dimension is the x dimension. @return true if matches. */ bool MDGeometryXMLParser::isXDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasXDimension()) { @@ -363,7 +364,7 @@ Determines whether query dimension is the y dimension. @return true if matches. */ bool MDGeometryXMLParser::isYDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasYDimension()) { @@ -380,7 +381,7 @@ Determines whether query dimension is the z dimension. @return true if matches. */ bool MDGeometryXMLParser::isZDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasZDimension()) { @@ -397,7 +398,7 @@ Determines whether query dimension is the t dimension. @return true if matches. */ bool MDGeometryXMLParser::isTDimension( - Mantid::Geometry::IMDDimension_sptr candidate) const { + const Mantid::Geometry::IMDDimension_sptr &candidate) const { validate(); bool bResult = false; if (hasTDimension()) { diff --git a/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp b/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp index 258aaf310fda016a18b31d2d4710ebe78e7d63d0..83d19054edb293f9a1b0f618089f24d5819326cb 100644 --- a/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp +++ b/Framework/Geometry/src/MDGeometry/MDHistoDimensionBuilder.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h" +#include <utility> + #include "MantidGeometry/MDGeometry/MDFrameFactory.h" +#include "MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h" #include "MantidKernel/Strings.h" #include "MantidKernel/UnitLabelTypes.h" @@ -21,7 +23,7 @@ MDHistoDimensionBuilder::MDHistoDimensionBuilder() Setter for the dimension name @param name : friendly name of dimension */ -void MDHistoDimensionBuilder::setName(std::string name) { +void MDHistoDimensionBuilder::setName(const std::string &name) { // String any spaces m_name = Kernel::Strings::strip(name); } @@ -30,7 +32,7 @@ void MDHistoDimensionBuilder::setName(std::string name) { Setter for the dimension id @param id : id of the dimension */ -void MDHistoDimensionBuilder::setId(std::string id) { m_id = id; } +void MDHistoDimensionBuilder::setId(std::string id) { m_id = std::move(id); } /* Setter for the dimension units @@ -69,7 +71,7 @@ void MDHistoDimensionBuilder::setNumBins(size_t nbins) { m_nbins = nbins; } * @param frameName: the frame name */ void MDHistoDimensionBuilder::setFrameName(std::string frameName) { - m_frameName = frameName; + m_frameName = std::move(frameName); } /* diff --git a/Framework/Geometry/src/Objects/CSGObject.cpp b/Framework/Geometry/src/Objects/CSGObject.cpp index 6a140257766ade61f608bef6f89feffef9c38981..bc955a76162d900785d4b338872565fbb29ece9e 100644 --- a/Framework/Geometry/src/Objects/CSGObject.cpp +++ b/Framework/Geometry/src/Objects/CSGObject.cpp @@ -38,6 +38,7 @@ #include <deque> #include <random> #include <stack> +#include <utility> using namespace Mantid::Geometry; using namespace Mantid::Kernel; @@ -1593,6 +1594,7 @@ double CSGObject::singleShotMonteCarloVolume(const int shotSize, const auto threadCount = PARALLEL_NUMBER_OF_THREADS; const auto currentThreadNum = PARALLEL_THREAD_NUMBER; size_t blocksize = shotSize / threadCount; + // cppcheck-suppress knownConditionTrueFalse if (currentThreadNum == threadCount - 1) { // Last thread may have to do threadCount extra iterations in // the worst case. @@ -2113,7 +2115,8 @@ int CSGObject::searchForObject(Kernel::V3D &point) const { * Set the geometry handler for Object * @param[in] h is pointer to the geometry handler. */ -void CSGObject::setGeometryHandler(boost::shared_ptr<GeometryHandler> h) { +void CSGObject::setGeometryHandler( + const boost::shared_ptr<GeometryHandler> &h) { if (h) m_handler = h; } @@ -2145,7 +2148,7 @@ void CSGObject::initDraw() const { */ void CSGObject::setVtkGeometryCacheWriter( boost::shared_ptr<vtkGeometryCacheWriter> writer) { - vtkCacheWriter = writer; + vtkCacheWriter = std::move(writer); updateGeometryHandler(); } @@ -2154,7 +2157,7 @@ void CSGObject::setVtkGeometryCacheWriter( */ void CSGObject::setVtkGeometryCacheReader( boost::shared_ptr<vtkGeometryCacheReader> reader) { - vtkCacheReader = reader; + vtkCacheReader = std::move(reader); updateGeometryHandler(); } diff --git a/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp b/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp index b7e5abd938f3c3854a58c25b29b6503023595ca7..772ca27da44dff1e9afc9eb4db8e16a9db500745 100644 --- a/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp +++ b/Framework/Geometry/src/Objects/InstrumentRayTracer.cpp @@ -15,6 +15,7 @@ #include "MantidKernel/V3D.h" #include <deque> #include <iterator> +#include <utility> namespace Mantid { namespace Geometry { @@ -33,7 +34,7 @@ using Kernel::V3D; * have a defined source. */ InstrumentRayTracer::InstrumentRayTracer(Instrument_const_sptr instrument) - : m_instrument(instrument) { + : m_instrument(std::move(instrument)) { if (!m_instrument) { std::ostringstream lexer; lexer << "Cannot create a InstrumentRayTracer, invalid instrument given. " diff --git a/Framework/Geometry/src/Objects/MeshObject.cpp b/Framework/Geometry/src/Objects/MeshObject.cpp index 4cd9be323fa61b89123da12596f2ccd4c2ded0dc..a17fadbd16358fe937714b82c0ad2cdb8317d932 100644 --- a/Framework/Geometry/src/Objects/MeshObject.cpp +++ b/Framework/Geometry/src/Objects/MeshObject.cpp @@ -21,7 +21,7 @@ namespace Geometry { MeshObject::MeshObject(const std::vector<uint32_t> &faces, const std::vector<Kernel::V3D> &vertices, - const Kernel::Material material) + const Kernel::Material &material) : m_boundingBox(), m_id("MeshObject"), m_triangles(faces), m_vertices(vertices), m_material(material) { @@ -453,7 +453,8 @@ bool MeshObject::searchForObject(Kernel::V3D &point) const { * @param[in] h is pointer to the geometry handler. don't delete this pointer in * the calling function. */ -void MeshObject::setGeometryHandler(boost::shared_ptr<GeometryHandler> h) { +void MeshObject::setGeometryHandler( + const boost::shared_ptr<GeometryHandler> &h) { if (h == nullptr) return; m_handler = h; diff --git a/Framework/Geometry/src/Rendering/GeometryHandler.cpp b/Framework/Geometry/src/Rendering/GeometryHandler.cpp index a51eea57de1c992cfaac3fdd46b8337a089565a6..d0a8d079e3530cd843a2695a578d2a1e276b11f6 100644 --- a/Framework/Geometry/src/Rendering/GeometryHandler.cpp +++ b/Framework/Geometry/src/Rendering/GeometryHandler.cpp @@ -19,7 +19,7 @@ namespace Geometry { GeometryHandler::GeometryHandler(IObjComponent *comp) : m_objComp(comp) {} -GeometryHandler::GeometryHandler(boost::shared_ptr<CSGObject> obj) +GeometryHandler::GeometryHandler(const boost::shared_ptr<CSGObject> &obj) : m_triangulator(new detail::GeometryTriangulator(obj.get())), m_csgObj(obj.get()) {} diff --git a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp index 11ec99e32fee1cf623f4fd2f68576dd7cf141d4e..627d711b01a94318736b5ada4ab1eb65c8e22c0b 100644 --- a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp +++ b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp @@ -13,6 +13,8 @@ #include <Poco/Exception.h> #include <Poco/SAX/InputSource.h> +#include <utility> + #include "MantidGeometry/Objects/CSGObject.h" #include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidGeometry/Rendering/vtkGeometryCacheReader.h" @@ -33,7 +35,7 @@ Kernel::Logger g_log("vtkGeometryCacheReader"); * Constructor */ vtkGeometryCacheReader::vtkGeometryCacheReader(std::string filename) { - mFileName = filename; + mFileName = std::move(filename); mDoc = nullptr; Init(); } @@ -104,7 +106,7 @@ void vtkGeometryCacheReader::readCacheForObject(IObject *obj) { * Get the Element by using the object name */ Poco::XML::Element * -vtkGeometryCacheReader::getElementByObjectName(std::string name) { +vtkGeometryCacheReader::getElementByObjectName(const std::string &name) { Element *pRoot = mDoc->documentElement(); if (pRoot == nullptr || pRoot->nodeName() != "VTKFile") return nullptr; diff --git a/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp b/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp index 84b834bccf0bdb3d8e2e8e9550a2efe682abd65f..c3a6460587cba7b76fb971cd01e306f707ef3455 100644 --- a/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp +++ b/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp @@ -22,6 +22,7 @@ #include <fstream> #include <sstream> +#include <utility> using Poco::XML::AutoPtr; using Poco::XML::Document; @@ -41,7 +42,7 @@ Kernel::Logger g_log("vtkGeometryCacheWriter"); * Constructor */ vtkGeometryCacheWriter::vtkGeometryCacheWriter(std::string filename) { - mFileName = filename; + mFileName = std::move(filename); mDoc = new Document(); Init(); diff --git a/Framework/Geometry/test/CSGObjectTest.h b/Framework/Geometry/test/CSGObjectTest.h index d99f7164575906db730dd7c2dddd5bfb1a419c0e..2f9da83d6f4fa427ba12f1271aa19d6f84debc05 100644 --- a/Framework/Geometry/test/CSGObjectTest.h +++ b/Framework/Geometry/test/CSGObjectTest.h @@ -416,7 +416,7 @@ public: TS_ASSERT_EQUALS(index, expectedResults.size()); } - void checkTrackIntercept(IObject_sptr obj, Track &track, + void checkTrackIntercept(const IObject_sptr &obj, Track &track, const std::vector<Link> &expectedResults) { int unitCount = obj->interceptSurface(track); TS_ASSERT_EQUALS(unitCount, expectedResults.size()); diff --git a/Framework/Geometry/test/IndexingUtilsTest.h b/Framework/Geometry/test/IndexingUtilsTest.h index 3e4d2faea0f7de43e06dadcbb69846a9e767fd16..25f07e272c40f8fc9161fceb373e4246f2592a4d 100644 --- a/Framework/Geometry/test/IndexingUtilsTest.h +++ b/Framework/Geometry/test/IndexingUtilsTest.h @@ -14,6 +14,8 @@ #include "MantidKernel/V3D.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid::Geometry; using Mantid::Kernel::Matrix; using Mantid::Kernel::V3D; @@ -55,7 +57,7 @@ public: static void ShowLatticeParameters(Matrix<double> UB) { Matrix<double> UB_inv(3, 3, false); - UB_inv = UB; + UB_inv = std::move(UB); UB_inv.Invert(); V3D a_dir(UB_inv[0][0], UB_inv[0][1], UB_inv[0][2]); V3D b_dir(UB_inv[1][0], UB_inv[1][1], UB_inv[1][2]); @@ -73,7 +75,8 @@ public: std::cout << "-------------------------------------------\n"; } - static void ShowIndexingStats(Matrix<double> UB, std::vector<V3D> q_vectors, + static void ShowIndexingStats(const Matrix<double> &UB, + const std::vector<V3D> &q_vectors, double required_tolerance) { std::vector<V3D> miller_indices; std::vector<V3D> indexed_qs; diff --git a/Framework/Geometry/test/InstrumentDefinitionParserTest.h b/Framework/Geometry/test/InstrumentDefinitionParserTest.h index ca4654fedc294301d56228c7a36f68c07ccaebe1..8ad15d693e80d6e5da58352386904821ddb140f8 100644 --- a/Framework/Geometry/test/InstrumentDefinitionParserTest.h +++ b/Framework/Geometry/test/InstrumentDefinitionParserTest.h @@ -34,7 +34,7 @@ private: /// Mock Type to act as IDF files. class MockIDFObject : public Mantid::Geometry::IDFObject { public: - MockIDFObject(const std::string fileName) + MockIDFObject(const std::string &fileName) : Mantid::Geometry::IDFObject(fileName) {} MOCK_CONST_METHOD0(exists, bool()); }; @@ -42,7 +42,7 @@ private: /// Mock Type to act as IDF files. class MockIDFObjectWithParentDirectory : public Mantid::Geometry::IDFObject { public: - MockIDFObjectWithParentDirectory(const std::string fileName) + MockIDFObjectWithParentDirectory(const std::string &fileName) : Mantid::Geometry::IDFObject(fileName) {} MOCK_CONST_METHOD0(exists, bool()); MOCK_CONST_METHOD0(getParentDirectory, const Poco::Path()); @@ -54,7 +54,7 @@ private: */ struct IDFEnvironment { IDFEnvironment(const ScopedFile &idf, const ScopedFile &vtp, - const std::string xmlText, const std::string instName) + const std::string &xmlText, const std::string &instName) : _idf(idf), _vtp(vtp), _xmlText(xmlText), _instName(instName){}; ScopedFile _idf; @@ -980,8 +980,8 @@ public: TS_ASSERT_DELTA(instr->getDetector(5)->getPos().Z(), 3.0, 1.0E-8); } - void checkDetectorRot(IDetector_const_sptr det, double deg, double axisx, - double axisy, double axisz) { + void checkDetectorRot(const IDetector_const_sptr &det, double deg, + double axisx, double axisy, double axisz) { double detDeg, detAxisX, detAxisY, detAxisZ; det->getRotation().getAngleAxis(detDeg, detAxisX, detAxisY, detAxisZ); diff --git a/Framework/Geometry/test/InstrumentRayTracerTest.h b/Framework/Geometry/test/InstrumentRayTracerTest.h index 80357a524c2ed09e13486dc61cafc150bd466338..5fea17192a9d1a068741874f5539f4543170bf77 100644 --- a/Framework/Geometry/test/InstrumentRayTracerTest.h +++ b/Framework/Geometry/test/InstrumentRayTracerTest.h @@ -163,8 +163,9 @@ public: * @param expectX :: expected x index, -1 if off * @param expectY :: expected y index, -1 if off */ - void doTestRectangularDetector(std::string message, Instrument_sptr inst, - V3D testDir, int expectX, int expectY) { + void doTestRectangularDetector(const std::string &message, + const Instrument_sptr &inst, V3D testDir, + int expectX, int expectY) { InstrumentRayTracer tracker(inst); testDir.normalize(); tracker.traceFromSample(testDir); diff --git a/Framework/Geometry/test/MDBoxImplicitFunctionTest.h b/Framework/Geometry/test/MDBoxImplicitFunctionTest.h index df0683d05f3da7cd6257bc8924f319e9348cbcf3..6d30faa3b665b3e34b8eaf0442000eaa6340bbec 100644 --- a/Framework/Geometry/test/MDBoxImplicitFunctionTest.h +++ b/Framework/Geometry/test/MDBoxImplicitFunctionTest.h @@ -106,7 +106,6 @@ public: // The box to test. const coord_t boxMin = 1.1f; const coord_t boxMax = 1.9f; - std::vector<coord_t> boxVertexes; std::vector<Extent> extents; // extent extents.emplace_back(Extent(boxMin, boxMax)); diff --git a/Framework/Geometry/test/PointGroupTest.h b/Framework/Geometry/test/PointGroupTest.h index 39929db7257aa10109ff276bf723e6382aadc58c..8917d739944fba93d201102945ff10078964ec72 100644 --- a/Framework/Geometry/test/PointGroupTest.h +++ b/Framework/Geometry/test/PointGroupTest.h @@ -22,7 +22,7 @@ using namespace Mantid::Geometry; class PointGroupTest : public CxxTest::TestSuite { public: - void check_point_group(std::string name, V3D hkl, size_t numEquiv, + void check_point_group(const std::string &name, V3D hkl, size_t numEquiv, V3D *equiv) { PointGroup_sptr testedPointGroup = PointGroupFactory::Instance().createPointGroup(name); diff --git a/Framework/Geometry/test/ShapeFactoryTest.h b/Framework/Geometry/test/ShapeFactoryTest.h index 9f89f8aa98bf26abc3252c3b778ba23fc0c93bdc..5d6fe1e5c283238eba302b45db9b24aac9fda8bb 100644 --- a/Framework/Geometry/test/ShapeFactoryTest.h +++ b/Framework/Geometry/test/ShapeFactoryTest.h @@ -636,7 +636,7 @@ public: TS_ASSERT(!shape_sptr->isValid(V3D(0.0, 0.0, 1))); } - boost::shared_ptr<CSGObject> getObject(std::string xmlShape) { + boost::shared_ptr<CSGObject> getObject(const std::string &xmlShape) { std::string shapeXML = "<type name=\"userShape\"> " + xmlShape + " </type>"; // Set up the DOM parser and parse xml string diff --git a/Framework/HistogramData/test/CountStandardDeviationsTest.h b/Framework/HistogramData/test/CountStandardDeviationsTest.h index fc094f623f4b9eb34e5d6c146b0af99f51a4e60a..4da236676c4c2888e762ab7493f56aeeed1b16ac 100644 --- a/Framework/HistogramData/test/CountStandardDeviationsTest.h +++ b/Framework/HistogramData/test/CountStandardDeviationsTest.h @@ -94,7 +94,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountStandardDeviations counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -104,8 +103,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountStandardDeviations counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } @@ -127,7 +124,6 @@ public: // This implicitly constructs FrequencyStandardDeviations first, so there is // a two-step move going on! const CountStandardDeviations counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/CountVariancesTest.h b/Framework/HistogramData/test/CountVariancesTest.h index f574cb79e7ee113e8130c574b165188ac1ce5331..1ee331c55109a2c6a40e37ffb36d27d28aa44e83 100644 --- a/Framework/HistogramData/test/CountVariancesTest.h +++ b/Framework/HistogramData/test/CountVariancesTest.h @@ -101,7 +101,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountVariances counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -111,8 +110,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountVariances counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } @@ -134,7 +131,6 @@ public: // This implicitly constructs FrequencyVariances first, so there is a // two-step move going on! const CountVariances counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/CountsTest.h b/Framework/HistogramData/test/CountsTest.h index d6474d26253b361f3c1ba7a510d2066de48acc92..49725b67d754d84891064760d61f8ff99b1b1144 100644 --- a/Framework/HistogramData/test/CountsTest.h +++ b/Framework/HistogramData/test/CountsTest.h @@ -97,7 +97,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const Counts counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -107,8 +106,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const Counts counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } diff --git a/Framework/HistogramData/test/FrequenciesTest.h b/Framework/HistogramData/test/FrequenciesTest.h index 598fd5aa8424e47c2b138a3ba12359f980f2edb8..1eb1b105bddb4a5f8ac56457ea1f7fd568331377 100644 --- a/Framework/HistogramData/test/FrequenciesTest.h +++ b/Framework/HistogramData/test/FrequenciesTest.h @@ -97,7 +97,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const Frequencies frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } @@ -107,8 +106,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const Frequencies frequencies(std::move(counts), edges); - // Moved from counts... - TS_ASSERT(!counts); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&frequencies[0], old_ptr); } diff --git a/Framework/HistogramData/test/FrequencyVariancesTest.h b/Framework/HistogramData/test/FrequencyVariancesTest.h index a308a66dd0ede9763c2dfcef1d09febb43b2abb1..cabf615d4746d78df244300195cf2bd624f9b3c2 100644 --- a/Framework/HistogramData/test/FrequencyVariancesTest.h +++ b/Framework/HistogramData/test/FrequencyVariancesTest.h @@ -104,7 +104,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const FrequencyVariances frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } @@ -114,8 +113,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const FrequencyVariances frequencies(std::move(counts), edges); - // Moved from counts... - TS_ASSERT(!counts); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&frequencies[0], old_ptr); } @@ -137,7 +134,6 @@ public: // This implicitly constructs CountVariances first, so there is a // two-step move going on! const FrequencyVariances frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/StandardDeviationVectorOfTest.h b/Framework/HistogramData/test/StandardDeviationVectorOfTest.h index f5da8607d1e5f95fbe39c7ffa020b94014e48ab6..113209ffb93d70d3744fae9eac2c20b8bdd6c953 100644 --- a/Framework/HistogramData/test/StandardDeviationVectorOfTest.h +++ b/Framework/HistogramData/test/StandardDeviationVectorOfTest.h @@ -74,7 +74,6 @@ public: VariancesTester variances{1.0, 4.0}; auto old_ptr = &variances[0]; StandardDeviationVectorOfTester sigmas(std::move(variances)); - TS_ASSERT(!variances); TS_ASSERT_EQUALS(&sigmas[0], old_ptr); TS_ASSERT_EQUALS(sigmas[0], 1.0); TS_ASSERT_EQUALS(sigmas[1], 2.0); @@ -93,7 +92,6 @@ public: auto old_ptr = &variances[0]; StandardDeviationVectorOfTester sigmas{}; sigmas = std::move(variances); - TS_ASSERT(!variances); TS_ASSERT_EQUALS(&sigmas[0], old_ptr); TS_ASSERT_EQUALS(sigmas[0], 1.0); TS_ASSERT_EQUALS(sigmas[1], 2.0); diff --git a/Framework/HistogramData/test/VarianceVectorOfTest.h b/Framework/HistogramData/test/VarianceVectorOfTest.h index 1dfed01a9c67c43698361c8b88ca8705cc49b629..2c58a64f541ba310f5591b327b97653b1e16db30 100644 --- a/Framework/HistogramData/test/VarianceVectorOfTest.h +++ b/Framework/HistogramData/test/VarianceVectorOfTest.h @@ -70,7 +70,6 @@ public: SigmasTester sigmas{1.0, 2.0}; auto old_ptr = &sigmas[0]; VarianceVectorOfTester variances(std::move(sigmas)); - TS_ASSERT(!sigmas); TS_ASSERT_EQUALS(&variances[0], old_ptr); TS_ASSERT_EQUALS(variances[0], 1.0); TS_ASSERT_EQUALS(variances[1], 4.0); @@ -89,7 +88,6 @@ public: auto old_ptr = &sigmas[0]; VarianceVectorOfTester variances{}; variances = std::move(sigmas); - TS_ASSERT(!sigmas); TS_ASSERT_EQUALS(&variances[0], old_ptr); TS_ASSERT_EQUALS(variances[0], 1.0); TS_ASSERT_EQUALS(variances[1], 4.0); diff --git a/Framework/HistogramData/test/VectorOfTest.h b/Framework/HistogramData/test/VectorOfTest.h index 032b30e9fd303422f0360c468f7a9810e23925e3..f38e4d64c540d051b4ef59699534be748bb6e87c 100644 --- a/Framework/HistogramData/test/VectorOfTest.h +++ b/Framework/HistogramData/test/VectorOfTest.h @@ -100,7 +100,6 @@ public: TS_ASSERT_EQUALS(src.size(), 2); TS_ASSERT(src); const VectorOfTester dest(std::move(src)); - TS_ASSERT(!src); TS_ASSERT_EQUALS(dest[0], 0.1); TS_ASSERT_EQUALS(dest[1], 0.1); } @@ -108,7 +107,6 @@ public: void test_move_from_null_constructor() { VectorOfTester src{}; const VectorOfTester dest(std::move(src)); - TS_ASSERT(!src); TS_ASSERT(!dest); } @@ -160,7 +158,6 @@ public: TS_ASSERT_EQUALS(dest[0], 0.0); TS_ASSERT(src); dest = std::move(src); - TS_ASSERT(!src); TS_ASSERT_EQUALS(dest[0], 0.1); TS_ASSERT_EQUALS(dest[1], 0.1); } @@ -169,7 +166,6 @@ public: VectorOfTester src{}; VectorOfTester dest(1); dest = std::move(src); - TS_ASSERT(!src); TS_ASSERT(!dest); } diff --git a/Framework/ICat/test/CatalogSearchTest.h b/Framework/ICat/test/CatalogSearchTest.h index 89c73f02b08983a849dc59697209a73dd6a57b02..54b80e7d6a5fd0989bb6d125330c462407ebbf2f 100644 --- a/Framework/ICat/test/CatalogSearchTest.h +++ b/Framework/ICat/test/CatalogSearchTest.h @@ -121,16 +121,9 @@ public: if (!searchobj.isInitialized()) searchobj.initialize(); - std::string errorMsg = "Invalid value for property StartDate (string) " - "sssss" - ": Invalid Date:date format must be DD/MM/YYYY"; TS_ASSERT_THROWS(searchobj.setPropertyValue("StartDate", "sssss"), const std::invalid_argument &); - - errorMsg = "Invalid value for property EndDate (string) " - "aaaaa" - ": Invalid Date:date format must be DD/MM/YYYY"; TS_ASSERT_THROWS(searchobj.setPropertyValue("EndDate", "aaaaa"), const std::invalid_argument &); @@ -146,17 +139,8 @@ public: if (!searchobj.isInitialized()) searchobj.initialize(); - std::string errorMsg = "Invalid value for property StartDate (string) " - "39/22/2009" - ": Invalid Date:Day part of the Date parameter must " - "be between 1 and 31"; TS_ASSERT_THROWS(searchobj.setPropertyValue("StartDate", "39/22/2009"), const std::invalid_argument &); - - errorMsg = "Invalid value for property EndDate (string) " - "1/22/2009" - ": Invalid Date:Month part of the Date parameter must be " - "between 1 and 12"; TS_ASSERT_THROWS(searchobj.setPropertyValue("EndDate", "1/22/2009"), const std::invalid_argument &); diff --git a/Framework/Indexing/inc/MantidIndexing/IndexInfo.h b/Framework/Indexing/inc/MantidIndexing/IndexInfo.h index 2c20d8f7edb1c91fd23b84eea4ba0e586966fa37..42392f70f58ab9f75f4d135c871c8f8290d6bbae 100644 --- a/Framework/Indexing/inc/MantidIndexing/IndexInfo.h +++ b/Framework/Indexing/inc/MantidIndexing/IndexInfo.h @@ -87,8 +87,9 @@ public: void setSpectrumDefinitions(std::vector<SpectrumDefinition> spectrumDefinitions); - void setSpectrumDefinitions( - Kernel::cow_ptr<std::vector<SpectrumDefinition>> spectrumDefinitions); + void + setSpectrumDefinitions(const Kernel::cow_ptr<std::vector<SpectrumDefinition>> + &spectrumDefinitions); const Kernel::cow_ptr<std::vector<SpectrumDefinition>> & spectrumDefinitions() const; diff --git a/Framework/Indexing/src/IndexInfo.cpp b/Framework/Indexing/src/IndexInfo.cpp index 79b7462634f3dab535e22bc56fd65b912d15ebc6..eb8e07adf815bd47741ea7d6b817bc82d6ddd70a 100644 --- a/Framework/Indexing/src/IndexInfo.cpp +++ b/Framework/Indexing/src/IndexInfo.cpp @@ -174,7 +174,8 @@ void IndexInfo::setSpectrumDefinitions( * indices. Validation requires access to the instrument and thus cannot be done * internally in IndexInfo, i.e., spectrum definitions must be set by hand. */ void IndexInfo::setSpectrumDefinitions( - Kernel::cow_ptr<std::vector<SpectrumDefinition>> spectrumDefinitions) { + const Kernel::cow_ptr<std::vector<SpectrumDefinition>> + &spectrumDefinitions) { if (!spectrumDefinitions || (size() != spectrumDefinitions->size())) throw std::runtime_error( "IndexInfo: Size mismatch when setting new spectrum definitions"); diff --git a/Framework/Indexing/test/PartitionerTest.h b/Framework/Indexing/test/PartitionerTest.h index 3a53a0b5bffdb8ea3d5da07300514547062b7849..f64f74c41ae7c3061f5349ccf4225a03eb806b71 100644 --- a/Framework/Indexing/test/PartitionerTest.h +++ b/Framework/Indexing/test/PartitionerTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidIndexing/Partitioner.h" using namespace Mantid; @@ -23,7 +25,8 @@ public: PartitionerHelper(int numberOfPartitions, const PartitionIndex partition, const MonitorStrategy monitorStrategy, std::vector<GlobalSpectrumIndex> monitors) - : Partitioner(numberOfPartitions, partition, monitorStrategy, monitors) {} + : Partitioner(numberOfPartitions, partition, monitorStrategy, + std::move(monitors)) {} private: PartitionIndex doIndexOf(const GlobalSpectrumIndex) const override { diff --git a/Framework/Kernel/inc/MantidKernel/ArrayProperty.h b/Framework/Kernel/inc/MantidKernel/ArrayProperty.h index 31682068bb7478a103010b0d0569b3dce47356e7..1dff3f72ca932500b88bdc6b0870b53912451654 100644 --- a/Framework/Kernel/inc/MantidKernel/ArrayProperty.h +++ b/Framework/Kernel/inc/MantidKernel/ArrayProperty.h @@ -28,16 +28,18 @@ namespace Kernel { template <typename T> class DLLExport ArrayProperty : public PropertyWithValue<std::vector<T>> { public: - ArrayProperty(std::string name, std::vector<T> vec, - IValidator_sptr validator = IValidator_sptr(new NullValidator), + ArrayProperty( + const std::string &name, std::vector<T> vec, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + const unsigned int direction = Direction::Input); + ArrayProperty(const std::string &name, const IValidator_sptr &validator, const unsigned int direction = Direction::Input); - ArrayProperty(std::string name, IValidator_sptr validator, - const unsigned int direction = Direction::Input); - ArrayProperty(std::string name, - const unsigned int direction = Direction::Input); - ArrayProperty(std::string name, const std::string &values, - IValidator_sptr validator = IValidator_sptr(new NullValidator), + ArrayProperty(const std::string &name, const unsigned int direction = Direction::Input); + ArrayProperty( + const std::string &name, const std::string &values, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + const unsigned int direction = Direction::Input); ArrayProperty<T> *clone() const override; diff --git a/Framework/Kernel/inc/MantidKernel/CompositeValidator.h b/Framework/Kernel/inc/MantidKernel/CompositeValidator.h index b386e9d55e8b075b1c6fe2e1d43f55e1f47246c3..539762d4fe4c590b7189bc57b03804d58069f4bd 100644 --- a/Framework/Kernel/inc/MantidKernel/CompositeValidator.h +++ b/Framework/Kernel/inc/MantidKernel/CompositeValidator.h @@ -41,7 +41,7 @@ public: /// Clones this and the children into a new Validator IValidator_sptr clone() const override; /// Adds a validator to the group of validators to check - void add(IValidator_sptr child); + void add(const IValidator_sptr &child); /// Add a validator based on a template type. Useful for validators that need /// no arguments template <typename T> void add() { this->add(boost::make_shared<T>()); } diff --git a/Framework/Kernel/inc/MantidKernel/ErrorReporter.h b/Framework/Kernel/inc/MantidKernel/ErrorReporter.h index 785913ae656ac7149d79c5930eda68702422dbe9..40369730102dfeafec1707ae3cb34e6973d81f31 100644 --- a/Framework/Kernel/inc/MantidKernel/ErrorReporter.h +++ b/Framework/Kernel/inc/MantidKernel/ErrorReporter.h @@ -21,16 +21,21 @@ namespace Kernel { class MANTID_KERNEL_DLL ErrorReporter { public: /// Constructor - ErrorReporter(std::string application, Types::Core::time_duration startTime, - std::string exitCode, bool share); + ErrorReporter(const std::string &application, + const Types::Core::time_duration &startTime, + const std::string &exitCode, bool share); /// Constructor - ErrorReporter(std::string application, Types::Core::time_duration startTime, - std::string exitCode, bool share, std::string name, - std::string email, std::string textBox); + ErrorReporter(const std::string &application, + const Types::Core::time_duration &startTime, + const std::string &exitCode, bool share, + const std::string &name, const std::string &email, + const std::string &textBox); /// Constructor - ErrorReporter(std::string application, Types::Core::time_duration startTime, - std::string exitCode, bool share, std::string name, - std::string email, std::string textBox, std::string stacktrace); + ErrorReporter(const std::string &application, + const Types::Core::time_duration &startTime, + const std::string &exitCode, bool share, + const std::string &name, const std::string &email, + const std::string &textBox, const std::string &stacktrace); /// Sends an error report int sendErrorReport(); diff --git a/Framework/Kernel/inc/MantidKernel/FunctionTask.h b/Framework/Kernel/inc/MantidKernel/FunctionTask.h index 905d34025fe580fd2d13217b88efc78fbc5c59b8..6d0d2a849faa75e0d55f913ba0b953d1a485ff7e 100644 --- a/Framework/Kernel/inc/MantidKernel/FunctionTask.h +++ b/Framework/Kernel/inc/MantidKernel/FunctionTask.h @@ -13,6 +13,8 @@ #ifndef Q_MOC_RUN #include <boost/function.hpp> +#include <utility> + #endif namespace Mantid { @@ -61,7 +63,7 @@ public: * @param cost :: computational cost */ FunctionTask(std::function<void()> func, double cost = 1.0) - : Task(cost), m_voidFunc(func) {} + : Task(cost), m_voidFunc(std::move(func)) {} //--------------------------------------------------------------------------------------------- /** Main method that performs the work for the task. */ diff --git a/Framework/Kernel/inc/MantidKernel/IndexSet.h b/Framework/Kernel/inc/MantidKernel/IndexSet.h index 92e33fc2b7e6cf997620580a03751ed8de9de96d..461ffc193b020f0efb1ecf296876ff135c37c56e 100644 --- a/Framework/Kernel/inc/MantidKernel/IndexSet.h +++ b/Framework/Kernel/inc/MantidKernel/IndexSet.h @@ -27,7 +27,7 @@ class MANTID_KERNEL_DLL IndexSet { public: IndexSet(size_t fullRange); IndexSet(int64_t min, int64_t max, size_t fullRange); - IndexSet(const std::vector<size_t> indices, size_t fullRange); + IndexSet(const std::vector<size_t> &indices, size_t fullRange); /// Returns the size of the set. size_t size() const { return m_size; } diff --git a/Framework/Kernel/inc/MantidKernel/MaskedProperty.h b/Framework/Kernel/inc/MantidKernel/MaskedProperty.h index 72c24d37fa78fbd8a90fe51cd12dbac56e5e2bed..b64a0cfb602f932bb12d687a0fac8e814d5c96dc 100644 --- a/Framework/Kernel/inc/MantidKernel/MaskedProperty.h +++ b/Framework/Kernel/inc/MantidKernel/MaskedProperty.h @@ -28,9 +28,10 @@ template <typename TYPE = std::string> class MaskedProperty : public Kernel::PropertyWithValue<TYPE> { public: /// Constructor with a validator - MaskedProperty(const std::string &name, TYPE defaultvalue, - IValidator_sptr validator = IValidator_sptr(new NullValidator), - const unsigned int direction = Direction::Input); + MaskedProperty( + const std::string &name, TYPE defaultvalue, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + const unsigned int direction = Direction::Input); /// Constructor with a validator without validation MaskedProperty(const std::string &name, const TYPE &defaultvalue, const unsigned int direction); diff --git a/Framework/Kernel/inc/MantidKernel/Material.h b/Framework/Kernel/inc/MantidKernel/Material.h index 6dc7b597b6977e8299211e143f3da7bd994a16cd..72cf13eac413a932bbe9d9a1a3e6d1a52ef120e9 100644 --- a/Framework/Kernel/inc/MantidKernel/Material.h +++ b/Framework/Kernel/inc/MantidKernel/Material.h @@ -56,7 +56,8 @@ public: using ChemicalFormula = std::vector<FormulaUnit>; - static ChemicalFormula parseChemicalFormula(const std::string chemicalSymbol); + static ChemicalFormula + parseChemicalFormula(const std::string &chemicalSymbol); /// Default constructor. Required for other parts of the code to /// function correctly. The material is considered "empty" diff --git a/Framework/Kernel/inc/MantidKernel/MatrixProperty.h b/Framework/Kernel/inc/MantidKernel/MatrixProperty.h index e3506e147a225f274ac90e0078a41cd51d8dca48..d840b9e35efa871e9c042907b98fd260089cd302 100644 --- a/Framework/Kernel/inc/MantidKernel/MatrixProperty.h +++ b/Framework/Kernel/inc/MantidKernel/MatrixProperty.h @@ -23,9 +23,10 @@ class MatrixProperty : public PropertyWithValue<Matrix<TYPE>> { public: /// Constructor - MatrixProperty(const std::string &propName, - IValidator_sptr validator = IValidator_sptr(new NullValidator), - unsigned int direction = Direction::Input); + MatrixProperty( + const std::string &propName, + const IValidator_sptr &validator = IValidator_sptr(new NullValidator), + unsigned int direction = Direction::Input); /// Copy constructor MatrixProperty(const MatrixProperty &rhs); // Unhide base class members (at minimum, avoids Intel compiler warning) diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h index d24066c5e5c17109ccccc3b4e7f1889a9112a820..5a2dc17558165abbccb4cb3c08a8acbed7a493b2 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h @@ -37,12 +37,12 @@ namespace Kernel { template <typename TYPE> class DLLExport PropertyWithValue : public Property { public: PropertyWithValue( - std::string name, TYPE defaultValue, + const std::string &name, TYPE defaultValue, IValidator_sptr validator = IValidator_sptr(new NullValidator), const unsigned int direction = Direction::Input); - PropertyWithValue(std::string name, TYPE defaultValue, + PropertyWithValue(const std::string &name, TYPE defaultValue, const unsigned int direction); - PropertyWithValue(std::string name, TYPE defaultValue, + PropertyWithValue(const std::string &name, TYPE defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, const unsigned int direction); PropertyWithValue(const PropertyWithValue<TYPE> &right); diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc index 3add2297950ec240a886fb2f878392f7686ad27f..1d2befbb731cbbae61e1058f732020a6e2578e33 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc @@ -42,7 +42,8 @@ namespace Kernel { * or Direction::InOut (Input & Output) property */ template <typename TYPE> -PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, +PropertyWithValue<TYPE>::PropertyWithValue(const std::string &name, + TYPE defaultValue, IValidator_sptr validator, unsigned int direction) : Property(std::move(name), typeid(TYPE), direction), m_value(defaultValue), @@ -56,7 +57,8 @@ PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, * or Direction::InOut (Input & Output) property */ template <typename TYPE> -PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, +PropertyWithValue<TYPE>::PropertyWithValue(const std::string &name, + TYPE defaultValue, unsigned int direction) : Property(std::move(name), typeid(TYPE), direction), m_value(defaultValue), m_initialValue(std::move(defaultValue)), @@ -77,7 +79,8 @@ PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, * or Direction::InOut (Input & Output) property */ template <typename TYPE> -PropertyWithValue<TYPE>::PropertyWithValue(std::string name, TYPE defaultValue, +PropertyWithValue<TYPE>::PropertyWithValue(const std::string &name, + TYPE defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, unsigned int direction) diff --git a/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h b/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h index 6da20d4b5a8ce644c6370b34d6ea8da9d8e63c73..175350eef35d7c3f6629ba28a6bbd8979bec287e 100644 --- a/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h +++ b/Framework/Kernel/inc/MantidKernel/RemoteJobManager.h @@ -70,11 +70,13 @@ public: private: // Wraps up some of the boilerplate code needed to execute HTTP GET and POST // requests - void initGetRequest(Poco::Net::HTTPRequest &req, std::string extraPath, - std::string queryString); - void initPostRequest(Poco::Net::HTTPRequest &req, std::string extraPath); + void initGetRequest(Poco::Net::HTTPRequest &req, const std::string &extraPath, + const std::string &queryString); + void initPostRequest(Poco::Net::HTTPRequest &req, + const std::string &extraPath); void initHTTPRequest(Poco::Net::HTTPRequest &req, const std::string &method, - std::string extraPath, std::string queryString = ""); + const std::string &extraPath, + const std::string &queryString = ""); std::string m_displayName; std::string diff --git a/Framework/Kernel/inc/MantidKernel/SingletonHolder.h b/Framework/Kernel/inc/MantidKernel/SingletonHolder.h index 51ffda22895f82578c9253cd9752cbc2edf0c509..84b793dbe82e059a192f4ba00d0bb0e0e2742d0a 100644 --- a/Framework/Kernel/inc/MantidKernel/SingletonHolder.h +++ b/Framework/Kernel/inc/MantidKernel/SingletonHolder.h @@ -35,7 +35,7 @@ using SingletonDeleterFn = std::function<void()>; /// Register the given deleter function to be called /// at exit -MANTID_KERNEL_DLL void deleteOnExit(SingletonDeleterFn func); +MANTID_KERNEL_DLL void deleteOnExit(const SingletonDeleterFn &func); /// Manage the lifetime of a class intended to be a singleton template <typename T> class SingletonHolder { diff --git a/Framework/Kernel/inc/MantidKernel/ThreadPool.h b/Framework/Kernel/inc/MantidKernel/ThreadPool.h index 7ac894b1dd51576777bf55cba98a6a7608922adf..2e60c564fe0323a1ff58f2d64428f3fe0ffdb203 100644 --- a/Framework/Kernel/inc/MantidKernel/ThreadPool.h +++ b/Framework/Kernel/inc/MantidKernel/ThreadPool.h @@ -42,7 +42,7 @@ public: void start(double waitSec = 0.0); - void schedule(std::shared_ptr<Task> task, bool start = false); + void schedule(const std::shared_ptr<Task> &task, bool start = false); void joinAll(); diff --git a/Framework/Kernel/inc/MantidKernel/Unit.h b/Framework/Kernel/inc/MantidKernel/Unit.h index 4951a26082b0ad016b249619808d3f547e8177c3..2d0a7201d86ce4af713a4c511d5fdc7d5c526b68 100644 --- a/Framework/Kernel/inc/MantidKernel/Unit.h +++ b/Framework/Kernel/inc/MantidKernel/Unit.h @@ -10,6 +10,8 @@ // Includes //---------------------------------------------------------------------- #include "MantidKernel/UnitLabel.h" +#include <utility> + #include <vector> #ifndef Q_MOC_RUN #include <boost/shared_ptr.hpp> @@ -684,13 +686,14 @@ private: //================================================================================================= -MANTID_KERNEL_DLL double timeConversionValue(std::string input_unit, - std::string output_unit); +MANTID_KERNEL_DLL double timeConversionValue(const std::string &input_unit, + const std::string &output_unit); template <typename T> -void timeConversionVector(std::vector<T> &vec, std::string input_unit, - std::string output_unit) { - double factor = timeConversionValue(input_unit, output_unit); +void timeConversionVector(std::vector<T> &vec, const std::string &input_unit, + const std::string &output_unit) { + double factor = + timeConversionValue(std::move(input_unit), std::move(output_unit)); if (factor != 1.0) std::transform(vec.begin(), vec.end(), vec.begin(), [factor](T x) -> T { return x * static_cast<T>(factor); }); diff --git a/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h b/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h index ff57c6ab9391bd747be5668a1cd9a01c2424bde8..5b2f259e393293c1bbf75bbead93a91023afc878 100644 --- a/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h +++ b/Framework/Kernel/inc/MantidKernel/UserCatalogInfo.h @@ -24,14 +24,14 @@ public: template <typename T> CatalogConfigService *makeCatalogConfigServiceAdapter( - const T &adaptee, const std::string key = "icatDownload.mountPoint") { + const T &adaptee, const std::string &key = "icatDownload.mountPoint") { class Adapter : public CatalogConfigService { private: const T &m_adaptee; std::string m_key; public: - Adapter(const T &adaptee, const std::string key) + Adapter(const T &adaptee, const std::string &key) : m_adaptee(adaptee), m_key(key) {} OptionalPath preferredMountPoint() const override { auto const mountPoint = m_adaptee.getString(m_key); diff --git a/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h b/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h index 6b4cd081f68a5af3795deb85b55cb7f2fd54612c..29340d9c51360712a331524aebb3c514590c1548 100644 --- a/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h +++ b/Framework/Kernel/inc/MantidKernel/VisibleWhenProperty.h @@ -19,8 +19,8 @@ class DLLExport VisibleWhenProperty : public EnabledWhenProperty { public: /// Constructs a VisibleWhenProperty object which checks the property /// with name given and if it matches the criteria makes it visible - VisibleWhenProperty(std::string otherPropName, ePropertyCriterion when, - std::string value = ""); + VisibleWhenProperty(const std::string &otherPropName, ePropertyCriterion when, + const std::string &value = ""); /// Constructs a VisibleWhenProperty object which copies two /// already constructed VisibleWhenProperty objects and returns the result diff --git a/Framework/Kernel/src/ArrayProperty.cpp b/Framework/Kernel/src/ArrayProperty.cpp index a9b9652f4922a556962e2218d920ddac7926a62d..eea56e12f4e265c5c08455b76bea27226de92659 100644 --- a/Framework/Kernel/src/ArrayProperty.cpp +++ b/Framework/Kernel/src/ArrayProperty.cpp @@ -19,8 +19,8 @@ namespace Kernel { * @param direction :: The direction (Input/Output/InOut) of this property */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, std::vector<T> vec, - IValidator_sptr validator, +ArrayProperty<T>::ArrayProperty(const std::string &name, std::vector<T> vec, + const IValidator_sptr &validator, const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::move(vec), std::move(validator), direction) {} @@ -34,7 +34,8 @@ ArrayProperty<T>::ArrayProperty(std::string name, std::vector<T> vec, */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, IValidator_sptr validator, +ArrayProperty<T>::ArrayProperty(const std::string &name, + const IValidator_sptr &validator, const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::vector<T>(), std::move(validator), direction) {} @@ -47,7 +48,8 @@ ArrayProperty<T>::ArrayProperty(std::string name, IValidator_sptr validator, * @param direction :: The direction (Input/Output/InOut) of this property */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, const unsigned int direction) +ArrayProperty<T>::ArrayProperty(const std::string &name, + const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::vector<T>(), IValidator_sptr(new NullValidator), direction) {} @@ -68,8 +70,9 @@ ArrayProperty<T>::ArrayProperty(std::string name, const unsigned int direction) * the array type */ template <typename T> -ArrayProperty<T>::ArrayProperty(std::string name, const std::string &values, - IValidator_sptr validator, +ArrayProperty<T>::ArrayProperty(const std::string &name, + const std::string &values, + const IValidator_sptr &validator, const unsigned int direction) : PropertyWithValue<std::vector<T>>(std::move(name), std::vector<T>(), values, std::move(validator), diff --git a/Framework/Kernel/src/CompositeValidator.cpp b/Framework/Kernel/src/CompositeValidator.cpp index d3a49c6555078bc263ff1c30bb8a0eb899afa9ca..696a684d5efb63554c3b030c413c576c9a52db73 100644 --- a/Framework/Kernel/src/CompositeValidator.cpp +++ b/Framework/Kernel/src/CompositeValidator.cpp @@ -68,7 +68,7 @@ Kernel::IValidator_sptr CompositeValidator::clone() const { /** Adds a validator to the group of validators to check * @param child :: A pointer to the validator to add */ -void CompositeValidator::add(Kernel::IValidator_sptr child) { +void CompositeValidator::add(const Kernel::IValidator_sptr &child) { m_children.emplace_back(child); } @@ -106,7 +106,7 @@ std::string CompositeValidator::checkAny(const boost::any &value) const { // capture its error message to a stream so we can potentially print it out // to the user if required. const auto checkIfValid = [&errorStream, - &value](const IValidator_sptr validator) { + &value](const IValidator_sptr &validator) { const auto errorMessage = validator->check(value); if (errorMessage.empty()) { return true; diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index 5e6b014115aa8b36c639bfab121eb149a1396457..fcd12bc765e9b373f7f570eb25591c7ab2bb5349 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -651,8 +651,6 @@ void ConfigServiceImpl::createUserPropertiesFile() const { filestr << "##\n"; filestr << "## GENERAL\n"; filestr << "##\n\n"; - filestr << "## Set the number of algorithm properties to retain\n"; - filestr << "#algorithms.retained=90\n\n"; filestr << "## Set the maximum number of cores used to run algorithms over\n"; filestr << "#MultiThreaded.MaxCores=4\n\n"; diff --git a/Framework/Kernel/src/ErrorReporter.cpp b/Framework/Kernel/src/ErrorReporter.cpp index 638287dac6ced487fd6e3ddd7687e5712493650c..a79d5dcd835cc8e8ca724523d9056202b48bcf5f 100644 --- a/Framework/Kernel/src/ErrorReporter.cpp +++ b/Framework/Kernel/src/ErrorReporter.cpp @@ -30,27 +30,27 @@ Logger g_log("ErrorReporter"); // Constructor for ErrorReporter /** Constructor */ -ErrorReporter::ErrorReporter(const std::string application, - const Types::Core::time_duration upTime, - const std::string exitCode, const bool share) +ErrorReporter::ErrorReporter(const std::string &application, + const Types::Core::time_duration &upTime, + const std::string &exitCode, const bool share) : ErrorReporter(application, upTime, exitCode, share, "", "", "", "") {} /** Constructor */ -ErrorReporter::ErrorReporter(const std::string application, - const Types::Core::time_duration upTime, - const std::string exitCode, const bool share, - const std::string name, const std::string email, - const std::string textBox) +ErrorReporter::ErrorReporter(const std::string &application, + const Types::Core::time_duration &upTime, + const std::string &exitCode, const bool share, + const std::string &name, const std::string &email, + const std::string &textBox) : ErrorReporter(application, upTime, exitCode, share, name, email, textBox, "") {} -ErrorReporter::ErrorReporter(const std::string application, - const Types::Core::time_duration upTime, - const std::string exitCode, const bool share, - const std::string name, const std::string email, - const std::string textBox, - const std::string traceback) +ErrorReporter::ErrorReporter(const std::string &application, + const Types::Core::time_duration &upTime, + const std::string &exitCode, const bool share, + const std::string &name, const std::string &email, + const std::string &textBox, + const std::string &traceback) : m_application(application), m_exitCode(exitCode), m_upTime(upTime), m_share(share), m_name(name), m_email(email), m_textbox(textBox), m_stacktrace(traceback) { diff --git a/Framework/Kernel/src/IndexSet.cpp b/Framework/Kernel/src/IndexSet.cpp index 9599e391dc17713a5b3b2571be065247d5fdc291..a7842786887f74e977d6e0aa099005667b141045 100644 --- a/Framework/Kernel/src/IndexSet.cpp +++ b/Framework/Kernel/src/IndexSet.cpp @@ -30,7 +30,7 @@ IndexSet::IndexSet(int64_t min, int64_t max, size_t fullRange) { /// Constructor for a set containing all specified indices. Range is verified at /// construction time and duplicates are removed. -IndexSet::IndexSet(const std::vector<size_t> indices, size_t fullRange) +IndexSet::IndexSet(const std::vector<size_t> &indices, size_t fullRange) : m_isRange(false) { // We use a set to create unique and ordered indices. std::set<size_t> index_set; diff --git a/Framework/Kernel/src/MaskedProperty.cpp b/Framework/Kernel/src/MaskedProperty.cpp index ba8d54563238dfa8998f37fb172c8597cb967da5..22e9a7dcdda790e2ba8746e3928e13ce4f768164 100644 --- a/Framework/Kernel/src/MaskedProperty.cpp +++ b/Framework/Kernel/src/MaskedProperty.cpp @@ -22,7 +22,7 @@ namespace Kernel { */ template <typename TYPE> MaskedProperty<TYPE>::MaskedProperty(const std::string &name, TYPE defaultvalue, - IValidator_sptr validator, + const IValidator_sptr &validator, const unsigned int direction) : Kernel::PropertyWithValue<TYPE>(name, defaultvalue, validator, direction), m_maskedValue("") { diff --git a/Framework/Kernel/src/Material.cpp b/Framework/Kernel/src/Material.cpp index 275508c4fd80f61062843bacb8e4ba92a9544001..72794908c5538447e7286a980fedc430c4ce933c 100644 --- a/Framework/Kernel/src/Material.cpp +++ b/Framework/Kernel/src/Material.cpp @@ -600,7 +600,7 @@ getAtomName(const std::string &text) // TODO change to get number after letters } // namespace Material::ChemicalFormula -Material::parseChemicalFormula(const std::string chemicalSymbol) { +Material::parseChemicalFormula(const std::string &chemicalSymbol) { Material::ChemicalFormula CF; tokenizer tokens(chemicalSymbol, " -", diff --git a/Framework/Kernel/src/MaterialBuilder.cpp b/Framework/Kernel/src/MaterialBuilder.cpp index 08af881eecbab11feaf43d2209374384632fa84b..23be2c3e8e6a4972b59224f0c6b92b801ae5334e 100644 --- a/Framework/Kernel/src/MaterialBuilder.cpp +++ b/Framework/Kernel/src/MaterialBuilder.cpp @@ -19,7 +19,7 @@ using PhysicalConstants::NeutronAtom; namespace Kernel { namespace { -inline bool isEmpty(const boost::optional<double> value) { +inline bool isEmpty(const boost::optional<double> &value) { return !value || value == Mantid::EMPTY_DBL(); } } // namespace diff --git a/Framework/Kernel/src/MatrixProperty.cpp b/Framework/Kernel/src/MatrixProperty.cpp index 95f70eda350f4e629b917fa962bde0e7cb24f64a..3a3cc8bad805a0b48b01467363846e438a338e57 100644 --- a/Framework/Kernel/src/MatrixProperty.cpp +++ b/Framework/Kernel/src/MatrixProperty.cpp @@ -22,7 +22,7 @@ namespace Kernel { */ template <typename TYPE> MatrixProperty<TYPE>::MatrixProperty(const std::string &propName, - IValidator_sptr validator, + const IValidator_sptr &validator, unsigned int direction) : PropertyWithValue<HeldType>(propName, HeldType(), validator, direction) {} diff --git a/Framework/Kernel/src/RemoteJobManager.cpp b/Framework/Kernel/src/RemoteJobManager.cpp index 15e6cbe67032d0a1b02e24d2910131962d6e2a9a..bb6e28d9b94fabe2ab5049bb0218e59a31e2e081 100644 --- a/Framework/Kernel/src/RemoteJobManager.cpp +++ b/Framework/Kernel/src/RemoteJobManager.cpp @@ -17,6 +17,7 @@ #include <Poco/URI.h> #include <sstream> +#include <utility> namespace Mantid { namespace Kernel { @@ -182,21 +183,22 @@ std::istream &RemoteJobManager::httpPost(const std::string &path, // Wrappers for a lot of the boilerplate code needed to perform an HTTPS GET or // POST void RemoteJobManager::initGetRequest(Poco::Net::HTTPRequest &req, - std::string extraPath, - std::string queryString) { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, extraPath, - queryString); + const std::string &extraPath, + const std::string &queryString) { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, + std::move(extraPath), std::move(queryString)); } void RemoteJobManager::initPostRequest(Poco::Net::HTTPRequest &req, - std::string extraPath) { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, extraPath); + const std::string &extraPath) { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, + std::move(extraPath)); } void RemoteJobManager::initHTTPRequest(Poco::Net::HTTPRequest &req, const std::string &method, - std::string extraPath, - std::string queryString) { + const std::string &extraPath, + const std::string &queryString) { // Set up the session object if (m_session) { diff --git a/Framework/Kernel/src/SingletonHolder.cpp b/Framework/Kernel/src/SingletonHolder.cpp index c418e89babf2aa868c8990d3755263e9ff2ef143..8d41da9b4ba715dc9bc1e3868b63f918d7fddf61 100644 --- a/Framework/Kernel/src/SingletonHolder.cpp +++ b/Framework/Kernel/src/SingletonHolder.cpp @@ -36,7 +36,7 @@ void cleanupSingletons() { /// functions are added to the start of the list so on deletion it is last in, /// first out /// @param func :: Exit function to call - the singleton destructor function -void deleteOnExit(SingletonDeleterFn func) { +void deleteOnExit(const SingletonDeleterFn &func) { auto &deleters = cleanupList(); if (deleters.empty()) { atexit(&cleanupSingletons); diff --git a/Framework/Kernel/src/ThreadPool.cpp b/Framework/Kernel/src/ThreadPool.cpp index 7513c6a972cbaf732aaecfe27a2dd7e14875f3f5..3a55ae88c8d81ea87f2296f963103ae586902c01 100644 --- a/Framework/Kernel/src/ThreadPool.cpp +++ b/Framework/Kernel/src/ThreadPool.cpp @@ -125,7 +125,7 @@ void ThreadPool::start(double waitSec) { * @param task :: pointer to a Task object to run. * @param start :: start the thread at the same time; default false */ -void ThreadPool::schedule(std::shared_ptr<Task> task, bool start) { +void ThreadPool::schedule(const std::shared_ptr<Task> &task, bool start) { if (task) { m_scheduler->push(task); // Start all the threads if they were not already. diff --git a/Framework/Kernel/src/Unit.cpp b/Framework/Kernel/src/Unit.cpp index 458efa1090fd393aec315b4e89a5b0827d4d0edd..41373f2e8edd3561f7168d9a3a64779a829f497d 100644 --- a/Framework/Kernel/src/Unit.cpp +++ b/Framework/Kernel/src/Unit.cpp @@ -1291,7 +1291,8 @@ double AtomicDistance::conversionTOFMax() const { // ================================================================================ -double timeConversionValue(std::string input_unit, std::string output_unit) { +double timeConversionValue(const std::string &input_unit, + const std::string &output_unit) { std::map<std::string, double> timesList; double seconds = 1.0e9; double milliseconds = 1.0e-3 * seconds; diff --git a/Framework/Kernel/src/VisibleWhenProperty.cpp b/Framework/Kernel/src/VisibleWhenProperty.cpp index 85eb26ec50d4fdc7f66f3a467ceb5bc3a925fd4b..82adc3a460d1a945def9e28211a6ca913f06874f 100644 --- a/Framework/Kernel/src/VisibleWhenProperty.cpp +++ b/Framework/Kernel/src/VisibleWhenProperty.cpp @@ -16,9 +16,9 @@ namespace Kernel { * @param value :: For the IS_EQUAL_TO or IS_NOT_EQUAL_TO condition, the value * (as string) to check for */ -VisibleWhenProperty::VisibleWhenProperty(std::string otherPropName, +VisibleWhenProperty::VisibleWhenProperty(const std::string &otherPropName, ePropertyCriterion when, - std::string value) + const std::string &value) : EnabledWhenProperty(otherPropName, when, value) {} /** Multiple conditions constructor - takes two VisibleWhenProperty diff --git a/Framework/Kernel/test/BinaryFileTest.h b/Framework/Kernel/test/BinaryFileTest.h index 4505525a626b61d0873f239a5a07fdb0da3b0f6e..9f6440199afa45072cfbb60a4d406f5eb3beb0f2 100644 --- a/Framework/Kernel/test/BinaryFileTest.h +++ b/Framework/Kernel/test/BinaryFileTest.h @@ -33,7 +33,7 @@ struct DasEvent { }; /** Creates a dummy file with so many bytes */ -static void MakeDummyFile(std::string filename, size_t num_bytes) { +static void MakeDummyFile(const std::string &filename, size_t num_bytes) { std::vector<char> buffer(num_bytes); for (size_t i = 0; i < num_bytes; i++) { // Put 1,2,3 in 32-bit ints diff --git a/Framework/Kernel/test/ConfigPropertyObserverTest.h b/Framework/Kernel/test/ConfigPropertyObserverTest.h index eda5f9655bef291dee9bf6423fa008a478224cbe..9982dbd761b2a028d362ebf532ce475e1c2c1f2a 100644 --- a/Framework/Kernel/test/ConfigPropertyObserverTest.h +++ b/Framework/Kernel/test/ConfigPropertyObserverTest.h @@ -15,7 +15,7 @@ using namespace Mantid::Kernel; template <typename Callback> class MockObserver : ConfigPropertyObserver { public: - MockObserver(std::string propertyName, Callback callback) + MockObserver(const std::string &propertyName, Callback callback) : ConfigPropertyObserver(std::move(propertyName)), m_callback(callback) {} protected: @@ -41,8 +41,6 @@ public: ConfigService::Instance().getString("datasearch.directories"); m_defaultSaveDirectory = ConfigService::Instance().getString("defaultsave.directory"); - m_retainedAlgorithms = - ConfigService::Instance().getString("algorithms.retained"); } void tearDown() override { @@ -50,8 +48,6 @@ public: m_searchDirectories); ConfigService::Instance().setString("defaultsave.directory", m_defaultSaveDirectory); - ConfigService::Instance().setString("algorithms.retained", - m_retainedAlgorithms); } void testRecievesCallbackForSearchDirectoryChange() { @@ -96,7 +92,7 @@ public: }); auto callCountB = 0; auto observerB = - makeMockObserver("algorithms.retained", + makeMockObserver("projectRecovery.secondsBetween", [&callCountB](const std::string &newValue, const std::string &prevValue) -> void { UNUSED_ARG(newValue); @@ -105,7 +101,8 @@ public: }); ConfigService::Instance().setString("datasearch.directories", "/dev/null"); - ConfigService::Instance().setString("algorithms.retained", "40"); + ConfigService::Instance().setString("projectRecovery.secondsBetween", + "600"); TS_ASSERT_EQUALS(1, callCountA); TS_ASSERT_EQUALS(1, callCountB); diff --git a/Framework/Kernel/test/ConfigServiceTest.h b/Framework/Kernel/test/ConfigServiceTest.h index cacccda23a13172c89ef521d0821b2a2bbc7eda3..384476a09cbc3ef59b4fe75bba5527caf10e7485 100644 --- a/Framework/Kernel/test/ConfigServiceTest.h +++ b/Framework/Kernel/test/ConfigServiceTest.h @@ -329,21 +329,20 @@ public: void TestCustomProperty() { std::string countString = - ConfigService::Instance().getString("algorithms.retained"); - TS_ASSERT_EQUALS(countString, "50"); + ConfigService::Instance().getString("projectRecovery.secondsBetween"); + TS_ASSERT_EQUALS(countString, "60"); } void TestCustomPropertyAsValue() { - // Mantid.legs is defined in the properties script as 6 int value = ConfigService::Instance() - .getValue<int>("algorithms.retained") + .getValue<int>("projectRecovery.secondsBetween") .get_value_or(0); double dblValue = ConfigService::Instance() - .getValue<double>("algorithms.retained") + .getValue<double>("projectRecovery.secondsBetween") .get_value_or(0); - TS_ASSERT_EQUALS(value, 50); - TS_ASSERT_EQUALS(dblValue, 50.0); + TS_ASSERT_EQUALS(value, 60); + TS_ASSERT_EQUALS(dblValue, 60.0); } void TestMissingProperty() { diff --git a/Framework/Kernel/test/CowPtrTest.h b/Framework/Kernel/test/CowPtrTest.h index e8de0414bac436662920b2c08a1af1d08eab3687..5736a8dee62a2ad73e15066b772ce1b91c2a0e69 100644 --- a/Framework/Kernel/test/CowPtrTest.h +++ b/Framework/Kernel/test/CowPtrTest.h @@ -10,6 +10,7 @@ #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> #include <cxxtest/TestSuite.h> +#include <memory> using namespace Mantid::Kernel; @@ -38,9 +39,8 @@ public: } void testConstructorByPtr() { - - auto *resource = new MyType{2}; - cow_ptr<MyType> cow{resource}; + auto resource = std::make_unique<MyType>(2); + cow_ptr<MyType> cow{resource.release()}; TSM_ASSERT_EQUALS("COW does not hold the expected value", 2, cow->value); } diff --git a/Framework/Kernel/test/InterpolationTest.h b/Framework/Kernel/test/InterpolationTest.h index 9d9e41a15f477a12f775e40f34a7f1e0e8e0be6b..47a491ff8b9e2a2408a0c57d3017f986be5a633e 100644 --- a/Framework/Kernel/test/InterpolationTest.h +++ b/Framework/Kernel/test/InterpolationTest.h @@ -227,8 +227,8 @@ public: } private: - Interpolation getInitializedInterpolation(std::string xUnit, - std::string yUnit) { + Interpolation getInitializedInterpolation(const std::string &xUnit, + const std::string &yUnit) { Interpolation interpolation; // take values from constructor @@ -286,7 +286,7 @@ private: * It takes a string argument to make it more obvious where the problem is. */ void checkValue(const Interpolation &interpolation, double x, double y, - std::string testedRange) { + const std::string &testedRange) { std::ostringstream errorString; errorString << "Interpolation error " << testedRange; diff --git a/Framework/Kernel/test/LogParserTest.h b/Framework/Kernel/test/LogParserTest.h index cc2e5d5e9fbf3e5c9e806f9e1ed44ce967ef0e39..47f6e248f6eb27b6d50948a2afe6c9f78c01672f 100644 --- a/Framework/Kernel/test/LogParserTest.h +++ b/Framework/Kernel/test/LogParserTest.h @@ -69,10 +69,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -119,10 +119,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -156,10 +156,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -216,9 +216,9 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; + ++v; + ++v; + ++v; // time 4 TS_ASSERT_EQUALS(v->second, " line 4"); const auto &ti_data4 = v->first.to_tm(); @@ -381,10 +381,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 // TS_ASSERT(!isNaN(v->second)); // last time diff --git a/Framework/Kernel/test/RegexStringsTest.h b/Framework/Kernel/test/RegexStringsTest.h index 6eed39b23afb3fb8b0b2545dc0e9f6adc29324ba..4f3e6c5dbdb971b307fc6bf90c0a37aa0a01324a 100644 --- a/Framework/Kernel/test/RegexStringsTest.h +++ b/Framework/Kernel/test/RegexStringsTest.h @@ -144,7 +144,6 @@ public: } void testStrFullCut() { - std::vector<double> dblresult; double sgldblResult; std::string input("100.01 101.02 103.04 105.06 Remainder of string"); TS_ASSERT_EQUALS( diff --git a/Framework/Kernel/test/SimpleJSONTest.h b/Framework/Kernel/test/SimpleJSONTest.h index 19e730790ae0e460fd90cc155537fd2ae645b111..e4c1e478db2e8b71dea5fa383524e9e351bb1c99 100644 --- a/Framework/Kernel/test/SimpleJSONTest.h +++ b/Framework/Kernel/test/SimpleJSONTest.h @@ -51,8 +51,6 @@ public: void test_JSONArray() { std::string str = "json failure here"; - std::istringstream input(str); - std::string res; JSONArray ja; TS_ASSERT_THROWS_NOTHING(ja.emplace_back(str)); @@ -64,11 +62,10 @@ public: } void test_JSONObjectWrongStrings() { - std::string str = "json failure here"; - std::istringstream input(str); + std::istringstream input; std::string res; - str = ""; + std::string str = ""; JSONObject jo; TS_ASSERT_THROWS(initFromStream(jo, input), const JSONParseException &); TS_ASSERT_THROWS_NOTHING(jo["no_param"].getValue(res)); diff --git a/Framework/Kernel/test/ThreadSchedulerMutexesTest.h b/Framework/Kernel/test/ThreadSchedulerMutexesTest.h index 3c745e553dfc4d9e4ead76b366fd3e9a5d97b809..d2c7285e9324004ec011c800d0e7e90c0e441e5b 100644 --- a/Framework/Kernel/test/ThreadSchedulerMutexesTest.h +++ b/Framework/Kernel/test/ThreadSchedulerMutexesTest.h @@ -9,6 +9,8 @@ #include "MantidKernel/System.h" #include "MantidKernel/Timer.h" #include <boost/make_shared.hpp> +#include <utility> + #include <cxxtest/TestSuite.h> #include "MantidKernel/ThreadSchedulerMutexes.h" @@ -24,7 +26,7 @@ public: class TaskWithMutex : public Task { public: TaskWithMutex(boost::shared_ptr<std::mutex> mutex, double cost) { - m_mutex = mutex; + m_mutex = std::move(mutex); m_cost = cost; } diff --git a/Framework/Kernel/test/TypedValidatorTest.h b/Framework/Kernel/test/TypedValidatorTest.h index 266c39e55661a00228aadfb3de2e385e8044825b..2be8724760fa3bfacff1882c0873bc5d70b60c0b 100644 --- a/Framework/Kernel/test/TypedValidatorTest.h +++ b/Framework/Kernel/test/TypedValidatorTest.h @@ -69,7 +69,7 @@ public: private: template <typename HeldType> void checkIsValidReturnsEmptyString( - const Mantid::Kernel::IValidator_sptr valueChecker, + const Mantid::Kernel::IValidator_sptr &valueChecker, const HeldType &value) { std::string error; TS_ASSERT_THROWS_NOTHING(error = valueChecker->isValid(value)); diff --git a/Framework/Kernel/test/UnitLabelTest.h b/Framework/Kernel/test/UnitLabelTest.h index e3a3db0efc8c83c22a5f9485d40bb318c2bb2f35..0b383a9f9847ef0f9f514d74089f94b512529390 100644 --- a/Framework/Kernel/test/UnitLabelTest.h +++ b/Framework/Kernel/test/UnitLabelTest.h @@ -70,7 +70,7 @@ public: } private: - void doImplicitConversionTest(UnitLabel lbl, std::string expected) { + void doImplicitConversionTest(const UnitLabel &lbl, std::string expected) { TS_ASSERT_EQUALS(expected, lbl.ascii()); const auto &utf8 = lbl.utf8(); TS_ASSERT_EQUALS(std::wstring(expected.begin(), expected.end()), utf8); diff --git a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h index 6bec842c938e8c429479d6214bb9fde7b460586b..77179fa9b50eb13ae9db68b3e0c672098b92a20f 100644 --- a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h @@ -62,13 +62,14 @@ private: void getIntArray(const std::string &par, std::vector<int> &arr, const size_t dim); void getData(int period, int index, int count, - boost::shared_ptr<API::MatrixWorkspace> workspace, + const boost::shared_ptr<API::MatrixWorkspace> &workspace, size_t workspaceIndex); void calculateIndicesForReading(std::vector<int> &index, std::vector<int> &count); void loadSpectraMap(); - void runLoadInstrument(boost::shared_ptr<API::MatrixWorkspace> localWorkspace, - const std::string &iName); + void runLoadInstrument( + const boost::shared_ptr<API::MatrixWorkspace> &localWorkspace, + const std::string &iName); void loadTimeRegimes(); int getTimeRegimeToLoad() const; bool isPeriodIgnored(int period) const; diff --git a/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h b/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h index 36fc120bfc654f0cc446b422f5ed63622f254957..461ee24881c351223b95fdcf5ac79fab9f112d91 100644 --- a/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h +++ b/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaStreamDecoder.h @@ -35,7 +35,7 @@ public: public: using FnType = std::function<void()>; - Callback(Callback::FnType callback) : m_mutex(), m_callback() { + Callback(const Callback::FnType &callback) : m_mutex(), m_callback() { setFunction(std::move(callback)); } diff --git a/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h b/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h index 3d5dda4a210a9ffb12ddb0b1588027883b0a0dda..67c22d079b2b46bd7708021d1a0ac2f4c15e5b5f 100644 --- a/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h +++ b/Framework/LiveData/inc/MantidLiveData/LoadLiveData.h @@ -42,14 +42,15 @@ private: void runPostProcessing(); void replaceChunk(Mantid::API::Workspace_sptr chunkWS); - void addChunk(Mantid::API::Workspace_sptr chunkWS); - void addMatrixWSChunk(API::Workspace_sptr accumWS, - API::Workspace_sptr chunkWS); + void addChunk(const Mantid::API::Workspace_sptr &chunkWS); + void addMatrixWSChunk(const API::Workspace_sptr &accumWS, + const API::Workspace_sptr &chunkWS); void addMDWSChunk(API::Workspace_sptr &accumWS, const API::Workspace_sptr &chunkWS); - void appendChunk(Mantid::API::Workspace_sptr chunkWS); - API::Workspace_sptr appendMatrixWSChunk(API::Workspace_sptr accumWS, - Mantid::API::Workspace_sptr chunkWS); + void appendChunk(const Mantid::API::Workspace_sptr &chunkWS); + API::Workspace_sptr + appendMatrixWSChunk(API::Workspace_sptr accumWS, + const Mantid::API::Workspace_sptr &chunkWS); void updateDefaultBinBoundaries(API::Workspace *workspace); /// The "accumulation" workspace = after adding, but before post-processing diff --git a/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp b/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp index 3ac632ce22bc2cb6f4a5f2157a91c00455eecddc..0a1d994f055b40da16b6730c209c505b265a3bf9 100644 --- a/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp +++ b/Framework/LiveData/src/ISIS/DAE/isisds_command.cpp @@ -86,10 +86,10 @@ typedef struct { /* wait until read len bytes, return <=0 on error */ static int recv_all(SOCKET s, void *buffer, int len, int flags) { auto *cbuffer = reinterpret_cast<char *>(buffer); - int n, ntot; + int ntot; ntot = 0; while (len > 0) { - n = recv(s, cbuffer, len, flags); + int n = recv(s, cbuffer, len, flags); if (n <= 0) { return n; /* error */ } @@ -283,7 +283,7 @@ int isisds_send_command(SOCKET s, const char *command, const void *data, static int isisds_recv_command_helper(SOCKET s, char **command, void **data, ISISDSDataType *type, int dims_array[], int *ndims, int do_alloc) { - int n, len_data, size_in, i; + int n, len_data, i; isisds_command_header_t comm; n = recv_all(s, reinterpret_cast<char *>(&comm), sizeof(comm), 0); if (n != sizeof(comm)) { @@ -308,7 +308,7 @@ static int isisds_recv_command_helper(SOCKET s, char **command, void **data, *data = malloc(len_data + 1); (reinterpret_cast<char *>(*data))[len_data] = '\0'; } else { - size_in = 1; + int size_in = 1; for (i = 0; i < *ndims; i++) { size_in *= dims_array[i]; } diff --git a/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp b/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp index dfc83b63f7b46cb7e0243b12dfdd815b89df572e..73abf7e03159e7791935b9eedfa5091fd23a4e0e 100644 --- a/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp +++ b/Framework/LiveData/src/ISIS/FakeISISEventDAE.cpp @@ -17,6 +17,8 @@ #include <Poco/Net/StreamSocket.h> #include <Poco/Net/TCPServer.h> +#include <utility> + namespace Mantid { namespace LiveData { // Register the algorithm into the algorithm factory @@ -46,7 +48,8 @@ public: TestServerConnection(const Poco::Net::StreamSocket &soc, int nper, int nspec, int rate, int nevents, boost::shared_ptr<Progress> prog) : Poco::Net::TCPServerConnection(soc), m_nPeriods(nper), - m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), m_prog(prog) { + m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), + m_prog(std::move(prog)) { m_prog->report(0, "Client Connected"); sendInitialSetup(); } @@ -135,7 +138,8 @@ public: TestServerConnectionFactory(int nper, int nspec, int rate, int nevents, boost::shared_ptr<Progress> prog) : Poco::Net::TCPServerConnectionFactory(), m_nPeriods(nper), - m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), m_prog(prog) {} + m_nSpectra(nspec), m_Rate(rate), m_nEvents(nevents), + m_prog(std::move(prog)) {} /** * The factory method. * @param socket :: The socket. diff --git a/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp b/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp index cb3d773355b5b45cf3d4006a642e48e5995b0f9f..f5b701b2778e5bc43ef17e0d4b83079e856adae8 100644 --- a/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp +++ b/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp @@ -422,7 +422,7 @@ void ISISHistoDataListener::calculateIndicesForReading( * @param workspaceIndex :: index in workspace to store data */ void ISISHistoDataListener::getData(int period, int index, int count, - API::MatrixWorkspace_sptr workspace, + const API::MatrixWorkspace_sptr &workspace, size_t workspaceIndex) { const int numberOfBins = m_numberOfBins[m_timeRegime]; const size_t bufferSize = count * (numberOfBins + 1) * sizeof(int); @@ -466,7 +466,7 @@ void ISISHistoDataListener::loadSpectraMap() { * @param iName :: The instrument name */ void ISISHistoDataListener::runLoadInstrument( - MatrixWorkspace_sptr localWorkspace, const std::string &iName) { + const MatrixWorkspace_sptr &localWorkspace, const std::string &iName) { auto loadInst = API::AlgorithmFactory::Instance().create("LoadInstrument", -1); if (!loadInst) diff --git a/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp b/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp index 588fec16bf274e85898e358716a6c6a1ec9e8b91..4f8ac88f0fe38254a78cae4183ffa3f9839ef1a0 100644 --- a/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/IKafkaStreamDecoder.cpp @@ -21,6 +21,8 @@ GNU_DIAG_ON("conversion") #include <json/json.h> +#include <utility> + using namespace Mantid::Types; namespace { @@ -54,7 +56,7 @@ IKafkaStreamDecoder::IKafkaStreamDecoder(std::shared_ptr<IKafkaBroker> broker, const std::string &sampleEnvTopic, const std::string &chopperTopic, const std::string &monitorTopic) - : m_broker(broker), m_streamTopic(streamTopic), + : m_broker(std::move(broker)), m_streamTopic(streamTopic), m_runInfoTopic(runInfoTopic), m_spDetTopic(spDetTopic), m_sampleEnvTopic(sampleEnvTopic), m_chopperTopic(chopperTopic), m_monitorTopic(monitorTopic), m_interrupt(false), m_specToIdx(), @@ -227,7 +229,7 @@ void IKafkaStreamDecoder::checkIfAllStopOffsetsReached( bool &checkOffsets) { if (std::all_of(reachedEnd.cbegin(), reachedEnd.cend(), - [](std::pair<std::string, std::vector<bool>> kv) { + [](const std::pair<std::string, std::vector<bool>> &kv) { return std::all_of( kv.second.cbegin(), kv.second.cend(), [](bool partitionEnd) { return partitionEnd; }); diff --git a/Framework/LiveData/src/Kafka/KafkaBroker.cpp b/Framework/LiveData/src/Kafka/KafkaBroker.cpp index d9a261729ea6ae14ea1cd6c29d7afd6799eea215..574ef98cc5fd2ad991eb74b505bcea2508c462b9 100644 --- a/Framework/LiveData/src/Kafka/KafkaBroker.cpp +++ b/Framework/LiveData/src/Kafka/KafkaBroker.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidLiveData/Kafka/KafkaBroker.h" #include "MantidLiveData/Kafka/KafkaTopicSubscriber.h" @@ -15,7 +17,7 @@ namespace LiveData { * @param address The address of a broker in the form host:port */ KafkaBroker::KafkaBroker(std::string address) - : IKafkaBroker(), m_address(address) {} + : IKafkaBroker(), m_address(std::move(address)) {} /** * Create an object to provide access to a topic stream from this broker diff --git a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp index 65e2f62c8f165b518794f67e7f11cfb49e8f9cf2..6a97ab35a03390685e88641a8a5edac7e36c0645 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp @@ -30,6 +30,8 @@ GNU_DIAG_ON("conversion") #include <chrono> #include <json/json.h> #include <numeric> +#include <utility> + #include <tbb/parallel_sort.h> using namespace Mantid::Types; @@ -120,8 +122,9 @@ KafkaEventStreamDecoder::KafkaEventStreamDecoder( const std::string &runInfoTopic, const std::string &spDetTopic, const std::string &sampleEnvTopic, const std::string &chopperTopic, const std::string &monitorTopic, const std::size_t bufferThreshold) - : IKafkaStreamDecoder(broker, eventTopic, runInfoTopic, spDetTopic, - sampleEnvTopic, chopperTopic, monitorTopic), + : IKafkaStreamDecoder(std::move(broker), eventTopic, runInfoTopic, + spDetTopic, sampleEnvTopic, chopperTopic, + monitorTopic), m_intermediateBufferFlushThreshold(bufferThreshold) { #ifndef _OPENMP g_log.warning() << "Multithreading is not available on your system. This " diff --git a/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp index 4c9b432d3e398dd9a460aeff696de8153a66c6e0..90398f877667b872eeb9f6ee544cb3c6bd62aea4 100644 --- a/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaHistoStreamDecoder.cpp @@ -29,6 +29,8 @@ GNU_DIAG_ON("conversion") #include <json/json.h> +#include <utility> + namespace { const std::string PROTON_CHARGE_PROPERTY = "proton_charge"; const std::string RUN_NUMBER_PROPERTY = "run_number"; @@ -59,8 +61,8 @@ KafkaHistoStreamDecoder::KafkaHistoStreamDecoder( std::shared_ptr<IKafkaBroker> broker, const std::string &histoTopic, const std::string &runInfoTopic, const std::string &spDetTopic, const std::string &sampleEnvTopic, const std::string &chopperTopic) - : IKafkaStreamDecoder(broker, histoTopic, runInfoTopic, spDetTopic, - sampleEnvTopic, chopperTopic, ""), + : IKafkaStreamDecoder(std::move(broker), histoTopic, runInfoTopic, + spDetTopic, sampleEnvTopic, chopperTopic, ""), m_workspace() {} /** diff --git a/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp b/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp index d79f64752b32100666557e6cbc760be4205359e4..93d2fba8ed39ef9685be4bbaf46d55b85bc2e9bf 100644 --- a/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp +++ b/Framework/LiveData/src/Kafka/KafkaTopicSubscriber.cpp @@ -13,6 +13,7 @@ #include <iostream> #include <sstream> #include <thread> +#include <utility> using RdKafka::Conf; using RdKafka::KafkaConsumer; @@ -77,8 +78,8 @@ const std::string KafkaTopicSubscriber::MONITOR_TOPIC_SUFFIX = "_monitors"; KafkaTopicSubscriber::KafkaTopicSubscriber(std::string broker, std::vector<std::string> topics, SubscribeAtOption subscribeOption) - : IKafkaStreamSubscriber(), m_consumer(), m_brokerAddr(broker), - m_topicNames(topics), m_subscribeOption(subscribeOption) {} + : IKafkaStreamSubscriber(), m_consumer(), m_brokerAddr(std::move(broker)), + m_topicNames(std::move(topics)), m_subscribeOption(subscribeOption) {} /// Destructor KafkaTopicSubscriber::~KafkaTopicSubscriber() { diff --git a/Framework/LiveData/src/LiveDataAlgorithm.cpp b/Framework/LiveData/src/LiveDataAlgorithm.cpp index 01dbfe061d59b0e95a77366f397a0e53cdc226bb..64e8c16429adbf524353604d5b25c35d27339d83 100644 --- a/Framework/LiveData/src/LiveDataAlgorithm.cpp +++ b/Framework/LiveData/src/LiveDataAlgorithm.cpp @@ -17,6 +17,7 @@ #include <boost/algorithm/string/trim.hpp> #include <unordered_set> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -260,7 +261,7 @@ ILiveListener_sptr LiveDataAlgorithm::createLiveListener(bool connect) { */ void LiveDataAlgorithm::setLiveListener( Mantid::API::ILiveListener_sptr listener) { - m_listener = listener; + m_listener = std::move(listener); } //---------------------------------------------------------------------------------------------- diff --git a/Framework/LiveData/src/LoadLiveData.cpp b/Framework/LiveData/src/LoadLiveData.cpp index 6010a8160b5fabcba373137968bf0085b162341a..b41ca72a8893d2a359df9640861810c758e99f4c 100644 --- a/Framework/LiveData/src/LoadLiveData.cpp +++ b/Framework/LiveData/src/LoadLiveData.cpp @@ -15,6 +15,7 @@ #include "MantidLiveData/Exception.h" #include <boost/algorithm/string.hpp> +#include <utility> #include <Poco/Thread.h> @@ -204,7 +205,7 @@ LoadLiveData::runProcessing(Mantid::API::Workspace_sptr inputWS, Mantid::API::Workspace_sptr LoadLiveData::processChunk(Mantid::API::Workspace_sptr chunkWS) { try { - return runProcessing(chunkWS, false); + return runProcessing(std::move(chunkWS), false); } catch (...) { g_log.error("While processing chunk:"); throw; @@ -232,7 +233,7 @@ void LoadLiveData::runPostProcessing() { * * @param chunkWS :: processed live data chunk workspace */ -void LoadLiveData::addChunk(Mantid::API::Workspace_sptr chunkWS) { +void LoadLiveData::addChunk(const Mantid::API::Workspace_sptr &chunkWS) { // Acquire locks on the workspaces we use WriteLock _lock1(*m_accumWS); ReadLock _lock2(*chunkWS); @@ -273,8 +274,8 @@ void LoadLiveData::addChunk(Mantid::API::Workspace_sptr chunkWS) { * @param accumWS :: accumulation matrix workspace * @param chunkWS :: processed live data chunk matrix workspace */ -void LoadLiveData::addMatrixWSChunk(Workspace_sptr accumWS, - Workspace_sptr chunkWS) { +void LoadLiveData::addMatrixWSChunk(const Workspace_sptr &accumWS, + const Workspace_sptr &chunkWS) { // Handle the addition of the internal monitor workspace, if present auto accumMW = boost::dynamic_pointer_cast<MatrixWorkspace>(accumWS); auto chunkMW = boost::dynamic_pointer_cast<MatrixWorkspace>(chunkWS); @@ -342,7 +343,7 @@ void LoadLiveData::replaceChunk(Mantid::API::Workspace_sptr chunkWS) { auto instrumentWS = m_accumWS; // When the algorithm exits the chunk workspace will be renamed // and overwrite the old one - m_accumWS = chunkWS; + m_accumWS = std::move(chunkWS); // Put the original instrument back. Otherwise geometry changes will not be // persistent copyInstrument(instrumentWS.get(), m_accumWS.get()); @@ -358,7 +359,7 @@ void LoadLiveData::replaceChunk(Mantid::API::Workspace_sptr chunkWS) { * * @param chunkWS :: processed live data chunk workspace */ -void LoadLiveData::appendChunk(Mantid::API::Workspace_sptr chunkWS) { +void LoadLiveData::appendChunk(const Mantid::API::Workspace_sptr &chunkWS) { // ISIS multi-period data come in workspace groups WorkspaceGroup_sptr chunk_gws = boost::dynamic_pointer_cast<WorkspaceGroup>(chunkWS); @@ -400,8 +401,9 @@ void LoadLiveData::appendChunk(Mantid::API::Workspace_sptr chunkWS) { * @param accumWS :: accumulation matrix workspace * @param chunkWS :: processed live data chunk matrix workspace */ -Workspace_sptr LoadLiveData::appendMatrixWSChunk(Workspace_sptr accumWS, - Workspace_sptr chunkWS) { +Workspace_sptr +LoadLiveData::appendMatrixWSChunk(Workspace_sptr accumWS, + const Workspace_sptr &chunkWS) { IAlgorithm_sptr alg; ReadLock _lock1(*accumWS); ReadLock _lock2(*chunkWS); diff --git a/Framework/LiveData/test/KafkaEventStreamDecoderTest.h b/Framework/LiveData/test/KafkaEventStreamDecoderTest.h index 244435a658bf8c6b988ef5b672cca4226e221a57..a3ca5e72d75be07edb4d483f319e9ec761d6f10d 100644 --- a/Framework/LiveData/test/KafkaEventStreamDecoderTest.h +++ b/Framework/LiveData/test/KafkaEventStreamDecoderTest.h @@ -19,8 +19,11 @@ #include <Poco/Path.h> #include <condition_variable> +#include <iostream> #include <thread> +using Mantid::LiveData::KafkaEventStreamDecoder; + class KafkaEventStreamDecoderTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically @@ -512,43 +515,54 @@ private: void startCapturing(Mantid::LiveData::KafkaEventStreamDecoder &decoder, uint8_t maxIterations) { // Register callback to know when a whole loop as been iterated through + m_maxIterations = maxIterations; m_niterations = 0; - auto callback = [this, maxIterations]() { - this->iterationCallback(maxIterations); - }; - decoder.registerIterationEndCb(callback); - decoder.registerErrorCb(callback); + decoder.registerIterationEndCb([this]() { this->iterationCallback(); }); + + decoder.registerErrorCb([this, &decoder]() { errCallback(decoder); }); TS_ASSERT_THROWS_NOTHING(decoder.startCapture()); continueCapturing(decoder, maxIterations); } - void iterationCallback(uint8_t maxIterations) { + void iterationCallback() { std::unique_lock<std::mutex> lock(this->m_callbackMutex); this->m_niterations++; - if (this->m_niterations == maxIterations) { + if (this->m_niterations == m_maxIterations) { lock.unlock(); this->m_callbackCondition.notify_one(); } } - void continueCapturing(Mantid::LiveData::KafkaEventStreamDecoder &decoder, + void errCallback(KafkaEventStreamDecoder &decoder) { + try { + // Get the stored exception by calling extract data again + decoder.extractData(); + } catch (std::exception &e) { + // We could try to port the exception from this child thread to the main + // thread, or just print it here which is significantly easier + std::cerr << "Exception: " << e.what() << "\n"; + // Always keep incrementing so we don't deadlock + iterationCallback(); + } + } + + void continueCapturing(KafkaEventStreamDecoder &decoder, uint8_t maxIterations) { + m_maxIterations = maxIterations; + // Re-register callback with the (potentially) new value of maxIterations - auto callback = [this, maxIterations]() { - this->iterationCallback(maxIterations); - }; - decoder.registerIterationEndCb(callback); - decoder.registerErrorCb(callback); + decoder.registerIterationEndCb([this]() { this->iterationCallback(); }); + decoder.registerErrorCb([this, &decoder]() { errCallback(decoder); }); + { std::unique_lock<std::mutex> lk(m_callbackMutex); - this->m_callbackCondition.wait(lk, [this, maxIterations]() { - return this->m_niterations == maxIterations; - }); + this->m_callbackCondition.wait( + lk, [this]() { return this->m_niterations == m_maxIterations; }); } } - std::unique_ptr<Mantid::LiveData::KafkaEventStreamDecoder> - createTestDecoder(std::shared_ptr<Mantid::LiveData::IKafkaBroker> broker) { + std::unique_ptr<Mantid::LiveData::KafkaEventStreamDecoder> createTestDecoder( + const std::shared_ptr<Mantid::LiveData::IKafkaBroker> &broker) { using namespace Mantid::LiveData; return std::make_unique<KafkaEventStreamDecoder>(broker, "", "", "", "", "", "", 0); @@ -574,8 +588,8 @@ private: void checkWorkspaceEventData( const Mantid::DataObjects::EventWorkspace &eventWksp) { - // A timer-based test and each message contains 6 events so the total should - // be divisible by 6, but not be 0 + // A timer-based test and each message contains 6 events so the total + // should be divisible by 6, but not be 0 TS_ASSERT(eventWksp.getNumberEvents() % 6 == 0); TS_ASSERT(eventWksp.getNumberEvents() != 0); } @@ -597,4 +611,5 @@ private: std::mutex m_callbackMutex; std::condition_variable m_callbackCondition; uint8_t m_niterations = 0; + std::atomic<uint8_t> m_maxIterations = 0; }; diff --git a/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h b/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h index 25196cc10b1816826cd226353186c0a99ef7cc54..3fc38756533dd776dda7b5c80e6e3bb4a843b739 100644 --- a/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h +++ b/Framework/LiveData/test/KafkaHistoStreamDecoderTest.h @@ -94,8 +94,8 @@ public: } private: - std::unique_ptr<Mantid::LiveData::KafkaHistoStreamDecoder> - createTestDecoder(std::shared_ptr<Mantid::LiveData::IKafkaBroker> broker) { + std::unique_ptr<Mantid::LiveData::KafkaHistoStreamDecoder> createTestDecoder( + const std::shared_ptr<Mantid::LiveData::IKafkaBroker> &broker) { using namespace Mantid::LiveData; return std::make_unique<KafkaHistoStreamDecoder>(broker, "", "", "", "", ""); diff --git a/Framework/LiveData/test/KafkaTesting.h b/Framework/LiveData/test/KafkaTesting.h index 11670e3e785a6531389dcbc098e3265d19ab24ac..85738a1355caaf142623756c1c149f99081460de 100644 --- a/Framework/LiveData/test/KafkaTesting.h +++ b/Framework/LiveData/test/KafkaTesting.h @@ -220,7 +220,7 @@ void fakeReceiveASampleEnvMessage(std::string *buffer) { void fakeReceiveARunStartMessage(std::string *buffer, int32_t runNumber, const std::string &startTime, const std::string &instName, int32_t nPeriods, - std::string nexusStructure = "") { + const std::string &nexusStructure = "") { // Convert date to time_t auto mantidTime = Mantid::Types::Core::DateAndTime(startTime); auto startTimestamp = diff --git a/Framework/LiveData/test/LoadLiveDataTest.h b/Framework/LiveData/test/LoadLiveDataTest.h index 92b08d01875f866ad97949ff87513fccca580928..146a2afd6e50f01e3e5264c118d570d604bb785d 100644 --- a/Framework/LiveData/test/LoadLiveDataTest.h +++ b/Framework/LiveData/test/LoadLiveDataTest.h @@ -53,11 +53,13 @@ public: */ template <typename TYPE> boost::shared_ptr<TYPE> - doExec(std::string AccumulationMethod, std::string ProcessingAlgorithm = "", - std::string ProcessingProperties = "", - std::string PostProcessingAlgorithm = "", - std::string PostProcessingProperties = "", bool PreserveEvents = true, - ILiveListener_sptr listener = ILiveListener_sptr(), + doExec(const std::string &AccumulationMethod, + const std::string &ProcessingAlgorithm = "", + const std::string &ProcessingProperties = "", + const std::string &PostProcessingAlgorithm = "", + const std::string &PostProcessingProperties = "", + bool PreserveEvents = true, + const ILiveListener_sptr &listener = ILiveListener_sptr(), bool makeThrow = false) { FacilityHelper::ScopedFacilities loadTESTFacility( "unit_testing/UnitTestFacilities.xml", "TEST"); diff --git a/Framework/LiveData/test/MonitorLiveDataTest.h b/Framework/LiveData/test/MonitorLiveDataTest.h index 48d02480083ccc6c1ec2f1cb4f30ee4d87db5165..26575e099c00b333a620511a3456c13d28041caf 100644 --- a/Framework/LiveData/test/MonitorLiveDataTest.h +++ b/Framework/LiveData/test/MonitorLiveDataTest.h @@ -61,10 +61,10 @@ public: /** Create but don't start a MonitorLiveData thread */ boost::shared_ptr<MonitorLiveData> - makeAlgo(std::string output, std::string accumWS = "", - std::string AccumulationMethod = "Replace", - std::string RunTransitionBehavior = "Restart", - std::string UpdateEvery = "1") { + makeAlgo(const std::string &output, const std::string &accumWS = "", + const std::string &AccumulationMethod = "Replace", + const std::string &RunTransitionBehavior = "Restart", + const std::string &UpdateEvery = "1") { auto alg = boost::dynamic_pointer_cast<MonitorLiveData>( AlgorithmManager::Instance().create("MonitorLiveData", -1, false)); alg->setPropertyValue("Instrument", "TestDataListener"); @@ -167,7 +167,7 @@ public: /** Executes the given algorithm asynchronously, until you reach the given * chunk number. * @return false if test failed*/ - bool runAlgoUntilChunk(boost::shared_ptr<MonitorLiveData> alg1, + bool runAlgoUntilChunk(const boost::shared_ptr<MonitorLiveData> &alg1, size_t stopAtChunk) { Poco::ActiveResult<bool> res1 = alg1->executeAsync(); Poco::Thread::sleep(50); diff --git a/Framework/LiveData/test/StartLiveDataTest.h b/Framework/LiveData/test/StartLiveDataTest.h index 65208964909d6443bd3772a9f59b796404e4b626..431bc8091f819687a6ec6927898a469fd28b1e71 100644 --- a/Framework/LiveData/test/StartLiveDataTest.h +++ b/Framework/LiveData/test/StartLiveDataTest.h @@ -51,12 +51,12 @@ public: * @param AccumulationMethod :: parameter string * @return the created processed WS */ - EventWorkspace_sptr doExecEvent(std::string AccumulationMethod, - double UpdateEvery, - std::string ProcessingAlgorithm = "", - std::string ProcessingProperties = "", - std::string PostProcessingAlgorithm = "", - std::string PostProcessingProperties = "") { + EventWorkspace_sptr + doExecEvent(const std::string &AccumulationMethod, double UpdateEvery, + const std::string &ProcessingAlgorithm = "", + const std::string &ProcessingProperties = "", + const std::string &PostProcessingAlgorithm = "", + const std::string &PostProcessingProperties = "") { TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("FromNow", "1")); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h index 49227304eac01c374191064f7ccd562b6c162167..3718367586913c2a561981be922fdb980dbdd451 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h @@ -31,17 +31,18 @@ protected: int MaxRecursionDepth = 5); /// Set the settings in the given box controller - void setBoxController(Mantid::API::BoxController_sptr bc, - Mantid::Geometry::Instrument_const_sptr instrument); + void + setBoxController(const Mantid::API::BoxController_sptr &bc, + const Mantid::Geometry::Instrument_const_sptr &instrument); /// Set the settings in the given box controller - void setBoxController(Mantid::API::BoxController_sptr bc); + void setBoxController(const Mantid::API::BoxController_sptr &bc); std::string getBoxSettingsGroupName() { return "Box Splitting Settings"; } /// Take the defaults for the box splitting from the instrument parameters. - void - takeDefaultsFromInstrument(Mantid::Geometry::Instrument_const_sptr instrument, - const size_t ndims); + void takeDefaultsFromInstrument( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const size_t ndims); private: }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h index 2499b0801bb12a5d8ae3f435fc48b1148ae2d15b..11e967304f3bf6623f906d1507ed898e562c30fb 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompactMD.h @@ -37,10 +37,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; } /// Finding the extents of the first non-zero signals. - void - findFirstNonZeroMinMaxExtents(Mantid::API::IMDHistoWorkspace_sptr inputWs, - std::vector<Mantid::coord_t> &minVec, - std::vector<Mantid::coord_t> &maxVec); + void findFirstNonZeroMinMaxExtents( + const Mantid::API::IMDHistoWorkspace_sptr &inputWs, + std::vector<Mantid::coord_t> &minVec, + std::vector<Mantid::coord_t> &maxVec); }; } // namespace MDAlgorithms } // namespace Mantid diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h index 5d1645549963b77789289d75a6adf50d79a2cf04..c5baef575669c52f0796c25b40827202c5dab26a 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CompareMDWorkspaces.h @@ -34,10 +34,11 @@ private: void init() override; void exec() override; void doComparison(); - void compareMDGeometry(Mantid::API::IMDWorkspace_sptr ws1, - Mantid::API::IMDWorkspace_sptr ws2); - void compareMDHistoWorkspaces(Mantid::DataObjects::MDHistoWorkspace_sptr ws1, - Mantid::DataObjects::MDHistoWorkspace_sptr ws2); + void compareMDGeometry(const Mantid::API::IMDWorkspace_sptr &ws1, + const Mantid::API::IMDWorkspace_sptr &ws2); + void compareMDHistoWorkspaces( + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws1, + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws2); template <typename MDE, size_t nd> void compareMDWorkspaces( diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h index fcf17e012355bb8ebb2347d2e4ef86758330f38c..e6711914d6f539927b6f146c590521960b4ed3f5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvToMDSelector.h @@ -33,7 +33,7 @@ public: /// function which selects the convertor depending on workspace type and /// (possibly, in a future) some workspace properties boost::shared_ptr<ConvToMDBase> - convSelector(API::MatrixWorkspace_sptr inputWS, + convSelector(const API::MatrixWorkspace_sptr &inputWS, boost::shared_ptr<ConvToMDBase> ¤tSolver) const; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h index 6485d4323250da7d445788d65f9faee12f9ea144..7e18f4bd3123da2fdf510af4a5684f5f44aef83b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h @@ -113,35 +113,37 @@ private: void exec() override; /// Main algorithm to reduce powder diffraction data - API::MatrixWorkspace_sptr reducePowderData( - API::IMDEventWorkspace_const_sptr dataws, - API::IMDEventWorkspace_const_sptr monitorws, const std::string targetunit, - const std::map<int, double> &map_runwavelength, const double xmin, - const double xmax, const double binsize, bool dolinearinterpolation, - const std::vector<detid_t> &vec_excludeddets); + API::MatrixWorkspace_sptr + reducePowderData(const API::IMDEventWorkspace_const_sptr &dataws, + const API::IMDEventWorkspace_const_sptr &monitorws, + const std::string &targetunit, + const std::map<int, double> &map_runwavelength, + const double xmin, const double xmax, const double binsize, + bool dolinearinterpolation, + const std::vector<detid_t> &vec_excludeddets); /// Find the binning boundary according to detectors' positions - void findXBoundary(API::IMDEventWorkspace_const_sptr dataws, + void findXBoundary(const API::IMDEventWorkspace_const_sptr &dataws, const std::string &targetunit, const std::map<int, double> &map_runwavelength, double &xmin, double &xmax); /// Bin signals to its 2theta position - void binMD(API::IMDEventWorkspace_const_sptr mdws, const char &unitbit, + void binMD(const API::IMDEventWorkspace_const_sptr &mdws, const char &unitbit, const std::map<int, double> &map_runlambda, const std::vector<double> &vecx, std::vector<double> &vecy, const std::vector<detid_t> &vec_excludedet); /// Do linear interpolation to zero counts if bin is too small - void linearInterpolation(API::MatrixWorkspace_sptr matrixws, + void linearInterpolation(const API::MatrixWorkspace_sptr &matrixws, const double &infinitesimal); /// Set up sample logs - void setupSampleLogs(API::MatrixWorkspace_sptr matrixws, - API::IMDEventWorkspace_const_sptr inputmdws); + void setupSampleLogs(const API::MatrixWorkspace_sptr &matrixws, + const API::IMDEventWorkspace_const_sptr &inputmdws); /// Scale reduced data - void scaleMatrixWorkspace(API::MatrixWorkspace_sptr matrixws, + void scaleMatrixWorkspace(const API::MatrixWorkspace_sptr &matrixws, const double &scalefactor, const double &infinitesimal); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h index 20d0878628ae5ef15ea6df65a3b282a95e077e9e..1719bb7fa3fa258e2786b912cb822e4904a94b0e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h @@ -45,7 +45,7 @@ private: void addMDEvents(bool usevirtual); void convertSpiceMatrixToMomentumMDEvents( - API::MatrixWorkspace_sptr dataws, bool usevirtual, + const API::MatrixWorkspace_sptr &dataws, bool usevirtual, const detid_t &startdetid, const int scannumber, const int runnumber, double measuretime, int monitor_counts); @@ -66,7 +66,7 @@ private: void parseDetectorTable(std::vector<Kernel::V3D> &vec_detpos, std::vector<detid_t> &vec_detid); - void setupTransferMatrix(API::MatrixWorkspace_sptr dataws, + void setupTransferMatrix(const API::MatrixWorkspace_sptr &dataws, Kernel::DblMatrix &rotationMatrix); void createVirtualInstrument(); @@ -74,7 +74,7 @@ private: void updateQRange(const std::vector<Mantid::coord_t> &vec_q); /// Remove background from - void removeBackground(API::MatrixWorkspace_sptr dataws); + void removeBackground(const API::MatrixWorkspace_sptr &dataws); API::ITableWorkspace_sptr m_expDataTableWS; API::ITableWorkspace_sptr m_detectorListTableWS; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h index ccfd30d9182eae27ecab4b504d4a5a3e98862d02..a627f571672e3c2dddce3964e4c5ab95b1ef9901 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h @@ -47,7 +47,7 @@ private: /// Execution code void exec() override; - void exportEvents(API::IMDEventWorkspace_sptr mdws, + void exportEvents(const API::IMDEventWorkspace_sptr &mdws, std::vector<Kernel::V3D> &vec_event_qsample, std::vector<signal_t> &vec_event_signal, std::vector<detid_t> &vec_event_det); @@ -74,7 +74,7 @@ private: void getUBMatrix(); - void getRange(const std::vector<Kernel::V3D> vec_hkl, + void getRange(const std::vector<Kernel::V3D> &vec_hkl, std::vector<double> &extentMins, std::vector<double> &extentMaxs); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h index 4f3abf712c7a98cde242e2e2fd5abf31c2cf2de5..a38007bceaa5d39de511074a535bfa907c4d976f 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h @@ -59,8 +59,8 @@ private: /// Parse data table workspace to a vector of matrix workspaces std::vector<API::MatrixWorkspace_sptr> convertToMatrixWorkspace( - DataObjects::TableWorkspace_sptr tablews, - API::MatrixWorkspace_const_sptr parentws, + const DataObjects::TableWorkspace_sptr &tablews, + const API::MatrixWorkspace_const_sptr &parentws, Types::Core::DateAndTime runstart, std::map<std::string, std::vector<double>> &logvecmap, std::vector<Types::Core::DateAndTime> &vectimes); @@ -71,43 +71,42 @@ private: /// Create an MDWorkspace for monitor counts API::IMDEventWorkspace_sptr createMonitorMDWorkspace( - const std::vector<API::MatrixWorkspace_sptr> vec_ws2d, + const std::vector<API::MatrixWorkspace_sptr> &vec_ws2d, const std::vector<double> &vecmonitor); /// Read parameter information from table workspace - void readTableInfo(DataObjects::TableWorkspace_const_sptr tablews, + void readTableInfo(const DataObjects::TableWorkspace_const_sptr &tablews, size_t &ipt, size_t &irotangle, size_t &itime, std::vector<std::pair<size_t, size_t>> &anodelist, std::map<std::string, size_t> &samplenameindexmap); /// Return sample logs - void parseSampleLogs(DataObjects::TableWorkspace_sptr tablews, + void parseSampleLogs(const DataObjects::TableWorkspace_sptr &tablews, const std::map<std::string, size_t> &indexlist, std::map<std::string, std::vector<double>> &logvecmap); /// Load one run (one pt.) to a matrix workspace - API::MatrixWorkspace_sptr - loadRunToMatrixWS(DataObjects::TableWorkspace_sptr tablews, size_t irow, - API::MatrixWorkspace_const_sptr parentws, - Types::Core::DateAndTime runstart, size_t ipt, - size_t irotangle, size_t itime, - const std::vector<std::pair<size_t, size_t>> anodelist, - double &duration); + API::MatrixWorkspace_sptr loadRunToMatrixWS( + const DataObjects::TableWorkspace_sptr &tablews, size_t irow, + const API::MatrixWorkspace_const_sptr &parentws, + Types::Core::DateAndTime runstart, size_t ipt, size_t irotangle, + size_t itime, const std::vector<std::pair<size_t, size_t>> &anodelist, + double &duration); /// Append Experiment Info void - addExperimentInfos(API::IMDEventWorkspace_sptr mdws, - const std::vector<API::MatrixWorkspace_sptr> vec_ws2d); + addExperimentInfos(const API::IMDEventWorkspace_sptr &mdws, + const std::vector<API::MatrixWorkspace_sptr> &vec_ws2d); /// Append sample logs to MD workspace void - appendSampleLogs(API::IMDEventWorkspace_sptr mdws, + appendSampleLogs(const API::IMDEventWorkspace_sptr &mdws, const std::map<std::string, std::vector<double>> &logvecmap, const std::vector<Types::Core::DateAndTime> &vectimes); /// Parse detector efficiency table workspace to map - std::map<detid_t, double> - parseDetectorEfficiencyTable(DataObjects::TableWorkspace_sptr detefftablews); + std::map<detid_t, double> parseDetectorEfficiencyTable( + const DataObjects::TableWorkspace_sptr &detefftablews); /// Apply the detector's efficiency correction to void diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h index 19d01bac63c589218f0077c0bc9b8bcb0f8fa28e..cb19a48fac4f9e3486d7188bd1b6e1305a78ef8e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h @@ -60,8 +60,8 @@ private: /// progress reporter boost::scoped_ptr<API::Progress> m_Progress; - void setupFileBackend(std::string filebackPath, - API::IMDEventWorkspace_sptr outputWS); + void setupFileBackend(const std::string &filebackPath, + const API::IMDEventWorkspace_sptr &outputWS); //------------------------------------------------------------------------------------------------------------------------------------------ protected: // for testing, otherwise private: @@ -74,13 +74,13 @@ protected: // for testing, otherwise private: // Workflow helpers: /**Check if target workspace new or existing one and we need to create new * workspace*/ - bool doWeNeedNewTargetWorkspace(API::IMDEventWorkspace_sptr spws); + bool doWeNeedNewTargetWorkspace(const API::IMDEventWorkspace_sptr &spws); /**Create new MD workspace using existing parameters for algorithm */ API::IMDEventWorkspace_sptr createNewMDWorkspace(const MDAlgorithms::MDWSDescription &targWSDescr, const bool filebackend, const std::string &filename); - bool buildTargetWSDescription(API::IMDEventWorkspace_sptr spws, + bool buildTargetWSDescription(const API::IMDEventWorkspace_sptr &spws, const std::string &QModReq, const std::string &dEModReq, const std::vector<std::string> &otherDimNames, @@ -106,7 +106,7 @@ protected: // for testing, otherwise private: std::vector<double> &minVal, std::vector<double> &maxVal); /// Sets up the top level splitting, i.e. of level 0, for the box controller - void setupTopLevelSplitting(Mantid::API::BoxController_sptr bc); + void setupTopLevelSplitting(const Mantid::API::BoxController_sptr &bc); }; } // namespace MDAlgorithms diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h index 4e1b3c7bbf2ce82f70ec5fe7a88c33415c170dcf..7f0eb9c749cb75e7e5c64e4605a3532075b26f2c 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h @@ -43,23 +43,23 @@ private: const std::string &wsname); /// Add a sample log to a workspace - void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, + void addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &log_name, double log_number); /// Set the goniometer values in a workspace - void setGoniometer(Mantid::API::MatrixWorkspace_sptr workspace); + void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &workspace); /// Set the UB matrix in a workspace - void setUB(Mantid::API::MatrixWorkspace_sptr workspace, double a, double b, - double c, double alpha, double beta, double gamma, + void setUB(const Mantid::API::MatrixWorkspace_sptr &workspace, double a, + double b, double c, double alpha, double beta, double gamma, const std::vector<double> &u, const std::vector<double> &v); /// Convert a workspace to MDWorkspace Mantid::API::IMDEventWorkspace_sptr - convertToMD(Mantid::API::Workspace_sptr workspace, + convertToMD(const Mantid::API::Workspace_sptr &workspace, const std::string &analysis_mode, bool in_place, const std::string &filebackend_filename, const bool filebackend, - Mantid::API::IMDEventWorkspace_sptr out_mdws); + const Mantid::API::IMDEventWorkspace_sptr &out_mdws); /// Merge input workspaces Mantid::API::IMDEventWorkspace_sptr @@ -67,13 +67,13 @@ private: /// Add logs and convert to MDWorkspace for a single run Mantid::API::IMDEventWorkspace_sptr - single_run(Mantid::API::MatrixWorkspace_sptr input_workspace, + single_run(const Mantid::API::MatrixWorkspace_sptr &input_workspace, const std::string &emode, double efix, double psi, double gl, double gs, bool in_place, const std::vector<double> &alatt, const std::vector<double> &angdeg, const std::vector<double> &u, const std::vector<double> &v, const std::string &filebackend_filename, const bool filebackend, - Mantid::API::IMDEventWorkspace_sptr out_mdws); + const Mantid::API::IMDEventWorkspace_sptr &out_mdws); /// Validate the algorithm's input properties std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h index f51b5659331c1e7d195650f36d6a783055b3ea88..af76fc6919dee496e8036c77bfb010cfcd869e4e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h @@ -57,8 +57,8 @@ private: template <typename MDE, size_t nd> void finish(typename DataObjects::MDEventWorkspace<MDE, nd>::sptr ws); - Mantid::Geometry::MDFrame_uptr createMDFrame(std::string frame, - std::string unit); + Mantid::Geometry::MDFrame_uptr createMDFrame(const std::string &frame, + const std::string &unit); bool checkIfFrameValid(const std::string &frame, const std::vector<std::string> &targetFrames); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h index 4330b015afb3007cffea4965540bec17b0728bb6..7b52787fc1883a49532f38b61b239bdf7392a326 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h @@ -14,9 +14,9 @@ namespace Mantid { namespace MDAlgorithms { -std::vector<std::string> - DLLExport findOriginalQUnits(Mantid::API::IMDWorkspace_const_sptr inws, - Mantid::Kernel::Logger &logger); +std::vector<std::string> DLLExport +findOriginalQUnits(const Mantid::API::IMDWorkspace_const_sptr &inws, + Mantid::Kernel::Logger &logger); /** CutMD : Slices multidimensional workspaces. diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h index 7624bd52a7264d8a510cefb890fbae0d84073435..24e2d7c1b902126c23be415a2378da385e39171b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DisplayNormalizationSetter.h @@ -19,7 +19,7 @@ energy-transfer-mode */ class DLLExport DisplayNormalizationSetter { public: - void operator()(Mantid::API::IMDWorkspace_sptr mdWorkspace, + void operator()(const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ = false, const Mantid::Kernel::DeltaEMode::Type &mode = @@ -27,14 +27,14 @@ public: private: void setNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ = false, const Mantid::Kernel::DeltaEMode::Type &mode = Mantid::Kernel::DeltaEMode::Elastic); void applyNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, Mantid::API::MDNormalization displayNormalization, Mantid::API::MDNormalization displayNormalizationHisto); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h index 22666e34921ef6e9c8512cfd6a86875e05f03467..14cb071885c5bb75b155164c8da7da16548ec0ac 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h @@ -74,7 +74,7 @@ private: template <typename MDE, size_t nd> void findPeaks(typename DataObjects::MDEventWorkspace<MDE, nd>::sptr ws); /// Run find peaks on a histo workspace - void findPeaksHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws); + void findPeaksHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws); /// Output PeaksWorkspace Mantid::DataObjects::PeaksWorkspace_sptr peakWS; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h index 794757a422522eb37bf0639be59048a7dad1c4f8..b8350d48d2f4c14bb7d1b71323e49f8c816fe43e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FitMD.h @@ -9,6 +9,8 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- +#include <utility> + #include "MantidAPI/IDomainCreator.h" namespace Mantid { @@ -64,7 +66,7 @@ public: size_t getDomainSize() const override; /// Set the workspace void setWorkspace(boost::shared_ptr<API::IMDWorkspace> IMDWorkspace) { - m_IMDWorkspace = IMDWorkspace; + m_IMDWorkspace = std::move(IMDWorkspace); } /// Set the range void setRange(size_t startIndex, size_t count); @@ -83,8 +85,8 @@ protected: const std::string &outputWorkspacePropertyName); /// Create histo output workspace boost::shared_ptr<API::Workspace> createHistoOutputWorkspace( - const std::string &baseName, API::IFunction_sptr function, - boost::shared_ptr<const API::IMDHistoWorkspace> inputWorkspace, + const std::string &baseName, const API::IFunction_sptr &function, + const boost::shared_ptr<const API::IMDHistoWorkspace> &inputWorkspace, const std::string &outputWorkspacePropertyName); /// Store workspace property name diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h index 841374d59de4669cf02d18147d7b98e43d049357..aba7a9949d9533cb1d29068e02458f74fbb0c079 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h @@ -47,34 +47,35 @@ private: void exec() override; /// Export all detectors' counts for a run - void exportDetCountsOfRun(API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, - const int runnumber, std::vector<double> &vecX, - std::vector<double> &vecY, std::string &xlabel, - std::string &ylabel, bool donormalize); + void + exportDetCountsOfRun(const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, + const int runnumber, std::vector<double> &vecX, + std::vector<double> &vecY, std::string &xlabel, + std::string &ylabel, bool donormalize); /// Export a detector's counts accross all runs - void exportIndividualDetCounts(API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, - const int detid, std::vector<double> &vecX, - std::vector<double> &vecY, std::string &xlabel, - std::string &ylabel, const bool &donormalize); + void exportIndividualDetCounts( + const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, const int detid, + std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, + std::string &ylabel, const bool &donormalize); /// Export sample log values accross all runs - void exportSampleLogValue(API::IMDEventWorkspace_const_sptr datamdws, + void exportSampleLogValue(const API::IMDEventWorkspace_const_sptr &datamdws, const std::string &samplelogname, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel); /// Get detectors' counts - void getDetCounts(API::IMDEventWorkspace_const_sptr mdws, + void getDetCounts(const API::IMDEventWorkspace_const_sptr &mdws, const int &runnumber, const int &detid, std::vector<double> &vecX, std::vector<double> &vecY, bool formX); /// Get sample log values - void getSampleLogValues(API::IMDEventWorkspace_const_sptr mdws, + void getSampleLogValues(const API::IMDEventWorkspace_const_sptr &mdws, const std::string &samplelogname, const int runnumber, std::vector<double> &vecSampleLog); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h index 2deb6d2f4095e6437200d8246fcc5d9678b28dbc..c9b16ab41c21634a1d38f5990f0863cd5b71cde3 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h @@ -37,8 +37,8 @@ protected: private: // Product of the bins across all dimensions. size_t m_bin_product = 0; - Mantid::Geometry::MDFrame_uptr createMDFrame(std::string frame, - std::string unit); + Mantid::Geometry::MDFrame_uptr createMDFrame(const std::string &frame, + const std::string &unit); bool checkIfFrameValid(const std::string &frame, const std::vector<std::string> &targetFrames); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h index 0208bdf1b60ca4e0a97fff70b9584093308ae373..ef2ddcf9f394819323feb5f47ee9de361485e5dc 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h @@ -80,7 +80,7 @@ public: /// Find the net integrated intensity of a peak, using ellipsoidal volumes boost::shared_ptr<const Mantid::Geometry::PeakShape> ellipseIntegrateEvents( - std::vector<Kernel::V3D> E1Vec, Mantid::Kernel::V3D const &peak_q, + const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q, bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius, std::vector<double> &axes_radii, double &inti, double &sigi); @@ -88,7 +88,7 @@ public: /// Find the net integrated intensity of a modulated peak, using ellipsoidal /// volumes boost::shared_ptr<const Mantid::Geometry::PeakShape> - ellipseIntegrateModEvents(std::vector<Kernel::V3D> E1Vec, + ellipseIntegrateModEvents(const std::vector<Kernel::V3D> &E1Vec, Mantid::Kernel::V3D const &peak_q, Mantid::Kernel::V3D const &hkl, Mantid::Kernel::V3D const &mnp, bool specify_size, @@ -176,7 +176,7 @@ private: /// Find the net integrated intensity of a list of Q's using ellipsoids boost::shared_ptr<const Mantid::DataObjects::PeakShapeEllipsoid> ellipseIntegrateEvents( - std::vector<Kernel::V3D> E1Vec, Kernel::V3D const &peak_q, + const std::vector<Kernel::V3D> &E1Vec, Kernel::V3D const &peak_q, std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &ev_list, std::vector<Mantid::Kernel::V3D> const &directions, @@ -185,7 +185,7 @@ private: std::vector<double> &axes_radii, double &inti, double &sigi); /// Compute if a particular Q falls on the edge of a detector - double detectorQ(std::vector<Kernel::V3D> E1Vec, + double detectorQ(const std::vector<Kernel::V3D> &E1Vec, const Mantid::Kernel::V3D QLabFrame, const std::vector<double> &r); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h index a0851899638c9ab94807783b67a10cb6c6b6cdb9..ba54418df9fd3ffb01fb0f711981a34c6d8bb4ac 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h @@ -52,8 +52,8 @@ private: /// Calculate if this Q is on a detector void calculateE1(const Geometry::DetectorInfo &detectorInfo); - void runMaskDetectors(Mantid::DataObjects::PeaksWorkspace_sptr peakWS, - std::string property, std::string values); + void runMaskDetectors(const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values); /// save for all detector pixels std::vector<Kernel::V3D> E1Vec; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h index 1148a831df7b9d6266000eff45b4807d937d0340..c00e19cc3a8c77862123761b39358d5c22a3d2ca 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h @@ -54,8 +54,8 @@ private: const Kernel::DblMatrix &UBinv, bool hkl_integ); /// Calculate if this Q is on a detector void calculateE1(const Geometry::DetectorInfo &detectorInfo); - void runMaskDetectors(Mantid::DataObjects::PeaksWorkspace_sptr peakWS, - std::string property, std::string values); + void runMaskDetectors(const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values); /// integrate a collection of strong peaks DataObjects::PeaksWorkspace_sptr diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h index 00a8ba972d4c4ec305362cc121b4f41848953114..39f6ce7ae3c9429ae16b16daafb468bef1dbb1ee 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h @@ -70,7 +70,7 @@ private: std::map<int, double> getMeasureTime(); std::vector<detid_t> - processMaskWorkspace(DataObjects::MaskWorkspace_const_sptr maskws); + processMaskWorkspace(const DataObjects::MaskWorkspace_const_sptr &maskws); void getPeakInformation(); @@ -82,7 +82,8 @@ private: void normalizePeaksIntensities(); DataObjects::PeaksWorkspace_sptr - createPeakworkspace(Kernel::V3D peakCenter, API::IMDEventWorkspace_sptr mdws); + createPeakworkspace(Kernel::V3D peakCenter, + const API::IMDEventWorkspace_sptr &mdws); /// Input MDEventWorkspace Mantid::API::IMDEventWorkspace_sptr m_inputWS; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h index 9f955d09525dfe27f9f8e73a5c57a2145f613a66..ce470c860cb4c4a6ffd6c3ee36a2a143589432be 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h @@ -61,14 +61,15 @@ private: /// Calculate if this Q is on a detector void calculateE1(const Geometry::DetectorInfo &detectorInfo); double detectorQ(Mantid::Kernel::V3D QLabFrame, double r); - void runMaskDetectors(Mantid::DataObjects::PeaksWorkspace_sptr peakWS, - std::string property, std::string values); + void runMaskDetectors(const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values); /// save for all detector pixels std::vector<Kernel::V3D> E1Vec; /// Check if peaks overlap - void checkOverlap(int i, Mantid::DataObjects::PeaksWorkspace_sptr peakWS, + void checkOverlap(int i, + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, Mantid::Kernel::SpecialCoordinateSystem CoordinatesToUse, double radius); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h index 8b6b73ced15727592d27a63341c3aea9cd1d9559..a6c4ad062a6b2475d1bce138eaf93aaf1e33732b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h @@ -60,8 +60,8 @@ private: DataObjects::MDHistoWorkspace_sptr cropHisto(int h, int k, int l, double box, const API::IMDWorkspace_sptr &ws); void integratePeak(const int neighborPts, - DataObjects::MDHistoWorkspace_sptr out, double &intensity, - double &errorSquared); + const DataObjects::MDHistoWorkspace_sptr &out, + double &intensity, double &errorSquared); }; } // namespace MDAlgorithms diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h index 6f4949d3ee9ea389fc9e3b5563ecdd803ac4992d..d67fa614cb781cc4c501170bc77a8492ab63952b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h @@ -89,13 +89,13 @@ private: Mantid::API::IMDEventWorkspace_sptr m_OutWS; int splitIntoColumns(std::list<std::string> &columns, std::string &str); - void read_data(const std::string fname, + void read_data(const std::string &fname, std::map<std::string, std::string> &str_metadata, std::map<std::string, double> &num_metadata); void fillOutputWorkspace(double wavelength); void fillOutputWorkspaceRaw(double wavelength); API::ITableWorkspace_sptr saveHuber(); - void loadHuber(API::ITableWorkspace_sptr tws); + void loadHuber(const API::ITableWorkspace_sptr &tws); template <class T> void updateProperties(API::Run &run, std::map<std::string, T> &metadata, std::string time); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h index 724a3176a74cd1af7126d0a9f06f2f238eb4655a..9d421695064819b7b09f82e53cd8602bb15a64d4 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h @@ -62,8 +62,8 @@ private: void loadExperimentInfos( boost::shared_ptr<Mantid::API::MultipleExperimentInfos> ws); - void loadSlab(std::string name, void *data, - DataObjects::MDHistoWorkspace_sptr ws, + void loadSlab(const std::string &name, void *data, + const DataObjects::MDHistoWorkspace_sptr &ws, NeXus::NXnumtype dataType); void loadHisto(); @@ -80,18 +80,18 @@ private: boost::optional<Mantid::API::MDNormalization> &normalization); /// Load all the affine matricies - void loadAffineMatricies(API::IMDWorkspace_sptr ws); + void loadAffineMatricies(const API::IMDWorkspace_sptr &ws); /// Load a given affine matrix - API::CoordTransform *loadAffineMatrix(std::string entry_name); + API::CoordTransform *loadAffineMatrix(const std::string &entry_name); /// Sets MDFrames for workspaces from legacy files - void setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws); + void setMDFrameOnWorkspaceFromLegacyFile(const API::IMDWorkspace_sptr &ws); /// Checks if a worspace is a certain type of legacy file - void checkForRequiredLegacyFixup(API::IMDWorkspace_sptr ws); + void checkForRequiredLegacyFixup(const API::IMDWorkspace_sptr &ws); /// Negative scaling for Q dimensions - std::vector<double> qDimensions(API::IMDWorkspace_sptr ws); + std::vector<double> qDimensions(const API::IMDWorkspace_sptr &ws); /// Open file handle // clang-format off diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h index f121f9adeebdda1daee548f722b6afb7d017cd62..7a95acbba7ed06b91a47b1f23f39303becd58834 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h @@ -63,7 +63,7 @@ private: Geometry::IMDDimension_sptr createEnDimension(float umin, float umax, size_t nbins); void setupBoxController(); - void setupFileBackend(std::string filebackPath); + void setupFileBackend(const std::string &filebackPath); void readPixelDataIntoWorkspace(); void splitAllBoxes(); void warnIfMemoryInsufficient(int64_t npixtot); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h index e5cf63619a566e7bfce5dce971118a0d553b3f65..f0bf7fced21ae1f62163a28caf23263099e7016d 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNorm.h @@ -34,25 +34,25 @@ private: void exec() override; void validateBinningForTemporaryDataWorkspace( const std::map<std::string, std::string> &, - const Mantid::API::IMDHistoWorkspace_sptr); + const Mantid::API::IMDHistoWorkspace_sptr &); std::map<std::string, std::string> validateInputs() override final; std::string QDimensionName(std::vector<double> projection); std::string QDimensionNameQSample(int i); std::map<std::string, std::string> getBinParameters(); void createNormalizationWS(const DataObjects::MDHistoWorkspace &dataWS); DataObjects::MDHistoWorkspace_sptr - binInputWS(std::vector<Geometry::SymmetryOperation> symmetryOps); + binInputWS(const std::vector<Geometry::SymmetryOperation> &symmetryOps); std::vector<coord_t> getValuesFromOtherDimensions(bool &skipNormalization, uint16_t expInfoIndex = 0) const; void cacheDimensionXValues(); void calculateNormalization(const std::vector<coord_t> &otherValues, - Geometry::SymmetryOperation so, + const Geometry::SymmetryOperation &so, uint16_t expInfoIndex, size_t soIndex); void calculateIntersections(std::vector<std::array<double, 4>> &intersections, const double theta, const double phi, - Kernel::DblMatrix transform, double lowvalue, - double highvalue); + const Kernel::DblMatrix &transform, + double lowvalue, double highvalue); void calcIntegralsForIntersections(const std::vector<double> &xValues, const API::MatrixWorkspace &integrFlux, size_t sp, std::vector<double> &yValues); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h index 4dab97231a00213072119cdee94adeaa25ea900c..b8352419bc22d404f12ae3826fa8c1588c7a8040 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDTransfNoQ.h @@ -96,7 +96,7 @@ private: private: // internal helper function which extract one or two axis from input matrix // workspace; - static void getAxes(API::MatrixWorkspace_const_sptr inWS, + static void getAxes(const API::MatrixWorkspace_const_sptr &inWS, API::NumericAxis *&pXAxis, API::NumericAxis *&pYAxis); }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h index 734df7c639362c357353cb899d79fc2bdbc07101..07a7f14a0b7c961903fbe71351966f2d3da13de5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDWSDescription.h @@ -108,7 +108,7 @@ public: // for the time being /// method builds MD Event ws description from a matrix workspace and the /// transformations, requested to be performed on the workspace void buildFromMatrixWS(const API::MatrixWorkspace_sptr &pWS, - const std::string &QMode, const std::string dEMode, + const std::string &QMode, const std::string &dEMode, const std::vector<std::string> &dimPropertyNames = std::vector<std::string>()); @@ -132,12 +132,12 @@ public: // for the time being /** function extracts the coordinates from additional workspace properties and * places them to AddCoord vector for further usage*/ static void - fillAddProperties(Mantid::API::MatrixWorkspace_const_sptr inWS2D, + fillAddProperties(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D, const std::vector<std::string> &dimPropertyNames, std::vector<coord_t> &AddCoord); static boost::shared_ptr<Geometry::OrientedLattice> - getOrientedLattice(Mantid::API::MatrixWorkspace_const_sptr inWS2D); + getOrientedLattice(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D); /// Set the special coordinate system if any. void @@ -145,7 +145,7 @@ public: // for the time being /// @return the special coordinate system if any. Mantid::Kernel::SpecialCoordinateSystem getCoordinateSystem() const; /// Set the md frame - void setFrame(const std::string frameKey); + void setFrame(const std::string &frameKey); /// Retrieve the md frame Geometry::MDFrame_uptr getFrame(size_t d) const; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h index 1288d08656dc700b2cfd30db1ecaaf8a840223d5..ab2023ee4f0098a46e66f77c35ab6161c47a68d4 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h @@ -54,7 +54,7 @@ private: void loadBoxData(); - void doExecByCloning(Mantid::API::IMDEventWorkspace_sptr ws, + void doExecByCloning(const Mantid::API::IMDEventWorkspace_sptr &ws, const std::string &outputFile); void finalizeOutput(const std::string &outputFile); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h index dfea448c535d223dc9fcfec3642507f653525c30..9a44dcd6a0ab8854d1409bb2596e51bc86bb617e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h @@ -66,7 +66,8 @@ protected: // for testing // build a table workspace corresponding to the input matrix workspace boost::shared_ptr<DataObjects::TableWorkspace> createTableWorkspace(const API::MatrixWorkspace_const_sptr &inputWS); - bool isDetInfoLost(Mantid::API::MatrixWorkspace_const_sptr inWS2D) const; + bool + isDetInfoLost(const Mantid::API::MatrixWorkspace_const_sptr &inWS2D) const; // helper function to get efixed if it is there or not; double getEi(const API::MatrixWorkspace_const_sptr &inputWS) const; }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h index de5a8b8ccceed2995937253061c4e4a50f52d6f9..a72107429aa7ddb145eb1781a058f3358b31df09 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveIsawQvector.h @@ -32,7 +32,7 @@ private: MDWSDescription m_targWSDescr; - void initTargetWSDescr(DataObjects::EventWorkspace_sptr wksp); + void initTargetWSDescr(const DataObjects::EventWorkspace_sptr &wksp); }; } // namespace MDAlgorithms diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h index 90238f869f60b41402fbbe7e586c6076798fa31e..d621277f40c1708de49c2ad00a88c7430e1cdee5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD.h @@ -46,7 +46,7 @@ private: void doSaveEvents(typename DataObjects::MDEventWorkspace<MDE, nd>::sptr ws); /// Save the MDHistoWorkspace. - void doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws); + void doSaveHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws); /// Save all the affine matricies void saveAffineTransformMatricies(::NeXus::File *const file, diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h index 9a2a6b0be456edf0817ff822335646106367ef83..efe1f6204b0c02863c4d2dcc84582f930a5deefa 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h @@ -42,7 +42,7 @@ private: void exec() override; /// Save the MDHistoWorkspace. - void doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws); + void doSaveHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws); /// Save a generic matrix template <typename T> diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h index 2bdd1eb5765abb0fe3ae8b933770e124622a2c6b..91be6c61ac581933090312db5dd5de6780e898d2 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SlicingAlgorithm.h @@ -136,8 +136,8 @@ protected: private: Mantid::Geometry::MDFrame_uptr - createMDFrameForNonAxisAligned(std::string units, - Mantid::Kernel::VMD basisVector) const; + createMDFrameForNonAxisAligned(const std::string &units, + const Mantid::Kernel::VMD &basisVector) const; std::vector<Mantid::Kernel::VMD> getOldBasis(size_t dimension) const; bool isProjectingOnFrame(const Mantid::Kernel::VMD &oldVector, const Mantid::Kernel::VMD &basisVector) const; @@ -146,7 +146,7 @@ private: const std::vector<Mantid::Kernel::VMD> &oldBasis) const; Mantid::Geometry::MDFrame_uptr extractMDFrameForNonAxisAligned(std::vector<size_t> indicesWithProjection, - std::string units) const; + const std::string &units) const; void setTargetUnits(Mantid::Geometry::MDFrame_uptr &frame, const std::string &units) const; }; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h index 20f2fe9e67d0867d201067425ea814be7d769111..05e2f54c788045868c526a9fed1ed53daa3320e5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h @@ -37,13 +37,13 @@ public: std::map<std::string, std::string> validateInputs() override; boost::shared_ptr<Mantid::API::IMDHistoWorkspace> hatSmooth( - boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> toSmooth, + const boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> &toSmooth, const std::vector<double> &widthVector, boost::optional<boost::shared_ptr<const Mantid::API::IMDHistoWorkspace>> weightingWS); boost::shared_ptr<Mantid::API::IMDHistoWorkspace> gaussianSmooth( - boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> toSmooth, + const boost::shared_ptr<const Mantid::API::IMDHistoWorkspace> &toSmooth, const std::vector<double> &widthVector, boost::optional<boost::shared_ptr<const Mantid::API::IMDHistoWorkspace>> weightingWS); diff --git a/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp b/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp index 855a89d15c0a33734b7c68e209de780b699615c7..84d0e2bc6fee59ce53546312d7b527ca4138eb73 100644 --- a/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp +++ b/Framework/MDAlgorithms/src/BoxControllerSettingsAlgorithm.cpp @@ -4,12 +4,14 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h" +#include <utility> + #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/StringTokenizer.h" #include "MantidKernel/Strings.h" #include "MantidKernel/System.h" +#include "MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h" using namespace Mantid::Kernel; using namespace Mantid::API; @@ -75,7 +77,8 @@ void BoxControllerSettingsAlgorithm::initBoxControllerProps( * @param ndims : Number of dimensions in output workspace. */ void BoxControllerSettingsAlgorithm::takeDefaultsFromInstrument( - Mantid::Geometry::Instrument_const_sptr instrument, const size_t ndims) { + const Mantid::Geometry::Instrument_const_sptr &instrument, + const size_t ndims) { const std::string splitThresholdName = "SplitThreshold"; const std::string splitIntoName = "SplitInto"; const std::string maxRecursionDepthName = "MaxRecursionDepth"; @@ -117,10 +120,11 @@ void BoxControllerSettingsAlgorithm::takeDefaultsFromInstrument( * @param instrument :: instrument to read parameters from. */ void BoxControllerSettingsAlgorithm::setBoxController( - BoxController_sptr bc, Mantid::Geometry::Instrument_const_sptr instrument) { + const BoxController_sptr &bc, + const Mantid::Geometry::Instrument_const_sptr &instrument) { size_t nd = bc->getNDims(); - takeDefaultsFromInstrument(instrument, nd); + takeDefaultsFromInstrument(std::move(instrument), nd); setBoxController(bc); } @@ -131,7 +135,8 @@ void BoxControllerSettingsAlgorithm::setBoxController( * * @param bc :: box controller to modify */ -void BoxControllerSettingsAlgorithm::setBoxController(BoxController_sptr bc) { +void BoxControllerSettingsAlgorithm::setBoxController( + const BoxController_sptr &bc) { size_t nd = bc->getNDims(); int val; diff --git a/Framework/MDAlgorithms/src/CompactMD.cpp b/Framework/MDAlgorithms/src/CompactMD.cpp index e08e00e8d2cb8ab5a792053966414776def816f9..8c158a00c83ed09765dc91e0a2a97493f4832c82 100644 --- a/Framework/MDAlgorithms/src/CompactMD.cpp +++ b/Framework/MDAlgorithms/src/CompactMD.cpp @@ -30,7 +30,7 @@ namespace { std::vector<std::string> createPBinStringVector(std::vector<Mantid::coord_t> minVector, std::vector<Mantid::coord_t> maxVector, - IMDHistoWorkspace_sptr inputWs) { + const IMDHistoWorkspace_sptr &inputWs) { size_t numDims = inputWs->getNumDims(); std::vector<std::string> pBinStrVector; for (size_t iter = 0; iter < numDims; iter++) { @@ -65,7 +65,7 @@ DECLARE_ALGORITHM(CompactMD) */ void CompactMD::findFirstNonZeroMinMaxExtents( - IMDHistoWorkspace_sptr inputWs, std::vector<Mantid::coord_t> &minVec, + const IMDHistoWorkspace_sptr &inputWs, std::vector<Mantid::coord_t> &minVec, std::vector<Mantid::coord_t> &maxVec) { auto ws_iter = inputWs->createIterator(); do { diff --git a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp index 9554e6a6bcbed42524294b516e486db1864827ce..77411b5561360c3e6110934ad298442f991a3eb0 100644 --- a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp +++ b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp @@ -130,7 +130,8 @@ void CompareMDWorkspaces::compareTol(T a, T b, const std::string &message) { /** Compare the dimensions etc. of two MDWorkspaces */ void CompareMDWorkspaces::compareMDGeometry( - Mantid::API::IMDWorkspace_sptr ws1, Mantid::API::IMDWorkspace_sptr ws2) { + const Mantid::API::IMDWorkspace_sptr &ws1, + const Mantid::API::IMDWorkspace_sptr &ws2) { compare(ws1->getNumDims(), ws2->getNumDims(), "Workspaces have a different number of dimensions"); for (size_t d = 0; d < ws1->getNumDims(); d++) { @@ -156,8 +157,8 @@ void CompareMDWorkspaces::compareMDGeometry( /** Compare the dimensions etc. of two MDWorkspaces */ void CompareMDWorkspaces::compareMDHistoWorkspaces( - Mantid::DataObjects::MDHistoWorkspace_sptr ws1, - Mantid::DataObjects::MDHistoWorkspace_sptr ws2) { + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws1, + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws2) { compare(ws1->getNumDims(), ws2->getNumDims(), "Workspaces have a different number of dimensions"); compare(ws1->getNPoints(), ws2->getNPoints(), diff --git a/Framework/MDAlgorithms/src/ConvToMDBase.cpp b/Framework/MDAlgorithms/src/ConvToMDBase.cpp index 7938951d5d8c1c205a43bf60761ccc1354b2056d..78eec7938d9af774a1ddc5cf5b41de704a1ac2f4 100644 --- a/Framework/MDAlgorithms/src/ConvToMDBase.cpp +++ b/Framework/MDAlgorithms/src/ConvToMDBase.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/ConvToMDBase.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" +#include "MantidMDAlgorithms/ConvToMDBase.h" namespace Mantid { namespace MDAlgorithms { @@ -46,7 +48,7 @@ size_t ConvToMDBase::initialize( m_detID = WSD.m_PreprDetTable->getColVector<int>("DetectorID"); // set up output MD workspace wrapper - m_OutWSWrapper = inWSWrapper; + m_OutWSWrapper = std::move(inWSWrapper); // get the index which identify the run the source workspace came from. // This index will mark the workspace' events for diffetent worksapces to // combine diff --git a/Framework/MDAlgorithms/src/ConvToMDSelector.cpp b/Framework/MDAlgorithms/src/ConvToMDSelector.cpp index 90ef582c913b5f681990ab4995d0eba0ec1f8847..049b9296600bfaeb5677b56795681615398ad882 100644 --- a/Framework/MDAlgorithms/src/ConvToMDSelector.cpp +++ b/Framework/MDAlgorithms/src/ConvToMDSelector.cpp @@ -33,7 +33,7 @@ initiated) *@returns shared pointer to new solver, which corresponds to the workspace */ boost::shared_ptr<ConvToMDBase> ConvToMDSelector::convSelector( - API::MatrixWorkspace_sptr inputWS, + const API::MatrixWorkspace_sptr &inputWS, boost::shared_ptr<ConvToMDBase> ¤tSolver) const { // identify what kind of workspace we expect to process wsType inputWSType = Undefined; diff --git a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp index 8779b9fd0a3992cabcf71b3dc6f90787db3d7bd0..c917989601202c49bb9825226423d72ddd5b6d21 100644 --- a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidMDAlgorithms/ConvertCWPDMDToSpectra.h" #include "MantidAPI/Axis.h" @@ -208,8 +210,9 @@ void ConvertCWPDMDToSpectra::exec() { * @return */ API::MatrixWorkspace_sptr ConvertCWPDMDToSpectra::reducePowderData( - API::IMDEventWorkspace_const_sptr dataws, - IMDEventWorkspace_const_sptr monitorws, const std::string targetunit, + const API::IMDEventWorkspace_const_sptr &dataws, + const IMDEventWorkspace_const_sptr &monitorws, + const std::string &targetunit, const std::map<int, double> &map_runwavelength, const double xmin, const double xmax, const double binsize, bool dolinearinterpolation, const std::vector<detid_t> &vec_excludeddets) { @@ -259,7 +262,8 @@ API::MatrixWorkspace_sptr ConvertCWPDMDToSpectra::reducePowderData( unitchar = 'q'; binMD(dataws, unitchar, map_runwavelength, vecx, vecy, vec_excludeddets); - binMD(monitorws, unitchar, map_runwavelength, vecx, vecm, vec_excludeddets); + binMD(std::move(monitorws), unitchar, map_runwavelength, vecx, vecm, + vec_excludeddets); // Normalize by division double maxmonitorcounts = 0; @@ -317,7 +321,8 @@ API::MatrixWorkspace_sptr ConvertCWPDMDToSpectra::reducePowderData( * @param xmax :: (output) upper binning boundary */ void ConvertCWPDMDToSpectra::findXBoundary( - API::IMDEventWorkspace_const_sptr dataws, const std::string &targetunit, + const API::IMDEventWorkspace_const_sptr &dataws, + const std::string &targetunit, const std::map<int, double> &map_runwavelength, double &xmin, double &xmax) { // Go through all instruments @@ -425,12 +430,10 @@ void ConvertCWPDMDToSpectra::findXBoundary( * @param vecy * @param vec_excludedet */ -void ConvertCWPDMDToSpectra::binMD(API::IMDEventWorkspace_const_sptr mdws, - const char &unitbit, - const std::map<int, double> &map_runlambda, - const std::vector<double> &vecx, - std::vector<double> &vecy, - const std::vector<detid_t> &vec_excludedet) { +void ConvertCWPDMDToSpectra::binMD( + const API::IMDEventWorkspace_const_sptr &mdws, const char &unitbit, + const std::map<int, double> &map_runlambda, const std::vector<double> &vecx, + std::vector<double> &vecy, const std::vector<detid_t> &vec_excludedet) { // Check whether MD workspace has proper instrument and experiment Info if (mdws->getNumExperimentInfo() == 0) throw std::runtime_error( @@ -599,7 +602,7 @@ void ConvertCWPDMDToSpectra::binMD(API::IMDEventWorkspace_const_sptr mdws, * @param infinitesimal */ void ConvertCWPDMDToSpectra::linearInterpolation( - API::MatrixWorkspace_sptr matrixws, const double &infinitesimal) { + const API::MatrixWorkspace_sptr &matrixws, const double &infinitesimal) { g_log.debug() << "Number of spectrum = " << matrixws->getNumberHistograms() << " Infinitesimal = " << infinitesimal << "\n"; size_t numspec = matrixws->getNumberHistograms(); @@ -670,8 +673,8 @@ void ConvertCWPDMDToSpectra::linearInterpolation( * @param inputmdws */ void ConvertCWPDMDToSpectra::setupSampleLogs( - API::MatrixWorkspace_sptr matrixws, - API::IMDEventWorkspace_const_sptr inputmdws) { + const API::MatrixWorkspace_sptr &matrixws, + const API::IMDEventWorkspace_const_sptr &inputmdws) { // get hold of the last experiment info from md workspace to copy over auto lastindex = static_cast<uint16_t>(inputmdws->getNumExperimentInfo() - 1); ExperimentInfo_const_sptr lastexpinfo = @@ -696,7 +699,7 @@ void ConvertCWPDMDToSpectra::setupSampleLogs( * @param infinitesimal */ void ConvertCWPDMDToSpectra::scaleMatrixWorkspace( - API::MatrixWorkspace_sptr matrixws, const double &scalefactor, + const API::MatrixWorkspace_sptr &matrixws, const double &scalefactor, const double &infinitesimal) { size_t numspec = matrixws->getNumberHistograms(); for (size_t iws = 0; iws < numspec; ++iws) { diff --git a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp index 8bdb5af394e8aa51214e588841b3ed6864fc38b7..88b8e36f26e7264b2bcf0c235d1e2ff619276992 100644 --- a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp @@ -342,7 +342,8 @@ void ConvertCWSDExpToMomentum::addMDEvents(bool usevirtual) { * Q-sample */ void ConvertCWSDExpToMomentum::setupTransferMatrix( - API::MatrixWorkspace_sptr dataws, Kernel::DblMatrix &rotationMatrix) { + const API::MatrixWorkspace_sptr &dataws, + Kernel::DblMatrix &rotationMatrix) { // Check sample logs if (!dataws->run().hasProperty("_omega") || !dataws->run().hasProperty("_chi") || !dataws->run().hasProperty("_phi")) @@ -384,9 +385,9 @@ void ConvertCWSDExpToMomentum::setupTransferMatrix( * workspace */ void ConvertCWSDExpToMomentum::convertSpiceMatrixToMomentumMDEvents( - MatrixWorkspace_sptr dataws, bool usevirtual, const detid_t &startdetid, - const int scannumber, const int runnumber, double measuretime, - int monitor_counts) { + const MatrixWorkspace_sptr &dataws, bool usevirtual, + const detid_t &startdetid, const int scannumber, const int runnumber, + double measuretime, int monitor_counts) { // Create transformation matrix from which the transformation is Kernel::DblMatrix rotationMatrix; setupTransferMatrix(dataws, rotationMatrix); @@ -696,7 +697,7 @@ void ConvertCWSDExpToMomentum::updateQRange( * @param dataws */ void ConvertCWSDExpToMomentum::removeBackground( - API::MatrixWorkspace_sptr dataws) { + const API::MatrixWorkspace_sptr &dataws) { if (dataws->getNumberHistograms() != m_backgroundWS->getNumberHistograms()) throw std::runtime_error("Impossible to have this situation"); diff --git a/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp b/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp index 94a2166a39bb355ac799f110e5760c1b7ac93ea0..ee6693b9c76bf319b3fe5761d26dfbd829c4e8ae 100644 --- a/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp @@ -169,7 +169,8 @@ void ConvertCWSDMDtoHKL::getUBMatrix() { * number of detectors */ void ConvertCWSDMDtoHKL::exportEvents( - IMDEventWorkspace_sptr mdws, std::vector<Kernel::V3D> &vec_event_qsample, + const IMDEventWorkspace_sptr &mdws, + std::vector<Kernel::V3D> &vec_event_qsample, std::vector<signal_t> &vec_event_signal, std::vector<detid_t> &vec_event_det) { // Set the size of the output vectors @@ -373,7 +374,7 @@ API::IMDEventWorkspace_sptr ConvertCWSDMDtoHKL::createHKLMDWorkspace( return mdws; } -void ConvertCWSDMDtoHKL::getRange(const std::vector<Kernel::V3D> vec_hkl, +void ConvertCWSDMDtoHKL::getRange(const std::vector<Kernel::V3D> &vec_hkl, std::vector<double> &extentMins, std::vector<double> &extentMaxs) { assert(extentMins.size() == 3); diff --git a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp index e72e3f73326f66dfd8ae5d59791e036cee160243..0d55347e1e56cee9acd4b0f55d689703de215232 100644 --- a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp +++ b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp @@ -209,8 +209,9 @@ void ConvertSpiceDataToRealSpace::exec() { */ std::vector<MatrixWorkspace_sptr> ConvertSpiceDataToRealSpace::convertToMatrixWorkspace( - DataObjects::TableWorkspace_sptr tablews, - API::MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, + const DataObjects::TableWorkspace_sptr &tablews, + const API::MatrixWorkspace_const_sptr &parentws, + Types::Core::DateAndTime runstart, std::map<std::string, std::vector<double>> &logvecmap, std::vector<Types::Core::DateAndTime> &vectimes) { // Get table workspace's column information @@ -249,7 +250,7 @@ ConvertSpiceDataToRealSpace::convertToMatrixWorkspace( * @param logvecmap */ void ConvertSpiceDataToRealSpace::parseSampleLogs( - DataObjects::TableWorkspace_sptr tablews, + const DataObjects::TableWorkspace_sptr &tablews, const std::map<std::string, size_t> &indexlist, std::map<std::string, std::vector<double>> &logvecmap) { size_t numrows = tablews->rowCount(); @@ -287,10 +288,11 @@ void ConvertSpiceDataToRealSpace::parseSampleLogs( * @return */ MatrixWorkspace_sptr ConvertSpiceDataToRealSpace::loadRunToMatrixWS( - DataObjects::TableWorkspace_sptr tablews, size_t irow, - MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, - size_t ipt, size_t irotangle, size_t itime, - const std::vector<std::pair<size_t, size_t>> anodelist, double &duration) { + const DataObjects::TableWorkspace_sptr &tablews, size_t irow, + const MatrixWorkspace_const_sptr &parentws, + Types::Core::DateAndTime runstart, size_t ipt, size_t irotangle, + size_t itime, const std::vector<std::pair<size_t, size_t>> &anodelist, + double &duration) { // New workspace from parent workspace MatrixWorkspace_sptr tempws = WorkspaceFactory::Instance().create(parentws, m_numSpec, 2, 1); @@ -367,7 +369,7 @@ MatrixWorkspace_sptr ConvertSpiceDataToRealSpace::loadRunToMatrixWS( * @param samplenameindexmap */ void ConvertSpiceDataToRealSpace::readTableInfo( - TableWorkspace_const_sptr tablews, size_t &ipt, size_t &irotangle, + const TableWorkspace_const_sptr &tablews, size_t &ipt, size_t &irotangle, size_t &itime, std::vector<std::pair<size_t, size_t>> &anodelist, std::map<std::string, size_t> &samplenameindexmap) { @@ -439,7 +441,7 @@ void ConvertSpiceDataToRealSpace::readTableInfo( * @param vectimes */ void ConvertSpiceDataToRealSpace::appendSampleLogs( - IMDEventWorkspace_sptr mdws, + const IMDEventWorkspace_sptr &mdws, const std::map<std::string, std::vector<double>> &logvecmap, const std::vector<Types::Core::DateAndTime> &vectimes) { // Check! @@ -524,8 +526,8 @@ void ConvertSpiceDataToRealSpace::appendSampleLogs( * @param vec_ws2d */ void ConvertSpiceDataToRealSpace::addExperimentInfos( - API::IMDEventWorkspace_sptr mdws, - const std::vector<API::MatrixWorkspace_sptr> vec_ws2d) { + const API::IMDEventWorkspace_sptr &mdws, + const std::vector<API::MatrixWorkspace_sptr> &vec_ws2d) { // Add N experiment info as there are N measurment points for (const auto &ws2d : vec_ws2d) { // Create an ExperimentInfo object @@ -633,7 +635,7 @@ IMDEventWorkspace_sptr ConvertSpiceDataToRealSpace::createDataMDWorkspace( * @return */ IMDEventWorkspace_sptr ConvertSpiceDataToRealSpace::createMonitorMDWorkspace( - const std::vector<MatrixWorkspace_sptr> vec_ws2d, + const std::vector<MatrixWorkspace_sptr> &vec_ws2d, const std::vector<double> &vecmonitor) { // Create a target output workspace. IMDEventWorkspace_sptr outWs = @@ -710,7 +712,7 @@ IMDEventWorkspace_sptr ConvertSpiceDataToRealSpace::createMonitorMDWorkspace( */ std::map<detid_t, double> ConvertSpiceDataToRealSpace::parseDetectorEfficiencyTable( - DataObjects::TableWorkspace_sptr detefftablews) { + const DataObjects::TableWorkspace_sptr &detefftablews) { std::map<detid_t, double> deteffmap; // check table workspace diff --git a/Framework/MDAlgorithms/src/ConvertToMD.cpp b/Framework/MDAlgorithms/src/ConvertToMD.cpp index 630390295c80f14457e62d5879107b1f145cc1d9..9c0530b042e66e6756272ad300c87e5c320c0f7a 100644 --- a/Framework/MDAlgorithms/src/ConvertToMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToMD.cpp @@ -445,7 +445,7 @@ is ignored in any other case together and used to describe selected transformation. */ bool ConvertToMD::buildTargetWSDescription( - API::IMDEventWorkspace_sptr spws, const std::string &QModReq, + const API::IMDEventWorkspace_sptr &spws, const std::string &QModReq, const std::string &dEModReq, const std::vector<std::string> &otherDimNames, std::vector<double> &dimMin, std::vector<double> &dimMax, const std::string &QFrame, const std::string &convertTo_, @@ -604,7 +604,8 @@ ConvertToMD::createNewMDWorkspace(const MDWSDescription &targWSDescr, * the first level. * @param bc A pointer to the box controller. */ -void ConvertToMD::setupTopLevelSplitting(Mantid::API::BoxController_sptr bc) { +void ConvertToMD::setupTopLevelSplitting( + const Mantid::API::BoxController_sptr &bc) { const size_t topLevelSplitSetting = 50; const size_t dimCutoff = 4; @@ -625,7 +626,8 @@ void ConvertToMD::setupTopLevelSplitting(Mantid::API::BoxController_sptr bc) { * *@returns true if one needs to create new workspace and false otherwise */ -bool ConvertToMD::doWeNeedNewTargetWorkspace(API::IMDEventWorkspace_sptr spws) { +bool ConvertToMD::doWeNeedNewTargetWorkspace( + const API::IMDEventWorkspace_sptr &spws) { bool createNewWs(false); if (!spws) { @@ -762,7 +764,8 @@ void ConvertToMD::findMinMax( * @param outputWS :: Workspace on which to set the file back end */ void ConvertToMD::setupFileBackend( - std::string filebackPath, Mantid::API::IMDEventWorkspace_sptr outputWS) { + const std::string &filebackPath, + const Mantid::API::IMDEventWorkspace_sptr &outputWS) { using DataObjects::BoxControllerNeXusIO; auto savemd = this->createChildAlgorithm("SaveMD", 0.01, 0.05, true); savemd->setProperty("InputWorkspace", outputWS); diff --git a/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp b/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp index a1227491a92aa53ab0709cd8f190b793ed889008..556551412635b6290e0c80ad3228f056267f7d54 100644 --- a/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp +++ b/Framework/MDAlgorithms/src/ConvertToReflectometryQ.cpp @@ -75,7 +75,8 @@ Check that the input workspace is of the correct type. @throw: runtime_error if the units do not appear to be correct/compatible with the algorithm. */ -void checkInputWorkspace(Mantid::API::MatrixWorkspace_const_sptr inputWs) { +void checkInputWorkspace( + const Mantid::API::MatrixWorkspace_const_sptr &inputWs) { auto spectraAxis = inputWs->getAxis(1); const std::string label = spectraAxis->unit()->label(); const std::string expectedLabel = "degrees"; @@ -148,7 +149,7 @@ Get the value of theta from the logs @return : theta found in the logs @throw: runtime_errror if 'stheta' was not found. */ -double getThetaFromLogs(MatrixWorkspace_sptr inputWs) { +double getThetaFromLogs(const MatrixWorkspace_sptr &inputWs) { double theta = -1.; const Mantid::API::Run &run = inputWs->run(); diff --git a/Framework/MDAlgorithms/src/CreateMD.cpp b/Framework/MDAlgorithms/src/CreateMD.cpp index b4eafe793cd23ed85a9cc1f59b5f36e0b49c4686..ff6410e56557ed621bf9de955df891ae17fe87ba 100644 --- a/Framework/MDAlgorithms/src/CreateMD.cpp +++ b/Framework/MDAlgorithms/src/CreateMD.cpp @@ -15,6 +15,8 @@ #include "MantidKernel/MandatoryValidator.h" #include <Poco/Path.h> +#include <utility> + using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; @@ -308,7 +310,7 @@ Mantid::API::Workspace_sptr CreateMD::loadWs(const std::string &filename, * @param log_name :: the name of the log * @param log_number :: the value to record in the log */ -void CreateMD::addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, +void CreateMD::addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &log_name, double log_number) { Algorithm_sptr log_alg = createChildAlgorithm("AddSampleLog"); @@ -327,7 +329,8 @@ void CreateMD::addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, * * @param workspace :: the workspace to set the goniometer values in */ -void CreateMD::setGoniometer(Mantid::API::MatrixWorkspace_sptr workspace) { +void CreateMD::setGoniometer( + const Mantid::API::MatrixWorkspace_sptr &workspace) { Algorithm_sptr log_alg = createChildAlgorithm("SetGoniometer"); if (!workspace->run().getProperty("gl")) { std::ostringstream temp_ss; @@ -356,8 +359,8 @@ void CreateMD::setGoniometer(Mantid::API::MatrixWorkspace_sptr workspace) { * @param u :: lattice vector parallel to incident neutron beam * @param v :: lattice vector perpendicular to u in the horizontal plane */ -void CreateMD::setUB(Mantid::API::MatrixWorkspace_sptr workspace, double a, - double b, double c, double alpha, double beta, +void CreateMD::setUB(const Mantid::API::MatrixWorkspace_sptr &workspace, + double a, double b, double c, double alpha, double beta, double gamma, const std::vector<double> &u, const std::vector<double> &v) { Algorithm_sptr set_ub_alg = createChildAlgorithm("SetUB"); @@ -383,10 +386,12 @@ void CreateMD::setUB(Mantid::API::MatrixWorkspace_sptr workspace, double a, * @out_mdws :: output workspace to use if merge step is carried out * @returns the output converted workspace */ -Mantid::API::IMDEventWorkspace_sptr CreateMD::convertToMD( - Mantid::API::Workspace_sptr workspace, const std::string &analysis_mode, - bool in_place, const std::string &filebackend_filename, - const bool filebackend, Mantid::API::IMDEventWorkspace_sptr out_mdws) { +Mantid::API::IMDEventWorkspace_sptr +CreateMD::convertToMD(const Mantid::API::Workspace_sptr &workspace, + const std::string &analysis_mode, bool in_place, + const std::string &filebackend_filename, + const bool filebackend, + const Mantid::API::IMDEventWorkspace_sptr &out_mdws) { Algorithm_sptr min_max_alg = createChildAlgorithm("ConvertToMDMinMaxGlobal"); min_max_alg->setProperty("InputWorkspace", workspace); min_max_alg->setProperty("QDimensions", "Q3D"); @@ -462,12 +467,13 @@ CreateMD::merge_runs(const std::vector<std::string> &to_merge) { * @param out_mdws :output workspace to use if merge step is carried out */ Mantid::API::IMDEventWorkspace_sptr CreateMD::single_run( - Mantid::API::MatrixWorkspace_sptr input_workspace, const std::string &emode, - double efix, double psi, double gl, double gs, bool in_place, - const std::vector<double> &alatt, const std::vector<double> &angdeg, - const std::vector<double> &u, const std::vector<double> &v, - const std::string &filebackend_filename, const bool filebackend, - Mantid::API::IMDEventWorkspace_sptr out_mdws) { + const Mantid::API::MatrixWorkspace_sptr &input_workspace, + const std::string &emode, double efix, double psi, double gl, double gs, + bool in_place, const std::vector<double> &alatt, + const std::vector<double> &angdeg, const std::vector<double> &u, + const std::vector<double> &v, const std::string &filebackend_filename, + const bool filebackend, + const Mantid::API::IMDEventWorkspace_sptr &out_mdws) { std::vector<std::vector<double>> ub_params{alatt, angdeg, u, v}; @@ -493,7 +499,7 @@ Mantid::API::IMDEventWorkspace_sptr CreateMD::single_run( setGoniometer(input_workspace); return convertToMD(input_workspace, emode, in_place, filebackend_filename, - filebackend, out_mdws); + filebackend, std::move(out_mdws)); } } diff --git a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp index 9c3883ba245df8d4aa4d17174196fbc88a091513..bbaaa2c2a426eb167a30633b8a84b5d0137be3d0 100644 --- a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp @@ -243,8 +243,8 @@ void CreateMDWorkspace::exec() { setProperty("OutputWorkspace", boost::dynamic_pointer_cast<Workspace>(out)); } -MDFrame_uptr CreateMDWorkspace::createMDFrame(std::string frame, - std::string unit) { +MDFrame_uptr CreateMDWorkspace::createMDFrame(const std::string &frame, + const std::string &unit) { auto frameFactory = makeMDFrameFactoryChain(); MDFrameArgument frameArg(frame, unit); return frameFactory->create(frameArg); diff --git a/Framework/MDAlgorithms/src/CutMD.cpp b/Framework/MDAlgorithms/src/CutMD.cpp index 07d65b3d8e41a9054dd6e01a30a3cfc915fe9339..0e0c56601b78157f4c8e083c895baef658026a67 100644 --- a/Framework/MDAlgorithms/src/CutMD.cpp +++ b/Framework/MDAlgorithms/src/CutMD.cpp @@ -31,7 +31,7 @@ namespace { // Typedef to simplify function signatures using MinMax = std::pair<double, double>; -MinMax getDimensionExtents(IMDEventWorkspace_sptr ws, size_t index) { +MinMax getDimensionExtents(const IMDEventWorkspace_sptr &ws, size_t index) { if (!ws) throw std::runtime_error( "Invalid workspace passed to getDimensionExtents."); @@ -50,7 +50,7 @@ std::string numToStringWithPrecision(const double num) { DblMatrix scaleProjection(const DblMatrix &inMatrix, const std::vector<std::string> &inUnits, std::vector<std::string> &outUnits, - IMDEventWorkspace_sptr inWS) { + const IMDEventWorkspace_sptr &inWS) { DblMatrix ret(inMatrix); // Check if we actually need to do anything if (std::equal(inUnits.begin(), inUnits.end(), outUnits.begin())) @@ -209,7 +209,7 @@ Determine the original q units. Assumes first 3 dimensions by index are r,l,d @param logger : logging object @return vector of markers */ -std::vector<std::string> findOriginalQUnits(IMDWorkspace_const_sptr inws, +std::vector<std::string> findOriginalQUnits(const IMDWorkspace_const_sptr &inws, Mantid::Kernel::Logger &logger) { std::vector<std::string> unitMarkers(3); for (size_t i = 0; i < inws->getNumDims() && i < 3; ++i) { diff --git a/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp b/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp index 6572ab64d006425e9a20108a014a208f71ae391e..1d89a09fbf476b1f3fea00d81b5c1047f9cb7d4c 100644 --- a/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp +++ b/Framework/MDAlgorithms/src/DisplayNormalizationSetter.cpp @@ -4,10 +4,12 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/DisplayNormalizationSetter.h" +#include <utility> + #include "MantidAPI/IMDEventWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidMDAlgorithms/DisplayNormalizationSetter.h" namespace Mantid { namespace MDAlgorithms { @@ -21,7 +23,7 @@ namespace MDAlgorithms { * @param mode: the energy transfer mode */ void DisplayNormalizationSetter:: -operator()(Mantid::API::IMDWorkspace_sptr mdWorkspace, +operator()(const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ, const Mantid::Kernel::DeltaEMode::Type &mode) { if (boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>( @@ -42,7 +44,7 @@ operator()(Mantid::API::IMDWorkspace_sptr mdWorkspace, * @param mode: the energy transfer mode */ void DisplayNormalizationSetter::setNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, const Mantid::API::MatrixWorkspace_sptr &underlyingWorkspace, bool isQ, const Mantid::Kernel::DeltaEMode::Type &mode) { @@ -73,7 +75,7 @@ void DisplayNormalizationSetter::setNormalizationMDEvent( Mantid::API::MDNormalization::NumEventsNormalization; } - applyNormalizationMDEvent(mdWorkspace, displayNormalization, + applyNormalizationMDEvent(std::move(mdWorkspace), displayNormalization, displayNormalizationHisto); } @@ -86,7 +88,7 @@ void DisplayNormalizationSetter::setNormalizationMDEvent( * MDHisto workspaces */ void DisplayNormalizationSetter::applyNormalizationMDEvent( - Mantid::API::IMDWorkspace_sptr mdWorkspace, + const Mantid::API::IMDWorkspace_sptr &mdWorkspace, Mantid::API::MDNormalization displayNormalization, Mantid::API::MDNormalization displayNormalizationHisto) { auto ws = diff --git a/Framework/MDAlgorithms/src/FindPeaksMD.cpp b/Framework/MDAlgorithms/src/FindPeaksMD.cpp index 10a1aab163167a0f44e738191ac3bb20549f31e7..eb8992ca9d5cdc0046e0a6daa621c979b08d5d6d 100644 --- a/Framework/MDAlgorithms/src/FindPeaksMD.cpp +++ b/Framework/MDAlgorithms/src/FindPeaksMD.cpp @@ -586,7 +586,7 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) { * @param ws :: MDHistoWorkspace */ void FindPeaksMD::findPeaksHisto( - Mantid::DataObjects::MDHistoWorkspace_sptr ws) { + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws) { size_t nd = ws->getNumDims(); if (nd < 3) throw std::invalid_argument("Workspace must have at least 3 dimensions."); diff --git a/Framework/MDAlgorithms/src/FitMD.cpp b/Framework/MDAlgorithms/src/FitMD.cpp index a0b92864cb4d2b48bc55862df8cf7daa57a3689c..fe289f2f494377274e389388f2fda1d4e946246a 100644 --- a/Framework/MDAlgorithms/src/FitMD.cpp +++ b/Framework/MDAlgorithms/src/FitMD.cpp @@ -269,8 +269,8 @@ boost::shared_ptr<API::Workspace> FitMD::createEventOutputWorkspace( * @param outputWorkspacePropertyName :: The property name */ boost::shared_ptr<API::Workspace> FitMD::createHistoOutputWorkspace( - const std::string &baseName, API::IFunction_sptr function, - API::IMDHistoWorkspace_const_sptr inputWorkspace, + const std::string &baseName, const API::IFunction_sptr &function, + const API::IMDHistoWorkspace_const_sptr &inputWorkspace, const std::string &outputWorkspacePropertyName) { // have to cast const away to be able to pass the workspace to the algorithm API::IMDHistoWorkspace_sptr nonConstInputWS = diff --git a/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp b/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp index 9aefe3c58f3c99f631b9f4b86b20920c4de5d57d..b82ab214b1b360fdd5a1147abf0d2407ac5c6c92 100644 --- a/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp +++ b/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp @@ -17,6 +17,7 @@ #include "MantidKernel/ListValidator.h" #include <algorithm> +#include <utility> namespace Mantid { namespace MDAlgorithms { @@ -147,15 +148,16 @@ void GetSpiceDataRawCountsFromMD::exec() { * @param donormalize */ void GetSpiceDataRawCountsFromMD::exportDetCountsOfRun( - API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, const int runnumber, + const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, const int runnumber, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel, bool donormalize) { // Get detector counts std::vector<double> vec2theta; std::vector<double> vecDetCounts; int detid = -1; - getDetCounts(datamdws, runnumber, detid, vec2theta, vecDetCounts, true); + getDetCounts(std::move(datamdws), runnumber, detid, vec2theta, vecDetCounts, + true); if (vec2theta.size() != vecDetCounts.size()) throw std::runtime_error( "Logic error! Vector of 2theta must have same size as " @@ -166,8 +168,8 @@ void GetSpiceDataRawCountsFromMD::exportDetCountsOfRun( std::vector<double> vecMonitorCounts; // Normalize if required if (donormalize) { - getDetCounts(monitormdws, runnumber, detid, vec2thetaMon, vecMonitorCounts, - false); + getDetCounts(std::move(monitormdws), runnumber, detid, vec2thetaMon, + vecMonitorCounts, false); // check if (vecDetCounts.size() != vecMonitorCounts.size()) throw std::runtime_error( @@ -218,8 +220,8 @@ void GetSpiceDataRawCountsFromMD::exportDetCountsOfRun( * @param donormalize */ void GetSpiceDataRawCountsFromMD::exportIndividualDetCounts( - API::IMDEventWorkspace_const_sptr datamdws, - API::IMDEventWorkspace_const_sptr monitormdws, const int detid, + const API::IMDEventWorkspace_const_sptr &datamdws, + const API::IMDEventWorkspace_const_sptr &monitormdws, const int detid, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel, const bool &donormalize) { // Get detector counts @@ -246,8 +248,8 @@ void GetSpiceDataRawCountsFromMD::exportIndividualDetCounts( // FIXME - Consider refactoring in future // Normalize if required if (donormalize) { - getDetCounts(monitormdws, runnumber, detid, vec2thetaMon, vecMonitorCounts, - false); + getDetCounts(std::move(monitormdws), runnumber, detid, vec2thetaMon, + vecMonitorCounts, false); if (vecDetCounts.size() != vecMonitorCounts.size()) throw std::runtime_error( "Number of detectors' counts' is different from that of " @@ -296,7 +298,7 @@ void GetSpiceDataRawCountsFromMD::exportIndividualDetCounts( * @param ylabel */ void GetSpiceDataRawCountsFromMD::exportSampleLogValue( - API::IMDEventWorkspace_const_sptr datamdws, + const API::IMDEventWorkspace_const_sptr &datamdws, const std::string &samplelogname, std::vector<double> &vecX, std::vector<double> &vecY, std::string &xlabel, std::string &ylabel) { // prepare @@ -349,7 +351,7 @@ void GetSpiceDataRawCountsFromMD::exportSampleLogValue( * @param formX :: flag to set up vecX */ void GetSpiceDataRawCountsFromMD::getDetCounts( - API::IMDEventWorkspace_const_sptr mdws, const int &runnumber, + const API::IMDEventWorkspace_const_sptr &mdws, const int &runnumber, const int &detid, std::vector<double> &vecX, std::vector<double> &vecY, bool formX) { // Get sample and source position @@ -441,7 +443,7 @@ void GetSpiceDataRawCountsFromMD::getDetCounts( * @param vecSampleLog */ void GetSpiceDataRawCountsFromMD::getSampleLogValues( - IMDEventWorkspace_const_sptr mdws, const std::string &samplelogname, + const IMDEventWorkspace_const_sptr &mdws, const std::string &samplelogname, const int runnumber, std::vector<double> &vecSampleLog) { // Clear input vecSampleLog.clear(); diff --git a/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp b/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp index fe71eb9bc1982af4b7b6fd6bd41d66f7fb574117..53ae75ebfbbfdb582bd83e70310a4dec7ddb8224 100644 --- a/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp +++ b/Framework/MDAlgorithms/src/ImportMDHistoWorkspaceBase.cpp @@ -145,8 +145,9 @@ MDHistoWorkspace_sptr ImportMDHistoWorkspaceBase::createEmptyOutputWorkspace() { * @param unit: the selected unit * @returns a unique pointer to an MDFrame */ -MDFrame_uptr ImportMDHistoWorkspaceBase::createMDFrame(std::string frame, - std::string unit) { +MDFrame_uptr +ImportMDHistoWorkspaceBase::createMDFrame(const std::string &frame, + const std::string &unit) { auto frameFactory = makeMDFrameFactoryChain(); MDFrameArgument frameArg(frame, unit); return frameFactory->create(frameArg); diff --git a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp index 798c7c907636878f3e106fcbd58cbc5b3bdd6052..b7fa3fe54a4e7fb407c5bb7fc30db005a982bfa5 100644 --- a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp +++ b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp @@ -18,6 +18,8 @@ extern "C" { #include <cstdio> +#include <utility> + #include <gsl/gsl_eigen.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_vector.h> @@ -447,7 +449,7 @@ bool Integrate3DEvents::correctForDetectorEdges( */ Mantid::Geometry::PeakShape_const_sptr Integrate3DEvents::ellipseIntegrateEvents( - std::vector<V3D> E1Vec, V3D const &peak_q, bool specify_size, + const std::vector<V3D> &E1Vec, V3D const &peak_q, bool specify_size, double peak_radius, double back_inner_radius, double back_outer_radius, std::vector<double> &axes_radii, double &inti, double &sigi) { inti = 0.0; // default values, in case something @@ -494,18 +496,18 @@ Integrate3DEvents::ellipseIntegrateEvents( return boost::make_shared<NoShape>(); // ellipsoids will be zero. } - return ellipseIntegrateEvents(E1Vec, peak_q, some_events, eigen_vectors, - sigmas, specify_size, peak_radius, - back_inner_radius, back_outer_radius, - axes_radii, inti, sigi); + return ellipseIntegrateEvents(std::move(E1Vec), peak_q, some_events, + eigen_vectors, sigmas, specify_size, + peak_radius, back_inner_radius, + back_outer_radius, axes_radii, inti, sigi); } Mantid::Geometry::PeakShape_const_sptr Integrate3DEvents::ellipseIntegrateModEvents( - std::vector<V3D> E1Vec, V3D const &peak_q, V3D const &hkl, V3D const &mnp, - bool specify_size, double peak_radius, double back_inner_radius, - double back_outer_radius, std::vector<double> &axes_radii, double &inti, - double &sigi) { + const std::vector<V3D> &E1Vec, V3D const &peak_q, V3D const &hkl, + V3D const &mnp, bool specify_size, double peak_radius, + double back_inner_radius, double back_outer_radius, + std::vector<double> &axes_radii, double &inti, double &sigi) { inti = 0.0; // default values, in case something sigi = 0.0; // is wrong with the peak. @@ -555,10 +557,10 @@ Integrate3DEvents::ellipseIntegrateModEvents( return boost::make_shared<NoShape>(); // ellipsoids will be zero. } - return ellipseIntegrateEvents(E1Vec, peak_q, some_events, eigen_vectors, - sigmas, specify_size, peak_radius, - back_inner_radius, back_outer_radius, - axes_radii, inti, sigi); + return ellipseIntegrateEvents(std::move(E1Vec), peak_q, some_events, + eigen_vectors, sigmas, specify_size, + peak_radius, back_inner_radius, + back_outer_radius, axes_radii, inti, sigi); } /** * Calculate the number of events in an ellipsoid centered at 0,0,0 with @@ -1107,7 +1109,7 @@ void Integrate3DEvents::addModEvent( * */ PeakShapeEllipsoid_const_sptr Integrate3DEvents::ellipseIntegrateEvents( - std::vector<V3D> E1Vec, V3D const &peak_q, + const std::vector<V3D> &E1Vec, V3D const &peak_q, std::vector<std::pair<std::pair<double, double>, Mantid::Kernel::V3D>> const &ev_list, std::vector<V3D> const &directions, std::vector<double> const &sigmas, @@ -1212,7 +1214,8 @@ PeakShapeEllipsoid_const_sptr Integrate3DEvents::ellipseIntegrateEvents( * @param QLabFrame: The Peak center. * @param r: Peak radius. */ -double Integrate3DEvents::detectorQ(std::vector<V3D> E1Vec, const V3D QLabFrame, +double Integrate3DEvents::detectorQ(const std::vector<V3D> &E1Vec, + const V3D QLabFrame, const std::vector<double> &r) { double quot = 1.0; for (auto &E1 : E1Vec) { diff --git a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp index ce914be9ceb54483e9c521cda74405fe546a7de5..e11aaaad9fef17eb5767838cd800669c86492abc 100644 --- a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp +++ b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp @@ -746,8 +746,8 @@ void IntegrateEllipsoids::calculateE1( } void IntegrateEllipsoids::runMaskDetectors( - Mantid::DataObjects::PeaksWorkspace_sptr peakWS, std::string property, - std::string values) { + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values) { IAlgorithm_sptr alg = createChildAlgorithm("MaskBTP"); alg->setProperty<Workspace_sptr>("Workspace", peakWS); alg->setProperty(property, values); diff --git a/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp b/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp index 78ea2ccc95e3ebeabe2152956c588766f9a0d040..0d5a049faa3a8cd77717a32f07c686d82f6f41e2 100644 --- a/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp +++ b/Framework/MDAlgorithms/src/IntegrateEllipsoidsTwoStep.cpp @@ -559,8 +559,8 @@ void IntegrateEllipsoidsTwoStep::calculateE1( } void IntegrateEllipsoidsTwoStep::runMaskDetectors( - Mantid::DataObjects::PeaksWorkspace_sptr peakWS, std::string property, - std::string values) { + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values) { IAlgorithm_sptr alg = createChildAlgorithm("MaskBTP"); alg->setProperty<Workspace_sptr>("Workspace", peakWS); alg->setProperty(property, values); diff --git a/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp b/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp index 066aa52318b58ef5f5270fb09f94bfa37ac9fe03..df0ce5a5a9495f70f2f84a99ad995a02bd2f43c0 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp @@ -368,7 +368,7 @@ void IntegratePeaksCWSD::simplePeakIntegration( * @param maskws */ std::vector<detid_t> IntegratePeaksCWSD::processMaskWorkspace( - DataObjects::MaskWorkspace_const_sptr maskws) { + const DataObjects::MaskWorkspace_const_sptr &maskws) { std::vector<detid_t> vecMaskedDetID; // Add the detector IDs of all masked detector to a vector @@ -452,9 +452,8 @@ DataObjects::PeaksWorkspace_sptr IntegratePeaksCWSD::createOutputs() { * @param mdws :: source MDEventWorkspace where the run numbers come from * @return */ -DataObjects::PeaksWorkspace_sptr -IntegratePeaksCWSD::createPeakworkspace(Kernel::V3D peakCenter, - API::IMDEventWorkspace_sptr mdws) { +DataObjects::PeaksWorkspace_sptr IntegratePeaksCWSD::createPeakworkspace( + Kernel::V3D peakCenter, const API::IMDEventWorkspace_sptr &mdws) { g_log.notice("Create peak workspace for output ... ..."); // new peak workspace DataObjects::PeaksWorkspace_sptr peakws = diff --git a/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp b/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp index 246604a2e3d65c7484f5722d56395d01483c430a..5f856905e9dc43d0996d9f6083deff0225e4c4b0 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp @@ -721,8 +721,8 @@ double IntegratePeaksMD2::detectorQ(Mantid::Kernel::V3D QLabFrame, double r) { } void IntegratePeaksMD2::runMaskDetectors( - Mantid::DataObjects::PeaksWorkspace_sptr peakWS, std::string property, - std::string values) { + const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, + const std::string &property, const std::string &values) { // For CORELLI do not count as edge if next to another detector bank if (property == "Tube" && peakWS->getInstrument()->getName() == "CORELLI") { IAlgorithm_sptr alg = createChildAlgorithm("MaskBTP"); @@ -750,7 +750,7 @@ void IntegratePeaksMD2::runMaskDetectors( } void IntegratePeaksMD2::checkOverlap( - int i, Mantid::DataObjects::PeaksWorkspace_sptr peakWS, + int i, const Mantid::DataObjects::PeaksWorkspace_sptr &peakWS, Mantid::Kernel::SpecialCoordinateSystem CoordinatesToUse, double radius) { // Get a direct ref to that peak. IPeak &p1 = peakWS->getPeak(i); diff --git a/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp b/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp index a20ee5229227a588ce2ce08361779f69f200f811..777e53bc68cd6e54dd41cc3c548e720a56d4ba3d 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksMDHKL.cpp @@ -195,7 +195,7 @@ IntegratePeaksMDHKL::normalize(int h, int k, int l, double box, int gridPts, } void IntegratePeaksMDHKL::integratePeak(const int neighborPts, - MDHistoWorkspace_sptr out, + const MDHistoWorkspace_sptr &out, double &intensity, double &errorSquared) { std::vector<int> gridPts; diff --git a/Framework/MDAlgorithms/src/InvalidParameter.cpp b/Framework/MDAlgorithms/src/InvalidParameter.cpp index 2d0bba40cef0606cff4d155bf982b7a332f1f5cd..3865fbed263b4e3d62b32f92e847f2e3272ee8af 100644 --- a/Framework/MDAlgorithms/src/InvalidParameter.cpp +++ b/Framework/MDAlgorithms/src/InvalidParameter.cpp @@ -4,13 +4,16 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidMDAlgorithms/InvalidParameter.h" namespace Mantid { namespace MDAlgorithms { InvalidParameter::InvalidParameter() {} -InvalidParameter::InvalidParameter(std::string value) : m_value(value) {} +InvalidParameter::InvalidParameter(std::string value) + : m_value(std::move(value)) {} std::string InvalidParameter::getName() const { return parameterName(); } diff --git a/Framework/MDAlgorithms/src/InvalidParameterParser.cpp b/Framework/MDAlgorithms/src/InvalidParameterParser.cpp index 56ff18f988c284c60f1bd1f88a243a95461b43de..f27ec3ef84c79591b19d48db49e1fa61cc5062de 100644 --- a/Framework/MDAlgorithms/src/InvalidParameterParser.cpp +++ b/Framework/MDAlgorithms/src/InvalidParameterParser.cpp @@ -7,6 +7,7 @@ #include "MantidMDAlgorithms/InvalidParameterParser.h" #include "MantidAPI/ImplicitFunctionParameterParserFactory.h" #include <boost/algorithm/string.hpp> +#include <utility> namespace Mantid { namespace MDAlgorithms { @@ -23,7 +24,7 @@ InvalidParameterParser::createParameter(Poco::XML::Element *parameterElement) { InvalidParameter * InvalidParameterParser::parseInvalidParameter(std::string value) { - return new InvalidParameter(value); + return new InvalidParameter(std::move(value)); } void InvalidParameterParser::setSuccessorParser( diff --git a/Framework/MDAlgorithms/src/LoadDNSSCD.cpp b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp index e58b7e14a42403de99e10c1ccde02c9af971904b..4dc8143a57dc15d0543e61a23fec1b3533cff30d 100644 --- a/Framework/MDAlgorithms/src/LoadDNSSCD.cpp +++ b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp @@ -240,7 +240,7 @@ void LoadDNSSCD::init() { /** Read Huber angles from a given table workspace. */ -void LoadDNSSCD::loadHuber(ITableWorkspace_sptr tws) { +void LoadDNSSCD::loadHuber(const ITableWorkspace_sptr &tws) { ColumnVector<double> huber = tws->getVector("Huber(degrees)"); // set huber[0] for each run in m_data for (auto &ds : m_data) { @@ -789,7 +789,7 @@ void LoadDNSSCD::fillOutputWorkspaceRaw(double wavelength) { setProperty("NormalizationWorkspace", normWS); } -void LoadDNSSCD::read_data(const std::string fname, +void LoadDNSSCD::read_data(const std::string &fname, std::map<std::string, std::string> &str_metadata, std::map<std::string, double> &num_metadata) { std::ifstream file(fname); diff --git a/Framework/MDAlgorithms/src/LoadMD.cpp b/Framework/MDAlgorithms/src/LoadMD.cpp index af997aae16cf43188d5a7e097fd9c7301fb46402..0ebd94bfad8540fcc52ebfe0fefc3ff11720c3c3 100644 --- a/Framework/MDAlgorithms/src/LoadMD.cpp +++ b/Framework/MDAlgorithms/src/LoadMD.cpp @@ -275,7 +275,8 @@ void LoadMD::exec() { * @param ws * @param dataType */ -void LoadMD::loadSlab(std::string name, void *data, MDHistoWorkspace_sptr ws, +void LoadMD::loadSlab(const std::string &name, void *data, + const MDHistoWorkspace_sptr &ws, NeXus::NXnumtype dataType) { m_file->openData(name); if (m_file->getInfo().type != dataType) @@ -634,7 +635,7 @@ void LoadMD::doLoad(typename MDEventWorkspace<MDE, nd>::sptr ws) { * appropriate coordinate transform and set those on the workspace. * @param ws : workspace to set the coordinate transforms on */ -void LoadMD::loadAffineMatricies(IMDWorkspace_sptr ws) { +void LoadMD::loadAffineMatricies(const IMDWorkspace_sptr &ws) { std::map<std::string, std::string> entries; m_file->getEntries(entries); @@ -655,7 +656,7 @@ void LoadMD::loadAffineMatricies(IMDWorkspace_sptr ws) { * @param entry_name : the entry point in the NeXus file to read * @return the coordinate transform object */ -CoordTransform *LoadMD::loadAffineMatrix(std::string entry_name) { +CoordTransform *LoadMD::loadAffineMatrix(const std::string &entry_name) { m_file->openData(entry_name); std::vector<coord_t> vec; m_file->getData<coord_t>(vec); @@ -686,7 +687,8 @@ CoordTransform *LoadMD::loadAffineMatrix(std::string entry_name) { * Set MDFrames for workspaces from legacy files * @param ws:: poitner to the workspace which needs to be corrected */ -void LoadMD::setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws) { +void LoadMD::setMDFrameOnWorkspaceFromLegacyFile( + const API::IMDWorkspace_sptr &ws) { g_log.information() << "LoadMD: Encountered a legacy file which has a mismatch between " @@ -761,7 +763,7 @@ void LoadMD::setMDFrameOnWorkspaceFromLegacyFile(API::IMDWorkspace_sptr ws) { * where * all MDFrames were stored as MDFrames */ -void LoadMD::checkForRequiredLegacyFixup(API::IMDWorkspace_sptr ws) { +void LoadMD::checkForRequiredLegacyFixup(const API::IMDWorkspace_sptr &ws) { // Check if the special coordinate is not none auto isQBasedSpecialCoordinateSystem = true; if (m_coordSystem == Mantid::Kernel::SpecialCoordinateSystem::None) { @@ -787,7 +789,7 @@ void LoadMD::checkForRequiredLegacyFixup(API::IMDWorkspace_sptr ws) { /** * Find scaling for Q dimensions */ -std::vector<double> LoadMD::qDimensions(API::IMDWorkspace_sptr ws) { +std::vector<double> LoadMD::qDimensions(const API::IMDWorkspace_sptr &ws) { std::vector<double> scaling(m_numDims); for (size_t d = 0; d < m_numDims; d++) { std::string dimd = ws->getDimension(d)->getName(); diff --git a/Framework/MDAlgorithms/src/LoadSQW2.cpp b/Framework/MDAlgorithms/src/LoadSQW2.cpp index a4ca1f4aec93326ace3c6af432809ca98f67ebea..df4856bb6c8183e3129f893cac554baa89e02ee0 100644 --- a/Framework/MDAlgorithms/src/LoadSQW2.cpp +++ b/Framework/MDAlgorithms/src/LoadSQW2.cpp @@ -595,7 +595,7 @@ void LoadSQW2::setupBoxController() { * box controller has already been initialized * @param filebackPath Path to the file used for backend storage */ -void LoadSQW2::setupFileBackend(std::string filebackPath) { +void LoadSQW2::setupFileBackend(const std::string &filebackPath) { using DataObjects::BoxControllerNeXusIO; auto savemd = this->createChildAlgorithm("SaveMD", 0.01, 0.05, true); savemd->setProperty("InputWorkspace", m_outputWS); diff --git a/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp b/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp index d81d9a73226a7c797e38d55c75bcb6f22bf46d18..0df5201068fc3f2547d3de872b1d8f28c34f8cea 100644 --- a/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp +++ b/Framework/MDAlgorithms/src/MDEventWSWrapper.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidMDAlgorithms/MDEventWSWrapper.h" +#include <utility> + #include "MantidGeometry/MDGeometry/MDTypes.h" +#include "MantidMDAlgorithms/MDEventWSWrapper.h" namespace Mantid { namespace MDAlgorithms { @@ -202,7 +204,7 @@ MDEventWSWrapper::createEmptyMDWS(const MDWSDescription &WSD) { /// set up existing workspace pointer as internal pointer for the class to /// perform proper MD operations on this workspace void MDEventWSWrapper::setMDWS(API::IMDEventWorkspace_sptr spWS) { - m_Workspace = spWS; + m_Workspace = std::move(spWS); m_NDimensions = m_Workspace->getNumDims(); } diff --git a/Framework/MDAlgorithms/src/MDNorm.cpp b/Framework/MDAlgorithms/src/MDNorm.cpp index 544fa1e7bcabf77d78e6d4053622dcd45a2a712e..e2ba944696455f95a4c84eb72699e1bfc5d92d0c 100644 --- a/Framework/MDAlgorithms/src/MDNorm.cpp +++ b/Framework/MDAlgorithms/src/MDNorm.cpp @@ -746,7 +746,7 @@ void MDNorm::createNormalizationWS( */ void MDNorm::validateBinningForTemporaryDataWorkspace( const std::map<std::string, std::string> ¶meters, - const Mantid::API::IMDHistoWorkspace_sptr tempDataWS) { + const Mantid::API::IMDHistoWorkspace_sptr &tempDataWS) { // parse the paramters map and get extents from tempDataWS const std::string numBinsStr = parameters.at("OutputBins"); @@ -921,8 +921,8 @@ void MDNorm::validateBinningForTemporaryDataWorkspace( * All slicing algorithm properties are passed along * @return MDHistoWorkspace as a result of the binning */ -DataObjects::MDHistoWorkspace_sptr -MDNorm::binInputWS(std::vector<Geometry::SymmetryOperation> symmetryOps) { +DataObjects::MDHistoWorkspace_sptr MDNorm::binInputWS( + const std::vector<Geometry::SymmetryOperation> &symmetryOps) { Mantid::API::IMDHistoWorkspace_sptr tempDataWS = this->getProperty("TemporaryDataWorkspace"); Mantid::API::Workspace_sptr outputWS; @@ -1142,7 +1142,7 @@ void MDNorm::cacheDimensionXValues() { * @param soIndex - the index of symmetry operation (for progress purposes) */ void MDNorm::calculateNormalization(const std::vector<coord_t> &otherValues, - Geometry::SymmetryOperation so, + const Geometry::SymmetryOperation &so, uint16_t expInfoIndex, size_t soIndex) { const auto ¤tExptInfo = *(m_inputWS->getExperimentInfo(expInfoIndex)); std::vector<double> lowValues, highValues; @@ -1330,7 +1330,7 @@ m_accumulate = true; */ void MDNorm::calculateIntersections( std::vector<std::array<double, 4>> &intersections, const double theta, - const double phi, Kernel::DblMatrix transform, double lowvalue, + const double phi, const Kernel::DblMatrix &transform, double lowvalue, double highvalue) { V3D qout(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)), qin(0., 0., 1); diff --git a/Framework/MDAlgorithms/src/MDTransfNoQ.cpp b/Framework/MDAlgorithms/src/MDTransfNoQ.cpp index e0aad525d45d3686604a7cab838668c9afbf3968..146d8188cbc1ab39a473259bff72114f90f1491b 100644 --- a/Framework/MDAlgorithms/src/MDTransfNoQ.cpp +++ b/Framework/MDAlgorithms/src/MDTransfNoQ.cpp @@ -119,7 +119,7 @@ MDTransfNoQ::getNMatrixDimensions(Kernel::DeltaEMode::Type mode, } // internal helper function which extract one or two axis from input matrix // workspace; -void MDTransfNoQ::getAxes(API::MatrixWorkspace_const_sptr inWS, +void MDTransfNoQ::getAxes(const API::MatrixWorkspace_const_sptr &inWS, API::NumericAxis *&pXAxis, API::NumericAxis *&pYAxis) { // get the X axis of input workspace, it has to be there; if not axis throws diff --git a/Framework/MDAlgorithms/src/MDWSDescription.cpp b/Framework/MDAlgorithms/src/MDWSDescription.cpp index 3560edc8cde8c9f0277fa1b65fcc1f9d9ae50450..aecd160aff605199cdce500ebb3ca9b46d49a6cb 100644 --- a/Framework/MDAlgorithms/src/MDWSDescription.cpp +++ b/Framework/MDAlgorithms/src/MDWSDescription.cpp @@ -20,6 +20,7 @@ #include "MantidMDAlgorithms/MDTransfFactory.h" #include <boost/lexical_cast.hpp> +#include <utility> namespace Mantid { namespace MDAlgorithms { @@ -67,7 +68,7 @@ which will be used as dimensions. */ void MDWSDescription::buildFromMatrixWS( const API::MatrixWorkspace_sptr &pWS, const std::string &QMode, - const std::string dEMode, + const std::string &dEMode, const std::vector<std::string> &dimPropertyNames) { m_InWS = pWS; // fill additional dimensions values, defined by workspace properties; @@ -125,7 +126,7 @@ void MDWSDescription::buildFromMatrixWS( } void MDWSDescription::setWS(API::MatrixWorkspace_sptr otherMatrixWS) { - m_InWS = otherMatrixWS; + m_InWS = std::move(otherMatrixWS); } /// Method checks if input workspace has defined goniometer bool MDWSDescription::hasGoniometer() const { @@ -349,7 +350,7 @@ std::string MDWSDescription::getEModeStr() const { *properties) for current multidimensional event */ void MDWSDescription::fillAddProperties( - Mantid::API::MatrixWorkspace_const_sptr inWS2D, + const Mantid::API::MatrixWorkspace_const_sptr &inWS2D, const std::vector<std::string> &dimPropertyNames, std::vector<coord_t> &AddCoord) { size_t nDimPropNames = dimPropertyNames.size(); @@ -400,7 +401,7 @@ void MDWSDescription::checkMinMaxNdimConsistent( /** function retrieves copy of the oriented lattice from the workspace */ boost::shared_ptr<Geometry::OrientedLattice> MDWSDescription::getOrientedLattice( - Mantid::API::MatrixWorkspace_const_sptr inWS2D) { + const Mantid::API::MatrixWorkspace_const_sptr &inWS2D) { // try to get the WS oriented lattice boost::shared_ptr<Geometry::OrientedLattice> orl; if (inWS2D->sample().hasOrientedLattice()) @@ -432,7 +433,7 @@ Geometry::MDFrame_uptr MDWSDescription::getFrame(size_t d) const { * Sets the frame. * @param frameKey : Frame key desired. */ -void MDWSDescription::setFrame(const std::string frameKey) { +void MDWSDescription::setFrame(const std::string &frameKey) { m_frameKey = frameKey; } diff --git a/Framework/MDAlgorithms/src/MaskMD.cpp b/Framework/MDAlgorithms/src/MaskMD.cpp index ad6b749a7075b59eda17ea7fc5f56e810241d0be..7dd1249f4dcee998233373b53e6040d9507a8ada 100644 --- a/Framework/MDAlgorithms/src/MaskMD.cpp +++ b/Framework/MDAlgorithms/src/MaskMD.cpp @@ -116,7 +116,7 @@ workspace. @throws runtime_error if the requested dimension is unknown either by id, or by name in the workspace. */ -size_t tryFetchDimensionIndex(Mantid::API::IMDWorkspace_sptr ws, +size_t tryFetchDimensionIndex(const Mantid::API::IMDWorkspace_sptr &ws, const std::string &candidateNameOrId) { size_t dimWorkspaceIndex; try { diff --git a/Framework/MDAlgorithms/src/MergeMDFiles.cpp b/Framework/MDAlgorithms/src/MergeMDFiles.cpp index 6c3720a0fa8728c3157062447f13702ced5cdce1..74c9a3836f7994d2cf37439275d6603971317acd 100644 --- a/Framework/MDAlgorithms/src/MergeMDFiles.cpp +++ b/Framework/MDAlgorithms/src/MergeMDFiles.cpp @@ -197,8 +197,9 @@ uint64_t MergeMDFiles::loadEventsFromSubBoxes(API::IMDNode *TargetBox) { * @param outputFile :: the name of the output file where file-based workspace *should be saved */ -void MergeMDFiles::doExecByCloning(Mantid::API::IMDEventWorkspace_sptr ws, - const std::string &outputFile) { +void MergeMDFiles::doExecByCloning( + const Mantid::API::IMDEventWorkspace_sptr &ws, + const std::string &outputFile) { m_OutIWS = ws; m_MDEventType = ws->getEventTypeName(); diff --git a/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp b/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp index ee4152a6e705442e69827f3be80a2e036ef7bea7..e8d6dc38f3b9d68ecf3d3eff61860130977fc7aa 100644 --- a/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp +++ b/Framework/MDAlgorithms/src/PreprocessDetectorsToMD.cpp @@ -399,7 +399,7 @@ void PreprocessDetectorsToMD::buildFakeDetectorsPositions( /// function checks if source workspace still has information about detectors. /// Some ws (like rebinned one) do not have this information any more. bool PreprocessDetectorsToMD::isDetInfoLost( - Mantid::API::MatrixWorkspace_const_sptr inWS2D) const { + const Mantid::API::MatrixWorkspace_const_sptr &inWS2D) const { auto pYAxis = dynamic_cast<API::NumericAxis *>(inWS2D->getAxis(1)); // if this is numeric axis, then the detector's information has been lost: return pYAxis != nullptr; diff --git a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp index 761bcdc86dbfde88a6809795bb7b3543240b83eb..a4a5fb82ab42e821964b280690ce77f0445bb029 100644 --- a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp +++ b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp @@ -194,7 +194,7 @@ void SaveIsawQvector::exec() { * * @param wksp The workspace to get information from. */ -void SaveIsawQvector::initTargetWSDescr(EventWorkspace_sptr wksp) { +void SaveIsawQvector::initTargetWSDescr(const EventWorkspace_sptr &wksp) { m_targWSDescr.setMinMax(std::vector<double>(3, -2000.), std::vector<double>(3, 2000.)); m_targWSDescr.buildFromMatrixWS(wksp, Q3D, ELASTIC); diff --git a/Framework/MDAlgorithms/src/SaveMD.cpp b/Framework/MDAlgorithms/src/SaveMD.cpp index 31253526ebee14b5d550d938c98511b0ad102d43..8f9fd29e434b3aa011b508ad4c33f7ed974d128c 100644 --- a/Framework/MDAlgorithms/src/SaveMD.cpp +++ b/Framework/MDAlgorithms/src/SaveMD.cpp @@ -33,7 +33,7 @@ namespace { template <typename MDE, size_t nd> void prepareUpdate(MDBoxFlatTree &BoxFlatStruct, BoxController *bc, typename MDEventWorkspace<MDE, nd>::sptr ws, - std::string filename) { + const std::string &filename) { // remove all boxes from the DiskBuffer. DB will calculate boxes positions // on HDD. bc->getFileIO()->flushCache(); @@ -236,7 +236,7 @@ void SaveMD::doSaveEvents(typename MDEventWorkspace<MDE, nd>::sptr ws) { * * @param ws :: MDHistoWorkspace to save */ -void SaveMD::doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws) { +void SaveMD::doSaveHisto(const Mantid::DataObjects::MDHistoWorkspace_sptr &ws) { std::string filename = getPropertyValue("Filename"); // Erase the file if it exists diff --git a/Framework/MDAlgorithms/src/SaveMD2.cpp b/Framework/MDAlgorithms/src/SaveMD2.cpp index 548baf4c74a76985012876bdd7a1be78ca8c2c7d..1bafc3309dd899b8ea6688ebeba50b639568d4d0 100644 --- a/Framework/MDAlgorithms/src/SaveMD2.cpp +++ b/Framework/MDAlgorithms/src/SaveMD2.cpp @@ -88,7 +88,8 @@ void SaveMD2::init() { * * @param ws :: MDHistoWorkspace to save */ -void SaveMD2::doSaveHisto(Mantid::DataObjects::MDHistoWorkspace_sptr ws) { +void SaveMD2::doSaveHisto( + const Mantid::DataObjects::MDHistoWorkspace_sptr &ws) { std::string filename = getPropertyValue("Filename"); // Erase the file if it exists diff --git a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp index 954651bc8efff869dcff8a7430415853976c7642..d8b8a17c5b6b876dae4b2734be177b210104ac89 100644 --- a/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp +++ b/Framework/MDAlgorithms/src/SlicingAlgorithm.cpp @@ -19,6 +19,7 @@ #include "MantidKernel/VisibleWhenProperty.h" #include <boost/regex.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -903,7 +904,7 @@ SlicingAlgorithm::getImplicitFunctionForChunk(const size_t *const chunkMin, * @returns the unique pointer */ Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::createMDFrameForNonAxisAligned( - std::string units, Mantid::Kernel::VMD basisVector) const { + const std::string &units, const Mantid::Kernel::VMD &basisVector) const { // Get set of basis vectors auto oldBasis = getOldBasis(m_inWS->getNumDims()); @@ -911,7 +912,8 @@ Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::createMDFrameForNonAxisAligned( auto indicesWithProjection = getIndicesWithProjection(basisVector, oldBasis); // Extract MDFrame - return extractMDFrameForNonAxisAligned(indicesWithProjection, units); + return extractMDFrameForNonAxisAligned(indicesWithProjection, + std::move(units)); } std::vector<Mantid::Kernel::VMD> @@ -964,7 +966,7 @@ std::vector<size_t> SlicingAlgorithm::getIndicesWithProjection( */ Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::extractMDFrameForNonAxisAligned( - std::vector<size_t> indicesWithProjection, std::string units) const { + std::vector<size_t> indicesWithProjection, const std::string &units) const { if (indicesWithProjection.empty()) { g_log.warning() << "Slicing Algorithm: Chosen vector does not " "project on any vector of the old basis."; diff --git a/Framework/MDAlgorithms/src/SmoothMD.cpp b/Framework/MDAlgorithms/src/SmoothMD.cpp index 30b8e145c1681b2fb685852ec2522a0015605fbb..e7409a0de4cf588389c63592844925a61dd64c4f 100644 --- a/Framework/MDAlgorithms/src/SmoothMD.cpp +++ b/Framework/MDAlgorithms/src/SmoothMD.cpp @@ -175,7 +175,7 @@ const std::string SmoothMD::summary() const { * @return Smoothed MDHistoWorkspace */ IMDHistoWorkspace_sptr -SmoothMD::hatSmooth(IMDHistoWorkspace_const_sptr toSmooth, +SmoothMD::hatSmooth(const IMDHistoWorkspace_const_sptr &toSmooth, const WidthVector &widthVector, OptionalIMDHistoWorkspace_const_sptr weightingWS) { @@ -278,7 +278,7 @@ SmoothMD::hatSmooth(IMDHistoWorkspace_const_sptr toSmooth, * @return Smoothed MDHistoWorkspace */ IMDHistoWorkspace_sptr -SmoothMD::gaussianSmooth(IMDHistoWorkspace_const_sptr toSmooth, +SmoothMD::gaussianSmooth(const IMDHistoWorkspace_const_sptr &toSmooth, const WidthVector &widthVector, OptionalIMDHistoWorkspace_const_sptr weightingWS) { diff --git a/Framework/MDAlgorithms/test/BinMDTest.h b/Framework/MDAlgorithms/test/BinMDTest.h index d795e966a524dbabf6d5ecc05d14c5cdf7dc008b..4cf15306a9217b3ca62227049d7d9ab7372cfb5a 100644 --- a/Framework/MDAlgorithms/test/BinMDTest.h +++ b/Framework/MDAlgorithms/test/BinMDTest.h @@ -26,6 +26,7 @@ #include "MantidTestHelpers/MDEventsTestHelper.h" #include <cmath> +#include <utility> #include <cxxtest/TestSuite.h> @@ -132,8 +133,9 @@ public: AnalysisDataService::Instance().addOrReplace("BinMDTest_ws", in_ws); execute_bin(functionXML, name1, name2, name3, name4, expected_signal, - expected_numBins, IterateEvents, numEventsPerBox, expectBasisX, - expectBasisY, expectBasisZ, in_ws); + expected_numBins, IterateEvents, numEventsPerBox, + std::move(expectBasisX), std::move(expectBasisY), + std::move(expectBasisZ), in_ws); } MDHistoWorkspace_sptr @@ -142,7 +144,7 @@ public: const std::string &name4, const double expected_signal, const size_t expected_numBins, bool IterateEvents, size_t numEventsPerBox, VMD expectBasisX, VMD expectBasisY, - VMD expectBasisZ, IMDEventWorkspace_sptr in_ws) { + VMD expectBasisZ, const IMDEventWorkspace_sptr &in_ws) { BinMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) @@ -584,9 +586,9 @@ public: * @param origWS :: both should have this as its originalWorkspace * @return binned2 shared pointer */ - MDHistoWorkspace_sptr do_compare_histo(std::string binned1Name, - std::string binned2Name, - std::string origWS) { + MDHistoWorkspace_sptr do_compare_histo(const std::string &binned1Name, + const std::string &binned2Name, + const std::string &origWS) { MDHistoWorkspace_sptr binned1 = AnalysisDataService::Instance().retrieveWS<MDHistoWorkspace>( binned1Name); @@ -1078,7 +1080,7 @@ public: return outWSName; } - std::string saveWorkspace(IMDEventWorkspace_sptr in_ws) { + std::string saveWorkspace(const IMDEventWorkspace_sptr &in_ws) { SaveMD2 saver; saver.setChild(true); saver.setRethrows(true); @@ -1128,7 +1130,7 @@ public: AnalysisDataService::Instance().remove("BinMDTest_ws"); } - void do_test(std::string binParams, bool IterateEvents) { + void do_test(const std::string &binParams, bool IterateEvents) { BinMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/BinaryOperationMDTest.h b/Framework/MDAlgorithms/test/BinaryOperationMDTest.h index d0a832cc4aca55694d924f85ec0028dc47ce667d..8b21a38ab82953901622057481deb8bec75cd720 100644 --- a/Framework/MDAlgorithms/test/BinaryOperationMDTest.h +++ b/Framework/MDAlgorithms/test/BinaryOperationMDTest.h @@ -95,8 +95,9 @@ public: } /// Run the mock algorithm - void doTest(MockBinaryOperationMD &alg, std::string lhs, std::string rhs, - std::string outName, bool succeeds = true) { + void doTest(MockBinaryOperationMD &alg, const std::string &lhs, + const std::string &rhs, const std::string &outName, + bool succeeds = true) { out.reset(); TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h b/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h index 65e5c12ddc73bf052ee09fda4a9b1d9b6d904257..135c89af5537ffb88f9ff5121a82123670c944f1 100644 --- a/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h +++ b/Framework/MDAlgorithms/test/BoxControllerSettingsAlgorithmTest.h @@ -14,6 +14,7 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <boost/format.hpp> +#include <utility> #include <cxxtest/TestSuite.h> @@ -47,8 +48,9 @@ private: Helper function. Runs LoadParameterAlg, to get an instrument parameter definition from a file onto a workspace. */ - void apply_instrument_parameter_file_to_workspace(MatrixWorkspace_sptr ws, - const ScopedFile &file) { + void + apply_instrument_parameter_file_to_workspace(const MatrixWorkspace_sptr &ws, + const ScopedFile &file) { // Load the Instrument Parameter file over the existing test workspace + // instrument. using DataHandling::LoadParameterFile; @@ -119,9 +121,9 @@ public: TS_ASSERT_EQUALS(bc->getMaxDepth(), 34); } - void doTest(BoxController_sptr bc, std::string SplitInto = "", - std::string SplitThreshold = "", - std::string MaxRecursionDepth = "") { + void doTest(const BoxController_sptr &bc, const std::string &SplitInto = "", + const std::string &SplitThreshold = "", + const std::string &MaxRecursionDepth = "") { BoxControllerSettingsAlgorithmImpl alg; alg.initBoxControllerProps(); if (!SplitInto.empty()) @@ -130,7 +132,7 @@ public: alg.setPropertyValue("SplitThreshold", SplitThreshold); if (!MaxRecursionDepth.empty()) alg.setPropertyValue("MaxRecursionDepth", MaxRecursionDepth); - alg.setBoxController(bc); + alg.setBoxController(std::move(bc)); } void test_SplitInto() { diff --git a/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h b/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h index f669d3671db91fbb193f43ffce77407efc23fd83..843b77ece157848917fbf4f6cc3311c216b3cd31 100644 --- a/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h +++ b/Framework/MDAlgorithms/test/CentroidPeaksMD2Test.h @@ -43,7 +43,7 @@ public: //------------------------------------------------------------------------------- /** Create the (blank) MDEW */ - static void createMDEW(std::string CoordinatesToUse) { + static void createMDEW(const std::string &CoordinatesToUse) { // ---- Start with empty MDEW ---- std::string frames; if (CoordinatesToUse == "Q (lab frame)") { @@ -98,9 +98,10 @@ public: //------------------------------------------------------------------------------- /** Run the CentroidPeaksMD2 with the given peak radius param */ - void doRun(V3D startPos, double PeakRadius, double binCount, - V3D expectedResult, std::string message, - std::string OutputWorkspace = "CentroidPeaksMD2Test_Peaks") { + void + doRun(V3D startPos, double PeakRadius, double binCount, V3D expectedResult, + const std::string &message, + const std::string &OutputWorkspace = "CentroidPeaksMD2Test_Peaks") { // Make a fake instrument - doesn't matter, we won't use it really Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(5); diff --git a/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h b/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h index 2791e5e7351c0bd894c49e9756b7bec8116421a4..2694382ce73feeee3cbd088e3240e8bc265bcce9 100644 --- a/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h +++ b/Framework/MDAlgorithms/test/CentroidPeaksMDTest.h @@ -43,7 +43,7 @@ public: //------------------------------------------------------------------------------- /** Create the (blank) MDEW */ - static void createMDEW(std::string CoordinatesToUse) { + static void createMDEW(const std::string &CoordinatesToUse) { // ---- Start with empty MDEW ---- std::string frames; if (CoordinatesToUse == "Q (lab frame)") { @@ -100,8 +100,8 @@ public: //------------------------------------------------------------------------------- /** Run the CentroidPeaksMD with the given peak radius param */ void doRun(V3D startPos, double PeakRadius, V3D expectedResult, - std::string message, - std::string OutputWorkspace = "CentroidPeaksMDTest_Peaks") { + const std::string &message, + const std::string &OutputWorkspace = "CentroidPeaksMDTest_Peaks") { // Make a fake instrument - doesn't matter, we won't use it really Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(5); diff --git a/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h b/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h index 5fc2b64ec2cd48cecbaac889fc346dd490348fbe..3c5cc4d73d683ea7794f9e9e6eb3e4f94f329fcb 100644 --- a/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/CloneMDWorkspaceTest.h @@ -45,7 +45,7 @@ public: do_test(true, "CloneMDWorkspaceTest_ws_custom_cloned_name2.nxs", true); } - void do_test(bool fileBacked, std::string Filename = "", + void do_test(bool fileBacked, const std::string &Filename = "", bool file_needs_updating = false) { // Name of the output workspace. std::string outWSName("CloneMDWorkspaceTest_OutputWS"); @@ -117,7 +117,7 @@ public: } /** Clone a workspace and check that the clone matches */ - void do_test_MDHisto(MDHistoWorkspace_sptr ws1) { + void do_test_MDHisto(const MDHistoWorkspace_sptr &ws1) { // Name of the output workspace. std::string outWSName("CloneMDWorkspaceTest_OutputWS"); // Add the input workspace diff --git a/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h b/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h index 09d48d0b74d6ed0529b6aa2e647694ca564f9e5b..a876e49842b42e483de1b14a84c2b78f83bcdb2a 100644 --- a/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h +++ b/Framework/MDAlgorithms/test/CompareMDWorkspacesTest.h @@ -31,9 +31,9 @@ public: TS_ASSERT(alg.isInitialized()) } - void doTest(std::string ws1, std::string ws2, - std::string resultExpected = "Success!", bool CheckEvents = true, - bool IgnoreDifferentID = false) { + void doTest(const std::string &ws1, const std::string &ws2, + const std::string &resultExpected = "Success!", + bool CheckEvents = true, bool IgnoreDifferentID = false) { CompareMDWorkspaces alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) diff --git a/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h b/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h index 89cb7617a90efbb58e7ee19a3871ff5ec60aaeb1..e6bb76af1e6cea369664ecaa0448f070970afa35 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDComponentsTest.h @@ -18,6 +18,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; @@ -26,23 +28,22 @@ using namespace Mantid::MDAlgorithms; class Convert2MDComponentsTestHelper : public ConvertToMD { public: - TableWorkspace_const_sptr - preprocessDetectorsPositions(Mantid::API::MatrixWorkspace_const_sptr InWS2D, - const std::string dEModeRequested = "Direct", - bool updateMasks = true) { + TableWorkspace_const_sptr preprocessDetectorsPositions( + const Mantid::API::MatrixWorkspace_const_sptr &InWS2D, + const std::string &dEModeRequested = "Direct", bool updateMasks = true) { std::string OutWSName(this->getProperty("PreprocDetectorsWS")); return ConvertToMD::preprocessDetectorsPositions(InWS2D, dEModeRequested, updateMasks, OutWSName); } void setSourceWS(Mantid::API::MatrixWorkspace_sptr InWS2D) { - this->m_InWS2D = InWS2D; + this->m_InWS2D = std::move(InWS2D); // and create the class, which will deal with the target workspace if (!this->m_OutWSWrapper) this->m_OutWSWrapper = boost::shared_ptr<MDAlgorithms::MDEventWSWrapper>( new MDAlgorithms::MDEventWSWrapper()); } Convert2MDComponentsTestHelper() { ConvertToMD::initialize(); } - bool buildTargetWSDescription(API::IMDEventWorkspace_sptr spws, + bool buildTargetWSDescription(const API::IMDEventWorkspace_sptr &spws, const std::string &Q_mod_req, const std::string &dEModeRequested, const std::vector<std::string> &other_dim_names, @@ -52,8 +53,8 @@ public: std::vector<double> dimMin = this->getProperty("MinValues"); std::vector<double> dimMax = this->getProperty("MaxValues"); return ConvertToMD::buildTargetWSDescription( - spws, Q_mod_req, dEModeRequested, other_dim_names, dimMin, dimMax, - QFrame, convert_to_, targWSDescr); + std::move(spws), Q_mod_req, dEModeRequested, other_dim_names, dimMin, + dimMax, QFrame, convert_to_, targWSDescr); } void copyMetaData(API::IMDEventWorkspace_sptr mdEventWS) const { ConvertToMD::copyMetaData(mdEventWS); diff --git a/Framework/MDAlgorithms/test/ConvertToMDTest.h b/Framework/MDAlgorithms/test/ConvertToMDTest.h index 9847608765c4e45c6b042037d5f8cda30acb7291..014f131a4cc5fd6fa54546a819dc1804491de1d8 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDTest.h @@ -19,6 +19,8 @@ #include <Poco/File.h> #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; @@ -57,16 +59,15 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspaces() { class Convert2AnyTestHelper : public ConvertToMD { public: Convert2AnyTestHelper(){}; - TableWorkspace_const_sptr - preprocessDetectorsPositions(Mantid::API::MatrixWorkspace_const_sptr InWS2D, - const std::string dEModeRequested = "Direct", - bool updateMasks = false) { + TableWorkspace_const_sptr preprocessDetectorsPositions( + const Mantid::API::MatrixWorkspace_const_sptr &InWS2D, + const std::string &dEModeRequested = "Direct", bool updateMasks = false) { return ConvertToMD::preprocessDetectorsPositions( InWS2D, dEModeRequested, updateMasks, std::string(this->getProperty("PreprocDetectorsWS"))); } void setSourceWS(Mantid::API::MatrixWorkspace_sptr InWS2D) { - m_InWS2D = InWS2D; + m_InWS2D = std::move(InWS2D); } }; // helper function to provide list of names to test: diff --git a/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h b/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h index 9bbadd84470a48f56c6121b82b7f402d82799a58..2446c16225689947d1bcd4bea14850c8af458ca2 100644 --- a/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h +++ b/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h @@ -59,7 +59,7 @@ public: /** Calculate min-max value defaults*/ Mantid::API::IAlgorithm * calcMinMaxValDefaults(const std::string &QMode, const std::string &QFrame, - std::string OtherProperties = std::string("")) { + const std::string &OtherProperties = std::string("")) { Mantid::API::IAlgorithm *childAlg = Mantid::API::FrameworkManager::Instance().createAlgorithm( diff --git a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h index f704953755f7320e3632f9a0af24344b751d72e1..04378718a13a55837fa7b67064f222fe91814970 100644 --- a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h +++ b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h @@ -42,7 +42,7 @@ private: Makes the tests much more readable like this. */ boost::shared_ptr<ConvertToReflectometryQ> - make_standard_algorithm(const std::string outputdimensions = "Q (lab frame)", + make_standard_algorithm(const std::string &outputdimensions = "Q (lab frame)", bool outputAsMD = true) { MatrixWorkspace_sptr in_ws = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(10, 10); diff --git a/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h b/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h index 11af60f6a5efc48a48b2c113cbbf387fff0f7311..64d9c0c8d866ee3370ffc165cfa80b60b847b930 100644 --- a/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/CreateMDWorkspaceTest.h @@ -91,8 +91,9 @@ public: ->isExecuted()); } - void do_test_exec(std::string Filename, bool lean, int MinRecursionDepth = 0, - int expectedNumMDBoxes = 216, bool withFrames = false) { + void do_test_exec(const std::string &Filename, bool lean, + int MinRecursionDepth = 0, int expectedNumMDBoxes = 216, + bool withFrames = false) { std::string wsName = "CreateMDWorkspaceTest_out"; CreateMDWorkspace alg; diff --git a/Framework/MDAlgorithms/test/CutMDTest.h b/Framework/MDAlgorithms/test/CutMDTest.h index 54c878295c63d97509206471b1255b9ad2ff4c75..cc8cef0d150d7acde449114000a7052bb11cfd8f 100644 --- a/Framework/MDAlgorithms/test/CutMDTest.h +++ b/Framework/MDAlgorithms/test/CutMDTest.h @@ -42,7 +42,7 @@ class CutMDTest : public CxxTest::TestSuite { private: IMDWorkspace_sptr m_inWS; - void addNormalization(std::string wsName) { + void addNormalization(const std::string &wsName) { auto ws = AnalysisDataService::Instance().retrieveWS<IMDWorkspace>(wsName); auto eventWS = boost::dynamic_pointer_cast<IMDEventWorkspace>(ws); auto histoWS = boost::dynamic_pointer_cast<IMDHistoWorkspace>(ws); diff --git a/Framework/MDAlgorithms/test/DivideMDTest.h b/Framework/MDAlgorithms/test/DivideMDTest.h index eb32ec58885242fe4b23c6e416d0676d3d7ab0be..cb039a85f717c58cde13784949f654aed8226d31 100644 --- a/Framework/MDAlgorithms/test/DivideMDTest.h +++ b/Framework/MDAlgorithms/test/DivideMDTest.h @@ -62,7 +62,7 @@ public: /** Get a MDEventWorkspace and check that all events have the given * signal/error */ - void checkMDEWSignal(std::string wsName, signal_t expectedSignal, + void checkMDEWSignal(const std::string &wsName, signal_t expectedSignal, signal_t expectedError) { IMDEventWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>(wsName); diff --git a/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h b/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h index 1d2cc0a197b16126ae555de8f2fbf15627814e76..1020c1488915f77da0f5a7157397b99aecc1b776 100644 --- a/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h +++ b/Framework/MDAlgorithms/test/FlippingRatioCorrectionMDTest.h @@ -85,7 +85,7 @@ public: } private: - void checkFRCorrection(std::string wsName, double expectedValuePeak1, + void checkFRCorrection(const std::string &wsName, double expectedValuePeak1, double expectedValuePeak2) { Mantid::MDAlgorithms::BinMD algBin; TS_ASSERT_THROWS_NOTHING(algBin.initialize()) diff --git a/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h b/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h index 84212d4c10267c7b0cf073f00225acf71c3f0b07..92dc688f9a2144a62b6416d7afbc39ae48d3efba 100644 --- a/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/ImportMDEventWorkspaceTest.h @@ -72,7 +72,7 @@ public: /// Create a simple input file. MDFileObject( const FileContentsBuilder &builder = FileContentsBuilder(), - std::string filename = "test_import_md_event_workspace_file.txt") { + const std::string &filename = "test_import_md_event_workspace_file.txt") { Poco::Path path( Mantid::Kernel::ConfigService::Instance().getTempDir().c_str()); path.append(filename); diff --git a/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h b/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h index 50c8c3d8f3b6c55817648c1c13e19edb2e87b3d9..0636526f31d700097cfc030ad41055b42f6dcf4b 100644 --- a/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/IntegrateMDHistoWorkspaceTest.h @@ -18,7 +18,7 @@ namespace { // This helper sets the signal values to the linear index to have some // variety -void resetSignalsToLinearIndexValue(IMDHistoWorkspace_sptr ws) { +void resetSignalsToLinearIndexValue(const IMDHistoWorkspace_sptr &ws) { auto numberOfIndices = static_cast<size_t>(ws->getNPoints()); for (size_t i = 0; i < numberOfIndices; ++i) { auto &signal = ws->signalAt(i); diff --git a/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h b/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h index 3ef787860f1604407c3d4c7e6a24ae4709836dbb..790cb2067be1afe6e1192e68857436b8f2aacb92 100644 --- a/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h +++ b/Framework/MDAlgorithms/test/IntegratePeaksMD2Test.h @@ -51,11 +51,11 @@ public: //------------------------------------------------------------------------------- /** Run the IntegratePeaksMD2 with the given peak radius integration param */ - static void doRun(double PeakRadius, double BackgroundRadius, - std::string OutputWorkspace = "IntegratePeaksMD2Test_peaks", - double BackgroundStartRadius = 0.0, bool edge = true, - bool cyl = false, std::string fnct = "NoFit", - double adaptive = 0.0) { + static void + doRun(double PeakRadius, double BackgroundRadius, + const std::string &OutputWorkspace = "IntegratePeaksMD2Test_peaks", + double BackgroundStartRadius = 0.0, bool edge = true, bool cyl = false, + const std::string &fnct = "NoFit", double adaptive = 0.0) { IntegratePeaksMD2 alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h b/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h index 43630aa372dd536bc01dbc53a0ba040581237662..23327899699fd2364dd4cdb0086a1105d1abea83 100644 --- a/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h +++ b/Framework/MDAlgorithms/test/IntegratePeaksMDHKLTest.h @@ -55,7 +55,7 @@ public: /** Run the IntegratePeaksMDHKL with the given peak radius integration param */ static void - doRun(std::string OutputWorkspace = "IntegratePeaksMDHKLTest_peaks") { + doRun(const std::string &OutputWorkspace = "IntegratePeaksMDHKLTest_peaks") { IntegratePeaksMDHKL alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h b/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h index 857f85c65a2c76fdc3ec80a7b7bf1d1626d752f2..167d9e8ab1e52d5bbf14ed881b38b980bcac2684 100644 --- a/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h +++ b/Framework/MDAlgorithms/test/IntegratePeaksMDTest.h @@ -48,10 +48,11 @@ public: //------------------------------------------------------------------------------- /** Run the IntegratePeaksMD with the given peak radius integration param */ - static void doRun(double PeakRadius, double BackgroundRadius, - std::string OutputWorkspace = "IntegratePeaksMDTest_peaks", - double BackgroundStartRadius = 0.0, bool edge = true, - bool cyl = false, std::string fnct = "NoFit") { + static void + doRun(double PeakRadius, double BackgroundRadius, + const std::string &OutputWorkspace = "IntegratePeaksMDTest_peaks", + double BackgroundStartRadius = 0.0, bool edge = true, bool cyl = false, + const std::string &fnct = "NoFit") { IntegratePeaksMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/LoadMDTest.h b/Framework/MDAlgorithms/test/LoadMDTest.h index bab2255eb4062e79ff4bcaf369294c1116e366a0..6a83c2b735fdc330faf1f1b3a1eaa6bf0aa6bdad 100644 --- a/Framework/MDAlgorithms/test/LoadMDTest.h +++ b/Framework/MDAlgorithms/test/LoadMDTest.h @@ -488,7 +488,7 @@ public: } /** Run SaveMD v1 with the MDHistoWorkspace */ - void doTestHistoV1(MDHistoWorkspace_sptr ws) { + void doTestHistoV1(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMDTestHisto.nxs"; SaveMD alg1; @@ -531,7 +531,7 @@ public: } /** Run SaveMD2 with the MDHistoWorkspace */ - void doTestHisto(MDHistoWorkspace_sptr ws) { + void doTestHisto(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMD2TestHisto.nxs"; SaveMD2 alg1; @@ -682,7 +682,7 @@ public: } Mantid::API::IMDWorkspace_sptr - testSaveAndLoadWorkspace(Mantid::API::IMDWorkspace_sptr inputWS, + testSaveAndLoadWorkspace(const Mantid::API::IMDWorkspace_sptr &inputWS, const char *rootGroup, const bool rmCoordField = false) { const std::string fileName = "SaveMDSpecialCoordinatesTest.nxs"; diff --git a/Framework/MDAlgorithms/test/LoadSQW2Test.h b/Framework/MDAlgorithms/test/LoadSQW2Test.h index ad577885c83c517e916ddf56ade7675d05eb06e8..afb097b986c74a527569f6878d67610ed303d1bd 100644 --- a/Framework/MDAlgorithms/test/LoadSQW2Test.h +++ b/Framework/MDAlgorithms/test/LoadSQW2Test.h @@ -20,6 +20,7 @@ #include <Poco/TemporaryFile.h> #include <array> +#include <utility> using Mantid::API::ExperimentInfo; using Mantid::API::IAlgorithm; @@ -159,7 +160,8 @@ private: SizeTList nbins; }; - IMDEventWorkspace_sptr runAlgorithm(std::string filename, Arguments args) { + IMDEventWorkspace_sptr runAlgorithm(const std::string &filename, + const Arguments &args) { auto algm = createAlgorithm(); algm->setProperty("Filename", filename); algm->setProperty("MetadataOnly", args.metadataOnly); @@ -180,9 +182,9 @@ private: } void checkGeometryAsExpected(const IMDEventWorkspace &outputWS, - std::string outputFrame, DataType dtype) { + const std::string &outputFrame, DataType dtype) { TS_ASSERT_EQUALS(4, outputWS.getNumDims()); - auto expectedDim = getExpectedDimProperties(outputFrame, dtype); + auto expectedDim = getExpectedDimProperties(std::move(outputFrame), dtype); for (size_t i = 0; i < 4; ++i) { auto dim = outputWS.getDimension(i); TS_ASSERT_EQUALS(expectedDim.ids[i], dim->getDimensionId()); @@ -196,7 +198,7 @@ private: } GNU_DIAG_OFF("missing-braces") - DimensionProperties getExpectedDimProperties(std::string outputFrame, + DimensionProperties getExpectedDimProperties(const std::string &outputFrame, DataType dtype) { DimensionProperties expected; expected.ids = {"qx", "qy", "qz", "en"}; @@ -297,8 +299,8 @@ private: TS_ASSERT_DELTA(0.0, vVec[2], 1e-04); } - void checkDataAsExpected(const IMDEventWorkspace &outputWS, Arguments args, - DataType dtype) { + void checkDataAsExpected(const IMDEventWorkspace &outputWS, + const Arguments &args, DataType dtype) { if (args.metadataOnly) { TS_ASSERT_EQUALS(0, outputWS.getNEvents()); } else { @@ -353,7 +355,7 @@ private: } void checkOutputFile(const IMDEventWorkspace &outputWS, - std::string outputFilename) { + const std::string &outputFilename) { TS_ASSERT(outputWS.isFileBacked()); Poco::File fileback(outputFilename); TS_ASSERT(fileback.getSize() > 0); diff --git a/Framework/MDAlgorithms/test/MergeMDFilesTest.h b/Framework/MDAlgorithms/test/MergeMDFilesTest.h index 923f4a41b88a1dc8eca58205daeda57eda8bc378..64db29a303658a6edb77c21c21ab61cc01746287 100644 --- a/Framework/MDAlgorithms/test/MergeMDFilesTest.h +++ b/Framework/MDAlgorithms/test/MergeMDFilesTest.h @@ -32,7 +32,7 @@ public: void test_exec_fileBacked() { do_test_exec("MergeMDFilesTest_OutputWS.nxs"); } - void do_test_exec(std::string OutputFilename) { + void do_test_exec(const std::string &OutputFilename) { if (OutputFilename != "") { if (Poco::File(OutputFilename).exists()) Poco::File(OutputFilename).remove(); diff --git a/Framework/MDAlgorithms/test/MultiplyMDTest.h b/Framework/MDAlgorithms/test/MultiplyMDTest.h index d50d56c8f148fe948a2631a0f61bab9b33f42938..a59854b4203c1f9f68f2cb7bea89993fdbb24efc 100644 --- a/Framework/MDAlgorithms/test/MultiplyMDTest.h +++ b/Framework/MDAlgorithms/test/MultiplyMDTest.h @@ -61,7 +61,7 @@ public: /** Get a MDEventWorkspace and check that all events have the given * signal/error */ - void checkMDEWSignal(std::string wsName, signal_t expectedSignal, + void checkMDEWSignal(const std::string &wsName, signal_t expectedSignal, signal_t expectedError) { IMDEventWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>(wsName); diff --git a/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h b/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h index ace0a40c7348c57e57d925568481cddadaa99b05..d012668da65384e12ea5ff3046745affc56c6e32 100644 --- a/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h @@ -30,7 +30,7 @@ public: QueryMDWorkspaceTest() { FrameworkManager::Instance(); } - void checkInputs(std::string strNormalisation) { + void checkInputs(const std::string &strNormalisation) { MDEventWorkspace3Lean::sptr in_ws = MDEventsTestHelper::makeMDEW<3>(10, -10.0, 20.0, 3); QueryMDWorkspace query; diff --git a/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h b/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h index e7683d13ce7c8857d25b5b81e7e6f0815f54ad72..c96e482de6a64379a0aab79068051952970e7de8 100644 --- a/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h +++ b/Framework/MDAlgorithms/test/RecalculateTrajectoriesExtentsTest.h @@ -34,8 +34,8 @@ public: delete suite; } - IMDEventWorkspace_sptr create_workspace(std::vector<double> extents, - std::string name) { + IMDEventWorkspace_sptr create_workspace(const std::vector<double> &extents, + const std::string &name) { // ---- empty MDEW ---- TS_ASSERT_EQUALS(extents.size(), 6) CreateMDWorkspace algC; @@ -76,7 +76,7 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string name, std::vector<double> extents) { + void do_test(const std::string &name, std::vector<double> extents) { IMDEventWorkspace_sptr inputWS = create_workspace(extents, name); RecalculateTrajectoriesExtents alg; diff --git a/Framework/MDAlgorithms/test/SaveMD2Test.h b/Framework/MDAlgorithms/test/SaveMD2Test.h index fcc675a7a4fd68a779902a229f8c853d7f5a4f1d..1b45b7e34141bff3bc7bd23bb58c0bb77bd4d031 100644 --- a/Framework/MDAlgorithms/test/SaveMD2Test.h +++ b/Framework/MDAlgorithms/test/SaveMD2Test.h @@ -46,7 +46,7 @@ public: do_test_exec(23, "SaveMD2Test_updating.nxs", true, true); } - void do_test_exec(size_t numPerBox, std::string filename, + void do_test_exec(size_t numPerBox, const std::string &filename, bool MakeFileBacked = false, bool UpdateFileBackEnd = false) { @@ -103,8 +103,8 @@ public: } /// Add some data and update the back-end - void do_test_UpdateFileBackEnd(MDEventWorkspace1Lean::sptr ws, - std::string filename) { + void do_test_UpdateFileBackEnd(const MDEventWorkspace1Lean::sptr &ws, + const std::string &filename) { size_t initial_numEvents = ws->getNPoints(); TSM_ASSERT_EQUALS("Starting off with 230 events.", initial_numEvents, 230); @@ -335,7 +335,7 @@ public: } /** Run SaveMD with the MDHistoWorkspace */ - void doTestHisto(MDHistoWorkspace_sptr ws) { + void doTestHisto(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMD2TestHisto.nxs"; SaveMD2 alg; diff --git a/Framework/MDAlgorithms/test/SaveMDTest.h b/Framework/MDAlgorithms/test/SaveMDTest.h index 81e927489b55727f5c1e3ff4cfe2ee901b65aa7b..aa73db31c62c87c008e6588d3b3053cf0842cfd9 100644 --- a/Framework/MDAlgorithms/test/SaveMDTest.h +++ b/Framework/MDAlgorithms/test/SaveMDTest.h @@ -50,7 +50,7 @@ public: do_test_exec(23, "SaveMDTest_other_file_name_test.nxs", true, false, true); } - void do_test_exec(size_t numPerBox, std::string filename, + void do_test_exec(size_t numPerBox, const std::string &filename, bool MakeFileBacked = false, bool UpdateFileBackEnd = false, bool OtherFileName = false) { @@ -108,8 +108,8 @@ public: } /// Add some data and update the back-end - void do_test_UpdateFileBackEnd(MDEventWorkspace1Lean::sptr ws, - std::string filename) { + void do_test_UpdateFileBackEnd(const MDEventWorkspace1Lean::sptr &ws, + const std::string &filename) { size_t initial_numEvents = ws->getNPoints(); TSM_ASSERT_EQUALS("Starting off with 230 events.", initial_numEvents, 230); @@ -150,8 +150,8 @@ public: Poco::File(fullPath).remove(); } - void do_test_OtherFileName(MDEventWorkspace1Lean::sptr ws, - std::string originalFileName) { + void do_test_OtherFileName(const MDEventWorkspace1Lean::sptr &ws, + const std::string &originalFileName) { const std::string otherFileName = "SaveMD_other_file_name.nxs"; auto algSave = AlgorithmManager::Instance().createUnmanaged("SaveMD"); @@ -284,7 +284,7 @@ public: } /** Run SaveMD with the MDHistoWorkspace */ - void doTestHisto(MDHistoWorkspace_sptr ws) { + void doTestHisto(const MDHistoWorkspace_sptr &ws) { std::string filename = "SaveMDTestHisto.nxs"; SaveMD alg; diff --git a/Framework/MDAlgorithms/test/SaveZODSTest.h b/Framework/MDAlgorithms/test/SaveZODSTest.h index 6798349998a709c396ee7f6e9308b371b81c1a1c..41eb380be5651b24da845448db6f8183099e9e1b 100644 --- a/Framework/MDAlgorithms/test/SaveZODSTest.h +++ b/Framework/MDAlgorithms/test/SaveZODSTest.h @@ -27,8 +27,8 @@ public: TS_ASSERT(alg.isInitialized()) } - std::string do_test(std::string InputWorkspace, std::string Filename, - bool expectSuccess = true) { + std::string do_test(const std::string &InputWorkspace, + const std::string &Filename, bool expectSuccess = true) { SaveZODS alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h b/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h index 8c22e846b14fa4e0406c043d69a54c1b76a07e6b..238ddcdeebdadbc5d3b87c9c9c7c6b4f180546d5 100644 --- a/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h +++ b/Framework/MDAlgorithms/test/SetMDUsingMaskTest.h @@ -26,9 +26,10 @@ public: TS_ASSERT(alg.isInitialized()) } - void do_test(std::string InputWorkspace, std::string MaskWorkspace, - std::string ValueWorkspace, std::string Value, - std::string OutputWorkspace, double expectedSignal, + void do_test(const std::string &InputWorkspace, + const std::string &MaskWorkspace, + const std::string &ValueWorkspace, const std::string &Value, + const std::string &OutputWorkspace, double expectedSignal, double expectedError, bool succeeds = true) { MDHistoWorkspace_sptr histo_A = MDEventsTestHelper::makeFakeMDHistoWorkspace(2.0, 2, 5, 10.0, 2.0); diff --git a/Framework/MDAlgorithms/test/SliceMDTest.h b/Framework/MDAlgorithms/test/SliceMDTest.h index e8a69d52565e8dee377e8bd977821b8cabf6c042..7ad71cd97b5bddfe1eefa70115fb254be7b0c1b2 100644 --- a/Framework/MDAlgorithms/test/SliceMDTest.h +++ b/Framework/MDAlgorithms/test/SliceMDTest.h @@ -144,7 +144,7 @@ public: const uint64_t expectedNumPoints, const size_t expectedNumDims, bool willFail, const std::string &OutputFilename, - IMDEventWorkspace_sptr in_ws) { + const IMDEventWorkspace_sptr &in_ws) { SliceMD alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) @@ -210,7 +210,7 @@ public: const std::string &name3, const std::string &name4, const uint64_t expectedNumPoints, const size_t expectedNumDims, bool willFail = false, - std::string OutputFilename = "") { + const std::string &OutputFilename = "") { Mantid::Geometry::QSample frame; IMDEventWorkspace_sptr in_ws = diff --git a/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h b/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h index cd5400279418666e900b3618b00db2a37f4327f1..3ca0c17dbec560367f57a0dcd60d5d4a47ab5ad8 100644 --- a/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h +++ b/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h @@ -594,10 +594,11 @@ public: //---------------------------------------------------------------------------- std::unique_ptr<SlicingAlgorithmImpl> do_createGeneralTransform( - IMDEventWorkspace_sptr inWS, std::string name1, std::string name2, - std::string name3, std::string name4, VMD translation, - std::string extents, std::string numBins, bool ForceOrthogonal = false, - bool NormalizeBasisVectors = true) { + const IMDEventWorkspace_sptr &inWS, const std::string &name1, + const std::string &name2, const std::string &name3, + const std::string &name4, const VMD &translation, + const std::string &extents, const std::string &numBins, + bool ForceOrthogonal = false, bool NormalizeBasisVectors = true) { auto alg = std::make_unique<SlicingAlgorithmImpl>(); alg->m_inWS = inWS; alg->initSlicingProps(); diff --git a/Framework/MDAlgorithms/test/ThresholdMDTest.h b/Framework/MDAlgorithms/test/ThresholdMDTest.h index 590dd4479cfbfc20af3ecf867f5bd77c0c15c958..64950aae1367ee773e591310eecfe4a3b3621ffc 100644 --- a/Framework/MDAlgorithms/test/ThresholdMDTest.h +++ b/Framework/MDAlgorithms/test/ThresholdMDTest.h @@ -51,7 +51,7 @@ public: TS_ASSERT(alg.isInitialized()) } - IMDHistoWorkspace_sptr doExecute(IMDHistoWorkspace_sptr inWS, + IMDHistoWorkspace_sptr doExecute(const IMDHistoWorkspace_sptr &inWS, const std::string &condition, const double &referenceValue) { const std::string outWSName = "OutWS"; diff --git a/Framework/MDAlgorithms/test/TransformMDTest.h b/Framework/MDAlgorithms/test/TransformMDTest.h index 2f75f3bbd86d61173fc552e2f514738e5e535b06..5ab835d75b91bc0e8a7c60f039a85d6b31c35fa9 100644 --- a/Framework/MDAlgorithms/test/TransformMDTest.h +++ b/Framework/MDAlgorithms/test/TransformMDTest.h @@ -95,7 +95,7 @@ public: } //-------------------------------------------------------------------------------------------- - void do_test_histo(MDHistoWorkspace_sptr ws1, bool inPlace = false) { + void do_test_histo(const MDHistoWorkspace_sptr &ws1, bool inPlace = false) { // Name of the output workspace. std::string outWSName("TransformMDTest_OutputWS"); std::string inWSName("TransformMDTest_ws"); diff --git a/Framework/MDAlgorithms/test/UnaryOperationMDTest.h b/Framework/MDAlgorithms/test/UnaryOperationMDTest.h index 14b0f2e9b651053bc4e58f3f28b84222e3edb7ff..24c153af76a6654fbcd2cc3f01911997840be2ea 100644 --- a/Framework/MDAlgorithms/test/UnaryOperationMDTest.h +++ b/Framework/MDAlgorithms/test/UnaryOperationMDTest.h @@ -60,8 +60,8 @@ public: } /// Run the mock algorithm - void doTest(MockUnaryOperationMD &alg, std::string inName, - std::string outName, bool succeeds = true) { + void doTest(MockUnaryOperationMD &alg, const std::string &inName, + const std::string &outName, bool succeeds = true) { out.reset(); TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/MDAlgorithms/test/WeightedMeanMDTest.h b/Framework/MDAlgorithms/test/WeightedMeanMDTest.h index 1d91aca4e09d181283cf6e1c795b003a1dbcc3af..e836ac0fe72261da5d032e3db9aadd4e3b1f89c4 100644 --- a/Framework/MDAlgorithms/test/WeightedMeanMDTest.h +++ b/Framework/MDAlgorithms/test/WeightedMeanMDTest.h @@ -45,8 +45,8 @@ private: /// Helper method to run the WeightedMean algorithm on two matrix workspaces /// and return the result. - MatrixWorkspace_sptr run_matrix_weighed_mean(MatrixWorkspace_sptr a, - MatrixWorkspace_sptr b, + MatrixWorkspace_sptr run_matrix_weighed_mean(const MatrixWorkspace_sptr &a, + const MatrixWorkspace_sptr &b, const std::string &name) { AnalysisDataServiceImpl &ADS = Mantid::API::AnalysisDataService::Instance(); IAlgorithm *alg = @@ -61,7 +61,8 @@ private: } /// Helper method to run input type validation checks. - void do_test_workspace_input_types(IMDWorkspace_sptr a, IMDWorkspace_sptr b) { + void do_test_workspace_input_types(const IMDWorkspace_sptr &a, + const IMDWorkspace_sptr &b) { WeightedMeanMD alg; alg.initialize(); diff --git a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h index ba1de51814fe8cc7e9a8e3c060a2bdda2e0d0cd5..ff6d99d2776af6586e4d976078b49d93d65dfc61 100644 --- a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h +++ b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGroupPairing.h @@ -56,14 +56,16 @@ public: /// return a workspace for a pair of detector groups, specified in options. API::MatrixWorkspace_sptr - createPairWorkspaceManually(API::Workspace_sptr inputWS, const bool noRebin); + createPairWorkspaceManually(const API::Workspace_sptr &inputWS, + const bool noRebin); /// Store the input properties in options. Muon::AnalysisOptions getUserInput(); /// Set MuonProcess properties (input workspace and period properties). void - setMuonProcessPeriodProperties(IAlgorithm &alg, API::Workspace_sptr inputWS, + setMuonProcessPeriodProperties(IAlgorithm &alg, + const API::Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const; /// Set MuonProcess properties according to the given options. @@ -72,10 +74,9 @@ public: const Muon::AnalysisOptions &options) const; /// Apply the asymmetry calculation to two workspaces. - API::MatrixWorkspace_sptr - createPairWorkspaceFromGroupWorkspaces(API::MatrixWorkspace_sptr inputWS1, - API::MatrixWorkspace_sptr inputWS2, - const double &alpha); + API::MatrixWorkspace_sptr createPairWorkspaceFromGroupWorkspaces( + const API::MatrixWorkspace_sptr &inputWS1, + const API::MatrixWorkspace_sptr &inputWS2, const double &alpha); /// Set grouping properties of MuonProcess void setMuonProcessAlgorithmGroupingProperties( diff --git a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h index 09630bd81cd0e0a9eb4c36d3b0482a291f6cca6b..4f6256f9a865df3d2f91c792a1d1f2b5c341a8ed 100644 --- a/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h +++ b/Framework/Muon/inc/MantidMuon/ApplyMuonDetectorGrouping.h @@ -59,9 +59,9 @@ private: void clipXRangeToWorkspace(const API::WorkspaceGroup &ws, Muon::AnalysisOptions &options); /// Creates and analyses a workspace, if noRebin does not rebin. - API::Workspace_sptr createAnalysisWorkspace(API::Workspace_sptr inputWS, - bool noRebin, - Muon::AnalysisOptions options); + API::Workspace_sptr + createAnalysisWorkspace(const API::Workspace_sptr &inputWS, bool noRebin, + Muon::AnalysisOptions options); /// Sets algorithm properties according to options. void setMuonProcessAlgorithmProperties(API::IAlgorithm &alg, const AnalysisOptions &options) const; @@ -70,7 +70,7 @@ private: /// MuonProcess. void setMuonProcessPeriodProperties(API::IAlgorithm &alg, - API::Workspace_sptr inputWS, + const API::Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const; void setMuonProcessAlgorithmOutputTypeProperty( diff --git a/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h b/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h index 4a00123c04cdfced2ea890c9ce88087893953168..018a1393e8089d854ace3c2484c69cb52b792706 100644 --- a/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h +++ b/Framework/Muon/inc/MantidMuon/CalMuonDetectorPhases.h @@ -57,7 +57,8 @@ private: removeExpDecay(const API::MatrixWorkspace_sptr &wsInput); /// Fit the workspace void fitWorkspace(const API::MatrixWorkspace_sptr &ws, double freq, - std::string groupName, API::ITableWorkspace_sptr resTab, + const std::string &groupName, + const API::ITableWorkspace_sptr &resTab, API::WorkspaceGroup_sptr &resGroup); /// Create the fitting function as string std::string createFittingFunction(double freq, bool fixFreq); diff --git a/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h b/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h index 06d2101dccfb4ef35ea45e587774096c15ce3601..5fe014f469ca7e653cd1578287003732136a7061 100644 --- a/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/CalculateMuonAsymmetry.h @@ -69,10 +69,10 @@ private: void init() override; void exec() override; // calculate Muon normalisation constant - std::vector<double> getNormConstants(std::vector<std::string> wsNames); + std::vector<double> getNormConstants(const std::vector<std::string> &wsNames); std::map<std::string, std::string> validateInputs() override; double getNormValue(API::CompositeFunction_sptr &func); - void addNormalizedFits(size_t numberOfFits, const std::vector<double>); + void addNormalizedFits(size_t numberOfFits, const std::vector<double> &); void normalizeWorkspace( const API::MatrixWorkspace_sptr &normalizedWorkspace, const API::MatrixWorkspace_const_sptr &unnormalizedWorkspace, diff --git a/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h b/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h index 484263f830587aaedacbd3cf724731f98fa336f5..a7b9ec57c752df18ed11b1eb0cfb4b9d930e72bf 100644 --- a/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h +++ b/Framework/Muon/inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h @@ -61,14 +61,14 @@ private: /// Add all the supplied groups to the ADS, inside wsGrouped, by /// executing the ApplyMuonDetectorGrouping algorithm void addGroupingToADS(const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped); + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped); /// Add all the supplied pairs to the ADS, inside wsGrouped, by /// executing the ApplyMuonDetectorGroupPairing algorithm void addPairingToADS(const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped); + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped); void addGroupingInformationToADS(const Mantid::API::Grouping &grouping); @@ -87,8 +87,9 @@ private: /// are paired are also included as groups. void CheckValidGroupsAndPairs(const Mantid::API::Grouping &grouping); - void getTimeLimitsFromInputWorkspace(Mantid::API::Workspace_sptr inputWS, - Mantid::Muon::AnalysisOptions &options); + void + getTimeLimitsFromInputWorkspace(const Mantid::API::Workspace_sptr &inputWS, + Mantid::Muon::AnalysisOptions &options); void getTimeLimitsFromInputs(AnalysisOptions &options); }; diff --git a/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h b/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h index cf83755b300e31b160c1cf0e01ea52eafc422ad3..7e22e0efeca28579f90a1928326524c21d31f8c6 100644 --- a/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h +++ b/Framework/Muon/inc/MantidMuon/MuonAlgorithmHelper.h @@ -55,7 +55,7 @@ namespace MuonAlgorithmHelper { /// Returns a first period MatrixWorkspace in a run workspace MANTID_MUON_DLL Mantid::API::MatrixWorkspace_sptr -firstPeriod(API::Workspace_sptr ws); +firstPeriod(const API::Workspace_sptr &ws); /// Get a run label for a workspace MANTID_MUON_DLL std::string getRunLabel(API::Workspace_sptr ws); @@ -89,15 +89,15 @@ generateWorkspaceName(const Muon::DatasetParams ¶ms); /// Find all the detector IDs contained inside a workspace (either matrix or /// group) and return as an ordered set. MANTID_MUON_DLL std::set<Mantid::detid_t> -getAllDetectorIDsFromWorkspace(Mantid::API::Workspace_sptr ws); +getAllDetectorIDsFromWorkspace(const Mantid::API::Workspace_sptr &ws); /// Find all the detector IDs contained inside a group workspace MANTID_MUON_DLL std::set<Mantid::detid_t> -getAllDetectorIDsFromGroupWorkspace(Mantid::API::WorkspaceGroup_sptr ws); +getAllDetectorIDsFromGroupWorkspace(const Mantid::API::WorkspaceGroup_sptr &ws); /// Find all the detector IDs contained inside a matrix workspace -MANTID_MUON_DLL std::set<Mantid::detid_t> -getAllDetectorIDsFromMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws); +MANTID_MUON_DLL std::set<Mantid::detid_t> getAllDetectorIDsFromMatrixWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws); /// Find all the detector IDs contained inside a grouping object and return as a /// vector of ints @@ -108,7 +108,7 @@ getAllDetectorIDsFromGroup(const API::Grouping &grouping); /// workspace. Workspace can be matrix or group type. MANTID_MUON_DLL bool checkGroupDetectorsInWorkspace(const API::Grouping &grouping, - API::Workspace_sptr ws); + const API::Workspace_sptr &ws); /// Checks that all of the entries of a vector are contained in a set. MANTID_MUON_DLL bool checkItemsInSet(const std::vector<int> &items, @@ -142,9 +142,9 @@ subtractWorkspaces(const Mantid::API::MatrixWorkspace_sptr &lhs, MANTID_MUON_DLL Mantid::API::MatrixWorkspace_sptr extractSpectrum(const Mantid::API::Workspace_sptr &inputWS, const int index); -MANTID_MUON_DLL void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, - const std::string &logName, - const std::string &logValue); +MANTID_MUON_DLL void +addSampleLog(const Mantid::API::MatrixWorkspace_sptr &workspace, + const std::string &logName, const std::string &logValue); MANTID_MUON_DLL bool isAlphanumericOrUnderscore(char character); diff --git a/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h b/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h index 9a9f4dbbb863c421d9ba8ca1aa8642dda4a92db9..60c713dd299549d8a7f087c1fd3a448899263bf2 100644 --- a/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/MuonGroupingAsymmetry.h @@ -44,9 +44,9 @@ private: std::map<std::string, std::string> validateInputs() override; - WorkspaceGroup_sptr createGroupWorkspace(WorkspaceGroup_sptr inputWS); + WorkspaceGroup_sptr createGroupWorkspace(const WorkspaceGroup_sptr &inputWS); - void addGroupingAsymmetrySampleLogs(MatrixWorkspace_sptr workspace); + void addGroupingAsymmetrySampleLogs(const MatrixWorkspace_sptr &workspace); }; } // namespace Muon diff --git a/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h b/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h index 32bf5f020b81037590993b27866aec9c39117b9a..59caf16207398ffe13675cc6d730342da193788f 100644 --- a/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h +++ b/Framework/Muon/inc/MantidMuon/MuonGroupingCounts.h @@ -42,7 +42,7 @@ private: void init() override; void exec() override; - void setGroupingSampleLogs(MatrixWorkspace_sptr workspace); + void setGroupingSampleLogs(const MatrixWorkspace_sptr &workspace); }; } // namespace Muon diff --git a/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h b/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h index 671b22636614a926822428d8568f93f353b2ca88..2df71cb4fd18a37944f017d23e0b0e41c2b2150e 100644 --- a/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h +++ b/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h @@ -47,27 +47,27 @@ private: std::map<std::string, std::string> validateInputs() override; void validateManualGroups(std::map<std::string, std::string> &errors); void validateGroupsWorkspaces(std::map<std::string, std::string> &errors); - void validatePeriods(WorkspaceGroup_sptr inputWS, + void validatePeriods(const WorkspaceGroup_sptr &inputWS, std::map<std::string, std::string> &errors); - WorkspaceGroup_sptr createGroupWorkspace(WorkspaceGroup_sptr inputWS); - MatrixWorkspace_sptr appendSpectra(MatrixWorkspace_sptr inputWS1, - MatrixWorkspace_sptr inputWS2); + WorkspaceGroup_sptr createGroupWorkspace(const WorkspaceGroup_sptr &inputWS); + MatrixWorkspace_sptr appendSpectra(const MatrixWorkspace_sptr &inputWS1, + const MatrixWorkspace_sptr &inputWS2); /// Perform an asymmetry calculation - MatrixWorkspace_sptr pairAsymmetryCalc(MatrixWorkspace_sptr inputWS, + MatrixWorkspace_sptr pairAsymmetryCalc(const MatrixWorkspace_sptr &inputWS, const double &alpha); MatrixWorkspace_sptr calcPairAsymmetryWithSummedAndSubtractedPeriods( const std::vector<int> &summedPeriods, const std::vector<int> &subtractedPeriods, - WorkspaceGroup_sptr groupedPeriods, const double &alpha); + const WorkspaceGroup_sptr &groupedPeriods, const double &alpha); /// Execute the algorithm if "SpecifyGroupsManually" is checked MatrixWorkspace_sptr execSpecifyGroupsManually(); MatrixWorkspace_sptr execGroupWorkspaceInput(); - void setPairAsymmetrySampleLogs(MatrixWorkspace_sptr workspace); + void setPairAsymmetrySampleLogs(const MatrixWorkspace_sptr &workspace); }; } // namespace Muon diff --git a/Framework/Muon/inc/MantidMuon/MuonPreProcess.h b/Framework/Muon/inc/MantidMuon/MuonPreProcess.h index 84441fe2c9c434fee995ea0575331431c383f95e..70b2407de69366c355be54fb57194ae842d82aa9 100644 --- a/Framework/Muon/inc/MantidMuon/MuonPreProcess.h +++ b/Framework/Muon/inc/MantidMuon/MuonPreProcess.h @@ -45,11 +45,11 @@ private: void exec() override; /// Apply a series of corrections ; DTC, offset, rebin, crop - WorkspaceGroup_sptr correctWorkspaces(WorkspaceGroup_sptr wsGroup); + WorkspaceGroup_sptr correctWorkspaces(const WorkspaceGroup_sptr &wsGroup); MatrixWorkspace_sptr correctWorkspace(MatrixWorkspace_sptr ws); MatrixWorkspace_sptr applyDTC(MatrixWorkspace_sptr ws, - TableWorkspace_sptr dt); + const TableWorkspace_sptr &dt); MatrixWorkspace_sptr applyTimeOffset(MatrixWorkspace_sptr ws, const double &offset); @@ -60,10 +60,10 @@ private: MatrixWorkspace_sptr applyRebinning(MatrixWorkspace_sptr ws, const std::vector<double> &rebinArgs); - MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr ws); + MatrixWorkspace_sptr cloneWorkspace(const MatrixWorkspace_sptr &ws); /// Add the correction inputs into the logs - void addPreProcessSampleLogs(WorkspaceGroup_sptr group); + void addPreProcessSampleLogs(const WorkspaceGroup_sptr &group); /// Perform validation of inputs to the algorithm std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h b/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h index a45994979e03e4d2014c3aa534041d2c99550102..9eebe959a5257263ba3f1213212a822a3ab4b439 100644 --- a/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h +++ b/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h @@ -67,7 +67,7 @@ private: // Load run, apply dead time corrections and detector grouping API::Workspace_sptr doLoad(size_t runNumber); // Analyse loaded run - void doAnalysis(API::Workspace_sptr loadedWs, size_t index); + void doAnalysis(const API::Workspace_sptr &loadedWs, size_t index); // Parse run names void parseRunNames(std::string &firstFN, std::string &lastFN, std::string &fnBase, std::string &fnExt, int &fnZeros); @@ -83,10 +83,11 @@ private: void groupDetectors(API::Workspace_sptr &loadedWs, API::Workspace_sptr grouping); /// Calculate the integral asymmetry for a workspace (single period) - void calcIntAsymmetry(API::MatrixWorkspace_sptr ws, double &Y, double &E); + void calcIntAsymmetry(const API::MatrixWorkspace_sptr &ws, double &Y, + double &E); /// Calculate the integral asymmetry for a workspace (red & green) - void calcIntAsymmetry(API::MatrixWorkspace_sptr ws_red, - API::MatrixWorkspace_sptr ws_green, double &Y, + void calcIntAsymmetry(const API::MatrixWorkspace_sptr &ws_red, + const API::MatrixWorkspace_sptr &ws_green, double &Y, double &E); /// Group detectors void groupDetectors(API::MatrixWorkspace_sptr &ws, diff --git a/Framework/Muon/inc/MantidMuon/RRFMuon.h b/Framework/Muon/inc/MantidMuon/RRFMuon.h index 793a0abd6dabcb14db86b22bfb275ddbadb10410..54ce32546cb730641b8dd77132a69ad880d56cee 100644 --- a/Framework/Muon/inc/MantidMuon/RRFMuon.h +++ b/Framework/Muon/inc/MantidMuon/RRFMuon.h @@ -43,7 +43,7 @@ private: /// Run the algorithm void exec() override; /// Get conversion factor from frequency units to input workspace units - double unitConversionFactor(std::string uin, std::string uuser); + double unitConversionFactor(const std::string &uin, const std::string &uuser); }; } // namespace Algorithms diff --git a/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h b/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h index 9327fa0404bec1a8c5e3dfe3024cd21100b9812d..03b02418ad05daa188f28bc1b5aa550a6b19c8c2 100644 --- a/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h +++ b/Framework/Muon/inc/MantidMuon/RemoveExpDecay.h @@ -56,7 +56,8 @@ private: HistogramData::Histogram removeDecay(const HistogramData::Histogram &histogram) const; // calculate Muon normalisation constant - double calNormalisationConst(API::MatrixWorkspace_sptr ws, int wsIndex); + double calNormalisationConst(const API::MatrixWorkspace_sptr &ws, + int wsIndex); }; } // namespace Algorithms diff --git a/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp b/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp index 7406f76e62c828988b0e6b1ee34029ce75e7d070..7a26b99d096fbcd618a916bb81bc59ec09247f91 100644 --- a/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp +++ b/Framework/Muon/src/ApplyMuonDetectorGroupPairing.cpp @@ -22,6 +22,8 @@ #include <algorithm> #include <cctype> #include <string> +#include <utility> + #include <vector> const std::vector<std::string> g_analysisTypes = {"Counts", "Asymmetry"}; @@ -340,7 +342,7 @@ const std::string ApplyMuonDetectorGroupPairing::getGroupWorkspaceNamesManually( */ MatrixWorkspace_sptr ApplyMuonDetectorGroupPairing::createPairWorkspaceFromGroupWorkspaces( - MatrixWorkspace_sptr inputWS1, MatrixWorkspace_sptr inputWS2, + const MatrixWorkspace_sptr &inputWS1, const MatrixWorkspace_sptr &inputWS2, const double &alpha) { IAlgorithm_sptr alg = this->createChildAlgorithm("AppendSpectra"); @@ -372,7 +374,7 @@ ApplyMuonDetectorGroupPairing::createPairWorkspaceFromGroupWorkspaces( * options. */ MatrixWorkspace_sptr ApplyMuonDetectorGroupPairing::createPairWorkspaceManually( - Workspace_sptr inputWS, bool noRebin) { + const Workspace_sptr &inputWS, bool noRebin) { IAlgorithm_sptr alg = this->createChildAlgorithm("MuonProcess"); if (!this->isLogging()) @@ -427,8 +429,8 @@ Muon::AnalysisOptions ApplyMuonDetectorGroupPairing::getUserInput() { // Checks that the detector IDs in grouping are in the workspace void ApplyMuonDetectorGroupPairing::checkDetectorIDsInWorkspace( API::Grouping &grouping, Workspace_sptr workspace) { - bool check = - MuonAlgorithmHelper::checkGroupDetectorsInWorkspace(grouping, workspace); + bool check = MuonAlgorithmHelper::checkGroupDetectorsInWorkspace( + grouping, std::move(workspace)); if (!check) { g_log.error("One or more detector IDs specified in the groups is not " "contained in the InputWorkspace"); @@ -443,7 +445,7 @@ void ApplyMuonDetectorGroupPairing::checkDetectorIDsInWorkspace( * to the given options. For use with MuonProcess. */ void ApplyMuonDetectorGroupPairing::setMuonProcessPeriodProperties( - IAlgorithm &alg, Workspace_sptr inputWS, + IAlgorithm &alg, const Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const { auto inputGroup = boost::make_shared<WorkspaceGroup>(); diff --git a/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp b/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp index 6d129b7a2a0bfbf6e3c2e5c65672ffce4eb4b1af..02fca46359cbdb32c236e8e753fc6d0c75247758 100644 --- a/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp +++ b/Framework/Muon/src/ApplyMuonDetectorGrouping.cpp @@ -19,6 +19,8 @@ #include <algorithm> #include <cctype> #include <string> +#include <utility> + #include <vector> const std::vector<std::string> g_analysisTypes = {"Counts", "Asymmetry"}; @@ -44,7 +46,7 @@ Mantid::Muon::PlotType getPlotType(const std::string &plotType) { * single period otherwise leave it alone. */ Mantid::API::WorkspaceGroup_sptr -convertInputWStoWSGroup(Mantid::API::Workspace_sptr inputWS) { +convertInputWStoWSGroup(const Mantid::API::Workspace_sptr &inputWS) { // Cast input WS to a WorkspaceGroup auto muonWS = boost::make_shared<Mantid::API::WorkspaceGroup>(); @@ -317,7 +319,8 @@ void ApplyMuonDetectorGrouping::clipXRangeToWorkspace( * Creates workspace, processing the data using the MuonProcess algorithm. */ Workspace_sptr ApplyMuonDetectorGrouping::createAnalysisWorkspace( - Workspace_sptr inputWS, bool noRebin, Muon::AnalysisOptions options) { + const Workspace_sptr &inputWS, bool noRebin, + Muon::AnalysisOptions options) { IAlgorithm_sptr alg = Algorithm::createChildAlgorithm("MuonProcess"); @@ -325,7 +328,7 @@ Workspace_sptr ApplyMuonDetectorGrouping::createAnalysisWorkspace( options.rebinArgs = ""; } - setMuonProcessPeriodProperties(*alg, inputWS, options); + setMuonProcessPeriodProperties(*alg, std::move(inputWS), options); setMuonProcessAlgorithmProperties(*alg, options); alg->setPropertyValue("OutputWorkspace", "__NotUsed__"); alg->execute(); @@ -350,7 +353,7 @@ bool ApplyMuonDetectorGrouping::renameAndMoveUnNormWorkspace( * to the given options. For use with MuonProcess. */ void ApplyMuonDetectorGrouping::setMuonProcessPeriodProperties( - IAlgorithm &alg, Workspace_sptr inputWS, + IAlgorithm &alg, const Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const { auto inputGroup = boost::make_shared<WorkspaceGroup>(); diff --git a/Framework/Muon/src/CalMuonDetectorPhases.cpp b/Framework/Muon/src/CalMuonDetectorPhases.cpp index 3f0f0940673be6be57c9012d5c1ca5ce3406d709..9788d4f3253512f9dc3d77cc6619146b09444516 100644 --- a/Framework/Muon/src/CalMuonDetectorPhases.cpp +++ b/Framework/Muon/src/CalMuonDetectorPhases.cpp @@ -152,10 +152,10 @@ void CalMuonDetectorPhases::exec() { * @param resTab :: [output] Table workspace storing the asymmetries and phases * @param resGroup :: [output] Workspace group storing the fitting results */ -void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, - double freq, std::string groupName, - API::ITableWorkspace_sptr resTab, - API::WorkspaceGroup_sptr &resGroup) { +void CalMuonDetectorPhases::fitWorkspace( + const API::MatrixWorkspace_sptr &ws, double freq, + const std::string &groupName, const API::ITableWorkspace_sptr &resTab, + API::WorkspaceGroup_sptr &resGroup) { auto nhist = static_cast<int>(ws->getNumberHistograms()); diff --git a/Framework/Muon/src/CalculateMuonAsymmetry.cpp b/Framework/Muon/src/CalculateMuonAsymmetry.cpp index 6b24c51409c1307567aa78add68ff1f96bdff792..d4f260631723249207ac478bc0167009e46c8bc1 100644 --- a/Framework/Muon/src/CalculateMuonAsymmetry.cpp +++ b/Framework/Muon/src/CalculateMuonAsymmetry.cpp @@ -228,7 +228,7 @@ void CalculateMuonAsymmetry::exec() { * @return normalization constants */ void CalculateMuonAsymmetry::addNormalizedFits( - size_t numberOfFits, const std::vector<double> norms) { + size_t numberOfFits, const std::vector<double> &norms) { for (size_t j = 0; j < numberOfFits; j++) { API::Workspace_sptr fitWorkspace = getProperty("OutputWorkspace"); API::MatrixWorkspace_sptr fitWorkspaceActual; @@ -279,7 +279,7 @@ void CalculateMuonAsymmetry::addNormalizedFits( * @return normalization constants */ std::vector<double> CalculateMuonAsymmetry::getNormConstants( - const std::vector<std::string> wsNames) { + const std::vector<std::string> &wsNames) { std::vector<double> norms; double startX = getProperty("StartX"); double endX = getProperty("EndX"); diff --git a/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp b/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp index a6cc50655d6cd668125b8cead2b5a5d6f6b288e7..6a2627176ca84e02727895e86f5b5a7428297a72 100644 --- a/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp +++ b/Framework/Muon/src/LoadAndApplyMuonDetectorGrouping.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidMuon/LoadAndApplyMuonDetectorGrouping.h" #include "MantidMuon/MuonAlgorithmHelper.h" @@ -198,7 +200,7 @@ LoadAndApplyMuonDetectorGrouping::validateInputs() { } void LoadAndApplyMuonDetectorGrouping::getTimeLimitsFromInputWorkspace( - Workspace_sptr inputWS, AnalysisOptions &options) { + const Workspace_sptr &inputWS, AnalysisOptions &options) { MatrixWorkspace_sptr inputMatrixWS = boost::dynamic_pointer_cast<MatrixWorkspace>(inputWS); WorkspaceGroup_sptr inputGroupWS = @@ -268,8 +270,8 @@ void LoadAndApplyMuonDetectorGrouping::exec() { // Checks that the detector IDs in grouping are in the workspace void LoadAndApplyMuonDetectorGrouping::checkDetectorIDsInWorkspace( API::Grouping &grouping, Workspace_sptr workspace) { - bool check = - MuonAlgorithmHelper::checkGroupDetectorsInWorkspace(grouping, workspace); + bool check = MuonAlgorithmHelper::checkGroupDetectorsInWorkspace( + grouping, std::move(workspace)); if (!check) { g_log.error("One or more detector IDs specified in the groups is not " "contained in the InputWorkspace"); @@ -288,7 +290,8 @@ WorkspaceGroup_sptr LoadAndApplyMuonDetectorGrouping::addGroupedWSWithDefaultName( Workspace_sptr workspace) { auto &ads = AnalysisDataService::Instance(); - std::string groupedWSName = MuonAlgorithmHelper::getRunLabel(workspace); + std::string groupedWSName = + MuonAlgorithmHelper::getRunLabel(std::move(workspace)); WorkspaceGroup_sptr groupedWS; if (ads.doesExist(groupedWSName)) { @@ -388,8 +391,8 @@ void LoadAndApplyMuonDetectorGrouping::CheckValidGroupsAndPairs( */ void LoadAndApplyMuonDetectorGrouping::addGroupingToADS( const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped) { + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped) { size_t numGroups = options.grouping.groups.size(); for (auto i = 0u; i < numGroups; ++i) { @@ -426,8 +429,8 @@ void LoadAndApplyMuonDetectorGrouping::addGroupingToADS( */ void LoadAndApplyMuonDetectorGrouping::addPairingToADS( const Mantid::Muon::AnalysisOptions &options, - Mantid::API::Workspace_sptr ws, - Mantid::API::WorkspaceGroup_sptr wsGrouped) { + const Mantid::API::Workspace_sptr &ws, + const Mantid::API::WorkspaceGroup_sptr &wsGrouped) { size_t numPairs = options.grouping.pairs.size(); for (size_t i = 0; i < numPairs; i++) { diff --git a/Framework/Muon/src/MuonAlgorithmHelper.cpp b/Framework/Muon/src/MuonAlgorithmHelper.cpp index 6e0e93e477caa2baec6019f47e3b345ecc8d1015..f04f4c25d956f02f7630714f9d56e523813419ab 100644 --- a/Framework/Muon/src/MuonAlgorithmHelper.cpp +++ b/Framework/Muon/src/MuonAlgorithmHelper.cpp @@ -15,6 +15,8 @@ #include <fstream> #include <string> +#include <utility> + #include <vector> namespace Mantid { @@ -28,7 +30,7 @@ using namespace Mantid::API; * workspace has one period only - it is returned. * @param ws :: Run workspace */ -MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { +MatrixWorkspace_sptr firstPeriod(const Workspace_sptr &ws) { if (auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(0)); @@ -43,7 +45,7 @@ MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { * @return :: run label */ std::string getRunLabel(Mantid::API::Workspace_sptr ws) { - const std::vector<Mantid::API::Workspace_sptr> wsList{ws}; + const std::vector<Mantid::API::Workspace_sptr> wsList{std::move(ws)}; return getRunLabel(wsList); } @@ -282,7 +284,7 @@ std::string generateWorkspaceName(const Muon::DatasetParams ¶ms) { * group) and return as an ordered set. */ std::set<Mantid::detid_t> -getAllDetectorIDsFromWorkspace(Mantid::API::Workspace_sptr ws) { +getAllDetectorIDsFromWorkspace(const Mantid::API::Workspace_sptr &ws) { std::set<Mantid::detid_t> detectorIDs; if (auto workspace = boost::dynamic_pointer_cast<MatrixWorkspace>(ws)) { @@ -296,8 +298,8 @@ getAllDetectorIDsFromWorkspace(Mantid::API::Workspace_sptr ws) { /** * Find all the detector IDs contained inside a matrix workspace */ -std::set<Mantid::detid_t> -getAllDetectorIDsFromMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +std::set<Mantid::detid_t> getAllDetectorIDsFromMatrixWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws) { std::set<Mantid::detid_t> detectorIDs; std::set<Mantid::detid_t> spectrumIDs; @@ -312,8 +314,8 @@ getAllDetectorIDsFromMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { /** * Find all the detector IDs contained inside a group workspace */ -std::set<Mantid::detid_t> -getAllDetectorIDsFromGroupWorkspace(Mantid::API::WorkspaceGroup_sptr ws) { +std::set<Mantid::detid_t> getAllDetectorIDsFromGroupWorkspace( + const Mantid::API::WorkspaceGroup_sptr &ws) { std::set<Mantid::detid_t> detectorIDs; std::set<Mantid::detid_t> detectorIDsSingleWorkspace; @@ -348,8 +350,8 @@ std::vector<int> getAllDetectorIDsFromGroup(const Grouping &grouping) { // Checks if all the detectors in the groups in a Grouping are in the workspace. // Workspace can be matrix or group type. bool checkGroupDetectorsInWorkspace(const Grouping &grouping, - Workspace_sptr ws) { - std::set<int> detectorIDs = getAllDetectorIDsFromWorkspace(ws); + const Workspace_sptr &ws) { + std::set<int> detectorIDs = getAllDetectorIDsFromWorkspace(std::move(ws)); std::vector<int> groupDetectorIDs = getAllDetectorIDsFromGroup(grouping); return checkItemsInSet(groupDetectorIDs, detectorIDs); } @@ -605,8 +607,8 @@ MatrixWorkspace_sptr extractSpectrum(const Workspace_sptr &inputWS, return outWS; } -void addSampleLog(MatrixWorkspace_sptr workspace, const std::string &logName, - const std::string &logValue) { +void addSampleLog(const MatrixWorkspace_sptr &workspace, + const std::string &logName, const std::string &logValue) { IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("AddSampleLog"); alg->initialize(); diff --git a/Framework/Muon/src/MuonGroupingAsymmetry.cpp b/Framework/Muon/src/MuonGroupingAsymmetry.cpp index 86624ee6054f7761b7f93df527ed5e7569fab22a..a43b232ad84b1f4c6738876395e33d43b7b0788f 100644 --- a/Framework/Muon/src/MuonGroupingAsymmetry.cpp +++ b/Framework/Muon/src/MuonGroupingAsymmetry.cpp @@ -66,7 +66,7 @@ estimateAsymmetry(const Workspace_sptr &inputWS, const int index, } std::pair<MatrixWorkspace_sptr, MatrixWorkspace_sptr> estimateMuonAsymmetry( - WorkspaceGroup_sptr inputWS, const std::vector<int> &summedPeriods, + const WorkspaceGroup_sptr &inputWS, const std::vector<int> &summedPeriods, const std::vector<int> &subtractedPeriods, int groupIndex, const double startX, const double endX, const double normalizationIn) { MatrixWorkspace_sptr tempWS; @@ -118,7 +118,7 @@ std::pair<MatrixWorkspace_sptr, MatrixWorkspace_sptr> estimateMuonAsymmetry( return outputPair; } -MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr groupDetectors(const MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIDs) { auto outputWS = WorkspaceFactory::Instance().create(workspace, 1); @@ -284,8 +284,8 @@ std::map<std::string, std::string> MuonGroupingAsymmetry::validateInputs() { return errors; } -WorkspaceGroup_sptr -MuonGroupingAsymmetry::createGroupWorkspace(WorkspaceGroup_sptr inputWS) { +WorkspaceGroup_sptr MuonGroupingAsymmetry::createGroupWorkspace( + const WorkspaceGroup_sptr &inputWS) { const std::vector<int> group = this->getProperty("Grouping"); auto groupedPeriods = boost::make_shared<WorkspaceGroup>(); // for each period @@ -320,7 +320,7 @@ void MuonGroupingAsymmetry::exec() { } void MuonGroupingAsymmetry::addGroupingAsymmetrySampleLogs( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { MuonAlgorithmHelper::addSampleLog(workspace, "analysis_asymmetry_group_name", getPropertyValue("GroupName")); MuonAlgorithmHelper::addSampleLog(workspace, "analysis_asymmetry_group", diff --git a/Framework/Muon/src/MuonGroupingCounts.cpp b/Framework/Muon/src/MuonGroupingCounts.cpp index 760841a98aca0da0dd76d40ca891be6eba35a182..2d1f6979e82969408aae54a6b29f8c8418ec6348 100644 --- a/Framework/Muon/src/MuonGroupingCounts.cpp +++ b/Framework/Muon/src/MuonGroupingCounts.cpp @@ -25,11 +25,11 @@ using namespace Mantid::HistogramData; namespace { bool checkPeriodInWorkspaceGroup(const int &period, - WorkspaceGroup_sptr workspace) { + const WorkspaceGroup_sptr &workspace) { return period <= workspace->getNumberOfEntries(); } -MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr groupDetectors(const MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIDs) { auto outputWS = WorkspaceFactory::Instance().create(workspace, 1); @@ -199,7 +199,8 @@ void MuonGroupingCounts::exec() { setProperty("OutputWorkspace", outputWS); } -void MuonGroupingCounts::setGroupingSampleLogs(MatrixWorkspace_sptr workspace) { +void MuonGroupingCounts::setGroupingSampleLogs( + const MatrixWorkspace_sptr &workspace) { MuonAlgorithmHelper::addSampleLog(workspace, "analysis_group_name", getPropertyValue("GroupName")); MuonAlgorithmHelper::addSampleLog(workspace, "analysis_group", diff --git a/Framework/Muon/src/MuonPairingAsymmetry.cpp b/Framework/Muon/src/MuonPairingAsymmetry.cpp index 66d1b70c7bc9c46fa1a9d7549920500db62161f1..5116956eb3a38c37cdf10f9e842242615f6d946e 100644 --- a/Framework/Muon/src/MuonPairingAsymmetry.cpp +++ b/Framework/Muon/src/MuonPairingAsymmetry.cpp @@ -23,11 +23,11 @@ using namespace Mantid::Kernel; namespace { bool checkPeriodInWorkspaceGroup(const int &period, - WorkspaceGroup_const_sptr workspace) { + const WorkspaceGroup_const_sptr &workspace) { return period <= workspace->getNumberOfEntries(); } -int countPeriods(Workspace_const_sptr ws) { +int countPeriods(const Workspace_const_sptr &ws) { if (auto tmp = boost::dynamic_pointer_cast<const WorkspaceGroup>(ws)) { return tmp->getNumberOfEntries(); } else { @@ -35,8 +35,8 @@ int countPeriods(Workspace_const_sptr ws) { } } -bool checkConsistentPeriods(Workspace_const_sptr ws1, - Workspace_const_sptr ws2) { +bool checkConsistentPeriods(const Workspace_const_sptr &ws1, + const Workspace_const_sptr &ws2) { if (ws1->isGroup()) { if (!ws2->isGroup()) { return false; @@ -48,12 +48,13 @@ bool checkConsistentPeriods(Workspace_const_sptr ws1, return true; } -MatrixWorkspace_sptr getWorkspace(WorkspaceGroup_sptr group, const int &index) { +MatrixWorkspace_sptr getWorkspace(const WorkspaceGroup_sptr &group, + const int &index) { auto ws = group->getItem(index); return boost::dynamic_pointer_cast<MatrixWorkspace>(ws); } -MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr groupDetectors(const MatrixWorkspace_sptr &workspace, const std::vector<int> &detectorIDs) { auto outputWS = WorkspaceFactory::Instance().create(workspace, 1); @@ -83,7 +84,7 @@ MatrixWorkspace_sptr groupDetectors(MatrixWorkspace_sptr workspace, // Convert a Workspace_sptr (which may be single period, MatrixWorkspace, or // multi period WorkspaceGroup) to a WorkspaceGroup_sptr -WorkspaceGroup_sptr workspaceToWorkspaceGroup(Workspace_sptr workspace) { +WorkspaceGroup_sptr workspaceToWorkspaceGroup(const Workspace_sptr &workspace) { WorkspaceGroup_sptr ws1; if (workspace->isGroup()) { @@ -333,7 +334,7 @@ MatrixWorkspace_sptr MuonPairingAsymmetry::calcPairAsymmetryWithSummedAndSubtractedPeriods( const std::vector<int> &summedPeriods, const std::vector<int> &subtractedPeriods, - WorkspaceGroup_sptr groupedPeriods, const double &alpha) { + const WorkspaceGroup_sptr &groupedPeriods, const double &alpha) { auto summedWS = MuonAlgorithmHelper::sumPeriods(groupedPeriods, summedPeriods); auto subtractedWS = @@ -358,7 +359,7 @@ workspace has two spectra corresponding to the two groupings specified in the inputs. */ WorkspaceGroup_sptr -MuonPairingAsymmetry::createGroupWorkspace(WorkspaceGroup_sptr inputWS) { +MuonPairingAsymmetry::createGroupWorkspace(const WorkspaceGroup_sptr &inputWS) { std::vector<int> group1 = this->getProperty("Group1"); std::vector<int> group2 = this->getProperty("Group2"); @@ -381,7 +382,7 @@ MuonPairingAsymmetry::createGroupWorkspace(WorkspaceGroup_sptr inputWS) { * @returns MatrixWorkspace containing result of the calculation. */ MatrixWorkspace_sptr -MuonPairingAsymmetry::pairAsymmetryCalc(MatrixWorkspace_sptr inputWS, +MuonPairingAsymmetry::pairAsymmetryCalc(const MatrixWorkspace_sptr &inputWS, const double &alpha) { MatrixWorkspace_sptr outWS; @@ -404,7 +405,7 @@ MuonPairingAsymmetry::pairAsymmetryCalc(MatrixWorkspace_sptr inputWS, } void MuonPairingAsymmetry::setPairAsymmetrySampleLogs( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { MuonAlgorithmHelper::addSampleLog(workspace, "analysis_pairName", getProperty("PairName")); MuonAlgorithmHelper::addSampleLog(workspace, "analysis_alpha", @@ -420,8 +421,8 @@ void MuonPairingAsymmetry::setPairAsymmetrySampleLogs( } MatrixWorkspace_sptr -MuonPairingAsymmetry::appendSpectra(MatrixWorkspace_sptr inputWS1, - MatrixWorkspace_sptr inputWS2) { +MuonPairingAsymmetry::appendSpectra(const MatrixWorkspace_sptr &inputWS1, + const MatrixWorkspace_sptr &inputWS2) { IAlgorithm_sptr alg = this->createChildAlgorithm("AppendSpectra"); alg->setProperty("InputWorkspace1", inputWS1); @@ -433,7 +434,8 @@ MuonPairingAsymmetry::appendSpectra(MatrixWorkspace_sptr inputWS1, } void MuonPairingAsymmetry::validatePeriods( - WorkspaceGroup_sptr inputWS, std::map<std::string, std::string> &errors) { + const WorkspaceGroup_sptr &inputWS, + std::map<std::string, std::string> &errors) { const std::vector<int> summedPeriods = getProperty("SummedPeriods"); const std::vector<int> subtractedPeriods = getProperty("SubtractedPeriods"); if (summedPeriods.empty() && subtractedPeriods.empty()) { diff --git a/Framework/Muon/src/MuonPreProcess.cpp b/Framework/Muon/src/MuonPreProcess.cpp index 38c409f9009932e878c8126d51d0a77cc6fa5f56..2d78c07483c09d1825fb4aa32b9cd46aca0505b4 100644 --- a/Framework/Muon/src/MuonPreProcess.cpp +++ b/Framework/Muon/src/MuonPreProcess.cpp @@ -155,7 +155,7 @@ void MuonPreProcess::exec() { * @return Corrected workspaces */ WorkspaceGroup_sptr -MuonPreProcess::correctWorkspaces(WorkspaceGroup_sptr wsGroup) { +MuonPreProcess::correctWorkspaces(const WorkspaceGroup_sptr &wsGroup) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (auto &&workspace : *wsGroup) { if (auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace)) { @@ -191,7 +191,7 @@ MatrixWorkspace_sptr MuonPreProcess::correctWorkspace(MatrixWorkspace_sptr ws) { } MatrixWorkspace_sptr MuonPreProcess::applyDTC(MatrixWorkspace_sptr ws, - TableWorkspace_sptr dt) { + const TableWorkspace_sptr &dt) { if (dt != nullptr) { IAlgorithm_sptr dtc = this->createChildAlgorithm("ApplyDeadTimeCorr"); dtc->setProperty("InputWorkspace", ws); @@ -248,7 +248,8 @@ MuonPreProcess::applyRebinning(MatrixWorkspace_sptr ws, } } -MatrixWorkspace_sptr MuonPreProcess::cloneWorkspace(MatrixWorkspace_sptr ws) { +MatrixWorkspace_sptr +MuonPreProcess::cloneWorkspace(const MatrixWorkspace_sptr &ws) { IAlgorithm_sptr cloneWorkspace = this->createChildAlgorithm("CloneWorkspace"); cloneWorkspace->setProperty("InputWorkspace", ws); cloneWorkspace->execute(); @@ -256,7 +257,7 @@ MatrixWorkspace_sptr MuonPreProcess::cloneWorkspace(MatrixWorkspace_sptr ws) { return boost::dynamic_pointer_cast<MatrixWorkspace>(wsClone); } -void MuonPreProcess::addPreProcessSampleLogs(WorkspaceGroup_sptr group) { +void MuonPreProcess::addPreProcessSampleLogs(const WorkspaceGroup_sptr &group) { const std::string numPeriods = std::to_string(group->getNumberOfEntries()); for (auto &&workspace : *group) { diff --git a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp index 4012572a49bf519f4dbe7557c06194df5ea04edf..c344108e3545418c862747b2e81087a3f320e951 100644 --- a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp +++ b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp @@ -5,6 +5,8 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include <cmath> +#include <utility> + #include <vector> #include "MantidAPI/AlgorithmManager.h" @@ -565,7 +567,7 @@ void PlotAsymmetryByLogValue::parseRunNames(std::string &firstFN, void PlotAsymmetryByLogValue::applyDeadtimeCorr(Workspace_sptr &loadedWs, Workspace_sptr deadTimes) { ScopedWorkspace ws(loadedWs); - ScopedWorkspace dt(deadTimes); + ScopedWorkspace dt(std::move(deadTimes)); IAlgorithm_sptr applyCorr = AlgorithmManager::Instance().createUnmanaged("ApplyDeadTimeCorr"); @@ -610,7 +612,7 @@ void PlotAsymmetryByLogValue::groupDetectors(Workspace_sptr &loadedWs, // Could be groups of workspaces, so need to work with ADS ScopedWorkspace inWS(loadedWs); - ScopedWorkspace grWS(grouping); + ScopedWorkspace grWS(std::move(grouping)); ScopedWorkspace outWS; IAlgorithm_sptr alg = @@ -628,7 +630,7 @@ void PlotAsymmetryByLogValue::groupDetectors(Workspace_sptr &loadedWs, * @param loadedWs :: [input] Workspace to apply analysis to * @param index :: [input] Vector index where results will be stored */ -void PlotAsymmetryByLogValue::doAnalysis(Workspace_sptr loadedWs, +void PlotAsymmetryByLogValue::doAnalysis(const Workspace_sptr &loadedWs, size_t index) { // Check if workspace is a workspace group @@ -698,7 +700,7 @@ void PlotAsymmetryByLogValue::doAnalysis(Workspace_sptr loadedWs, * @param Y :: Reference to a variable receiving the value of asymmetry * @param E :: Reference to a variable receiving the value of the error */ -void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws, +void PlotAsymmetryByLogValue::calcIntAsymmetry(const MatrixWorkspace_sptr &ws, double &Y, double &E) { // Output workspace @@ -746,9 +748,9 @@ void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws, * @param Y :: Reference to a variable receiving the value of asymmetry * @param E :: Reference to a variable receiving the value of the error */ -void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws_red, - MatrixWorkspace_sptr ws_green, - double &Y, double &E) { +void PlotAsymmetryByLogValue::calcIntAsymmetry( + const MatrixWorkspace_sptr &ws_red, const MatrixWorkspace_sptr &ws_green, + double &Y, double &E) { if (!m_int) { // "Differential asymmetry" HistogramBuilder builder; builder.setX(ws_red->x(0).size()); diff --git a/Framework/Muon/src/RRFMuon.cpp b/Framework/Muon/src/RRFMuon.cpp index 945cc980b95c899ceb8f5fee16fdb7d43ada0bf3..801d8bfb95f0e935f8330b91cbb49c2f1f397673 100644 --- a/Framework/Muon/src/RRFMuon.cpp +++ b/Framework/Muon/src/RRFMuon.cpp @@ -109,7 +109,8 @@ void RRFMuon::exec() { * @param uin :: [input] input workspace units * @param uuser :: [input] units selected by user */ -double RRFMuon::unitConversionFactor(std::string uin, std::string uuser) { +double RRFMuon::unitConversionFactor(const std::string &uin, + const std::string &uuser) { if ((uin == "microsecond")) { diff --git a/Framework/Muon/src/RemoveExpDecay.cpp b/Framework/Muon/src/RemoveExpDecay.cpp index e8ac3d63edbf1a0e3bc81044c438d9e68523ecf1..c23d63849799f9062b65bad4aaceb76a57c37f39 100644 --- a/Framework/Muon/src/RemoveExpDecay.cpp +++ b/Framework/Muon/src/RemoveExpDecay.cpp @@ -178,8 +178,9 @@ HistogramData::Histogram MuonRemoveExpDecay::removeDecay( * @param wsIndex :: workspace index * @return normalisation constant */ -double MuonRemoveExpDecay::calNormalisationConst(API::MatrixWorkspace_sptr ws, - int wsIndex) { +double +MuonRemoveExpDecay::calNormalisationConst(const API::MatrixWorkspace_sptr &ws, + int wsIndex) { double retVal = 1.0; API::IAlgorithm_sptr fit; diff --git a/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h b/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h index 78f280b46e8d0f9ad1afc91651ef03cedf398a13..b0bfef20a031a1f49761228db6abbac5b70c1bfc 100644 --- a/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h +++ b/Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h @@ -36,8 +36,8 @@ namespace { // Set algorithm properties to sensible defaults (assuming data with 10 groups) // Use when specifying groups manually void setPairAlgorithmProperties(ApplyMuonDetectorGroupPairing &alg, - std::string inputWSName, - std::string wsGroupName) { + const std::string &inputWSName, + const std::string &wsGroupName) { alg.setProperty("SpecifyGroupsManually", true); alg.setProperty("PairName", "test"); alg.setProperty("Alpha", 1.0); @@ -58,8 +58,8 @@ void setPairAlgorithmProperties(ApplyMuonDetectorGroupPairing &alg, // Set algorithm properties to sensible defaults (assuming data with 10 groups) // Use when entering workspaces to pair void setPairAlgorithmPropertiesForInputWorkspace( - ApplyMuonDetectorGroupPairing &alg, std::string inputWSName, - std::string wsGroupName) { + ApplyMuonDetectorGroupPairing &alg, const std::string &inputWSName, + const std::string &wsGroupName) { alg.setProperty("SpecifyGroupsManually", false); alg.setProperty("PairName", "test"); alg.setProperty("Alpha", 1.0); @@ -72,7 +72,7 @@ void setPairAlgorithmPropertiesForInputWorkspace( // algorithm (a MatrixWorkspace and an empty group). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); wsGroup = boost::make_shared<WorkspaceGroup>(); AnalysisDataService::Instance().addOrReplace(groupWSName, wsGroup); diff --git a/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h b/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h index 44d16b3aaf7aab1103405f26cbabb79c2a97d464..08b59730bc17a4f72eb1601c8151d3fdc45022c1 100644 --- a/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h +++ b/Framework/Muon/test/ApplyMuonDetectorGroupingTest.h @@ -50,7 +50,7 @@ IAlgorithm_sptr algorithmWithPropertiesSet(const std::string &inputWSName, // algorithm (a MatrixWorkspace and an empty GroupWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); wsGroup = boost::make_shared<WorkspaceGroup>(); AnalysisDataService::Instance().addOrReplace(groupWSName, wsGroup); diff --git a/Framework/Muon/test/CalMuonDetectorPhasesTest.h b/Framework/Muon/test/CalMuonDetectorPhasesTest.h index 93c061a72b0e0bf93334bfdcb564e6190160ff9e..4fb6b5b283397c79a5d311c69e0b74f0222657bb 100644 --- a/Framework/Muon/test/CalMuonDetectorPhasesTest.h +++ b/Framework/Muon/test/CalMuonDetectorPhasesTest.h @@ -187,7 +187,7 @@ private: } /// Runs test of execution on the given workspace - void runExecutionTest(const MatrixWorkspace_sptr workspace) { + void runExecutionTest(const MatrixWorkspace_sptr &workspace) { auto calc = AlgorithmManager::Instance().create("CalMuonDetectorPhases"); calc->initialize(); calc->setChild(true); diff --git a/Framework/Muon/test/CalculateMuonAsymmetryTest.h b/Framework/Muon/test/CalculateMuonAsymmetryTest.h index a541963ed7fbd1058afa156d4fd23d7888cffb8f..5f97b2a47d66961e95bc6e501ceeaef49837043c 100644 --- a/Framework/Muon/test/CalculateMuonAsymmetryTest.h +++ b/Framework/Muon/test/CalculateMuonAsymmetryTest.h @@ -16,6 +16,8 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> +#include <utility> + #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/IFunction.h" #include "MantidAPI/ITableWorkspace.h" @@ -90,7 +92,7 @@ ITableWorkspace_sptr genTable() { return table; } -IAlgorithm_sptr setUpFuncAlg(std::vector<std::string> wsNames, +IAlgorithm_sptr setUpFuncAlg(const std::vector<std::string> &wsNames, const IFunction_sptr &func) { IAlgorithm_sptr asymmAlg = AlgorithmManager::Instance().create( "ConvertFitFunctionForMuonTFAsymmetry"); @@ -103,31 +105,32 @@ IAlgorithm_sptr setUpFuncAlg(std::vector<std::string> wsNames, return asymmAlg; } -IFunction_sptr genSingleFunc(std::vector<std::string> wsNames) { +IFunction_sptr genSingleFunc(const std::vector<std::string> &wsNames) { IFunction_sptr func = FunctionFactory::Instance().createInitialized( "name=GausOsc,Frequency=3.0"); - IAlgorithm_sptr alg = setUpFuncAlg(wsNames, func); + IAlgorithm_sptr alg = setUpFuncAlg(std::move(wsNames), func); alg->execute(); IFunction_sptr funcOut = alg->getProperty("OutputFunction"); return funcOut; } -IFunction_sptr genDoubleFunc(std::vector<std::string> wsNames) { +IFunction_sptr genDoubleFunc(const std::vector<std::string> &wsNames) { std::string multiFuncString = "composite=MultiDomainFunction,NumDeriv=1;"; multiFuncString += "name=GausOsc,$domains=i,Frequency=3.0;"; multiFuncString += "name=GausOsc,$domains=i,Frequency=3.0;"; IFunction_sptr func = FunctionFactory::Instance().createInitialized(multiFuncString); - IAlgorithm_sptr alg = setUpFuncAlg(wsNames, func); + IAlgorithm_sptr alg = setUpFuncAlg(std::move(wsNames), func); alg->execute(); IFunction_sptr funcOut = alg->getProperty("OutputFunction"); std::cout << funcOut << std::endl; return funcOut; } -IAlgorithm_sptr setUpAlg(ITableWorkspace_sptr &table, IFunction_sptr func, - std::vector<std::string> wsNamesNorm, - std::vector<std::string> wsOut) { +IAlgorithm_sptr setUpAlg(ITableWorkspace_sptr &table, + const IFunction_sptr &func, + const std::vector<std::string> &wsNamesNorm, + const std::vector<std::string> &wsOut) { IAlgorithm_sptr asymmAlg = AlgorithmManager::Instance().create("CalculateMuonAsymmetry"); asymmAlg->initialize(); diff --git a/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h b/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h index 2499f7c21a39c5adc3a33daeac069795a552a129..7d7b8c16f2a9bf274db135ac463fcd34999922c1 100644 --- a/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h +++ b/Framework/Muon/test/ConvertFitFunctionForMuonTFAsymmetryTest.h @@ -59,7 +59,7 @@ ITableWorkspace_sptr genTable() { return table; } -IAlgorithm_sptr setUpAlg(std::vector<std::string> wsNames, +IAlgorithm_sptr setUpAlg(const std::vector<std::string> &wsNames, const IFunction_sptr &func) { IAlgorithm_sptr asymmAlg = AlgorithmManager::Instance().create( "ConvertFitFunctionForMuonTFAsymmetry"); diff --git a/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h b/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h index cf4c786dbd90e8c55f6cf0cd676fcc9cbc807d7b..ee52ecb44b66dcd0e1bd8c1bb3423fcdace2c918 100644 --- a/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h +++ b/Framework/Muon/test/LoadAndApplyMuonDetectorGroupingTest.h @@ -43,7 +43,7 @@ algorithmWithPropertiesSet(const std::string &inputWSName, // algorithm (a MatrixWorkspace and an empty group). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); wsGroup = boost::make_shared<WorkspaceGroup>(); AnalysisDataService::Instance().addOrReplace(groupWSName, wsGroup); diff --git a/Framework/Muon/test/MuonGroupingAsymmetryTest.h b/Framework/Muon/test/MuonGroupingAsymmetryTest.h index 589608f3bd58701807eba3cd265e77b0f1095d10..66789bd98278f2c415ec4cfad7ddd58fb7dc2bfb 100644 --- a/Framework/Muon/test/MuonGroupingAsymmetryTest.h +++ b/Framework/Muon/test/MuonGroupingAsymmetryTest.h @@ -27,7 +27,7 @@ namespace { // algorithm (a MatrixWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; @@ -51,7 +51,7 @@ algorithmWithWorkspacePropertiesSet(const std::string &inputWSName) { // Set up algorithm without any optional properties // i.e. just the input workspace and group name. IAlgorithm_sptr -setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, +setUpAlgorithmWithoutOptionalProperties(const WorkspaceGroup_sptr &ws, const std::string &name, const std::vector<int> &grouping) { setUpADSWithWorkspace setup(ws); @@ -62,7 +62,7 @@ setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, } // Retrieve the output workspace from an executed algorithm -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr alg) { +MatrixWorkspace_sptr getOutputWorkspace(const IAlgorithm_sptr &alg) { MatrixWorkspace_sptr outputWS = alg->getProperty("OutputWorkspace"); return outputWS; } diff --git a/Framework/Muon/test/MuonGroupingCountsTest.h b/Framework/Muon/test/MuonGroupingCountsTest.h index 6eeef999d7149d68d57d6d00dede8e64d273c72e..bd42678b49d2a2c62e113b99639a97f13cf263c5 100644 --- a/Framework/Muon/test/MuonGroupingCountsTest.h +++ b/Framework/Muon/test/MuonGroupingCountsTest.h @@ -26,7 +26,7 @@ namespace { // algorithm (a MatrixWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; @@ -50,7 +50,7 @@ algorithmWithoutOptionalPropertiesSet(const std::string &inputWSName) { // Set up algorithm without any optional properties // i.e. just the input workspace and group name. IAlgorithm_sptr -setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, +setUpAlgorithmWithoutOptionalProperties(const WorkspaceGroup_sptr &ws, const std::string &name) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -60,7 +60,7 @@ setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, } // Set up algorithm with GroupName applied -IAlgorithm_sptr setUpAlgorithmWithGroupName(WorkspaceGroup_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithGroupName(const WorkspaceGroup_sptr &ws, const std::string &name) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -71,7 +71,7 @@ IAlgorithm_sptr setUpAlgorithmWithGroupName(WorkspaceGroup_sptr ws, // Set up algorithm with TimeOffset applied IAlgorithm_sptr -setUpAlgorithmWithGroupNameAndDetectors(WorkspaceGroup_sptr ws, +setUpAlgorithmWithGroupNameAndDetectors(const WorkspaceGroup_sptr &ws, const std::string &name, const std::vector<int> &detectors) { setUpADSWithWorkspace setup(ws); @@ -83,7 +83,7 @@ setUpAlgorithmWithGroupNameAndDetectors(WorkspaceGroup_sptr ws, } // Retrieve the output workspace from an executed algorithm -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr alg) { +MatrixWorkspace_sptr getOutputWorkspace(const IAlgorithm_sptr &alg) { Workspace_sptr outputWS = alg->getProperty("OutputWorkspace"); auto wsOut = boost::dynamic_pointer_cast<MatrixWorkspace>(outputWS); return wsOut; diff --git a/Framework/Muon/test/MuonPairingAsymmetryTest.h b/Framework/Muon/test/MuonPairingAsymmetryTest.h index ff748fb2031980bc1289df074b2f8d9a9aae31fb..3922da95028dce51f9576da968f299782199d57e 100644 --- a/Framework/Muon/test/MuonPairingAsymmetryTest.h +++ b/Framework/Muon/test/MuonPairingAsymmetryTest.h @@ -27,7 +27,7 @@ namespace { // algorithm (a MatrixWorkspace). class setUpADSWithWorkspace { public: - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; @@ -55,7 +55,7 @@ IAlgorithm_sptr algorithmWithoutOptionalPropertiesSet( // Set up algorithm without any optional properties. IAlgorithm_sptr -setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, +setUpAlgorithmWithoutOptionalProperties(const WorkspaceGroup_sptr &ws, const std::string &name) { const std::vector<int> group1 = {1, 2}; const std::vector<int> group2 = {3, 4}; @@ -67,7 +67,7 @@ setUpAlgorithmWithoutOptionalProperties(WorkspaceGroup_sptr ws, } // Set up algorithm with groupings -IAlgorithm_sptr setUpAlgorithmWithGroups(WorkspaceGroup_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithGroups(const WorkspaceGroup_sptr &ws, const std::vector<int> &group1, const std::vector<int> &group2) { setUpADSWithWorkspace setup(ws); @@ -78,8 +78,8 @@ IAlgorithm_sptr setUpAlgorithmWithGroups(WorkspaceGroup_sptr ws, // Set up algorithm to accept two group workspaces IAlgorithm_sptr -setUpAlgorithmWithGroupWorkspaces(MatrixWorkspace_sptr groupedWS1, - MatrixWorkspace_sptr groupedWS2) { +setUpAlgorithmWithGroupWorkspaces(const MatrixWorkspace_sptr &groupedWS1, + const MatrixWorkspace_sptr &groupedWS2) { auto alg = boost::make_shared<MuonPairingAsymmetry>(); alg->initialize(); alg->setProperty("SpecifyGroupsManually", false); @@ -94,8 +94,8 @@ setUpAlgorithmWithGroupWorkspaces(MatrixWorkspace_sptr groupedWS1, // Set up MuonPairingAsymmetry algorithm to accept two WorkspaceGroups IAlgorithm_sptr -setUpAlgorithmWithGroupWorkspaceGroups(WorkspaceGroup_sptr groupedWS1, - WorkspaceGroup_sptr groupedWS2) { +setUpAlgorithmWithGroupWorkspaceGroups(const WorkspaceGroup_sptr &groupedWS1, + const WorkspaceGroup_sptr &groupedWS2) { auto alg = boost::make_shared<MuonPairingAsymmetry>(); alg->setRethrows(true); alg->initialize(); @@ -110,7 +110,7 @@ setUpAlgorithmWithGroupWorkspaceGroups(WorkspaceGroup_sptr groupedWS1, } // Retrieve the output workspace from an executed algorithm -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr alg) { +MatrixWorkspace_sptr getOutputWorkspace(const IAlgorithm_sptr &alg) { MatrixWorkspace_sptr outputWS = alg->getProperty("OutputWorkspace"); return outputWS; } diff --git a/Framework/Muon/test/MuonPreProcessTest.h b/Framework/Muon/test/MuonPreProcessTest.h index 4ad8086d6ec647e5ab5ee1915f22443b751dbe53..c2554089ce3b936e4815103de9fd13e75f56ffa1 100644 --- a/Framework/Muon/test/MuonPreProcessTest.h +++ b/Framework/Muon/test/MuonPreProcessTest.h @@ -13,6 +13,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; @@ -41,22 +43,23 @@ class setUpADSWithWorkspace { public: std::string const inputWSName = "inputData"; - setUpADSWithWorkspace(Workspace_sptr ws) { + setUpADSWithWorkspace(const Workspace_sptr &ws) { AnalysisDataService::Instance().addOrReplace(inputWSName, ws); }; ~setUpADSWithWorkspace() { AnalysisDataService::Instance().clear(); }; }; // Set up algorithm with none of the optional properties -IAlgorithm_sptr setUpAlgorithmWithNoOptionalProperties(Workspace_sptr ws) { - setUpADSWithWorkspace setup(ws); +IAlgorithm_sptr +setUpAlgorithmWithNoOptionalProperties(const Workspace_sptr &ws) { + setUpADSWithWorkspace setup(std::move(ws)); IAlgorithm_sptr alg = algorithmWithoutOptionalPropertiesSet(setup.inputWSName); return alg; } // Set up algorithm with TimeOffset applied -IAlgorithm_sptr setUpAlgorithmWithTimeOffset(MatrixWorkspace_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithTimeOffset(const MatrixWorkspace_sptr &ws, const double &offset) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -67,8 +70,8 @@ IAlgorithm_sptr setUpAlgorithmWithTimeOffset(MatrixWorkspace_sptr ws, // Set up algorithm with DeadTimeTable applied IAlgorithm_sptr -setUpAlgorithmWithDeadTimeTable(MatrixWorkspace_sptr ws, - ITableWorkspace_sptr deadTimes) { +setUpAlgorithmWithDeadTimeTable(const MatrixWorkspace_sptr &ws, + const ITableWorkspace_sptr &deadTimes) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = algorithmWithoutOptionalPropertiesSet(setup.inputWSName); @@ -77,7 +80,7 @@ setUpAlgorithmWithDeadTimeTable(MatrixWorkspace_sptr ws, } // Set up algorithm with TimeMin applied -IAlgorithm_sptr setUpAlgorithmWithTimeMin(MatrixWorkspace_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithTimeMin(const MatrixWorkspace_sptr &ws, const double &timeMin) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -87,7 +90,7 @@ IAlgorithm_sptr setUpAlgorithmWithTimeMin(MatrixWorkspace_sptr ws, } // Set up algorithm with TimeMax applied -IAlgorithm_sptr setUpAlgorithmWithTimeMax(MatrixWorkspace_sptr ws, +IAlgorithm_sptr setUpAlgorithmWithTimeMax(const MatrixWorkspace_sptr &ws, const double &timeMax) { setUpADSWithWorkspace setup(ws); IAlgorithm_sptr alg = @@ -98,8 +101,8 @@ IAlgorithm_sptr setUpAlgorithmWithTimeMax(MatrixWorkspace_sptr ws, // Get the workspace at a particular index from the output workspace // group produced by the PreProcess alg -MatrixWorkspace_sptr getOutputWorkspace(IAlgorithm_sptr muonPreProcessAlg, - const int &index) { +MatrixWorkspace_sptr +getOutputWorkspace(const IAlgorithm_sptr &muonPreProcessAlg, const int &index) { WorkspaceGroup_sptr outputWS; outputWS = muonPreProcessAlg->getProperty("OutputWorkspace"); MatrixWorkspace_sptr wsOut = diff --git a/Framework/Muon/test/PhaseQuadMuonTest.h b/Framework/Muon/test/PhaseQuadMuonTest.h index 8f0969d7ae8e4e127173eb907d40d133dfe023c9..b6d69c4febb83353b6b7fad42cbfd329be45ef2d 100644 --- a/Framework/Muon/test/PhaseQuadMuonTest.h +++ b/Framework/Muon/test/PhaseQuadMuonTest.h @@ -17,6 +17,8 @@ #include "MantidDataObjects/TableWorkspace.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace Mantid::DataObjects; using namespace Mantid::API; @@ -25,8 +27,8 @@ namespace { const int dead1 = 4; const int dead2 = 12; -void populatePhaseTableWithDeadDetectors(ITableWorkspace_sptr phaseTable, - const MatrixWorkspace_sptr ws) { +void populatePhaseTableWithDeadDetectors(const ITableWorkspace_sptr &phaseTable, + const MatrixWorkspace_sptr &ws) { phaseTable->addColumn("int", "DetectprID"); phaseTable->addColumn("double", "Asymmetry"); phaseTable->addColumn("double", "phase"); @@ -42,7 +44,7 @@ void populatePhaseTableWithDeadDetectors(ITableWorkspace_sptr phaseTable, } } } -void populatePhaseTable(ITableWorkspace_sptr phaseTable, +void populatePhaseTable(const ITableWorkspace_sptr &phaseTable, std::vector<std::string> names, bool swap = false) { phaseTable->addColumn("int", names[0]); phaseTable->addColumn("double", names[1]); @@ -58,12 +60,14 @@ void populatePhaseTable(ITableWorkspace_sptr phaseTable, phaseRow2 << i << asym << phase; } } -void populatePhaseTable(ITableWorkspace_sptr phaseTable) { - populatePhaseTable(phaseTable, {"DetectorID", "Asymmetry", "Phase"}); +void populatePhaseTable(const ITableWorkspace_sptr &phaseTable) { + populatePhaseTable(std::move(phaseTable), + {"DetectorID", "Asymmetry", "Phase"}); } -IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg, - ITableWorkspace_sptr phaseTable) { +IAlgorithm_sptr setupAlg(const MatrixWorkspace_sptr &m_loadedData, + bool isChildAlg, + const ITableWorkspace_sptr &phaseTable) { // Set up PhaseQuad IAlgorithm_sptr phaseQuad = AlgorithmManager::Instance().create("PhaseQuad"); phaseQuad->setChild(isChildAlg); @@ -74,26 +78,28 @@ IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg, return phaseQuad; } -IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg) { +IAlgorithm_sptr setupAlg(const MatrixWorkspace_sptr &m_loadedData, + bool isChildAlg) { // Create and populate a detector table boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); populatePhaseTable(phaseTable); - return setupAlg(m_loadedData, isChildAlg, phaseTable); + return setupAlg(std::move(m_loadedData), isChildAlg, phaseTable); } -IAlgorithm_sptr setupAlg(MatrixWorkspace_sptr m_loadedData, bool isChildAlg, - std::vector<std::string> names, bool swap = false) { +IAlgorithm_sptr setupAlg(const MatrixWorkspace_sptr &m_loadedData, + bool isChildAlg, std::vector<std::string> names, + bool swap = false) { // Create and populate a detector table boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); - populatePhaseTable(phaseTable, names, swap); + populatePhaseTable(phaseTable, std::move(names), swap); - return setupAlg(m_loadedData, isChildAlg, phaseTable); + return setupAlg(std::move(m_loadedData), isChildAlg, phaseTable); } -IAlgorithm_sptr setupAlgDead(MatrixWorkspace_sptr m_loadedData) { +IAlgorithm_sptr setupAlgDead(const MatrixWorkspace_sptr &m_loadedData) { // Create and populate a detector table boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); @@ -102,7 +108,7 @@ IAlgorithm_sptr setupAlgDead(MatrixWorkspace_sptr m_loadedData) { return setupAlg(m_loadedData, true, phaseTable); } -MatrixWorkspace_sptr setupWS(MatrixWorkspace_sptr m_loadedData) { +MatrixWorkspace_sptr setupWS(const MatrixWorkspace_sptr &m_loadedData) { boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); MatrixWorkspace_sptr ws = m_loadedData->clone(); diff --git a/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h b/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h index 0ba3101577d7fa858d19fe6ad7fb80cdfcd079ee..7a8748dae8ffd7853cabea7dbe7d1c2c95dfa3e8 100644 --- a/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h +++ b/Framework/Nexus/inc/MantidNexus/MuonNexusReader.h @@ -48,7 +48,7 @@ private: /// file to base all NXlog times on std::time_t startTime_time_t; ///< startTime in time_t format std::time_t - to_time_t(boost::posix_time::ptime t) ///< convert posix time to time_t + to_time_t(const boost::posix_time::ptime &t) ///< convert posix time to time_t { /** Take the input Posix time, subtract the unix epoch, and return the seconds diff --git a/Framework/Nexus/inc/MantidNexus/NexusFileIO.h b/Framework/Nexus/inc/MantidNexus/NexusFileIO.h index a78851eb13c7436fd9365c4e7b5728f987bc2af0..e6b04b001935f8323cfba04eb3e91f75683d7694 100644 --- a/Framework/Nexus/inc/MantidNexus/NexusFileIO.h +++ b/Framework/Nexus/inc/MantidNexus/NexusFileIO.h @@ -83,7 +83,7 @@ public: float *errorSquareds, int64_t *pulsetimes, bool compress) const; int writeEventList(const DataObjects::EventList &el, - std::string group_name) const; + const std::string &group_name) const; template <class T> void writeEventListData(std::vector<T> events, bool writeTOF, @@ -103,7 +103,7 @@ public: const int &spectra) const; /// write bin masking information - bool writeNexusBinMasking(API::MatrixWorkspace_const_sptr ws) const; + bool writeNexusBinMasking(const API::MatrixWorkspace_const_sptr &ws) const; /// Reset the pointer to the progress object. void resetProgress(Mantid::API::Progress *prog); @@ -171,7 +171,7 @@ private: int findMantidWSEntries() const; /// convert posix time to time_t std::time_t - to_time_t(boost::posix_time::ptime t) ///< convert posix time to time_t + to_time_t(const boost::posix_time::ptime &t) ///< convert posix time to time_t { /** Take the input Posix time, subtract the unix epoch, and return the seconds @@ -202,7 +202,7 @@ private: /// Writes given vector column to the currently open Nexus file template <typename VecType, typename ElemType> - void writeNexusVectorColumn(API::Column_const_sptr col, + void writeNexusVectorColumn(const API::Column_const_sptr &col, const std::string &columnName, int nexusType, const std::string &interpret_as) const; diff --git a/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h b/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h index 5f191b93a878fc18323b63ced6fb9b8ada4a49b7..69de03ffe0d0817af6b2334228f7cf9bdf5a50af 100644 --- a/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h +++ b/Framework/Nexus/inc/MantidNexus/NexusIOHelper.h @@ -12,6 +12,9 @@ #include <nexus/NeXusFile.hpp> #include <numeric> #include <string> +#include <utility> + +#include <utility> namespace Mantid { namespace NeXus { @@ -46,8 +49,8 @@ namespace { throw std::runtime_error("Unknown type in Nexus file"); \ } -std::pair<::NeXus::Info, bool> checkIfOpenAndGetInfo(::NeXus::File &file, - std::string entry) { +std::pair<::NeXus::Info, bool> +checkIfOpenAndGetInfo(::NeXus::File &file, const std::string &&entry) { std::pair<::NeXus::Info, bool> info_and_close; info_and_close.second = false; if (!file.isDataSetOpen()) { @@ -160,8 +163,10 @@ T readNexusAnyVariable(::NeXus::File &file, bool close_file) { * and calls readNexusAnyVector via the RUN_NEXUSIOHELPER_FUNCTION macro. */ template <typename T> -std::vector<T> readNexusVector(::NeXus::File &file, std::string entry = "") { - auto info_and_close = checkIfOpenAndGetInfo(file, entry); +std::vector<T> readNexusVector(::NeXus::File &file, + const std::string &entry = "") { + auto info_and_close = + checkIfOpenAndGetInfo(file, std::move(std::move(entry))); auto dims = (info_and_close.first).dims; auto total_size = std::accumulate(dims.begin(), dims.end(), int64_t{1}, std::multiplies<>()); @@ -173,17 +178,19 @@ std::vector<T> readNexusVector(::NeXus::File &file, std::string entry = "") { * readNexusAnySlab via the RUN_NEXUSIOHELPER_FUNCTION macro. */ template <typename T> -std::vector<T> readNexusSlab(::NeXus::File &file, std::string entry, +std::vector<T> readNexusSlab(::NeXus::File &file, const std::string &entry, const std::vector<int64_t> &start, const std::vector<int64_t> &size) { - auto info_and_close = checkIfOpenAndGetInfo(file, entry); + auto info_and_close = + checkIfOpenAndGetInfo(file, std::move(std::move(entry))); RUN_NEXUSIOHELPER_FUNCTION((info_and_close.first).type, readNexusAnySlab, file, start, size, info_and_close.second); } template <typename T> -T readNexusValue(::NeXus::File &file, std::string entry = "") { - auto info_and_close = checkIfOpenAndGetInfo(file, entry); +T readNexusValue(::NeXus::File &file, const std::string &entry = "") { + auto info_and_close = + checkIfOpenAndGetInfo(file, std::move(std::move(entry))); RUN_NEXUSIOHELPER_FUNCTION((info_and_close.first).type, readNexusAnyVariable, file, info_and_close.second); } diff --git a/Framework/Nexus/src/NexusFileIO.cpp b/Framework/Nexus/src/NexusFileIO.cpp index 08cbbffce57bca7ff7320c18a1b1e8235076a806..c82b40f08d4b92432a2d88fc25de3e7b23edc960 100644 --- a/Framework/Nexus/src/NexusFileIO.cpp +++ b/Framework/Nexus/src/NexusFileIO.cpp @@ -574,7 +574,7 @@ size_t getSizeOf(const Kernel::V3D & /*unused*/) { return 3; } */ template <typename VecType, typename ElemType> void NexusFileIO::writeNexusVectorColumn( - Column_const_sptr col, const std::string &columnName, int nexusType, + const Column_const_sptr &col, const std::string &columnName, int nexusType, const std::string &interpret_as) const { ConstColumnVector<VecType> column(col); size_t rowCount = column.size(); @@ -893,7 +893,7 @@ void NexusFileIO::writeEventListData(std::vector<T> events, bool writeTOF, * @param group_name :: group_name to create. * */ int NexusFileIO::writeEventList(const DataObjects::EventList &el, - std::string group_name) const { + const std::string &group_name) const { // write data entry NXstatus status = NXmakegroup(fileID, group_name.c_str(), "NXdata"); if (status == NX_ERROR) @@ -1162,7 +1162,7 @@ bool NexusFileIO::checkEntryAtLevelByAttribute(const std::string &attribute, * @return true for OK, false for error */ bool NexusFileIO::writeNexusBinMasking( - API::MatrixWorkspace_const_sptr ws) const { + const API::MatrixWorkspace_const_sptr &ws) const { std::vector<int> spectra; std::vector<std::size_t> bins; std::vector<double> weights; diff --git a/Framework/Nexus/src/NexusHDF5Descriptor.cpp b/Framework/Nexus/src/NexusHDF5Descriptor.cpp index 39e0bbe6b122f0250f5e7b6e76a41ef601d72ee4..266397764a7f14be029287535602a87ba80e49cd 100644 --- a/Framework/Nexus/src/NexusHDF5Descriptor.cpp +++ b/Framework/Nexus/src/NexusHDF5Descriptor.cpp @@ -28,15 +28,12 @@ namespace { */ herr_t readStringAttribute(hid_t attr, char **data) { herr_t iRet = 0; - hid_t atype = -1; - hid_t space; - int ndims; - hsize_t thedims[H5S_MAX_RANK], sdim; - - atype = H5Aget_type(attr); - sdim = H5Tget_size(atype); - space = H5Aget_space(attr); - ndims = H5Sget_simple_extent_dims(space, thedims, NULL); + hsize_t thedims[H5S_MAX_RANK]; + + hid_t atype = H5Aget_type(attr); + hsize_t sdim = H5Tget_size(atype); + hid_t space = H5Aget_space(attr); + int ndims = H5Sget_simple_extent_dims(space, thedims, NULL); if (ndims == 0) { if (H5Tis_variable_str(atype)) { diff --git a/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h b/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h index 242cf870995c7d5d9583c6875d67f309a5026fec..24828bdff3ea60ee460c41bab6e59380ba929293 100644 --- a/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h +++ b/Framework/NexusGeometry/inc/MantidNexusGeometry/InstrumentBuilder.h @@ -37,9 +37,10 @@ public: Geometry::IComponent *addComponent(const std::string &compName, const Eigen::Vector3d &position); /// Adds tubes (ObjComponentAssemblies) to the last registered bank - void addTubes(const std::string &bankName, - const std::vector<detail::TubeBuilder> &tubes, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape); + void addTubes( + const std::string &bankName, + const std::vector<detail::TubeBuilder> &tubes, + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape); /// Adds detector to the root (instrument) void addDetectorToInstrument( const std::string &detName, detid_t detId, @@ -69,8 +70,9 @@ public: private: /// Add a single tube to the last registed bank - void doAddTube(const std::string &compName, const detail::TubeBuilder &tube, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape); + void doAddTube( + const std::string &compName, const detail::TubeBuilder &tube, + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape); /// Sorts detectors void sortDetectors() const; /// product diff --git a/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h b/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h index 2d297dff52035605203c7a1fead17c7189f83059..94626863f7d0b5c938f50a06625fb57cb6e03f2c 100644 --- a/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h +++ b/Framework/NexusGeometry/inc/MantidNexusGeometry/TubeBuilder.h @@ -25,7 +25,8 @@ Colinear detectors with cylindrical shape. class MANTID_NEXUSGEOMETRY_DLL TubeBuilder { public: TubeBuilder(const Mantid::Geometry::IObject &pixelShape, - Eigen::Vector3d firstDetectorPosition, int firstDetectorId); + const Eigen::Vector3d &firstDetectorPosition, + int firstDetectorId); const Eigen::Vector3d &tubePosition() const; const std::vector<Eigen::Vector3d> &detPositions() const; const std::vector<int> &detIDs() const; diff --git a/Framework/NexusGeometry/src/InstrumentBuilder.cpp b/Framework/NexusGeometry/src/InstrumentBuilder.cpp index 22df87101ee6b1330bf476575b0163eaa6302718..30e54b073b651495eed42fe143fae0d5550d25fc 100644 --- a/Framework/NexusGeometry/src/InstrumentBuilder.cpp +++ b/Framework/NexusGeometry/src/InstrumentBuilder.cpp @@ -14,6 +14,7 @@ #include "MantidNexusGeometry/NexusShapeFactory.h" #include <boost/make_shared.hpp> +#include <utility> namespace Mantid { namespace NexusGeometry { @@ -56,7 +57,7 @@ InstrumentBuilder::addComponent(const std::string &compName, */ void InstrumentBuilder::addTubes( const std::string &bankName, const std::vector<detail::TubeBuilder> &tubes, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape) { + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape) { for (size_t i = 0; i < tubes.size(); i++) doAddTube(bankName + "_tube_" + std::to_string(i), tubes[i], pixelShape); } @@ -68,7 +69,7 @@ void InstrumentBuilder::addTubes( */ void InstrumentBuilder::doAddTube( const std::string &compName, const detail::TubeBuilder &tube, - boost::shared_ptr<const Mantid::Geometry::IObject> pixelShape) { + const boost::shared_ptr<const Mantid::Geometry::IObject> &pixelShape) { auto *objComp(new Geometry::ObjCompAssembly(compName)); const auto &pos = tube.tubePosition(); objComp->setPos(pos(0), pos(1), pos(2)); @@ -98,7 +99,7 @@ void InstrumentBuilder::addDetectorToLastBank( detector->translate(Mantid::Kernel::toV3D(relativeOffset)); // No rotation set for detector pixels of a bank. This is not possible in the // Nexus Geometry specification. - detector->setShape(shape); + detector->setShape(std::move(shape)); m_lastBank->add(detector); m_instrument->markAsDetectorIncomplete(detector); } diff --git a/Framework/NexusGeometry/src/TubeBuilder.cpp b/Framework/NexusGeometry/src/TubeBuilder.cpp index cc73f59d596fd34e7dcd790d0e22d90a4b1a3f6c..c01c154a3e7d6816c4a18c8f96fdfb018c797180 100644 --- a/Framework/NexusGeometry/src/TubeBuilder.cpp +++ b/Framework/NexusGeometry/src/TubeBuilder.cpp @@ -17,7 +17,7 @@ namespace NexusGeometry { namespace detail { TubeBuilder::TubeBuilder(const Mantid::Geometry::IObject &pixelShape, - Eigen::Vector3d firstDetectorPosition, + const Eigen::Vector3d &firstDetectorPosition, int firstDetectorId) : m_pixelHeight(pixelShape.getGeometryHandler()->shapeInfo().height()), m_pixelRadius(pixelShape.getGeometryHandler()->shapeInfo().radius()) { diff --git a/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h b/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h index ccda1bfe2ec2b103f4ac7bef9fec4ba41c26b2e8..a058a511b4d0f1f3cd19a4f66b1f7369197d7acb 100644 --- a/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h +++ b/Framework/Parallel/inc/MantidParallel/IO/EventLoader.h @@ -37,13 +37,13 @@ MANTID_PARALLEL_DLL void load(const Communicator &communicator, const std::string &filename, const std::string &groupName, const std::vector<std::string> &bankNames, const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists); + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists); MANTID_PARALLEL_DLL void load(const std::string &filename, const std::string &groupName, const std::vector<std::string> &bankNames, const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists, bool precalcEvents); } // namespace EventLoader diff --git a/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h b/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h index 866894d4c5af6fd6f8a70f42f01e649d9b8664d2..9e0ff90110544551a05dd823c17027b7bc79537e 100644 --- a/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h +++ b/Framework/Parallel/inc/MantidParallel/IO/EventLoaderHelpers.h @@ -76,10 +76,11 @@ void load(const Chunker &chunker, NXEventDataSource<TimeOffsetType> &dataSource, } template <class TimeOffsetType> -void load(const Communicator &comm, const H5::Group &group, - const std::vector<std::string> &bankNames, - const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists) { +void load( + const Communicator &comm, const H5::Group &group, + const std::vector<std::string> &bankNames, + const std::vector<int32_t> &bankOffsets, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists) { // In tests loading from a single SSD this chunk size seems close to the // optimum. May need to be adjusted in the future (potentially dynamically) // when loading from parallel file systems and running on a cluster. diff --git a/Framework/Parallel/src/Communicator.cpp b/Framework/Parallel/src/Communicator.cpp index 0d8f458daf9a8a12ca7c52bb10aef1e7db2d2bcb..6e44485b03cc0773e16639103f149128527e969d 100644 --- a/Framework/Parallel/src/Communicator.cpp +++ b/Framework/Parallel/src/Communicator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidParallel/Communicator.h" #ifdef MPI_EXPERIMENTAL @@ -24,7 +26,7 @@ Communicator::Communicator(const boost::mpi::communicator &comm) Communicator::Communicator(boost::shared_ptr<detail::ThreadingBackend> backend, const int rank) - : m_backend(backend), m_rank(rank) {} + : m_backend(std::move(backend)), m_rank(rank) {} int Communicator::rank() const { if (m_backend) diff --git a/Framework/Parallel/src/IO/EventLoader.cpp b/Framework/Parallel/src/IO/EventLoader.cpp index 170795e68bb4db3e63b3951df0e83d8e0993070e..a4a0ba4641aa8ddf72bd277d992a46da5b1f8278 100644 --- a/Framework/Parallel/src/IO/EventLoader.cpp +++ b/Framework/Parallel/src/IO/EventLoader.cpp @@ -45,11 +45,11 @@ makeAnyEventIdToBankMap(const std::string &filename, } /// Load events from given banks into event lists using MPI. -void load(const Communicator &comm, const std::string &filename, - const std::string &groupName, - const std::vector<std::string> &bankNames, - const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists) { +void load( + const Communicator &comm, const std::string &filename, + const std::string &groupName, const std::vector<std::string> &bankNames, + const std::vector<int32_t> &bankOffsets, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists) { H5::H5File file(filename, H5F_ACC_RDONLY); H5::Group group = file.openGroup(groupName); load(readDataType(group, bankNames, "event_time_offset"), comm, group, @@ -60,7 +60,7 @@ void load(const Communicator &comm, const std::string &filename, void load(const std::string &filename, const std::string &groupname, const std::vector<std::string> &bankNames, const std::vector<int32_t> &bankOffsets, - std::vector<std::vector<Types::Event::TofEvent> *> eventLists, + const std::vector<std::vector<Types::Event::TofEvent> *> &eventLists, bool precalcEvents) { auto concurencyNumber = PARALLEL_GET_MAX_THREADS; auto numThreads = std::max<int>(concurencyNumber / 2, 1); diff --git a/Framework/Properties/Mantid.properties.template b/Framework/Properties/Mantid.properties.template index aa98016f34e54182ce72ffdff53cd35db52ca658..028a3ecc5a97239449801f6056cc479da7d51882 100644 --- a/Framework/Properties/Mantid.properties.template +++ b/Framework/Properties/Mantid.properties.template @@ -111,9 +111,6 @@ icatDownload.directory = # ICat mount point. Directory where archive is mounted. See Facility.xml filelocation. icatDownload.mountPoint = -# The Number of algorithms properties to retain im memory for refence in scripts. -algorithms.retained = 50 - # Defines the maximum number of cores to use for OpenMP # For machine default set to 0 MultiThreaded.MaxCores = 0 diff --git a/Framework/PythonInterface/mantid/__init__.py b/Framework/PythonInterface/mantid/__init__.py index abc301bbd94be03a430f33fa67914b7c0676e686..42caea480daf7b294f3f57bd81f7ba8b9a7007b3 100644 --- a/Framework/PythonInterface/mantid/__init__.py +++ b/Framework/PythonInterface/mantid/__init__.py @@ -22,8 +22,7 @@ algorithms and data objects that are: Implementing Algorithms, Virtual Instrument Geometry. """ -from __future__ import (absolute_import, division, - print_function) + import os import sys diff --git a/Framework/PythonInterface/mantid/_plugins/__init__.py b/Framework/PythonInterface/mantid/_plugins/__init__.py index 136498795eb8b107d73b82104af24e17d8af4a81..1d7a9d6f68822d652ca724296044c840fee6f421 100644 --- a/Framework/PythonInterface/mantid/_plugins/__init__.py +++ b/Framework/PythonInterface/mantid/_plugins/__init__.py @@ -19,8 +19,7 @@ and so methods, such as __len__() & add() inherited from CompositeFunction are m The names from the library are not imported by default as it is best if the interface classes are used for checks such as isinstance() """ -from __future__ import (absolute_import, division, - print_function) + ############################################################################### # Load the C++ library and register the C++ class exports diff --git a/Framework/PythonInterface/mantid/api/__init__.py b/Framework/PythonInterface/mantid/api/__init__.py index 0ec0bf31a23969d086193f1a2fd196f52491a01c..bf2877e0a6c0da28d0199d6c8a89ac860c4c8268 100644 --- a/Framework/PythonInterface/mantid/api/__init__.py +++ b/Framework/PythonInterface/mantid/api/__init__.py @@ -11,8 +11,6 @@ api Defines Python objects that wrap the C++ API namespace. """ -from __future__ import absolute_import - ############################################################################### # Load the C++ library ############################################################################### @@ -42,4 +40,3 @@ from mantid.api import _adsimports # Make aliases accessible in this namespace ############################################################################### from mantid.api._aliases import * - diff --git a/Framework/PythonInterface/mantid/api/_aliases.py b/Framework/PythonInterface/mantid/api/_aliases.py index a5ccca32168fabb18d048e0ff7e67c2c23dfc7bb..274e005b7a7bd761e1e1c600a371425d7a4cafb0 100644 --- a/Framework/PythonInterface/mantid/api/_aliases.py +++ b/Framework/PythonInterface/mantid/api/_aliases.py @@ -7,8 +7,6 @@ """ Defines a set of aliases to make accessing certain objects easier """ -from __future__ import absolute_import - from mantid.api import (AlgorithmFactoryImpl, AlgorithmManagerImpl, AnalysisDataServiceImpl, CatalogManagerImpl, FileFinderImpl, FileLoaderRegistryImpl, FrameworkManagerImpl, FunctionFactoryImpl, WorkspaceFactoryImpl) diff --git a/Framework/PythonInterface/mantid/api/_workspaceops.py b/Framework/PythonInterface/mantid/api/_workspaceops.py index f128e77c9b72314b68e64162c293529cb72b0a7e..ab1319e0608b7cca4cd5c8745ba4b5aef043064e 100644 --- a/Framework/PythonInterface/mantid/api/_workspaceops.py +++ b/Framework/PythonInterface/mantid/api/_workspaceops.py @@ -10,13 +10,12 @@ It is intended for internal use. """ -from __future__ import (absolute_import, division, - print_function) + import inspect as _inspect import sys -from six import Iterator, get_function_code, iteritems +from inspect import getsource from mantid.api import AnalysisDataServiceImpl, ITableWorkspace, Workspace, WorkspaceGroup, performBinaryOp from mantid.kernel.funcinspect import customise_func, lhs_info @@ -63,7 +62,7 @@ def attach_binary_operators_to_workspace(): operations["Divide"] = divops # Loop through and add each one in turn - for alg, attributes in iteritems(operations): + for alg, attributes in operations.items(): if type(attributes) == str: attributes = [attributes] for attr in attributes: add_operator_func(attr, alg, attr.startswith('__i'), attr.startswith('__r')) @@ -149,7 +148,7 @@ def attach_unary_operators_to_workspace(): 'NotMD': '__invert__' } # Loop through and add each one in turn - for alg, attributes in iteritems(operations): + for alg, attributes in operations.items(): if type(attributes) == str: attributes = [attributes] for attr in attributes: add_operator_func(attr, alg) @@ -204,7 +203,7 @@ def attach_tableworkspaceiterator(): """Attaches the iterator code to a table workspace.""" def __iter_method(self): - class ITableWorkspaceIter(Iterator): + class ITableWorkspaceIter(object): def __init__(self, wksp): self.__wksp = wksp self.__pos = 0 @@ -254,7 +253,7 @@ def attach_func_as_method(name, func_obj, self_param_name, workspace_types=None) signature = func_obj.__signature__.replace(parameters=func_parameters) else: signature = ['self'] - signature.extend(get_function_code(func_obj).co_varnames) + signature.extend(getsource(func_obj).co_varnames) signature = tuple(signature) customise_func(_method_impl, func_obj.__name__, signature, func_obj.__doc__) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp index 03a7faa6ae71c64cb9aebe4f406d55a587cf26f4..f45dc113d3dc90b82666184de2d443d2470be767 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmHistory.cpp @@ -27,7 +27,7 @@ using namespace boost::python; * @returns A python list created from the set of child algorithm histories */ boost::python::list -getChildrenAsList(boost::shared_ptr<AlgorithmHistory> self) { +getChildrenAsList(const boost::shared_ptr<AlgorithmHistory> &self) { boost::python::list names; const auto histories = self->getChildHistories(); for (const auto &history : histories) { diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp index f851ae4a710f04aa39cb8b84c5c8474cbd03fc09..8379c24ee2b27b440da24dd697a62c41d7887d29 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp @@ -109,9 +109,6 @@ void export_AlgorithmManager() { "Creates an unmanaged algorithm.")) .def("size", &AlgorithmManagerImpl::size, arg("self"), "Returns the number of managed algorithms") - .def("setMaxAlgorithms", &AlgorithmManagerImpl::setMaxAlgorithms, - (arg("self"), arg("n")), - "Set the maximum number of allowed managed algorithms") .def("getAlgorithm", &getAlgorithm, (arg("self"), arg("id_holder")), "Return the algorithm instance identified by the given id.") .def("removeById", &removeById, (arg("self"), arg("id_holder")), diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp index d42b9dd3121ae389ec978da825f19e7da051030d..867fcfa855f781f3293036d69aea563a63c6a2c3 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmObserver.cpp @@ -14,22 +14,23 @@ using namespace Mantid::API; using namespace Mantid::PythonInterface; using namespace boost::python; -void observeFinish(AlgorithmObserver &self, boost::python::object alg) { +void observeFinish(AlgorithmObserver &self, const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.observeFinish(calg); } -void observeError(AlgorithmObserver &self, boost::python::object alg) { +void observeError(AlgorithmObserver &self, const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.observeError(calg); } -void observeProgress(AlgorithmObserver &self, boost::python::object alg) { +void observeProgress(AlgorithmObserver &self, + const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.observeProgress(calg); } -void stopObserving(AlgorithmObserver &self, boost::python::object alg) { +void stopObserving(AlgorithmObserver &self, const boost::python::object &alg) { IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg); self.stopObserving(calg); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp b/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp index 867883010c07206c96df29e236350489308e119d..b03273526f03c7319b213b730ff96175d69be391 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp @@ -39,7 +39,8 @@ GNU_DIAG_ON("unused-local-typedef") * combination of exts_list and facility_exts. */ std::vector<std::string> runFinderProxy(FileFinderImpl &self, - std::string hintstr, list exts_list, + const std::string &hintstr, + list exts_list, const bool useExtsOnly) { // Convert python list to c++ vector std::vector<std::string> exts; diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp index e5245a9dc57d7a5ab08390f7c6c418602886d589..2817282c22a6f4eb76c0244630cee66a2481032c 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IPeaksWorkspace.cpp @@ -16,6 +16,7 @@ #include <boost/python/iterator.hpp> #include <boost/python/manage_new_object.hpp> #include <boost/python/return_internal_reference.hpp> +#include <utility> using namespace boost::python; using namespace Mantid::Geometry; @@ -102,7 +103,7 @@ public: throw std::runtime_error(columnName + " is a read only column of a peaks workspace"); } - m_setterMap[columnName](peak, value); + m_setterMap[columnName](peak, std::move(value)); } private: @@ -122,7 +123,7 @@ private: * setter's value type */ template <typename T> SetterType setterFunction(MemberFunc<T> func) { - return [func](IPeak &peak, const object value) { + return [func](IPeak &peak, const object &value) { extract<T> extractor{value}; if (!extractor.check()) { throw std::runtime_error( @@ -143,7 +144,7 @@ private: * setter's value type */ SetterType setterFunction(MemberFuncV3D func) { - return [func](IPeak &peak, const object value) { + return [func](IPeak &peak, const object &value) { extract<const V3D &> extractor{value}; if (!extractor.check()) { throw std::runtime_error( diff --git a/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp b/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp index deaa6bd6c3d466b4adb6c90410f001b1312e4fc7..e2bf4e2c7df6e19541d7a5b324d59385cc38edae 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp @@ -82,7 +82,7 @@ namespace { * @param typeID The python identifier of the column type. * @param row The row to get the value from. */ -PyObject *getValue(Mantid::API::Column_const_sptr column, +PyObject *getValue(const Mantid::API::Column_const_sptr &column, const std::type_info &typeID, const int row) { if (typeID.hash_code() == typeid(Mantid::API::Boolean).hash_code()) { bool res = column->cell<Mantid::API::Boolean>(row); @@ -129,7 +129,7 @@ PyObject *getValue(Mantid::API::Column_const_sptr column, * @param row :: The index of the row * @param value :: The value to set */ -void setValue(const Column_sptr column, const int row, const object &value) { +void setValue(const Column_sptr &column, const int row, const object &value) { const auto &typeID = column->get_type_info(); // Special case: Treat Mantid Boolean as normal bool @@ -542,7 +542,7 @@ public: return data; } - static void setstate(ITableWorkspace &ws, dict state) { + static void setstate(ITableWorkspace &ws, const dict &state) { readMetaData(ws, state); readData(ws, state); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp b/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp index 86e71d566f2421aa2344ef38143eb10094339f54..1a7e17e2221e264269fef95550ce39d5af8e889c 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/Run.cpp @@ -16,6 +16,7 @@ #include <boost/python/list.hpp> #include <boost/python/overloads.hpp> #include <boost/python/register_ptr_to_python.hpp> +#include <utility> using Mantid::API::LogManager; using Mantid::API::Run; @@ -103,7 +104,7 @@ void addOrReplaceProperty(Run &self, const std::string &name, * @param key The key * @param default_ The default to return if it does not exist */ -bpl::object getWithDefault(bpl::object self, bpl::object key, +bpl::object getWithDefault(bpl::object self, const bpl::object &key, bpl::object default_) { bpl::object exists(self.attr("__contains__")); if (extract<bool>(exists(key))()) { @@ -119,8 +120,8 @@ bpl::object getWithDefault(bpl::object self, bpl::object key, * @param self The bpl::object called on * @param key The key */ -bpl::object get(bpl::object self, bpl::object key) { - return getWithDefault(self, key, bpl::object()); +bpl::object get(bpl::object self, const bpl::object &key) { + return getWithDefault(std::move(self), std::move(key), bpl::object()); } /** diff --git a/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp b/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp index 6428d5c8bd162ceddbed655fa74f46658ab566a0..bda56715c423d33730655f195409509e39a039fd 100644 --- a/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp +++ b/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp @@ -10,6 +10,7 @@ #include <boost/python/class.hpp> #include <boost/python/list.hpp> +#include <utility> #define PY_ARRAY_UNIQUE_SYMBOL API_ARRAY_API #define NO_IMPORT_ARRAY @@ -80,7 +81,7 @@ IFunction::Attribute createAttributeFromPythonValue(const object &value) { IFunctionAdapter::IFunctionAdapter(PyObject *self, std::string functionMethod, std::string derivMethod) : m_self(self), m_functionName(std::move(functionMethod)), - m_derivName(derivMethod), + m_derivName(std::move(derivMethod)), m_derivOveridden(typeHasAttribute(self, m_derivName.c_str())) { if (!typeHasAttribute(self, "init")) throw std::runtime_error("Function does not define an init method."); diff --git a/Framework/PythonInterface/mantid/dataobjects/__init__.py b/Framework/PythonInterface/mantid/dataobjects/__init__.py index 5bd41720c97e3a39248657ce9315296171ab4b7f..28de58bc65e691236c35539a299fd88618310ef4 100644 --- a/Framework/PythonInterface/mantid/dataobjects/__init__.py +++ b/Framework/PythonInterface/mantid/dataobjects/__init__.py @@ -19,8 +19,6 @@ downcast to the correct leaf type if the export for that class exists in the reg The names from the library are not imported by default as it is best if the interface classes are used for checks such as isinstance() """ -from __future__ import absolute_import - ############################################################################### # Load the C++ library and register the C++ class exports ############################################################################### diff --git a/Framework/PythonInterface/mantid/geometry/__init__.py b/Framework/PythonInterface/mantid/geometry/__init__.py index c982060c841fd18b7e689e5ff5f944fe463e0c70..6e20006e045a3028dbd013cbe0a9a8599b4f15c2 100644 --- a/Framework/PythonInterface/mantid/geometry/__init__.py +++ b/Framework/PythonInterface/mantid/geometry/__init__.py @@ -11,8 +11,6 @@ mantid.geometry Defines Python objects that wrap the C++ Geometry namespace. """ -from __future__ import absolute_import - ############################################################################### # Load the C++ library ############################################################################### diff --git a/Framework/PythonInterface/mantid/geometry/_aliases.py b/Framework/PythonInterface/mantid/geometry/_aliases.py index 651fc5acd8251cc618c725af435faf086b4c9057..7c0bb2d932ebd021f05b594b65c7418b7856066f 100644 --- a/Framework/PythonInterface/mantid/geometry/_aliases.py +++ b/Framework/PythonInterface/mantid/geometry/_aliases.py @@ -8,8 +8,7 @@ Defines a set of aliases to make accessing certain objects easier, like in mantid.api. """ -from __future__ import (absolute_import, division, - print_function) + from mantid.kernel._aliases import lazy_instance_access from mantid.geometry import (SpaceGroupFactoryImpl, SymmetryOperationFactoryImpl, diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp index a2880c72ca7c4cb6d93555f4ab3318fad0e334b6..5811c325eb7e6364637075a26812bf233f720a9a 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp @@ -30,7 +30,7 @@ namespace //<unnamed> using namespace Mantid::PythonInterface; /// Pass-through function to set the unit cell from a 2D numpy array -void recalculateFromGstar(UnitCell &self, object values) { +void recalculateFromGstar(UnitCell &self, const object &values) { // Create a double matrix and put this in to the unit cell self.recalculateFromGstar(Converters::PyObjectToMatrix(values)()); } diff --git a/Framework/PythonInterface/mantid/kernel/__init__.py b/Framework/PythonInterface/mantid/kernel/__init__.py index 888f203deab3573d6457fc826ebb5603a11f3277..47ceca9922713187f9a080aa0181defe080f7f5c 100644 --- a/Framework/PythonInterface/mantid/kernel/__init__.py +++ b/Framework/PythonInterface/mantid/kernel/__init__.py @@ -11,8 +11,6 @@ kernel Defines Python objects that wrap the C++ Kernel namespace. """ -from __future__ import absolute_import - ############################################################################### # Make modules available in this namespace ############################################################################### diff --git a/Framework/PythonInterface/mantid/kernel/_aliases.py b/Framework/PythonInterface/mantid/kernel/_aliases.py index d4a217c0c0be6b3d519b055656227175042babfa..a12a32b7c330b79fde96b08bb467f60b51dbbc2a 100644 --- a/Framework/PythonInterface/mantid/kernel/_aliases.py +++ b/Framework/PythonInterface/mantid/kernel/_aliases.py @@ -8,8 +8,7 @@ Defines a set of aliases for the kernel module to make accessing certain objects easier. """ -from __future__ import (absolute_import, division, - print_function) + from mantid.kernel import (ConfigServiceImpl, Logger, PropertyManagerDataServiceImpl, UnitFactoryImpl, UsageServiceImpl) diff --git a/Framework/PythonInterface/mantid/kernel/funcinspect.py b/Framework/PythonInterface/mantid/kernel/funcinspect.py index ce5a1611cf84d4afc07155ff123ccbe70b4a44e2..285fb8bec50ba2b4c5cafe28513ba67bc7ba9583 100644 --- a/Framework/PythonInterface/mantid/kernel/funcinspect.py +++ b/Framework/PythonInterface/mantid/kernel/funcinspect.py @@ -12,13 +12,11 @@ arguments that are being assigned to a function return """ -from __future__ import (absolute_import, division, - print_function) + import opcode import inspect import sys import dis -from six import PY3 def replace_signature(func, signature): @@ -77,6 +75,8 @@ def customise_func(func, name, signature, docstring): return func #------------------------------------------------------------------------------- + + def decompile(code_object): """ Taken from @@ -108,45 +108,8 @@ def decompile(code_object): ins = decompile(f.f_code) """ instructions = [] - - if PY3: - for ins in dis.get_instructions(code_object): - instructions.append( (ins.offset, ins.opcode, ins.opname, ins.arg, ins.argval) ) - else: - code = code_object.co_code - variables = code_object.co_cellvars + code_object.co_freevars - n = len(code) - i = 0 - e = 0 - while i < n: - i_offset = i - i_opcode = ord(code[i]) - i = i + 1 - if i_opcode >= opcode.HAVE_ARGUMENT: - i_argument = ord(code[i]) + (ord(code[i+1]) << (4*2)) + e - i = i + 2 - if i_opcode == opcode.EXTENDED_ARG: - e = i_argument << 16 - else: - e = 0 - if i_opcode in opcode.hasconst: - i_arg_value = repr(code_object.co_consts[i_argument]) - elif i_opcode in opcode.hasname: - i_arg_value = code_object.co_names[i_argument] - elif i_opcode in opcode.hasjrel: - i_arg_value = repr(i + i_argument) - elif i_opcode in opcode.haslocal: - i_arg_value = code_object.co_varnames[i_argument] - elif i_opcode in opcode.hascompare: - i_arg_value = opcode.cmp_op[i_argument] - elif i_opcode in opcode.hasfree: - i_arg_value = variables[i_argument] - else: - i_arg_value = i_argument - else: - i_argument = None - i_arg_value = None - instructions.append( (i_offset, i_opcode, opcode.opname[i_opcode], i_argument, i_arg_value) ) + for ins in dis.get_instructions(code_object): + instructions.append( (ins.offset, ins.opcode, ins.opname, ins.arg, ins.argval) ) return instructions #------------------------------------------------------------------------------- @@ -168,6 +131,7 @@ __operator_names = set(['CALL_FUNCTION', 'CALL_FUNCTION_VAR', 'CALL_FUNCTION_KW' 'CALL_FUNCTION_EX', 'LOAD_METHOD', 'CALL_METHOD']) #-------------------------------------------------------------------------------------- + def process_frame(frame): """Returns the number of arguments on the left of assignment along with the names of the variables for the given frame. @@ -256,6 +220,7 @@ def process_frame(frame): #------------------------------------------------------------------------------- + def lhs_info(output_type='both', frame=None): """Returns the number of arguments on the left of assignment along with the names of the variables. diff --git a/Framework/PythonInterface/mantid/kernel/plugins.py b/Framework/PythonInterface/mantid/kernel/plugins.py index fe28799d80d567ddf5e35e04a8146bf7c125d06f..168d84ad234d89e7602853e880085b6222611544 100644 --- a/Framework/PythonInterface/mantid/kernel/plugins.py +++ b/Framework/PythonInterface/mantid/kernel/plugins.py @@ -10,8 +10,7 @@ Defines functions to dynamically load Python modules. These modules may define extensions to C++ types, e.g. algorithms, fit functions etc. """ -from __future__ import (absolute_import, division, - print_function) + import os as _os import sys as _sys @@ -39,6 +38,7 @@ from . import logger, Logger, config # String that separates paths (should be in the ConfigService) PATH_SEPARATOR=";" + class PluginLoader(object): extension = ".py" @@ -69,6 +69,7 @@ class PluginLoader(object): # High-level functions to assist with loading #====================================================================================================================== + def get_plugin_paths_as_set(key): """ Returns the value of the given key in the config service @@ -82,6 +83,7 @@ def get_plugin_paths_as_set(key): s.remove('') return s + def check_for_plugins(top_dir): """ Runs a quick check to see if any plugin files exist in the given directory @@ -120,6 +122,7 @@ def find_plugins(top_dir): #====================================================================================================================== + def load(path): """ High-level function to import the module(s) on the given path. @@ -152,6 +155,7 @@ def load(path): #====================================================================================================================== + def load_from_list(paths): """ Load all modules in the given list @@ -169,6 +173,7 @@ def load_from_list(paths): #====================================================================================================================== + def load_from_dir(directory): """ Load all modules in the given directory @@ -184,6 +189,7 @@ def load_from_dir(directory): #====================================================================================================================== + def load_from_file(filepath): """ Loads the plugin file. Any code present at the top-level will @@ -201,6 +207,7 @@ def load_from_file(filepath): #====================================================================================================================== + def load_plugin(plugin_path): """ Load a plugin and return the name & module object @@ -216,6 +223,7 @@ def load_plugin(plugin_path): #====================================================================================================================== + def sync_attrs(source, attrs, clients): """ Syncs the attribute definitions between the @@ -235,6 +243,7 @@ def sync_attrs(source, attrs, clients): #====================================================================================================================== + def contains_algorithm(filename): """ Inspects the file to look for an algorithm registration line diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp index 9fdb7d3f4cd22398b724503ab734259c2bf80093..0c904dd32a933aaabfafa7ac1c29fad7989cdcf0 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp @@ -114,7 +114,7 @@ template <> std::string dtype(ArrayProperty<std::string> &self) { template <typename T> ArrayProperty<T> *createArrayPropertyFromList(const std::string &name, const boost::python::list &values, - IValidator_sptr validator, + const IValidator_sptr &validator, const unsigned int direction) { return new ArrayProperty<T>(name, Converters::PySequenceToVector<T>(values)(), validator, direction); @@ -130,10 +130,10 @@ ArrayProperty<T> *createArrayPropertyFromList(const std::string &name, * @return */ template <typename T> -ArrayProperty<T> *createArrayPropertyFromNDArray(const std::string &name, - const NDArray &values, - IValidator_sptr validator, - const unsigned int direction) { +ArrayProperty<T> * +createArrayPropertyFromNDArray(const std::string &name, const NDArray &values, + const IValidator_sptr &validator, + const unsigned int direction) { return new ArrayProperty<T>(name, Converters::NDArrayToVector<T>(values)(), validator, direction); } diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp index f2cc1cb0d7b112b144dda737a21f40db740ff381..685993a4f756f33f3aac3547f919d69b1258b328 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/CompositeValidator.cpp @@ -52,7 +52,7 @@ void export_CompositeValidator() { &createCompositeValidator, default_call_policies(), (arg("validators"), arg("relation") = CompositeRelation::AND))) .def("add", - (void (CompositeValidator::*)(IValidator_sptr)) & + (void (CompositeValidator::*)(const IValidator_sptr &)) & CompositeValidator::add, (arg("self"), arg("other")), "Add another validator to the list"); } diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp index 0ff4fb1eb7532d28a903c9c5bbb7dc9c27eaf99f..ebff49089ca1d8169b915cb0698789548fd5e6fc 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp @@ -76,7 +76,7 @@ void setProperties(IPropertyManager &self, const boost::python::dict &kwargs) { * @param value :: The value of the property as a bpl object */ void declareProperty(IPropertyManager &self, const std::string &name, - boost::python::object value) { + const boost::python::object &value) { auto p = std::unique_ptr<Property>( Registry::PropertyWithValueFactory::create(name, value, 0)); self.declareProperty(std::move(p)); @@ -91,7 +91,7 @@ void declareProperty(IPropertyManager &self, const std::string &name, * @param value :: The value of the property as a bpl object */ void declareOrSetProperty(IPropertyManager &self, const std::string &name, - boost::python::object value) { + const boost::python::object &value) { bool propExists = self.existsProperty(name); if (propExists) { setProperty(self, name, value); diff --git a/Framework/PythonInterface/mantid/plots/__init__.py b/Framework/PythonInterface/mantid/plots/__init__.py index 587580b72012e24d942c9a392433d634fb7890cf..496ddae931d4594343113e46b3587fe926be1843 100644 --- a/Framework/PythonInterface/mantid/plots/__init__.py +++ b/Framework/PythonInterface/mantid/plots/__init__.py @@ -13,9 +13,6 @@ Functionality for unpacking mantid objects for plotting with matplotlib. # This file should be left free of PyQt imports to allow quick importing # of the main package. -from __future__ import (absolute_import, division, print_function) - - try: from collections.abc import Iterable except ImportError: diff --git a/Framework/PythonInterface/mantid/plots/_compatability.py b/Framework/PythonInterface/mantid/plots/_compatability.py index fb1b13958c3920b23dd2bf874bd2ff9956f4f68d..131fa3ccbf9736bcf05b2e78931eb750fff96c12 100644 --- a/Framework/PythonInterface/mantid/plots/_compatability.py +++ b/Framework/PythonInterface/mantid/plots/_compatability.py @@ -7,8 +7,6 @@ # This file is part of the mantid package # # -from __future__ import (absolute_import, division, print_function) - # local imports from mantid.kernel import Logger from mantid.plots.utility import MantidAxType @@ -21,6 +19,8 @@ LOGGER = Logger("mantid.plots.plotCompatability") # ================================================ # Compatability functions # ================================================ + + def plotSpectrum(workspaces, indices=None, distribution=None, error_bars=False, type=None, window=None, clearWindow=None, waterfall=None, spectrum_nums=None): @@ -97,4 +97,3 @@ def _report_deprecated_parameter(param_name,param_value): """Logs a warning message if the parameter value is not None""" if param_value is not None: LOGGER.warning("The argument '{}' is not supported in workbench and has been ignored".format(param_name)) - diff --git a/Framework/PythonInterface/mantid/plots/axesfunctions.py b/Framework/PythonInterface/mantid/plots/axesfunctions.py index 8fc4fdd66257c37c1c6d15b3e9efca0632e262a9..e70153a4e6497b722d96aac1fab022a387df4623 100644 --- a/Framework/PythonInterface/mantid/plots/axesfunctions.py +++ b/Framework/PythonInterface/mantid/plots/axesfunctions.py @@ -7,8 +7,6 @@ # This file is part of the mantid package # # -from __future__ import (absolute_import, division, print_function) - import collections import matplotlib import matplotlib.collections as mcoll diff --git a/Framework/PythonInterface/mantid/plots/axesfunctions3D.py b/Framework/PythonInterface/mantid/plots/axesfunctions3D.py index aff2d05efb079cbf52759a50751288bd7608ea14..708a48551d0bf4a470204152f8f3fef132ea5449 100644 --- a/Framework/PythonInterface/mantid/plots/axesfunctions3D.py +++ b/Framework/PythonInterface/mantid/plots/axesfunctions3D.py @@ -7,8 +7,6 @@ # This file is part of the mantid package # # -from __future__ import (absolute_import, division, print_function) - import numpy from mantid.plots.datafunctions import (get_axes_labels, get_normalization, get_distribution, diff --git a/Framework/PythonInterface/mantid/plots/datafunctions.py b/Framework/PythonInterface/mantid/plots/datafunctions.py index f86b46e53bd58b5f402b81860e4a79937f184a32..6d6c2b7c0985ccb8cc81b826c033538f61e98c31 100644 --- a/Framework/PythonInterface/mantid/plots/datafunctions.py +++ b/Framework/PythonInterface/mantid/plots/datafunctions.py @@ -7,8 +7,6 @@ # This file is part of the mantid package # # -from __future__ import (absolute_import, division, print_function) - import datetime import numpy as np diff --git a/Framework/PythonInterface/mantid/plots/legend.py b/Framework/PythonInterface/mantid/plots/legend.py index af84c91242f1b2a37b6014c36032d43d0c3dd0c0..64417338abacd60e5aa21d174c2118a197d35815 100644 --- a/Framework/PythonInterface/mantid/plots/legend.py +++ b/Framework/PythonInterface/mantid/plots/legend.py @@ -10,8 +10,6 @@ """ Functionality for dealing with legends on plots """ -from __future__ import (absolute_import, division, print_function) - import sys import matplotlib diff --git a/Framework/PythonInterface/mantid/plots/mantidaxes.py b/Framework/PythonInterface/mantid/plots/mantidaxes.py index a9c7f4482fa1c3e75e2000739c3f3d1b48754cc2..a0300b7205000cd410f37444deaed190afc9aac8 100644 --- a/Framework/PythonInterface/mantid/plots/mantidaxes.py +++ b/Framework/PythonInterface/mantid/plots/mantidaxes.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid package -from __future__ import absolute_import - try: from collections.abc import Iterable except ImportError: @@ -37,6 +35,8 @@ WATERFALL_XOFFSET_DEFAULT, WATERFALL_YOFFSET_DEFAULT = 10, 20 # ----------------------------------------------------------------------------- # Decorators # ----------------------------------------------------------------------------- + + def plot_decorator(func): def wrapper(self, *args, **kwargs): func_value = func(self, *args, **kwargs) @@ -58,6 +58,8 @@ def plot_decorator(func): # ----------------------------------------------------------------------------- # MantidAxes # ----------------------------------------------------------------------------- + + class MantidAxes(Axes): """ This class defines the **mantid** projection for 2d plotting. One chooses @@ -285,7 +287,7 @@ class MantidAxes(Axes): Remove the artists reference by this workspace (if any) and return True if the axes is then empty :param workspace: A Workspace object - :return: True if the axes is empty, false if artists remain or this workspace is not associated here + :return: True is an artist was removed False if one was not """ try: # pop to ensure we don't hold onto an artist reference @@ -296,7 +298,7 @@ class MantidAxes(Axes): for workspace_artist in artist_info: workspace_artist.remove(self) - return self.is_empty(self) + return True def remove_artists_if(self, unary_predicate): """ @@ -1103,6 +1105,8 @@ class MantidAxes(Axes): # ----------------------------------------------------------------------------- # MantidAxes3D # ----------------------------------------------------------------------------- + + class MantidAxes3D(Axes3D): """ This class defines the **mantid3d** projection for 3d plotting. One chooses @@ -1375,4 +1379,4 @@ class _WorkspaceArtists(object): if isinstance(artists, Container) or not isinstance(artists, Iterable): self._artists = [artists] else: - self._artists = artists \ No newline at end of file + self._artists = artists diff --git a/Framework/PythonInterface/mantid/plots/modest_image/modest_image.py b/Framework/PythonInterface/mantid/plots/modest_image/modest_image.py index 098610c30dd0b3c958e0299535ad312e375b8760..ca057e8caf2a95a0826f861645d63423db71e2c8 100644 --- a/Framework/PythonInterface/mantid/plots/modest_image/modest_image.py +++ b/Framework/PythonInterface/mantid/plots/modest_image/modest_image.py @@ -9,8 +9,6 @@ Modification of Chris Beaumont's mpl-modest-image package to allow the use of set_extent. """ -from __future__ import print_function, division - import matplotlib rcParams = matplotlib.rcParams diff --git a/Framework/PythonInterface/mantid/plots/plotfunctions.py b/Framework/PythonInterface/mantid/plots/plotfunctions.py index b69fd0eddb5ec7ad8a23704ad50542b9e302f959..e48ddff957d51e1f5bfccdf423b421395bd89cb9 100644 --- a/Framework/PythonInterface/mantid/plots/plotfunctions.py +++ b/Framework/PythonInterface/mantid/plots/plotfunctions.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid package -from __future__ import absolute_import - # std imports import math import numpy as np @@ -20,7 +18,6 @@ from matplotlib.legend import Legend from mantid.api import AnalysisDataService, MatrixWorkspace from mantid.kernel import ConfigService from mantid.plots import datafunctions, MantidAxes -from mantid.py3compat import is_text_string, string_types # ----------------------------------------------------------------------------- # Constants @@ -43,6 +40,8 @@ MARKER_MAP = {'square': 's', 'plus (filled)': 'P', 'point': '.', 'tickdown': 3, # ----------------------------------------------------------------------------- # Decorators # ----------------------------------------------------------------------------- + + def manage_workspace_names(func): """ A decorator to go around plotting functions. @@ -75,7 +74,7 @@ def figure_title(workspaces, fig_num): def wsname(w): return w.name() if hasattr(w, 'name') else w - if is_text_string(workspaces) or not isinstance(workspaces, collections.Sequence): + if isinstance(workspaces, str) or not isinstance(workspaces, collections.Sequence): # assume a single workspace first = workspaces else: @@ -84,6 +83,7 @@ def figure_title(workspaces, fig_num): return wsname(first) + '-' + str(fig_num) + @manage_workspace_names def plot(workspaces, spectrum_nums=None, wksp_indices=None, errors=False, overplot=False, fig=None, plot_kwargs=None, ax_properties=None, @@ -352,7 +352,7 @@ def _validate_workspace_names(workspaces): :return: A list of workspaces """ try: - raise_if_not_sequence(workspaces, 'workspaces', string_types) + raise_if_not_sequence(workspaces, 'workspaces', str) except ValueError: return workspaces else: @@ -370,5 +370,3 @@ def _do_single_plot(ax, workspaces, errors, set_title, nums, kw, plot_kwargs): if set_title: title = workspaces[0].name() ax.set_title(title) - - diff --git a/Framework/PythonInterface/mantid/plots/scales.py b/Framework/PythonInterface/mantid/plots/scales.py index d048f2ccbab4567f2380596d399d6c22b73be74d..1d29e53e8c3acdb3f8c0c667b76a69f5ab0552e3 100644 --- a/Framework/PythonInterface/mantid/plots/scales.py +++ b/Framework/PythonInterface/mantid/plots/scales.py @@ -8,8 +8,6 @@ """ Defines a set of custom axis scales """ -from __future__ import (absolute_import, division, unicode_literals) - from mantid.plots.utility import mpl_version_info from matplotlib.scale import ScaleBase from matplotlib.ticker import (AutoLocator, NullFormatter, diff --git a/Framework/PythonInterface/mantid/plots/utility.py b/Framework/PythonInterface/mantid/plots/utility.py index a3a4b2f6a66e90033aeb5e3c0f28c2bafa3e5438..284654faeabd72a300b18ccfd5e507efb17a988a 100644 --- a/Framework/PythonInterface/mantid/plots/utility.py +++ b/Framework/PythonInterface/mantid/plots/utility.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid package -from __future__ import absolute_import - # std imports import math import numpy as np diff --git a/Framework/PythonInterface/mantid/py3compat/__init__.py b/Framework/PythonInterface/mantid/py3compat/__init__.py deleted file mode 100644 index d27238a25eca6012f5bf9de800b8a75c2971276c..0000000000000000000000000000000000000000 --- a/Framework/PythonInterface/mantid/py3compat/__init__.py +++ /dev/null @@ -1,120 +0,0 @@ -# Mantid Repository : https://github.com/mantidproject/mantid -# -# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, -# NScD Oak Ridge National Laboratory, European Spallation Source, -# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS -# SPDX - License - Identifier: GPL - 3.0 + -# This file is part of the mantid workbench. -# -# -""" -mantid.py3compat ------------------- - -Transitional module providing compatibility functions intended to help -migrating from Python 2 to Python 3. Mostly just wraps six but allowing -for additional functionality of our own. - -This module should be fully compatible with: - * Python >=v2.7 - * Python 3 -""" - -from __future__ import (absolute_import, print_function, unicode_literals) - -import inspect -import six -from six import * # noqa -import sys - -# Enumerations are built in with Python 3 -try: - from enum import Enum -except ImportError: - # use a compatability layer - from mantid.py3compat.enum import Enum # noqa - -# ----------------------------------------------------------------------------- -# Globals and constants -# ----------------------------------------------------------------------------- -__all__ = dir(six) - - -# ----------------------------------------------------------------------------- -# Library functions -# ----------------------------------------------------------------------------- -if six.PY2 or sys.version_info[0:2] < (3, 2): - setswitchinterval = sys.setcheckinterval -else: - setswitchinterval = sys.setswitchinterval - -if six.PY2 or sys.version_info[0:2] < (3, 5): - # getfullargspec deprecated up until python 3.5, so use getargspec - getfullargspec = inspect.getargspec -else: - getfullargspec = inspect.getfullargspec - - -# ----------------------------------------------------------------------------- -# File manipulation -# ----------------------------------------------------------------------------- -if six.PY2: - csv_open_type = 'wb' -else: - csv_open_type = 'w' - - -# ----------------------------------------------------------------------------- -# Strings -# ----------------------------------------------------------------------------- -if not hasattr(six, "ensure_str"): - # Ubuntu 16.04, Windows, and OSX Mantid builds have a version of six which - # doesn't include ensure_str - # ensure_str was added in six 1.12.0 - def ensure_str(s, encoding='utf-8', errors='strict'): - """Coerce *s* to `str`. - For Python 2: - - `unicode` -> encoded to `str` - - `str` -> `str` - For Python 3: - - `str` -> `str` - - `bytes` -> decoded to `str` - """ - if not isinstance(s, (text_type, binary_type)): - raise TypeError("not expecting type '%s'" % type(s)) - if PY2 and isinstance(s, text_type): - s = s.encode(encoding, errors) - elif PY3 and isinstance(s, binary_type): - s = s.decode(encoding, errors) - return s - - -def is_text_string(obj): - """Return True if `obj` is a text string, False if it is anything else, - like binary data (Python 3) or QString (Python 2, PyQt API #1)""" - return isinstance(obj, string_types) - - -def to_text_string(obj, encoding=None): - """Convert `obj` to (unicode) text string""" - - if PY2: - # Python 2 - if encoding is None: - return unicode(obj) - else: - return unicode(obj, encoding) - else: - # Python 3 - if encoding is None: - return str(obj) - elif isinstance(obj, str): - # In case this function is not used properly, this could happen - return obj - else: - return str(obj, encoding) - - -def qbytearray_to_str(qba): - """Convert QByteArray object to str in a way compatible with Python 2/3""" - return str(bytes(qba.toHex().data()).decode()) diff --git a/Framework/PythonInterface/mantid/py3compat/enum.py b/Framework/PythonInterface/mantid/py3compat/enum.py deleted file mode 100644 index d070916a6cdd0cf34a7c2dd74a5af166fdfa0dbf..0000000000000000000000000000000000000000 --- a/Framework/PythonInterface/mantid/py3compat/enum.py +++ /dev/null @@ -1,351 +0,0 @@ -# Copyright (C) 2004-2017 Barry Warsaw -# -# This file is part of flufl.enum -# -# flufl.enum is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, version 3 of the License. -# -# flufl.enum is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License -# for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with flufl.enum. If not, see <http://www.gnu.org/licenses/>. -# -# Author: Barry Warsaw <barry@python.org> -# -# Used to provide backwards compatability with Python 2 -"""Python enumerations. -""" - -from __future__ import absolute_import, print_function, unicode_literals - -import re -import sys -import warnings - -from operator import itemgetter - - -__metaclass__ = type -__all__ = [ - 'Enum', - 'EnumValue', - 'IntEnum', - 'make', - ] - - -COMMASPACE = ', ' -SPACE = ' ' -IDENTIFIER_RE = r'^[a-zA-Z_][a-zA-Z0-9_]*$' - - -class EnumMetaclass(type): - """Meta class for Enums.""" - - def __init__(cls, name, bases, attributes): - """Create an Enum class. - - :param cls: The class being defined. - :param name: The name of the class. - :param bases: The class's base classes. - :param attributes: The class attributes. - """ - super(EnumMetaclass, cls).__init__(name, bases, attributes) - # Store EnumValues here for easy access. - cls._enums = {} - # Figure out if this class has a custom factory for building enum - # values. The default is EnumValue, but the class (or one of its - # bases) can declare a custom one with a special attribute. - factory = attributes.get('__value_factory__') - # Figure out the set of enum values on the base classes, to ensure - # that we don't get any duplicate values. At the same time, check the - # base classes for the special attribute. - for basecls in cls.__mro__: - if hasattr(basecls, '_enums'): - cls._enums.update(basecls._enums) - if hasattr(basecls, '__value_factory__'): - basecls_factory = basecls.__value_factory__ - if factory is not None and basecls_factory != factory: - raise TypeError( - 'Conflicting enum factory in base class: {}'.format( - basecls_factory)) - factory = basecls_factory - # Set the factory default if necessary. - if factory is None: - factory = EnumValue - # For each class attribute, create an enum value and store that back - # on the class instead of the original value. Skip Python reserved - # names. Also add a mapping from the original value to the enum value - # instance so we can return the same object on conversion. - for attr in attributes: - if not (attr.startswith('__') and attr.endswith('__')): - value = attributes[attr] - enumval = factory(cls, value, attr) - if value in cls._enums: - other = cls._enums[value] - # Without this, sort order is undefined and causes - # unpredictable results for the test suite. - first = (attr if attr < other else other) - second = (other if attr < other else attr) - raise ValueError("Conflicting enum value '{}' " - "for names: '{}' and '{}'".format( - value, first, second)) - # Store as an attribute on the class, and save the attr name. - setattr(cls, attr, enumval) - cls._enums[value] = attr - - def __dir__(cls): - # For Python 3.2, we must explicitly convert the dict view to a list. - # Order is not guaranteed, so don't sort it. - return list(cls._enums.values()) - - def __repr__(cls): - # We want predictable reprs. Because base Enum items can have any - # value, the only reliable way to sort the keys for the repr is based - # on the attribute name, which must be Python identifiers. - return '<{0} {{{1}}}>'.format(cls.__name__, COMMASPACE.join( - '{0}: {1}'.format(value, key) - for key, value in sorted(cls._enums.items(), key=itemgetter(1)))) - - def __iter__(cls): - for value in sorted(cls._enums.values()): - yield getattr(cls, value) - - def __getitem__(cls, item): - attr = cls._enums.get(item) - if attr is None: - # If this is an EnumValue, try it's .value attribute. - if hasattr(item, 'value'): - attr = cls._enums.get(item.value) - if attr is None: - # It wasn't value-ish -- try the attribute name. This was - # deprecated in LP: #1167091. - try: - warnings.warn('Enum[item_name] is deprecated; ' - 'use getattr(Enum, item_name)', - DeprecationWarning, 2) - return getattr(cls, item) - except (AttributeError, TypeError): - raise ValueError(item) - return getattr(cls, attr) - - def __call__(cls, *args): - # One-argument calling is a deprecated synonym for getitem. - if len(args) == 1: - warnings.warn('MyEnum(arg) is deprecated; use MyEnum[arg]', - DeprecationWarning, 2) - return cls.__getitem__(args[0]) - name, source = args - return _make(cls, name, source) - - -class EnumValue: - """Class to represent an enumeration value. - - EnumValue('Color', 'red', 12) prints as 'Color.red' and can be converted - to the integer 12. - """ - def __init__(self, enum, value, name): - self._enum = enum - self._value = value - self._name = name - - def __repr__(self): - return '<EnumValue: {0}.{1} [value={2}]>'.format( - self._enum.__name__, self._name, self._value) - - def __str__(self): - return '{0}.{1}'.format(self._enum.__name__, self._name) - - def __int__(self): - warnings.warn('int() is deprecated; use IntEnums', - DeprecationWarning, 2) - return self._value - - def __reduce__(self): - return getattr, (self._enum, self._name) - - @property - def enum(self): - """Return the class associated with the enum value.""" - return self._enum - - @property - def name(self): - """Return the name of the enum value.""" - return self._name - - @property - def value(self): - """Return the underlying value.""" - return self._value - - # Support only comparison by identity and equality. Ordered comparisions - # are not supported. - def __eq__(self, other): - return self is other - - def __ne__(self, other): - return self is not other - - def __lt__(self, other): - # In Python 3, returning NotImplemented from an ordered comparison - # operator will cause a TypeError to be raised. This doesn't work in - # Python 2 though, and you'd end up with working, but incorrect, - # ordered comparisons. In Python 2 we raise the TypeError explicitly. - if sys.version_info[0] < 3: - raise TypeError( - 'unorderable types: {}() < {}()'.format( - self.__class__.__name__, other.__class__.__name__)) - return NotImplemented - - def __gt__(self, other): - if sys.version_info[0] < 3: - raise TypeError( - 'unorderable types: {}() > {}()'.format( - self.__class__.__name__, other.__class__.__name__)) - return NotImplemented - - def __le__(self, other): - if sys.version_info[0] < 3: - raise TypeError( - 'unorderable types: {}() <= {}()'.format( - self.__class__.__name__, other.__class__.__name__)) - return NotImplemented - - def __ge__(self, other): - if sys.version_info[0] < 3: - raise TypeError( - 'unorderable types: {}() >= {}()'.format( - self.__class__.__name__, other.__class__.__name__)) - return NotImplemented - - __hash__ = object.__hash__ - - -# Define the Enum class using metaclass syntax compatible with both Python 2 -# and Python 3. -Enum = EnumMetaclass(str('Enum'), (), { - '__doc__': 'The public API Enum class.', - }) - - -class IntEnumValue(int, EnumValue): - """An EnumValue that is also an integer.""" - - def __new__(cls, enum, value, attr): - return super(IntEnumValue, cls).__new__(cls, value) - - __repr__ = EnumValue.__repr__ - __str__ = EnumValue.__str__ - - # For Python 2 (Python 3 doesn't need this to work). - __eq__ = int.__eq__ - __ne__ = int.__ne__ - __le__ = int.__le__ - __lt__ = int.__lt__ - __gt__ = int.__gt__ - __ge__ = int.__ge__ - - # The non-deprecated version of this method. - def __int__(self): - return self._value - - # For slices and index(). - __index__ = __int__ - - -class IntEnumMetaclass(EnumMetaclass): - # Define an iteration over the integer values instead of the attribute - # names. - def __iter__(cls): - for key in sorted(cls._enums): - yield getattr(cls, cls._enums[key]) - - -IntEnum = IntEnumMetaclass(str('IntEnum'), (Enum,), { - '__doc__': 'A specialized enumeration with values that are also integers.', - '__value_factory__': IntEnumValue, - }) - - -if str is bytes: - # Python 2 - STRING_TYPE = basestring -else: - # Python 3 - STRING_TYPE = str - - -def _swap(sequence): - for key, value in sequence: - yield value, key - - -def _make(enum_class, name, source): - """The common implementation for `Enum()` and `IntEnum()`.""" - namespace = {} - illegals = [] - have_strings = None - # Auto-splitting of strings. - if isinstance(source, STRING_TYPE): - source = source.split() - # Look for dict-like arguments. Specifically, it must have a callable - # .items() attribute. Because of the way enumerate() works, here we have - # to swap the key/values. - try: - source = _swap(source.items()) - except (TypeError, AttributeError): - source = enumerate(source, start=1) - for i, item in source: - if isinstance(item, STRING_TYPE): - if have_strings is None: - have_strings = True - elif not have_strings: - raise ValueError('heterogeneous source') - namespace[item] = i - if re.match(IDENTIFIER_RE, item) is None: - illegals.append(item) - else: - if have_strings is None: - have_strings = False - elif have_strings: - raise ValueError('heterogeneous source') - item_name, item_value = item - namespace[item_name] = item_value - if re.match(IDENTIFIER_RE, item_name) is None: - illegals.append(item_name) - if len(illegals) > 0: - raise ValueError('non-identifiers: {0}'.format(SPACE.join(illegals))) - return EnumMetaclass(str(name), (enum_class,), namespace) - - -def make(name, source): - """Return an Enum class from a name and source. - - This is a convenience function for defining a new enumeration given an - existing sequence. When an sequence is used, it is iterated over to get - the enumeration value items. The sequence iteration can either return - strings or 2-tuples. When strings are used, values are automatically - assigned starting from 1. When 2-tuples are used, the first item of the - tuple is a string and the second item is the integer value. - - `source` must be homogeneous. You cannot mix string-only and 2-tuple - items in the sequence. - - :param name: The resulting enum's class name. - :type name: byte string (or ASCII-only unicode string) - :param source: An object giving the enumeration value items. - :type source: A sequence of strings or 2-tuples. - :return: The new enumeration class. - :rtype: instance of `EnumMetaClass` - :raises ValueError: when a heterogeneous source is given, or when - non-identifiers are used as enumeration value names. - """ - warnings.warn('make() is deprecated; use Enum(name, source)', - DeprecationWarning, 2) - return _make(Enum, name, source) diff --git a/Framework/PythonInterface/mantid/py3compat/mock.py b/Framework/PythonInterface/mantid/py3compat/mock.py deleted file mode 100644 index 16a2c781934a1cb35f6ff1d51ff559e872821835..0000000000000000000000000000000000000000 --- a/Framework/PythonInterface/mantid/py3compat/mock.py +++ /dev/null @@ -1,14 +0,0 @@ -# Mantid Repository : https://github.com/mantidproject/mantid -# -# Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI, -# NScD Oak Ridge National Laboratory, European Spallation Source, -# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS -# SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import - -try: - # import for python 2 and python 3 with mock package installed - from mock import * # noqa -except ImportError: - # Mock is within unittest.mock with Python 3 - from unittest.mock import * # noqa diff --git a/Framework/PythonInterface/mantid/simpleapi.py b/Framework/PythonInterface/mantid/simpleapi.py index 1f33127f28f137289ea9a68320b809291f7dd80d..e5e50fc250b4e3e1fe62b381bceefa2bc5b8c4ef 100644 --- a/Framework/PythonInterface/mantid/simpleapi.py +++ b/Framework/PythonInterface/mantid/simpleapi.py @@ -26,17 +26,12 @@ and assign it to the rebinned variable. Importing this module starts the FrameworkManager instance. """ -from __future__ import (absolute_import, division, print_function) - # std libs from collections import OrderedDict, namedtuple import inspect import os import sys -import six -from six import iteritems - import mantid # This is a simple API so give access to the aliases by default as well from mantid import __gui__, api as _api, kernel as _kernel, apiVersion @@ -747,10 +742,7 @@ def _get_function_spec(func): """ import inspect try: - if six.PY2: - argspec = inspect.getargspec(func) - else: - argspec = inspect.getfullargspec(func) + argspec = inspect.getfullargspec(func) except TypeError: return '' # Algorithm functions have varargs set not args @@ -1109,7 +1101,7 @@ def set_properties(alg_object, *args, **kwargs): mandatory_props = [] postponed = [] - for (key, value) in iteritems(kwargs): + for (key, value) in kwargs.items(): if key in mandatory_props: mandatory_props.remove(key) if "IndexSet" in key: @@ -1447,7 +1439,7 @@ def _translate(): algs = AlgorithmFactory.getRegisteredAlgorithms(True) algorithm_mgr = AlgorithmManager - for name, versions in iteritems(algs): + for name, versions in algs.items(): if specialization_exists(name): continue try: diff --git a/Framework/PythonInterface/mantid/utils.py b/Framework/PythonInterface/mantid/utils.py index 18394d05873ae28f0fb59c0f1fc755e145f0400d..6e3870c2ad77bbb70a222b8d789050e824587f77 100644 --- a/Framework/PythonInterface/mantid/utils.py +++ b/Framework/PythonInterface/mantid/utils.py @@ -70,11 +70,7 @@ def _shared_cextension(): yield return - import six - if six.PY2: - import DLFCN as dl - else: - import os as dl + import os as dl flags_orig = sys.getdlopenflags() sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) yield diff --git a/Framework/PythonInterface/plugins/algorithms/Abins.py b/Framework/PythonInterface/plugins/algorithms/Abins.py index 1fe77c6498b0772b5b25053660910f364e22133c..0fcccce1e07f9b9d6cbaa0aa11d840707fe6f79d 100644 --- a/Framework/PythonInterface/plugins/algorithms/Abins.py +++ b/Framework/PythonInterface/plugins/algorithms/Abins.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - try: import pathos.multiprocessing as mp @@ -14,7 +12,6 @@ except ImportError: PATHOS_FOUND = False import numpy as np -import six import os import re @@ -770,7 +767,7 @@ class Abins(PythonAlgorithm): :param message_end: closing part of the error message. """ optimal_size = AbinsParameters.performance['optimal_size'] - if not (isinstance(optimal_size, six.integer_types) and optimal_size > 0): + if not (isinstance(optimal_size, int) and optimal_size > 0): raise RuntimeError("Invalid value of optimal_size" + message_end) def _check_threads(self, message_end=None): @@ -780,7 +777,7 @@ class Abins(PythonAlgorithm): """ if PATHOS_FOUND: threads = AbinsModules.AbinsParameters.performance['threads'] - if not (isinstance(threads, six.integer_types) and 1 <= threads <= mp.cpu_count()): + if not (isinstance(threads, int) and 1 <= threads <= mp.cpu_count()): raise RuntimeError("Invalid number of threads for parallelisation over atoms" + message_end) def _validate_ab_initio_file_extension(self, filename_full_path=None, expected_file_extension=None): diff --git a/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py b/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py index 3adcc45b3829a2beac89f80bf345746698f0ed1c..dcdaf177c8c0ecf1b9a87041987c64c31aecbb84 100644 --- a/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py +++ b/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd, AlgorithmFactory, DistributedDataProcessorAlgorithm, ITableWorkspaceProperty, \ MatrixWorkspaceProperty, MultipleFileProperty, PropertyMode from mantid.kernel import Direction, PropertyManagerDataService diff --git a/Framework/PythonInterface/plugins/algorithms/AlignComponents.py b/Framework/PythonInterface/plugins/algorithms/AlignComponents.py index 97cba2c7b03aaaab29713d0fe2430fccad25ddcb..372ff1cc1fe2d0914a3bcbcfeeb5c32a4447a302 100644 --- a/Framework/PythonInterface/plugins/algorithms/AlignComponents.py +++ b/Framework/PythonInterface/plugins/algorithms/AlignComponents.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init, no-name-in-module -from __future__ import (absolute_import, division, print_function) - import math import numpy as np from scipy.stats import chisquare diff --git a/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsSingleAxis.py b/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsSingleAxis.py index b2f6708dbab9cb37d620333cafdee006ddcc62e5..a1bf9da02f7ee2f418a49111e3f882436e0b3adc 100644 --- a/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsSingleAxis.py +++ b/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsSingleAxis.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-branches,too-many-locals, invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsTwoAxes.py b/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsTwoAxes.py index 5b2f0bce7256d0b60137b3b55a18664aba943dc5..98956e4ae0d4cf165d265975f17a648169c40c28 100644 --- a/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsTwoAxes.py +++ b/Framework/PythonInterface/plugins/algorithms/AngularAutoCorrelationsTwoAxes.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-branches,too-many-locals, invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py b/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py index faeeb73ad49908205cbc42aeb89b18beea0d86f0..f223cf07da637d94a64d301048c8d8460aa133ca 100644 --- a/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py +++ b/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function - from mantid.simpleapi import CreateWorkspace, Transpose, Multiply, MaskDetectors from mantid.api import AlgorithmFactory, PropertyMode, PythonAlgorithm, WorkspaceProperty from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/ApplyNegMuCorrection.py b/Framework/PythonInterface/plugins/algorithms/ApplyNegMuCorrection.py index fc3ab839adf2fc4fd46910949c3b802474024bf8..ad9e7bb40edaba485ff95cf1d06aab17d3989c59 100644 --- a/Framework/PythonInterface/plugins/algorithms/ApplyNegMuCorrection.py +++ b/Framework/PythonInterface/plugins/algorithms/ApplyNegMuCorrection.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import * # PythonAlgorithm, registerAlgorithm, WorkspaceProperty from mantid.simpleapi import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py b/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py index 27c5b797860ed8a173eb007eaae8678cda3e42ab..90291525cd1193b77c734c2b3240ffd24303dc36 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISCrystalDiffraction.py @@ -6,15 +6,13 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-branches -from __future__ import (absolute_import, division, print_function) - import os import tempfile from collections import namedtuple from contextlib import contextmanager import numpy as np -from mantid.py3compat.enum import Enum +from enum import Enum from mantid import config as mantid_config from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, FileProperty, WorkspaceProperty, FileAction, PropertyMode, mtd, diff --git a/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py b/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py index 0bd137efa0263c1c20fa055ba864725b135535e5..298df732af179f139cb07b304b306db59925e53f 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-branches -from __future__ import (absolute_import, division, print_function) - import os import tempfile import itertools diff --git a/Framework/PythonInterface/plugins/algorithms/BASISPowderDiffraction.py b/Framework/PythonInterface/plugins/algorithms/BASISPowderDiffraction.py index be7b818048810d599dda49bbf3e03d1ce41c225c..90e7185da75e36f4eb38eac63cac3a0e162eba8b 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISPowderDiffraction.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISPowderDiffraction.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import random import os import string @@ -13,7 +11,7 @@ import numpy as np from collections import namedtuple from contextlib import contextmanager -from mantid.py3compat.enum import Enum +from enum import Enum from mantid import config as mantid_config from mantid.api import (AnalysisDataService, DataProcessorAlgorithm, AlgorithmFactory, FileProperty, FileAction, diff --git a/Framework/PythonInterface/plugins/algorithms/BASISReduction.py b/Framework/PythonInterface/plugins/algorithms/BASISReduction.py index f1ecf432c12c8d7010e74026aeac720404967f86..08310c4064c48db46bc6ccedbd1a05c76651f281 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISReduction.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # Mantid Repository : https://github.com/mantidproject/mantid # pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - import os import re import numpy as np diff --git a/Framework/PythonInterface/plugins/algorithms/BinWidthAtX.py b/Framework/PythonInterface/plugins/algorithms/BinWidthAtX.py index 94530f3de2b9e8ecc8e6e5000c94787ecf2b8dbf..88bb7f78c28f4d0e08fc1327dbc10b0a71b30013 100644 --- a/Framework/PythonInterface/plugins/algorithms/BinWidthAtX.py +++ b/Framework/PythonInterface/plugins/algorithms/BinWidthAtX.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import AlgorithmFactory, HistogramValidator,\ MatrixWorkspaceProperty, PythonAlgorithm from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/CalculateEfficiencyCorrection.py b/Framework/PythonInterface/plugins/algorithms/CalculateEfficiencyCorrection.py index acfc065d3e2a4a63681eaf2bde8b412782583eaf..a62ddc3e8d64ff70a984c10ee79c810e376ee206 100644 --- a/Framework/PythonInterface/plugins/algorithms/CalculateEfficiencyCorrection.py +++ b/Framework/PythonInterface/plugins/algorithms/CalculateEfficiencyCorrection.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function import numpy as np from mantid.simpleapi import \ diff --git a/Framework/PythonInterface/plugins/algorithms/CalculateFlux.py b/Framework/PythonInterface/plugins/algorithms/CalculateFlux.py index 4e44fe523e82b84b45f7b8f884a24bb26ddd8e3f..edf12705b6b4c17d3d1a9a24ef5f9c512d546a9b 100644 --- a/Framework/PythonInterface/plugins/algorithms/CalculateFlux.py +++ b/Framework/PythonInterface/plugins/algorithms/CalculateFlux.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, MatrixWorkspaceProperty, WorkspaceUnitValidator, HistogramValidator, InstrumentValidator from mantid.simpleapi import * from mantid.kernel import Direction, FloatBoundedValidator, CompositeValidator diff --git a/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py b/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py index 2c54044b2893e46b2b092230f6cc6b7088e29844..96e4e79089790bea8fa7fc89744921ed42a13718 100644 --- a/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py +++ b/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py b/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py index 549a16febb1780a67a5e579787d32a622185bdf7..f3f7d2eb877cf3abc18ef39d0417931104216136 100644 --- a/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py +++ b/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py b/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py index 7443fc437d4cc326bbe14aaa528233115dec9fe9..225b486e0a26321dd3603bf7b765069ee341f5f5 100644 --- a/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py +++ b/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name, no-init -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty from mantid.kernel import Direction, logger diff --git a/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py b/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py index 826c8752c40ae08a2061f9bae2595be81ac75a40..4323ad913f73abed92223a688d47effd00f2d732 100644 --- a/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py +++ b/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,bare-except,too-many-arguments,multiple-statements -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * import os diff --git a/Framework/PythonInterface/plugins/algorithms/CollectHB3AExperimentInfo.py b/Framework/PythonInterface/plugins/algorithms/CollectHB3AExperimentInfo.py index f615a6faf2f3053b68894b44afb2a4ce5d85085b..ab73e17241b6b1ac93c28fe20d61740395e699fc 100644 --- a/Framework/PythonInterface/plugins/algorithms/CollectHB3AExperimentInfo.py +++ b/Framework/PythonInterface/plugins/algorithms/CollectHB3AExperimentInfo.py @@ -5,13 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) - import mantid import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * -from six.moves import range #pylint: disable=redefined-builtin import os diff --git a/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py b/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py index a6c090705b7ec22257d2beb9a8ddd72483dcffa6..268774d7542de295860f81b8cd334757e4f77fa8 100644 --- a/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py +++ b/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceGroup, MatrixWorkspace from mantid.kernel import Direction, StringArrayLengthValidator, StringArrayProperty, FloatBoundedValidator import mantid.simpleapi as api diff --git a/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py b/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py index 3687c3c78d41d3c34f31b65a0baee46975b4ea8b..a8edf867245ff2f842eeeaab24449c4746c88041 100644 --- a/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py +++ b/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, Progress, InstrumentValidator, ITableWorkspaceProperty) diff --git a/Framework/PythonInterface/plugins/algorithms/ComputeIncoherentDOS.py b/Framework/PythonInterface/plugins/algorithms/ComputeIncoherentDOS.py index 85414aade70319356cc825da0bda55848c5f2704..cf57058ce93a25bde8e86a7d18153913621d3ad0 100644 --- a/Framework/PythonInterface/plugins/algorithms/ComputeIncoherentDOS.py +++ b/Framework/PythonInterface/plugins/algorithms/ComputeIncoherentDOS.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable = no-init, invalid-name, line-too-long, eval-used, unused-argument, too-many-locals, too-many-branches, too-many-statements -from __future__ import (absolute_import, division, print_function) - import numpy as np from scipy import constants from mantid.kernel import CompositeValidator, Direction, FloatBoundedValidator diff --git a/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py b/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py index 72e44169cb9168eaaa1f61f2764fbf4f9e65f166..43c0909085c90300764792b687f80b6492802fa1 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py +++ b/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py b/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py index d81bc78a591d3ebdad62e1fea088876dc77103cb..61c9d9b593f08990dc24e3f16d28b96940d077da 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py +++ b/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py b/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py index 09721f7e6e355ed2a6e8ae7555154402eba85a08..c652b75f710bdceb327d738aba21c6df80b667b9 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py +++ b/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as msapi import mantid.api as api import mantid.kernel as kernel diff --git a/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py b/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py index f334589ed49b30a0f725bb4e1b83ad8fc4165be5..e8a8470f1514b6ca26458b959e6098fdd27ef4ca 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py +++ b/Framework/PythonInterface/plugins/algorithms/ConvertWANDSCDtoQ.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import (PythonAlgorithm, AlgorithmFactory, PropertyMode, WorkspaceProperty, Progress, IMDHistoWorkspaceProperty, mtd) diff --git a/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py b/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py index 2c43988cb61a4c4dce329de162ab87949be48b3d..62f5ad71dbe4164b473510914a16f1e52477a887 100644 --- a/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py +++ b/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi import mantid.api import mantid.kernel diff --git a/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py b/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py index d100f99a0ab78ed902b7a91056c48dc081e6565b..9fc55f8db6b1e06c5868d9bc40aaa73c8bd21603 100644 --- a/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py +++ b/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import scipy as sp from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceUnitValidator, \ diff --git a/Framework/PythonInterface/plugins/algorithms/CreateCacheFilename.py b/Framework/PythonInterface/plugins/algorithms/CreateCacheFilename.py index 631a90978e006b225f86beeffe3a766a99086474..1fc0e5b6095b3141bd4140dec03bf2910b76064c 100644 --- a/Framework/PythonInterface/plugins/algorithms/CreateCacheFilename.py +++ b/Framework/PythonInterface/plugins/algorithms/CreateCacheFilename.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,bare-except,too-many-arguments -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * import mantid diff --git a/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py b/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py index 4c7ed28904bd6c282109fe51e81faff87aee007d..08898762eafe381e9b676d65c842c19bfca61709 100644 --- a/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py +++ b/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory, ITableWorkspaceProperty, WorkspaceFactory from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py b/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py index 178268813bcbb49d6e8ebc695dc4ea913ac62cb7..53ae6c912177b20f1c3cd58ff2ffbd1bbfaf296a 100644 --- a/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py +++ b/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py @@ -5,13 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * -from six.moves import range #pylint: disable=redefined-builtin - _OUTPUTLEVEL = "NOOUTPUT" diff --git a/Framework/PythonInterface/plugins/algorithms/CropWorkspaceForMDNorm.py b/Framework/PythonInterface/plugins/algorithms/CropWorkspaceForMDNorm.py index e3e7986d3a8f32f3d0d0012321c0ce324c021f4a..1b169df38e51009b5a6816f5db5a6ec90bb945af 100644 --- a/Framework/PythonInterface/plugins/algorithms/CropWorkspaceForMDNorm.py +++ b/Framework/PythonInterface/plugins/algorithms/CropWorkspaceForMDNorm.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import numpy from mantid.api import (PythonAlgorithm, AlgorithmFactory, WorkspaceUnitValidator,IEventWorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py b/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py index 616ffd680b5fa5df0c24db26fb50b354ee3b8c41..369d6ae36f2dad27f9589cd9317074d64a09849f 100644 --- a/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py +++ b/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.simpleapi import ConjoinWorkspaces, CropWorkspace, DeleteWorkspace from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/CylinderPaalmanPingsCorrection2.py b/Framework/PythonInterface/plugins/algorithms/CylinderPaalmanPingsCorrection2.py index f920a78d7a530fbccb2063ae003773cbc628ece2..5062076fa29b08a0fb0bb42123221aa3478753af 100644 --- a/Framework/PythonInterface/plugins/algorithms/CylinderPaalmanPingsCorrection2.py +++ b/Framework/PythonInterface/plugins/algorithms/CylinderPaalmanPingsCorrection2.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,too-many-locals,too-many-instance-attributes,too-many-arguments,invalid-name -from __future__ import (absolute_import, division, print_function) - import math import numpy as np from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py b/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py index 337de47751a3a495f97fe89e7d16a09f1c2bd4dd..73987760d8852f9117ebae6b91e15880a788318e 100644 --- a/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py +++ b/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as api from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty, WorkspaceGroup from mantid.kernel import Direction, StringArrayProperty, StringArrayLengthValidator, FloatBoundedValidator diff --git a/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py b/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py index f1c3ec437cfe5375e202d5b39ee1c61f2cab5be5..47b568b4a1458d36ef2d7ab67384da1a2c0a24ce 100644 --- a/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py +++ b/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-locals -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as api from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py b/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py index 1f8ac0b97b4e11e4a4fc4cda832524904d752ed7..e100d28e31820d40103f6d7267fddf27aba2e76e 100644 --- a/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py +++ b/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as api from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceGroup from mantid.kernel import Direction, StringArrayProperty, StringListValidator, V3D, StringArrayLengthValidator diff --git a/Framework/PythonInterface/plugins/algorithms/DPDFreduction.py b/Framework/PythonInterface/plugins/algorithms/DPDFreduction.py index ece8f7bcf7d973a9bda1a7216f5cfaeb0629d715..e10be7abf19a36a22695877c37316b70a41ac858 100644 --- a/Framework/PythonInterface/plugins/algorithms/DPDFreduction.py +++ b/Framework/PythonInterface/plugins/algorithms/DPDFreduction.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import os import numpy import re diff --git a/Framework/PythonInterface/plugins/algorithms/DSFinterp.py b/Framework/PythonInterface/plugins/algorithms/DSFinterp.py index 944a78ff8d92a490c6e1a0c43af842ab60a09130..d7304b248408973458fa4a7b6424445a6856d4ef 100644 --- a/Framework/PythonInterface/plugins/algorithms/DSFinterp.py +++ b/Framework/PythonInterface/plugins/algorithms/DSFinterp.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory import mantid.simpleapi from mantid.kernel import StringListValidator, FloatArrayProperty, FloatArrayMandatoryValidator,\ diff --git a/Framework/PythonInterface/plugins/algorithms/DakotaChiSquared.py b/Framework/PythonInterface/plugins/algorithms/DakotaChiSquared.py index eaafa1e617b001b30b23407413cdd51b1d33e5d6..49470911acbbe393b32db90056d7749fb899761b 100644 --- a/Framework/PythonInterface/plugins/algorithms/DakotaChiSquared.py +++ b/Framework/PythonInterface/plugins/algorithms/DakotaChiSquared.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory,MatrixWorkspaceProperty,PropertyMode from mantid.kernel import Direction import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/DeltaPDF3D.py b/Framework/PythonInterface/plugins/algorithms/DeltaPDF3D.py index 1de36ac736091d818b47ed0fea9c006644551839..4b9d67186a1e51fb1aa6c39e990cf3e63806368c 100644 --- a/Framework/PythonInterface/plugins/algorithms/DeltaPDF3D.py +++ b/Framework/PythonInterface/plugins/algorithms/DeltaPDF3D.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory, IMDHistoWorkspaceProperty, PropertyMode, WorkspaceProperty, Progress from mantid.kernel import (Direction, EnabledWhenProperty, PropertyCriterion, Property, StringListValidator, FloatArrayBoundedValidator, FloatArrayProperty, FloatBoundedValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py b/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py index c9c919f6f4d0f7cabf807a57263577ba9017a822..38d494540ba1303f0b6248adc91879c6e5618030 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * import mantid.simpleapi as mantid diff --git a/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py b/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py index 71d4e3d48fdd6e97442b6610e1e6282738da2e77..05da9f6e4b2f14fda500bc6038fdfb6dac9edd83 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import math from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py b/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py index badf5e32e36d2916847942f0a96060457d5b2a42..278c4d411679641490244d273cd46253ed6e68e4 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import math from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/EnggFitTOFFromPeaks.py b/Framework/PythonInterface/plugins/algorithms/EnggFitTOFFromPeaks.py index f97556daa117f029ab9b0e51568928d71061185d..b7f106ab0b68430aca9a68c1dbdffbff1facc69a 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggFitTOFFromPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggFitTOFFromPeaks.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/EnggFocus.py b/Framework/PythonInterface/plugins/algorithms/EnggFocus.py index 56ad9aadbf8859931260eb417d9a2aecd1c5f20c..71e025b5adb8788c8ded492ac441bc6ff7fb382a 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggFocus.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggFocus.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5.py b/Framework/PythonInterface/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5.py index 3e64ee1c7a689dc9ad8f1932092b721d08a17aaf..39896a8c3d3f033cecfeec9b9b46624d70f7c261 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * import h5py diff --git a/Framework/PythonInterface/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5.py b/Framework/PythonInterface/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5.py index 502770be183298d432ca969ee94e511ce74b3b3b..3a298b72cf3a199715559dbd7ea1af0e7c3061af 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * import h5py diff --git a/Framework/PythonInterface/plugins/algorithms/EnggVanadiumCorrections.py b/Framework/PythonInterface/plugins/algorithms/EnggVanadiumCorrections.py index 34bc610f6b169ca9a280888a94fd768f326b0c41..caaed8cdb56e76629ef27d77127a2e174ded88b8 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggVanadiumCorrections.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggVanadiumCorrections.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * import mantid.simpleapi as mantid diff --git a/Framework/PythonInterface/plugins/algorithms/ExaminePowderDiffProfile.py b/Framework/PythonInterface/plugins/algorithms/ExaminePowderDiffProfile.py index 9e997b7a6e59ccdf573b253adf55493686727b4d..68c15ddb8cd9468f91ed10409dc01bd01968951b 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExaminePowderDiffProfile.py +++ b/Framework/PythonInterface/plugins/algorithms/ExaminePowderDiffProfile.py @@ -5,13 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init, too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * -from six.moves import range - _OUTPUTLEVEL = "NOOUTPUT" diff --git a/Framework/PythonInterface/plugins/algorithms/Examples/ExampleSaveAscii.py b/Framework/PythonInterface/plugins/algorithms/Examples/ExampleSaveAscii.py index 7ea23478e5773e7c05cf7645b930f7a265762c6e..90aba83bfba64ef5ca797dabdd1599d477f2de2b 100644 --- a/Framework/PythonInterface/plugins/algorithms/Examples/ExampleSaveAscii.py +++ b/Framework/PythonInterface/plugins/algorithms/Examples/ExampleSaveAscii.py @@ -12,7 +12,6 @@ Note that the SaveAscii algorithm should be used instead in most cases. """ # This __future__ import is for Python 2/3 compatibility -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/Examples/Squares.py b/Framework/PythonInterface/plugins/algorithms/Examples/Squares.py index 2ad3c4b09084c40eb3f13c665c49f20c1b991205..557e891f5a000ede1e1ff666ec9dfd5cc6fb5e96 100644 --- a/Framework/PythonInterface/plugins/algorithms/Examples/Squares.py +++ b/Framework/PythonInterface/plugins/algorithms/Examples/Squares.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init # This __future__ import is for Python 2/3 compatibility -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py b/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py index 1ce6a2fb474816d182c45a60f7df1e1aa3cea5ee..ab7d7283c7d5dd95e393f754f834980c2ceb9a36 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py @@ -5,15 +5,12 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import mantid from mantid.api import * from mantid.kernel import * import datetime import time import os -from six.moves import range - #pylint: disable=too-many-instance-attributes diff --git a/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py b/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py index bd90b173e7d9c5effcf898c0c943ed388da8ef1e..fe9069f4f48657f4063ebf854e082613fc595df0 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty, \ InstrumentValidator, FileProperty, FileAction from mantid.kernel import Direction, StringArrayProperty, StringListValidator diff --git a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py index 050bce2d6fc059ce1009b0388b508867b3530b5d..838f086cf36c6aa5bd9b7e55c7521ace6d667201 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py @@ -5,13 +5,11 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * from distutils.version import LooseVersion import numpy as np import os -from six.moves import range # pylint: disable=redefined-builtin class ExportSampleLogsToCSVFile(PythonAlgorithm): diff --git a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToHDF5.py b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToHDF5.py index 990ef2361258da2e00ee8802c82bdb52422be32b..6da83c409ad4edbe81e8588d1bd7befcd8ca0412 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToHDF5.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToHDF5.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * import h5py diff --git a/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py b/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py index f3e5387b001f9c56a0796d65800804042e4d41e5..36527b0cb60bd7e54ac7962c803a88e3d46b7845 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name, no-init -from __future__ import (absolute_import, division, print_function) import os from mantid import config from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty, mtd, FileProperty, FileAction diff --git a/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py b/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py index c9b3e9a53d2cdcdf075b16f317def83d1ce09dd2..27e69fa123fbc443a356b9a23bf330ec060ac73a 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py +++ b/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.kernel import * from mantid.api import (MatrixWorkspaceProperty, DataProcessorAlgorithm, PropertyMode) diff --git a/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py b/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py index ea0ec4d17c83d35ef0e85566ce0cc9cfdccb98ae..f80748fe62b15456ddaa68bfdf43db2e3151f0d0 100644 --- a/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py +++ b/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/FitGaussian.py b/Framework/PythonInterface/plugins/algorithms/FitGaussian.py index ef6ce8ccbc89409cd9a4197d4afef6c5d7be4c93..e8d7999c23edf0ce87cf704ed8df9258db3a479d 100644 --- a/Framework/PythonInterface/plugins/algorithms/FitGaussian.py +++ b/Framework/PythonInterface/plugins/algorithms/FitGaussian.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty from mantid.kernel import Direction, IntBoundedValidator from mantid.simpleapi import Fit diff --git a/Framework/PythonInterface/plugins/algorithms/FitIncidentSpectrum.py b/Framework/PythonInterface/plugins/algorithms/FitIncidentSpectrum.py index 938a60db1099154619c9990b9d4cf89432177fa7..53457a481390729260e2fe5e2585f526504b9936 100644 --- a/Framework/PythonInterface/plugins/algorithms/FitIncidentSpectrum.py +++ b/Framework/PythonInterface/plugins/algorithms/FitIncidentSpectrum.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from copy import copy import numpy as np from scipy import signal, ndimage, interpolate diff --git a/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py b/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py index 001b551274c6820a831ad5f03956040dc19ed99c..13d3da9a786bdc3ece8f86a9751d9b9bee85bc4d 100644 --- a/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from contextlib import contextmanager import numpy import os diff --git a/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py b/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py index 8748d4b7c12ab09ef66d774be28b563ca2b42512..956e0ee716b2b4510e9dc6cce9d7d53263dced9a 100644 --- a/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py +++ b/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import mantid import mantid.api import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py b/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py index 48246f1a5e7d0eed32244905f3435b191540bc19..e2e42699f660ead6cddcabbb0eac1ccf632299d2 100644 --- a/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py +++ b/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import mantid import numpy diff --git a/Framework/PythonInterface/plugins/algorithms/GetIPTS.py b/Framework/PythonInterface/plugins/algorithms/GetIPTS.py index 89d49af1c7cccc22271f188402acc20e28e3ccab..98e3a99c39000caa80892333939f5fb12e3e8a5b 100644 --- a/Framework/PythonInterface/plugins/algorithms/GetIPTS.py +++ b/Framework/PythonInterface/plugins/algorithms/GetIPTS.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import AlgorithmFactory, FileFinder, PythonAlgorithm from mantid.kernel import ConfigService, Direction, IntBoundedValidator, \ StringListValidator diff --git a/Framework/PythonInterface/plugins/algorithms/GetLiveInstrumentValue.py b/Framework/PythonInterface/plugins/algorithms/GetLiveInstrumentValue.py index 08e1a35e0b8b1163b2726b74b581393fe6cce5a2..c1642a44637bd9366ade2f659f1d9d7ccd62688e 100644 --- a/Framework/PythonInterface/plugins/algorithms/GetLiveInstrumentValue.py +++ b/Framework/PythonInterface/plugins/algorithms/GetLiveInstrumentValue.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py b/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py index 7c874bc906a909716b71fd1b5b737c80a485cdca..4c728b1336eb18ecbd05af53faa42298afe3e751 100644 --- a/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py +++ b/Framework/PythonInterface/plugins/algorithms/HB2AReduce.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import (PythonAlgorithm, AlgorithmFactory, PropertyMode, WorkspaceProperty, FileProperty, FileAction, MultipleFileProperty) from mantid.kernel import (Direction, IntArrayProperty, FloatTimeSeriesProperty, FloatBoundedValidator, diff --git a/Framework/PythonInterface/plugins/algorithms/HFIRSANS2Wavelength.py b/Framework/PythonInterface/plugins/algorithms/HFIRSANS2Wavelength.py index f766d6af1f685d487d741843857b4f0aa9910a69..d218b44d254dfa40e35241816c0c75c9b086ee41 100644 --- a/Framework/PythonInterface/plugins/algorithms/HFIRSANS2Wavelength.py +++ b/Framework/PythonInterface/plugins/algorithms/HFIRSANS2Wavelength.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import (PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress) from mantid.kernel import (Direction) diff --git a/Framework/PythonInterface/plugins/algorithms/IndirectTransmission.py b/Framework/PythonInterface/plugins/algorithms/IndirectTransmission.py index 3fa272cade206b36a024169273e8d16aed3797f9..09c79a2ab9ab2a88b30fcb59c3e9147019247387 100644 --- a/Framework/PythonInterface/plugins/algorithms/IndirectTransmission.py +++ b/Framework/PythonInterface/plugins/algorithms/IndirectTransmission.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py index 9ca63312683914286b292aa096bf7eb19110c29c..318c8e11c8512fdc91bde8a9704a8f130c82f238 100644 --- a/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py +++ b/Framework/PythonInterface/plugins/algorithms/IntegratePeaksProfileFitting.py @@ -11,7 +11,6 @@ fitting for integrating peaks. """ # This __future__ import is for Python 2/3 compatibility -from __future__ import (absolute_import, division, print_function) import sys from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/LRAutoReduction.py b/Framework/PythonInterface/plugins/algorithms/LRAutoReduction.py index 9be2f10bf574390760422cd0eb741a6e98a9b30f..a7398ba6d9c864dcea538bb610ffd221169842ca 100644 --- a/Framework/PythonInterface/plugins/algorithms/LRAutoReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/LRAutoReduction.py @@ -8,7 +8,6 @@ """ Top-level auto-reduction algorithm for the SNS Liquids Reflectometer """ -from __future__ import (absolute_import, division, print_function) import sys import math import re @@ -21,7 +20,6 @@ from mantid.simpleapi import * from mantid.kernel import * from reduction_gui.reduction.reflectometer.refl_data_series import DataSeries from reduction_gui.reduction.reflectometer.refl_data_script import DataSets -from six import string_types class LRAutoReduction(PythonAlgorithm): @@ -444,7 +442,7 @@ class LRAutoReduction(PythonAlgorithm): direct_beam_runs_str = self._read_property(meta_data_run, "direct_beam_runs", _direct_beam_runs, is_string=True) # The direct runs in the DAS logs are stored as a string - if isinstance(direct_beam_runs_str, string_types): + if isinstance(direct_beam_runs_str, str): try: direct_beam_runs = [int(r.strip()) for r in direct_beam_runs_str.split(',')] except ValueError: diff --git a/Framework/PythonInterface/plugins/algorithms/LRDirectBeamSort.py b/Framework/PythonInterface/plugins/algorithms/LRDirectBeamSort.py index d7cccf9be61f58746838c8d5c51d8546716ef6fe..961f7aeae3874fff5743d53593929138b712bc92 100644 --- a/Framework/PythonInterface/plugins/algorithms/LRDirectBeamSort.py +++ b/Framework/PythonInterface/plugins/algorithms/LRDirectBeamSort.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.simpleapi import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/LRPeakSelection.py b/Framework/PythonInterface/plugins/algorithms/LRPeakSelection.py index 22054d2a6b66a7ed96e88bc61723981fb81a5e78..b2c2c9ed51d239178bd26e65bc699b122228c1b6 100644 --- a/Framework/PythonInterface/plugins/algorithms/LRPeakSelection.py +++ b/Framework/PythonInterface/plugins/algorithms/LRPeakSelection.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name, too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) import math import numpy as np from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/LRPrimaryFraction.py b/Framework/PythonInterface/plugins/algorithms/LRPrimaryFraction.py index 31a072787b8d44f390b49113e97591faa848385c..5f665bbbf2d8313fd9b1297f4b21ec026b27dedd 100644 --- a/Framework/PythonInterface/plugins/algorithms/LRPrimaryFraction.py +++ b/Framework/PythonInterface/plugins/algorithms/LRPrimaryFraction.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import math from mantid.api import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/LRReflectivityOutput.py b/Framework/PythonInterface/plugins/algorithms/LRReflectivityOutput.py index f49c58c0069dec3ce717d7504e10847ed9125e88..bf2c5f81f41067c7ec7d34cef11bae80b34a531c 100644 --- a/Framework/PythonInterface/plugins/algorithms/LRReflectivityOutput.py +++ b/Framework/PythonInterface/plugins/algorithms/LRReflectivityOutput.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,bare-except -from __future__ import (absolute_import, division, print_function) import math import time import mantid diff --git a/Framework/PythonInterface/plugins/algorithms/LRScalingFactors.py b/Framework/PythonInterface/plugins/algorithms/LRScalingFactors.py index d474992872d890b8e62a03f2b6ba4de88145d3cb..6d4a809baa8aff88fdc493703ccdf38f82831975 100644 --- a/Framework/PythonInterface/plugins/algorithms/LRScalingFactors.py +++ b/Framework/PythonInterface/plugins/algorithms/LRScalingFactors.py @@ -5,13 +5,11 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name, no-init -from __future__ import (absolute_import, division, print_function) import os import re from mantid.api import * from mantid.simpleapi import * from mantid.kernel import * -from six import iteritems class LRScalingFactors(PythonAlgorithm): @@ -402,7 +400,7 @@ class LRScalingFactors(PythonAlgorithm): fd.write("# y=a+bx\n#\n") fd.write("# LambdaRequested[Angstroms] S1H[mm] (S2/Si)H[mm] S1W[mm] (S2/Si)W[mm] a b error_a error_b\n#\n") - for k, v in iteritems(scaling_file_meta): + for k, v in scaling_file_meta.items(): fd.write("%s\n" % v) for item in scaling_file_content: fd.write("IncidentMedium=%s " % item["IncidentMedium"]) diff --git a/Framework/PythonInterface/plugins/algorithms/LRSubtractAverageBackground.py b/Framework/PythonInterface/plugins/algorithms/LRSubtractAverageBackground.py index 59330c218edca8d7dc7816c17c54ad69d49940e6..529e190a58287ffffd53f99d1d91bfe8994ab661 100644 --- a/Framework/PythonInterface/plugins/algorithms/LRSubtractAverageBackground.py +++ b/Framework/PythonInterface/plugins/algorithms/LRSubtractAverageBackground.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.simpleapi import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/LiquidsReflectometryReduction.py b/Framework/PythonInterface/plugins/algorithms/LiquidsReflectometryReduction.py index a2126f254b2f45e635ae13f5200467898edad86a..157d0bff4b9b7a20ed24411b4f113758c0ccf0f8 100644 --- a/Framework/PythonInterface/plugins/algorithms/LiquidsReflectometryReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/LiquidsReflectometryReduction.py @@ -13,7 +13,6 @@ - Keep the same parameters and work as a drop-in replacement for the old algorithm. - Reproduce the output of the old algorithm. """ -from __future__ import (absolute_import, division, print_function) import time import math import os diff --git a/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py b/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py index dcaca149e623efa3ec3d8389bcfc5d152d78d4d4..f253e59449ff4fe5d1e398b2cfebcdfd6e665ded 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os.path from mantid.kernel import Direction, StringContainsValidator, PropertyManagerProperty from mantid.api import AlgorithmFactory, AlgorithmManager, MultipleFileProperty, \ diff --git a/Framework/PythonInterface/plugins/algorithms/LoadCIF.py b/Framework/PythonInterface/plugins/algorithms/LoadCIF.py index ce451509a5d9895ef5953774206d359300172c05..0f2814ef055103fee32d95a87cbd05f0f8e6834b 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadCIF.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadCIF.py @@ -5,13 +5,11 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,too-few-public-methods -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.simpleapi import * from mantid.api import * from mantid.geometry import SpaceGroupFactory, CrystalStructure, UnitCell -from six import iteritems import re import numpy as np @@ -251,7 +249,7 @@ class AtomListBuilder(object): anisoLabels = self._get_ansitropic_labels(cifData) equivalentUMap = self._getEquivalentUs(cifData, anisoLabels, unitCell) - for key, uIso in iteritems(isotropicUMap): + for key, uIso in isotropicUMap.items(): if uIso is None and key in equivalentUMap: isotropicUMap[key] = equivalentUMap[key] @@ -268,7 +266,7 @@ class AtomListBuilder(object): # Return U_equiv calculated according to [Fischer & Tillmanns, Acta Cryst C44, p775, 10.1107/S0108270187012745] # in a dict like { 'label1': 'U_equiv1' ... }. Invalid matrices (containing None) are excluded. return dict([(label, np.around(np.sum(np.multiply(uMatrix, sumWeights)) / 3., decimals=5)) - for label, uMatrix in iteritems(anisotropicParameters) if uMatrix.dtype.type != np.object_]) + for label, uMatrix in anisotropicParameters.items() if uMatrix.dtype.type != np.object_]) def _getAnisotropicParametersU(self, cifData, labels): # Try to extract U or if that fails, B. @@ -280,7 +278,7 @@ class AtomListBuilder(object): bTensors = self._getTensors(cifData, labels, ['_atom_site_aniso_b_11', '_atom_site_aniso_b_12', '_atom_site_aniso_b_13', '_atom_site_aniso_b_22', '_atom_site_aniso_b_23', '_atom_site_aniso_b_33']) - return dict([(label, convertBtoU(bTensor)) for label, bTensor in iteritems(bTensors)]) + return dict([(label, convertBtoU(bTensor)) for label, bTensor in bTensors.items()]) def _get_ansitropic_labels(self, cifData): anisoLabel = '_atom_site_aniso_label' diff --git a/Framework/PythonInterface/plugins/algorithms/LoadDNSLegacy.py b/Framework/PythonInterface/plugins/algorithms/LoadDNSLegacy.py index 1989684cc604341fa33deecc62e9d2a2659eac26..1e1f30e5d65da6dbe252be6939d1718150867533 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadDNSLegacy.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadDNSLegacy.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as api import numpy as np from scipy.constants import m_n, h, physical_constants diff --git a/Framework/PythonInterface/plugins/algorithms/LoadEXED.py b/Framework/PythonInterface/plugins/algorithms/LoadEXED.py index 235c2685136caaba117faed9b7b535b10181d57b..90c491335ba952fdf74712ce0ed0a12c550df5a7 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadEXED.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadEXED.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import Direction from mantid.api import (PythonAlgorithm, AlgorithmFactory, FileAction, FileProperty, WorkspaceProperty, MatrixWorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py b/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py index 7b7e6b8d3b06bb5eefa873827182ff67072138f7..44f219a3c18b56ff7ee495df4285ff0f4d9eb822 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py b/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py index 7d51a5d09a1d1d75cc1e0196bd670c925c7e84dc..57831f78a464830afbfb55baeb4393bc5795c509 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py @@ -5,13 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory, ITableWorkspaceProperty, WorkspaceFactory,\ FileProperty, FileAction, MatrixWorkspaceProperty from mantid.kernel import Direction -from six.moves import range #pylint: disable=redefined-builtin - _OUTPUTLEVEL = "NOOUTPUT" diff --git a/Framework/PythonInterface/plugins/algorithms/LoadGudrunOutput.py b/Framework/PythonInterface/plugins/algorithms/LoadGudrunOutput.py index ee167e499d119e3fde37c5d86f516b9e2ca45fdc..57d93a71b2d138522045e2b58db1dd9ce1afd8d0 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadGudrunOutput.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadGudrunOutput.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import (FileProperty, WorkspaceProperty, PythonAlgorithm, AlgorithmFactory, FileAction, PropertyMode) from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/LoadLamp.py b/Framework/PythonInterface/plugins/algorithms/LoadLamp.py index 78b8b68b7cff83167b9bb6388c31af092f3b1d47..522d828aade293742d7c63d7b9b982b394385e44 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadLamp.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadLamp.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import FileProperty, WorkspaceProperty, PythonAlgorithm, AlgorithmFactory, FileAction from mantid.kernel import Direction from mantid.simpleapi import CreateWorkspace, AddSampleLogMultiple diff --git a/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py b/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py index abc6ed0c9682a51907f39e410a8dc082de9fc51d..691488d90ccc5c87edbfc2ed1da43209905d85c2 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import time import datetime import numbers diff --git a/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py b/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py index 3cb95b539e9dc0e47425671fe6fe8fc280e41cae..8cf3a15dce7295c8aae7e82f3bbb96e7f3c4c398 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.simpleapi import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn3Ascii.py b/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn3Ascii.py index a8138648d023e6720ae838cde57a1d11043f6521..3bc944955a58bcce87ab9ec89d7e46f8ae856b4a 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn3Ascii.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn3Ascii.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init,too-many-locals,too-many-branches -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii.py b/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii.py index 857343d6a15b0c46b5836591b2bfb798f54b36b4..0f583a62830a8518d9ce4c2058ea3d130b3d57c0 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii1D.py b/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii1D.py index 2afefea75a3892b953ab2b5e98398372754ac4b5..a47b39fe7460b2ae712bfac8a7c81b2fa3d68fb3 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii1D.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadNMoldyn4Ascii1D.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import CreateWorkspace, GroupWorkspaces from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/LoadPreNexusLive.py b/Framework/PythonInterface/plugins/algorithms/LoadPreNexusLive.py index 7d0aaf953c425cc101399e0818bfb74759776c2f..5b25055a3cbacbcdb93f5ca48b43c105b650ed19 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadPreNexusLive.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadPreNexusLive.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid import mtd from mantid.api import AlgorithmFactory, DataProcessorAlgorithm, FileAction, \ FileProperty, WorkspaceProperty diff --git a/Framework/PythonInterface/plugins/algorithms/LoadSINQ.py b/Framework/PythonInterface/plugins/algorithms/LoadSINQ.py index d630240588f033f3379b4697c46c1be929f7af4b..9372808fe58c9fc9ffadc828aaae051d08a25905 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadSINQ.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadSINQ.py @@ -13,7 +13,6 @@ # # Mark Koennecke, November 2012 #-------------------------------------------------------------- -from __future__ import (absolute_import, division, print_function) from mantid.api import AlgorithmFactory from mantid.api import PythonAlgorithm, WorkspaceProperty from mantid.kernel import Direction, StringListValidator, ConfigServiceImpl diff --git a/Framework/PythonInterface/plugins/algorithms/LoadSINQFile.py b/Framework/PythonInterface/plugins/algorithms/LoadSINQFile.py index 9717663c928ee1a9cef46e8bd498a1cc15251625..28686db40230728ed602c7dec62050c205c58de2 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadSINQFile.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadSINQFile.py @@ -12,7 +12,6 @@ # # Mark Koennecke, November 2012 #-------------------------------------------------------------- -from __future__ import (absolute_import, division, print_function) from mantid.api import AlgorithmFactory from mantid.api import PythonAlgorithm, FileProperty, FileAction, WorkspaceProperty from mantid.kernel import Direction, StringListValidator diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py b/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py index cc1b385463f3ae6804ae053d29a5e022b094bcce..24f212cf7760bec9a2ed0f07614a57e1ca1dbac7 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * import mantid.simpleapi as ms @@ -15,8 +14,6 @@ import copy import numpy as np import os import re -import six - RUN_PROP = "Filename" WKSP_PROP = "OutputWorkspace" MODE_PROP = "Mode" @@ -396,7 +393,7 @@ class LoadVesuvio(LoadEmptyVesuvio): """Given a string containing either a filename/partial filename or run number find the correct file prefix""" vesuvio = config.getInstrument("VESUVIO") - if isinstance(run_or_filename, six.integer_types): + if isinstance(run_or_filename, int): run_no = run_or_filename return vesuvio.filePrefix(int(run_no)) + str(run_or_filename) else: diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py index 4a93e325df9e3547a105dc7817962f47e0ea2c1a..a0e12eb47938e29515fff186edde5824fb9fa49f 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py @@ -8,7 +8,6 @@ #from mantid.api import AlgorithmFactory #from mantid.simpleapi import PythonAlgorithm, WorkspaceProperty # from mantid.kernel import Direction -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py index b12a8e508c4f9c8fae385567bb9c209ae4a74886..064ffda752e5ab5ed8e60177ef7b9dc11b03bfca 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py @@ -8,7 +8,6 @@ #from mantid.api import AlgorithmFactory #from mantid.simpleapi import PythonAlgorithm, WorkspaceProperty # from mantid.kernel import Direction -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py b/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py index 1eeceabf0d4a63cc1f59c7e602916af3521507d1..0b0d89f46420dd930660b753c992e68251919113 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py @@ -8,7 +8,6 @@ #from mantid.api import AlgorithmFactory #from mantid.simpleapi import PythonAlgorithm, WorkspaceProperty # from mantid.kernel import Direction -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py b/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py index 8303c6ee52b7e88249a652b107480ee9da4ac8a4..56975dc6e177be3fbc3a39e951a488fbea0e9242 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadWANDSCD.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory, PropertyMode, WorkspaceProperty, Progress, MultipleFileProperty, FileAction, mtd from mantid.kernel import Direction, Property, IntArrayProperty, StringListValidator from mantid.simpleapi import LoadEventNexus, RemoveLogs, DeleteWorkspace, ConvertToMD, Rebin, CreateGroupingWorkspace, GroupDetectors, SetUB diff --git a/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py b/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py index 5afbd8df43fe074fac88ab3d12dca8361f1c6122..4007d78e242aed538adfa08ae764c2de209cefb8 100644 --- a/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py +++ b/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import os from operator import itemgetter from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/MRGetTheta.py b/Framework/PythonInterface/plugins/algorithms/MRGetTheta.py index 5c22cb0a32d666e20e5b281b4d16b54573b2c4ae..76cee08884b420d889b310afc4377b0bdc8d7c11 100644 --- a/Framework/PythonInterface/plugins/algorithms/MRGetTheta.py +++ b/Framework/PythonInterface/plugins/algorithms/MRGetTheta.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty from mantid.kernel import Direction, FloatBoundedValidator, Property import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/MRInspectData.py b/Framework/PythonInterface/plugins/algorithms/MRInspectData.py index df20dc64118868bcb5225d533e79e802247e5dae..a79f7e03be5d7987816dc4391afab0778f301bb4 100644 --- a/Framework/PythonInterface/plugins/algorithms/MRInspectData.py +++ b/Framework/PythonInterface/plugins/algorithms/MRInspectData.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=bare-except,no-init,invalid-name,dangerous-default-value -from __future__ import (absolute_import, division, print_function) import sys from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py b/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py index 54bed65f3234eef6f87c2289db4bf6bf76ec5c8a..ca521300ca4867f5ce8cece40b121d1437c4ca98 100644 --- a/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py @@ -8,7 +8,6 @@ """ Magnetism reflectometry reduction """ -from __future__ import (absolute_import, division, print_function) import sys import math import numpy as np diff --git a/Framework/PythonInterface/plugins/algorithms/MaskAngle.py b/Framework/PythonInterface/plugins/algorithms/MaskAngle.py index c582e5432f4373386469db1582e90c474597dcf6..8e444a5d12e83dbdce563624d2d0c8ed11112aa4 100644 --- a/Framework/PythonInterface/plugins/algorithms/MaskAngle.py +++ b/Framework/PythonInterface/plugins/algorithms/MaskAngle.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi import mantid.kernel import mantid.api diff --git a/Framework/PythonInterface/plugins/algorithms/MaskBTP.py b/Framework/PythonInterface/plugins/algorithms/MaskBTP.py index d00a88e3827a982bd0e79fa7a3a08b90fba2dc83..7f85a18ff2cb10898093512fa9a01edea51e1a0a 100644 --- a/Framework/PythonInterface/plugins/algorithms/MaskBTP.py +++ b/Framework/PythonInterface/plugins/algorithms/MaskBTP.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi import mantid.api from mantid.kernel import Direction, IntArrayProperty, StringArrayProperty, StringListValidator diff --git a/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py b/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py index 3132c489f53f5233dee03081b42227e66d4b8ecc..df4eda9955f45361002268e7cf68693b07189ee2 100644 --- a/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py +++ b/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name, no-init -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py b/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py index 10ce38de7695091006a06951b7518c5ff202b59d..6dc3de89daf8a0192adbb1be7f09900973e25df2 100644 --- a/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-branches -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, MatrixWorkspaceProperty, ITableWorkspaceProperty, PropertyMode, MatrixWorkspace from mantid.simpleapi import * from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/MatchSpectra.py b/Framework/PythonInterface/plugins/algorithms/MatchSpectra.py index 93037bf04dd1764406923262b2a83ff3e42962a1..40e0d1f648b884d177abb38e86d98e6fbc6583c9 100644 --- a/Framework/PythonInterface/plugins/algorithms/MatchSpectra.py +++ b/Framework/PythonInterface/plugins/algorithms/MatchSpectra.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import AlgorithmFactory, MatrixWorkspaceProperty, PythonAlgorithm from mantid.kernel import Direction, FloatArrayProperty from mantid.simpleapi import ConvertToMatrixWorkspace diff --git a/Framework/PythonInterface/plugins/algorithms/Mean.py b/Framework/PythonInterface/plugins/algorithms/Mean.py index ce5122288333077846c53d35d380610d7d530e00..da10b76a2c93d59bfeb18d7195cc3347faf86e59 100644 --- a/Framework/PythonInterface/plugins/algorithms/Mean.py +++ b/Framework/PythonInterface/plugins/algorithms/Mean.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import numpy from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/MedianBinWidth.py b/Framework/PythonInterface/plugins/algorithms/MedianBinWidth.py index 004edb5c7eec1b1f08514c8ccb43b083a427f912..e3146e6189700378134150fd9f348d19758e0434 100644 --- a/Framework/PythonInterface/plugins/algorithms/MedianBinWidth.py +++ b/Framework/PythonInterface/plugins/algorithms/MedianBinWidth.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import AlgorithmFactory, HistogramValidator,\ MatrixWorkspaceProperty, PythonAlgorithm from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py b/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py index 938238597796b8cdbafb114f880937b4d74bd38a..173e428bee135f67ba77a63e4b4b1ac5fb6138b2 100644 --- a/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py +++ b/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py b/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py index 4492297d97987ffb89a34f0edae4e882104797da..2cdd2a9e4536be5e4d1cf2036562facef5f697e2 100644 --- a/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py +++ b/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import math from Muon.MaxentTools.multimaxalpha import MULTIMAX diff --git a/Framework/PythonInterface/plugins/algorithms/MuscatSofQW.py b/Framework/PythonInterface/plugins/algorithms/MuscatSofQW.py index 5c9b53886db372b6338c98de7b4e164c1b495138..a894d539e00dbfb6bdf9e52c1ef4d49437131ecc 100644 --- a/Framework/PythonInterface/plugins/algorithms/MuscatSofQW.py +++ b/Framework/PythonInterface/plugins/algorithms/MuscatSofQW.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,too-many-instance-attributes,too-many-arguments -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty) from mantid.kernel import (Direction, logger) diff --git a/Framework/PythonInterface/plugins/algorithms/NMoldyn4Interpolation.py b/Framework/PythonInterface/plugins/algorithms/NMoldyn4Interpolation.py index 6600a2f98edf27acf1f9eafcc11b414166477a1f..99b6d947ea7209c3168262408eb1de9ee055baf5 100644 --- a/Framework/PythonInterface/plugins/algorithms/NMoldyn4Interpolation.py +++ b/Framework/PythonInterface/plugins/algorithms/NMoldyn4Interpolation.py @@ -10,8 +10,6 @@ import math import numpy as np import scipy as sc -from sys import version_info - from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * @@ -48,8 +46,6 @@ class NMoldyn4Interpolation(PythonAlgorithm): doc='Output Workspace of remapped simulation data') def PyExec(self): - self.validate_environment() - e_fixed = float(self.getPropertyValue('EFixed')) # Loads simulated workspace simulation = self.getPropertyValue('InputWorkspace') @@ -80,14 +76,6 @@ class NMoldyn4Interpolation(PythonAlgorithm): VerticalAxisValues=ref_Q, WorkspaceTitle=output_ws) self.setProperty('OutputWorkspace', output_ws) - def validate_environment(self): - # RHEL 6 produces spurious results because it runs on Python 2.6.X - # test and warn for this. When RHEL6 is no longer supported this check - # can be removed - python_version = version_info - if python_version < (2, 7, 0): - logger.warning("NMoldyn4Interpolation may not run correctly on Python 2.6 and below") - def validate_bounds(self, sim_X, ref_X, sim_Q, ref_Q): if min(sim_X) > min(ref_X): raise ValueError('Minimum simulated X value is higher than minimum ' diff --git a/Framework/PythonInterface/plugins/algorithms/NormaliseSpectra.py b/Framework/PythonInterface/plugins/algorithms/NormaliseSpectra.py index 12a441399fb2063b219283d2c619837e86b31145..ff673ad2bf414284708468620a3fb15d9fdc19f1 100644 --- a/Framework/PythonInterface/plugins/algorithms/NormaliseSpectra.py +++ b/Framework/PythonInterface/plugins/algorithms/NormaliseSpectra.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import (MatrixWorkspaceProperty, DataProcessorAlgorithm, AlgorithmFactory) from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/OrderWorkspaceHistory.py b/Framework/PythonInterface/plugins/algorithms/OrderWorkspaceHistory.py index 0a652ac6aa826ca55c73b7797ef214399036a781..a3a7ca9b102a8c58d554b7e126d956120cc17b1f 100644 --- a/Framework/PythonInterface/plugins/algorithms/OrderWorkspaceHistory.py +++ b/Framework/PythonInterface/plugins/algorithms/OrderWorkspaceHistory.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function - import os import tokenize import glob diff --git a/Framework/PythonInterface/plugins/algorithms/PDConvertRealSpace.py b/Framework/PythonInterface/plugins/algorithms/PDConvertRealSpace.py index af20bcc293bf1887686c89318f581a6cf86acf0f..e60e2c89ca7611f6078dd3bd702a6e483b42a26a 100644 --- a/Framework/PythonInterface/plugins/algorithms/PDConvertRealSpace.py +++ b/Framework/PythonInterface/plugins/algorithms/PDConvertRealSpace.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import (PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceProperty, WorkspaceFactory) diff --git a/Framework/PythonInterface/plugins/algorithms/PDConvertReciprocalSpace.py b/Framework/PythonInterface/plugins/algorithms/PDConvertReciprocalSpace.py index e6c796f1b81e1a1e92372521a02ec3772ea9a0b8..a2209b5605918fc573bbc672a15f0f6ca5cc3479 100644 --- a/Framework/PythonInterface/plugins/algorithms/PDConvertReciprocalSpace.py +++ b/Framework/PythonInterface/plugins/algorithms/PDConvertReciprocalSpace.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import (PythonAlgorithm, AlgorithmFactory, WorkspaceUnitValidator, MatrixWorkspaceProperty, WorkspaceProperty, WorkspaceFactory) diff --git a/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py b/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py index 5c016a408c7c3d2addc7d80370d05dd317516de3..da17a93e6d36f602aa6a4e0ec8e9ea80694a7f66 100644 --- a/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py +++ b/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import * from mantid.kernel import Direction, FloatArrayProperty, StringListValidator diff --git a/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py b/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py index 1b529a9d6ea7016339a6662e1c3d4620af315ce6..49a1356e4c8d52ec587877b3fd780709a4d517da 100644 --- a/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py +++ b/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import AlignAndFocusPowder, AlignAndFocusPowderFromFiles, \ NormaliseByCurrent, PDDetermineCharacterizations,PDLoadCharacterizations, \ SaveGSS, SetUncertainties diff --git a/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py b/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py index 83553032a2a2e0a62469676e352f9b314db9a68b..77b62ce576abaeb6e224b686f02e240f00540ff0 100644 --- a/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py b/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py index 62dfdc88e0385995b55ceaf524655722d008ec15..f776116e342156574e38d60f74291ecbb722aefc 100644 --- a/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py +++ b/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - # pylint: disable=no-init,invalid-name,too-few-public-methods,unused-import from mantid.kernel import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/PoldiLoadRuns.py b/Framework/PythonInterface/plugins/algorithms/PoldiLoadRuns.py index aba6c8a29aae97d78f476afcd20a8d04a8d7c268..071a07d1f380823bdba4dd61f36726e61f44a05d 100644 --- a/Framework/PythonInterface/plugins/algorithms/PoldiLoadRuns.py +++ b/Framework/PythonInterface/plugins/algorithms/PoldiLoadRuns.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - # pylint: disable=no-init,invalid-name,bare-except from mantid.kernel import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/PoldiMerge.py b/Framework/PythonInterface/plugins/algorithms/PoldiMerge.py index cbb2b0d32a57800f373cfed976e9d1565097db21..c75aaee36d43edff02b83cc18b8bca045c67f40d 100644 --- a/Framework/PythonInterface/plugins/algorithms/PoldiMerge.py +++ b/Framework/PythonInterface/plugins/algorithms/PoldiMerge.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.kernel import StringArrayProperty, Direction from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py b/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py index ee5baf1560dbfe9bcda19e18a0eefc34820b3452..9a73e3b29ba923fb912deee02d7aefd9c69ff709 100644 --- a/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py +++ b/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py @@ -5,10 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - -from six.moves import range #pylint: disable=redefined-builtin - from mantid.api import * import mantid.simpleapi as api from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/ReflectometryReductionOneLiveData.py b/Framework/PythonInterface/plugins/algorithms/ReflectometryReductionOneLiveData.py index 485b7c2c9e5a3e5647fd59f3e35336e3d1ce9a18..b3aee6bf987d249e3fdf2d71e9eccd69e9313e67 100644 --- a/Framework/PythonInterface/plugins/algorithms/ReflectometryReductionOneLiveData.py +++ b/Framework/PythonInterface/plugins/algorithms/ReflectometryReductionOneLiveData.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/ReflectometrySliceEventWorkspace.py b/Framework/PythonInterface/plugins/algorithms/ReflectometrySliceEventWorkspace.py index 65cf8ce0b25315f036f1f9aaaa07a089f4c385f3..785929f3bf13e953084b65f83035b541d34f4e66 100644 --- a/Framework/PythonInterface/plugins/algorithms/ReflectometrySliceEventWorkspace.py +++ b/Framework/PythonInterface/plugins/algorithms/ReflectometrySliceEventWorkspace.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/ResNorm.py b/Framework/PythonInterface/plugins/algorithms/ResNorm.py index 3e0a41f0ed22683e78e045e9627d6dae2521f684..69d653e87e7884a074001851f57bfe10b9bd3c51 100644 --- a/Framework/PythonInterface/plugins/algorithms/ResNorm.py +++ b/Framework/PythonInterface/plugins/algorithms/ResNorm.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory from mantid.kernel import StringListValidator, StringMandatoryValidator from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py b/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py index b964d99cb5ad0f0166196f6d3e3d719d7997035b..c3f79a6f6cb5cc0bda5c71cf9654f372c20ddee6 100644 --- a/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py +++ b/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py @@ -5,13 +5,12 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory, ITableWorkspaceProperty from mantid.simpleapi import * from mantid.kernel import StringMandatoryValidator, Direction from mantid import config import os -from six.moves import filterfalse +from itertools import filterfalse class Intervals(object): diff --git a/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py b/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py index 360128e7fc25a694d04bac124b0520ccb7e14991..0507c9f139c17ae63cc215521d5ee7e32800be8e 100644 --- a/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py +++ b/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import Direction, FloatBoundedValidator import mantid.simpleapi diff --git a/Framework/PythonInterface/plugins/algorithms/SANSWideAngleCorrection.py b/Framework/PythonInterface/plugins/algorithms/SANSWideAngleCorrection.py index 7d32302fc0554d23daba58afe421c80c465834ae..1f3484d86e4990e4612de10ea16dd10a3602ddf3 100644 --- a/Framework/PythonInterface/plugins/algorithms/SANSWideAngleCorrection.py +++ b/Framework/PythonInterface/plugins/algorithms/SANSWideAngleCorrection.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * import sys diff --git a/Framework/PythonInterface/plugins/algorithms/SNAPReduce.py b/Framework/PythonInterface/plugins/algorithms/SNAPReduce.py index 9209a655c97e77ae542f000b97a958c2b8a74664..c1091dae18e445348cbbaa675088974322a53a51 100644 --- a/Framework/PythonInterface/plugins/algorithms/SNAPReduce.py +++ b/Framework/PythonInterface/plugins/algorithms/SNAPReduce.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,no-init,too-many-lines -from __future__ import (absolute_import, division, print_function) from mantid.kernel import Direction, FloatArrayProperty, IntArrayBoundedValidator, \ IntArrayProperty, Property, StringListValidator from mantid.api import AlgorithmFactory, DataProcessorAlgorithm, FileAction, FileProperty, \ diff --git a/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py b/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py index 3e16ac1decc25d9661b4daf9d6c8fa6c9529a8ef..ec73d3dbd4a31cc895423c3c73c8584bce325d75 100644 --- a/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init,too-many-lines -from __future__ import (absolute_import, division, print_function) import numpy as np import os @@ -16,8 +15,6 @@ from mantid.api import mtd, AlgorithmFactory, AnalysisDataService, DistributedDa from mantid.kernel import ConfigService, Direction, FloatArrayProperty, FloatBoundedValidator, \ IntArrayBoundedValidator, IntArrayProperty, Property, PropertyManagerDataService, StringListValidator from mantid.dataobjects import SplittersWorkspace # SplittersWorkspace -from six.moves import range #pylint: disable=redefined-builtin - if AlgorithmFactory.exists('GatherWorkspaces'): HAVE_MPI = True from mpi4py import MPI diff --git a/Framework/PythonInterface/plugins/algorithms/SaveGEMMAUDParamFile.py b/Framework/PythonInterface/plugins/algorithms/SaveGEMMAUDParamFile.py index 98786ee7d66810e7046298f64737d7e17fadd1f1..62340186d56958859d9b0a9f219faf582357ed02 100644 --- a/Framework/PythonInterface/plugins/algorithms/SaveGEMMAUDParamFile.py +++ b/Framework/PythonInterface/plugins/algorithms/SaveGEMMAUDParamFile.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import math import os import re diff --git a/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py b/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py index 9cf53e444d791ff1ef415bad5f108c63d5d6a708..77e0cd80080691487690110eec1326d9fe35f575 100644 --- a/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py +++ b/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py @@ -5,13 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import numpy as np import mantid import mantid.simpleapi as api from mantid.kernel import StringListValidator -from six.moves import range #pylint: disable=redefined-builtin - try: import h5py # http://www.h5py.org/ except ImportError: diff --git a/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py b/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py index 4fcdcd54360c963e0c19657c41ebfdb96968b566..23d30df368c05997388f9e981b38379944a2e369 100644 --- a/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py +++ b/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,unused-variable,invalid-name,bare-except -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/SaveReflections.py b/Framework/PythonInterface/plugins/algorithms/SaveReflections.py index cce52b5e21a5e34f55da4e0493fa022c1c9c5b05..a2311f7d642954ddeec7959c62fee1c4bd94788f 100644 --- a/Framework/PythonInterface/plugins/algorithms/SaveReflections.py +++ b/Framework/PythonInterface/plugins/algorithms/SaveReflections.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - import os.path as osp import numpy as np from mantid.api import (AlgorithmFactory, FileProperty, FileAction, IPeaksWorkspaceProperty, PythonAlgorithm) from mantid.kernel import StringListValidator, Direction -from mantid.py3compat.enum import Enum +from enum import Enum def num_modulation_vectors(workspace): diff --git a/Framework/PythonInterface/plugins/algorithms/SaveYDA.py b/Framework/PythonInterface/plugins/algorithms/SaveYDA.py index c2fe2aa45ee3327782db27c156b4e739fe54530e..2b0f0a5ffed80970b9d66ed820613a179f835674 100644 --- a/Framework/PythonInterface/plugins/algorithms/SaveYDA.py +++ b/Framework/PythonInterface/plugins/algorithms/SaveYDA.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function - from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceUnitValidator, \ InstrumentValidator, FileProperty, FileAction from mantid.kernel import Direction, CompositeValidator diff --git a/Framework/PythonInterface/plugins/algorithms/SelectNexusFilesByMetadata.py b/Framework/PythonInterface/plugins/algorithms/SelectNexusFilesByMetadata.py index cb51bf58f83332ee83bad5dfcb617f7c40eb5c84..51027b1c8cc472f125a62e547bdf0b6d63344aad 100644 --- a/Framework/PythonInterface/plugins/algorithms/SelectNexusFilesByMetadata.py +++ b/Framework/PythonInterface/plugins/algorithms/SelectNexusFilesByMetadata.py @@ -5,12 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=eval-used -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * -from six import PY3 class SelectNexusFilesByMetadata(PythonAlgorithm): @@ -108,8 +105,7 @@ class SelectNexusFilesByMetadata(PythonAlgorithm): if str(value.dtype).startswith('|S'): # string value, need to quote for eval - if PY3: - value = value.decode() + value = value.decode() toeval += '\"' + value + '\"' else: toeval += str(value) diff --git a/Framework/PythonInterface/plugins/algorithms/SetDetScale.py b/Framework/PythonInterface/plugins/algorithms/SetDetScale.py index 7ab33c62646b5dc04577c99c9672d094f87d1fbc..8bd94324569c50724248f6db002f9789a84be5c1 100644 --- a/Framework/PythonInterface/plugins/algorithms/SetDetScale.py +++ b/Framework/PythonInterface/plugins/algorithms/SetDetScale.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty, InstrumentValidator, FileProperty, FileAction from mantid.kernel import Direction, StringArrayProperty import mantid.simpleapi as api diff --git a/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py b/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py index 8a1b33421b6ae286a6b8ef908e8e992293e623d2..3db628c5aa0f07e72c0dce8c55616ae3bd99c005 100644 --- a/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py +++ b/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * import mantid.simpleapi as ms diff --git a/Framework/PythonInterface/plugins/algorithms/SortDetectors.py b/Framework/PythonInterface/plugins/algorithms/SortDetectors.py index f28c2dd820f19d845ea30f058bd2e131032861ee..478365bb8231d98df83d0da083540f7653a2d5f0 100644 --- a/Framework/PythonInterface/plugins/algorithms/SortDetectors.py +++ b/Framework/PythonInterface/plugins/algorithms/SortDetectors.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory from mantid.kernel import Direction,IntArrayProperty, FloatArrayProperty import mantid diff --git a/Framework/PythonInterface/plugins/algorithms/StatisticsOfTableWorkspace.py b/Framework/PythonInterface/plugins/algorithms/StatisticsOfTableWorkspace.py index e5b63c8879312bb695cb8359d93458111974f202..d8317f1bd4f022d5c3a405d9a1c3d800febed75c 100644 --- a/Framework/PythonInterface/plugins/algorithms/StatisticsOfTableWorkspace.py +++ b/Framework/PythonInterface/plugins/algorithms/StatisticsOfTableWorkspace.py @@ -6,13 +6,9 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - import collections import numpy as np -from six import iteritems - import mantid.simpleapi as ms from mantid import logger, mtd from mantid.api import AlgorithmFactory, ITableWorkspaceProperty, PythonAlgorithm @@ -89,7 +85,7 @@ class StatisticsOfTableWorkspace(PythonAlgorithm): except: logger.notice('Column \'%s\' is not numerical, skipping' % column_name) - for index, stat_name in iteritems(stats): + for index, stat_name in stats.items(): stat = collections.OrderedDict(stat_name) stat['Statistic'] = index out_ws.addRow(stat) diff --git a/Framework/PythonInterface/plugins/algorithms/StringToPng.py b/Framework/PythonInterface/plugins/algorithms/StringToPng.py index 9e78bbc9df0ff6277bbda20b1dfdaf389279096b..fabb831e5e8b6360a0726baec2f313df9f14284e 100644 --- a/Framework/PythonInterface/plugins/algorithms/StringToPng.py +++ b/Framework/PythonInterface/plugins/algorithms/StringToPng.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) -from six import u import mantid @@ -53,7 +51,7 @@ class StringToPng(mantid.api.PythonAlgorithm): import matplotlib.pyplot as plt fig=plt.figure(figsize=(.1,.1)) ax1=plt.axes(frameon=False) - ax1.text(0.,1,bytearray(u(self.getProperty("String").valueAsStr), 'utf-8').decode('unicode_escape'),va="center",fontsize=16) + ax1.text(0.,1,bytearray(self.getProperty("String").valueAsStr, 'utf-8').decode('unicode_escape'),va="center",fontsize=16) ax1.axes.get_xaxis().set_visible(False) ax1.axes.get_yaxis().set_visible(False) filename = self.getProperty("OutputFilename").value diff --git a/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py b/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py index cb70790b3d4f086039a18848b740122345a47c17..f5d3604781819b3419230bec8d2c3b5d533e7136 100644 --- a/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py +++ b/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, AlgorithmFactory from mantid.kernel import FloatBoundedValidator,Direction import numpy as np diff --git a/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py b/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py index 85332455c48be368836d6e4b53c011cfebd309aa..dafd7fee8df673b9c45e31f36d62805b77217026 100644 --- a/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py +++ b/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory from mantid.kernel import FloatBoundedValidator,Direction,logger import numpy diff --git a/Framework/PythonInterface/plugins/algorithms/Symmetrise.py b/Framework/PythonInterface/plugins/algorithms/Symmetrise.py index cd94eb2b70457f0a0422e0f0d5931db8b08c49ef..d9e032f0a882a5206114a9e97c82df73c38454da 100644 --- a/Framework/PythonInterface/plugins/algorithms/Symmetrise.py +++ b/Framework/PythonInterface/plugins/algorithms/Symmetrise.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import math import numpy as np diff --git a/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py b/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py index 03378303122d0fa42772fadafa125988136ce0bf..78cf7aa02c90150a4474ff06f4e2ec77ee51ebae 100644 --- a/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py +++ b/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty # , WorkspaceUnitValidator from mantid.kernel import Direction import mantid.simpleapi as api diff --git a/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py b/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py index abb4c95648ad2fe839262f3af37c567430ece10a..8016ee86d7827bd083849c69a3136c80cf8b64a0 100644 --- a/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py +++ b/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import Direction, StringArrayProperty, StringArrayLengthValidator from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty, WorkspaceGroup import mantid.simpleapi as api diff --git a/Framework/PythonInterface/plugins/algorithms/TestWorkspaceGroupProperty.py b/Framework/PythonInterface/plugins/algorithms/TestWorkspaceGroupProperty.py index 7e29d62fd2b7a0eddc9f3007a6b4f582de35b708..23c5f2ae52b3575d8946f6af31e1472440951294 100644 --- a/Framework/PythonInterface/plugins/algorithms/TestWorkspaceGroupProperty.py +++ b/Framework/PythonInterface/plugins/algorithms/TestWorkspaceGroupProperty.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py b/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py index d8c47e652780fdd20e12d85fd2824ca38a559b96..9a1b3caaca4e70a2af82a2378cc1032fb7893796 100644 --- a/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py +++ b/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/UpdatePeakParameterTableValue.py b/Framework/PythonInterface/plugins/algorithms/UpdatePeakParameterTableValue.py index bef0a617508de4d8eece1bdbb65f02aeadad57b5..712b49f5aae058cdafd0fd1ae1e8ba1e448294ef 100644 --- a/Framework/PythonInterface/plugins/algorithms/UpdatePeakParameterTableValue.py +++ b/Framework/PythonInterface/plugins/algorithms/UpdatePeakParameterTableValue.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six.moves import range - import mantid import mantid.api import mantid.kernel diff --git a/Framework/PythonInterface/plugins/algorithms/VelocityAutoCorrelations.py b/Framework/PythonInterface/plugins/algorithms/VelocityAutoCorrelations.py index bf67e3507a6d82e93b4cc402416e7efc6ef0ea75..4b481791eb119a6d388a654c2ec42e164f7d6810 100644 --- a/Framework/PythonInterface/plugins/algorithms/VelocityAutoCorrelations.py +++ b/Framework/PythonInterface/plugins/algorithms/VelocityAutoCorrelations.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-branches,too-many-locals, invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/VelocityCrossCorrelations.py b/Framework/PythonInterface/plugins/algorithms/VelocityCrossCorrelations.py index 053df6409699e4bee5bc7a95aa3190faec344709..bfb207631992ed3c1cfc6da62174354bcb1b17a5 100644 --- a/Framework/PythonInterface/plugins/algorithms/VelocityCrossCorrelations.py +++ b/Framework/PythonInterface/plugins/algorithms/VelocityCrossCorrelations.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-branches,too-many-locals, invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/VesuvioCorrections.py b/Framework/PythonInterface/plugins/algorithms/VesuvioCorrections.py index 2e900d72505487f0c990f04355f5547e885afe9f..068b10ae505b87277b1554c215f9194b8ee0ff62 100644 --- a/Framework/PythonInterface/plugins/algorithms/VesuvioCorrections.py +++ b/Framework/PythonInterface/plugins/algorithms/VesuvioCorrections.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init, too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) -from six import iteritems - from mantid.kernel import * from mantid.api import * from vesuvio.base import VesuvioBase, TableWorkspaceDictionaryFacade @@ -418,7 +415,7 @@ class VesuvioCorrections(VesuvioBase): for idx, wsn in enumerate(fit_workspaces): tie = '' - for param, value in iteritems(fixed_parameters): + for param, value in fixed_parameters.items(): if param in wsn: tie = 'Scaling=%f,' % value function_str = "name=TabulatedFunction,Workspace=%s," % wsn \ diff --git a/Framework/PythonInterface/plugins/algorithms/VesuvioPreFit.py b/Framework/PythonInterface/plugins/algorithms/VesuvioPreFit.py index 3c527fb75e7a069a41796168f22848b8b59533ba..2ac15fcb195355a1b6fa3417bf4010232f1144b6 100644 --- a/Framework/PythonInterface/plugins/algorithms/VesuvioPreFit.py +++ b/Framework/PythonInterface/plugins/algorithms/VesuvioPreFit.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.api import * import numpy as np diff --git a/Framework/PythonInterface/plugins/algorithms/VesuvioResolution.py b/Framework/PythonInterface/plugins/algorithms/VesuvioResolution.py index 4410508417c93016406ed41c1c275f8b6dca6885..ea1221bc71237de58076f54bfe50f0a6d97c02cf 100644 --- a/Framework/PythonInterface/plugins/algorithms/VesuvioResolution.py +++ b/Framework/PythonInterface/plugins/algorithms/VesuvioResolution.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * from vesuvio.base import VesuvioBase diff --git a/Framework/PythonInterface/plugins/algorithms/VesuvioTOFFit.py b/Framework/PythonInterface/plugins/algorithms/VesuvioTOFFit.py index 2e8e283f6c2ae67511fe80581c6d4de6fdaf16a3..838497f8eaedb4c83b925f30c401acafc3e3906a 100644 --- a/Framework/PythonInterface/plugins/algorithms/VesuvioTOFFit.py +++ b/Framework/PythonInterface/plugins/algorithms/VesuvioTOFFit.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/VesuvioThickness.py b/Framework/PythonInterface/plugins/algorithms/VesuvioThickness.py index 933fff2a076dffc0446af531f65a1fffa135d9c8..38af2e0fdd19d8ed295d2be15b92b9353ed26520 100644 --- a/Framework/PythonInterface/plugins/algorithms/VesuvioThickness.py +++ b/Framework/PythonInterface/plugins/algorithms/VesuvioThickness.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import Direction, FloatArrayProperty from mantid.api import (PythonAlgorithm, AlgorithmFactory, ITableWorkspaceProperty) diff --git a/Framework/PythonInterface/plugins/algorithms/ViewBOA.py b/Framework/PythonInterface/plugins/algorithms/ViewBOA.py index e434c18f253ecf18c4f5321cbccdc2679c3406d0..8162aa958f8ee7a4110753ad8a2e0728f65ef0e8 100644 --- a/Framework/PythonInterface/plugins/algorithms/ViewBOA.py +++ b/Framework/PythonInterface/plugins/algorithms/ViewBOA.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.api import AlgorithmFactory from mantid.api import PythonAlgorithm from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/VisionReduction.py b/Framework/PythonInterface/plugins/algorithms/VisionReduction.py index 059774b2774ff020ffda57b10f34fa8d0fc5d263..331caed9313d5dd443db5ba93f17a7a3d853d332 100644 --- a/Framework/PythonInterface/plugins/algorithms/VisionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/VisionReduction.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - #from mantid.api import AlgorithmFactory #from mantid.simpleapi import PythonAlgorithm, WorkspaceProperty # from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py index b37888685b714313c9606d78da2c476f0bb3a5d1..4af6349a0cfc922a893fbfc9b68ea5495df21d44 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrection.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrection.py index 8dcc0bb10941d970909d919aad4112a16e744a59..e7855f92bdc1d38fd24edc1978996257bc1568e4 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrection.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrection.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceGroupProperty, \ PropertyMode, MatrixWorkspace, Progress, WorkspaceGroup diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesQuasi.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesQuasi.py index 3c7fdd0f6c602c1e1ef6fe05a20fd01c4551d52b..202bb4d404a93b7bd80b8d45dae3d32cdcec0a22 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesQuasi.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesQuasi.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,too-many-instance-attributes,too-many-branches,no-init,redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six.moves import range -from six import next import os import numpy as np diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesStretch.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesStretch.py index 699c1a4ba9bba8fb7803d9c964226335382f3894..0dfe3e5d445b18840aa8b32e94861c1ef9840057 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesStretch.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/BayesStretch.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,too-many-instance-attributes,too-many-branches,no-init -from __future__ import (absolute_import, division, print_function) from IndirectImport import * from mantid.api import (PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py index aa6a54c5981588140a4bf90fcde78b557c3a4544..5ff2ba5032610737df92852cb1520d5fdc002058 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, PropertyMode, WorkspaceGroupProperty, Progress, mtd, SpectraAxis, WorkspaceGroup, WorkspaceProperty) from mantid.kernel import (VisibleWhenProperty, PropertyCriterion, StringListValidator, IntBoundedValidator, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py index f6a35cabbce59b4741134a1110aebf1a373e6268..5af04c107d5a9f1107ca120d8d873fc51732c9fa 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, mtd, AlgorithmFactory, FileProperty, FileAction, MultipleFileProperty, WorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeighting.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeighting.py index b63e2d672aaee904aa1abcef3ffaffd288bc9a29..31bca62a56d5e3a3b28782d3a3d858fd05cb5009 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeighting.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeighting.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceUnitValidator, \ diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py index 8421e94002c350f5891dec86396058fc1defbda6..61c40765fbbc916b03af60ba07c0ec782d79d1ca 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import DirectILL_common as common import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, InstrumentValidator, MatrixWorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py index 0dedded20fe2f2fd8cf0577bdc99b05086563e31..8cf060771b82144791fa66266bcae5a1bf5f7535 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import DirectILL_common as common import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, FileAction, InstrumentValidator, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py index d32d5a396da370e1fbc727d722e074249a9e1845..d1be09c8be4391ac05084087a0c0412c69f64a5d 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import DirectILL_common as common import ILL_utilities as utils import mantid diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py index 66544e3aace637a8be3caed990b6548b2605cbca..6519ee8079a89868f9ee8ded544bb3f9c2f900a8 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import DirectILL_common as common import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, InstrumentValidator, ITableWorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py index a9407cb0633fbdb11a1b57e07046bd9e1d9e187c..c0366f02f481f4ef6f42c8829fc62e8477d4d7be 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import DirectILL_common as common import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, InstrumentValidator, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py index 11b26505bff94b3a2a0605459b5e2ea574b398fd..bcf39c2890c30af479fc0f730330152bfb25a5b7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import DirectILL_common as common import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, InstrumentValidator, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILL_common.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILL_common.py index 8e6d94ffc04610d52a50b3046d63a523fd981984..f59858b98a71091c36dae7e9e8beab0943dfb643 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILL_common.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILL_common.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - ABSOLUTE_UNITS_OFF = 'Absolute Units OFF' ABSOLUTE_UNITS_ON = 'Absolute Units ON' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSAzimuthalAverage1D.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSAzimuthalAverage1D.py index 07b7f4c8035e5308d16bddf4243a91985c646431..01b62ee674204afbe30055d6f80e3df95626c843 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSAzimuthalAverage1D.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSAzimuthalAverage1D.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import math from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSDirectBeamTransmission.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSDirectBeamTransmission.py index 191383701f8c11397ca33cc38a3ee05c804204d0..f2000bdb9605f0380bf8b66eaf1cab40b1c7acda 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSDirectBeamTransmission.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSDirectBeamTransmission.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #Pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import os from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSNormalise.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSNormalise.py index ed1532d1e37a2697716bf0eb21036801bab99dfd..dbd33336ec02af08cd24bf08dbecc949dc8f9cfc 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSNormalise.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/EQSANSNormalise.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - import os from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py index 34ad391e3663ddb847f7b84236946ed192aa70ef..f494bbd06b29f8ce0cd73b1b5c3e4e98de99611a 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import AppendSpectra, CloneWorkspace, ElasticWindow, LoadLog, Logarithm, SortXAxis, Transpose from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py index 71815d40ff00dc0b2574dc1e7cb0d2b36bcec872..1017e09ec3cca82d27abf0f109842e0a52d883de 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FindPeaksAutomatic.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - from mantid.simpleapi import (ConvertToPointData, CreateWorkspace, DeleteWorkspace, CreateEmptyTableWorkspace, FitGaussianPeaks) from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, WorkspaceProperty, Progress, ITableWorkspaceProperty) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py index c5f5f9c6fa8f263bc5908f9574dea5c0ee81349a..4465dd385c1f18655e0c497ebcb8077e4b1309c1 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaks.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - from mantid.simpleapi import (CreateEmptyTableWorkspace, Fit) from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, WorkspaceProperty, ITableWorkspaceProperty) from mantid.kernel import (Direction, FloatBoundedValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py index 5185712cfeed5775ab296aed39a10335305987ea..406d8a7c04f02da4de154b5cbf8ced2cfb29bc7d 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrection.py @@ -6,10 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) import math -from six import iteritems -from six import integer_types import numpy as np from mantid.simpleapi import * @@ -545,10 +542,10 @@ class FlatPlatePaalmanPingsCorrection(PythonAlgorithm): @param sample_logs Dictionary of logs to append to the workspace. """ - for key, value in iteritems(sample_logs): + for key, value in sample_logs.items(): if isinstance(value, bool): log_type = 'String' - elif isinstance(value, (integer_types, float)): + elif isinstance(value, (int, float)): log_type = 'Number' else: log_type = 'String' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/HFIRSANSReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/HFIRSANSReduction.py index 01dcabe76d0be311856b405612cff62ac3c6a7ae..bf6218a4d2e941b142dd056242cf1241194186b2 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/HFIRSANSReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/HFIRSANSReduction.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,too-many-branches -from __future__ import (absolute_import, division, print_function) - import os import mantid.simpleapi as api from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ILL_utilities.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ILL_utilities.py index dc0c9390ee4bc5f179d93d78c8b99be7cdb8e4cb..b196bbec52de553d5ba63803e7a27994b16edd3a 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ILL_utilities.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ILL_utilities.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid import mtd from mantid.simpleapi import DeleteWorkspace diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py index 9c7253650ce2ea640cc324445484a53d1b22281d..46c5137710295b58013c24f2ca695a437b73a71f 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) - import os from IndirectReductionCommon import load_files, load_file_ranges diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransfer.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransfer.py index 360d2c196d454959b33d0e5cce6622db423a7669..594ee2f303a5482f1e36a0a23138817ad60f67bd 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransfer.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransfer.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,too-many-instance-attributes,too-many-branches,no-init,deprecated-module -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.api import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapper.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapper.py index 3a17e0c6b1880e4096a7bdebc059f1b4df7a7113..386f3ca13689e66d1a0c14d4759093ec2b76abef 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapper.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapper.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,too-many-instance-attributes,too-many-branches,no-init,deprecated-module -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import (Direction, FloatArrayProperty, FloatBoundedValidator, IntArrayMandatoryValidator, IntArrayProperty, Property, StringArrayProperty, StringListValidator) from mantid.api import (AlgorithmFactory, AnalysisDataService, DataProcessorAlgorithm, FileAction, FileProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption.py index e9897f0f21015438c8ec7c237b66b5604d0f4587..1128433da40c47f6b831b7f9369652e14d35085b 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init, too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress, WorkspaceGroupProperty from mantid.kernel import (StringMandatoryValidator, Direction, logger, IntBoundedValidator, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2.py index 2c4c3e16b404cba9decf6933c603087e1307303d..f20f99ca995116971ffab6a464a302df61d7f647 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import SetBeam, SetSample, MonteCarloAbsorption, GroupWorkspaces from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress, WorkspaceGroupProperty, mtd) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCalibration.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCalibration.py index dde63797fb7f80b6fb04e48144b11ee3a52e2857..5723cfb0b0a636682332d011f5867a162bc1f04f 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCalibration.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCalibration.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption.py index ccb203631a53097551a26ce687d5bef36a30803e..6c2bd0d98b964fa8fe678149948916840f5ea56c 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init, too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceGroupProperty, PropertyMode, Progress from mantid.kernel import (StringMandatoryValidator, Direction, logger, FloatBoundedValidator, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2.py index 48fda32f4803d5ce1ed10f0f061e9c40bfbd6f3b..7d7bbdfb82e7bb4a2f05ca683286eac38f631887 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import SetBeam, SetSample, MonteCarloAbsorption, GroupWorkspaces from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceGroupProperty, PropertyMode, Progress, mtd) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScan.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScan.py index 1a38968706b25f755b4e044f3ab7a3cf8e784278..19c2e796aadef4cb43377666ea066320634d98a5 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScan.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScan.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption.py index ff96daf0257294493e558f574801729c3e770298..61cde324b02868af53607569e9f2d28ca843cafd 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,too-many-instance-attributes,too-many-branches -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress, WorkspaceGroupProperty from mantid.kernel import StringMandatoryValidator, Direction, logger, FloatBoundedValidator, MaterialBuilder, StringListValidator diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2.py index 8db5610f7112ae439d9cb82ee7f6732d62ff0bd7..666e78248382a47ad579cd41c59094d14053a7b7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import SetBeam, SetSample, MonteCarloAbsorption, GroupWorkspaces from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, Progress, WorkspaceGroupProperty, mtd) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py index 3f601a6fa456ab98007cf6bf01e7fd7a488993c9..74807247b714867a19e6a7e2a8c6ad916b501b0a 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import math import numpy as np diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py index 14d44c754fe7d5a5f2607085bdabed558380ca8a..371f22023bb2c7c9baff559eb00754787d6193f7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import time from mantid import mtd @@ -627,7 +625,7 @@ class IndirectILLReductionFWS(PythonAlgorithm): self._set_x_label(wsname) - for energy, ws_list in iteritems(self._all_runs[label]): + for energy, ws_list in self._all_runs[label].items(): for ws in ws_list: DeleteWorkspace(ws) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py index 8aa7953c9b5f166f409e063f314b7a8c985c5d4d..a856a1156d81fcc9459a337d249c280aa843db01 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import numpy from mantid import mtd diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResult.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResult.py index ace858f77ef36e13b7250e7b95ea287248797fbe..edb029673aa6189feebeb9454bd88f9e4e31fc96 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResult.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResult.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) from mantid.api import (AlgorithmFactory, AnalysisDataService, MatrixWorkspace, MatrixWorkspaceProperty, PythonAlgorithm, PropertyMode, WorkspaceGroup) from mantid.kernel import Direction diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectResolution.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectResolution.py index 77c0a9b0e181096328df7a107b8e84b6ad9ed781..1f85f9d7b2a3bc049991cc1b2c983719c20f19af 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectResolution.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectResolution.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitor.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitor.py index 9772aeeffa8dd2c91dcafe6f3670013789c98dc9..f79f718ac4ac089b04052e2c876a9e88081ee6ab 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitor.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitor.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IqtFitMultiple.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IqtFitMultiple.py index b224bae32d1e9dc63355d5da3a0bcf2386e7bd9f..943cdb271e8a56813ed12912d96d4118729eb939 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IqtFitMultiple.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IqtFitMultiple.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid import logger, AlgorithmFactory from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/LoadWAND.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/LoadWAND.py index db0196c14bb833cf750411ceca834aa37cb372e6..ec051e4bd68dda761a5051a8fd41526667b61bb1 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/LoadWAND.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/LoadWAND.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from mantid.api import DataProcessorAlgorithm, AlgorithmFactory, MultipleFileProperty, FileAction, WorkspaceProperty from mantid.kernel import Direction, UnitConversion, Elastic, Property, IntArrayProperty, StringListValidator from mantid.simpleapi import (mtd, SetGoniometer, AddSampleLog, MaskBTP, RenameWorkspace, GroupWorkspaces, CreateWorkspace, LoadNexusLogs, LoadInstrument) -from six.moves import range import numpy as np import h5py diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py index c2af5e28821476a1f87202e79b98ec444a18e112..8e1e73ad498eb1693dceafa11d73c8ddd9afb98a 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, mtd, AlgorithmFactory, FileProperty, FileAction, MultipleFileProperty, WorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MSDFit.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MSDFit.py index 982335ab975e735777eb2076bd41ac818c017175..d9f1b4ee8ad0a64b0d951f3b2b16039dac27e9d1 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MSDFit.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MSDFit.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * -from six.moves import range # pylint: disable=redefined-builti class MSDFit(DataProcessorAlgorithm): diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py index 85937583480bbee0e48cd637a3482228a8789a5e..6edbf73f9f0d2b66acf6cc020a2310574c004025 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspaces.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import (AnalysisDataService, CloneWorkspace, ConjoinWorkspaces, CropWorkspaceRagged, DeleteWorkspace, MatchSpectra, Rebin, SumSpectra) from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, WorkspaceProperty, WorkspaceGroup, ADSValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MolDyn.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MolDyn.py index 16a540fbf96cc3a6079cbab399ee68830f05add8..f02df5e68a16732e8a4a4f4676895aa4ee0083cf 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MolDyn.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MolDyn.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatData.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatData.py index 86d9a2a703cf248675b225aca5f8af751585de2c..27f09164da4ae7537012f74534099add648c0a04 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatData.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatData.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init # Algorithm to start Bayes programs -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, AlgorithmFactory from mantid.kernel import StringListValidator, StringMandatoryValidator diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatFunc.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatFunc.py index 634b2b2ff30817874d664b26845f6cce2bda5c54..a28b8c35ea7d9d475a6ee9464ebad96b03f533b7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatFunc.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MuscatFunc.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name # Algorithm to start Bayes programs -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import StringListValidator, StringMandatoryValidator from mantid.api import PythonAlgorithm, AlgorithmFactory diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/NormaliseByThickness.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/NormaliseByThickness.py index d52c007137b7824261a98e91ec9daac4f87d0983..25b3ceb9763a69a891f79283f15a84f6749c3b57 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/NormaliseByThickness.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/NormaliseByThickness.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py index 7375fd46240ec1a29c221fc160e381889d32a6ad..fef2fcf7a79034a2a8c6443330553823edef86bc 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import itertools from IndirectReductionCommon import load_files diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py index 638eeb4b6bd22fd2daf75d9778b28de459ed29c7..1a1f15dc9af55e2a590e7999d6f25ecda4c59e80 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,attribute-defined-outside-init,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScan.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScan.py index a2cbad2b926d971973dce5ac2ae2ae65008e3c55..9617fda958a9f2ee7f5d7650e74c67b69ff2652e 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScan.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScan.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import CompositeValidator, Direction, FloatArrayLengthValidator, FloatArrayOrderedPairsValidator, \ FloatArrayProperty, StringListValidator, IntBoundedValidator from mantid.api import DataProcessorAlgorithm, MultipleFileProperty, Progress, WorkspaceGroupProperty, FileProperty, FileAction diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLEfficiency.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLEfficiency.py index 8d0d28f0cef46239b0d3066505511c2b42a576d0..9ed9d96db60471f5bdf3d7015db06075a8b0f4aa 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLEfficiency.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLEfficiency.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import math import numpy as np import numpy.ma as ma diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScan.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScan.py index 87f40ed5fb70d02d9a96e7077516dcac2682919d..e95aefea1f785efc785bfb45da7b53615a321719 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScan.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScan.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np from mantid.kernel import StringListValidator, Direction, FloatArrayProperty, \ FloatArrayOrderedPairsValidator, VisibleWhenProperty, PropertyCriterion, FloatBoundedValidator diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py index 6db1669788dab23335fe9337e6d59f3360884cb5..0b7c9647271198d364a800cd47ce375a47b25901 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * import math diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcess.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcess.py index cc3c087a191766a7333ec1114bd5ebd2081c9576..19dfa7de0ca870de6a5ca9d660bb303d1da339ef 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcess.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcess.py @@ -5,11 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import ( - absolute_import, - division, - print_function -) from mantid.api import ( AlgorithmFactory, DataProcessorAlgorithm, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQ.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQ.py index c39d017a00ee212f3807dd1f6f99aae17b6cb162..44355ca216a2fd60dfc8eb2f1363d7eea61a8192 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQ.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQ.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, MatrixWorkspaceProperty, WorkspaceUnitValidator) from mantid.kernel import (Direction, FloatBoundedValidator, Property, StringListValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCor.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCor.py index b2111a652f2e085e29567579d1da63e497746cac..af704621e6fae5d0c8f9819f53a62d87dfe99292 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCor.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCor.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, FileAction, FileProperty, mtd, WorkspaceGroupProperty) from mantid.kernel import (CompositeValidator, Direction, StringArrayLengthValidator, StringArrayMandatoryValidator, StringArrayProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocess.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocess.py index 578d64a36b019e995044bae796daa9135690daa2..95c99e428120a7cc3f87f60d586e98871811280f 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocess.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocess.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py index 7f6d08dddd379db1df46f040de92819645f11745..642e3880be4299a5d82b1e773ee7e924558b4bcb 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForeground.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import ILL_utilities as utils from mantid.api import (AlgorithmFactory, DataProcessorAlgorithm, MatrixWorkspaceProperty, PropertyMode, WorkspaceUnitValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_common.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_common.py index 8bb711d0ece60e1e39eea07f30e3db9848f4870f..4edaed1f5acca985982720bab10fbd5566bb2ded 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_common.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_common.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import UnitConversion, DeltaEModeType from mantid.simpleapi import * import scipy.constants as constants diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py index 332f171e74b7e5d9de4f2d28d0ee9e5354cfb64b..5ed00ee522eb770df65eba597c389eeb8ffc7367 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (AlgorithmFactory, AnalysisDataService, DataProcessorAlgorithm, WorkspaceGroup) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ResNorm2.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ResNorm2.py index 3ae64957666e756cbac121886046e45da9580029..fa557dbd6625e412723729a6bd3b85eaae22a839 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ResNorm2.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ResNorm2.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.api import (PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, WorkspaceGroup, WorkspaceGroupProperty, ITableWorkspaceProperty, Progress, PropertyMode) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py index 74e2de3e859b0711b8d1ab2c0c60951d8af79e76..31586cc6b2fb44a46d78a43981e4a41d5e0df498 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinder.py @@ -8,8 +8,6 @@ """ Finds the beam centre for SANS""" -from __future__ import (absolute_import, division, print_function) - import numpy as np from mantid import AnalysisDataService diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderCore.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderCore.py index e4939224bf2866b0b6e43e19a608a115e056d843..1d19fa4223ea53b194f7b928bad749858b7a55a8 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderCore.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderCore.py @@ -8,8 +8,6 @@ """ Finds the beam centre.""" -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode, Progress, IEventWorkspace) from mantid.kernel import (Direction, StringListValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderMassMethod.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderMassMethod.py index 6c75018d801990d604eff1a8c1b5699b1006de1f..899c08ad0403142d549d2690d95dd8e0cb039547 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderMassMethod.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSBeamCentreFinderMassMethod.py @@ -8,8 +8,6 @@ """ Finds the beam centre for SANS""" -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode, Progress, IEventWorkspace) from mantid.kernel import (Direction, StringListValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSConvertToWavelengthAndRebin.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSConvertToWavelengthAndRebin.py index 9e39f0c47c63e1ff82d0309dc6c93eecf30c201d..e72921f578207c2eceec4d41b4424050ea0707f7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSConvertToWavelengthAndRebin.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSConvertToWavelengthAndRebin.py @@ -8,8 +8,6 @@ """ SANSConvertToWavelengthAndRebin algorithm converts to wavelength units and performs a rebin.""" -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DistributedDataProcessorAlgorithm, MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode, Progress) from mantid.dataobjects import EventWorkspace diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSCreateAdjustmentWorkspaces.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSCreateAdjustmentWorkspaces.py index f5b3d0d630c6de093d9b495cc6d77461ae01013d..ae938d523713a1f53fa9913f400fbb1869230472 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSCreateAdjustmentWorkspaces.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSCreateAdjustmentWorkspaces.py @@ -10,8 +10,6 @@ , wavelength adjustment and pixel-and-wavelength adjustment workspaces. """ -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DistributedDataProcessorAlgorithm, MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode, WorkspaceUnitValidator) from mantid.kernel import (Direction, StringListValidator, CompositeValidator) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py index 63355d2d456af8c0b9c4adcfba3d3e0cc5d2abc0..cb46677d5f2737e13ea32b3f684491154ebd58c9 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSLoad.py @@ -8,8 +8,6 @@ """ SANSLoad algorithm which handles loading SANS files""" -from __future__ import (absolute_import, division, print_function) - from mantid.api import (ParallelDataProcessorAlgorithm, MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode, Progress, WorkspaceProperty) from mantid.kernel import (Direction, FloatArrayProperty) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCore.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCore.py index 71fccf9bbba5e29c9718cd97d7647579239750e9..963a6a692b991ebbfe4ade61469b2d9a6a354ba7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCore.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCore.py @@ -8,8 +8,6 @@ """ SANSReductionCore algorithm runs the sequence of reduction steps which are necessary to reduce a data set.""" -from __future__ import (absolute_import, division, print_function) - from SANSReductionCoreBase import SANSReductionCoreBase from mantid.api import AlgorithmFactory, Progress diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreBase.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreBase.py index fc4da011268d735052bb852b7a600e90c771ce9d..7d12afe5e1d4472aeea538006c3307061e5d0103 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreBase.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreBase.py @@ -8,8 +8,6 @@ """A base class to share functionality between SANSReductionCore algorithms.""" -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DistributedDataProcessorAlgorithm, MatrixWorkspaceProperty, PropertyMode, IEventWorkspace) from mantid.kernel import (Direction, StringListValidator) from sans.algorithm_detail.CreateSANSAdjustmentWorkspaces import CreateSANSAdjustmentWorkspaces diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreEventSlice.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreEventSlice.py index 2bcf3a126137bf2e706da23f0b9c7551a138385c..f2a29a7ffda4e9e626f96cecaf6591f81eea4902 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreEventSlice.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCoreEventSlice.py @@ -9,8 +9,6 @@ """ SANSReductionCoreEventSlice algorithm runs the sequence of reduction steps which are necessary to reduce a data set, for which data must be event sliced. These steps are: slicing, adjustment, convert to q.""" -from __future__ import (absolute_import, division, print_function) - from SANSReductionCoreBase import SANSReductionCoreBase from mantid.api import (MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCorePreprocess.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCorePreprocess.py index a885277ff7cd75424b7697474bd35fdd6ed39053..9b1a359a364f6615f7d27f3bc80afba9900ea553 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCorePreprocess.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSReductionCorePreprocess.py @@ -9,8 +9,6 @@ """ SANSReductionCorePreprocess algorithm runs the sequence of reduction steps which are necessary to reduce a data set, which can be performed before event slicing.""" -from __future__ import (absolute_import, division, print_function) - from SANSReductionCoreBase import SANSReductionCoreBase from mantid.api import MatrixWorkspaceProperty, AlgorithmFactory, Progress diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSave.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSave.py index 01b6b8383ad4440fdeea54ec67b2652ad3b69840..afc584d96c6081c5543f7babd13c0b2529981714 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSave.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSave.py @@ -8,8 +8,6 @@ """ SANSSave algorithm performs saving of SANS reduction data.""" -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode, FileProperty, FileAction, Progress) from mantid.kernel import (Direction) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction.py index 67b78d9247f79c333c010533605f637dec0a8bb9..32115667a40cd473743831e6f2ecfa09bb31e938 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction.py @@ -8,8 +8,6 @@ """ SANSSingleReduction algorithm performs a single reduction.""" -from __future__ import (absolute_import, division, print_function) - from SANSSingleReductionBase import SANSSingleReductionBase from mantid.api import (MatrixWorkspaceProperty, AlgorithmFactory, PropertyMode) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction2.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction2.py index 2a115e7037cb3962e181e7c0f7639700550caab6..c8c6c726ec10e7abe5e774e8a81faf802f419c71 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction2.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReduction2.py @@ -8,8 +8,6 @@ """ SANSSingleReduction version 2 algorithm performs a single reduction on event sliced data.""" -from __future__ import (absolute_import, division, print_function) - from copy import deepcopy from SANSSingleReductionBase import SANSSingleReductionBase diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReductionBase.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReductionBase.py index ccabfaddb94010222cda9e74d2b44503204d87cc..090b74d875a3bea43c65720e9363d86d6a2da109 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReductionBase.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANS/SANSSingleReductionBase.py @@ -8,8 +8,6 @@ """A base class to share functionality between SANSSingleReduction versions.""" -from __future__ import (absolute_import, division, print_function) - from collections import defaultdict from mantid.api import (DistributedDataProcessorAlgorithm, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAbsoluteScale.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAbsoluteScale.py index c743c02c47dc69dc6a7d3d72889b53ec43f5f785..6900bfa404ca72b4221d22712618bae170cbfc8b 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAbsoluteScale.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAbsoluteScale.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import os from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAzimuthalAverage1D.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAzimuthalAverage1D.py index 855ce3a734ed287efce9218c5a60d94ff8c5c11a..3370b85556888e176b01bfe5ad3f52e64c23899b 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAzimuthalAverage1D.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSAzimuthalAverage1D.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,too-many-locals,too-many-branches -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * import math diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSBeamSpreaderTransmission.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSBeamSpreaderTransmission.py index 5f21b10360452e895bfc70035b80b6ce73225001..da697dea30245e8647fef3f2b4283570254d59c2 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSBeamSpreaderTransmission.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSBeamSpreaderTransmission.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrection.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrection.py index 74bcc04f28c0a030ad7e7e1de8ee0fdb30727316..3babd3e2768a59ed7f1a6142e24d4595e47852fa 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrection.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrection.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,too-many-locals,too-many-branches -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDirectBeamTransmission.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDirectBeamTransmission.py index e5b2a5f9b121cf91bb3dbb21d34c372636809ae4..8e5f354a2cd8b5990bf4e43ec73885e8ce4ab373 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDirectBeamTransmission.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSDirectBeamTransmission.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * import os diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScale.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScale.py index 5379df9e28bfbb0bf7fe9f10c0593b67cbba2bc9..b582ea326add8e9a46b8f458137c592c5a9e97b3 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScale.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScale.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-arguments,too-few-public-methods -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import ParallelDataProcessorAlgorithm, MatrixWorkspaceProperty, PropertyMode, AnalysisDataService from mantid.kernel import Direction, Property, StringListValidator, UnitFactory diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLAutoProcess.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLAutoProcess.py index 5c8313556a7478deebe91a08f35d8ad7e3f5e626..94dcd52dbbede41875402079e48870c7f5bcfe58 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLAutoProcess.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLAutoProcess.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import * from mantid.kernel import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegration.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegration.py index fc8c647dd238f8f188241f62f6b448507e5602ba..d7743fc1f02cc7ca5e6078f063652d2c343e5cfe 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegration.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegration.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import PythonAlgorithm, MatrixWorkspaceProperty, WorkspaceUnitValidator, WorkspaceGroupProperty, \ PropertyMode, MatrixWorkspace, NumericAxis from mantid.kernel import EnabledWhenProperty, FloatArrayProperty, Direction, StringListValidator, \ diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py index 33d6147704d0d815a38cecc8659b951f76e6b066..a79426fe3935c645492132e4069f4009d7637bbd 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import PythonAlgorithm, MatrixWorkspaceProperty, MultipleFileProperty, PropertyMode, Progress, WorkspaceGroup from mantid.kernel import Direction, EnabledWhenProperty, FloatBoundedValidator, LogicOperator, PropertyCriterion, StringListValidator from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSMask.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSMask.py index c4518727a29ea98764a37c56474eb54bc51b4722..45a434f702535029904a960e42c03f16ef4d9ae4 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSMask.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSMask.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,bare-except -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSPatchSensitivity.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSPatchSensitivity.py index d33421d93dab907c93404325a56972470c5af29d..e743400ce2a9d11da33526f469e49c5501bf3bb8 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSPatchSensitivity.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSPatchSensitivity.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,bare-except -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSReduction.py index f220b7cc99b4c57c9108d31ac5906bdc26eaf696..654964f43e0bbfebf8da74aca861a1201cbd4950 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSReduction.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as api from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSStitch.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSStitch.py index cbf1d41da560311f8265926d1aa2908e0b5ff7d0..336cb75fcc3682f3b2d4b7b08cb90bff2a34ea59 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSStitch.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSStitch.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-arguments,too-few-public-methods -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import * from mantid.api import ParallelDataProcessorAlgorithm, MatrixWorkspaceProperty, PropertyMode from mantid.kernel import Direction, Property, StringListValidator, UnitFactory, \ diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py index 59274dec950043eddb302180328584efe6e81133..5991a861ea3fc9785c0d670396eb24ab78a68fb8 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six.moves import range - import mantid from mantid.kernel import Direction, IntArrayProperty, StringArrayProperty, StringListValidator import sys diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py index 6308e7f50b0bf2546ccba9e473bc1047a71532d7..e69393c63de008f11bcfd7553a3e1d49cb8fbd12 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) -from six.moves import range #pylint: disable=redefined-builtin import mantid.simpleapi as api from mantid.api import AnalysisDataService from mantid.api import MatrixWorkspaceProperty, PropertyMode, PythonAlgorithm, AlgorithmFactory, ITableWorkspaceProperty diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py index 2d7ad054ffbffc283798a18b6554bec43b60bd09..9b09faea7279255d9816a9ec6b1c56336b831088 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, Progress) from mantid.kernel import (VisibleWhenProperty, EnabledWhenProperty, Property, PropertyCriterion, StringListValidator, IntBoundedValidator, FloatBoundedValidator, Direction) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStates.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStates.py index 2f39927da802f56905163f84e2b321543d44d6d6..1edc446ec7d568b051535201c4f61031e83c010c 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStates.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStates.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,too-many-locals,too-many-lines, redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six.moves import range - import numpy as np import re import os.path diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py index 309bbb32905c81d24f9efb9f8ac949209079bcfa..32a26f794528c981ce26a8bd24bf1a6c0fbf0a45 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (DataProcessorAlgorithm, mtd, AlgorithmFactory, FileProperty, FileAction, MultipleFileProperty, WorkspaceProperty, diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SwapWidths.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SwapWidths.py index 0a6994d6c286d7e5a3e94994f2edc4e634dfc29f..a20647f2383e028561b9c834ee83da8374d5a497 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SwapWidths.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SwapWidths.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.api import (WorkspaceProperty,DataProcessorAlgorithm, AlgorithmFactory, mtd, Progress) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrection.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrection.py index 2cc4e2d362fc578ee63089dbdcb3656a05401b2a..56176e796e886d4ce69bca09f8079973416e09b6 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrection.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrection.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.api import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py index 77fa091a73b1187d44dfbe57a9cf7a1b11136b70..75cc3740606b48483146e51e9f6e36e968402a1d 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import * from mantid.api import * from mantid.simpleapi import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScattering.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScattering.py index c56274516f63d9dfe40b79edb95f3b900e759309..3f898ea64625991cde2e48e15bf3aa01e5634349 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScattering.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScattering.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import (CalculatePlaczekSelfScattering, ConvertToDistribution, ConvertUnits, CreateWorkspace, DeleteWorkspace, DiffractionFocussing, Divide, ExtractSpectra, FitIncidentSpectrum, LoadCalFile, SetSample) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransformToIqt.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransformToIqt.py index 9b2dfbc6379deae009051248d1ec7d49ffc6393e..94ad6afa49d56da8d6b4a9e8dc4eb70de3880f96 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransformToIqt.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransformToIqt.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import (PythonAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, ITableWorkspaceProperty, PropertyMode, Progress) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransmissionUtils.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransmissionUtils.py index 1da362a7952a988c9858a628ead9af6a3fa5c59b..483ad5a0619ecdf877ddef028ae11943b1f0082a 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransmissionUtils.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TransmissionUtils.py @@ -5,12 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * import os import sys -from six import iteritems def simple_algorithm(algorithm_str, parameters): @@ -24,7 +22,7 @@ def _execute(algorithm_str, parameters, is_name=True): alg = Algorithm.fromString(algorithm_str) alg.initialize() alg.setChild(True) - for key, value in iteritems(parameters): + for key, value in parameters.items(): if value is None: Logger("TransmissionUtils").error("Trying to set %s=None" % key) if alg.existsProperty(key): diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py index bd1d0b0661087099416a3e37d4283def9a0ccaff..3d51e45d14fdae343c96c6da70e13aa85e3bcd65 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * @@ -14,7 +13,6 @@ import numpy import sys import os import json -from six import iteritems class USANSReduction(PythonAlgorithm): @@ -320,7 +318,7 @@ def _execute(algorithm_name, **parameters): alg = AlgorithmManager.create(algorithm_name) alg.initialize() alg.setChild(True) - for key, value in iteritems(parameters): + for key, value in parameters.items(): if value is None: Logger("USANSReduction").error("Trying to set %s=None" % key) if alg.existsProperty(key): diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py index 88051eb83797393ee85559f889232f578d9fc409..2ce441e98286c909718e3143bbe84ec03a7194e9 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py index 9e23a4bec0986a3494c9b4694e8d96426e4ed959..b15030885571a78124ce711ec4332c76ba5d6938 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode, IEventWorkspace) diff --git a/Framework/PythonInterface/plugins/algorithms/dnsdata.py b/Framework/PythonInterface/plugins/algorithms/dnsdata.py index 78b63467e9a6f32538eb6fff13a36026f8af1b11..6e79a62c3fb6814f568df10387bc6bd94a4613bb 100644 --- a/Framework/PythonInterface/plugins/algorithms/dnsdata.py +++ b/Framework/PythonInterface/plugins/algorithms/dnsdata.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-instance-attributes,too-few-public-methods -from __future__ import (absolute_import, division, print_function) import re from dateutil.parser import parse diff --git a/Framework/PythonInterface/plugins/algorithms/roundinghelper.py b/Framework/PythonInterface/plugins/algorithms/roundinghelper.py index c993044234a93b781c1104621d8fdf2ba639a8c1..73c421e677963f3e44d7c515b7beb5e0bea5aa4a 100644 --- a/Framework/PythonInterface/plugins/algorithms/roundinghelper.py +++ b/Framework/PythonInterface/plugins/algorithms/roundinghelper.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import Direction, StringListValidator import numpy diff --git a/Framework/PythonInterface/plugins/functions/BivariateGaussian.py b/Framework/PythonInterface/plugins/functions/BivariateGaussian.py index 1184c1e5a54370423c6246b862034fe2451bf283..bc23e7dd44b3e63c59eebe5f68815bf13efd63e6 100644 --- a/Framework/PythonInterface/plugins/functions/BivariateGaussian.py +++ b/Framework/PythonInterface/plugins/functions/BivariateGaussian.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/ChudleyElliot.py b/Framework/PythonInterface/plugins/functions/ChudleyElliot.py index bba99c455898516613bfe2364431a05d610a19f9..b75d8a8c6d3732e2fb6fe9356a0e119f3d387c4e 100644 --- a/Framework/PythonInterface/plugins/functions/ChudleyElliot.py +++ b/Framework/PythonInterface/plugins/functions/ChudleyElliot.py @@ -9,8 +9,6 @@ @author Spencer Howells, ISIS @date December 05, 2013 ''' -from __future__ import (absolute_import, division, print_function) - import math import numpy as np diff --git a/Framework/PythonInterface/plugins/functions/DSFinterp1DFit.py b/Framework/PythonInterface/plugins/functions/DSFinterp1DFit.py index 7a2fee15b140a246565cf4a7cbfbb64864230c8e..b4fb6f52a4d3ba2f00331f0657061ce02ef91d05 100644 --- a/Framework/PythonInterface/plugins/functions/DSFinterp1DFit.py +++ b/Framework/PythonInterface/plugins/functions/DSFinterp1DFit.py @@ -9,7 +9,6 @@ @author Jose Borreguero, NScD @date October 06, 2013 ''' -from __future__ import (absolute_import, division, print_function) import numpy import scipy.interpolate from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/EISFDiffCylinder.py b/Framework/PythonInterface/plugins/functions/EISFDiffCylinder.py index 65293a4c5f0c03a593ea554e86376540628174de..c058cd15140db88e8aa3fa135604190d723475cb 100644 --- a/Framework/PythonInterface/plugins/functions/EISFDiffCylinder.py +++ b/Framework/PythonInterface/plugins/functions/EISFDiffCylinder.py @@ -9,8 +9,6 @@ @author Jose Borreguero, ORNL @date December 07, 2017 """ -from __future__ import (absolute_import, division, print_function) - import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/EISFDiffSphere.py b/Framework/PythonInterface/plugins/functions/EISFDiffSphere.py index a8ad8207e851569153e7a0650ee07a452416d769..bfe5bed44fbe6a7e7c980a8657f12d4947cc658a 100644 --- a/Framework/PythonInterface/plugins/functions/EISFDiffSphere.py +++ b/Framework/PythonInterface/plugins/functions/EISFDiffSphere.py @@ -9,8 +9,6 @@ @author Jose Borreguero, ORNL @date December 05, 2017 """ -from __future__ import (absolute_import, division, print_function) - import numpy as np try: from scipy.special import spherical_jn diff --git a/Framework/PythonInterface/plugins/functions/EISFDiffSphereAlkyl.py b/Framework/PythonInterface/plugins/functions/EISFDiffSphereAlkyl.py index 5d9c7afe4d9ca3d2b8541677f6f1cd5df80421ed..2ea46cb95368cfaaf093e63d2d52598259eff91a 100644 --- a/Framework/PythonInterface/plugins/functions/EISFDiffSphereAlkyl.py +++ b/Framework/PythonInterface/plugins/functions/EISFDiffSphereAlkyl.py @@ -9,8 +9,6 @@ @author Jose Borreguero, ORNL @date December 06, 2017 """ -from __future__ import (absolute_import, division, print_function) - import numpy as np try: from scipy.special import spherical_jn diff --git a/Framework/PythonInterface/plugins/functions/Examples/Example1DFunction.py b/Framework/PythonInterface/plugins/functions/Examples/Example1DFunction.py index 40f9024e0d6edc077907baa5a18028d77451dad5..f0c0f120944af2f21d650e3cbe9dd13bc8666377 100644 --- a/Framework/PythonInterface/plugins/functions/Examples/Example1DFunction.py +++ b/Framework/PythonInterface/plugins/functions/Examples/Example1DFunction.py @@ -15,7 +15,6 @@ to have meaningful concepts such as this then see ExamplePeakFunction. 1D functions do not have to have a derivative defined, if they do not then they will use a numerical derivative """ -from __future__ import (absolute_import, division, print_function) from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/Examples/ExamplePeakFunction.py b/Framework/PythonInterface/plugins/functions/Examples/ExamplePeakFunction.py index 430587e7e37ce4e203b4199fb08eb72e9b31d5a9..a44eead5d7cdc9aaba912322af603e7d38ae3f74 100644 --- a/Framework/PythonInterface/plugins/functions/Examples/ExamplePeakFunction.py +++ b/Framework/PythonInterface/plugins/functions/Examples/ExamplePeakFunction.py @@ -14,7 +14,6 @@ It uses the so-called IPeakFunction that should be used when there is a sensible calculate the centre, height & fwhm of the function. If it does not make sense, for example a in linear background, where does not give a peak shape, then see the more general Example1DFunction that does not require these concepts. """ -from __future__ import (absolute_import, division, print_function) import math import numpy as np from mantid.api import IPeakFunction, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/FickDiffusion.py b/Framework/PythonInterface/plugins/functions/FickDiffusion.py index bc599951d58342c6d1cc9255a4f77e7025f614c2..11591fbdafd486f2adb27be9536762cc42dc95e9 100644 --- a/Framework/PythonInterface/plugins/functions/FickDiffusion.py +++ b/Framework/PythonInterface/plugins/functions/FickDiffusion.py @@ -10,7 +10,6 @@ @date December 05, 2013 ''' -from __future__ import (absolute_import, division, print_function) from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/Guinier.py b/Framework/PythonInterface/plugins/functions/Guinier.py index 46f8ae86e17ddb89224ae0f61bd989cbb8e223ce..6f0e49bc6fe866fc1072d48ec148510613abaf7f 100644 --- a/Framework/PythonInterface/plugins/functions/Guinier.py +++ b/Framework/PythonInterface/plugins/functions/Guinier.py @@ -9,7 +9,6 @@ @author Mathieu Doucet, ORNL @date Oct 10, 2014 ''' -from __future__ import (absolute_import, division, print_function) import math import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/GuinierPorod.py b/Framework/PythonInterface/plugins/functions/GuinierPorod.py index 4146d630c7e575c7afdc5e34b46a73fb9095179b..25e7a5da67d98f21fc1b726bad0c2cfd6e5fdb2f 100644 --- a/Framework/PythonInterface/plugins/functions/GuinierPorod.py +++ b/Framework/PythonInterface/plugins/functions/GuinierPorod.py @@ -9,7 +9,6 @@ @author Mathieu Doucet, ORNL @date Oct 13, 2014 ''' -from __future__ import (absolute_import, division, print_function) import math import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/HallRoss.py b/Framework/PythonInterface/plugins/functions/HallRoss.py index df80753cdeac871a8f4bfb38bac654e2b67aac02..32ff6f09f62418901fcc35678fcde3d95542e505 100644 --- a/Framework/PythonInterface/plugins/functions/HallRoss.py +++ b/Framework/PythonInterface/plugins/functions/HallRoss.py @@ -9,8 +9,6 @@ @author Spencer Howells, ISIS @date December 05, 2013 ''' -from __future__ import (absolute_import, division, print_function) - import math import numpy as np diff --git a/Framework/PythonInterface/plugins/functions/ICConvoluted.py b/Framework/PythonInterface/plugins/functions/ICConvoluted.py index 97fc3e7263f7962fcaada0dc33d263d807bafc0f..b44e9952f56286c24647147f6a19bc535c7ae8fa 100644 --- a/Framework/PythonInterface/plugins/functions/ICConvoluted.py +++ b/Framework/PythonInterface/plugins/functions/ICConvoluted.py @@ -11,7 +11,6 @@ # a square wave and a Gaussian. # # -from __future__ import (absolute_import, division, print_function) import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/Lorentz.py b/Framework/PythonInterface/plugins/functions/Lorentz.py index 7ec0240cdedecd58f3fce17a5ef08cf9759b24a8..9c0b62f7706b52c6577ccb9ca51e773b36ecdf5a 100644 --- a/Framework/PythonInterface/plugins/functions/Lorentz.py +++ b/Framework/PythonInterface/plugins/functions/Lorentz.py @@ -9,7 +9,6 @@ @author Mathieu Doucet, ORNL @date Oct 13, 2014 ''' -from __future__ import (absolute_import, division, print_function) import math import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/MsdGauss.py b/Framework/PythonInterface/plugins/functions/MsdGauss.py index 41c38ec0d560db0002fe903a4cd1556a1ea02d81..e442427688d9b364a8e41367b1c708b1957abe8c 100644 --- a/Framework/PythonInterface/plugins/functions/MsdGauss.py +++ b/Framework/PythonInterface/plugins/functions/MsdGauss.py @@ -9,8 +9,6 @@ @author Spencer Howells, ISIS @date December 05, 2013 ''' -from __future__ import (absolute_import, division, print_function) - import math import numpy as np diff --git a/Framework/PythonInterface/plugins/functions/MsdPeters.py b/Framework/PythonInterface/plugins/functions/MsdPeters.py index 62ab90e01b11d307487a5cb9883b65c73b4ea1ed..272de8b49740c1c9f22df51e84a80284706d22eb 100644 --- a/Framework/PythonInterface/plugins/functions/MsdPeters.py +++ b/Framework/PythonInterface/plugins/functions/MsdPeters.py @@ -9,8 +9,6 @@ @author Spencer Howells, ISIS @date December 05, 2013 ''' -from __future__ import (absolute_import, division, print_function) - import math import numpy as np diff --git a/Framework/PythonInterface/plugins/functions/MsdYi.py b/Framework/PythonInterface/plugins/functions/MsdYi.py index 137eaea4417026cbe4ec5ed9796a6596e6bc722d..e773b625605eec91cb80a905faebb6f7a50d0135 100644 --- a/Framework/PythonInterface/plugins/functions/MsdYi.py +++ b/Framework/PythonInterface/plugins/functions/MsdYi.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import math import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/Porod.py b/Framework/PythonInterface/plugins/functions/Porod.py index e29a5c975791f7d67fd871dbf4de821c1b4ab388..762aff10511f921501c537ca9d68bc266cef3104 100644 --- a/Framework/PythonInterface/plugins/functions/Porod.py +++ b/Framework/PythonInterface/plugins/functions/Porod.py @@ -9,7 +9,6 @@ @author Mathieu Doucet, ORNL @date Oct 13, 2014 ''' -from __future__ import (absolute_import, division, print_function) import math import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/PrimStretchedExpFT.py b/Framework/PythonInterface/plugins/functions/PrimStretchedExpFT.py index 6b173fda85b551d42072ca678f8e2ce360dcb443..d27c30e2bc5190889af2f63e45ad571e8eaa0f1a 100644 --- a/Framework/PythonInterface/plugins/functions/PrimStretchedExpFT.py +++ b/Framework/PythonInterface/plugins/functions/PrimStretchedExpFT.py @@ -11,7 +11,6 @@ @date June 01, 2017 """ -from __future__ import (absolute_import, division, print_function) import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/StretchedExpFT.py b/Framework/PythonInterface/plugins/functions/StretchedExpFT.py index 3def86307f0d831cbe0e732330a9b01fd95fcc3e..4c2675f9d08cee0c6780d5fef6c092629fb10396 100644 --- a/Framework/PythonInterface/plugins/functions/StretchedExpFT.py +++ b/Framework/PythonInterface/plugins/functions/StretchedExpFT.py @@ -11,7 +11,6 @@ @date October 06, 2013 """ -from __future__ import (absolute_import, division, print_function) import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/plugins/functions/StretchedExpFTHelper.py b/Framework/PythonInterface/plugins/functions/StretchedExpFTHelper.py index 9d9280e2a2f395367ad7bfc6a54447b3c39eb87c..b2d18abb952429df3cc018ff8136d6e3ff7f43e0 100644 --- a/Framework/PythonInterface/plugins/functions/StretchedExpFTHelper.py +++ b/Framework/PythonInterface/plugins/functions/StretchedExpFTHelper.py @@ -13,7 +13,6 @@ This module provides functionality common to classes StretchedExpFT and PrimStretchedExpFT """ -from __future__ import (absolute_import, division, print_function) import copy from scipy.fftpack import fft, fftfreq from scipy.special import gamma diff --git a/Framework/PythonInterface/plugins/functions/TeixeiraWater.py b/Framework/PythonInterface/plugins/functions/TeixeiraWater.py index f047c648243d1a700f74a07d12474846f877c0c8..72f8d7fc042711aa79be085dfa0a29a1490ab7c9 100644 --- a/Framework/PythonInterface/plugins/functions/TeixeiraWater.py +++ b/Framework/PythonInterface/plugins/functions/TeixeiraWater.py @@ -9,8 +9,6 @@ @author Spencer Howells, ISIS @date December 05, 2013 ''' -from __future__ import (absolute_import, division, print_function) - import numpy as np from mantid.api import IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/test/python/mantid/FitFunctionsTest.py b/Framework/PythonInterface/test/python/mantid/FitFunctionsTest.py index 8616c4eb5fd89fac58fce104e6ad673dda5eda68..5946b9240dfde16910e0ca92fcb06c0a46d79d4f 100644 --- a/Framework/PythonInterface/test/python/mantid/FitFunctionsTest.py +++ b/Framework/PythonInterface/test/python/mantid/FitFunctionsTest.py @@ -7,8 +7,6 @@ """ Test of fitfunctions.py and related classes """ -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers import platform diff --git a/Framework/PythonInterface/test/python/mantid/ImportModuleTest.py b/Framework/PythonInterface/test/python/mantid/ImportModuleTest.py index 79b98ee28707d9b555f60dffe82d87d9b3c73ea2..edc6ef04ab75746d644ac59e5d289135a2334be5 100644 --- a/Framework/PythonInterface/test/python/mantid/ImportModuleTest.py +++ b/Framework/PythonInterface/test/python/mantid/ImportModuleTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmFactory + class ImportModuleTest(unittest.TestCase): def test_import_succeeds(self): diff --git a/Framework/PythonInterface/test/python/mantid/PVPythonTest.py b/Framework/PythonInterface/test/python/mantid/PVPythonTest.py index 2549fdcb8826e3b5f4740eab8f4d85e8b3e2ff87..7b8e006086c78d8b116e5b7dbcae343341160065 100644 --- a/Framework/PythonInterface/test/python/mantid/PVPythonTest.py +++ b/Framework/PythonInterface/test/python/mantid/PVPythonTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from paraview.simple import * diff --git a/Framework/PythonInterface/test/python/mantid/SimpleAPIFitTest.py b/Framework/PythonInterface/test/python/mantid/SimpleAPIFitTest.py index e759c2a3f66710d56bbba454fb794373cdff03b3..229b6646acd8006971f0ff2399fa0a4694faeba0 100644 --- a/Framework/PythonInterface/test/python/mantid/SimpleAPIFitTest.py +++ b/Framework/PythonInterface/test/python/mantid/SimpleAPIFitTest.py @@ -7,8 +7,6 @@ """ Specifically tests the Fit function in the simple API """ -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers import platform @@ -20,6 +18,7 @@ from mantid.api import mtd, MatrixWorkspace, ITableWorkspace, IFunction import numpy as np from testhelpers import run_algorithm + class SimpleAPIFitTest(unittest.TestCase): _raw_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/SimpleAPILoadTest.py b/Framework/PythonInterface/test/python/mantid/SimpleAPILoadTest.py index 5c23b5ce43fa6ec149df619848363a1749931a23..9a6b71ad7162a468ec11e74281cebc84f35f9cb5 100644 --- a/Framework/PythonInterface/test/python/mantid/SimpleAPILoadTest.py +++ b/Framework/PythonInterface/test/python/mantid/SimpleAPILoadTest.py @@ -7,12 +7,11 @@ """ Specifically tests the Load function in the simple API """ -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import Load, LoadDialog from mantid.api import mtd, MatrixWorkspace, WorkspaceGroup + class SimpleAPILoadTest(unittest.TestCase): def tearDown(self): diff --git a/Framework/PythonInterface/test/python/mantid/SimpleAPIRenameWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/SimpleAPIRenameWorkspaceTest.py index 992ff4e7fa35e6b612427ba40b7d9ce99eba0adb..56796257609db29707d46b36da8d7120a214e46c 100644 --- a/Framework/PythonInterface/test/python/mantid/SimpleAPIRenameWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/SimpleAPIRenameWorkspaceTest.py @@ -7,14 +7,13 @@ """ Specifically tests the RenameWorkspace algorithm in the simple API """ -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers import platform from mantid.api import mtd from mantid.simpleapi import CreateSampleWorkspace,RenameWorkspace + class SimpleAPIRenameWorkspaceTest(unittest.TestCase): _raw_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py b/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py index e35c8fa0360cbad29f730e3bdaef9c8093a3113e..06328a0c5a03cc8e1f68fe62ecdcff306737acc7 100644 --- a/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py +++ b/Framework/PythonInterface/test/python/mantid/SimpleAPITest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import inspect import unittest @@ -13,7 +11,6 @@ from mantid.api import (AlgorithmFactory, AlgorithmProxy, IAlgorithm, IEventWork PythonAlgorithm, MatrixWorkspace, mtd) import mantid.simpleapi as simpleapi import numpy -import six class SimpleAPITest(unittest.TestCase): @@ -193,10 +190,10 @@ class SimpleAPITest(unittest.TestCase): self.assertEqual(method_parameters[1:], list(simpleapi.rebin.__signature__.parameters)) else: - freefunction_sig = six.get_function_code(simpleapi.rebin).co_varnames + freefunction_sig = inspect.getsource(simpleapi.rebin).co_varnames expected_method_sig = ['self'] expected_method_sig.extend(freefunction_sig) - self.assertEqual(six.get_function_code(MatrixWorkspace.rebin).co_varnames, tuple(expected_method_sig)) + self.assertEqual(inspect.getsource(MatrixWorkspace.rebin).co_varnames, tuple(expected_method_sig)) def test_function_attached_as_workpace_method_does_the_same_as_the_free_function(self): # Use Rebin as a test diff --git a/Framework/PythonInterface/test/python/mantid/_plugins/ProductFunctionTest.py b/Framework/PythonInterface/test/python/mantid/_plugins/ProductFunctionTest.py index 7cf1b0b6cd016bd934512b2dfd87f81ffdc9c06f..04e5f7f1d9f6e8afa34ab93b630925d638f904ea 100644 --- a/Framework/PythonInterface/test/python/mantid/_plugins/ProductFunctionTest.py +++ b/Framework/PythonInterface/test/python/mantid/_plugins/ProductFunctionTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name, too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest # from mantid.kernel import DateAndTime diff --git a/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryObserverTest.py b/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryObserverTest.py index 67b6c5e9f34a0a82178e0726d23fda73e48f14be..62979372eefdaafe1596039b2bcc4bb7bbf9ebdf 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryObserverTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryObserverTest.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest import sys diff --git a/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryTest.py b/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryTest.py index 0af3a2b856edd463156985ecc009399a4a666c1d..5612e88b0390e58fc4ad3b037f0e7425de35d7da 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AlgorithmFactoryTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers diff --git a/Framework/PythonInterface/test/python/mantid/api/AlgorithmHistoryTest.py b/Framework/PythonInterface/test/python/mantid/api/AlgorithmHistoryTest.py index 30c8f8e6960e49932a0eb127c56ac59d2895e9d8..75119671ac1cb9206a659980801cd24934a38b78 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AlgorithmHistoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AlgorithmHistoryTest.py @@ -4,14 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import CreateWorkspace, set_properties from mantid.api import (MatrixWorkspaceProperty, AlgorithmFactory, AlgorithmManager, DataProcessorAlgorithm, PythonAlgorithm) from mantid.kernel import Direction -from six import iteritems + class ChildAlg(PythonAlgorithm): @@ -91,7 +89,7 @@ class AlgorithmHistoryTest(unittest.TestCase): alg.initialize() alg.setChild(child_algorithm) alg.enableHistoryRecordingForChild(record_history) - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): alg.setProperty(key, value) alg.execute() return alg diff --git a/Framework/PythonInterface/test/python/mantid/api/AlgorithmManagerTest.py b/Framework/PythonInterface/test/python/mantid/api/AlgorithmManagerTest.py index 9fa5ca60cbcb86f2e1f49fae6ec40ec803af1ba6..666e691de96e155be73ddb3ebdf55e391717db6b 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AlgorithmManagerTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AlgorithmManagerTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.api import (AlgorithmManager, Algorithm, AlgorithmProxy, @@ -44,10 +42,11 @@ class AlgorithmManagerTest(unittest.TestCase): self.assertTrue(isinstance(alg, Algorithm)) def test_size_reports_number_of_managed_algorithms(self): - old_size = AlgorithmManager.size() - new_alg = AlgorithmManager.create("ConvertUnits") - new_size = AlgorithmManager.size() - self.assertEqual(new_size, old_size + 1) + # no longer deterministically possible to have a correct answer for size + # if test are run multi threaded + # just check we got an integer back + size = AlgorithmManager.size() + self.assertTrue(isinstance(size, int)) def test_getAlgorithm_returns_correct_instance(self): returned_instance = AlgorithmManager.create("ConvertUnits") diff --git a/Framework/PythonInterface/test/python/mantid/api/AlgorithmPropertyTest.py b/Framework/PythonInterface/test/python/mantid/api/AlgorithmPropertyTest.py index 9452ae0ccbd9a0c827a3124380020ead5eb2f9fb..016b7886a91c77ff498ee426cf251894ee6ace20 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AlgorithmPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AlgorithmPropertyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmProperty, FrameworkManagerImpl, IAlgorithm from mantid.kernel import Direction diff --git a/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py b/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py index f0b0ef308011d938c23423698259edcc61fb02c8..8d1a2fe044a06a64680299ae492a451db87928b0 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -import six import unittest import json from mantid.api import AlgorithmID, AlgorithmManager, FrameworkManagerImpl from testhelpers import run_algorithm + class AlgorithmTest(unittest.TestCase): _load = None @@ -67,12 +66,7 @@ class AlgorithmTest(unittest.TestCase): data = [1.5,2.5,3.5] kwargs = {'child':True} unitx = 'Wavelength' - if six.PY2: - # force a property value to be unicode to assert conversion happens correctly - # this is only an issue in python2 - kwargs[unicode('UnitX')] = unicode(unitx) - else: - kwargs['UnitX'] = unitx + kwargs['UnitX'] = unitx alg = run_algorithm('CreateWorkspace',DataX=data,DataY=data,NSpec=1,**kwargs) diff --git a/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceObserverTest.py b/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceObserverTest.py index 90c0e5f4a8f069440fbe5674c471207fb2390bdd..30a151f1892bcafc8b0782b7710f60390861d6ce 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceObserverTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceObserverTest.py @@ -6,13 +6,11 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantid.api import AnalysisDataService as ADS, AnalysisDataServiceObserver from mantid.simpleapi import CreateSampleWorkspace, RenameWorkspace, GroupWorkspaces, UnGroupWorkspace, DeleteWorkspace -from mantid.py3compat import mock +from unittest import mock class FakeADSObserver(AnalysisDataServiceObserver): diff --git a/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceTest.py b/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceTest.py index 3ecb6b16a715705d6ffd983983c19edc20ed9249..0cc5122f2a09a27c44900f7533025d4fb1ed50a0 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AnalysisDataServiceTest.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -import six import unittest from testhelpers import run_algorithm from mantid.api import (AnalysisDataService, AnalysisDataServiceImpl, @@ -179,7 +176,7 @@ class AnalysisDataServiceTest(unittest.TestCase): group = mtd['NewGroup'] self.assertEqual(group.size(), 3) - six.assertCountEqual(self, group.getNames(), ["ws1", "ws2", "ws3"]) + self.assertCountEqual(group.getNames(), ["ws1", "ws2", "ws3"]) def test_removeFromGroup_removes_workspace_from_group(self): from mantid.simpleapi import CreateSampleWorkspace, GroupWorkspaces @@ -193,7 +190,7 @@ class AnalysisDataServiceTest(unittest.TestCase): group = mtd['NewGroup'] self.assertEqual(group.size(), 2) - six.assertCountEqual(self, group.getNames(), ["ws1", "ws2"]) + self.assertCountEqual(group.getNames(), ["ws1", "ws2"]) if __name__ == '__main__': diff --git a/Framework/PythonInterface/test/python/mantid/api/AxisTest.py b/Framework/PythonInterface/test/python/mantid/api/AxisTest.py index 1a69080a3ddcc371acc303c0ae1b3c3371295700..e1da231febfb313bb2202e79de570c106346d255 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AxisTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AxisTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from mantid.api import NumericAxis, SpectraAxis, TextAxis, mtd import numpy as np + class AxisTest(unittest.TestCase): _test_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/api/CatalogManagerTest.py b/Framework/PythonInterface/test/python/mantid/api/CatalogManagerTest.py index a0496c6c1b26fe48fb633e686f78e807dfc0bcd1..aba7fe1721628b937ab5b954b8632d6af50f0af2 100644 --- a/Framework/PythonInterface/test/python/mantid/api/CatalogManagerTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/CatalogManagerTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers diff --git a/Framework/PythonInterface/test/python/mantid/api/CompositeFunctionTest.py b/Framework/PythonInterface/test/python/mantid/api/CompositeFunctionTest.py index 16b78067c6b7d8ad00bddbead4bd6ec2adbf6e16..87a4a93eba16e4f6378aaf63a738cc94c0ecc993 100644 --- a/Framework/PythonInterface/test/python/mantid/api/CompositeFunctionTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/CompositeFunctionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import FrameworkManagerImpl, FunctionFactory, CompositeFunction, IFunction1D diff --git a/Framework/PythonInterface/test/python/mantid/api/DataProcessorAlgorithmTest.py b/Framework/PythonInterface/test/python/mantid/api/DataProcessorAlgorithmTest.py index 31bee3311c5ca7f52bc0758bd95554fe7699522b..e71bc88579fd81c4b376eb95f9740ed82437c416 100644 --- a/Framework/PythonInterface/test/python/mantid/api/DataProcessorAlgorithmTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/DataProcessorAlgorithmTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import assertRaisesNothing from mantid.api import (Algorithm, DataProcessorAlgorithm, AlgorithmFactory, AlgorithmManager, WorkspaceProperty) from mantid.kernel import Direction + class TestDataProcessor(DataProcessorAlgorithm): def PyInit(self): pass @@ -19,6 +18,7 @@ class TestDataProcessor(DataProcessorAlgorithm): pass # end v1 alg + class DataProcessorAlgorithmTest(unittest.TestCase): def test_DataProcessorAlgorithm_instance_inherits_Algorithm(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py b/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py index 3b835a41fd3abb857d44b34c7ec66f81232847d2..ca0919e86c8c156572d4fcec61280d41392cc001 100644 --- a/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/DeprecatedAlgorithmCheckerTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import DeprecatedAlgorithmChecker, FrameworkManagerImpl diff --git a/Framework/PythonInterface/test/python/mantid/api/ExperimentInfoTest.py b/Framework/PythonInterface/test/python/mantid/api/ExperimentInfoTest.py index c97d362966ff2af67dbafce1b4c83753e3a3d55b..f6156e22315892190d49831d684ed2a4d2c19605 100644 --- a/Framework/PythonInterface/test/python/mantid/api/ExperimentInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/ExperimentInfoTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest ############################################################################### # This has to be tested through a workspace as it cannot be created in @@ -16,6 +14,7 @@ from mantid.geometry import Instrument from mantid.api import Sample, Run from math import pi + class ExperimentInfoTest(unittest.TestCase): _expt_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py b/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py index cab2bb7ae26410d3961e3c9c5fb19546b143183f..0eadff0be57820031889a6ba4cf2e00ecf38b5e3 100644 --- a/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/FileFinderTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import unittest diff --git a/Framework/PythonInterface/test/python/mantid/api/FilePropertyTest.py b/Framework/PythonInterface/test/python/mantid/api/FilePropertyTest.py index cc7459dbac368bc023f502f334ff26c1cd928c47..b0fcf620873698112c8cf4aa9013a6003263b4c6 100644 --- a/Framework/PythonInterface/test/python/mantid/api/FilePropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/FilePropertyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmManager, FileProperty, FileAction, FrameworkManagerImpl from mantid.kernel import Direction diff --git a/Framework/PythonInterface/test/python/mantid/api/FrameworkManagerTest.py b/Framework/PythonInterface/test/python/mantid/api/FrameworkManagerTest.py index add99b12ca7bcb783318dd20ca27d2605e1bb18c..31072941983f5083975ec03d5394103eee60f641 100644 --- a/Framework/PythonInterface/test/python/mantid/api/FrameworkManagerTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/FrameworkManagerTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.api import FrameworkManager, FrameworkManagerImpl, IAlgorithm, AlgorithmProxy + class FrameworkManagerTest(unittest.TestCase): def test_clear_functions_do_not_throw(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py b/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py index 12e0f1a50fdbc28520e5dccca302b3bbbacb69cb..d6c7a5da7e7c32c39a632f5143de6e393cc3dd35 100644 --- a/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/FunctionFactoryTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import FrameworkManagerImpl, IFunction1D, FunctionFactory diff --git a/Framework/PythonInterface/test/python/mantid/api/FunctionPropertyTest.py b/Framework/PythonInterface/test/python/mantid/api/FunctionPropertyTest.py index 9d9b20383e9ba0b649715e9bb38904ed9cdfb877..044c9d7e5dc1022a8019673d1c519faff67c32fc 100644 --- a/Framework/PythonInterface/test/python/mantid/api/FunctionPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/FunctionPropertyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import FrameworkManagerImpl, FunctionProperty, PythonAlgorithm, IFunction from testhelpers import assertRaisesNothing import unittest diff --git a/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py index fe8f99db7b03104e375783bf26bd8841e30a6e52..37a340132f1250bc8aad3128d48e08853a42d326 100644 --- a/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm, can_be_instantiated, WorkspaceCreationHelper @@ -13,6 +11,7 @@ from testhelpers import run_algorithm, can_be_instantiated, WorkspaceCreationHel from mantid.api import (IEventWorkspace, IEventList, IWorkspaceProperty, AlgorithmManager) + class IEventWorkspaceTest(unittest.TestCase): _test_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/api/IFunction1DTest.py b/Framework/PythonInterface/test/python/mantid/api/IFunction1DTest.py index 7519e19df1482c25208435f6b6783495c63d4e7c..66424bd6e0fa5c024e39f9f9c2dcc124420ce436 100644 --- a/Framework/PythonInterface/test/python/mantid/api/IFunction1DTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/IFunction1DTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import IFunction1D, IFunction, FunctionFactory import numpy as np diff --git a/Framework/PythonInterface/test/python/mantid/api/IMaskWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/IMaskWorkspaceTest.py index 21d07404733f433ea53995e64bde9e0fa3149b69..6b5b35fda0625ba5aeb0ebfbde4ba62a1c9bec9e 100644 --- a/Framework/PythonInterface/test/python/mantid/api/IMaskWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/IMaskWorkspaceTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AnalysisDataService, IMaskWorkspace from testhelpers import run_algorithm, WorkspaceCreationHelper + class IMaskWorkspaceTest(unittest.TestCase): def test_MaskWorkspace_Is_Retrievable(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/IPeakFunctionTest.py b/Framework/PythonInterface/test/python/mantid/api/IPeakFunctionTest.py index 5e35f5b4cc9bf5c1cccaefd0736116e3f1d97614..f19141d09cce7b55dadaa23c25fb1fcc15b67420 100644 --- a/Framework/PythonInterface/test/python/mantid/api/IPeakFunctionTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/IPeakFunctionTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import * import numpy as np + class MyPeak(IPeakFunction): def init(self): @@ -20,6 +19,7 @@ class MyPeak(IPeakFunction): def functionLocal(self, xvals): return 5*xvals + class RectangularFunction(IPeakFunction): def init(self): self.declareParameter("Height") @@ -55,6 +55,7 @@ class RectangularFunction(IPeakFunction): return values + class IPeakFunctionTest(unittest.TestCase): def test_instance_can_be_created_standalone(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/IPeaksWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/IPeaksWorkspaceTest.py index b70d165782384ce1daacfe1484b28dce6313edff..fe696ac183217719d05277319eff3ef733ef77cc 100644 --- a/Framework/PythonInterface/test/python/mantid/api/IPeaksWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/IPeaksWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm, WorkspaceCreationHelper from mantid.kernel import V3D @@ -141,5 +139,3 @@ class IPeaksWorkspaceTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - - diff --git a/Framework/PythonInterface/test/python/mantid/api/ITableWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/ITableWorkspaceTest.py index 46a88016621e2166061c8174a3f1a3987efce6c9..558c691e4d42a92d610a207d9069b6e23bf1ffcc 100644 --- a/Framework/PythonInterface/test/python/mantid/api/ITableWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/ITableWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from mantid.kernel import std_vector_str @@ -13,6 +11,7 @@ from mantid.api import AnalysisDataService, ITableWorkspace, WorkspaceFactory from mantid.dataobjects import TableWorkspace import numpy + class ITableWorkspaceTest(unittest.TestCase): _test_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/api/JacobianTest.py b/Framework/PythonInterface/test/python/mantid/api/JacobianTest.py index e9b23083f73ab669dd27d9caaa2d72e340880a0c..bcc8bdc8c36179f67ca3b37ab805ea8836d60f42 100644 --- a/Framework/PythonInterface/test/python/mantid/api/JacobianTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/JacobianTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import Jacobian + class JacobianTest(unittest.TestCase): def test_class_has_expected_attrs(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/MDEventWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/MDEventWorkspaceTest.py index 192106176893e2c2f449b73a9b11f398d04f153b..e62584c56aac24e83e14497e422e11930d227c9b 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MDEventWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/MDEventWorkspaceTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import unittest from testhelpers import run_algorithm from mantid import mtd import mantid + class MDEventWorkspaceTest(unittest.TestCase): """ Test the interface to MDEventWorkspaces @@ -35,4 +34,3 @@ class MDEventWorkspaceTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py b/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py index 2347b99b8b7be4800e97fed343d7a1febedbfe17..56c9285e83fb307a81d3e76ea247eed87af63596 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/MDGeometryTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid from mantid.kernel import VMD from mantid.geometry import IMDDimension @@ -15,6 +13,7 @@ import unittest from testhelpers import WorkspaceCreationHelper + class MDGeometryTest(unittest.TestCase): _test_ndims = 4 diff --git a/Framework/PythonInterface/test/python/mantid/api/MDHistoWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/MDHistoWorkspaceTest.py index b15eb400f70322eb855b36000f813f2bf2c2010c..e39be7385fedc8ab1e9217916f428546b85718c9 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MDHistoWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/MDHistoWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import unittest from testhelpers import run_algorithm from mantid import mtd @@ -277,5 +275,3 @@ class MDHistoWorkspaceTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - - diff --git a/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py index 57dfbf4b1c8a743c26c2ab03c6a226dfa779ab0a..dbb44943d45f84a86a9f231eaa85e39430bbdf54 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/MatrixWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import unittest import sys import math @@ -16,7 +14,6 @@ from mantid.geometry import Detector from mantid.kernel import Direction, V3D from mantid.simpleapi import CreateSampleWorkspace, Rebin import numpy as np -from six.moves import range class MatrixWorkspaceTest(unittest.TestCase): diff --git a/Framework/PythonInterface/test/python/mantid/api/MultipleExperimentInfos.py b/Framework/PythonInterface/test/python/mantid/api/MultipleExperimentInfos.py index 585a0a7d2de0eb4b5d4a1d558026409786df9c55..c69b7180bd86481cbb16402744c0be17243091e3 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MultipleExperimentInfos.py +++ b/Framework/PythonInterface/test/python/mantid/api/MultipleExperimentInfos.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import WorkspaceCreationHelper from mantid.api import ExperimentInfo + class MultipleExperimentInfoTest(unittest.TestCase): def test_information_access(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/MultipleFilePropertyTest.py b/Framework/PythonInterface/test/python/mantid/api/MultipleFilePropertyTest.py index dc0408a761c1775d1bd5075004e72f6b7b175900..84e0d8135dd6d7ede2f82c74d61e7f752825e8f8 100644 --- a/Framework/PythonInterface/test/python/mantid/api/MultipleFilePropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/MultipleFilePropertyTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import MultipleFileProperty, mtd from testhelpers import create_algorithm + class MultipleFilePropertyTest(unittest.TestCase): def tearDown(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/ProgressTest.py b/Framework/PythonInterface/test/python/mantid/api/ProgressTest.py index ef8ee10371476038ab4524b77b7929e74a454fd5..95837d03cbd4150a8a926425495a398d5861d8c3 100644 --- a/Framework/PythonInterface/test/python/mantid/api/ProgressTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/ProgressTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import Progress,PythonAlgorithm from mantid.kernel import ProgressBase + class ProgressTest(unittest.TestCase): def test_class_inherits_ProgressBase(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/ProjectionTest.py b/Framework/PythonInterface/test/python/mantid/api/ProjectionTest.py index cef2eb0f3f1b4747e65e6acf226477701549df6b..63c0c8dff746247c0f36563c374f2108ddf00bda 100644 --- a/Framework/PythonInterface/test/python/mantid/api/ProjectionTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/ProjectionTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import Projection from mantid.kernel import V3D from mantid.simpleapi import mtd import numpy as np + class ProjectionTest(unittest.TestCase): def test_constructors(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmChildAlgCallTest.py b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmChildAlgCallTest.py index af4b2eb404f6e95ee62064a65514cea4ac185650..95fa9b8ecbb22b2eb205e36e82a71bee5c45bdb4 100644 --- a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmChildAlgCallTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmChildAlgCallTest.py @@ -7,8 +7,6 @@ """A test for the simple API dedicated to Python algorithms. Checks things like Child Algorithm calls """ -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm diff --git a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmPropertiesTest.py b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmPropertiesTest.py index 8267e70957b64563a29d1ca7796c70976935a9f2..76cee5b4136d3d5a3db74474647f8c7b174bf714 100644 --- a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmPropertiesTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmPropertiesTest.py @@ -7,8 +7,6 @@ """Defines tests for the simple property declarations types within Python algorithms """ -from __future__ import (absolute_import, division, print_function) - import sys import unittest import testhelpers diff --git a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmTraitsTest.py b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmTraitsTest.py index 79a5f4df635ce2f7bef6329d7bdd5e9ae24fabf0..055237ecdf101d2bf64483f1db89ec0be4997d12 100644 --- a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmTraitsTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmTraitsTest.py @@ -7,8 +7,6 @@ """Defines tests for the traits within Python algorithms such as name, version etc. """ -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers @@ -17,6 +15,7 @@ from mantid.api import (PythonAlgorithm, AlgorithmProxy, Algorithm, IAlgorithm, ########################### Test classes ##################################### + class TestPyAlgDefaultAttrs(PythonAlgorithm): def PyInit(self): pass @@ -24,6 +23,7 @@ class TestPyAlgDefaultAttrs(PythonAlgorithm): def PyExec(self): pass + class TestPyAlgOverriddenAttrs(PythonAlgorithm): def version(self): @@ -44,6 +44,7 @@ class TestPyAlgOverriddenAttrs(PythonAlgorithm): def PyExec(self): pass + class TestPyAlgIsRunningReturnsNonBool(PythonAlgorithm): def isRunning(self): @@ -55,6 +56,7 @@ class TestPyAlgIsRunningReturnsNonBool(PythonAlgorithm): def PyExec(self): pass + class CancellableAlg(PythonAlgorithm): is_running = True @@ -73,6 +75,7 @@ class CancellableAlg(PythonAlgorithm): ############################################################################### + class PythonAlgorithmTest(unittest.TestCase): _registered = None diff --git a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmWorkspacePropertyTest.py b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmWorkspacePropertyTest.py index b2b502da7f0e2f138229e27ac1b3281ed9690adc..cab633f7aa6db1753baea575b7e7d90cf63aa284 100644 --- a/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmWorkspacePropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/PythonAlgorithmWorkspacePropertyTest.py @@ -7,12 +7,11 @@ """Defines tests for the WorkspaceProperty types within Python algorithms """ -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import PythonAlgorithm, WorkspaceProperty from mantid.kernel import Direction + class PythonAlgorithmWorkspacePropertyTest(unittest.TestCase): def _do_test(self, classtype): diff --git a/Framework/PythonInterface/test/python/mantid/api/RunPythonScriptTest.py b/Framework/PythonInterface/test/python/mantid/api/RunPythonScriptTest.py index 39dfe76c7c9367fdf860f7858410362ea2ed477d..9b2ef32e9ae1db4a331069bde0fa0d8a53ad36ff 100644 --- a/Framework/PythonInterface/test/python/mantid/api/RunPythonScriptTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/RunPythonScriptTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import os @@ -15,6 +13,7 @@ from mantid.simpleapi import * from testhelpers import WorkspaceCreationHelper + class RunPythonScriptTest(unittest.TestCase): """ Try out RunPythonScript diff --git a/Framework/PythonInterface/test/python/mantid/api/RunTest.py b/Framework/PythonInterface/test/python/mantid/api/RunTest.py index 4361d892741343dd36b3d24df7c782694977e759..1bbe8fedc23479111aca600e8b12f713f1bce65d 100644 --- a/Framework/PythonInterface/test/python/mantid/api/RunTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/RunTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import copy from mantid.geometry import Goniometer @@ -13,6 +11,7 @@ from mantid.kernel import DateAndTime, FloatTimeSeriesProperty from mantid.api import Run import numpy as np + class RunTest(unittest.TestCase): _expt_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/api/SampleTest.py b/Framework/PythonInterface/test/python/mantid/api/SampleTest.py index 8f7bde6ded04ab2e63fa50f8a14856bb213c94a0..845075019e5fab9405f5bdd69b095495f9483a27 100644 --- a/Framework/PythonInterface/test/python/mantid/api/SampleTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/SampleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import CreateSampleWorkspace, CreatePeaksWorkspace, CreateWorkspace, SetSampleMaterial, SetUB from mantid.geometry import CrystalStructure, CSGObject, OrientedLattice diff --git a/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py b/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py index bcaee8d1ab35ec74ff46275f60457a9a5e5723c7..7c3fc864518f4a0f3a7f44d401f4454cd11f73d7 100644 --- a/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/SpectrumInfoTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import WorkspaceCreationHelper from mantid.kernel import V3D from mantid.api import SpectrumDefinition + class SpectrumInfoTest(unittest.TestCase): _ws = None diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceBinaryOpsTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceBinaryOpsTest.py index 210adde80d7c04f906fb605c1cd075ab6799a1b7..b7f101a17266e803229ab59a677fd54b6bf260b5 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceBinaryOpsTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceBinaryOpsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from mantid.simpleapi import CreateSampleWorkspace import unittest diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceFactoryTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceFactoryTest.py index f992cf33bcacc76d112f3e7a8e1ea57a48d15ffa..8e164f9d5e3202c8af10e5436bc49ed3fb24602d 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceFactoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceFactoryTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import (WorkspaceFactory, WorkspaceFactoryImpl, MatrixWorkspace, ITableWorkspace, IPeaksWorkspace) + class WorkspaceFactoryTest(unittest.TestCase): diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceGroupTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceGroupTest.py index 49c0a47581902bfd1c61f3616c1de0aa9347166f..be9255a49e987c65ce04716e36a609dd28901747 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceGroupTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceGroupTest.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -import six import unittest from testhelpers import run_algorithm from mantid.api import mtd, WorkspaceGroup, MatrixWorkspace, AnalysisDataService, WorkspaceFactory @@ -88,7 +85,7 @@ class WorkspaceGroupTest(unittest.TestCase): group = self.create_group_via_GroupWorkspace_algorithm() names = group.getNames() - six.assertCountEqual(self, names, ["First", "Second"]) + self.assertCountEqual(names, ["First", "Second"]) def test_that_a_group_is_invalidated_if_ADS_is_cleared_and_RuntimeError_raised(self): group = self.create_group_via_GroupWorkspace_algorithm() diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceHistoryTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceHistoryTest.py index 9dbfa8f5a29a6e8cdcba912cf95326aa63890b0c..5d5c5f4776ea2852779b7b47a66f943a475ca9b6 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceHistoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceHistoryTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import Load from mantid import mtd, FileFinder diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspacePropertiesTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspacePropertiesTest.py index 10be3193855f5dab68467edc8185b648c79f881a..29f03aa73da8ee9766c67ec1fd3fca13fde70b8c 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspacePropertiesTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspacePropertiesTest.py @@ -7,8 +7,6 @@ """Tests the construction of the various workspace property types """ -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.api import (WorkspaceProperty, WorkspaceGroupProperty, MatrixWorkspaceProperty, @@ -17,6 +15,7 @@ from mantid.api import (WorkspaceProperty, WorkspaceGroupProperty, MatrixWorkspa PropertyMode, LockMode) from mantid.kernel import Direction, Property + class WorkspacePropertiesTest(unittest.TestCase): def _do_test(self, classtype): diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceTest.py index 8e4a42b6d8456e032f959c736825d8119179dc67..6a074e903a94a2d6a1a21d896adf298f09cfbe42 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from mantid.api import Workspace + class WorkspaceTest(unittest.TestCase): def test_that_one_cannot_be_instantiated(self): diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceUnaryOpsTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceUnaryOpsTest.py index 6ffb7d71c1bb09b9767db81a85e91d131f4af789..992863aad49478d5219f35d0159a6304889c6bd0 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceUnaryOpsTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceUnaryOpsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from mantid.simpleapi import CreateMDHistoWorkspace import unittest diff --git a/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py b/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py index e3020a432e25572cc8e2e419cd1e32f1b7f699e3..41838c08107e06ba2ca938af13a917e9c106270f 100644 --- a/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/WorkspaceValidatorsTest.py @@ -7,8 +7,6 @@ """ Test construction of the WorkspaceValidators """ -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import IValidator @@ -18,6 +16,7 @@ from mantid.api import (WorkspaceUnitValidator, HistogramValidator, InstrumentValidator, MDFrameValidator, OrientedLatticeValidator) + class WorkspaceValidatorsTest(unittest.TestCase): def test_WorkspaceUnitValidator_construction(self): diff --git a/Framework/PythonInterface/test/python/mantid/dataobjects/EventListTest.py b/Framework/PythonInterface/test/python/mantid/dataobjects/EventListTest.py index ee3c635b5f7153ed6068357800a11c1cb42174f7..d54bb2774a505bbe256c3d1dd2e975bfca3e3d26 100644 --- a/Framework/PythonInterface/test/python/mantid/dataobjects/EventListTest.py +++ b/Framework/PythonInterface/test/python/mantid/dataobjects/EventListTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name, too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np @@ -16,6 +14,7 @@ from mantid.dataobjects import EventList gps_epoch_plus_42_nanoseconds = np.datetime64('1990-01-01T00:00:00.000000042Z', 'ns') + class EventListTest(unittest.TestCase): def createRandomEventList(self, length): diff --git a/Framework/PythonInterface/test/python/mantid/dataobjects/Workspace2DPickleTest.py b/Framework/PythonInterface/test/python/mantid/dataobjects/Workspace2DPickleTest.py index 5657c4dc616a64764d74342002c0a57274dbb3df..116919be86b4c0b7b5ffc3cfbc6f7d25952983f1 100644 --- a/Framework/PythonInterface/test/python/mantid/dataobjects/Workspace2DPickleTest.py +++ b/Framework/PythonInterface/test/python/mantid/dataobjects/Workspace2DPickleTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name, too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest try: diff --git a/Framework/PythonInterface/test/python/mantid/geometry/BoundingBoxTest.py b/Framework/PythonInterface/test/python/mantid/geometry/BoundingBoxTest.py index de7d689c6c70ddf33547bf8278c98248588c9605..f4c046865ec0429b6301db89fa92887ceb3a684a 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/BoundingBoxTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/BoundingBoxTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import BoundingBox from mantid.kernel import V3D + class BoundingBoxTest(unittest.TestCase): def test_default_construction_is_allowed(self): diff --git a/Framework/PythonInterface/test/python/mantid/geometry/CSGObjectTest.py b/Framework/PythonInterface/test/python/mantid/geometry/CSGObjectTest.py index 9c97836f048e2e5693242140c8e5cd121b0f84a5..20b5d0877512af3dc76b3fb2dcca9b3696ecb3e5 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/CSGObjectTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/CSGObjectTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import BoundingBox, CSGObject diff --git a/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py b/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py index 3cb254ff671f0dd3d4d2f806b3897c58b04e15eb..dc6e29377151f3c87862d9b84699df947ee67a47 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/ComponentInfoTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import argparse import numpy as np @@ -16,6 +14,7 @@ from mantid.geometry import CSGObject from mantid.simpleapi import * from itertools import islice + class ComponentInfoTest(unittest.TestCase): _ws = None diff --git a/Framework/PythonInterface/test/python/mantid/geometry/CrystalStructureTest.py b/Framework/PythonInterface/test/python/mantid/geometry/CrystalStructureTest.py index f66b1a93d8bc34549c5de3ee197bc2b903cc9d42..ab8ed7a3fe368f3e96c0339e360d9643244d03fd 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/CrystalStructureTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/CrystalStructureTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-public-methods,broad-except -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import CrystalStructure diff --git a/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py b/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py index f9377c7ab4b0643dbd62b20f0c5a3b3f609f2fd0..ea97f1618a2ba390b39b8b77ba6d3d51189695d8 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/DetectorInfoTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid from testhelpers import WorkspaceCreationHelper diff --git a/Framework/PythonInterface/test/python/mantid/geometry/GoniometerTest.py b/Framework/PythonInterface/test/python/mantid/geometry/GoniometerTest.py index ae195e5f6244ed1dd55b070e0175b97d0173273b..9ee6ccc306f8e050d3972d06a388f21b85a6a43c 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/GoniometerTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/GoniometerTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import DateAndTime from mantid.geometry import Goniometer @@ -13,6 +11,7 @@ from testhelpers import can_be_instantiated from testhelpers import run_algorithm import numpy as np + class GoniometerTest(unittest.TestCase): def test_Goniometer_can_be_instantiated(self): diff --git a/Framework/PythonInterface/test/python/mantid/geometry/GroupTest.py b/Framework/PythonInterface/test/python/mantid/geometry/GroupTest.py index 106f95593f67d8451cdbe2d2c3cac8c76f185f94..7d267bc5220cbc4ca2e258619110b6c46f3ffb35 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/GroupTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/GroupTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import Group, SpaceGroupFactory, PointGroupFactory, UnitCell diff --git a/Framework/PythonInterface/test/python/mantid/geometry/IComponentTest.py b/Framework/PythonInterface/test/python/mantid/geometry/IComponentTest.py index 020fd91b00e462f6f1df157140d115ef348436a6..32232d4495bb67589437fd544d8eb67efb1dd950 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/IComponentTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/IComponentTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import can_be_instantiated from mantid.geometry import IComponent + class IComponentTest(unittest.TestCase): def test_IComponent_cannot_be_instantiated(self): diff --git a/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py b/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py index 12be77ca21e95515cec931ccc48bf95aa4f45cb3..d5cb00f72052dc82826ada95a89e1c4ed291cc64 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/InstrumentTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import DateAndTime from mantid.geometry import(Detector, Instrument, ObjComponent, ReferenceFrame) diff --git a/Framework/PythonInterface/test/python/mantid/geometry/OrientedLatticeTest.py b/Framework/PythonInterface/test/python/mantid/geometry/OrientedLatticeTest.py index 31a56890a34b0dfdf14e22dbbe9e980f1e6c8c29..1398d38b4baaa45a7c290824b7f662b9a4d14bcf 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/OrientedLatticeTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/OrientedLatticeTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.geometry import OrientedLattice, UnitCell from mantid.kernel import V3D import numpy as np + class OrientedLatticeTest(unittest.TestCase): def test_OrientedLattice_is_subclass_of_UnitCell(self): @@ -87,4 +86,4 @@ class OrientedLatticeTest(unittest.TestCase): self.assertTrue(isinstance( ol.hklFromQ(np.array([1,1,1])), V3D), "Should work with numpy array input" ) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/mantid/geometry/PeakShapeTest.py b/Framework/PythonInterface/test/python/mantid/geometry/PeakShapeTest.py index 8cf57179d18c67e6569ec8603491f3f4f8f09773..8beaea9efd91d15377665172c97d0ff274e02e01 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/PeakShapeTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/PeakShapeTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import CreatePeaksWorkspace, CreateSampleWorkspace from mantid.geometry import PeakShape + class PeakShapeTest(unittest.TestCase): def test_basic_access(self): @@ -22,4 +21,4 @@ class PeakShapeTest(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/mantid/geometry/PointGroupTest.py b/Framework/PythonInterface/test/python/mantid/geometry/PointGroupTest.py index 37c84b401b023e44157f20ab1c531df5bc2246a0..15e3038504e28aa8aedc18f0f37b58a48fbe907b 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/PointGroupTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/PointGroupTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import PointGroup, PointGroupFactory from mantid.kernel import V3D diff --git a/Framework/PythonInterface/test/python/mantid/geometry/RectangularDetectorTest.py b/Framework/PythonInterface/test/python/mantid/geometry/RectangularDetectorTest.py index d6f141e338e10455da4a4690d7c8f41ee0ad78e1..72fd241dfe63bb43294649e05667358fee2f9b17 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/RectangularDetectorTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/RectangularDetectorTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import * from testhelpers import can_be_instantiated, WorkspaceCreationHelper + class RectangularDetectorTest(unittest.TestCase): def test_RectangularDetector_cannot_be_instantiated(self): diff --git a/Framework/PythonInterface/test/python/mantid/geometry/ReferenceFrameTest.py b/Framework/PythonInterface/test/python/mantid/geometry/ReferenceFrameTest.py index 0c7d23661c0cfa898ff48b84ff6e1e3eab1c5f2b..f9c09cd02d0ba3766c1df5f578f0a2aaa8497b2a 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/ReferenceFrameTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/ReferenceFrameTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import ReferenceFrame + class ReferenceFrameTest(object): def test_ReferenceFrame_cannot_be_instantiated(self): self.assertFalse(can_be_instantiated(Instrument)) diff --git a/Framework/PythonInterface/test/python/mantid/geometry/ReflectionGeneratorTest.py b/Framework/PythonInterface/test/python/mantid/geometry/ReflectionGeneratorTest.py index 21521d5192859421ed6e005e8b811ad53e8a2741..19d2f8ae3687c0731810950e1ee9235a1a5bf8f3 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/ReflectionGeneratorTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/ReflectionGeneratorTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import CrystalStructure, ReflectionGenerator, ReflectionConditionFilter from mantid.kernel import V3D diff --git a/Framework/PythonInterface/test/python/mantid/geometry/SpaceGroupTest.py b/Framework/PythonInterface/test/python/mantid/geometry/SpaceGroupTest.py index 54c8eb51bb6af3a59238eaeae51ac1eabcc44451..78379abdc7b37fece96d998336883e56dd616900 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/SpaceGroupTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/SpaceGroupTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import SpaceGroupFactory, UnitCell diff --git a/Framework/PythonInterface/test/python/mantid/geometry/SymmetryElementTest.py b/Framework/PythonInterface/test/python/mantid/geometry/SymmetryElementTest.py index 2454749ea78157e9f5feb7b56c4f9888622fefbf..010c64ab613131877a4a44ae25ac67195452677c 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/SymmetryElementTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/SymmetryElementTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import SymmetryOperation, SymmetryOperationFactory from mantid.geometry import SymmetryElement, SymmetryElementFactory from mantid.kernel import V3D + class SymmetryElementTest(unittest.TestCase): def test_creation_axis(self): diff --git a/Framework/PythonInterface/test/python/mantid/geometry/SymmetryOperationTest.py b/Framework/PythonInterface/test/python/mantid/geometry/SymmetryOperationTest.py index ba0e3d53035768a57ebdb9af9245a32c57cfa866..953363a063238469635c4b7534efaa00c01a0c74 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/SymmetryOperationTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/SymmetryOperationTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.geometry import SymmetryOperation, SymmetryOperationFactory from mantid.kernel import V3D + class SymmetryOperationTest(unittest.TestCase): def test_creation(self): @@ -33,4 +32,4 @@ class SymmetryOperationTest(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/mantid/geometry/UnitCellTest.py b/Framework/PythonInterface/test/python/mantid/geometry/UnitCellTest.py index 98fcf086ba3b4beb1d5d548041af8a6536e8d128..4b30d412833eca13920e6ff4cff77cc084500231 100644 --- a/Framework/PythonInterface/test/python/mantid/geometry/UnitCellTest.py +++ b/Framework/PythonInterface/test/python/mantid/geometry/UnitCellTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.geometry import UnitCell, AngleUnits from mantid.kernel import V3D import numpy as np + class UnitCellTest(unittest.TestCase): def test_invalid_parameters_throw(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ArrayBoundedValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ArrayBoundedValidatorTest.py index 6b850963a4bc1b69ee7d3e8a87d34a7231af18cf..b938bf4d5906624a7a564dba6fefa5d2a2e9acc1 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ArrayBoundedValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ArrayBoundedValidatorTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import FloatArrayBoundedValidator, FloatArrayProperty from mantid.api import PythonAlgorithm + class ArrayBoundedValidatorTest(unittest.TestCase): def test_empty_constructor_gives_no_lower_upper_bound_set(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ArrayLengthValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ArrayLengthValidatorTest.py index e771606e3340e1af27bd15b35419cd865f83c051..16016c114b70b9fa3a46f2a04adb42ac92d7bfe4 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ArrayLengthValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ArrayLengthValidatorTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import FloatArrayLengthValidator, FloatArrayProperty from mantid.api import PythonAlgorithm + class ArrayLengthValidatorTest(unittest.TestCase): def test_empty_constructor_has_no_lengths_set(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ArrayOrderedPairsValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ArrayOrderedPairsValidatorTest.py index 3e12f5ec7bfefb38f3ddc60c72830e090a4f2af1..645ca5f61b5b6a25518e23c548fe73a1ec49771f 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ArrayOrderedPairsValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ArrayOrderedPairsValidatorTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ArrayPropertyTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ArrayPropertyTest.py index 38b53f8bf1305bb97f5c5ae69231d230d0d84ca2..2ec4f20472fec98f2452f25bbe1506238f14fbd9 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ArrayPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ArrayPropertyTest.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + """Test the exposed ArrayProperty """ -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import (FloatArrayProperty, StringArrayProperty, IntArrayProperty, Direction, NullValidator) @@ -15,6 +13,7 @@ from mantid.api import PythonAlgorithm import numpy as np import sys + class ArrayPropertyTest(unittest.TestCase): def test_default_constructor_raises_an_exception(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/BoundedValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/BoundedValidatorTest.py index bcd2bc121f6edbb795c9892b7accf747fbe82b19..0e5c9088ec3a52899d3efa0db0a55aacb4122520 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/BoundedValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/BoundedValidatorTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import FloatBoundedValidator, IntBoundedValidator + class BoundedValidatorTest(unittest.TestCase): def test_construction_does_not_raise_error_when_both_are_floats(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/CompositeValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/CompositeValidatorTest.py index 84f8ad1d83b9ed18fe8c20000e8d501ac7469ecc..9369302d9c61b20b4738231f37fcd006614b70d0 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/CompositeValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/CompositeValidatorTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import CompositeValidator, CompositeRelation, FloatBoundedValidator from mantid.api import PythonAlgorithm + class CompositeValidatorTest(unittest.TestCase): def test_creation_with_add_succeeds_correctly_in_algorithm(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ConfigObserverTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ConfigObserverTest.py index 9b966b335f133901ee44c9e73990551d4f4b7659..8244e002766bdc74d77f7058c31c0eff08d5ca76 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ConfigObserverTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ConfigObserverTest.py @@ -7,7 +7,7 @@ import unittest from mantid.kernel import ConfigService, ConfigObserver -from mantid.py3compat import mock +from unittest import mock class ConfigObserverTest(unittest.TestCase): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ConfigPropertyObserverTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ConfigPropertyObserverTest.py index 809f334830acb3b69787f52d73ea28c8f013e609..105cb78b4f348dc2c31d49fc55bb2143d47a3c21 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ConfigPropertyObserverTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ConfigPropertyObserverTest.py @@ -7,7 +7,7 @@ import unittest from mantid.kernel import ConfigService, ConfigPropertyObserver -from mantid.py3compat import mock +from unittest import mock class ConfigObserverTest(unittest.TestCase): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py index fbeb78d81a9979656937f3dfc2ce47249d629dc5..d298f37f2203b9e7aaa2d975acd96cb3e30890ec 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ConfigServiceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - import inspect import os import testhelpers @@ -13,7 +11,7 @@ import unittest from mantid.kernel import (ConfigService, ConfigServiceImpl, config, std_vector_str, FacilityInfo, InstrumentInfo) -import six + class ConfigServiceTest(unittest.TestCase): @@ -65,7 +63,7 @@ class ConfigServiceTest(unittest.TestCase): self.assertRaises(RuntimeError, config.getInstrument, "MadeUpInstrument") def test_service_acts_like_dictionary(self): - test_prop = "algorithms.retained" + test_prop = "projectRecovery.secondsBetween" self.assertTrue(config.hasProperty(test_prop)) dictcall = config[test_prop] fncall = config.getString(test_prop) @@ -111,7 +109,7 @@ class ConfigServiceTest(unittest.TestCase): def test_appending_paths(self): new_path_list = self._setup_test_areas() try: - config.appendDataSearchDir(six.text_type(new_path_list[0])) + config.appendDataSearchDir(str(new_path_list[0])) updated_paths = config.getDataSearchDirs() finally: self._clean_up_test_areas() diff --git a/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py b/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py index 7affe0c954887ceabdd03f4ac2263ae2c7ee3525..03e70b9b8597fccd19e4c7130e80e34f21b334d0 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import DateAndTime import numpy diff --git a/Framework/PythonInterface/test/python/mantid/kernel/DeltaEModeTest.py b/Framework/PythonInterface/test/python/mantid/kernel/DeltaEModeTest.py index d0216dff6d6eec7496ddd86baea5cc147782244f..b87521d9d39e9715bb56b053f8eb726d494cae13 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/DeltaEModeTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/DeltaEModeTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import DeltaEMode, DeltaEModeType + class DeltaEModeTest(unittest.TestCase): def test_availableTypes_contains_three_modes(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/EnabledWhenPropertyTest.py b/Framework/PythonInterface/test/python/mantid/kernel/EnabledWhenPropertyTest.py index 2b64b8987f5783855f504d866d29124c55e1289a..e267c4b312ff52ae527cc4437b04126f20a7730f 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/EnabledWhenPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/EnabledWhenPropertyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import EnabledWhenProperty, PropertyCriterion, LogicOperator diff --git a/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py b/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py index 61e4f5fec6d92fd52b078ba73c81b87121593a2d..94407c955978e34b6a09ad469f9f4cc252c8fd5f 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/FacilityInfoTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import FacilityInfo, InstrumentInfo, ConfigService import pytz + class FacilityInfoTest(unittest.TestCase): def test_construction_raies_an_error(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/FilteredTimeSeriesPropertyTest.py b/Framework/PythonInterface/test/python/mantid/kernel/FilteredTimeSeriesPropertyTest.py index dd1b037e587b9850e233bcd8c6712fc63caedcd6..aeb5508666bd65729b708d0c71cd37399e171495 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/FilteredTimeSeriesPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/FilteredTimeSeriesPropertyTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import BoolTimeSeriesProperty, FloatTimeSeriesProperty, FloatFilteredTimeSeriesProperty + class FilteredTimeSeriesPropertyTest(unittest.TestCase): _source = None diff --git a/Framework/PythonInterface/test/python/mantid/kernel/IPropertySettingsTest.py b/Framework/PythonInterface/test/python/mantid/kernel/IPropertySettingsTest.py index be7226f80e60dc1f99f7581653c85eaabd4376a3..d77d507d229bd343de876c212d2d36042aa19f3e 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/IPropertySettingsTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/IPropertySettingsTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import IPropertySettings + class IPropertySettingsTest(unittest.TestCase): def test_construction_raises_an_exception(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/InstrumentInfoTest.py b/Framework/PythonInterface/test/python/mantid/kernel/InstrumentInfoTest.py index 973f0146c1d1b0ec9e81f807ade988e2bebe53c8..aac1df11cb7274c2a8c17d96edc2048c58d41057 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/InstrumentInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/InstrumentInfoTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import InstrumentInfo, ConfigService @@ -44,4 +42,3 @@ class InstrumentInfoTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ListValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ListValidatorTest.py index 2ee79e9f85c5114b377bf587266313d180002890..dca07e07a7fa20dd02ae4944e356f86a6f5d6117 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ListValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ListValidatorTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import StringListValidator, Direction from mantid.api import PythonAlgorithm + class ListValidatorTest(unittest.TestCase): def test_empty_ListValidator_allows_nothing(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/LiveListenerInfoTest.py b/Framework/PythonInterface/test/python/mantid/kernel/LiveListenerInfoTest.py index 8a3c3686c62e03a11eed328589aa843f8a79606e..cd17f67543a608cd91b3764d33f37b31130441bb 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/LiveListenerInfoTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/LiveListenerInfoTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import LiveListenerInfo, ConfigService @@ -29,4 +27,3 @@ class LiveListenerInfoTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/Framework/PythonInterface/test/python/mantid/kernel/LogFilterTest.py b/Framework/PythonInterface/test/python/mantid/kernel/LogFilterTest.py index f94c213dc9a5a13a77a059477b8a4eeeb09d8193..3244e5bc631a9e829996c85ac2a05b6d3e2f6f2c 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/LogFilterTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/LogFilterTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import LogFilter, FloatTimeSeriesProperty, BoolTimeSeriesProperty diff --git a/Framework/PythonInterface/test/python/mantid/kernel/LoggerTest.py b/Framework/PythonInterface/test/python/mantid/kernel/LoggerTest.py index 20fc806ed96d8c0fe7bc3e5d62ea21aa860cf529..a18627236d17ea82f4c330a3b32dd9d365134b25 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/LoggerTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/LoggerTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantid.kernel import Logger diff --git a/Framework/PythonInterface/test/python/mantid/kernel/MandatoryValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/MandatoryValidatorTest.py index 05bfebbd433e8f81ac3ec2efbfcd004e36cacd4d..6e25b79daf530c02b5ef86d85569387a90237596 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/MandatoryValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/MandatoryValidatorTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import FloatArrayProperty, StringMandatoryValidator, FloatArrayMandatoryValidator from mantid.api import PythonAlgorithm + class MandatoryValidatorTest(unittest.TestCase): def test_constructor_does_not_raise_error(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/MaterialBuilderTest.py b/Framework/PythonInterface/test/python/mantid/kernel/MaterialBuilderTest.py index 9183dc6933297215ccde7c3dc7235abf08f10a31..b22b66147838a4fba8d647ce374f5c957e77ea3f 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/MaterialBuilderTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/MaterialBuilderTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import MaterialBuilder, NumberDensityUnit diff --git a/Framework/PythonInterface/test/python/mantid/kernel/MemoryStatsTest.py b/Framework/PythonInterface/test/python/mantid/kernel/MemoryStatsTest.py index 573f2115729145ae07e47101b3c9bf46638e7096..4e8063d6fefde826c5a08aaeb8e0213e37453250 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/MemoryStatsTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/MemoryStatsTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import MemoryStats import sys + class MemoryStatsTest(unittest.TestCase): def test_values_are_all_greater_than_zero(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/NullValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/NullValidatorTest.py index c8c45bf9f54855ed60bd7d74f2f6a384650c09b9..ffcf7430416a38952ea40485e0156d460717df7d 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/NullValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/NullValidatorTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import NullValidator + class NullValidatorTest(unittest.TestCase): def test_NullValidator_can_be_default_constructed(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/OptionalBoolTest.py b/Framework/PythonInterface/test/python/mantid/kernel/OptionalBoolTest.py index 629c0fa81de4806f03e3f4d2a8fa0afffd5ebded..da4483b9a3bfb15f0d36d4cb5964b1e9fb895a4b 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/OptionalBoolTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/OptionalBoolTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import Direction, OptionalBool, OptionalBoolValue, OptionalBoolPropertyWithValue + class OptionalBoolTest(unittest.TestCase): @@ -31,4 +30,3 @@ class OptionalBoolTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/Framework/PythonInterface/test/python/mantid/kernel/ProgressBaseTest.py b/Framework/PythonInterface/test/python/mantid/kernel/ProgressBaseTest.py index 28f345745a7699c912597fe320971e4a25ec99c5..e6cf41d6e146f576926b89517790a3bf72165e0a 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/ProgressBaseTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/ProgressBaseTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import ProgressBase + class ProgressBaseTest(unittest.TestCase): def test_class_has_expected_attributes(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PropertyHistoryTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PropertyHistoryTest.py index 3b838d84f29444475b985e3c2e600cc322155efb..0a4322f584f774e4828d40712e734d06ab62f8f8 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PropertyHistoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PropertyHistoryTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import PropertyHistory diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerDataServiceTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerDataServiceTest.py index 52867a8457967b92ee5124ed4fb1c1bb430b8d83..e9d6118870734b425464c42e9361804b91e01262 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerDataServiceTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerDataServiceTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantid.kernel import PropertyManager, PropertyManagerDataService + class PropertyManagerDataServiceTest(unittest.TestCase): def test_add_existing_mgr_object(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerPropertyTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerPropertyTest.py index 60f2c35bc4639bfd43ac69c9769cf9030f09e06b..99404299d89c9af98e444ae0e6821baca3497200 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerPropertyTest.py @@ -6,13 +6,12 @@ # SPDX - License - Identifier: GPL - 3.0 + """Test the exposed PropertyManagerProperty """ -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import PropertyManagerProperty, Direction, PropertyManager from mantid.api import Algorithm import numpy as np + class FakeAlgorithm(Algorithm): def PyInit(self): self.declareProperty(PropertyManagerProperty("Args")) @@ -20,6 +19,7 @@ class FakeAlgorithm(Algorithm): def PyExec(self): pass + class PropertyManagerPropertyTest(unittest.TestCase): def test_default_constructor_raises_an_exception(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerTest.py index ebd111a872161523b61668f45be00652dc1f6908..49a0f11ee75344928642362f9487c6570c315076 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PropertyManagerTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import PropertyManager, IPropertyManager + class PropertyManagerTest(unittest.TestCase): def test_propertymanager_population(self): manager = PropertyManager() diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py index d4ee387013b8cf843c9e048436220cf509af7e03..07c0135aaaa435d87a1222884dc7563645ef8519 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PropertyWithValueTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmManager, MatrixWorkspace from mantid.kernel import Property, StringPropertyWithValue diff --git a/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py b/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py index 4ee81cc12af48fd53b3186168035b31b8230e13d..ae9f82ac3721323c513dae4c8531ad2ecc46891d 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/PythonPluginsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import os import shutil @@ -28,6 +26,7 @@ class TestPyAlg(PythonAlgorithm): AlgorithmFactory.subscribe(TestPyAlg) """ + class PythonPluginsTest(unittest.TestCase): def setUp(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/QuatTest.py b/Framework/PythonInterface/test/python/mantid/kernel/QuatTest.py index 917a9e4997c6caca113d6cf6f6a74a8ebb9fa026..de4f77a37b02bdf753ad08c6a7bd6f0f0f11d5a6 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/QuatTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/QuatTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import math from mantid.kernel import Quat, V3D + class QuatTest(unittest.TestCase): def test_empty_constructor(self): @@ -74,4 +73,4 @@ class QuatTest(unittest.TestCase): self.assertEqual(v, V3D(a, a, 0)) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/mantid/kernel/RebinParamsValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/RebinParamsValidatorTest.py index 6100b3d83f8662ba456a3f681ff7e56ddb644423..7707ac5e587609f893cae348f56b3665df532a40 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/RebinParamsValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/RebinParamsValidatorTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers diff --git a/Framework/PythonInterface/test/python/mantid/kernel/StatisticsTest.py b/Framework/PythonInterface/test/python/mantid/kernel/StatisticsTest.py index 33bfd035d73a7dbc60fec2349aeb5751a0e1eb3d..94365725dfe2a836968977ab96717bfea8e0de94 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/StatisticsTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/StatisticsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import Stats import math @@ -13,6 +11,7 @@ import numpy DELTA_PLACES = 10 + class StatisticsTest(unittest.TestCase): def test_getStatistics_with_floats(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/StringContainsValidatorTest.py b/Framework/PythonInterface/test/python/mantid/kernel/StringContainsValidatorTest.py index 19467543e8c9579ebeab30b6f5119d8e990c3bcd..279c9eb4f37b019b8f4a796719e79869721ba180 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/StringContainsValidatorTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/StringContainsValidatorTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import testhelpers from mantid.kernel import StringContainsValidator from mantid.api import PythonAlgorithm + class StringContainsValidatorTest(unittest.TestCase): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/TimeSeriesPropertyTest.py b/Framework/PythonInterface/test/python/mantid/kernel/TimeSeriesPropertyTest.py index 8050d3ca3c810a9e0017d4b25bd4f082a3a27e1f..24012d36d8d1aa71992c86c3721a98770252e9a5 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/TimeSeriesPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/TimeSeriesPropertyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np @@ -13,6 +11,7 @@ from mantid.kernel import (DateAndTime, BoolTimeSeriesProperty, FloatTimeSeriesP StringTimeSeriesProperty) from testhelpers import run_algorithm + class TimeSeriesPropertyTest(unittest.TestCase): _test_ws = None diff --git a/Framework/PythonInterface/test/python/mantid/kernel/UnitConversionTest.py b/Framework/PythonInterface/test/python/mantid/kernel/UnitConversionTest.py index c17e14382c27e9cca08bd94cff33cbc0083a2a3f..4b8ebf717e17d93ffc7e8b02b577491f31b43ffe 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/UnitConversionTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/UnitConversionTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import UnitConversion, DeltaEModeType import math + class UnitConversionTest(unittest.TestCase): def test_run_accepts_string_units(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py b/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py index 155d5eb0cc84148ce0d547efb910a085496d815e..6480972de6f69ad5d6378a0659a28998c42af6c5 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/UnitFactoryTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import UnitFactory, UnitFactoryImpl, Unit + class UnitFactoryTest(unittest.TestCase): def test_alias_is_of_type_UnitFactoryImpl(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/UnitLabelTest.py b/Framework/PythonInterface/test/python/mantid/kernel/UnitLabelTest.py index 620f1318740ef0e630b1fec99a9c7dac16d46f0f..4f8e3e39d1cd192b9eba5bebf99257ad7c1fd522 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/UnitLabelTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/UnitLabelTest.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import UnitFactory, UnitLabel -import six import sys + class UnitLabelTest(unittest.TestCase): def test_UnitLabel_can_be_built_from_simple_string(self): @@ -26,19 +24,19 @@ class UnitLabelTest(unittest.TestCase): def test_utf8_is_converted_to_unicode_object(self): tof = UnitFactory.Instance().create("TOF") unit_lbl = tof.symbol() - self.assertTrue(isinstance(unit_lbl.utf8(), six.text_type)) + self.assertTrue(isinstance(unit_lbl.utf8(), str)) self.assertEqual(u"\u03bcs", unit_lbl.utf8()) self.assertEqual("\mu s", unit_lbl.latex()) def test_str_function_produces_ascii_string_from_label(self): label = UnitLabel("MyLabel", u"\u03bcs","\mu s") - self.assertTrue(isinstance(str(label), six.string_types)) + self.assertTrue(isinstance(str(label), str)) self.assertEqual("MyLabel", str(label)) def test_unicode_function_produces_unicode_string_from_label_py2(self): if sys.version_info[0] < 3: label = UnitLabel("MyLabel", u"\u03bcs","\mu s") - self.assertTrue(isinstance(unicode(label), six.text_type)) + self.assertTrue(isinstance(unicode(label), str)) self.assertEqual(u"\u03bcs", unicode(label)) else: pass diff --git a/Framework/PythonInterface/test/python/mantid/kernel/UnitsTest.py b/Framework/PythonInterface/test/python/mantid/kernel/UnitsTest.py index 763649525f09efa8bc2dc6abca31763d5cff4385..644688af6a359695f874a4f28bfeb2bd5ec03f60 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/UnitsTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/UnitsTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import UnitFactory, Unit, Label, UnitLabel import types + class UnitsTest(unittest.TestCase): def test_Label_is_returned_from_Factory(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py b/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py index 20d142b19544526173aad163a5b93dba56da47ef..667fc2d32d89ef1fadd11c1d44afd2a7b0b4b979 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantid.kernel import (UsageService, UsageServiceImpl, FeatureType) diff --git a/Framework/PythonInterface/test/python/mantid/kernel/V3DTest.py b/Framework/PythonInterface/test/python/mantid/kernel/V3DTest.py index 7d244e58a71dead0bfe58c1627bbe39ceefe5150..8d832124986cb93c862e973779796aee63a362f3 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/V3DTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/V3DTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import math import numpy as np diff --git a/Framework/PythonInterface/test/python/mantid/kernel/VMDTest.py b/Framework/PythonInterface/test/python/mantid/kernel/VMDTest.py index 08a119434520c3d536945b958770ec29b3c1e2ff..6e349ee3458cf2b85ad060fc645d8d98d6eafe07 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/VMDTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/VMDTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - from mantid.kernel import VMD import math import unittest + class VMDTest(unittest.TestCase): def test_default_construction_gives_object_with_single_dimension(self): diff --git a/Framework/PythonInterface/test/python/mantid/kernel/VisibleWhenPropertyTest.py b/Framework/PythonInterface/test/python/mantid/kernel/VisibleWhenPropertyTest.py index 6ffd0a876be1c0a68fc6d2f10d910e40f08460a0..7b5905815589c757caff50b49c626b00300601d5 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/VisibleWhenPropertyTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/VisibleWhenPropertyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import VisibleWhenProperty, PropertyCriterion, LogicOperator diff --git a/Framework/PythonInterface/test/python/mantid/plots/ScalesTest.py b/Framework/PythonInterface/test/python/mantid/plots/ScalesTest.py index 7e283244c046731b8eaed16fb3680974904b0748..417ed116c12bfd541c7dc90ddbb5bb7fbfaafb87 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/ScalesTest.py +++ b/Framework/PythonInterface/test/python/mantid/plots/ScalesTest.py @@ -11,8 +11,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from matplotlib.scale import scale_factory @@ -20,6 +18,7 @@ from mantid.plots.scales import PowerScale, SquareScale import numpy as np import testhelpers + class ScalesTest(unittest.TestCase): def test_power_scale_registered_in_factory(self): diff --git a/Framework/PythonInterface/test/python/mantid/plots/UtilityTest.py b/Framework/PythonInterface/test/python/mantid/plots/UtilityTest.py index 83d65de0799c3521db24e6b6c380f953609a253e..21b6a88fd6b2bab2b0f555ece213f70a0f902aaf 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/UtilityTest.py +++ b/Framework/PythonInterface/test/python/mantid/plots/UtilityTest.py @@ -11,12 +11,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division - import unittest from mantid.plots.utility import legend_set_draggable -from mantid.py3compat.mock import create_autospec +from unittest.mock import create_autospec from matplotlib.legend import Legend diff --git a/Framework/PythonInterface/test/python/mantid/plots/__init__.py b/Framework/PythonInterface/test/python/mantid/plots/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/__init__.py +++ b/Framework/PythonInterface/test/python/mantid/plots/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/Framework/PythonInterface/test/python/mantid/plots/axesfunctions3DTest.py b/Framework/PythonInterface/test/python/mantid/plots/axesfunctions3DTest.py index 2701d1a1f81e5b6161bc7c3ff4d91037bf882156..01f4a653f2f5cf15a5023e7feb2ff3f31216f66b 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/axesfunctions3DTest.py +++ b/Framework/PythonInterface/test/python/mantid/plots/axesfunctions3DTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import matplotlib matplotlib.use('AGG') diff --git a/Framework/PythonInterface/test/python/mantid/plots/axesfunctionsTest.py b/Framework/PythonInterface/test/python/mantid/plots/axesfunctionsTest.py index c5be1f8b4384142d4d9345dc0e627f9d38b54574..686fcd37ba3d7d3b5779187de55d26a98b8249d7 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/axesfunctionsTest.py +++ b/Framework/PythonInterface/test/python/mantid/plots/axesfunctionsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import matplotlib import unittest diff --git a/Framework/PythonInterface/test/python/mantid/plots/compatabilityTest.py b/Framework/PythonInterface/test/python/mantid/plots/compatabilityTest.py index 6c0affbfce8355e28fa1d491d78047051bd72595..95e932e02830075c510491e73110900fdb852435 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/compatabilityTest.py +++ b/Framework/PythonInterface/test/python/mantid/plots/compatabilityTest.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - # std imports import unittest @@ -19,10 +17,11 @@ matplotlib.use('AGG') # noqa # local imports -from mantid.py3compat.mock import patch +from unittest.mock import patch from mantid.plots._compatability import plotSpectrum, plotBin from mantid.plots.utility import MantidAxType + class compatabilityTest(unittest.TestCase): @patch('mantid.plots._compatability.plot') diff --git a/Framework/PythonInterface/test/python/mantid/plots/datafunctionsTest.py b/Framework/PythonInterface/test/python/mantid/plots/datafunctionsTest.py index 0a1bd9c1fb68505333c4388b08286db256241f60..45a5e6638d69c54f0c46c3da271594c50300d46a 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/datafunctionsTest.py +++ b/Framework/PythonInterface/test/python/mantid/plots/datafunctionsTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # -from __future__ import (absolute_import, division, print_function) - import datetime import unittest @@ -17,7 +15,7 @@ import numpy as np import mantid.api import mantid.plots.datafunctions as funcs -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantid.kernel import config from mantid.plots.utility import MantidAxType from mantid.simpleapi import (AddSampleLog, AddTimeSeriesLog, ConjoinWorkspaces, diff --git a/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_imshow.py b/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_imshow.py index c32a344fb4ce360a3a7b9d039d7c10c982f7f321..d087c00db418e058618c69e04c8bc19c3c4c5404 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_imshow.py +++ b/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_imshow.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, division import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_modest_image.py b/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_modest_image.py index e3c98982cf0c3eca19a37dcbe1419a91a7526f1d..a8b8b6c7b3a2e8d1831a1dd89337ad3b6c18a7d9 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_modest_image.py +++ b/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_modest_image.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, division import itertools import unittest diff --git a/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_speed.py b/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_speed.py index 927381b902ab662f4d57af84767815a817a6df71..363afcedad1e4b9700c25d63bef22ed157d1337f 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_speed.py +++ b/Framework/PythonInterface/test/python/mantid/plots/modest_image/test_speed.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, division from time import time diff --git a/Framework/PythonInterface/test/python/mantid/plots/plotfunctionsTest.py b/Framework/PythonInterface/test/python/mantid/plots/plotfunctionsTest.py index 569619dd069620936e3727d5cb85939e9e024bcb..e227c0cc7b06472bc122be53a2168c700c00097f 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/plotfunctionsTest.py +++ b/Framework/PythonInterface/test/python/mantid/plots/plotfunctionsTest.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - # std imports import unittest diff --git a/Framework/PythonInterface/test/python/mantid/plots/plots__init__Test.py b/Framework/PythonInterface/test/python/mantid/plots/plots__init__Test.py index 781ba2262e2c42f1ff9e52d726b1bfc7ec751dd7..465d62df5185a47c24a4ea95a131dc121bcc70d1 100644 --- a/Framework/PythonInterface/test/python/mantid/plots/plots__init__Test.py +++ b/Framework/PythonInterface/test/python/mantid/plots/plots__init__Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import matplotlib matplotlib.use('AGG') # noqa @@ -20,7 +18,7 @@ from mantid.plots import datafunctions from mantid.plots.legend import convert_color_to_hex from mantid.plots.utility import MantidAxType from mantid.plots.axesfunctions import get_colorplot_extents -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantid.simpleapi import (CreateWorkspace, CreateSampleWorkspace, DeleteWorkspace, RemoveSpectra, AnalysisDataService as ADS) from mantidqt.plotting.markers import SingleMarker @@ -76,14 +74,15 @@ class Plots__init__Test(unittest.TestCase): def test_remove_workspace_artist_for_known_workspace_removes_plot(self): self.ax.plot(self.ws2d_histo, specNum=2, linewidth=6) - is_empty = self.ax.remove_workspace_artists(self.ws2d_histo) - self.assertEqual(True, is_empty) + workspace_removed = self.ax.remove_workspace_artists(self.ws2d_histo) + self.assertEqual(True, workspace_removed) self.assertEqual(0, len(self.ax.lines)) def test_remove_workspace_artist_for_unknown_workspace_does_nothing(self): self.ax.plot(self.ws2d_histo, specNum=2, linewidth=6) unknown_ws = CreateSampleWorkspace() - self.ax.remove_workspace_artists(unknown_ws) + workspace_removed = self.ax.remove_workspace_artists(unknown_ws) + self.assertEqual(False, workspace_removed) self.assertEqual(1, len(self.ax.lines)) def test_remove_workspace_artist_for_removes_only_specified_workspace(self): @@ -92,7 +91,8 @@ class Plots__init__Test(unittest.TestCase): line_second_ws = self.ax.plot(second_ws, specNum=5)[0] self.assertEqual(2, len(self.ax.lines)) - self.ax.remove_workspace_artists(self.ws2d_histo) + workspace_removed = self.ax.remove_workspace_artists(self.ws2d_histo) + self.assertEqual(True, workspace_removed) self.assertEqual(1, len(self.ax.lines)) self.assertTrue(line_ws2d_histo not in self.ax.lines) self.assertTrue(line_second_ws in self.ax.lines) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/AbinsAdvancedParametersTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/AbinsAdvancedParametersTest.py index c353487052fa2333a83f8cb122a1b63b11babcf5..b20621e7ac6b3ff7c20f6b3be789ccbf6573f168 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/AbinsAdvancedParametersTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/AbinsAdvancedParametersTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import Abins, DeleteWorkspace, mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/AbinsBasicTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/AbinsBasicTest.py index b948729aff214cd1eedb451f99b76786e9fbf9df..ccae62072b529b765a244b941f1afa83117ea220 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/AbinsBasicTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/AbinsBasicTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid import logger # noinspection PyUnresolvedReferences @@ -13,6 +12,7 @@ from AbinsModules import AbinsConstants, AbinsTestHelpers import numpy as np from numpy.testing import assert_array_almost_equal + class AbinsBasicTest(unittest.TestCase): _si2 = "Si2-sc_Abins" diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/AlignComponentsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/AlignComponentsTest.py index e8a8ad6cd3886254d8d092050718a5ef8f6855f4..ec7e8d91237f599d773d4cfaa86857e4f737f31c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/AlignComponentsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/AlignComponentsTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import AlignComponents, CreateSampleWorkspace, MoveInstrumentComponent, CreateEmptyTableWorkspace, mtd, RotateInstrumentComponent from mantid.api import AlgorithmFactory + class AlignComponentsTest(unittest.TestCase): def testAlignComponentsPositionXY(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsSingleAxisTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsSingleAxisTest.py index a64f1c5ac83e466c4cda1b0b4bfb662f7215c5a1..466e2c22ac7e4be78d52e31177c3f321973ec696 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsSingleAxisTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsSingleAxisTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid from mantid.simpleapi import AngularAutoCorrelationsSingleAxis + class AngularAutoCorrelationsSingleAxisTest(unittest.TestCase): def test_simple(self): @@ -28,4 +27,4 @@ class AngularAutoCorrelationsSingleAxisTest(unittest.TestCase): self.assertAlmostEqual(output_ws.blocksize(), 501) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsTwoAxesTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsTwoAxesTest.py index c6e3af1188fc0a4ea412d781ba64bc109d5291f7..72703e5025554db4af8fd1df41521049c0e921a2 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsTwoAxesTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/AngularAutoCorrelationsTwoAxesTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid from mantid.simpleapi import AngularAutoCorrelationsTwoAxes + class AngularAutoCorrelationsTwoAxesTest(unittest.TestCase): def test_simple(self): @@ -28,4 +27,4 @@ class AngularAutoCorrelationsTwoAxesTest(unittest.TestCase): self.assertAlmostEqual(output_ws.blocksize(), 501) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ApplyDetectorScanEffCorrTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ApplyDetectorScanEffCorrTest.py index 0cf1087c7dc588da82c44cfcbae0a075f1e47f06..5dd6948528cc7de9ab153402a7c7bebbd7f3c01f 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ApplyDetectorScanEffCorrTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ApplyDetectorScanEffCorrTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np from mantid.simpleapi import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/BinWidthAtXTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/BinWidthAtXTest.py index 097cb6c6a70489293be9bd28cd7ea39c6e879d63..8931ae384ac290bfb9c6a5910dc3c26307aa344e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/BinWidthAtXTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/BinWidthAtXTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import CreateWorkspace, DeleteWorkspace import numpy import sys diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CalculateEfficiencyCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CalculateEfficiencyCorrectionTest.py index 539754e91864e5cdba78d19fb34dcc3841ac2c3c..b9c9435d1d50298b59aebcc1299d9aad10302f6a 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CalculateEfficiencyCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CalculateEfficiencyCorrectionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import \ CalculateEfficiencyCorrection, CloneWorkspace, ConvertToPointData, \ diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CalculateFluxTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CalculateFluxTest.py index d6e15113af17d7ff889a878df452904a43126867..8ad3693d017b6e426ef12ae44dd7ea062efd4fa9 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CalculateFluxTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CalculateFluxTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import CalculateFlux, CreateSampleWorkspace, FindDetectorsInShape, mtd import numpy as np import testhelpers + class CalculateFluxTest(unittest.TestCase): pixels_in_shape = 0 diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CalculateSampleTransmissionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CalculateSampleTransmissionTest.py index c0477f6a42f10d002f566e2c9c6a3282bb834e28..f95dd132fed09681179b89790280cabaed88b49d 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CalculateSampleTransmissionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CalculateSampleTransmissionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np from mantid.simpleapi import CalculateSampleTransmission diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CheckForSampleLogsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CheckForSampleLogsTest.py index 71884672bb0f757e7f7d54785ba78142ff331efd..991853836c20f6f085148c1388c6fc8892d03cfa 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CheckForSampleLogsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CheckForSampleLogsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import simpleapi diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CleanFileCacheTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CleanFileCacheTest.py index b7627588e10141c72e25862297afe8db17395360..06bd6b9594b109859e02767f652cbc2e288c6727 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CleanFileCacheTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CleanFileCacheTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,too-many-public-methods,too-many-arguments,multiple-statements -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * from mantid.api import * @@ -16,6 +14,7 @@ from mantid.simpleapi import CreateCacheFilename import os, sys, hashlib, tempfile, glob, shutil, time + class CleanFileCache(unittest.TestCase): def test1(self): @@ -165,6 +164,7 @@ def computeTime(daysbefore): "compute time as float of the time at n=daysbefore days before today" return time.time() - daysbefore * 24*60*60 + def touch(f): with open(f, 'w') as stream: stream.write('\n') diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CompareSampleLogsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CompareSampleLogsTest.py index 4a3eb111852c90e962e8ca278dba0f4c81a5c3d7..605cfc6ea8c1d53499c3cd21cea16744a2a6200c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CompareSampleLogsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CompareSampleLogsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from mantid.api import AnalysisDataService diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py index 55e35b84207211e9e396016535199914669dcd84..94c1c51f055c3857f69d7ca5b0ebf2d3b4a82b81 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import FloatTimeSeriesProperty from mantid.simpleapi import (DeleteWorkspace, CreateSampleWorkspace, diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ComputeIncoherentDOSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ComputeIncoherentDOSTest.py index d4b47cb288fb9d7ec912b600334639b2fa856bf8..50436957cb9a17d0e27da7b1ce89480751ff2652 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ComputeIncoherentDOSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ComputeIncoherentDOSTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import (AddSampleLog, ComputeIncoherentDOS, CreateSampleWorkspace, CreateWorkspace, LoadInstrument, ScaleX, Scale, SetInstrumentParameter, SetSampleMaterial, SofQW3, Transpose) @@ -14,6 +12,7 @@ from numpy import testing from scipy import constants import testhelpers + class ComputeIncoherentDOSTest(unittest.TestCase): def createPhononWS(self, T, en, e_units): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ConjoinSpectraTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ConjoinSpectraTest.py index 23c7375ce2ddcea0663f6a77bc0ec044b90f6280..3e209e54c2df96cc027f727e9ae974b4f3ea6211 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ConjoinSpectraTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ConjoinSpectraTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * from mantid.api import * from testhelpers import run_algorithm + class ConjoinSpectraTest(unittest.TestCase): _aWS= None diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ConvertWANDSCDtoQTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ConvertWANDSCDtoQTest.py index 91912d78993c6500d35774bc3083d1701b387fd8..2d0d21bdb7c43111f54b890dae2225651ad3343c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ConvertWANDSCDtoQTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ConvertWANDSCDtoQTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from mantid.simpleapi import ConvertWANDSCDtoQ, CreateMDHistoWorkspace, CreateSingleValuedWorkspace, SetUB, mtd import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CorrectLogTimesTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CorrectLogTimesTest.py index 56ed13a02d074a2b758df89e2f9fd74227be3e08..a22b14b094bd397188ede1a661fb686a418fde9d 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CorrectLogTimesTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CorrectLogTimesTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * from testhelpers import * from numpy import * + class CorrectLogTimesTest(unittest.TestCase): def testCLTWrongLog(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CorrectTOFTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CorrectTOFTest.py index 277ad2d115e9f0d3aa0aa43214dab37d67302f91..566afbe387719e61539dbb9cde3b4660f2c4e25c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CorrectTOFTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CorrectTOFTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import CreateSampleWorkspace, CloneWorkspace, GroupWorkspaces, AddSampleLogMultiple, CreateEmptyTableWorkspace from testhelpers import run_algorithm @@ -13,6 +11,7 @@ from mantid.api import AnalysisDataService, WorkspaceGroup from scipy.constants import h, m_n, eV import numpy as np + class CorrectTOFTest(unittest.TestCase): def setUp(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CreateCacheFilenameTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CreateCacheFilenameTest.py index b2bb855087182534fcf96894e0c8ab3e88f4460f..76f09c16e4f288fa7f0aa60bdfd2afa93df6390e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CreateCacheFilenameTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CreateCacheFilenameTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,too-many-public-methods,too-many-arguments -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * from mantid.api import * @@ -14,6 +12,7 @@ from testhelpers import run_algorithm import os, mantid, hashlib + class CreateCacheFilename(unittest.TestCase): def test1(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CreateLeBailFitInputTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CreateLeBailFitInputTest.py index 4aa8f1d5e070ac193d94554dda2a4191f7e38511..844b28d2d1e45f700509cbbed0401bd3560c25dc 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CreateLeBailFitInputTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CreateLeBailFitInputTest.py @@ -4,17 +4,15 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy from mantid.kernel import * from mantid.api import * from testhelpers import run_algorithm from mantid.api import AnalysisDataService -from six.moves import range import os + class CreateLeBailFitInputTest(unittest.TestCase): def test_LoadHKLFile(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CreateWorkspaceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CreateWorkspaceTest.py index d7a48126f7dba2467eedf9b48304fcf99fa96d11..a4e3e58d1ba196486349631156d1fa6cb7a8207a 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CreateWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CreateWorkspaceTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import MatrixWorkspace, AnalysisDataService from mantid.simpleapi import CreateWorkspace from testhelpers import run_algorithm import numpy as np + class CreateWorkspaceTest(unittest.TestCase): def test_create_with_1D_numpy_array(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py index d1fdbd1e591ae08603026c22667cdb827dd8c548..f0535ac98869e8dae08cdae7633c6759e6a51c9e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceForMDNormTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest,os from mantid.simpleapi import CreateSampleWorkspace, CropWorkspaceForMDNorm + class CropWorkspaceForMDNormTest(unittest.TestCase): def test_simple(self): ws_in = CreateSampleWorkspace(WorkspaceType='Event', diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceRaggedTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceRaggedTest.py index e5349805653aff481a818fc8fd21497858b4300e..7908d145c6ce367076fba416a1b6f9675041110b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceRaggedTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CropWorkspaceRaggedTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid.simpleapi as api from testhelpers import run_algorithm diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/CylinderPaalmanPingsCorrection2Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/CylinderPaalmanPingsCorrection2Test.py index 0d5452bfbb95aae9df2b0c49bfe1b6ae8e0ec4f8..4cd372d7b43b6956adae71a1d663cca2712b9062 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/CylinderPaalmanPingsCorrection2Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/CylinderPaalmanPingsCorrection2Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import mtd, config from mantid.simpleapi import (CreateSampleWorkspace, Scale, DeleteWorkspace, ConvertToPointData, diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/DNSComputeDetEffCorrCoefsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/DNSComputeDetEffCorrCoefsTest.py index 5644a024a4b98f7a02f0f7fec4a048d0a006ca06..bd3f37012cf8f24ac61594fa51190a0dc1d97c9f 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/DNSComputeDetEffCorrCoefsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/DNSComputeDetEffCorrCoefsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from testhelpers.mlzhelpers import create_fake_dns_workspace diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/DNSFlippingRatioCorrTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/DNSFlippingRatioCorrTest.py index 5a09f871aa75c66ccdc7726d4a58b31f9428c72d..4d8179e9fe5b22b9686a50fa6c63c36662064f7f 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/DNSFlippingRatioCorrTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/DNSFlippingRatioCorrTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import unittest from testhelpers import run_algorithm from testhelpers.mlzhelpers import create_fake_dns_workspace diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/DNSMergeRunsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/DNSMergeRunsTest.py index fe6299dba2ae10030c0931ca6083143ace97dc5a..79a618546754fccbcaeaa5347ccce6ec928c8df6 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/DNSMergeRunsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/DNSMergeRunsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from testhelpers.mlzhelpers import create_fake_dns_workspace diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/DSFinterpTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/DSFinterpTest.py index 4dc898534b52393f75ee6ae0eca6fa24a5afb743..49566067fd47d793fa4117a2c82d2e487661ce26 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/DSFinterpTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/DSFinterpTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest,os import mantid import numpy import pdb from mantid.kernel import logger + class DSFinterpTest(unittest.TestCase): def generateWorkspaces(self, nf): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/DakotaChiSquaredTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/DakotaChiSquaredTest.py index d73496d8e70f7f1391530439fffef676efde73c3..15d749d9c025ba0cf9ec80d29b993edadb2a39a4 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/DakotaChiSquaredTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/DakotaChiSquaredTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest, os from mantid import AnalysisDataServiceImpl, config, simpleapi diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/DeltaPDF3DTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/DeltaPDF3DTest.py index b69569c2b58010931f57b1e016e162102622e830..e6aa4308ec57e8a11bbfe476aa9f3cc445e3e738 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/DeltaPDF3DTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/DeltaPDF3DTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import DeltaPDF3D, CreateMDWorkspace, FakeMDEventData, BinMD, mtd import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateFullTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateFullTest.py index 3ac664875eeb1df92949918215d94d72721d8de0..b31dcd8801dea0cdb7026481952ca2781a6bdcb1 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateFullTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateFullTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * + class EnggCalibrateFullTest(unittest.TestCase): _data_ws = None diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateTest.py index 8b74419fce5573b3733d8668468f456b50189a59..637e3f816b03d948611fe9efc3e0d2ae1a3d76ad 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggCalibrateTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import sys import unittest from mantid.api import * import mantid.simpleapi as sapi + class EnggCalibrateTest(unittest.TestCase): _data_ws = None diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py index a535fc9f41409eac7fdc0d636991671188ecfb36..ef03a9c67ebd3940ff9b5d5bdf33eeac8993d7ca 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitPeaksTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitTOFFromPeaksTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitTOFFromPeaksTest.py index b6c8ada02ef0fe1895f99c13452a783be8ada646..cba5e65da666fbe94dd7f3229890719e5e25f506 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitTOFFromPeaksTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFitTOFFromPeaksTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFocusTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFocusTest.py index c5fbd57010f110afb0c8e76c426f400480d23d83..db2b740c7576398280977e8b1b857cdb4541c850 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggFocusTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggFocusTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5Test.py index 9c6cc4ede04e7acba1a6655c8e670f2d7a9b599a..df3004094ea5a6338bee8b87273f2dbdf724f811 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveGSASIIFitResultsToHDF5Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import h5py import os import random diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5Test.py index b01576d645b3f2155afaee2dff8c0d1c04e4851a..7cc81ccc111974ace0a75f92b787884ff58505a3 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggSaveSinglePeakFitResultsToHDF5Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import h5py import os import random diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/EnggVanadiumCorrectionsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/EnggVanadiumCorrectionsTest.py index 24f6b2bd1e8c58078bf422cd15d7d83daa5ff1b5..59ae09c40f5cccba2baa9e54327ce3dbf8a5c840 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/EnggVanadiumCorrectionsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/EnggVanadiumCorrectionsTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import * import mantid.simpleapi as sapi + class EnggVanadiumCorrectionsTest(unittest.TestCase): _data_ws = None diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py index 6ae58e9127ce25d5cea72ea03e1c9b94cfe1f794..120605c129acf9e11b7d2a2ccbf4f433906dbd35 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ExportExperimentLogTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy from numpy import * @@ -15,7 +13,7 @@ import mantid.kernel as kernel from testhelpers import run_algorithm from mantid.api import AnalysisDataService import os -from six.moves import range + class ExportExperimentLogTest(unittest.TestCase): @@ -743,4 +741,3 @@ class ExportExperimentLogTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py index f103669dcfaef807b4e522e38c65c768b40c36fa..01d691884871b3d753e1c0c911a05e24e5c50d27 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np import mantid.kernel as kernel @@ -13,7 +11,6 @@ from testhelpers import run_algorithm from mantid.api import AnalysisDataService import os from distutils.version import LooseVersion -from six.moves import range class ExportVulcanSampleLogTest(unittest.TestCase): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToHDF5Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToHDF5Test.py index 480e8a94f9c92a1d85416e4a4562366dcf17710a..96685ce7b0b60e1c088cdbe574445b582277b076 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToHDF5Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToHDF5Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import h5py import numpy as np import os diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSpectraMaskTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSpectraMaskTest.py index e89707adee82eca03d5f20282f7632dc9564ddfb..c8ea94f83ad54d2f82fac7a11920a56977286bab 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSpectraMaskTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSpectraMaskTest.py @@ -4,15 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import sys import numpy as np import unittest import mantid from mantid.simpleapi import ExportSpectraMask,DeleteWorkspace -from six.moves import range + class ExportSpectraMaskTest(unittest.TestCase): def __init__(self,method_name): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ExtractMonitorsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ExtractMonitorsTest.py index bfd2ffac5e307f01236dcd07bd860a9b3238f6a3..829f6cfb49807ef80463f52d1490420b9a719307 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ExtractMonitorsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ExtractMonitorsTest.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * + class ExtractMonitorsTest(unittest.TestCase): def setUp(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/FilterLogByTimeTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/FilterLogByTimeTest.py index d5fa9a181e94b7eff57f119ddf361d916c39bcef..d47004e7a84ce943b2994ebce153c2ff0d339b38 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/FilterLogByTimeTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/FilterLogByTimeTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy from mantid.simpleapi import * from mantid.kernel import * from mantid.api import * + class FilterLogByTimeTest(unittest.TestCase): __ws = None @@ -131,4 +130,4 @@ class FilterLogByTimeTest(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py index 27cdc9c6ef097959366a013914e564412d3b21be..2f2841fda03c801e4d5822a0c5024e097eeaec5e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/FitGaussianTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import FitGaussian, CreateSampleWorkspace, DeleteWorkspace import logging + class FitGaussianTest(unittest.TestCase): def setUp(self): self.ws = None diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/FitIncidentSpectrumTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/FitIncidentSpectrumTest.py index 2dfa372c376849794ac1073fcf31a0ecda6cc224..63ed99d7a7d2da014f5d7bc1c7bea6a2ea7ca783 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/FitIncidentSpectrumTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/FitIncidentSpectrumTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np from mantid.simpleapi import AnalysisDataService, FitIncidentSpectrum, CalculateEfficiencyCorrection, CloneWorkspace, ConvertToPointData, \ diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py index 6bee61f04d81606ff5da949bd8a6ec50f43675f0..dc1a69dd3731098684879dc5550664a42ba4ff9e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/GetEiT0atSNSTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/HB2AReduceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/HB2AReduceTest.py index 9989f4830765fcc0f8134c6919df1079140ec3db..85624f22198348244ba7231409e8f625d3dd37ae 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/HB2AReduceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/HB2AReduceTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from mantid.simpleapi import HB2AReduce import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/HFIRSANS2WavelengthTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/HFIRSANS2WavelengthTest.py index cb40e25fd0bdfb2395da7a90dd7a2230971f6e30..374d4328b580c943e1df6333de9795c25f4e95df 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/HFIRSANS2WavelengthTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/HFIRSANS2WavelengthTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import HFIRSANS2Wavelength, CreateWorkspace, AddSampleLog, mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/IndirectTransmissionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/IndirectTransmissionTest.py index 3bf384766c40f3516764ea28a1a607c2d0301d3c..6a40bcf13d379e280f2200f32cd1404a1e775e2c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/IndirectTransmissionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/IndirectTransmissionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np from mantid.simpleapi import IndirectTransmission diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py index 9d646a83107bce90245ba205444af0cbf6bd1459..74b7773f1a61eef4f74fbbb8f592e64e3ee0ad55 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LRPeakSelectionTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LRPeakSelection, CreateSampleWorkspace, DeleteWorkspace import logging + class LRPeakSelectionTest(unittest.TestCase): def setUp(self): self.ws = None diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadAndMergeTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadAndMergeTest.py index 7bb064bb6efda948ca28f607d029520ad91f0543..4403c6bd24e2cc4371b48533e403bb641c3d4bad 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadAndMergeTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadAndMergeTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import MatrixWorkspace, WorkspaceGroup from mantid.simpleapi import LoadAndMerge, config, mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadCIFTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadCIFTest.py index 981f28b4233d7c2616bbcb62b1732afac1789e58..7196b488d5469f848707fa43ea90f4fe6d14abc0 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadCIFTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadCIFTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,too-many-public-methods,invalid-name,protected-access -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import assertRaisesNothing @@ -15,7 +13,6 @@ from LoadCIF import SpaceGroupBuilder, UnitCellBuilder, AtomListBuilder, UBMatri from mantid.api import AlgorithmFactory from mantid.geometry import UnitCell -from six import iteritems import numpy as np import sys @@ -208,7 +205,7 @@ class AtomListBuilderTest(unittest.TestCase): uElements = {'11': [u'0.01', u'0.02'], '12': [u'0.0', u'0.0'], '13': [u'0.0', u'0.0'], '22': [u'0.01', u'0.02'], '23': [u'0.0', u'0.0'], '33': [u'0.04', u'0.05']} - uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in iteritems(uElements)]) + uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in uElements.items()]) uDict.update(dict([(u'_atom_site_label', [u'Si', u'Al']), (u'_atom_site_aniso_label', [u'Si', u'Al']) ])) @@ -225,7 +222,7 @@ class AtomListBuilderTest(unittest.TestCase): '22': [u'0.01', u'0.02'], '23': [u'0.0', u'0.0'], '33': [u'0.04', u'0.05']} - uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in iteritems(uElements)]) + uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in uElements.items()]) uDict.update(dict([(u'_atom_site_label', [u'Si', u'Al']), (u'_atom_site_aniso_label', [u'Si', u'Al']) ])) @@ -241,7 +238,7 @@ class AtomListBuilderTest(unittest.TestCase): bElements = {'11': [u'1.0', u'2.0'], '12': [u'0.0', u'0.0'], '13': [u'0.0', u'0.0'], '22': [u'1.0', u'2.0'], '23': [u'0.0', u'0.0'], '33': [u'4.0', u'5.0']} - bDict = dict([(u'_atom_site_aniso_b_{0}'.format(key), value) for key, value in iteritems(bElements)]) + bDict = dict([(u'_atom_site_aniso_b_{0}'.format(key), value) for key, value in bElements.items()]) bDict.update(dict([(u'_atom_site_label', [u'Si', u'Al']), (u'_atom_site_aniso_label', [u'Si', u'Al']) ])) @@ -256,7 +253,7 @@ class AtomListBuilderTest(unittest.TestCase): uElements = {'11': [u'0.01'], '12': [u'0.0'], '13': [u'0.0'], '22': [u'0.01'], '23': [u'0.0'], '33': [u'0.04']} - uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in iteritems(uElements)]) + uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in uElements.items()]) uDict.update(dict([(u'_atom_site_label', [u'Si', u'Al']), (u'_atom_site_aniso_label', [u'Al']), (u'_atom_site_u_iso_or_equiv', [u'0.01', u'invalid']) @@ -272,7 +269,7 @@ class AtomListBuilderTest(unittest.TestCase): uElements = {'11': [u'0.01', u'0.02'], '12': [u'0.0', u'0.0'], '13': [u'0.0', u'0.0'], '22': [u'0.01', u'0.02'], '23': [u'0.0', u'0.0'], '33': [u'0.04', u'0.05']} - uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in iteritems(uElements)]) + uDict = dict([(u'_atom_site_aniso_u_{0}'.format(key), value) for key, value in uElements.items()]) uDict.update(dict([(u'_atom_site_label', [u'Si', u'Al']), (u'_atom_site_aniso_label', [u'Si', u'Al']), (u'_atom_site_u_iso_or_equiv', [u'0.01', u'0.02']) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadDNSLegacyTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadDNSLegacyTest.py index d0eea6fad53217ed659067a03e09ad89290048e0..83711289974cf3fc79f342bc724c3929518d972f 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadDNSLegacyTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadDNSLegacyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from mantid.api import AnalysisDataService diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadEmptyVesuvioTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadEmptyVesuvioTest.py index 660f72f8b83d7e211881c60767bb05bc8a4616fd..de38ee79e0868f52f17eded528a253bb6d3f305c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadEmptyVesuvioTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadEmptyVesuvioTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * + class LoadEmptyVesuvioTest(unittest.TestCase): def test_load_empty_no_par_file(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadFullprofFileTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadFullprofFileTest.py index 4aaa8668203ea7b3ccb05d5a73f3173f9e19108e..bd21c998489fa2383d372ed9aa1fda0d978d6420 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadFullprofFileTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadFullprofFileTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy from mantid.kernel import * @@ -15,6 +13,7 @@ from mantid.api import AnalysisDataService import os + class LoadFullprofFileTest(unittest.TestCase): def test_LoadHKLFile(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadGudrunOutputTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadGudrunOutputTest.py index f5be53822bd61d5f140fb3bff36d6ed6116f0373..71be425e6efd2758d1393d413d3acee8375b620a 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadGudrunOutputTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadGudrunOutputTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import LoadGudrunOutput, Workspace import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadLampTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadLampTest.py index ed8a24d0d86f5ee362f35ee83fca4e51a75b4c8d..dce1e20a1d914af70235b9fd27d1f8625acdee30 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadLampTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadLampTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import config, mtd, LoadLamp import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadLiveDataTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadLiveDataTest.py index 1bfb77979e3c337573f98484155aafe00f7fd979..fca072b42a825f77f6d4f25fb18611d1e7817161 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadLiveDataTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadLiveDataTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import os diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadLogPropertyTableTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadLogPropertyTableTest.py index 6c65286de65f20d418245d84d5b79c332d305c04..594dbdf5954471c0ac25437fb4cbc6ea133ec103 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadLogPropertyTableTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadLogPropertyTableTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy from mantid.kernel import * @@ -15,6 +13,7 @@ from mantid.api import AnalysisDataService import os + class LoadLogPropertyTableTest(unittest.TestCase): def test_LoadValidFilesComments(self): outputWorskapceName = "LoadLogPropertyTableTest_Test1" diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadMultipleGSSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadMultipleGSSTest.py index 5569ed64e9c4d203d5bb9c5413ede21b4fb9fe50..47d81ca3dd4325b9af9f5bd03006320e18e5af76 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadMultipleGSSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadMultipleGSSTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import run_algorithm from mantid.api import AnalysisDataService + class LoadMultipleGSSTest(unittest.TestCase): def test_LoadMultipleGSSTest(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn3AsciiTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn3AsciiTest.py index d06a22c30618c0c42d3506c960b40deff678aaee..abef8c1f4a9741ac7bb8500b5352dc32e8f25be3 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn3AsciiTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn3AsciiTest.py @@ -5,12 +5,11 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * + class LoadNMoldyn3AsciiTest(unittest.TestCase): _cdl_filename = 'NaF_DISF.cdl' diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4Ascii1DTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4Ascii1DTest.py index 78a68b5cf79e6a1df2bd8e2faa3a96fad63cd49e..7f63c04302c54370de6621ac89a87abc28eea93b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4Ascii1DTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4Ascii1DTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadNMoldyn4Ascii1D, config from mantid.api import * import os import math + class LoadNMoldyn4Ascii1DTest(unittest.TestCase): def setUp(self): data_dirs = config['datasearch.directories'].split(';') diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4AsciiTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4AsciiTest.py index 54c6c43507f2fa15d1048fae06b21545b2de961f..eaec78aaf98ce2c2e44b8b6da69ebd69105f523b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4AsciiTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadNMoldyn4AsciiTest.py @@ -5,14 +5,13 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * import os + class LoadNMoldyn4AsciiTest(unittest.TestCase): """ Note that the test files used here are not axactly in the same format as diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/LoadWANDSCDTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/LoadWANDSCDTest.py index cda4f1f4a2516b2992c95f4553be9de7442eb30f..d46aa9a755652b67f2fd9f62d51a3921abc51c82 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/LoadWANDSCDTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/LoadWANDSCDTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from mantid.simpleapi import LoadWANDSCD import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MaskAngleTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MaskAngleTest.py index 93b53b25af814ace97e5e70acdaa8dc8528e077a..873d9b3cf96974ac061a24bafd15424fc3fb62a9 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MaskAngleTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MaskAngleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MaskBTPTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MaskBTPTest.py index 4cbeac2717c3cae643c4795a29af8ab0bd1a23a9..5fe8932a89dd72a29205de3328952e2d35bf7138 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MaskBTPTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MaskBTPTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MaskWorkspaceToCalFileTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MaskWorkspaceToCalFileTest.py index 88a362c3db2dfb04aff33460eeecc557db31d339..82caa0f6013587d0333f6eb5984f1b4c9ab1a0b0 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MaskWorkspaceToCalFileTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MaskWorkspaceToCalFileTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import os from mantid.kernel import * @@ -13,6 +11,7 @@ from mantid.api import * from mantid.simpleapi import * from testhelpers import run_algorithm + class MaskWorkspaceToCalFileTest(unittest.TestCase): def get_masking_for_index(self, cal_file, requested_index): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MatchPeaksTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MatchPeaksTest.py index 7d13a6a4d196e1dae1487c56b814409bc43e2607..c9f360be90ef4c9c181d7a213b3325d3d2f029e7 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MatchPeaksTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MatchPeaksTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import sys import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MatchSpectraTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MatchSpectraTest.py index ecc460b8a18c416563f13339babe572110bfb198..5f3bc5c1c1a9e132da694f0183aa5fd33dbb13e2 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MatchSpectraTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MatchSpectraTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import CreateWorkspace, DeleteWorkspace, DeleteWorkspaces, MatchSpectra, mtd import numpy as np import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MeanTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MeanTest.py index aa891036ce8fe24d598b8b1223b22ac964d5a501..1ab04ccc7589367becb3ee7822320e847c0b9011 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MeanTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MeanTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * + class MeanTest(unittest.TestCase): def test_throws_if_non_existing_names(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MedianBinWidthTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MedianBinWidthTest.py index d9f6792bdd02bb80a36ca37244f6b04c01664489..1eb15383c71cafb794eebcb1e4b41298e77f5ade 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MedianBinWidthTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MedianBinWidthTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import CreateWorkspace, DeleteWorkspace import numpy import testhelpers diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MergeCalFilesTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MergeCalFilesTest.py index d122ea39de7f288db2171ab0a6b329cb8f0aa5c5..9a5624ca5e4972a177b6e89de63b3d21056473a8 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MergeCalFilesTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MergeCalFilesTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import os import tempfile @@ -18,6 +16,8 @@ from testhelpers import run_algorithm ''' Helper type to represent an entry in a cal file ''' + + class CalFileLine: _number = None @@ -51,6 +51,8 @@ class CalFileLine: ''' A helper resource managing wrapper over a new calfile object. Creates cal file and allows writing to it. ''' + + class DisposableCalFileObject: _fullpath = None @@ -77,6 +79,8 @@ class DisposableCalFileObject: ''' A helper resource managing wrapper over an existing cal file for reading. Disposes of it after reading. ''' + + class ReadableCalFileObject: _fullpath = None @@ -197,4 +201,4 @@ class MergeCalFilesTest(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py index 1ff9fd20a37f228705952b5f75c8356c1465d126..8f69594236fb141450317bfeec4f6cf0c3fcae0c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import numpy as np import math import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MuscatSofQWTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MuscatSofQWTest.py index 965e28ee9fb463cc778d0b925a944519985f2435..1693e2aab99a297dfdcbf7fd431fd9f5ee332850 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MuscatSofQWTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MuscatSofQWTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * + class MuscatSofQWTest(unittest.TestCase): def setUp(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/NMoldyn4InterpolationTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/NMoldyn4InterpolationTest.py index f69e5edadcc76abec0b52db041a9c4f52803c109..c875ef038b9acc51feafc431e3be4be65d1eb2dd 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/NMoldyn4InterpolationTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/NMoldyn4InterpolationTest.py @@ -110,9 +110,4 @@ class NMoldyn4InterpolationTest(unittest.TestCase): if __name__ == "__main__": - python_version = version_info - if python_version < (2, 7, 0): - logger.warning("Not running this test as it requires Python >= 2.7. Version found: {0}". - format(python_version)) - else: - unittest.main() + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py index 6b2d8713e8f4fef7ed73a7fcdc7905e5a227a17f..53b883d4c0530a294bddcb81c4eb65caab3e61ce 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/NormaliseSpectraTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import platform from mantid.simpleapi import * from mantid.api import MatrixWorkspace, WorkspaceGroup + class NormaliseSpectraTest(unittest.TestCase): _positive ='1,2,3,4,5' diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/OptimizeCrystalPlacementByRunTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/OptimizeCrystalPlacementByRunTest.py index f37ab7d447a59d5732a270d81b7529b13c97ad5d..e1083e952658e729d42422c05cdfc39a1a7b6b97 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/OptimizeCrystalPlacementByRunTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/OptimizeCrystalPlacementByRunTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadIsawPeaks, FindUBUsingFFT, IndexPeaks, OptimizeCrystalPlacementByRun from mantid.api import mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertRealSpaceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertRealSpaceTest.py index 6d42d188aa4bc7bffe5e98297dda5f920f53701f..da90581aed283bef39037b2ce3a593d5cba77b50 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertRealSpaceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertRealSpaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import (CreateWorkspace, SetSampleMaterial, diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertReciprocalSpaceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertReciprocalSpaceTest.py index b2bbf15c40637836bb762540318a104c01828d84..c9434f3233d768c5300c2aab645321883becb85f 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertReciprocalSpaceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/PDConvertReciprocalSpaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import (CreateWorkspace, SetSampleMaterial, diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/PoldiCreatePeaksFromFileTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/PoldiCreatePeaksFromFileTest.py index 2bfa2f5f42ae82b960e4fc5403c0f31170dc594d..f98ad8e228d9e8387be498f33de4840c625e4f89 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/PoldiCreatePeaksFromFileTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/PoldiCreatePeaksFromFileTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-public-methods -from __future__ import (absolute_import, division, print_function) - import unittest from testhelpers import assertRaisesNothing from testhelpers.tempfile_wrapper import TemporaryFileHelper diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/PoldiMergeTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/PoldiMergeTest.py index 0d88c34962fb498d2ff8afdfefb73d9fa6f689c2..fa1622d8c1c55ee2ff318ed84950e34d6979d180 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/PoldiMergeTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/PoldiMergeTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * @@ -103,4 +101,4 @@ class PoldiMergeTest(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometryReductionOneLiveDataTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometryReductionOneLiveDataTest.py index 88de096dec18816daa50cf3502f46199167c0b15..f27f5bf5d6cb3746625dea672faff481bf0a18e5 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometryReductionOneLiveDataTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometryReductionOneLiveDataTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometrySliceEventWorkspaceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometrySliceEventWorkspaceTest.py index 09dc3aeb62297d259e88f46bad16e0f56eee8542..1e0a1d4192f8a41970c939730770f211702a5710 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometrySliceEventWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ReflectometrySliceEventWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/RetrieveRunInfoTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/RetrieveRunInfoTest.py index 76ac755af646b34c99184d252adec8fa74ceded0..aa9d7bc465b0990a085dc9b30662734654dc90dc 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/RetrieveRunInfoTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/RetrieveRunInfoTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * @@ -14,6 +12,7 @@ from mantid import config from mantid.simpleapi import * from testhelpers import run_algorithm + class RetrieveRunInfoTest(unittest.TestCase): class_has_been_set_up = False diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SANSSubtractTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SANSSubtractTest.py index d7e2b738dff045e685230e4d28cc457361d0c4de..4d4a24d31ad0e9b09476a806bb6772be679a7fb5 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SANSSubtractTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SANSSubtractTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy @@ -14,6 +12,7 @@ from mantid.api import * from mantid import config from testhelpers import run_algorithm + class SANSSubtractTest(unittest.TestCase): def setUp(self): @@ -43,4 +42,4 @@ class SANSSubtractTest(unittest.TestCase): self.assertAlmostEqual(value, 0, 2) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py index b1e18b13c15490db50224e1722763571fc7b41b8..a6f7feeb7b3ceec0bc05f5966801400e3bfe07ad 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SANSWideAngleCorrectionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy from mantid.kernel import * @@ -14,6 +12,8 @@ from mantid.simpleapi import (CreateWorkspace, LoadInstrument, MoveInstrumentComponent, CropWorkspace, SANSWideAngleCorrection, Min, Max, Transpose, Multiply) + + class SANSWideAngleCorrectionTest(unittest.TestCase): _sample = None _trans = None @@ -66,4 +66,3 @@ class SANSWideAngleCorrectionTest(unittest.TestCase): if __name__ == "__main__": unittest.main() - diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SaveGEMMAUDParamFileTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SaveGEMMAUDParamFileTest.py index 7417e5168f652347aab86c085cbd5f2a184b3f33..1513beb712934532ce50c06d14d5c24bbbed60fb 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SaveGEMMAUDParamFileTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SaveGEMMAUDParamFileTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py index 343a56aa487309a63afe712fbc9d9f3e17325588..f3e5cba6b2c2aefca906406f5beff17b0162fd47 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SaveNexusPDTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,too-many-public-methods,too-many-arguments -from __future__ import (absolute_import, division, print_function) - import mantid from mantid.api import AnalysisDataService from mantid.simpleapi import CreateWorkspace, SaveNexusPD @@ -21,6 +19,7 @@ try: except ImportError: runTests = False + class SaveNexusPDTest(unittest.TestCase): def saveFilePath(self, wkspname): dataDir = mantid.config.getString('defaultsave.directory') diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SavePlot1DAsJsonTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SavePlot1DAsJsonTest.py index 19f6604db164d59a24012427f3b0b0f30602a0be..d26707d62d9d2a50a166d568136f941fa987dc25 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SavePlot1DAsJsonTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SavePlot1DAsJsonTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,too-many-public-methods,too-many-arguments -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np import mantid.simpleapi as api @@ -17,6 +15,7 @@ from mantid.api import AnalysisDataService import os, json + class SavePlot1DAsJsonTest(unittest.TestCase): def test_save_one_curve(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py index 07e92a131c32c79c55aaa4a0f7613d48c6ae3625..064be1122afcf5c17ef360840d5009cb071b49a2 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SaveYDATest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid from mantid.api import mtd from mantid.simpleapi import CreateWorkspace, CreateSampleWorkspace, SaveYDA, ConvertSpectrumAxis, \ diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SelectNexusFilesByMetadataTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SelectNexusFilesByMetadataTest.py index 15626706d52c4907a43c9f14db05fe95913538ac..ea3cafdadee5f25cc89760fd1b48812f6e4d2a4f 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SelectNexusFilesByMetadataTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SelectNexusFilesByMetadataTest.py @@ -5,11 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=unused-import -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * + class SelectNexusFilesByMetadataTest(unittest.TestCase): _fileslist = 'INTER00013460,13463,13464.nxs' @@ -78,4 +77,3 @@ if __name__=="__main__": unittest.main() except ImportError: pass - diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SetDetScaleTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SetDetScaleTest.py index df82657a0a2e5cdd91f6ebb49f15befd67c74cc2..ed984813e6ecc3a57dfe4a9df05bed4648a1cce4 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SetDetScaleTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SetDetScaleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import os from mantid.simpleapi import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SortByQVectorsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SortByQVectorsTest.py index 0f3f2d420f56eaf127db4bf04df55a676951d401..52162c418c5fbac24bad748dea4bed9a48d960f7 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SortByQVectorsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SortByQVectorsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import AnalysisDataServiceImpl, simpleapi diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SortDetectorsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SortDetectorsTest.py index 55dad04901464a3c4e9c8f015a3bf1a0506ab2b4..f2cb0b3c37207ea24ea68eab38d0ee0347128137 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SortDetectorsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SortDetectorsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/StatisticsOfTableWorkspaceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/StatisticsOfTableWorkspaceTest.py index 90d127dcb1fd720d16a9d8c6e7f30b8e56def8b6..84a29c44d496f813b93e3196c1f321bbf4deff21 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/StatisticsOfTableWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/StatisticsOfTableWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np from mantid.simpleapi import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py index e426fbe4aafe78d3b6646db40fd7188f01b0a136..3f7eb6fd0f7e5bb1861824e641af469b1f9f1304 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/StringToPngTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest, os from mantid import AnalysisDataServiceImpl, config, simpleapi diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibCNCSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibCNCSTest.py index 52288a25abd908227887428c068eec752d221890..aee0e8598697aa7412cc25d236063187e22a6897 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibCNCSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibCNCSTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import simpleapi import numpy diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibHYSPECTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibHYSPECTest.py index 65e8b7b023e40b8d2064f2547e57ff3f1466f1ca..dc67530277e843eb1c8b137434d15dce14b68d1c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibHYSPECTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SuggestTibHYSPECTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import simpleapi diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py index 3e4bd6c2a9f32831f1e6cbd8358d649e752b59f8..04ce1c5dcad6c2cd3227a95a2a318c8f24ac7d76 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SymmetriseTest.py @@ -5,13 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=redefined-builtin -from __future__ import (absolute_import, division, print_function) - import numpy as np import unittest -from six.moves import range - from mantid.api import * from mantid.simpleapi import CreateWorkspace, ScaleX, Symmetrise diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py index f06b7d4f40c5053ceec72defc82f6f500a2166af..1a1ae707c82441ff04488137c74a1806345adb99 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFCropWorkspaceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import Load, DeleteWorkspace, GroupWorkspaces, TOFTOFCropWorkspace from testhelpers import run_algorithm diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFMergeRunsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFMergeRunsTest.py index 92f0bca8ea4fe0a78ce7b06923759b265ccc622e..8cf974ac209b424c9558ce1d2af238137edc3373 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFMergeRunsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/TOFTOFMergeRunsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import Load, DeleteWorkspace, AddSampleLogMultiple, \ DeleteLog diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/UpdatePeakParameterTableValueTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/UpdatePeakParameterTableValueTest.py index 58bb7741446a4a86dc52d005e379734ebf3c4722..004979312f783654875355dff98b4c324c6c9410 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/UpdatePeakParameterTableValueTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/UpdatePeakParameterTableValueTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy from mantid.kernel import * @@ -13,6 +11,7 @@ from mantid.api import * from testhelpers import run_algorithm from mantid.api import AnalysisDataService + class UpdatePeakParameterTableValueTest(unittest.TestCase): def test_updateDouble(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/VelocityAutoCorrelationsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/VelocityAutoCorrelationsTest.py index 42c65df7669025a3002ce7e0fa37cd15cf839b86..a645fbbebb400e441f31a4e726c0487e0fcd02cc 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/VelocityAutoCorrelationsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/VelocityAutoCorrelationsTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid from mantid.simpleapi import VelocityAutoCorrelations + class VelocityAutoCorrelationsTest(unittest.TestCase): def test_simple(self): @@ -24,4 +23,4 @@ class VelocityAutoCorrelationsTest(unittest.TestCase): self.assertAlmostEqual(data_y[0], 0.000247266521347895) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/VelocityCrossCorrelationsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/VelocityCrossCorrelationsTest.py index 5fc2f0268c892674f0a19f2d3ca407d7db60c293..c3e6afa6a10077c39e2061e1ecd79a862bd60258 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/VelocityCrossCorrelationsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/VelocityCrossCorrelationsTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid from mantid.simpleapi import VelocityCrossCorrelations + class VelocityCrossCorrelationsTest(unittest.TestCase): def test_simple(self): @@ -26,4 +25,4 @@ class VelocityCrossCorrelationsTest(unittest.TestCase): self.assertAlmostEqual(data_y[0], -8.76322385197998e-05) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioPreFitTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioPreFitTest.py index 354f44d5cf3684a7d2180fa80f13b5c75d3f2e9b..6e1a574f3ecd109e33f29a2c638833824688e1d6 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioPreFitTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioPreFitTest.py @@ -11,9 +11,6 @@ Assumes that mantid can be imported and the data paths are configured to find the Vesuvio data """ -from __future__ import (absolute_import, division, print_function) -from six import iteritems - from mantid.api import AlgorithmManager import numpy as np @@ -114,7 +111,7 @@ class VesuvioPreFitTest(unittest.TestCase): alg.initialize() alg.setChild(True) alg.setProperty("OutputWorkspace", "__unused") - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): alg.setProperty(key, value) return alg @@ -134,4 +131,3 @@ class VesuvioPreFitTest(unittest.TestCase): if __name__ == "__main__": unittest.main() - diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioResolutionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioResolutionTest.py index a3998c9cdde2788a21ec06af261c715c8df153d4..36d08de9c644aeca920660ddb02b96e804eec0a6 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioResolutionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioResolutionTest.py @@ -4,13 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * import vesuvio.testing as testing + class VesuvioResolutionTest(unittest.TestCase): def setUp(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioTOFFitTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioTOFFitTest.py index a6cf2e405ac6dfd5c26277f7d96bfdb4a9477b41..45a3a0504b286133038c98d4367433936cbb415a 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioTOFFitTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioTOFFitTest.py @@ -10,9 +10,6 @@ Unit test for Vesuvio reduction Assumes that mantid can be imported and the data paths are configured to find the Vesuvio data """ -from __future__ import (absolute_import, division, print_function) -from six import iteritems - import unittest import numpy as np import sys @@ -188,7 +185,7 @@ class VesuvioTOFFitTest(unittest.TestCase): alg.setChild(True) alg.setProperty("OutputWorkspace", "__unused") alg.setProperty("FitParameters", "__unused") - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): alg.setProperty(key, value) return alg diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioThicknessTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioThicknessTest.py index 0a42d1bbf180f58e6a8c9cd73e97d884362e586e..e203cef5460ca8f35a32cb59eef98ec5d74c7686 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioThicknessTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/VesuvioThicknessTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import platform import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultipleTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultipleTest.py index 19883d21d72024c356ab4b534989ca3a7977c1bd..fcd8dd014df06ca17cae6fb9f5e4cbaf7bf11d93 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultipleTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultipleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py index 313324a48e293778097971f24a4b7c04d459447b..265790cace6b3dcbaa8ba5c95d45b0f47f848755 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ApplyPaalmanPingsCorrectionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesQuasiTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesQuasiTest.py index 1641351d7791a044875e1f1023b8f970ec57a5fb..f2dc01ae919b2d77fca27b121b7993b43e20954a 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesQuasiTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesQuasiTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import platform import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesStretchTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesStretchTest.py index 658ba4be7c3e5b976932a0679e7a59d5be22df15..d00a4118d5525ba28844523f722af20389355311 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesStretchTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/BayesStretchTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import platform from mantid.simpleapi import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeightingTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeightingTest.py index 75eec44d2c3300298635453cdb72e9c1ba5f7417..6b0f3df608ff9f43e5689991d2a525f94b5a3a63 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeightingTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DetectorFloodWeightingTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmManager from mantid.simpleapi import CreateSampleWorkspace, DeleteWorkspace diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShieldingTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShieldingTest.py index 7403e418018bbfc41cd46e5701554d61e6148578..0363e53e16328f1d8c64cb289197a08a5590719e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShieldingTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShieldingTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (mtd) from mantid.simpleapi import (CloneWorkspace) import numpy.testing diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectDataTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectDataTest.py index e53a69d7816294dc7667731111d442acdc7d6822..547eba76e850f1ab0b2fa0b6c846c463e4d4b312 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectDataTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectDataTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd import numpy.testing from testhelpers import assert_almost_equal, illhelpers, run_algorithm diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnosticsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnosticsTest.py index f21b83c6787d344dcc4988717e3bcfd031bc74c8..f6e604117ef917d5465b524ac638bc801f55c2ef 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnosticsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnosticsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from testhelpers import illhelpers, run_algorithm import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadiumTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadiumTest.py index 15da84bc444a85d2b32d1416439b574a90e5de23..8409007852976667985ba7d11ffb3ea252841b63 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadiumTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadiumTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid import mtd from mantid.simpleapi import (CloneWorkspace, FindEPP) import numpy diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLReductionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLReductionTest.py index 01685333b1c5c9224d4f29cc31508797db0df627..5c61da56e7d1940657f8fd081883637e65c564b3 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLReductionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLReductionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import collections from mantid.api import mtd import numpy diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShieldingTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShieldingTest.py index 39ed6f27d65e08548d80f79a85bf4b24f92c8437..8b798131b0c2b1f15dd7ae8117ee1745e6526017 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShieldingTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShieldingTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from testhelpers import assert_almost_equal, illhelpers, run_algorithm from mantid.api import mtd import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/EnergyWindowScanTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/EnergyWindowScanTest.py index 8b66a39092b22ec20b02bc747e8641df28cce95a..d7f3b11e22c09f092653da2e483ceacc14ecf850 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/EnergyWindowScanTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/EnergyWindowScanTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import EnergyWindowScan from mantid.api import mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FindPeakAutomaticTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FindPeakAutomaticTest.py index 632f183057f5a08624641fcdad5de7dda10638ec..995bf0769872359b295e40e48c438dcbd6b016cb 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FindPeakAutomaticTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FindPeakAutomaticTest.py @@ -9,7 +9,7 @@ import numpy as np from mantid.simpleapi import CreateEmptyTableWorkspace, CreateWorkspace, DeleteWorkspace, FindPeaksAutomatic from mantid.api import mtd -from mantid.py3compat import mock +from unittest import mock import plugins.algorithms.WorkflowAlgorithms.FindPeaksAutomatic as _FindPeaksAutomatic diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py index 7f43c96386fbbc6b783f2a8b2efbbac07b0f12b8..bc47006834698f18fa4ce1c17ffa5765451a6260 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FitGaussianPeaksTest.py @@ -4,14 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - import numpy as np import unittest from mantid.simpleapi import CreateEmptyTableWorkspace, CreateWorkspace, DeleteWorkspace, FitGaussianPeaks from mantid.api import * -from mantid.py3compat import mock +from unittest import mock import plugins.algorithms.WorkflowAlgorithms.FitGaussianPeaks as _FitGaussianPeaks diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrectionTest.py index 14084604e463de9e221e2105b37af2010a6fce0a..868d33483b5485431968688be9ccf230bf4ecd74 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/FlatPlatePaalmanPingsCorrectionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import mtd, config from mantid.simpleapi import CreateSampleWorkspace, Scale, DeleteWorkspace, ConvertToPointData, \ diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReductionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReductionTest.py index d447069f410b078e4dcee36db449c41173c19027..6b8b5118fa9c5dc2bd8fea0279607fb72ab779ed 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReductionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReductionTest.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferTest.py index 452a02eb9f8fd46ee82299c5a759ad33d30ef9d8..cfea3948b804a03cb5814fd5af6c0006d3aa6e68 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapperTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapperTest.py index ec9ce0787a9e02ec57961f47b1039ca96d8b2f5b..4da20de2abfb9e12f8226ebfed6c5c833b7e4c0d 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapperTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ISISIndirectEnergyTransferWrapperTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import (CreateSimulationWorkspace, CreateWorkspace, CompareWorkspaces, DeleteWorkspace, ISISIndirectEnergyTransfer, ISISIndirectEnergyTransferWrapper) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2Test.py index ce39323af56c4bf8598e33cf42f1f9e0ef377697..58caaf2a6c0f553c84835dd62655a41dfae73b4d 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorption2Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadNexusProcessed, IndirectAnnulusAbsorption, DeleteWorkspace from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorptionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorptionTest.py index 654ba6c2ad2abf38405f5369a4407f30ec5b74e1..edbccbaf8ba60722b92d16dee237a410d044b607 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorptionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectAnnulusAbsorptionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadNexusProcessed, IndirectAnnulusAbsorption from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCalibrationTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCalibrationTest.py index 209eed919cb4bf5d9c797ab1360583f6398e891f..ce9388e5131dfa1c955a68c4e40b818b8878f874 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCalibrationTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCalibrationTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid from mantid.simpleapi import IndirectCalibration diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2Test.py index f4eb642c1f01aa0641510ec363e2d3898acd8bda..56aae7ec227738f611be9593805218d4cad83ebe 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorption2Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadNexusProcessed, IndirectCylinderAbsorption, DeleteWorkspace from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorptionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorptionTest.py index 89b3877877bbb24c847276b80e9620c992b72172..92e9933deb1a5ab20afc587ea7afd1ff261ce03f 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorptionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectCylinderAbsorptionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadNexusProcessed, IndirectCylinderAbsorption from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScanTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScanTest.py index e4c297774fc285e9e4cd94a8e01e069a6af40516..e4dcb2d6f69d6a04c3f1b37329289b07cf7c1a6b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScanTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectDiffScanTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2Test.py index b8acb73891538103143f4b3afc6f7db259590dad..e9f9ded90e4b2895acf99432419cd3ba632cf656 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorption2Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadNexusProcessed, IndirectFlatPlateAbsorption, DeleteWorkspace from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorptionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorptionTest.py index d69e5744354b809f6de0245261bcc3599f7da6c0..7a46c20d0385824d7e6b2db97503de4df58ae0df 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorptionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectFlatPlateAbsorptionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import LoadNexusProcessed, IndirectFlatPlateAbsorption diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransferTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransferTest.py index 6013f355ccbc27af640c352cfa2c546e2048ffbb..1815ac0eb3d18730b08cbb92675bf32314cf5c52 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransferTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransferTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import unittest from mantid.simpleapi import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWSTest.py index e4f640d65012b3f2e6b108c5861dd60b9a63f235..9fa3f1d4cdfcd1fd81f7d4e4f9b014d6b5228f09 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWSTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import mtd from testhelpers import run_algorithm diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENSTest.py index 3a5f5529ca8e78de8d542b46f640e8cb2026f6de..d92d0dc8524a67b3ff08a66d2f0ac5fe8e5aaf94 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENSTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import MatrixWorkspace, WorkspaceGroup diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResultTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResultTest.py index 59aeda0b3746c04d9adc08de02b9e9038f4dffc2..7bfe6e60a728cbcc691602b0587a4568d419575c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResultTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectReplaceFitResultTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import (CompareWorkspaces, ConvolutionFitSequential, ConvolutionFitSimultaneous, LoadNexus, IndirectReplaceFitResult, RenameWorkspace) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectResolutionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectResolutionTest.py index 03302ce561fb85dcf67ab7724ac4463a08745d23..34fee500d84fee43d10e02505baf3cb2efa14dad 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectResolutionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectResolutionTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid from mantid.simpleapi import IndirectResolution + class IndirectResolutionTest(unittest.TestCase): def test_simple(self): @@ -58,4 +57,4 @@ class IndirectResolutionTest(unittest.TestCase): self.assertTrue(res_ws.run().getProperty('current_period').value, 1) if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChangerTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChangerTest.py index fffa277cbafeedae3916157bf456c2ace5c6a602..e08fdb0504bb9338f94741ff5b2d06221e66b5e9 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChangerTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChangerTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import AnalysisDataService from mantid.simpleapi import IndirectSampleChanger diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitorTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitorTest.py index 380b11019905879b6a4eda540bdcd49b180133af..b1a7596dc88592309921a653cff8e60699ebdaf0 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitorTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTransmissionMonitorTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import os import mantid diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTwoPeakFitTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTwoPeakFitTest.py index 6612f157f2e1ec786bbcc590f9dd3a50bb7162d7..43497782708c0176e257069ee4039ffce8ab072b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTwoPeakFitTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IndirectTwoPeakFitTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (AnalysisDataService, MatrixWorkspace, WorkspaceGroup) from mantid.simpleapi import (CompareWorkspaces, EnergyWindowScan, IndirectTwoPeakFit, LoadNexus) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitMultipleTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitMultipleTest.py index 7c1a82a555ef5e25c1386cf56a1fb6e7c31c5a4f..8bf64c2262993d85e785b2c93222832aaafe3b90 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitMultipleTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitMultipleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import MatrixWorkspace, WorkspaceGroup, ITableWorkspace diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitSequentialTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitSequentialTest.py index 731bb44d8cb334cbbd193ad458ba9d6152f5080b..29d716a276383eebdd7d1aab38e20757f322c075 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitSequentialTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/IqtFitSequentialTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import MatrixWorkspace, WorkspaceGroup, ITableWorkspace diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/LoadWANDTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/LoadWANDTest.py index 2b4a59942f1cb624448f4bedd966598a40a05fdd..8e7c10fad6f6c3b935077f3c1ab8ce4604773851 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/LoadWANDTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/LoadWANDTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from mantid.simpleapi import LoadWAND import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherentTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherentTest.py index db0ae9ce85ec7edd151478dfe63d44d4267469e1..2ffd887eed855ccfa3a6d2087c2dabc2d73167ff 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherentTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherentTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import numpy as np from mantid.simpleapi import MDNormSCDPreprocessIncoherent diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MSDFitTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MSDFitTest.py index b01d906598ff87486303ad9b6785160e47213b4f..3080ba107dfabbb051d93b61cfd913e2522c39fe 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MSDFitTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MSDFitTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import CreateSampleWorkspace, MSDFit from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspacesTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspacesTest.py index 744f4b4eb62c7a907b0dccd128b41fffc019b428..f9131a1b5f6a8ea2fc22a7d1ab986e8d69650d7e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspacesTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MatchAndMergeWorkspacesTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np from mantid.api import MatrixWorkspace diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py index f4ee79bc32021e0a0a4d6d70fa5c7586aa18736f..afcfc967c226c924b6b0abb35a531834db5ee50d 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/MolDynTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import os import unittest from mantid.simpleapi import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReductionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReductionTest.py index f7daafc8d893b16b31f6e3615e4f468f1c1a4631..addef04b82fda999fb2aa9afae8122845deac508 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReductionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReductionTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScanTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScanTest.py index f7d28e0ef179c023b938f7efdbb7119e0f7ea485..64f38c9ab2e05952b995a0f53b5e29bb61394dc0 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScanTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLDetectorScanTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import MatrixWorkspace, WorkspaceGroup from mantid.simpleapi import PowderILLDetectorScan, config, mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScanTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScanTest.py index bf3871fb6e5627c31ade4ac145cb4346d039fa90..f8081333ca551674ea2a9d7d02415edf3b25b272 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScanTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/PowderILLParameterScanTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import PowderILLParameterScan from mantid import config, mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcessTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcessTest.py index b4a46c03afc56919b411db74c68874cf436c26b4..e41823baf1a40e732816c4aeac5597b167e16771 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcessTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLAutoProcessTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (MatrixWorkspace, WorkspaceGroup) from mantid.simpleapi import (mtd, config) from testhelpers import (assertRaisesNothing, create_algorithm) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQTest.py index 34cd61ca6a82def52a6f5d516593f13f1fa056f1..fe62f9001a61ea784d745af02d28b6ebf53a7df3 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLConvertToQTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from testhelpers import (assertRaisesNothing, create_algorithm, illhelpers) import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCorTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCorTest.py index ee35dd6bb5029d7cb51e451b55b5ebe54a15ef89..0e604ce85962a895bb0a23e04885daa111a7d33b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCorTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPolarizationCorTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from testhelpers import (assertRaisesNothing, create_algorithm, illhelpers) import unittest diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocessTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocessTest.py index b25f2fa7844bd65dc0a2505619132d41705afdd2..3649601f938ee7da84902eab9e53ebff96a0e64c 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocessTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLPreprocessTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from mantid.simpleapi import ReflectometryILLPreprocess import numpy.testing diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py index e1611f96baae2a0d6de5ea07d61cb3c796a77e15..b9248af301e253988b333b0f0d847d2faa1423a5 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILLSumForegroundTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from testhelpers import (assertRaisesNothing, create_algorithm, illhelpers) import numpy @@ -217,7 +215,7 @@ class ReflectometryILLSumForegroundTest(unittest.TestCase): 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) - self.assertRaisesRegexp(RuntimeError, 'Some invalid Properties found', alg.execute) + self.assertRaisesRegex(RuntimeError, 'Some invalid Properties found', alg.execute) self.assertTrue(alg.isExecuted) def testNotSummedDirectForegroundRaises(self): @@ -233,7 +231,7 @@ class ReflectometryILLSumForegroundTest(unittest.TestCase): 'child': True } alg = create_algorithm('ReflectometryILLSumForeground', **args) - self.assertRaisesRegexp(RuntimeError, 'Some invalid Properties found', alg.execute) + self.assertRaisesRegex(RuntimeError, 'Some invalid Properties found', alg.execute) self.assertTrue(alg.isExecuted) def testReflectedBeamSumInLambdaNoRotation(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_commonTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_commonTest.py index cae3ad8bf6c4bbc209ac1209518e04c880fc3876..406bf6ac49f049abfd7e82d9e454f3042e60112e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_commonTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryILL_commonTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import mtd from testhelpers import (assertRaisesNothing, create_algorithm, illhelpers) import unittest @@ -33,4 +31,4 @@ class ReflectometryILL_commonTest(unittest.TestCase): if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcessTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcessTest.py index 6a93cf1ecf0bdf2662b4e937e8a2408e7fb1fb6d..79d257d75436a74349d6be20a428fe0199115e15 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcessTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcessTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import config diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ResNorm2Test.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ResNorm2Test.py index b62879a4d176ee59e20cb3a931a9010f43bddbbe..5f9c4d5b7a39069af576ea9349db559623ae48a7 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ResNorm2Test.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ResNorm2Test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import MatrixWorkspace, WorkspaceGroup diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrectionTest.py index 6a571d7acfafbe120b4ee17b733928b48cd92866..e3496c858e09cd1ab4f74b55a8f063369d562a35 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSDarkRunBackgroundCorrectionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * @@ -14,7 +12,6 @@ from testhelpers import run_algorithm import numpy as np from SANSDarkRunBackgroundCorrection import DarkRunMonitorAndDetectorRemover from SANSDarkRunBackgroundCorrection import SANSDarkRunBackgroundCorrection -from six.moves import range class SANSDarkRunBackgroundCorrectionTest(unittest.TestCase): @@ -561,6 +558,7 @@ class SANSDarkRunBackgroundCorrectionTest(unittest.TestCase): return ws + class DarkRunMonitorAndDetectorRemoverTest(unittest.TestCase): def test_finds_all_monitor_indices_when_monitor_is_present(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScaleTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScaleTest.py index 3a23be12413dc858598bf1a382cccd1ea281ce59..d730c8be291e1f646a468ad0702521469462cd42 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScaleTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSFitShiftScaleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmManager import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegrationTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegrationTest.py index 7e4aaf58870e2b7dc38fcb81eac1bf3363082c61..aac43a2b0c226bbe8aa0c51c5390f4018b4619ca 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegrationTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLIntegrationTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import MatrixWorkspace, WorkspaceGroup diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLReductionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLReductionTest.py index 23700e030f1b08355cd53669e09aca6342a79ff1..a39643002514a200de1a4e50b39d05e19a8d02c4 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLReductionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSILLReductionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import MatrixWorkspace, Run from mantid.simpleapi import SANSILLReduction, config, mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSMaskTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSMaskTest.py index 49edeef4e42a831056f6a302fbec71a8fa6e7349..bcb6848d86c6ed8e648b88fe845541f2deff7dc5 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSMaskTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSMaskTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import SANSMask, SetInstrumentParameter, MaskDetectors, CreateSampleWorkspace, mtd diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py index c3a37ecd5d42f71c9441365673bfac7c6370e5bf..9dc6e56a07905b81a4a1d84dfbaca730163a9154 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmManager, MatrixWorkspace import numpy as np from SANSStitch import QErrorCorrectionForMergedWorkspaces + class SANSStitchTest(unittest.TestCase): def test_initalize(self): alg = AlgorithmManager.create('SANSStitch') diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py index ec6d9ea160ef6d7cf4f82ae3de2c59dab7e4f3ab..0553495575ace3342d98274b2b39fbcd6fa5a8c1 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SavePlot1DTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest, os from mantid import AnalysisDataServiceImpl, config, simpleapi try: diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSSTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSSTest.py index 23ec76dc102c9a7d39d1bf13b2595f42e4dc7276..0507536309a133f7c789038a9c23be4ed3b9ce43 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSSTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSSTest.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -from six.moves import range - import unittest import math import numpy diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorptionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorptionTest.py index 7d427b698e7e08611e12496054c2bea8161ac1a6..cd07d7c0fade17232062d1131cd91d74c261310b 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorptionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorptionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import (SimpleShapeMonteCarloAbsorption, Load, ConvertUnits, CompareWorkspaces, SetSampleMaterial, DeleteWorkspace) @@ -13,7 +11,8 @@ import unittest class SimpleShapeMonteCarloAbsorptionTest(unittest.TestCase): - def setUp(self): + @classmethod + def setUpClass(self): red_ws = Load('irs26176_graphite002_red.nxs') red_ws = ConvertUnits( InputWorkspace=red_ws, @@ -38,7 +37,7 @@ class SimpleShapeMonteCarloAbsorptionTest(unittest.TestCase): 'OuterRadius': 2.0 }) - corrected = SimpleShapeMonteCarloAbsorption(InputWorkspace=self._red_ws, + __corrected_flat_plate = SimpleShapeMonteCarloAbsorption(InputWorkspace=self._red_ws, Shape='FlatPlate', Width=2.0, Thickness=2.0, @@ -46,7 +45,12 @@ class SimpleShapeMonteCarloAbsorptionTest(unittest.TestCase): # store the basic flat plate workspace so it can be compared with # others - self._corrected_flat_plate = corrected + self._corrected_flat_plate = __corrected_flat_plate + + @classmethod + def tearDownClass(self): + DeleteWorkspace(self._red_ws) + DeleteWorkspace(self._corrected_flat_plate) def _test_corrections_workspace(self, corr_ws): x_unit = corr_ws.getAxis(0).getUnit().unitID() @@ -61,10 +65,6 @@ class SimpleShapeMonteCarloAbsorptionTest(unittest.TestCase): blocksize = corr_ws.blocksize() self.assertEqual(blocksize, 1905) - def tearDown(self): - DeleteWorkspace(self._red_ws) - DeleteWorkspace(self._corrected_flat_plate) - def test_flat_plate(self): # Test flat plate shape diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStatesTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStatesTest.py index 24f0e382956459c60b425ad653385890d54d709c..9cae636351e53f6c42edfbbb04f627fd382583e0 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStatesTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SimulatedDensityOfStatesTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import logger from mantid.api import ITableWorkspace @@ -320,6 +318,7 @@ def _is_name_in_group(wks_group, name_to_find): else: return True + def _perform_group_name_search(wks_group, name_to_find): """ Performs the search for a name in a group and returns diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SofQWMomentsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SofQWMomentsTest.py index 54706645e981b7ee528487ff1b8f2ab1d376c5da..db47c530f9c3f47dd6e2350a0b0fbe2e53c2c41d 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SofQWMomentsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SofQWMomentsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import (CompareWorkspaces, CreateSampleWorkspace, Load, LoadInstrument, RenameWorkspace, ScaleX, SofQW, SofQWMoments) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SwapWidthsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SwapWidthsTest.py index 2ef022800bb53a73cb2062109ca4f90fbf06c270..9815a16b792ad45ba6b6aa76d5268d738350e180 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SwapWidthsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SwapWidthsTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import MatrixWorkspace, WorkspaceGroup + class SwapWidthsTest(unittest.TestCase): _input_ws = 'IN16B_125878_QLd_Result' diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrectionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrectionTest.py index d04df142373988618dfd3e3dbf9df3c4c6894732..e7a7b1507f88936844c0fe016230c04ac8d31cf9 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrectionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TOSCABankCorrectionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TimeSliceTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TimeSliceTest.py index 04a406b7e928dac66d1b1ccac5bd87bdd904c090..51f614d54debf9c593059c9c3318173201df55d3 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TimeSliceTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TimeSliceTest.py @@ -4,12 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * + class TimeSliceTest(unittest.TestCase): def test_basic(self): diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScatteringTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScatteringTest.py index 23af31f7d27a6e69911a6631b3ca6dafa4fdbf9f..8d2efb6546607bbf794595464c5758af66959060 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScatteringTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TotScatCalculateSelfScatteringTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import TotScatCalculateSelfScattering, Load from isis_powder import SampleDetails diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TransformToIqtTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TransformToIqtTest.py index 4b1b92903bb349f492e757f23c2c78d26795e724..53c37f775c94aad33f8d7a8df9f8e932cf0838a9 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TransformToIqtTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/TransformToIqtTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReductionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReductionTest.py index 1f9f240d66d0082aa0ce530e12a02379e917d673..ffcdb38ac744eeb1efb4de60a85be26ebd7837de 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReductionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReductionTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-public-methods,invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import * from mantid.api import * diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/WANDPowderReductionTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/WANDPowderReductionTest.py index 8ade53fe51cfb3c455fa124ff0a09e1662437756..50adc5288334de288b8db3bf4ba0731496abddbe 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/WANDPowderReductionTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/WANDPowderReductionTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function from mantid.simpleapi import (WANDPowderReduction, CreateSampleWorkspace, RotateInstrumentComponent, MoveInstrumentComponent, CloneWorkspace, AddSampleLog) diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSBeamCentreFinderTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSBeamCentreFinderTest.py index faa755c4ec0ba75156c63be70c9f61e03548dd2a..d57d5e4fc18f56da426d29dc92389a7c85f7d442 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSBeamCentreFinderTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSBeamCentreFinderTest.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from plugins.algorithms.WorkflowAlgorithms.SANS.SANSBeamCentreFinder import SANSBeamCentreFinder, _ResidualsDetails diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToWavelengthAndRebinTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToWavelengthAndRebinTest.py index 735aa2ec17bac347b719b77e2588cb45964f9912..9be374252a0a36d8d2db5d2760cc8e6f77a30b1e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToWavelengthAndRebinTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToWavelengthAndRebinTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.api import FrameworkManager diff --git a/Framework/PythonInterface/test/python/plugins/functions/AFM_LFTest.py b/Framework/PythonInterface/test/python/plugins/functions/AFM_LFTest.py index 89ffdd5f068783d5b38f8ef2b14d548f30e3f96c..98d5cdbf1f6fec3d7459335d320e86067eeda86e 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/AFM_LFTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/AFM_LFTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/AFM_ZFTest.py b/Framework/PythonInterface/test/python/plugins/functions/AFM_ZFTest.py index 94077cd13c1711db69d828c0dcdca0e8ff71c896..f7e658c41c578d344fa2016f3c676b87efc30ee4 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/AFM_ZFTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/AFM_ZFTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py b/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py index bf5784336d5b461943454c983f0af39e70aac4c5..470690b168fd24fa99185af61228f093f63e77df 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * from mantid.api import * @@ -13,6 +11,7 @@ from mantid.simpleapi import Fit import testhelpers import numpy + class AttributeExample(IFunction1D): def init(self): @@ -39,6 +38,7 @@ class AttributeExample(IFunction1D): FunctionFactory.subscribe(AttributeExample) + class AttributeTest(unittest.TestCase): def test_setAttributeValue_called_on_declaration(self): diff --git a/Framework/PythonInterface/test/python/plugins/functions/BesselTest.py b/Framework/PythonInterface/test/python/plugins/functions/BesselTest.py index 27de45812ee827c086c65bfb8b40c09739f93452..48e0b13b2a4aea840f2c4de409bdf11f869f3ccc 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/BesselTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/BesselTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/ChudleyElliotTest.py b/Framework/PythonInterface/test/python/plugins/functions/ChudleyElliotTest.py index 14e4835f19d9c7547e2141dc69b27f7045490c1d..db95a1b47c69417bec39d6d5b733e3a8eef6611c 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/ChudleyElliotTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/ChudleyElliotTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/CombGaussLorentzKTTest.py b/Framework/PythonInterface/test/python/plugins/functions/CombGaussLorentzKTTest.py index b1671db7a0d1b0aafabfb32c5745dde2abe38697..6ff0372f7c840948941306506d14d5ad10affa98 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/CombGaussLorentzKTTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/CombGaussLorentzKTTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/CompositePCRmagnetTest.py b/Framework/PythonInterface/test/python/plugins/functions/CompositePCRmagnetTest.py index ea61f944e5f175186e4ca58618d0a0dea907467a..c237bf4161a14435e0d1b4f4021b883b642317b3 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/CompositePCRmagnetTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/CompositePCRmagnetTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/DSFinterp1DFitTest.py b/Framework/PythonInterface/test/python/plugins/functions/DSFinterp1DFitTest.py index d23bb7cbd33b81e6c24c57da41195f62def1e21d..4dba5fb1fb6f8a903330aa52d15f1bb39cd65152 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/DSFinterp1DFitTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/DSFinterp1DFitTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy @@ -14,6 +12,7 @@ from mantid.simpleapi import CreateWorkspace, Fit, mtd, SaveNexus from mantid.api import AnalysisDataService import sys + class DSFinterp1DTestTest(unittest.TestCase): def generateWorkspaces(self, nf, startf, df, e=False, seed=10): diff --git a/Framework/PythonInterface/test/python/plugins/functions/DampedBesselTest.py b/Framework/PythonInterface/test/python/plugins/functions/DampedBesselTest.py index 8535ecfa86a9e1ba3009f088e0a80f87d023dc2e..4cda05c2b260eef354a594daa4bd6dc75c595589 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/DampedBesselTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/DampedBesselTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/EISFDiffCylinderTest.py b/Framework/PythonInterface/test/python/plugins/functions/EISFDiffCylinderTest.py index b6929e36e5daa795d267ffa236f54c8f98f6036a..152ba9d4d1cfdcefb25ebb7b86c5dee120331bb1 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/EISFDiffCylinderTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/EISFDiffCylinderTest.py @@ -4,12 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np -from six.moves import zip - from MsdTestHelper import (is_registered, check_output, do_a_fit) diff --git a/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereAlkylTest.py b/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereAlkylTest.py index 262de3c569c8cfdd533b3a68286d3f724373f433..194c4acb8b73c0577ebb9aee822a2744054a3e8a 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereAlkylTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereAlkylTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereTest.py b/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereTest.py index 03986189c426297e8e819a69d4d141e57d7fc941..1b196f520ac07d1d6671196e3a486f6f93176d53 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/EISFDiffSphereTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/Example1DFunctionTest.py b/Framework/PythonInterface/test/python/plugins/functions/Example1DFunctionTest.py index 14a7748598ed17590df3d30aaad7c74e15e682ba..b132abd3da9c49389fd14fd2bf20d4d8b103917f 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/Example1DFunctionTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/Example1DFunctionTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * from mantid.api import * from mantid.simpleapi import Fit import testhelpers + class _InternalMakeLinear(PythonAlgorithm): def PyInit(self): @@ -45,6 +44,7 @@ class _InternalMakeLinear(PythonAlgorithm): self.setProperty("OutputWorkspace", wspace) # Stores the workspace as the given name + class Example1DFunctionTest(unittest.TestCase): def test_function_has_been_registered(self): diff --git a/Framework/PythonInterface/test/python/plugins/functions/ExamplePeakFunctionTest.py b/Framework/PythonInterface/test/python/plugins/functions/ExamplePeakFunctionTest.py index 65e1eb08faaaebd366bf7c0d9b8d2e990540c11e..07e09153278e16e4c63d9aeaeba5780d010009e3 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/ExamplePeakFunctionTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/ExamplePeakFunctionTest.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import * from mantid.api import * from mantid.simpleapi import Fit import testhelpers + class _InternalMakeGaussian(PythonAlgorithm): def PyInit(self): @@ -45,6 +44,7 @@ class _InternalMakeGaussian(PythonAlgorithm): self.setProperty("OutputWorkspace", wspace) # Stores the workspace as the given name + class ExamplePeakFunctionTest(unittest.TestCase): def test_function_has_been_registered(self): diff --git a/Framework/PythonInterface/test/python/plugins/functions/FmuFTest.py b/Framework/PythonInterface/test/python/plugins/functions/FmuFTest.py index 719205a4d91c7853d0c5bbca3ae332a68a1f8566..08e4e7eb4b18677ed954dd1e15dbef22bf447f50 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/FmuFTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/FmuFTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/GauBroadGauKTTest.py b/Framework/PythonInterface/test/python/plugins/functions/GauBroadGauKTTest.py index 85e4daf4e2f9d4a58f2390a1cabf42edc2055a5b..73b6105d63632ddcc3e4c8df2975032370ee4009 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/GauBroadGauKTTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/GauBroadGauKTTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/GaussBesselTest.py b/Framework/PythonInterface/test/python/plugins/functions/GaussBesselTest.py index ec53472438f802640b5906f3082f9e648cd2e8c8..0bf121b6499c3779eafc7c9f19d619b44346dfe1 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/GaussBesselTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/GaussBesselTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/HighTFMuoniumTest.py b/Framework/PythonInterface/test/python/plugins/functions/HighTFMuoniumTest.py index 820d22a23f797dffd6a1cfa285f71d5acf39b17d..0991cb3f98e7982839885d577950d6c444792059 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/HighTFMuoniumTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/HighTFMuoniumTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/LowTFMuoniumTest.py b/Framework/PythonInterface/test/python/plugins/functions/LowTFMuoniumTest.py index 5605e9b2f151da24e0963d12155dab14e6f241ab..8ca806cdb45be03d486c3b5cea729faeb5b6c913 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/LowTFMuoniumTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/LowTFMuoniumTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/MeierTest.py b/Framework/PythonInterface/test/python/plugins/functions/MeierTest.py index 2cb2b8785a9fca19f16832ebc8e92d27d126520a..d62ceb69f5c084d18d0a2134a4855e203803123c 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/MeierTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/MeierTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/ModOscTest.py b/Framework/PythonInterface/test/python/plugins/functions/ModOscTest.py index 0d54f46e08bb03b30723bb71e7d265cb3ab22661..d5df125c5c1512d5d2e547785feda06a18a5657b 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/ModOscTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/ModOscTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/MsdGaussTest.py b/Framework/PythonInterface/test/python/plugins/functions/MsdGaussTest.py index f8da7ed228a19213d5317856576483c4ba714607..d43c279c333cb8ac78baf1de8386191c48f93cc9 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/MsdGaussTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/MsdGaussTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/MsdPetersTest.py b/Framework/PythonInterface/test/python/plugins/functions/MsdPetersTest.py index 8115e580174eb3236d57f0de7659386278bfd632..1b13a9705b49792dbbde0ef6d2844ef96d9faab4 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/MsdPetersTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/MsdPetersTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/MsdYiTest.py b/Framework/PythonInterface/test/python/plugins/functions/MsdYiTest.py index 1df748c01b15a6a06de40333d2b6fe43b012c616..450bca6f3240b4c5300ede2eddc85e30d8ed8097 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/MsdYiTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/MsdYiTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/MuHTest.py b/Framework/PythonInterface/test/python/plugins/functions/MuHTest.py index 8af4bf30017ffd7daf337aeecfec0c9452a6d6fa..6cbc40dd7fa03c5b516108828cfb45aa8537291b 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/MuHTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/MuHTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/MuMinusExpTFTest.py b/Framework/PythonInterface/test/python/plugins/functions/MuMinusExpTFTest.py index fa6f95ad6e05849b9e48771568db6c5e970317b8..5cb47329e9ed9c7d571b65d08ac3979254896f6b 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/MuMinusExpTFTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/MuMinusExpTFTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetRedfieldTest.py b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetRedfieldTest.py index 458842e126040f89b58cd48e51458d157f76f571..5060ff0a066a451762dd88c64e7e69510bb88c8e 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetRedfieldTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetRedfieldTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetTest.py b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetTest.py index 4e8eea6d347e035b7672b4df84f8ed6c340369aa..7b1522c647da673fa4bfa8ecf5fa6237c7a30f2f 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetZFKTTest.py b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetZFKTTest.py index b925f5fa25cb19dc1abf1682c2856ad9493ccfeb..cb67f49eaa8d0356488edffcd136221d0cbeea53 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetZFKTTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetZFKTTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetfnormTest.py b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetfnormTest.py index 91a9f620cb7a81daa79311d0e192eddb770bb853..b826758d3767ceeab034beabcb15233198f3b613 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetfnormTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/PCRmagnetfnormTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/PrimStretchedExpFTTest.py b/Framework/PythonInterface/test/python/plugins/functions/PrimStretchedExpFTTest.py index 01bcd3335f4fbc5c294c54dd9890edd773b33785..2b77243966eddece330b11dd01c7cfcc58841c48 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/PrimStretchedExpFTTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/PrimStretchedExpFTTest.py @@ -4,11 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from StretchedExpFTTestHelper import isregistered, do_fit + class PrimStretchedExpFTTest(unittest.TestCase): def testRegistered(self): diff --git a/Framework/PythonInterface/test/python/plugins/functions/RFresonanceTest.py b/Framework/PythonInterface/test/python/plugins/functions/RFresonanceTest.py index eaf5f700e7d9b8bfdb5834f7f47a54d78d31d4ce..84af981f7ea1f7f506127f9df59283de8d971fb8 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/RFresonanceTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/RFresonanceTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/RedfieldTest.py b/Framework/PythonInterface/test/python/plugins/functions/RedfieldTest.py index 52bc64a9ccbd9772d039d55f6b97e28e2f31e1ac..bd62d69edc7d0e8267ae293a2f3f8db32934385e 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/RedfieldTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/RedfieldTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/SpinGlassTest.py b/Framework/PythonInterface/test/python/plugins/functions/SpinGlassTest.py index 7b771e4c5cce3d097fc09d496224dc9149014dd4..fff1f524acc26d51e5762afdcfbb8b8618876a20 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/SpinGlassTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/SpinGlassTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/StandardSCTest.py b/Framework/PythonInterface/test/python/plugins/functions/StandardSCTest.py index 537ee0f870478ad2f67b779ab5a7a010f2757a53..580ab7395f853c2c2c8a556574092b2dd9b36a31 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/StandardSCTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/StandardSCTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/StaticLorentzianKTTest.py b/Framework/PythonInterface/test/python/plugins/functions/StaticLorentzianKTTest.py index d996f040ac99edf341af0e78d60523d31f79f8e3..f134da94febc121961c45d0e0b0f5bc3a24ccc6f 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/StaticLorentzianKTTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/StaticLorentzianKTTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTest.py b/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTest.py index b3e5c68766644596e3e0efb48afa1c1685d75bef..1b507010c98d1c7654c437fbee1672f439f6807f 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTest.py @@ -4,11 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from StretchedExpFTTestHelper import isregistered, do_fit + class StretchedExpFTTest(unittest.TestCase): def testRegistered(self): @@ -43,4 +43,3 @@ class StretchedExpFTTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTestHelper.py b/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTestHelper.py index 991c49ece8a3b10b3435fd038c72b4a113a592e4..dcfe97a4ed35482aab5b29b98b3be2f628dc1015 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTestHelper.py +++ b/Framework/PythonInterface/test/python/plugins/functions/StretchedExpFTTestHelper.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np from scipy import constants diff --git a/Framework/PythonInterface/test/python/plugins/functions/StretchedKTTest.py b/Framework/PythonInterface/test/python/plugins/functions/StretchedKTTest.py index 5cbbb673aa82290cacf71dcd126d4fa295334e6d..ed227f8d6f718756af2830d8af604f265a01599c 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/StretchedKTTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/StretchedKTTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/TFMuoniumTest.py b/Framework/PythonInterface/test/python/plugins/functions/TFMuoniumTest.py index e78ad616f88ef3969c6c91e5cfcd7b3ea70ccbcc..cad50d027636dc35921bcafa0edd28152f3801e1 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/TFMuoniumTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/TFMuoniumTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/TeixeiraWaterTest.py b/Framework/PythonInterface/test/python/plugins/functions/TeixeiraWaterTest.py index a26a3f56c567b1e0c4bc2768d3b2c48a617920f2..ed4fabcc316816977774f646aaaf49a141ebb65b 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/TeixeiraWaterTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/TeixeiraWaterTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/ZFMuoniumTest.py b/Framework/PythonInterface/test/python/plugins/functions/ZFMuoniumTest.py index 74633aeacf70f9864e07013b5e84692fa1fc781f..22e399f6330190dabd390a53e572a8d2850f7da1 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/ZFMuoniumTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/ZFMuoniumTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/ZFdipoleTest.py b/Framework/PythonInterface/test/python/plugins/functions/ZFdipoleTest.py index ffe8d0db6c7eb3a27e85b1e1d474d0ad206dea2f..cd190e70fd2c7a5656a6b1f0a9e7c71a6f2ee6cc 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/ZFdipoleTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/ZFdipoleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/ZFelectronDipoleTest.py b/Framework/PythonInterface/test/python/plugins/functions/ZFelectronDipoleTest.py index f6702b678300c69c362f61fefbc3cbf910289670..783cf238387f7dec295af3dcd35869f3dc3f87fe 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/ZFelectronDipoleTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/ZFelectronDipoleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/python/plugins/functions/ZFprotonDipoleTest.py b/Framework/PythonInterface/test/python/plugins/functions/ZFprotonDipoleTest.py index 6aea67e457bfc8fbdd7dcf7881c796700b9defbc..a53cf428821c9e74c00b5ab5e70de7ba0f02b3bc 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/ZFprotonDipoleTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/ZFprotonDipoleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import numpy as np diff --git a/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelper/__init__.py b/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelper/__init__.py index e263aa0814864f68a91009f8e92fc68210d1d643..6052818231ac71a4c29b2442836185b3f0cb0dd6 100644 --- a/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelper/__init__.py +++ b/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelper/__init__.py @@ -4,6 +4,4 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import - from _WorkspaceCreationHelper import * diff --git a/Framework/PythonInterface/test/testhelpers/__init__.py b/Framework/PythonInterface/test/testhelpers/__init__.py index 395d69af206a21f9a5c01e9d2e36ce5218a1d88f..820dce2e78fd62385033feb37cc37c2df1840391 100644 --- a/Framework/PythonInterface/test/testhelpers/__init__.py +++ b/Framework/PythonInterface/test/testhelpers/__init__.py @@ -7,8 +7,7 @@ """Defines a set of helpers wrapped around the C++ TestHelpers package that are for use in unit tests only! """ -from __future__ import (absolute_import, division, - print_function) + from distutils.version import LooseVersion @@ -19,6 +18,7 @@ import numpy # Define some pure-Python functions to add to the mix + def run_algorithm(name, **kwargs): """Run a named algorithm and return the algorithm handle diff --git a/Framework/PythonInterface/test/testhelpers/algorithm_decorator.py b/Framework/PythonInterface/test/testhelpers/algorithm_decorator.py index 9bb863b56fbef9794da4a632029d71d5e3ba2355..cee854f4e7e61dd3394f8b582515d5027fa104b8 100644 --- a/Framework/PythonInterface/test/testhelpers/algorithm_decorator.py +++ b/Framework/PythonInterface/test/testhelpers/algorithm_decorator.py @@ -4,11 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import inspect import re + def make_decorator(algorithm_to_decorate): """ Dynamically create a builder pattern style decorator around a Mantid algorithm. diff --git a/Framework/PythonInterface/test/testhelpers/illhelpers.py b/Framework/PythonInterface/test/testhelpers/illhelpers.py index 307a5a77d2f52e9d37afa3702e085765a276612e..f545392bd3d9c36c4011386326d506b6d3eadd17 100644 --- a/Framework/PythonInterface/test/testhelpers/illhelpers.py +++ b/Framework/PythonInterface/test/testhelpers/illhelpers.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import mtd from mantid.kernel import DeltaEModeType, UnitConversion import numpy diff --git a/Framework/PythonInterface/test/testhelpers/mlzhelpers.py b/Framework/PythonInterface/test/testhelpers/mlzhelpers.py index 02a9631f73737920d41d9504bc967f9ff08117dc..b53a551dfad4fc31444ec8f2d02631c078db8d48 100644 --- a/Framework/PythonInterface/test/testhelpers/mlzhelpers.py +++ b/Framework/PythonInterface/test/testhelpers/mlzhelpers.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import mantid.simpleapi as api diff --git a/Framework/PythonInterface/test/testhelpers/tempfile_wrapper.py b/Framework/PythonInterface/test/testhelpers/tempfile_wrapper.py index 9d75d8031c35c3b53ef6c672fb9a0962f75297e2..424ea5b1e8fafe3b2b790c0593027268321bf02e 100644 --- a/Framework/PythonInterface/test/testhelpers/tempfile_wrapper.py +++ b/Framework/PythonInterface/test/testhelpers/tempfile_wrapper.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from tempfile import NamedTemporaryFile import os diff --git a/Framework/PythonInterface/test/testhelpers/testrunner.py b/Framework/PythonInterface/test/testhelpers/testrunner.py index 161558f5ea6928a36adf7b16954dceea082fa22a..ea7103a5c01e6f73b51d688badd9edc8cfbc0fca 100644 --- a/Framework/PythonInterface/test/testhelpers/testrunner.py +++ b/Framework/PythonInterface/test/testhelpers/testrunner.py @@ -11,8 +11,6 @@ once qtpy is universally used. It is intended to be used as a launcher script for a given unit test file. The reports are output to the current working directory. """ -from __future__ import (absolute_import, division, print_function) - import imp import os import sys diff --git a/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h b/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h index cd27ba638b825bfda16c4efd09b25b90268205db..118dd2fc36bdc8c21ed36d3b94333a20a8abe63f 100644 --- a/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h +++ b/Framework/RemoteJobManagers/inc/MantidRemoteJobManagers/MantidWebServiceAPIHelper.h @@ -82,13 +82,13 @@ public: private: // Wraps up some of the boilerplate code needed to execute HTTP GET and POST // requests - void initGetRequest(Poco::Net::HTTPRequest &req, std::string extraPath, - std::string queryString) const; + void initGetRequest(Poco::Net::HTTPRequest &req, const std::string &extraPath, + const std::string &queryString) const; void initPostRequest(Poco::Net::HTTPRequest &req, - std::string extraPath) const; + const std::string &extraPath) const; void initHTTPRequest(Poco::Net::HTTPRequest &req, const std::string &method, - std::string extraPath, - std::string queryString = "") const; + const std::string &extraPath, + const std::string &queryString = "") const; std::string m_displayName; std::string diff --git a/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp b/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp index 25308d73222e5331b0f1c947fd20c5d2a44c8a8e..1c45bfde63d45f7c1423886a236ed51585e05919 100644 --- a/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp +++ b/Framework/RemoteJobManagers/src/MantidWebServiceAPIHelper.cpp @@ -19,6 +19,7 @@ #include <ostream> #include <sstream> +#include <utility> namespace Mantid { namespace RemoteJobManagers { @@ -169,22 +170,22 @@ void MantidWebServiceAPIHelper::clearSessionCookies() { g_cookies.clear(); } // Wrappers for a lot of the boilerplate code needed to perform an HTTPS GET or // POST -void MantidWebServiceAPIHelper::initGetRequest(Poco::Net::HTTPRequest &req, - std::string extraPath, - std::string queryString) const { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, extraPath, - queryString); +void MantidWebServiceAPIHelper::initGetRequest( + Poco::Net::HTTPRequest &req, const std::string &extraPath, + const std::string &queryString) const { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_GET, + std::move(extraPath), std::move(queryString)); } -void MantidWebServiceAPIHelper::initPostRequest(Poco::Net::HTTPRequest &req, - std::string extraPath) const { - return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, extraPath); +void MantidWebServiceAPIHelper::initPostRequest( + Poco::Net::HTTPRequest &req, const std::string &extraPath) const { + return initHTTPRequest(req, Poco::Net::HTTPRequest::HTTP_POST, + std::move(extraPath)); } -void MantidWebServiceAPIHelper::initHTTPRequest(Poco::Net::HTTPRequest &req, - const std::string &method, - std::string extraPath, - std::string queryString) const { +void MantidWebServiceAPIHelper::initHTTPRequest( + Poco::Net::HTTPRequest &req, const std::string &method, + const std::string &extraPath, const std::string &queryString) const { // Set up the session object m_session.reset(); diff --git a/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h b/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h index 29a5ffca558c41c034824eb9a3528825a530be92..dfc7952fa123e2d3442d251f84bc63f836805a7e 100644 --- a/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h +++ b/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h @@ -44,13 +44,14 @@ private: /// Execution code void exec() override; - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); - void recurseDim(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::API::IMDHistoWorkspace_sptr outWS, int currentDim, - int *idx, int rank); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); + void recurseDim(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::API::IMDHistoWorkspace_sptr &outWS, + int currentDim, int *idx, int rank); - unsigned int calcIndex(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim); - unsigned int calcInvertedIndex(Mantid::API::IMDHistoWorkspace_sptr ws, + unsigned int calcIndex(const Mantid::API::IMDHistoWorkspace_sptr &ws, + int *dim); + unsigned int calcInvertedIndex(const Mantid::API::IMDHistoWorkspace_sptr &ws, int *dim); }; diff --git a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h index a1085680de8d3e8c10cf7ddbfbca703537c2ba93..297e47d74371c1b88506abb45774c52b78986a4e 100644 --- a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h +++ b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h @@ -64,7 +64,7 @@ private: // A dictionary std::map<std::string, std::string> dictionary; - void loadDictionary(std::string dictionaryFile); + void loadDictionary(const std::string &dictionaryFile); void load2DWorkspace(NeXus::File *fin); @@ -80,10 +80,10 @@ private: std::unordered_set<std::string> populateSpecialMap(); - void addMetaData(NeXus::File *fin, Mantid::API::Workspace_sptr ws, - Mantid::API::ExperimentInfo_sptr info); + void addMetaData(NeXus::File *fin, const Mantid::API::Workspace_sptr &ws, + const Mantid::API::ExperimentInfo_sptr &info); - int safeOpenpath(NeXus::File *fin, std::string path); + int safeOpenpath(NeXus::File *fin, const std::string &path); int calculateCAddress(int *pos, int *dim, int rank); int calculateF77Address(int *pos, int rank); }; diff --git a/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h b/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h index b45e7d312e573de0388d4ee2984d9527ad748a80..b2890b897d05589c0d2df1e427172966b49581ed 100644 --- a/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h +++ b/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h @@ -51,13 +51,13 @@ private: size_t m_rank; size_t m_currentSpectra; - size_t calculateNSpectra(Mantid::API::IMDHistoWorkspace_sptr inws); - void recurseData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::DataObjects::Workspace2D_sptr outWS, + size_t calculateNSpectra(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void recurseData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::DataObjects::Workspace2D_sptr &outWS, size_t currentDim, Mantid::coord_t *pos); - void checkW2D(Mantid::DataObjects::Workspace2D_sptr outWS); + void checkW2D(const Mantid::DataObjects::Workspace2D_sptr &outWS); - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::DataObjects::Workspace2D_sptr outWS); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::DataObjects::Workspace2D_sptr &outWS); }; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h b/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h index fe59f3c42104eedd92d1581a1f5e60a6f3320a53..e4ac09f9774751cd4d5808021694b06d8fd72a14 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h @@ -59,8 +59,8 @@ protected: void exec() override; void logConfigurationInformation( - boost::shared_ptr<PoldiDeadWireDecorator> cleanDetector, - PoldiAbstractChopper_sptr chopper); + const boost::shared_ptr<PoldiDeadWireDecorator> &cleanDetector, + const PoldiAbstractChopper_sptr &chopper); private: /// Overwrites Algorithm method. diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h index 9bc3749470e2cba475049086f8da5b1262b52096..444ff42d500887bad3084f21c478eb521c21e5df 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D.h @@ -43,9 +43,10 @@ protected: API::IFunction_sptr getPeakProfile(const PoldiPeak_sptr &poldiPeak) const; void - setValuesFromProfileFunction(PoldiPeak_sptr poldiPeak, + setValuesFromProfileFunction(const PoldiPeak_sptr &poldiPeak, const API::IFunction_sptr &fittedFunction) const; - double getFwhmWidthRelation(API::IPeakFunction_sptr peakFunction) const; + double + getFwhmWidthRelation(const API::IPeakFunction_sptr &peakFunction) const; API::IAlgorithm_sptr getFitAlgorithm(const DataObjects::Workspace2D_sptr &dataWorkspace, diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h index 895e1d514b7cd1cf0753c1a0e448e29def6de708..65138c4e17f01c7f84aca9fb7cf94428e7e57c81 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h @@ -106,10 +106,11 @@ protected: API::IFunction_sptr getPeakProfile(const PoldiPeak_sptr &poldiPeak) const; void - setValuesFromProfileFunction(PoldiPeak_sptr poldiPeak, + setValuesFromProfileFunction(const PoldiPeak_sptr &poldiPeak, const API::IFunction_sptr &fittedFunction) const; - double getFwhmWidthRelation(API::IPeakFunction_sptr peakFunction) const; + double + getFwhmWidthRelation(const API::IPeakFunction_sptr &peakFunction) const; API::IAlgorithm_sptr getFitAlgorithm(const DataObjects::Workspace2D_sptr &dataWorkspace, diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h index e9394f8cc54e3b40a3a44651e994bdc105a7e133..62d7459d1f00dedabb4bb2b05521b8af5bdb981e 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h @@ -75,7 +75,7 @@ protected: // Conversion between peaks and functions PoldiPeak_sptr - getPeakFromPeakFunction(API::IPeakFunction_sptr profileFunction, + getPeakFromPeakFunction(const API::IPeakFunction_sptr &profileFunction, const Kernel::V3D &hkl); // Conversion between peak collections and functions @@ -83,11 +83,11 @@ protected: getFunctionFromPeakCollection(const PoldiPeakCollection_sptr &peakCollection); Poldi2DFunction_sptr getFunctionIndividualPeaks( - std::string profileFunctionName, + const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection) const; Poldi2DFunction_sptr - getFunctionPawley(std::string profileFunctionName, + getFunctionPawley(const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection); std::string getLatticeSystemFromPointGroup( @@ -131,7 +131,7 @@ protected: API::IFunction_sptr getFunction(const API::IAlgorithm_sptr &fitAlgorithm) const; - void addBackgroundTerms(Poldi2DFunction_sptr poldi2DFunction) const; + void addBackgroundTerms(const Poldi2DFunction_sptr &poldi2DFunction) const; boost::shared_ptr<Kernel::DblMatrix> getLocalCovarianceMatrix( const boost::shared_ptr<const Kernel::DblMatrix> &covarianceMatrix, diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h b/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h index 3c3da954772bc2dacab76882ffbd2fecd51e6513..b308644161e3bd327100ab51ff690c4684a6656b 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h @@ -62,16 +62,17 @@ protected: MantidVec::const_iterator baseDataStart, MantidVec::const_iterator originalDataStart) const; - UncertainValue - getBackgroundWithSigma(std::list<MantidVec::const_iterator> peakPositions, - const MantidVec &correlationCounts) const; - MantidVec getBackground(std::list<MantidVec::const_iterator> peakPositions, - const MantidVec &correlationCounts) const; + UncertainValue getBackgroundWithSigma( + const std::list<MantidVec::const_iterator> &peakPositions, + const MantidVec &correlationCounts) const; + MantidVec + getBackground(const std::list<MantidVec::const_iterator> &peakPositions, + const MantidVec &correlationCounts) const; bool distanceToPeaksGreaterThanMinimum( std::list<MantidVec::const_iterator> peakPositions, MantidVec::const_iterator point) const; size_t getNumberOfBackgroundPoints( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const; double getMedianFromSortedVector(MantidVec::const_iterator begin, @@ -95,8 +96,9 @@ protected: MantidVec::const_iterator peakPosition, const MantidVec &xData) const; - void setErrorsOnWorkspace(DataObjects::Workspace2D_sptr correlationWorkspace, - double error) const; + void setErrorsOnWorkspace( + const DataObjects::Workspace2D_sptr &correlationWorkspace, + double error) const; void setMinimumDistance(int newMinimumDistance); void setMinimumPeakHeight(double newMinimumPeakHeight); @@ -104,7 +106,7 @@ protected: static bool vectorElementGreaterThan(MantidVec::const_iterator first, MantidVec::const_iterator second); - bool isLessThanMinimum(PoldiPeak_sptr peak); + bool isLessThanMinimum(const PoldiPeak_sptr &peak); int m_minimumDistance; int m_doubleMinimumDistance; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h b/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h index f14d9889ead38fb03658d9128a5e1d34e0a1f70f..da2b9ecd3a72aab3141415d2106cc49edbce7359 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiTruncateData.h @@ -42,10 +42,12 @@ public: size_t getActualBinCount(); protected: - void setChopperFromWorkspace(API::MatrixWorkspace_const_sptr workspace); + void + setChopperFromWorkspace(const API::MatrixWorkspace_const_sptr &workspace); void setChopper(PoldiAbstractChopper_sptr chopper); - void setTimeBinWidthFromWorkspace(API::MatrixWorkspace_const_sptr workspace); + void setTimeBinWidthFromWorkspace( + const API::MatrixWorkspace_const_sptr &workspace); void setTimeBinWidth(double timeBinWidth); void setActualBinCount(size_t actualBinCount); @@ -58,16 +60,17 @@ protected: getExtraCountsWorkspace(API::MatrixWorkspace_sptr workspace); API::MatrixWorkspace_sptr - getWorkspaceBelowX(API::MatrixWorkspace_sptr workspace, double x); + getWorkspaceBelowX(const API::MatrixWorkspace_sptr &workspace, double x); API::MatrixWorkspace_sptr - getWorkspaceAboveX(API::MatrixWorkspace_sptr workspace, double x); + getWorkspaceAboveX(const API::MatrixWorkspace_sptr &workspace, double x); API::Algorithm_sptr - getCropAlgorithmForWorkspace(API::MatrixWorkspace_sptr workspace); - API::MatrixWorkspace_sptr getOutputWorkspace(API::Algorithm_sptr algorithm); + getCropAlgorithmForWorkspace(const API::MatrixWorkspace_sptr &workspace); + API::MatrixWorkspace_sptr + getOutputWorkspace(const API::Algorithm_sptr &algorithm); API::MatrixWorkspace_sptr - getSummedSpectra(API::MatrixWorkspace_sptr workspace); + getSummedSpectra(const API::MatrixWorkspace_sptr &workspace); PoldiAbstractChopper_sptr m_chopper; double m_timeBinWidth; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h index ac6673891119074ae990a8354a41e399cdcb7b3a..83f317de25e440e0daeeb7ea89c225d17656a9c9 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h @@ -30,12 +30,14 @@ namespace Poldi { */ class MANTID_SINQ_DLL PoldiDeadWireDecorator : public PoldiDetectorDecorator { public: - PoldiDeadWireDecorator(std::set<int> deadWires, - boost::shared_ptr<PoldiAbstractDetector> detector = - boost::shared_ptr<PoldiAbstractDetector>()); - PoldiDeadWireDecorator(const Geometry::DetectorInfo &poldiDetectorInfo, - boost::shared_ptr<PoldiAbstractDetector> detector = - boost::shared_ptr<PoldiAbstractDetector>()); + PoldiDeadWireDecorator( + std::set<int> deadWires, + const boost::shared_ptr<PoldiAbstractDetector> &detector = + boost::shared_ptr<PoldiAbstractDetector>()); + PoldiDeadWireDecorator( + const Geometry::DetectorInfo &poldiDetectorInfo, + const boost::shared_ptr<PoldiAbstractDetector> &detector = + boost::shared_ptr<PoldiAbstractDetector>()); void setDeadWires(std::set<int> deadWires); std::set<int> deadWires(); diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h index 993afd00cdbad2f08d6eeeefa40c189ff0e9abdd..04d41ccbd40393a7fd0f80557628f6a33291ec61 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeakCollection.h @@ -84,7 +84,7 @@ protected: std::string getUnitCellStringFromLog(const API::LogManager_sptr &tableLog); std::string getStringValueFromLog(const API::LogManager_sptr &logManager, - std::string valueName); + const std::string &valueName); std::string intensityTypeToString(IntensityType type) const; IntensityType intensityTypeFromString(std::string typeString) const; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h index 7b99555b3422b660e42cb5fc4d0815787b01926e..66c3592715d91f916e94108d633e62c998fe54e2 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h @@ -27,19 +27,19 @@ namespace Poldi { class MANTID_SINQ_DLL PoldiSourceSpectrum { public: - PoldiSourceSpectrum(Kernel::Interpolation spectrum); - PoldiSourceSpectrum(Geometry::Instrument_const_sptr poldiInstrument); + PoldiSourceSpectrum(const Kernel::Interpolation &spectrum); + PoldiSourceSpectrum(const Geometry::Instrument_const_sptr &poldiInstrument); double intensity(double wavelength) const; protected: - void - setSpectrumFromInstrument(Geometry::Instrument_const_sptr poldiInstrument); + void setSpectrumFromInstrument( + const Geometry::Instrument_const_sptr &poldiInstrument); Geometry::IComponent_const_sptr - getSourceComponent(Geometry::Instrument_const_sptr poldiInstrument); - Geometry::Parameter_sptr - getSpectrumParameter(Geometry::IComponent_const_sptr source, - Geometry::ParameterMap_sptr instrumentParameterMap); - void setSpectrum(Geometry::Parameter_sptr spectrumParameter); + getSourceComponent(const Geometry::Instrument_const_sptr &poldiInstrument); + Geometry::Parameter_sptr getSpectrumParameter( + const Geometry::IComponent_const_sptr &source, + const Geometry::ParameterMap_sptr &instrumentParameterMap); + void setSpectrum(const Geometry::Parameter_sptr &spectrumParameter); Kernel::Interpolation m_spectrum; }; diff --git a/Framework/SINQ/inc/MantidSINQ/ProjectMD.h b/Framework/SINQ/inc/MantidSINQ/ProjectMD.h index 59cc9aaf6ba02b217c17d5276200463b84e238e3..76bb71579a5e3ca29bf25faceab3094c0445f1e2 100644 --- a/Framework/SINQ/inc/MantidSINQ/ProjectMD.h +++ b/Framework/SINQ/inc/MantidSINQ/ProjectMD.h @@ -43,14 +43,16 @@ private: /// Execution code void exec() override; - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); - void sumData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws, int *sourceDim, + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); + void sumData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws, int *sourceDim, int *targetDim, int targetDimCount, int dimNo, int start, int end, int currentDim); - double getValue(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim); - void putValue(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim, double val); - unsigned int calcIndex(Mantid::API::IMDHistoWorkspace_sptr ws, int *dim); + double getValue(const Mantid::API::IMDHistoWorkspace_sptr &ws, int *dim); + void putValue(const Mantid::API::IMDHistoWorkspace_sptr &ws, int *dim, + double val); + unsigned int calcIndex(const Mantid::API::IMDHistoWorkspace_sptr &ws, + int *dim); }; diff --git a/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h b/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h index f5e8fb77406c68eb2cb897181cf7ded323699aca..1c3fa22862425614163c54f1f78620da73bea308 100644 --- a/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h +++ b/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h @@ -52,11 +52,11 @@ private: int dim[3]; // @SINQ we only do 3D HM's, change when more dimensions std::string hmhost; - std::istream &httpRequest(std::string path); + std::istream &httpRequest(const std::string &path); void loadDimensions(); void doSpecialDim(); - void readHMData(Mantid::API::IMDHistoWorkspace_sptr ws); - void recurseDim(int *data, Mantid::API::IMDHistoWorkspace_sptr ws, + void readHMData(const Mantid::API::IMDHistoWorkspace_sptr &ws); + void recurseDim(int *data, const Mantid::API::IMDHistoWorkspace_sptr &ws, int currentDim, Mantid::coord_t *idx); int calculateCAddress(Mantid::coord_t *pos); diff --git a/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h b/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h index 69c24e6415dc11a0ea2ebacd3f4d6a30822b8e68..0c64ce7aefb3dd3a90a9dc8325f055a6b6ec2acf 100644 --- a/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h +++ b/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h @@ -54,11 +54,11 @@ private: /// Execution code void exec() override; - void doYXZ(Mantid::API::IMDHistoWorkspace_sptr inws); - void doXZY(Mantid::API::IMDHistoWorkspace_sptr inws); - void doTRICS(Mantid::API::IMDHistoWorkspace_sptr inws); - void doAMOR(Mantid::API::IMDHistoWorkspace_sptr inws); + void doYXZ(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void doXZY(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void doTRICS(const Mantid::API::IMDHistoWorkspace_sptr &inws); + void doAMOR(const Mantid::API::IMDHistoWorkspace_sptr &inws); - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); }; diff --git a/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h b/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h index 7d3e390ff64babfcde342497cbb75b83931b1bfb..22a30baf55d69410b323a508d369ddd82b8f677b 100644 --- a/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h +++ b/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h @@ -48,11 +48,11 @@ private: unsigned int m_rank; std::vector<int> m_dim; - void cutData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::API::IMDHistoWorkspace_sptr outWS, + void cutData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::API::IMDHistoWorkspace_sptr &outWS, Mantid::coord_t *sourceDim, Mantid::coord_t *targetDim, std::vector<int> start, std::vector<int> end, unsigned int dim); - void copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws); + void copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws); }; diff --git a/Framework/SINQ/src/InvertMDDim.cpp b/Framework/SINQ/src/InvertMDDim.cpp index 428afdddea0060d24b328ea3f5281bfe54781534..f2d8e13a4bfc153f9deb29c531232d59f7f0fa8b 100644 --- a/Framework/SINQ/src/InvertMDDim.cpp +++ b/Framework/SINQ/src/InvertMDDim.cpp @@ -62,9 +62,9 @@ void InvertMDDim::exec() { setProperty("OutputWorkspace", outWS); } -void InvertMDDim::recurseDim(IMDHistoWorkspace_sptr inWS, - IMDHistoWorkspace_sptr outWS, int currentDim, - int *idx, int rank) { +void InvertMDDim::recurseDim(const IMDHistoWorkspace_sptr &inWS, + const IMDHistoWorkspace_sptr &outWS, + int currentDim, int *idx, int rank) { boost::shared_ptr<const IMDDimension> dimi = inWS->getDimension(currentDim); if (currentDim == rank - 1) { for (int i = 0; i < static_cast<int>(dimi->getNBins()); i++) { @@ -82,8 +82,9 @@ void InvertMDDim::recurseDim(IMDHistoWorkspace_sptr inWS, } } -void InvertMDDim::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void InvertMDDim::copyMetaData( + const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; @@ -97,7 +98,8 @@ void InvertMDDim::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, * IMDHistoWorkspace. * I.e. a proper address calculation from an index array. */ -unsigned int InvertMDDim::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { +unsigned int InvertMDDim::calcIndex(const IMDHistoWorkspace_sptr &ws, + int dim[]) { size_t idx = 0; switch (ws->getNumDims()) { case 2: @@ -115,7 +117,7 @@ unsigned int InvertMDDim::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { return static_cast<unsigned int>(idx); } -unsigned int InvertMDDim::calcInvertedIndex(IMDHistoWorkspace_sptr ws, +unsigned int InvertMDDim::calcInvertedIndex(const IMDHistoWorkspace_sptr &ws, int dim[]) { size_t idx = 0; switch (ws->getNumDims()) { diff --git a/Framework/SINQ/src/LoadFlexiNexus.cpp b/Framework/SINQ/src/LoadFlexiNexus.cpp index 50b92f5544d3a45f9d1bcd6f5cda819d90e77baa..48156e4a8e12f2e367f87d5738920be9bbe28325 100644 --- a/Framework/SINQ/src/LoadFlexiNexus.cpp +++ b/Framework/SINQ/src/LoadFlexiNexus.cpp @@ -71,7 +71,7 @@ void LoadFlexiNexus::exec() { readData(&fin); } -void LoadFlexiNexus::loadDictionary(std::string dictFile) { +void LoadFlexiNexus::loadDictionary(const std::string &dictFile) { std::ifstream in(dictFile.c_str(), std::ifstream::in); std::string line, key, value; @@ -312,8 +312,8 @@ MDHistoDimension_sptr LoadFlexiNexus::makeDimension(NeXus::File *fin, int index, return MDHistoDimension_sptr( new MDHistoDimension(name, name, frame, min, max, length)); } -void LoadFlexiNexus::addMetaData(NeXus::File *fin, Workspace_sptr ws, - ExperimentInfo_sptr info) { +void LoadFlexiNexus::addMetaData(NeXus::File *fin, const Workspace_sptr &ws, + const ExperimentInfo_sptr &info) { std::map<std::string, std::string>::const_iterator it; // assign a title @@ -404,7 +404,7 @@ std::unordered_set<std::string> LoadFlexiNexus::populateSpecialMap() { return specialMap; } -int LoadFlexiNexus::safeOpenpath(NeXus::File *fin, std::string path) { +int LoadFlexiNexus::safeOpenpath(NeXus::File *fin, const std::string &path) { try { fin->openPath(path); } catch (NeXus::Exception &) { diff --git a/Framework/SINQ/src/MDHistoToWorkspace2D.cpp b/Framework/SINQ/src/MDHistoToWorkspace2D.cpp index db9f959ae21ed2c153f14930f3b40a8aa6ce4c00..e6761fdd99e7b63f393c87caefcaddd5209813af 100644 --- a/Framework/SINQ/src/MDHistoToWorkspace2D.cpp +++ b/Framework/SINQ/src/MDHistoToWorkspace2D.cpp @@ -85,7 +85,8 @@ void MDHistoToWorkspace2D::exec() { setProperty("OutputWorkspace", boost::dynamic_pointer_cast<Workspace>(outWS)); } -size_t MDHistoToWorkspace2D::calculateNSpectra(IMDHistoWorkspace_sptr inWS) { +size_t +MDHistoToWorkspace2D::calculateNSpectra(const IMDHistoWorkspace_sptr &inWS) { size_t nSpectra = 1; for (size_t i = 0; i < m_rank - 1; i++) { boost::shared_ptr<const IMDDimension> dim = inWS->getDimension(i); @@ -94,8 +95,8 @@ size_t MDHistoToWorkspace2D::calculateNSpectra(IMDHistoWorkspace_sptr inWS) { return nSpectra; } -void MDHistoToWorkspace2D::recurseData(IMDHistoWorkspace_sptr inWS, - Workspace2D_sptr outWS, +void MDHistoToWorkspace2D::recurseData(const IMDHistoWorkspace_sptr &inWS, + const Workspace2D_sptr &outWS, size_t currentDim, coord_t *pos) { boost::shared_ptr<const IMDDimension> dim = inWS->getDimension(currentDim); if (currentDim == m_rank - 1) { @@ -128,7 +129,7 @@ void MDHistoToWorkspace2D::recurseData(IMDHistoWorkspace_sptr inWS, } void MDHistoToWorkspace2D::checkW2D( - Mantid::DataObjects::Workspace2D_sptr outWS) { + const Mantid::DataObjects::Workspace2D_sptr &outWS) { size_t nSpectra = outWS->getNumberHistograms(); size_t length = outWS->blocksize(); @@ -155,8 +156,8 @@ void MDHistoToWorkspace2D::checkW2D( } void MDHistoToWorkspace2D::copyMetaData( - Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::DataObjects::Workspace2D_sptr outWS) { + const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::DataObjects::Workspace2D_sptr &outWS) { if (inWS->getNumExperimentInfo() > 0) { ExperimentInfo_sptr info = inWS->getExperimentInfo(0); outWS->copyExperimentInfoFrom(info.get()); diff --git a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp index b7ee1476624369e50fdf886f977a8086202eb2d1..f40f8a392dac42b9556986e82cf16e9d613c8764 100644 --- a/Framework/SINQ/src/PoldiAutoCorrelation5.cpp +++ b/Framework/SINQ/src/PoldiAutoCorrelation5.cpp @@ -113,8 +113,8 @@ void PoldiAutoCorrelation5::exec() { } void PoldiAutoCorrelation5::logConfigurationInformation( - boost::shared_ptr<PoldiDeadWireDecorator> cleanDetector, - PoldiAbstractChopper_sptr chopper) { + const boost::shared_ptr<PoldiDeadWireDecorator> &cleanDetector, + const PoldiAbstractChopper_sptr &chopper) { if (cleanDetector && chopper) { g_log.information() << "____________________________________________________ \n"; diff --git a/Framework/SINQ/src/PoldiFitPeaks1D.cpp b/Framework/SINQ/src/PoldiFitPeaks1D.cpp index b44a2547d45898a89fd82baa28015349690a2a77..f0cecc14250bdba3708a53bdad4ed853c306735c 100644 --- a/Framework/SINQ/src/PoldiFitPeaks1D.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks1D.cpp @@ -113,7 +113,8 @@ PoldiFitPeaks1D::getPeakProfile(const PoldiPeak_sptr &poldiPeak) const { } void PoldiFitPeaks1D::setValuesFromProfileFunction( - PoldiPeak_sptr poldiPeak, const IFunction_sptr &fittedFunction) const { + const PoldiPeak_sptr &poldiPeak, + const IFunction_sptr &fittedFunction) const { CompositeFunction_sptr totalFunction = boost::dynamic_pointer_cast<CompositeFunction>(fittedFunction); @@ -134,8 +135,8 @@ void PoldiFitPeaks1D::setValuesFromProfileFunction( } } -double -PoldiFitPeaks1D::getFwhmWidthRelation(IPeakFunction_sptr peakFunction) const { +double PoldiFitPeaks1D::getFwhmWidthRelation( + const IPeakFunction_sptr &peakFunction) const { return peakFunction->fwhm() / peakFunction->getParameter(2); } diff --git a/Framework/SINQ/src/PoldiFitPeaks1D2.cpp b/Framework/SINQ/src/PoldiFitPeaks1D2.cpp index 257516171d67a4e8ad818c0a7170e2489fd19fdc..c6a97a0dc4b502eae13ae9d2bbc7ca659811bf0a 100644 --- a/Framework/SINQ/src/PoldiFitPeaks1D2.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks1D2.cpp @@ -256,7 +256,8 @@ PoldiFitPeaks1D2::getPeakProfile(const PoldiPeak_sptr &poldiPeak) const { } void PoldiFitPeaks1D2::setValuesFromProfileFunction( - PoldiPeak_sptr poldiPeak, const IFunction_sptr &fittedFunction) const { + const PoldiPeak_sptr &poldiPeak, + const IFunction_sptr &fittedFunction) const { IPeakFunction_sptr peakFunction = boost::dynamic_pointer_cast<IPeakFunction>(fittedFunction); @@ -271,8 +272,8 @@ void PoldiFitPeaks1D2::setValuesFromProfileFunction( } } -double -PoldiFitPeaks1D2::getFwhmWidthRelation(IPeakFunction_sptr peakFunction) const { +double PoldiFitPeaks1D2::getFwhmWidthRelation( + const IPeakFunction_sptr &peakFunction) const { return peakFunction->fwhm() / peakFunction->getParameter(2); } diff --git a/Framework/SINQ/src/PoldiFitPeaks2D.cpp b/Framework/SINQ/src/PoldiFitPeaks2D.cpp index adb481bed87cd41ccc024aa3a4d6d4f8eeac0b2f..e9456e9734ba633b341f9539f2499f1b8d8cd22f 100644 --- a/Framework/SINQ/src/PoldiFitPeaks2D.cpp +++ b/Framework/SINQ/src/PoldiFitPeaks2D.cpp @@ -381,9 +381,8 @@ PoldiPeakCollection_sptr PoldiFitPeaks2D::getCountPeakCollection( } /// Creates a PoldiPeak from the given profile function/hkl pair. -PoldiPeak_sptr -PoldiFitPeaks2D::getPeakFromPeakFunction(IPeakFunction_sptr profileFunction, - const V3D &hkl) { +PoldiPeak_sptr PoldiFitPeaks2D::getPeakFromPeakFunction( + const IPeakFunction_sptr &profileFunction, const V3D &hkl) { // Use EstimatePeakErrors to calculate errors of FWHM and so on IAlgorithm_sptr errorAlg = createChildAlgorithm("EstimatePeakErrors"); @@ -466,7 +465,7 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionFromPeakCollection( * @return :: A Poldi2DFunction with peak profile functions. */ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionIndividualPeaks( - std::string profileFunctionName, + const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection) const { auto mdFunction = boost::make_shared<Poldi2DFunction>(); @@ -519,7 +518,7 @@ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionIndividualPeaks( * @return :: A Poldi2DFunction with a PawleyFunction. */ Poldi2DFunction_sptr PoldiFitPeaks2D::getFunctionPawley( - std::string profileFunctionName, + const std::string &profileFunctionName, const PoldiPeakCollection_sptr &peakCollection) { auto mdFunction = boost::make_shared<Poldi2DFunction>(); @@ -1048,7 +1047,7 @@ PoldiFitPeaks2D::getFunction(const IAlgorithm_sptr &fitAlgorithm) const { * @param poldi2DFunction :: Poldi2DFunction to which the background is added. */ void PoldiFitPeaks2D::addBackgroundTerms( - Poldi2DFunction_sptr poldi2DFunction) const { + const Poldi2DFunction_sptr &poldi2DFunction) const { bool addConstantBackground = getProperty("FitConstantBackground"); if (addConstantBackground) { IFunction_sptr constantBackground = diff --git a/Framework/SINQ/src/PoldiPeakSearch.cpp b/Framework/SINQ/src/PoldiPeakSearch.cpp index 930825f230d07d88259ef490b1eca878ddd19441..6c4dc2453266eda129f6a7bb313db2c27664f847 100644 --- a/Framework/SINQ/src/PoldiPeakSearch.cpp +++ b/Framework/SINQ/src/PoldiPeakSearch.cpp @@ -22,6 +22,7 @@ #include <list> #include <numeric> #include <queue> +#include <utility> #include "boost/math/distributions.hpp" @@ -314,7 +315,7 @@ PoldiPeakSearch::getFWHMEstimate(const MantidVec::const_iterator &baseListStart, * @param error :: Error that is set on the workspace. */ void PoldiPeakSearch::setErrorsOnWorkspace( - Workspace2D_sptr correlationWorkspace, double error) const { + const Workspace2D_sptr &correlationWorkspace, double error) const { MantidVec &errors = correlationWorkspace->dataE(0); std::fill(errors.begin(), errors.end(), error); @@ -332,7 +333,7 @@ void PoldiPeakSearch::setErrorsOnWorkspace( * @return Vector only with counts that belong to the background. */ MantidVec PoldiPeakSearch::getBackground( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const { size_t backgroundPoints = getNumberOfBackgroundPoints(peakPositions, correlationCounts); @@ -366,9 +367,10 @@ MantidVec PoldiPeakSearch::getBackground( * @return Background estimation with error. */ UncertainValue PoldiPeakSearch::getBackgroundWithSigma( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const { - MantidVec background = getBackground(peakPositions, correlationCounts); + MantidVec background = + getBackground(std::move(peakPositions), correlationCounts); /* Instead of using Mean and Standard deviation, which are appropriate * for data originating from a normal distribution (which is not the case @@ -420,7 +422,7 @@ bool PoldiPeakSearch::distanceToPeaksGreaterThanMinimum( * @return Number of background points. */ size_t PoldiPeakSearch::getNumberOfBackgroundPoints( - std::list<MantidVec::const_iterator> peakPositions, + const std::list<MantidVec::const_iterator> &peakPositions, const MantidVec &correlationCounts) const { /* subtracting 2, to match original algorithm, where * the first and the last point of the spectrum are not @@ -528,7 +530,7 @@ bool PoldiPeakSearch::vectorElementGreaterThan( return *first > *second; } -bool PoldiPeakSearch::isLessThanMinimum(PoldiPeak_sptr peak) { +bool PoldiPeakSearch::isLessThanMinimum(const PoldiPeak_sptr &peak) { return peak->intensity().value() <= m_minimumPeakHeight; } diff --git a/Framework/SINQ/src/PoldiTruncateData.cpp b/Framework/SINQ/src/PoldiTruncateData.cpp index 9f22eb59d5bf863732a8be2a7284b779cdb10c13..e94235204433cbe22533dc07a9bd367c137a8c4b 100644 --- a/Framework/SINQ/src/PoldiTruncateData.cpp +++ b/Framework/SINQ/src/PoldiTruncateData.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiTruncateData.h" +#include <utility> + #include "MantidAPI/MatrixWorkspace.h" +#include "MantidSINQ/PoldiTruncateData.h" #include "MantidSINQ/PoldiUtilities/PoldiInstrumentAdapter.h" namespace Mantid { @@ -44,7 +46,7 @@ const std::string PoldiTruncateData::summary() const { *definition and log. */ void PoldiTruncateData::setChopperFromWorkspace( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { PoldiInstrumentAdapter poldiInstrument(workspace); setChopper(poldiInstrument.chopper()); } @@ -54,7 +56,7 @@ void PoldiTruncateData::setChopperFromWorkspace( * @param chopper :: POLDI chopper compatible with the measurement. */ void PoldiTruncateData::setChopper(PoldiAbstractChopper_sptr chopper) { - m_chopper = chopper; + m_chopper = std::move(chopper); } /** Extracts timing information from the given MatrixWorkspace. @@ -68,7 +70,7 @@ void PoldiTruncateData::setChopper(PoldiAbstractChopper_sptr chopper) { * @param workspace :: Workspace with POLDI data */ void PoldiTruncateData::setTimeBinWidthFromWorkspace( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { if (!workspace || workspace->getNumberHistograms() < 1) { throw std::invalid_argument( "Workspace does not contain any data. Aborting."); @@ -233,7 +235,7 @@ MatrixWorkspace_sptr PoldiTruncateData::getCroppedWorkspace(MatrixWorkspace_sptr workspace) { double maximumXValue = getMaximumTimeValue(getCalculatedBinCount()); - return getWorkspaceBelowX(workspace, maximumXValue); + return getWorkspaceBelowX(std::move(workspace), maximumXValue); } /** Returns a MatrixWorkspace with all extra counts @@ -260,7 +262,7 @@ MatrixWorkspace_sptr PoldiTruncateData::getExtraCountsWorkspace(MatrixWorkspace_sptr workspace) { double minimumXValue = getMinimumExtraTimeValue(getCalculatedBinCount()); MatrixWorkspace_sptr croppedOutput = - getWorkspaceAboveX(workspace, minimumXValue); + getWorkspaceAboveX(std::move(workspace), minimumXValue); return getSummedSpectra(croppedOutput); } @@ -272,9 +274,9 @@ PoldiTruncateData::getExtraCountsWorkspace(MatrixWorkspace_sptr workspace) { * @return MatrixWorkspace cropped to values with x < specified limit. */ MatrixWorkspace_sptr -PoldiTruncateData::getWorkspaceBelowX(MatrixWorkspace_sptr workspace, +PoldiTruncateData::getWorkspaceBelowX(const MatrixWorkspace_sptr &workspace, double x) { - Algorithm_sptr crop = getCropAlgorithmForWorkspace(workspace); + Algorithm_sptr crop = getCropAlgorithmForWorkspace(std::move(workspace)); crop->setProperty("XMax", x); return getOutputWorkspace(crop); @@ -288,9 +290,9 @@ PoldiTruncateData::getWorkspaceBelowX(MatrixWorkspace_sptr workspace, * @return MatrixWorkspace cropped to values with x >= specified limit. */ MatrixWorkspace_sptr -PoldiTruncateData::getWorkspaceAboveX(MatrixWorkspace_sptr workspace, +PoldiTruncateData::getWorkspaceAboveX(const MatrixWorkspace_sptr &workspace, double x) { - Algorithm_sptr crop = getCropAlgorithmForWorkspace(workspace); + Algorithm_sptr crop = getCropAlgorithmForWorkspace(std::move(workspace)); crop->setProperty("Xmin", x); return getOutputWorkspace(crop); @@ -307,7 +309,7 @@ PoldiTruncateData::getWorkspaceAboveX(MatrixWorkspace_sptr workspace, * @return Pointer to crop algorithm. */ Algorithm_sptr PoldiTruncateData::getCropAlgorithmForWorkspace( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { Algorithm_sptr crop = createChildAlgorithm("CropWorkspace"); if (!crop) { @@ -328,7 +330,7 @@ Algorithm_sptr PoldiTruncateData::getCropAlgorithmForWorkspace( * @return MatrixWorkspace stored in algorithm's OutputWorkspace property. */ MatrixWorkspace_sptr -PoldiTruncateData::getOutputWorkspace(Algorithm_sptr algorithm) { +PoldiTruncateData::getOutputWorkspace(const Algorithm_sptr &algorithm) { if (!algorithm || !algorithm->execute()) { throw std::runtime_error("Workspace could not be retrieved successfully."); } @@ -346,7 +348,7 @@ PoldiTruncateData::getOutputWorkspace(Algorithm_sptr algorithm) { * @return MatrixWorkspace with one spectrum which contains all counts. */ MatrixWorkspace_sptr -PoldiTruncateData::getSummedSpectra(MatrixWorkspace_sptr workspace) { +PoldiTruncateData::getSummedSpectra(const MatrixWorkspace_sptr &workspace) { Algorithm_sptr sumSpectra = createChildAlgorithm("SumSpectra"); if (!sumSpectra) { diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp index 976966e6eee064045994f63a78e22dd7d6d56d3e..d1dedab391ce2f57adb33ae2bd8833af46bf7b0d 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiDGrid.cpp @@ -4,8 +4,10 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiUtilities/PoldiDGrid.h" +#include <utility> + #include "MantidSINQ/PoldiUtilities/PoldiConversions.h" +#include "MantidSINQ/PoldiUtilities/PoldiDGrid.h" namespace Mantid { namespace Poldi { @@ -13,18 +15,19 @@ namespace Poldi { PoldiDGrid::PoldiDGrid(boost::shared_ptr<PoldiAbstractDetector> detector, boost::shared_ptr<PoldiAbstractChopper> chopper, double deltaT, std::pair<double, double> wavelengthRange) - : m_detector(detector), m_chopper(chopper), m_deltaT(deltaT), - m_wavelengthRange(wavelengthRange), m_dRangeAsMultiples(), m_deltaD(0.0), - m_dgrid(), m_hasCachedCalculation(false) {} + : m_detector(std::move(detector)), m_chopper(std::move(chopper)), + m_deltaT(deltaT), m_wavelengthRange(wavelengthRange), + m_dRangeAsMultiples(), m_deltaD(0.0), m_dgrid(), + m_hasCachedCalculation(false) {} void PoldiDGrid::setDetector( boost::shared_ptr<PoldiAbstractDetector> newDetector) { - m_detector = newDetector; + m_detector = std::move(newDetector); } void PoldiDGrid::setChopper( boost::shared_ptr<PoldiAbstractChopper> newChopper) { - m_chopper = newChopper; + m_chopper = std::move(newChopper); } void PoldiDGrid::setDeltaT(double newDeltaT) { m_deltaT = newDeltaT; } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp index c8502b5d57a8981ae030edc436ae97d0f41de375..96a497e8d9977324e5734433008ffad608eb2ab4 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiDeadWireDecorator.cpp @@ -8,6 +8,7 @@ #include "MantidGeometry/Instrument/DetectorInfo.h" #include <algorithm> +#include <utility> namespace Mantid { namespace Poldi { @@ -16,15 +17,15 @@ using namespace Geometry; PoldiDeadWireDecorator::PoldiDeadWireDecorator( std::set<int> deadWires, - boost::shared_ptr<Poldi::PoldiAbstractDetector> detector) - : PoldiDetectorDecorator(detector), m_deadWireSet(deadWires), + const boost::shared_ptr<Poldi::PoldiAbstractDetector> &detector) + : PoldiDetectorDecorator(detector), m_deadWireSet(std::move(deadWires)), m_goodElements() { setDecoratedDetector(detector); } PoldiDeadWireDecorator::PoldiDeadWireDecorator( const Geometry::DetectorInfo &poldiDetectorInfo, - boost::shared_ptr<PoldiAbstractDetector> detector) + const boost::shared_ptr<PoldiAbstractDetector> &detector) : PoldiDetectorDecorator(detector), m_deadWireSet(), m_goodElements() { setDecoratedDetector(detector); @@ -42,7 +43,7 @@ PoldiDeadWireDecorator::PoldiDeadWireDecorator( } void PoldiDeadWireDecorator::setDeadWires(std::set<int> deadWires) { - m_deadWireSet = deadWires; + m_deadWireSet = std::move(deadWires); detectorSetHook(); } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp index dabf81181a199c51cba5ce170593441ca4018447..62cf8b06a98fe7befe1dd74fc09f3e761f26ae0b 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiDetectorDecorator.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidSINQ/PoldiUtilities/PoldiDetectorDecorator.h" namespace Mantid { @@ -14,12 +16,12 @@ using namespace Geometry; PoldiDetectorDecorator::PoldiDetectorDecorator( boost::shared_ptr<PoldiAbstractDetector> decoratedDetector) : PoldiAbstractDetector(), m_decoratedDetector() { - setDecoratedDetector(decoratedDetector); + setDecoratedDetector(std::move(decoratedDetector)); } void PoldiDetectorDecorator::setDecoratedDetector( boost::shared_ptr<PoldiAbstractDetector> detector) { - m_decoratedDetector = detector; + m_decoratedDetector = std::move(detector); detectorSetHook(); } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp index da1dc71771324de85c17b2e10937e0553c47c493..8085d49146480f07fe6516eef95ed92b9eec3e05 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp @@ -8,6 +8,7 @@ #include <cmath> #include <stdexcept> +#include <utility> namespace Mantid { namespace Poldi { @@ -18,7 +19,7 @@ PoldiPeak_sptr PoldiPeak::clone() const { const MillerIndices &PoldiPeak::hkl() const { return m_hkl; } -void PoldiPeak::setHKL(MillerIndices hkl) { m_hkl = hkl; } +void PoldiPeak::setHKL(MillerIndices hkl) { m_hkl = std::move(hkl); } UncertainValue PoldiPeak::d() const { return m_d; } @@ -118,14 +119,16 @@ PoldiPeak_sptr PoldiPeak::create(double qValue, double intensity) { } PoldiPeak_sptr PoldiPeak::create(MillerIndices hkl, double dValue) { - return PoldiPeak_sptr(new PoldiPeak( - UncertainValue(dValue), UncertainValue(0.0), UncertainValue(0.0), hkl)); + return PoldiPeak_sptr(new PoldiPeak(UncertainValue(dValue), + UncertainValue(0.0), UncertainValue(0.0), + std::move(hkl))); } PoldiPeak_sptr PoldiPeak::create(MillerIndices hkl, UncertainValue dValue, UncertainValue intensity, UncertainValue fwhmRelative) { - return PoldiPeak_sptr(new PoldiPeak(dValue, intensity, fwhmRelative, hkl)); + return PoldiPeak_sptr( + new PoldiPeak(dValue, intensity, fwhmRelative, std::move(hkl))); } bool PoldiPeak::greaterThan(const PoldiPeak_sptr &first, @@ -144,7 +147,7 @@ bool PoldiPeak::lessThan(const PoldiPeak_sptr &first, PoldiPeak::PoldiPeak(UncertainValue d, UncertainValue intensity, UncertainValue fwhm, MillerIndices hkl) - : m_hkl(hkl), m_intensity(intensity) { + : m_hkl(std::move(hkl)), m_intensity(intensity) { setD(d); setFwhm(fwhm, Relative); } diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp index 8217baa4b0346c1891301a0e69551452b37b0102..6eb5691a00f8039ad0669f70e3e705253a92b37b 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp @@ -4,11 +4,13 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h" +#include <utility> + #include "MantidAPI/LogManager.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidGeometry/Crystal/PointGroupFactory.h" +#include "MantidSINQ/PoldiUtilities/PoldiPeakCollection.h" #include "MantidGeometry/Crystal/ReflectionGenerator.h" @@ -97,7 +99,7 @@ PoldiPeakCollection::IntensityType PoldiPeakCollection::intensityType() const { void PoldiPeakCollection::setProfileFunctionName( std::string newProfileFunction) { - m_profileFunctionName = newProfileFunction; + m_profileFunctionName = std::move(newProfileFunction); } std::string PoldiPeakCollection::getProfileFunctionName() const { @@ -275,7 +277,7 @@ PoldiPeakCollection::getUnitCellStringFromLog(const LogManager_sptr &tableLog) { std::string PoldiPeakCollection::getStringValueFromLog(const LogManager_sptr &logManager, - std::string valueName) { + const std::string &valueName) { if (logManager->hasProperty(valueName)) { return logManager->getPropertyValueAsType<std::string>(valueName); } @@ -297,7 +299,7 @@ std::string PoldiPeakCollection::intensityTypeToString( PoldiPeakCollection::IntensityType PoldiPeakCollection::intensityTypeFromString(std::string typeString) const { - std::string lowerCaseType(typeString); + std::string lowerCaseType(std::move(typeString)); std::transform(lowerCaseType.begin(), lowerCaseType.end(), lowerCaseType.begin(), ::tolower); diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp index 22c3345fe6972124a29d455eea8db8170efa428d..ea2be969a91e0c179a498d901e52ad5680fcb820 100644 --- a/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp +++ b/Framework/SINQ/src/PoldiUtilities/PoldiSourceSpectrum.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h" +#include <utility> + #include "MantidGeometry/Instrument/FitParameter.h" #include "MantidGeometry/Instrument/ParameterMap.h" +#include "MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h" namespace Mantid { namespace Poldi { @@ -14,12 +16,13 @@ namespace Poldi { using namespace Mantid::Kernel; using namespace Mantid::Geometry; -PoldiSourceSpectrum::PoldiSourceSpectrum(Interpolation spectrum) +PoldiSourceSpectrum::PoldiSourceSpectrum(const Interpolation &spectrum) : m_spectrum(spectrum) {} -PoldiSourceSpectrum::PoldiSourceSpectrum(Instrument_const_sptr poldiInstrument) +PoldiSourceSpectrum::PoldiSourceSpectrum( + const Instrument_const_sptr &poldiInstrument) : m_spectrum() { - setSpectrumFromInstrument(poldiInstrument); + setSpectrumFromInstrument(std::move(poldiInstrument)); } /** Returns the interpolated intensity at the given wavelength @@ -43,7 +46,7 @@ double PoldiSourceSpectrum::intensity(double wavelength) const { *spectrum. */ void PoldiSourceSpectrum::setSpectrumFromInstrument( - Instrument_const_sptr poldiInstrument) { + const Instrument_const_sptr &poldiInstrument) { IComponent_const_sptr source = getSourceComponent(poldiInstrument); Parameter_sptr spectrumParameter = @@ -61,8 +64,8 @@ void PoldiSourceSpectrum::setSpectrumFromInstrument( * @param poldiInstrument :: Instrument with valid POLDI definition * @return Shared pointer to source component */ -IComponent_const_sptr -PoldiSourceSpectrum::getSourceComponent(Instrument_const_sptr poldiInstrument) { +IComponent_const_sptr PoldiSourceSpectrum::getSourceComponent( + const Instrument_const_sptr &poldiInstrument) { IComponent_const_sptr source = poldiInstrument->getComponentByName("source"); if (!source) { @@ -86,7 +89,8 @@ PoldiSourceSpectrum::getSourceComponent(Instrument_const_sptr poldiInstrument) { * @return Shared pointer to Parameter that contains the spectrum. */ Parameter_sptr PoldiSourceSpectrum::getSpectrumParameter( - IComponent_const_sptr source, ParameterMap_sptr instrumentParameterMap) { + const IComponent_const_sptr &source, + const ParameterMap_sptr &instrumentParameterMap) { Parameter_sptr spectrumParameter = instrumentParameterMap->getRecursive( &(*source), "WavelengthDistribution", "fitting"); @@ -107,7 +111,7 @@ Parameter_sptr PoldiSourceSpectrum::getSpectrumParameter( * @param spectrumParameter :: Shared pointer to fitting parameter with lookup *table */ -void PoldiSourceSpectrum::setSpectrum(Parameter_sptr spectrumParameter) { +void PoldiSourceSpectrum::setSpectrum(const Parameter_sptr &spectrumParameter) { if (!spectrumParameter) { throw std::runtime_error("Spectrum parameter pointer is null"); } diff --git a/Framework/SINQ/src/ProjectMD.cpp b/Framework/SINQ/src/ProjectMD.cpp index a2ab0ac2741d41bedbf7d3c5c846639f19f5914b..5036dbc5f360eb826742bff53a0320ba9316356f 100644 --- a/Framework/SINQ/src/ProjectMD.cpp +++ b/Framework/SINQ/src/ProjectMD.cpp @@ -89,8 +89,8 @@ void ProjectMD::exec() { // assign the workspace setProperty("OutputWorkspace", outWS); } -void ProjectMD::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void ProjectMD::copyMetaData(const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; @@ -109,7 +109,7 @@ void ProjectMD::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, * The documentation actually suggest F77, the code too? * This isolates this from the storage order concern. */ -unsigned int ProjectMD::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { +unsigned int ProjectMD::calcIndex(const IMDHistoWorkspace_sptr &ws, int dim[]) { size_t idx = 0; switch (ws->getNumDims()) { case 1: @@ -130,7 +130,7 @@ unsigned int ProjectMD::calcIndex(IMDHistoWorkspace_sptr ws, int dim[]) { return static_cast<unsigned int>(idx); } -double ProjectMD::getValue(IMDHistoWorkspace_sptr ws, int dim[]) { +double ProjectMD::getValue(const IMDHistoWorkspace_sptr &ws, int dim[]) { unsigned int idx = calcIndex(ws, dim); double val = ws->signalAt(idx); // double *a = ws->getSignalArray(); @@ -139,7 +139,8 @@ double ProjectMD::getValue(IMDHistoWorkspace_sptr ws, int dim[]) { // " << dim[1] << "," <<dim[2] <<'\n'; return val; } -void ProjectMD::putValue(IMDHistoWorkspace_sptr ws, int dim[], double value) { +void ProjectMD::putValue(const IMDHistoWorkspace_sptr &ws, int dim[], + double value) { unsigned int idx = calcIndex(ws, dim); // std::cout << "Result index " << idx << " value " << value << " dim= " << // dim[0] << ", " << dim[1] <<", " << dim[2] <<'\n'; @@ -147,8 +148,8 @@ void ProjectMD::putValue(IMDHistoWorkspace_sptr ws, int dim[], double value) { ws->setErrorSquaredAt(idx, value); } -void ProjectMD::sumData(IMDHistoWorkspace_sptr inWS, - IMDHistoWorkspace_sptr outWS, int *sourceDim, +void ProjectMD::sumData(const IMDHistoWorkspace_sptr &inWS, + const IMDHistoWorkspace_sptr &outWS, int *sourceDim, int *targetDim, int targetDimCount, int dimNo, int start, int end, int currentDim) { boost::shared_ptr<const IMDDimension> dimi; diff --git a/Framework/SINQ/src/SINQHMListener.cpp b/Framework/SINQ/src/SINQHMListener.cpp index 3e778b43f95bdf8e8969ce02aa32a5e10af63d66..58c876d60584a8f56c506c00d1daad52570aaee8 100644 --- a/Framework/SINQ/src/SINQHMListener.cpp +++ b/Framework/SINQ/src/SINQHMListener.cpp @@ -25,6 +25,7 @@ #include <Poco/StreamCopier.h> #include <boost/algorithm/string/trim.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::DataObjects; @@ -165,7 +166,7 @@ void SINQHMListener::loadDimensions() { doSpecialDim(); } -std::istream &SINQHMListener::httpRequest(std::string path) { +std::istream &SINQHMListener::httpRequest(const std::string &path) { HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1); req.setKeepAlive(true); @@ -208,7 +209,7 @@ int SINQHMListener::calculateCAddress(coord_t *pos) { } return result; } -void SINQHMListener::recurseDim(int *data, IMDHistoWorkspace_sptr ws, +void SINQHMListener::recurseDim(int *data, const IMDHistoWorkspace_sptr &ws, int currentDim, coord_t *idx) { if (currentDim == rank) { int Cindex = calculateCAddress(idx); @@ -226,7 +227,7 @@ void SINQHMListener::recurseDim(int *data, IMDHistoWorkspace_sptr ws, } } -void SINQHMListener::readHMData(IMDHistoWorkspace_sptr ws) { +void SINQHMListener::readHMData(const IMDHistoWorkspace_sptr &ws) { int *data = nullptr, length = 1; coord_t *idx; @@ -256,7 +257,7 @@ void SINQHMListener::readHMData(IMDHistoWorkspace_sptr ws) { * why.... */ idx = reinterpret_cast<coord_t *>(malloc(rank * sizeof(coord_t))); - recurseDim(data, ws, 0, idx); + recurseDim(data, std::move(ws), 0, idx); free(data); free(idx); diff --git a/Framework/SINQ/src/SINQTranspose3D.cpp b/Framework/SINQ/src/SINQTranspose3D.cpp index 856019ec3b333993de83cab654d92ff889b042d0..82a4806b5372b335b0afea06db59aa31b8af763a 100644 --- a/Framework/SINQ/src/SINQTranspose3D.cpp +++ b/Framework/SINQ/src/SINQTranspose3D.cpp @@ -57,7 +57,7 @@ void SINQTranspose3D::exec() { } } -void SINQTranspose3D::doYXZ(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doYXZ(const IMDHistoWorkspace_sptr &inWS) { size_t idxIn, idxOut; boost::shared_ptr<const IMDDimension> x, y, z; @@ -92,7 +92,7 @@ void SINQTranspose3D::doYXZ(IMDHistoWorkspace_sptr inWS) { setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::doXZY(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doXZY(const IMDHistoWorkspace_sptr &inWS) { size_t idxIn, idxOut; unsigned int xdim, ydim, zdim; @@ -130,7 +130,7 @@ void SINQTranspose3D::doXZY(IMDHistoWorkspace_sptr inWS) { // assign the workspace setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::doTRICS(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doTRICS(const IMDHistoWorkspace_sptr &inWS) { size_t idxIn, idxOut; unsigned int xdim, ydim, zdim; @@ -169,7 +169,7 @@ void SINQTranspose3D::doTRICS(IMDHistoWorkspace_sptr inWS) { // assign the workspace setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::doAMOR(IMDHistoWorkspace_sptr inWS) { +void SINQTranspose3D::doAMOR(const IMDHistoWorkspace_sptr &inWS) { double val; unsigned int xdim, ydim, zdim, idx; @@ -208,8 +208,9 @@ void SINQTranspose3D::doAMOR(IMDHistoWorkspace_sptr inWS) { setProperty("OutputWorkspace", outWS); } -void SINQTranspose3D::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void SINQTranspose3D::copyMetaData( + const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; diff --git a/Framework/SINQ/src/SliceMDHisto.cpp b/Framework/SINQ/src/SliceMDHisto.cpp index 7ead2951c05d20146e108e19922a44385e354e9c..b6e57a138aa2ac59ae986cfa52c15d9a89e46028 100644 --- a/Framework/SINQ/src/SliceMDHisto.cpp +++ b/Framework/SINQ/src/SliceMDHisto.cpp @@ -99,8 +99,8 @@ void SliceMDHisto::exec() { setProperty("OutputWorkspace", outWS); } -void SliceMDHisto::cutData(Mantid::API::IMDHistoWorkspace_sptr inWS, - Mantid::API::IMDHistoWorkspace_sptr outWS, +void SliceMDHisto::cutData(const Mantid::API::IMDHistoWorkspace_sptr &inWS, + const Mantid::API::IMDHistoWorkspace_sptr &outWS, Mantid::coord_t *sourceDim, Mantid::coord_t *targetDim, std::vector<int> start, std::vector<int> end, unsigned int dim) { @@ -130,8 +130,9 @@ void SliceMDHisto::cutData(Mantid::API::IMDHistoWorkspace_sptr inWS, } } -void SliceMDHisto::copyMetaData(Mantid::API::IMDHistoWorkspace_sptr inws, - Mantid::API::IMDHistoWorkspace_sptr outws) { +void SliceMDHisto::copyMetaData( + const Mantid::API::IMDHistoWorkspace_sptr &inws, + const Mantid::API::IMDHistoWorkspace_sptr &outws) { outws->setTitle(inws->getTitle()); ExperimentInfo_sptr info; diff --git a/Framework/SINQ/test/PoldiDGridTest.h b/Framework/SINQ/test/PoldiDGridTest.h index faf194afd1e1a47b8532ba3e1c422b85856c1e5b..7acbe6e061a83ac4fcafb0f9ac947465b8926672 100644 --- a/Framework/SINQ/test/PoldiDGridTest.h +++ b/Framework/SINQ/test/PoldiDGridTest.h @@ -14,6 +14,7 @@ #include "MantidSINQ/PoldiUtilities/PoldiMockInstrumentHelpers.h" #include <stdexcept> +#include <utility> using ::testing::Return; using namespace Mantid::Poldi; @@ -28,7 +29,8 @@ class TestablePoldiDGrid : public PoldiDGrid { boost::shared_ptr<PoldiAbstractChopper>(), double deltaT = 0.0, std::pair<double, double> wavelengthRange = std::pair<double, double>()) - : PoldiDGrid(detector, chopper, deltaT, wavelengthRange) {} + : PoldiDGrid(std::move(detector), std::move(chopper), deltaT, + wavelengthRange) {} }; class PoldiDGridTest : public CxxTest::TestSuite { diff --git a/Framework/SINQ/test/PoldiFitPeaks2DTest.h b/Framework/SINQ/test/PoldiFitPeaks2DTest.h index fd40da297dfd4c02ae71ea1a346a77b80313dda7..04b91d797c1a1b94909ed24bf1b69fa0e425407a 100644 --- a/Framework/SINQ/test/PoldiFitPeaks2DTest.h +++ b/Framework/SINQ/test/PoldiFitPeaks2DTest.h @@ -481,8 +481,8 @@ private: PoldiInstrumentAdapter_sptr m_instrument; PoldiTimeTransformer_sptr m_timeTransformer; - void compareIntensities(PoldiPeakCollection_sptr first, - PoldiPeakCollection_sptr second, + void compareIntensities(const PoldiPeakCollection_sptr &first, + const PoldiPeakCollection_sptr &second, double relativePrecision) { for (size_t i = 0; i < first->peakCount(); ++i) { PoldiPeak_sptr peak = first->peak(i); diff --git a/Framework/SINQ/test/PoldiPeakCollectionTest.h b/Framework/SINQ/test/PoldiPeakCollectionTest.h index c59ee2fdc12b28d76954303e479645d8c398e8b6..5dd7d0703cfbc7139d72ea282f9ca83634b7e0ff 100644 --- a/Framework/SINQ/test/PoldiPeakCollectionTest.h +++ b/Framework/SINQ/test/PoldiPeakCollectionTest.h @@ -36,7 +36,7 @@ class TestablePoldiPeakCollection : public PoldiPeakCollection { TestablePoldiPeakCollection() : PoldiPeakCollection() {} - TestablePoldiPeakCollection(TableWorkspace_sptr workspace) + TestablePoldiPeakCollection(const TableWorkspace_sptr &workspace) : PoldiPeakCollection(workspace) {} }; diff --git a/Framework/SINQ/test/PoldiSourceSpectrumTest.h b/Framework/SINQ/test/PoldiSourceSpectrumTest.h index 81084f222b4f8f40e63cbfbadbe2d5a4dc600089..3a2d2185d484d40d1e962f37f2f1c7e6e7b6491e 100644 --- a/Framework/SINQ/test/PoldiSourceSpectrumTest.h +++ b/Framework/SINQ/test/PoldiSourceSpectrumTest.h @@ -12,6 +12,7 @@ #include "MantidSINQ/PoldiUtilities/PoldiSourceSpectrum.h" #include <cxxtest/TestSuite.h> #include <stdexcept> +#include <utility> using namespace Mantid::Poldi; using namespace Mantid::Kernel; @@ -97,10 +98,10 @@ private: friend class PoldiSourceSpectrumTest; public: - TestablePoldiSourceSpectrum(Interpolation spectrum = Interpolation()) + TestablePoldiSourceSpectrum(const Interpolation &spectrum = Interpolation()) : PoldiSourceSpectrum(spectrum) {} TestablePoldiSourceSpectrum(Instrument_const_sptr poldiInstrument) - : PoldiSourceSpectrum(poldiInstrument) {} + : PoldiSourceSpectrum(std::move(poldiInstrument)) {} }; }; diff --git a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h index eccbb0b49642c4e693d71b421cb54ebd0c3b58b7..c6a68c630580f65b3b9b0557221e416839e88b94 100644 --- a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h +++ b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h @@ -15,7 +15,7 @@ namespace Mantid { namespace API { -void writeJsonFile(const std::string &filename, Json::Value json, +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); diff --git a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp index 328ab2b505a5bbd49d8e2bf2365bc7d3f91b8f97..12d7fe2dbf224b8b7bf8a5d16b5a47d1124cfad2 100644 --- a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp +++ b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp @@ -82,7 +82,7 @@ const char *emptyURL = /** Write json object to file */ -void writeJsonFile(const std::string &filename, Json::Value json, +void writeJsonFile(const std::string &filename, const Json::Value &json, const std::string &error) { Poco::FileOutputStream filestream(filename); if (!filestream.good()) { diff --git a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h index 1f5b1b125d1fad9e53892458bff4c5816c8fd0fb..93e45055462b5a4843f71e9d91f5ab0183b0a99b 100644 --- a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h +++ b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h @@ -83,7 +83,8 @@ to simulate changes and new values for the downloading. class ScriptRepositoryImplLocal : public ScriptRepositoryImpl { public: - ScriptRepositoryImplLocal(std::string a = "", std::string b = "") + ScriptRepositoryImplLocal(const std::string &a = "", + const std::string &b = "") : ScriptRepositoryImpl(a, b) { repository_json_content = REPOSITORYJSON; tofconv_readme_content = TOFCONV_README; diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h index 4e3d45ba6f868b8542720edbab1c75e8bf3ce877..97ad18fe1e367904d0f6f23e40ae557bea216927 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/BinaryOperationMDTestHelper.h @@ -16,17 +16,19 @@ namespace BinaryOperationMDTestHelper { /// Run a binary algorithm. DLLExport Mantid::DataObjects::MDHistoWorkspace_sptr -doTest(std::string algoName, std::string lhs, std::string rhs, - std::string outName, bool succeeds = true, std::string otherProp = "", - std::string otherPropValue = ""); +doTest(const std::string &algoName, const std::string &lhs, + const std::string &rhs, const std::string &outName, bool succeeds = true, + const std::string &otherProp = "", + const std::string &otherPropValue = ""); } // namespace BinaryOperationMDTestHelper namespace UnaryOperationMDTestHelper { /// Run a unary algorithm. DLLExport Mantid::DataObjects::MDHistoWorkspace_sptr -doTest(std::string algoName, std::string inName, std::string outName, - bool succeeds = true, std::string otherProp = "", - std::string otherPropValue = ""); +doTest(const std::string &algoName, const std::string &inName, + const std::string &outName, bool succeeds = true, + const std::string &otherProp = "", + const std::string &otherPropValue = ""); } // namespace UnaryOperationMDTestHelper diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h index 66454bb43c389e4111a17ee585ef60c4defbf181..362683a46b8b18c4bd55446f3d1e8cd0bad5a637 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/ComponentCreationHelper.h @@ -200,7 +200,7 @@ Mantid::Geometry::Instrument_sptr createTestInstrumentCylindrical( void addRectangularBank(Mantid::Geometry::Instrument &testInstrument, int idStart, int pixels, double pixelSpacing, - std::string bankName, + const std::string &bankName, const Mantid::Kernel::V3D &bankPos, const Mantid::Kernel::Quat &bankRot); diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h index 46730b0efe900fdc22abdca6fbeb32c818a95fd7..11a86d24311a2f39c7bf22a0c90f66c64d12f841 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/DataProcessorTestHelper.h @@ -25,15 +25,15 @@ namespace DataProcessorTestHelper { // Add a property value from a list to the given row data with an optional // prefix -DLLExport void -addPropertyValue(MantidQt::MantidWidgets::DataProcessor::RowData_sptr rowData, - const std::vector<std::string> &list, const size_t index, - const std::string &property, const std::string &prefix = ""); +DLLExport void addPropertyValue( + const MantidQt::MantidWidgets::DataProcessor::RowData_sptr &rowData, + const std::vector<std::string> &list, const size_t index, + const std::string &property, const std::string &prefix = ""); // Add a property value to the given row data -DLLExport void -addPropertyValue(MantidQt::MantidWidgets::DataProcessor::RowData_sptr rowData, - const std::string &property, const std::string &value); +DLLExport void addPropertyValue( + const MantidQt::MantidWidgets::DataProcessor::RowData_sptr &rowData, + const std::string &property, const std::string &value); // Utility to create a row data class from a string list of simple inputs DLLExport MantidQt::MantidWidgets::DataProcessor::RowData_sptr diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h index 9803484a3c47723e5390af4f0f230c85f627c8a1..1b4d7ad274bfdd780b35f3bf4c0ebed7508f94c9 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h @@ -728,8 +728,9 @@ public: throw std::runtime_error("Not Implemented"); } - MDHistoWorkspaceTester(MDHistoDimension_sptr dimX, MDHistoDimension_sptr dimY, - MDHistoDimension_sptr dimZ) { + MDHistoWorkspaceTester(const MDHistoDimension_sptr &dimX, + const MDHistoDimension_sptr &dimY, + const MDHistoDimension_sptr &dimZ) { std::vector<IMDDimension_sptr> dimensions{dimX, dimY, dimZ}; initGeometry(dimensions); } diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h index a67c9c86d761e03630f6fdd9a64a22f0793f8952..bbeab78161e64ea1af49996b81e75626bcb38acb 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h @@ -38,8 +38,8 @@ createOutputWorkspace(size_t splitInto) { template <typename MDE, size_t nd> void addMDDimensions( boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out, - Mantid::coord_t min, Mantid::coord_t max, std::string axisNameFormat, - std::string axisIdFormat) { + Mantid::coord_t min, Mantid::coord_t max, const std::string &axisNameFormat, + const std::string &axisIdFormat) { // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( @@ -64,8 +64,8 @@ template <typename MDE, size_t nd> void addMDDimensionsWithFrames( boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out, Mantid::coord_t min, Mantid::coord_t max, - const Mantid::Geometry::MDFrame &frame, std::string axisNameFormat, - std::string axisIdFormat) { + const Mantid::Geometry::MDFrame &frame, const std::string &axisNameFormat, + const std::string &axisIdFormat) { for (size_t d = 0; d < nd; d++) { char name[200]; sprintf(name, axisNameFormat.c_str(), d); @@ -85,7 +85,7 @@ void addMDDimensionsWithIndividualFrames( boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out, Mantid::coord_t min, Mantid::coord_t max, const std::vector<Mantid::Geometry::MDFrame_sptr> &frame, - std::string axisNameFormat, std::string axisIdFormat) { + const std::string &axisNameFormat, const std::string &axisIdFormat) { for (size_t d = 0; d < nd; d++) { char name[200]; sprintf(name, axisNameFormat.c_str(), d); @@ -172,17 +172,17 @@ makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins = 10, Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( double signal, size_t numDims, const Mantid::Geometry::MDFrame &frame, size_t numBins = 10, coord_t max = 10.0, double errorSquared = 1.0, - std::string name = "", double numEvents = 1.0); + const std::string &name = "", double numEvents = 1.0); /// More general fake n-dimensionsal MDHistoWorkspace Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( size_t numDims, double signal, double errorSquared, size_t *numBins, - coord_t *min, coord_t *max, std::string name = ""); + coord_t *min, coord_t *max, const std::string &name = ""); /// More general fake n-dimensionsal MDHistoWorkspace Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( size_t numDims, double signal, double errorSquared, size_t *numBins, coord_t *min, coord_t *max, std::vector<std::string> names, - std::string name = ""); + const std::string &name = ""); //------------------------------------------------------------------------------------- /** Create a test MDEventWorkspace<nd> . Dimensions are names Axis0, Axis1, etc. @@ -202,7 +202,7 @@ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( template <typename MDE, size_t nd> boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> makeAnyMDEW(size_t splitInto, coord_t min, coord_t max, - size_t numEventsPerBox = 0, std::string wsName = "", + size_t numEventsPerBox = 0, const std::string &wsName = "", std::string axisNameFormat = "Axis%d", std::string axisIdFormat = "Axis%d") { // Create bare workspace @@ -242,7 +242,7 @@ boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> makeAnyMDEWWithIndividualFrames( size_t splitInto, coord_t min, coord_t max, std::vector<Mantid::Geometry::MDFrame_sptr> frames, - size_t numEventsPerBox = 0, std::string wsName = "", + size_t numEventsPerBox = 0, const std::string &wsName = "", std::string axisNameFormat = "Axis%d", std::string axisIdFormat = "Axis%d") { // Create bare workspace @@ -283,7 +283,8 @@ template <typename MDE, size_t nd> boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> makeAnyMDEWWithFrames(size_t splitInto, coord_t min, coord_t max, const Mantid::Geometry::MDFrame &frame, - size_t numEventsPerBox = 0, std::string wsName = "", + size_t numEventsPerBox = 0, + const std::string &wsName = "", std::string axisNameFormat = "Axis%d", std::string axisIdFormat = "Axis%d") { // Create bare workspace @@ -499,7 +500,7 @@ static void extents_match(MDBOX box, size_t dim, double min, double max) { TSM_ASSERT_DELTA(dim, box->getExtents(dim).getMax(), max, 1e-6); } -void checkAndDeleteFile(std::string filename); +void checkAndDeleteFile(const std::string &filename); //===================================================================================== //===================================== TEST METHODS diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h b/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h index 0215002c0680687c274e43491f183b2116b586bf..519febe4c98b3b1be20adb12dda0ead3bb04efc8 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/NexusFileReader.h @@ -121,7 +121,7 @@ public: // read a multidimensional dataset and returns vector containing the data template <typename T> std::vector<T> readDataSetMultidimensional(FullNXPath &pathToGroup, - std::string dataSetName) { + const std::string &dataSetName) { std::vector<T> dataInFile; @@ -299,7 +299,7 @@ public: return false; } - bool hasDataset(const std::string dsetName, const FullNXPath &pathToGroup) { + bool hasDataset(const std::string &dsetName, const FullNXPath &pathToGroup) { H5::Group parentGroup = openfullH5Path(pathToGroup); @@ -373,7 +373,7 @@ public: } bool hasAttributeInDataSet( - const std::string dataSetName, const std::string &attrName, + const std::string &dataSetName, const std::string &attrName, const std::string &attrVal, const FullNXPath &pathToGroup /*where the dataset lives*/) { @@ -387,7 +387,7 @@ public: return attributeValue == attrVal; } - bool hasNXAttributeInDataSet(const std::string dataSetName, + bool hasNXAttributeInDataSet(const std::string &dataSetName, const std::string &attrVal, const FullNXPath &pathToGroup) { H5::Attribute attribute; diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h index 10238c69637e2c639a1cc2e8fe514df01a7112e7..65ca02b5c5c6a78cbf1c7f1d7d84bd4527d2e0b4 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/SANSInstrumentCreationHelper.h @@ -31,14 +31,14 @@ public: * @param workspace: name of the workspace to be created. */ static Mantid::DataObjects::Workspace2D_sptr - createSANSInstrumentWorkspace(std::string workspace); + createSANSInstrumentWorkspace(const std::string &workspace); /** Run the Child Algorithm LoadInstrument (as for LoadRaw) * @param inst_name :: The name written in the Nexus file * @param workspace :: The workspace to insert the instrument into */ static void runLoadInstrument(const std::string &inst_name, - Mantid::DataObjects::Workspace2D_sptr workspace); + const Mantid::DataObjects::Workspace2D_sptr &workspace); /** * Populate spectra mapping to detector IDs @@ -48,6 +48,6 @@ public: * @param nybins: number of bins in Y */ static void - runLoadMappingTable(Mantid::DataObjects::Workspace2D_sptr workspace, + runLoadMappingTable(const Mantid::DataObjects::Workspace2D_sptr &workspace, int nxbins, int nybins); }; diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h index a8abc58fef0ec1027c9db75b8a9ce2fdbdbe6d21..7d1886783063a0b3b48b0c927f80b9d6e6ca00e4 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h @@ -234,7 +234,7 @@ create2DWorkspaceFromFunction(fT yFunc, int nSpec, double x0, double x1, } /// Add random noise to the signalcreate2DWorkspaceWithFullInstrument -void addNoise(Mantid::API::MatrixWorkspace_sptr ws, double noise, +void addNoise(const Mantid::API::MatrixWorkspace_sptr &ws, double noise, const double lower = -0.5, const double upper = 0.5); /// Create a test workspace with a fully defined instrument. @@ -305,7 +305,8 @@ createWorkspaceSingleValue(double value); Mantid::DataObjects::WorkspaceSingleValue_sptr createWorkspaceSingleValueWithError(double value, double error); /** Perform some finalization on event workspace stuff */ -void eventWorkspace_Finalize(Mantid::DataObjects::EventWorkspace_sptr ew); +void eventWorkspace_Finalize( + const Mantid::DataObjects::EventWorkspace_sptr &ew); /** Create event workspace with: * 500 pixels * 1000 histogrammed bins. @@ -348,22 +349,23 @@ Mantid::API::MatrixWorkspace_sptr createGroupedWorkspace2DWithRingsAndBoxes( size_t RootOfNumHist = 10, int numBins = 10, double binDelta = 1.0); // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataY(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayDataY(const Mantid::API::MatrixWorkspace_const_sptr &ws); // not strictly creating a workspace, but really helpful to see what one // contains -void displayData(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayData(const Mantid::API::MatrixWorkspace_const_sptr &ws); // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataX(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayDataX(const Mantid::API::MatrixWorkspace_const_sptr &ws); // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataE(Mantid::API::MatrixWorkspace_const_sptr ws); +void displayDataE(const Mantid::API::MatrixWorkspace_const_sptr &ws); -void addTSPEntry(Mantid::API::Run &runInfo, std::string name, double val); -void setOrientedLattice(Mantid::API::MatrixWorkspace_sptr ws, double a, +void addTSPEntry(Mantid::API::Run &runInfo, const std::string &name, + double val); +void setOrientedLattice(const Mantid::API::MatrixWorkspace_sptr &ws, double a, double b, double c); -void setGoniometer(Mantid::API::MatrixWorkspace_sptr ws, double phi, double chi, - double omega); +void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &ws, double phi, + double chi, double omega); // create workspace which should be result of homering (transform to energy in // inelastic) @@ -378,9 +380,9 @@ Mantid::API::MatrixWorkspace_sptr createProcessedInelasticWS( const std::vector<double> &azimutal, size_t numBins = 4, double Emin = -10, double Emax = 10, double Ei = 11); -Mantid::DataObjects::EventWorkspace_sptr -createEventWorkspace3(Mantid::DataObjects::EventWorkspace_const_sptr sourceWS, - std::string wsname, Mantid::API::Algorithm *alg); +Mantid::DataObjects::EventWorkspace_sptr createEventWorkspace3( + const Mantid::DataObjects::EventWorkspace_const_sptr &sourceWS, + const std::string &wsname, Mantid::API::Algorithm *alg); /// Function to create a fixed RebinnedOutput workspace Mantid::DataObjects::RebinnedOutput_sptr createRebinnedOutputWorkspace(); @@ -403,7 +405,8 @@ createPeaksWorkspace(const int numPeaks, /**Build table workspace with preprocessed detectors for existing workspace with * instrument */ boost::shared_ptr<Mantid::DataObjects::TableWorkspace> -buildPreprocessedDetectorsWorkspace(Mantid::API::MatrixWorkspace_sptr ws); +buildPreprocessedDetectorsWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws); // create range of angular detectors positions void create2DAngles(std::vector<double> &L2, std::vector<double> &polar, std::vector<double> &azim, size_t nPolar = 10, @@ -440,7 +443,7 @@ create2DWorkspaceWithReflectometryInstrumentMultiDetector( const int nSpectra = 4, const int nBins = 20, const double deltaX = 5000.0); void createInstrumentForWorkspaceWithDistances( - Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const Mantid::Kernel::V3D &samplePosition, const Mantid::Kernel::V3D &sourcePosition, const std::vector<Mantid::Kernel::V3D> &detectorPositions); diff --git a/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp b/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp index e835e4e5ccffe15e5a3a96ee1b4aecbc0020224c..bce53656bb83b9d81c3d0be4fd313c1451eb481e 100644 --- a/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp +++ b/Framework/TestHelpers/src/BinaryOperationMDTestHelper.cpp @@ -59,10 +59,11 @@ void setUpBinaryOperationMDTestHelper() { } /// Run a binary algorithm. -MDHistoWorkspace_sptr doTest(std::string algoName, std::string lhs, - std::string rhs, std::string outName, - bool succeeds, std::string otherProp, - std::string otherPropValue) { +MDHistoWorkspace_sptr doTest(const std::string &algoName, + const std::string &lhs, const std::string &rhs, + const std::string &outName, bool succeeds, + const std::string &otherProp, + const std::string &otherPropValue) { setUpBinaryOperationMDTestHelper(); IAlgorithm *alg = FrameworkManager::Instance().createAlgorithm(algoName); @@ -94,10 +95,11 @@ MDHistoWorkspace_sptr doTest(std::string algoName, std::string lhs, namespace UnaryOperationMDTestHelper { -MDHistoWorkspace_sptr doTest(std::string algoName, std::string inName, - std::string outName, bool succeeds, - std::string otherProp, - std::string otherPropValue) { +MDHistoWorkspace_sptr doTest(const std::string &algoName, + const std::string &inName, + const std::string &outName, bool succeeds, + const std::string &otherProp, + const std::string &otherPropValue) { MDHistoWorkspace_sptr histo = MDEventsTestHelper::makeFakeMDHistoWorkspace(2.0, 2, 5, 10.0, 2.0); IMDEventWorkspace_sptr event = diff --git a/Framework/TestHelpers/src/ComponentCreationHelper.cpp b/Framework/TestHelpers/src/ComponentCreationHelper.cpp index c520c9f1b3c746852e6e30f8701b287b70e84039..b40c9378213386232c7a00fa746ee79542f9d7d0 100644 --- a/Framework/TestHelpers/src/ComponentCreationHelper.cpp +++ b/Framework/TestHelpers/src/ComponentCreationHelper.cpp @@ -531,7 +531,7 @@ createCylInstrumentWithDetInGivenPositions(const std::vector<double> &L2, //---------------------------------------------------------------------------------------------- void addRectangularBank(Instrument &testInstrument, int idStart, int pixels, - double pixelSpacing, std::string bankName, + double pixelSpacing, const std::string &bankName, const V3D &bankPos, const Quat &bankRot) { const double cylRadius(pixelSpacing / 2); diff --git a/Framework/TestHelpers/src/DataProcessorTestHelper.cpp b/Framework/TestHelpers/src/DataProcessorTestHelper.cpp index e42ae87e7646ec5bbdfd6ff99fc05f47fc59a578..e8074c49288d743cc76fdc1b6d92b3eb640c6bc3 100644 --- a/Framework/TestHelpers/src/DataProcessorTestHelper.cpp +++ b/Framework/TestHelpers/src/DataProcessorTestHelper.cpp @@ -14,7 +14,7 @@ namespace DataProcessorTestHelper { /* Add a property value from a list to the given row data with an optional * prefix */ -void addPropertyValue(RowData_sptr rowData, +void addPropertyValue(const RowData_sptr &rowData, const std::vector<std::string> &list, const size_t index, const std::string &property, const std::string &prefix) { if (index >= list.size() || list[index].empty()) @@ -28,7 +28,7 @@ void addPropertyValue(RowData_sptr rowData, /* Add a property value to the given row data */ -void addPropertyValue(RowData_sptr rowData, const std::string &property, +void addPropertyValue(const RowData_sptr &rowData, const std::string &property, const std::string &value) { // Set the value and preprocessed value to the given value rowData->setOptionValue(property, value); diff --git a/Framework/TestHelpers/src/MDEventsTestHelper.cpp b/Framework/TestHelpers/src/MDEventsTestHelper.cpp index 1d758e654d1efa5c9af91f120323b0de75ba3161..690db659153f7e9bc38b2a19dc87a491ee38b4fa 100644 --- a/Framework/TestHelpers/src/MDEventsTestHelper.cpp +++ b/Framework/TestHelpers/src/MDEventsTestHelper.cpp @@ -244,10 +244,9 @@ makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins, * @param name :: optional name * @return the MDHisto */ -MDHistoWorkspace_sptr -makeFakeMDHistoWorkspaceGeneral(size_t numDims, double signal, - double errorSquared, size_t *numBins, - coord_t *min, coord_t *max, std::string name) { +MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( + size_t numDims, double signal, double errorSquared, size_t *numBins, + coord_t *min, coord_t *max, const std::string &name) { std::vector<std::string> names{"x", "y", "z", "t"}; // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( @@ -283,7 +282,7 @@ makeFakeMDHistoWorkspaceGeneral(size_t numDims, double signal, MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( size_t numDims, double signal, double errorSquared, size_t *numBins, coord_t *min, coord_t *max, std::vector<std::string> names, - std::string name) { + const std::string &name) { std::vector<Mantid::Geometry::MDHistoDimension_sptr> dimensions; // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( @@ -316,7 +315,7 @@ MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceGeneral( */ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( double signal, size_t numDims, const Mantid::Geometry::MDFrame &frame, - size_t numBins, coord_t max, double errorSquared, std::string name, + size_t numBins, coord_t max, double errorSquared, const std::string &name, double numEvents) { // MDHistoWorkspace *ws = nullptr; MDHistoWorkspace_sptr ws_sptr; @@ -365,7 +364,7 @@ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspaceWithMDFrame( * Delete a file from disk * @param filename : File name to check and delete */ -void checkAndDeleteFile(std::string filename) { +void checkAndDeleteFile(const std::string &filename) { if (!filename.empty()) { if (Poco::File(filename).exists()) { Poco::File(filename).remove(); diff --git a/Framework/TestHelpers/src/ReflectometryHelper.cpp b/Framework/TestHelpers/src/ReflectometryHelper.cpp index 0a03f9137a35d575f4b543868eb71d8be2e26a0a..91e8a5b59795a8544075404b2671c970cc553dee 100644 --- a/Framework/TestHelpers/src/ReflectometryHelper.cpp +++ b/Framework/TestHelpers/src/ReflectometryHelper.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidTestHelpers/ReflectometryHelper.h" #include "MantidAPI/AlgorithmManager.h" @@ -115,7 +117,8 @@ void prepareInputGroup(std::string const &name, std::string const ¶msType, mkGroup->execute(); } -std::vector<MatrixWorkspace_sptr> groupToVector(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( @@ -129,9 +132,9 @@ std::vector<MatrixWorkspace_sptr> retrieveOutWS(std::string const &name) { return groupToVector(group); } -void applyPolarizationEfficiencies(WorkspaceGroup_sptr ws) { +void applyPolarizationEfficiencies(const WorkspaceGroup_sptr &ws) { - auto wss = groupToVector(ws); + auto wss = groupToVector(std::move(ws)); auto Rpp = wss[0]; auto Rpa = wss[1]; auto Rap = wss[2]; diff --git a/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp b/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp index d73a3262928174d8497fc5f770842a6e99ff22e3..a2e26a0b9f948b308f67931d5db7b98c0d3c6f46 100644 --- a/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp +++ b/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp @@ -44,7 +44,7 @@ const int SANSInstrumentCreationHelper::nMonitors = 2; * @param workspace: name of the workspace to be created. */ Workspace2D_sptr SANSInstrumentCreationHelper::createSANSInstrumentWorkspace( - std::string workspace) { + const std::string &workspace) { // Create a test workspace with test data with a well defined peak // The test instrument has two monitor channels Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace123( @@ -67,7 +67,7 @@ Workspace2D_sptr SANSInstrumentCreationHelper::createSANSInstrumentWorkspace( */ void SANSInstrumentCreationHelper::runLoadInstrument( const std::string &inst_name, - Mantid::DataObjects::Workspace2D_sptr workspace) { + const Mantid::DataObjects::Workspace2D_sptr &workspace) { // Determine the search directory for XML instrument definition files (IDFs) // std::string directoryName = // Mantid::Kernel::ConfigService::Instance().getInstrumentDirectory(); @@ -97,7 +97,8 @@ void SANSInstrumentCreationHelper::runLoadInstrument( * @param nybins: number of bins in Y */ void SANSInstrumentCreationHelper::runLoadMappingTable( - Mantid::DataObjects::Workspace2D_sptr workspace, int nxbins, int nybins) { + const Mantid::DataObjects::Workspace2D_sptr &workspace, int nxbins, + int nybins) { // Get the number of monitor channels size_t nMonitors(0); size_t nXbins, nYbins; diff --git a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index 9e491ac2393c303fd0fa23b3f602a466bcb1b3e4..a910ef03d33c26a0c3f5f4d57800e6e8f5928fbf 100644 --- a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -366,7 +366,7 @@ Workspace2D_sptr create2DWorkspaceNonUniformlyBinned(int nhist, * @param lower :: The lower bound of the flucation (default=-0.5) * @param upper:: The upper bound of the flucation (default=-0.5) */ -void addNoise(Mantid::API::MatrixWorkspace_sptr ws, double noise, +void addNoise(const Mantid::API::MatrixWorkspace_sptr &ws, double noise, const double lower, const double upper) { const size_t seed(12345); MersenneTwister randGen(seed, lower, upper); @@ -707,7 +707,7 @@ MatrixWorkspace_sptr create2DWorkspaceWithReflectometryInstrumentMultiDetector( } void createInstrumentForWorkspaceWithDistances( - MatrixWorkspace_sptr workspace, const V3D &samplePosition, + const MatrixWorkspace_sptr &workspace, const V3D &samplePosition, const V3D &sourcePosition, const std::vector<V3D> &detectorPositions) { Instrument_sptr instrument = boost::make_shared<Instrument>(); instrument->setReferenceFrame( @@ -739,7 +739,7 @@ WorkspaceSingleValue_sptr createWorkspaceSingleValueWithError(double value, } /** Perform some finalization on event workspace stuff */ -void eventWorkspace_Finalize(EventWorkspace_sptr ew) { +void eventWorkspace_Finalize(const EventWorkspace_sptr &ew) { // get a proton charge ew->mutableRun().integrateProtonCharge(); } @@ -944,7 +944,7 @@ createGroupedWorkspace2DWithRingsAndBoxes(size_t RootOfNumHist, int numBins, // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataY(MatrixWorkspace_const_sptr ws) { +void displayDataY(const MatrixWorkspace_const_sptr &ws) { const size_t numHists = ws->getNumberHistograms(); for (size_t i = 0; i < numHists; ++i) { std::cout << "Histogram " << i << " = "; @@ -955,11 +955,13 @@ void displayDataY(MatrixWorkspace_const_sptr ws) { std::cout << '\n'; } } -void displayData(MatrixWorkspace_const_sptr ws) { displayDataX(ws); } +void displayData(const MatrixWorkspace_const_sptr &ws) { + displayDataX(std::move(ws)); +} // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataX(MatrixWorkspace_const_sptr ws) { +void displayDataX(const MatrixWorkspace_const_sptr &ws) { const size_t numHists = ws->getNumberHistograms(); for (size_t i = 0; i < numHists; ++i) { std::cout << "Histogram " << i << " = "; @@ -973,7 +975,7 @@ void displayDataX(MatrixWorkspace_const_sptr ws) { // not strictly creating a workspace, but really helpful to see what one // contains -void displayDataE(MatrixWorkspace_const_sptr ws) { +void displayDataE(const MatrixWorkspace_const_sptr &ws) { const size_t numHists = ws->getNumberHistograms(); for (size_t i = 0; i < numHists; ++i) { std::cout << "Histogram " << i << " = "; @@ -992,7 +994,7 @@ void displayDataE(MatrixWorkspace_const_sptr ws) { * @param name :: property name * @param val :: value */ -void addTSPEntry(Run &runInfo, std::string name, double val) { +void addTSPEntry(Run &runInfo, const std::string &name, double val) { TimeSeriesProperty<double> *tsp; tsp = new TimeSeriesProperty<double>(name); tsp->addValue("2011-05-24T00:00:00", val); @@ -1008,7 +1010,7 @@ void addTSPEntry(Run &runInfo, std::string name, double val) { * @param b :: lattice length * @param c :: lattice length */ -void setOrientedLattice(Mantid::API::MatrixWorkspace_sptr ws, double a, +void setOrientedLattice(const Mantid::API::MatrixWorkspace_sptr &ws, double a, double b, double c) { ws->mutableSample().setOrientedLattice( std::make_unique<OrientedLattice>(a, b, c, 90., 90., 90.)); @@ -1022,8 +1024,8 @@ void setOrientedLattice(Mantid::API::MatrixWorkspace_sptr ws, double a, * @param chi :: +X rotation angle (deg) * @param omega :: +Y rotation angle (deg) */ -void setGoniometer(Mantid::API::MatrixWorkspace_sptr ws, double phi, double chi, - double omega) { +void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &ws, double phi, + double chi, double omega) { addTSPEntry(ws->mutableRun(), "phi", phi); addTSPEntry(ws->mutableRun(), "chi", chi); addTSPEntry(ws->mutableRun(), "omega", omega); @@ -1151,9 +1153,9 @@ createProcessedInelasticWS(const std::vector<double> &L2, * The new workspace should be exactly the same as the source workspace but * without any events */ -Mantid::DataObjects::EventWorkspace_sptr -createEventWorkspace3(Mantid::DataObjects::EventWorkspace_const_sptr sourceWS, - std::string wsname, API::Algorithm *alg) { +Mantid::DataObjects::EventWorkspace_sptr createEventWorkspace3( + const Mantid::DataObjects::EventWorkspace_const_sptr &sourceWS, + const std::string &wsname, API::Algorithm *alg) { UNUSED_ARG(wsname); // 1. Initialize:use dummy numbers for arguments, for event workspace it // doesn't matter @@ -1474,7 +1476,8 @@ void processDetectorsPositions(const API::MatrixWorkspace_const_sptr &inputWS, } boost::shared_ptr<Mantid::DataObjects::TableWorkspace> -buildPreprocessedDetectorsWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +buildPreprocessedDetectorsWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws) { Mantid::DataObjects::TableWorkspace_sptr DetPos = createTableWorkspace(ws); auto Ei = ws->run().getPropertyValueAsType<double>("Ei"); processDetectorsPositions(ws, DetPos, Ei); diff --git a/Framework/Types/inc/MantidTypes/Core/DateAndTime.h b/Framework/Types/inc/MantidTypes/Core/DateAndTime.h index da4b659f1d26437b5e474ca368f670382a6d05d3..d0f48450d1cf5da393540848471f6f4999bf819f 100644 --- a/Framework/Types/inc/MantidTypes/Core/DateAndTime.h +++ b/Framework/Types/inc/MantidTypes/Core/DateAndTime.h @@ -45,9 +45,9 @@ public: DateAndTime(const int32_t seconds, const int32_t nanoseconds); DateAndTime(const int64_t seconds, const int64_t nanoseconds); DateAndTime(const std::string &ISO8601_string); - DateAndTime(const boost::posix_time::ptime _ptime); + DateAndTime(const boost::posix_time::ptime &_ptime); - void set_from_ptime(boost::posix_time::ptime _ptime); + void set_from_ptime(const boost::posix_time::ptime &_ptime); boost::posix_time::ptime to_ptime() const; void set_from_time_t(std::time_t _timet); @@ -59,7 +59,7 @@ public: void setFromISO8601(const std::string &str); std::string toSimpleString() const; std::string - toFormattedString(const std::string format = "%Y-%b-%d %H:%M:%S") const; + toFormattedString(const std::string &format = "%Y-%b-%d %H:%M:%S") const; std::string toISO8601String() const; /// Stream output operator @@ -112,7 +112,7 @@ public: static DateAndTime getCurrentTime(); static DateAndTime maximum(); static DateAndTime minimum(); - static double secondsFromDuration(time_duration duration); + static double secondsFromDuration(const time_duration &duration); static time_duration durationFromSeconds(double duration); static int64_t nanosecondsFromDuration(const time_duration &td); static int64_t nanosecondsFromSeconds(double sec); diff --git a/Framework/Types/src/Core/DateAndTime.cpp b/Framework/Types/src/Core/DateAndTime.cpp index d64835cba9e541f7ecfbb61caa22c32d6259f7ed..3b6c1c9884e19dec72d23ca6b96b09802e4a4d3d 100644 --- a/Framework/Types/src/Core/DateAndTime.cpp +++ b/Framework/Types/src/Core/DateAndTime.cpp @@ -133,7 +133,7 @@ DateAndTime::DateAndTime(const std::string &ISO8601_string) : _nanoseconds(0) { /** Construct time from a boost::posix_time::ptime. * @param _ptime :: boost::posix_time::ptime */ -DateAndTime::DateAndTime(const boost::posix_time::ptime _ptime) +DateAndTime::DateAndTime(const boost::posix_time::ptime &_ptime) : _nanoseconds(0) { this->set_from_ptime(_ptime); } @@ -207,7 +207,7 @@ boost::posix_time::ptime DateAndTime::to_ptime() const { * * @param _ptime :: boost::posix_time::ptime date and time. */ -void DateAndTime::set_from_ptime(boost::posix_time::ptime _ptime) { +void DateAndTime::set_from_ptime(const boost::posix_time::ptime &_ptime) { if (_ptime.is_special()) { // --- SPECIAL VALUES! ---- if (_ptime.is_infinity() || _ptime.is_pos_infinity()) @@ -452,7 +452,7 @@ std::string DateAndTime::toSimpleString() const { * @param format : format for strftime(). Default "%Y-%b-%d %H:%M:%S" * @return date as string, formatted as requested */ -std::string DateAndTime::toFormattedString(const std::string format) const { +std::string DateAndTime::toFormattedString(const std::string &format) const { char buffer[25]; std::tm date_as_tm = this->to_tm(); strftime(buffer, 25, format.c_str(), &date_as_tm); @@ -688,7 +688,7 @@ DateAndTime DateAndTime::getCurrentTime() { * Return the number of seconds in a time_duration, as a double, including * fractional seconds. */ -double DateAndTime::secondsFromDuration(time_duration duration) { +double DateAndTime::secondsFromDuration(const time_duration &duration) { #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS // Nanosecond resolution return static_cast<double>(duration.total_nanoseconds()) / 1e9; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h index 8657a78876b6160f110eca68360fb9563e11de58..a82e1e84769e364e8948d896d428ae534ac5f6a2 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h @@ -75,23 +75,22 @@ private: const std::string &groupFilename); API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr matrixws); - API::MatrixWorkspace_sptr conjoinWorkspaces(API::MatrixWorkspace_sptr ws1, - API::MatrixWorkspace_sptr ws2, - size_t offset); + API::MatrixWorkspace_sptr + conjoinWorkspaces(const API::MatrixWorkspace_sptr &ws1, + const API::MatrixWorkspace_sptr &ws2, size_t offset); /// Call diffraction focus to a matrix workspace. API::MatrixWorkspace_sptr diffractionFocus(API::MatrixWorkspace_sptr ws); /// Convert units API::MatrixWorkspace_sptr convertUnits(API::MatrixWorkspace_sptr matrixws, - std::string target); + const std::string &target); /// Call edit instrument geometry - API::MatrixWorkspace_sptr editInstrument(API::MatrixWorkspace_sptr ws, - std::vector<double> polars, - std::vector<specnum_t> specids, - std::vector<double> l2s, - std::vector<double> phis); + API::MatrixWorkspace_sptr editInstrument( + API::MatrixWorkspace_sptr ws, const std::vector<double> &polars, + const std::vector<specnum_t> &specids, const std::vector<double> &l2s, + const std::vector<double> &phis); void convertOffsetsToCal(DataObjects::OffsetsWorkspace_sptr &offsetsWS); double getVecPropertyFromPmOrSelf(const std::string &name, std::vector<double> &avec); @@ -123,7 +122,7 @@ private: double tmin{0.0}; double tmax{0.0}; bool m_preserveEvents{false}; - void doSortEvents(Mantid::API::Workspace_sptr ws); + void doSortEvents(const Mantid::API::Workspace_sptr &ws); /// Low resolution TOF matrix workspace API::MatrixWorkspace_sptr m_lowResW; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h index 5da83dcc1e4baee757132d9a4812349dcb5ecfd3..6ed48dc7a615f473c699e2cb4e5c03233f128b3e 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsReduction.h @@ -32,12 +32,13 @@ public: private: void init() override; void exec() override; - API::Workspace_sptr loadInputData(const std::string prop, + API::Workspace_sptr loadInputData(const std::string &prop, const bool mustLoad = true); - API::MatrixWorkspace_sptr loadGroupingFile(const std::string prop); + API::MatrixWorkspace_sptr loadGroupingFile(const std::string &prop); API::MatrixWorkspace_sptr loadHardMask(); - double getParameter(std::string algParam, API::MatrixWorkspace_sptr ws, - std::string altParam); + double getParameter(const std::string &algParam, + const API::MatrixWorkspace_sptr &ws, + const std::string &altParam); boost::shared_ptr<Kernel::PropertyManager> reductionManager; }; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h index 5b7a37597bb473201ee4e05d9a5ed1c8952a16f7..52e054f871e8c628619975904cda8fd2e2108bff 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/DgsRemap.h @@ -30,9 +30,9 @@ public: private: void init() override; void exec() override; - void execGrouping(API::MatrixWorkspace_sptr iWS, + void execGrouping(const API::MatrixWorkspace_sptr &iWS, API::MatrixWorkspace_sptr &oWS); - void execMasking(API::MatrixWorkspace_sptr iWS); + void execMasking(const API::MatrixWorkspace_sptr &iWS); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h index f8bc95b1595f8341a8578bba0e9dcae99c8b06a4..9482d96bbb4f0d7d3644abdeb0ec98e5c291967e 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSInstrument.h @@ -24,17 +24,17 @@ const double default_slit_positions[3][8] = { {0.0, 10.0, 10.0, 15.0, 15.0, 20.0, 20.0, 40.0}}; double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y); void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); } // namespace EQSANSInstrument } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h index 4b8bc0f2890ade4477f459b09c44b13afc479ee2..18c9ef46276c20020cba6aecb8dfab4ae9385c68 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/EQSANSMonitorTOF.h @@ -52,7 +52,7 @@ private: void exec() override; /// Compute TOF offset - double getTofOffset(API::MatrixWorkspace_const_sptr inputWS, + double getTofOffset(const API::MatrixWorkspace_const_sptr &inputWS, bool frame_skipping, double source_to_monitor); }; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h index eaf91d39f4d1c632c39c4028e810b40dff796784..18dd6e576e96802cdea0dfce2dd8eb4aee8a4538 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/ExtractQENSMembers.h @@ -33,7 +33,7 @@ private: getQValues(const std::vector<Mantid::API::MatrixWorkspace_sptr> &workspaces); std::vector<std::string> - getAxisLabels(Mantid::API::MatrixWorkspace_sptr workspace, + getAxisLabels(const Mantid::API::MatrixWorkspace_sptr &workspace, size_t axisIndex) const; std::vector<std::string> @@ -41,20 +41,21 @@ private: const std::vector<std::string> &newNames) const; Mantid::API::MatrixWorkspace_sptr - extractSpectrum(Mantid::API::MatrixWorkspace_sptr inputWS, size_t spectrum); + extractSpectrum(const Mantid::API::MatrixWorkspace_sptr &inputWS, + size_t spectrum); Mantid::API::MatrixWorkspace_sptr - appendSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr spectraWorkspace); + appendSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &spectraWorkspace); Mantid::API::WorkspaceGroup_sptr groupWorkspaces(const std::vector<std::string> &workspaceNames); std::vector<Mantid::API::MatrixWorkspace_sptr> - createMembersWorkspaces(Mantid::API::MatrixWorkspace_sptr initialWS, + createMembersWorkspaces(const Mantid::API::MatrixWorkspace_sptr &initialWS, const std::vector<std::string> &members); - void appendToMembers(Mantid::API::MatrixWorkspace_sptr resultWS, + void appendToMembers(const Mantid::API::MatrixWorkspace_sptr &resultWS, std::vector<Mantid::API::MatrixWorkspace_sptr> &members); void setNumericAxis( diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h index 8167b77c9123765e209f981b49f903c8196bebb3..61d45c8c2be64632468474f52e16e005ed4a68e3 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRDarkCurrentSubtraction.h @@ -59,7 +59,7 @@ private: void init() override; /// Execution code void exec() override; - double getCountingTime(API::MatrixWorkspace_sptr inputWS); + double getCountingTime(const API::MatrixWorkspace_sptr &inputWS); static const int DEFAULT_MONITOR_ID = 0; static const int DEFAULT_TIMER_ID = 1; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h index a42ba6969a7050315285920e8c2768081ac6595f..76d24d463d60c1bb58bd227d24b67cf75a65d828 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/HFIRInstrument.h @@ -20,18 +20,18 @@ namespace HFIRInstrument { */ double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS); void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y); void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y); -double getSourceToSampleDistance(API::MatrixWorkspace_sptr dataWS); + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y); +double getSourceToSampleDistance(const API::MatrixWorkspace_sptr &dataWS); } // namespace HFIRInstrument } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h index 54c73581cedadca69bcbc3a32b3609530a7ec0ce..17b9d84bb998d18f53a3d170727736e06da2c573 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/IMuonAsymmetryCalculator.h @@ -20,9 +20,9 @@ namespace WorkflowAlgorithms { */ class DLLExport IMuonAsymmetryCalculator { public: - IMuonAsymmetryCalculator(const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods); + IMuonAsymmetryCalculator(const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods); virtual ~IMuonAsymmetryCalculator() = default; /// Overridden in derived classes to perform asymmetry calculation virtual API::MatrixWorkspace_sptr calculate() const = 0; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h index 8226fe81590c000d3bc14f39ec62eab15c80018f..9c9294fce63c81dbce292b90571a721faa540348 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupAsymmetryCalculator.h @@ -16,12 +16,12 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonGroupAsymmetryCalculator : public MuonGroupCalculator { public: - MuonGroupAsymmetryCalculator(const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonGroupAsymmetryCalculator(const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex, const double start = 0.0, const double end = 30.0, - const std::string wsName = ""); + const std::string &wsName = ""); /// Performs group asymmetry calculation API::MatrixWorkspace_sptr calculate() const override; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h index 7bd7d3fb087d4a6270f110153688bfb85dc445a2..145e64d2dc951b7d7abb8e3bc669123d0fda9de1 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCalculator.h @@ -15,12 +15,12 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonGroupCalculator : public IMuonAsymmetryCalculator { public: - MuonGroupCalculator(const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonGroupCalculator(const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex); void setStartEnd(const double start, const double end); - void setWSName(const std::string wsName); + void setWSName(const std::string &wsName); protected: /// Workspace index of the group to analyse diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h index 39527d5f27438f3ed0e67584435d9ce3d858d8e4..7065beb04fd34086b10e0b710450c98494aa545e 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonGroupCountsCalculator.h @@ -16,9 +16,9 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonGroupCountsCalculator : public MuonGroupCalculator { public: - MuonGroupCountsCalculator(const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonGroupCountsCalculator(const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex); /// Performs group counts calculation Mantid::API::MatrixWorkspace_sptr calculate() const override; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h index e648207f6aa0899382211a648e3b7f74236de157..00d978d8757e8cf3a66fc4e7b248bce340db6e3a 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h @@ -16,9 +16,9 @@ namespace WorkflowAlgorithms { */ class DLLExport MuonPairAsymmetryCalculator : public IMuonAsymmetryCalculator { public: - MuonPairAsymmetryCalculator(const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, + MuonPairAsymmetryCalculator(const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int firstPairIndex, const int secondPairIndex, const double alpha = 1); diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h index b5e022ab69534d2cf49b91e0796f83b17809d001..7489a3e35a1f45809fe3288ffcfd92f13870f739 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/MuonProcess.h @@ -39,12 +39,12 @@ private: /// Groups specified workspace group according to specified /// DetectorGroupingTable. API::WorkspaceGroup_sptr - groupWorkspaces(API::WorkspaceGroup_sptr wsGroup, - DataObjects::TableWorkspace_sptr grouping); + groupWorkspaces(const API::WorkspaceGroup_sptr &wsGroup, + const DataObjects::TableWorkspace_sptr &grouping); /// Applies dead time correction to the workspace group. - API::WorkspaceGroup_sptr applyDTC(API::WorkspaceGroup_sptr wsGroup, - DataObjects::TableWorkspace_sptr dt); + API::WorkspaceGroup_sptr applyDTC(const API::WorkspaceGroup_sptr &wsGroup, + const DataObjects::TableWorkspace_sptr &dt); /// Applies offset, crops and rebin the workspace according to specified /// params @@ -52,8 +52,9 @@ private: double loadedTimeZero); /// Applies offset, crops and rebins all workspaces in the group - API::WorkspaceGroup_sptr correctWorkspaces(API::WorkspaceGroup_sptr wsGroup, - double loadedTimeZero); + API::WorkspaceGroup_sptr + correctWorkspaces(const API::WorkspaceGroup_sptr &wsGroup, + double loadedTimeZero); /// Builds an error message from a list of invalid periods std::string buildErrorString(const std::vector<int> &invalidPeriods) const; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h index 14feb749b97b2e4284dedb0d1389b0892994d178..4e5ade301355d87dd43635c7a67562f29ad3e135 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFinder.h @@ -40,8 +40,8 @@ private: void exec() override; API::MatrixWorkspace_sptr loadBeamFinderFile(const std::string &beamCenterFile); - void maskEdges(API::MatrixWorkspace_sptr beamCenterWS, int high, int low, - int left, int right, + void maskEdges(const API::MatrixWorkspace_sptr &beamCenterWS, int high, + int low, int left, int right, const std::string &componentName = "detector1"); boost::shared_ptr<Kernel::PropertyManager> m_reductionManager; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h index d58c344d69d639e09e94909dd6d543e60b77f4d1..fc5e6f053b362dd2f521697b78100a92112c41d3 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupEQSANSReduction.h @@ -39,12 +39,12 @@ private: /// Execution code void exec() override; std::string _findFile(std::string dataRun); - void - setupSensitivity(boost::shared_ptr<Kernel::PropertyManager> reductionManager); + void setupSensitivity( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); void setupTransmission( - boost::shared_ptr<Kernel::PropertyManager> reductionManager); - void - setupBackground(boost::shared_ptr<Kernel::PropertyManager> reductionManager); + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); + void setupBackground( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h index ab794a925ae0feb9958845cb5c70d141c539245d..e3f63b5d70f999f40d05edc2a8ceb8fd1edcb4fa 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SetupHFIRReduction.h @@ -40,11 +40,11 @@ private: /// Execution code void exec() override; void setupTransmission( - boost::shared_ptr<Kernel::PropertyManager> reductionManager); - void - setupBackground(boost::shared_ptr<Kernel::PropertyManager> reductionManager); - void - setupSensitivity(boost::shared_ptr<Kernel::PropertyManager> reductionManager); + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); + void setupBackground( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); + void setupSensitivity( + const boost::shared_ptr<Kernel::PropertyManager> &reductionManager); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h index 54981c1a711d270b4723483dfdcc09b1a730ef25..7fec136646bb02cb8ff59ec1a1681605cf7b5f74 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/StepScan.h @@ -35,13 +35,13 @@ private: void exec() override; DataObjects::EventWorkspace_sptr - getMonitorWorkspace(API::MatrixWorkspace_sptr inputWS); + getMonitorWorkspace(const API::MatrixWorkspace_sptr &inputWS); DataObjects::EventWorkspace_sptr - cloneInputWorkspace(API::Workspace_sptr inputWS); - void runMaskDetectors(API::MatrixWorkspace_sptr inputWS, - API::MatrixWorkspace_sptr maskWS); - void runFilterByXValue(API::MatrixWorkspace_sptr inputWS, const double xmin, - const double xmax); + cloneInputWorkspace(const API::Workspace_sptr &inputWS); + void runMaskDetectors(const API::MatrixWorkspace_sptr &inputWS, + const API::MatrixWorkspace_sptr &maskWS); + void runFilterByXValue(const API::MatrixWorkspace_sptr &inputWS, + const double xmin, const double xmax); }; } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp index 38c7735f2c521f9baa6a6d6550802c1b00d07f74..2a5961d7306cdf1606d0a423863598c8149bc5b2 100644 --- a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -823,9 +823,9 @@ void AlignAndFocusPowder::exec() { /** Call edit instrument geometry */ API::MatrixWorkspace_sptr AlignAndFocusPowder::editInstrument( - API::MatrixWorkspace_sptr ws, std::vector<double> polars, - std::vector<specnum_t> specids, std::vector<double> l2s, - std::vector<double> phis) { + API::MatrixWorkspace_sptr ws, const std::vector<double> &polars, + const std::vector<specnum_t> &specids, const std::vector<double> &l2s, + const std::vector<double> &phis) { g_log.information() << "running EditInstrumentGeometry started at " << Types::Core::DateAndTime::getCurrentTime() << "\n"; @@ -884,7 +884,7 @@ AlignAndFocusPowder::diffractionFocus(API::MatrixWorkspace_sptr ws) { */ API::MatrixWorkspace_sptr AlignAndFocusPowder::convertUnits(API::MatrixWorkspace_sptr matrixws, - std::string target) { + const std::string &target) { g_log.information() << "running ConvertUnits(Target=" << target << ") started at " << Types::Core::DateAndTime::getCurrentTime() << "\n"; @@ -955,8 +955,8 @@ AlignAndFocusPowder::rebin(API::MatrixWorkspace_sptr matrixws) { /** Add workspace2 to workspace1 by adding spectrum. */ MatrixWorkspace_sptr -AlignAndFocusPowder::conjoinWorkspaces(API::MatrixWorkspace_sptr ws1, - API::MatrixWorkspace_sptr ws2, +AlignAndFocusPowder::conjoinWorkspaces(const API::MatrixWorkspace_sptr &ws1, + const API::MatrixWorkspace_sptr &ws2, size_t offset) { // Get information from ws1: maximum spectrum number, and store original // spectrum Nos @@ -1129,7 +1129,7 @@ void AlignAndFocusPowder::loadCalFile(const std::string &calFilename, * * @param ws :: any Workspace. Does nothing if not EventWorkspace. */ -void AlignAndFocusPowder::doSortEvents(Mantid::API::Workspace_sptr ws) { +void AlignAndFocusPowder::doSortEvents(const Mantid::API::Workspace_sptr &ws) { EventWorkspace_sptr eventWS = boost::dynamic_pointer_cast<EventWorkspace>(ws); if (!eventWS) return; diff --git a/Framework/WorkflowAlgorithms/src/DgsReduction.cpp b/Framework/WorkflowAlgorithms/src/DgsReduction.cpp index f14fbc06ef24f1b9d6041cce894fa939e7702ab6..0f1c20578807a83cec7cf92bd25685691a1a1298 100644 --- a/Framework/WorkflowAlgorithms/src/DgsReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/DgsReduction.cpp @@ -566,7 +566,7 @@ void DgsReduction::init() { * Create a workspace by either loading a file or using an existing * workspace. */ -Workspace_sptr DgsReduction::loadInputData(const std::string prop, +Workspace_sptr DgsReduction::loadInputData(const std::string &prop, const bool mustLoad) { g_log.debug() << "MustLoad = " << mustLoad << '\n'; Workspace_sptr inputWS; @@ -648,7 +648,7 @@ MatrixWorkspace_sptr DgsReduction::loadHardMask() { } } -MatrixWorkspace_sptr DgsReduction::loadGroupingFile(const std::string prop) { +MatrixWorkspace_sptr DgsReduction::loadGroupingFile(const std::string &prop) { const std::string propName = prop + "GroupingFile"; const std::string groupFile = this->getProperty(propName); if (groupFile.empty()) { @@ -672,8 +672,9 @@ MatrixWorkspace_sptr DgsReduction::loadGroupingFile(const std::string prop) { } } -double DgsReduction::getParameter(std::string algParam, MatrixWorkspace_sptr ws, - std::string altParam) { +double DgsReduction::getParameter(const std::string &algParam, + const MatrixWorkspace_sptr &ws, + const std::string &altParam) { double param = this->getProperty(algParam); if (EMPTY_DBL() == param) { param = ws->getInstrument()->getNumberParameter(altParam)[0]; diff --git a/Framework/WorkflowAlgorithms/src/DgsRemap.cpp b/Framework/WorkflowAlgorithms/src/DgsRemap.cpp index f2675e2c31f01f414897a19ddc098c6ed6e4df75..dc3a07d689405d7795d87f7245828114544bd4e8 100644 --- a/Framework/WorkflowAlgorithms/src/DgsRemap.cpp +++ b/Framework/WorkflowAlgorithms/src/DgsRemap.cpp @@ -74,7 +74,7 @@ void DgsRemap::exec() { this->setProperty("OutputWorkspace", outputWS); } -void DgsRemap::execMasking(MatrixWorkspace_sptr iWS) { +void DgsRemap::execMasking(const MatrixWorkspace_sptr &iWS) { MatrixWorkspace_sptr maskWS = this->getProperty("MaskWorkspace"); if (maskWS) { IAlgorithm_sptr mask = this->createChildAlgorithm("MaskDetectors"); @@ -84,7 +84,7 @@ void DgsRemap::execMasking(MatrixWorkspace_sptr iWS) { } } -void DgsRemap::execGrouping(MatrixWorkspace_sptr iWS, +void DgsRemap::execGrouping(const MatrixWorkspace_sptr &iWS, MatrixWorkspace_sptr &oWS) { MatrixWorkspace_sptr groupWS = this->getProperty("GroupingWorkspace"); std::string oldGroupingFile = this->getProperty("OldGroupingFile"); diff --git a/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp b/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp index 8e335feaa8d73737048719733835ac127894f7bb..a775a38f9fcd5c79039451f165203be61e68b64f 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSInstrument.cpp @@ -7,10 +7,12 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- -#include "MantidWorkflowAlgorithms/EQSANSInstrument.h" +#include <utility> + #include "MantidDataObjects/EventWorkspace.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/Exception.h" +#include "MantidWorkflowAlgorithms/EQSANSInstrument.h" namespace Mantid { namespace WorkflowAlgorithms { @@ -24,7 +26,7 @@ namespace EQSANSInstrument { * Read a parameter from the instrument description */ double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { std::vector<double> pars = dataWS->getInstrument()->getNumberParameter(parameter); if (pars.empty()) @@ -37,9 +39,9 @@ double readInstrumentParameter(const std::string ¶meter, * Return the detector ID corresponding to the [x,y] pixel coordinates. */ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS) { - int ny_pixels = - static_cast<int>(readInstrumentParameter("number-of-y-pixels", dataWS)); + const API::MatrixWorkspace_sptr &dataWS) { + int ny_pixels = static_cast<int>( + readInstrumentParameter("number-of-y-pixels", std::move(dataWS))); return ny_pixels * pixel_x + pixel_y; } @@ -48,7 +50,7 @@ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, * given pixel coordinates [m]. */ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); @@ -68,8 +70,8 @@ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, * @param y: real-space y coordinate [m] */ void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); const int ny_pixels = @@ -84,9 +86,9 @@ void getPixelFromCoordinate(const double &x, const double &y, * Returns the default beam center position, or the pixel location * of real-space coordinates (0,0). */ -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { - getPixelFromCoordinate(0.0, 0.0, dataWS, pixel_x, pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { + getPixelFromCoordinate(0.0, 0.0, std::move(dataWS), pixel_x, pixel_y); } } // namespace EQSANSInstrument diff --git a/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp b/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp index 6eb5dc9957311a09c2d94ffb0b5ee90a7961e61a..67d70ac8cf4c51981ddb433e6342a14acf01e531 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp @@ -120,7 +120,7 @@ void EQSANSLoad::init() { /// Returns the value of a run property from a given workspace /// @param inputWS :: input workspace /// @param pname :: name of the property to retrieve -double getRunPropertyDbl(MatrixWorkspace_sptr inputWS, +double getRunPropertyDbl(const MatrixWorkspace_sptr &inputWS, const std::string &pname) { Mantid::Kernel::Property *prop = inputWS->run().getProperty(pname); auto *dp = dynamic_cast<Mantid::Kernel::PropertyWithValue<double> *>(prop); diff --git a/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp b/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp index 80c5abb0c8f9080a56bdb2da7ffe32b8e9a84a41..a35a04e1d8d8d163255be226a737f500f9ce5067 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSMonitorTOF.cpp @@ -190,7 +190,7 @@ void EQSANSMonitorTOF::exec() { setProperty("OutputWorkspace", outputWS); } -double EQSANSMonitorTOF::getTofOffset(MatrixWorkspace_const_sptr inputWS, +double EQSANSMonitorTOF::getTofOffset(const MatrixWorkspace_const_sptr &inputWS, bool frame_skipping, double source_to_monitor) { //# Storage for chopper information read from the logs diff --git a/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp b/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp index 0e05c886d9df7f56f0091eccaba308bfca4e406d..e28de98b3f7d4b2f40e5a86178174b04729f0a04 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSQ2D.cpp @@ -39,7 +39,8 @@ void EQSANSQ2D::init() { /// Returns the value of a run property from a given workspace /// @param inputWS :: input workspace /// @param pname :: name of the property to retrieve -double getRunProperty(MatrixWorkspace_sptr inputWS, const std::string &pname) { +double getRunProperty(const MatrixWorkspace_sptr &inputWS, + const std::string &pname) { return inputWS->run().getPropertyValueAsType<double>(pname); } diff --git a/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp b/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp index c1659b2fcd3c66166555fcfd35fd03b49ab0effb..097629278935e881245e1f9ca681f0419f00458f 100644 --- a/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp +++ b/Framework/WorkflowAlgorithms/src/ExtractQENSMembers.cpp @@ -158,7 +158,7 @@ std::vector<double> ExtractQENSMembers::getQValues( * @return The retrieved axis labels. */ std::vector<std::string> -ExtractQENSMembers::getAxisLabels(MatrixWorkspace_sptr workspace, +ExtractQENSMembers::getAxisLabels(const MatrixWorkspace_sptr &workspace, size_t axisIndex) const { auto axis = workspace->getAxis(axisIndex); std::vector<std::string> labels; @@ -201,7 +201,7 @@ std::vector<std::string> ExtractQENSMembers::renameConvolvedMembers( * @return A workspace containing the extracted spectrum. */ MatrixWorkspace_sptr -ExtractQENSMembers::extractSpectrum(MatrixWorkspace_sptr inputWS, +ExtractQENSMembers::extractSpectrum(const MatrixWorkspace_sptr &inputWS, size_t spectrum) { auto extractAlg = createChildAlgorithm("ExtractSpectra", -1.0, -1.0, false); extractAlg->setProperty("InputWorkspace", inputWS); @@ -221,9 +221,9 @@ ExtractQENSMembers::extractSpectrum(MatrixWorkspace_sptr inputWS, * @param inputWS The input workspace to append to. * @param spectraWorkspace The workspace whose spectra to append. */ -MatrixWorkspace_sptr -ExtractQENSMembers::appendSpectra(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr spectraWorkspace) { +MatrixWorkspace_sptr ExtractQENSMembers::appendSpectra( + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &spectraWorkspace) { auto appendAlg = createChildAlgorithm("AppendSpectra", -1.0, -1.0, false); appendAlg->setProperty("InputWorkspace1", inputWS); appendAlg->setProperty("InputWorkspace2", spectraWorkspace); @@ -256,7 +256,8 @@ WorkspaceGroup_sptr ExtractQENSMembers::groupWorkspaces( * @return A vector of the created members workspaces. */ std::vector<MatrixWorkspace_sptr> ExtractQENSMembers::createMembersWorkspaces( - MatrixWorkspace_sptr initialWS, const std::vector<std::string> &members) { + const MatrixWorkspace_sptr &initialWS, + const std::vector<std::string> &members) { std::vector<MatrixWorkspace_sptr> memberWorkspaces; memberWorkspaces.reserve(members.size()); for (auto i = 0u; i < members.size(); ++i) @@ -272,7 +273,7 @@ std::vector<MatrixWorkspace_sptr> ExtractQENSMembers::createMembersWorkspaces( * @param members A vector containing the member workspaces. */ void ExtractQENSMembers::appendToMembers( - MatrixWorkspace_sptr resultWS, + const MatrixWorkspace_sptr &resultWS, std::vector<Mantid::API::MatrixWorkspace_sptr> &members) { for (auto i = 0u; i < members.size(); ++i) members[i] = appendSpectra(members[i], extractSpectrum(resultWS, i)); diff --git a/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp b/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp index 1fc8de3bca30398897053aaa804412772cbe0c9a..ea3bf5f6c296d06a475aa1c5ee7e410ae8af9d74 100644 --- a/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp +++ b/Framework/WorkflowAlgorithms/src/HFIRDarkCurrentSubtraction.cpp @@ -157,8 +157,8 @@ void HFIRDarkCurrentSubtraction::exec() { /// Get the counting time from a workspace /// @param inputWS :: workspace to read the counting time from -double -HFIRDarkCurrentSubtraction::getCountingTime(MatrixWorkspace_sptr inputWS) { +double HFIRDarkCurrentSubtraction::getCountingTime( + const MatrixWorkspace_sptr &inputWS) { // First, look whether we have the information in the log if (inputWS->run().hasProperty("timer")) { return inputWS->run().getPropertyValueAsType<double>("timer"); diff --git a/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp b/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp index fcedefe5c75478d780949b7511cf9b3c4bfd7621..1063baa7a96692c6428c4d86b79d5744682613f3 100644 --- a/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp +++ b/Framework/WorkflowAlgorithms/src/HFIRInstrument.cpp @@ -21,6 +21,7 @@ #include <boost/regex.hpp> #include <boost/shared_array.hpp> #include <boost/shared_ptr.hpp> +#include <utility> namespace Mantid { namespace WorkflowAlgorithms { @@ -34,7 +35,7 @@ namespace HFIRInstrument { * Read a parameter from the instrument description */ double readInstrumentParameter(const std::string ¶meter, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { std::vector<double> pars = dataWS->getInstrument()->getNumberParameter(parameter); if (pars.empty()) @@ -47,7 +48,7 @@ double readInstrumentParameter(const std::string ¶meter, * Return the detector ID corresponding to the [x,y] pixel coordinates. */ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, - API::MatrixWorkspace_sptr dataWS) { + const API::MatrixWorkspace_sptr &dataWS) { UNUSED_ARG(dataWS); return 1000000 + 1000 * pixel_x + pixel_y; } @@ -57,7 +58,7 @@ int getDetectorFromPixel(const int &pixel_x, const int &pixel_y, * given pixel coordinates [m]. */ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, - API::MatrixWorkspace_sptr dataWS, double &x, + const API::MatrixWorkspace_sptr &dataWS, double &x, double &y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); @@ -78,8 +79,8 @@ void getCoordinateFromPixel(const double &pixel_x, const double &pixel_y, * */ void getPixelFromCoordinate(const double &x, const double &y, - API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { + const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { const int nx_pixels = static_cast<int>(readInstrumentParameter("number-of-x-pixels", dataWS)); const int ny_pixels = @@ -94,9 +95,9 @@ void getPixelFromCoordinate(const double &x, const double &y, * Returns the default beam center position, or the pixel location * of real-space coordinates (0,0). */ -void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, - double &pixel_y) { - getPixelFromCoordinate(0.0, 0.0, dataWS, pixel_x, pixel_y); +void getDefaultBeamCenter(const API::MatrixWorkspace_sptr &dataWS, + double &pixel_x, double &pixel_y) { + getPixelFromCoordinate(0.0, 0.0, std::move(dataWS), pixel_x, pixel_y); } /* @@ -106,7 +107,7 @@ void getDefaultBeamCenter(API::MatrixWorkspace_sptr dataWS, double &pixel_x, * defined in instrument parameters file as "aperture-distances" * and sums "Header/sample_aperture_to_flange" */ -double getSourceToSampleDistance(API::MatrixWorkspace_sptr dataWS) { +double getSourceToSampleDistance(const API::MatrixWorkspace_sptr &dataWS) { double sourceToSampleDistance; diff --git a/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp b/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp index 3dd6530b6e5fa73ee3ff878bdf2f32387bdd5cf4..369be06715826c5f00f97dfecb54da4524d22bfe 100644 --- a/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/IMuonAsymmetryCalculator.cpp @@ -25,8 +25,8 @@ namespace WorkflowAlgorithms { * from summed periods */ IMuonAsymmetryCalculator::IMuonAsymmetryCalculator( - const WorkspaceGroup_sptr inputWS, const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods) + const WorkspaceGroup_sptr &inputWS, const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods) : m_inputWS(inputWS), m_summedPeriods(summedPeriods), m_subtractedPeriods(subtractedPeriods) {} diff --git a/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp index a49dd44f8335d7c63dff94737dd4647168c52d98..92a15201ad5f3713e43e53b73e8250d7877d23a5 100644 --- a/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonGroupAsymmetryCalculator.cpp @@ -33,10 +33,10 @@ namespace WorkflowAlgorithms { * @param wsName :: the name of the workspace (for normalization table) */ MuonGroupAsymmetryCalculator::MuonGroupAsymmetryCalculator( - const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int groupIndex, - const double start, const double end, const std::string wsName) + const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex, + const double start, const double end, const std::string &wsName) : MuonGroupCalculator(inputWS, summedPeriods, subtractedPeriods, groupIndex) { MuonGroupCalculator::setStartEnd(start, end); diff --git a/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp index c17150ef32a32b63022f2c386fb2720c936eb6a8..4dc4d1ec99635bae8638d7c0a6688564841782c0 100644 --- a/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonGroupCalculator.cpp @@ -19,16 +19,16 @@ namespace WorkflowAlgorithms { * @param groupIndex :: [input] Workspace index of the group to analyse */ MuonGroupCalculator::MuonGroupCalculator( - const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int groupIndex) + const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex) : IMuonAsymmetryCalculator(inputWS, summedPeriods, subtractedPeriods), m_groupIndex(groupIndex) {} void MuonGroupCalculator::setStartEnd(const double start, const double end) { m_startX = start; m_endX = end; } -void MuonGroupCalculator::setWSName(const std::string wsName) { +void MuonGroupCalculator::setWSName(const std::string &wsName) { m_wsName = wsName; } } // namespace WorkflowAlgorithms diff --git a/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp index dd4565741960b90427e59d75603ac967793be1aa..0d50f9124dcad767385f13bc34bd27a0310f08bd 100644 --- a/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonGroupCountsCalculator.cpp @@ -21,9 +21,9 @@ namespace WorkflowAlgorithms { * @param groupIndex :: [input] Workspace index of the group to analyse */ MuonGroupCountsCalculator::MuonGroupCountsCalculator( - const Mantid::API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int groupIndex) + const Mantid::API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int groupIndex) : MuonGroupCalculator(inputWS, summedPeriods, subtractedPeriods, groupIndex) {} diff --git a/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp b/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp index 41f8868be78cbf66c3a9d7ef593ad9a9ae563cc7..e51b7ca8a64a24782ec36e38f271f4f9e663d570 100644 --- a/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonPairAsymmetryCalculator.cpp @@ -27,9 +27,9 @@ namespace WorkflowAlgorithms { * @param alpha :: [input] Alpha (balance) value of the pair */ MuonPairAsymmetryCalculator::MuonPairAsymmetryCalculator( - const API::WorkspaceGroup_sptr inputWS, - const std::vector<int> summedPeriods, - const std::vector<int> subtractedPeriods, const int firstPairIndex, + const API::WorkspaceGroup_sptr &inputWS, + const std::vector<int> &summedPeriods, + const std::vector<int> &subtractedPeriods, const int firstPairIndex, const int secondPairIndex, const double alpha) : IMuonAsymmetryCalculator(inputWS, summedPeriods, subtractedPeriods), m_alpha(alpha), m_firstPairIndex(firstPairIndex), diff --git a/Framework/WorkflowAlgorithms/src/MuonProcess.cpp b/Framework/WorkflowAlgorithms/src/MuonProcess.cpp index 1fd924f9262c9d893d1c64502f7f3aee19920f80..414e9abca8345caf738baff73778cd980acd2349 100644 --- a/Framework/WorkflowAlgorithms/src/MuonProcess.cpp +++ b/Framework/WorkflowAlgorithms/src/MuonProcess.cpp @@ -218,8 +218,9 @@ void MuonProcess::exec() { * @param grouping :: Detector grouping table to use * @return Grouped workspaces */ -WorkspaceGroup_sptr MuonProcess::groupWorkspaces(WorkspaceGroup_sptr wsGroup, - TableWorkspace_sptr grouping) { +WorkspaceGroup_sptr +MuonProcess::groupWorkspaces(const WorkspaceGroup_sptr &wsGroup, + const TableWorkspace_sptr &grouping) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (int i = 0; i < wsGroup->getNumberOfEntries(); i++) { auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(i)); @@ -242,8 +243,8 @@ WorkspaceGroup_sptr MuonProcess::groupWorkspaces(WorkspaceGroup_sptr wsGroup, * @param dt :: Dead time table to use * @return Corrected workspace group */ -WorkspaceGroup_sptr MuonProcess::applyDTC(WorkspaceGroup_sptr wsGroup, - TableWorkspace_sptr dt) { +WorkspaceGroup_sptr MuonProcess::applyDTC(const WorkspaceGroup_sptr &wsGroup, + const TableWorkspace_sptr &dt) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (int i = 0; i < wsGroup->getNumberOfEntries(); i++) { auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(i)); @@ -273,8 +274,9 @@ WorkspaceGroup_sptr MuonProcess::applyDTC(WorkspaceGroup_sptr wsGroup, * offset * @return Corrected workspaces */ -WorkspaceGroup_sptr MuonProcess::correctWorkspaces(WorkspaceGroup_sptr wsGroup, - double loadedTimeZero) { +WorkspaceGroup_sptr +MuonProcess::correctWorkspaces(const WorkspaceGroup_sptr &wsGroup, + double loadedTimeZero) { WorkspaceGroup_sptr outWS = boost::make_shared<WorkspaceGroup>(); for (int i = 0; i < wsGroup->getNumberOfEntries(); i++) { auto ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(i)); diff --git a/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp b/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp index 1afb28210acda212503d97aa63048e67833fb859..8da85b6f7c7236e919537b24cf70ea6874dd0ca5 100644 --- a/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp +++ b/Framework/WorkflowAlgorithms/src/ProcessIndirectFitParameters.cpp @@ -80,7 +80,7 @@ void extractColumnValues(Column const &column, std::size_t startRow, template <typename T, typename OutputIterator> void extractValuesFromColumns(std::size_t startRow, std::size_t endRow, - std::vector<Column_const_sptr> columns, + const std::vector<Column_const_sptr> &columns, OutputIterator outputIt) { for (auto &&column : columns) extractColumnValues<T>(*column, startRow, endRow, outputIt); @@ -104,7 +104,9 @@ std::vector<double> getNumericColumnValuesOrIndices(Column const &column, return getIncrementingSequence(0.0, length); } -std::string getColumnName(Column_const_sptr column) { return column->name(); } +std::string getColumnName(const Column_const_sptr &column) { + return column->name(); +} std::vector<std::string> extractColumnNames(std::vector<Column_const_sptr> const &columns) { diff --git a/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp b/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp index d79fce4546070bee5c7d80d021c9108a067bf514..7b1eab7f3d375a11aad37904f38435cdd5f7240d 100644 --- a/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp +++ b/Framework/WorkflowAlgorithms/src/SANSBeamFinder.cpp @@ -246,8 +246,8 @@ void SANSBeamFinder::exec() { * 2016/05/06 : this only works for RectangularDetector * */ -void SANSBeamFinder::maskEdges(MatrixWorkspace_sptr beamCenterWS, int high, - int low, int left, int right, +void SANSBeamFinder::maskEdges(const MatrixWorkspace_sptr &beamCenterWS, + int high, int low, int left, int right, const std::string &componentName) { auto instrument = beamCenterWS->getInstrument(); diff --git a/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp b/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp index 1dbd40376b45e4b918befe962ac7fab1aa36c449..3b364ee50b6a5d618ddad8af53bafd3d2464a592 100644 --- a/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/SetupEQSANSReduction.cpp @@ -890,7 +890,7 @@ void SetupEQSANSReduction::exec() { } void SetupEQSANSReduction::setupSensitivity( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); const std::string sensitivityFile = getPropertyValue("SensitivityFile"); @@ -957,7 +957,7 @@ void SetupEQSANSReduction::setupSensitivity( } } void SetupEQSANSReduction::setupTransmission( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Transmission options const bool thetaDependentTrans = getProperty("ThetaDependentTransmission"); @@ -1042,7 +1042,7 @@ void SetupEQSANSReduction::setupTransmission( } void SetupEQSANSReduction::setupBackground( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Background const std::string backgroundFile = getPropertyValue("BackgroundFiles"); diff --git a/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp b/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp index abff959319d847e7af655f49717a628048ae4563..dfb032453ad2074d79c4bb60d394b2399b9923d9 100644 --- a/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp +++ b/Framework/WorkflowAlgorithms/src/SetupHFIRReduction.cpp @@ -904,7 +904,7 @@ void SetupHFIRReduction::exec() { } void SetupHFIRReduction::setupSensitivity( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); const std::string sensitivityFile = getPropertyValue("SensitivityFile"); @@ -994,7 +994,7 @@ void SetupHFIRReduction::setupSensitivity( } void SetupHFIRReduction::setupBackground( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Background const std::string backgroundFile = getPropertyValue("BackgroundFiles"); @@ -1112,7 +1112,7 @@ void SetupHFIRReduction::setupBackground( } void SetupHFIRReduction::setupTransmission( - boost::shared_ptr<PropertyManager> reductionManager) { + const boost::shared_ptr<PropertyManager> &reductionManager) { const std::string reductionManagerName = getProperty("ReductionProperties"); // Transmission options const bool thetaDependentTrans = getProperty("ThetaDependentTransmission"); diff --git a/Framework/WorkflowAlgorithms/src/StepScan.cpp b/Framework/WorkflowAlgorithms/src/StepScan.cpp index 81b4ab565b8c1988f1449e2d790f24948ccfa47a..3efd351eca42d2ec861de0eab65c9db81de0572f 100644 --- a/Framework/WorkflowAlgorithms/src/StepScan.cpp +++ b/Framework/WorkflowAlgorithms/src/StepScan.cpp @@ -114,14 +114,14 @@ void StepScan::exec() { * pointer. */ DataObjects::EventWorkspace_sptr -StepScan::getMonitorWorkspace(API::MatrixWorkspace_sptr inputWS) { +StepScan::getMonitorWorkspace(const API::MatrixWorkspace_sptr &inputWS) { // See if there's a monitor workspace inside the input one return boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( inputWS->monitorWorkspace()); } DataObjects::EventWorkspace_sptr -StepScan::cloneInputWorkspace(API::Workspace_sptr inputWS) { +StepScan::cloneInputWorkspace(const API::Workspace_sptr &inputWS) { IAlgorithm_sptr clone = createChildAlgorithm("CloneWorkspace"); clone->setProperty("InputWorkspace", inputWS); clone->executeAsChildAlg(); @@ -134,8 +134,8 @@ StepScan::cloneInputWorkspace(API::Workspace_sptr inputWS) { * @param inputWS The input workspace * @param maskWS A masking workspace */ -void StepScan::runMaskDetectors(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr maskWS) { +void StepScan::runMaskDetectors(const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &maskWS) { IAlgorithm_sptr maskingAlg = createChildAlgorithm("MaskDetectors"); maskingAlg->setProperty<MatrixWorkspace_sptr>("Workspace", inputWS); maskingAlg->setProperty<MatrixWorkspace_sptr>("MaskedWorkspace", maskWS); @@ -147,7 +147,7 @@ void StepScan::runMaskDetectors(MatrixWorkspace_sptr inputWS, * @param xmin The minimum value of the filter * @param xmax The maximum value of the filter */ -void StepScan::runFilterByXValue(MatrixWorkspace_sptr inputWS, +void StepScan::runFilterByXValue(const MatrixWorkspace_sptr &inputWS, const double xmin, const double xmax) { std::string rangeUnit = getProperty("RangeUnit"); // Run ConvertUnits on the input workspace if xmin/max were given in a diff --git a/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h b/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h index 8f737f7403c1fa43bb7ab95307327c050ad2d562..f3c3cd481e0ceb2bb98add6a1c5bc8d6aa70e123 100644 --- a/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h +++ b/Framework/WorkflowAlgorithms/test/AlignAndFocusPowderTest.h @@ -692,7 +692,8 @@ public: } /* Utility functions */ - void loadDiffCal(std::string calfilename, bool group, bool cal, bool mask) { + void loadDiffCal(const std::string &calfilename, bool group, bool cal, + bool mask) { LoadDiffCal loadDiffAlg; loadDiffAlg.initialize(); loadDiffAlg.setPropertyValue("Filename", calfilename); @@ -704,7 +705,7 @@ public: loadDiffAlg.execute(); } - void groupAllBanks(std::string m_inputWS) { + void groupAllBanks(const std::string &m_inputWS) { CreateGroupingWorkspace groupAlg; groupAlg.initialize(); groupAlg.setPropertyValue("InputWorkspace", m_inputWS); @@ -713,7 +714,7 @@ public: groupAlg.execute(); } - void rebin(std::string params, bool preserveEvents = true) { + void rebin(const std::string ¶ms, bool preserveEvents = true) { Rebin rebin; rebin.initialize(); rebin.setPropertyValue("InputWorkspace", m_inputWS); @@ -734,8 +735,9 @@ public: resamplexAlg.execute(); } - std::string createArgForNumberHistograms(double val, MatrixWorkspace_sptr ws, - std::string delimiter = ",") { + std::string createArgForNumberHistograms(double val, + const MatrixWorkspace_sptr &ws, + const std::string &delimiter = ",") { std::vector<std::string> vec; for (size_t i = 0; i < ws->getNumberHistograms(); i++) vec.emplace_back(boost::lexical_cast<std::string>(val)); diff --git a/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h b/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h index 31adb867821815b7ad4bd077e078eeb73df4f44c..b3e725f6513114743b65be3a754e74feb4f17606 100644 --- a/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h +++ b/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h @@ -26,6 +26,7 @@ #include <algorithm> #include <memory> #include <random> +#include <utility> using Mantid::Algorithms::ExtractQENSMembers; @@ -94,7 +95,7 @@ public: } private: - void checkMembersOutput(WorkspaceGroup_sptr membersWorkspace, + void checkMembersOutput(const WorkspaceGroup_sptr &membersWorkspace, const std::vector<std::string> &members, const std::string &outputName, size_t numSpectra, const std::vector<double> &dataX) const { @@ -112,31 +113,32 @@ private: } } - WorkspaceGroup_sptr extractMembers(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + WorkspaceGroup_sptr extractMembers(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const { - auto extractAlgorithm = - extractMembersAlgorithm(inputWs, resultGroupWs, outputWsName); + auto extractAlgorithm = extractMembersAlgorithm( + std::move(inputWs), std::move(resultGroupWs), outputWsName); extractAlgorithm->execute(); return AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( outputWsName); } WorkspaceGroup_sptr - extractMembers(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + extractMembers(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<std::string> &convolvedMembers, const std::string &outputWsName) const { - auto extractAlgorithm = extractMembersAlgorithm( - inputWs, resultGroupWs, convolvedMembers, outputWsName); + auto extractAlgorithm = + extractMembersAlgorithm(std::move(inputWs), std::move(resultGroupWs), + convolvedMembers, outputWsName); extractAlgorithm->execute(); return AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( outputWsName); } IAlgorithm_sptr - extractMembersAlgorithm(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::string &outputWsName) const { auto extractMembersAlg = AlgorithmManager::Instance().create("ExtractQENSMembers"); @@ -147,8 +149,8 @@ private: } IAlgorithm_sptr - extractMembersAlgorithm(MatrixWorkspace_sptr inputWs, - WorkspaceGroup_sptr resultGroupWs, + extractMembersAlgorithm(const MatrixWorkspace_sptr &inputWs, + const WorkspaceGroup_sptr &resultGroupWs, const std::vector<std::string> &convolvedMembers, const std::string &outputWsName) const { auto extractMembersAlg = @@ -205,9 +207,11 @@ private: return createWorkspace->getProperty("OutputWorkspace"); } - MatrixWorkspace_sptr appendSpectra(MatrixWorkspace_sptr workspace, - MatrixWorkspace_sptr spectraWS) const { - auto appendAlgorithm = appendSpectraAlgorithm(workspace, spectraWS); + MatrixWorkspace_sptr + appendSpectra(const MatrixWorkspace_sptr &workspace, + const MatrixWorkspace_sptr &spectraWS) const { + auto appendAlgorithm = + appendSpectraAlgorithm(std::move(workspace), std::move(spectraWS)); appendAlgorithm->execute(); return appendAlgorithm->getProperty("OutputWorkspace"); } @@ -257,8 +261,9 @@ private: return createWorkspace; } - IAlgorithm_sptr appendSpectraAlgorithm(MatrixWorkspace_sptr workspace, - MatrixWorkspace_sptr spectraWS) const { + IAlgorithm_sptr + appendSpectraAlgorithm(const MatrixWorkspace_sptr &workspace, + const MatrixWorkspace_sptr &spectraWS) const { auto appendAlgorithm = AlgorithmManager::Instance().create("AppendSpectra"); appendAlgorithm->setChild(true); appendAlgorithm->setProperty("InputWorkspace1", workspace); diff --git a/MantidPlot/ipython_widget/__init__.py b/MantidPlot/ipython_widget/__init__.py index 1300e7ee5ed5416e7f3eacd883017afe7047c7f7..0f46fcd36c1854390f5ebb9f942861bbc680f909 100644 --- a/MantidPlot/ipython_widget/__init__.py +++ b/MantidPlot/ipython_widget/__init__.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, - print_function) + from .mantid_ipython_widget import * diff --git a/MantidPlot/ipython_widget/mantid_ipython_widget.py b/MantidPlot/ipython_widget/mantid_ipython_widget.py index 2ab0a34db9f252e8a1843b5e9499a92edddf2216..ef29c7659c8e058db270e14afa7dde8e90fd7f58 100644 --- a/MantidPlot/ipython_widget/mantid_ipython_widget.py +++ b/MantidPlot/ipython_widget/mantid_ipython_widget.py @@ -4,14 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, - print_function) + import sys import threading import types import warnings -from mantid.py3compat import getfullargspec +from inspect import getfullargspec from PyQt4 import QtGui # IPython monkey patches the pygments.lexer.RegexLexer.get_tokens_unprocessed method diff --git a/MantidPlot/mantidplot.py b/MantidPlot/mantidplot.py index a81905468499164d37fd50aa50ca14a91ce544de..85cda6be56c086620cb3f2743a7d96640fc2e954 100644 --- a/MantidPlot/mantidplot.py +++ b/MantidPlot/mantidplot.py @@ -10,8 +10,7 @@ # Load 'pymantidplot' which cannot be called 'mantidplot' because of # name conflict with the MantidPlot binary (especially on osx) #------------------------------------------------------------------- -from __future__ import (absolute_import, division, - print_function) + import os.path as osp import sys @@ -26,6 +25,7 @@ import pymantidplot.qtiplot # error early if PyQt4 cannot be used import PyQt4 + def load_ui(caller_filename, ui_relfilename, baseinstance=None): '''This is copied from mantidqt.utils.qt and should be deprecated as soon as possible.''' diff --git a/MantidPlot/mantidplotrc.py b/MantidPlot/mantidplotrc.py index 1b463a9c7f2cdd7c4c20b6d5d3a3f1cfa8ae06f5..f0713a31d8f7c3876be93bf5333aaca02b39e7a6 100644 --- a/MantidPlot/mantidplotrc.py +++ b/MantidPlot/mantidplotrc.py @@ -23,8 +23,6 @@ if __name__ == '__main__': except ImportError: pass - from six import iteritems as _iteritems - # Import MantidPlot python commands import mantidplot from mantidplot import * @@ -70,7 +68,7 @@ if __name__ == '__main__': return [] from mantid.simpleapi import _get_function_spec keywords = [] - for name,obj in _iteritems(definitions): + for name,obj in definitions.items(): if name.startswith('_') : continue if _inspect.isclass(obj) or _inspect.ismodule(obj): continue diff --git a/MantidPlot/pymantidplot/__init__.py b/MantidPlot/pymantidplot/__init__.py index c8d9a29887ba5a7c2e1b81a5f3035d0131b95417..c306ad7e1641d9e843651079f025f396b15d590d 100644 --- a/MantidPlot/pymantidplot/__init__.py +++ b/MantidPlot/pymantidplot/__init__.py @@ -8,8 +8,7 @@ MantidPlot module to gain access to plotting functions etc. Requires that the main script be run from within MantidPlot """ -from __future__ import (absolute_import, division, - print_function) + # Requires MantidPlot try: import _qti @@ -34,8 +33,6 @@ import mantidqtpython from mantidqtpython import GraphOptions # noqa # historical names in MantidPlot from mantidqtpython import MantidQt as _MantidQt -from six.moves import range - # (a) don't need a proxy & (b) can be constructed from python or (c) have enumerations within them from _qti import (PlotSymbol, ImageSymbol, ArrowMarker, ImageMarker, InstrumentView) # noqa @@ -63,6 +60,7 @@ def _get_analysis_data_service(): # -------------------------- Wrapped MantidPlot functions ----------------- + def runPythonScript(code, asynchronous=False, quiet=False, redirect=True): """ Redirects the runPythonScript method to the app object diff --git a/MantidPlot/pymantidplot/mpl/backend_mtdqt4agg.py b/MantidPlot/pymantidplot/mpl/backend_mtdqt4agg.py index 5fc30c9d8e030be57c0df89a3c85d75b8ca21154..3d3fdceba7f5699eb438b848305a6097493bb77c 100644 --- a/MantidPlot/pymantidplot/mpl/backend_mtdqt4agg.py +++ b/MantidPlot/pymantidplot/mpl/backend_mtdqt4agg.py @@ -13,8 +13,7 @@ mode for MantidPlot is to run all python scripts asynchronously. Providing this backend allows users to work with the standard matplotlib API without modification """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) + try: # Newer matplotlib has qt_compat @@ -26,8 +25,6 @@ except ImportError: # Import everything from the *real* matplotlib backend from matplotlib.backends.backend_qt4agg import * from matplotlib.figure import Figure -import six - # Remove the implementations of new_figure_manager_*. We replace them below del new_figure_manager try: @@ -71,7 +68,7 @@ class QAppThreadCall(QtCore.QObject): QtCore.QMetaObject.invokeMethod(self, "on_call", QtCore.Qt.BlockingQueuedConnection) if self._exc_info is not None: - six.reraise(*self._exc_info) + raise self._exc_info[1].with_traceback(self._exc_info[2]) return self._result @QtCore.pyqtSlot() diff --git a/MantidPlot/pymantidplot/proxies.py b/MantidPlot/pymantidplot/proxies.py index 617b336c94729fa3b12fad9e00bb30f1bd269a7f..67fa08586b09d82de69b1bb92350f1dacde8a4f4 100644 --- a/MantidPlot/pymantidplot/proxies.py +++ b/MantidPlot/pymantidplot/proxies.py @@ -9,10 +9,6 @@ Module containing classes that act as proxies to the various MantidPlot gui obje accessible from python. They listen for the QObject 'destroyed' signal and set the wrapped reference to None, thus ensuring that further attempts at access do not cause a crash. """ -from __future__ import (absolute_import, division, - print_function) -from six.moves import range - from PyQt4 import QtCore, QtGui from PyQt4.QtCore import Qt, pyqtSlot try: @@ -26,6 +22,7 @@ import mantidqtpython #--------------------------- MultiThreaded Access ---------------------------- #----------------------------------------------------------------------------- + class CrossThreadCall(QtCore.QObject): """ Defines a dispatch call that marshals @@ -94,6 +91,7 @@ class CrossThreadCall(QtCore.QObject): argtype = int return argtype + def threadsafe_call(callable, *args, **kwargs): """ Calls the given function with the given arguments @@ -104,6 +102,7 @@ def threadsafe_call(callable, *args, **kwargs): caller = CrossThreadCall(callable) return caller.dispatch(*args, **kwargs) + def new_proxy(classType, callable, *args, **kwargs): """ Calls the callable object with the given args and kwargs dealing @@ -124,6 +123,7 @@ def new_proxy(classType, callable, *args, **kwargs): #--------------------------- Proxy Objects ----------------------------------- #----------------------------------------------------------------------------- + class QtProxyObject(QtCore.QObject): """Generic Proxy object for wrapping Qt C++ QObjects. This holds the QObject internally and passes methods to it. @@ -212,6 +212,8 @@ class QtProxyObject(QtCore.QObject): self.__obj = obj #----------------------------------------------------------------------------- + + class MDIWindow(QtProxyObject): """Proxy for the _qti.MDIWindow object. Also used for subclasses that do not need any methods intercepted (e.g. Table, Note, Matrix) @@ -223,6 +225,8 @@ class MDIWindow(QtProxyObject): return new_proxy(Folder, self._getHeldObject().folder) #----------------------------------------------------------------------------- + + class Graph(MDIWindow): """Proxy for the _qti.Graph object. """ @@ -440,6 +444,8 @@ class Graph3D(QtProxyObject): threadsafe_call(self._getHeldObject().setMatrix, matrix._getHeldObject()) #----------------------------------------------------------------------------- + + class Spectrogram(QtProxyObject): """Proxy for the _qti.Spectrogram object. """ @@ -451,6 +457,8 @@ class Spectrogram(QtProxyObject): return new_proxy(QtProxyObject, self._getHeldObject().matrix) #----------------------------------------------------------------------------- + + class Folder(QtProxyObject): """Proxy for the _qti.Folder object. """ @@ -546,6 +554,8 @@ class Folder(QtProxyObject): return new_proxy(Folder, self._getHeldObject().rootFolder) #----------------------------------------------------------------------------- + + class MantidMatrix(MDIWindow): """Proxy for the _qti.MantidMatrix object. """ @@ -575,6 +585,8 @@ class MantidMatrix(MDIWindow): return new_proxy(Graph, self._getHeldObject().plotGraph2D, type) #----------------------------------------------------------------------------- + + class InstrumentView(MDIWindow): """Proxy for the instrument window """ @@ -755,6 +767,8 @@ class SliceViewerWindowProxy(QtProxyObject): return liner #----------------------------------------------------------------------------- + + def getWorkspaceNames(source): """Takes a "source", which could be a WorkspaceGroup, or a list of workspaces, or a list of names, and converts @@ -802,6 +816,8 @@ def getWorkspaceNames(source): return ws_names #----------------------------------------------------------------------------- + + class ProxyCompositePeaksPresenter(QtProxyObject): def __init__(self, toproxy): QtProxyObject.__init__(self,toproxy) @@ -820,6 +836,8 @@ class ProxyCompositePeaksPresenter(QtProxyObject): return new_proxy(QtProxyObject, self._getHeldObject().getPeaksPresenter, to_present) #----------------------------------------------------------------------------- + + class SliceViewerProxy(QtProxyObject): """Proxy for a C++ SliceViewer widget. """ @@ -921,26 +939,32 @@ class TiledWindowProxy(QtProxyObject): """ threadsafe_call(self._getHeldObject().clear) + def showHelpPage(page_name=None): """Show a page in the help system""" window = threadsafe_call(mantidqtpython.MantidQt.API.InterfaceManager().showHelpPage, page_name) + def showWikiPage(page_name=None): """Show a wiki page through the help system""" window = threadsafe_call(mantidqtpython.MantidQt.API.InterfaceManager().showWikiPage, page_name) + def showAlgorithmHelp(algorithm=None, version=-1): """Show an algorithm help page""" window = threadsafe_call(mantidqtpython.MantidQt.API.InterfaceManager().showAlgorithmHelp, algorithm, version) + def showConceptHelp(name=None): """Show a concept help page""" window = threadsafe_call(mantidqtpython.MantidQt.API.InterfaceManager().showConceptHelp, name) + def showFitFunctionHelp(name=None): """Show a fit function help page""" window = threadsafe_call(mantidqtpython.MantidQt.API.InterfaceManager().showFitFunctionHelp, name) + def showCustomInterfaceHelp(name=None): """Show a custom interface help page""" window = threadsafe_call(mantidqtpython.MantidQt.API.InterfaceManager().showCustomInterfaceHelp, name) diff --git a/MantidPlot/pymantidplot/qtiplot.py b/MantidPlot/pymantidplot/qtiplot.py index 9a3ebdf99bed5bd2b582129e9f229b4923196bc7..70e60bc0a770ed5cf60125b26a97a62983bee23d 100644 --- a/MantidPlot/pymantidplot/qtiplot.py +++ b/MantidPlot/pymantidplot/qtiplot.py @@ -11,8 +11,7 @@ qti-based MantidPlot Python plotting interface As with other MantidPlot modules, this has to run from within MantidPlot """ -from __future__ import (absolute_import, division, - print_function) + # Require MantidPlot try: @@ -25,6 +24,8 @@ from PyQt4 import QtCore #----------------------------------------------------------------------------- # Intercept qtiplot "plot" command and forward to plotSpectrum for a workspace + + def plot(source, *args, **kwargs): """Create a new plot given a workspace, table or matrix. diff --git a/MantidPlot/src/ApplicationWindow.cpp b/MantidPlot/src/ApplicationWindow.cpp index a403111cc381f952ab5a9833f4f60e0c5a4aac4f..b5af9c6165523e02640d09044a7c2cc83e04dbee 100644 --- a/MantidPlot/src/ApplicationWindow.cpp +++ b/MantidPlot/src/ApplicationWindow.cpp @@ -180,6 +180,7 @@ #include <gsl/gsl_sort.h> #include <boost/regex.hpp> +#include <utility> #include <Poco/Path.h> @@ -3161,7 +3162,7 @@ void ApplicationWindow::initTable(Table *w, const QString &caption) { * base */ TableStatistics *ApplicationWindow::newTableStatistics(Table *base, int type, - QList<int> target, + const QList<int> &target, const QString &caption) { TableStatistics *s = new TableStatistics(scriptingEnv(), this, base, (TableStatistics::Type)type, target); @@ -4231,7 +4232,7 @@ void ApplicationWindow::importASCII( const QString &local_column_separator, int local_ignored_lines, bool local_rename_columns, bool local_strip_spaces, bool local_simplify_spaces, bool local_import_comments, - bool update_dec_separators, QLocale local_separators, + bool update_dec_separators, const QLocale &local_separators, const QString &local_comment_string, bool import_read_only, int endLineChar, const QString &sepforloadAscii) { if (files.isEmpty()) @@ -6158,7 +6159,7 @@ void ApplicationWindow::loadDataFile() { saveSettings(); // save new list of recent files } -void ApplicationWindow::loadDataFileByName(QString fn) { +void ApplicationWindow::loadDataFileByName(const QString &fn) { QFileInfo fnInfo(fn); AlgorithmInputHistory::Instance().setPreviousDirectory( fnInfo.absoluteDir().path()); @@ -13709,7 +13710,7 @@ void ApplicationWindow::updateRecentProjectsList() { recentProjects[i]); } -void ApplicationWindow::updateRecentFilesList(QString fname) { +void ApplicationWindow::updateRecentFilesList(const QString &fname) { if (!fname.isEmpty()) { recentFiles.removeAll(fname); recentFiles.push_front(fname); @@ -16791,8 +16792,8 @@ bool ApplicationWindow::isOfType(const QObject *obj, * @param sourceFile The full path to the .project file * @return True is loading was successful, false otherwise */ -bool ApplicationWindow::loadProjectRecovery(std::string sourceFile, - std::string recoveryFolder) { +bool ApplicationWindow::loadProjectRecovery(const std::string &sourceFile, + const std::string &recoveryFolder) { // Wait on this thread until scriptWindow is finished (Should be a seperate // thread) do { @@ -16801,7 +16802,7 @@ bool ApplicationWindow::loadProjectRecovery(std::string sourceFile, const bool isRecovery = true; ProjectSerialiser projectWriter(this, isRecovery); // File version is not applicable to project recovery - so set to 0 - const auto loadSuccess = projectWriter.load(sourceFile, 0); + const auto loadSuccess = projectWriter.load(std::move(sourceFile), 0); // Handle the removal of old checkpoints and start project saving again Poco::Path deletePath(recoveryFolder); @@ -16820,7 +16821,7 @@ bool ApplicationWindow::loadProjectRecovery(std::string sourceFile, * @param destination:: The full path to write the recovery file to * @return True if saving is successful, false otherwise */ -bool ApplicationWindow::saveProjectRecovery(std::string destination) { +bool ApplicationWindow::saveProjectRecovery(const std::string &destination) { const bool isRecovery = true; ProjectSerialiser projectWriter(this, isRecovery); return projectWriter.save(QString::fromStdString(destination)); diff --git a/MantidPlot/src/ApplicationWindow.h b/MantidPlot/src/ApplicationWindow.h index 0bc349a2f26071d732fd8fb884a755a10ed4ffb2..df62345d86aab9087af8c83b884fdd53c9dd98d7 100644 --- a/MantidPlot/src/ApplicationWindow.h +++ b/MantidPlot/src/ApplicationWindow.h @@ -233,7 +233,7 @@ public slots: /// Load mantid data files using generic load algorithm, opening user dialog void loadDataFile(); /// Load mantid data files (generic load algorithm) - void loadDataFileByName(QString fn); + void loadDataFileByName(const QString &fn); /// Open from the list of recent files void openRecentFile(QAction *action); @@ -492,7 +492,7 @@ public slots: int local_ignored_lines, bool local_rename_columns, bool local_strip_spaces, bool local_simplify_spaces, bool local_import_comments, bool update_dec_separators, - QLocale local_separators, + const QLocale &local_separators, const QString &local_comment_string, bool import_read_only, int endLineChar, const QString &sepforloadAscii); void exportAllTables(const QString &sep, bool colNames, bool colComments, @@ -503,7 +503,7 @@ public slots: //! recalculate selected cells of current table void recalculateTable(); - TableStatistics *newTableStatistics(Table *base, int type, QList<int>, + TableStatistics *newTableStatistics(Table *base, int type, const QList<int> &, const QString &caption = QString::null); //@} @@ -916,7 +916,7 @@ public slots: void updateRecentProjectsList(); //! Inserts file name in the list of recent files (if fname not empty) and // updates the "recent files" menu - void updateRecentFilesList(QString fname = ""); + void updateRecentFilesList(const QString &fname = ""); //! Open QtiPlot homepage in external browser void showHomePage(); //! Open bug tracking system at berliOS in external browser @@ -1123,11 +1123,12 @@ public slots: bool isOfType(const QObject *obj, const char *toCompare) const; - bool loadProjectRecovery(std::string sourceFile, std::string recoveryFolder); + bool loadProjectRecovery(const std::string &sourceFile, + const std::string &recoveryFolder); // The string must be copied from the other thread in saveProjectRecovery /// Saves the current project as part of recovery auto saving - bool saveProjectRecovery(std::string destination); + bool saveProjectRecovery(const std::string &destination); /// Checks for and attempts project recovery if required void checkForProjectRecovery(); diff --git a/MantidPlot/src/AssociationsDialog.cpp b/MantidPlot/src/AssociationsDialog.cpp index c2f5329ef7b454fb781d78851d8b622b62db79d0..88be52400b02868861f3c38c48c90cd91dc662c3 100644 --- a/MantidPlot/src/AssociationsDialog.cpp +++ b/MantidPlot/src/AssociationsDialog.cpp @@ -45,8 +45,9 @@ #include <QMessageBox> #include <QPushButton> #include <QTableWidget> +#include <utility> -AssociationsDialog::AssociationsDialog(Graph *g, Qt::WFlags fl) +AssociationsDialog::AssociationsDialog(Graph *g, const Qt::WFlags &fl) : QDialog(g, fl) { setObjectName("AssociationsDialog"); setWindowTitle(tr("MantidPlot - Plot Associations")); @@ -192,7 +193,7 @@ QString AssociationsDialog::plotAssociation(const QString &text) { } void AssociationsDialog::initTablesList(QList<MdiSubWindow *> lst, int curve) { - tables = lst; + tables = std::move(lst); active_table = nullptr; if (curve < 0 || curve >= static_cast<int>(associations->count())) diff --git a/MantidPlot/src/AssociationsDialog.h b/MantidPlot/src/AssociationsDialog.h index d247ba76570159944f0422160f9774c42431c848..502b6f6df429ebdc7bc436ff106e5983e5144701 100644 --- a/MantidPlot/src/AssociationsDialog.h +++ b/MantidPlot/src/AssociationsDialog.h @@ -46,7 +46,7 @@ class AssociationsDialog : public QDialog { Q_OBJECT public: - AssociationsDialog(Graph *g, Qt::WFlags fl = nullptr); + AssociationsDialog(Graph *g, const Qt::WFlags &fl = nullptr); void initTablesList(QList<MdiSubWindow *> lst, int curve); diff --git a/MantidPlot/src/AxesDialog.cpp b/MantidPlot/src/AxesDialog.cpp index 8548910e0720d35d931f9177eeefb32704387316..912115a736a1ad8132d46528fc6f14dfd4e570a5 100644 --- a/MantidPlot/src/AxesDialog.cpp +++ b/MantidPlot/src/AxesDialog.cpp @@ -1496,7 +1496,7 @@ Mantid::Kernel::Logger g_log("AxisDialog"); * @param g :: the graph the dialog is settign the options for * @param fl :: The QT flags for this window */ -AxesDialog::AxesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl) +AxesDialog::AxesDialog(ApplicationWindow *app, Graph *g, const Qt::WFlags &fl) : QDialog(g, fl), m_app(app), m_graph(g) { QPixmap image4((const char **)image4_data); QPixmap image5((const char **)image5_data); diff --git a/MantidPlot/src/AxesDialog.h b/MantidPlot/src/AxesDialog.h index 2c22a6e3db8e899ebada3fd6f071e38bf3945c94..5396b1fcdf6a9d7495dba3f9e76624400f0635f8 100644 --- a/MantidPlot/src/AxesDialog.h +++ b/MantidPlot/src/AxesDialog.h @@ -71,7 +71,7 @@ class AxesDialog : public QDialog { Q_OBJECT public: - AxesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl = nullptr); + AxesDialog(ApplicationWindow *app, Graph *g, const Qt::WFlags &fl = nullptr); ~AxesDialog() override; public slots: diff --git a/MantidPlot/src/BoxCurve.h b/MantidPlot/src/BoxCurve.h index 55f8019398dbbf1c4c7ba68ce9610f23308cfef9..edc1839f79e6e63e1ced972cba9bcea9d9cd4873 100644 --- a/MantidPlot/src/BoxCurve.h +++ b/MantidPlot/src/BoxCurve.h @@ -33,6 +33,8 @@ #include <qwt_plot.h> #include <qwt_symbol.h> +#include <utility> + //! Box curve class BoxCurve : public DataCurve { public: @@ -97,7 +99,7 @@ private: class QwtSingleArrayData : public QwtData { public: QwtSingleArrayData(const double x, QwtArray<double> y, size_t) { - d_y = y; + d_y = std::move(y); d_x = x; }; diff --git a/MantidPlot/src/ColorMapDialog.cpp b/MantidPlot/src/ColorMapDialog.cpp index ec3bd737efdb263d9ca698c27a3041f6cfc06c7d..e161f8a3505d93a0a7bd47f2fb537532e4d4434f 100644 --- a/MantidPlot/src/ColorMapDialog.cpp +++ b/MantidPlot/src/ColorMapDialog.cpp @@ -33,7 +33,7 @@ #include <QLayout> #include <QPushButton> -ColorMapDialog::ColorMapDialog(QWidget *parent, Qt::WFlags fl) +ColorMapDialog::ColorMapDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), applyBtn(nullptr), closeBtn(nullptr), editor(nullptr), d_matrix(nullptr) { setObjectName("ColorMapDialog"); diff --git a/MantidPlot/src/ColorMapDialog.h b/MantidPlot/src/ColorMapDialog.h index 916b1a9d156f6f0e2fec4168c8d99182bed6eb40..27811a06fefee45b381e1749f55ed4ee5f0199f1 100644 --- a/MantidPlot/src/ColorMapDialog.h +++ b/MantidPlot/src/ColorMapDialog.h @@ -37,7 +37,7 @@ class ColorMapDialog : public QDialog { Q_OBJECT public: - ColorMapDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + ColorMapDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMatrix(Matrix *m); protected slots: diff --git a/MantidPlot/src/ConfigDialog.cpp b/MantidPlot/src/ConfigDialog.cpp index 92fd15419a6677bc93e7c4bd5baf987d1bdbaf6b..5e6fb1596b8d98fab61fbfbf97d46982f7a3bbcf 100644 --- a/MantidPlot/src/ConfigDialog.cpp +++ b/MantidPlot/src/ConfigDialog.cpp @@ -1541,7 +1541,7 @@ void ConfigDialog::correctTreePatrialTicks(QTreeWidgetItem &topLevelCat) { } QTreeWidgetItem * -ConfigDialog::createCheckedTreeItem(QString name, +ConfigDialog::createCheckedTreeItem(const QString &name, Qt::CheckState checkBoxState) { QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(name)); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); diff --git a/MantidPlot/src/ConfigDialog.h b/MantidPlot/src/ConfigDialog.h index 669c79f9e914c9d65df70840e58e5f98436b81e2..e68e6907f6595ebe8a78dbecde6e5e4528601242 100644 --- a/MantidPlot/src/ConfigDialog.h +++ b/MantidPlot/src/ConfigDialog.h @@ -178,7 +178,7 @@ private: void updateMdPlottingSettings(); void setupMdPlottingConnections(); - QTreeWidgetItem *createCheckedTreeItem(QString name, + QTreeWidgetItem *createCheckedTreeItem(const QString &name, Qt::CheckState checkBoxState); QStringList buildHiddenCategoryString(QTreeWidgetItem *parent = nullptr); diff --git a/MantidPlot/src/CurveRangeDialog.cpp b/MantidPlot/src/CurveRangeDialog.cpp index 6af557138fad811f6cda0293c24f60b2640e9d35..0f2159bdb3b854df48b2bc65113cf7e7457b548a 100644 --- a/MantidPlot/src/CurveRangeDialog.cpp +++ b/MantidPlot/src/CurveRangeDialog.cpp @@ -27,7 +27,7 @@ #include <QPushButton> #include <QSpinBox> -CurveRangeDialog::CurveRangeDialog(QWidget *parent, Qt::WFlags fl) +CurveRangeDialog::CurveRangeDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), d_curve(nullptr), d_graph(nullptr) { setWindowTitle(tr("MantidPlot - Plot range")); setObjectName("CurveRangeDialog"); diff --git a/MantidPlot/src/CurveRangeDialog.h b/MantidPlot/src/CurveRangeDialog.h index 1f36476e890ba4debb74be8fba60bfe834f7620b..28749672cab67d1850eff60b74bc6fd71fef661f 100644 --- a/MantidPlot/src/CurveRangeDialog.h +++ b/MantidPlot/src/CurveRangeDialog.h @@ -30,7 +30,7 @@ class CurveRangeDialog : public QDialog { Q_OBJECT public: - CurveRangeDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + CurveRangeDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); public slots: void setCurveToModify(Graph *g, int curve); diff --git a/MantidPlot/src/CurvesDialog.cpp b/MantidPlot/src/CurvesDialog.cpp index 9c4b51f0fc4e85e7b488b25edb639ed5564e9184..0539402541b780e71049a0ed4ce79e1d71663851 100644 --- a/MantidPlot/src/CurvesDialog.cpp +++ b/MantidPlot/src/CurvesDialog.cpp @@ -56,7 +56,8 @@ using namespace MantidQt::API; -CurvesDialog::CurvesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl) +CurvesDialog::CurvesDialog(ApplicationWindow *app, Graph *g, + const Qt::WFlags &fl) : QDialog(g, fl), d_app(app), d_graph(g) { if (!app) { throw std::logic_error( diff --git a/MantidPlot/src/CurvesDialog.h b/MantidPlot/src/CurvesDialog.h index 90fb0c8a74ec07498243dc5d1552669b84651eef..9d113a1a1dc7638b6fc426b594db7b61c5bf9310 100644 --- a/MantidPlot/src/CurvesDialog.h +++ b/MantidPlot/src/CurvesDialog.h @@ -45,7 +45,8 @@ class CurvesDialog : public QDialog { Q_OBJECT public: - CurvesDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl = nullptr); + CurvesDialog(ApplicationWindow *app, Graph *g, + const Qt::WFlags &fl = nullptr); ~CurvesDialog() override; private slots: diff --git a/MantidPlot/src/CustomActionDialog.cpp b/MantidPlot/src/CustomActionDialog.cpp index 1f6a1206e078697c2ecf1fc88f560d8b37ac09a5..51b62e93ba6f33012cb8316c05e7b07f444f1ad5 100644 --- a/MantidPlot/src/CustomActionDialog.cpp +++ b/MantidPlot/src/CustomActionDialog.cpp @@ -36,7 +36,7 @@ #include <QShortcut> #include <QToolBar> -CustomActionDialog::CustomActionDialog(QWidget *parent, Qt::WFlags fl) +CustomActionDialog::CustomActionDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot") + " - " + tr("Add Custom Action")); diff --git a/MantidPlot/src/CustomActionDialog.h b/MantidPlot/src/CustomActionDialog.h index 2cf37166bcea0669776ee986c277e86c812470e2..bc7d4c3aa4a49ea50c847108e451fe5f4fc3b241 100644 --- a/MantidPlot/src/CustomActionDialog.h +++ b/MantidPlot/src/CustomActionDialog.h @@ -38,7 +38,7 @@ public: * @param parent :: parent widget (must be the application window!= * @param fl :: window flags */ - CustomActionDialog(QWidget *parent, Qt::WFlags fl = nullptr); + CustomActionDialog(QWidget *parent, const Qt::WFlags &fl = nullptr); private slots: void chooseIcon(); diff --git a/MantidPlot/src/DataSetDialog.cpp b/MantidPlot/src/DataSetDialog.cpp index 4a498d9a3b9717f251b287f211128712f2a7a650..b488801c6bec307e8135c14a1e821e9807097d28 100644 --- a/MantidPlot/src/DataSetDialog.cpp +++ b/MantidPlot/src/DataSetDialog.cpp @@ -40,7 +40,7 @@ #include <QVBoxLayout> DataSetDialog::DataSetDialog(const QString &text, ApplicationWindow *app, - Graph *g, Qt::WFlags fl) + Graph *g, const Qt::WFlags &fl) : QDialog(g, fl), d_app(app), d_graph(g) { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("MantidPlot - Select data set")); diff --git a/MantidPlot/src/DataSetDialog.h b/MantidPlot/src/DataSetDialog.h index dc60ab2abdfd6102b61c8f859e2b42442c630161..ebb4b7657ec0d3891d29deb1f2115e2d89f99915 100644 --- a/MantidPlot/src/DataSetDialog.h +++ b/MantidPlot/src/DataSetDialog.h @@ -45,7 +45,7 @@ class DataSetDialog : public QDialog { public: DataSetDialog(const QString &text, ApplicationWindow *app, Graph *g = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void accept() override; diff --git a/MantidPlot/src/ErrDialog.cpp b/MantidPlot/src/ErrDialog.cpp index addd11bef981d196c650afee560db67272f17094..47597ad6dbac4af06db1f79695ce97530416e6cd 100644 --- a/MantidPlot/src/ErrDialog.cpp +++ b/MantidPlot/src/ErrDialog.cpp @@ -45,7 +45,7 @@ #include <QVBoxLayout> #include <QWidget> -ErrDialog::ErrDialog(ApplicationWindow *parent, Qt::WFlags fl) +ErrDialog::ErrDialog(ApplicationWindow *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setFocusPolicy(Qt::StrongFocus); setSizeGripEnabled(true); @@ -166,7 +166,7 @@ void ErrDialog::setCurveNames(const QStringList &names) { nameLabel->addItems(names); } -void ErrDialog::setSrcTables(QList<MdiSubWindow *> tables) { +void ErrDialog::setSrcTables(const QList<MdiSubWindow *> &tables) { if (tables.isEmpty()) return; diff --git a/MantidPlot/src/ErrDialog.h b/MantidPlot/src/ErrDialog.h index 84287351570a7fc6cce13848a036048683ab51f7..83ac907e708391c41ee26df6f484ca801197988a 100644 --- a/MantidPlot/src/ErrDialog.h +++ b/MantidPlot/src/ErrDialog.h @@ -52,7 +52,7 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - ErrDialog(ApplicationWindow *parent, Qt::WFlags fl = nullptr); + ErrDialog(ApplicationWindow *parent, const Qt::WFlags &fl = nullptr); private: QLabel *textLabel1; @@ -82,7 +82,7 @@ public slots: //! Supply the dialog with a curves list void setCurveNames(const QStringList &names); //! Supply the dialog with a tables list - void setSrcTables(QList<MdiSubWindow *> tables); + void setSrcTables(const QList<MdiSubWindow *> &tables); //! Select a table void selectSrcTable(int tabnr); diff --git a/MantidPlot/src/ExpDecayDialog.cpp b/MantidPlot/src/ExpDecayDialog.cpp index d39b38573f46c998e9ad400862941c3370baa372..e13b229a77d9397ab0f82c79ca1063ed240736f3 100644 --- a/MantidPlot/src/ExpDecayDialog.cpp +++ b/MantidPlot/src/ExpDecayDialog.cpp @@ -43,7 +43,7 @@ #include <QMessageBox> #include <QPushButton> -ExpDecayDialog::ExpDecayDialog(int type, QWidget *parent, Qt::WFlags fl) +ExpDecayDialog::ExpDecayDialog(int type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), fitter(nullptr), graph(nullptr), buttonFit(nullptr), buttonCancel(nullptr), boxName(nullptr), boxAmplitude(nullptr), boxFirst(nullptr), boxSecond(nullptr), boxThird(nullptr), diff --git a/MantidPlot/src/ExpDecayDialog.h b/MantidPlot/src/ExpDecayDialog.h index 8c3b04102aef8dda106cb7be411ec4d8fff45269..217f8c9d991a04498f9ffc10cdbe560d91466ac5 100644 --- a/MantidPlot/src/ExpDecayDialog.h +++ b/MantidPlot/src/ExpDecayDialog.h @@ -44,7 +44,8 @@ class ExpDecayDialog : public QDialog { Q_OBJECT public: - ExpDecayDialog(int type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + ExpDecayDialog(int type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void fit(); diff --git a/MantidPlot/src/ExportDialog.cpp b/MantidPlot/src/ExportDialog.cpp index 514ac1e30d72c906bf3c3287332bbd80b77b5d78..9ed732b74092dcea0a2d662008380c380dbef2d8 100644 --- a/MantidPlot/src/ExportDialog.cpp +++ b/MantidPlot/src/ExportDialog.cpp @@ -39,7 +39,7 @@ #include <QPushButton> ExportDialog::ExportDialog(const QString &tableName, QWidget *parent, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Export ASCII")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/ExportDialog.h b/MantidPlot/src/ExportDialog.h index 2d135b20e0d7a8978162101a99db31c505d7a568..bd5f0a65f9720fb39c4ba9e7db7acc9d0e4033c1 100644 --- a/MantidPlot/src/ExportDialog.h +++ b/MantidPlot/src/ExportDialog.h @@ -47,7 +47,7 @@ public: * @param fl :: window flags */ ExportDialog(const QString &tableName, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); private: void closeEvent(QCloseEvent *) override; diff --git a/MantidPlot/src/FFTDialog.cpp b/MantidPlot/src/FFTDialog.cpp index 6b529eed2df9c14f848b4542c0410731e6e9238a..3f0be090532e5ac80829ede8122d8d01be7a5562 100644 --- a/MantidPlot/src/FFTDialog.cpp +++ b/MantidPlot/src/FFTDialog.cpp @@ -49,7 +49,7 @@ #include <QPushButton> #include <QRadioButton> -FFTDialog::FFTDialog(int type, QWidget *parent, Qt::WFlags fl) +FFTDialog::FFTDialog(int type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), buttonOK(nullptr), buttonCancel(nullptr), forwardBtn(nullptr), backwardBtn(nullptr), boxName(nullptr), boxReal(nullptr), boxImaginary(nullptr), boxSampling(nullptr), diff --git a/MantidPlot/src/FFTDialog.h b/MantidPlot/src/FFTDialog.h index 9e92aaa6980dd03da6dc318b00bd185ee7ef4fcc..4e4ddb1d828155af185f2fd472c965ec85da99f0 100644 --- a/MantidPlot/src/FFTDialog.h +++ b/MantidPlot/src/FFTDialog.h @@ -47,7 +47,8 @@ class FFTDialog : public QDialog { public: enum DataType { onGraph = 0, onTable = 1, onMatrix = 2 }; - FFTDialog(int type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FFTDialog(int type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void setGraph(Graph *g); diff --git a/MantidPlot/src/FilterDialog.cpp b/MantidPlot/src/FilterDialog.cpp index 43dfe6aba9a0e79dc245f10e53fb787d3732ed27..b078fb7dad093da08c006ae5f63510a0da4abd62 100644 --- a/MantidPlot/src/FilterDialog.cpp +++ b/MantidPlot/src/FilterDialog.cpp @@ -42,7 +42,7 @@ #include <QMessageBox> #include <QPushButton> -FilterDialog::FilterDialog(int type, QWidget *parent, Qt::WFlags fl) +FilterDialog::FilterDialog(int type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr), buttonFilter(nullptr), buttonCancel(nullptr), boxName(nullptr), boxOffset(nullptr), boxStart(nullptr), boxEnd(nullptr), boxColor(nullptr) { diff --git a/MantidPlot/src/FilterDialog.h b/MantidPlot/src/FilterDialog.h index da87c9004897fcea96bf2369eb90e235550ed88a..c361fe97851159d7925adff7ef49c9501b2b8f31 100644 --- a/MantidPlot/src/FilterDialog.h +++ b/MantidPlot/src/FilterDialog.h @@ -43,7 +43,8 @@ class FilterDialog : public QDialog { Q_OBJECT public: - FilterDialog(int type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FilterDialog(int type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void setGraph(Graph *g); diff --git a/MantidPlot/src/FindDialog.cpp b/MantidPlot/src/FindDialog.cpp index e1ff277bd3b3dca260ed65b10df5ff888db47309..9fddeefb9b53d9819d210c03b286088c603b230f 100644 --- a/MantidPlot/src/FindDialog.cpp +++ b/MantidPlot/src/FindDialog.cpp @@ -41,7 +41,8 @@ #include <QRegExp> #include <QVBoxLayout> -FindDialog::FindDialog(QWidget *parent, Qt::WFlags fl) : QDialog(parent, fl) { +FindDialog::FindDialog(QWidget *parent, const Qt::WFlags &fl) + : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot") + " - " + tr("Find")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/FindDialog.h b/MantidPlot/src/FindDialog.h index 53a86644a516a41772da1680b055d32947558be2..3b74832f7a1e76cc11d988c7b0d78c6e3faa9191 100644 --- a/MantidPlot/src/FindDialog.h +++ b/MantidPlot/src/FindDialog.h @@ -42,7 +42,7 @@ class FindDialog : public QDialog { Q_OBJECT public: - FindDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FindDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); ~FindDialog() override; private: diff --git a/MantidPlot/src/FitDialog.cpp b/MantidPlot/src/FitDialog.cpp index 7bba4f70f2c4f8feb35e9a9c78d417319080f8fc..7524d652aed067759c22e32135ce8970557d16c7 100644 --- a/MantidPlot/src/FitDialog.cpp +++ b/MantidPlot/src/FitDialog.cpp @@ -56,7 +56,7 @@ using namespace MantidQt::API; -FitDialog::FitDialog(Graph *g, QWidget *parent, Qt::WFlags fl) +FitDialog::FitDialog(Graph *g, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setObjectName("FitDialog"); setWindowTitle(tr("MantidPlot - Fit Wizard")); @@ -1215,7 +1215,7 @@ void FitDialog::changeDataRange() { boxTo->setValue(qMax(start, end)); } -void FitDialog::setSrcTables(QList<MdiSubWindow *> tables) { +void FitDialog::setSrcTables(const QList<MdiSubWindow *> &tables) { if (tables.isEmpty()) { tableNamesBox->addItem(tr("No data tables")); colNamesBox->addItem(tr("No data tables")); diff --git a/MantidPlot/src/FitDialog.h b/MantidPlot/src/FitDialog.h index 5e8d0e4219bd6234136162e0efc4dd3e9b3665a3..664ee1aac000a7d70dfa74accd1eb1dab8a6dc21 100644 --- a/MantidPlot/src/FitDialog.h +++ b/MantidPlot/src/FitDialog.h @@ -44,9 +44,10 @@ class FitDialog : public QDialog { Q_OBJECT public: - FitDialog(Graph *g, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + FitDialog(Graph *g, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); - void setSrcTables(QList<MdiSubWindow *> tables); + void setSrcTables(const QList<MdiSubWindow *> &tables); protected: void closeEvent(QCloseEvent *e) override; diff --git a/MantidPlot/src/FloatingWindow.cpp b/MantidPlot/src/FloatingWindow.cpp index b25f7632c4ad91ac1c4d9981c5a14a1fcc6f0451..5a21ef17e6ab463fa37f50506cff79bf203de5f4 100644 --- a/MantidPlot/src/FloatingWindow.cpp +++ b/MantidPlot/src/FloatingWindow.cpp @@ -24,7 +24,8 @@ /** * Constructor. */ -FloatingWindow::FloatingWindow(ApplicationWindow *appWindow, Qt::WindowFlags f) +FloatingWindow::FloatingWindow(ApplicationWindow *appWindow, + const Qt::WindowFlags &f) : #ifdef Q_OS_WIN QMainWindow(appWindow, f), diff --git a/MantidPlot/src/FloatingWindow.h b/MantidPlot/src/FloatingWindow.h index 91626dcc4791ee6e3a38565f7a7b263c81306534..29bd00795552bbdbb23ed5934c9a7a04ce8792d4 100644 --- a/MantidPlot/src/FloatingWindow.h +++ b/MantidPlot/src/FloatingWindow.h @@ -19,7 +19,8 @@ class QSize; class FloatingWindow : public QMainWindow { Q_OBJECT public: - FloatingWindow(ApplicationWindow *appWindow, Qt::WindowFlags f = nullptr); + FloatingWindow(ApplicationWindow *appWindow, + const Qt::WindowFlags &f = nullptr); ~FloatingWindow() override; void setStaysOnTopFlag(); void removeStaysOnTopFlag(); diff --git a/MantidPlot/src/FunctionCurve.cpp b/MantidPlot/src/FunctionCurve.cpp index 0d658b286bf99ff411c09a373e45db170af2c31e..6ee0f4231f9d35133e736ebe150b5ecd87a668ac 100644 --- a/MantidPlot/src/FunctionCurve.cpp +++ b/MantidPlot/src/FunctionCurve.cpp @@ -243,8 +243,9 @@ void FunctionCurve::loadData(int points) { * @param wi :: An index of a histogram with the data. * @param peakRadius :: A peak radius to pass to the domain. */ -void FunctionCurve::loadMantidData(Mantid::API::MatrixWorkspace_const_sptr ws, - size_t wi, int peakRadius) { +void FunctionCurve::loadMantidData( + const Mantid::API::MatrixWorkspace_const_sptr &ws, size_t wi, + int peakRadius) { if (!d_variable.isEmpty() || d_formulas.isEmpty() || d_formulas[0] != "Mantid") return; diff --git a/MantidPlot/src/FunctionCurve.h b/MantidPlot/src/FunctionCurve.h index 6e4bb863f8fd0f190823f9cf551125153f7aacea..d92cfdfb8e1c48a9f93dfbc7210ba001111b98b6 100644 --- a/MantidPlot/src/FunctionCurve.h +++ b/MantidPlot/src/FunctionCurve.h @@ -84,8 +84,9 @@ public: void loadData(int points = 0); - void loadMantidData(boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws, - size_t wi, int peakRadius = 0); + void loadMantidData( + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws, + size_t wi, int peakRadius = 0); /// No error bars on this curve: Always return an empty list. QList<ErrorBarSettings *> errorBarSettingsList() const override { diff --git a/MantidPlot/src/FunctionDialog.cpp b/MantidPlot/src/FunctionDialog.cpp index c21971bc176dd9784a439701ae4713f3e02f939a..b40241efae5ab093f5203a7bcb29c4ea96c4bb97 100644 --- a/MantidPlot/src/FunctionDialog.cpp +++ b/MantidPlot/src/FunctionDialog.cpp @@ -44,7 +44,8 @@ #include <QTextEdit> #include <QWidget> -FunctionDialog::FunctionDialog(ApplicationWindow *app, Graph *g, Qt::WFlags fl) +FunctionDialog::FunctionDialog(ApplicationWindow *app, Graph *g, + const Qt::WFlags &fl) : QDialog(g, fl), d_app(app), graph(g) { setObjectName("FunctionDialog"); setWindowTitle(tr("MantidPlot - Add function curve")); diff --git a/MantidPlot/src/FunctionDialog.h b/MantidPlot/src/FunctionDialog.h index 69389b2ff243042c766e6524eeced65c3f422dcf..f7a420196549b131ed3996f5f4253a1d4fc926a0 100644 --- a/MantidPlot/src/FunctionDialog.h +++ b/MantidPlot/src/FunctionDialog.h @@ -47,7 +47,7 @@ class FunctionDialog : public QDialog { public: FunctionDialog(ApplicationWindow *app, Graph *g = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); protected: QComboBox *boxXFunction; diff --git a/MantidPlot/src/Graph.cpp b/MantidPlot/src/Graph.cpp index 632d8d90f5674fe49b7d93b677ade6a7c6407d05..07c10ddf1f89e48ee1526def97ea03e1480c1ebe 100644 --- a/MantidPlot/src/Graph.cpp +++ b/MantidPlot/src/Graph.cpp @@ -126,7 +126,8 @@ namespace { Mantid::Kernel::Logger g_log("Graph"); } // namespace -Graph::Graph(int x, int y, int width, int height, QWidget *parent, Qt::WFlags f) +Graph::Graph(int x, int y, int width, int height, QWidget *parent, + const Qt::WFlags &f) : QWidget(parent, f) { setWindowFlags(f); n_curves = 0; @@ -1183,7 +1184,7 @@ void Graph::setScale(QwtPlot::Axis axis, ScaleTransformation::Type scaleType) { * @param axis :: the scale to change either QwtPlot::xBottom or QwtPlot::yLeft * @param logOrLin :: either "log" or "linear" */ -void Graph::setScale(QwtPlot::Axis axis, QString logOrLin) { +void Graph::setScale(QwtPlot::Axis axis, const QString &logOrLin) { if (logOrLin == "log") { setScale(axis, ScaleTransformation::Log10); } else if (logOrLin == "linear") { @@ -2842,7 +2843,7 @@ PlotCurve *Graph::insertCurve(Table *w, const QString &xColName, return c; } -PlotCurve *Graph::insertCurve(QString workspaceName, int index, bool err, +PlotCurve *Graph::insertCurve(const QString &workspaceName, int index, bool err, GraphOptions::CurveType style, bool distribution) { return (new MantidMatrixCurve(workspaceName, this, index, @@ -4954,7 +4955,7 @@ void Graph::setCurveLineColor(int curveIndex, int colorIndex) { } } -void Graph::setCurveLineColor(int curveIndex, QColor qColor) { +void Graph::setCurveLineColor(int curveIndex, const QColor &qColor) { QwtPlotCurve *c = curve(curveIndex); if (c) { QPen pen = c->pen(); diff --git a/MantidPlot/src/Graph.h b/MantidPlot/src/Graph.h index 30d7f397b380f59eb1dd07ab48095ba2b3024718..075294f31896773bce78ece4bf61562a1433f922 100644 --- a/MantidPlot/src/Graph.h +++ b/MantidPlot/src/Graph.h @@ -158,7 +158,7 @@ class Graph : public QWidget { public: Graph(int x = 0, int y = 0, int width = 500, int height = 400, - QWidget *parent = nullptr, Qt::WFlags f = nullptr); + QWidget *parent = nullptr, const Qt::WFlags &f = nullptr); ~Graph() override; enum Ticks { NoTicks = 0, Out = 1, InOut = 2, In = 3 }; @@ -265,7 +265,7 @@ public slots: const QString &yColName, int style, int startRow = 0, int endRow = -1); PlotCurve * - insertCurve(QString workspaceName, int index, bool err = false, + insertCurve(const QString &workspaceName, int index, bool err = false, GraphOptions::CurveType style = GraphOptions::Unspecified, bool distribution = false); PlotCurve *insertCurve(PlotCurve *c, int lineWidth = -1, @@ -338,7 +338,7 @@ public slots: void setCurveStyle(int index, int s); void setCurveFullRange(int curveIndex); void setCurveLineColor(int curveIndex, int colorIndex); - void setCurveLineColor(int curveIndex, QColor qColor); + void setCurveLineColor(int curveIndex, const QColor &qColor); void setCurveLineStyle(int curveIndex, Qt::PenStyle style); void setCurveLineWidth(int curveIndex, double width); void setGrayScale(); @@ -417,7 +417,7 @@ public slots: bool log10AfterBreak = false, int breakWidth = 4, bool breakDecoration = true, double nth_power = 2.0); void setScale(QwtPlot::Axis axis, ScaleTransformation::Type scaleType); - void setScale(QwtPlot::Axis axis, QString logOrLin); + void setScale(QwtPlot::Axis axis, const QString &logOrLin); double axisStep(int axis) { return d_user_step[axis]; }; //! Set the axis scale void setAxisScale(int axis, double start, double end, int scaleType = -1, diff --git a/MantidPlot/src/Graph3D.cpp b/MantidPlot/src/Graph3D.cpp index 69b403023409bdb9a95ed3efa9012bd72ed451dc..1521f5326e8303b577261f04db13060eef958614 100644 --- a/MantidPlot/src/Graph3D.cpp +++ b/MantidPlot/src/Graph3D.cpp @@ -107,7 +107,7 @@ Triple UserParametricSurface::operator()(double u, double v) { } Graph3D::Graph3D(const QString &label, QWidget *parent, const char *name, - Qt::WFlags f) + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f) { initPlot(); } @@ -2346,7 +2346,7 @@ void Graph3D::setDataColorMap(const QString &fileName) { sp->updateGL(); } -bool Graph3D::openColorMap(ColorVector &cv, QString fname) { +bool Graph3D::openColorMap(ColorVector &cv, const QString &fname) { if (fname.isEmpty()) return false; diff --git a/MantidPlot/src/Graph3D.h b/MantidPlot/src/Graph3D.h index d101f7106ce59e8b90a45e934205be45dc685130..f326a107fac740e1a39c7b6b735858c156fc0055 100644 --- a/MantidPlot/src/Graph3D.h +++ b/MantidPlot/src/Graph3D.h @@ -55,7 +55,7 @@ class Graph3D : public MdiSubWindow { public: Graph3D(const QString &label, QWidget *parent, const char *name = nullptr, - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~Graph3D() override; void initPlot(); @@ -317,7 +317,7 @@ public slots: QString colorMap() { return color_map; }; void setDataColorMap(const QString &fileName); - bool openColorMap(Qwt3D::ColorVector &cv, QString fname); + bool openColorMap(Qwt3D::ColorVector &cv, const QString &fname); void setMeshColor(const QColor &); void setAxesColor(const QColor &); diff --git a/MantidPlot/src/ImageDialog.cpp b/MantidPlot/src/ImageDialog.cpp index 0b46d1158792b84775a4b618793dff88ec111c8c..437b6dd5ab53dddeb4664cb35057d866de0e3bad 100644 --- a/MantidPlot/src/ImageDialog.cpp +++ b/MantidPlot/src/ImageDialog.cpp @@ -21,7 +21,7 @@ #include <QLabel> #include <QLayout> -ImageDialog::ImageDialog(QWidget *parent, Qt::WFlags fl) +ImageDialog::ImageDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), aspect_ratio(1.) { setObjectName("ImageDialog"); setWindowTitle(tr("MantidPlot - Image Geometry")); diff --git a/MantidPlot/src/ImageDialog.h b/MantidPlot/src/ImageDialog.h index a5936852a96fe0a455a9119cdaeaee884b31570b..db5ccc0dcd2294bc20462b2c129f80b6cc7e3203 100644 --- a/MantidPlot/src/ImageDialog.h +++ b/MantidPlot/src/ImageDialog.h @@ -39,7 +39,7 @@ class ImageDialog : public QDialog { Q_OBJECT public: - ImageDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + ImageDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setOrigin(const QPoint &o); void setSize(const QSize &size); diff --git a/MantidPlot/src/ImageExportDialog.cpp b/MantidPlot/src/ImageExportDialog.cpp index 9d0b967b9f37052ba8d5965603a949379d0880d7..dad44dcbdaa09d49e8b4c1bf4fb3b029f427eae8 100644 --- a/MantidPlot/src/ImageExportDialog.cpp +++ b/MantidPlot/src/ImageExportDialog.cpp @@ -42,7 +42,7 @@ #include <QStackedWidget> ImageExportDialog::ImageExportDialog(QWidget *parent, bool vector_options, - bool extended, Qt::WFlags flags) + bool extended, const Qt::WFlags &flags) : ExtensibleFileDialog(parent, extended, flags) { setWindowTitle(tr("MantidPlot - Choose a filename to save under")); setAcceptMode(QFileDialog::AcceptSave); diff --git a/MantidPlot/src/ImageExportDialog.h b/MantidPlot/src/ImageExportDialog.h index 20a4f0118ec8125374567673134cf7626d2d97e4..8c23e08525bd41842bd23559055a6d11e510f377 100644 --- a/MantidPlot/src/ImageExportDialog.h +++ b/MantidPlot/src/ImageExportDialog.h @@ -75,8 +75,8 @@ public: */ ImageExportDialog(QWidget *parent = nullptr, bool vector_options = true, bool extended = true, - Qt::WFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + const Qt::WFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); //! For vector formats: returns the output resolution the user selected, // defaulting to the screen resolution. int resolution() const { return d_resolution->value(); } diff --git a/MantidPlot/src/ImportASCIIDialog.cpp b/MantidPlot/src/ImportASCIIDialog.cpp index bd87d3897dbd421bb4982e6e918116252cceaa32..ee04b06f672f9fd6551db46eb2792fbf687248bf 100644 --- a/MantidPlot/src/ImportASCIIDialog.cpp +++ b/MantidPlot/src/ImportASCIIDialog.cpp @@ -50,7 +50,7 @@ #include <gsl/gsl_math.h> ImportASCIIDialog::ImportASCIIDialog(bool new_windows_only, QWidget *parent, - bool extended, Qt::WFlags flags) + bool extended, const Qt::WFlags &flags) : ExtensibleFileDialog(parent, extended, flags) { setWindowTitle(tr("MantidPlot - Import ASCII File(s)")); diff --git a/MantidPlot/src/ImportASCIIDialog.h b/MantidPlot/src/ImportASCIIDialog.h index cb767e331b6fcbc19d096c5bb6acbcfff379d26f..5b8b3e0e2b91b9030de820ae1ffd63f5df4dfd3b 100644 --- a/MantidPlot/src/ImportASCIIDialog.h +++ b/MantidPlot/src/ImportASCIIDialog.h @@ -117,8 +117,8 @@ public: */ ImportASCIIDialog(bool new_windows_only, QWidget *parent = nullptr, bool extended = true, - Qt::WFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + const Qt::WFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); //! Return the selected import mode /** diff --git a/MantidPlot/src/IntDialog.cpp b/MantidPlot/src/IntDialog.cpp index bc9edb76b73a4c599653b5f85d81b86c1539a924..d072c34e0f9c4bb5d1fc9486b7408ed5064d64e3 100644 --- a/MantidPlot/src/IntDialog.cpp +++ b/MantidPlot/src/IntDialog.cpp @@ -41,7 +41,7 @@ #include <QSpinBox> #include <QTextEdit> -IntDialog::IntDialog(QWidget *parent, Graph *g, Qt::WFlags fl) +IntDialog::IntDialog(QWidget *parent, Graph *g, const Qt::WFlags &fl) : QDialog(parent, fl), d_graph(g) { setObjectName("IntegrationDialog"); setAttribute(Qt::WA_DeleteOnClose); diff --git a/MantidPlot/src/IntDialog.h b/MantidPlot/src/IntDialog.h index 9036ec6136ae6b8297cf7a8e823d5cb3aac65bdd..f4e4257bb158d2ea262dc61077cb4d4b71a57985 100644 --- a/MantidPlot/src/IntDialog.h +++ b/MantidPlot/src/IntDialog.h @@ -44,7 +44,7 @@ class IntDialog : public QDialog { public: IntDialog(QWidget *parent = nullptr, Graph *g = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void accept() override; diff --git a/MantidPlot/src/InterpolationDialog.cpp b/MantidPlot/src/InterpolationDialog.cpp index 071c38c945376320d831c0599b4cab9f0423efb8..54a9bb20dfcc7a6ad00cfd753bbf13c48cc40b77 100644 --- a/MantidPlot/src/InterpolationDialog.cpp +++ b/MantidPlot/src/InterpolationDialog.cpp @@ -42,7 +42,7 @@ #include <QPushButton> #include <QSpinBox> -InterpolationDialog::InterpolationDialog(QWidget *parent, Qt::WFlags fl) +InterpolationDialog::InterpolationDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr) { setObjectName("InterpolationDialog"); setWindowTitle(tr("MantidPlot - Interpolation Options")); diff --git a/MantidPlot/src/InterpolationDialog.h b/MantidPlot/src/InterpolationDialog.h index 9008dddd68f704f80dfa3411afe9d65ff1309aaf..837dbf5702f3c8740f5800dddbb4bd756016d9b9 100644 --- a/MantidPlot/src/InterpolationDialog.h +++ b/MantidPlot/src/InterpolationDialog.h @@ -43,7 +43,8 @@ class InterpolationDialog : public QDialog { Q_OBJECT public: - InterpolationDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + InterpolationDialog(QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); public slots: void activateCurve(const QString &curveName); diff --git a/MantidPlot/src/LayerDialog.cpp b/MantidPlot/src/LayerDialog.cpp index cde51096487d695c4bb9d95948f7699429731764..f2a43002f88b1faaa35d4fc5b4f6791d9de6c04b 100644 --- a/MantidPlot/src/LayerDialog.cpp +++ b/MantidPlot/src/LayerDialog.cpp @@ -29,7 +29,7 @@ #include <QPushButton> #include <QSpinBox> -LayerDialog::LayerDialog(QWidget *parent, Qt::WFlags fl) +LayerDialog::LayerDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), multi_layer(nullptr) { setObjectName("LayerDialog"); setWindowTitle(tr("MantidPlot - Arrange Layers")); diff --git a/MantidPlot/src/LayerDialog.h b/MantidPlot/src/LayerDialog.h index bb13823e6246e58f7e0e8da0110cd61826c62d55..71967c37e4c436a034ece6a4c8553ded552763e4 100644 --- a/MantidPlot/src/LayerDialog.h +++ b/MantidPlot/src/LayerDialog.h @@ -30,7 +30,7 @@ class LayerDialog : public QDialog { Q_OBJECT public: - LayerDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + LayerDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMultiLayer(MultiLayer *g); protected slots: diff --git a/MantidPlot/src/LineDialog.cpp b/MantidPlot/src/LineDialog.cpp index 2a9a76ed66e20e6331ca8006a1b0071ddebbfaf7..afef704cd36dbc34256394a0891d4f2d75f2bd3c 100644 --- a/MantidPlot/src/LineDialog.cpp +++ b/MantidPlot/src/LineDialog.cpp @@ -29,7 +29,7 @@ #include <QGroupBox> #include <QSpinBox> -LineDialog::LineDialog(ArrowMarker *line, QWidget *parent, Qt::WFlags fl) +LineDialog::LineDialog(ArrowMarker *line, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { unitBox = nullptr; diff --git a/MantidPlot/src/LineDialog.h b/MantidPlot/src/LineDialog.h index 2f54e19f62598ddae864116f6efd4f914e19c410..875243a061855f39ef222a03d2dbfd117731d6cf 100644 --- a/MantidPlot/src/LineDialog.h +++ b/MantidPlot/src/LineDialog.h @@ -36,7 +36,7 @@ class LineDialog : public QDialog { public: LineDialog(ArrowMarker *line, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); enum Unit { ScaleCoordinates, Pixels }; diff --git a/MantidPlot/src/Mantid/AlgorithmMonitor.cpp b/MantidPlot/src/Mantid/AlgorithmMonitor.cpp index bb16b32ab27880056e0acff7a763c913230bf046..b090ed4438f4a76d951e74f2d3d0703a8e6fdb86 100644 --- a/MantidPlot/src/Mantid/AlgorithmMonitor.cpp +++ b/MantidPlot/src/Mantid/AlgorithmMonitor.cpp @@ -58,7 +58,7 @@ AlgorithmMonitor::~AlgorithmMonitor() { * * @param alg :: algorithm to monitor. */ -void AlgorithmMonitor::add(Mantid::API::IAlgorithm_sptr alg) { +void AlgorithmMonitor::add(const Mantid::API::IAlgorithm_sptr &alg) { lock(); alg->addObserver(m_finishedObserver); alg->addObserver(m_errorObserver); diff --git a/MantidPlot/src/Mantid/AlgorithmMonitor.h b/MantidPlot/src/Mantid/AlgorithmMonitor.h index 2f926b48b7bb6c54eaefb19ea9cb428f9679e418..aea9f1db805a44c4d69722266fc7d429aa27545c 100644 --- a/MantidPlot/src/Mantid/AlgorithmMonitor.h +++ b/MantidPlot/src/Mantid/AlgorithmMonitor.h @@ -34,7 +34,7 @@ public: /// Destructor ~AlgorithmMonitor() override; /// Add algorithm to monitor - void add(Mantid::API::IAlgorithm_sptr alg); + void add(const Mantid::API::IAlgorithm_sptr &alg); /// Removes stopped algorithm void remove(const Mantid::API::IAlgorithm *alg); @@ -116,7 +116,7 @@ private: class AlgButton : public QPushButton { Q_OBJECT public: - AlgButton(const QString &text, Mantid::API::IAlgorithm_sptr alg) + AlgButton(const QString &text, const Mantid::API::IAlgorithm_sptr &alg) : QPushButton(text), m_alg(alg->getAlgorithmID()) { connect(this, SIGNAL(clicked()), this, SLOT(sendClicked())); } diff --git a/MantidPlot/src/Mantid/FitParameterTie.cpp b/MantidPlot/src/Mantid/FitParameterTie.cpp index f5dc75728629ae73ff3650cdc9b51100b44f4473..dbf91658842ffcab9472894cc1ef90bc7c8cd8af 100644 --- a/MantidPlot/src/Mantid/FitParameterTie.cpp +++ b/MantidPlot/src/Mantid/FitParameterTie.cpp @@ -8,11 +8,12 @@ #include "MantidAPI/CompositeFunction.h" #include <QRegExp> #include <stdexcept> +#include <utility> /// Constructor FitParameterTie::FitParameterTie( boost::shared_ptr<Mantid::API::CompositeFunction> cf) - : m_compositeFunction(cf), m_prop(nullptr) {} + : m_compositeFunction(std::move(cf)), m_prop(nullptr) {} /// Destructor FitParameterTie::~FitParameterTie() { diff --git a/MantidPlot/src/Mantid/IFunctionWrapper.cpp b/MantidPlot/src/Mantid/IFunctionWrapper.cpp index f8d3448b44676d1d55a84f95609fdf85e1f89007..eb2943a0ad0414955f900d148208fa81bca5c58e 100644 --- a/MantidPlot/src/Mantid/IFunctionWrapper.cpp +++ b/MantidPlot/src/Mantid/IFunctionWrapper.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "IFunctionWrapper.h" + +#include <utility> + #include "MantidAPI/CompositeFunction.h" #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/IPeakFunction.h" @@ -27,7 +30,7 @@ void IFunctionWrapper::setFunction(const QString &name) { void IFunctionWrapper::setFunction( boost::shared_ptr<Mantid::API::IFunction> function) { - m_function = function; + m_function = std::move(function); m_compositeFunction = boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(m_function); m_peakFunction = diff --git a/MantidPlot/src/Mantid/InputHistory.cpp b/MantidPlot/src/Mantid/InputHistory.cpp index e52d175f08e4d00ebbe71d69f7a8c65f8e5d5d1d..1879698a2cf776197f346d4a1e2e7fd900d1d9b1 100644 --- a/MantidPlot/src/Mantid/InputHistory.cpp +++ b/MantidPlot/src/Mantid/InputHistory.cpp @@ -68,7 +68,8 @@ void InputHistoryImpl::save() { Upadates the non-default algorithm properties in the history. @param alg :: Pointer to the algorthm */ -void InputHistoryImpl::updateAlgorithm(Mantid::API::IAlgorithm_sptr alg) { +void InputHistoryImpl::updateAlgorithm( + const Mantid::API::IAlgorithm_sptr &alg) { const std::vector<Property *> &props = alg->getProperties(); QList<PropertyData> prop_hist_list; for (std::vector<Property *>::const_iterator prop = props.begin(); diff --git a/MantidPlot/src/Mantid/InputHistory.h b/MantidPlot/src/Mantid/InputHistory.h index c4dc5dcba9385e2e3435a853f3094f24d54eb712..1841b5e9bf004c98d9c222fcff3199b82dcd5cd7 100644 --- a/MantidPlot/src/Mantid/InputHistory.h +++ b/MantidPlot/src/Mantid/InputHistory.h @@ -38,7 +38,7 @@ class InputHistoryImpl { public: InputHistoryImpl(const InputHistoryImpl &) = delete; InputHistoryImpl &operator=(const InputHistoryImpl &) = delete; - void updateAlgorithm(Mantid::API::IAlgorithm_sptr alg); + void updateAlgorithm(const Mantid::API::IAlgorithm_sptr &alg); /// The name:value map of non-default properties with which algorithm algName /// was called last time. QMap<QString, QString> algorithmProperties(const QString &algName); diff --git a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp index 261dcf3be6d1f094f43d8f20b41d0f4de7b36b90..521ed90a3dddaaa8d3ff4f68b4a0064462f14e22 100644 --- a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp +++ b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.cpp @@ -41,7 +41,7 @@ using namespace Mantid::Kernel; */ LabelToolLogValuesDialog::LabelToolLogValuesDialog(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags, + const Qt::WFlags &flags, size_t experimentInfoIndex) : SampleLogDialogBase(wsname, parentContainer, flags, experimentInfoIndex) { diff --git a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h index 676f20dc53c2599bf868d4d11e1216e083ea3b3d..45fcb520f76bf585c9be36e912675582f4093732 100644 --- a/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h +++ b/MantidPlot/src/Mantid/LabelToolLogValuesDialog.h @@ -38,7 +38,7 @@ class LabelToolLogValuesDialog : public SampleLogDialogBase { public: /// Constructor LabelToolLogValuesDialog(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags = nullptr, + const Qt::WFlags &flags = nullptr, size_t experimentInfoIndex = 0); virtual ~LabelToolLogValuesDialog() override; diff --git a/MantidPlot/src/Mantid/MantidApplication.cpp b/MantidPlot/src/Mantid/MantidApplication.cpp index a12261ca305f2e3efa6395923e2779fc58f25e62..17fa5370465c4d9b320b304f0aac6fb58c90cc0c 100644 --- a/MantidPlot/src/Mantid/MantidApplication.cpp +++ b/MantidPlot/src/Mantid/MantidApplication.cpp @@ -39,8 +39,8 @@ MantidApplication::MantidApplication(int &argc, char **argv) } void MantidApplication::errorHandling(bool continueWork, int share, - QString name, QString email, - QString textbox) { + const QString &name, const QString &email, + const QString &textbox) { if (share == 0) { Mantid::Kernel::ErrorReporter errorReporter( "mantidplot", Mantid::Kernel::UsageService::Instance().getUpTime(), "", diff --git a/MantidPlot/src/Mantid/MantidApplication.h b/MantidPlot/src/Mantid/MantidApplication.h index 977eadb591a21d24a375ede1dd1b588f955faefc..dd8e64600a96aa8e072b3e6c1c1c1226f89c866e 100644 --- a/MantidPlot/src/Mantid/MantidApplication.h +++ b/MantidPlot/src/Mantid/MantidApplication.h @@ -20,6 +20,6 @@ public: signals: bool runAsPythonScript(const QString &code); public slots: - void errorHandling(bool continueWork, int sharing, QString name, - QString email, QString textbox); + void errorHandling(bool continueWork, int sharing, const QString &name, + const QString &email, const QString &textbox); }; diff --git a/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp b/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp index 320b0dd862b6449d222992fdc619375618980e82..d05d007ccede3b0f0ffb6a07c288c93401c4b4d1 100644 --- a/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp +++ b/MantidPlot/src/Mantid/MantidMDCurveDialog.cpp @@ -12,7 +12,7 @@ using Mantid::API::AnalysisDataService; using Mantid::API::IMDWorkspace; using Mantid::API::IMDWorkspace_sptr; -MantidMDCurveDialog::MantidMDCurveDialog(QWidget *parent, QString wsName) +MantidMDCurveDialog::MantidMDCurveDialog(QWidget *parent, const QString &wsName) : QDialog(parent), m_wsName(wsName) { ui.setupUi(this); m_lineOptions = new LinePlotOptions(this); diff --git a/MantidPlot/src/Mantid/MantidMDCurveDialog.h b/MantidPlot/src/Mantid/MantidMDCurveDialog.h index d63a8af756e0697b94e28ccfb025854cb4e951a5..d2ba68801cbc62e66b62875e20177bcc3069f901 100644 --- a/MantidPlot/src/Mantid/MantidMDCurveDialog.h +++ b/MantidPlot/src/Mantid/MantidMDCurveDialog.h @@ -17,7 +17,8 @@ class MantidMDCurveDialog : public QDialog { Q_OBJECT public: - MantidMDCurveDialog(QWidget *parent = nullptr, QString wsName = QString()); + MantidMDCurveDialog(QWidget *parent = nullptr, + const QString &wsName = QString()); ~MantidMDCurveDialog() override; LinePlotOptions *getLineOptionsWidget() { return m_lineOptions; } diff --git a/MantidPlot/src/Mantid/MantidMatrix.cpp b/MantidPlot/src/Mantid/MantidMatrix.cpp index 0b71aa06f6f05b93d9b95f3be15d31957782c3c5..453512d4305eb6dadb2363311a2b02b5c033b8ac 100644 --- a/MantidPlot/src/Mantid/MantidMatrix.cpp +++ b/MantidPlot/src/Mantid/MantidMatrix.cpp @@ -91,7 +91,7 @@ int modelTypeToInt(MantidMatrixModel::Type type) { } } // namespace -MantidMatrix::MantidMatrix(Mantid::API::MatrixWorkspace_const_sptr ws, +MantidMatrix::MantidMatrix(const Mantid::API::MatrixWorkspace_const_sptr &ws, QWidget *parent, const QString &label, const QString &name, int start, int end) : MdiSubWindow(parent, label, name, nullptr), WorkspaceObserver(), @@ -213,8 +213,8 @@ void MantidMatrix::viewChanged(int index) { } } -void MantidMatrix::setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start, - int end) { +void MantidMatrix::setup(const Mantid::API::MatrixWorkspace_const_sptr &ws, + int start, int end) { if (!ws) { QMessageBox::critical(nullptr, "WorkspaceMatrixModel error", "2D workspace expected."); @@ -997,7 +997,8 @@ void MantidMatrix::afterReplaceHandle( } } -void MantidMatrix::changeWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +void MantidMatrix::changeWorkspace( + const Mantid::API::MatrixWorkspace_sptr &ws) { if (m_workspaceTotalHist != static_cast<int>(ws->getNumberHistograms()) || m_cols != static_cast<int>(ws->blocksize())) { closeDependants(); @@ -1171,7 +1172,8 @@ void MantidMatrix::goToTab(const QString &name) { */ const std::string &MantidMatrix::getWorkspaceName() { return m_strName; } -void findYRange(MatrixWorkspace_const_sptr ws, double &miny, double &maxy) { +void findYRange(const MatrixWorkspace_const_sptr &ws, double &miny, + double &maxy) { // this is here to fill m_min and m_max with numbers that aren't nan miny = std::numeric_limits<double>::max(); maxy = std::numeric_limits<double>::lowest(); @@ -1349,7 +1351,8 @@ void MantidMatrix::setupNewExtension(MantidMatrixModel::Type type) { * Update the existing extensions * @param ws: the new workspace */ -void MantidMatrix::updateExtensions(Mantid::API::MatrixWorkspace_sptr ws) { +void MantidMatrix::updateExtensions( + const Mantid::API::MatrixWorkspace_sptr &ws) { auto it = m_extensions.begin(); while (it != m_extensions.cend()) { auto type = it->first; diff --git a/MantidPlot/src/Mantid/MantidMatrix.h b/MantidPlot/src/Mantid/MantidMatrix.h index 19caf3206f42745172e373fecab9a8f7debfde75..8cb759dddb931f60e11378b806787ffe9f799c8a 100644 --- a/MantidPlot/src/Mantid/MantidMatrix.h +++ b/MantidPlot/src/Mantid/MantidMatrix.h @@ -56,7 +56,7 @@ class ProjectData; * @param miny :: Variable to receive the minimum value. * @param maxy :: Variable to receive the maximum value. */ -void findYRange(Mantid::API::MatrixWorkspace_const_sptr ws, double &miny, +void findYRange(const Mantid::API::MatrixWorkspace_const_sptr &ws, double &miny, double &maxy); /** MantidMatrix is the class that represents a Qtiplot window for displaying @@ -70,9 +70,9 @@ class MantidMatrix : public MdiSubWindow, MantidQt::API::WorkspaceObserver { Q_OBJECT public: - MantidMatrix(Mantid::API::MatrixWorkspace_const_sptr ws, QWidget *parent, - const QString &label, const QString &name = QString(), - int start = -1, int end = -1); + MantidMatrix(const Mantid::API::MatrixWorkspace_const_sptr &ws, + QWidget *parent, const QString &label, + const QString &name = QString(), int start = -1, int end = -1); void connectTableView(QTableView *, MantidMatrixModel *); MantidMatrixModel *model() { return m_modelY; } @@ -173,7 +173,7 @@ signals: public slots: - void changeWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + void changeWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); void closeMatrix(); //! Return the width of all columns @@ -245,7 +245,7 @@ public slots: void setMatrixProperties(); protected: - void setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start = -1, + void setup(const Mantid::API::MatrixWorkspace_const_sptr &ws, int start = -1, int end = -1); ApplicationWindow *m_appWindow; @@ -308,7 +308,7 @@ private: /// Hook up a MantidMatrixExtension void setupNewExtension(MantidMatrixModel::Type type); /// Update the existing extensions - void updateExtensions(Mantid::API::MatrixWorkspace_sptr ws); + void updateExtensions(const Mantid::API::MatrixWorkspace_sptr &ws); /// ExtensioRequest handler MantidMatrixExtensionRequest m_extensionRequest; diff --git a/MantidPlot/src/Mantid/MantidMatrixCurve.cpp b/MantidPlot/src/Mantid/MantidMatrixCurve.cpp index 723a09b5b09b0b9dd427ae31247d1ad0c59ce9d4..dead95e8e3836f6591b8c7bcf49bc344a2509571 100644 --- a/MantidPlot/src/Mantid/MantidMatrixCurve.cpp +++ b/MantidPlot/src/Mantid/MantidMatrixCurve.cpp @@ -289,7 +289,7 @@ void MantidMatrixCurve::itemChanged() { */ QString MantidMatrixCurve::createCurveName( const QString &prefix, - const boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws) { + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws) { QString name = ""; if (prefix.isEmpty()) diff --git a/MantidPlot/src/Mantid/MantidMatrixCurve.h b/MantidPlot/src/Mantid/MantidMatrixCurve.h index 1b901acbb6d358aa158cd20f9c1456a1a372d2d7..20af7ed6aca3caf4ea0c7e9529848bea01712da7 100644 --- a/MantidPlot/src/Mantid/MantidMatrixCurve.h +++ b/MantidPlot/src/Mantid/MantidMatrixCurve.h @@ -145,7 +145,7 @@ private: /// Make the curve name QString createCurveName( const QString &prefix, - const boost::shared_ptr<const Mantid::API::MatrixWorkspace> ws); + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &ws); QString m_wsName; ///< Workspace name. If empty the ws isn't in the data service diff --git a/MantidPlot/src/Mantid/MantidMatrixDialog.cpp b/MantidPlot/src/Mantid/MantidMatrixDialog.cpp index 7a7ac69f35a0fcbb73fc68dedeef3aec045d7b7a..d27ab3a758dd9263bb73a5580ed02bcad7b9e118 100644 --- a/MantidPlot/src/Mantid/MantidMatrixDialog.cpp +++ b/MantidPlot/src/Mantid/MantidMatrixDialog.cpp @@ -15,7 +15,7 @@ #include <QPushButton> #include <QSpinBox> -MantidMatrixDialog::MantidMatrixDialog(QWidget *parent, Qt::WFlags fl) +MantidMatrixDialog::MantidMatrixDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), d_matrix(nullptr) { setWindowTitle(tr("MantidPlot - Matrix Properties")); diff --git a/MantidPlot/src/Mantid/MantidMatrixDialog.h b/MantidPlot/src/Mantid/MantidMatrixDialog.h index 18fccb4abc31037211f2fbbe0c8498b3882f3d44..9b2fcb113a85c2e415c45f0f4134fa470645d4b3 100644 --- a/MantidPlot/src/Mantid/MantidMatrixDialog.h +++ b/MantidPlot/src/Mantid/MantidMatrixDialog.h @@ -25,7 +25,7 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - MantidMatrixDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + MantidMatrixDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMatrix(MantidMatrix *m); private slots: diff --git a/MantidPlot/src/Mantid/MantidMatrixTabExtension.h b/MantidPlot/src/Mantid/MantidMatrixTabExtension.h index 205a28f4d05fc3a06047eada8ab4184e20ea8535..36c0cf2b0a30e608846799e3ba88993384c1fb2f 100644 --- a/MantidPlot/src/Mantid/MantidMatrixTabExtension.h +++ b/MantidPlot/src/Mantid/MantidMatrixTabExtension.h @@ -15,7 +15,7 @@ * Holds the information for a new tab. */ struct MantidMatrixTabExtension { - MantidMatrixTabExtension(QString label, QTableView *tableView, + MantidMatrixTabExtension(const QString &&label, QTableView *tableView, MantidMatrixModel *model, MantidMatrixModel::Type type) : label(label), tableView(tableView), model(model), type(type) {} diff --git a/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp b/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp index 2d5483c9178595f9725883207096b5fd4299e923..6421dc566e22e06ff928f2ce4a4287515d0523f7 100644 --- a/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp +++ b/MantidPlot/src/Mantid/MantidSampleLogDialog.cpp @@ -35,7 +35,8 @@ using namespace Mantid::Kernel; * ExperimentInfo objects. Should only be non-zero for MDWorkspaces. */ MantidSampleLogDialog::MantidSampleLogDialog(const QString &wsname, - MantidUI *mui, Qt::WFlags flags, + MantidUI *mui, + const Qt::WFlags &flags, size_t experimentInfoIndex) : SampleLogDialogBase(wsname, mui->appWindow(), flags, experimentInfoIndex), m_mantidUI(mui) { diff --git a/MantidPlot/src/Mantid/MantidSampleLogDialog.h b/MantidPlot/src/Mantid/MantidSampleLogDialog.h index 4cb33e38381d37124b2177e15f56f76d96754d3a..810c0d8f51c7ab1dc2bc24cedee509327cad0cfb 100644 --- a/MantidPlot/src/Mantid/MantidSampleLogDialog.h +++ b/MantidPlot/src/Mantid/MantidSampleLogDialog.h @@ -39,7 +39,7 @@ class MantidSampleLogDialog : public SampleLogDialogBase { public: /// Constructor MantidSampleLogDialog(const QString &wsname, MantidUI *mui, - Qt::WFlags flags = nullptr, + const Qt::WFlags &flags = nullptr, size_t experimentInfoIndex = 0); /// Destructor diff --git a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp index 8a8eddc24c3ab20eeeb49b0d2c4fbb30fb851973..ca345897ded3e31e3095c4f9563871b3612697e3 100644 --- a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp +++ b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.cpp @@ -29,7 +29,7 @@ using namespace Mantid::Kernel; */ MantidSampleMaterialDialog::MantidSampleMaterialDialog(const QString &wsName, MantidUI *mtdUI, - Qt::WFlags flags) + const Qt::WFlags &flags) : QDialog(mtdUI->appWindow(), flags), m_wsName(wsName), m_mantidUI(mtdUI) { m_uiForm.setupUi(this); diff --git a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h index 2044d628e05c95a70341bfd6a543248c934db60f..9dc60cedfaee57abf4ad664b01f9d5e1c18d88bb 100644 --- a/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h +++ b/MantidPlot/src/Mantid/MantidSampleMaterialDialog.h @@ -34,7 +34,7 @@ class MantidSampleMaterialDialog : public QDialog, public: MantidSampleMaterialDialog(const QString &wsName, MantidUI *mtdUI, - Qt::WFlags flags = nullptr); + const Qt::WFlags &flags = nullptr); public slots: void updateMaterial(); diff --git a/MantidPlot/src/Mantid/MantidTable.cpp b/MantidPlot/src/Mantid/MantidTable.cpp index 5d41e306f8f2768091949ca41965d3f3b27c7dd5..da323c473bf284e5a52ebc12b6e7e62c359be7c0 100644 --- a/MantidPlot/src/Mantid/MantidTable.cpp +++ b/MantidPlot/src/Mantid/MantidTable.cpp @@ -34,7 +34,7 @@ using namespace MantidQt::API; * @return the MantidTable created */ MantidTable::MantidTable(ScriptingEnv *env, - Mantid::API::ITableWorkspace_sptr ws, + const Mantid::API::ITableWorkspace_sptr &ws, const QString &label, ApplicationWindow *parent, bool transpose) : Table(env, diff --git a/MantidPlot/src/Mantid/MantidTable.h b/MantidPlot/src/Mantid/MantidTable.h index 030ff75a9451d18c2b5e2bac3e66b86cee47fb41..a88a12b6612efdf39368b29d3d5cb47e9088bdc7 100644 --- a/MantidPlot/src/Mantid/MantidTable.h +++ b/MantidPlot/src/Mantid/MantidTable.h @@ -17,7 +17,7 @@ class MantidTable : public Table, public MantidQt::API::WorkspaceObserver { Q_OBJECT public: - MantidTable(ScriptingEnv *env, Mantid::API::ITableWorkspace_sptr ws, + MantidTable(ScriptingEnv *env, const Mantid::API::ITableWorkspace_sptr &ws, const QString &label, ApplicationWindow *parent, bool transpose = false); diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index b1ffb8be465bda12c37f6c802dfea7f0a4dd1013..8f6158ce4c5c0e78a55922088bfef9c1dc74d4f8 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -1716,7 +1716,7 @@ void MantidUI::executeAlgorithm(Mantid::API::IAlgorithm_sptr alg) { * This creates an algorithm dialog (the default property entry thingie). */ MantidQt::API::AlgorithmDialog * -MantidUI::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { +MantidUI::createAlgorithmDialog(const Mantid::API::IAlgorithm_sptr &alg) { QHash<QString, QString> presets; QStringList enabled; @@ -1759,7 +1759,7 @@ MantidUI::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { * @param algorithm :: A pointer to the algorithm instance */ QString MantidUI::findInputWorkspaceProperty( - Mantid::API::IAlgorithm_sptr algorithm) const { + const Mantid::API::IAlgorithm_sptr &algorithm) const { // Iterate through the properties and find the first input one std::vector<Mantid::Kernel::Property *> props = algorithm->getProperties(); std::vector<Mantid::Kernel::Property *>::const_iterator pend = props.end(); @@ -2974,7 +2974,7 @@ MultiLayer *MantidUI::createGraphFromTable(Table *t, int type) { */ void MantidUI::setUpBinGraph( MultiLayer *ml, const QString &Name, - Mantid::API::MatrixWorkspace_const_sptr workspace) { + const Mantid::API::MatrixWorkspace_const_sptr &workspace) { Graph *g = ml->activeGraph(); g->setTitle(tr("Workspace ") + Name); QString xtitle; @@ -3742,7 +3742,8 @@ MultiLayer *MantidUI::plotSubplots(const QStringList &wsNames, } Table *MantidUI::createTableFromBins( - const QString &wsName, Mantid::API::MatrixWorkspace_const_sptr workspace, + const QString &wsName, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, const QList<int> &bins, bool errs, int fromRow, int toRow) { if (bins.empty()) return nullptr; diff --git a/MantidPlot/src/Mantid/MantidUI.h b/MantidPlot/src/Mantid/MantidUI.h index d2a5c67199fe40fea083bdf1bbdcfc27ca20190c..a19385119f6136a636d5b68e61bfc0e39e058a77 100644 --- a/MantidPlot/src/Mantid/MantidUI.h +++ b/MantidPlot/src/Mantid/MantidUI.h @@ -310,15 +310,17 @@ public slots: bool errs = true); // Set properties of a 1d graph which plots data from a workspace - static void setUpBinGraph(MultiLayer *ml, const QString &wsName, - Mantid::API::MatrixWorkspace_const_sptr workspace); + static void + setUpBinGraph(MultiLayer *ml, const QString &wsName, + const Mantid::API::MatrixWorkspace_const_sptr &workspace); // Copy to a Table Y-values (and Err-values if errs==true) of bins with // indeces from i0 to i1 (inclusive) from a workspace - Table *createTableFromBins(const QString &wsName, - Mantid::API::MatrixWorkspace_const_sptr workspace, - const QList<int> &bins, bool errs = true, - int fromRow = -1, int toRow = -1); + Table * + createTableFromBins(const QString &wsName, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + const QList<int> &bins, bool errs = true, + int fromRow = -1, int toRow = -1); // Copies selected columns (time bins) in a MantidMatrix to a Table Table *createTableFromSelectedColumns(MantidMatrix *m, bool errs); @@ -499,8 +501,8 @@ public slots: void executeAlgorithm(Mantid::API::IAlgorithm_sptr alg) override; // Find the name of the first input workspace for an algorithm - QString - findInputWorkspaceProperty(Mantid::API::IAlgorithm_sptr algorithm) const; + QString findInputWorkspaceProperty( + const Mantid::API::IAlgorithm_sptr &algorithm) const; // Show Qt critical error message box void showCritical(const QString &) override; // Show the dialog monitoring currently running algorithms @@ -595,7 +597,7 @@ private: /// This creates an algorithm dialog. MantidQt::API::AlgorithmDialog * - createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg); + createAlgorithmDialog(const Mantid::API::IAlgorithm_sptr &alg); /// This method accepts user inputs and executes loadraw/load nexus /// algorithm diff --git a/MantidPlot/src/Mantid/PeakPickerTool.cpp b/MantidPlot/src/Mantid/PeakPickerTool.cpp index d39062b4a903c9810355a2a31e9882f7d1955462..7dec8b965a94dc0b6715529e14e29cf3a037f817 100644 --- a/MantidPlot/src/Mantid/PeakPickerTool.cpp +++ b/MantidPlot/src/Mantid/PeakPickerTool.cpp @@ -316,8 +316,8 @@ bool PeakPickerTool::eventFilter(QObject *obj, QEvent *event) { return QwtPlotPicker::eventFilter(obj, event); } -void PeakPickerTool::windowStateChanged(Qt::WindowStates, - Qt::WindowStates newState) { +void PeakPickerTool::windowStateChanged(const Qt::WindowStates &, + const Qt::WindowStates &newState) { (void)newState; } diff --git a/MantidPlot/src/Mantid/PeakPickerTool.h b/MantidPlot/src/Mantid/PeakPickerTool.h index 7f8de38db612a677ea946af47470cbb60cf78aa3..bf1b5bae9c45593b8e5d5f0fab1dee15369e0419 100644 --- a/MantidPlot/src/Mantid/PeakPickerTool.h +++ b/MantidPlot/src/Mantid/PeakPickerTool.h @@ -81,7 +81,8 @@ public: bool isInitialized() const { return m_init; } public slots: - void windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState); + void windowStateChanged(const Qt::WindowStates &oldState, + const Qt::WindowStates &newState); signals: void peakChanged(); diff --git a/MantidPlot/src/Mantid/SampleLogDialogBase.cpp b/MantidPlot/src/Mantid/SampleLogDialogBase.cpp index cafe18ff040ecdd3dcc0fc87ee1bbee42f872a2b..d9d150c0e264134d2c69ee17d5093dd362c146e7 100644 --- a/MantidPlot/src/Mantid/SampleLogDialogBase.cpp +++ b/MantidPlot/src/Mantid/SampleLogDialogBase.cpp @@ -50,7 +50,7 @@ using namespace Mantid::Kernel; */ SampleLogDialogBase::SampleLogDialogBase(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags, + const Qt::WFlags &flags, size_t experimentInfoIndex) : QDialog(parentContainer, flags), m_tree(new QTreeWidget()), m_parentContainer(parentContainer), m_wsname(wsname.toStdString()), diff --git a/MantidPlot/src/Mantid/SampleLogDialogBase.h b/MantidPlot/src/Mantid/SampleLogDialogBase.h index e2c155e764a9115bf50aa754afdea47926c680f6..216f180f856ba4bf833c011f3026c218bab9c613 100644 --- a/MantidPlot/src/Mantid/SampleLogDialogBase.h +++ b/MantidPlot/src/Mantid/SampleLogDialogBase.h @@ -47,7 +47,7 @@ class SampleLogDialogBase : public QDialog { public: /// Constructor SampleLogDialogBase(const QString &wsname, QWidget *parentContainer, - Qt::WFlags flags = nullptr, + const Qt::WFlags &flags = nullptr, size_t experimentInfoIndex = 0); /// Virtual Destructor for derived classes diff --git a/MantidPlot/src/Matrix.cpp b/MantidPlot/src/Matrix.cpp index 6d96fad55cda39a3cb4fe67362b1a1b09982fd56..79de07d76efdd2aeb79303ff1d9a36098214fd66 100644 --- a/MantidPlot/src/Matrix.cpp +++ b/MantidPlot/src/Matrix.cpp @@ -76,7 +76,7 @@ using namespace Mantid; using namespace MantidQt::API; Matrix::Matrix(ScriptingEnv *env, const QString &label, QWidget *parent, - const QString &name, Qt::WFlags f) + const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env), d_matrix_model(nullptr), m_bk_color(), d_stack(nullptr), d_table_view(nullptr), imageLabel(nullptr), formula_str(), txt_format(), @@ -91,7 +91,7 @@ Matrix::Matrix(ScriptingEnv *env, const QString &label, QWidget *parent, } Matrix::Matrix(ScriptingEnv *env, int r, int c, const QString &label, - QWidget *parent, const QString &name, Qt::WFlags f) + QWidget *parent, const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env), d_matrix_model(nullptr), m_bk_color(), d_stack(nullptr), d_table_view(nullptr), imageLabel(nullptr), formula_str(), txt_format(), @@ -107,7 +107,7 @@ Matrix::Matrix(ScriptingEnv *env, int r, int c, const QString &label, } Matrix::Matrix(ScriptingEnv *env, const QImage &image, const QString &label, - QWidget *parent, const QString &name, Qt::WFlags f) + QWidget *parent, const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env), d_matrix_model(nullptr), m_bk_color(), d_stack(nullptr), d_table_view(nullptr), imageLabel(nullptr), formula_str(), diff --git a/MantidPlot/src/Matrix.h b/MantidPlot/src/Matrix.h index 5d15ee80410f97feb3227b32212e4bc06f63a87e..7713504f713e355a03ae1bd39a37beb263e12da1 100644 --- a/MantidPlot/src/Matrix.h +++ b/MantidPlot/src/Matrix.h @@ -65,7 +65,7 @@ class Matrix : public MdiSubWindow, public Scripted { protected: Matrix(ScriptingEnv *env, const QString &label, QWidget *parent, - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); public: /** @@ -81,10 +81,10 @@ public: * @param f :: window flags */ Matrix(ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent, - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); Matrix(ScriptingEnv *env, const QImage &image, const QString &label, QWidget *parent, const QString &name = QString(), - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~Matrix() override; enum Operation { diff --git a/MantidPlot/src/MatrixDialog.cpp b/MantidPlot/src/MatrixDialog.cpp index d5322f4015788729777754bbfe06f5cc475587b0..fdcf06258d99bd21ef0369e67931efaef214fadd 100644 --- a/MantidPlot/src/MatrixDialog.cpp +++ b/MantidPlot/src/MatrixDialog.cpp @@ -26,7 +26,7 @@ #include <QPushButton> #include <QSpinBox> -MatrixDialog::MatrixDialog(QWidget *parent, Qt::WFlags fl) +MatrixDialog::MatrixDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), d_matrix(nullptr) { setWindowTitle(tr("MantidPlot - Matrix Properties")); diff --git a/MantidPlot/src/MatrixDialog.h b/MantidPlot/src/MatrixDialog.h index 13c7a1bf2290106c768909d7e517fc14bf4fe3da..9a14b47ffd1a31bb5c8f1ad7f9a3ca7ce3c00462 100644 --- a/MantidPlot/src/MatrixDialog.h +++ b/MantidPlot/src/MatrixDialog.h @@ -34,7 +34,7 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - MatrixDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + MatrixDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void setMatrix(Matrix *m); private slots: diff --git a/MantidPlot/src/MatrixSizeDialog.cpp b/MantidPlot/src/MatrixSizeDialog.cpp index 8e1f39838be1b6a0fbd2052efc7cda5e237c6cda..3993bd3b396255a85a071453b0ae5b2c9b6a3841 100644 --- a/MantidPlot/src/MatrixSizeDialog.cpp +++ b/MantidPlot/src/MatrixSizeDialog.cpp @@ -26,7 +26,8 @@ #include <QPushButton> #include <QSpinBox> -MatrixSizeDialog::MatrixSizeDialog(Matrix *m, QWidget *parent, Qt::WFlags fl) +MatrixSizeDialog::MatrixSizeDialog(Matrix *m, QWidget *parent, + const Qt::WFlags &fl) : QDialog(parent, fl), d_matrix(m) { setWindowTitle(tr("MantidPlot - Matrix Dimensions")); diff --git a/MantidPlot/src/MatrixSizeDialog.h b/MantidPlot/src/MatrixSizeDialog.h index 6bcb69b329ac69515a6d62f54d9c03b24811a67a..2fdb1eb92ba6fa8fd5a7d0d7327d089e84cda19a 100644 --- a/MantidPlot/src/MatrixSizeDialog.h +++ b/MantidPlot/src/MatrixSizeDialog.h @@ -36,7 +36,7 @@ public: * @param fl :: window flags */ MatrixSizeDialog(Matrix *m, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); private slots: //! Accept changes and quit diff --git a/MantidPlot/src/MatrixValuesDialog.cpp b/MantidPlot/src/MatrixValuesDialog.cpp index 1f5925bd7613f9f5b354440cd6a86cfcef9358df..a4cd794e38f99cc1abdb518c77c3e37cdc1ccacb 100644 --- a/MantidPlot/src/MatrixValuesDialog.cpp +++ b/MantidPlot/src/MatrixValuesDialog.cpp @@ -47,7 +47,7 @@ #endif MatrixValuesDialog::MatrixValuesDialog(ScriptingEnv *env, QWidget *parent, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(parent, fl), Scripted(env), matrix(nullptr) { setObjectName("MatrixValuesDialog"); setWindowTitle(tr("MantidPlot - Set Matrix Values")); diff --git a/MantidPlot/src/MatrixValuesDialog.h b/MantidPlot/src/MatrixValuesDialog.h index 4db565ffb01dc94ba2e4ed9faa426d72d2616410..ea5e401346f1c84f6127fbc4ad2e3be457163f17 100644 --- a/MantidPlot/src/MatrixValuesDialog.h +++ b/MantidPlot/src/MatrixValuesDialog.h @@ -50,7 +50,7 @@ class MatrixValuesDialog : public QDialog, public Scripted { public: MatrixValuesDialog(ScriptingEnv *env, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); void setMatrix(Matrix *m); private slots: diff --git a/MantidPlot/src/MdPlottingCmapsProvider.cpp b/MantidPlot/src/MdPlottingCmapsProvider.cpp index 15de0dfbd9d31a6efb20eba01fabd96a589b5c22..f2075d55506b21ce255bcf161dc9c1bcb240d232 100644 --- a/MantidPlot/src/MdPlottingCmapsProvider.cpp +++ b/MantidPlot/src/MdPlottingCmapsProvider.cpp @@ -90,7 +90,7 @@ void MdPlottingCmapsProvider::getColorMapsForVSI(QStringList &colorMapNames) { void MdPlottingCmapsProvider::appendAllFileNamesForFileType( QStringList &colorMapNames, QStringList &colorMapFiles, - QString colorMapDirectory, QString fileType) { + const QString &colorMapDirectory, const QString &fileType) { QDir directory(colorMapDirectory); QStringList filter(QString("*.%1").arg(fileType)); @@ -105,7 +105,7 @@ void MdPlottingCmapsProvider::appendAllFileNamesForFileType( std::vector<int> MdPlottingCmapsProvider::getSliceViewerIndicesForCommonColorMaps( - QStringList colorMapNamesSliceViewer, QStringList colorMapNamesVsi) { + QStringList colorMapNamesSliceViewer, const QStringList &colorMapNamesVsi) { int index = 0; std::vector<int> indexVector; diff --git a/MantidPlot/src/MdPlottingCmapsProvider.h b/MantidPlot/src/MdPlottingCmapsProvider.h index 152b292a4b28a0646a05fedda9de2a448a77daa5..7c8a40e8532bb2552092de53979bc1b9423ec7aa 100644 --- a/MantidPlot/src/MdPlottingCmapsProvider.h +++ b/MantidPlot/src/MdPlottingCmapsProvider.h @@ -52,8 +52,8 @@ private: */ void appendAllFileNamesForFileType(QStringList &colorMapNames, QStringList &colorMapFiles, - QString colorMapDirectory, - QString fileType); + const QString &colorMapDirectory, + const QString &fileType); /** * Compare the colormap names of the Slice Viewer and the VSI and extract all @@ -65,5 +65,5 @@ private: */ std::vector<int> getSliceViewerIndicesForCommonColorMaps(QStringList colorMapNamesSliceViewer, - QStringList colorMapNamesVsi); + const QStringList &colorMapNamesVsi); }; diff --git a/MantidPlot/src/MdiSubWindow.cpp b/MantidPlot/src/MdiSubWindow.cpp index fd422b069e77c89950997cd8fbe5199c2b90c3b6..5d1f5ef9b7a8c5d5a851c3ed6153c8776038daad 100644 --- a/MantidPlot/src/MdiSubWindow.cpp +++ b/MantidPlot/src/MdiSubWindow.cpp @@ -52,7 +52,7 @@ using std::string; using namespace Mantid; MdiSubWindow::MdiSubWindow(QWidget *parent, const QString &label, - const QString &name, Qt::WFlags f) + const QString &name, const Qt::WFlags &f) : MdiSubWindowParent_t(parent, f), d_app(static_cast<ApplicationWindow *>(parent)), d_folder(d_app->currentFolder()), d_label(label), d_status(Normal), @@ -70,7 +70,7 @@ MdiSubWindow::MdiSubWindow() d_min_restore_size(QSize()) {} void MdiSubWindow::init(QWidget *parent, const QString &label, - const QString &name, Qt::WFlags flags) { + const QString &name, const Qt::WFlags &flags) { setParent(parent); setObjectName(name); setName(name); diff --git a/MantidPlot/src/MdiSubWindow.h b/MantidPlot/src/MdiSubWindow.h index 87c7330c64179e098c9f247ac5a5fe675647d664..b2575cf0a8b0ce1aa3b26480652620cae5bd5a3a 100644 --- a/MantidPlot/src/MdiSubWindow.h +++ b/MantidPlot/src/MdiSubWindow.h @@ -49,7 +49,7 @@ class Folder; class MdiSubWindowParent_t : public QFrame { Q_OBJECT public: - MdiSubWindowParent_t(QWidget *parent, Qt::WFlags f = nullptr) + MdiSubWindowParent_t(QWidget *parent, const Qt::WFlags &f = nullptr) : QFrame(parent, f), m_widget(nullptr) {} void setWidget(QWidget *w) { if (w == nullptr) { // removing widget @@ -124,13 +124,13 @@ public: * \sa setCaptionPolicy(), captionPolicy() */ MdiSubWindow(QWidget *parent, const QString &label = QString(), - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); MdiSubWindow(); /// Setup the window without constructor void init(QWidget *parent, const QString &label, const QString &name, - Qt::WFlags flags); + const Qt::WFlags &flags); //! Possible window captions. enum CaptionPolicy { diff --git a/MantidPlot/src/MultiLayer.cpp b/MantidPlot/src/MultiLayer.cpp index 13ea8f39184ad2d23a120b1d1df3cbfdaf74d277..f9e07ea5f817de2611c8569ccb9f97252d01076e 100644 --- a/MantidPlot/src/MultiLayer.cpp +++ b/MantidPlot/src/MultiLayer.cpp @@ -113,7 +113,8 @@ void LayerButton::mouseDoubleClickEvent(QMouseEvent *) { } MultiLayer::MultiLayer(QWidget *parent, int layers, int rows, int cols, - const QString &label, const char *name, Qt::WFlags f) + const QString &label, const char *name, + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), active_graph(nullptr), d_cols(cols), d_rows(rows), graph_width(500), graph_height(400), colsSpace(5), rowsSpace(5), left_margin(5), right_margin(5), top_margin(5), diff --git a/MantidPlot/src/MultiLayer.h b/MantidPlot/src/MultiLayer.h index ad453f12b188d91cd64b856fa7e5c5ce84cc576f..b0ce909fd8666127c0da4a9c1162925af88164c6 100644 --- a/MantidPlot/src/MultiLayer.h +++ b/MantidPlot/src/MultiLayer.h @@ -82,7 +82,7 @@ class MultiLayer : public MdiSubWindow { public: MultiLayer(QWidget *parent, int layers = 1, int rows = 1, int cols = 1, const QString &label = "", const char *name = nullptr, - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~MultiLayer() override; /// Get the window type as a string diff --git a/MantidPlot/src/Note.cpp b/MantidPlot/src/Note.cpp index 51dd908bec782c521379afa66754ee8bef0087bc..ca70a44a87aacc685127fb804a81fc126617ef07 100644 --- a/MantidPlot/src/Note.cpp +++ b/MantidPlot/src/Note.cpp @@ -50,7 +50,7 @@ DECLARE_WINDOW(Note) using namespace Mantid; Note::Note(const QString &label, QWidget *parent, const QString &name, - Qt::WFlags f) + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f) { te = new QTextEdit(this); te->setObjectName(name); diff --git a/MantidPlot/src/Note.h b/MantidPlot/src/Note.h index d338954d35661a873d29b53a80eac6ccbb8d28b4..e724c86c9ae95d0de2fcd8e40f0036e6752e71b0 100644 --- a/MantidPlot/src/Note.h +++ b/MantidPlot/src/Note.h @@ -45,7 +45,7 @@ class Note : public MdiSubWindow { public: Note(const QString &label, QWidget *parent, const QString &name = QString(), - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); ~Note() override{}; static MantidQt::API::IProjectSerialisable * diff --git a/MantidPlot/src/Plot3DDialog.cpp b/MantidPlot/src/Plot3DDialog.cpp index ec764b88452f34c24424b2ee508bbf7dd8ca3a84..eedff1758176b13ef436475beff0cf33a447ce22 100644 --- a/MantidPlot/src/Plot3DDialog.cpp +++ b/MantidPlot/src/Plot3DDialog.cpp @@ -46,7 +46,7 @@ using Mantid::Kernel::ConfigService; -Plot3DDialog::Plot3DDialog(QWidget *parent, Qt::WFlags fl) +Plot3DDialog::Plot3DDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setObjectName("Plot3DDialog"); setWindowTitle(tr("MantidPlot - Surface Plot Options")); diff --git a/MantidPlot/src/Plot3DDialog.h b/MantidPlot/src/Plot3DDialog.h index 664806982666b0d2ce5ab417ddfef27f4f9cbec9..f8a6a179edf4d0b82cb22baca38c00add951fab4 100644 --- a/MantidPlot/src/Plot3DDialog.h +++ b/MantidPlot/src/Plot3DDialog.h @@ -41,7 +41,7 @@ class Plot3DDialog : public QDialog { Q_OBJECT public: - Plot3DDialog(QWidget *parent, Qt::WFlags fl = nullptr); + Plot3DDialog(QWidget *parent, const Qt::WFlags &fl = nullptr); void setPlot(Graph3D *); void showTitleTab(); diff --git a/MantidPlot/src/PlotDialog.cpp b/MantidPlot/src/PlotDialog.cpp index 933f04a338a81b5ed619617a2953ff90c922630c..5ca24067fa4fbfc4613a4499e2c13f2d0c4843e2 100644 --- a/MantidPlot/src/PlotDialog.cpp +++ b/MantidPlot/src/PlotDialog.cpp @@ -75,7 +75,7 @@ using Mantid::Kernel::ConfigService; using namespace MantidQt::API; PlotDialog::PlotDialog(bool showExtended, ApplicationWindow *app, - MultiLayer *ml, Qt::WFlags fl) + MultiLayer *ml, const Qt::WFlags &fl) : QDialog(ml, fl), d_app(app), d_ml(nullptr) { setObjectName("PlotDialog"); setWindowTitle(tr("MantidPlot - Plot details")); diff --git a/MantidPlot/src/PlotDialog.h b/MantidPlot/src/PlotDialog.h index beb8d8a62a29ea88227bb497153835efe78d6000..a1d7a4175197797b6508d8072c3c1351e651d588 100644 --- a/MantidPlot/src/PlotDialog.h +++ b/MantidPlot/src/PlotDialog.h @@ -69,7 +69,7 @@ class PlotDialog : public QDialog { public: PlotDialog(bool showExtended, ApplicationWindow *app, MultiLayer *ml, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); void initFonts(const QFont &titlefont, const QFont &axesfont, const QFont &numbersfont, const QFont &legendfont); void insertColumnsList(const QStringList &names) { columnNames = names; }; diff --git a/MantidPlot/src/PlotWizard.cpp b/MantidPlot/src/PlotWizard.cpp index e181c6d17808b9520ab9253212716a5f8d395a5d..4d7db635cb44656d0fb8a9994a2efd7cb71fe4b6 100644 --- a/MantidPlot/src/PlotWizard.cpp +++ b/MantidPlot/src/PlotWizard.cpp @@ -37,7 +37,8 @@ #include <QGroupBox> #include <QListWidget> -PlotWizard::PlotWizard(QWidget *parent, Qt::WFlags fl) : QDialog(parent, fl) { +PlotWizard::PlotWizard(QWidget *parent, const Qt::WFlags &fl) + : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Select Columns to Plot")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/PlotWizard.h b/MantidPlot/src/PlotWizard.h index e7e69ff2ef4319d7aabcae886fa9eff355d05829..cb68e8867ed89783c36a80c7c97255c7705633a8 100644 --- a/MantidPlot/src/PlotWizard.h +++ b/MantidPlot/src/PlotWizard.h @@ -46,7 +46,7 @@ public: * @param parent :: parent widget * @param fl :: Qt window flags */ - PlotWizard(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + PlotWizard(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); private: //! Button "Plot" diff --git a/MantidPlot/src/PolynomFitDialog.cpp b/MantidPlot/src/PolynomFitDialog.cpp index c06057a329063938c6d00574c0718ae4bad5b5f2..8d950fcfdace5b77d80e980da293cb610e1d7124 100644 --- a/MantidPlot/src/PolynomFitDialog.cpp +++ b/MantidPlot/src/PolynomFitDialog.cpp @@ -38,7 +38,7 @@ #include <QMessageBox> #include <QSpinBox> -PolynomFitDialog::PolynomFitDialog(QWidget *parent, Qt::WFlags fl) +PolynomFitDialog::PolynomFitDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr) { setObjectName("PolynomFitDialog"); setWindowTitle(tr("MantidPlot - Polynomial Fit Options")); diff --git a/MantidPlot/src/PolynomFitDialog.h b/MantidPlot/src/PolynomFitDialog.h index 148607e92d58efcd95e9f12022af1769b6207ae0..7a1d51c1daf8a7c55d57e1ff33449559353acf8a 100644 --- a/MantidPlot/src/PolynomFitDialog.h +++ b/MantidPlot/src/PolynomFitDialog.h @@ -44,7 +44,7 @@ class PolynomFitDialog : public QDialog { Q_OBJECT public: - PolynomFitDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + PolynomFitDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); public slots: void fit(); diff --git a/MantidPlot/src/Processes.cpp b/MantidPlot/src/Processes.cpp index 392770cefb934bd778e0107497ec97cd880d4afc..92723188e4c696c81eb01e441a32973c236525ea 100644 --- a/MantidPlot/src/Processes.cpp +++ b/MantidPlot/src/Processes.cpp @@ -24,7 +24,7 @@ namespace { -bool isOtherInstance(int64_t otherPID, QString otherExeName) { +bool isOtherInstance(int64_t otherPID, const QString &otherExeName) { static const int64_t ourPID(QCoreApplication::applicationPid()); if (otherPID == ourPID) return false; diff --git a/MantidPlot/src/ProjectRecovery.cpp b/MantidPlot/src/ProjectRecovery.cpp index 5085c402c690ce660ee12131e75d18c41547fd87..7007e0d5a7bf9cf6aa27b603cc4f950f576cc371 100644 --- a/MantidPlot/src/ProjectRecovery.cpp +++ b/MantidPlot/src/ProjectRecovery.cpp @@ -339,7 +339,8 @@ bool ProjectRecovery::checkForRecovery() const noexcept { } } -bool ProjectRecovery::clearAllCheckpoints(Poco::Path path) const noexcept { +bool ProjectRecovery::clearAllCheckpoints(const Poco::Path &path) const + noexcept { try { Poco::File(path).remove(true); return true; diff --git a/MantidPlot/src/ProjectRecovery.h b/MantidPlot/src/ProjectRecovery.h index cca98b0ce4eed238b47da058c22d5a1ed439ae56..bc323123d21a490384d0dbde04cc201731310b14 100644 --- a/MantidPlot/src/ProjectRecovery.h +++ b/MantidPlot/src/ProjectRecovery.h @@ -47,7 +47,7 @@ public: bool checkForRecovery() const noexcept; /// Clears all checkpoints in the existing folder at the given path - bool clearAllCheckpoints(Poco::Path path) const noexcept; + bool clearAllCheckpoints(const Poco::Path &path) const noexcept; /// Clears all checkpoints in the existing folder at the given path bool clearAllUnusedCheckpoints() const noexcept; diff --git a/MantidPlot/src/ProjectSerialiser.cpp b/MantidPlot/src/ProjectSerialiser.cpp index cbd97ac9b4e2d13c2eaad24e21482fdd37715588..3cfbb334e7c6bb34d74b51ddab44bc4396706c7c 100644 --- a/MantidPlot/src/ProjectSerialiser.cpp +++ b/MantidPlot/src/ProjectSerialiser.cpp @@ -220,7 +220,7 @@ bool ProjectSerialiser::save(const QString &projectName, bool compress, * folder. (Default True) * @return True is loading was successful, otherwise false */ -bool ProjectSerialiser::load(std::string filepath, const int fileVersion, +bool ProjectSerialiser::load(const std::string &filepath, const int fileVersion, const bool isTopLevel) { // We have to accept std::string to maintain Python compatibility auto qfilePath = QString::fromStdString(filepath); diff --git a/MantidPlot/src/ProjectSerialiser.h b/MantidPlot/src/ProjectSerialiser.h index 36b3b6d6fa907b5ed86959d29f4f98d3a9b3f93b..7ef131461b2a734cd11e176a8655a3f4b8cd6498 100644 --- a/MantidPlot/src/ProjectSerialiser.h +++ b/MantidPlot/src/ProjectSerialiser.h @@ -59,7 +59,7 @@ public: bool save(const QString &projectName, bool compress = false, bool saveAll = true); /// Load a project file from disk - bool load(std::string filepath, const int fileVersion, + bool load(const std::string &filepath, const int fileVersion, const bool isTopLevel = true); /// Open the script window and load scripts from string void openScriptWindow(const QStringList &files); diff --git a/MantidPlot/src/RenameWindowDialog.cpp b/MantidPlot/src/RenameWindowDialog.cpp index e717cf0ec27ae05555c28d5d2e91012dfe2982d5..0fde8040217f54a9bd6235b6f96603f75c9d9a2a 100644 --- a/MantidPlot/src/RenameWindowDialog.cpp +++ b/MantidPlot/src/RenameWindowDialog.cpp @@ -37,7 +37,7 @@ #include <QMessageBox> #include <QRadioButton> -RenameWindowDialog::RenameWindowDialog(QWidget *parent, Qt::WFlags fl) +RenameWindowDialog::RenameWindowDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Rename Window")); diff --git a/MantidPlot/src/RenameWindowDialog.h b/MantidPlot/src/RenameWindowDialog.h index 2307e1af7f3e77c8c7c2839feb3de008b04b2533..87efc06339dd8c9efd9612a1755451a7933ebd5a 100644 --- a/MantidPlot/src/RenameWindowDialog.h +++ b/MantidPlot/src/RenameWindowDialog.h @@ -47,7 +47,7 @@ class RenameWindowDialog : public QDialog { Q_OBJECT public: - RenameWindowDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + RenameWindowDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); private: QPushButton *buttonOk; diff --git a/MantidPlot/src/ScriptingLangDialog.cpp b/MantidPlot/src/ScriptingLangDialog.cpp index 58308238c79c30cc6fdff502c7bc6b28db296cfa..4ee342dd39c5daf7eb4d57710acef340e6e97c78 100644 --- a/MantidPlot/src/ScriptingLangDialog.cpp +++ b/MantidPlot/src/ScriptingLangDialog.cpp @@ -37,7 +37,7 @@ ScriptingLangDialog::ScriptingLangDialog(ScriptingEnv *env, ApplicationWindow *parent, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(parent, fl), Scripted(env) { setWindowTitle(tr("MantidPlot - Select scripting language")); diff --git a/MantidPlot/src/ScriptingLangDialog.h b/MantidPlot/src/ScriptingLangDialog.h index 1dc8dba2cdd226d7b9b3e2b9c8af31b3a0400d82..780c6ba9861cd1f6d4a1f1662b976917de4b48eb 100644 --- a/MantidPlot/src/ScriptingLangDialog.h +++ b/MantidPlot/src/ScriptingLangDialog.h @@ -43,7 +43,7 @@ class ScriptingLangDialog : public QDialog, public Scripted { public: ScriptingLangDialog(ScriptingEnv *env, ApplicationWindow *parent, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void updateLangList(); diff --git a/MantidPlot/src/SendToProgramDialog.cpp b/MantidPlot/src/SendToProgramDialog.cpp index 2902f85d2e668be3f1aae31fffa2c7d766fa94b1..dd72797177637d5fcfe30c3df395e8bae379ba17 100644 --- a/MantidPlot/src/SendToProgramDialog.cpp +++ b/MantidPlot/src/SendToProgramDialog.cpp @@ -31,7 +31,7 @@ using namespace MantidQt::API; /** * Constructor when adding a new program to the send to list */ -SendToProgramDialog::SendToProgramDialog(QWidget *parent, Qt::WFlags fl) +SendToProgramDialog::SendToProgramDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl), validName(false), validTarget(false), validSaveUsing(false) { m_uiform.setupUi(this); @@ -61,8 +61,9 @@ SendToProgramDialog::SendToProgramDialog(QWidget *parent, Qt::WFlags fl) * Constructor when editing a program settings */ SendToProgramDialog::SendToProgramDialog( - QWidget *parent, QString programName, - std::map<std::string, std::string> programKeysAndDetails, Qt::WFlags fl) + QWidget *parent, const QString &programName, + std::map<std::string, std::string> programKeysAndDetails, + const Qt::WFlags &fl) : QDialog(parent, fl), validName(true), validTarget(true), validSaveUsing(true) { m_uiform.setupUi(this); diff --git a/MantidPlot/src/SendToProgramDialog.h b/MantidPlot/src/SendToProgramDialog.h index 19fe0936f911e7c3226d0fb6680c167e7cd83d78..1e16fc996abd1abdfba0ee8d0e2fd40d291fb0fb 100644 --- a/MantidPlot/src/SendToProgramDialog.h +++ b/MantidPlot/src/SendToProgramDialog.h @@ -26,10 +26,10 @@ class SendToProgramDialog : public QDialog { Q_OBJECT public: - SendToProgramDialog(QWidget *parent, Qt::WFlags fl = nullptr); - SendToProgramDialog(QWidget *parent, QString programName, + SendToProgramDialog(QWidget *parent, const Qt::WFlags &fl = nullptr); + SendToProgramDialog(QWidget *parent, const QString &programName, std::map<std::string, std::string> programKeysAndDetails, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); std::pair<std::string, std::map<std::string, std::string>> getSettings() const; diff --git a/MantidPlot/src/SetColValuesDialog.cpp b/MantidPlot/src/SetColValuesDialog.cpp index a04958664203f33cbf845fe1e7d366bfb76480a5..969f46337c3b24c1e801c2e0adc122a5456ead55 100644 --- a/MantidPlot/src/SetColValuesDialog.cpp +++ b/MantidPlot/src/SetColValuesDialog.cpp @@ -50,7 +50,7 @@ #endif SetColValuesDialog::SetColValuesDialog(ScriptingEnv *env, Table *t, - Qt::WFlags fl) + const Qt::WFlags &fl) : QDialog(t, fl), Scripted(env) { setObjectName("SetColValuesDialog"); setWindowTitle(tr("MantidPlot - Set column values")); diff --git a/MantidPlot/src/SetColValuesDialog.h b/MantidPlot/src/SetColValuesDialog.h index 9732f19ff59d51fb3bf0d0a108865fbb0422c812..65be95aec42f88a53e158f143bd20a96f920555d 100644 --- a/MantidPlot/src/SetColValuesDialog.h +++ b/MantidPlot/src/SetColValuesDialog.h @@ -52,7 +52,8 @@ class SetColValuesDialog : public QDialog, public Scripted { Q_OBJECT public: - SetColValuesDialog(ScriptingEnv *env, Table *t, Qt::WFlags fl = nullptr); + SetColValuesDialog(ScriptingEnv *env, Table *t, + const Qt::WFlags &fl = nullptr); private slots: bool apply(); diff --git a/MantidPlot/src/SmoothCurveDialog.cpp b/MantidPlot/src/SmoothCurveDialog.cpp index 1881bb953b86272117e382c6820e466ccfc4ef40..83d941b1166b1f19db86658086aeea994b641c0a 100644 --- a/MantidPlot/src/SmoothCurveDialog.cpp +++ b/MantidPlot/src/SmoothCurveDialog.cpp @@ -42,7 +42,8 @@ #include <QPushButton> #include <QSpinBox> -SmoothCurveDialog::SmoothCurveDialog(int method, QWidget *parent, Qt::WFlags fl) +SmoothCurveDialog::SmoothCurveDialog(int method, QWidget *parent, + const Qt::WFlags &fl) : QDialog(parent, fl), graph(nullptr), boxPointsLeft(nullptr), boxPointsRight(nullptr), boxOrder(nullptr) { smooth_method = method; diff --git a/MantidPlot/src/SmoothCurveDialog.h b/MantidPlot/src/SmoothCurveDialog.h index 644f417a1fa5b5b79e45cb9fa45442e5abf67d1f..e5e9048ce28d295a5ce4cda4e0e5ea4cac959bd9 100644 --- a/MantidPlot/src/SmoothCurveDialog.h +++ b/MantidPlot/src/SmoothCurveDialog.h @@ -43,7 +43,7 @@ class SmoothCurveDialog : public QDialog { public: SmoothCurveDialog(int method, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); public slots: void setGraph(Graph *g); diff --git a/MantidPlot/src/SortDialog.cpp b/MantidPlot/src/SortDialog.cpp index 4914069e850538758fc35b068c9fb5c84a8891e7..8e422cbcc3d968ed78be05372176ebf1e9f95cf8 100644 --- a/MantidPlot/src/SortDialog.cpp +++ b/MantidPlot/src/SortDialog.cpp @@ -36,7 +36,8 @@ #include <QLayout> #include <QPushButton> -SortDialog::SortDialog(QWidget *parent, Qt::WFlags fl) : QDialog(parent, fl) { +SortDialog::SortDialog(QWidget *parent, const Qt::WFlags &fl) + : QDialog(parent, fl) { setWindowTitle(tr("MantidPlot - Sorting Options")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/SortDialog.h b/MantidPlot/src/SortDialog.h index 42ce2a3e622898ec5b5f448e600d6dbc761e0422..6773e9bb1fd47f79d0de4746b979b62c52f1433c 100644 --- a/MantidPlot/src/SortDialog.h +++ b/MantidPlot/src/SortDialog.h @@ -39,7 +39,7 @@ class SortDialog : public QDialog { Q_OBJECT public: - SortDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + SortDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); void insertColumnsList(const QStringList &cols); private slots: diff --git a/MantidPlot/src/Spectrogram.cpp b/MantidPlot/src/Spectrogram.cpp index 3d60e8bc3894a3fb0c225686fb5cff80989c5d61..8c02a539d938d6fb9827d372a731dabca31ef679 100644 --- a/MantidPlot/src/Spectrogram.cpp +++ b/MantidPlot/src/Spectrogram.cpp @@ -49,6 +49,7 @@ #include "MantidQtWidgets/Common/TSVSerialiser.h" #include <numeric> +#include <utility> Spectrogram::Spectrogram() : QObject(), QwtPlotSpectrogram(), d_color_map_pen(false), @@ -694,7 +695,7 @@ void Spectrogram::loadSettings() { * This method saves the selectcolrmap file name to membervaraible */ void Spectrogram::setColorMapFileName(QString colormapName) { - mCurrentColorMap = colormapName; + mCurrentColorMap = std::move(colormapName); } QwtDoubleRect Spectrogram::boundingRect() const { return d_matrix ? d_matrix->boundingRect() : data().boundingRect(); @@ -707,7 +708,7 @@ double Spectrogram::getMinPositiveValue() const { } void Spectrogram::setContourPenList(QList<QPen> lst) { - d_pen_list = lst; + d_pen_list = std::move(lst); setDefaultContourPen(Qt::NoPen); d_color_map_pen = false; } diff --git a/MantidPlot/src/SurfaceDialog.cpp b/MantidPlot/src/SurfaceDialog.cpp index dcbef03d769d6f9604c07946fa5c37e8bb95e4ea..812bde0ca580b0e3e1d73f1c44783509b8438192 100644 --- a/MantidPlot/src/SurfaceDialog.cpp +++ b/MantidPlot/src/SurfaceDialog.cpp @@ -34,7 +34,7 @@ #include <QSpinBox> #include <QStackedWidget> -SurfaceDialog::SurfaceDialog(QWidget *parent, Qt::WFlags fl) +SurfaceDialog::SurfaceDialog(QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setObjectName("SurfaceDialog"); setWindowTitle(tr("MantidPlot - Define surface plot")); diff --git a/MantidPlot/src/SurfaceDialog.h b/MantidPlot/src/SurfaceDialog.h index f14ae164915c8d733dd3e61a677a7538102d28de..239a4ae773745654669c94be3b227be6b82f8783 100644 --- a/MantidPlot/src/SurfaceDialog.h +++ b/MantidPlot/src/SurfaceDialog.h @@ -32,7 +32,7 @@ class SurfaceDialog : public QDialog { Q_OBJECT public: - SurfaceDialog(QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + SurfaceDialog(QWidget *parent = nullptr, const Qt::WFlags &fl = nullptr); public slots: void accept() override; diff --git a/MantidPlot/src/Table.cpp b/MantidPlot/src/Table.cpp index 77a64b210d3752c16b4d78266a2f3ddf36d354dd..606c439cc61bb73f0f604720df53e0106e8338c8 100644 --- a/MantidPlot/src/Table.cpp +++ b/MantidPlot/src/Table.cpp @@ -73,7 +73,7 @@ using namespace Mantid; using namespace MantidQt::API; Table::Table(ScriptingEnv *env, int rows, int cols, const QString &label, - QWidget *parent, const QString &name, Qt::WFlags f) + QWidget *parent, const QString &name, const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), Scripted(env) { selectedCol = -1; d_saved_cells = nullptr; @@ -2002,7 +2002,7 @@ void Table::loadHeader(QStringList header) { setHeaderColType(); } -void Table::setHeader(QStringList header) { +void Table::setHeader(const QStringList &header) { col_label = header; setHeaderColType(); } @@ -3267,7 +3267,7 @@ void Table::recordSelection() { * @param alignment :: [input] Alignment flags to give the cell */ void Table::setTextAlignment(int row, int col, - QFlags<Qt::AlignmentFlag> alignment) { + const QFlags<Qt::AlignmentFlag> &alignment) { auto *cell = d_table->item(row, col); if (cell) { cell->setTextAlignment(alignment); diff --git a/MantidPlot/src/Table.h b/MantidPlot/src/Table.h index e81b3bc679523386b085e04de447c5ebce8fad66..434bb77f1c2078917aca9023420383a2b82bb44d 100644 --- a/MantidPlot/src/Table.h +++ b/MantidPlot/src/Table.h @@ -33,6 +33,9 @@ #include <QTableWidget> #include <QVarLengthArray> +#include <utility> + +#include <utility> #include "Graph.h" #include "MdiSubWindow.h" @@ -116,7 +119,7 @@ public: }; Table(ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent, - const QString &name = QString(), Qt::WFlags f = nullptr); + const QString &name = QString(), const Qt::WFlags &f = nullptr); int topSelectedRow() const { return d_table->topSelectedRow(); } int bottomSelectedRow() const { return d_table->bottomSelectedRow(); } @@ -160,13 +163,14 @@ public slots: bool rightColumns = false); QList<int> plotDesignations() { return col_plot_type; }; - void setHeader(QStringList header); + void setHeader(const QStringList &header); void loadHeader(QStringList header); void setHeaderColType(); void setText(int row, int col, const QString &text); void setRandomValues(); void setAscValues(); - void setTextAlignment(int row, int col, QFlags<Qt::AlignmentFlag> alignment); + void setTextAlignment(int row, int col, + const QFlags<Qt::AlignmentFlag> &alignment); virtual void cellEdited(int, int col); void moveCurrentCell(); @@ -339,7 +343,7 @@ public slots: int columnType(int col) { return colTypes[col]; }; QList<int> columnTypes() { return colTypes; }; - void setColumnTypes(QList<int> ctl) { colTypes = ctl; }; + void setColumnTypes(QList<int> ctl) { colTypes = std::move(std::move(ctl)); }; void setColumnTypes(const QStringList &ctl); void setColumnType(int col, ColType val) { colTypes[col] = val; } diff --git a/MantidPlot/src/TableDialog.cpp b/MantidPlot/src/TableDialog.cpp index 546de53ec27cf47369e92622dea158d0f0edbe55..b7a10b34342c0364964fbe5310ca63565133db6c 100644 --- a/MantidPlot/src/TableDialog.cpp +++ b/MantidPlot/src/TableDialog.cpp @@ -45,7 +45,8 @@ #include <QSpinBox> #include <QTextEdit> -TableDialog::TableDialog(Table *t, Qt::WFlags fl) : QDialog(t, fl), d_table(t) { +TableDialog::TableDialog(Table *t, const Qt::WFlags &fl) + : QDialog(t, fl), d_table(t) { setObjectName("TableDialog"); setWindowTitle(tr("MantidPlot - Column options")); setSizeGripEnabled(true); diff --git a/MantidPlot/src/TableDialog.h b/MantidPlot/src/TableDialog.h index 0ddef50ab45ff6dc0dad8591103afcd637d4a519..5fc8b09dcc8d2c3b388a8bb5b93f518c9ea5d390 100644 --- a/MantidPlot/src/TableDialog.h +++ b/MantidPlot/src/TableDialog.h @@ -44,7 +44,7 @@ class TableDialog : public QDialog { Q_OBJECT public: - TableDialog(Table *t, Qt::WFlags fl = nullptr); + TableDialog(Table *t, const Qt::WFlags &fl = nullptr); private slots: void prevColumn(); diff --git a/MantidPlot/src/TableStatistics.cpp b/MantidPlot/src/TableStatistics.cpp index 98e09f7a1b043b6146d25f08ce2fce4d414ac9d9..fc6bbb93f3e42686b82b2d252ac89ea195a66a1b 100644 --- a/MantidPlot/src/TableStatistics.cpp +++ b/MantidPlot/src/TableStatistics.cpp @@ -47,7 +47,7 @@ DECLARE_WINDOW(TableStatistics) using namespace Mantid; TableStatistics::TableStatistics(ScriptingEnv *env, QWidget *parent, - Table *base, Type t, QList<int> targets) + Table *base, Type t, const QList<int> &targets) : Table(env, 1, 1, "", parent, ""), d_base(base), d_type(t), d_targets(targets) { diff --git a/MantidPlot/src/TableStatistics.h b/MantidPlot/src/TableStatistics.h index 0877b0e7be658b632ed2654801f3c311a3a33151..f489cc3db1f18c83cab8ba78ba46e73031df9751 100644 --- a/MantidPlot/src/TableStatistics.h +++ b/MantidPlot/src/TableStatistics.h @@ -43,7 +43,7 @@ public: //! supported statistics types enum Type { row, column }; TableStatistics(ScriptingEnv *env, QWidget *parent, Table *base, Type, - QList<int> targets); + const QList<int> &targets); //! return the type of statistics Type type() const { return d_type; } //! return the base table of which statistics are displayed diff --git a/MantidPlot/src/TextDialog.cpp b/MantidPlot/src/TextDialog.cpp index 62a2da5fb0e8b64486dd526d26d28c7841d57f60..255bf8398dbd138c307fe97bb05725c7baefaeb1 100644 --- a/MantidPlot/src/TextDialog.cpp +++ b/MantidPlot/src/TextDialog.cpp @@ -47,7 +47,7 @@ #include <qwt_scale_widget.h> -TextDialog::TextDialog(TextType type, QWidget *parent, Qt::WFlags fl) +TextDialog::TextDialog(TextType type, QWidget *parent, const Qt::WFlags &fl) : QDialog(parent, fl) { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("MantidPlot - Text options")); diff --git a/MantidPlot/src/TextDialog.h b/MantidPlot/src/TextDialog.h index 28b7fecf68ef6930781255f9e561f7ec689c2381..59bbbd53dd3edcc47f0713279c46ccc6f615ca01 100644 --- a/MantidPlot/src/TextDialog.h +++ b/MantidPlot/src/TextDialog.h @@ -62,7 +62,8 @@ public: * @param parent :: parent widget * @param fl :: window flags */ - TextDialog(TextType type, QWidget *parent = nullptr, Qt::WFlags fl = nullptr); + TextDialog(TextType type, QWidget *parent = nullptr, + const Qt::WFlags &fl = nullptr); //! Return axis label alignment /** diff --git a/MantidPlot/src/TextFileIO.cpp b/MantidPlot/src/TextFileIO.cpp index 64df4906e6af0e0590bdb615990f15b71d25df13..3e0085c4f12c13bee323e69af2fc001c3de08db4 100644 --- a/MantidPlot/src/TextFileIO.cpp +++ b/MantidPlot/src/TextFileIO.cpp @@ -16,7 +16,8 @@ /** * Construct an object with a list of file filters */ -TextFileIO::TextFileIO(QStringList fileFilters) : m_filters(fileFilters) {} +TextFileIO::TextFileIO(const QStringList &fileFilters) + : m_filters(fileFilters) {} /** * Save to a file diff --git a/MantidPlot/src/TextFileIO.h b/MantidPlot/src/TextFileIO.h index edb217ce5e6b3b09bf0eb34ee4e367b00d3185ab..1c4b36c6bebf0802d1f64c3724955e8bc1e89195 100644 --- a/MantidPlot/src/TextFileIO.h +++ b/MantidPlot/src/TextFileIO.h @@ -16,7 +16,7 @@ class TextFileIO { public: /// Construct the object with a list of file filters - explicit TextFileIO(QStringList fileFilters = QStringList()); + explicit TextFileIO(const QStringList &fileFilters = QStringList()); /// Save to a file bool save(const QString &txt, const QString &filename) const; diff --git a/MantidPlot/src/TiledWindow.cpp b/MantidPlot/src/TiledWindow.cpp index 1661270ade1c44b2ad7410718552e5a0c84c37aa..46925af38084a218cb818107378e75247182af8d 100644 --- a/MantidPlot/src/TiledWindow.cpp +++ b/MantidPlot/src/TiledWindow.cpp @@ -215,7 +215,7 @@ InnerWidget *getInnerWidget(QWidget *w) { */ TiledWindow::TiledWindow(QWidget *parent, const QString &label, const QString &name, int nrows, int ncols, - Qt::WFlags f) + const Qt::WFlags &f) : MdiSubWindow(parent, label, name, f), m_scrollArea(nullptr), m_layout(nullptr), m_buttonPressed(false) { connect(this, SIGNAL(dropAtPositionQueued(MdiSubWindow *, QPoint, bool)), diff --git a/MantidPlot/src/TiledWindow.h b/MantidPlot/src/TiledWindow.h index d4ce70a50d83888a52a9ec5c98422cfebcd70a6f..49df22a9e90743a2c29bb9c658f2b7b0d3241747 100644 --- a/MantidPlot/src/TiledWindow.h +++ b/MantidPlot/src/TiledWindow.h @@ -30,7 +30,7 @@ class TiledWindow : public MdiSubWindow { public: TiledWindow(QWidget *parent, const QString &label, const QString &name = QString(), int nrows = 1, int ncols = 1, - Qt::WFlags f = nullptr); + const Qt::WFlags &f = nullptr); /// Populate a menu with actions void populateMenu(QMenu *menu); diff --git a/MantidPlot/src/lib/include/ExtensibleFileDialog.h b/MantidPlot/src/lib/include/ExtensibleFileDialog.h index 0dcea4e15f3a39760105d384de8d5ed30120a8fc..6162c67f713dbd465ef49928370091de38f86b82 100644 --- a/MantidPlot/src/lib/include/ExtensibleFileDialog.h +++ b/MantidPlot/src/lib/include/ExtensibleFileDialog.h @@ -54,9 +54,10 @@ public: * \param extended flag: show/hide the advanced options on start-up * \param flags window flags */ - ExtensibleFileDialog(QWidget *parent = nullptr, bool extended = true, - Qt::WFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + ExtensibleFileDialog( + QWidget *parent = nullptr, bool extended = true, + const Qt::WFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); //! Set the extension widget to be displayed when the user presses the toggle // button. void setExtensionWidget(QWidget *extension); diff --git a/MantidPlot/src/lib/include/SymbolDialog.h b/MantidPlot/src/lib/include/SymbolDialog.h index 659cc9c3095aeaa400e0d0838cb9febfcaf8218a..e8aaf0f03a1d5eee32b0004a78585b88a758b29f 100644 --- a/MantidPlot/src/lib/include/SymbolDialog.h +++ b/MantidPlot/src/lib/include/SymbolDialog.h @@ -62,7 +62,7 @@ public: * \param fl window flags */ SymbolDialog(CharSet charSet, QWidget *parent = nullptr, - Qt::WFlags fl = nullptr); + const Qt::WFlags &fl = nullptr); private: //! Show lowercase Greek characters diff --git a/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp b/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp index 71a0cecd62fd3e13453b87f98830a7a606cd3902..4a189d275001c051bc188c9e3c79de29d8aa8c38 100644 --- a/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp +++ b/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp @@ -35,7 +35,7 @@ #include <QUrl> ExtensibleFileDialog::ExtensibleFileDialog(QWidget *parent, bool extended, - Qt::WFlags flags) + const Qt::WFlags &flags) : QFileDialog(parent, flags) { d_extension = nullptr; d_extension_row = 0; diff --git a/MantidPlot/src/lib/src/SymbolDialog.cpp b/MantidPlot/src/lib/src/SymbolDialog.cpp index 812744badd640d0cb6d2dd5bc4f4207da00f64b2..3029e085474350c7d50a8846715d73ca7b0ebcce 100644 --- a/MantidPlot/src/lib/src/SymbolDialog.cpp +++ b/MantidPlot/src/lib/src/SymbolDialog.cpp @@ -38,7 +38,8 @@ #include <QSizePolicy> #include <QTextCodec> -SymbolDialog::SymbolDialog(CharSet charSet, QWidget *parent, Qt::WFlags fl) +SymbolDialog::SymbolDialog(CharSet charSet, QWidget *parent, + const Qt::WFlags &fl) : QDialog(parent, fl) { setAttribute(Qt::WA_DeleteOnClose); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); diff --git a/MantidPlot/src/origin/OPJFile.h b/MantidPlot/src/origin/OPJFile.h index 7bbecb120a7b7ed3c88ed669759074e9f7b47644..61aa4550ec67946bfbab159c0424e003ece4aa35 100644 --- a/MantidPlot/src/origin/OPJFile.h +++ b/MantidPlot/src/origin/OPJFile.h @@ -37,6 +37,8 @@ #include "tree.hh" #include <string> +#include <utility> + #include <vector> struct rect { @@ -67,8 +69,8 @@ struct originWindow { originWindow(std::string _name = "", std::string _label = "", bool _bHidden = false) - : name(_name), label(_label), objectID(0), bHidden(_bHidden), - state(Normal), title(Both), creation_date(0.0), + : name(std::move(_name)), label(std::move(_label)), objectID(0), + bHidden(_bHidden), state(Normal), title(Both), creation_date(0.0), modification_date(0.0){}; }; struct originData { @@ -97,9 +99,10 @@ struct spreadColumn { int index; std::vector<originData> odata; spreadColumn(std::string _name = "", int _index = 0) - : name(_name), type(NONE), value_type(0), value_type_specification(0), - significant_digits(6), decimal_places(6), numeric_display_type(0), - command(""), comment(""), width(8), index(_index){}; + : name(std::move(_name)), type(NONE), value_type(0), + value_type_specification(0), significant_digits(6), decimal_places(6), + numeric_display_type(0), command(""), comment(""), width(8), + index(_index){}; }; struct spreadSheet : public originWindow { @@ -108,8 +111,8 @@ struct spreadSheet : public originWindow { bool bMultisheet; std::vector<spreadColumn> column; spreadSheet(std::string _name = "") - : originWindow(_name), maxRows(0), bLoose(true), bMultisheet(false), - column(){}; + : originWindow(std::move(_name)), maxRows(0), bLoose(true), + bMultisheet(false), column(){}; }; struct excel : public originWindow { @@ -118,8 +121,8 @@ struct excel : public originWindow { std::vector<spreadSheet> sheet; excel(std::string _name = "", std::string _label = "", int _maxRows = 0, bool _bHidden = false, bool _bLoose = true) - : originWindow(_name, _label, _bHidden), maxRows(_maxRows), - bLoose(_bLoose){}; + : originWindow(std::move(_name), std::move(_label), _bHidden), + maxRows(_maxRows), bLoose(_bLoose){}; }; struct matrix : public originWindow { @@ -139,7 +142,7 @@ struct matrix : public originWindow { HeaderViewType header; std::vector<double> data; matrix(std::string _name = "", int _index = 0) - : originWindow(_name), nr_rows(0), nr_cols(0), + : originWindow(std::move(_name)), nr_rows(0), nr_cols(0), value_type_specification(0), significant_digits(6), decimal_places(6), numeric_display_type(0), command(""), width(8), index(_index), view(DataView), header(ColumnRow){}; @@ -154,8 +157,8 @@ struct function { int points; int index; function(std::string _name = "", int _index = 0) - : name(_name), type(0), formula(""), begin(0.0), end(0.0), points(0), - index(_index){}; + : name(std::move(_name)), type(0), formula(""), begin(0.0), end(0.0), + points(0), index(_index){}; }; struct text { @@ -414,12 +417,13 @@ struct graph : public originWindow { unsigned short width; unsigned short height; - graph(std::string _name = "") : originWindow(_name), width(0), height(0){}; + graph(std::string _name = "") + : originWindow(std::move(_name)), width(0), height(0){}; }; struct note : public originWindow { std::string text; - note(std::string _name = "") : originWindow(_name){}; + note(std::string _name = "") : originWindow(std::move(_name)){}; }; struct projectNode { @@ -430,7 +434,7 @@ struct projectNode { projectNode(std::string _name = "", int _type = 0, double _creation_date = 0.0, double _modification_date = 0.0) - : type(_type), name(_name), creation_date(_creation_date), + : type(_type), name(std::move(_name)), creation_date(_creation_date), modification_date(_modification_date){}; }; diff --git a/MantidPlot/test/MantidPlotInputArgsCheck.py b/MantidPlot/test/MantidPlotInputArgsCheck.py index c68753298a9da3de539c65b76776fa937188fad3..dc2d91043f2d4a7e1b25ea8fd9e39ed435006e4f 100644 --- a/MantidPlot/test/MantidPlotInputArgsCheck.py +++ b/MantidPlot/test/MantidPlotInputArgsCheck.py @@ -11,7 +11,6 @@ All these functions should throw a ValueError exception when, for example: - the specified workspaces don't exist - the index(es) of spectra, bin or dimension is wrong """ -from __future__ import (absolute_import, division, print_function) import mantidplottests from mantidplottests import * import time @@ -40,6 +39,7 @@ CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m WrongWorkspaceName = 'foo inexistent' + class MantidPlotInputArgsCheck(unittest.TestCase): def setUp(self): diff --git a/MantidPlot/test/MantidPlotMatplotlibTest.py b/MantidPlot/test/MantidPlotMatplotlibTest.py index 6da54072598409c10c7beb80c64cdf26cdcaecb9..99ecc31cbf248a17ee37587381ce0e50c22ad20e 100644 --- a/MantidPlot/test/MantidPlotMatplotlibTest.py +++ b/MantidPlot/test/MantidPlotMatplotlibTest.py @@ -7,8 +7,6 @@ """ Test matplotlib plotting for MantidPlot. Without our custom backend matplotlib graphs crash MantidPlot. """ -from __future__ import print_function - import mantidplottests from mantidplottests import * import time diff --git a/MantidPlot/test/mantidplottests.py b/MantidPlot/test/mantidplottests.py index a9da33b4cdd5aa35f21576b761fdf542e94cf9d5..9e9592bbe67686d2e8afca47feb19af5a3d8c8c9 100644 --- a/MantidPlot/test/mantidplottests.py +++ b/MantidPlot/test/mantidplottests.py @@ -13,7 +13,6 @@ Public methods: screenshot(): take a screenshot and save to a report """ -from __future__ import (absolute_import, division, print_function) import sys import os import unittest @@ -33,6 +32,7 @@ except: qtest = False print("QTest not available") + def moveMouseToCentre(widget): """Moves the mouse over the widget """ @@ -41,6 +41,7 @@ def moveMouseToCentre(widget): threadsafe_call(QTest.mouseMove, widget) QtCore.QCoreApplication.processEvents() + def runTests(classname): """ Run the test suite in the class. Uses the XML runner if the MANTID_SOURCE environment variable was set. diff --git a/Testing/PerformanceTests/analysis_mpl.py b/Testing/PerformanceTests/analysis_mpl.py index d5b8427b1bfb2d05ef27f0b3c119012b5ba50b7c..1d26bcff1a910f4a9bfe9abf3b8269dc6f78a3e8 100644 --- a/Testing/PerformanceTests/analysis_mpl.py +++ b/Testing/PerformanceTests/analysis_mpl.py @@ -7,15 +7,11 @@ """ Module containing functions for test performance analysis, plotting, and saving to other formats (CSV, PDF) """ -from __future__ import (absolute_import, division, print_function) - import datetime import os import numpy as np from pylab import close, figure, gcf, plot, xticks, ylabel, xlabel, title, savefig -from six.moves import range - import sqlresults from sqlresults import get_results diff --git a/Testing/PerformanceTests/sqlresults.py b/Testing/PerformanceTests/sqlresults.py index bdb6de9750c2219d921afb9b1797f99c5b54438e..d060abe9fa93b232d2b0a75ebdc435f7fd9c10f2 100644 --- a/Testing/PerformanceTests/sqlresults.py +++ b/Testing/PerformanceTests/sqlresults.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -from six.moves import range try: import sqlite3 has_sql = True diff --git a/Testing/SystemTests/lib/systemtests/systemtesting.py b/Testing/SystemTests/lib/systemtests/systemtesting.py index fe2d60a02daa19d046706fcf3912a70c7dfa282a..be7db3fb06b5f2bab22f55e92cf0411c4f4a8dd9 100644 --- a/Testing/SystemTests/lib/systemtests/systemtesting.py +++ b/Testing/SystemTests/lib/systemtests/systemtesting.py @@ -11,8 +11,6 @@ or by importing them into MantidPlot. File change history is stored at: <https://github.com/mantidproject/systemtests>. """ -from __future__ import (absolute_import, division, print_function) - # == for testing conda build of mantid-framework ========== import os @@ -21,7 +19,6 @@ if os.environ.get('MANTID_FRAMEWORK_CONDA_SYSTEMTEST'): import matplotlib # ========================================================= -from six import PY3 import datetime import difflib import imp @@ -764,9 +761,8 @@ class TestSuite(object): self._result.status = status self._result.addItem(['status', status]) # Dump std out so we know what happened - if PY3: - if isinstance(output, bytes): - output = output.decode() + if isinstance(output, bytes): + output = output.decode() self._result.output = '\n' + output all_lines = output.split('\n') # Find the test results diff --git a/Testing/SystemTests/lib/systemtests/xmlreporter.py b/Testing/SystemTests/lib/systemtests/xmlreporter.py index bcfe0d98a31bf94256f1f5da77323c666750aef7..2d2d911ed51012552caab20b83cb1468f187fc93 100644 --- a/Testing/SystemTests/lib/systemtests/xmlreporter.py +++ b/Testing/SystemTests/lib/systemtests/xmlreporter.py @@ -4,12 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os import sys from xml.dom.minidom import getDOMImplementation import systemtesting + class XmlResultReporter(systemtesting.ResultReporter): _time_taken = 0.0 diff --git a/Testing/SystemTests/scripts/InstallerTests.py b/Testing/SystemTests/scripts/InstallerTests.py index 3f33057f878b9e5a156c0ce299c2b3cb8992a426..b45b97ebcb9517e19d915757c6b31f2c82333706 100644 --- a/Testing/SystemTests/scripts/InstallerTests.py +++ b/Testing/SystemTests/scripts/InstallerTests.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) """Finds a package, installs it and runs the tests against it. """ import argparse diff --git a/Testing/SystemTests/scripts/mantidinstaller.py b/Testing/SystemTests/scripts/mantidinstaller.py index 4b589a0f27696af45bf6ed54ed0b10892cc8e012..0e59456109b57d318595a6ce5893075f0a47782c 100644 --- a/Testing/SystemTests/scripts/mantidinstaller.py +++ b/Testing/SystemTests/scripts/mantidinstaller.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) """Defines classes for handling installation """ import platform diff --git a/Testing/SystemTests/scripts/performance/analysis.py b/Testing/SystemTests/scripts/performance/analysis.py index 2654be90a0188185ac6973f76b865b79f67da75a..16e027062d080969f5c4ddd22705efc8008b3691 100644 --- a/Testing/SystemTests/scripts/performance/analysis.py +++ b/Testing/SystemTests/scripts/performance/analysis.py @@ -7,8 +7,6 @@ """ Module containing functions for test performance analysis, plotting, and saving to other formats (CSV, PDF) """ -from __future__ import (absolute_import, division, print_function) -from six.moves import range import testresult import os import sys @@ -24,6 +22,8 @@ import random DATE_STR_FORMAT = "%Y-%m-%d %H:%M:%S.%f" #============================================================================================ + + def get_orderby_clause(last_num): """Returns a order by clause that limits to the last # revisions """ if last_num > 0: @@ -98,6 +98,8 @@ def get_unique_fields(results, field): return list(out) #============================================================================================ + + def get_results_matching(results, field, value): """Given a list of TestResult, return a list of TestResult's where 'field' matches 'value'.""" @@ -275,6 +277,8 @@ default_html_header = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transition default_html_footer = """</body></html>""" #============================================================================================ + + def make_css_file(path): """ Make a save the report.css file to be used by all html """ default_css = """ @@ -310,6 +314,8 @@ font-weight: bold; f.close() #============================================================================================ + + def make_environment_html(res): """Return a HTML string with details of test environment, taken from the 'res' TestResult object""" @@ -322,6 +328,8 @@ def make_environment_html(res): return html #============================================================================================ + + def make_detailed_html_file(basedir, name, fig1, fig2, fig3, fig4, last_num): """ Create a detailed HTML report for the named test """ html = default_html_header diff --git a/Testing/SystemTests/scripts/performance/sqlresults.py b/Testing/SystemTests/scripts/performance/sqlresults.py index ed4d530cb3c9cc7f3fd694ffcca7cd94252ea2eb..ec1f57c4836bb0ce8e1523bab0601ddf1b574392 100644 --- a/Testing/SystemTests/scripts/performance/sqlresults.py +++ b/Testing/SystemTests/scripts/performance/sqlresults.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -from six.moves import range try: import sqlite3 has_sql = True @@ -22,6 +20,8 @@ import math import random #==================================================================================== + + def getSourceDir(): """Returns the location of the source code.""" import os @@ -44,17 +44,23 @@ TABLE_FIELDS = ['date', 'name', 'type', 'host', 'environment', 'runner', database_file = os.path.join(getSourceDir(), "MantidSystemTests.db") #===================================================================== + + def get_database_filename(): """Return the path to the database to use """ return database_file #===================================================================== + + def set_database_filename(value): """Override the default database location""" global database_file database_file = value #===================================================================== + + def SQLgetConnection(): """ Get a connection to the SQL database """ # These are automatic conversion factors @@ -103,6 +109,8 @@ def get_latest_result(name=''): return None #===================================================================== + + def get_results(name, type="", where_clause='', orderby_clause=''): """Return a list of testresult.TestResult objects generated from looking up in the table @@ -179,6 +187,8 @@ def get_all_field_values(field_name, where_clause=""): return out #===================================================================== + + def get_latest_revison(): """ Return the latest revision number """ # Now get the latest revision @@ -193,6 +203,8 @@ def get_latest_revison(): return 0 #===================================================================== + + def add_revision(): """ Adds an entry with the current date/time to the table. Retrieve the index of that entry = the "revision". diff --git a/Testing/SystemTests/scripts/runSystemTests.py b/Testing/SystemTests/scripts/runSystemTests.py index 641d723a0415a0919255e6a06af1dcedd5f2b399..c850a3c1cf0528272579e04d97da7f3f4b9da22d 100755 --- a/Testing/SystemTests/scripts/runSystemTests.py +++ b/Testing/SystemTests/scripts/runSystemTests.py @@ -5,15 +5,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import argparse import os import sys import time from multiprocessing import Process, Array, Manager, Value, Lock -from six import itervalues try: # If any tests happen to hit a PyQt4 import make sure item uses version 2 of the api # Remove this when everything is switched to qtpy @@ -326,7 +323,7 @@ def main(): if options.dry_run: print() print("Tests that would be executed:") - for suites in itervalues(test_list): + for suites in test_list.values(): for suite in suites: print(' ' + suite.name) elif not options.clean: diff --git a/Testing/SystemTests/tests/analysis/AbinsTest.py b/Testing/SystemTests/tests/analysis/AbinsTest.py index 0201954fbf1e3063aac61777648295c977fbd749..25ff1bb60536e5311404823a8231755a804d8f43 100644 --- a/Testing/SystemTests/tests/analysis/AbinsTest.py +++ b/Testing/SystemTests/tests/analysis/AbinsTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import Abins, mtd, DeleteWorkspace from AbinsModules import AbinsConstants, AbinsTestHelpers diff --git a/Testing/SystemTests/tests/analysis/BASISTest.py b/Testing/SystemTests/tests/analysis/BASISTest.py index 5f3fd867b0db7c1bfa28f3d000427a5f08e992f8..bbb972a2403c329964ba9b7ecb370919184fb96b 100644 --- a/Testing/SystemTests/tests/analysis/BASISTest.py +++ b/Testing/SystemTests/tests/analysis/BASISTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid import config from mantid.simpleapi import (BASISCrystalDiffraction, GroupWorkspaces, diff --git a/Testing/SystemTests/tests/analysis/BilbySANSDataProcessorTest.py b/Testing/SystemTests/tests/analysis/BilbySANSDataProcessorTest.py index 3c10edae98685a112ba2cde25ceed404a7fa20c8..4cf3748bec98a6f90830c9a98b717d732c7f9947 100644 --- a/Testing/SystemTests/tests/analysis/BilbySANSDataProcessorTest.py +++ b/Testing/SystemTests/tests/analysis/BilbySANSDataProcessorTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import systemtesting from BilbyReductionScript import RunBilbyReduction diff --git a/Testing/SystemTests/tests/analysis/BuildSQWTest.py b/Testing/SystemTests/tests/analysis/BuildSQWTest.py index 4b041e1d8d4f696acedcd2449a224dc1c8daff78..46c56034e5109a7d39a6a2279b04b3afb76691eb 100644 --- a/Testing/SystemTests/tests/analysis/BuildSQWTest.py +++ b/Testing/SystemTests/tests/analysis/BuildSQWTest.py @@ -13,7 +13,6 @@ the result file that is ~30Gb. The files are not included with the standard repository & required to be accessible from any machine that wishes to run the test. """ -from __future__ import (absolute_import, division, print_function) import systemtesting import os from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py b/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py index dab0cd186996ecf3439459b93fe06aa5b640d463..6fbc2de35738cf1d2031842a612c338b93e2c222 100644 --- a/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py +++ b/Testing/SystemTests/tests/analysis/CRISPLoadingTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from LoadAndCheckBase import * diff --git a/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py b/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py index 0d81439462b866c84cd4c629cdacff393c1a766c..42a33495902a219456a9546770c78e6f3889efba 100644 --- a/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py +++ b/Testing/SystemTests/tests/analysis/CalibrateRectangularDetector_Test.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting import os from mantid.simpleapi import * -from six import string_types def _skip_test(): @@ -49,7 +47,7 @@ class PG3Calibration(systemtesting.MantidSystemTest): MaxOffset=0.01, PeakPositions = '.6866,.7283,.8185,.8920,1.0758,1.2615,2.0599', CrossCorrelation = False, RunNumber = 'PG3_2538') - if isinstance(output, string_types): + if isinstance(output, str): self.saved_cal_file = output.replace('.h5','.cal') else: raise NotImplementedError("Output from CalibrateRectangularDetectors is NOT string for calibration file name!") @@ -97,7 +95,7 @@ class PG3CCCalibration(systemtesting.MantidSystemTest): MaxOffset=0.01, PeakPositions = '0.7282933,1.261441',DetectorsPeaks = '17,6', CrossCorrelation = True, RunNumber = 'PG3_2538') - if isinstance(output, string_types): + if isinstance(output, str): self.saved_cal_file = output.replace('.h5','.cal') else: raise NotImplementedError("Output from CalibrateRectangularDetectors is NOT string for calibration file name!") diff --git a/Testing/SystemTests/tests/analysis/CodeConventions.py b/Testing/SystemTests/tests/analysis/CodeConventions.py index a9bd3f22393321463c45f54df269cea93a5832d1..fec9d63d6bc527d85a52eb8f98cc559099f07403 100644 --- a/Testing/SystemTests/tests/analysis/CodeConventions.py +++ b/Testing/SystemTests/tests/analysis/CodeConventions.py @@ -5,14 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import re import mantid from mantid.simpleapi import * -from six.moves import range -from six import iteritems - MAX_ALG_LEN = 40 # TODO convention says 20 is the maximum SPECIAL = ["InputWorkspace", "OutputWorkspace", "Workspace", @@ -140,7 +136,7 @@ class Algorithms(systemtesting.MantidSystemTest): def runTest(self): algs = AlgorithmFactory.getRegisteredAlgorithms(True) - for (name, versions) in iteritems(algs): + for (name, versions) in algs.items(): if not self.verifyAlgName(name): self.__ranOk += 1 continue diff --git a/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py b/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py index c8885d6b5b36de0dd9e9640216474670b32cbe81..1d01967678e81d118bfcd7057e0b532638381836 100644 --- a/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py +++ b/Testing/SystemTests/tests/analysis/ConvertToMDworkflow.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/CountReflectionsTest.py b/Testing/SystemTests/tests/analysis/CountReflectionsTest.py index 6d1ed6b7ca7bdd5bf149f2d3d7d2f6a41246d8a4..034d61ef831a6d8839326a8fb15a5100073c8195 100644 --- a/Testing/SystemTests/tests/analysis/CountReflectionsTest.py +++ b/Testing/SystemTests/tests/analysis/CountReflectionsTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from SortHKLTest import HKLStatisticsTestMixin diff --git a/Testing/SystemTests/tests/analysis/DOSTest.py b/Testing/SystemTests/tests/analysis/DOSTest.py index 5534dbfc9c3e5439ff000bb596f7369de25e2814..65c9cfe91c2abbadafc4c2763a93f2180436e98d 100644 --- a/Testing/SystemTests/tests/analysis/DOSTest.py +++ b/Testing/SystemTests/tests/analysis/DOSTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.kernel import * from mantid.api import * diff --git a/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py b/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py index bf399cb583ae0832e2d2c82e9e81be5e2293f324..610748049bd52934cee9b611dac5b9065bed95fd 100644 --- a/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py +++ b/Testing/SystemTests/tests/analysis/Diffraction_Workflow_Test.py @@ -9,7 +9,6 @@ System test that loads TOPAZ single-crystal data, and runs Diffraction Workflow. """ -from __future__ import (absolute_import, division, print_function) import systemtesting import numpy import os diff --git a/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py b/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py index bf569483a6765694657f0f36df7deb6296c6031f..053b76edaac92eefa30176097b23ba45164c3c33 100644 --- a/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py +++ b/Testing/SystemTests/tests/analysis/DirectInelasticDiagnostic2.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) #pylint: disable=invalid-name,no-init import os from systemtesting import MantidSystemTest diff --git a/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py b/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py index 928e96618731bbcdca77eaaf225504e05561b158..ce506f929162307dd23cfd6e1aa9d0888b6b32ba 100644 --- a/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py +++ b/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting import math import os diff --git a/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py b/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py index c6477b2dc744c73fe428633fc5aabf89c514be2e..1502d84000652e3cf847493227838171678848a6 100644 --- a/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py +++ b/Testing/SystemTests/tests/analysis/EQSANSSolidAPIv2.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from reduction_workflow.instruments.sans.sns_command_interface import * diff --git a/Testing/SystemTests/tests/analysis/EnggCalibrationTest.py b/Testing/SystemTests/tests/analysis/EnggCalibrationTest.py index 48a3bf557c0e0d862144346542428af99f0bac9f..7a82a7c9b65d981280e32cb7dfb38606298948e0 100644 --- a/Testing/SystemTests/tests/analysis/EnggCalibrationTest.py +++ b/Testing/SystemTests/tests/analysis/EnggCalibrationTest.py @@ -7,7 +7,6 @@ # pylint: disable=no-init import systemtesting from mantid.simpleapi import * -from six import PY2 def rel_err_less_delta(val, ref, epsilon): @@ -239,8 +238,6 @@ class EnginXCalibrateFullThenCalibrateTest(systemtesting.MantidSystemTest): for idx in [0, 12, 516, 789, 891, 1112]: cell_val = self.peaks_info.cell(idx, 1) self.assertTrue(isinstance(cell_val, str)) - if PY2: # This test depends on consistent ordering of a dict which is not guaranteed for python 3 - self.assertEqual(cell_val[0:11], '{"1": {"A":') self.assertEqual(cell_val[-2:], '}}') # this will be used as a comparison delta in relative terms (percentage) diff --git a/Testing/SystemTests/tests/analysis/EnginXScriptTest.py b/Testing/SystemTests/tests/analysis/EnginXScriptTest.py index 078ded2ee25261231fd27d5614bc22dd02b4471e..02ab8e33ec462bb6da9daae8bfcc9988a89ae8fe 100644 --- a/Testing/SystemTests/tests/analysis/EnginXScriptTest.py +++ b/Testing/SystemTests/tests/analysis/EnginXScriptTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os import shutil import systemtesting diff --git a/Testing/SystemTests/tests/analysis/GSASIIRefineFitPeaksTest.py b/Testing/SystemTests/tests/analysis/GSASIIRefineFitPeaksTest.py index 53954c27557f1a9bb1eceb674e09ac2d647c2b19..d3dff75930a1f3b29d1a9e7c6784efd1cef10233 100644 --- a/Testing/SystemTests/tests/analysis/GSASIIRefineFitPeaksTest.py +++ b/Testing/SystemTests/tests/analysis/GSASIIRefineFitPeaksTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from abc import ABCMeta, abstractmethod import os import re diff --git a/Testing/SystemTests/tests/analysis/GUIStartupTest.py b/Testing/SystemTests/tests/analysis/GUIStartupTest.py index 73efbf4fef27dd2349a57512ba1013945971a368..edacdbea8a09e607fcc677026c23556c76cb2357 100644 --- a/Testing/SystemTests/tests/analysis/GUIStartupTest.py +++ b/Testing/SystemTests/tests/analysis/GUIStartupTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os import platform import subprocess diff --git a/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py b/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py index f20d6fe3bfd76f082510d9c8fb9244aeaeb62cc9..6ecc3080b6ae171f82f20bccb402144f047964b6 100644 --- a/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py +++ b/Testing/SystemTests/tests/analysis/HFIRTestsAPIv2.py @@ -13,7 +13,6 @@ The following tests were converted from the unittest framework that is part of python to the systemtesting framework used in Mantid. """ -from __future__ import (absolute_import, division, print_function) import types import traceback diff --git a/Testing/SystemTests/tests/analysis/ILLDetectorEfficiencyCorUserTest.py b/Testing/SystemTests/tests/analysis/ILLDetectorEfficiencyCorUserTest.py index fe96ca2f448fd4bebd3db54a56ee92c242f710ea..a937ef3c9805b971ff317dcf27b032e8bcfde73a 100644 --- a/Testing/SystemTests/tests/analysis/ILLDetectorEfficiencyCorUserTest.py +++ b/Testing/SystemTests/tests/analysis/ILLDetectorEfficiencyCorUserTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy import systemtesting from mantid.simpleapi import (ConvertUnits, DetectorEfficiencyCorUser, DirectILLCollectData) diff --git a/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py b/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py index d4462d82145e6a6283d663127884a89a45c0a041..dba4f6a6d5b2c06b093d8d42ce5cdf047a402824 100644 --- a/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py +++ b/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid import mtd from mantid.simpleapi import (config, CropWorkspace, DeleteWorkspace, DirectILLApplySelfShielding, DirectILLCollectData, DirectILLDiagnostics, DirectILLIntegrateVanadium, DirectILLReduction, DirectILLSelfShielding, diff --git a/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py b/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py index 07f9f82ca7039021a0ad9c4684589606f6c0e7ad..17133ebbe370317c10d9a20eea4815ee11cb40aa 100644 --- a/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py +++ b/Testing/SystemTests/tests/analysis/ILLPowderD2BEfficiencyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import PowderILLEfficiency, GroupWorkspaces from mantid import config, mtd diff --git a/Testing/SystemTests/tests/analysis/ILLPowderDetectorScanTest.py b/Testing/SystemTests/tests/analysis/ILLPowderDetectorScanTest.py index 6862da7fc68810f6ee263960b2a45413795f6d36..46f51f9e22f73139dcb88e608fd86345a0f4be2f 100644 --- a/Testing/SystemTests/tests/analysis/ILLPowderDetectorScanTest.py +++ b/Testing/SystemTests/tests/analysis/ILLPowderDetectorScanTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyClosureTest.py b/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyClosureTest.py index e73e60c4ca1569c50e3af18a911c8e7c1db7ddea..c38e5b167ae963f02fc89d9b9a46d05cef1b8b80 100644 --- a/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyClosureTest.py +++ b/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyClosureTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from tempfile import gettempdir from os import path, remove import systemtesting diff --git a/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyTest.py b/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyTest.py index efab9cef6ae31a0129afe878ed8bed060fa2616b..a1edd2e7e4f47df24557d9ccf238f390a4b389d4 100644 --- a/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyTest.py +++ b/Testing/SystemTests/tests/analysis/ILLPowderEfficiencyTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import PowderILLEfficiency, GroupWorkspaces from mantid import config, mtd diff --git a/Testing/SystemTests/tests/analysis/ILLPowderParameterScanTest.py b/Testing/SystemTests/tests/analysis/ILLPowderParameterScanTest.py index a98317f161ef9aef4a4b730d32285e6b71a6bec8..6a07aadf012a299b543c10fd973811eb2b3b0453 100644 --- a/Testing/SystemTests/tests/analysis/ILLPowderParameterScanTest.py +++ b/Testing/SystemTests/tests/analysis/ILLPowderParameterScanTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import PowderILLParameterScan from mantid import config, mtd diff --git a/Testing/SystemTests/tests/analysis/ILLReflAutoProcessTest.py b/Testing/SystemTests/tests/analysis/ILLReflAutoProcessTest.py index 9b71506c5e19e4575e4034a74eb8173246e40793..bfa2dfe0860286ffe85d4f8741cbee8fa448b166 100644 --- a/Testing/SystemTests/tests/analysis/ILLReflAutoProcessTest.py +++ b/Testing/SystemTests/tests/analysis/ILLReflAutoProcessTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import ReflectometryILLAutoProcess, config, mtd diff --git a/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py b/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py index 4a20e2f4295ebd945aaa186505d63d91115a07ad..8d445c416dff000199e0d92894230bf2053a7d00 100644 --- a/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py +++ b/Testing/SystemTests/tests/analysis/ISISDirectInelastic.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from mantid.api import Workspace @@ -14,11 +13,10 @@ import shutil from abc import ABCMeta, abstractmethod from Direct.PropertyManager import PropertyManager -from six import with_metaclass +#---------------------------------------------------------------------- -#---------------------------------------------------------------------- -class ISISDirectInelasticReduction(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class ISISDirectInelasticReduction(metaclass=ABCMeta): """A base class for the ISIS direct inelastic tests The workflow is defined in the runTest() method, simply diff --git a/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py b/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py index 7c94af5a1dd94d699e0f370e8cff9a9cf2d5cab7..fc92255b4ad6d60dde31b636cecfd71cc39ee689 100644 --- a/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py +++ b/Testing/SystemTests/tests/analysis/ISISDirectReductionComponents.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import os import sys import systemtesting diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py b/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py index 1ad59163af653ec9e3c6d12a3402186baff27028..bf83242817d2e0b2cc2fa00a22e79f323edbfeff 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectBayesTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init, too-few-public-methods -from __future__ import (absolute_import, division, print_function) - import warnings import systemtesting @@ -14,8 +12,6 @@ import os from abc import ABCMeta, abstractmethod from mantid.simpleapi import * import platform -from six import with_metaclass - #============================================================================== @@ -329,7 +325,7 @@ class QLWidthTest(systemtesting.MantidSystemTest): #============================================================================== -class JumpFitFunctionTestBase(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class JumpFitFunctionTestBase(metaclass=ABCMeta): def __init__(self): systemtesting.MantidSystemTest.__init__(self) diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py b/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py index 090c193822efee69035f6b9fbe52fa720097b4f9..6587db51b7601605a7c34d1d0a307369c8d8a6d9 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectInelastic.py @@ -73,7 +73,6 @@ systemtesting.MantidSystemTest | ''' -from __future__ import (absolute_import, division, print_function) from abc import ABCMeta, abstractmethod from mantid.simpleapi import * @@ -82,10 +81,8 @@ from mantid.simpleapi import * from mantid.api import FileFinder from systemtesting import MantidSystemTest, using_gsl_v1 -from six import with_metaclass - -class ISISIndirectInelasticBase(with_metaclass(ABCMeta, MantidSystemTest)): +class ISISIndirectInelasticBase(MantidSystemTest, metaclass=ABCMeta): ''' A common base class for the ISISIndirectInelastic* base classes. ''' @@ -157,7 +154,7 @@ class ISISIndirectInelasticBase(with_metaclass(ABCMeta, MantidSystemTest)): #============================================================================== -class ISISIndirectInelasticReduction(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticReduction(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic reduction tests The workflow is defined in the _run() method, simply @@ -386,7 +383,7 @@ class IRISMultiFileSummedReduction(ISISIndirectInelasticReduction): #============================================================================== -class ISISIndirectInelasticCalibration(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticCalibration(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic calibration tests The workflow is defined in the _run() method, simply @@ -457,7 +454,7 @@ class IRISCalibration(ISISIndirectInelasticCalibration): #============================================================================== -class ISISIndirectInelasticResolution(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticResolution(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic resolution tests The workflow is defined in the _run() method, simply @@ -545,7 +542,7 @@ class IRISResolution(ISISIndirectInelasticResolution): #============================================================================== -class ISISIndirectInelasticDiagnostics(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticDiagnostics(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic diagnostic tests The workflow is defined in the _run() method, simply @@ -619,7 +616,7 @@ class OSIRISDiagnostics(ISISIndirectInelasticDiagnostics): #============================================================================== -class ISISIndirectInelasticMoments(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticMoments(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic TransformToIqt/TransformToIqtFit tests The output of Elwin is usually used with MSDFit and so we plug one into @@ -683,7 +680,7 @@ class IRISMoments(ISISIndirectInelasticMoments): #============================================================================== -class ISISIndirectInelasticElwinAndMSDFit(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticElwinAndMSDFit(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic Elwin/MSD Fit tests The output of Elwin is usually used with MSDFit and so we plug one into @@ -785,7 +782,7 @@ class IRISElwinAndMSDFit(ISISIndirectInelasticElwinAndMSDFit): #============================================================================== -class ISISIndirectInelasticIqtAndIqtFit(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticIqtAndIqtFit(metaclass=ABCMeta): ''' A base class for the ISIS indirect inelastic Iqt/IqtFit tests @@ -909,7 +906,7 @@ class IRISIqtAndIqtFit(ISISIndirectInelasticIqtAndIqtFit): #============================================================================== -class ISISIndirectInelasticIqtAndIqtFitMulti(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticIqtAndIqtFitMulti(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic Iqt/IqtFit tests The output of Elwin is usually used with MSDFit and so we plug one into @@ -1043,7 +1040,7 @@ class IRISIqtAndIqtFitMulti(ISISIndirectInelasticIqtAndIqtFitMulti): #============================================================================== -class ISISIndirectInelasticConvFit(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticConvFit(metaclass=ABCMeta): '''A base class for the ISIS indirect inelastic ConvFit tests The workflow is defined in the _run() method, simply @@ -1148,7 +1145,7 @@ class IRISConvFit(ISISIndirectInelasticConvFit): # Transmission Monitor Test -class ISISIndirectInelasticTransmissionMonitor(with_metaclass(ABCMeta, ISISIndirectInelasticBase)): +class ISISIndirectInelasticTransmissionMonitor(metaclass=ABCMeta): # Mark as an abstract class def _run(self): '''Defines the workflow for the test''' diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py b/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py index 370e2abd3cdf1a9bc19c6669ae2158f76c2d99d8..90cdf90ea292c942ae171a25e3d60b059599619d 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectLoadAsciiTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid.simpleapi as ms diff --git a/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py b/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py index 28ffe767b136643f3b770cda73efd72116c1f374..348892de97abeae8d7f8ebf09cc84ae27408b80e 100644 --- a/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py +++ b/Testing/SystemTests/tests/analysis/ISISIndirectSimulationTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid.simpleapi as ms diff --git a/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py b/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py index 6f4cd225177151e29f0e8a0193d4eaa794beefa1..09bf72ffcf8c085940649c233180ee6a2bc8ca38 100644 --- a/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py +++ b/Testing/SystemTests/tests/analysis/ISISMuonAnalysis.py @@ -5,18 +5,15 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,attribute-defined-outside-init,too-many-instance-attributes,too-few-public-methods -from __future__ import (absolute_import, division, print_function) import math import systemtesting from mantid.simpleapi import * from abc import ABCMeta, abstractmethod -from six import with_metaclass - #---------------------------------------------------------------------- -class ISISMuonAnalysis(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class ISISMuonAnalysis(systemtesting.MantidSystemTest, metaclass=ABCMeta): """A base class for the ISIS Muon Analysis tests The workflow is defined in the runTest() method, simply diff --git a/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py b/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py index 6331a0ea99959cac8238fc0686eb04820fe07315..92b7967f8b87e2551a2373c2d3d9b7e9d6138e54 100644 --- a/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py +++ b/Testing/SystemTests/tests/analysis/ISISMuonAnalysisGrouping.py @@ -5,17 +5,14 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init,too-many-instance-attributes,too-few-public-methods -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from abc import ABCMeta, abstractmethod -from six import with_metaclass - #---------------------------------------------------------------------- -class ISISMuonAnalysisGrouping(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class ISISMuonAnalysisGrouping(systemtesting.MantidSystemTest, metaclass=ABCMeta): """A base class for the ISIS Muon Analysis tests The workflow is defined in the runTest() method, simply diff --git a/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py b/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py index e6cf63637416e9d268abb632b262a4f04953cb27..0fe57b9fbb8720b2327713256fce8c3820b8d799 100644 --- a/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py +++ b/Testing/SystemTests/tests/analysis/ISISReflInstrumentIDFTest.py @@ -9,15 +9,13 @@ These system tests are to verify that the IDF and parameter files for POLREF, CRISP, INTER and SURF are read properly """ -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import os from abc import ABCMeta, abstractmethod -from six import with_metaclass -class ISISReflInstrumentIDFTest(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class ISISReflInstrumentIDFTest(systemtesting.MantidSystemTest, metaclass=ABCMeta): @abstractmethod def get_IDF_name(self): diff --git a/Testing/SystemTests/tests/analysis/ISISReflectometryWorkflowBase.py b/Testing/SystemTests/tests/analysis/ISISReflectometryWorkflowBase.py index ecf743351845b5ef95477b50c8657a1de0bb46c7..bbbff8a0470583ceafb7425dcc1d482364ef9117 100644 --- a/Testing/SystemTests/tests/analysis/ISISReflectometryWorkflowBase.py +++ b/Testing/SystemTests/tests/analysis/ISISReflectometryWorkflowBase.py @@ -8,7 +8,6 @@ System Test for ISIS Reflectometry reduction Adapted from scripts provided by Max Skoda. """ -from __future__ import (print_function) from mantid.simpleapi import * from mantid import ConfigService diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py index a5202313cb861a03f5bfb9329282b13454e70691..df6792bcba004d4ce0ca288bc04e3fd42453fb0e 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderGemTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import systemtesting import shutil diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderHRPDTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderHRPDTest.py index ced0d1ff131beb7a963c3816b300a6cea13d6949..8b5e3a854b1af2f5faa41fab2bf68fb508529114 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderHRPDTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderHRPDTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import platform import shutil diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py index 42d64ef90d06a727dbb3d8ab82e4c207a421e524..72ca3f6abce61ac865bf873e932860a5fc890319 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPearlTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import systemtesting import shutil diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py index 4dc45f8bf01fba19fd58326b71dbbd5473f15254..e0e9911071b37d1b0e77560fa42bc30e124e0e70 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py +++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import os import systemtesting diff --git a/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py b/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py index 8165d9f397d2b7b5a28f2e95556197c7ac3ee464..b071c1c91a31fd280df0feec7adc3bb2646fc3a9 100644 --- a/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py +++ b/Testing/SystemTests/tests/analysis/IndirectDiffractionTests.py @@ -6,16 +6,13 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,non-parent-init-called,too-few-public-methods # non-parent-init-called is disabled to remove false positives from a bug in pyLint < 1.4 -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta, abstractmethod import systemtesting import mantid.simpleapi as ms from mantid import mtd -from six import with_metaclass -class ISISIndirectDiffractionReduction(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class ISISIndirectDiffractionReduction(metaclass=ABCMeta): """ Base class for tests that use the ISISIndirectDiffractionReduction algorithm. """ diff --git a/Testing/SystemTests/tests/analysis/IndirectQuickRunTest.py b/Testing/SystemTests/tests/analysis/IndirectQuickRunTest.py index 397f77f285e22a0ee4c62d16e60565805dfbfe2c..7508455ed51f72d16863e739fb6e546cf0f3e238 100644 --- a/Testing/SystemTests/tests/analysis/IndirectQuickRunTest.py +++ b/Testing/SystemTests/tests/analysis/IndirectQuickRunTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import (AnalysisDataService, WorkspaceGroup) from mantid.simpleapi import (CompareWorkspaces, IndirectQuickRun, LoadNexus) import systemtesting diff --git a/Testing/SystemTests/tests/analysis/LinkedUBs_Test.py b/Testing/SystemTests/tests/analysis/LinkedUBs_Test.py index 2107e4d37b3696cd004cbea6a190959b27181c65..2a5f88159d5421fcbe41ed4442b02cbcaae2cc67 100644 --- a/Testing/SystemTests/tests/analysis/LinkedUBs_Test.py +++ b/Testing/SystemTests/tests/analysis/LinkedUBs_Test.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,no-init # System test that loads short SXD numors and runs LinkedUBs. -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import numpy as np diff --git a/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py b/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py index 6efd57d980f1293e4b201232ea720918815c97fc..fd4450316a7903f6bee08933ebf9fcb49beec644 100644 --- a/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py +++ b/Testing/SystemTests/tests/analysis/LoadAndCheckBase.py @@ -9,16 +9,14 @@ These system tests are to verify the behaviour of the ISIS reflectometry reduction scripts """ -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import mantid.api from abc import ABCMeta, abstractmethod -from six import with_metaclass -class LoadAndCheckBase(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class LoadAndCheckBase(systemtesting.MantidSystemTest, metaclass=ABCMeta): __comparison_out_workspace_name = 'a_integrated' diff --git a/Testing/SystemTests/tests/analysis/LoadExedTest.py b/Testing/SystemTests/tests/analysis/LoadExedTest.py index 530289c0ced512225b11aa5a954c94545c91223c..7a7c7f2dd54d29aab257ff3378f9e9985bf8f855 100644 --- a/Testing/SystemTests/tests/analysis/LoadExedTest.py +++ b/Testing/SystemTests/tests/analysis/LoadExedTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init,too-many-public-methods,too-many-arguments -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid.simpleapi as ms diff --git a/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py b/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py index 52be91c318ed51192fa98b611f855421f9dc9cc8..2cd7f558782e23f85b5703274482d15cb8ba7e9f 100644 --- a/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py +++ b/Testing/SystemTests/tests/analysis/LoadLotsOfFiles.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,no-init -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import config, Load from mantid.api import FrameworkManager import os diff --git a/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py b/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py index d58fa443b22e014d48a9b7ff0b2ace3b6fdbc02c..681691016dd77f922bf11eed1659e54115fbe742 100644 --- a/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py +++ b/Testing/SystemTests/tests/analysis/LoadLotsOfInstruments.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-few-public-methods -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import FrameworkManager import os diff --git a/Testing/SystemTests/tests/analysis/LoadVesuvioTest.py b/Testing/SystemTests/tests/analysis/LoadVesuvioTest.py index f03b9634a9d2cb2a78f80430e3c1897a8765c0e5..efec2c29a3cbb0cde29e36f6af5e4b6f1dac525a 100644 --- a/Testing/SystemTests/tests/analysis/LoadVesuvioTest.py +++ b/Testing/SystemTests/tests/analysis/LoadVesuvioTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init,too-many-public-methods,too-many-arguments -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.api import FileFinder, MatrixWorkspace, mtd diff --git a/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py b/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py index bdff0a744c9885021ab1c58d335f577353d78edd..63c930e0d209fcb74cd1ac2efda18805d848dfbe 100644 --- a/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py +++ b/Testing/SystemTests/tests/analysis/MDWorkspaceTests.py @@ -10,14 +10,11 @@ Test some features of MDWorkspaces, such as file-backed MDWorkspaces. """ -from __future__ import (absolute_import, division, print_function) import systemtesting import os from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * -from six.moves import range - ############################################################################### diff --git a/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py b/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py index 681a1dd4bb63b1dadabcfebeca6d7bad0415727a..9d0a9f547d13101ad6b778ee054c1a441ca21933 100644 --- a/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py +++ b/Testing/SystemTests/tests/analysis/POLDICreatePeaksFromCellTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-locals,too-few-public-methods -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py b/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py index 9f0b190f65fc53615dc2f16e9d76735cb3701543..ab6460a003ca5801cbf84d01ba780f067b4b0e51 100644 --- a/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py +++ b/Testing/SystemTests/tests/analysis/POLDIFitPeaks1DTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import numpy as np diff --git a/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py b/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py index 150b55b0447e95b999624116a8481347147e407a..468486569457214aed679a882de1152c3a314829 100644 --- a/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py +++ b/Testing/SystemTests/tests/analysis/POLDIFitPeaks2DTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name,too-many-locals,too-few-public-methods -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import numpy as np diff --git a/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py b/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py index 45b539145507a96a1a700ad9c90953a776119cb5..1b4aac129cc1fe7350f05521d1978a9d3444997f 100644 --- a/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py +++ b/Testing/SystemTests/tests/analysis/Peak2ConvCell_Test.py @@ -15,7 +15,6 @@ # import systemtesting -from __future__ import (absolute_import, division, print_function) import numpy from numpy import matrix import math diff --git a/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py b/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py index 0dc688183327c3ac8e099d207726c61442aad1f7..401081ae39b9b9e15f7bd1096a4dc903cb8ca04f 100644 --- a/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py +++ b/Testing/SystemTests/tests/analysis/PowderDiffProfileCalibrateTest.py @@ -14,7 +14,6 @@ # for powder diffractometers. # ######################################################################## -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid.simpleapi as api from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py b/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py index 4b33526eb53968ee49fe2bd99e440f128bde73b7..976417f44896ed85654ca50ad535101c74569220 100644 --- a/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py +++ b/Testing/SystemTests/tests/analysis/QENSGlobalFitTeixeiraWaterSQE.py @@ -8,7 +8,6 @@ """ Extract or compute the Q values from reduced QENS data """ -from __future__ import (absolute_import, division, print_function) from systemtesting import MantidSystemTest import mantid import mantid.simpleapi as sm diff --git a/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py b/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py index 11135c5e5fb8dde70e00738579eb2aa608e7700c..2f69e364c887da0b12216c167f7d1f5f5c91e56d 100644 --- a/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py +++ b/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py @@ -19,7 +19,6 @@ #information. # # -from __future__ import (absolute_import, division, print_function) import time import systemtesting diff --git a/Testing/SystemTests/tests/analysis/ReflectometryISIS.py b/Testing/SystemTests/tests/analysis/ReflectometryISIS.py index 993f502e81a268e5405f6ceb58ad372f66c1e10f..a03127c059558ebc4d6a1e905f952e3fcb862949 100644 --- a/Testing/SystemTests/tests/analysis/ReflectometryISIS.py +++ b/Testing/SystemTests/tests/analysis/ReflectometryISIS.py @@ -9,15 +9,13 @@ These system tests are to verify the behaviour of the ISIS reflectometry reduction scripts """ -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from abc import ABCMeta, abstractmethod -from six import with_metaclass -class ReflectometryISIS(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class ReflectometryISIS(systemtesting.MantidSystemTest, metaclass=ABCMeta): @abstractmethod def get_workspace_name(self): diff --git a/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py b/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py index 0ba0842ed1c1403f7b78caed36446dba48e50e7f..fcca174b061382ff83d7c04adacc1b48a09aa569 100644 --- a/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py +++ b/Testing/SystemTests/tests/analysis/ReuseExistingCalibration.py @@ -9,7 +9,6 @@ Verifies that a calibration file can be loaded once and reused to apply, using CopyInstrumentParameters, the same calibration in successive reductions. """ -from __future__ import (absolute_import, division, print_function) import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANS2DBatch.py b/Testing/SystemTests/tests/analysis/SANS2DBatch.py index 95c02eb57abb0f6a4c7a36449943b54d280b579b..d04a0ad8e72f3bbe2fde4f38ae4be7f5db729fff 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DBatch.py +++ b/Testing/SystemTests/tests/analysis/SANS2DBatch.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DBatchTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DBatchTest_V2.py index 3a9e223056541e5548a72554a1a6d00e2b4c081a..d7ebb0e83c118ab082eca0a536488c84c4ff056c 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DBatchTest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DBatchTest_V2.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid import config diff --git a/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav.py b/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav.py index bb78811248b865a80ffe62a6940a0729c48bbcc7..a104bf37cd7de3eb4112f891b07bbfd73e7a2cf2 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav.py +++ b/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav_V2.py b/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav_V2.py index 9a645e4cf005bda095bad3e19ebadc1c42629747..99120e0ba26e68d5aa5a774153629dfa225c2b13 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DFrontNoGrav_V2.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid # noqa from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, SetDetectorOffsets, Gravity, Set1D, diff --git a/Testing/SystemTests/tests/analysis/SANS2DLOQReloadWorkspaces.py b/Testing/SystemTests/tests/analysis/SANS2DLOQReloadWorkspaces.py index 270d6648e1d696094e1276836c71638130812281..ad9810975e93f9f6564d006a5e7a19ded2b70cd1 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DLOQReloadWorkspaces.py +++ b/Testing/SystemTests/tests/analysis/SANS2DLOQReloadWorkspaces.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime.py b/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime.py index 547acfe505c5b1c840d4479e28a418c20f6c159c..39966a7c04952212447baece6ce8fcfb572292cc 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime.py +++ b/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime_V2.py b/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime_V2.py index 53328e62be3f40012d26474c79285d33e7a85fb5..6e1dfc64d4b58f9a82751bddb6683b38c0fefa3f 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DLimitEventsTime_V2.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid # noqa from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, AssignSample, WavRangeReduction, diff --git a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod.py b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod.py index 6c2fd280a4ff65c9655d4bc4ae089a07fad669b6..71adc93e5e72b533e34af09bec0ef148c582b423 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod.py +++ b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod.py @@ -7,7 +7,6 @@ #pylint: disable=no-init,too-few-public-methods # test batch mode with sans2d and selecting a period in batch mode -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.api import AnalysisDataService from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFiles.py b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFiles.py index dada802fb1914b9c1c49ba46ce9f6a0013b03308..ec95710827dd07219b0046fcbfb72029f4cda7cc 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFiles.py +++ b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFiles.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py index 0d2879054c0b3cb7cfad45bf81d6aff1b07ac7a4..dc913e1b5c39b2c13933479c57e61f3ed6bba612 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriodAddFilesTest_V2.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) -from __future__ import (absolute_import, division, print_function) import systemtesting import os from mantid.kernel import config diff --git a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod_V2.py b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod_V2.py index 0d83c73d6285531bfdda3058eb3b8c4206e59e55..9f7853cf03a1edd61714e14d09082a383f276c51 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DMultiPeriod_V2.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,too-few-public-methods -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid # noqa diff --git a/Testing/SystemTests/tests/analysis/SANS2DReductionGUI.py b/Testing/SystemTests/tests/analysis/SANS2DReductionGUI.py index 63dc3e11feba66546fa380cdef0aadc01f424fd9..f10c1d276b775e35690dce94ddcb0bbed1a3f05b 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DReductionGUI.py +++ b/Testing/SystemTests/tests/analysis/SANS2DReductionGUI.py @@ -19,7 +19,6 @@ The first 2 Tests ensures that the result provided by the GUI are the same for t Test was first created to apply to Mantid Release 3.0. """ -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import isis_reducer diff --git a/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAdded.py b/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAdded.py index db1f889e3eb84cce579a69b644408caed1699dde..7d9ab6101092f9aafdb44e3321d2d4289c31a195 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAdded.py +++ b/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAdded.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * import ISISCommandInterface as i import copy diff --git a/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAddedTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAddedTest_V2.py index ff15655636707e1677845746702d048fefbdf949..3cc7930caa8e4f2ca5c0ce42cb08a7766a770c90 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAddedTest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DReductionGUIAddedTest_V2.py @@ -10,7 +10,6 @@ One test has been removed from the port since it uses the ReductionSingleton. """ -from __future__ import (absolute_import, division, print_function) import mantid # noqa import systemtesting import os diff --git a/Testing/SystemTests/tests/analysis/SANS2DReductionGUI_V2.py b/Testing/SystemTests/tests/analysis/SANS2DReductionGUI_V2.py index 7d4233374efc409668013b1c8c31a8334758421b..138bec176a4e056f2c7d74bd3b2774695d6bbe95 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DReductionGUI_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DReductionGUI_V2.py @@ -10,7 +10,6 @@ The tests here are ports from the original SANS2DReductionGUI.py test suite. Not include details about the ReductionSingleton """ -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.kernel import (config) from mantid.api import (FileFinder) diff --git a/Testing/SystemTests/tests/analysis/SANS2DSearchCentreGUI.py b/Testing/SystemTests/tests/analysis/SANS2DSearchCentreGUI.py index f6a2c995799b74501b834f6898268901ea592bfa..042f21accd801a1cb45879fb9ad7b4fc3eb56d5d 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DSearchCentreGUI.py +++ b/Testing/SystemTests/tests/analysis/SANS2DSearchCentreGUI.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import mantid # noqa import ISISCommandInterface as i import isis_reducer diff --git a/Testing/SystemTests/tests/analysis/SANS2DSlicing.py b/Testing/SystemTests/tests/analysis/SANS2DSlicing.py index 31003fa3e89770b59ac95ee865cdec10042ea456..77f2556bc9a9de636f2f44b311d481da91305be6 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DSlicing.py +++ b/Testing/SystemTests/tests/analysis/SANS2DSlicing.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DSlicingTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DSlicingTest_V2.py index 691487e97eba38d03df5f4bccbc2b63a2f321fcd..1fc9534c8f31ab82ca1c040fdceda33e4ebc8c9b 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DSlicingTest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DSlicingTest_V2.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.api import (AnalysisDataService, FileFinder) from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, BatchReduce, SetEventSlices, diff --git a/Testing/SystemTests/tests/analysis/SANS2DWaveloops.py b/Testing/SystemTests/tests/analysis/SANS2DWaveloops.py index 426cf71f621a23d20e3d94b73323881c538b9f76..47b4fea5bbea85142063e534fece7ae7290df2bf 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DWaveloops.py +++ b/Testing/SystemTests/tests/analysis/SANS2DWaveloops.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANS2DWaveloopsTest_V2.py b/Testing/SystemTests/tests/analysis/SANS2DWaveloopsTest_V2.py index 27f2bb0525cb39b6aa275d434cd4f30b2e0b0bb4..da0377ce093f850244f4bd7c01324f4e9a68e1e7 100644 --- a/Testing/SystemTests/tests/analysis/SANS2DWaveloopsTest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANS2DWaveloopsTest_V2.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid # noqa from sans.command_interface.ISISCommandInterface import (SANS2D, MaskFile, Gravity, Set1D, AssignSample, diff --git a/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py b/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py index 9e4a98f452847e23d2e9ede41e8a5e70f910e38e..2c6ee286af3104eb32bb408793cacffceae1ee18 100644 --- a/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py +++ b/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) - import unittest import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py b/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py index 6aba9a0c48fe2fe67b1ab3514c824dd2571b5076..384b386f1dae12bb694e7cd30b6c136a19a9ae40 100644 --- a/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py +++ b/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) import unittest import os import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANSCentreSample.py b/Testing/SystemTests/tests/analysis/SANSCentreSample.py index bf6cbca41ee0a05ab4767e30484be7a85bf8f224..8155f2b6cfcdd01e5be6f5d44c94bce4674cbf17 100644 --- a/Testing/SystemTests/tests/analysis/SANSCentreSample.py +++ b/Testing/SystemTests/tests/analysis/SANSCentreSample.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANSDarkRunSubtractionTest.py b/Testing/SystemTests/tests/analysis/SANSDarkRunSubtractionTest.py index e66a5cc48abddc2ed35cd2a9ccd96593ac358e84..7de71954ea3f65f43305cc4e4ffc93d2c23164ed 100644 --- a/Testing/SystemTests/tests/analysis/SANSDarkRunSubtractionTest.py +++ b/Testing/SystemTests/tests/analysis/SANSDarkRunSubtractionTest.py @@ -8,7 +8,6 @@ #pylint: disable=invalid-name #pylint: disable=too-many-arguments #pylint: disable=too-many-public-methods -from __future__ import (absolute_import, division, print_function) import unittest import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py b/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py index 17b37bd2ca5a35d5fb959a101139ab1747223076..f17d4626eef01f1d6be3d9eed8fcdc023e4ea1cd 100644 --- a/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py +++ b/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) import unittest import os import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANSFileChecking.py b/Testing/SystemTests/tests/analysis/SANSFileChecking.py index e9953522b2c8cf9fb0f46edfa97ecfab5fe3d784..40c2f747528c1f6ac54e7a2ea054a58c403bdc8f 100644 --- a/Testing/SystemTests/tests/analysis/SANSFileChecking.py +++ b/Testing/SystemTests/tests/analysis/SANSFileChecking.py @@ -10,7 +10,6 @@ Check that file manipulation works fine """ -from __future__ import (absolute_import, division, print_function) import unittest import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SANSILLAbsoluteScaleTest.py b/Testing/SystemTests/tests/analysis/SANSILLAbsoluteScaleTest.py index 0690c3989203dd48b8564f1a0674175df963955c..99c4674ef07d0f541bba0d0a343fdfbbbdc374ab 100644 --- a/Testing/SystemTests/tests/analysis/SANSILLAbsoluteScaleTest.py +++ b/Testing/SystemTests/tests/analysis/SANSILLAbsoluteScaleTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SANSILLAutoProcessTest.py b/Testing/SystemTests/tests/analysis/SANSILLAutoProcessTest.py index 0e6d54b9abf7181b25617e9e8685597cbb4f59f0..5d3eec88f50078926f2fbe2cbf9a9d6fc205b632 100644 --- a/Testing/SystemTests/tests/analysis/SANSILLAutoProcessTest.py +++ b/Testing/SystemTests/tests/analysis/SANSILLAutoProcessTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import SANSILLAutoProcess, config, mtd, GroupWorkspaces, SaveNexusProcessed import os diff --git a/Testing/SystemTests/tests/analysis/SANSILLReductionTest.py b/Testing/SystemTests/tests/analysis/SANSILLReductionTest.py index bea24b0aac0db00485f5aca390273b6182ca6f5e..d8ec0a1a3af0e6c90c49c64c77cdd3ad6ab61a73 100644 --- a/Testing/SystemTests/tests/analysis/SANSILLReductionTest.py +++ b/Testing/SystemTests/tests/analysis/SANSILLReductionTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SANSLOQAddBatch.py b/Testing/SystemTests/tests/analysis/SANSLOQAddBatch.py index a80df8d4d6230011b28571ce737c9bc3ebee9791..1a2aafbdd5c1aad0f8e0f77a77af4ac8a41703ea 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQAddBatch.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQAddBatch.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from mantid.api import FileFinder diff --git a/Testing/SystemTests/tests/analysis/SANSLOQBatch.py b/Testing/SystemTests/tests/analysis/SANSLOQBatch.py index 17c23c1785fa255cfae29778efd37a42c90c88a9..fb94c339b2ebba2cef1e87b0e32befca0e1b979f 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQBatch.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQBatch.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from mantid import config diff --git a/Testing/SystemTests/tests/analysis/SANSLOQBatch_V2.py b/Testing/SystemTests/tests/analysis/SANSLOQBatch_V2.py index e0334f1e94cf01049caed5bde6b58985011a1a4e..625c09f70aa847be1ae464c2295c9f615ab9a7fc 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQBatch_V2.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQBatch_V2.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import os.path from mantid.kernel import config diff --git a/Testing/SystemTests/tests/analysis/SANSLOQCan2D.py b/Testing/SystemTests/tests/analysis/SANSLOQCan2D.py index 5b9736978925314cc1cf486f0a9b54715d40e05f..b6ffdbec9445b79abdab9544dcc978debfbeecd9 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQCan2D.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQCan2D.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANSLOQCan2D_V2.py b/Testing/SystemTests/tests/analysis/SANSLOQCan2D_V2.py index d9c6ad67bb440ebe743115543516c640fd7cacb9..09ab942c06702446c3f7e68e29d39c0c0ee6a00a 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQCan2D_V2.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQCan2D_V2.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid # noqa from sans.command_interface.ISISCommandInterface import (LOQ, Set2D, Detector, MaskFile, SetDetectorOffsets, Gravity, diff --git a/Testing/SystemTests/tests/analysis/SANSLOQCentreNoGrav.py b/Testing/SystemTests/tests/analysis/SANSLOQCentreNoGrav.py index 36ce185baa572ece700f5d20fe83a769650e2f90..bc16d6a53055d295840901d6878954e76f6fa7a6 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQCentreNoGrav.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQCentreNoGrav.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANSLOQReductionGUI.py b/Testing/SystemTests/tests/analysis/SANSLOQReductionGUI.py index 0c6b834ddcf3fd58b5a2359a6b0dd9ec60e1f450..645ee2fab3469ae4b64c36670210687dc290e57b 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQReductionGUI.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQReductionGUI.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import ISISCommandInterface as i diff --git a/Testing/SystemTests/tests/analysis/SANSLOQReductionGUITest_V2.py b/Testing/SystemTests/tests/analysis/SANSLOQReductionGUITest_V2.py index 4ee325c93ac85e67a9b78c6613a9c9b7b5ede928..fb42b89d2fcdc19de0727895e7a1e09e61f3e526 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQReductionGUITest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQReductionGUITest_V2.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.kernel import config from mantid.api import FileFinder diff --git a/Testing/SystemTests/tests/analysis/SANSLOQTransFitWorkspace2D.py b/Testing/SystemTests/tests/analysis/SANSLOQTransFitWorkspace2D.py index b2e9670faeb53fa401c0633a7961cdb25a5bce0b..0fe7bc76350d286eb80de89cca35bd3ffe2ba333 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOQTransFitWorkspace2D.py +++ b/Testing/SystemTests/tests/analysis/SANSLOQTransFitWorkspace2D.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANSLOWCentreNoGrav_V2.py b/Testing/SystemTests/tests/analysis/SANSLOWCentreNoGrav_V2.py index 7e259d2bf3598fad63578a1d07a579c08e11158d..7a604ede90e17f71dd0cf4032a25bbbc052c28fb 100644 --- a/Testing/SystemTests/tests/analysis/SANSLOWCentreNoGrav_V2.py +++ b/Testing/SystemTests/tests/analysis/SANSLOWCentreNoGrav_V2.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid # noqa from sans.command_interface.ISISCommandInterface import (LOQ, Set1D, Detector, MaskFile, Gravity, AssignSample, diff --git a/Testing/SystemTests/tests/analysis/SANSLoadTest.py b/Testing/SystemTests/tests/analysis/SANSLoadTest.py index 241b311156301933b9030ed02d378b17282fc910..364a9931b847d82952941d28c3122c94909a38de 100644 --- a/Testing/SystemTests/tests/analysis/SANSLoadTest.py +++ b/Testing/SystemTests/tests/analysis/SANSLoadTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) import unittest import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANSLoadersTest.py b/Testing/SystemTests/tests/analysis/SANSLoadersTest.py index 2164482b6cdbe1bdb541e469b75c9a0a6ee1f58d..db4fb67b71ebe4fd4124d046b58ccc9314cc7ce8 100644 --- a/Testing/SystemTests/tests/analysis/SANSLoadersTest.py +++ b/Testing/SystemTests/tests/analysis/SANSLoadersTest.py @@ -11,7 +11,6 @@ take considerable time because it involves loading data. Besides, it uses data t currently available inside the systemtests. """ -from __future__ import (absolute_import, division, print_function) import unittest import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest.py b/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest.py index 93c86a7f091e8588e5cdace2832f4f2c15f35298..8582443594558950476cfa2a2cfcafb8dae5aaf6 100644 --- a/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest.py +++ b/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import DeleteWorkspace, mtd import ISISCommandInterface as i import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest_V2.py b/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest_V2.py index 7576e67bbfa2524f3e5c2b75ea5e0fb2d004acbe..1a401188abcac40c062454e7fa2788eef404d23f 100644 --- a/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest_V2.py +++ b/Testing/SystemTests/tests/analysis/SANSMergedDetectorsTest_V2.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import DeleteWorkspace, mtd from sans.command_interface.ISISCommandInterface import (SANS2DTUBES, MaskFile, SetDetectorOffsets, Gravity, Set1D, diff --git a/Testing/SystemTests/tests/analysis/SANSQResolutionTest.py b/Testing/SystemTests/tests/analysis/SANSQResolutionTest.py index 465452367795e72997834ce76ab9fd60a7884cdf..9eb1adeab130fb7cdea5e6d84d80ee51d1a3040a 100644 --- a/Testing/SystemTests/tests/analysis/SANSQResolutionTest.py +++ b/Testing/SystemTests/tests/analysis/SANSQResolutionTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from ISISCommandInterface import * diff --git a/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py b/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py index 6d76e23a0cd2bdf2e755afab7febc31f3e74b02f..38d44e52b912614435d74b068b8490f5241bfe9d 100644 --- a/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py +++ b/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) import unittest import os import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANSSaveTest.py b/Testing/SystemTests/tests/analysis/SANSSaveTest.py index 20e0947e7fbfa6e386df0d31e7512f116774286c..f2d666dfc792e1ce0b4aebca7568e45266e2086f 100644 --- a/Testing/SystemTests/tests/analysis/SANSSaveTest.py +++ b/Testing/SystemTests/tests/analysis/SANSSaveTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) import os import mantid import unittest diff --git a/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py b/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py index fdf418b6bec85f8c97a5581539aaecc56c6d46d4..3edd09c7a29dd9f24891f91e5ad068ba3559bf63 100644 --- a/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py +++ b/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) - import unittest import systemtesting diff --git a/Testing/SystemTests/tests/analysis/SANSUtilityTest.py b/Testing/SystemTests/tests/analysis/SANSUtilityTest.py index fd733cb52f8695b69c74b176f3ccaf15804f9cb9..13eae87db49d961c239714409a01e0e1ca1ee83d 100644 --- a/Testing/SystemTests/tests/analysis/SANSUtilityTest.py +++ b/Testing/SystemTests/tests/analysis/SANSUtilityTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init,too-few-public-methods -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import SANSUtility as su diff --git a/Testing/SystemTests/tests/analysis/SANSWorkspaceTypeTest.py b/Testing/SystemTests/tests/analysis/SANSWorkspaceTypeTest.py index 7d9088f995f87792087ea6bdee73ce7e8da73de7..b3ccc89fde297bb6286f1957522cf259e3ca6059 100644 --- a/Testing/SystemTests/tests/analysis/SANSWorkspaceTypeTest.py +++ b/Testing/SystemTests/tests/analysis/SANSWorkspaceTypeTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from SANSUtility import can_load_as_event_workspace diff --git a/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py b/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py index 836843de73370406b8fa8e741ff8b273fed584bc..224a3e6fa21bf321ce0796acf6b9da9bdc35f3e1 100644 --- a/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py +++ b/Testing/SystemTests/tests/analysis/SEQUOIAreduction.py @@ -9,7 +9,6 @@ Test the SNS inelatic reduction scripts. """ -from __future__ import (absolute_import, division, print_function) import systemtesting import os import shutil diff --git a/Testing/SystemTests/tests/analysis/SNAPRedux.py b/Testing/SystemTests/tests/analysis/SNAPRedux.py index 5388dcdd86adcfb2101ff13b1fcde63d89cefdd9..15194cde1bc8c9d3fffeea2090a1777d1089f2cc 100644 --- a/Testing/SystemTests/tests/analysis/SNAPRedux.py +++ b/Testing/SystemTests/tests/analysis/SNAPRedux.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * import os diff --git a/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py b/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py index 9b1f1591c9a1a43a1c16df313db71d2599a0687a..db8393c2acaa34e1d0124f2dcb27878416cd1771 100644 --- a/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py +++ b/Testing/SystemTests/tests/analysis/SNSConvertToMDTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-init -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SXDAnalysis.py b/Testing/SystemTests/tests/analysis/SXDAnalysis.py index 7f838c5cddbc2892cd615264c2e03d0c0bb07c96..85f622fbd5a48f4bcbd2e7f708c9ff6a04ea16e9 100644 --- a/Testing/SystemTests/tests/analysis/SXDAnalysis.py +++ b/Testing/SystemTests/tests/analysis/SXDAnalysis.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SaveLoadNexusProcessed.py b/Testing/SystemTests/tests/analysis/SaveLoadNexusProcessed.py index d610fa0e76a627c09ed0d7228d742a875afcbb3b..7f44cf648c3b533b598fdfd3079eeb0db7f55352 100644 --- a/Testing/SystemTests/tests/analysis/SaveLoadNexusProcessed.py +++ b/Testing/SystemTests/tests/analysis/SaveLoadNexusProcessed.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + from abc import ABCMeta, abstractmethod import os -from six import with_metaclass - import systemtesting from mantid.simpleapi import * from mantid import config @@ -22,7 +20,7 @@ def create_file_path(base_name): return filename -class SaveLoadNexusProcessedTestBase(with_metaclass(ABCMeta, systemtesting.MantidSystemTest)): +class SaveLoadNexusProcessedTestBase(systemtesting.MantidSystemTest, metaclass=ABCMeta): filename = None test_ws_name = 'input_ws' diff --git a/Testing/SystemTests/tests/analysis/SaveNexusTest.py b/Testing/SystemTests/tests/analysis/SaveNexusTest.py index 7fafd4e1122f2f843affcf5275902e522d050eb8..0aeb9e5f23b2f202cddebe2c8a1edd52a40cc41f 100644 --- a/Testing/SystemTests/tests/analysis/SaveNexusTest.py +++ b/Testing/SystemTests/tests/analysis/SaveNexusTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init,invalid-name,too-few-public-methods -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import FrameworkManager import os diff --git a/Testing/SystemTests/tests/analysis/SortHKLTest.py b/Testing/SystemTests/tests/analysis/SortHKLTest.py index 8397ed79742836c8341058fc768b6ff395b66e68..17774047eed815a1171e612ffe534e66a9ce7381 100644 --- a/Testing/SystemTests/tests/analysis/SortHKLTest.py +++ b/Testing/SystemTests/tests/analysis/SortHKLTest.py @@ -5,12 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function) import systemtesting import json from mantid.simpleapi import * from mantid.geometry import PointGroupFactory -from six import iteritems class HKLStatisticsTestMixin(object): @@ -43,7 +41,7 @@ class HKLStatisticsTestMixin(object): ub_parameters.update( dict( [(str(x), y if isinstance(y, float) else str(y)) - for x, y in iteritems(raw_ub_parameters)] + for x, y in raw_ub_parameters.items()] )) return ub_parameters @@ -150,7 +148,7 @@ class SortHKLTest(HKLStatisticsTestMixin, systemtesting.MantidSystemTest): unique_map[unique].append(peak) # pylint: disable=unused-variable - for unique_hkl, equivalents in iteritems(unique_map): + for unique_hkl, equivalents in unique_map.items(): if len(equivalents) > 1: reference_peak = equivalents[0] for peak in equivalents[1:]: diff --git a/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py b/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py index 428ca565e8094bc2c0f52350685f2e5fd9d49e85..6c9659df1552ac356c8526224f6377ecfad92a8a 100644 --- a/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py +++ b/Testing/SystemTests/tests/analysis/SpaceGroupFactoryTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) import systemtesting import re from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py b/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py index 2027daf0f38eeb71efbc7365da56071f8e4ad8d9..f8c4e2ff04b1d5c57e1e9cc823e0dd679a515485 100644 --- a/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py +++ b/Testing/SystemTests/tests/analysis/SpaceGroupReflectionConditionsTest.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.simpleapi import * from mantid.geometry import * -from six import iteritems class SpaceGroupReflectionConditionsTest(systemtesting.MantidSystemTest): @@ -26,7 +24,7 @@ class SpaceGroupReflectionConditionsTest(systemtesting.MantidSystemTest): def runTest(self): sgTestDict = self.generateReflectionLists() - for sgName, hkls in iteritems(sgTestDict): + for sgName, hkls in sgTestDict.items(): sg = SpaceGroupFactory.createSpaceGroup(sgName) for hkl in hkls: diff --git a/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py b/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py index 6e425ef8391182e1e1a407a76aeb0c3c035baa03..df7589651589f9df432a1a68029dbc79c8acb03b 100644 --- a/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py +++ b/Testing/SystemTests/tests/analysis/SpaceGroupUnitCellTest.py @@ -5,10 +5,8 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) import systemtesting from mantid.geometry import * -from six import iteritems class SpaceGroupUnitCellTest(systemtesting.MantidSystemTest): @@ -40,7 +38,7 @@ class SpaceGroupUnitCellTest(systemtesting.MantidSystemTest): self._check_spacegroup(sg, monoclinic_c_cells, monoclinic_c_compatiblity[lattice_system]) def _check_spacegroup(self, sg, cells, compatible_metrics): - for system, cell in iteritems(cells): + for system, cell in cells.items(): is_allowed = sg.isAllowedUnitCell(cell) should_be_allowed = system in compatible_metrics diff --git a/Testing/SystemTests/tests/analysis/SphinxWarnings.py b/Testing/SystemTests/tests/analysis/SphinxWarnings.py index 50fbcdfc65bc3e580d0411d1e7a6e2436de1a7a7..4e4b5f087033f097746ba8d3802cff625d44fc99 100644 --- a/Testing/SystemTests/tests/analysis/SphinxWarnings.py +++ b/Testing/SystemTests/tests/analysis/SphinxWarnings.py @@ -10,11 +10,9 @@ Some of the sphinx warnings come from the C++ code, from the properties of the a This test tries to detect the most common such errors. It also detects if a new category is created (i.e. someone uses Utilities instead of Utility) """ -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid import re -from six import iteritems class SphinxWarnings(systemtesting.MantidSystemTest): @@ -88,7 +86,7 @@ class SphinxWarnings(systemtesting.MantidSystemTest): def runTest(self): algs = mantid.AlgorithmFactory.getRegisteredAlgorithms(True) - for (name, versions) in iteritems(algs): + for (name, versions) in algs.items(): for version in versions: if mantid.api.DeprecatedAlgorithmChecker(name,version).isDeprecated()=='': # get an instance diff --git a/Testing/SystemTests/tests/analysis/SurfLoadingTest.py b/Testing/SystemTests/tests/analysis/SurfLoadingTest.py index 1871838f2ad0d9c881e1884918fcf4cbd29ee642..2ee43fd4b908bca7c60866c714c46277d0c01447 100644 --- a/Testing/SystemTests/tests/analysis/SurfLoadingTest.py +++ b/Testing/SystemTests/tests/analysis/SurfLoadingTest.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from LoadAndCheckBase import * diff --git a/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py b/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py index 7300e8ee4f15d267c94243e59b45bf457a9df57a..55e6b9354bfd4e1a8921c25df0337e7b5486a8bc 100644 --- a/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py +++ b/Testing/SystemTests/tests/analysis/TOPAZPeakFinding.py @@ -10,7 +10,6 @@ System test that loads TOPAZ single-crystal data, converts to Q space, finds peaks and indexes them. """ -from __future__ import (absolute_import, division, print_function) import systemtesting import numpy from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/ValidateInstrumentDir.py b/Testing/SystemTests/tests/analysis/ValidateInstrumentDir.py index 6472bc1d7f6766609400c9b33b5a49afbf6e8ddd..98bb21f3c75f99e11032e7256a70d582352cc2c3 100644 --- a/Testing/SystemTests/tests/analysis/ValidateInstrumentDir.py +++ b/Testing/SystemTests/tests/analysis/ValidateInstrumentDir.py @@ -6,17 +6,12 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) - import glob import os from mantid import config -import six import systemtesting -if six.PY2: - from io import open # noqa # Constants FILE_TO_TEST = None # "MARI_Definition.xml" diff --git a/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py b/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py index ca13d12c374eebbbb22fb326f287f780b9468aea..f216e05557288418701bfbdd6cf9030a3aaee7a6 100644 --- a/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py +++ b/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py @@ -12,16 +12,12 @@ Unit test for Vesuvio corrections steps Assumes that mantid can be imported and the data paths are configured to find the Vesuvio data """ -from __future__ import (absolute_import, division, print_function) import systemtesting import numpy as np from mantid.api import * import mantid.simpleapi as ms from mantid import * -from six import iteritems - - # ====================================Helper Functions======================================= @@ -58,7 +54,7 @@ def _create_algorithm(**kwargs): alg.setProperty("CorrectionWorkspaces", "__Correction") alg.setProperty("CorrectedWorkspaces", "__Corrected") alg.setProperty("LinearFitResult", "__LinearFit") - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): alg.setProperty(key, value) return alg diff --git a/Testing/SystemTests/tests/analysis/WishCalibrate.py b/Testing/SystemTests/tests/analysis/WishCalibrate.py index 133c9410c08679b111e3e30ab898386147f2d7c3..fed2bb4a1b3e4f512aebbbfdd0563f87a2b1723f 100644 --- a/Testing/SystemTests/tests/analysis/WishCalibrate.py +++ b/Testing/SystemTests/tests/analysis/WishCalibrate.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import filecmp import numpy as np import os diff --git a/Testing/SystemTests/tests/analysis/WishMasking.py b/Testing/SystemTests/tests/analysis/WishMasking.py index e583061c0747aae5173def243f074cef43af99fd..f093a43696d7acabf89fcd17218d14c4625bfcec 100644 --- a/Testing/SystemTests/tests/analysis/WishMasking.py +++ b/Testing/SystemTests/tests/analysis/WishMasking.py @@ -10,7 +10,6 @@ Tests masking functionality specific to WISH. Working masking behaviour is criti - Email Pascal Manuel @ ISIS if things break here and let him know how his scripts may need to be modified. """ -from __future__ import (absolute_import, division, print_function) import systemtesting import os from mantid.simpleapi import * diff --git a/Testing/SystemTests/tests/analysis/complexShapeAbsorptionsTest.py b/Testing/SystemTests/tests/analysis/complexShapeAbsorptionsTest.py index b8444723c997ea87493eb38d0ea8d4f8c0f7137c..94d14f140f1e203876819be86f9afa6a3393f775 100644 --- a/Testing/SystemTests/tests/analysis/complexShapeAbsorptionsTest.py +++ b/Testing/SystemTests/tests/analysis/complexShapeAbsorptionsTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import systemtesting import mantid.simpleapi as mantid from mantid import config diff --git a/Testing/Tools/cxxtest/build_tools/SCons/test/eprouvette.py b/Testing/Tools/cxxtest/build_tools/SCons/test/eprouvette.py index fe78125a853520991ae442e439587a15d4af66c8..cafee1e0a86888af6af7d5dedc3132d863c92d63 100755 --- a/Testing/Tools/cxxtest/build_tools/SCons/test/eprouvette.py +++ b/Testing/Tools/cxxtest/build_tools/SCons/test/eprouvette.py @@ -7,7 +7,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # vim: encoding=utf-8 -from __future__ import print_function import shutil, os, sys from os.path import isdir, isfile, islink, join from optparse import OptionParser @@ -19,6 +18,7 @@ args = [] available_types = set(['scons']) tool_stdout = PIPE + def main(): global options global args @@ -76,11 +76,13 @@ def main(): for t in tests: clean_test(t) + def crawl_tests(target): """Gather the directories in the test directory.""" files = os.listdir(target) return [f for f in files if isdir(f) and f[0] != '.'] + def purge_tests(dirs): """Look at the test candidates and purge those that aren't from the list""" tests = [] @@ -91,21 +93,25 @@ def purge_tests(dirs): warn("{0} is not a test (missing TestDef.py file).".format(t)) return tests + def warn(msg): """A general warning function.""" if options.verbose: print('[Warn]: ' + msg, file=sys.stderr) + def notice(msg): """A general print function.""" if options.verbose: print(msg) + def debug(msg): """A debugging function""" if options.debug: print(msg) + def run_test(t): """Runs the test in directory t.""" opts = read_opts(t) @@ -138,6 +144,7 @@ def run_test(t): else: print("test '{0}' successful.".format(t)) + def read_opts(t): """Read the test options and return them.""" opts = { @@ -148,6 +155,7 @@ def read_opts(t): exec(open(join(t, "TestDef.py")), opts) return opts + def setup_env(t, opts): """Set up the environment for the test.""" # symlinks @@ -160,6 +168,7 @@ def setup_env(t, opts): os.unlink(to) os.symlink(frm, to) + def teardown_env(t, opts): """Remove all files generated for the test.""" links = opts['links'] @@ -168,6 +177,7 @@ def teardown_env(t, opts): debug('removing link {0}'.format(to)) os.unlink(to) + def clean_test(t): """Remove all generated files.""" opts = read_opts(t) @@ -177,6 +187,7 @@ def clean_test(t): clean_scons(t, opts) teardown_env(t, opts) + def clean_scons(t, opts): """Make scons clean after itself.""" cwd = os.getcwd() @@ -190,6 +201,7 @@ def clean_scons(t, opts): if isfile(sconsign): os.unlink(sconsign) + def run_scons(t, opts): """Run scons test.""" cwd = os.getcwd() diff --git a/Testing/Tools/cxxtest/python/cxxtest/cxxtest_parser.py b/Testing/Tools/cxxtest/python/cxxtest/cxxtest_parser.py index b97709ce36d8fee47f695ee6e67460455a0933dd..09000ae82eb5007816da83bcf58f5dcb38fa9018 100644 --- a/Testing/Tools/cxxtest/python/cxxtest/cxxtest_parser.py +++ b/Testing/Tools/cxxtest/python/cxxtest/cxxtest_parser.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import re #import sys #import getopt @@ -12,6 +11,7 @@ inBlock = 0 options=None lastLineVoid = False + def scanInputFiles(files, _options): '''Scan all input files for test suites''' global options @@ -31,6 +31,8 @@ def scanInputFiles(files, _options): return [options,suites] lineCont_re = re.compile('(.*)\\\s*$') + + def scanInputFile(fileName): '''Scan single input file for test suites''' file = open(fileName) @@ -57,6 +59,7 @@ def scanInputFile(fileName): closeSuite() file.close() + def scanInputLine( fileName, lineNo, line ): '''Scan single input line for interesting stuff''' scanLineForExceptionHandling( line ) @@ -68,6 +71,7 @@ def scanInputLine( fileName, lineNo, line ): if suite: scanLineInsideSuite( suite, lineNo, line ) + def scanLineInsideSuite( suite, lineNo, line ): '''Analyze line which is part of a suite''' global inBlock @@ -76,6 +80,7 @@ def scanLineInsideSuite( suite, lineNo, line ): scanLineForCreate( suite, lineNo, line ) scanLineForDestroy( suite, lineNo, line ) + def lineBelongsToSuite( suite, lineNo, line ): '''Returns whether current line is part of the current suite. This can be false when we are in a generated suite outside of CXXTEST_CODE() blocks @@ -92,6 +97,8 @@ def lineBelongsToSuite( suite, lineNo, line ): std_re = re.compile( r"\b(std\s*::|CXXTEST_STD|using\s+namespace\s+std\b|^\s*\#\s*include\s+<[a-z0-9]+>)" ) + + def scanLineForStandardLibrary( line ): '''Check if current line uses standard library''' global options @@ -100,6 +107,8 @@ def scanLineForStandardLibrary( line ): options.haveStandardLibrary = 1 exception_re = re.compile( r"\b(throw|try|catch|TSM?_ASSERT_THROWS[A-Z_]*)\b" ) + + def scanLineForExceptionHandling( line ): '''Check if current line uses exception handling''' global options @@ -113,6 +122,8 @@ testsuite = '(?:(?:::)?\s*CxxTest\s*::\s*)?TestSuite' suite_re = re.compile( r"\bclass\s+(%s)\s*:(?:\s*%s\s*,)*\s*public\s+%s" % (classdef, baseclassdef, testsuite) ) generatedSuite_re = re.compile( r'\bCXXTEST_SUITE\s*\(\s*(\w*)\s*\)' ) + + def scanLineForSuiteStart( fileName, lineNo, line ): '''Check if current line starts a new test suite''' m = suite_re.search( line ) @@ -123,6 +134,7 @@ def scanLineForSuiteStart( fileName, lineNo, line ): sys.stdout.write( "%s:%s: Warning: Inline test suites are deprecated.\n" % (fileName, lineNo) ) startSuite( m.group(1), fileName, lineNo, 1 ) + def startSuite( name, file, line, generated ): '''Start scanning a new suite''' global suite @@ -139,6 +151,7 @@ def startSuite( name, file, line, generated ): 'tests' : [], 'lines' : [] } + def lineStartsBlock( line ): '''Check if current line starts a new CXXTEST_CODE() block''' return re.search( r'\bCXXTEST_CODE\s*\(', line ) is not None @@ -146,6 +159,8 @@ def lineStartsBlock( line ): test_re = re.compile( r'^([^/]|/[^/])*\bvoid\s+([Tt]est\w+)\s*\(\s*(void)?\s*\)' ) void_re = re.compile( r'^([^/]|/[^/])*\bvoid\s*$' ) test_novoid_re = re.compile( r'^([^/]|/[^/])*\b([Tt]est\w+)\s*\(\s*(void)?\s*\)' ) + + def scanLineForTest( suite, lineNo, line ): '''Check if current line starts a test''' global lastLineVoid @@ -163,6 +178,7 @@ def scanLineForTest( suite, lineNo, line ): if m3: lastLineVoid = True + def addTest( suite, name, line ): '''Add a test function to the current suite''' test = { 'name' : name, @@ -173,6 +189,7 @@ def addTest( suite, name, line ): } suite['tests'].append( test ) + def addLineToBlock( suite, lineNo, line ): '''Append the line to the current CXXTEST_CODE() block''' line = fixBlockLine( suite, lineNo, line ) @@ -184,6 +201,7 @@ def addLineToBlock( suite, lineNo, line ): suite['lines'].append( line ) return e is None + def fixBlockLine( suite, lineNo, line): '''Change all [E]TS_ macros used in a line to _[E]TS_ macros with the correct file/line''' return re.sub( r'\b(E?TSM?_(ASSERT[A-Z_]*|FAIL))\s*\(', @@ -191,17 +209,22 @@ def fixBlockLine( suite, lineNo, line): line, 0 ) create_re = re.compile( r'\bstatic\s+\w+\s*\*\s*createSuite\s*\(\s*(void)?\s*\)' ) + + def scanLineForCreate( suite, lineNo, line ): '''Check if current line defines a createSuite() function''' if create_re.search( line ): addSuiteCreateDestroy( suite, 'create', lineNo ) destroy_re = re.compile( r'\bstatic\s+void\s+destroySuite\s*\(\s*\w+\s*\*\s*\w*\s*\)' ) + + def scanLineForDestroy( suite, lineNo, line ): '''Check if current line defines a destroySuite() function''' if destroy_re.search( line ): addSuiteCreateDestroy( suite, 'destroy', lineNo ) + def cstr( s ): '''Convert a string to its C representation''' return '"' + s.replace( '\\', '\\\\' ) + '"' @@ -213,6 +236,7 @@ def addSuiteCreateDestroy( suite, which, line ): abort( '%s:%s: %sSuite() already declared' % ( suite['file'], str(line), which ) ) suite[which] = line + def closeSuite(): '''Close current suite and add it to the list if valid''' global suite @@ -222,6 +246,7 @@ def closeSuite(): rememberSuite(suite) suite = None + def verifySuite(suite): '''Verify current suite is legal''' if 'create' in suite and 'destroy' not in suite: @@ -231,6 +256,7 @@ def verifySuite(suite): abort( '%s:%s: Suite %s has destroySuite() but no createSuite()' % (suite['file'], suite['destroy'], suite['name']) ) + def rememberSuite(suite): '''Add current suite to list''' global suites diff --git a/Testing/Tools/cxxtest/python/cxxtest/cxxtestgen.py b/Testing/Tools/cxxtest/python/cxxtest/cxxtestgen.py index 2e17ecdb3c7f8af12d19fb833f0a5c8313d4ceda..391b8b3c6dd696dc54cc1f2b1f5a8bfa7107c214 100755 --- a/Testing/Tools/cxxtest/python/cxxtest/cxxtestgen.py +++ b/Testing/Tools/cxxtest/python/cxxtest/cxxtestgen.py @@ -1,5 +1,3 @@ -from __future__ import print_function, absolute_import - __all__ = ['main'] import sys @@ -26,6 +24,7 @@ wrotePreamble = 0 wroteWorld = 0 lastIncluded = '' + def main(args=None): '''The main program''' # @@ -47,6 +46,7 @@ def main(args=None): [options,suites] = cxxtest_parser.scanInputFiles( files, options ) writeOutput() + def parseCommandline(args): '''Analyze command line arguments''' global imported_fog @@ -162,11 +162,13 @@ def printVersion(): sys.stdout.write( "This is CxxTest version INSERT_VERSION_HERE.\n" ) sys.exit(0) + def setFiles(patterns ): '''Set input files specified on command line''' files = expandWildcards( patterns ) return files + def expandWildcards( patterns ): '''Expand all wildcards in an array (glob)''' fileNames = [] @@ -176,6 +178,7 @@ def expandWildcards( patterns ): fileNames.append( fixBackslashes( fileName ) ) return fileNames + def fixBackslashes( fileName ): '''Convert backslashes to slashes in file name''' return re.sub( r'\\', '/', fileName, 0 ) @@ -188,6 +191,7 @@ def writeOutput(): else: writeSimpleOutput() + def writeSimpleOutput(): '''Create output not based on template''' output = startOutputFile() @@ -204,6 +208,8 @@ def writeSimpleOutput(): include_re = re.compile( r"\s*\#\s*include\s+<cxxtest/" ) preamble_re = re.compile( r"^\s*<CxxTest\s+preamble>\s*$" ) world_re = re.compile( r"^\s*<CxxTest\s+world>\s*$" ) + + def writeTemplateOutput(): '''Create output based on template file''' template = open(options.templateFileName) @@ -224,6 +230,7 @@ def writeTemplateOutput(): template.close() output.close() + def startOutputFile(): '''Create output file and write header''' if options.outputFileName is not None: @@ -233,6 +240,7 @@ def startOutputFile(): output.write( "/* Generated file, do not edit */\n\n" ) return output + def writePreamble( output ): '''Write the CxxTest header (#includes and #defines)''' global wrotePreamble @@ -267,6 +275,7 @@ def writePreamble( output ): output.write( "\n" ) wrotePreamble = 1 + def writeMain( output ): '''Write the main() function for the test runner''' if not (options.gui or options.runner): @@ -313,6 +322,7 @@ def writeWorld( output ): writeInitialize( output ) wroteWorld = 1 + def writeSuites(output): '''Write all TestDescriptions and SuiteDescriptions''' for suite in suites: @@ -327,14 +337,17 @@ def writeSuites(output): writeSuiteDescription( output, suite ) writeTestDescriptions( output, suite ) + def isGenerated(suite): '''Checks whether a suite class should be created''' return suite['generated'] + def isDynamic(suite): '''Checks whether a suite is dynamic''' return 'create' in suite + def writeInclude(output, file): '''Add #include "file" statement''' global lastIncluded @@ -342,6 +355,7 @@ def writeInclude(output, file): output.writelines( [ '#include "', file, '"\n\n' ] ) lastIncluded = file + def generateSuite( output, suite ): '''Write a suite declared with CXXTEST_SUITE()''' output.write( 'class %s : public CxxTest::TestSuite {\n' % suite['name'] ) @@ -350,6 +364,7 @@ def generateSuite( output, suite ): output.write(line) output.write( '};\n\n' ) + def writeSuitePointer( output, suite ): '''Create static suite pointer object for dynamic suites''' if options.noStaticInit: @@ -357,10 +372,12 @@ def writeSuitePointer( output, suite ): else: output.write( 'static %s *%s = nullptr;\n\n' % (suite['name'], suite['object']) ) + def writeSuiteObject( output, suite ): '''Create static suite object for non-dynamic suites''' output.writelines( [ "static ", suite['name'], " ", suite['object'], ";\n\n" ] ) + def writeTestList( output, suite ): '''Write the head of the test linked list for a suite''' if options.noStaticInit: @@ -368,6 +385,7 @@ def writeTestList( output, suite ): else: output.write( 'static CxxTest::List %s = { nullptr, nullptr };\n' % suite['tlist'] ) + def writeWorldDescr( output ): '''Write the static name of the world name''' if options.noStaticInit: @@ -375,11 +393,13 @@ def writeWorldDescr( output ): else: output.write( 'const char* CxxTest::RealWorldDescription::_worldName = "cxxtest";\n' ) + def writeTestDescriptions( output, suite ): '''Write all test descriptions for a suite''' for test in suite['tests']: writeTestDescription( output, suite, test ) + def writeTestDescription( output, suite, test ): '''Write test description object''' output.write( 'static class %s final : public CxxTest::RealTestDescription {\n' % test['class'] ) @@ -390,19 +410,23 @@ def writeTestDescription( output, suite, test ): output.write( ' void runTest() override final { %s } // NOLINT\n' % runBody( suite, test ) ) output.write( '} %s;\n\n' % test['object'] ) + def runBody( suite, test ): '''Body of TestDescription::run()''' if isDynamic(suite): return dynamicRun( suite, test ) else: return staticRun( suite, test ) + def dynamicRun( suite, test ): '''Body of TestDescription::run() for test in a dynamic suite''' return 'if ( ' + suite['object'] + ' ) ' + suite['object'] + '->' + test['name'] + '();' + def staticRun( suite, test ): '''Body of TestDescription::run() for test in a non-dynamic suite''' return suite['object'] + '.' + test['name'] + '();' + def writeSuiteDescription( output, suite ): '''Write SuiteDescription object''' if isDynamic( suite ): @@ -410,6 +434,7 @@ def writeSuiteDescription( output, suite ): else: writeStaticDescription( output, suite ) + def writeDynamicDescription( output, suite ): '''Write SuiteDescription for a dynamic suite''' output.write( 'CxxTest::DynamicSuiteDescription<%s> %s' % (suite['name'], suite['dobject']) ) @@ -419,6 +444,7 @@ def writeDynamicDescription( output, suite ): suite['object'], suite['create'], suite['destroy']) ) output.write( ';\n\n' ) + def writeStaticDescription( output, suite ): '''Write SuiteDescription for a static suite''' output.write( 'CxxTest::StaticSuiteDescription %s' % suite['dobject'] ) @@ -427,10 +453,12 @@ def writeStaticDescription( output, suite ): (suite['cfile'], suite['line'], suite['name'], suite['object'], suite['tlist']) ) output.write( ';\n\n' ) + def writeRoot(output): '''Write static members of CxxTest classes''' output.write( '#include <cxxtest/Root.cpp>\n' ) + def writeInitialize(output): '''Write CxxTest::initialize(), which replaces static initialization''' output.write( 'namespace CxxTest {\n' ) diff --git a/buildconfig/CMake/CppCheckSetup.cmake b/buildconfig/CMake/CppCheckSetup.cmake index 75d183a1a1004b0dc9d44e46e89a15ab336502f8..cf1df3315898c12266a409d1cb05b766c0bf4780 100644 --- a/buildconfig/CMake/CppCheckSetup.cmake +++ b/buildconfig/CMake/CppCheckSetup.cmake @@ -1,133 +1,28 @@ find_package ( Cppcheck ) if ( CPPCHECK_EXECUTABLE ) - set ( CPPCHECK_SOURCE_DIRS - Framework - MantidPlot - qt/paraview_ext - qt/scientific_interfaces - qt/widgets/common - qt/widgets/instrumentView - qt/widgets/mplcpp - ) - option ( CPPCHECK_USE_INCLUDE_DIRS "Use specified include directories. WARNING: cppcheck will run significantly slower." ) + # We must export the compile commands for cppcheck to be able to check + # everything correctly + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - set ( CPPCHECK_INCLUDE_DIRS - Framework/Algorithms/inc - Framework/PythonInterface/inc - Framework/Nexus/inc - Framework/MPIAlgorithms/inc - Framework/MDAlgorithms/inc - Framework/DataHandling/inc - Framework/WorkflowAlgorithms/inc - Framework/MDEvents/inc - Framework/DataObjects/inc - Framework/Geometry/inc - Framework/ICat/inc - Framework/CurveFitting/inc - Framework/API/inc - Framework/TestHelpers/inc - Framework/Crystal/inc - Framework/Kernel/inc - qt/paraview_ext/VatesAPI/inc - qt/paraview_ext/VatesSimpleGui/ViewWidgets/inc - qt/paraview_ext/VatesSimpleGui/QtWidgets/inc - qt/widgets/common/inc - qt/widgets/factory/inc - qt/widgets/instrumentview/inc - qt/widgets/refdetectrview/inc - qt/widgets/sliceviewer/inc - qt/widgets/spectrumviewer/inc - qt/widgets/plugins/algorithm_dialogs/inc - qt/widgets/plugins/designer/inc - qt/scientific_interfaces - ) - - set ( CPPCHECK_EXCLUDES - Framework/LiveData/src/ISIS/DAE/ - Framework/LiveData/src/Kafka/private/Schema/ - Framework/DataHandling/src/LoadRaw/ - Framework/ICat/inc/MantidICat/ICat3/GSoapGenerated/ - Framework/ICat/src/ICat3/GSoapGenerated/ - Framework/ICat/src/ICat3/ICat3GSoapGenerated.cpp - Framework/ICat/inc/MantidICat/ICat4/GSoapGenerated/ - Framework/ICat/src/ICat4/GSoapGenerated/ - Framework/ICat/src/ICat4/ICat4GSoapGenerated.cpp - Framework/ICat/src/GSoap/ - Framework/ICat/src/GSoap.cpp - Framework/Kernel/src/ANN/ - Framework/Kernel/src/ANN_complete.cpp - Framework/Kernel/src/Math/Optimization/SLSQPMinimizer.cpp - MantidPlot/src/nrutil.cpp - MantidPlot/src/origin/OPJFile.cpp - MantidPlot/src/zlib123/minigzip.c - Framework/SINQ/src/PoldiPeakFit.cpp - qt/widgets/common/src/QtPropertyBrowser/ - qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ - ) - - # Header files to be ignored require different handling - set ( CPPCHECK_HEADER_EXCLUDES - Framework/LiveData/src/Kafka/private/Schema/ba57_run_info_generated.h - Framework/LiveData/src/Kafka/private/Schema/df12_det_spec_map_generated.h - Framework/LiveData/src/Kafka/private/Schema/ev42_events_generated.h - Framework/LiveData/src/Kafka/private/Schema/fwdi_forwarder_internal_generated.h - Framework/LiveData/src/Kafka/private/Schema/f142_logdata_generated.h - Framework/LiveData/src/Kafka/private/Schema/is84_isis_events_generated.h - Framework/LiveData/src/Kafka/private/Schema/flatbuffers/base.h - Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h - Framework/LiveData/src/Kafka/private/Schema/flatbuffers/stl_emulation.h - MantidPlot/src/origin/OPJFile.h - MantidPlot/src/origin/tree.hh - ) + configure_file(${CMAKE_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt.in ${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt) # setup the standard arguments + set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120 + --suppressions-list=${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt + --project=${CMAKE_BINARY_DIR}/compile_commands.json + # Force cppcheck to check when we use project-wide macros + -DDLLExport= + -DMANTID_ALGORITHMS_DLL= + ) + set (_cppcheck_args "${CPPCHECK_ARGS}") list ( APPEND _cppcheck_args ${CPPCHECK_TEMPLATE_ARG} ) if ( CPPCHECK_NUM_THREADS GREATER 0) list ( APPEND _cppcheck_args -j ${CPPCHECK_NUM_THREADS} ) endif ( CPPCHECK_NUM_THREADS GREATER 0) - # process list of include/exclude directories - set (_cppcheck_source_dirs) - foreach (_dir ${CPPCHECK_SOURCE_DIRS} ) - set ( _tmpdir "${CMAKE_SOURCE_DIR}/${_dir}" ) - if ( EXISTS ${_tmpdir} ) - list ( APPEND _cppcheck_source_dirs ${_tmpdir} ) - endif () - endforeach() - - set (_cppcheck_includes) - foreach( _dir ${CPPCHECK_INCLUDE_DIRS} ) - set ( _tmpdir "${CMAKE_SOURCE_DIR}/${_dir}" ) - if ( EXISTS ${_tmpdir} ) - list ( APPEND _cppcheck_includes -I ${_tmpdir} ) - endif () - endforeach() - if (CPPCHECK_USE_INCLUDE_DIRS) - list ( APPEND _cppcheck_args ${_cppcheck_includes} ) - endif (CPPCHECK_USE_INCLUDE_DIRS) - - set (_cppcheck_excludes) - foreach( _file ${CPPCHECK_EXCLUDES} ) - set ( _tmp "${CMAKE_SOURCE_DIR}/${_file}" ) - if ( EXISTS ${_tmp} ) - list ( APPEND _cppcheck_excludes -i ${_tmp} ) - endif () - endforeach() - list ( APPEND _cppcheck_args ${_cppcheck_excludes} ) - - # Handle header files in the required manner - set (_cppcheck_header_excludes) - foreach( _file ${CPPCHECK_HEADER_EXCLUDES} ) - set ( _tmp "${CMAKE_SOURCE_DIR}/${_file}" ) - if ( EXISTS ${_tmp} ) - list ( APPEND _cppcheck_header_excludes --suppress=*:${_tmp} ) - endif() - endforeach() - list ( APPEND _cppcheck_args ${_cppcheck_header_excludes} ) - # put the finishing bits on the final command call set (_cppcheck_xml_args) if (CPPCHECK_GENERATE_XML) @@ -136,10 +31,12 @@ if ( CPPCHECK_EXECUTABLE ) list( APPEND _cppcheck_xml_args ${_cppcheck_source_dirs} ) endif (CPPCHECK_GENERATE_XML) + + # generate the target if (NOT TARGET cppcheck) add_custom_target ( cppcheck - COMMAND ${CPPCHECK_EXECUTABLE} ${_cppcheck_args} ${_cppcheck_header_excludes} ${_cppcheck_xml_args} + COMMAND ${CPPCHECK_EXECUTABLE} ${_cppcheck_args} ${_cppcheck_xml_args} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Running cppcheck" ) diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt b/buildconfig/CMake/CppCheck_Suppressions.txt deleted file mode 100644 index 8ea3af11393379dcf667cea4c56c76b7da6ad5cd..0000000000000000000000000000000000000000 --- a/buildconfig/CMake/CppCheck_Suppressions.txt +++ /dev/null @@ -1,14 +0,0 @@ -// suppress specific rule in specific files -// NOTE this needs the full path to the file, so would need this file to be generated by cmake -// as different build servers have different starts to the file path -// Example: -// memsetClassFloat:/Users/builder/Jenkins/workspace/cppcheck-1.72/Framework/DataHandling/src/LoadRaw/isisraw.h - - -// suppress in all files - BE CAREFUL not to leave trailing spaces after the rule id. or empty lines -// For a library this is not a problem per se -// unusedFunction -// cppcheck has problems handling the number of pre-processor definitions used in the DLL_EXPORTs -class_X_Y -// the exported functions are not used in the cpp land -unusedFunction:Framework/PythonInterface/mantid/*/src/Exports/*.cpp diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..f60bde7ca6c07350da914bd49f6587cc984566e3 --- /dev/null +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -0,0 +1,104 @@ +// suppress specific rule in specific files +// NOTE this needs the full path to the file, so would need this file to be generated by cmake +// as different build servers have different starts to the file path + +// -------- Project Wide ------------------ + +// Hide warnings about using explicit keyword constructors as we have "too many" +// and automated clang-tidy breaks a couple of implicit conversions we use widely +noExplicitConstructor + +// Hide warnings about shadowed members for inheritance. Typically "m_log" with Algorithm +duplInheritedMember + +// We have some potentially uninitialized member vars but too many to fix at the moment +uninitMemberVar + +// Around 100 of these exist where noConstructor is present +noConstructor + +// Pre-processor Directives, such as #error, which are upstream anyway +preprocessorErrorDirective + +// ---------- cppcheck 1.90 Transition ------- +unmatchedSuppression + +// If-init not supported +syntaxError:${CMAKE_SOURCE_DIR}/Framework/API/src/MatrixWorkspace.cpp + +// --- To be added back ------ +//cstyleCase:*${CMAKE_SOURCE_DIR}/MantidPlot + +// A large number of copying instead of pass by ref were picked up by clang-tidy, but around 200 remain +//passedByValue + +// Cppcheck struggles with some inheritance chains, some of these might be true though +//unusedPrivateFunction + +// Nice to have, not need to have at the moment +//useInitializationList + +// Libs we have in-source +// *:${CMAKE_SOURCE_DIR}/Framework/DataObjects/inc/MantidDataObjects/MortonIndex/* + +// ---------- Individual suppressions ----------------- + +// Mantid Plot specific ones we probably won't fix before removal + +*:${CMAKE_SOURCE_DIR}/MantidPlot/src/origin/tree.hh +*:${CMAKE_SOURCE_DIR}/MantidPlot/src/nrutil.cpp + +pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp +pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.h + +// Macro expansion means this is incorrectly flagged on Unix +redundantAssignment:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.cpp + +// Ref binding means Cppcheck can't see these are used +unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/MaskBinsIf.cpp + +// --------- Missing copy assignment / constructors ------------------- +// We don't want more creeping in so just mark these one by one + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/BoxController.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/ExperimentInfo.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/IFunction.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MDGeometry.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/MultipleExperimentInfos.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/SingleValueParameter.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/API/inc/MantidAPI/VectorParameter.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCat.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ONCatEntity.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/CompAssembly.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/Container.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/ObjCompAssembly.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h + +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceBinData.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceSpectrumData.h + +noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h +noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.h +noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheWriter.h + +// ----------------- Upstream libs --------------- + +// Always ignore bin dir +*:*${CMAKE_BINARY_DIR}/* + +// For some reason upstream libs sometimes end up in the check results +*:*/usr/include/* + +// All ANN files as they are upstream anyway +*:*${CMAKE_SOURCE_DIR}/Framework/Kernel/src/ANN/* + +// Libs we have in-source +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/GSoap/* +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat3/GSoapGenerated/* +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat4/GSoapGenerated/* +*:${CMAKE_SOURCE_DIR}/MantidPlot/src/zlib123/* diff --git a/buildconfig/CMake/FindCppcheck.cmake b/buildconfig/CMake/FindCppcheck.cmake index fad22793cb0533a477cdb92d454e4c8e37c9ece9..89bb0b88ec5e512df5d147450bf3893b278e7cf0 100644 --- a/buildconfig/CMake/FindCppcheck.cmake +++ b/buildconfig/CMake/FindCppcheck.cmake @@ -61,15 +61,6 @@ if(CPPCHECK_EXECUTABLE) endif() mark_as_advanced(CPPCHECK_EXECUTABLE) -if(CPPCHECK_EXECUTABLE) - if (${CPPCHECK_VERSION} VERSION_LESS 1.71) - set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120 - --suppressions ${CMAKE_CURRENT_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt ) - else() - set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120 - --suppressions-list=${CMAKE_CURRENT_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt ) - endif() -endif() set ( CPPCHECK_NUM_THREADS 0 CACHE STRING "Number of threads to use when running cppcheck" ) set ( CPPCHECK_GENERATE_XML OFF CACHE BOOL "Generate xml output files from cppcheck" ) diff --git a/buildconfig/CMake/FindCxxTest.cmake b/buildconfig/CMake/FindCxxTest.cmake index d88bbdd42c8bd0c64aa8d148be3f74148e8b2e68..ffb3dad5f08348f62abea9cbf66b1bae3e16beb0 100644 --- a/buildconfig/CMake/FindCxxTest.cmake +++ b/buildconfig/CMake/FindCxxTest.cmake @@ -180,26 +180,43 @@ macro(CXXTEST_ADD_TEST _cxxtest_testname) add_test ( NAME ${_cxxtest_separate_name} COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" $<TARGET_FILE:${_cxxtest_testname}> ${_suitename} ) - set_tests_properties ( ${_cxxtest_separate_name} PROPERTIES - TIMEOUT ${TESTING_TIMEOUT} ) - if (CXXTEST_ADD_PERFORMANCE) - # ------ Performance test version ------- - # Name of the possibly-existing Performance test suite - set( _performance_suite_name "${_suitename}Performance" ) - # Read the contents of the header file - FILE( READ ${part} _file_contents ) - # Is that suite defined in there at all? - STRING(REGEX MATCH ${_performance_suite_name} _search_res ${_file_contents} ) - if (NOT "${_search_res}" STREQUAL "") - set( _cxxtest_separate_name "${_cxxtest_testname}_${_performance_suite_name}") - add_test ( NAME ${_cxxtest_separate_name} - COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" - $<TARGET_FILE:${_cxxtest_testname}> ${_performance_suite_name} ) set_tests_properties ( ${_cxxtest_separate_name} PROPERTIES TIMEOUT ${TESTING_TIMEOUT} ) - endif () - endif () + + if (CXXTEST_ADD_PERFORMANCE) + # ------ Performance test version ------- + # Name of the possibly-existing Performance test suite + set( _performance_suite_name "${_suitename}Performance" ) + # Read the contents of the header file + FILE( READ ${part} _file_contents ) + # Is that suite defined in there at all? + STRING(REGEX MATCH ${_performance_suite_name} _search_res ${_file_contents} ) + if (NOT "${_search_res}" STREQUAL "") + set( _cxxtest_separate_name "${_cxxtest_testname}_${_performance_suite_name}") + add_test ( NAME ${_cxxtest_separate_name} + COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/bin/Testing" + $<TARGET_FILE:${_cxxtest_testname}> ${_performance_suite_name} ) + set_tests_properties ( ${_cxxtest_separate_name} PROPERTIES + TIMEOUT ${TESTING_TIMEOUT} ) + endif () + endif () + + set( SUPPRESSIONS_DIR "${CMAKE_SOURCE_DIR}/tools/Sanitizer" ) + if ( USE_SANITIZERS_LOWER STREQUAL "address" ) + # See dev docs on sanitizers for details on why verify_asan_link is false + # Trying to quote these options causes the quotation to be forwarded + set(_ASAN_OPTS "suppressions=${SUPPRESSIONS_DIR}/Address.supp:detect_stack_use_after_return=true") + set_property( TEST ${_cxxtest_separate_name} APPEND PROPERTY + ENVIRONMENT ASAN_OPTIONS=${_ASAN_OPTS} ) + + set( _LSAN_OPTS "suppressions=${SUPPRESSIONS_DIR}/Leak.supp" ) + set_property( TEST ${_cxxtest_separate_name} APPEND PROPERTY + ENVIRONMENT LSAN_OPTIONS=${_LSAN_OPTS} ) + + endif() + + endforeach ( part ${ARGN} ) endmacro(CXXTEST_ADD_TEST) diff --git a/buildconfig/CMake/FindPyQt.py b/buildconfig/CMake/FindPyQt.py index a4d8d4166007dc447ed2222f5801e4429b91c549..e17e534e8e74155a37e73cbd4ababac027595a8a 100644 --- a/buildconfig/CMake/FindPyQt.py +++ b/buildconfig/CMake/FindPyQt.py @@ -4,8 +4,6 @@ There is a commandline argument to select the version of PyQt. """ -from __future__ import print_function - import argparse import os import pprint @@ -14,6 +12,7 @@ import sys QT_TAG_RE = re.compile(r'Qt_\d+_\d+_\d+') + class PyQtConfig(object): version_hex = None @@ -98,6 +97,7 @@ def main(): print(PyQtConfig('PyQt%d' % args.version)) return 0 + def get_options(): parser = argparse.ArgumentParser(description='Extract PyQt config information') parser.add_argument('version', type=int, help="PyQt major version") diff --git a/buildconfig/CMake/GNUSetup.cmake b/buildconfig/CMake/GNUSetup.cmake index a129359016f7638690fb3151163728a3066d8fd1..6fbf75cc72463dfdd66c5b771be881331951a6e2 100644 --- a/buildconfig/CMake/GNUSetup.cmake +++ b/buildconfig/CMake/GNUSetup.cmake @@ -72,39 +72,6 @@ endif() # Add some options for debug build to help the Zoom profiler add_compile_options ( $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-fno-omit-frame-pointer> ) -option(WITH_ASAN "Enable address sanitizer" OFF) -if(WITH_ASAN) - message(STATUS "enabling address sanitizer") - add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=address) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address" ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") -endif() - -option(WITH_TSAN "Enable thread sanitizer" OFF) -if(WITH_TSAN) - message(STATUS "enabling thread sanitizer") - add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=thread) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=thread" ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread") -endif() - -option(WITH_UBSAN "Enable undefined behavior sanitizer" OFF) -if(WITH_UBSAN) - message(STATUS "enabling undefined behavior sanitizers") - set( UBSAN_NO_RECOVER "-fno-sanitize-recover") - if ( CMAKE_COMPILER_IS_GNUCXX AND GCC_COMPILER_VERSION VERSION_LESS "5.1.0") - set( UBSAN_NO_RECOVER "") - endif() - # vptr check is generating a lot of false positives, hiding other more serious warnings. - set(SAN_FLAGS "-fno-omit-frame-pointer -fno-common -fsanitize=undefined -fno-sanitize=vptr ${UBSAN_NO_RECOVER}") - add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=undefined -fno-sanitize=vptr ${UBSAN_NO_RECOVER}) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SAN_FLAGS}" ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SAN_FLAGS}" ) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SAN_FLAGS}" ) -endif() - # XCode isn't picking up the c++ standard by CMAKE_CXX_STANDARD if(CMAKE_GENERATOR STREQUAL Xcode) set ( CMAKE_XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS "${GNUFLAGS} -Woverloaded-virtual -fno-operator-names") diff --git a/buildconfig/CMake/Sanitizers.cmake b/buildconfig/CMake/Sanitizers.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4e8c29a8e274edb188102534cc753a2b8ced9ba1 --- /dev/null +++ b/buildconfig/CMake/Sanitizers.cmake @@ -0,0 +1,62 @@ +################################################# +# Controls various project wide sanitizer options +################################################# + +set(USE_SANITIZER "Off" CACHE STRING "Sanitizer mode to enable") +set_property(CACHE USE_SANITIZER PROPERTY STRINGS + Off Address Thread Undefined) + +string(TOLOWER "${USE_SANITIZER}" USE_SANITIZERS_LOWER) + +if(NOT ${USE_SANITIZERS_LOWER} MATCHES "off") + # Check we have a supported compiler + if(WIN32) + message(FATAL_ERROR "Windows does not support sanitizers") + endif() + + if(CMAKE_COMPILER_IS_GNUCXX AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8)) + message(FATAL_ERROR "GCC 7 and below do not support sanitizers") + endif() + + # Check and warn if we are not in a mode without debug symbols + string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower) + if("${build_type_lower}" MATCHES "release" OR "${build_type_lower}" MATCHES "minsizerel" ) + message(WARNING "You are running address sanitizers without debug information, try RelWithDebInfo") + + elseif(${build_type_lower} MATCHES "relwithdebinfo") + # RelWithDebug runs with -o2 which performs inlining reducing the usefulness + message("Replacing -O2 flag with -O1 to preserve stack trace on sanitizers") + string(REPLACE "-O2" "-O1" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) + string(REPLACE "-O2" "-O1" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) + + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE) + set(CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE) + + add_compile_options(-fno-omit-frame-pointer -fno-optimize-sibling-calls) + endif() +endif() + +# Allow all instrumented code to continue beyond the first error +add_compile_options($<$<NOT:$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"off">>:-fsanitize-recover=all>) + +# Address +add_compile_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>) +add_link_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>) + +# Thread +add_compile_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>) +add_link_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>) + +# Undefined +# RTTI information is not exported for some classes causing the +# linker to fail whilst adding vptr instrumentation +add_compile_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined> + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fno-sanitize=vptr>) + +add_link_options( + $<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined>) diff --git a/buildconfig/CMake/Span.cmake b/buildconfig/CMake/Span.cmake index e5020d24c8a67de0ef3853c2c29156f146f05b36..426d1880d95ec859b5d6bf0838d574cf9b236721 100644 --- a/buildconfig/CMake/Span.cmake +++ b/buildconfig/CMake/Span.cmake @@ -9,8 +9,8 @@ FetchContent_Declare( span GIT_REPOSITORY https://github.com/tcbrindle/span.git GIT_TAG 08cb4bf0e06c0e36f7e2b64e488ede711a8bb5ad - PATCH_COMMAND ${GIT_EXECUTABLE} reset --hard ${_tag} - COMMAND ${GIT_EXECUTABLE} apply ${_apply_flags} ${CMAKE_SOURCE_DIR}/buildconfig/CMake/span_disable_testing.patch + PATCH_COMMAND "${GIT_EXECUTABLE}" reset --hard ${_tag} + COMMAND "${GIT_EXECUTABLE}" apply ${_apply_flags} "${CMAKE_SOURCE_DIR}/buildconfig/CMake/span_disable_testing.patch" ) FetchContent_GetProperties(span) diff --git a/buildconfig/Jenkins/buildscript b/buildconfig/Jenkins/buildscript index 796f2625dbfcf069da8a71aebfc54bb3e867f3fd..09c68128ccb0427feba51de0de1acc7146f79fe1 100755 --- a/buildconfig/Jenkins/buildscript +++ b/buildconfig/Jenkins/buildscript @@ -9,6 +9,9 @@ # corresponds to any labels set on a slave. BUILD_THREADS & # PARAVIEW_DIR should be set in the configuration of each slave. ############################################################################### +# Set all string comparisons to case insensitive (i.e. Release == release) +shopt -s nocasematch + SCRIPT_DIR=$(dirname "$0") XVFB_SERVER_NUM=101 ULIMIT_CORE_ORIG=$(ulimit -c) @@ -61,6 +64,14 @@ if [[ ${NODE_LABELS} == *rhel7* ]] || [[ ${NODE_LABELS} == *centos7* ]] || [[ ${ USE_CORE_DUMPS=false fi +# Setup software collections on rhel7 to allow using gcc7 +if [[ $ON_RHEL7 ]]; then + SCL_ENABLE="scl enable devtoolset-7" +else + SCL_ENABLE="eval" +fi + + ############################################################################### # Script cleanup ############################################################################### @@ -100,10 +111,7 @@ $CMAKE_EXE --version ############################################################################### # Check job requirements from the name and changes ############################################################################### -if [[ ${JOB_NAME} == *clean* ]]; then - CLEANBUILD=true -fi -if [[ ${JOB_NAME} == *clang_tidy* ]]; then +if [[ ${JOB_NAME} == *clean* || ${JOB_NAME} == *clang_tidy* ]]; then CLEANBUILD=true fi @@ -146,6 +154,7 @@ DO_DOCTESTS_USER=true DO_BUILD_DEVDOCS=true DO_BUILD_PKG=true DO_SYSTEMTESTS=false + if [[ ${PRBUILD} == true ]]; then if ${SCRIPT_DIR}/check_for_changes dev-docs-only || ${SCRIPT_DIR}/check_for_changes user-docs-only; then DO_BUILD_CODE=false @@ -157,7 +166,7 @@ if [[ ${PRBUILD} == true ]]; then DO_SYSTEMTESTS=false if [[ ${ON_RHEL7} == true ]]; then - # rhel does system testing + # rhel does system testing if there are any non-doc or gui changes if ! ${SCRIPT_DIR}/check_for_changes docs-gui-only; then if [[ ${PY3_BUILD} == true ]]; then DO_BUILD_PKG=true @@ -196,15 +205,16 @@ fi if [[ "$CLEANBUILD" == true ]]; then rm -rf $BUILD_DIR fi -if [ -d $BUILD_DIR ]; then - rm -rf ${BUILD_DIR:?}/bin ${BUILD_DIR:?}/ExternalData ${BUILD_DIR:?}/Testing - find ${BUILD_DIR:?} -name 'TEST-*.xml' -delete - if [[ -n ${CLEAN_EXTERNAL_PROJECTS} && "${CLEAN_EXTERNAL_PROJECTS}" == true ]]; then - rm -rf $BUILD_DIR/eigen-* - rm -rf $BUILD_DIR/googletest-* - fi -else - mkdir $BUILD_DIR + +mkdir -p $BUILD_DIR + +# Tidy build dir +rm -rf ${BUILD_DIR:?}/bin ${BUILD_DIR:?}/ExternalData ${BUILD_DIR:?}/Testing +find ${BUILD_DIR:?} -name 'TEST-*.xml' -delete + +if [[ -n ${CLEAN_EXTERNAL_PROJECTS} && "${CLEAN_EXTERNAL_PROJECTS}" == true ]]; then + rm -rf $BUILD_DIR/eigen-* + rm -rf $BUILD_DIR/googletest-* fi ############################################################################### @@ -298,6 +308,27 @@ if [[ ${DO_BUILD_PKG} == true ]]; then fi fi +############################################################################### +# Figure out if were doing a sanitizer build and setup any steps we need +############################################################################### + +if [[ ${JOB_NAME} == *address* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=Address" + +elif [[ ${JOB_NAME} == *memory* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=memory" + +elif [[ ${JOB_NAME} == *thread* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=thread" + +elif [[ ${JOB_NAME} == *undefined* ]]; then + SANITIZER_FLAGS="-DUSE_SANITIZER=undefined" +fi + +if [[ -n "${SANITIZER_FLAGS}" ]]; then + # Force build to RelWithDebInfo + BUILD_CONFIG="RelWithDebInfo" +fi ############################################################################### # Generator @@ -307,6 +338,7 @@ if [ "$(command -v ninja)" ]; then elif [ "$(command -v ninja-build)" ]; then CMAKE_GENERATOR="-G Ninja" fi + if [ -e $BUILD_DIR/CMakeCache.txt ]; then CMAKE_GENERATOR="" fi @@ -325,7 +357,7 @@ rm -f -- *.dmg *.rpm *.deb *.tar.gz *.tar.xz ############################################################################### # CMake configuration ############################################################################### -$SCL_ENABLE "${CMAKE_EXE} ${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} -DENABLE_CPACK=ON -DMAKE_VATES=ON -DParaView_DIR=${PARAVIEW_DIR} -DMANTID_DATA_STORE=${MANTID_DATA_STORE} -DDOCS_HTML=ON -DENABLE_CONDA=ON -DCOLORED_COMPILER_OUTPUT=OFF ${DIST_FLAGS} ${PACKAGINGVARS} ${CLANGTIDYVAR} .." +$SCL_ENABLE "${CMAKE_EXE} ${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${BUILD_CONFIG} -DENABLE_CPACK=ON -DMAKE_VATES=ON -DParaView_DIR=${PARAVIEW_DIR} -DMANTID_DATA_STORE=${MANTID_DATA_STORE} -DDOCS_HTML=ON -DENABLE_CONDA=ON -DCOLORED_COMPILER_OUTPUT=OFF ${DIST_FLAGS} ${PACKAGINGVARS} ${CLANGTIDYVAR} ${SANITIZER_FLAGS} .." ############################################################################### # Coverity build should exit early @@ -360,7 +392,6 @@ if [[ $USE_CLANG ]] && [[ ${JOB_NAME} == *clang_tidy* ]]; then exit 0 fi - ############################################################################### # Run the unit tests ############################################################################### diff --git a/buildconfig/class_maker.py b/buildconfig/class_maker.py index d50942b00c2cb4199b71c261f5cfa8ba9dac2fd7..4a3274ef0506a0e576981cd6d3386bb52460de52 100755 --- a/buildconfig/class_maker.py +++ b/buildconfig/class_maker.py @@ -6,8 +6,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ Utility for generating a class file, header, and test file """ -from __future__ import (absolute_import, division, print_function, unicode_literals) - import argparse import sys import os @@ -19,11 +17,15 @@ from cmakelists_utils import * VERSION = "1.0" #====================================================================== + + def get_year(): """returns the current year""" return datetime.datetime.now().year #====================================================================== + + def write_header(subproject, classname, filename, args): """Write a class header file""" print("Writing header file to", filename) @@ -391,4 +393,4 @@ if __name__ == "__main__": if args.subfolder[-1:] != "/": args.subfolder += "/" - generate(subproject, classname, overwrite, args) \ No newline at end of file + generate(subproject, classname, overwrite, args) diff --git a/buildconfig/cmakelists_utils.py b/buildconfig/cmakelists_utils.py index 248f40ccb6a7396b32f7384a1ddaa2e02512150a..9731251afe9f8b6b5089200fd4a6298332bd9905 100644 --- a/buildconfig/cmakelists_utils.py +++ b/buildconfig/cmakelists_utils.py @@ -1,11 +1,11 @@ -from __future__ import (absolute_import, division, print_function, unicode_literals) - import datetime import os import re import sys #====================================================================================== + + def find_basedir(project, subproject): """ Returns the base directory. If the subproject is known to be in MantidQt or Vates, it uses that. The default is current dir + Framework @@ -122,6 +122,8 @@ def fix_cmake_format(subproject): f.close() #====================================================================== + + def fix_all_cmakes(): """ Fix all cmake files """ projects = ["Algorithms", "DataObjects", "MDAlgorithms", "API", diff --git a/buildconfig/delete_class.py b/buildconfig/delete_class.py index 69f8c3b5a9cd6266f1bee96ef4468a98bb75b15c..322deeb3c08c69de02d91918be61e293a482c917 100755 --- a/buildconfig/delete_class.py +++ b/buildconfig/delete_class.py @@ -6,8 +6,6 @@ # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + """ Utility for deleting a class file """ -from __future__ import (absolute_import, division, print_function, unicode_literals) - import argparse import datetime import os @@ -23,6 +21,8 @@ def delete_one(oldfilename): os.system(cmd) #====================================================================== + + def delete_all(subproject, classname, args): # Directory at base of subproject diff --git a/buildconfig/move_class.py b/buildconfig/move_class.py index 5e6a1dea2e842a642ac372dc8273865f89709c73..23686f350a180cf8b210007b051e7479688bfd38 100755 --- a/buildconfig/move_class.py +++ b/buildconfig/move_class.py @@ -6,8 +6,6 @@ # & Institut Laue - Langevin # SPDX - License - Identifier: GPL - 3.0 + """ Utility for moving a class file to a different project.""" -from __future__ import (absolute_import, division, print_function, unicode_literals) - import argparse import datetime import os @@ -17,6 +15,8 @@ import sys from cmakelists_utils import * #====================================================================== + + def move_one(subproject, classname, newproject, newclassname, oldfilename, newfilename, args): """Move one file """ diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/main.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/main.py index 05f56278ef97d76b1badf6b72642823b853edee9..7ef2659a0b2bf40faab4ea51fc507f6701d475af 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/main.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/main.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets import sys diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/master_presenter.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/master_presenter.py index ebd68d667287e75d976bc2ee7e83b07925c6f436..c260b8dcf76e24141c94982f734e61fea20bbebb 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/master_presenter.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/master_presenter.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - import presenter import plot_presenter diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/master_view.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/master_view.py index 06531ea48559b9763a88f00929d0566ab0500adf..a5b731d55e470e30ddc1769fc20d0888137a1427 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/master_view.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/master_view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets import view diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/model_colour.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/model_colour.py index 4632a5563d71417d6b9fd46b4c23e2157f554e2c..10c01a68641b39caf1812f60eb0d9ad1f12d6a05 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/model_colour.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/model_colour.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) def line_colours(): diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/model_data.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/model_data.py index 995e99af40e8b6f777bc3e555b739f9120b22743..b0c5abfb33981fe7d2f97558da637b37f04eb50b 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/model_data.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/model_data.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_presenter.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_presenter.py index 15b621fc6b81fd1179be4f6ca035dc125b25fbe3..a69fe0ac83ae0f7587037e7a4378b41d21628d0e 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_presenter.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class PlotPresenter(object): diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_view.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_view.py index c4d1c9aa0315715a805d271e46ea7cea939d7085..2c41e8bb992714afa558772a2d55a0eec7d0a8dd 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_view.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/plot_view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets import matplotlib.pyplot as plt diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/presenter.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/presenter.py index 02360230e3a416b6a704a20601d786c2b726b390..e970b3d6ee404d0a69c1ac1529b871342240e937 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/presenter.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class Presenter(object): diff --git a/dev-docs/source/MVPTutorial/CompleteGUIcode/view.py b/dev-docs/source/MVPTutorial/CompleteGUIcode/view.py index 3f650cde0f2a071eed76cc13a38edba4686b178c..0f1aa66b9c0d57d6904c239ec529e12036cdb548 100644 --- a/dev-docs/source/MVPTutorial/CompleteGUIcode/view.py +++ b/dev-docs/source/MVPTutorial/CompleteGUIcode/view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets, QtCore diff --git a/dev-docs/source/RunningSanitizers.rst b/dev-docs/source/RunningSanitizers.rst new file mode 100644 index 0000000000000000000000000000000000000000..b3d916c0f6d1d898d8cb3c8c6b2430c08ef5d472 --- /dev/null +++ b/dev-docs/source/RunningSanitizers.rst @@ -0,0 +1,155 @@ +.. _RunningSanitizers: + +################## +Running Sanitizers +################## + +.. contents:: + :local: + +Overview +========= + +Sanitizers allow developers to find any issues with their code at runtime +related to memory, threading or undefined behaviour. + +Pre-requisites +============== + +The following tooling is required: + +- GCC-8 onwards +- Clang 3.2 onwards + + +Switching to Sanitizer Build +============================ + +The following sanitizers modes are available: + +- Address +- Thread +- Undefined + +It's recommended to build in *RelWithDebInfo* mode, CMake will automatically +switch to -O1 and append extra flags for stack traces to work correctly whilst +preserving high performance + +If required, a build can be completed in debug mode too, however the +performance penalty will be pretty severe. + +Command Line +------------ + +First, delete *CMakeCache.txt* if your system compiler is GCC 7 or below +(you can check with *gcc -v*). + +To change to a sanitized build navigate to your build folder and execute the +following: + + .. code-block:: sh + + cmake *path_to_src* -DUSE_SANITIZER=*Mode* -DCMAKE_BUILD_TYPE=RelWithDebInfo + +If you need to specify a different compiler too (for example if your system +default is GCC-7) + + .. code-block:: sh + + CC=gcc-8 CXX=g++-8 cmake *path_to_src* -DUSE_SANITIZER=*Mode* -DCMAKE_BUILD_TYPE=RelWithDebInfo + + +For example, to switch to an address sanitizer build the following can be used: + + .. code-block:: sh + + cmake *path_to_src* -DUSE_SANITIZER=Address -DCMAKE_BUILD_TYPE=RelWithDebInfo + +CMake GUI +--------- + +- Delete the cache if your system compiler is GCC 7 or below (you can check + with *gcc -v*). Hit configure and click specify native compilers to *gcc-8* + and *g++-8* +- Change *CMAKE_BUILD_TYPE* to *RelWithDebInfo* (or *Debug*) +- Change *USE_SANITIZERS* to any of the options in the drop down +- Hit generate and rebuild the project + +Running Tests +============= + +Several upstream linked libraries currently contain leaks which we cannot +resolve (or have been resolved but not appeared downstream). + +We can suppress warnings in the address sanitizer by setting environment +variables in the console before running in each mode. + +Advanced Details +================ + +Most developers do not need to read this, but it's good for those who +want to know what's happening + +CMake substitutes in various flags for the address sanitizer builds to +setup suppressions etc... this is the equivalent of doing the following +in a local shell: + + .. code-block:: sh + + export ASAN_OPTIONS="verify_asan_link_order=0:detect_stack_use_after_return=true:halt_on_error=false:suppressions=*path_to_mantid*/tools/Sanitizer/Address.supp" + export LSAN_OPTIONS="suppressions=*path_to_mantid*/tools/Sanitizer/Leak.supp" + +All code executed which is executed in that shell will now be sanitized +correctly. To save developers effort the CXX_ADD_TEST macro (in +FindCxxTest.cmake) will append these environment variables on a developers +behalf. + +Instrumenting Python (Advanced) +------------------------------- + +Currently any code started in Python (i.e. Python Unit Tests) will not pre-load +ASAN instrumentation. This can be split into two categories: + +- Code which uses Python only components: Not worth instrumenting as any + issues will be upstream. This also will emit an error if + *verify_asan_link_order* is set to true, as we technically haven't + instrumented anything (unless you have a sanitized Python build) +- Code which uses Mantid C++ components: This can be instrumented, but + (currently) isn't by default, as the user has to determine the *LD_PRELOAD* + path. + +If you need / want to profile C++ components which are triggered from Python +the following steps should setup your environment: + + .. code-block:: sh + + # Get the path to your linked ASAN + ldd bin/KernelTest | grep "libasan" + export LD_PRELOAD=/usr/lib/path_to/libasan.so.x + + # You may want to re-run the ASAN_OPTIONS export dropping + # the verify to make sure that the C++ component is being instrumented: + + export ASAN_OPTIONS="detect_stack_use_after_return=true:halt_on_error=false:suppressions=*path_to_mantid*/buildconfig/Sanitizer/Address.supp" + + +Common Problems +=============== + +Library Leaks Appearing +----------------------- + +Check that you have correctly spelt *suppressions* as there will be no warnings +for typos. A good check is to put some random characters in the .supp files, +which will cause all tests to fail if it's begin read. + +Any new third party memory leaks need to go into *Leaks.supp* not +*Address.supp* (which should ideally be completely empty) to be suppressed. + +ASAN was not the first library loaded +-------------------------------------- + +This can appear when running Python tests, as the executable is not build +with instrumentation. To avoid this warning ensure that +*verify_asan_link_order=0* is set in your environment and that you are +using GCC 8 onwards. diff --git a/dev-docs/source/index.rst b/dev-docs/source/index.rst index 1bd00d7980ca5ab63883dee9915a444f07e9565c..dde789db23843c5db47545dd4c2e6ec30ef5b283 100644 --- a/dev-docs/source/index.rst +++ b/dev-docs/source/index.rst @@ -155,6 +155,7 @@ Testing SystemTests DataFilesForTesting TestingUtilities + RunningSanitizers :doc:`RunningTheUnitTests` Details on how to run the suite of unit tests. @@ -180,6 +181,9 @@ Testing :doc:`TestingUtilities` Helper utlities used for testing. +:doc:`RunningSanitizers` + How to run the various sanitizers locally. + =============== GUI Development =============== diff --git a/docs/source/concepts/PropertiesFile.rst b/docs/source/concepts/PropertiesFile.rst index d6cf42272ef18eb1e93298931615262e1128613f..41994c91022d556c1d320c357dcd88db00c22817 100644 --- a/docs/source/concepts/PropertiesFile.rst +++ b/docs/source/concepts/PropertiesFile.rst @@ -36,9 +36,6 @@ General properties | ``algorithms.categories.hidden`` | A comma separated list of any categories of | ``Muons,Testing`` | | | algorithms that should be hidden in Mantid. | | +----------------------------------+--------------------------------------------------+------------------------+ -| ``algorithms.retained`` | The Number of algorithms properties to retain in | ``50`` | -| | memory for reference in scripts. | | -+----------------------------------+--------------------------------------------------+------------------------+ | ``curvefitting.guiExclude`` | A semicolon separated list of function names | ``ExpDecay;Gaussian;`` | | | that should be hidden in Mantid. | | +----------------------------------+--------------------------------------------------+------------------------+ diff --git a/docs/source/release/v5.1.0/diffraction.rst b/docs/source/release/v5.1.0/diffraction.rst index 6a86de8a8e6c03acb1590156efefb2db30928069..954c18bc6991e108c15ba1f58a9aba19c3e71379 100644 --- a/docs/source/release/v5.1.0/diffraction.rst +++ b/docs/source/release/v5.1.0/diffraction.rst @@ -12,6 +12,8 @@ Diffraction Changes Powder Diffraction ------------------ +- Polaris.create_total_scattering_pdf output workspaces now have the run number in the names. + Engineering Diffraction ----------------------- Improvements diff --git a/docs/source/release/v5.1.0/framework.rst b/docs/source/release/v5.1.0/framework.rst index a893818aae15fa7ccbaa5cd3a782ec694d43d5f4..02d64bb3567e0b6ba1ea322fbcb7eca5d6cf95a1 100644 --- a/docs/source/release/v5.1.0/framework.rst +++ b/docs/source/release/v5.1.0/framework.rst @@ -15,6 +15,10 @@ Concepts Algorithms ---------- +- Add specialization to :ref:`SetUncertainties <algm-SetUncertainties>` for the + case where InputWorkspace == OutputWorkspace. Where possible, avoid the + cost of cloning the inputWorkspace. + Data Objects ------------ diff --git a/docs/source/release/v5.1.0/mantidworkbench.rst b/docs/source/release/v5.1.0/mantidworkbench.rst index 2d1ab24cb4b04fa63e0c5939383c1006c6ad2663..89e3ce05d8610020309c59c9174920abfd0110d0 100644 --- a/docs/source/release/v5.1.0/mantidworkbench.rst +++ b/docs/source/release/v5.1.0/mantidworkbench.rst @@ -13,6 +13,7 @@ Improvements - The plot selection dialog now correctly shows the full range of valid spectra to plot, not just the min to max range. - Tile plots are now reloaded correctly by project recovery. +- Fixed an issue where some scripts were running slower if a plot was open at the same time. Bugfixes @@ -20,5 +21,6 @@ Bugfixes - Fixed a bug where setting columns to Y error in table workspaces wasn't working. The links between the Y error and Y columns weren't being set up properly. - Fixed a crash when you selected a spectra to plot that was not present in a workspace. +- The scale of the color bars on colorfill plots of ragged workspaces now uses the maximum and minimum values of the data. :ref:`Release 5.1.0 <v5.1.0>` diff --git a/docs/sphinxext/mantiddoc/directives/algorithm.py b/docs/sphinxext/mantiddoc/directives/algorithm.py index f118d5c11173e2c3d2f78147c8d5164dc5f3318c..51f655f1f95f5c88acfba5ee5f5095aa183a2efd 100644 --- a/docs/sphinxext/mantiddoc/directives/algorithm.py +++ b/docs/sphinxext/mantiddoc/directives/algorithm.py @@ -4,12 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantiddoc.directives.base import AlgorithmBaseDirective #pylint: disable=unused-import import os import re -from six import iteritems - REDIRECT_TEMPLATE = "redirect.html" DEPRECATE_USE_ALG_RE = re.compile(r"Use\s(([A-Z][a-zA-Z0-9]+)\s(version ([0-9])+)?)\s*instead.") @@ -20,6 +17,8 @@ DEPRECATE_USE_ALG_RE = re.compile(r"Use\s(([A-Z][a-zA-Z0-9]+)\s(version ([0-9])+ SCREENSHOT_MAX_HEIGHT = 250 #-------------------------------------------------------------------------- + + class AlgorithmDirective(AlgorithmBaseDirective): """ @@ -219,7 +218,7 @@ def html_collect_pages(dummy_app): template = REDIRECT_TEMPLATE all_algs = AlgorithmFactory.getRegisteredAlgorithms(True) - for name, versions in iteritems(all_algs): + for name, versions in all_algs.items(): redirect_pagename = "algorithms/%s" % name versions.sort() highest_version = versions[-1] @@ -229,6 +228,7 @@ def html_collect_pages(dummy_app): #------------------------------------------------------------------------------------------------------------ + def setup(app): """ Setup the directives when the extension is activated diff --git a/docs/sphinxext/mantiddoc/directives/categories.py b/docs/sphinxext/mantiddoc/directives/categories.py index 9842d126cee0419fa96f9018ca192214c36ed339..06f25388847b4d61ed8d51453c4f2e3d011cda6d 100644 --- a/docs/sphinxext/mantiddoc/directives/categories.py +++ b/docs/sphinxext/mantiddoc/directives/categories.py @@ -12,12 +12,10 @@ creates "index" pages that lists the contents of each category. The display of each "index" page is controlled by a jinja2 template. """ -from __future__ import (absolute_import, division, print_function) from mantiddoc.directives.base import AlgorithmBaseDirective, algorithm_name_and_version #pylint: disable=unused-import from sphinx.util.osutil import relative_uri import os import posixpath -from six import iteritems, itervalues CATEGORY_PAGE_TEMPLATE = "category.html" ALG_CATEGORY_PAGE_TEMPLATE = "algorithmcategories.html" @@ -29,6 +27,7 @@ CATEGORIES_DIR = "categories" # directory of the document and the category directory INDEX_CATEGORIES = ["Algorithms", "FitFunctions", "Concepts", "Techniques", "Interfaces"] + class LinkItem(object): """ Defines a linkable item with a name and html reference @@ -83,6 +82,7 @@ class LinkItem(object): # endclass + class PageRef(LinkItem): """ Store details of a single page reference @@ -93,6 +93,7 @@ class PageRef(LinkItem): #endclass + class Category(LinkItem): """ Store information about a single category @@ -315,6 +316,7 @@ def to_unix_style_path(path): #--------------------------------------------------------------------------------- + def html_collect_pages(app): """ Callback for the 'html-collect-pages' Sphinx event. Adds category @@ -333,6 +335,7 @@ def html_collect_pages(app): yield (name, context, template) # enddef + def create_category_pages(app): """ Returns an iterable of (category_name, context, "category.html") @@ -345,7 +348,7 @@ def create_category_pages(app): template = CATEGORY_PAGE_TEMPLATE categories = env.categories - for name, category in iteritems(categories): + for name, category in categories.items(): context = {} # First write out the named page context["title"] = category.name @@ -393,6 +396,8 @@ def create_category_pages(app): # enddef #----------------------------------------------------------------------------------------------------------- + + def create_top_algorithm_category(categories): """ Returns a tuple of (category_name, context, "category.html") @@ -409,7 +414,7 @@ def create_top_algorithm_category(categories): all_top_categories = [] category_src_dir = '' # If the category is a top category it will not contain "\\" - for top_name, top_category in iteritems(categories): + for top_name, top_category in categories.items(): #Add all the top level categories if "\\" not in top_name and top_category.section == 'algorithms': #get additional text for each category @@ -445,6 +450,7 @@ def create_top_algorithm_category(categories): top_html_path_noext = posixpath.join('algorithms', 'index') return (top_html_path_noext, top_context, template) + def extract_matching_categories(input_categories,filepath): """ Extract entries with a name matching that included the supplied file. @@ -466,6 +472,8 @@ def extract_matching_categories(input_categories,filepath): input_categories[:] = [category for category in input_categories if category.name not in name_list] return extracted_list + + def purge_categories(app, env, docname): """ Purge information about the given document name from the tracked algorithms @@ -485,12 +493,14 @@ def purge_categories(app, env, docname): return deadref = PageRef(name, docname) - for category in itervalues(categories): + for category in categories.values(): pages = category.pages if deadref in pages: pages.remove(deadref) #------------------------------------------------------------------------------ + + def setup(app): # Add categories directive app.add_directive('categories', CategoriesDirective) diff --git a/docs/sphinxext/mantiddoc/directives/diagram.py b/docs/sphinxext/mantiddoc/directives/diagram.py index cd410e7da104b94e0d7a43161cf7c9d9046134d7..a01a6af317c1456b406d3dd4a0292831239caea2 100644 --- a/docs/sphinxext/mantiddoc/directives/diagram.py +++ b/docs/sphinxext/mantiddoc/directives/diagram.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantiddoc.directives.base import BaseDirective #pylint: disable=unused-import from sphinx.locale import _ #pylint: disable=unused-import import os from string import Template import subprocess -from six import PY3 ###################### #CONFIGURABLE OPTIONS# @@ -94,8 +92,7 @@ class DiagramDirective(BaseDirective): raise RuntimeError("Cannot find dot-file: '" + diagram_name + "' in '" + os.path.join(env.srcdir,"diagrams")) out_src = Template(in_src).substitute(STYLE) - if PY3: - out_src = out_src.encode() + out_src = out_src.encode() gviz = subprocess.Popen([dot_executable,"-Tpng","-o",out_path], stdin=subprocess.PIPE) gviz.communicate(input=out_src) gviz.wait() @@ -109,6 +106,7 @@ class DiagramDirective(BaseDirective): #------------------------------------------------------------------------------------------------------------ + def setup(app): """ Setup the directives when the extension is activated diff --git a/docs/sphinxext/mantiddoc/directives/properties.py b/docs/sphinxext/mantiddoc/directives/properties.py index cc027352d115bc76c72dd334f64cf870f857210c..d8f97dd546f98ffcb8774c1a9be0b95662c00947 100644 --- a/docs/sphinxext/mantiddoc/directives/properties.py +++ b/docs/sphinxext/mantiddoc/directives/properties.py @@ -5,14 +5,12 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,deprecated-module -from __future__ import (absolute_import, division, print_function) from mantiddoc.directives.base import AlgorithmBaseDirective #pylint: disable=unused-import import re from string import punctuation -from six.moves import range - SUBSTITUTE_REF_RE = re.compile(r'\|(.+?)\|') + class PropertiesDirective(AlgorithmBaseDirective): """ diff --git a/docs/sphinxext/mantiddoc/directives/sourcelink.py b/docs/sphinxext/mantiddoc/directives/sourcelink.py index 1baf5c6d6955c2405aa1eabb2cdc8559a7e90d7d..11aa65458c4b3ff43b04cd22d84d5c0ced742989 100644 --- a/docs/sphinxext/mantiddoc/directives/sourcelink.py +++ b/docs/sphinxext/mantiddoc/directives/sourcelink.py @@ -4,12 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import subprocess -from six import iteritems - import mantid from .base import AlgorithmBaseDirective #pylint: disable=unused-import @@ -204,7 +200,7 @@ class SourceLinkDirective(AlgorithmBaseDirective): valid_ext_list = [] self.add_rst(self.make_header("Source")) - for extension, filepath in iteritems(file_paths): + for extension, filepath in file_paths.items(): if filepath is not None: self.output_path_to_page(filepath, extension) valid_ext_list.append(extension) diff --git a/qt/applications/workbench/workbench/app/mainwindow.py b/qt/applications/workbench/workbench/app/mainwindow.py index a9488f0aa0dd10c1e4d17b0bcb73cf1e0a63596d..c856a544d2cefb06f16b0ecb5d1891ea80666e1e 100644 --- a/qt/applications/workbench/workbench/app/mainwindow.py +++ b/qt/applications/workbench/workbench/app/mainwindow.py @@ -10,8 +10,6 @@ """ Defines the QMainWindow of the application and the main() entry point. """ -from __future__ import (absolute_import, division, print_function, unicode_literals) - import argparse import atexit import importlib @@ -21,7 +19,7 @@ from functools import partial from mantid.api import FrameworkManagerImpl from mantid.kernel import (ConfigService, UsageService, logger, version_str as mantid_version_str) -from mantid.py3compat import setswitchinterval +from sys import setswitchinterval from mantid.utils import is_required_version from workbench.app import MAIN_WINDOW_OBJECT_NAME, MAIN_WINDOW_TITLE from workbench.plugins.exception_handler import exception_logger diff --git a/qt/applications/workbench/workbench/config/__init__.py b/qt/applications/workbench/workbench/config/__init__.py index b5128ff08f2bb398b3b66816bfe987f2165da868..9dfdac28ee5298b3fca72d9bd6e1c5ad7059afbe 100644 --- a/qt/applications/workbench/workbench/config/__init__.py +++ b/qt/applications/workbench/workbench/config/__init__.py @@ -16,8 +16,6 @@ should import the CONF object as and use it to access the settings """ -from __future__ import (absolute_import, unicode_literals) - # std imports from collections import namedtuple import os diff --git a/qt/applications/workbench/workbench/config/fonts.py b/qt/applications/workbench/workbench/config/fonts.py index 785a1eb6f0de982d4df811e056f9f684ce53cd85..e714b2047dfcf826dcb3e90f8fb2efb5e732c5c9 100644 --- a/qt/applications/workbench/workbench/config/fonts.py +++ b/qt/applications/workbench/workbench/config/fonts.py @@ -9,8 +9,6 @@ # """ Utility functions to deal with fetching fonts """ -from __future__ import (absolute_import, unicode_literals) - # std imports import os import os.path as osp diff --git a/qt/applications/workbench/workbench/config/test/test_user.py b/qt/applications/workbench/workbench/config/test/test_user.py index 2dea80396b964ec3c5489937f6f26600276b2066..f10164855d6e5bca7f645c4fa5cfef18178ba5d5 100644 --- a/qt/applications/workbench/workbench/config/test/test_user.py +++ b/qt/applications/workbench/workbench/config/test/test_user.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - import os from unittest import TestCase, main diff --git a/qt/applications/workbench/workbench/config/user.py b/qt/applications/workbench/workbench/config/user.py index f38d73d8d9e6fa6144d11d622f397f06f9078b97..daa70465b1e87080bcccf7e0d5d834f546effb9e 100644 --- a/qt/applications/workbench/workbench/config/user.py +++ b/qt/applications/workbench/workbench/config/user.py @@ -7,10 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - -from mantid.py3compat import is_text_string from posixpath import join as joinsettings from qtpy.QtCore import QSettings @@ -158,13 +154,13 @@ class UserConfig(object): Sanity check the section and option are strings and return the flattened option key """ if second is None: - if not is_text_string(option): + if not isinstance(option, str): raise TypeError('Found invalid type ({}) for option ({}) must be a string'.format(type(option), option)) return option - else: # fist argument is actually the section/group - if not is_text_string(option): + else: # first argument is actually the section/group + if not isinstance(option, str): raise TypeError( 'Found invalid type ({}) for section ({}) must be a string'.format(type(option), option)) - if not is_text_string(second): + if not isinstance(second, str): raise TypeError('Found invalid type ({}) for option ({}) must be a string'.format(type(second), second)) return joinsettings(option, second) diff --git a/qt/applications/workbench/workbench/plotting/backend_workbench.py b/qt/applications/workbench/workbench/plotting/backend_workbench.py index 7193035b7a41ec229d6c38e024f198df74932a91..ce0c24fe39e5f704640507b42d85ee1c4b331080 100644 --- a/qt/applications/workbench/workbench/plotting/backend_workbench.py +++ b/qt/applications/workbench/workbench/plotting/backend_workbench.py @@ -13,8 +13,7 @@ Qt-based matplotlib backend that can operate when called from non-gui threads. It uses qtagg for rendering but the ensures that any rendering calls are done on the main thread of the application as the default """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) + # std imports import importlib diff --git a/qt/applications/workbench/workbench/plotting/config.py b/qt/applications/workbench/workbench/plotting/config.py index 5b9733fceab215b67d45b01ce89648a78d88ead4..87da32bd242b811e613dd11f1632b5cf87d47408 100644 --- a/qt/applications/workbench/workbench/plotting/config.py +++ b/qt/applications/workbench/workbench/plotting/config.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import) - # system imports # 3rd-party imports diff --git a/qt/applications/workbench/workbench/plotting/figureinteraction.py b/qt/applications/workbench/workbench/plotting/figureinteraction.py index a23811d34f04cf233a7fa7f2688fcbd637d5969d..f54cdce9b624002606d9319020049da9fa2f6f4e 100644 --- a/qt/applications/workbench/workbench/plotting/figureinteraction.py +++ b/qt/applications/workbench/workbench/plotting/figureinteraction.py @@ -9,9 +9,8 @@ """ Defines interaction behaviour for plotting. """ -from __future__ import (absolute_import, unicode_literals) - # std imports +import numpy as np from collections import OrderedDict from copy import copy from functools import partial @@ -26,7 +25,6 @@ from matplotlib.collections import Collection from mantid.api import AnalysisDataService as ads from mantid.plots import datafunctions, MantidAxes from mantid.plots.utility import zoom, MantidAxType -from mantid.py3compat import iteritems from mantidqt.plotting.figuretype import FigureType, figure_type from mantidqt.plotting.markers import SingleMarker from mantidqt.widgets.plotconfigdialog.curvestabwidget import curve_has_errors, CurveProperties @@ -308,7 +306,7 @@ class FigureInteraction(object): axes_menu = QMenu("Axes", menu) axes_actions = QActionGroup(axes_menu) current_scale_types = (ax.get_xscale(), ax.get_yscale()) - for label, scale_types in iteritems(AXES_SCALE_MENU_OPTS): + for label, scale_types in AXES_SCALE_MENU_OPTS.items(): action = axes_menu.addAction(label, partial(self._quick_change_axes, scale_types, ax)) if current_scale_types == scale_types: action.setCheckable(True) @@ -346,7 +344,7 @@ class FigureInteraction(object): axes_menu = QMenu("Color bar", menu) axes_actions = QActionGroup(axes_menu) images = ax.get_images() + [col for col in ax.collections if isinstance(col, Collection)] - for label, scale_type in iteritems(COLORBAR_SCALE_MENU_OPTS): + for label, scale_type in COLORBAR_SCALE_MENU_OPTS.items(): action = axes_menu.addAction(label, partial(self._change_colorbar_axes, scale_type)) if type(images[0].norm) == scale_type: action.setCheckable(True) @@ -704,6 +702,12 @@ class FigureInteraction(object): if ax.lines: # Relim causes issues with colour plots, which have no lines. ax.relim() + if ax.images: # Colour bar limits are wrong if workspace is ragged. Set them manually. + colorbar_min = np.nanmin(ax.images[-1].get_array()) + colorbar_max = np.nanmax(ax.images[-1].get_array()) + for image in ax.images: + image.set_clim(colorbar_min, colorbar_max) + ax.autoscale() datafunctions.set_initial_dimensions(ax) diff --git a/qt/applications/workbench/workbench/plotting/figuremanager.py b/qt/applications/workbench/workbench/plotting/figuremanager.py index 7201eade9b7323e2bcafce57b9f529fa4716b849..2f877a1668823f81d43fcecc469c727165e313cf 100644 --- a/qt/applications/workbench/workbench/plotting/figuremanager.py +++ b/qt/applications/workbench/workbench/plotting/figuremanager.py @@ -8,8 +8,6 @@ # # """Provides our custom figure manager to wrap the canvas, window and our custom toolbar""" -from __future__ import (absolute_import, unicode_literals) - import sys from functools import wraps @@ -24,7 +22,6 @@ from qtpy.QtWidgets import QApplication, QLabel, QFileDialog from mantid.api import AnalysisDataService, AnalysisDataServiceObserver, ITableWorkspace, MatrixWorkspace from mantid.kernel import logger from mantid.plots import datafunctions, MantidAxes -from mantid.py3compat import text_type from mantidqt.io import open_a_file_dialog from mantidqt.plotting.figuretype import FigureType, figure_type from mantidqt.utils.qt.qappthreadcall import QAppThreadCall @@ -92,9 +89,12 @@ class FigureManagerADSObserver(AnalysisDataServiceObserver): # managed via a workspace. # See https://github.com/mantidproject/mantid/issues/25135. empty_axes = [] + redraw = False for ax in all_axes: if isinstance(ax, MantidAxes): - ax.remove_workspace_artists(workspace) + to_redraw = ax.remove_workspace_artists(workspace) + else: + to_redraw = False # We check for axes type below as a pseudo check for an axes being # a colorbar. Creating a colorfill plot creates 2 axes: one linked # to a workspace, the other a colorbar. Deleting the workspace @@ -104,10 +104,11 @@ class FigureManagerADSObserver(AnalysisDataServiceObserver): # Axes object being closed. if type(ax) is not Axes: empty_axes.append(MantidAxes.is_empty(ax)) + redraw = redraw | to_redraw if all(empty_axes): self.window.emit_close() - else: + elif redraw: self.canvas.draw() @_catch_exceptions @@ -367,7 +368,7 @@ class FigureManagerWorkbench(FigureManagerBase, QObject): self.toolbar.hold() def get_window_title(self): - return text_type(self.window.windowTitle()) + return isinstance(self.window.windowTitle(), str) def set_window_title(self, title): self.window.setWindowTitle(title) diff --git a/qt/applications/workbench/workbench/plotting/figurewindow.py b/qt/applications/workbench/workbench/plotting/figurewindow.py index 2062f268634d3ba1055f8c92a6a932a0d85c117e..d51ba6b183762ce78a96bbc0b1ce2fbf93398e78 100644 --- a/qt/applications/workbench/workbench/plotting/figurewindow.py +++ b/qt/applications/workbench/workbench/plotting/figurewindow.py @@ -8,8 +8,6 @@ # # """Provides the QMainWindow subclass for a plotting window""" -from __future__ import absolute_import - # std imports import weakref diff --git a/qt/applications/workbench/workbench/plotting/globalfiguremanager.py b/qt/applications/workbench/workbench/plotting/globalfiguremanager.py index 7f0c8cf2f2973e1f77545dab19317a271856d08d..6443f24728443305c0a0765b4ed2e901e2c97619 100644 --- a/qt/applications/workbench/workbench/plotting/globalfiguremanager.py +++ b/qt/applications/workbench/workbench/plotting/globalfiguremanager.py @@ -7,14 +7,11 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - # std imports import atexit import gc # 3rd party imports -import six from enum import Enum from .observabledictionary import DictionaryAction, ObservableDictionary @@ -131,7 +128,7 @@ class GlobalFigureManager(object): def destroy_fig(cls, fig): "*fig* is a Figure instance" num = None - for manager in six.itervalues(cls.figs): + for manager in cls.figs.values(): if manager.canvas.figure == fig: num = manager.num break diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/__init__.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/__init__.py index 7e74ab9d98555b862261ff62c6767055d28b840b..ab55a883fd4abadde69e1199b7f1ba744fbbce37 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/__init__.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/__init__.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from mantid.plots.mantidaxes import MantidAxes from mantidqt.widgets.plotconfigdialog import curve_in_ax diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/axes.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/axes.py index 3032199f3e1c34401c2aacbbf53b1adcb69b54eb..54cd3158ac71bafe48b311015904b9ae191eb04d 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/axes.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/axes.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from numpy import isclose from mantid.plots.utility import get_autoscale_limits diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/figure.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/figure.py index ed257509c1bd26744351666ca22186d14ab1cf6d..56c506aa5358b8458572214f56d78a7404c6dd73 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/figure.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/figure.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from matplotlib import rcParams from numpy import isclose diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/lines.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/lines.py index e218c4e03500140e27d258a9e18a20983478045e..553b4e50256fba420f899fbe81e2f34e4f359c25 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/lines.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/lines.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from matplotlib import rcParams from matplotlib.container import ErrorbarContainer diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/__init__.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/__init__.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgenerator.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgenerator.py index 8978bd8958801e8eb435ca4764a0627aa8bc8d19..d9b298aef94ee50ac99bc4a6f8fc9b7b0e5c4a19 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgenerator.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgenerator.py @@ -14,7 +14,7 @@ from matplotlib.axes import Axes from matplotlib.legend import Legend from mantid.plots import MantidAxes -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantid.simpleapi import CreateWorkspace from workbench.plotting.plotscriptgenerator import generate_script diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratoraxes.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratoraxes.py index 4f84bbd28266ed52138fd8aae8b3e57958317b01..f844f5c3762feddc3a34d6ba0bfc79e7ba7f8890 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratoraxes.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratoraxes.py @@ -6,15 +6,13 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import unittest import matplotlib as mpl mpl.use('Agg') # noqa import matplotlib.pyplot as plt -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from workbench.plotting.plotscriptgenerator.axes import (generate_axis_limit_commands, generate_axis_label_commands) diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorlines.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorlines.py index 3dfbe5bf4f38823dea672cdbebbd6705d347d7b2..5353e6b143c11b7f3ce33ab6358bb8354edbf151 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorlines.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorlines.py @@ -14,7 +14,7 @@ import matplotlib.pyplot as plt from copy import copy from matplotlib.container import ErrorbarContainer -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantid.simpleapi import CreateWorkspace from workbench.plotting.plotscriptgenerator.lines import (_get_plot_command_kwargs_from_line2d, _get_errorbar_specific_plot_kwargs, diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorutils.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorutils.py index 6416f144dca0b07cf73f11b950ccbccdfe0ae5c8..96f51807c17a283991196496ecfab6113cca0e84 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorutils.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/test/test_plotscriptgeneratorutils.py @@ -12,7 +12,7 @@ from ast import parse from collections import OrderedDict from numpy import array -from mantid.py3compat.mock import patch, Mock +from unittest.mock import patch, Mock from workbench.plotting.plotscriptgenerator.utils import (convert_args_to_string, get_plotted_workspaces_names, clean_variable_name, diff --git a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/utils.py b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/utils.py index 2a6cef17e959a3a9b5b87db65b3a8b139752125d..3f17ee1dd5fc1e5b4e666c8ca741519e02e32735 100644 --- a/qt/applications/workbench/workbench/plotting/plotscriptgenerator/utils.py +++ b/qt/applications/workbench/workbench/plotting/plotscriptgenerator/utils.py @@ -6,15 +6,11 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import re import numpy as np from matplotlib.container import ErrorbarContainer -from mantid.py3compat import is_text_string - def round_to_sig_figs(number, sig_figs): if np.isclose(number, 0): @@ -28,7 +24,7 @@ def convert_value_to_arg_string(value): which can be passed to a function. It is recursive so works on objects such as lists. """ - if is_text_string(value): + if isinstance(value, str): return "'{}'".format(value) if isinstance(value, (list, np.ndarray, tuple)): return "[{}]".format(', '.join([convert_value_to_arg_string(v) for v in value])) diff --git a/qt/applications/workbench/workbench/plotting/propertiesdialog.py b/qt/applications/workbench/workbench/plotting/propertiesdialog.py index f814e7f8796821dc8d7928e3cf2a7941782d7da4..ba10e60d7be6d408c11ffd2b78d31a8520d1d12b 100644 --- a/qt/applications/workbench/workbench/plotting/propertiesdialog.py +++ b/qt/applications/workbench/workbench/plotting/propertiesdialog.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - # std imports # 3rdparty imports diff --git a/qt/applications/workbench/workbench/plotting/test/test_figureerrorsmanager.py b/qt/applications/workbench/workbench/plotting/test/test_figureerrorsmanager.py index b6b9e9cd0b1f836608b9fc7784ecf98347530240..ed27ed4cf6a9691be1efbca4cedf57bc955f01e3 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_figureerrorsmanager.py +++ b/qt/applications/workbench/workbench/plotting/test/test_figureerrorsmanager.py @@ -6,9 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. # -from __future__ import (absolute_import, division, print_function, - unicode_literals) - import unittest import matplotlib diff --git a/qt/applications/workbench/workbench/plotting/test/test_figureinteraction.py b/qt/applications/workbench/workbench/plotting/test/test_figureinteraction.py index 3c54cd45f94d3a4ec4ad177f457df61893c06f03..fe5915fc324d1024f2e710455a132a5c85147a05 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_figureinteraction.py +++ b/qt/applications/workbench/workbench/plotting/test/test_figureinteraction.py @@ -6,8 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + # system imports import unittest @@ -24,10 +23,10 @@ from testhelpers import assert_almost_equal # local package imports from mantid.plots import MantidAxes -from mantid.py3compat.mock import MagicMock, PropertyMock, call, patch +from unittest.mock import MagicMock, PropertyMock, call, patch from mantid.simpleapi import CreateWorkspace from mantidqt.plotting.figuretype import FigureType -from mantidqt.plotting.functions import plot +from mantidqt.plotting.functions import plot, pcolormesh_from_names from mantidqt.utils.qt.testing import start_qapplication from workbench.plotting.figureinteraction import FigureInteraction @@ -378,6 +377,19 @@ class FigureInteractionTest(unittest.TestCase): current_scale_types2 = (ax.get_xscale(), ax.get_yscale()) self.assertNotEqual(current_scale_types2, current_scale_types1) + def test_scale_on_ragged_workspaces_maintained_when_toggling_normalisation(self): + ws = CreateWorkspace(DataX=[1, 2, 3, 4, 2, 4, 6, 8], DataY=[2] * 8, NSpec=2, OutputWorkspace="ragged_ws") + fig = pcolormesh_from_names([ws]) + mock_canvas = MagicMock(figure=fig) + fig_manager_mock = MagicMock(canvas=mock_canvas) + fig_interactor = FigureInteraction(fig_manager_mock) + fig_interactor._toggle_normalization(fig.axes[0]) + + clim = fig.axes[0].images[0].get_clim() + fig_interactor._toggle_normalization(fig.axes[0]) + self.assertEqual(clim, fig.axes[0].images[0].get_clim()) + self.assertNotEqual((-0.1, 0.1), fig.axes[0].images[0].get_clim()) + # Private methods def _create_mock_fig_manager_to_accept_right_click(self): fig_manager = MagicMock() diff --git a/qt/applications/workbench/workbench/plotting/test/test_figuremanager.py b/qt/applications/workbench/workbench/plotting/test/test_figuremanager.py index 2866b3ddd01086ca6872119d2e0ad838bc7263f6..a4ef45de703e97bc6e1acdb63293766a9d9098c4 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_figuremanager.py +++ b/qt/applications/workbench/workbench/plotting/test/test_figuremanager.py @@ -7,7 +7,7 @@ # This file is part of the mantid workbench. import unittest -from mantid.py3compat.mock import MagicMock, patch +from unittest.mock import MagicMock, patch from mantidqt.utils.qt.testing import start_qapplication from workbench.plotting.figuremanager import FigureCanvasQTAgg, FigureManagerWorkbench diff --git a/qt/applications/workbench/workbench/plotting/test/test_figurewindow.py b/qt/applications/workbench/workbench/plotting/test/test_figurewindow.py index 99a46a4a016314ae8204981e7febdb1e3a0d2e74..b112c68cf8962523bbc724a3a4b44290dfbc54e5 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_figurewindow.py +++ b/qt/applications/workbench/workbench/plotting/test/test_figurewindow.py @@ -13,7 +13,7 @@ matplotlib.use('Qt5Agg') # noqa # we need Qt for events to work import matplotlib.pyplot as plt from mantid import plots # noqa # register mantid projection -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantid.simpleapi import CreateWorkspace from mantidqt.utils.qt.testing import start_qapplication from workbench.plotting.figurewindow import FigureWindow diff --git a/qt/applications/workbench/workbench/plotting/test/test_globalfiguremanager.py b/qt/applications/workbench/workbench/plotting/test/test_globalfiguremanager.py index 25782ac4ff5863475f51aa08b7864d1b8c73a0f1..a0ec1c6d751b6455dfdc9074184ce62b04a9e8fe 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_globalfiguremanager.py +++ b/qt/applications/workbench/workbench/plotting/test/test_globalfiguremanager.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat.mock import Mock, call, patch +from unittest.mock import Mock, call, patch from workbench.plotting.globalfiguremanager import FigureAction, GlobalFigureManager, GlobalFigureManagerObserver from workbench.plotting.observabledictionary import DictionaryAction diff --git a/qt/applications/workbench/workbench/plotting/test/test_propertiesdialog.py b/qt/applications/workbench/workbench/plotting/test/test_propertiesdialog.py index a7b9545e066c43747f883f7e345cd6a467771e13..cf3275899d7dcd100c5db261f6db915f204c52d7 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_propertiesdialog.py +++ b/qt/applications/workbench/workbench/plotting/test/test_propertiesdialog.py @@ -6,8 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + # system imports import unittest diff --git a/qt/applications/workbench/workbench/plotting/test/test_utility.py b/qt/applications/workbench/workbench/plotting/test/test_utility.py index 9927c34aa0d07e0379dd413b67dc75c260adb05f..d4e3fc6c4afe16c44acb7c2e64dca5edbadd93c5 100644 --- a/qt/applications/workbench/workbench/plotting/test/test_utility.py +++ b/qt/applications/workbench/workbench/plotting/test/test_utility.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid package -from __future__ import absolute_import - import unittest import matplotlib.pyplot as plt diff --git a/qt/applications/workbench/workbench/plotting/toolbar.py b/qt/applications/workbench/workbench/plotting/toolbar.py index 34e050eba708c07d9a8f947ed0860534abbd62a1..e1073d6510029103d0c1cb4168a0b26e7097003b 100644 --- a/qt/applications/workbench/workbench/plotting/toolbar.py +++ b/qt/applications/workbench/workbench/plotting/toolbar.py @@ -8,8 +8,6 @@ # # -from __future__ import (absolute_import, division, print_function, unicode_literals) - from matplotlib.backends.backend_qt5 import NavigationToolbar2QT from qtpy import QtCore, QtGui, QtPrintSupport, QtWidgets diff --git a/qt/applications/workbench/workbench/plugins/algorithmselectorwidget.py b/qt/applications/workbench/workbench/plugins/algorithmselectorwidget.py index 58972040250f607d7b368c3060eab1d236ab5ddd..7814524100a2afdacb7e94ae6005e0cd09bd6bd0 100644 --- a/qt/applications/workbench/workbench/plugins/algorithmselectorwidget.py +++ b/qt/applications/workbench/workbench/plugins/algorithmselectorwidget.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - from contextlib import contextmanager from qtpy.QtWidgets import QVBoxLayout diff --git a/qt/applications/workbench/workbench/plugins/base.py b/qt/applications/workbench/workbench/plugins/base.py index 3701a411db137cf8d602479c21f20b72d1bc16c4..ee978e9f9b7148a4ad77faffcb30a4e51d5e89e8 100644 --- a/qt/applications/workbench/workbench/plugins/base.py +++ b/qt/applications/workbench/workbench/plugins/base.py @@ -8,8 +8,6 @@ # # """Provides a widget to wrap common behaviour for all plugins""" -from __future__ import absolute_import - from qtpy.QtCore import Qt from qtpy.QtWidgets import QDockWidget, QMainWindow, QWidget diff --git a/qt/applications/workbench/workbench/plugins/editor.py b/qt/applications/workbench/workbench/plugins/editor.py index f34125a26c9fdb905e7d15c17224c703da277027..8daf4773bb6be05da8d018a698cafd40fe05b92e 100644 --- a/qt/applications/workbench/workbench/plugins/editor.py +++ b/qt/applications/workbench/workbench/plugins/editor.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - # system imports import os.path as osp diff --git a/qt/applications/workbench/workbench/plugins/exception_handler/__init__.py b/qt/applications/workbench/workbench/plugins/exception_handler/__init__.py index a2cbe241dd56caebdcd443639d8be278c5036742..f0aa51665beaa0f76ef97508f46786e90c9190bd 100644 --- a/qt/applications/workbench/workbench/plugins/exception_handler/__init__.py +++ b/qt/applications/workbench/workbench/plugins/exception_handler/__init__.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import - import traceback from ErrorReporter.error_report_presenter import ErrorReporterPresenter diff --git a/qt/applications/workbench/workbench/plugins/exception_handler/error_messagebox.py b/qt/applications/workbench/workbench/plugins/exception_handler/error_messagebox.py index d7eac019918910e223f79d89c59cbfd273dfac48..3d3d4c0eb985c394252c7489454e40016a5b48ce 100644 --- a/qt/applications/workbench/workbench/plugins/exception_handler/error_messagebox.py +++ b/qt/applications/workbench/workbench/plugins/exception_handler/error_messagebox.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import - from qtpy.QtCore import Qt from qtpy.QtWidgets import QMessageBox diff --git a/qt/applications/workbench/workbench/plugins/jupyterconsole.py b/qt/applications/workbench/workbench/plugins/jupyterconsole.py index 10737d2c9f010addcc5d64ca4b555eda6c1143e0..5f8f599f011781256ff6f38b5686a4109ea4e4ba 100644 --- a/qt/applications/workbench/workbench/plugins/jupyterconsole.py +++ b/qt/applications/workbench/workbench/plugins/jupyterconsole.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - # system imports import warnings warnings.filterwarnings(action='ignore', diff --git a/qt/applications/workbench/workbench/plugins/logmessagedisplay.py b/qt/applications/workbench/workbench/plugins/logmessagedisplay.py index c9e431a22e5e292cd6989165d4784b13f0baeeea..24bd3230f3728f9850f71471bd1cb7c14a55fa55 100644 --- a/qt/applications/workbench/workbench/plugins/logmessagedisplay.py +++ b/qt/applications/workbench/workbench/plugins/logmessagedisplay.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - import sys from qtpy.QtWidgets import QHBoxLayout diff --git a/qt/applications/workbench/workbench/plugins/plotselectorwidget.py b/qt/applications/workbench/workbench/plugins/plotselectorwidget.py index 81618bca7337e7ac327a0cf29407a0abf0416c4a..9aafffff6367a40a286d69847d41ff1b65d74e70 100644 --- a/qt/applications/workbench/workbench/plugins/plotselectorwidget.py +++ b/qt/applications/workbench/workbench/plugins/plotselectorwidget.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - # system imports # third-party library imports diff --git a/qt/applications/workbench/workbench/plugins/test/test_editor.py b/qt/applications/workbench/workbench/plugins/test/test_editor.py index 39136a392cb8d90ab68dd4da6890751cfc86eb45..6b10feff66a13a4e567ea76192e655d86c020470 100644 --- a/qt/applications/workbench/workbench/plugins/test/test_editor.py +++ b/qt/applications/workbench/workbench/plugins/test/test_editor.py @@ -11,7 +11,7 @@ import os from qtpy.QtWidgets import QMainWindow import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from workbench.plugins.editor import MultiFileEditor diff --git a/qt/applications/workbench/workbench/plugins/test/test_exception_handler.py b/qt/applications/workbench/workbench/plugins/test/test_exception_handler.py index 378cd501cefcbd3c15b1e98a4562efd02142e242..b8df7a21d1de23f42836ebe6f69c82a9e79e353a 100644 --- a/qt/applications/workbench/workbench/plugins/test/test_exception_handler.py +++ b/qt/applications/workbench/workbench/plugins/test/test_exception_handler.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, unicode_literals - import unittest from mantid import UsageService -from mantid.py3compat.mock import patch +from unittest.mock import patch from mantidqt.utils.testing.mocks.mock_qt import MockQWidget from workbench.plugins.exception_handler import exception_logger diff --git a/qt/applications/workbench/workbench/plugins/test/test_jupyterconsole.py b/qt/applications/workbench/workbench/plugins/test/test_jupyterconsole.py index 3b267279d7711caa8095c2e7a430c23ec8d3c008..c5575730891ef8a5e7199f06cb4cabd83f845fe1 100644 --- a/qt/applications/workbench/workbench/plugins/test/test_jupyterconsole.py +++ b/qt/applications/workbench/workbench/plugins/test/test_jupyterconsole.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import) - # system imports import unittest diff --git a/qt/applications/workbench/workbench/plugins/test/test_workspacewidget.py b/qt/applications/workbench/workbench/plugins/test/test_workspacewidget.py index 12ac4b7b71c0975945cbdbd91060d07da731e7ae..800394274f8e30c9cd2a457179214ed0e0b1e1c0 100644 --- a/qt/applications/workbench/workbench/plugins/test/test_workspacewidget.py +++ b/qt/applications/workbench/workbench/plugins/test/test_workspacewidget.py @@ -7,14 +7,12 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division) - import unittest import matplotlib as mpl mpl.use('Agg') # noqa -from mantid.py3compat import mock +from unittest import mock from mantid.simpleapi import (CreateEmptyTableWorkspace, CreateSampleWorkspace, GroupWorkspaces) from mantidqt.utils.qt.testing import start_qapplication diff --git a/qt/applications/workbench/workbench/plugins/workspacewidget.py b/qt/applications/workbench/workbench/plugins/workspacewidget.py index 54a817063e238fe6cd1c503bb60590abaf7c859d..5e3782a33497f778dc57991591af7597b55d5c26 100644 --- a/qt/applications/workbench/workbench/plugins/workspacewidget.py +++ b/qt/applications/workbench/workbench/plugins/workspacewidget.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # # -from __future__ import (absolute_import, unicode_literals) - from functools import partial from qtpy.QtWidgets import QApplication, QMessageBox, QVBoxLayout diff --git a/qt/applications/workbench/workbench/projectrecovery/projectrecovery.py b/qt/applications/workbench/workbench/projectrecovery/projectrecovery.py index 3bd71ff6e5bcb90910ccb7fb7fec0d7f43749624..f6414aa370b500c09edf4a5454518ae3f1203bd5 100644 --- a/qt/applications/workbench/workbench/projectrecovery/projectrecovery.py +++ b/qt/applications/workbench/workbench/projectrecovery/projectrecovery.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import os import shutil import socket diff --git a/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py b/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py index 6ffa0a9ca44c86dcfa54658463ad379961308939..a11b152d4fb55a79ebd4ef955ac7dc63234d9771 100644 --- a/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py +++ b/qt/applications/workbench/workbench/projectrecovery/projectrecoveryloader.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import os from qtpy.QtWidgets import QApplication diff --git a/qt/applications/workbench/workbench/projectrecovery/projectrecoverysaver.py b/qt/applications/workbench/workbench/projectrecovery/projectrecoverysaver.py index 40bfa90c672abc10b95c9bfaf5d0e9060ec26abe..6d449d63fdbb33871e1be6f48f1afdb873d768bc 100644 --- a/qt/applications/workbench/workbench/projectrecovery/projectrecoverysaver.py +++ b/qt/applications/workbench/workbench/projectrecovery/projectrecoverysaver.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import datetime import os from threading import Timer diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverymodel.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverymodel.py index 0d4b442363cbc00130beeb6426cb808990d4ff5b..e6a9a893488521d36a82d6f791955959424c6ca1 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverymodel.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverymodel.py @@ -7,10 +7,7 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import os -import six from qtpy.QtCore import Slot, QObject @@ -59,7 +56,7 @@ class ProjectRecoveryModel(QObject): :return: List of 3 Strings; [0] Checkpoint name, [1] Number of workspaces, [2] Whether checkpoint has been tried or not """ - if isinstance(checkpoint, six.string_types): + if isinstance(checkpoint, str): # Assume if there is a T then it is a checkpoint and it needs to be replaced with a space checkpoint = checkpoint.replace("T", " ") for index in self.rows: diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverypresenter.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverypresenter.py index 87190845e09b2cd23505a23bae8fac148ba2824e..07b413bfe86f4bf1f2356eb125e12d62570b1786 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverypresenter.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverypresenter.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - from workbench.projectrecovery.recoverygui.projectrecoverymodel import ProjectRecoveryModel from workbench.projectrecovery.recoverygui.projectrecoverywidgetview import ProjectRecoveryWidgetView from workbench.projectrecovery.recoverygui.recoveryfailureview import RecoveryFailureView diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverywidgetview.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverywidgetview.py index 1d80cbdd9a22c8f9fabb9b2f865d38cfd4f41036..db0dffdb22081582e46af81e25cadf7efa4ce931 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverywidgetview.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/projectrecoverywidgetview.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Signal, Slot, Qt from qtpy.QtWidgets import QDialog, QHeaderView, QTableWidgetItem diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/recoveryfailureview.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/recoveryfailureview.py index ea28b892ffe8a8fadeb1595c5b0d5f19d7ba8a2e..0d7a670e4e21f955faf20bbd426b21fb93b2c9a1 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/recoveryfailureview.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/recoveryfailureview.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Signal, Slot, Qt from qtpy.QtWidgets import QDialog, QHeaderView, QTableWidgetItem diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverymodel.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverymodel.py index 1fa778efbdcf061c6aa2a681a0acebef251d8be1..713ef87a77a762b7325fe757ed206602c43a6f3c 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverymodel.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverymodel.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import os import shutil import time @@ -17,7 +15,7 @@ import unittest from mantid.api import AnalysisDataService as ADS from mantid.kernel import ConfigService from mantid.simpleapi import CreateSampleWorkspace -from mantid.py3compat import mock +from unittest import mock from workbench.projectrecovery.projectrecovery import ProjectRecovery, NO_OF_CHECKPOINTS_KEY from workbench.projectrecovery.recoverygui.projectrecoverymodel import ProjectRecoveryModel diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverypresenter.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverypresenter.py index 9ac771a46cc9ff06f23bb5f1cf6a0e207f325210..d1870cf8f33f03b6faae16d4a11292b9a3f36325 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverypresenter.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverypresenter.py @@ -7,11 +7,9 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import unittest -from mantid.py3compat import mock +from unittest import mock from workbench.projectrecovery.recoverygui.projectrecoverypresenter import ProjectRecoveryPresenter diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverywidgetview.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverywidgetview.py index fa6aee88220436f7117d3568e3666d71d2549b5b..6c5f8b035c4a38d9611c70cb3166ac3e74d8a6da 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverywidgetview.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_projectrecoverywidgetview.py @@ -7,11 +7,9 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from workbench.projectrecovery.recoverygui.projectrecoverywidgetview import ProjectRecoveryWidgetView diff --git a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_recoveryfailureview.py b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_recoveryfailureview.py index c9601cbe8f2380d415f4e0ecea5405c162e1b603..2f443db90b9ee5c519d8165fbb856a0a34991b4a 100644 --- a/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_recoveryfailureview.py +++ b/qt/applications/workbench/workbench/projectrecovery/recoverygui/test/test_recoveryfailureview.py @@ -7,13 +7,11 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import unittest from qtpy.QtWidgets import QTableWidgetItem -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from workbench.projectrecovery.recoverygui.recoveryfailureview import RecoveryFailureView diff --git a/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecovery.py b/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecovery.py index 88d5e895516a66a8c20dd730586ce4cb8c3bb519..eb5d56e0c07507df5c22e4e0783862bf0a1b8535 100644 --- a/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecovery.py +++ b/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecovery.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import os import shutil import socket @@ -20,7 +18,7 @@ import datetime from mantid.api import AnalysisDataService as ADS from mantid.kernel import ConfigService -from mantid.py3compat import mock +from unittest import mock from workbench.projectrecovery.projectrecovery import ProjectRecovery, SAVING_TIME_KEY, NO_OF_CHECKPOINTS_KEY, \ RECOVERY_ENABLED_KEY diff --git a/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoveryloader.py b/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoveryloader.py index 6ad9ca74a3c56b37c4f30741105a3a88b7b4eaf4..5c964f38073148d129e0aa5784242dab56520cc0 100644 --- a/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoveryloader.py +++ b/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoveryloader.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import os import shutil import sys @@ -16,7 +14,7 @@ import tempfile import unittest from mantid.api import AnalysisDataService as ADS -from mantid.py3compat import mock +from unittest import mock from mantid.simpleapi import CreateSampleWorkspace from mantidqt.utils.testing.strict_mock import StrictContextManagerMock diff --git a/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoverysaver.py b/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoverysaver.py index 50dd04418d73a5e2d6c43b31e62bb2d842e7777a..1f3ecd7ddb7f1d5cef0f371e662d987a75168c7e 100644 --- a/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoverysaver.py +++ b/qt/applications/workbench/workbench/projectrecovery/test/test_projectrecoverysaver.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - import json import os import shutil @@ -18,7 +16,7 @@ import unittest from mantid.api import AnalysisDataService as ADS from mantid.simpleapi import CreateSampleWorkspace, GroupWorkspaces -from mantid.py3compat import mock +from unittest import mock from workbench.projectrecovery.projectrecovery import ProjectRecovery if sys.version_info.major >= 3: diff --git a/qt/applications/workbench/workbench/requirements.py b/qt/applications/workbench/workbench/requirements.py index a695991d216800cd39c72562896a54ff778e79fe..47dade02d6552c091e8e24ce991c99567c71ac41 100644 --- a/qt/applications/workbench/workbench/requirements.py +++ b/qt/applications/workbench/workbench/requirements.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + """Defines methods to check requirements for the application """ -from __future__ import absolute_import - from distutils.version import LooseVersion diff --git a/qt/applications/workbench/workbench/test/mainwindowtest.py b/qt/applications/workbench/workbench/test/mainwindowtest.py index 3c2cd0b2a36672f02627077b43bc2c9e71ff7215..5373ee24bbe237b119a079e74ac4d80a6509dbb3 100644 --- a/qt/applications/workbench/workbench/test/mainwindowtest.py +++ b/qt/applications/workbench/workbench/test/mainwindowtest.py @@ -10,11 +10,9 @@ """ Defines the QMainWindow of the application and the main() entry point. """ -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest -from mantid.py3compat.mock import patch +from unittest.mock import patch from workbench.app.mainwindow import MainWindow diff --git a/qt/applications/workbench/workbench/test/test_import.py b/qt/applications/workbench/workbench/test/test_import.py index ee6db74c54a86081f520e9ec4e7822724e6731c6..2ebd5ef463a2389d4394671c5cf95c3fa1bea373 100644 --- a/qt/applications/workbench/workbench/test/test_import.py +++ b/qt/applications/workbench/workbench/test/test_import.py @@ -7,8 +7,7 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + import unittest diff --git a/qt/applications/workbench/workbench/utils/test/windowfindertest.py b/qt/applications/workbench/workbench/utils/test/windowfindertest.py index f9ac6f7b92656171eca11c87366b48b228170820..8cc1a5e005a139fa2228248fda2541cc16687b5b 100644 --- a/qt/applications/workbench/workbench/utils/test/windowfindertest.py +++ b/qt/applications/workbench/workbench/utils/test/windowfindertest.py @@ -10,8 +10,6 @@ """ Defines the QMainWindow of the application and the main() entry point. """ -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from workbench.app.mainwindow import MainWindow diff --git a/qt/applications/workbench/workbench/utils/windowfinder.py b/qt/applications/workbench/workbench/utils/windowfinder.py index cd60ad7a56bba68890976531c857bf7855516ce1..eb40b707beff6a23920b1d5ac4aabf8210c91275 100644 --- a/qt/applications/workbench/workbench/utils/windowfinder.py +++ b/qt/applications/workbench/workbench/utils/windowfinder.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - from qtpy.QtWidgets import QApplication from mantidqt.project.encoderfactory import EncoderFactory diff --git a/qt/applications/workbench/workbench/utils/workspacehistorygeneration.py b/qt/applications/workbench/workbench/utils/workspacehistorygeneration.py index 71270b07c6a01ad913389b5e94dda12e44bfec4f..cf0b3187da6de2ebce386b020a67a5e4efb628ef 100644 --- a/qt/applications/workbench/workbench/utils/workspacehistorygeneration.py +++ b/qt/applications/workbench/workbench/utils/workspacehistorygeneration.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidworkbench package -import six from mantid.api import AlgorithmManager, AnalysisDataService as ADS from workbench.projectrecovery.projectrecoverysaver import ALGS_TO_IGNORE, ALG_PROPERTIES_TO_IGNORE @@ -36,7 +35,7 @@ def get_workspace_history_list(workspace): def convert_list_to_string(to_convert, add_new_line=True, fix_comments=False): string = "" for line in to_convert: - if isinstance(line, six.string_types): + if isinstance(line, str): string += line elif fix_comments and isinstance(line, tuple): string += line[0] diff --git a/qt/applications/workbench/workbench/widgets/plotselector/model.py b/qt/applications/workbench/workbench/widgets/plotselector/model.py index 8a9824d7669cb70c08a700fe8199b48a7271209a..e172968e92c0157bb74bce5d53168eacdff3d160 100644 --- a/qt/applications/workbench/workbench/widgets/plotselector/model.py +++ b/qt/applications/workbench/workbench/widgets/plotselector/model.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, print_function - from workbench.plotting.globalfiguremanager import FigureAction diff --git a/qt/applications/workbench/workbench/widgets/plotselector/presenter.py b/qt/applications/workbench/workbench/widgets/plotselector/presenter.py index ae58ca8efbee6ad881bea863e7e7c784daacc4ce..cafb3f897c827d3725e998a85a86adec67166c2a 100644 --- a/qt/applications/workbench/workbench/widgets/plotselector/presenter.py +++ b/qt/applications/workbench/workbench/widgets/plotselector/presenter.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, print_function - import os import re diff --git a/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_model.py b/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_model.py index 00c53750415967b83630ce8c91249cf5d0e0ad45..781ba002958b166020ec396b2ef4bbb5dbcda001 100644 --- a/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_model.py +++ b/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_model.py @@ -7,11 +7,9 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, division, print_function - import unittest -from mantid.py3compat import mock +from unittest import mock from workbench.plotting.globalfiguremanager import FigureAction from workbench.widgets.plotselector.model import PlotSelectorModel from workbench.widgets.plotselector.presenter import PlotSelectorPresenter diff --git a/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_presenter.py b/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_presenter.py index c1cc8e2e4ab5455a19f2fe1e5567a70c877284ab..1615401b2e6f0ae34d16e1ea8932956266ccd332 100644 --- a/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_presenter.py +++ b/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_presenter.py @@ -7,12 +7,10 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, division, print_function - import os import unittest -from mantid.py3compat import mock +from unittest import mock from workbench.widgets.plotselector.model import PlotSelectorModel from workbench.widgets.plotselector.presenter import PlotSelectorPresenter from workbench.widgets.plotselector.view import PlotSelectorView, Column diff --git a/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_view.py b/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_view.py index d413a60e1a5a134a9564816835be6079f78f70f1..acf545aa5d2b1947262cb822794cea930173790a 100644 --- a/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_view.py +++ b/qt/applications/workbench/workbench/widgets/plotselector/test/test_plotselector_view.py @@ -7,14 +7,12 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, division, print_function - from qtpy.QtCore import Qt from qtpy.QtGui import QIcon from qtpy.QtTest import QTest import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from workbench.widgets.plotselector.presenter import PlotSelectorPresenter from workbench.widgets.plotselector.view import EXPORT_TYPES, PlotSelectorView, Column diff --git a/qt/applications/workbench/workbench/widgets/plotselector/view.py b/qt/applications/workbench/workbench/widgets/plotselector/view.py index 9f7c32e2e1abf5f769b659747a3e0b65e8921204..667bb57155c8fd67db2ef80ffa45212ae2efd92a 100644 --- a/qt/applications/workbench/workbench/widgets/plotselector/view.py +++ b/qt/applications/workbench/workbench/widgets/plotselector/view.py @@ -7,14 +7,12 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, print_function - import re from qtpy.QtCore import Qt, Signal, QMutex, QMutexLocker from qtpy.QtWidgets import (QAbstractItemView, QAction, QActionGroup, QFileDialog, QHBoxLayout, QHeaderView, QLineEdit, QMenu, QPushButton, QTableWidget, QTableWidgetItem, QVBoxLayout, QWidget) -from mantid.py3compat.enum import IntEnum +from enum import IntEnum from mantidqt.icons import get_icon from mantidqt.utils.flowlayout import FlowLayout diff --git a/qt/applications/workbench/workbench/widgets/settings/categories/presenter.py b/qt/applications/workbench/workbench/widgets/settings/categories/presenter.py index 8071f360fcc4c109a9fb73f00743aed9c7dab78e..e0efb728e115de26f7899f22f4b72d3d759ea924 100644 --- a/qt/applications/workbench/workbench/widgets/settings/categories/presenter.py +++ b/qt/applications/workbench/workbench/widgets/settings/categories/presenter.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench # # -from __future__ import absolute_import, unicode_literals - from mantid.api import AlgorithmFactory from mantid.kernel import ConfigService from workbench.widgets.settings.categories.view import CategoriesSettingsView diff --git a/qt/applications/workbench/workbench/widgets/settings/categories/test/test_categories_settings.py b/qt/applications/workbench/workbench/widgets/settings/categories/test/test_categories_settings.py index 0b06caf05642f06475fe59cbc85a0981c66f2024..ce3021ee42b1af552a062da7f00f4ea4d5918013 100644 --- a/qt/applications/workbench/workbench/widgets/settings/categories/test/test_categories_settings.py +++ b/qt/applications/workbench/workbench/widgets/settings/categories/test/test_categories_settings.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - import unittest -from mantid.py3compat.mock import call, Mock, patch, ANY +from unittest.mock import call, Mock, patch, ANY from mantidqt.utils.qt.testing import start_qapplication from mantidqt.utils.testing.mocks.mock_qt import MockQWidget from mantidqt.utils.testing.strict_mock import StrictMock diff --git a/qt/applications/workbench/workbench/widgets/settings/categories/view.py b/qt/applications/workbench/workbench/widgets/settings/categories/view.py index 3b38e107e8c2189d3dc07e81ad85583462ee1e63..e10e2f3d7e59a319fab06d2c0a105f1c6ae890b6 100644 --- a/qt/applications/workbench/workbench/widgets/settings/categories/view.py +++ b/qt/applications/workbench/workbench/widgets/settings/categories/view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - from qtpy.QtCore import Qt from qtpy.QtWidgets import QTreeWidgetItem diff --git a/qt/applications/workbench/workbench/widgets/settings/fitting/presenter.py b/qt/applications/workbench/workbench/widgets/settings/fitting/presenter.py index a674816ec97b256dde4b108756134f199eed4ca3..dadc238455034d05a8c6f0fa99f6f8839cb1f845 100644 --- a/qt/applications/workbench/workbench/widgets/settings/fitting/presenter.py +++ b/qt/applications/workbench/workbench/widgets/settings/fitting/presenter.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench # # -from __future__ import absolute_import, unicode_literals - from mantid.api import FunctionFactory from mantid.kernel import ConfigService from workbench.widgets.settings.fitting.view import FittingSettingsView diff --git a/qt/applications/workbench/workbench/widgets/settings/fitting/test/test_fitting_settings.py b/qt/applications/workbench/workbench/widgets/settings/fitting/test/test_fitting_settings.py index d0c762435d808ebccfcf243b098ddb71f08c72e8..3e17e10da48ce9ac741deb61b60b82114e609f46 100644 --- a/qt/applications/workbench/workbench/widgets/settings/fitting/test/test_fitting_settings.py +++ b/qt/applications/workbench/workbench/widgets/settings/fitting/test/test_fitting_settings.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - import unittest -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantidqt.utils.qt.testing import start_qapplication from mantidqt.utils.testing.strict_mock import StrictMock from workbench.widgets.settings.fitting.presenter import FittingSettings diff --git a/qt/applications/workbench/workbench/widgets/settings/fitting/view.py b/qt/applications/workbench/workbench/widgets/settings/fitting/view.py index b1b34c71bf00fce150405ded5f2115e4a1cc24ec..e1782b8d70983e6cef90b9d8efb1f5c90db2bfa3 100644 --- a/qt/applications/workbench/workbench/widgets/settings/fitting/view.py +++ b/qt/applications/workbench/workbench/widgets/settings/fitting/view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - from qtpy.QtCore import Qt from mantidqt.utils.qt import load_ui diff --git a/qt/applications/workbench/workbench/widgets/settings/general/presenter.py b/qt/applications/workbench/workbench/widgets/settings/general/presenter.py index d978f76115c497137e56c38ca720bae35e2d5bea..a40bab6af100dc698dc32e1d6cb93c54d92beacc 100644 --- a/qt/applications/workbench/workbench/widgets/settings/general/presenter.py +++ b/qt/applications/workbench/workbench/widgets/settings/general/presenter.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench # # -from __future__ import absolute_import, unicode_literals - from mantid.kernel import ConfigService from workbench.config import CONF from workbench.widgets.settings.general.view import GeneralSettingsView diff --git a/qt/applications/workbench/workbench/widgets/settings/general/test/test_general_settings.py b/qt/applications/workbench/workbench/widgets/settings/general/test/test_general_settings.py index ffc88ebd93ff5e9a39c689aab1dfe775f17fd3c5..4836ef1318f7de5da689ecd9652d3c60ff42b2cb 100644 --- a/qt/applications/workbench/workbench/widgets/settings/general/test/test_general_settings.py +++ b/qt/applications/workbench/workbench/widgets/settings/general/test/test_general_settings.py @@ -5,12 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - import unittest import sys -from mantid.py3compat.mock import call, patch, MagicMock, Mock +from unittest.mock import call, patch, MagicMock, Mock from mantidqt.utils.qt.testing import start_qapplication from mantidqt.utils.testing.strict_mock import StrictMock from workbench.widgets.settings.general.presenter import GeneralSettings diff --git a/qt/applications/workbench/workbench/widgets/settings/general/view.py b/qt/applications/workbench/workbench/widgets/settings/general/view.py index 37dee2ea68d2af805ed17a746a1016f25b0035f8..e740ff56c44d3e17a7891dad8e9c472302d1a97f 100644 --- a/qt/applications/workbench/workbench/widgets/settings/general/view.py +++ b/qt/applications/workbench/workbench/widgets/settings/general/view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - from qtpy.QtCore import Qt from qtpy.QtWidgets import QFontDialog diff --git a/qt/applications/workbench/workbench/widgets/settings/plots/presenter.py b/qt/applications/workbench/workbench/widgets/settings/plots/presenter.py index d14e3dc071540e9c02f26df4fbce426005326fd2..644082ca0857ae5897c32cb766815c93e0d939d6 100644 --- a/qt/applications/workbench/workbench/widgets/settings/plots/presenter.py +++ b/qt/applications/workbench/workbench/widgets/settings/plots/presenter.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench # # -from __future__ import absolute_import, unicode_literals - from mantid.kernel import ConfigService from workbench.widgets.settings.plots.view import PlotsSettingsView from workbench.plotting.style import VALID_LINE_STYLE diff --git a/qt/applications/workbench/workbench/widgets/settings/plots/test/test_plot_settings.py b/qt/applications/workbench/workbench/widgets/settings/plots/test/test_plot_settings.py index 4e620ea673e41ad289eceab1498b17d69fc0a8ea..27e9deb552afff78986a8f0ac64bcccef3bce30b 100644 --- a/qt/applications/workbench/workbench/widgets/settings/plots/test/test_plot_settings.py +++ b/qt/applications/workbench/workbench/widgets/settings/plots/test/test_plot_settings.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - import unittest -from mantid.py3compat.mock import call, patch +from unittest.mock import call, patch from mantidqt.utils.qt.testing import start_qapplication from mantidqt.utils.testing.strict_mock import StrictMock from workbench.widgets.settings.plots.presenter import PlotSettings diff --git a/qt/applications/workbench/workbench/widgets/settings/plots/view.py b/qt/applications/workbench/workbench/widgets/settings/plots/view.py index 3825049b5ab5780e09046b519f31c16798a97034..4191bbbe09805448e84821ff759ecc8da77667fd 100644 --- a/qt/applications/workbench/workbench/widgets/settings/plots/view.py +++ b/qt/applications/workbench/workbench/widgets/settings/plots/view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - from qtpy.QtCore import Qt from mantidqt.utils.qt import load_ui diff --git a/qt/applications/workbench/workbench/widgets/settings/presenter.py b/qt/applications/workbench/workbench/widgets/settings/presenter.py index 9d0ca53319953b247e5270b1c7121865e0f362e4..ef12d81f791d088a383b471d91b06ee91f766076 100644 --- a/qt/applications/workbench/workbench/widgets/settings/presenter.py +++ b/qt/applications/workbench/workbench/widgets/settings/presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from mantid import ConfigService diff --git a/qt/applications/workbench/workbench/widgets/settings/test/test_settings_presenter.py b/qt/applications/workbench/workbench/widgets/settings/test/test_settings_presenter.py index 1e84dec45b2647aa40978f2e0c59f4cb1d01ff57..967317b8792b7c8e7fbe4003ab25d61f2c62fac2 100644 --- a/qt/applications/workbench/workbench/widgets/settings/test/test_settings_presenter.py +++ b/qt/applications/workbench/workbench/widgets/settings/test/test_settings_presenter.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - from unittest import TestCase -from mantid.py3compat.mock import call, Mock +from unittest.mock import call, Mock from mantidqt.utils.testing.mocks.mock_qt import MockQButton, MockQWidget from mantidqt.utils.testing.strict_mock import StrictPropertyMock from workbench.widgets.settings.presenter import SettingsPresenter diff --git a/qt/applications/workbench/workbench/widgets/settings/test/test_settings_view.py b/qt/applications/workbench/workbench/widgets/settings/test/test_settings_view.py index 181b5935650dd9e9f8210b4ae8b043fba397ab23..ffa1244fccc6f5f4f5667b31fa0651e542e65d8b 100644 --- a/qt/applications/workbench/workbench/widgets/settings/test/test_settings_view.py +++ b/qt/applications/workbench/workbench/widgets/settings/test/test_settings_view.py @@ -5,13 +5,11 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - import unittest from qtpy.QtWidgets import QApplication, QWidget -from mantid.py3compat.mock import MagicMock +from unittest.mock import MagicMock from mantidqt.utils.qt.testing import start_qapplication from mantidqt.utils.qt.testing.qt_widget_finder import QtWidgetFinder from workbench.widgets.settings.presenter import SettingsPresenter diff --git a/qt/applications/workbench/workbench/widgets/settings/view.py b/qt/applications/workbench/workbench/widgets/settings/view.py index 68a36a91350b1265065114bbcab6cc3b5eacf3ed..a4431b901a8234d7232fa7a0b8ba079d2c7eee50 100644 --- a/qt/applications/workbench/workbench/widgets/settings/view.py +++ b/qt/applications/workbench/workbench/widgets/settings/view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench -from __future__ import absolute_import, unicode_literals - from qtpy.QtCore import Qt from qtpy.QtWidgets import QMessageBox diff --git a/qt/icons/inc/MantidQtIcons/CharIconEngine.h b/qt/icons/inc/MantidQtIcons/CharIconEngine.h index efd7962da46b73eb4e628d6cb06138a56c844cfc..9002cae11d94b2657863db43d35e8e084eb42bca 100644 --- a/qt/icons/inc/MantidQtIcons/CharIconEngine.h +++ b/qt/icons/inc/MantidQtIcons/CharIconEngine.h @@ -35,7 +35,7 @@ class CharIconPainter; class EXPORT_OPT_MANTIDQT_ICONS CharIconEngine : public QIconEngine { public: CharIconEngine(IconicFont *iconic, CharIconPainter *painter, - QList<QHash<QString, QVariant>> options); + const QList<QHash<QString, QVariant>> &options); void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; QPixmap pixmap(const QSize &size, QIcon::Mode mode, diff --git a/qt/icons/src/CharIconEngine.cpp b/qt/icons/src/CharIconEngine.cpp index adbd38b437a23cd4c07c4a970b2cc41b10455c49..40fa6670bfd65967150016fd6a4ce60f2e7ebf6d 100644 --- a/qt/icons/src/CharIconEngine.cpp +++ b/qt/icons/src/CharIconEngine.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtIcons/CharIconEngine.h" #include "MantidQtIcons/CharIconPainter.h" @@ -11,8 +13,8 @@ namespace MantidQt { namespace Icons { CharIconEngine::CharIconEngine(IconicFont *iconic, CharIconPainter *painter, - QList<QHash<QString, QVariant>> options) - : m_iconic(iconic), m_painter(painter), m_options(options) {} + const QList<QHash<QString, QVariant>> &options) + : m_iconic(iconic), m_painter(painter), m_options(std::move(options)) {} void CharIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { diff --git a/qt/icons/src/Icon.cpp b/qt/icons/src/Icon.cpp index 1ef2f925b6834412bb92576805faa16ed151269b..0bc0293ad1274649f01df25aa05b2bc192f96db2 100644 --- a/qt/icons/src/Icon.cpp +++ b/qt/icons/src/Icon.cpp @@ -31,7 +31,7 @@ MantidQt::Icons::IconicFont &iconFontInstance() { // https://stackoverflow.com/questions/4169988/easiest-way-to-parse-json-in-qt-4-7 // specifically in the answer by user2243820 on April 4th 2013 at 8:10 -QHash<QString, QVariant> decodeInner(QScriptValue object) { +QHash<QString, QVariant> decodeInner(const QScriptValue &object) { QHash<QString, QVariant> map; QScriptValueIterator it(object); while (it.hasNext()) { diff --git a/qt/python/mantidqt/MPLwidgets.py b/qt/python/mantidqt/MPLwidgets.py index f28eb9bdabed10d6790dbc3b425cf0216048af4d..cf1435a64307de38587eba3d515067df542d775b 100644 --- a/qt/python/mantidqt/MPLwidgets.py +++ b/qt/python/mantidqt/MPLwidgets.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from .gui_helper import set_matplotlib_backend backend = set_matplotlib_backend() # must be at the top of this file diff --git a/qt/python/mantidqt/algorithminputhistory.py b/qt/python/mantidqt/algorithminputhistory.py index c95a5f67a4177d34a738652010115a075ed705a2..4132de0cdc125ed944e7fa22aa9da1e9a7fe6007 100644 --- a/qt/python/mantidqt/algorithminputhistory.py +++ b/qt/python/mantidqt/algorithminputhistory.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt, toQSettings diff --git a/qt/python/mantidqt/dialogs/algorithmdialog.py b/qt/python/mantidqt/dialogs/algorithmdialog.py index 42f9d3a2812db697a327eb7651143ee415564d74..533efdaa6f6333772f11aba77b7462dc9b630452 100644 --- a/qt/python/mantidqt/dialogs/algorithmdialog.py +++ b/qt/python/mantidqt/dialogs/algorithmdialog.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/dialogs/genericdialog.py b/qt/python/mantidqt/dialogs/genericdialog.py index 94d24f2e31c0ce62a3fca4dfad4690ee39dcb02d..1e29fadc9a16c6be41f073054d2e3193558dc84f 100644 --- a/qt/python/mantidqt/dialogs/genericdialog.py +++ b/qt/python/mantidqt/dialogs/genericdialog.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/dialogs/spectraselectordialog.py b/qt/python/mantidqt/dialogs/spectraselectordialog.py index 543aa7bd54dfee03b182171bd9ecaae39e61f7d9..268623e1f8dd5fdd8c2fb44ee3aaf6090a38cf05 100644 --- a/qt/python/mantidqt/dialogs/spectraselectordialog.py +++ b/qt/python/mantidqt/dialogs/spectraselectordialog.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtGui import QIcon from qtpy.QtWidgets import QDialogButtonBox, QMessageBox diff --git a/qt/python/mantidqt/dialogs/test/__init__.py b/qt/python/mantidqt/dialogs/test/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/dialogs/test/__init__.py +++ b/qt/python/mantidqt/dialogs/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/dialogs/test/test_spectraselectiondialog.py b/qt/python/mantidqt/dialogs/test/test_spectraselectiondialog.py index e4a125f39fd6f7be656f047699ba9459c96d325c..b42fac458c220ee29d29b1a7e7438cdbf270e790 100644 --- a/qt/python/mantidqt/dialogs/test/test_spectraselectiondialog.py +++ b/qt/python/mantidqt/dialogs/test/test_spectraselectiondialog.py @@ -10,7 +10,7 @@ from qtpy.QtGui import QIcon from qtpy.QtWidgets import QDialogButtonBox from mantid.api import WorkspaceFactory -from mantid.py3compat import mock +from unittest import mock from mantid.simpleapi import ExtractSpectra from mantidqt.dialogs import spectraselectordialog from mantidqt.dialogs.spectraselectordialog import parse_selection_str, SpectraSelectionDialog diff --git a/qt/python/mantidqt/dialogs/test/test_spectraselectorutils.py b/qt/python/mantidqt/dialogs/test/test_spectraselectorutils.py index 7511ec7faffeee90da3eef12d01be562569c3e61..37a00369405c5d7a7220f52149fd9fc6e949e975 100644 --- a/qt/python/mantidqt/dialogs/test/test_spectraselectorutils.py +++ b/qt/python/mantidqt/dialogs/test/test_spectraselectorutils.py @@ -5,12 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - import unittest from mantid.api import WorkspaceFactory -from mantid.py3compat import mock +from unittest import mock from mantid.simpleapi import ExtractSpectra from mantidqt.dialogs.spectraselectorutils import get_spectra_selection from mantidqt.utils.qt.testing import start_qapplication diff --git a/qt/python/mantidqt/gui_helper.py b/qt/python/mantidqt/gui_helper.py index 8c5c79c88265855eead6fe5fc194271d79436dd5..fbca12f7572d72f6cdff5aa31b5e7577ce770604 100644 --- a/qt/python/mantidqt/gui_helper.py +++ b/qt/python/mantidqt/gui_helper.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QApplication) # noqa from qtpy import QtCore, QtGui import matplotlib diff --git a/qt/python/mantidqt/hint.py b/qt/python/mantidqt/hint.py index c9a518338a64248f874d3298162f50174f951322..cfbe8fc4a67ab8ec3c97517a8f18bf7b2d380b29 100644 --- a/qt/python/mantidqt/hint.py +++ b/qt/python/mantidqt/hint.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt Hint = import_qt('._common', 'mantidqt', 'Hint') diff --git a/qt/python/mantidqt/icons/__init__.py b/qt/python/mantidqt/icons/__init__.py index 2c651b80a4fa0852ea1744323a7e340d54ad9506..963438d8cf778c35e5ef1790fd60f7c247c146a6 100644 --- a/qt/python/mantidqt/icons/__init__.py +++ b/qt/python/mantidqt/icons/__init__.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt get_icon = import_qt('._icons', 'mantidqt.icons', 'getIcon') diff --git a/qt/python/mantidqt/icons/test/test_icons.py b/qt/python/mantidqt/icons/test/test_icons.py index aea93d1a5b9ad6999d814649ae73b5842525110f..b6317343dd7fa6b59d390c05c39a2ee09ad7e4a8 100644 --- a/qt/python/mantidqt/icons/test/test_icons.py +++ b/qt/python/mantidqt/icons/test/test_icons.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantidqt.icons import get_icon diff --git a/qt/python/mantidqt/interfacemanager.py b/qt/python/mantidqt/interfacemanager.py index 199cb4f8c90e72da1eb6d98b662cd48ab0765d92..123920569122e5f9a30749b7c86760b9d3f5d16e 100644 --- a/qt/python/mantidqt/interfacemanager.py +++ b/qt/python/mantidqt/interfacemanager.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/plotting/figuretype.py b/qt/python/mantidqt/plotting/figuretype.py index d2576f307f2f316db1cba1e87b3146a98a604722..b1590a40103110d843f13380f898498d8f618d9c 100644 --- a/qt/python/mantidqt/plotting/figuretype.py +++ b/qt/python/mantidqt/plotting/figuretype.py @@ -10,8 +10,6 @@ """ Provides facilities to check plot types """ -from __future__ import absolute_import - # third party from enum import Enum from matplotlib.container import ErrorbarContainer diff --git a/qt/python/mantidqt/plotting/functions.py b/qt/python/mantidqt/plotting/functions.py index 71f85df551006bfe6456286c24e026de33149de0..6be1029037a8bf881f643bf294399a838abbf916 100644 --- a/qt/python/mantidqt/plotting/functions.py +++ b/qt/python/mantidqt/plotting/functions.py @@ -162,6 +162,10 @@ def pcolormesh(workspaces, fig=None): if subplot_idx < workspaces_len: ws = workspaces[subplot_idx] pcm = pcolormesh_on_axis(ax, ws) + if pcm: # Colour bar limits are wrong if workspace is ragged. Set them manually. + colorbar_min = np.nanmin(pcm.get_array()) + colorbar_max = np.nanmax(pcm.get_array()) + pcm.set_clim(colorbar_min, colorbar_max) if col_idx < ncols - 1: col_idx += 1 else: diff --git a/qt/python/mantidqt/plotting/test/test_functions.py b/qt/python/mantidqt/plotting/test/test_functions.py index 6dcd7c66a005a2b2c6bb62b31eed3ea5d26e949c..e24c7a0d88d7852c2aa9011ba31b1ba0e0f9892b 100644 --- a/qt/python/mantidqt/plotting/test/test_functions.py +++ b/qt/python/mantidqt/plotting/test/test_functions.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - # std imports from unittest import TestCase, main @@ -23,9 +21,10 @@ import numpy as np # register mantid projection import mantid.plots # noqa from mantid.api import AnalysisDataService, WorkspaceFactory +from mantid.simpleapi import CreateWorkspace from mantid.kernel import config from mantid.plots import MantidAxes -from mantid.py3compat import mock +from unittest import mock from mantidqt.dialogs.spectraselectordialog import SpectraSelection from mantidqt.plotting.functions import (can_overplot, current_figure_or_none, figure_title, manage_workspace_names, plot, plot_from_names, @@ -151,6 +150,11 @@ class FunctionsTest(TestCase): pcolormesh_from_names([ws_name]) self.assertEqual(1, pcolormesh_mock.call_count) + def test_scale_is_correct_on_pcolourmesh_of_ragged_workspace(self): + ws = CreateWorkspace(DataX=[1, 2, 3, 4, 2, 4, 6, 8], DataY=[2] * 8, NSpec=2) + fig = pcolormesh_from_names([ws]) + self.assertEqual((1.8, 2.2), fig.axes[0].images[0].get_clim()) + def test_pcolormesh_from_names(self): ws_name = 'test_pcolormesh_from_names-1' AnalysisDataService.Instance().addOrReplace(ws_name, self._test_ws) diff --git a/qt/python/mantidqt/plotting/test/test_tiledplots.py b/qt/python/mantidqt/plotting/test/test_tiledplots.py index cd2c6e2856ac42311175642ec02a35f0ac52d725..21c68ca124aa51b10427aa7da4a1731cfcb79fe5 100644 --- a/qt/python/mantidqt/plotting/test/test_tiledplots.py +++ b/qt/python/mantidqt/plotting/test/test_tiledplots.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - # std imports from unittest import TestCase, main @@ -22,7 +20,7 @@ from matplotlib import _pylab_helpers # register mantid projection import mantid.plots # noqa from mantid.api import AnalysisDataService, WorkspaceFactory -from mantid.py3compat import mock +from unittest import mock from mantidqt.dialogs.spectraselectordialog import SpectraSelection from mantid.plots.plotfunctions import manage_workspace_names, get_plot_fig from mantidqt.plotting.functions import plot_from_names diff --git a/qt/python/mantidqt/project/basedecoder.py b/qt/python/mantidqt/project/basedecoder.py index e5da77ba147f28305cfeb78db9bc4e88b44f1324..0f13d26817dd589af36d45c116b4bc2ca65aa482 100644 --- a/qt/python/mantidqt/project/basedecoder.py +++ b/qt/python/mantidqt/project/basedecoder.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - from mantidqt.utils.qt import import_qt BaseDecoder = import_qt('._common', 'mantidqt', 'BaseDecoder') diff --git a/qt/python/mantidqt/project/baseencoder.py b/qt/python/mantidqt/project/baseencoder.py index ba1426a0d598137ad67e006d68a73df6602bf4c3..fa61ae7388604f52762b361d763b9b27f068c654 100644 --- a/qt/python/mantidqt/project/baseencoder.py +++ b/qt/python/mantidqt/project/baseencoder.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - from mantidqt.utils.qt import import_qt BaseEncoder = import_qt('._common', 'mantidqt', 'BaseEncoder') diff --git a/qt/python/mantidqt/project/decoderfactory.py b/qt/python/mantidqt/project/decoderfactory.py index d1d80f5df93c9a545f44c0631d77a679c0e446d1..e96800297a2ef9a9f27652368f7924fe2a5c573a 100644 --- a/qt/python/mantidqt/project/decoderfactory.py +++ b/qt/python/mantidqt/project/decoderfactory.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - from mantidqt.usersubwindowfactory import UserSubWindowFactory diff --git a/qt/python/mantidqt/project/encoderfactory.py b/qt/python/mantidqt/project/encoderfactory.py index 1cb5b0426a88af36956397670a77684f1e0483ee..c7718d7ea3f6f32468b6049b512fc38951c80dda 100644 --- a/qt/python/mantidqt/project/encoderfactory.py +++ b/qt/python/mantidqt/project/encoderfactory.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - from mantidqt.usersubwindowfactory import UserSubWindowFactory diff --git a/qt/python/mantidqt/project/plotsloader.py b/qt/python/mantidqt/project/plotsloader.py index 4b94e6fb50e0f0e9cedaf0c84081ee18d8d44f1c..83d8be21902f6092e2a61bdd36df991323e34ce7 100644 --- a/qt/python/mantidqt/project/plotsloader.py +++ b/qt/python/mantidqt/project/plotsloader.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import copy import matplotlib.axes import matplotlib.cm as cm diff --git a/qt/python/mantidqt/project/plotssaver.py b/qt/python/mantidqt/project/plotssaver.py index 35c8f515006805ffbb855b5e4d16c69c2db5673e..81b97cfb8a6c1600daf0560621dc39e80b26b393 100644 --- a/qt/python/mantidqt/project/plotssaver.py +++ b/qt/python/mantidqt/project/plotssaver.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import matplotlib.axis from matplotlib import ticker from matplotlib.image import AxesImage diff --git a/qt/python/mantidqt/project/project.py b/qt/python/mantidqt/project/project.py index ad6479ca6781a072e13bcfeded9cc08537e8ef5c..69b99364abecac623402022c6c469897c5150af3 100644 --- a/qt/python/mantidqt/project/project.py +++ b/qt/python/mantidqt/project/project.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import os from qtpy.QtWidgets import QApplication, QFileDialog, QMessageBox diff --git a/qt/python/mantidqt/project/projectloader.py b/qt/python/mantidqt/project/projectloader.py index ddbeb37fdf1a788427764a9a8d2c4b513811d8a1..20ff31c7eb7d84160f6aa20fa097afa6f2fef0cc 100644 --- a/qt/python/mantidqt/project/projectloader.py +++ b/qt/python/mantidqt/project/projectloader.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import json import os import re diff --git a/qt/python/mantidqt/project/projectsaver.py b/qt/python/mantidqt/project/projectsaver.py index 1e776b4d9e3d28315cdf8dfcefc6c78a139e9eea..8f7ad52d68616f14537e88f19bf910e10d34f792 100644 --- a/qt/python/mantidqt/project/projectsaver.py +++ b/qt/python/mantidqt/project/projectsaver.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import os from json import dump diff --git a/qt/python/mantidqt/project/test/test_decoderfactory.py b/qt/python/mantidqt/project/test/test_decoderfactory.py index 6310b24af6cfd1106dc1eb11cb80017afca3909c..a56e0b33877cdb7211936838139a4493859a9dc7 100644 --- a/qt/python/mantidqt/project/test/test_decoderfactory.py +++ b/qt/python/mantidqt/project/test/test_decoderfactory.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantidqt.project.decoderfactory import DecoderFactory diff --git a/qt/python/mantidqt/project/test/test_encoderfactory.py b/qt/python/mantidqt/project/test/test_encoderfactory.py index 86b4503dc51bf676284d876025820bb0f9885836..4a202d2e17734b3072c36f327bd4c15a6dc0987f 100644 --- a/qt/python/mantidqt/project/test/test_encoderfactory.py +++ b/qt/python/mantidqt/project/test/test_encoderfactory.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantidqt.project.encoderfactory import EncoderFactory diff --git a/qt/python/mantidqt/project/test/test_plotsloader.py b/qt/python/mantidqt/project/test/test_plotsloader.py index 68ed084547a8ec332deb12bfbe48a70fe386cf8d..b0cf4ca42fb819007cb90038385bc92a84b4c4b1 100644 --- a/qt/python/mantidqt/project/test/test_plotsloader.py +++ b/qt/python/mantidqt/project/test/test_plotsloader.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import matplotlib matplotlib.use('AGG') @@ -20,7 +18,7 @@ from mantidqt.project.plotsloader import PlotsLoader # noqa import mantid.plots.axesfunctions # noqa from mantid.api import AnalysisDataService as ADS # noqa from mantid.dataobjects import Workspace2D # noqa -from mantid.py3compat import mock # noqa +from unittest import mock # noqa def pass_func(): diff --git a/qt/python/mantidqt/project/test/test_plotssaver.py b/qt/python/mantidqt/project/test/test_plotssaver.py index 36c1bbe11a39ebb19b8fe755c213e8c02032bbe2..50da81010c370d4937194a3755fbd4f17c26d5c7 100644 --- a/qt/python/mantidqt/project/test/test_plotssaver.py +++ b/qt/python/mantidqt/project/test/test_plotssaver.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import matplotlib import unittest diff --git a/qt/python/mantidqt/project/test/test_project.py b/qt/python/mantidqt/project/test/test_project.py index fc1f3a383b6d65f18283aec522253be542127345..038f223090579e618520911fc698481ffbe7118b 100644 --- a/qt/python/mantidqt/project/test/test_project.py +++ b/qt/python/mantidqt/project/test/test_project.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import os import tempfile import unittest @@ -19,7 +17,7 @@ from qtpy.QtWidgets import QMessageBox from mantid.api import AnalysisDataService as ADS from mantid.kernel import ConfigService from mantid.simpleapi import CreateSampleWorkspace, GroupWorkspaces, RenameWorkspace, UnGroupWorkspace -from mantid.py3compat import mock +from unittest import mock from mantidqt.project.project import Project from mantidqt.utils.qt.testing import start_qapplication diff --git a/qt/python/mantidqt/project/test/test_projectloader.py b/qt/python/mantidqt/project/test/test_projectloader.py index 1870ad4ede0da0f788a6442a48dd0196c52bd8ac..7517e36915176d4b2b164855d3a125839c7b368b 100644 --- a/qt/python/mantidqt/project/test/test_projectloader.py +++ b/qt/python/mantidqt/project/test/test_projectloader.py @@ -20,7 +20,7 @@ import tempfile # noqa from mantid.api import AnalysisDataService as ADS # noqa from mantid.simpleapi import CreateSampleWorkspace # noqa -from mantid.py3compat import mock # noqa +from unittest import mock # noqa from mantidqt.project import projectloader, projectsaver # noqa from mantidqt.utils.qt.testing import start_qapplication # noqa diff --git a/qt/python/mantidqt/project/test/test_projectsaver.py b/qt/python/mantidqt/project/test/test_projectsaver.py index 40e7725c5bb4d4d72323dd9a72c8fe373b7561cf..30292a2d11c96af6ddeaa24bf26fc5e4b0b4a407 100644 --- a/qt/python/mantidqt/project/test/test_projectsaver.py +++ b/qt/python/mantidqt/project/test/test_projectsaver.py @@ -16,7 +16,7 @@ from shutil import rmtree from mantid.api import AnalysisDataService as ADS from mantid.simpleapi import CreateSampleWorkspace -from mantid.py3compat import mock +from unittest import mock from mantidqt.project import projectsaver diff --git a/qt/python/mantidqt/project/test/test_workspacesaver.py b/qt/python/mantidqt/project/test/test_workspacesaver.py index bc4fde63330aa2d21cdcd32864df35f5058a66dc..fe18900e2ad28147fdbe77cf701aa281609066e6 100644 --- a/qt/python/mantidqt/project/test/test_workspacesaver.py +++ b/qt/python/mantidqt/project/test/test_workspacesaver.py @@ -17,7 +17,7 @@ import tempfile from mantid.api import AnalysisDataService as ADS, IMDEventWorkspace # noqa from mantid.dataobjects import MDHistoWorkspace, MaskWorkspace # noqa from mantidqt.project import workspacesaver -from mantid.py3compat import mock +from unittest import mock from mantid.simpleapi import (CreateSampleWorkspace, CreateMDHistoWorkspace, LoadMD, LoadMask, MaskDetectors, # noqa ExtractMask, GroupWorkspaces) # noqa diff --git a/qt/python/mantidqt/project/workspaceloader.py b/qt/python/mantidqt/project/workspaceloader.py index 4a4fe5ef9aa50ae9bd9e7fee33990dec1300a160..9d608aff7323cfcf7e23b8ecd8ec1aa4fce462be 100644 --- a/qt/python/mantidqt/project/workspaceloader.py +++ b/qt/python/mantidqt/project/workspaceloader.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - from os import path from mantid import logger diff --git a/qt/python/mantidqt/project/workspacesaver.py b/qt/python/mantidqt/project/workspacesaver.py index c8acb87604ce1ba5eeec05ee0bcccc253302e04c..c3167fdcbad48614c792d3b4cb86a5b013f1925e 100644 --- a/qt/python/mantidqt/project/workspacesaver.py +++ b/qt/python/mantidqt/project/workspacesaver.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import os.path from mantid.api import AnalysisDataService as ADS, IMDEventWorkspace diff --git a/qt/python/mantidqt/test/test_algorithm_observer.py b/qt/python/mantidqt/test/test_algorithm_observer.py index 6d3af4559e8ce450ac5589c7858f6ee21f4127e8..107a40035fa4c606ed8201181c93af2374dd98d9 100644 --- a/qt/python/mantidqt/test/test_algorithm_observer.py +++ b/qt/python/mantidqt/test/test_algorithm_observer.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function import unittest from mantid.api import AlgorithmObserver, AlgorithmManager, AlgorithmFactory, PythonAlgorithm, Progress diff --git a/qt/python/mantidqt/test/test_import.py b/qt/python/mantidqt/test/test_import.py index ff8010718597309270a4cf8f04af4a3d766191e8..f17fe305259f2d524c3784eb007a1aae76ca5ca2 100644 --- a/qt/python/mantidqt/test/test_import.py +++ b/qt/python/mantidqt/test/test_import.py @@ -4,8 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, - unicode_literals) + import unittest diff --git a/qt/python/mantidqt/usersubwindow.py b/qt/python/mantidqt/usersubwindow.py index 5b9ebbc53306bccde428f6a36d28d882e2fa72ef..de1ffec1452a1c62ba084cb4750d8d8344f4b7ba 100644 --- a/qt/python/mantidqt/usersubwindow.py +++ b/qt/python/mantidqt/usersubwindow.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/usersubwindowfactory.py b/qt/python/mantidqt/usersubwindowfactory.py index a945d40c4c60ff7656c068330ec7e3fc4ba3f100..898c6ebb56ee58a55e73cd07fb460ea399ace708 100644 --- a/qt/python/mantidqt/usersubwindowfactory.py +++ b/qt/python/mantidqt/usersubwindowfactory.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/utils/asynchronous.py b/qt/python/mantidqt/utils/asynchronous.py index de0c478de3d41a9383e742f020f3491151c48c8a..bdaa790b1ad6c149f06fb878f0ba71efb8be7380 100644 --- a/qt/python/mantidqt/utils/asynchronous.py +++ b/qt/python/mantidqt/utils/asynchronous.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - # system imports import ctypes import sys @@ -16,7 +14,7 @@ import threading import time from traceback import extract_tb -from mantid.py3compat.enum import Enum +from enum import Enum class TaskExitCode(Enum): diff --git a/qt/python/mantidqt/utils/observer_pattern.py b/qt/python/mantidqt/utils/observer_pattern.py index cf931b255e950eaae9db01964d989caa3f5cae52..eb7b4fc47b864979ead990cd668708a3d02068d1 100644 --- a/qt/python/mantidqt/utils/observer_pattern.py +++ b/qt/python/mantidqt/utils/observer_pattern.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantidqt.utils.qt.qappthreadcall import QAppThreadCall diff --git a/qt/python/mantidqt/utils/qt/__init__.py b/qt/python/mantidqt/utils/qt/__init__.py index 1d6d36c2707b5c7a1d30b4ce244babca2aa7bef2..190bf85e34490c1e6056ca8b52e606a9a2990754 100644 --- a/qt/python/mantidqt/utils/qt/__init__.py +++ b/qt/python/mantidqt/utils/qt/__init__.py @@ -9,8 +9,6 @@ # """A selection of utility functions related to Qt functionality """ -from __future__ import absolute_import - # stdlib modules import os.path as osp from contextlib import contextmanager diff --git a/qt/python/mantidqt/utils/qt/qappthreadcall.py b/qt/python/mantidqt/utils/qt/qappthreadcall.py index ffa370049b20a8edc60ea5a3a2e860ba456f8798..d08e02b9aece44584651718743b7a40c27db7950 100644 --- a/qt/python/mantidqt/utils/qt/qappthreadcall.py +++ b/qt/python/mantidqt/utils/qt/qappthreadcall.py @@ -13,8 +13,6 @@ import sys from qtpy.QtCore import Qt, QMetaObject, QObject, QThread, Slot from qtpy.QtWidgets import QApplication -from six import reraise - class QAppThreadCall(QObject): """ @@ -51,7 +49,7 @@ class QAppThreadCall(QObject): QMetaObject.invokeMethod(self, "on_call", Qt.BlockingQueuedConnection) if self._exc_info is not None: - reraise(*self._exc_info) + raise self._exc_info[1].with_traceback(self._exc_info[2]) return self._result @Slot() diff --git a/qt/python/mantidqt/utils/qt/test/__init__.py b/qt/python/mantidqt/utils/qt/test/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/qt/python/mantidqt/utils/qt/test/test_qappthreadcall.py b/qt/python/mantidqt/utils/qt/test/test_qappthreadcall.py new file mode 100644 index 0000000000000000000000000000000000000000..ffdd23eede192173d8dd1ab4afde59b4c05b6889 --- /dev/null +++ b/qt/python/mantidqt/utils/qt/test/test_qappthreadcall.py @@ -0,0 +1,50 @@ +# Mantid Repository : https://github.com/mantidproject/mantid +# +# Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI, +# NScD Oak Ridge National Laboratory, European Spallation Source +# & Institut Laue - Langevin +# SPDX - License - Identifier: GPL - 3.0 + +# This file is part of the mantid workbench. +# +# +import unittest + +from qtpy.QtWidgets import QApplication + +from mantidqt.utils.asynchronous import AsyncTask, TaskExitCode +from mantidqt.utils.qt.qappthreadcall import QAppThreadCall +from mantidqt.utils.qt.testing import start_qapplication + + +class CustomException(Exception): + pass + + +@start_qapplication +class QAppThreadCallTest(unittest.TestCase): + def test_correct_exception_is_raised_when_called_on_main_thread(self): + qappthread_wrap = QAppThreadCall(self.raises_exception) + + self.assertRaises(CustomException, qappthread_wrap) + + def test_correct_exception_is_raised_when_called_on_other_thread(self): + self.exc = None + self.exit_code = None + + def collect_error(e): + self.exc = e + + thread = AsyncTask(self.task, error_cb=collect_error) + thread.start() + while thread.is_alive(): + QApplication.processEvents() + thread.join(0.5) + self.assertTrue(isinstance(self.exc.exc_value, CustomException)) + self.assertEqual(TaskExitCode.ERROR, thread.exit_code) + + def raises_exception(self): + raise CustomException() + + def task(self): + qappthread_wrap = QAppThreadCall(self.raises_exception) + qappthread_wrap() diff --git a/qt/python/mantidqt/utils/qt/testing/__init__.py b/qt/python/mantidqt/utils/qt/testing/__init__.py index 7ff5da2bc57b4da3a9b97e0c05a4d57485484d17..e44f45c6cdae65cd8ab3337b1f1900c1aacf6eeb 100644 --- a/qt/python/mantidqt/utils/qt/testing/__init__.py +++ b/qt/python/mantidqt/utils/qt/testing/__init__.py @@ -10,8 +10,6 @@ # flake8: noqa """A selection of utility functions related to testing of Qt-based GUI elements. """ -from __future__ import absolute_import - from qtpy.QtCore import Qt, QObject from .application import get_application diff --git a/qt/python/mantidqt/utils/qt/testing/application.py b/qt/python/mantidqt/utils/qt/testing/application.py index 4efe6d044af339198632eccd96b34ca662bd0bac..434de477aa12ccd33acfdc4194ca6feca445a0fb 100644 --- a/qt/python/mantidqt/utils/qt/testing/application.py +++ b/qt/python/mantidqt/utils/qt/testing/application.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import - import atexit import sys import traceback diff --git a/qt/python/mantidqt/utils/qt/testing/gui_test_runner.py b/qt/python/mantidqt/utils/qt/testing/gui_test_runner.py index c6cf9329528a29a530605d9232f79a18fd2ea3b1..eda1f09f20aaf92d94857cae508413324e714aab 100644 --- a/qt/python/mantidqt/utils/qt/testing/gui_test_runner.py +++ b/qt/python/mantidqt/utils/qt/testing/gui_test_runner.py @@ -7,10 +7,7 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, print_function - import inspect -import six import traceback from qtpy.QtCore import QTimer, QMetaObject, Qt @@ -100,7 +97,7 @@ class ScriptRunner(object): if inspect.isgenerator(ret): self.script_iter.append(ret) ret = None - elif isinstance(ret, six.integer_types) or isinstance(ret, float): + elif isinstance(ret, int) or isinstance(ret, float): # Start non-blocking pause in seconds self.pause_timer.start(int(ret * 1000)) ret = None @@ -162,7 +159,7 @@ def open_in_window(widget_or_name, script, attach_debugger=True, pause=0, app = get_application() if widget_or_name is not None: widget_name = 'Widget to test' - if isinstance(widget_or_name, six.string_types): + if isinstance(widget_or_name, str): widget = create_widget(widget_or_name) widget_name = widget_or_name elif isinstance(widget_or_name, QWidget): @@ -201,7 +198,7 @@ def run_script(script_or_name, widget): :param widget: A widget to interact with. :return: Output of the script or an Exception object. """ - if isinstance(script_or_name, six.string_types): + if isinstance(script_or_name, str): module_name, fun_name = split_qualified_name(script_or_name) m = __import__(module_name, fromlist=[fun_name]) fun = getattr(m, fun_name) diff --git a/qt/python/mantidqt/utils/qt/testing/gui_window_test.py b/qt/python/mantidqt/utils/qt/testing/gui_window_test.py index c8afa8a21be31d4b5ee1e70d137b5d80aab8923a..f48e763f6d02a1bec5c9c6641491347697bf6778 100644 --- a/qt/python/mantidqt/utils/qt/testing/gui_window_test.py +++ b/qt/python/mantidqt/utils/qt/testing/gui_window_test.py @@ -7,7 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import print_function import inspect import platform import sys diff --git a/qt/python/mantidqt/utils/qt/testing/modal_tester.py b/qt/python/mantidqt/utils/qt/testing/modal_tester.py index 95e92319daac3b7756fb6de6bc9ec6d597bd1ebf..5567957383ad552b190c8b310e58770f91c1b567 100644 --- a/qt/python/mantidqt/utils/qt/testing/modal_tester.py +++ b/qt/python/mantidqt/utils/qt/testing/modal_tester.py @@ -25,8 +25,6 @@ class TestModalDialog(unittest.TestCase): tester.start() self.assertTrue(tester.passed) """ -from __future__ import absolute_import - import traceback from qtpy.QtCore import QTimer diff --git a/qt/python/mantidqt/utils/qt/testing/qt_assertions_helper.py b/qt/python/mantidqt/utils/qt/testing/qt_assertions_helper.py index bc5a648f3c2883ff7f75285b743a9f6b4e309920..058f60d503c673a2ce229e8183560787fff3a655 100644 --- a/qt/python/mantidqt/utils/qt/testing/qt_assertions_helper.py +++ b/qt/python/mantidqt/utils/qt/testing/qt_assertions_helper.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - from qtpy.QtWidgets import QPushButton diff --git a/qt/python/mantidqt/utils/show_in_explorer.py b/qt/python/mantidqt/utils/show_in_explorer.py index 0892016c1f9eaf2ad305658de15f6fad521dd0c8..b5b72af9e4c673405eff2ab03caca79cd761833b 100644 --- a/qt/python/mantidqt/utils/show_in_explorer.py +++ b/qt/python/mantidqt/utils/show_in_explorer.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - import os import subprocess import sys diff --git a/qt/python/mantidqt/utils/test/test_async.py b/qt/python/mantidqt/utils/test/test_async.py index 4bfdc7eeefbd768b7d136241270cca837fbc98b7..6d69ad2508f6b0f2b871b03785999982b65b5f42 100644 --- a/qt/python/mantidqt/utils/test/test_async.py +++ b/qt/python/mantidqt/utils/test/test_async.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - # system imports import traceback import unittest @@ -108,9 +106,9 @@ class AsyncTaskTest(unittest.TestCase): self.assertEqual(2, len(recv.task_exc_stack)) # line number of self.target in asynchronous.py - self.assertEqual(67, recv.task_exc_stack[0][1]) + self.assertEqual(65, recv.task_exc_stack[0][1]) # line number of raise statement above - self.assertEqual(95, recv.task_exc_stack[1][1]) + self.assertEqual(93, recv.task_exc_stack[1][1]) def test_unsuccessful_args_and_kwargs_operation_calls_error_and_finished_callback(self): def foo(scale, shift): @@ -143,8 +141,8 @@ class AsyncTaskTest(unittest.TestCase): self.assertTrue(recv.error_cb_called) self.assertTrue(isinstance(recv.task_exc, RuntimeError)) self.assertEqual(3, len(recv.task_exc_stack)) - self.assertEqual(135, recv.task_exc_stack[1][1]) - self.assertEqual(134, recv.task_exc_stack[2][1]) + self.assertEqual(133, recv.task_exc_stack[1][1]) + self.assertEqual(132, recv.task_exc_stack[2][1]) # --------------------------------------------------------------- # Failure cases diff --git a/qt/python/mantidqt/utils/test/test_modal_tester.py b/qt/python/mantidqt/utils/test/test_modal_tester.py index 254ad2149ba4f3acf67caa869d1d26e77a0b255f..18981949c94c37c6dfd92ac7b266cedc4e3e1040 100644 --- a/qt/python/mantidqt/utils/test/test_modal_tester.py +++ b/qt/python/mantidqt/utils/test/test_modal_tester.py @@ -7,13 +7,12 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + import unittest from qtpy.QtWidgets import QInputDialog -from mantid.py3compat.mock import patch +from unittest.mock import patch from mantidqt.utils.qt.testing import start_qapplication, ModalTester diff --git a/qt/python/mantidqt/utils/test/test_qt_utils.py b/qt/python/mantidqt/utils/test/test_qt_utils.py index 298acefbcd982991fe67aff8f449539e47dc158b..bf9ee1d865d6172fa4fdf696a4adf356b6acae77 100644 --- a/qt/python/mantidqt/utils/test/test_qt_utils.py +++ b/qt/python/mantidqt/utils/test/test_qt_utils.py @@ -7,8 +7,7 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + import unittest diff --git a/qt/python/mantidqt/utils/test/test_writetosignal.py b/qt/python/mantidqt/utils/test/test_writetosignal.py index 5dc8c4c5e45fd208a59c2e878dd350bef03e78c7..051aedf89d84f60c6bf8333eab3e41c90225921c 100644 --- a/qt/python/mantidqt/utils/test/test_writetosignal.py +++ b/qt/python/mantidqt/utils/test/test_writetosignal.py @@ -7,12 +7,10 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import) - from qtpy.QtCore import QCoreApplication, QObject import unittest -from mantid.py3compat.mock import patch +from unittest.mock import patch from mantidqt.utils.qt.testing import start_qapplication from mantidqt.utils.writetosignal import WriteToSignal diff --git a/qt/python/mantidqt/utils/testing/__init__.py b/qt/python/mantidqt/utils/testing/__init__.py index 0fb72b0143feabc37340826351939db3450f273e..5d9ba75dbc79786691ecb615c855a0483050425b 100644 --- a/qt/python/mantidqt/utils/testing/__init__.py +++ b/qt/python/mantidqt/utils/testing/__init__.py @@ -5,4 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import diff --git a/qt/python/mantidqt/utils/testing/mocks/mock_codeeditor.py b/qt/python/mantidqt/utils/testing/mocks/mock_codeeditor.py index a41c9ea53b9db4caa344fa3b78c60bd085a1e6c5..f7f950ea365fa58a0b509079188664097e7175d3 100644 --- a/qt/python/mantidqt/utils/testing/mocks/mock_codeeditor.py +++ b/qt/python/mantidqt/utils/testing/mocks/mock_codeeditor.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - from mantidqt.utils.testing.strict_mock import StrictMock diff --git a/qt/python/mantidqt/utils/testing/mocks/mock_mantid.py b/qt/python/mantidqt/utils/testing/mocks/mock_mantid.py index 82ee2727536d34e1b24a121c1fda975d6fd3173c..9a37f8549b0660702bb6ba5e3e9324cbc2df49ff 100644 --- a/qt/python/mantidqt/utils/testing/mocks/mock_mantid.py +++ b/qt/python/mantidqt/utils/testing/mocks/mock_mantid.py @@ -5,9 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.utils.testing.strict_mock import StrictMock AXIS_INDEX_FOR_HORIZONTAL = 0 diff --git a/qt/python/mantidqt/utils/testing/mocks/mock_matrixworkspacedisplay.py b/qt/python/mantidqt/utils/testing/mocks/mock_matrixworkspacedisplay.py index 4e3d4cbf9099b43e7c8026a07e33966884de487e..35e53f3282a8f11f1a095a70a964e45bc0e05f43 100644 --- a/qt/python/mantidqt/utils/testing/mocks/mock_matrixworkspacedisplay.py +++ b/qt/python/mantidqt/utils/testing/mocks/mock_matrixworkspacedisplay.py @@ -5,9 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.utils.testing.mocks.mock_qt import MockQTab, MockQTableView diff --git a/qt/python/mantidqt/utils/testing/mocks/mock_observing.py b/qt/python/mantidqt/utils/testing/mocks/mock_observing.py index a13b81f74e0b39e1a9b3f6b4804bc71874337522..3fb6ca81a86c9a3b478f8258b2a516025e7f1d41 100644 --- a/qt/python/mantidqt/utils/testing/mocks/mock_observing.py +++ b/qt/python/mantidqt/utils/testing/mocks/mock_observing.py @@ -5,9 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.widgets.observers.observing_presenter import ObservingPresenter from mantidqt.widgets.observers.observing_view import ObservingView diff --git a/qt/python/mantidqt/utils/testing/mocks/mock_plotlib.py b/qt/python/mantidqt/utils/testing/mocks/mock_plotlib.py index e690d97a03f9f25529bff250e606a5674d8a2896..0025d34f9de72aeae271bdeea7b96345fb098c49 100644 --- a/qt/python/mantidqt/utils/testing/mocks/mock_plotlib.py +++ b/qt/python/mantidqt/utils/testing/mocks/mock_plotlib.py @@ -23,10 +23,7 @@ only the ones that have been necessary so far. If another function needs to be mocked it can be freely added in the relevant class below and it should not break any existing tests. """ -from __future__ import (absolute_import, division, print_function) - - -from mantid.py3compat.mock import Mock +from unittest.mock import Mock class MockAx: diff --git a/qt/python/mantidqt/utils/testing/mocks/mock_qt.py b/qt/python/mantidqt/utils/testing/mocks/mock_qt.py index c6bb3b7192b5026994a5e75e8be09083595d57d8..6de077c164725331d477c3ca572073c7f9bd2c07 100644 --- a/qt/python/mantidqt/utils/testing/mocks/mock_qt.py +++ b/qt/python/mantidqt/utils/testing/mocks/mock_qt.py @@ -5,9 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.utils.testing.strict_mock import StrictMock try: diff --git a/qt/python/mantidqt/utils/testing/strict_mock.py b/qt/python/mantidqt/utils/testing/strict_mock.py index bcedfc3f1a5fee38297041947823285459a0f3b4..d6f6a9ee6b89a933027658e5a404c3dd8836cf01 100644 --- a/qt/python/mantidqt/utils/testing/strict_mock.py +++ b/qt/python/mantidqt/utils/testing/strict_mock.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - import unittest -from mantid.py3compat.mock import Mock, PropertyMock +from unittest.mock import Mock, PropertyMock class StrictMock(Mock): diff --git a/qt/python/mantidqt/utils/writetosignal.py b/qt/python/mantidqt/utils/writetosignal.py index 0e20fd6204583c51d35f35d4f3a4931e48ba4172..cf42760cc187b027940a119cc5cf6911f037ac7d 100644 --- a/qt/python/mantidqt/utils/writetosignal.py +++ b/qt/python/mantidqt/utils/writetosignal.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import) - from qtpy.QtCore import QObject, Signal diff --git a/qt/python/mantidqt/widgets/algorithmselector/algorithm_factory_observer.py b/qt/python/mantidqt/widgets/algorithmselector/algorithm_factory_observer.py index 53dc193903da353c6f4fef36b3120c3ab86d77cd..dc602bd8551881f7d94732606ec6acf39dc6f245 100644 --- a/qt/python/mantidqt/widgets/algorithmselector/algorithm_factory_observer.py +++ b/qt/python/mantidqt/widgets/algorithmselector/algorithm_factory_observer.py @@ -6,9 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import - - from mantid.api import AlgorithmFactoryObserver diff --git a/qt/python/mantidqt/widgets/algorithmselector/model.py b/qt/python/mantidqt/widgets/algorithmselector/model.py index d1c1b61ed30484b0869fc778556d42ee4c2cad81..f842c62f01fd6346b557794e5d4e072405b06f19 100644 --- a/qt/python/mantidqt/widgets/algorithmselector/model.py +++ b/qt/python/mantidqt/widgets/algorithmselector/model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from mantid.api import AlgorithmFactory, AlgorithmManager, IWorkspaceProperty from mantid.kernel import Direction diff --git a/qt/python/mantidqt/widgets/algorithmselector/presenter.py b/qt/python/mantidqt/widgets/algorithmselector/presenter.py index a7625aea0781f2d2c2db75538a0a53d8558af21f..a7ded888d264a668bae794de90093dcca238324c 100644 --- a/qt/python/mantidqt/widgets/algorithmselector/presenter.py +++ b/qt/python/mantidqt/widgets/algorithmselector/presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from collections import namedtuple from .model import AlgorithmSelectorModel diff --git a/qt/python/mantidqt/widgets/algorithmselector/test/observer_test.py b/qt/python/mantidqt/widgets/algorithmselector/test/observer_test.py index 20d7ed548cd10d394a05ccb7fb9decb519ad757e..b65be5c43701c2e94128da71b08fb8a46a36b15d 100644 --- a/qt/python/mantidqt/widgets/algorithmselector/test/observer_test.py +++ b/qt/python/mantidqt/widgets/algorithmselector/test/observer_test.py @@ -7,12 +7,10 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - import unittest from mantid.api import AlgorithmFactory, PythonAlgorithm -from mantid.py3compat import mock +from unittest import mock from mantidqt.widgets.algorithmselector.widget import AlgorithmSelectorWidget from mantidqt.widgets.algorithmselector.algorithm_factory_observer import AlgorithmSelectorFactoryObserver diff --git a/qt/python/mantidqt/widgets/algorithmselector/test/test_algorithmselector.py b/qt/python/mantidqt/widgets/algorithmselector/test/test_algorithmselector.py index a9f0d1dca63769c9470c0b557f5074ae8a61d752..a0be969cd8ccde3407c8392cb4bd0af718acece2 100644 --- a/qt/python/mantidqt/widgets/algorithmselector/test/test_algorithmselector.py +++ b/qt/python/mantidqt/widgets/algorithmselector/test/test_algorithmselector.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import - from collections import Counter, namedtuple import unittest @@ -17,7 +15,7 @@ from qtpy.QtCore import Qt from qtpy.QtTest import QTest from mantid.api import AlgorithmFactoryImpl -from mantid.py3compat.mock import Mock, patch, call +from unittest.mock import Mock, patch, call from mantidqt.utils.qt.testing import (select_item_in_combo_box, select_item_in_tree, start_qapplication) from mantidqt.widgets.algorithmselector.model import AlgorithmSelectorModel diff --git a/qt/python/mantidqt/widgets/algorithmselector/widget.py b/qt/python/mantidqt/widgets/algorithmselector/widget.py index f09a4be91d438d71d60d50756ba79b46b9e1d293..04efba951631baaab6a0f58c8f031b4e12a5231e 100644 --- a/qt/python/mantidqt/widgets/algorithmselector/widget.py +++ b/qt/python/mantidqt/widgets/algorithmselector/widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - import re import qtpy diff --git a/qt/python/mantidqt/widgets/codeeditor/completion.py b/qt/python/mantidqt/widgets/codeeditor/completion.py index 5635af79038604bb99d4af10b25b48d3fd579c20..d91b96ceb57dfaf4e391ac3e6da33d33b3f06e50 100644 --- a/qt/python/mantidqt/widgets/codeeditor/completion.py +++ b/qt/python/mantidqt/widgets/codeeditor/completion.py @@ -25,8 +25,6 @@ For these reasons it was agreed jedi would be dropped, possibly revisiting when we move to Python 3. """ -from __future__ import (absolute_import, unicode_literals) - import ast from collections import namedtuple import contextlib @@ -38,12 +36,8 @@ import warnings from lib2to3.pgen2.tokenize import detect_encoding from io import BytesIO -from six import PY2, string_types -if PY2: # noqa - from inspect import getargspec as getfullargspec -else: # noqa - from inspect import getfullargspec +from inspect import getfullargspec from mantidqt.widgets.codeeditor.editor import CodeEditor @@ -181,7 +175,7 @@ def generate_call_tips(definitions, prepend_module_name=None): else: module_name = prepend_module_name if inspect.isfunction(py_object) or inspect.isbuiltin(py_object): - if isinstance(module_name, string_types): + if isinstance(module_name, str): call_tips.append(module_name + '.' + name + get_function_spec(py_object)) else: call_tips.append(name + get_function_spec(py_object)) @@ -199,7 +193,7 @@ def generate_call_tips(definitions, prepend_module_name=None): call_tip = name + '.' + attr + get_function_spec(f_attr) else: call_tip = name + '.' + attr - if isinstance(module_name, string_types): + if isinstance(module_name, str): call_tips.append(module_name + '.' + call_tip) except Exception: continue diff --git a/qt/python/mantidqt/widgets/codeeditor/editor.py b/qt/python/mantidqt/widgets/codeeditor/editor.py index 24e8139123b5ba5a14ecc291e80deedf0b15e3de..04c71cebc17bb0f83980be7f83ab4dec7bad9572 100644 --- a/qt/python/mantidqt/widgets/codeeditor/editor.py +++ b/qt/python/mantidqt/widgets/codeeditor/editor.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - # 3rd party imports # local imports diff --git a/qt/python/mantidqt/widgets/codeeditor/errorformatter.py b/qt/python/mantidqt/widgets/codeeditor/errorformatter.py index 41e0dcf9a694679204272fabe57a7cdfc263fd5b..4096c9ed4dbf2e93faa5f92c336bc305d633121c 100644 --- a/qt/python/mantidqt/widgets/codeeditor/errorformatter.py +++ b/qt/python/mantidqt/widgets/codeeditor/errorformatter.py @@ -7,13 +7,10 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - # std imports import traceback # third-party imports -import six class ErrorFormatter(object): @@ -34,9 +31,4 @@ class ErrorFormatter(object): if stack is not None: lines.extend(traceback.format_list(stack)) - if six.PY2: - # traceback always returns a list of ascii string objects - # encoded as utf-8 we want unicode to be consistent - # with using unicode_literals across the codebase - lines = map(lambda x: x.decode('utf-8') , lines) return ''.join(lines) diff --git a/qt/python/mantidqt/widgets/codeeditor/execution.py b/qt/python/mantidqt/widgets/codeeditor/execution.py index c78a7ce1fed8e53e85cd00da675be969544fda84..d5457fc4896617a68c48736ed585a2be54df29b2 100644 --- a/qt/python/mantidqt/widgets/codeeditor/execution.py +++ b/qt/python/mantidqt/widgets/codeeditor/execution.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import absolute_import, unicode_literals - import __future__ import ast diff --git a/qt/python/mantidqt/widgets/codeeditor/interpreter.py b/qt/python/mantidqt/widgets/codeeditor/interpreter.py index 862db7ebf7ecfe30f27596948ab520252873a2f1..937dd2c80b72e7e9ef9394d7091d0fccd7c087c9 100644 --- a/qt/python/mantidqt/widgets/codeeditor/interpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/interpreter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import (absolute_import, unicode_literals) - import io import os.path import sys diff --git a/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py b/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py index 3def7f5f9db1b9594cad38d07b5942a111b6530e..19cb1124d719cd7992bed9f5b09b8e823fb776da 100644 --- a/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - # std imports import os.path as osp diff --git a/qt/python/mantidqt/widgets/codeeditor/tab_widget/__init__.py b/qt/python/mantidqt/widgets/codeeditor/tab_widget/__init__.py index 0fb72b0143feabc37340826351939db3450f273e..5d9ba75dbc79786691ecb615c855a0483050425b 100644 --- a/qt/python/mantidqt/widgets/codeeditor/tab_widget/__init__.py +++ b/qt/python/mantidqt/widgets/codeeditor/tab_widget/__init__.py @@ -5,4 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import diff --git a/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_presenter.py b/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_presenter.py index 1fe3d36987c3e0276570af1cbc2b46706a914b4a..2d2c99b0c602770059d966570b2966b66d60faa7 100644 --- a/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_presenter.py +++ b/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - import os from mantid.kernel import logger diff --git a/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_view.py b/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_view.py index d8fdca3e96a187e93554f299a9cea582a09df3fe..4981f50c8f5230dd7de0686d08d8380df11866fa 100644 --- a/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_view.py +++ b/qt/python/mantidqt/widgets/codeeditor/tab_widget/codeeditor_tab_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - from qtpy.QtCore import Qt from qtpy.QtGui import QColor from qtpy.QtWidgets import QAction, QHBoxLayout, QMenu, QPushButton, QSizePolicy, QTabWidget, QWidget diff --git a/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/__init__.py b/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/__init__.py index 0fb72b0143feabc37340826351939db3450f273e..5d9ba75dbc79786691ecb615c855a0483050425b 100644 --- a/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/__init__.py +++ b/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/__init__.py @@ -5,4 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import diff --git a/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_presenter.py b/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_presenter.py index 58c499172691776038f305b9410de1a09b1e609c..b4ec7fbe3f34c762cb8df9702f89f5a77a6d002c 100644 --- a/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_presenter.py +++ b/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_presenter.py @@ -5,12 +5,10 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - import os from unittest import TestCase -from mantid.py3compat.mock import patch +from unittest.mock import patch from mantidqt.utils.testing.mocks.mock_qt import MockQWidget from mantidqt.utils.testing.strict_mock import StrictPropertyMock from mantidqt.widgets.codeeditor.tab_widget.codeeditor_tab_presenter import CodeEditorTabPresenter diff --git a/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_view.py b/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_view.py index 09a382cd30deac37d6d437b1fb13b94876fb7d0b..f9df768897c8486f06b6c52d2de45d8cdda45af1 100644 --- a/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_view.py +++ b/qt/python/mantidqt/widgets/codeeditor/tab_widget/test/test_codeeditor_tab_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import absolute_import - import unittest from qtpy.QtWidgets import QAction, QApplication, QWidget diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_codeeditor.py b/qt/python/mantidqt/widgets/codeeditor/test/test_codeeditor.py index d0a78c40f4ac9149487afbe6f6b643d794bb7946..a5a11e35bd53e8e8af5e5a4777514f6ecd45cc18 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_codeeditor.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_codeeditor.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - # system imports import unittest diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_completion.py b/qt/python/mantidqt/widgets/codeeditor/test/test_completion.py index ef1effd4bc699d6b7bc0eb330c1e19a48514323f..edc7fc1a7d7094c3db75b82dc42b7b66e64fe034 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_completion.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_completion.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import re import unittest @@ -14,7 +12,7 @@ import matplotlib.pyplot as plt # noqa import numpy as np # noqa from mantid.simpleapi import Rebin # noqa # needed so sys.modules can pick up Rebin -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.widgets.codeeditor.completion import (CodeCompleter, generate_call_tips, get_function_spec, get_builtin_argspec, get_module_import_alias) from testhelpers import assertRaisesNothing diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_errorformatter.py b/qt/python/mantidqt/widgets/codeeditor/test/test_errorformatter.py index b4a5b3198b4970440f8428ed66667ea74c94cedd..886056a2f279bcfdfdd7d8c324328adb81c05f8f 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_errorformatter.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_errorformatter.py @@ -7,15 +7,12 @@ # # This file is part of the mantidqt package -from __future__ import (absolute_import, unicode_literals) - # std imports import sys import traceback import unittest # third-party imports -import six # local imports from mantidqt.widgets.codeeditor.errorformatter import ErrorFormatter @@ -71,24 +68,6 @@ foo() for produced, expected in zip(error_lines, expected_lines): self.assertRegexpMatches(produced, expected) - def test_errors_containing_unicode_produce_expected_value_in_python2(self): - if not six.PY2: - # everything is already unicode in python > 2 - return - try: - exec("é =") - except SyntaxError: - exc_type, exc_value = sys.exc_info()[:2] - formatter = ErrorFormatter() - error = formatter.format(exc_type, exc_value, None) - - expected = """ File "<string>", line 1 - é = - ^ -SyntaxError: invalid syntax -""" - self.assertEqual(expected, error) - if __name__ == "__main__": unittest.main() diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_execution.py b/qt/python/mantidqt/widgets/codeeditor/test/test_execution.py index ac36b915c7368553af72efba26a90393113c1d22..660417454da0c46d361e794c273ebc6a0c03a807 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_execution.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_execution.py @@ -8,8 +8,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - # std imports import sys import traceback @@ -19,8 +17,8 @@ import unittest from qtpy.QtCore import QCoreApplication, QObject # local imports -from mantid.py3compat import StringIO -from mantid.py3compat.mock import patch, Mock +from io import StringIO +from unittest.mock import patch, Mock from mantidqt.utils.qt.testing import start_qapplication from mantidqt.widgets.codeeditor.execution import PythonCodeExecution, _get_imported_from_future diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter.py b/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter.py index 4596e2cf32352a350824c3b2074eff689c51d147..35b83d55ebed39c8699690c376c6834a0098476e 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter.py @@ -7,11 +7,9 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from mantidqt.widgets.codeeditor.interpreter import PythonFileInterpreter diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter_view.py b/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter_view.py index b4583e98c190933b4e3fbbae96033416eafb0de8..022563dbf3ce6d43d03653689c2ff5dd42da30f0 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter_view.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_interpreter_view.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - import unittest from mantidqt.utils.qt.testing import start_qapplication diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py b/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py index 0df872acaf64b3f0afe092d6a45e0f3d9a37d732..e449aab996cb1da794689228a6400d62227be526 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter.py @@ -7,11 +7,9 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from mantidqt.utils.qt.testing.qt_widget_finder import QtWidgetFinder from mantidqt.widgets.codeeditor.multifileinterpreter import MultiPythonFileInterpreter diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter_view.py b/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter_view.py index 4d33075dffb508e06d3f99ca88efcd27037c37a3..adc3ba40d8b2ce2a0cd2df2932a9f4285c99d759 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter_view.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_multifileinterpreter_view.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - import unittest from qtpy.QtWidgets import QApplication diff --git a/qt/python/mantidqt/widgets/codeeditor/test/test_scriptcompatibility.py b/qt/python/mantidqt/widgets/codeeditor/test/test_scriptcompatibility.py index 3fa0ce52b3e741aeb4f0ab052e7b1a4b528032e1..2c9321e49acef62aecd7868c3a9ee208084bb813 100644 --- a/qt/python/mantidqt/widgets/codeeditor/test/test_scriptcompatibility.py +++ b/qt/python/mantidqt/widgets/codeeditor/test/test_scriptcompatibility.py @@ -10,7 +10,7 @@ import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.widgets.codeeditor.scriptcompatibility import (mantid_api_import_needed, mantid_algorithm_used_without_import) diff --git a/qt/python/mantidqt/widgets/colorbar/colorbar.py b/qt/python/mantidqt/widgets/colorbar/colorbar.py index 6c0e0c106116c623d955f0d34ce4f91b0371fb41..069b34c7268354dcb3c97bab1e26c0a1707af91f 100644 --- a/qt/python/mantidqt/widgets/colorbar/colorbar.py +++ b/qt/python/mantidqt/widgets/colorbar/colorbar.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - from mantid.plots.utility import mpl_version_info, get_current_cmap from mantidqt.MPLwidgets import FigureCanvas from matplotlib.colorbar import Colorbar diff --git a/qt/python/mantidqt/widgets/embedded_find_replace_dialog/presenter.py b/qt/python/mantidqt/widgets/embedded_find_replace_dialog/presenter.py index eafb8e8d28e51ba79000e101bd1f947776bdaf27..d8326202508ee15c32042cfa1dda054b01c3a5c6 100644 --- a/qt/python/mantidqt/widgets/embedded_find_replace_dialog/presenter.py +++ b/qt/python/mantidqt/widgets/embedded_find_replace_dialog/presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import (absolute_import, division, print_function) - from enum import Enum from mantidqt.widgets.embedded_find_replace_dialog.view import EmbeddedFindReplaceDialogView diff --git a/qt/python/mantidqt/widgets/embedded_find_replace_dialog/test/test_embedded_find_replace_dialog_presenter.py b/qt/python/mantidqt/widgets/embedded_find_replace_dialog/test/test_embedded_find_replace_dialog_presenter.py index 68cba2835421ea6962625495081787f4a0782a33..206a263abe1d40426ad67cf9a43bdadbc3b9a00c 100644 --- a/qt/python/mantidqt/widgets/embedded_find_replace_dialog/test/test_embedded_find_replace_dialog_presenter.py +++ b/qt/python/mantidqt/widgets/embedded_find_replace_dialog/test/test_embedded_find_replace_dialog_presenter.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package -from __future__ import (absolute_import, division, print_function) - from unittest import TestCase -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantidqt.widgets.embedded_find_replace_dialog.presenter import EmbeddedFindReplaceDialog, SearchDirection from mantidqt.utils.testing.mocks.mock_codeeditor import MockCodeEditor diff --git a/qt/python/mantidqt/widgets/filefinder/__init__.py b/qt/python/mantidqt/widgets/filefinder/__init__.py index 7384daca550ed27125b15d156c381e3903386c24..0d7a0619616547f14aedd82ada99966d113d1ae8 100644 --- a/qt/python/mantidqt/widgets/filefinder/__init__.py +++ b/qt/python/mantidqt/widgets/filefinder/__init__.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - from mantidqt.utils.qt import import_qt FileFinder = import_qt('..._common', 'mantidqt.widgets.filefinder', 'MWRunFiles') diff --git a/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/presenter.py b/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/presenter.py index 6c47b0a931e42fef994cf20099bcd86945e69670..510fd8d59e73013c95619a97125f999a7b5a6648 100644 --- a/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/presenter.py +++ b/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - from .view import AddFunctionDialogView from mantidqt.interfacemanager import InterfaceManager diff --git a/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/test/test_addfunctiondialogpresenter.py b/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/test/test_addfunctiondialogpresenter.py index 7d85ad05b81a1f42dd2f2987673c2f9728f2941e..3a4d7099c37f679ca90ebca3397871d122394b31 100644 --- a/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/test/test_addfunctiondialogpresenter.py +++ b/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/test/test_addfunctiondialogpresenter.py @@ -8,7 +8,7 @@ import unittest -from mantid.py3compat.mock import patch +from unittest.mock import patch from mantidqt.widgets.fitpropertybrowser.addfunctiondialog.presenter import AddFunctionDialog from testhelpers import assertRaisesNothing diff --git a/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/view.py b/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/view.py index b8d172d448fe27e019f1dca9aaa4335ae87bffbe..987b87e04f597d0a6d26f23a231df43c35e67f58 100644 --- a/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/view.py +++ b/qt/python/mantidqt/widgets/fitpropertybrowser/addfunctiondialog/view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt, Signal from qtpy.QtGui import QIcon from qtpy.QtWidgets import QCompleter, QDialog diff --git a/qt/python/mantidqt/widgets/fitpropertybrowser/fitpropertybrowser.py b/qt/python/mantidqt/widgets/fitpropertybrowser/fitpropertybrowser.py index 2d9c6a67f1346cf7a3e2325c94ebd9bc180685c4..5910630694e6f1ec8a860a35d5d703d718adbf87 100644 --- a/qt/python/mantidqt/widgets/fitpropertybrowser/fitpropertybrowser.py +++ b/qt/python/mantidqt/widgets/fitpropertybrowser/fitpropertybrowser.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (print_function, absolute_import, unicode_literals) - from qtpy.QtCore import Qt, Signal, Slot import matplotlib.pyplot diff --git a/qt/python/mantidqt/widgets/fitpropertybrowser/interactive_tool.py b/qt/python/mantidqt/widgets/fitpropertybrowser/interactive_tool.py index 9133e99474b47d2be2355dff25bda0ca881047c2..e692ceaa94ae93fdbb90cb02b35fe737e88d2460 100644 --- a/qt/python/mantidqt/widgets/fitpropertybrowser/interactive_tool.py +++ b/qt/python/mantidqt/widgets/fitpropertybrowser/interactive_tool.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import QObject, Signal, Slot from mantidqt.plotting.markers import PeakMarker, RangeMarker diff --git a/qt/python/mantidqt/widgets/instrumentview/__init__.py b/qt/python/mantidqt/widgets/instrumentview/__init__.py index fea27059e188b62cc03c2664754f8b417ebdcc37..3a8621ded61f42c6b600860ae377e76bf582e438 100644 --- a/qt/python/mantidqt/widgets/instrumentview/__init__.py +++ b/qt/python/mantidqt/widgets/instrumentview/__init__.py @@ -20,8 +20,6 @@ You can run this widget independently by for example: window = InstrumentView(ws) app.exec_() """ -from __future__ import (absolute_import, unicode_literals) - # 3rdparty imports from qtpy import PYQT4 diff --git a/qt/python/mantidqt/widgets/instrumentview/io.py b/qt/python/mantidqt/widgets/instrumentview/io.py index 880fc2e465a8e4a2376ddb639b85504cb3b9b51e..088ccbb759a9d6ff11d5cce519f97bc367ec08fc 100644 --- a/qt/python/mantidqt/widgets/instrumentview/io.py +++ b/qt/python/mantidqt/widgets/instrumentview/io.py @@ -6,9 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - - from mantid.api import AnalysisDataService as ADS from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/widgets/instrumentview/presenter.py b/qt/python/mantidqt/widgets/instrumentview/presenter.py index 0f0a2fa6e5bbc4c80de9123531423bd1987984b5..e4629aee494d263977602d78249fb51abfbe6f3b 100644 --- a/qt/python/mantidqt/widgets/instrumentview/presenter.py +++ b/qt/python/mantidqt/widgets/instrumentview/presenter.py @@ -10,8 +10,6 @@ """ Contains the presenter for displaying the InstrumentWidget """ -from __future__ import (absolute_import, unicode_literals) - from mantidqt.widgets.observers.ads_observer import WorkspaceDisplayADSObserver from mantidqt.widgets.observers.observing_presenter import ObservingPresenter from .view import InstrumentView diff --git a/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_io.py b/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_io.py index c59d7b2fb25214c3102a6c83a24f08378df82140..3e34fe62d2e42b864537b85c50102bd5ee90f802 100644 --- a/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_io.py +++ b/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_io.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package # -from __future__ import (absolute_import, division, print_function, unicode_literals) - import unittest from mantidqt.project.encoderfactory import EncoderFactory diff --git a/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_view.py b/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_view.py index 74bb51eab5d09daba98cb4e67aa929f343acf207..8e5e88fe1b723631124b868ef17dff8bce80048d 100644 --- a/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_view.py +++ b/qt/python/mantidqt/widgets/instrumentview/test/test_instrumentview_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import, unicode_literals - import unittest from qtpy.QtWidgets import QApplication diff --git a/qt/python/mantidqt/widgets/instrumentview/view.py b/qt/python/mantidqt/widgets/instrumentview/view.py index 36ca948edd99e30d66be9291471d0bf0ed464746..252f6792f40eaf4bfd4d599483d5dd4b3c96d851 100644 --- a/qt/python/mantidqt/widgets/instrumentview/view.py +++ b/qt/python/mantidqt/widgets/instrumentview/view.py @@ -10,8 +10,6 @@ """ Contains the Python wrapper class for the C++ instrument widget """ -from __future__ import (absolute_import, unicode_literals) - # 3rdparty imports from qtpy.QtCore import Qt, Signal, Slot from qtpy.QtWidgets import QVBoxLayout, QWidget diff --git a/qt/python/mantidqt/widgets/jobtreeview/__init__.py b/qt/python/mantidqt/widgets/jobtreeview/__init__.py index 52124cdf06bfd82a39c052057380e47ccbf14a2f..ac5f84908ad26870e191ef0937aac57d68ba4050 100644 --- a/qt/python/mantidqt/widgets/jobtreeview/__init__.py +++ b/qt/python/mantidqt/widgets/jobtreeview/__init__.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt Cell = import_qt('..._common', 'mantidqt.widgets.jobtreeview', 'Cell') diff --git a/qt/python/mantidqt/widgets/jupyterconsole.py b/qt/python/mantidqt/widgets/jupyterconsole.py index c5aa0d961c943e8ee454b05b778919ba2c7581b6..8b2c65657320c3906144c7a804f36ba2aac5612a 100644 --- a/qt/python/mantidqt/widgets/jupyterconsole.py +++ b/qt/python/mantidqt/widgets/jupyterconsole.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import absolute_import - # system imports import types @@ -26,7 +24,7 @@ except ImportError: from IPython.qt.inprocess import QtInProcessKernelManager # local imports -from mantid.py3compat import getfullargspec +from inspect import getfullargspec from mantidqt.utils.asynchronous import BlockingAsyncTaskWithCallback diff --git a/qt/python/mantidqt/widgets/manageuserdirectories.py b/qt/python/mantidqt/widgets/manageuserdirectories.py index 449e0d5cc269f8baf1012fa10e522c0f32eca6a8..79c3a3aff27a5cbd8600ffd49a3121155f2a1b1d 100644 --- a/qt/python/mantidqt/widgets/manageuserdirectories.py +++ b/qt/python/mantidqt/widgets/manageuserdirectories.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - from mantidqt.utils.qt import import_qt ManageUserDirectories = import_qt('.._common', 'mantidqt.widgets', 'ManageUserDirectories') diff --git a/qt/python/mantidqt/widgets/messagedisplay.py b/qt/python/mantidqt/widgets/messagedisplay.py index 7c413883acfcd6faf714ba5a76dc4fe917174891..843c3985339f7224ada9429cad337496710e1baa 100644 --- a/qt/python/mantidqt/widgets/messagedisplay.py +++ b/qt/python/mantidqt/widgets/messagedisplay.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtWidgets import QAction, QActionGroup from qtpy.QtGui import QFont diff --git a/qt/python/mantidqt/widgets/observers/ads_observer.py b/qt/python/mantidqt/widgets/observers/ads_observer.py index a1e3372b99fa7cd2c2907adcd58875b9e6b42eba..90e2a2f288d1fb838be04496a57cc58394f0ecb1 100644 --- a/qt/python/mantidqt/widgets/observers/ads_observer.py +++ b/qt/python/mantidqt/widgets/observers/ads_observer.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - import sys from functools import wraps diff --git a/qt/python/mantidqt/widgets/observers/observing_presenter.py b/qt/python/mantidqt/widgets/observers/observing_presenter.py index 37f1dd12913484712cacade1101abad8e4ab3d89..de6929d82806c5128a79586dc1ef368dfbaf607a 100644 --- a/qt/python/mantidqt/widgets/observers/observing_presenter.py +++ b/qt/python/mantidqt/widgets/observers/observing_presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - class ObservingPresenter(object): """ diff --git a/qt/python/mantidqt/widgets/observers/observing_view.py b/qt/python/mantidqt/widgets/observers/observing_view.py index ed507045d371a63c94f3c4a4f438f35bbb6caced..52b52d6bbf7396940cddce26fd87648d0cb4be1e 100644 --- a/qt/python/mantidqt/widgets/observers/observing_view.py +++ b/qt/python/mantidqt/widgets/observers/observing_view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - class ObservingView(object): """ diff --git a/qt/python/mantidqt/widgets/observers/test/test_ads_observer.py b/qt/python/mantidqt/widgets/observers/test/test_ads_observer.py index 6c3bf71b62883ad427581270f23680f749836235..923c6edb690b5b209e7b6bf7d7baa9223b1a45f2 100644 --- a/qt/python/mantidqt/widgets/observers/test/test_ads_observer.py +++ b/qt/python/mantidqt/widgets/observers/test/test_ads_observer.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.widgets.observers.ads_observer import WorkspaceDisplayADSObserver diff --git a/qt/python/mantidqt/widgets/observers/test/test_observing_presenter.py b/qt/python/mantidqt/widgets/observers/test/test_observing_presenter.py index 1fb7db9de19f7dc7761a0cdcd41a1bb561abe545..3dbf84c398d7768d94a4a3890a47d21ada728696 100644 --- a/qt/python/mantidqt/widgets/observers/test/test_observing_presenter.py +++ b/qt/python/mantidqt/widgets/observers/test/test_observing_presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - import unittest from mantidqt.utils.testing.mocks.mock_observing import MockObservingPresenter diff --git a/qt/python/mantidqt/widgets/observers/test/test_observing_view.py b/qt/python/mantidqt/widgets/observers/test/test_observing_view.py index aba39e6fdec8274f2ff4a57928cb42fddf1da591..c83cd90e45f54dca43daa2df4b7d52077f540bfc 100644 --- a/qt/python/mantidqt/widgets/observers/test/test_observing_view.py +++ b/qt/python/mantidqt/widgets/observers/test/test_observing_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - import unittest from mantidqt.utils.testing.mocks.mock_observing import MockObservingView diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/__init__.py index 87763f237517340b803315a527b1b1467882c731..58ef4a89010ebc610f86986c7e546f9a17549d5e 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/__init__.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from matplotlib.axes import ErrorbarContainer from matplotlib.collections import QuadMesh diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/__init__.py index 40d396400dae13c796656567142050a462867304..96bd7a51cb88ea107b07c806f0b42dc9860e7b4d 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/__init__.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - class AxProperties(dict): """ diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/presenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/presenter.py index 343ea46b10956118aefe0bd30290e556a989640a..982a686cd6f4e91b40ace8b63e6ef3cf1cf28809 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/presenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from mantidqt.widgets.plotconfigdialog import generate_ax_name, get_axes_names_dict from mantidqt.widgets.plotconfigdialog.axestabwidget import AxProperties from mantidqt.widgets.plotconfigdialog.axestabwidget.view import AxesTabWidgetView diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/test_axestabwidgetpresenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/test_axestabwidgetpresenter.py index 9f4698acb99d3e2ac3d2b6bc7e9971e06a66b7e4..ed9b8188047bc5b46b862c405347e0f03dee18fa 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/test_axestabwidgetpresenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/test/test_axestabwidgetpresenter.py @@ -6,15 +6,13 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import unittest from matplotlib import use as mpl_use mpl_use('Agg') # noqa from matplotlib.pyplot import figure -from mantid.py3compat import mock +from unittest import mock from mantidqt.widgets.plotconfigdialog import generate_ax_name, get_axes_names_dict from mantidqt.widgets.plotconfigdialog.axestabwidget import AxProperties from mantidqt.widgets.plotconfigdialog.axestabwidget.presenter import AxesTabWidgetPresenter as Presenter diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/view.py index 7e923bcbee7d42f0a58199a51f5cd674134b7db2..c8924fb4bb1cbc769be71eb4a586ffe8a301e041 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/axestabwidget/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtGui import QDoubleValidator from qtpy.QtWidgets import QWidget, QMessageBox diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/colorselector.py b/qt/python/mantidqt/widgets/plotconfigdialog/colorselector.py index dc7db8c600dfa748b3ffb3c7a630940ed2acfb77..20916eb4366fd304e19e4d575a2748969a4e3859 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/colorselector.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/colorselector.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from mantid.plots.legend import convert_color_to_hex from matplotlib import rcParams from qtpy.QtCore import QRegExp diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py index 343a8a03bd77e0de0a0cbd834d15dc3fc8996730..1acaabb712c48710fe93aa1c3ee22390781d234f 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/__init__.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from matplotlib import rcParams from matplotlib.axes import ErrorbarContainer from matplotlib.lines import Line2D diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/view.py index b63e862e61e24c79f91883373d36597862d9d85c..c9ac5f9f38458da02398597348fa7951fa816a1d 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/errorbarstabwidget/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtWidgets import QWidget diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/view.py index 8e0e7362e71e19ab11e23aafc9398c8ceb00cd0a..a762c27b899d1ff4c8c1762eacc214619a384e56 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/linetabwidget/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtWidgets import QWidget diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/view.py index 20351fcff3e87aba79c4e2f1549df7f7cfbf8678..b8a39c9bce8951c93afabf69f3db08511c28ce38 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/markertabwidget/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtWidgets import QWidget diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/presenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/presenter.py index 98b15e08b255e2954ad962ae3cd36b56f139ee35..56724d8c1f2662c7f904cdf4b48d3fec2e564e35 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/presenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from matplotlib.collections import PolyCollection from matplotlib.lines import Line2D diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curveproperties.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curveproperties.py index 757762013dcb650491a45f0d7fecfa0bddab0655..da4b0243a00a5bac590eaa2716955ccdd3a287ab 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curveproperties.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curveproperties.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import unittest from matplotlib import use as mpl_use diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curvestabwidgetpresenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curvestabwidgetpresenter.py index d06247161250e557fcac4b443fb1075cd3458dd4..eedcd97191f7dd3fe85f23d7c1b3b6dde550b424 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curvestabwidgetpresenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/test/test_curvestabwidgetpresenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import unittest from matplotlib import use as mpl_use @@ -19,7 +17,7 @@ from numpy import array_equal from mantid.simpleapi import CreateWorkspace from mantid.plots import datafunctions from mantid.plots.utility import MantidAxType -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantidqt.widgets.plotconfigdialog.colorselector import convert_color_to_hex from mantidqt.widgets.plotconfigdialog.curvestabwidget import CurveProperties from mantidqt.widgets.plotconfigdialog.curvestabwidget.presenter import ( diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/view.py index 6b40e0d88cea00a04c2ee99e0c1e7d8b61b1b4fc..25ad138fa858f9daa29f4aae9ac1f0f61b04c06b 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/curvestabwidget/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtWidgets import QWidget diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/__init__.py index 7b7731026419baaaed080f80b4e0b7b89b9f5043..40c77756bab3b595649bce4498ea5ed60cff94a0 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/__init__.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from matplotlib.collections import QuadMesh from matplotlib.colors import LogNorm diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/presenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/presenter.py index 0ccbe31e90d0b258eb06938c419f1f63e174c185..a635b873fc9a103cb27531a7d7c761d8fb05bbda 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/presenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from mantid.plots.datafunctions import update_colorbar_scale from mantidqt.utils.qt import block_signals from mantidqt.widgets.plotconfigdialog import generate_ax_name, get_images_from_fig diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/test_imagestabwidgetpresenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/test_imagestabwidgetpresenter.py index 4190ff43b052c015e0f0859d8717ac8675fa3101..2134a1acd5fc218a422a413d3332e98475597139 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/test_imagestabwidgetpresenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/test/test_imagestabwidgetpresenter.py @@ -15,7 +15,7 @@ from matplotlib.pyplot import figure from numpy import linspace, random from mantid.plots import MantidAxes # register mantid projection # noqa -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantid.simpleapi import CreateWorkspace from mantidqt.widgets.plotconfigdialog.imagestabwidget import ImageProperties from mantidqt.widgets.plotconfigdialog.imagestabwidget.presenter import ImagesTabWidgetPresenter diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/view.py index 8dfa5554b0ba3d9234bee14b29cec6fc54ff4ac1..07fafd71878929ae16a694cb44d7d8ca0196a714 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/imagestabwidget/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import numpy as np from matplotlib.colors import LogNorm, Normalize from matplotlib import cm diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/view.py index 3daba515629ce8c4da9a80632f565f0a4e613bca..e4ea50b4889f99128aa463208fceeeb92decd7ba 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/advancedlegendoptionsdialog/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt, QSize from qtpy.QtGui import QIcon from qtpy.QtWidgets import QDialog diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/presenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/presenter.py index 62717edb75196f8bdd5480af446574f26988605a..a6ebb26d6957ec820032f464f4715580f65067bb 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/presenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from mantid.plots.legend import LegendProperties from mantidqt.widgets.plotconfigdialog.legendtabwidget.view import LegendTabWidgetView diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/view.py index 320506a1cedd5196ae9e665819d8ffa32e5c6c3e..f414d3cd65368421c86aada8dc123ae88bc56dec 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/legendtabwidget/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtWidgets import QWidget diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/presenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/presenter.py index 547f4ef1ed51f59d74ab33a0bfcd72af491f2d24..89455efc511e9a7990db58ab5901330c7a79121d 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/presenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from mantidqt.widgets.plotconfigdialog import curve_in_figure, image_in_figure, legend_in_figure from mantidqt.widgets.plotconfigdialog.view import PlotConfigDialogView from mantidqt.widgets.plotconfigdialog.axestabwidget.presenter import AxesTabWidgetPresenter diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/test/__init__.py b/qt/python/mantidqt/widgets/plotconfigdialog/test/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/test/__init__.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/test/test_apply_all_properties.py b/qt/python/mantidqt/widgets/plotconfigdialog/test/test_apply_all_properties.py index 84eac3ac2e35bf48a42059fbd389b31779639b9e..755f292774e0dbda1fce817efc66cf335e3f7b47 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/test/test_apply_all_properties.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/test/test_apply_all_properties.py @@ -16,7 +16,7 @@ from matplotlib.patches import BoxStyle from matplotlib.pyplot import figure from mantid.plots.legend import LegendProperties -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantidqt.widgets.plotconfigdialog.colorselector import convert_color_to_hex from mantidqt.widgets.plotconfigdialog.axestabwidget import AxProperties from mantidqt.widgets.plotconfigdialog.imagestabwidget import ImageProperties diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/test/test_plotconfigdialogpresenter.py b/qt/python/mantidqt/widgets/plotconfigdialog/test/test_plotconfigdialogpresenter.py index 3e003acfd5857ddf37eabacd53b43a243bcc1c4c..648a178c1c73c85a70cd054c073957a0d5ebfdee 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/test/test_plotconfigdialogpresenter.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/test/test_plotconfigdialogpresenter.py @@ -6,15 +6,13 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import unittest from matplotlib import use as mpl_use mpl_use('Agg') # noqa from matplotlib.pyplot import figure -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantidqt.widgets.plotconfigdialog.presenter import PlotConfigDialogPresenter diff --git a/qt/python/mantidqt/widgets/plotconfigdialog/view.py b/qt/python/mantidqt/widgets/plotconfigdialog/view.py index c15bb639b02b74bec643d838cd11e0d46b19e5d3..6e71d2df0f65f9e273682cb992a0cd9423f27c88 100644 --- a/qt/python/mantidqt/widgets/plotconfigdialog/view.py +++ b/qt/python/mantidqt/widgets/plotconfigdialog/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtGui import QIcon from qtpy.QtWidgets import QDialog diff --git a/qt/python/mantidqt/widgets/samplelogs/model.py b/qt/python/mantidqt/widgets/samplelogs/model.py index 8b20520ada90b03c3fb165c1b2310e5f496136d9..a98feafc801aeea21b5359cc82d4e1072de16a9e 100644 --- a/qt/python/mantidqt/widgets/samplelogs/model.py +++ b/qt/python/mantidqt/widgets/samplelogs/model.py @@ -7,7 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) from mantid.kernel import (BoolTimeSeriesProperty, FloatTimeSeriesProperty, Int32TimeSeriesProperty, Int64TimeSeriesProperty, StringTimeSeriesProperty, logger) diff --git a/qt/python/mantidqt/widgets/samplelogs/presenter.py b/qt/python/mantidqt/widgets/samplelogs/presenter.py index 5498c3fc910ab96acfabd4c5efa5f04a24fa6937..bab138a7088af8f28ea8e353ac31333655bfd904 100644 --- a/qt/python/mantidqt/widgets/samplelogs/presenter.py +++ b/qt/python/mantidqt/widgets/samplelogs/presenter.py @@ -7,7 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) from .model import SampleLogsModel from .view import SampleLogsView diff --git a/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_model.py b/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_model.py index 19e6c582a4b0c3ee975c48f9a1a6522e0216fe81..022452e71b781a9e7740144bb2816bbc766a33dd 100644 --- a/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_model.py +++ b/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_model.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import LoadEventNexus, CreateMDWorkspace from mantidqt.widgets.samplelogs.model import SampleLogsModel diff --git a/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_presenter.py b/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_presenter.py index e373f06c99ecae1a57a38b794f2a0eaf49e407ea..570d8ae0bfe53a513fbd7939648fc7bfcaf74ff1 100644 --- a/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_presenter.py +++ b/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_presenter.py @@ -7,13 +7,11 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import matplotlib matplotlib.use('Agg') # noqa: E402 import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.widgets.samplelogs.model import SampleLogsModel from mantidqt.widgets.samplelogs.presenter import SampleLogs from mantidqt.widgets.samplelogs.view import SampleLogsView diff --git a/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py b/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py index 72b439918dceadfe4e1214aaf98ec9500ba0dd34..b71e9ce83136bd31044daa16824849fc17b2059b 100644 --- a/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py +++ b/qt/python/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import - import unittest import matplotlib as mpl diff --git a/qt/python/mantidqt/widgets/samplelogs/view.py b/qt/python/mantidqt/widgets/samplelogs/view.py index 7c6299a265f280901c4c34ea4d6e1b220703f84f..6bad261fc1f6aa263e5769c393d2688640c63557 100644 --- a/qt/python/mantidqt/widgets/samplelogs/view.py +++ b/qt/python/mantidqt/widgets/samplelogs/view.py @@ -7,7 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QTableView, QHBoxLayout, QVBoxLayout, QAbstractItemView, QFormLayout, QLineEdit, QHeaderView, QLabel, QCheckBox, QMenu, diff --git a/qt/python/mantidqt/widgets/scriptrepository.py b/qt/python/mantidqt/widgets/scriptrepository.py index b4b1182608ba9a769a4538237b675e979c14b542..9a9883e6bb6d1fa794622cb0cbf582015eaf8e7c 100644 --- a/qt/python/mantidqt/widgets/scriptrepository.py +++ b/qt/python/mantidqt/widgets/scriptrepository.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/widgets/sliceviewer/dimensionwidget.py b/qt/python/mantidqt/widgets/sliceviewer/dimensionwidget.py index 9afa7bd0523d1aa4ad684f46e741cd9919213d63..d0fa58871a048fedcc2eafbd4381f31251e3a243 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/dimensionwidget.py +++ b/qt/python/mantidqt/widgets/sliceviewer/dimensionwidget.py @@ -7,10 +7,9 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QLabel, QPushButton, QSlider, QDoubleSpinBox, QSpinBox from qtpy.QtCore import Qt, Signal -from mantid.py3compat.enum import Enum +from enum import Enum class State(Enum): diff --git a/qt/python/mantidqt/widgets/sliceviewer/model.py b/qt/python/mantidqt/widgets/sliceviewer/model.py index 43b76f1a092787f932e2b1d724ea8136c8277bf7..cb94985dcc2a15ce92c8078665f6ca9345c4c102 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/model.py +++ b/qt/python/mantidqt/widgets/sliceviewer/model.py @@ -7,11 +7,10 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) from mantid.plots.datafunctions import get_indices from mantid.api import MatrixWorkspace, MultipleExperimentInfos from mantid.simpleapi import BinMD -from mantid.py3compat.enum import Enum +from enum import Enum import numpy as np diff --git a/qt/python/mantidqt/widgets/sliceviewer/presenter.py b/qt/python/mantidqt/widgets/sliceviewer/presenter.py index c82acf7910bb4988e0b8b61422ab60a9999de3d1..45f2716e43392fad249bc4e29e0b2be98ccfc762 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/presenter.py +++ b/qt/python/mantidqt/widgets/sliceviewer/presenter.py @@ -7,7 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) from .model import SliceViewerModel, WS_TYPE from .view import SliceViewerView import mantid.api diff --git a/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_model.py b/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_model.py index 4c0916b97e885c1fa9b0ac12e8b42678500335e6..b1302a3a58cc2683434a498dc4bb45a06ee5a50c 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_model.py +++ b/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_model.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import CreateMDHistoWorkspace, CreateWorkspace, CreateMDWorkspace, FakeMDEventData from mantidqt.widgets.sliceviewer.model import SliceViewerModel, WS_TYPE from numpy.testing import assert_equal, assert_allclose diff --git a/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py b/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py index 1b807d4d453899cc4ad39ac7b2afdfef258b96a5..6398948e75727cc36727b07ed5de865b762191a2 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py +++ b/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_presenter.py @@ -7,14 +7,12 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import matplotlib matplotlib.use('Agg') # noqa: E402 import unittest import mantid.api -from mantid.py3compat import mock +from unittest import mock from mantidqt.widgets.sliceviewer.model import SliceViewerModel, WS_TYPE from mantidqt.widgets.sliceviewer.presenter import SliceViewer from mantidqt.widgets.sliceviewer.view import SliceViewerView diff --git a/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_view.py b/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_view.py index 0bf01b069e8a0421af1e98984128749c72d323ce..f30b8811cbd8b8cc584dd575cad6c90679a25da6 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_view.py +++ b/qt/python/mantidqt/widgets/sliceviewer/test/test_sliceviewer_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import - import unittest import matplotlib as mpl diff --git a/qt/python/mantidqt/widgets/sliceviewer/toolbar.py b/qt/python/mantidqt/widgets/sliceviewer/toolbar.py index c3e1191cb170bd4d69708115e39b038a3c96e782..0de17f733dc82e1772aa808d4e1f8b5e16f85fcc 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/toolbar.py +++ b/qt/python/mantidqt/widgets/sliceviewer/toolbar.py @@ -8,8 +8,7 @@ # # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + from mantidqt.MPLwidgets import NavigationToolbar2QT from mantidqt.icons import get_icon from qtpy.QtCore import Signal, Qt, QSize diff --git a/qt/python/mantidqt/widgets/sliceviewer/view.py b/qt/python/mantidqt/widgets/sliceviewer/view.py index 50d6307d4dcbf96ba282de444a2f4b2ef4150413..67e27a477c0315ac8c26b79888e16029bde94281 100644 --- a/qt/python/mantidqt/widgets/sliceviewer/view.py +++ b/qt/python/mantidqt/widgets/sliceviewer/view.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - from matplotlib import gridspec from matplotlib.figure import Figure from matplotlib.transforms import Bbox, BboxTransform diff --git a/qt/python/mantidqt/widgets/test/test_fitpropertybrowser.py b/qt/python/mantidqt/widgets/test/test_fitpropertybrowser.py index a0cd07b36a6e1d789dfbc55d10cf2d04b0ce2c49..99c611413fbd7954e8461784d84c6d31717db2d1 100644 --- a/qt/python/mantidqt/widgets/test/test_fitpropertybrowser.py +++ b/qt/python/mantidqt/widgets/test/test_fitpropertybrowser.py @@ -13,7 +13,7 @@ matplotlib.use('AGG') # noqa from numpy import zeros from mantid.api import AnalysisDataService, WorkspaceFactory -from mantid.py3compat.mock import MagicMock, Mock, patch +from unittest.mock import MagicMock, Mock, patch from mantid.simpleapi import CreateSampleWorkspace, CreateWorkspace from mantidqt.plotting.functions import plot from mantidqt.utils.qt.testing import start_qapplication diff --git a/qt/python/mantidqt/widgets/test/test_fitpropertybrowserbase.py b/qt/python/mantidqt/widgets/test/test_fitpropertybrowserbase.py index 0bbb1e0b91eba735da62c74c713a08110079fe51..c679e41b748d90cf15bcdd32640c27483dfe2112 100644 --- a/qt/python/mantidqt/widgets/test/test_fitpropertybrowserbase.py +++ b/qt/python/mantidqt/widgets/test/test_fitpropertybrowserbase.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import platform import sys import unittest diff --git a/qt/python/mantidqt/widgets/test/test_functionbrowser.py b/qt/python/mantidqt/widgets/test/test_functionbrowser.py index 5cf6660a9f7a687280d80cc8dd7f685bdb3bfa7f..7335afe66e00fbc415694ddfa868a056e368aecd 100644 --- a/qt/python/mantidqt/widgets/test/test_functionbrowser.py +++ b/qt/python/mantidqt/widgets/test/test_functionbrowser.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from qtpy.QtWidgets import QApplication @@ -13,7 +12,7 @@ from qtpy.QtTest import QTest from mantid import FrameworkManager, FunctionFactory from mantid.fitfunctions import FunctionWrapper -from mantid.py3compat.mock import MagicMock, call +from unittest.mock import MagicMock, call from mantidqt.utils.qt.testing.gui_window_test import (GuiWindowTest, not_on_windows, get_child, click_on) from mantidqt.widgets.functionbrowser import FunctionBrowser diff --git a/qt/python/mantidqt/widgets/test/test_jupyterconsole.py b/qt/python/mantidqt/widgets/test/test_jupyterconsole.py index 588df0fd83de3d23c608276aa47de4eba741df39..a1b84668154ea983b88bf2faedb03b3e9d6694f8 100644 --- a/qt/python/mantidqt/widgets/test/test_jupyterconsole.py +++ b/qt/python/mantidqt/widgets/test/test_jupyterconsole.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import) - # system imports # import readline (if available) before QApplication starts to avoid segfault with IPython 5 and Python 3 try: diff --git a/qt/python/mantidqt/widgets/test/test_messagedisplay.py b/qt/python/mantidqt/widgets/test/test_messagedisplay.py index 7ea86346dccb980a9b017b3524ea70fbcb1bf8d1..ab28aed6d53422b2c9e7254dd880820326890d71 100644 --- a/qt/python/mantidqt/widgets/test/test_messagedisplay.py +++ b/qt/python/mantidqt/widgets/test/test_messagedisplay.py @@ -7,8 +7,7 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + import unittest diff --git a/qt/python/mantidqt/widgets/test/test_scriptrepository.py b/qt/python/mantidqt/widgets/test/test_scriptrepository.py index 4cc0bb8e86d8a07594399250e4a13c4e7397edc9..3be7488862cc8db7ec743ee9496597ca4ee24cf5 100644 --- a/qt/python/mantidqt/widgets/test/test_scriptrepository.py +++ b/qt/python/mantidqt/widgets/test/test_scriptrepository.py @@ -7,8 +7,7 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function, - unicode_literals) + import unittest diff --git a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/__init__.py b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/__init__.py +++ b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/presenter.py b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/presenter.py index 14c9052fb712f1760ed06c81e7340ab62e360737..e51c888c9ac9ef3babdda06c3b48752442544c0a 100644 --- a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/presenter.py +++ b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from matplotlib.collections import PolyCollection from mantid.plots import datafunctions diff --git a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/__init__.py b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/__init__.py index b105f6a10f2dd8d2e7665b7edabde3a24caa287b..4370b7d972d02421b34adb29127a111a345e8a8b 100644 --- a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/__init__.py +++ b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/test_waterfallplotfillareadialogpresenter.py b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/test_waterfallplotfillareadialogpresenter.py index 3d1b5c554cc1b679ac8f5d07023a6e06e72d4dcd..586214700bc495129e2d5bbfd6d480ce733f198e 100644 --- a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/test_waterfallplotfillareadialogpresenter.py +++ b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/test/test_waterfallplotfillareadialogpresenter.py @@ -6,15 +6,13 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import unittest from matplotlib.collections import PolyCollection from matplotlib.pyplot import figure from mantid.plots import datafunctions -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.widgets.waterfallplotfillareadialog.presenter import WaterfallPlotFillAreaDialogPresenter diff --git a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/view.py b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/view.py index 84a54916f0b5a2b0725460fb91a56a537a099bac..3108abf11e281faaf1d5262a1fbc41f50fc5d477 100644 --- a/qt/python/mantidqt/widgets/waterfallplotfillareadialog/view.py +++ b/qt/python/mantidqt/widgets/waterfallplotfillareadialog/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtGui import QIcon from qtpy.QtWidgets import QDialog diff --git a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/__init__.py b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/__init__.py index d4649f5e6d8bb07eea47f10137cb8dbc8c8b3cb0..b4bf0064ff36baea47116c7d1090b9da96e3ebdd 100644 --- a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/__init__.py +++ b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/presenter.py b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/presenter.py index 10401c4e3e3c5438524408cababa6e7f8def6f7c..8a22ab17dd602af0443ff2d36c7e59a3ab8933c0 100644 --- a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/presenter.py +++ b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from mantidqt.widgets.waterfallplotoffsetdialog.view import WaterfallPlotOffsetDialogView diff --git a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/__init__.py b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/__init__.py index b105f6a10f2dd8d2e7665b7edabde3a24caa287b..4370b7d972d02421b34adb29127a111a345e8a8b 100644 --- a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/__init__.py +++ b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/__init__.py @@ -5,5 +5,3 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. - -from __future__ import (absolute_import, unicode_literals) diff --git a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/test_waterfallplotoffsetdialogpresenter.py b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/test_waterfallplotoffsetdialogpresenter.py index f2c2e1de134f1259d8872fe95095dba80c47fd80..a197b4cb9eba49f10ab3ee18552cab10d0ef5f29 100644 --- a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/test_waterfallplotoffsetdialogpresenter.py +++ b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/test/test_waterfallplotoffsetdialogpresenter.py @@ -6,14 +6,12 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - import unittest from matplotlib.pyplot import figure from mantid.plots import MantidAxes # noqa -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.widgets.waterfallplotoffsetdialog.presenter import WaterfallPlotOffsetDialogPresenter diff --git a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/view.py b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/view.py index 5f10de04bc9580e61f026fde3133ffa4fb4b98ee..b4441f6558f75a960fdc5087a81e2e799e4260d6 100644 --- a/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/view.py +++ b/qt/python/mantidqt/widgets/waterfallplotoffsetdialog/view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - from qtpy.QtCore import Qt from qtpy.QtGui import QIcon from qtpy.QtWidgets import QDialog diff --git a/qt/python/mantidqt/widgets/workspacedisplay/__init__.py b/qt/python/mantidqt/widgets/workspacedisplay/__init__.py index 2a0da4d3236beba7b1c2c7db9aaacf47084f4252..896aed8278b6ac9ec3d58b34e7343ae4d0def834 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/__init__.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/__init__.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, unicode_literals) - # 3rdparty imports from qtpy import PYQT4 diff --git a/qt/python/mantidqt/widgets/workspacedisplay/data_copier.py b/qt/python/mantidqt/widgets/workspacedisplay/data_copier.py index a8e51b624028283099fc17f7cb2566f72b85ef78..a1d50522cdb74416d8f4f1c6aada3600647b06d9 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/data_copier.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/data_copier.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, print_function) - from qtpy import QtGui from qtpy.QtWidgets import QMessageBox diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/model.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/model.py index 159247f38d5b378ca794682dce3682d6408519f5..9aaa549df62b4a7d32b9354d6d20aa2f2de2836e 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/model.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/model.py @@ -8,8 +8,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - from mantid.api import MatrixWorkspace from mantid.dataobjects import EventWorkspace, Workspace2D from mantidqt.widgets.workspacedisplay.matrix.table_view_model import MatrixWorkspaceTableViewModel, \ diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/presenter.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/presenter.py index b31e8ab22087ee4d989d2b999f2e993a81003359..bca546995f302d83aca83d1f7a917453a6db6f28 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/presenter.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/presenter.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, division, print_function - from mantid.plots.utility import MantidAxType from mantidqt.widgets.observers.ads_observer import WorkspaceDisplayADSObserver from mantidqt.widgets.workspacedisplay.data_copier import DataCopier diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/table_view_model.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/table_view_model.py index acdc39da8466a9328a0f60d6b31382d20ffcf0a4..fe8403749c8e5169f7c91e68b6dee1eca284598e 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/table_view_model.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/table_view_model.py @@ -8,8 +8,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - from qtpy import QtGui from qtpy.QtCore import QVariant, Qt, QAbstractTableModel from enum import Enum diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_io.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_io.py index 3260175104876fe9ac61263302258006da032421..66e59e648b6a5bf0800fad065881499a27bb035e 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_io.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_io.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. # -from __future__ import absolute_import - import unittest from mantidqt.utils.qt.testing import start_qapplication diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_model.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_model.py index db27c672e9941fe2787fe49d0c88d0f4f78dffb5..3fcd61060034291e1dc4242bf0711668e45659a5 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_model.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_model.py @@ -7,11 +7,9 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantid.simpleapi import CreateSampleWorkspace from mantidqt.utils.testing.mocks.mock_mantid import MockWorkspace from mantidqt.widgets.workspacedisplay.matrix.model import MatrixWorkspaceDisplayModel diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_presenter.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_presenter.py index a77180a93d094ebc055d2f4fb8034a37d0093ad5..7d17e1f2a7b6aa1feb5c8242ff5f02588cd8cd41 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_presenter.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_presenter.py @@ -7,13 +7,11 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import unittest from qtpy.QtWidgets import QStatusBar -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from mantidqt.utils.testing.mocks.mock_mantid import MockWorkspace from mantidqt.utils.testing.mocks.mock_matrixworkspacedisplay import MockMatrixWorkspaceDisplayView from mantidqt.utils.testing.mocks.mock_qt import MockQModelIndex, MockQTableView diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_table_view_model.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_table_view_model.py index 735478410934f3c71ec27fba3f700fedd218afd6..ffd71c7b7b0f3c401e2ebc7cf22406173ca0c639 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_table_view_model.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_table_view_model.py @@ -7,15 +7,13 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, absolute_import, division, division, print_function, print_function - import unittest import qtpy from qtpy import QtCore from qtpy.QtCore import Qt -from mantid.py3compat.mock import MagicMock, Mock, call +from unittest.mock import MagicMock, Mock, call from mantidqt.utils.testing.mocks.mock_mantid import AXIS_INDEX_FOR_HORIZONTAL, AXIS_INDEX_FOR_VERTICAL, MockMantidAxis, \ MockMantidSymbol, MockMantidUnit, MockSpectrum, MockWorkspace from mantidqt.utils.testing.mocks.mock_qt import MockQModelIndex diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_view.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_view.py index 3e6e906b83da15fe3377856e2cf250438f8f1b65..7800c021a016ab229baded1b99dc5d57bb500895 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_view.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/test/test_matrixworkspacedisplay_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import absolute_import - import unittest from mantid.simpleapi import CreateSampleWorkspace diff --git a/qt/python/mantidqt/widgets/workspacedisplay/matrix/view.py b/qt/python/mantidqt/widgets/workspacedisplay/matrix/view.py index ddca1f42eb15301b57066abc8a26993ed0d59c35..fad62358e4e27b3491ba7fc2bbe6fe2691ac8668 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/matrix/view.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/matrix/view.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - from functools import partial from qtpy import QtGui diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/error_column.py b/qt/python/mantidqt/widgets/workspacedisplay/table/error_column.py index 410006c5cb5fd0d2927a5d8882317fb5bbe7cad6..a06426ed88f0daa870732e4a6600f68fd8c24ccd 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/error_column.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/error_column.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package. -from __future__ import absolute_import class ErrorColumn: diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/marked_columns.py b/qt/python/mantidqt/widgets/workspacedisplay/table/marked_columns.py index 3cdd9b938c1a1865fb495b7b6633a00650ca521f..0d3447ebb8d28c9fdebdc7525a85c7ada3528666 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/marked_columns.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/marked_columns.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package. -from __future__ import absolute_import class MarkedColumns: diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/model.py b/qt/python/mantidqt/widgets/workspacedisplay/table/model.py index 99738ce70c2f3954e29dedcaa1a1a4cf299bb215..8d1d5e3f4e3c6b9b3857e9522cb2abc22f82b64d 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/model.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/model.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # coding=utf-8 # This file is part of the mantidqt package. -from __future__ import (absolute_import, division, print_function) - from mantid.dataobjects import PeaksWorkspace, TableWorkspace from mantid.kernel import V3D from mantid.simpleapi import DeleteTableRows, SortPeaksWorkspace, SortTableWorkspace, StatisticsOfTableWorkspace diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/presenter.py b/qt/python/mantidqt/widgets/workspacedisplay/table/presenter.py index ebf0f80798eccadd22ab986c91e28b7ea76d2ce4..99326805af8421a213b69489bf67c80881aeb391 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/presenter.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of mantidqt package. -from __future__ import absolute_import, division, print_function - from functools import partial from qtpy.QtCore import Qt diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_io.py b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_io.py index 3f27e21eca97bc43ab3c46b803d89bf6fa947dbd..c84680bf59db79c3436925a60f607a4a42c3a75e 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_io.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_io.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. # -from __future__ import (absolute_import, print_function) - import unittest from mantidqt.utils.qt.testing import start_qapplication diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_marked_columns.py b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_marked_columns.py index 324f2c0ff30a472ff0474a5299803ca784de23b8..6d29940a419b9fecd9c15e03afa291691aba2773 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_marked_columns.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_marked_columns.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import unittest from itertools import permutations diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_model.py b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_model.py index fcd8ad23220319424c63246f32038eeb883826ae..a856738438be04e18788a1bd1ad5eadba48bd104 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_model.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_model.py @@ -7,13 +7,11 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import functools import unittest from mantid.kernel import V3D -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from mantidqt.utils.testing.mocks.mock_mantid import MockWorkspace from mantidqt.utils.testing.strict_mock import StrictMock from mantidqt.widgets.workspacedisplay.table.model import TableWorkspaceColumnTypeMapping, TableWorkspaceDisplayModel diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_presenter.py b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_presenter.py index 682f09c1820a8a6f0251f6888b28463ac9b635b3..9e80be240af4503143229abbabc4c83aa5a28507 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_presenter.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_presenter.py @@ -7,13 +7,11 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import unittest from qtpy.QtWidgets import QStatusBar -from mantid.py3compat.mock import Mock, call, patch +from unittest.mock import Mock, call, patch from mantidqt.utils.testing.mocks.mock_mantid import MockWorkspace from mantidqt.utils.testing.mocks.mock_plotlib import MockAx, MockPlotLib from mantidqt.utils.testing.mocks.mock_qt import MockQModelIndex, MockQSelectionModel diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_view.py b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_view.py index c2744fbc89393f7cb701ef2105a401aa1fc7c95a..e51fa582887960dadb686d232630042263e7db4e 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_view.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, print_function) - import unittest from qtpy.QtWidgets import QApplication diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_workbench_table_widget_item.py b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_workbench_table_widget_item.py index b21691ebf17459cd03d95c2f8f0c0c65d64ea590..2a9c7ae5cd7e8ab1d7bddab0415dcbc219928e04 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_workbench_table_widget_item.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/test/test_tableworkspacedisplay_workbench_table_widget_item.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, division, print_function) - import unittest from qtpy.QtCore import Qt diff --git a/qt/python/mantidqt/widgets/workspacedisplay/table/view.py b/qt/python/mantidqt/widgets/workspacedisplay/table/view.py index dc7d2874e9a0cc643f3892ab8e5c916dd9cf9a30..971f0b66ccf37a9c7c2971c69eb19a2355ff7113 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/table/view.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/table/view.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantidqt package. -from __future__ import (absolute_import, division, print_function) - import sys from functools import partial diff --git a/qt/python/mantidqt/widgets/workspacedisplay/test/test_data_copier.py b/qt/python/mantidqt/widgets/workspacedisplay/test/test_data_copier.py index b95ab45e14f6f8ad5ff5b99238f9eb0daf8c0211..70b5d28264b1b5bec85b5455e5ff66334a61f172 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/test/test_data_copier.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/test/test_data_copier.py @@ -7,7 +7,7 @@ # This file is part of the mantid workbench. from unittest import TestCase -from mantid.py3compat.mock import Mock, patch +from unittest.mock import Mock, patch from qtpy.QtWidgets import QMessageBox from mantidqt.widgets.workspacedisplay.data_copier import DataCopier diff --git a/qt/python/mantidqt/widgets/workspacedisplay/test/test_user_notifier.py b/qt/python/mantidqt/widgets/workspacedisplay/test/test_user_notifier.py index 4a2a244d43df151d98c177de11b6c05d13ec81db..fc903200df9ebec1e4a09707e8c620317d60539d 100644 --- a/qt/python/mantidqt/widgets/workspacedisplay/test/test_user_notifier.py +++ b/qt/python/mantidqt/widgets/workspacedisplay/test/test_user_notifier.py @@ -8,7 +8,7 @@ import sys import unittest -from mantid.py3compat.mock import patch +from unittest.mock import patch from mantidqt.utils.testing.mocks.mock_qt import MockQStatusBar from mantidqt.widgets.workspacedisplay.user_notifier import UserNotifier diff --git a/qt/python/mantidqt/widgets/workspacewidget/algorithmhistorywindow.py b/qt/python/mantidqt/widgets/workspacewidget/algorithmhistorywindow.py index e811f53c2ffb73ced762f5b015f5ab1e45e6b8ce..1a4366a64ace66490220aedaf00b121578057f8a 100644 --- a/qt/python/mantidqt/widgets/workspacewidget/algorithmhistorywindow.py +++ b/qt/python/mantidqt/widgets/workspacewidget/algorithmhistorywindow.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import (absolute_import, unicode_literals) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/widgets/workspacewidget/mantidtreemodel.py b/qt/python/mantidqt/widgets/workspacewidget/mantidtreemodel.py index 6dc646142c82dfcf0d8ce20eb03f030d279b5a15..1f8498b6bde987fbdbc9e7ca881540304510a631 100644 --- a/qt/python/mantidqt/widgets/workspacewidget/mantidtreemodel.py +++ b/qt/python/mantidqt/widgets/workspacewidget/mantidtreemodel.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import) - from mantidqt.utils.qt import import_qt diff --git a/qt/python/mantidqt/widgets/workspacewidget/test/test_workspacetreewidget.py b/qt/python/mantidqt/widgets/workspacewidget/test/test_workspacetreewidget.py index 18c0a2ad53a1a2a084c1ce409760208a3618a709..9b1187b72fc6b1e484cb0ac6c9437b129355bf0f 100644 --- a/qt/python/mantidqt/widgets/workspacewidget/test/test_workspacetreewidget.py +++ b/qt/python/mantidqt/widgets/workspacewidget/test/test_workspacetreewidget.py @@ -7,8 +7,6 @@ # This file is part of the mantid workbench. # # -from __future__ import absolute_import, print_function - import unittest from mantidqt.widgets.workspacewidget.workspacetreewidget import WorkspaceTreeWidget diff --git a/qt/python/mantidqt/widgets/workspacewidget/workspacetreewidget.py b/qt/python/mantidqt/widgets/workspacewidget/workspacetreewidget.py index d099ad33ed47a547a15dad98afae709dbaa7835f..2810a33ba806297db3cdb782c59292af052cc022 100644 --- a/qt/python/mantidqt/widgets/workspacewidget/workspacetreewidget.py +++ b/qt/python/mantidqt/widgets/workspacewidget/workspacetreewidget.py @@ -7,8 +7,6 @@ # This file is part of the mantidqt package # # -from __future__ import (absolute_import, unicode_literals) - from mantidqt.utils.qt import import_qt WorkspaceTreeWidget = import_qt('..._common', 'mantidqt.widgets.workspacewidget', 'WorkspaceTreeWidgetSimple') diff --git a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp index 5481fdba6195771225d6ba1300c3e17a2d8dbe40..916da8260701fbd5b9086ad92dd11ade90128e2e 100644 --- a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp +++ b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.cpp @@ -11,6 +11,7 @@ #include <QSizePolicy> #include <QSpacerItem> #include <QVBoxLayout> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -90,8 +91,8 @@ void ALFCustomInstrumentView::setupAnalysisPane( BaseCustomInstrumentView::setupInstrumentAnalysisSplitters(analysis); } -void ALFCustomInstrumentView::addSpectrum(std::string wsName) { - m_analysisPane->addSpectrum(wsName); +void ALFCustomInstrumentView::addSpectrum(const std::string &wsName) { + m_analysisPane->addSpectrum(std::move(wsName)); } } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h index 99d71e6ef74d6667a34f0865de816ede92f36f2d..5eec9fbc802e664671758c069f15304491dbd7f6 100644 --- a/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h +++ b/qt/scientific_interfaces/Direct/ALFCustomInstrumentView.h @@ -35,7 +35,7 @@ public: &binders) override; void addObserver(std::tuple<std::string, Observer *> &listener) override; - void addSpectrum(std::string wsName); + void addSpectrum(const std::string &wsName); void setupAnalysisPane(MantidWidgets::PlotFitAnalysisPaneView *analysis); public slots: diff --git a/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp b/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp index b381d9a24b91fafb1554fc52b395f10d38b77689..6a49d01388e049238a031193f19f921f99203099 100644 --- a/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp +++ b/qt/scientific_interfaces/DynamicPDF/DPDFFitControl.cpp @@ -23,6 +23,7 @@ #include <QPushButton> #include <QSettings> #include <QSignalMapper> +#include <utility> namespace { Mantid::Kernel::Logger g_log("DynamicPDF"); @@ -312,7 +313,7 @@ void FitControl::fitIndividual(const bool &isEvaluation) { * @param fun A function from which to retrieve the parameters */ void FitControl::updateFunctionBrowser(Mantid::API::IFunction_sptr fun) { - m_functionBrowser->setFunction(fun); + m_functionBrowser->setFunction(std::move(fun)); } /* diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24e3c22e00b125f8f7f52e95655bfb4b0c4d851a --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.cpp @@ -0,0 +1,609 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffFittingModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/ITableWorkspace_fwd.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/Run.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidAPI/WorkspaceGroup.h" +#include "MantidKernel/PropertyWithValue.h" + +#include <algorithm> +#include <numeric> + +using namespace Mantid; + +namespace { // helpers + +bool isDigit(const std::string &text) { + return std::all_of(text.cbegin(), text.cend(), ::isdigit); +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +void EnggDiffFittingModel::addFocusedWorkspace( + const RunLabel &runLabel, const API::MatrixWorkspace_sptr &ws, + const std::string &filename) { + m_focusedWorkspaceMap.add(runLabel, ws); + m_wsFilenameMap.add(runLabel, filename); +} + +void EnggDiffFittingModel::addFitResults( + const RunLabel &runLabel, const Mantid::API::ITableWorkspace_sptr &ws) { + m_fitParamsMap.add(runLabel, ws); +} + +const std::string & +EnggDiffFittingModel::getWorkspaceFilename(const RunLabel &runLabel) const { + return m_wsFilenameMap.get(runLabel); +} + +Mantid::API::ITableWorkspace_sptr +EnggDiffFittingModel::getFitResults(const RunLabel &runLabel) const { + return m_fitParamsMap.get(runLabel); +} + +namespace { + +template <size_t S, typename T> +void removeFromRunMapAndADS(const RunLabel &runLabel, RunMap<S, T> &map, + Mantid::API::AnalysisDataServiceImpl &ADS) { + if (map.contains(runLabel)) { + const auto &name = map.get(runLabel)->getName(); + if (ADS.doesExist(name)) { + ADS.remove(name); + } + map.remove(runLabel); + } +} + +} // anonymous namespace + +void EnggDiffFittingModel::removeRun(const RunLabel &runLabel) { + m_wsFilenameMap.remove(runLabel); + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + removeFromRunMapAndADS(runLabel, m_focusedWorkspaceMap, ADS); + removeFromRunMapAndADS(runLabel, m_fittedPeaksMap, ADS); + removeFromRunMapAndADS(runLabel, m_alignedWorkspaceMap, ADS); + removeFromRunMapAndADS(runLabel, m_fitParamsMap, ADS); +} + +void EnggDiffFittingModel::setDifcTzero( + const RunLabel &runLabel, + const std::vector<GSASCalibrationParms> &calibParams) { + auto ws = getFocusedWorkspace(runLabel); + auto &run = ws->mutableRun(); + const std::string units = "none"; + + if (calibParams.empty()) { + run.addProperty<double>("difc", DEFAULT_DIFC, units, true); + run.addProperty<double>("difa", DEFAULT_DIFA, units, true); + run.addProperty<double>("tzero", DEFAULT_TZERO, units, true); + } else { + GSASCalibrationParms params(0, 0.0, 0.0, 0.0); + const auto found = std::find_if(calibParams.cbegin(), calibParams.cend(), + [&runLabel](const auto ¶mSet) { + return paramSet.bankid == runLabel.bank; + }); + if (found != calibParams.cend()) { + params = *found; + } + if (params.difc == 0) { + params = calibParams.front(); + } + + run.addProperty<double>("difc", params.difc, units, true); + run.addProperty<double>("difa", params.difa, units, false); + run.addProperty<double>("tzero", params.tzero, units, false); + } +} + +void EnggDiffFittingModel::enggFitPeaks(const RunLabel &runLabel, + const std::string &expectedPeaks) { + const auto ws = getFocusedWorkspace(runLabel); + auto enggFitPeaksAlg = + Mantid::API::AlgorithmManager::Instance().create("EnggFitPeaks"); + + enggFitPeaksAlg->initialize(); + enggFitPeaksAlg->setProperty("InputWorkspace", ws); + if (!expectedPeaks.empty()) { + enggFitPeaksAlg->setProperty("ExpectedPeaks", expectedPeaks); + } + enggFitPeaksAlg->setProperty("FittedPeaks", FIT_RESULTS_TABLE_NAME); + enggFitPeaksAlg->execute(); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + const auto fitResultsTable = + ADS.retrieveWS<API::ITableWorkspace>(FIT_RESULTS_TABLE_NAME); + addFitResults(runLabel, fitResultsTable); +} + +void EnggDiffFittingModel::saveFitResultsToHDF5( + const std::vector<RunLabel> &runLabels, const std::string &filename) const { + std::vector<std::string> inputWorkspaces; + inputWorkspaces.reserve(runLabels.size()); + std::vector<std::string> runNumbers; + runNumbers.reserve(runLabels.size()); + std::vector<long> bankIDs; + bankIDs.reserve(runLabels.size()); + + for (const auto &runLabel : runLabels) { + const auto ws = getFitResults(runLabel); + const auto clonedWSName = "enggggui_fit_params_" + runLabel.runNumber + + "_" + std::to_string(runLabel.bank); + cloneWorkspace(ws, clonedWSName); + inputWorkspaces.emplace_back(clonedWSName); + runNumbers.emplace_back(runLabel.runNumber); + bankIDs.emplace_back(static_cast<long>(runLabel.bank)); + } + + auto saveAlg = Mantid::API::AlgorithmManager::Instance().create( + "EnggSaveSinglePeakFitResultsToHDF5"); + saveAlg->initialize(); + saveAlg->setProperty("InputWorkspaces", inputWorkspaces); + saveAlg->setProperty("RunNumbers", runNumbers); + saveAlg->setProperty("BankIDs", bankIDs); + saveAlg->setProperty("Filename", filename); + saveAlg->execute(); + + auto &ADS = API::AnalysisDataService::Instance(); + for (const auto &wsName : inputWorkspaces) { + ADS.remove(wsName); + } +} + +void EnggDiffFittingModel::createFittedPeaksWS(const RunLabel &runLabel) { + const auto fitFunctionParams = getFitResults(runLabel); + const auto focusedWS = getFocusedWorkspace(runLabel); + + const size_t numberOfPeaks = fitFunctionParams->rowCount(); + + for (size_t i = 0; i < numberOfPeaks; ++i) { + const auto functionDescription = createFunctionString(fitFunctionParams, i); + double startX, endX; + std::tie(startX, endX) = getStartAndEndXFromFitParams(fitFunctionParams, i); + + const std::string singlePeakWSName = + "__engggui_fitting_single_peak_" + std::to_string(i); + + evaluateFunction(functionDescription, focusedWS, singlePeakWSName, startX, + endX); + + cropWorkspace(singlePeakWSName, singlePeakWSName, 1, 1); + + rebinToFocusedWorkspace(singlePeakWSName, runLabel, singlePeakWSName); + + if (i == 0) { + cloneWorkspace(focusedWS, FITTED_PEAKS_WS_NAME); + setDataToClonedWS(singlePeakWSName, FITTED_PEAKS_WS_NAME); + } else { + const std::string clonedWSName = + "__engggui_cloned_peaks_" + std::to_string(i); + cloneWorkspace(focusedWS, clonedWSName); + setDataToClonedWS(singlePeakWSName, clonedWSName); + + appendSpectra(FITTED_PEAKS_WS_NAME, clonedWSName); + } + } + + const std::string alignedWSName = FOCUSED_WS_NAME + "_d"; + cloneWorkspace(focusedWS, alignedWSName); + alignDetectors(alignedWSName, alignedWSName); + + alignDetectors(FITTED_PEAKS_WS_NAME, FITTED_PEAKS_WS_NAME); + + const auto &ADS = Mantid::API::AnalysisDataService::Instance(); + + const auto fittedPeaksWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(FITTED_PEAKS_WS_NAME); + m_fittedPeaksMap.add(runLabel, fittedPeaksWS); + + const auto alignedFocusedWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(alignedWSName); + m_alignedWorkspaceMap.add(runLabel, alignedFocusedWS); +} + +size_t EnggDiffFittingModel::getNumFocusedWorkspaces() const { + return m_focusedWorkspaceMap.size(); +} + +bool EnggDiffFittingModel::hasFittedPeaksForRun( + const RunLabel &runLabel) const { + return m_fittedPeaksMap.contains(runLabel); +} + +Mantid::API::MatrixWorkspace_sptr +EnggDiffFittingModel::getAlignedWorkspace(const RunLabel &runLabel) const { + return m_alignedWorkspaceMap.get(runLabel); +} + +Mantid::API::MatrixWorkspace_sptr +EnggDiffFittingModel::getFittedPeaksWS(const RunLabel &runLabel) const { + return m_fittedPeaksMap.get(runLabel); +} + +void EnggDiffFittingModel::evaluateFunction( + const std::string &function, + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName, const double startX, const double endX) { + + auto evalFunctionAlg = + Mantid::API::AlgorithmManager::Instance().create("EvaluateFunction"); + evalFunctionAlg->initialize(); + evalFunctionAlg->setProperty("Function", function); + evalFunctionAlg->setProperty("InputWorkspace", inputWS); + evalFunctionAlg->setProperty("OutputWorkspace", outputWSName); + evalFunctionAlg->setProperty("StartX", startX); + evalFunctionAlg->setProperty("EndX", endX); + evalFunctionAlg->execute(); +} + +void EnggDiffFittingModel::cropWorkspace(const std::string &inputWSName, + const std::string &outputWSName, + const int startWSIndex, + const int endWSIndex) { + auto cropWSAlg = + Mantid::API::AlgorithmManager::Instance().create("CropWorkspace"); + cropWSAlg->initialize(); + cropWSAlg->setProperty("InputWorkspace", inputWSName); + cropWSAlg->setProperty("OutputWorkspace", outputWSName); + cropWSAlg->setProperty("StartWorkspaceIndex", startWSIndex); + cropWSAlg->setProperty("EndWorkspaceIndex", endWSIndex); + cropWSAlg->execute(); +} + +void EnggDiffFittingModel::rebinToFocusedWorkspace( + const std::string &wsToRebinName, const RunLabel &runLabelToMatch, + const std::string &outputWSName) { + auto rebinToWSAlg = + Mantid::API::AlgorithmManager::Instance().create("RebinToWorkspace"); + + rebinToWSAlg->initialize(); + rebinToWSAlg->setProperty("WorkspaceToRebin", wsToRebinName); + + const auto wsToMatch = getFocusedWorkspace(runLabelToMatch); + rebinToWSAlg->setProperty("WorkspaceToMatch", wsToMatch); + rebinToWSAlg->setProperty("OutputWorkspace", outputWSName); + rebinToWSAlg->execute(); +} + +void EnggDiffFittingModel::cloneWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const { + auto cloneWSAlg = + Mantid::API::AlgorithmManager::Instance().create("CloneWorkspace"); + cloneWSAlg->initialize(); + cloneWSAlg->setProperty("InputWorkspace", inputWorkspace); + cloneWSAlg->setProperty("OutputWorkspace", outputWSName); + cloneWSAlg->execute(); +} + +void EnggDiffFittingModel::cloneWorkspace( + const Mantid::API::ITableWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const { + auto cloneWSAlg = + Mantid::API::AlgorithmManager::Instance().create("CloneWorkspace"); + cloneWSAlg->initialize(); + cloneWSAlg->setProperty("InputWorkspace", inputWorkspace); + cloneWSAlg->setProperty("OutputWorkspace", outputWSName); + cloneWSAlg->execute(); +} + +void EnggDiffFittingModel::setDataToClonedWS(const std::string &wsToCopyName, + const std::string &targetWSName) { + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + auto wsToCopy = ADS.retrieveWS<Mantid::API::MatrixWorkspace>(wsToCopyName); + auto currentClonedWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(targetWSName); + currentClonedWS->mutableY(0) = wsToCopy->y(0); + currentClonedWS->mutableE(0) = wsToCopy->e(0); +} + +void EnggDiffFittingModel::appendSpectra(const std::string &ws1Name, + const std::string &ws2Name) const { + auto appendSpectraAlg = + Mantid::API::AlgorithmManager::Instance().create("AppendSpectra"); + + appendSpectraAlg->initialize(); + appendSpectraAlg->setProperty("InputWorkspace1", ws1Name); + appendSpectraAlg->setProperty("InputWorkspace2", ws2Name); + appendSpectraAlg->setProperty("OutputWorkspace", ws1Name); + appendSpectraAlg->execute(); +} + +std::tuple<double, double, double> EnggDiffFittingModel::getDifcDifaTzero( + const Mantid::API::MatrixWorkspace_const_sptr &ws) { + const auto run = ws->run(); + + const auto difc = run.getPropertyValueAsType<double>("difc"); + const auto difa = run.getPropertyValueAsType<double>("difa"); + const auto tzero = run.getPropertyValueAsType<double>("tzero"); + + return std::tuple<double, double, double>(difc, difa, tzero); +} + +Mantid::API::ITableWorkspace_sptr +EnggDiffFittingModel::createCalibrationParamsTable( + const Mantid::API::MatrixWorkspace_const_sptr &inputWS) { + double difc, difa, tzero; + std::tie(difc, difa, tzero) = getDifcDifaTzero(inputWS); + + auto calibrationParamsTable = + Mantid::API::WorkspaceFactory::Instance().createTable(); + + calibrationParamsTable->addColumn("int", "detid"); + calibrationParamsTable->addColumn("double", "difc"); + calibrationParamsTable->addColumn("double", "difa"); + calibrationParamsTable->addColumn("double", "tzero"); + + Mantid::API::TableRow row = calibrationParamsTable->appendRow(); + const auto &spectrum = inputWS->getSpectrum(0); + + Mantid::detid_t detID = *(spectrum.getDetectorIDs().cbegin()); + row << detID << difc << difa << tzero; + return calibrationParamsTable; +} + +void EnggDiffFittingModel::convertFromDistribution( + const Mantid::API::MatrixWorkspace_sptr &inputWS) { + auto convertFromDistAlg = Mantid::API::AlgorithmManager::Instance().create( + "ConvertFromDistribution"); + convertFromDistAlg->initialize(); + convertFromDistAlg->setProperty("Workspace", inputWS); + convertFromDistAlg->execute(); +} + +void EnggDiffFittingModel::alignDetectors(const std::string &inputWSName, + const std::string &outputWSName) { + const auto &ADS = Mantid::API::AnalysisDataService::Instance(); + const auto inputWS = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(inputWSName); + alignDetectors(inputWS, outputWSName); +} + +void EnggDiffFittingModel::alignDetectors( + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName) { + const auto calibrationParamsTable = createCalibrationParamsTable(inputWS); + + if (inputWS->isDistribution()) { + convertFromDistribution(inputWS); + } + + auto alignDetAlg = + Mantid::API::AlgorithmManager::Instance().create("AlignDetectors"); + alignDetAlg->initialize(); + alignDetAlg->setProperty("InputWorkspace", inputWS); + alignDetAlg->setProperty("OutputWorkspace", outputWSName); + alignDetAlg->setProperty("CalibrationWorkspace", calibrationParamsTable); + alignDetAlg->execute(); +} + +void EnggDiffFittingModel::loadWorkspace(const std::string &filename, + const std::string &wsName) { + auto loadAlg = API::AlgorithmManager::Instance().create("Load"); + loadAlg->setProperty("Filename", filename); + loadAlg->setProperty("OutputWorkspace", wsName); + loadAlg->execute(); +} + +void EnggDiffFittingModel::renameWorkspace(const API::Workspace_sptr &inputWS, + const std::string &newName) const { + auto renameAlg = API::AlgorithmManager::Instance().create("RenameWorkspace"); + renameAlg->setProperty("InputWorkspace", inputWS); + renameAlg->setProperty("OutputWorkspace", newName); + renameAlg->execute(); +} + +void EnggDiffFittingModel::groupWorkspaces( + const std::vector<std::string> &workspaceNames, + const std::string &outputWSName) { + auto groupAlg = API::AlgorithmManager::Instance().create("GroupWorkspaces"); + groupAlg->setProperty("InputWorkspaces", workspaceNames); + groupAlg->setProperty("OutputWorkspace", outputWSName); + groupAlg->execute(); +} + +API::MatrixWorkspace_sptr +EnggDiffFittingModel::getFocusedWorkspace(const RunLabel &runLabel) const { + return m_focusedWorkspaceMap.get(runLabel); +} + +void EnggDiffFittingModel::mergeTables( + const API::ITableWorkspace_sptr &tableToCopy, + const API::ITableWorkspace_sptr &targetTable) const { + for (size_t i = 0; i < tableToCopy->rowCount(); ++i) { + API::TableRow rowToCopy = tableToCopy->getRow(i); + API::TableRow newRow = targetTable->appendRow(); + + for (size_t j = 0; j < tableToCopy->columnCount(); ++j) { + double valueToCopy; + rowToCopy >> valueToCopy; + newRow << valueToCopy; + } + } +} + +void EnggDiffFittingModel::addAllFitResultsToADS() const { + auto fitParamsTable = Mantid::API::WorkspaceFactory::Instance().createTable(); + renameWorkspace(fitParamsTable, FIT_RESULTS_TABLE_NAME); + + const auto runLabels = getRunLabels(); + + for (const auto &runLabel : runLabels) { + const auto singleWSFitResults = getFitResults(runLabel); + + if (runLabel == *runLabels.begin()) { + // First element - copy column headings over + const auto columnHeaders = singleWSFitResults->getColumnNames(); + for (const auto &header : columnHeaders) { + fitParamsTable->addColumn("double", header); + } + } + mergeTables(singleWSFitResults, fitParamsTable); + } +} + +void EnggDiffFittingModel::addAllFittedPeaksToADS() const { + const auto runLabels = getRunLabels(); + if (runLabels.size() < 1) { + return; + } + const auto firstWSLabel = runLabels[0]; + auto fittedPeaksWS = getFittedPeaksWS(firstWSLabel); + cloneWorkspace(fittedPeaksWS, FITTED_PEAKS_WS_NAME); + + for (size_t i = 1; i < runLabels.size(); ++i) { + auto wsToAppend = getFittedPeaksWS(runLabels[i]); + appendSpectra(FITTED_PEAKS_WS_NAME, wsToAppend->getName()); + } +} + +namespace { + +std::string stripWSNameFromFilename(const std::string &fullyQualifiedFilename) { + std::vector<std::string> directories; + boost::split(directories, fullyQualifiedFilename, boost::is_any_of("\\/")); + const std::string filename = directories.back(); + std::vector<std::string> filenameSegments; + boost::split(filenameSegments, filename, boost::is_any_of(".")); + return filenameSegments[0]; +} +} // namespace + +void EnggDiffFittingModel::loadWorkspaces(const std::string &filenamesString) { + std::vector<std::string> filenames; + boost::split(filenames, filenamesString, boost::is_any_of(",")); + + std::vector<RunLabel> collectedRunLabels; + + for (const auto &filename : filenames) { + // Set ws name to filename first, in case we need to guess bank ID from it + const std::string temporaryWSName = stripWSNameFromFilename(filename); + loadWorkspace(filename, temporaryWSName); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + auto ws_test = ADS.retrieveWS<API::Workspace>(temporaryWSName); + const auto ws = boost::dynamic_pointer_cast<API::MatrixWorkspace>(ws_test); + if (!ws) { + throw std::invalid_argument("Workspace is not a matrix workspace."); + } + const auto bank = guessBankID(ws); + const auto runNumber = std::to_string(ws->getRunNumber()); + RunLabel runLabel(runNumber, bank); + + addFocusedWorkspace(runLabel, ws, filename); + collectedRunLabels.emplace_back(runLabel); + } + + if (collectedRunLabels.size() == 1) { + auto ws = getFocusedWorkspace(collectedRunLabels[0]); + renameWorkspace(ws, FOCUSED_WS_NAME); + } else { + std::vector<std::string> workspaceNames; + std::transform(collectedRunLabels.begin(), collectedRunLabels.end(), + std::back_inserter(workspaceNames), + [&](const RunLabel &runLabel) { + return getFocusedWorkspace(runLabel)->getName(); + }); + groupWorkspaces(workspaceNames, FOCUSED_WS_NAME); + } +} + +std::vector<RunLabel> EnggDiffFittingModel::getRunLabels() const { + return m_focusedWorkspaceMap.getRunLabels(); +} + +size_t EnggDiffFittingModel::guessBankID( + const API::MatrixWorkspace_const_sptr &ws) const { + const static std::string bankIDName = "bankid"; + if (ws->run().hasProperty(bankIDName)) { + const auto log = dynamic_cast<Kernel::PropertyWithValue<int> *>( + ws->run().getLogData(bankIDName)); + return boost::lexical_cast<size_t>(log->value()); + } + + // couldn't get it from sample logs - try using the old naming convention + const std::string name = ws->getName(); + std::vector<std::string> chunks; + boost::split(chunks, name, boost::is_any_of("_")); + if (!chunks.empty()) { + const bool isNum = isDigit(chunks.back()); + if (isNum) { + try { + return boost::lexical_cast<size_t>(chunks.back()); + } catch (boost::exception &) { + // If we get a bad cast or something goes wrong then + // the file is probably not what we were expecting + // so throw a runtime error + throw std::runtime_error( + "Failed to fit file: The data was not what is expected. " + "Does the file contain a focused workspace?"); + } + } + } + + throw std::runtime_error("Could not guess run number from input workspace. " + "Are you sure it has been focused correctly?"); +} + +std::string EnggDiffFittingModel::createFunctionString( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row) { + const auto A0 = fitFunctionParams->cell<double>(row, size_t(1)); + const auto A1 = fitFunctionParams->cell<double>(row, size_t(3)); + const auto I = fitFunctionParams->cell<double>(row, size_t(13)); + const auto A = fitFunctionParams->cell<double>(row, size_t(7)); + const auto B = fitFunctionParams->cell<double>(row, size_t(9)); + const auto X0 = fitFunctionParams->cell<double>(row, size_t(5)); + const auto S = fitFunctionParams->cell<double>(row, size_t(11)); + + const std::string function = + "name=LinearBackground,A0=" + boost::lexical_cast<std::string>(A0) + + ",A1=" + boost::lexical_cast<std::string>(A1) + + ";name=BackToBackExponential,I=" + boost::lexical_cast<std::string>(I) + + ",A=" + boost::lexical_cast<std::string>(A) + + ",B=" + boost::lexical_cast<std::string>(B) + + ",X0=" + boost::lexical_cast<std::string>(X0) + + ",S=" + boost::lexical_cast<std::string>(S); + return function; +} + +std::pair<double, double> EnggDiffFittingModel::getStartAndEndXFromFitParams( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row) { + const auto X0 = fitFunctionParams->cell<double>(row, size_t(5)); + const auto S = fitFunctionParams->cell<double>(row, size_t(11)); + const double windowLeft = 9; + const double windowRight = 12; + + const auto startX = X0 - (windowLeft * S); + const auto endX = X0 + (windowRight * S); + return std::pair<double, double>(startX, endX); +} + +const std::string EnggDiffFittingModel::FOCUSED_WS_NAME = + "engggui_fitting_focused_ws"; +const std::string EnggDiffFittingModel::FIT_RESULTS_TABLE_NAME = + "engggui_fitting_fitpeaks_params"; +const std::string EnggDiffFittingModel::FITTED_PEAKS_WS_NAME = + "engggui_fitting_single_peaks"; + +const double EnggDiffFittingModel::DEFAULT_DIFA = 0.0; +const double EnggDiffFittingModel::DEFAULT_DIFC = 18400.0; +const double EnggDiffFittingModel::DEFAULT_TZERO = 4.0; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.h new file mode 100644 index 0000000000000000000000000000000000000000..73d8b5f3f80d9d65cf007234cc493891c71183fb --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingModel.h @@ -0,0 +1,152 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggDiffFittingModel.h" +#include "IEnggDiffractionCalibration.h" +#include "RunMap.h" + +#include <array> +#include <unordered_map> + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffFittingModel + : public IEnggDiffFittingModel { + +public: + Mantid::API::MatrixWorkspace_sptr + getFocusedWorkspace(const RunLabel &runLabel) const override; + + Mantid::API::MatrixWorkspace_sptr + getAlignedWorkspace(const RunLabel &runLabel) const override; + + Mantid::API::MatrixWorkspace_sptr + getFittedPeaksWS(const RunLabel &runLabel) const override; + + Mantid::API::ITableWorkspace_sptr + getFitResults(const RunLabel &runLabel) const override; + + const std::string & + getWorkspaceFilename(const RunLabel &runLabel) const override; + + void removeRun(const RunLabel &runLabel) override; + + void loadWorkspaces(const std::string &filenames) override; + + std::vector<RunLabel> getRunLabels() const override; + + void + setDifcTzero(const RunLabel &runLabel, + const std::vector<GSASCalibrationParms> &calibParams) override; + + void enggFitPeaks(const RunLabel &runLabel, + const std::string &expectedPeaks) override; + + void saveFitResultsToHDF5(const std::vector<RunLabel> &runLabels, + const std::string &filename) const override; + + void createFittedPeaksWS(const RunLabel &runLabel) override; + + size_t getNumFocusedWorkspaces() const override; + + void addAllFitResultsToADS() const override; + + void addAllFittedPeaksToADS() const override; + + bool hasFittedPeaksForRun(const RunLabel &runLabel) const override; + +protected: + void addFocusedWorkspace(const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &ws, + const std::string &filename); + + void addFitResults(const RunLabel &runLabel, + const Mantid::API::ITableWorkspace_sptr &ws); + + void mergeTables(const Mantid::API::ITableWorkspace_sptr &tableToCopy, + const Mantid::API::ITableWorkspace_sptr &targetTable) const; + +private: + static const size_t MAX_BANKS = 3; + static const double DEFAULT_DIFC; + static const double DEFAULT_DIFA; + static const double DEFAULT_TZERO; + static const std::string FOCUSED_WS_NAME; + static const std::string FIT_RESULTS_TABLE_NAME; + static const std::string FITTED_PEAKS_WS_NAME; + + RunMap<MAX_BANKS, Mantid::API::MatrixWorkspace_sptr> m_focusedWorkspaceMap; + RunMap<MAX_BANKS, std::string> m_wsFilenameMap; + RunMap<MAX_BANKS, Mantid::API::ITableWorkspace_sptr> m_fitParamsMap; + RunMap<MAX_BANKS, Mantid::API::MatrixWorkspace_sptr> m_fittedPeaksMap; + RunMap<MAX_BANKS, Mantid::API::MatrixWorkspace_sptr> m_alignedWorkspaceMap; + + std::string createFunctionString( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row); + + std::pair<double, double> getStartAndEndXFromFitParams( + const Mantid::API::ITableWorkspace_sptr &fitFunctionParams, + const size_t row); + + void evaluateFunction(const std::string &function, + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName, const double startX, + const double endX); + + void cropWorkspace(const std::string &inputWSName, + const std::string &outputWSName, const int startWSIndex, + const int endWSIndex); + + void rebinToFocusedWorkspace(const std::string &wsToRebinName, + const RunLabel &runLabelToMatch, + const std::string &outputWSName); + + void cloneWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const; + + void cloneWorkspace(const Mantid::API::ITableWorkspace_sptr &inputWorkspace, + const std::string &outputWSName) const; + + void setDataToClonedWS(const std::string &wsToCopyName, + const std::string &targetWSName); + + void appendSpectra(const std::string &ws1Name, + const std::string &ws2Name) const; + + std::tuple<double, double, double> + getDifcDifaTzero(const Mantid::API::MatrixWorkspace_const_sptr &ws); + + Mantid::API::ITableWorkspace_sptr createCalibrationParamsTable( + const Mantid::API::MatrixWorkspace_const_sptr &inputWS); + + void + convertFromDistribution(const Mantid::API::MatrixWorkspace_sptr &inputWS); + + void alignDetectors(const std::string &inputWSName, + const std::string &outputWSName); + + void alignDetectors(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const std::string &outputWSName); + + void loadWorkspace(const std::string &filename, const std::string &wsName); + + void renameWorkspace(const Mantid::API::Workspace_sptr &inputWS, + const std::string &newName) const; + + void groupWorkspaces(const std::vector<std::string> &workspaceNames, + const std::string &outputWSName); + + size_t + guessBankID(const Mantid::API::MatrixWorkspace_const_sptr & /*ws*/) const; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6d24969f6b5a156fce07f4723efaa2a0e042fd85 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.cpp @@ -0,0 +1,745 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffFittingPresenter.h" +#include "EnggDiffFittingPresWorker.h" +#include "IEnggDiffFittingModel.h" +#include "MantidAPI/Algorithm.h" +#include "MantidAPI/Axis.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/Run.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" + +#include <boost/algorithm/string.hpp> +#include <boost/lexical_cast.hpp> +#include <cctype> +#include <fstream> +#include <utility> + +#include <Poco/DirectoryIterator.h> +#include <Poco/File.h> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace QwtHelper = API::QwtHelper; +namespace CustomInterfaces { + +namespace { +Mantid::Kernel::Logger g_log("EngineeringDiffractionGUI"); + +RunLabel runLabelFromListWidgetLabel(const std::string &listLabel) { + const size_t underscorePosition = listLabel.find_first_of("_"); + const auto runNumber = listLabel.substr(0, underscorePosition); + const auto bank = listLabel.substr(underscorePosition + 1); + + return RunLabel(runNumber, std::atoi(bank.c_str())); +} + +std::string listWidgetLabelFromRunLabel(const RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank); +} + +// Remove commas at the start and end of the string, +// as well as any adjacent to another (eg ,, gets corrected to ,) +std::string stripExtraCommas(std::string &expectedPeaks) { + if (!expectedPeaks.empty()) { + + g_log.debug() << "Validating the expected peak list.\n"; + + const auto comma = ','; + + for (size_t i = 0; i < expectedPeaks.size() - 1; i++) { + size_t j = i + 1; + + if (expectedPeaks[i] == comma && expectedPeaks[i] == expectedPeaks[j]) { + expectedPeaks.erase(j, 1); + i--; + + } else { + ++j; + } + } + + size_t strLength = expectedPeaks.length() - 1; + if (expectedPeaks.at(0) == ',') { + expectedPeaks.erase(0, 1); + strLength -= 1; + } + + if (expectedPeaks.at(strLength) == ',') { + expectedPeaks.erase(strLength, 1); + } + } + return expectedPeaks; +} + +std::string generateXAxisLabel(const Mantid::Kernel::Unit_const_sptr &unit) { + std::string label = unit->unitID(); + if (label == "TOF") { + label += " (us)"; + } else if (label == "dSpacing") { + label += " (A)"; + } + return label; +} +} // namespace + +/** + * Constructs a presenter for a fitting tab/widget view, which has a + * handle on the current calibration (produced and updated elsewhere). + * + * @param view the view that is attached to this presenter + * @param model the model that is attached to this presenter + * @param mainCalib provides the current calibration parameters/status + * @param mainParam provides current params and functions + */ +EnggDiffFittingPresenter::EnggDiffFittingPresenter( + IEnggDiffFittingView *view, std::unique_ptr<IEnggDiffFittingModel> model, + boost::shared_ptr<IEnggDiffractionCalibration> mainCalib, + boost::shared_ptr<IEnggDiffractionParam> mainParam) + : m_fittingFinishedOK(false), m_workerThread(nullptr), + m_mainCalib(std::move(mainCalib)), m_mainParam(std::move(mainParam)), + m_view(view), m_model(std::move(model)), m_viewHasClosed(false) {} + +EnggDiffFittingPresenter::~EnggDiffFittingPresenter() { cleanup(); } + +/** + * Close open sessions, kill threads etc., for a graceful window + * close/destruction + */ +void EnggDiffFittingPresenter::cleanup() { + // m_model->cleanup(); + + // this may still be running + if (m_workerThread) { + if (m_workerThread->isRunning()) { + g_log.notice() << "A fitting process is currently running, shutting " + "it down immediately...\n"; + m_workerThread->wait(10); + } + delete m_workerThread; + m_workerThread = nullptr; + } +} + +void EnggDiffFittingPresenter::notify( + IEnggDiffFittingPresenter::Notification notif) { + + // Check the view is valid - QT can send multiple notification + // signals in any order at any time. This means that it is possible + // to receive a shutdown signal and subsequently an input example + // for example. As we can't guarantee the state of the viewer + // after calling shutdown instead we shouldn't do anything after + if (m_viewHasClosed) { + return; + } + + switch (notif) { + + case IEnggDiffFittingPresenter::Start: + processStart(); + break; + + case IEnggDiffFittingPresenter::Load: + processLoad(); + break; + + case IEnggDiffFittingPresenter::FitPeaks: + processFitPeaks(); + break; + + case IEnggDiffFittingPresenter::FitAllPeaks: + processFitAllPeaks(); + break; + + case IEnggDiffFittingPresenter::addPeaks: + addPeakToList(); + break; + + case IEnggDiffFittingPresenter::browsePeaks: + browsePeaksToFit(); + break; + + case IEnggDiffFittingPresenter::savePeaks: + savePeakList(); + break; + + case IEnggDiffFittingPresenter::ShutDown: + processShutDown(); + break; + + case IEnggDiffFittingPresenter::LogMsg: + processLogMsg(); + break; + + case IEnggDiffFittingPresenter::selectRun: + processSelectRun(); + break; + + case IEnggDiffFittingPresenter::updatePlotFittedPeaks: + processUpdatePlotFitPeaks(); + break; + + case IEnggDiffFittingPresenter::removeRun: + processRemoveRun(); + break; + } +} + +std::vector<GSASCalibrationParms> +EnggDiffFittingPresenter::currentCalibration() const { + return m_mainCalib->currentCalibration(); +} + +Poco::Path +EnggDiffFittingPresenter::outFilesUserDir(const std::string &addToDir) const { + return m_mainParam->outFilesUserDir(addToDir); +} + +std::string EnggDiffFittingPresenter::userHDFRunFilename( + const std::string &runNumber) const { + return m_mainParam->userHDFRunFilename(runNumber); +} + +std::string EnggDiffFittingPresenter::userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const { + return m_mainParam->userHDFMultiRunFilename(runLabels); +} + +void EnggDiffFittingPresenter::startAsyncFittingWorker( + const std::vector<RunLabel> &runLabels, const std::string &expectedPeaks) { + + delete m_workerThread; + m_workerThread = new QThread(this); + EnggDiffFittingWorker *worker = + new EnggDiffFittingWorker(this, runLabels, expectedPeaks); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(fitting())); + connect(worker, SIGNAL(finished()), this, SLOT(fittingFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Takes a full file path as a string and attempts to get the base name + * of the file at that location and return it + * + * @param filePath The full path to get the basename of + * + * @return The base name (without ext) of the file + */ +std::string EnggDiffFittingPresenter::getBaseNameFromStr( + const std::string &filePath) const { + Poco::Path pocoPath = filePath; + return pocoPath.getBaseName(); +} + +void EnggDiffFittingPresenter::fittingFinished() { + if (!m_view) + return; + + if (m_fittingFinishedOK) { + + g_log.notice() << "The single peak fitting finished - the output " + "workspace is ready.\n"; + + m_view->showStatus("Single peak fitting process finished. Ready"); + + if (!m_view->listWidgetHasSelectedRow()) { + m_view->setFittingListWidgetCurrentRow(0); + } + + m_model->addAllFitResultsToADS(); + m_model->addAllFittedPeaksToADS(); + + try { + // should now plot the focused workspace when single peak fitting + // process fails + plotAlignedWorkspace(m_view->plotFittedPeaksEnabled()); + + } catch (std::runtime_error &re) { + g_log.error() << "Unable to finish the plotting of the graph for " + "engggui_fitting_focused_fitpeaks workspace. Error " + "description: " + + static_cast<std::string>(re.what()) + + " Please check also the log message for detail."; + } + g_log.notice() << "EnggDiffraction GUI: plotting of peaks for single peak " + "fits has completed. \n"; + + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + } else { + // Fitting failed log and tidy up + g_log.warning() << "The single peak fitting did not finish correctly. " + "Please check a focused file was selected."; + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + m_view->showStatus( + "Single peak fitting process did not complete successfully"); + } + // enable the GUI + m_view->enableFitAllButton(m_model->getNumFocusedWorkspaces() > 1); + m_view->enableCalibrateFocusFitUserActions(true); +} + +void EnggDiffFittingPresenter::processSelectRun() { updatePlot(); } + +void EnggDiffFittingPresenter::processStart() {} + +void EnggDiffFittingPresenter::processLoad() { + const std::string filenames = m_view->getFocusedFileNames(); + if (filenames.empty()) { + m_view->userWarning("No file selected", "Please enter filename(s) to load"); + return; + } + + try { + m_model->loadWorkspaces(filenames); + } catch (Poco::PathSyntaxException &ex) { + warnFileNotFound(ex); + return; + } catch (std::invalid_argument &ex) { + warnFileNotFound(ex); + return; + } catch (std::runtime_error &ex) { + warnFileNotFound(ex); + return; + } + + const auto runLabels = m_model->getRunLabels(); + std::vector<std::string> listWidgetLabels; + std::transform(runLabels.begin(), runLabels.end(), + std::back_inserter(listWidgetLabels), + [](const RunLabel &runLabel) { + return listWidgetLabelFromRunLabel(runLabel); + }); + m_view->enableFittingListWidget(true); + m_view->updateFittingListWidget(listWidgetLabels); + + m_view->enableFitAllButton(m_model->getNumFocusedWorkspaces() > 1); +} + +void EnggDiffFittingPresenter::processShutDown() { + m_viewHasClosed = true; + m_view->saveSettings(); + cleanup(); +} + +void EnggDiffFittingPresenter::processLogMsg() { + std::vector<std::string> msgs = m_view->logMsgs(); + for (const auto &msg : msgs) { + g_log.information() << msg << '\n'; + } +} + +void EnggDiffFittingPresenter::processUpdatePlotFitPeaks() { updatePlot(); } + +void EnggDiffFittingPresenter::processRemoveRun() { + const auto workspaceLabel = m_view->getFittingListWidgetCurrentValue(); + + if (workspaceLabel) { + const auto runLabel = runLabelFromListWidgetLabel(*workspaceLabel); + m_model->removeRun(runLabel); + + const auto runLabels = m_model->getRunLabels(); + std::vector<std::string> listWidgetLabels; + std::transform(runLabels.begin(), runLabels.end(), + std::back_inserter(listWidgetLabels), + [](const RunLabel &runLabel) { + return listWidgetLabelFromRunLabel(runLabel); + }); + m_view->updateFittingListWidget(listWidgetLabels); + } else { + m_view->userWarning("No run selected", + "Tried to remove run but no run was selected.\n" + "Please select a run and try again"); + } +} + +void EnggDiffFittingPresenter::processFitAllPeaks() { + std::string fittingPeaks = m_view->getExpectedPeaksInput(); + + const std::string normalisedPeakCentres = stripExtraCommas(fittingPeaks); + m_view->setPeakList(normalisedPeakCentres); + + const auto runLabels = m_model->getRunLabels(); + + g_log.debug() << "Focused files found are: " << normalisedPeakCentres << '\n'; + for (const auto &runLabel : runLabels) { + g_log.debug() << listWidgetLabelFromRunLabel(runLabel) << '\n'; + } + + if (!runLabels.empty()) { + + for (const auto &runLabel : runLabels) { + try { + validateFittingInputs(m_model->getWorkspaceFilename(runLabel), + normalisedPeakCentres); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for fitting", + ia.what()); + return; + } + } + + g_log.notice() << "EnggDiffraction GUI: starting new multi-run " + << "single peak fits. This may take some seconds...\n"; + m_view->showStatus("Fitting multi-run single peaks..."); + + // disable GUI to avoid any double threads + m_view->enableCalibrateFocusFitUserActions(false); + m_view->enableFitAllButton(false); + + startAsyncFittingWorker(runLabels, normalisedPeakCentres); + } else { + m_view->userWarning("Error in the inputs required for fitting", + "No runs were loaded for fitting"); + } +} + +void EnggDiffFittingPresenter::processFitPeaks() { + const auto listLabel = m_view->getFittingListWidgetCurrentValue(); + + if (!listLabel) { + m_view->userWarning("No run selected", + "Please select a run to fit from the list"); + return; + } + + const auto runLabel = runLabelFromListWidgetLabel(*listLabel); + std::string fittingPeaks = m_view->getExpectedPeaksInput(); + + const std::string normalisedPeakCentres = stripExtraCommas(fittingPeaks); + m_view->setPeakList(normalisedPeakCentres); + + g_log.debug() << "the expected peaks are: " << normalisedPeakCentres << '\n'; + + const auto filename = m_model->getWorkspaceFilename(runLabel); + try { + validateFittingInputs(filename, normalisedPeakCentres); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for fitting", ia.what()); + return; + } + + // disable so that user is forced to select file again + // otherwise empty vector will be passed + m_view->enableFitAllButton(false); + + const std::string outWSName = "engggui_fitting_fit_peak_ws"; + g_log.notice() << "EnggDiffraction GUI: starting new " + << "single peak fits into workspace '" << outWSName + << "'. This may take some seconds... \n"; + + m_view->showStatus("Fitting single peaks..."); + // disable GUI to avoid any double threads + m_view->enableCalibrateFocusFitUserActions(false); + + startAsyncFittingWorker({runLabel}, normalisedPeakCentres); +} + +void EnggDiffFittingPresenter::validateFittingInputs( + const std::string &focusedRunFilename, const std::string &expectedPeaks) { + if (focusedRunFilename.empty()) { + throw std::invalid_argument( + "Focused run filename cannot be empty and must be a valid file"); + } + + Poco::File file(focusedRunFilename); + if (!file.exists()) { + throw std::invalid_argument("The focused workspace file for single peak " + "fitting could not be found: " + + focusedRunFilename); + } + + if (expectedPeaks.empty()) { + g_log.warning() << "Expected peaks were not passed, via fitting interface, " + "the default list of " + "expected peaks will be utilised instead.\n"; + } + bool contains_non_digits = + expectedPeaks.find_first_not_of("0123456789,. ") != std::string::npos; + if (contains_non_digits) { + throw std::invalid_argument("The expected peaks provided " + expectedPeaks + + " is invalid, " + "fitting process failed. Please try again!"); + } +} + +void EnggDiffFittingPresenter::doFitting(const std::vector<RunLabel> &runLabels, + const std::string &expectedPeaks) { + m_fittingFinishedOK = false; + + for (const auto &runLabel : runLabels) { + g_log.notice() << "EnggDiffraction GUI: starting new fitting with run " + << runLabel.runNumber << " and bank " << runLabel.bank + << ". This may take a few seconds... \n"; + + // apply calibration to the focused workspace + m_model->setDifcTzero(runLabel, currentCalibration()); + + // run the algorithm EnggFitPeaks with workspace loaded above + // requires unit in Time of Flight + try { + m_model->enggFitPeaks(runLabel, expectedPeaks); + } catch (const std::runtime_error &exc) { + g_log.error() << "Could not run the algorithm EnggFitPeaks successfully." + << exc.what(); + // A userError should be used for this message once the threading has been + // looked into + return; + } catch (const Mantid::API::Algorithm::CancelException &) { + g_log.error() << "Fit terminated by user.\n"; + return; + } + + const auto outFilename = userHDFRunFilename(runLabel.runNumber); + m_model->saveFitResultsToHDF5({runLabel}, outFilename); + + m_model->createFittedPeaksWS(runLabel); + } + + if (runLabels.size() > 1) { + m_model->saveFitResultsToHDF5(runLabels, + userHDFMultiRunFilename(runLabels)); + } + m_fittingFinishedOK = true; +} + +void EnggDiffFittingPresenter::browsePeaksToFit() { + try { + const auto &userDir = outFilesUserDir(""); + std::string path = m_view->getOpenFile(userDir.toString()); + if (path.empty()) { + return; + } + + m_view->setPreviousDir(path); + std::string peaksData = readPeaksFile(path); + m_view->setPeakList(peaksData); + + } catch (std::runtime_error &re) { + m_view->userWarning( + "Unable to import the peaks from a file: ", + "File corrupted or could not be opened. Please try again" + + static_cast<std::string>(re.what()) + '\n'); + return; + } +} + +void EnggDiffFittingPresenter::addPeakToList() { + + if (m_view->peakPickerEnabled()) { + auto peakCentre = m_view->getPeakCentre(); + + std::stringstream stream; + stream << std::fixed << std::setprecision(4) << peakCentre; + auto strPeakCentre = stream.str(); + + auto curExpPeaksList = m_view->getExpectedPeaksInput(); + + std::string comma = ","; + + if (!curExpPeaksList.empty()) { + // when further peak added to list + + std::string lastTwoChr = + curExpPeaksList.substr(curExpPeaksList.size() - 2); + auto lastChr = curExpPeaksList.back(); + if (lastChr == ',' || lastTwoChr == ", ") { + curExpPeaksList.append(strPeakCentre); + } else { + curExpPeaksList.append(comma + strPeakCentre); + } + m_view->setPeakList(curExpPeaksList); + } else { + // when new peak given when list is empty + curExpPeaksList.append(strPeakCentre); + curExpPeaksList.append(comma); + m_view->setPeakList(curExpPeaksList); + } + } +} + +void EnggDiffFittingPresenter::savePeakList() { + try { + const auto &userDir = outFilesUserDir(""); + const auto &path = m_view->getSaveFile(userDir.toString()); + + if (path.empty()) { + return; + } + + fittingWriteFile(path); + } catch (std::runtime_error &re) { + m_view->userWarning( + "Unable to save the peaks file: ", + "Invalid file path or could not be saved. Error description : " + + static_cast<std::string>(re.what()) + '\n'); + return; + } +} + +std::string +EnggDiffFittingPresenter::readPeaksFile(const std::string &fileDir) { + std::string fileData = ""; + std::string line; + std::string comma = ", "; + + std::ifstream peakFile(fileDir); + + if (peakFile.is_open()) { + while (std::getline(peakFile, line)) { + fileData += line; + if (!peakFile.eof()) + fileData += comma; + } + peakFile.close(); + } + + else + fileData = ""; + + return fileData; +} + +void EnggDiffFittingPresenter::fittingWriteFile(const std::string &fileDir) { + std::ofstream outfile(fileDir.c_str()); + if (!outfile) { + m_view->userWarning("File not found", + "File " + fileDir + + " , could not be found. Please try again!"); + } else { + auto expPeaks = m_view->getExpectedPeaksInput(); + outfile << expPeaks; + } +} + +void EnggDiffFittingPresenter::updatePlot() { + const auto listLabel = m_view->getFittingListWidgetCurrentValue(); + if (listLabel) { + const auto runLabel = runLabelFromListWidgetLabel(*listLabel); + + const bool fitResultsExist = m_model->hasFittedPeaksForRun(runLabel); + const bool plotFittedPeaksEnabled = m_view->plotFittedPeaksEnabled(); + + if (fitResultsExist) { + plotAlignedWorkspace(plotFittedPeaksEnabled); + } else { + if (plotFittedPeaksEnabled) { + m_view->userWarning("Cannot plot fitted peaks", + "Cannot plot fitted peaks, as none have been " + "generated by a fit. Plotting focused workspace " + "instead."); + } + const auto ws = m_model->getFocusedWorkspace(runLabel); + plotFocusedFile(false, ws); + } + } +} + +bool EnggDiffFittingPresenter::isDigit(const std::string &text) const { + return std::all_of(text.cbegin(), text.cend(), ::isdigit); +} + +void EnggDiffFittingPresenter::warnFileNotFound(const std::exception &ex) { + m_view->showStatus("Error while loading focused run"); + m_view->userWarning("Invalid file selected", + "Mantid could not load the selected file, " + "or was unable to get necessary information." + "See the logger for more information"); + g_log.error("Failed to load file. Error message: "); + g_log.error(ex.what()); +} + +void EnggDiffFittingPresenter::plotFocusedFile( + bool plotSinglePeaks, const MatrixWorkspace_sptr &focusedPeaksWS) { + + try { + auto focusedData = QwtHelper::curveDataFromWs(focusedPeaksWS); + + // Check that the number of curves to plot isn't excessive + // lets cap it at 20 to begin with - this number could need + // raising but each curve creates about ~5 calls on the stack + // so keep the limit low. This will stop users using unfocused + // files which have 200+ curves to plot and will "freeze" Mantid + constexpr int maxCurves = 20; + + if (focusedData.size() > maxCurves) { + throw std::invalid_argument("Too many curves to plot." + " Is this a focused file?"); + } + + m_view->setDataVector( + focusedData, true, plotSinglePeaks, + generateXAxisLabel(focusedPeaksWS->getAxis(0)->unit())); + + } catch (std::runtime_error &re) { + g_log.error() + << "Unable to plot focused workspace on the canvas. " + << "Error description: " << re.what() + << " Please check also the previous log messages for details."; + + m_view->showStatus("Error while plotting the peaks fitted"); + throw; + } +} + +void EnggDiffFittingPresenter::plotAlignedWorkspace( + const bool plotFittedPeaks) { + try { + + // detaches previous plots from canvas + m_view->resetCanvas(); + + const auto listLabel = m_view->getFittingListWidgetCurrentValue(); + if (!listLabel) { + m_view->userWarning("Invalid run number or bank", + "Tried to plot a focused file which does not exist"); + return; + } + + const auto runLabel = runLabelFromListWidgetLabel(*listLabel); + const auto ws = m_model->getAlignedWorkspace(runLabel); + + // plots focused workspace + plotFocusedFile(m_fittingFinishedOK, ws); + + if (plotFittedPeaks) { + g_log.debug() << "single peaks fitting being plotted now.\n"; + auto singlePeaksWS = m_model->getFittedPeaksWS(runLabel); + auto singlePeaksData = QwtHelper::curveDataFromWs(singlePeaksWS); + m_view->setDataVector(singlePeaksData, false, true, + generateXAxisLabel(ws->getAxis(0)->unit())); + m_view->showStatus("Peaks fitted successfully"); + } + } catch (const std::runtime_error &) { + g_log.error() + << "Unable to finish of the plotting of the graph for " + "engggui_fitting_focused_fitpeaks workspace. Error " + "description. Please check also the log message for detail."; + + m_view->showStatus("Error while plotting the peaks fitted"); + throw; + } +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..79acf0ae5fe95d60aae3fb631c06482d7571619f --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingPresenter.h @@ -0,0 +1,142 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2016 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggDiffFittingModel.h" +#include "IEnggDiffFittingPresenter.h" +#include "IEnggDiffFittingView.h" +#include "IEnggDiffractionCalibration.h" +#include "IEnggDiffractionParam.h" + +#include <string> +#include <vector> + +#include <QObject> + +class QThread; + +namespace MantidQt { +namespace CustomInterfaces { + +/** +Presenter for the fitting tab/widget of the enggineering diffraction +GUI (presenter as in the MVP Model-View-Presenter pattern). +*/ +// needs to be dll-exported for the tests +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffFittingPresenter + : public QObject, + public IEnggDiffFittingPresenter, + public IEnggDiffractionCalibration, + public IEnggDiffractionParam { + // Q_OBJECT for 'connect' with thread/worker + Q_OBJECT + +public: + EnggDiffFittingPresenter( + IEnggDiffFittingView *view, std::unique_ptr<IEnggDiffFittingModel> model, + boost::shared_ptr<IEnggDiffractionCalibration> mainCalib, + boost::shared_ptr<IEnggDiffractionParam> mainParam); + ~EnggDiffFittingPresenter() override; + + void notify(IEnggDiffFittingPresenter::Notification notif) override; + + /// From the IEnggDiffractionCalibration interface + //@{ + std::vector<GSASCalibrationParms> currentCalibration() const override; + //@} + + /// From the IEnggDiffractionCalibration interface + //@{ + Poco::Path outFilesUserDir(const std::string &addToDir) const override; + //@} + + std::string userHDFRunFilename(const std::string &runNumber) const override; + std::string userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const override; + + /// the fitting hard work that a worker / thread will run + void doFitting(const std::vector<RunLabel> &runLabels, + const std::string &expectedPeaks); + + void plotFocusedFile(bool plotSinglePeaks, + const Mantid::API::MatrixWorkspace_sptr &focusedPeaksWS); + + void plotAlignedWorkspace(const bool plotFittedPeaks); + +protected: + void processStart(); + void processLoad(); + void processFitPeaks(); + void processFitAllPeaks(); + void processShutDown(); + void processLogMsg(); + void processUpdatePlotFitPeaks(); + void processRemoveRun(); + + /// clean shut down of model, view, etc. + void cleanup(); + +protected slots: + + void fittingFinished(); + +private: + void updatePlot(); + + bool isDigit(const std::string &text) const; + + void warnFileNotFound(const std::exception &ex); + + // Methods related single peak fits + virtual void startAsyncFittingWorker(const std::vector<RunLabel> &runLabels, + const std::string &expectedPeaks); + + std::string getBaseNameFromStr(const std::string &filePath) const; + + void validateFittingInputs(const std::string &focusedRunNo, + const std::string &expectedPeaks); + + void browsePeaksToFit(); + + void addPeakToList(); + + void savePeakList(); + + std::string readPeaksFile(const std::string &fileDir); + + void fittingWriteFile(const std::string &fileDir); + + // Holds the previous user input so we can short circuit further checks + std::string m_previousInput; + + /// true if the last fitting completed successfully + bool m_fittingFinishedOK; + + QThread *m_workerThread; + + /// interface for the 'current' calibration + boost::shared_ptr<IEnggDiffractionCalibration> m_mainCalib; + + /// interface for the 'current' calibration + boost::shared_ptr<IEnggDiffractionParam> m_mainParam; + + /// Associated view for this presenter (MVP pattern) + IEnggDiffFittingView *const m_view; + + /// Associated model for this presenter + std::unique_ptr<IEnggDiffFittingModel> m_model; + + /// Holds if the view is in the process of being closed + bool m_viewHasClosed; + + /// Handle the user selecting a different run to plot + void processSelectRun(); +}; + +} // namespace CustomInterfaces +} // namespace MantidQt \ No newline at end of file diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingViewQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingViewQtWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2a1dc1100ad037563e9bb742edfd359f1d9ef92 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffFittingViewQtWidget.cpp @@ -0,0 +1,577 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffFittingViewQtWidget.h" +#include "EnggDiffFittingModel.h" +#include "EnggDiffFittingPresenter.h" +#include "MantidAPI/FunctionFactory.h" +#include "MantidAPI/IPeakFunction.h" + +#include "MantidQtWidgets/Common/AlgorithmInputHistory.h" +#include "MantidQtWidgets/Plotting/Qwt/PeakPicker.h" + +#include <array> +#include <iomanip> +#include <random> +#include <sstream> + +#include <boost/algorithm/string.hpp> +#include <boost/make_shared.hpp> + +#include <Poco/Path.h> + +#include <QEvent> +#include <QFileDialog> +#include <QHelpEvent> +#include <QSettings> +#include <utility> + +#include <qwt_plot_curve.h> +#include <qwt_plot_zoomer.h> +#include <qwt_symbol.h> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace CustomInterfaces { + +const std::string EnggDiffFittingViewQtWidget::g_settingsGroup = + "CustomInterfaces/EnggDiffraction/FittingView"; + +const std::string EnggDiffFittingViewQtWidget::g_peaksListExt = + "Peaks list File: CSV " + "(*.csv *.txt);;" + "Other extensions/all files (*)"; + +std::vector<std::string> EnggDiffFittingViewQtWidget::m_fitting_runno_dir_vec; + +EnggDiffFittingViewQtWidget::EnggDiffFittingViewQtWidget( + QWidget * /*parent*/, boost::shared_ptr<IEnggDiffractionUserMsg> mainMsg, + boost::shared_ptr<IEnggDiffractionSettings> mainSettings, + boost::shared_ptr<IEnggDiffractionCalibration> mainCalib, + boost::shared_ptr<IEnggDiffractionParam> mainParam, + boost::shared_ptr<IEnggDiffractionPythonRunner> mainPythonRunner, + boost::shared_ptr<IEnggDiffractionParam> fileSettings) + : IEnggDiffFittingView(), m_fittedDataVector(), + m_fileSettings(std::move(fileSettings)), + m_mainMsgProvider(std::move(mainMsg)), + m_mainSettings(std::move(mainSettings)), + m_mainPythonRunner(std::move(mainPythonRunner)), + m_presenter(boost::make_shared<EnggDiffFittingPresenter>( + this, std::make_unique<EnggDiffFittingModel>(), mainCalib, + mainParam)) { + + initLayout(); + m_presenter->notify(IEnggDiffFittingPresenter::Start); +} + +EnggDiffFittingViewQtWidget::~EnggDiffFittingViewQtWidget() { + m_presenter->notify(IEnggDiffFittingPresenter::ShutDown); + + for (auto curves : m_focusedDataVector) { + curves->detach(); + delete curves; + } + + for (auto curves : m_fittedDataVector) { + curves->detach(); + delete curves; + } +} + +void EnggDiffFittingViewQtWidget::initLayout() { + m_ui.setupUi(this); + + readSettings(); + doSetup(); +} + +void EnggDiffFittingViewQtWidget::doSetup() { + connect(m_ui.pushButton_fitting_browse_run_num, SIGNAL(released()), this, + SLOT(browseFitFocusedRun())); + + connect(m_ui.lineEdit_pushButton_run_num, SIGNAL(returnPressed()), this, + SLOT(loadClicked())); + + connect(m_ui.pushButton_fitting_browse_peaks, SIGNAL(released()), this, + SLOT(browseClicked())); + + connect(m_ui.pushButton_load, SIGNAL(released()), this, SLOT(loadClicked())); + + connect(m_ui.pushButton_fit, SIGNAL(released()), this, SLOT(fitClicked())); + + connect(m_ui.pushButton_fit_all, SIGNAL(released()), this, + SLOT(fitAllClicked())); + + // add peak by clicking the button + connect(m_ui.pushButton_select_peak, SIGNAL(released()), SLOT(setPeakPick())); + + connect(m_ui.pushButton_add_peak, SIGNAL(released()), SLOT(addClicked())); + + connect(m_ui.pushButton_save_peak_list, SIGNAL(released()), + SLOT(saveClicked())); + + connect(m_ui.pushButton_clear_peak_list, SIGNAL(released()), + SLOT(clearPeakList())); + + connect(m_ui.pushButton_plot_separate_window, SIGNAL(released()), + SLOT(plotSeparateWindow())); + + connect(m_ui.listWidget_fitting_run_num, + SIGNAL(itemClicked(QListWidgetItem *)), this, + SLOT(listWidget_fitting_run_num_clicked(QListWidgetItem *))); + + connect(m_ui.checkBox_plotFittedPeaks, SIGNAL(stateChanged(int)), this, + SLOT(plotFittedPeaksStateChanged())); + + // Tool-tip button + connect(m_ui.pushButton_tooltip, SIGNAL(released()), SLOT(showToolTipHelp())); + + // Remove run button + connect(m_ui.pushButton_remove_run, SIGNAL(released()), this, + SLOT(removeRunClicked())); + + m_ui.dataPlot->setCanvasBackground(Qt::white); + m_ui.dataPlot->setAxisTitle(QwtPlot::xBottom, "d-Spacing (A)"); + m_ui.dataPlot->setAxisTitle(QwtPlot::yLeft, "Counts (us)^-1"); + QFont font("MS Shell Dlg 2", 8); + m_ui.dataPlot->setAxisFont(QwtPlot::xBottom, font); + m_ui.dataPlot->setAxisFont(QwtPlot::yLeft, font); + + // constructor of the peakPicker + // XXX: Being a QwtPlotItem, should get deleted when m_ui.plot gets deleted + // (auto-delete option) + m_peakPicker = new MantidWidgets::PeakPicker(m_ui.dataPlot, Qt::red); + setPeakPickerEnabled(false); + + m_zoomTool = + new QwtPlotZoomer(QwtPlot::xBottom, QwtPlot::yLeft, + QwtPicker::DragSelection | QwtPicker::CornerToCorner, + QwtPicker::AlwaysOff, m_ui.dataPlot->canvas()); + m_zoomTool->setRubberBandPen(QPen(Qt::black)); + setZoomTool(false); +} + +void EnggDiffFittingViewQtWidget::readSettings() { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + // user params + m_ui.lineEdit_pushButton_run_num->setText( + qs.value("user-params-fitting-focused-file", "").toString()); + m_ui.lineEdit_fitting_peaks->setText( + qs.value("user-params-fitting-peaks-to-fit", "").toString()); + + qs.endGroup(); +} + +void EnggDiffFittingViewQtWidget::saveSettings() const { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + qs.setValue("user-params-fitting-focused-file", + m_ui.lineEdit_pushButton_run_num->text()); + qs.setValue("user-params-fitting-peaks-to-fit", + m_ui.lineEdit_fitting_peaks->text()); + + qs.endGroup(); +} + +void EnggDiffFittingViewQtWidget::enable(bool enable) { + m_ui.pushButton_fitting_browse_run_num->setEnabled(enable); + m_ui.pushButton_load->setEnabled(enable); + m_ui.lineEdit_pushButton_run_num->setEnabled(enable); + m_ui.pushButton_fitting_browse_peaks->setEnabled(enable); + m_ui.lineEdit_fitting_peaks->setEnabled(enable); + m_ui.pushButton_fit->setEnabled(enable); + m_ui.pushButton_clear_peak_list->setEnabled(enable); + m_ui.pushButton_save_peak_list->setEnabled(enable); + m_ui.groupBox_fititng_preview->setEnabled(enable); +} + +void EnggDiffFittingViewQtWidget::showStatus(const std::string &sts) { + m_mainMsgProvider->showStatus(sts); +} + +void EnggDiffFittingViewQtWidget::userWarning(const std::string &err, + const std::string &description) { + m_mainMsgProvider->userWarning(err, description); +} + +void EnggDiffFittingViewQtWidget::userError(const std::string &err, + const std::string &description) { + m_mainMsgProvider->userError(err, description); +} + +void EnggDiffFittingViewQtWidget::enableCalibrateFocusFitUserActions( + bool enable) { + m_mainMsgProvider->enableCalibrateFocusFitUserActions(enable); +} + +EnggDiffCalibSettings +EnggDiffFittingViewQtWidget::currentCalibSettings() const { + return m_mainSettings->currentCalibSettings(); +} + +std::string +EnggDiffFittingViewQtWidget::enggRunPythonCode(const std::string &pyCode) { + return m_mainPythonRunner->enggRunPythonCode(pyCode); +} + +void EnggDiffFittingViewQtWidget::loadClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::Load); +} + +void EnggDiffFittingViewQtWidget::fitClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::FitPeaks); +} + +void EnggDiffFittingViewQtWidget::fitAllClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::FitAllPeaks); +} + +void EnggDiffFittingViewQtWidget::addClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::addPeaks); +} + +void EnggDiffFittingViewQtWidget::browseClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::browsePeaks); +} + +void EnggDiffFittingViewQtWidget::saveClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::savePeaks); +} + +void EnggDiffFittingViewQtWidget::plotFittedPeaksStateChanged() { + m_presenter->notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); +} + +void EnggDiffFittingViewQtWidget::listWidget_fitting_run_num_clicked( + QListWidgetItem *) { + m_presenter->notify(IEnggDiffFittingPresenter::selectRun); +} + +void EnggDiffFittingViewQtWidget::removeRunClicked() { + m_presenter->notify(IEnggDiffFittingPresenter::removeRun); +} + +void EnggDiffFittingViewQtWidget::resetCanvas() { + // clear vector and detach curves to avoid plot crash + // when only plotting focused workspace + for (auto curves : m_fittedDataVector) { + if (curves) { + curves->detach(); + delete curves; + } + } + + if (m_fittedDataVector.size() > 0) + m_fittedDataVector.clear(); + + // set it as false as there will be no valid workspace to plot + m_ui.pushButton_plot_separate_window->setEnabled(false); +} + +void EnggDiffFittingViewQtWidget::setDataVector( + std::vector<boost::shared_ptr<QwtData>> &data, bool focused, + bool plotSinglePeaks, const std::string &xAxisLabel) { + + if (!plotSinglePeaks) { + // clear vector and detach curves to avoid plot crash + resetCanvas(); + } + m_ui.dataPlot->setAxisTitle(QwtPlot::xBottom, xAxisLabel.c_str()); + + // when only plotting focused workspace + if (focused) { + dataCurvesFactory(data, m_focusedDataVector, focused); + } else { + dataCurvesFactory(data, m_fittedDataVector, focused); + } +} + +void EnggDiffFittingViewQtWidget::dataCurvesFactory( + std::vector<boost::shared_ptr<QwtData>> &data, + std::vector<QwtPlotCurve *> &dataVector, bool focused) { + + // clear vector + for (auto curves : dataVector) { + if (curves) { + curves->detach(); + delete curves; + } + } + + if (dataVector.size() > 0) + dataVector.clear(); + resetView(); + + // dark colours could be removed so that the coloured peaks stand out more + const std::array<QColor, 16> QPenList{ + {Qt::white, Qt::red, Qt::darkRed, Qt::green, Qt::darkGreen, Qt::blue, + Qt::darkBlue, Qt::cyan, Qt::darkCyan, Qt::magenta, Qt::darkMagenta, + Qt::yellow, Qt::darkYellow, Qt::gray, Qt::lightGray, Qt::black}}; + + std::mt19937 gen; + std::uniform_int_distribution<std::size_t> dis(0, QPenList.size() - 1); + + for (size_t i = 0; i < data.size(); i++) { + auto *peak = data[i].get(); + + QwtPlotCurve *dataCurve = new QwtPlotCurve(); + if (!focused) { + dataCurve->setStyle(QwtPlotCurve::Lines); + auto randIndex = dis(gen); + dataCurve->setPen(QPen(QPenList[randIndex], 2)); + + // only set enabled when single peak workspace plotted + m_ui.pushButton_plot_separate_window->setEnabled(true); + } else { + dataCurve->setStyle(QwtPlotCurve::NoCurve); + // focused workspace in bg set as darkGrey crosses insted of line + dataCurve->setSymbol(QwtSymbol(QwtSymbol::XCross, QBrush(), + QPen(Qt::darkGray, 1), QSize(3, 3))); + } + dataCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); + + dataVector.emplace_back(dataCurve); + + dataVector[i]->setData(*peak); + dataVector[i]->attach(m_ui.dataPlot); + } + + m_ui.dataPlot->replot(); + m_zoomTool->setZoomBase(); + // enable zoom & select peak btn after the plotting on graph + setZoomTool(true); + m_ui.pushButton_select_peak->setEnabled(true); + data.clear(); +} + +void EnggDiffFittingViewQtWidget::setPeakPickerEnabled(bool enabled) { + m_peakPicker->setEnabled(enabled); + m_peakPicker->setVisible(enabled); + m_ui.dataPlot->replot(); // PeakPicker might get hidden/shown + m_ui.pushButton_add_peak->setEnabled(enabled); + if (enabled) { + QString btnText = "Reset Peak Selector"; + m_ui.pushButton_select_peak->setText(btnText); + } +} + +void EnggDiffFittingViewQtWidget::setPeakPicker( + const IPeakFunction_const_sptr &peak) { + m_peakPicker->setPeak(peak); + m_ui.dataPlot->replot(); +} + +double EnggDiffFittingViewQtWidget::getPeakCentre() const { + auto peak = m_peakPicker->peak(); + auto centre = peak->centre(); + return centre; +} + +bool EnggDiffFittingViewQtWidget::peakPickerEnabled() const { + return m_peakPicker->isEnabled(); +} + +void EnggDiffFittingViewQtWidget::setZoomTool(bool enabled) { + m_zoomTool->setEnabled(enabled); +} + +void EnggDiffFittingViewQtWidget::resetView() { + // Resets the view to a sensible default + // Auto scale the axis + m_ui.dataPlot->setAxisAutoScale(QwtPlot::xBottom); + m_ui.dataPlot->setAxisAutoScale(QwtPlot::yLeft); + + // Set this as the default zoom level + m_zoomTool->setZoomBase(true); +} + +std::string EnggDiffFittingViewQtWidget::getPreviousDir() const { + + QString prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + + return prevPath.toStdString(); +} + +void EnggDiffFittingViewQtWidget::setPreviousDir(const std::string &path) { + QString qPath = QString::fromStdString(path); + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(qPath); +} + +std::string +EnggDiffFittingViewQtWidget::getOpenFile(const std::string &prevPath) { + + QString path(QFileDialog::getOpenFileName( + this, tr("Open Peaks To Fit"), QString::fromStdString(prevPath), + QString::fromStdString(g_peaksListExt))); + + return path.toStdString(); +} + +std::string +EnggDiffFittingViewQtWidget::getSaveFile(const std::string &prevPath) { + + QString path(QFileDialog::getSaveFileName( + this, tr("Save Expected Peaks List"), QString::fromStdString(prevPath), + QString::fromStdString(g_peaksListExt))); + + return path.toStdString(); +} + +void EnggDiffFittingViewQtWidget::browseFitFocusedRun() { + const auto &focusDir = m_fileSettings->outFilesUserDir("Focus").toString(); + std::string nexusFormat = "Nexus file with calibration table: NXS, NEXUS" + "(*.nxs *.nexus);;"; + + QStringList paths(QFileDialog::getOpenFileNames( + this, tr("Open Focused File "), QString::fromStdString(focusDir), + QString::fromStdString(nexusFormat))); + + if (paths.isEmpty()) { + return; + } + + setFocusedFileNames(paths.join(",").toStdString()); +} + +void EnggDiffFittingViewQtWidget::setFocusedFileNames( + const std::string &paths) { + m_ui.lineEdit_pushButton_run_num->setText(QString::fromStdString(paths)); +} + +std::string EnggDiffFittingViewQtWidget::getFocusedFileNames() const { + return m_ui.lineEdit_pushButton_run_num->text().toStdString(); +} + +void EnggDiffFittingViewQtWidget::enableFitAllButton(bool enable) const { + m_ui.pushButton_fit_all->setEnabled(enable); +} + +void EnggDiffFittingViewQtWidget::clearFittingListWidget() const { + m_ui.listWidget_fitting_run_num->clear(); +} + +void EnggDiffFittingViewQtWidget::enableFittingListWidget(bool enable) const { + m_ui.listWidget_fitting_run_num->setEnabled(enable); +} + +int EnggDiffFittingViewQtWidget::getFittingListWidgetCurrentRow() const { + return m_ui.listWidget_fitting_run_num->currentRow(); +} + +boost::optional<std::string> +EnggDiffFittingViewQtWidget::getFittingListWidgetCurrentValue() const { + if (listWidgetHasSelectedRow()) { + return m_ui.listWidget_fitting_run_num->currentItem()->text().toStdString(); + } + return boost::none; +} + +bool EnggDiffFittingViewQtWidget::listWidgetHasSelectedRow() const { + return m_ui.listWidget_fitting_run_num->selectedItems().size() != 0; +} + +void EnggDiffFittingViewQtWidget::updateFittingListWidget( + const std::vector<std::string> &rows) { + clearFittingListWidget(); + + for (const auto &rowLabel : rows) { + this->addRunNoItem(rowLabel); + } +} + +void EnggDiffFittingViewQtWidget::setFittingListWidgetCurrentRow( + int idx) const { + m_ui.listWidget_fitting_run_num->setCurrentRow(idx); +} + +bool EnggDiffFittingViewQtWidget::plotFittedPeaksEnabled() const { + return m_ui.checkBox_plotFittedPeaks->isChecked(); +} + +void EnggDiffFittingViewQtWidget::plotSeparateWindow() { + std::string pyCode = + + "fitting_single_peaks_twin_ws = \"__engggui_fitting_single_peaks_twin\"\n" + "if (mtd.doesExist(fitting_single_peaks_twin_ws)):\n" + " DeleteWorkspace(fitting_single_peaks_twin_ws)\n" + + "single_peak_ws = CloneWorkspace(InputWorkspace = " + "\"engggui_fitting_single_peaks\", OutputWorkspace = " + "fitting_single_peaks_twin_ws)\n" + "tot_spec = single_peak_ws.getNumberHistograms()\n" + + "spec_list = []\n" + "for i in range(0, tot_spec):\n" + " spec_list.append(i)\n" + + "fitting_plot = plotSpectrum(single_peak_ws, spec_list).activeLayer()\n" + "fitting_plot.setTitle(\"Engg GUI Single Peaks Fitting Workspace\")\n"; + + std::string status = m_mainPythonRunner->enggRunPythonCode(pyCode); + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffFittingPresenter::LogMsg); +} + +void EnggDiffFittingViewQtWidget::showToolTipHelp() { + // We need a the mouse click position relative to the widget + // and relative to the screen. We will set the mouse click position + // relative to widget to 0 as the global position of the mouse + // is what is considered when the tool tip is displayed + const QPoint relWidgetPosition(0, 0); + const QPoint mousePos = QCursor::pos(); + // Now fire the generated event to show a tool tip at the cursor + QEvent *toolTipEvent = + new QHelpEvent(QEvent::ToolTip, relWidgetPosition, mousePos); + QCoreApplication::sendEvent(m_ui.pushButton_tooltip, toolTipEvent); +} + +std::string EnggDiffFittingViewQtWidget::getExpectedPeaksInput() const { + + return m_ui.lineEdit_fitting_peaks->text().toStdString(); +} + +void EnggDiffFittingViewQtWidget::setPeakList( + const std::string &peakList) const { + m_ui.lineEdit_fitting_peaks->setText(QString::fromStdString(peakList)); +} + +void EnggDiffFittingViewQtWidget::addRunNoItem(std::string runNo) { + m_ui.listWidget_fitting_run_num->addItem(QString::fromStdString(runNo)); +} + +std::vector<std::string> EnggDiffFittingViewQtWidget::getFittingRunNumVec() { + return m_fitting_runno_dir_vec; +} + +void EnggDiffFittingViewQtWidget::setFittingRunNumVec( + std::vector<std::string> assignVec) { + // holds all the directories required + m_fitting_runno_dir_vec.clear(); + m_fitting_runno_dir_vec = assignVec; +} + +void EnggDiffFittingViewQtWidget::setPeakPick() { + auto bk2bk = + FunctionFactory::Instance().createFunction("BackToBackExponential"); + auto bk2bkFunc = boost::dynamic_pointer_cast<IPeakFunction>(bk2bk); + // set the peak to BackToBackExponential function + setPeakPicker(bk2bkFunc); + setPeakPickerEnabled(true); +} + +void EnggDiffFittingViewQtWidget::clearPeakList() { + m_ui.lineEdit_fitting_peaks->clear(); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8a3b71e7e044b3c92d18296039dd9aab276f48ce --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp @@ -0,0 +1,353 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffGSASFittingModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidQtWidgets/Common/MantidAlgorithmMetatype.h" + +#include <boost/algorithm/string/join.hpp> +#include <utility> + +using namespace Mantid; + +namespace { + +std::string stripWSNameFromFilename(const std::string &fullyQualifiedFilename) { + std::vector<std::string> directories; + boost::split(directories, fullyQualifiedFilename, boost::is_any_of("\\/")); + const std::string filename = directories.back(); + std::vector<std::string> filenameSegments; + boost::split(filenameSegments, filename, boost::is_any_of(".")); + return filenameSegments[0]; +} + +std::string refinementMethodToString( + const MantidQt::CustomInterfaces::GSASRefinementMethod &method) { + switch (method) { + case MantidQt::CustomInterfaces::GSASRefinementMethod::PAWLEY: + return "Pawley refinement"; + case MantidQt::CustomInterfaces::GSASRefinementMethod::RIETVELD: + return "Rietveld refinement"; + default: + throw std::invalid_argument( + "Invalid refinement method: please contact the development team"); + } +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffGSASFittingModel::EnggDiffGSASFittingModel() { + qRegisterMetaType< + MantidQt::CustomInterfaces::GSASIIRefineFitPeaksOutputProperties>( + "GSASIIRefineFitPeaksOutputProperties"); + qRegisterMetaType<Mantid::API::IAlgorithm_sptr>("IAlgorithm_sptr"); + qRegisterMetaType<std::vector<GSASIIRefineFitPeaksOutputProperties>>( + "std::vector<GSASIIRefineFitPeaksOutputProperties>"); +} + +EnggDiffGSASFittingModel::~EnggDiffGSASFittingModel() { + if (m_workerThread) { + if (m_workerThread->isRunning()) { + m_workerThread->wait(10); + } + } +} + +void EnggDiffGSASFittingModel::addFitResultsToMaps( + const RunLabel &runLabel, const double rwp, const double sigma, + const double gamma, const API::ITableWorkspace_sptr &latticeParams) { + addRwp(runLabel, rwp); + addSigma(runLabel, sigma); + addGamma(runLabel, gamma); + addLatticeParams(runLabel, latticeParams); +} + +void EnggDiffGSASFittingModel::addLatticeParams( + const RunLabel &runLabel, const API::ITableWorkspace_sptr &table) { + m_latticeParamsMap.add(runLabel, table); +} + +void EnggDiffGSASFittingModel::addGamma(const RunLabel &runLabel, + const double gamma) { + m_gammaMap.add(runLabel, gamma); +} + +void EnggDiffGSASFittingModel::addRwp(const RunLabel &runLabel, + const double rwp) { + m_rwpMap.add(runLabel, rwp); +} + +void EnggDiffGSASFittingModel::addSigma(const RunLabel &runLabel, + const double sigma) { + m_sigmaMap.add(runLabel, sigma); +} + +namespace { + +std::string generateFittedPeaksWSName(const RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_gsasii_fitted_peaks"; +} + +std::string generateLatticeParamsName(const RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_lattice_params"; +} +} // namespace + +std::pair<API::IAlgorithm_sptr, GSASIIRefineFitPeaksOutputProperties> +EnggDiffGSASFittingModel::doGSASRefinementAlgorithm( + const GSASIIRefineFitPeaksParameters ¶ms) { + auto gsasAlg = + API::AlgorithmManager::Instance().create("GSASIIRefineFitPeaks"); + + gsasAlg->setProperty("RefinementMethod", + refinementMethodToString(params.refinementMethod)); + gsasAlg->setProperty("InputWorkspace", params.inputWorkspace); + gsasAlg->setProperty("InstrumentFile", params.instParamsFile); + gsasAlg->setProperty("PhaseInfoFiles", + boost::algorithm::join(params.phaseFiles, ",")); + gsasAlg->setProperty("PathToGSASII", params.gsasHome); + + if (params.dMin) { + gsasAlg->setProperty("PawleyDMin", *(params.dMin)); + } + if (params.negativeWeight) { + gsasAlg->setProperty("PawleyNegativeWeight", *(params.negativeWeight)); + } + if (params.xMin) { + gsasAlg->setProperty("XMin", *(params.xMin)); + } + if (params.xMax) { + gsasAlg->setProperty("XMax", *(params.xMax)); + } + gsasAlg->setProperty("RefineSigma", params.refineSigma); + gsasAlg->setProperty("RefineGamma", params.refineGamma); + + const auto outputWSName = generateFittedPeaksWSName(params.runLabel); + const auto latticeParamsName = generateLatticeParamsName(params.runLabel); + gsasAlg->setProperty("OutputWorkspace", outputWSName); + gsasAlg->setProperty("LatticeParameters", latticeParamsName); + gsasAlg->setProperty("SaveGSASIIProjectFile", params.gsasProjectFile); + gsasAlg->execute(); + + const double rwp = gsasAlg->getProperty("Rwp"); + const double sigma = gsasAlg->getProperty("Sigma"); + const double gamma = gsasAlg->getProperty("Gamma"); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + const auto fittedPeaks = ADS.retrieveWS<API::MatrixWorkspace>(outputWSName); + const auto latticeParams = + ADS.retrieveWS<API::ITableWorkspace>(latticeParamsName); + return std::make_pair(gsasAlg, GSASIIRefineFitPeaksOutputProperties( + rwp, sigma, gamma, fittedPeaks, + latticeParams, params.runLabel)); +} + +void EnggDiffGSASFittingModel::doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) { + m_workerThread = std::make_unique<QThread>(this); + EnggDiffGSASFittingWorker *worker = + new EnggDiffGSASFittingWorker(this, params); + worker->moveToThread(m_workerThread.get()); + + connect(m_workerThread.get(), SIGNAL(started()), worker, + SLOT(doRefinements())); + connect(worker, + SIGNAL(refinementSuccessful(Mantid::API::IAlgorithm_sptr, + GSASIIRefineFitPeaksOutputProperties)), + this, + SLOT(processRefinementSuccessful( + Mantid::API::IAlgorithm_sptr, + const GSASIIRefineFitPeaksOutputProperties &))); + connect(worker, + SIGNAL(refinementsComplete( + Mantid::API::IAlgorithm_sptr, + std::vector<GSASIIRefineFitPeaksOutputProperties>)), + this, + SLOT(processRefinementsComplete( + Mantid::API::IAlgorithm_sptr, + const std::vector<GSASIIRefineFitPeaksOutputProperties> &))); + connect(worker, SIGNAL(refinementFailed(const std::string &)), this, + SLOT(processRefinementFailed(const std::string &))); + connect(worker, SIGNAL(refinementCancelled()), this, + SLOT(processRefinementCancelled())); + connect(m_workerThread.get(), SIGNAL(finished()), m_workerThread.get(), + SLOT(deleteLater())); + connect(worker, + SIGNAL(refinementSuccessful(Mantid::API::IAlgorithm_sptr, + GSASIIRefineFitPeaksOutputProperties)), + worker, SLOT(deleteLater())); + connect(worker, SIGNAL(refinementFailed(const std::string &)), worker, + SLOT(deleteLater())); + m_workerThread->start(); +} + +boost::optional<API::ITableWorkspace_sptr> +EnggDiffGSASFittingModel::getLatticeParams(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_latticeParamsMap, runLabel); +} + +boost::optional<double> +EnggDiffGSASFittingModel::getGamma(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_gammaMap, runLabel); +} + +boost::optional<double> +EnggDiffGSASFittingModel::getRwp(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_rwpMap, runLabel); +} + +boost::optional<double> +EnggDiffGSASFittingModel::getSigma(const RunLabel &runLabel) const { + return getFromRunMapOptional(m_sigmaMap, runLabel); +} + +bool EnggDiffGSASFittingModel::hasFitResultsForRun( + const RunLabel &runLabel) const { + return m_rwpMap.contains(runLabel) && m_sigmaMap.contains(runLabel) && + m_gammaMap.contains(runLabel); +} + +Mantid::API::MatrixWorkspace_sptr +EnggDiffGSASFittingModel::loadFocusedRun(const std::string &filename) const { + const auto wsName = stripWSNameFromFilename(filename); + + auto loadAlg = API::AlgorithmManager::Instance().create("Load"); + loadAlg->setProperty("Filename", filename); + loadAlg->setProperty("OutputWorkspace", wsName); + loadAlg->execute(); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + auto wsTest = ADS.retrieveWS<API::Workspace>(wsName); + const auto ws = boost::dynamic_pointer_cast<API::MatrixWorkspace>(wsTest); + if (!ws) { + throw std::invalid_argument( + "Invalid Workspace loaded, are you sure it has been focused?"); + } + return ws; +} + +void EnggDiffGSASFittingModel::processRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets) { + m_observer->notifyRefinementsComplete(std::move(alg), refinementResultSets); +} + +void EnggDiffGSASFittingModel::processRefinementFailed( + const std::string &failureMessage) { + if (m_observer) { + m_observer->notifyRefinementFailed(failureMessage); + } +} + +void EnggDiffGSASFittingModel::processRefinementSuccessful( + API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults) { + addFitResultsToMaps(refinementResults.runLabel, refinementResults.rwp, + refinementResults.sigma, refinementResults.gamma, + refinementResults.latticeParamsWS); + if (m_observer) { + m_observer->notifyRefinementSuccessful(std::move(successfulAlgorithm), + refinementResults); + } +} + +void EnggDiffGSASFittingModel::processRefinementCancelled() { + if (m_observer) { + m_observer->notifyRefinementCancelled(); + } +} + +void EnggDiffGSASFittingModel::saveRefinementResultsToHDF5( + const Mantid::API::IAlgorithm_sptr successfulAlg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets, + const std::string &filename) const { + auto saveAlg = API::AlgorithmManager::Instance().create( + "EnggSaveGSASIIFitResultsToHDF5"); + + const auto numRuns = refinementResultSets.size(); + std::vector<std::string> latticeParamWSNames; + latticeParamWSNames.reserve(numRuns); + std::vector<std::string> runNumbers; + runNumbers.reserve(numRuns); + std::vector<long> bankIDs; + bankIDs.reserve(numRuns); + std::vector<double> sigmas; + sigmas.reserve(numRuns); + std::vector<double> gammas; + gammas.reserve(numRuns); + std::vector<double> rwps; + rwps.reserve(numRuns); + + const bool refineSigma = successfulAlg->getProperty("RefineSigma"); + saveAlg->setProperty("RefineSigma", refineSigma); + const bool refineGamma = successfulAlg->getProperty("RefineGamma"); + saveAlg->setProperty("RefineGamma", refineGamma); + + for (const auto &refinementResults : refinementResultSets) { + const auto &runLabel = refinementResults.runLabel; + const auto latticeParams = *getLatticeParams(runLabel); + + latticeParamWSNames.emplace_back(latticeParams->getName()); + runNumbers.emplace_back(runLabel.runNumber); + bankIDs.emplace_back(static_cast<long>(runLabel.bank)); + rwps.emplace_back(refinementResults.rwp); + + if (refineSigma) { + sigmas.emplace_back(refinementResults.sigma); + } + if (refineGamma) { + gammas.emplace_back(refinementResults.gamma); + } + } + + saveAlg->setProperty("LatticeParamWorkspaces", latticeParamWSNames); + saveAlg->setProperty("BankIDs", bankIDs); + saveAlg->setProperty("RunNumbers", runNumbers); + + const std::string refinementMethod = + successfulAlg->getProperty("RefinementMethod"); + saveAlg->setProperty("RefinementMethod", refinementMethod); + saveAlg->setProperty("XMin", successfulAlg->getPropertyValue("XMin")); + saveAlg->setProperty("XMax", successfulAlg->getPropertyValue("XMax")); + + if (refinementMethod == "Pawley refinement") { + saveAlg->setProperty("PawleyDMin", + successfulAlg->getPropertyValue("PawleyDMin")); + saveAlg->setProperty( + "PawleyNegativeWeight", + successfulAlg->getPropertyValue("PawleyNegativeWeight")); + } + + if (refineSigma) { + saveAlg->setProperty("Sigma", sigmas); + } + + if (refineGamma) { + saveAlg->setProperty("Gamma", gammas); + } + + saveAlg->setProperty("Rwp", rwps); + saveAlg->setProperty("Filename", filename); + saveAlg->execute(); +} + +void EnggDiffGSASFittingModel::setObserver( + boost::shared_ptr<IEnggDiffGSASFittingObserver> observer) { + m_observer = observer; +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h new file mode 100644 index 0000000000000000000000000000000000000000..b8efb449f66462484d2220e6e779c25f9e698aae --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h @@ -0,0 +1,132 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffGSASFittingWorker.h" +#include "GSASIIRefineFitPeaksOutputProperties.h" +#include "IEnggDiffGSASFittingModel.h" +#include "IEnggDiffGSASFittingObserver.h" +#include "RunMap.h" + +#include "MantidAPI/IAlgorithm_fwd.h" + +#include <QObject> +#include <QThread> + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffGSASFittingModel + : public QObject, // Must be a QObject to run GSASIIRefineFitPeaksWorker + // asynchronously + public IEnggDiffGSASFittingModel { + Q_OBJECT + + friend void EnggDiffGSASFittingWorker::doRefinements(); + +public: + EnggDiffGSASFittingModel(); + + ~EnggDiffGSASFittingModel(); + + void setObserver( + boost::shared_ptr<IEnggDiffGSASFittingObserver> observer) override; + + void doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) override; + + boost::optional<Mantid::API::ITableWorkspace_sptr> + getLatticeParams(const RunLabel &runLabel) const override; + + boost::optional<double> getGamma(const RunLabel &runLabel) const override; + + boost::optional<double> getRwp(const RunLabel &runLabel) const override; + + boost::optional<double> getSigma(const RunLabel &runLabel) const override; + + bool hasFitResultsForRun(const RunLabel &runLabel) const override; + + Mantid::API::MatrixWorkspace_sptr + loadFocusedRun(const std::string &filename) const override; + + void saveRefinementResultsToHDF5( + const Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets, + const std::string &filename) const override; + +protected: + /// The following methods are marked as protected so that they can be exposed + /// by a helper class in the tests + + /// Add a lattice parameter table to the map + void addLatticeParams(const RunLabel &runLabel, + const Mantid::API::ITableWorkspace_sptr &table); + + /// Add a gamma value to the gamma map + void addGamma(const RunLabel &runLabel, const double gamma); + + /// Add an rwp value to the rwp map + void addRwp(const RunLabel &runLabel, const double rwp); + + /// Add a sigma value to the sigma map + void addSigma(const RunLabel &runLabel, const double sigma); + +protected slots: + void processRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets); + + void processRefinementFailed(const std::string &failureMessage); + + void processRefinementSuccessful( + Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults); + + void processRefinementCancelled(); + +private: + static constexpr double DEFAULT_PAWLEY_DMIN = 1; + static constexpr double DEFAULT_PAWLEY_NEGATIVE_WEIGHT = 0; + static const size_t MAX_BANKS = 3; + + RunMap<MAX_BANKS, double> m_gammaMap; + RunMap<MAX_BANKS, Mantid::API::ITableWorkspace_sptr> m_latticeParamsMap; + RunMap<MAX_BANKS, double> m_rwpMap; + RunMap<MAX_BANKS, double> m_sigmaMap; + + boost::shared_ptr<IEnggDiffGSASFittingObserver> m_observer; + + std::unique_ptr<QThread> m_workerThread; + + /// Add Rwp, sigma, gamma and lattice params table to their + /// respective RunMaps + void + addFitResultsToMaps(const RunLabel &runLabel, const double rwp, + const double sigma, const double gamma, + const Mantid::API::ITableWorkspace_sptr &latticeParams); + + void deleteWorkerThread(); + + /// Run GSASIIRefineFitPeaks + std::pair<Mantid::API::IAlgorithm_sptr, GSASIIRefineFitPeaksOutputProperties> + doGSASRefinementAlgorithm(const GSASIIRefineFitPeaksParameters ¶ms); + + template <typename T> + boost::optional<T> getFromRunMapOptional(const RunMap<MAX_BANKS, T> &map, + const RunLabel &runLabel) const { + if (map.contains(runLabel)) { + return map.get(runLabel); + } + return boost::none; + } +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7c536da040a59dc10980d1c83331461c12113d34 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp @@ -0,0 +1,301 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffGSASFittingPresenter.h" + +#include <utility> + +#include "EnggDiffGSASRefinementMethod.h" +#include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" + +namespace { + +std::string addRunNumberToGSASIIProjectFile( + const std::string &filename, + const MantidQt::CustomInterfaces::RunLabel &runLabel) { + const auto dotPosition = filename.find_last_of("."); + return filename.substr(0, dotPosition) + "_" + runLabel.runNumber + "_" + + std::to_string(runLabel.bank) + + filename.substr(dotPosition, filename.length()); +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffGSASFittingPresenter::EnggDiffGSASFittingPresenter( + std::unique_ptr<IEnggDiffGSASFittingModel> model, + IEnggDiffGSASFittingView *view, + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> multiRunWidget, + boost::shared_ptr<IEnggDiffractionParam> mainSettings) + : m_model(std::move(model)), m_multiRunWidget(std::move(multiRunWidget)), + m_mainSettings(std::move(mainSettings)), m_view(view), + m_viewHasClosed(false) {} + +EnggDiffGSASFittingPresenter::~EnggDiffGSASFittingPresenter() {} + +void EnggDiffGSASFittingPresenter::notify( + IEnggDiffGSASFittingPresenter::Notification notif) { + + if (m_viewHasClosed) { + return; + } + + switch (notif) { + + case IEnggDiffGSASFittingPresenter::DoRefinement: + processDoRefinement(); + break; + + case IEnggDiffGSASFittingPresenter::LoadRun: + processLoadRun(); + break; + + case IEnggDiffGSASFittingPresenter::RefineAll: + processRefineAll(); + break; + + case IEnggDiffGSASFittingPresenter::SelectRun: + processSelectRun(); + break; + + case IEnggDiffGSASFittingPresenter::Start: + processStart(); + break; + + case IEnggDiffGSASFittingPresenter::ShutDown: + processShutDown(); + break; + } +} + +std::vector<GSASIIRefineFitPeaksParameters> +EnggDiffGSASFittingPresenter::collectAllInputParameters() const { + const auto runLabels = m_multiRunWidget->getAllRunLabels(); + std::vector<GSASIIRefineFitPeaksParameters> inputParams; + std::vector<std::string> GSASIIProjectFiles; + inputParams.reserve(runLabels.size()); + + const auto refinementMethod = m_view->getRefinementMethod(); + const auto instParamFile = m_view->getInstrumentFileName(); + const auto phaseFiles = m_view->getPhaseFileNames(); + const auto pathToGSASII = m_view->getPathToGSASII(); + const auto GSASIIProjectFile = m_view->getGSASIIProjectPath(); + if (runLabels.size() == 1) { + GSASIIProjectFiles = std::vector<std::string>({GSASIIProjectFile}); + } else { + GSASIIProjectFiles.reserve(runLabels.size()); + for (const auto &runLabel : runLabels) { + GSASIIProjectFiles.emplace_back( + addRunNumberToGSASIIProjectFile(GSASIIProjectFile, runLabel)); + } + } + + const auto dMin = m_view->getPawleyDMin(); + const auto negativeWeight = m_view->getPawleyNegativeWeight(); + const auto xMin = m_view->getXMin(); + const auto xMax = m_view->getXMax(); + const auto refineSigma = m_view->getRefineSigma(); + const auto refineGamma = m_view->getRefineGamma(); + + for (size_t i = 0; i < runLabels.size(); i++) { + const auto &runLabel = runLabels[i]; + const auto inputWS = *(m_multiRunWidget->getFocusedRun(runLabel)); + + inputParams.emplace_back(inputWS, runLabel, refinementMethod, instParamFile, + phaseFiles, pathToGSASII, GSASIIProjectFiles[i], + dMin, negativeWeight, xMin, xMax, refineSigma, + refineGamma); + } + return inputParams; +} + +GSASIIRefineFitPeaksParameters +EnggDiffGSASFittingPresenter::collectInputParameters( + const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &inputWS) const { + const auto refinementMethod = m_view->getRefinementMethod(); + const auto instParamFile = m_view->getInstrumentFileName(); + const auto phaseFiles = m_view->getPhaseFileNames(); + const auto pathToGSASII = m_view->getPathToGSASII(); + const auto GSASIIProjectFile = m_view->getGSASIIProjectPath(); + + const auto dMin = m_view->getPawleyDMin(); + const auto negativeWeight = m_view->getPawleyNegativeWeight(); + const auto xMin = m_view->getXMin(); + const auto xMax = m_view->getXMax(); + const auto refineSigma = m_view->getRefineSigma(); + const auto refineGamma = m_view->getRefineGamma(); + + return GSASIIRefineFitPeaksParameters(inputWS, runLabel, refinementMethod, + instParamFile, phaseFiles, pathToGSASII, + GSASIIProjectFile, dMin, negativeWeight, + xMin, xMax, refineSigma, refineGamma); +} + +void EnggDiffGSASFittingPresenter::displayFitResults(const RunLabel &runLabel) { + const auto latticeParams = m_model->getLatticeParams(runLabel); + const auto rwp = m_model->getRwp(runLabel); + const auto sigma = m_model->getSigma(runLabel); + const auto gamma = m_model->getGamma(runLabel); + + if (!latticeParams || !rwp || !sigma || !gamma) { + m_view->userError("Invalid run identifier", + "Unexpectedly tried to display fit results for invalid " + "run, run number = " + + runLabel.runNumber + + ", bank ID = " + std::to_string(runLabel.bank) + + ". Please contact the development team"); + return; + } + + m_view->displayLatticeParams(*latticeParams); + m_view->displayRwp(*rwp); + m_view->displaySigma(*sigma); + m_view->displayGamma(*gamma); +} + +void EnggDiffGSASFittingPresenter::doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) { + m_model->doRefinements(params); +} + +void EnggDiffGSASFittingPresenter::notifyRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets) { + if (!m_viewHasClosed) { + const auto numRuns = refinementResultSets.size(); + + if (numRuns > 1) { + std::vector<RunLabel> runLabels; + runLabels.reserve(numRuns); + for (const auto &refinementResults : refinementResultSets) { + runLabels.emplace_back(refinementResults.runLabel); + } + m_model->saveRefinementResultsToHDF5( + alg, refinementResultSets, + m_mainSettings->userHDFMultiRunFilename(runLabels)); + } + + m_view->setEnabled(true); + m_view->showStatus("Ready"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementCancelled() { + if (!m_viewHasClosed) { + m_view->setEnabled(true); + m_view->showStatus("Ready"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementFailed( + const std::string &failureMessage) { + if (!m_viewHasClosed) { + m_view->setEnabled(true); + m_view->userWarning("Refinement failed", failureMessage); + m_view->showStatus("Refinement failed"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementSuccessful( + const Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults) { + if (!m_viewHasClosed) { + m_view->showStatus("Saving refinement results"); + const auto filename = m_mainSettings->userHDFRunFilename( + refinementResults.runLabel.runNumber); + + try { + m_model->saveRefinementResultsToHDF5(successfulAlgorithm, + {refinementResults}, filename); + } catch (std::exception &e) { + m_view->userWarning( + "Could not save refinement results", + std::string("Refinement was successful but saving results to " + "HDF5 failed for the following reason:\n") + + e.what()); + } + m_view->setEnabled(true); + m_view->showStatus("Ready"); + + m_multiRunWidget->addFittedPeaks(refinementResults.runLabel, + refinementResults.fittedPeaksWS); + displayFitResults(refinementResults.runLabel); + } +} + +void EnggDiffGSASFittingPresenter::processDoRefinement() { + const auto runLabel = m_multiRunWidget->getSelectedRunLabel(); + if (!runLabel) { + m_view->userWarning("No run selected", + "Please select a run to do refinement on"); + return; + } + + const auto inputWSOptional = m_multiRunWidget->getFocusedRun(*runLabel); + if (!inputWSOptional) { + m_view->userError( + "Invalid run selected for refinement", + "Tried to run refinement on invalid focused run, run number " + + runLabel->runNumber + " and bank ID " + + std::to_string(runLabel->bank) + + ". Please contact the development team with this message"); + return; + } + + m_view->showStatus("Refining run"); + const auto refinementParams = + collectInputParameters(*runLabel, *inputWSOptional); + + m_view->setEnabled(false); + doRefinements({refinementParams}); +} + +void EnggDiffGSASFittingPresenter::processLoadRun() { + const auto focusedFileNames = m_view->getFocusedFileNames(); + + try { + for (const auto fileName : focusedFileNames) { + const auto focusedRun = m_model->loadFocusedRun(fileName); + m_multiRunWidget->addFocusedRun(focusedRun); + } + } catch (const std::exception &ex) { + m_view->userWarning("Could not load file", ex.what()); + } +} + +void EnggDiffGSASFittingPresenter::processRefineAll() { + const auto refinementParams = collectAllInputParameters(); + if (refinementParams.size() == 0) { + m_view->userWarning("No runs loaded", + "Please load at least one run before refining"); + return; + } + m_view->showStatus("Refining run"); + m_view->setEnabled(false); + doRefinements(refinementParams); +} + +void EnggDiffGSASFittingPresenter::processSelectRun() { + const auto runLabel = m_multiRunWidget->getSelectedRunLabel(); + if (runLabel && m_model->hasFitResultsForRun(*runLabel)) { + displayFitResults(*runLabel); + } +} + +void EnggDiffGSASFittingPresenter::processStart() { + auto addMultiRunWidget = m_multiRunWidget->getWidgetAdder(); + (*addMultiRunWidget)(*m_view); + m_view->showStatus("Ready"); +} + +void EnggDiffGSASFittingPresenter::processShutDown() { m_viewHasClosed = true; } + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..6b0c930826551fe71203399969777a0f724f5aaf --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h @@ -0,0 +1,100 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "GSASIIRefineFitPeaksOutputProperties.h" +#include "IEnggDiffGSASFittingModel.h" +#include "IEnggDiffGSASFittingPresenter.h" +#include "IEnggDiffGSASFittingView.h" +#include "IEnggDiffMultiRunFittingWidgetPresenter.h" +#include "IEnggDiffractionParam.h" + +#include "MantidAPI/MatrixWorkspace_fwd.h" + +#include <boost/shared_ptr.hpp> +#include <memory> + +namespace MantidQt { +namespace CustomInterfaces { + +// needs to be dll-exported for the tests +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffGSASFittingPresenter + : public IEnggDiffGSASFittingPresenter { + +public: + EnggDiffGSASFittingPresenter( + std::unique_ptr<IEnggDiffGSASFittingModel> model, + IEnggDiffGSASFittingView *view, + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> multiRunWidget, + boost::shared_ptr<IEnggDiffractionParam> mainSettings); + + EnggDiffGSASFittingPresenter(EnggDiffGSASFittingPresenter &&other) = default; + + EnggDiffGSASFittingPresenter & + operator=(EnggDiffGSASFittingPresenter &&other) = default; + + ~EnggDiffGSASFittingPresenter() override; + + void notify(IEnggDiffGSASFittingPresenter::Notification notif) override; + + void notifyRefinementsComplete( + Mantid::API::IAlgorithm_sptr alg, + const std::vector<GSASIIRefineFitPeaksOutputProperties> + &refinementResultSets) override; + + void notifyRefinementSuccessful( + const Mantid::API::IAlgorithm_sptr successfulAlgorithm, + const GSASIIRefineFitPeaksOutputProperties &refinementResults) override; + + void notifyRefinementFailed(const std::string &failureMessage) override; + + void notifyRefinementCancelled() override; + +private: + void processDoRefinement(); + void processLoadRun(); + void processRefineAll(); + void processSelectRun(); + void processShutDown(); + void processStart(); + + /// Collect GSASIIRefineFitPeaks parameters for all runs loaded in + std::vector<GSASIIRefineFitPeaksParameters> collectAllInputParameters() const; + + /// Collect GSASIIRefineFitPeaks input parameters for a given run from the + /// presenter's various children + GSASIIRefineFitPeaksParameters + collectInputParameters(const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &ws) const; + + /** + Perform refinements on a number of runs + @param params Input parameters for each run to pass to GSASIIRefineFitPeaks + */ + void doRefinements(const std::vector<GSASIIRefineFitPeaksParameters> ¶ms); + + /** + Overplot fitted peaks for a run, and display lattice parameters and Rwp in + the view + @param runLabel Run number and bank ID of the run to display + */ + void displayFitResults(const RunLabel &runLabel); + + std::unique_ptr<IEnggDiffGSASFittingModel> m_model; + + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> m_multiRunWidget; + + boost::shared_ptr<IEnggDiffractionParam> m_mainSettings; + + IEnggDiffGSASFittingView *m_view; + + bool m_viewHasClosed; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c3f88619fe05879a7f1e65c42b426b3b7a7e90f0 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp @@ -0,0 +1,389 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffGSASFittingViewQtWidget.h" +#include "EnggDiffGSASFittingModel.h" +#include "EnggDiffGSASFittingPresenter.h" +#include "EnggDiffMultiRunFittingQtWidget.h" +#include "EnggDiffMultiRunFittingWidgetModel.h" +#include "EnggDiffMultiRunFittingWidgetPresenter.h" + +#include "MantidAPI/TableRow.h" + +#include <QFileDialog> +#include <QSettings> +#include <boost/make_shared.hpp> +#include <utility> + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffGSASFittingViewQtWidget::EnggDiffGSASFittingViewQtWidget( + boost::shared_ptr<IEnggDiffractionUserMsg> userMessageProvider, + const boost::shared_ptr<IEnggDiffractionPythonRunner> &pythonRunner, + boost::shared_ptr<IEnggDiffractionParam> mainSettings) + : m_userMessageProvider(std::move(userMessageProvider)) { + + auto multiRunWidgetModel = + std::make_unique<EnggDiffMultiRunFittingWidgetModel>(); + m_multiRunWidgetView = + std::make_unique<EnggDiffMultiRunFittingQtWidget>(pythonRunner); + + auto multiRunWidgetPresenter = + boost::make_shared<EnggDiffMultiRunFittingWidgetPresenter>( + std::move(multiRunWidgetModel), m_multiRunWidgetView.get()); + + m_multiRunWidgetView->setPresenter(multiRunWidgetPresenter); + m_multiRunWidgetView->setMessageProvider(m_userMessageProvider); + + setupUI(); + + auto model = std::make_unique<EnggDiffGSASFittingModel>(); + auto *model_ptr = model.get(); + m_presenter = boost::make_shared<EnggDiffGSASFittingPresenter>( + std::move(model), this, multiRunWidgetPresenter, mainSettings); + model_ptr->setObserver(m_presenter); + m_presenter->notify(IEnggDiffGSASFittingPresenter::Start); +} + +EnggDiffGSASFittingViewQtWidget::~EnggDiffGSASFittingViewQtWidget() { + QSettings settings(tr(SETTINGS_NAME)); + const auto gsasHome = m_ui.lineEdit_gsasHome->text(); + settings.setValue(tr(GSAS_HOME_SETTING_NAME), gsasHome); + + m_presenter->notify(IEnggDiffGSASFittingPresenter::ShutDown); +} + +void EnggDiffGSASFittingViewQtWidget::addWidget( + IEnggDiffMultiRunFittingWidgetView *widget) { + auto *qWidget = dynamic_cast<QWidget *>(widget); + m_ui.gridLayout_multiRunWidget->addWidget(qWidget, 0, 0); +} + +void EnggDiffGSASFittingViewQtWidget::browseFocusedRun() { + const auto filenames( + QFileDialog::getOpenFileNames(this, tr("Find focused run files"))); + setFocusedRunFileNames(filenames); +} + +void EnggDiffGSASFittingViewQtWidget::browseGSASHome() { + auto directoryName(QFileDialog::getExistingDirectory( + this, tr("GSAS-II installation directory"))); + m_ui.lineEdit_gsasHome->setText(directoryName); +} + +void EnggDiffGSASFittingViewQtWidget::browseGSASProj() { + auto filename(QFileDialog::getSaveFileName( + this, tr("Output GSAS-II project file"), "", "GSAS-II Project (*.gpx)")); + if (!filename.endsWith(".gpx")) { + filename.append(".gpx"); + } + m_ui.lineEdit_gsasProjPath->setText(filename); +} + +void EnggDiffGSASFittingViewQtWidget::browseInstParams() { + const auto filename( + QFileDialog::getOpenFileName(this, tr("Instrument parameter file"), "", + "Instrument parameter file (*.par *.prm)")); + m_ui.lineEdit_instParamsFile->setText(filename); +} + +void EnggDiffGSASFittingViewQtWidget::browsePhaseFiles() { + const auto filenames(QFileDialog::getOpenFileNames( + this, tr("Phase files"), "", "Phase files (*.cif)")); + m_ui.lineEdit_phaseFiles->setText(filenames.join(tr(","))); +} + +void EnggDiffGSASFittingViewQtWidget::disableLoadIfInputEmpty() { + setLoadEnabled(!runFileLineEditEmpty()); +} + +void EnggDiffGSASFittingViewQtWidget::displayLatticeParams( + const Mantid::API::ITableWorkspace_sptr latticeParams) const { + double length_a, length_b, length_c, angle_alpha, angle_beta, angle_gamma; + Mantid::API::TableRow row = latticeParams->getFirstRow(); + row >> length_a >> length_b >> length_c >> angle_alpha >> angle_beta >> + angle_gamma; + m_ui.lineEdit_latticeParamA->setText(QString::number(length_a)); + m_ui.lineEdit_latticeParamB->setText(QString::number(length_b)); + m_ui.lineEdit_latticeParamC->setText(QString::number(length_c)); + m_ui.lineEdit_latticeParamAlpha->setText(QString::number(angle_alpha)); + m_ui.lineEdit_latticeParamBeta->setText(QString::number(angle_beta)); + m_ui.lineEdit_latticeParamGamma->setText(QString::number(angle_gamma)); +} + +void EnggDiffGSASFittingViewQtWidget::displayGamma(const double gamma) const { + m_ui.lineEdit_gamma->setText(QString::number(gamma)); +} + +void EnggDiffGSASFittingViewQtWidget::displayRwp(const double rwp) const { + m_ui.lineEdit_rwp->setText(QString::number(rwp)); +} + +void EnggDiffGSASFittingViewQtWidget::displaySigma(const double sigma) const { + m_ui.lineEdit_sigma->setText(QString::number(sigma)); +} + +void EnggDiffGSASFittingViewQtWidget::doRefinement() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::DoRefinement); +} + +std::vector<std::string> +EnggDiffGSASFittingViewQtWidget::getFocusedFileNames() const { + const auto filenamesQStringList = m_ui.lineEdit_runFile->text().split(","); + std::vector<std::string> filenames; + filenames.reserve(filenamesQStringList.size()); + for (const auto &filenameQString : filenamesQStringList) { + filenames.emplace_back(filenameQString.toStdString()); + } + return filenames; +} + +std::string EnggDiffGSASFittingViewQtWidget::getGSASIIProjectPath() const { + return m_ui.lineEdit_gsasProjPath->text().toStdString(); +} + +std::string EnggDiffGSASFittingViewQtWidget::getInstrumentFileName() const { + return m_ui.lineEdit_instParamsFile->text().toStdString(); +} + +std::string EnggDiffGSASFittingViewQtWidget::getPathToGSASII() const { + return m_ui.lineEdit_gsasHome->text().toStdString(); +} + +boost::optional<double> EnggDiffGSASFittingViewQtWidget::getPawleyDMin() const { + const auto pawleyDMinString = m_ui.lineEdit_pawleyDMin->text(); + if (pawleyDMinString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto pawleyDMin = pawleyDMinString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid Pawley DMin", "Invalid entry for Pawley DMin \"" + + pawleyDMinString.toStdString() + + "\". Using default"); + return boost::none; + } + + return pawleyDMin; +} + +boost::optional<double> +EnggDiffGSASFittingViewQtWidget::getPawleyNegativeWeight() const { + const auto pawleyNegWeightString = m_ui.lineEdit_pawleyNegativeWeight->text(); + if (pawleyNegWeightString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto pawleyNegWeight = + pawleyNegWeightString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid Pawley negative weight", + "Invalid entry for negative weight \"" + + pawleyNegWeightString.toStdString() + "\". Using default"); + return boost::none; + } + + return pawleyNegWeight; +} + +std::vector<std::string> +EnggDiffGSASFittingViewQtWidget::getPhaseFileNames() const { + std::vector<std::string> fileNameStrings; + const auto fileNameQStrings = m_ui.lineEdit_phaseFiles->text().split(","); + fileNameStrings.reserve(fileNameQStrings.size()); + for (const auto &fileNameQString : fileNameQStrings) { + fileNameStrings.emplace_back(fileNameQString.toStdString()); + } + return fileNameStrings; +} + +bool EnggDiffGSASFittingViewQtWidget::getRefineGamma() const { + return m_ui.checkBox_refineGamma->isChecked(); +} + +bool EnggDiffGSASFittingViewQtWidget::getRefineSigma() const { + return m_ui.checkBox_refineSigma->isChecked(); +} + +GSASRefinementMethod +EnggDiffGSASFittingViewQtWidget::getRefinementMethod() const { + const auto refinementMethod = + m_ui.comboBox_refinementMethod->currentText().toStdString(); + if (refinementMethod == "Pawley") { + return GSASRefinementMethod::PAWLEY; + } else if (refinementMethod == "Rietveld") { + return GSASRefinementMethod::RIETVELD; + } else { + userError("Unexpected refinement method", + "Unexpected refinement method \"" + refinementMethod + + "\" selected. Please contact development team with this " + "message. If you choose to continue, Pawley will be used"); + return GSASRefinementMethod::PAWLEY; + } +} + +boost::optional<double> EnggDiffGSASFittingViewQtWidget::getXMax() const { + const auto xMaxString = m_ui.lineEdit_xMax->text(); + if (xMaxString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto xMax = xMaxString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid XMax", "Invalid entry for XMax \"" + + xMaxString.toStdString() + + "\". Using default"); + return boost::none; + } + + return xMax; +} + +boost::optional<double> EnggDiffGSASFittingViewQtWidget::getXMin() const { + const auto xMinString = m_ui.lineEdit_xMin->text(); + if (xMinString.isEmpty()) { + return boost::none; + } + + bool conversionSuccessful(false); + const auto xMin = xMinString.toDouble(&conversionSuccessful); + if (!conversionSuccessful) { + userWarning("Invalid XMin", "Invalid entry for XMin \"" + + xMinString.toStdString() + + "\". Using default"); + return boost::none; + } + + return xMin; +} + +void EnggDiffGSASFittingViewQtWidget::loadFocusedRun() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::LoadRun); +} + +void EnggDiffGSASFittingViewQtWidget::refineAll() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::RefineAll); +} + +bool EnggDiffGSASFittingViewQtWidget::runFileLineEditEmpty() const { + return m_ui.lineEdit_runFile->text().isEmpty(); +} + +void EnggDiffGSASFittingViewQtWidget::selectRun() { + m_presenter->notify(IEnggDiffGSASFittingPresenter::SelectRun); +} + +void EnggDiffGSASFittingViewQtWidget::setEnabled(const bool enabled) { + m_ui.lineEdit_runFile->setEnabled(enabled); + m_ui.pushButton_browseRunFile->setEnabled(enabled); + setLoadEnabled(enabled && !runFileLineEditEmpty()); + + m_ui.lineEdit_instParamsFile->setEnabled(enabled); + m_ui.pushButton_browseInstParams->setEnabled(enabled); + + m_ui.lineEdit_phaseFiles->setEnabled(enabled); + m_ui.pushButton_browsePhaseFiles->setEnabled(enabled); + + m_ui.lineEdit_gsasProjPath->setEnabled(enabled); + m_ui.pushButton_gsasProjPath->setEnabled(enabled); + + m_ui.lineEdit_gsasHome->setEnabled(enabled); + m_ui.pushButton_browseGSASHome->setEnabled(enabled); + + m_ui.comboBox_refinementMethod->setEnabled(enabled); + + m_ui.lineEdit_pawleyDMin->setEnabled(enabled); + m_ui.lineEdit_pawleyNegativeWeight->setEnabled(enabled); + + m_ui.lineEdit_xMin->setEnabled(enabled); + m_ui.lineEdit_xMax->setEnabled(enabled); + + m_ui.checkBox_refineSigma->setEnabled(enabled); + m_ui.checkBox_refineGamma->setEnabled(enabled); + + m_ui.pushButton_doRefinement->setEnabled(enabled); + m_ui.pushButton_refineAll->setEnabled(enabled); + + m_multiRunWidgetView->setEnabled(enabled); +} + +void EnggDiffGSASFittingViewQtWidget::setFocusedRunFileNames( + const QStringList &filenames) { + m_ui.lineEdit_runFile->setText(filenames.join(tr(","))); +} + +void EnggDiffGSASFittingViewQtWidget::setLoadEnabled(const bool enabled) { + if (enabled) { + m_ui.pushButton_loadRun->setEnabled(true); + m_ui.pushButton_loadRun->setToolTip(tr("Load focused run file")); + } else { + m_ui.pushButton_loadRun->setEnabled(false); + m_ui.pushButton_loadRun->setToolTip( + tr("Please specify a file to load via the browse menu or by typing the " + "full path to the file in the text field")); + } +} + +void EnggDiffGSASFittingViewQtWidget::setupUI() { + m_ui.setupUi(this); + connect(m_ui.pushButton_browseRunFile, SIGNAL(clicked()), this, + SLOT(browseFocusedRun())); + connect(m_ui.pushButton_loadRun, SIGNAL(clicked()), this, + SLOT(loadFocusedRun())); + connect(m_ui.lineEdit_runFile, SIGNAL(textChanged(const QString &)), this, + SLOT(disableLoadIfInputEmpty())); + + connect(m_ui.pushButton_browseInstParams, SIGNAL(clicked()), this, + SLOT(browseInstParams())); + connect(m_ui.pushButton_browsePhaseFiles, SIGNAL(clicked()), this, + SLOT(browsePhaseFiles())); + connect(m_ui.pushButton_gsasProjPath, SIGNAL(clicked()), this, + SLOT(browseGSASProj())); + connect(m_ui.pushButton_browseGSASHome, SIGNAL(clicked()), this, + SLOT(browseGSASHome())); + + connect(m_ui.pushButton_doRefinement, SIGNAL(clicked()), this, + SLOT(doRefinement())); + connect(m_ui.pushButton_refineAll, SIGNAL(clicked()), this, + SLOT(refineAll())); + + connect(m_multiRunWidgetView.get(), SIGNAL(runSelected()), this, + SLOT(selectRun())); + + QSettings settings(tr(SETTINGS_NAME)); + if (settings.contains(tr(GSAS_HOME_SETTING_NAME))) { + m_ui.lineEdit_gsasHome->setText( + settings.value(tr(GSAS_HOME_SETTING_NAME)).toString()); + } +} + +void EnggDiffGSASFittingViewQtWidget::showStatus( + const std::string &status) const { + m_userMessageProvider->showStatus(status); +} + +void EnggDiffGSASFittingViewQtWidget::userError( + const std::string &errorTitle, const std::string &errorDescription) const { + m_userMessageProvider->userError(errorTitle, errorDescription); +} + +void EnggDiffGSASFittingViewQtWidget::userWarning( + const std::string &warningTitle, + const std::string &warningDescription) const { + m_userMessageProvider->userWarning(warningTitle, warningDescription); +} + +const char EnggDiffGSASFittingViewQtWidget::GSAS_HOME_SETTING_NAME[] = + "GSAS_HOME"; +const char EnggDiffGSASFittingViewQtWidget::SETTINGS_NAME[] = + "EnggGUIGSASTabSettings"; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..e8807d6329182731cb05768574b3e0f66e4ccfd9 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h @@ -0,0 +1,118 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffMultiRunFittingQtWidget.h" +#include "IEnggDiffGSASFittingPresenter.h" +#include "IEnggDiffGSASFittingView.h" +#include "IEnggDiffractionParam.h" +#include "IEnggDiffractionPythonRunner.h" +#include "IEnggDiffractionUserMsg.h" + +#include <boost/shared_ptr.hpp> +#include <qwt_plot_curve.h> +#include <qwt_plot_zoomer.h> + +#include "ui_EnggDiffractionQtTabGSAS.h" + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffGSASFittingViewQtWidget + : public QWidget, + public IEnggDiffGSASFittingView { + Q_OBJECT + +public: + EnggDiffGSASFittingViewQtWidget( + boost::shared_ptr<IEnggDiffractionUserMsg> userMessageProvider, + const boost::shared_ptr<IEnggDiffractionPythonRunner> &pythonRunner, + boost::shared_ptr<IEnggDiffractionParam> mainSettings); + + ~EnggDiffGSASFittingViewQtWidget() override; + + void addWidget(IEnggDiffMultiRunFittingWidgetView *widget) override; + + void displayLatticeParams( + const Mantid::API::ITableWorkspace_sptr latticeParams) const override; + + void displayGamma(const double gamma) const override; + + void displayRwp(const double rwp) const override; + + void displaySigma(const double sigma) const override; + + std::vector<std::string> getFocusedFileNames() const override; + + std::string getGSASIIProjectPath() const override; + + std::string getInstrumentFileName() const override; + + std::string getPathToGSASII() const override; + + boost::optional<double> getPawleyDMin() const override; + + boost::optional<double> getPawleyNegativeWeight() const override; + + std::vector<std::string> getPhaseFileNames() const override; + + GSASRefinementMethod getRefinementMethod() const override; + + bool getRefineGamma() const override; + + bool getRefineSigma() const override; + + boost::optional<double> getXMax() const override; + + boost::optional<double> getXMin() const override; + + void setEnabled(const bool enabled) override; + + void showStatus(const std::string &status) const override; + + void userError(const std::string &errorTitle, + const std::string &errorDescription) const override; + + void userWarning(const std::string &warningTitle, + const std::string &warningDescription) const override; + +private slots: + void browseFocusedRun(); + void browseGSASHome(); + void browseGSASProj(); + void browseInstParams(); + void browsePhaseFiles(); + void disableLoadIfInputEmpty(); + void doRefinement(); + void loadFocusedRun(); + void refineAll(); + void selectRun(); + +private: + bool runFileLineEditEmpty() const; + + void setLoadEnabled(const bool enabled); + + static const char GSAS_HOME_SETTING_NAME[]; + static const char SETTINGS_NAME[]; + + boost::shared_ptr<EnggDiffMultiRunFittingQtWidget> m_multiRunWidgetView; + + boost::shared_ptr<IEnggDiffGSASFittingPresenter> m_presenter; + + Ui::EnggDiffractionQtTabGSAS m_ui; + + boost::shared_ptr<IEnggDiffractionUserMsg> m_userMessageProvider; + + void setFocusedRunFileNames(const QStringList &filenames); + + void setupUI(); +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc14fa9b51eb061e566ee885bf799cbd6cda1a97 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp @@ -0,0 +1,255 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffMultiRunFittingQtWidget.h" + +#include <utility> + +namespace { + +MantidQt::CustomInterfaces::RunLabel +parseListWidgetItem(const QString &listWidgetItem) { + const auto pieces = listWidgetItem.split("_"); + if (pieces.size() != 2) { + throw std::runtime_error( + "Unexpected run label: \"" + listWidgetItem.toStdString() + + "\". Please contact the development team with this message"); + } + return MantidQt::CustomInterfaces::RunLabel(pieces[0].toStdString(), + pieces[1].toUInt()); +} + +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffMultiRunFittingQtWidget::EnggDiffMultiRunFittingQtWidget( + boost::shared_ptr<IEnggDiffractionPythonRunner> pythonRunner) + : m_pythonRunner(std::move(pythonRunner)) { + setupUI(); + + m_zoomTool = std::make_unique<QwtPlotZoomer>( + QwtPlot::xBottom, QwtPlot::yLeft, + QwtPicker::DragSelection | QwtPicker::CornerToCorner, + QwtPicker::AlwaysOff, m_ui.plotArea->canvas()); + m_zoomTool->setRubberBandPen(QPen(Qt::black)); + m_zoomTool->setEnabled(false); +} + +EnggDiffMultiRunFittingQtWidget::~EnggDiffMultiRunFittingQtWidget() { + cleanUpPlot(); +} + +void EnggDiffMultiRunFittingQtWidget::cleanUpPlot() { + for (auto &curve : m_focusedRunCurves) { + curve->detach(); + } + m_focusedRunCurves.clear(); + for (auto &curve : m_fittedPeaksCurves) { + curve->detach(); + } + m_fittedPeaksCurves.clear(); +} + +std::vector<RunLabel> EnggDiffMultiRunFittingQtWidget::getAllRunLabels() const { + std::vector<RunLabel> runLabels; + runLabels.reserve(m_ui.listWidget_runLabels->count()); + + for (int i = 0; i < m_ui.listWidget_runLabels->count(); i++) { + const auto currentLabel = m_ui.listWidget_runLabels->item(i)->text(); + runLabels.emplace_back(parseListWidgetItem(currentLabel)); + } + return runLabels; +} + +boost::optional<RunLabel> +EnggDiffMultiRunFittingQtWidget::getSelectedRunLabel() const { + if (hasSelectedRunLabel()) { + const auto currentLabel = m_ui.listWidget_runLabels->currentItem()->text(); + return parseListWidgetItem(currentLabel); + } else { + return boost::none; + } +} + +void EnggDiffMultiRunFittingQtWidget::reportNoRunSelectedForPlot() { + userError("No run selected", + "Please select a run from the list before plotting"); +} + +void EnggDiffMultiRunFittingQtWidget::reportPlotInvalidFittedPeaks( + const RunLabel &runLabel) { + userError("Invalid fitted peaks identifier", + "Tried to plot invalid fitted peaks, run number " + + runLabel.runNumber + " and bank ID " + + std::to_string(runLabel.bank) + + ". Please contact the development team with this message"); +} + +void EnggDiffMultiRunFittingQtWidget::reportPlotInvalidFocusedRun( + const RunLabel &runLabel) { + userError("Invalid focused run identifier", + "Tried to plot invalid focused run, run number " + + runLabel.runNumber + " and bank ID " + + std::to_string(runLabel.bank) + + ". Please contact the development team with this message"); +} + +bool EnggDiffMultiRunFittingQtWidget::hasSelectedRunLabel() const { + return m_ui.listWidget_runLabels->selectedItems().size() != 0; +} + +void EnggDiffMultiRunFittingQtWidget::plotFittedPeaksStateChanged() { + m_presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotPeaksStateChanged); +} + +void EnggDiffMultiRunFittingQtWidget::plotFittedPeaks( + const std::vector<boost::shared_ptr<QwtData>> &curves) { + for (const auto &curve : curves) { + auto plotCurve = std::make_unique<QwtPlotCurve>(); + + plotCurve->setPen(QColor(Qt::red)); + plotCurve->setData(*curve); + plotCurve->attach(m_ui.plotArea); + m_fittedPeaksCurves.emplace_back(std::move(plotCurve)); + } + m_ui.plotArea->replot(); + m_zoomTool->setZoomBase(); + m_zoomTool->setEnabled(true); +} + +void EnggDiffMultiRunFittingQtWidget::processPlotToSeparateWindow() { + m_presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); +} + +void EnggDiffMultiRunFittingQtWidget::plotFocusedRun( + const std::vector<boost::shared_ptr<QwtData>> &curves) { + for (const auto &curve : curves) { + auto plotCurve = std::make_unique<QwtPlotCurve>(); + + plotCurve->setData(*curve); + plotCurve->attach(m_ui.plotArea); + m_focusedRunCurves.emplace_back(std::move(plotCurve)); + } + m_ui.plotArea->replot(); + m_zoomTool->setZoomBase(); + m_zoomTool->setEnabled(true); +} + +void EnggDiffMultiRunFittingQtWidget::plotToSeparateWindow( + const std::string &focusedRunName, + const boost::optional<std::string> fittedPeaksName) { + + std::string plotCode = "ws1 = \"" + focusedRunName + "\"\n"; + + plotCode += "workspaceToPlot = \"engg_gui_separate_plot_ws\"\n" + + "if (mtd.doesExist(workspaceToPlot)):\n" + " DeleteWorkspace(workspaceToPlot)\n" + + "ExtractSingleSpectrum(InputWorkspace=ws1, WorkspaceIndex=0, " + "OutputWorkspace=workspaceToPlot)\n" + + "spectra_to_plot = [0]\n"; + + if (fittedPeaksName) { + plotCode += "ws2 = \"" + *fittedPeaksName + "\"\n"; + plotCode += + "ws2_spectrum = ExtractSingleSpectrum(InputWorkspace=ws2, " + "WorkspaceIndex=0, StoreInADS=False)\n" + + "AppendSpectra(InputWorkspace1=workspaceToPlot, " + "InputWorkspace2=ws2_spectrum, OutputWorkspace=workspaceToPlot)\n" + + "DeleteWorkspace(ws2_spectrum)\n" + "spectra_to_plot = [0, 1]\n"; + } + + plotCode += + "plot = plotSpectrum(workspaceToPlot, spectra_to_plot).activeLayer()\n" + "plot.setTitle(\"Engg GUI Fitting Workspaces\")\n"; + m_pythonRunner->enggRunPythonCode(plotCode); +} + +void EnggDiffMultiRunFittingQtWidget::processRemoveRun() { + emit removeRunClicked(); + m_presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::RemoveRun); +} + +void EnggDiffMultiRunFittingQtWidget::processSelectRun() { + emit runSelected(); + m_presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); +} + +void EnggDiffMultiRunFittingQtWidget::resetCanvas() { + cleanUpPlot(); + m_ui.plotArea->replot(); + resetPlotZoomLevel(); +} + +void EnggDiffMultiRunFittingQtWidget::resetPlotZoomLevel() { + m_ui.plotArea->setAxisAutoScale(QwtPlot::xBottom); + m_ui.plotArea->setAxisAutoScale(QwtPlot::yLeft); + m_zoomTool->setZoomBase(true); +} + +void EnggDiffMultiRunFittingQtWidget::setEnabled(const bool enabled) { + m_ui.listWidget_runLabels->setEnabled(enabled); + m_ui.pushButton_removeRun->setEnabled(enabled); + m_ui.pushButton_plotToSeparateWindow->setEnabled(enabled); + m_ui.checkBox_plotFittedPeaks->setEnabled(enabled); + m_zoomTool->setEnabled(enabled); +} + +void EnggDiffMultiRunFittingQtWidget::setMessageProvider( + boost::shared_ptr<IEnggDiffractionUserMsg> messageProvider) { + m_userMessageProvider = messageProvider; +} + +void EnggDiffMultiRunFittingQtWidget::setPresenter( + boost::shared_ptr<IEnggDiffMultiRunFittingWidgetPresenter> presenter) { + m_presenter = presenter; +} + +void EnggDiffMultiRunFittingQtWidget::setupUI() { + m_ui.setupUi(this); + + connect(m_ui.listWidget_runLabels, SIGNAL(itemSelectionChanged()), this, + SLOT(processSelectRun())); + connect(m_ui.checkBox_plotFittedPeaks, SIGNAL(stateChanged(int)), this, + SLOT(plotFittedPeaksStateChanged())); + connect(m_ui.pushButton_removeRun, SIGNAL(clicked()), this, + SLOT(processRemoveRun())); + connect(m_ui.pushButton_plotToSeparateWindow, SIGNAL(clicked()), this, + SLOT(processPlotToSeparateWindow())); +} + +bool EnggDiffMultiRunFittingQtWidget::showFitResultsSelected() const { + return m_ui.checkBox_plotFittedPeaks->isChecked(); +} + +void EnggDiffMultiRunFittingQtWidget::updateRunList( + const std::vector<RunLabel> &runLabels) { + m_ui.listWidget_runLabels->clear(); + for (const auto &runLabel : runLabels) { + const auto labelStr = QString(runLabel.runNumber.c_str()) + tr("_") + + QString::number(runLabel.bank); + m_ui.listWidget_runLabels->addItem(labelStr); + } +} + +void EnggDiffMultiRunFittingQtWidget::userError( + const std::string &errorTitle, const std::string &errorDescription) { + m_userMessageProvider->userError(errorTitle, errorDescription); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..721de6b05ca9cea191e3caea198213d957ed3c01 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.cpp @@ -0,0 +1,227 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffMultiRunFittingWidgetPresenter.h" +#include "EnggDiffMultiRunFittingWidgetAdder.h" + +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/Run.h" + +#include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" + +#include <boost/algorithm/string.hpp> +#include <cctype> + +namespace { + +bool isDigit(const std::string &text) { + return std::all_of(text.cbegin(), text.cend(), isdigit); +} + +std::string +generateFittedPeaksName(const MantidQt::CustomInterfaces::RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_fitted_peaks_external_plot"; +} + +std::string +generateFocusedRunName(const MantidQt::CustomInterfaces::RunLabel &runLabel) { + return runLabel.runNumber + "_" + std::to_string(runLabel.bank) + + "_external_plot"; +} + +size_t guessBankID(const Mantid::API::MatrixWorkspace_const_sptr &ws) { + const static std::string bankIDName = "bankid"; + if (ws->run().hasProperty(bankIDName)) { + const auto log = dynamic_cast<Mantid::Kernel::PropertyWithValue<int> *>( + ws->run().getLogData(bankIDName)); + return boost::lexical_cast<size_t>(log->value()); + } + + // couldn't get it from sample logs - try using the old naming convention + const std::string name = ws->getName(); + std::vector<std::string> chunks; + boost::split(chunks, name, boost::is_any_of("_")); + if (!chunks.empty()) { + const bool isNum = isDigit(chunks.back()); + if (isNum) { + try { + return boost::lexical_cast<size_t>(chunks.back()); + } catch (boost::exception &) { + // If we get a bad cast or something goes wrong then + // the file is probably not what we were expecting + // so throw a runtime error + throw std::runtime_error( + "Failed to fit file: The data was not what is expected. " + "Does the file contain a focused workspace?"); + } + } + } + + throw std::runtime_error("Could not guess run number from input workspace. " + "Are you sure it has been focused correctly?"); +} +} // anonymous namespace + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffMultiRunFittingWidgetPresenter::EnggDiffMultiRunFittingWidgetPresenter( + std::unique_ptr<IEnggDiffMultiRunFittingWidgetModel> model, + IEnggDiffMultiRunFittingWidgetView *view) + : m_model(std::move(model)), m_view(view) {} + +void EnggDiffMultiRunFittingWidgetPresenter::addFittedPeaks( + const RunLabel &runLabel, const Mantid::API::MatrixWorkspace_sptr ws) { + m_model->addFittedPeaks(runLabel, ws); + updatePlot(runLabel); +} + +void EnggDiffMultiRunFittingWidgetPresenter::addFocusedRun( + const Mantid::API::MatrixWorkspace_sptr ws) { + const auto runNumber = std::to_string(ws->getRunNumber()); + const auto bankID = guessBankID(ws); + + m_model->addFocusedRun(RunLabel(runNumber, bankID), ws); + m_view->updateRunList(m_model->getAllWorkspaceLabels()); +} + +void EnggDiffMultiRunFittingWidgetPresenter::displayFitResults( + const RunLabel &runLabel) { + const auto fittedPeaks = m_model->getFittedPeaks(runLabel); + if (!fittedPeaks) { + m_view->reportPlotInvalidFittedPeaks(runLabel); + } else { + const auto plottablePeaks = API::QwtHelper::curveDataFromWs(*fittedPeaks); + m_view->plotFittedPeaks(plottablePeaks); + } +} + +std::vector<RunLabel> +EnggDiffMultiRunFittingWidgetPresenter::getAllRunLabels() const { + return m_view->getAllRunLabels(); +} + +std::unique_ptr<IEnggDiffMultiRunFittingWidgetAdder> +EnggDiffMultiRunFittingWidgetPresenter::getWidgetAdder() const { + return std::make_unique<EnggDiffMultiRunFittingWidgetAdder>(m_view); +} + +boost::optional<Mantid::API::MatrixWorkspace_sptr> +EnggDiffMultiRunFittingWidgetPresenter::getFittedPeaks( + const RunLabel &runLabel) const { + return m_model->getFittedPeaks(runLabel); +} + +boost::optional<Mantid::API::MatrixWorkspace_sptr> +EnggDiffMultiRunFittingWidgetPresenter::getFocusedRun( + const RunLabel &runLabel) const { + return m_model->getFocusedRun(runLabel); +} + +boost::optional<RunLabel> +EnggDiffMultiRunFittingWidgetPresenter::getSelectedRunLabel() const { + return m_view->getSelectedRunLabel(); +} + +void EnggDiffMultiRunFittingWidgetPresenter::notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification notif) { + switch (notif) { + case Notification::PlotPeaksStateChanged: + processPlotPeaksStateChanged(); + break; + + case Notification::PlotToSeparateWindow: + processPlotToSeparateWindow(); + break; + + case Notification::RemoveRun: + processRemoveRun(); + break; + + case Notification::SelectRun: + processSelectRun(); + break; + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processPlotPeaksStateChanged() { + const auto runLabel = getSelectedRunLabel(); + if (runLabel) { + updatePlot(*runLabel); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processPlotToSeparateWindow() { + const auto runLabel = m_view->getSelectedRunLabel(); + if (!runLabel) { + m_view->reportNoRunSelectedForPlot(); + return; + } + + const auto focusedRun = m_model->getFocusedRun(*runLabel); + if (!focusedRun) { + m_view->reportPlotInvalidFocusedRun(*runLabel); + return; + } + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + const auto focusedRunName = generateFocusedRunName(*runLabel); + ADS.add(focusedRunName, *focusedRun); + + boost::optional<std::string> fittedPeaksName = boost::none; + if (m_view->showFitResultsSelected() && + m_model->hasFittedPeaksForRun(*runLabel)) { + fittedPeaksName = generateFittedPeaksName(*runLabel); + const auto fittedPeaks = m_model->getFittedPeaks(*runLabel); + ADS.add(*fittedPeaksName, *fittedPeaks); + } + + m_view->plotToSeparateWindow(focusedRunName, fittedPeaksName); + + ADS.remove(focusedRunName); + if (fittedPeaksName) { + ADS.remove(*fittedPeaksName); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processRemoveRun() { + const auto runLabel = getSelectedRunLabel(); + if (runLabel) { + m_model->removeRun(*runLabel); + m_view->updateRunList(m_model->getAllWorkspaceLabels()); + m_view->resetCanvas(); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::processSelectRun() { + const auto runLabel = getSelectedRunLabel(); + if (runLabel) { + updatePlot(*runLabel); + } +} + +void EnggDiffMultiRunFittingWidgetPresenter::updatePlot( + const RunLabel &runLabel) { + const auto focusedRun = m_model->getFocusedRun(runLabel); + + if (!focusedRun) { + m_view->reportPlotInvalidFocusedRun(runLabel); + } else { + const auto plottableCurve = API::QwtHelper::curveDataFromWs(*focusedRun); + + m_view->resetCanvas(); + m_view->plotFocusedRun(plottableCurve); + + if (m_model->hasFittedPeaksForRun(runLabel) && + m_view->showFitResultsSelected()) { + displayFitResults(runLabel); + } + } +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ff4eceb0d89776edc5153d9040fc455b15e5de8 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.cpp @@ -0,0 +1,2899 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffractionPresenter.h" +#include "EnggDiffractionPresWorker.h" +#include "EnggVanadiumCorrectionsModel.h" +#include "IEnggDiffractionView.h" +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/TableRow.h" +#include "MantidKernel/Property.h" +#include "MantidKernel/StringTokenizer.h" +#include "MantidQtWidgets/Common/PythonRunner.h" + +#include <algorithm> +#include <cctype> +#include <fstream> + +#include <boost/lexical_cast.hpp> + +#include <Poco/File.h> +#include <Poco/Path.h> + +#include <QThread> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace CustomInterfaces { + +namespace { +Mantid::Kernel::Logger g_log("EngineeringDiffractionGUI"); +} + +const std::string EnggDiffractionPresenter::g_runNumberErrorStr = + " cannot be empty, must be an integer number, valid ENGINX run number/s " + "or " + "valid directory/directories."; + +// discouraged at the moment +const bool EnggDiffractionPresenter::g_askUserCalibFilename = false; + +const std::string EnggDiffractionPresenter::g_calibBanksParms = + "engggui_calibration_banks_parameters"; + +int EnggDiffractionPresenter::g_croppedCounter = 0; +int EnggDiffractionPresenter::g_plottingCounter = 0; +bool EnggDiffractionPresenter::g_abortThread = false; +std::string EnggDiffractionPresenter::g_lastValidRun = ""; +std::string EnggDiffractionPresenter::g_calibCropIdentifier = "SpectrumNumbers"; +std::string EnggDiffractionPresenter::g_sumOfFilesFocus = ""; + +EnggDiffractionPresenter::EnggDiffractionPresenter(IEnggDiffractionView *view) + : m_workerThread(nullptr), m_calibFinishedOK(false), + m_focusFinishedOK(false), m_rebinningFinishedOK(false), m_view(view), + m_viewHasClosed(false), + m_vanadiumCorrectionsModel( + boost::make_shared<EnggVanadiumCorrectionsModel>( + m_view->currentCalibSettings(), m_view->currentInstrument())) { + if (!m_view) { + throw std::runtime_error( + "Severe inconsistency found. Presenter created " + "with an empty/null view (Engineering diffraction interface). " + "Cannot continue."); + } + + m_currentInst = m_view->currentInstrument(); +} + +EnggDiffractionPresenter::~EnggDiffractionPresenter() { cleanup(); } + +/** + * Close open sessions, kill threads etc., save settings, etc. for a + * graceful window close/destruction + */ +void EnggDiffractionPresenter::cleanup() { + // m_model->cleanup(); + + // this may still be running + if (m_workerThread) { + if (m_workerThread->isRunning()) { + g_log.notice() << "A calibration process is currently running, shutting " + "it down immediately...\n"; + m_workerThread->wait(10); + } + delete m_workerThread; + m_workerThread = nullptr; + } + + // Remove the workspace which is loaded when the interface starts + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + if (ADS.doesExist(g_calibBanksParms)) { + ADS.remove(g_calibBanksParms); + } +} + +void EnggDiffractionPresenter::notify( + IEnggDiffractionPresenter::Notification notif) { + + // Check the view is valid - QT can send multiple notification + // signals in any order at any time. This means that it is possible + // to receive a shutdown signal and subsequently an input example + // for example. As we can't guarantee the state of the viewer + // after calling shutdown instead we shouldn't do anything after + if (m_viewHasClosed) { + return; + } + + switch (notif) { + + case IEnggDiffractionPresenter::Start: + processStart(); + break; + + case IEnggDiffractionPresenter::LoadExistingCalib: + processLoadExistingCalib(); + break; + + case IEnggDiffractionPresenter::CalcCalib: + processCalcCalib(); + break; + + case IEnggDiffractionPresenter::CropCalib: + ProcessCropCalib(); + break; + + case IEnggDiffractionPresenter::FocusRun: + processFocusBasic(); + break; + + case IEnggDiffractionPresenter::FocusCropped: + processFocusCropped(); + break; + + case IEnggDiffractionPresenter::FocusTexture: + processFocusTexture(); + break; + + case IEnggDiffractionPresenter::ResetFocus: + processResetFocus(); + break; + + case IEnggDiffractionPresenter::RebinTime: + processRebinTime(); + break; + + case IEnggDiffractionPresenter::RebinMultiperiod: + processRebinMultiperiod(); + break; + + case IEnggDiffractionPresenter::LogMsg: + processLogMsg(); + break; + + case IEnggDiffractionPresenter::InstrumentChange: + processInstChange(); + break; + + case IEnggDiffractionPresenter::RBNumberChange: + processRBNumberChange(); + break; + + case IEnggDiffractionPresenter::ShutDown: + processShutDown(); + break; + + case IEnggDiffractionPresenter::StopFocus: + processStopFocus(); + break; + } +} + +void EnggDiffractionPresenter::processStart() { m_view->showStatus("Ready"); } + +void EnggDiffractionPresenter::processLoadExistingCalib() { + const std::string fname = m_view->askExistingCalibFilename(); + if (fname.empty()) { + return; + } + + updateNewCalib(fname); +} + +/** + * Grab a calibration from a (GSAS calibration) file + * (.prm/.par/.iparm) and set/use it as current calibration. + * + * @param fname name/path of the calibration file + */ + +void EnggDiffractionPresenter::updateNewCalib(const std::string &fname) { + + Poco::Path pocoPath; + const bool pathValid = pocoPath.tryParse(fname); + + if (!pathValid || fname.empty() || pocoPath.isDirectory()) { + // Log that we couldn't open the file - its probably and invalid + // path which will be regenerated + g_log.warning("Could not open GSAS calibration file: " + fname); + return; + } + + std::string instName, vanNo, ceriaNo; + try { + parseCalibrateFilename(fname, instName, vanNo, ceriaNo); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Invalid calibration filename : " + fname, ia.what()); + return; + } + + try { + grabCalibParms(fname, vanNo, ceriaNo); + updateCalibParmsTable(); + m_view->newCalibLoaded(vanNo, ceriaNo, fname); + } catch (std::runtime_error &rexc) { + m_view->userWarning("Problem while updating calibration.", rexc.what()); + } +} + +/** + * Get from a calibration file (GSAS instrument parameters file) the + * DIFC, DIFA, TZERO calibration parameters used for units + * conversions. Normally this is used on the ...all_banks.prm file + * which has the parameters for every bank included in the calibration + * process. + * + * @param fname name of the calibration/GSAS iparm file + * @param vanNo output param to hold the vanadium run + * @param ceriaNo output param to hold the ceria run + */ +void EnggDiffractionPresenter::grabCalibParms(const std::string &fname, + std::string &vanNo, + std::string &ceriaNo) { + std::vector<GSASCalibrationParms> parms; + + // To grab the bank indices, lines like "INS BANK 2" + // To grab the difc,difa,tzero parameters, lines like: + // "INS 2 ICONS 18388.00 0.00 -6.76" + try { + std::ifstream prmFile(fname); + std::string line; + int opts = Mantid::Kernel::StringTokenizer::TOK_TRIM + + Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY; + while (std::getline(prmFile, line)) { + if (line.find("ICONS") != std::string::npos) { + Mantid::Kernel::StringTokenizer tokenizer(line, " ", opts); + const size_t numElems = 6; + if (tokenizer.count() == numElems) { + try { + size_t bid = boost::lexical_cast<size_t>(tokenizer[1]); + double difc = boost::lexical_cast<double>(tokenizer[3]); + double difa = boost::lexical_cast<double>(tokenizer[4]); + double tzero = boost::lexical_cast<double>(tokenizer[5]); + parms.emplace_back(GSASCalibrationParms(bid, difc, difa, tzero)); + } catch (std::runtime_error &rexc) { + g_log.warning() + << "Error when trying to extract parameters from this line: " + << line + << ". This calibration file may not load correctly. " + "Error details: " + << rexc.what() << '\n'; + } + } else { + g_log.warning() << "Could not parse correctly a parameters " + "definition line in this calibration file (" + << fname << "). Did not find " << numElems + << " elements as expected. The calibration may not " + "load correctly\n"; + } + } else if (line.find("CALIB") != std::string::npos) { + Mantid::Kernel::StringTokenizer tokenizer(line, " ", opts); + ceriaNo = tokenizer[2]; + vanNo = tokenizer[3]; + } + } + + } catch (std::runtime_error &rexc) { + g_log.error() + << "Error while loading calibration / GSAS IPARM file (" << fname + << "). Could not parse the file. Please check its contents. Details: " + << rexc.what() << '\n'; + } + + m_currentCalibParms = parms; +} + +/** + * Puts in a table workspace, visible in the ADS, the per-bank + * calibration parameters for the current calibration. + */ +void EnggDiffractionPresenter::updateCalibParmsTable() { + if (m_currentCalibParms.empty()) { + return; + } + + ITableWorkspace_sptr parmsTbl; + AnalysisDataServiceImpl &ADS = Mantid::API::AnalysisDataService::Instance(); + if (ADS.doesExist(g_calibBanksParms)) { + parmsTbl = ADS.retrieveWS<ITableWorkspace>(g_calibBanksParms); + parmsTbl->setRowCount(0); + } else { + auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( + "CreateEmptyTableWorkspace"); + alg->initialize(); + alg->setPropertyValue("OutputWorkspace", g_calibBanksParms); + alg->execute(); + + parmsTbl = ADS.retrieveWS<ITableWorkspace>(g_calibBanksParms); + parmsTbl->addColumn("int", "bankid"); + parmsTbl->addColumn("double", "difc"); + parmsTbl->addColumn("double", "difa"); + parmsTbl->addColumn("double", "tzero"); + } + + for (const auto &parms : m_currentCalibParms) { + // ADS.remove(FocusedFitPeaksTableName); + TableRow row = parmsTbl->appendRow(); + row << static_cast<int>(parms.bankid) << parms.difc << parms.difa + << parms.tzero; + } +} + +void EnggDiffractionPresenter::processCalcCalib() { + const std::string vanNo = isValidRunNumber(m_view->newVanadiumNo()); + const std::string ceriaNo = isValidRunNumber(m_view->newCeriaNo()); + try { + inputChecksBeforeCalibrate(vanNo, ceriaNo); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for calibrate", + ia.what()); + return; + } + g_log.notice() << "EnggDiffraction GUI: starting new calibration. This may " + "take a few seconds... \n"; + + const std::string outFilename = outputCalibFilename(vanNo, ceriaNo); + + m_view->showStatus("Calculating calibration..."); + m_view->enableCalibrateFocusFitUserActions(false); + // alternatively, this would be GUI-blocking: + // doNewCalibration(outFilename, vanNo, ceriaNo, ""); + // calibrationFinished(); + startAsyncCalibWorker(outFilename, vanNo, ceriaNo, ""); +} + +void EnggDiffractionPresenter::ProcessCropCalib() { + const std::string vanNo = isValidRunNumber(m_view->newVanadiumNo()); + const std::string ceriaNo = isValidRunNumber(m_view->newCeriaNo()); + int specNoNum = m_view->currentCropCalibBankName(); + enum BankMode { SPECNOS = 0, NORTH = 1, SOUTH = 2 }; + + try { + inputChecksBeforeCalibrate(vanNo, ceriaNo); + if (m_view->currentCalibSpecNos().empty() && + specNoNum == BankMode::SPECNOS) { + throw std::invalid_argument( + "The Spectrum Numbers field cannot be empty, must be a " + "valid range or a Bank Name can be selected instead."); + } + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required for cropped calibration", + ia.what()); + return; + } + + g_log.notice() + << "EnggDiffraction GUI: starting cropped calibration. This may " + "take a few seconds... \n"; + + const std::string outFilename = outputCalibFilename(vanNo, ceriaNo); + + std::string specNo = ""; + if (specNoNum == BankMode::NORTH) { + specNo = "North"; + g_calibCropIdentifier = "Bank"; + + } else if (specNoNum == BankMode::SOUTH) { + specNo = "South"; + g_calibCropIdentifier = "Bank"; + + } else if (specNoNum == BankMode::SPECNOS) { + g_calibCropIdentifier = "SpectrumNumbers"; + specNo = m_view->currentCalibSpecNos(); + } + + m_view->showStatus("Calculating cropped calibration..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncCalibWorker(outFilename, vanNo, ceriaNo, specNo); +} + +void EnggDiffractionPresenter::processFocusBasic() { + std::vector<std::string> multi_RunNo = + isValidMultiRunNumber(m_view->focusingRunNo()); + const std::vector<bool> banks = m_view->focusingBanks(); + + // reset global values + g_abortThread = false; + g_sumOfFilesFocus = ""; + g_plottingCounter = 0; + + // check if valid run number provided before focusin + try { + inputChecksBeforeFocusBasic(multi_RunNo, banks); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required to focus a run", + ia.what()); + return; + } + + int focusMode = m_view->currentMultiRunMode(); + if (focusMode == 0) { + g_log.debug() << " focus mode selected Individual Run Files Separately \n"; + + // start focusing + startFocusing(multi_RunNo, banks, "", ""); + + } else if (focusMode == 1) { + g_log.debug() << " focus mode selected Focus Sum Of Files \n"; + g_sumOfFilesFocus = "basic"; + std::vector<std::string> firstRun; + firstRun.emplace_back(multi_RunNo[0]); + + // to avoid multiple loops, use firstRun instead as the + // multi-run number is not required for sumOfFiles + startFocusing(firstRun, banks, "", ""); + } +} + +void EnggDiffractionPresenter::processFocusCropped() { + const std::vector<std::string> multi_RunNo = + isValidMultiRunNumber(m_view->focusingCroppedRunNo()); + const std::vector<bool> banks = m_view->focusingBanks(); + const std::string specNos = m_view->focusingCroppedSpectrumNos(); + + // reset global values + g_abortThread = false; + g_sumOfFilesFocus = ""; + g_plottingCounter = 0; + + // check if valid run number provided before focusin + try { + inputChecksBeforeFocusCropped(multi_RunNo, banks, specNos); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Error in the inputs required to focus a run (in cropped mode)", + ia.what()); + return; + } + + int focusMode = m_view->currentMultiRunMode(); + if (focusMode == 0) { + g_log.debug() << " focus mode selected Individual Run Files Separately \n"; + + startFocusing(multi_RunNo, banks, specNos, ""); + + } else if (focusMode == 1) { + g_log.debug() << " focus mode selected Focus Sum Of Files \n"; + g_sumOfFilesFocus = "cropped"; + std::vector<std::string> firstRun{multi_RunNo[0]}; + + // to avoid multiple loops, use firstRun instead as the + // multi-run number is not required for sumOfFiles + startFocusing(firstRun, banks, specNos, ""); + } +} + +void EnggDiffractionPresenter::processFocusTexture() { + const std::vector<std::string> multi_RunNo = + isValidMultiRunNumber(m_view->focusingTextureRunNo()); + const std::string dgFile = m_view->focusingTextureGroupingFile(); + + // reset global values + g_abortThread = false; + g_sumOfFilesFocus = ""; + g_plottingCounter = 0; + + // check if valid run number provided before focusing + try { + inputChecksBeforeFocusTexture(multi_RunNo, dgFile); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Error in the inputs required to focus a run (in texture mode)", + ia.what()); + return; + } + + int focusMode = m_view->currentMultiRunMode(); + if (focusMode == 0) { + g_log.debug() << " focus mode selected Individual Run Files Separately \n"; + startFocusing(multi_RunNo, std::vector<bool>(), "", dgFile); + + } else if (focusMode == 1) { + g_log.debug() << " focus mode selected Focus Sum Of Files \n"; + g_sumOfFilesFocus = "texture"; + std::vector<std::string> firstRun{multi_RunNo[0]}; + + // to avoid multiple loops, use firstRun instead as the + // multi-run number is not required for sumOfFiles + startFocusing(firstRun, std::vector<bool>(), "", dgFile); + } +} + +/** + * Starts a focusing worker, for different modes depending on the + * inputs provided. Assumes that the inputs have been checked by the + * respective specific processFocus methods (for normal, cropped, + * texture, etc. focusing). + * + * @param multi_RunNo vector of run/file number to focus + * @param banks banks to include in the focusing, processed one at a time + * + * @param specNos list of spectra to use when focusing. If not empty + * this implies focusing in cropped mode. + * + * @param dgFile detector grouping file to define banks (texture). If + * not empty, this implies focusing in texture mode. + */ +void EnggDiffractionPresenter::startFocusing( + const std::vector<std::string> &multi_RunNo, const std::vector<bool> &banks, + const std::string &specNos, const std::string &dgFile) { + + std::string optMsg = ""; + if (!specNos.empty()) { + optMsg = " (cropped)"; + } else if (!dgFile.empty()) { + optMsg = " (texture)"; + } + g_log.notice() << "EnggDiffraction GUI: starting new focusing" << optMsg + << ". This may take some seconds... \n"; + + m_view->showStatus("Focusing..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncFocusWorker(multi_RunNo, banks, specNos, dgFile); +} + +void EnggDiffractionPresenter::processResetFocus() { m_view->resetFocus(); } + +void EnggDiffractionPresenter::processRebinTime() { + + const std::string runNo = isValidRunNumber(m_view->currentPreprocRunNo()); + double bin = m_view->rebinningTimeBin(); + + try { + inputChecksBeforeRebinTime(runNo, bin); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Error in the inputs required to pre-process (rebin) a run", ia.what()); + return; + } + + const std::string outWSName = "engggui_preproc_time_ws"; + g_log.notice() << "EnggDiffraction GUI: starting new pre-processing " + "(re-binning) with a TOF bin into workspace '" + + outWSName + + "'. This " + "may take some seconds... \n"; + + m_view->showStatus("Rebinning by time..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncRebinningTimeWorker(runNo, bin, outWSName); +} + +void EnggDiffractionPresenter::processRebinMultiperiod() { + const std::string runNo = isValidRunNumber(m_view->currentPreprocRunNo()); + size_t nperiods = m_view->rebinningPulsesNumberPeriods(); + double timeStep = m_view->rebinningPulsesTime(); + + try { + inputChecksBeforeRebinPulses(runNo, nperiods, timeStep); + } catch (std::invalid_argument &ia) { + m_view->userWarning("Error in the inputs required to pre-process (rebin) a " + "run by pulse times", + ia.what()); + return; + } + const std::string outWSName = "engggui_preproc_by_pulse_time_ws"; + g_log.notice() << "EnggDiffraction GUI: starting new pre-processing " + "(re-binning) by pulse times into workspace '" + + outWSName + + "'. This " + "may take some seconds... \n"; + + m_view->showStatus("Rebinning by pulses..."); + m_view->enableCalibrateFocusFitUserActions(false); + startAsyncRebinningPulsesWorker(runNo, nperiods, timeStep, outWSName); +} + +void EnggDiffractionPresenter::processLogMsg() { + std::vector<std::string> msgs = m_view->logMsgs(); + for (const auto &msg : msgs) { + g_log.information() << msg << '\n'; + } +} + +void EnggDiffractionPresenter::processInstChange() { + m_currentInst = m_view->currentInstrument(); + m_view->updateTabsInstrument(m_currentInst); +} + +void EnggDiffractionPresenter::processRBNumberChange() { + const std::string rbn = m_view->getRBNumber(); + auto valid = validateRBNumber(rbn); + m_view->enableTabs(valid); + m_view->showInvalidRBNumber(valid); + if (!valid) { + m_view->showStatus("Valid RB number required"); + } else { + m_view->showStatus("Ready"); + } +} + +void EnggDiffractionPresenter::processShutDown() { + // Set that the view has closed in case QT attempts to fire another + // signal whilst we are shutting down. This stops notify before + // it hits the switch statement as the view could be in any state. + m_viewHasClosed = true; + m_view->showStatus("Closing..."); + m_view->saveSettings(); + cleanup(); +} + +void EnggDiffractionPresenter::processStopFocus() { + if (m_workerThread) { + if (m_workerThread->isRunning()) { + g_log.notice() << "A focus process is currently running, shutting " + "it down as soon as possible...\n"; + + g_abortThread = true; + g_log.warning() << "Focus Stop has been clicked, please wait until " + "current focus run process has been completed. \n"; + } + } +} + +/** + * Check if an RB number is valid to work with it (retrieve data, + * calibrate, focus, etc.). For now this will accept any non-empty + * string. Later on we might be more strict about valid RB numbers / + * experiment IDs. + * + * @param rbn RB number as given by the user + */ +bool EnggDiffractionPresenter::validateRBNumber(const std::string &rbn) const { + return !rbn.empty(); +} + +/** + * Checks if the provided run number is valid and if a directory is + * provided it will convert it to a run number. It also records the + * paths the user has browsed to. + * + * @param userPaths the input/directory given by the user via the "browse" + * button + * + * @return run_number 6 character string of a run number + */ +std::string EnggDiffractionPresenter::isValidRunNumber( + const std::vector<std::string> &userPaths) { + + std::string run_number; + if (userPaths.empty() || userPaths.front().empty()) { + return run_number; + } + return userPaths[0]; +} + +/** + * Checks if the provided run number is valid and if a directory is provided + * + * @param paths takes the input/paths of the user + * + * @return vector of string multi_run_number, 6 character string of a run number + */ +std::vector<std::string> EnggDiffractionPresenter::isValidMultiRunNumber( + const std::vector<std::string> &paths) { + + std::vector<std::string> multi_run_number; + if (paths.empty() || paths.front().empty()) + return multi_run_number; + return paths; +} + +/** + * Does several checks on the current inputs and settings. This should + * be done before starting any calibration work. The message return + * should in principle be shown to the user as a visible message + * (pop-up, error log, etc.) + * + * @param newVanNo number of the Vanadium run for the new calibration + * @param newCeriaNo number of the Ceria run for the new calibration + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeCalibrate( + const std::string &newVanNo, const std::string &newCeriaNo) { + if (newVanNo.empty()) { + throw std::invalid_argument("The Vanadium number" + g_runNumberErrorStr); + } + if (newCeriaNo.empty()) { + throw std::invalid_argument("The Ceria number" + g_runNumberErrorStr); + } + + const auto &cs = m_view->currentCalibSettings(); + const auto &pixelCalib = cs.m_pixelCalibFilename; + if (pixelCalib.empty()) { + throw std::invalid_argument( + "You need to set a pixel (full) calibration in settings."); + } + const auto &templGSAS = cs.m_templateGSAS_PRM; + if (templGSAS.empty()) { + throw std::invalid_argument( + "You need to set a template calibration file for GSAS in settings."); + } +} + +/** + * What should be the name of the output GSAS calibration file, given + * the Vanadium and Ceria runs + * + * @param vanNo number of the Vanadium run, which is normally part of the name + * @param ceriaNo number of the Ceria run, which is normally part of the name + * @param bankName bank name when generating a file for an individual + * bank. Leave empty to use a generic name for all banks + * + * @return filename (without the full path) + */ +std::string +EnggDiffractionPresenter::outputCalibFilename(const std::string &vanNo, + const std::string &ceriaNo, + const std::string &bankName) { + std::string outFilename = ""; + const std::string sugg = + buildCalibrateSuggestedFilename(vanNo, ceriaNo, bankName); + if (!g_askUserCalibFilename) { + outFilename = sugg; + } else { + outFilename = m_view->askNewCalibrationFilename(sugg); + if (!outFilename.empty()) { + // make sure it follows the rules + try { + std::string inst, van, ceria; + parseCalibrateFilename(outFilename, inst, van, ceria); + } catch (std::invalid_argument &ia) { + m_view->userWarning( + "Invalid output calibration filename: " + outFilename, ia.what()); + outFilename = ""; + } + } + } + + return outFilename; +} + +/** + * Parses the name of a calibration file and guesses the instrument, + * vanadium and ceria run numbers, assuming that the name has been + * build with buildCalibrateSuggestedFilename(). + * + * @todo this is currently based on the filename. This method should + * do a basic sanity check that the file is actually a calibration + * file (IPARM file for GSAS), and get the numbers from the file not + * from the name of the file. Leaving this as a TODO for now, as the + * file template and contents are still subject to change. + * + * @param path full path to a calibration file + * @param instName instrument used in the file + * @param vanNo number of the Vanadium run used for this calibration file + * @param ceriaNo number of the Ceria run + * + * @throws invalid_argument with an informative message if tha name does + * not look correct (does not follow the conventions). + */ +void EnggDiffractionPresenter::parseCalibrateFilename(const std::string &path, + std::string &instName, + std::string &vanNo, + std::string &ceriaNo) { + instName = ""; + vanNo = ""; + ceriaNo = ""; + + Poco::Path fullPath(path); + const std::string &filename = fullPath.getFileName(); + if (filename.empty()) { + return; + } + + const std::string explMsg = + "Expected a file name like 'INSTR_vanNo_ceriaNo_....par', " + "where INSTR is the instrument name and vanNo and ceriaNo are the " + "numbers of the Vanadium and calibration sample (Ceria, CeO2) runs."; + std::vector<std::string> parts; + boost::split(parts, filename, boost::is_any_of("_")); + if (parts.size() < 4) { + throw std::invalid_argument( + "Failed to find at least the 4 required parts of the file name.\n\n" + + explMsg); + } + + // check the rules on the file name + if (m_currentInst != parts[0]) { + throw std::invalid_argument("The first component of the file name is not " + "the expected instrument name: " + + m_currentInst + ".\n\n" + explMsg); + } + + instName = parts[0]; +} + +/** + * Start the calibration work without blocking the GUI. This uses + * connect for Qt signals/slots so that it runs well with the Qt event + * loop. Because of that this class needs to be a Q_OBJECT. + * + * @param outFilename name for the output GSAS calibration file + * @param vanNo vanadium run number + * @param ceriaNo ceria run number + * @param specNos SpecNos or bank name to be passed + */ +void EnggDiffractionPresenter::startAsyncCalibWorker( + const std::string &outFilename, const std::string &vanNo, + const std::string &ceriaNo, const std::string &specNos) { + delete m_workerThread; + m_workerThread = new QThread(this); + auto *worker = new EnggDiffWorker(this, outFilename, vanNo, ceriaNo, specNos); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(calibrate())); + connect(worker, SIGNAL(finished()), this, SLOT(calibrationFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Calculate a new calibration. This is what threads/workers should + * use to run the calculations in response to the user clicking + * 'calibrate' or similar. + * + * @param outFilename name for the output GSAS calibration file + * @param vanNo vanadium run number + * @param ceriaNo ceria run number + * @param specNos SpecNos or bank name to be passed + */ +void EnggDiffractionPresenter::doNewCalibration(const std::string &outFilename, + const std::string &vanNo, + const std::string &ceriaNo, + const std::string &specNos) { + g_log.notice() << "Generating new calibration file: " << outFilename << '\n'; + + EnggDiffCalibSettings cs = m_view->currentCalibSettings(); + Mantid::Kernel::ConfigServiceImpl &conf = + Mantid::Kernel::ConfigService::Instance(); + const std::vector<std::string> tmpDirs = conf.getDataSearchDirs(); + // in principle, the run files will be found from 'DirRaw', and the + // pre-calculated Vanadium corrections from 'DirCalib' + if (!cs.m_inputDirCalib.empty() && Poco::File(cs.m_inputDirCalib).exists()) { + conf.appendDataSearchDir(cs.m_inputDirCalib); + } + if (!cs.m_inputDirRaw.empty() && Poco::File(cs.m_inputDirRaw).exists()) + conf.appendDataSearchDir(cs.m_inputDirRaw); + for (const auto &browsed : m_browsedToPaths) { + conf.appendDataSearchDir(browsed); + } + + try { + m_calibFinishedOK = true; + doCalib(cs, vanNo, ceriaNo, outFilename, specNos); + } catch (std::runtime_error &rexc) { + m_calibFinishedOK = false; + m_calibError = "The calibration calculations failed. One of the " + "algorithms did not execute correctly. See log messages for " + "further details."; + g_log.error() + << "The calibration calculations failed. One of the " + "algorithms did not execute correctly. See log messages for " + "further details. Error: " + + std::string(rexc.what()) + << '\n'; + } catch (std::invalid_argument &iaexc) { + m_calibFinishedOK = false; + m_calibError = "The calibration calculations failed. Some input properties " + "were not valid. See log messages for details. \n Error: " + + std::string(iaexc.what()); + g_log.error() + << "The calibration calculations failed. Some input properties " + "were not valid. See log messages for details. \n"; + } catch (Mantid::API::Algorithm::CancelException &) { + m_calibFinishedOK = false; + m_cancelled = true; + g_log.warning() << "Execution cancelled by user. \n"; + } + // restore normal data search paths + conf.setDataSearchDirs(tmpDirs); +} + +/** + * Method to call when the calibration work has finished, either from + * a separate thread or not (as in this presenter's' test). + */ +void EnggDiffractionPresenter::calibrationFinished() { + if (!m_view) + return; + + m_view->enableCalibrateFocusFitUserActions(true); + if (!m_calibFinishedOK) { + if (!m_cancelled) { + m_view->userWarning("Calibration Error", m_calibError); + } + m_cancelled = false; + + m_view->showStatus("Calibration didn't finish succesfully. Ready"); + } else { + const std::string vanNo = isValidRunNumber(m_view->newVanadiumNo()); + + const std::string ceriaNo = isValidRunNumber(m_view->newCeriaNo()); + updateCalibParmsTable(); + m_view->newCalibLoaded(vanNo, ceriaNo, m_calibFullPath); + g_log.notice() + << "Calibration finished and ready as 'current calibration'.\n"; + m_view->showStatus("Calibration finished succesfully. Ready"); + } + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } +} + +/** + * Build a suggested name for a new calibration, by appending instrument name, + * relevant run numbers, etc., like: ENGINX_241391_236516_all_banks.par + * + * @param vanNo number of the Vanadium run + * @param ceriaNo number of the Ceria run + * @param bankName bank name when generating a file for an individual + * bank. Leave empty to use a generic name for all banks + * + * @return Suggested name for a new calibration file, following + * ENGIN-X practices + */ +std::string EnggDiffractionPresenter::buildCalibrateSuggestedFilename( + const std::string &vanNo, const std::string &ceriaNo, + const std::string &bankName) const { + // default and only one supported instrument for now + std::string instStr = m_currentInst; + std::string nameAppendix = "_all_banks"; + if (!bankName.empty()) { + nameAppendix = "_" + bankName; + } + + // default extension for calibration files + const std::string calibExt = ".prm"; + std::string vanFilename = Poco::Path(vanNo).getBaseName(); + std::string ceriaFilename = Poco::Path(ceriaNo).getBaseName(); + std::string vanRun = + vanFilename.substr(vanFilename.find(instStr) + instStr.size()); + std::string ceriaRun = + ceriaFilename.substr(ceriaFilename.find(instStr) + instStr.size()); + vanRun.erase(0, std::min(vanRun.find_first_not_of('0'), vanRun.size() - 1)); + ceriaRun.erase( + 0, std::min(ceriaRun.find_first_not_of('0'), ceriaRun.size() - 1)); + std::string sugg = + instStr + "_" + vanRun + "_" + ceriaRun + nameAppendix + calibExt; + + return sugg; +} + +std::vector<GSASCalibrationParms> +EnggDiffractionPresenter::currentCalibration() const { + return m_currentCalibParms; +} + +/** + * Calculate a calibration, responding the the "new calibration" + * action/button. + * + * @param cs user settings + * @param vanNo Vanadium run number + * @param ceriaNo Ceria run number + * @param outFilename output filename chosen by the user + * @param specNos SpecNos or bank name to be passed + */ +void EnggDiffractionPresenter::doCalib(const EnggDiffCalibSettings &cs, + const std::string &vanNo, + const std::string &ceriaNo, + const std::string &outFilename, + const std::string &specNos) { + if (cs.m_inputDirCalib.empty()) { + m_calibError = + "No calibration directory selected. Please select a calibration " + "directory in Settings. This will be used to " + "cache Vanadium calibration data"; + g_log.warning("No calibration directory selected. Please select a " + "calibration directory in Settings. This will be used to " + "cache Vanadium calibration data"); + // This should be a userWarning once the threading problem has been dealt + // with + m_calibFinishedOK = false; + return; + } + + // TODO: the settings tab should emit a signal when these are changed, on + // which the vanadium corrections model should be updated automatically + m_vanadiumCorrectionsModel->setCalibSettings(cs); + m_vanadiumCorrectionsModel->setCurrentInstrument(m_view->currentInstrument()); + const auto vanadiumCorrectionWorkspaces = + m_vanadiumCorrectionsModel->fetchCorrectionWorkspaces(vanNo); + const auto &vanIntegWS = vanadiumCorrectionWorkspaces.first; + const auto &vanCurvesWS = vanadiumCorrectionWorkspaces.second; + + MatrixWorkspace_sptr ceriaWS; + try { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", ceriaNo); + const std::string ceriaWSName = "engggui_calibration_sample_ws"; + load->setPropertyValue("OutputWorkspace", ceriaWSName); + load->execute(); + + AnalysisDataServiceImpl &ADS = Mantid::API::AnalysisDataService::Instance(); + ceriaWS = ADS.retrieveWS<MatrixWorkspace>(ceriaWSName); + } catch (std::runtime_error &re) { + g_log.error() + << "Error while loading calibration sample data. " + "Could not run the algorithm Load succesfully for the " + "calibration " + "sample (run number: " + + ceriaNo + "). Error description: " + re.what() + + " Please check also the previous log messages for details."; + throw; + } + + // Bank 1 and 2 - ENGIN-X + // bank 1 - loops once & used for cropped calibration + // bank 2 - loops twice, one with each bank & used for new calibration + std::vector<double> difa, difc, tzero; + // for the names of the output files + std::vector<std::string> bankNames; + + bool specNumUsed = specNos != ""; + // TODO: this needs sanitizing, it should be simpler + if (specNumUsed) { + constexpr size_t bankNo1 = 1; + + difa.resize(bankNo1); + difc.resize(bankNo1); + tzero.resize(bankNo1); + int selection = m_view->currentCropCalibBankName(); + if (0 == selection) { + // user selected "custom" name + const std::string customName = m_view->currentCalibCustomisedBankName(); + if (customName.empty()) { + bankNames.emplace_back("cropped"); + } else { + bankNames.emplace_back(customName); + } + } else if (1 == selection) { + bankNames.emplace_back("North"); + } else { + bankNames.emplace_back("South"); + } + } else { + constexpr size_t bankNo2 = 2; + + difa.resize(bankNo2); + difc.resize(bankNo2); + tzero.resize(bankNo2); + bankNames = {"North", "South"}; + } + + for (size_t i = 0; i < difc.size(); i++) { + auto alg = + Mantid::API::AlgorithmManager::Instance().create("EnggCalibrate"); + + alg->initialize(); + alg->setProperty("InputWorkspace", ceriaWS); + alg->setProperty("VanIntegrationWorkspace", vanIntegWS); + alg->setProperty("VanCurvesWorkspace", vanCurvesWS); + if (specNumUsed) { + alg->setPropertyValue(g_calibCropIdentifier, + boost::lexical_cast<std::string>(specNos)); + } else { + alg->setPropertyValue("Bank", boost::lexical_cast<std::string>(i + 1)); + } + const std::string outFitParamsTblName = + outFitParamsTblNameGenerator(specNos, i); + alg->setPropertyValue("FittedPeaks", outFitParamsTblName); + alg->setPropertyValue("OutputParametersTableName", outFitParamsTblName); + alg->execute(); + if (!alg->isExecuted()) { + g_log.error() << "Error in calibration. ", + "Could not run the algorithm EnggCalibrate successfully for bank " + + boost::lexical_cast<std::string>(i); + throw std::runtime_error("EnggCalibrate failed"); + } + + difa[i] = alg->getProperty("DIFA"); + difc[i] = alg->getProperty("DIFC"); + tzero[i] = alg->getProperty("TZERO"); + + g_log.information() << " * Bank " << i + 1 << " calibrated, " + << "difa: " << difa[i] << ", difc: " << difc[i] + << ", zero: " << tzero[i] << '\n'; + } + + // Creates appropriate output directory + const std::string calibrationComp = "Calibration"; + const Poco::Path userCalSaveDir = outFilesUserDir(calibrationComp); + const Poco::Path generalCalSaveDir = outFilesGeneralDir(calibrationComp); + + // Use poco to append filename so it is OS independent + std::string userCalFullPath = + appendToPath(userCalSaveDir.toString(), outFilename); + std::string generalCalFullPath = + appendToPath(generalCalSaveDir.toString(), outFilename); + + // Double horror: 1st use a python script + // 2nd: because runPythonCode does this by emitting a signal that goes to + // MantidPlot, it has to be done in the view (which is a UserSubWindow). + // First write the all banks parameters file + m_calibFullPath = generalCalSaveDir.toString(); + writeOutCalibFile(userCalFullPath, difa, difc, tzero, bankNames, ceriaNo, + vanNo); + writeOutCalibFile(generalCalFullPath, difa, difc, tzero, bankNames, ceriaNo, + vanNo); + + m_currentCalibParms.clear(); + + // Then write one individual file per bank, using different templates and the + // specific bank name as suffix + for (size_t bankIdx = 0; bankIdx < difc.size(); ++bankIdx) { + // Need to use van number not file name here else it will be + // "ENGINX_ENGINX12345_ENGINX12345...." as out name + const std::string bankFilename = buildCalibrateSuggestedFilename( + vanNo, ceriaNo, "bank_" + bankNames[bankIdx]); + + // Regenerate both full paths for each bank now + userCalFullPath = appendToPath(userCalSaveDir.toString(), bankFilename); + generalCalFullPath = + appendToPath(generalCalSaveDir.toString(), bankFilename); + + std::string templateFile = "template_ENGINX_241391_236516_North_bank.prm"; + if (1 == bankIdx) { + templateFile = "template_ENGINX_241391_236516_South_bank.prm"; + } + + writeOutCalibFile(userCalFullPath, {difa[bankIdx]}, {difc[bankIdx]}, + {tzero[bankIdx]}, {bankNames[bankIdx]}, ceriaNo, vanNo, + templateFile); + writeOutCalibFile(generalCalFullPath, {difa[bankIdx]}, {difc[bankIdx]}, + {tzero[bankIdx]}, {bankNames[bankIdx]}, ceriaNo, vanNo, + templateFile); + + m_currentCalibParms.emplace_back(GSASCalibrationParms( + bankIdx, difc[bankIdx], difa[bankIdx], tzero[bankIdx])); + if (1 == difc.size()) { + // it is a single bank or cropped calibration, so take its specific name + m_calibFullPath = generalCalFullPath; + } + } + g_log.notice() << "Calibration file written as " << generalCalFullPath << '\n' + << "And: " << userCalFullPath; + + // plots the calibrated workspaces. + g_plottingCounter++; + plotCalibWorkspace(difa, difc, tzero, specNos); +} + +/** + * Appends the current instrument as a filename prefix for numeric + * only inputs of the Vanadium run so Load can find the file + * + * @param vanNo The user input for the vanadium run + * @param outVanName The fixed filename for the vanadium run + */ +void EnggDiffractionPresenter::appendCalibInstPrefix( + const std::string &vanNo, std::string &outVanName) const { + // Use a single non numeric digit so we are guaranteed to skip + // generating cerium file names + const std::string cer = "-"; + std::string outCerName; + appendCalibInstPrefix(vanNo, cer, outVanName, outCerName); +} + +/** + * Appends the current instrument as a filename prefix for numeric + * only inputs of both the Vanadium and Cerium Oxide runs so Load + * can find the files. + * + * @param vanNo The user input for the vanadium run + * @param cerNo The user input for the cerium run + * @param outVanName The fixed filename for the vanadium run + * @param outCerName The fixed filename for the cerium run + */ +void EnggDiffractionPresenter::appendCalibInstPrefix( + const std::string &vanNo, const std::string &cerNo, std::string &outVanName, + std::string &outCerName) const { + + // Load uses the default instrument if we don't give it the name of the + // instrument as a prefix (m_currentInst), when one isn't set or is set + // incorrectly, we prepend the name of the instrument to the vanadium number + // so that load can find the file and not cause a crash in Mantid + // Vanadium file + if (std::all_of(vanNo.begin(), vanNo.end(), ::isdigit)) { + // This only has digits - append prefix + outVanName = m_currentInst + vanNo; + } + + // Cerium file + if (std::all_of(cerNo.begin(), cerNo.end(), ::isdigit)) { + // All digits - append inst prefix + outCerName = m_currentInst + cerNo; + } +} + +/** + * Perform checks specific to normal/basic run focusing in addition to + * the general checks for any focusing (as done by + * inputChecksBeforeFocus() which is called from this method). Use + * always before running 'Focus' + * + * @param multi_RunNo vector of run number to focus + * @param banks which banks to consider in the focusing + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocusBasic( + const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks) { + if (multi_RunNo.size() == 0) { + const std::string msg = "The sample run number" + g_runNumberErrorStr; + throw std::invalid_argument(msg); + } + + inputChecksBanks(banks); + + inputChecksBeforeFocus(); +} + +/** + * Perform checks specific to focusing in "cropped" mode, in addition + * to the general checks for any focusing (as done by + * inputChecksBeforeFocus() which is called from this method). Use + * always before running 'FocusCropped' + * + * @param multi_RunNo vector of run number to focus + * @param banks which banks to consider in the focusing + * @param specNos list of spectra (as usual csv list of spectra in Mantid) + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocusCropped( + const std::vector<std::string> &multi_RunNo, const std::vector<bool> &banks, + const std::string &specNos) { + if (multi_RunNo.size() == 0) { + throw std::invalid_argument("To focus cropped the sample run number" + + g_runNumberErrorStr); + } + + if (specNos.empty()) { + throw std::invalid_argument( + "The Spectrum Numbers field cannot be empty when " + "focusing in 'cropped' mode."); + } + + inputChecksBanks(banks); + + inputChecksBeforeFocus(); +} + +/** + * Perform checks specific to focusing in "texture" mode, in addition + * to the general checks for any focusing (as done by + * inputChecksBeforeFocus() which is called from this method). Use + * always before running 'FocusCropped' + * + * @param multi_RunNo vector of run number to focus + * @param dgFile file with detector grouping info + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocusTexture( + const std::vector<std::string> &multi_RunNo, const std::string &dgFile) { + if (multi_RunNo.size() == 0) { + throw std::invalid_argument("To focus texture banks the sample run number" + + g_runNumberErrorStr); + } + + if (dgFile.empty()) { + throw std::invalid_argument("A detector grouping file needs to be " + "specified when focusing texture banks."); + } + Poco::File dgf(dgFile); + if (!dgf.exists()) { + throw std::invalid_argument( + "The detector grouping file coult not be found: " + dgFile); + } + + inputChecksBeforeFocus(); +} + +void EnggDiffractionPresenter::inputChecksBanks( + const std::vector<bool> &banks) { + if (0 == banks.size()) { + const std::string msg = + "Error in specification of banks found when starting the " + "focusing process. Cannot continue."; + g_log.error() << msg << '\n'; + throw std::invalid_argument(msg); + } + if (banks.end() == std::find(banks.begin(), banks.end(), true)) { + const std::string msg = + "EnggDiffraction GUI: not focusing, as none of the banks " + "have been selected. You probably forgot to select at least one."; + g_log.warning() << msg << '\n'; + throw std::invalid_argument(msg); + } +} + +/** + * Performs several checks on the current focusing inputs and + * settings. This should be done before starting any focus work. The + * message return should be shown to the user as a visible message + * (pop-up, error log, etc.) + * + * @throws std::invalid_argument with an informative message. + */ +void EnggDiffractionPresenter::inputChecksBeforeFocus() { + EnggDiffCalibSettings cs = m_view->currentCalibSettings(); + const std::string pixelCalib = cs.m_pixelCalibFilename; + if (pixelCalib.empty()) { + throw std::invalid_argument( + "You need to set a pixel (full) calibration in settings."); + } +} + +/** + * Builds the names of the output focused files (one per bank), given + * the sample run number and which banks should be focused. + * + * @param runNo number of the run for which we want a focused output + * file name + * + * @param banks for every bank, (true/false) to consider it or not for + * the focusing + * + * @return filenames (without the full path) + */ +std::vector<std::string> +EnggDiffractionPresenter::outputFocusFilenames(const std::string &runNo, + const std::vector<bool> &banks) { + const std::string instStr = m_view->currentInstrument(); + const std::string runNumber = Poco::Path(runNo).getBaseName(); + std::vector<std::string> res; + res.reserve(banks.size()); + const auto instrumentPresent = runNumber.find(instStr); + std::string runName = + (instrumentPresent != std::string::npos) + ? runNumber.substr(instrumentPresent + instStr.size()) + : runNumber; + + std::string prefix = instStr + "_" + + runName.erase(0, std::min(runName.find_first_not_of('0'), + runName.size() - 1)) + + "_focused_bank_"; + + for (size_t b = 1; b <= banks.size(); b++) { + res.emplace_back(prefix + boost::lexical_cast<std::string>(b) + ".nxs"); + } + return res; +} + +std::string +EnggDiffractionPresenter::outputFocusCroppedFilename(const std::string &runNo) { + const std::string instStr = m_view->currentInstrument(); + const std::string runNumber = Poco::Path(runNo).getBaseName(); + const auto instrumentPresent = runNumber.find(instStr); + std::string runName = + (instrumentPresent != std::string::npos) + ? runNumber.substr(instrumentPresent + instStr.size()) + : runNumber; + return instStr + "_" + + runName.erase( + 0, std::min(runName.find_first_not_of('0'), runName.size() - 1)) + + "_focused_cropped.nxs"; +} + +std::vector<std::string> EnggDiffractionPresenter::sumOfFilesLoadVec() { + std::vector<std::string> multi_RunNo; + + if (g_sumOfFilesFocus == "basic") + multi_RunNo = isValidMultiRunNumber(m_view->focusingRunNo()); + else if (g_sumOfFilesFocus == "cropped") + multi_RunNo = isValidMultiRunNumber(m_view->focusingCroppedRunNo()); + else if (g_sumOfFilesFocus == "texture") + multi_RunNo = isValidMultiRunNumber(m_view->focusingTextureRunNo()); + + return multi_RunNo; +} + +std::vector<std::string> EnggDiffractionPresenter::outputFocusTextureFilenames( + const std::string &runNo, const std::vector<size_t> &bankIDs) { + const std::string instStr = m_view->currentInstrument(); + const std::string runNumber = Poco::Path(runNo).getBaseName(); + const std::string runName = + runNumber.substr(runNumber.find(instStr) + instStr.size()); + std::vector<std::string> res; + res.reserve(bankIDs.size()); + std::string prefix = instStr + "_" + runName + "_focused_texture_bank_"; + for (auto bankID : bankIDs) { + res.emplace_back(prefix + boost::lexical_cast<std::string>(bankID) + + ".nxs"); + } + + return res; +} + +/** + * Start the focusing algorithm(s) without blocking the GUI. This is + * based on Qt connect / signals-slots so that it goes in sync with + * the Qt event loop. For that reason this class needs to be a + * Q_OBJECT. + * + * @param multi_RunNo input vector of run number + * @param banks instrument bank to focus + * @param specNos list of spectra (as usual csv list of spectra in Mantid) + * @param dgFile detector grouping file name + */ +void EnggDiffractionPresenter::startAsyncFocusWorker( + const std::vector<std::string> &multi_RunNo, const std::vector<bool> &banks, + const std::string &dgFile, const std::string &specNos) { + + delete m_workerThread; + m_workerThread = new QThread(this); + EnggDiffWorker *worker = + new EnggDiffWorker(this, multi_RunNo, banks, dgFile, specNos); + worker->moveToThread(m_workerThread); + connect(m_workerThread, SIGNAL(started()), worker, SLOT(focus())); + connect(worker, SIGNAL(finished()), this, SLOT(focusingFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Produce a new focused output file. This is what threads/workers + * should use to run the calculations required to process a 'focus' + * push or similar from the user. + * + * @param runNo input run number + * + * @param specNos list of spectra to use when focusing. Not empty + * implies focusing in cropped mode. + * + * @param dgFile detector grouping file to define banks (texture). Not + * empty implies focusing in texture mode. + * + * @param banks for every bank, (true/false) to consider it or not for + * the focusing + */ +void EnggDiffractionPresenter::doFocusRun(const std::string &runNo, + const std::vector<bool> &banks, + const std::string &specNos, + const std::string &dgFile) { + + if (g_abortThread) { + return; + } + + // to track last valid run + g_lastValidRun = runNo; + + g_log.notice() << "Generating new focusing workspace(s) and file(s)"; + + // TODO: this is almost 100% common with doNewCalibrate() - refactor + EnggDiffCalibSettings cs = m_view->currentCalibSettings(); + Mantid::Kernel::ConfigServiceImpl &conf = + Mantid::Kernel::ConfigService::Instance(); + const std::vector<std::string> tmpDirs = conf.getDataSearchDirs(); + // in principle, the run files will be found from 'DirRaw', and the + // pre-calculated Vanadium corrections from 'DirCalib' + if (!cs.m_inputDirCalib.empty() && Poco::File(cs.m_inputDirCalib).exists()) { + conf.appendDataSearchDir(cs.m_inputDirCalib); + } + if (!cs.m_inputDirRaw.empty() && Poco::File(cs.m_inputDirRaw).exists()) { + conf.appendDataSearchDir(cs.m_inputDirRaw); + } + for (const auto &browsed : m_browsedToPaths) { + conf.appendDataSearchDir(browsed); + } + + // Prepare special inputs for "texture" focusing + std::vector<size_t> bankIDs; + std::vector<std::string> effectiveFilenames; + std::vector<std::string> specs; + if (!specNos.empty()) { + // Cropped focusing + // just to iterate once, but there's no real bank here + bankIDs.emplace_back(0); + specs.emplace_back(specNos); // one spectrum Nos list given by the user + effectiveFilenames.emplace_back(outputFocusCroppedFilename(runNo)); + } else { + if (dgFile.empty()) { + // Basic/normal focusing + for (size_t bidx = 0; bidx < banks.size(); bidx++) { + if (banks[bidx]) { + bankIDs.emplace_back(bidx + 1); + specs.emplace_back(""); + effectiveFilenames = outputFocusFilenames(runNo, banks); + } + } + } else { + // texture focusing + try { + loadDetectorGroupingCSV(dgFile, bankIDs, specs); + } catch (std::runtime_error &re) { + g_log.error() << "Error loading detector grouping file: " + dgFile + + ". Detailed error: " + re.what() + << '\n'; + bankIDs.clear(); + specs.clear(); + } + effectiveFilenames = outputFocusTextureFilenames(runNo, bankIDs); + } + } + + // focus all requested banks + for (size_t idx = 0; idx < bankIDs.size(); idx++) { + g_log.notice() << "Generating new focused file (bank " + + boost::lexical_cast<std::string>(bankIDs[idx]) + + ") for run " + runNo + " into: " + << effectiveFilenames[idx] << '\n'; + try { + + doFocusing(cs, runNo, bankIDs[idx], specs[idx], dgFile); + m_focusFinishedOK = true; + } catch (std::runtime_error &rexc) { + m_focusFinishedOK = false; + g_log.error() << "The focusing calculations failed. One of the algorithms" + "did not execute correctly. See log messages for " + "further details. Error: " + + std::string(rexc.what()) + << '\n'; + } catch (std::invalid_argument &ia) { + m_focusFinishedOK = false; + g_log.error() << "The focusing failed. Some input properties " + "were not valid. " + "See log messages for details. Error: " + << ia.what() << '\n'; + } catch (const Mantid::API::Algorithm::CancelException &) { + m_focusFinishedOK = false; + g_log.error() << "Focus terminated by user.\n"; + } + } + + // restore initial data search paths + conf.setDataSearchDirs(tmpDirs); +} + +void EnggDiffractionPresenter::loadDetectorGroupingCSV( + const std::string &dgFile, std::vector<size_t> &bankIDs, + std::vector<std::string> &specs) { + const char commentChar = '#'; + const std::string delim = ","; + + std::ifstream file(dgFile.c_str()); + if (!file.is_open()) { + throw std::runtime_error("Failed to open file."); + } + + bankIDs.clear(); + specs.clear(); + std::string line; + for (size_t li = 1; getline(file, line); li++) { + if (line.empty() || commentChar == line[0]) + continue; + + auto delimPos = line.find_first_of(delim); + if (std::string::npos == delimPos) { + throw std::runtime_error( + "In file '" + dgFile + + "', wrong format in line: " + boost::lexical_cast<std::string>(li) + + " which does not contain any delimiters (comma, etc.)"); + } + + try { + const std::string bstr = line.substr(0, delimPos); + const std::string spec = line.substr(delimPos + 1, std::string::npos); + + if (bstr.empty()) { + throw std::runtime_error( + "In file '" + dgFile + "', wrong format in line: " + + boost::lexical_cast<std::string>(li) + ", the bank ID is empty!"); + } + if (spec.empty()) { + throw std::runtime_error( + "In file '" + dgFile + + "', wrong format in line: " + boost::lexical_cast<std::string>(li) + + ", the list of spectrum Nos is empty!"); + } + + size_t bankID = boost::lexical_cast<size_t>(bstr); + bankIDs.emplace_back(bankID); + specs.emplace_back(spec); + } catch (std::runtime_error &re) { + throw std::runtime_error( + "In file '" + dgFile + + "', issue found when trying to interpret line: " + + boost::lexical_cast<std::string>(li) + + ". Error description: " + re.what()); + } + } +} + +/** + * Method (Qt slot) to call when the focusing work has finished, + * possibly from a separate thread but sometimes not (as in this + * presenter class' test). + */ +void EnggDiffractionPresenter::focusingFinished() { + if (!m_view) + return; + + if (!m_focusFinishedOK) { + g_log.warning() << "The focusing did not finish correctly. Check previous " + "log messages for details\n"; + m_view->showStatus("Focusing didn't finish succesfully. Ready"); + } else { + g_log.notice() << "Focusing finished - focused run(s) are ready.\n"; + m_view->showStatus("Focusing finished succesfully. Ready"); + } + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + m_view->enableCalibrateFocusFitUserActions(true); + + // display warning and information to the users regarding Stop Focus + if (g_abortThread) { + // will get the last number in the list + const std::string last_RunNo = isValidRunNumber(m_view->focusingRunNo()); + if (last_RunNo != g_lastValidRun) { + g_log.warning() << "Focussing process has been stopped, last successful " + "run: " + << g_lastValidRun << '\n'; + m_view->showStatus("Focusing stopped. Ready"); + } + } +} + +/** + * Focuses a run, produces a focused workspace, and saves it into a + * file. + * + * @param cs user settings for calibration (this does not calibrate but + * uses calibration input files such as vanadium runs + * + * @param runLabel run number of the run to focus + * + * @param bank the Bank ID to focus + * + * @param specNos string specifying a list of spectra (for "cropped" + * focusing or "texture" focusing), only considered if not empty + * + * @param dgFile detector grouping file name. If not empty implies + * texture focusing + */ +void EnggDiffractionPresenter::doFocusing(const EnggDiffCalibSettings &cs, + const std::string &runLabel, + const size_t bank, + const std::string &specNos, + const std::string &dgFile) { + MatrixWorkspace_sptr inWS; + + m_vanadiumCorrectionsModel->setCalibSettings(cs); + m_vanadiumCorrectionsModel->setCurrentInstrument(m_view->currentInstrument()); + const auto vanadiumCorrectionWorkspaces = + m_vanadiumCorrectionsModel->fetchCorrectionWorkspaces( + m_view->currentVanadiumNo()); + const auto &vanIntegWS = vanadiumCorrectionWorkspaces.first; + const auto &vanCurvesWS = vanadiumCorrectionWorkspaces.second; + + const std::string inWSName = "engggui_focusing_input_ws"; + const std::string instStr = m_view->currentInstrument(); + std::vector<std::string> multi_RunNo = sumOfFilesLoadVec(); + std::string loadInput = ""; + + for (size_t i = 0; i < multi_RunNo.size(); i++) { + // if last run number in list + if (i + 1 == multi_RunNo.size()) + loadInput += multi_RunNo[i]; + else + loadInput += multi_RunNo[i] + '+'; + } + + // if its not empty the global variable is set for sumOfFiles + if (!g_sumOfFilesFocus.empty()) { + + try { + auto load = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("Load"); + load->initialize(); + load->setPropertyValue("Filename", loadInput); + + load->setPropertyValue("OutputWorkspace", inWSName); + load->execute(); + + AnalysisDataServiceImpl &ADS = + Mantid::API::AnalysisDataService::Instance(); + inWS = ADS.retrieveWS<MatrixWorkspace>(inWSName); + } catch (std::runtime_error &re) { + g_log.error() + << "Error while loading files provided. " + "Could not run the algorithm Load succesfully for the focus " + "(run number provided. Error description:" + "Please check also the previous log messages for details." + + static_cast<std::string>(re.what()); + throw; + } + + if (multi_RunNo.size() == 1) { + g_log.notice() << "Only single file has been listed, the Sum Of Files" + "cannot not be processed\n"; + } else { + g_log.notice() + << "Load alogirthm has successfully merged the files provided\n"; + } + + } else { + try { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", runLabel); + load->setPropertyValue("OutputWorkspace", inWSName); + load->execute(); + + AnalysisDataServiceImpl &ADS = + Mantid::API::AnalysisDataService::Instance(); + inWS = ADS.retrieveWS<MatrixWorkspace>(inWSName); + } catch (std::runtime_error &re) { + g_log.error() << "Error while loading sample data for focusing. " + "Could not run the algorithm Load succesfully for " + "the focusing " + "sample (run number: " + + runLabel + "). Error description: " + re.what() + + " Please check also the previous log messages " + "for details."; + throw; + } + } + const auto bankString = std::to_string(bank); + std::string outWSName; + if (!dgFile.empty()) { + // doing focus "texture" + outWSName = "engggui_focusing_output_ws_texture_bank_" + bankString; + } else if (specNos.empty()) { + // doing focus "normal" / by banks + outWSName = "engggui_focusing_output_ws_bank_" + bankString; + } else { + // doing focus "cropped" + outWSName = "engggui_focusing_output_ws_cropped"; + } + try { + auto alg = Mantid::API::AlgorithmManager::Instance().create("EnggFocus"); + alg->initialize(); + alg->setProperty("InputWorkspace", inWSName); + alg->setProperty("OutputWorkspace", outWSName); + alg->setProperty("VanIntegrationWorkspace", vanIntegWS); + alg->setProperty("VanCurvesWorkspace", vanCurvesWS); + // cropped / normal focusing + if (specNos.empty()) { + alg->setPropertyValue("Bank", bankString); + } else { + alg->setPropertyValue("SpectrumNumbers", specNos); + } + // TODO: use detector positions (from calibrate full) when available + // alg->setProperty(DetectorPositions, TableWorkspace) + alg->execute(); + g_plottingCounter++; + plotFocusedWorkspace(outWSName); + + } catch (std::runtime_error &re) { + g_log.error() << "Error in calibration. ", + "Could not run the algorithm EnggCalibrate successfully for bank " + + bankString + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Produced focused workspace: " << outWSName << '\n'; + + const bool saveOutputFiles = m_view->saveFocusedOutputFiles(); + if (saveOutputFiles) { + try { + const auto runNo = + runLabel.substr(runLabel.rfind(instStr) + instStr.size()); + RunLabel label(runNo, bank); + saveFocusedXYE(label, outWSName); + saveGSS(label, outWSName); + saveOpenGenie(label, outWSName); + saveNexus(label, outWSName); + exportSampleLogsToHDF5(outWSName, userHDFRunFilename(runNo)); + } catch (std::runtime_error &re) { + g_log.error() << "Error saving focused data. ", + "There was an error while saving focused data. " + "Error Description: " + + std::string(re.what()) + + "Please check log messages for more details."; + throw; + } + } +} + +/** + * Loads a workspace to pre-process (rebin, etc.). The workspace + * loaded can be a MatrixWorkspace or a group of MatrixWorkspace (for + * multiperiod data). + * + * @param runNo run number to search for the file with 'Load'. + */ +Workspace_sptr +EnggDiffractionPresenter::loadToPreproc(const std::string &runNo) { + const std::string instStr = m_view->currentInstrument(); + Workspace_sptr inWS; + + // this is required when file is selected via browse button + const auto MultiRunNoDir = m_view->currentPreprocRunNo(); + const auto runNoDir = MultiRunNoDir[0]; + + try { + auto load = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("Load"); + load->initialize(); + if (Poco::File(runNoDir).exists()) { + load->setPropertyValue("Filename", runNoDir); + } else { + load->setPropertyValue("Filename", instStr + runNo); + } + const std::string inWSName = "engggui_preproc_input_ws"; + load->setPropertyValue("OutputWorkspace", inWSName); + + load->execute(); + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + inWS = ADS.retrieveWS<Workspace>(inWSName); + } catch (std::runtime_error &re) { + g_log.error() + << "Error while loading run data to pre-process. " + "Could not run the algorithm Load succesfully for the run " + "number: " + + runNo + "). Error description: " + re.what() + + " Please check also the previous log messages for details."; + throw; + } + + return inWS; +} + +void EnggDiffractionPresenter::doRebinningTime(const std::string &runNo, + double bin, + const std::string &outWSName) { + + // Runs something like: + // Rebin(InputWorkspace='ws_runNo', outputWorkspace=outWSName,Params=bin) + + m_rebinningFinishedOK = false; + const Workspace_sptr inWS = loadToPreproc(runNo); + if (!inWS) + g_log.error() + << "Error: could not load the input workspace for rebinning.\n"; + + const std::string rebinName = "Rebin"; + try { + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged(rebinName); + alg->initialize(); + alg->setPropertyValue("InputWorkspace", inWS->getName()); + alg->setPropertyValue("OutputWorkspace", outWSName); + alg->setProperty("Params", boost::lexical_cast<std::string>(bin)); + + alg->execute(); + } catch (std::invalid_argument &ia) { + g_log.error() << "Error when rebinning with a regular bin width in time. " + "There was an error in the inputs to the algorithm " + + rebinName + ". Error description: " + ia.what() + + ".\n"; + return; + } catch (std::runtime_error &re) { + g_log.error() << "Error when rebinning with a regular bin width in time. " + "Coult not run the algorithm " + + rebinName + + " successfully. Error description: " + re.what() + + ".\n"; + return; + } + + // succesful completion + m_rebinningFinishedOK = true; +} + +void EnggDiffractionPresenter::inputChecksBeforeRebin( + const std::string &runNo) { + if (runNo.empty()) { + throw std::invalid_argument("The run to pre-process" + g_runNumberErrorStr); + } +} + +void EnggDiffractionPresenter::inputChecksBeforeRebinTime( + const std::string &runNo, double bin) { + inputChecksBeforeRebin(runNo); + + if (bin <= 0) { + throw std::invalid_argument("The bin width must be strictly positive"); + } +} + +/** + * Starts the Rebin algorithm(s) without blocking the GUI. This is + * based on Qt connect / signals-slots so that it goes in sync with + * the Qt event loop. For that reason this class needs to be a + * Q_OBJECT. + * + * @param runNo run number(s) + * @param bin bin width parameter for Rebin + * @param outWSName name for the output workspace produced here + */ +void EnggDiffractionPresenter::startAsyncRebinningTimeWorker( + const std::string &runNo, double bin, const std::string &outWSName) { + + delete m_workerThread; + m_workerThread = new QThread(this); + auto *worker = new EnggDiffWorker(this, runNo, bin, outWSName); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(rebinTime())); + connect(worker, SIGNAL(finished()), this, SLOT(rebinningFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +void EnggDiffractionPresenter::inputChecksBeforeRebinPulses( + const std::string &runNo, size_t nperiods, double timeStep) { + inputChecksBeforeRebin(runNo); + + if (0 == nperiods) { + throw std::invalid_argument("The number of periods has been set to 0 so " + "none of the periods will be processed"); + } + + if (timeStep <= 0) { + throw std::invalid_argument( + "The bin or step for the time axis must be strictly positive"); + } +} + +void EnggDiffractionPresenter::doRebinningPulses(const std::string &runNo, + size_t nperiods, + double timeStep, + const std::string &outWSName) { + // TOOD: not clear what will be the role of this parameter for now + UNUSED_ARG(nperiods); + + // Runs something like: + // RebinByPulseTimes(InputWorkspace='ws_runNo', outputWorkspace=outWSName, + // Params=timeStepstep) + + m_rebinningFinishedOK = false; + const Workspace_sptr inWS = loadToPreproc(runNo); + if (!inWS) + g_log.error() + << "Error: could not load the input workspace for rebinning.\n"; + + const std::string rebinName = "RebinByPulseTimes"; + try { + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged(rebinName); + alg->initialize(); + alg->setPropertyValue("InputWorkspace", inWS->getName()); + alg->setPropertyValue("OutputWorkspace", outWSName); + alg->setProperty("Params", boost::lexical_cast<std::string>(timeStep)); + + alg->execute(); + } catch (std::invalid_argument &ia) { + g_log.error() << "Error when rebinning by pulse times. " + "There was an error in the inputs to the algorithm " + + rebinName + ". Error description: " + ia.what() + + ".\n"; + return; + } catch (std::runtime_error &re) { + g_log.error() << "Error when rebinning by pulse times. " + "Coult not run the algorithm " + + rebinName + + " successfully. Error description: " + re.what() + + ".\n"; + return; + } + + // successful execution + m_rebinningFinishedOK = true; +} + +/** + * Starts the Rebin (by pulses) algorithm(s) without blocking the + * GUI. This is based on Qt connect / signals-slots so that it goes in + * sync with the Qt event loop. For that reason this class needs to be + * a Q_OBJECT. + * + * @param runNo run number(s) + * @param nperiods max number of periods to process + * @param timeStep bin width parameter for the x (time) axis + * @param outWSName name for the output workspace produced here + */ +void EnggDiffractionPresenter::startAsyncRebinningPulsesWorker( + const std::string &runNo, size_t nperiods, double timeStep, + const std::string &outWSName) { + + delete m_workerThread; + m_workerThread = new QThread(this); + auto *worker = new EnggDiffWorker(this, runNo, nperiods, timeStep, outWSName); + worker->moveToThread(m_workerThread); + + connect(m_workerThread, SIGNAL(started()), worker, SLOT(rebinPulses())); + connect(worker, SIGNAL(finished()), this, SLOT(rebinningFinished())); + // early delete of thread and worker + connect(m_workerThread, SIGNAL(finished()), m_workerThread, + SLOT(deleteLater()), Qt::DirectConnection); + connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); + m_workerThread->start(); +} + +/** + * Method (Qt slot) to call when the rebin work has finished, + * possibly from a separate thread but sometimes not (as in this + * presenter class' test). + */ +void EnggDiffractionPresenter::rebinningFinished() { + if (!m_view) + return; + + if (!m_rebinningFinishedOK) { + g_log.warning() << "The pre-processing (re-binning) did not finish " + "correctly. Check previous log messages for details\n"; + m_view->showStatus("Rebinning didn't finish succesfully. Ready"); + } else { + g_log.notice() << "Pre-processing (re-binning) finished - the output " + "workspace is ready.\n"; + m_view->showStatus("Rebinning finished succesfully. Ready"); + } + if (m_workerThread) { + delete m_workerThread; + m_workerThread = nullptr; + } + + m_view->enableCalibrateFocusFitUserActions(true); +} + +/** + * Checks the plot type selected and applies the appropriate + * python function to apply during first bank and second bank + * + * @param outWSName title of the focused workspace + */ +void EnggDiffractionPresenter::plotFocusedWorkspace( + const std::string &outWSName) { + const bool plotFocusedWS = m_view->focusedOutWorkspace(); + enum PlotMode { REPLACING = 0, WATERFALL = 1, MULTIPLE = 2 }; + + int plotType = m_view->currentPlotType(); + + if (plotFocusedWS) { + if (plotType == PlotMode::REPLACING) { + if (g_plottingCounter == 1) + m_view->plotFocusedSpectrum(outWSName); + else + m_view->plotReplacingWindow(outWSName, "0", "0"); + + } else if (plotType == PlotMode::WATERFALL) { + if (g_plottingCounter == 1) + m_view->plotFocusedSpectrum(outWSName); + else + m_view->plotWaterfallSpectrum(outWSName); + + } else if (plotType == PlotMode::MULTIPLE) { + m_view->plotFocusedSpectrum(outWSName); + } + } +} + +/** + * Check if the plot calibration check-box is ticked + * python script is passed on to mantid python window + * which plots the workspaces with customisation + * + * @param difa vector of double passed on to py script + * @param difc vector of double passed on to py script + * @param tzero vector of double to plot graph + * @param specNos string carrying cropped calib info + */ +void EnggDiffractionPresenter::plotCalibWorkspace( + const std::vector<double> &difa, const std::vector<double> &difc, + const std::vector<double> &tzero, const std::string &specNos) { + const bool plotCalibWS = m_view->plotCalibWorkspace(); + if (plotCalibWS) { + std::string pyCode = vanadiumCurvesPlotFactory(); + m_view->plotCalibOutput(pyCode); + + // Get the Customised Bank Name text-ield string from qt + std::string CustomisedBankName = m_view->currentCalibCustomisedBankName(); + if (CustomisedBankName.empty()) + CustomisedBankName = "cropped"; + const std::string pythonCode = + TOFFitWorkspaceFactory(difa, difc, tzero, specNos, CustomisedBankName) + + plotTOFWorkspace(CustomisedBankName); + m_view->plotCalibOutput(pythonCode); + } +} + +/** + * Convert the generated output files and saves them in + * FocusedXYE format + * + * @param runLabel run number and bank ID of the workspace to save + * @param inputWorkspace title of the focused workspace + */ +void EnggDiffractionPresenter::saveFocusedXYE( + const RunLabel &runLabel, const std::string &inputWorkspace) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runLabel, ".dat"); + + const std::string focusingComp = "Focus"; + // Creates appropriate directory + auto saveDir = outFilesUserDir(focusingComp); + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << '\n'; + auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( + "SaveFocusedXYE"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + const std::string filename(saveDir.toString()); + alg->setPropertyValue("Filename", filename); + alg->setProperty("SplitFiles", false); + alg->setPropertyValue("StartAtBankNumber", std::to_string(runLabel.bank)); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in saving FocusedXYE format file. ", + "Could not run the algorithm SaveFocusXYE succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << saveDir.toString() + << '\n'; + copyToGeneral(saveDir, focusingComp); +} + +/** + * Convert the generated output files and saves them in + * GSS format + * + * @param runLabel run number and bank ID the workspace to save + * @param inputWorkspace title of the focused workspace + */ +void EnggDiffractionPresenter::saveGSS(const RunLabel &runLabel, + const std::string &inputWorkspace) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runLabel, ".gss"); + + const std::string focusingComp = "Focus"; + // Creates appropriate directory + auto saveDir = outFilesUserDir(focusingComp); + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << '\n'; + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("SaveGSS"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + std::string filename(saveDir.toString()); + alg->setPropertyValue("Filename", filename); + alg->setProperty("SplitFiles", false); + alg->setPropertyValue("Bank", std::to_string(runLabel.bank)); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in saving GSS format file. ", + "Could not run the algorithm saveGSS succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << saveDir.toString() + << '\n'; + copyToGeneral(saveDir, focusingComp); +} + +void EnggDiffractionPresenter::saveNexus(const RunLabel &runLabel, + const std::string &inputWorkspace) { + const auto filename = outFileNameFactory(inputWorkspace, runLabel, ".nxs"); + auto saveDirectory = outFilesUserDir("Focus"); + saveDirectory.append(filename); + const auto fullOutFileName = saveDirectory.toString(); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullOutFileName << "\n"; + auto alg = + Mantid::API::AlgorithmManager::Instance().createUnmanaged("SaveNexus"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + alg->setProperty("Filename", fullOutFileName); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in save NXS format file. Could not run the " + "algorithm SaveNexus successfully for workspace " + << inputWorkspace << ". Error description: " << re.what() + << ". Please also check the log message for details."; + throw; + } + g_log.notice() << "Saved focused workspace as file: " << fullOutFileName + << "\n"; + copyToGeneral(saveDirectory, "Focus"); +} + +/** + * Convert the generated output files and saves them in + * OpenGenie format + * + * @param runLabel run number and bank ID of the workspace to save + * @param inputWorkspace title of the focused workspace + */ +void EnggDiffractionPresenter::saveOpenGenie( + const RunLabel &runLabel, const std::string &inputWorkspace) { + + // Generates the file name in the appropriate format + std::string fullFilename = + outFileNameFactory(inputWorkspace, runLabel, ".his"); + + std::string comp; + Poco::Path saveDir; + if (inputWorkspace.std::string::find("curves") != std::string::npos || + inputWorkspace.std::string::find("intgration") != std::string::npos) { + // Creates appropriate directory + comp = "Calibration"; + saveDir = outFilesUserDir(comp); + } else { + // Creates appropriate directory + comp = "Focus"; + saveDir = outFilesUserDir(comp); + } + + // append the full file name in the end + saveDir.append(fullFilename); + + try { + g_log.debug() << "Going to save focused output into OpenGenie file: " + << fullFilename << '\n'; + auto alg = Mantid::API::AlgorithmManager::Instance().createUnmanaged( + "SaveOpenGenieAscii"); + alg->initialize(); + alg->setProperty("InputWorkspace", inputWorkspace); + std::string filename(saveDir.toString()); + alg->setPropertyValue("Filename", filename); + alg->setPropertyValue("OpenGenieFormat", "ENGIN-X Format"); + alg->execute(); + } catch (std::runtime_error &re) { + g_log.error() << "Error in saving OpenGenie format file. ", + "Could not run the algorithm SaveOpenGenieAscii succesfully for " + "workspace " + + inputWorkspace + ". Error description: " + re.what() + + " Please check also the log messages for details."; + throw; + } + g_log.notice() << "Saves OpenGenieAscii (.his) file written as: " + << saveDir.toString() << '\n'; + copyToGeneral(saveDir, comp); +} + +void EnggDiffractionPresenter::exportSampleLogsToHDF5( + const std::string &inputWorkspace, const std::string &filename) const { + auto saveAlg = Mantid::API::AlgorithmManager::Instance().create( + "ExportSampleLogsToHDF5"); + saveAlg->initialize(); + saveAlg->setProperty("InputWorkspace", inputWorkspace); + saveAlg->setProperty("Filename", filename); + saveAlg->setProperty("Blacklist", "bankid"); + saveAlg->execute(); +} + +/** + * Generates the required file name of the output files + * + * @param inputWorkspace title of the focused workspace + * @param runLabel run number and bank ID of the workspace to save + * @param format the format of the file to be saved as + */ +std::string +EnggDiffractionPresenter::outFileNameFactory(const std::string &inputWorkspace, + const RunLabel &runLabel, + const std::string &format) { + std::string fullFilename; + + const auto runNo = runLabel.runNumber; + const auto bank = std::to_string(runLabel.bank); + + // calibration output files + if (inputWorkspace.std::string::find("curves") != std::string::npos) { + fullFilename = + "ob+" + m_currentInst + "_" + runNo + "_" + bank + "_bank" + format; + + // focus output files + } else if (inputWorkspace.std::string::find("texture") != std::string::npos) { + fullFilename = m_currentInst + "_" + runNo + "_texture_" + bank + format; + } else if (inputWorkspace.std::string::find("cropped") != std::string::npos) { + fullFilename = m_currentInst + "_" + runNo + "_cropped_" + + boost::lexical_cast<std::string>(g_croppedCounter) + format; + g_croppedCounter++; + } else { + fullFilename = m_currentInst + "_" + runNo + "_bank_" + bank + format; + } + return fullFilename; +} + +std::string EnggDiffractionPresenter::vanadiumCurvesPlotFactory() { + std::string pyCode = + + "van_curve_twin_ws = \"__engggui_vanadium_curves_twin_ws\"\n" + + "if(mtd.doesExist(van_curve_twin_ws)):\n" + " DeleteWorkspace(van_curve_twin_ws)\n" + + "CloneWorkspace(InputWorkspace = \"engggui_vanadium_curves\", " + "OutputWorkspace = van_curve_twin_ws)\n" + + "van_curves_ws = workspace(van_curve_twin_ws)\n" + "for i in range(1, 3):\n" + " if (i == 1):\n" + " curve_plot_bank_1 = plotSpectrum(van_curves_ws, [0, 1, " + "2]).activeLayer()\n" + " curve_plot_bank_1.setTitle(\"Engg GUI Vanadium Curves Bank 1\")\n" + + " if (i == 2):\n" + " curve_plot_bank_2 = plotSpectrum(van_curves_ws, [3, 4, " + "5]).activeLayer()\n" + " curve_plot_bank_2.setTitle(\"Engg GUI Vanadium Curves Bank 2\")\n"; + + return pyCode; +} + +/** + * Generates the workspace with difc/zero according to the selected bank + * + * @param difa vector containing constants difa value of each bank + * @param difc vector containing constants difc value of each bank + * @param tzero vector containing constants tzero value of each bank + * @param specNo used to set range for Calibration Cropped + * @param customisedBankName used to set the file and workspace name + * + * @return string with a python script + */ +std::string EnggDiffractionPresenter::TOFFitWorkspaceFactory( + const std::vector<double> &difa, const std::vector<double> &difc, + const std::vector<double> &tzero, const std::string &specNo, + const std::string &customisedBankName) const { + + auto bank1 = size_t(0); + auto bank2 = size_t(1); + std::string pyRange; + std::string plotSpecNum = "False"; + + // sets the range to plot appropriate graph for the particular bank + if (specNo == "North") { + // only enable script to plot bank 1 + pyRange = "1, 2"; + } else if (specNo == "South") { + // only enables python script to plot bank 2 + // as bank 2 data will be located in difc[0] & tzero[0] - refactor + pyRange = "2, 3"; + bank2 = size_t(0); + } else if (specNo != "") { + pyRange = "1, 2"; + plotSpecNum = "True"; + } else { + // enables python script to plot bank 1 & 2 + pyRange = "1, 3"; + } + + std::string pyCode = + "plotSpecNum = " + plotSpecNum + + "\n" + "for i in range(" + + pyRange + + "):\n" + + " if (plotSpecNum == False):\n" + " bank_ws = workspace(\"engggui_calibration_bank_\" + str(i))\n" + " else:\n" + " bank_ws = workspace(\"engggui_calibration_bank_" + + customisedBankName + + "\")\n" + + " xVal = []\n" + " yVal = []\n" + " y2Val = []\n" + + " if (i == 1):\n" + " difa=" + + boost::lexical_cast<std::string>(difa[bank1]) + "\n" + + " difc=" + boost::lexical_cast<std::string>(difc[bank1]) + "\n" + + " tzero=" + boost::lexical_cast<std::string>(tzero[bank1]) + "\n" + + " else:\n" + + " difa=" + + boost::lexical_cast<std::string>(difa[bank2]) + "\n" + + " difc=" + boost::lexical_cast<std::string>(difc[bank2]) + "\n" + + " tzero=" + boost::lexical_cast<std::string>(tzero[bank2]) + "\n" + + + " for irow in range(0, bank_ws.rowCount()):\n" + " xVal.append(bank_ws.cell(irow, 0))\n" + " yVal.append(bank_ws.cell(irow, 5))\n" + + " y2Val.append(pow(xVal[irow], 2) * difa + xVal[irow] * difc + tzero)\n" + + " ws1 = CreateWorkspace(DataX=xVal, DataY=yVal, UnitX=\"Expected " + "Peaks " + " Centre(dSpacing, A)\", YUnitLabel = \"Fitted Peaks Centre(TOF, " + "us)\")\n" + " ws2 = CreateWorkspace(DataX=xVal, DataY=y2Val)\n"; + return pyCode; +} + +/** +* Plot the workspace with difc/zero acordding to selected bank +* +* @param customisedBankName used to set the file and workspace name +* +* @return string with a python script which will merge with +* + +*/ +std::string EnggDiffractionPresenter::plotTOFWorkspace( + const std::string &customisedBankName) const { + std::string pyCode = + // plotSpecNum is true when SpectrumNos being used + " if (plotSpecNum == False):\n" + " output_ws = \"engggui_difc_zero_peaks_bank_\" + str(i)\n" + " else:\n" + " output_ws = \"engggui_difc_zero_peaks_" + + customisedBankName + + "\"\n" + + // delete workspace if exists within ADS already + " if(mtd.doesExist(output_ws)):\n" + " DeleteWorkspace(output_ws)\n" + + // append workspace with peaks data for Peaks Fitted + // and Difc/TZero Straight line + " AppendSpectra(ws1, ws2, OutputWorkspace=output_ws)\n" + " DeleteWorkspace(ws1)\n" + " DeleteWorkspace(ws2)\n" + + " if (plotSpecNum == False):\n" + " DifcZero = \"engggui_difc_zero_peaks_bank_\" + str(i)\n" + " else:\n" + " DifcZero = \"engggui_difc_zero_peaks_" + + customisedBankName + + "\"\n" + + " DifcZeroWs = workspace(DifcZero)\n" + " DifcZeroPlot = plotSpectrum(DifcZeroWs, [0, 1]).activeLayer()\n" + + " if (plotSpecNum == False):\n" + " DifcZeroPlot.setTitle(\"Engg Gui Difc Zero Peaks Bank \" + " + "str(i))\n" + " else:\n" + " DifcZeroPlot.setTitle(\"Engg Gui Difc Zero Peaks " + + customisedBankName + + "\")\n" + + // set the legend title + " DifcZeroPlot.setCurveTitle(0, \"Peaks Fitted\")\n" + " DifcZeroPlot.setCurveTitle(1, \"DifC/TZero Fitted Straight Line\")\n" + " DifcZeroPlot.setAxisTitle(Layer.Bottom, \"Expected Peaks " + "Centre(dSpacing, " + " A)\")\n" + " DifcZeroPlot.setCurveLineStyle(0, QtCore.Qt.DotLine)\n"; + + return pyCode; +} + +/** + * Generates appropriate names for table workspaces + * + * @param specNos SpecNos or bank name to be passed + * @param bank_i current loop of the bank during calibration + */ +std::string EnggDiffractionPresenter::outFitParamsTblNameGenerator( + const std::string &specNos, const size_t bank_i) const { + std::string outFitParamsTblName; + bool specNumUsed = specNos != ""; + + if (specNumUsed) { + if (specNos == "North") + outFitParamsTblName = "engggui_calibration_bank_1"; + else if (specNos == "South") + outFitParamsTblName = "engggui_calibration_bank_2"; + else { + // Get the Customised Bank Name text-ield string from qt + std::string CustomisedBankName = m_view->currentCalibCustomisedBankName(); + + if (CustomisedBankName.empty()) + outFitParamsTblName = "engggui_calibration_bank_cropped"; + else + outFitParamsTblName = "engggui_calibration_bank_" + CustomisedBankName; + } + } else { + outFitParamsTblName = "engggui_calibration_bank_" + + boost::lexical_cast<std::string>(bank_i + 1); + } + return outFitParamsTblName; +} + +/** + * Produces a path to the output directory where files are going to be + * written for a specific user + RB number / experiment ID. It creates + * the output directory if not found, and checks if it is ok and readable. + * + * @param addToDir adds a component to a specific directory for + * focusing, calibration or other files, for example "Calibration" or + * "Focus" + */ +Poco::Path +EnggDiffractionPresenter::outFilesUserDir(const std::string &addToDir) const { + std::string rbn = m_view->getRBNumber(); + Poco::Path dir = outFilesRootDir(); + + try { + dir.append("User"); + dir.append(rbn); + dir.append(addToDir); + + Poco::File dirFile(dir); + if (!dirFile.exists()) { + dirFile.createDirectories(); + } + } catch (Poco::FileAccessDeniedException &e) { + g_log.error() << "Error caused by file access/permission, path to user " + "directory: " + << dir.toString() << ". Error details: " << e.what() << '\n'; + } catch (std::runtime_error &re) { + g_log.error() << "Error while finding/creating a user path: " + << dir.toString() << ". Error details: " << re.what() << '\n'; + } + return dir; +} + +std::string EnggDiffractionPresenter::userHDFRunFilename( + const std::string &runNumber) const { + auto userOutputDir = outFilesUserDir("Runs"); + userOutputDir.append(runNumber + ".hdf5"); + return userOutputDir.toString(); +} + +std::string EnggDiffractionPresenter::userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const { + const auto &begin = runLabels.cbegin(); + const auto &end = runLabels.cend(); + const auto minLabel = std::min_element(begin, end); + const auto maxLabel = std::max_element(begin, end); + auto userOutputDir = outFilesUserDir("Runs"); + userOutputDir.append((minLabel->runNumber) + "_" + (maxLabel->runNumber) + + ".hdf5"); + return userOutputDir.toString(); +} + +/** + * Produces a path to the output directory where files are going to be + * written for a specific user + RB number / experiment ID. It creates + * the output directory if not found. See outFilesUserDir() for the + * sibling method that produces user/rb number-specific directories. + * + * @param addComponent path component to add to the root of general + * files, for example "Calibration" or "Focus" + */ +Poco::Path +EnggDiffractionPresenter::outFilesGeneralDir(const std::string &addComponent) { + Poco::Path dir = outFilesRootDir(); + + try { + + dir.append(addComponent); + + Poco::File dirFile(dir); + if (!dirFile.exists()) { + dirFile.createDirectories(); + } + } catch (Poco::FileAccessDeniedException &e) { + g_log.error() << "Error caused by file access/permission, path to " + "general directory: " + << dir.toString() << ". Error details: " << e.what() << '\n'; + } catch (std::runtime_error &re) { + g_log.error() << "Error while finding/creating a general path: " + << dir.toString() << ". Error details: " << re.what() << '\n'; + } + return dir; +} + +/** + * Produces the root path where output files are going to be written. + */ +Poco::Path EnggDiffractionPresenter::outFilesRootDir() const { + // TODO decide whether to move into settings or use mantid's default directory + // after discussion with users + const std::string rootDir = "EnginX_Mantid"; + Poco::Path dir; + + try { +// takes to the root of directory according to the platform +#ifdef _WIN32 + const std::string ROOT_DRIVE = "C:/"; + dir.assign(ROOT_DRIVE); +#else + dir = Poco::Path().home(); +#endif + dir.append(rootDir); + + Poco::File dirFile(dir); + if (!dirFile.exists()) { + dirFile.createDirectories(); + g_log.notice() << "Creating output directory root for the first time: " + << dir.toString() << '\n'; + } + + } catch (Poco::FileAccessDeniedException &e) { + g_log.error() << "Error, access/permission denied for root directory: " + << dir.toString() + << ". This is a severe error. The interface will not behave " + "correctly when generating files. Error details: " + << e.what() << '\n'; + } catch (std::runtime_error &re) { + g_log.error() << "Error while finding/creating the root directory: " + << dir.toString() + << ". This is a severe error. Details: " << re.what() << '\n'; + } + + return dir; +} + +/* + * Provides a small wrapper function that appends the given string + * to the given path in an OS independent manner and returns the + * resulting path as a string. + * + * @param currentPath The path to be appended to + * @param toAppend The string to append to the path (note '/' or '\\' + * characters should not be included + * + * @return String with the two parts of the path appended + */ +std::string +EnggDiffractionPresenter::appendToPath(const std::string ¤tPath, + const std::string &toAppend) const { + // Uses poco to handle to operation to ensure OS independence + Poco::Path newPath(currentPath); + newPath.append(toAppend); + return newPath.toString(); +} + +/** + * Copy files to the general directories. Normally files are produced + * in the user/RB number specific directories and then can be copied + * to the general/all directories using this method. + * + * @param source path to the file to copy + * + * @param pathComp path component to use for the copy file in the + * general directories, for example "Calibration" or "Focus" + */ +void EnggDiffractionPresenter::copyToGeneral(const Poco::Path &source, + const std::string &pathComp) { + Poco::File file(source); + if (!file.exists() || !file.canRead()) { + g_log.warning() << "Cannot copy the file " << source.toString() + << " to the general/all users directories because it " + "cannot be read.\n"; + return; + } + + auto destDir = outFilesGeneralDir(pathComp); + try { + Poco::File destDirFile(destDir); + if (!destDirFile.exists()) { + destDirFile.createDirectories(); + } + } catch (std::runtime_error &rexc) { + g_log.error() << "Could not create output directory for the general/all " + "files. Cannot copy the user files there: " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + + return; + } + + try { + file.copyTo(destDir.toString()); + } catch (std::runtime_error &rexc) { + g_log.error() << " Could not copy the file '" << file.path() << "' to " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + } + + g_log.information() << "Copied file '" << source.toString() + << "'to general/all directory: " << destDir.toString() + << '\n'; +} + +/** + * Copy files to the user/RB number directories. + * + * @param source path to the file to copy + * + * @param pathComp path component to use for the copy file in the + * general directories, for example "Calibration" or "Focus" + */ +void EnggDiffractionPresenter::copyToUser(const Poco::Path &source, + const std::string &pathComp) { + Poco::File file(source); + if (!file.exists() || !file.canRead()) { + g_log.warning() << "Cannot copy the file " << source.toString() + << " to the user directories because it cannot be read.\n"; + return; + } + + auto destDir = outFilesUserDir(pathComp); + try { + Poco::File destDirFile(destDir); + if (!destDirFile.exists()) { + destDirFile.createDirectories(); + } + } catch (std::runtime_error &rexc) { + g_log.error() << "Could not create output directory for the user " + "files. Cannot copy the user files there: " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + + return; + } + + try { + file.copyTo(destDir.toString()); + } catch (std::runtime_error &rexc) { + g_log.error() << " Could not copy the file '" << file.path() << "' to " + << destDir.toString() << ". Error details: " << rexc.what() + << '\n'; + } + + g_log.information() << "Copied file '" << source.toString() + << "'to user directory: " << destDir.toString() << '\n'; +} + +/** + * Copies a file from a third location to the standard user/RB number + * and the general/all directories. This just uses copyToUser() and + * copyToGeneral(). + * + * @param fullFilename full path to the origin file + */ +void EnggDiffractionPresenter::copyFocusedToUserAndAll( + const std::string &fullFilename) { + // The files are saved by SaveNexus in the Settings/Focusing output folder. + // Then they need to go to the user and 'all' directories. + // The "Settings/Focusing output folder" may go away in the future + Poco::Path nxsPath(fullFilename); + const std::string focusingComp = "Focus"; + auto saveDir = outFilesUserDir(focusingComp); + Poco::Path outFullPath(saveDir); + outFullPath.append(nxsPath.getFileName()); + copyToUser(nxsPath, focusingComp); + copyToGeneral(nxsPath, focusingComp); +} + +/** + * To write the calibration/instrument parameter for GSAS. + * + * @param outFilename name of the output .par/.prm/.iparm file for GSAS + * @param difa list of GSAS DIFA values to include in the file + * @param difc list of GSAS DIFC values to include in the file + * @param tzero list of GSAS TZERO values to include in the file + * @param bankNames list of bank names corresponding the the difc/tzero + * + * @param ceriaNo ceria/calibration run number, to be replaced in the + * template file + * + * @param vanNo vanadium run number, to be replaced in the template file + * + * @param templateFile a template file where to replace the difc/zero + * values. An empty default implies using an "all-banks" template. + */ +void EnggDiffractionPresenter::writeOutCalibFile( + const std::string &outFilename, const std::vector<double> &difa, + const std::vector<double> &difc, const std::vector<double> &tzero, + const std::vector<std::string> &bankNames, const std::string &ceriaNo, + const std::string &vanNo, const std::string &templateFile) { + // TODO: this is horrible and should be changed to avoid running + // Python code. Update this as soon as we have a more stable way of + // generating IPARM/PRM files. + + // Writes a file doing this: + // write_ENGINX_GSAS_iparam_file(output_file, difa, difc, zero, + // ceria_run=241391, vanadium_run=236516, template_file=None): + + // this replace is to prevent issues with network drives on windows: + const std::string safeOutFname = + boost::replace_all_copy(outFilename, "\\", "/"); + std::string pyCode = "import EnggUtils\n"; + pyCode += "import os\n"; + // normalize apparently not needed after the replace, but to be double-safe: + pyCode += "GSAS_iparm_fname = os.path.normpath('" + safeOutFname + "')\n"; + pyCode += "bank_names = []\n"; + pyCode += "ceria_number = \"" + ceriaNo + "\"\n"; + pyCode += "van_number = \"" + vanNo + "\"\n"; + pyCode += "Difas = []\n"; + pyCode += "Difcs = []\n"; + pyCode += "Zeros = []\n"; + std::string templateFileVal = "None"; + if (!templateFile.empty()) { + templateFileVal = "'" + templateFile + "'"; + } + pyCode += "template_file = " + templateFileVal + "\n"; + for (size_t i = 0; i < difc.size(); ++i) { + pyCode += "bank_names.append('" + bankNames[i] + "')\n"; + pyCode += + "Difas.append(" + boost::lexical_cast<std::string>(difa[i]) + ")\n"; + pyCode += + "Difcs.append(" + boost::lexical_cast<std::string>(difc[i]) + ")\n"; + pyCode += + "Zeros.append(" + boost::lexical_cast<std::string>(tzero[i]) + ")\n"; + } + pyCode += + "EnggUtils.write_ENGINX_GSAS_iparam_file(output_file=GSAS_iparm_fname, " + "bank_names=bank_names, difa=Difas, difc=Difcs, tzero=Zeros, " + "ceria_run=ceria_number, " + "vanadium_run=van_number, template_file=template_file) \n"; + + const auto status = m_view->enggRunPythonCode(pyCode); + g_log.information() << "Saved output calibration file via Python. Status: " + << status << '\n'; +} + +/** + * Note down a directory that needs to be added to the data search + * path when looking for run files. This simply uses a vector and adds + * all the paths, as the ConfigService will take care of duplicates, + * invalid directories, etc. + * + * @param filename (full) path to a file + */ +void EnggDiffractionPresenter::recordPathBrowsedTo( + const std::string &filename) { + + Poco::File file(filename); + if (!file.exists() || !file.isFile()) + return; + + Poco::Path path(filename); + Poco::File directory(path.parent()); + if (!directory.exists() || !directory.isDirectory()) + return; + + m_browsedToPaths.emplace_back(directory.path()); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.h new file mode 100644 index 0000000000000000000000000000000000000000..ab7f699f238059ff13d185a1f98a33a8f9a5c59f --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionPresenter.h @@ -0,0 +1,354 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggDiffractionCalibration.h" +#include "IEnggDiffractionParam.h" +#include "IEnggDiffractionPresenter.h" +#include "IEnggDiffractionView.h" +#include "IEnggVanadiumCorrectionsModel.h" +#include "MantidAPI/ITableWorkspace_fwd.h" +#include "MantidAPI/MatrixWorkspace_fwd.h" +#include "MantidAPI/Workspace_fwd.h" + +#include <boost/scoped_ptr.hpp> + +#include <QObject> + +namespace Poco { +class Path; +} + +class QThread; + +namespace MantidQt { +namespace CustomInterfaces { + +/** +Presenter for the Enggineering Diffraction GUI (presenter as in the +MVP Model-View-Presenter pattern). In principle, in a strict MVP +setup, signals from the model should always be handled through this +presenter and never go directly to the view, and viceversa. +*/ +// needs to be dll-exported for the tests +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffractionPresenter + : public QObject, + public IEnggDiffractionPresenter, + public IEnggDiffractionCalibration, + public IEnggDiffractionParam { + // Q_OBJECT for 'connect' with thread/worker + Q_OBJECT + +public: + EnggDiffractionPresenter(IEnggDiffractionView *view); + ~EnggDiffractionPresenter() override; + + void notify(IEnggDiffractionPresenter::Notification notif) override; + + /// the calibration hard work that a worker / thread will run + void doNewCalibration(const std::string &outFilename, + const std::string &vanNo, const std::string &ceriaNo, + const std::string &specNos); + + /// the focusing hard work that a worker / thread will run + void doFocusRun(const std::string &runNo, const std::vector<bool> &banks, + const std::string &specNos, const std::string &dgFile); + + /// checks if its a valid run number returns string + std::string isValidRunNumber(const std::vector<std::string> &dir); + + /// checks if its a valid run number inside vector and returns a vector; + /// used for mutli-run focusing, and other multi-run file selections + std::vector<std::string> + isValidMultiRunNumber(const std::vector<std::string> &dir); + + /// pre-processing re-binning with Rebin, for a worker/thread + void doRebinningTime(const std::string &runNo, double bin, + const std::string &outWSName); + + /// pre-processing re-binning with RebinByPulseTimes, for a worker/thread + void doRebinningPulses(const std::string &runNo, size_t nperiods, double bin, + const std::string &outWSName); + +protected: + void initialize(); + + /// clean shut down of model, view, etc. + void cleanup(); + + void processStart(); + void processLoadExistingCalib(); + void processCalcCalib(); + void ProcessCropCalib(); + void processFocusBasic(); + void processFocusCropped(); + void processFocusTexture(); + void processResetFocus(); + void processRebinTime(); + void processRebinMultiperiod(); + void processLogMsg(); + void processInstChange(); + void processRBNumberChange(); + void processShutDown(); + void processStopFocus(); + + std::vector<std::string> outputFocusFilenames(const std::string &runNo, + const std::vector<bool> &banks); + + std::string outputFocusCroppedFilename(const std::string &runNo); + +protected slots: + void calibrationFinished(); + void focusingFinished(); + void rebinningFinished(); + +private: + bool validateRBNumber(const std::string &rbn) const; + + /// @name Calibration related private methods + //@{ + void inputChecksBeforeCalibrate(const std::string &newVanNo, + const std::string &newCeriaNo); + + std::string outputCalibFilename(const std::string &vanNo, + const std::string &ceriaNo, + const std::string &bankName = ""); + + void updateNewCalib(const std::string &fname); + + void parseCalibrateFilename(const std::string &path, std::string &instName, + std::string &vanNo, std::string &ceriaNo); + + void grabCalibParms(const std::string &fname, std::string &vanNo, + std::string &ceriaNo); + + void updateCalibParmsTable(); + + // this may need to be mocked up in tests + virtual void startAsyncCalibWorker(const std::string &outFilename, + const std::string &vanNo, + const std::string &ceriaNo, + const std::string &specNos); + + void doCalib(const EnggDiffCalibSettings &cs, const std::string &vanNo, + const std::string &ceriaNo, const std::string &outFilename, + const std::string &specNos); + + void appendCalibInstPrefix(const std::string &vanNo, + std::string &outVanName) const; + + void appendCalibInstPrefix(const std::string &vanNo, const std::string &cerNo, + std::string &outVanName, + std::string &outCerName) const; + + std::string + buildCalibrateSuggestedFilename(const std::string &vanNo, + const std::string &ceriaNo, + const std::string &bankName = "") const; + + std::vector<GSASCalibrationParms> currentCalibration() const override; + //@} + + /// @name Focusing related private methods + //@{ + /// this may also need to be mocked up in tests + void startFocusing(const std::vector<std::string> &multi_runNo, + const std::vector<bool> &banks, + const std::string &specNos = "", + const std::string &dgFile = ""); + + virtual void + startAsyncFocusWorker(const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks, + const std::string &specNos, const std::string &dgFile); + + void inputChecksBeforeFocusBasic(const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks); + void + inputChecksBeforeFocusCropped(const std::vector<std::string> &multi_RunNo, + const std::vector<bool> &banks, + const std::string &specNos); + void + inputChecksBeforeFocusTexture(const std::vector<std::string> &multi_RunNo, + const std::string &dgfile); + void inputChecksBeforeFocus(); + void inputChecksBanks(const std::vector<bool> &banks); + + std::vector<std::string> sumOfFilesLoadVec(); + + std::vector<std::string> + outputFocusTextureFilenames(const std::string &runNo, + const std::vector<size_t> &bankIDs); + + void loadDetectorGroupingCSV(const std::string &dgFile, + std::vector<size_t> &bankIDs, + std::vector<std::string> &specs); + + void doFocusing(const EnggDiffCalibSettings &cs, const std::string &runLabel, + const size_t bank, const std::string &specNos, + const std::string &dgFile); + + /// @name Methods related to pre-processing / re-binning + //@{ + void inputChecksBeforeRebin(const std::string &runNo); + + void inputChecksBeforeRebinTime(const std::string &runNo, double bin); + + void inputChecksBeforeRebinPulses(const std::string &runNo, size_t nperiods, + double timeStep); + + Mantid::API::Workspace_sptr loadToPreproc(const std::string &runNo); + + virtual void startAsyncRebinningTimeWorker(const std::string &runNo, + double bin, + const std::string &outWSName); + + virtual void startAsyncRebinningPulsesWorker(const std::string &runNo, + size_t nperiods, double timeStep, + const std::string &outWSName); + //@} + + // plots workspace according to the user selection + void plotFocusedWorkspace(const std::string &outWSName); + + void plotCalibWorkspace(const std::vector<double> &difa, + const std::vector<double> &difc, + const std::vector<double> &tzero, + const std::string &specNos); + + // algorithms to save the generated workspace + void saveGSS(const RunLabel &runLabel, const std::string &inputWorkspace); + void saveFocusedXYE(const RunLabel &runLabel, + const std::string &inputWorkspace); + void saveNexus(const RunLabel &runLabel, const std::string &inputWorkspace); + void saveOpenGenie(const RunLabel &runLabel, + const std::string &inputWorkspace); + void exportSampleLogsToHDF5(const std::string &inputWorkspace, + const std::string &filename) const; + + // generates the required file name of the output files + std::string outFileNameFactory(const std::string &inputWorkspace, + const RunLabel &runLabel, + const std::string &format); + + // returns a directory as a path, creating it if not found, and checking + // errors + Poco::Path outFilesUserDir(const std::string &addToDir) const override; + std::string userHDFRunFilename(const std::string &runNumber) const override; + std::string userHDFMultiRunFilename( + const std::vector<RunLabel> &runLabels) const override; + Poco::Path outFilesGeneralDir(const std::string &addComponent); + Poco::Path outFilesRootDir() const; + + std::string appendToPath(const std::string &path, + const std::string &toAppend) const; + + /// convenience methods to copy files to different destinations + void copyToGeneral(const Poco::Path &source, const std::string &pathComp); + void copyToUser(const Poco::Path &source, const std::string &pathComp); + void copyFocusedToUserAndAll(const std::string &fullFilename); + + // generates appropriate names for table workspaces + std::string outFitParamsTblNameGenerator(const std::string &specNos, + size_t bank_i) const; + + // generates the pycode string which can be passed to view + std::string vanadiumCurvesPlotFactory(); + + std::string TOFFitWorkspaceFactory( + const std::vector<double> &difa, const std::vector<double> &difc, + const std::vector<double> &tzero, const std::string &specNo, + const std::string &customisedBankName) const; + + std::string plotTOFWorkspace(const std::string &customisedBankName) const; + + void writeOutCalibFile(const std::string &outFilename, + const std::vector<double> &difa, + const std::vector<double> &difc, + const std::vector<double> &tzero, + const std::vector<std::string> &bankNames, + const std::string &ceriaNo, const std::string &vanNo, + const std::string &templateFile = ""); + + /// keep track of the paths the user "browses to", to add them in + /// the file search path + void recordPathBrowsedTo(const std::string &filename); + + /// paths the user has "browsed to", to add them to the search path + std::vector<std::string> m_browsedToPaths; + + /// string to use for invalid run number error message + const static std::string g_runNumberErrorStr; + + // for the GSAS parameters (difc, difa, tzero) of the banks + static const std::string g_calibBanksParms; + + /// whether to allow users to give the output calibration filename + const static bool g_askUserCalibFilename; + + /// whether to break the thread + static bool g_abortThread; + + /// whether to run Sum Of Files & which focus run number to use + static std::string g_sumOfFilesFocus; + + /// saves the last valid run number + static std::string g_lastValidRun; + + /// bank name used or SpecNos for cropped calibration + static std::string g_calibCropIdentifier; + + QThread *m_workerThread; + + /// true if the last thing ran was cancelled + bool m_cancelled; + + /// true if the last calibration completed successfully + bool m_calibFinishedOK; + + /// error that caused the calibration to fail + std::string m_calibError; + /// path where the calibration has been produced (par/prm file) + std::string m_calibFullPath; + + /// The current calibration parameters (used for units conversion). It should + /// be updated when a new calibration is done or re-loading an existing one + std::vector<GSASCalibrationParms> m_currentCalibParms; + + /// true if the last focusing completed successfully + bool m_focusFinishedOK; + /// error that caused the focus to fail + std::string m_focusError; + /// true if the last pre-processing/re-binning completed successfully + bool m_rebinningFinishedOK; + + /// Counter for the cropped output files + static int g_croppedCounter; + + /// counter for the plotting workspace + static int g_plottingCounter; + + /// Associated view for this presenter (MVP pattern) + IEnggDiffractionView *const m_view; + + /// Tracks if the view has started to shut down following a close signal + bool m_viewHasClosed; + + /// Associated model for this presenter (MVP pattern) + // const boost::scoped_ptr<EnggDiffractionModel> m_model; + + /// the current selected instrument + std::string m_currentInst = ""; + + /// Model for calculating the vanadium corrections workspaces for focus and + /// calib + boost::shared_ptr<IEnggVanadiumCorrectionsModel> m_vanadiumCorrectionsModel; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt \ No newline at end of file diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d8abce02b5edaf2e809430707b77ae3878f5cf0f --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.cpp @@ -0,0 +1,1105 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggDiffractionViewQtGUI.h" +#include "EnggDiffractionPresenter.h" +#include "MantidKernel/ConfigService.h" +#include "MantidQtWidgets/Common/AlgorithmInputHistory.h" +#include "MantidQtWidgets/Common/AlgorithmRunner.h" +#include "MantidQtWidgets/Common/HelpWindow.h" +#include "MantidQtWidgets/Common/MWRunFiles.h" + +#include <Poco/DirectoryIterator.h> +#include <Poco/Path.h> + +#include <QCheckBox> +#include <QCloseEvent> +#include <QFileDialog> +#include <QMessageBox> +#include <QSettings> + +using namespace Mantid::API; +using namespace MantidQt::CustomInterfaces; + +namespace MantidQt { +namespace CustomInterfaces { + +// Add this class to the list of specialised dialogs in this namespace +// Hidden for release of 5.0 to be removed as a maintainance issue. +// DECLARE_SUBWINDOW(EnggDiffractionViewQtGUI) + +const double EnggDiffractionViewQtGUI::g_defaultRebinWidth = -0.0005; + +int EnggDiffractionViewQtGUI::g_currentType = 0; +int EnggDiffractionViewQtGUI::g_currentRunMode = 0; +int EnggDiffractionViewQtGUI::g_currentCropCalibBankName = 0; + +const std::string EnggDiffractionViewQtGUI::g_iparmExtStr = + "GSAS instrument parameters, IPARM file: PRM, PAR, IPAR, IPARAM " + "(*.prm *.par *.ipar *.iparam);;" + "Other extensions/all files (*)"; + +const std::string EnggDiffractionViewQtGUI::g_pixelCalibExt = + "Comma separated values text file with calibration table, CSV" + "(*.csv);;" + "Nexus file with calibration table: NXS, NEXUS" + "(*.nxs *.nexus);;" + "Supported formats: CSV, NXS " + "(*.csv *.nxs *.nexus);;" + "Other extensions/all files (*)"; + +const std::string EnggDiffractionViewQtGUI::g_DetGrpExtStr = + "Detector Grouping File: CSV " + "(*.csv *.txt);;" + "Other extensions/all files (*)"; + +const std::string EnggDiffractionViewQtGUI::g_settingsGroup = + "CustomInterfaces/EnggDiffractionView"; + +/** + * Default constructor. + * + * @param parent Parent window (most likely the Mantid main app window). + */ +EnggDiffractionViewQtGUI::EnggDiffractionViewQtGUI(QWidget *parent) + : UserSubWindow(parent), IEnggDiffractionView(), m_fittingWidget(nullptr), + m_currentInst("ENGINX"), m_splashMsg(nullptr), m_presenter(nullptr) {} + +void EnggDiffractionViewQtGUI::initLayout() { + // setup container ui + m_ui.setupUi(this); + + // presenter that knows how to handle a IEnggDiffractionView should + // take care of all the logic. Note that the view needs to know the + // concrete presenter + auto fullPres = boost::make_shared<EnggDiffractionPresenter>(this); + m_presenter = fullPres; + + // add tab contents and set up their ui's + QWidget *wCalib = new QWidget(m_ui.tabMain); + m_uiTabCalib.setupUi(wCalib); + m_ui.tabMain->addTab(wCalib, QString("Calibration")); + + QWidget *wFocus = new QWidget(m_ui.tabMain); + m_uiTabFocus.setupUi(wFocus); + m_ui.tabMain->addTab(wFocus, QString("Focus")); + + QWidget *wPreproc = new QWidget(m_ui.tabMain); + m_uiTabPreproc.setupUi(wPreproc); + m_ui.tabMain->addTab(wPreproc, QString("Pre-processing")); + + // This is created from a QWidget* -> use null-deleter to prevent double-free + // with Qt + boost::shared_ptr<EnggDiffractionViewQtGUI> sharedView( + this, [](EnggDiffractionViewQtGUI * /*unused*/) {}); + m_fittingWidget = + new EnggDiffFittingViewQtWidget(m_ui.tabMain, sharedView, sharedView, + fullPres, fullPres, sharedView, fullPres); + m_ui.tabMain->addTab(m_fittingWidget, QString("Fitting")); + + m_gsasWidget = + new EnggDiffGSASFittingViewQtWidget(sharedView, sharedView, fullPres); + m_ui.tabMain->addTab(m_gsasWidget, QString("GSAS-II Refinement")); + + QWidget *wSettings = new QWidget(m_ui.tabMain); + m_uiTabSettings.setupUi(wSettings); + m_ui.tabMain->addTab(wSettings, QString("Settings")); + + QComboBox *inst = m_ui.comboBox_instrument; + m_currentInst = inst->currentText().toStdString(); + + setPrefix(m_currentInst); + // An initial check on the RB number will enable the tabs after all + // the widgets and connections are set up + enableTabs(false); + + readSettings(); + + // basic UI setup, connect signals, etc. + doSetupGeneralWidgets(); + doSetupTabCalib(); + doSetupTabFocus(); + doSetupTabPreproc(); + doSetupTabSettings(); + + m_presenter->notify(IEnggDiffractionPresenter::Start); + // We need to delay the RB-number check for the pop-up (splash message) + // as it will be shown very early (before the interface + // window itself is shown) and that will cause a crash in Qt code on + // some platforms (windows 10, and 7 sometimes). + // so perform the check in the showEvent method to check on start up +} + +void EnggDiffractionViewQtGUI::doSetupTabCalib() { + // Some recent available runs as defaults. This (as well as the + // empty defaults just above) should probably be made persistent - + // and encapsulated into a CalibrationParameters or similar + // class/structure + const std::string vanadiumRun = "236516"; + const std::string ceriaRun = "241391"; + if (m_uiTabCalib.MWRunFiles_new_vanadium_num->getUserInput() + .toString() + .isEmpty()) { + m_uiTabCalib.MWRunFiles_new_vanadium_num->setFileTextWithoutSearch( + QString::fromStdString(vanadiumRun)); + } + if (m_uiTabCalib.MWRunFiles_new_ceria_num->getUserInput() + .toString() + .isEmpty()) { + m_uiTabCalib.MWRunFiles_new_ceria_num->setFileTextWithoutSearch( + QString::fromStdString(ceriaRun)); + } + + // push button signals/slots + connect(m_uiTabCalib.pushButton_load_calib, SIGNAL(released()), this, + SLOT(loadCalibrationClicked())); + + connect(m_uiTabCalib.pushButton_new_calib, SIGNAL(released()), this, + SLOT(calibrateClicked())); + + connect(m_uiTabCalib.pushButton_new_cropped_calib, SIGNAL(released()), this, + SLOT(CroppedCalibrateClicked())); + + connect(m_uiTabCalib.comboBox_calib_cropped_bank_name, + SIGNAL(currentIndexChanged(int)), this, + SLOT(calibspecNoChanged(int))); + + connect(m_uiTabCalib.comboBox_calib_cropped_bank_name, + SIGNAL(currentIndexChanged(int)), this, SLOT(enableSpecNos())); + + enableCalibrateFocusFitUserActions(true); +} + +void EnggDiffractionViewQtGUI::doSetupTabFocus() { + + connect(m_uiTabFocus.pushButton_focus, SIGNAL(released()), this, + SLOT(focusClicked())); + + connect(m_uiTabFocus.pushButton_focus_cropped, SIGNAL(released()), this, + SLOT(focusCroppedClicked())); + + connect(m_uiTabFocus.pushButton_texture_browse_grouping_file, + SIGNAL(released()), this, SLOT(browseTextureDetGroupingFile())); + + connect(m_uiTabFocus.pushButton_focus_texture, SIGNAL(released()), this, + SLOT(focusTextureClicked())); + + connect(m_uiTabFocus.pushButton_reset, SIGNAL(released()), this, + SLOT(focusResetClicked())); + + connect(m_uiTabFocus.pushButton_stop_focus, SIGNAL(released()), this, + SLOT(focusStopClicked())); + + connect(m_uiTabFocus.comboBox_PlotData, SIGNAL(currentIndexChanged(int)), + this, SLOT(plotRepChanged(int))); + + connect(m_uiTabFocus.comboBox_Multi_Runs, SIGNAL(currentIndexChanged(int)), + this, SLOT(multiRunModeChanged(int))); + + connect(m_uiTabFocus.checkBox_plot_focused_ws, SIGNAL(clicked()), this, + SLOT(plotFocusStatus())); +} + +void EnggDiffractionViewQtGUI::doSetupTabPreproc() { + connect(m_uiTabPreproc.pushButton_rebin_time, SIGNAL(released()), this, + SLOT(rebinTimeClicked())); + + connect(m_uiTabPreproc.pushButton_rebin_multiperiod, SIGNAL(released()), this, + SLOT(rebinMultiperiodClicked())); +} + +void EnggDiffractionViewQtGUI::doSetupTabSettings() { + // line edits that display paths and the like + m_uiTabSettings.lineEdit_input_dir_calib->setText( + QString::fromStdString(m_calibSettings.m_inputDirCalib)); + m_uiTabSettings.lineEdit_input_dir_raw->setText( + QString::fromStdString(m_calibSettings.m_inputDirRaw)); + m_uiTabSettings.lineEdit_pixel_calib_filename->setText( + QString::fromStdString(m_calibSettings.m_pixelCalibFilename)); + m_uiTabSettings.lineEdit_template_gsas_prm->setText( + QString::fromStdString(m_calibSettings.m_templateGSAS_PRM)); + m_calibSettings.m_forceRecalcOverwrite = false; + m_uiTabSettings.checkBox_force_recalculate_overwrite->setChecked( + m_calibSettings.m_forceRecalcOverwrite); + + // push button signals/slots + connect(m_uiTabSettings.pushButton_browse_input_dir_calib, SIGNAL(released()), + this, SLOT(browseInputDirCalib())); + + connect(m_uiTabSettings.pushButton_browse_input_dir_raw, SIGNAL(released()), + this, SLOT(browseInputDirRaw())); + + connect(m_uiTabSettings.pushButton_browse_pixel_calib_filename, + SIGNAL(released()), this, SLOT(browsePixelCalibFilename())); + + connect(m_uiTabSettings.pushButton_browse_template_gsas_prm, + SIGNAL(released()), this, SLOT(browseTemplateGSAS_PRM())); + + connect(m_uiTabSettings.checkBox_force_recalculate_overwrite, + SIGNAL(stateChanged(int)), this, + SLOT(forceRecalculateStateChanged())); +} + +void EnggDiffractionViewQtGUI::doSetupGeneralWidgets() { + doSetupSplashMsg(); + + // don't show the re-size corner + m_ui.statusbar->setSizeGripEnabled(false); + + // change instrument + connect(m_ui.comboBox_instrument, SIGNAL(currentIndexChanged(int)), this, + SLOT(instrumentChanged(int))); + connect(m_ui.pushButton_help, SIGNAL(released()), this, SLOT(openHelpWin())); + // note connection to the parent window, otherwise an empty frame window + // may remain open and visible after this close + if (this->parent()) { + connect(m_ui.pushButton_close, SIGNAL(released()), this->parent(), + SLOT(close())); + } + + connect(m_ui.lineEdit_RBNumber, SIGNAL(editingFinished()), this, + SLOT(RBNumberChanged())); +} + +void EnggDiffractionViewQtGUI::doSetupSplashMsg() { + if (m_splashMsg) + delete m_splashMsg; + + m_splashMsg = new QMessageBox(this); + m_splashMsg->setIcon(QMessageBox::Information); + m_splashMsg->setStandardButtons(QMessageBox::NoButton); + m_splashMsg->setWindowTitle("Setting up"); + m_splashMsg->setText("Setting up the interface!"); + m_splashMsg->setWindowFlags(Qt::SplashScreen | Qt::FramelessWindowHint | + Qt::X11BypassWindowManagerHint); + m_splashMsg->setWindowModality(Qt::NonModal); + // we don't want to show now: m_splashMsg->show(); +} + +void EnggDiffractionViewQtGUI::readSettings() { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + m_ui.lineEdit_RBNumber->setText( + qs.value("user-params-RBNumber", "").toString()); + + m_uiTabCalib.lineEdit_current_vanadium_num->setText( + qs.value("user-params-current-vanadium-num", "").toString()); + m_uiTabCalib.lineEdit_current_ceria_num->setText( + qs.value("user-params-current-ceria-num", "").toString()); + QString calibFname = qs.value("current-calib-filename", "").toString(); + m_uiTabCalib.lineEdit_current_calib_filename->setText(calibFname); + + m_uiTabCalib.MWRunFiles_new_vanadium_num->setUserInput( + qs.value("user-params-new-vanadium-num", "").toString()); + m_uiTabCalib.MWRunFiles_new_ceria_num->setUserInput( + qs.value("user-params-new-ceria-num", "").toString()); + + m_uiTabCalib.groupBox_calib_cropped->setChecked( + qs.value("user-params-calib-cropped-group-checkbox", false).toBool()); + + m_uiTabCalib.comboBox_calib_cropped_bank_name->setCurrentIndex(0); + + m_uiTabCalib.lineEdit_cropped_spec_nos->setText( + qs.value("user-params-calib-cropped-spectrum-nos", "").toString()); + + m_uiTabCalib.lineEdit_cropped_customise_bank_name->setText( + qs.value("user-params-calib-cropped-customise-name", "cropped") + .toString()); + + m_uiTabCalib.checkBox_PlotData_Calib->setChecked( + qs.value("user-param-calib-plot-data", true).toBool()); + + // user params - focusing + m_uiTabFocus.MWRunFiles_run_num->setUserInput( + qs.value("user-params-focus-runno", "").toString()); + + qs.beginReadArray("user-params-focus-bank_i"); + qs.setArrayIndex(0); + m_uiTabFocus.checkBox_focus_bank1->setChecked( + qs.value("value", true).toBool()); + qs.setArrayIndex(1); + m_uiTabFocus.checkBox_focus_bank2->setChecked( + qs.value("value", true).toBool()); + qs.endArray(); + + m_uiTabFocus.MWRunFiles_cropped_run_num->setUserInput( + qs.value("user-params-focus-cropped-runno", "").toString()); + + m_uiTabFocus.lineEdit_cropped_spec_nos->setText( + qs.value("user-params-focus-cropped-spectrum-nos", "").toString()); + + m_uiTabFocus.MWRunFiles_texture_run_num->setUserInput( + qs.value("user-params-focus-texture-runno", "").toString()); + + m_uiTabFocus.lineEdit_texture_grouping_file->setText( + qs.value("user-params-focus-texture-detector-grouping-file", "") + .toString()); + + m_uiTabFocus.groupBox_cropped->setChecked( + qs.value("user-params-focus-cropped-group-checkbox", false).toBool()); + + m_uiTabFocus.groupBox_texture->setChecked( + qs.value("user-params-focus-texture-group-checkbox", false).toBool()); + + m_uiTabFocus.checkBox_plot_focused_ws->setChecked( + qs.value("user-params-focus-plot-focused-ws", true).toBool()); + + m_uiTabFocus.checkBox_save_output_files->setChecked( + qs.value("user-params-focus-save-output-files", true).toBool()); + + m_uiTabFocus.comboBox_PlotData->setCurrentIndex( + qs.value("user-params-focus-plot-type", 0).toInt()); + + m_uiTabFocus.comboBox_Multi_Runs->setCurrentIndex( + qs.value("user-params-multiple-runs-focus-mode", 0).toInt()); + + // pre-processing (re-binning) + m_uiTabPreproc.MWRunFiles_preproc_run_num->setUserInput( + qs.value("user-params-preproc-runno", "").toString()); + + m_uiTabPreproc.doubleSpinBox_time_bin->setValue( + qs.value("user-params-time-bin", 0.1).toDouble()); + + m_uiTabPreproc.spinBox_nperiods->setValue( + qs.value("user-params-nperiods", 2).toInt()); + + m_uiTabPreproc.doubleSpinBox_step_time->setValue( + qs.value("user-params-step-time", 1).toDouble()); + + // settings + QString lastPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + // TODO: as this is growing, it should become << >> operators on + // EnggDiffCalibSettings + m_calibSettings.m_inputDirCalib = + qs.value("input-dir-calib-files", lastPath).toString().toStdString(); + + m_calibSettings.m_inputDirRaw = + qs.value("input-dir-raw-files", lastPath).toString().toStdString(); + + const std::string fullCalib = guessDefaultFullCalibrationPath(); + m_calibSettings.m_pixelCalibFilename = + qs.value("pixel-calib-filename", QString::fromStdString(fullCalib)) + .toString() + .toStdString(); + + // 'advanced' block + m_calibSettings.m_forceRecalcOverwrite = + qs.value("force-recalc-overwrite", false).toBool(); + + const std::string templ = guessGSASTemplatePath(); + m_calibSettings.m_templateGSAS_PRM = + qs.value("template-gsas-prm", QString::fromStdString(templ)) + .toString() + .toStdString(); + + m_calibSettings.m_rebinCalibrate = + qs.value("rebin-calib", g_defaultRebinWidth).toFloat(); + + m_ui.tabMain->setCurrentIndex(qs.value("selected-tab-index").toInt()); + + restoreGeometry(qs.value("interface-win-geometry").toByteArray()); + qs.endGroup(); +} + +void EnggDiffractionViewQtGUI::saveSettings() const { + QSettings qs; + qs.beginGroup(QString::fromStdString(g_settingsGroup)); + + qs.setValue("user-params-RBNumber", m_ui.lineEdit_RBNumber->text()); + + qs.setValue("user-params-current-vanadium-num", + m_uiTabCalib.lineEdit_current_vanadium_num->text()); + qs.setValue("user-params-current-ceria-num", + m_uiTabCalib.lineEdit_current_ceria_num->text()); + qs.setValue("current-calib-filename", + m_uiTabCalib.lineEdit_current_calib_filename->text()); + + qs.setValue("user-params-new-vanadium-num", ""); + qs.setValue("user-params-new-ceria-num", ""); + + qs.setValue("user-params-calib-cropped-group-checkbox", + m_uiTabCalib.groupBox_calib_cropped->isChecked()); + + qs.setValue("user-params-calib-cropped-spectrum-nos", + m_uiTabCalib.lineEdit_cropped_spec_nos->text()); + + qs.setValue("user-params-calib-cropped-customise-name", + m_uiTabCalib.lineEdit_cropped_customise_bank_name->text()); + + qs.setValue("user-param-calib-plot-data", + m_uiTabCalib.checkBox_PlotData_Calib->isChecked()); + + // user params - focusing + qs.setValue("user-params-focus-runno", + m_uiTabFocus.MWRunFiles_run_num->getText()); + + qs.beginWriteArray("user-params-focus-bank_i"); + qs.setArrayIndex(0); + qs.setValue("value", m_uiTabFocus.checkBox_focus_bank1->isChecked()); + qs.setArrayIndex(1); + qs.setValue("value", m_uiTabFocus.checkBox_focus_bank2->isChecked()); + qs.endArray(); + + qs.setValue("user-params-focus-cropped-runno", + m_uiTabFocus.MWRunFiles_cropped_run_num->getText()); + qs.setValue("user-params-focus-cropped-spectrum-nos", + m_uiTabFocus.lineEdit_cropped_spec_nos->text()); + + qs.setValue("user-params-focus-texture-runno", + m_uiTabFocus.MWRunFiles_texture_run_num->getText()); + qs.setValue("user-params-focus-texture-detector-grouping-file", + m_uiTabFocus.lineEdit_texture_grouping_file->text()); + + qs.setValue("user-params-focus-cropped-group-checkbox", + m_uiTabFocus.groupBox_cropped->isChecked()); + + qs.setValue("user-params-focus-texture-group-checkbox", + m_uiTabFocus.groupBox_texture->isChecked()); + + qs.setValue("user-params-focus-plot-focused-ws", + m_uiTabFocus.checkBox_plot_focused_ws->isChecked()); + + qs.setValue("user-params-focus-save-output-files", + m_uiTabFocus.checkBox_plot_focused_ws->isChecked()); + + qs.setValue("user-params-focus-plot-type", + m_uiTabFocus.comboBox_PlotData->currentIndex()); + + qs.setValue("user-params-multiple-runs-focus-mode", + m_uiTabFocus.comboBox_Multi_Runs->currentIndex()); + + // pre-processing (re-binning) + qs.setValue("user-params-preproc-runno", + m_uiTabPreproc.MWRunFiles_preproc_run_num->getText()); + + qs.setValue("user-params-time-bin", + m_uiTabPreproc.doubleSpinBox_time_bin->value()); + + qs.setValue("user-params-nperiods", m_uiTabPreproc.spinBox_nperiods->value()); + + qs.value("user-params-step-time", + m_uiTabPreproc.doubleSpinBox_step_time->value()); + + // TODO: this should become << >> operators on EnggDiffCalibSettings + qs.setValue("input-dir-calib-files", + QString::fromStdString(m_calibSettings.m_inputDirCalib)); + qs.setValue("input-dir-raw-files", + QString::fromStdString(m_calibSettings.m_inputDirRaw)); + qs.setValue("pixel-calib-filename", + QString::fromStdString(m_calibSettings.m_pixelCalibFilename)); + // 'advanced' block + qs.setValue("force-recalc-overwrite", m_calibSettings.m_forceRecalcOverwrite); + qs.setValue("template-gsas-prm", + QString::fromStdString(m_calibSettings.m_templateGSAS_PRM)); + qs.setValue("rebin-calib", m_calibSettings.m_rebinCalibrate); + + qs.setValue("selected-tab-index", m_ui.tabMain->currentIndex()); + + qs.setValue("interface-win-geometry", saveGeometry()); + qs.endGroup(); +} + +std::string EnggDiffractionViewQtGUI::guessGSASTemplatePath() const { + // Inside the mantid installation target directory: + // scripts/Engineering/template_ENGINX_241391_236516_North_and_South_banks.par + Poco::Path templ = + Mantid::Kernel::ConfigService::Instance().getInstrumentDirectory(); + templ = templ.makeParent(); + templ.append("scripts"); + templ.append("Engineering"); + templ.append("template_ENGINX_241391_236516_North_and_South_banks.par"); + return templ.toString(); +} + +std::string EnggDiffractionViewQtGUI::guessDefaultFullCalibrationPath() const { + // Inside the mantid installation target directory: + // scripts/Engineering/ENGINX_full_pixel_calibration_vana194547_ceria193749.csv + Poco::Path templ = + Mantid::Kernel::ConfigService::Instance().getInstrumentDirectory(); + templ = templ.makeParent(); + templ.append("scripts"); + templ.append("Engineering"); + templ.append("calib"); + templ.append("ENGINX_full_pixel_calibration_vana194547_ceria193749.csv"); + return templ.toString(); +} + +void EnggDiffractionViewQtGUI::splashMessage(bool visible, + const std::string &shortMsg, + const std::string &description) { + if (!m_splashMsg) + return; + + m_splashMsg->setWindowTitle(QString::fromStdString(shortMsg)); + m_splashMsg->setText(QString::fromStdString(description)); + // when showing the message, force it to show up centered + if (visible) { + const auto pos = this->mapToGlobal(rect().center()); + m_splashMsg->move(pos.x() - m_splashMsg->width() / 2, + pos.y() - m_splashMsg->height() / 2); + } + m_splashMsg->setVisible(visible); +} + +void EnggDiffractionViewQtGUI::showStatus(const std::string &sts) { + m_ui.statusbar->showMessage(QString::fromStdString(sts)); +} + +void EnggDiffractionViewQtGUI::userWarning(const std::string &err, + const std::string &description) { + QMessageBox::warning(this, QString::fromStdString(err), + QString::fromStdString(description), QMessageBox::Ok, + QMessageBox::Ok); +} + +void EnggDiffractionViewQtGUI::userError(const std::string &err, + const std::string &description) { + QMessageBox::critical(this, QString::fromStdString(err), + QString::fromStdString(description), QMessageBox::Ok, + QMessageBox::Ok); +} + +std::string EnggDiffractionViewQtGUI::askNewCalibrationFilename( + const std::string &suggestedFname) { + // append dir (basename) + filename + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + QDir path(prevPath); + QString suggestion = path.filePath(QString::fromStdString(suggestedFname)); + QString choice = QFileDialog::getSaveFileName( + this, tr("Please select the name of the calibration file"), suggestion, + QString::fromStdString(g_iparmExtStr)); + + return choice.toStdString(); +} + +std::string EnggDiffractionViewQtGUI::getRBNumber() const { + return m_ui.lineEdit_RBNumber->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::currentVanadiumNo() const { + return m_uiTabCalib.lineEdit_current_vanadium_num->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::currentCeriaNo() const { + return m_uiTabCalib.lineEdit_current_ceria_num->text().toStdString(); +} + +std::vector<std::string> EnggDiffractionViewQtGUI::newVanadiumNo() const { + return qListToVector(m_uiTabCalib.MWRunFiles_new_vanadium_num->getFilenames(), + m_uiTabCalib.MWRunFiles_new_vanadium_num->isValid()); +} + +std::vector<std::string> EnggDiffractionViewQtGUI::newCeriaNo() const { + return qListToVector(m_uiTabCalib.MWRunFiles_new_ceria_num->getFilenames(), + m_uiTabCalib.MWRunFiles_new_ceria_num->isValid()); +} + +std::string EnggDiffractionViewQtGUI::currentCalibFile() const { + return m_uiTabCalib.lineEdit_current_calib_filename->text().toStdString(); +} + +void EnggDiffractionViewQtGUI::newCalibLoaded(const std::string &vanadiumNo, + const std::string &ceriaNo, + const std::string &fname) { + + m_uiTabCalib.lineEdit_current_vanadium_num->setText( + QString::fromStdString(vanadiumNo)); + m_uiTabCalib.lineEdit_current_ceria_num->setText( + QString::fromStdString(ceriaNo)); + m_uiTabCalib.lineEdit_current_calib_filename->setText( + QString::fromStdString(fname)); + + if (!fname.empty()) { + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory( + QString::fromStdString(fname)); + } +} + +void EnggDiffractionViewQtGUI::enableCalibrateFocusFitUserActions(bool enable) { + // calibrate + m_uiTabCalib.groupBox_make_new_calib->setEnabled(enable); + m_uiTabCalib.groupBox_current_calib->setEnabled(enable); + m_uiTabCalib.groupBox_calib_cropped->setEnabled(enable); + m_uiTabCalib.pushButton_new_cropped_calib->setEnabled(enable); + m_ui.pushButton_close->setEnabled(enable); + m_uiTabCalib.checkBox_PlotData_Calib->setEnabled(enable); + + // focus + m_uiTabFocus.MWRunFiles_run_num->setEnabled(enable); + m_uiTabFocus.pushButton_focus->setEnabled(enable); + + m_uiTabFocus.groupBox_cropped->setEnabled(enable); + m_uiTabFocus.groupBox_texture->setEnabled(enable); + + // Disable all focus output options except graph plotting + m_uiTabFocus.checkBox_plot_focused_ws->setEnabled(enable); + m_uiTabFocus.checkBox_save_output_files->setEnabled(enable); + m_uiTabFocus.comboBox_Multi_Runs->setEnabled(enable); + + m_uiTabFocus.pushButton_stop_focus->setDisabled(enable); + m_uiTabFocus.pushButton_reset->setEnabled(enable); + + // pre-processing + m_uiTabPreproc.MWRunFiles_preproc_run_num->setEnabled(enable); + m_uiTabPreproc.pushButton_rebin_time->setEnabled(enable); + m_uiTabPreproc.pushButton_rebin_multiperiod->setEnabled(enable); + + // fitting + m_fittingWidget->enable(enable); + m_gsasWidget->setEnabled(enable); +} + +void EnggDiffractionViewQtGUI::enableTabs(bool enable) { + for (int ti = 0; ti < m_ui.tabMain->count(); ++ti) { + m_ui.tabMain->setTabEnabled(ti, enable); + } +} + +std::vector<std::string> EnggDiffractionViewQtGUI::currentPreprocRunNo() const { + return qListToVector( + m_uiTabPreproc.MWRunFiles_preproc_run_num->getFilenames(), + m_uiTabPreproc.MWRunFiles_preproc_run_num->isValid()); +} + +double EnggDiffractionViewQtGUI::rebinningTimeBin() const { + return m_uiTabPreproc.doubleSpinBox_time_bin->value(); +} + +size_t EnggDiffractionViewQtGUI::rebinningPulsesNumberPeriods() const { + return m_uiTabPreproc.spinBox_nperiods->value(); +} + +double EnggDiffractionViewQtGUI::rebinningPulsesTime() const { + return m_uiTabPreproc.doubleSpinBox_step_time->value(); +} + +void EnggDiffractionViewQtGUI::plotFocusedSpectrum(const std::string &wsName) { + std::string pyCode = + "win=plotSpectrum('" + wsName + "', 0, error_bars=False, type=0)"; + + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::plotWaterfallSpectrum( + const std::string &wsName) { + // parameter of list ? + std::string pyCode = + "plotSpectrum('" + wsName + + "', 0, error_bars=False, type=0, waterfall=True, window=win)"; + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::plotReplacingWindow(const std::string &wsName, + const std::string &spectrum, + const std::string &type) { + std::string pyCode = "win=plotSpectrum('" + wsName + "', " + spectrum + + ", error_bars=False, type=" + type + + ", window=win, clearWindow=True)"; + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + + m_logMsgs.emplace_back("Plotted output focused data, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::plotCalibOutput(const std::string &pyCode) { + + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + + m_logMsgs.emplace_back( + "Plotted output calibration vanadium curves, with status string " + + status); + m_presenter->notify(IEnggDiffractionPresenter::LogMsg); +} + +void EnggDiffractionViewQtGUI::resetFocus() { + m_uiTabFocus.MWRunFiles_run_num->setUserInput(""); + m_uiTabFocus.checkBox_focus_bank1->setChecked(true); + m_uiTabFocus.checkBox_focus_bank2->setChecked(true); + + m_uiTabFocus.MWRunFiles_cropped_run_num->setUserInput(""); + m_uiTabFocus.lineEdit_cropped_spec_nos->setText(""); + + m_uiTabFocus.groupBox_cropped->setChecked(false); + m_uiTabFocus.groupBox_texture->setChecked(false); + + m_uiTabFocus.MWRunFiles_run_num->setUserInput(""); + m_uiTabFocus.lineEdit_texture_grouping_file->setText(""); +} + +std::string +EnggDiffractionViewQtGUI::enggRunPythonCode(const std::string &pyCode) { + std::string status = + runPythonCode(QString::fromStdString(pyCode), false).toStdString(); + + return status; +} + +std::string EnggDiffractionViewQtGUI::askExistingCalibFilename() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + + QString filename = + QFileDialog::getOpenFileName(this, tr("Open calibration file"), prevPath, + QString::fromStdString(g_iparmExtStr)); + + if (!filename.isEmpty()) { + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory( + filename); + } + + return filename.toStdString(); +} + +void EnggDiffractionViewQtGUI::loadCalibrationClicked() { + m_presenter->notify(IEnggDiffractionPresenter::LoadExistingCalib); +} + +void EnggDiffractionViewQtGUI::calibrateClicked() { + m_presenter->notify(IEnggDiffractionPresenter::CalcCalib); +} + +void EnggDiffractionViewQtGUI::CroppedCalibrateClicked() { + m_presenter->notify(IEnggDiffractionPresenter::CropCalib); +} + +void EnggDiffractionViewQtGUI::focusClicked() { + m_presenter->notify(IEnggDiffractionPresenter::FocusRun); +} + +void EnggDiffractionViewQtGUI::focusCroppedClicked() { + m_presenter->notify(IEnggDiffractionPresenter::FocusCropped); +} + +void EnggDiffractionViewQtGUI::focusTextureClicked() { + m_presenter->notify(IEnggDiffractionPresenter::FocusTexture); +} + +void EnggDiffractionViewQtGUI::focusResetClicked() { + m_presenter->notify(IEnggDiffractionPresenter::ResetFocus); +} + +void EnggDiffractionViewQtGUI::focusStopClicked() { + m_presenter->notify(IEnggDiffractionPresenter::StopFocus); +} + +void EnggDiffractionViewQtGUI::rebinTimeClicked() { + m_presenter->notify(IEnggDiffractionPresenter::RebinTime); +} + +void EnggDiffractionViewQtGUI::rebinMultiperiodClicked() { + m_presenter->notify(IEnggDiffractionPresenter::RebinMultiperiod); +} + +void EnggDiffractionViewQtGUI::browseInputDirCalib() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + QString dir = QFileDialog::getExistingDirectory( + this, tr("Open Directory"), prevPath, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if (dir.isEmpty()) { + return; + } + + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(dir); + m_calibSettings.m_inputDirCalib = dir.toStdString(); + m_uiTabSettings.lineEdit_input_dir_calib->setText( + QString::fromStdString(m_calibSettings.m_inputDirCalib)); +} + +void EnggDiffractionViewQtGUI::browseInputDirRaw() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirRaw); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + QString dir = QFileDialog::getExistingDirectory( + this, tr("Open Directory"), prevPath, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if (dir.isEmpty()) { + return; + } + + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(dir); + m_calibSettings.m_inputDirRaw = dir.toStdString(); + m_uiTabSettings.lineEdit_input_dir_raw->setText( + QString::fromStdString(m_calibSettings.m_inputDirRaw)); +} + +void EnggDiffractionViewQtGUI::browsePixelCalibFilename() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirCalib); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + + QString filename = QFileDialog::getOpenFileName( + this, tr("Open pixel calibration (full calibration) file"), prevPath, + QString::fromStdString(g_pixelCalibExt)); + + if (filename.isEmpty()) { + return; + } + + m_calibSettings.m_pixelCalibFilename = filename.toStdString(); + m_uiTabSettings.lineEdit_pixel_calib_filename->setText( + QString::fromStdString(m_calibSettings.m_pixelCalibFilename)); +} + +void EnggDiffractionViewQtGUI::browseTemplateGSAS_PRM() { + + QString prevPath = QString::fromStdString(m_calibSettings.m_templateGSAS_PRM); + QString path(QFileDialog::getOpenFileName( + this, tr("Open GSAS IPAR template file"), prevPath, + QString::fromStdString(g_iparmExtStr))); + + if (path.isEmpty()) { + return; + } + + m_calibSettings.m_templateGSAS_PRM = path.toStdString(); + m_uiTabSettings.lineEdit_template_gsas_prm->setText( + QString::fromStdString(m_calibSettings.m_templateGSAS_PRM)); +} + +void EnggDiffractionViewQtGUI::forceRecalculateStateChanged() { + m_calibSettings.m_forceRecalcOverwrite = + m_uiTabSettings.checkBox_force_recalculate_overwrite->isChecked(); +} + +void EnggDiffractionViewQtGUI::browseTextureDetGroupingFile() { + QString prevPath = QString::fromStdString(m_calibSettings.m_inputDirRaw); + if (prevPath.isEmpty()) { + prevPath = + MantidQt::API::AlgorithmInputHistory::Instance().getPreviousDirectory(); + } + + QString path(QFileDialog::getOpenFileName( + this, tr("Open detector grouping file"), prevPath, + QString::fromStdString(g_DetGrpExtStr))); + + if (path.isEmpty()) { + return; + } + + MantidQt::API::AlgorithmInputHistory::Instance().setPreviousDirectory(path); + m_uiTabFocus.lineEdit_texture_grouping_file->setText(path); +} + +std::vector<std::string> EnggDiffractionViewQtGUI::focusingRunNo() const { + return qListToVector(m_uiTabFocus.MWRunFiles_run_num->getFilenames(), + m_uiTabFocus.MWRunFiles_run_num->isValid()); +} + +std::vector<std::string> +EnggDiffractionViewQtGUI::focusingCroppedRunNo() const { + return qListToVector(m_uiTabFocus.MWRunFiles_cropped_run_num->getFilenames(), + m_uiTabFocus.MWRunFiles_cropped_run_num->isValid()); +} + +std::vector<std::string> +EnggDiffractionViewQtGUI::focusingTextureRunNo() const { + return qListToVector(m_uiTabFocus.MWRunFiles_texture_run_num->getFilenames(), + m_uiTabFocus.MWRunFiles_texture_run_num->isValid()); +} + +std::vector<std::string> +EnggDiffractionViewQtGUI::qListToVector(const QStringList &list, + bool validator) const { + std::vector<std::string> vec; + if (validator) { + foreach (const QString &str, list) { vec.emplace_back(str.toStdString()); } + } + + return vec; +} + +std::vector<bool> EnggDiffractionViewQtGUI::focusingBanks() const { + std::vector<bool> res; + res.emplace_back(m_uiTabFocus.checkBox_focus_bank1->isChecked()); + res.emplace_back(m_uiTabFocus.checkBox_focus_bank2->isChecked()); + return res; +} + +std::string EnggDiffractionViewQtGUI::focusingCroppedSpectrumNos() const { + return m_uiTabFocus.lineEdit_cropped_spec_nos->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::focusingTextureGroupingFile() const { + return m_uiTabFocus.lineEdit_texture_grouping_file->text().toStdString(); +} + +bool EnggDiffractionViewQtGUI::focusedOutWorkspace() const { + return m_uiTabFocus.checkBox_plot_focused_ws->checkState(); +} + +bool EnggDiffractionViewQtGUI::plotCalibWorkspace() const { + return m_uiTabCalib.checkBox_PlotData_Calib->checkState(); +} + +bool EnggDiffractionViewQtGUI::saveFocusedOutputFiles() const { + return m_uiTabFocus.checkBox_save_output_files->checkState(); +} + +void MantidQt::CustomInterfaces::EnggDiffractionViewQtGUI::showInvalidRBNumber( + const bool rbNumberIsValid) { + m_ui.label_invalidRBNumber->setVisible(!rbNumberIsValid); +} + +void EnggDiffractionViewQtGUI::plotFocusStatus() { + if (focusedOutWorkspace()) { + m_uiTabFocus.comboBox_PlotData->setEnabled(true); + } else { + m_uiTabFocus.comboBox_PlotData->setEnabled(false); + } +} + +void EnggDiffractionViewQtGUI::calibspecNoChanged(int /*idx*/) { + QComboBox *BankName = m_uiTabCalib.comboBox_calib_cropped_bank_name; + if (!BankName) + return; + g_currentCropCalibBankName = BankName->currentIndex(); +} + +void EnggDiffractionViewQtGUI::enableSpecNos() { + if (g_currentCropCalibBankName == 0) { + m_uiTabCalib.lineEdit_cropped_spec_nos->setEnabled(true); + m_uiTabCalib.lineEdit_cropped_customise_bank_name->setEnabled(true); + } else { + m_uiTabCalib.lineEdit_cropped_spec_nos->setDisabled(true); + m_uiTabCalib.lineEdit_cropped_customise_bank_name->setDisabled(true); + } +} + +std::string EnggDiffractionViewQtGUI::currentCalibSpecNos() const { + return m_uiTabCalib.lineEdit_cropped_spec_nos->text().toStdString(); +} + +std::string EnggDiffractionViewQtGUI::currentCalibCustomisedBankName() const { + return m_uiTabCalib.lineEdit_cropped_customise_bank_name->text() + .toStdString(); +} + +void EnggDiffractionViewQtGUI::multiRunModeChanged(int /*idx*/) { + QComboBox *plotType = m_uiTabFocus.comboBox_Multi_Runs; + if (!plotType) + return; + g_currentRunMode = plotType->currentIndex(); +} + +void EnggDiffractionViewQtGUI::plotRepChanged(int /*idx*/) { + QComboBox *plotType = m_uiTabFocus.comboBox_PlotData; + if (!plotType) + return; + g_currentType = plotType->currentIndex(); +} + +void EnggDiffractionViewQtGUI::instrumentChanged(int /*idx*/) { + QComboBox *inst = m_ui.comboBox_instrument; + if (!inst) + return; + m_currentInst = inst->currentText().toStdString(); + m_presenter->notify(IEnggDiffractionPresenter::InstrumentChange); +} + +void EnggDiffractionViewQtGUI::RBNumberChanged() { + m_presenter->notify(IEnggDiffractionPresenter::RBNumberChange); +} + +void EnggDiffractionViewQtGUI::userSelectInstrument(const QString &prefix) { + // Set file browsing to current instrument + setPrefix(prefix.toStdString()); +} + +void EnggDiffractionViewQtGUI::setPrefix(const std::string &prefix) { + QString prefixInput = QString::fromStdString(prefix); + // focus tab + m_uiTabFocus.MWRunFiles_run_num->setInstrumentOverride(prefixInput); + m_uiTabFocus.MWRunFiles_texture_run_num->setInstrumentOverride(prefixInput); + + // calibration tab + m_uiTabCalib.MWRunFiles_new_ceria_num->setInstrumentOverride(prefixInput); + m_uiTabCalib.MWRunFiles_new_vanadium_num->setInstrumentOverride(prefixInput); + + // rebin tab + m_uiTabPreproc.MWRunFiles_preproc_run_num->setInstrumentOverride(prefixInput); +} + +void EnggDiffractionViewQtGUI::showEvent(QShowEvent * /*unused*/) { + // make sure that the RB number is checked on interface startup/show + m_presenter->notify(IEnggDiffractionPresenter::RBNumberChange); +} + +void EnggDiffractionViewQtGUI::closeEvent(QCloseEvent *event) { + int answer = QMessageBox::AcceptRole; + + QMessageBox msgBox; + if (false /* TODO: get this from user settings if eventually used */) { + msgBox.setWindowTitle("Close the engineering diffraction interface"); + // with something like this, we'd have layout issues: + // msgBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes); + // msgBox.setDefaultButton(QMessageBox::Yes); + msgBox.setIconPixmap(QPixmap(":/win/unknown.png")); + QCheckBox confirmCheckBox("Always ask for confirmation", &msgBox); + confirmCheckBox.setCheckState(Qt::Checked); + msgBox.layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding)); + msgBox.layout()->addWidget(&confirmCheckBox); + QPushButton *bYes = msgBox.addButton("Yes", QMessageBox::YesRole); + bYes->setIcon(style()->standardIcon(QStyle::SP_DialogYesButton)); + QPushButton *bNo = msgBox.addButton("No", QMessageBox::NoRole); + bNo->setIcon(style()->standardIcon(QStyle::SP_DialogNoButton)); + msgBox.setDefaultButton(bNo); + msgBox.setText("You are about to close this interface"); + msgBox.setInformativeText("Are you sure?"); + answer = msgBox.exec(); + } + + if (answer == QMessageBox::AcceptRole && m_ui.pushButton_close->isEnabled()) { + m_presenter->notify(IEnggDiffractionPresenter::ShutDown); + delete m_splashMsg; + m_splashMsg = nullptr; + event->accept(); + } else { + event->ignore(); + } +} + +void EnggDiffractionViewQtGUI::openHelpWin() { + MantidQt::API::HelpWindow::showCustomInterface( + nullptr, QString("Engineering Diffraction")); +} + +void EnggDiffractionViewQtGUI::updateTabsInstrument( + const std::string &newInstrument) { + m_fittingWidget->setCurrentInstrument(newInstrument); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h new file mode 100644 index 0000000000000000000000000000000000000000..a189152fb8d09a1dfb960508d5a0449b8a69a7ce --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffractionViewQtGUI.h @@ -0,0 +1,301 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2015 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffFittingViewQtWidget.h" +#include "EnggDiffGSASFittingViewQtWidget.h" +#include "IEnggDiffractionPresenter.h" +#include "IEnggDiffractionView.h" +#include "MantidAPI/IPeakFunction.h" +#include "MantidQtWidgets/Common/UserSubWindow.h" +#include "MantidQtWidgets/Plotting/Qwt/PeakPicker.h" + +#include "ui_EnggDiffractionQtGUI.h" +#include "ui_EnggDiffractionQtTabCalib.h" +#include "ui_EnggDiffractionQtTabFocus.h" +#include "ui_EnggDiffractionQtTabPreproc.h" +#include "ui_EnggDiffractionQtTabSettings.h" + +// Qt classes forward declarations +class QMessageBox; +class QMutex; + +class QwtPlotCurve; +class QwtPlotZoomer; + +namespace MantidQt { +namespace CustomInterfaces { + +/** +Qt-based view of the Engineering Diffraction (EnggDiffraction) +GUI. Provides a concrete view for the graphical interface for Engg +functionality in Mantid. This view is Qt-based and it is probably the +only one that will be implemented in a foreseeable horizon. The +interface of this class is given by IEnggDiffractionView so that it +fits in the MVP (Model-View-Presenter) design of this GUI. +*/ +class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffractionViewQtGUI + : public MantidQt::API::UserSubWindow, + public IEnggDiffractionView { + Q_OBJECT + +public: + /// Default Constructor + EnggDiffractionViewQtGUI(QWidget *parent = nullptr); + /// Interface name + static std::string name() { return "Engineering Diffraction (Old)"; } + /// This interface's categories. + static QString categoryInfo() { return "Diffraction"; } + + void splashMessage(bool visible, const std::string &shortMsg, + const std::string &description) override; + + void showStatus(const std::string &sts) override; + + void userWarning(const std::string &warn, + const std::string &description) override; + + void userError(const std::string &err, + const std::string &description) override; + + std::string + askNewCalibrationFilename(const std::string &suggestedFname) override; + + std::string askExistingCalibFilename() override; + + std::vector<std::string> logMsgs() const override { return m_logMsgs; } + + std::string getRBNumber() const override; + + EnggDiffCalibSettings currentCalibSettings() const override { + return m_calibSettings; + } + + std::string currentInstrument() const override { return m_currentInst; } + + std::string currentVanadiumNo() const override; + + std::string currentCeriaNo() const override; + + std::string currentCalibFile() const override; + + std::vector<std::string> newVanadiumNo() const override; + + std::vector<std::string> newCeriaNo() const override; + + int currentCropCalibBankName() const override { + return g_currentCropCalibBankName; + } + + std::string currentCalibSpecNos() const override; + + std::string currentCalibCustomisedBankName() const override; + + void newCalibLoaded(const std::string &vanadiumNo, const std::string &ceriaNo, + const std::string &fname) override; + + std::string enggRunPythonCode(const std::string &pyCode) override; + + void enableTabs(bool enable) override; + + void enableCalibrateFocusFitUserActions(bool enable) override; + + std::vector<std::string> focusingRunNo() const override; + + std::vector<std::string> focusingCroppedRunNo() const override; + + std::vector<std::string> focusingTextureRunNo() const override; + + std::vector<bool> focusingBanks() const override; + + std::string focusingCroppedSpectrumNos() const override; + + std::string focusingTextureGroupingFile() const override; + + bool focusedOutWorkspace() const override; + + bool plotCalibWorkspace() const override; + + void resetFocus() override; + + std::vector<std::string> currentPreprocRunNo() const override; + + double rebinningTimeBin() const override; + + size_t rebinningPulsesNumberPeriods() const override; + + double rebinningPulsesTime() const override; + + void plotFocusedSpectrum(const std::string &wsName) override; + + void plotWaterfallSpectrum(const std::string &wsName) override; + + void plotReplacingWindow(const std::string &wsName, + const std::string &spectrum, + const std::string &type) override; + + void plotCalibOutput(const std::string &pyCode) override; + + bool saveFocusedOutputFiles() const override; + + void showInvalidRBNumber(const bool rbNumberIsValid) override; + + int currentPlotType() const override { return g_currentType; } + + int currentMultiRunMode() const override { return g_currentRunMode; } + + void updateTabsInstrument(const std::string &newInstrument) override; + +signals: + void getBanks(); + void setBank(); + +private slots: + /// for buttons, do calibrate, focus, event->histo rebin, and similar + void loadCalibrationClicked(); + void calibrateClicked(); + void CroppedCalibrateClicked(); + void focusClicked(); + void focusCroppedClicked(); + void focusTextureClicked(); + void focusStopClicked(); + void rebinTimeClicked(); + void rebinMultiperiodClicked(); + + // slots of the settings tab/section of the interface + void browseInputDirCalib(); + void browseInputDirRaw(); + void browsePixelCalibFilename(); + void browseTemplateGSAS_PRM(); + void forceRecalculateStateChanged(); + + // slots for the focusing options + void browseTextureDetGroupingFile(); + void focusResetClicked(); + + // slots of the calibration tab/section of the interface + + // slots of the general part of the interface + void instrumentChanged(int idx); + + void RBNumberChanged(); + + // slot of the cropped calibration part of the interface + void calibspecNoChanged(int idx); + + // slots of the focus part of the interface + void plotRepChanged(int idx); + + // slot of the multi-run mode for focus + void multiRunModeChanged(int idx); + + // slots of plot spectrum check box status + void plotFocusStatus(); + + // enables the text field when appropriate bank name is selected + void enableSpecNos(); + + // show the standard Mantid help window with this interface's help + void openHelpWin(); + +private: + /// Setup the interface (tab UI) + void initLayout() override; + void doSetupGeneralWidgets(); + void doSetupSplashMsg(); + void doSetupTabCalib(); + void doSetupTabFocus(); + void doSetupTabPreproc(); + void doSetupTabSettings(); + + std::string guessGSASTemplatePath() const; + std::string guessDefaultFullCalibrationPath() const; + + /// Load default interface settings for each tab, normally on startup + void readSettings(); + /// save settings (before closing) + void saveSettings() const override; + + // when the interface is shown + void showEvent(QShowEvent * /*unused*/) override; + + // window (custom interface) close + void closeEvent(QCloseEvent *ev) override; + + // path/name for the persistent settings group of this interface + const static std::string g_settingsGroup; + + // here the view puts messages before notifying the presenter to show them + std::vector<std::string> m_logMsgs; + + /// Interface definition with widgets for the main interface window + Ui::EnggDiffractionQtGUI m_ui; + // And its sections/tabs. Note that for compactness they're called simply + // 'tabs' + // but they could be separate dialogs, widgets, etc. + Ui::EnggDiffractionQtTabCalib m_uiTabCalib; + Ui::EnggDiffractionQtTabFocus m_uiTabFocus; + Ui::EnggDiffractionQtTabPreproc m_uiTabPreproc; + // Ui::EnggDiffractionQtTabFitting m_uiTabFitting; + EnggDiffFittingViewQtWidget *m_fittingWidget; + EnggDiffGSASFittingViewQtWidget *m_gsasWidget; + Ui::EnggDiffractionQtTabSettings m_uiTabSettings; + + /// converts QList to a vector + std::vector<std::string> qListToVector(const QStringList &list, + bool validator) const; + + /// instrument selected (ENGIN-X, etc.) + std::string m_currentInst; + + /// User select instrument + void userSelectInstrument(const QString &prefix); + + /// setting the instrument prefix ahead of the run number + void setPrefix(const std::string &prefix); + + // TODO: The values of these three next static members (bank name, + // type, run mode) can be obtained from widgets when requested/required. They + // shouldn't need to be cached in data members. Remove them. + + // current bank number used for cropped calibration + int static g_currentCropCalibBankName; + + // plot data representation type selected + int static g_currentType; + + // multi-run focus mode type selected + int static g_currentRunMode; + + /// calibration settings - from/to the 'settings' tab + EnggDiffCalibSettings m_calibSettings; + + /// To show important non-modal messages + QMessageBox *m_splashMsg; + + /// This is in principle the only settings for 'focus' + std::string m_focusDir; + + /// for the 'Rebin' parameter of some Engg* algorithms + static const double g_defaultRebinWidth; + + /// supported file extensions string for IPARM files (for the open + /// file dialogs) + static const std::string g_iparmExtStr; + /// supported file extensions string for the pixel (full) claibration + static const std::string g_pixelCalibExt; + /// supported/suggested file extensions for the detector groups file + /// (focusing) + static const std::string g_DetGrpExtStr; + + /// presenter as in the model-view-presenter + boost::shared_ptr<IEnggDiffractionPresenter> m_presenter; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4a853ba26050276c93b2361c80b5cfa3fd50c3fb --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.cpp @@ -0,0 +1,196 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "EnggVanadiumCorrectionsModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/MatrixWorkspace.h" + +#include <Poco/File.h> +#include <Poco/Path.h> + +namespace MantidQt { +namespace CustomInterfaces { + +EnggVanadiumCorrectionsModel::EnggVanadiumCorrectionsModel( + const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument) + : m_calibSettings(calibSettings), m_currentInstrument(currentInstrument) {} + +const std::string EnggVanadiumCorrectionsModel::CURVES_WORKSPACE_NAME = + "engggui_vanadium_curves"; + +const std::string EnggVanadiumCorrectionsModel::INTEGRATED_WORKSPACE_NAME = + "engggui_vanadium_integration"; + +const std::string EnggVanadiumCorrectionsModel::VANADIUM_INPUT_WORKSPACE_NAME = + "engggui_vanadium_ws"; + +std::pair<Mantid::API::ITableWorkspace_sptr, Mantid::API::MatrixWorkspace_sptr> +EnggVanadiumCorrectionsModel::calculateCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const { + const auto vanadiumWS = + loadMatrixWorkspace(vanadiumRunNumber, VANADIUM_INPUT_WORKSPACE_NAME); + + auto enggVanadiumCorrections = + Mantid::API::AlgorithmManager::Instance().create( + "EnggVanadiumCorrections"); + enggVanadiumCorrections->initialize(); + enggVanadiumCorrections->setPropertyValue("VanadiumWorkspace", + VANADIUM_INPUT_WORKSPACE_NAME); + enggVanadiumCorrections->setPropertyValue("OutIntegrationWorkspace", + INTEGRATED_WORKSPACE_NAME); + enggVanadiumCorrections->setPropertyValue("OutCurvesWorkspace", + CURVES_WORKSPACE_NAME); + enggVanadiumCorrections->execute(); + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + + ADS.remove(VANADIUM_INPUT_WORKSPACE_NAME); + const auto integratedWorkspace = + ADS.retrieveWS<Mantid::API::ITableWorkspace>(INTEGRATED_WORKSPACE_NAME); + const auto curvesWorkspace = + ADS.retrieveWS<Mantid::API::MatrixWorkspace>(CURVES_WORKSPACE_NAME); + return std::make_pair(integratedWorkspace, curvesWorkspace); +} + +std::pair<Mantid::API::ITableWorkspace_sptr, Mantid::API::MatrixWorkspace_sptr> +EnggVanadiumCorrectionsModel::fetchCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const { + const auto cachedCurvesWorkspace = + fetchCachedCurvesWorkspace(vanadiumRunNumber); + const auto cachedIntegratedWorkspace = + fetchCachedIntegratedWorkspace(vanadiumRunNumber); + + if (cachedCurvesWorkspace && cachedIntegratedWorkspace && + !m_calibSettings.m_forceRecalcOverwrite) { + return std::make_pair(cachedIntegratedWorkspace, cachedCurvesWorkspace); + } else { + const auto correctionWorkspaces = + calculateCorrectionWorkspaces(vanadiumRunNumber); + saveCorrectionsToCache(vanadiumRunNumber, correctionWorkspaces.second, + correctionWorkspaces.first); + return correctionWorkspaces; + } +} + +Mantid::API::MatrixWorkspace_sptr +EnggVanadiumCorrectionsModel::fetchCachedCurvesWorkspace( + const std::string &vanadiumRunNumber) const { + const auto filename = generateCurvesFilename(vanadiumRunNumber); + const Poco::File inputFile(filename); + if (inputFile.exists()) { + return loadMatrixWorkspace(filename, CURVES_WORKSPACE_NAME); + } + + return nullptr; +} + +Mantid::API::ITableWorkspace_sptr +EnggVanadiumCorrectionsModel::fetchCachedIntegratedWorkspace( + const std::string &vanadiumRunNumber) const { + const auto filename = generateIntegratedFilename(vanadiumRunNumber); + const Poco::File inputFile(filename); + if (inputFile.exists()) { + return loadTableWorkspace(filename, INTEGRATED_WORKSPACE_NAME); + } + + return nullptr; +} + +std::string EnggVanadiumCorrectionsModel::generateCurvesFilename( + const std::string &vanadiumRunNumber) const { + const static std::string filenameSuffix = + "_precalculated_vanadium_run_bank_curves.nxs"; + + const auto normalisedRunName = Poco::Path(vanadiumRunNumber).getBaseName(); + const auto curvesFilename = normalisedRunName + filenameSuffix; + + Poco::Path inputDir(m_calibSettings.m_inputDirCalib); + inputDir.append(curvesFilename); + return inputDir.toString(); +} + +std::string EnggVanadiumCorrectionsModel::generateIntegratedFilename( + const std::string &vanadiumRunNumber) const { + const static std::string filenameSuffix = + "_precalculated_vanadium_run_integration.nxs"; + + const auto normalisedRunName = Poco::Path(vanadiumRunNumber).getBaseName(); + const auto integratedFilename = normalisedRunName + filenameSuffix; + + Poco::Path inputDir(m_calibSettings.m_inputDirCalib); + inputDir.append(integratedFilename); + return inputDir.toString(); +} + +std::string EnggVanadiumCorrectionsModel::generateVanadiumRunName( + const std::string &vanadiumRunNumber) const { + constexpr static size_t normalisedRunNumberLength = 8; + return m_currentInstrument + + std::string(normalisedRunNumberLength - vanadiumRunNumber.length(), + '0') + + vanadiumRunNumber; +} + +Mantid::API::MatrixWorkspace_sptr +EnggVanadiumCorrectionsModel::loadMatrixWorkspace( + const std::string &filename, const std::string &workspaceName) const { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", filename); + load->setPropertyValue("OutputWorkspace", workspaceName); + load->execute(); + return Mantid::API::AnalysisDataService::Instance() + .retrieveWS<Mantid::API::MatrixWorkspace>(workspaceName); +} + +Mantid::API::ITableWorkspace_sptr +EnggVanadiumCorrectionsModel::loadTableWorkspace( + const std::string &filename, const std::string &workspaceName) const { + auto load = Mantid::API::AlgorithmManager::Instance().create("Load"); + load->initialize(); + load->setPropertyValue("Filename", filename); + load->setPropertyValue("OutputWorkspace", workspaceName); + load->execute(); + return Mantid::API::AnalysisDataService::Instance() + .retrieveWS<Mantid::API::ITableWorkspace>(workspaceName); +} + +void EnggVanadiumCorrectionsModel::saveCorrectionsToCache( + const std::string &runNumber, + const Mantid::API::MatrixWorkspace_sptr &curvesWorkspace, + const Mantid::API::ITableWorkspace_sptr &integratedWorkspace) const { + const auto curvesFilename = generateCurvesFilename(runNumber); + saveNexus(curvesFilename, curvesWorkspace); + + const auto integratedFilename = generateIntegratedFilename(runNumber); + saveNexus(integratedFilename, integratedWorkspace); +} + +void EnggVanadiumCorrectionsModel::saveNexus( + const std::string &filename, + const Mantid::API::Workspace_sptr &workspace) const { + auto save = Mantid::API::AlgorithmManager::Instance().create("SaveNexus"); + save->initialize(); + save->setProperty("InputWorkspace", workspace); + save->setProperty("Filename", filename); + save->execute(); +} + +void EnggVanadiumCorrectionsModel::setCalibSettings( + const EnggDiffCalibSettings &calibSettings) { + m_calibSettings = calibSettings; +} + +void EnggVanadiumCorrectionsModel::setCurrentInstrument( + const std::string ¤tInstrument) { + m_currentInstrument = currentInstrument; +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.h b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.h new file mode 100644 index 0000000000000000000000000000000000000000..e448801a74efcdc84dd7921e4c9b69c994163461 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggVanadiumCorrectionsModel.h @@ -0,0 +1,83 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "IEnggVanadiumCorrectionsModel.h" + +#include <Poco/Path.h> +#include <boost/optional.hpp> + +namespace MantidQt { +namespace CustomInterfaces { + +class MANTIDQT_ENGGDIFFRACTION_DLL EnggVanadiumCorrectionsModel + : public IEnggVanadiumCorrectionsModel { + +public: + EnggVanadiumCorrectionsModel(const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument); + + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + fetchCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const override; + + void setCalibSettings(const EnggDiffCalibSettings &calibSettings) override; + + void setCurrentInstrument(const std::string ¤tInstrument) override; + +protected: + const static std::string CURVES_WORKSPACE_NAME; + + const static std::string INTEGRATED_WORKSPACE_NAME; + +private: + const static std::string VANADIUM_INPUT_WORKSPACE_NAME; + + virtual std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + calculateCorrectionWorkspaces(const std::string &vanadiumRunNumber) const; + + Mantid::API::MatrixWorkspace_sptr + fetchCachedCurvesWorkspace(const std::string &vanadiumRunNumber) const; + + Mantid::API::ITableWorkspace_sptr + fetchCachedIntegratedWorkspace(const std::string &vanadiumRunNumber) const; + + std::string + generateCurvesFilename(const std::string &vanadiumRunNumber) const; + + std::string + generateIntegratedFilename(const std::string &vanadiumRunNumber) const; + + std::string + generateVanadiumRunName(const std::string &vanadiumRunNumber) const; + + Mantid::API::MatrixWorkspace_sptr + loadMatrixWorkspace(const std::string &filename, + const std::string &workspaceName) const; + + Mantid::API::ITableWorkspace_sptr + loadTableWorkspace(const std::string &filename, + const std::string &workspaceName) const; + + void saveCorrectionsToCache( + const std::string &runNumber, + const Mantid::API::MatrixWorkspace_sptr &curvesWorkspace, + const Mantid::API::ITableWorkspace_sptr &integratedWorkspace) const; + + void saveNexus(const std::string &filename, + const Mantid::API::Workspace_sptr &workspace) const; + + EnggDiffCalibSettings m_calibSettings; + + std::string m_currentInstrument; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64bf41193da13485979afaee0cbf5bb156c4159c --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp @@ -0,0 +1,34 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "GSASIIRefineFitPeaksOutputProperties.h" + +namespace MantidQt { +namespace CustomInterfaces { + +GSASIIRefineFitPeaksOutputProperties::GSASIIRefineFitPeaksOutputProperties( + const double _rwp, const double _sigma, const double _gamma, + const Mantid::API::MatrixWorkspace_sptr &_fittedPeaksWS, + const Mantid::API::ITableWorkspace_sptr &_latticeParamsWS, + const RunLabel &_runLabel) + : rwp(_rwp), sigma(_sigma), gamma(_gamma), fittedPeaksWS(_fittedPeaksWS), + latticeParamsWS(_latticeParamsWS), runLabel(_runLabel) {} + +bool operator==(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs) { + return lhs.rwp == rhs.rwp && lhs.sigma == rhs.sigma && + lhs.gamma == rhs.gamma && lhs.fittedPeaksWS == rhs.fittedPeaksWS && + lhs.latticeParamsWS == rhs.latticeParamsWS && + lhs.runLabel == rhs.runLabel; +} + +bool operator!=(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs) { + return !(lhs == rhs); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h new file mode 100644 index 0000000000000000000000000000000000000000..435cf4b170a69710eeccae647d4473ad910bf54b --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h @@ -0,0 +1,49 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "RunLabel.h" + +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/MatrixWorkspace_fwd.h" + +#include <QMetaType> + +namespace MantidQt { +namespace CustomInterfaces { + +struct MANTIDQT_ENGGDIFFRACTION_DLL GSASIIRefineFitPeaksOutputProperties { + GSASIIRefineFitPeaksOutputProperties( + const double _rwp, const double _sigma, const double _gamma, + const Mantid::API::MatrixWorkspace_sptr &_fittedPeaksWS, + const Mantid::API::ITableWorkspace_sptr &_latticeParamsWS, + const RunLabel &_runLabel); + + GSASIIRefineFitPeaksOutputProperties() = default; + + double rwp; + double sigma; + double gamma; + Mantid::API::MatrixWorkspace_sptr fittedPeaksWS; + Mantid::API::ITableWorkspace_sptr latticeParamsWS; + RunLabel runLabel; +}; + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator==(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs); + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator!=(const GSASIIRefineFitPeaksOutputProperties &lhs, + const GSASIIRefineFitPeaksOutputProperties &rhs); + +} // namespace CustomInterfaces +} // namespace MantidQt + +Q_DECLARE_METATYPE( + MantidQt::CustomInterfaces::GSASIIRefineFitPeaksOutputProperties) diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.cpp b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.cpp new file mode 100644 index 0000000000000000000000000000000000000000..370d025fc80a0e2688ce09dc9e96bfda2a84b49a --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.cpp @@ -0,0 +1,47 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#include "GSASIIRefineFitPeaksParameters.h" + +namespace MantidQt { +namespace CustomInterfaces { + +GSASIIRefineFitPeaksParameters::GSASIIRefineFitPeaksParameters( + const Mantid::API::MatrixWorkspace_sptr &_inputWorkspace, + const RunLabel &_runLabel, const GSASRefinementMethod &_refinementMethod, + const std::string &_instParamsFile, + const std::vector<std::string> &_phaseFiles, const std::string &_gsasHome, + const std::string &_gsasProjectFile, const boost::optional<double> &_dMin, + const boost::optional<double> &_negativeWeight, + const boost::optional<double> &_xMin, const boost::optional<double> &_xMax, + const bool _refineSigma, const bool _refineGamma) + : inputWorkspace(_inputWorkspace), runLabel(_runLabel), + refinementMethod(_refinementMethod), instParamsFile(_instParamsFile), + phaseFiles(_phaseFiles), gsasHome(_gsasHome), + gsasProjectFile(_gsasProjectFile), dMin(_dMin), + negativeWeight(_negativeWeight), xMin(_xMin), xMax(_xMax), + refineSigma(_refineSigma), refineGamma(_refineGamma) {} + +bool operator==(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs) { + return lhs.inputWorkspace == rhs.inputWorkspace && + lhs.runLabel == rhs.runLabel && + lhs.refinementMethod == rhs.refinementMethod && + lhs.instParamsFile == rhs.instParamsFile && + lhs.phaseFiles == rhs.phaseFiles && lhs.gsasHome == rhs.gsasHome && + lhs.gsasProjectFile == rhs.gsasProjectFile && lhs.dMin == rhs.dMin && + lhs.negativeWeight == rhs.negativeWeight && lhs.xMin == rhs.xMin && + lhs.xMax == rhs.xMax && lhs.refineSigma == rhs.refineSigma && + lhs.refineGamma == rhs.refineGamma; +} + +bool operator!=(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs) { + return !(lhs == rhs); +} + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.h b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.h new file mode 100644 index 0000000000000000000000000000000000000000..d3ef97805f656d90e5484e6bc245761bfb196c5e --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksParameters.h @@ -0,0 +1,59 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "DllConfig.h" +#include "EnggDiffGSASRefinementMethod.h" +#include "RunLabel.h" + +#include "MantidAPI/MatrixWorkspace.h" + +#include <boost/optional.hpp> +#include <vector> + +namespace MantidQt { +namespace CustomInterfaces { + +struct MANTIDQT_ENGGDIFFRACTION_DLL GSASIIRefineFitPeaksParameters { + GSASIIRefineFitPeaksParameters( + const Mantid::API::MatrixWorkspace_sptr &_inputWorkspace, + const RunLabel &_runLabel, const GSASRefinementMethod &_refinementMethod, + const std::string &_instParamsFile, + const std::vector<std::string> &_phaseFiles, const std::string &_gsasHome, + const std::string &_gsasProjectFile, const boost::optional<double> &_dMin, + const boost::optional<double> &_negativeWeight, + const boost::optional<double> &_xMin, + const boost::optional<double> &_xMax, const bool _refineSigma, + const bool _refineGamma); + + const Mantid::API::MatrixWorkspace_sptr inputWorkspace; + const RunLabel runLabel; + const GSASRefinementMethod refinementMethod; + const std::string instParamsFile; + const std::vector<std::string> phaseFiles; + const std::string gsasHome; + const std::string gsasProjectFile; + + const boost::optional<double> dMin; + const boost::optional<double> negativeWeight; + const boost::optional<double> xMin; + const boost::optional<double> xMax; + + const bool refineSigma; + const bool refineGamma; +}; + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator==(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs); + +MANTIDQT_ENGGDIFFRACTION_DLL bool +operator!=(const GSASIIRefineFitPeaksParameters &lhs, + const GSASIIRefineFitPeaksParameters &rhs); + +} // namespace CustomInterfaces +} // namespace MantidQt diff --git a/qt/scientific_interfaces/General/DataComparison.cpp b/qt/scientific_interfaces/General/DataComparison.cpp index b328b1ef313b66bcf8b125e3c0b8b219de310e3e..8eaa1ccad120c82811c93b748f5f124fce7972b9 100644 --- a/qt/scientific_interfaces/General/DataComparison.cpp +++ b/qt/scientific_interfaces/General/DataComparison.cpp @@ -139,7 +139,7 @@ void DataComparison::addData() { * * @param ws Pointer to workspace to add. */ -void DataComparison::addDataItem(Workspace_const_sptr ws) { +void DataComparison::addDataItem(const Workspace_const_sptr &ws) { // Check that the workspace is the correct type MatrixWorkspace_const_sptr matrixWs = boost::dynamic_pointer_cast<const MatrixWorkspace>(ws); @@ -212,7 +212,7 @@ void DataComparison::addDataItem(Workspace_const_sptr ws) { * * @param ws Pointer to the workspace */ -bool DataComparison::containsWorkspace(MatrixWorkspace_const_sptr ws) { +bool DataComparison::containsWorkspace(const MatrixWorkspace_const_sptr &ws) { QString testWsName = QString::fromStdString(ws->getName()); int numRows = m_uiForm.twCurrentData->rowCount(); diff --git a/qt/scientific_interfaces/General/DataComparison.h b/qt/scientific_interfaces/General/DataComparison.h index 8e40d12b61afe3894463ffd61e3825ff7044db93..b7893dae28cfa8ee97cdc03edc9ed5d1365a60bd 100644 --- a/qt/scientific_interfaces/General/DataComparison.h +++ b/qt/scientific_interfaces/General/DataComparison.h @@ -37,7 +37,7 @@ public: explicit DataComparison(QWidget *parent = nullptr); /// Tests if a workspace is shown in the UI - bool containsWorkspace(Mantid::API::MatrixWorkspace_const_sptr ws); + bool containsWorkspace(const Mantid::API::MatrixWorkspace_const_sptr &ws); private slots: /// Add selected data to plot @@ -72,7 +72,7 @@ private: /// Initialize the layout void initLayout() override; /// Adds a workspace to the data table - void addDataItem(Mantid::API::Workspace_const_sptr ws); + void addDataItem(const Mantid::API::Workspace_const_sptr &ws); /// Normalises spectra offsets in table void normaliseSpectraOffsets(); /// Gets an initial curve colour for a new workspace diff --git a/qt/scientific_interfaces/General/MantidEV.cpp b/qt/scientific_interfaces/General/MantidEV.cpp index fe65cb689995791917969c12919b7f0cc414bfa0..88506b13206bc0b60fa46baf06d965e867846dcf 100644 --- a/qt/scientific_interfaces/General/MantidEV.cpp +++ b/qt/scientific_interfaces/General/MantidEV.cpp @@ -1833,7 +1833,7 @@ void MantidEV::errorMessage(const std::string &message) { * * @return true if a double was extacted from the string. */ -bool MantidEV::getDouble(std::string str, double &value) { +bool MantidEV::getDouble(const std::string &str, double &value) { std::istringstream strs(str); if (strs >> value) { return true; @@ -2260,7 +2260,7 @@ void MantidEV::loadSettings(const std::string &filename) { * @param ledt pointer to the QLineEdit component whose state * is to be restored. */ -void MantidEV::restore(QSettings *state, QString name, QLineEdit *ledt) { +void MantidEV::restore(QSettings *state, const QString &name, QLineEdit *ledt) { // NOTE: If state was not saved yet, we don't want to change the // default value, so we only change the text if it's non-empty QString sText = state->value(name, "").toString(); @@ -2278,7 +2278,8 @@ void MantidEV::restore(QSettings *state, QString name, QLineEdit *ledt) { * @param btn pointer to the QCheckbox or QRadioButton component * whose state is to be restored. */ -void MantidEV::restore(QSettings *state, QString name, QAbstractButton *btn) { +void MantidEV::restore(QSettings *state, const QString &name, + QAbstractButton *btn) { btn->setChecked(state->value(name, false).toBool()); } @@ -2290,7 +2291,7 @@ void MantidEV::restore(QSettings *state, QString name, QAbstractButton *btn) { * @param cmbx pointer to the QComboBox component whose state is * to be restored. */ -void MantidEV::restore(QSettings *state, QString name, QComboBox *cmbx) { +void MantidEV::restore(QSettings *state, const QString &name, QComboBox *cmbx) { // NOTE: If state was not saved yet, we don't want to change the // default value, so we only change the selected item if the index // has been set to a valid value. diff --git a/qt/scientific_interfaces/General/MantidEV.h b/qt/scientific_interfaces/General/MantidEV.h index 5818a94f5f11043ba14e08ade84a7558644321d3..ca678fdcb1141f4cc26ed4f7ce95e0cae2cd17cd 100644 --- a/qt/scientific_interfaces/General/MantidEV.h +++ b/qt/scientific_interfaces/General/MantidEV.h @@ -363,7 +363,7 @@ private: void errorMessage(const std::string &message); /// Utility method to parse a double value in a string - bool getDouble(std::string str, double &value); + bool getDouble(const std::string &str, double &value); /// Utility method to get a double value from a QtLineEdit widget bool getDouble(QLineEdit *ledt, double &value); @@ -393,13 +393,13 @@ private: void loadSettings(const std::string &filename); /// Restore the value of the QLineEdit component from QSettings - void restore(QSettings *state, QString name, QLineEdit *ledt); + void restore(QSettings *state, const QString &name, QLineEdit *ledt); /// Restore the value of the QCheckbox or QRadioButton from QSettings - void restore(QSettings *state, QString name, QAbstractButton *btn); + void restore(QSettings *state, const QString &name, QAbstractButton *btn); /// Restore the value of a QComboBox from QSettings - void restore(QSettings *state, QString name, QComboBox *cmbx); + void restore(QSettings *state, const QString &name, QComboBox *cmbx); Ui::MantidEV m_uiForm; /// The form generated by Qt Designer diff --git a/qt/scientific_interfaces/General/StepScan.cpp b/qt/scientific_interfaces/General/StepScan.cpp index 0af5bf2a9fa92195ea58e0a16ecd27104e389a9a..0731b28502048f2c0d067e38e9dcde51086ffedd 100644 --- a/qt/scientific_interfaces/General/StepScan.cpp +++ b/qt/scientific_interfaces/General/StepScan.cpp @@ -248,7 +248,8 @@ void StepScan::loadFileComplete(bool error) { namespace { class ScopedStatusText { public: - ScopedStatusText(QLabel *label, QString labelText) : status_label(label) { + ScopedStatusText(QLabel *label, const QString &labelText) + : status_label(label) { status_label->setText("<i><font color='darkblue'>" + labelText + "</font></i>"); } @@ -549,7 +550,7 @@ void StepScan::runStepScanAlg() { generateCurve(m_uiForm.plotVariable->currentText()); } -bool StepScan::runStepScanAlgLive(std::string stepScanProperties) { +bool StepScan::runStepScanAlgLive(const std::string &stepScanProperties) { // First stop the currently running live algorithm IAlgorithm_const_sptr oldMonitorLiveData = m_uiForm.mWRunFiles->stopLiveAlgorithm(); diff --git a/qt/scientific_interfaces/General/StepScan.h b/qt/scientific_interfaces/General/StepScan.h index 5e713baae37ae4ee41369407d7b2899a12ad4246..b44c224b5af56630fed50c1d7d1d9f7a4ddff31d 100644 --- a/qt/scientific_interfaces/General/StepScan.h +++ b/qt/scientific_interfaces/General/StepScan.h @@ -45,7 +45,7 @@ private slots: void expandPlotVarCombobox(const Mantid::API::MatrixWorkspace_const_sptr &ws); void fillNormalizationCombobox(); void runStepScanAlg(); - bool runStepScanAlgLive(std::string stepScanProperties); + bool runStepScanAlgLive(const std::string &stepScanProperties); void updateForNormalizationChange(); void generateCurve(const QString &var); diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp index 998b086eaac86631655fefa30dbed7c9980802d7..ef4d6a8ac6c7850e9aa74167cfb1a1708ca55b53 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.cpp @@ -10,7 +10,7 @@ namespace CustomInterfaces { namespace ISISReflectometry { std::vector<std::string> InstrumentParameter<std::string>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getStringParameter(parameterName); @@ -20,7 +20,7 @@ std::vector<std::string> InstrumentParameter<std::string>::get( } std::vector<int> InstrumentParameter<int>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getIntParameter(parameterName); @@ -30,7 +30,7 @@ std::vector<int> InstrumentParameter<int>::get( } std::vector<bool> InstrumentParameter<bool>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getBoolParameter(parameterName); @@ -40,7 +40,7 @@ std::vector<bool> InstrumentParameter<bool>::get( } std::vector<double> InstrumentParameter<double>::get( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return instrument->getNumberParameter(parameterName); diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h index dc31f2ea2dab45c1cb58360a2f6041edb73bd013..d10c16bc5b2d105de141f88dbfe62c7dc7f6c563 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h +++ b/qt/scientific_interfaces/ISISReflectometry/Common/GetInstrumentParameter.h @@ -17,28 +17,28 @@ template <typename T> class InstrumentParameter; template <> class InstrumentParameter<std::string> { public: static std::vector<std::string> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; template <> class InstrumentParameter<double> { public: static std::vector<double> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; template <> class InstrumentParameter<int> { public: static std::vector<int> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; template <> class InstrumentParameter<bool> { public: static std::vector<bool> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName); }; @@ -73,7 +73,7 @@ template <typename T1, typename T2> class InstrumentParameter<boost::variant<T1, T2>> { public: static boost::variant<std::vector<T1>, std::vector<T2>> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return InstrumentParameter<T1>::get(instrument, parameterName); @@ -106,7 +106,7 @@ class InstrumentParameter<boost::variant<T1, T2, T3, Ts...>> { public: static boost::variant<std::vector<T1>, std::vector<T2>, std::vector<T3>, std::vector<Ts>...> - get(Mantid::Geometry::Instrument_const_sptr instrument, + get(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const ¶meterName) { try { return InstrumentParameter<T1>::get(instrument, parameterName); @@ -124,8 +124,9 @@ public: }; template <typename T> -auto getInstrumentParameter(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const ¶meterName) +auto getInstrumentParameter( + const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const ¶meterName) -> decltype(InstrumentParameter<T>::get( std::declval<Mantid::Geometry::Instrument_const_sptr>(), std::declval<std::string const &>())) { diff --git a/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp index f75d7957cf110676a096611b7a7eaa63f1215457..7e06d2d8a2347b1ad888b47845b54d9cf3f64a95 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Common/OptionDefaults.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "OptionDefaults.h" + +#include <utility> + #include "MantidAPI/AlgorithmManager.h" namespace MantidQt { @@ -13,7 +16,7 @@ namespace ISISReflectometry { OptionDefaults::OptionDefaults( Mantid::Geometry::Instrument_const_sptr instrument) - : m_instrument(instrument) { + : m_instrument(std::move(instrument)) { // Get the algorithm for which we'll take defaults if available m_algorithm = Mantid::API::AlgorithmManager::Instance().createUnmanaged( "ReflectometryReductionOneAuto"); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp index c83da7f41013b74e406b9a51f3162db97ce9aaab..c4376c478c3d1ac55281e5c82acdd176be46dbe1 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.cpp @@ -65,7 +65,7 @@ void updateFromMap(AlgorithmRuntimeProps &properties, update(kvp.first, kvp.second, properties); } } -std::string getOutputWorkspace(IAlgorithm_sptr algorithm, +std::string getOutputWorkspace(const IAlgorithm_sptr &algorithm, std::string const &property) { auto const workspaceName = algorithm->getPropertyValue(property); return workspaceName; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h index 4761c175603231d1cd54e7d015e4304806776b5b..5ed98adf3a780fe13b049a5c74eb0cfd09ba3d62 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/AlgorithmProperties.h @@ -47,7 +47,7 @@ void update(std::string const &property, boost::optional<double> const &value, void updateFromMap(AlgorithmRuntimeProps &properties, std::map<std::string, std::string> const ¶meterMap); -std::string getOutputWorkspace(Mantid::API::IAlgorithm_sptr algorithm, +std::string getOutputWorkspace(const Mantid::API::IAlgorithm_sptr &algorithm, std::string const &property); template <typename VALUE_TYPE> diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp index fe526791206f60ffd463b634a7ff09d9c743224c..8e2a949474d2ab67ce49aacbb32770352ea74079 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "BatchJobAlgorithm.h" + +#include <utility> + #include "MantidAPI/IAlgorithm.h" namespace MantidQt { @@ -18,8 +21,8 @@ BatchJobAlgorithm::BatchJobAlgorithm( Mantid::API::IAlgorithm_sptr algorithm, MantidQt::API::ConfiguredAlgorithm::AlgorithmRuntimeProps properties, UpdateFunction updateFunction, Item *item) - : ConfiguredAlgorithm(algorithm, properties), m_item(item), - m_updateFunction(updateFunction) {} + : ConfiguredAlgorithm(std::move(algorithm), std::move(properties)), + m_item(item), m_updateFunction(updateFunction) {} Item *BatchJobAlgorithm::item() { return m_item; } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h index dc9aaff17ea5bef89723de8b4b742a7462d900bc..4799ae993fda8fcb122ed2a8d14ea244904572d4 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/BatchJobAlgorithm.h @@ -23,7 +23,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL BatchJobAlgorithm : public IBatchJobAlgorithm, public MantidQt::API::ConfiguredAlgorithm { public: - using UpdateFunction = void (*)(Mantid::API::IAlgorithm_sptr algorithm, + using UpdateFunction = void (*)(const Mantid::API::IAlgorithm_sptr &algorithm, Item &item); BatchJobAlgorithm( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp index 10d4cf321f30b9b77e1226006445c4469097ee5d..168134898f8d225f5b04e1015f48e87499c7995e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/GroupProcessingAlgorithm.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "GroupProcessingAlgorithm.h" + +#include <utility> + #include "../../Reduction/Batch.h" #include "../../Reduction/Group.h" #include "AlgorithmProperties.h" @@ -58,9 +61,10 @@ void updateWorkspaceProperties(AlgorithmRuntimeProps &properties, AlgorithmProperties::update("OutputWorkspace", outputName, properties); } -void updateGroupFromOutputProperties(IAlgorithm_sptr algorithm, Item &group) { - auto const stitched = - AlgorithmProperties::getOutputWorkspace(algorithm, "OutputWorkspace"); +void updateGroupFromOutputProperties(const IAlgorithm_sptr &algorithm, + Item &group) { + auto const stitched = AlgorithmProperties::getOutputWorkspace( + std::move(algorithm), "OutputWorkspace"); group.setOutputNames(std::vector<std::string>{stitched}); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp index cf2ffff5a62cadaf7be4d4de3ab1cf44029673a6..a9c9a13c6e4faa1f07cee87929c0bb43933c849e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.cpp @@ -14,6 +14,7 @@ #include <QMessageBox> #include <QMetaType> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -105,17 +106,17 @@ void QtBatchView::onBatchComplete(bool error) { void QtBatchView::onBatchCancelled() { m_notifyee->notifyBatchCancelled(); } void QtBatchView::onAlgorithmStarted(API::IConfiguredAlgorithm_sptr algorithm) { - m_notifyee->notifyAlgorithmStarted(algorithm); + m_notifyee->notifyAlgorithmStarted(std::move(algorithm)); } void QtBatchView::onAlgorithmComplete( API::IConfiguredAlgorithm_sptr algorithm) { - m_notifyee->notifyAlgorithmComplete(algorithm); + m_notifyee->notifyAlgorithmComplete(std::move(algorithm)); } void QtBatchView::onAlgorithmError(API::IConfiguredAlgorithm_sptr algorithm, - std::string message) { - m_notifyee->notifyAlgorithmError(algorithm, message); + const std::string &message) { + m_notifyee->notifyAlgorithmError(std::move(algorithm), message); } std::unique_ptr<QtRunsView> QtBatchView::createRunsTab() { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h index 9ecf75f901650f85169f6ba0ef50a0e01ff6c440..a97d90a15de5d8d86b08f53ef6b0a468c63aa8d8 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/QtBatchView.h @@ -47,7 +47,7 @@ private slots: void onAlgorithmStarted(MantidQt::API::IConfiguredAlgorithm_sptr algorithm); void onAlgorithmComplete(MantidQt::API::IConfiguredAlgorithm_sptr algorithm); void onAlgorithmError(MantidQt::API::IConfiguredAlgorithm_sptr algorithm, - std::string errorMessage); + const std::string &errorMessage); private: void initLayout(); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp index e02d207771a4c4feb8ce4b4937b6913d218fcea9..ad82098a4f180b18a3004c51b91b6cd705182301 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Batch/RowProcessingAlgorithm.cpp @@ -242,13 +242,14 @@ void updateEventProperties(AlgorithmRuntimeProps &properties, boost::apply_visitor(UpdateEventPropertiesVisitor(properties), slicing); } -boost::optional<double> getDouble(IAlgorithm_sptr algorithm, +boost::optional<double> getDouble(const IAlgorithm_sptr &algorithm, std::string const &property) { double result = algorithm->getProperty(property); return result; } -void updateRowFromOutputProperties(IAlgorithm_sptr algorithm, Item &item) { +void updateRowFromOutputProperties(const IAlgorithm_sptr &algorithm, + Item &item) { auto &row = dynamic_cast<Row &>(item); auto const iVsLam = AlgorithmProperties::getOutputWorkspace( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp index 025d0812238ca6a9a37fc7bda4032baf2c797759..94441e5f3d46806702caf89b449397764ac32d48 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentOptionDefaults.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ExperimentOptionDefaults.h" + +#include <utility> + #include "Common/OptionDefaults.h" #include "MantidAPI/AlgorithmManager.h" #include "PerThetaDefaultsTableValidator.h" @@ -24,7 +27,7 @@ std::string stringValueOrEmpty(boost::optional<double> value) { Experiment getExperimentDefaults(Mantid::Geometry::Instrument_const_sptr instrument) { - auto defaults = OptionDefaults(instrument); + auto defaults = OptionDefaults(std::move(instrument)); auto analysisMode = analysisModeFromString(defaults.getStringOrDefault( "AnalysisMode", "AnalysisMode", "PointDetectorAnalysis")); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui index 87ce5f4fc24be8be5c7d8acd1319b56240a3c498..4c6d279f7fb766beae8662ffdee86be63185d6da 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/ExperimentWidget.ui @@ -75,7 +75,7 @@ </size> </property> <property name="text"> - <string>Output Stitch Params</string> + <string>Output Stitch Properties</string> </property> </widget> </item> diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp index b939c91d707382c7e46becf825c342550567973e..b47755f1c0c42e70affc2c26fa67c3a4a8184879 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/PerThetaDefaultsTableValidationError.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "PerThetaDefaultsTableValidationError.h" + +#include <utility> + #include "ThetaValuesValidationError.h" namespace MantidQt { namespace CustomInterfaces { @@ -15,7 +18,7 @@ PerThetaDefaultsTableValidationError::PerThetaDefaultsTableValidationError( std::vector<InvalidDefaultsError> validationErrors, boost::optional<ThetaValuesValidationError> fullTableError) : m_validationErrors(std::move(validationErrors)), - m_fullTableError(fullTableError) {} + m_fullTableError(std::move(fullTableError)) {} std::vector<InvalidDefaultsError> const & PerThetaDefaultsTableValidationError::errors() const { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp index 4acf28d3cb1be47cc21d14010d8cc19837e357dd..60a9a6fb9c2ae1a31eb2901bd323880d0660b228 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.cpp @@ -11,6 +11,7 @@ #include <QMessageBox> #include <QScrollBar> #include <boost/algorithm/string/join.hpp> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -46,7 +47,7 @@ void showAsValid(QLineEdit &lineEdit) { * @param parent :: [input] The parent of this widget */ QtExperimentView::QtExperimentView( - Mantid::API::IAlgorithm_sptr algorithmForTooltips, QWidget *parent) + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips, QWidget *parent) : QWidget(parent), m_stitchEdit(nullptr), m_deleteShortcut(), m_notifyee(nullptr), m_columnToolTips() { initLayout(algorithmForTooltips); @@ -98,7 +99,7 @@ void QtExperimentView::initLayout( m_ui.optionsTable); connect(m_deleteShortcut.get(), SIGNAL(activated()), this, SLOT(onRemovePerThetaDefaultsRequested())); - initOptionsTable(algorithmForTooltips); + initOptionsTable(std::move(algorithmForTooltips)); initFloodControls(); auto blacklist = @@ -116,7 +117,8 @@ void QtExperimentView::initLayout( } void QtExperimentView::initializeTableColumns( - QTableWidget &table, Mantid::API::IAlgorithm_sptr algorithmForTooltips) { + QTableWidget &table, + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips) { for (auto column = 0; column < table.columnCount(); ++column) { // Get the tooltip for this column based on the algorithm property auto const propertyName = PerThetaDefaults::ColumnPropertyName[column]; @@ -159,14 +161,14 @@ void QtExperimentView::initializeTableRow( } void QtExperimentView::initOptionsTable( - Mantid::API::IAlgorithm_sptr algorithmForTooltips) { + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips) { auto table = m_ui.optionsTable; // Set angle and scale columns to a small width so everything fits table->resizeColumnsToContents(); table->setColumnCount(PerThetaDefaults::OPTIONS_TABLE_COLUMN_COUNT); table->setRowCount(1); - initializeTableColumns(*table, algorithmForTooltips); + initializeTableColumns(*table, std::move(algorithmForTooltips)); initializeTableItems(*table); auto header = table->horizontalHeader(); @@ -254,20 +256,19 @@ void QtExperimentView::disableAll() { setEnabledStateForAllWidgets(false); } void QtExperimentView::enableAll() { setEnabledStateForAllWidgets(true); } void QtExperimentView::registerSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { - registerExperimentSettingsWidgets(alg); + const Mantid::API::IAlgorithm_sptr &alg) { + registerExperimentSettingsWidgets(std::move(alg)); connectExperimentSettingsWidgets(); } void QtExperimentView::registerExperimentSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { registerSettingWidget(*m_ui.analysisModeComboBox, "AnalysisMode", alg); registerSettingWidget(*m_ui.startOverlapEdit, "StartOverlap", alg); registerSettingWidget(*m_ui.endOverlapEdit, "EndOverlap", alg); registerSettingWidget(*m_ui.transStitchParamsEdit, "Params", alg); registerSettingWidget(*m_ui.transScaleRHSCheckBox, "ScaleRHSWorkspace", alg); registerSettingWidget(*m_ui.polCorrCheckBox, "PolarizationAnalysis", alg); - registerSettingWidget(stitchOptionsLineEdit(), "Params", alg); registerSettingWidget(*m_ui.reductionTypeComboBox, "ReductionType", alg); registerSettingWidget(*m_ui.summationTypeComboBox, "SummationType", alg); registerSettingWidget(*m_ui.includePartialBinsCheckBox, "IncludePartialBins", @@ -275,6 +276,12 @@ void QtExperimentView::registerExperimentSettingsWidgets( registerSettingWidget(*m_ui.floodCorComboBox, "FloodCorrection", alg); registerSettingWidget(*m_ui.floodWorkspaceWsSelector, "FloodWorkspace", alg); registerSettingWidget(*m_ui.debugCheckBox, "Debug", alg); + + registerSettingWidget(stitchOptionsLineEdit(), + "Properties to use for stitching the output workspaces " + "in Q. Only required for groups containing multiple " + "rows. Start typing to see property hints or see " + "Stitch1DMany for details."); } void QtExperimentView::connectExperimentSettingsWidgets() { @@ -341,15 +348,21 @@ void QtExperimentView::disableIncludePartialBins() { } template <typename Widget> -void QtExperimentView::registerSettingWidget(Widget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { +void QtExperimentView::registerSettingWidget( + Widget &widget, std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg) { setToolTipAsPropertyDocumentation(widget, propertyName, alg); } +template <typename Widget> +void QtExperimentView::registerSettingWidget(Widget &widget, + std::string const &tooltip) { + widget.setToolTip(QString::fromStdString(tooltip)); +} + void QtExperimentView::setToolTipAsPropertyDocumentation( QWidget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { widget.setToolTip(QString::fromStdString( alg->getPointerToProperty(propertyName)->documentation())); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h index 386b2e3cd9c630454710c977c5f9dd80d9087a00..2efaf48f3fd0fc80195586c95ac6403f40075e9d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Experiment/QtExperimentView.h @@ -25,7 +25,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL QtExperimentView : public QWidget, public IExperimentView { Q_OBJECT public: - QtExperimentView(Mantid::API::IAlgorithm_sptr algorithmForTooltips, + QtExperimentView(const Mantid::API::IAlgorithm_sptr &algorithmForTooltips, QWidget *parent = nullptr); void subscribe(ExperimentViewSubscriber *notifyee) override; void connectExperimentSettingsWidgets() override; @@ -114,9 +114,9 @@ public slots: void onPerAngleDefaultsChanged(int row, int column); private: - void - initializeTableColumns(QTableWidget &table, - Mantid::API::IAlgorithm_sptr algorithmForTooltips); + void initializeTableColumns( + QTableWidget &table, + const Mantid::API::IAlgorithm_sptr &algorithmForTooltips); void initializeTableItems(QTableWidget &table); void initializeTableRow(QTableWidget &table, int row); void initializeTableRow(QTableWidget &table, int row, @@ -127,17 +127,22 @@ private: /// Initialise the interface void initLayout(Mantid::API::IAlgorithm_sptr algorithmForTooltips); - void initOptionsTable(Mantid::API::IAlgorithm_sptr algorithmForTooltips); + void + initOptionsTable(const Mantid::API::IAlgorithm_sptr &algorithmForTooltips); void initFloodControls(); - void registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void registerExperimentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void setToolTipAsPropertyDocumentation(QWidget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + void registerSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + registerExperimentSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + setToolTipAsPropertyDocumentation(QWidget &widget, + std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg); template <typename Widget> void registerSettingWidget(Widget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + const Mantid::API::IAlgorithm_sptr &alg); + template <typename Widget> + void registerSettingWidget(Widget &widget, std::string const &tooltip); void connectSettingsChange(QLineEdit &edit); void connectSettingsChange(QComboBox &edit); void connectSettingsChange(QCheckBox &edit); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp index d1a7f3eed32e7a0b29d7be3ce081ee05ea933a9e..73d3c4b5ecfb954971b4c2893bdd176914619766 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/InstrumentOptionDefaults.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "InstrumentOptionDefaults.h" + +#include <utility> + #include "Common/OptionDefaults.h" #include "MantidAPI/AlgorithmManager.h" #include "Reduction/Instrument.h" @@ -19,7 +22,7 @@ Mantid::Kernel::Logger g_log("Reflectometry GUI"); Instrument getInstrumentDefaults(Mantid::Geometry::Instrument_const_sptr instrument) { - auto defaults = OptionDefaults(instrument); + auto defaults = OptionDefaults(std::move(instrument)); auto wavelengthRange = RangeInLambda(defaults.getValue<double>("WavelengthMin", "LambdaMin"), diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp index a527c694704ff299c39cedb6314ded0aa4d111e1..7fd4fac9f4b24406af044d5d034b1b96022b5c51 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.cpp @@ -10,6 +10,7 @@ #include <QMessageBox> #include <QScrollBar> #include <boost/algorithm/string/join.hpp> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -36,7 +37,7 @@ QtInstrumentView::QtInstrumentView( Mantid::API::IAlgorithm_sptr algorithmForTooltips, QWidget *parent) : QWidget(parent) { initLayout(); - registerSettingsWidgets(algorithmForTooltips); + registerSettingsWidgets(std::move(algorithmForTooltips)); } void QtInstrumentView::subscribe(InstrumentViewSubscriber *notifyee) { @@ -132,12 +133,12 @@ void QtInstrumentView::disableDetectorCorrectionType() { } void QtInstrumentView::registerSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { - registerInstrumentSettingsWidgets(alg); + const Mantid::API::IAlgorithm_sptr &alg) { + registerInstrumentSettingsWidgets(std::move(alg)); } void QtInstrumentView::registerInstrumentSettingsWidgets( - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { registerSettingWidget(*m_ui.intMonCheckBox, "NormalizeByIntegratedMonitors", alg); registerSettingWidget(*m_ui.monIntMinEdit, "MonitorIntegrationWavelengthMin", @@ -184,16 +185,16 @@ void QtInstrumentView::disconnectInstrumentSettingsWidgets() { } template <typename Widget> -void QtInstrumentView::registerSettingWidget(Widget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { +void QtInstrumentView::registerSettingWidget( + Widget &widget, std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg) { connectSettingsChange(widget); setToolTipAsPropertyDocumentation(widget, propertyName, alg); } void QtInstrumentView::setToolTipAsPropertyDocumentation( QWidget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg) { + const Mantid::API::IAlgorithm_sptr &alg) { widget.setToolTip(QString::fromStdString( alg->getPointerToProperty(propertyName)->documentation())); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h index 52cd251212221c7e7d453bfed417ec93289f9dba..6735bcf0fffd75c0b83a894bc30c19d8453ac9ab 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Instrument/QtInstrumentView.h @@ -77,15 +77,17 @@ private: /// Initialise the interface void initLayout(); - void registerSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void registerInstrumentSettingsWidgets(Mantid::API::IAlgorithm_sptr alg); - void setToolTipAsPropertyDocumentation(QWidget &widget, - std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + void registerSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + registerInstrumentSettingsWidgets(const Mantid::API::IAlgorithm_sptr &alg); + void + setToolTipAsPropertyDocumentation(QWidget &widget, + std::string const &propertyName, + const Mantid::API::IAlgorithm_sptr &alg); template <typename Widget> void registerSettingWidget(Widget &widget, std::string const &propertyName, - Mantid::API::IAlgorithm_sptr alg); + const Mantid::API::IAlgorithm_sptr &alg); void connectSettingsChange(QLineEdit &edit); void connectSettingsChange(QComboBox &edit); void connectSettingsChange(QCheckBox &edit); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp index d6facb1a02f61572bfd43b776cd2e37076252002..a270d106334b2257eb6e7bdb0782ef2dd51f6895 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtCatalogSearcher.cpp @@ -21,7 +21,8 @@ namespace CustomInterfaces { namespace ISISReflectometry { namespace { // unnamed -void removeResultsWithoutFilenameExtension(ITableWorkspace_sptr results) { +void removeResultsWithoutFilenameExtension( + const ITableWorkspace_sptr &results) { std::set<size_t> toRemove; for (size_t i = 0; i < results->rowCount(); ++i) { std::string &run = results->String(i, 0); diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp index d654e5187dbb947b7a44f1bbbc8e592083820ca1..2ac57dcdbe5646904cf664d81e3bbfc4924dfe88 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.cpp @@ -27,7 +27,8 @@ using namespace MantidQt::Icons; * @param parent :: The parent of this view * @param makeRunsTableView :: The factory for the RunsTableView. */ -QtRunsView::QtRunsView(QWidget *parent, RunsTableViewFactory makeRunsTableView) +QtRunsView::QtRunsView(QWidget *parent, + const RunsTableViewFactory &makeRunsTableView) : MantidWidget(parent), m_notifyee(nullptr), m_timerNotifyee(nullptr), m_searchNotifyee(nullptr), m_searchModel(), m_tableView(makeRunsTableView()), m_timer() { diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h index a9b16bbe3837d5e4882efd3e3f4752bb0fc10192..9f50d4c262b6404cfc19ff10920032e95dd59c73 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Runs/QtRunsView.h @@ -33,7 +33,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL QtRunsView public IRunsView { Q_OBJECT public: - QtRunsView(QWidget *parent, RunsTableViewFactory makeView); + QtRunsView(QWidget *parent, const RunsTableViewFactory &makeView); void subscribe(RunsViewSubscriber *notifyee) override; void subscribeTimer(RunsViewTimerSubscriber *notifyee) override; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp index b242bc70f8c9a4ee5cb8367f97b8dc58da29527f..a6b08d7016a918c4814a8849595f8fe12a9ec828 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.cpp @@ -13,7 +13,7 @@ namespace ISISReflectometry { using MantidQt::MantidWidgets::Batch::IJobTreeView; using MantidQt::MantidWidgets::Batch::RowLocation; -RegexFilter::RegexFilter(boost::regex regex, IJobTreeView const &view, +RegexFilter::RegexFilter(const boost::regex ®ex, IJobTreeView const &view, ReductionJobs const &jobs) : m_filter(std::move(regex)), m_view(view), m_jobs(jobs) {} diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h index c95a22ef720983a797c0665e213c66318098a68a..6c5e45643148783afe999e344e38784f9b626ded 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/RunsTable/RegexRowFilter.h @@ -19,7 +19,7 @@ namespace ISISReflectometry { class RegexFilter : public MantidQt::MantidWidgets::Batch::RowPredicate { public: - RegexFilter(boost::regex regex, + RegexFilter(const boost::regex ®ex, MantidQt::MantidWidgets::Batch::IJobTreeView const &view, ReductionJobs const &jobs); bool rowMeetsCriteria( diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp index cd0148060e31625b0721f32c3cff0be10e566699..80c8a48e4d11b5f5a6bef22ce31d47a5cb75821c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.cpp @@ -11,6 +11,9 @@ #include "MantidAPI/WorkspaceGroup.h" #include <Poco/File.h> #include <Poco/Path.h> + +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { @@ -65,7 +68,7 @@ bool AsciiSaver::isValidSaveDirectory(std::string const &path) const { namespace { template <typename T> -void setPropertyIfSupported(Mantid::API::IAlgorithm_sptr alg, +void setPropertyIfSupported(const Mantid::API::IAlgorithm_sptr &alg, std::string const &propertyName, T const &value) { if (alg->existsProperty(propertyName)) alg->setProperty(propertyName, value); @@ -93,7 +96,7 @@ AsciiSaver::workspace(std::string const &workspaceName) const { Mantid::API::IAlgorithm_sptr AsciiSaver::setUpSaveAlgorithm(std::string const &saveDirectory, - Mantid::API::Workspace_sptr workspace, + const Mantid::API::Workspace_sptr &workspace, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const { auto saveAlg = algorithmForFormat(fileFormat.format()); @@ -112,12 +115,12 @@ AsciiSaver::setUpSaveAlgorithm(std::string const &saveDirectory, return saveAlg; } -void AsciiSaver::save(Mantid::API::Workspace_sptr workspace, +void AsciiSaver::save(const Mantid::API::Workspace_sptr &workspace, std::string const &saveDirectory, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const { - auto alg = - setUpSaveAlgorithm(saveDirectory, workspace, logParameters, fileFormat); + auto alg = setUpSaveAlgorithm(saveDirectory, std::move(workspace), + logParameters, fileFormat); alg->execute(); } diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h index 1f028e4b52ad685980e31470c0280622ad635d5c..695674e61efe5403d38ae3615084f919e0a5224c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/AsciiSaver.h @@ -28,7 +28,7 @@ public: private: Mantid::API::IAlgorithm_sptr setUpSaveAlgorithm(std::string const &saveDirectory, - Mantid::API::Workspace_sptr workspace, + const Mantid::API::Workspace_sptr &workspace, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const; @@ -38,7 +38,7 @@ private: std::string const &extension) const; Mantid::API::Workspace_sptr workspace(std::string const &workspaceName) const; - void save(Mantid::API::Workspace_sptr workspace, + void save(const Mantid::API::Workspace_sptr &workspace, std::string const &saveDirectory, std::vector<std::string> const &logParameters, FileFormatOptions const &fileFormat) const; diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp index add0b4c9e071540d20f17b7abc54188a8b34016f..1c6e779087e6e95c4cb848113eb3f6bb377260e8 100644 --- a/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/GUI/Save/SavePresenter.cpp @@ -135,7 +135,7 @@ void SavePresenter::filterWorkspaceNames() { boost::regex rgx(filter); it = std::copy_if( wsNames.begin(), wsNames.end(), validNames.begin(), - [rgx](std::string s) { return boost::regex_search(s, rgx); }); + [rgx](const std::string &s) { return boost::regex_search(s, rgx); }); m_view->showFilterEditValid(); } catch (boost::regex_error &) { m_view->showFilterEditInvalid(); @@ -143,7 +143,7 @@ void SavePresenter::filterWorkspaceNames() { } else { // Otherwise simply add names where the filter string is found in it = std::copy_if(wsNames.begin(), wsNames.end(), validNames.begin(), - [filter](std::string s) { + [filter](const std::string &s) { return s.find(filter) != std::string::npos; }); } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp index 4f5b0503d675cd600ac468e28f1949774d8f2f76..aba3620fb54f210545f843e55ec2a7cc43e414b3 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/FloodCorrections.cpp @@ -5,13 +5,16 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "FloodCorrections.h" + +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { FloodCorrections::FloodCorrections(FloodCorrectionType correctionType, boost::optional<std::string> workspace) - : m_correctionType(correctionType), m_workspace(workspace) {} + : m_correctionType(correctionType), m_workspace(std::move(workspace)) {} FloodCorrectionType FloodCorrections::correctionType() const { return m_correctionType; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp index d4efc4bfca57f8ba2a27b692a91df2edd955ddba..a4b931cb8395ae77b65788a843cb26a574a36a0c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/MonitorCorrections.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "MonitorCorrections.h" + +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { @@ -14,7 +17,8 @@ MonitorCorrections::MonitorCorrections( boost::optional<RangeInLambda> backgroundRange, boost::optional<RangeInLambda> integralRange) : m_monitorIndex(monitorIndex), m_integrate(integrate), - m_backgroundRange(backgroundRange), m_integralRange(integralRange) {} + m_backgroundRange(std::move(backgroundRange)), + m_integralRange(std::move(integralRange)) {} size_t MonitorCorrections::monitorIndex() const { return m_monitorIndex; } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp index 83d975eb03331b2a9cecb50801b5837533118fb5..b629cdcb190fdb99d9bf264052a1fd0657f6eac9 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/RangeInQ.cpp @@ -6,13 +6,15 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "RangeInQ.h" #include <cassert> +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace ISISReflectometry { RangeInQ::RangeInQ(boost::optional<double> min, boost::optional<double> step, boost::optional<double> max) - : m_min(min), m_step(step), m_max(max) { + : m_min(std::move(min)), m_step(std::move(step)), m_max(std::move(max)) { assert(!(m_min.is_initialized() && m_max.is_initialized() && m_max < m_min)); } diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp index 656088bcba85e1fce999a62ea581719eea511ca8..a3d92ecaeb706a968eeb269a220807ebede058bc 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.cpp @@ -288,7 +288,7 @@ ReductionJobs::getItemWithOutputWorkspaceOrNone(std::string const &wsName) { } Group const &ReductionJobs::getGroupFromPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isGroupLocation(rowLocation)) { return groups()[groupOf(rowLocation)]; } else { @@ -297,7 +297,7 @@ Group const &ReductionJobs::getGroupFromPath( } boost::optional<Row> const &ReductionJobs::getRowFromPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isRowLocation(rowLocation)) { return groups()[groupOf(rowLocation)].rows()[rowOf(rowLocation)]; } else { @@ -306,7 +306,7 @@ boost::optional<Row> const &ReductionJobs::getRowFromPath( } bool ReductionJobs::validItemAtPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isGroupLocation(rowLocation)) return true; @@ -314,7 +314,7 @@ bool ReductionJobs::validItemAtPath( } Item const &ReductionJobs::getItemFromPath( - const MantidWidgets::Batch::RowLocation rowLocation) const { + const MantidWidgets::Batch::RowLocation &rowLocation) const { if (isGroupLocation(rowLocation)) { return getGroupFromPath(rowLocation); } else { diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h index 3f2c4ea7a69aa6af6a9f0035e2f6b70838e03ad0..030fb2033b20e31b2a2ee5d5e24008bce43a530e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionJobs.h @@ -47,13 +47,13 @@ public: getItemWithOutputWorkspaceOrNone(std::string const &wsName); bool - validItemAtPath(const MantidWidgets::Batch::RowLocation rowLocation) const; + validItemAtPath(const MantidWidgets::Batch::RowLocation &rowLocation) const; Group const & - getGroupFromPath(const MantidWidgets::Batch::RowLocation path) const; + getGroupFromPath(const MantidWidgets::Batch::RowLocation &path) const; boost::optional<Row> const & - getRowFromPath(const MantidWidgets::Batch::RowLocation path) const; + getRowFromPath(const MantidWidgets::Batch::RowLocation &path) const; Item const & - getItemFromPath(const MantidWidgets::Batch::RowLocation path) const; + getItemFromPath(const MantidWidgets::Batch::RowLocation &path) const; private: std::vector<Group> m_groups; diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp index 414351f7c11efacc9b4018df469b183bbf54ed48..fff3cc9003ec1f2fb4c0710ab63f60fa8084b359 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ReductionWorkspaces.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ReductionWorkspaces.h" + +#include <utility> + #include "Common/Map.h" namespace MantidQt { @@ -16,7 +19,7 @@ ReductionWorkspaces::ReductionWorkspaces( // cppcheck-suppress passedByValue TransmissionRunPair transmissionRuns) : m_inputRunNumbers(std::move(inputRunNumbers)), - m_transmissionRuns(transmissionRuns), m_iVsLambda(), m_iVsQ(), + m_transmissionRuns(std::move(transmissionRuns)), m_iVsLambda(), m_iVsQ(), m_iVsQBinned() {} std::vector<std::string> const &ReductionWorkspaces::inputRunNumbers() const { diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp index f48a38c25fc6017de828d77548cd8f27ebb227dc..812ef2fdcabe79bf8dd4a59eb9342d83c519cb48 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidatePerThetaDefaults.cpp @@ -28,7 +28,7 @@ public: return boost::none; } - boost::optional<T> operator()(std::vector<int> errorColumns) const { + boost::optional<T> operator()(const std::vector<int> &errorColumns) const { std::transform(errorColumns.cbegin(), errorColumns.cend(), std::back_inserter(m_invalidParams), [this](int column) -> int { return m_baseColumn + column; }); diff --git a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp index 1e08a461995d8c453d2a2965d81682738770f394..02edeee301e441e780f1c877f19b2c975f059c8c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/Reduction/ValidateRow.cpp @@ -44,7 +44,7 @@ public: return boost::none; } - boost::optional<T> operator()(std::vector<int> errorColumns) const { + boost::optional<T> operator()(const std::vector<int> &errorColumns) const { std::transform(errorColumns.cbegin(), errorColumns.cend(), std::back_inserter(m_invalidParams), [this](int column) -> int { return m_baseColumn + column; }); diff --git a/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp b/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp index 5b0c880b25358083f587512b709f77787335c170..27dc770b73f52e0b09468b276ba172badcbc591c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/TestHelpers/ModelCreationHelper.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ModelCreationHelper.h" + +#include <utility> + #include "../../ISISReflectometry/Reduction/Batch.h" namespace MantidQt { @@ -55,7 +58,8 @@ Row makeRow(std::string const &run, double theta, std::string const &trans1, boost::optional<double> scale, ReductionOptionsMap const &optionsMap) { return Row({run}, theta, TransmissionRunPair({trans1, trans2}), - RangeInQ(qMin, qMax, qStep), scale, optionsMap, + RangeInQ(std::move(qMin), std::move(qMax), std::move(qStep)), + std::move(scale), optionsMap, ReductionWorkspaces({run}, TransmissionRunPair({trans1, trans2}))); } diff --git a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp index f11b53d9ef656853b5a5f8be7e5a0190d8779b2e..7f050f86aac28811a0514a3811ea3c9e8f391e08 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.cpp @@ -175,7 +175,7 @@ QListWidgetItem *SANSAddFiles::insertListFront(const QString &text) { * that users see * @param dir :: full path of the output directory */ -void SANSAddFiles::setOutDir(std::string dir) { +void SANSAddFiles::setOutDir(const std::string &dir) { m_outDir = QString::fromStdString(dir); m_SANSForm->summedPath_lb->setText(OUT_MSG + m_outDir); } @@ -521,8 +521,10 @@ bool SANSAddFiles::checkValidityTimeShiftsForAddedEventFiles() { * @param lineEditText :: text for the line edit field * @param enabled :: if the input should be enabled. */ -void SANSAddFiles::setHistogramUiLogic(QString label, QString toolTip, - QString lineEditText, bool enabled) { +void SANSAddFiles::setHistogramUiLogic(const QString &label, + const QString &toolTip, + const QString &lineEditText, + bool enabled) { // Line edit field m_SANSForm->eventToHistBinning->setText(lineEditText); m_SANSForm->eventToHistBinning->setToolTip(toolTip); diff --git a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h index a03ad3a03f2381778e6991a20d5852188e95d6c2..ad16cc7c93d7600ef8f4ef519a052205d513a1f8 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h +++ b/qt/scientific_interfaces/ISISSANS/SANSAddFiles.h @@ -55,8 +55,8 @@ private: /// Text for tooltip for save event data QString m_saveEventDataToolTip; /// Set the bin field - void setHistogramUiLogic(QString label, QString toolTip, QString lineEditText, - bool enabled); + void setHistogramUiLogic(const QString &label, const QString &toolTip, + const QString &lineEditText, bool enabled); /// Set the histo gram input enabled or disabled void setInputEnabled(bool enabled); /// Create Python string list @@ -69,7 +69,7 @@ private: QListWidgetItem *insertListFront(const QString &text); void changeOutputDir(Mantid::Kernel::ConfigValChangeNotification_ptr pDirInfo); - void setOutDir(std::string dir); + void setOutDir(const std::string &dir); bool checkValidityTimeShiftsForAddedEventFiles(); private slots: diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp index 59929314117a4220628c31b52c070e01a62d5f44..e0aeb2f9f73de9a4b74d615c33760315fef4d429 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.cpp @@ -9,7 +9,8 @@ namespace MantidQt { namespace CustomInterfaces { SANSBackgroundCorrectionSettings::SANSBackgroundCorrectionSettings( - QString runNumber, bool useMean, bool useMon, QString monNumber) + const QString &runNumber, bool useMean, bool useMon, + const QString &monNumber) : m_runNumber(runNumber), m_useMean(useMean), m_useMon(useMon), m_monNumber(monNumber) { hasValidSettings(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h index 4614ee57d50cf7979e09aa40f4cb7eeeb7b6e56c..546b9a0b9d8953430e12230d9c48e1ba650c18a7 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionSettings.h @@ -19,8 +19,8 @@ the SANSBackgroundCorrectionWidget */ class MANTIDQT_ISISSANS_DLL SANSBackgroundCorrectionSettings { public: - SANSBackgroundCorrectionSettings(QString runNumber, bool useMean, bool useMon, - QString monNumber); + SANSBackgroundCorrectionSettings(const QString &runNumber, bool useMean, + bool useMon, const QString &monNumber); bool hasValidSettings(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp index c9905f1a26624b9813d7cea037f49f6a3aa804d4..2120d89456deaec65aae556526aacc15b9531ef1 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.cpp @@ -16,7 +16,8 @@ namespace { Mantid::Kernel::Logger g_log("SANSBackgroundCorrectionWidget"); bool hasRunNumber( - MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings setting) { + const MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings + &setting) { auto hasNumber = true; if (setting.getRunNumber().isEmpty()) { hasNumber = false; @@ -49,7 +50,7 @@ SANSBackgroundCorrectionWidget::SANSBackgroundCorrectionWidget(QWidget *parent) * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeDetectors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; @@ -73,7 +74,7 @@ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeDetectors( * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeMonitors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; } @@ -97,7 +98,7 @@ void SANSBackgroundCorrectionWidget::setDarkRunSettingForTimeMonitors( * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForUampDetectors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; } @@ -118,7 +119,7 @@ void SANSBackgroundCorrectionWidget::setDarkRunSettingForUampDetectors( * want */ void SANSBackgroundCorrectionWidget::setDarkRunSettingForUampMonitors( - SANSBackgroundCorrectionSettings setting) { + const SANSBackgroundCorrectionSettings &setting) { if (!hasRunNumber(setting)) { return; } diff --git a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h index 52df3b2bd1c8aa580bfb5327bafca4f69ba89c24..dfe8a3550d29250144723b7596a7a8ad010d238a 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h +++ b/qt/scientific_interfaces/ISISSANS/SANSBackgroundCorrectionWidget.h @@ -25,18 +25,18 @@ class MANTIDQT_ISISSANS_DLL SANSBackgroundCorrectionWidget : public QWidget { public: SANSBackgroundCorrectionWidget(QWidget *parent = nullptr); - void - setDarkRunSettingForTimeDetectors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForTimeDetectors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForTimeDetectors(); - void - setDarkRunSettingForUampDetectors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForUampDetectors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForUampDetectors(); - void - setDarkRunSettingForTimeMonitors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForTimeMonitors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForTimeMonitors(); - void - setDarkRunSettingForUampMonitors(SANSBackgroundCorrectionSettings setting); + void setDarkRunSettingForUampMonitors( + const SANSBackgroundCorrectionSettings &setting); SANSBackgroundCorrectionSettings getDarkRunSettingForUampMonitors(); void resetEntries(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp index 16083b0dcfa5b20ffd4ceb544c20c37674184b62..a315af1582f5369fe9814bf5276bb1c2b860e2c6 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.cpp @@ -1185,7 +1185,7 @@ void SANSDiagnostics::saveSettings() { * @param orientation - orientation of the detector */ bool SANSDiagnostics::executeSumRowColumn( - const std::vector<unsigned int> &values, const QString ipws, + const std::vector<unsigned int> &values, const QString &ipws, const QString &opws, const QString &orientation) { if (values.empty()) { return false; @@ -1229,7 +1229,7 @@ bool SANSDiagnostics::executeSumRowColumn( * @param hvMin minimum value of * @param hvMax */ -bool SANSDiagnostics::runsumRowColumn(const QString ipwsName, +bool SANSDiagnostics::runsumRowColumn(const QString &ipwsName, const QString &opwsName, const QString &orientation, const QString &hvMin, @@ -1431,8 +1431,8 @@ void SANSDiagnostics::enableMaskFileControls() { * @returns an output workspace name */ QString SANSDiagnostics::createOutputWorkspaceName( - QString originalWorkspaceName, QString detectorName, - QString integrationType, QString min, QString max) { + const QString &originalWorkspaceName, const QString &detectorName, + const QString &integrationType, const QString &min, const QString &max) { // Get run number from the loaded workspace boost::optional<int> runNumber = boost::none; try { diff --git a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h index d305c4723f22dc342aafddb936cfda74816ecec1..f3ab468401ab4b3be72773be96592797616efd07 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h +++ b/qt/scientific_interfaces/ISISSANS/SANSDiagnostics.h @@ -80,7 +80,7 @@ private: void setToolTips(); /// execute sumrowcolumn algorithm bool executeSumRowColumn(const std::vector<unsigned int> &values, - const QString ipws, const QString &op, + const QString &ipws, const QString &op, const QString &orientation); /// load the settings from the registry void loadSettings(); @@ -99,7 +99,7 @@ private: bool runLoadAlgorithm(const QString &fileName, const QString &specMin = "-1", const QString &specMax = "-1"); /// returns sumrowcolumn script - bool runsumRowColumn(const QString ipwsName, const QString &opwsName, + bool runsumRowColumn(const QString &ipwsName, const QString &opwsName, const QString &orientation, const QString &hvMin, const QString &hvMax); // get rectangular detector details @@ -173,10 +173,10 @@ private: void HVMinHVMaxStringValues(const int minVal, const int maxVal, QString &hvMin, QString &hvMax); /// Create the name for the outputworkspace - QString createOutputWorkspaceName(QString originalWorkspaceName, - QString detectorName, - QString integrationType, QString min, - QString max); + QString createOutputWorkspaceName(const QString &originalWorkspaceName, + const QString &detectorName, + const QString &integrationType, + const QString &min, const QString &max); private: QString m_dataDir; ///< default data search directory diff --git a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp index 7c37701d14058d30968f2a54dbe1c85e6f7b21c2..e9f824dd02ecddfd7c0fa8a5a9b7c1ec39924c86 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.cpp @@ -148,7 +148,8 @@ SANSEventSlicing::runSliceEvent(const QString &code) { return values2ChargeAndTime(result); } -void SANSEventSlicing::raiseWarning(QString title, QString message) { +void SANSEventSlicing::raiseWarning(const QString &title, + const QString &message) { QMessageBox::warning(this, title, message); } diff --git a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h index 67434d6b236c000e81903f6692e9c985ecdf1d34..446f138a5eee9661efeff6548d52bd9408c1576b 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h +++ b/qt/scientific_interfaces/ISISSANS/SANSEventSlicing.h @@ -39,7 +39,7 @@ private: ChargeAndTime runSliceEvent(const QString &code2run); void checkPythonOutput(const QString &result); ChargeAndTime values2ChargeAndTime(const QString &input); - void raiseWarning(QString title, QString message); + void raiseWarning(const QString &title, const QString &message); protected: void showEvent(QShowEvent * /*unused*/) override; diff --git a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp index fd1591ea4ee4d4b6af0a5ac3b143d705c01beba4..d4094c00dc48c08bc2230c68cb45a2aa15d76f15 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp @@ -474,7 +474,7 @@ void SANSPlotSpecial::setupTable() { QwtPlotCurve *SANSPlotSpecial::plotMiniplot( QwtPlotCurve *curve, - boost::shared_ptr<Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &workspace, size_t workspaceIndex) { bool data = (curve == m_dataCurve); diff --git a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h index 131e69decbc7326e5175e30e108f02a8101808a1..abcddc324ee66727d6f864f271883f5035567113 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h +++ b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.h @@ -100,7 +100,7 @@ private: void createTransforms(); QwtPlotCurve * plotMiniplot(QwtPlotCurve *curve, - boost::shared_ptr<Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<Mantid::API::MatrixWorkspace> &workspace, size_t workspaceIndex = 0); void deriveGuinierSpheres(); diff --git a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp index acd8be43bda711b981eb3649f5c786d63dd8fb6b..f882baace119c80ae470f6acf4626427e8afa0bd 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.cpp @@ -45,6 +45,7 @@ #include <boost/tuple/tuple.hpp> #include <cmath> +#include <utility> using Mantid::detid_t; @@ -159,7 +160,7 @@ QString convertBoolToPythonBoolString(bool input) { * @param input: the python string representation * @returns a true or false */ -bool convertPythonBoolStringToBool(QString input) { +bool convertPythonBoolStringToBool(const QString &input) { bool value = false; if (input == MantidQt::CustomInterfaces::SANSConstants::getPythonTrueKeyword()) { @@ -173,7 +174,8 @@ bool convertPythonBoolStringToBool(QString input) { } void setTransmissionOnSaveCommand( - QString &saveCommand, Mantid::API::MatrixWorkspace_sptr matrix_workspace, + QString &saveCommand, + const Mantid::API::MatrixWorkspace_sptr &matrix_workspace, const QString &detectorSelection) { if (matrix_workspace->getInstrument()->getName() == "SANS2D") saveCommand += "'front-detector, rear-detector'"; @@ -1461,7 +1463,7 @@ void SANSRunWindow::appendRowToMaskTable(const QString &type, * @param lsdb :: The result of the sample-detector bank 2 distance */ void SANSRunWindow::componentLOQDistances( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, double &lms, double &lsda, double &lsdb) { Instrument_const_sptr instr = workspace->getInstrument(); if (!instr) @@ -1882,7 +1884,7 @@ void SANSRunWindow::setGeometryDetails() { * @param wscode :: 0 for sample, 1 for can, others not defined */ void SANSRunWindow::setSANS2DGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode) { const double unitconv = 1000.; const double distance = workspace->spectrumInfo().l1() * unitconv; @@ -1934,11 +1936,11 @@ void SANSRunWindow::setSANS2DGeometry( * @param wscode :: ????? */ void SANSRunWindow::setLOQGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode) { double dist_ms(0.0), dist_mdb(0.0), dist_hab(0.0); // Sample - componentLOQDistances(workspace, dist_ms, dist_mdb, dist_hab); + componentLOQDistances(std::move(workspace), dist_ms, dist_mdb, dist_hab); QHash<QString, QLabel *> &labels = m_loq_detlabels[wscode]; QLabel *detlabel = labels.value("moderator-sample"); @@ -3687,7 +3689,7 @@ void SANSRunWindow::fillDetectNames(QComboBox *output) { * @throw NotFoundError if a workspace can't be returned */ Mantid::API::MatrixWorkspace_sptr -SANSRunWindow::getGroupMember(Mantid::API::Workspace_const_sptr in, +SANSRunWindow::getGroupMember(const Mantid::API::Workspace_const_sptr &in, const int member) const { Mantid::API::WorkspaceGroup_const_sptr group = boost::dynamic_pointer_cast<const Mantid::API::WorkspaceGroup>(in); @@ -3820,7 +3822,7 @@ void SANSRunWindow::cleanup() { * @param csv_line :: Add a line of csv text to the grid * @param separator :: An optional separator, default = "," */ -int SANSRunWindow::addBatchLine(QString csv_line, QString separator) { +int SANSRunWindow::addBatchLine(const QString &csv_line, QString separator) { // Try to detect separator if one is not specified if (separator.isEmpty()) { if (csv_line.contains(",")) { @@ -4688,7 +4690,7 @@ bool SANSRunWindow::areSettingsValid(States type) { void SANSRunWindow::checkWaveLengthAndQValues(bool &isValid, QString &message, QLineEdit *min, QLineEdit *max, QComboBox *selection, - QString type) { + const QString &type) { auto min_value = min->text().simplified().toDouble(); auto max_value = max->text().simplified().toDouble(); @@ -4834,7 +4836,7 @@ void SANSRunWindow::retrieveQResolutionAperture() { * @param command: the python command to execute * @returns either a length (string) in mm or an empty string */ -QString SANSRunWindow::retrieveQResolutionGeometry(QString command) { +QString SANSRunWindow::retrieveQResolutionGeometry(const QString &command) { QString result(runPythonCode(command, false)); result = result.simplified(); if (result == m_constants.getPythonEmptyKeyword()) { @@ -4864,9 +4866,10 @@ void SANSRunWindow::setupQResolutionCircularAperture() { * @param h2: the height of the second aperture * @param w2: the width of the second aperture */ -void SANSRunWindow::setupQResolutionRectangularAperture(QString h1, QString w1, - QString h2, - QString w2) { +void SANSRunWindow::setupQResolutionRectangularAperture(const QString &h1, + const QString &w1, + const QString &h2, + const QString &w2) { // Set the QResolution Aperture setQResolutionApertureType(QResoluationAperture::RECTANGULAR, "H1 [mm]", "H2 [mm]", h1, h2, @@ -4914,9 +4917,9 @@ void SANSRunWindow::setupQResolutionRectangularAperture() { * @param w1W2Disabled: if the w1W2Inputs should be disabled */ void SANSRunWindow::setQResolutionApertureType( - QResoluationAperture apertureType, QString a1H1Label, QString a2H2Label, - QString a1H1, QString a2H2, QString toolTipA1H1, QString toolTipA2H2, - bool w1W2Disabled) { + QResoluationAperture apertureType, const QString &a1H1Label, + const QString &a2H2Label, const QString &a1H1, const QString &a2H2, + const QString &toolTipA1H1, const QString &toolTipA2H2, bool w1W2Disabled) { // Set the labels m_uiForm.q_resolution_a1_h1_label->setText(a1H1Label); m_uiForm.q_resolution_a2_h2_label->setText(a2H2Label); @@ -5012,7 +5015,7 @@ void SANSRunWindow::writeQResolutionSettingsToPythonScript( * @param py_code: the code segment to which we want to append */ void SANSRunWindow::writeQResolutionSettingsToPythonScriptSingleEntry( - QString value, QString code_entry, const QString lineEnding, + const QString &value, const QString &code_entry, const QString &lineEnding, QString &py_code) const { if (!value.isEmpty()) { py_code += code_entry + value + lineEnding; @@ -5125,7 +5128,8 @@ SANSRunWindow::retrieveBackgroundCorrectionSetting(bool isTime, bool isMon) { std::map<QString, QString> commandMap = { {"run_number", ""}, {"is_mean", ""}, {"is_mon", ""}, {"mon_number", ""}}; - auto createPythonScript = [](bool isTime, bool isMon, QString component) { + auto createPythonScript = [](bool isTime, bool isMon, + const QString &component) { return "i.get_background_correction(is_time = " + convertBoolToPythonBoolString(isTime) + ", is_mon=" + convertBoolToPythonBoolString(isMon) + @@ -5185,7 +5189,7 @@ void SANSRunWindow::writeBackgroundCorrectionToPythonScript( */ void SANSRunWindow::addBackgroundCorrectionToPythonScript( QString &pythonCode, - MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings setting, + const MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings &setting, bool isTimeBased) { QString newSetting = diff --git a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h index 426533cd3197851fba11fb07d26f0cb63e283636..096cfd7636556ef64a1a1f262e41af2bab5e71c9 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h +++ b/qt/scientific_interfaces/ISISSANS/SANSRunWindow.h @@ -149,14 +149,15 @@ private: QString readSampleObjectGUIChanges(); /// Get the component distances void componentLOQDistances( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, double &lms, double &lsda, double &lsdb); /// Enable/disable user interaction void setProcessingState(const States action); /// Check for workspace name in the AnalysisDataService bool workspaceExists(const QString &ws_name) const; Mantid::API::MatrixWorkspace_sptr - getGroupMember(Mantid::API::Workspace_const_sptr in, const int member) const; + getGroupMember(const Mantid::API::Workspace_const_sptr &in, + const int member) const; /// Construct a QStringList of the currently loaded workspaces QStringList currentWorkspaceList() const; /// Is the user file loaded @@ -168,11 +169,11 @@ private: void setGeometryDetails(); /// Set the SANS2D geometry void setSANS2DGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode); /// Set LOQ geometry void setLOQGeometry( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> workspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> &workspace, int wscode); /// Mark an error on a label void markError(QLabel *label); @@ -207,7 +208,7 @@ private: bool browseForFile(const QString &box_title, QLineEdit *file_field, QString file_filter = QString()); /// Add a csv line to the batch grid - int addBatchLine(QString csv_line, QString separator = ""); + int addBatchLine(const QString &csv_line, QString separator = ""); /// Save the batch file QString saveBatchGrid(const QString &filename = ""); /// Check that the workspace can have the zero errors removed @@ -445,7 +446,7 @@ private: /// Check setting for wavelengths and Q values void checkWaveLengthAndQValues(bool &isValid, QString &message, QLineEdit *min, QLineEdit *max, - QComboBox *selection, QString type); + QComboBox *selection, const QString &type); /// Checks if the save settings are valid for a particular workspace bool areSaveSettingsValid(const QString &workspaceName); /// Update the beam center fields @@ -458,26 +459,29 @@ private: /// correct setting and displays it void retrieveQResolutionAperture(); /// General getter for aperture settings of Q Resolution - QString retrieveQResolutionGeometry(QString command); + QString retrieveQResolutionGeometry(const QString &command); /// Write the QResolution GUI changes to a python script void writeQResolutionSettingsToPythonScript(QString &pythonCode); /// Write single line for Q Resolution void writeQResolutionSettingsToPythonScriptSingleEntry( - QString value, QString code_entry, const QString lineEnding, - QString &py_code) const; + const QString &value, const QString &code_entry, + const QString &lineEnding, QString &py_code) const; /// Sets the cirucular aperture, ie labels and populates the values with what /// is available from the user file void setupQResolutionCircularAperture(); /// Sets the rectuanular aperture - void setupQResolutionRectangularAperture(QString h1, QString w1, QString h2, - QString w2); + void setupQResolutionRectangularAperture(const QString &h1, const QString &w1, + const QString &h2, + const QString &w2); /// Set the rectangular aperture void setupQResolutionRectangularAperture(); /// Set the aperture type void setQResolutionApertureType(QResoluationAperture apertureType, - QString a1H1Label, QString a2H2Label, - QString a1H1, QString a2H2, - QString toolTipA1H1, QString toolTipA2H2, + const QString &a1H1Label, + const QString &a2H2Label, const QString &a1H1, + const QString &a2H2, + const QString &toolTipA1H1, + const QString &toolTipA2H2, bool w1W2Disabled); /// Initialize the QResolution settings void initQResolutionSettings(); @@ -494,7 +498,8 @@ private: /// Generic addition of background correction to python script void addBackgroundCorrectionToPythonScript( QString &pythonCode, - MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings setting, + const MantidQt::CustomInterfaces::SANSBackgroundCorrectionSettings + &setting, bool isTimeBased); /// Check if the user file has a valid user file extension bool hasUserFileValidFileExtension(); diff --git a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp index 4eb769e324841862cc09281e4056b48878b59d5a..a3e6cbf5d131c400fbc8f8c52c028893ba6bc32e 100644 --- a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp +++ b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp @@ -47,7 +47,7 @@ std::string extractFirstOf(std::string const &str, return str; } -void setYAxisLabels(WorkspaceGroup_sptr group, std::string const &unit, +void setYAxisLabels(const WorkspaceGroup_sptr &group, std::string const &unit, std::string const &axisLabel) { for (auto const &workspace : *group) { auto matrixWs = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); @@ -56,7 +56,8 @@ void setYAxisLabels(WorkspaceGroup_sptr group, std::string const &unit, } } -void convertSpectrumAxis(MatrixWorkspace_sptr workspace, double eFixed = 0.0) { +void convertSpectrumAxis(const MatrixWorkspace_sptr &workspace, + double eFixed = 0.0) { auto convertAlg = AlgorithmManager::Instance().create("ConvertSpectrumAxis"); convertAlg->initialize(); convertAlg->setProperty("InputWorkspace", workspace); @@ -68,7 +69,7 @@ void convertSpectrumAxis(MatrixWorkspace_sptr workspace, double eFixed = 0.0) { convertAlg->execute(); } -MatrixWorkspace_sptr convertUnits(MatrixWorkspace_sptr workspace, +MatrixWorkspace_sptr convertUnits(const MatrixWorkspace_sptr &workspace, std::string const &target) { auto convertAlg = AlgorithmManager::Instance().create("ConvertUnits"); convertAlg->initialize(); @@ -95,7 +96,7 @@ groupWorkspaces(std::vector<std::string> const &workspaceNames) { return groupAlg->getProperty("OutputWorkspace"); } -WorkspaceGroup_sptr convertUnits(WorkspaceGroup_sptr workspaceGroup, +WorkspaceGroup_sptr convertUnits(const WorkspaceGroup_sptr &workspaceGroup, std::string const &target) { std::vector<std::string> convertedNames; convertedNames.reserve(workspaceGroup->size()); @@ -299,8 +300,8 @@ void AbsorptionCorrections::run() { * @param alg Algorithm to set properties of * @param shape Sample shape */ -void AbsorptionCorrections::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, - QString shape) { +void AbsorptionCorrections::addShapeSpecificSampleOptions( + const IAlgorithm_sptr &alg, const QString &shape) { if (shape == "FlatPlate") { double const sampleHeight = m_uiForm.spFlatSampleHeight->value(); @@ -342,8 +343,8 @@ void AbsorptionCorrections::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, * @param alg Algorithm to set properties of * @param shape Sample shape */ -void AbsorptionCorrections::addShapeSpecificCanOptions(IAlgorithm_sptr alg, - QString const &shape) { +void AbsorptionCorrections::addShapeSpecificCanOptions( + const IAlgorithm_sptr &alg, QString const &shape) { if (shape == "FlatPlate") { double const canFrontThickness = m_uiForm.spFlatCanFrontThickness->value(); alg->setProperty("ContainerFrontThickness", canFrontThickness); @@ -470,7 +471,7 @@ void AbsorptionCorrections::processWavelengthWorkspace() { } void AbsorptionCorrections::convertSpectrumAxes( - WorkspaceGroup_sptr correctionsWs) { + const WorkspaceGroup_sptr &correctionsWs) { auto const sampleWsName = m_uiForm.dsSampleInput->getCurrentDataName().toStdString(); convertSpectrumAxes(correctionsWs, getADSMatrixWorkspace(sampleWsName)); @@ -478,7 +479,8 @@ void AbsorptionCorrections::convertSpectrumAxes( } void AbsorptionCorrections::convertSpectrumAxes( - WorkspaceGroup_sptr correctionsGroup, MatrixWorkspace_sptr sample) { + const WorkspaceGroup_sptr &correctionsGroup, + const MatrixWorkspace_sptr &sample) { for (auto const &workspace : *correctionsGroup) { auto const correction = boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); @@ -486,8 +488,9 @@ void AbsorptionCorrections::convertSpectrumAxes( } } -void AbsorptionCorrections::convertSpectrumAxes(MatrixWorkspace_sptr correction, - MatrixWorkspace_sptr sample) { +void AbsorptionCorrections::convertSpectrumAxes( + const MatrixWorkspace_sptr &correction, + const MatrixWorkspace_sptr &sample) { if (correction && sample && getEMode(sample) == "Indirect") { try { convertSpectrumAxis(correction, getEFixed(correction)); @@ -523,7 +526,7 @@ void AbsorptionCorrections::getParameterDefaults(QString const &dataName) { } void AbsorptionCorrections::getParameterDefaults( - Instrument_const_sptr instrument) { + const Instrument_const_sptr &instrument) { setBeamWidthValue(instrument, "Workflow.beam-width"); setBeamHeightValue(instrument, "Workflow.beam-height"); setWavelengthsValue(instrument, "Workflow.absorption-wavelengths"); @@ -533,7 +536,7 @@ void AbsorptionCorrections::getParameterDefaults( } void AbsorptionCorrections::setBeamWidthValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &beamWidthParamName) const { if (instrument->hasParameter(beamWidthParamName)) { auto const beamWidth = QString::fromStdString( @@ -544,7 +547,7 @@ void AbsorptionCorrections::setBeamWidthValue( } void AbsorptionCorrections::setBeamHeightValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &beamHeightParamName) const { if (instrument->hasParameter(beamHeightParamName)) { auto const beamHeight = QString::fromStdString( @@ -555,7 +558,7 @@ void AbsorptionCorrections::setBeamHeightValue( } void AbsorptionCorrections::setWavelengthsValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &wavelengthsParamName) const { if (instrument->hasParameter(wavelengthsParamName)) { auto const wavelengths = QString::fromStdString( @@ -566,7 +569,7 @@ void AbsorptionCorrections::setWavelengthsValue( } void AbsorptionCorrections::setEventsValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &eventsParamName) const { if (instrument->hasParameter(eventsParamName)) { auto const events = QString::fromStdString( @@ -577,7 +580,7 @@ void AbsorptionCorrections::setEventsValue( } void AbsorptionCorrections::setInterpolationValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &interpolationParamName) const { if (instrument->hasParameter(interpolationParamName)) { auto const interpolation = QString::fromStdString( @@ -589,7 +592,7 @@ void AbsorptionCorrections::setInterpolationValue( } void AbsorptionCorrections::setMaxAttemptsValue( - Instrument_const_sptr instrument, + const Instrument_const_sptr &instrument, std::string const &maxAttemptsParamName) const { if (instrument->hasParameter(maxAttemptsParamName)) { auto const maxScatterAttempts = QString::fromStdString( diff --git a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h index 330a2fdb9cfb0bc6878a561c0a3ef446f8be687a..fbac43c086653408fbc6a6f412d1879e5745314c 100644 --- a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h +++ b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.h @@ -51,31 +51,39 @@ private: void setFileExtensionsByName(bool filter) override; void addSaveWorkspace(std::string const &wsName); - void addShapeSpecificSampleOptions(Mantid::API::IAlgorithm_sptr alg, - QString shape); - void addShapeSpecificCanOptions(Mantid::API::IAlgorithm_sptr alg, + void addShapeSpecificSampleOptions(const Mantid::API::IAlgorithm_sptr &alg, + const QString &shape); + void addShapeSpecificCanOptions(const Mantid::API::IAlgorithm_sptr &alg, QString const &shape); void processWavelengthWorkspace(); - void convertSpectrumAxes(Mantid::API::WorkspaceGroup_sptr correctionsWs); - void convertSpectrumAxes(Mantid::API::WorkspaceGroup_sptr correctionsGroup, - Mantid::API::MatrixWorkspace_sptr sample); - void convertSpectrumAxes(Mantid::API::MatrixWorkspace_sptr correction, - Mantid::API::MatrixWorkspace_sptr sample); - - void getParameterDefaults(Mantid::Geometry::Instrument_const_sptr instrument); - void setBeamWidthValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &beamWidthParamName) const; - void setBeamHeightValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &beamHeightParamName) const; - void setWavelengthsValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &wavelengthsParamName) const; - void setEventsValue(Mantid::Geometry::Instrument_const_sptr instrument, + void + convertSpectrumAxes(const Mantid::API::WorkspaceGroup_sptr &correctionsWs); + void + convertSpectrumAxes(const Mantid::API::WorkspaceGroup_sptr &correctionsGroup, + const Mantid::API::MatrixWorkspace_sptr &sample); + void convertSpectrumAxes(const Mantid::API::MatrixWorkspace_sptr &correction, + const Mantid::API::MatrixWorkspace_sptr &sample); + + void getParameterDefaults( + const Mantid::Geometry::Instrument_const_sptr &instrument); + void + setBeamWidthValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &beamWidthParamName) const; + void + setBeamHeightValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &beamHeightParamName) const; + void + setWavelengthsValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &wavelengthsParamName) const; + void setEventsValue(const Mantid::Geometry::Instrument_const_sptr &instrument, std::string const &eventsParamName) const; - void setInterpolationValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &interpolationParamName) const; - void setMaxAttemptsValue(Mantid::Geometry::Instrument_const_sptr instrument, - std::string const &maxAttemptsParamName) const; + void setInterpolationValue( + const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &interpolationParamName) const; + void + setMaxAttemptsValue(const Mantid::Geometry::Instrument_const_sptr &instrument, + std::string const &maxAttemptsParamName) const; void setComboBoxOptions(QComboBox *combobox, std::vector<std::string> const &options); diff --git a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp index 86940d28ec0c0a00718e12c9a5e9ad8854c90a08..ba1fb9b74c69ddb92c865c6a409b42016a3efc2c 100644 --- a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp +++ b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp @@ -15,6 +15,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <QStringList> +#include <utility> using namespace IndirectDataValidationHelper; using namespace Mantid::API; @@ -370,9 +371,9 @@ void ApplyAbsorptionCorrections::run() { * @param toMatch Name of the workspace to match */ void ApplyAbsorptionCorrections::addInterpolationStep( - MatrixWorkspace_sptr toInterpolate, std::string toMatch) { + const MatrixWorkspace_sptr &toInterpolate, std::string toMatch) { API::BatchAlgorithmRunner::AlgorithmRuntimeProps interpolationProps; - interpolationProps["WorkspaceToMatch"] = toMatch; + interpolationProps["WorkspaceToMatch"] = std::move(toMatch); IAlgorithm_sptr interpolationAlg = AlgorithmManager::Instance().create("SplineInterpolation"); diff --git a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h index 30335c7cc610ac4bb4a7eaf31e940602adc6743f..13420b73c8f725f4aabcd5452c4bfaaec9617980 100644 --- a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h +++ b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.h @@ -47,8 +47,9 @@ private: void loadSettings(const QSettings &settings) override; void setFileExtensionsByName(bool filter) override; - void addInterpolationStep(Mantid::API::MatrixWorkspace_sptr toInterpolate, - std::string toMatch); + void + addInterpolationStep(const Mantid::API::MatrixWorkspace_sptr &toInterpolate, + std::string toMatch); void plotInPreview(const QString &curveName, Mantid::API::MatrixWorkspace_sptr &ws, const QColor &curveColor); diff --git a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp index 3e6ed6cd3861a1efdbe8f099b9f4cc754744fbf7..01166a226eb8fbff811ee2bd1e024de55aa9653c 100644 --- a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp +++ b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp @@ -572,7 +572,7 @@ void CalculatePaalmanPings::getBeamWidthFromWorkspace(const QString &wsName) { * boost::none. */ boost::optional<double> CalculatePaalmanPings::getInstrumentParameter( - Mantid::Geometry::Instrument_const_sptr instrument, + const Mantid::Geometry::Instrument_const_sptr &instrument, const std::string ¶meterName) { if (instrument->hasParameter(parameterName)) { @@ -589,8 +589,8 @@ boost::optional<double> CalculatePaalmanPings::getInstrumentParameter( * @param alg Algorithm to set properties of * @param shape Sample shape */ -void CalculatePaalmanPings::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, - QString shape) { +void CalculatePaalmanPings::addShapeSpecificSampleOptions( + const IAlgorithm_sptr &alg, const QString &shape) { if (shape == "FlatPlate") { const auto sampleThickness = m_uiForm.spFlatSampleThickness->value(); alg->setProperty("SampleThickness", sampleThickness); @@ -635,8 +635,8 @@ void CalculatePaalmanPings::addShapeSpecificSampleOptions(IAlgorithm_sptr alg, * @param alg Algorithm to set properties of * @param shape Sample shape */ -void CalculatePaalmanPings::addShapeSpecificCanOptions(IAlgorithm_sptr alg, - QString shape) { +void CalculatePaalmanPings::addShapeSpecificCanOptions( + const IAlgorithm_sptr &alg, const QString &shape) { if (shape == "FlatPlate") { const auto canFrontThickness = m_uiForm.spFlatCanFrontThickness->value(); alg->setProperty("CanFrontThickness", canFrontThickness); diff --git a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h index dda97d5a3b2a9538ba9f47a5a913e6f3c2639f8d..907f9490186b356f75568253b9aaa800f5910f4b 100644 --- a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h +++ b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.h @@ -51,10 +51,10 @@ private: bool doValidation(bool silent = false); - void addShapeSpecificSampleOptions(Mantid::API::IAlgorithm_sptr alg, - QString shape); - void addShapeSpecificCanOptions(Mantid::API::IAlgorithm_sptr alg, - QString shape); + void addShapeSpecificSampleOptions(const Mantid::API::IAlgorithm_sptr &alg, + const QString &shape); + void addShapeSpecificCanOptions(const Mantid::API::IAlgorithm_sptr &alg, + const QString &shape); void setComboBoxOptions(QComboBox *combobox, std::vector<std::string> const &options); @@ -71,9 +71,9 @@ private: void setButtonsEnabled(bool enabled); void setRunIsRunning(bool running); - boost::optional<double> - getInstrumentParameter(Mantid::Geometry::Instrument_const_sptr instrument, - const std::string ¶meterName); + boost::optional<double> getInstrumentParameter( + const Mantid::Geometry::Instrument_const_sptr &instrument, + const std::string ¶meterName); Ui::CalculatePaalmanPings m_uiForm; diff --git a/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp b/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp index 65bf7a458adeaacf2e0e0a3acfaeef224c68e7b1..d917718b4a219895dec728e8bbb3670f01c88d98 100644 --- a/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp +++ b/qt/scientific_interfaces/Indirect/ContainerSubtraction.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "ContainerSubtraction.h" + +#include <utility> + #include "MantidQtWidgets/Common/UserInputValidator.h" #include "MantidAPI/Axis.h" @@ -58,12 +61,12 @@ ContainerSubtraction::~ContainerSubtraction() { void ContainerSubtraction::setTransformedContainer( MatrixWorkspace_sptr workspace, const std::string &name) { - m_transformedContainerWS = workspace; + m_transformedContainerWS = std::move(workspace); AnalysisDataService::Instance().addOrReplace(name, m_transformedContainerWS); } void ContainerSubtraction::setTransformedContainer( - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { m_transformedContainerWS = workspace; AnalysisDataService::Instance().addOrReplace(workspace->getName(), m_transformedContainerWS); @@ -456,46 +459,48 @@ MatrixWorkspace_sptr ContainerSubtraction::requestRebinToSample( } MatrixWorkspace_sptr -ContainerSubtraction::shiftWorkspace(MatrixWorkspace_sptr workspace, +ContainerSubtraction::shiftWorkspace(const MatrixWorkspace_sptr &workspace, double shiftValue) const { - auto shiftAlg = shiftAlgorithm(workspace, shiftValue); + auto shiftAlg = shiftAlgorithm(std::move(workspace), shiftValue); shiftAlg->execute(); return shiftAlg->getProperty("OutputWorkspace"); } MatrixWorkspace_sptr -ContainerSubtraction::scaleWorkspace(MatrixWorkspace_sptr workspace, +ContainerSubtraction::scaleWorkspace(const MatrixWorkspace_sptr &workspace, double scaleValue) const { - auto scaleAlg = scaleAlgorithm(workspace, scaleValue); + auto scaleAlg = scaleAlgorithm(std::move(workspace), scaleValue); scaleAlg->execute(); return scaleAlg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr -ContainerSubtraction::minusWorkspace(MatrixWorkspace_sptr lhsWorkspace, - MatrixWorkspace_sptr rhsWorkspace) const { - auto minusAlg = minusAlgorithm(lhsWorkspace, rhsWorkspace); +MatrixWorkspace_sptr ContainerSubtraction::minusWorkspace( + const MatrixWorkspace_sptr &lhsWorkspace, + const MatrixWorkspace_sptr &rhsWorkspace) const { + auto minusAlg = + minusAlgorithm(std::move(lhsWorkspace), std::move(rhsWorkspace)); minusAlg->execute(); return minusAlg->getProperty("OutputWorkspace"); } MatrixWorkspace_sptr ContainerSubtraction::rebinToWorkspace( - MatrixWorkspace_sptr workspaceToRebin, - MatrixWorkspace_sptr workspaceToMatch) const { - auto rebinAlg = rebinToWorkspaceAlgorithm(workspaceToRebin, workspaceToMatch); + const MatrixWorkspace_sptr &workspaceToRebin, + const MatrixWorkspace_sptr &workspaceToMatch) const { + auto rebinAlg = rebinToWorkspaceAlgorithm(std::move(workspaceToRebin), + std::move(workspaceToMatch)); rebinAlg->execute(); return rebinAlg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr -ContainerSubtraction::convertToHistogram(MatrixWorkspace_sptr workspace) const { - auto convertAlg = convertToHistogramAlgorithm(workspace); +MatrixWorkspace_sptr ContainerSubtraction::convertToHistogram( + const MatrixWorkspace_sptr &workspace) const { + auto convertAlg = convertToHistogramAlgorithm(std::move(workspace)); convertAlg->execute(); return convertAlg->getProperty("OutputWorkspace"); } IAlgorithm_sptr -ContainerSubtraction::shiftAlgorithm(MatrixWorkspace_sptr workspace, +ContainerSubtraction::shiftAlgorithm(const MatrixWorkspace_sptr &workspace, double shiftValue) const { IAlgorithm_sptr shift = AlgorithmManager::Instance().create("ScaleX"); shift->initialize(); @@ -509,7 +514,7 @@ ContainerSubtraction::shiftAlgorithm(MatrixWorkspace_sptr workspace, } IAlgorithm_sptr -ContainerSubtraction::scaleAlgorithm(MatrixWorkspace_sptr workspace, +ContainerSubtraction::scaleAlgorithm(const MatrixWorkspace_sptr &workspace, double scaleValue) const { IAlgorithm_sptr scale = AlgorithmManager::Instance().create("Scale"); scale->initialize(); @@ -522,9 +527,9 @@ ContainerSubtraction::scaleAlgorithm(MatrixWorkspace_sptr workspace, return scale; } -IAlgorithm_sptr -ContainerSubtraction::minusAlgorithm(MatrixWorkspace_sptr lhsWorkspace, - MatrixWorkspace_sptr rhsWorkspace) const { +IAlgorithm_sptr ContainerSubtraction::minusAlgorithm( + const MatrixWorkspace_sptr &lhsWorkspace, + const MatrixWorkspace_sptr &rhsWorkspace) const { IAlgorithm_sptr minus = AlgorithmManager::Instance().create("Minus"); minus->initialize(); minus->setChild(true); @@ -536,8 +541,8 @@ ContainerSubtraction::minusAlgorithm(MatrixWorkspace_sptr lhsWorkspace, } IAlgorithm_sptr ContainerSubtraction::rebinToWorkspaceAlgorithm( - MatrixWorkspace_sptr workspaceToRebin, - MatrixWorkspace_sptr workspaceToMatch) const { + const MatrixWorkspace_sptr &workspaceToRebin, + const MatrixWorkspace_sptr &workspaceToMatch) const { IAlgorithm_sptr rebin = AlgorithmManager::Instance().create("RebinToWorkspace"); rebin->initialize(); @@ -550,7 +555,7 @@ IAlgorithm_sptr ContainerSubtraction::rebinToWorkspaceAlgorithm( } IAlgorithm_sptr ContainerSubtraction::convertToHistogramAlgorithm( - MatrixWorkspace_sptr workspace) const { + const MatrixWorkspace_sptr &workspace) const { IAlgorithm_sptr convert = AlgorithmManager::Instance().create("ConvertToHistogram"); convert->initialize(); @@ -562,7 +567,7 @@ IAlgorithm_sptr ContainerSubtraction::convertToHistogramAlgorithm( } IAlgorithm_sptr ContainerSubtraction::addSampleLogAlgorithm( - MatrixWorkspace_sptr workspace, const std::string &name, + const MatrixWorkspace_sptr &workspace, const std::string &name, const std::string &type, const std::string &value) const { IAlgorithm_sptr shiftLog = AlgorithmManager::Instance().create("AddSampleLog"); diff --git a/qt/scientific_interfaces/Indirect/ContainerSubtraction.h b/qt/scientific_interfaces/Indirect/ContainerSubtraction.h index 2a8a230b3baaaa0f683ae84a2c052fb501e467a7..2821e893d53ae4ff586185779b11eaf14e5143ba 100644 --- a/qt/scientific_interfaces/Indirect/ContainerSubtraction.h +++ b/qt/scientific_interfaces/Indirect/ContainerSubtraction.h @@ -20,7 +20,8 @@ public: void setTransformedContainer(Mantid::API::MatrixWorkspace_sptr workspace, const std::string &name); - void setTransformedContainer(Mantid::API::MatrixWorkspace_sptr workspace); + void + setTransformedContainer(const Mantid::API::MatrixWorkspace_sptr &workspace); private slots: /// Handles a new sample being loaded @@ -57,36 +58,36 @@ private: requestRebinToSample(Mantid::API::MatrixWorkspace_sptr workspace) const; Mantid::API::MatrixWorkspace_sptr - shiftWorkspace(Mantid::API::MatrixWorkspace_sptr workspace, + shiftWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace, double shiftValue) const; Mantid::API::MatrixWorkspace_sptr - scaleWorkspace(Mantid::API::MatrixWorkspace_sptr workspace, + scaleWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace, double scaleValue) const; Mantid::API::MatrixWorkspace_sptr - minusWorkspace(Mantid::API::MatrixWorkspace_sptr lhsWorkspace, - Mantid::API::MatrixWorkspace_sptr rhsWorkspace) const; + minusWorkspace(const Mantid::API::MatrixWorkspace_sptr &lhsWorkspace, + const Mantid::API::MatrixWorkspace_sptr &rhsWorkspace) const; + Mantid::API::MatrixWorkspace_sptr rebinToWorkspace( + const Mantid::API::MatrixWorkspace_sptr &workspaceToRebin, + const Mantid::API::MatrixWorkspace_sptr &workspaceToMatch) const; Mantid::API::MatrixWorkspace_sptr - rebinToWorkspace(Mantid::API::MatrixWorkspace_sptr workspaceToRebin, - Mantid::API::MatrixWorkspace_sptr workspaceToMatch) const; - Mantid::API::MatrixWorkspace_sptr - convertToHistogram(Mantid::API::MatrixWorkspace_sptr workspace) const; + convertToHistogram(const Mantid::API::MatrixWorkspace_sptr &workspace) const; Mantid::API::IAlgorithm_sptr - shiftAlgorithm(Mantid::API::MatrixWorkspace_sptr workspace, + shiftAlgorithm(const Mantid::API::MatrixWorkspace_sptr &workspace, double shiftValue) const; Mantid::API::IAlgorithm_sptr - scaleAlgorithm(Mantid::API::MatrixWorkspace_sptr workspace, + scaleAlgorithm(const Mantid::API::MatrixWorkspace_sptr &workspace, double scaleValue) const; Mantid::API::IAlgorithm_sptr - minusAlgorithm(Mantid::API::MatrixWorkspace_sptr lhsWorkspace, - Mantid::API::MatrixWorkspace_sptr rhsWorkspace) const; + minusAlgorithm(const Mantid::API::MatrixWorkspace_sptr &lhsWorkspace, + const Mantid::API::MatrixWorkspace_sptr &rhsWorkspace) const; Mantid::API::IAlgorithm_sptr rebinToWorkspaceAlgorithm( - Mantid::API::MatrixWorkspace_sptr workspaceToRebin, - Mantid::API::MatrixWorkspace_sptr workspaceToMatch) const; + const Mantid::API::MatrixWorkspace_sptr &workspaceToRebin, + const Mantid::API::MatrixWorkspace_sptr &workspaceToMatch) const; Mantid::API::IAlgorithm_sptr convertToHistogramAlgorithm( - Mantid::API::MatrixWorkspace_sptr workspace) const; + const Mantid::API::MatrixWorkspace_sptr &workspace) const; Mantid::API::IAlgorithm_sptr - addSampleLogAlgorithm(Mantid::API::MatrixWorkspace_sptr workspace, + addSampleLogAlgorithm(const Mantid::API::MatrixWorkspace_sptr &workspace, const std::string &name, const std::string &type, const std::string &value) const; diff --git a/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp b/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp index ddfc5f938782041db8c7c19d5781f0602443cadb..16f7e273429bb9e9b99131919624fb0c48b21895 100644 --- a/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp +++ b/qt/scientific_interfaces/Indirect/ConvFitAddWorkspaceDialog.cpp @@ -11,6 +11,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <boost/optional.hpp> +#include <utility> namespace { using namespace Mantid::API; @@ -27,7 +28,8 @@ bool validWorkspace(std::string const &name) { return !name.empty() && doesExistInADS(name); } -boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { +boost::optional<std::size_t> +maximumIndex(const MatrixWorkspace_sptr &workspace) { if (workspace) { const auto numberOfHistograms = workspace->getNumberHistograms(); if (numberOfHistograms > 0) @@ -36,8 +38,8 @@ boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { return boost::none; } -QString getIndexString(MatrixWorkspace_sptr workspace) { - const auto maximum = maximumIndex(workspace); +QString getIndexString(const MatrixWorkspace_sptr &workspace) { + const auto maximum = maximumIndex(std::move(workspace)); if (maximum) return QString("0-%1").arg(*maximum); return ""; diff --git a/qt/scientific_interfaces/Indirect/ConvFitModel.cpp b/qt/scientific_interfaces/Indirect/ConvFitModel.cpp index 2c10111356b36fdc28f3f3ef9618ef7eb99cb7f0..8e2af45fa01a33eca3b490fd30e69a91c766ac53 100644 --- a/qt/scientific_interfaces/Indirect/ConvFitModel.cpp +++ b/qt/scientific_interfaces/Indirect/ConvFitModel.cpp @@ -14,6 +14,7 @@ #include <boost/algorithm/string/join.hpp> #include <stdexcept> +#include <utility> using namespace Mantid::API; @@ -38,7 +39,7 @@ IAlgorithm_sptr loadParameterFileAlgorithm(std::string const &workspaceName, } void readAnalyserFromFile(const std::string &analyser, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto const instrument = workspace->getInstrument(); auto const idfDirectory = Mantid::Kernel::ConfigService::Instance().getString( "instrumentDefinition.directory"); @@ -57,7 +58,7 @@ void readAnalyserFromFile(const std::string &analyser, } Mantid::Geometry::IComponent_const_sptr -getAnalyser(MatrixWorkspace_sptr workspace) { +getAnalyser(const MatrixWorkspace_sptr &workspace) { auto const instrument = workspace->getInstrument(); auto const analysers = instrument->getStringParameter("analyser"); @@ -79,7 +80,8 @@ getAnalyser(MatrixWorkspace_sptr workspace) { return instrument->getComponentByName(analysers[0]); } -boost::optional<double> instrumentResolution(MatrixWorkspace_sptr workspace) { +boost::optional<double> +instrumentResolution(const MatrixWorkspace_sptr &workspace) { try { auto const analyser = getAnalyser(workspace); if (analyser && analyser->hasParameter("resolution")) @@ -101,7 +103,7 @@ boost::optional<double> instrumentResolution(MatrixWorkspace_sptr workspace) { } } -MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr inputWS, +MatrixWorkspace_sptr cloneWorkspace(const MatrixWorkspace_sptr &inputWS, std::string const &outputName) { auto cloneAlg = AlgorithmManager::Instance().create("CloneWorkspace"); cloneAlg->setLogging(false); @@ -112,8 +114,8 @@ MatrixWorkspace_sptr cloneWorkspace(MatrixWorkspace_sptr inputWS, return getADSMatrixWorkspace(outputName); } -MatrixWorkspace_sptr appendWorkspace(MatrixWorkspace_sptr leftWS, - MatrixWorkspace_sptr rightWS, +MatrixWorkspace_sptr appendWorkspace(const MatrixWorkspace_sptr &leftWS, + const MatrixWorkspace_sptr &rightWS, int numHistograms, std::string const &outputName) { auto appendAlg = AlgorithmManager::Instance().create("AppendSpectra"); @@ -144,7 +146,7 @@ void deleteWorkspace(std::string const &workspaceName) { deleter->execute(); } -void extendResolutionWorkspace(MatrixWorkspace_sptr resolution, +void extendResolutionWorkspace(const MatrixWorkspace_sptr &resolution, std::size_t numberOfHistograms, std::string const &outputName) { const auto resolutionNumHist = resolution->getNumberHistograms(); @@ -257,7 +259,7 @@ constructParameterNameChanges(const IFunction &model, } } -IAlgorithm_sptr addSampleLogAlgorithm(Workspace_sptr workspace, +IAlgorithm_sptr addSampleLogAlgorithm(const Workspace_sptr &workspace, const std::string &name, const std::string &text, const std::string &type) { @@ -273,7 +275,8 @@ IAlgorithm_sptr addSampleLogAlgorithm(Workspace_sptr workspace, struct AddSampleLogRunner { AddSampleLogRunner(Workspace_sptr resultWorkspace, WorkspaceGroup_sptr resultGroup) - : m_resultWorkspace(resultWorkspace), m_resultGroup(resultGroup) {} + : m_resultWorkspace(std::move(resultWorkspace)), + m_resultGroup(std::move(resultGroup)) {} void operator()(const std::string &name, const std::string &text, const std::string &type) { @@ -291,15 +294,15 @@ getNames(const MantidQt::CustomInterfaces::IDA::ResolutionCollectionType &workspaces) { std::vector<std::string> names; names.reserve(workspaces.size().value); - std::transform(workspaces.begin(), workspaces.end(), - std::back_inserter(names), - [](boost::weak_ptr<Mantid::API::MatrixWorkspace> workspace) { - return workspace.lock()->getName(); - }); + std::transform( + workspaces.begin(), workspaces.end(), std::back_inserter(names), + [](const boost::weak_ptr<Mantid::API::MatrixWorkspace> &workspace) { + return workspace.lock()->getName(); + }); return names; } -void setResolutionAttribute(CompositeFunction_sptr convolutionModel, +void setResolutionAttribute(const CompositeFunction_sptr &convolutionModel, const IFunction::Attribute &attr) { if (convolutionModel->name() == "Convolution") convolutionModel->getFunction(0)->setAttribute("Workspace", attr); @@ -425,7 +428,7 @@ void ConvFitModel::setResolution(const std::string &name, throw std::runtime_error("A valid resolution file needs to be selected."); } -void ConvFitModel::setResolution(MatrixWorkspace_sptr resolution, +void ConvFitModel::setResolution(const MatrixWorkspace_sptr &resolution, TableDatasetIndex index) { if (m_resolution.size() > index) m_resolution[index] = resolution; @@ -556,7 +559,7 @@ void ConvFitModel::addOutput(IndirectFitOutput *fitOutput, void ConvFitModel::setParameterNameChanges( const IFunction &model, boost::optional<std::size_t> backgroundIndex) { m_parameterNameChanges = constructParameterNameChanges( - model, backgroundIndex, m_temperature.is_initialized()); + model, std::move(backgroundIndex), m_temperature.is_initialized()); } std::vector<std::pair<std::string, int>> diff --git a/qt/scientific_interfaces/Indirect/ConvFitModel.h b/qt/scientific_interfaces/Indirect/ConvFitModel.h index 7779f69264256ef0d8c9cd36bd8b17185c640659..c1e01b72876984760f4fbf97d7c8c7c81b1944ef 100644 --- a/qt/scientific_interfaces/Indirect/ConvFitModel.h +++ b/qt/scientific_interfaces/Indirect/ConvFitModel.h @@ -41,7 +41,7 @@ public: const Spectra &spectra) override; void removeWorkspace(TableDatasetIndex index) override; void setResolution(const std::string &name, TableDatasetIndex index); - void setResolution(Mantid::API::MatrixWorkspace_sptr resolution, + void setResolution(const Mantid::API::MatrixWorkspace_sptr &resolution, TableDatasetIndex index); void setFitTypeString(const std::string &fitType); diff --git a/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp b/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp index 20f11e3de5e34d0b37ce2d58ab8ac0605d9d16c5..4e0918d4721826aa247bf0c2faa7dffb9aae52d6 100644 --- a/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp +++ b/qt/scientific_interfaces/Indirect/CorrectionsTab.cpp @@ -74,7 +74,8 @@ void CorrectionsTab::inputChanged() { validate(); } * @throws std::runtime_error if one of the workspaces is an invalid pointer */ bool CorrectionsTab::checkWorkspaceBinningMatches( - MatrixWorkspace_const_sptr left, MatrixWorkspace_const_sptr right) { + const MatrixWorkspace_const_sptr &left, + const MatrixWorkspace_const_sptr &right) { if (left && right) // check the workspaces actually point to something first { const auto &leftX = left->x(0); @@ -100,7 +101,7 @@ bool CorrectionsTab::checkWorkspaceBinningMatches( * @return Name of output workspace */ boost::optional<std::string> CorrectionsTab::addConvertUnitsStep( - MatrixWorkspace_sptr ws, std::string const &unitID, + const MatrixWorkspace_sptr &ws, std::string const &unitID, std::string const &suffix, std::string eMode, double eFixed) { std::string outputName = ws->getName(); diff --git a/qt/scientific_interfaces/Indirect/CorrectionsTab.h b/qt/scientific_interfaces/Indirect/CorrectionsTab.h index c26de73e64e36d64fea6d9b551cb04c2d0a52161..665934445bcc4a3edcbe1dd214e93006743fd849 100644 --- a/qt/scientific_interfaces/Indirect/CorrectionsTab.h +++ b/qt/scientific_interfaces/Indirect/CorrectionsTab.h @@ -84,12 +84,12 @@ public: protected: /// Check the binning between two workspaces match - bool - checkWorkspaceBinningMatches(Mantid::API::MatrixWorkspace_const_sptr left, - Mantid::API::MatrixWorkspace_const_sptr right); + bool checkWorkspaceBinningMatches( + const Mantid::API::MatrixWorkspace_const_sptr &left, + const Mantid::API::MatrixWorkspace_const_sptr &right); /// Adds a unit conversion step to the algorithm queue boost::optional<std::string> - addConvertUnitsStep(Mantid::API::MatrixWorkspace_sptr ws, + addConvertUnitsStep(const Mantid::API::MatrixWorkspace_sptr &ws, const std::string &unitID, const std::string &suffix = "UNIT", std::string eMode = "", double eFixed = 0.0); diff --git a/qt/scientific_interfaces/Indirect/Elwin.cpp b/qt/scientific_interfaces/Indirect/Elwin.cpp index d25764868d2af036ae9a1d7863bd30a51b3baea0..93bece3aef0dadd4e4e24ea08a49bf518b33fd79 100644 --- a/qt/scientific_interfaces/Indirect/Elwin.cpp +++ b/qt/scientific_interfaces/Indirect/Elwin.cpp @@ -384,8 +384,9 @@ void Elwin::setFileExtensionsByName(bool filter) { : getExtensions(tabName)); } -void Elwin::setDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws, - const QPair<double, double> &range) { +void Elwin::setDefaultResolution( + const Mantid::API::MatrixWorkspace_const_sptr &ws, + const QPair<double, double> &range) { auto inst = ws->getInstrument(); auto analyser = inst->getStringParameter("analyser"); @@ -414,7 +415,8 @@ void Elwin::setDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws, } } -void Elwin::setDefaultSampleLog(Mantid::API::MatrixWorkspace_const_sptr ws) { +void Elwin::setDefaultSampleLog( + const Mantid::API::MatrixWorkspace_const_sptr &ws) { auto inst = ws->getInstrument(); // Set sample environment log name auto log = inst->getStringParameter("Workflow.SE-log"); diff --git a/qt/scientific_interfaces/Indirect/Elwin.h b/qt/scientific_interfaces/Indirect/Elwin.h index 0c66b5b6805645f5c0e37be30410246314f57b9f..40a87b96c83f3d9eab47a06b5b10efe91b7d1cab 100644 --- a/qt/scientific_interfaces/Indirect/Elwin.h +++ b/qt/scientific_interfaces/Indirect/Elwin.h @@ -40,9 +40,9 @@ private: void loadSettings(const QSettings &settings) override; void setFileExtensionsByName(bool filter) override; void setBrowserWorkspace() override{}; - void setDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws, + void setDefaultResolution(const Mantid::API::MatrixWorkspace_const_sptr &ws, const QPair<double, double> &range); - void setDefaultSampleLog(Mantid::API::MatrixWorkspace_const_sptr ws); + void setDefaultSampleLog(const Mantid::API::MatrixWorkspace_const_sptr &ws); void checkForELTWorkspace(); diff --git a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp index bb56ecc89ac898a31cabbb28e7ae0f7700f7fbab..6da405dd977e1510631c9656e1c4cb393a9ec467 100644 --- a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp +++ b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.cpp @@ -386,8 +386,8 @@ void ILLEnergyTransfer::setRunEnabled(bool enabled) { void ILLEnergyTransfer::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { UNUSED_ARG(enableOutputButtons); setRunEnabled(enabled); m_uiForm.pbRun->setText(message); diff --git a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h index c7f253575a4f14e4b721877fa56e78846d4f4090..3ac3e459575fa4b99278b0d04455f98dbd702b94 100644 --- a/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h +++ b/qt/scientific_interfaces/Indirect/ILLEnergyTransfer.h @@ -39,8 +39,8 @@ private slots: void setRunEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: Ui::ILLEnergyTransfer m_uiForm; diff --git a/qt/scientific_interfaces/Indirect/ISISCalibration.cpp b/qt/scientific_interfaces/Indirect/ISISCalibration.cpp index d4b0a47ae2657d118b9b66f24e46f19387ef27da..fb906d2b395162ec0dc1a1e4f23e974fe4c09d92 100644 --- a/qt/scientific_interfaces/Indirect/ISISCalibration.cpp +++ b/qt/scientific_interfaces/Indirect/ISISCalibration.cpp @@ -522,7 +522,8 @@ void ISISCalibration::calPlotEnergy() { * * @param ws :: Mantid workspace containing the loaded instrument */ -void ISISCalibration::calSetDefaultResolution(MatrixWorkspace_const_sptr ws) { +void ISISCalibration::calSetDefaultResolution( + const MatrixWorkspace_const_sptr &ws) { auto inst = ws->getInstrument(); auto analyser = inst->getStringParameter("analyser"); @@ -816,8 +817,8 @@ void ISISCalibration::setSaveEnabled(bool enabled) { void ISISCalibration::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/ISISCalibration.h b/qt/scientific_interfaces/Indirect/ISISCalibration.h index 945cce8711717fcdb3244dda3bf13f8161a21793..1aa3634d6c230ccc5d8b8db5595b045aa0cd9680 100644 --- a/qt/scientific_interfaces/Indirect/ISISCalibration.h +++ b/qt/scientific_interfaces/Indirect/ISISCalibration.h @@ -56,7 +56,8 @@ private slots: void calMinChanged(double /*val*/); void calMaxChanged(double /*val*/); void calUpdateRS(QtProperty * /*prop*/, double /*val*/); - void calSetDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws); + void + calSetDefaultResolution(const Mantid::API::MatrixWorkspace_const_sptr &ws); void resCheck(bool state); ///< handles checking/unchecking of "Create RES /// File" checkbox void setDefaultInstDetails(); @@ -73,8 +74,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setDefaultInstDetails(QMap<QString, QString> const &instrumentDetails); diff --git a/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp b/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp index a238b385ee1b78a97ef12de870258cbdd7d8f3ed..df670758704a45bc0565008083b6efd6e99c69b8 100644 --- a/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp +++ b/qt/scientific_interfaces/Indirect/ISISDiagnostics.cpp @@ -561,8 +561,8 @@ void ISISDiagnostics::setSaveEnabled(bool enabled) { void ISISDiagnostics::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/ISISDiagnostics.h b/qt/scientific_interfaces/Indirect/ISISDiagnostics.h index e40fd3f1f6890af1f95cbbc84716c4786e337ccd..05cb96df8ed99bc7dfe682761f2bb765eeae3621 100644 --- a/qt/scientific_interfaces/Indirect/ISISDiagnostics.h +++ b/qt/scientific_interfaces/Indirect/ISISDiagnostics.h @@ -69,8 +69,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setDefaultInstDetails(QMap<QString, QString> const &instrumentDetails); diff --git a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp index 24c5e4b661d1cadf442bfc4b00d492bf777269b9..71bf58cb7d69dec92a7507df1729b400e167c591 100644 --- a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp +++ b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp @@ -115,7 +115,7 @@ void deleteWorkspace(std::string const &name) { deleter->execute(); } -double getSampleLog(MatrixWorkspace_const_sptr workspace, +double getSampleLog(const MatrixWorkspace_const_sptr &workspace, std::string const &logName, double const &defaultValue) { try { return workspace->getLogAsSingleValue(logName); @@ -124,7 +124,7 @@ double getSampleLog(MatrixWorkspace_const_sptr workspace, } } -double getSampleLog(MatrixWorkspace_const_sptr workspace, +double getSampleLog(const MatrixWorkspace_const_sptr &workspace, std::vector<std::string> const &logNames, double const &defaultValue) { double value(defaultValue); @@ -1014,8 +1014,8 @@ void ISISEnergyTransfer::setSaveEnabled(bool enable) { void ISISEnergyTransfer::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h index c0b547acf0c4ee3825e8feecca75c377f930872e..3dfcca5b65964320f1ea7ad38e5c213c81552b1a 100644 --- a/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h +++ b/qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h @@ -60,8 +60,8 @@ private slots: void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setInstrumentDefault(QMap<QString, QString> const &instDetails); diff --git a/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp b/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp index 3fe56ac1f40f36d69d4ea2d64e326a81f2b5cd82..9917de6f81633485fb416e6579323ad942267bfa 100644 --- a/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectAddWorkspaceDialog.cpp @@ -10,6 +10,7 @@ #include "MantidAPI/MatrixWorkspace.h" #include <boost/optional.hpp> +#include <utility> namespace { using namespace Mantid::API; @@ -26,7 +27,8 @@ bool validWorkspace(std::string const &name) { return !name.empty() && doesExistInADS(name); } -boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { +boost::optional<std::size_t> +maximumIndex(const MatrixWorkspace_sptr &workspace) { if (workspace) { const auto numberOfHistograms = workspace->getNumberHistograms(); if (numberOfHistograms > 0) @@ -35,8 +37,8 @@ boost::optional<std::size_t> maximumIndex(MatrixWorkspace_sptr workspace) { return boost::none; } -QString getIndexString(MatrixWorkspace_sptr workspace) { - const auto maximum = maximumIndex(workspace); +QString getIndexString(const MatrixWorkspace_sptr &workspace) { + const auto maximum = maximumIndex(std::move(workspace)); if (maximum) { if (*maximum > 0) return QString("0-%1").arg(*maximum); diff --git a/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp b/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp index 050001f810f021eeaa47d54d14015cf47e2eb011..8d7484a3a3f81e6868d9deaa9841100fab83ddcf 100644 --- a/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp @@ -14,6 +14,7 @@ IndirectBayesTab::IndirectBayesTab(QWidget *parent) m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac); connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, + // cppcheck-suppress pureVirtualCall SLOT(updateProperties(QtProperty *, double))); } diff --git a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp index a1709e90c81db1ed5d26bbdb39feac1a8f6180b8..ff7996578005feba4f433f1de35a31c00d5f8594 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.cpp @@ -15,6 +15,7 @@ #include <QSettings> #include <QString> +#include <utility> using namespace Mantid::API; @@ -92,7 +93,7 @@ MatrixWorkspace_sptr IndirectDataAnalysisTab::inputWorkspace() const { */ void IndirectDataAnalysisTab::setInputWorkspace( MatrixWorkspace_sptr inputWorkspace) { - m_inputWorkspace = inputWorkspace; + m_inputWorkspace = std::move(inputWorkspace); } /** @@ -113,7 +114,7 @@ MatrixWorkspace_sptr IndirectDataAnalysisTab::previewPlotWorkspace() { * @param previewPlotWorkspace The workspace to set. */ void IndirectDataAnalysisTab::setPreviewPlotWorkspace( - MatrixWorkspace_sptr previewPlotWorkspace) { + const MatrixWorkspace_sptr &previewPlotWorkspace) { m_previewPlotWorkspace = previewPlotWorkspace; } @@ -262,7 +263,7 @@ void IndirectDataAnalysisTab::updatePlot( * @param diffPreviewPlot The difference preview plot. */ void IndirectDataAnalysisTab::updatePlot( - WorkspaceGroup_sptr outputWS, size_t index, + const WorkspaceGroup_sptr &outputWS, size_t index, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot) { // Check whether the specified index is within the bounds of the @@ -318,7 +319,7 @@ void IndirectDataAnalysisTab::updatePlot( * @param diffPreviewPlot The difference preview plot. */ void IndirectDataAnalysisTab::updatePlot( - WorkspaceGroup_sptr outputWS, + const WorkspaceGroup_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot) { if (outputWS && selectedSpectrum() >= minimumSpectrum() && @@ -339,7 +340,7 @@ void IndirectDataAnalysisTab::updatePlot( * @param diffPreviewPlot The difference preview plot. */ void IndirectDataAnalysisTab::updatePlot( - MatrixWorkspace_sptr outputWS, + const MatrixWorkspace_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot) { fitPreviewPlot->clear(); diff --git a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h index 9c2b956c77fd33308c167bf966062a993237e362..beb59db18d80a1d1daf5cd98d6fc724f252291f2 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectDataAnalysisTab.h @@ -90,7 +90,7 @@ protected: /// Set preview plot workspace void setPreviewPlotWorkspace( - Mantid::API::MatrixWorkspace_sptr previewPlotWorkspace); + const Mantid::API::MatrixWorkspace_sptr &previewPlotWorkspace); /// Retrieve the selected spectrum int selectedSpectrum() const; @@ -110,11 +110,12 @@ protected: MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); - void updatePlot(Mantid::API::WorkspaceGroup_sptr workspaceGroup, size_t index, + void updatePlot(const Mantid::API::WorkspaceGroup_sptr &workspaceGroup, + size_t index, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); - void updatePlot(Mantid::API::WorkspaceGroup_sptr outputWS, + void updatePlot(const Mantid::API::WorkspaceGroup_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); @@ -122,7 +123,7 @@ protected: MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); - void updatePlot(Mantid::API::MatrixWorkspace_sptr outputWS, + void updatePlot(const Mantid::API::MatrixWorkspace_sptr &outputWS, MantidQt::MantidWidgets::PreviewPlot *fitPreviewPlot, MantidQt::MantidWidgets::PreviewPlot *diffPreviewPlot); diff --git a/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp b/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp index e785ece295abd8a11768ec4ce49dd3d9bc535a93..61b659e070469ecb332a0382c298d28c3f386424 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp @@ -316,7 +316,8 @@ void IndirectDataReduction::loadInstrumentDetails() { * @return Value as QString */ QString IndirectDataReduction::getInstrumentParameterFrom( - Mantid::Geometry::IComponent_const_sptr comp, std::string param) { + const Mantid::Geometry::IComponent_const_sptr &comp, + const std::string ¶m) { QString value; if (!comp->hasParameter(param)) { @@ -445,7 +446,7 @@ void IndirectDataReduction::saveSettings() { * * @param facility Name of facility */ -void IndirectDataReduction::filterUiForFacility(QString facility) { +void IndirectDataReduction::filterUiForFacility(const QString &facility) { g_log.information() << "Facility selected: " << facility.toStdString() << '\n'; QStringList enabledTabs; diff --git a/qt/scientific_interfaces/Indirect/IndirectDataReduction.h b/qt/scientific_interfaces/Indirect/IndirectDataReduction.h index 9cd0cbfbba9749736b19018993d942b95e9d1681..582b93441d3b6f16bf63f87818e23e7863b3f85e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataReduction.h +++ b/qt/scientific_interfaces/Indirect/IndirectDataReduction.h @@ -69,7 +69,7 @@ signals: private slots: /// Shows/hides tabs based on facility - void filterUiForFacility(QString facility); + void filterUiForFacility(const QString &facility); /// Exports the current tab algorithms as a Python script void exportTabPython(); @@ -89,9 +89,9 @@ private: void loadInstrumentDetails(); - QString - getInstrumentParameterFrom(Mantid::Geometry::IComponent_const_sptr comp, - std::string param); + QString getInstrumentParameterFrom( + const Mantid::Geometry::IComponent_const_sptr &comp, + const std::string ¶m); void readSettings(); void saveSettings(); diff --git a/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp index eafa0818ac2602c7720bc0e980956fd4a3c0cc5c..3039804bcef9a0a3ee99b0f86988a388e6616e3e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataTablePresenter.cpp @@ -216,11 +216,11 @@ IndirectDataTablePresenter::getSpectra(TableRowIndex start, while (start < end) { WorkspaceIndex minimum = getWorkspaceIndex(start); WorkspaceIndex maximum = minimum; - start++; + ++start; while (start < end && getWorkspaceIndex(start) == maximum + WorkspaceIndex{1}) { ++maximum; - start++; + ++start; } spectraPairs.emplace_back(minimum, maximum); } diff --git a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp index e40aa619cc172ce040e69f839462a780a2966c09..6ae644b2f730c022931243fe0840e34e7c3d3e72 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp @@ -354,8 +354,8 @@ IAlgorithm_sptr IndirectDiffractionReduction::convertUnitsAlgorithm( * @param instName Name of the instrument * @param mode Mode instrument is operating in (diffspec/diffonly) */ -void IndirectDiffractionReduction::runGenericReduction(QString instName, - QString mode) { +void IndirectDiffractionReduction::runGenericReduction(const QString &instName, + const QString &mode) { QString rebinStart = ""; QString rebinWidth = ""; diff --git a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h index 03c119a5a6f15a0a08c62529797480df7dae62f2..8e9e8aafd85849fa8a3458d7d3e9b12e52abfe54 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h +++ b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.h @@ -79,7 +79,7 @@ private: loadInstrument(const std::string &instrumentName, const std::string &reflection = ""); - void runGenericReduction(QString instName, QString mode); + void runGenericReduction(const QString &instName, const QString &mode); void connectRunButtonValidation(const MantidQt::API::MWRunFiles *file_field); void runOSIRISdiffonlyReduction(); void createGroupingWorkspace(const std::string &outputWsName); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp index d87a94d8b5f13542c170ba9fcd36c6b681f396f7..4c4793df70b4e6c6751bc9779bd44e1451af1812 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.cpp @@ -19,6 +19,7 @@ #include <QtCore> #include <algorithm> +#include <utility> /// Logger Mantid::Kernel::Logger g_log("IndirectFitAnalysisTab"); @@ -643,7 +644,7 @@ void IndirectFitAnalysisTab::setEditResultVisible(bool visible) { } void IndirectFitAnalysisTab::setAlgorithmProperties( - IAlgorithm_sptr fitAlgorithm) const { + const IAlgorithm_sptr &fitAlgorithm) const { fitAlgorithm->setProperty("Minimizer", m_fitPropertyBrowser->minimizer(true)); fitAlgorithm->setProperty("MaxIterations", m_fitPropertyBrowser->maxIterations()); @@ -674,14 +675,14 @@ void IndirectFitAnalysisTab::setAlgorithmProperties( void IndirectFitAnalysisTab::runFitAlgorithm(IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } void IndirectFitAnalysisTab::runSingleFit(IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateSingleFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h index d18221f9fcbe6315f8000cca6a304b532798dce6..001d4335225586f3044943a968874f1b9003f65d 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTab.h @@ -71,7 +71,8 @@ protected: void setSampleSuffixes(std::string const &tab, bool filter); void setResolutionSuffixes(std::string const &tab, bool filter); - void setAlgorithmProperties(Mantid::API::IAlgorithm_sptr fitAlgorithm) const; + void setAlgorithmProperties( + const Mantid::API::IAlgorithm_sptr &fitAlgorithm) const; void runFitAlgorithm(Mantid::API::IAlgorithm_sptr fitAlgorithm); void runSingleFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); virtual void setupFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp index bc22a7f659a9eefea54ba620098e15654f3d2b3a..02d0163c5e8e5afb4fff36f80fe9d293ca31d026 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.cpp @@ -21,6 +21,7 @@ #include <QtCore> #include <algorithm> +#include <utility> using namespace Mantid::API; @@ -37,7 +38,7 @@ WorkspaceGroup_sptr getADSGroupWorkspace(std::string const &workspaceName) { } void updateParameters( - IFunction_sptr function, + const IFunction_sptr &function, std::unordered_map<std::string, ParameterValueLegacy> const ¶meters) { for (auto i = 0u; i < function->nParams(); ++i) { auto const value = parameters.find(function->parameterName(i)); @@ -50,7 +51,8 @@ void updateParameters( } void updateAttributes( - IFunction_sptr function, std::vector<std::string> const &attributeNames, + const IFunction_sptr &function, + std::vector<std::string> const &attributeNames, std::unordered_map<std::string, IFunction::Attribute> const &attributes) { for (const auto &attributeName : attributeNames) { auto const value = attributes.find(attributeName); @@ -807,17 +809,19 @@ void IndirectFitAnalysisTabLegacy::updateAttributeValues() { * @param attributeNames The attributes to update */ void IndirectFitAnalysisTabLegacy::updateAttributeValues( - IFunction_sptr function, std::vector<std::string> const &attributeNames) { + const IFunction_sptr &function, + std::vector<std::string> const &attributeNames) { auto const attributes = getAttributes(function, attributeNames); if (!attributes.empty()) updateAttributeValues(function, attributeNames, attributes); } void IndirectFitAnalysisTabLegacy::updateAttributeValues( - IFunction_sptr fitFunction, std::vector<std::string> const &attributeNames, + const IFunction_sptr &fitFunction, + std::vector<std::string> const &attributeNames, std::unordered_map<std::string, IFunction::Attribute> const &attributes) { try { - updateAttributes(fitFunction, attributeNames, attributes); + updateAttributes(std::move(fitFunction), attributeNames, attributes); updateFitBrowserAttributeValues(); } catch (const std::runtime_error &) { showMessageBox("An unexpected error occured:\n The setting of attribute " @@ -1067,7 +1071,7 @@ void IndirectFitAnalysisTabLegacy::setEditResultVisible(bool visible) { } void IndirectFitAnalysisTabLegacy::setAlgorithmProperties( - IAlgorithm_sptr fitAlgorithm) const { + const IAlgorithm_sptr &fitAlgorithm) const { fitAlgorithm->setProperty("Minimizer", m_fitPropertyBrowser->minimizer(true)); fitAlgorithm->setProperty("MaxIterations", m_fitPropertyBrowser->maxIterations()); @@ -1094,14 +1098,14 @@ void IndirectFitAnalysisTabLegacy::runFitAlgorithm( IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } void IndirectFitAnalysisTabLegacy::runSingleFit(IAlgorithm_sptr fitAlgorithm) { connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(updateSingleFitOutput(bool))); - setupFit(fitAlgorithm); + setupFit(std::move(fitAlgorithm)); m_batchAlgoRunner->executeBatchAsync(); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h index afcd92bf5275fd8a90e00fedc3c5ecafaa89c05c..0deb72aedee5bfbe11213310bac15a59038ff50a 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitAnalysisTabLegacy.h @@ -131,7 +131,8 @@ protected: void setResolutionWSSuffixes(const QStringList &suffices); void setResolutionFBSuffixes(const QStringList &suffices); - void setAlgorithmProperties(Mantid::API::IAlgorithm_sptr fitAlgorithm) const; + void setAlgorithmProperties( + const Mantid::API::IAlgorithm_sptr &fitAlgorithm) const; void runFitAlgorithm(Mantid::API::IAlgorithm_sptr fitAlgorithm); void runSingleFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); virtual void setupFit(Mantid::API::IAlgorithm_sptr fitAlgorithm); @@ -176,10 +177,10 @@ protected slots: void executeFit(); void updateAttributeValues(); - void updateAttributeValues(Mantid::API::IFunction_sptr function, + void updateAttributeValues(const Mantid::API::IFunction_sptr &function, std::vector<std::string> const &attributeNames); void updateAttributeValues( - Mantid::API::IFunction_sptr function, + const Mantid::API::IFunction_sptr &function, std::vector<std::string> const &attributeNames, std::unordered_map<std::string, Mantid::API::IFunction::Attribute> const &attributes); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitData.cpp b/qt/scientific_interfaces/Indirect/IndirectFitData.cpp index f81b02c69a2b0ac7e1424f35827b051a74fe9fda..d3cddcda4766c4d18cf2a7c21cc1bac2199bd367 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitData.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitData.cpp @@ -29,7 +29,7 @@ using namespace Mantid::Kernel::Strings; * them. * @param workspace workspace possibly containing Q values. */ -std::vector<double> extractQValues(const MatrixWorkspace_sptr workspace, +std::vector<double> extractQValues(const MatrixWorkspace_sptr &workspace, const Spectra &spectra) { std::vector<double> qs; // Check if the vertical axis has units of momentum transfer, then extract Q @@ -143,7 +143,7 @@ tryPassFormatArgument(boost::basic_format<char> &formatString, } } -std::pair<double, double> getBinRange(MatrixWorkspace_sptr workspace) { +std::pair<double, double> getBinRange(const MatrixWorkspace_sptr &workspace) { return std::make_pair(workspace->x(0).front(), workspace->x(0).back()); } @@ -296,7 +296,7 @@ void Spectra::checkContinuous() { } } -IndirectFitData::IndirectFitData(MatrixWorkspace_sptr workspace, +IndirectFitData::IndirectFitData(const MatrixWorkspace_sptr &workspace, const Spectra &spectra) : m_workspace(workspace), m_spectra(Spectra("")) { setSpectra(spectra); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitData.h b/qt/scientific_interfaces/Indirect/IndirectFitData.h index 58913cc934b0a11c17b3f408852b2a429e251c77..41f44de2b63bd2dc647491451cb2c52271d831ff 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitData.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitData.h @@ -108,7 +108,7 @@ std::vector<T> vectorFromString(const std::string &listString) { */ class MANTIDQT_INDIRECT_DLL IndirectFitData { public: - IndirectFitData(Mantid::API::MatrixWorkspace_sptr workspace, + IndirectFitData(const Mantid::API::MatrixWorkspace_sptr &workspace, const Spectra &spectra); std::string displayName(const std::string &formatString, diff --git a/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp index f8735143ada34fea30a25ced287ab7dd9de71728..f54ed01a18df09584bc532223514f8970f740611 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitDataLegacy.cpp @@ -12,6 +12,7 @@ #include <boost/format.hpp> #include <sstream> +#include <utility> using namespace Mantid::API; @@ -227,7 +228,7 @@ tryPassFormatArgument(boost::basic_format<char> &formatString, } } -std::pair<double, double> getBinRange(MatrixWorkspace_sptr workspace) { +std::pair<double, double> getBinRange(const MatrixWorkspace_sptr &workspace) { return std::make_pair(workspace->x(0).front(), workspace->x(0).back()); } @@ -275,7 +276,8 @@ namespace IDA { IndirectFitDataLegacy::IndirectFitDataLegacy(MatrixWorkspace_sptr workspace, const SpectraLegacy &spectra) - : m_workspace(workspace), m_spectra(DiscontinuousSpectra<std::size_t>("")) { + : m_workspace(std::move(workspace)), + m_spectra(DiscontinuousSpectra<std::size_t>("")) { setSpectra(spectra); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp index 2d926e32acb9203086fbefb8a3987fb89d6175a9..0c6eb63abff0431ec2ad08ff2f0f229b6e1ca7dd 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.cpp @@ -5,6 +5,9 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitDataPresenter.h" + +#include <utility> + #include "IndirectAddWorkspaceDialog.h" namespace MantidQt { @@ -208,8 +211,8 @@ void IndirectFitDataPresenter::replaceHandle(const std::string &workspaceName, DataForParameterEstimationCollection IndirectFitDataPresenter::getDataForParameterEstimation( - EstimationDataSelector selector) const { - return m_model->getDataForParameterEstimation(selector); + const EstimationDataSelector &selector) const { + return m_model->getDataForParameterEstimation(std::move(selector)); } void IndirectFitDataPresenter::selectReplacedWorkspace( diff --git a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h index 9240d20217755ee32209db0250acf7213a31456a..ae5f9d668e03d709b14ec4dfaedce365bc79850e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitDataPresenter.h @@ -58,7 +58,7 @@ public: void replaceHandle(const std::string &workspaceName, const Workspace_sptr &workspace) override; DataForParameterEstimationCollection - getDataForParameterEstimation(EstimationDataSelector selector) const; + getDataForParameterEstimation(const EstimationDataSelector &selector) const; public slots: void updateSpectraInTable(TableDatasetIndex dataIndex); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp index 2e78f0e3a46ffa595f517d0448ccefc8ffe9ab07..f471023b4a08c10ca59efc6a15cd3a45d6d1fa2c 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutput.cpp @@ -14,6 +14,7 @@ #include <boost/functional/hash.hpp> #include <unordered_set> +#include <utility> using namespace Mantid::API; using IDAWorkspaceIndex = MantidQt::CustomInterfaces::IDA::WorkspaceIndex; @@ -23,7 +24,7 @@ using namespace MantidQt::CustomInterfaces::IDA; struct TableRowExtractor { explicit TableRowExtractor(ITableWorkspace_sptr table) - : m_table(table), m_columns(m_table->getColumnNames()) { + : m_table(std::move(table)), m_columns(m_table->getColumnNames()) { m_chiIndex = std::find(m_columns.begin(), m_columns.end(), "Chi_squared") - m_columns.begin(); } @@ -74,7 +75,7 @@ void extractParametersFromTable( const FitDataIterator &fitDataEnd, std::unordered_map<IndirectFitData const *, ParameterValuesNew> ¶meters) { - TableRowExtractor extractRowFromTable(tableWs); + TableRowExtractor extractRowFromTable(std::move(tableWs)); IDAWorkspaceIndex index; for (auto fitData = fitDataBegin; fitData < fitDataEnd; ++fitData) { auto &values = parameters[fitData->get()]; @@ -116,8 +117,9 @@ Map mapKeys(const Map &map, const KeyMap &keyMap) { return newMap; } -MatrixWorkspace_sptr getMatrixWorkspaceFromGroup(WorkspaceGroup_sptr group, - std::size_t index) { +MatrixWorkspace_sptr +getMatrixWorkspaceFromGroup(const WorkspaceGroup_sptr &group, + std::size_t index) { if (group->size() > index) return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(index)); return nullptr; @@ -131,7 +133,7 @@ std::vector<std::string> getAxisLabels(TextAxis const *axis) { return labels; } -std::vector<std::string> getAxisLabels(MatrixWorkspace_sptr workspace, +std::vector<std::string> getAxisLabels(const MatrixWorkspace_sptr &workspace, std::size_t index) { auto axis = dynamic_cast<TextAxis *>(workspace->getAxis(index)); if (axis) @@ -166,12 +168,12 @@ void renameWorkspace(std::string const &name, std::string const &newName) { renamer->execute(); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, const std::string &workspaceName) { renameWorkspace(resultWorkspace->getName(), workspaceName + "_Result"); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, IndirectFitData const *fitData) { const auto name = resultWorkspace->getName(); const auto newName = constructResultName(name, fitData); @@ -179,13 +181,13 @@ void renameResult(Workspace_sptr resultWorkspace, renameWorkspace(name, newName); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData) { for (auto const &workspace : *resultWorkspace) renameResult(workspace, fitData); } -void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithoutSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { std::size_t index = 0; @@ -200,7 +202,7 @@ void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, } } -void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { std::size_t index = 0; @@ -208,7 +210,7 @@ void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, renameResult(resultWorkspace->getItem(index++), it->get()); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { if (static_cast<int>(resultWorkspace->size()) >= fitDataEnd - fitDataBegin) @@ -238,25 +240,26 @@ namespace MantidQt { namespace CustomInterfaces { namespace IDA { -IndirectFitOutput::IndirectFitOutput(WorkspaceGroup_sptr resultGroup, +IndirectFitOutput::IndirectFitOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) : m_resultGroup(resultGroup), m_resultWorkspace(resultWorkspace), m_parameters(), m_outputResultLocations() { - addOutput(resultGroup, parameterTable, resultWorkspace, fitDataBegin, - fitDataEnd); + addOutput(resultGroup, std::move(parameterTable), resultWorkspace, + fitDataBegin, fitDataEnd); } -IndirectFitOutput::IndirectFitOutput(WorkspaceGroup_sptr resultGroup, +IndirectFitOutput::IndirectFitOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum) { m_parameters[fitData] = ParameterValuesNew(); m_outputResultLocations[fitData] = ResultLocationsNew(); - addOutput(resultGroup, parameterTable, resultWorkspace, fitData, spectrum); + addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } bool IndirectFitOutput::isSpectrumFit(IndirectFitData const *fitData, @@ -322,24 +325,24 @@ void IndirectFitOutput::mapParameterNames( parameters = mapKeys(parameters, parameterNameChanges); } -void IndirectFitOutput::addOutput(WorkspaceGroup_sptr resultGroup, +void IndirectFitOutput::addOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { - updateParameters(parameterTable, fitDataBegin, fitDataEnd); + updateParameters(std::move(parameterTable), fitDataBegin, fitDataEnd); updateFitResults(resultGroup, fitDataBegin, fitDataEnd); renameResult(resultWorkspace, fitDataBegin, fitDataEnd); m_resultWorkspace = resultWorkspace; m_resultGroup = resultGroup; } -void IndirectFitOutput::addOutput(WorkspaceGroup_sptr resultGroup, +void IndirectFitOutput::addOutput(const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum) { - TableRowExtractor extractRowFromTable(parameterTable); + TableRowExtractor extractRowFromTable(std::move(parameterTable)); m_parameters[fitData][spectrum] = extractRowFromTable(WorkspaceIndex{0}); m_outputResultLocations[fitData][spectrum] = ResultLocationNew(resultGroup, WorkspaceGroupIndex{0}); @@ -353,7 +356,7 @@ void IndirectFitOutput::removeOutput(IndirectFitData const *fitData) { m_outputResultLocations.erase(fitData); } -void IndirectFitOutput::updateFitResults(WorkspaceGroup_sptr resultGroup, +void IndirectFitOutput::updateFitResults(const WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { if (numberOfSpectraIn(fitDataBegin, fitDataEnd).value <= @@ -366,12 +369,12 @@ void IndirectFitOutput::updateFitResults(WorkspaceGroup_sptr resultGroup, void IndirectFitOutput::updateParameters(ITableWorkspace_sptr parameterTable, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { - extractParametersFromTable(parameterTable, fitDataBegin, fitDataEnd, - m_parameters); + extractParametersFromTable(std::move(parameterTable), fitDataBegin, + fitDataEnd, m_parameters); } void IndirectFitOutput::updateFitResultsFromUnstructured( - WorkspaceGroup_sptr resultGroup, const FitDataIterator &fitDataBegin, + const WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { std::unordered_map<MatrixWorkspace *, std::map<WorkspaceIndex, WorkspaceGroupIndex>> @@ -396,7 +399,7 @@ void IndirectFitOutput::updateFitResultsFromUnstructured( } void IndirectFitOutput::updateFitResultsFromStructured( - WorkspaceGroup_sptr resultGroup, const FitDataIterator &fitDataBegin, + const WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { WorkspaceGroupIndex index; for (auto fitData = fitDataBegin; fitData < fitDataEnd; ++fitData) { diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutput.h b/qt/scientific_interfaces/Indirect/IndirectFitOutput.h index 9bf1c957377a609ddefcde35b03ca93958b1fa9b..92bc19a0612fbdd10be1b71527d90af27dcc5c6d 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutput.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutput.h @@ -30,7 +30,7 @@ struct ParameterValue { struct ResultLocationNew { ResultLocationNew() = default; - ResultLocationNew(Mantid::API::WorkspaceGroup_sptr group, + ResultLocationNew(const Mantid::API::WorkspaceGroup_sptr &group, WorkspaceGroupIndex i) : result(group), index(i) {} boost::weak_ptr<Mantid::API::WorkspaceGroup> result; @@ -51,15 +51,15 @@ using FitDataIterator = */ class MANTIDQT_INDIRECT_DLL IndirectFitOutput { public: - IndirectFitOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + IndirectFitOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - IndirectFitOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + IndirectFitOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum); bool isSpectrumFit(IndirectFitData const *fitData, @@ -85,33 +85,31 @@ public: const std::unordered_map<std::string, std::string> ¶meterNameChanges, IndirectFitData const *fitData, WorkspaceIndex spectrum); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitData const *fitData, WorkspaceIndex spectrum); void removeOutput(IndirectFitData const *fitData); private: - void updateFitResults(Mantid::API::WorkspaceGroup_sptr resultGroup, + void updateFitResults(const Mantid::API::WorkspaceGroup_sptr &resultGroup, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); void updateParameters(Mantid::API::ITableWorkspace_sptr parameterTable, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void - updateFitResultsFromUnstructured(Mantid::API::WorkspaceGroup_sptr resultGroup, - const FitDataIterator &fitDataBegin, - const FitDataIterator &fitDataEnd); - void - updateFitResultsFromStructured(Mantid::API::WorkspaceGroup_sptr resultGroup, - const FitDataIterator &fitDataBegin, - const FitDataIterator &fitDataEnd); + void updateFitResultsFromUnstructured( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); + void updateFitResultsFromStructured( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); boost::weak_ptr<Mantid::API::WorkspaceGroup> m_resultGroup; boost::weak_ptr<Mantid::API::WorkspaceGroup> m_resultWorkspace; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp index 66f8d682659c3a2b3cf7239c2ed68854baf8a4e8..0fce2d58734799ad1cc3c112478051d732c55255 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.cpp @@ -14,6 +14,7 @@ #include <boost/functional/hash.hpp> #include <unordered_set> +#include <utility> using namespace Mantid::API; @@ -22,7 +23,7 @@ using namespace MantidQt::CustomInterfaces::IDA; struct TableRowExtractor { explicit TableRowExtractor(ITableWorkspace_sptr table) - : m_table(table), m_columns(m_table->getColumnNames()) { + : m_table(std::move(table)), m_columns(m_table->getColumnNames()) { m_chiIndex = std::find(m_columns.begin(), m_columns.end(), "Chi_squared") - m_columns.begin(); } @@ -74,7 +75,7 @@ void extractParametersFromTable( const FitDataIteratorLegacy &fitDataEnd, std::unordered_map<IndirectFitDataLegacy const *, ParameterValues> ¶meters) { - TableRowExtractor extractRowFromTable(tableWs); + TableRowExtractor extractRowFromTable(std::move(tableWs)); auto extract = [&](IndirectFitDataLegacy const *inputData) { auto &values = extractOrAddDefault(parameters, inputData); return [&](std::size_t index, std::size_t spectrum) { @@ -115,8 +116,9 @@ Map mapKeys(const Map &map, const KeyMap &keyMap) { return newMap; } -MatrixWorkspace_sptr getMatrixWorkspaceFromGroup(WorkspaceGroup_sptr group, - std::size_t index) { +MatrixWorkspace_sptr +getMatrixWorkspaceFromGroup(const WorkspaceGroup_sptr &group, + std::size_t index) { if (group->size() > index) return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(index)); return nullptr; @@ -130,7 +132,7 @@ std::vector<std::string> getAxisLabels(TextAxis const *axis) { return labels; } -std::vector<std::string> getAxisLabels(MatrixWorkspace_sptr workspace, +std::vector<std::string> getAxisLabels(const MatrixWorkspace_sptr &workspace, std::size_t index) { auto axis = dynamic_cast<TextAxis *>(workspace->getAxis(index)); if (axis) @@ -165,12 +167,12 @@ void renameWorkspace(std::string const &name, std::string const &newName) { renamer->execute(); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, const std::string &workspaceName) { renameWorkspace(resultWorkspace->getName(), workspaceName + "_Result"); } -void renameResult(Workspace_sptr resultWorkspace, +void renameResult(const Workspace_sptr &resultWorkspace, IndirectFitDataLegacy const *fitData) { const auto name = resultWorkspace->getName(); const auto newName = constructResultName(name, fitData); @@ -178,13 +180,13 @@ void renameResult(Workspace_sptr resultWorkspace, renameWorkspace(name, newName); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy const *fitData) { for (auto const &workspace : *resultWorkspace) renameResult(workspace, fitData); } -void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithoutSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { std::size_t index = 0; @@ -199,7 +201,7 @@ void renameResultWithoutSpectra(WorkspaceGroup_sptr resultWorkspace, } } -void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, +void renameResultWithSpectra(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { std::size_t index = 0; @@ -207,7 +209,7 @@ void renameResultWithSpectra(WorkspaceGroup_sptr resultWorkspace, renameResult(resultWorkspace->getItem(index++), it->get()); } -void renameResult(WorkspaceGroup_sptr resultWorkspace, +void renameResult(const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { if (static_cast<int>(resultWorkspace->size()) >= fitDataEnd - fitDataBegin) @@ -230,7 +232,7 @@ public: WorkspaceGroup_sptr resultGroup, ResultLocations &locations, std::unordered_map<std::size_t, std::size_t> &defaultPositions, std::size_t &index) - : m_resultGroup(resultGroup), m_locations(locations), + : m_resultGroup(std::move(resultGroup)), m_locations(locations), m_defaultPositions(defaultPositions), m_index(index) {} void operator()(std::size_t spectrum) const { @@ -264,23 +266,24 @@ namespace CustomInterfaces { namespace IDA { IndirectFitOutputLegacy::IndirectFitOutputLegacy( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) : m_resultGroup(resultGroup), m_resultWorkspace(resultWorkspace), m_parameters(), m_outputResultLocations() { - addOutput(resultGroup, parameterTable, resultWorkspace, fitDataBegin, - fitDataEnd); + addOutput(resultGroup, std::move(parameterTable), resultWorkspace, + fitDataBegin, fitDataEnd); } IndirectFitOutputLegacy::IndirectFitOutputLegacy( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy const *fitData, - std::size_t spectrum) { + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, + IndirectFitDataLegacy const *fitData, std::size_t spectrum) { m_parameters[fitData] = ParameterValues(); m_outputResultLocations[fitData] = ResultLocations(); - addOutput(resultGroup, parameterTable, resultWorkspace, fitData, spectrum); + addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } bool IndirectFitOutputLegacy::isSpectrumFit( @@ -349,23 +352,22 @@ void IndirectFitOutputLegacy::mapParameterNames( } void IndirectFitOutputLegacy::addOutput( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { - updateParameters(parameterTable, fitDataBegin, fitDataEnd); + updateParameters(std::move(parameterTable), fitDataBegin, fitDataEnd); updateFitResults(resultGroup, fitDataBegin, fitDataEnd); renameResult(resultWorkspace, fitDataBegin, fitDataEnd); m_resultWorkspace = resultWorkspace; m_resultGroup = resultGroup; } -void IndirectFitOutputLegacy::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, - IndirectFitDataLegacy const *fitData, - std::size_t spectrum) { - TableRowExtractor extractRowFromTable(parameterTable); +void IndirectFitOutputLegacy::addOutput( + const WorkspaceGroup_sptr &resultGroup, ITableWorkspace_sptr parameterTable, + const WorkspaceGroup_sptr &resultWorkspace, + IndirectFitDataLegacy const *fitData, std::size_t spectrum) { + TableRowExtractor extractRowFromTable(std::move(parameterTable)); m_parameters[fitData][spectrum] = extractRowFromTable(0); m_outputResultLocations[fitData][spectrum] = ResultLocation(resultGroup, 0); renameResult(resultWorkspace, fitData); @@ -380,7 +382,8 @@ void IndirectFitOutputLegacy::removeOutput( } void IndirectFitOutputLegacy::updateFitResults( - WorkspaceGroup_sptr resultGroup, const FitDataIteratorLegacy &fitDataBegin, + const WorkspaceGroup_sptr &resultGroup, + const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { if (numberOfSpectraIn(fitDataBegin, fitDataEnd) <= resultGroup->size()) updateFitResultsFromStructured(resultGroup, fitDataBegin, fitDataEnd); @@ -392,8 +395,8 @@ void IndirectFitOutputLegacy::updateParameters( ITableWorkspace_sptr parameterTable, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { - extractParametersFromTable(parameterTable, fitDataBegin, fitDataEnd, - m_parameters); + extractParametersFromTable(std::move(parameterTable), fitDataBegin, + fitDataEnd, m_parameters); } void IndirectFitOutputLegacy::updateFitResultsFromUnstructured( diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h index 58bc119c27feb55e78dcea4ec11b8ea6b728fee1..7dc61035373a1c45b570e16469947dc6cc605da0 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputLegacy.h @@ -30,7 +30,7 @@ struct ParameterValueLegacy { struct ResultLocation { ResultLocation() : result(), index(0) {} - ResultLocation(Mantid::API::WorkspaceGroup_sptr group, std::size_t i) + ResultLocation(const Mantid::API::WorkspaceGroup_sptr &group, std::size_t i) : result(group), index(i) {} boost::weak_ptr<Mantid::API::WorkspaceGroup> result; std::size_t index; @@ -51,17 +51,18 @@ using FitDataIteratorLegacy = */ class MANTIDQT_INDIRECT_DLL IndirectFitOutputLegacy { public: - IndirectFitOutputLegacy(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, - const FitDataIteratorLegacy &fitDataBegin, - const FitDataIteratorLegacy &fitDataEnd); - - IndirectFitOutputLegacy(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, - IndirectFitDataLegacy const *fitData, - std::size_t spectrum); + IndirectFitOutputLegacy( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + Mantid::API::ITableWorkspace_sptr parameterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, + const FitDataIteratorLegacy &fitDataBegin, + const FitDataIteratorLegacy &fitDataEnd); + + IndirectFitOutputLegacy( + const Mantid::API::WorkspaceGroup_sptr &resultGroup, + Mantid::API::ITableWorkspace_sptr parameterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, + IndirectFitDataLegacy const *fitData, std::size_t spectrum); bool isSpectrumFit(IndirectFitDataLegacy const *fitData, std::size_t spectrum) const; @@ -88,20 +89,20 @@ public: const std::unordered_map<std::string, std::string> ¶meterNameChanges, IndirectFitDataLegacy const *fitData, std::size_t spectrum); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy const *fitData, std::size_t spectrum); void removeOutput(IndirectFitDataLegacy const *fitData); private: - void updateFitResults(Mantid::API::WorkspaceGroup_sptr resultGroup, + void updateFitResults(const Mantid::API::WorkspaceGroup_sptr &resultGroup, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); void updateParameters(Mantid::API::ITableWorkspace_sptr parameterTable, diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp index ae7f7ab60b9ad94f9b542ca7e0a2045c3cb2b38e..d946dbe86babef55436b78ab98c7d7ac66ed7f13 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitOutputOptionsModel.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" @@ -20,11 +22,11 @@ std::string noWorkspaceErrorMessage(std::string const &process) { return "The " + process + " of a workspace failed:\n\n No workspace found"; } -MatrixWorkspace_sptr convertToMatrixWorkspace(Workspace_sptr workspace) { +MatrixWorkspace_sptr convertToMatrixWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } -WorkspaceGroup_sptr convertToGroupWorkspace(Workspace_sptr workspace) { +WorkspaceGroup_sptr convertToGroupWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<WorkspaceGroup>(workspace); } @@ -50,7 +52,7 @@ std::unordered_map<std::string, std::size_t> extractAxisLabels(Axis *axis) { } std::unordered_map<std::string, std::size_t> -extractAxisLabels(MatrixWorkspace_const_sptr workspace, +extractAxisLabels(const MatrixWorkspace_const_sptr &workspace, std::size_t const &axisIndex) { auto const axis = workspace->getAxis(axisIndex); if (axis->isText()) @@ -67,18 +69,20 @@ std::vector<std::string> extractParameterNames(Axis *axis) { return parameters; } -std::vector<std::string> extractParameterNames(MatrixWorkspace_sptr workspace) { +std::vector<std::string> +extractParameterNames(const MatrixWorkspace_sptr &workspace) { auto const axis = workspace->getAxis(1); if (axis->isText()) return extractParameterNames(axis); return std::vector<std::string>(); } -std::vector<std::string> extractParameterNames(Workspace_sptr workspace) { - return extractParameterNames(convertToMatrixWorkspace(workspace)); +std::vector<std::string> +extractParameterNames(const Workspace_sptr &workspace) { + return extractParameterNames(convertToMatrixWorkspace(std::move(workspace))); } -IAlgorithm_sptr saveNexusProcessedAlgorithm(Workspace_sptr workspace, +IAlgorithm_sptr saveNexusProcessedAlgorithm(const Workspace_sptr &workspace, std::string const &filename) { auto saveAlg = AlgorithmManager::Instance().create("SaveNexusProcessed"); saveAlg->setProperty("InputWorkspace", workspace); @@ -86,23 +90,24 @@ IAlgorithm_sptr saveNexusProcessedAlgorithm(Workspace_sptr workspace, return saveAlg; } -void saveWorkspace(Workspace_sptr workspace) { +void saveWorkspace(const Workspace_sptr &workspace) { auto const filename = Mantid::Kernel::ConfigService::Instance().getString( "defaultsave.directory") + workspace->getName() + ".nxs"; saveNexusProcessedAlgorithm(workspace, filename)->execute(); } -void saveWorkspacesInGroup(WorkspaceGroup_const_sptr group) { +void saveWorkspacesInGroup(const WorkspaceGroup_const_sptr &group) { for (auto const workspace : *group) saveWorkspace(workspace); } -bool workspaceIsPlottable(MatrixWorkspace_const_sptr workspace) { +bool workspaceIsPlottable(const MatrixWorkspace_const_sptr &workspace) { return workspace->y(0).size() > 1; } -bool containsPlottableWorkspace(WorkspaceGroup_const_sptr groupWorkspace) { +bool containsPlottableWorkspace( + const WorkspaceGroup_const_sptr &groupWorkspace) { return std::any_of(groupWorkspace->begin(), groupWorkspace->end(), [](auto const &workspace) { return workspaceIsPlottable( @@ -126,8 +131,8 @@ validateInputs(std::string const &inputWorkspaceName, return errors; } -IAlgorithm_sptr replaceAlgorithm(MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr singleFitWorkspace, +IAlgorithm_sptr replaceAlgorithm(const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &singleFitWorkspace, std::string const &outputName) { auto replaceAlg = AlgorithmManager::Instance().create("IndirectReplaceFitResult"); @@ -159,7 +164,7 @@ std::vector<std::string> filterByEndSuffix(std::vector<std::string> &strings, } bool doesGroupContain(std::string const &groupName, - MatrixWorkspace_sptr workspace) { + const MatrixWorkspace_sptr &workspace) { auto const adsWorkspace = getADSWorkspace(groupName); if (adsWorkspace->isGroup()) { auto const group = @@ -180,7 +185,9 @@ std::string filterByContents(std::vector<std::string> &strings, std::string findGroupWorkspaceContaining(MatrixWorkspace_sptr workspace) { auto workspaceNames = AnalysisDataService::Instance().getObjectNames(); auto resultGroups = filterByEndSuffix(workspaceNames, "_Results"); - return !resultGroups.empty() ? filterByContents(resultGroups, workspace) : ""; + return !resultGroups.empty() + ? filterByContents(resultGroups, std::move(workspace)) + : ""; } } // namespace @@ -247,7 +254,8 @@ void IndirectFitOutputOptionsModel::plotResult(std::string const &plotType) { } void IndirectFitOutputOptionsModel::plotResult( - WorkspaceGroup_const_sptr groupWorkspace, std::string const &plotType) { + const WorkspaceGroup_const_sptr &groupWorkspace, + std::string const &plotType) { if (plotType == "All") plotAll(groupWorkspace); else @@ -255,19 +263,19 @@ void IndirectFitOutputOptionsModel::plotResult( } void IndirectFitOutputOptionsModel::plotAll( - WorkspaceGroup_const_sptr groupWorkspace) { + const WorkspaceGroup_const_sptr &groupWorkspace) { for (auto const &workspace : *groupWorkspace) plotAll(convertToMatrixWorkspace(workspace)); } void IndirectFitOutputOptionsModel::plotAll( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { if (workspaceIsPlottable(workspace)) plotAllSpectra(workspace); } void IndirectFitOutputOptionsModel::plotAllSpectra( - MatrixWorkspace_const_sptr workspace) { + const MatrixWorkspace_const_sptr &workspace) { for (auto index = 0u; index < workspace->getNumberHistograms(); ++index) { auto const plotInfo = std::make_pair(workspace->getName(), index); m_spectraToPlot.emplace_back(plotInfo); @@ -275,19 +283,20 @@ void IndirectFitOutputOptionsModel::plotAllSpectra( } void IndirectFitOutputOptionsModel::plotParameter( - WorkspaceGroup_const_sptr groupWorkspace, std::string const ¶meter) { + const WorkspaceGroup_const_sptr &groupWorkspace, + std::string const ¶meter) { for (auto const &workspace : *groupWorkspace) plotParameter(convertToMatrixWorkspace(workspace), parameter); } void IndirectFitOutputOptionsModel::plotParameter( - MatrixWorkspace_const_sptr workspace, std::string const ¶meter) { + const MatrixWorkspace_const_sptr &workspace, std::string const ¶meter) { if (workspaceIsPlottable(workspace)) plotParameterSpectrum(workspace, parameter); } void IndirectFitOutputOptionsModel::plotParameterSpectrum( - MatrixWorkspace_const_sptr workspace, std::string const ¶meter) { + const MatrixWorkspace_const_sptr &workspace, std::string const ¶meter) { auto const parameters = extractAxisLabels(workspace, 1); auto const iter = parameters.find(parameter); if (iter != parameters.end()) { @@ -306,7 +315,7 @@ void IndirectFitOutputOptionsModel::plotPDF(std::string const &workspaceName, } void IndirectFitOutputOptionsModel::plotPDF( - MatrixWorkspace_const_sptr workspace, std::string const &plotType) { + const MatrixWorkspace_const_sptr &workspace, std::string const &plotType) { if (plotType == "All") plotAll(workspace); else @@ -353,16 +362,17 @@ void IndirectFitOutputOptionsModel::replaceFitResult( } void IndirectFitOutputOptionsModel::replaceFitResult( - MatrixWorkspace_sptr inputWorkspace, - MatrixWorkspace_sptr singleFitWorkspace, std::string const &outputName) { - auto const replaceAlg = - replaceAlgorithm(inputWorkspace, singleFitWorkspace, outputName); + const MatrixWorkspace_sptr &inputWorkspace, + const MatrixWorkspace_sptr &singleFitWorkspace, + std::string const &outputName) { + auto const replaceAlg = replaceAlgorithm( + std::move(inputWorkspace), std::move(singleFitWorkspace), outputName); replaceAlg->execute(); setOutputAsResultWorkspace(replaceAlg); } void IndirectFitOutputOptionsModel::setOutputAsResultWorkspace( - IAlgorithm_sptr algorithm) { + const IAlgorithm_sptr &algorithm) { auto const outputName = algorithm->getPropertyValue("OutputWorkspace"); auto const output = getADSMatrixWorkspace(outputName); setResultWorkspace(findGroupWorkspaceContaining(output)); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h index 70f9c115426f46320581f4ad35dfee610f10833a..958fc3823a18d19efb74bb2854f0ff190f5c8949 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsModel.h @@ -59,25 +59,29 @@ public: std::string const &outputName) override; private: - void plotResult(Mantid::API::WorkspaceGroup_const_sptr groupWorkspace, + void plotResult(const Mantid::API::WorkspaceGroup_const_sptr &groupWorkspace, std::string const &plotType); - void plotAll(Mantid::API::WorkspaceGroup_const_sptr groupWorkspace); - void plotAll(Mantid::API::MatrixWorkspace_const_sptr workspace); - void plotAllSpectra(Mantid::API::MatrixWorkspace_const_sptr workspace); - void plotParameter(Mantid::API::WorkspaceGroup_const_sptr groupWorkspace, - std::string const ¶meter); - void plotParameter(Mantid::API::MatrixWorkspace_const_sptr workspace, + void plotAll(const Mantid::API::WorkspaceGroup_const_sptr &groupWorkspace); + void plotAll(const Mantid::API::MatrixWorkspace_const_sptr &workspace); + void plotAllSpectra(const Mantid::API::MatrixWorkspace_const_sptr &workspace); + void + plotParameter(const Mantid::API::WorkspaceGroup_const_sptr &groupWorkspace, + std::string const ¶meter); + void plotParameter(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const ¶meter); - void plotParameterSpectrum(Mantid::API::MatrixWorkspace_const_sptr workspace, - std::string const ¶meter); + void plotParameterSpectrum( + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + std::string const ¶meter); - void plotPDF(Mantid::API::MatrixWorkspace_const_sptr workspace, + void plotPDF(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const &plotType); - void replaceFitResult(Mantid::API::MatrixWorkspace_sptr inputWorkspace, - Mantid::API::MatrixWorkspace_sptr singleFitWorkspace, - std::string const &outputName); - void setOutputAsResultWorkspace(Mantid::API::IAlgorithm_sptr algorithm); + void + replaceFitResult(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const Mantid::API::MatrixWorkspace_sptr &singleFitWorkspace, + std::string const &outputName); + void + setOutputAsResultWorkspace(const Mantid::API::IAlgorithm_sptr &algorithm); void setResultWorkspace(std::string const &groupName); Mantid::API::WorkspaceGroup_sptr m_resultGroup; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp index 9cb4003e07fac2b0a2796b5cdc0f528fe88e19de..01a58541e8871c6b38ce39c714aea3942ffe4dcf 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitOutputOptionsPresenter.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitOutputOptionsPresenter.h" +#include <utility> + using namespace Mantid::API; namespace MantidQt { @@ -56,12 +58,12 @@ void IndirectFitOutputOptionsPresenter::setAvailablePlotOptions( void IndirectFitOutputOptionsPresenter::setResultWorkspace( WorkspaceGroup_sptr groupWorkspace) { - m_model->setResultWorkspace(groupWorkspace); + m_model->setResultWorkspace(std::move(groupWorkspace)); } void IndirectFitOutputOptionsPresenter::setPDFWorkspace( WorkspaceGroup_sptr groupWorkspace) { - m_model->setPDFWorkspace(groupWorkspace); + m_model->setPDFWorkspace(std::move(groupWorkspace)); } void IndirectFitOutputOptionsPresenter::setPlotWorkspaces() { diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp index 897f137a9e43f765cff56560fd65d91db024bc42..e0663de8ace8189e0510bd4c6aed94ae6b486b9b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitPlotModel.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FunctionDomain1D.h" @@ -25,9 +27,10 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, const std::string &category, const std::string ¶meterName); -IFunction_sptr firstFunctionWithParameter(CompositeFunction_sptr composite, - const std::string &category, - const std::string ¶meterName) { +IFunction_sptr +firstFunctionWithParameter(const CompositeFunction_sptr &composite, + const std::string &category, + const std::string ¶meterName) { for (auto i = 0u; i < composite->nFunctions(); ++i) { const auto value = firstFunctionWithParameter(composite->getFunction(i), category, parameterName); @@ -50,7 +53,7 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, return nullptr; } -boost::optional<double> firstParameterValue(IFunction_sptr function, +boost::optional<double> firstParameterValue(const IFunction_sptr &function, const std::string &category, const std::string ¶meterName) { if (!function) @@ -63,22 +66,24 @@ boost::optional<double> firstParameterValue(IFunction_sptr function, return boost::none; } -boost::optional<double> findFirstPeakCentre(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "PeakCentre"); +boost::optional<double> findFirstPeakCentre(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "PeakCentre"); } -boost::optional<double> findFirstFWHM(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "FWHM"); +boost::optional<double> findFirstFWHM(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "FWHM"); } -boost::optional<double> findFirstBackgroundLevel(IFunction_sptr function) { - return firstParameterValue(function, "Background", "A0"); +boost::optional<double> +findFirstBackgroundLevel(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Background", "A0"); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value); -void setFunctionParameters(CompositeFunction_sptr composite, +void setFunctionParameters(const CompositeFunction_sptr &composite, const std::string &category, const std::string ¶meterName, double value) { for (auto i = 0u; i < composite->nFunctions(); ++i) @@ -86,7 +91,8 @@ void setFunctionParameters(CompositeFunction_sptr composite, value); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value) { if (function->category() == category && function->hasParameter(parameterName)) function->setParameter(parameterName, value); @@ -96,7 +102,7 @@ void setFunctionParameters(IFunction_sptr function, const std::string &category, setFunctionParameters(composite, category, parameterName, value); } -void setFunctionParameters(MultiDomainFunction_sptr function, +void setFunctionParameters(const MultiDomainFunction_sptr &function, const std::string &category, const std::string ¶meterName, double value) { for (size_t i = 0u; i < function->nFunctions(); ++i) @@ -105,11 +111,11 @@ void setFunctionParameters(MultiDomainFunction_sptr function, } void setFirstBackground(IFunction_sptr function, double value) { - firstFunctionWithParameter(function, "Background", "A0") + firstFunctionWithParameter(std::move(function), "Background", "A0") ->setParameter("A0", value); } -MatrixWorkspace_sptr castToMatrixWorkspace(Workspace_sptr workspace) { +MatrixWorkspace_sptr castToMatrixWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } @@ -297,9 +303,9 @@ MatrixWorkspace_sptr IndirectFitPlotModel::getGuessWorkspace() const { } MatrixWorkspace_sptr IndirectFitPlotModel::appendGuessToInput( - MatrixWorkspace_sptr guessWorkspace) const { + const MatrixWorkspace_sptr &guessWorkspace) const { const auto range = getGuessRange(); - return createInputAndGuessWorkspace(getWorkspace(), guessWorkspace, + return createInputAndGuessWorkspace(getWorkspace(), std::move(guessWorkspace), m_activeSpectrum.value, range.first, range.second); } @@ -311,8 +317,9 @@ std::pair<double, double> IndirectFitPlotModel::getGuessRange() const { } MatrixWorkspace_sptr IndirectFitPlotModel::createInputAndGuessWorkspace( - MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const { + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &guessWorkspace, int spectrum, double startX, + double endX) const { guessWorkspace->setInstrument(inputWS->getInstrument()); guessWorkspace->replaceAxis( 0, @@ -331,10 +338,9 @@ MatrixWorkspace_sptr IndirectFitPlotModel::createInputAndGuessWorkspace( return inputAndGuess; } -MatrixWorkspace_sptr -IndirectFitPlotModel::createGuessWorkspace(MatrixWorkspace_sptr inputWorkspace, - IFunction_const_sptr func, - double startX, double endX) const { +MatrixWorkspace_sptr IndirectFitPlotModel::createGuessWorkspace( + const MatrixWorkspace_sptr &inputWorkspace, + const IFunction_const_sptr &func, double startX, double endX) const { IAlgorithm_sptr createWsAlg = AlgorithmManager::Instance().create("EvaluateFunction"); createWsAlg->initialize(); @@ -354,7 +360,7 @@ IndirectFitPlotModel::createGuessWorkspace(MatrixWorkspace_sptr inputWorkspace, } std::vector<double> -IndirectFitPlotModel::computeOutput(IFunction_const_sptr func, +IndirectFitPlotModel::computeOutput(const IFunction_const_sptr &func, const std::vector<double> &dataX) const { if (dataX.empty()) return std::vector<double>(); @@ -385,7 +391,7 @@ IAlgorithm_sptr IndirectFitPlotModel::createWorkspaceAlgorithm( } MatrixWorkspace_sptr -IndirectFitPlotModel::extractSpectra(MatrixWorkspace_sptr inputWS, +IndirectFitPlotModel::extractSpectra(const MatrixWorkspace_sptr &inputWS, int startIndex, int endIndex, double startX, double endX) const { auto extractSpectraAlg = @@ -403,9 +409,9 @@ IndirectFitPlotModel::extractSpectra(MatrixWorkspace_sptr inputWS, return extractSpectraAlg->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr -IndirectFitPlotModel::appendSpectra(MatrixWorkspace_sptr inputWS, - MatrixWorkspace_sptr spectraWS) const { +MatrixWorkspace_sptr IndirectFitPlotModel::appendSpectra( + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &spectraWS) const { auto appendSpectraAlg = AlgorithmManager::Instance().create("AppendSpectra"); appendSpectraAlg->initialize(); appendSpectraAlg->setChild(true); @@ -418,8 +424,8 @@ IndirectFitPlotModel::appendSpectra(MatrixWorkspace_sptr inputWS, } MatrixWorkspace_sptr -IndirectFitPlotModel::cropWorkspace(MatrixWorkspace_sptr inputWS, double startX, - double endX, int startIndex, +IndirectFitPlotModel::cropWorkspace(const MatrixWorkspace_sptr &inputWS, + double startX, double endX, int startIndex, int endIndex) const { const auto cropAlg = AlgorithmManager::Instance().create("CropWorkspace"); cropAlg->initialize(); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h index 58c37cc0b163db1c77feed09f94cefdd57e8d0db..9d8603612c19e00593d96e09e429c6deacc238e9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModel.h @@ -30,8 +30,8 @@ public: Mantid::API::MatrixWorkspace_sptr getGuessWorkspace() const; Spectra getSpectra() const; - Mantid::API::MatrixWorkspace_sptr - appendGuessToInput(Mantid::API::MatrixWorkspace_sptr guessWorkspace) const; + Mantid::API::MatrixWorkspace_sptr appendGuessToInput( + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace) const; TableDatasetIndex getActiveDataIndex() const; WorkspaceIndex getActiveSpectrum() const; @@ -62,18 +62,19 @@ public: private: std::pair<double, double> getGuessRange() const; - Mantid::API::MatrixWorkspace_sptr - createInputAndGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const; + Mantid::API::MatrixWorkspace_sptr createInputAndGuessWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace, int spectrum, + double startX, double endX) const; Mantid::API::MatrixWorkspace_sptr - createGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace, - Mantid::API::IFunction_const_sptr func, double startX, - double endX) const; + createGuessWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const Mantid::API::IFunction_const_sptr &func, + double startX, double endX) const; - std::vector<double> computeOutput(Mantid::API::IFunction_const_sptr func, - const std::vector<double> &dataX) const; + std::vector<double> + computeOutput(const Mantid::API::IFunction_const_sptr &func, + const std::vector<double> &dataX) const; Mantid::API::IAlgorithm_sptr createWorkspaceAlgorithm(std::size_t numberOfSpectra, @@ -81,15 +82,16 @@ private: const std::vector<double> &dataY) const; Mantid::API::MatrixWorkspace_sptr - extractSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, int startIndex, - int endIndex, double startX, double endX) const; + extractSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + int startIndex, int endIndex, double startX, + double endX) const; Mantid::API::MatrixWorkspace_sptr - appendSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr spectraWS) const; + appendSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &spectraWS) const; Mantid::API::MatrixWorkspace_sptr - cropWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, double startX, + cropWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWS, double startX, double endX, int startIndex, int endIndex) const; void deleteWorkspace(const std::string &name) const; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp index 673c2894e62d5d8ed21a1f687640b09f6b6edfc5..b6bd5fc96ce99f51250fdb1ccfe197937cec39f9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectFitPlotModelLegacy.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/CompositeFunction.h" @@ -25,9 +27,10 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, const std::string &category, const std::string ¶meterName); -IFunction_sptr firstFunctionWithParameter(CompositeFunction_sptr composite, - const std::string &category, - const std::string ¶meterName) { +IFunction_sptr +firstFunctionWithParameter(const CompositeFunction_sptr &composite, + const std::string &category, + const std::string ¶meterName) { for (auto i = 0u; i < composite->nFunctions(); ++i) { const auto value = firstFunctionWithParameter(composite->getFunction(i), category, parameterName); @@ -50,7 +53,7 @@ IFunction_sptr firstFunctionWithParameter(IFunction_sptr function, return nullptr; } -boost::optional<double> firstParameterValue(IFunction_sptr function, +boost::optional<double> firstParameterValue(const IFunction_sptr &function, const std::string &category, const std::string ¶meterName) { if (!function) @@ -63,22 +66,24 @@ boost::optional<double> firstParameterValue(IFunction_sptr function, return boost::none; } -boost::optional<double> findFirstPeakCentre(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "PeakCentre"); +boost::optional<double> findFirstPeakCentre(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "PeakCentre"); } -boost::optional<double> findFirstFWHM(IFunction_sptr function) { - return firstParameterValue(function, "Peak", "FWHM"); +boost::optional<double> findFirstFWHM(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Peak", "FWHM"); } -boost::optional<double> findFirstBackgroundLevel(IFunction_sptr function) { - return firstParameterValue(function, "Background", "A0"); +boost::optional<double> +findFirstBackgroundLevel(const IFunction_sptr &function) { + return firstParameterValue(std::move(function), "Background", "A0"); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value); -void setFunctionParameters(CompositeFunction_sptr composite, +void setFunctionParameters(const CompositeFunction_sptr &composite, const std::string &category, const std::string ¶meterName, double value) { for (auto i = 0u; i < composite->nFunctions(); ++i) @@ -86,7 +91,8 @@ void setFunctionParameters(CompositeFunction_sptr composite, value); } -void setFunctionParameters(IFunction_sptr function, const std::string &category, +void setFunctionParameters(const IFunction_sptr &function, + const std::string &category, const std::string ¶meterName, double value) { if (function->category() == category && function->hasParameter(parameterName)) function->setParameter(parameterName, value); @@ -97,11 +103,11 @@ void setFunctionParameters(IFunction_sptr function, const std::string &category, } void setFirstBackground(IFunction_sptr function, double value) { - firstFunctionWithParameter(function, "Background", "A0") + firstFunctionWithParameter(std::move(function), "Background", "A0") ->setParameter("A0", value); } -MatrixWorkspace_sptr castToMatrixWorkspace(Workspace_sptr workspace) { +MatrixWorkspace_sptr castToMatrixWorkspace(const Workspace_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } @@ -265,10 +271,10 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::getGuessWorkspace() const { } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::appendGuessToInput( - MatrixWorkspace_sptr guessWorkspace) const { + const MatrixWorkspace_sptr &guessWorkspace) const { const auto range = getGuessRange(); return createInputAndGuessWorkspace( - getWorkspace(), guessWorkspace, + getWorkspace(), std::move(guessWorkspace), boost::numeric_cast<int>(m_activeSpectrum), range.first, range.second); } @@ -279,8 +285,9 @@ std::pair<double, double> IndirectFitPlotModelLegacy::getGuessRange() const { } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createInputAndGuessWorkspace( - MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const { + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &guessWorkspace, int spectrum, double startX, + double endX) const { guessWorkspace->setInstrument(inputWS->getInstrument()); guessWorkspace->replaceAxis( 0, @@ -300,8 +307,8 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createInputAndGuessWorkspace( } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createGuessWorkspace( - MatrixWorkspace_sptr inputWorkspace, IFunction_const_sptr func, - double startX, double endX) const { + const MatrixWorkspace_sptr &inputWorkspace, + const IFunction_const_sptr &func, double startX, double endX) const { IAlgorithm_sptr createWsAlg = AlgorithmManager::Instance().create("EvaluateFunction"); createWsAlg->initialize(); @@ -321,7 +328,7 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::createGuessWorkspace( } std::vector<double> IndirectFitPlotModelLegacy::computeOutput( - IFunction_const_sptr func, const std::vector<double> &dataX) const { + const IFunction_const_sptr &func, const std::vector<double> &dataX) const { if (dataX.empty()) return std::vector<double>(); @@ -351,7 +358,7 @@ IAlgorithm_sptr IndirectFitPlotModelLegacy::createWorkspaceAlgorithm( } MatrixWorkspace_sptr -IndirectFitPlotModelLegacy::extractSpectra(MatrixWorkspace_sptr inputWS, +IndirectFitPlotModelLegacy::extractSpectra(const MatrixWorkspace_sptr &inputWS, int startIndex, int endIndex, double startX, double endX) const { auto extractSpectraAlg = @@ -370,7 +377,8 @@ IndirectFitPlotModelLegacy::extractSpectra(MatrixWorkspace_sptr inputWS, } MatrixWorkspace_sptr IndirectFitPlotModelLegacy::appendSpectra( - MatrixWorkspace_sptr inputWS, MatrixWorkspace_sptr spectraWS) const { + const MatrixWorkspace_sptr &inputWS, + const MatrixWorkspace_sptr &spectraWS) const { auto appendSpectraAlg = AlgorithmManager::Instance().create("AppendSpectra"); appendSpectraAlg->initialize(); appendSpectraAlg->setChild(true); @@ -383,7 +391,7 @@ MatrixWorkspace_sptr IndirectFitPlotModelLegacy::appendSpectra( } MatrixWorkspace_sptr -IndirectFitPlotModelLegacy::cropWorkspace(MatrixWorkspace_sptr inputWS, +IndirectFitPlotModelLegacy::cropWorkspace(const MatrixWorkspace_sptr &inputWS, double startX, double endX, int startIndex, int endIndex) const { const auto cropAlg = AlgorithmManager::Instance().create("CropWorkspace"); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h index 3f8cfc43e8e1535264f71aa73d478e91df7cf00b..2da0b9fa59b40b24f3077fbbfe2ff4b3db77c503 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotModelLegacy.h @@ -29,8 +29,8 @@ public: Mantid::API::MatrixWorkspace_sptr getGuessWorkspace() const; SpectraLegacy getSpectra() const; - Mantid::API::MatrixWorkspace_sptr - appendGuessToInput(Mantid::API::MatrixWorkspace_sptr guessWorkspace) const; + Mantid::API::MatrixWorkspace_sptr appendGuessToInput( + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace) const; std::size_t getActiveDataIndex() const; std::size_t getActiveSpectrum() const; @@ -60,18 +60,19 @@ public: private: std::pair<double, double> getGuessRange() const; - Mantid::API::MatrixWorkspace_sptr - createInputAndGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr guessWorkspace, - int spectrum, double startX, double endX) const; + Mantid::API::MatrixWorkspace_sptr createInputAndGuessWorkspace( + const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &guessWorkspace, int spectrum, + double startX, double endX) const; Mantid::API::MatrixWorkspace_sptr - createGuessWorkspace(Mantid::API::MatrixWorkspace_sptr inputWorkspace, - Mantid::API::IFunction_const_sptr func, double startX, - double endX) const; + createGuessWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWorkspace, + const Mantid::API::IFunction_const_sptr &func, + double startX, double endX) const; - std::vector<double> computeOutput(Mantid::API::IFunction_const_sptr func, - const std::vector<double> &dataX) const; + std::vector<double> + computeOutput(const Mantid::API::IFunction_const_sptr &func, + const std::vector<double> &dataX) const; Mantid::API::IAlgorithm_sptr createWorkspaceAlgorithm(std::size_t numberOfSpectra, @@ -79,15 +80,16 @@ private: const std::vector<double> &dataY) const; Mantid::API::MatrixWorkspace_sptr - extractSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, int startIndex, - int endIndex, double startX, double endX) const; + extractSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + int startIndex, int endIndex, double startX, + double endX) const; Mantid::API::MatrixWorkspace_sptr - appendSpectra(Mantid::API::MatrixWorkspace_sptr inputWS, - Mantid::API::MatrixWorkspace_sptr spectraWS) const; + appendSpectra(const Mantid::API::MatrixWorkspace_sptr &inputWS, + const Mantid::API::MatrixWorkspace_sptr &spectraWS) const; Mantid::API::MatrixWorkspace_sptr - cropWorkspace(Mantid::API::MatrixWorkspace_sptr inputWS, double startX, + cropWorkspace(const Mantid::API::MatrixWorkspace_sptr &inputWS, double startX, double endX, int startIndex, int endIndex) const; void deleteWorkspace(const std::string &name) const; diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp index fec31eb06db4233deeebdfa3d2a0514dfa862520..bfcea94e63e568dbbce6b6710a1fbc8a770685d5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.cpp @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <QTimer> +#include <utility> namespace { using MantidQt::CustomInterfaces::IDA::IIndirectFitPlotView; @@ -278,17 +279,17 @@ void IndirectFitPlotPresenter::plotLines() { } void IndirectFitPlotPresenter::plotInput(MatrixWorkspace_sptr workspace) { - plotInput(workspace, m_model->getActiveSpectrum()); + plotInput(std::move(workspace), m_model->getActiveSpectrum()); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); } void IndirectFitPlotPresenter::plotInput(MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum) { - m_view->plotInTopPreview("Sample", workspace, spectrum, Qt::black); + m_view->plotInTopPreview("Sample", std::move(workspace), spectrum, Qt::black); } -void IndirectFitPlotPresenter::plotFit(MatrixWorkspace_sptr workspace) { +void IndirectFitPlotPresenter::plotFit(const MatrixWorkspace_sptr &workspace) { plotInput(workspace, WorkspaceIndex{0}); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); @@ -298,12 +299,13 @@ void IndirectFitPlotPresenter::plotFit(MatrixWorkspace_sptr workspace) { void IndirectFitPlotPresenter::plotFit(MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum) { - m_view->plotInTopPreview("Fit", workspace, spectrum, Qt::red); + m_view->plotInTopPreview("Fit", std::move(workspace), spectrum, Qt::red); } void IndirectFitPlotPresenter::plotDifference(MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum) { - m_view->plotInBottomPreview("Difference", workspace, spectrum, Qt::blue); + m_view->plotInBottomPreview("Difference", std::move(workspace), spectrum, + Qt::blue); } void IndirectFitPlotPresenter::updatePlotRange( @@ -360,11 +362,12 @@ void IndirectFitPlotPresenter::plotGuess(bool doPlotGuess) { void IndirectFitPlotPresenter::plotGuess( Mantid::API::MatrixWorkspace_sptr workspace) { - m_view->plotInTopPreview("Guess", workspace, WorkspaceIndex{0}, Qt::green); + m_view->plotInTopPreview("Guess", std::move(workspace), WorkspaceIndex{0}, + Qt::green); } void IndirectFitPlotPresenter::plotGuessInSeparateWindow( - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { m_plotExternalGuessRunner.addCallback( [this, workspace]() { m_model->appendGuessToInput(workspace); }); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h index 6c4bc0f96a21acb83be5b10e1859535263f7959b..0a4218be8eb52f52929054ec946af4fef2a411a5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenter.h @@ -91,7 +91,7 @@ private: void plotInput(Mantid::API::MatrixWorkspace_sptr workspace); void plotInput(Mantid::API::MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum); - void plotFit(Mantid::API::MatrixWorkspace_sptr workspace); + void plotFit(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotFit(Mantid::API::MatrixWorkspace_sptr workspace, WorkspaceIndex spectrum); void plotDifference(Mantid::API::MatrixWorkspace_sptr workspace, @@ -100,7 +100,8 @@ private: void clearFit(); void clearDifference(); void plotGuess(Mantid::API::MatrixWorkspace_sptr workspace); - void plotGuessInSeparateWindow(Mantid::API::MatrixWorkspace_sptr workspace); + void + plotGuessInSeparateWindow(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotLines(); void updatePlotRange(const std::pair<double, double> &range); void clearGuess(); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp index b3ab5fe5f99da383b6cc9041c8c2c094facdc935..1039289f86d912575fc0df9740e02b6ea0aa428a 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.cpp @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/SignalBlocker.h" #include <QTimer> +#include <utility> namespace { using MantidQt::CustomInterfaces::IDA::DiscontinuousSpectra; @@ -264,17 +265,18 @@ void IndirectFitPlotPresenterLegacy::plotLines() { } void IndirectFitPlotPresenterLegacy::plotInput(MatrixWorkspace_sptr workspace) { - plotInput(workspace, m_model->getActiveSpectrum()); + plotInput(std::move(workspace), m_model->getActiveSpectrum()); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); } void IndirectFitPlotPresenterLegacy::plotInput(MatrixWorkspace_sptr workspace, std::size_t spectrum) { - m_view->plotInTopPreview("Sample", workspace, spectrum, Qt::black); + m_view->plotInTopPreview("Sample", std::move(workspace), spectrum, Qt::black); } -void IndirectFitPlotPresenterLegacy::plotFit(MatrixWorkspace_sptr workspace) { +void IndirectFitPlotPresenterLegacy::plotFit( + const MatrixWorkspace_sptr &workspace) { plotInput(workspace, 0); if (auto doGuess = m_view->isPlotGuessChecked()) plotGuess(doGuess); @@ -284,12 +286,13 @@ void IndirectFitPlotPresenterLegacy::plotFit(MatrixWorkspace_sptr workspace) { void IndirectFitPlotPresenterLegacy::plotFit(MatrixWorkspace_sptr workspace, std::size_t spectrum) { - m_view->plotInTopPreview("Fit", workspace, spectrum, Qt::red); + m_view->plotInTopPreview("Fit", std::move(workspace), spectrum, Qt::red); } void IndirectFitPlotPresenterLegacy::plotDifference( MatrixWorkspace_sptr workspace, std::size_t spectrum) { - m_view->plotInBottomPreview("Difference", workspace, spectrum, Qt::blue); + m_view->plotInBottomPreview("Difference", std::move(workspace), spectrum, + Qt::blue); } void IndirectFitPlotPresenterLegacy::updatePlotRange( @@ -346,11 +349,11 @@ void IndirectFitPlotPresenterLegacy::plotGuess(bool doPlotGuess) { void IndirectFitPlotPresenterLegacy::plotGuess( Mantid::API::MatrixWorkspace_sptr workspace) { - m_view->plotInTopPreview("Guess", workspace, 0, Qt::green); + m_view->plotInTopPreview("Guess", std::move(workspace), 0, Qt::green); } void IndirectFitPlotPresenterLegacy::plotGuessInSeparateWindow( - Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { m_plotExternalGuessRunner.addCallback( [this, workspace]() { m_model->appendGuessToInput(workspace); }); } diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h index 35baeea08b4873b4315973b0d4b0b3d2d62af985..b893ba19b8acc33ae0cdd224941c662d4cad06c3 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotPresenterLegacy.h @@ -85,13 +85,14 @@ private: void plotInput(Mantid::API::MatrixWorkspace_sptr workspace); void plotInput(Mantid::API::MatrixWorkspace_sptr workspace, std::size_t spectrum); - void plotFit(Mantid::API::MatrixWorkspace_sptr workspace); + void plotFit(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotFit(Mantid::API::MatrixWorkspace_sptr workspace, std::size_t spectrum); void plotDifference(Mantid::API::MatrixWorkspace_sptr workspace, std::size_t spectrum); void plotGuess(Mantid::API::MatrixWorkspace_sptr workspace); - void plotGuessInSeparateWindow(Mantid::API::MatrixWorkspace_sptr workspace); + void + plotGuessInSeparateWindow(const Mantid::API::MatrixWorkspace_sptr &workspace); void plotLines(); void updatePlotRange(const std::pair<double, double> &range); void clearGuess(); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h index 49fda6350e2f2f5d5a8a4c7d8525a737da1f4b02..f2c750704e044c7ae0b155d7b4764c8dfc294740 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotView.h @@ -19,6 +19,7 @@ #include <QSplitterHandle> #endif #include <QSplitter> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -30,7 +31,7 @@ class SplitterHandle : public QSplitterHandle { public: SplitterHandle(QIcon icon, Qt::Orientation orientation, QSplitter *parent = nullptr) - : QSplitterHandle(orientation, parent), m_icon(icon) {} + : QSplitterHandle(orientation, parent), m_icon(std::move(icon)) {} void paintEvent(QPaintEvent *e) override { QSplitterHandle::paintEvent(e); @@ -47,7 +48,7 @@ private: class Splitter : public QSplitter { public: Splitter(QIcon icon, QWidget *parent = nullptr) - : QSplitter(parent), m_icon(icon) {} + : QSplitter(parent), m_icon(std::move(icon)) {} QSplitterHandle *createHandle() override { return new SplitterHandle(m_icon, Qt::Vertical, this); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h index 7a079933b4399a4d86d4e91c1400568f77e2f3ba..541d49473036c30d9664fcdc809a39f4aee0ead9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPlotViewLegacy.h @@ -19,6 +19,7 @@ #include <QSplitterHandle> #endif #include <QSplitter> +#include <utility> namespace MantidQt { namespace CustomInterfaces { @@ -30,7 +31,7 @@ class SplitterHandleLegacy : public QSplitterHandle { public: SplitterHandleLegacy(QIcon icon, Qt::Orientation orientation, QSplitter *parent = nullptr) - : QSplitterHandle(orientation, parent), m_icon(icon) {} + : QSplitterHandle(orientation, parent), m_icon(std::move(icon)) {} void paintEvent(QPaintEvent *e) override { QSplitterHandle::paintEvent(e); @@ -47,7 +48,7 @@ private: class SplitterLegacy : public QSplitter { public: SplitterLegacy(QIcon icon, QWidget *parent = nullptr) - : QSplitter(parent), m_icon(icon) {} + : QSplitter(parent), m_icon(std::move(icon)) {} QSplitterHandle *createHandle() override { return new SplitterHandleLegacy(m_icon, Qt::Vertical, this); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp index 69209c537e8fa483c2972eb469ad2e9858514ff1..1471c62ee515438741fe44dba0deb011d2394b5c 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.cpp @@ -318,7 +318,8 @@ void IndirectFitPropertyBrowser::clear() { * Updates the plot guess feature in this indirect fit property browser. * @param sampleWorkspace :: The workspace loaded as sample */ -void IndirectFitPropertyBrowser::updatePlotGuess(MatrixWorkspace_const_sptr) {} +void IndirectFitPropertyBrowser::updatePlotGuess( + const MatrixWorkspace_const_sptr &) {} void IndirectFitPropertyBrowser::setErrorsEnabled(bool enabled) { m_functionBrowser->setErrorsEnabled(enabled); diff --git a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h index 369dfdfa8d69983de37261d6464044d57200e057..80fbebee9fb2c92bb6c4ef1e38f7fec07b9d8735 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h +++ b/qt/scientific_interfaces/Indirect/IndirectFitPropertyBrowser.h @@ -66,7 +66,7 @@ public: TableRowIndex nData, const QStringList &datasetNames, const std::vector<double> &qValues, const std::vector<std::pair<std::string, int>> &fitResolutions); - void updatePlotGuess(MatrixWorkspace_const_sptr sampleWorkspace); + void updatePlotGuess(const MatrixWorkspace_const_sptr &sampleWorkspace); void setErrorsEnabled(bool enabled); void updateParameterEstimationData(DataForParameterEstimationCollection &&data); diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp index 2a4bf65eefd136afc0a36fb20b62a87e3626e343..67a5e0b8db4e7865b3e56e785a24f101bfbdde7c 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp @@ -19,6 +19,7 @@ #include <set> #include <boost/algorithm/string.hpp> +#include <utility> using namespace Mantid::API; using IDAWorkspaceIndex = MantidQt::CustomInterfaces::IDA::WorkspaceIndex; @@ -37,8 +38,8 @@ std::string cutLastOf(std::string const &str, std::string const &delimiter) { return str; } -bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, - MatrixWorkspace_const_sptr rhs) { +bool equivalentWorkspaces(const MatrixWorkspace_const_sptr &lhs, + const MatrixWorkspace_const_sptr &rhs) { if (!lhs || !rhs) return false; else if (lhs->getName() == "" && rhs->getName() == "") @@ -50,8 +51,8 @@ bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, * @return True if the first function precedes the second when ordering by * name. */ -bool functionNameComparator(IFunction_const_sptr first, - IFunction_const_sptr second) { +bool functionNameComparator(const IFunction_const_sptr &first, + const IFunction_const_sptr &second) { return first->name() < second->name(); } @@ -72,8 +73,8 @@ extractFunctions(const CompositeFunction &composite) { return functions; } -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2); +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2); /* * Checks whether the specified composite functions have the same composition. @@ -111,8 +112,8 @@ bool equivalentComposites(const CompositeFunction &composite1, * @return True if the specified functions have the same composition, * False otherwise. */ -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2) { +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2) { const auto composite1 = boost::dynamic_pointer_cast<const CompositeFunction>(func1); const auto composite2 = @@ -147,8 +148,8 @@ constructInputString(const IndirectFitDataCollectionType &fittingData) { return input.str(); } -void addInputDataToSimultaneousFit(IAlgorithm_sptr fitAlgorithm, - MatrixWorkspace_sptr workspace, +void addInputDataToSimultaneousFit(const IAlgorithm_sptr &fitAlgorithm, + const MatrixWorkspace_sptr &workspace, IDAWorkspaceIndex spectrum, const std::pair<double, double> &xRange, const std::vector<double> &excludeRegions, @@ -192,7 +193,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const IndirectFitDataCollectionType &fittingData) { std::size_t counter = 0; for (const auto &data : fittingData) @@ -200,7 +201,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const IndirectFitDataCollectionType &fittingData, const std::pair<double, double> &range, const std::vector<double> &exclude) { @@ -216,7 +217,7 @@ template <typename Map> Map combine(const Map &mapA, const Map &mapB) { } std::unordered_map<std::string, std::string> -shortToLongParameterNames(IFunction_sptr function) { +shortToLongParameterNames(const IFunction_sptr &function) { std::unordered_map<std::string, std::string> shortToLong; for (const auto &name : function->getParameterNames()) shortToLong[name.substr(name.rfind(".") + 1)] = name; @@ -279,26 +280,29 @@ IFunction_sptr extractFirstInnerFunction(const std::string &function) { template <typename WorkspaceType> boost::shared_ptr<WorkspaceType> -getWorkspaceOutput(IAlgorithm_sptr algorithm, const std::string &propertyName) { +getWorkspaceOutput(const IAlgorithm_sptr &algorithm, + const std::string &propertyName) { return AnalysisDataService::Instance().retrieveWS<WorkspaceType>( algorithm->getProperty(propertyName)); } -WorkspaceGroup_sptr getOutputResult(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspace"); +WorkspaceGroup_sptr getOutputResult(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspace"); } -ITableWorkspace_sptr getOutputParameters(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<ITableWorkspace>(algorithm, +ITableWorkspace_sptr getOutputParameters(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<ITableWorkspace>(std::move(algorithm), "OutputParameterWorkspace"); } -WorkspaceGroup_sptr getOutputGroup(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspaceGroup"); +WorkspaceGroup_sptr getOutputGroup(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspaceGroup"); } void addFitProperties(Mantid::API::IAlgorithm &algorithm, - Mantid::API::IFunction_sptr function, + const Mantid::API::IFunction_sptr &function, std::string const &xAxisUnit) { algorithm.setProperty("Function", function); algorithm.setProperty("ResultXAxisUnit", xAxisUnit); @@ -576,9 +580,10 @@ void IndirectFittingModel::addWorkspace(MatrixWorkspace_sptr workspace, addNewWorkspace(workspace, spectra); } -void IndirectFittingModel::addNewWorkspace(MatrixWorkspace_sptr workspace, - const Spectra &spectra) { - m_fittingData.emplace_back(new IndirectFitData(workspace, spectra)); +void IndirectFittingModel::addNewWorkspace( + const MatrixWorkspace_sptr &workspace, const Spectra &spectra) { + m_fittingData.emplace_back( + new IndirectFitData(std::move(workspace), spectra)); m_defaultParameters.emplace_back( createDefaultParameters(m_fittingData.last())); } @@ -626,7 +631,7 @@ void IndirectFittingModel::setFittingMode(FittingMode mode) { } void IndirectFittingModel::setFitFunction(MultiDomainFunction_sptr function) { - m_activeFunction = function; + m_activeFunction = std::move(function); m_previousModelSelected = isPreviousModelSelected(); } @@ -637,10 +642,11 @@ void IndirectFittingModel::setDefaultParameterValue( } void IndirectFittingModel::addOutput(IAlgorithm_sptr fitAlgorithm) { - addOutput(fitAlgorithm, m_fittingData.begin(), m_fittingData.end()); + addOutput(std::move(fitAlgorithm), m_fittingData.begin(), + m_fittingData.end()); } -void IndirectFittingModel::addOutput(IAlgorithm_sptr fitAlgorithm, +void IndirectFittingModel::addOutput(const IAlgorithm_sptr &fitAlgorithm, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { auto group = getOutputGroup(fitAlgorithm); @@ -651,8 +657,8 @@ void IndirectFittingModel::addOutput(IAlgorithm_sptr fitAlgorithm, addOutput(group, parameters, result, fitDataBegin, fitDataEnd); } -void IndirectFittingModel::addSingleFitOutput(IAlgorithm_sptr fitAlgorithm, - TableDatasetIndex index) { +void IndirectFittingModel::addSingleFitOutput( + const IAlgorithm_sptr &fitAlgorithm, TableDatasetIndex index) { auto group = getOutputGroup(fitAlgorithm); auto parameters = getOutputParameters(fitAlgorithm); auto result = getOutputResult(fitAlgorithm); @@ -663,9 +669,9 @@ void IndirectFittingModel::addSingleFitOutput(IAlgorithm_sptr fitAlgorithm, WorkspaceIndex{spectrum}); } -void IndirectFittingModel::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, +void IndirectFittingModel::addOutput(const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) { if (m_previousModelSelected && m_fitOutput) @@ -678,9 +684,9 @@ void IndirectFittingModel::addOutput(WorkspaceGroup_sptr resultGroup, m_previousModelSelected = isPreviousModelSelected(); } -void IndirectFittingModel::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, +void IndirectFittingModel::addOutput(const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) { if (m_previousModelSelected && m_fitOutput) @@ -696,8 +702,9 @@ IndirectFitOutput IndirectFittingModel::createFitOutput( WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, WorkspaceGroup_sptr resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) const { - return IndirectFitOutput(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + return IndirectFitOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, + fitDataEnd); } IndirectFitOutput IndirectFittingModel::createFitOutput( @@ -705,8 +712,8 @@ IndirectFitOutput IndirectFittingModel::createFitOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) const { - return IndirectFitOutput(resultGroup, parameterTable, resultWorkspace, - fitData, spectrum); + return IndirectFitOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } void IndirectFittingModel::addOutput(IndirectFitOutput *fitOutput, @@ -715,8 +722,8 @@ void IndirectFittingModel::addOutput(IndirectFitOutput *fitOutput, WorkspaceGroup_sptr resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, fitDataEnd); } void IndirectFittingModel::addOutput( @@ -724,8 +731,8 @@ void IndirectFittingModel::addOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, fitData, - spectrum); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } FittingMode IndirectFittingModel::getFittingMode() const { @@ -867,14 +874,15 @@ IndirectFittingModel::simultaneousFitAlgorithm() const { IAlgorithm_sptr IndirectFittingModel::createSequentialFit(IFunction_sptr function) const { const auto input = constructInputString(m_fittingData); - return createSequentialFit(function, input, m_fittingData.front().get()); + return createSequentialFit(std::move(function), input, + m_fittingData.front().get()); } IAlgorithm_sptr IndirectFittingModel::createSequentialFit( - IFunction_sptr function, const std::string &input, + const IFunction_sptr &function, const std::string &input, IndirectFitData *initialFitData) const { auto fitAlgorithm = sequentialFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); fitAlgorithm->setProperty("Input", input); fitAlgorithm->setProperty("OutputWorkspace", sequentialFitOutputName()); fitAlgorithm->setProperty("LogName", getResultLogName()); @@ -892,7 +900,7 @@ IAlgorithm_sptr IndirectFittingModel::createSequentialFit( } IAlgorithm_sptr IndirectFittingModel::createSimultaneousFit( - MultiDomainFunction_sptr function) const { + const MultiDomainFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); addInputDataToSimultaneousFit(fitAlgorithm, m_fittingData); @@ -901,9 +909,9 @@ IAlgorithm_sptr IndirectFittingModel::createSimultaneousFit( } IAlgorithm_sptr IndirectFittingModel::createSimultaneousFitWithEqualRange( - IFunction_sptr function) const { + const IFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); auto const dataIndex = TableDatasetIndex{0}; auto const workspaceIndex = getSpectra(dataIndex).front(); @@ -931,12 +939,13 @@ std::string IndirectFittingModel::getOutputBasename() const { return cutLastOf(sequentialFitOutputName(), "_Results"); } -void IndirectFittingModel::cleanFailedRun(IAlgorithm_sptr fittingAlgorithm) { +void IndirectFittingModel::cleanFailedRun( + const IAlgorithm_sptr &fittingAlgorithm) { cleanTemporaries(fittingAlgorithm->name(), m_fittingData); } void IndirectFittingModel::cleanFailedSingleRun( - IAlgorithm_sptr fittingAlgorithm, TableDatasetIndex index) { + const IAlgorithm_sptr &fittingAlgorithm, TableDatasetIndex index) { const auto base = "__" + fittingAlgorithm->name() + "_ws" + std::to_string(index.value + 1); removeFromADSIfExists(base); @@ -945,7 +954,7 @@ void IndirectFittingModel::cleanFailedSingleRun( DataForParameterEstimationCollection IndirectFittingModel::getDataForParameterEstimation( - EstimationDataSelector selector) const { + const EstimationDataSelector &selector) const { DataForParameterEstimationCollection dataCollection; for (auto i = m_fittingData.zero(); i < m_fittingData.size(); ++i) { auto const &data = *m_fittingData[i]; diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModel.h b/qt/scientific_interfaces/Indirect/IndirectFittingModel.h index dd5b37ad3c2edb92740c20790fa24bc2653c814d..b4b39ccbb0ab93ab8906fb5d482988c9eb06820e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModel.h @@ -109,7 +109,7 @@ public: virtual void setFitFunction(Mantid::API::MultiDomainFunction_sptr function); virtual void setDefaultParameterValue(const std::string &name, double value, TableDatasetIndex dataIndex); - void addSingleFitOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addSingleFitOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, TableDatasetIndex index); virtual void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm); @@ -135,11 +135,12 @@ public: WorkspaceIndex spectrum) const; std::string getOutputBasename() const; - void cleanFailedRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm); - void cleanFailedSingleRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm, - TableDatasetIndex index); + void cleanFailedRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm); + void + cleanFailedSingleRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm, + TableDatasetIndex index); DataForParameterEstimationCollection - getDataForParameterEstimation(EstimationDataSelector selector) const; + getDataForParameterEstimation(const EstimationDataSelector &selector) const; std::vector<double> getQValuesForData() const; virtual std::vector<std::pair<std::string, int>> getResolutionsForFit() const; @@ -148,17 +149,17 @@ protected: Mantid::API::IAlgorithm_sptr getFittingAlgorithm(FittingMode mode) const; Mantid::API::IAlgorithm_sptr createSequentialFit(Mantid::API::IFunction_sptr function) const; - Mantid::API::IAlgorithm_sptr - createSimultaneousFit(Mantid::API::MultiDomainFunction_sptr function) const; + Mantid::API::IAlgorithm_sptr createSimultaneousFit( + const Mantid::API::MultiDomainFunction_sptr &function) const; Mantid::API::IAlgorithm_sptr createSimultaneousFitWithEqualRange( - Mantid::API::IFunction_sptr function) const; + const Mantid::API::IFunction_sptr &function) const; virtual Mantid::API::MultiDomainFunction_sptr getMultiDomainFunction() const; virtual std::unordered_map<std::string, std::string> mapDefaultParameterNames() const; std::string createSingleFitOutputName(const std::string &formatString, TableDatasetIndex index, WorkspaceIndex spectrum) const; - void addNewWorkspace(Mantid::API::MatrixWorkspace_sptr workspace, + void addNewWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace, const Spectra &spectra); void removeFittingData(TableDatasetIndex index); @@ -168,7 +169,7 @@ private: void removeWorkspaceFromFittingData(TableDatasetIndex const &index); Mantid::API::IAlgorithm_sptr - createSequentialFit(Mantid::API::IFunction_sptr function, + createSequentialFit(const Mantid::API::IFunction_sptr &function, const std::string &input, IndirectFitData *initialFitData) const; virtual Mantid::API::IAlgorithm_sptr sequentialFitAlgorithm() const; @@ -197,17 +198,17 @@ private: Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum) const; - void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIterator &fitDataBegin, const FitDataIterator &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitData *fitData, WorkspaceIndex spectrum); virtual void addOutput(IndirectFitOutput *fitOutput, diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp index 059c0de67ff38f0847e8ec4922932189981c37f1..fb1120f4b61c61ed7219c6a4ebf00032349597e6 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.cpp @@ -19,6 +19,7 @@ #include <set> #include <boost/algorithm/string.hpp> +#include <utility> using namespace Mantid::API; @@ -36,8 +37,8 @@ std::string cutLastOf(std::string const &str, std::string const &delimiter) { return str; } -bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, - MatrixWorkspace_const_sptr rhs) { +bool equivalentWorkspaces(const MatrixWorkspace_const_sptr &lhs, + const MatrixWorkspace_const_sptr &rhs) { if (!lhs || !rhs) return false; else if (lhs->getName() == "" && rhs->getName() == "") @@ -49,8 +50,8 @@ bool equivalentWorkspaces(MatrixWorkspace_const_sptr lhs, * @return True if the first function precedes the second when ordering by * name. */ -bool functionNameComparator(IFunction_const_sptr first, - IFunction_const_sptr second) { +bool functionNameComparator(const IFunction_const_sptr &first, + const IFunction_const_sptr &second) { return first->name() < second->name(); } @@ -71,8 +72,8 @@ extractFunctions(const CompositeFunction &composite) { return functions; } -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2); +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2); /* * Checks whether the specified composite functions have the same composition. @@ -110,8 +111,8 @@ bool equivalentComposites(const CompositeFunction &composite1, * @return True if the specified functions have the same composition, * False otherwise. */ -bool equivalentFunctions(IFunction_const_sptr func1, - IFunction_const_sptr func2) { +bool equivalentFunctions(const IFunction_const_sptr &func1, + const IFunction_const_sptr &func2) { const auto composite1 = boost::dynamic_pointer_cast<const CompositeFunction>(func1); const auto composite2 = @@ -146,8 +147,8 @@ std::string constructInputString( return input.str(); } -void addInputDataToSimultaneousFit(IAlgorithm_sptr fitAlgorithm, - MatrixWorkspace_sptr workspace, +void addInputDataToSimultaneousFit(const IAlgorithm_sptr &fitAlgorithm, + const MatrixWorkspace_sptr &workspace, std::size_t spectrum, const std::pair<double, double> &xRange, const std::vector<double> &excludeRegions, @@ -193,7 +194,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const std::vector<std::unique_ptr<IndirectFitDataLegacy>> &fittingData) { std::size_t counter = 0; for (const auto &data : fittingData) @@ -201,7 +202,7 @@ void addInputDataToSimultaneousFit( } void addInputDataToSimultaneousFit( - IAlgorithm_sptr fitAlgorithm, + const IAlgorithm_sptr &fitAlgorithm, const std::vector<std::unique_ptr<IndirectFitDataLegacy>> &fittingData, const std::pair<double, double> &range, const std::vector<double> &exclude) { @@ -217,7 +218,7 @@ template <typename Map> Map combine(const Map &mapA, const Map &mapB) { } std::unordered_map<std::string, std::string> -shortToLongParameterNames(IFunction_sptr function) { +shortToLongParameterNames(const IFunction_sptr &function) { std::unordered_map<std::string, std::string> shortToLong; for (const auto &name : function->getParameterNames()) shortToLong[name.substr(name.rfind(".") + 1)] = name; @@ -264,7 +265,7 @@ void cleanTemporaries( cleanTemporaries(prefix + std::to_string(i + 1), fittingData[i]); } -CompositeFunction_sptr createMultiDomainFunction(IFunction_sptr function, +CompositeFunction_sptr createMultiDomainFunction(const IFunction_sptr &function, std::size_t numberOfDomains) { auto multiDomainFunction = boost::make_shared<MultiDomainFunction>(); @@ -291,26 +292,29 @@ IFunction_sptr extractFirstInnerFunction(const std::string &function) { template <typename WorkspaceType> boost::shared_ptr<WorkspaceType> -getWorkspaceOutput(IAlgorithm_sptr algorithm, const std::string &propertyName) { +getWorkspaceOutput(const IAlgorithm_sptr &algorithm, + const std::string &propertyName) { return AnalysisDataService::Instance().retrieveWS<WorkspaceType>( algorithm->getProperty(propertyName)); } -WorkspaceGroup_sptr getOutputResult(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspace"); +WorkspaceGroup_sptr getOutputResult(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspace"); } -ITableWorkspace_sptr getOutputParameters(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<ITableWorkspace>(algorithm, +ITableWorkspace_sptr getOutputParameters(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<ITableWorkspace>(std::move(algorithm), "OutputParameterWorkspace"); } -WorkspaceGroup_sptr getOutputGroup(IAlgorithm_sptr algorithm) { - return getWorkspaceOutput<WorkspaceGroup>(algorithm, "OutputWorkspaceGroup"); +WorkspaceGroup_sptr getOutputGroup(const IAlgorithm_sptr &algorithm) { + return getWorkspaceOutput<WorkspaceGroup>(std::move(algorithm), + "OutputWorkspaceGroup"); } void addFitProperties(Mantid::API::IAlgorithm &algorithm, - Mantid::API::IFunction_sptr function, + const Mantid::API::IFunction_sptr &function, std::string const &xAxisUnit) { algorithm.setProperty("Function", function); algorithm.setProperty("ResultXAxisUnit", xAxisUnit); @@ -550,7 +554,8 @@ void IndirectFittingModelLegacy::addWorkspace(MatrixWorkspace_sptr workspace, void IndirectFittingModelLegacy::addNewWorkspace(MatrixWorkspace_sptr workspace, const SpectraLegacy &spectra) { - m_fittingData.emplace_back(new IndirectFitDataLegacy(workspace, spectra)); + m_fittingData.emplace_back( + new IndirectFitDataLegacy(std::move(workspace), spectra)); m_defaultParameters.emplace_back( createDefaultParameters(m_fittingData.size() - 1)); } @@ -596,7 +601,7 @@ void IndirectFittingModelLegacy::setFittingMode(FittingModeLegacy mode) { } void IndirectFittingModelLegacy::setFitFunction(IFunction_sptr function) { - m_activeFunction = function; + m_activeFunction = std::move(function); m_previousModelSelected = isPreviousModelSelected(); } @@ -607,11 +612,13 @@ void IndirectFittingModelLegacy::setDefaultParameterValue( } void IndirectFittingModelLegacy::addOutput(IAlgorithm_sptr fitAlgorithm) { - addOutput(fitAlgorithm, m_fittingData.begin(), m_fittingData.end()); + addOutput(std::move(fitAlgorithm), m_fittingData.begin(), + m_fittingData.end()); } void IndirectFittingModelLegacy::addOutput( - IAlgorithm_sptr fitAlgorithm, const FitDataIteratorLegacy &fitDataBegin, + const IAlgorithm_sptr &fitAlgorithm, + const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { auto group = getOutputGroup(fitAlgorithm); auto parameters = getOutputParameters(fitAlgorithm); @@ -622,7 +629,7 @@ void IndirectFittingModelLegacy::addOutput( } void IndirectFittingModelLegacy::addSingleFitOutput( - IAlgorithm_sptr fitAlgorithm, std::size_t index) { + const IAlgorithm_sptr &fitAlgorithm, std::size_t index) { auto group = getOutputGroup(fitAlgorithm); auto parameters = getOutputParameters(fitAlgorithm); auto result = getOutputResult(fitAlgorithm); @@ -634,8 +641,9 @@ void IndirectFittingModelLegacy::addSingleFitOutput( } void IndirectFittingModelLegacy::addOutput( - WorkspaceGroup_sptr resultGroup, ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, + const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) { if (m_previousModelSelected && m_fitOutput) @@ -648,11 +656,11 @@ void IndirectFittingModelLegacy::addOutput( m_previousModelSelected = isPreviousModelSelected(); } -void IndirectFittingModelLegacy::addOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, - IndirectFitDataLegacy *fitData, - std::size_t spectrum) { +void IndirectFittingModelLegacy::addOutput( + const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy *fitData, + std::size_t spectrum) { if (m_previousModelSelected && m_fitOutput) addOutput(m_fitOutput.get(), resultGroup, parameterTable, resultWorkspace, fitData, spectrum); @@ -667,8 +675,9 @@ IndirectFitOutputLegacy IndirectFittingModelLegacy::createFitOutput( WorkspaceGroup_sptr resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) const { - return IndirectFitOutputLegacy(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + return IndirectFitOutputLegacy( + std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, fitDataEnd); } IndirectFitOutputLegacy IndirectFittingModelLegacy::createFitOutput( @@ -676,8 +685,9 @@ IndirectFitOutputLegacy IndirectFittingModelLegacy::createFitOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) const { - return IndirectFitOutputLegacy(resultGroup, parameterTable, resultWorkspace, - fitData, spectrum); + return IndirectFitOutputLegacy(std::move(resultGroup), + std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } void IndirectFittingModelLegacy::addOutput( @@ -685,8 +695,8 @@ void IndirectFittingModelLegacy::addOutput( ITableWorkspace_sptr parameterTable, WorkspaceGroup_sptr resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, - fitDataBegin, fitDataEnd); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitDataBegin, fitDataEnd); } void IndirectFittingModelLegacy::addOutput( @@ -695,8 +705,8 @@ void IndirectFittingModelLegacy::addOutput( Mantid::API::ITableWorkspace_sptr parameterTable, Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) const { - fitOutput->addOutput(resultGroup, parameterTable, resultWorkspace, fitData, - spectrum); + fitOutput->addOutput(std::move(resultGroup), std::move(parameterTable), + std::move(resultWorkspace), fitData, spectrum); } FittingModeLegacy IndirectFittingModelLegacy::getFittingMode() const { @@ -820,14 +830,15 @@ IndirectFittingModelLegacy::simultaneousFitAlgorithm() const { IAlgorithm_sptr IndirectFittingModelLegacy::createSequentialFit(IFunction_sptr function) const { const auto input = constructInputString(m_fittingData); - return createSequentialFit(function, input, m_fittingData.front().get()); + return createSequentialFit(std::move(function), input, + m_fittingData.front().get()); } IAlgorithm_sptr IndirectFittingModelLegacy::createSequentialFit( - IFunction_sptr function, const std::string &input, + const IFunction_sptr &function, const std::string &input, IndirectFitDataLegacy *initialFitData) const { auto fitAlgorithm = sequentialFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); fitAlgorithm->setProperty("Input", input); fitAlgorithm->setProperty("OutputWorkspace", sequentialFitOutputName()); fitAlgorithm->setProperty("PassWSIndexToFunction", true); @@ -845,18 +856,18 @@ IAlgorithm_sptr IndirectFittingModelLegacy::createSequentialFit( } IAlgorithm_sptr IndirectFittingModelLegacy::createSimultaneousFit( - IFunction_sptr function) const { + const IFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); addInputDataToSimultaneousFit(fitAlgorithm, m_fittingData); fitAlgorithm->setProperty("OutputWorkspace", simultaneousFitOutputName()); return fitAlgorithm; } IAlgorithm_sptr IndirectFittingModelLegacy::createSimultaneousFitWithEqualRange( - IFunction_sptr function) const { + const IFunction_sptr &function) const { auto fitAlgorithm = simultaneousFitAlgorithm(); - addFitProperties(*fitAlgorithm, function, getResultXAxisUnit()); + addFitProperties(*fitAlgorithm, std::move(function), getResultXAxisUnit()); auto exclude = vectorFromStringLegacy<double>(getExcludeRegion(0, 0)); addInputDataToSimultaneousFit(fitAlgorithm, m_fittingData, @@ -880,12 +891,12 @@ std::string IndirectFittingModelLegacy::getOutputBasename() const { } void IndirectFittingModelLegacy::cleanFailedRun( - IAlgorithm_sptr fittingAlgorithm) { + const IAlgorithm_sptr &fittingAlgorithm) { cleanTemporaries(fittingAlgorithm->name(), m_fittingData); } void IndirectFittingModelLegacy::cleanFailedSingleRun( - IAlgorithm_sptr fittingAlgorithm, std::size_t index) { + const IAlgorithm_sptr &fittingAlgorithm, std::size_t index) { const auto base = "__" + fittingAlgorithm->name() + "_ws" + std::to_string(index + 1); removeFromADSIfExists(base); diff --git a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h index 1e316cc02dd050abc94f8bd7fa8161bd574a2d32..d87fee500ee4439fad1b67dd3fde9936ea76ea58 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h +++ b/qt/scientific_interfaces/Indirect/IndirectFittingModelLegacy.h @@ -96,7 +96,7 @@ public: virtual void setFitFunction(Mantid::API::IFunction_sptr function); virtual void setDefaultParameterValue(const std::string &name, double value, std::size_t dataIndex); - void addSingleFitOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addSingleFitOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, std::size_t index); virtual void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm); @@ -119,9 +119,10 @@ public: std::size_t spectrum) const; std::string getOutputBasename() const; - void cleanFailedRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm); - void cleanFailedSingleRun(Mantid::API::IAlgorithm_sptr fittingAlgorithm, - std::size_t index); + void cleanFailedRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm); + void + cleanFailedSingleRun(const Mantid::API::IAlgorithm_sptr &fittingAlgorithm, + std::size_t index); protected: Mantid::API::IAlgorithm_sptr @@ -129,9 +130,9 @@ protected: Mantid::API::IAlgorithm_sptr createSequentialFit(Mantid::API::IFunction_sptr function) const; Mantid::API::IAlgorithm_sptr - createSimultaneousFit(Mantid::API::IFunction_sptr function) const; + createSimultaneousFit(const Mantid::API::IFunction_sptr &function) const; Mantid::API::IAlgorithm_sptr createSimultaneousFitWithEqualRange( - Mantid::API::IFunction_sptr function) const; + const Mantid::API::IFunction_sptr &function) const; virtual Mantid::API::CompositeFunction_sptr getMultiDomainFunction() const; virtual std::unordered_map<std::string, std::string> mapDefaultParameterNames() const; @@ -148,7 +149,7 @@ private: void removeWorkspaceFromFittingData(std::size_t const &index); Mantid::API::IAlgorithm_sptr - createSequentialFit(Mantid::API::IFunction_sptr function, + createSequentialFit(const Mantid::API::IFunction_sptr &function, const std::string &input, IndirectFitDataLegacy *initialFitData) const; virtual Mantid::API::IAlgorithm_sptr sequentialFitAlgorithm() const; @@ -177,17 +178,17 @@ private: Mantid::API::WorkspaceGroup_sptr resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) const; - void addOutput(Mantid::API::IAlgorithm_sptr fitAlgorithm, + void addOutput(const Mantid::API::IAlgorithm_sptr &fitAlgorithm, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, const FitDataIteratorLegacy &fitDataBegin, const FitDataIteratorLegacy &fitDataEnd); - void addOutput(Mantid::API::WorkspaceGroup_sptr resultGroup, - Mantid::API::ITableWorkspace_sptr parameterTable, - Mantid::API::WorkspaceGroup_sptr resultWorkspace, + void addOutput(const Mantid::API::WorkspaceGroup_sptr &resultGroup, + const Mantid::API::ITableWorkspace_sptr ¶meterTable, + const Mantid::API::WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum); virtual void addOutput(IndirectFitOutputLegacy *fitOutput, diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp index 563f7ba7366fedafec1408722656a80ceecff8c0..0cf9dc9adbe76ad0176ecc227295b216d5048b36 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.cpp @@ -69,7 +69,7 @@ void ConvFunctionModel::setFunction(IFunction_sptr fun) { m_model.setFunction(fun); } -void ConvFunctionModel::checkConvolution(IFunction_sptr fun) { +void ConvFunctionModel::checkConvolution(const IFunction_sptr &fun) { bool isFitTypeSet = false; bool isResolutionSet = false; for (size_t i = 0; i < fun->nFunctions(); ++i) { @@ -102,7 +102,7 @@ void ConvFunctionModel::checkConvolution(IFunction_sptr fun) { } } -void ConvFunctionModel::checkSingleFunction(IFunction_sptr fun, +void ConvFunctionModel::checkSingleFunction(const IFunction_sptr &fun, bool &isFitTypeSet) { assert(fun->nFunctions() == 0); auto const name = fun->name(); @@ -609,7 +609,7 @@ void ConvFunctionModel::setCurrentValues(const QMap<ParamID, double> &values) { } void ConvFunctionModel::applyParameterFunction( - std::function<void(ParamID)> paramFun) const { + const std::function<void(ParamID)> ¶mFun) const { applyToFitType(m_fitType, paramFun); applyToBackground(m_backgroundType, paramFun); applyToDelta(m_hasDeltaFunction, paramFun); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h index 2f67831a5e25f165af7d358ae1e5807200422b37..edfa5f477bf7d12ac9c9bd5671f5f8e276016be4 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvFunctionModel.h @@ -115,7 +115,8 @@ private: boost::optional<QString> getParameterDescription(ParamID name) const; boost::optional<QString> getPrefix(ParamID name) const; void setCurrentValues(const QMap<ParamID, double> &); - void applyParameterFunction(std::function<void(ParamID)> paramFun) const; + void + applyParameterFunction(const std::function<void(ParamID)> ¶mFun) const; boost::optional<ParamID> getParameterId(const QString &parName); std::string buildLorentzianFunctionString() const; std::string buildTeixeiraFunctionString() const; @@ -130,8 +131,8 @@ private: void removeGlobal(const QString &parName); QStringList makeGlobalList() const; int getNumberOfPeaks() const; - void checkConvolution(IFunction_sptr fun); - void checkSingleFunction(IFunction_sptr fun, bool &isFitTypeSet); + void checkConvolution(const IFunction_sptr &fun); + void checkSingleFunction(const IFunction_sptr &fun, bool &isFitTypeSet); ConvolutionFunctionModel m_model; FitType m_fitType = FitType::None; diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h index daaedec3ca4a1002c275e89563bb20cb0c631a8d..99473fdaed02f6e47418adb05dd9f89650721732 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/ConvTypes.h @@ -91,7 +91,7 @@ inline ParamID &operator++(ParamID &id) { } inline void applyToParamIDRange(ParamID from, ParamID to, - std::function<void(ParamID)> fun) { + const std::function<void(ParamID)> &fun) { if (from == ParamID::NONE || to == ParamID::NONE) return; for (auto i = from; i <= to; ++i) diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp index 50ba28e890706ff3db8f2224d7becd244698cf2f..d46c53ec0aaf43003a79e3cd2f6a82865960d0f3 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.cpp @@ -56,7 +56,7 @@ void FQTemplateBrowser::createProperties() { m_boolManager->blockSignals(false); } -void FQTemplateBrowser::setDataType(QStringList allowedFunctionsList) { +void FQTemplateBrowser::setDataType(const QStringList &allowedFunctionsList) { ScopedFalse _false(m_emitEnumChange); m_enumManager->setEnumNames(m_fitType, allowedFunctionsList); m_enumManager->setValue(m_fitType, 0); @@ -67,8 +67,8 @@ void FQTemplateBrowser::setEnumValue(int enumIndex) { m_enumManager->setValue(m_fitType, enumIndex); } -void FQTemplateBrowser::addParameter(QString parameterName, - QString parameterDescription) { +void FQTemplateBrowser::addParameter(const QString ¶meterName, + const QString ¶meterDescription) { auto newParameter = m_parameterManager->addProperty(parameterName); m_parameterManager->setDescription(newParameter, parameterDescription.toStdString()); @@ -152,7 +152,7 @@ void FQTemplateBrowser::updateParameters(const IFunction &fun) { m_presenter.updateParameters(fun); } -void FQTemplateBrowser::setParameterValue(QString parameterName, +void FQTemplateBrowser::setParameterValue(const QString ¶meterName, double parameterValue, double parameterError) { m_parameterManager->setValue(m_parameterMap[parameterName], parameterValue); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h index 74b37cecedd4b5f798f236127dbaf03bcc47ec98..72c5221d0a1079a0a6358bff8ce07fc7b0ddf767 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/FQTemplateBrowser.h @@ -59,10 +59,11 @@ public: int getCurrentDataset() override; void updateDataType(DataType) override; void spectrumChanged(int) override; - void addParameter(QString parameterName, QString parameterDescription); - void setParameterValue(QString parameterName, double parameterValue, + void addParameter(const QString ¶meterName, + const QString ¶meterDescription); + void setParameterValue(const QString ¶meterName, double parameterValue, double parameterError); - void setDataType(QStringList allowedFunctionsList); + void setDataType(const QStringList &allowedFunctionsList); void setEnumValue(int enumIndex); signals: diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp index 6f52de42fd7779c840451f45312f698e6bef8cc4..d299d35e23b23a007c2cb35c10dc07c2b410232b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.cpp @@ -565,7 +565,7 @@ void IqtFunctionModel::setCurrentValues(const QMap<ParamID, double> &values) { } void IqtFunctionModel::applyParameterFunction( - std::function<void(ParamID)> paramFun) const { + const std::function<void(ParamID)> ¶mFun) const { if (m_numberOfExponentials > 0) { paramFun(ParamID::EXP1_HEIGHT); paramFun(ParamID::EXP1_LIFETIME); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h index 7e41e7ed46c202d73589ea29eafbd964fd05988f..3751883378023cfbda4124420f6936ef14e40f1b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/IqtFunctionModel.h @@ -114,7 +114,8 @@ private: boost::optional<QString> getParameterDescription(ParamID name) const; boost::optional<QString> getPrefix(ParamID name) const; void setCurrentValues(const QMap<ParamID, double> &); - void applyParameterFunction(std::function<void(ParamID)> paramFun) const; + void + applyParameterFunction(const std::function<void(ParamID)> ¶mFun) const; boost::optional<ParamID> getParameterId(const QString &parName); std::string buildExpDecayFunctionString() const; std::string buildStretchExpFunctionString() const; diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp index 3dbc02bab6192fba34ea2b342539e850e74fe19c..be208b3b0673db08b6b8b675591117954eab4645 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.cpp @@ -457,7 +457,7 @@ void MSDFunctionModel::setCurrentValues(const QMap<ParamID, double> &values) { } void MSDFunctionModel::applyParameterFunction( - std::function<void(ParamID)> paramFun) const { + const std::function<void(ParamID)> ¶mFun) const { if (m_fitType == QString::fromStdString(Gauss)) { paramFun(ParamID::GAUSSIAN_HEIGHT); paramFun(ParamID::GAUSSIAN_MSD); diff --git a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h index fef723310a80c523594e30577771d4d567464b0b..19962b630a85e237e4985e0158fe346f1edfc6e9 100644 --- a/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectFunctionBrowser/MSDFunctionModel.h @@ -109,7 +109,8 @@ private: boost::optional<QString> getParameterDescription(ParamID name) const; boost::optional<QString> getPrefix(ParamID name) const; void setCurrentValues(const QMap<ParamID, double> &); - void applyParameterFunction(std::function<void(ParamID)> paramFun) const; + void + applyParameterFunction(const std::function<void(ParamID)> ¶mFun) const; boost::optional<ParamID> getParameterId(const QString &parName); std::string buildGaussianFunctionString() const; std::string buildPetersFunctionString() const; diff --git a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp index 33dccab2d0cf7dbcbdad5c373f8815e8b1c00ee9..a743511ad4c57647bccb370618416c66b18f6602 100644 --- a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.cpp @@ -300,7 +300,8 @@ void IndirectInstrumentConfig::updateInstrumentConfigurations( * @param ws Instrument workspace * @return If the workspace contained valid analysers */ -bool IndirectInstrumentConfig::updateAnalysersList(MatrixWorkspace_sptr ws) { +bool IndirectInstrumentConfig::updateAnalysersList( + const MatrixWorkspace_sptr &ws) { if (!ws) return false; diff --git a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h index dafeaba3598e88023a35a782a1aaa109f4de2a4c..1419916b327a71b4386a732ddc508ae132ae3e48 100644 --- a/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h +++ b/qt/scientific_interfaces/Indirect/IndirectInstrumentConfig.h @@ -96,7 +96,7 @@ signals: private slots: /// Updates the list of analysers when an instrument is selected - bool updateAnalysersList(Mantid::API::MatrixWorkspace_sptr ws); + bool updateAnalysersList(const Mantid::API::MatrixWorkspace_sptr &ws); /// Updates the list of reflections when an analyser is selected void updateReflectionsList(int index); /// Filters out any disabled instruments diff --git a/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp b/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp index fa721defb413e7300b9a61943f7cf6324b6fe62e..9b7e11f354ac40d62053ad0bc93ce401c03cfcdc 100644 --- a/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp @@ -47,7 +47,7 @@ std::string constructPrefix(std::string const &runName, return constructPrefix(runName, analyser, reflection); } -std::string getWorkspacePrefix(MatrixWorkspace_const_sptr workspace, +std::string getWorkspacePrefix(const MatrixWorkspace_const_sptr &workspace, std::string const &facility) { auto const instrument = workspace->getInstrument(); auto const runName = diff --git a/qt/scientific_interfaces/Indirect/IndirectMoments.cpp b/qt/scientific_interfaces/Indirect/IndirectMoments.cpp index d95ef29160435e1cf86c3a2b7d296d3d4e0da401..85f54fcd2caa75df4ef5c3cc805aee95b111eecb 100644 --- a/qt/scientific_interfaces/Indirect/IndirectMoments.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectMoments.cpp @@ -267,8 +267,8 @@ void IndirectMoments::setSaveEnabled(bool enabled) { void IndirectMoments::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectMoments.h b/qt/scientific_interfaces/Indirect/IndirectMoments.h index 8ea77bb0812a1a1659a4f92707a7ed1b245838ad..35234afd12b0d51f2f20d05799ceeb4067cb36ab 100644 --- a/qt/scientific_interfaces/Indirect/IndirectMoments.h +++ b/qt/scientific_interfaces/Indirect/IndirectMoments.h @@ -48,8 +48,8 @@ protected slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private slots: void handleDataReady(QString const &dataName) override; diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp index cddf78e04ff10213c34ba079c4e7a5e68d2933e8..cb11eac1a0821bb5591aa4ff86884a4684182766 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.cpp @@ -86,7 +86,7 @@ void insertWorkspaceNames(std::vector<std::string> &allNames, } boost::optional<std::string> -checkWorkspaceSpectrumSize(MatrixWorkspace_const_sptr workspace) { +checkWorkspaceSpectrumSize(const MatrixWorkspace_const_sptr &workspace) { if (workspace->y(0).size() < 2) return "Plot Spectra failed: There is only one data point to plot in " + workspace->getName() + "."; @@ -94,7 +94,7 @@ checkWorkspaceSpectrumSize(MatrixWorkspace_const_sptr workspace) { } boost::optional<std::string> -checkWorkspaceBinSize(MatrixWorkspace_const_sptr workspace) { +checkWorkspaceBinSize(const MatrixWorkspace_const_sptr &workspace) { if (workspace->getNumberHistograms() < 2) return "Plot Bins failed: There is only one data point to plot in " + workspace->getName() + "."; @@ -208,14 +208,14 @@ bool IndirectPlotOptionsModel::validateIndices( } bool IndirectPlotOptionsModel::validateSpectra( - MatrixWorkspace_sptr workspace, std::string const &spectra) const { + const MatrixWorkspace_sptr &workspace, std::string const &spectra) const { auto const numberOfHistograms = workspace->getNumberHistograms(); auto const lastIndex = std::stoul(splitStringBy(spectra, ",-").back()); return lastIndex < numberOfHistograms; } -bool IndirectPlotOptionsModel::validateBins(MatrixWorkspace_sptr workspace, - std::string const &bins) const { +bool IndirectPlotOptionsModel::validateBins( + const MatrixWorkspace_sptr &workspace, std::string const &bins) const { auto const numberOfBins = workspace->y(0).size(); auto const lastIndex = std::stoul(splitStringBy(bins, ",-").back()); return lastIndex < numberOfBins; diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h index 6092f5f3330bfe9f2ec61b83c587008e398cb157..eebcf27dbddd4899f2920c2b88194140383c350b 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h +++ b/qt/scientific_interfaces/Indirect/IndirectPlotOptionsModel.h @@ -61,9 +61,9 @@ public: std::map<std::string, std::string> availableActions() const; private: - bool validateSpectra(Mantid::API::MatrixWorkspace_sptr workspace, + bool validateSpectra(const Mantid::API::MatrixWorkspace_sptr &workspace, std::string const &spectra) const; - bool validateBins(Mantid::API::MatrixWorkspace_sptr workspace, + bool validateBins(const Mantid::API::MatrixWorkspace_sptr &workspace, std::string const &bins) const; boost::optional<std::string> diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp b/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp index aa18b4cd7c47307fd51ba232fd18360b70b37cd0..56711979d16521a4924a6483d515050ed7a4702d 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectPlotter.cpp @@ -18,6 +18,7 @@ #include <QString> #include <QStringList> #include <QVariant> +#include <utility> using namespace MantidQt::Widgets::MplCpp; #endif @@ -178,8 +179,8 @@ workbenchPlot(QStringList const &workspaceNames, plotKwargs["capsize"] = ERROR_CAPSIZE; using MantidQt::Widgets::MplCpp::plot; - return plot(workspaceNames, boost::none, indices, figure, plotKwargs, - boost::none, boost::none, errorBars); + return plot(workspaceNames, boost::none, indices, std::move(figure), + plotKwargs, boost::none, boost::none, errorBars); } #endif @@ -360,7 +361,7 @@ bool IndirectPlotter::validate( * @return True if the data is valid */ bool IndirectPlotter::validate( - MatrixWorkspace_const_sptr workspace, + const MatrixWorkspace_const_sptr &workspace, boost::optional<std::string> const &workspaceIndices, boost::optional<MantidAxis> const &axisType) const { if (workspaceIndices && axisType && axisType.get() == MantidAxis::Spectrum) @@ -379,7 +380,7 @@ bool IndirectPlotter::validate( * @return True if the indices exist */ bool IndirectPlotter::validateSpectra( - MatrixWorkspace_const_sptr workspace, + const MatrixWorkspace_const_sptr &workspace, std::string const &workspaceIndices) const { auto const numberOfHistograms = workspace->getNumberHistograms(); auto const lastIndex = @@ -395,7 +396,7 @@ bool IndirectPlotter::validateSpectra( * '0-2,5,7-10') * @return True if the bin indices exist */ -bool IndirectPlotter::validateBins(MatrixWorkspace_const_sptr workspace, +bool IndirectPlotter::validateBins(const MatrixWorkspace_const_sptr &workspace, std::string const &binIndices) const { auto const numberOfBins = workspace->y(0).size(); auto const lastIndex = std::stoul(splitStringBy(binIndices, ",-").back()); diff --git a/qt/scientific_interfaces/Indirect/IndirectPlotter.h b/qt/scientific_interfaces/Indirect/IndirectPlotter.h index 4e3560d3d5750f98d73e98bbcdf6fd1a6ad7eb8f..db9a1a2e01a9b644daeb4f11303726bff52a1051 100644 --- a/qt/scientific_interfaces/Indirect/IndirectPlotter.h +++ b/qt/scientific_interfaces/Indirect/IndirectPlotter.h @@ -54,12 +54,12 @@ public: private: bool - validate(Mantid::API::MatrixWorkspace_const_sptr workspace, + validate(const Mantid::API::MatrixWorkspace_const_sptr &workspace, boost::optional<std::string> const &workspaceIndices = boost::none, boost::optional<MantidAxis> const &axisType = boost::none) const; - bool validateSpectra(Mantid::API::MatrixWorkspace_const_sptr workspace, + bool validateSpectra(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const &workspaceIndices) const; - bool validateBins(Mantid::API::MatrixWorkspace_const_sptr workspace, + bool validateBins(const Mantid::API::MatrixWorkspace_const_sptr &workspace, std::string const &binIndices) const; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) diff --git a/qt/scientific_interfaces/Indirect/IndirectSettings.cpp b/qt/scientific_interfaces/Indirect/IndirectSettings.cpp index 983666592b06966cd6c424ede601aa1895cd861c..cc3e604f7f91d3b1d9cab56c96908cb6809f5a09 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSettings.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSettings.cpp @@ -54,7 +54,7 @@ void IndirectSettings::otherUserSubWindowCreated( } void IndirectSettings::connectIndirectInterface( - QPointer<UserSubWindow> window) { + const QPointer<UserSubWindow> &window) { if (auto indirectInterface = dynamic_cast<IndirectInterface *>(window.data())) connect(m_presenter.get(), SIGNAL(applySettings()), indirectInterface, SLOT(applySettings())); diff --git a/qt/scientific_interfaces/Indirect/IndirectSettings.h b/qt/scientific_interfaces/Indirect/IndirectSettings.h index 02e3fb43722827481433def648c2cc29a2291757..581da825cd230e99f00dee20b97223b72ea94536 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSettings.h +++ b/qt/scientific_interfaces/Indirect/IndirectSettings.h @@ -51,7 +51,7 @@ private: void otherUserSubWindowCreated(QList<QPointer<UserSubWindow>> &windows) override; - void connectIndirectInterface(QPointer<UserSubWindow> window); + void connectIndirectInterface(const QPointer<UserSubWindow> &window); QWidget *getDockedOrFloatingWindow(); diff --git a/qt/scientific_interfaces/Indirect/IndirectSqw.cpp b/qt/scientific_interfaces/Indirect/IndirectSqw.cpp index 0b7a4ac2568b5e1a789b198c9fc8304500e55468..61368c34ca774285237ae8c6686e9c67dcdeb17e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSqw.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSqw.cpp @@ -300,8 +300,8 @@ void IndirectSqw::setSaveEnabled(bool enabled) { void IndirectSqw::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectSqw.h b/qt/scientific_interfaces/Indirect/IndirectSqw.h index ea018c966ed71fe24f76511e86fbb3dc6ce0bc40..68299a9e82bae2194f207b995421f25fb7e9f2db 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSqw.h +++ b/qt/scientific_interfaces/Indirect/IndirectSqw.h @@ -38,8 +38,8 @@ private slots: void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void plotRqwContour(std::string const &sampleName); diff --git a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp index 33e78fe617ec1505f994da3539a5292d01304504..955c6774538cfaf3ea2a81305fd543c6870f799e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.cpp @@ -620,8 +620,8 @@ void IndirectSymmetrise::setSaveEnabled(bool enabled) { void IndirectSymmetrise::updateRunButton(bool enabled, std::string const &enableOutputButtons, - QString const message, - QString const tooltip) { + QString const &message, + QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h index 49dc8ab1b27ab4be13a0e6c288d93f0c0688dd97..c1d739beed57eab2ae3236db306ec5b8dafb1c4a 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h +++ b/qt/scientific_interfaces/Indirect/IndirectSymmetrise.h @@ -68,8 +68,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setFileExtensionsByName(bool filter) override; diff --git a/qt/scientific_interfaces/Indirect/IndirectTab.cpp b/qt/scientific_interfaces/Indirect/IndirectTab.cpp index 5e0ae57d68c53bc0b1313ab7422b297f72b28060..efc40de6b1862c8e77ce45a357af320cb34be4f5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectTab.cpp @@ -51,7 +51,7 @@ std::string castToString(int value) { } template <typename Predicate> -void setPropertyIf(Algorithm_sptr algorithm, std::string const &propName, +void setPropertyIf(const Algorithm_sptr &algorithm, std::string const &propName, std::string const &value, Predicate const &condition) { if (condition) algorithm->setPropertyValue(propName, value); @@ -503,7 +503,7 @@ void IndirectTab::setRangeSelectorMax(QtProperty *minProperty, * @param ws Pointer to the workspace * @return Energy mode */ -std::string IndirectTab::getEMode(Mantid::API::MatrixWorkspace_sptr ws) { +std::string IndirectTab::getEMode(const Mantid::API::MatrixWorkspace_sptr &ws) { Mantid::Kernel::Unit_sptr xUnit = ws->getAxis(0)->unit(); std::string xUnitName = xUnit->caption(); @@ -521,7 +521,7 @@ std::string IndirectTab::getEMode(Mantid::API::MatrixWorkspace_sptr ws) { * @param ws Pointer to the workspace * @return eFixed value */ -double IndirectTab::getEFixed(Mantid::API::MatrixWorkspace_sptr ws) { +double IndirectTab::getEFixed(const Mantid::API::MatrixWorkspace_sptr &ws) { Mantid::Geometry::Instrument_const_sptr inst = ws->getInstrument(); if (!inst) throw std::runtime_error("No instrument on workspace"); @@ -567,7 +567,7 @@ bool IndirectTab::getResolutionRangeFromWs(const QString &workspace, *found) */ bool IndirectTab::getResolutionRangeFromWs( - Mantid::API::MatrixWorkspace_const_sptr workspace, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, QPair<double, double> &res) { if (workspace) { auto const instrument = workspace->getInstrument(); @@ -601,7 +601,8 @@ IndirectTab::getXRangeFromWorkspace(std::string const &workspaceName, } QPair<double, double> IndirectTab::getXRangeFromWorkspace( - Mantid::API::MatrixWorkspace_const_sptr workspace, double precision) const { + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + double precision) const { auto const xValues = workspace->x(0); return roundRangeToPrecision(xValues.front(), xValues.back(), precision); } @@ -611,7 +612,7 @@ QPair<double, double> IndirectTab::getXRangeFromWorkspace( * * @param algorithm :: The algorithm to be run */ -void IndirectTab::runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm) { +void IndirectTab::runAlgorithm(const Mantid::API::IAlgorithm_sptr &algorithm) { algorithm->setRethrows(true); // There should never really be unexecuted algorithms in the queue, but it is @@ -646,7 +647,7 @@ void IndirectTab::algorithmFinished(bool error) { * @param no_output Enable to ignore any output * @returns What was printed to stdout */ -QString IndirectTab::runPythonCode(QString code, bool no_output) { +QString IndirectTab::runPythonCode(const QString &code, bool no_output) { return m_pythonRunner.runPythonCode(code, no_output); } @@ -675,7 +676,7 @@ bool IndirectTab::checkADSForPlotSaveWorkspace(const std::string &workspaceName, } std::unordered_map<std::string, size_t> IndirectTab::extractAxisLabels( - Mantid::API::MatrixWorkspace_const_sptr workspace, + const Mantid::API::MatrixWorkspace_const_sptr &workspace, const size_t &axisIndex) const { Axis *axis = workspace->getAxis(axisIndex); if (!axis->isText()) diff --git a/qt/scientific_interfaces/Indirect/IndirectTab.h b/qt/scientific_interfaces/Indirect/IndirectTab.h index a327c5d9eaa39556918cb976dd690e0486ce8ff3..199dfe650e27af120a503eaf5e5ca305d155060e 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectTab.h @@ -116,7 +116,7 @@ protected: /// Extracts the labels from the axis at the specified index in the /// specified workspace. std::unordered_map<std::string, size_t> - extractAxisLabels(Mantid::API::MatrixWorkspace_const_sptr workspace, + extractAxisLabels(const Mantid::API::MatrixWorkspace_const_sptr &workspace, const size_t &axisIndex) const; /// Function to set the range limits of the plot @@ -138,10 +138,10 @@ protected: double newValue); /// Function to get energy mode from a workspace - std::string getEMode(Mantid::API::MatrixWorkspace_sptr ws); + std::string getEMode(const Mantid::API::MatrixWorkspace_sptr &ws); /// Function to get eFixed from a workspace - double getEFixed(Mantid::API::MatrixWorkspace_sptr ws); + double getEFixed(const Mantid::API::MatrixWorkspace_sptr &ws); /// Function to read an instrument's resolution from the IPF using a string bool getResolutionRangeFromWs(const QString &filename, @@ -149,25 +149,26 @@ protected: /// Function to read an instrument's resolution from the IPF using a workspace /// pointer - bool getResolutionRangeFromWs(Mantid::API::MatrixWorkspace_const_sptr ws, - QPair<double, double> &res); + bool + getResolutionRangeFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws, + QPair<double, double> &res); /// Gets the x range from a workspace QPair<double, double> getXRangeFromWorkspace(std::string const &workspaceName, double precision = 0.000001) const; - QPair<double, double> - getXRangeFromWorkspace(Mantid::API::MatrixWorkspace_const_sptr workspace, - double precision = 0.000001) const; + QPair<double, double> getXRangeFromWorkspace( + const Mantid::API::MatrixWorkspace_const_sptr &workspace, + double precision = 0.000001) const; /// Converts a standard vector of standard strings to a QVector of QStrings. QVector<QString> convertStdStringVector(const std::vector<std::string> &stringVec) const; /// Function to run an algorithm on a seperate thread - void runAlgorithm(const Mantid::API::IAlgorithm_sptr algorithm); + void runAlgorithm(const Mantid::API::IAlgorithm_sptr &algorithm); - QString runPythonCode(QString vode, bool no_output = false); + QString runPythonCode(const QString &vode, bool no_output = false); /// Checks the ADS for a workspace named `workspaceName`, /// opens a warning box for plotting/saving if none found diff --git a/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp b/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp index 71f8def07411774905f37688f9426ff0e2f734d0..db76d8e2632486d38a72b7a024b03961a0e517b5 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectTransmission.cpp @@ -165,8 +165,8 @@ void IndirectTransmission::setSaveEnabled(bool enabled) { } void IndirectTransmission::updateRunButton( - bool enabled, std::string const &enableOutputButtons, QString const message, - QString const tooltip) { + bool enabled, std::string const &enableOutputButtons, + QString const &message, QString const &tooltip) { setRunEnabled(enabled); m_uiForm.pbRun->setText(message); m_uiForm.pbRun->setToolTip(tooltip); diff --git a/qt/scientific_interfaces/Indirect/IndirectTransmission.h b/qt/scientific_interfaces/Indirect/IndirectTransmission.h index 2531a66baabb46ec5df507552f492c948860b54e..310e712854766699f9b3d5686d186b7e8792b970 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTransmission.h +++ b/qt/scientific_interfaces/Indirect/IndirectTransmission.h @@ -44,8 +44,8 @@ private slots: void setSaveEnabled(bool enabled); void updateRunButton(bool enabled = true, std::string const &enableOutputButtons = "unchanged", - QString const message = "Run", - QString const tooltip = ""); + QString const &message = "Run", + QString const &tooltip = ""); private: void setInstrument(QString const &instrumentName); diff --git a/qt/scientific_interfaces/Indirect/Iqt.cpp b/qt/scientific_interfaces/Indirect/Iqt.cpp index 17c7e47c09f58b9e1a6fdd16b22928f4d1fadb19..058e944fc594b59a20626464628533feecf7940e 100644 --- a/qt/scientific_interfaces/Indirect/Iqt.cpp +++ b/qt/scientific_interfaces/Indirect/Iqt.cpp @@ -28,10 +28,10 @@ MatrixWorkspace_sptr getADSMatrixWorkspace(std::string const &workspaceName) { workspaceName); } -std::string -checkInstrumentParametersMatch(Instrument_const_sptr sampleInstrument, - Instrument_const_sptr resolutionInstrument, - std::string const ¶meter) { +std::string checkInstrumentParametersMatch( + const Instrument_const_sptr &sampleInstrument, + const Instrument_const_sptr &resolutionInstrument, + std::string const ¶meter) { if (!sampleInstrument->hasParameter(parameter)) return "Could not find the " + parameter + " for the sample workspace."; if (!resolutionInstrument->hasParameter(parameter)) @@ -43,9 +43,10 @@ checkInstrumentParametersMatch(Instrument_const_sptr sampleInstrument, return ""; } -std::string checkParametersMatch(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resolutionWorkspace, - std::string const ¶meter) { +std::string +checkParametersMatch(const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resolutionWorkspace, + std::string const ¶meter) { auto const sampleInstrument = sampleWorkspace->getInstrument(); auto const resolutionInstrument = resolutionWorkspace->getInstrument(); return checkInstrumentParametersMatch(sampleInstrument, resolutionInstrument, @@ -61,8 +62,8 @@ std::string checkParametersMatch(std::string const &sampleName, } std::string -checkInstrumentsMatch(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resolutionWorkspace) { +checkInstrumentsMatch(const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resolutionWorkspace) { auto const sampleInstrument = sampleWorkspace->getInstrument(); auto const resolutionInstrument = resolutionWorkspace->getInstrument(); if (sampleInstrument->getName() != resolutionInstrument->getName()) @@ -70,9 +71,9 @@ checkInstrumentsMatch(MatrixWorkspace_const_sptr sampleWorkspace, return ""; } -std::string -validateNumberOfHistograms(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resolutionWorkspace) { +std::string validateNumberOfHistograms( + const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resolutionWorkspace) { auto const sampleSize = sampleWorkspace->getNumberHistograms(); auto const resolutionSize = resolutionWorkspace->getNumberHistograms(); if (resolutionSize > 1 && sampleSize != resolutionSize) @@ -85,8 +86,8 @@ void addErrorMessage(UserInputValidator &uiv, std::string const &message) { uiv.addErrorMessage(QString::fromStdString(message) + "\n"); } -bool isTechniqueDirect(MatrixWorkspace_const_sptr sampleWorkspace, - MatrixWorkspace_const_sptr resWorkspace) { +bool isTechniqueDirect(const MatrixWorkspace_const_sptr &sampleWorkspace, + const MatrixWorkspace_const_sptr &resWorkspace) { try { auto const logValue1 = sampleWorkspace->getLog("deltaE-mode")->value(); auto const logValue2 = resWorkspace->getLog("deltaE-mode")->value(); diff --git a/qt/scientific_interfaces/Indirect/IqtFitModel.cpp b/qt/scientific_interfaces/Indirect/IqtFitModel.cpp index ef402af173b4cf6e1b9925c555bf0360b798a555..2750e94081f60c70d4982362d9829e33339eb480 100644 --- a/qt/scientific_interfaces/Indirect/IqtFitModel.cpp +++ b/qt/scientific_interfaces/Indirect/IqtFitModel.cpp @@ -12,6 +12,7 @@ #include "MantidAPI/MultiDomainFunction.h" #include <boost/algorithm/string/predicate.hpp> +#include <utility> using namespace Mantid::API; @@ -19,7 +20,7 @@ namespace { IFunction_sptr getFirstInCategory(IFunction_sptr function, const std::string &category); -IFunction_sptr getFirstInCategory(CompositeFunction_sptr composite, +IFunction_sptr getFirstInCategory(const CompositeFunction_sptr &composite, const std::string &category) { for (auto i = 0u; i < composite->nFunctions(); ++i) { auto function = getFirstInCategory(composite->getFunction(i), category); @@ -41,7 +42,7 @@ IFunction_sptr getFirstInCategory(IFunction_sptr function, return nullptr; } -std::vector<std::string> getParameters(IFunction_sptr function, +std::vector<std::string> getParameters(const IFunction_sptr &function, const std::string &shortParameterName) { std::vector<std::string> parameters; @@ -52,7 +53,7 @@ std::vector<std::string> getParameters(IFunction_sptr function, return parameters; } -bool constrainIntensities(IFunction_sptr function) { +bool constrainIntensities(const IFunction_sptr &function) { const auto intensityParameters = getParameters(function, "Height"); const auto backgroundParameters = getParameters(function, "A0"); @@ -73,7 +74,7 @@ bool constrainIntensities(IFunction_sptr function) { return true; } -double computeTauApproximation(MatrixWorkspace_sptr workspace) { +double computeTauApproximation(const MatrixWorkspace_sptr &workspace) { const auto &x = workspace->x(0); const auto &y = workspace->y(0); @@ -83,28 +84,28 @@ double computeTauApproximation(MatrixWorkspace_sptr workspace) { } double computeHeightApproximation(IFunction_sptr function) { - const auto background = getFirstInCategory(function, "Background"); + const auto background = getFirstInCategory(std::move(function), "Background"); const double height = 1.0; if (background && background->hasParameter("A0")) return height - background->getParameter("A0"); return height; } -std::string getSuffix(MatrixWorkspace_sptr workspace) { +std::string getSuffix(const MatrixWorkspace_sptr &workspace) { const auto position = workspace->getName().rfind("_"); return workspace->getName().substr(position + 1); } -std::string getFitString(MatrixWorkspace_sptr workspace) { - auto suffix = getSuffix(workspace); +std::string getFitString(const MatrixWorkspace_sptr &workspace) { + auto suffix = getSuffix(std::move(workspace)); boost::algorithm::to_lower(suffix); if (suffix == "iqt") return "Fit"; return "_IqtFit"; } -boost::optional<std::string> findFullParameterName(IFunction_sptr function, - const std::string &name) { +boost::optional<std::string> +findFullParameterName(const IFunction_sptr &function, const std::string &name) { for (auto i = 0u; i < function->nParams(); ++i) { const auto fullName = function->parameterName(i); if (boost::algorithm::ends_with(fullName, name)) @@ -230,8 +231,8 @@ IqtFitModel::createDefaultParameters(TableDatasetIndex index) const { return parameters; } -MultiDomainFunction_sptr -IqtFitModel::createFunctionWithGlobalBeta(IFunction_sptr function) const { +MultiDomainFunction_sptr IqtFitModel::createFunctionWithGlobalBeta( + const IFunction_sptr &function) const { boost::shared_ptr<MultiDomainFunction> multiDomainFunction( new MultiDomainFunction); const auto functionString = function->asString(); diff --git a/qt/scientific_interfaces/Indirect/IqtFitModel.h b/qt/scientific_interfaces/Indirect/IqtFitModel.h index 962064594cedc70729452c8a3a1487845bc60892..3c083447af3c56f1f7e6ad78206ec7923ff191d5 100644 --- a/qt/scientific_interfaces/Indirect/IqtFitModel.h +++ b/qt/scientific_interfaces/Indirect/IqtFitModel.h @@ -31,8 +31,8 @@ private: WorkspaceIndex spectrum) const override; std::unordered_map<std::string, ParameterValue> createDefaultParameters(TableDatasetIndex index) const override; - Mantid::API::MultiDomainFunction_sptr - createFunctionWithGlobalBeta(Mantid::API::IFunction_sptr function) const; + Mantid::API::MultiDomainFunction_sptr createFunctionWithGlobalBeta( + const Mantid::API::IFunction_sptr &function) const; bool m_makeBetaGlobal; bool m_constrainIntensities; diff --git a/qt/scientific_interfaces/Indirect/JumpFitModel.cpp b/qt/scientific_interfaces/Indirect/JumpFitModel.cpp index fbb7043541c17a01d0fbd77613d8fdb3c57c11a1..a1050b133a3ad8d81958dd6055939320db65b1f7 100644 --- a/qt/scientific_interfaces/Indirect/JumpFitModel.cpp +++ b/qt/scientific_interfaces/Indirect/JumpFitModel.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "JumpFitModel.h" +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/TextAxis.h" #include "MantidKernel/Logger.h" @@ -60,7 +62,7 @@ findAxisLabels(MatrixWorkspace const *workspace, Predicate const &predicate) { return std::make_pair(std::vector<std::string>(), std::vector<std::size_t>()); } -std::string createSpectra(std::vector<std::size_t> spectrum) { +std::string createSpectra(const std::vector<std::size_t> &spectrum) { std::string spectra = ""; for (auto spec : spectrum) { spectra.append(std::to_string(spec) + ","); @@ -123,16 +125,18 @@ std::string extractSpectra(std::string const &inputName, int startIndex, return outputName; } -std::string extractSpectrum(MatrixWorkspace_sptr workspace, int index, +std::string extractSpectrum(const MatrixWorkspace_sptr &workspace, int index, std::string const &outputName) { return extractSpectra(workspace->getName(), index, index, outputName); } -std::string extractHWHMSpectrum(MatrixWorkspace_sptr workspace, int index) { +std::string extractHWHMSpectrum(const MatrixWorkspace_sptr &workspace, + int index) { auto const scaledName = "__scaled_" + std::to_string(index); auto const extractedName = "__extracted_" + std::to_string(index); auto const outputName = scaleWorkspace( - extractSpectrum(workspace, index, extractedName), scaledName, 0.5); + extractSpectrum(std::move(workspace), index, extractedName), scaledName, + 0.5); deleteTemporaryWorkspaces({extractedName}); return outputName; } @@ -159,7 +163,7 @@ MatrixWorkspace_sptr appendAll(std::vector<std::string> const &workspaces, } std::vector<std::string> -subdivideWidthWorkspace(MatrixWorkspace_sptr workspace, +subdivideWidthWorkspace(const MatrixWorkspace_sptr &workspace, const std::vector<std::size_t> &widthSpectra) { std::vector<std::string> subworkspaces; subworkspaces.reserve(1 + 2 * widthSpectra.size()); @@ -393,7 +397,7 @@ std::string JumpFitModel::constructOutputName() const { } bool JumpFitModel::allWorkspacesEqual( - Mantid::API::MatrixWorkspace_sptr workspace) const { + const Mantid::API::MatrixWorkspace_sptr &workspace) const { for (auto i = TableDatasetIndex{1}; i < numberOfWorkspaces(); ++i) { if (getWorkspace(i) != workspace) return false; diff --git a/qt/scientific_interfaces/Indirect/JumpFitModel.h b/qt/scientific_interfaces/Indirect/JumpFitModel.h index ac9881c537b5cf79ba0f83a833214f0c362cc1fc..12125b237bf996b536471bf0055c4f6ccace6f9b 100644 --- a/qt/scientific_interfaces/Indirect/JumpFitModel.h +++ b/qt/scientific_interfaces/Indirect/JumpFitModel.h @@ -53,7 +53,8 @@ public: private: std::string constructOutputName() const; - bool allWorkspacesEqual(Mantid::API::MatrixWorkspace_sptr workspace) const; + bool + allWorkspacesEqual(const Mantid::API::MatrixWorkspace_sptr &workspace) const; JumpFitParameters & addJumpFitParameters(Mantid::API::MatrixWorkspace *workspace, const std::string &hwhmName); diff --git a/qt/scientific_interfaces/Indirect/ResNorm.cpp b/qt/scientific_interfaces/Indirect/ResNorm.cpp index 35ef872c1284fb0b5cbbd3531d8a13eed7561910..21b982a8ac9b7f652704030fb274b566328a293c 100644 --- a/qt/scientific_interfaces/Indirect/ResNorm.cpp +++ b/qt/scientific_interfaces/Indirect/ResNorm.cpp @@ -215,12 +215,12 @@ void ResNorm::processLogs() { addAdditionalLogs(resultWorkspace); } -void ResNorm::addAdditionalLogs(WorkspaceGroup_sptr resultGroup) const { +void ResNorm::addAdditionalLogs(const WorkspaceGroup_sptr &resultGroup) const { for (auto const &workspace : *resultGroup) addAdditionalLogs(workspace); } -void ResNorm::addAdditionalLogs(Workspace_sptr resultWorkspace) const { +void ResNorm::addAdditionalLogs(const Workspace_sptr &resultWorkspace) const { auto logAdder = AlgorithmManager::Instance().create("AddSampleLog"); auto const name = resultWorkspace->getName(); @@ -265,14 +265,14 @@ double ResNorm::getDoubleManagerProperty(QString const &propName) const { return m_dblManager->value(m_properties[propName]); } -void ResNorm::copyLogs(MatrixWorkspace_sptr resultWorkspace, - 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(MatrixWorkspace_sptr resultWorkspace, - 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()); diff --git a/qt/scientific_interfaces/Indirect/ResNorm.h b/qt/scientific_interfaces/Indirect/ResNorm.h index 77319d6be74f8204447715c537d524ca70bb527e..c793c9c751e8737ddb8300484f491b687af604a2 100644 --- a/qt/scientific_interfaces/Indirect/ResNorm.h +++ b/qt/scientific_interfaces/Indirect/ResNorm.h @@ -51,15 +51,17 @@ private: void setFileExtensionsByName(bool filter) override; void processLogs(); - void addAdditionalLogs(Mantid::API::WorkspaceGroup_sptr resultGroup) const; - void addAdditionalLogs(Mantid::API::Workspace_sptr resultWorkspace) const; + void + addAdditionalLogs(const Mantid::API::WorkspaceGroup_sptr &resultGroup) const; + void + addAdditionalLogs(const Mantid::API::Workspace_sptr &resultWorkspace) const; std::map<std::string, std::string> getAdditionalLogStrings() const; std::map<std::string, std::string> getAdditionalLogNumbers() const; double getDoubleManagerProperty(QString const &propName) const; - void copyLogs(Mantid::API::MatrixWorkspace_sptr resultWorkspace, - Mantid::API::WorkspaceGroup_sptr resultGroup) const; - void copyLogs(Mantid::API::MatrixWorkspace_sptr resultWorkspace, - Mantid::API::Workspace_sptr workspace) const; + void copyLogs(const Mantid::API::MatrixWorkspace_sptr &resultWorkspace, + const Mantid::API::WorkspaceGroup_sptr &resultGroup) const; + void copyLogs(const Mantid::API::MatrixWorkspace_sptr &resultWorkspace, + const Mantid::API::Workspace_sptr &workspace) const; void setRunEnabled(bool enabled); void setPlotResultEnabled(bool enabled); diff --git a/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h b/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h index 8538eddeb39080863adf72bd9e4f1994a0af4b6f..f8f511c6691e88c609f2bf44c67c594d0a81c3f0 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectDataValidationHelperTest.h @@ -45,7 +45,8 @@ std::string emptyWorkspaceGroupError() { " is empty."; } -MatrixWorkspace_sptr convertWorkspace2DToMatrix(Workspace2D_sptr workspace) { +MatrixWorkspace_sptr +convertWorkspace2DToMatrix(const Workspace2D_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h b/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h index a7917e4d55cd6eb9593b5f160298706d99f38d13..4ec0658d631896a8645e6d2def18d33eb026d84e 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectFitOutputTest.h @@ -88,9 +88,9 @@ WorkspaceGroup_sptr getPopulatedGroup(std::size_t const &size) { } std::unique_ptr<IndirectFitOutputLegacy> -createFitOutput(WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr parameterTable, - WorkspaceGroup_sptr resultWorkspace, +createFitOutput(const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr ¶meterTable, + const WorkspaceGroup_sptr &resultWorkspace, IndirectFitDataLegacy *fitData, std::size_t spectrum) { return std::make_unique<IndirectFitOutputLegacy>( resultGroup, parameterTable, resultWorkspace, fitData, spectrum); @@ -324,9 +324,9 @@ private: } /// Store workspaces in ADS and won't destruct the ADS when leaving scope - void storeWorkspacesInADS(WorkspaceGroup_sptr workspacesGroup, - WorkspaceGroup_sptr resultGroup, - ITableWorkspace_sptr table) { + void storeWorkspacesInADS(const WorkspaceGroup_sptr &workspacesGroup, + const WorkspaceGroup_sptr &resultGroup, + const ITableWorkspace_sptr &table) { std::string const nameStart = resultGroup->size() > 1 ? "Multi" : ""; m_ads = std::make_unique<SetUpADSWithWorkspace>( nameStart + "ConvFit_1L_Workspaces", workspacesGroup); diff --git a/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h b/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h index 55a0f2ce1252d81dcca3209ea372f0121c9ea1c1..2114fe0717ec4de8b56054201c8a6a51f9546c6c 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectFitPlotModelTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "IndirectFitPlotModelLegacy.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/FunctionFactory.h" @@ -121,7 +123,7 @@ IndirectFittingModelLegacy *createModelWithSingleInstrumentWorkspace( return model; } -IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, +IAlgorithm_sptr setupFitAlgorithm(const MatrixWorkspace_sptr &workspace, std::string const &functionString) { auto alg = boost::make_shared<ConvolutionFitSequential>(); alg->initialize(); @@ -140,18 +142,19 @@ IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, } IAlgorithm_sptr getSetupFitAlgorithm(IndirectFittingModelLegacy *model, - MatrixWorkspace_sptr workspace, + const MatrixWorkspace_sptr &workspace, std::string const &workspaceName) { setFittingFunction(model, getFittingFunctionString(workspaceName), true); - auto alg = - setupFitAlgorithm(workspace, getFittingFunctionString(workspaceName)); + auto alg = setupFitAlgorithm(std::move(workspace), + getFittingFunctionString(workspaceName)); return alg; } IAlgorithm_sptr getExecutedFitAlgorithm(IndirectFittingModelLegacy *model, MatrixWorkspace_sptr workspace, std::string const &workspaceName) { - auto const alg = getSetupFitAlgorithm(model, workspace, workspaceName); + auto const alg = + getSetupFitAlgorithm(model, std::move(workspace), workspaceName); alg->execute(); return alg; } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h b/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h index cf0333eb5034f692ab53e855eeb26f7fb695f94f..b5afd434e62d86001c1217058a993a180e81a1e9 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h @@ -8,6 +8,8 @@ #include <cxxtest/TestSuite.h> +#include <utility> + #include "IndirectFittingModelLegacy.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/FunctionFactory.h" @@ -106,7 +108,7 @@ void setFittingFunction(std::unique_ptr<DummyModel> &model, model->setFitFunction(getFunction(functionString)); } -IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, +IAlgorithm_sptr setupFitAlgorithm(const MatrixWorkspace_sptr &workspace, std::string const &functionString) { auto alg = boost::make_shared<ConvolutionFitSequential>(); alg->initialize(); @@ -125,7 +127,7 @@ IAlgorithm_sptr setupFitAlgorithm(MatrixWorkspace_sptr workspace, } IAlgorithm_sptr getSetupFitAlgorithm(std::unique_ptr<DummyModel> &model, - MatrixWorkspace_sptr workspace, + const MatrixWorkspace_sptr &workspace, std::string const &workspaceName) { std::string const function = "name=LinearBackground,A0=0,A1=0,ties=(A0=0.000000,A1=0.0);" @@ -136,14 +138,15 @@ IAlgorithm_sptr getSetupFitAlgorithm(std::unique_ptr<DummyModel> &model, "false;name=Lorentzian,Amplitude=1,PeakCentre=0,FWHM=0." "0175)))"; setFittingFunction(model, function); - auto alg = setupFitAlgorithm(workspace, function); + auto alg = setupFitAlgorithm(std::move(workspace), function); return alg; } IAlgorithm_sptr getExecutedFitAlgorithm(std::unique_ptr<DummyModel> &model, MatrixWorkspace_sptr workspace, std::string const &workspaceName) { - auto const alg = getSetupFitAlgorithm(model, workspace, workspaceName); + auto const alg = + getSetupFitAlgorithm(model, std::move(workspace), workspaceName); alg->execute(); return alg; } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h b/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h index 963a8a9ee9457bf7cd45417f8fa7cdad0f52c025..50daa20751bd4fb4365d3a1d86dde3c9a56050a1 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectPlotOptionsModelTest.h @@ -32,7 +32,8 @@ std::string const GROUP_NAME = "GroupName"; std::string const WORKSPACE_NAME = "WorkspaceName"; std::string const WORKSPACE_INDICES = "0-2,4"; -MatrixWorkspace_sptr convertWorkspace2DToMatrix(Workspace2D_sptr workspace) { +MatrixWorkspace_sptr +convertWorkspace2DToMatrix(const Workspace2D_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } diff --git a/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h b/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h index 8a8ac0ca31ebe158afa8b6275e1289dfa520799c..63e26d4b06a4e5e2ce872fa6ca018a218cfc8800 100644 --- a/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h +++ b/qt/scientific_interfaces/Indirect/test/IndirectPlotterTest.h @@ -28,7 +28,8 @@ namespace { std::string const WORKSPACE_NAME = "WorkspaceName"; std::string const WORKSPACE_INDICES = "0-2,4"; -MatrixWorkspace_sptr convertWorkspace2DToMatrix(Workspace2D_sptr workspace) { +MatrixWorkspace_sptr +convertWorkspace2DToMatrix(const Workspace2D_sptr &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } diff --git a/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp b/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp index 269e083b5ff8ea78994b1ebce78618aefd430244..775b683bac3d9e8fd00139c3dd9cd87f881c9e39 100644 --- a/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp +++ b/qt/scientific_interfaces/MultiDatasetFit/MDFFunctionPlotData.cpp @@ -18,6 +18,8 @@ #include <qwt_plot.h> #include <qwt_plot_curve.h> +#include <utility> + namespace MantidQt { namespace CustomInterfaces { namespace MDF { @@ -38,7 +40,7 @@ auto FUNCTION_CURVE_COLOR = Qt::magenta; MDFFunctionPlotData::MDFFunctionPlotData( boost::shared_ptr<Mantid::API::IFunction> fun, double startX, double endX, size_t nX) - : m_function(fun), m_functionCurve(new QwtPlotCurve()) { + : m_function(std::move(fun)), m_functionCurve(new QwtPlotCurve()) { setDomain(startX, endX, nX); auto pen = m_functionCurve->pen(); pen.setColor(FUNCTION_CURVE_COLOR); diff --git a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp index 66f8c2d83d91cd5030d6dbe14907eebd73725c71..16ddb25e259a86ae7fdede67135202373faf53fb 100644 --- a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp +++ b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.cpp @@ -704,7 +704,7 @@ QString MultiDatasetFit::getLocalParameterTie(const QString &parName, /// @param i :: Index of the dataset (spectrum). /// @param tie :: A tie string to set. void MultiDatasetFit::setLocalParameterTie(const QString &parName, int i, - QString tie) { + const QString &tie) { m_functionBrowser->setLocalParameterTie(parName, i, tie); } diff --git a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h index 1c22f702a8943c468585a7ac60a167926e15aaf4..4fbffc943cb3aef475a674c5a29257c0148f54f2 100644 --- a/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h +++ b/qt/scientific_interfaces/MultiDatasetFit/MultiDatasetFit.h @@ -79,7 +79,7 @@ public: /// Get the tie for a local parameter. QString getLocalParameterTie(const QString &parName, int i) const; /// Set a tie for a local parameter. - void setLocalParameterTie(const QString &parName, int i, QString tie); + void setLocalParameterTie(const QString &parName, int i, const QString &tie); /// Log a warning static void logWarning(const std::string &msg); diff --git a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp index 5d098f6c3a688bf9e1c5edd6a60c65bfa1aa7eee..6bce171fc778969a6b2aeee621d6c2c4e2d74401 100644 --- a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp +++ b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.cpp @@ -14,12 +14,13 @@ #include "Poco/ActiveResult.h" #include <QApplication> +#include <utility> using namespace Mantid::API; namespace { -MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, +MatrixWorkspace_sptr extractSpectrum(const MatrixWorkspace_sptr &inputWorkspace, const int workspaceIndex) { auto extracter = AlgorithmManager::Instance().create("ExtractSingleSpectrum"); extracter->setChild(true); @@ -31,8 +32,9 @@ MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, return output; } -MatrixWorkspace_sptr evaluateFunction(IFunction_const_sptr function, - MatrixWorkspace_sptr inputWorkspace) { +MatrixWorkspace_sptr +evaluateFunction(const IFunction_const_sptr &function, + const MatrixWorkspace_sptr &inputWorkspace) { auto fit = AlgorithmManager::Instance().create("Fit"); fit->setChild(true); fit->setProperty("Function", function->asString()); @@ -96,7 +98,7 @@ void ALCBaselineModellingModel::fit(IFunction_const_sptr function, } void ALCBaselineModellingModel::setData(MatrixWorkspace_sptr data) { - m_data = data; + m_data = std::move(data); emit dataChanged(); } @@ -108,7 +110,7 @@ void ALCBaselineModellingModel::setData(MatrixWorkspace_sptr data) { * @param sections :: Section we want to use for fitting */ void ALCBaselineModellingModel::disableUnwantedPoints( - MatrixWorkspace_sptr ws, + const MatrixWorkspace_sptr &ws, const std::vector<IALCBaselineModellingModel::Section> §ions) { // Whether point with particular index should be disabled const size_t numBins = ws->blocksize(); @@ -146,7 +148,8 @@ void ALCBaselineModellingModel::disableUnwantedPoints( * @param sourceWs :: Workspace with original errors */ void ALCBaselineModellingModel::enableDisabledPoints( - MatrixWorkspace_sptr destWs, MatrixWorkspace_const_sptr sourceWs) { + const MatrixWorkspace_sptr &destWs, + const MatrixWorkspace_const_sptr &sourceWs) { // Unwanted points were disabled by setting their errors to very high values. // We recover here the original errors stored in sourceWs destWs->mutableE(0) = sourceWs->e(0); @@ -156,7 +159,8 @@ void ALCBaselineModellingModel::enableDisabledPoints( * Set errors in Diff spectrum after a fit * @param data :: [input/output] Workspace containing spectrum to set errors to */ -void ALCBaselineModellingModel::setErrorsAfterFit(MatrixWorkspace_sptr data) { +void ALCBaselineModellingModel::setErrorsAfterFit( + const MatrixWorkspace_sptr &data) { data->mutableE(2) = data->e(0); } @@ -208,13 +212,13 @@ ITableWorkspace_sptr ALCBaselineModellingModel::exportModel() { } void ALCBaselineModellingModel::setCorrectedData(MatrixWorkspace_sptr data) { - m_data = data; + m_data = std::move(data); emit correctedDataChanged(); } void ALCBaselineModellingModel::setFittedFunction( IFunction_const_sptr function) { - m_fittedFunction = function; + m_fittedFunction = std::move(function); emit fittedFunctionChanged(); } diff --git a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h index 58b7793440ea6442497f509b63660c9a0b07cdf5..552cf859176858c2f330fe2e5d2f2ecef5124d32 100644 --- a/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h +++ b/qt/scientific_interfaces/Muon/ALCBaselineModellingModel.h @@ -76,16 +76,16 @@ private: void setFittedFunction(Mantid::API::IFunction_const_sptr function); // Set errors in the ws after the fit - void setErrorsAfterFit(Mantid::API::MatrixWorkspace_sptr data); + void setErrorsAfterFit(const Mantid::API::MatrixWorkspace_sptr &data); /// Disables points which shouldn't be used for fitting - static void disableUnwantedPoints(Mantid::API::MatrixWorkspace_sptr ws, + static void disableUnwantedPoints(const Mantid::API::MatrixWorkspace_sptr &ws, const std::vector<Section> §ions); /// Enable previously disabled points static void - enableDisabledPoints(Mantid::API::MatrixWorkspace_sptr destWs, - Mantid::API::MatrixWorkspace_const_sptr sourceWs); + enableDisabledPoints(const Mantid::API::MatrixWorkspace_sptr &destWs, + const Mantid::API::MatrixWorkspace_const_sptr &sourceWs); }; } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp index 9b690fb5a69f9a38652966ca646dfd6da182da28..b69d77f6408322d3b340d73fc5894d3ba6fb02bf 100644 --- a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp +++ b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.cpp @@ -331,7 +331,7 @@ MatrixWorkspace_sptr ALCDataLoadingPresenter::exportWorkspace() { return MatrixWorkspace_sptr(); } -void ALCDataLoadingPresenter::setData(MatrixWorkspace_sptr data) { +void ALCDataLoadingPresenter::setData(const MatrixWorkspace_sptr &data) { if (data) { // Set the data diff --git a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h index 5d3c9b115f5d2da19b445043785b725705cf10d3..cd32412a5bfa946942c83f266ca9cd0c123e4a5f 100644 --- a/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h +++ b/qt/scientific_interfaces/Muon/ALCDataLoadingPresenter.h @@ -35,7 +35,7 @@ public: Mantid::API::MatrixWorkspace_sptr exportWorkspace(); /// Sets some data - void setData(Mantid::API::MatrixWorkspace_sptr data); + void setData(const Mantid::API::MatrixWorkspace_sptr &data); // Returns a boolean stating whether data is currently being loading bool isLoading() const; diff --git a/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp b/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp index e163ec97d036e269a9adcf43d0fa6aaff19356a9..9eae7ba7510fc4d3a2e3d71ad7807807009ccdd8 100644 --- a/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp +++ b/qt/scientific_interfaces/Muon/ALCPeakFittingModel.cpp @@ -16,12 +16,13 @@ #include <Poco/ActiveResult.h> #include <QApplication> +#include <utility> using namespace Mantid::API; namespace { -MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, +MatrixWorkspace_sptr extractSpectrum(const MatrixWorkspace_sptr &inputWorkspace, const int workspaceIndex) { auto extracter = AlgorithmManager::Instance().create("ExtractSingleSpectrum"); extracter->setChild(true); @@ -33,8 +34,9 @@ MatrixWorkspace_sptr extractSpectrum(MatrixWorkspace_sptr inputWorkspace, return output; } -MatrixWorkspace_sptr evaluateFunction(IFunction_const_sptr function, - MatrixWorkspace_sptr inputWorkspace) { +MatrixWorkspace_sptr +evaluateFunction(const IFunction_const_sptr &function, + const MatrixWorkspace_sptr &inputWorkspace) { auto fit = AlgorithmManager::Instance().create("Fit"); fit->setChild(true); fit->setProperty("Function", function->asString()); @@ -52,7 +54,7 @@ namespace MantidQt { namespace CustomInterfaces { void ALCPeakFittingModel::setData(MatrixWorkspace_sptr newData) { - m_data = newData; + m_data = std::move(newData); emit dataChanged(); } @@ -79,7 +81,7 @@ ITableWorkspace_sptr ALCPeakFittingModel::exportFittedPeaks() { } void ALCPeakFittingModel::setFittedPeaks(IFunction_const_sptr fittedPeaks) { - m_fittedPeaks = fittedPeaks; + m_fittedPeaks = std::move(fittedPeaks); emit fittedPeaksChanged(); } diff --git a/qt/scientific_interfaces/Muon/MuonAnalysis.cpp b/qt/scientific_interfaces/Muon/MuonAnalysis.cpp index 656b4b0092ec843eef2a4b18b7266b89bfa0cfe2..2de5fbaf935ed5c766331b0b2088b462878317b1 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysis.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysis.cpp @@ -60,6 +60,7 @@ #include <QVariant> #include <fstream> +#include <utility> // Add this class to the list of specialised dialogs in this namespace namespace MantidQt { @@ -604,7 +605,7 @@ Workspace_sptr MuonAnalysis::createAnalysisWorkspace(ItemType itemType, options.timeLimits.second = finishTime(); options.rebinArgs = isRaw ? "" : rebinParams(loadedWS); options.plotType = plotType; - options.wsName = wsName; + options.wsName = std::move(wsName); const auto *table = itemType == ItemType::Group ? m_uiForm.groupTable : m_uiForm.pairTable; options.groupPairName = table->item(tableRow, 0)->text().toStdString(); @@ -1180,8 +1181,8 @@ void MuonAnalysis::handleInputFileChanges() { * @param loadResult :: Various loaded parameters as returned by load() * @return Used grouping for populating grouping table */ -boost::shared_ptr<GroupResult> -MuonAnalysis::getGrouping(boost::shared_ptr<LoadResult> loadResult) const { +boost::shared_ptr<GroupResult> MuonAnalysis::getGrouping( + const boost::shared_ptr<LoadResult> &loadResult) const { auto result = boost::make_shared<GroupResult>(); boost::shared_ptr<Mantid::API::Grouping> groupingToUse; @@ -2220,13 +2221,13 @@ double MuonAnalysis::timeZero() { * size * @return Params string to pass to rebin */ -std::string MuonAnalysis::rebinParams(Workspace_sptr wsForRebin) { +std::string MuonAnalysis::rebinParams(const Workspace_sptr &wsForRebin) { MuonAnalysisOptionTab::RebinType rebinType = m_optionTab->getRebinType(); if (rebinType == MuonAnalysisOptionTab::NoRebin) { return ""; } else if (rebinType == MuonAnalysisOptionTab::FixedRebin) { - MatrixWorkspace_sptr ws = firstPeriod(wsForRebin); + MatrixWorkspace_sptr ws = firstPeriod(std::move(wsForRebin)); double binSize = ws->x(0)[1] - ws->x(0)[0]; double stepSize = m_optionTab->getRebinStep(); @@ -2749,7 +2750,7 @@ void MuonAnalysis::changeTab(int newTabIndex) { m_currentTab = newTab; } -void MuonAnalysis::updateNormalization(QString name) { +void MuonAnalysis::updateNormalization(const QString &name) { m_uiForm.fitBrowser->setNormalization(name.toStdString()); } diff --git a/qt/scientific_interfaces/Muon/MuonAnalysis.h b/qt/scientific_interfaces/Muon/MuonAnalysis.h index 66edab2ad32081072730286cb7a51454a8dc00cd..928e66f62e98c86aaf97017908e6ef3b2cbb7198 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysis.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysis.h @@ -241,7 +241,7 @@ private slots: /// Called when "overwrite" is changed void updateDataPresenterOverwrite(int state); // update the displayed normalization - void updateNormalization(QString name); + void updateNormalization(const QString &name); private: void moveUnNormWS(const std::string &name, std::vector<std::string> &wsNames, @@ -270,7 +270,7 @@ private: /// Get grouping for the loaded workspace boost::shared_ptr<Muon::GroupResult> - getGrouping(boost::shared_ptr<Muon::LoadResult> loadResult) const; + getGrouping(const boost::shared_ptr<Muon::LoadResult> &loadResult) const; /// Set whether the loading buttons and MWRunFiles widget are enabled. void allowLoading(bool enabled); @@ -413,7 +413,7 @@ private: /// Returns params string which can be passed to Rebin, according to what user /// specified - std::string rebinParams(Mantid::API::Workspace_sptr wsForRebin); + std::string rebinParams(const Mantid::API::Workspace_sptr &wsForRebin); /// Updates rebin params in the fit data presenter void updateRebinParams(); diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp index 7c173945654d579e4ef90c4831acb62ec4c495ba..07eee852f1d2fa6f728982b73ace406524445808 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.cpp @@ -199,7 +199,7 @@ LoadResult MuonAnalysisDataLoader::loadFiles(const QStringList &files) const { * @returns :: name of instrument (empty if failed to get it) */ std::string MuonAnalysisDataLoader::getInstrumentName( - const Workspace_sptr workspace) const { + const Workspace_sptr &workspace) const { if (workspace) { const auto period = MuonAnalysisHelper::firstPeriod(workspace); if (period) { @@ -339,7 +339,7 @@ Workspace_sptr MuonAnalysisDataLoader::loadDeadTimesFromFile( * @returns :: Workspace containing analysed data */ Workspace_sptr MuonAnalysisDataLoader::createAnalysisWorkspace( - const Workspace_sptr inputWS, const AnalysisOptions &options) const { + const Workspace_sptr &inputWS, const AnalysisOptions &options) const { IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged("MuonProcess"); @@ -381,7 +381,7 @@ Workspace_sptr MuonAnalysisDataLoader::createAnalysisWorkspace( * @param options :: [input] Options to get properties from */ void MuonAnalysisDataLoader::setProcessAlgorithmProperties( - IAlgorithm_sptr alg, const AnalysisOptions &options) const { + const IAlgorithm_sptr &alg, const AnalysisOptions &options) const { alg->setProperty("Mode", "Analyse"); alg->setProperty("TimeZero", options.timeZero); // user input alg->setProperty("LoadedTimeZero", options.loadedTimeZero); // from file diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h index e79b47c4e8536d32769cbd16d6697b43ff3fa322..1922723d230e2e9347b32a6575cb9841f4835c78 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisDataLoader.h @@ -72,7 +72,7 @@ public: const Mantid::API::Grouping &grouping) const; /// create analysis workspace Mantid::API::Workspace_sptr - createAnalysisWorkspace(const Mantid::API::Workspace_sptr inputWS, + createAnalysisWorkspace(const Mantid::API::Workspace_sptr &inputWS, const Muon::AnalysisOptions &options) const; /// Get dead time table Mantid::API::ITableWorkspace_sptr @@ -92,7 +92,7 @@ public: protected: /// Set properties of algorithm from options void - setProcessAlgorithmProperties(Mantid::API::IAlgorithm_sptr alg, + setProcessAlgorithmProperties(const Mantid::API::IAlgorithm_sptr &alg, const Muon::AnalysisOptions &options) const; /// Remove from cache any workspaces that have been deleted in the meantime void updateCache() const; @@ -100,7 +100,7 @@ protected: private: /// Get instrument name from workspace std::string - getInstrumentName(const Mantid::API::Workspace_sptr workspace) const; + getInstrumentName(const Mantid::API::Workspace_sptr &workspace) const; /// Check if we should cache result of a load of the given files bool shouldBeCached(const QStringList &filenames) const; diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp index f02b2080ab4f386dd1640dff18cf38f3115c9797..4130fd8f14b0b211e6cbaa075fc0edc6791be193 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.cpp @@ -483,7 +483,7 @@ MuonAnalysisFitDataPresenter::createWorkspace(const std::string &name, * @returns :: parameter string for rebinning */ std::string MuonAnalysisFitDataPresenter::getRebinParams( - const Mantid::API::Workspace_sptr ws) const { + const Mantid::API::Workspace_sptr &ws) const { // First check for workspace group. If it is, use first entry if (const auto &group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { if (group->size() > 0) { diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h index 438b59b8a08c9393964ffb3fc7b8b25e24b8e73e..bf7701c46f8df1998ad1c9cb6b22a19784f9606b 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisFitDataPresenter.h @@ -134,7 +134,7 @@ private: /// Update model and view with names of workspaces to fit void updateWorkspaceNames(const std::vector<std::string> &names) const; /// Get rebin options for analysis - std::string getRebinParams(const Mantid::API::Workspace_sptr ws) const; + std::string getRebinParams(const Mantid::API::Workspace_sptr &ws) const; /// Add special logs to fitted workspaces void addSpecialLogs( const std::string &wsName, diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp index c48468a378df4f4a1a57dbf6f7dd347c12173892..bc4dea86177f3fed4fcf6f4d1630645abcf18c15 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp @@ -27,6 +27,7 @@ #include <boost/lexical_cast.hpp> #include <boost/scope_exit.hpp> #include <stdexcept> +#include <utility> namespace { /// Colors for workspace (Black, Red, Green, Blue, Orange, Purple, if there are @@ -96,7 +97,7 @@ void setDoubleValidator(QLineEdit *field, bool allowEmpty) { * only - it is returned. * @param ws :: Run workspace */ -MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { +MatrixWorkspace_sptr firstPeriod(const Workspace_sptr &ws) { if (auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { return boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(0)); } else { @@ -109,7 +110,7 @@ MatrixWorkspace_sptr firstPeriod(Workspace_sptr ws) { * @param ws :: Run wokspace * @return Number of periods */ -size_t numPeriods(Workspace_sptr ws) { +size_t numPeriods(const Workspace_sptr &ws) { if (auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(ws)) { return group->size(); } else { @@ -122,7 +123,7 @@ size_t numPeriods(Workspace_sptr ws) { * @param runWs :: Run workspace to retrieve information from * @param out :: Stream to print to */ -void printRunInfo(MatrixWorkspace_sptr runWs, std::ostringstream &out) { +void printRunInfo(const MatrixWorkspace_sptr &runWs, std::ostringstream &out) { // Remember current out stream format std::ios_base::fmtflags outFlags(out.flags()); std::streamsize outPrecision(out.precision()); @@ -253,7 +254,7 @@ void WidgetAutoSaver::registerWidget(QWidget *widget, const QString &name, QVariant defaultValue) { m_registeredWidgets.push_back(widget); m_widgetNames[widget] = name; - m_widgetDefaultValues[widget] = defaultValue; + m_widgetDefaultValues[widget] = std::move(defaultValue); m_widgetGroups[widget] = m_settings.group(); // Current group set up using beginGroup and endGroup } @@ -710,7 +711,7 @@ void replaceLogValue(const std::string &wsName, const std::string &logName, * @param logName :: [input] Name of log * @returns All values found for the given log */ -std::vector<std::string> findLogValues(const Workspace_sptr ws, +std::vector<std::string> findLogValues(const Workspace_sptr &ws, const std::string &logName) { std::vector<std::string> values; MatrixWorkspace_sptr matrixWS; @@ -747,7 +748,7 @@ std::vector<std::string> findLogValues(const Workspace_sptr ws, * @returns :: Pair of (smallest, largest) values */ std::pair<std::string, std::string> findLogRange( - const Workspace_sptr ws, const std::string &logName, + const Workspace_sptr &ws, const std::string &logName, bool (*isLessThan)(const std::string &first, const std::string &second)) { auto values = findLogValues(ws, logName); if (!values.empty()) { @@ -793,7 +794,8 @@ std::pair<std::string, std::string> findLogRange( * @throws std::invalid_argument if the workspaces supplied are null or have * different number of periods */ -void appendTimeSeriesLogs(Workspace_sptr toAppend, Workspace_sptr resultant, +void appendTimeSeriesLogs(const Workspace_sptr &toAppend, + const Workspace_sptr &resultant, const std::string &logName) { // check input if (!toAppend || !resultant) { @@ -802,7 +804,7 @@ void appendTimeSeriesLogs(Workspace_sptr toAppend, Workspace_sptr resultant, } // Cast the inputs to MatrixWorkspace (could be a group) - auto getWorkspaces = [](const Workspace_sptr ws) { + auto getWorkspaces = [](const Workspace_sptr &ws) { std::vector<MatrixWorkspace_sptr> workspaces; MatrixWorkspace_sptr matrixWS = boost::dynamic_pointer_cast<MatrixWorkspace>(ws); @@ -824,7 +826,7 @@ void appendTimeSeriesLogs(Workspace_sptr toAppend, Workspace_sptr resultant, }; // Extract time series log from workspace - auto getTSLog = [&logName](const MatrixWorkspace_sptr ws) { + auto getTSLog = [&logName](const MatrixWorkspace_sptr &ws) { const Mantid::API::Run &run = ws->run(); TimeSeriesProperty<double> *prop = nullptr; if (run.hasProperty(logName)) { @@ -905,8 +907,8 @@ QString runNumberString(const std::string &workspaceName, * @throws std::invalid_argument if loadedWorkspace is null */ bool isReloadGroupingNecessary( - const boost::shared_ptr<Mantid::API::Workspace> currentWorkspace, - const boost::shared_ptr<Mantid::API::Workspace> loadedWorkspace) { + const boost::shared_ptr<Mantid::API::Workspace> ¤tWorkspace, + const boost::shared_ptr<Mantid::API::Workspace> &loadedWorkspace) { if (!loadedWorkspace) { throw std::invalid_argument("No loaded workspace to get grouping for!"); } diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h index 8eb5319168f12e98d98325873e2e5fafb13ebab5..4044b3314635ac50cefe91cab379eff63d4856a1 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h @@ -50,7 +50,7 @@ MANTIDQT_MUONINTERFACE_DLL void setDoubleValidator(QLineEdit *field, /// Returns a first period MatrixWorkspace in a run workspace MANTIDQT_MUONINTERFACE_DLL Mantid::API::MatrixWorkspace_sptr -firstPeriod(Mantid::API::Workspace_sptr ws); +firstPeriod(const Mantid::API::Workspace_sptr &ws); /// Validates the field and returns the value MANTIDQT_MUONINTERFACE_DLL double @@ -58,11 +58,13 @@ getValidatedDouble(QLineEdit *field, const QString &defaultValue, const QString &valueDescr, Mantid::Kernel::Logger &log); /// Returns a number of periods in a run workspace -MANTIDQT_MUONINTERFACE_DLL size_t numPeriods(Mantid::API::Workspace_sptr ws); +MANTIDQT_MUONINTERFACE_DLL size_t +numPeriods(const Mantid::API::Workspace_sptr &ws); /// Print various information about the run MANTIDQT_MUONINTERFACE_DLL void -printRunInfo(Mantid::API::MatrixWorkspace_sptr runWs, std::ostringstream &out); +printRunInfo(const Mantid::API::MatrixWorkspace_sptr &runWs, + std::ostringstream &out); /// Get a run label for the workspace MANTIDQT_MUONINTERFACE_DLL std::string @@ -97,11 +99,12 @@ MANTIDQT_MUONINTERFACE_DLL void replaceLogValue(const std::string &wsName, /// Finds all of the values for a log MANTIDQT_MUONINTERFACE_DLL std::vector<std::string> -findLogValues(const Mantid::API::Workspace_sptr ws, const std::string &logName); +findLogValues(const Mantid::API::Workspace_sptr &ws, + const std::string &logName); /// Finds the range of values for a log MANTIDQT_MUONINTERFACE_DLL std::pair<std::string, std::string> findLogRange( - const Mantid::API::Workspace_sptr ws, const std::string &logName, + const Mantid::API::Workspace_sptr &ws, const std::string &logName, bool (*isLessThan)(const std::string &first, const std::string &second)); /// Finds the range of values for a log for a vector of workspaces @@ -112,8 +115,8 @@ MANTIDQT_MUONINTERFACE_DLL std::pair<std::string, std::string> findLogRange( /// Concatenates time-series log of one workspace with the second MANTIDQT_MUONINTERFACE_DLL void -appendTimeSeriesLogs(boost::shared_ptr<Mantid::API::Workspace> toAppend, - boost::shared_ptr<Mantid::API::Workspace> resultant, +appendTimeSeriesLogs(const boost::shared_ptr<Mantid::API::Workspace> &toAppend, + const boost::shared_ptr<Mantid::API::Workspace> &resultant, const std::string &logName); /// Parse analysis workspace name @@ -130,8 +133,8 @@ runNumberString(const std::string &workspaceName, const std::string &firstRun); /// Decide if grouping needs to be reloaded MANTIDQT_MUONINTERFACE_DLL bool isReloadGroupingNecessary( - const boost::shared_ptr<Mantid::API::Workspace> currentWorkspace, - const boost::shared_ptr<Mantid::API::Workspace> loadedWorkspace); + const boost::shared_ptr<Mantid::API::Workspace> ¤tWorkspace, + const boost::shared_ptr<Mantid::API::Workspace> &loadedWorkspace); /// Parse run label into instrument and runs MANTIDQT_MUONINTERFACE_DLL void parseRunLabel(const std::string &label, diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp index 976259602cd2787aee33cf41f8527d287be34b2e..73921efcb8fea5d35423860779f5246c4ab6fd03 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.cpp @@ -278,7 +278,7 @@ void MuonAnalysisResultTableCreator::checkSameNumberOfDatasets( const size_t firstNumRuns = workspacesByLabel.begin()->second.size(); if (std::any_of(workspacesByLabel.begin(), workspacesByLabel.end(), [&firstNumRuns]( - const std::pair<QString, std::vector<std::string>> fit) { + const std::pair<QString, std::vector<std::string>> &fit) { return fit.second.size() != firstNumRuns; })) { throw std::runtime_error( @@ -753,7 +753,7 @@ bool MuonAnalysisResultTableCreator::haveSameParameters( * @param table :: [input, output] Pointer to TableWorkspace to edit */ void MuonAnalysisResultTableCreator::removeFixedParameterErrors( - const ITableWorkspace_sptr table) const { + const ITableWorkspace_sptr &table) const { assert(table); const size_t nRows = table->rowCount(); const auto colNames = table->getColumnNames(); diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h index 35b5255dfbc6684c75a59648359bfaa3ed82cc52..54a07a44d503cc7fa7a7b082695a3d8413f65984 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableCreator.h @@ -37,7 +37,7 @@ protected: const std::vector<Mantid::API::ITableWorkspace_sptr> &tables) const; /// Remove error columns for fixed parameters from a results table void removeFixedParameterErrors( - const Mantid::API::ITableWorkspace_sptr table) const; + const Mantid::API::ITableWorkspace_sptr &table) const; private: /// Get map of label to workspaces diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp index ad0aaa54505281b32aefeb452574c3cf2a5fcda0..448285609140d4f8ffee450bf343be3858bea5cf 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp @@ -676,7 +676,7 @@ bool MuonAnalysisResultTableTab::logNameLessThan(const QString &logName1, */ void MuonAnalysisResultTableTab::populateFittings( const QStringList &names, - std::function<Workspace_sptr(const QString &)> wsFromName) { + const std::function<Workspace_sptr(const QString &)> &wsFromName) { // Add number of rows for the amount of fittings. m_uiForm.fittingResultsTable->setRowCount(names.size()); diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h index e055b3238f8b59074f5e5295845db9df4bd62ffa..180e873717d2cdb4d87d28a654488d4887ebb6a9 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.h @@ -98,7 +98,8 @@ private: void populateLogsAndValues(const QStringList &fittedWsList); void populateFittings( const QStringList &names, - std::function<Mantid::API::Workspace_sptr(const QString &)> wsFromName); + const std::function<Mantid::API::Workspace_sptr(const QString &)> + &wsFromName); /// Creates the results table void createTable(bool multipleFits); diff --git a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp index b4b32f5cd36240f94824cd7ef319f5673d687369..12bbd3b993f3df84ee1ccd873defa97ad6d5e185 100644 --- a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp +++ b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.cpp @@ -140,7 +140,8 @@ std::string MuonSequentialFitDialog::isValidLabel(const std::string &label) { * @param ws :: Workspace to get title from * @return The title, or empty string if unable to get one */ -std::string MuonSequentialFitDialog::getRunTitle(Workspace_const_sptr ws) { +std::string +MuonSequentialFitDialog::getRunTitle(const Workspace_const_sptr &ws) { auto matrixWS = boost::dynamic_pointer_cast<const MatrixWorkspace>(ws); if (!matrixWS) @@ -194,9 +195,9 @@ void MuonSequentialFitDialog::initDiagnosisTable() { * @param fitQuality :: Number representing goodness of the fit * @param fittedFunction :: Function containing fitted parameters */ -void MuonSequentialFitDialog::addDiagnosisEntry(const std::string &runTitle, - double fitQuality, - IFunction_sptr fittedFunction) { +void MuonSequentialFitDialog::addDiagnosisEntry( + const std::string &runTitle, double fitQuality, + const IFunction_sptr &fittedFunction) { int newRow = m_ui.diagnosisTable->rowCount(); m_ui.diagnosisTable->insertRow(newRow); diff --git a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h index ae4b581bbc7c780e096a52959b25e7c9fc4c5154..b63041d86e7e39fd1e5e6cc65b137fee01f10aa9 100644 --- a/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h +++ b/qt/scientific_interfaces/Muon/MuonSequentialFitDialog.h @@ -56,7 +56,7 @@ private: /// Add a new entry to the diagnosis table void addDiagnosisEntry(const std::string &runTitle, double fitQuality, - Mantid::API::IFunction_sptr fittedFunction); + const Mantid::API::IFunction_sptr &fittedFunction); /// Helper function to create new item for Diagnosis table QTableWidgetItem *createTableWidgetItem(const QString &text); @@ -90,7 +90,7 @@ private: static std::string isValidLabel(const std::string &label); /// Returns displayable title for the given workspace - static std::string getRunTitle(Mantid::API::Workspace_const_sptr ws); + static std::string getRunTitle(const Mantid::API::Workspace_const_sptr &ws); // -- SLOTS ------------------------------------------------------ diff --git a/qt/scientific_interfaces/test/EnggDiffFittingModelTest.h b/qt/scientific_interfaces/test/EnggDiffFittingModelTest.h new file mode 100644 index 0000000000000000000000000000000000000000..7a7355b78ced0fbe7863d5bc2f7c3910b5339fa0 --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffFittingModelTest.h @@ -0,0 +1,312 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/Run.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" + +#include "../EnggDiffraction/EnggDiffFittingModel.h" + +#include <cxxtest/TestSuite.h> +#include <utility> + +#include <vector> + +using namespace Mantid; +using namespace MantidQt::CustomInterfaces; + +namespace { + +// Helper class that exposes addFocusedWorkspace +// This means we can test the workspace maps without having to run Load +class EnggDiffFittingModelAddWSExposed : public EnggDiffFittingModel { +public: + void addWorkspace(const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr &ws); + + void addFitParams(const RunLabel &runLabel, + const Mantid::API::ITableWorkspace_sptr &ws); + + void mergeTablesExposed(const API::ITableWorkspace_sptr &tableToCopy, + const API::ITableWorkspace_sptr &targetTable); +}; + +inline void EnggDiffFittingModelAddWSExposed::addWorkspace( + const RunLabel &runLabel, const API::MatrixWorkspace_sptr &ws) { + addFocusedWorkspace(runLabel, std::move(ws), + runLabel.runNumber + "_" + std::to_string(runLabel.bank)); +} + +inline void EnggDiffFittingModelAddWSExposed::addFitParams( + const RunLabel &runLabel, const Mantid::API::ITableWorkspace_sptr &ws) { + addFitResults(runLabel, std::move(ws)); +} + +inline void EnggDiffFittingModelAddWSExposed::mergeTablesExposed( + const API::ITableWorkspace_sptr &tableToCopy, + const API::ITableWorkspace_sptr &targetTable) { + mergeTables(std::move(tableToCopy), std::move(targetTable)); +} + +void addSampleWorkspaceToModel(const RunLabel &runLabel, + EnggDiffFittingModelAddWSExposed &model) { + API::MatrixWorkspace_sptr ws = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + model.addWorkspace(runLabel, ws); +} + +API::ITableWorkspace_sptr createFitParamsTable() { + const size_t numColumns = 16; + const size_t numRows = 4; + auto table = API::WorkspaceFactory::Instance().createTable("TableWorkspace"); + const std::array<std::string, numColumns> headings({{ + "dSpacing[Y]", + "A0[Y]", + "A0_Err[yEr]", + "A1[Y]", + "A1_Err[yEr]", + "X0[Y]", + "X0_Err[yEr]", + "A[Y]", + "A_Err[yEr]", + "B[Y]", + "B_Err[yEr]", + "S[Y]", + "S_Err[yEr]", + "I[Y]", + "I_Err[yEr]", + "Chi[Y]", + }}); + + for (const auto &columnHeading : headings) { + table->addColumn("double", columnHeading); + } + + const std::array<std::array<double, numColumns>, numRows> rows = { + {{{1.4826999999999999, 0.093628531894011102, 0.66109193835092461, + 1.2564478992707699e-06, 2.4291293347225761e-05, 27140.960929827994, + 4.4430783321852303, 0.045621368052062856, 0.0092005773305902459, + 0.020298218347394655, 0.0025002243189996306, 11.741120992807753, + 5.3771683079349311, 34.202007864467461, 1.8695496489293224, + 1.4096728498206776}}, + {{1.7197, 1.0731062065126851, 0.72931461734063008, + -2.9359794063082084e-05, 2.285663646689115e-05, 31770.101042814735, + 5.6899014393655358, 0.050855278541599255, 0.013915934527381201, + 0.029076388335360012, 0.002935493268317269, 27.132751332587915, + 4.5849081323418064, 89.646425792809978, 2.1570533782524279, + 0.79304374868658656}}, + {{2.2399, 1.3229681799066122, 0.45360789821414083, + -3.0219780224537017e-05, 1.0941426250415265e-05, 41266.973604075109, + 4.0391546488412224, 0.043604800066098286, 0.0071406722143233931, + 0.021740542092941812, 0.001008755490980281, 36.523446658868707, + 3.2982922870662814, 205.36292151601506, 2.3728608996241367, + 0.90144473999482344}}, + {{2.552, 0.46162942972449567, 0.24323265893625406, + -9.0850559562388256e-06, 5.1638893666718458e-06, 46982.314791027922, + 46.041577282817634, 0.14208244137460718, 0.61720906575104273, + 0.018444321135930489, 0.0078725143001187933, 45.171720946242374, + 18.656365897259217, 14.950355673087914, 1.02699955199189, + 0.68147322764610252}}}}; + + for (const auto &row : rows) { + API::TableRow tableRow = table->appendRow(); + for (const auto entry : row) { + tableRow << entry; + } + } + return table; +} + +template <size_t numColumns, size_t numRows> +API::ITableWorkspace_sptr createDummyTable( + const std::array<std::string, numColumns> &columnHeadings, + const std::array<std::array<double, numColumns>, numRows> tableContents) { + auto table = API::WorkspaceFactory::Instance().createTable(); + for (const auto &header : columnHeadings) { + table->addColumn("double", header); + } + for (const auto &row : tableContents) { + API::TableRow newRow = table->appendRow(); + for (const auto value : row) { + newRow << value; + } + } + return table; +} + +} // anonymous namespace + +class EnggDiffFittingModelTest : 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 EnggDiffFittingModelTest *createSuite() { + return new EnggDiffFittingModelTest(); + } + static void destroySuite(EnggDiffFittingModelTest *suite) { delete suite; } + + EnggDiffFittingModelTest() { API::FrameworkManager::Instance(); } + + void test_addAndGetWorkspace() { + auto model = EnggDiffFittingModelAddWSExposed(); + API::MatrixWorkspace_sptr ws = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + + const RunLabel runLabel("100", 1); + TS_ASSERT_THROWS_NOTHING(model.addWorkspace(runLabel, ws)); + const auto retrievedWS = model.getFocusedWorkspace(runLabel); + + TS_ASSERT(retrievedWS != nullptr); + TS_ASSERT_EQUALS(ws, retrievedWS); + } + + void test_getRunNumbersAndBankIDs() { + auto model = EnggDiffFittingModelAddWSExposed(); + + addSampleWorkspaceToModel(RunLabel("123", 1), model); + addSampleWorkspaceToModel(RunLabel("456", 2), model); + addSampleWorkspaceToModel(RunLabel("789", 1), model); + addSampleWorkspaceToModel(RunLabel("123", 2), model); + + const auto runLabels = model.getRunLabels(); + + TS_ASSERT_EQUALS(runLabels.size(), 4); + TS_ASSERT_EQUALS(runLabels[0], RunLabel("123", 1)); + TS_ASSERT_EQUALS(runLabels[1], RunLabel("123", 2)); + TS_ASSERT_EQUALS(runLabels[2], RunLabel("456", 2)); + TS_ASSERT_EQUALS(runLabels[3], RunLabel("789", 1)); + } + + void test_loadWorkspaces() { + auto model = EnggDiffFittingModel(); + TS_ASSERT_THROWS_NOTHING(model.loadWorkspaces(FOCUSED_WS_FILENAME)); + API::MatrixWorkspace_sptr ws; + TS_ASSERT_THROWS_NOTHING( + ws = model.getFocusedWorkspace(FOCUSED_WS_RUN_LABEL)); + TS_ASSERT_EQUALS(ws->getNumberHistograms(), 1); + TS_ASSERT_EQUALS(std::to_string(ws->getRunNumber()), + FOCUSED_WS_RUN_LABEL.runNumber); + } + + void test_setDifcTzero() { + auto model = EnggDiffFittingModel(); + TS_ASSERT_THROWS_NOTHING(model.loadWorkspaces(FOCUSED_WS_FILENAME)); + + TS_ASSERT_THROWS_NOTHING(model.setDifcTzero( + FOCUSED_WS_RUN_LABEL, std::vector<GSASCalibrationParms>())); + auto ws = model.getFocusedWorkspace(FOCUSED_WS_RUN_LABEL); + auto run = ws->run(); + TS_ASSERT(run.hasProperty("difa")); + TS_ASSERT(run.hasProperty("difc")); + TS_ASSERT(run.hasProperty("tzero")); + } + + void test_createFittedPeaksWS() { + auto model = EnggDiffFittingModelAddWSExposed(); + + const auto fitParams = createFitParamsTable(); + TS_ASSERT_THROWS_NOTHING( + model.addFitParams(FOCUSED_WS_RUN_LABEL, fitParams)); + TS_ASSERT_THROWS_NOTHING(model.loadWorkspaces(FOCUSED_WS_FILENAME)); + + TS_ASSERT_THROWS_NOTHING(model.setDifcTzero( + FOCUSED_WS_RUN_LABEL, std::vector<GSASCalibrationParms>())); + TS_ASSERT_THROWS_NOTHING(model.createFittedPeaksWS(FOCUSED_WS_RUN_LABEL)); + + API::MatrixWorkspace_sptr fittedPeaksWS; + TS_ASSERT_THROWS_NOTHING(fittedPeaksWS = + model.getFittedPeaksWS(FOCUSED_WS_RUN_LABEL)); + TS_ASSERT_EQUALS(fittedPeaksWS->getNumberHistograms(), 4); + } + + void test_getNumFocusedWorkspaces() { + auto model = EnggDiffFittingModelAddWSExposed(); + + addSampleWorkspaceToModel(RunLabel("123", 1), model); + addSampleWorkspaceToModel(RunLabel("456", 2), model); + addSampleWorkspaceToModel(RunLabel("789", 1), model); + + TS_ASSERT_EQUALS(model.getNumFocusedWorkspaces(), 3); + } + + void test_mergeTables() { + auto model = EnggDiffFittingModelAddWSExposed(); + + const size_t numberOfColumns = 3; + const size_t numberOfRows = 2; + + const std::array<std::string, numberOfColumns> columnHeadings = { + {"X", "Y", "Z"}}; + + const std::array<std::array<double, numberOfColumns>, numberOfRows> + targetTableValues = {{{{1, 2, 3}}, {{4, 5, 6}}}}; + + auto targetTable = createDummyTable(columnHeadings, targetTableValues); + + const std::array<std::array<double, numberOfColumns>, numberOfRows> + copyTableValues = {{{{7, 8, 9}}, {{10, 11, 12}}}}; + + auto copyTable = createDummyTable(columnHeadings, copyTableValues); + + TS_ASSERT_THROWS_NOTHING(model.mergeTablesExposed(copyTable, targetTable)); + + TS_ASSERT_EQUALS(targetTable->columnCount(), numberOfColumns); + TS_ASSERT_EQUALS(targetTable->rowCount(), numberOfRows * 2); + + for (size_t rowIndex = 0; rowIndex < numberOfRows * 2; ++rowIndex) { + std::cout << "ROW " << rowIndex << "\n"; + API::TableRow row = targetTable->getRow(rowIndex); + const double expectedX = static_cast<double>(rowIndex) * 3 + 1; + const double expectedY = static_cast<double>(rowIndex) * 3 + 2; + const double expectedZ = static_cast<double>(rowIndex) * 3 + 3; + + // x, y and z must be initialized to keep RHEL7 happy + auto x = expectedX + 1; + auto y = expectedY + 1; + auto z = expectedZ + 1; + + TS_ASSERT_THROWS_NOTHING(row >> x >> y >> z); + TS_ASSERT_EQUALS(x, expectedX); + TS_ASSERT_EQUALS(y, expectedY); + TS_ASSERT_EQUALS(z, expectedZ); + } + } + + void test_removeRun() { + auto model = EnggDiffFittingModelAddWSExposed(); + + const RunLabel label1("123", 1); + addSampleWorkspaceToModel(label1, model); + const RunLabel label2("456", 2); + addSampleWorkspaceToModel(label2, model); + const RunLabel label3("789", 1); + addSampleWorkspaceToModel(label3, model); + + model.removeRun(label1); + + const auto runLabels = model.getRunLabels(); + TS_ASSERT_EQUALS(runLabels.size(), 2); + + TS_ASSERT_EQUALS(runLabels[0], label2); + TS_ASSERT_EQUALS(runLabels[1], label3); + } + +private: + const static std::string FOCUSED_WS_FILENAME; + const static RunLabel FOCUSED_WS_RUN_LABEL; +}; + +const std::string EnggDiffFittingModelTest::FOCUSED_WS_FILENAME = + "ENGINX_277208_focused_bank_2.nxs"; + +const RunLabel EnggDiffFittingModelTest::FOCUSED_WS_RUN_LABEL = + RunLabel("277208", 2); diff --git a/qt/scientific_interfaces/test/EnggDiffFittingPresenterTest.h b/qt/scientific_interfaces/test/EnggDiffFittingPresenterTest.h new file mode 100644 index 0000000000000000000000000000000000000000..94f569ca36d0d8658c7e2b8a4a33d9d85180014a --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffFittingPresenterTest.h @@ -0,0 +1,764 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggDiffFittingPresenter.h" +#include "MantidAPI/FrameworkManager.h" + +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include "EnggDiffFittingModelMock.h" +#include "EnggDiffFittingViewMock.h" +#include "EnggDiffractionParamMock.h" +#include <cxxtest/TestSuite.h> +#include <utility> + +#include <vector> + +using namespace MantidQt::CustomInterfaces; +using testing::Return; +using testing::ReturnRef; +using testing::TypedEq; + +// Use this mocked presenter for tests that will start the focusing +// workers/threads. Otherwise you'll run into trouble with issues like +// "QEventLoop: Cannot be used without QApplication", as there is not +// Qt application here and the normal Qt thread used by the presenter +// uses signals/slots. +class EnggDiffFittingPresenterNoThread : public EnggDiffFittingPresenter { +public: + EnggDiffFittingPresenterNoThread(IEnggDiffFittingView *view) + : EnggDiffFittingPresenterNoThread( + view, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>()) {} + + EnggDiffFittingPresenterNoThread(IEnggDiffFittingView *view, + std::unique_ptr<IEnggDiffFittingModel> model) + : EnggDiffFittingPresenter(view, std::move(model), nullptr, nullptr) {} + + EnggDiffFittingPresenterNoThread( + IEnggDiffFittingView *view, std::unique_ptr<IEnggDiffFittingModel> model, + boost::shared_ptr<IEnggDiffractionParam> mainParam) + : EnggDiffFittingPresenter(view, std::move(model), nullptr, + std::move(mainParam)) {} + +private: + // not async at all + void startAsyncFittingWorker(const std::vector<RunLabel> &runLabels, + const std::string &ExpectedPeaks) override { + assert(runLabels.size() == 1); + doFitting(runLabels, ExpectedPeaks); + fittingFinished(); + } +}; + +class EnggDiffFittingPresenterTest : public CxxTest::TestSuite { + +public: + // This pair of boilerplate methods prevent tghe suite being created + // statically + // This means the constructor isn't called when running other tests + static EnggDiffFittingPresenterTest *createSuite() { + return new EnggDiffFittingPresenterTest(); + } + + static void destroySuite(EnggDiffFittingPresenterTest *suite) { + delete suite; + } + + EnggDiffFittingPresenterTest() { + Mantid::API::FrameworkManager::Instance(); // make sure framework is + // initialized + } + + void setUp() override { + m_view.reset(new testing::NiceMock<MockEnggDiffFittingView>()); + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + + m_presenter.reset(new MantidQt::CustomInterfaces::EnggDiffFittingPresenter( + m_view.get(), std::move(mockModel), nullptr, nullptr)); + + // default banks + m_ex_enginx_banks.emplace_back(true); + m_ex_enginx_banks.emplace_back(false); + + // default run number + m_ex_empty_run_num.emplace_back(""); + m_invalid_run_number.emplace_back(""); + m_ex_run_number.emplace_back(g_validRunNo); + g_vanNo.emplace_back("8899999988"); + g_ceriaNo.emplace_back("9999999999"); + + // provide personal directories in order to carry out the full disable tests + m_basicCalibSettings.m_inputDirCalib = "GUI_calib_folder/"; + m_basicCalibSettings.m_inputDirRaw = "GUI_calib_folder/"; + + m_basicCalibSettings.m_pixelCalibFilename = + "ENGINX_full_pixel_calibration.csv"; + + m_basicCalibSettings.m_templateGSAS_PRM = "GUI_calib_folder/" + "template_ENGINX_241391_236516_" + "North_and_South_banks.prm"; + + m_basicCalibSettings.m_forceRecalcOverwrite = false; + m_basicCalibSettings.m_rebinCalibrate = 1; + } + + void tearDown() override { + TS_ASSERT(testing::Mock::VerifyAndClearExpectations(m_view.get())); + } + + void test_load_with_missing_param() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, std::move(mockModel), nullptr, nullptr); + + EXPECT_CALL(mockView, getFocusedFileNames()).Times(1).WillOnce(Return("")); + + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + + // Should never get as far as trying to load + EXPECT_CALL(*mockModel_ptr, loadWorkspaces(testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::Load); + TSM_ASSERT( + "View mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + TSM_ASSERT( + "Model mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(mockModel_ptr)) + } + + void test_fitting_with_missing_param() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, std::move(mockModel), nullptr, nullptr); + + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::none)); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + // This would test the fitting tab with no focused workspace + // which should produce a warning + void test_fitting_without_focused_run() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + // inputs from user + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::none)); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + // This would test the fitting tab with invalid expected peaks but should only + // produce a warning + void test_fitting_with_invalid_expected_peaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::optional<std::string>( + boost::optional<std::string>("123_1")))); + EXPECT_CALL(*mockModel_ptr, getWorkspaceFilename(testing::_)) + .Times(1) + .WillOnce(ReturnRef(EMPTY)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return(",3.5,7.78,r43d")); + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitPeaks); + TSM_ASSERT( + "View mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + TSM_ASSERT( + "Model mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(mockModel_ptr)) + } + + // Fit All Peaks test begin here + void test_fit_all_runno_valid_single_run() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("2.3445,3.3433,4.5664")); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*mockModel_ptr, getRunLabels()) + .Times(1) + .WillOnce(Return(std::vector<RunLabel>({runLabel}))); + + EXPECT_CALL(*mockModel_ptr, getWorkspaceFilename(runLabel)) + .Times(1) + .WillOnce(ReturnRef(EMPTY)); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + EXPECT_CALL(mockView, enableFitAllButton(testing::_)).Times(0); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log because dir vector + // is empty + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitAllPeaks); + } + + // This would test the fitting tab with invalid expected peaks but should only + // produce a warning + void test_fit_all_with_invalid_expected_peaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + // inputs from user + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return(",3.5,7.78,r43d")); + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*mockModel_ptr, getRunLabels()) + .Times(1) + .WillOnce(Return(std::vector<RunLabel>({runLabel}))); + + EXPECT_CALL(*mockModel_ptr, getWorkspaceFilename(runLabel)) + .Times(1) + .WillOnce(ReturnRef(EMPTY)); + + // should not get to the point where the status is updated + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/1 warnings. There will be an error log from the algorithms + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::FitAllPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_browse_peaks_list() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + EXPECT_CALL(mockView, getOpenFile(userDir)).Times(1); + + EXPECT_CALL(mockView, getSaveFile(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::browsePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_browse_peaks_list_with_warning() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + std::string dummyDir = "I/am/a/dummy/directory"; + + EXPECT_CALL(mockView, getOpenFile(userDir)) + .Times(1) + .WillOnce(Return(dummyDir)); + + EXPECT_CALL(mockView, setPreviousDir(dummyDir)).Times(1); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::browsePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_save_peaks_list() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + EXPECT_CALL(mockView, getSaveFile(userDir)).Times(1); + + // No errors/No warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::savePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_save_peaks_list_with_warning() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + const auto paramMock = + boost::make_shared<testing::NiceMock<MockEnggDiffractionParam>>(); + EnggDiffFittingPresenterNoThread pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + paramMock); + + const auto &userDir(Poco::Path::home()); + EXPECT_CALL(*paramMock, outFilesUserDir("")) + .Times(1) + .WillOnce(Return(userDir)); + + std::string dummyDir = "/dummy/directory/"; + EXPECT_CALL(mockView, getSaveFile(userDir)) + .Times(1) + .WillOnce(Return(dummyDir)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()).Times(0); + + // No errors/1 warnings. Dummy file entered is not found + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(1); + + pres.notify(IEnggDiffFittingPresenter::savePeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_peaks_to_empty_list() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("")); + ; + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(1); + + // should not be updating the status + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_peaks_with_disabled_peak_picker() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(false)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(0); + + EXPECT_CALL(mockView, getExpectedPeaksInput()).Times(0); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + + // should not be updating the status + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_valid_peaks_to_list_with_comma() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1).WillOnce(Return(2.0684)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("1.7906,2.0684,1.2676,")); + + EXPECT_CALL(mockView, setPeakList("1.7906,2.0684,1.2676,2.0684")).Times(1); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_customised_valid_peaks_to_list_without_comma() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1).WillOnce(Return(3.0234)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("2.0684,1.2676")); + + EXPECT_CALL(mockView, setPeakList("2.0684,1.2676,3.0234")).Times(1); + + // should not be updating the status + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + // No errors/0 warnings. + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_add_invalid_peaks_to_list() { + + testing::NiceMock<MockEnggDiffFittingView> mockView; + EnggDiffFittingPresenterNoThread pres(&mockView); + + EXPECT_CALL(mockView, peakPickerEnabled()).Times(1).WillOnce(Return(true)); + + EXPECT_CALL(mockView, getPeakCentre()).Times(1).WillOnce(Return(0.0133)); + + EXPECT_CALL(mockView, getExpectedPeaksInput()) + .Times(1) + .WillOnce(Return("")); + + // string should be "0.133," instead + EXPECT_CALL(mockView, setPeakList("0.0133")).Times(0); + EXPECT_CALL(mockView, setPeakList(",0.0133")).Times(0); + EXPECT_CALL(mockView, setPeakList("0.0133,")).Times(1); + + // No errors/0 warnings. File entered is not found + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::addPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_shutDown() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(), + nullptr, nullptr); + + EXPECT_CALL(mockView, setPeakList(testing::_)).Times(0); + EXPECT_CALL(mockView, getFocusedFileNames()).Times(0); + EXPECT_CALL(mockView, getFittingRunNumVec()).Times(0); + + EXPECT_CALL(mockView, getFittingMultiRunMode()).Times(0); + + EXPECT_CALL(mockView, showStatus(testing::_)).Times(0); + + EXPECT_CALL(mockView, saveSettings()).Times(1); + // No errors, no warnings + EXPECT_CALL(mockView, userError(testing::_, testing::_)).Times(0); + EXPECT_CALL(mockView, userWarning(testing::_, testing::_)).Times(0); + + pres.notify(IEnggDiffFittingPresenter::ShutDown); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_removeRun() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + MantidQt::CustomInterfaces::EnggDiffFittingPresenter pres( + &mockView, std::move(mockModel), nullptr, nullptr); + + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, removeRun(RunLabel("123", 1))); + EXPECT_CALL(*mockModel_ptr, getRunLabels()) + .Times(1) + .WillOnce(Return( + std::vector<RunLabel>({RunLabel("123", 2), RunLabel("456", 1)}))); + EXPECT_CALL(mockView, updateFittingListWidget( + std::vector<std::string>({"123_2", "456_1"}))); + + pres.notify(IEnggDiffFittingPresenter::removeRun); + + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_updatePlotFittedPeaksValidFittedPeaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(2) + .WillRepeatedly(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getAlignedWorkspace(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, plotFittedPeaksEnabled()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getFittedPeaksWS(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, + setDataVector(testing::_, testing::_, testing::_, testing::_)) + .Times(2); + + pres.notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_updatePlotFittedPeaksNoFittedPeaks() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(1) + .WillOnce(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(false)); + EXPECT_CALL(*mockModel_ptr, getFocusedWorkspace(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, plotFittedPeaksEnabled()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getFittedPeaksWS(runLabel)).Times(0); + EXPECT_CALL(mockView, + setDataVector(testing::_, testing::_, testing::_, testing::_)) + .Times(1); + EXPECT_CALL(mockView, userWarning("Cannot plot fitted peaks", testing::_)) + .Times(1); + + pres.notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + + void test_updatePlotSuccessfulFitPlotPeaksDisabled() { + testing::NiceMock<MockEnggDiffFittingView> mockView; + auto mockModel = + std::make_unique<testing::NiceMock<MockEnggDiffFittingModel>>(); + auto *mockModel_ptr = mockModel.get(); + + EnggDiffFittingPresenterNoThread pres(&mockView, std::move(mockModel)); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(mockView, getFittingListWidgetCurrentValue()) + .Times(2) + .WillRepeatedly(Return(boost::optional<std::string>("123_1"))); + EXPECT_CALL(*mockModel_ptr, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*mockModel_ptr, getAlignedWorkspace(runLabel)) + .Times(1) + .WillOnce(Return(WorkspaceCreationHelper::create2DWorkspace(10, 10))); + EXPECT_CALL(mockView, plotFittedPeaksEnabled()) + .Times(1) + .WillOnce(Return(false)); + EXPECT_CALL(*mockModel_ptr, getFittedPeaksWS(runLabel)).Times(0); + EXPECT_CALL(mockView, + setDataVector(testing::_, testing::_, testing::_, testing::_)) + .Times(1); + + pres.notify(IEnggDiffFittingPresenter::updatePlotFittedPeaks); + TSM_ASSERT( + "Mock not used as expected. Some EXPECT_CALL conditions were not " + "satisfied.", + testing::Mock::VerifyAndClearExpectations(&mockView)) + } + +private: + std::unique_ptr<testing::NiceMock<MockEnggDiffFittingView>> m_view; + std::unique_ptr<MantidQt::CustomInterfaces::EnggDiffFittingPresenter> + m_presenter; + + std::vector<bool> m_ex_enginx_banks; + const static std::string g_validRunNo; + const static std::string g_focusedRun; + const static std::string g_focusedBankFile; + const static std::string g_focusedFittingRunNo; + const static std::string EMPTY; + EnggDiffCalibSettings m_basicCalibSettings; + + std::vector<std::string> m_ex_empty_run_num; + std::vector<std::string> m_invalid_run_number; + std::vector<std::string> m_ex_run_number; + std::vector<std::string> g_vanNo; + std::vector<std::string> g_ceriaNo; +}; + +const std::string EnggDiffFittingPresenterTest::g_focusedRun = + "focused_texture_bank_1"; + +const std::string EnggDiffFittingPresenterTest::g_validRunNo = "228061"; + +const std::string EnggDiffFittingPresenterTest::g_focusedBankFile = + "ENGINX_241395_focused_texture_bank_1"; + +const std::string EnggDiffFittingPresenterTest::g_focusedFittingRunNo = + "241391-241394"; + +const std::string EnggDiffFittingPresenterTest::EMPTY = ""; diff --git a/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h new file mode 100644 index 0000000000000000000000000000000000000000..245b8b7b1a4561ffff018192125fedab73ea7b28 --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h @@ -0,0 +1,289 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggDiffGSASFittingModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include <cxxtest/TestSuite.h> + +#include <utility> + +using namespace Mantid; +using namespace MantidQt::CustomInterfaces; + +namespace { // Helpers + +std::vector<GSASIIRefineFitPeaksParameters> +createGSASIIRefineFitPeaksParameters( + const API::MatrixWorkspace_sptr &inputWS, const RunLabel &runLabel, + const GSASRefinementMethod &refinementMethod) { + return {GSASIIRefineFitPeaksParameters( + inputWS, runLabel, refinementMethod, "", std::vector<std::string>({}), "", + "", boost::none, boost::none, boost::none, boost::none, false, false)}; +} + +template <size_t numColumns, size_t numRows> +API::ITableWorkspace_sptr createDummyTable( + const std::array<std::string, numColumns> &columnHeadings, + const std::array<std::array<double, numColumns>, numRows> tableContents) { + auto table = API::WorkspaceFactory::Instance().createTable(); + for (const auto &header : columnHeadings) { + table->addColumn("double", header); + } + for (const auto &row : tableContents) { + API::TableRow newRow = table->appendRow(); + for (const auto value : row) { + newRow << value; + } + } + return table; +} + +// Helper class with some protected methods exposed +class TestEnggDiffGSASFittingModel : public EnggDiffGSASFittingModel { +public: + void addGammaValue(const RunLabel &runLabel, const double gamma); + + void addLatticeParamTable(const RunLabel &runLabel, + const API::ITableWorkspace_sptr &table); + + void addRwpValue(const RunLabel &runLabel, const double rwp); + + void addSigmaValue(const RunLabel &runLabel, const double sigma); + + void doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) override; +}; + +inline void +TestEnggDiffGSASFittingModel::addGammaValue(const RunLabel &runLabel, + const double gamma) { + addGamma(runLabel, gamma); +} + +inline void TestEnggDiffGSASFittingModel::addLatticeParamTable( + const RunLabel &runLabel, const API::ITableWorkspace_sptr &table) { + addLatticeParams(runLabel, std::move(table)); +} + +inline void TestEnggDiffGSASFittingModel::addRwpValue(const RunLabel &runLabel, + const double rwp) { + addRwp(runLabel, rwp); +} + +inline void +TestEnggDiffGSASFittingModel::addSigmaValue(const RunLabel &runLabel, + const double sigma) { + addSigma(runLabel, sigma); +} + +void TestEnggDiffGSASFittingModel::doRefinements( + const std::vector<GSASIIRefineFitPeaksParameters> ¶ms) { + // Mock method - just create some dummy output and ignore all the parameters + UNUSED_ARG(params); + + const static std::array<std::string, 3> columnHeadings = {{"a", "b", "c"}}; + const static std::array<std::array<double, 3>, 1> targetTableValues = { + {{{1, 2, 3}}}}; + const auto latticeParams = + createDummyTable(columnHeadings, targetTableValues); + + API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); + ADS.add("LATTICEPARAMS", latticeParams); + + API::MatrixWorkspace_sptr ws = + WorkspaceCreationHelper::create2DWorkspaceBinned(4, 4, 0.5); + ADS.add("FITTEDPEAKS", ws); + + processRefinementSuccessful( + nullptr, GSASIIRefineFitPeaksOutputProperties(1, 2, 3, ws, latticeParams, + params[0].runLabel)); +} + +} // Anonymous namespace + +class EnggDiffGSASFittingModelTest : 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 EnggDiffGSASFittingModelTest *createSuite() { + return new EnggDiffGSASFittingModelTest(); + } + static void destroySuite(EnggDiffGSASFittingModelTest *suite) { + delete suite; + } + + EnggDiffGSASFittingModelTest() { API::FrameworkManager::Instance(); } + + void test_validLoadRun() { + const static std::string inputFilename = "ENGINX_277208_focused_bank_2.nxs"; + TestEnggDiffGSASFittingModel model; + + API::MatrixWorkspace_sptr ws; + TS_ASSERT_THROWS_NOTHING(ws = model.loadFocusedRun(inputFilename)); + TS_ASSERT(ws); + } + + void test_invalidLoadRun() { + const static std::string inputFilename = "ENGINX_277209_focused_bank_2.nxs"; + TestEnggDiffGSASFittingModel model; + + API::MatrixWorkspace_sptr ws; + TS_ASSERT_THROWS_ANYTHING(ws = model.loadFocusedRun(inputFilename)); + TS_ASSERT(!ws); + } + + void test_getRwp() { + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + const double rwp = 75.5; + model.addRwpValue(valid, rwp); + + auto retrievedRwp = boost::make_optional<double>(false, double()); + TS_ASSERT_THROWS_NOTHING(retrievedRwp = model.getRwp(valid)); + TS_ASSERT(retrievedRwp); + TS_ASSERT_EQUALS(rwp, *retrievedRwp); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedRwp = model.getRwp(invalid)); + TS_ASSERT_EQUALS(retrievedRwp, boost::none); + } + + void test_getGamma() { + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + const double gamma = 75.5; + model.addGammaValue(valid, gamma); + + auto retrievedGamma = boost::make_optional<double>(false, double()); + TS_ASSERT_THROWS_NOTHING(retrievedGamma = model.getGamma(valid)); + TS_ASSERT(retrievedGamma); + TS_ASSERT_EQUALS(gamma, *retrievedGamma); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedGamma = model.getGamma(invalid)); + TS_ASSERT_EQUALS(retrievedGamma, boost::none); + } + + void test_getSigma() { + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + const double sigma = 75.5; + model.addSigmaValue(valid, sigma); + + auto retrievedSigma = boost::make_optional<double>(false, double()); + TS_ASSERT_THROWS_NOTHING(retrievedSigma = model.getSigma(valid)); + TS_ASSERT(retrievedSigma); + TS_ASSERT_EQUALS(sigma, *retrievedSigma); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedSigma = model.getSigma(invalid)); + TS_ASSERT_EQUALS(retrievedSigma, boost::none); + } + + void test_getLatticeParams() { + const std::array<std::string, 3> columnHeadings = {{"a", "b", "c"}}; + const std::array<std::array<double, 3>, 1> targetTableValues = { + {{{1, 2, 3}}}}; + const auto table = createDummyTable(columnHeadings, targetTableValues); + + TestEnggDiffGSASFittingModel model; + + const RunLabel valid("123", 1); + TS_ASSERT_THROWS_NOTHING(model.addLatticeParamTable(valid, table)); + + // auto retrievedTable = model.getLatticeParams(123, 1); + boost::optional<API::ITableWorkspace_sptr> retrievedTable; + TS_ASSERT_THROWS_NOTHING(retrievedTable = model.getLatticeParams(valid)); + TS_ASSERT(retrievedTable); + + API::TableRow row = (*retrievedTable)->getRow(0); + const double expectedA = 1; + const double expectedB = 2; + const double expectedC = 3; + auto a = expectedA + 1; + auto b = expectedB + 1; + auto c = expectedC + 1; + + TS_ASSERT_THROWS_NOTHING(row >> a >> b >> c); + TS_ASSERT_EQUALS(a, expectedA); + TS_ASSERT_EQUALS(b, expectedB); + TS_ASSERT_EQUALS(c, expectedC); + + const RunLabel invalid("456", 2); + TS_ASSERT_THROWS_NOTHING(retrievedTable = model.getLatticeParams(invalid)); + TS_ASSERT_EQUALS(retrievedTable, boost::none); + } + + void test_pawleyRefinement() { + // Note: due to the reliance on GSAS-II, this cannot test that the algorithm + // is used properly. It tests that, given that the algorithm is used + // properly, results are added to the appropriate maps in the model + TestEnggDiffGSASFittingModel model; + const RunLabel runLabel("123", 1); + + API::MatrixWorkspace_sptr inputWS = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + + TS_ASSERT_THROWS_NOTHING( + model.doRefinements(createGSASIIRefineFitPeaksParameters( + inputWS, runLabel, GSASRefinementMethod::PAWLEY))); + + const auto rwp = model.getRwp(runLabel); + TS_ASSERT(rwp); + + const auto sigma = model.getSigma(runLabel); + TS_ASSERT(sigma); + + const auto gamma = model.getGamma(runLabel); + TS_ASSERT(gamma); + + const auto latticeParams = model.getLatticeParams(runLabel); + TS_ASSERT(latticeParams); + + API::AnalysisDataService::Instance().clear(); + } + + void test_RietveldRefinement() { + // Note: due to the reliance on GSAS-II, this cannot test that the algorithm + // is used properly. It tests that, given that the algorithm is used + // properly, results are added to the appropriate maps in the model + TestEnggDiffGSASFittingModel model; + const RunLabel runLabel("123", 1); + + API::MatrixWorkspace_sptr inputWS = + API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); + + TS_ASSERT_THROWS_NOTHING( + model.doRefinements(createGSASIIRefineFitPeaksParameters( + inputWS, runLabel, GSASRefinementMethod::RIETVELD))); + + const auto rwp = model.getRwp(runLabel); + TS_ASSERT(rwp); + + const auto sigma = model.getSigma(runLabel); + TS_ASSERT(sigma); + + const auto gamma = model.getGamma(runLabel); + TS_ASSERT(gamma); + + const auto latticeParams = model.getLatticeParams(runLabel); + TS_ASSERT(latticeParams); + + API::AnalysisDataService::Instance().clear(); + } +}; diff --git a/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetPresenterTest.h b/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetPresenterTest.h new file mode 100644 index 0000000000000000000000000000000000000000..f46a1ee251847b71f520a41cce1f9f1641b142dd --- /dev/null +++ b/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetPresenterTest.h @@ -0,0 +1,393 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggDiffMultiRunFittingWidgetPresenter.h" +#include "EnggDiffMultiRunFittingWidgetModelMock.h" +#include "EnggDiffMultiRunFittingWidgetViewMock.h" + +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include <cxxtest/TestSuite.h> + +using namespace Mantid; + +using namespace MantidQt::CustomInterfaces; +using testing::Return; + +namespace { +API::MatrixWorkspace_sptr createSampleWorkspace() { + return API::WorkspaceFactory::Instance().create("Workspace2D", 1, 1, 1); +} + +void addBankID(const API::MatrixWorkspace_sptr &ws, const size_t bankID) { + auto addLogAlg = + API::FrameworkManager::Instance().createAlgorithm("AddSampleLog"); + addLogAlg->initialize(); + addLogAlg->setProperty("Workspace", ws); + addLogAlg->setPropertyValue("LogName", "bankid"); + addLogAlg->setPropertyValue("LogText", std::to_string(bankID)); + addLogAlg->setPropertyValue("LogType", "Number"); + addLogAlg->execute(); +} +} // namespace + +class EnggDiffMultiRunFittingWidgetPresenterTest : public CxxTest::TestSuite { +public: + void test_addFittedPeaks() { + auto presenter = setUpPresenter(); + const auto ws = createSampleWorkspace(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockModel, addFittedPeaks(runLabel, ws)).Times(1); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(ws)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(testing::_)).Times(0); + EXPECT_CALL(*m_mockView, resetCanvas()).Times(1); + EXPECT_CALL(*m_mockView, plotFocusedRun(testing::_)).Times(1); + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*m_mockView, showFitResultsSelected()) + .Times(1) + .WillOnce(Return(false)); + EXPECT_CALL(*m_mockModel, getFittedPeaks(testing::_)).Times(0); + + presenter->addFittedPeaks(runLabel, ws); + assertMocksUsedCorrectly(); + } + + void test_addFocusedRun() { + auto presenter = setUpPresenter(); + const API::MatrixWorkspace_sptr ws = createSampleWorkspace(); + addBankID(ws, 2); + const RunLabel runLabel("0", 2); + + const std::vector<RunLabel> workspaceLabels({runLabel}); + EXPECT_CALL(*m_mockModel, getAllWorkspaceLabels()) + .Times(1) + .WillOnce(Return(workspaceLabels)); + + EXPECT_CALL(*m_mockView, updateRunList(workspaceLabels)); + presenter->addFocusedRun(ws); + assertMocksUsedCorrectly(); + } + + void test_loadRunUpdatesView() { + auto presenter = setUpPresenter(); + const API::MatrixWorkspace_sptr ws = createSampleWorkspace(); + addBankID(ws, 2); + + const RunLabel runLabel("0", 2); + const std::vector<RunLabel> workspaceLabels({runLabel}); + ON_CALL(*m_mockModel, getAllWorkspaceLabels()) + .WillByDefault(Return(workspaceLabels)); + EXPECT_CALL(*m_mockView, updateRunList(workspaceLabels)); + + presenter->addFocusedRun(ws); + assertMocksUsedCorrectly(); + } + + void test_getFittedPeaks() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockModel, getFittedPeaks(runLabel)) + .Times(1) + .WillOnce(Return(boost::none)); + + presenter->getFittedPeaks(runLabel); + assertMocksUsedCorrectly(); + } + + void test_getFocusedRun() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(boost::none)); + + presenter->getFocusedRun(runLabel); + assertMocksUsedCorrectly(); + } + + void test_selectValidRunWithoutFittedPeaks() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(createSampleWorkspace())); + + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(testing::_)).Times(0); + EXPECT_CALL(*m_mockView, resetCanvas()).Times(1); + EXPECT_CALL(*m_mockView, plotFocusedRun(testing::_)).Times(1); + + ON_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .WillByDefault(Return(false)); + EXPECT_CALL(*m_mockView, plotFittedPeaks(testing::_)).Times(0); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_selectRunInvalid() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(runLabel)).Times(1); + EXPECT_CALL(*m_mockView, resetCanvas()).Times(0); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_selectValidRunWithFittedPeaks() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + ON_CALL(*m_mockView, getSelectedRunLabel()).WillByDefault(Return(runLabel)); + + const auto sampleWorkspace = createSampleWorkspace(); + ON_CALL(*m_mockModel, getFocusedRun(runLabel)) + .WillByDefault(Return(sampleWorkspace)); + + ON_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .WillByDefault(Return(true)); + ON_CALL(*m_mockView, showFitResultsSelected()).WillByDefault(Return(true)); + EXPECT_CALL(*m_mockModel, getFittedPeaks(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFittedPeaks(testing::_)).Times(0); + EXPECT_CALL(*m_mockView, plotFittedPeaks(testing::_)).Times(1); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_selectRunDoesNothingWhenNoRunSelected() { + auto presenter = setUpPresenter(); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::SelectRun); + assertMocksUsedCorrectly(); + } + + void test_plotPeaksStateChangedUpdatesPlot() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleWorkspace( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + + EXPECT_CALL(*m_mockView, resetCanvas()).Times(1); + EXPECT_CALL(*m_mockView, plotFocusedRun(testing::_)).Times(1); + + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(false)); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotPeaksStateChanged); + assertMocksUsedCorrectly(); + } + + void test_plotPeaksStateChangedDoesNotCrashWhenNoRunSelected() { + auto presenter = setUpPresenter(); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockModel, getFocusedRun(testing::_)).Times(0); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotPeaksStateChanged); + assertMocksUsedCorrectly(); + } + + void test_removeRun() { + auto presenter = setUpPresenter(); + + const RunLabel runLabel("123", 1); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + EXPECT_CALL(*m_mockModel, removeRun(runLabel)); + + const std::vector<RunLabel> runLabels({runLabel}); + EXPECT_CALL(*m_mockModel, getAllWorkspaceLabels()) + .Times(1) + .WillOnce(Return(runLabels)); + EXPECT_CALL(*m_mockView, updateRunList(runLabels)); + EXPECT_CALL(*m_mockView, resetCanvas()); + + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::RemoveRun); + assertMocksUsedCorrectly(); + } + + void test_removeRunDoesNothingWhenNoRunSelected() { + auto presenter = setUpPresenter(); + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockModel, removeRun(testing::_)).Times(0); + presenter->notify( + IEnggDiffMultiRunFittingWidgetPresenter::Notification::RemoveRun); + assertMocksUsedCorrectly(); + } + + void test_plotToSeparateWindowDoesNothingWhenNoRunSelected() { + auto presenter = setUpPresenter(); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(boost::none)); + EXPECT_CALL(*m_mockView, reportNoRunSelectedForPlot()).Times(1); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); + assertMocksUsedCorrectly(); + } + + void test_plotToSeparateWindowValidFocusedRunNoFittedPeaks() { + auto presenter = setUpPresenter(); + const RunLabel runLabel("123", 1); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleWorkspace( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + + EXPECT_CALL(*m_mockView, reportNoRunSelectedForPlot()).Times(0); + EXPECT_CALL(*m_mockView, reportPlotInvalidFocusedRun(testing::_)).Times(0); + + EXPECT_CALL(*m_mockView, showFitResultsSelected()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(false)); + + EXPECT_CALL(*m_mockView, plotToSeparateWindow( + "123_1_external_plot", + boost::make_optional(false, std::string()))) + .Times(1); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); + assertMocksUsedCorrectly(); + } + + void test_plotToSeparateWindowWithFittedPeaks() { + auto presenter = setUpPresenter(); + const RunLabel runLabel("123", 1); + + EXPECT_CALL(*m_mockView, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(runLabel)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleWorkspace( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + + EXPECT_CALL(*m_mockModel, getFocusedRun(runLabel)) + .Times(1) + .WillOnce(Return(sampleWorkspace)); + + EXPECT_CALL(*m_mockView, showFitResultsSelected()) + .Times(1) + .WillOnce(Return(true)); + EXPECT_CALL(*m_mockModel, hasFittedPeaksForRun(runLabel)) + .Times(1) + .WillOnce(Return(true)); + + const boost::optional<Mantid::API::MatrixWorkspace_sptr> sampleFittedPeaks( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + EXPECT_CALL(*m_mockModel, getFittedPeaks(runLabel)) + .Times(1) + .WillOnce(Return(sampleFittedPeaks)); + EXPECT_CALL(*m_mockView, reportPlotInvalidFittedPeaks(testing::_)).Times(0); + + EXPECT_CALL(*m_mockView, + plotToSeparateWindow("123_1_external_plot", + boost::optional<std::string>( + "123_1_fitted_peaks_external_plot"))) + .Times(1); + + presenter->notify(IEnggDiffMultiRunFittingWidgetPresenter::Notification:: + PlotToSeparateWindow); + assertMocksUsedCorrectly(); + } + + void test_getAllRunLabelsDelegatesToView() { + auto presenter = setUpPresenter(); + EXPECT_CALL(*m_mockView, getAllRunLabels()); + presenter->getAllRunLabels(); + assertMocksUsedCorrectly(); + } + +private: + MockEnggDiffMultiRunFittingWidgetModel *m_mockModel; + MockEnggDiffMultiRunFittingWidgetView *m_mockView; + + std::unique_ptr<EnggDiffMultiRunFittingWidgetPresenter> setUpPresenter() { + auto mockModel_uptr = std::make_unique< + testing::NiceMock<MockEnggDiffMultiRunFittingWidgetModel>>(); + m_mockModel = mockModel_uptr.get(); + + m_mockView = new testing::NiceMock<MockEnggDiffMultiRunFittingWidgetView>(); + + return std::make_unique<EnggDiffMultiRunFittingWidgetPresenter>( + std::move(mockModel_uptr), m_mockView); + } + + void assertMocksUsedCorrectly() { + TSM_ASSERT("View mock not used as expected: some EXPECT_CALL conditions " + "not satisfied", + testing::Mock::VerifyAndClearExpectations(m_mockModel)); + TSM_ASSERT("Model mock not used as expected: some EXPECT_CALL conditions " + "not satisfied", + testing::Mock::VerifyAndClearExpectations(m_mockView)); + if (m_mockView) { + delete m_mockView; + } + } +}; diff --git a/qt/scientific_interfaces/test/EnggVanadiumCorrectionsModelTest.h b/qt/scientific_interfaces/test/EnggVanadiumCorrectionsModelTest.h new file mode 100644 index 0000000000000000000000000000000000000000..c3c5309a19015ca67f4ca1ddfef958651a85a6ec --- /dev/null +++ b/qt/scientific_interfaces/test/EnggVanadiumCorrectionsModelTest.h @@ -0,0 +1,206 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source +// & Institut Laue - Langevin +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "../EnggDiffraction/EnggVanadiumCorrectionsModel.h" + +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/FrameworkManager.h" +#include "MantidAPI/TableRow.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" + +#include <Poco/File.h> +#include <Poco/Path.h> + +#include <cxxtest/TestSuite.h> + +using namespace MantidQt::CustomInterfaces; + +namespace { + +Mantid::API::MatrixWorkspace_sptr createSampleMatrixWorkspace() { + return WorkspaceCreationHelper::create2DWorkspaceBinned(1, 1, 2); +} + +Mantid::API::ITableWorkspace_sptr createSampleTableWorkspace() { + auto table = Mantid::API::WorkspaceFactory::Instance().createTable(); + table->addColumn("double", "x"); + Mantid::API::TableRow newRow = table->appendRow(); + newRow << 1.0; + return table; +} + +/// Helper class to allow us to fake EnggVanadiumCorrections +class TestEnggVanadiumCorrectionsModel : public EnggVanadiumCorrectionsModel { +public: + TestEnggVanadiumCorrectionsModel(const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument); + + mutable bool m_calculateCorrectionsCalled; + +private: + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + calculateCorrectionWorkspaces( + const std::string &vanadiumRunNumber) const override; +}; + +inline TestEnggVanadiumCorrectionsModel::TestEnggVanadiumCorrectionsModel( + const EnggDiffCalibSettings &calibSettings, + const std::string ¤tInstrument) + : EnggVanadiumCorrectionsModel(calibSettings, currentInstrument), + m_calculateCorrectionsCalled(false) {} + +inline std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> +TestEnggVanadiumCorrectionsModel::calculateCorrectionWorkspaces( + const std::string &) const { + m_calculateCorrectionsCalled = true; + + auto &ADS = Mantid::API::AnalysisDataService::Instance(); + + Mantid::API::MatrixWorkspace_sptr curvesWS = createSampleMatrixWorkspace(); + ADS.addOrReplace(CURVES_WORKSPACE_NAME, curvesWS); + + auto integratedWS = createSampleTableWorkspace(); + ADS.addOrReplace(INTEGRATED_WORKSPACE_NAME, integratedWS); + + return std::make_pair(integratedWS, curvesWS); +} + +} // anonymous namespace + +class EnggVanadiumCorrectionsModelTest : public CxxTest::TestSuite { + +public: + static EnggVanadiumCorrectionsModelTest *createSuite() { + return new EnggVanadiumCorrectionsModelTest(); + } + + static void destroySuite(EnggVanadiumCorrectionsModelTest *suite) { + delete suite; + } + + EnggVanadiumCorrectionsModelTest() { + Poco::Path tempDir(Poco::Path::temp()); + tempDir.append(INPUT_DIR_NAME); + m_inputDir = tempDir; + Mantid::API::FrameworkManager::Instance(); + } + + void setUp() override { m_inputDir.createDirectory(); } + + void tearDown() override { m_inputDir.remove(true); } + + void test_generateNewWorkspacesWhenNoCache() { + // We've created the calib directory but not populated it with any + // workspaces, so we should get our fake ones + EnggDiffCalibSettings calibSettings; + calibSettings.m_inputDirCalib = m_inputDir.path(); + calibSettings.m_forceRecalcOverwrite = false; + + if (m_inputDir.exists()) { + // Make sure that m_inputDir doesn't exist, as if a previous test exited + // abnormally tearDown() may not have been called + m_inputDir.remove(true); + } + + TestEnggVanadiumCorrectionsModel model(calibSettings, CURRENT_INSTRUMENT); + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + correctionWorkspaces; + TS_ASSERT_THROWS_NOTHING(correctionWorkspaces = + model.fetchCorrectionWorkspaces("123")); + TS_ASSERT(model.m_calculateCorrectionsCalled); + TS_ASSERT(correctionWorkspaces.first); + TS_ASSERT(correctionWorkspaces.second); + + Poco::Path curvesWSPath(m_inputDir.path()); + curvesWSPath.append("123_precalculated_vanadium_run_bank_curves.nxs"); + TS_ASSERT(Poco::File(curvesWSPath).exists()); + + Poco::Path integWSPath(m_inputDir.path()); + integWSPath.append("123_precalculated_vanadium_run_integration.nxs"); + TS_ASSERT(Poco::File(integWSPath).exists()); + } + + void test_cacheUsedWhenAvailable() { + const auto curvesWS = createSampleMatrixWorkspace(); + const auto integratedWS = createSampleTableWorkspace(); + writeOutSampleCorrectionWorkspaces(integratedWS, curvesWS); + + EnggDiffCalibSettings calibSettings; + calibSettings.m_inputDirCalib = m_inputDir.path(); + calibSettings.m_forceRecalcOverwrite = false; + TestEnggVanadiumCorrectionsModel model(calibSettings, CURRENT_INSTRUMENT); + + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + correctionWorkspaces; + TS_ASSERT_THROWS_NOTHING(correctionWorkspaces = + model.fetchCorrectionWorkspaces("123")); + TS_ASSERT(!model.m_calculateCorrectionsCalled); + + TS_ASSERT_EQUALS(curvesWS->y(0), correctionWorkspaces.second->y(0)); + + Mantid::API::TableRow sampleDataRow = integratedWS->getRow(0); + Mantid::API::TableRow readDataRow = correctionWorkspaces.first->getRow(0); + TS_ASSERT_EQUALS(sampleDataRow.Double(0), readDataRow.Double(0)); + } + + void test_recalculateIfRequired() { + const auto curvesWS = createSampleMatrixWorkspace(); + const auto integratedWS = createSampleTableWorkspace(); + writeOutSampleCorrectionWorkspaces(integratedWS, curvesWS); + + EnggDiffCalibSettings calibSettings; + calibSettings.m_inputDirCalib = m_inputDir.path(); + calibSettings.m_forceRecalcOverwrite = true; + TestEnggVanadiumCorrectionsModel model(calibSettings, CURRENT_INSTRUMENT); + + std::pair<Mantid::API::ITableWorkspace_sptr, + Mantid::API::MatrixWorkspace_sptr> + correctionWorkspaces; + TS_ASSERT_THROWS_NOTHING(correctionWorkspaces = + model.fetchCorrectionWorkspaces("123")); + TS_ASSERT(model.m_calculateCorrectionsCalled); + } + +private: + const static std::string CURRENT_INSTRUMENT; + const static std::string INPUT_DIR_NAME; + + Poco::File m_inputDir; + + void saveNexus(const std::string &filename, + const Mantid::API::Workspace_sptr &workspace) const { + auto save = Mantid::API::AlgorithmManager::Instance().create("SaveNexus"); + save->initialize(); + save->setProperty("InputWorkspace", workspace); + save->setProperty("Filename", filename); + save->execute(); + } + + void writeOutSampleCorrectionWorkspaces( + const Mantid::API::ITableWorkspace_sptr &integratedWS, + const Mantid::API::MatrixWorkspace_sptr &curvesWS) { + Poco::Path curvesWSPath(m_inputDir.path()); + curvesWSPath.append("123_precalculated_vanadium_run_bank_curves.nxs"); + saveNexus(curvesWSPath.toString(), curvesWS); + + Poco::Path integWSPath(m_inputDir.path()); + integWSPath.append("123_precalculated_vanadium_run_integration.nxs"); + saveNexus(integWSPath.toString(), integratedWS); + } +}; + +const std::string EnggVanadiumCorrectionsModelTest::CURRENT_INSTRUMENT = + "TESTINST"; + +const std::string EnggVanadiumCorrectionsModelTest::INPUT_DIR_NAME( + "EnggVanadiumCorrectionsModelTestData"); diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h index d332900b9776b7f68dbd28e711d434379637199d..15bc9f560a104312935950d273a25b9b5d80c6a2 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/ExperimentPresenterTest.h @@ -903,7 +903,8 @@ private: } void runTestForInvalidPerAngleOptions(OptionsTable const &optionsTable, - std::vector<int> rows, int column) { + const std::vector<int> &rows, + int column) { auto presenter = makePresenter(); EXPECT_CALL(m_view, getPerAngleOptions()).WillOnce(Return(optionsTable)); for (auto row : rows) diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h index 427fe07ae5a961b371109022acb48b35dfef1600..cfd1f346c4bea414397b07dd501c0f4f067957f3 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Experiment/PerThetaDefaultsTableValidatorTest.h @@ -173,22 +173,23 @@ private: Table emptyTable() { return Table(); } Cells emptyRow() { return Cells(); } - std::vector<InvalidDefaultsError> expectedErrors(std::vector<int> rows, - std::vector<int> columns) { + std::vector<InvalidDefaultsError> + expectedErrors(const std::vector<int> &rows, + const std::vector<int> &columns) { std::vector<InvalidDefaultsError> errors; for (auto row : rows) errors.emplace_back(InvalidDefaultsError(row, columns)); return errors; } - std::vector<PerThetaDefaults> runTestValid(Table table) { + std::vector<PerThetaDefaults> runTestValid(const Table &table) { PerThetaDefaultsTableValidator validator; auto result = validator(table, TOLERANCE); TS_ASSERT(result.isValid()); return result.assertValid(); } - void runTestInvalidThetas(Table table, + void runTestInvalidThetas(const Table &table, ThetaValuesValidationError thetaValuesError, std::vector<InvalidDefaultsError> expectedErrors) { PerThetaDefaultsTableValidator validator; @@ -200,7 +201,7 @@ private: TS_ASSERT_EQUALS(validationError.errors(), expectedErrors); } - void runTestInvalidCells(Table table, + void runTestInvalidCells(const Table &table, std::vector<InvalidDefaultsError> expectedErrors) { PerThetaDefaultsTableValidator validator; auto result = validator(table, TOLERANCE); diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h index 399ea8ca6f0fbca733a0fd0b25bcf453a282d795..57e05ea745940becba851e0a94dbdadb145e258a 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Runs/RunsPresenterTest.h @@ -24,6 +24,8 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <utility> + using namespace MantidQt::CustomInterfaces::ISISReflectometry; using namespace MantidQt::CustomInterfaces::ISISReflectometry:: ModelCreationHelper; @@ -708,7 +710,7 @@ private: } AlgorithmRuntimeProps defaultLiveMonitorReductionOptions( - std::string instrument = std::string("OFFSPEC")) { + const std::string &instrument = std::string("OFFSPEC")) { return AlgorithmRuntimeProps{ {"GetLiveValueAlgorithm", "GetLiveInstrumentValue"}, {"InputWorkspace", "TOF_live"}, @@ -1005,7 +1007,7 @@ private: expectGetUpdateInterval(updateInterval); EXPECT_CALL(m_mainPresenter, rowProcessingProperties()) .Times(1) - .WillOnce(Return(options)); + .WillOnce(Return(std::move(options))); } void expectGetLiveDataOptions(std::string const &instrument, diff --git a/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h b/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h index 7484989a61580d955b68b8a3c42e56e9ae0d18de..182f9f6f32669b35c8916dc3e9011f6b84fd08da 100644 --- a/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h +++ b/qt/scientific_interfaces/test/ISISReflectometry/Save/SavePresenterTest.h @@ -347,13 +347,13 @@ private: AnalysisDataService::Instance().clear(); } - Workspace2D_sptr createWorkspace(std::string name) { + Workspace2D_sptr createWorkspace(const std::string &name) { Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); AnalysisDataService::Instance().addOrReplace(name, ws); return ws; } - void createTableWorkspace(std::string name) { + void createTableWorkspace(const std::string &name) { ITableWorkspace_sptr ws = WorkspaceFactory::Instance().createTable("TableWorkspace"); AnalysisDataService::Instance().addOrReplace(name, ws); @@ -367,8 +367,8 @@ private: return workspaceNames; } - void createWorkspaceGroup(std::string groupName, - std::vector<std::string> workspaceNames) { + void createWorkspaceGroup(const std::string &groupName, + const std::vector<std::string> &workspaceNames) { AnalysisDataService::Instance().add(groupName, boost::make_shared<WorkspaceGroup>()); createWorkspaces(workspaceNames); @@ -436,8 +436,8 @@ private: } void expectSaveWorkspaces( - std::vector<std::string> workspaceNames, - std::vector<std::string> logs = std::vector<std::string>{}) { + const std::vector<std::string> &workspaceNames, + const std::vector<std::string> &logs = std::vector<std::string>{}) { EXPECT_CALL(m_view, getSelectedParameters()) .Times(1) .WillOnce(Return(logs)); diff --git a/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h b/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h index ea2dfa309fe8f0dd134b64e05a3fe0b7b4d0510f..04cdbe410a675e2262aa5ec3054d8645d4ac1c40 100644 --- a/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h +++ b/qt/scientific_interfaces/test/MuonAnalysisDataLoaderTest.h @@ -10,6 +10,8 @@ #include <Poco/Path.h> #include <cxxtest/TestSuite.h> +#include <utility> + #include "../Muon/MuonAnalysisDataLoader.h" #include "MantidAPI/Algorithm.h" #include "MantidAPI/AlgorithmManager.h" @@ -42,9 +44,10 @@ public: const QStringList &instruments, const std::string &deadTimesFile = "") : MuonAnalysisDataLoader(deadTimesType, instruments, deadTimesFile){}; - void setProcessAlgorithmProperties(IAlgorithm_sptr alg, + void setProcessAlgorithmProperties(const IAlgorithm_sptr &alg, const AnalysisOptions &options) const { - MuonAnalysisDataLoader::setProcessAlgorithmProperties(alg, options); + MuonAnalysisDataLoader::setProcessAlgorithmProperties(std::move(alg), + options); } }; diff --git a/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h b/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h index c3d785d9cd2eecbc899b644136d49634bdef4cc4..b41151b0d6a69815a7ae953dbf0534af6dbc5a27 100644 --- a/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h +++ b/qt/scientific_interfaces/test/MuonAnalysisResultTableCreatorTest.h @@ -58,7 +58,7 @@ public: return MuonAnalysisResultTableCreator::haveSameParameters(tables); } void removeFixedParameterErrors( - const Mantid::API::ITableWorkspace_sptr table) const { + const Mantid::API::ITableWorkspace_sptr &table) const { MuonAnalysisResultTableCreator::removeFixedParameterErrors(table); } }; @@ -467,7 +467,7 @@ private: } /// Expected output table - ITableWorkspace_sptr getExpectedOutputSingle(const QStringList workspaces) { + ITableWorkspace_sptr getExpectedOutputSingle(const QStringList &workspaces) { auto table = WorkspaceFactory::Instance().createTable(); table->addColumn("str", "workspace_Name"); const std::vector<std::string> titles = { @@ -548,8 +548,8 @@ private: return table; } - bool compareTables(const ITableWorkspace_sptr lhs, - const ITableWorkspace_sptr rhs) { + bool compareTables(const ITableWorkspace_sptr &lhs, + const ITableWorkspace_sptr &rhs) { auto alg = AlgorithmManager::Instance().create("CompareWorkspaces"); alg->initialize(); alg->setChild(true); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h index ea8e08a8444b6fafd086e41eafa1efce7e817d98..c77003e337c82a08e9c8197262b8a393f576d1d7 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h @@ -141,7 +141,7 @@ protected: /// Set properties on this algorithm by pulling values from the tied widgets bool setPropertyValues(const QStringList &skipList = QStringList()); - bool setPropertyValue(const QString pName, bool validateOthers); + bool setPropertyValue(const QString &pName, bool validateOthers); void showValidators(); //@} @@ -255,7 +255,7 @@ protected: /// GenericDialogDemo.cpp public: /// Set the algorithm associated with this dialog - void setAlgorithm(Mantid::API::IAlgorithm_sptr /*alg*/); + void setAlgorithm(const Mantid::API::IAlgorithm_sptr & /*alg*/); /// Set a list of suggested values void setPresetValues(const QHash<QString, QString> &presetValues); /// Set whether this is intended for use from a script or not diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h index c50fd636cf32ec9318bb181f121631f47025f894..4b63aad0dafdc666c4c715a6591adeb92cba3266 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHintStrategy.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/IAlgorithm.h" #include "MantidQtWidgets/Common/HintStrategy.h" @@ -18,7 +20,7 @@ class AlgorithmHintStrategy : public HintStrategy { public: AlgorithmHintStrategy(Mantid::API::IAlgorithm_sptr algorithm, std::vector<std::string> blacklist) - : m_algorithm(algorithm), m_blacklist(blacklist) {} + : m_algorithm(std::move(algorithm)), m_blacklist(std::move(blacklist)) {} AlgorithmHintStrategy(std::string const &algorithmName, std::vector<std::string> blacklist) diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h index 523cb50607ca7f51c15dcd62894800eeb9056130..985fc73eff5fae7d69b02b2c574a3e363248fc13 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmHistoryWindow.h @@ -24,6 +24,9 @@ #include <QStandardItemModel> #include <QTreeView> #include <QTreeWidget> +#include <utility> + +#include <utility> //------------------------------------------------------------------------------ // Forward declarations @@ -49,7 +52,8 @@ public: Mantid::API::AlgorithmHistory_const_sptr algHistory, AlgHistoryItem *parent = nullptr) : QTreeWidgetItem(parent, names, UserType), Mantid::API::HistoryItem( - algHistory) {} + std::move(std::move( + algHistory))) {} }; class AlgHistoryTreeWidget : public QTreeWidget { @@ -84,7 +88,7 @@ private: void itemChecked(QTreeWidgetItem *item, int index); void itemUnchecked(QTreeWidgetItem *item, int index); void populateNestedHistory(AlgHistoryItem *parentWidget, - Mantid::API::AlgorithmHistory_sptr history); + const Mantid::API::AlgorithmHistory_sptr &history); void uncheckAllChildren(QTreeWidgetItem *item, int index); QString concatVersionwithName(const std::string &name, const int version); @@ -97,7 +101,7 @@ class AlgExecSummaryGrpBox : public QGroupBox { Q_OBJECT public: explicit AlgExecSummaryGrpBox(QWidget *w); - AlgExecSummaryGrpBox(QString /*title*/, QWidget *w); + AlgExecSummaryGrpBox(const QString & /*title*/, QWidget *w); ~AlgExecSummaryGrpBox() override; void setData(const double execDuration, const Mantid::Types::Core::DateAndTime execDate); @@ -118,7 +122,7 @@ class AlgEnvHistoryGrpBox : public QGroupBox { Q_OBJECT public: explicit AlgEnvHistoryGrpBox(QWidget *w); - AlgEnvHistoryGrpBox(QString /*title*/, QWidget *w); + AlgEnvHistoryGrpBox(const QString & /*title*/, QWidget *w); ~AlgEnvHistoryGrpBox() override; QLineEdit *getosNameEdit() const { return m_osNameEdit; } @@ -145,14 +149,15 @@ signals: public: AlgorithmHistoryWindow( QWidget *parent, - const boost::shared_ptr<const Mantid::API::Workspace> /*wsptr*/); + const boost::shared_ptr<const Mantid::API::Workspace> & /*wsptr*/); AlgorithmHistoryWindow(QWidget *parent, const QString &workspaceName); ~AlgorithmHistoryWindow() override; void closeEvent(QCloseEvent *ce) override; public slots: - void updateAll(Mantid::API::AlgorithmHistory_const_sptr algHistmakeory); + void + updateAll(const Mantid::API::AlgorithmHistory_const_sptr &algHistmakeory); void doUnroll(const std::vector<int> &unrollIndicies); void doRoll(int index); @@ -166,10 +171,10 @@ private: AlgHistoryProperties *createAlgHistoryPropWindow(); QFileDialog *createScriptDialog(const QString &algName); - void - updateExecSummaryGrpBox(Mantid::API::AlgorithmHistory_const_sptr algHistory); + void updateExecSummaryGrpBox( + const Mantid::API::AlgorithmHistory_const_sptr &algHistory); void updateAlgHistoryProperties( - Mantid::API::AlgorithmHistory_const_sptr algHistory); + const Mantid::API::AlgorithmHistory_const_sptr &algHistory); std::string getScriptVersionMode(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h index b7fc3579623279a7c343ab692ee7bc765797b10d..6ba3742680b0e7146c8abd9e627f26c8aebcc29b 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmInputHistory.h @@ -60,7 +60,7 @@ public: protected: /// Constructor - AbstractAlgorithmInputHistory(QString settingsGroup); + AbstractAlgorithmInputHistory(const QString &settingsGroup); private: /// Load any values that are available from persistent storage diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h index 0428e7f18745afe6a99ee9f7ee4cba44f1511385..bb74c538df04ac72eccbfb649f50b1ed77fa0cbb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmPropertiesWidget.h @@ -46,7 +46,7 @@ public: void initLayout(); Mantid::API::IAlgorithm_sptr getAlgorithm(); - void setAlgorithm(Mantid::API::IAlgorithm_sptr algo); + void setAlgorithm(const Mantid::API::IAlgorithm_sptr &algo); QString getAlgorithmName() const; void setAlgorithmName(QString name); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h index 6944e44b90393baba9c6e3a734f56662106c10be..26aed5baa8fbde226fdfa22a3ec79db9a8fb293e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h @@ -44,7 +44,7 @@ struct SelectedAlgorithm { /// implicit conversion to QString operator QString() { return name; } /// constructor - SelectedAlgorithm(const QString nameIn, const int versionIn) + SelectedAlgorithm(const QString &nameIn, const int versionIn) : name(nameIn), version(versionIn){}; }; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h b/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h index c5e68293b80ddc4e8e0b7f2f667ce21aeed75a63..687a16aa311fbdddae5c3bb18a6297b4c9602f35 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/BatchAlgorithmRunner.h @@ -19,6 +19,7 @@ #include <QMetaType> #include <deque> #include <mutex> +#include <utility> namespace MantidQt { namespace API { @@ -70,7 +71,7 @@ public: class AlgorithmCompleteNotification : public Poco::Notification { public: AlgorithmCompleteNotification(IConfiguredAlgorithm_sptr algorithm) - : Poco::Notification(), m_algorithm(algorithm) {} + : Poco::Notification(), m_algorithm(std::move(algorithm)) {} IConfiguredAlgorithm_sptr algorithm() const { return m_algorithm; } @@ -81,7 +82,7 @@ private: class AlgorithmStartedNotification : public Poco::Notification { public: AlgorithmStartedNotification(IConfiguredAlgorithm_sptr algorithm) - : Poco::Notification(), m_algorithm(algorithm) {} + : Poco::Notification(), m_algorithm(std::move(algorithm)) {} IConfiguredAlgorithm_sptr algorithm() const { return m_algorithm; } @@ -93,7 +94,7 @@ class AlgorithmErrorNotification : public Poco::Notification { public: AlgorithmErrorNotification(IConfiguredAlgorithm_sptr algorithm, std::string const &errorMessage) - : Poco::Notification(), m_algorithm(algorithm), + : Poco::Notification(), m_algorithm(std::move(algorithm)), m_errorMessage(errorMessage) {} IConfiguredAlgorithm_sptr algorithm() const { return m_algorithm; } @@ -120,8 +121,9 @@ public: ~BatchAlgorithmRunner() override; /// Adds an algorithm to the execution queue - void addAlgorithm(Mantid::API::IAlgorithm_sptr algo, - AlgorithmRuntimeProps props = AlgorithmRuntimeProps()); + void + addAlgorithm(const Mantid::API::IAlgorithm_sptr &algo, + const AlgorithmRuntimeProps &props = AlgorithmRuntimeProps()); void setQueue(std::deque<IConfiguredAlgorithm_sptr> algorithm); /// Clears all algorithms from queue void clearQueue(); @@ -151,7 +153,7 @@ private: /// Implementation of algorithm runner bool executeBatchAsyncImpl(const Poco::Void & /*unused*/); /// Sets up and executes an algorithm - bool executeAlgo(IConfiguredAlgorithm_sptr algorithm); + bool executeAlgo(const IConfiguredAlgorithm_sptr &algorithm); /// Handlers for notifications void handleBatchComplete(const Poco::AutoPtr<BatchCompleteNotification> &pNf); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h b/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h index 8a7296221a3920b55636674ed7b889756840cea9..af2ee7038ba350f4094e85dfad62624d6ff06d75 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/CatalogSearch.h @@ -100,7 +100,7 @@ private: /// Obtain all file extensions from the provided column (dataFileResults -> /// File name). std::unordered_set<std::string> - getDataFileExtensions(Mantid::API::Column_sptr column); + getDataFileExtensions(const Mantid::API::Column_sptr &column); /// Add the list of file extensions to the "Filter type..." drop-down. void populateDataFileType(const std::unordered_set<std::string> &extensions); /// Disable the download button if user can access the files locally from the @@ -197,7 +197,7 @@ private: /// The current page the user is on in the results window. Used for paging. int m_currentPageNumber; // Ensure tooltip uses visible color on current OS - void correctedToolTip(std::string toolTip, QLabel *label); + void correctedToolTip(const std::string &toolTip, QLabel *label); }; } // namespace MantidWidgets } // namespace MantidQt \ No newline at end of file diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h index e7ae0322114b50a79def549253c1203a43a263c4..0ad93fa0aae23ac038f4563a8adde5bdd28431c9 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ConvolutionFunctionModel.h @@ -51,21 +51,22 @@ private: // void findConvolutionPrefixes(const IFunction_sptr &fun); void iterateThroughFunction(IFunction *func, const QString &prefix); void setPrefix(IFunction *func, const QString &prefix); - CompositeFunction_sptr createInnerFunction(std::string peaksFunction, + CompositeFunction_sptr createInnerFunction(const std::string &peaksFunction, bool hasDeltaFunction, bool isQDependent, double q, bool hasTempCorrection, double tempValue); - CompositeFunction_sptr addTempCorrection(CompositeFunction_sptr peaksFunction, - double tempValue); + CompositeFunction_sptr + addTempCorrection(const CompositeFunction_sptr &peaksFunction, + double tempValue); IFunction_sptr createTemperatureCorrection(double correction); CompositeFunction_sptr createConvolutionFunction(IFunction_sptr resolutionFunction, - IFunction_sptr innerFunction); - IFunction_sptr createResolutionFunction(std::string workspaceName, + const IFunction_sptr &innerFunction); + IFunction_sptr createResolutionFunction(const std::string &workspaceName, int workspaceIndex); CompositeFunction_sptr addBackground(CompositeFunction_sptr domainFunction, - std::string background); + const std::string &background); boost::optional<QString> m_backgroundPrefix; boost::optional<QString> m_convolutionPrefix; boost::optional<QString> m_deltaFunctionPrefix; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h index 594db9c9d40fbf4afe5186f9871cd93167de74dd..4eb2c2daa9106b0964d2a11abfd3d0271b6868bd 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h @@ -50,7 +50,7 @@ QString DLLExport plotsString(const GroupData &groupData, const ProcessingAlgorithm &processor); QString DLLExport -reduceRowString(const RowData_sptr data, const QString &instrument, +reduceRowString(const RowData_sptr &data, const QString &instrument, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, @@ -77,9 +77,10 @@ QString DLLExport completeOutputProperties(const QString &algName, class DLLExport GenerateNotebook { public: - GenerateNotebook(QString name, QString instrument, WhiteList whitelist, + GenerateNotebook(const QString &name, const QString &instrument, + WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, + const ProcessingAlgorithm &processor, boost::optional<PostprocessingStep> postprocessingStep, ColumnOptionsMap preprocessingInstructionsMap); virtual ~GenerateNotebook() = default; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h index fd8e95f54d692afee36445c40a36bf75642b0c4a..e1ef47643f74f09faa48d4b0a759514719538af6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h @@ -33,6 +33,7 @@ #include "MantidAPI/AnalysisDataService.h" #include <QObject> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -57,7 +58,7 @@ struct PreprocessingAttributes { : m_options(options) {} PreprocessingAttributes(const ColumnOptionsMap &options, std::map<QString, PreprocessingAlgorithm> map) - : m_options(options), m_map(map) {} + : m_options(options), m_map(std::move(map)) {} ColumnOptionsMap m_options; std::map<QString, PreprocessingAlgorithm> m_map; @@ -91,23 +92,24 @@ public: GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, PostprocessingAlgorithm postprocessor, - int group, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group, std::map<QString, QString> postprocessMap = std::map<QString, QString>(), - QString loader = "Load"); + const QString &loader = "Load"); // Constructor: no pre-processing, post-processing GenericDataProcessorPresenter(WhiteList whitelist, - ProcessingAlgorithm processor, - PostprocessingAlgorithm postprocessor, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group); // Constructor: pre-processing, no post-processing GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, int group); + const ProcessingAlgorithm &processor, int group); // Constructor: no pre-processing, no post-processing GenericDataProcessorPresenter(WhiteList whitelist, - ProcessingAlgorithm processor, int group); + const ProcessingAlgorithm &processor, + int group); // Constructor: only whitelist GenericDataProcessorPresenter(WhiteList whitelist, int group); // Delegating constructor: pre-processing, no post-processing @@ -141,7 +143,7 @@ public: // Get the whitelist WhiteList getWhiteList() const { return m_whitelist; }; // Get the name of the reduced workspace for a given row - QString getReducedWorkspaceName(const RowData_sptr data) const; + QString getReducedWorkspaceName(const RowData_sptr &data) const; ParentItems selectedParents() const override; ChildItems selectedChildren() const override; @@ -195,23 +197,23 @@ protected: void postProcessGroup(const GroupData &data); // Preprocess the given column value if applicable void preprocessColumnValue(const QString &columnName, QString &columnValue, - RowData_sptr data); + const RowData_sptr &data); // Preprocess all option values where applicable - void preprocessOptionValues(RowData_sptr data); + void preprocessOptionValues(const RowData_sptr &data); // Update the model with values used from the options and/or the results from // the algorithm - void updateModelFromResults(Mantid::API::IAlgorithm_sptr alg, - RowData_sptr data); + void updateModelFromResults(const Mantid::API::IAlgorithm_sptr &alg, + const RowData_sptr &data); // Create and execute the algorithm with the given properties Mantid::API::IAlgorithm_sptr createAndRunAlgorithm(const OptionsMap &options); // Reduce a row - void reduceRow(RowData_sptr data); + void reduceRow(const RowData_sptr &data); // Finds a run in the AnalysisDataService QString findRunInADS(const QString &run, const QString &prefix, bool &runFound); // Set up data required for processing a row - bool initRowForProcessing(RowData_sptr rowData); + bool initRowForProcessing(const RowData_sptr &rowData); // Process rows virtual void process(TreeData itemsToProcess); // Plotting @@ -249,12 +251,12 @@ protected: bool promptUser() const { return m_promptUser; } void setGroupIsProcessed(const int groupIndex, const bool isProcessed); void setGroupError(const int groupIndex, const std::string &error); - void setRowIsProcessed(RowData_sptr rowData, const bool isProcessed); - void setRowError(RowData_sptr rowData, const std::string &error); - bool rowNeedsProcessing(RowData_sptr rowData) const; + void setRowIsProcessed(const RowData_sptr &rowData, const bool isProcessed); + void setRowError(const RowData_sptr &rowData, const std::string &error); + bool rowNeedsProcessing(const RowData_sptr &rowData) const; bool groupNeedsProcessing(const int groupIndex) const; void resetProcessedState(const int groupIndex); - void resetProcessedState(RowData_sptr rowData); + void resetProcessedState(const RowData_sptr &rowData); void resetProcessedState(const std::string &workspaceName); void resetProcessedState(); void updateWidgetEnabledState(const bool isProcessing) const; @@ -383,7 +385,7 @@ private: int parentColumn) override; int getNumberOfRows() override; void clearTable() override; - bool workspaceIsOutputOfRow(RowData_sptr rowData, + bool workspaceIsOutputOfRow(const RowData_sptr &rowData, const std::string &workspaceName) const; bool workspaceIsBeingReduced(const std::string &workspaceName) const; void handleWorkspaceRemoved(const std::string &workspaceName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h index ee0705a292ce4f60ac5c7498626cd44682cb3492..82d41b9e37a58913aaea996b50961e52f493280a 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterRowReducerWorker.h @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h" #include <QThread> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -27,8 +28,8 @@ public: GenericDataProcessorPresenterRowReducerWorker( GenericDataProcessorPresenter *presenter, RowData_sptr rowData, const int rowIndex, const int groupIndex) - : m_presenter(presenter), m_rowData(rowData), m_rowIndex(rowIndex), - m_groupIndex(groupIndex) {} + : m_presenter(presenter), m_rowData(std::move(rowData)), + m_rowIndex(rowIndex), m_groupIndex(groupIndex) {} private slots: void startWorker() { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h index 6a0c2c30646ae7a7f6a39c0e653ef917b3810599..76f9fd9179ce3d61d1c37a497fd243d1bb20b44f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h @@ -27,7 +27,7 @@ class EXPORT_OPT_MANTIDQT_COMMON OneLevelTreeManager : public TreeManager { public: /// Constructor OneLevelTreeManager(DataProcessorPresenter *presenter, - Mantid::API::ITableWorkspace_sptr table, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist); /// Constructor (no table ws given) OneLevelTreeManager(DataProcessorPresenter *presenter, @@ -123,9 +123,9 @@ private: Mantid::API::ITableWorkspace_sptr createDefaultWorkspace(const WhiteList &whitelist); /// Validate a table workspace - void validateModel(Mantid::API::ITableWorkspace_sptr ws, + void validateModel(const Mantid::API::ITableWorkspace_sptr &ws, size_t whitelistColumns) const; - TreeData constructTreeData(std::set<int> rows); + TreeData constructTreeData(const std::set<int> &rows); }; } // namespace DataProcessor } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h index f84122987deb9ef3840388cfb75e6613c62e48e0..891cda313b7d5117fc96e0ea91e8d99b1523416b 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingStep.h @@ -21,8 +21,9 @@ namespace MantidWidgets { namespace DataProcessor { struct EXPORT_OPT_MANTIDQT_COMMON PostprocessingStep { public: - PostprocessingStep(QString options); - PostprocessingStep(QString options, PostprocessingAlgorithm algorithm, + PostprocessingStep(const QString &options); + PostprocessingStep(const QString &options, + const PostprocessingAlgorithm &algorithm, std::map<QString, QString> map); void postProcessGroup(const QString &outputWSName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h index 95e3e86f2941caed37d64f941037a4c96ab6bdce..9fd596235f892c608264f1004d35d37367e5101e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h @@ -23,12 +23,13 @@ class EXPORT_OPT_MANTIDQT_COMMON PreprocessingAlgorithm : public ProcessingAlgorithmBase { public: // Constructor - PreprocessingAlgorithm(QString name, QString prefix = "", - QString separator = "", - std::set<QString> blacklist = std::set<QString>()); + PreprocessingAlgorithm( + const QString &name, const QString &prefix = "", + const QString &separator = "", + const std::set<QString> &blacklist = std::set<QString>()); // Delegating constructor - PreprocessingAlgorithm(QString name, QString prefix, QString separator, - const QString &blacklist); + PreprocessingAlgorithm(const QString &name, const QString &prefix, + const QString &separator, const QString &blacklist); // Default constructor PreprocessingAlgorithm(); // Destructor diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h index eda2f2f5cf6a5c3c7a85d445b45618ec7495f33e..77010523d6ac2c62cc4a4210f39be9a280d8cc0f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h @@ -25,12 +25,12 @@ class EXPORT_OPT_MANTIDQT_COMMON ProcessingAlgorithm public: ProcessingAlgorithm(); // Constructor - ProcessingAlgorithm(QString name, std::vector<QString> prefix, + ProcessingAlgorithm(const QString &name, std::vector<QString> prefix, std::size_t postprocessedOutputPrefixIndex, - std::set<QString> blacklist = std::set<QString>(), + const std::set<QString> &blacklist = std::set<QString>(), const int version = -1); // Delegating constructor - ProcessingAlgorithm(QString name, QString const &prefix, + ProcessingAlgorithm(const QString &name, QString const &prefix, std::size_t postprocessedOutputPrefixIndex, QString const &blacklist = "", const int version = -1); // Destructor diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h index a1b9420c31de63f7e79345bbaf14802b6de80a20..2b0e7624a1f65104469bb87732ced25f08509b32 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h @@ -31,7 +31,7 @@ the same number of columns as the number of items in the WhiteList. class EXPORT_OPT_MANTIDQT_COMMON QOneLevelTreeModel : public AbstractTreeModel { Q_OBJECT public: - QOneLevelTreeModel(Mantid::API::ITableWorkspace_sptr tableWorkspace, + QOneLevelTreeModel(const Mantid::API::ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist); ~QOneLevelTreeModel() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h index 2742bf09fc08bfaaa12c570e13ce6d529dd0a265..37c5d68c43fb3b836235fdaa194859a28207284d 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h @@ -36,7 +36,7 @@ number of items in the WhiteList. class EXPORT_OPT_MANTIDQT_COMMON QTwoLevelTreeModel : public AbstractTreeModel { Q_OBJECT public: - QTwoLevelTreeModel(Mantid::API::ITableWorkspace_sptr tableWorkspace, + QTwoLevelTreeModel(const Mantid::API::ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist); ~QTwoLevelTreeModel() override; @@ -112,7 +112,7 @@ private: const std::map<QString, QString> &rowValues); void insertRowAndGroupWithValues(const std::map<QString, QString> &rowValues); bool rowIsEmpty(int row, int parent) const; - void setupModelData(Mantid::API::ITableWorkspace_sptr table); + void setupModelData(const Mantid::API::ITableWorkspace_sptr &table); bool insertGroups(int position, int count); bool removeGroups(int position, int count); bool removeRows(int position, int count, int parent); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h index e19fa5862f6c79e7cf48d77d911085f124a58de1..3f29447436f74a16aca281434d242a0e87b1c043 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h @@ -35,7 +35,7 @@ class DLLExport RowData { public: // Constructors explicit RowData(const int columnCount); - explicit RowData(QStringList data); + explicit RowData(const QStringList &data); explicit RowData(const std::vector<std::string> &data); explicit RowData(const RowData &src); @@ -112,7 +112,7 @@ public: bool reductionFailed() const; /// Get the reduced workspace name, optionally adding a prefix - QString reducedName(const QString prefix = QString()) const; + QString reducedName(const QString &prefix = QString()) const; /// Set the reduced workspace name void setReducedName(const QString &name) { m_reducedName = name; } bool hasOutputWorkspaceWithNameAndPrefix(const QString &workspaceName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h index fe365bf7d26bde67f51d800c52a8e57e072bec17..fde32267a06b16eff5b0d7f2247271b4c057c234 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h @@ -29,7 +29,7 @@ class EXPORT_OPT_MANTIDQT_COMMON TwoLevelTreeManager : public TreeManager { public: /// Constructor TwoLevelTreeManager(DataProcessorPresenter *presenter, - Mantid::API::ITableWorkspace_sptr table, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist); /// Constructor (no table ws given) TwoLevelTreeManager(DataProcessorPresenter *presenter, @@ -122,9 +122,9 @@ private: Mantid::API::ITableWorkspace_sptr createDefaultWorkspace(const WhiteList &whitelist); /// Validate a table workspace - void validateModel(Mantid::API::ITableWorkspace_sptr ws, + void validateModel(const Mantid::API::ITableWorkspace_sptr &ws, size_t whitelistColumns) const; - TreeData constructTreeData(ChildItems rows); + TreeData constructTreeData(const ChildItems &rows); }; } // namespace DataProcessor } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h index 8690aa2bce30a7709f90ba9b16c8db68574049ed..8d34e2234ba168291a813d1a84575eef31275390 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceNameUtils.h @@ -31,11 +31,11 @@ QString preprocessingListToString(const QStringList &values, const QString &separator); // Returns the name of the reduced workspace for a given row QString DLLExport getReducedWorkspaceName( - const RowData_sptr data, const WhiteList &whitelist, + const RowData_sptr &data, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessor); // Consolidate global options with row values OptionsMap DLLExport getCanonicalOptions( - const RowData_sptr data, const OptionsMap &globalOptions, + const RowData_sptr &data, const OptionsMap &globalOptions, const WhiteList &whitelist, const bool allowInsertions, const std::vector<QString> &outputProperties = std::vector<QString>(), const std::vector<QString> &prefixes = std::vector<QString>()); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h index 622baafe033cf37ef0326a4e358f474818c7bc57..36c1891eec3a2c627b5210f66d72811fe762cca6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DiagResults.h @@ -28,8 +28,8 @@ signals: void died(); private: - void updateRow(int row, QString text); - int addRow(QString firstColumn, QString secondColumn); + void updateRow(int row, const QString &text); + int addRow(const QString &firstColumn, const QString &secondColumn); void closeEvent(QCloseEvent *event) override; private: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h index bad6c44add3850a6326996eff327a5976e5a6648..11af6dae0bd741c300600ba4a37b5391974415cb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h @@ -62,7 +62,7 @@ public: setDecimals(prec); }; - void addSpecialTextMapping(QString text, double value); + void addSpecialTextMapping(const QString &text, double value); QString textFromValue(double value) const; QValidator::State validate(QString &input, int &pos) const override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h index 811941e87c0c408cb719236917872d494fa7de1c..14a36248c28f3549b6a5a4068e6eb5a54e5584ce 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/EditLocalParameterDialog.h @@ -28,9 +28,10 @@ class EXPORT_OPT_MANTIDQT_COMMON EditLocalParameterDialog Q_OBJECT public: EditLocalParameterDialog(QWidget *parent, const QString &parName, - const QStringList &wsNames, QList<double> values, - QList<bool> fixes, QStringList ties, - QStringList constraints); + const QStringList &wsNames, + const QList<double> &values, + const QList<bool> &fixes, const QStringList &ties, + const QStringList &constraints); void doSetup(const QString &parName, const QStringList &wsNames); QString getParameterName() const { return m_parName; } QList<double> getValues() const; @@ -55,9 +56,9 @@ private slots: void fixParameter(int /*index*/, bool /*fix*/); void setAllFixed(bool /*fix*/); void setTie(int /*index*/, QString /*tie*/); - void setTieAll(QString /*tie*/); + void setTieAll(const QString & /*tie*/); void setConstraint(int /*index*/, QString /*tie*/); - void setConstraintAll(QString /*tie*/); + void setConstraintAll(const QString & /*tie*/); void copy(); void paste(); void setValueToLog(int /*i*/); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h index cb511b106e713c3921ccbec8f66752ca9b5bdc0b..c9a80cb04781f64b5261bc247f7ed083879838c4 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FileDialogHandler.h @@ -37,7 +37,7 @@ namespace FileDialogHandler { DLLExport QString getSaveFileName(QWidget *parent = nullptr, const Mantid::Kernel::Property *baseProp = nullptr, - QFileDialog::Options options = nullptr); + const QFileDialog::Options &options = nullptr); /** * For file dialogs. This will add the selected extension if an extension diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h index 66d6c471214667f898bea756fbe06c41b9008aff..d0d0f4c1c91f329c2a907dbb74692ca1c7f2116e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FitOptionsBrowser.h @@ -64,7 +64,7 @@ public: void setLogNames(const QStringList &logNames); void setParameterNamesForPlotting(const QStringList &parNames); QString getParameterToPlot() const; - bool addPropertyToBlacklist(QString); + bool addPropertyToBlacklist(const QString &); signals: void changedToSequentialFitting(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h index 862b93bd5c37c90d23b9d441f5248ceaae6794e3..c7a0832df9f5bae34ce9f74c4ea80139d9bcef94 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FitPropertyBrowser.h @@ -226,7 +226,7 @@ public: void setTip(const QString &txt); /// alter text of Plot Guess - void setTextPlotGuess(const QString text); + void setTextPlotGuess(const QString &text); /// Creates the "Ties" property value for the Fit algorithm QString getTieString() const; @@ -466,7 +466,7 @@ protected: /// void updateDecimals(); /// Sets the workspace to a function - void setWorkspace(boost::shared_ptr<Mantid::API::IFunction> f) const; + void setWorkspace(const boost::shared_ptr<Mantid::API::IFunction> &f) const; /// Display properties relevant to the selected workspace void setWorkspaceProperties(); /// Adds the workspace index property to the browser. @@ -486,7 +486,7 @@ protected: /// Catches unexpected not found exceptions Mantid::API::IFunction_sptr tryCreateFitFunction(const QString &str); /// Create CompositeFunction from pointer - void createCompositeFunction(const Mantid::API::IFunction_sptr func); + void createCompositeFunction(const Mantid::API::IFunction_sptr &func); /// Property managers: QtGroupPropertyManager *m_groupManager; @@ -593,7 +593,7 @@ private: /// Return the nearest allowed workspace index. int getAllowedIndex(int currentIndex) const; - void setCurrentFunction(Mantid::API::IFunction_const_sptr f) const; + void setCurrentFunction(const Mantid::API::IFunction_const_sptr &f) const; /// Sets the new workspace to the current one virtual void workspaceChange(const QString &wsName); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h index b99020efd284384f5af4445bacf89d77c33aa56b..eb2d18a920197321cb4e73331020dfac96e068f4 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h @@ -142,7 +142,7 @@ public slots: void setDatasetNames(const QStringList &names) override; void resetLocalParameters(); void setCurrentDataset(int i) override; - void removeDatasets(QList<int> indices); + void removeDatasets(const QList<int> &indices); void addDatasets(const QStringList &names); protected: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h index db966aed4d08dbf7793986df4492680b631c823d..64fb98aec9ec037b5290d93dd51b6377b04de565 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionModel.h @@ -33,7 +33,7 @@ public: bool isParameterFixed(const QString &parName) const; QString getParameterTie(const QString &parName) const; void setParameterFixed(const QString &parName, bool fixed); - void setParameterTie(const QString &parName, QString tie); + void setParameterTie(const QString &parName, const QString &tie); QStringList getParameterNames() const override; IFunction_sptr getSingleFunction(int index) const override; IFunction_sptr getCurrentFunction() const override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h index e6f852b08b01d2977d0ace85d823b80c3dab289d..ca5a129267555c4cbaf29eba2a164e25e2d07f9e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionMultiDomainPresenter.h @@ -62,9 +62,9 @@ public: void setLocalParameterValue(const QString &parName, int i, double value, double error); void setLocalParameterFixed(const QString &parName, int i, bool fixed); - void setLocalParameterTie(const QString &parName, int i, QString tie); + void setLocalParameterTie(const QString &parName, int i, const QString &tie); void setLocalParameterConstraint(const QString &parName, int i, - QString constraint); + const QString &constraint); QStringList getGlobalParameters() const; void setGlobalParameters(const QStringList &globals); QStringList getLocalParameters() const; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h index 365ea2d20a69e83c89c89e21f503f770b3cc47c5..cf0a75346af8c7b2ac762c8b77a48750b06968a6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionTreeView.h @@ -137,24 +137,26 @@ protected: /// Remove and delete property void removeProperty(QtProperty *prop); /// Set a function - void setFunction(QtProperty *prop, Mantid::API::IFunction_sptr fun); + void setFunction(QtProperty *prop, const Mantid::API::IFunction_sptr &fun); /// Add a function - bool addFunction(QtProperty *prop, Mantid::API::IFunction_sptr fun); + bool addFunction(QtProperty *prop, const Mantid::API::IFunction_sptr &fun); /// Add a function property - AProperty addFunctionProperty(QtProperty *parent, QString funName); + AProperty addFunctionProperty(QtProperty *parent, const QString &funName); /// Add a parameter property - AProperty addParameterProperty(QtProperty *parent, QString paramName, - QString paramDesc, double paramValue); + AProperty addParameterProperty(QtProperty *parent, const QString ¶mName, + const QString ¶mDesc, double paramValue); /// Add a attribute property - AProperty addAttributeProperty(QtProperty *parent, QString attName, + AProperty addAttributeProperty(QtProperty *parent, const QString &attName, const Mantid::API::IFunction::Attribute &att); /// Add attribute and parameter properties to a function property - void addAttributeAndParameterProperties(QtProperty *prop, - Mantid::API::IFunction_sptr fun); + void + addAttributeAndParameterProperties(QtProperty *prop, + const Mantid::API::IFunction_sptr &fun); /// Add property showing function's index in the composite function AProperty addIndexProperty(QtProperty *prop); /// Update function index properties - void updateFunctionIndices(QtProperty *prop = nullptr, QString index = ""); + void updateFunctionIndices(QtProperty *prop = nullptr, + const QString &index = ""); /// Get property of the overall function AProperty getFunctionProperty() const; /// Check if property is a function group @@ -194,7 +196,7 @@ protected: QtProperty *getTieProperty(QtProperty *prop) const; /// Add a tie property - void addTieProperty(QtProperty *prop, QString tie); + void addTieProperty(QtProperty *prop, const QString &tie); /// Check if a parameter property has a tie bool hasTie(QtProperty *prop) const; /// Check if a property is a tie @@ -204,7 +206,7 @@ protected: /// Add a constraint property QList<AProperty> addConstraintProperties(QtProperty *prop, - QString constraint); + const QString &constraint); /// Check if a property is a constraint bool isConstraint(QtProperty *prop) const; /// Check if a parameter property has a constraint diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h b/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h index b7c60108de7e6becfba459249952aff346bc43ae..fa184ab919f8a11fc162eb29542bd5b9d0ce702a 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/IndirectFitPropertyBrowserLegacy.h @@ -34,7 +34,7 @@ public: boost::optional<size_t> backgroundIndex() const; boost::optional<size_t> - functionIndex(Mantid::API::IFunction_sptr function) const; + functionIndex(const Mantid::API::IFunction_sptr &function) const; QString selectedFitType() const; @@ -55,7 +55,7 @@ public: void setParameterValue(const std::string &functionName, const std::string ¶meterName, double value); - void setParameterValue(Mantid::API::IFunction_sptr function, + void setParameterValue(const Mantid::API::IFunction_sptr &function, const std::string ¶meterName, double value); void setBackground(const std::string &backgroundName); @@ -134,7 +134,8 @@ public: void setWorkspaceIndex(int i) override; - void updatePlotGuess(Mantid::API::MatrixWorkspace_const_sptr sampleWorkspace); + void updatePlotGuess( + const Mantid::API::MatrixWorkspace_const_sptr &sampleWorkspace); public slots: void fit() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h index a59322011b495f71b11e1b8b56111fcc3747d7f0..547503c904cbb6d2de79834ee11035232ba92322 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h @@ -58,8 +58,8 @@ class EXPORT_OPT_MANTIDQT_COMMON InterfaceManager { public: /// Create a new instance of the correct type of AlgorithmDialog AlgorithmDialog *createDialog( - boost::shared_ptr<Mantid::API::IAlgorithm> alg, QWidget *parent = nullptr, - bool forScript = false, + const boost::shared_ptr<Mantid::API::IAlgorithm> &alg, + QWidget *parent = nullptr, bool forScript = false, const QHash<QString, QString> &presetValues = (QHash<QString, QString>()), const QString &optional_msg = QString(), const QStringList &enabled = QStringList(), diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h b/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h index 47c65042c6ee0ff16ae09c0307b62134d5dc7ce1..01701a1af44141fabc72c097cbaa6177c9ccb2b6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/LocalParameterEditor.h @@ -24,8 +24,8 @@ class LocalParameterEditor : public QWidget { Q_OBJECT public: LocalParameterEditor(QWidget *parent, int index, double value, bool fixed, - QString tie, QString constraint, bool othersFixed, - bool allOthersFixed, bool othersTied, + const QString &tie, const QString &constraint, + bool othersFixed, bool allOthersFixed, bool othersTied, bool logOptionsEnabled); signals: void setAllValues(double /*_t1*/); @@ -57,8 +57,8 @@ private slots: private: bool eventFilter(QObject *widget, QEvent *evn) override; void setEditorState(); - static QString setTieDialog(QString tie); - static QString setConstraintDialog(QString tie); + static QString setTieDialog(const QString &tie); + static QString setConstraintDialog(const QString &tie); QLineEdit *m_editor; QPushButton *m_button; QAction *m_setAllAction; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h index 98e2530fdd79cee9f90eccae9a24d01d14214dde..68f45b649caab64c72616e68ef579d6c3259fb34 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidDialog.h @@ -58,8 +58,8 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidDialog : public QDialog { public: /// DefaultConstructor MantidDialog(QWidget *parent = nullptr, - Qt::WindowFlags flags = Qt::WindowCloseButtonHint | - Qt::WindowType::WindowTitleHint); + const Qt::WindowFlags &flags = Qt::WindowCloseButtonHint | + Qt::WindowType::WindowTitleHint); /// Destructor ~MantidDialog() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h index eb827f00ce9165ee8bcff9a86326e73f4cb97739..d4f39094c92e175265db7f1b468b24a43c24bd54 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h @@ -27,7 +27,8 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidHelpWindow public: static bool helpWindowExists() { return g_helpWindow != nullptr; } - MantidHelpWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr); + MantidHelpWindow(QWidget *parent = nullptr, + const Qt::WindowFlags &flags = nullptr); ~MantidHelpWindow() override; void showPage(const std::string &url = std::string()) override; @@ -68,7 +69,7 @@ private: public slots: /// Perform any clean up on main window shutdown void shutdown() override; - void warning(QString msg); + void warning(const QString &msg); }; } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h index 097001f301bbba7540b6a6260d9a99c3c712ff19..c351c8080cc02d54f669021e999a5f65eee5aaf2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeModel.h @@ -57,7 +57,7 @@ public: QWidget *getParent() override; MantidQt::API::AlgorithmDialog * - createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg); + createAlgorithmDialog(const Mantid::API::IAlgorithm_sptr &alg); // Plotting Methods MultiLayer * diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h index b3854149d3796831b4c9f2dc232f81291083098b..3ff2ee37ebbb61c4e95d351f0e60eae72801a8f5 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h @@ -22,7 +22,8 @@ class MantidTreeWidget; class EXPORT_OPT_MANTIDQT_COMMON MantidTreeWidgetItem : public QTreeWidgetItem { public: explicit MantidTreeWidgetItem(MantidTreeWidget * /*parent*/); - MantidTreeWidgetItem(QStringList /*list*/, MantidTreeWidget * /*parent*/); + MantidTreeWidgetItem(const QStringList & /*list*/, + MantidTreeWidget * /*parent*/); void disableIfNode(bool); void setSortPos(int o) { m_sortPos = o; } int getSortPos() const { return m_sortPos; } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h index 48f03a8dc184d04682a6f6e98318e19804882539..483e5edddd5c4537815d86b0015bc88b467805dc 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h @@ -72,7 +72,7 @@ public: /// Constructor - starting at start and ending at end. Interval(int start, int end); /// Constructor - attempts to parse given string to find start and end. - explicit Interval(QString /*intervalString*/); + explicit Interval(const QString & /*intervalString*/); /// Copy constructor Interval(const Interval & /*copy*/); @@ -114,9 +114,9 @@ public: /// Constructor - with empty list. IntervalList(void); /// Constructor - with a list created by parsing the input string - explicit IntervalList(QString /*intervals*/); + explicit IntervalList(const QString & /*intervals*/); /// Constructor - with a list containing a single Interval - explicit IntervalList(Interval /*interval*/); + explicit IntervalList(const Interval & /*interval*/); /// Copy Constructor IntervalList(const IntervalList & /*copy*/); @@ -220,7 +220,7 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidWSIndexWidget : public QWidget { QLineEdit *lineEdit() { return _lineEdit; }; /// if Error is not empty, it will make the * label visible and set the /// tooltip as the error. - void setError(QString error); + void setError(const QString &error); private: QLineEdit *_lineEdit; @@ -268,7 +268,7 @@ public: /// Constructor - same parameters as one of the parent constructors, along /// with a /// list of the names of workspaces to be plotted. - MantidWSIndexWidget(QWidget *parent, Qt::WindowFlags flags, + MantidWSIndexWidget(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames, const bool showWaterfallOption = false, const bool showTiledOption = false, @@ -391,7 +391,7 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidWSIndexDialog : public QDialog { public: /// Constructor - has a list of the names of workspaces to be plotted. - MantidWSIndexDialog(QWidget *parent, Qt::WindowFlags flags, + MantidWSIndexDialog(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames, const bool showWaterfallOption = false, const bool showPlotAll = true, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h index 65f84da41a61ca74113d0e0f08f1edb96e0ed8aa..ab09a44d7e7c566343bb7202edda83bcfef57147 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MdSettings.h @@ -31,7 +31,7 @@ public: * Set the UserSetting color map for the vsi. *@param colorMap UserSetting colormap for the vsi */ - void setUserSettingColorMap(QString colorMap); + void setUserSettingColorMap(const QString &colorMap); /** * Get the UserSetting color map for the vsi. @@ -48,7 +48,7 @@ public: * Set the LastSession color map * @param colorMap The colormap for the VSI. */ - void setLastSessionColorMap(QString colorMap); + void setLastSessionColorMap(const QString &colorMap); /** * Get the background color for the user setting. @@ -66,7 +66,7 @@ public: * Set the background color for the user setting. * @param backgroundColor The background color. */ - void setUserSettingBackgroundColor(QColor backgroundColor); + void setUserSettingBackgroundColor(const QColor &backgroundColor); /** * Get the background color for the last session. @@ -78,14 +78,15 @@ public: * Set the background color for the user setting. * @param backgroundColor The background color. */ - void setLastSessionBackgroundColor(QColor backgroundColor); + void setLastSessionBackgroundColor(const QColor &backgroundColor); /** * Set the general MD color map * @param colorMapName The name of the general color map. * @param colorMapFile The file name of the general color map. */ - void setGeneralMdColorMap(QString colorMapName, QString colorMapFile); + void setGeneralMdColorMap(const QString &colorMapName, + const QString &colorMapFile); /** * Get the general MD color map file @@ -141,7 +142,7 @@ public: * Set the user setting for the initial view. * @param initialView The selected initial view. */ - void setUserSettingIntialView(QString initialView); + void setUserSettingIntialView(const QString &initialView); /** * Retrieves the state of the last session's log scale. diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h b/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h index d5667c988bef848e7832c016e81dcfbd9859b636..c218b7fec153fe44702e9217e708fb691238f0e2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/Message.h @@ -36,15 +36,15 @@ public: Message(); /// Construct a message from a QString with a given priority (default=notice) Message(const QString &text, Priority priority = Priority::PRIO_NOTICE, - QString scriptPath = ""); + const QString &scriptPath = ""); /// Construct a message from a std::string with a given priority /// (default=notice) Message(const std::string &text, Priority priority = Priority::PRIO_NOTICE, - QString scriptPath = ""); + const QString &scriptPath = ""); /// Construct a message from a c-style string and a given priority /// (default=notice) Message(const char *text, Priority priority = Priority::PRIO_NOTICE, - QString scriptPath = ""); + const QString &scriptPath = ""); /// Copy constructor Message(const Message &msg); /// Copy assignment diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h index e3caa39e9d337058084aec767c8eb9231e41042e..4baa49c3dbc1e196dbfc9eb8e0ba7d923958aa1f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitDataSelector.h @@ -48,8 +48,12 @@ public: /// Get names of chosen groups QStringList getChosenGroups() const override; /// Set chosen group/period - void setGroupsSelected(QStringList groups) { m_chosenGroups = groups; }; - void setPeriodsSelected(QStringList periods) { m_chosenPeriods = periods; }; + void setGroupsSelected(const QStringList &groups) { + m_chosenGroups = groups; + }; + void setPeriodsSelected(const QStringList &periods) { + m_chosenPeriods = periods; + }; /// Get selected periods QStringList getPeriodSelections() const override; /// Get type of fit diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h index e5ebbd454dc1f28a5066b9081f4ff91b1822d609..3239b024b3f9eabf072d92a92184ec5764ce5c8b 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFitPropertyBrowser.h @@ -128,8 +128,8 @@ public: void setChosenGroup(const QString &group); void setAllPeriods(); void setChosenPeriods(const QString &period); - void setSingleFitLabel(std::string name); - void setNormalization(const std::string name); + void setSingleFitLabel(const std::string &name); + void setNormalization(const std::string &name); void checkFitEnabled(); public slots: /// Perform the fit algorithm @@ -185,8 +185,8 @@ private: void finishAfterSimultaneousFit(const Mantid::API::IAlgorithm *fitAlg, const int nWorkspaces) const; void finishAfterTFSimultaneousFit(const Mantid::API::IAlgorithm *alg, - const std::string baseName) const; - void setFitWorkspaces(const std::string input); + const std::string &baseName) const; + void setFitWorkspaces(const std::string &input); std::string getUnnormName(const std::string wsName); void ConvertFitFunctionForMuonTFAsymmetry(bool enabled); void setTFAsymmMode(bool state); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h b/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h index 9e87f040843fd46bc4c947bcffef61dcfd93e0f1..773b926fd90c7f95fb981273c44ab6e25b522075 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/NonOrthogonal.h @@ -27,7 +27,8 @@ bool EXPORT_OPT_MANTIDQT_COMMON isHKLDimensions( const Mantid::API::IMDWorkspace &workspace, size_t dimX, size_t dimY); size_t EXPORT_OPT_MANTIDQT_COMMON getMissingHKLDimensionIndex( - Mantid::API::IMDWorkspace_const_sptr workspace, size_t dimX, size_t dimY); + const Mantid::API::IMDWorkspace_const_sptr &workspace, size_t dimX, + size_t dimY); void EXPORT_OPT_MANTIDQT_COMMON transformFromDoubleToCoordT(const Mantid::Kernel::DblMatrix &skewMatrix, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h index 158052067ee156ec84128a3896aa8f10a6395629..f84dd4db5c09fd97f3323d6964c62a1ff6af8e21 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h @@ -13,12 +13,13 @@ namespace MantidQt { namespace API { -EXPORT_OPT_MANTIDQT_COMMON std::string qtPluginPathFromCfg(std::string key); +EXPORT_OPT_MANTIDQT_COMMON std::string +qtPluginPathFromCfg(const std::string &key); /// Load plugins from a path given by the key in the config service -EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromCfgPath(std::string key); +EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromCfgPath(const std::string &key); /// Load plugins from a path -EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromPath(std::string path); +EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromPath(const std::string &path); } // namespace API } // namespace MantidQt diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h index 92f2975ebceb4e72d354e5ad3ffce3edd4ddc724..913753c63a757c34952a88c430c1426e48c8fb59 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ProcessingAlgoWidget.h @@ -34,7 +34,7 @@ public: /// @return the info string displayed at the top QString infoString() { return ui.lblInfo->text(); } /// Sets the info string displayed at the top - void infoString(QString text) { return ui.lblInfo->setText(text); } + void infoString(const QString &text) { return ui.lblInfo->setText(text); } /// @return true if the script editor is visible bool editorVisible() { return ui.editorContainer->isVisible(); } @@ -55,7 +55,7 @@ public: /// @return the text in the script editor QString getScriptText(); /// Set the script editor text - void setScriptText(QString text); + void setScriptText(const QString &text); void saveInput(); /// Sets the AlgorithmInputHistory object recording the algorithm properties diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h index eb1c2078e049cf6babdb30712a1eac432d455f47..25db0015b4a53286d66a4737851bf9c3f6f05039 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ProjectSaveModel.h @@ -45,9 +45,10 @@ struct WindowInfo { class EXPORT_OPT_MANTIDQT_COMMON ProjectSaveModel { public: /// Construct a new model instance with vector of window handles - ProjectSaveModel(std::vector<MantidQt::API::IProjectSerialisable *> windows, - std::vector<std::string> activePythonInterfaces = - std::vector<std::string>()); + ProjectSaveModel( + const std::vector<MantidQt::API::IProjectSerialisable *> &windows, + std::vector<std::string> activePythonInterfaces = + std::vector<std::string>()); /// Check if a workspace has any windows attached to it bool hasWindows(const std::string &ws) const; @@ -80,7 +81,7 @@ public: private: /// Create a workspace info object for this workspace WorkspaceInfo - makeWorkspaceInfoObject(Mantid::API::Workspace_const_sptr ws) const; + makeWorkspaceInfoObject(const Mantid::API::Workspace_const_sptr &ws) const; WindowInfo makeWindowInfoObject(MantidQt::API::IProjectSerialisable *window) const; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h index ac28a12a507f007ae665f35c260d868410632d85..1fa12b5f7bff5c48d3d4690c10a5c9926af7dcfe 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PropertyHandler.h @@ -42,7 +42,7 @@ class EXPORT_OPT_MANTIDQT_COMMON PropertyHandler Q_OBJECT public: // Constructor - PropertyHandler(Mantid::API::IFunction_sptr fun, + PropertyHandler(const Mantid::API::IFunction_sptr &fun, boost::shared_ptr<Mantid::API::CompositeFunction> parent, FitPropertyBrowser *browser, QtBrowserItem *item = nullptr); @@ -94,7 +94,7 @@ public: PropertyHandler *findHandler(QtProperty *prop); - PropertyHandler *findHandler(Mantid::API::IFunction_const_sptr fun); + PropertyHandler *findHandler(const Mantid::API::IFunction_const_sptr &fun); PropertyHandler *findHandler(const Mantid::API::IFunction *fun); /** @@ -184,7 +184,7 @@ public: void addTie(const QString &tieStr); void fix(const QString &parName); - void removeTie(QtProperty *prop, std::string globalName); + void removeTie(QtProperty *prop, const std::string &globalName); void removeTie(QtProperty *prop); void removeTie(const QString &propName); void addConstraint(QtProperty *parProp, bool lo, bool up, double loBound, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h index 39f0522746e15312802508b4fcf4bec6a0567f7d..0d4a272bf932ae84cdf6bee28c2c827203778cfb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h @@ -192,7 +192,7 @@ private slots: private: void handleKeyEvent(QKeyEvent *e); - int translateModifiers(Qt::KeyboardModifiers state, + int translateModifiers(const Qt::KeyboardModifiers &state, const QString &text) const; int m_num; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h index 59a69bd24c59c01adf791f7960e0bd7fadafc9bb..a0fcbbbfe2c9139ab2a9c82d41856571b7cfe7dc 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h @@ -77,7 +77,7 @@ private: QHash<QString, QString> workspaceMap); QHash<QString, QString> provideZeroFreeWorkspaces(const QListWidget *workspaces); - void removeZeroFreeWorkspaces(QHash<QString, QString> workspaces); + void removeZeroFreeWorkspaces(const QHash<QString, QString> &workspaces); bool isValid(); private slots: void saveSel(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h b/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h index 2ff1ff0d336f8dbf04277eddf38340704c5feb86..bbb6ecd5c853aa61aab6c6257a627ae5f81cbb92 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/ScriptRepositoryView.h @@ -37,7 +37,7 @@ class EXPORT_OPT_MANTIDQT_COMMON ScriptRepositoryView : public MantidDialog { const QModelIndex &index) override; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; - QIcon getIcon(QString state) const; + QIcon getIcon(const QString &state) const; }; /// Delegate to show the checkbox for configuring the auto update class CheckBoxDelegate : public QStyledItemDelegate { @@ -78,7 +78,7 @@ protected slots: void updateModel(); void currentChanged(const QModelIndex ¤t); void helpClicked(); - void openFolderLink(QString /*link*/); + void openFolderLink(const QString & /*link*/); private: Ui::ScriptRepositoryView *ui; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h index f2d09a6454da10e7f3e2be12cebae635be5e54ca..9f6f9ec91a6b27c7609a414f8efab56173a03b7d 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SequentialFitDialog.h @@ -37,7 +37,7 @@ public: /// Add a list of workspace names to the data list /// Returns false if neither of the workspaces can be loaded - bool addWorkspaces(const QStringList wsNames); + bool addWorkspaces(const QStringList &wsNames); private: /// The form generated with Qt Designer @@ -84,7 +84,7 @@ private slots: private: /// Checks that the logs in workspace wsName are consistent /// with logs of other workspaces - bool validateLogs(const QString wsName); + bool validateLogs(const QString &wsName); /// Populate parameter combo box with possible parameter names void populateParameters(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h index 38a18c6755043e37b3707d92f23f0553606b6637..8b65c65627856505c0529ae3a34568ccf51438c6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h @@ -44,10 +44,10 @@ public: ~SlicingAlgorithmDialog() override; // Customisation for the VSI - void customiseLayoutForVsi(std::string initialWorkspace); + void customiseLayoutForVsi(const std::string &initialWorkspace); /// Reset the aligned dim values for the VSI - void resestAlignedDimProperty(size_t index, QString propertyValue); + void resestAlignedDimProperty(size_t index, const QString &propertyValue); protected: /// view @@ -96,7 +96,7 @@ private: /// Build dimension inputs. void makeDimensionInputs( const QString &propertyPrefix, QLayout *owningLayout, - QString (*format)(Mantid::Geometry::IMDDimension_const_sptr), + QString (*format)(const Mantid::Geometry::IMDDimension_const_sptr &), History history); /// Determine if history should be used. diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h index 5d2dfa271f802cb7a1a06dbb19d52b23dcea3184..c9cf9d3fedf6c912045e594313c1796a8db9f063 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SlitCalculator.h @@ -37,10 +37,10 @@ private: Mantid::Geometry::Instrument_const_sptr instrument; std::string currentInstrumentName; void setupSlitCalculatorWithInstrumentValues( - Mantid::Geometry::Instrument_const_sptr /*instrument*/); + const Mantid::Geometry::Instrument_const_sptr & /*instrument*/); std::string getCurrentInstrumentName(); Mantid::Geometry::Instrument_const_sptr getInstrument(); - void setInstrument(std::string instrumentName); + void setInstrument(const std::string &instrumentName); private slots: void on_recalculate_triggered(); }; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h index dfc351b42b18d20b6cd5c610ab15cc25cb8e9121..7fec9813d37849d5b893da6294bcdf812a2dc3f5 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/TSVSerialiser.h @@ -110,7 +110,7 @@ public: void storeDouble(const double val); void storeInt(const int val); - void storeString(const std::string val); + void storeString(const std::string &val); void storeBool(const bool val); double readDouble(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h b/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h index 0eeac6564f865be56a8a3ddcdabfe0a79b50f648..8647a5dcc000ae1629870ffc82d9b398ba1d55b2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/UserInputValidator.h @@ -80,12 +80,13 @@ public: /// Checks the number of histograms in a workspace bool checkWorkspaceNumberOfHistograms(QString const &workspaceName, std::size_t const &validSize); - bool checkWorkspaceNumberOfHistograms(Mantid::API::MatrixWorkspace_sptr, - std::size_t const &validSize); + bool + checkWorkspaceNumberOfHistograms(const Mantid::API::MatrixWorkspace_sptr &, + std::size_t const &validSize); /// Checks the number of bins in a workspace bool checkWorkspaceNumberOfBins(QString const &workspaceName, std::size_t const &validSize); - bool checkWorkspaceNumberOfBins(Mantid::API::MatrixWorkspace_sptr, + bool checkWorkspaceNumberOfBins(const Mantid::API::MatrixWorkspace_sptr &, std::size_t const &validSize); /// Checks that a workspace group contains valid matrix workspace's bool checkWorkspaceGroupIsValid(QString const &groupName, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h index 136d68e6aac274b06fe76d2c00d8348231d6e504..3f744bcbb7ae52ec7cc3536ba26fe5aae5b16818 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspacePresenter/WorkspaceTreeWidget.h @@ -131,7 +131,8 @@ public: private: bool hasUBMatrix(const std::string &wsName); - void addSaveMenuOption(QString algorithmString, QString menuEntryName = ""); + void addSaveMenuOption(const QString &algorithmString, + QString menuEntryName = ""); void setTreeUpdating(const bool state); inline bool isTreeUpdating() const { return m_treeUpdating; } void updateTree(const TopLevelItems &items) override; @@ -140,7 +141,7 @@ private: MantidTreeWidgetItem * addTreeEntry(const std::pair<std::string, Mantid::API::Workspace_sptr> &item, QTreeWidgetItem *parent = nullptr); - bool shouldBeSelected(QString name) const; + bool shouldBeSelected(const QString &name) const; void createWorkspaceMenuActions(); void createSortMenuActions(); void setItemIcon(QTreeWidgetItem *item, const std::string &wsID); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h index a59a49342dac3f38027708451b9ff5bd6c87b962..e01677133bdc416afb2b8e06d4dcf5f0fe89bbe5 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/WorkspaceSelector.h @@ -94,9 +94,9 @@ private: handleReplaceEvent(Mantid::API::WorkspaceAfterReplaceNotification_ptr pNf); bool checkEligibility(const QString &name, - Mantid::API::Workspace_sptr object) const; + const Mantid::API::Workspace_sptr &object) const; bool hasValidSuffix(const QString &name) const; - bool hasValidNumberOfBins(Mantid::API::Workspace_sptr object) const; + bool hasValidNumberOfBins(const Mantid::API::Workspace_sptr &object) const; protected: // Method for handling drop events diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h index 3ad5450c2912319e3cb31eb75fd62907d3bb1c83..e3ae6d05ee26dd87e1c48bfba94c8f3f8f26e152 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h @@ -78,7 +78,7 @@ class EXPORT_OPT_MANTIDQT_COMMON pqHelpWindow : public QMainWindow { public: pqHelpWindow(QHelpEngine *engine, QWidget *parent = nullptr, - Qt::WindowFlags flags = nullptr); + const Qt::WindowFlags &flags = nullptr); public slots: /// Requests showing of a particular page. The url must begin with "qthelp:" diff --git a/qt/widgets/common/src/AlgorithmDialog.cpp b/qt/widgets/common/src/AlgorithmDialog.cpp index a7f2c0c8ae44aaca501126e2938ea188e9f41398..9a29351738bd4969e4fe7a5ab0202ccf0c8cc8f3 100644 --- a/qt/widgets/common/src/AlgorithmDialog.cpp +++ b/qt/widgets/common/src/AlgorithmDialog.cpp @@ -180,7 +180,7 @@ void AlgorithmDialog::saveInput() { * Set the algorithm pointer * @param alg :: A pointer to the algorithm */ -void AlgorithmDialog::setAlgorithm(Mantid::API::IAlgorithm_sptr alg) { +void AlgorithmDialog::setAlgorithm(const Mantid::API::IAlgorithm_sptr &alg) { m_algorithm = alg; m_algName = QString::fromStdString(alg->name()); m_algProperties.clear(); @@ -330,7 +330,7 @@ void AlgorithmDialog::showValidators() { * end. * @return true if the property is valid. */ -bool AlgorithmDialog::setPropertyValue(const QString pName, +bool AlgorithmDialog::setPropertyValue(const QString &pName, bool validateOthers) { // Mantid::Kernel::Property *p = getAlgorithmProperty(pName); QString value = getInputValue(pName); diff --git a/qt/widgets/common/src/AlgorithmHistoryWindow.cpp b/qt/widgets/common/src/AlgorithmHistoryWindow.cpp index cbc796ec461727e6ce3ace05053e3a401256b7c5..c6308d8aab9b4f304f2715b060729c322a8287bb 100644 --- a/qt/widgets/common/src/AlgorithmHistoryWindow.cpp +++ b/qt/widgets/common/src/AlgorithmHistoryWindow.cpp @@ -60,7 +60,7 @@ AlgExecSummaryGrpBox::AlgExecSummaryGrpBox(QWidget *w) : QGroupBox(w), m_execDurationlabel(nullptr), m_execDurationEdit(nullptr), m_Datelabel(nullptr), m_execDateTimeEdit(nullptr), m_algexecDuration() {} -AlgExecSummaryGrpBox::AlgExecSummaryGrpBox(QString title, QWidget *w) +AlgExecSummaryGrpBox::AlgExecSummaryGrpBox(const QString &title, QWidget *w) : QGroupBox(title, w), m_execDurationlabel(nullptr), m_execDurationEdit(nullptr), m_Datelabel(nullptr), m_execDateTimeEdit(nullptr), m_algexecDuration() { @@ -135,7 +135,7 @@ AlgEnvHistoryGrpBox::AlgEnvHistoryGrpBox(QWidget *w) m_osVersionLabel(nullptr), m_osVersionEdit(nullptr), m_frmworkVersionLabel(nullptr), m_frmwkVersnEdit(nullptr) {} -AlgEnvHistoryGrpBox::AlgEnvHistoryGrpBox(QString title, QWidget *w) +AlgEnvHistoryGrpBox::AlgEnvHistoryGrpBox(const QString &title, QWidget *w) : QGroupBox(title, w), m_osNameLabel(nullptr), m_osNameEdit(nullptr), m_osVersionLabel(nullptr), m_osVersionEdit(nullptr), m_frmworkVersionLabel(nullptr), m_frmwkVersnEdit(nullptr) { @@ -202,7 +202,7 @@ AlgEnvHistoryGrpBox::~AlgEnvHistoryGrpBox() { } AlgorithmHistoryWindow::AlgorithmHistoryWindow( - QWidget *parent, const boost::shared_ptr<const Workspace> wsptr) + QWidget *parent, const boost::shared_ptr<const Workspace> &wsptr) : QDialog(parent), m_algHist(wsptr->getHistory()), m_histPropWindow(nullptr), m_execSumGrpBox(nullptr), m_envHistGrpBox(nullptr), m_wsName(wsptr->getName().c_str()), @@ -464,13 +464,13 @@ void AlgEnvHistoryGrpBox::fillEnvHistoryGroupBox( } void AlgorithmHistoryWindow::updateAll( - Mantid::API::AlgorithmHistory_const_sptr algHistory) { + const Mantid::API::AlgorithmHistory_const_sptr &algHistory) { updateAlgHistoryProperties(algHistory); updateExecSummaryGrpBox(algHistory); } void AlgorithmHistoryWindow::updateAlgHistoryProperties( - AlgorithmHistory_const_sptr algHistory) { + const AlgorithmHistory_const_sptr &algHistory) { PropertyHistories histProp = algHistory->getProperties(); if (m_histPropWindow) { m_histPropWindow->setAlgProperties(histProp); @@ -480,7 +480,7 @@ void AlgorithmHistoryWindow::updateAlgHistoryProperties( } void AlgorithmHistoryWindow::updateExecSummaryGrpBox( - AlgorithmHistory_const_sptr algHistory) { + const AlgorithmHistory_const_sptr &algHistory) { // getting the selected algorithm at pos from History vector double duration = algHistory->executionDuration(); Mantid::Types::Core::DateAndTime date = algHistory->executionDate(); @@ -766,7 +766,8 @@ void AlgHistoryTreeWidget::populateAlgHistoryTreeWidget( } void AlgHistoryTreeWidget::populateNestedHistory( - AlgHistoryItem *parentWidget, Mantid::API::AlgorithmHistory_sptr history) { + AlgHistoryItem *parentWidget, + const Mantid::API::AlgorithmHistory_sptr &history) { const Mantid::API::AlgorithmHistories &entries = history->getChildHistories(); if (history->childHistorySize() > 0) { parentWidget->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | diff --git a/qt/widgets/common/src/AlgorithmInputHistory.cpp b/qt/widgets/common/src/AlgorithmInputHistory.cpp index 9ed41fb910c48b339e97170f486bc96a76377c62..84228b2ae6e6fcdb06981e82bd2cfc13bbd3b2c8 100644 --- a/qt/widgets/common/src/AlgorithmInputHistory.cpp +++ b/qt/widgets/common/src/AlgorithmInputHistory.cpp @@ -12,6 +12,7 @@ #include <QSettings> #include <QStringList> +#include <utility> using namespace MantidQt::API; @@ -23,9 +24,9 @@ using namespace MantidQt::API; * Constructor */ AbstractAlgorithmInputHistory::AbstractAlgorithmInputHistory( - QString settingsGroup) - : m_lastInput(), m_previousDirectory(""), m_algorithmsGroup(settingsGroup), - m_dirKey("LastDirectory") { + const QString &settingsGroup) + : m_lastInput(), m_previousDirectory(""), + m_algorithmsGroup(std::move(settingsGroup)), m_dirKey("LastDirectory") { // Fill the stored map from the QSettings information load(); } diff --git a/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp b/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp index 6c51bf9ae4641477f8450434735bbabda5009fc8..ffb6d372ccf23b521b5515fac66b0b6e7549b7c2 100644 --- a/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp +++ b/qt/widgets/common/src/AlgorithmPropertiesWidget.cpp @@ -23,6 +23,8 @@ #include <QScrollArea> #include <algorithm> +#include <utility> + #include <vector> using namespace Mantid::Kernel; @@ -98,7 +100,7 @@ Mantid::API::IAlgorithm_sptr AlgorithmPropertiesWidget::getAlgorithm() { * * @param algo :: IAlgorithm bare ptr */ void AlgorithmPropertiesWidget::setAlgorithm( - Mantid::API::IAlgorithm_sptr algo) { + const Mantid::API::IAlgorithm_sptr &algo) { if (!algo) return; saveInput(); @@ -118,7 +120,7 @@ QString AlgorithmPropertiesWidget::getAlgorithmName() const { * @param name :: The algorithm name*/ void AlgorithmPropertiesWidget::setAlgorithmName(QString name) { FrameworkManager::Instance(); - m_algoName = name; + m_algoName = std::move(name); try { Algorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged(m_algoName.toStdString()); diff --git a/qt/widgets/common/src/Batch/RowLocation.cpp b/qt/widgets/common/src/Batch/RowLocation.cpp index 6a1ea542bb9265f9e9971979afea7e2bbf3f55f1..17a93674670c82ec90a9b0cca14e4a4829563f95 100644 --- a/qt/widgets/common/src/Batch/RowLocation.cpp +++ b/qt/widgets/common/src/Batch/RowLocation.cpp @@ -7,6 +7,7 @@ #include "MantidQtWidgets/Common/Batch/RowLocation.h" #include "MantidQtWidgets/Common/Batch/AssertOrThrow.h" #include <boost/algorithm/string/predicate.hpp> +#include <utility> #include "MantidQtWidgets/Common/Batch/equal.hpp" // equivalent to @@ -18,7 +19,7 @@ namespace MantidQt { namespace MantidWidgets { namespace Batch { -RowLocation::RowLocation(RowPath path) : m_path(path) {} +RowLocation::RowLocation(RowPath path) : m_path(std::move(path)) {} RowPath const &RowLocation::path() const { return m_path; } int RowLocation::rowRelativeToParent() const { return m_path.back(); } bool RowLocation::isRoot() const { return m_path.empty(); } diff --git a/qt/widgets/common/src/BatchAlgorithmRunner.cpp b/qt/widgets/common/src/BatchAlgorithmRunner.cpp index 28b47469e2f2d00b6051260b571dcc4c8abcfe39..a7aea0cff7ee7c9e266c26faf84a9558e59c9f54 100644 --- a/qt/widgets/common/src/BatchAlgorithmRunner.cpp +++ b/qt/widgets/common/src/BatchAlgorithmRunner.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/Common/BatchAlgorithmRunner.h" #include "MantidAPI/AlgorithmManager.h" @@ -20,7 +22,7 @@ namespace API { ConfiguredAlgorithm::ConfiguredAlgorithm(Mantid::API::IAlgorithm_sptr algorithm, AlgorithmRuntimeProps properties) - : m_algorithm(algorithm), m_properties(std::move(properties)) {} + : m_algorithm(std::move(algorithm)), m_properties(std::move(properties)) {} ConfiguredAlgorithm::~ConfiguredAlgorithm() {} @@ -82,8 +84,8 @@ void BatchAlgorithmRunner::stopOnFailure(bool stopOnFailure) { * @param props Optional map of property name to property values to be set just *before execution (mainly intended for input and inout workspace names) */ -void BatchAlgorithmRunner::addAlgorithm(IAlgorithm_sptr algo, - AlgorithmRuntimeProps props) { +void BatchAlgorithmRunner::addAlgorithm(const IAlgorithm_sptr &algo, + const AlgorithmRuntimeProps &props) { m_algorithms.emplace_back(std::make_unique<ConfiguredAlgorithm>(algo, props)); g_log.debug() << "Added algorithm \"" @@ -216,7 +218,8 @@ bool BatchAlgorithmRunner::executeBatchAsyncImpl( * @param algorithm Algorithm and properties to assign to it * @return False if algorithm execution failed */ -bool BatchAlgorithmRunner::executeAlgo(IConfiguredAlgorithm_sptr algorithm) { +bool BatchAlgorithmRunner::executeAlgo( + const IConfiguredAlgorithm_sptr &algorithm) { try { m_currentAlgorithm = algorithm->algorithm(); diff --git a/qt/widgets/common/src/CatalogSearch.cpp b/qt/widgets/common/src/CatalogSearch.cpp index 7ac9b3a457de92b352c07df86e3eac08c41e717a..e7e59c70eb28a0cb232506c57172e03052d8e29a 100644 --- a/qt/widgets/common/src/CatalogSearch.cpp +++ b/qt/widgets/common/src/CatalogSearch.cpp @@ -576,7 +576,7 @@ bool CatalogSearch::validateDates() { return ret; } -void CatalogSearch::correctedToolTip(std::string text, QLabel *label) { +void CatalogSearch::correctedToolTip(const std::string &text, QLabel *label) { #ifdef Q_OS_WIN label->setToolTip(QString::fromStdString("<span style=\"color: black;\">" + text + "</span>")); @@ -1121,7 +1121,7 @@ void CatalogSearch::updateDataFileLabels(QTableWidgetItem *item) { * @return A set containing all file extensions. */ std::unordered_set<std::string> -CatalogSearch::getDataFileExtensions(Mantid::API::Column_sptr column) { +CatalogSearch::getDataFileExtensions(const Mantid::API::Column_sptr &column) { std::unordered_set<std::string> extensions; // For every filename in the column... diff --git a/qt/widgets/common/src/ConvolutionFunctionModel.cpp b/qt/widgets/common/src/ConvolutionFunctionModel.cpp index 1caaf25bd7e649dfe090919f58d156936457da57..b67f48c0105da4a1fc7b9bfe83e0db4befed4e3d 100644 --- a/qt/widgets/common/src/ConvolutionFunctionModel.cpp +++ b/qt/widgets/common/src/ConvolutionFunctionModel.cpp @@ -12,6 +12,7 @@ #include "MantidKernel/Logger.h" #include "MantidQtWidgets/Common/FunctionBrowser/FunctionBrowserUtils.h" #include <iostream> +#include <utility> namespace { Mantid::Kernel::Logger g_log("ConvolutionFunctionModel"); @@ -112,7 +113,7 @@ void ConvolutionFunctionModel::setModel( CompositeFunction_sptr ConvolutionFunctionModel::addBackground(CompositeFunction_sptr domainFunction, - std::string background) { + const std::string &background) { if (background.empty()) return domainFunction; @@ -126,7 +127,7 @@ ConvolutionFunctionModel::addBackground(CompositeFunction_sptr domainFunction, } CompositeFunction_sptr ConvolutionFunctionModel::createInnerFunction( - std::string peaksFunction, bool hasDeltaFunction, bool isQDependent, + const std::string &peaksFunction, bool hasDeltaFunction, bool isQDependent, double qValue, bool hasTempCorrection, double tempValue) { auto functionSpecified = !peaksFunction.empty(); CompositeFunction_sptr innerFunction = @@ -169,7 +170,7 @@ CompositeFunction_sptr ConvolutionFunctionModel::createInnerFunction( } CompositeFunction_sptr ConvolutionFunctionModel::addTempCorrection( - CompositeFunction_sptr peaksFunction, double tempValue) { + const CompositeFunction_sptr &peaksFunction, double tempValue) { CompositeFunction_sptr productFunction = boost::dynamic_pointer_cast<CompositeFunction>( FunctionFactory::Instance().createFunction("ProductFunction")); @@ -194,11 +195,11 @@ ConvolutionFunctionModel::createTemperatureCorrection(double correction) { } CompositeFunction_sptr ConvolutionFunctionModel::createConvolutionFunction( - IFunction_sptr resolutionFunction, IFunction_sptr innerFunction) { + IFunction_sptr resolutionFunction, const IFunction_sptr &innerFunction) { CompositeFunction_sptr convolution = boost::dynamic_pointer_cast<CompositeFunction>( FunctionFactory::Instance().createFunction("Convolution")); - convolution->addFunction(resolutionFunction); + convolution->addFunction(std::move(resolutionFunction)); if (innerFunction->nFunctions() > 0) convolution->addFunction(innerFunction); @@ -206,9 +207,8 @@ CompositeFunction_sptr ConvolutionFunctionModel::createConvolutionFunction( return convolution; } -IFunction_sptr -ConvolutionFunctionModel::createResolutionFunction(std::string workspaceName, - int workspaceIndex) { +IFunction_sptr ConvolutionFunctionModel::createResolutionFunction( + const std::string &workspaceName, int workspaceIndex) { std::string resolution = workspaceName.empty() ? "name=Resolution" diff --git a/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp index 2d8eae3ddd683aa34c46a2e2d85398c6b86bee9b..f5ea73451f7e3f6790bc04ca84f41d7a7e74b875 100644 --- a/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp @@ -4,9 +4,11 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h" +#include <utility> + #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/TableRow.h" +#include "MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h" namespace MantidQt { namespace MantidWidgets { @@ -21,7 +23,7 @@ using namespace Mantid::API; */ AbstractTreeModel::AbstractTreeModel(ITableWorkspace_sptr tableWorkspace, const WhiteList &whitelist) - : m_tWS(tableWorkspace), m_whitelist(whitelist) {} + : m_tWS(std::move(tableWorkspace)), m_whitelist(whitelist) {} AbstractTreeModel::~AbstractTreeModel() {} diff --git a/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp b/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp index d7de335e5dfed0167e4994c88db712f6990dd548..17f11bedd75fec12b0a951b7776a7ee5b3ac5a1d 100644 --- a/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp +++ b/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp @@ -51,9 +51,9 @@ the corresponding hinting line edit in the view @returns ipython notebook string */ GenerateNotebook::GenerateNotebook( - QString name, QString instrument, WhiteList whitelist, + const QString &name, const QString &instrument, WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, + const ProcessingAlgorithm &processor, boost::optional<PostprocessingStep> postprocessingStep, ColumnOptionsMap preprocessingOptionsMap) : m_wsName(std::move(name)), m_instrument(std::move(instrument)), @@ -391,7 +391,7 @@ void addProperties(QStringList &algProperties, const Map &optionsMap) { second item are the names of the output workspaces. */ QString -reduceRowString(const RowData_sptr data, const QString &instrument, +reduceRowString(const RowData_sptr &data, const QString &instrument, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, diff --git a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp index 405d70d087629cabe34e907ad06751c6959c25a9..dbb8011a087ee37dc331c2e606d63c9fd0853a25 100644 --- a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp +++ b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp @@ -37,6 +37,7 @@ #include <fstream> #include <iterator> #include <sstream> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -80,7 +81,7 @@ template <typename T> void pop_front(std::vector<T> &queue) { /** Validate the algorithm inputs * @return : an error message, or empty string if ok */ -std::string validateAlgorithmInputs(IAlgorithm_sptr alg) { +std::string validateAlgorithmInputs(const IAlgorithm_sptr &alg) { std::string error; // Get input property errors as a map auto errorMap = alg->validateInputs(); @@ -115,8 +116,9 @@ namespace DataProcessor { GenericDataProcessorPresenter::GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, PostprocessingAlgorithm postprocessor, - int group, std::map<QString, QString> postprocessMap, QString loader) + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group, + std::map<QString, QString> postprocessMap, const QString &loader) : WorkspaceObserver(), m_view(nullptr), m_progressView(nullptr), m_mainPresenter(), m_loader(std::move(loader)), m_reductionPaused(true), m_postprocessing(postprocessor.name().isEmpty() @@ -178,8 +180,8 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( * (reflectometry). */ GenericDataProcessorPresenter::GenericDataProcessorPresenter( - WhiteList whitelist, ProcessingAlgorithm processor, - PostprocessingAlgorithm postprocessor, int group) + WhiteList whitelist, const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, int group) : GenericDataProcessorPresenter( std::move(whitelist), std::map<QString, PreprocessingAlgorithm>(), std::move(processor), std::move(postprocessor), group) {} @@ -208,7 +210,7 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( GenericDataProcessorPresenter::GenericDataProcessorPresenter( WhiteList whitelist, std::map<QString, PreprocessingAlgorithm> preprocessMap, - ProcessingAlgorithm processor, int group) + const ProcessingAlgorithm &processor, int group) : GenericDataProcessorPresenter( std::move(whitelist), std::move(preprocessMap), std::move(processor), PostprocessingAlgorithm(), group) {} @@ -222,7 +224,7 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( * (reflectometry) */ GenericDataProcessorPresenter::GenericDataProcessorPresenter( - WhiteList whitelist, ProcessingAlgorithm processor, int group) + WhiteList whitelist, const ProcessingAlgorithm &processor, int group) : GenericDataProcessorPresenter( std::move(whitelist), std::map<QString, PreprocessingAlgorithm>(), std::move(processor), PostprocessingAlgorithm(), group) {} @@ -233,7 +235,7 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( GenericDataProcessorPresenter::~GenericDataProcessorPresenter() {} namespace { -std::vector<std::string> toStdStringVector(std::set<QString> in) { +std::vector<std::string> toStdStringVector(const std::set<QString> &in) { auto out = std::vector<std::string>(); std::transform( in.cbegin(), in.cend(), std::back_inserter(out), @@ -320,7 +322,7 @@ Returns the name of the reduced workspace for a given row @returns : The name of the workspace */ QString GenericDataProcessorPresenter::getReducedWorkspaceName( - const RowData_sptr data) const { + const RowData_sptr &data) const { return MantidQt::MantidWidgets::DataProcessor::getReducedWorkspaceName( data, m_whitelist, m_preprocessing.m_map); } @@ -356,13 +358,13 @@ void GenericDataProcessorPresenter::setGroupError(const int groupIndex, m_manager->setError(error, groupIndex); } -void GenericDataProcessorPresenter::setRowIsProcessed(RowData_sptr rowData, - const bool isProcessed) { +void GenericDataProcessorPresenter::setRowIsProcessed( + const RowData_sptr &rowData, const bool isProcessed) { if (rowData) rowData->setProcessed(isProcessed); } -void GenericDataProcessorPresenter::setRowError(RowData_sptr rowData, +void GenericDataProcessorPresenter::setRowError(const RowData_sptr &rowData, const std::string &error) { if (rowData) rowData->setError(error); @@ -439,7 +441,7 @@ bool GenericDataProcessorPresenter::workspaceIsOutputOfGroup( } bool GenericDataProcessorPresenter::workspaceIsOutputOfRow( - RowData_sptr rowData, const std::string &workspaceName) const { + const RowData_sptr &rowData, const std::string &workspaceName) const { if (!rowData) return false; @@ -458,7 +460,8 @@ void GenericDataProcessorPresenter::resetProcessedState(const int groupIndex) { /** Reset the processed state for a row */ -void GenericDataProcessorPresenter::resetProcessedState(RowData_sptr rowData) { +void GenericDataProcessorPresenter::resetProcessedState( + const RowData_sptr &rowData) { rowData->reset(); } @@ -505,7 +508,8 @@ void GenericDataProcessorPresenter::resetProcessedState() { * @param rowData [inout] : the data to initialise * @return : true if ok, false if there was a problem */ -bool GenericDataProcessorPresenter::initRowForProcessing(RowData_sptr rowData) { +bool GenericDataProcessorPresenter::initRowForProcessing( + const RowData_sptr &rowData) { // Reset the row to its unprocessed state rowData->reset(); @@ -575,7 +579,7 @@ bool GenericDataProcessorPresenter::groupNeedsProcessing( /** Check whether a row should be processed */ bool GenericDataProcessorPresenter::rowNeedsProcessing( - RowData_sptr rowData) const { + const RowData_sptr &rowData) const { if (m_forceProcessing) return true; @@ -591,7 +595,7 @@ bool GenericDataProcessorPresenter::rowNeedsProcessing( /** Process a given set of items */ void GenericDataProcessorPresenter::process(TreeData itemsToProcess) { - m_itemsToProcess = itemsToProcess; + m_itemsToProcess = std::move(itemsToProcess); // Emit a signal that the process is starting m_view->emitProcessClicked(); @@ -707,7 +711,7 @@ void GenericDataProcessorPresenter::startAsyncRowReduceThread( RowData_sptr rowData, const int rowIndex, const int groupIndex) { auto *worker = new GenericDataProcessorPresenterRowReducerWorker( - this, rowData, rowIndex, groupIndex); + this, std::move(rowData), rowIndex, groupIndex); connect(worker, SIGNAL(finished(int)), this, SLOT(rowThreadFinished(int))); connect(worker, SIGNAL(reductionErrorSignal(QString)), this, @@ -960,7 +964,8 @@ QString GenericDataProcessorPresenter::getPostprocessedWorkspaceName( if (!hasPostprocessing()) throw std::runtime_error("Attempted to get postprocessing workspace but no " "postprocessing is specified."); - return m_postprocessing->getPostprocessedWorkspaceName(groupData, sliceIndex); + return m_postprocessing->getPostprocessedWorkspaceName(groupData, + std::move(sliceIndex)); } /** Loads a run found from disk or AnalysisDataService @@ -1089,7 +1094,7 @@ GenericDataProcessorPresenter::createProcessingAlgorithm() const { * @param data [in] :: the data in the row */ void GenericDataProcessorPresenter::preprocessColumnValue( - const QString &columnName, QString &columnValue, RowData_sptr data) { + const QString &columnName, QString &columnValue, const RowData_sptr &data) { // Check if preprocessing is required for this column if (!m_preprocessing.hasPreprocessing(columnName)) return; @@ -1099,7 +1104,8 @@ void GenericDataProcessorPresenter::preprocessColumnValue( OptionsMap options; if (m_preprocessing.hasOptions(columnName)) { auto globalOptions = m_preprocessing.m_options.at(columnName); - options = getCanonicalOptions(data, globalOptions, m_whitelist, false); + options = + getCanonicalOptions(std::move(data), globalOptions, m_whitelist, false); } // Run the preprocessing algorithm @@ -1112,7 +1118,8 @@ void GenericDataProcessorPresenter::preprocessColumnValue( /** Perform preprocessing on algorithm property values where applicable * @param data : the data in the row */ -void GenericDataProcessorPresenter::preprocessOptionValues(RowData_sptr data) { +void GenericDataProcessorPresenter::preprocessOptionValues( + const RowData_sptr &data) { auto options = data->options(); // Loop through all columns (excluding the Options and Hidden options // columns) @@ -1137,8 +1144,8 @@ void GenericDataProcessorPresenter::preprocessOptionValues(RowData_sptr data) { * @param alg : the executed algorithm * @param data : the row data */ -void GenericDataProcessorPresenter::updateModelFromResults(IAlgorithm_sptr alg, - RowData_sptr data) { +void GenericDataProcessorPresenter::updateModelFromResults( + const IAlgorithm_sptr &alg, const RowData_sptr &data) { auto newData = data; @@ -1221,7 +1228,7 @@ IAlgorithm_sptr GenericDataProcessorPresenter::createAndRunAlgorithm( * correspond to column contents * @throws std::runtime_error if reduction fails */ -void GenericDataProcessorPresenter::reduceRow(RowData_sptr data) { +void GenericDataProcessorPresenter::reduceRow(const RowData_sptr &data) { // Perform any preprocessing on the input properties and cache the results // in the row data diff --git a/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp b/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp index 03694d1dfeb8fb620624f459f8818a6e2158065e..5218be72ac0894ec182e93204941df26d3cca433 100644 --- a/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp +++ b/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp @@ -30,6 +30,7 @@ #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -46,10 +47,10 @@ namespace DataProcessor { * @param whitelist :: a whitelist */ OneLevelTreeManager::OneLevelTreeManager( - DataProcessorPresenter *presenter, Mantid::API::ITableWorkspace_sptr table, - const WhiteList &whitelist) + DataProcessorPresenter *presenter, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist) : m_presenter(presenter), - m_model(new QOneLevelTreeModel(table, whitelist)) {} + m_model(new QOneLevelTreeModel(std::move(table), whitelist)) {} /** * Constructor (no table workspace given) @@ -323,7 +324,7 @@ std::set<int> OneLevelTreeManager::getRowsToProcess(bool shouldPrompt) const { * @return :: All data as a map where keys are units of post-processing (i.e. * group indices) and values are a map of row index in the group to row data */ -TreeData OneLevelTreeManager::constructTreeData(std::set<int> rows) { +TreeData OneLevelTreeManager::constructTreeData(const std::set<int> &rows) { // Return data in the format: map<int, set<RowData_sptr>>, where: // int -> row index @@ -525,7 +526,7 @@ OneLevelTreeManager::createDefaultWorkspace(const WhiteList &whitelist) { * @param ws :: the table workspace * @param whitelistColumns :: the number of columns as specified in a whitelist */ -void OneLevelTreeManager::validateModel(ITableWorkspace_sptr ws, +void OneLevelTreeManager::validateModel(const ITableWorkspace_sptr &ws, size_t whitelistColumns) const { if (!ws) diff --git a/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp b/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp index 5a101cb911c56a5fc732db8299b40aa2d74a645e..eb731cdc8e42bbcbc5d2f6869f575fb4e764aaed 100644 --- a/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp +++ b/qt/widgets/common/src/DataProcessorUI/PostprocessingStep.cpp @@ -10,10 +10,10 @@ namespace MantidQt { namespace MantidWidgets { namespace DataProcessor { -PostprocessingStep::PostprocessingStep(QString options) +PostprocessingStep::PostprocessingStep(const QString &options) : m_options(std::move(options)) {} -PostprocessingStep::PostprocessingStep(QString options, - PostprocessingAlgorithm algorithm, +PostprocessingStep::PostprocessingStep(const QString &options, + const PostprocessingAlgorithm &algorithm, std::map<QString, QString> map) : m_options(std::move(options)), m_algorithm(std::move(algorithm)), m_map(std::move(map)) {} diff --git a/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp b/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp index 3ec222ce2dc0c85c52c7390b39a0dd106750c4d5..b17a8ca3bb352852b787994098ee7d27ef7dd4be 100644 --- a/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp +++ b/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp @@ -18,9 +18,9 @@ namespace DataProcessor { * @param blacklist : The list of properties we don't want to show * algorithm in the processed workspace's name */ -PreprocessingAlgorithm::PreprocessingAlgorithm(QString name, QString prefix, - QString separator, - std::set<QString> blacklist) +PreprocessingAlgorithm::PreprocessingAlgorithm( + const QString &name, const QString &prefix, const QString &separator, + const std::set<QString> &blacklist) : ProcessingAlgorithmBase(std::move(name), std::move(blacklist)), m_prefix(std::move(prefix)), m_separator(std::move(separator)) { @@ -53,8 +53,9 @@ PreprocessingAlgorithm::PreprocessingAlgorithm(QString name, QString prefix, * @param blacklist : The list of properties we don't want to show, as a string * algorithm in the processed workspace's name */ -PreprocessingAlgorithm::PreprocessingAlgorithm(QString name, QString prefix, - QString separator, +PreprocessingAlgorithm::PreprocessingAlgorithm(const QString &name, + const QString &prefix, + const QString &separator, const QString &blacklist) : PreprocessingAlgorithm(std::move(name), std::move(prefix), std::move(separator), diff --git a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp index b470b1bfbb950e8769b90b296307929795d9de13..186423fd86081ed795f0e7d1bc67fb1b36d267b1 100644 --- a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp +++ b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp @@ -21,9 +21,9 @@ namespace DataProcessor { * indicate the most recent version. */ ProcessingAlgorithm::ProcessingAlgorithm( - QString name, std::vector<QString> prefix, - std::size_t postprocessedOutputPrefixIndex, std::set<QString> blacklist, - const int version) + const QString &name, std::vector<QString> prefix, + std::size_t postprocessedOutputPrefixIndex, + const std::set<QString> &blacklist, const int version) : ProcessingAlgorithmBase(std::move(name), std::move(blacklist), version), m_postprocessedOutputPrefixIndex(postprocessedOutputPrefixIndex), m_prefix(std::move(prefix)) { @@ -63,7 +63,7 @@ ProcessingAlgorithm::ProcessingAlgorithm( * indicate the most recent version. */ ProcessingAlgorithm::ProcessingAlgorithm( - QString name, QString const &prefix, + const QString &name, QString const &prefix, std::size_t postprocessedOutputPrefixIndex, QString const &blacklist, const int version) : ProcessingAlgorithm(std::move(name), convertStringToVector(prefix), diff --git a/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp index d8b577cc69eb19192f4491c9f15f263ad1ec1bd5..8e417ba67f655f61a02841d473c71c7ce67e1abe 100644 --- a/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp @@ -19,8 +19,8 @@ using namespace Mantid::API; @param tableWorkspace : The table workspace to wrap @param whitelist : A WhiteList containing the columns */ -QOneLevelTreeModel::QOneLevelTreeModel(ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist) +QOneLevelTreeModel::QOneLevelTreeModel( + const ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist) : AbstractTreeModel(tableWorkspace, whitelist) { if (tableWorkspace->columnCount() != m_whitelist.size()) diff --git a/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp index 57a1a32609755a13b8176e1514556bfd26bb632a..7f6e3707c40cd70c660db545525326eb0f31d50d 100644 --- a/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp @@ -25,7 +25,7 @@ public: : m_absoluteIndex(absoluteIndex), m_rowData(std::make_shared<RowData>(columnCount)) {} // Constructor taking a list of data values - RowInfo(const size_t absoluteIndex, QStringList rowDataValues) + RowInfo(const size_t absoluteIndex, const QStringList &rowDataValues) : m_absoluteIndex(absoluteIndex), m_rowData(std::make_shared<RowData>(std::move(rowDataValues))) {} @@ -174,8 +174,8 @@ private: @param whitelist : A WhiteList containing information about the columns, their indices and descriptions */ -QTwoLevelTreeModel::QTwoLevelTreeModel(ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist) +QTwoLevelTreeModel::QTwoLevelTreeModel( + const ITableWorkspace_sptr &tableWorkspace, const WhiteList &whitelist) : AbstractTreeModel(tableWorkspace, whitelist) { if (tableWorkspace->columnCount() != m_whitelist.size() + 1) @@ -786,7 +786,7 @@ bool QTwoLevelTreeModel::setData(const QModelIndex &index, * whitelist * @param table : A table workspace containing the data */ -void QTwoLevelTreeModel::setupModelData(ITableWorkspace_sptr table) { +void QTwoLevelTreeModel::setupModelData(const ITableWorkspace_sptr &table) { int nrows = static_cast<int>(table->rowCount()); diff --git a/qt/widgets/common/src/DataProcessorUI/TreeData.cpp b/qt/widgets/common/src/DataProcessorUI/TreeData.cpp index 566c778c3e31015d635da6c2006405bcad2bd38f..16aa102ccadd71a0ba04c4a967aede03ab9c16bf 100644 --- a/qt/widgets/common/src/DataProcessorUI/TreeData.cpp +++ b/qt/widgets/common/src/DataProcessorUI/TreeData.cpp @@ -18,7 +18,7 @@ RowData::RowData(const int columnCount) : m_isProcessed{false} { m_data.append(""); } -RowData::RowData(QStringList data) +RowData::RowData(const QStringList &data) : m_data(std::move(data)), m_isProcessed{false} {} RowData::RowData(const std::vector<std::string> &data) : m_isProcessed{false} { @@ -311,7 +311,7 @@ bool RowData::reductionFailed() const { * prefixes have been applied for specific output properties. * @param prefix [in] : if not empty, apply this prefix to the name */ -QString RowData::reducedName(const QString prefix) const { +QString RowData::reducedName(const QString &prefix) const { if (prefix.isEmpty()) return m_reducedName; else diff --git a/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp b/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp index 64d2b5e8864954e2f5e4a1a9406af5e293e56739..c78a17311e0595e8d9319bf63827d6fef7dd0bfb 100644 --- a/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp +++ b/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp @@ -39,6 +39,7 @@ #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/split.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -55,10 +56,10 @@ namespace DataProcessor { * @param whitelist :: a whitelist */ TwoLevelTreeManager::TwoLevelTreeManager( - DataProcessorPresenter *presenter, Mantid::API::ITableWorkspace_sptr table, - const WhiteList &whitelist) + DataProcessorPresenter *presenter, + const Mantid::API::ITableWorkspace_sptr &table, const WhiteList &whitelist) : m_presenter(presenter), - m_model(new QTwoLevelTreeModel(table, whitelist)) {} + m_model(new QTwoLevelTreeModel(std::move(table), whitelist)) {} /** * Constructor (no table workspace given) @@ -446,7 +447,7 @@ int TwoLevelTreeManager::numRowsInGroup(int group) const { * @return :: All data as a map where keys are units of post-processing (i.e. * group indices) and values are a map of row index in the group to row data */ -TreeData TwoLevelTreeManager::constructTreeData(ChildItems rows) { +TreeData TwoLevelTreeManager::constructTreeData(const ChildItems &rows) { TreeData tree; const int columnNotUsed = 0; // dummy value required to create index // Return row data in the format: map<int, set<vector<string>>>, where: @@ -722,7 +723,7 @@ TwoLevelTreeManager::createDefaultWorkspace(const WhiteList &whitelist) { * @param ws :: the table workspace * @param whitelistColumns :: the number of columns as specified in a whitelist */ -void TwoLevelTreeManager::validateModel(ITableWorkspace_sptr ws, +void TwoLevelTreeManager::validateModel(const ITableWorkspace_sptr &ws, size_t whitelistColumns) const { if (!ws) diff --git a/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp b/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp index 88563e9f060a9ec3f76fba198a47cb9882689e6a..1dff5796842f1b8f94300f0520c041193480f776 100644 --- a/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp +++ b/qt/widgets/common/src/DataProcessorUI/WorkspaceNameUtils.cpp @@ -27,7 +27,7 @@ namespace { // unnamed namespace * @param allowInsertions : if true, allow new keys to be inserted; * otherwise, only allow updating of keys that already exist */ -void updateRowOptions(OptionsMap &options, const RowData_sptr data, +void updateRowOptions(OptionsMap &options, const RowData_sptr &data, const WhiteList &whitelist, const bool allowInsertions) { // Loop through all columns (excluding the Options and Hidden options // columns) @@ -55,7 +55,7 @@ void updateRowOptions(OptionsMap &options, const RowData_sptr data, * @param allowInsertions : if true, allow new keys to be inserted; * otherwise, only allow updating of keys that already exist */ -void updateUserOptions(OptionsMap &options, const RowData_sptr data, +void updateUserOptions(OptionsMap &options, const RowData_sptr &data, const WhiteList &whitelist, const bool allowInsertions) { auto userOptions = parseKeyValueQString(data->value(static_cast<int>(whitelist.size()) - 2)); @@ -72,7 +72,7 @@ void updateUserOptions(OptionsMap &options, const RowData_sptr data, * @param allowInsertions : if true, allow new keys to be inserted; * otherwise, only allow updating of keys that already exist */ -void updateHiddenOptions(OptionsMap &options, const RowData_sptr data, +void updateHiddenOptions(OptionsMap &options, const RowData_sptr &data, const bool allowInsertions) { const auto hiddenOptions = parseKeyValueQString(data->back()); for (auto &kvp : hiddenOptions) { @@ -86,7 +86,7 @@ void updateHiddenOptions(OptionsMap &options, const RowData_sptr data, * @param options : a map of property name to option value to update * @param data : the data for this row */ -void updateOutputOptions(OptionsMap &options, const RowData_sptr data, +void updateOutputOptions(OptionsMap &options, const RowData_sptr &data, const bool allowInsertions, const std::vector<QString> &outputPropertyNames, const std::vector<QString> &outputNamePrefixes) { @@ -141,7 +141,7 @@ algorithm for that column @returns : The name of the workspace */ QString getReducedWorkspaceName( - const RowData_sptr data, const WhiteList &whitelist, + const RowData_sptr &data, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessMap) { if (data->size() != static_cast<int>(whitelist.size())) throw std::invalid_argument("Can't find reduced workspace name"); @@ -206,7 +206,7 @@ QString getReducedWorkspaceName( * names * @return : a map of property names to value */ -OptionsMap getCanonicalOptions(const RowData_sptr data, +OptionsMap getCanonicalOptions(const RowData_sptr &data, const OptionsMap &globalOptions, const WhiteList &whitelist, const bool allowInsertions, diff --git a/qt/widgets/common/src/DiagResults.cpp b/qt/widgets/common/src/DiagResults.cpp index 66a944e5b7ae3043d185f893e070ba4b46dea858..90b925690a8573bddb92ba1e7fa46052dea8d1e6 100644 --- a/qt/widgets/common/src/DiagResults.cpp +++ b/qt/widgets/common/src/DiagResults.cpp @@ -112,7 +112,8 @@ void DiagResults::updateResults(const QString &testSummary) { // Private member functions //---------------------- /// insert a row at the bottom of the grid -int DiagResults::addRow(QString firstColumn, QString secondColumn) { +int DiagResults::addRow(const QString &firstColumn, + const QString &secondColumn) { // set row to one past the end of the number of rows that currently exist int row = m_Grid->rowCount(); m_Grid->addWidget(new QLabel(firstColumn), row, 0); @@ -124,7 +125,7 @@ int DiagResults::addRow(QString firstColumn, QString secondColumn) { * @param row :: the row where the data will be displayed * @param text :: the text that should be displayed in the first column */ -void DiagResults::updateRow(int row, QString text) { +void DiagResults::updateRow(int row, const QString &text) { // Get the text label from the grid QWidget *widget = m_Grid->itemAtPosition(row, 1)->widget(); QLabel *label = qobject_cast<QLabel *>(widget); diff --git a/qt/widgets/common/src/DoubleSpinBox.cpp b/qt/widgets/common/src/DoubleSpinBox.cpp index f215e3c726a33af56867c757f7cbda3db67ac98c..583cdf5a216a67649a6d06956664737e22fb4eb8 100644 --- a/qt/widgets/common/src/DoubleSpinBox.cpp +++ b/qt/widgets/common/src/DoubleSpinBox.cpp @@ -115,7 +115,7 @@ void DoubleSpinBox::interpretText(bool notify) { * @param text QString with text to map * @param value Value to map it to */ -void DoubleSpinBox::addSpecialTextMapping(QString text, double value) { +void DoubleSpinBox::addSpecialTextMapping(const QString &text, double value) { m_specialTextMappings[text] = value; } diff --git a/qt/widgets/common/src/EditLocalParameterDialog.cpp b/qt/widgets/common/src/EditLocalParameterDialog.cpp index 226cae763bd5cee131834b32bc0e48e371a2ece5..b39f1e02c302505b45000cbe1462276038b7ac61 100644 --- a/qt/widgets/common/src/EditLocalParameterDialog.cpp +++ b/qt/widgets/common/src/EditLocalParameterDialog.cpp @@ -13,6 +13,7 @@ #include <QMenu> #include <QMessageBox> #include <limits> +#include <utility> namespace { QString makeNumber(double d) { return QString::number(d, 'g', 16); } @@ -35,8 +36,8 @@ namespace MantidWidgets { */ EditLocalParameterDialog::EditLocalParameterDialog( QWidget *parent, const QString &parName, const QStringList &wsNames, - QList<double> values, QList<bool> fixes, QStringList ties, - QStringList constraints) + const QList<double> &values, const QList<bool> &fixes, + const QStringList &ties, const QStringList &constraints) : MantidDialog(parent), m_parName(parName), m_values(values), m_fixes(fixes), m_ties(ties), m_constraints(constraints) { assert(values.size() == wsNames.size()); @@ -171,14 +172,14 @@ void EditLocalParameterDialog::fixParameter(int index, bool fix) { /// @param index :: Index of a paramter to tie. /// @param tie :: A tie string. void EditLocalParameterDialog::setTie(int index, QString tie) { - m_ties[index] = tie; + m_ties[index] = std::move(tie); m_fixes[index] = false; updateRoleColumn(index); } /// Set the same tie to all parameters. /// @param tie :: A tie string. -void EditLocalParameterDialog::setTieAll(QString tie) { +void EditLocalParameterDialog::setTieAll(const QString &tie) { for (int i = 0; i < m_ties.size(); ++i) { m_ties[i] = tie; m_fixes[i] = false; @@ -188,11 +189,11 @@ void EditLocalParameterDialog::setTieAll(QString tie) { } void EditLocalParameterDialog::setConstraint(int index, QString constraint) { - m_constraints[index] = constraint; + m_constraints[index] = std::move(constraint); updateRoleColumn(index); } -void EditLocalParameterDialog::setConstraintAll(QString constraint) { +void EditLocalParameterDialog::setConstraintAll(const QString &constraint) { for (int i = 0; i < m_constraints.size(); ++i) { m_constraints[i] = constraint; updateRoleColumn(i); diff --git a/qt/widgets/common/src/FileDialogHandler.cpp b/qt/widgets/common/src/FileDialogHandler.cpp index 8afbe8aef42e9e3d4d1321d7f68b5585df7ba374..aadd30c3ceacf918f95f53ae9307a133cebb45b4 100644 --- a/qt/widgets/common/src/FileDialogHandler.cpp +++ b/qt/widgets/common/src/FileDialogHandler.cpp @@ -41,7 +41,7 @@ namespace FileDialogHandler { */ QString getSaveFileName(QWidget *parent, const Mantid::Kernel::Property *baseProp, - QFileDialog::Options options) { + const QFileDialog::Options &options) { // set up filters and dialog title const auto filter = getFilter(baseProp); const auto caption = getCaption("Save file", baseProp); diff --git a/qt/widgets/common/src/FindFilesThreadPoolManager.cpp b/qt/widgets/common/src/FindFilesThreadPoolManager.cpp index 6fc29255e7cac4ac96699fc190405fa2328528db..2f03ba23f9798699ed33bcb988dc3816e27c6238 100644 --- a/qt/widgets/common/src/FindFilesThreadPoolManager.cpp +++ b/qt/widgets/common/src/FindFilesThreadPoolManager.cpp @@ -17,6 +17,7 @@ #include <QCoreApplication> #include <QSharedPointer> #include <boost/algorithm/string.hpp> +#include <utility> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -63,7 +64,7 @@ FindFilesThreadPoolManager::FindFilesThreadPoolManager() { * worker objects */ void FindFilesThreadPoolManager::setAllocator(ThreadAllocator allocator) { - m_workerAllocator = allocator; + m_workerAllocator = std::move(allocator); } void FindFilesThreadPoolManager::createWorker( diff --git a/qt/widgets/common/src/FitOptionsBrowser.cpp b/qt/widgets/common/src/FitOptionsBrowser.cpp index c964e6f595da80a1e1b3a639d1da9c0ae209c901..83b2719810143120570e5972075f49c14717b4b0 100644 --- a/qt/widgets/common/src/FitOptionsBrowser.cpp +++ b/qt/widgets/common/src/FitOptionsBrowser.cpp @@ -838,7 +838,7 @@ void FitOptionsBrowser::displayProperty(const QString &propertyName, /** * Adds the property with the given name to a blacklist of properties to hide */ -bool FitOptionsBrowser::addPropertyToBlacklist(QString name) { +bool FitOptionsBrowser::addPropertyToBlacklist(const QString &name) { if (!m_propertyNameMap.contains(name)) { return false; } diff --git a/qt/widgets/common/src/FitPropertyBrowser.cpp b/qt/widgets/common/src/FitPropertyBrowser.cpp index 25d268dc758f4c189c68e434b7487794dab52586..1d75b9d193c2639287f0ee9cc793c2328a8bf748 100644 --- a/qt/widgets/common/src/FitPropertyBrowser.cpp +++ b/qt/widgets/common/src/FitPropertyBrowser.cpp @@ -55,6 +55,7 @@ #include <QVBoxLayout> #include <algorithm> +#include <utility> namespace MantidQt { using API::MantidDesktopServices; @@ -66,7 +67,7 @@ Mantid::Kernel::Logger g_log("FitPropertyBrowser"); using namespace Mantid::API; -int getNumberOfSpectra(MatrixWorkspace_sptr workspace) { +int getNumberOfSpectra(const MatrixWorkspace_sptr &workspace) { return static_cast<int>(workspace->getNumberHistograms()); } @@ -774,7 +775,7 @@ void FitPropertyBrowser::closeFit() { m_fitSelector->close(); } * @param func :: [input] Pointer to function */ void FitPropertyBrowser::createCompositeFunction( - const Mantid::API::IFunction_sptr func) { + const Mantid::API::IFunction_sptr &func) { if (m_compositeFunction) { emit functionRemoved(); m_autoBackground = nullptr; @@ -1598,8 +1599,8 @@ void FitPropertyBrowser::setCurrentFunction(PropertyHandler *h) const { * @param f :: New current function */ void FitPropertyBrowser::setCurrentFunction( - Mantid::API::IFunction_const_sptr f) const { - setCurrentFunction(getHandler()->findHandler(f)); + const Mantid::API::IFunction_const_sptr &f) const { + setCurrentFunction(getHandler()->findHandler(std::move(f))); } /** @@ -2716,7 +2717,7 @@ void FitPropertyBrowser::reset() { } void FitPropertyBrowser::setWorkspace( - Mantid::API::IFunction_sptr function) const { + const Mantid::API::IFunction_sptr &function) const { std::string wsName = workspaceName(); if (!wsName.empty()) { try { @@ -2979,7 +2980,7 @@ bool FitPropertyBrowser::rawData() const { return m_boolManager->value(m_rawData); } -void FitPropertyBrowser::setTextPlotGuess(const QString text) { +void FitPropertyBrowser::setTextPlotGuess(const QString &text) { m_displayActionPlotGuess->setText(text); } diff --git a/qt/widgets/common/src/FunctionBrowser.cpp b/qt/widgets/common/src/FunctionBrowser.cpp index b207df97dc17b6a19ae9923892d06500ded6ff9b..6824ab9ea5bb7ee3cae3b9bc55dadb3f77f3c5c7 100644 --- a/qt/widgets/common/src/FunctionBrowser.cpp +++ b/qt/widgets/common/src/FunctionBrowser.cpp @@ -25,6 +25,7 @@ #include <algorithm> #include <boost/lexical_cast.hpp> +#include <utility> namespace { Mantid::Kernel::Logger g_log("Function Browser"); @@ -81,7 +82,7 @@ void FunctionBrowser::setFunction(const QString &funStr) { * @param fun :: A function */ void FunctionBrowser::setFunction(IFunction_sptr fun) { - m_presenter->setFunction(fun); + m_presenter->setFunction(std::move(fun)); } /** @@ -199,8 +200,8 @@ void FunctionBrowser::setCurrentDataset(int i) { /// Remove local parameter values for a number of datasets. /// @param indices :: A list of indices of datasets to remove. -void FunctionBrowser::removeDatasets(QList<int> indices) { - m_presenter->removeDatasets(indices); +void FunctionBrowser::removeDatasets(const QList<int> &indices) { + m_presenter->removeDatasets(std::move(indices)); } /// Add some datasets to those already set. diff --git a/qt/widgets/common/src/FunctionModel.cpp b/qt/widgets/common/src/FunctionModel.cpp index 2d74d736d6a4418809fd8a8c53d6bd1e4af9db80..6109e3be89a85e86e6faf8752d78f064a590f991 100644 --- a/qt/widgets/common/src/FunctionModel.cpp +++ b/qt/widgets/common/src/FunctionModel.cpp @@ -178,7 +178,8 @@ void FunctionModel::setParameterFixed(const QString &parName, bool fixed) { fixed); } -void FunctionModel::setParameterTie(const QString &parName, QString tie) { +void FunctionModel::setParameterTie(const QString &parName, + const QString &tie) { setLocalParameterTie(parName, static_cast<int>(m_currentDomainIndex), tie); } diff --git a/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp b/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp index 54b5abade8cd2eb374199d1c36a08fe3ef8ed1aa..f6877ec980c03b52209a6d1b6690ae68d98c4cbc 100644 --- a/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp +++ b/qt/widgets/common/src/FunctionMultiDomainPresenter.cpp @@ -17,6 +17,7 @@ #include <QClipboard> #include <QMessageBox> #include <QWidget> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -51,7 +52,7 @@ FunctionMultiDomainPresenter::FunctionMultiDomainPresenter(IFunctionView *view) } void FunctionMultiDomainPresenter::setFunction(IFunction_sptr fun) { - m_model->setFunction(fun); + m_model->setFunction(std::move(fun)); m_view->setFunction(m_model->getCurrentFunction()); emit functionStructureChanged(); } @@ -224,7 +225,8 @@ void FunctionMultiDomainPresenter::setLocalParameterFixed( } void FunctionMultiDomainPresenter::setLocalParameterTie(const QString &parName, - int i, QString tie) { + int i, + const QString &tie) { m_model->setLocalParameterTie(parName, i, tie); if (m_model->currentDomainIndex() == i) { m_view->setParameterTie(parName, tie); @@ -232,7 +234,7 @@ void FunctionMultiDomainPresenter::setLocalParameterTie(const QString &parName, } void FunctionMultiDomainPresenter::setLocalParameterConstraint( - const QString &parName, int i, QString constraint) { + const QString &parName, int i, const QString &constraint) { m_model->setLocalParameterConstraint(parName, i, constraint); if (m_model->currentDomainIndex() == i) { m_view->setParameterConstraint(parName, constraint); diff --git a/qt/widgets/common/src/FunctionTreeView.cpp b/qt/widgets/common/src/FunctionTreeView.cpp index 7fe4bba3e687e6c2d1f1cd54af85ddc6d1b5c251..3969cf380a94a78f20d84c46e072ac754664b0af 100644 --- a/qt/widgets/common/src/FunctionTreeView.cpp +++ b/qt/widgets/common/src/FunctionTreeView.cpp @@ -47,6 +47,7 @@ #include <algorithm> #include <boost/lexical_cast.hpp> +#include <utility> namespace { const char *globalOptionName = "Global"; @@ -362,7 +363,8 @@ void FunctionTreeView::removeProperty(QtProperty *prop) { * @return :: A set AProperty struct */ FunctionTreeView::AProperty -FunctionTreeView::addFunctionProperty(QtProperty *parent, QString funName) { +FunctionTreeView::addFunctionProperty(QtProperty *parent, + const QString &funName) { // check that parent is a function property if (parent && dynamic_cast<QtAbstractPropertyManager *>(m_functionManager) != parent->propertyManager()) { @@ -379,9 +381,9 @@ FunctionTreeView::addFunctionProperty(QtProperty *parent, QString funName) { * @param paramDesc :: Parameter description * @param paramValue :: Parameter value */ -FunctionTreeView::AProperty -FunctionTreeView::addParameterProperty(QtProperty *parent, QString paramName, - QString paramDesc, double paramValue) { +FunctionTreeView::AProperty FunctionTreeView::addParameterProperty( + QtProperty *parent, const QString ¶mName, const QString ¶mDesc, + double paramValue) { // check that parent is a function property if (!parent || dynamic_cast<QtAbstractPropertyManager *>(m_functionManager) != parent->propertyManager()) { @@ -406,11 +408,11 @@ FunctionTreeView::addParameterProperty(QtProperty *parent, QString paramName, * @param fun :: A function */ void FunctionTreeView::setFunction(QtProperty *prop, - Mantid::API::IFunction_sptr fun) { + const Mantid::API::IFunction_sptr &fun) { auto children = prop->subProperties(); foreach (QtProperty *child, children) { removeProperty(child); } // m_localParameterValues.clear(); - addAttributeAndParameterProperties(prop, fun); + addAttributeAndParameterProperties(prop, std::move(fun)); } /** @@ -419,7 +421,7 @@ void FunctionTreeView::setFunction(QtProperty *prop, * @param fun :: A function to add */ bool FunctionTreeView::addFunction(QtProperty *prop, - Mantid::API::IFunction_sptr fun) { + const Mantid::API::IFunction_sptr &fun) { if (!fun) return false; if (!prop) { @@ -459,8 +461,8 @@ class CreateAttributePropertyForFunctionTreeView public: CreateAttributePropertyForFunctionTreeView(FunctionTreeView *browser, QtProperty *parent, - QString attName) - : m_browser(browser), m_parent(parent), m_attName(attName) { + const QString &attName) + : m_browser(browser), m_parent(parent), m_attName(std::move(attName)) { // check that parent is a function property if (!m_parent || dynamic_cast<QtAbstractPropertyManager *>( @@ -614,9 +616,10 @@ private: * @param att :: Attribute value */ FunctionTreeView::AProperty FunctionTreeView::addAttributeProperty( - QtProperty *parent, QString attName, + QtProperty *parent, const QString &attName, const Mantid::API::IFunction::Attribute &att) { - CreateAttributePropertyForFunctionTreeView cap(this, parent, attName); + CreateAttributePropertyForFunctionTreeView cap(this, parent, + std::move(attName)); return att.apply(cap); } @@ -628,7 +631,7 @@ FunctionTreeView::AProperty FunctionTreeView::addAttributeProperty( * @param fun :: Shared pointer to a created function */ void FunctionTreeView::addAttributeAndParameterProperties( - QtProperty *prop, Mantid::API::IFunction_sptr fun) { + QtProperty *prop, const Mantid::API::IFunction_sptr &fun) { // add the function index property addIndexProperty(prop); @@ -703,7 +706,8 @@ FunctionTreeView::addIndexProperty(QtProperty *prop) { * @param prop :: A function property * @param index :: The parent function's index */ -void FunctionTreeView::updateFunctionIndices(QtProperty *prop, QString index) { +void FunctionTreeView::updateFunctionIndices(QtProperty *prop, + const QString &index) { if (prop == nullptr) { auto top = m_browser->properties(); if (top.isEmpty()) @@ -896,14 +900,10 @@ QtProperty *FunctionTreeView::getFunctionProperty(const QString &index) const { * @param prop :: Parent parameter property * @param tie :: A tie string */ -void FunctionTreeView::addTieProperty(QtProperty *prop, QString tie) { +void FunctionTreeView::addTieProperty(QtProperty *prop, const QString &tie) { if (!prop) { throw std::runtime_error("FunctionTreeView: null property pointer"); } - AProperty ap; - ap.item = nullptr; - ap.prop = nullptr; - ap.parent = nullptr; if (!isParameter(prop)) return; @@ -914,7 +914,7 @@ void FunctionTreeView::addTieProperty(QtProperty *prop, QString tie) { m_tieManager->blockSignals(true); QtProperty *tieProp = m_tieManager->addProperty("Tie"); m_tieManager->setValue(tieProp, tie); - ap = addProperty(prop, tieProp); + addProperty(prop, tieProp); m_tieManager->blockSignals(false); const auto parName = getParameterName(prop); @@ -977,7 +977,7 @@ QString FunctionTreeView::getTie(QtProperty *prop) const { */ QList<FunctionTreeView::AProperty> FunctionTreeView::addConstraintProperties(QtProperty *prop, - QString constraint) { + const QString &constraint) { if (!isParameter(prop)) return QList<FunctionTreeView::AProperty>(); auto const parts = splitConstraintString(constraint); diff --git a/qt/widgets/common/src/HintingLineEdit.cpp b/qt/widgets/common/src/HintingLineEdit.cpp index 17267943b059819c52b906287f9abfa0bba2a1ac..0454039340b0f0c6c1c8f8eee4f30f15cc93d0ae 100644 --- a/qt/widgets/common/src/HintingLineEdit.cpp +++ b/qt/widgets/common/src/HintingLineEdit.cpp @@ -11,11 +11,12 @@ #include <QStyle> #include <QToolTip> #include <boost/algorithm/string.hpp> +#include <utility> namespace MantidQt { namespace MantidWidgets { HintingLineEdit::HintingLineEdit(QWidget *parent, std::vector<Hint> hints) - : QLineEdit(parent), m_hints(hints), m_dontComplete(false) { + : QLineEdit(parent), m_hints(std::move(hints)), m_dontComplete(false) { m_hintLabel = new QLabel(this, Qt::ToolTip); m_hintLabel->setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, diff --git a/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp b/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp index 2685c42720f9bf7da554070d7d7748b2c18d0e7b..4d6335bc43bf5677def7b96873967deae3ba075f 100644 --- a/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp +++ b/qt/widgets/common/src/IndirectFitPropertyBrowserLegacy.cpp @@ -211,8 +211,8 @@ IndirectFitPropertyBrowserLegacy::backgroundIndex() const { * @param function The function, whose function index to retrieve. * @return The function index of the specified function in the browser. */ -boost::optional<size_t> -IndirectFitPropertyBrowserLegacy::functionIndex(IFunction_sptr function) const { +boost::optional<size_t> IndirectFitPropertyBrowserLegacy::functionIndex( + const IFunction_sptr &function) const { for (size_t i = 0u; i < compositeFunction()->nFunctions(); ++i) { if (compositeFunction()->getFunction(i) == function) return i; @@ -344,7 +344,8 @@ void IndirectFitPropertyBrowserLegacy::setParameterValue( * @param value The value to set. */ void IndirectFitPropertyBrowserLegacy::setParameterValue( - IFunction_sptr function, const std::string ¶meterName, double value) { + const IFunction_sptr &function, const std::string ¶meterName, + double value) { if (function->hasParameter(parameterName)) { function->setParameter(parameterName, value); emit parameterChanged(function.get()); @@ -818,7 +819,7 @@ void IndirectFitPropertyBrowserLegacy::clearAllCustomFunctions() { * @param sampleWorkspace :: The workspace loaded as sample */ void IndirectFitPropertyBrowserLegacy::updatePlotGuess( - MatrixWorkspace_const_sptr sampleWorkspace) { + const MatrixWorkspace_const_sptr &sampleWorkspace) { if (sampleWorkspace && compositeFunction()->nFunctions() > 0) setPeakToolOn(true); else diff --git a/qt/widgets/common/src/InterfaceManager.cpp b/qt/widgets/common/src/InterfaceManager.cpp index 60da0c8b8c88e01df4e075c5adb1c3fcaaf1321d..e0c13a43397318707e0f068306c4f9e01c241ba9 100644 --- a/qt/widgets/common/src/InterfaceManager.cpp +++ b/qt/widgets/common/src/InterfaceManager.cpp @@ -74,7 +74,7 @@ Mantid::Kernel::AbstractInstantiator<MantidHelpInterface> * @returns An AlgorithmDialog object */ AlgorithmDialog *InterfaceManager::createDialog( - boost::shared_ptr<Mantid::API::IAlgorithm> alg, QWidget *parent, + const boost::shared_ptr<Mantid::API::IAlgorithm> &alg, QWidget *parent, bool forScript, const QHash<QString, QString> &presetValues, const QString &optionalMsg, const QStringList &enabled, const QStringList &disabled) { diff --git a/qt/widgets/common/src/LocalParameterEditor.cpp b/qt/widgets/common/src/LocalParameterEditor.cpp index 0546605e8d69b244eb28582e1d80a8d53201393c..c502f1c4a3b9ceb6823fafd421a37a931f0579df 100644 --- a/qt/widgets/common/src/LocalParameterEditor.cpp +++ b/qt/widgets/common/src/LocalParameterEditor.cpp @@ -16,6 +16,7 @@ #include <QLineEdit> #include <QMenu> #include <QPushButton> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -31,16 +32,14 @@ namespace MantidWidgets { /// @param allOthersFixed :: True if all other local parameters are fixed. /// @param othersTied :: True if there are other tied parameters. /// @param logOptionsEnabled :: True if the log checkbox is ticked. -LocalParameterEditor::LocalParameterEditor(QWidget *parent, int index, - double value, bool fixed, - QString tie, QString constraint, - bool othersFixed, - bool allOthersFixed, bool othersTied, - bool logOptionsEnabled) +LocalParameterEditor::LocalParameterEditor( + QWidget *parent, int index, double value, bool fixed, const QString &tie, + const QString &constraint, bool othersFixed, bool allOthersFixed, + bool othersTied, bool logOptionsEnabled) : QWidget(parent), m_index(index), m_value(QString::number(value, 'g', 16)), - m_fixed(fixed), m_tie(tie), m_constraint(constraint), - m_othersFixed(othersFixed), m_allOthersFixed(allOthersFixed), - m_othersTied(othersTied) { + m_fixed(fixed), m_tie(std::move(tie)), + m_constraint(std::move(constraint)), m_othersFixed(othersFixed), + m_allOthersFixed(allOthersFixed), m_othersTied(othersTied) { auto layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); @@ -312,7 +311,7 @@ void LocalParameterEditor::setEditorState() { } /// Open an input dialog to enter a tie expression. -QString LocalParameterEditor::setTieDialog(QString tie) { +QString LocalParameterEditor::setTieDialog(const QString &tie) { QInputDialog input; input.setWindowTitle("Set a tie."); input.setTextValue(tie); @@ -322,7 +321,7 @@ QString LocalParameterEditor::setTieDialog(QString tie) { return ""; } -QString LocalParameterEditor::setConstraintDialog(QString constraint) { +QString LocalParameterEditor::setConstraintDialog(const QString &constraint) { QInputDialog input; input.setWindowTitle("Set a constraint."); input.setTextValue(constraint); diff --git a/qt/widgets/common/src/MantidDialog.cpp b/qt/widgets/common/src/MantidDialog.cpp index 74a30e921740dd0853104fb22e87d02b1003d9b0..dd67a2f8c7d3a8f00d69435db2146bcb2926eec2 100644 --- a/qt/widgets/common/src/MantidDialog.cpp +++ b/qt/widgets/common/src/MantidDialog.cpp @@ -19,7 +19,7 @@ using namespace MantidQt::API; /** * Default Constructor */ -MantidDialog::MantidDialog(QWidget *parent, Qt::WindowFlags flags) +MantidDialog::MantidDialog(QWidget *parent, const Qt::WindowFlags &flags) : QDialog(parent, flags), m_pyRunner() { // re-emit the run Python code from m_pyRunner, to work this signal must reach // the slot in QtiPlot diff --git a/qt/widgets/common/src/MantidHelpWindow.cpp b/qt/widgets/common/src/MantidHelpWindow.cpp index b65427535ac25c6325a8f9b87d17259940ca1e32..cb0af5b2e49db68bb93bbee2d07ed9ecb921ab5d 100644 --- a/qt/widgets/common/src/MantidHelpWindow.cpp +++ b/qt/widgets/common/src/MantidHelpWindow.cpp @@ -65,7 +65,8 @@ const QString COLLECTION_FILE("MantidProject.qhc"); /** * Default constructor shows the @link DEFAULT_URL @endlink. */ -MantidHelpWindow::MantidHelpWindow(QWidget *parent, Qt::WindowFlags flags) +MantidHelpWindow::MantidHelpWindow(QWidget *parent, + const Qt::WindowFlags &flags) : MantidHelpInterface(), m_collectionFile(""), m_cacheFile(""), m_firstRun(true) { // find the collection and delete the cache file if this is the first run @@ -487,7 +488,7 @@ void MantidHelpWindow::determineFileLocs() { } } -void MantidHelpWindow::warning(QString msg) { +void MantidHelpWindow::warning(const QString &msg) { g_log.warning(msg.toStdString()); } diff --git a/qt/widgets/common/src/MantidTreeModel.cpp b/qt/widgets/common/src/MantidTreeModel.cpp index 9e9508d53b9e578980cf0b0012b7168753c0c2ed..f7dbee085936a1d1f9f38b9a87c6ebd223761704 100644 --- a/qt/widgets/common/src/MantidTreeModel.cpp +++ b/qt/widgets/common/src/MantidTreeModel.cpp @@ -121,8 +121,8 @@ void MantidTreeModel::showAlgorithmDialog(const QString &algName, * This creates an algorithm dialog (the default property entry thingie). * Helper function not required by interface */ -MantidQt::API::AlgorithmDialog * -MantidTreeModel::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { +MantidQt::API::AlgorithmDialog *MantidTreeModel::createAlgorithmDialog( + const Mantid::API::IAlgorithm_sptr &alg) { QHash<QString, QString> presets; QStringList enabled; diff --git a/qt/widgets/common/src/MantidTreeWidget.cpp b/qt/widgets/common/src/MantidTreeWidget.cpp index d94c406f99f8bcf3fb365bebcf51de3a0ea1f076..fa6c4d5a6f0e4e7906f73bc76f818ca1e7d1a1d5 100644 --- a/qt/widgets/common/src/MantidTreeWidget.cpp +++ b/qt/widgets/common/src/MantidTreeWidget.cpp @@ -37,7 +37,7 @@ MantidTreeWidget::MantidTreeWidget(MantidDisplayBase *mui, QWidget *parent) setSortOrder(Qt::AscendingOrder); setAcceptDrops(true); - m_doubleClickAction = [&](QString wsName) { + m_doubleClickAction = [&](const QString &wsName) { m_mantidUI->importWorkspace(wsName, false); }; } diff --git a/qt/widgets/common/src/MantidTreeWidgetItem.cpp b/qt/widgets/common/src/MantidTreeWidgetItem.cpp index 200faef424af6ec4fbb9650d870134a688ab5589..0381fcafdcde5130cbfe4dbc9dca25b3794b913c 100644 --- a/qt/widgets/common/src/MantidTreeWidgetItem.cpp +++ b/qt/widgets/common/src/MantidTreeWidgetItem.cpp @@ -25,7 +25,7 @@ MantidTreeWidgetItem::MantidTreeWidgetItem(MantidTreeWidget *parent) /**Constructor. * Must be passed its parent MantidTreeWidget, to facilitate correct sorting. */ -MantidTreeWidgetItem::MantidTreeWidgetItem(QStringList list, +MantidTreeWidgetItem::MantidTreeWidgetItem(const QStringList &list, MantidTreeWidget *parent) : QTreeWidgetItem(list), m_parent(parent), m_sortPos(0) {} diff --git a/qt/widgets/common/src/MantidWSIndexDialog.cpp b/qt/widgets/common/src/MantidWSIndexDialog.cpp index 77590e3268df805c6d1f2f3f1ccafcd961fdf5a5..b017b39fa43f09ad9296dd5d008d3d09951c0a25 100644 --- a/qt/widgets/common/src/MantidWSIndexDialog.cpp +++ b/qt/widgets/common/src/MantidWSIndexDialog.cpp @@ -20,6 +20,7 @@ #include <boost/lexical_cast.hpp> #include <cstdlib> #include <exception> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -48,7 +49,8 @@ const QString MantidWSIndexWidget::CONTOUR_PLOT = "Contour Plot"; * @param showTiledOption :: true if tiled plot enabled * @param isAdvanced :: true if advanced plotting has been selected */ -MantidWSIndexWidget::MantidWSIndexWidget(QWidget *parent, Qt::WindowFlags flags, +MantidWSIndexWidget::MantidWSIndexWidget(QWidget *parent, + const Qt::WindowFlags &flags, const QList<QString> &wsNames, const bool showWaterfallOption, const bool showTiledOption, @@ -830,12 +832,10 @@ bool MantidWSIndexWidget::usingSpectraNumbers() const { * @param showTiledOption :: If true the "Tiled" option is created * @param isAdvanced :: true if adanced plotting dialog is created */ -MantidWSIndexDialog::MantidWSIndexDialog(QWidget *parent, Qt::WindowFlags flags, - const QList<QString> &wsNames, - const bool showWaterfallOption, - const bool showPlotAll, - const bool showTiledOption, - const bool isAdvanced) +MantidWSIndexDialog::MantidWSIndexDialog( + QWidget *parent, const Qt::WindowFlags &flags, + const QList<QString> &wsNames, const bool showWaterfallOption, + const bool showPlotAll, const bool showTiledOption, const bool isAdvanced) : QDialog(parent, flags), m_widget(this, flags, wsNames, showWaterfallOption, showTiledOption, isAdvanced), @@ -973,7 +973,7 @@ Interval::Interval(int single) { init(single, single); } Interval::Interval(int start, int end) { init(start, end); } -Interval::Interval(QString intervalString) { +Interval::Interval(const QString &intervalString) { // Check to see if string is of the correct format, and then parse. // An interval can either be "n" or "n-m" where n and m are integers const QString patternSingle("^\\d+$"); // E.g. "2" or "712" @@ -1086,9 +1086,13 @@ void Interval::init(int start, int end) { //---------------------------------- IntervalList::IntervalList(void) {} -IntervalList::IntervalList(QString intervals) { addIntervals(intervals); } +IntervalList::IntervalList(const QString &intervals) { + addIntervals(std::move(intervals)); +} -IntervalList::IntervalList(Interval interval) { m_list.append(interval); } +IntervalList::IntervalList(const Interval &interval) { + m_list.append(interval); +} IntervalList::IntervalList(const IntervalList ©) { m_list = copy.m_list; } @@ -1350,7 +1354,8 @@ MantidWSIndexWidget::QLineEditWithErrorMark::QLineEditWithErrorMark( setLayout(layout); } -void MantidWSIndexWidget::QLineEditWithErrorMark::setError(QString error) { +void MantidWSIndexWidget::QLineEditWithErrorMark::setError( + const QString &error) { if (error.isEmpty()) { m_validLbl->setVisible(false); } else { diff --git a/qt/widgets/common/src/MdSettings.cpp b/qt/widgets/common/src/MdSettings.cpp index 3ae4ba778f6b30326586666818809c5bff774291..291db7c62ccb1616619c628f45d37251c16c3a19 100644 --- a/qt/widgets/common/src/MdSettings.cpp +++ b/qt/widgets/common/src/MdSettings.cpp @@ -47,7 +47,7 @@ QString MdSettings::getUserSettingColorMap() { return userSettingColorMap; } -void MdSettings::setUserSettingColorMap(QString colorMap) { +void MdSettings::setUserSettingColorMap(const QString &colorMap) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -66,7 +66,7 @@ QString MdSettings::getLastSessionColorMap() { return colormap; } -void MdSettings::setLastSessionColorMap(QString colorMap) { +void MdSettings::setLastSessionColorMap(const QString &colorMap) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -87,7 +87,7 @@ QColor MdSettings::getUserSettingBackgroundColor() { return backgroundColor; } -void MdSettings::setUserSettingBackgroundColor(QColor backgroundColor) { +void MdSettings::setUserSettingBackgroundColor(const QColor &backgroundColor) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -112,7 +112,7 @@ QColor MdSettings::getDefaultBackgroundColor() { return m_mdConstants.getDefaultBackgroundColor(); } -void MdSettings::setLastSessionBackgroundColor(QColor backgroundColor) { +void MdSettings::setLastSessionBackgroundColor(const QColor &backgroundColor) { QSettings settings; settings.beginGroup(m_vsiGroup); @@ -120,8 +120,8 @@ void MdSettings::setLastSessionBackgroundColor(QColor backgroundColor) { settings.endGroup(); } -void MdSettings::setGeneralMdColorMap(QString colorMapName, - QString colorMapFile) { +void MdSettings::setGeneralMdColorMap(const QString &colorMapName, + const QString &colorMapFile) { QSettings settings; settings.beginGroup(m_generalMdGroup); @@ -221,7 +221,7 @@ bool MdSettings::getLastSessionLogScale() { return logScale; } -void MdSettings::setUserSettingIntialView(QString initialView) { +void MdSettings::setUserSettingIntialView(const QString &initialView) { QSettings settings; settings.beginGroup(m_vsiGroup); diff --git a/qt/widgets/common/src/Message.cpp b/qt/widgets/common/src/Message.cpp index 21dda845f29d57f820c7e287571163961af2f51c..fe80bde54c025d63f19cd10cf90cfd2c36968076 100644 --- a/qt/widgets/common/src/Message.cpp +++ b/qt/widgets/common/src/Message.cpp @@ -7,6 +7,8 @@ //------------------------------------------- // Includes //------------------------------------------- +#include <utility> + #include "MantidQtWidgets/Common/Message.h" namespace MantidQt { @@ -28,8 +30,10 @@ Message::Message() * @param scriptPath The path of the script the message originated from. Empty * string if no script applicable */ -Message::Message(const QString &text, Priority priority, QString scriptPath) - : QObject(), m_text(text), m_priority(priority), m_scriptPath(scriptPath) {} +Message::Message(const QString &text, Priority priority, + const QString &scriptPath) + : QObject(), m_text(text), m_priority(priority), + m_scriptPath(std::move(scriptPath)) {} /** * @param text A std::string containing the message text @@ -37,9 +41,10 @@ Message::Message(const QString &text, Priority priority, QString scriptPath) * @param scriptPath The path of the script the message originated from. Empty * string if no script applicable */ -Message::Message(const std::string &text, Priority priority, QString scriptPath) +Message::Message(const std::string &text, Priority priority, + const QString &scriptPath) : QObject(), m_text(QString::fromStdString(text)), m_priority(priority), - m_scriptPath(scriptPath) {} + m_scriptPath(std::move(scriptPath)) {} /** * @param text A c-style string containing the message text @@ -47,8 +52,9 @@ Message::Message(const std::string &text, Priority priority, QString scriptPath) * @param scriptPath The path of the script the message originated from. Empty * string if no script applicable */ -Message::Message(const char *text, Priority priority, QString scriptPath) - : QObject(), m_text(text), m_priority(priority), m_scriptPath(scriptPath) {} +Message::Message(const char *text, Priority priority, const QString &scriptPath) + : QObject(), m_text(text), m_priority(priority), + m_scriptPath(std::move(scriptPath)) {} /** * Construct a message from another object diff --git a/qt/widgets/common/src/MuonFitPropertyBrowser.cpp b/qt/widgets/common/src/MuonFitPropertyBrowser.cpp index 48fe43dc82fdee4ee88873d169ba71b9ce521fc3..f4bb2caa3260259299a9b79b19962d30a28a2669 100644 --- a/qt/widgets/common/src/MuonFitPropertyBrowser.cpp +++ b/qt/widgets/common/src/MuonFitPropertyBrowser.cpp @@ -64,6 +64,7 @@ #include <QMessageBox> #include <QSignalMapper> #include <QTableWidgetItem> +#include <utility> namespace { Mantid::Kernel::Logger g_log("MuonFitPropertyBrowser"); @@ -514,7 +515,7 @@ void MuonFitPropertyBrowser::setNormalization() { * @param name :: the ws name to get normalization for * @returns the normalization */ -void MuonFitPropertyBrowser::setNormalization(const std::string name) { +void MuonFitPropertyBrowser::setNormalization(const std::string &name) { m_normalizationValue.clear(); QString label; auto norms = readMultipleNormalization(); @@ -891,7 +892,7 @@ bool MuonFitPropertyBrowser::isWorkspaceValid(Workspace_sptr ws) const { return dynamic_cast<MatrixWorkspace *>(ws.get()) != nullptr; } -void MuonFitPropertyBrowser::setFitWorkspaces(const std::string input) { +void MuonFitPropertyBrowser::setFitWorkspaces(const std::string &input) { // Copy experiment info to output workspace if (AnalysisDataService::Instance().doesExist(outputName() + "_Workspace")) { // Input workspace should be a MatrixWorkspace according to isWorkspaceValid @@ -1027,7 +1028,7 @@ void MuonFitPropertyBrowser::finishAfterSimultaneousFit( * @param baseName :: [input] The common name of the workspaces of interest */ void MuonFitPropertyBrowser::finishAfterTFSimultaneousFit( - const Mantid::API::IAlgorithm *alg, const std::string baseName) const { + const Mantid::API::IAlgorithm *alg, const std::string &baseName) const { AnalysisDataServiceImpl &ads = AnalysisDataService::Instance(); try { std::vector<std::string> wsList = @@ -1827,7 +1828,7 @@ void MuonFitPropertyBrowser::combineBtnPressed() { * selects the relevant group/pair * @param name :: string of the ws */ -void MuonFitPropertyBrowser::setSingleFitLabel(std::string name) { +void MuonFitPropertyBrowser::setSingleFitLabel(const std::string &name) { clearChosenGroups(); clearChosenPeriods(); std::vector<std::string> splitName; @@ -1898,7 +1899,7 @@ void MuonFitPropertyBrowser::setAllGroupsOrPairs(const bool isItGroup) { } void MuonFitPropertyBrowser::setGroupNames( std::vector<std::string> groupNames) { - m_groupsList = groupNames; + m_groupsList = std::move(groupNames); } void MuonFitPropertyBrowser::setTFAsymm(bool state) { m_boolManager->setValue(m_TFAsymmMode, state); diff --git a/qt/widgets/common/src/NonOrthogonal.cpp b/qt/widgets/common/src/NonOrthogonal.cpp index 01a5ab14b5f0ebd3ea4a05bf5f7c41ce45fb2fa7..7a5d216a9a8f15add575e5324ad15fa87fb06d9b 100644 --- a/qt/widgets/common/src/NonOrthogonal.cpp +++ b/qt/widgets/common/src/NonOrthogonal.cpp @@ -350,9 +350,9 @@ double getAngleInRadian(std::array<Mantid::coord_t, N> orthogonalVector, namespace MantidQt { namespace API { -size_t -getMissingHKLDimensionIndex(Mantid::API::IMDWorkspace_const_sptr workspace, - size_t dimX, size_t dimY) { +size_t getMissingHKLDimensionIndex( + const Mantid::API::IMDWorkspace_const_sptr &workspace, size_t dimX, + size_t dimY) { for (size_t i = 0; i < workspace->getNumDims(); ++i) { auto dimension = workspace->getDimension(i); const auto &frame = dimension->getMDFrame(); diff --git a/qt/widgets/common/src/PlotAxis.cpp b/qt/widgets/common/src/PlotAxis.cpp index a1ae86bcbd5799f6ec386cba0e50b7a3e27f269a..16ed2f1d3e6e8e256a7791a11985a50ecae0b40e 100644 --- a/qt/widgets/common/src/PlotAxis.cpp +++ b/qt/widgets/common/src/PlotAxis.cpp @@ -22,7 +22,7 @@ namespace { QString replacePerWithNegativeIndice(const std::string &label, const bool &plotAsDistribution, - const Mantid::Kernel::UnitLabel xLabel = "") { + const Mantid::Kernel::UnitLabel &xLabel = "") { std::vector<std::string> splitVec; QString negativeOnePower = toQStringInternal(L"\u207b\u00b9"); QString newLabel; diff --git a/qt/widgets/common/src/PluginLibraries.cpp b/qt/widgets/common/src/PluginLibraries.cpp index ae681c9b7971acf58b17559e2d776e7bb1675214..ef046a6cb87e9ac792fdbb3a5829e7a2dc37dd19 100644 --- a/qt/widgets/common/src/PluginLibraries.cpp +++ b/qt/widgets/common/src/PluginLibraries.cpp @@ -25,7 +25,7 @@ namespace API { * @param key The name of a key in the Mantid config * @return The value of the key */ -std::string qtPluginPathFromCfg(std::string key) { +std::string qtPluginPathFromCfg(const std::string &key) { static std::string qtMajorVersion; static std::string qtTag("%V"); if (qtMajorVersion.empty()) { @@ -42,7 +42,7 @@ std::string qtPluginPathFromCfg(std::string key) { * %V to specify the Qt version * @return The number of libraries successfully loaded */ -int loadPluginsFromCfgPath(std::string key) { +int loadPluginsFromCfgPath(const std::string &key) { return loadPluginsFromPath(qtPluginPathFromCfg(std::move(key))); } @@ -50,7 +50,7 @@ int loadPluginsFromCfgPath(std::string key) { * Load all plugins from the path specified. * @return The number of libraries successfully loaded */ -int loadPluginsFromPath(std::string path) { +int loadPluginsFromPath(const std::string &path) { // We must *NOT* load plugins compiled against a different version of Qt // so we set exclude flags by Qt version. #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) diff --git a/qt/widgets/common/src/ProcessingAlgoWidget.cpp b/qt/widgets/common/src/ProcessingAlgoWidget.cpp index 86a64dcd7d9c13d58281fbb7729d1a1aa49531fe..d0fb062f7d4e7abacbd60618ee2cefe099f0ebb0 100644 --- a/qt/widgets/common/src/ProcessingAlgoWidget.cpp +++ b/qt/widgets/common/src/ProcessingAlgoWidget.cpp @@ -164,7 +164,7 @@ void ProcessingAlgoWidget::setSelectedAlgorithm(QString algo) { /// @return the text in the script editor QString ProcessingAlgoWidget::getScriptText() { return ui.editor->text(); } /// Set the script editor text -void ProcessingAlgoWidget::setScriptText(QString text) { +void ProcessingAlgoWidget::setScriptText(const QString &text) { ui.editor->setText(text); } diff --git a/qt/widgets/common/src/ProjectSaveModel.cpp b/qt/widgets/common/src/ProjectSaveModel.cpp index 86b2a1fdb8bcd51a6ccf53240086903ae911d516..83b529b11d9c6b10949c649000dbac2c03b78d0f 100644 --- a/qt/widgets/common/src/ProjectSaveModel.cpp +++ b/qt/widgets/common/src/ProjectSaveModel.cpp @@ -24,7 +24,7 @@ using namespace MantidQt::MantidWidgets; * @param activePythonInterfaces The list of active Python interfaces */ ProjectSaveModel::ProjectSaveModel( - std::vector<IProjectSerialisable *> windows, + const std::vector<IProjectSerialisable *> &windows, std::vector<std::string> activePythonInterfaces) : m_activePythonInterfaces(std::move(activePythonInterfaces)) { auto workspaces = getWorkspaces(); @@ -204,8 +204,8 @@ std::vector<Workspace_sptr> ProjectSaveModel::getWorkspaces() const { return ads.getObjects(); } -WorkspaceInfo -ProjectSaveModel::makeWorkspaceInfoObject(Workspace_const_sptr ws) const { +WorkspaceInfo ProjectSaveModel::makeWorkspaceInfoObject( + const Workspace_const_sptr &ws) const { WorkspaceIcons icons; WorkspaceInfo info; info.name = ws->getName(); diff --git a/qt/widgets/common/src/PropertyHandler.cpp b/qt/widgets/common/src/PropertyHandler.cpp index d66dc9a77ba24ff442a5bfc83349b652da6bce28..ce324b420ede4370fb64718a760ca425fd601f16 100644 --- a/qt/widgets/common/src/PropertyHandler.cpp +++ b/qt/widgets/common/src/PropertyHandler.cpp @@ -26,6 +26,7 @@ #include "MantidQtWidgets/Common/QtPropertyBrowser/qttreepropertybrowser.h" #include <QMessageBox> +#include <utility> using std::size_t; @@ -33,16 +34,16 @@ namespace MantidQt { namespace MantidWidgets { // Constructor -PropertyHandler::PropertyHandler(Mantid::API::IFunction_sptr fun, +PropertyHandler::PropertyHandler(const Mantid::API::IFunction_sptr &fun, Mantid::API::CompositeFunction_sptr parent, FitPropertyBrowser *browser, QtBrowserItem *item) : FunctionHandler(fun), m_browser(browser), m_cf(boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(fun)), m_pf(boost::dynamic_pointer_cast<Mantid::API::IPeakFunction>(fun)), - m_parent(parent), m_type(nullptr), m_item(item), m_isMultispectral(false), - m_workspace(nullptr), m_workspaceIndex(nullptr), m_base(0), m_ci(0), - m_hasPlot(false) {} + m_parent(std::move(parent)), m_type(nullptr), m_item(item), + m_isMultispectral(false), m_workspace(nullptr), m_workspaceIndex(nullptr), + m_base(0), m_ci(0), m_hasPlot(false) {} /// Destructor PropertyHandler::~PropertyHandler() {} @@ -606,7 +607,7 @@ PropertyHandler *PropertyHandler::findHandler(QtProperty *prop) { } PropertyHandler * -PropertyHandler::findHandler(Mantid::API::IFunction_const_sptr fun) { +PropertyHandler::findHandler(const Mantid::API::IFunction_const_sptr &fun) { if (fun == function()) return this; if (m_cf) { @@ -1156,7 +1157,8 @@ void PropertyHandler::fix(const QString &parName) { * @param globalName :: Name of the parameter in compoite function * (e.g. f1.omega) */ -void PropertyHandler::removeTie(QtProperty *prop, std::string globalName) { +void PropertyHandler::removeTie(QtProperty *prop, + const std::string &globalName) { QString parName = m_ties.key(prop, ""); if (parName.isEmpty()) return; diff --git a/qt/widgets/common/src/QtJSONUtils.cpp b/qt/widgets/common/src/QtJSONUtils.cpp index 44e1821f07114023ea2fe5aac06d7c87d8cbc69d..ad1d4d972f14f2d471ca163202dee7d20887302c 100644 --- a/qt/widgets/common/src/QtJSONUtils.cpp +++ b/qt/widgets/common/src/QtJSONUtils.cpp @@ -58,7 +58,7 @@ public: return toString.call(obj).toString(); } - QMap<QString, QVariant> decodeInner(QScriptValue object) { + QMap<QString, QVariant> decodeInner(const QScriptValue &object) { QMap<QString, QVariant> map; QScriptValueIterator it(object); while (it.hasNext()) { @@ -79,7 +79,7 @@ public: return map; } - QList<QVariant> decodeInnerToList(QScriptValue arrayValue) { + QList<QVariant> decodeInnerToList(const QScriptValue &arrayValue) { QList<QVariant> list; QScriptValueIterator it(arrayValue); while (it.hasNext()) { diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp index bf89eb4fde6cc877dc10e35056ac6412ecf239a6..5d38e2237fa91442f937470c362504f6aae4bcb6 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp @@ -308,15 +308,12 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) { } else { WidgetItem *par = parentItem->parent; QGridLayout *l = nullptr; - int oldRow = -1; if (!par) { l = m_mainLayout; - oldRow = m_children.indexOf(parentItem); + m_children.indexOf(parentItem); } else { l = par->layout; - oldRow = par->children.indexOf(parentItem); - if (hasHeader(par)) - oldRow += 2; + par->children.indexOf(parentItem); } if (parentItem->widget) { diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp index b314504ea06de5f1080e340211f4b642715357b8..d36cf51256d44db9b6659fb9dd1a711fd7d52e90 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp @@ -461,7 +461,7 @@ void QtKeySequenceEdit::setKeySequence(const QKeySequence &sequence) { QKeySequence QtKeySequenceEdit::keySequence() const { return m_keySequence; } -int QtKeySequenceEdit::translateModifiers(Qt::KeyboardModifiers state, +int QtKeySequenceEdit::translateModifiers(const Qt::KeyboardModifiers &state, const QString &text) const { int result = 0; if ((state & Qt::ShiftModifier) && diff --git a/qt/widgets/common/src/SaveWorkspaces.cpp b/qt/widgets/common/src/SaveWorkspaces.cpp index b9b9a82511f542a9fe8e8a59bde0c82968373647..379f2712a6da7f1feb1293c9653feb39e5a3311a 100644 --- a/qt/widgets/common/src/SaveWorkspaces.cpp +++ b/qt/widgets/common/src/SaveWorkspaces.cpp @@ -482,7 +482,7 @@ SaveWorkspaces::provideZeroFreeWorkspaces(const QListWidget *workspaces) { * workspaces. */ void SaveWorkspaces::removeZeroFreeWorkspaces( - QHash<QString, QString> workspaces) { + const QHash<QString, QString> &workspaces) { auto zeroFreeWorkspaceNames = workspaces.values(); for (auto &zeroFreeWorkspaceName : zeroFreeWorkspaceNames) { emit deleteZeroErrorFreeWorkspace(zeroFreeWorkspaceName); diff --git a/qt/widgets/common/src/ScriptRepositoryView.cpp b/qt/widgets/common/src/ScriptRepositoryView.cpp index e9f39afc030f435f2fdb8e6c66b3aad7814fbadb..71d96520c2a4e71164c5bcf9e95006cf760195ce 100644 --- a/qt/widgets/common/src/ScriptRepositoryView.cpp +++ b/qt/widgets/common/src/ScriptRepositoryView.cpp @@ -360,7 +360,7 @@ void ScriptRepositoryView::RepoDelegate::paint( QApplication::style()->drawControl(QStyle::CE_PushButton, &button, painter); } -QIcon ScriptRepositoryView::RepoDelegate::getIcon(QString state) const { +QIcon ScriptRepositoryView::RepoDelegate::getIcon(const QString &state) const { QIcon icon; #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) if (state == RepoModel::remoteOnlySt()) @@ -646,7 +646,7 @@ bool ScriptRepositoryView::RemoveEntryDelegate::editorEvent( * * @param link :: the folder link to open. */ -void ScriptRepositoryView::openFolderLink(QString link) { +void ScriptRepositoryView::openFolderLink(const QString &link) { const std::string error_msg = "Unable to open \"" + link.toStdString() + "\". Reason: "; diff --git a/qt/widgets/common/src/SelectWorkspacesDialog.cpp b/qt/widgets/common/src/SelectWorkspacesDialog.cpp index 77c0465afe06ccd1efa1957ebe172b8e85d24902..1a3617b57b3fc4f41c80cb05bbf9d9b80b363f8b 100644 --- a/qt/widgets/common/src/SelectWorkspacesDialog.cpp +++ b/qt/widgets/common/src/SelectWorkspacesDialog.cpp @@ -32,7 +32,7 @@ private: public: explicit WorkspaceIsNotOfType(const std::string &type) : m_type(type), m_isMatrixWorkspace(type == "MatrixWorkspace") {} - bool operator()(Mantid::API::Workspace_sptr ws) const { + bool operator()(const Mantid::API::Workspace_sptr &ws) const { if (m_type.empty()) return false; if (m_isMatrixWorkspace) { diff --git a/qt/widgets/common/src/SequentialFitDialog.cpp b/qt/widgets/common/src/SequentialFitDialog.cpp index 3b3eb16fe4cd839c9d381be101bd742b99b014f3..e4db13d7fb551087fcb33b82b09333ada03113bf 100644 --- a/qt/widgets/common/src/SequentialFitDialog.cpp +++ b/qt/widgets/common/src/SequentialFitDialog.cpp @@ -88,7 +88,7 @@ void SequentialFitDialog::addWorkspace() { } } -bool SequentialFitDialog::addWorkspaces(const QStringList wsNames) { +bool SequentialFitDialog::addWorkspaces(const QStringList &wsNames) { if (wsNames.isEmpty()) return false; int row = ui.tWorkspaces->rowCount(); @@ -191,7 +191,7 @@ void SequentialFitDialog::removeItem() { } } -bool SequentialFitDialog::validateLogs(const QString wsName) { +bool SequentialFitDialog::validateLogs(const QString &wsName) { Mantid::API::MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( diff --git a/qt/widgets/common/src/SlicingAlgorithmDialog.cpp b/qt/widgets/common/src/SlicingAlgorithmDialog.cpp index 523f936469efe00030c723abd9e25ad89f83ee45..d55299da9b42dadc74ce89d70f8d09bd1ad905ef 100644 --- a/qt/widgets/common/src/SlicingAlgorithmDialog.cpp +++ b/qt/widgets/common/src/SlicingAlgorithmDialog.cpp @@ -102,8 +102,8 @@ SlicingAlgorithmDialog::~SlicingAlgorithmDialog() { saveSettings(); } dimension. @param dim : dimension to format to string. */ -QString -formattedAlignedDimensionInput(Mantid::Geometry::IMDDimension_const_sptr dim) { +QString formattedAlignedDimensionInput( + const Mantid::Geometry::IMDDimension_const_sptr &dim) { QString min, max, nbins, result; QString name(dim->getName().c_str()); min.setNum(dim->getMinimum()); @@ -133,7 +133,7 @@ formattedAlignedDimensionInput(Mantid::Geometry::IMDDimension_const_sptr dim) { @return : empty string. */ QString formatNonAlignedDimensionInput( - Mantid::Geometry::IMDDimension_const_sptr /*unused*/) { + const Mantid::Geometry::IMDDimension_const_sptr & /*unused*/) { // Deliberately return an empty string here, because it's not obvious how the // basis vectors could be automatically formed. return QString(""); @@ -288,7 +288,7 @@ generated. */ void SlicingAlgorithmDialog::makeDimensionInputs( const QString &propertyPrefix, QLayout *owningLayout, - QString (*format)(IMDDimension_const_sptr), History history) { + QString (*format)(const IMDDimension_const_sptr &), History history) { // Remove excess dimensions from the tied properties and the stored property // values size_t indexRemoved = 0; @@ -441,7 +441,7 @@ bool SlicingAlgorithmDialog::doAutoFillDimensions() const { *Customise the layout for usage in the Vsi */ void SlicingAlgorithmDialog::customiseLayoutForVsi( - std::string initialWorkspace) { + const std::string &initialWorkspace) { // File back-end ui.file_backend_layout->setVisible(false); @@ -466,8 +466,8 @@ void SlicingAlgorithmDialog::customiseLayoutForVsi( * @param index The property index. * @param propertyValue The new value of the axis dimension. */ -void SlicingAlgorithmDialog::resestAlignedDimProperty(size_t index, - QString propertyValue) { +void SlicingAlgorithmDialog::resestAlignedDimProperty( + size_t index, const QString &propertyValue) { QString alignedDim = "AlignedDim"; const QString propertyName = alignedDim.append(QString().number(index)); diff --git a/qt/widgets/common/src/SlitCalculator.cpp b/qt/widgets/common/src/SlitCalculator.cpp index 5b6b51b76cf25e7918b9bafb6d1143fb370b69cc..33b7e1d7703b36a46c560e02639542f71ae6d81b 100644 --- a/qt/widgets/common/src/SlitCalculator.cpp +++ b/qt/widgets/common/src/SlitCalculator.cpp @@ -32,7 +32,7 @@ void SlitCalculator::processInstrumentHasBeenChanged() { on_recalculate_triggered(); } SlitCalculator::~SlitCalculator() {} -void SlitCalculator::setInstrument(std::string instrumentName) { +void SlitCalculator::setInstrument(const std::string &instrumentName) { // we want to get the most up-to-date definition, so we use the current // date/time auto date = @@ -64,7 +64,7 @@ void SlitCalculator::setInstrument(std::string instrumentName) { void SlitCalculator::show() { QDialog::show(); } void SlitCalculator::setupSlitCalculatorWithInstrumentValues( - Mantid::Geometry::Instrument_const_sptr instrument) { + const Mantid::Geometry::Instrument_const_sptr &instrument) { // fetch the components that we need for values from IDF auto slit1Component = instrument->getComponentByName("slit1"); auto slit2Component = instrument->getComponentByName("slit2"); diff --git a/qt/widgets/common/src/TSVSerialiser.cpp b/qt/widgets/common/src/TSVSerialiser.cpp index fa34ed03c945e691b55e79986829a02068b5b970..240460e63a4db527a0cd900238b1f9daa196b0d1 100644 --- a/qt/widgets/common/src/TSVSerialiser.cpp +++ b/qt/widgets/common/src/TSVSerialiser.cpp @@ -325,7 +325,7 @@ QString TSVSerialiser::asQString(const size_t i) const { void TSVSerialiser::storeDouble(const double val) { m_output << "\t" << val; } void TSVSerialiser::storeInt(const int val) { m_output << "\t" << val; } -void TSVSerialiser::storeString(const std::string val) { +void TSVSerialiser::storeString(const std::string &val) { m_output << "\t" << val; } diff --git a/qt/widgets/common/src/UserInputValidator.cpp b/qt/widgets/common/src/UserInputValidator.cpp index 7572c5148db32dd3ea72bcb147b2a157a27b080a..c3b520b567eaebbfa8cbf6cab5bf08ea9ed019bf 100644 --- a/qt/widgets/common/src/UserInputValidator.cpp +++ b/qt/widgets/common/src/UserInputValidator.cpp @@ -33,7 +33,7 @@ bool doesExistInADS(std::string const &workspaceName) { } boost::optional<std::string> -containsInvalidWorkspace(WorkspaceGroup_const_sptr group) { +containsInvalidWorkspace(const WorkspaceGroup_const_sptr &group) { if (group->isEmpty()) return "The group workspace " + group->getName() + " is empty."; @@ -337,7 +337,7 @@ bool UserInputValidator::checkWorkspaceNumberOfHistograms( * @return True if the workspace has the correct size */ bool UserInputValidator::checkWorkspaceNumberOfHistograms( - MatrixWorkspace_sptr workspace, std::size_t const &validSize) { + const MatrixWorkspace_sptr &workspace, std::size_t const &validSize) { if (workspace->getNumberHistograms() != validSize) { addErrorMessage( QString::fromStdString(workspace->getName()) + " should contain " + @@ -370,7 +370,7 @@ bool UserInputValidator::checkWorkspaceNumberOfBins( * @return True if the workspace has the correct size */ bool UserInputValidator::checkWorkspaceNumberOfBins( - MatrixWorkspace_sptr workspace, std::size_t const &validSize) { + const MatrixWorkspace_sptr &workspace, std::size_t const &validSize) { if (workspace->x(0).size() != validSize) { addErrorMessage( QString::fromStdString(workspace->getName()) + " should contain " + diff --git a/qt/widgets/common/src/WorkspaceObserver.cpp b/qt/widgets/common/src/WorkspaceObserver.cpp index af54813cd84bed12672b6387133911f334892d4d..7d58b5b0b940b9a0a6d22b326b95318d4bf1bdc0 100644 --- a/qt/widgets/common/src/WorkspaceObserver.cpp +++ b/qt/widgets/common/src/WorkspaceObserver.cpp @@ -7,8 +7,10 @@ //----------------------------------- // Includes //----------------------------------- -#include "MantidQtWidgets/Common/WorkspaceObserver.h" +#include <utility> + #include "MantidAPI/AnalysisDataService.h" +#include "MantidQtWidgets/Common/WorkspaceObserver.h" namespace MantidQt { namespace API { @@ -18,7 +20,7 @@ namespace API { //--------------------------------------------------------------------------- void ObserverCallback::handlePreDelete(const std::string &name, Mantid::API::Workspace_sptr workspace) { - m_observer->preDeleteHandle(name, workspace); + m_observer->preDeleteHandle(name, std::move(workspace)); } void ObserverCallback::handlePostDelete(const std::string &name) { @@ -27,12 +29,12 @@ void ObserverCallback::handlePostDelete(const std::string &name) { void ObserverCallback::handleAdd(const std::string &name, Mantid::API::Workspace_sptr workspace) { - m_observer->addHandle(name, workspace); + m_observer->addHandle(name, std::move(workspace)); } void ObserverCallback::handleAfterReplace( const std::string &name, Mantid::API::Workspace_sptr workspace) { - m_observer->afterReplaceHandle(name, workspace); + m_observer->afterReplaceHandle(name, std::move(workspace)); } void ObserverCallback::handleRename(const std::string &oldName, diff --git a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp index 72baa7b8d2ce10050edf94a1a885222b41aa709a..cf9a9136fadeb80d9ccc2c034c32ceaaa148f6e5 100644 --- a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp +++ b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp @@ -883,7 +883,7 @@ MantidTreeWidgetItem *WorkspaceTreeWidget::addTreeEntry( * Check if a workspace should be selected after dock update. * @param name :: Name of a workspace to check. */ -bool WorkspaceTreeWidget::shouldBeSelected(QString name) const { +bool WorkspaceTreeWidget::shouldBeSelected(const QString &name) const { QMutexLocker lock(&m_mutex); QStringList renamed = m_renameMap.keys(name); if (!renamed.isEmpty()) { @@ -1114,7 +1114,7 @@ bool WorkspaceTreeWidget::hasUBMatrix(const std::string &wsName) { * ALGO_NAME * @param menuEntryName Text to be shown in menu */ -void WorkspaceTreeWidget::addSaveMenuOption(QString algorithmString, +void WorkspaceTreeWidget::addSaveMenuOption(const QString &algorithmString, QString menuEntryName) { // Default to algo string if no entry name given if (menuEntryName.isEmpty()) diff --git a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp index 151c0ce6d4aa1870b20c021202fd20bc26a01d78..b21c583f702abc7c7563a00bbcf50e5df5fdb8e0 100644 --- a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp +++ b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp @@ -45,7 +45,7 @@ WorkspaceTreeWidgetSimple::WorkspaceTreeWidgetSimple(bool viewOnly, m_showDetectors(new QAction("Show Detectors", this)) { // Replace the double click action on the MantidTreeWidget - m_tree->m_doubleClickAction = [&](QString wsName) { + m_tree->m_doubleClickAction = [&](const QString &wsName) { emit workspaceDoubleClicked(wsName); }; diff --git a/qt/widgets/common/src/WorkspaceSelector.cpp b/qt/widgets/common/src/WorkspaceSelector.cpp index 69d8f4ee05f7bcca9b31b42de716c2021b633468..d21f5d69936512fbb9f082064996be63e528e759 100644 --- a/qt/widgets/common/src/WorkspaceSelector.cpp +++ b/qt/widgets/common/src/WorkspaceSelector.cpp @@ -246,7 +246,7 @@ void WorkspaceSelector::handleReplaceEvent( } bool WorkspaceSelector::checkEligibility( - const QString &name, Mantid::API::Workspace_sptr object) const { + const QString &name, const Mantid::API::Workspace_sptr &object) const { if (m_algorithm && !m_algPropName.isEmpty()) { try { m_algorithm->setPropertyValue(m_algPropName.toStdString(), @@ -287,7 +287,7 @@ bool WorkspaceSelector::hasValidSuffix(const QString &name) const { } bool WorkspaceSelector::hasValidNumberOfBins( - Mantid::API::Workspace_sptr object) const { + const Mantid::API::Workspace_sptr &object) const { if (m_binLimits.first != 0 || m_binLimits.second != -1) { if (auto const workspace = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(object)) { diff --git a/qt/widgets/common/src/pqHelpWindow.cxx b/qt/widgets/common/src/pqHelpWindow.cxx index 3af9bb00463b4534a6b422a9844a05ddc3f457d3..6973caf08ef0e4eb619c027b5662f80b9ddb6254 100644 --- a/qt/widgets/common/src/pqHelpWindow.cxx +++ b/qt/widgets/common/src/pqHelpWindow.cxx @@ -224,7 +224,7 @@ private: //----------------------------------------------------------------------------- pqHelpWindow::pqHelpWindow(QHelpEngine *engine, QWidget *parentObject, - Qt::WindowFlags parentFlags) + const Qt::WindowFlags& parentFlags) : Superclass(parentObject, parentFlags), m_helpEngine(engine) { Q_ASSERT(engine != nullptr); // Take ownership of the engine diff --git a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h index 6d1e519ae89f0754733584f58c096af4782a1014..8bbea10b4e9a8b4be21c546d33ab796406c83781 100644 --- a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h +++ b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h @@ -9,6 +9,8 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <utility> + #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceGroup.h" @@ -432,7 +434,7 @@ private: // Expect the view's widgets to be set in a particular state according to // whether processing or not void expectUpdateViewState(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, bool isProcessing) { + const Cardinality &numTimes, bool isProcessing) { // Update menu items according to whether processing or not EXPECT_CALL(mockDataProcessorView, updateMenuEnabledState(isProcessing)) .Times(numTimes); @@ -451,18 +453,20 @@ private: // Expect the view's widgets to be set in the paused state void expectUpdateViewToPausedState(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { - expectUpdateViewState(mockDataProcessorView, numTimes, false); + const Cardinality &numTimes) { + expectUpdateViewState(mockDataProcessorView, std::move(numTimes), false); } // Expect the view's widgets to be set in the processing state void expectUpdateViewToProcessingState( - MockDataProcessorView &mockDataProcessorView, Cardinality numTimes) { - expectUpdateViewState(mockDataProcessorView, numTimes, true); + MockDataProcessorView &mockDataProcessorView, + const Cardinality &numTimes) { + expectUpdateViewState(mockDataProcessorView, std::move(numTimes), true); } void expectGetSelection(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, RowList rowlist = RowList(), + const Cardinality &numTimes, + RowList rowlist = RowList(), GroupList grouplist = GroupList()) { if (numTimes.IsSatisfiedByCallCount(0)) { @@ -472,16 +476,16 @@ private: } else { EXPECT_CALL(mockDataProcessorView, getSelectedChildren()) .Times(numTimes) - .WillRepeatedly(Return(rowlist)); + .WillRepeatedly(Return(std::move(rowlist))); EXPECT_CALL(mockDataProcessorView, getSelectedParents()) .Times(numTimes) - .WillRepeatedly(Return(grouplist)); + .WillRepeatedly(Return(std::move(grouplist))); } } void expectGetOptions(MockMainPresenter &mockMainPresenter, - Cardinality numTimes, - std::string postprocessingOptions = "") { + const Cardinality &numTimes, + const std::string &postprocessingOptions = "") { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value EXPECT_CALL(mockMainPresenter, getPreprocessingOptions()).Times(numTimes); @@ -503,7 +507,7 @@ private: } void expectNotebookIsDisabled(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { + const Cardinality &numTimes) { // Call to check whether the notebook is enabled if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -519,7 +523,7 @@ private: } void expectNotebookIsEnabled(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { + const Cardinality &numTimes) { // Call to check whether the notebook is enabled if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -535,7 +539,8 @@ private: } void expectGetWorkspace(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, const char *workspaceName) { + const Cardinality &numTimes, + const char *workspaceName) { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value EXPECT_CALL(mockDataProcessorView, getWorkspaceToOpen()).Times(numTimes); @@ -547,7 +552,7 @@ private: } void expectAskUserWorkspaceName(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, + const Cardinality &numTimes, const char *workspaceName = "") { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -563,7 +568,8 @@ private: } void expectAskUserYesNo(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes, const bool answer = false) { + const Cardinality &numTimes, + const bool answer = false) { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value @@ -581,7 +587,7 @@ private: } void expectInstrumentIsINTER(MockDataProcessorView &mockDataProcessorView, - Cardinality numTimes) { + const Cardinality &numTimes) { if (numTimes.IsSatisfiedByCallCount(0)) { // If 0 calls, don't check return value EXPECT_CALL(mockDataProcessorView, getProcessInstrument()) @@ -607,12 +613,13 @@ private: "IvsQ_TOF_12345", "IvsQ_binned_TOF_12346", "IvsQ_TOF_12346", "IvsQ_TOF_12345_TOF_12346"}; - void checkWorkspacesExistInADS(std::vector<std::string> workspaceNames) { + void + checkWorkspacesExistInADS(const std::vector<std::string> &workspaceNames) { for (auto &ws : workspaceNames) TS_ASSERT(AnalysisDataService::Instance().doesExist(ws)); } - void removeWorkspacesFromADS(std::vector<std::string> workspaceNames) { + void removeWorkspacesFromADS(const std::vector<std::string> &workspaceNames) { for (auto &ws : workspaceNames) AnalysisDataService::Instance().remove(ws); } diff --git a/qt/widgets/common/test/MWRunFilesTest.py b/qt/widgets/common/test/MWRunFilesTest.py index f01d47e254d37de0235e48670650efd87b2f12d9..ee9e01e74998b59288e08a8e527c31261a1a056b 100644 --- a/qt/widgets/common/test/MWRunFilesTest.py +++ b/qt/widgets/common/test/MWRunFilesTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import sys import unittest from PyQt4 import QtCore, QtGui diff --git a/qt/widgets/common/test/ProjectSaveModelTest.h b/qt/widgets/common/test/ProjectSaveModelTest.h index 31977d77ce3380a3d119d0cf3919af165d4925b5..9489c88aced403f84adc23f78969dbfa8271ffdf 100644 --- a/qt/widgets/common/test/ProjectSaveModelTest.h +++ b/qt/widgets/common/test/ProjectSaveModelTest.h @@ -17,6 +17,8 @@ #include <cxxtest/TestSuite.h> #include <gmock/gmock.h> +#include <utility> + using namespace MantidQt::API; using namespace MantidQt::MantidWidgets; using namespace testing; @@ -28,17 +30,18 @@ GNU_DIAG_OFF_SUGGEST_OVERRIDE class MockProjectSaveModel : public ProjectSaveModel { public: MockProjectSaveModel( - std::vector<MantidQt::API::IProjectSerialisable *> windows, + const std::vector<MantidQt::API::IProjectSerialisable *> &windows, std::vector<std::string> activePythonInterfaces = std::vector<std::string>()) - : ProjectSaveModel(windows, activePythonInterfaces) {} + : ProjectSaveModel(std::move(windows), + std::move(activePythonInterfaces)) {} MOCK_METHOD1(getProjectSize, size_t(const std::vector<std::string> &wsNames)); }; GNU_DIAG_ON_SUGGEST_OVERRIDE namespace { -size_t calculateSize(std::vector<Workspace_sptr> workspaces) { +size_t calculateSize(const std::vector<Workspace_sptr> &workspaces) { size_t result = 0; for (const auto &ws : workspaces) { result += ws->getMemorySize(); diff --git a/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h b/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h index ce64cbfef79f482a5af7c7a249b03695cba5cdba..916adb5874e612fc6e7e7075a2314394df85d5af 100644 --- a/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h +++ b/qt/widgets/common/test/WorkspacePresenter/WorkspacePresenterTest.h @@ -657,7 +657,7 @@ private: boost::shared_ptr<NiceMock<MockWorkspaceDockView>> mockView; WorkspacePresenterVN_sptr presenter; - void createGroup(std::string groupName) { + void createGroup(const std::string &groupName) { auto group = WorkspaceCreationHelper::createWorkspaceGroup(0, 10, 10, groupName); auto wksp1 = WorkspaceCreationHelper::create2DWorkspace(10, 10); @@ -669,7 +669,7 @@ private: AnalysisDataService::Instance().addToGroup(groupName, "wksp2"); } - void removeGroup(std::string groupName) { + void removeGroup(const std::string &groupName) { AnalysisDataService::Instance().deepRemoveGroup(groupName); } }; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h index dd8c977526fdec0ef31d79c124feec9dcfdecac5..12f95b9866f86c07bfd5ce3ed37bc44c86fe353e 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h @@ -216,9 +216,10 @@ signals: void colorMapChanged() const; private: - void setUpWorkspace( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> sharedWorkspace, - double scaleMin, double scaleMax); + void + setUpWorkspace(const boost::shared_ptr<const Mantid::API::MatrixWorkspace> + &sharedWorkspace, + double scaleMin, double scaleMax); void setupPhysicalInstrumentIfExists(); void resetColors(); void loadSettings(); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h index eb0f5f9c17b29de73e1f0fe2cde91cd7cc88e059..20a66988fdde9c2119298d806bcbe97ad046f78c 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h @@ -39,7 +39,7 @@ public: QStringList findExpandedComponents(const QModelIndex &parent = QModelIndex()) const; public slots: - void sendComponentSelectedSignal(const QModelIndex /*index*/); + void sendComponentSelectedSignal(const QModelIndex & /*index*/); signals: void componentSelected(size_t /*_t1*/); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h index 33e697c4735d00ebac6c85a4cd6e4a39f284a90c..1592f4fcd6f8889ab820e781b4b2852200a59d27 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h @@ -117,7 +117,7 @@ public: /// Recalculate the detector data and redraw the instrument view void updateInstrumentDetectors(); /// Delete the peaks workspace. - void deletePeaksWorkspace(Mantid::API::IPeaksWorkspace_sptr pws); + void deletePeaksWorkspace(const Mantid::API::IPeaksWorkspace_sptr &pws); /// Alter data from a script. These just foward calls to the 3D widget void setColorMapMinValue(double minValue); @@ -148,7 +148,7 @@ public: bool hasWorkspace(const std::string &wsName) const; void handleWorkspaceReplacement( const std::string &wsName, - const boost::shared_ptr<Mantid::API::Workspace> workspace); + const boost::shared_ptr<Mantid::API::Workspace> &workspace); /// Get the currently selected tab index int getCurrentTab() const; @@ -193,7 +193,7 @@ public slots: void tabChanged(int /*unused*/); void componentSelected(size_t componentIndex); void executeAlgorithm(const QString & /*unused*/, const QString & /*unused*/); - void executeAlgorithm(Mantid::API::IAlgorithm_sptr /*alg*/); + void executeAlgorithm(const Mantid::API::IAlgorithm_sptr & /*alg*/); void setupColorMap(); @@ -325,11 +325,11 @@ private: const std::string &newName) override; void clearADSHandle() override; /// overlay a peaks workspace on the projection surface - void overlayPeaksWorkspace(Mantid::API::IPeaksWorkspace_sptr ws); + void overlayPeaksWorkspace(const Mantid::API::IPeaksWorkspace_sptr &ws); /// overlay a masked workspace on the projection surface - void overlayMaskedWorkspace(Mantid::API::IMaskWorkspace_sptr ws); + void overlayMaskedWorkspace(const Mantid::API::IMaskWorkspace_sptr &ws); /// overlay a table workspace with shape parameters on the projection surface - void overlayShapesWorkspace(Mantid::API::ITableWorkspace_sptr /*ws*/); + void overlayShapesWorkspace(const Mantid::API::ITableWorkspace_sptr & /*ws*/); /// get a workspace from the ADS Mantid::API::Workspace_sptr getWorkspaceFromADS(const std::string &name); /// get a handle to the unwrapped surface diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h index e5f9794f2b97db54017bcb63f94b610454197611..fc2dce20e2753ae9a7743e13aacf7d645d76a119 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h @@ -71,7 +71,7 @@ public slots: void changeColorMap(const QString &filename = ""); void setSurfaceType(int /*index*/); void flipUnwrappedView(bool /*on*/); - void saveImage(QString filename = ""); + void saveImage(const QString &filename = ""); private slots: diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h index 19216c20d91f5199173f569bcd82264537b42f67..049049a3fbc7d0f4130aa8e6aca9e40e952ff3a5 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h @@ -30,7 +30,7 @@ public: void setSurface(boost::shared_ptr<ProjectionSurface> surface); boost::shared_ptr<ProjectionSurface> getSurface() { return m_surface; } - void setBackgroundColor(QColor /*input*/); + void setBackgroundColor(const QColor & /*input*/); QColor currentBackgroundColor() const; void saveToFile(const QString &filename); // int getLightingState() const {return m_lightingState;} diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h index 36265b569ee78776ce6f7b330412d640bd6ea347..5935ef11dc24dae69397c4f62e1813dd7b3a7def 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakMarker2D.h @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #pragma once +#include <utility> + #include "MantidGeometry/Crystal/IPeak.h" #include "Shape2D.h" @@ -23,8 +25,9 @@ class PeakMarker2D : public Shape2D { public: enum Symbol { Circle = 0, Diamond, Square }; struct Style { - Style(Symbol sb = Circle, QColor c = Qt::red, int sz = g_defaultMarkerSize) - : symbol(sb), color(c), size(sz) {} + Style(Symbol sb = Circle, const QColor &c = Qt::red, + int sz = g_defaultMarkerSize) + : symbol(sb), color(std::move(c)), size(sz) {} Symbol symbol; QColor color; int size; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h index d3f4595fdacaf42525eb46ec8b71b05eb7c68d6b..134d4f8eb1cc340c76204336c73f838e60531dce 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h @@ -122,7 +122,7 @@ class PeakOverlay : public Shape2DCollection, Q_OBJECT public: PeakOverlay(UnwrappedSurface *surface, - boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws); + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws); ~PeakOverlay() override {} /// Override the drawing method void draw(QPainter &painter) const override; @@ -146,7 +146,7 @@ public: void setShowLabelsFlag(bool yes) { m_showLabels = yes; } void setShowRelativeIntensityFlag(bool yes); static PeakMarker2D::Style getDefaultStyle(int index); - void setPeakVisibility(double xmin, double xmax, QString units); + void setPeakVisibility(double xmin, double xmax, const QString &units); signals: void executeAlgorithm(Mantid::API::IAlgorithm_sptr /*_t1*/); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h index 3084622be38b21fc4c1add2ea75184d007a9c8dd..d3f799633cf97ec2f18eadcf71bb6b544116c489 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneModel.h @@ -19,7 +19,7 @@ class PlotFitAnalysisPaneModel { public: IFunction_sptr doFit(const std::string &wsName, const std::pair<double, double> &range, - const IFunction_sptr func); + const IFunction_sptr &func); }; } // namespace MantidWidgets diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h index 51db83e9ceb1e1c8c12e1398cfe6f7d28177af01..63764ebde7ee1ee02cf07eaef2e518a41f57e547 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PlotFitAnalysisPaneView.h @@ -35,10 +35,10 @@ public: }; std::pair<double, double> getRange(); Mantid::API::IFunction_sptr getFunction(); - void addSpectrum(std::string wsName); - void addFitSpectrum(std::string wsName); + void addSpectrum(const std::string &wsName); + void addFitSpectrum(const std::string &wsName); void addFunction(Mantid::API::IFunction_sptr func); - void updateFunction(Mantid::API::IFunction_sptr func); + void updateFunction(const Mantid::API::IFunction_sptr &func); void fitWarning(const std::string &message); public slots: diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h index 4d13f8079d6a4350c98055dd122918904f6e23d4..3e557dc36d092b1384fc4b9a574e141056e360b6 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h @@ -235,7 +235,8 @@ public: /// Save masks to a table workspace void saveShapesToTableWorkspace(); /// Load masks from a table workspace - void loadShapesFromTableWorkspace(Mantid::API::ITableWorkspace_const_sptr ws); + void loadShapesFromTableWorkspace( + const Mantid::API::ITableWorkspace_const_sptr &ws); //----------------------------------- // Peaks overlay methods @@ -244,7 +245,8 @@ public: QList<PeakMarker2D *> getMarkersWithID(int detID) const; boost::shared_ptr<Mantid::API::IPeaksWorkspace> getEditPeaksWorkspace() const; QStringList getPeaksWorkspaceNames() const; - void deletePeaksWorkspace(boost::shared_ptr<Mantid::API::IPeaksWorkspace> ws); + void deletePeaksWorkspace( + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &ws); void clearPeakOverlays(); void clearAlignmentPlane(); void clearComparisonPeaks(); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h index eefdd65ed15d0145bbe77afdd1991d5b5a835abe..4546c0b021a7348d1004bc61158e21bd4b870dfd 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h @@ -96,7 +96,8 @@ public: /// Save shape collection to a Table workspace void saveToTableWorkspace(); /// Load shape collectio from a Table workspace - void loadFromTableWorkspace(Mantid::API::ITableWorkspace_const_sptr ws); + void + loadFromTableWorkspace(const Mantid::API::ITableWorkspace_const_sptr &ws); /// Load settings for the shape 2D collection from a project file virtual void loadFromProject(const std::string &lines); /// Save settings for the shape 2D collection to a project file diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h index 28a33c3632a71701112cee74c18295858c5fdd46..9a35771d759efc6600d428d6b20e81a7fa039db5 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h @@ -34,7 +34,7 @@ This class keeps information used to draw a detector on an unwrapped surface. class UnwrappedDetector { public: UnwrappedDetector(); - UnwrappedDetector(GLColor color, size_t detIndex); + UnwrappedDetector(const GLColor &color, size_t detIndex); UnwrappedDetector(const UnwrappedDetector &other); UnwrappedDetector &operator=(const UnwrappedDetector &other); bool empty() const; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h index 84a3d5934d3d3701a71dc33eaae81b93cfd6cc62..44b56e70a32d17b31f17794d7fbc0b89da960c29 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h @@ -67,7 +67,8 @@ public: void componentSelected(size_t componentIndex) override; void getSelectedDetectors(std::vector<size_t> &detIndices) override; void getMaskedDetectors(std::vector<size_t> &detIndices) const override; - void setPeaksWorkspace(boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws); + void + setPeaksWorkspace(const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws); QString getInfoText() const override; RectF getSurfaceBounds() const override; //@} diff --git a/qt/widgets/instrumentview/src/InstrumentActor.cpp b/qt/widgets/instrumentview/src/InstrumentActor.cpp index 43de0c06ec5986acd7fd59f0b3818acc8418f59b..b82e897367471665aac3f858cb5f9a8e18518a3e 100644 --- a/qt/widgets/instrumentview/src/InstrumentActor.cpp +++ b/qt/widgets/instrumentview/src/InstrumentActor.cpp @@ -38,6 +38,7 @@ #include <limits> #include <numeric> +#include <utility> using namespace Mantid::Kernel::Exception; using namespace Mantid::Geometry; @@ -140,7 +141,8 @@ InstrumentActor::~InstrumentActor() { saveSettings(); } * value is ignored. */ void InstrumentActor::setUpWorkspace( - boost::shared_ptr<const Mantid::API::MatrixWorkspace> sharedWorkspace, + const boost::shared_ptr<const Mantid::API::MatrixWorkspace> + &sharedWorkspace, double scaleMin, double scaleMax) { m_WkspBinMinValue = DBL_MAX; m_WkspBinMaxValue = -DBL_MAX; @@ -257,7 +259,7 @@ MatrixWorkspace_sptr InstrumentActor::getMaskMatrixWorkspace() const { */ void InstrumentActor::setMaskMatrixWorkspace( MatrixWorkspace_sptr wsMask) const { - m_maskWorkspace = wsMask; + m_maskWorkspace = std::move(wsMask); } void InstrumentActor::invertMaskWorkspace() const { diff --git a/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp b/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp index 5809d78c549f031833cc4e87488b20991dc175b0..558c6dbce2f4ee9cf6508c91bc0d50310711aae9 100644 --- a/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp +++ b/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp @@ -70,7 +70,7 @@ InstrumentTreeWidget::findComponentByName(const QString &name) const { } void InstrumentTreeWidget::sendComponentSelectedSignal( - const QModelIndex index) { + const QModelIndex &index) { auto selectedIndex = InstrumentTreeModel::extractIndex(index); m_instrWidget->getInstrumentActor().setComponentVisible(selectedIndex); emit componentSelected(selectedIndex); diff --git a/qt/widgets/instrumentview/src/InstrumentWidget.cpp b/qt/widgets/instrumentview/src/InstrumentWidget.cpp index a2b103af25cf47a33550dbbb4f71a25df2686c99..dd0dab3d9d22dd4e61aaee6ee57f9deaedb2ef88 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidget.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidget.cpp @@ -65,6 +65,7 @@ #include <numeric> #include <stdexcept> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -893,7 +894,8 @@ void InstrumentWidget::executeAlgorithm(const QString & /*unused*/, // emit execMantidAlgorithm(alg_name, param_list, this); } -void InstrumentWidget::executeAlgorithm(Mantid::API::IAlgorithm_sptr alg) { +void InstrumentWidget::executeAlgorithm( + const Mantid::API::IAlgorithm_sptr &alg) { try { alg->executeAsync(); } catch (Poco::NoThreadAvailableException &) { @@ -1184,8 +1186,8 @@ void InstrumentWidget::updateInstrumentDetectors() { } void InstrumentWidget::deletePeaksWorkspace( - Mantid::API::IPeaksWorkspace_sptr pws) { - this->getSurface()->deletePeaksWorkspace(pws); + const Mantid::API::IPeaksWorkspace_sptr &pws) { + this->getSurface()->deletePeaksWorkspace(std::move(pws)); updateInstrumentView(); } @@ -1336,7 +1338,7 @@ bool InstrumentWidget::hasWorkspace(const std::string &wsName) const { } void InstrumentWidget::handleWorkspaceReplacement( - const std::string &wsName, const boost::shared_ptr<Workspace> workspace) { + const std::string &wsName, const boost::shared_ptr<Workspace> &workspace) { if (!hasWorkspace(wsName) || !m_instrumentActor) { return; } @@ -1400,10 +1402,10 @@ void InstrumentWidget::clearADSHandle() { * Overlay a peaks workspace on the surface projection * @param ws :: peaks workspace to overlay */ -void InstrumentWidget::overlayPeaksWorkspace(IPeaksWorkspace_sptr ws) { +void InstrumentWidget::overlayPeaksWorkspace(const IPeaksWorkspace_sptr &ws) { auto surface = getUnwrappedSurface(); if (surface) { - surface->setPeaksWorkspace(ws); + surface->setPeaksWorkspace(std::move(ws)); updateInstrumentView(); } } @@ -1412,7 +1414,7 @@ void InstrumentWidget::overlayPeaksWorkspace(IPeaksWorkspace_sptr ws) { * Overlay a mask workspace on the surface projection * @param ws :: mask workspace to overlay */ -void InstrumentWidget::overlayMaskedWorkspace(IMaskWorkspace_sptr ws) { +void InstrumentWidget::overlayMaskedWorkspace(const IMaskWorkspace_sptr &ws) { auto &actor = getInstrumentActor(); actor.setMaskMatrixWorkspace( boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws)); @@ -1425,7 +1427,7 @@ void InstrumentWidget::overlayMaskedWorkspace(IMaskWorkspace_sptr ws) { * Overlay a table workspace containing shape parameters * @param ws :: a workspace of shape parameters to create */ -void InstrumentWidget::overlayShapesWorkspace(ITableWorkspace_sptr ws) { +void InstrumentWidget::overlayShapesWorkspace(const ITableWorkspace_sptr &ws) { auto surface = getUnwrappedSurface(); if (surface) { surface->loadShapesFromTableWorkspace(ws); diff --git a/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp b/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp index 6b212df0eb02e6bd7e5c1d145f73a5bc2b5b2ca9..1709377cd178b4a70976839ceb357bebd7c59e08 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp @@ -35,6 +35,7 @@ #include "MantidQtWidgets/InstrumentView/InstrumentWidget.h" #include <limits> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -610,8 +611,8 @@ void InstrumentWidgetRenderTab::flipUnwrappedView(bool on) { * for finding the file * @param filename Optional full path of the saved image */ -void InstrumentWidgetRenderTab::saveImage(QString filename) { - m_instrWidget->saveImage(filename); +void InstrumentWidgetRenderTab::saveImage(const QString &filename) { + m_instrWidget->saveImage(std::move(filename)); } /** diff --git a/qt/widgets/instrumentview/src/MantidGLWidget.cpp b/qt/widgets/instrumentview/src/MantidGLWidget.cpp index de77556d24a27ee2b0399e6d260d905d069a857e..227fe14cefcb06d50720106c6e07661bb3273523 100644 --- a/qt/widgets/instrumentview/src/MantidGLWidget.cpp +++ b/qt/widgets/instrumentview/src/MantidGLWidget.cpp @@ -23,6 +23,7 @@ #include <map> #include <string> #include <typeinfo> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -57,7 +58,7 @@ MantidGLWidget::MantidGLWidget(QWidget *parent) MantidGLWidget::~MantidGLWidget() {} void MantidGLWidget::setSurface(boost::shared_ptr<ProjectionSurface> surface) { - m_surface = surface; + m_surface = std::move(surface); connect(m_surface.get(), SIGNAL(redrawRequired()), this, SLOT(repaint()), Qt::QueuedConnection); m_firstFrame = true; @@ -227,7 +228,7 @@ void MantidGLWidget::keyReleaseEvent(QKeyEvent *event) { /** * This method set the background color. */ -void MantidGLWidget::setBackgroundColor(QColor input) { +void MantidGLWidget::setBackgroundColor(const QColor &input) { makeCurrent(); glClearColor(GLclampf(input.red() / 255.0), GLclampf(input.green() / 255.0), GLclampf(input.blue() / 255.0), 1.0); diff --git a/qt/widgets/instrumentview/src/MiniPlotMpl.cpp b/qt/widgets/instrumentview/src/MiniPlotMpl.cpp index 4ecdb1aea4397e76927953e0167e4b8836e2276a..1a721c83a084edeffff3e5c0be6cd5902733fe66 100644 --- a/qt/widgets/instrumentview/src/MiniPlotMpl.cpp +++ b/qt/widgets/instrumentview/src/MiniPlotMpl.cpp @@ -20,6 +20,7 @@ #include <QPushButton> #include <QSpacerItem> #include <QVBoxLayout> +#include <utility> using Mantid::PythonInterface::GlobalInterpreterLock; using MantidQt::Widgets::MplCpp::cycler; @@ -116,7 +117,7 @@ void MiniPlotMpl::setData(std::vector<double> x, std::vector<double> y, // plot automatically calls "scalex=True, scaley=True" m_lines.emplace_back( axes.plot(std::move(x), std::move(y), ACTIVE_CURVE_FORMAT)); - m_activeCurveLabel = curveLabel; + m_activeCurveLabel = std::move(curveLabel); setXLabel(std::move(xunit)); // If the current axis limits can fit the data then matplotlib // won't change the axis scale. If the intensity of different plots diff --git a/qt/widgets/instrumentview/src/MiniPlotQwt.cpp b/qt/widgets/instrumentview/src/MiniPlotQwt.cpp index f8d5806e4dc551caf1e86e82525d88975c12fe25..8283466913532d29b23805efbdc63ca8a03dca18 100644 --- a/qt/widgets/instrumentview/src/MiniPlotQwt.cpp +++ b/qt/widgets/instrumentview/src/MiniPlotQwt.cpp @@ -24,6 +24,7 @@ #include <QPainter> #include <cmath> +#include <utility> namespace { Mantid::Kernel::Logger g_log("MiniPlotQwt"); @@ -72,7 +73,7 @@ MiniPlotQwt::~MiniPlotQwt() { clearAll(); } * @param xunit */ void MiniPlotQwt::setXLabel(QString xunit) { - m_xUnits = xunit; + m_xUnits = std::move(xunit); this->setAxisTitle(xBottom, m_xUnits); } @@ -238,8 +239,8 @@ void MiniPlotQwt::setData(std::vector<double> x, std::vector<double> y, return; } - m_xUnits = xunit; - m_label = curveLabel; + m_xUnits = std::move(xunit); + m_label = std::move(curveLabel); if (!m_curve) { m_curve = new QwtPlotCurve(); m_curve->attach(this); diff --git a/qt/widgets/instrumentview/src/PeakOverlay.cpp b/qt/widgets/instrumentview/src/PeakOverlay.cpp index 05ef068ed7b82e79f352eb3d3f30c7400ddb0da3..9311990a846b82475f2c5f48bf73f88830c9bffd 100644 --- a/qt/widgets/instrumentview/src/PeakOverlay.cpp +++ b/qt/widgets/instrumentview/src/PeakOverlay.cpp @@ -176,8 +176,9 @@ int QualitativeIntensityScale::getIntensityLevel(double intensity) const { /**--------------------------------------------------------------------- * Constructor */ -PeakOverlay::PeakOverlay(UnwrappedSurface *surface, - boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws) +PeakOverlay::PeakOverlay( + UnwrappedSurface *surface, + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws) : Shape2DCollection(), m_peaksWorkspace(pws), m_surface(surface), m_precision(6), m_showRows(true), m_showLabels(true), m_peakIntensityScale(std::make_unique<QualitativeIntensityScale>(pws)) { @@ -416,7 +417,8 @@ PeakMarker2D::Style PeakOverlay::getDefaultStyle(int index) { * @param units :: Units of the x - array in the underlying workspace: * "TOF", "dSpacing", or "Wavelength". */ -void PeakOverlay::setPeakVisibility(double xmin, double xmax, QString units) { +void PeakOverlay::setPeakVisibility(double xmin, double xmax, + const QString &units) { enum XUnits { Unknown, TOF, dSpacing, Wavelength }; XUnits xUnits = Unknown; if (units == "TOF") diff --git a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp index d31692b947433a1437ba442edb23b6abfa11a226..0b5e38f9cb4c7327362c7a71cacdebc7321396aa 100644 --- a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp +++ b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneModel.cpp @@ -15,7 +15,7 @@ namespace MantidWidgets { IFunction_sptr PlotFitAnalysisPaneModel::doFit(const std::string &wsName, const std::pair<double, double> &range, - IFunction_sptr func) { + const IFunction_sptr &func) { IAlgorithm_sptr alg = AlgorithmManager::Instance().create("Fit"); alg->initialize(); diff --git a/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp b/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp index 73b45b00ffd5331796a341912f8a9123e5a2f15a..792eab3751772c81d364add6699f3ef7a7e93ba7 100644 --- a/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp +++ b/qt/widgets/instrumentview/src/PlotFitAnalysisPanePresenter.cpp @@ -9,6 +9,7 @@ #include <exception> #include <functional> #include <tuple> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -42,7 +43,7 @@ void PlotFitAnalysisPanePresenter::doFit() { void PlotFitAnalysisPanePresenter::addFunction( Mantid::API::IFunction_sptr func) { - m_view->addFunction(func); + m_view->addFunction(std::move(func)); } void PlotFitAnalysisPanePresenter::addSpectrum(const std::string &wsName) { diff --git a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp index 5f2ea4000543b90c5b57da4fa1d337b0c6b78303..044ea34f26d526bfceb772195b5bbf189f8953a4 100644 --- a/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp +++ b/qt/widgets/instrumentview/src/PlotFitAnalysisPaneView.cpp @@ -15,6 +15,8 @@ #include <QSpacerItem> #include <QSplitter> #include <QVBoxLayout> +#include <utility> + namespace MantidQt { namespace MantidWidgets { @@ -86,10 +88,10 @@ void PlotFitAnalysisPaneView::doFit() { } } -void PlotFitAnalysisPaneView::addSpectrum(std::string wsName) { +void PlotFitAnalysisPaneView::addSpectrum(const std::string &wsName) { m_plot->addSpectrum("Extracted Data", wsName.c_str(), 0, Qt::black); } -void PlotFitAnalysisPaneView::addFitSpectrum(std::string wsName) { +void PlotFitAnalysisPaneView::addFitSpectrum(const std::string &wsName) { m_plot->addSpectrum("Fitted Data", wsName.c_str(), 1, Qt::red); } @@ -103,12 +105,13 @@ Mantid::API::IFunction_sptr PlotFitAnalysisPaneView::getFunction() { return m_fitBrowser->getFunction(); } -void PlotFitAnalysisPaneView::updateFunction(Mantid::API::IFunction_sptr func) { +void PlotFitAnalysisPaneView::updateFunction( + const Mantid::API::IFunction_sptr &func) { m_fitBrowser->updateMultiDatasetParameters(*func); } void PlotFitAnalysisPaneView::addFunction(Mantid::API::IFunction_sptr func) { - m_fitBrowser->setFunction(func); + m_fitBrowser->setFunction(std::move(func)); } void PlotFitAnalysisPaneView::fitWarning(const std::string &message) { diff --git a/qt/widgets/instrumentview/src/ProjectionSurface.cpp b/qt/widgets/instrumentview/src/ProjectionSurface.cpp index 350e38d7e9969481777859f392978b09c9880141..9b9d0667480e89fa5b1627a735e31c3bb2f47a95 100644 --- a/qt/widgets/instrumentview/src/ProjectionSurface.cpp +++ b/qt/widgets/instrumentview/src/ProjectionSurface.cpp @@ -33,6 +33,7 @@ #include <cfloat> #include <cmath> #include <limits> +#include <utility> using Mantid::Kernel::V3D; @@ -689,8 +690,8 @@ void ProjectionSurface::saveShapesToTableWorkspace() { * @param ws :: table workspace to load shapes from */ void ProjectionSurface::loadShapesFromTableWorkspace( - Mantid::API::ITableWorkspace_const_sptr ws) { - m_maskShapes.loadFromTableWorkspace(ws); + const Mantid::API::ITableWorkspace_const_sptr &ws) { + m_maskShapes.loadFromTableWorkspace(std::move(ws)); } /** @@ -721,7 +722,7 @@ ProjectionSurface::getEditPeaksWorkspace() const { * @param ws :: Shared pointer to the deleted peaks workspace. */ void ProjectionSurface::deletePeaksWorkspace( - boost::shared_ptr<Mantid::API::IPeaksWorkspace> ws) { + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &ws) { const int npeaks = m_peakShapes.size(); for (int i = 0; i < npeaks; ++i) { if (m_peakShapes[i]->getPeaksWorkspace() == ws) { diff --git a/qt/widgets/instrumentview/src/Shape2DCollection.cpp b/qt/widgets/instrumentview/src/Shape2DCollection.cpp index 31fa6c27c8012ad6fd581fbdef8d50dffb4fc66c..762dfc384f2f1cb208a512e56ebb03d1624551e0 100644 --- a/qt/widgets/instrumentview/src/Shape2DCollection.cpp +++ b/qt/widgets/instrumentview/src/Shape2DCollection.cpp @@ -677,7 +677,7 @@ void Shape2DCollection::saveToTableWorkspace() { * @param ws :: table workspace to load shapes from. */ void Shape2DCollection::loadFromTableWorkspace( - Mantid::API::ITableWorkspace_const_sptr ws) { + const Mantid::API::ITableWorkspace_const_sptr &ws) { using namespace Mantid::API; auto columnNames = ws->getColumnNames(); diff --git a/qt/widgets/instrumentview/src/SimpleWidget.cpp b/qt/widgets/instrumentview/src/SimpleWidget.cpp index aad5c279317dcc3bb40092aea30c9fd519ace4d2..8b1842ded58b2d41268bbe341044ca80bc02ed7b 100644 --- a/qt/widgets/instrumentview/src/SimpleWidget.cpp +++ b/qt/widgets/instrumentview/src/SimpleWidget.cpp @@ -9,6 +9,7 @@ #include <QApplication> #include <QPixmap> +#include <utility> namespace MantidQt { namespace MantidWidgets { @@ -25,7 +26,7 @@ SimpleWidget::~SimpleWidget() {} /// Assign a surface to draw on void SimpleWidget::setSurface(boost::shared_ptr<ProjectionSurface> surface) { - m_surface = surface; + m_surface = std::move(surface); connect(m_surface.get(), SIGNAL(redrawRequired()), this, SLOT(repaint()), Qt::QueuedConnection); } diff --git a/qt/widgets/instrumentview/src/UnwrappedDetector.cpp b/qt/widgets/instrumentview/src/UnwrappedDetector.cpp index fde0abeff9eb728731c39e5005d55336ce425b24..6e09fd0c7778e6b30477c4ffbcfc296847cc8b3c 100644 --- a/qt/widgets/instrumentview/src/UnwrappedDetector.cpp +++ b/qt/widgets/instrumentview/src/UnwrappedDetector.cpp @@ -18,7 +18,7 @@ UnwrappedDetector::UnwrappedDetector() color = GLColor(0, 0, 0); } -UnwrappedDetector::UnwrappedDetector(GLColor color, size_t detIndex) +UnwrappedDetector::UnwrappedDetector(const GLColor &color, size_t detIndex) : u(0), v(0), width(0), height(0), uscale(0), vscale(0), detIndex(detIndex) { this->color = color; diff --git a/qt/widgets/instrumentview/src/UnwrappedSurface.cpp b/qt/widgets/instrumentview/src/UnwrappedSurface.cpp index 4661474e0b4c0e04b0467ef2945bd4f4ef0c900b..81bd7c3068df2cb5a5fce2a6647454ea2a59e76f 100644 --- a/qt/widgets/instrumentview/src/UnwrappedSurface.cpp +++ b/qt/widgets/instrumentview/src/UnwrappedSurface.cpp @@ -226,8 +226,9 @@ void UnwrappedSurface::setColor(size_t index, bool picking) const { } } -bool hasParent(boost::shared_ptr<const Mantid::Geometry::IComponent> comp, - Mantid::Geometry::ComponentID id) { +bool hasParent( + const boost::shared_ptr<const Mantid::Geometry::IComponent> &comp, + Mantid::Geometry::ComponentID id) { boost::shared_ptr<const Mantid::Geometry::IComponent> parent = comp->getParent(); if (!parent) @@ -362,7 +363,7 @@ RectF UnwrappedSurface::getSurfaceBounds() const { return m_viewRect; } * @param pws :: A shared pointer to the workspace. */ void UnwrappedSurface::setPeaksWorkspace( - boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws) { + const boost::shared_ptr<Mantid::API::IPeaksWorkspace> &pws) { if (!pws) { return; } diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h index 6e8ccc100814d2c55ee55c69188d287b8dde9729..e00b29ba706b86c68c93daee2fa19390cc9e45fd 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Artist.h @@ -21,7 +21,7 @@ public: // Holds a reference to the matplotlib artist object explicit Artist(Common::Python::Object obj); - void set(Common::Python::Dict kwargs); + void set(const Common::Python::Dict &kwargs); void remove(); }; diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h index b9bdf7ee6110b4e5158d00862ceca18636a329d3..c85cd575f371598b62919a5034df43eef68334e0 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Axes.h @@ -27,7 +27,7 @@ public: /// Function-signature required for operation applied to each artist using ArtistOperation = std::function<void(Artist &&)>; void forEachArtist(const char *containerAttr, const ArtistOperation &op); - void removeArtists(const char *containerAttr, const QString label); + void removeArtists(const char *containerAttr, const QString &label); void setXLabel(const char *label); void setYLabel(const char *label); void setTitle(const char *label); @@ -40,8 +40,8 @@ public: Line2D plot(std::vector<double> xdata, std::vector<double> ydata, const char *format = "b-"); Line2D plot(std::vector<double> xdata, std::vector<double> ydata, - const QString format, const QString label); - Artist text(double x, double y, QString text, + const QString &format, const QString &label); + Artist text(double x, double y, const QString &text, const char *horizontalAlignment); /// @} diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h index cc1bd6f7e7ec0deadee11d06153eb85229bc42f7..64058256db2bea93dc6f84d651a10b9a4cf3ce8f 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Cycler.h @@ -24,7 +24,7 @@ namespace MplCpp { */ class MANTID_MPLCPP_DLL Cycler : public Common::Python::InstanceHolder { public: - Cycler(Common::Python::Object obj); + Cycler(const Common::Python::Object &obj); /// Return the next value in the sequence Common::Python::Dict operator()() const; diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h index a38a3b10d9a998bf42d8b65facf39d74805b880b..61c1171108b5c2e9091e6b74ff1fa6cec3587a89 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/Figure.h @@ -46,10 +46,10 @@ public: void setTightLayout(QHash<QString, QVariant> const &args); QColor faceColor() const; - void setFaceColor(const QColor color); + void setFaceColor(const QColor &color); void setFaceColor(const char *color); Axes addAxes(double left, double bottom, double width, double height); - Axes addSubPlot(const int subplotspec, const QString projection = ""); + Axes addSubPlot(const int subplotspec, const QString &projection = ""); Common::Python::Object colorbar(const ScalarMappable &mappable, const Axes &cax, const Common::Python::Object &ticks = Common::Python::Object(), diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h index eb11150f311831b36a6457b5d67ae346f75b543d..63320a265a16e63c46a6e596451a1fda7a03b088 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/FigureCanvasQt.h @@ -26,7 +26,7 @@ class MANTID_MPLCPP_DLL FigureCanvasQt : public QWidget, public Common::Python::InstanceHolder { Q_OBJECT public: - FigureCanvasQt(const int subplotspec, const QString projection = "", + FigureCanvasQt(const int subplotspec, const QString &projection = "", QWidget *parent = nullptr); FigureCanvasQt(Figure fig, QWidget *parent = nullptr); diff --git a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h index 07e10c445010c85b1109158805f32485dca2f4f8..23730a5fafa46b7890287082694e439323f73287 100644 --- a/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h +++ b/qt/widgets/mplcpp/inc/MantidQtWidgets/MplCpp/MantidAxes.h @@ -30,13 +30,13 @@ public: /// @name Plot creation functions ///@{ Line2D plot(const Mantid::API::MatrixWorkspace_sptr &workspace, - const size_t wkspIndex, const QString lineColour, - const QString label, + const size_t wkspIndex, const QString &lineColour, + const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs = boost::none); ErrorbarContainer errorbar(const Mantid::API::MatrixWorkspace_sptr &workspace, - const size_t wkspIndex, const QString lineColour, - const QString label, + const size_t wkspIndex, const QString &lineColour, + const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs = boost::none); void pcolormesh(const Mantid::API::MatrixWorkspace_sptr &workspace, diff --git a/qt/widgets/mplcpp/src/Artist.cpp b/qt/widgets/mplcpp/src/Artist.cpp index e6044471c6b3c28b5a4d9d5568ea716d42f5683d..cb5ef776d850c25dd18a411d3ae70d71f39f3f9a 100644 --- a/qt/widgets/mplcpp/src/Artist.cpp +++ b/qt/widgets/mplcpp/src/Artist.cpp @@ -26,7 +26,7 @@ Artist::Artist(Python::Object obj) : InstanceHolder(std::move(obj), "draw") {} * Set properties on the Artist given by the dict of kwargs * @param kwargs A dict of known matplotlib.artist.Artist properties */ -void Artist::set(Python::Dict kwargs) { +void Artist::set(const Python::Dict &kwargs) { GlobalInterpreterLock lock; auto args = Python::NewRef(Py_BuildValue("()")); pyobj().attr("set")(*args, **kwargs); diff --git a/qt/widgets/mplcpp/src/Axes.cpp b/qt/widgets/mplcpp/src/Axes.cpp index e950f310831338be12a8b5056ba8e00c1a84bd83..09d8e8869eea22983a8b27c72dd76447f2cd61e2 100644 --- a/qt/widgets/mplcpp/src/Axes.cpp +++ b/qt/widgets/mplcpp/src/Axes.cpp @@ -85,7 +85,7 @@ void Axes::forEachArtist(const char *containerAttr, const ArtistOperation &op) { * @param containerAttr The name of the container attribute * @param label The label of the artists to remove */ -void Axes::removeArtists(const char *containerAttr, const QString label) { +void Axes::removeArtists(const char *containerAttr, const QString &label) { GlobalInterpreterLock lock; const auto lineNameAsUnicode = Python::NewRef(PyUnicode_FromString(label.toLatin1().constData())); @@ -166,7 +166,7 @@ Artist Axes::legendInstance() const { * the canvas as the vector data will be destroyed. */ Line2D Axes::plot(std::vector<double> xdata, std::vector<double> ydata, - const QString format, const QString label) { + const QString &format, const QString &label) { GlobalInterpreterLock lock; auto line2d = plot(std::move(xdata), std::move(ydata), format.toLatin1().constData()); @@ -221,7 +221,7 @@ Line2D Axes::plot(std::vector<double> xdata, std::vector<double> ydata, * @param horizontalAlignment A string indicating the horizontal * alignment of the string */ -Artist Axes::text(double x, double y, QString text, +Artist Axes::text(double x, double y, const QString &text, const char *horizontalAlignment) { GlobalInterpreterLock lock; auto args = diff --git a/qt/widgets/mplcpp/src/Colormap.cpp b/qt/widgets/mplcpp/src/Colormap.cpp index ba7d580526c7f3cb92e52b82b97aefe1e70bb850..8083106aa7009c2899b901dfa78876c5814599e3 100644 --- a/qt/widgets/mplcpp/src/Colormap.cpp +++ b/qt/widgets/mplcpp/src/Colormap.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/MplCpp/Colormap.h" #include "MantidQtWidgets/MplCpp/Colors.h" @@ -21,7 +23,7 @@ namespace MplCpp { * @brief Construct a Colormap object given a name */ Colormap::Colormap(Python::Object obj) - : Python::InstanceHolder(obj, "is_gray") {} + : Python::InstanceHolder(std::move(obj), "is_gray") {} /** * @return A reference to the matplotlib.cm module diff --git a/qt/widgets/mplcpp/src/Cycler.cpp b/qt/widgets/mplcpp/src/Cycler.cpp index 50cb3ac14733644b3e9f15af1807d93211325832..d1c83065728f46da29486e00ddc8bbdbe9e2a2fe 100644 --- a/qt/widgets/mplcpp/src/Cycler.cpp +++ b/qt/widgets/mplcpp/src/Cycler.cpp @@ -40,7 +40,7 @@ Python::Object cycleIterator(const Python::Object &rawCycler) { * that produces an iterable * @param obj An existing instance of a Cycler object */ -Cycler::Cycler(Python::Object obj) +Cycler::Cycler(const Python::Object &obj) : Python::InstanceHolder(cycleIterator(std::move(obj))) {} /** diff --git a/qt/widgets/mplcpp/src/Figure.cpp b/qt/widgets/mplcpp/src/Figure.cpp index 2853d932e11e1cffb486fbf3c622cf1027e66c91..41f9d66d9e7ec5c425e21df9b57c4619e073cf16 100644 --- a/qt/widgets/mplcpp/src/Figure.cpp +++ b/qt/widgets/mplcpp/src/Figure.cpp @@ -58,7 +58,7 @@ QColor Figure::faceColor() const { * @param color A character string indicating the color. * See https://matplotlib.org/api/colors_api.html */ -void Figure::setFaceColor(const QColor color) { +void Figure::setFaceColor(const QColor &color) { callMethodNoCheck<void, const char *>( pyobj(), "set_facecolor", color.name(QColor::HexRgb).toLatin1().constData()); @@ -103,7 +103,7 @@ Axes Figure::addAxes(double left, double bottom, double width, double height) { * @param projection An optional string denoting the projection type * @return A wrapper around the Axes object */ -Axes Figure::addSubPlot(const int subplotspec, const QString projection) { +Axes Figure::addSubPlot(const int subplotspec, const QString &projection) { GlobalInterpreterLock lock; if (projection.isEmpty()) return Axes{pyobj().attr("add_subplot")(subplotspec)}; diff --git a/qt/widgets/mplcpp/src/FigureCanvasQt.cpp b/qt/widgets/mplcpp/src/FigureCanvasQt.cpp index c0edcadcb5e38ceb3183233c74536db44cda3d96..354d007dbf60adcc0ac06ba8340b918ed3139e9c 100644 --- a/qt/widgets/mplcpp/src/FigureCanvasQt.cpp +++ b/qt/widgets/mplcpp/src/FigureCanvasQt.cpp @@ -30,7 +30,7 @@ const char *DEFAULT_FACECOLOR = "w"; * @param fig An existing matplotlib Figure instance * @return A new FigureCanvasQT object */ -Python::Object createPyCanvasFromFigure(Figure fig) { +Python::Object createPyCanvasFromFigure(const Figure &fig) { GlobalInterpreterLock lock; return backendModule().attr("FigureCanvasQTAgg")(fig.pyobj()); } @@ -41,7 +41,8 @@ Python::Object createPyCanvasFromFigure(Figure fig) { * @param projection A string denoting the projection to use * @return A new FigureCanvasQT object */ -Python::Object createPyCanvas(const int subplotspec, const QString projection) { +Python::Object createPyCanvas(const int subplotspec, + const QString &projection) { Figure fig{true}; fig.setFaceColor(DEFAULT_FACECOLOR); @@ -73,7 +74,7 @@ QWidget *initLayout(FigureCanvasQt *cppCanvas) { * @param projection A string denoting the projection to use on the canvas * @param parent The owning parent widget */ -FigureCanvasQt::FigureCanvasQt(const int subplotspec, const QString projection, +FigureCanvasQt::FigureCanvasQt(const int subplotspec, const QString &projection, QWidget *parent) : QWidget(parent), InstanceHolder(createPyCanvas(subplotspec, projection), "draw"), diff --git a/qt/widgets/mplcpp/src/MantidAxes.cpp b/qt/widgets/mplcpp/src/MantidAxes.cpp index a16f33d4158f638ee52b1d12a03a9a96f270e4fa..81ad08271e79f81c78e7f72a03297613d07fb7f0 100644 --- a/qt/widgets/mplcpp/src/MantidAxes.cpp +++ b/qt/widgets/mplcpp/src/MantidAxes.cpp @@ -34,8 +34,8 @@ MantidAxes::MantidAxes(Python::Object pyObj) : Axes{std::move(pyObj)} {} */ Line2D MantidAxes::plot(const Mantid::API::MatrixWorkspace_sptr &workspace, - const size_t wkspIndex, const QString lineColour, - const QString label, + const size_t wkspIndex, const QString &lineColour, + const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs) { GlobalInterpreterLock lock; const auto wksp = Python::NewRef(MatrixWorkpaceToPython()(workspace)); @@ -61,7 +61,7 @@ MantidAxes::plot(const Mantid::API::MatrixWorkspace_sptr &workspace, */ ErrorbarContainer MantidAxes::errorbar( const Mantid::API::MatrixWorkspace_sptr &workspace, const size_t wkspIndex, - const QString lineColour, const QString label, + const QString &lineColour, const QString &label, const boost::optional<QHash<QString, QVariant>> &otherKwargs) { GlobalInterpreterLock lock; const auto wksp = Python::NewRef(MatrixWorkpaceToPython()(workspace)); diff --git a/qt/widgets/mplcpp/src/Plot.cpp b/qt/widgets/mplcpp/src/Plot.cpp index c9c989d4eb565825e14185aa8ee72158c9e9d3f1..cb324f79ad4e36dbf7d038fd3b8251b406749da5 100644 --- a/qt/widgets/mplcpp/src/Plot.cpp +++ b/qt/widgets/mplcpp/src/Plot.cpp @@ -5,12 +5,15 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include "MantidQtWidgets/MplCpp/Plot.h" + #include "MantidPythonInterface/core/CallMethod.h" #include "MantidPythonInterface/core/Converters/ToPyList.h" #include "MantidPythonInterface/core/GlobalInterpreterLock.h" #include "MantidQtWidgets/Common/Python/Object.h" #include "MantidQtWidgets/Common/Python/QHashToDict.h" #include "MantidQtWidgets/Common/Python/Sip.h" +#include "MantidQtWidgets/MplCpp/Plot.h" +#include <utility> using namespace Mantid::PythonInterface; using namespace MantidQt::Widgets::Common; @@ -102,9 +105,10 @@ Python::Object plot(const Python::Object &args, boost::optional<QHash<QString, QVariant>> axProperties, boost::optional<std::string> windowTitle, bool errors, bool overplot, bool tiled) { - const auto kwargs = - constructKwargs(spectrumNums, wkspIndices, fig, plotKwargs, axProperties, - windowTitle, errors, overplot, tiled); + const auto kwargs = constructKwargs( + std::move(spectrumNums), std::move(wkspIndices), std::move(fig), + std::move(plotKwargs), std::move(axProperties), std::move(windowTitle), + errors, overplot, tiled); try { return functionsModule().attr("plot")(*args, **kwargs); } catch (Python::ErrorAlreadySet &) { diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h index fafd2d672cba9041159619aebaaa88a978dc6fe5..634c1b4aed2109ecedb655283e3f25a50d8f351b 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/ContourPreviewPlot.h @@ -39,7 +39,7 @@ public: void setCanvasColour(QColor const &colour); - void setWorkspace(Mantid::API::MatrixWorkspace_sptr workspace); + void setWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace); std::tuple<double, double> getAxisRange(AxisID axisID) const; diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h index 4c07a0cd02708ec0753f578ff232696bb952c30c..a320af8b07b44318d7d4cd91fb00b4f7fcc66247 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Mpl/PreviewPlot.h @@ -94,8 +94,8 @@ public slots: void clear(); void resizeX(); void resetView(); - void setCanvasColour(QColor colour); - void setLinesWithErrors(QStringList labels); + void setCanvasColour(const QColor &colour); + void setLinesWithErrors(const QStringList &labels); void showLegend(bool visible); void replot(); @@ -136,7 +136,7 @@ private: void switchPlotTool(QAction *selected); void setXScaleType(QAction *selected); void setYScaleType(QAction *selected); - void setScaleType(AxisID id, QString actionName); + void setScaleType(AxisID id, const QString &actionName); void toggleLegend(const bool checked); boost::optional<char const *> overrideAxisLabel(AxisID const &axisID); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h index 7e6e878cdd9f9168a6c94f76108c0f3cddeeb725..0ffe6150789bbe527bc91187033fa9c6c1ee9b8e 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ContourPreviewPlot.h @@ -52,7 +52,7 @@ public: ~ContourPreviewPlot() override; Mantid::API::MatrixWorkspace_sptr getActiveWorkspace() const; - void setWorkspace(Mantid::API::MatrixWorkspace_sptr const workspace); + void setWorkspace(Mantid::API::MatrixWorkspace_sptr const &workspace); SafeQwtPlot *getPlot2D(); void setPlotVisible(bool const &visible); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h index dcbd15cfaf794ef1a00de26fd14415a2c23b2e5c..58f0c0091cf878702d607c11b517eee9ddbf46de 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/DisplayCurveFit.h @@ -57,12 +57,12 @@ public: void setAxisRange(QPair<double, double> range, AxisID axisID = AxisID::XBottom); curveTypes - getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr workspace); + getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace); QPair<double, double> getCurveRange(const curveType &atype); QPair<double, double> - getCurveRange(const Mantid::API::MatrixWorkspace_sptr workspace); + getCurveRange(const Mantid::API::MatrixWorkspace_sptr &workspace); void addSpectrum(const curveType &aType, - const Mantid::API::MatrixWorkspace_sptr workspace, + const Mantid::API::MatrixWorkspace_sptr &workspace, const size_t specIndex = 0); void removeSpectrum(const curveType &aType); bool hasCurve(const curveType &aType); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h index 5e21b68f7366892c7d9ddc24e9298a70f77ebeb2..7b5fdca0c9c4ad951fefd30c8b79ed614d6728ab 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/MWView.h @@ -58,8 +58,8 @@ class EXPORT_OPT_MANTIDQT_PLOTTING MWView public: MWView(QWidget *parent = nullptr); ~MWView() override; - void loadColorMap(QString filename = QString()); - void setWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + void loadColorMap(const QString &filename = QString()); + void setWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); void updateDisplay(); SafeQwtPlot *getPlot2D(); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h index c8fbdbffa31cbad9e309d5256341ab2f236fdddd..a68fb643c69766291be97d78c588b70baabc4e1f 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PeakPicker.h @@ -28,8 +28,8 @@ class EXPORT_OPT_MANTIDQT_PLOTTING PeakPicker : public QwtPlotPicker, public: /// Constructor - PeakPicker(QwtPlot *plot, QColor color); - PeakPicker(PreviewPlot *plot, QColor color); + PeakPicker(QwtPlot *plot, const QColor &color); + PeakPicker(PreviewPlot *plot, const QColor &color); /// Correct QwtPlotItem type info int rtti() const override { return QwtPlotItem::Rtti_PlotMarker; } diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h index 8b7f9bb5b097b58bd3809bfca44b946851f77102..49b16a49db50eba65fab72edcee7918e91b8a258 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/PreviewPlot.h @@ -73,7 +73,7 @@ public: getAxisRange(AxisID axisID = AxisID::XBottom) const; QPair<double, double> - getCurveRange(const Mantid::API::MatrixWorkspace_sptr ws); + getCurveRange(const Mantid::API::MatrixWorkspace_sptr &ws); QPair<double, double> getCurveRange(const QString &curveName); void addSpectrum( @@ -85,7 +85,7 @@ public: const QColor &curveColour = QColor(), const QHash<QString, QVariant> &plotKwargs = QHash<QString, QVariant>()); - void removeSpectrum(const Mantid::API::MatrixWorkspace_sptr ws); + void removeSpectrum(const Mantid::API::MatrixWorkspace_sptr &ws); void removeSpectrum(const QString &curveName); bool hasCurve(const QString &curveName); @@ -157,16 +157,19 @@ private: const QColor &curveColour, const QString &curveName = ""); void removeCurve(QwtPlotItem *curve); - QList<QAction *> addOptionsToMenus(QString menuName, QActionGroup *group, - QStringList items, QString defaultItem); + QList<QAction *> addOptionsToMenus(const QString &menuName, + QActionGroup *group, + const QStringList &items, + const QString &defaultItem); - QStringList getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr ws); + QStringList + getCurvesForWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); private slots: void showContextMenu(QPoint position); void handleViewToolSelect(); void handleAxisTypeSelect(); - void removeWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + void removeWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); private: Ui::PreviewPlot m_uiForm; diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h index 12eeac6d4b0b63bbf37d43983e993f51034f4751..17ce370ae64f8f5a2b323df3a39cf60b8dc7bae6 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtHelper.h @@ -18,25 +18,27 @@ namespace API { namespace QwtHelper { /// Create Qwt curve data from a workspace EXPORT_OPT_MANTIDQT_PLOTTING boost::shared_ptr<QwtData> -curveDataFromWs(Mantid::API::MatrixWorkspace_const_sptr ws, size_t wsIndex); +curveDataFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws, + size_t wsIndex); /// Create vector of Qwt curve data from a workspace, used for EnggDiffraction /// GUI EXPORT_OPT_MANTIDQT_PLOTTING std::vector<boost::shared_ptr<QwtData>> -curveDataFromWs(Mantid::API::MatrixWorkspace_const_sptr ws); +curveDataFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws); /// Create error vector from a workspace EXPORT_OPT_MANTIDQT_PLOTTING std::vector<double> -curveErrorsFromWs(Mantid::API::MatrixWorkspace_const_sptr ws, size_t wsIndex); +curveErrorsFromWs(const Mantid::API::MatrixWorkspace_const_sptr &ws, + size_t wsIndex); /// Create Qwt curve data from a function EXPORT_OPT_MANTIDQT_PLOTTING boost::shared_ptr<QwtData> -curveDataFromFunction(Mantid::API::IFunction_const_sptr func, +curveDataFromFunction(const Mantid::API::IFunction_const_sptr &func, const std::vector<double> &xValues); /// Create workspace filled with function values EXPORT_OPT_MANTIDQT_PLOTTING Mantid::API::MatrixWorkspace_sptr -createWsFromFunction(Mantid::API::IFunction_const_sptr func, +createWsFromFunction(const Mantid::API::IFunction_const_sptr &func, const std::vector<double> &xValues); /// Creates empty Qwt curve data diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h index 01d90f854a6bf57825ba48e588691f51300253cf..1aa5cf4eaf438acad30934c7f4d3891387fafeff 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtRasterDataMD.h @@ -41,7 +41,7 @@ public: virtual void setWorkspace(Mantid::API::IMDWorkspace_const_sptr ws); Mantid::API::IMDWorkspace_const_sptr getWorkspace() const; - void setOverlayWorkspace(Mantid::API::IMDWorkspace_const_sptr ws); + void setOverlayWorkspace(const Mantid::API::IMDWorkspace_const_sptr &ws); QwtDoubleInterval range() const override; void setRange(const QwtDoubleInterval &range); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h index 37e57137f43e092e02fad75a2a56607f36a686d7..ab37db3277dd760ac5c3ed2a8b2058f4fae8bddd 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/RangeSelector.h @@ -56,7 +56,7 @@ public slots: void setMaximum(double /*val*/); ///< outside setting of value void reapply(); ///< re-apply the range selector lines void detach(); ///< Detach range selector lines from the plot - void setColour(QColor colour); + void setColour(const QColor &colour); void setInfoOnly(bool state); void setVisible(bool state); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h index 8a6667050281c60f343225f0c7afca1c7ae4f68a..937e569189b54c5c9f8c85a846c6db8494345b8e 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h @@ -45,8 +45,8 @@ public: : QwtScaleTransformation(Other), d_engine(engine){}; double xForm(double x, double /*s1*/, double /*s2*/, double p1, double p2) const override; - double invXForm(double x, double s1, double s2, double p1, - double p2) const override; + double invXForm(double p, double p1, double p2, double s1, + double s2) const override; QwtScaleTransformation *copy() const override; ~ScaleTransformation() override; diff --git a/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp b/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp index 599e863bfc554bd38ff9343eccfa2ae6f91ae4ba..ab7ddad5de5dc56f94ffa33e6d52aa543f8b568f 100644 --- a/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp +++ b/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp @@ -104,7 +104,7 @@ void ContourPreviewPlot::setCanvasColour(QColor const &colour) { * Sets the workspace for the contour plot * @param workspace The workspace to plot on the contour plot. */ -void ContourPreviewPlot::setWorkspace(MatrixWorkspace_sptr workspace) { +void ContourPreviewPlot::setWorkspace(const MatrixWorkspace_sptr &workspace) { if (workspace) { auto axes = m_canvas->gca<MantidAxes>(); axes.pcolormesh(workspace); diff --git a/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp b/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp index 8ede39c537e8f6a9651cfffe654448ab58f4ce26..08faa6ab84c6b9c86217ae909cb21984ad110e91 100644 --- a/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp +++ b/qt/widgets/plotting/src/Mpl/PreviewPlot.cpp @@ -19,6 +19,7 @@ #include <QVBoxLayout> #include <algorithm> +#include <utility> using Mantid::API::AnalysisDataService; using Mantid::API::MatrixWorkspace; @@ -354,15 +355,15 @@ void PreviewPlot::resetView() { * Set the face colour for the canvas * @param colour A new colour for the figure facecolor */ -void PreviewPlot::setCanvasColour(QColor colour) { - m_canvas->gcf().setFaceColor(colour); +void PreviewPlot::setCanvasColour(const QColor &colour) { + m_canvas->gcf().setFaceColor(std::move(colour)); } /** * @brief PreviewPlot::setLinesWithErrors * @param labels A list of line labels where error bars should be shown */ -void PreviewPlot::setLinesWithErrors(QStringList labels) { +void PreviewPlot::setLinesWithErrors(const QStringList &labels) { for (const QString &label : labels) { m_lines[label] = true; } @@ -685,7 +686,7 @@ void PreviewPlot::setYScaleType(QAction *selected) { setScaleType(AxisID::YLeft, selected->text()); } -void PreviewPlot::setScaleType(AxisID id, QString actionName) { +void PreviewPlot::setScaleType(AxisID id, const QString &actionName) { auto scaleType = actionName.toLower().toLatin1(); auto axes = m_canvas->gca(); switch (id) { diff --git a/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp b/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp index 71b159b1fc9d1fa5db1ac88f765030a08495a7ca..7e2ac2f8c44553669c1f7f7ac132c744abba3a5c 100644 --- a/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp +++ b/qt/widgets/plotting/src/Qwt/ContourPreviewPlot.cpp @@ -31,7 +31,7 @@ namespace { Mantid::Kernel::Logger g_log("ContourPreviewPlot"); MatrixWorkspace_sptr -convertToMatrixWorkspace(boost::shared_ptr<Workspace> const workspace) { +convertToMatrixWorkspace(boost::shared_ptr<Workspace> const &workspace) { return boost::dynamic_pointer_cast<MatrixWorkspace>(workspace); } @@ -79,7 +79,7 @@ MatrixWorkspace_sptr ContourPreviewPlot::getActiveWorkspace() const { /** * Initialize objects after loading the workspace */ -void ContourPreviewPlot::setWorkspace(MatrixWorkspace_sptr const workspace) { +void ContourPreviewPlot::setWorkspace(MatrixWorkspace_sptr const &workspace) { m_workspace = workspace; this->checkRangeLimits(); m_data->setWorkspace(workspace); diff --git a/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp b/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp index dcfb2b3c6aefe584dea937faf9814a2c66dbca3e..c4ca4641697322eb3e555b7274e29c00ad00f36e 100644 --- a/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp +++ b/qt/widgets/plotting/src/Qwt/DisplayCurveFit.cpp @@ -76,7 +76,7 @@ void DisplayCurveFit::setAxisRange(QPair<double, double> range, AxisID axisID) { * @return a std::vector containing the curve types */ DisplayCurveFit::curveTypes DisplayCurveFit::getCurvesForWorkspace( - const Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { QStringList curveNames = m_uiForm.fitPlot->getCurvesForWorkspace(workspace); curveNames = curveNames + m_uiForm.residualsPlot->getCurvesForWorkspace(workspace); @@ -103,7 +103,7 @@ QPair<double, double> DisplayCurveFit::getCurveRange(const curveType &atype) { * workspace */ QPair<double, double> DisplayCurveFit::getCurveRange( - const Mantid::API::MatrixWorkspace_sptr workspace) { + const Mantid::API::MatrixWorkspace_sptr &workspace) { curveTypes typesFound = this->getCurvesForWorkspace(workspace); if (typesFound.size() == 0) { throw std::runtime_error("No fitting curves associated to workspace" + @@ -119,7 +119,7 @@ QPair<double, double> DisplayCurveFit::getCurveRange( * @param specIndex Spectrum index of workspace argument. */ void DisplayCurveFit::addSpectrum( - const curveType &aType, const Mantid::API::MatrixWorkspace_sptr workspace, + const curveType &aType, const Mantid::API::MatrixWorkspace_sptr &workspace, const size_t specIndex) { const QString &curveName{m_curveTypeToQString.at(aType)}; const QColor curveColor(m_curveTypeToColor.at(aType)); diff --git a/qt/widgets/plotting/src/Qwt/MWView.cpp b/qt/widgets/plotting/src/Qwt/MWView.cpp index 2cd925473618e5e5f6a3d8bf32babffb76a07b8a..c7fea8b389f2196e66b1ee82abc2a15a6c77891a 100644 --- a/qt/widgets/plotting/src/Qwt/MWView.cpp +++ b/qt/widgets/plotting/src/Qwt/MWView.cpp @@ -63,7 +63,7 @@ MWView::~MWView() { * * @param filename :: file to open; empty to ask via a dialog box. */ -void MWView::loadColorMap(QString filename) { +void MWView::loadColorMap(const QString &filename) { QString fileselection; if (filename.isEmpty()) { fileselection = MantidColorMap::chooseColorMap(m_currentColorMapFile, this); @@ -81,7 +81,7 @@ void MWView::loadColorMap(QString filename) { /** * @brief Initialize objects after loading the workspace, and observe. */ -void MWView::setWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +void MWView::setWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws) { m_workspace = ws; this->checkRangeLimits(); m_data->setWorkspace(ws); diff --git a/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp b/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp index 7e55f94fa6d0f1ef6138830cb2aea93bd805d21f..969ade58360305666ecfacd7189ae8e39d428a58 100644 --- a/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp +++ b/qt/widgets/plotting/src/Qwt/MantidQwtIMDWorkspaceData.cpp @@ -15,6 +15,7 @@ #include "MantidGeometry/MDGeometry/MDTypes.h" #include "MantidQtWidgets/Common/QStringUtils.h" #include <QStringBuilder> +#include <utility> using MantidQt::API::toQStringInternal; using namespace Mantid::Kernel; @@ -39,7 +40,7 @@ MantidQwtIMDWorkspaceData::MantidQwtIMDWorkspaceData( Mantid::API::IMDWorkspace_const_sptr workspace, const bool logScaleY, Mantid::Kernel::VMD start, Mantid::Kernel::VMD end, Mantid::API::MDNormalization normalize, bool isDistribution) - : MantidQwtWorkspaceData(logScaleY), m_workspace(workspace), + : MantidQwtWorkspaceData(logScaleY), m_workspace(std::move(workspace)), m_preview(false), m_start(start), m_end(end), m_normalization(normalize), m_isDistribution(isDistribution), m_transform(nullptr), m_plotAxis(PlotDistance), m_currentPlotAxis(PlotDistance) { diff --git a/qt/widgets/plotting/src/Qwt/PeakPicker.cpp b/qt/widgets/plotting/src/Qwt/PeakPicker.cpp index 62a5c8fc6275cae04c38b1b03515ee4bc70b80d8..0c00852b62e8fbc02f0f96cbadfc56339abd3533 100644 --- a/qt/widgets/plotting/src/Qwt/PeakPicker.cpp +++ b/qt/widgets/plotting/src/Qwt/PeakPicker.cpp @@ -24,7 +24,7 @@ const Qt::CursorShape PeakPicker::DEFAULT_CURSOR = Qt::PointingHandCursor; * @param plot :: A plot this peak picker should operate on * @param color :: Peak picker color */ -PeakPicker::PeakPicker(QwtPlot *plot, QColor color) +PeakPicker::PeakPicker(QwtPlot *plot, const QColor &color) : QwtPlotPicker(plot->canvas()), QwtPlotItem(), m_plot(plot), m_basePen(color, 0, Qt::SolidLine), m_widthPen(color, 0, Qt::DashLine), m_isMoving(false), m_isResizing(false), m_peak() { @@ -32,7 +32,7 @@ PeakPicker::PeakPicker(QwtPlot *plot, QColor color) plot->canvas()->setCursor(DEFAULT_CURSOR); } -PeakPicker::PeakPicker(PreviewPlot *plot, QColor color) +PeakPicker::PeakPicker(PreviewPlot *plot, const QColor &color) : QwtPlotPicker(plot->canvas()), QwtPlotItem(), m_plot(plot->getPlot()), m_basePen(color, 0, Qt::SolidLine), m_widthPen(color, 0, Qt::DashLine), m_isMoving(false), m_isResizing(false), m_peak() { diff --git a/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp b/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp index 7dd0ac92a87523298c5bac91b42864cea1ea933b..72333906a1fc96d001e1f1d30f58f2a8523e1663 100644 --- a/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp +++ b/qt/widgets/plotting/src/Qwt/PreviewPlot.cpp @@ -17,6 +17,7 @@ #include <QAction> #include <QPalette> +#include <utility> #include <qwt_array.h> #include <qwt_data.h> @@ -240,7 +241,7 @@ std::tuple<double, double> PreviewPlot::getAxisRange(AxisID axisID) const { * @param ws Pointer to workspace */ QPair<double, double> -PreviewPlot::getCurveRange(const Mantid::API::MatrixWorkspace_sptr ws) { +PreviewPlot::getCurveRange(const Mantid::API::MatrixWorkspace_sptr &ws) { QStringList curveNames = getCurvesForWorkspace(ws); if (curveNames.size() == 0) @@ -365,7 +366,7 @@ void PreviewPlot::addSpectrum(const QString &curveName, const QString &wsName, * * @param ws Pointer to workspace */ -void PreviewPlot::removeSpectrum(const MatrixWorkspace_sptr ws) { +void PreviewPlot::removeSpectrum(const MatrixWorkspace_sptr &ws) { if (!ws) { g_log.error("Cannot remove curve for null workspace"); return; @@ -658,9 +659,9 @@ void PreviewPlot::handleRemoveEvent(WorkspacePreDeleteNotification_ptr pNf) { * * @param ws the workspace that is being removed. */ -void PreviewPlot::removeWorkspace(MatrixWorkspace_sptr ws) { +void PreviewPlot::removeWorkspace(const MatrixWorkspace_sptr &ws) { // Remove the workspace on the main GUI thread - removeSpectrum(ws); + removeSpectrum(std::move(ws)); emit needToReplot(); } @@ -820,10 +821,10 @@ void PreviewPlot::removeCurve(QwtPlotItem *curve) { * @param defaultItem Default item name * @return List of Actions added */ -QList<QAction *> PreviewPlot::addOptionsToMenus(QString menuName, +QList<QAction *> PreviewPlot::addOptionsToMenus(const QString &menuName, QActionGroup *group, - QStringList items, - QString defaultItem) { + const QStringList &items, + const QString &defaultItem) { auto *menu = new QMenu(m_contextMenu); for (auto &item : items) { @@ -880,7 +881,7 @@ QString PreviewPlot::getAxisType(int axisID) { * @param ws Pointer to workspace * @return List of curve names */ -QStringList PreviewPlot::getCurvesForWorkspace(const MatrixWorkspace_sptr ws) { +QStringList PreviewPlot::getCurvesForWorkspace(const MatrixWorkspace_sptr &ws) { QStringList curveNames; for (auto it = m_curves.begin(); it != m_curves.end(); ++it) { diff --git a/qt/widgets/plotting/src/Qwt/QwtHelper.cpp b/qt/widgets/plotting/src/Qwt/QwtHelper.cpp index 1b6f9c764a1e0b2cc68e673fe3d24a91a492ba18..b86a5762578b8dbf8de834ca823753d0c84bae7c 100644 --- a/qt/widgets/plotting/src/Qwt/QwtHelper.cpp +++ b/qt/widgets/plotting/src/Qwt/QwtHelper.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/Plotting/Qwt/QwtHelper.h" #include "MantidAPI/AlgorithmManager.h" @@ -24,7 +26,7 @@ namespace QwtHelper { * @param wsIndex :: Workspace index to use * @return Pointer to created QwtData */ -boost::shared_ptr<QwtData> curveDataFromWs(MatrixWorkspace_const_sptr ws, +boost::shared_ptr<QwtData> curveDataFromWs(const MatrixWorkspace_const_sptr &ws, size_t wsIndex) { const double *x = &ws->x(wsIndex)[0]; const double *y = &ws->y(wsIndex)[0]; @@ -40,7 +42,7 @@ boost::shared_ptr<QwtData> curveDataFromWs(MatrixWorkspace_const_sptr ws, * @return Pointer to created Vector QwtData */ std::vector<boost::shared_ptr<QwtData>> -curveDataFromWs(MatrixWorkspace_const_sptr ws) { +curveDataFromWs(const MatrixWorkspace_const_sptr &ws) { std::vector<boost::shared_ptr<QwtData>> dataVector; auto histograms = ws->getNumberHistograms(); @@ -58,7 +60,7 @@ curveDataFromWs(MatrixWorkspace_const_sptr ws) { * @param wsIndex :: Workspace index to use * @return Vector of errors */ -std::vector<double> curveErrorsFromWs(MatrixWorkspace_const_sptr ws, +std::vector<double> curveErrorsFromWs(const MatrixWorkspace_const_sptr &ws, size_t wsIndex) { return ws->e(wsIndex).rawData(); } @@ -72,9 +74,9 @@ std::vector<double> curveErrorsFromWs(MatrixWorkspace_const_sptr ws, * @return Pointer to create QwtData */ boost::shared_ptr<QwtData> -curveDataFromFunction(IFunction_const_sptr func, +curveDataFromFunction(const IFunction_const_sptr &func, const std::vector<double> &xValues) { - MatrixWorkspace_sptr ws = createWsFromFunction(func, xValues); + MatrixWorkspace_sptr ws = createWsFromFunction(std::move(func), xValues); return curveDataFromWs(ws, 0); } @@ -85,7 +87,7 @@ curveDataFromFunction(IFunction_const_sptr func, * @param xValues :: X values to use * @return Single-spectrum workspace with calculated function values */ -MatrixWorkspace_sptr createWsFromFunction(IFunction_const_sptr func, +MatrixWorkspace_sptr createWsFromFunction(const IFunction_const_sptr &func, const std::vector<double> &xValues) { auto inputWs = boost::dynamic_pointer_cast<MatrixWorkspace>( WorkspaceFactory::Instance().create("Workspace2D", 1, xValues.size(), diff --git a/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp b/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp index 435e4a21be70de9b9be10f68ecefd4bf60c46d78..e4ebde8e8dcfd15580ba1fdb91e783d37b78bde9 100644 --- a/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp +++ b/qt/widgets/plotting/src/Qwt/QwtRasterDataMD.cpp @@ -10,6 +10,7 @@ #include "MantidGeometry/MDGeometry/IMDDimension.h" #include "MantidGeometry/MDGeometry/MDTypes.h" #include <cmath> +#include <utility> namespace MantidQt { namespace API { @@ -199,7 +200,7 @@ Mantid::API::IMDWorkspace_const_sptr QwtRasterDataMD::getWorkspace() const { * @param ws :: IMDWorkspace to show */ void QwtRasterDataMD::setOverlayWorkspace( - Mantid::API::IMDWorkspace_const_sptr ws) { + const Mantid::API::IMDWorkspace_const_sptr &ws) { if (!ws) { m_overlayWS.reset(); return; @@ -229,8 +230,8 @@ void QwtRasterDataMD::setSliceParams( "vector/number of dimensions size."); m_dimX = dimX; m_dimY = dimY; - m_X = X; - m_Y = Y; + m_X = std::move(X); + m_Y = std::move(Y); if (!m_X || !m_Y) throw std::runtime_error("QwtRasterDataMD::setSliceParams(): one of the " "input dimensions is NULL"); diff --git a/qt/widgets/plotting/src/Qwt/RangeSelector.cpp b/qt/widgets/plotting/src/Qwt/RangeSelector.cpp index 1f3a4fad886405cf71cc255ac9cae8b5434d2223..36e161d2fa2d4068f8da860513abeade1dcf5f68 100644 --- a/qt/widgets/plotting/src/Qwt/RangeSelector.cpp +++ b/qt/widgets/plotting/src/Qwt/RangeSelector.cpp @@ -305,7 +305,7 @@ void RangeSelector::detach() { m_mrkMax->attach(nullptr); } -void RangeSelector::setColour(QColor colour) { +void RangeSelector::setColour(const QColor &colour) { m_pen->setColor(colour); switch (m_type) { case XMINMAX: diff --git a/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp b/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp index f0f8f6dea3fea3e540f0193dbcf01f2ca3f56b57..fc2f6a8e8f64f9a4d6d923ff91090f058a255318 100644 --- a/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp +++ b/qt/widgets/plotting/src/Qwt/SafeQwtPlot.cpp @@ -4,10 +4,12 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h" +#include <utility> + #include "MantidAPI/Workspace.h" #include "MantidKernel/ReadLock.h" #include "MantidKernel/System.h" +#include "MantidQtWidgets/Plotting/Qwt/SafeQwtPlot.h" using namespace Mantid::Kernel; @@ -35,7 +37,9 @@ SafeQwtPlot::~SafeQwtPlot() {} * * @param ws :: shared ptr to workspace */ -void SafeQwtPlot::setWorkspace(Mantid::API::Workspace_sptr ws) { m_ws = ws; } +void SafeQwtPlot::setWorkspace(Mantid::API::Workspace_sptr ws) { + m_ws = std::move(ws); +} //---------------------------------------------------------------------------------------------- /** Overridden drawCanvas() that protects the diff --git a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h index df543c96171990bdb5fd29291ab59726127d8e7c..3f6e331b6e90f1d9e205e0565b15fa7c42386aad 100644 --- a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h +++ b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/PeriodicTableWidget.h @@ -42,7 +42,8 @@ public: /// @return Comma-separated string of all the element buttons for one group /// that are currently checked - QString elementsSelectedToString(QVector<QPushButton *> elementsSelected); + QString + elementsSelectedToString(const QVector<QPushButton *> &elementsSelected); /// @return Comma-separated string of all element buttons that are checked in /// the whole PeriodicTableWidget @@ -55,12 +56,12 @@ public: void disableAllElementButtons(); /// Enables a button for an element by the element name i.e 'Au' for Gold. - void enableButtonByName(QString elementStr); + void enableButtonByName(const QString &elementStr); ///@return the result of the comparison between a string and the text of a /// button. bool compareButtonNameToStr(QPushButton *buttonToCompare, - QString stringToCompare); + const QString &stringToCompare); /// Displays or hides the Legend for the colour coding of periodic groups void showGroupLegend(bool checked); @@ -86,7 +87,7 @@ private: void ColourNobleGases(const QVector<QPushButton *> &nobleGases); /// Methods to colour single element button by setting styleSheet - void ColourButton(QPushButton *elementButton, QString colour); + void ColourButton(QPushButton *elementButton, const QString &colour); /// Method to populate Group Vectors with element QPushButtons void populateGroupVectors(); diff --git a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h index 42105c79aad6eac4ef7364f6c5b452bb0bdfb0b6..cf97e72a5a9495d29485391008d0b11ecd56b133 100644 --- a/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h +++ b/qt/widgets/plugins/algorithm_dialogs/inc/MantidQtWidgets/Plugins/AlgorithmDialogs/SampleShapeHelpers.h @@ -74,7 +74,7 @@ struct Operation { Operation(int op = 0) : binaryop(op) {} /// Return the string that represnts the result of this operation - QString toString(QString left, QString right) const; + QString toString(const QString &left, const QString &right) const; /// The stored operation int binaryop; diff --git a/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp b/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp index c9a665b7e4557f14a16fe2c326040f1c39b1bc55..016e947c58a1b42946a39084cd0c8fabbe8f6a05 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp @@ -103,7 +103,9 @@ void ConvertTableToMatrixWorkspaceDialog::fillColumnNames( /// Initialize the layout void ConvertTableToMatrixWorkspaceDialog::initLayout() { m_form.setupUi(this); - ((QVBoxLayout *)this->layout())->addLayout(createDefaultButtonLayout()); + + static_cast<QVBoxLayout *>(this->layout()) + ->addLayout(createDefaultButtonLayout()); tie(m_form.cbInputWorkspace, "InputWorkspace", m_form.gridLayout); tie(m_form.leOutputWorkspace, "OutputWorkspace", m_form.gridLayout); tie(m_form.cbColumnX, "ColumnX", m_form.gridLayout); diff --git a/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp b/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp index f15fbd0863a17762be5ff41076374e624bcb35eb..81012058c5137588738285d65e3195d7f89bfbd4 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/FitDialog.cpp @@ -514,7 +514,7 @@ namespace { * Helper function to check if a function is an MD one. * @param fun :: Function to check */ -bool isFunctionMD(Mantid::API::IFunction_sptr fun) { +bool isFunctionMD(const Mantid::API::IFunction_sptr &fun) { auto cf = boost::dynamic_pointer_cast<Mantid::API::CompositeFunction>(fun); if (!cf) return static_cast<bool>( diff --git a/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp b/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp index a76790c57a8c45ef8d38e83c317f9b20de1a2251..5ebeba86d624f9b21f91d1a4b5dbd37b51373df1 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/MantidGLWidget.cpp @@ -14,6 +14,7 @@ #include <QtOpenGL> #include <cfloat> +#include <utility> using namespace MantidQt::CustomDialogs; @@ -50,7 +51,7 @@ MantidGLWidget::~MantidGLWidget() { makeCurrent(); } */ void MantidGLWidget::setDisplayObject( boost::shared_ptr<Mantid::Geometry::IObject> object) { - m_display_object = object; + m_display_object = std::move(object); m_x_rot = 0.0; m_y_rot = 0.0; m_z_rot = 0.0; diff --git a/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp b/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp index 35bc73bc7b1f56f56d91161a6f620aecbcc4b457..d67146de96e35f110ed5bbe5c63c9982e5cb2969 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/PeriodicTableWidget.cpp @@ -131,7 +131,7 @@ void PeriodicTableWidget::ColourUnknownProperties( } } -void PeriodicTableWidget::enableButtonByName(QString elementStr) { +void PeriodicTableWidget::enableButtonByName(const QString &elementStr) { for (auto &AllElementButton : AllElementButtons) { for (auto btn_i = AllElementButton.begin(); btn_i != AllElementButton.end(); btn_i++) { @@ -142,8 +142,8 @@ void PeriodicTableWidget::enableButtonByName(QString elementStr) { } } -bool PeriodicTableWidget::compareButtonNameToStr(QPushButton *buttonToCompare, - QString stringToCompare) { +bool PeriodicTableWidget::compareButtonNameToStr( + QPushButton *buttonToCompare, const QString &stringToCompare) { return (strcmp(buttonToCompare->text().toStdString().c_str(), stringToCompare.toStdString().c_str()) == 0); } @@ -162,15 +162,15 @@ void PeriodicTableWidget::disableAllElementButtons() { disableButtons(UnknownProperties); } void PeriodicTableWidget::ColourButton(QPushButton *element, - QString colourStr) { + const QString &colourStr) { element->setStyleSheet( "QPushButton{border:1px solid rgb(0, 0, 0); " + colourStr + ";}" + "QPushButton:checked{ background-color:rgb(175,255,255)}" + "QPushButton:!enabled{background-color: rgb(204,204,204);" + "}"); } -QString -PeriodicTableWidget::elementsSelectedToString(QVector<QPushButton *> elements) { +QString PeriodicTableWidget::elementsSelectedToString( + const QVector<QPushButton *> &elements) { QString selectedElements = ""; /* Loop through QPushButtons and if they are checked * then retrieve the text on the button i.e the diff --git a/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp b/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp index 77103e3563b03c4eb3d9de1ddcb1ecf4c0eb3c30..14a7f1f5d7a1580651beed9743d7f72e4474ac6a 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/SampleShapeHelpers.cpp @@ -150,7 +150,7 @@ QString PointGroupBox::write3DElement(const QString &elem_name) const { * @param right Right-hand side of binary operation * @returns A string representing the result of the operation on the arguments */ -QString Operation::toString(QString left, QString right) const { +QString Operation::toString(const QString &left, const QString &right) const { QString result; switch (binaryop) { // union diff --git a/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h b/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h index 89be6c9787b2fa9165fbff5cdecdaa85b0cbc1c2..4511192c88eea95a2adfaaecef31aa2c94804e39 100644 --- a/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h +++ b/qt/widgets/refdetectorview/inc/MantidQtWidgets/RefDetectorView/RefMatrixWSImageView.h @@ -29,10 +29,10 @@ class EXPORT_OPT_MANTIDQT_REFDETECTORVIEWER RefMatrixWSImageView { public: /// Construct an image viewer for the specifed MatrixWorkspace - RefMatrixWSImageView(Mantid::API::MatrixWorkspace_sptr /*mat_ws*/); + RefMatrixWSImageView(const Mantid::API::MatrixWorkspace_sptr & /*mat_ws*/); - RefMatrixWSImageView(QString wpsName, int peakMin, int peakMax, int backMin, - int backMax, int tofMin, int tofMax); + RefMatrixWSImageView(const QString &wpsName, int peakMin, int peakMax, + int backMin, int backMax, int tofMin, int tofMax); RefIVConnections *getConnections(); diff --git a/qt/widgets/refdetectorview/src/RefImageView.cpp b/qt/widgets/refdetectorview/src/RefImageView.cpp index ca2e6436143b64d053a3b66bc3a5ca7019eb96a2..340f279f244ea98ddd7ff17fbadd9211bed329bf 100644 --- a/qt/widgets/refdetectorview/src/RefImageView.cpp +++ b/qt/widgets/refdetectorview/src/RefImageView.cpp @@ -15,6 +15,7 @@ #include <sstream> #include <string> +#include <utility> namespace MantidQt { namespace RefDetectorViewer { @@ -89,7 +90,7 @@ RefImageView::RefImageView(SpectrumView::SpectrumDataSource_sptr dataSource, m_imageDisplay->updateImage(); iv_connections->peakBackTofRangeUpdate(); - m_imageDisplay->setDataSource(dataSource); + m_imageDisplay->setDataSource(std::move(dataSource)); } RefImageView::~RefImageView() { diff --git a/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp b/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp index 52febb1c0371ec1640cfdce8e457f4022f401c00..5db995cd442f44b4e7c0f8f777bbb807d8af828b 100644 --- a/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp +++ b/qt/widgets/refdetectorview/src/RefMatrixWSImageView.cpp @@ -21,7 +21,8 @@ using namespace Mantid::API; /** * Construct an ImageView for the specified matrix workspace */ -RefMatrixWSImageView::RefMatrixWSImageView(MatrixWorkspace_sptr /*mat_ws*/) +RefMatrixWSImageView::RefMatrixWSImageView( + const MatrixWorkspace_sptr & /*mat_ws*/) : m_imageView(nullptr) { return; // RefMatrixWSDataSource* source = new RefMatrixWSDataSource( mat_ws ); @@ -31,7 +32,7 @@ RefMatrixWSImageView::RefMatrixWSImageView(MatrixWorkspace_sptr /*mat_ws*/) // // is closed } -RefMatrixWSImageView::RefMatrixWSImageView(QString wpsName, int peakMin, +RefMatrixWSImageView::RefMatrixWSImageView(const QString &wpsName, int peakMin, int peakMax, int backMin, int backMax, int tofMin, int tofMax) { diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h index aa7d682618113315acbe838ac1a9a2d0fd2a76f5..611b695daa72389d55e5fa85ea572035e59138bc 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h @@ -92,7 +92,7 @@ public: /// Destructor ~CompositePeaksPresenter() override; /// Add a peaks presenter onto the composite. - void addPeaksPresenter(PeaksPresenter_sptr presenter); + void addPeaksPresenter(const PeaksPresenter_sptr &presenter); /// Get the number of subjects. size_t size() const; /// Clear the owned presenters. @@ -107,43 +107,46 @@ public: double getPeakSizeIntoProjection() const override; /// Enter peak edit mode. void peakEditMode(EditMode mode) override; - void - setForegroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor /*color*/); + void setForegroundColor( + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor & /*color*/); /// Change the background representation for the peaks of this workspace - void - setBackgroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor /*color*/); + void setBackgroundColor( + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor & /*color*/); /// Get the foreground colour corresponding to the workspace PeakViewColor getForegroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Get the background colour corresponding to the workspace PeakViewColor getBackgroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Determine if the background is shown or not. bool getShowBackground( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Get a copy of the palette in its current state. PeakPalette<PeakViewColor> getPalette() const; /// Setter for indicating whether the background radius will be shown. void setBackgroundRadiusShown( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, const bool shown); /// Remove the workspace and corresponding presenter. - void remove(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS); + void + remove(const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS); /// Hide these peaks in the plot. - void setShown(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, - const bool shown); + void + setShown(const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, + const bool shown); /// zoom in on a peak. - void zoomToPeak(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, - const int peakIndex); + void zoomToPeak( + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, + const int peakIndex); /// Get the named peaks presenter. PeaksPresenter *getPeaksPresenter(const QString &name); /// Register any owning presenter void registerOwningPresenter(UpdateableOnDemand *owner) override; /// Is the presenter hidden. - bool getIsHidden( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) const; + bool getIsHidden(const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> + &peaksWS) const; /// Perform update on demand void performUpdate() override; /// Zoom to the rectangle @@ -162,8 +165,9 @@ public: /// Determine if the presenter contents are different. bool contentsDifferent(PeaksPresenter const *other) const override; /// Enter the requested edit mode for the peaks workspace. - void editCommand(EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target); + void editCommand( + EditMode editMode, + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target); private: /// Updateable on demand method. @@ -179,10 +183,10 @@ private: bool useDefault() const { return m_subjects.size() == 0; } /// Get the presenter for a given workspace. SubjectContainer::iterator getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws); /// Get the presenter for a given workspace. SubjectContainer::const_iterator getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const; /// Get the presenter from a workspace name. SubjectContainer::iterator getPresenterIteratorFromName(const QString &name); /// Color palette diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h index ffa89dfef72aa7f0c78046afdb3c270a3511389a..867d6e2cee608e767e0b9a63df4d324c06e0a63c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ConcretePeaksPresenter.h @@ -36,9 +36,9 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER ConcretePeaksPresenter public: ConcretePeaksPresenter( PeakOverlayViewFactory_sptr viewFactory, - Mantid::API::IPeaksWorkspace_sptr peaksWS, - boost::shared_ptr<Mantid::API::MDGeometry> mdWS, - Mantid::Geometry::PeakTransformFactory_sptr transformFactory); + const Mantid::API::IPeaksWorkspace_sptr &peaksWS, + const boost::shared_ptr<Mantid::API::MDGeometry> &mdWS, + const Mantid::Geometry::PeakTransformFactory_sptr &transformFactory); void reInitialize(Mantid::API::IPeaksWorkspace_sptr peaksWS) override; ~ConcretePeaksPresenter() override; void setNonOrthogonal(bool nonOrthogonalEnabled) override; @@ -107,7 +107,7 @@ private: void produceViews(); /// Check workspace compatibilities. void checkWorkspaceCompatibilities( - boost::shared_ptr<Mantid::API::MDGeometry> mdWS); + const boost::shared_ptr<Mantid::API::MDGeometry> &mdWS); /// Find peaks interacting with the slice and update the view. void doFindPeaksInRegion(); /// make owner update. diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h index c953fecb6645cb03e9da48f5a6d3eb2e44ec67a7..3b9668f4ac581869624e6f80f27e7ca31bd7239b 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineOverlay.h @@ -92,7 +92,7 @@ private: int height() const; int width() const; - QRect drawHandle(QPainter &painter, QPointF coords, QColor brush); + QRect drawHandle(QPainter &painter, QPointF coords, const QColor &brush); void paintEvent(QPaintEvent *event) override; eHandleID mouseOverHandle(QPoint pos); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h index 9338f5749482b953598a7919742e53376e8195b3..9a367fbea56c47a7a9d8c40162f0bfccfb318453 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LinePlotOptions.h @@ -19,7 +19,7 @@ public: LinePlotOptions(QWidget *parent = nullptr, bool logScaleOption = false); ~LinePlotOptions() override; - void setOriginalWorkspace(Mantid::API::IMDWorkspace_sptr ws); + void setOriginalWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); int getPlotAxis() const; void setPlotAxis(int choice); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h index 36acf63665cd9c2612e7c4c6d4ac9c60c514a7a1..448a1dd234b1f40aecb4b7fc7fef10e8e9f214d9 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/LineViewer.h @@ -28,11 +28,11 @@ public: LineViewer(QWidget *parent = nullptr); ~LineViewer() override; - void setWorkspace(Mantid::API::IMDWorkspace_sptr ws); + void setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); void setFreeDimensions(bool all, int dimX, int dimY); - void setStart(Mantid::Kernel::VMD start); - void setEnd(Mantid::Kernel::VMD end); - void setThickness(Mantid::Kernel::VMD width); + void setStart(const Mantid::Kernel::VMD &start); + void setEnd(const Mantid::Kernel::VMD &end); + void setThickness(const Mantid::Kernel::VMD &width); void setPlanarWidth(double width); void setNumBins(int numBins); void setFixedBinWidthMode(bool fixedWidth, double binWidth); @@ -97,9 +97,9 @@ signals: private: Mantid::API::IAlgorithm_sptr - applyMDWorkspace(Mantid::API::IMDWorkspace_sptr ws); + applyMDWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); Mantid::API::IAlgorithm_sptr - applyMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws); + applyMatrixWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws); void setupScaleEngine(MantidQwtWorkspaceData &curveData); /// set the slice workspace from the ADS void setSliceWorkspace(const std::string &name); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h index 451284a726fcbb626ca1531d459a5d053ec8f140..5c8d363ae5b0a36e7ba0a451dd7a9a7f239be1a3 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/NonOrthogonalOverlay.h @@ -52,10 +52,10 @@ private: QPointF invTransform(QPoint pixels) const; void drawYLines(QPainter &painter, QPen &gridPen, int widthScreen, - QwtValueList yAxisTicks, double yAngle); + const QwtValueList &yAxisTicks, double yAngle); void drawXLines(QPainter &painter, QPen &gridPen, int heightScreen, - QwtValueList xAxisTicks, double xAngle); + const QwtValueList &xAxisTicks, double xAngle); void paintEvent(QPaintEvent *event) override; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h index dd7038bbfe94362155b04540d7ad5d569ea7c938..fc7eaf10c94e59eddf4ec2811b1d71e37604a54c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakBoundingBox.h @@ -104,7 +104,7 @@ public: /// Serialize as set of comma separated values std::string toExtentsString() const; /// Transform the box. - void transformBox(Mantid::Geometry::PeakTransform_sptr transform); + void transformBox(const Mantid::Geometry::PeakTransform_sptr &transform); /// Make a new box based on the slice PeakBoundingBox makeSliceBox(const double &sliceDelta) const; }; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h index 33f1aeedb77e696655148724271a9b7eb6b6c072..edfb0ea865660afdc4cb634643bd8e6c75996a7f 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h @@ -18,10 +18,10 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER PeakRepresentationEllipsoid : public PeakRepresentation { public: PeakRepresentationEllipsoid( - const Mantid::Kernel::V3D &origin, const std::vector<double> peakRadii, - const std::vector<double> backgroundInnerRadii, - const std::vector<double> backgroundOuterRadii, - const std::vector<Mantid::Kernel::V3D> directions, + const Mantid::Kernel::V3D &origin, const std::vector<double> &peakRadii, + const std::vector<double> &backgroundInnerRadii, + const std::vector<double> &backgroundOuterRadii, + const std::vector<Mantid::Kernel::V3D> &directions, std::shared_ptr<Mantid::SliceViewer::EllipsoidPlaneSliceCalculator> calculator); diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h index c10442a46ce52cddb599f43ec2877279660b0fd7..be320a3aa467d0c1987134ec963f213559b28a26 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewColor.h @@ -22,8 +22,9 @@ * New peak types will need to have a color entry registered here. */ struct PeakViewColor { - PeakViewColor(QColor colorCross = QColor(), QColor colorSphere = QColor(), - QColor colorEllipsoid = QColor()) + PeakViewColor(const QColor &colorCross = QColor(), + const QColor &colorSphere = QColor(), + const QColor &colorEllipsoid = QColor()) : colorCross(colorCross), colorSphere(colorSphere), colorEllipsoid(colorEllipsoid) {} diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h index 50103e19ce47da444217e228750e1055a409956a..4081b4e2b4a0573dcbfe355f57852ff6de0c7261 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeakViewFactory.h @@ -44,7 +44,7 @@ private: // Creates a cross-like representation PeakRepresentation_sptr createPeakRepresentationCross( Mantid::Kernel::V3D position, - Mantid::Geometry::PeakTransform_const_sptr transform) const; + const Mantid::Geometry::PeakTransform_const_sptr &transform) const; // Creates a spherical representation PeakRepresentation_sptr diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h index 2f43b597c351937e4bc533594d48146a120f13e7..5b1c3ee32f2d2aa08e53416da5e3926311ea29fc 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewer.h @@ -31,14 +31,15 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER PeaksViewer : public QWidget, public: PeaksViewer(QWidget *parent = nullptr); void setPeaksWorkspaces(const SetPeaksWorkspaces &workspaces); - void setPresenter(boost::shared_ptr<ProxyCompositePeaksPresenter> presenter); + void setPresenter( + const boost::shared_ptr<ProxyCompositePeaksPresenter> &presenter); void performUpdate() override; void updatePeaksWorkspace(const std::string &toName, boost::shared_ptr<const Mantid::API::IPeaksWorkspace> toWorkspace) override; bool removePeaksWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> toRemove); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &toRemove); bool removePeaksWorkspace(const std::string &toRemove); void hide(); ~PeaksViewer() override; @@ -61,7 +62,8 @@ public slots: void onBackgroundRadiusShown(Mantid::API::IPeaksWorkspace_const_sptr /*peaksWS*/, bool /*show*/); - void onRemoveWorkspace(Mantid::API::IPeaksWorkspace_const_sptr /*peaksWS*/); + void onRemoveWorkspace( + const Mantid::API::IPeaksWorkspace_const_sptr & /*peaksWS*/); void onHideInPlot(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, bool /*hide*/); void onZoomToPeak(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, @@ -82,8 +84,8 @@ private: /// Load a presented peaks workspace and settings from a project file void loadPresentedWorkspace(const std::string §ion); /// Save a presented peaks workspace and settings to a project file - std::string - savePresentedWorkspace(Mantid::API::IPeaksWorkspace_const_sptr ws) const; + std::string savePresentedWorkspace( + const Mantid::API::IPeaksWorkspace_const_sptr &ws) const; boost::shared_ptr<ProxyCompositePeaksPresenter> m_presenter; }; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h index 604913459cd39e84c3c85eb7389c26deeef23358..21514a8fabcb22b7e8289300437b53e045a589d2 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksViewerOverlayDialog.h @@ -20,7 +20,7 @@ class PeaksViewerOverlayDialog : public QDialog { Q_OBJECT public: - explicit PeaksViewerOverlayDialog(PeaksPresenter_sptr peaksPresenter, + explicit PeaksViewerOverlayDialog(const PeaksPresenter_sptr &peaksPresenter, QWidget *parent = nullptr); ~PeaksViewerOverlayDialog() override; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h index 88e6f5f5c0fdb5c0e7e092c5281f8b0310eee65a..1b71b2529991df19dad4c3b5aea0ed0bc9d2cb0c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/PeaksWorkspaceWidget.h @@ -37,7 +37,7 @@ public: void setHidden(bool isHidden); void setSelectedPeak(int index); std::string getWSName() const; - void workspaceUpdate(Mantid::API::IPeaksWorkspace_const_sptr ws = + void workspaceUpdate(const Mantid::API::IPeaksWorkspace_const_sptr &ws = Mantid::API::IPeaksWorkspace_const_sptr()); void exitClearPeaksMode(); void exitAddPeaksMode(); @@ -95,7 +95,7 @@ private slots: void onShowBackgroundChanged(bool /*show*/); void onRemoveWorkspaceClicked(); void onToggleHideInPlot(); - void onCurrentChanged(QModelIndex /*index*/, QModelIndex /*unused*/); + void onCurrentChanged(QModelIndex /*index*/, const QModelIndex & /*unused*/); void onClearPeaksToggled(bool /*on*/); void onAddPeaksToggled(bool /*on*/); }; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h index 3a75f574bed780373e479c6fcaeb5662063b7ee9..f0a774f2395c5dfa5aa682aa442973e19f9187dd 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h @@ -34,11 +34,11 @@ public: void setForegroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor /*color*/); + const PeakViewColor & /*color*/); /// Change the background representation for the peaks of this workspace void setBackgroundColor(boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor /*color*/); + const PeakViewColor & /*color*/); /// Get the foreground colour corresponding to the workspace PeakViewColor getForegroundPeakViewColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const; @@ -87,8 +87,9 @@ public: /// Get optional zoomed peak index. int getZoomedPeakIndex() const; /// Set the edit mode. - void editCommand(EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target); + void editCommand( + EditMode editMode, + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target); /// Set the peaks size within the current projection void setPeakSizeOnProjection(const double fraction); /// Set the peaks size into the current projection diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h index 571f76e1941d3457da16c6d097767f5a0ceab399..b8ec1b0e3525394af6ac45929afce673f5dfc39a 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QwtScaleDrawNonOrthogonal.h @@ -20,7 +20,7 @@ public: QwtScaleDrawNonOrthogonal( QwtPlot *plot, ScreenDimension screenDimension, - Mantid::API::IMDWorkspace_sptr workspace, size_t dimX, size_t dimY, + const Mantid::API::IMDWorkspace_sptr &workspace, size_t dimX, size_t dimY, Mantid::Kernel::VMD slicePoint, MantidQt::SliceViewer::NonOrthogonalOverlay *gridPlot); @@ -32,7 +32,8 @@ public: void updateSlicePoint(Mantid::Kernel::VMD newSlicepoint); private: - void setTransformationMatrices(Mantid::API::IMDWorkspace_sptr workspace); + void + setTransformationMatrices(const Mantid::API::IMDWorkspace_sptr &workspace); qreal getScreenBottomInXyz() const; qreal getScreenLeftInXyz() const; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h index d4fa335b3712844b3e0f46560f0f942e70fa0cbd..66628a84527da9ca140217fc34e4f16d561d41ed 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewer.h @@ -85,11 +85,11 @@ public: ~SliceViewer() override; void setWorkspace(const QString &wsName); - void setWorkspace(Mantid::API::IMDWorkspace_sptr ws); + void setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws); Mantid::API::IMDWorkspace_sptr getWorkspace(); void showControls(bool visible); void zoomBy(double factor); - void loadColorMap(QString filename = QString()); + void loadColorMap(const QString &filename = QString()); LineOverlay *getLineOverlay() { return m_lineOverlay; } Mantid::Kernel::VMD getSlicePoint() const { return m_slicePoint; } int getDimX() const; diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h index 31f29ddf333b0566997464217db5d278ff3f7030..f6d598531e6c11321abf2baa51c6b9786c13f320 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/SliceViewerWindow.h @@ -36,7 +36,7 @@ class EXPORT_OPT_MANTIDQT_SLICEVIEWER SliceViewerWindow public: SliceViewerWindow(const QString &wsName, const QString &label = QString(), - Qt::WindowFlags f = nullptr); + const Qt::WindowFlags &f = nullptr); ~SliceViewerWindow() override; MantidQt::SliceViewer::SliceViewer *getSlicer(); MantidQt::SliceViewer::LineViewer *getLiner(); @@ -66,7 +66,7 @@ protected slots: void closeWindow(); void updateWorkspace(); void slicerWorkspaceChanged(); - void changedSlicePoint(Mantid::Kernel::VMD /*slice*/); + void changedSlicePoint(const Mantid::Kernel::VMD & /*slice*/); void lineChanging(QPointF start, QPointF end, double width); void lineChanged(QPointF start, QPointF end, double width); void changeStartOrEnd(Mantid::Kernel::VMD /*start*/, diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h index 72cc991dab6370536fd51b8bb04bf5d8f3eb4a74..55c522ff6da335d25c67e0fd2fc47249a969bb4c 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/XYLimitsDialog.h @@ -23,8 +23,8 @@ public: XYLimitsDialog(QWidget *parent = nullptr); ~XYLimitsDialog() override; - void setXDim(Mantid::Geometry::IMDDimension_const_sptr dim); - void setYDim(Mantid::Geometry::IMDDimension_const_sptr dim); + void setXDim(const Mantid::Geometry::IMDDimension_const_sptr &dim); + void setYDim(const Mantid::Geometry::IMDDimension_const_sptr &dim); void setLimits(double x0, double x1, double y0, double y1); double getXMin(); double getXMax(); diff --git a/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp b/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp index bac9535472a3b82f67d46528b720440fd694adb6..c9f010b773f6b9eaf258cf994602cb1237be14a1 100644 --- a/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp +++ b/qt/widgets/sliceviewer/src/CompositePeaksPresenter.cpp @@ -7,6 +7,7 @@ #include "MantidQtWidgets/SliceViewer/CompositePeaksPresenter.h" #include "MantidAPI/IPeaksWorkspace.h" #include <stdexcept> +#include <utility> using Mantid::Geometry::PeakTransform_sptr; @@ -19,7 +20,8 @@ CompositePeaksPresenter::CompositePeaksPresenter( ZoomablePeaksView *const zoomablePlottingWidget, PeaksPresenter_sptr defaultPresenter) : m_zoomablePlottingWidget(zoomablePlottingWidget), - m_default(defaultPresenter), m_owner(nullptr), m_zoomedPeakIndex(-1) { + m_default(std::move(defaultPresenter)), m_owner(nullptr), + m_zoomedPeakIndex(-1) { if (m_zoomablePlottingWidget == nullptr) { throw std::runtime_error("Zoomable Plotting Widget is NULL"); } @@ -146,7 +148,8 @@ bool CompositePeaksPresenter::contentsDifferent( Add peaks presenter @param presenter : Subject peaks presenter */ -void CompositePeaksPresenter::addPeaksPresenter(PeaksPresenter_sptr presenter) { +void CompositePeaksPresenter::addPeaksPresenter( + const PeaksPresenter_sptr &presenter) { if (this->size() == 10) { throw std::invalid_argument("Maximum number of PeaksWorkspaces that can be " "simultaneously displayed is 10."); @@ -186,7 +189,7 @@ SetPeaksWorkspaces CompositePeaksPresenter::presentedWorkspaces() const { */ CompositePeaksPresenter::SubjectContainer::iterator CompositePeaksPresenter::getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) { SubjectContainer::iterator presenterFound = m_subjects.end(); for (auto presenterIterator = m_subjects.begin(); presenterIterator != m_subjects.end(); ++presenterIterator) { @@ -206,7 +209,7 @@ CompositePeaksPresenter::getPresenterIteratorFromWorkspace( */ CompositePeaksPresenter::SubjectContainer::const_iterator CompositePeaksPresenter::getPresenterIteratorFromWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { SubjectContainer::const_iterator presenterFound = m_subjects.end(); for (auto presenterIterator = m_subjects.begin(); presenterIterator != m_subjects.end(); ++presenterIterator) { @@ -226,9 +229,10 @@ Set the foreground colour of the peaks. @ colour to use for re-colouring */ void CompositePeaksPresenter::setForegroundColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor color) { - SubjectContainer::iterator iterator = getPresenterIteratorFromWorkspace(ws); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor &color) { + SubjectContainer::iterator iterator = + getPresenterIteratorFromWorkspace(std::move(ws)); // Update the palette the foreground colour const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); @@ -244,9 +248,10 @@ Set the background colour of the peaks. @ colour to use for re-colouring */ void CompositePeaksPresenter::setBackgroundColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - const PeakViewColor color) { - SubjectContainer::iterator iterator = getPresenterIteratorFromWorkspace(ws); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, + const PeakViewColor &color) { + SubjectContainer::iterator iterator = + getPresenterIteratorFromWorkspace(std::move(ws)); // Update the palette background colour. const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); @@ -279,13 +284,13 @@ PeakPalette<PeakViewColor> CompositePeaksPresenter::getPalette() const { @return the foreground colour corresponding to the peaks workspace. */ PeakViewColor CompositePeaksPresenter::getForegroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { if (useDefault()) { throw std::runtime_error("Foreground colours from palette cannot be " "fetched until nested presenters are added."); } SubjectContainer::const_iterator iterator = - getPresenterIteratorFromWorkspace(ws); + getPresenterIteratorFromWorkspace(std::move(ws)); const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); return m_palettePeakViewColor.foregroundIndexToColour(pos); } @@ -295,13 +300,13 @@ PeakViewColor CompositePeaksPresenter::getForegroundPeakViewColor( @return the background colour corresponding to the peaks workspace. */ PeakViewColor CompositePeaksPresenter::getBackgroundPeakViewColor( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { if (useDefault()) { throw std::runtime_error("Background colours from palette cannot be " "fetched until nested presenters are added."); } SubjectContainer::const_iterator iterator = - getPresenterIteratorFromWorkspace(ws); + getPresenterIteratorFromWorkspace(std::move(ws)); const int pos = static_cast<int>(std::distance(m_subjects.begin(), iterator)); return m_palettePeakViewColor.backgroundIndexToColour(pos); } @@ -313,12 +318,12 @@ PeakViewColor CompositePeaksPresenter::getBackgroundPeakViewColor( * @param shown : True to show. */ void CompositePeaksPresenter::setBackgroundRadiusShown( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws, const bool shown) { if (useDefault()) { return m_default->showBackgroundRadius(shown); } - auto iterator = getPresenterIteratorFromWorkspace(ws); + auto iterator = getPresenterIteratorFromWorkspace(std::move(ws)); (*iterator)->showBackgroundRadius(shown); } @@ -327,11 +332,11 @@ void CompositePeaksPresenter::setBackgroundRadiusShown( * @param peaksWS : Peaks list to remove. */ void CompositePeaksPresenter::remove( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS) { if (useDefault()) { return; } - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); if (iterator != m_subjects.end()) { m_subjects.erase(iterator); } @@ -346,12 +351,12 @@ void CompositePeaksPresenter::remove( * @param shown : True to show. */ void CompositePeaksPresenter::setShown( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, const bool shown) { if (useDefault()) { return m_default->setShown(shown); } - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); if (iterator == m_subjects.end()) return; @@ -367,9 +372,9 @@ void CompositePeaksPresenter::setShown( * @param peakIndex : Index of the peak in the peaks list to zoom into. */ void CompositePeaksPresenter::zoomToPeak( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS, const int peakIndex) { - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); auto subjectPresenter = *iterator; auto boundingBox = subjectPresenter->getBoundingBox(peakIndex); m_zoomablePlottingWidget->zoomToRectangle(boundingBox); @@ -460,13 +465,13 @@ double CompositePeaksPresenter::getPeakSizeIntoProjection() const { * @return */ bool CompositePeaksPresenter::getShowBackground( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &ws) const { if (useDefault()) { throw std::runtime_error("Get show background cannot be fetched until " "nested presenters are added."); } SubjectContainer::const_iterator iterator = - getPresenterIteratorFromWorkspace(ws); + getPresenterIteratorFromWorkspace(std::move(ws)); return (*iterator)->getShowBackground(); } @@ -478,7 +483,7 @@ private: public: explicit MatchWorkspaceName(const QString &name) : m_wsName(name) {} - bool operator()(SetPeaksWorkspaces::value_type ws) { + bool operator()(const SetPeaksWorkspaces::value_type &ws) { const std::string &wsName = ws->getName(); const std::string toMatch = m_wsName.toStdString(); const bool result = (wsName == toMatch); @@ -557,7 +562,7 @@ private: public: explicit MatchPointer(PeaksPresenter *toFind) : m_toFind(toFind) {} - bool operator()(PeaksPresenter_sptr candidate) { + bool operator()(const PeaksPresenter_sptr &candidate) { return candidate.get() == m_toFind; } }; @@ -594,8 +599,9 @@ void CompositePeaksPresenter::zoomToPeak(PeaksPresenter *const presenter, * @return True if hidden. */ bool CompositePeaksPresenter::getIsHidden( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) const { - auto iterator = getPresenterIteratorFromWorkspace(peaksWS); + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &peaksWS) + const { + auto iterator = getPresenterIteratorFromWorkspace(std::move(peaksWS)); auto subjectPresenter = *iterator; return subjectPresenter->isHidden(); } @@ -630,7 +636,7 @@ int CompositePeaksPresenter::getZoomedPeakIndex() const { void CompositePeaksPresenter::editCommand( EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target) { + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target) { if (auto ws = target.lock()) { // Change the right subject to the desired edit mode. diff --git a/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp b/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp index db85bdd976fc69233026b52d05f13ac4709b90f6..5aab97492e8d88558a9c3e29d527d733e4a381ce 100644 --- a/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp +++ b/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp @@ -21,6 +21,7 @@ #include "MantidQtWidgets/SliceViewer/UpdateableOnDemand.h" #include "MantidQtWidgets/SliceViewer/ZoomableOnDemand.h" #include <boost/regex.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -78,7 +79,7 @@ void ConcretePeaksPresenter::produceViews() { * @param mdWS : MDWorkspace currently plotted. */ void ConcretePeaksPresenter::checkWorkspaceCompatibilities( - boost::shared_ptr<Mantid::API::MDGeometry> mdWS) { + const boost::shared_ptr<Mantid::API::MDGeometry> &mdWS) { if (auto imdWS = boost::dynamic_pointer_cast<Mantid::API::IMDWorkspace>(mdWS)) { const SpecialCoordinateSystem coordSystMD = @@ -135,10 +136,11 @@ void ConcretePeaksPresenter::checkWorkspaceCompatibilities( interpreting the MODEL. */ ConcretePeaksPresenter::ConcretePeaksPresenter( - PeakOverlayViewFactory_sptr viewFactory, IPeaksWorkspace_sptr peaksWS, - boost::shared_ptr<MDGeometry> mdWS, - Mantid::Geometry::PeakTransformFactory_sptr transformFactory) - : m_viewFactory(viewFactory), m_peaksWS(peaksWS), + PeakOverlayViewFactory_sptr viewFactory, + const IPeaksWorkspace_sptr &peaksWS, + const boost::shared_ptr<MDGeometry> &mdWS, + const Mantid::Geometry::PeakTransformFactory_sptr &transformFactory) + : m_viewFactory(std::move(viewFactory)), m_peaksWS(peaksWS), m_transformFactory(transformFactory), m_transform(transformFactory->createDefaultTransform()), m_slicePoint(), m_owningPresenter(nullptr), m_isHidden(false), @@ -159,7 +161,7 @@ ConcretePeaksPresenter::ConcretePeaksPresenter( m_axisData.fromHklToXyz[8] = 1.0; // Check that the workspaces appear to be compatible. Log if otherwise. - checkWorkspaceCompatibilities(mdWS); + checkWorkspaceCompatibilities(std::move(mdWS)); this->initialize(); } diff --git a/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp b/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp index c4f21af99616e08a7988687a614d70aaf3dc85b1..cf5abdf884a40cda4159db37cf9570e9918443a9 100644 --- a/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp +++ b/qt/widgets/sliceviewer/src/DimensionSliceWidget.cpp @@ -9,6 +9,7 @@ #include "MantidQtWidgets/Common/QStringUtils.h" #include <QLayout> #include <iosfwd> +#include <utility> namespace MantidQt { using API::toQStringInternal; @@ -179,7 +180,7 @@ void DimensionSliceWidget::setMinMax(double min, double max) { /** Set the dimension to display */ void DimensionSliceWidget::setDimension( int index, Mantid::Geometry::IMDDimension_const_sptr dim) { - m_dim = dim; + m_dim = std::move(dim); m_dimIndex = index; // set the limits of the slider to be the bin centres and not // the edges of the bins diff --git a/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp b/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp index 91cbe5e151f0bb2fef05e1e4107c6e070a6b9da3..f1d8b04f6a697bff1d10ef0823e8fa42fefb8a2f 100644 --- a/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp +++ b/qt/widgets/sliceviewer/src/EllipsoidPlaneSliceCalculator.cpp @@ -9,6 +9,8 @@ #include <algorithm> #include <cmath> +#include <utility> + /** * * The functions in this file intend to calculate the paramters of an ellipse @@ -94,8 +96,8 @@ namespace { * @param zVal: the z value (in the ellipse frame) * @return the origin of the ellipse */ -Mantid::Kernel::V3D getOrigin(Mantid::Kernel::DblMatrix AInverse, - Mantid::Kernel::DblMatrix B, +Mantid::Kernel::V3D getOrigin(const Mantid::Kernel::DblMatrix &AInverse, + const Mantid::Kernel::DblMatrix &B, Mantid::Kernel::V3D originEllipsoid, double zVal) { const auto multiplied = AInverse * B; @@ -167,16 +169,17 @@ getEigenVectorsForEllipse(const Mantid::Kernel::DblMatrix &MM, * @return radii and directions */ EigenSystemEllipse getAxesInformation(Mantid::Kernel::DblMatrix A, - Mantid::Kernel::DblMatrix AInverse, - Mantid::Kernel::DblMatrix B, - Mantid::Kernel::DblMatrix BT, double c) { + const Mantid::Kernel::DblMatrix &AInverse, + const Mantid::Kernel::DblMatrix &B, + const Mantid::Kernel::DblMatrix &BT, + double c) { // Calculate the denominator: (Transpose[B]*A^(-1)*B/4 - (c-1)) const auto temp1 = AInverse * B; const auto temp2 = BT * temp1; const auto denominator = 0.25 * temp2[0][0] - c + 1; // Calculate the MM matrix: A/(Transpose[B]*A^(-1)*B/4 - (c-1)) - auto MM = A; + auto MM = std::move(A); MM /= denominator; // Calculate the Eigenvalues: since we are dealing with EVs of a @@ -234,7 +237,8 @@ SliceEllipseInfo EllipsoidPlaneSliceCalculator::getSlicePlaneInfo( std::vector<Mantid::Kernel::V3D> directions, std::vector<double> radii, Mantid::Kernel::V3D originEllipsoid, double zPlane) const { // Setup the Ellipsoid Matrix - auto m = createEllipsoidMatrixInXYZFrame(directions, radii); + auto m = + createEllipsoidMatrixInXYZFrame(std::move(directions), std::move(radii)); auto isEllipsoid = checkIfIsEllipse(m); diff --git a/qt/widgets/sliceviewer/src/LineOverlay.cpp b/qt/widgets/sliceviewer/src/LineOverlay.cpp index 2ccd3c96939fb0af7acd1d2cb1e78b924b274302..5b2591c9968dda3b0c1f125cae2d645ff230513a 100644 --- a/qt/widgets/sliceviewer/src/LineOverlay.cpp +++ b/qt/widgets/sliceviewer/src/LineOverlay.cpp @@ -240,7 +240,8 @@ QPointF LineOverlay::snap(QPointF original) const { //---------------------------------------------------------------------------------------------- /** Draw a handle (for dragging) at the given plot coordinates */ -QRect LineOverlay::drawHandle(QPainter &painter, QPointF coords, QColor brush) { +QRect LineOverlay::drawHandle(QPainter &painter, QPointF coords, + const QColor &brush) { int size = 8; QPoint center = transform(coords); QRect marker(center.x() - size / 2, center.y() - size / 2, size, size); diff --git a/qt/widgets/sliceviewer/src/LinePlotOptions.cpp b/qt/widgets/sliceviewer/src/LinePlotOptions.cpp index 5c48a5f89b9cfa93823e0e132c7a99a25833d2ed..adb9a72406a749ee17bd91ca2eb1afc4f1fd02c5 100644 --- a/qt/widgets/sliceviewer/src/LinePlotOptions.cpp +++ b/qt/widgets/sliceviewer/src/LinePlotOptions.cpp @@ -64,7 +64,8 @@ void LinePlotOptions::addPlotRadioButton(const std::string &text, //------------------------------------------------------------------------------ /** Set the original workspace, to show the axes plot choice */ -void LinePlotOptions::setOriginalWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +void LinePlotOptions::setOriginalWorkspace( + const Mantid::API::IMDWorkspace_sptr &ws) { if (!ws) return; diff --git a/qt/widgets/sliceviewer/src/LineViewer.cpp b/qt/widgets/sliceviewer/src/LineViewer.cpp index 084a6c933b2ab1f2a55cfb490e1c61985a94d669..66c1b8e0351ffd63b561b31b05a24e4b1c749206 100644 --- a/qt/widgets/sliceviewer/src/LineViewer.cpp +++ b/qt/widgets/sliceviewer/src/LineViewer.cpp @@ -75,8 +75,8 @@ Mantid::Kernel::Logger g_log("LineViewer"); * @param width : Default thickness (for non integrated dimensions) * @param thicknesses : Thickness vector to write to */ -void setThicknessUsingDimensionInfo(IMDWorkspace_sptr ws, size_t dimIndex, - double width, +void setThicknessUsingDimensionInfo(const IMDWorkspace_sptr &ws, + size_t dimIndex, double width, Mantid::Kernel::VMD &thicknesses) { auto currentDim = ws->getDimension(dimIndex); if (currentDim->getIsIntegrated()) { @@ -328,7 +328,7 @@ void LineViewer::readTextboxes() { * @param ws :: MatrixWorkspace to integrate */ IAlgorithm_sptr -LineViewer::applyMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { +LineViewer::applyMatrixWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws) { // (half-width in the plane) const double planeWidth = getPlanarWidth(); @@ -409,7 +409,7 @@ LineViewer::applyMatrixWorkspace(Mantid::API::MatrixWorkspace_sptr ws) { * @return the algorithm to run */ IAlgorithm_sptr -LineViewer::applyMDWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +LineViewer::applyMDWorkspace(const Mantid::API::IMDWorkspace_sptr &ws) { bool adaptive = ui.chkAdaptiveBins->isChecked(); // (half-width in the plane) @@ -706,7 +706,7 @@ bool LineViewer::getFixedBinWidthMode() const { return m_fixedBinWidthMode; } /** Set the workspace being sliced * * @param ws :: IMDWorkspace */ -void LineViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +void LineViewer::setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws) { if (!ws) throw std::runtime_error("LineViewer::setWorkspace(): Invalid workspace."); m_initFreeDimX = -1; @@ -720,7 +720,7 @@ void LineViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws) { /** Set the start point of the line to integrate * @param start :: vector for the start point */ -void LineViewer::setStart(Mantid::Kernel::VMD start) { +void LineViewer::setStart(const Mantid::Kernel::VMD &start) { if (m_ws && start.getNumDims() != m_ws->getNumDims()) throw std::runtime_error("LineViewer::setStart(): Invalid number of " "dimensions in the start vector."); @@ -730,7 +730,7 @@ void LineViewer::setStart(Mantid::Kernel::VMD start) { /** Set the end point of the line to integrate * @param end :: vector for the end point */ -void LineViewer::setEnd(Mantid::Kernel::VMD end) { +void LineViewer::setEnd(const Mantid::Kernel::VMD &end) { if (m_ws && end.getNumDims() != m_ws->getNumDims()) throw std::runtime_error("LineViewer::setEnd(): Invalid number of " "dimensions in the end vector."); @@ -741,7 +741,7 @@ void LineViewer::setEnd(Mantid::Kernel::VMD end) { /** Set the width of the line in each dimensions * @param width :: vector for the width in each dimension. X dimension stands in * for the XY plane width */ -void LineViewer::setThickness(Mantid::Kernel::VMD width) { +void LineViewer::setThickness(const Mantid::Kernel::VMD &width) { if (m_ws && width.getNumDims() != m_ws->getNumDims()) throw std::runtime_error("LineViewer::setThickness(): Invalid number of " "dimensions in the width vector."); diff --git a/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp b/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp index 95b5cb431eeb55dd1453b201ade3131bc5485f2c..b809c442f2ce1afd6c97de4ef57b6cda754a4623 100644 --- a/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp +++ b/qt/widgets/sliceviewer/src/NonOrthogonalOverlay.cpp @@ -127,7 +127,8 @@ void NonOrthogonalOverlay::paintEvent(QPaintEvent * /*event*/) { } void NonOrthogonalOverlay::drawYLines(QPainter &painter, QPen &gridPen, - int widthScreen, QwtValueList yAxisTicks, + int widthScreen, + const QwtValueList &yAxisTicks, double yAngle) { auto offset = yAngle == 0. ? 0. : widthScreen * tan(yAngle); @@ -141,7 +142,8 @@ void NonOrthogonalOverlay::drawYLines(QPainter &painter, QPen &gridPen, } void NonOrthogonalOverlay::drawXLines(QPainter &painter, QPen &gridPen, - int heightScreen, QwtValueList xAxisTicks, + int heightScreen, + const QwtValueList &xAxisTicks, double xAngle) { xAngle *= -1.f; auto offset = xAngle == 0. ? 0. : heightScreen * tan(xAngle); diff --git a/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp b/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp index c200d724c7e4e3d2e06c4968aecb6640cf5a1959..39a844e5f9a2c419a7ad254b6a6b303612704dfa 100644 --- a/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp +++ b/qt/widgets/sliceviewer/src/PeakBoundingBox.cpp @@ -213,7 +213,7 @@ std::string PeakBoundingBox::toExtentsString() const { * @param transform : Transform to use. */ void PeakBoundingBox::transformBox( - Mantid::Geometry::PeakTransform_sptr transform) { + const Mantid::Geometry::PeakTransform_sptr &transform) { using Mantid::Kernel::V3D; // Front bottom left V3D newBottomLeft = diff --git a/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp b/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp index fd496f5154e0f42a2f083fda05fd03e2b4b03388..03b75fc1c4767a693a6d5bbcb19bc07169cf491e 100644 --- a/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp +++ b/qt/widgets/sliceviewer/src/PeakRepresentationEllipsoid.cpp @@ -14,6 +14,7 @@ Mantid::Kernel::Logger g_log("PeakRepresentation"); } #include <QPainter> +#include <utility> namespace { @@ -62,10 +63,10 @@ namespace SliceViewer { const double PeakRepresentationEllipsoid::zeroRadius = 0.0; PeakRepresentationEllipsoid::PeakRepresentationEllipsoid( - const Mantid::Kernel::V3D &origin, const std::vector<double> peakRadii, - const std::vector<double> backgroundInnerRadii, - const std::vector<double> backgroundOuterRadii, - const std::vector<Mantid::Kernel::V3D> directions, + const Mantid::Kernel::V3D &origin, const std::vector<double> &peakRadii, + const std::vector<double> &backgroundInnerRadii, + const std::vector<double> &backgroundOuterRadii, + const std::vector<Mantid::Kernel::V3D> &directions, std::shared_ptr<Mantid::SliceViewer::EllipsoidPlaneSliceCalculator> calculator) : m_originalOrigin(origin), m_originalDirections(directions), @@ -73,7 +74,7 @@ PeakRepresentationEllipsoid::PeakRepresentationEllipsoid( m_backgroundInnerRadii(backgroundInnerRadii), m_backgroundOuterRadii(backgroundOuterRadii), m_opacityMax(0.8), m_opacityMin(0.0), m_cachedOpacityAtDistance(0.0), m_angleEllipse(-1.0), - m_showBackgroundRadii(false), m_calculator(calculator) { + m_showBackgroundRadii(false), m_calculator(std::move(calculator)) { // Get projection lengths onto the xyz axes of the ellipsoid axes auto projections = Mantid::SliceViewer::getProjectionLengths( directions, backgroundOuterRadii); diff --git a/qt/widgets/sliceviewer/src/PeakView.cpp b/qt/widgets/sliceviewer/src/PeakView.cpp index e0c121610fad8cdae47c3c2b3f6bdecd8ccf487a..ae6d3a6c97bfa72921e5adf911d56e1172acc7ad 100644 --- a/qt/widgets/sliceviewer/src/PeakView.cpp +++ b/qt/widgets/sliceviewer/src/PeakView.cpp @@ -8,6 +8,8 @@ #include "MantidQtWidgets/SliceViewer/SliceViewer.h" #include <QPainter> +#include <utility> + #include <qwt_double_interval.h> #include <qwt_plot.h> #include <qwt_scale_div.h> @@ -24,7 +26,8 @@ PeakView::PeakView(PeaksPresenter *const presenter, QwtPlot *plot, : PeakOverlayInteractive(presenter, plot, plotXIndex, plotYIndex, parent), m_peaks(vecPeakRepresentation), m_cachedOccupancyIntoView(0.015), m_cachedOccupancyInView(0.015), m_showBackground(false), - m_foregroundColor(foregroundColor), m_backgroundColor(backgroundColor), + m_foregroundColor(std::move(foregroundColor)), + m_backgroundColor(std::move(backgroundColor)), m_largestEffectiveRadius(largestEffectiveRadius) {} PeakView::~PeakView() {} diff --git a/qt/widgets/sliceviewer/src/PeakViewFactory.cpp b/qt/widgets/sliceviewer/src/PeakViewFactory.cpp index d48e7cb24b1168813c82f4278bcd4ce9318536c6..402ccb0c30b937c0a07e8cd74d73815accadacec 100644 --- a/qt/widgets/sliceviewer/src/PeakViewFactory.cpp +++ b/qt/widgets/sliceviewer/src/PeakViewFactory.cpp @@ -4,7 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + -#include "MantidQtWidgets/SliceViewer/PeakViewFactory.h" +#include <utility> + #include "MantidDataObjects/PeakShapeEllipsoid.h" #include "MantidDataObjects/PeakShapeSpherical.h" #include "MantidGeometry/Crystal/IPeak.h" @@ -17,6 +18,7 @@ #include "MantidQtWidgets/SliceViewer/PeakRepresentationEllipsoid.h" #include "MantidQtWidgets/SliceViewer/PeakRepresentationSphere.h" #include "MantidQtWidgets/SliceViewer/PeakView.h" +#include "MantidQtWidgets/SliceViewer/PeakViewFactory.h" namespace { struct ZMinAndMax { @@ -24,8 +26,9 @@ struct ZMinAndMax { double zMin; }; -ZMinAndMax getZMinAndMax(Mantid::API::IMDWorkspace_sptr workspace, - Mantid::Geometry::PeakTransform_const_sptr transform) { +ZMinAndMax +getZMinAndMax(const Mantid::API::IMDWorkspace_sptr &workspace, + const Mantid::Geometry::PeakTransform_const_sptr &transform) { double zMax = 0.0; double zMin = 0.0; const auto numberOfDimensions = workspace->getNumDims(); @@ -79,7 +82,7 @@ PeakViewFactory::PeakViewFactory(Mantid::API::IMDWorkspace_sptr mdWS, const size_t colorNumber) : PeakOverlayViewFactoryBase(plot, parent, plotXIndex, plotYIndex, colorNumber), - m_mdWS(mdWS), m_peaksWS(peaksWS), + m_mdWS(std::move(mdWS)), m_peaksWS(std::move(peaksWS)), m_calculator(std::make_shared< Mantid::SliceViewer::EllipsoidPlaneSliceCalculator>()) { setForegroundAndBackgroundColors(colorNumber); @@ -127,15 +130,16 @@ PeakRepresentation_sptr PeakViewFactory::createSinglePeakRepresentation( Mantid::DataObjects::PeakShapeEllipsoid::ellipsoidShapeName()) { peakRepresentation = createPeakRepresentationEllipsoid(position, peak); } else { - peakRepresentation = createPeakRepresentationCross(position, transform); + peakRepresentation = + createPeakRepresentationCross(position, std::move(transform)); } return peakRepresentation; } PeakRepresentation_sptr PeakViewFactory::createPeakRepresentationCross( Mantid::Kernel::V3D position, - Mantid::Geometry::PeakTransform_const_sptr transform) const { - const auto zMinAndMax = getZMinAndMax(m_mdWS, transform); + const Mantid::Geometry::PeakTransform_const_sptr &transform) const { + const auto zMinAndMax = getZMinAndMax(m_mdWS, std::move(transform)); return std::make_shared<PeakRepresentationCross>(position, zMinAndMax.zMax, zMinAndMax.zMin); } diff --git a/qt/widgets/sliceviewer/src/PeaksViewer.cpp b/qt/widgets/sliceviewer/src/PeaksViewer.cpp index 1331feeaca96cb24d5475fdaf943e2ab869a7918..2c673a4fe642516e856a4b44f89aae64e24881b7 100644 --- a/qt/widgets/sliceviewer/src/PeaksViewer.cpp +++ b/qt/widgets/sliceviewer/src/PeaksViewer.cpp @@ -14,6 +14,7 @@ #include "MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h" #include <QBoxLayout> #include <QLayoutItem> +#include <utility> namespace MantidQt { namespace SliceViewer { @@ -49,7 +50,7 @@ void removeLayout(QWidget *widget) { * @param presenter : Proxy through which all information can be fetched. */ void PeaksViewer::setPresenter( - boost::shared_ptr<ProxyCompositePeaksPresenter> presenter) { + const boost::shared_ptr<ProxyCompositePeaksPresenter> &presenter) { m_presenter = presenter; m_presenter->registerView(this); @@ -317,7 +318,7 @@ std::string PeaksViewer::saveToProject() const { * @return the state of the presented peaks workspace as a project file string */ std::string PeaksViewer::savePresentedWorkspace( - Mantid::API::IPeaksWorkspace_const_sptr ws) const { + const Mantid::API::IPeaksWorkspace_const_sptr &ws) const { API::TSVSerialiser tsv; tsv.writeLine("Name") << ws->getName(); tsv.writeLine("ShowBackground") << m_presenter->getShowBackground(ws); @@ -345,7 +346,7 @@ std::string PeaksViewer::savePresentedWorkspace( */ void PeaksViewer::onPeakColorChanged( Mantid::API::IPeaksWorkspace_const_sptr peaksWS, PeakViewColor newColor) { - m_presenter->setForegroundColor(peaksWS, newColor); + m_presenter->setForegroundColor(std::move(peaksWS), std::move(newColor)); } /** @@ -355,7 +356,7 @@ void PeaksViewer::onPeakColorChanged( */ void PeaksViewer::onBackgroundColorChanged( Mantid::API::IPeaksWorkspace_const_sptr peaksWS, PeakViewColor newColor) { - m_presenter->setBackgroundColor(peaksWS, newColor); + m_presenter->setBackgroundColor(std::move(peaksWS), std::move(newColor)); } /** @@ -365,7 +366,7 @@ void PeaksViewer::onBackgroundColorChanged( */ void PeaksViewer::onBackgroundRadiusShown( Mantid::API::IPeaksWorkspace_const_sptr peaksWS, bool show) { - m_presenter->setBackgroundRadiusShown(peaksWS, show); + m_presenter->setBackgroundRadiusShown(std::move(peaksWS), show); } /** @@ -373,8 +374,8 @@ void PeaksViewer::onBackgroundRadiusShown( * @param peaksWS : Workspace to remove */ void PeaksViewer::onRemoveWorkspace( - Mantid::API::IPeaksWorkspace_const_sptr peaksWS) { - this->removePeaksWorkspace(peaksWS); + const Mantid::API::IPeaksWorkspace_const_sptr &peaksWS) { + this->removePeaksWorkspace(std::move(peaksWS)); } /** @@ -384,7 +385,7 @@ void PeaksViewer::onRemoveWorkspace( */ void PeaksViewer::onHideInPlot(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, bool hide) { - m_presenter->hideInPlot(peaksWS, hide); + m_presenter->hideInPlot(std::move(peaksWS), hide); } /** @@ -394,7 +395,7 @@ void PeaksViewer::onHideInPlot(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, */ void PeaksViewer::onZoomToPeak(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, int peakIndex) { - m_presenter->zoomToPeak(peaksWS, peakIndex); + m_presenter->zoomToPeak(std::move(peaksWS), peakIndex); } /** @@ -476,7 +477,7 @@ void PeaksViewer::updatePeaksWorkspace( } bool PeaksViewer::removePeaksWorkspace( - boost::shared_ptr<const Mantid::API::IPeaksWorkspace> toRemove) { + const boost::shared_ptr<const Mantid::API::IPeaksWorkspace> &toRemove) { bool somethingToRemove = false; if (m_presenter) { diff --git a/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp b/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp index c12e0d3dfba6d9d5e92b40613d136f86bf2e424c..a77f05cca5463e159261d97b38ede3433306cf49 100644 --- a/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp +++ b/qt/widgets/sliceviewer/src/PeaksViewerOverlayDialog.cpp @@ -62,7 +62,7 @@ QString formattedPercentageValue(double fraction) { * @param parent : Parent widget */ PeaksViewerOverlayDialog::PeaksViewerOverlayDialog( - PeaksPresenter_sptr peaksPresenter, QWidget *parent) + const PeaksPresenter_sptr &peaksPresenter, QWidget *parent) : QDialog(parent), ui(new Ui::PeaksViewerOverlayDialog), m_peaksPresenter(peaksPresenter) { ui->setupUi(this); diff --git a/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp b/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp index 8a413595174034b2774f9e2282cf3f07b62dc1ca..79b501194736ece7aad46cc205093f5a387404d3 100644 --- a/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp +++ b/qt/widgets/sliceviewer/src/PeaksWorkspaceWidget.cpp @@ -12,6 +12,7 @@ #include <QColorDialog> #include <QPlastiqueStyle> #include <QSortFilterProxyModel> +#include <utility> namespace { QColor getSelectedColor() { @@ -40,9 +41,10 @@ PeaksWorkspaceWidget::PeaksWorkspaceWidget( const std::string &coordinateSystem, PeakViewColor defaultForegroundPeakViewColor, PeakViewColor defaultBackgroundPeakViewColor, PeaksViewer *parent) - : QWidget(parent), m_ws(ws), m_coordinateSystem(coordinateSystem), - m_foregroundPeakViewColor(defaultForegroundPeakViewColor), - m_backgroundPeakViewColor(defaultBackgroundPeakViewColor), + : QWidget(parent), m_ws(std::move(ws)), + m_coordinateSystem(coordinateSystem), + m_foregroundPeakViewColor(std::move(defaultForegroundPeakViewColor)), + m_backgroundPeakViewColor(std::move(defaultBackgroundPeakViewColor)), m_parent(parent) { ui.setupUi(this); @@ -340,7 +342,7 @@ std::string PeaksWorkspaceWidget::getWSName() const { * @param ws : Workspace to redisplay with */ void PeaksWorkspaceWidget::workspaceUpdate( - Mantid::API::IPeaksWorkspace_const_sptr ws) { + const Mantid::API::IPeaksWorkspace_const_sptr &ws) { // Only if we provide a peaks workspace for replacement. if (ws) { m_ws = ws; @@ -360,7 +362,7 @@ void PeaksWorkspaceWidget::workspaceUpdate( * @param index : Index of the table newly selected */ void PeaksWorkspaceWidget::onCurrentChanged(QModelIndex index, - QModelIndex /*unused*/) { + const QModelIndex & /*unused*/) { if (index.isValid()) { index = m_tableModel->mapToSource(index); emit zoomToPeak(this->m_ws, index.row()); diff --git a/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp b/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp index 348deaac6ab0848f4744ffe2594d258625f71116..69bd6210919ff953902976891626780e7c320d92 100644 --- a/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp +++ b/qt/widgets/sliceviewer/src/ProxyCompositePeaksPresenter.cpp @@ -4,6 +4,8 @@ // NScD Oak Ridge National Laboratory, European Spallation Source, // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + +#include <utility> + #include "MantidQtWidgets/SliceViewer/ProxyCompositePeaksPresenter.h" namespace MantidQt { @@ -13,7 +15,7 @@ Constructor */ ProxyCompositePeaksPresenter::ProxyCompositePeaksPresenter( boost::shared_ptr<CompositePeaksPresenter> composite) - : m_compositePresenter(composite), m_updateableView(nullptr) { + : m_compositePresenter(std::move(composite)), m_updateableView(nullptr) { m_compositePresenter->registerOwningPresenter(this); } @@ -44,8 +46,8 @@ Set the foreground colour of the peaks. */ void ProxyCompositePeaksPresenter::setForegroundColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor color) { - m_compositePresenter->setForegroundColor(ws, color); + const PeakViewColor &color) { + m_compositePresenter->setForegroundColor(std::move(ws), std::move(color)); } /** @@ -55,23 +57,23 @@ Set the background colour of the peaks. */ void ProxyCompositePeaksPresenter::setBackgroundColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, - PeakViewColor color) { - m_compositePresenter->setBackgroundColor(ws, color); + const PeakViewColor &color) { + m_compositePresenter->setBackgroundColor(std::move(ws), std::move(color)); } PeakViewColor ProxyCompositePeaksPresenter::getBackgroundPeakViewColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { - return m_compositePresenter->getBackgroundPeakViewColor(ws); + return m_compositePresenter->getBackgroundPeakViewColor(std::move(ws)); } PeakViewColor ProxyCompositePeaksPresenter::getForegroundPeakViewColor( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { - return m_compositePresenter->getForegroundPeakViewColor(ws); + return m_compositePresenter->getForegroundPeakViewColor(std::move(ws)); } bool ProxyCompositePeaksPresenter::getShowBackground( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws) const { - return m_compositePresenter->getShowBackground(ws); + return m_compositePresenter->getShowBackground(std::move(ws)); } /** @@ -91,24 +93,24 @@ std::string ProxyCompositePeaksPresenter::getTransformName() const { void ProxyCompositePeaksPresenter::setBackgroundRadiusShown( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> ws, const bool shown) { - m_compositePresenter->setBackgroundRadiusShown(ws, shown); + m_compositePresenter->setBackgroundRadiusShown(std::move(ws), shown); } void ProxyCompositePeaksPresenter::remove( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) { - m_compositePresenter->remove(peaksWS); + m_compositePresenter->remove(std::move(peaksWS)); } void ProxyCompositePeaksPresenter::hideInPlot( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const bool hide) { - m_compositePresenter->setShown(peaksWS, !hide); + m_compositePresenter->setShown(std::move(peaksWS), !hide); } void ProxyCompositePeaksPresenter::zoomToPeak( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS, const int peakIndex) { - m_compositePresenter->zoomToPeak(peaksWS, peakIndex); + m_compositePresenter->zoomToPeak(std::move(peaksWS), peakIndex); } PeaksPresenter * @@ -132,7 +134,7 @@ void ProxyCompositePeaksPresenter::updatePeaksWorkspace( bool ProxyCompositePeaksPresenter::getIsHidden( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) const { - return m_compositePresenter->getIsHidden(peaksWS); + return m_compositePresenter->getIsHidden(std::move(peaksWS)); } void ProxyCompositePeaksPresenter::registerView( @@ -151,8 +153,8 @@ int ProxyCompositePeaksPresenter::getZoomedPeakIndex() const { void ProxyCompositePeaksPresenter::editCommand( EditMode editMode, - boost::weak_ptr<const Mantid::API::IPeaksWorkspace> target) { - m_compositePresenter->editCommand(editMode, target); + const boost::weak_ptr<const Mantid::API::IPeaksWorkspace> &target) { + m_compositePresenter->editCommand(editMode, std::move(target)); } void ProxyCompositePeaksPresenter::setPeakSizeOnProjection( diff --git a/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp b/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp index 0def403617738e297aa798e0936ee27047d6a0a5..0e7d10697dd8a5aa1b76b620023cd4dbf3c98015 100644 --- a/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp +++ b/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp @@ -14,6 +14,7 @@ #include "MantidKernel/InstrumentInfo.h" #include <QString> #include <boost/lexical_cast.hpp> +#include <utility> using namespace Mantid::API; using namespace Mantid::Geometry; @@ -152,7 +153,7 @@ Constructor */ QPeaksTableModel::QPeaksTableModel( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) - : QAbstractTableModel(nullptr), m_peaksWS(peaksWS) { + : QAbstractTableModel(nullptr), m_peaksWS(std::move(peaksWS)) { m_columnNameMap = {{0, RUNNUMBER}, {1, DETID}, {2, H}, @@ -264,7 +265,7 @@ void QPeaksTableModel::setPeaksWorkspace( boost::shared_ptr<const Mantid::API::IPeaksWorkspace> peaksWS) { beginResetModel(); emit layoutAboutToBeChanged(); - m_peaksWS = peaksWS; + m_peaksWS = std::move(peaksWS); emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); emit layoutChanged(); endResetModel(); diff --git a/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp b/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp index bf424782861eaa0f6b4f9eb9c3e5d5b70b7a9eba..f06198fa22f82401a2a3b15a1f344602bb61792d 100644 --- a/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp +++ b/qt/widgets/sliceviewer/src/QwtScaleDrawNonOrthogonal.cpp @@ -15,18 +15,19 @@ #include <QMatrix> #include <QPainter> #include <QPalette> +#include <utility> QwtScaleDrawNonOrthogonal::QwtScaleDrawNonOrthogonal( QwtPlot *plot, ScreenDimension screenDimension, - Mantid::API::IMDWorkspace_sptr workspace, size_t dimX, size_t dimY, + const Mantid::API::IMDWorkspace_sptr &workspace, size_t dimX, size_t dimY, Mantid::Kernel::VMD slicePoint, MantidQt::SliceViewer::NonOrthogonalOverlay *gridPlot) : m_fromHklToXyz({{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}}), m_fromXyzToHkl({{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}}), m_plot(plot), m_screenDimension(screenDimension), m_dimX(dimX), - m_dimY(dimY), m_slicePoint(slicePoint), m_gridPlot(gridPlot) { + m_dimY(dimY), m_slicePoint(std::move(slicePoint)), m_gridPlot(gridPlot) { // Set up the transformation matrix - setTransformationMatrices(workspace); + setTransformationMatrices(std::move(workspace)); // Set up the angles // set the angles for the two dimensions @@ -289,7 +290,7 @@ QwtScaleDrawNonOrthogonal::fromHklToXyz(const Mantid::Kernel::VMD &hkl) const { } void QwtScaleDrawNonOrthogonal::setTransformationMatrices( - Mantid::API::IMDWorkspace_sptr workspace) { + const Mantid::API::IMDWorkspace_sptr &workspace) { m_missingDimension = MantidQt::API::getMissingHKLDimensionIndex(workspace, m_dimX, m_dimY); @@ -315,5 +316,5 @@ qreal QwtScaleDrawNonOrthogonal::getScreenLeftInXyz() const { void QwtScaleDrawNonOrthogonal::updateSlicePoint( Mantid::Kernel::VMD newSlicepoint) { - m_slicePoint = newSlicepoint; + m_slicePoint = std::move(newSlicepoint); } diff --git a/qt/widgets/sliceviewer/src/SliceViewer.cpp b/qt/widgets/sliceviewer/src/SliceViewer.cpp index fe03b73ec689caa37688622398d8026f99fe8e21..1569f9d4b7b7a79b439590040c378426f97de889 100644 --- a/qt/widgets/sliceviewer/src/SliceViewer.cpp +++ b/qt/widgets/sliceviewer/src/SliceViewer.cpp @@ -750,7 +750,7 @@ void SliceViewer::switchQWTRaster(bool useNonOrthogonal) { * * @param ws :: IMDWorkspace to show. */ -void SliceViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws) { +void SliceViewer::setWorkspace(const Mantid::API::IMDWorkspace_sptr &ws) { struct ScopedFlag { explicit ScopedFlag(bool &b) : m_flag(b) { m_flag = true; } ~ScopedFlag() { m_flag = false; } @@ -913,7 +913,7 @@ Mantid::API::IMDWorkspace_sptr SliceViewer::getWorkspace() { return m_ws; } * * @param filename :: file to open; empty to ask via a dialog box. */ -void SliceViewer::loadColorMap(QString filename) { +void SliceViewer::loadColorMap(const QString &filename) { QString fileselection; if (filename.isEmpty()) { fileselection = MantidColorMap::chooseColorMap(m_currentColorMapFile, this); diff --git a/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp b/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp index 04b7ca66e87973130c90bd80d0e46cf59ba4811e..12ebfdbaf3c70de2f18eb552aaae8b079301b10c 100644 --- a/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp +++ b/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp @@ -37,7 +37,8 @@ namespace SliceViewer { * @return */ SliceViewerWindow::SliceViewerWindow(const QString &wsName, - const QString &label, Qt::WindowFlags f) + const QString &label, + const Qt::WindowFlags &f) : QMainWindow(nullptr, f), WorkspaceObserver(), m_lastLinerWidth(0), m_lastPeaksViewerWidth(0) { @@ -372,7 +373,7 @@ void SliceViewerWindow::lineChanged(QPointF start2D, QPointF end2D, /** Slot called when changing the slice point of the 2D view * (keeping the line in the same 2D point) */ -void SliceViewerWindow::changedSlicePoint(Mantid::Kernel::VMD slice) { +void SliceViewerWindow::changedSlicePoint(const Mantid::Kernel::VMD &slice) { UNUSED_ARG(slice); setLineViewerValues(m_slicer->getLineOverlay()->getPointA(), m_slicer->getLineOverlay()->getPointB(), diff --git a/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp b/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp index 35a4a5436ee005ea5b375215ac87e08181f0c8d6..af4f1d35411b1cb54d3a4ab1304821b74c1e4a94 100644 --- a/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp +++ b/qt/widgets/sliceviewer/src/XYLimitsDialog.cpp @@ -27,14 +27,16 @@ XYLimitsDialog::~XYLimitsDialog() {} //------------------------------------------------------------------------------------------ /** Set the labels for the X dimensions * @param dim : IMDDimension */ -void XYLimitsDialog::setXDim(Mantid::Geometry::IMDDimension_const_sptr dim) { +void XYLimitsDialog::setXDim( + const Mantid::Geometry::IMDDimension_const_sptr &dim) { ui.lblXName->setText(QString::fromStdString(dim->getName())); ui.lblXUnits->setText(toQStringInternal(dim->getUnits().utf8())); } /** Set the labels for the Y dimensions * @param dim : IMDDimension */ -void XYLimitsDialog::setYDim(Mantid::Geometry::IMDDimension_const_sptr dim) { +void XYLimitsDialog::setYDim( + const Mantid::Geometry::IMDDimension_const_sptr &dim) { ui.lblYName->setText(QString::fromStdString(dim->getName())); ui.lblYUnits->setText(toQStringInternal(dim->getUnits().utf8())); } diff --git a/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h b/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h index cdc4686369f98a3d7bd3554b2a67b15938e783cd..ba7f4afd37513fe3206a254facdffebe0ad31e29 100644 --- a/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h +++ b/qt/widgets/sliceviewer/test/ConcretePeaksPresenterTest.h @@ -22,6 +22,7 @@ #include <boost/make_shared.hpp> #include <cxxtest/TestSuite.h> #include <string> +#include <utility> using namespace MantidQt::SliceViewer; using namespace Mantid::API; @@ -50,7 +51,7 @@ class ConcretePeaksPresenterTest : public CxxTest::TestSuite { } /// Helper method to create a mock MDDimension. - IMDDimension_sptr createExpectedMDDimension(const std::string returnLabel) { + IMDDimension_sptr createExpectedMDDimension(const std::string &returnLabel) { auto *pDim = new NiceMock<MockIMDDimension>; IMDDimension_sptr dim(pDim); EXPECT_CALL(*pDim, getName()).WillRepeatedly(Return(returnLabel)); @@ -100,12 +101,16 @@ class ConcretePeaksPresenterTest : public CxxTest::TestSuite { } void withViewFactory(PeakOverlayViewFactory_sptr val) { - m_viewFactory = val; + m_viewFactory = std::move(val); + } + void withPeaksWorkspace(IPeaksWorkspace_sptr val) { + m_peaksWS = std::move(val); + } + void withMDWorkspace(boost::shared_ptr<MDGeometry> val) { + m_mdWS = std::move(val); } - void withPeaksWorkspace(IPeaksWorkspace_sptr val) { m_peaksWS = val; } - void withMDWorkspace(boost::shared_ptr<MDGeometry> val) { m_mdWS = val; } void withTransformFactory(PeakTransformFactory_sptr val) { - m_transformFactory = val; + m_transformFactory = std::move(val); } ConcretePeaksPresenter_sptr create() { diff --git a/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h b/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h index 6d58882e1b3e1d7355cb0e6cafd713168373756b..bef73f4f1a6f31f066c8740ede13a9f54fbc3ef5 100644 --- a/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h +++ b/qt/widgets/sliceviewer/test/PeakRepresentationEllipsoidTest.h @@ -10,6 +10,8 @@ #include "MockObjects.h" #include <cxxtest/TestSuite.h> +#include <utility> + using namespace MantidQt::SliceViewer; using namespace testing; @@ -34,12 +36,12 @@ public: const Mantid::Kernel::V3D &origin, const std::vector<double> &peakRadius, const std::vector<double> &backgroundInnerRadius, const std::vector<double> &backgroundOuterRadius, - const std::vector<Mantid::Kernel::V3D> directions, + const std::vector<Mantid::Kernel::V3D> &directions, std::shared_ptr<Mantid::SliceViewer::EllipsoidPlaneSliceCalculator> calculator) : PeakRepresentationEllipsoid(origin, peakRadius, backgroundInnerRadius, backgroundOuterRadius, directions, - calculator) + std::move(calculator)) {} std::shared_ptr<PeakPrimitives> getDrawingInformationWrapper( diff --git a/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h b/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h index dff6162d9e878750847564c282a9337833fbd59c..50d77e46b41fd9b8d4671e4550748873e099e468 100644 --- a/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h +++ b/qt/widgets/sliceviewer/test/SliceViewerFunctionsTest.h @@ -38,7 +38,7 @@ SliceDefinition get_slice_definition(const size_t numberOfDimensions, std::vector<Mantid::Geometry::MDHistoDimension_sptr> get_dimensions_collection( const size_t numberOfDimensions, const Mantid::Kernel::VMD_t minValue, - const Mantid::Kernel::VMD_t maxValue, const std::string sliceLies) { + const Mantid::Kernel::VMD_t maxValue, const std::string &sliceLies) { std::vector<Mantid::Geometry::MDHistoDimension_sptr> dimensions( numberOfDimensions); @@ -75,7 +75,7 @@ std::vector<Mantid::Geometry::MDHistoDimension_sptr> get_dimensions_collection( class SliceViewerFunctionsTest : public CxxTest::TestSuite { public: bool do_test_slice_lies_in_workspace_boundaries( - const std::string sliceLiesWithinWorkspaceBoundary) { + const std::string &sliceLiesWithinWorkspaceBoundary) { // Arrange const size_t numberOfDimensions = 3; Mantid::Kernel::VMD_t minValue = 1; diff --git a/qt/widgets/sliceviewer/test/SliceViewerPythonInterfaceTest.py b/qt/widgets/sliceviewer/test/SliceViewerPythonInterfaceTest.py index 683242097f5494185352fa9a14ddc25a9811c173..26c70a5f0bc8eb872cd9d961343f5ac25ec6eca9 100644 --- a/qt/widgets/sliceviewer/test/SliceViewerPythonInterfaceTest.py +++ b/qt/widgets/sliceviewer/test/SliceViewerPythonInterfaceTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import sys import sys import os diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h index 57ee73206d72983f3032779f5c504a910641fecf..9b8e7ca0fd2878efbf3947999d7a7994bd2086da 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/MatrixWSDataSource.h @@ -41,7 +41,7 @@ class EXPORT_OPT_MANTIDQT_SPECTRUMVIEWER MatrixWSDataSource : public SpectrumDataSource { public: /// Construct a DataSource object around the specifed MatrixWorkspace - MatrixWSDataSource(Mantid::API::MatrixWorkspace_const_sptr matWs); + MatrixWSDataSource(const Mantid::API::MatrixWorkspace_const_sptr &matWs); ~MatrixWSDataSource() override; diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h index 08b0dfbcba772ecc5da337ee769dfa9d83b315b8..65c07eb21b42a279ee8d5fee33a994219a491cf9 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SliderHandler.h @@ -36,7 +36,8 @@ public: SpectrumDataSource_sptr dataSource) override; /// Configure the image scrollbars for the specified drawing area - void reConfigureSliders(QRect drawArea, SpectrumDataSource_sptr dataSource); + void reConfigureSliders(QRect drawArea, + const SpectrumDataSource_sptr &dataSource); /// Configure the horizontal scrollbar to cover the specified range void configureHSlider(int nDataSteps, int nPixels) override; diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h index ec79009e063e32d59c5961b1219b100fcab478ee..9afb272f8e8390540d7e1fa50833248e037975b3 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumPlotItem.h @@ -37,7 +37,7 @@ public: ~SpectrumPlotItem() override; /// Specify the data to be plotted and the color table to use - void setData(DataArray_const_sptr dataArray, + void setData(const DataArray_const_sptr &dataArray, std::vector<QRgb> *positiveColorTable, std::vector<QRgb> *negativeColorTable); diff --git a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h index 5dc7dc559b315dcdb5c25198a4f0c4a8047dc913..bbc286f57ce40da916cc835fe00b77d1ef0632b8 100644 --- a/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h +++ b/qt/widgets/spectrumviewer/inc/MantidQtWidgets/SpectrumViewer/SpectrumView.h @@ -56,7 +56,7 @@ public: SpectrumView(QWidget *parent = nullptr); ~SpectrumView() override; - void renderWorkspace(Mantid::API::MatrixWorkspace_const_sptr wksp); + void renderWorkspace(const Mantid::API::MatrixWorkspace_const_sptr &wksp); void renderWorkspace(const QString &wsName); QList<boost::shared_ptr<SpectrumDisplay>> getSpectrumDisplays() const { return m_spectrumDisplay; diff --git a/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp b/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp index ae9c8910e860ea6e3aca36628152aa815a2f8e6b..8323d504ba7496ef8bc0499e2367c8541429d984 100644 --- a/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp @@ -5,6 +5,7 @@ // Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS // SPDX - License - Identifier: GPL - 3.0 + #include <cmath> +#include <utility> #include "MantidQtWidgets/SpectrumViewer/ArrayDataSource.h" #include "MantidQtWidgets/SpectrumViewer/SVUtils.h" @@ -38,7 +39,7 @@ ArrayDataSource::ArrayDataSource(double m_totalXMin, double m_totalXMax, std::vector<float> data) : SpectrumDataSource(m_totalXMin, m_totalXMax, m_totalYMin, m_totalYMax, m_totalRows, m_totalCols), - m_data(data) {} + m_data(std::move(data)) {} ArrayDataSource::~ArrayDataSource() {} diff --git a/qt/widgets/spectrumviewer/src/GraphDisplay.cpp b/qt/widgets/spectrumviewer/src/GraphDisplay.cpp index cb9ce8bdecfb99cb9ae5d82a3906a6a9f92b0173..69768e395e82b52a70f5c625fba64052a1758e25 100644 --- a/qt/widgets/spectrumviewer/src/GraphDisplay.cpp +++ b/qt/widgets/spectrumviewer/src/GraphDisplay.cpp @@ -13,6 +13,8 @@ #include <QString> #include <QVector> #include <boost/algorithm/clamp.hpp> +#include <utility> + #include <qwt_scale_engine.h> namespace MantidQt { @@ -56,7 +58,7 @@ GraphDisplay::~GraphDisplay() { clearCurves(); } * the table. */ void GraphDisplay::setDataSource(SpectrumDataSource_sptr dataSource) { - m_dataSource = dataSource; + m_dataSource = std::move(dataSource); } /** diff --git a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp index 03a4824cdc7f085800105a69c326aa8d72cedec7..125f79a9b1274abf39bda2c6786094c5e4729b7e 100644 --- a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp @@ -46,7 +46,7 @@ namespace SpectrumView { * * @param matWs Shared pointer to the matrix workspace being "wrapped" */ -MatrixWSDataSource::MatrixWSDataSource(MatrixWorkspace_const_sptr matWs) +MatrixWSDataSource::MatrixWSDataSource(const MatrixWorkspace_const_sptr &matWs) : SpectrumDataSource(0.0, 1.0, 0.0, 1.0, 0, 0), m_matWs(matWs), m_emodeHandler(nullptr), m_spectrumInfo(m_matWs->spectrumInfo()) { m_totalXMin = matWs->getXMin(); diff --git a/qt/widgets/spectrumviewer/src/SliderHandler.cpp b/qt/widgets/spectrumviewer/src/SliderHandler.cpp index 8537256237f5f2375b40de0ea276b25f4ac1b5b6..90c5d1b58e01bc275535671eb8afd546f1122c55 100644 --- a/qt/widgets/spectrumviewer/src/SliderHandler.cpp +++ b/qt/widgets/spectrumviewer/src/SliderHandler.cpp @@ -27,8 +27,8 @@ SliderHandler::SliderHandler(Ui_SpectrumViewer *svUI) * be drawn * @param dataSource SpectrumDataSource that provides the data to be drawn */ -void SliderHandler::reConfigureSliders(QRect drawArea, - SpectrumDataSource_sptr dataSource) { +void SliderHandler::reConfigureSliders( + QRect drawArea, const SpectrumDataSource_sptr &dataSource) { QScrollBar *vScroll = m_svUI->imageVerticalScrollBar; int oldVValue = vScroll->value(); diff --git a/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp b/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp index a0a6741ca1ae3b2e66c56bc6490e72ed8e9ce97b..c4b581760c948ba5351adae53f3a573dd91d5e86 100644 --- a/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp +++ b/qt/widgets/spectrumviewer/src/SpectrumDisplay.cpp @@ -10,6 +10,8 @@ #include <QImage> #include <QString> #include <QVector> +#include <utility> + #include <qwt_scale_engine.h> #include "MantidQtWidgets/SpectrumViewer/ColorMaps.h" @@ -97,7 +99,7 @@ void SpectrumDisplay::setupSpectrumPlotItem() { * and information for the table. */ void SpectrumDisplay::setDataSource(SpectrumDataSource_sptr dataSource) { - m_dataSource = dataSource; + m_dataSource = std::move(dataSource); m_hGraphDisplay->setDataSource(m_dataSource); m_vGraphDisplay->setDataSource(m_dataSource); diff --git a/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp b/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp index 6cfb788c6803432b8fb974c270eb03bf2325100f..1404950528c973d5c051801baef2f9d69536e7e7 100644 --- a/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp +++ b/qt/widgets/spectrumviewer/src/SpectrumPlotItem.cpp @@ -35,7 +35,7 @@ SpectrumPlotItem::~SpectrumPlotItem() {} * must have the same number of entries as the * positive color table. */ -void SpectrumPlotItem::setData(DataArray_const_sptr dataArray, +void SpectrumPlotItem::setData(const DataArray_const_sptr &dataArray, std::vector<QRgb> *positiveColorTable, std::vector<QRgb> *negativeColorTable) { if (m_bufferID == 0) { diff --git a/qt/widgets/spectrumviewer/src/SpectrumView.cpp b/qt/widgets/spectrumviewer/src/SpectrumView.cpp index 33daff0127b470427feb260e0d8f9e6d8949da75..c185ec691367d33a23c6c4556d6874dfd4c4bada 100644 --- a/qt/widgets/spectrumviewer/src/SpectrumView.cpp +++ b/qt/widgets/spectrumviewer/src/SpectrumView.cpp @@ -99,7 +99,7 @@ void SpectrumView::resizeEvent(QResizeEvent *event) { * @param wksp The matrix workspace to render */ void SpectrumView::renderWorkspace( - Mantid::API::MatrixWorkspace_const_sptr wksp) { + const Mantid::API::MatrixWorkspace_const_sptr &wksp) { // Handle rendering of a workspace we already track if (replaceExistingWorkspace(wksp->getName(), wksp)) diff --git a/scripts/AbinsModules/AbinsConstants.py b/scripts/AbinsModules/AbinsConstants.py index ef9c931b2cd410abf2167171daf1b5b4bbf91303..cecccd7235ac6da8eafc5037e1602eff888e1cb2 100644 --- a/scripts/AbinsModules/AbinsConstants.py +++ b/scripts/AbinsModules/AbinsConstants.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import math import numpy as np from scipy import constants diff --git a/scripts/AbinsModules/AbinsData.py b/scripts/AbinsModules/AbinsData.py index 9f2136dbe1256059aa804185e7028ec1b6e2953d..a4b57b0fae7e806a9a5f969dd2eae95654ec5547 100644 --- a/scripts/AbinsModules/AbinsData.py +++ b/scripts/AbinsModules/AbinsData.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import AbinsModules diff --git a/scripts/AbinsModules/AbinsTestHelpers.py b/scripts/AbinsModules/AbinsTestHelpers.py index a1a052e7e9acad531cf8ca4521d9d0cd9f6af9be..f6fc2a952c9d193ae5ab654e978afee50a92e648 100644 --- a/scripts/AbinsModules/AbinsTestHelpers.py +++ b/scripts/AbinsModules/AbinsTestHelpers.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os diff --git a/scripts/AbinsModules/AtomsData.py b/scripts/AbinsModules/AtomsData.py index 74b5a0d3e68e934df8ebc966b86a11b7bf417ce3..1b987dd369d67fd1e4ac4ceac4c07618cba03b8d 100644 --- a/scripts/AbinsModules/AtomsData.py +++ b/scripts/AbinsModules/AtomsData.py @@ -4,9 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np -import six import AbinsModules @@ -52,7 +50,7 @@ class AtomsData(AbinsModules.GeneralData): # "sort" sort = item["sort"] - if not (isinstance(sort, six.integer_types) or np.issubdtype(sort.dtype, np.integer)): + if not (isinstance(sort, int) or np.issubdtype(sort.dtype, np.integer)): raise ValueError("Parameter sort should be integer.") if sort < 0: raise ValueError("Parameter sort cannot be negative.") diff --git a/scripts/AbinsModules/CalculateDWSingleCrystal.py b/scripts/AbinsModules/CalculateDWSingleCrystal.py index 01d15b67d0989e3f3578d5f9bdae3a042a91c08e..8299c92fd46d7743ba98b812391bbc7f64f5a590 100644 --- a/scripts/AbinsModules/CalculateDWSingleCrystal.py +++ b/scripts/AbinsModules/CalculateDWSingleCrystal.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np # Abins modules diff --git a/scripts/AbinsModules/CalculatePowder.py b/scripts/AbinsModules/CalculatePowder.py index 9448b023d0c2988486593e4bd4761c22c68bb77b..291fe748b16fc3205f0e77e5517b487a9762279f 100644 --- a/scripts/AbinsModules/CalculatePowder.py +++ b/scripts/AbinsModules/CalculatePowder.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import AbinsModules from AbinsModules import AbinsParameters diff --git a/scripts/AbinsModules/CalculateS.py b/scripts/AbinsModules/CalculateS.py index 9a6bb5eed0452657954e339729b6b04110d3bcca..5b7e3a19422622ee1460747a92359592f60de33c 100644 --- a/scripts/AbinsModules/CalculateS.py +++ b/scripts/AbinsModules/CalculateS.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import AbinsModules diff --git a/scripts/AbinsModules/CalculateSingleCrystal.py b/scripts/AbinsModules/CalculateSingleCrystal.py index 86ed8f595eb41bbcc8a50e2f3c0e44ef03e7b012..6ef6bcb6a83f506bfda4a02a2aab7120c805542d 100644 --- a/scripts/AbinsModules/CalculateSingleCrystal.py +++ b/scripts/AbinsModules/CalculateSingleCrystal.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import AbinsModules diff --git a/scripts/AbinsModules/DWSingleCrystalData.py b/scripts/AbinsModules/DWSingleCrystalData.py index 0efbf26b03408fb8555da7c065167f659275889f..cd342fb1f57713478a4c99d7c832079d967878ab 100644 --- a/scripts/AbinsModules/DWSingleCrystalData.py +++ b/scripts/AbinsModules/DWSingleCrystalData.py @@ -4,10 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np -import six - # Abins modules import AbinsModules @@ -28,7 +25,7 @@ class DWSingleCrystalData(AbinsModules.GeneralData): else: raise ValueError("Improper value of temperature.") - if isinstance(num_atoms, six.integer_types) and num_atoms > 0: + if isinstance(num_atoms, int) and num_atoms > 0: self._num_atoms = num_atoms else: raise ValueError("Improper number of atoms.") @@ -71,7 +68,7 @@ class DWSingleCrystalData(AbinsModules.GeneralData): :param data: Debye-Waller factor to check :param atom: number of atom """ - if not isinstance(atom, six.integer_types): + if not isinstance(atom, int): raise ValueError("Number of atom should be an integer.") if atom < 0 or atom > self._num_atoms: # here we count from zero raise ValueError("Invalid number of atom.") diff --git a/scripts/AbinsModules/FrequencyPowderGenerator.py b/scripts/AbinsModules/FrequencyPowderGenerator.py index 3620b00934860ba56ee7ae628ce635b55d6f9b1e..cf8c4a0f727f729fb51a0bb473da95767b5e0aaa 100644 --- a/scripts/AbinsModules/FrequencyPowderGenerator.py +++ b/scripts/AbinsModules/FrequencyPowderGenerator.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import AbinsModules diff --git a/scripts/AbinsModules/GeneralAbInitioParser.py b/scripts/AbinsModules/GeneralAbInitioParser.py index 8556d246b6dcb4c12d58bd73b676ca9a1ff60e09..b31d3738cea909b7bb121ff2d78322f30d062fc5 100644 --- a/scripts/AbinsModules/GeneralAbInitioParser.py +++ b/scripts/AbinsModules/GeneralAbInitioParser.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -import six import re import AbinsModules @@ -29,11 +26,10 @@ class GeneralAbInitioParser(object): This string will be compiled to a Python re.Pattern . :type regex: str """ - if not six.PY2: - if msg is not None: - msg = bytes(msg, "utf8") - if regex is not None: - regex = bytes(regex, "utf8") + if msg is not None: + msg = bytes(msg, "utf8") + if regex is not None: + regex = bytes(regex, "utf8") if msg and regex: raise ValueError("msg or regex should be provided, not both") @@ -59,8 +55,7 @@ class GeneralAbInitioParser(object): :param file_obj: file object from which we read :param msg: keyword to find """ - if not six.PY2: - msg = bytes(msg, "utf8") + msg = bytes(msg, "utf8") found = False last_entry = None @@ -103,8 +98,7 @@ class GeneralAbInitioParser(object): pos = file_obj.tell() line = file_obj.readline() file_obj.seek(pos) - if not six.PY2: - item = bytes(item, "utf8") + item = bytes(item, "utf8") if item in line: return True return False @@ -115,8 +109,7 @@ class GeneralAbInitioParser(object): :param file_obj: file object from which we read :param msg: keyword to find """ - if not six.PY2: - msg = bytes(msg, "utf8") + msg = bytes(msg, "utf8") while not self.file_end(file_obj=file_obj): pos = file_obj.tell() line = file_obj.readline() diff --git a/scripts/AbinsModules/GeneralAbInitioProgram.py b/scripts/AbinsModules/GeneralAbInitioProgram.py index b44d55dcac0024541f60925d985da1719f44b5a6..022e149ae17e68f3b699df4772cbcdcee3f0b73a 100644 --- a/scripts/AbinsModules/GeneralAbInitioProgram.py +++ b/scripts/AbinsModules/GeneralAbInitioProgram.py @@ -4,10 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import logger import AbinsModules -import six from mantid.kernel import Atom @@ -17,8 +15,7 @@ class GeneralAbInitioProgramName(type): # noinspection PyMethodMayBeStatic -@six.add_metaclass(GeneralAbInitioProgramName) -class GeneralAbInitioProgram(object): +class GeneralAbInitioProgram(object, metaclass=GeneralAbInitioProgramName): """ A general class which groups all methods which should be inherited or implemented by an ab initio program used in INS analysis. diff --git a/scripts/AbinsModules/GeneralData.py b/scripts/AbinsModules/GeneralData.py index f5e0deccecdee187c802625910b7b8720dcba8f9..2c2c56d97e480eb36cf09ceecc55662ed722db1c 100644 --- a/scripts/AbinsModules/GeneralData.py +++ b/scripts/AbinsModules/GeneralData.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class GeneralData(object): diff --git a/scripts/AbinsModules/GeneralLoadAbInitioTester.py b/scripts/AbinsModules/GeneralLoadAbInitioTester.py index a1775656b91177b213f0929ce02b08e92a8dfe44..a27fe6d8f92db3cd228b583450add3f337b64d9f 100644 --- a/scripts/AbinsModules/GeneralLoadAbInitioTester.py +++ b/scripts/AbinsModules/GeneralLoadAbInitioTester.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import AbinsModules import json import numpy as np diff --git a/scripts/AbinsModules/IOmodule.py b/scripts/AbinsModules/IOmodule.py index 008843815b4fbf043e62eea4e2b728604fc2d1db..14bc7e64e5fce1775bc16bdfd890c29bcf8c77eb 100644 --- a/scripts/AbinsModules/IOmodule.py +++ b/scripts/AbinsModules/IOmodule.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import hashlib import io import json import os -import six import subprocess import shutil import h5py @@ -301,28 +299,6 @@ class IOmodule(object): end = reversed_path.find("/") return reversed_path[:end] - @classmethod - def _convert_unicode_to_str(cls, object_to_check): - """ - Converts unicode to Python str, works for nested dicts and lists (recursive algorithm). Only required - for Python 2 where a mismatch with unicode/str objects is a problem for dictionary lookup - - :param object_to_check: dictionary, or list with names which should be converted from unicode to string. - """ - if six.PY2: - if isinstance(object_to_check, list): - object_to_check = list(map(cls._convert_unicode_to_str, object_to_check)) - - elif isinstance(object_to_check, dict): - return {cls._encode_utf8_if_text(key): cls._convert_unicode_to_str(value) - for key, value in object_to_check.items()} - - # unicode element - elif isinstance(object_to_check, six.text_type): - object_to_check = cls._encode_utf8_if_text(object_to_check) - - return object_to_check - @staticmethod def _encode_utf8_if_text(item): """ @@ -332,7 +308,7 @@ class IOmodule(object): :param item: item to convert to unicode str if Python 2 str :returns: laundered item """ - if isinstance(item, six.text_type): + if isinstance(item, str): return item.encode('utf-8') else: return item @@ -364,11 +340,9 @@ class IOmodule(object): structured_dataset_list.append( self._recursively_load_dict_contents_from_group(hdf_file=hdf_file, path=hdf_group.name + "/%s" % item)) - return self._convert_unicode_to_str(structured_dataset_list) + return structured_dataset_list else: - return self._convert_unicode_to_str( - self._recursively_load_dict_contents_from_group(hdf_file=hdf_file, - path=hdf_group.name + "/")) + return self._recursively_load_dict_contents_from_group(hdf_file=hdf_file, path=hdf_group.name + "/") @classmethod def _recursively_load_dict_contents_from_group(cls, hdf_file=None, path=None): diff --git a/scripts/AbinsModules/InstrumentProducer.py b/scripts/AbinsModules/InstrumentProducer.py index 551c71e97164a9b3a4a0b13c381e59258d80eedd..01e5ea544562cc3a9d5628699c2cf1c87be34c86 100644 --- a/scripts/AbinsModules/InstrumentProducer.py +++ b/scripts/AbinsModules/InstrumentProducer.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from AbinsModules.Instruments import ToscaInstrument from AbinsModules import AbinsConstants diff --git a/scripts/AbinsModules/Instruments/Broadening.py b/scripts/AbinsModules/Instruments/Broadening.py index 843e55ab28a29a13196933cf425f1a1c8dd5096c..4ea2d6b151cef52c5e22354d338340fe4c594391 100644 --- a/scripts/AbinsModules/Instruments/Broadening.py +++ b/scripts/AbinsModules/Instruments/Broadening.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from scipy.special import erf from scipy.signal import convolve diff --git a/scripts/AbinsModules/Instruments/Instrument.py b/scripts/AbinsModules/Instruments/Instrument.py index 02c7887a6c99895a94502ec8b96ec18cc8942d27..1bfdb5d19e3d9237fb8d7fff7aadd295fcf47c4c 100644 --- a/scripts/AbinsModules/Instruments/Instrument.py +++ b/scripts/AbinsModules/Instruments/Instrument.py @@ -4,10 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) +# noinspection PyPep8Naming -# noinspection PyPep8Naming class Instrument(object): _name = None diff --git a/scripts/AbinsModules/Instruments/ToscaInstrument.py b/scripts/AbinsModules/Instruments/ToscaInstrument.py index 7b5c83a3f3f0fde99438f4bc31fb8e41c9fe4161..668b6115d3bda160ebd0ec8b2c10fde0f3400da8 100644 --- a/scripts/AbinsModules/Instruments/ToscaInstrument.py +++ b/scripts/AbinsModules/Instruments/ToscaInstrument.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np from .Instrument import Instrument from .Broadening import broaden_spectrum, prebin_required_schemes diff --git a/scripts/AbinsModules/Instruments/__init__.py b/scripts/AbinsModules/Instruments/__init__.py index cb3c293c5c58386e5545255f1717bd192371cb0f..87179b99f85685b06f059e266a7c0a5674b7d2be 100644 --- a/scripts/AbinsModules/Instruments/__init__.py +++ b/scripts/AbinsModules/Instruments/__init__.py @@ -5,7 +5,5 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # flake8: noqa -from __future__ import (absolute_import, division, print_function) - from .ToscaInstrument import ToscaInstrument from .Instrument import Instrument diff --git a/scripts/AbinsModules/KpointsData.py b/scripts/AbinsModules/KpointsData.py index 010f6853596d55e3723df8e3f3bd92e51c399956..c94f643b90adbb4863adda882d2674be9990f6df 100644 --- a/scripts/AbinsModules/KpointsData.py +++ b/scripts/AbinsModules/KpointsData.py @@ -4,9 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np -import six import AbinsModules @@ -43,12 +41,12 @@ class KpointsData(AbinsModules.GeneralData): """ super(KpointsData, self).__init__() - if isinstance(num_k, six.integer_types) and num_k > 0: + if isinstance(num_k, int) and num_k > 0: self._num_k = num_k else: raise ValueError("Invalid number of k-points.") - if isinstance(num_atoms, six.integer_types) and num_atoms > 0: + if isinstance(num_atoms, int) and num_atoms > 0: self._num_atoms = num_atoms # number of displacements for one k-point else: raise ValueError("Invalid number of atoms.") diff --git a/scripts/AbinsModules/LoadCASTEP.py b/scripts/AbinsModules/LoadCASTEP.py index 37bbcf346c8a81d9dd3e259783402240759ab786..0a031da8dbadf5e67082f7e9015b6ca8c4e7dece 100644 --- a/scripts/AbinsModules/LoadCASTEP.py +++ b/scripts/AbinsModules/LoadCASTEP.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import re import AbinsModules diff --git a/scripts/AbinsModules/LoadCRYSTAL.py b/scripts/AbinsModules/LoadCRYSTAL.py index b90545a6d29a3dd6c34062efd5011857f4dc2eae..02486eccf446f93f69ba23989c1e3fd782907c8e 100644 --- a/scripts/AbinsModules/LoadCRYSTAL.py +++ b/scripts/AbinsModules/LoadCRYSTAL.py @@ -4,9 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import io -import six import numpy as np import AbinsModules from mantid.kernel import Atom, logger @@ -538,9 +536,8 @@ class LoadCRYSTAL(AbinsModules.GeneralAbInitioProgram): end_message = ["INFORMATION", "*******************************************************************************", "GAMMA"] - if not six.PY2: - for i, item in enumerate(end_message): - end_message[i] = bytes(item, "utf8") + for i, item in enumerate(end_message): + end_message[i] = bytes(item, "utf8") while not self._parser.file_end(file_obj=file_obj): diff --git a/scripts/AbinsModules/LoadDMOL3.py b/scripts/AbinsModules/LoadDMOL3.py index 0f028fb9a76fded1c502ad9e619c6e25292bc5b9..2fe2e5f3f5b8079eef54b977e6dfb02a6d371e1e 100644 --- a/scripts/AbinsModules/LoadDMOL3.py +++ b/scripts/AbinsModules/LoadDMOL3.py @@ -4,10 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import AbinsModules import io -import six import numpy as np from math import sqrt from mantid.kernel import Atom @@ -255,9 +253,8 @@ class LoadDMOL3(AbinsModules.GeneralAbInitioProgram): end_msg = "Molecular Mass:" key = "Atom" - if not six.PY2: - end_msg = bytes(end_msg, "utf8") - key = bytes(key, "utf8") + end_msg = bytes(end_msg, "utf8") + key = bytes(key, "utf8") while not self._parser.file_end(file_obj=obj_file): line = obj_file.readline() diff --git a/scripts/AbinsModules/LoadGAUSSIAN.py b/scripts/AbinsModules/LoadGAUSSIAN.py index 62e61cea629d7d3291911240b39c9a641823237b..1ef9e949e3cd9a91465515e8f1091a8934455360 100644 --- a/scripts/AbinsModules/LoadGAUSSIAN.py +++ b/scripts/AbinsModules/LoadGAUSSIAN.py @@ -4,10 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import AbinsModules import io -import six import numpy as np from mantid.kernel import Atom @@ -197,9 +195,8 @@ class LoadGAUSSIAN(AbinsModules.GeneralAbInitioProgram): end_msg = "Molecular mass:" key = "Atom" - if not six.PY2: - end_msg = bytes(end_msg, "utf8") - key = bytes(key, "utf8") + end_msg = bytes(end_msg, "utf8") + key = bytes(key, "utf8") while not self._parser.file_end(file_obj=file_obj): diff --git a/scripts/AbinsModules/PowderData.py b/scripts/AbinsModules/PowderData.py index 8ec142a081e77128f6cf31d3d08fb1da2a24e142..9aa69421a4f12d4a64faa79d2a4137712e31a7d0 100644 --- a/scripts/AbinsModules/PowderData.py +++ b/scripts/AbinsModules/PowderData.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -import six import AbinsModules @@ -16,7 +14,7 @@ class PowderData(AbinsModules.GeneralData): def __init__(self, num_atoms=None): super(PowderData, self).__init__() - if isinstance(num_atoms, six.integer_types) and num_atoms > 0: + if isinstance(num_atoms, int) and num_atoms > 0: self._num_atoms = num_atoms else: raise ValueError("Invalid value of atoms.") diff --git a/scripts/AbinsModules/SData.py b/scripts/AbinsModules/SData.py index 04d410f17aca034c610283db6fee96e9d54a56b1..5c45012a8a38fb1f3a933201c1a345822f4beda2 100644 --- a/scripts/AbinsModules/SData.py +++ b/scripts/AbinsModules/SData.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from mantid.kernel import logger as mantid_logger import AbinsModules diff --git a/scripts/AbinsModules/SPowderSemiEmpiricalCalculator.py b/scripts/AbinsModules/SPowderSemiEmpiricalCalculator.py index fb9e69332f95f081c6cf0d7a252d972c2d459af4..84e097f0300bd59900e89123c4dd907c59e2ab9b 100644 --- a/scripts/AbinsModules/SPowderSemiEmpiricalCalculator.py +++ b/scripts/AbinsModules/SPowderSemiEmpiricalCalculator.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import AbinsModules from AbinsModules import AbinsParameters, AbinsConstants import gc diff --git a/scripts/AbinsModules/SingleCrystalData.py b/scripts/AbinsModules/SingleCrystalData.py index 39e0e81dcc1dc08910ba1c9b835327661746aec6..b18b9dd5caaea5bf3747c0ef00374c63b7c18148 100644 --- a/scripts/AbinsModules/SingleCrystalData.py +++ b/scripts/AbinsModules/SingleCrystalData.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import AbinsModules diff --git a/scripts/AbinsModules/__init__.py b/scripts/AbinsModules/__init__.py index f7f017454ea09d283afcb81aa694b41459534119..ba8624e18bc9ec95858907601d034a6e4bb09dbe 100644 --- a/scripts/AbinsModules/__init__.py +++ b/scripts/AbinsModules/__init__.py @@ -6,9 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # flake8: noqa -from __future__ import (absolute_import, division, print_function) - - from .IOmodule import IOmodule # Frequency generator diff --git a/scripts/BilbyCustomFunctions_Reduction.py b/scripts/BilbyCustomFunctions_Reduction.py index 29d574d9f6b4277e7f6e207479e25d3ac94b4041..a9ed4c2c3ade1272d2c387f9cc276cc5e5abb985 100644 --- a/scripts/BilbyCustomFunctions_Reduction.py +++ b/scripts/BilbyCustomFunctions_Reduction.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function import csv import math from itertools import product diff --git a/scripts/Calibration/Examples/TubeCalibDemoMaps_All.py b/scripts/Calibration/Examples/TubeCalibDemoMaps_All.py index 9798d847093cf2efa60d92fd85f610b73379d9f7..d4f296050865b91ac2dbc2e522e7600ec2729570 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMaps_All.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMaps_All.py @@ -58,8 +58,6 @@ Calibration technique: Finding tubes not well calibrated """ -from __future__ import absolute_import, division, print_function - import mantid.simpleapi as mantid import tube import numpy diff --git a/scripts/Calibration/Examples/TubeCalibDemoMaps_B1.py b/scripts/Calibration/Examples/TubeCalibDemoMaps_B1.py index b9c62e695f45d7d88483b7467210c5017b9545b4..2d1ea2e243ee5d0fa9b5c40f17ac8d061091147d 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMaps_B1.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMaps_B1.py @@ -10,8 +10,6 @@ # # Here we run the calibration of a selected part of MAPS -from __future__ import absolute_import, division, print_function - import tube from tube_calib_fit_params import TubeCalibFitParams import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3.py b/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3.py index d63b0541c99d7a134ae6e8c3e87ffd17cf0a9428..ba188c23b0e0c33712d542e68b11c7dc4f82cdbd 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3.py @@ -11,8 +11,6 @@ # Here we run the calibration of a selected part of MAPS consisting of several components # by running setTubeSpecByString several times. -from __future__ import absolute_import, division, print_function - import tube from tube_spec import TubeSpec import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3C2.py b/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3C2.py index 7db8de221f4988c0476b4f75540de213983e48c0..fef52b033983c192767cac3534b25ed5fb9e0faf 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3C2.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMaps_C4C3C2.py @@ -11,8 +11,6 @@ # Here we run the calibration of a selected part of MAPS consisting of several components # specifying them in an array of strings. -from __future__ import absolute_import, division, print_function - import tube import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoMaps_D2.py b/scripts/Calibration/Examples/TubeCalibDemoMaps_D2.py index 11912b5b888305cf0858b7a33f8e9c87f650ce3f..11e23633a420d9901d5f1218fc628f2eb9ea137f 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMaps_D2.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMaps_D2.py @@ -10,8 +10,6 @@ # # Here we run the calibration of a selected part of MAPS -from __future__ import absolute_import, division, print_function - import tube from tube_calib_fit_params import TubeCalibFitParams import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoMaps_D2_WideMargins.py b/scripts/Calibration/Examples/TubeCalibDemoMaps_D2_WideMargins.py index 196030a2e59c3c6ec31efb90ea375ed9f57c50cc..dcfa9ed3df94e937e72c65ae21bdb3bf5d472166 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMaps_D2_WideMargins.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMaps_D2_WideMargins.py @@ -10,8 +10,6 @@ # # Here we run the calibration of a selected part of MAPS -from __future__ import absolute_import, division, print_function - import tube import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoMaps_D4.py b/scripts/Calibration/Examples/TubeCalibDemoMaps_D4.py index f313d1fe1826eee01ae2373af8717da2bd15088b..4f3201c99a25f1f007dc2b8288d7032fe3e09a25 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMaps_D4.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMaps_D4.py @@ -10,8 +10,6 @@ # # Here we run the calibration of a selected part of MAPS -from __future__ import absolute_import, division, print_function - import tube from tube_calib_fit_params import TubeCalibFitParams import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoMerlin.py b/scripts/Calibration/Examples/TubeCalibDemoMerlin.py index 40d3abde9b5481759852c3a29068455d6f1990bb..98bff03d25ab370c739041da27847650c7c94295 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMerlin.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMerlin.py @@ -49,8 +49,6 @@ The previous calibrated instrument view: .. sectionauthor:: Gesner Passos - ISIS """ -from __future__ import absolute_import, division, print_function - import numpy import mantid.simpleapi as mantid import tube diff --git a/scripts/Calibration/Examples/TubeCalibDemoMerlin_Simple.py b/scripts/Calibration/Examples/TubeCalibDemoMerlin_Simple.py index 53b4fc586a91806ccf9b1f5e1ef99be009e7b42b..c5b141cafab0f5693bcf00b2fbb4e6a46481d796 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoMerlin_Simple.py +++ b/scripts/Calibration/Examples/TubeCalibDemoMerlin_Simple.py @@ -18,8 +18,6 @@ # The workspace with calibrated instrument is saved to a Nexus file # -from __future__ import absolute_import, division, print_function - import tube from tube_calib_fit_params import TubeCalibFitParams import numpy diff --git a/scripts/Calibration/Examples/TubeCalibDemoWish0.py b/scripts/Calibration/Examples/TubeCalibDemoWish0.py index 31e780d7939c8960b7001d58243ea8750d3e3e3b..685414c46424e050e6158d3f5d1f0dfc97d6ccee 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoWish0.py +++ b/scripts/Calibration/Examples/TubeCalibDemoWish0.py @@ -15,8 +15,6 @@ # because we do not consider the upper and lower position of the tubes around the # WISH instrument. # -from __future__ import absolute_import, division, print_function - import tube import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoWish1.py b/scripts/Calibration/Examples/TubeCalibDemoWish1.py index 89204997b83287208548e7375a29b72a67d40ebb..9837db0168f1aa3e2732d7790c17588ca5bd5011 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoWish1.py +++ b/scripts/Calibration/Examples/TubeCalibDemoWish1.py @@ -12,8 +12,6 @@ # We base the ideal tube on one tube of this door. # -from __future__ import absolute_import, division, print_function - import tube reload(tube) # noqa from tube_spec import TubeSpec diff --git a/scripts/Calibration/Examples/TubeCalibDemoWish_5panels.py b/scripts/Calibration/Examples/TubeCalibDemoWish_5panels.py index ba7205080bacac4d49a37a09a6146e055f470c4b..354f32c0ca354ab5d4f850bd67df70b95cbe19e2 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoWish_5panels.py +++ b/scripts/Calibration/Examples/TubeCalibDemoWish_5panels.py @@ -18,8 +18,6 @@ to calibrate the whole instrument. """ -from __future__ import absolute_import, division, print_function - import numpy import mantid.simpleapi as mantid diff --git a/scripts/Calibration/Examples/TubeCalibDemoWish_Simple.py b/scripts/Calibration/Examples/TubeCalibDemoWish_Simple.py index a3aca6bee7e805a4cfd8bcbf00af3b9d527926f4..d604c5bf71ab262821586740cd1e562fb17e4576 100644 --- a/scripts/Calibration/Examples/TubeCalibDemoWish_Simple.py +++ b/scripts/Calibration/Examples/TubeCalibDemoWish_Simple.py @@ -11,8 +11,6 @@ # Here we run the calibration of WISH panel03 using a simple CalibrateWish function. # -from __future__ import absolute_import, division, print_function - import numpy import tube import mantid.simpleapi as mantid diff --git a/scripts/Calibration/tube.py b/scripts/Calibration/tube.py index ef121149f2b00ce367acab189f301b10e43d790f..781408f6e86746be030089c3f78b02003c23b64a 100644 --- a/scripts/Calibration/tube.py +++ b/scripts/Calibration/tube.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import absolute_import, division, print_function - import numpy import os import re diff --git a/scripts/Calibration/tube_calib.py b/scripts/Calibration/tube_calib.py index bc5c1b88ad246c66c7db0416867432b001ca319c..a529c1c5e92f427c5383c306452fe1686c4bee47 100644 --- a/scripts/Calibration/tube_calib.py +++ b/scripts/Calibration/tube_calib.py @@ -16,8 +16,6 @@ Users should not need to directly call any other function other than :func:`getC """ ## Author: Karl palmen ISIS and for readPeakFile Gesner Passos ISIS -from __future__ import absolute_import, division, print_function - import numpy from mantid.simpleapi import * from mantid.kernel import * diff --git a/scripts/Calibration/tube_calib_fit_params.py b/scripts/Calibration/tube_calib_fit_params.py index 7d4192983827a507fe7717e6b53bbb2c7b7edeec..76ae22eec9db0a721f22a0a9ff77494fd1a25869 100644 --- a/scripts/Calibration/tube_calib_fit_params.py +++ b/scripts/Calibration/tube_calib_fit_params.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, division, print_function class TubeCalibFitParams(object): diff --git a/scripts/Calibration/tube_spec.py b/scripts/Calibration/tube_spec.py index f86b60538a23154b947540f787d812c6af53a5ca..a7df4ebd859de9bac4306b385435f3d8300c0cc0 100644 --- a/scripts/Calibration/tube_spec.py +++ b/scripts/Calibration/tube_spec.py @@ -12,8 +12,6 @@ # Author: Karl Palmen ISIS -from __future__ import absolute_import, division, print_function - class TubeSpec: """ diff --git a/scripts/CrystalTools/PeakReport.py b/scripts/CrystalTools/PeakReport.py index d9ddd21262c010424f25ea2e80e8a98bafebc185..8afcda27fe78e2d2293c683bbf277ee286a19a0e 100644 --- a/scripts/CrystalTools/PeakReport.py +++ b/scripts/CrystalTools/PeakReport.py @@ -8,7 +8,6 @@ """ This is a module for creating peak integration reports. """ -from __future__ import (absolute_import, division, print_function) import os import mantid.api from mantidplot import plotSlice diff --git a/scripts/DGSPlanner.py b/scripts/DGSPlanner.py index d1a5cb0b49aa77019eaacf0bc833e6eaf57839a8..2151e9e2ede349da28b03ca69d182d73792e7bfc 100644 --- a/scripts/DGSPlanner.py +++ b/scripts/DGSPlanner.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,unused-import -from __future__ import (absolute_import, division, print_function) import sys from DGSPlanner import DGSPlannerGUI from mantidqt.gui_helper import get_qapplication diff --git a/scripts/DGSPlanner/ClassicUBInputWidget.py b/scripts/DGSPlanner/ClassicUBInputWidget.py index 1dcbe720806cbc457358afa6fc40b03598e743bb..e1bd1493b904082a2721227f0999b517b1ae1f3d 100644 --- a/scripts/DGSPlanner/ClassicUBInputWidget.py +++ b/scripts/DGSPlanner/ClassicUBInputWidget.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-name-in-module,too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets, QtGui, QtCore import sys import mantid diff --git a/scripts/DGSPlanner/DGSPlannerGUI.py b/scripts/DGSPlanner/DGSPlannerGUI.py index af6e49f7a9cb847c677bfad6947daa59c3b8f26f..ad54f83348a402ebf38ecac27c473fcbc2916e52 100644 --- a/scripts/DGSPlanner/DGSPlannerGUI.py +++ b/scripts/DGSPlanner/DGSPlannerGUI.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,relative-import -from __future__ import (absolute_import, division, print_function) from . import InstrumentSetupWidget from . import ClassicUBInputWidget from . import MatrixUBInputWidget diff --git a/scripts/DGSPlanner/DimensionSelectorWidget.py b/scripts/DGSPlanner/DimensionSelectorWidget.py index f3137f95033b3f2b04f17499c62461f114b5b3bf..32e19314b672f10c2489f86da27f3fd70276c356 100644 --- a/scripts/DGSPlanner/DimensionSelectorWidget.py +++ b/scripts/DGSPlanner/DimensionSelectorWidget.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-name-in-module,too-many-instance-attributes,super-on-old-class,too-few-public-methods -from __future__ import (absolute_import, division, print_function) from qtpy import QtGui, QtCore, QtWidgets import sys import numpy diff --git a/scripts/DGSPlanner/InstrumentSetupWidget.py b/scripts/DGSPlanner/InstrumentSetupWidget.py index e663c0dd9d25682244004e89e94d4a8c311ee355..4257fa03535d127cce9a3242f3160d704f8631df 100644 --- a/scripts/DGSPlanner/InstrumentSetupWidget.py +++ b/scripts/DGSPlanner/InstrumentSetupWidget.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-name-in-module,too-many-instance-attributes,too-many-public-methods -from __future__ import (absolute_import, division, print_function) from qtpy import QtGui, QtCore, QtWidgets import sys import mantid diff --git a/scripts/DGSPlanner/LoadNexusUB.py b/scripts/DGSPlanner/LoadNexusUB.py index 54cc854ab6724371fbea7e8365c58f19a4df816c..047286e380391e9727dd2bf1ec59d829ff96fd56 100644 --- a/scripts/DGSPlanner/LoadNexusUB.py +++ b/scripts/DGSPlanner/LoadNexusUB.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-name-in-module,too-many-public-methods -from __future__ import (absolute_import, division, print_function) import numpy as np from mantid.simpleapi import * diff --git a/scripts/DGSPlanner/MatrixUBInputWidget.py b/scripts/DGSPlanner/MatrixUBInputWidget.py index 47b8f200d690b0ec77bb6e3da8873b0908f51b3f..c57ef80386c864d8a0b558b5a6dffd2e1adbc5fe 100644 --- a/scripts/DGSPlanner/MatrixUBInputWidget.py +++ b/scripts/DGSPlanner/MatrixUBInputWidget.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,no-name-in-module,too-many-public-methods -from __future__ import (absolute_import, division, print_function) from qtpy import QtCore, QtGui, QtWidgets import sys import mantid diff --git a/scripts/DGSPlanner/ValidateOL.py b/scripts/DGSPlanner/ValidateOL.py index daff258ef6287f6708428c3fd1ec42877e8b6726..c438f8a08688e4b067435b144b7a511b6aa431fe 100644 --- a/scripts/DGSPlanner/ValidateOL.py +++ b/scripts/DGSPlanner/ValidateOL.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,bare-except -from __future__ import (absolute_import, division, print_function) import mantid import numpy diff --git a/scripts/DGS_Reduction.py b/scripts/DGS_Reduction.py index 99e0878803cf3a684000047f6250a054d750ea47..2557ac17852d91fc1b24663f3304a7d85e8f863a 100644 --- a/scripts/DGS_Reduction.py +++ b/scripts/DGS_Reduction.py @@ -8,7 +8,6 @@ """ Script used to start the DGS reduction GUI from MantidPlot """ -from __future__ import (absolute_import, division, print_function) from reduction_application import ReductionGUI reducer = ReductionGUI(instrument_list=["ARCS", "CNCS", "HYSPEC", "MAPS", diff --git a/scripts/DiamondAttenuationCorrection/FitTrans.py b/scripts/DiamondAttenuationCorrection/FitTrans.py index bba1a3bd336de8b2aa12c5a54f7ac8b496c4cdd7..1289e12b55492fb5136d40603576944de253d6d8 100644 --- a/scripts/DiamondAttenuationCorrection/FitTrans.py +++ b/scripts/DiamondAttenuationCorrection/FitTrans.py @@ -19,7 +19,6 @@ Data types: *** ''' # Import all needed libraries -from __future__ import (absolute_import, division, print_function) from matplotlib import pyplot as plt import numpy as np import itertools as itt diff --git a/scripts/DiamondAttenuationCorrection/FitTransReadUB.py b/scripts/DiamondAttenuationCorrection/FitTransReadUB.py index 30e27f3c00b1d2db1b73e5d5638fcd675ce3771d..a30965f27da7f4c38d3e15161df39245ce0bae15 100644 --- a/scripts/DiamondAttenuationCorrection/FitTransReadUB.py +++ b/scripts/DiamondAttenuationCorrection/FitTransReadUB.py @@ -19,7 +19,6 @@ Data types: *** ''' # Import all needed libraries -from __future__ import (absolute_import, division, print_function) from matplotlib import pyplot as plt import numpy as np import itertools as itt diff --git a/scripts/DiamondAttenuationCorrection/UBMatrixGenerator.py b/scripts/DiamondAttenuationCorrection/UBMatrixGenerator.py index 3f16202fb08b7e4714f6f2aa7ce0e06ccd606a4d..4ab94557fe95e396b7bc32a03b18f4afa3027b6c 100644 --- a/scripts/DiamondAttenuationCorrection/UBMatrixGenerator.py +++ b/scripts/DiamondAttenuationCorrection/UBMatrixGenerator.py @@ -10,7 +10,6 @@ Identifies upstream and downstream diamonds and assigns matrices to them ''' # Import all needed libraries -from __future__ import (absolute_import, division, print_function) import numpy as np import itertools as itt diff --git a/scripts/Diffraction/isis_powder/__init__.py b/scripts/Diffraction/isis_powder/__init__.py index b4fa960144b1174999f9cfc047684807c5afcdd4..108af00a69a84fcb4b3eb8982915d3bf064e9b02 100644 --- a/scripts/Diffraction/isis_powder/__init__.py +++ b/scripts/Diffraction/isis_powder/__init__.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - # Disable unused import warnings. The import is for user convenience # Bring instruments into package namespace from .gem import Gem # noqa: F401 diff --git a/scripts/Diffraction/isis_powder/abstract_inst.py b/scripts/Diffraction/isis_powder/abstract_inst.py index 5d0527b98fea1bd4ab7026f9dd60d69ea1f50e61..62b5a8c40ab1a194af43bce235a5bccadc2471e0 100644 --- a/scripts/Diffraction/isis_powder/abstract_inst.py +++ b/scripts/Diffraction/isis_powder/abstract_inst.py @@ -4,13 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os from isis_powder.routines import calibrate, focus, common, common_enums, common_output from mantid.kernel import config, logger -from six import iteritems - # This class provides common hooks for instruments to override # if they want to define the behaviour of the hook. Otherwise it # returns the object passed in without manipulating it as a default @@ -322,7 +318,7 @@ class AbstractInst(object): "tof_xye_filename": dat_files_directory, "dspacing_xye_filename": dat_files_directory } - for key, output_dir in iteritems(output_formats): + for key, output_dir in output_formats.items(): filepath = os.path.join(output_dir, getattr(self._inst_settings, key).format(**format_options)) out_file_names[key] = filepath diff --git a/scripts/Diffraction/isis_powder/gem.py b/scripts/Diffraction/isis_powder/gem.py index 3ad4b27b8950b99a6691280418b0cfabdab58f3d..74b5e36671e3fe6714f1927321e812a06eaaa7b3 100644 --- a/scripts/Diffraction/isis_powder/gem.py +++ b/scripts/Diffraction/isis_powder/gem.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os from isis_powder.abstract_inst import AbstractInst diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py b/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py index 069ef627f5708cac805c8833a8c0e8f3a3a891d5..9d29951c8ded2bb27bd6e79768ddf7cbabe25a03 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import copy from isis_powder.routines.common import ADVANCED_CONFIG as COMMON_ADVANCED_CONFIG diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py b/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py index b9a9a87b1227a6ea18cf4e163587bcf3ab436e53..6170315b2a8783ec1b02fcec9ceba0ef8ea0a298 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_algs.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid from isis_powder.routines import absorb_corrections, common diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py index 44eef7e076eb825daeecbdb05ee7e28959c3fd18..f91a8d5fc2f1b115a6ddf977f5d32f358d8d1d9c 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_calibration_algs.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import mantid.simpleapi as mantid import isis_powder.routines.common as common diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_enums.py b/scripts/Diffraction/isis_powder/gem_routines/gem_enums.py index 2d50a547488f5d1d039ed30e1b68b2f1ccd1a9b9..c5f1bcae8e4c369a15a04778fa4265fe795ef77f 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_enums.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_enums.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class GEM_CHOPPER_MODES(object): diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_output.py b/scripts/Diffraction/isis_powder/gem_routines/gem_output.py index 7c6603e8e9d45d9217f69b53ae957695958b248f..de8fd4c5fa933b73d007ccc89efceed386148dd1 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_output.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_output.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py b/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py index cfcd44e6e0450340790defcc5a853443f2829546..e7ae385b573b8d55fac08b28b6e7df36115e7c79 100644 --- a/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py +++ b/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from isis_powder.routines.param_map_entry import ParamMapEntry from isis_powder.gem_routines.gem_enums import GEM_CHOPPER_MODES from isis_powder.routines.common import PARAM_MAPPING as COMMON_PARAM_MAPPING diff --git a/scripts/Diffraction/isis_powder/hrpd.py b/scripts/Diffraction/isis_powder/hrpd.py index a55065ee1501814febe560436d8c1a1ffb483a7d..9055f8c684dd25a63b7d4bdb4fee0f351e78208a 100644 --- a/scripts/Diffraction/isis_powder/hrpd.py +++ b/scripts/Diffraction/isis_powder/hrpd.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os from isis_powder.abstract_inst import AbstractInst diff --git a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_advanced_config.py b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_advanced_config.py index 0f1113854e7089eb831316e3be352d5abd26dbff..93eaa0f1e9c50faaae430475a5c12e89ee7a2ae2 100644 --- a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_advanced_config.py +++ b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_advanced_config.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from isis_powder.hrpd_routines.hrpd_enums import HRPD_TOF_WINDOWS absorption_correction_params = { diff --git a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_algs.py b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_algs.py index 906b90866b6549b5aea4bbcf852f9fe1e63609bb..2dde439e9090c63445d56a87ec6aab63bdd6fb63 100644 --- a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_algs.py +++ b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_algs.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid from isis_powder.hrpd_routines import hrpd_advanced_config diff --git a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_enums.py b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_enums.py index b54c973da7e403f7d7d12b209aea6290b9401dcc..d785d775e6a2a92819071eb5b169d51f077cea94 100644 --- a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_enums.py +++ b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_enums.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class HRPD_TOF_WINDOWS(object): diff --git a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_param_mapping.py b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_param_mapping.py index 443848545a6d757e69d080224863560d68f02672..5131937d160f2759ae64d678a3dcf736ef2fb725 100644 --- a/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_param_mapping.py +++ b/scripts/Diffraction/isis_powder/hrpd_routines/hrpd_param_mapping.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from isis_powder.hrpd_routines.hrpd_enums import HRPD_MODES, HRPD_TOF_WINDOWS from isis_powder.routines.common import PARAM_MAPPING as COMMON_PARAM_MAPPING from isis_powder.routines.param_map_entry import ParamMapEntry diff --git a/scripts/Diffraction/isis_powder/pearl.py b/scripts/Diffraction/isis_powder/pearl.py index 7b391a35eb86607ef813f2964f1c8aba8f4baffe..ac106f99bb244e63dd1a96ffad0fddb72aff930c 100644 --- a/scripts/Diffraction/isis_powder/pearl.py +++ b/scripts/Diffraction/isis_powder/pearl.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from contextlib import contextmanager import mantid.simpleapi as mantid diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py index 978a24d0d66c99d1fbab5a5063f74756e84d336a..22302dbb14baac3eeb9b193b26a782f64a08f8fd 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_advanced_config.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from numpy import array general_params = { diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py index e697118c202b2b972baadfa54d3cd0b227e6c7e7..f94c254e3962041d109a06aeba30d9aa090fca07 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_algs.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid import isis_powder.routines.common as common diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration_algs.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration_algs.py index 03bf602e55bdb0799ac6eccb8b096edfbbdb94b6..180830647ef608bddb29023451092949d04d5831 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration_algs.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_calibration_algs.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import mantid.simpleapi as mantid import isis_powder.routines.common as common diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_enums.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_enums.py index b12801d05520878837f8010de30f9ffd14a4fc58..3649c244f468893b2b6a7f06fa0577453c2e3a8e 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_enums.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_enums.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class PEARL_FOCUS_MODES(object): diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py index 4a6a9fa2a46bbdb72befa96f9c2850f1499e5dda..605c7997f642603c5245f47ac94002b45ae5bbc2 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_output.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid from isis_powder.routines.common_enums import WORKSPACE_UNITS diff --git a/scripts/Diffraction/isis_powder/pearl_routines/pearl_param_mapping.py b/scripts/Diffraction/isis_powder/pearl_routines/pearl_param_mapping.py index e0508d6ae66cdb480dc8b64e6d76bb746fd5c05f..2514081153dff9b440df31058e154fe3121cbf45 100644 --- a/scripts/Diffraction/isis_powder/pearl_routines/pearl_param_mapping.py +++ b/scripts/Diffraction/isis_powder/pearl_routines/pearl_param_mapping.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from isis_powder.routines.common import PARAM_MAPPING from isis_powder.routines.param_map_entry import ParamMapEntry from isis_powder.pearl_routines.pearl_enums import PEARL_FOCUS_MODES, PEARL_TT_MODES diff --git a/scripts/Diffraction/isis_powder/polaris.py b/scripts/Diffraction/isis_powder/polaris.py index 0dfd83cb460e32aed14e7d11b39d829c154e9662..0c80b633fdeba1dad103dc0710fdf22a758f09a2 100644 --- a/scripts/Diffraction/isis_powder/polaris.py +++ b/scripts/Diffraction/isis_powder/polaris.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os from isis_powder.routines import absorb_corrections, common, instrument_settings diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py index 8cd626c228d5511f5992b2d1d91708b3b2ded854..21d9f4893b0331f4cf8710db993613924b7f2938 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_advanced_config.py @@ -7,8 +7,6 @@ # Note all changes in this file require a restart of Mantid # additionally any long term changes should be sent back to the development team so any changes can be merged # into future versions of Mantid. -from __future__ import (absolute_import, unicode_literals) - import copy from isis_powder.routines.common import ADVANCED_CONFIG as COMMON_ADVANCED_CONFIG diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py index 835267e2eb45dc24b43e63db3f97e6e17dedbbeb..cd94d7cd1422f455689511e50c5652bdd0b1aee2 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import math import mantid.simpleapi as mantid -from six import string_types - +from mantid.api import WorkspaceGroup from isis_powder.routines import absorb_corrections, common from isis_powder.routines.common_enums import WORKSPACE_UNITS from isis_powder.routines.run_details import create_run_details_object, get_cal_mapping_dict @@ -125,6 +123,17 @@ def generate_ts_pdf(run_number, focus_file_path, merge_banks=False, q_lims=None, pdf_output = mantid.Rebin(InputWorkspace=pdf_output, Params=output_binning) except RuntimeError: return pdf_output + # Rename output ws + if 'merged_ws' in locals(): + mantid.RenameWorkspace(InputWorkspace=merged_ws, OutputWorkspace=run_number + '_merged_Q') + mantid.RenameWorkspace(InputWorkspace='focused_ws', OutputWorkspace=run_number+'_focused_Q') + if isinstance(focused_ws, WorkspaceGroup): + for i in range(len(focused_ws)): + mantid.RenameWorkspace(InputWorkspace=focused_ws[i], OutputWorkspace=run_number+'_focused_Q_'+str(i+1)) + mantid.RenameWorkspace(InputWorkspace='pdf_output', OutputWorkspace=run_number+'_pdf_R') + if isinstance(pdf_output, WorkspaceGroup): + for i in range(len(pdf_output)): + mantid.RenameWorkspace(InputWorkspace=pdf_output[i], OutputWorkspace=run_number+'_pdf_R_'+str(i+1)) return pdf_output @@ -155,7 +164,7 @@ def _obtain_focused_run(run_number, focus_file_path): def _load_qlims(q_lims): - if isinstance(q_lims, string_types): + if isinstance(q_lims, str): q_min = [] q_max = [] try: diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py index 3147259db17c7b658fd7c018d8ccd7d7a4e34d78..ae042fb669efe1a252d34992d81183120ce8bde6 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_enums.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class POLARIS_CHOPPER_MODES(object): diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py index cb2e721b2ec2bdcf8efbe1080759e62afe45e7ca..3b26bb1f2cdc6a46855b50b9d8a2cb2fe2112e16 100644 --- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py +++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_param_mapping.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from isis_powder.routines.param_map_entry import ParamMapEntry from isis_powder.routines.common import PARAM_MAPPING as COMMON_PARAM_MAPPING from isis_powder.routines.common_enums import INPUT_BATCHING diff --git a/scripts/Diffraction/isis_powder/routines/__init__.py b/scripts/Diffraction/isis_powder/routines/__init__.py index 700e4f0d1ad22c4e0df0bd9f764f0053f54247ca..9fcc06f4b0b39877ddc8a8450fcd2dd205c40328 100644 --- a/scripts/Diffraction/isis_powder/routines/__init__.py +++ b/scripts/Diffraction/isis_powder/routines/__init__.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - # Disable unused import warnings. The import is for user convenience # Currently these are the things from routines we want to expose to a public API diff --git a/scripts/Diffraction/isis_powder/routines/absorb_corrections.py b/scripts/Diffraction/isis_powder/routines/absorb_corrections.py index 2bb2b5e86f4ff97c623f5c20c08ff1ba503a30b0..eb8614f157ce0d2e2d172714540cba77fe151d9c 100644 --- a/scripts/Diffraction/isis_powder/routines/absorb_corrections.py +++ b/scripts/Diffraction/isis_powder/routines/absorb_corrections.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid from isis_powder.routines import common, common_enums, sample_details diff --git a/scripts/Diffraction/isis_powder/routines/calibrate.py b/scripts/Diffraction/isis_powder/routines/calibrate.py index f2008529dc24d979125f038ff20de6c766f3a274..5bf66e1f5561e3b03d30148f166359f0dbf344cb 100644 --- a/scripts/Diffraction/isis_powder/routines/calibrate.py +++ b/scripts/Diffraction/isis_powder/routines/calibrate.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid import isis_powder.routines.common as common diff --git a/scripts/Diffraction/isis_powder/routines/common.py b/scripts/Diffraction/isis_powder/routines/common.py index b8956e879e564ea854f46e67e9978c443fdac031..4024a1ac123131f7cffe5aae6058daaec844ebe7 100644 --- a/scripts/Diffraction/isis_powder/routines/common.py +++ b/scripts/Diffraction/isis_powder/routines/common.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -from six import PY2, iterkeys import collections import warnings @@ -146,7 +144,7 @@ def dictionary_key_helper(dictionary, key, throws=True, case_insensitive=False, if case_insensitive: # Convert key to str lower_key = str(key).lower() - for dict_key in iterkeys(dictionary): + for dict_key in dictionary.keys(): if str(dict_key).lower() == lower_key: # Found it return dictionary[dict_key] @@ -522,14 +520,7 @@ def read_masking_file(masking_file_path): all_banks_masking_list = [] bank_masking_list = [] - # Python > 3 requires the encoding to be included so an Angstrom - # symbol can be read, I'm assuming all file read here are - # `latin-1` which may not be true in the future. Python 2 `open` - # doesn't have an encoding option - if PY2: - encoding = {} - else: - encoding = {"encoding": "latin-1"} + encoding = {"encoding": "latin-1"} with open(masking_file_path, **encoding) as mask_file: for line in mask_file: if 'bank' in line: diff --git a/scripts/Diffraction/isis_powder/routines/common_enums.py b/scripts/Diffraction/isis_powder/routines/common_enums.py index cd55f4f46d38b6ac7b6277aa2b75bf1f357153e3..59d657444be3bc6b8f0c9a02384d4fd382c24ead 100644 --- a/scripts/Diffraction/isis_powder/routines/common_enums.py +++ b/scripts/Diffraction/isis_powder/routines/common_enums.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - # Holds enumeration classes for common values diff --git a/scripts/Diffraction/isis_powder/routines/common_output.py b/scripts/Diffraction/isis_powder/routines/common_output.py index 9d67c20958105f65288afed3c3758ea58f8586ad..b2425442790f9c19e7488285845696418b034767 100644 --- a/scripts/Diffraction/isis_powder/routines/common_output.py +++ b/scripts/Diffraction/isis_powder/routines/common_output.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid import os diff --git a/scripts/Diffraction/isis_powder/routines/focus.py b/scripts/Diffraction/isis_powder/routines/focus.py index ff2e7d48ecb87c3d43bf3d9553a0eec2575c5ab6..8880bc998e5954954acbf8a9309d5f7b8412a5e6 100644 --- a/scripts/Diffraction/isis_powder/routines/focus.py +++ b/scripts/Diffraction/isis_powder/routines/focus.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import WorkspaceGroup import mantid.simpleapi as mantid diff --git a/scripts/Diffraction/isis_powder/routines/instrument_settings.py b/scripts/Diffraction/isis_powder/routines/instrument_settings.py index 9e60fd3da8c2223f0def67009dfcca437e86b0e1..75d6ca6d1f793015f57de16f679de83d5d46ed38 100644 --- a/scripts/Diffraction/isis_powder/routines/instrument_settings.py +++ b/scripts/Diffraction/isis_powder/routines/instrument_settings.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -from six import iteritems from isis_powder.routines import yaml_parser import warnings @@ -190,7 +187,7 @@ def _get_enum_values(enum_cls): """ enum_known_vals = [] - for k, enum_val in iteritems(enum_cls.__dict__): + for k, enum_val in enum_cls.__dict__.items(): # Get all class attribute and value pairs except enum_friendly_name if k.startswith("__") or k.lower() == "enum_friendly_name": continue diff --git a/scripts/Diffraction/isis_powder/routines/param_map_entry.py b/scripts/Diffraction/isis_powder/routines/param_map_entry.py index e260b0dd8da2f28e10f2d1e8778d55cd63f58f08..4da9de368b1e812bcd14e57086d175c856b3b652 100644 --- a/scripts/Diffraction/isis_powder/routines/param_map_entry.py +++ b/scripts/Diffraction/isis_powder/routines/param_map_entry.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - # Holds an entry for a parameter map which will be later parsed by InstrumentSettings diff --git a/scripts/Diffraction/isis_powder/routines/run_details.py b/scripts/Diffraction/isis_powder/routines/run_details.py index 14aa89cb90627201d77358e3b4a2bd8c9c7b7a38..bbc45fa162d527396be48f17e8edaa848cb17c64 100644 --- a/scripts/Diffraction/isis_powder/routines/run_details.py +++ b/scripts/Diffraction/isis_powder/routines/run_details.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from isis_powder.routines import common, yaml_parser import os diff --git a/scripts/Diffraction/isis_powder/routines/sample_details.py b/scripts/Diffraction/isis_powder/routines/sample_details.py index 0354c99d2482a01fb7f3570313de7da9ba1aee67..addcffe6b0a3fe7bb9888e9b3c631f46750d3a5c 100644 --- a/scripts/Diffraction/isis_powder/routines/sample_details.py +++ b/scripts/Diffraction/isis_powder/routines/sample_details.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -from six import iteritems from isis_powder.routines import common import math from mantid import logger @@ -95,7 +92,7 @@ class SampleDetails(object): # Attempt to convert them all to floating point relying on the fact on # the way Python has aliases to an object - for key, value in iteritems(values_to_check): + for key, value in values_to_check.items(): _check_value_is_physical(property_name=key, value=value) _check_can_convert_to_float(property_name=key, value=value) @@ -226,7 +223,7 @@ class _Cylinder(object): # Attempt to convert them all to floating point relying on the fact on # the way Python has aliases to an object - for key, value in iteritems(values_to_check): + for key, value in values_to_check.items(): _check_value_is_physical(property_name=key, value=value) _check_can_convert_to_float(property_name=key, value=value) diff --git a/scripts/Diffraction/isis_powder/routines/yaml_parser.py b/scripts/Diffraction/isis_powder/routines/yaml_parser.py index 0b5489e04180020bc44b651ad67b77ebb4e46146..e97886594b074fd92fe95446b11cee091a69faa3 100644 --- a/scripts/Diffraction/isis_powder/routines/yaml_parser.py +++ b/scripts/Diffraction/isis_powder/routines/yaml_parser.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import yaml from isis_powder.routines import common as common diff --git a/scripts/Diffraction/isis_powder/routines/yaml_sanity.py b/scripts/Diffraction/isis_powder/routines/yaml_sanity.py index 039e7e1a61ade636ef23a4a5e2cc974c3663da6c..0f083d17fc021e30c18fb944c27030066c7c622a 100644 --- a/scripts/Diffraction/isis_powder/routines/yaml_sanity.py +++ b/scripts/Diffraction/isis_powder/routines/yaml_sanity.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) def calibration_file_sanity_check(yaml_dict, file_path): diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py index 06d8a50a6903d7fedfe69dc960fac78ee8782274..801887642f4b583af0a8aa361e1079e2e57e5965 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderAbsorptionTest.py @@ -4,13 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid import unittest -from six import iterkeys, assertRaisesRegex - from isis_powder.routines import absorb_corrections, SampleDetails @@ -37,17 +33,17 @@ class ISISPowderAbsorptionTest(unittest.TestCase): } # Test each key one at a time - for blacklisted_key in iterkeys(sample_properties): + for blacklisted_key in sample_properties.keys(): # Force python to make a shallow copy modified_dict = sample_properties.copy() modified_dict.pop(blacklisted_key) # Check that is raises an error - with assertRaisesRegex(self, KeyError, "The following key was not found in the advanced configuration"): + with self.assertRaisesRegex(KeyError, "The following key was not found in the advanced configuration"): absorb_corrections.create_vanadium_sample_details_obj(config_dict=modified_dict) # Then check the error actually has the key name in it - with assertRaisesRegex(self, KeyError, blacklisted_key): + with self.assertRaisesRegex(KeyError, blacklisted_key): absorb_corrections.create_vanadium_sample_details_obj(config_dict=modified_dict) diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderAbstractInstrumentTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderAbstractInstrumentTest.py index 711d3f2e3d791750b49f1a0ee575bc57efd10d0d..cc8509c4b56e51e97420b0c11034cb49cdd2dfd5 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderAbstractInstrumentTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderAbstractInstrumentTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid from isis_powder.abstract_inst import AbstractInst diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py index 5021089160d6dc2f06980c08366c5a0b07adf79b..21284c0a3e5dd28138a776f4d49dd630f2f3926b 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderCommonTest.py @@ -4,13 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid # Have to import Mantid to setup paths import unittest -from six import assertRaisesRegex - from isis_powder.routines import common, common_enums, SampleDetails @@ -23,12 +19,12 @@ class ISISPowderCommonTest(unittest.TestCase): dict_with_key = {correct_key_name: expected_val} # Check it correctly raises - with assertRaisesRegex(self, KeyError, "The field '" + missing_key_name + "' is required"): + with self.assertRaisesRegex(KeyError, "The field '" + missing_key_name + "' is required"): common.cal_map_dictionary_key_helper(dictionary=dict_with_key, key=missing_key_name) # Check it correctly appends the passed error message when raising appended_e_msg = "test append message" - with assertRaisesRegex(self, KeyError, appended_e_msg): + with self.assertRaisesRegex(KeyError, appended_e_msg): common.cal_map_dictionary_key_helper(dictionary=dict_with_key, key=missing_key_name, append_to_error_message=appended_e_msg) @@ -60,15 +56,15 @@ class ISISPowderCommonTest(unittest.TestCase): bank_list.append(mantid.CreateSampleWorkspace(OutputWorkspace=out_name, XMin=0, XMax=1100, BinWidth=1)) # Check a list of WS and single cropping value is detected - with assertRaisesRegex(self, ValueError, "The cropping values were not in a list or tuple type"): + with self.assertRaisesRegex(ValueError, "The cropping values were not in a list or tuple type"): common.crop_banks_using_crop_list(bank_list=bank_list, crop_values_list=1000) # Check a list of cropping values and a single workspace is detected - with assertRaisesRegex(self, RuntimeError, "Attempting to use list based cropping"): + with self.assertRaisesRegex(RuntimeError, "Attempting to use list based cropping"): common.crop_banks_using_crop_list(bank_list=bank_list[0], crop_values_list=cropping_value_list) # What about a mismatch between the number of cropping values and workspaces - with assertRaisesRegex(self, RuntimeError, "The number of TOF cropping values does not match"): + with self.assertRaisesRegex(RuntimeError, "The number of TOF cropping values does not match"): common.crop_banks_using_crop_list(bank_list=bank_list[1:], crop_values_list=cropping_value_list) # Check we can crop a single workspace from the list @@ -97,11 +93,11 @@ class ISISPowderCommonTest(unittest.TestCase): bank_list.append(mantid.CreateSampleWorkspace(OutputWorkspace=out_name, XMin=x_min, XMax=x_max, BinWidth=1)) # Check a list of WS and non list or tuple - with assertRaisesRegex(self, ValueError, "The cropping values were not in a list or tuple type"): + with self.assertRaisesRegex(ValueError, "The cropping values were not in a list or tuple type"): common.crop_banks_using_crop_list(bank_list=bank_list, crop_values_list=1000) # Check a cropping value and a single workspace is detected - with assertRaisesRegex(self, RuntimeError, "Attempting to use list based cropping"): + with self.assertRaisesRegex(RuntimeError, "Attempting to use list based cropping"): common.crop_banks_using_crop_list(bank_list=bank_list[0], crop_values_list=cropping_value) # Check we can crop a single workspace from the list @@ -208,7 +204,7 @@ class ISISPowderCommonTest(unittest.TestCase): with self.assertRaises(KeyError): common.dictionary_key_helper(dictionary=test_dictionary, key=bad_key_name) - with assertRaisesRegex(self, KeyError, e_msg): + with self.assertRaisesRegex(KeyError, e_msg): common.dictionary_key_helper(dictionary=test_dictionary, key=bad_key_name, exception_msg=e_msg) self.assertEqual(common.dictionary_key_helper(dictionary=test_dictionary, key=good_key_name), 123) @@ -312,11 +308,11 @@ class ISISPowderCommonTest(unittest.TestCase): def test_generate_run_numbers_fails(self): run_input_sting = "text-string" - with assertRaisesRegex(self, ValueError, "Could not generate run numbers from this input"): + with self.assertRaisesRegex(ValueError, "Could not generate run numbers from this input"): common.generate_run_numbers(run_number_string=run_input_sting) # Check it says what the actual string was - with assertRaisesRegex(self, ValueError, run_input_sting): + with self.assertRaisesRegex(ValueError, run_input_sting): common.generate_run_numbers(run_number_string=run_input_sting) def test_load_current_normalised_workspace(self): @@ -446,14 +442,14 @@ class ISISPowderCommonTest(unittest.TestCase): NumBanks=1, BankPixelWidth=1, XMax=10, BinWidth=1)) # What if the item passed in is not a list err_msg_not_list = "was not a list" - with assertRaisesRegex(self, RuntimeError, err_msg_not_list): + with self.assertRaisesRegex(RuntimeError, err_msg_not_list): common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=None) - with assertRaisesRegex(self, RuntimeError, err_msg_not_list): + with self.assertRaisesRegex(RuntimeError, err_msg_not_list): common.rebin_workspace_list(workspace_list=None, bin_width_list=[]) # What about if the lists aren't the same length - with assertRaisesRegex(self, ValueError, "does not match the number of banks"): + with self.assertRaisesRegex(ValueError, "does not match the number of banks"): incorrect_number_bin_widths = [1] * (number_of_ws - 1) common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=incorrect_number_bin_widths) @@ -482,10 +478,10 @@ class ISISPowderCommonTest(unittest.TestCase): # Are the lengths checked incorrect_length = [1] * (number_of_ws - 1) - with assertRaisesRegex(self, ValueError, "The number of starting bin values"): + with self.assertRaisesRegex(ValueError, "The number of starting bin values"): common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=ws_bin_widths, start_x_list=incorrect_length, end_x_list=end_x_list) - with assertRaisesRegex(self, ValueError, "The number of ending bin values"): + with self.assertRaisesRegex(ValueError, "The number of ending bin values"): common.rebin_workspace_list(workspace_list=ws_list, bin_width_list=ws_bin_widths, start_x_list=start_x_list, end_x_list=incorrect_length) @@ -590,7 +586,7 @@ class ISISPowderCommonTest(unittest.TestCase): ws_file_name = "100" # Load POL100 # This should throw as the TOF ranges do not match - with assertRaisesRegex(self, ValueError, "specified for this file do not have matching binning. Do the "): + with self.assertRaisesRegex(ValueError, "specified for this file do not have matching binning. Do the "): common.subtract_summed_runs(ws_to_correct=sample_ws, instrument=ISISPowderMockInst(), empty_sample_ws_string=ws_file_name) diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderFocusCropTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderFocusCropTest.py index c0f7e8baa93fa7c49000b326214deb24b8cdb625..a6036aec7030b10363bc0aa57cad35a7db39d166 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderFocusCropTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderFocusCropTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as mantid from isis_powder.routines import focus import unittest diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderGemOutputTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderGemOutputTest.py index 52a8dc9198f4c527a93078f2e2c198065759b723..95a7dd7a3ae89051440d479cbab148a8f4b23bd6 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderGemOutputTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderGemOutputTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import FileFinder import mantid.simpleapi as mantid # Have to import Mantid to setup paths import unittest diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py index 8040524d061f5165ad0262920875355182f48d07..1c6966ae8e6f3de0cd5c7aa126d6ccc1d11b489b 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderInstrumentSettingsTest.py @@ -4,13 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import warnings -from six import assertRaisesRegex, assertRegex - from isis_powder.routines import instrument_settings, param_map_entry @@ -20,7 +16,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): inst_settings_obj = instrument_settings.InstrumentSettings(param_map=[param_entry]) - with assertRaisesRegex(self, AttributeError, "is required but was not set or passed"): + with self.assertRaisesRegex(AttributeError, "is required but was not set or passed"): foo = inst_settings_obj.script_facing_name del foo @@ -30,7 +26,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): inst_settings_obj = instrument_settings.InstrumentSettings(param_map=[param_entry]) # Check it still prints the acceptable values when it fails - with assertRaisesRegex(self, AttributeError, "A BAR"): + with self.assertRaisesRegex(AttributeError, "A BAR"): foo = inst_settings_obj.script_facing_name del foo @@ -39,7 +35,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): inst_settings_obj = instrument_settings.InstrumentSettings(param_map=[param_entry]) - with assertRaisesRegex(self, AttributeError, "Please contact the development team"): + with self.assertRaisesRegex(AttributeError, "Please contact the development team"): foo = inst_settings_obj.not_known del foo @@ -65,9 +61,9 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): inst_settings_obj = instrument_settings.InstrumentSettings(param_map=[param_entry], kwargs=keyword_args, adv_conf_dict=adv_config) - assertRegex(self, str(warning_capture[-1].message), "which was previously set to") - assertRegex(self, str(warning_capture[-1].message), str(original_value)) - assertRegex(self, str(warning_capture[-1].message), str(new_value)) + self.assertRegex(str(warning_capture[-1].message), "which was previously set to") + self.assertRegex(str(warning_capture[-1].message), str(original_value)) + self.assertRegex(str(warning_capture[-1].message), str(new_value)) self.assertEqual(inst_settings_obj.script_facing_name, new_value) @@ -92,9 +88,9 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): warnings.simplefilter("always") inst_settings_obj.update_attributes(basic_config=config_dict) - assertRegex(self, str(warning_capture[-1].message), "which was previously set to") - assertRegex(self, str(warning_capture[-1].message), str(original_value)) - assertRegex(self, str(warning_capture[-1].message), str(new_value)) + self.assertRegex(str(warning_capture[-1].message), "which was previously set to") + self.assertRegex(str(warning_capture[-1].message), str(original_value)) + self.assertRegex(str(warning_capture[-1].message), str(new_value)) warnings_current_length = len(warning_capture) # Then check that we only get one additional warning when replacing values again not two @@ -143,7 +139,7 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): # First test we cannot set it to a different value incorrect_value_dict = {"user_facing_name": "wrong"} - with assertRaisesRegex(self, ValueError, "The user specified value: 'wrong' is unknown"): + with self.assertRaisesRegex(ValueError, "The user specified value: 'wrong' is unknown"): instrument_settings.InstrumentSettings(param_map=[param_entry], adv_conf_dict=incorrect_value_dict) @@ -159,8 +155,8 @@ class ISISPowderInstrumentSettingsTest(unittest.TestCase): def test_param_map_rejects_enum_missing_friendly_name(self): # Check that is the friendly name is not set it is correctly detected - with assertRaisesRegex(self, RuntimeError, - "'enum_friendly_name' was not set. Please contact development team."): + with self.assertRaisesRegex(RuntimeError, + "'enum_friendly_name' was not set. Please contact development team."): param_map_entry.ParamMapEntry(ext_name="user_facing_name", int_name="script_facing_name", enum_class=BadSampleEnum) diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderRunDetailsTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderRunDetailsTest.py index 67f1d5797057d72f9798e8870683a38c09192ff2..917785670ccdd7fb451d3abe0ea1d53c31703d32 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderRunDetailsTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderRunDetailsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.api import os import random diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py index b04f02ed6ed0382e60d7a99dfae457b830d8a02a..d9bd971cdccdab86a231bb20709c12f3cff8fa57 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderSampleDetailsTest.py @@ -4,17 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import io -import six import sys import unittest from isis_powder.routines import sample_details -from six import assertRaisesRegex, assertRegex - class ISISPowderSampleDetailsTest(unittest.TestCase): def test_constructor(self): @@ -61,34 +56,34 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): char_input_value = 'a' # Check it handles empty input - with assertRaisesRegex(self, ValueError, "Could not convert the height to a number"): + with self.assertRaisesRegex(ValueError, "Could not convert the height to a number"): sample_details.SampleDetails(height=empty_input_value, radius=good_input, center=good_center_input, shape="cylinder") # Does it handle bad input and tell us what we put in - with assertRaisesRegex(self, ValueError, ".*to a number. The input was: '" + char_input_value + "'"): + with self.assertRaisesRegex(ValueError, ".*to a number. The input was: '" + char_input_value + "'"): sample_details.SampleDetails(height=char_input_value, radius=good_input, center=good_center_input, shape="cylinder") # Does it indicate which field was incorrect - with assertRaisesRegex(self, ValueError, "radius"): + with self.assertRaisesRegex(ValueError, "radius"): sample_details.SampleDetails(height=good_input, radius=char_input_value, center=good_center_input, shape="cylinder") # Can it handle bad center values - with assertRaisesRegex(self, ValueError, "center"): + with self.assertRaisesRegex(ValueError, "center"): sample_details.SampleDetails(height=good_input, radius=good_input, center=["", 2, 3], shape="cylinder") # Does it throw if were not using a list for the input - with assertRaisesRegex(self, ValueError, "must be specified as a list of X, Y, Z"): + with self.assertRaisesRegex(ValueError, "must be specified as a list of X, Y, Z"): sample_details.SampleDetails(height=good_input, radius=good_input, center=1, shape="cylinder") # Does it throw if we are using a list of incorrect length (e.g. not 3D) - with assertRaisesRegex(self, ValueError, "must have three values corresponding to"): + with self.assertRaisesRegex(ValueError, "must have three values corresponding to"): sample_details.SampleDetails(height=good_input, radius=good_input, center=[], shape="cylinder") - with assertRaisesRegex(self, ValueError, "must have three values corresponding to"): + with self.assertRaisesRegex(ValueError, "must have three values corresponding to"): sample_details.SampleDetails(height=good_input, radius=good_input, center=[1, 2], shape="cylinder") - with assertRaisesRegex(self, ValueError, "must have three values corresponding to"): + with self.assertRaisesRegex(ValueError, "must have three values corresponding to"): sample_details.SampleDetails(height=good_input, radius=good_input, center=[1, 2, 3, 4], shape="cylinder") def test_constructor_with_impossible_val(self): @@ -100,22 +95,22 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): negative_string = "-1" # Check it handles zero - with assertRaisesRegex(self, ValueError, "The value set for height was: 0"): + with self.assertRaisesRegex(ValueError, "The value set for height was: 0"): sample_details.SampleDetails(height=zero_value, radius=good_input, center=good_center_input, shape="cylinder") # Very small negative - with assertRaisesRegex(self, ValueError, "which is impossible for a physical object"): + with self.assertRaisesRegex(ValueError, "which is impossible for a physical object"): sample_details.SampleDetails(height=good_input, radius=negative_value, center=good_center_input, shape="cylinder") # Integer negative - with assertRaisesRegex(self, ValueError, "The value set for height was: -1"): + with self.assertRaisesRegex(ValueError, "The value set for height was: -1"): sample_details.SampleDetails(height=negative_int, radius=good_input, center=good_center_input, shape="cylinder") # String negative - with assertRaisesRegex(self, ValueError, "The value set for radius was: -1"): + with self.assertRaisesRegex(ValueError, "The value set for radius was: -1"): sample_details.SampleDetails(height=good_input, radius=negative_string, center=good_center_input, shape="cylinder") @@ -127,7 +122,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertIsNotNone(sample_details_obj.material_object) # Check that the material is now immutable - with assertRaisesRegex(self, RuntimeError, "The material has already been set to the above details"): + with self.assertRaisesRegex(RuntimeError, "The material has already been set to the above details"): sample_details_obj.set_material(chemical_formula='V') # Check resetting it works @@ -144,7 +139,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertIsNone(sample_details_obj.material_object) # Check we cannot set a material property without setting the underlying material - with assertRaisesRegex(self, RuntimeError, "The material has not been set"): + with self.assertRaisesRegex(RuntimeError, "The material has not been set"): sample_details_obj.set_material_properties(absorption_cross_section=1.0, scattering_cross_section=2.0) # Check that with a material object we are allowed to set material properties @@ -180,7 +175,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertEqual(material_obj_number_density.number_density, number_density_sample) # Check that it raises an error if we have a non-elemental formula without number density - with assertRaisesRegex(self, ValueError, "A number density formula must be set on a chemical formula"): + with self.assertRaisesRegex(ValueError, "A number density formula must be set on a chemical formula"): sample_details._Material(chemical_formula=chemical_formula_complex) # Check it constructs if it is given the number density too @@ -197,14 +192,14 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): good_scattering = 2.0 material_obj = sample_details._Material(chemical_formula='V') - with assertRaisesRegex(self, ValueError, "absorption_cross_section was: -1 which is impossible for a physical " - "object"): + with self.assertRaisesRegex(ValueError, "absorption_cross_section was: -1 which is impossible for a physical " + "object"): material_obj.set_material_properties(abs_cross_sect=bad_absorb, scattering_cross_sect=good_scattering) # Check the immutability flag has not been set on a failure self.assertFalse(material_obj._is_material_props_set) - with assertRaisesRegex(self, ValueError, "scattering_cross_section was: 0"): + with self.assertRaisesRegex(ValueError, "scattering_cross_section was: 0"): material_obj.set_material_properties(abs_cross_sect=good_absorb, scattering_cross_sect=bad_scattering) # Check nothing has been set yet @@ -218,7 +213,7 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): self.assertEqual(material_obj.scattering_cross_section, float(good_scattering)) # Check we cannot set it twice and fields do not change - with assertRaisesRegex(self, RuntimeError, "The material properties have already been set"): + with self.assertRaisesRegex(RuntimeError, "The material properties have already been set"): material_obj.set_material_properties(abs_cross_sect=999, scattering_cross_sect=999) self.assertEqual(material_obj.absorption_cross_section, float(good_absorb)) self.assertEqual(material_obj.scattering_cross_section, float(good_scattering)) @@ -244,19 +239,19 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): # Test with most defaults set sample_details_obj.print_sample_details() captured_std_out_default = std_out_buffer.getvalue() - assertRegex(self, captured_std_out_default, "Height: " + str(float(expected_height))) - assertRegex(self, captured_std_out_default, "Radius: " + str(float(expected_radius))) - assertRegex(self, captured_std_out_default, "Center X:" + str(float(expected_center[0]))) - assertRegex(self, captured_std_out_default, "Material has not been set") + self.assertRegex(captured_std_out_default, "Height: " + str(float(expected_height))) + self.assertRegex(captured_std_out_default, "Radius: " + str(float(expected_radius))) + self.assertRegex(captured_std_out_default, "Center X:" + str(float(expected_center[0]))) + self.assertRegex(captured_std_out_default, "Material has not been set") # Test with material set but not number density sys.stdout = std_out_buffer = get_std_out_buffer_obj() sample_details_obj.set_material(chemical_formula=chemical_formula) sample_details_obj.print_sample_details() captured_std_out_material_default = std_out_buffer.getvalue() - assertRegex(self, captured_std_out_material_default, "Material properties:") - assertRegex(self, captured_std_out_material_default, "Chemical formula: " + chemical_formula) - assertRegex(self, captured_std_out_material_default, "Number Density: Set from elemental properties") + self.assertRegex(captured_std_out_material_default, "Material properties:") + self.assertRegex(captured_std_out_material_default, "Chemical formula: " + chemical_formula) + self.assertRegex(captured_std_out_material_default, "Number Density: Set from elemental properties") # Test with material and number density sys.stdout = std_out_buffer = get_std_out_buffer_obj() @@ -265,13 +260,13 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): number_density=expected_number_density) sample_details_obj.print_sample_details() captured_std_out_material_set = std_out_buffer.getvalue() - assertRegex(self, captured_std_out_material_set, "Chemical formula: " + chemical_formula_two) - assertRegex(self, captured_std_out_material_set, "Number Density: " + str(expected_number_density)) + self.assertRegex(captured_std_out_material_set, "Chemical formula: " + chemical_formula_two) + self.assertRegex(captured_std_out_material_set, "Number Density: " + str(expected_number_density)) # Test with no material properties set - we can reuse buffer from previous test - assertRegex(self, captured_std_out_material_default, "Absorption cross section: Calculated by Mantid") - assertRegex(self, captured_std_out_material_default, "Scattering cross section: Calculated by Mantid") - assertRegex(self, captured_std_out_material_default, "Note to manually override these call") + self.assertRegex(captured_std_out_material_default, "Absorption cross section: Calculated by Mantid") + self.assertRegex(captured_std_out_material_default, "Scattering cross section: Calculated by Mantid") + self.assertRegex(captured_std_out_material_default, "Note to manually override these call") expected_abs_x_section = 2.13 expected_scattering_x_section = 5.32 @@ -282,10 +277,10 @@ class ISISPowderSampleDetailsTest(unittest.TestCase): scattering_cross_section=expected_scattering_x_section) sample_details_obj.print_sample_details() captured_std_out_material_props = std_out_buffer.getvalue() - assertRegex(self, captured_std_out_material_props, "Absorption cross section: " - + str(expected_abs_x_section)) - assertRegex(self, captured_std_out_material_props, "Scattering cross section: " - + str(expected_scattering_x_section)) + self.assertRegex(captured_std_out_material_props, "Absorption cross section: " + + str(expected_abs_x_section)) + self.assertRegex(captured_std_out_material_props, "Scattering cross section: " + + str(expected_scattering_x_section)) finally: # Ensure std IO is restored. Do NOT remove this line as all std out will pipe into our buffer otherwise sys.stdout = old_std_out @@ -354,10 +349,7 @@ def get_std_out_buffer_obj(): # Because of the way that strings and bytes # have changed between Python 2/3 we need to # return a buffer which is appropriate to the current version - if six.PY2: - return io.BytesIO() - elif six.PY3: - return io.StringIO() + return io.StringIO() if __name__ == "__main__": diff --git a/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py b/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py index f9a3019d73446efed8b63ba884ef1392f42d51c2..7efd940a530f59f8b5be013013b87d75713e592d 100644 --- a/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py +++ b/scripts/Diffraction/isis_powder/test/ISISPowderYamlParserTest.py @@ -4,14 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import tempfile import os import unittest import warnings -from six import assertRaisesRegex - from isis_powder.routines import yaml_parser @@ -79,7 +75,7 @@ class ISISPowderYamlParserTest(unittest.TestCase): self.fail("File exists after deleting cannot continue this test") # Check the error message is there - with assertRaisesRegex(self, ValueError, "Config file not found at path"): + with self.assertRaisesRegex(ValueError, "Config file not found at path"): yaml_parser.get_run_dictionary(run_number_string="1", file_path=file_path) def test_is_run_range_unbounded(self): @@ -105,7 +101,7 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_path = file_handle.name file_handle.close() - with assertRaisesRegex(self, ValueError, "YAML files appears to be empty at"): + with self.assertRaisesRegex(ValueError, "YAML files appears to be empty at"): yaml_parser.get_run_dictionary(run_number_string=1, file_path=file_path) def test_run_number_not_found_gives_sane_err(self): @@ -120,15 +116,15 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_handle.close() # Test a value in the middle of 1-10 - with assertRaisesRegex(self, ValueError, "Run number 5 not recognised in cycle mapping file"): + with self.assertRaisesRegex(ValueError, "Run number 5 not recognised in cycle mapping file"): yaml_parser.get_run_dictionary(run_number_string="5", file_path=file_path) # Check on edge of invalid numbers - with assertRaisesRegex(self, ValueError, "Run number 9 not recognised in cycle mapping file"): + with self.assertRaisesRegex(ValueError, "Run number 9 not recognised in cycle mapping file"): yaml_parser.get_run_dictionary(run_number_string=9, file_path=file_path) # What about a range of numbers - with assertRaisesRegex(self, ValueError, "Run number 2 not recognised in cycle mapping file"): + with self.assertRaisesRegex(ValueError, "Run number 2 not recognised in cycle mapping file"): yaml_parser.get_run_dictionary(run_number_string="2-8", file_path=file_path) # Check valid number still works @@ -143,7 +139,7 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_path = file_handle.name file_handle.close() - with assertRaisesRegex(self, ValueError, "Seen multiple unbounded keys in mapping file"): + with self.assertRaisesRegex(ValueError, "Seen multiple unbounded keys in mapping file"): yaml_parser.get_run_dictionary(run_number_string="11", file_path=file_path) def test_yaml_sanity_detects_val_larger_than_unbound(self): @@ -154,8 +150,8 @@ class ISISPowderYamlParserTest(unittest.TestCase): file_path = file_handle.name file_handle.close() - with assertRaisesRegex(self, ValueError, "Found a run range in calibration mapping overlaps an unbounded run " - "range"): + with self.assertRaisesRegex(ValueError, "Found a run range in calibration mapping overlaps an unbounded run " + "range"): yaml_parser.get_run_dictionary(run_number_string="32", file_path=file_path) diff --git a/scripts/Diffraction/wish/reduce.py b/scripts/Diffraction/wish/reduce.py index d0b58a042bb3d1d8a72e642a54cf018aeed3379c..fe898d4fe7887d25441d0596bb592b9389329b1d 100644 --- a/scripts/Diffraction/wish/reduce.py +++ b/scripts/Diffraction/wish/reduce.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid import logger import mantid.simpleapi as simple import os diff --git a/scripts/Elemental_Analysis.py b/scripts/Elemental_Analysis.py index ef3ed66f8282e6f04e8e3d63cf337acd53481701..51c824c0f67d9894b22e67995355350a50d32fd4 100644 --- a/scripts/Elemental_Analysis.py +++ b/scripts/Elemental_Analysis.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from qtpy import QtCore from Muon.GUI.ElementalAnalysis.elemental_analysis import ElementalAnalysisGui from Muon.GUI.Common.usage_report import report_interface_startup diff --git a/scripts/Engineering/EnggUtils.py b/scripts/Engineering/EnggUtils.py index 6d5b752f7733b4322d26f8ff06e0f2395a9a9085..370527dbb59ba0efc5e4778e8ec6f2e8a1a504f3 100644 --- a/scripts/Engineering/EnggUtils.py +++ b/scripts/Engineering/EnggUtils.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import * import mantid.simpleapi as mantid diff --git a/scripts/Engineering/EnginX.py b/scripts/Engineering/EnginX.py index 933b4956628700caac68d5d96f0c6ff9630d25de..6bb5c4449757e389f2de2d6b5d74654a96ee20c5 100644 --- a/scripts/Engineering/EnginX.py +++ b/scripts/Engineering/EnginX.py @@ -4,16 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import csv import matplotlib.pyplot as plt import numpy as np import os from platform import system from shutil import copy2 -import six - import mantid.plots # noqa import Engineering.EnggUtils as Utils import mantid.simpleapi as simple @@ -576,18 +572,11 @@ def focus_texture_mode(run_number, van_curves, van_int, focus_directory, focus_g banks = {} # read the csv file to work out the banks # ensure csv reading works on python 2 or 3 - if not six.PY2: - with open(dg_file, 'r', newline='', encoding='utf-8') as grouping_file: - group_reader = csv.reader(_decomment_csv(grouping_file), delimiter=',') - - for row in group_reader: - banks.update({row[0]: ','.join(row[1:])}) - else: - with open(dg_file, 'r') as grouping_file: - group_reader = csv.reader(_decomment_csv(grouping_file), delimiter=',') + with open(dg_file, 'r', newline='', encoding='utf-8') as grouping_file: + group_reader = csv.reader(_decomment_csv(grouping_file), delimiter=',') - for row in group_reader: - banks.update({row[0]: ','.join(row[1:])}) + for row in group_reader: + banks.update({row[0]: ','.join(row[1:])}) # loop through the banks described in the csv, focusing and saing them out for bank in banks: @@ -635,7 +624,7 @@ def _save_out(run_number, focus_directory, focus_general, output, enginx_file_na dat_name, genie_filename, gss_name, hdf5_name, nxs_name = _find_focus_file_location(bank_id, focus_directory, enginx_file_name_format, run_number) - if not six.u(bank_id).isnumeric(): + if not str(bank_id).isnumeric(): bank_id = 0 # save the files out to the user directory simple.SaveFocusedXYE(InputWorkspace=output, Filename=dat_name, SplitFiles=False, diff --git a/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py b/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py index 97157eaa5f9a1614077f4e20869276de0cca4d71..6c71e427b75654f2d919591e6d3d16503778cc9e 100644 --- a/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py +++ b/scripts/Engineering/gui/engineering_diffraction/engineering_diffraction.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy import QtCore, QtWidgets from .tabs.calibration.model import CalibrationModel diff --git a/scripts/Engineering/gui/engineering_diffraction/settings/settings_helper.py b/scripts/Engineering/gui/engineering_diffraction/settings/settings_helper.py index ecfa06083aba7e992736efe4cfffad4ac006882a..b9e2df13e27b01de37fdca2553d5d22ce747ec8d 100644 --- a/scripts/Engineering/gui/engineering_diffraction/settings/settings_helper.py +++ b/scripts/Engineering/gui/engineering_diffraction/settings/settings_helper.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy.QtCore import QSettings diff --git a/scripts/Engineering/gui/engineering_diffraction/settings/settings_model.py b/scripts/Engineering/gui/engineering_diffraction/settings/settings_model.py index 24a641c2458ca2cb77c94872f40d21ad13868375..fb003562f72a5b19641a4a6847a96d602c4ab446 100644 --- a/scripts/Engineering/gui/engineering_diffraction/settings/settings_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/settings/settings_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Engineering.gui.engineering_diffraction.settings.settings_helper import get_setting, set_setting from Engineering.gui.engineering_diffraction.tabs.common import path_handling diff --git a/scripts/Engineering/gui/engineering_diffraction/settings/settings_presenter.py b/scripts/Engineering/gui/engineering_diffraction/settings/settings_presenter.py index ef44ae60a5cf9e6c220f72f347741912aa45bfc7..1a3f20754452424727a579d2b9bc64d1575dbe4c 100644 --- a/scripts/Engineering/gui/engineering_diffraction/settings/settings_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/settings/settings_presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - from os import path SETTINGS_DICT = {"save_location": str, "full_calibration": str, "recalc_vanadium": bool} diff --git a/scripts/Engineering/gui/engineering_diffraction/settings/settings_view.py b/scripts/Engineering/gui/engineering_diffraction/settings/settings_view.py index 59b9bfa8dddafa6793671672ece5003c282216a4..d5c9b4e215dbadb6731717a5d6c89de8ad45fc49 100644 --- a/scripts/Engineering/gui/engineering_diffraction/settings/settings_view.py +++ b/scripts/Engineering/gui/engineering_diffraction/settings/settings_view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets, QtCore from mantidqt.utils.qt import load_ui diff --git a/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_helper.py b/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_helper.py index f9d646c9d4ecc703a522ca79f89470cb5724f38e..0b162adde95d586d35f070e49744a811f18eec95 100644 --- a/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_helper.py +++ b/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_helper.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Engineering.gui.engineering_diffraction.settings.settings_helper import set_setting, get_setting from qtpy.QtCore import QSettings, QCoreApplication diff --git a/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_model.py b/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_model.py index e7efc5d99e75f3852374fc03ecba7dd6eab6bced..17f7b77831d8415d9f8e6d5958965a947cd53bf1 100644 --- a/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_model.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat.mock import patch +from unittest.mock import patch from Engineering.gui.engineering_diffraction.settings.settings_model import SettingsModel dir_path = "Engineering.gui.engineering_diffraction.settings." diff --git a/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_presenter.py b/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_presenter.py index b60834f9309d9ac85de2fc51f44237efdb3cb5f6..03b3e977b07490b719457bd799701ece3ffe3377 100644 --- a/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/settings/test/test_settings_presenter.py @@ -5,11 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from Engineering.gui.engineering_diffraction.settings import settings_model, settings_view, settings_presenter diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py index 7226bcbeecc9017b4effab53ad35edbf44dbe74a..99fdd6912832c521daa58d347d06fc606290b74a 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from os import path, makedirs from matplotlib import gridspec import matplotlib.pyplot as plt diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py index c2f544610995594f506a924291cc4f5dff3d452b..581c8ae078abc8f854a497c111897657eb64b2b2 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - from copy import deepcopy from Engineering.gui.engineering_diffraction.tabs.common import INSTRUMENT_DICT, create_error_message diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_model.py index c0be1f4250ed25d0890f87c2cfc1c9836fea0ee6..1b15fdbc71939a0035633cd1bc474fab2221c5e0 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_model.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat.mock import patch -from mantid.py3compat.mock import MagicMock +from unittest.mock import patch +from unittest.mock import MagicMock from Engineering.gui.engineering_diffraction.tabs.calibration.model import CalibrationModel VANADIUM_NUMBER = "307521" diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_presenter.py index 909b6ba0f3718105e958992c4ec05b11d9f76c0f..8719144e3d943140aa6680824d7a68d99ee1071a 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/test/test_calib_presenter.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat.mock import patch, MagicMock -from mantid.py3compat import mock +from unittest.mock import patch, MagicMock +from unittest import mock from Engineering.gui.engineering_diffraction.tabs.calibration import model, view, presenter from Engineering.gui.engineering_diffraction.tabs.common.calibration_info import CalibrationInfo diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py index 09d685f039f50c9782972cf189ab6503a1de3a85..c9d71b8f34ab2b5089e7b4994df88f14af52deda 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets, QtCore from mantidqt.utils.qt import load_ui diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/calibration_info.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/calibration_info.py index 4e2d57432e9b48db6113ee6ede6f7d3fe3e3222d..d0902aa517bc043b00ca7d8faf1b7421ca68baf5 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/calibration_info.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/calibration_info.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class CalibrationInfo(object): diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_model.py index 0f610f4e01a06574371a31534a04f08f5d26d312..2ad947119a48384dadeaeaef9b6310941a0a5e2b 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import re ENGINX_MAX_SPECTRA = 2400 # 2512 spectra appear in the ws. But from testing, anything > 2400 doesn't work. diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_presenter.py index 478e9a69474191374319e4107ced77713f3ed26c..ba44698dd08f8a192650d23bf0a7fb93e6c5bb46 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class CroppingPresenter(object): diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_view.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_view.py index 9879c0e339135d4cfb6319b7b05e69064640b91f..adda044e6518d6d56b7e357b0b57cd1b559e4154 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_view.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets from mantidqt.utils.qt import load_ui diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_widget.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_widget.py index 5312ad202a556b94851d332ddbef3c66c48bcce0..21c9c35549aa94971b40189d5fca3bee9786eac4 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_widget.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/cropping_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Engineering.gui.engineering_diffraction.tabs.common.cropping.cropping_model import CroppingModel from Engineering.gui.engineering_diffraction.tabs.common.cropping.cropping_view import CroppingView from Engineering.gui.engineering_diffraction.tabs.common.cropping.cropping_presenter import CroppingPresenter diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py index e7c4a0a730c593bfb4fbdd8af69a141ec837b4f1..75da21c3f4749b8f94d99668b75ad8588effea5f 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from Engineering.gui.engineering_diffraction.tabs.common.cropping.cropping_model import CroppingModel @@ -47,9 +45,9 @@ class CroppingModelTest(unittest.TestCase): self.assertEqual(self.model._clean_spectrum_numbers("2-1, 76-5, 3"), "1-2,5-76,3") def test_clean_spectrum_numbers_equal_range(self): - self.assertRaisesRegexp(ValueError, - "Ranges cannot contain the same value twice. Invalid Range:*", - self.model._clean_spectrum_numbers, "1-1, 76-76, 3") + self.assertRaisesRegex(ValueError, + "Ranges cannot contain the same value twice. Invalid Range:*", + self.model._clean_spectrum_numbers, "1-1, 76-76, 3") def test_validate_and_clean_with_valid_input(self): self.assertEqual(self.model.validate_and_clean_spectrum_numbers("1-6, 7-23, 46, 1"), diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_presenter.py index 11cd00f1531d1e9797de20655d611fd39643f879..dc49c3c48ce7597630ec48b9715b5a721b2bf97a 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/cropping/test/test_cropping_presenter.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from Engineering.gui.engineering_diffraction.tabs.common.cropping import cropping_model, cropping_view, cropping_presenter dir_path = "Engineering.gui.engineering_diffraction.tabs.common.cropping" diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/path_handling.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/path_handling.py index 07df2ef7e1a5dc1f9267afe331b55d1e055d3852..97fdbd900fbe7b9df5dd824b322506113838bd3f 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/path_handling.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/path_handling.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from os import path from mantid.kernel import logger from mantid.simpleapi import Load diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/test/test_vanadium_corrections.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/test/test_vanadium_corrections.py index 7feb1cca23b64b3807065a4476e18bc5d7851948..b27db29fcf9493139830389ecc1389446b1ee86f 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/test/test_vanadium_corrections.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/test/test_vanadium_corrections.py @@ -4,15 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import tempfile from shutil import rmtree from os import path from Engineering.gui.engineering_diffraction.tabs.common import vanadium_corrections -from mantid.py3compat.mock import patch +from unittest.mock import patch dir_path = "Engineering.gui.engineering_diffraction.tabs.common" diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/common/vanadium_corrections.py b/scripts/Engineering/gui/engineering_diffraction/tabs/common/vanadium_corrections.py index 9526b520710b9cf1b800eeb99a47249f55c3c0b1..710bcb9dbea07b53b4cdf436c6d18800bd0d676b 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/common/vanadium_corrections.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/common/vanadium_corrections.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from os import path from os import makedirs diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_model.py index 1c42efc282f570e4f4cf68146439d2e2524f02a9..3d177b0ac34e09e4ac14c7d4153c575288b69ec1 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_model.py @@ -6,8 +6,8 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock -from mantid.py3compat.mock import patch +from unittest import mock +from unittest.mock import patch from Engineering.gui.engineering_diffraction.tabs.fitting.data_handling.data_model import FittingDataModel diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_presenter.py index 4d0301cb2de3eab2d4d446a96bdb015216f3832f..fe3e6af22a9945fb34795a5674e440322c554f5d 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/data_handling/test/test_data_presenter.py @@ -6,8 +6,8 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock -from mantid.py3compat.mock import patch +from unittest import mock +from unittest.mock import patch from Engineering.gui.engineering_diffraction.tabs.fitting.data_handling import data_model, data_presenter, data_view diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_model.py index 812fcfa65e95979244ff1c8ab6895625efae38fd..d05061a7b48ac18f010979bd452125b4ef5dab3d 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_model.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from Engineering.gui.engineering_diffraction.tabs.fitting.plotting import plot_model diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py index 293ae3859c8dd97c7584b95301297172c753eccf..3595a2bb52cd390db0e200585c4c1327ae740697 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/fitting/plotting/test/test_plot_presenter.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from Engineering.gui.engineering_diffraction.tabs.fitting.plotting import plot_model, plot_view, plot_presenter diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/model.py index a744c6995cc5cd64365faa0d8388afde7cc35219..7018f1bf99c6d4a0e07821537979dbaff2ef833a 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import csv from os import path, makedirs from matplotlib import gridspec diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py index 037145720d5fbf806d72cb30ff2eb19129e8fa06..b4d8a8c8290eb2f67b998a85963e7eb054583807 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - from Engineering.gui.engineering_diffraction.tabs.common import INSTRUMENT_DICT, create_error_message from Engineering.gui.engineering_diffraction.tabs.common.calibration_info import CalibrationInfo from Engineering.gui.engineering_diffraction.tabs.common.vanadium_corrections import check_workspaces_exist diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_model.py index d117784272767ff41946ec001cff9adf9a8efce7..413857d2987df6136af7bb9ad57de27045821a63 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_model.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_model.py @@ -4,14 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import tempfile import shutil from os import path -from mantid.py3compat.mock import patch, MagicMock +from unittest.mock import patch, MagicMock from mantid.simpleapi import CreateSampleWorkspace from Engineering.gui.engineering_diffraction.tabs.focus import model from Engineering.gui.engineering_diffraction.tabs.common import path_handling diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_presenter.py b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_presenter.py index e87f279d1b1e58289a0b57b03b430ec89c34d6a0..6d74fefe505990d9a20d74166b3388c7c14b90b2 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_presenter.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/test/test_focus_presenter.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock -from mantid.py3compat.mock import patch, MagicMock +from unittest import mock +from unittest.mock import patch, MagicMock from Engineering.gui.engineering_diffraction.tabs.focus import model, view, presenter from Engineering.gui.engineering_diffraction.tabs.common.calibration_info import CalibrationInfo diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py index b9c89f23ca7fb117d545a64bea8641ac453f9cd6..288d38fbfaee1f5f0d87c2a35ae2e41564786987 100644 --- a/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py +++ b/scripts/Engineering/gui/engineering_diffraction/tabs/focus/view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets, QtCore from mantidqt.utils.qt import load_ui diff --git a/scripts/Engineering_Diffraction.py b/scripts/Engineering_Diffraction.py index a3b4396c63356532ab1be14c715ea7fd1f38767b..a23e7d83dc14a5407dd7053b592b54037c11da7e 100644 --- a/scripts/Engineering_Diffraction.py +++ b/scripts/Engineering_Diffraction.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from Engineering.gui.engineering_diffraction.engineering_diffraction import EngineeringDiffractionGui from qtpy import QtCore diff --git a/scripts/ErrorReporter/error_dialog_app.py b/scripts/ErrorReporter/error_dialog_app.py index 97a136caff84905f27fb24a69d1613cdda7b9f6f..eac92f7ab60a420c20c9b8f70159877e18be9610 100644 --- a/scripts/ErrorReporter/error_dialog_app.py +++ b/scripts/ErrorReporter/error_dialog_app.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import argparse import sys diff --git a/scripts/ErrorReporter/error_report_presenter.py b/scripts/ErrorReporter/error_report_presenter.py index 4033d6800705ea5652314613f8a635eecaaa95dd..ad6630c4355ef2335da10a3e82faaeb1cb2471e9 100644 --- a/scripts/ErrorReporter/error_report_presenter.py +++ b/scripts/ErrorReporter/error_report_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import os from mantid.kernel import ConfigService, ErrorReporter, Logger, UsageService diff --git a/scripts/ErrorReporter/errorreport.py b/scripts/ErrorReporter/errorreport.py index 4f588692b503004359e0c089ec0f5b0ac70f576f..93d179e8335025442591385854960ce39a688735 100644 --- a/scripts/ErrorReporter/errorreport.py +++ b/scripts/ErrorReporter/errorreport.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - import qtpy if qtpy.PYQT5: # noqa diff --git a/scripts/FilterEvents.py b/scripts/FilterEvents.py index 0df797189a229f4b8c4691c78d2e6e0f3dfcdedd..51421f005ce2c2793f4b41f2444e6da35ceb355b 100644 --- a/scripts/FilterEvents.py +++ b/scripts/FilterEvents.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import sys from mantidqt.gui_helper import set_matplotlib_backend, get_qapplication set_matplotlib_backend() # must be called before anything tries to use matplotlib diff --git a/scripts/FilterEvents/eventFilterGUI.py b/scripts/FilterEvents/eventFilterGUI.py index 604453b9e0ae8cd7562b4fe36f1ff710c1405647..29651b3425864533f98713b814880f6542ef70f6 100644 --- a/scripts/FilterEvents/eventFilterGUI.py +++ b/scripts/FilterEvents/eventFilterGUI.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name, too-many-lines, too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) import numpy from qtpy.QtWidgets import (QFileDialog, QMainWindow, QMessageBox, QSlider, QVBoxLayout, QWidget) # noqa diff --git a/scripts/Frequency_Domain_Analysis.py b/scripts/Frequency_Domain_Analysis.py index 245dc491f0f788a130786b101db2c445d281e954..53228c87841c8a8457896bfbdce19814ef122d42 100644 --- a/scripts/Frequency_Domain_Analysis.py +++ b/scripts/Frequency_Domain_Analysis.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from Muon.GUI.FrequencyDomainAnalysis.frequency_domain_analysis_2 import FrequencyAnalysisGui from qtpy import QtCore from Muon.GUI.Common.usage_report import report_interface_startup diff --git a/scripts/Frequency_Domain_Analysis_Old.py b/scripts/Frequency_Domain_Analysis_Old.py index 2452d83cd7f932072c936242542fdd445e8594e6..2bc1e89136c370075c95c151b977c30872d74953 100644 --- a/scripts/Frequency_Domain_Analysis_Old.py +++ b/scripts/Frequency_Domain_Analysis_Old.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - import sys import PyQt4.QtGui as QtGui diff --git a/scripts/HFIR_4Circle_Reduction.py b/scripts/HFIR_4Circle_Reduction.py index 54da4b755effe09bc04aa91040ad0187f9057ca4..a026c1364078d9912c3cb693b770b1eaacdf83b8 100644 --- a/scripts/HFIR_4Circle_Reduction.py +++ b/scripts/HFIR_4Circle_Reduction.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import sys from mantidqt.gui_helper import set_matplotlib_backend, get_qapplication set_matplotlib_backend() # must be called before anything tries to use matplotlib diff --git a/scripts/HFIR_4Circle_Reduction/FindUBUtility.py b/scripts/HFIR_4Circle_Reduction/FindUBUtility.py index 9591efb30b63f0596ee6f8a9f92a90845af77871..a9f995b25dd0fc1796cd3637b257731cb3867c66 100644 --- a/scripts/HFIR_4Circle_Reduction/FindUBUtility.py +++ b/scripts/HFIR_4Circle_Reduction/FindUBUtility.py @@ -7,7 +7,6 @@ """ Containing a set of classes used for finding (calculating and refining) UB matrix """ -from __future__ import (absolute_import, division, print_function) import os from . import guiutility from qtpy.QtWidgets import (QDialog, QFileDialog) # noqa diff --git a/scripts/HFIR_4Circle_Reduction/IntegrateSingePtSubWindow.py b/scripts/HFIR_4Circle_Reduction/IntegrateSingePtSubWindow.py index 298b8e9ceb6e5ef5a39c93bbcf6ca49aa86aa696..bd4e7a65360505cde4ace443591bfe5b4adefc31 100644 --- a/scripts/HFIR_4Circle_Reduction/IntegrateSingePtSubWindow.py +++ b/scripts/HFIR_4Circle_Reduction/IntegrateSingePtSubWindow.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=C0103 -from __future__ import (absolute_import, division, print_function) from HFIR_4Circle_Reduction.hfctables import SinglePtIntegrationTable from HFIR_4Circle_Reduction.integratedpeakview import SinglePtIntegrationView import HFIR_4Circle_Reduction.guiutility as guiutility diff --git a/scripts/HFIR_4Circle_Reduction/NTableWidget.py b/scripts/HFIR_4Circle_Reduction/NTableWidget.py index b595cadfa9beccadf625a8017e29e053137b692b..74598a992dacf20cc48b0e02a686c9296dc8533d 100644 --- a/scripts/HFIR_4Circle_Reduction/NTableWidget.py +++ b/scripts/HFIR_4Circle_Reduction/NTableWidget.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=C0103,R0904 # N(DAV)TableWidget -from __future__ import (absolute_import, division, print_function) -from six.moves import range import csv from qtpy.QtWidgets import (QCheckBox, QTableWidget, QTableWidgetItem) # noqa from qtpy import QtCore # noqa diff --git a/scripts/HFIR_4Circle_Reduction/PeaksIntegrationReport.py b/scripts/HFIR_4Circle_Reduction/PeaksIntegrationReport.py index fb81758227559a3a8aca9e522fe60b56c05ae3db..ab129168f40c5beab0771459f0743290f155ca93 100644 --- a/scripts/HFIR_4Circle_Reduction/PeaksIntegrationReport.py +++ b/scripts/HFIR_4Circle_Reduction/PeaksIntegrationReport.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os from qtpy.QtWidgets import (QDialog, QFileDialog) # noqa diff --git a/scripts/HFIR_4Circle_Reduction/absorption.py b/scripts/HFIR_4Circle_Reduction/absorption.py index e7c5dc13c0369872aae8e9c65bd44cc65138320d..255b850ab1bce9eaf76673dd782c131fa7e82d84 100644 --- a/scripts/HFIR_4Circle_Reduction/absorption.py +++ b/scripts/HFIR_4Circle_Reduction/absorption.py @@ -5,14 +5,11 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=R0913,W0403,R0903,C0103 -from __future__ import (absolute_import, division, print_function) import HFIR_4Circle_Reduction.fourcircle_utility as util4 import math from mantid.api import AnalysisDataService import numpy import numpy.linalg -from six.moves import range - # This module does absorption correction diff --git a/scripts/HFIR_4Circle_Reduction/detector2dview.py b/scripts/HFIR_4Circle_Reduction/detector2dview.py index 37baa6b3f90346a2ccce6d79d3e353cdf7e2b9be..6de56654864d20c65e0d590ec3f238afd4b759b0 100644 --- a/scripts/HFIR_4Circle_Reduction/detector2dview.py +++ b/scripts/HFIR_4Circle_Reduction/detector2dview.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=W0403,R0902,R0903,R0904,W0212 -from __future__ import (absolute_import, division, print_function) from HFIR_4Circle_Reduction import mpl2dgraphicsview import numpy as np import os diff --git a/scripts/HFIR_4Circle_Reduction/fourcircle_utility.py b/scripts/HFIR_4Circle_Reduction/fourcircle_utility.py index 8ea88badebac3a35ac5ee4c6677e32029a55b7c4..5678816a1f21aa9135527768cbeb24580cf83ac0 100644 --- a/scripts/HFIR_4Circle_Reduction/fourcircle_utility.py +++ b/scripts/HFIR_4Circle_Reduction/fourcircle_utility.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=W0633,R0913,too-many-branches -from __future__ import (absolute_import, division, print_function) -from six.moves import range import csv import os try: diff --git a/scripts/HFIR_4Circle_Reduction/fputility.py b/scripts/HFIR_4Circle_Reduction/fputility.py index 37ad2c9a9805077ce79d1c3d989e35b10f34dc17..a57d8906fbb4d9fddcd7c5abb3563b848af88695 100644 --- a/scripts/HFIR_4Circle_Reduction/fputility.py +++ b/scripts/HFIR_4Circle_Reduction/fputility.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=R0914,R0912,R0913 # Utility methods for Fullprof -from __future__ import (absolute_import, division, print_function) import os import math diff --git a/scripts/HFIR_4Circle_Reduction/guiutility.py b/scripts/HFIR_4Circle_Reduction/guiutility.py index 6e78c1c31c4422af3ef46e44a69c5951aa2faab1..33686806dc607a6a37796a55e05b9d98573ba0b8 100644 --- a/scripts/HFIR_4Circle_Reduction/guiutility.py +++ b/scripts/HFIR_4Circle_Reduction/guiutility.py @@ -7,8 +7,6 @@ # # GUI Utility Methods # -from __future__ import (absolute_import, division, print_function) -from six.moves import range import math import numpy import os diff --git a/scripts/HFIR_4Circle_Reduction/hfctables.py b/scripts/HFIR_4Circle_Reduction/hfctables.py index 2903c2cc580064b4641981955c7e3be37cab5ddd..1c9a4e3c7b1c177033bbd14729ba33848c160bf5 100644 --- a/scripts/HFIR_4Circle_Reduction/hfctables.py +++ b/scripts/HFIR_4Circle_Reduction/hfctables.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=W0403,C0103,R0901,R0904,R0913,C0302 -from __future__ import (absolute_import, division, print_function) -from six.moves import range import numpy import sys from HFIR_4Circle_Reduction import fourcircle_utility diff --git a/scripts/HFIR_4Circle_Reduction/integratedpeakview.py b/scripts/HFIR_4Circle_Reduction/integratedpeakview.py index 88d4db885bb7d6b0059a8b09dbab47915fa14000..a30b982585be6687a25138e9e9a35dbbad70c32b 100644 --- a/scripts/HFIR_4Circle_Reduction/integratedpeakview.py +++ b/scripts/HFIR_4Circle_Reduction/integratedpeakview.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=W0403,R0904,R0903 -from __future__ import (absolute_import, division, print_function) import numpy from HFIR_4Circle_Reduction import mplgraphicsview diff --git a/scripts/HFIR_4Circle_Reduction/message_dialog.py b/scripts/HFIR_4Circle_Reduction/message_dialog.py index 5bd120966b0323502222bfdc2ded22f3d3bee309..dc3cee74144e6e94e1f5285c1e2586c0cb2d3282 100644 --- a/scripts/HFIR_4Circle_Reduction/message_dialog.py +++ b/scripts/HFIR_4Circle_Reduction/message_dialog.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # Dialog for message -from __future__ import (absolute_import, division, print_function) -from six.moves import range from qtpy.QtWidgets import (QDialog) # noqa from mantid.kernel import Logger try: diff --git a/scripts/HFIR_4Circle_Reduction/mpl2dgraphicsview.py b/scripts/HFIR_4Circle_Reduction/mpl2dgraphicsview.py index 35999dd59c1b92d09928b04ff6734fe3fe6dee85..9b94c4d6cb6e927d51a157ae5ef180cc906ba13c 100644 --- a/scripts/HFIR_4Circle_Reduction/mpl2dgraphicsview.py +++ b/scripts/HFIR_4Circle_Reduction/mpl2dgraphicsview.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,too-many-public-methods,too-many-arguments,non-parent-init-called,R0901,R0902,too-many-branches,C0302 -from __future__ import (absolute_import, division, print_function) import os import numpy as np from qtpy.QtWidgets import (QWidget, QVBoxLayout, QSizePolicy) diff --git a/scripts/HFIR_4Circle_Reduction/mplgraphicsview.py b/scripts/HFIR_4Circle_Reduction/mplgraphicsview.py index 07ad0787b8e19641bc1dab9bdf3f435044fd2325..3492b1335edb83b333cb669d7ad7ebd648590a39 100644 --- a/scripts/HFIR_4Circle_Reduction/mplgraphicsview.py +++ b/scripts/HFIR_4Circle_Reduction/mplgraphicsview.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,too-many-public-methods,too-many-arguments,non-parent-init-called,R0902,too-many-branches,C0302 -from __future__ import (absolute_import, division, print_function) -from six.moves import range import os import numpy as np from mantidqt.MPLwidgets import FigureCanvasQTAgg as FigureCanvas diff --git a/scripts/HFIR_4Circle_Reduction/mplgraphicsview3d.py b/scripts/HFIR_4Circle_Reduction/mplgraphicsview3d.py index 90633c55ae21c660eb5e038b50b516ce4d49546a..b4fd4e22a0ec3adc421b9cb72c45cd8359771680 100644 --- a/scripts/HFIR_4Circle_Reduction/mplgraphicsview3d.py +++ b/scripts/HFIR_4Circle_Reduction/mplgraphicsview3d.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=R0901,R0902,R0904 -from __future__ import (absolute_import, division, print_function) -from six.moves import range import numpy as np import os diff --git a/scripts/HFIR_4Circle_Reduction/multi_threads_helpers.py b/scripts/HFIR_4Circle_Reduction/multi_threads_helpers.py index 9ef97de5f18bfe9cddaf8498bf9c0d616f621605..c96ecef7c1e8582c9ac1fd910721a9f2769bebda 100644 --- a/scripts/HFIR_4Circle_Reduction/multi_threads_helpers.py +++ b/scripts/HFIR_4Circle_Reduction/multi_threads_helpers.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=W0403,R0913,R0902 -from __future__ import (absolute_import, division, print_function) import os from qtpy.QtCore import Signal as pyqtSignal from qtpy.QtCore import QThread # noqa diff --git a/scripts/HFIR_4Circle_Reduction/optimizelatticewindow.py b/scripts/HFIR_4Circle_Reduction/optimizelatticewindow.py index 358c8e91ef32c0f44477f475a7831ed2905270fd..4823c7cd5199edac87f0d46215ee9be017b80cbf 100644 --- a/scripts/HFIR_4Circle_Reduction/optimizelatticewindow.py +++ b/scripts/HFIR_4Circle_Reduction/optimizelatticewindow.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=C0103 -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QMainWindow) from qtpy.QtCore import Signal as pyqtSignal from mantid.kernel import Logger diff --git a/scripts/HFIR_4Circle_Reduction/peak_integration_utility.py b/scripts/HFIR_4Circle_Reduction/peak_integration_utility.py index b9d13c6802e8bda26e7a14ef8997a916929428c0..c5011c6af8f2e28f7b65aca931e6ccdf683ebc42 100644 --- a/scripts/HFIR_4Circle_Reduction/peak_integration_utility.py +++ b/scripts/HFIR_4Circle_Reduction/peak_integration_utility.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # Utility methods to do peak integration -from __future__ import (absolute_import, division, print_function) -from six.moves import range import numpy import math import os diff --git a/scripts/HFIR_4Circle_Reduction/peakprocesshelper.py b/scripts/HFIR_4Circle_Reduction/peakprocesshelper.py index ae0e5bbeb5a1a434a70eecd9e6db0320fc4f286c..dc6ad63d5fd3195becb98f6e250c7b50c60dda54 100644 --- a/scripts/HFIR_4Circle_Reduction/peakprocesshelper.py +++ b/scripts/HFIR_4Circle_Reduction/peakprocesshelper.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=W0403,R0902 -from __future__ import (absolute_import, division, print_function) -from six.moves import range import numpy import time import random diff --git a/scripts/HFIR_4Circle_Reduction/plot3dwindow.py b/scripts/HFIR_4Circle_Reduction/plot3dwindow.py index a88c9bd0a1881a61dc55869e03b8198738326ada..8de6d26cb817bb0b9d06c9f94be9e789ed2218e2 100644 --- a/scripts/HFIR_4Circle_Reduction/plot3dwindow.py +++ b/scripts/HFIR_4Circle_Reduction/plot3dwindow.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=C0103,W0403 -from __future__ import (absolute_import, division, print_function) -from six.moves import range import sys import numpy as np from qtpy.QtWidgets import (QMainWindow) diff --git a/scripts/HFIR_4Circle_Reduction/process_mask.py b/scripts/HFIR_4Circle_Reduction/process_mask.py index d22307f943794b7620fd4b3c88054658430f4c36..bd240492ab0b6ebeee5b66b58b6531645742834c 100644 --- a/scripts/HFIR_4Circle_Reduction/process_mask.py +++ b/scripts/HFIR_4Circle_Reduction/process_mask.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function - import math import numpy import re diff --git a/scripts/HFIR_4Circle_Reduction/project_manager.py b/scripts/HFIR_4Circle_Reduction/project_manager.py index 6c0f9f5425de96bedc4bead39c7dce61667390ab..50a3bc6c916da3787803c06a6b6ecccf3fb1e398 100644 --- a/scripts/HFIR_4Circle_Reduction/project_manager.py +++ b/scripts/HFIR_4Circle_Reduction/project_manager.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os import mantid.simpleapi as mantidsimple diff --git a/scripts/HFIR_4Circle_Reduction/reduce4circleControl.py b/scripts/HFIR_4Circle_Reduction/reduce4circleControl.py index 054bd6c2cf37ad3a9211edec95feee9dcbbfc870..556fa85b0222b44adf0189bfe0fa2623ced0f6ad 100644 --- a/scripts/HFIR_4Circle_Reduction/reduce4circleControl.py +++ b/scripts/HFIR_4Circle_Reduction/reduce4circleControl.py @@ -14,7 +14,6 @@ # - Download from internet to cache (download-mode) # ################################################################################ -from __future__ import (absolute_import, division, print_function) import bisect try: # python3 @@ -25,7 +24,6 @@ except ImportError: from urllib2 import urlopen from urllib2 import HTTPError from urllib2 import URLError -from six.moves import range import math import csv import random diff --git a/scripts/HFIR_4Circle_Reduction/reduce4circleGUI.py b/scripts/HFIR_4Circle_Reduction/reduce4circleGUI.py index 5eadb8771e6c400c5b0358d6c0962bcb6319b1ea..b1917bfd8e5b1ac51f456a00fae96df802878be5 100644 --- a/scripts/HFIR_4Circle_Reduction/reduce4circleGUI.py +++ b/scripts/HFIR_4Circle_Reduction/reduce4circleGUI.py @@ -10,9 +10,6 @@ # MainWindow application for reducing HFIR 4-circle # ################################################################################ -from __future__ import (absolute_import, division, print_function) -from six.moves import range -import six import os import sys import csv @@ -63,8 +60,7 @@ if PYQT4: SCROLL_AVAILABLE = True except ImportError: SCROLL_AVAILABLE = False -if six.PY3: - unicode = str +unicode = str # define constants IndexFromSpice = 'From Spice (pre-defined)' diff --git a/scripts/HFIR_4Circle_Reduction/refineubfftsetup.py b/scripts/HFIR_4Circle_Reduction/refineubfftsetup.py index 43ce8a562647a617ec2fe31fb4d21a54e95c2c60..adc0f3c9e3b05e174ca800612b07ce36c25b48e4 100644 --- a/scripts/HFIR_4Circle_Reduction/refineubfftsetup.py +++ b/scripts/HFIR_4Circle_Reduction/refineubfftsetup.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy.QtWidgets import (QDialog) # noqa from mantid.kernel import Logger try: diff --git a/scripts/HFIR_4Circle_Reduction/viewspicedialog.py b/scripts/HFIR_4Circle_Reduction/viewspicedialog.py index d169d0b65019e40b278b670c98aae95cab349e3e..e7f47610f6e68c0495f13c4f5f88fa2664fb30b4 100644 --- a/scripts/HFIR_4Circle_Reduction/viewspicedialog.py +++ b/scripts/HFIR_4Circle_Reduction/viewspicedialog.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QDialog) # noqa from mantid.kernel import Logger try: diff --git a/scripts/Inelastic/CrystalField/__init__.py b/scripts/Inelastic/CrystalField/__init__.py index d057ea945087019be119cea700a7e848d95afdef..a8ed4a5891083a2a5aa7b3675737ce616a075082 100644 --- a/scripts/Inelastic/CrystalField/__init__.py +++ b/scripts/Inelastic/CrystalField/__init__.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from .fitting import CrystalField, CrystalFieldFit from .function import PeaksFunction, Background, Function, ResolutionModel, PhysicalProperties from .pointcharge import PointCharge diff --git a/scripts/Inelastic/CrystalField/energies.py b/scripts/Inelastic/CrystalField/energies.py index 9cc270c3b8cd88ca37f78eebf863e2606b1b9951..ac979e1ac198b87bb596327958ef2b5396eba81b 100644 --- a/scripts/Inelastic/CrystalField/energies.py +++ b/scripts/Inelastic/CrystalField/energies.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-name-in-module -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import CrystalFieldEnergies import numpy as np import warnings diff --git a/scripts/Inelastic/CrystalField/fitting.py b/scripts/Inelastic/CrystalField/fitting.py index 586e7189746d39fcbe79fc0f10231f8330d33696..88380bc986ac3aed7f68d0d0c8bd330f2880ace6 100644 --- a/scripts/Inelastic/CrystalField/fitting.py +++ b/scripts/Inelastic/CrystalField/fitting.py @@ -4,13 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import re import warnings -from six import string_types, iteritems - - # RegEx pattern matching a composite function parameter name, eg f2.Sigma. FN_PATTERN = re.compile('f(\\d+)\\.(.+)') @@ -903,7 +899,7 @@ class CrystalField(object): ws_index = args.pop(0) pptype = 'M(T)' if (typeid == 4) else 'M(H)' - self._typeid = self._str2id(typeid) if isinstance(typeid, string_types) else int(typeid) + self._typeid = self._str2id(typeid) if isinstance(typeid, str) else int(typeid) return self._getPhysProp(PhysicalProperties(pptype, *args, **kwargs), workspace, ws_index) @@ -1004,7 +1000,7 @@ class CrystalField(object): params['ion1.' + bparam] = other[bparam] ties = {} fixes = [] - for prefix, obj in iteritems({'ion0.':self, 'ion1.':other}): + for prefix, obj in {'ion0.':self, 'ion1.':other}.items(): tiestr = obj.function.getTies() if tiestr: for tiepair in [tie.split('=') for tie in tiestr.split(',')]: @@ -1159,7 +1155,7 @@ class CrystalField(object): alg = AlgorithmManager.createUnmanaged('EvaluateFunction') alg.initialize() alg.setChild(True) - alg.setProperty('Function', i if isinstance(i, string_types) else self.makeSpectrumFunction(i)) + alg.setProperty('Function', i if isinstance(i, str) else self.makeSpectrumFunction(i)) alg.setProperty("InputWorkspace", workspace) alg.setProperty('WorkspaceIndex', ws_index) alg.setProperty('OutputWorkspace', 'dummy') diff --git a/scripts/Inelastic/CrystalField/function.py b/scripts/Inelastic/CrystalField/function.py index 9a9b0dfd410c192409b291fba971f50c7eec3126..89ee2dd6aa520be6c9316d50e1d3b73c9ff6fb61 100644 --- a/scripts/Inelastic/CrystalField/function.py +++ b/scripts/Inelastic/CrystalField/function.py @@ -4,10 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import re -from six import string_types - parNamePattern = re.compile(r'([a-zA-Z][\w.]+)') @@ -507,7 +504,7 @@ class PhysicalProperties(object): self._physpropTemperature = 1. self._lambda = 0. # Exchange parameter (for susceptibility only) self._chi0 = 0. # Residual/background susceptibility (for susceptibility only) - self._typeid = self._str2id(typeid) if isinstance(typeid, string_types) else int(typeid) + self._typeid = self._str2id(typeid) if isinstance(typeid, str) else int(typeid) try: initialiser = getattr(self, 'init' + str(self._typeid)) except AttributeError: @@ -530,7 +527,7 @@ class PhysicalProperties(object): def _checkhdir(self, hdir): import numpy as np try: - if isinstance(hdir, string_types): + if isinstance(hdir, str): if 'powder' in hdir.lower(): return 'powder' else: @@ -563,7 +560,7 @@ class PhysicalProperties(object): @Inverse.setter def Inverse(self, value): if (self._typeid == self.SUSCEPTIBILITY or self._typeid == self.MAGNETICMOMENT): - if isinstance(value, string_types): + if isinstance(value, str): self._suscInverseFlag = value.lower() in ['true', 't', '1', 'yes', 'y'] else: self._suscInverseFlag = bool(value) # In some cases will always be true... diff --git a/scripts/Inelastic/CrystalField/normalisation.py b/scripts/Inelastic/CrystalField/normalisation.py index b1e8842b3579f9b15fcd9b0f382277f6f43838bd..bde70d5bb95af9004f5cec28704c3cf79b81c8ee 100644 --- a/scripts/Inelastic/CrystalField/normalisation.py +++ b/scripts/Inelastic/CrystalField/normalisation.py @@ -4,12 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from CrystalField.energies import energies as CFEnergy from CrystalField.fitting import ionname2Nre -from six import iteritems -from six import string_types def _get_normalisation(nre, bnames): @@ -177,10 +174,10 @@ def split2range(*args, **kwargs): argin[argnames[ia]] = args[ia] # Further arguments beyond the first 3 are treated as crystal field parameter names for ia in range(3, len(args)): - if isinstance(args[ia], string_types) and args[ia].startswith('B'): + if isinstance(args[ia], str) and args[ia].startswith('B'): argin['Parameters'].append(args[ia]) # Parses the keyword arguments - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): for ia in range(len(argnames)): if key == argnames[ia]: argin[key] = value diff --git a/scripts/Inelastic/CrystalField/pointcharge.py b/scripts/Inelastic/CrystalField/pointcharge.py index 4ad0b5fc4e6a34fcb74280b7b8d2a4a82f84a44e..b4c71474abb573d65cab6b7c2e7620eeba31fdd6 100644 --- a/scripts/Inelastic/CrystalField/pointcharge.py +++ b/scripts/Inelastic/CrystalField/pointcharge.py @@ -4,9 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np -from six import string_types from scipy import constants import warnings @@ -133,7 +131,7 @@ class PointCharge(object): from mantid.simpleapi import mtd, LoadCIF, CreateWorkspace, DeleteWorkspace import uuid self._fromCIF = False - if isinstance(structure, string_types): + if isinstance(structure, str): if mtd.doesExist(structure): try: self._cryst = self._copyCrystalStructure(mtd[structure].sample().getCrystalStructure()) diff --git a/scripts/Inelastic/Direct/AbsorptionShapes.py b/scripts/Inelastic/Direct/AbsorptionShapes.py index 37dbcc12910524f80b64eecffb9e9162f244585f..bcba21b4b558309d86fe2094812ba8695344b89e 100644 --- a/scripts/Inelastic/Direct/AbsorptionShapes.py +++ b/scripts/Inelastic/Direct/AbsorptionShapes.py @@ -4,8 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) -from six import string_types + from mantid.kernel import funcinspect from mantid.simpleapi import * @@ -107,7 +106,7 @@ class anAbsorptionShape(object): if value is None: self._Material = {} return - if isinstance(value, string_types): + if isinstance(value, str): value = [value] if isinstance(value,(list,tuple)): if len(value) == 2: @@ -130,7 +129,7 @@ class anAbsorptionShape(object): # Mater_properties = self._Material if 'ChemicalFormula' in Mater_properties: - if not isinstance(Mater_properties['ChemicalFormula'], string_types): + if not isinstance(Mater_properties['ChemicalFormula'], str): raise TypeError('*** The chemical formula for the material must be described by a string') # Test if the material property are recognized by SetSampleMaterial # algorithm. @@ -247,7 +246,7 @@ class anAbsorptionShape(object): {'Cylinder': Cylinder(), 'FlatPlate':FlatPlate(), 'HollowCylinder':HollowCylinder(),'Sphere': Sphere()} # noqa: E127 - if not isinstance(str_val, string_types): + if not isinstance(str_val, str): raise ValueError( 'The input of the "from_str" function should be a string representing a diary.' ' Actually it is: {0}'.format(type(str_val))) diff --git a/scripts/Inelastic/Direct/CommonFunctions.py b/scripts/Inelastic/Direct/CommonFunctions.py index a4c5afb4be0f4e7358ed25cc3256c8e98e60861d..c60338a495b035de4451e1986a330afdc18d6fb3 100644 --- a/scripts/Inelastic/Direct/CommonFunctions.py +++ b/scripts/Inelastic/Direct/CommonFunctions.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) - import sys # See https://www.python.org/dev/peps/pep-0479/#abstract and diff --git a/scripts/Inelastic/Direct/DirectEnergyConversion.py b/scripts/Inelastic/Direct/DirectEnergyConversion.py index c92e4a9f14da204da4189915060c162cae9c1277..56abf1de7b1d756ea1e349dde6acc6528358e87b 100644 --- a/scripts/Inelastic/Direct/DirectEnergyConversion.py +++ b/scripts/Inelastic/Direct/DirectEnergyConversion.py @@ -7,7 +7,6 @@ #pylint: disable=too-many-lines #pylint: disable=invalid-name #pylind: disable=attribute-defined-outside-init -from __future__ import (absolute_import, division, print_function, unicode_literals) from mantid.simpleapi import * from mantid.kernel import funcinspect from mantid import geometry,api @@ -18,9 +17,6 @@ import math import time import numpy as np import collections -from six import iteritems, string_types -from six.moves import range - import Direct.CommonFunctions as common import Direct.diagnostics as diagnostics from Direct.PropertyManager import PropertyManager @@ -1344,7 +1340,7 @@ class DirectEnergyConversion(object): self._spectra_masks=None elif isinstance(value,api.Workspace): self._spectra_masks = value.name() - elif isinstance(value, string_types): + elif isinstance(value, str): if value in mtd: self._spectra_masks = value else: @@ -1519,7 +1515,7 @@ class DirectEnergyConversion(object): scale_factor = van_multiplier * sample_multiplier / xsection - for norm_type,val in iteritems(norm_factor): + for norm_type,val in norm_factor.items(): norm_factor[norm_type] = val * scale_factor # check for NaN diff --git a/scripts/Inelastic/Direct/ISISDirecInelasticConfig.py b/scripts/Inelastic/Direct/ISISDirecInelasticConfig.py index 2c42ca646a184564dd840778954a0726f84e7369..55c02cf2e7b1199b035927a84872503876f89e8d 100644 --- a/scripts/Inelastic/Direct/ISISDirecInelasticConfig.py +++ b/scripts/Inelastic/Direct/ISISDirecInelasticConfig.py @@ -5,7 +5,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) import os import sys import platform @@ -15,8 +14,6 @@ import copy from datetime import date import time from xml.dom import minidom -from six import iteritems, string_types - # the list of instruments this configuration is applicable to INELASTIC_INSTRUMENTS = ['MAPS', 'LET', 'MERLIN', 'MARI', 'HET'] # the list of the parameters, which can be replaced if found in user files @@ -94,7 +91,7 @@ class UserProperties(object): self._rb_dirs[recent_date_id] = rb_folder_or_id if self._recent_dateID: max_date = self._start_dates[self._recent_dateID] - for date_key, a_date in iteritems(self._start_dates): + for date_key, a_date in self._start_dates.items(): if a_date > max_date: self._recent_dateID = date_key max_date = a_date @@ -265,7 +262,7 @@ class UserProperties(object): if isinstance(cycle, int): cycle = convert_cycle_int(cycle) - if isinstance(cycle, string_types): + if isinstance(cycle, str): if len(cycle) == 11: last_letter = cycle[-1] if not last_letter.upper() in {'A','B','C','D','E'}: @@ -289,7 +286,7 @@ class UserProperties(object): "but it is {0}".format(cycle)) if isinstance(rb_folder_or_id, int): rb_folder_or_id = "RB{0:07}".format(rb_folder_or_id) - if not isinstance(rb_folder_or_id, string_types): + if not isinstance(rb_folder_or_id, str): raise RuntimeError("RB Folder {0} should be a string".format(rb_folder_or_id)) else: f_path, rbf = os.path.split(rb_folder_or_id) @@ -317,7 +314,7 @@ class UserProperties(object): "ISIS inelastic instruments".format(instrument)) def validate_date(self, start_date): - if isinstance(start_date, string_types): + if isinstance(start_date, str): # the date of express -- let's make it long in the past if start_date.lower() == 'none': start_date = '19800101' diff --git a/scripts/Inelastic/Direct/NonIDF_Properties.py b/scripts/Inelastic/Direct/NonIDF_Properties.py index 95410d6d1e6db3b17fb66ac61a8253e689f9865a..967916b032ddc63fd395eabd9aabb611584f1498 100644 --- a/scripts/Inelastic/Direct/NonIDF_Properties.py +++ b/scripts/Inelastic/Direct/NonIDF_Properties.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function, unicode_literals) -from six import string_types from Direct.PropertiesDescriptors import * from Direct.RunDescriptor import RunDescriptor,RunDescriptorDependent from mantid.simpleapi import * @@ -203,7 +201,7 @@ class NonIDF_Properties(object): facility_ = config.getFacility('TEST_LIVE') #end - elif isinstance(Instrument, string_types): # instrument name defined + elif isinstance(Instrument, str): # instrument name defined new_name,full_name,facility_ = prop_helpers.check_instrument_name(None,Instrument) #idf_dir = config.getString('instrumentDefinitgeton.directory') idf_file = api.ExperimentInfo.getInstrumentFilename(full_name) diff --git a/scripts/Inelastic/Direct/PropertiesDescriptors.py b/scripts/Inelastic/Direct/PropertiesDescriptors.py index 4babec380fed7a5eff845f51f84c02279e90b583..b676d400ae7d2623555ff7756e76a9932c74acc3 100644 --- a/scripts/Inelastic/Direct/PropertiesDescriptors.py +++ b/scripts/Inelastic/Direct/PropertiesDescriptors.py @@ -9,14 +9,11 @@ """ File contains collection of Descriptors used to define complex properties in NonIDF_Properties and PropertyManager classes """ -from __future__ import (absolute_import, division, print_function, unicode_literals) import os import numpy as np import math import re from collections import Iterable -from six import string_types - import mantid.simpleapi as mantid from mantid import api @@ -190,7 +187,7 @@ class IncidentEnergy(PropDescriptor): """ Set up incident energy or range of energies in various formats or define autoEi""" if value is not None: - if isinstance(value, string_types): + if isinstance(value, str): # Check autoEi if value.lower() == 'auto': self._use_autoEi = True @@ -405,7 +402,7 @@ class EnergyBins(PropDescriptor): def __set__(self, instance, values): if values is not None: - if isinstance(values, string_types): + if isinstance(values, str): values = values.replace('[', '').replace(']', '').strip() lst = values.split(',') self.__set__(instance, lst) @@ -622,7 +619,7 @@ class mon2NormalizationEnergyRange(PropDescriptor): """ set detector calibration file using various formats """ if isinstance(val, list): self._relative_range = self._check_range(val, instance) - elif isinstance(val, string_types): + elif isinstance(val, str): val = self._parce_string2list(val) self.__set__(instance, val) else: @@ -744,7 +741,7 @@ class DetCalFile(PropDescriptor): self._det_cal_file = val self._calibrated_by_run = False return - if isinstance(val, string_types): + if isinstance(val, str): if val in mantid.mtd: val = mantid.mtd[val] self._det_cal_file = val @@ -798,7 +795,7 @@ class DetCalFile(PropDescriptor): return (True, 'Workspace {0} used for detectors calibration'.format(self._det_cal_file.name())) dcf_val = self._det_cal_file - if isinstance(dcf_val, string_types): # it may be string representation of runN + if isinstance(dcf_val, str): # it may be string representation of runN try: dcf_val = int(dcf_val) except ValueError: @@ -939,7 +936,7 @@ class HardMaskOnly(prop_helpers.ComplexProperty): if isinstance(value, bool) or isinstance(value, int): use_hard_mask_only = bool(value) hard_mask_file = instance.hard_mask_file - elif isinstance(value, string_types): + elif isinstance(value, str): if value.lower() in ['true', 'yes']: use_hard_mask_only = True elif value.lower() in ['false', 'no']: @@ -1036,7 +1033,7 @@ class MonovanIntegrationRange(prop_helpers.ComplexProperty): self._rel_range = False self._other_prop = ['monovan_lo_value', 'monovan_hi_value'] - if isinstance(value, string_types): + if isinstance(value, str): values = value.split(',') result = [] for val in values: @@ -1104,7 +1101,7 @@ class EiMonSpectra(prop_helpers.ComplexProperty): else: tDict = instance.__dict__ - if isinstance(value, string_types): + if isinstance(value, str): val = value.replace('[', '').replace(']', '').strip() if val.find(':') > -1: val = val.split(':') @@ -1150,7 +1147,7 @@ class EiMonSpectra(prop_helpers.ComplexProperty): properties and these properties are currently standard properties """ - if isinstance(mon_range, string_types): + if isinstance(mon_range, str): mon_val = mon_range.split(',') else: mon_val = mon_range @@ -1200,7 +1197,7 @@ class SpectraToMonitorsList(PropDescriptor): if spectra_list is None: return None - if isinstance(spectra_list, string_types): + if isinstance(spectra_list, str): if spectra_list.lower() == 'none': result = None else: @@ -1255,7 +1252,7 @@ class SaveFormat(PropDescriptor): return # check string - if isinstance(value, string_types): + if isinstance(value, str): value = value.strip('[]().') subformats = value.split(',') if len(subformats) > 1: @@ -1319,7 +1316,7 @@ class DiagSpectra(PropDescriptor): """ process IDF description of the spectra string """ if specta_sring is None: return None - if isinstance(specta_sring, string_types): + if isinstance(specta_sring, str): if specta_sring.lower() in ['none', 'no']: return None else: @@ -1364,7 +1361,7 @@ class BackbgroundTestRange(PropDescriptor): if value is None: self._background_test_range = None return - if isinstance(value, string_types): + if isinstance(value, str): value = value.split(',') if len(value) != 2: raise ValueError("background test range can be only a 2 element list of floats") @@ -1409,7 +1406,7 @@ class MultirepTOFSpectraList(PropDescriptor): if value is None: self._spectra_list = None return - if isinstance(value, string_types): + if isinstance(value, str): value = value.split(',') self.__set__(instance, value) return @@ -1522,7 +1519,7 @@ class MotorLogName(PropDescriptor): return self._log_names def __set__(self, instance, value): - if isinstance(value, string_types): + if isinstance(value, str): val_list = value.split(';') elif isinstance(value, list): val_list = [] @@ -1590,7 +1587,7 @@ class RotationAngle(PropDescriptor): return self.read_psi_from_workspace(self._log_ws_name) def __set__(self, instance, value): - if isinstance(value, string_types): + if isinstance(value, str): if value in mantid.mtd: ## its workspace self._log_ws_name = value self._own_psi_value = None @@ -1615,7 +1612,7 @@ class RotationAngle(PropDescriptor): if working_ws is None: raise RuntimeError("No workspace provided. Can not read logs to identify psi") else: - if isinstance(external_ws, string_types): + if isinstance(external_ws, str): working_ws = mantid.mtd[external_ws] value = None @@ -1707,7 +1704,7 @@ class AbsCorrInfo(PropDescriptor): self._is_fast = False return val_dict = {} - if isinstance(value, string_types): + if isinstance(value, str): val = re.sub(' u ', ' ', re.sub(r'[{}\[\]"=:;,\']', ' ', value)) val_list = re.split(r'\s+',val) ik = 0 @@ -1788,7 +1785,7 @@ class AbsorptionShapesContainer(PropDescriptor): if value is None: self._theShapeHolder = None return - if isinstance(value, string_types): + if isinstance(value, str): self._theShapeHolder = anAbsorptionShape.from_str(value) elif isinstance(value,anAbsorptionShape): self._theShapeHolder = value diff --git a/scripts/Inelastic/Direct/PropertyManager.py b/scripts/Inelastic/Direct/PropertyManager.py index 415525d66d3711894a7bad324746900e7ca8593c..7a34d05abc597468bde3b43225da7b61768c95f4 100644 --- a/scripts/Inelastic/Direct/PropertyManager.py +++ b/scripts/Inelastic/Direct/PropertyManager.py @@ -8,11 +8,9 @@ # Mantid Repository : https://github.com/mantidproject/mantid #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function, unicode_literals) from Direct.NonIDF_Properties import * from collections import OrderedDict, Iterable -from six import iteritems, string_types from mantid.kernel import funcinspect @@ -104,7 +102,7 @@ class PropertyManager(NonIDF_Properties): self.__dict__.update(param_dict) # use existing descriptors setter to define IDF-defined descriptor's state - for key,val in iteritems(descr_dict): + for key,val in descr_dict.items(): object.__setattr__(self,key,val) # file properties -- the properties described files which should exist for reduction to work. @@ -141,7 +139,7 @@ class PropertyManager(NonIDF_Properties): class_decor = '_'+type(self).__name__+'__' - for key,val in iteritems(prop_dict): + for key,val in prop_dict.items(): new_key = class_decor+key object.__setattr__(self,new_key,val) @@ -165,7 +163,7 @@ class PropertyManager(NonIDF_Properties): #end # replace common substitutions for string value - if isinstance(val, string_types): + if isinstance(val, str): val1 = val.lower() if val1 == 'none' or len(val1) == 0: val = None @@ -352,7 +350,7 @@ class PropertyManager(NonIDF_Properties): 'instr_name':'','print_diag_results':True,'mapmask_ref_ws':None} result = {} - for key,val in iteritems(diag_param_list): + for key,val in diag_param_list.items(): try: result[key] = getattr(self,key) except KeyError: @@ -400,7 +398,7 @@ class PropertyManager(NonIDF_Properties): # Walk through descriptors list and set their values # Assignment to descriptors should accept the form, descriptor is written in IDF changed_descriptors = set() - for key,val in iteritems(descr_dict): + for key,val in descr_dict.items(): if key not in old_changes_list: try: # this is reliability check, and except ideally should never be hit. May occur if old IDF contains # properties, not present in recent IDF. @@ -444,7 +442,7 @@ class PropertyManager(NonIDF_Properties): self.setChangedProperties(changed_descriptors) # Walk through the complex properties first and then through simple properties - for key,val in iteritems(sorted_param.copy()): + for key,val in sorted_param.copy().items(): # complex properties may change through their dependencies so we are setting them first public_name = self.is_complex_property(key, val) @@ -552,7 +550,7 @@ class PropertyManager(NonIDF_Properties): self.setChangedProperties(set()) # set back all changes stored earlier and may be overwritten by new IDF # (this is just to be sure -- should not change anything as we do not set properties changed) - for key,val in iteritems(old_changes): + for key,val in old_changes.items(): setattr(self,key,val) # Clear changed properties list (is this wise?, may be we want to know that some defaults changed?) diff --git a/scripts/Inelastic/Direct/ReductionHelpers.py b/scripts/Inelastic/Direct/ReductionHelpers.py index d6a7ffb5098c2d0eec53a10acb6857e4c7516f7a..ce40e02416aef42e58b2ed8ed077e4f9bf99405c 100644 --- a/scripts/Inelastic/Direct/ReductionHelpers.py +++ b/scripts/Inelastic/Direct/ReductionHelpers.py @@ -5,13 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function, unicode_literals) -from six import string_types from mantid import config import os import re -from six.moves import range - """ Set of functions to assist with processing instrument parameters relevant to reduction. """ @@ -167,7 +163,7 @@ def build_properties_dict(param_map,synonims,descr_list=[]) : if final_name in descr_list: is_descriptor = True - if isinstance(val, string_types): + if isinstance(val, str): val = val.strip() keys_candidates = val.split(":") n_keys = len(keys_candidates) @@ -227,7 +223,7 @@ def build_subst_dictionary(synonims_list=None) : return dict() if isinstance(synonims_list, dict) : # all done return synonims_list - if not isinstance(synonims_list, string_types): + if not isinstance(synonims_list, str): raise AttributeError("The synonyms field of Reducer object has to be special format string or the dictionary") # we are in the right place and going to transform string into # dictionary @@ -378,7 +374,7 @@ def parse_single_name(filename): def parse_run_file_name(run_string): """ Parses run file name to obtain run number, path if possible, and file extension if any present in the string""" - if not isinstance(run_string, string_types): + if not isinstance(run_string, str): raise ValueError("REDUCTION_HELPER:parse_run_file_name -- input has to be a string") runs = run_string.split(',') diff --git a/scripts/Inelastic/Direct/ReductionWrapper.py b/scripts/Inelastic/Direct/ReductionWrapper.py index 6963c797ba23d78a141391a220d39ed8eb7aeb04..9bd1a70fe2569c0703ac14e366e7779bdeb9c449 100644 --- a/scripts/Inelastic/Direct/ReductionWrapper.py +++ b/scripts/Inelastic/Direct/ReductionWrapper.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function, unicode_literals) from mantid.simpleapi import * from mantid import config, api from mantid.kernel import funcinspect @@ -17,8 +16,6 @@ from types import MethodType # noqa import os import re import time -from six import iteritems, string_types - try: import h5py @@ -134,9 +131,9 @@ class ReductionWrapper(object): f = open(FileName, 'w') f.write("standard_vars = {\n") str_wrapper = ' ' - for key, val in iteritems(self._wvs.standard_vars): - if isinstance(val, string_types): - row = "{0}\'{1}\':\'{2}\'".format(str_wrapper, key, val) + for key, val in self._wvs.standard_vars.items(): + if isinstance(val, str): + row = "{0}\'{1}\':\'{2}\'".format(str_wrapper,key,val) else: row = "{0}\'{1}\':{2}".format(str_wrapper, key, val) f.write(row) @@ -144,9 +141,9 @@ class ReductionWrapper(object): f.write("\n}\nadvanced_vars={\n") # print advances variables str_wrapper = ' ' - for key, val in iteritems(self._wvs.advanced_vars): - if isinstance(val, string_types): - row = "{0}\'{1}\':\'{2}\'".format(str_wrapper, key, val) + for key, val in self._wvs.advanced_vars.items(): + if isinstance(val, str): + row = "{0}\'{1}\':\'{2}\'".format(str_wrapper,key,val) else: row = "{0}\'{1}\':{2}".format(str_wrapper, key, val) f.write(row) @@ -321,7 +318,7 @@ class ReductionWrapper(object): # this row defines location of the validation file validation_file = self.validation_file_name() sample_run = self.validate_run_number - if isinstance(validation_file, string_types): + if isinstance(validation_file, str): path, name = os.path.split(validation_file) if name in mtd: reference_ws = mtd[name] @@ -759,7 +756,7 @@ def iliad(reduce): input_file = None output_directory = None # add input file folder to data search directory if file has it - if input_file and isinstance(input_file, string_types): + if input_file and isinstance(input_file, str): data_path = os.path.dirname(input_file) if len(data_path) > 0: try: @@ -787,7 +784,7 @@ def iliad(reduce): # prohibit returning workspace to web services. # pylint: disable=protected-access - if host._run_from_web and not isinstance(rez, string_types): + if host._run_from_web and not isinstance(rez, str): rez = "" else: if isinstance(rez, list): diff --git a/scripts/Inelastic/Direct/RunDescriptor.py b/scripts/Inelastic/Direct/RunDescriptor.py index c9451c23e6621d828005236035643ea26f4847ce..7fbd7339ac69e1c0fed22579943281e005a3d770 100644 --- a/scripts/Inelastic/Direct/RunDescriptor.py +++ b/scripts/Inelastic/Direct/RunDescriptor.py @@ -9,8 +9,6 @@ #pylint: disable=attribute-defined-outside-init """ File contains Descriptors used describe run for direct inelastic reduction """ -from __future__ import (absolute_import, division, print_function, unicode_literals) -from six import string_types from mantid.simpleapi import * from mantid.kernel import funcinspect from Direct.PropertiesDescriptors import * @@ -54,7 +52,7 @@ class RunList(object): local_fext=[] for item in runs_to_add: - if isinstance(item, string_types): + if isinstance(item, str): file_path,run_num,fext = prop_helpers.parse_run_file_name(item) runs.append(run_num) if not fnames_given: @@ -452,7 +450,7 @@ class RunDescriptor(PropDescriptor): self._set_ws_as_source(value) return - if isinstance(value, string_types): # it may be run number as string or it may be a workspace name + if isinstance(value, str): # it may be run number as string or it may be a workspace name if value in mtd: # workspace name ws = mtd[value] self.__set__(instance,ws) @@ -993,7 +991,7 @@ class RunDescriptor(PropDescriptor): def set_file_ext(self,val): """Set non-default file extension """ - if isinstance(val, string_types): + if isinstance(val, str): if val[0] != '.': value = '.' + val else: @@ -1152,7 +1150,7 @@ class RunDescriptor(PropDescriptor): ws_calibration = prop_helpers.get_default_parameter(loaded_ws.getInstrument(),'det_cal_file') if ws_calibration is None: ws_calibration = calibration - if isinstance(ws_calibration, string_types) and ws_calibration.lower() == 'none': + if isinstance(ws_calibration, str) and ws_calibration.lower() == 'none': ws_calibration = calibration if ws_calibration : test_name = ws_calibration @@ -1168,7 +1166,7 @@ class RunDescriptor(PropDescriptor): else: return - if isinstance(ws_calibration, string_types) : # It can be only a file (got it from calibration property) + if isinstance(ws_calibration, str) : # It can be only a file (got it from calibration property) RunDescriptor._logger('load_data: Moving detectors to positions specified in cal file {0}'.format(ws_calibration),'debug') # Pull in pressures, thicknesses & update from cal file LoadDetectorInfo(Workspace=loaded_ws, DataFilename=ws_calibration, RelocateDets=True) @@ -1670,7 +1668,7 @@ def build_run_file_name(run_num,inst,file_path='',fext=''): """Build the full name of a runfile from all possible components""" if fext is None: fext = '' - if isinstance(run_num, string_types): + if isinstance(run_num, str): run_num_str = run_num else: #pylint: disable=protected-access diff --git a/scripts/Inelastic/Direct/dgreduce.py b/scripts/Inelastic/Direct/dgreduce.py index 52911c53a3ba6f2694cd71517246254d7f2535bc..95c32d070c3958377c883375dfec300a361e76e3 100644 --- a/scripts/Inelastic/Direct/dgreduce.py +++ b/scripts/Inelastic/Direct/dgreduce.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name """ Empty class temporary left for compatibility with previous interfaces """ -from __future__ import (absolute_import, division, print_function, unicode_literals) import Direct.DirectEnergyConversion as DRC from mantid.simpleapi import * from mantid.kernel import funcinspect diff --git a/scripts/Inelastic/Direct/diagnostics.py b/scripts/Inelastic/Direct/diagnostics.py index 0c0cb79d94bccb530f606b6ff90cf07292045f9a..82eb87987d1a350002869b48950aa548d95fa042 100644 --- a/scripts/Inelastic/Direct/diagnostics.py +++ b/scripts/Inelastic/Direct/diagnostics.py @@ -17,14 +17,11 @@ The output of each function is a workspace containing a single bin where: This workspace can be summed with other masked workspaces to accumulate masking and also passed to MaskDetectors to match masking there. """ -from __future__ import (absolute_import, division, print_function, unicode_literals) -from six import string_types from mantid.simpleapi import * from mantid.kernel.funcinspect import lhs_info import os import Direct.RunDescriptor as RunDescriptor from Direct.PropertyManager import PropertyManager -from six import iteritems # Reference to reducer used if necessary for working with run descriptors (in diagnostics) __Reducer__ = None @@ -457,7 +454,7 @@ def get_failed_spectra_list(diag_workspace): diag_workspace - A workspace containing masking """ - if isinstance(diag_workspace, string_types): + if isinstance(diag_workspace, str): diag_workspace = mtd[diag_workspace] failed_spectra = [] @@ -477,5 +474,5 @@ class ArgumentParser(object): def __init__(self, keywords): self.start_index = None # Make this more general for anything that is missing! self.end_index = None - for key, value in iteritems(keywords): + for key, value in keywords.items(): setattr(self, key, value) diff --git a/scripts/Inelastic/IndirectBayes.py b/scripts/Inelastic/IndirectBayes.py index 1525e9b13fba7039515fa11291957f8caa8f5579..0936593c1e22b9b7354a0ea8a51c7f82907b9c45 100644 --- a/scripts/Inelastic/IndirectBayes.py +++ b/scripts/Inelastic/IndirectBayes.py @@ -13,7 +13,6 @@ Input : the Python list is padded to Fortrans length using procedure PadArray Output : the Fortran numpy array is sliced to Python length using dataY = yout[:ny] """ -from __future__ import (absolute_import, division, print_function) from IndirectImport import * if is_supported_f2py_platform(): # noqa QLr = import_f2py("QLres") diff --git a/scripts/Inelastic/IndirectCommon.py b/scripts/Inelastic/IndirectCommon.py index ac2384eabab6fdd28d060beef64da73b5b4d92ed..5e3a53baee2b0a15ed9ce9453d7cefd0f2b04fe7 100644 --- a/scripts/Inelastic/IndirectCommon.py +++ b/scripts/Inelastic/IndirectCommon.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six.moves import range - import mantid.simpleapi as s_api from mantid import config, logger diff --git a/scripts/Inelastic/IndirectImport.py b/scripts/Inelastic/IndirectImport.py index a1570644015d39244fd6af043fe5a6a15a69d4ed..c50699be1f78181e567bf9b466b645faff73f22f 100644 --- a/scripts/Inelastic/IndirectImport.py +++ b/scripts/Inelastic/IndirectImport.py @@ -10,8 +10,6 @@ the Indirect scripts depending on platform and numpy package version. We also deal with importing the mantidplot module outside of MantidPlot here. """ -from __future__ import (absolute_import, division, print_function) - from contextlib import contextmanager import numpy.core.setup_common as numpy_cfg import os diff --git a/scripts/Inelastic/IndirectMuscat.py b/scripts/Inelastic/IndirectMuscat.py index 88dff9a707715cad16657ed58ed1fb32ef357c04..9b74728daabff684d1c0156fd2da4cc4d0c6e2d6 100644 --- a/scripts/Inelastic/IndirectMuscat.py +++ b/scripts/Inelastic/IndirectMuscat.py @@ -10,7 +10,6 @@ MUSIC : Version of Minus for MIDAS """ -from __future__ import (absolute_import, division, print_function) from IndirectImport import * if is_supported_f2py_platform(): # noqa muscat = import_f2py("muscat") diff --git a/scripts/Inelastic/IndirectNeutron.py b/scripts/Inelastic/IndirectNeutron.py index 0cd0a744b1720dce948da960d7e68ff89ac1bd67..754cb8600f6510963d3285f5b5dbfa82ab6d80a3 100644 --- a/scripts/Inelastic/IndirectNeutron.py +++ b/scripts/Inelastic/IndirectNeutron.py @@ -10,7 +10,6 @@ Force for ILL backscattering raw """ -from __future__ import (absolute_import, division, print_function) from IndirectImport import * from mantid.simpleapi import * from mantid import config, logger, mtd, FileFinder diff --git a/scripts/Inelastic/IndirectReductionCommon.py b/scripts/Inelastic/IndirectReductionCommon.py index b8fbc3e61241bd4c7c121872e4241aec38bccd54..228c84f8674db91e8de74279fcbdaa0db12ca4e8 100644 --- a/scripts/Inelastic/IndirectReductionCommon.py +++ b/scripts/Inelastic/IndirectReductionCommon.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import DeleteWorkspace, Load from mantid.api import AnalysisDataService, WorkspaceGroup, AlgorithmManager from mantid import mtd, logger, config diff --git a/scripts/Inelastic/dos/__init__.py b/scripts/Inelastic/dos/__init__.py index c292a33b86ab4c8db3c944693a352eadcede926e..479ea6a6fd575a2fbbedf37e0e666c9a6281ee82 100644 --- a/scripts/Inelastic/dos/__init__.py +++ b/scripts/Inelastic/dos/__init__.py @@ -10,6 +10,4 @@ load_castep -- Parses a castep file into a file data object load_phonon -- Parses a phonon file into a file data object """ -from __future__ import absolute_import - __all__=['load_castep','load_phonon', 'load_helper'] diff --git a/scripts/Inelastic/dos/load_castep.py b/scripts/Inelastic/dos/load_castep.py index 4ad003730ec09aaf47643e3f7f322b75c74e1bf3..415dce5595c7d987a7c185eeb5cf769333038009 100644 --- a/scripts/Inelastic/dos/load_castep.py +++ b/scripts/Inelastic/dos/load_castep.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six.moves import range - import re import numpy as np diff --git a/scripts/Inelastic/dos/load_phonon.py b/scripts/Inelastic/dos/load_phonon.py index a3893aec2254a37e1eee352727a518d7a0f4f742..f9b61a961e5bcb63939beb91cc8095d097894c7d 100644 --- a/scripts/Inelastic/dos/load_phonon.py +++ b/scripts/Inelastic/dos/load_phonon.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six.moves import range - import re import numpy as np diff --git a/scripts/Inelastic/vesuvio/__init__.py b/scripts/Inelastic/vesuvio/__init__.py index ae05f8178944d7ede5f96158e96793d08304d3fa..777ef7a03edde3af2e786ec436b3e9c91eed0591 100644 --- a/scripts/Inelastic/vesuvio/__init__.py +++ b/scripts/Inelastic/vesuvio/__init__.py @@ -15,6 +15,4 @@ profiles -- Defines mass profiles testing -- Simulates Vesuvio data for use in tests """ -from __future__ import absolute_import - __all__=['backgrounds','base','commands','fitting','instrument','profiles', 'testing'] diff --git a/scripts/Inelastic/vesuvio/backgrounds.py b/scripts/Inelastic/vesuvio/backgrounds.py index d612de57e1b523861e4b32e3c6429b51ec818083..873431c605fd073a8415c6a7b52645e741fb8b3f 100644 --- a/scripts/Inelastic/vesuvio/backgrounds.py +++ b/scripts/Inelastic/vesuvio/backgrounds.py @@ -7,9 +7,6 @@ # pylint: disable=too-few-public-methods,redefined-builtin """Holds classes that define the backgrounds for fitting """ -from __future__ import (absolute_import, division, print_function) -from six import iteritems - import ast # -------------------------------------------------------------------------------- @@ -90,5 +87,5 @@ def create_from_str(func_str): errors[str(cls)] = str(exc) # if we get here we were unable to parse anything acceptable - msgs = ["{0}: {1}".format(name, error) for name, error in iteritems(errors)] + msgs = ["{0}: {1}".format(name, error) for name, error in errors.items()] raise ValueError("\n".join(msgs)) diff --git a/scripts/Inelastic/vesuvio/base.py b/scripts/Inelastic/vesuvio/base.py index 07673ece9ce1ff46dc335687ec4df7d36f423585..b68f071f127457ba4d28954686a4ca8de64ec55d 100644 --- a/scripts/Inelastic/vesuvio/base.py +++ b/scripts/Inelastic/vesuvio/base.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-few-public-methods,redefined-builtin -from __future__ import (absolute_import, division, print_function) -from six import iteritems - from mantid.api import Algorithm @@ -37,7 +34,7 @@ class VesuvioBase(Algorithm): ret_props = [ret_props] del kwargs['return_values'] - for name, value in iteritems(kwargs): + for name, value in kwargs.items(): alg.setProperty(name, value) alg.execute() diff --git a/scripts/Inelastic/vesuvio/commands.py b/scripts/Inelastic/vesuvio/commands.py index 9c80a35556b6918f8834f31529c4d9a3dde94751..4061eb2ab489d82dfd88a9d42ee0b9cf0fc2cee9 100644 --- a/scripts/Inelastic/vesuvio/commands.py +++ b/scripts/Inelastic/vesuvio/commands.py @@ -9,8 +9,6 @@ Defines functions and classes to start the processing of Vesuvio data. The main entry point that most users should care about is fit_tof(). """ -from __future__ import (absolute_import, division, print_function) - import re import numpy as np from functools import reduce @@ -198,10 +196,8 @@ class VesuvioTOFFitRoutineIteration(object): # Calculate corrections corrections_result = self._corrections(vesuvio_input.sample_data, vesuvio_input.container_data, index, all_mass_values, all_profiles, prefit_result[1], verbose_output) - # Calculate final fit fit_result = self._final_fit(corrections_result[-1], fit_mass_values, fit_profiles) - # Update output with results from fit _update_output(vesuvio_output, prefit_result, corrections_result, fit_result) @@ -210,7 +206,6 @@ class VesuvioTOFFitRoutineIteration(object): UnGroupWorkspace(corrections_result[0]) UnGroupWorkspace(corrections_result[1]) mtd.remove(prefit_result[1].name()) - mtd.remove(corrections_result[-1].name()) mtd.remove(fit_result[1].name()) return vesuvio_output diff --git a/scripts/Inelastic/vesuvio/profiles.py b/scripts/Inelastic/vesuvio/profiles.py index 056b12d0cbdc7f828430357394e662a1583ecc96..daf0f00d08e2dfdce77552e5b8c569f4a4298780 100644 --- a/scripts/Inelastic/vesuvio/profiles.py +++ b/scripts/Inelastic/vesuvio/profiles.py @@ -9,9 +9,6 @@ This is all essentially about parsing the user input and putting it into a form the Mantid fitting algorithm will understand """ -from __future__ import (absolute_import, division, print_function) -from six import iteritems - import ast import collections import re @@ -430,5 +427,5 @@ def create_from_str(func_str, mass): errors[str(cls)] = str(exc) # if we get here we were unable to parse anything acceptable - msgs = ["{0}: {1}".format(name, error) for name, error in iteritems(errors)] + msgs = ["{0}: {1}".format(name, error) for name, error in errors.items()] raise ValueError("\n".join(msgs)) diff --git a/scripts/Interface/compile_pd_ui.py b/scripts/Interface/compile_pd_ui.py index b66c2859ea5fb3bdb7d17cd0ac62a33cb0d2b077..66348f5983bd97e3c3b701a1db576ac14cb04162 100755 --- a/scripts/Interface/compile_pd_ui.py +++ b/scripts/Interface/compile_pd_ui.py @@ -5,7 +5,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from compile_util import compile_ui # Compile resource files for Diffraction instruments diff --git a/scripts/Interface/compile_util_ui.py b/scripts/Interface/compile_util_ui.py index 5080f47ed469d04aab11aeba3b22cfa4d482369d..5bbdaca58b5e3486959779f9723f2076f0d801a7 100644 --- a/scripts/Interface/compile_util_ui.py +++ b/scripts/Interface/compile_util_ui.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os diff --git a/scripts/Interface/reduction_application.py b/scripts/Interface/reduction_application.py index e78c9e15d9c4c1bb8dd722d6aae40810428d5387..f8643250e5e3d055ffc4337030f6f796a0d29f77 100644 --- a/scripts/Interface/reduction_application.py +++ b/scripts/Interface/reduction_application.py @@ -8,8 +8,6 @@ """ Main window for reduction UIs """ -from __future__ import (absolute_import, division, print_function) -import six import sys import os import traceback @@ -31,8 +29,7 @@ except ImportError: Logger("ReductionGUI").information('Using legacy ui importer') from mantidplot import load_ui # noqa -if six.PY3: - unicode = str +unicode = str STARTUP_WARNING = "" diff --git a/scripts/Interface/reduction_gui/instruments/dgs_interface_dev.py b/scripts/Interface/reduction_gui/instruments/dgs_interface_dev.py index 2358a567156f003c2d7da6053e011855a2768545..ee73393ce050baaca6302f5dd15b1cbe843e2295 100644 --- a/scripts/Interface/reduction_gui/instruments/dgs_interface_dev.py +++ b/scripts/Interface/reduction_gui/instruments/dgs_interface_dev.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from reduction_gui.instruments.interface import InstrumentInterface from reduction_gui.widgets.inelastic.dgs_sample_setup import SampleSetupWidget from reduction_gui.widgets.inelastic.dgs_data_corrections import DataCorrectionsWidget diff --git a/scripts/Interface/reduction_gui/instruments/diffraction_interface_dev.py b/scripts/Interface/reduction_gui/instruments/diffraction_interface_dev.py index 525913ceab6e4ba5fe7c53315942f7a9656fa83f..6d7f267de446cd2c05d3cc2baa568c0308d9fcf3 100644 --- a/scripts/Interface/reduction_gui/instruments/diffraction_interface_dev.py +++ b/scripts/Interface/reduction_gui/instruments/diffraction_interface_dev.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from reduction_gui.instruments.interface import InstrumentInterface from reduction_gui.widgets.diffraction.diffraction_run_setup import RunSetupWidget from reduction_gui.widgets.diffraction.diffraction_adv_setup import AdvancedSetupWidget diff --git a/scripts/Interface/reduction_gui/instruments/eqsans_interface_dev.py b/scripts/Interface/reduction_gui/instruments/eqsans_interface_dev.py index fd52fe62f9aa98ffb305986a73fb625a881e4006..0246724cbfda0c446bdff01206876dcab3ef060f 100644 --- a/scripts/Interface/reduction_gui/instruments/eqsans_interface_dev.py +++ b/scripts/Interface/reduction_gui/instruments/eqsans_interface_dev.py @@ -10,7 +10,6 @@ The actual view/layout is define in .ui files. The state of the reduction process is kept elsewhere (SNSReduction object) """ -from __future__ import (absolute_import, division, print_function) from reduction_gui.instruments.interface import InstrumentInterface from reduction_gui.widgets.sans.hfir_detector import DetectorWidget from reduction_gui.widgets.sans.eqsans_instrument import SANSInstrumentWidget diff --git a/scripts/Interface/reduction_gui/instruments/hfir_interface_dev.py b/scripts/Interface/reduction_gui/instruments/hfir_interface_dev.py index 32a101d23a4874043bc7ea28bff5403a35592da6..ba61da55496c50f3376383b580dd17e296fed4f2 100644 --- a/scripts/Interface/reduction_gui/instruments/hfir_interface_dev.py +++ b/scripts/Interface/reduction_gui/instruments/hfir_interface_dev.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) """ This module defines the interface control for HFIR SANS. Each reduction method tab that needs to be presented is defined here. diff --git a/scripts/Interface/reduction_gui/instruments/instrument_factory.py b/scripts/Interface/reduction_gui/instruments/instrument_factory.py index fb2eb86cb0af2c586c10f35b4e96698158844721..4f0f722c24e89de0cba88c146f564eb768339888 100644 --- a/scripts/Interface/reduction_gui/instruments/instrument_factory.py +++ b/scripts/Interface/reduction_gui/instruments/instrument_factory.py @@ -9,7 +9,6 @@ This module is responsible for the association between an instrument name and its corresponding interface class. """ -from __future__ import (absolute_import, division, print_function) from reduction_gui.instruments.hfir_interface_dev import HFIRInterface from reduction_gui.instruments.eqsans_interface_dev import EQSANSInterface from reduction_gui.instruments.dgs_interface_dev import DgsInterface diff --git a/scripts/Interface/reduction_gui/instruments/interface.py b/scripts/Interface/reduction_gui/instruments/interface.py index e994d52cd3c3b5ce484b18e4d135cc54cec0f6d8..e36c0d5335f935d15d99a7fbb01ad7915304e9d7 100644 --- a/scripts/Interface/reduction_gui/instruments/interface.py +++ b/scripts/Interface/reduction_gui/instruments/interface.py @@ -8,16 +8,13 @@ """ Base class for instrument-specific user interface """ -from __future__ import (absolute_import, division, print_function) -import six from qtpy.QtWidgets import (QMessageBox) # noqa import sys import os import traceback from reduction_gui.reduction.scripter import BaseReductionScripter -if six.PY3: - unicode = str +unicode = str class InstrumentInterface(object): diff --git a/scripts/Interface/reduction_gui/instruments/toftof_interface_dev.py b/scripts/Interface/reduction_gui/instruments/toftof_interface_dev.py index 23670d06739b15bba5538f4af4857055f83d5c0d..4ac651b6b77632ed1a794cced856ecee6f7680ad 100644 --- a/scripts/Interface/reduction_gui/instruments/toftof_interface_dev.py +++ b/scripts/Interface/reduction_gui/instruments/toftof_interface_dev.py @@ -8,7 +8,6 @@ """ TOFTOF reduction workflow gui. """ -from __future__ import (absolute_import, division, print_function) from reduction_gui.instruments.interface import InstrumentInterface from reduction_gui.reduction.toftof.toftof_reduction import TOFTOFReductionScripter diff --git a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_adv_setup_script.py b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_adv_setup_script.py index a5964d1f0b2d8b8d56d30663deb10f14fd7ecbb5..ec9c64d1ac660b3fee187553f2aa22e82faf463e 100644 --- a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_adv_setup_script.py +++ b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_adv_setup_script.py @@ -10,7 +10,6 @@ from the the interface class so that the DgsReduction class could be used independently of the interface implementation """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement diff --git a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_filter_setup_script.py b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_filter_setup_script.py index f1df36ce97ca6457f79c38f997cc5277a49c0e54..701325672c44258c076dd195edea656229be7f03 100644 --- a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_filter_setup_script.py +++ b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_filter_setup_script.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) #pylint: disable=invalid-name """ Classes for each reduction step. Those are kept separately diff --git a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_reduction_script.py b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_reduction_script.py index a9b80cbb5ba32b4c1817ebd14bd475ecfe715ab9..9050f4e42bf0c77d74320d2b019f5c2ad48f1080 100644 --- a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_reduction_script.py +++ b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_reduction_script.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) #pylint: disable=invalid-name,R0912 """ Classes for each reduction step. Those are kept separately @@ -304,7 +303,7 @@ class DiffractionReductionScripter(BaseReductionScripter): runsetupdict.pop('ExpIniFile', None) # c) all properties - for propname, propvalue in runsetupdict.iteritems(): + for propname, propvalue in runsetupdict.items(): # skip these pseudo-properties if propname in ['DisableBackgroundCorrection', 'DisableVanadiumCorrection', 'DisableVanadiumBackgroundCorrection', 'DoReSampleX']: @@ -329,7 +328,7 @@ class DiffractionReductionScripter(BaseReductionScripter): # ENDFOR # 2. Advanced setup - for propname, propvalue in advsetupdict.iteritems(): + for propname, propvalue in advsetupdict.items(): if propvalue == '' or propvalue is None: # Skip not-defined value continue diff --git a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_run_setup_script.py b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_run_setup_script.py index df7ed4ee6eb0a0607aad2b8a3b8efcdc6547000f..f097e71022225693689ea674e048500710cb5dc4 100644 --- a/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_run_setup_script.py +++ b/scripts/Interface/reduction_gui/reduction/diffraction/diffraction_run_setup_script.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) """ Classes for each reduction step. Those are kept separately from the the interface class so that the DgsReduction class could diff --git a/scripts/Interface/reduction_gui/reduction/eqsans_reduction.py b/scripts/Interface/reduction_gui/reduction/eqsans_reduction.py index 97dbf3c7a34fc2d7380f4e6ede273a3dec4c9966..b87e9877b72a667f24e4b441719cf9a1d28603a8 100644 --- a/scripts/Interface/reduction_gui/reduction/eqsans_reduction.py +++ b/scripts/Interface/reduction_gui/reduction/eqsans_reduction.py @@ -9,7 +9,6 @@ This class holds all the necessary information to create a reduction script. This is a fake version of the Reducer for testing purposes. """ -from __future__ import (absolute_import, division, print_function) import time import os from reduction_gui.reduction.scripter import BaseReductionScripter diff --git a/scripts/Interface/reduction_gui/reduction/hfir_reduction.py b/scripts/Interface/reduction_gui/reduction/hfir_reduction.py index d723c3ff33ef86a5e8156eb5d33c94f72a92d96e..1e80d8c5d3a8ff44ca259cc32ef75e395f9864c6 100644 --- a/scripts/Interface/reduction_gui/reduction/hfir_reduction.py +++ b/scripts/Interface/reduction_gui/reduction/hfir_reduction.py @@ -9,7 +9,6 @@ This class holds all the necessary information to create a reduction script. This is a fake version of the Reducer for testing purposes. """ -from __future__ import (absolute_import, division, print_function) import time import os from reduction_gui.reduction.scripter import BaseReductionScripter diff --git a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_absolute_units_script.py b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_absolute_units_script.py index edd03ec03d35cfdec539ef67fc406db7853512e3..3630595d28069eebf92618d364d788afab7b36f6 100644 --- a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_absolute_units_script.py +++ b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_absolute_units_script.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) #pylint: disable=invalid-name """ Classes for each reduction step. Those are kept separately diff --git a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_data_corrections_script.py b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_data_corrections_script.py index 4050a932815723fd1ab032e765d6523fd9416a5b..ad623d18cb7e986546f49ea14aff0efa44d21042 100644 --- a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_data_corrections_script.py +++ b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_data_corrections_script.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) #pylint: disable=invalid-name """ Classes for each reduction step. Those are kept separately diff --git a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_diagnose_detectors_script.py b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_diagnose_detectors_script.py index 428114e49b8dbfb584a78f22530fe82cd7b9c42b..078bf1bc0436ba87c57eb0253cadc8a8e3cc830b 100644 --- a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_diagnose_detectors_script.py +++ b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_diagnose_detectors_script.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) #pylint: disable=invalid-name """ Classes for each reduction step. Those are kept separately diff --git a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_pd_sc_conversion_script.py b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_pd_sc_conversion_script.py index 8cd8bc48d9c4ebaf5c0eb94b269f07439cdbf3df..62e23c861bc91110398d8ee5803a33e0a9ca8d03 100644 --- a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_pd_sc_conversion_script.py +++ b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_pd_sc_conversion_script.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) """ Classes for each reduction step. Those are kept separately from the the interface class so that the DgsReduction class could diff --git a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_reduction_script.py b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_reduction_script.py index 977b2432a6c297daed0543831314a88343443498..7072cfcc3f9113c22412131ca421cbaab65be7e8 100644 --- a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_reduction_script.py +++ b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_reduction_script.py @@ -10,7 +10,6 @@ from the the interface class so that the DgsReduction class could be used independently of the interface implementation """ -from __future__ import (absolute_import, division, print_function) import time import mantid from reduction_gui.reduction.scripter import BaseReductionScripter diff --git a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_sample_data_setup_script.py b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_sample_data_setup_script.py index a7ab34d275a105f58d02772025c6adaf84d16929..6937d7a1d8058117d8bc55f4c2403825b59c915c 100644 --- a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_sample_data_setup_script.py +++ b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_sample_data_setup_script.py @@ -10,7 +10,6 @@ from the the interface class so that the DgsReduction class could be used independently of the interface implementation """ -from __future__ import (absolute_import, division, print_function) import os import xml.dom.minidom diff --git a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_utils.py b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_utils.py index 261bdb8adb8854472862d7b5dcc28e4c0ce70a11..b04dfa37469c83e22dd9eba61b5bf384ae672fce 100644 --- a/scripts/Interface/reduction_gui/reduction/inelastic/dgs_utils.py +++ b/scripts/Interface/reduction_gui/reduction/inelastic/dgs_utils.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os IS_IN_MANTIDPLOT = False diff --git a/scripts/Interface/reduction_gui/reduction/output_script.py b/scripts/Interface/reduction_gui/reduction/output_script.py index 79a2acd8147fa47198aed0757d89099b2aa3ad03..83be0261dd19156e12e41ea24de993161ac70df3 100644 --- a/scripts/Interface/reduction_gui/reduction/output_script.py +++ b/scripts/Interface/reduction_gui/reduction/output_script.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import sys from reduction_gui.reduction.scripter import BaseScriptElement diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py index d516fb9052bc8c1995ac6c062af88c043dca9663..831dc0f60293f70ab7298fc63ee5dcc2e82128fd 100644 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py +++ b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py @@ -8,7 +8,6 @@ Legacy class that old LR reduction options. This is still in use for backward compatibility. """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py index 4a30c132c16dcf89e60bfb51d7b0c6101f4d1459..8b6a91007533f7b3afa12b832499a8978c382b91 100644 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py +++ b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py @@ -9,7 +9,6 @@ from the the interface class so that the HFIRReduction class could be used independently of the interface implementation """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement from reduction_gui.reduction.reflectometer.refl_data_script import DataSets as REFLDataSets diff --git a/scripts/Interface/reduction_gui/reduction/sans/data_cat.py b/scripts/Interface/reduction_gui/reduction/sans/data_cat.py index c263d134344c703d26ee3ea543d925f4b21f2569..145e587d9f2c76dc62f67d4b4ff0027d83de43a2 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/data_cat.py +++ b/scripts/Interface/reduction_gui/reduction/sans/data_cat.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) #pylint: disable=invalid-name """ Simple local data catalog for Mantid diff --git a/scripts/Interface/reduction_gui/reduction/sans/eqsans_background_script.py b/scripts/Interface/reduction_gui/reduction/sans/eqsans_background_script.py index f35f4108f43bd52f5e797b7b3e1077f4381b4bcd..47ec6bfafabf5311acbb8e49fa479612a6927ad5 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/eqsans_background_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/eqsans_background_script.py @@ -7,7 +7,6 @@ """ Sample data options for EQSANS reduction """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement from reduction_gui.reduction.sans.hfir_background_script import Background as BaseBackground diff --git a/scripts/Interface/reduction_gui/reduction/sans/eqsans_catalog.py b/scripts/Interface/reduction_gui/reduction/sans/eqsans_catalog.py index c317d3d13e270d29e8a8976a63e1a95d84877dd2..8d1507a6022d1eb2f8b72e546ab218cac42279ec 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/eqsans_catalog.py +++ b/scripts/Interface/reduction_gui/reduction/sans/eqsans_catalog.py @@ -8,7 +8,6 @@ """ Data catalog for EQSANS """ -from __future__ import (absolute_import, division, print_function) from reduction_gui.reduction.sans.data_cat import DataCatalog as BaseCatalog from reduction_gui.reduction.sans.data_cat import DataSet, DataType from reduction_gui.reduction.scripter import execute_script diff --git a/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_proxy.py b/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_proxy.py index 9610941352d2414f857a15ae7f290ee059c48067..649cfe2aab6a46cf78d033af12803159fa69df46 100755 --- a/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_proxy.py +++ b/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_proxy.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import sys # Check whether Mantid is available try: diff --git a/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_script.py b/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_script.py index e7ff9ded46a7e24482a60440a5814e0e3c62f8be..511f860ff1e608b5f2fd6208a251f2ea87006c78 100755 --- a/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/eqsans_data_script.py @@ -7,7 +7,6 @@ """ Data set options for EQSANS reduction """ -from __future__ import (absolute_import, division, print_function) from reduction_gui.reduction.sans.eqsans_sample_script import SampleData as BaseSampleData from reduction_gui.reduction.sans.eqsans_background_script import Background diff --git a/scripts/Interface/reduction_gui/reduction/sans/eqsans_options_script.py b/scripts/Interface/reduction_gui/reduction/sans/eqsans_options_script.py index e1f39bcd0be96c4dec74e623f219e3d3515cf45e..da2b489341ef7d8d7ae8caeff661c938878f55ac 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/eqsans_options_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/eqsans_options_script.py @@ -7,7 +7,6 @@ """ General options for EQSANS reduction """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement from reduction_gui.reduction.sans.hfir_options_script import ReductionOptions as BaseOptions diff --git a/scripts/Interface/reduction_gui/reduction/sans/eqsans_sample_script.py b/scripts/Interface/reduction_gui/reduction/sans/eqsans_sample_script.py index 5d96f9287c01b767b36d1a86f871f2d804d91f2e..6d4f2aa65e9843c2dcd720ecf36cc8dd38b611fc 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/eqsans_sample_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/eqsans_sample_script.py @@ -7,7 +7,6 @@ """ Sample data options for EQSANS reduction """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement from reduction_gui.reduction.sans.hfir_sample_script import SampleData as BaseSampleData diff --git a/scripts/Interface/reduction_gui/reduction/sans/hfir_background_script.py b/scripts/Interface/reduction_gui/reduction/sans/hfir_background_script.py index 1737a1279376306a2d51dc3d32e2dcab7fac9266..672f1d55d1e46a8e14d69b67054fce2b67205e1e 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/hfir_background_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/hfir_background_script.py @@ -9,7 +9,6 @@ from the the interface class so that the HFIRReduction class could be used independently of the interface implementation """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement from reduction_gui.reduction.sans.hfir_sample_script import SampleData diff --git a/scripts/Interface/reduction_gui/reduction/sans/hfir_catalog.py b/scripts/Interface/reduction_gui/reduction/sans/hfir_catalog.py index a85ee36d6e566fa97e6a723fe1afaef607fc6b92..063f90503b276677b3db760f0ed2707209983d43 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/hfir_catalog.py +++ b/scripts/Interface/reduction_gui/reduction/sans/hfir_catalog.py @@ -8,7 +8,6 @@ """ Data catalog for HFIR SANS """ -from __future__ import (absolute_import, division, print_function) from reduction_gui.reduction.sans.data_cat import DataCatalog as BaseCatalog from reduction_gui.reduction.sans.data_cat import DataSet, DataType from reduction_gui.reduction.scripter import execute_script diff --git a/scripts/Interface/reduction_gui/reduction/sans/hfir_data_proxy.py b/scripts/Interface/reduction_gui/reduction/sans/hfir_data_proxy.py index 5ad9d011421058b33113103fa1694f27bde49c0e..1f43b16baed1a71be1daffef6c7efa96d3745e2a 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/hfir_data_proxy.py +++ b/scripts/Interface/reduction_gui/reduction/sans/hfir_data_proxy.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=bare-except,invalid-name -from __future__ import (absolute_import, division, print_function) import sys # Check whether Mantid is available try: diff --git a/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py b/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py index 67faea2a708f565463a675198aec55935c8e94e7..2e7690f15b04dd487fe231b774641c2d5eb10066 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/hfir_detector_script.py @@ -8,7 +8,6 @@ """ Detector options for reduction """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement diff --git a/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py b/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py index 00518a887423cb828b86fac1a28d5495c3eddcff..b43e39348bf79ea2d4ef62bccf05c3175539baa4 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/hfir_options_script.py @@ -9,7 +9,6 @@ from the the interface class so that the HFIRReduction class could be used independently of the interface implementation """ -from __future__ import (absolute_import, division, print_function) import inspect import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement diff --git a/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py b/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py index 4f88ddba09230013dbd3f241320eb36a07b958b1..bb779bb939d23b80651a209f8b1c7c329120ad29 100644 --- a/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py +++ b/scripts/Interface/reduction_gui/reduction/sans/hfir_sample_script.py @@ -10,7 +10,6 @@ from the the interface class so that the HFIRReduction class could be used independently of the interface implementation """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom import os from reduction_gui.reduction.scripter import BaseScriptElement diff --git a/scripts/Interface/reduction_gui/reduction/scripter.py b/scripts/Interface/reduction_gui/reduction/scripter.py index 6039660efa7fee129e3780e4c08eb7843bf5e814..a3fadcd4ab09b9bb9ab8a3188bc2a4ccfc9bd14c 100644 --- a/scripts/Interface/reduction_gui/reduction/scripter.py +++ b/scripts/Interface/reduction_gui/reduction/scripter.py @@ -9,7 +9,6 @@ Reduction scripter used to take reduction parameters end produce a Mantid reduction script """ -from __future__ import (absolute_import, division, print_function) import xml.dom.minidom import sys import time diff --git a/scripts/Interface/reduction_gui/reduction/toftof/toftof_reduction.py b/scripts/Interface/reduction_gui/reduction/toftof/toftof_reduction.py index a2074aad79cc78c5584a88fc11f08e096a461997..cb9677c1ace82c97cd070a1381d5e51189249a5e 100644 --- a/scripts/Interface/reduction_gui/reduction/toftof/toftof_reduction.py +++ b/scripts/Interface/reduction_gui/reduction/toftof/toftof_reduction.py @@ -11,8 +11,6 @@ """ TOFTOF reduction workflow gui. """ -from __future__ import (absolute_import, division, print_function) - from itertools import repeat, compress import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement, BaseReductionScripter diff --git a/scripts/Interface/reduction_gui/settings/application_settings.py b/scripts/Interface/reduction_gui/settings/application_settings.py index 132776196d81966f6640a62719c22b058088f766..ee880e42955aee355e9dc58a6cef1dfd6375a749 100644 --- a/scripts/Interface/reduction_gui/settings/application_settings.py +++ b/scripts/Interface/reduction_gui/settings/application_settings.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -import six ''' Notes: @@ -20,8 +18,7 @@ From mantidplot: from qtpy.QtCore import (QObject, QSettings, Signal) # noqa -if six.PY3: - unicode = str +unicode = str class GeneralSettings(QObject): diff --git a/scripts/Interface/reduction_gui/widgets/base_widget.py b/scripts/Interface/reduction_gui/widgets/base_widget.py index b2fbdc514001f56f8e1d8d3b5120f8003af1d65f..90ef8ffe12816a03234728b5004a0d54bee92142 100644 --- a/scripts/Interface/reduction_gui/widgets/base_widget.py +++ b/scripts/Interface/reduction_gui/widgets/base_widget.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtCore import (QFileInfo) # noqa from qtpy.QtWidgets import (QFileDialog, QHBoxLayout, QMessageBox, QWidget) # noqa import os diff --git a/scripts/Interface/reduction_gui/widgets/data_table_view.py b/scripts/Interface/reduction_gui/widgets/data_table_view.py index 210324521ddc46e487191fde99420dafc0de59aa..8576f20a3624048a34d63619c675eacf235fc97e 100644 --- a/scripts/Interface/reduction_gui/widgets/data_table_view.py +++ b/scripts/Interface/reduction_gui/widgets/data_table_view.py @@ -7,7 +7,6 @@ """ DataTable Widget for data runs. """ -from __future__ import (absolute_import, division, print_function) from qtpy import QtCore, QtWidgets from qtpy.QtCore import Qt diff --git a/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_adv_setup.py b/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_adv_setup.py index cb265ea77ac258c8d0a004f9c66e81a291ee0453..975db7e3435eaad42e7e285c689defd78bdd2afd 100644 --- a/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_adv_setup.py +++ b/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_adv_setup.py @@ -8,7 +8,6 @@ ################################################################################ # Advanced Setup Widget ################################################################################ -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QDialog, QFrame) # noqa from qtpy.QtGui import (QDoubleValidator, QIntValidator) # noqa from reduction_gui.widgets.base_widget import BaseWidget diff --git a/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_filter_setup.py b/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_filter_setup.py index 477bd26d3fffcf2872431d1d610cf3dceb9cb66f..87eb676284a3715a48ad457a80b402d76fb8ae80 100644 --- a/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_filter_setup.py +++ b/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_filter_setup.py @@ -8,7 +8,6 @@ ################################################################################ # Event Filtering (and advanced) Setup Widget ################################################################################ -from __future__ import (absolute_import, division, print_function) from mantid.kernel import Logger from mantid.simpleapi import ExportTimeSeriesLog, Load import matplotlib.pyplot as plt diff --git a/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_run_setup.py b/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_run_setup.py index 041831c9ea86c51d8a26384d286d4c5dc0385544..dc1d5bd544166ef3e0000183507fb95b46f1b880 100644 --- a/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_run_setup.py +++ b/scripts/Interface/reduction_gui/widgets/diffraction/diffraction_run_setup.py @@ -8,7 +8,6 @@ ################################################################################ # This is my first attempt to make a tab from quasi-scratch ################################################################################ -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QDialog, QFrame) # noqa from qtpy.QtCore import (QRegExp) # noqa from qtpy.QtGui import (QDoubleValidator, QIntValidator, QRegExpValidator) # noqa diff --git a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_absolute_units.py b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_absolute_units.py index a074a5447a437d9e6fcc4d7a5de9388ffe86d032..4f541d027a6f4ef3a249c664450298dd7fdd3f0b 100644 --- a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_absolute_units.py +++ b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_absolute_units.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QFrame) # noqa from qtpy.QtGui import (QDoubleValidator) # noqa from reduction_gui.widgets.base_widget import BaseWidget diff --git a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_data_corrections.py b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_data_corrections.py index 8bea8f914e64e26390d47a48072fdb7941f37201..b5611a8368563c5422751b7098dc422d3f240287 100644 --- a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_data_corrections.py +++ b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_data_corrections.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QButtonGroup, QFrame) # noqa from qtpy.QtGui import (QIntValidator) # noqa from reduction_gui.widgets.base_widget import BaseWidget diff --git a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_diagnose_detectors.py b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_diagnose_detectors.py index c9eece0d22952ad0416fb11aee561338a960090a..6cd25d23dba50cbfe72ab6902a33e646ac0b6af4 100644 --- a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_diagnose_detectors.py +++ b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_diagnose_detectors.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QFrame) # noqa from qtpy.QtGui import (QDoubleValidator, QIntValidator) # noqa from reduction_gui.widgets.base_widget import BaseWidget diff --git a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_pd_sc_conversion.py b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_pd_sc_conversion.py index fbf4c78685bd09ad53e06106dfb1f05ce2f6ccc9..ef3839c70003694f9f29009e1a7a8934e1706b06 100644 --- a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_pd_sc_conversion.py +++ b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_pd_sc_conversion.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from PyQt4 import QtGui, QtCore from functools import partial from reduction_gui.widgets.base_widget import BaseWidget diff --git a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_sample_setup.py b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_sample_setup.py index 36960a056c67f31694abb8a91cfbde3d451e3f16..fa0a0f63f9ca6c071df5b275fedfbed2d42a12bd 100644 --- a/scripts/Interface/reduction_gui/widgets/inelastic/dgs_sample_setup.py +++ b/scripts/Interface/reduction_gui/widgets/inelastic/dgs_sample_setup.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QFileDialog, QFrame) # noqa from qtpy.QtGui import (QDoubleValidator, QIntValidator) # noqa from functools import partial diff --git a/scripts/Interface/reduction_gui/widgets/output.py b/scripts/Interface/reduction_gui/widgets/output.py index 66c8047e38e6da2ecaba770cf8801b094002bc6c..41d3336438508758b247ab67677718a48d0fc696 100644 --- a/scripts/Interface/reduction_gui/widgets/output.py +++ b/scripts/Interface/reduction_gui/widgets/output.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QFrame) # noqa from reduction_gui.reduction.output_script import Output from reduction_gui.widgets.base_widget import BaseWidget diff --git a/scripts/Interface/reduction_gui/widgets/sans/eqsans_data.py b/scripts/Interface/reduction_gui/widgets/sans/eqsans_data.py index 1b55535ade5a1118c1e92601a3bcd28f9e99cb4c..b82fc2bd458d96f956b0186509a285dd62b05aca 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/eqsans_data.py +++ b/scripts/Interface/reduction_gui/widgets/sans/eqsans_data.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) -import six from qtpy.QtWidgets import (QButtonGroup, QFrame, QMessageBox) # noqa from qtpy.QtGui import (QDoubleValidator) # noqa import os @@ -21,8 +19,7 @@ except ImportError: Logger("DataSetsWidget").information('Using legacy ui importer') from mantidplot import load_ui -if six.PY3: - unicode = str +unicode = str class DataSetsWidget(BaseWidget): diff --git a/scripts/Interface/reduction_gui/widgets/sans/eqsans_instrument.py b/scripts/Interface/reduction_gui/widgets/sans/eqsans_instrument.py index 3442e3e408eaf52db7f2ea71661f3dca10001b60..aa21774f2b0d783658c13e052799f5c287a46f7c 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/eqsans_instrument.py +++ b/scripts/Interface/reduction_gui/widgets/sans/eqsans_instrument.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) -import six from qtpy.QtWidgets import (QButtonGroup, QDialog, QFileDialog, QFrame) # noqa from qtpy.QtGui import (QDoubleValidator, QIntValidator) # noqa import reduction_gui.widgets.util as util @@ -22,8 +20,7 @@ except ImportError: from mantidplot import load_ui from mantid.api import AnalysisDataService from mantid.simpleapi import ExtractMask -if six.PY3: - unicode = str +unicode = str class SANSInstrumentWidget(BaseWidget): diff --git a/scripts/Interface/reduction_gui/widgets/sans/hfir_background.py b/scripts/Interface/reduction_gui/widgets/sans/hfir_background.py index 17d7b84bbc4b978e6e3d9fff18366fabc69e8bc4..0fddcdd9bf62aeeb019468113b4d54306780e0d5 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/hfir_background.py +++ b/scripts/Interface/reduction_gui/widgets/sans/hfir_background.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import (QFrame) # noqa from qtpy.QtGui import (QDoubleValidator) # noqa import reduction_gui.widgets.util as util diff --git a/scripts/Interface/reduction_gui/widgets/sans/hfir_detector.py b/scripts/Interface/reduction_gui/widgets/sans/hfir_detector.py index 1e830ca44e270abb0719f100a4e7235da8a996a5..c9ee1e24ac0eb76dc195def2f1a71d76433f0a3e 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/hfir_detector.py +++ b/scripts/Interface/reduction_gui/widgets/sans/hfir_detector.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) -import six from qtpy.QtWidgets import (QFrame, QMessageBox) # noqa from qtpy.QtGui import (QDoubleValidator) # noqa import reduction_gui.widgets.util as util @@ -22,8 +20,7 @@ except ImportError: from mantid.api import AnalysisDataService from reduction_gui.reduction.scripter import execute_script -if six.PY3: - unicode = str +unicode = str class DetectorWidget(BaseWidget): diff --git a/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py b/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py index a67123b12b5f5d8d5912eebd11aad0a37247b4cd..c61a5eee42d2d37abc26abc5f4296c852b63d8bd 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py +++ b/scripts/Interface/reduction_gui/widgets/sans/hfir_instrument.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,protected-access -from __future__ import (absolute_import, division, print_function) -import six from qtpy.QtWidgets import (QFrame) # noqa from qtpy.QtGui import (QDoubleValidator, QIntValidator) # noqa import reduction_gui.widgets.util as util @@ -22,8 +20,7 @@ except ImportError: from mantidplot import load_ui from mantid.api import AnalysisDataService from mantid.simpleapi import ExtractMask -if six.PY3: - unicode = str +unicode = str class SANSInstrumentWidget(BaseWidget): diff --git a/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py b/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py index 5451b7465b43d2de6792de815c86a321213fbfab..0896eb240cd2f97e078aa1b1c5c4089e98785abc 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py +++ b/scripts/Interface/reduction_gui/widgets/sans/hfir_sample_data.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,protected-access -from __future__ import (absolute_import, division, print_function) -import six import os from qtpy.QtWidgets import (QFrame, QGroupBox, QMessageBox) # noqa from qtpy.QtGui import (QDoubleValidator) # noqa @@ -20,8 +18,7 @@ except ImportError: Logger("DirectBeam").information('Using legacy ui importer') from mantidplot import load_ui -if six.PY3: - unicode = str +unicode = str class DirectBeam(BaseWidget): diff --git a/scripts/Interface/reduction_gui/widgets/sans/sans_catalog.py b/scripts/Interface/reduction_gui/widgets/sans/sans_catalog.py index 29eedfc74d4d14a70362a339f4282d16121f2f2f..a8aaa60f576b587000bb1c40f8a53d00250b7ee8 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/sans_catalog.py +++ b/scripts/Interface/reduction_gui/widgets/sans/sans_catalog.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtCore import (Qt) # noqa from qtpy.QtWidgets import (QAction, QApplication, QFileDialog, QFrame, QMenu, QTableWidgetItem) # noqa from reduction_gui.settings.application_settings import GeneralSettings diff --git a/scripts/Interface/reduction_gui/widgets/sans/stitcher.py b/scripts/Interface/reduction_gui/widgets/sans/stitcher.py index 08cd4e7d0dc4a45d606971df46636e9519431850..6976a3484f090a5a775a6199a60bca25b6e57aed 100644 --- a/scripts/Interface/reduction_gui/widgets/sans/stitcher.py +++ b/scripts/Interface/reduction_gui/widgets/sans/stitcher.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name, protected-access, super-on-old-class -from __future__ import (absolute_import, division, print_function) from PyQt4 import QtGui, QtCore import os from reduction_gui.settings.application_settings import GeneralSettings diff --git a/scripts/Interface/reduction_gui/widgets/toftof/toftof_setup.py b/scripts/Interface/reduction_gui/widgets/toftof/toftof_setup.py index 19c2d3789d7c6cf65d1301be4f7e74fc88f475cc..a55ae810d250b4740c8f64d6827703fb1e828008 100644 --- a/scripts/Interface/reduction_gui/widgets/toftof/toftof_setup.py +++ b/scripts/Interface/reduction_gui/widgets/toftof/toftof_setup.py @@ -10,7 +10,6 @@ """ TOFTOF reduction workflow gui. """ -from __future__ import (absolute_import, division, print_function) from qtpy.QtCore import (Qt) # noqa from qtpy.QtGui import (QDoubleValidator) # noqa from qtpy.QtWidgets import (QButtonGroup, QCheckBox, QDoubleSpinBox, QFileDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLayout, QLineEdit, QPushButton, QRadioButton, QSizePolicy, QSpacerItem, QWidget, QVBoxLayout) # noqa diff --git a/scripts/Interface/reduction_gui/widgets/util.py b/scripts/Interface/reduction_gui/widgets/util.py index 87ee5981faac25754c008ab59ca3bd2c9b3f0f37..3d75d27f6ec7eee63646a0a772a0663e76d0c166 100644 --- a/scripts/Interface/reduction_gui/widgets/util.py +++ b/scripts/Interface/reduction_gui/widgets/util.py @@ -7,7 +7,6 @@ """ Utility functions used be the widgets """ -from __future__ import (absolute_import, division, print_function) CSS_VALID = """QLineEdit { background-color: white; }""" diff --git a/scripts/Interface/ui/batchwidget/batch_widget_gui.py b/scripts/Interface/ui/batchwidget/batch_widget_gui.py index fd45f28e0c3f8fc8224eb1d35d24a680931006a1..54a9c9692e087bd0eb7475a71ff9ae1c4591a796 100644 --- a/scripts/Interface/ui/batchwidget/batch_widget_gui.py +++ b/scripts/Interface/ui/batchwidget/batch_widget_gui.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from PyQt4 import QtGui from mantidqtpython import MantidQt from ui.batchwidget.ui_batch_widget_window import Ui_BatchWidgetWindow diff --git a/scripts/Interface/ui/dataprocessorinterface/data_processor_gui.py b/scripts/Interface/ui/dataprocessorinterface/data_processor_gui.py index 540f318b59b8ee436d1be38d236fd6c3bbe7a072..f85e59ea1fe16d4b54bfcb703cc2adcd3c5430ff 100644 --- a/scripts/Interface/ui/dataprocessorinterface/data_processor_gui.py +++ b/scripts/Interface/ui/dataprocessorinterface/data_processor_gui.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from PyQt4 import QtGui from mantidqtpython import MantidQt from ui.dataprocessorinterface.ui_data_processor_window import Ui_DataProcessorWindow diff --git a/scripts/Interface/ui/poldi/poldi_gui.py b/scripts/Interface/ui/poldi/poldi_gui.py index 6ad2af48f06b5f94c4466c78dcd47487b5135ec9..02bc95db6f11b5c48dafdf6273bd1e4d6573d0f4 100644 --- a/scripts/Interface/ui/poldi/poldi_gui.py +++ b/scripts/Interface/ui/poldi/poldi_gui.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) try: from mantidplot import * except ImportError: diff --git a/scripts/Interface/ui/sans_isis/add_runs_page.py b/scripts/Interface/ui/sans_isis/add_runs_page.py index 1ba692ab01e4a0e6b1459db268cc947228760251..9461c580054ca68bbe63cd99fa571646bf2b022e 100644 --- a/scripts/Interface/ui/sans_isis/add_runs_page.py +++ b/scripts/Interface/ui/sans_isis/add_runs_page.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import - from qtpy import QtWidgets from qtpy.QtCore import Signal diff --git a/scripts/Interface/ui/sans_isis/beam_centre.py b/scripts/Interface/ui/sans_isis/beam_centre.py index f3d257b2dc503a6c2f0b45c05cd5629f75832963..531693b47c6cc705ed7b2d359c78725da2ee11ce 100644 --- a/scripts/Interface/ui/sans_isis/beam_centre.py +++ b/scripts/Interface/ui/sans_isis/beam_centre.py @@ -4,12 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta, abstractmethod from qtpy import QtGui, QtCore, QtWidgets -from six import with_metaclass - from mantidqt.utils.qt import load_ui from mantidqt.widgets import messagedisplay @@ -28,7 +24,7 @@ Ui_BeamCentre, _ = load_ui(__file__, "beam_centre.ui") class BeamCentre(QtWidgets.QWidget, Ui_BeamCentre): - class BeamCentreListener(with_metaclass(ABCMeta, object)): + class BeamCentreListener(metaclass=ABCMeta): """ Defines the elements which a presenter can listen to for the beam centre finder """ diff --git a/scripts/Interface/ui/sans_isis/diagnostics_page.py b/scripts/Interface/ui/sans_isis/diagnostics_page.py index 57a463bf875f092084fecc3fed4395f3bfc1867c..e32925663e92e36f2f01a380f3dfea689c2d6d98 100644 --- a/scripts/Interface/ui/sans_isis/diagnostics_page.py +++ b/scripts/Interface/ui/sans_isis/diagnostics_page.py @@ -4,14 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta, abstractmethod from qtpy import QtCore, QtWidgets from mantidqt.utils.qt import load_ui -from six import with_metaclass - from sans.gui_logic.gui_common import (load_file, GENERIC_SETTINGS) try: @@ -24,7 +20,7 @@ Ui_DiagnosticsPage, _ = load_ui(__file__, "diagnostics_page.ui") class DiagnosticsPage(QtWidgets.QWidget, Ui_DiagnosticsPage): - class DiagnosticsPageListener(with_metaclass(ABCMeta, object)): + class DiagnosticsPageListener(metaclass=ABCMeta): """ Defines the elements which a presenter can listen to for the beam centre finder """ diff --git a/scripts/Interface/ui/sans_isis/masking_table.py b/scripts/Interface/ui/sans_isis/masking_table.py index 893c357c37cb508af7c9e2ed92f17f3055d87d02..df07e525946097e1e4b0682e6c6c6e781b06a0db 100644 --- a/scripts/Interface/ui/sans_isis/masking_table.py +++ b/scripts/Interface/ui/sans_isis/masking_table.py @@ -10,19 +10,15 @@ The view for the masking table displays all available masks for a SANS reduction and masked SANS workspace. """ -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta, abstractmethod from qtpy import QtWidgets -from six import with_metaclass - from mantidqt.utils.qt import load_ui Ui_MaskingTable, _ = load_ui(__file__, "masking_table.ui") class MaskingTable(QtWidgets.QWidget, Ui_MaskingTable): - class MaskingTableListener(with_metaclass(ABCMeta, object)): + class MaskingTableListener(metaclass=ABCMeta): """ Defines the elements which a presenter can listen to for the masking table """ diff --git a/scripts/Interface/ui/sans_isis/run_selector_widget.py b/scripts/Interface/ui/sans_isis/run_selector_widget.py index daf7f0dbfe1acede20bb1a79e11e45fd641e8b14..c532514a720f995dfd8722fce3f503a85d04a3ff 100644 --- a/scripts/Interface/ui/sans_isis/run_selector_widget.py +++ b/scripts/Interface/ui/sans_isis/run_selector_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtGui, QtWidgets from qtpy.QtCore import Signal, QSettings, QFileInfo diff --git a/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py b/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py index 19d1d483fbf2a20c80a29635083cbbeeb0b3df3b..cc002a04f163a85bbfb7987c4fcd316da8040170 100644 --- a/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py +++ b/scripts/Interface/ui/sans_isis/sans_data_processor_gui.py @@ -8,17 +8,13 @@ """ Main view for the ISIS SANS reduction interface. """ -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta, abstractmethod from qtpy.QtCore import QRegExp from qtpy.QtGui import (QDoubleValidator, QIntValidator, QRegExpValidator) from qtpy.QtWidgets import (QListWidgetItem, QMessageBox, QFileDialog, QMainWindow) -from six import with_metaclass - from mantid.kernel import (Logger, UsageService, FeatureType) -from mantid.py3compat import Enum +from enum import Enum from mantidqt import icons from mantidqt.interfacemanager import InterfaceManager from mantidqt.utils.qt import load_ui @@ -57,7 +53,7 @@ class SANSDataProcessorGui(QMainWindow, MULTI_PERIOD_COLUMNS = ["SSP", "STP", "SDP", "CSP", "CTP", "CDP"] - class RunTabListener(with_metaclass(ABCMeta, object)): + class RunTabListener(metaclass=ABCMeta): """ Defines the elements which a presenter can listen to in this View """ diff --git a/scripts/Interface/ui/sans_isis/settings_diagnostic_tab.py b/scripts/Interface/ui/sans_isis/settings_diagnostic_tab.py index f04d99dbc8d790b5c295b7b51baa4fcf2183dae7..21ad68551084814a2cd7cc601d9bfb79522a53ac 100644 --- a/scripts/Interface/ui/sans_isis/settings_diagnostic_tab.py +++ b/scripts/Interface/ui/sans_isis/settings_diagnostic_tab.py @@ -11,11 +11,9 @@ from the individual rows in the data table. This view is useful for checking the and helps the developer to identify issues. """ -from __future__ import (absolute_import, division, print_function) from abc import ABCMeta, abstractmethod import os from qtpy import QtWidgets -from six import with_metaclass, PY3 from mantidqt.utils.qt import load_ui @@ -23,14 +21,13 @@ from mantid import UsageService from mantid.kernel import FeatureType from sans.gui_logic.gui_common import (GENERIC_SETTINGS, JSON_SUFFIX, load_file) -if PY3: - unicode = str +unicode = str Ui_SettingsDiagnosticTab, _ = load_ui(__file__, "settings_diagnostic_tab.ui") class SettingsDiagnosticTab(QtWidgets.QWidget, Ui_SettingsDiagnosticTab): - class SettingsDiagnosticTabListener(with_metaclass(ABCMeta, object)): + class SettingsDiagnosticTabListener(metaclass=ABCMeta): """ Defines the elements which a presenter can listen to for the diagnostic tab """ diff --git a/scripts/Interface/ui/sans_isis/summation_settings_widget.py b/scripts/Interface/ui/sans_isis/summation_settings_widget.py index b80a591bf85abed597cd1cf2865cc3b6e5dadfcf..cb1d2f857bd0756863a234aaad3a9ab92a520537 100644 --- a/scripts/Interface/ui/sans_isis/summation_settings_widget.py +++ b/scripts/Interface/ui/sans_isis/summation_settings_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets from qtpy.QtCore import Signal diff --git a/scripts/Interface/ui/sans_isis/work_handler.py b/scripts/Interface/ui/sans_isis/work_handler.py index 19b6b0532732a9e2a6829da3b88f06b371a6e62f..6945ad09ff3929d42c8a2c7c7e1179309e4a41b8 100644 --- a/scripts/Interface/ui/sans_isis/work_handler.py +++ b/scripts/Interface/ui/sans_isis/work_handler.py @@ -14,11 +14,8 @@ The "worker" handles running the function via a unique process ID; "listeners" m each process which are then notified upon certain actions (such as an error being thrown by the worker, or the worker finishing its task) using the nested class WorkListener. """ -from __future__ import absolute_import - from qtpy.QtCore import Slot, QThreadPool from abc import ABCMeta, abstractmethod -from six import with_metaclass import functools import uuid @@ -34,7 +31,7 @@ class WorkHandler(object): an ID which is then used to identify the Worker through the API. """ - class WorkListener(with_metaclass(ABCMeta, object)): + class WorkListener(metaclass=ABCMeta): """ This abstract base class defines methods which must be overriden and which handle responses to certain worker actions such as raised errors, or completion. diff --git a/scripts/LargeScaleStructures/EQSANS_geometry.py b/scripts/LargeScaleStructures/EQSANS_geometry.py index b8cd5667b6d4887a8c21b22279a388c5246186f3..303b277ff0f2d4c5ffbfdef8436f396f621cc087 100644 --- a/scripts/LargeScaleStructures/EQSANS_geometry.py +++ b/scripts/LargeScaleStructures/EQSANS_geometry.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from .geometry_writer import MantidGeom import math diff --git a/scripts/LargeScaleStructures/PolrefTest.py b/scripts/LargeScaleStructures/PolrefTest.py index be34f82161f55b74a9f7e59c6b628aa23bf4a485..6cef5ddaa58da0cfaf70cbf172bee2331366728e 100644 --- a/scripts/LargeScaleStructures/PolrefTest.py +++ b/scripts/LargeScaleStructures/PolrefTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from .ReflectometerCors import * diff --git a/scripts/LargeScaleStructures/REF_L_geometry.py b/scripts/LargeScaleStructures/REF_L_geometry.py index db7ee1159ce62dab5b0621de8a92145cc6147896..895bef04c3d698b3a277e707e188b957985d4727 100644 --- a/scripts/LargeScaleStructures/REF_L_geometry.py +++ b/scripts/LargeScaleStructures/REF_L_geometry.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from .geometry_writer import MantidGeom import mantid.simpleapi as mantid diff --git a/scripts/LargeScaleStructures/ReflectometerCors.py b/scripts/LargeScaleStructures/ReflectometerCors.py index 14d8411622facd5bbe63b044cf5351fca9d33c55..b07d5ad10a750b4fb9c7f15d631e00bd0bbf69fd 100644 --- a/scripts/LargeScaleStructures/ReflectometerCors.py +++ b/scripts/LargeScaleStructures/ReflectometerCors.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * diff --git a/scripts/LargeScaleStructures/data_stitching.py b/scripts/LargeScaleStructures/data_stitching.py index 684926166532849201f80dd47063eee73592e7ff..7af99d7a7a428f8db9cbf898aa92111311ef5301 100644 --- a/scripts/LargeScaleStructures/data_stitching.py +++ b/scripts/LargeScaleStructures/data_stitching.py @@ -8,7 +8,6 @@ """ Data stitching for SANS and reflectometry """ -from __future__ import (absolute_import, division, print_function) import os from mantid.simpleapi import * from mantid.kernel import Logger diff --git a/scripts/LargeScaleStructures/geometry_writer.py b/scripts/LargeScaleStructures/geometry_writer.py index 1b5a0a8c5aff7b6cba75bf7d4d165a51028b1e4d..b63ea581a670dbb85324c558e52ea83b518bd455 100644 --- a/scripts/LargeScaleStructures/geometry_writer.py +++ b/scripts/LargeScaleStructures/geometry_writer.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from xml.dom.minidom import getDOMImplementation from datetime import datetime import re diff --git a/scripts/MSlice.py b/scripts/MSlice.py index 89c3f329789b37611de4b793fcb22b2b0e95d2f8..fd666becbc7e22c62d086df31ec2a597463f4c42 100755 --- a/scripts/MSlice.py +++ b/scripts/MSlice.py @@ -5,7 +5,5 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import - from mslice.app import show_gui show_gui() diff --git a/scripts/MantidIPython/__init__.py b/scripts/MantidIPython/__init__.py index a8c8b49962078356826a6e1bf737b80d6b5c9ca0..3b0a8c2dac161fe2ed8bb04a4a39758e92abaf00 100644 --- a/scripts/MantidIPython/__init__.py +++ b/scripts/MantidIPython/__init__.py @@ -11,7 +11,6 @@ Some tools for use in ipython notebooks generated by Mantid. # Suppress warnings about unused import as these # imports are important for iPython -from __future__ import (absolute_import, division, print_function) from MantidIPython.plot_functions import * # noqa: F401 import warnings # noqa: F401 import mantid.kernel # noqa: F401 diff --git a/scripts/MantidIPython/plot_functions.py b/scripts/MantidIPython/plot_functions.py index a06b74ad0caa0251c8b12b5abd99f3e083a0dffb..31dec186e10c5fe3a72cc5ada62b6189e2a4af35 100644 --- a/scripts/MantidIPython/plot_functions.py +++ b/scripts/MantidIPython/plot_functions.py @@ -8,7 +8,6 @@ Plotting functions for use in IPython notebooks that are generated by MantidPlot """ -from __future__ import (absolute_import, division, print_function) import matplotlib.pyplot as plt # Import Mantid diff --git a/scripts/MultiPlotting/QuickEdit/quickEdit_presenter.py b/scripts/MultiPlotting/QuickEdit/quickEdit_presenter.py index 772e1c579cc3471dd5336f33f6f6af871b3eafe3..e7cffe80a92dd4114f989e9a92d696e80563cca0 100644 --- a/scripts/MultiPlotting/QuickEdit/quickEdit_presenter.py +++ b/scripts/MultiPlotting/QuickEdit/quickEdit_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function class QuickEditPresenter(object): diff --git a/scripts/MultiPlotting/QuickEdit/quickEdit_view.py b/scripts/MultiPlotting/QuickEdit/quickEdit_view.py index d03db00ff0d71d2d31cfefc3875993b10ea15fb7..af2c38de5705f5f54a9164746a6c5d5a3bc3e63e 100644 --- a/scripts/MultiPlotting/QuickEdit/quickEdit_view.py +++ b/scripts/MultiPlotting/QuickEdit/quickEdit_view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function from qtpy import QtWidgets, QtCore import qtpy from MultiPlotting.AxisChanger.axis_changer_presenter import AxisChangerPresenter diff --git a/scripts/MultiPlotting/QuickEdit/quickEdit_widget.py b/scripts/MultiPlotting/QuickEdit/quickEdit_widget.py index f6a0eeb23aa60f735bbcf0dfd4814c47ca9365fa..f20c3c74555dcb8bb0cfce42b71901eb9998e7f7 100644 --- a/scripts/MultiPlotting/QuickEdit/quickEdit_widget.py +++ b/scripts/MultiPlotting/QuickEdit/quickEdit_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from MultiPlotting.QuickEdit.quickEdit_view import QuickEditView from MultiPlotting.QuickEdit.quickEdit_presenter import QuickEditPresenter diff --git a/scripts/MultiPlotting/edit_windows/remove_plot_window.py b/scripts/MultiPlotting/edit_windows/remove_plot_window.py index 6eec769417d50740c85c55fbeddb2f0159daa9f3..58f32431a73b03aea71aa1927fbc06df50c2b2a9 100644 --- a/scripts/MultiPlotting/edit_windows/remove_plot_window.py +++ b/scripts/MultiPlotting/edit_windows/remove_plot_window.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtCore, QtWidgets from Muon.GUI.Common.utilities import table_utils diff --git a/scripts/MultiPlotting/edit_windows/select_subplot.py b/scripts/MultiPlotting/edit_windows/select_subplot.py index 92fdb26781374ef63dd5dec249ced7e2b8541626..30469feaed1e4b8f25f356b94d747c98965fb5eb 100644 --- a/scripts/MultiPlotting/edit_windows/select_subplot.py +++ b/scripts/MultiPlotting/edit_windows/select_subplot.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtCore, QtWidgets diff --git a/scripts/MultiPlotting/gridspec_engine.py b/scripts/MultiPlotting/gridspec_engine.py index 272b20744246fa5b4b49fb215faae9c3f9e9481c..2cc581762e182b18176ffe2485f10bce65dcf346 100644 --- a/scripts/MultiPlotting/gridspec_engine.py +++ b/scripts/MultiPlotting/gridspec_engine.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from matplotlib.gridspec import GridSpec import math diff --git a/scripts/MultiPlotting/label.py b/scripts/MultiPlotting/label.py index aeb8572e3a5a72a07fc5255f134d526c394613f7..ffa28338455eec7d9ae8534443b88caab8e89149 100644 --- a/scripts/MultiPlotting/label.py +++ b/scripts/MultiPlotting/label.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function class Label(object): diff --git a/scripts/MultiPlotting/multi_plotting_context.py b/scripts/MultiPlotting/multi_plotting_context.py index e1ef31e584e3c6af39eaade6bd8be014ac918f03..f784a705178776070163eb3c7a5ae0cb79fcf4bc 100644 --- a/scripts/MultiPlotting/multi_plotting_context.py +++ b/scripts/MultiPlotting/multi_plotting_context.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from MultiPlotting.gridspec_engine import gridspecEngine from MultiPlotting.subplot.subplot_context import subplotContext diff --git a/scripts/MultiPlotting/multi_plotting_widget.py b/scripts/MultiPlotting/multi_plotting_widget.py index de2329899f1cec9254ddc15d8c5e85f4bfa85174..5627114b5dd3c460ededdeef564ddc3dce4479d4 100644 --- a/scripts/MultiPlotting/multi_plotting_widget.py +++ b/scripts/MultiPlotting/multi_plotting_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from copy import deepcopy from MultiPlotting.subplot.subplot import subplot diff --git a/scripts/MultiPlotting/navigation_toolbar.py b/scripts/MultiPlotting/navigation_toolbar.py index c9566b5d3cf9d8689ce5bc9dffa7cc34f0fdfd27..3780b57ae786415e2e9d1fc1f0f3846c40866fdb 100644 --- a/scripts/MultiPlotting/navigation_toolbar.py +++ b/scripts/MultiPlotting/navigation_toolbar.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtGui from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar diff --git a/scripts/MultiPlotting/subplot/subplot.py b/scripts/MultiPlotting/subplot/subplot.py index a0c72b0972badbbf734826cc07154a56dc6e4c69..7c599db34c095d9ee5462bf96de8b74e438fee74 100644 --- a/scripts/MultiPlotting/subplot/subplot.py +++ b/scripts/MultiPlotting/subplot/subplot.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from copy import deepcopy diff --git a/scripts/MultiPlotting/subplot/subplot_ADS_observer.py b/scripts/MultiPlotting/subplot/subplot_ADS_observer.py index 4556adf12291303621e63fdc2a2bfe2d468a222a..c94c85cebcd566b347251fec997b81caadfed963 100644 --- a/scripts/MultiPlotting/subplot/subplot_ADS_observer.py +++ b/scripts/MultiPlotting/subplot/subplot_ADS_observer.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.api import AnalysisDataServiceObserver diff --git a/scripts/MultiPlotting/subplot/subplot_context.py b/scripts/MultiPlotting/subplot/subplot_context.py index 6bc18e7315c46b3b37f9bdd127b3f3bdb99f5b95..264db242b05275cecb285e646384e0fa688b5a80 100644 --- a/scripts/MultiPlotting/subplot/subplot_context.py +++ b/scripts/MultiPlotting/subplot/subplot_context.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -from six import iteritems from mantid import plots from copy import copy @@ -193,7 +191,7 @@ class subplotContext(object): del self._specNum[name] # remove line for ws to_delete = [] - for key, list in iteritems(self._ws): + for key, list in self._ws.items(): if name in list: list.remove(name) if len(list) == 0: diff --git a/scripts/Muon/GUI/Common/ADSHandler/muon_workspace_wrapper.py b/scripts/Muon/GUI/Common/ADSHandler/muon_workspace_wrapper.py index 3255bc3efd7b089cb5abe9e340ef429480069c76..54dba9366aa38d36fa3c1bf18a19eaf1d450bdc2 100644 --- a/scripts/Muon/GUI/Common/ADSHandler/muon_workspace_wrapper.py +++ b/scripts/Muon/GUI/Common/ADSHandler/muon_workspace_wrapper.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=F0401 -from __future__ import (absolute_import, division, print_function) from mantid.api import Workspace, AnalysisDataService from mantid.simpleapi import RenameWorkspace, GroupWorkspaces diff --git a/scripts/Muon/GUI/Common/ADSHandler/workspace_naming.py b/scripts/Muon/GUI/Common/ADSHandler/workspace_naming.py index 97aab03dc77c0d8862dd50c4b9fd53028ef344d9..c5306e13bbae6bd4a3e1e5baed5b0f76cb73e4a2 100644 --- a/scripts/Muon/GUI/Common/ADSHandler/workspace_naming.py +++ b/scripts/Muon/GUI/Common/ADSHandler/workspace_naming.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import re group_str = "; Group; " diff --git a/scripts/Muon/GUI/Common/calculate_pair_and_group.py b/scripts/Muon/GUI/Common/calculate_pair_and_group.py index 06bba6dae21a753a95e38dd7e80f258a74152f67..68947d3e0690a4202feeab102bb05754544dcefb 100644 --- a/scripts/Muon/GUI/Common/calculate_pair_and_group.py +++ b/scripts/Muon/GUI/Common/calculate_pair_and_group.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - import Muon.GUI.Common.utilities.algorithm_utils as algorithm_utils diff --git a/scripts/Muon/GUI/Common/checkbox.py b/scripts/Muon/GUI/Common/checkbox.py index 4d925e5863e439e850f0af49dd9cef7a1403e363..7fe7b683443442067aab03528352d97ce7fb9068 100644 --- a/scripts/Muon/GUI/Common/checkbox.py +++ b/scripts/Muon/GUI/Common/checkbox.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from qtpy import QtCore, QtWidgets diff --git a/scripts/Muon/GUI/Common/context_example/context_example_model.py b/scripts/Muon/GUI/Common/context_example/context_example_model.py index 6673b273eae76f7e9b5454500202863487964888..de5821377d759c5ec4f546b017c17a733c86ee42 100644 --- a/scripts/Muon/GUI/Common/context_example/context_example_model.py +++ b/scripts/Muon/GUI/Common/context_example/context_example_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common import group_object from Muon.GUI.Common import pair_object diff --git a/scripts/Muon/GUI/Common/context_example/context_example_presenter.py b/scripts/Muon/GUI/Common/context_example/context_example_presenter.py index c46d45a9036e85b845a911e11d9d0d3a9beec53f..40e3d95f504e08b1d14601b01cd87a7fc6ba9ab9 100644 --- a/scripts/Muon/GUI/Common/context_example/context_example_presenter.py +++ b/scripts/Muon/GUI/Common/context_example/context_example_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class ContextExamplePresenter(object): diff --git a/scripts/Muon/GUI/Common/context_example/context_example_view.py b/scripts/Muon/GUI/Common/context_example/context_example_view.py index dfa139579fdcbf9353e9fea5230eb3080b0a852d..eb8420521173a34acaf7aedc3cdb667fc2051bec 100644 --- a/scripts/Muon/GUI/Common/context_example/context_example_view.py +++ b/scripts/Muon/GUI/Common/context_example/context_example_view.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - from qtpy import QtCore, QtWidgets from Muon.GUI.Common.utilities import table_utils diff --git a/scripts/Muon/GUI/Common/context_example/context_example_widget.py b/scripts/Muon/GUI/Common/context_example/context_example_widget.py index f9aca966a31f3be682372057dfa0cdd1a6e906b4..cbe2317c8b1d5170cf60c2c502cc07345e08af97 100644 --- a/scripts/Muon/GUI/Common/context_example/context_example_widget.py +++ b/scripts/Muon/GUI/Common/context_example/context_example_widget.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - from Muon.GUI.Common.context_example.context_example_view import ContextExampleView from Muon.GUI.Common.context_example.context_example_presenter import ContextExamplePresenter from Muon.GUI.Common.context_example.context_example_model import ContextExampleModel diff --git a/scripts/Muon/GUI/Common/contexts/fitting_context.py b/scripts/Muon/GUI/Common/contexts/fitting_context.py index adf6d1398d7ab78106a9fc06486693515ca8276f..d04bab1587913786ca3ee12d973c75d0a7fa1a7b 100644 --- a/scripts/Muon/GUI/Common/contexts/fitting_context.py +++ b/scripts/Muon/GUI/Common/contexts/fitting_context.py @@ -4,13 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division) - from collections import OrderedDict import re from mantid.api import AnalysisDataService -from mantid.py3compat import iteritems, iterkeys, string_types import numpy as np from mantidqt.utils.observer_pattern import Observable @@ -60,7 +57,7 @@ def _create_unique_param_lookup(parameter_workspace, global_parameters): return False, False # Do we have this parameter already? - for unique_name in iterkeys(unique_params): + for unique_name in unique_params.keys(): if is_same_parameter(unique_name, global_name): return True, True @@ -86,7 +83,7 @@ def _move_globals_to_front(unique_params): :return: The updated parameters list reordered """ return OrderedDict( - sorted(iteritems(unique_params), key=lambda x: not x[1].is_global)) + sorted(unique_params.items(), key=lambda x: not x[1].is_global)) class Parameter(object): @@ -200,9 +197,9 @@ class FitInformation(object): global_parameters) self.fit_function_name = fit_function_name self.input_workspaces = [input_workspace] if isinstance( - input_workspace, string_types) else input_workspace + input_workspace, str) else input_workspace self.output_workspace_names = [output_workspace_names] if isinstance( - output_workspace_names, string_types) else output_workspace_names + output_workspace_names, str) else output_workspace_names def __eq__(self, other): """Objects are equal if each member is equal to the other""" diff --git a/scripts/Muon/GUI/Common/contexts/muon_context.py b/scripts/Muon/GUI/Common/contexts/muon_context.py index 25bb0fe44ff918a609ffac7b7b6ed757fb680f55..0f98ba53fe4893aae4d4cbcc1d748dcf100b8176 100644 --- a/scripts/Muon/GUI/Common/contexts/muon_context.py +++ b/scripts/Muon/GUI/Common/contexts/muon_context.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.ADSHandler.workspace_naming import (get_raw_data_workspace_name, get_group_data_workspace_name, get_pair_data_workspace_name, get_base_data_directory, get_group_asymmetry_name, diff --git a/scripts/Muon/GUI/Common/contexts/muon_context_ADS_observer.py b/scripts/Muon/GUI/Common/contexts/muon_context_ADS_observer.py index a00871a5ce1943a36fef933964767f25d54221d9..3a4e3fc6008de3d4d6903b7b3ce1d2613aa98c7a 100644 --- a/scripts/Muon/GUI/Common/contexts/muon_context_ADS_observer.py +++ b/scripts/Muon/GUI/Common/contexts/muon_context_ADS_observer.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) from mantid.api import AnalysisDataServiceObserver, WorkspaceGroup from functools import wraps import sys diff --git a/scripts/Muon/GUI/Common/contexts/muon_data_context.py b/scripts/Muon/GUI/Common/contexts/muon_data_context.py index 17fdc8f7b194102fb81275b36b8526ac11fecabd..fe808fe9917b1afbf5175bec85e63fcee4af4237 100644 --- a/scripts/Muon/GUI/Common/contexts/muon_data_context.py +++ b/scripts/Muon/GUI/Common/contexts/muon_data_context.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import Muon.GUI.Common.utilities.load_utils as load_utils from Muon.GUI.Common.muon_group import MuonGroup from Muon.GUI.Common.muon_pair import MuonPair diff --git a/scripts/Muon/GUI/Common/contexts/muon_group_pair_context.py b/scripts/Muon/GUI/Common/contexts/muon_group_pair_context.py index b348039d81c3528edf42f14a430629bf5c7b1d09..94b9e597810a91221085287b895921c0b6dbb0a9 100644 --- a/scripts/Muon/GUI/Common/contexts/muon_group_pair_context.py +++ b/scripts/Muon/GUI/Common/contexts/muon_group_pair_context.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import Muon.GUI.Common.utilities.xml_utils as xml_utils diff --git a/scripts/Muon/GUI/Common/contexts/muon_gui_context.py b/scripts/Muon/GUI/Common/contexts/muon_gui_context.py index c0e929eb5e8ff1ce78c3a8088ea22dbc18e8c5a8..60647c6edbb049122f52d9b5e5d85588ccc77f23 100644 --- a/scripts/Muon/GUI/Common/contexts/muon_gui_context.py +++ b/scripts/Muon/GUI/Common/contexts/muon_gui_context.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from mantidqt.utils.observer_pattern import Observable diff --git a/scripts/Muon/GUI/Common/contexts/phase_table_context.py b/scripts/Muon/GUI/Common/contexts/phase_table_context.py index c04dd95cece88dd820d5c5c23b19c3a62d8ecbce..421f9e0adfee560cd7dd09e7578fc5266a3dd19c 100644 --- a/scripts/Muon/GUI/Common/contexts/phase_table_context.py +++ b/scripts/Muon/GUI/Common/contexts/phase_table_context.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - default_dict = {'first_good_time': 0.1, 'last_good_time': 15, 'forward_group': 'fwd', 'backward_group': 'bwd', 'input_workspace': '', 'phase_quad_input_workspace': '', 'phase_table_for_phase_quad': ''} diff --git a/scripts/Muon/GUI/Common/dock/dock_view.py b/scripts/Muon/GUI/Common/dock/dock_view.py index 215fe68c9b74534ef5246f3855292fc02a0a4626..56b97d3b6e841d684b0519f6424f6265c9af5f15 100644 --- a/scripts/Muon/GUI/Common/dock/dock_view.py +++ b/scripts/Muon/GUI/Common/dock/dock_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore diff --git a/scripts/Muon/GUI/Common/dock/dockable_tabs.py b/scripts/Muon/GUI/Common/dock/dockable_tabs.py index e47ea72320ab7a4a89dce9fc9d3a2b82795d1c49..a562f95223421e31bca80ecbe8f9feb3f59084f3 100644 --- a/scripts/Muon/GUI/Common/dock/dockable_tabs.py +++ b/scripts/Muon/GUI/Common/dock/dockable_tabs.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - - from qtpy import QtWidgets, QtCore, QtGui, PYQT4 from qtpy.QtCore import Slot diff --git a/scripts/Muon/GUI/Common/dummy/dummy_presenter.py b/scripts/Muon/GUI/Common/dummy/dummy_presenter.py index 9929b766792d40bc854e7b62fa0076d61885d98a..c3b8ee64d475257d02e85db194bbb7d1c30ca96c 100644 --- a/scripts/Muon/GUI/Common/dummy/dummy_presenter.py +++ b/scripts/Muon/GUI/Common/dummy/dummy_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class DummyPresenter(object): diff --git a/scripts/Muon/GUI/Common/dummy/dummy_view.py b/scripts/Muon/GUI/Common/dummy/dummy_view.py index 4caceb9d613ae037a7ba83a3c941be20e76f0e05..2d98d6bddeee0580b9ae8c3dc2392d48d60d3678 100644 --- a/scripts/Muon/GUI/Common/dummy/dummy_view.py +++ b/scripts/Muon/GUI/Common/dummy/dummy_view.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - from qtpy import QtCore, QtWidgets diff --git a/scripts/Muon/GUI/Common/dummy/dummy_widget.py b/scripts/Muon/GUI/Common/dummy/dummy_widget.py index 6747bbea2e4ff42c7d488ca50ebada6c66a36768..4edad0589dfa7752770dba4f29e18fc94ecfeffa 100644 --- a/scripts/Muon/GUI/Common/dummy/dummy_widget.py +++ b/scripts/Muon/GUI/Common/dummy/dummy_widget.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - from Muon.GUI.Common.dummy.dummy_view import DummyView from Muon.GUI.Common.dummy.dummy_presenter import DummyPresenter diff --git a/scripts/Muon/GUI/Common/dummy_label/dummy_label_model.py b/scripts/Muon/GUI/Common/dummy_label/dummy_label_model.py index 7be742bef59e746f3459d611166ed106f38fd388..9d178203f5d0f80637b722dea7e198f14c7abaef 100644 --- a/scripts/Muon/GUI/Common/dummy_label/dummy_label_model.py +++ b/scripts/Muon/GUI/Common/dummy_label/dummy_label_model.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class DummyLabelModel(object): diff --git a/scripts/Muon/GUI/Common/dummy_label/dummy_label_presenter.py b/scripts/Muon/GUI/Common/dummy_label/dummy_label_presenter.py index 2d69d0ab8496acc48ded06779881626b860af768..dd753d9e2539b16214206cb40c3e39892e7ede45 100644 --- a/scripts/Muon/GUI/Common/dummy_label/dummy_label_presenter.py +++ b/scripts/Muon/GUI/Common/dummy_label/dummy_label_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class DummyLabelPresenter(object): diff --git a/scripts/Muon/GUI/Common/dummy_label/dummy_label_view.py b/scripts/Muon/GUI/Common/dummy_label/dummy_label_view.py index 786f900a342f669d3862a2349cb039f58a87e25f..bd82af777a6cc1cfa3e66ff625eeea5eda40850f 100644 --- a/scripts/Muon/GUI/Common/dummy_label/dummy_label_view.py +++ b/scripts/Muon/GUI/Common/dummy_label/dummy_label_view.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - from qtpy import QtWidgets diff --git a/scripts/Muon/GUI/Common/dummy_label/dummy_label_widget.py b/scripts/Muon/GUI/Common/dummy_label/dummy_label_widget.py index d42c2a24373e391b5f05f9d6a36157906fbb9745..49a24d0b8427b371003f98f4e651487036005f30 100644 --- a/scripts/Muon/GUI/Common/dummy_label/dummy_label_widget.py +++ b/scripts/Muon/GUI/Common/dummy_label/dummy_label_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common.dummy_label.dummy_label_view import DummyLabelView from Muon.GUI.Common.dummy_label.dummy_label_presenter import DummyLabelPresenter from Muon.GUI.Common.dummy_label.dummy_label_model import DummyLabelModel diff --git a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_model.py b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_model.py index 3444f771e36606dd58669d7908f4f698d69a803d..faa6f83df02550aeb0ffe5e37caafe91bad474ce 100644 --- a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_model.py +++ b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.utilities.algorithm_utils import run_Fit, run_simultaneous_Fit, run_CalculateMuonAsymmetry from Muon.GUI.Common.ADSHandler.workspace_naming import * from Muon.GUI.Common.ADSHandler.muon_workspace_wrapper import MuonWorkspaceWrapper diff --git a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_presenter.py b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_presenter.py index 375bad229bc331ca8797b585053fc3dabe79243b..86f0a81b8a4001723e7c1ff860af5c83d84578f6 100644 --- a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_presenter.py +++ b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.fitting_tab_widget.workspace_selector_view import WorkspaceSelectorView from mantidqt.utils.observer_pattern import GenericObserver, GenericObserverWithArgPassing, GenericObservable from Muon.GUI.Common.thread_model_wrapper import ThreadModelWrapperWithOutput diff --git a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_view.py b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_view.py index 64f70f916fb31c06c2a65c165d81a0ec3d01ebd1..d791afb418dc8886e080a8a056c33489fe08ebc5 100644 --- a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_view.py +++ b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from Muon.GUI.Common.utilities import table_utils from Muon.GUI.Common.message_box import warning diff --git a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_widget.py b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_widget.py index d6fc5812d925ccbbc64d2d6778b10eafda5e57b6..698f0b95b6f75a7545894f74d31df9ec6a3a4c92 100644 --- a/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_widget.py +++ b/scripts/Muon/GUI/Common/fitting_tab_widget/fitting_tab_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.fitting_tab_widget.fitting_tab_view import FittingTabView from Muon.GUI.Common.fitting_tab_widget.fitting_tab_presenter import FittingTabPresenter from Muon.GUI.Common.fitting_tab_widget.fitting_tab_model import FittingTabModel diff --git a/scripts/Muon/GUI/Common/fitting_tab_widget/workspace_selector_view.py b/scripts/Muon/GUI/Common/fitting_tab_widget/workspace_selector_view.py index 7e5080196601f9de338d16a2e8684ed2638b982b..5a19df66aefcd55f657655587c610d9669e38aea 100644 --- a/scripts/Muon/GUI/Common/fitting_tab_widget/workspace_selector_view.py +++ b/scripts/Muon/GUI/Common/fitting_tab_widget/workspace_selector_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from qtpy import QtWidgets from mantidqt.utils.qt import load_ui diff --git a/scripts/Muon/GUI/Common/group_object.py b/scripts/Muon/GUI/Common/group_object.py index 167a0b4d53691f3d6f21d6cce3ead9dea58238a5..fd01718f705c5334702739d78088646121ad01a5 100644 --- a/scripts/Muon/GUI/Common/group_object.py +++ b/scripts/Muon/GUI/Common/group_object.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import pythonTSV as TSVHelper diff --git a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget.py b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget.py index 719c2daf2c021e7c06d464f693b329a62d7c56fb..14a092685d8557da15f783d64239ef414a01047b 100644 --- a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget.py +++ b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.grouping_table_widget.grouping_table_widget_view import GroupingTableView from Muon.GUI.Common.grouping_table_widget.grouping_table_widget_presenter import GroupingTablePresenter diff --git a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_model.py b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_model.py index 661affe491a621903345a1fd94ea00466b892c1c..c51b396c5e3ade32a01366cc20362bb9acccbb09 100644 --- a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_model.py +++ b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common.contexts.muon_data_context import construct_empty_group, construct_empty_pair from Muon.GUI.Common.muon_group import MuonGroup from Muon.GUI.Common.muon_pair import MuonPair diff --git a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_presenter.py b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_presenter.py index 38b599d1be0e77e8a250ebc6aa4107cc3dc79e55..0543ddff8e0cf36dbbb85e5574e307baa6e6bf00 100644 --- a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_presenter.py +++ b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantidqt.utils.observer_pattern import Observer, Observable, GenericObservable, GenericObserver import Muon.GUI.Common.utilities.muon_file_utils as file_utils import Muon.GUI.Common.utilities.xml_utils as xml_utils diff --git a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_view.py b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_view.py index e2bdf558ff7508b4a1c7658e6a92bb9907167d42..b657173dec8c4b20319905a055df571bfeefa1fc 100644 --- a/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_view.py +++ b/scripts/Muon/GUI/Common/grouping_tab_widget/grouping_tab_widget_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, PYQT4, QtCore, QtGui from Muon.GUI.Common.utilities.run_string_utils import run_string_regex from Muon.GUI.Common.message_box import warning, question diff --git a/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_presenter.py b/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_presenter.py index 646dba409d377a370a65729e22f6174897a28526..b616bb1e0331055e5f642b5061d0d20a282ac7c7 100644 --- a/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_presenter.py +++ b/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import re from Muon.GUI.Common.utilities import run_string_utils as run_utils diff --git a/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_view.py b/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_view.py index 1cd4fecb95c41a16a72bef076f61e3a423ce4d1d..13cf8df0a3b83d04fbf0de946ce93e37d349f76b 100644 --- a/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_view.py +++ b/scripts/Muon/GUI/Common/grouping_table_widget/grouping_table_widget_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtGui, QtCore from qtpy.QtCore import Signal import sys diff --git a/scripts/Muon/GUI/Common/help_widget/help_widget_presenter.py b/scripts/Muon/GUI/Common/help_widget/help_widget_presenter.py index 73851a53325ef98af3acf55d7a1787039758b6f4..ecc2fe1ea6d5763b09d6a56f34ada2c934af70db 100644 --- a/scripts/Muon/GUI/Common/help_widget/help_widget_presenter.py +++ b/scripts/Muon/GUI/Common/help_widget/help_widget_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from Muon.GUI.Common.help_widget.help_widget_view import HelpWidgetView diff --git a/scripts/Muon/GUI/Common/help_widget/help_widget_view.py b/scripts/Muon/GUI/Common/help_widget/help_widget_view.py index 8ddae50bcea3d6ad54e4c65ffd4f42adb1e08d29..da1db7b2a6accfb58622fad5f3ef078fa0a4241e 100644 --- a/scripts/Muon/GUI/Common/help_widget/help_widget_view.py +++ b/scripts/Muon/GUI/Common/help_widget/help_widget_view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets import Muon.GUI.Common.message_box as message_box diff --git a/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_model.py b/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_model.py index 2982446416e7bbe5cf7ea735e6f3eef872981559..37c95c8fd06247cbd1bbe2cb36499b0b8ffaf3e5 100644 --- a/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_model.py +++ b/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from decimal import Decimal, InvalidOperation from mantid import api from mantid.api import ITableWorkspace diff --git a/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_presenter.py b/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_presenter.py index 400c74ddd971735f43bc6efc4e73e284062f8aaf..13648fddb71282f68f439d8ed13dcf690a7b4ba1 100644 --- a/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_presenter.py +++ b/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common.home_tab.home_tab_presenter import HomeTabSubWidget import Muon.GUI.Common.utilities.load_utils as load_utils from Muon.GUI.Common.utilities.muon_file_utils import filter_for_extensions diff --git a/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_view.py b/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_view.py index b7b615a36e1fe6860e087769b7f3f79aab64ee01..5b74561c51f3d48de382523459fa972a461910dd 100644 --- a/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_view.py +++ b/scripts/Muon/GUI/Common/home_instrument_widget/home_instrument_widget_view.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore, QtGui from qtpy.QtCore import Signal from Muon.GUI.Common.utilities.muon_file_utils import allowed_instruments, show_file_browser_and_return_selection diff --git a/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_model.py b/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_model.py index 0dd50b86715accd57bd4400f19ca145fc4aa2423..afc1abb0dc20da449374579e1112bdf08330bca2 100644 --- a/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_model.py +++ b/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - millions_counts_conversion = 1. / 1e6 diff --git a/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_presenter.py b/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_presenter.py index 4451aa7eaccc0976b8ef41dcfb0fdbe429dcc25a..7d0ecd97e8083c14dc6b006fd24ce44338b7e1a3 100644 --- a/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_presenter.py +++ b/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common.home_tab.home_tab_presenter import HomeTabSubWidget diff --git a/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_view.py b/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_view.py index 43f8c489532b0b2f6485e5133d51caaa470a8fad..ff4ab6176efda74e85d66107ec05a0b86c27f0f3 100644 --- a/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_view.py +++ b/scripts/Muon/GUI/Common/home_runinfo_widget/home_runinfo_widget_view.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from qtpy import QtWidgets, QtGui diff --git a/scripts/Muon/GUI/Common/home_tab/home_tab_model.py b/scripts/Muon/GUI/Common/home_tab/home_tab_model.py index dee45d9a45f439bf970414c13ecbead98ec9a556..8a0077f9b9842aa0ccb7187735d091f5108621e1 100644 --- a/scripts/Muon/GUI/Common/home_tab/home_tab_model.py +++ b/scripts/Muon/GUI/Common/home_tab/home_tab_model.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class HomeTabModel(object): diff --git a/scripts/Muon/GUI/Common/home_tab/home_tab_presenter.py b/scripts/Muon/GUI/Common/home_tab/home_tab_presenter.py index d308f9b881aef55ab97017a79f7af5fd72bc4843..a2dfb07bc58809570848efb28b433de7446297d6 100644 --- a/scripts/Muon/GUI/Common/home_tab/home_tab_presenter.py +++ b/scripts/Muon/GUI/Common/home_tab/home_tab_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta, abstractmethod from mantidqt.utils.observer_pattern import Observer, GenericObserver diff --git a/scripts/Muon/GUI/Common/home_tab/home_tab_view.py b/scripts/Muon/GUI/Common/home_tab/home_tab_view.py index ad7ac86e9240544ed869121360fad2a12b537032..6655e9d978d5fb01bbd50c32b24bbfdd36d20a49 100644 --- a/scripts/Muon/GUI/Common/home_tab/home_tab_view.py +++ b/scripts/Muon/GUI/Common/home_tab/home_tab_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets diff --git a/scripts/Muon/GUI/Common/home_tab/home_tab_widget.py b/scripts/Muon/GUI/Common/home_tab/home_tab_widget.py index 07611a002fe884060c1568f23fa8012359d83f95..232eefdadce7129628ff610a44b8778edac1ba33 100644 --- a/scripts/Muon/GUI/Common/home_tab/home_tab_widget.py +++ b/scripts/Muon/GUI/Common/home_tab/home_tab_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.home_instrument_widget.home_instrument_widget_model import InstrumentWidgetModel from Muon.GUI.Common.home_instrument_widget.home_instrument_widget_view import InstrumentWidgetView from Muon.GUI.Common.home_instrument_widget.home_instrument_widget_presenter import InstrumentWidgetPresenter diff --git a/scripts/Muon/GUI/Common/list_selector/TableWidgetDragRows.py b/scripts/Muon/GUI/Common/list_selector/TableWidgetDragRows.py index 3a89007294a3733f90c812ec13fb61429c5c0fcf..986903ad15188c4bc0557d222f7929e2ce2b079f 100644 --- a/scripts/Muon/GUI/Common/list_selector/TableWidgetDragRows.py +++ b/scripts/Muon/GUI/Common/list_selector/TableWidgetDragRows.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - # Original from https://stackoverflow.com/questions/26227885/drag-and-drop-rows-within-qtablewidget from qtpy.QtCore import Qt from qtpy.QtWidgets import QTableWidget, QAbstractItemView, QTableWidgetItem diff --git a/scripts/Muon/GUI/Common/list_selector/list_selector_presenter.py b/scripts/Muon/GUI/Common/list_selector/list_selector_presenter.py index be787b66978669851a853f8e0b2b701f10d70a78..eccb51613880708dfd9fb8d942765b9d4419e60b 100644 --- a/scripts/Muon/GUI/Common/list_selector/list_selector_presenter.py +++ b/scripts/Muon/GUI/Common/list_selector/list_selector_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - model_position = 0 model_selected = 1 model_enabled = 2 diff --git a/scripts/Muon/GUI/Common/list_selector/list_selector_view.py b/scripts/Muon/GUI/Common/list_selector/list_selector_view.py index f2aedd1f77e91fe9e84ef5e1f282f9311bfb85cc..8d22598f9ebb375b543558757ffe3ab2d68df3ae 100644 --- a/scripts/Muon/GUI/Common/list_selector/list_selector_view.py +++ b/scripts/Muon/GUI/Common/list_selector/list_selector_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from qtpy import QtWidgets import functools from qtpy.QtCore import Qt diff --git a/scripts/Muon/GUI/Common/load_file_widget/model.py b/scripts/Muon/GUI/Common/load_file_widget/model.py index cebf07735737d5cf2e758a0ec95fb432737dcebd..d051f1964c663473fe82c0faa8163480182adf70 100644 --- a/scripts/Muon/GUI/Common/load_file_widget/model.py +++ b/scripts/Muon/GUI/Common/load_file_widget/model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os from mantid.kernel import ConfigService from Muon.GUI.Common.muon_load_data import MuonLoadData diff --git a/scripts/Muon/GUI/Common/load_file_widget/presenter.py b/scripts/Muon/GUI/Common/load_file_widget/presenter.py index f6a9a90e139436f91dafd799bfe9bde51de5fddb..66ced7869836a5db76958530d65ad44589378b96 100644 --- a/scripts/Muon/GUI/Common/load_file_widget/presenter.py +++ b/scripts/Muon/GUI/Common/load_file_widget/presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import copy from Muon.GUI.Common import thread_model diff --git a/scripts/Muon/GUI/Common/load_file_widget/view.py b/scripts/Muon/GUI/Common/load_file_widget/view.py index 4f293d104b0d4d73af300650230e06c82006da47..7f077851276a893ef69da51bcaa977a2e7e69532 100644 --- a/scripts/Muon/GUI/Common/load_file_widget/view.py +++ b/scripts/Muon/GUI/Common/load_file_widget/view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets from qtpy.QtCore import Signal import Muon.GUI.Common.message_box as message_box diff --git a/scripts/Muon/GUI/Common/load_run_widget/load_run_model.py b/scripts/Muon/GUI/Common/load_run_widget/load_run_model.py index 9b81bbdcd3905b2a6f4d543a12a6434937fd97f9..05d3d2d0ab632dc5b53d2b673a5e56e61730763d 100644 --- a/scripts/Muon/GUI/Common/load_run_widget/load_run_model.py +++ b/scripts/Muon/GUI/Common/load_run_widget/load_run_model.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from Muon.GUI.Common.muon_load_data import MuonLoadData import Muon.GUI.Common.utilities.load_utils as load_utils diff --git a/scripts/Muon/GUI/Common/load_run_widget/load_run_presenter.py b/scripts/Muon/GUI/Common/load_run_widget/load_run_presenter.py index 566afd7a2bd4dd1f6617ba8f0fd5e0e1e566a530..c58a2a4c51a84d6f18e48420ca18feac654b1e8e 100644 --- a/scripts/Muon/GUI/Common/load_run_widget/load_run_presenter.py +++ b/scripts/Muon/GUI/Common/load_run_widget/load_run_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import copy from Muon.GUI.Common import thread_model diff --git a/scripts/Muon/GUI/Common/load_run_widget/load_run_view.py b/scripts/Muon/GUI/Common/load_run_widget/load_run_view.py index cf44de59d1b0be7c8d85e4445b0e459a6c3eff0c..9941407038af4e36c2f8786545da095acbe1e42a 100644 --- a/scripts/Muon/GUI/Common/load_run_widget/load_run_view.py +++ b/scripts/Muon/GUI/Common/load_run_widget/load_run_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore, QtGui from qtpy.QtCore import Signal diff --git a/scripts/Muon/GUI/Common/load_widget/load_presenter.py b/scripts/Muon/GUI/Common/load_widget/load_presenter.py index 5751995d4e24ba6c4982586b7acfdd77912d544a..1ddd040989e6283d18d9a24a566a472e2b4a8b53 100644 --- a/scripts/Muon/GUI/Common/load_widget/load_presenter.py +++ b/scripts/Muon/GUI/Common/load_widget/load_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from Muon.GUI.Common import thread_model import mantid.simpleapi as mantid diff --git a/scripts/Muon/GUI/Common/load_widget/load_view.py b/scripts/Muon/GUI/Common/load_widget/load_view.py index 282eb57c96c9a17b225bd60932508cb0b696d430..ff2720d2ba5fa1cfb4da5ffe95e94d33f5bdf5c3 100644 --- a/scripts/Muon/GUI/Common/load_widget/load_view.py +++ b/scripts/Muon/GUI/Common/load_widget/load_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import - from qtpy import QtWidgets, QtCore from mantidqt.widgets import manageuserdirectories diff --git a/scripts/Muon/GUI/Common/message_box.py b/scripts/Muon/GUI/Common/message_box.py index b01fb7cf781d093a1c8e592e447b5c120dd34587..90fa457229aaf07565302d7c4ec140b0a0f3c4a5 100644 --- a/scripts/Muon/GUI/Common/message_box.py +++ b/scripts/Muon/GUI/Common/message_box.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from qtpy import QtWidgets diff --git a/scripts/Muon/GUI/Common/muon_context/muon_context.py b/scripts/Muon/GUI/Common/muon_context/muon_context.py index c566385c9674786375d0f7cb530a9badfd417d20..2ef3066e20138ae10d083d7fac00014b3612d6a1 100644 --- a/scripts/Muon/GUI/Common/muon_context/muon_context.py +++ b/scripts/Muon/GUI/Common/muon_context/muon_context.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # Muon context - contains all of the values from the GUI -from __future__ import (absolute_import, division, print_function) from collections import OrderedDict import copy diff --git a/scripts/Muon/GUI/Common/muon_group.py b/scripts/Muon/GUI/Common/muon_group.py index 24b1420ba3eef396a60b171505a9738223bf797e..16e9550f58a4c8bcaf511d17503e0341306c580e 100644 --- a/scripts/Muon/GUI/Common/muon_group.py +++ b/scripts/Muon/GUI/Common/muon_group.py @@ -5,10 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=C0111 -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common.ADSHandler.muon_workspace_wrapper import MuonWorkspaceWrapper -import six class MuonGroup(object): @@ -65,7 +62,7 @@ class MuonGroup(object): @detectors.setter def detectors(self, detector_ids): - if isinstance(detector_ids, six.string_types): + if isinstance(detector_ids, str): raise AttributeError("MuonGroup : detectors must be a list of ints.") elif isinstance(detector_ids, list): if sum([not isinstance(item, int) for item in detector_ids]) == 0: diff --git a/scripts/Muon/GUI/Common/muon_load_data.py b/scripts/Muon/GUI/Common/muon_load_data.py index aac1de09232316f127e030cbaa511a02b3f66a36..e8827e54ae07dd68fbe8cf4dd371c835287c5eef 100644 --- a/scripts/Muon/GUI/Common/muon_load_data.py +++ b/scripts/Muon/GUI/Common/muon_load_data.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import Muon.GUI.Common.utilities.load_utils as load_utils diff --git a/scripts/Muon/GUI/Common/muon_pair.py b/scripts/Muon/GUI/Common/muon_pair.py index 71515fb83503067d7a6f1410eb0330e236ffdf94..105d3fee4e6c5b65dfdef92ed37176c5aae9f7b2 100644 --- a/scripts/Muon/GUI/Common/muon_pair.py +++ b/scripts/Muon/GUI/Common/muon_pair.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=C0111 -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common.ADSHandler.muon_workspace_wrapper import MuonWorkspaceWrapper diff --git a/scripts/Muon/GUI/Common/pair_object.py b/scripts/Muon/GUI/Common/pair_object.py index 11323244d35b50a09d8fd4e0c739d515cea5ac0c..650520e62779d1a249e583cc2c9c2c5504a7c990 100644 --- a/scripts/Muon/GUI/Common/pair_object.py +++ b/scripts/Muon/GUI/Common/pair_object.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - - import pythonTSV as TSVHelper diff --git a/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_presenter.py b/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_presenter.py index 006f65bfc21640a9e8bed9635c89c745c3c75aee..de27f300b4095d2fe548b4e498c3822050b410d1 100644 --- a/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_presenter.py +++ b/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import re from Muon.GUI.Common.muon_pair import MuonPair diff --git a/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_view.py b/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_view.py index 62e61abe31065d73ae1df29b3147040e1ebae6a1..b1c17e31f63ced5045067d91fd6596d1f82a2f23 100644 --- a/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_view.py +++ b/scripts/Muon/GUI/Common/pairing_table_widget/pairing_table_widget_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore, QtGui from qtpy.QtCore import Signal diff --git a/scripts/Muon/GUI/Common/phase_table_widget/phase_table_presenter.py b/scripts/Muon/GUI/Common/phase_table_widget/phase_table_presenter.py index 00ee926d0f70ecc8d8acf092ae0d0d4584cea64f..9c3d550364b77366f6ee13c51871c670358e295b 100644 --- a/scripts/Muon/GUI/Common/phase_table_widget/phase_table_presenter.py +++ b/scripts/Muon/GUI/Common/phase_table_widget/phase_table_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.thread_model_wrapper import ThreadModelWrapper from Muon.GUI.Common import thread_model from Muon.GUI.Common.utilities.algorithm_utils import run_CalMuonDetectorPhases, run_PhaseQuad diff --git a/scripts/Muon/GUI/Common/phase_table_widget/phase_table_view.py b/scripts/Muon/GUI/Common/phase_table_widget/phase_table_view.py index 05ea07c4c5b7436564b5a4181e06668ceb0a4c6e..b6f9dc8b2211f3f753bf4d671d0ef854641c4540 100644 --- a/scripts/Muon/GUI/Common/phase_table_widget/phase_table_view.py +++ b/scripts/Muon/GUI/Common/phase_table_widget/phase_table_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from Muon.GUI.Common.utilities import table_utils from Muon.GUI.Common.message_box import warning diff --git a/scripts/Muon/GUI/Common/phase_table_widget/phase_table_widget.py b/scripts/Muon/GUI/Common/phase_table_widget/phase_table_widget.py index 10978081fd49078d090c1a94c4173602f6c2f580..16088612277c2902647ddd60e8de5953b74bc92f 100644 --- a/scripts/Muon/GUI/Common/phase_table_widget/phase_table_widget.py +++ b/scripts/Muon/GUI/Common/phase_table_widget/phase_table_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.phase_table_widget.phase_table_view import PhaseTableView from Muon.GUI.Common.phase_table_widget.phase_table_presenter import PhaseTablePresenter diff --git a/scripts/Muon/GUI/Common/plotting_widget/dockable_plot_toolbar.py b/scripts/Muon/GUI/Common/plotting_widget/dockable_plot_toolbar.py index 2aeea10c3f9f42569940395f5c96bde1b5ace74a..02c47ed8e07c56381202e3b5406ec2fb155effeb 100644 --- a/scripts/Muon/GUI/Common/plotting_widget/dockable_plot_toolbar.py +++ b/scripts/Muon/GUI/Common/plotting_widget/dockable_plot_toolbar.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from matplotlib.backends.qt_compat import is_pyqt5 if is_pyqt5(): diff --git a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget.py b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget.py index 073ac51c26f4ce1825a4cb32c04db21d21d1bc64..9e9094e07b69906f65066539f065ec7ce2370950 100644 --- a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget.py +++ b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.plotting_widget.plotting_widget_view import PlotWidgetView from Muon.GUI.Common.plotting_widget.plotting_widget_presenter import PlotWidgetPresenter from Muon.GUI.Common.plotting_widget.plotting_widget_model import PlotWidgetModel diff --git a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_model.py b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_model.py index 770884a83e8b8db74946f477ad93e723c0397d61..1b4dde5dce7b260721d4fb229ab7e9325eba57d8 100644 --- a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_model.py +++ b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_model.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from mantid.api import AnalysisDataService diff --git a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_presenter.py b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_presenter.py index 65031995bf71a2da6081f9d720b9453b07ca461c..aa663d1ee88d4e5dcfaf157071d6bf8ae41f026e 100644 --- a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_presenter.py +++ b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import re from Muon.GUI.Common.home_tab.home_tab_presenter import HomeTabSubWidget from mantidqt.utils.observer_pattern import GenericObservable, GenericObserver, GenericObserverWithArgPassing diff --git a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_view.py b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_view.py index 03fa2ad3815140207923108c9cb240201e9d227b..410309654b9d9d43bd26b44f3d89eaba9ae451b3 100644 --- a/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_view.py +++ b/scripts/Muon/GUI/Common/plotting_widget/plotting_widget_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets import Muon.GUI.Common.message_box as message_box from Muon.GUI.Common.plotting_widget.dockable_plot_toolbar import DockablePlotToolbar diff --git a/scripts/Muon/GUI/Common/plotting_widget/workspace_finder.py b/scripts/Muon/GUI/Common/plotting_widget/workspace_finder.py index 485a53bde8b38b28068e25fae28cf0291397ea7f..33c3473309be168617d23848bfed66e4aab2be5e 100644 --- a/scripts/Muon/GUI/Common/plotting_widget/workspace_finder.py +++ b/scripts/Muon/GUI/Common/plotting_widget/workspace_finder.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - COUNTS_PLOT_TYPE = 'Counts' ASYMMETRY_PLOT_TYPE = 'Asymmetry' FREQ_PLOT_TYPE = "Frequency " diff --git a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_model.py b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_model.py index 7e6fc7f1197316e819300d4c7e80481661ad872e..22072ddb64381f1c291f13fe61e37f46281e2892 100644 --- a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_model.py +++ b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_model.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, division, unicode_literals) - from mantid.api import AnalysisDataService as ads, WorkspaceFactory from mantid.kernel import FloatTimeSeriesProperty from enum import Enum diff --git a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_presenter.py b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_presenter.py index dd7ae93f21a852e31b3c634b11cde1adc1d323d3..26c88062aac4848603074fe44567a69466a704e8 100644 --- a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_presenter.py +++ b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division) - from qtpy.QtCore import QMetaObject, QObject, Slot from mantidqt.utils.observer_pattern import GenericObserver diff --git a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_view.py b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_view.py index 608fb37c9fc65126d8f4aa68a14bc599c30e6768..8695fc9084c4e37ff97592c194e7511ecd77d387 100644 --- a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_view.py +++ b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantidqt.utils.qt import load_ui from qtpy import PYQT4, QtCore, QtWidgets diff --git a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_widget.py b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_widget.py index 903b3c245af9697af253db260d0fa5882ecadc39..145b60d1aa18a292eb5cb81a4f41a1ecf31bf58e 100644 --- a/scripts/Muon/GUI/Common/results_tab_widget/results_tab_widget.py +++ b/scripts/Muon/GUI/Common/results_tab_widget/results_tab_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division) - from Muon.GUI.Common.results_tab_widget.results_tab_presenter import ResultsTabPresenter from Muon.GUI.Common.results_tab_widget.results_tab_view import ResultsTabView from Muon.GUI.Common.results_tab_widget.results_tab_model import ResultsTabModel diff --git a/scripts/Muon/GUI/Common/run_selection_dialog.py b/scripts/Muon/GUI/Common/run_selection_dialog.py index 14b692e88c0b1fc37277aa1952b9d18563a77f2b..b8b8499e42d798e8905fd1240a72c571d86d66e2 100644 --- a/scripts/Muon/GUI/Common/run_selection_dialog.py +++ b/scripts/Muon/GUI/Common/run_selection_dialog.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - - from qtpy import QtWidgets, QtCore diff --git a/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_presenter.py b/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_presenter.py index 851aa58f3aab516aef191999198e19c3f8033c70..3b7280618a24c53d8811dcde286db3b0c802919f 100644 --- a/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_presenter.py +++ b/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) from mantidqt.utils.observer_pattern import GenericObserver, GenericObserverWithArgPassing from Muon.GUI.Common.thread_model_wrapper import ThreadModelWrapperWithOutput from Muon.GUI.Common import thread_model diff --git a/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_view.py b/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_view.py index f7f3849ec43463ae0f55b37d3af04b6007f83309..12a19c08967b4b98813c5207739c9d4040616c79 100644 --- a/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_view.py +++ b/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore, QtGui from mantidqt.utils.qt import load_ui from Muon.GUI.Common.message_box import warning diff --git a/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_widget.py b/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_widget.py index 92609bd2b2c68946b0b214c8cbf7325fdc2dba4e..089b6a73c7689b00bfec1a8738404fba9854f31c 100644 --- a/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_widget.py +++ b/scripts/Muon/GUI/Common/seq_fitting_tab_widget/seq_fitting_tab_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.seq_fitting_tab_widget.seq_fitting_tab_view import SeqFittingTabView from Muon.GUI.Common.seq_fitting_tab_widget.seq_fitting_tab_presenter import SeqFittingTabPresenter diff --git a/scripts/Muon/GUI/Common/test_helpers/context_setup.py b/scripts/Muon/GUI/Common/test_helpers/context_setup.py index a5c19ce2864e77e79b80639b715c3795d5a968d0..97b19930917180442b2c528aedfd8d66c227f2e4 100644 --- a/scripts/Muon/GUI/Common/test_helpers/context_setup.py +++ b/scripts/Muon/GUI/Common/test_helpers/context_setup.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.contexts.muon_context import MuonContext from Muon.GUI.Common.contexts.muon_data_context import MuonDataContext from Muon.GUI.Common.contexts.muon_group_pair_context import MuonGroupPairContext @@ -14,7 +12,7 @@ from Muon.GUI.Common.muon_load_data import MuonLoadData from Muon.GUI.Common.contexts.phase_table_context import PhaseTableContext from Muon.GUI.Common.contexts.fitting_context import FittingContext from Muon.GUI.FrequencyDomainAnalysis.frequency_context import FrequencyContext -from mantid.py3compat import mock +from unittest import mock def setup_context_for_tests(parent_object): diff --git a/scripts/Muon/GUI/Common/test_helpers/general_test_helpers.py b/scripts/Muon/GUI/Common/test_helpers/general_test_helpers.py index 683a9fe972db491936c77b51083af8a4fb62a746..31bc8b873a1c4bd8b7c6ad71aa10e8efca17d89a 100644 --- a/scripts/Muon/GUI/Common/test_helpers/general_test_helpers.py +++ b/scripts/Muon/GUI/Common/test_helpers/general_test_helpers.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from mantid.simpleapi import CreateWorkspace from Muon.GUI.Common.ADSHandler.muon_workspace_wrapper import MuonWorkspaceWrapper from Muon.GUI.Common.muon_group import MuonGroup diff --git a/scripts/Muon/GUI/Common/thread_model.py b/scripts/Muon/GUI/Common/thread_model.py index 15d18ca62c4d8a4ffe12142c922676a5de321fa8..8d40dfcc3ee910193005c227ad36e295ab35730c 100644 --- a/scripts/Muon/GUI/Common/thread_model.py +++ b/scripts/Muon/GUI/Common/thread_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from qtpy.QtCore import Signal from qtpy.QtCore import Slot diff --git a/scripts/Muon/GUI/Common/thread_model_wrapper.py b/scripts/Muon/GUI/Common/thread_model_wrapper.py index f8380287286fd8e479877e3b04bdf920d43ead07..32f05968945ed1c4b24879f9dc705ab6fac89f01 100644 --- a/scripts/Muon/GUI/Common/thread_model_wrapper.py +++ b/scripts/Muon/GUI/Common/thread_model_wrapper.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) class ThreadModelWrapper(object): diff --git a/scripts/Muon/GUI/Common/usage_report.py b/scripts/Muon/GUI/Common/usage_report.py index a509ccf717550f3bdd7d2c5886e6b3bdd284df12..a360df9f665cfbbb605519da3dec0480b9567090 100644 --- a/scripts/Muon/GUI/Common/usage_report.py +++ b/scripts/Muon/GUI/Common/usage_report.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from mantid.kernel import (UsageService, FeatureType) diff --git a/scripts/Muon/GUI/Common/utilities/algorithm_utils.py b/scripts/Muon/GUI/Common/utilities/algorithm_utils.py index cdfb512fe4e2dc531e4a4a9424067775d114e85b..652b39f6173529e93b6852e105e7bd9702ea29d2 100644 --- a/scripts/Muon/GUI/Common/utilities/algorithm_utils.py +++ b/scripts/Muon/GUI/Common/utilities/algorithm_utils.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid from mantid.kernel import Logger diff --git a/scripts/Muon/GUI/Common/utilities/load_utils.py b/scripts/Muon/GUI/Common/utilities/load_utils.py index 59280fef37ad0669a27c6196be856c4156183a8e..9d8216d2598b52935ff4335ee6ddcbde261b2d34 100644 --- a/scripts/Muon/GUI/Common/utilities/load_utils.py +++ b/scripts/Muon/GUI/Common/utilities/load_utils.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import mantid.simpleapi as mantid from mantid.api import WorkspaceGroup, AnalysisDataService diff --git a/scripts/Muon/GUI/Common/utilities/muon_file_utils.py b/scripts/Muon/GUI/Common/utilities/muon_file_utils.py index e10ba9f33cd925985acf8b4f4741d8ac378d4f73..44885d274558fb6757d36484f06642fa3875d03c 100644 --- a/scripts/Muon/GUI/Common/utilities/muon_file_utils.py +++ b/scripts/Muon/GUI/Common/utilities/muon_file_utils.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os from mantid.api import FileFinder from Muon.GUI.Common.message_box import warning diff --git a/scripts/Muon/GUI/Common/utilities/muon_test_helpers.py b/scripts/Muon/GUI/Common/utilities/muon_test_helpers.py index 8590b67fb65aa4113d14bb418e917c99766a3593..20eaf29fd7a628b9322dd4cc926b094cd5c289eb 100644 --- a/scripts/Muon/GUI/Common/utilities/muon_test_helpers.py +++ b/scripts/Muon/GUI/Common/utilities/muon_test_helpers.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) class IteratorWithException: diff --git a/scripts/Muon/GUI/Common/utilities/run_string_utils.py b/scripts/Muon/GUI/Common/utilities/run_string_utils.py index 1c57e9189205570ac62c1676437ad9ce6204130f..b4fb1810acf7868e4343d6e14b988b122258e99b 100644 --- a/scripts/Muon/GUI/Common/utilities/run_string_utils.py +++ b/scripts/Muon/GUI/Common/utilities/run_string_utils.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from itertools import groupby from operator import itemgetter import functools diff --git a/scripts/Muon/GUI/Common/utilities/table_utils.py b/scripts/Muon/GUI/Common/utilities/table_utils.py index 78a342160f41bd14a9b4e10ee7eb3ef176bc8cc7..8204cd5899fdc7c210280301302b36fc06fc9046 100644 --- a/scripts/Muon/GUI/Common/utilities/table_utils.py +++ b/scripts/Muon/GUI/Common/utilities/table_utils.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os from functools import wraps import sys diff --git a/scripts/Muon/GUI/Common/utilities/xml_utils.py b/scripts/Muon/GUI/Common/utilities/xml_utils.py index 42eebfec8a6d9433a3acefe9841f3f92c7cc30f4..bf45aa46fdf0c21be1b9f2b680dba7d2d5dd1975 100644 --- a/scripts/Muon/GUI/Common/utilities/xml_utils.py +++ b/scripts/Muon/GUI/Common/utilities/xml_utils.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import xml.etree.ElementTree as ET import Muon.GUI.Common.utilities.run_string_utils as run_string_utils diff --git a/scripts/Muon/GUI/Common/validate_errors.py b/scripts/Muon/GUI/Common/validate_errors.py index f68fd4695c206bbb903fa7d2626806e19ebc4124..5a00b93fdbc6b32ea1f86c5e79ae83583600b6e3 100644 --- a/scripts/Muon/GUI/Common/validate_errors.py +++ b/scripts/Muon/GUI/Common/validate_errors.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) def validateToErrors(alg): diff --git a/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_presenter.py b/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_presenter.py index b2f17882df804fae272ce8c5ad515f06e7b2e523..b510c34f3e60dd7130c4901ebac6d38fc22021cb 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_presenter.py +++ b/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) class DetectorsPresenter(object): diff --git a/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_view.py b/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_view.py index 75ed5cfec54855f791de4e612372366256036ab8..acba523e33dec1de18927226b81402bf114adb26 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_view.py +++ b/scripts/Muon/GUI/ElementalAnalysis/Detectors/detectors_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from qtpy import QtWidgets from collections import OrderedDict diff --git a/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorPresenter.py b/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorPresenter.py index 22dadf60380986c1a972edb46f46fa358c3d4c4a..24185597f7c994e61f2fcc9a2498c3913cc86e2f 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorPresenter.py +++ b/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorPresenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) class LineSelectorPresenter(object): diff --git a/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorView.py b/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorView.py index 6eb808d4411382a51d5ba9d4554f8ff3b861488a..cdec801ae32d6032e3aadc3c1796464a9a9534b4 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorView.py +++ b/scripts/Muon/GUI/ElementalAnalysis/LineSelector/LineSelectorView.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from qtpy import QtWidgets from Muon.GUI.Common.checkbox import Checkbox diff --git a/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_model.py b/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_model.py index 8f215fe2bcc334ba4eaed98cd4981e85514559eb..0cb5b64c7a89c565304185bd9eb0ce66c118e029 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_model.py +++ b/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function - import mantid.simpleapi as mantid from Muon.GUI.ElementalAnalysis.LoadWidget import load_utils as lutils diff --git a/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_utils.py b/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_utils.py index accef1154dedc791c0450ae7f03a4e60c4d42b55..034f41ef85bdcd6911faa158be40af0c13836ae2 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_utils.py +++ b/scripts/Muon/GUI/ElementalAnalysis/LoadWidget/load_utils.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) from collections import OrderedDict import glob import os import numpy as np -from six import iteritems from mantid import config import mantid.simpleapi as mantid @@ -28,7 +26,7 @@ class LModel(object): def _load(self, inputs): """ inputs is a dict mapping filepaths to output names """ - for path, output in iteritems(inputs): + for path, output in inputs.items(): workspace = mantid.LoadAscii(path, OutputWorkspace=output) workspace.getAxis(0).setUnit("Label").setLabel("Energy", "keV") @@ -41,7 +39,7 @@ class LModel(object): for filename in to_load if get_filename(filename, self.run) is not None } unique_workspaces = {} - for path, workspace in iteritems(workspaces): + for path, workspace in workspaces.items(): if workspace not in unique_workspaces.values(): unique_workspaces[path] = workspace workspaces = unique_workspaces @@ -99,7 +97,7 @@ def merge_workspaces(run, workspaces): tmp = mantid.CreateSampleWorkspace() overall_ws = mantid.GroupWorkspaces(tmp, OutputWorkspace=str(run)) # merge each workspace list in detectors into a single workspace - for detector, workspace_list in iteritems(detectors): + for detector, workspace_list in detectors.items(): if workspace_list: # sort workspace list according to type_index sorted_workspace_list = [None] * num_files_per_detector diff --git a/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_presenter.py b/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_presenter.py index e12e1cf5c6ad7784d89f5ff57d69b47b4c35854c..e46b38ca45ff7fedc6d97c6e1fe6ab7208a4c4dc 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_presenter.py +++ b/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) class PeaksPresenter(object): diff --git a/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_view.py b/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_view.py index 443d5b67949681b7cf4b477dcc5f5d5c9582e6cb..97c4c28162a1abdc29d9a2d682624ffcbe50e54d 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_view.py +++ b/scripts/Muon/GUI/ElementalAnalysis/Peaks/peaks_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from qtpy import QtWidgets from Muon.GUI.Common.checkbox import Checkbox diff --git a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_presenter.py b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_presenter.py index 6649710971f25aad8543f282ee3ba85dc429065b..4fadfb61a88bdd8908eae314ec33099561c6389d 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_presenter.py +++ b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) class PeakSelectorPresenter(object): diff --git a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py index 13d8c6f85d0639b2753c199bf172077bc3da1337..e9de4acf4dd5e7d39f90f6b3e93ec1d99165d644 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py +++ b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/PeakSelector/peak_selector_view.py @@ -4,10 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) from qtpy import QtWidgets, QtCore -from six import iteritems import numpy as np from Muon.GUI.Common.checkbox import Checkbox @@ -120,7 +118,7 @@ class PeakSelectorView(QtWidgets.QListWidget): return self.new_data def update_new_data(self, data): - for el, values in iteritems(data): + for el, values in data.items(): if values is None: data[el] = {} new_data = data["Primary"].copy() @@ -139,7 +137,7 @@ class PeakSelectorView(QtWidgets.QListWidget): _heading = QtWidgets.QLabel(heading) self.list.addWidget(_heading) checkboxes = [] - for peak_type, value in iteritems(checkbox_data): + for peak_type, value in checkbox_data.items(): checkboxes.append(self._setup_checkbox("{}: {}".format(peak_type, value), checked)) return checkboxes diff --git a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_model.py b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_model.py index 0471c74ce6e5755a44223cf4e6ce9bef8e933261..2c6fa7fb9291cfd962cf37ef7d7044555906af4f 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_model.py +++ b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - import os import json diff --git a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_presenter.py b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_presenter.py index 545afb722172a2e78cabb462ffeb4b5ef85bf6bd..9b64a8fefa19f093103dbe2a09373f127893c7ac 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_presenter.py +++ b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function - from Muon.GUI.Common import message_box diff --git a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_view.py b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_view.py index cd9aa7647a79cc81555dfc8f7e2c4e70ff6c0510..3601dc9ab2d64a1d8e742c930c49ce787d84eb7f 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_view.py +++ b/scripts/Muon/GUI/ElementalAnalysis/PeriodicTable/periodic_table_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import - from qtpy import QtWidgets from Muon.GUI.ElementalAnalysis.PeriodicTable import periodic_table diff --git a/scripts/Muon/GUI/ElementalAnalysis/elemental_analysis.py b/scripts/Muon/GUI/ElementalAnalysis/elemental_analysis.py index 5bf351f00ed767ff263262902807e65d0f2fee45..e10142e3e4d1cc8e696f24e15bbb48b3f8d774a4 100644 --- a/scripts/Muon/GUI/ElementalAnalysis/elemental_analysis.py +++ b/scripts/Muon/GUI/ElementalAnalysis/elemental_analysis.py @@ -4,12 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from qtpy import QtWidgets from copy import deepcopy import matplotlib as mpl -from six import iteritems from Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table_presenter import PeriodicTablePresenter from Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table_view import PeriodicTableView @@ -234,7 +231,7 @@ class ElementalAnalysisGui(QtWidgets.QMainWindow): # Select a different color, if all used then use the first color = self.get_color(element) - for name, x_value in iteritems(data): + for name, x_value in data.items(): try: x_value = float(x_value) except ValueError: @@ -338,7 +335,7 @@ class ElementalAnalysisGui(QtWidgets.QMainWindow): if data is None: data = self.element_widgets[element].get_checked() color = self.get_color(element) - for name, x_value in iteritems(data): + for name, x_value in data.items(): if isinstance(x_value, float): full_name = gen_name(element, name) label = self._gen_label(full_name, x_value, element) @@ -416,19 +413,19 @@ class ElementalAnalysisGui(QtWidgets.QMainWindow): self._update_peak_data(element) def electrons_changed(self, electron_peaks): - for element, selector in iteritems(self.element_widgets): + for element, selector in self.element_widgets.items(): self.checked_data(element, selector.electron_checkboxes, electron_peaks.isChecked()) def gammas_changed(self, gamma_peaks): - for element, selector in iteritems(self.element_widgets): + for element, selector in self.element_widgets.items(): self.checked_data(element, selector.gamma_checkboxes, gamma_peaks.isChecked()) def major_peaks_changed(self, major_peaks): - for element, selector in iteritems(self.element_widgets): + for element, selector in self.element_widgets.items(): self.checked_data(element, selector.primary_checkboxes, major_peaks.isChecked()) def minor_peaks_changed(self, minor_peaks): - for element, selector in iteritems(self.element_widgets): + for element, selector in self.element_widgets.items(): self.checked_data(element, selector.secondary_checkboxes, minor_peaks.isChecked()) def add_line_by_type(self, run, _type): diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_model.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_model.py index bad67e3c44ae364026f3f105c33c35c01f95c7a9..39c214d2259fdf19b0097a6079d157823c38e8ed 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_model.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_model.py @@ -4,10 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -from six import iteritems - import mantid.simpleapi as mantid @@ -98,7 +94,7 @@ class FFTModel(object): self.alg.initialize() self.alg.setRethrows(True) - for name, value in iteritems(preInputs): + for name, value in preInputs.items(): self.alg.setProperty(name, value) self.alg.execute() self.alg = None @@ -111,7 +107,7 @@ class FFTModel(object): self.alg.initialize() self.alg.setRethrows(True) - for name, value in iteritems(FFTInputs): + for name, value in FFTInputs.items(): self.alg.setProperty(name, value) self.alg.execute() diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter.py index a68735c1603905b8656686eea8e50c6ff597acb3..3fcfe7b3cca034f0e480a2c5d789712500ed7ac7 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - import mantid.simpleapi as mantid from Muon.GUI.Common import thread_model diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter_new.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter_new.py index 164257639d1c89a9c544a52788409a0391da19d8..847e611430e045d7fe3bf4dff382df4389ae9933 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter_new.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_presenter_new.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import mantid.simpleapi as mantid from Muon.GUI.Common import thread_model diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view.py index e58e83f59e6c42b6fa5ddf4813491f9c360ffd92..1adc87d638a99c1c20d11b720bd582e81f2144af 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore import mantid.simpleapi as mantid diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view_new.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view_new.py index dcd9ccc953b8336c166da43bc7a23dfe2dd6ac0a..ef2163aac8d9a1a7c8d7dfe61ca846e5c1110c78 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view_new.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_view_new.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from Muon.GUI.Common.utilities import table_utils diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget.py index dd3247b9a4a86f4c0b8fc32278fbd0b4359f9a62..12db1e90b1f79362003ea7618850879ba4b02846 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.FrequencyDomainAnalysis.FFT.fft_view import FFTView from Muon.GUI.FrequencyDomainAnalysis.FFT.fft_presenter import FFTPresenter from Muon.GUI.FrequencyDomainAnalysis.FFT.fft_model import FFTModel, FFTWrapper diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget_new.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget_new.py index 4e299e066f3ffc3063026a7a7b369b86c0e6157f..daebfdbffb32a1f4900cb107dce72ec86dcce0a9 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget_new.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/FFT/fft_widget_new.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.FrequencyDomainAnalysis.FFT.fft_view_new import FFTView from Muon.GUI.FrequencyDomainAnalysis.FFT.fft_presenter_new import FFTPresenter from Muon.GUI.FrequencyDomainAnalysis.FFT.fft_model import FFTModel, FFTWrapper diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_model.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_model.py index ffc8475b28cf876c626cac091344e04c564c5fb7..3a379386822f8827a190613857679fecb043c220 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_model.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_model.py @@ -4,10 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -from six import iteritems - import mantid.simpleapi as mantid from Muon.GUI.Common.validate_errors import validateToErrors @@ -71,7 +67,7 @@ class MaxEntModel(object): self.alg = mantid.AlgorithmManager.create("MuonMaxent") self.alg.initialize() self.alg.setAlwaysStoreInADS(False) - for name, value in iteritems(inputs): + for name, value in inputs.items(): self.alg.setProperty(name, value) self.alg.setRethrows(True) validateToErrors(self.alg) @@ -92,7 +88,7 @@ class MaxEntModel(object): self.alg.setAlwaysStoreInADS(False) self.alg.setRethrows(True) - for name, value in iteritems(inputs): + for name, value in inputs.items(): self.alg.setProperty(name, value) # check for version 1 if inputs["InputWorkspace"] != "MuonAnalysis" and "MuonAnalysisGrouped" in inputs["InputWorkspace"]: diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py index 01ddb16a71bcc9fc826c9b11343d4d928511ba0a..8ccf6b5698f45fc3a0cafd795329b07c8356552f 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - - import math from Muon.GUI.Common import thread_model import mantid.simpleapi as mantid diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter_new.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter_new.py index 40dc119eb90dd64431063231259bf2f159d79c75..d70a7004fb437dd3dca8c3b40fec1966db74ac37 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter_new.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_presenter_new.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import functools import math import re diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view.py index ef25f6be5719a2437cd564651573c5a4adb42793..4788ba04130f37fb13a9f4b337ccb7a1136c8ea1 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from Muon.GUI.Common.utilities import table_utils diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view_new.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view_new.py index 45026d915d9884c60f158a10d02013327c76f7bd..2c184051252fa0c6c9e89d1d3599619ad9e02ce4 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view_new.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_view_new.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore from Muon.GUI.Common.utilities import table_utils diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget.py index d5f24f57c6ba108a6bf662259312ff16caeec4fb..68170ab34b0fb0891b08a783fd4cb5d27a4cafa4 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.FrequencyDomainAnalysis.MaxEnt.maxent_view import MaxEntView from Muon.GUI.FrequencyDomainAnalysis.MaxEnt.maxent_presenter import MaxEntPresenter from Muon.GUI.FrequencyDomainAnalysis.MaxEnt.maxent_model import MaxEntModel, MaxEntWrapper diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget_new.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget_new.py index ffeb78509453643f93c26472e0dfdbc2907421ad..bad67eb534f8fe598bf1aa525f230bf39b9ab3c4 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget_new.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/MaxEnt/maxent_widget_new.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.FrequencyDomainAnalysis.MaxEnt.maxent_view_new import MaxEntView from Muon.GUI.FrequencyDomainAnalysis.MaxEnt.maxent_presenter_new import MaxEntPresenter diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_view.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_view.py index a25d2b23f0929ed698d26e588e792eb316b6e35c..66d4f3dc9af0d7f5383ed2007321c45b71134e4e 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_view.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_widget.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_widget.py index 6abbe3c247d694e7d2699349a38fbd0173635be9..a7f467fd449a962a46cbb2de867fb9a5707dd2bd 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_widget.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/Transform/transform_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.FrequencyDomainAnalysis.Transform.transform_view import TransformView from Muon.GUI.FrequencyDomainAnalysis.TransformSelection.transform_selection_widget import TransformSelectionWidget diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_presenter.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_presenter.py index 4948750038327f7a1cbf1b4c98eadd5623c9eb28..85acf76df967c091da049ddf91970bc297f6e303 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_presenter.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_presenter.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) class TransformSelectionPresenter(object): diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_view.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_view.py index a3435824ea5d2ed45a00e4985e7f890ee79fd0ff..d26ead698df7d845a4570df491179211fdd5e42b 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_view.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_widget.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_widget.py index 39485ee0482985d7c3cb23aac1657898b536734b..396c1c02f15127a5cb067f23650fcfdd5074fe15 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_widget.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/TransformSelection/transform_selection_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.FrequencyDomainAnalysis.TransformSelection.transform_selection_view import TransformSelectionView from Muon.GUI.FrequencyDomainAnalysis.TransformSelection.transform_selection_presenter import TransformSelectionPresenter diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_context.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_context.py index 0b6c02295cfcbe989db07da7c4ec5c2c6f602abc..3606f22a112142b379ebf6b52d7fee9a7ec05f89 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_context.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_context.py @@ -4,9 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from re import findall -from six import iteritems from mantid import AnalysisDataService @@ -74,13 +72,13 @@ class FrequencyContext(object): def get_frequency_workspace_names(self, run_list, group, pair, phasequad, frequency_type): # do MaxEnt first as it only has run number names = [] - for name, maxEnt in iteritems(self._maxEnt_freq): + for name, maxEnt in self._maxEnt_freq.items(): for runs in run_list: for run in runs: if int(run) == int(maxEnt.run): names.append(name) # do FFT - for name, fft in iteritems(self._FFT_freq): + for name, fft in self._FFT_freq.items(): for runs in run_list: for run in runs: # check Re part diff --git a/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_domain_analysis_2.py b/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_domain_analysis_2.py index e7c8ed9ccce53590166d3741b8752f3812d1ff86..a3c9861ff2577df0f60ff35a7f09dda11a7d0963 100644 --- a/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_domain_analysis_2.py +++ b/scripts/Muon/GUI/FrequencyDomainAnalysis/frequency_domain_analysis_2.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore, QT_VERSION from distutils.version import LooseVersion diff --git a/scripts/Muon/GUI/MuonAnalysis/dock/dock_widget.py b/scripts/Muon/GUI/MuonAnalysis/dock/dock_widget.py index 2bd5be10d7dff72018a1d191e6f0605ba04f018e..0b48320623145437f609eed790e8c0a436104937 100644 --- a/scripts/Muon/GUI/MuonAnalysis/dock/dock_widget.py +++ b/scripts/Muon/GUI/MuonAnalysis/dock/dock_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets from Muon.GUI.Common.context_example.context_example_widget import ContextExampleWidget diff --git a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget.py b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget.py index 590ca2e068a3f670a194c52b3e757c84997cfd99..8d9791d241e231e1efe60b9b38bb88d8dfb56762 100644 --- a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget.py +++ b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - from Muon.GUI.Common.load_file_widget.model import BrowseFileWidgetModel from Muon.GUI.Common.load_file_widget.view import BrowseFileWidgetView from Muon.GUI.Common.load_file_widget.presenter import BrowseFileWidgetPresenter diff --git a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_model.py b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_model.py index 15c91234d0bab0d589726bd7ab67a66b85f1d16e..4834d23b18f53fc2049e883f66e9f46ffcf86c17 100644 --- a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_model.py +++ b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_model.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from Muon.GUI.Common.muon_load_data import MuonLoadData diff --git a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_presenter.py b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_presenter.py index 99d8ab433d82ca7e4d7830c3d777f10ba798f92b..e15d4e70cc084bc0bea10b6f91d3d75ef5c72f03 100644 --- a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_presenter.py +++ b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantidqt.utils.observer_pattern import Observer, Observable, GenericObserver CO_ADD = 'Co-Add' diff --git a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_view.py b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_view.py index 2c02af93187773d30c7f85e2c4ee7e453e8673b8..4f9c5e24f44fd5c8116c29087b35bee8e7f46f06 100644 --- a/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_view.py +++ b/scripts/Muon/GUI/MuonAnalysis/load_widget/load_widget_view.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets diff --git a/scripts/Muon/GUI/MuonAnalysis/muon_analysis_2.py b/scripts/Muon/GUI/MuonAnalysis/muon_analysis_2.py index 49073ee83051706b40c945e94ce8ff056bec91c9..4d51658339dc909cb4bcc14ac80a2b4176451c02 100644 --- a/scripts/Muon/GUI/MuonAnalysis/muon_analysis_2.py +++ b/scripts/Muon/GUI/MuonAnalysis/muon_analysis_2.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - from qtpy import QtWidgets, QtCore, QT_VERSION from distutils.version import LooseVersion diff --git a/scripts/Muon/MaxentTools/back.py b/scripts/Muon/MaxentTools/back.py index 4b21aa1052461efac4ae60d38d48b5da495d2c07..2be429a121b033ae975038ba3852c611ada1e0a3 100644 --- a/scripts/Muon/MaxentTools/back.py +++ b/scripts/Muon/MaxentTools/back.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np """ diff --git a/scripts/Muon/MaxentTools/chinow.py b/scripts/Muon/MaxentTools/chinow.py index 75de4c5c8580ad43fdc19d76f5c3f70799af6cb2..c020b6cb78243b092528d9e56f547b3b03f55726 100644 --- a/scripts/Muon/MaxentTools/chinow.py +++ b/scripts/Muon/MaxentTools/chinow.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from Muon.MaxentTools.chosol import CHOSOL diff --git a/scripts/Muon/MaxentTools/chosol.py b/scripts/Muon/MaxentTools/chosol.py index 328ecc169bcc7198322782eeed096dcca58185d7..2a2f4a32f7cfb314d66796a7aeb91db7a47fc2a9 100644 --- a/scripts/Muon/MaxentTools/chosol.py +++ b/scripts/Muon/MaxentTools/chosol.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - import numpy as np import math diff --git a/scripts/Muon/MaxentTools/dead_detector_handler.py b/scripts/Muon/MaxentTools/dead_detector_handler.py index fa3887063fcf8380cf476b5cdfd9875a27480d2b..b054842da55a217150b1f1a22a3c92ae14862adf 100644 --- a/scripts/Muon/MaxentTools/dead_detector_handler.py +++ b/scripts/Muon/MaxentTools/dead_detector_handler.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import mantid.simpleapi as mantid diff --git a/scripts/Muon/MaxentTools/deadfit.py b/scripts/Muon/MaxentTools/deadfit.py index 856ff79dcb1b9d7c168824d93676048884b34f00..f567c76e5e3788daa5df1b17da1aae5fd8ca93bb 100644 --- a/scripts/Muon/MaxentTools/deadfit.py +++ b/scripts/Muon/MaxentTools/deadfit.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from Muon.MaxentTools.zft import ZFT diff --git a/scripts/Muon/MaxentTools/dist.py b/scripts/Muon/MaxentTools/dist.py index 82d02c32e919c532a2fbc7bf9440446c4871e624..b05cd55b11e7666ef5b1f098dfa50f7dc1a7fbe7 100644 --- a/scripts/Muon/MaxentTools/dist.py +++ b/scripts/Muon/MaxentTools/dist.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np diff --git a/scripts/Muon/MaxentTools/input.py b/scripts/Muon/MaxentTools/input.py index 739531ab252cc6bbe115c7e848140e10e3b11b15..81430a8e1656eee19356afd0b333563bdb91e978 100644 --- a/scripts/Muon/MaxentTools/input.py +++ b/scripts/Muon/MaxentTools/input.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import math """ diff --git a/scripts/Muon/MaxentTools/maxent.py b/scripts/Muon/MaxentTools/maxent.py index ee2c46a47ec2dbe1e6466b6100620a7b7b56acd4..2de214d78ed9d63c0c243b892478d53a7d287f82 100644 --- a/scripts/Muon/MaxentTools/maxent.py +++ b/scripts/Muon/MaxentTools/maxent.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - import numpy as np import math from Muon.MaxentTools.opus import OPUS diff --git a/scripts/Muon/MaxentTools/modab.py b/scripts/Muon/MaxentTools/modab.py index 4b5b86110ad384e3b457d53e49ce34c4d7647624..6bb45f07c78c5f4e62a2cc4b28fc5a193d84948f 100644 --- a/scripts/Muon/MaxentTools/modab.py +++ b/scripts/Muon/MaxentTools/modab.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from Muon.MaxentTools.zft import ZFT diff --git a/scripts/Muon/MaxentTools/modamp.py b/scripts/Muon/MaxentTools/modamp.py index 7ea44b1799eff05d3d8e889580c0e637ec4a19c3..8266718dd7cb592114aef04a0996ebf8e5a449d0 100644 --- a/scripts/Muon/MaxentTools/modamp.py +++ b/scripts/Muon/MaxentTools/modamp.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from Muon.MaxentTools.zft import ZFT diff --git a/scripts/Muon/MaxentTools/modbak.py b/scripts/Muon/MaxentTools/modbak.py index c4d7ec2157364a64075680ac7c798b9dc34a65b8..5539e505dca6549355861e0a58019363b9b0d39f 100644 --- a/scripts/Muon/MaxentTools/modbak.py +++ b/scripts/Muon/MaxentTools/modbak.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from Muon.MaxentTools.zft import ZFT diff --git a/scripts/Muon/MaxentTools/move.py b/scripts/Muon/MaxentTools/move.py index 59decbb33c25b25b375f268efb4dcc21e5de9ff5..c05d41226f5bb860bd960e09a94ef82cbfc639ae 100644 --- a/scripts/Muon/MaxentTools/move.py +++ b/scripts/Muon/MaxentTools/move.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import math from Muon.MaxentTools.chinow import CHINOW diff --git a/scripts/Muon/MaxentTools/multimaxalpha.py b/scripts/Muon/MaxentTools/multimaxalpha.py index 04e9f769a121b69bc03b83b3dc78f54e4a09cdd0..1f500586244298668858d39f8fed9c8df48be052 100644 --- a/scripts/Muon/MaxentTools/multimaxalpha.py +++ b/scripts/Muon/MaxentTools/multimaxalpha.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from Muon.MaxentTools.input import INPUT diff --git a/scripts/Muon/MaxentTools/opus.py b/scripts/Muon/MaxentTools/opus.py index 9093ed8e82382c3a096cf50196dcf1750add9f58..836a49f1192ce76e63a8c5ca0134d4e3b5172d56 100644 --- a/scripts/Muon/MaxentTools/opus.py +++ b/scripts/Muon/MaxentTools/opus.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np diff --git a/scripts/Muon/MaxentTools/outspec.py b/scripts/Muon/MaxentTools/outspec.py index 29221ce4737f49f3aa16e7b2bc273133fec5f7fb..da9b0683495ac259085bc5d9314c7d92c197843b 100644 --- a/scripts/Muon/MaxentTools/outspec.py +++ b/scripts/Muon/MaxentTools/outspec.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np from Muon.MaxentTools.zft import ZFT diff --git a/scripts/Muon/MaxentTools/project.py b/scripts/Muon/MaxentTools/project.py index cf505c95c614ad1edca71105a037cc6ad1f95964..d860e0349069e267a0660676ca56e6be9c4c1122 100644 --- a/scripts/Muon/MaxentTools/project.py +++ b/scripts/Muon/MaxentTools/project.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np diff --git a/scripts/Muon/MaxentTools/start.py b/scripts/Muon/MaxentTools/start.py index d48d33c531746fd46837d4c88e20654f7cfde96d..b777e75943f4d13e561297f44adb1afac7a2ae6e 100644 --- a/scripts/Muon/MaxentTools/start.py +++ b/scripts/Muon/MaxentTools/start.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import math diff --git a/scripts/Muon/MaxentTools/tropus.py b/scripts/Muon/MaxentTools/tropus.py index b2ab8eb9294a67c9d55bd345660a80e9f77a788c..db96ef8d1532d2968c861d9e4bfb84f549940122 100644 --- a/scripts/Muon/MaxentTools/tropus.py +++ b/scripts/Muon/MaxentTools/tropus.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np diff --git a/scripts/Muon/MaxentTools/zft.py b/scripts/Muon/MaxentTools/zft.py index b81b67f6ec4b2c6346429e84d1381e8aa40f7577..ebeac7f62e9e70463148b00d10f2be953d737105 100644 --- a/scripts/Muon/MaxentTools/zft.py +++ b/scripts/Muon/MaxentTools/zft.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np # param P not used! diff --git a/scripts/Muon_Analysis.py b/scripts/Muon_Analysis.py index 8522fe09dd3215d2e27d93e74e39b0df53a3170a..ae52da0fc3c28b0d352206a2bfe23a307e94f1ef 100644 --- a/scripts/Muon_Analysis.py +++ b/scripts/Muon_Analysis.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from Muon.GUI.MuonAnalysis.muon_analysis_2 import MuonAnalysisGui from qtpy import QtCore from Muon.GUI.Common.usage_report import report_interface_startup diff --git a/scripts/ORNL_SANS.py b/scripts/ORNL_SANS.py index bb6289e02e6c1c952c2dd52f152e8fe55cb52876..dbadb86ac2789cf5bbf7e4f0cd0f8b270f80565c 100644 --- a/scripts/ORNL_SANS.py +++ b/scripts/ORNL_SANS.py @@ -8,7 +8,6 @@ """ Script used to start the HFIR SANS reduction gui from Mantidplot """ -from __future__ import (absolute_import, division, print_function) from reduction_application import ReductionGUI reducer = ReductionGUI(instrument_list=["BIOSANS", "GPSANS", "EQSANS"]) diff --git a/scripts/Powder_Diffraction_Reduction.py b/scripts/Powder_Diffraction_Reduction.py index fe52af88b6737a51a9c69583435420ffc1bc582d..5e1862c96b92c95ac40e4f31239adf440c64c073 100644 --- a/scripts/Powder_Diffraction_Reduction.py +++ b/scripts/Powder_Diffraction_Reduction.py @@ -8,7 +8,6 @@ """ Script used to start the DGS reduction GUI from MantidPlot """ -from __future__ import (absolute_import, division, print_function) import os from reduction_application import ReductionGUI diff --git a/scripts/PyChop/Chop.py b/scripts/PyChop/Chop.py index c4ef62a270ab432ae42eba5f983c8be535284798..49b0c2d937dce6e426539c0f1973530711d95d75 100644 --- a/scripts/PyChop/Chop.py +++ b/scripts/PyChop/Chop.py @@ -23,7 +23,6 @@ technical reports: http://www.neutronresearch.com/parch/1993/01/199301013280.pdf """ -from __future__ import (absolute_import, division, print_function) import numpy as np import collections import warnings diff --git a/scripts/PyChop/ISISDisk.py b/scripts/PyChop/ISISDisk.py index 049c2eab9e652d77c4090f216ac29a663d191483..8d56cac44abc47b49d9dbc7f2bd32c1e91cc44e3 100644 --- a/scripts/PyChop/ISISDisk.py +++ b/scripts/PyChop/ISISDisk.py @@ -12,7 +12,6 @@ Contains the ISISDisk class which calculates resolution and flux for ISIS Disk c spectrometer (LET) - using the functions in MulpyRep and additional tables of instrument parameters """ -from __future__ import (absolute_import, division, print_function) import warnings import numpy as np from . import MulpyRep diff --git a/scripts/PyChop/ISISFermi.py b/scripts/PyChop/ISISFermi.py index e74a78fe7914060118559263d628ac54c8df9d13..a5f64ebffec1ccf55133314f3aae3e754f376e4c 100644 --- a/scripts/PyChop/ISISFermi.py +++ b/scripts/PyChop/ISISFermi.py @@ -13,7 +13,6 @@ Contains the ISISFermi class which calculates the resolution and flux for ISIS F spectrometers (MAPS, MARI, MERLIN) - using the functions in Chop.py and addition lookup tables. """ -from __future__ import (absolute_import, division, print_function) import warnings import numpy as np from . import Chop diff --git a/scripts/PyChop/Instruments.py b/scripts/PyChop/Instruments.py index 4ea8759b46133af0080e6071ce27d3e4cb8ba020..507c4b1df5af895e07cdecd07059839402c60847 100644 --- a/scripts/PyChop/Instruments.py +++ b/scripts/PyChop/Instruments.py @@ -9,8 +9,6 @@ This module is a wrapper around a set of instrument parameters (to be read from and methods which then call either Chop.py or MulpyRep.py to do the resolution calculations. """ -from __future__ import (absolute_import, division, print_function) -from six import string_types import numpy as np import yaml import warnings @@ -670,7 +668,7 @@ class Instrument(object): __known_instruments = ['let', 'maps', 'mari', 'merlin'] def __init__(self, instrument, chopper=None, freq=None): - if isinstance(instrument, string_types): + if isinstance(instrument, str): # check if it is a file or instrument name we want if instrument.lower() in self.__known_instruments: import os.path diff --git a/scripts/PyChop/MulpyRep.py b/scripts/PyChop/MulpyRep.py index 030264e3cde7eaee1f8773d35ec6082071a494cf..89173d9124ef612bd6ba98d3af329dccea407fc6 100644 --- a/scripts/PyChop/MulpyRep.py +++ b/scripts/PyChop/MulpyRep.py @@ -12,8 +12,6 @@ Contains a class to calculate the possible reps, resolution and flux for a direc spectrometer. Python implementation by D J Voneshen based on the original Matlab program of R I Bewley. """ -from __future__ import (absolute_import, division, print_function) -from six import string_types import numpy as np import copy @@ -224,8 +222,8 @@ def calcChopTimes(efocus, freq, instrumentpars, chop2Phase=5): for i in range(len(dist)): # loop over each chopper # checks whether this chopper should have an independently set phase / delay - islt = int(phase[i]) if (ph_ind[i] and isinstance(phase[i], string_types)) else 0 - if ph_ind[i] and not isinstance(phase[i], string_types): + islt = int(phase[i]) if (ph_ind[i] and isinstance(phase[i], str)) else 0 + if ph_ind[i] and not isinstance(phase[i], str): # effective chopper velocity (if 2 disks effective velocity is double) chopVel = 2*np.pi*radius[i] * numDisk[i] * freq[i] # full opening time diff --git a/scripts/PyChop/PyChop2.py b/scripts/PyChop/PyChop2.py index bcc91912b863ac58fd7c1befa6f66f9806b1f33c..e275232254193d6c675d05f52b63dffd747f3c68 100644 --- a/scripts/PyChop/PyChop2.py +++ b/scripts/PyChop/PyChop2.py @@ -11,7 +11,6 @@ This module contains the PyChop2 class which allows calculation of the resolutio direct geometry time-of-flight inelastic neutron spectrometers. """ -from __future__ import (absolute_import, division, print_function) from .ISISFermi import ISISFermi from .ISISDisk import ISISDisk import warnings diff --git a/scripts/PyChop/PyChopGui.py b/scripts/PyChop/PyChopGui.py index 589c45e954fd6c6cd0428ca149cebc1cfc498f6d..2183304b3f58b43c37a5c3bebe277cc49c880d4f 100755 --- a/scripts/PyChop/PyChopGui.py +++ b/scripts/PyChop/PyChopGui.py @@ -14,8 +14,6 @@ This module contains a class to create a graphical user interface for PyChop. """ -from __future__ import (absolute_import, division, print_function) -from six import string_types import sys import re import numpy as np @@ -162,7 +160,7 @@ class PyChopGui(QMainWindow): freq_in = [freq_in, freqpr] if not self.widgets['Chopper2Phase']['Label'].isHidden(): chop2phase = self.widgets['Chopper2Phase']['Edit'].text() - if isinstance(self.engine.chopper_system.defaultPhase[0], string_types): + if isinstance(self.engine.chopper_system.defaultPhase[0], str): chop2phase = str(chop2phase) else: chop2phase = float(chop2phase) % (1e6 / self.engine.moderator.source_rep) diff --git a/scripts/PyChop/__init__.py b/scripts/PyChop/__init__.py index d7ada5a222e89ddb86c6fa8c2ddcfddd1bca7c50..e595c68ae3c073fb5e88af11d65f163e27f94251 100644 --- a/scripts/PyChop/__init__.py +++ b/scripts/PyChop/__init__.py @@ -23,5 +23,4 @@ resolution, flux = PyChop2.calculate(inst='maps', chtyp='a', freq=500, ei=600, e PyChop2.showGUI() """ -from __future__ import (absolute_import, division, print_function) from .Instruments import Instrument as PyChop2 # noqa: F401 diff --git a/scripts/QECoverage.py b/scripts/QECoverage.py index 6d0447f7ff30c7cebeb691967f387b899d97706f..3a2bb7820d5219a1463a6495bc9031991e2df4e6 100644 --- a/scripts/QECoverage.py +++ b/scripts/QECoverage.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=line-too-long, too-many-instance-attributes, invalid-name, missing-docstring, too-many-statements # pylint: disable= too-many-branches, no-self-use -from __future__ import (absolute_import, division, print_function) from mantidqt.gui_helper import get_qapplication, show_interface_help import numpy as np import os diff --git a/scripts/Reflectometry/isis_reflectometry/combineMulti.py b/scripts/Reflectometry/isis_reflectometry/combineMulti.py index 59434f56c247d0a20b2a702d3353e2c2baa3d46f..2a32e8abadb0bb924abfc1e1234716846902c47a 100644 --- a/scripts/Reflectometry/isis_reflectometry/combineMulti.py +++ b/scripts/Reflectometry/isis_reflectometry/combineMulti.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from .l2q import * from mantid.simpleapi import * from mantid.api import WorkspaceGroup diff --git a/scripts/Reflectometry/isis_reflectometry/convert_to_wavelength.py b/scripts/Reflectometry/isis_reflectometry/convert_to_wavelength.py index f69337ee7d036cf1680b90a75435125d8fb6fb8d..2b63662c85cb2f3cdaf3a0443d33fc5e8a5e01ea 100644 --- a/scripts/Reflectometry/isis_reflectometry/convert_to_wavelength.py +++ b/scripts/Reflectometry/isis_reflectometry/convert_to_wavelength.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as msi import mantid.api from mantid.kernel import logger diff --git a/scripts/Reflectometry/isis_reflectometry/l2q.py b/scripts/Reflectometry/isis_reflectometry/l2q.py index cb5b331047ea4b9d6b3753336140cd7a031730f6..31c806b93650787e5f558c4ff7f61dbf31a96df3 100644 --- a/scripts/Reflectometry/isis_reflectometry/l2q.py +++ b/scripts/Reflectometry/isis_reflectometry/l2q.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import math from mantid.simpleapi import * # New API diff --git a/scripts/Reflectometry/isis_reflectometry/load_live_runs.py b/scripts/Reflectometry/isis_reflectometry/load_live_runs.py index 0e2789731228f08caacf24898a7d24ec8dcc7f3e..770ae600f496bf4318295c6971dc6bd86f145a83 100644 --- a/scripts/Reflectometry/isis_reflectometry/load_live_runs.py +++ b/scripts/Reflectometry/isis_reflectometry/load_live_runs.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * diff --git a/scripts/Reflectometry/isis_reflectometry/procedures.py b/scripts/Reflectometry/isis_reflectometry/procedures.py index 50aa9860465a5323ba411e806c43c9d0fe63e5bf..bb384df70a5ce1a0c61ad08b915000be2a1a1b63 100644 --- a/scripts/Reflectometry/isis_reflectometry/procedures.py +++ b/scripts/Reflectometry/isis_reflectometry/procedures.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-lines, invalid-name, too-many-arguments, too-many-branches, too-many-locals -from __future__ import (absolute_import, division, print_function) from math import * try: diff --git a/scripts/Reflectometry/isis_reflectometry/quick.py b/scripts/Reflectometry/isis_reflectometry/quick.py index 430f0be97e11e354365b860f800ec658221040e2..df65076ccbe60a97de0408aa595b697334362aa6 100644 --- a/scripts/Reflectometry/isis_reflectometry/quick.py +++ b/scripts/Reflectometry/isis_reflectometry/quick.py @@ -15,7 +15,6 @@ ''' # these need to be moved into one NR folder or so # from ReflectometerCors import * -from __future__ import (absolute_import, division, print_function) from isis_reflectometry.l2q import * from isis_reflectometry.combineMulti import * from mantid.simpleapi import * # New API @@ -26,7 +25,6 @@ from isis_reflectometry.convert_to_wavelength import ConvertToWavelength import math import re import abc -from six import with_metaclass def enum(**enums): @@ -36,7 +34,7 @@ def enum(**enums): PolarisationCorrection = enum(PNR=1, PA=2, NONE=3) -class CorrectionStrategy(with_metaclass(abc.ABCMeta, object)): +class CorrectionStrategy(metaclass=abc.ABCMeta): @abc.abstractmethod def apply(self, to_correct): pass diff --git a/scripts/Reflectometry/isis_reflectometry/saveModule.py b/scripts/Reflectometry/isis_reflectometry/saveModule.py index 9c8c63be26d501dc9e8d29c21e7ada373ec9f1ec..e6944ce16d336e05431a9feb2794dd23e4ad8ed3 100644 --- a/scripts/Reflectometry/isis_reflectometry/saveModule.py +++ b/scripts/Reflectometry/isis_reflectometry/saveModule.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from PyQt4 import QtCore from mantid.simpleapi import * import numpy as n diff --git a/scripts/Reflectometry/isis_reflectometry/settings.py b/scripts/Reflectometry/isis_reflectometry/settings.py index 9d3842f74e91886bbc53feb9ec12baa9f5201abf..47a49b023214d0ae6ef5836129c92f8d8093272a 100644 --- a/scripts/Reflectometry/isis_reflectometry/settings.py +++ b/scripts/Reflectometry/isis_reflectometry/settings.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import xml.etree.ElementTree as XML import os.path diff --git a/scripts/SANS/DarkRunCorrection.py b/scripts/SANS/DarkRunCorrection.py index 4aa9312a452479414a952fa780dbef42a74dd0aa..6f7051f87b7289cca2137d1125ce3cab29627b5e 100644 --- a/scripts/SANS/DarkRunCorrection.py +++ b/scripts/SANS/DarkRunCorrection.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * diff --git a/scripts/SANS/ISISCommandInterface.py b/scripts/SANS/ISISCommandInterface.py index c1423f59983901313604f61337cbaadb37dfa19a..e3373be720818cf50476cab2d9bd61805db4978f 100644 --- a/scripts/SANS/ISISCommandInterface.py +++ b/scripts/SANS/ISISCommandInterface.py @@ -9,7 +9,6 @@ Enables the SANS commands (listed at http://www.mantidproject.org/SANS) to be run """ -from __future__ import (absolute_import, division, print_function) import isis_instrument from reducer_singleton import ReductionSingleton from mantid.kernel import Logger diff --git a/scripts/SANS/SANSBatchMode.py b/scripts/SANS/SANSBatchMode.py index 8652fd5be5b9a751b3bec3206dbf98b471c5cb47..c3122c3082d0cf9fccf09bb92ae3f3fc15bd1898 100644 --- a/scripts/SANS/SANSBatchMode.py +++ b/scripts/SANS/SANSBatchMode.py @@ -36,7 +36,6 @@ # The save directory must currently be specified in the Mantid.user.properties file #Make the reduction module available -from __future__ import (absolute_import, division, print_function) from ISISCommandInterface import * import SANSUtility as su from mantid.simpleapi import * diff --git a/scripts/SANS/SANSUserFileParser.py b/scripts/SANS/SANSUserFileParser.py index 08de9f88c3cadfd6057e15fd206cf9b507287162..cd315fe6eef9bacbdd5ae2f511bde9fe9c8b4b17 100644 --- a/scripts/SANS/SANSUserFileParser.py +++ b/scripts/SANS/SANSUserFileParser.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from collections import namedtuple import re diff --git a/scripts/SANS/SANSUtility.py b/scripts/SANS/SANSUtility.py index bdd25fcf2331cb7eb20982ea51781ec93ed33ea7..f74495fec95d446067c318077d3ca5e9c7e5e333 100644 --- a/scripts/SANS/SANSUtility.py +++ b/scripts/SANS/SANSUtility.py @@ -10,7 +10,6 @@ # This module contains utility functions common to the # SANS data reduction scripts ######################################################## -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import IEventWorkspace, MatrixWorkspace, WorkspaceGroup, FileLoaderRegistry, FileFinder from mantid.kernel import DateAndTime @@ -18,7 +17,7 @@ import inspect import math import os import re -from six import types, iteritems, PY3 +import types import numpy as np import h5py as h5 @@ -736,14 +735,9 @@ def check_if_is_event_data(file_name): is_event_mode = False for value in list(first_entry.values()): if "NX_class" in value.attrs: - if PY3: - if "NXevent_data" == value.attrs["NX_class"].decode() : - is_event_mode = True - break - else: - if "NXevent_data" == value.attrs["NX_class"]: - is_event_mode = True - break + if "NXevent_data" == value.attrs["NX_class"].decode() : + is_event_mode = True + break return is_event_mode @@ -1971,7 +1965,7 @@ def createUnmanagedAlgorithm(name, **kwargs): alg = AlgorithmManager.createUnmanaged(name) alg.initialize() alg.setChild(True) - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): alg.setProperty(key, value) return alg diff --git a/scripts/SANS/SANSadd2.py b/scripts/SANS/SANSadd2.py index 1b7c08f163e1464d6b21c80f6af0d6bc17e7d460..62eb72c924cadcc3021035503b473ee8be4ac896 100644 --- a/scripts/SANS/SANSadd2.py +++ b/scripts/SANS/SANSadd2.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - import numpy as np import os from shutil import copyfile diff --git a/scripts/SANS/centre_finder.py b/scripts/SANS/centre_finder.py index d3da5a8a9ad9160b662335c5bcc024060aee8042..d36c61efbf36fc218cc7dd985efe1ecb0b003444 100644 --- a/scripts/SANS/centre_finder.py +++ b/scripts/SANS/centre_finder.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from isis_reduction_steps import StripEndNans from isis_instrument import LARMOR from mantid.simpleapi import * diff --git a/scripts/SANS/isis_instrument.py b/scripts/SANS/isis_instrument.py index 5a45796d008eb933cce393bef1a6df2f45acd899..2eb89630de797a95180feb3f0bca03059069b073 100644 --- a/scripts/SANS/isis_instrument.py +++ b/scripts/SANS/isis_instrument.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-lines, invalid-name, bare-except, too-many-instance-attributes -from __future__ import (absolute_import, division, print_function) import math import os import re @@ -17,8 +16,6 @@ from mantid.kernel import Logger from mantid.kernel import V3D import SANSUtility as su from math import copysign -from six import iteritems - sanslog = Logger("SANS") @@ -616,7 +613,7 @@ class ISISInstrument(BaseInstrument): return self.DETECTORS['high-angle'] def getDetector(self, requested): - for _n, detect in iteritems(self.DETECTORS): + for _n, detect in self.DETECTORS.items(): if detect.isAlias(requested): return detect sanslog.notice("getDetector: Detector " + requested + "not found") diff --git a/scripts/SANS/isis_reducer.py b/scripts/SANS/isis_reducer.py index b962d7d1e23586902789c4252750f683fdfdd8ed..d92cfcb86684d8e2816f4a27f56dc01a6f83e2f7 100644 --- a/scripts/SANS/isis_reducer.py +++ b/scripts/SANS/isis_reducer.py @@ -12,7 +12,6 @@ understand what's happening and how best to fit it in the Reducer design. """ -from __future__ import (absolute_import, division, print_function) from reducer_singleton import Reducer import isis_reduction_steps import isis_instrument diff --git a/scripts/SANS/isis_reduction_steps.py b/scripts/SANS/isis_reduction_steps.py index d9adec0121918e04900d3419bbbb931679baf23f..3d2cb8d851397c53ea1249c2acc491a04c3fd9aa 100644 --- a/scripts/SANS/isis_reduction_steps.py +++ b/scripts/SANS/isis_reduction_steps.py @@ -14,7 +14,6 @@ Most of this code is a copy-paste from SANSReduction.py, organized to be used with ReductionStep objects. The guts needs refactoring. """ -from __future__ import (absolute_import, division, print_function) import os import re import math diff --git a/scripts/SANS/reduction_settings.py b/scripts/SANS/reduction_settings.py index df4eb1a370118737db2b0dbe125e78b1e80db550..7cea24348aee72e96a40c7f5355b216d99d1a2d2 100644 --- a/scripts/SANS/reduction_settings.py +++ b/scripts/SANS/reduction_settings.py @@ -68,7 +68,6 @@ between reduction steps. The benefits to this new method are as follows: passing settings to each other via PropertyManager objects. """ -from __future__ import (absolute_import, division, print_function) from mantid.simpleapi import * from mantid.api import * from mantid.kernel import * diff --git a/scripts/SANS/sans/algorithm_detail/CreateSANSAdjustmentWorkspaces.py b/scripts/SANS/sans/algorithm_detail/CreateSANSAdjustmentWorkspaces.py index b64471f3a085c3eeed479ac0dc3cddbee939b0f0..9cb27be639044ef50fe3e06e6a16ca004f5cb198 100644 --- a/scripts/SANS/sans/algorithm_detail/CreateSANSAdjustmentWorkspaces.py +++ b/scripts/SANS/sans/algorithm_detail/CreateSANSAdjustmentWorkspaces.py @@ -8,8 +8,6 @@ wavelength adjustment and pixel-and-wavelength adjustment workspaces. """ -from __future__ import (absolute_import, division, print_function) - from sans.algorithm_detail.calculate_sans_transmission import calculate_transmission from sans.algorithm_detail.CreateSANSWavelengthPixelAdjustment import CreateSANSWavelengthPixelAdjustment from sans.algorithm_detail.normalize_to_sans_monitor import normalize_to_monitor diff --git a/scripts/SANS/sans/algorithm_detail/CreateSANSWavelengthPixelAdjustment.py b/scripts/SANS/sans/algorithm_detail/CreateSANSWavelengthPixelAdjustment.py index 846d3b2a59cb4a186270f7bd995529acf94c0a24..888f9527e06778c005bc9db05bab595169fc9e3f 100644 --- a/scripts/SANS/sans/algorithm_detail/CreateSANSWavelengthPixelAdjustment.py +++ b/scripts/SANS/sans/algorithm_detail/CreateSANSWavelengthPixelAdjustment.py @@ -8,8 +8,6 @@ and wavelength adjustment. """ -from __future__ import (absolute_import, division, print_function) - from sans.algorithm_detail.crop_helper import get_component_name from sans.common.constants import EMPTY_NAME from sans.common.enums import (DetectorType) diff --git a/scripts/SANS/sans/algorithm_detail/batch_execution.py b/scripts/SANS/sans/algorithm_detail/batch_execution.py index 2b1d1cd1f5e2065f89b62a0558486c83267e4bbf..1af602dcae987420a5630704e9fc2bc845a37eac 100644 --- a/scripts/SANS/sans/algorithm_detail/batch_execution.py +++ b/scripts/SANS/sans/algorithm_detail/batch_execution.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from copy import deepcopy from mantid.api import AnalysisDataService, WorkspaceGroup diff --git a/scripts/SANS/sans/algorithm_detail/bundles.py b/scripts/SANS/sans/algorithm_detail/bundles.py index 5965a1c633ff2ba8467bdd3f424f018bec513718..060b58321a74894236e0356ee00fc2d93462be29 100644 --- a/scripts/SANS/sans/algorithm_detail/bundles.py +++ b/scripts/SANS/sans/algorithm_detail/bundles.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ This module contains bundle definitions for passing reduction settings between functions.""" -from __future__ import (absolute_import, division, print_function) from collections import namedtuple # The ReductionSettingBundle contains the information and data for starting a SANSReductionCore reduction. diff --git a/scripts/SANS/sans/algorithm_detail/calculate_sans_transmission.py b/scripts/SANS/sans/algorithm_detail/calculate_sans_transmission.py index cd6b38671764f6e8db94c6e1e2498f76e90b225e..e951df0c5720ab17cac6530f5e10543de71c12d3 100644 --- a/scripts/SANS/sans/algorithm_detail/calculate_sans_transmission.py +++ b/scripts/SANS/sans/algorithm_detail/calculate_sans_transmission.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from sans.algorithm_detail.calculate_transmission_helper import (get_detector_id_for_spectrum_number, get_workspace_indices_for_monitors, apply_flat_background_correction_to_monitors, diff --git a/scripts/SANS/sans/algorithm_detail/calculate_transmission_helper.py b/scripts/SANS/sans/algorithm_detail/calculate_transmission_helper.py index efcd70d92f91298f9d7b28084c7464d76aae0a08..4a572839bef0896ed2883e98a31470e44e29574c 100644 --- a/scripts/SANS/sans/algorithm_detail/calculate_transmission_helper.py +++ b/scripts/SANS/sans/algorithm_detail/calculate_transmission_helper.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.api import ExperimentInfo from sans.common.general_functions import (create_unmanaged_algorithm, sanitise_instrument_name) from sans.common.constants import EMPTY_NAME diff --git a/scripts/SANS/sans/algorithm_detail/calibration.py b/scripts/SANS/sans/algorithm_detail/calibration.py index dcf9314a2182c5634425bf1fd7f19f71dcebffd9..28bbc8e6ff7158d56151528e6a221a53fc201bc2 100644 --- a/scripts/SANS/sans/algorithm_detail/calibration.py +++ b/scripts/SANS/sans/algorithm_detail/calibration.py @@ -7,7 +7,6 @@ # pylint: disable=invalid-name """ Handles calibration of SANS workspaces.""" -from __future__ import (absolute_import, division, print_function) from os.path import (basename, splitext, isfile) from mantid.api import (AnalysisDataService) diff --git a/scripts/SANS/sans/algorithm_detail/centre_finder_new.py b/scripts/SANS/sans/algorithm_detail/centre_finder_new.py index 95546a289d35f8470cf5bb3b04346499460427a3..178a734c3d7d80cf6847ee8a386842516c927aba 100644 --- a/scripts/SANS/sans/algorithm_detail/centre_finder_new.py +++ b/scripts/SANS/sans/algorithm_detail/centre_finder_new.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.simpleapi import CreateEmptyTableWorkspace from sans.algorithm_detail.batch_execution import (provide_loaded_data, get_reduction_packages) from sans.common.enums import (SANSDataType, DetectorType) diff --git a/scripts/SANS/sans/algorithm_detail/convert_to_q.py b/scripts/SANS/sans/algorithm_detail/convert_to_q.py index 99265932ce40f1d873aa2b949439766a451a84a4..02d5962afe640cc152bd1b9b6dbf0949c24a45e2 100644 --- a/scripts/SANS/sans/algorithm_detail/convert_to_q.py +++ b/scripts/SANS/sans/algorithm_detail/convert_to_q.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ Converts a workspace from wavelengths to momentum transfer.""" -from __future__ import (absolute_import, division, print_function) - from math import sqrt from sans.common.constants import EMPTY_NAME diff --git a/scripts/SANS/sans/algorithm_detail/crop_helper.py b/scripts/SANS/sans/algorithm_detail/crop_helper.py index 9d2d1040535ca42470caec3dfe9b9a5c68a2d888..6ea9b47582d6c2fcb0ff97b4d5af67091a3dcba0 100644 --- a/scripts/SANS/sans/algorithm_detail/crop_helper.py +++ b/scripts/SANS/sans/algorithm_detail/crop_helper.py @@ -7,7 +7,6 @@ # pylint: disable=invalid-name """ Helpers for CropToComponent for SANS.""" -from __future__ import (absolute_import, division, print_function) from sans.common.general_functions import convert_instrument_and_detector_type_to_bank_name from sans.common.enums import SANSInstrument diff --git a/scripts/SANS/sans/algorithm_detail/load_data.py b/scripts/SANS/sans/algorithm_detail/load_data.py index 56d940642c00c6777b120245917b4aee5d7656b8..4e75f0193b61f670d180295b7e91f71a1e1e3182 100644 --- a/scripts/SANS/sans/algorithm_detail/load_data.py +++ b/scripts/SANS/sans/algorithm_detail/load_data.py @@ -48,9 +48,7 @@ Adding to the cache(ADS) is supported for the TubeCalibration file. Reading from the cache is supported for all files. This avoids data reloads if the correct file is already in the cache. """ -from __future__ import (absolute_import, division, print_function) from abc import (ABCMeta, abstractmethod) -from six import with_metaclass import os from mantid.kernel import config from mantid.api import (AnalysisDataService) @@ -689,7 +687,7 @@ def load_isis(data_type, file_information, period, use_cached, calibration_file_ # ---------------------------------------------------------------------------------------------------------------------- # Load classes # ---------------------------------------------------------------------------------------------------------------------- -class SANSLoadData(with_metaclass(ABCMeta, object)): +class SANSLoadData(metaclass=ABCMeta): """ Base class for all SANSLoad implementations.""" @abstractmethod def do_execute(self, data_info, use_cached, publish_to_ads, progress, parent_alg): @@ -789,7 +787,7 @@ class SANSLoadDataFactory(object): # Corrections for a loaded transmission workspace # ------------------------------------------------- -class TransmissionCorrection(with_metaclass(ABCMeta, object)): +class TransmissionCorrection(metaclass=ABCMeta): @abstractmethod def correct(self, workspaces, parent_alg): pass diff --git a/scripts/SANS/sans/algorithm_detail/mask_functions.py b/scripts/SANS/sans/algorithm_detail/mask_functions.py index bb1c590978e33a161dbe1f19634248caadbd276c..f0715a632106fb397645e195a37428e43670a71a 100644 --- a/scripts/SANS/sans/algorithm_detail/mask_functions.py +++ b/scripts/SANS/sans/algorithm_detail/mask_functions.py @@ -4,10 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from collections import (namedtuple, Sequence) -from mantid.py3compat import Enum +from enum import Enum from sans.common.enums import (DetectorType, SANSInstrument) from sans.common.xml_parsing import get_named_elements_from_ipf_file diff --git a/scripts/SANS/sans/algorithm_detail/mask_sans_workspace.py b/scripts/SANS/sans/algorithm_detail/mask_sans_workspace.py index 25d8fe10a5a7254a25dcf7ec38852866a3ef65ad..f0828ad0f01aa32f7f23fb3931a935b22b4a67e0 100644 --- a/scripts/SANS/sans/algorithm_detail/mask_sans_workspace.py +++ b/scripts/SANS/sans/algorithm_detail/mask_sans_workspace.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from sans.algorithm_detail.mask_workspace import create_masker from sans.common.enums import DetectorType from sans.common.general_functions import append_to_sans_file_tag diff --git a/scripts/SANS/sans/algorithm_detail/mask_workspace.py b/scripts/SANS/sans/algorithm_detail/mask_workspace.py index 76cc42e74701f4ef1ddd894bba132b55cf2d6a2f..8457a49c3210a55d228eafb1190fefb43d852ba6 100644 --- a/scripts/SANS/sans/algorithm_detail/mask_workspace.py +++ b/scripts/SANS/sans/algorithm_detail/mask_workspace.py @@ -4,12 +4,8 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from abc import (ABCMeta, abstractmethod) -from six import with_metaclass - from mantid.kernel import Logger from sans.algorithm_detail.mask_functions import SpectraBlock @@ -356,7 +352,7 @@ def mask_beam_stop(mask_info, workspace, instrument, detector_names): # Masker classes # ------------------------------------------------------------------ -class Masker(with_metaclass(ABCMeta, object)): +class Masker(metaclass=ABCMeta): def __init__(self): super(Masker, self).__init__() diff --git a/scripts/SANS/sans/algorithm_detail/merge_reductions.py b/scripts/SANS/sans/algorithm_detail/merge_reductions.py index a030ce0b1d55fe23636747ea46ee5293516e4f33..064e57965e60beee8e8cbe61028cadc3bdb9ba1e 100644 --- a/scripts/SANS/sans/algorithm_detail/merge_reductions.py +++ b/scripts/SANS/sans/algorithm_detail/merge_reductions.py @@ -6,19 +6,15 @@ # SPDX - License - Identifier: GPL - 3.0 + """ Merges two reduction types to single reduction""" -from __future__ import (absolute_import, division, print_function) - from abc import (ABCMeta, abstractmethod) -from six import with_metaclass - import mantid.simpleapi as mantid_api from sans.algorithm_detail.bundles import MergeBundle from sans.common.enums import (SANSFacility, DataType) from sans.common.general_functions import create_child_algorithm -class Merger(with_metaclass(ABCMeta, object)): +class Merger(metaclass=ABCMeta): """ Merger interface""" @abstractmethod diff --git a/scripts/SANS/sans/algorithm_detail/move_sans_instrument_component.py b/scripts/SANS/sans/algorithm_detail/move_sans_instrument_component.py index 43e7a7ebece4fd3de7e92cde49ac54d96dcf735a..b7aa21006b05a45bdcba929e58e73ccc8826e49c 100644 --- a/scripts/SANS/sans/algorithm_detail/move_sans_instrument_component.py +++ b/scripts/SANS/sans/algorithm_detail/move_sans_instrument_component.py @@ -4,7 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from mantid.py3compat.enum import Enum +from enum import Enum from sans.algorithm_detail.move_workspaces import create_mover from sans.common.enums import DetectorType diff --git a/scripts/SANS/sans/algorithm_detail/move_workspaces.py b/scripts/SANS/sans/algorithm_detail/move_workspaces.py index 5669572bdf155a3f15480e670ed2655370f7b3ae..89c42c5e6cd89db8329794fd7301191e789741b2 100644 --- a/scripts/SANS/sans/algorithm_detail/move_workspaces.py +++ b/scripts/SANS/sans/algorithm_detail/move_workspaces.py @@ -6,10 +6,8 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-few-public-methods, invalid-name -from __future__ import (absolute_import, division, print_function) import math from mantid.api import MatrixWorkspace -from six import with_metaclass from abc import (ABCMeta, abstractmethod) from sans.state.StateObjects.StateMoveDetectors import StateMove from sans.common.enums import CanonicalCoordinates, DetectorType, SANSInstrument @@ -334,7 +332,7 @@ def move_low_angle_bank_for_SANS2D_and_ZOOM(move_info, workspace, coordinates, u # ------------------------------------------------- # Move classes # ------------------------------------------------- -class SANSMove(with_metaclass(ABCMeta, object)): +class SANSMove(metaclass=ABCMeta): def __init__(self): super(SANSMove, self).__init__() diff --git a/scripts/SANS/sans/algorithm_detail/normalize_to_sans_monitor.py b/scripts/SANS/sans/algorithm_detail/normalize_to_sans_monitor.py index 619118e120f70afa9f6867cdffa249a2917eaf02..9761a40e4e49b56441fa23a445deed619f78f2fa 100644 --- a/scripts/SANS/sans/algorithm_detail/normalize_to_sans_monitor.py +++ b/scripts/SANS/sans/algorithm_detail/normalize_to_sans_monitor.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + """ SANSNormalizeToMonitor algorithm calculates the normalization to the monitor.""" -from __future__ import (absolute_import, division, print_function) - from sans.common.constants import EMPTY_NAME from sans.common.general_functions import create_unmanaged_algorithm diff --git a/scripts/SANS/sans/algorithm_detail/save_workspace.py b/scripts/SANS/sans/algorithm_detail/save_workspace.py index cf76a1b9dad65f4f3e7453731a5d176f778288e3..ba135ebb39787e9bd1969fbc7e1fd274b6a41d68 100644 --- a/scripts/SANS/sans/algorithm_detail/save_workspace.py +++ b/scripts/SANS/sans/algorithm_detail/save_workspace.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from collections import namedtuple from mantid.api import MatrixWorkspace from mantid.dataobjects import EventWorkspace diff --git a/scripts/SANS/sans/algorithm_detail/scale_sans_workspace.py b/scripts/SANS/sans/algorithm_detail/scale_sans_workspace.py index 2204dd86195af6af9fa70179545022670e75df22..d60f89e47dfd687952baaf357a9a609e32ac8033 100644 --- a/scripts/SANS/sans/algorithm_detail/scale_sans_workspace.py +++ b/scripts/SANS/sans/algorithm_detail/scale_sans_workspace.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + """ Multiplies a SANS workspace by an absolute scale and divides it by the sample volume. """ -from __future__ import (absolute_import, division, print_function) - import math from sans.common.constants import EMPTY_NAME diff --git a/scripts/SANS/sans/algorithm_detail/single_execution.py b/scripts/SANS/sans/algorithm_detail/single_execution.py index c71ae14321c9e6123b8612588b5fdf882df9e456..184f4970c61d30f33f3d4d54fea7377c7e6b2ee6 100644 --- a/scripts/SANS/sans/algorithm_detail/single_execution.py +++ b/scripts/SANS/sans/algorithm_detail/single_execution.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import sys from mantid.kernel import mpisetup diff --git a/scripts/SANS/sans/algorithm_detail/slice_sans_event.py b/scripts/SANS/sans/algorithm_detail/slice_sans_event.py index 021f308a1c48c45c92a9678d1bb4bd8fa78cbf76..86e727193e0992e5546e5bb8754f681b4d7c4086 100644 --- a/scripts/SANS/sans/algorithm_detail/slice_sans_event.py +++ b/scripts/SANS/sans/algorithm_detail/slice_sans_event.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from SANSUtility import _clean_logs from mantid.dataobjects import Workspace2D from sans.common.constants import EMPTY_NAME diff --git a/scripts/SANS/sans/algorithm_detail/strip_end_nans_and_infs.py b/scripts/SANS/sans/algorithm_detail/strip_end_nans_and_infs.py index 02962641d2f847b78ec5f4ea407431c8848e2a92..3287449d852909580d8d2522892c4a4ffa49c6c8 100644 --- a/scripts/SANS/sans/algorithm_detail/strip_end_nans_and_infs.py +++ b/scripts/SANS/sans/algorithm_detail/strip_end_nans_and_infs.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from math import (isinf, isnan) from sans.common.constants import EMPTY_NAME from sans.common.general_functions import create_child_algorithm diff --git a/scripts/SANS/sans/algorithm_detail/xml_shapes.py b/scripts/SANS/sans/algorithm_detail/xml_shapes.py index 76d765dcb4ed68051279ed45348a048e23886feb..583bd7001a8aef7fcb2573d9b24fe2107dcd3bcf 100644 --- a/scripts/SANS/sans/algorithm_detail/xml_shapes.py +++ b/scripts/SANS/sans/algorithm_detail/xml_shapes.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from math import (pi, cos, sin) from sans.common.enums import MaskingQuadrant diff --git a/scripts/SANS/sans/command_interface/ISISCommandInterface.py b/scripts/SANS/sans/command_interface/ISISCommandInterface.py index f1b85fe77713661ddbab0b7fa01b12bb1fa5957f..b4648c8091cf8dbd661593b16c938b35cf775cae 100644 --- a/scripts/SANS/sans/command_interface/ISISCommandInterface.py +++ b/scripts/SANS/sans/command_interface/ISISCommandInterface.py @@ -4,14 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import inspect import os import re -import six -from six import types +import types from SANSadd2 import add_runs from mantid.api import (AnalysisDataService, WorkspaceGroup) @@ -31,10 +28,6 @@ from sans.common.general_functions import (convert_bank_name_to_detector_type_is from sans.gui_logic.models.RowEntries import RowEntries from sans.sans_batch import SANSBatchReduction, SANSCentreFinder -if six.PY2: - # This can be swapped with in box FileNotFoundError - FileNotFoundError = IOError - # Disable plotting if running outside Mantidplot try: diff --git a/scripts/SANS/sans/command_interface/batch_csv_parser.py b/scripts/SANS/sans/command_interface/batch_csv_parser.py index 64d4417ef0fba37bbc90cf3f2e0825b71b73e007..bf4f71268b0586a0b4271baf44d89ed1d344e205 100644 --- a/scripts/SANS/sans/command_interface/batch_csv_parser.py +++ b/scripts/SANS/sans/command_interface/batch_csv_parser.py @@ -4,14 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import csv import re from csv import reader from enum import Enum -from mantid.py3compat import csv_open_type from sans.common.constants import ALL_PERIODS from sans.common.file_information import find_full_file_path from sans.gui_logic.models.RowEntries import RowEntries @@ -72,7 +69,7 @@ class BatchCsvParser(object): for row in rows: to_write.append(self._convert_row_to_list(row)) - with open(file_path, csv_open_type) as outfile: + with open(file_path, "w") as outfile: writer_handle = csv.writer(outfile) for line in to_write: writer_handle.writerow(line) diff --git a/scripts/SANS/sans/command_interface/command_interface_functions.py b/scripts/SANS/sans/command_interface/command_interface_functions.py index b1edf7b22999463693f5aa128cabea1c1bc966ee..c5702ed52002ce769c25e6a2939b267d3bacccdb 100644 --- a/scripts/SANS/sans/command_interface/command_interface_functions.py +++ b/scripts/SANS/sans/command_interface/command_interface_functions.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from mantid.kernel import Logger diff --git a/scripts/SANS/sans/command_interface/command_interface_state_director.py b/scripts/SANS/sans/command_interface/command_interface_state_director.py index 4da3b57899710d187b99d7cc2cda5f1b88382372..95009f514966c201620b4608a546f09c8326d99d 100644 --- a/scripts/SANS/sans/command_interface/command_interface_state_director.py +++ b/scripts/SANS/sans/command_interface/command_interface_state_director.py @@ -4,9 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - -from mantid.py3compat import Enum +from enum import Enum from sans.common.enums import DataType from sans.common.file_information import SANSFileInformationFactory from sans.state.StateRunDataBuilder import StateRunDataBuilder diff --git a/scripts/SANS/sans/common/configurations.py b/scripts/SANS/sans/common/configurations.py index f1bec969236312fcb60319cf6c435012759c27fd..2ed1353e419d497ddb2a1ff2c35a64dc3cd47228 100644 --- a/scripts/SANS/sans/common/configurations.py +++ b/scripts/SANS/sans/common/configurations.py @@ -7,8 +7,6 @@ """ The SANSConfigurations class holds instrument-specific configs to centralize instrument-specific magic numbers""" # pylint: disable=too-few-public-methods -from __future__ import (absolute_import, division, print_function) - class Configurations(object): diff --git a/scripts/SANS/sans/common/constants.py b/scripts/SANS/sans/common/constants.py index 59a36544db0300263726750ff8235e8c1f672c56..039bb99d48958e5420867bd1b80125679d18581f 100644 --- a/scripts/SANS/sans/common/constants.py +++ b/scripts/SANS/sans/common/constants.py @@ -8,8 +8,6 @@ # pylint: disable=too-few-public-methods -from __future__ import (absolute_import, division, print_function) - # ---------------------------------------- # Property names for Algorithms # --------------------------------------- diff --git a/scripts/SANS/sans/common/enums.py b/scripts/SANS/sans/common/enums.py index c02a235de1557c7900f9926b2b3f56c59500b485..00fd44bc7a3dd0646cdd276c35d09565f611dcdb 100644 --- a/scripts/SANS/sans/common/enums.py +++ b/scripts/SANS/sans/common/enums.py @@ -6,9 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + """ The elements of this module define typed enums which are used in the SANS reduction framework.""" -from __future__ import (absolute_import, division, print_function) - -from mantid.py3compat import Enum +from enum import Enum from sans.state.JsonSerializable import json_serializable diff --git a/scripts/SANS/sans/common/file_information.py b/scripts/SANS/sans/common/file_information.py index 867102bfe24e1ad6fd81d869f0a7c8889bc98675..314e7fe90fb0fcde3c83f8611338613a3964329a 100644 --- a/scripts/SANS/sans/common/file_information.py +++ b/scripts/SANS/sans/common/file_information.py @@ -8,7 +8,6 @@ # pylint: disable=too-few-public-methods, invalid-name -from __future__ import (absolute_import, division, print_function) import os import h5py as h5 import re @@ -18,8 +17,6 @@ from mantid.kernel import (DateAndTime, ConfigService, Logger) from mantid.api import (AlgorithmManager, ExperimentInfo) from sans.common.enums import (SANSInstrument, FileType, SampleShape) from sans.common.general_functions import (get_instrument, instrument_name_correction, get_facility) -from six import with_metaclass - # ---------------------------------------------------------------------------------------------------------------------- # Constants # ---------------------------------------------------------------------------------------------------------------------- @@ -719,7 +716,7 @@ def get_geometry_information_raw(file_name): # ---------------------------------------------------------------------------------------------------------------------- # SANS file Information # ---------------------------------------------------------------------------------------------------------------------- -class SANSFileInformation(with_metaclass(ABCMeta, object)): +class SANSFileInformation(metaclass=ABCMeta): logger = Logger("SANS") def __init__(self, full_file_name): diff --git a/scripts/SANS/sans/common/general_functions.py b/scripts/SANS/sans/common/general_functions.py index 64da771d430ef734cc395756ea1015bec3ffbd6b..a44e29072c31a0fa8e2944726c032b0ddb411f8d 100644 --- a/scripts/SANS/sans/common/general_functions.py +++ b/scripts/SANS/sans/common/general_functions.py @@ -8,7 +8,6 @@ # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from math import (acos, sqrt, degrees) import re from copy import deepcopy diff --git a/scripts/SANS/sans/common/log_tagger.py b/scripts/SANS/sans/common/log_tagger.py index 3f44f2d2ccdd8ff193c41bd2e155b5d39b9938a7..4d1ca1b00d4081dd8ce79ffb7f4ca426f3a5b64f 100644 --- a/scripts/SANS/sans/common/log_tagger.py +++ b/scripts/SANS/sans/common/log_tagger.py @@ -8,10 +8,8 @@ # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from hashlib import sha224 from mantid.api import (MatrixWorkspace, WorkspaceGroup) -from six import string_types def get_hash_value(value): @@ -34,7 +32,7 @@ def check_if_valid_tag_and_workspace(tag, workspace): :param tag: the tag :param workspace: the workspace """ - if not(isinstance(tag, string_types) and isinstance(workspace, MatrixWorkspace)): + if not(isinstance(tag, str) and isinstance(workspace, MatrixWorkspace)): raise RuntimeError("SANSLogTagger: Either tag {0} or workspace are invalid. The tag has to be a string" " and the workspace {1} has to be a MatrixWorkspace".format(str(tag), str(workspace))) diff --git a/scripts/SANS/sans/common/xml_parsing.py b/scripts/SANS/sans/common/xml_parsing.py index f839d33a25ada015bff2a3c23da31e74009d05a8..34cfc21d71853d6df782ce620f11a0cb2efc6d12 100644 --- a/scripts/SANS/sans/common/xml_parsing.py +++ b/scripts/SANS/sans/common/xml_parsing.py @@ -8,8 +8,6 @@ # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - try: import xml.etree.cElementTree as eTree except ImportError: diff --git a/scripts/SANS/sans/gui_logic/models/RowEntries.py b/scripts/SANS/sans/gui_logic/models/RowEntries.py index ee35d192ec481c0efd08c28a382aa3de32f5175a..3e602b7702ad9c9965fc291c801da7458f392bab 100644 --- a/scripts/SANS/sans/gui_logic/models/RowEntries.py +++ b/scripts/SANS/sans/gui_logic/models/RowEntries.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from six import iteritems, iterkeys from sans.common.enums import RowState, SampleShape from sans.common.file_information import SANSFileInformationFactory @@ -56,7 +55,7 @@ class RowEntries(_UserEntries): self._start_observing = True # Allow init to use setattr without validation - for k, v in iteritems(kwargs): + for k, v in kwargs.items(): setattr(self, k, v) @property @@ -100,7 +99,7 @@ class RowEntries(_UserEntries): self.can_scatter_period, self.can_transmission_period, self.can_direct_period)) def is_empty(self): - return not any(getattr(self, attr) for attr in iterkeys(self._data_vars)) + return not any(getattr(self, attr) for attr in self._data_vars.keys()) def reset_row_state(self): self.state = RowState.UNPROCESSED diff --git a/scripts/SANS/sans/gui_logic/models/batch_process_runner.py b/scripts/SANS/sans/gui_logic/models/batch_process_runner.py index 4a15e81a4e94867f099c69f224127364c6eed9ec..9236e42b22e71c77663d13bdfe750a4fed7c7305 100644 --- a/scripts/SANS/sans/gui_logic/models/batch_process_runner.py +++ b/scripts/SANS/sans/gui_logic/models/batch_process_runner.py @@ -6,9 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import traceback -import six from qtpy.QtCore import Slot, QThreadPool, Signal, QObject -from six import itervalues from mantid.kernel import Logger from sans.algorithm_detail.batch_execution import load_workspaces_from_states @@ -73,10 +71,10 @@ class BatchProcessRunner(QObject): assert len(states) + len(errors) == 1, \ "Expected 1 error to return got {0}".format(len(states) + len(errors)) - for error in itervalues(errors): + for error in errors.values(): self.row_failed_signal.emit(index, error) - for state in itervalues(states): + for state in states.values(): try: out_scale_factors, out_shift_factors = \ self.batch_processor([state], use_optimizations, output_mode, plot_results, output_graph, save_can) @@ -100,10 +98,10 @@ class BatchProcessRunner(QObject): self._handle_err(index, e) continue - for error in itervalues(errors): + for error in errors.values(): self.row_failed_signal.emit(index, error) - for state in itervalues(states): + for state in states.values(): try: load_workspaces_from_states(state) self.row_processed_signal.emit(index, [], []) @@ -113,7 +111,6 @@ class BatchProcessRunner(QObject): def _handle_err(self, index, e): # We manually have to extract out the traceback, since going to a str for Qt signals will strip this - if six.PY3: - self._logger.error(''.join(traceback.format_tb(e.__traceback__))) + self._logger.error(''.join(traceback.format_tb(e.__traceback__))) self._logger.error(str(e)) self.row_failed_signal.emit(index, str(e)) diff --git a/scripts/SANS/sans/gui_logic/models/create_state.py b/scripts/SANS/sans/gui_logic/models/create_state.py index 3638ddbdb5787cf6bad59d6c09f33e6acc4e45aa..3446c03d6a8dbea3cdb8f013d5d68a5cedef29a5 100644 --- a/scripts/SANS/sans/gui_logic/models/create_state.py +++ b/scripts/SANS/sans/gui_logic/models/create_state.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os from mantid.api import FileFinder from sans.gui_logic.models.state_gui_model import StateGuiModel diff --git a/scripts/SANS/sans/gui_logic/models/model_common.py b/scripts/SANS/sans/gui_logic/models/model_common.py index 805164e0723f8103dcacf1c7a124a609cea5dd00..d78acffcabf57e6057ec514ba9bfd25dcfad7ff2 100644 --- a/scripts/SANS/sans/gui_logic/models/model_common.py +++ b/scripts/SANS/sans/gui_logic/models/model_common.py @@ -5,16 +5,12 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ The settings diagnostic tab which visualizes the SANS state object. """ -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta -from six import with_metaclass - from sans.common.enums import SANSInstrument from sans.user_file.settings_tags import MonId, monitor_spectrum, DetectorId -class ModelCommon(with_metaclass(ABCMeta)): +class ModelCommon(metaclass=ABCMeta): def __init__(self, user_file_items): # Workaround to avoid refactoring becoming impossibly large # TODO this should be encapsulated in sub-models diff --git a/scripts/SANS/sans/gui_logic/models/settings_adjustment_model.py b/scripts/SANS/sans/gui_logic/models/settings_adjustment_model.py index e0b61e44d3e6b50a96afccd8dc7b4b062b31fdb7..647fe72d44b53b8416f91537a58147953a7b1212 100644 --- a/scripts/SANS/sans/gui_logic/models/settings_adjustment_model.py +++ b/scripts/SANS/sans/gui_logic/models/settings_adjustment_model.py @@ -10,8 +10,6 @@ This is one of the two models which is used for the data reduction. It contains are not available in the model associated with the data table. """ -from __future__ import (absolute_import, division, print_function) - from sans.common.enums import SANSInstrument, DataType, FitType, DetectorType from sans.gui_logic.models.model_common import ModelCommon from sans.user_file.settings_tags import TransId, MonId, FitId, fit_general, monitor_file diff --git a/scripts/SANS/sans/gui_logic/models/state_gui_model.py b/scripts/SANS/sans/gui_logic/models/state_gui_model.py index 844bb1f9b6bd40a04c850cdfeff30e8c664cf857..95a384078f5d413b32096794a373f76ef1a9e941 100644 --- a/scripts/SANS/sans/gui_logic/models/state_gui_model.py +++ b/scripts/SANS/sans/gui_logic/models/state_gui_model.py @@ -10,9 +10,6 @@ This is one of the two models which is used for the data reduction. It contains are not available in the model associated with the data table. """ -from __future__ import (absolute_import, division, print_function) - -from mantid.py3compat import ensure_str from sans.common.enums import (ReductionDimensionality, ReductionMode, RangeStepType, SaveType, DetectorType) from sans.gui_logic.models.model_common import ModelCommon @@ -561,7 +558,7 @@ class StateGuiModel(ModelCommon): @q_1d_rebin_string.setter def q_1d_rebin_string(self, value): - self._set_q_1d_limits(rebin_string=ensure_str(value)) + self._set_q_1d_limits(rebin_string=value) @property def q_xy_max(self): diff --git a/scripts/SANS/sans/gui_logic/models/table_model.py b/scripts/SANS/sans/gui_logic/models/table_model.py index 8aa5d9e9cd250243c193ebd363e8d6f3e04895d7..bc889409aad60fc47f9dcab54feabf02f0f204ef 100644 --- a/scripts/SANS/sans/gui_logic/models/table_model.py +++ b/scripts/SANS/sans/gui_logic/models/table_model.py @@ -10,8 +10,6 @@ The main information in the table model are the run numbers and the selected per information regarding the custom output name and the information in the options tab. """ -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import Logger from sans.common.enums import RowState from sans.gui_logic.models.RowEntries import RowEntries diff --git a/scripts/SANS/sans/gui_logic/plotting.py b/scripts/SANS/sans/gui_logic/plotting.py index 68bb30ede429241fa9793c73e4369591741a7c08..101114f3c5527fbceac3abac08b21fd02d7d8c6c 100644 --- a/scripts/SANS/sans/gui_logic/plotting.py +++ b/scripts/SANS/sans/gui_logic/plotting.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import) def get_plotting_module(): diff --git a/scripts/SANS/sans/gui_logic/presenter/add_runs_presenter.py b/scripts/SANS/sans/gui_logic/presenter/add_runs_presenter.py index 28f82e19e11b54858d39b597bd28056bdeac3038..2f457a54b4d1af75ab2a9988d40e95e2ebe90d31 100644 --- a/scripts/SANS/sans/gui_logic/presenter/add_runs_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/add_runs_presenter.py @@ -7,7 +7,7 @@ import os from mantid.kernel import ConfigService -from mantid.py3compat import Enum +from enum import Enum from sans.common.enums import BinningType from sans.common.file_information import SANSFileInformationFactory from sans.gui_logic.gui_common import SANSGuiPropertiesHandler diff --git a/scripts/SANS/sans/gui_logic/presenter/beam_centre_presenter.py b/scripts/SANS/sans/gui_logic/presenter/beam_centre_presenter.py index c91f96f0b5319f9671ec99aa277e9c781e27df65..a69e1b60b45f7c8fe8c543d4cdeb109076f2a400 100644 --- a/scripts/SANS/sans/gui_logic/presenter/beam_centre_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/beam_centre_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import copy from mantid.kernel import Logger diff --git a/scripts/SANS/sans/gui_logic/presenter/diagnostic_presenter.py b/scripts/SANS/sans/gui_logic/presenter/diagnostic_presenter.py index 24a8f09f010b3aea27303565e9c0a87813026ae0..02889d8e6c67b3f3329535e3cbc7f0744e2c34dc 100644 --- a/scripts/SANS/sans/gui_logic/presenter/diagnostic_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/diagnostic_presenter.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from mantid.kernel import Logger from ui.sans_isis.diagnostics_page import DiagnosticsPage from ui.sans_isis.work_handler import WorkHandler diff --git a/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py b/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py index 169601fbac75c3ab285346149591e3e40bd02a74..c31fd97ed3b7386e973dc6fa969d8246a515826b 100644 --- a/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py +++ b/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py @@ -10,8 +10,6 @@ The GuiStateDirector gets the information from the table and state model and gen the main part of the work to an StateDirectorISIS object. """ -from __future__ import (absolute_import, division, print_function) - import copy from sans.common.file_information import SANSFileInformationBlank diff --git a/scripts/SANS/sans/gui_logic/presenter/masking_table_presenter.py b/scripts/SANS/sans/gui_logic/presenter/masking_table_presenter.py index a243d1478e5e9f71230cd5131e96a42063b5f19d..3061d98e5cf5a7d4bbbb84a0bfa682bbe6f5c0bb 100644 --- a/scripts/SANS/sans/gui_logic/presenter/masking_table_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/masking_table_presenter.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + """ The presenter associated with the masking table view. """ -from __future__ import (absolute_import, division, print_function) - from collections import namedtuple import copy diff --git a/scripts/SANS/sans/gui_logic/presenter/presenter_common.py b/scripts/SANS/sans/gui_logic/presenter/presenter_common.py index 3f250ac1e020ba956c6b11cf4e314dc2dbba87ca..713e20692be7f4793e83c169369d3d02cc95b2a9 100644 --- a/scripts/SANS/sans/gui_logic/presenter/presenter_common.py +++ b/scripts/SANS/sans/gui_logic/presenter/presenter_common.py @@ -10,13 +10,10 @@ This abstract class allows other presenters to share functions which set attribu the view or retrieve them from the view """ -from __future__ import (absolute_import, division, print_function) - from abc import ABCMeta, abstractmethod -from six import with_metaclass -class PresenterCommon(with_metaclass(ABCMeta)): +class PresenterCommon(metaclass=ABCMeta): def __init__(self, view, model): self._view = view self._model = model diff --git a/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py b/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py index 4fe9f609ce592f432c50e2319192c65668df4654..e4fd6c0c37da97a6f8d7cccfaac67179979d5182 100644 --- a/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py @@ -10,8 +10,6 @@ This presenter is essentially the brain of the reduction gui. It controls other for presenting and generating the reduction settings. """ -from __future__ import (absolute_import, division, print_function) - import copy import os import time diff --git a/scripts/SANS/sans/gui_logic/presenter/settings_adjustment_presenter.py b/scripts/SANS/sans/gui_logic/presenter/settings_adjustment_presenter.py index a4fc306c30393b91368b341d2ce11cfbc7a1e339..36da3766239a1fed15ce56adfcaa58ceb73a5964 100644 --- a/scripts/SANS/sans/gui_logic/presenter/settings_adjustment_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/settings_adjustment_presenter.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ The settings diagnostic tab which visualizes the SANS state object. """ -from __future__ import (absolute_import, division, print_function) - import copy from sans.common.enums import FitType diff --git a/scripts/SANS/sans/gui_logic/presenter/settings_diagnostic_presenter.py b/scripts/SANS/sans/gui_logic/presenter/settings_diagnostic_presenter.py index 688106be1379034f28609ba16d1f7b12446d3c6a..74b476104fe3b0c4bfb97759011ec7ccfe425159 100644 --- a/scripts/SANS/sans/gui_logic/presenter/settings_diagnostic_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/settings_diagnostic_presenter.py @@ -5,9 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ The settings diagnostic tab which visualizes the SANS state object. """ -from __future__ import (absolute_import, division, print_function) - - import os import json diff --git a/scripts/SANS/sans/sans_batch.py b/scripts/SANS/sans/sans_batch.py index 1302bca43c24b75ee6fbfa3e4375f8bc1bdae9d1..94cd8f6dd2387e5886206409c2f4f21d22912481 100644 --- a/scripts/SANS/sans/sans_batch.py +++ b/scripts/SANS/sans/sans_batch.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name """ SANBatchReduction algorithm is the starting point for any new type reduction, event single reduction""" -from __future__ import (absolute_import, division, print_function) from sans.state.AllStates import AllStates from sans.algorithm_detail.batch_execution import (single_reduction_for_batch) from sans.common.enums import (OutputMode, FindDirectionEnum, DetectorType) diff --git a/scripts/SANS/sans/state/AllStates.py b/scripts/SANS/sans/state/AllStates.py index cc13dbc0f675520a59bfd6fcbc7bc0b05554b6b8..43c56bee76ef855c475d547f871924a32a47c3be 100644 --- a/scripts/SANS/sans/state/AllStates.py +++ b/scripts/SANS/sans/state/AllStates.py @@ -5,13 +5,9 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ Defines the main State object.""" -from __future__ import (absolute_import, division, print_function) - import copy import json -from six import with_metaclass - from sans.common.enums import SANSFacility from sans.state.JsonSerializable import JsonSerializable from sans.state.StateObjects.StateCompatibility import get_compatibility_builder @@ -24,7 +20,7 @@ from sans.state.automatic_setters import automatic_setters # State # ---------------------------------------------------------------------------------------------------------------------- -class AllStates(with_metaclass(JsonSerializable)): +class AllStates(metaclass=JsonSerializable): def __init__(self): diff --git a/scripts/SANS/sans/state/IStateParser.py b/scripts/SANS/sans/state/IStateParser.py index 113027855f667a41ae3ab53de479f9b8e903aa14..5471192a7269f468e90a2d9fed8691566fe20b39 100644 --- a/scripts/SANS/sans/state/IStateParser.py +++ b/scripts/SANS/sans/state/IStateParser.py @@ -6,12 +6,10 @@ # SPDX - License - Identifier: GPL - 3.0 + from abc import ABCMeta, abstractmethod -from six import with_metaclass - from sans.state.AllStates import AllStates -class IStateParser(with_metaclass(ABCMeta)): +class IStateParser(metaclass=ABCMeta): def get_all_states(self): # -> AllStates all_states = AllStates() all_states.data = self.get_state_data() diff --git a/scripts/SANS/sans/state/JsonSerializable.py b/scripts/SANS/sans/state/JsonSerializable.py index 603455249f79efc74c4d45258b585ffa6498c9bd..091f462c493dcc4fcf6da1dccced3618eea8990a 100644 --- a/scripts/SANS/sans/state/JsonSerializable.py +++ b/scripts/SANS/sans/state/JsonSerializable.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from enum import Enum diff --git a/scripts/SANS/sans/state/Serializer.py b/scripts/SANS/sans/state/Serializer.py index 64c168574760688b6a9ce9209e8da2ef897411a6..d75fe4c9b570bd078b9e60bea7d6594fb29de1bd 100644 --- a/scripts/SANS/sans/state/Serializer.py +++ b/scripts/SANS/sans/state/Serializer.py @@ -7,7 +7,6 @@ import json from enum import Enum -import six from sans.state.JsonSerializable import JsonSerializable @@ -53,7 +52,7 @@ class SerializerImpl(json.JSONEncoder): @staticmethod def obj_hook(o): for type_tag, internal_dict in o.items(): - assert isinstance(type_tag, six.string_types) + assert isinstance(type_tag, str) cls_type = JsonSerializable.class_type_from_tag(type_tag) if cls_type: diff --git a/scripts/SANS/sans/state/StateObjects/StateAdjustment.py b/scripts/SANS/sans/state/StateObjects/StateAdjustment.py index fb2a638258a1121175fcbdac3bbbda117fd5e664..9f47aa83cf2c12e5ee92dcb987e98fb43c72eff3 100644 --- a/scripts/SANS/sans/state/StateObjects/StateAdjustment.py +++ b/scripts/SANS/sans/state/StateObjects/StateAdjustment.py @@ -8,19 +8,15 @@ """State describing the adjustment workspace creation of the SANS reduction.""" -from __future__ import (absolute_import, division, print_function) - import copy import json -from six import with_metaclass - from sans.common.enums import SANSFacility from sans.state.JsonSerializable import JsonSerializable from sans.state.automatic_setters import automatic_setters -class StateAdjustment(with_metaclass(JsonSerializable)): +class StateAdjustment(metaclass=JsonSerializable): def __init__(self): super(StateAdjustment, self).__init__() diff --git a/scripts/SANS/sans/state/StateObjects/StateCalculateTransmission.py b/scripts/SANS/sans/state/StateObjects/StateCalculateTransmission.py index 41940749be68de96b3830209ec9f0fb6e684acbd..c98c04f6a761d3d2ae51aec7568aee291c9cfc98 100644 --- a/scripts/SANS/sans/state/StateObjects/StateCalculateTransmission.py +++ b/scripts/SANS/sans/state/StateObjects/StateCalculateTransmission.py @@ -8,11 +8,9 @@ """State describing the calculation of the transmission for SANS reduction.""" -from __future__ import (absolute_import, division, print_function) import json import copy import abc -from six import with_metaclass, itervalues, add_metaclass from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import (RebinType, RangeStepType, FitType, DataType, SANSInstrument) @@ -23,7 +21,7 @@ from sans.state.state_functions import (is_pure_none_or_not_none, validation_mes from sans.common.xml_parsing import get_named_elements_from_ipf_file -class StateTransmissionFit(with_metaclass(JsonSerializable)): +class StateTransmissionFit(metaclass=JsonSerializable): def __init__(self): super(StateTransmissionFit, self).__init__() @@ -59,7 +57,7 @@ class StateTransmissionFit(with_metaclass(JsonSerializable)): "Please see: {0}".format(json.dumps(is_invalid))) -class StateCalculateTransmission(with_metaclass(JsonSerializable)): +class StateCalculateTransmission(metaclass=JsonSerializable): def __init__(self): super(StateCalculateTransmission, self).__init__() # ----------------------- @@ -257,7 +255,7 @@ class StateCalculateTransmission(with_metaclass(JsonSerializable)): "background_TOF_monitor_stop": self.background_TOF_monitor_stop}) is_invalid.update(entry) - for fit_type in itervalues(self.fit): + for fit_type in self.fit.values(): fit_type.validate() if is_invalid: @@ -337,8 +335,7 @@ def set_default_monitors(calculate_transmission_info, data_info): # --------------------------------------- # State builders # --------------------------------------- -@add_metaclass(abc.ABCMeta) -class StateCalculateTransmissionBuilderCommon(object): +class StateCalculateTransmissionBuilderCommon(object, metaclass=abc.ABCMeta): def __init__(self, state): self.state = state diff --git a/scripts/SANS/sans/state/StateObjects/StateCompatibility.py b/scripts/SANS/sans/state/StateObjects/StateCompatibility.py index e8cffd6825f9b92df989f41ed1410ff5bb4ea12e..9ca7c67d9491b35cf4460bd215d686bada6b956f 100644 --- a/scripts/SANS/sans/state/StateObjects/StateCompatibility.py +++ b/scripts/SANS/sans/state/StateObjects/StateCompatibility.py @@ -12,11 +12,8 @@ that we are dealing with a bug """ -from __future__ import (absolute_import, division, print_function) import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import SANSFacility @@ -28,7 +25,7 @@ from sans.common.enums import SANSFacility from sans.state.automatic_setters import automatic_setters -class StateCompatibility(with_metaclass(JsonSerializable)): +class StateCompatibility(metaclass=JsonSerializable): def __init__(self): super(StateCompatibility, self).__init__() self.use_compatibility_mode = False # : Bool diff --git a/scripts/SANS/sans/state/StateObjects/StateConvertToQ.py b/scripts/SANS/sans/state/StateObjects/StateConvertToQ.py index 6084b6019efc074376e732e071d2cbb4f5d6c127..c569f22241cbf19eef98010f31cf64906550ee66 100644 --- a/scripts/SANS/sans/state/StateObjects/StateConvertToQ.py +++ b/scripts/SANS/sans/state/StateObjects/StateConvertToQ.py @@ -8,12 +8,9 @@ """State describing the conversion to momentum transfer""" -from __future__ import (absolute_import, division, print_function) import json import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import (ReductionDimensionality, RangeStepType, SANSFacility) from sans.state.automatic_setters import automatic_setters @@ -25,7 +22,7 @@ from sans.state.state_functions import (is_pure_none_or_not_none, is_not_none_an # State # ---------------------------------------------------------------------------------------------------------------------- -class StateConvertToQ(with_metaclass(JsonSerializable)): +class StateConvertToQ(metaclass=JsonSerializable): def __init__(self): super(StateConvertToQ, self).__init__() diff --git a/scripts/SANS/sans/state/StateObjects/StateData.py b/scripts/SANS/sans/state/StateObjects/StateData.py index a4ce9cb3e64d35fa997f62e559b68a0e7b7354cb..b56dbdbaedbbd1ccba7167489e96833e717d7b08 100644 --- a/scripts/SANS/sans/state/StateObjects/StateData.py +++ b/scripts/SANS/sans/state/StateObjects/StateData.py @@ -7,12 +7,9 @@ # pylint: disable=too-few-public-methods """State about the actual data which is to be reduced.""" -from __future__ import (absolute_import, division, print_function) import json import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import SANSFacility, SANSInstrument import sans.common.constants @@ -24,7 +21,7 @@ from sans.state.state_functions import (is_pure_none_or_not_none, validation_mes # State # ---------------------------------------------------------------------------------------------------------------------- -class StateData(with_metaclass(JsonSerializable)): +class StateData(metaclass=JsonSerializable): ALL_PERIODS = sans.common.constants.ALL_PERIODS def __init__(self): diff --git a/scripts/SANS/sans/state/StateObjects/StateMaskDetectors.py b/scripts/SANS/sans/state/StateObjects/StateMaskDetectors.py index e5720e82c828668228d751cbb90ae4ab185fc533..5d97c566ea9d1049c14c73dcaf313dcaf8d6cbb6 100644 --- a/scripts/SANS/sans/state/StateObjects/StateMaskDetectors.py +++ b/scripts/SANS/sans/state/StateObjects/StateMaskDetectors.py @@ -8,12 +8,9 @@ """State describing the masking behaviour of the SANS reduction.""" -from __future__ import (absolute_import, division, print_function) import json import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.state.automatic_setters import automatic_setters from sans.state.state_functions import (is_pure_none_or_not_none, validation_message, set_detector_names) @@ -83,7 +80,7 @@ def is_spectrum_range_all_on_one_detector(start, stop, invalid_dict, start_name, # StateData # ------------------------------------------------ -class StateMaskDetectors(with_metaclass(JsonSerializable)): +class StateMaskDetectors(metaclass=JsonSerializable): def __init__(self): super(StateMaskDetectors, self).__init__() # Vertical strip masks @@ -171,7 +168,7 @@ class StateMaskDetectors(with_metaclass(JsonSerializable)): "Please see: {0}".format(json.dumps(is_invalid))) -class StateMask(with_metaclass(JsonSerializable)): +class StateMask(metaclass=JsonSerializable): def __init__(self): super(StateMask, self).__init__() # Radius Mask diff --git a/scripts/SANS/sans/state/StateObjects/StateMoveDetectors.py b/scripts/SANS/sans/state/StateObjects/StateMoveDetectors.py index 58e2f6db13dedb1bcf8b2a9ff738acaf09be5682..8f40b5f15835537f59d006dac570cc08d75c1217 100644 --- a/scripts/SANS/sans/state/StateObjects/StateMoveDetectors.py +++ b/scripts/SANS/sans/state/StateObjects/StateMoveDetectors.py @@ -8,13 +8,9 @@ """State for moving workspaces.""" -from __future__ import (absolute_import, division, print_function) - import copy import json -from six import with_metaclass - from sans.common.enums import (CanonicalCoordinates, SANSInstrument, DetectorType) from sans.state.JsonSerializable import JsonSerializable from sans.state.automatic_setters import automatic_setters @@ -25,7 +21,7 @@ from sans.state.state_functions import (validation_message, set_detector_names, # State # ---------------------------------------------------------------------------------------------------------------------- -class StateMoveDetectors(with_metaclass(JsonSerializable)): +class StateMoveDetectors(metaclass=JsonSerializable): def __init__(self): super(StateMoveDetectors, self).__init__() # Translation correction @@ -66,7 +62,7 @@ class StateMoveDetectors(with_metaclass(JsonSerializable)): "Please see: {0}".format(json.dumps(is_invalid))) -class StateMove(with_metaclass(JsonSerializable)): +class StateMove(metaclass=JsonSerializable): def __init__(self): super(StateMove, self).__init__() diff --git a/scripts/SANS/sans/state/StateObjects/StateNormalizeToMonitor.py b/scripts/SANS/sans/state/StateObjects/StateNormalizeToMonitor.py index 1c3b2bc3d33c8cbac70484cd0ed257ddbf198272..ad936dbd5825912500fa4f877257c489445b273f 100644 --- a/scripts/SANS/sans/state/StateObjects/StateNormalizeToMonitor.py +++ b/scripts/SANS/sans/state/StateObjects/StateNormalizeToMonitor.py @@ -8,12 +8,9 @@ """State describing the normalization to the incident monitor for SANS reduction.""" -from __future__ import (absolute_import, division, print_function) import json import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import (RebinType, RangeStepType, SANSInstrument) from sans.state.automatic_setters import automatic_setters @@ -22,7 +19,7 @@ from sans.state.state_functions import (is_pure_none_or_not_none, is_not_none_an from sans.common.xml_parsing import get_named_elements_from_ipf_file -class StateNormalizeToMonitor(with_metaclass(JsonSerializable)): +class StateNormalizeToMonitor(metaclass=JsonSerializable): def __init__(self): super(StateNormalizeToMonitor, self).__init__() self.prompt_peak_correction_min = None # : Float (Optional) diff --git a/scripts/SANS/sans/state/StateObjects/StateReductionMode.py b/scripts/SANS/sans/state/StateObjects/StateReductionMode.py index 26e42ec18bac9cd52d234585762218ff791923e1..8f42a8b05f4765a3af8338c7f2ac26cc47ea2b47 100644 --- a/scripts/SANS/sans/state/StateObjects/StateReductionMode.py +++ b/scripts/SANS/sans/state/StateObjects/StateReductionMode.py @@ -6,13 +6,9 @@ # SPDX - License - Identifier: GPL - 3.0 + """ Defines the state of the reduction.""" -from __future__ import (absolute_import, division, print_function) - import copy import json -from six import (with_metaclass) - from sans.common.enums import (ReductionMode, ReductionDimensionality, FitModeForMerge, SANSFacility, DetectorType) from sans.common.xml_parsing import get_named_elements_from_ipf_file @@ -20,7 +16,7 @@ from sans.state.JsonSerializable import JsonSerializable from sans.state.automatic_setters import automatic_setters -class StateReductionMode(with_metaclass(JsonSerializable)): +class StateReductionMode(metaclass=JsonSerializable): def __init__(self): super(StateReductionMode, self).__init__() self.reduction_mode = ReductionMode.LAB diff --git a/scripts/SANS/sans/state/StateObjects/StateSave.py b/scripts/SANS/sans/state/StateObjects/StateSave.py index af2f9a70158b707096e7feebfdfe17950e631ae5..5309ea1cf560259cc8624012b630afb1064e519c 100644 --- a/scripts/SANS/sans/state/StateObjects/StateSave.py +++ b/scripts/SANS/sans/state/StateObjects/StateSave.py @@ -8,17 +8,14 @@ """ Defines the state of saving.""" -from __future__ import (absolute_import, division, print_function) import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import (SaveType, SANSFacility) from sans.state.automatic_setters import automatic_setters -class StateSave(with_metaclass(JsonSerializable)): +class StateSave(metaclass=JsonSerializable): def __init__(self): super(StateSave, self).__init__() self.zero_free_correction = True # : Bool diff --git a/scripts/SANS/sans/state/StateObjects/StateScale.py b/scripts/SANS/sans/state/StateObjects/StateScale.py index 2538e3108c864db406ccd1395746f7df914e9419..f54dad2b6839bc9fedbcea66e07e26e9ce448563 100644 --- a/scripts/SANS/sans/state/StateObjects/StateScale.py +++ b/scripts/SANS/sans/state/StateObjects/StateScale.py @@ -6,11 +6,8 @@ # SPDX - License - Identifier: GPL - 3.0 + """ Defines the state of the geometry and unit scaling.""" -from __future__ import (absolute_import, division, print_function) import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import SampleShape, SANSFacility @@ -21,7 +18,7 @@ from sans.common.enums import SampleShape, SANSFacility from sans.state.automatic_setters import automatic_setters -class StateScale(with_metaclass(JsonSerializable)): +class StateScale(metaclass=JsonSerializable): def __init__(self): super(StateScale, self).__init__() diff --git a/scripts/SANS/sans/state/StateObjects/StateSliceEvent.py b/scripts/SANS/sans/state/StateObjects/StateSliceEvent.py index f9fbb9a8058cdc783e0d2bac0b968d1beea78874..bb31aaa83547f33d95a6d9902ed8e79bb54f14f6 100644 --- a/scripts/SANS/sans/state/StateObjects/StateSliceEvent.py +++ b/scripts/SANS/sans/state/StateObjects/StateSliceEvent.py @@ -6,12 +6,9 @@ # SPDX - License - Identifier: GPL - 3.0 + """ Defines the state of the event slices which should be reduced.""" -from __future__ import (absolute_import, division, print_function) import json import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.state.automatic_setters import automatic_setters from sans.state.state_functions import (is_pure_none_or_not_none, validation_message) @@ -22,7 +19,7 @@ from sans.common.enums import SANSFacility # State # ---------------------------------------------------------------------------------------------------------------------- -class StateSliceEvent(with_metaclass(JsonSerializable)): +class StateSliceEvent(metaclass=JsonSerializable): def __init__(self): super(StateSliceEvent, self).__init__() diff --git a/scripts/SANS/sans/state/StateObjects/StateWavelength.py b/scripts/SANS/sans/state/StateObjects/StateWavelength.py index 349bca141b5521fb086b7fb6bd64ba4a2d66236c..0e35502c83bc74f3c0eef6c049d20be0599ab116 100644 --- a/scripts/SANS/sans/state/StateObjects/StateWavelength.py +++ b/scripts/SANS/sans/state/StateObjects/StateWavelength.py @@ -6,19 +6,16 @@ # SPDX - License - Identifier: GPL - 3.0 + """ Defines the state of the event slices which should be reduced.""" -from __future__ import (absolute_import, division, print_function) import json import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.common.enums import (RebinType, RangeStepType, SANSFacility) from sans.state.automatic_setters import automatic_setters from sans.state.state_functions import (is_not_none_and_first_larger_than_second, one_is_none, validation_message) -class StateWavelength(with_metaclass(JsonSerializable)): +class StateWavelength(metaclass=JsonSerializable): def __init__(self): super(StateWavelength, self).__init__() self.rebin_type = RebinType.REBIN diff --git a/scripts/SANS/sans/state/StateObjects/StateWavelengthAndPixelAdjustment.py b/scripts/SANS/sans/state/StateObjects/StateWavelengthAndPixelAdjustment.py index b358a189a75f8493ed29a1bf78eb4adf1480921f..b7248b1481994cef9b071df8ce32c2aa6a056813 100644 --- a/scripts/SANS/sans/state/StateObjects/StateWavelengthAndPixelAdjustment.py +++ b/scripts/SANS/sans/state/StateObjects/StateWavelengthAndPixelAdjustment.py @@ -8,19 +8,16 @@ """State describing the creation of pixel and wavelength adjustment workspaces for SANS reduction.""" -from __future__ import (absolute_import, division, print_function) import json import copy -from six import with_metaclass - from sans.state.JsonSerializable import JsonSerializable from sans.state.automatic_setters import automatic_setters from sans.state.state_functions import (is_not_none_and_first_larger_than_second, one_is_none, validation_message) from sans.common.enums import (RangeStepType, DetectorType, SANSFacility) -class StateAdjustmentFiles(with_metaclass(JsonSerializable)): +class StateAdjustmentFiles(metaclass=JsonSerializable): def __init__(self): super(StateAdjustmentFiles, self).__init__() self.pixel_adjustment_file = None # : Str() @@ -36,7 +33,7 @@ class StateAdjustmentFiles(with_metaclass(JsonSerializable)): "Please see: {0}".format(json.dumps(is_invalid))) -class StateWavelengthAndPixelAdjustment(with_metaclass(JsonSerializable)): +class StateWavelengthAndPixelAdjustment(metaclass=JsonSerializable): def __init__(self): super(StateWavelengthAndPixelAdjustment, self).__init__() self.wavelength_low = None # : List[Float] (Positive) diff --git a/scripts/SANS/sans/state/automatic_setters.py b/scripts/SANS/sans/state/automatic_setters.py index 07b7b08db266cd7754252657a7c38b0856588f27..f132c6f38cd912d07ec1779381c159fa2d73e418 100644 --- a/scripts/SANS/sans/state/automatic_setters.py +++ b/scripts/SANS/sans/state/automatic_setters.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from functools import (partial, wraps) import inspect diff --git a/scripts/SANS/sans/state/state_functions.py b/scripts/SANS/sans/state/state_functions.py index f62636079d69955817bc9bacfa11817b04bffc53..f83f0cf228c36563b4278ed45984512f36d2d4af 100644 --- a/scripts/SANS/sans/state/state_functions.py +++ b/scripts/SANS/sans/state/state_functions.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + """Set of general purpose functions which are related to the SANSState approach.""" -from __future__ import (absolute_import, division, print_function) - from sans.common.enums import (DetectorType) from sans.common.xml_parsing import (get_monitor_names_from_idf_file, get_named_elements_from_ipf_file) diff --git a/scripts/SANS/sans/test_helper/mock_objects.py b/scripts/SANS/sans/test_helper/mock_objects.py index c4b275d8a2f215259ba5af6e7cbc864724ebbb3d..54124d691afba235083e748fb394b51edf9ee715 100644 --- a/scripts/SANS/sans/test_helper/mock_objects.py +++ b/scripts/SANS/sans/test_helper/mock_objects.py @@ -4,13 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import) - from functools import (partial) -from six import with_metaclass - -from mantid.py3compat import mock +from unittest import mock from sans.gui_logic.presenter.run_tab_presenter import RunTabPresenter from sans.common.enums import (RangeStepType, OutputMode, SANSFacility, SANSInstrument) from sans.state.JsonSerializable import JsonSerializable @@ -240,7 +236,7 @@ def create_mock_view2(user_file_path, batch_file_path=None): return view -class FakeState(with_metaclass(JsonSerializable)): +class FakeState(metaclass=JsonSerializable): def __init__(self): super(FakeState, self).__init__() self.dummy_state = "dummy_state" diff --git a/scripts/SANS/sans/test_helper/test_director.py b/scripts/SANS/sans/test_helper/test_director.py index a82aaf1363f97dd296105b57f5489d3d2f57ef73..2f217368778f7a22ba51dca2bcee0002c0a3df05 100644 --- a/scripts/SANS/sans/test_helper/test_director.py +++ b/scripts/SANS/sans/test_helper/test_director.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + """ A Test director """ -from __future__ import (absolute_import, division, print_function) from sans.state.StateObjects.StateData import get_data_builder from sans.state.StateObjects.StateMoveDetectors import get_move_builder from sans.state.StateObjects.StateReductionMode import get_reduction_mode_builder diff --git a/scripts/SANS/sans/test_helper/user_file_test_helper.py b/scripts/SANS/sans/test_helper/user_file_test_helper.py index 99467a5006e7e0b70f6a825bc742fcff8258820c..66e10dc04be82b136e550b9e09e430117b477285 100644 --- a/scripts/SANS/sans/test_helper/user_file_test_helper.py +++ b/scripts/SANS/sans/test_helper/user_file_test_helper.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import tempfile base_user_file = ("PRINT for changer\n" diff --git a/scripts/SANS/sans/user_file/settings_tags.py b/scripts/SANS/sans/user_file/settings_tags.py index 37966f394e6ab83d95a36dce414e5ee610fec5ab..ac0f3795f001da25bf4dd5eaaa4a69738b17e1cc 100644 --- a/scripts/SANS/sans/user_file/settings_tags.py +++ b/scripts/SANS/sans/user_file/settings_tags.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from collections import namedtuple -from mantid.py3compat import Enum +from enum import Enum # ---------------------------------------------------------------------------------------------------------------------- # Named tuples for passing around data in a structured way, a bit like a plain old c-struct. diff --git a/scripts/SANS/sans/user_file/user_file_parser.py b/scripts/SANS/sans/user_file/user_file_parser.py index 49d80d182f9330017f1554c9cbedbca85d27e207..e4b7618d37e02cc81ecf70d1346586b079c5f3e9 100644 --- a/scripts/SANS/sans/user_file/user_file_parser.py +++ b/scripts/SANS/sans/user_file/user_file_parser.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-lines, invalid-name, too-many-instance-attributes, too-many-branches, too-few-public-methods -from __future__ import (absolute_import, division, print_function) import abc import re from math import copysign diff --git a/scripts/SANS/sans/user_file/user_file_reader.py b/scripts/SANS/sans/user_file/user_file_reader.py index 9641f2e638c3a35f4bf0899025e2f429967a32dc..25ea4e1a1c84701504fa797c3c046e6878823415 100644 --- a/scripts/SANS/sans/user_file/user_file_reader.py +++ b/scripts/SANS/sans/user_file/user_file_reader.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from sans.common.file_information import find_full_file_path from sans.user_file.user_file_parser import UserFileParser diff --git a/scripts/SCD_Reduction/BVGFitTools.py b/scripts/SCD_Reduction/BVGFitTools.py index 20afbd64d45cb87d5358ddce50201af4585deb00..8a8ae09f2221aa8f1597ec5b2ee5e99ab543ef23 100644 --- a/scripts/SCD_Reduction/BVGFitTools.py +++ b/scripts/SCD_Reduction/BVGFitTools.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import numpy as np import matplotlib.pyplot as plt import ICCFitTools as ICCFT diff --git a/scripts/SCD_Reduction/ICCFitTools.py b/scripts/SCD_Reduction/ICCFitTools.py index 333bbee867610ec25fc4d4f9c9af81e747ac8db0..b566fabe9f844837bcfb103b3ff9f434356f2df3 100644 --- a/scripts/SCD_Reduction/ICCFitTools.py +++ b/scripts/SCD_Reduction/ICCFitTools.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import matplotlib.pyplot as plt import numpy as np import sys diff --git a/scripts/SCD_Reduction/ReduceDictionary.py b/scripts/SCD_Reduction/ReduceDictionary.py index f9a1615947f883dda04005f3373188dbce389841..558d66775d4bd9f262d3406227de4b510404160b 100644 --- a/scripts/SCD_Reduction/ReduceDictionary.py +++ b/scripts/SCD_Reduction/ReduceDictionary.py @@ -19,7 +19,6 @@ # The run numbers themselves may be specified as a comma separated list of # individual run numbers, or ranges specified with a colon separator. # -from __future__ import (absolute_import, division, print_function) def LoadDictionary( *filenames, **kwargs ): diff --git a/scripts/SCD_Reduction/ReduceSCD_OneRun.py b/scripts/SCD_Reduction/ReduceSCD_OneRun.py index d35a0e36268acd24f5eb643305254fc60e0b7c4b..7f326ba5657aa51070fbded0b00268074fe0a9fd 100644 --- a/scripts/SCD_Reduction/ReduceSCD_OneRun.py +++ b/scripts/SCD_Reduction/ReduceSCD_OneRun.py @@ -41,7 +41,6 @@ # the use of either monitor counts (True) or proton charge (False) for # scaling. -from __future__ import (absolute_import, division, print_function) import os import sys import time diff --git a/scripts/SCD_Reduction/ReduceSCD_Parallel.py b/scripts/SCD_Reduction/ReduceSCD_Parallel.py index 0704b04f9bafd29315b01688e3c8f65df7d2f507..b4bd6f57a6a1d3551f90400a4d8f62971e321a0b 100644 --- a/scripts/SCD_Reduction/ReduceSCD_Parallel.py +++ b/scripts/SCD_Reduction/ReduceSCD_Parallel.py @@ -40,7 +40,6 @@ # run or the loaded matirix instead of the default FFT method # -from __future__ import (absolute_import, division, print_function) import os import sys import threading diff --git a/scripts/SCD_Reduction/SCDCalibratePanelsResults.py b/scripts/SCD_Reduction/SCDCalibratePanelsResults.py index 1d894a8ce841a732a2a65fa758ecba561b87805c..bdddb5f7fbb8e2b802fca4369d727922bce20c0e 100755 --- a/scripts/SCD_Reduction/SCDCalibratePanelsResults.py +++ b/scripts/SCD_Reduction/SCDCalibratePanelsResults.py @@ -10,7 +10,6 @@ Plot data in SCDcalib.log file from Mantid SCD Calibration. A. J. Schultz, V. E. Lynch, August 2015 """ -from __future__ import (absolute_import, division, print_function) import pylab import os import math diff --git a/scripts/SliceViewAnimator.py b/scripts/SliceViewAnimator.py index c965c4f64eac171b15544b3b32222a0c5e674321..8cc2701b20006174a07e8aa6a825800e20a7a3d1 100644 --- a/scripts/SliceViewAnimator.py +++ b/scripts/SliceViewAnimator.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=too-many-arguments -from __future__ import (absolute_import, division, print_function) import numpy from wand.image import Image from wand.drawing import Drawing diff --git a/scripts/TemporaryREF_MScripts/testCenterREF_M.py b/scripts/TemporaryREF_MScripts/testCenterREF_M.py index 9eae563e35387b64e89c3594e63b4b59a5ff242a..84cd1881356a1d087cc9f5a673422e828af418c9 100644 --- a/scripts/TemporaryREF_MScripts/testCenterREF_M.py +++ b/scripts/TemporaryREF_MScripts/testCenterREF_M.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import numpy as np import mantid diff --git a/scripts/TofConverter.py b/scripts/TofConverter.py index 315bd032a038d5e46b07472243b9eb540888d06a..b3771cf72ff9d9a924e49321d49fa524043270f1 100644 --- a/scripts/TofConverter.py +++ b/scripts/TofConverter.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from TofConverter import converterGUI from mantidqt.gui_helper import get_qapplication diff --git a/scripts/TofConverter/convertUnits.py b/scripts/TofConverter/convertUnits.py index 1c916c6d3eea61745caad40328ab6fcebc46ac3e..de2fddb9e87e40033c84fe4b4ee35d37d419e496 100644 --- a/scripts/TofConverter/convertUnits.py +++ b/scripts/TofConverter/convertUnits.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,too-many-branches -from __future__ import (absolute_import, division, print_function) import math # Used by converter GUI to do unit conversions diff --git a/scripts/TofConverter/converterGUI.py b/scripts/TofConverter/converterGUI.py index 6e2de610d9ff1e2864f9b2a5b8b4ec02e5490347..44c95ca0433ba9b52a6b29a11a8381d01c3fe7ca 100644 --- a/scripts/TofConverter/converterGUI.py +++ b/scripts/TofConverter/converterGUI.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) from qtpy.QtWidgets import QMainWindow, QMessageBox from qtpy.QtGui import QDoubleValidator from qtpy import QtCore diff --git a/scripts/Vates/SXD_NaCl.py b/scripts/Vates/SXD_NaCl.py index f70465c2f88c86ef74ceb7cc5fe4b664d14b105f..38b3c6f505194cd952ee135cf08118cc80b7a172 100644 --- a/scripts/Vates/SXD_NaCl.py +++ b/scripts/Vates/SXD_NaCl.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as mantid diff --git a/scripts/directtools/__init__.py b/scripts/directtools/__init__.py index b52c44adb2f81a9aec0e8c0b90685e9af018d79c..987286546ade402616ad7d3aeb8e417a10a422bf 100644 --- a/scripts/directtools/__init__.py +++ b/scripts/directtools/__init__.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import collections from directtools import _validate from mantid import logger, mtd diff --git a/scripts/directtools/_validate.py b/scripts/directtools/_validate.py index 72d67a16ce117700d1f3dcd0970184d5bb63205d..e69a20155fa42fbdaabaa947d15e1596d488260a 100644 --- a/scripts/directtools/_validate.py +++ b/scripts/directtools/_validate.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) def _isDOS(workspace): diff --git a/scripts/plotting_test.py b/scripts/plotting_test.py index 91df6bc12ec2e31b361863bad90b3f30a27739a8..cecfc43b99b0790db59090860839455a90687e24 100644 --- a/scripts/plotting_test.py +++ b/scripts/plotting_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - from PyQt4 import QtGui import sys diff --git a/scripts/pythonTSV.py b/scripts/pythonTSV.py index 4143018b2d143be79e13b61c30c0281d2ba0f35a..d422e447dfbeeea1b48b993ede10c3706d9ab2a0 100644 --- a/scripts/pythonTSV.py +++ b/scripts/pythonTSV.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - """ Some simple helpers for dealing with the TSV """ diff --git a/scripts/reducer_singleton.py b/scripts/reducer_singleton.py index e259d5dcd5609f2d7165076243620e67a764c0df..bd3ca52725b6b6c3f95905d90e19be7e191026b3 100644 --- a/scripts/reducer_singleton.py +++ b/scripts/reducer_singleton.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import random import string import os diff --git a/scripts/reduction/__init__.py b/scripts/reduction/__init__.py index 65c20f65fb36ae621a4e42a08c2068d633fd472b..4b9ad48081b83eef158cba2ab6a9eb432011c525 100644 --- a/scripts/reduction/__init__.py +++ b/scripts/reduction/__init__.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from reduction.reducer import * # noqa: F401 from reduction.instrument import * # noqa: F401 from reduction.find_data import find_data, find_file # noqa: F401 diff --git a/scripts/reduction/command_interface.py b/scripts/reduction/command_interface.py index d8cfa7f3377958812c4aa4cb47da8982d99e375c..a749ca08d1e288fa9dd0346d5bb342c9c1d3db7d 100644 --- a/scripts/reduction/command_interface.py +++ b/scripts/reduction/command_interface.py @@ -8,7 +8,6 @@ """ List of user commands. """ -from __future__ import (absolute_import, division, print_function) from reduction.reducer import Reducer diff --git a/scripts/reduction/find_data.py b/scripts/reduction/find_data.py index 3adb286336d6462673b3543eb4c16c31360d861c..dbd1d7909179e48b881216b402410a4e23d010ae 100644 --- a/scripts/reduction/find_data.py +++ b/scripts/reduction/find_data.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,redefined-builtin -from __future__ import (absolute_import, division, print_function) import os import mantid.api as api from mantid.simpleapi import * diff --git a/scripts/reduction/instrument.py b/scripts/reduction/instrument.py index 0431e867eabe5649d4f0cd985648c54ff68fb0b3..108112ed44796a6b0b1e713083bd9512559a195f 100644 --- a/scripts/reduction/instrument.py +++ b/scripts/reduction/instrument.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import mantid.simpleapi as api from mantid.kernel import * from mantid.api import * diff --git a/scripts/reduction/instruments/example/ExampleRedStep.py b/scripts/reduction/instruments/example/ExampleRedStep.py index 574f12ae1178be505155203411ad924875dc3054..299931bd81ea0fbf33d0dcbe62b1f94927ea11ae 100644 --- a/scripts/reduction/instruments/example/ExampleRedStep.py +++ b/scripts/reduction/instruments/example/ExampleRedStep.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=no-init -from __future__ import (absolute_import, division, print_function) from mantid.kernel import * from mantid.api import * from mantid.simpleapi import * diff --git a/scripts/reduction/instruments/example/example_reducer.py b/scripts/reduction/instruments/example/example_reducer.py index f26589d176d799f924075c3c2b7d41c1e537d33e..ae9d46df30231a08025664be4937d7903aad3900 100644 --- a/scripts/reduction/instruments/example/example_reducer.py +++ b/scripts/reduction/instruments/example/example_reducer.py @@ -8,7 +8,6 @@ """ Simple Reducer example """ -from __future__ import (absolute_import, division, print_function) from reduction import Reducer from reduction.instruments.example.ExampleRedStep import ExampleRedStep # Validate_step is a decorator that allows both Python algorithms and ReductionStep objects to be passed to the Reducer. diff --git a/scripts/reduction/instruments/inelastic/direct_command_interface.py b/scripts/reduction/instruments/inelastic/direct_command_interface.py index 243e1d710e393cc365b9468df7bf44512c2ff418..8320b1700c35712e12bcda9ce1a23e53269256ca 100644 --- a/scripts/reduction/instruments/inelastic/direct_command_interface.py +++ b/scripts/reduction/instruments/inelastic/direct_command_interface.py @@ -8,7 +8,6 @@ """ Command set for Direct Geometry reduction """ -from __future__ import (absolute_import, division, print_function) # Import the specific commands that we need from mantid.api import AlgorithmManager from reduction.command_interface import * diff --git a/scripts/reduction/instruments/sans/sans_reducer.py b/scripts/reduction/instruments/sans/sans_reducer.py index e304c2820a178bcffa8465b3c98f7aaa129737f1..f7c5b9cc908a0989980075b77c6da7359d6dd1e2 100644 --- a/scripts/reduction/instruments/sans/sans_reducer.py +++ b/scripts/reduction/instruments/sans/sans_reducer.py @@ -9,7 +9,6 @@ a predefined set of reduction steps to be followed. The actual ReductionStep objects executed for each of those steps can be modified. """ -from __future__ import (absolute_import, division, print_function) from reduction import Reducer from reduction import ReductionStep from reduction import validate_step diff --git a/scripts/reduction/instruments/sans/sans_reduction_steps.py b/scripts/reduction/instruments/sans/sans_reduction_steps.py index 122e3f1351e2df54ff4dffd08f64e2aa11af2cb3..e7e44ab53dcad5decfa1ad09942d2f5f46bb6ff4 100644 --- a/scripts/reduction/instruments/sans/sans_reduction_steps.py +++ b/scripts/reduction/instruments/sans/sans_reduction_steps.py @@ -8,7 +8,6 @@ """ Implementation of reduction steps for SANS """ -from __future__ import (absolute_import, division, print_function) import math import pickle from reduction import ReductionStep diff --git a/scripts/reduction/reducer.py b/scripts/reduction/reducer.py index f38d48478d56087eeac2a1883f6b872875e8be21..76c7527a1948ec23ce098957a93fc49a1010d0cf 100644 --- a/scripts/reduction/reducer.py +++ b/scripts/reduction/reducer.py @@ -26,7 +26,6 @@ instrument settings. """ -from __future__ import (absolute_import, division, print_function) import os import sys import time diff --git a/scripts/reduction_workflow/command_interface.py b/scripts/reduction_workflow/command_interface.py index 18172a08d2de0b04b294e1fd7caec90655eb3ff6..9e0a9b50a4a9f1006f91f2605b92c1126e9ebf71 100644 --- a/scripts/reduction_workflow/command_interface.py +++ b/scripts/reduction_workflow/command_interface.py @@ -8,7 +8,6 @@ """ List of user commands. """ -from __future__ import (absolute_import, division, print_function) from reduction_workflow.reducer import Reducer diff --git a/scripts/reduction_workflow/find_data.py b/scripts/reduction_workflow/find_data.py index c36f23c8c87010de1ebc315e28de2f26cd3c263b..2d5b7e41bd2da3cbbb2650cf59fb192f9f616077 100644 --- a/scripts/reduction_workflow/find_data.py +++ b/scripts/reduction_workflow/find_data.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) - import os from mantid.kernel import ConfigService, Logger from mantid.api import FileFinder diff --git a/scripts/reduction_workflow/instruments/sans/hfir_command_interface.py b/scripts/reduction_workflow/instruments/sans/hfir_command_interface.py index 05e5ce484c37fd3f90add5c4fe8fd309f4b9e0af..6138a7c8344489c400d02fb2abcabcf49566b427 100644 --- a/scripts/reduction_workflow/instruments/sans/hfir_command_interface.py +++ b/scripts/reduction_workflow/instruments/sans/hfir_command_interface.py @@ -10,7 +10,6 @@ List of common user commands for HFIR SANS """ -from __future__ import (absolute_import, division, print_function) import os.path import mantid diff --git a/scripts/reduction_workflow/instruments/sans/hfir_instrument.py b/scripts/reduction_workflow/instruments/sans/hfir_instrument.py index b2963de1eb10e50323906409967693674df3d7df..ae4cf028477cf64ed827aaf6e586d87252e9ef57 100644 --- a/scripts/reduction_workflow/instruments/sans/hfir_instrument.py +++ b/scripts/reduction_workflow/instruments/sans/hfir_instrument.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=invalid-name,too-many-arguments,too-many-branches -from __future__ import (absolute_import, division, print_function) import sys from mantid.kernel import Logger diff --git a/scripts/reduction_workflow/instruments/sans/sns_command_interface.py b/scripts/reduction_workflow/instruments/sans/sns_command_interface.py index 1928f771ada13f84ea4b0c7384fb157b1fe9dd09..4f2da87420a08abd012f1756152d48aa3be92fd9 100644 --- a/scripts/reduction_workflow/instruments/sans/sns_command_interface.py +++ b/scripts/reduction_workflow/instruments/sans/sns_command_interface.py @@ -9,7 +9,6 @@ Command set for EQSANS reduction """ # Import the specific commands that we need - some of these are used in systemtests -from __future__ import (absolute_import, division, print_function) from reduction_workflow.command_interface import * # The following imports allow users to import this file and have all functionality automatically imported diff --git a/scripts/reduction_workflow/instruments/sans/sns_instrument.py b/scripts/reduction_workflow/instruments/sans/sns_instrument.py index fa4af710cd42907626e10a3a49ff28a1916e2c42..3a7af9acad99e415d5710b8bdf84c34ba26a4a65 100644 --- a/scripts/reduction_workflow/instruments/sans/sns_instrument.py +++ b/scripts/reduction_workflow/instruments/sans/sns_instrument.py @@ -8,8 +8,6 @@ """ Instrument-specific utility functions for EQSANS """ -from __future__ import (absolute_import, division, print_function) - from .hfir_instrument import _get_pixel_info diff --git a/scripts/reduction_workflow/reducer.py b/scripts/reduction_workflow/reducer.py index 4dc396f5ded1c28f624653f7424bd506613ea045..72f93e9ef7b1c972442a569334529987c72faddb 100644 --- a/scripts/reduction_workflow/reducer.py +++ b/scripts/reduction_workflow/reducer.py @@ -8,7 +8,6 @@ """ Base reduction class. Uses version 2 python API. """ -from __future__ import (absolute_import, division, print_function) import os import sys import time diff --git a/scripts/test/Abins/AbinsAtomsDataTest.py b/scripts/test/Abins/AbinsAtomsDataTest.py index bafa00118b75ff6b85a483044e72ba09ff10ec7b..ac446dd261da2588b1612946b6527393278c13b2 100644 --- a/scripts/test/Abins/AbinsAtomsDataTest.py +++ b/scripts/test/Abins/AbinsAtomsDataTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import numpy as np diff --git a/scripts/test/Abins/AbinsBroadeningTest.py b/scripts/test/Abins/AbinsBroadeningTest.py index 05518c4e0ec066c542d87b0b30b6d12fb5d31136..b40d3979beecb523bb357d3db6d30f8bbcb1d3c6 100644 --- a/scripts/test/Abins/AbinsBroadeningTest.py +++ b/scripts/test/Abins/AbinsBroadeningTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import numpy as np @@ -13,6 +12,7 @@ from scipy.stats import norm as spnorm from AbinsModules.Instruments import Broadening + class AbinsBroadeningTest(unittest.TestCase): """ Test Abins broadening functions diff --git a/scripts/test/Abins/AbinsCalculateDWSingleCrystalTest.py b/scripts/test/Abins/AbinsCalculateDWSingleCrystalTest.py index 3b5ab0d2f024dec084f6e9527d270c9140b943f7..6066f59e748c6524839c599d5958f4c58d5092b2 100644 --- a/scripts/test/Abins/AbinsCalculateDWSingleCrystalTest.py +++ b/scripts/test/Abins/AbinsCalculateDWSingleCrystalTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import * import numpy as np diff --git a/scripts/test/Abins/AbinsCalculatePowderTest.py b/scripts/test/Abins/AbinsCalculatePowderTest.py index 4e0bc67201474e7434b73759a6a757ebf15da678..6b56766a25ecdff98ac6d6195fa74f6690592925 100644 --- a/scripts/test/Abins/AbinsCalculatePowderTest.py +++ b/scripts/test/Abins/AbinsCalculatePowderTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import numpy as np diff --git a/scripts/test/Abins/AbinsCalculateQToscaTest.py b/scripts/test/Abins/AbinsCalculateQToscaTest.py index e6114a5292117d873718c1f7d0d3d9f7709bc948..de2cd0637aac26d74ec9d422caa2ca7c3f2cd022 100644 --- a/scripts/test/Abins/AbinsCalculateQToscaTest.py +++ b/scripts/test/Abins/AbinsCalculateQToscaTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import numpy as np from mantid.simpleapi import * diff --git a/scripts/test/Abins/AbinsCalculateSPowderTest.py b/scripts/test/Abins/AbinsCalculateSPowderTest.py index ba6eebedeb77a151d4dcbfde0722b5175cc32248..455801eb6663ac488e215b7c6b309e0fd19e412f 100644 --- a/scripts/test/Abins/AbinsCalculateSPowderTest.py +++ b/scripts/test/Abins/AbinsCalculateSPowderTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import json diff --git a/scripts/test/Abins/AbinsCalculateSingleCrystalTest.py b/scripts/test/Abins/AbinsCalculateSingleCrystalTest.py index 052f162000f6d0d55787c04ee546cccd9de82b13..caa137c224b648e8887f3f2a12d220e9948c3b7d 100644 --- a/scripts/test/Abins/AbinsCalculateSingleCrystalTest.py +++ b/scripts/test/Abins/AbinsCalculateSingleCrystalTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import numpy as np diff --git a/scripts/test/Abins/AbinsDWSingleCrystalDataTest.py b/scripts/test/Abins/AbinsDWSingleCrystalDataTest.py index bfd0d1659b3fc6954bcf0fc8a82e6566e8e1f7b5..dfa632d6fd1c486add5da46aca296da9e0fa81d8 100644 --- a/scripts/test/Abins/AbinsDWSingleCrystalDataTest.py +++ b/scripts/test/Abins/AbinsDWSingleCrystalDataTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import numpy as np diff --git a/scripts/test/Abins/AbinsFrequencyPowderGeneratorTest.py b/scripts/test/Abins/AbinsFrequencyPowderGeneratorTest.py index 7438a48bf87efa4ec88463477c0526b73f7b61e7..b7d07d67e5dcf1cd91362894c7e213b956ea6957 100644 --- a/scripts/test/Abins/AbinsFrequencyPowderGeneratorTest.py +++ b/scripts/test/Abins/AbinsFrequencyPowderGeneratorTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) from itertools import product import unittest @@ -15,6 +14,7 @@ from mantid.simpleapi import logger from AbinsModules import FrequencyPowderGenerator, AbinsParameters, AbinsConstants from AbinsModules.AbinsConstants import INT_TYPE, FLOAT_TYPE + class AbinsFrequencyPowderGeneratorTest(unittest.TestCase): def setUp(self): diff --git a/scripts/test/Abins/AbinsIOmoduleTest.py b/scripts/test/Abins/AbinsIOmoduleTest.py index f4a60685fcdcbac9531e615f5d22c224298961aa..6c91cef88c4f53bce577206328568425d462db00 100644 --- a/scripts/test/Abins/AbinsIOmoduleTest.py +++ b/scripts/test/Abins/AbinsIOmoduleTest.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + - -from __future__ import (absolute_import, division, print_function) -import six import unittest import numpy as np from mantid.simpleapi import logger @@ -102,31 +99,6 @@ class AbinsIOmoduleTest(unittest.TestCase): self.assertRaises(ValueError, self.loader.load, list_of_datasets=1) - def _py2_unicode_laundering(self): - if six.PY2: - unit_data_list = [u'1 Ã…', u'2 Ã…', u'3 Ã…'] - cleaned_data_list = IOmodule._convert_unicode_to_str(unit_data_list) - self.assertNotIn(u'2 Ã…', cleaned_data_list) - self.assertIn('2 \xc3\x85', cleaned_data_list) - - unit_data_nested = [[u'1 Ã…', u'2 Ã…'], [u'3 Ã…', u'4 Ã…']] - cleaned_data_nested = IOmodule._convert_unicode_to_str(unit_data_nested) - self.assertNotIn(u'3 Ã…', cleaned_data_nested[1]) - self.assertIn('3 \xc3\x85', cleaned_data_nested[1]) - - unit_data_dict = {u'1 Ã…': 1, u'2 Ã…': 2, - 'tens': {u'10 Ã…': 10, u'20 Ã…': 20}} - cleaned_data_dict = IOmodule._convert_unicode_to_str(unit_data_dict) - self.assertNotIn(u'2 Ã…', cleaned_data_dict) - self.assertNotIn(u'10 Ã…', cleaned_data_dict['tens']) - self.assertIn('10 \xc3\x85', cleaned_data_dict['tens']) - - for item in ('x', 1, 2.34, (1, 2)): - self.assertEqual(IOmodule._convert_unicode_to_str(item), item) - - self.assertIsInstance(IOmodule._convert_unicode_to_str(np.ones(5)), - np.ndarray) - def runTest(self): self._save_stuff() @@ -144,7 +116,6 @@ class AbinsIOmoduleTest(unittest.TestCase): self._loading_datasets() self._loading_structured_datasets() - self._py2_unicode_laundering() if __name__ == '__main__': unittest.main() diff --git a/scripts/test/Abins/AbinsInstrumentTest.py b/scripts/test/Abins/AbinsInstrumentTest.py index c64f269d667889acb31cbc73f7e93f68540d3c34..da7da5353a1348b264a1f5148d9f8ee00eeb4413 100644 --- a/scripts/test/Abins/AbinsInstrumentTest.py +++ b/scripts/test/Abins/AbinsInstrumentTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from AbinsModules.Instruments.Instrument import Instrument diff --git a/scripts/test/Abins/AbinsKpointsDataTest.py b/scripts/test/Abins/AbinsKpointsDataTest.py index f6aee35c9ed4749557f41035fa58a3c20d14ab40..ae553c6d022942e967b3a324e692dcbac6361ead 100644 --- a/scripts/test/Abins/AbinsKpointsDataTest.py +++ b/scripts/test/Abins/AbinsKpointsDataTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import numpy as np from mantid.simpleapi import logger diff --git a/scripts/test/Abins/AbinsLoadCASTEPTest.py b/scripts/test/Abins/AbinsLoadCASTEPTest.py index c44ca86abd524a08e9247615c83d19b681c9d385..a50fc7bccff05e0c008ed8dc9c4d9e4a4c0d3342 100644 --- a/scripts/test/Abins/AbinsLoadCASTEPTest.py +++ b/scripts/test/Abins/AbinsLoadCASTEPTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import mantid # has to be imported so that AbinsModules can be found import AbinsModules diff --git a/scripts/test/Abins/AbinsLoadCRYSTALTest.py b/scripts/test/Abins/AbinsLoadCRYSTALTest.py index d14985b291c188c812d29ad3ec7cf7b2acb726d7..c3a8a0433e3da3905d51cbc1f7be77ca8bb19e40 100644 --- a/scripts/test/Abins/AbinsLoadCRYSTALTest.py +++ b/scripts/test/Abins/AbinsLoadCRYSTALTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import AbinsModules diff --git a/scripts/test/Abins/AbinsLoadDMOL3Test.py b/scripts/test/Abins/AbinsLoadDMOL3Test.py index 56d0d2d752fb7151ea69ab217bb4cfc7e44e155e..cd5b6ac56ed9ba31bc719a97e8147bcb4828fcc9 100644 --- a/scripts/test/Abins/AbinsLoadDMOL3Test.py +++ b/scripts/test/Abins/AbinsLoadDMOL3Test.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import AbinsModules diff --git a/scripts/test/Abins/AbinsLoadGAUSSIANTest.py b/scripts/test/Abins/AbinsLoadGAUSSIANTest.py index 54fba2e5e8eff720a0829667da1a8c9a51db09d0..981996ee1bb97299ce44c84ef51928dd19c2b0c2 100644 --- a/scripts/test/Abins/AbinsLoadGAUSSIANTest.py +++ b/scripts/test/Abins/AbinsLoadGAUSSIANTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import AbinsModules diff --git a/scripts/test/Abins/AbinsPowderDataTest.py b/scripts/test/Abins/AbinsPowderDataTest.py index 684213c4525e0fc651e5b2169cd3121ff0063f6b..657548010e37eba0c372f0e6587286f82bf042fd 100644 --- a/scripts/test/Abins/AbinsPowderDataTest.py +++ b/scripts/test/Abins/AbinsPowderDataTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import logger import numpy as np diff --git a/scripts/test/Abins/AbinsSDataTest.py b/scripts/test/Abins/AbinsSDataTest.py index 7b842e166b9694a4dce90b2c000cf76f7826d71f..f620a62518298afade8b8d32e9021382e70fe907 100644 --- a/scripts/test/Abins/AbinsSDataTest.py +++ b/scripts/test/Abins/AbinsSDataTest.py @@ -4,9 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + - -from __future__ import (absolute_import, division, print_function) -import six import unittest import numpy as np import logging @@ -34,11 +31,10 @@ class AbinsSDataTest(unittest.TestCase): s_data.set({'frequencies': np.linspace(105, 145, 5), 'atom_1': {'s': {'order_1': np.array([0., 0.001, 1., 1., 0., 0.,])}}}) - if six.PY3: # assertLogs is available from Python 3.4 and up - with self.assertRaises(AssertionError): - with self.assertLogs(logger=self.logger, level='WARNING'): - s_data.check_thresholds(logger=self.logger) - - AbinsParameters.sampling['s_absolute_threshold'] = 0.5 + with self.assertRaises(AssertionError): with self.assertLogs(logger=self.logger, level='WARNING'): s_data.check_thresholds(logger=self.logger) + + AbinsParameters.sampling['s_absolute_threshold'] = 0.5 + with self.assertLogs(logger=self.logger, level='WARNING'): + s_data.check_thresholds(logger=self.logger) diff --git a/scripts/test/AbsorptionShapesTest.py b/scripts/test/AbsorptionShapesTest.py index 7d82a9ea9764f126dbc384520a3d00d557b0e088..a5e76536f01af6208743d269ce6fd5d0e52b08d1 100644 --- a/scripts/test/AbsorptionShapesTest.py +++ b/scripts/test/AbsorptionShapesTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os from mantid.simpleapi import * from mantid import api @@ -12,6 +11,7 @@ import unittest import numpy as np from Direct.AbsorptionShapes import (anAbsorptionShape,Cylinder,FlatPlate,HollowCylinder,Sphere) + class AbsorbtionShapesTest(unittest.TestCase): def __init__(self, methodName): return super(AbsorbtionShapesTest, self).__init__(methodName) diff --git a/scripts/test/CrystalFieldTest.py b/scripts/test/CrystalFieldTest.py index 9dfd62ff6ed73ce1c70d51a189bad966a295762f..da94610ecfc837971693eedfde56b2465c377c8f 100644 --- a/scripts/test/CrystalFieldTest.py +++ b/scripts/test/CrystalFieldTest.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + """Test suite for the crystal field calculations in the Inelastic/CrystalField package """ -from __future__ import (absolute_import, division, print_function) import unittest import numpy as np import re @@ -1505,7 +1504,7 @@ class CrystalFieldFitTest(unittest.TestCase): def test_CrystalField_PointCharge_file(self): from CrystalField import PointCharge import mantid.simpleapi - from mantid.py3compat import mock + from unittest import mock # Just check that LoadCIF is called... we'll rely on LoadCIF working properly! with mock.patch.object(mantid.simpleapi, 'LoadCIF') as loadcif: diff --git a/scripts/test/DirectEnergyConversionTest.py b/scripts/test/DirectEnergyConversionTest.py index 52d624d87450429bfdb998c10265f35faf06a1f4..5045fc6d1efc867e654e2f66984ca5efe49efa20 100644 --- a/scripts/test/DirectEnergyConversionTest.py +++ b/scripts/test/DirectEnergyConversionTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os, sys from mantid.simpleapi import * from mantid import api @@ -18,6 +17,8 @@ import Direct.dgreduce as dgreduce #----------------------------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------------------------- + + class DirectEnergyConversionTest(unittest.TestCase): def __init__(self, methodName): self.reducer = None diff --git a/scripts/test/DirectPropertyManagerTest.py b/scripts/test/DirectPropertyManagerTest.py index ebf9bdafc36787924b49012b18549334d5e237fe..e158e1ed1805d8815a8c664b0ff6cb7e3ecf050e 100644 --- a/scripts/test/DirectPropertyManagerTest.py +++ b/scripts/test/DirectPropertyManagerTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) import os from mantid.simpleapi import * from mantid import api diff --git a/scripts/test/DirectPropertyManater_OldInterfaceXest.py b/scripts/test/DirectPropertyManater_OldInterfaceXest.py index 15edc3ea68c550d601569defbde8557b6dca0546..4228a26614acfd5b2167b8aaa20a2120d3807933 100644 --- a/scripts/test/DirectPropertyManater_OldInterfaceXest.py +++ b/scripts/test/DirectPropertyManater_OldInterfaceXest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) -from six.moves import range from mantid.simpleapi import * import unittest from DirectEnergyConversion import DirectEnergyConversion diff --git a/scripts/test/DirectReductionHelpersTest.py b/scripts/test/DirectReductionHelpersTest.py index 14f822d5c09a41e0dc79a7f1b324d2f9f3a9e315..f0476b4510867687c3f23c29bd6694c99d1071cf 100644 --- a/scripts/test/DirectReductionHelpersTest.py +++ b/scripts/test/DirectReductionHelpersTest.py @@ -4,13 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os from mantid.simpleapi import * from mantid import api import unittest import Direct.ReductionHelpers as helpers + class SomeDescriptor(object): def __init__(self): self._val=None @@ -530,4 +530,3 @@ class DirectReductionHelpersTest(unittest.TestCase): if __name__=="__main__": unittest.main() - diff --git a/scripts/test/ErrorReportPresenterTest.py b/scripts/test/ErrorReportPresenterTest.py index 1969e3fa8c1d5d64c9236e82de8f4fdf5824d7e2..b32a7b4eef98504230d3ed7f15e24d00a02ec358 100644 --- a/scripts/test/ErrorReportPresenterTest.py +++ b/scripts/test/ErrorReportPresenterTest.py @@ -7,7 +7,7 @@ import unittest from ErrorReporter.error_report_presenter import ErrorReporterPresenter -from mantid.py3compat import mock +from unittest import mock class ErrorReportPresenterTest(unittest.TestCase): diff --git a/scripts/test/ISISDirecInelasticConfigTest.py b/scripts/test/ISISDirecInelasticConfigTest.py index d7fc87b91b07c4e8ac699773604e95ab77d3efdd..34aefcd57321a65ced603e1f72b4650b31429d89 100644 --- a/scripts/test/ISISDirecInelasticConfigTest.py +++ b/scripts/test/ISISDirecInelasticConfigTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os import sys import unittest diff --git a/scripts/test/IndirectCommonTests.py b/scripts/test/IndirectCommonTests.py index 116828f364cbb59e4c65dc10c2f03dc15de33f9f..4bda6fde5de53b221684ae5f15f9f0618de26bc3 100644 --- a/scripts/test/IndirectCommonTests.py +++ b/scripts/test/IndirectCommonTests.py @@ -16,6 +16,7 @@ import numpy as np from mantid.simpleapi import * import IndirectCommon as indirect_common + class IndirectCommonTests(unittest.TestCase): _default_config = {} @@ -322,7 +323,7 @@ class IndirectCommonTests(unittest.TestCase): def assert_logs_match_expected(self, workspace, expected_logs): run = mtd[workspace].getRun() - for log_name, log_value in expected_logs.iteritems(): + for log_name, log_value in expected_logs.items(): self.assertTrue(run.hasProperty(log_name), "The log %s is missing from the workspace" % log_name) self.assertEqual(str(run.getProperty(log_name).value), str(log_value), diff --git a/scripts/test/MultiPlotting/AxisChangerTwoPresenter_test.py b/scripts/test/MultiPlotting/AxisChangerTwoPresenter_test.py index b0802c7b5f8be2a91e5d493d16eb3d692446c51b..d8f5d210e47de96d6428b0bb1db7859d0193f330 100644 --- a/scripts/test/MultiPlotting/AxisChangerTwoPresenter_test.py +++ b/scripts/test/MultiPlotting/AxisChangerTwoPresenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from MultiPlotting.AxisChanger.axis_changer_presenter import AxisChangerPresenter from MultiPlotting.AxisChanger.axis_changer_view import AxisChangerView diff --git a/scripts/test/MultiPlotting/AxisChangerTwoView_test.py b/scripts/test/MultiPlotting/AxisChangerTwoView_test.py index e319bd74871cad218c5c31f5c9714a51720654fd..22230da406fcbf1b78f0597f08405933b0442799 100644 --- a/scripts/test/MultiPlotting/AxisChangerTwoView_test.py +++ b/scripts/test/MultiPlotting/AxisChangerTwoView_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from MultiPlotting.AxisChanger.axis_changer_view import AxisChangerView diff --git a/scripts/test/MultiPlotting/MultiPlotWidget_test.py b/scripts/test/MultiPlotting/MultiPlotWidget_test.py index d9a394da579b9f71d9ed615f011bea238e6f8a43..12307c8b33827e4a27397b5acc7a6bbdc1392f6e 100644 --- a/scripts/test/MultiPlotting/MultiPlotWidget_test.py +++ b/scripts/test/MultiPlotting/MultiPlotWidget_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from MultiPlotting.multi_plotting_context import PlottingContext diff --git a/scripts/test/MultiPlotting/MultiPlottingContext_test.py b/scripts/test/MultiPlotting/MultiPlottingContext_test.py index 2ed8bd38abb0504e0e849795c2c35a31f4e469f1..a671c19bc7072ba0915a2b77b6ae08bbafb4fb1a 100644 --- a/scripts/test/MultiPlotting/MultiPlottingContext_test.py +++ b/scripts/test/MultiPlotting/MultiPlottingContext_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from MultiPlotting.multi_plotting_context import PlottingContext from MultiPlotting.subplot.subplot_context import subplotContext from line_helper import line diff --git a/scripts/test/MultiPlotting/QuickEditPresenter_test.py b/scripts/test/MultiPlotting/QuickEditPresenter_test.py index 249b9ea91dca0753dc7069a620925ff233fa0cbc..95cfa4449eee91d6d64c2f1fb57bfdf80b4672fc 100644 --- a/scripts/test/MultiPlotting/QuickEditPresenter_test.py +++ b/scripts/test/MultiPlotting/QuickEditPresenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from MultiPlotting.QuickEdit.quickEdit_presenter import QuickEditPresenter from MultiPlotting.QuickEdit.quickEdit_view import QuickEditView diff --git a/scripts/test/MultiPlotting/QuickEditWidget_test.py b/scripts/test/MultiPlotting/QuickEditWidget_test.py index 522fb58d09fc58fbef31380177578e1eb2c8d91d..cb2f419c58dff21a7e5ba9d25cceacc814664369 100644 --- a/scripts/test/MultiPlotting/QuickEditWidget_test.py +++ b/scripts/test/MultiPlotting/QuickEditWidget_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from MultiPlotting.QuickEdit.quickEdit_presenter import QuickEditPresenter diff --git a/scripts/test/MultiPlotting/SubPlotContext_test.py b/scripts/test/MultiPlotting/SubPlotContext_test.py index 88581ee0fce85cfa4c75504f346cde18b996157a..06a4e3db028a5690b7af0696d5fa91da84ef3a9a 100644 --- a/scripts/test/MultiPlotting/SubPlotContext_test.py +++ b/scripts/test/MultiPlotting/SubPlotContext_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from MultiPlotting.subplot.subplot_context import subplotContext from mantid import plots diff --git a/scripts/test/MultiPlotting/SubplotADSObserver_test.py b/scripts/test/MultiPlotting/SubplotADSObserver_test.py index 382210555937b342914ff96207cc388ea8f8c31b..a5c1f9ccf4cee1d45c6251cf91deaedad8c9ff8c 100644 --- a/scripts/test/MultiPlotting/SubplotADSObserver_test.py +++ b/scripts/test/MultiPlotting/SubplotADSObserver_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from MultiPlotting.subplot.subplot_ADS_observer import SubplotADSObserver diff --git a/scripts/test/MultiPlotting/Subplot_test.py b/scripts/test/MultiPlotting/Subplot_test.py index 1dc992905b3c84da0c21bbd020e8932b4084c082..c687d3f5db65e0c706d2d82a2ecbbbce73cc6186 100644 --- a/scripts/test/MultiPlotting/Subplot_test.py +++ b/scripts/test/MultiPlotting/Subplot_test.py @@ -7,7 +7,7 @@ import unittest from matplotlib.gridspec import GridSpec -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from MultiPlotting.multi_plotting_context import PlottingContext diff --git a/scripts/test/Muon/FFTModel_test.py b/scripts/test/Muon/FFTModel_test.py index 8adaef52318df7be7d752fc59840833d9fbf51ac..ec31ab2e2e0a6f82cea5cb0c4347e9f3e9aa473f 100644 --- a/scripts/test/Muon/FFTModel_test.py +++ b/scripts/test/Muon/FFTModel_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.FrequencyDomainAnalysis.FFT import fft_model diff --git a/scripts/test/Muon/FFTPresenter_test.py b/scripts/test/Muon/FFTPresenter_test.py index 5bb8785021c0b1aa13c0146c51526f2581bb1b68..22c67e7a15bfbe2ab217721793e850f1b84b76cd 100644 --- a/scripts/test/Muon/FFTPresenter_test.py +++ b/scripts/test/Muon/FFTPresenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.Common.utilities import load_utils from Muon.GUI.Common import thread_model from Muon.GUI.FrequencyDomainAnalysis.FFT import fft_presenter diff --git a/scripts/test/Muon/LoadWidgetPresenter_test.py b/scripts/test/Muon/LoadWidgetPresenter_test.py index 2706b6c9df67dda8acde7dea2055ec801d131069..df1a421f50cef77a186dcf6ac9d1fc872a8b511d 100644 --- a/scripts/test/Muon/LoadWidgetPresenter_test.py +++ b/scripts/test/Muon/LoadWidgetPresenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.load_widget.load_presenter import LoadPresenter @@ -14,6 +14,7 @@ from Muon.GUI.Common.load_widget.load_view import LoadView from Muon.GUI.ElementalAnalysis.LoadWidget.load_model import LoadModel, CoLoadModel from collections import OrderedDict + @start_qapplication class LoadPresenterTest(unittest.TestCase): def setUp(self): diff --git a/scripts/test/Muon/LoadWidgetView_test.py b/scripts/test/Muon/LoadWidgetView_test.py index ea17a98f35a364c860757f4299489d9fa3e2e7a6..9b56191827536958dfb2cd3bc12789a6d4db258c 100644 --- a/scripts/test/Muon/LoadWidgetView_test.py +++ b/scripts/test/Muon/LoadWidgetView_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.load_widget.load_view import LoadView diff --git a/scripts/test/Muon/MaxEntModel_test.py b/scripts/test/Muon/MaxEntModel_test.py index c86e1f86b3afef6d3b6689eb8a312f67073b56d4..fd581cc306014bd3510d0e004ebc7d920a7495bc 100644 --- a/scripts/test/Muon/MaxEntModel_test.py +++ b/scripts/test/Muon/MaxEntModel_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.FrequencyDomainAnalysis.MaxEnt import maxent_model diff --git a/scripts/test/Muon/MaxEntPresenter_test.py b/scripts/test/Muon/MaxEntPresenter_test.py index ae0a3d52a1db98e5fc732443e9e5671ad91cf6f2..3052865bf64c6527599860300933b9bd3ae03ee6 100644 --- a/scripts/test/Muon/MaxEntPresenter_test.py +++ b/scripts/test/Muon/MaxEntPresenter_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.Common.utilities import load_utils from Muon.GUI.Common import thread_model from Muon.GUI.FrequencyDomainAnalysis.MaxEnt import maxent_presenter diff --git a/scripts/test/Muon/PlottingView_test.py b/scripts/test/Muon/PlottingView_test.py index 6bcdb06e5ec95d3d37063489b1bcc7ac7a564204..daac1f7b07db85e103dadbe5447dff2c556cc3a8 100644 --- a/scripts/test/Muon/PlottingView_test.py +++ b/scripts/test/Muon/PlottingView_test.py @@ -4,14 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - import sys import unittest from matplotlib.figure import Figure from mantid import WorkspaceFactory, plots -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.ElementalAnalysis.Plotting.subPlot_object import subPlot diff --git a/scripts/test/Muon/elemental_analysis/PeriodicTableModel_test.py b/scripts/test/Muon/elemental_analysis/PeriodicTableModel_test.py index 7d0b6289b4cd97e1c9b6efe8393ee54279e661a9..ae158e1a7ead6e1b3e038e802e9425aeb7dc5f9d 100644 --- a/scripts/test/Muon/elemental_analysis/PeriodicTableModel_test.py +++ b/scripts/test/Muon/elemental_analysis/PeriodicTableModel_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table_model import PeriodicTableModel diff --git a/scripts/test/Muon/elemental_analysis/PeriodicTablePresenter_test.py b/scripts/test/Muon/elemental_analysis/PeriodicTablePresenter_test.py index 2bea4c6e89c77c7eac3825a9cbac10da97ca9b1d..41a5d7863805788eaa162043ded0b26428d90adb 100644 --- a/scripts/test/Muon/elemental_analysis/PeriodicTablePresenter_test.py +++ b/scripts/test/Muon/elemental_analysis/PeriodicTablePresenter_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table import PeriodicTable as silxPT, PeriodicTableItem diff --git a/scripts/test/Muon/elemental_analysis/detectors_presenter_test.py b/scripts/test/Muon/elemental_analysis/detectors_presenter_test.py index 73690b9f55b74c669ccf194bda58182d472c7490..aac65011d057d0b6ec1148b14d645815f82aaa79 100644 --- a/scripts/test/Muon/elemental_analysis/detectors_presenter_test.py +++ b/scripts/test/Muon/elemental_analysis/detectors_presenter_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.ElementalAnalysis.Detectors.detectors_presenter import DetectorsPresenter diff --git a/scripts/test/Muon/elemental_analysis/element_button_test.py b/scripts/test/Muon/elemental_analysis/element_button_test.py index c6e8c83671c4d4c83cccc1673c8fdcd8213d1c74..d5aeff0c41d7ee6496afdb3f31ba179f37388df3 100644 --- a/scripts/test/Muon/elemental_analysis/element_button_test.py +++ b/scripts/test/Muon/elemental_analysis/element_button_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table import ColoredPeriodicTableItem, _ElementButton diff --git a/scripts/test/Muon/elemental_analysis/elemental_analysis_test.py b/scripts/test/Muon/elemental_analysis/elemental_analysis_test.py index 45f2c9218cb9996a38f757a31f452c9edce9be30..a42926908ee2bf571f6c11410518efe6e38d364d 100644 --- a/scripts/test/Muon/elemental_analysis/elemental_analysis_test.py +++ b/scripts/test/Muon/elemental_analysis/elemental_analysis_test.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - import copy import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from testhelpers import assertRaisesNothing diff --git a/scripts/test/Muon/elemental_analysis/lmodel_test.py b/scripts/test/Muon/elemental_analysis/lmodel_test.py index 5170a98088390113e69e1f79f211a009cfede32b..4b39366be2e7547543c9db423132a4c5465a6a8c 100644 --- a/scripts/test/Muon/elemental_analysis/lmodel_test.py +++ b/scripts/test/Muon/elemental_analysis/lmodel_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, unicode_literals) - import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.ElementalAnalysis.LoadWidget.load_utils import LModel diff --git a/scripts/test/Muon/elemental_analysis/load_model_test.py b/scripts/test/Muon/elemental_analysis/load_model_test.py index c24b8ce1b53b6d0ab58a0a6cd40557203cb01965..00474d803544ec7b9309bda4523b6b5867f38c12 100644 --- a/scripts/test/Muon/elemental_analysis/load_model_test.py +++ b/scripts/test/Muon/elemental_analysis/load_model_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function - import unittest -from mantid.py3compat import mock +from unittest import mock import mantid.simpleapi as mantid from Muon.GUI.ElementalAnalysis.LoadWidget import load_model diff --git a/scripts/test/Muon/elemental_analysis/load_utils_test.py b/scripts/test/Muon/elemental_analysis/load_utils_test.py index 561e0e699902bbf6080ea7d702720c167d36c6d9..31b8c22e6d23b91cd3c09d05c8b41a52aadf7d70 100644 --- a/scripts/test/Muon/elemental_analysis/load_utils_test.py +++ b/scripts/test/Muon/elemental_analysis/load_utils_test.py @@ -5,14 +5,13 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.ElementalAnalysis.LoadWidget import load_utils as lutils import mantid.simpleapi as mantid from mantid import config import numpy as np -from six import iteritems class LoadUtilsTest(unittest.TestCase): @@ -26,7 +25,7 @@ class LoadUtilsTest(unittest.TestCase): def test_pad_run(self): tests = {123: "00123", 0: "00000", 12345: "12345", 123456: "123456"} - for run, padded_run in iteritems(tests): + for run, padded_run in tests.items(): self.assertEqual(lutils.pad_run(run), padded_run) @mock.patch('Muon.GUI.ElementalAnalysis.LoadWidget.load_utils.glob.iglob') @@ -67,7 +66,7 @@ class LoadUtilsTest(unittest.TestCase): def test_hyphenise(self): tests = {"1-5": [1, 2, 3, 4, 5], "1, 4-5": [1, 4, 5], "1-3, 5": [1, 3, 2, 5], "1, 3, 5": [1, 5, 3]} - for out, arg in iteritems(tests): + for out, arg in tests.items(): self.assertEqual(lutils.hyphenise(arg), out) def test_merge_workspaces(self): @@ -159,7 +158,7 @@ class LoadUtilsTest(unittest.TestCase): def test_replace_workspace_name_suffix(self): tests = {self.test_ws_name: "suffix", "_".join([self.test_ws_name, "test"]): "suffix"} - for workspace_name, suffix in iteritems(tests): + for workspace_name, suffix in tests.items(): self.assertEquals(lutils.replace_workspace_name_suffix(workspace_name, suffix), self.var_ws_name.format(1, suffix)) diff --git a/scripts/test/Muon/elemental_analysis/name_generator_test.py b/scripts/test/Muon/elemental_analysis/name_generator_test.py index 82e5f26b71f52cfe6a681d44253a107ac0a5114b..8f83c5377e688c836314905d6eb480e06f63c252 100644 --- a/scripts/test/Muon/elemental_analysis/name_generator_test.py +++ b/scripts/test/Muon/elemental_analysis/name_generator_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import absolute_import, print_function - import unittest import sys diff --git a/scripts/test/Muon/elemental_analysis/peak_data_file_test.py b/scripts/test/Muon/elemental_analysis/peak_data_file_test.py index 8e2c999b554adda62f0ea7e19585c0dd7524dc7d..369ae7d903d55afe662aca7190337584795b8857 100644 --- a/scripts/test/Muon/elemental_analysis/peak_data_file_test.py +++ b/scripts/test/Muon/elemental_analysis/peak_data_file_test.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import import unittest import json diff --git a/scripts/test/Muon/elemental_analysis/peak_selector_view_test.py b/scripts/test/Muon/elemental_analysis/peak_selector_view_test.py index a8c5c7adf774153ce3329bc3479a48917d380b0e..766b19c395870c3c5f427225d90f8690811a6136 100644 --- a/scripts/test/Muon/elemental_analysis/peak_selector_view_test.py +++ b/scripts/test/Muon/elemental_analysis/peak_selector_view_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.checkbox import Checkbox diff --git a/scripts/test/Muon/elemental_analysis/periodic_combo_test.py b/scripts/test/Muon/elemental_analysis/periodic_combo_test.py index 97562c510dc35642feeb4c6e5b079f1fd6e9673d..306af99d87b3f7064c73138262c14772e235a9ef 100644 --- a/scripts/test/Muon/elemental_analysis/periodic_combo_test.py +++ b/scripts/test/Muon/elemental_analysis/periodic_combo_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication import Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table as periodic_table diff --git a/scripts/test/Muon/elemental_analysis/periodic_list_test.py b/scripts/test/Muon/elemental_analysis/periodic_list_test.py index 641b8bc5a2212f4003c83bd3e26271d67fc0bd54..4739a34412993c907343d740329ec38a8cd8af74 100644 --- a/scripts/test/Muon/elemental_analysis/periodic_list_test.py +++ b/scripts/test/Muon/elemental_analysis/periodic_list_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy import QtWidgets diff --git a/scripts/test/Muon/elemental_analysis/periodic_table_item_test.py b/scripts/test/Muon/elemental_analysis/periodic_table_item_test.py index c67fe8dbef2ccd33c9c605f2f1eb4405684b3636..ea6e46960bf65404f806d37790f44760ed5e3627 100644 --- a/scripts/test/Muon/elemental_analysis/periodic_table_item_test.py +++ b/scripts/test/Muon/elemental_analysis/periodic_table_item_test.py @@ -4,12 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - - import unittest -from mantid.py3compat import mock +from unittest import mock import Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table as periodic_table from Muon.GUI.ElementalAnalysis.PeriodicTable.periodic_table import PeriodicTableItem,\ diff --git a/scripts/test/Muon/elemental_analysis/periodic_table_test.py b/scripts/test/Muon/elemental_analysis/periodic_table_test.py index 93888654fe90ee7adf86f0b36dbdca3e5d01892d..6a3bd1c170ae2a7edb409fb2ecba65f20f9ddccd 100644 --- a/scripts/test/Muon/elemental_analysis/periodic_table_test.py +++ b/scripts/test/Muon/elemental_analysis/periodic_table_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function, absolute_import - import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from testhelpers import assertRaisesNothing diff --git a/scripts/test/Muon/fft_presenter_context_interaction_test.py b/scripts/test/Muon/fft_presenter_context_interaction_test.py index a3c392a722bba2361a433f7dc61ad47352028c00..dba5260bb3051ae43b7ae9d4b03be97ef867afa5 100644 --- a/scripts/test/Muon/fft_presenter_context_interaction_test.py +++ b/scripts/test/Muon/fft_presenter_context_interaction_test.py @@ -7,7 +7,7 @@ import unittest from mantid.api import FileFinder -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.muon_pair import MuonPair @@ -19,6 +19,7 @@ from Muon.GUI.FrequencyDomainAnalysis.FFT import fft_model from Muon.GUI.Common.utilities.algorithm_utils import convert_to_field + def retrieve_combobox_info(combo_box): output_list = [] for i in range(combo_box.count()): diff --git a/scripts/test/Muon/fit_information_test.py b/scripts/test/Muon/fit_information_test.py index 66068b820e399f271f2fcc0765a94a8cc48fd0e6..ffb8d5de434567f244cabc3fa10423dd53ceadc3 100644 --- a/scripts/test/Muon/fit_information_test.py +++ b/scripts/test/Muon/fit_information_test.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - import unittest from mantid.api import AnalysisDataService, WorkspaceFactory from mantid.kernel import FloatTimeSeriesProperty, StringPropertyWithValue -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.Common.contexts.fitting_context import FitInformation diff --git a/scripts/test/Muon/fit_parameters_test.py b/scripts/test/Muon/fit_parameters_test.py index 947a2d2ad3cd6efeadc805eb057aebe25f58c7dc..b7f5d25e7f45991a4d1cd381e848271d0d9ab5d3 100644 --- a/scripts/test/Muon/fit_parameters_test.py +++ b/scripts/test/Muon/fit_parameters_test.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - from collections import OrderedDict import unittest -from mantid.py3compat import iteritems, mock +from unittest import mock from Muon.GUI.Common.contexts.fitting_context import FitParameters @@ -19,7 +17,7 @@ def create_test_fit_parameters(test_parameters, global_parameters=None): 'Name': name, 'Value': value, 'Error': error - } for name, (value, error) in iteritems(test_parameters)] + } for name, (value, error) in test_parameters.items()] parameter_workspace = mock.MagicMock() parameter_workspace.workspace.__iter__.return_value = fit_table diff --git a/scripts/test/Muon/fitting_context_test.py b/scripts/test/Muon/fitting_context_test.py index b165ebd9db626abe7db60d119d2d912eb47d9d52..31a0a5361c71afd43426eb58e0c9d395678b109a 100644 --- a/scripts/test/Muon/fitting_context_test.py +++ b/scripts/test/Muon/fitting_context_test.py @@ -4,15 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - from collections import OrderedDict import unittest from mantidqt.utils.qt.testing import start_qapplication from mantid.api import AnalysisDataService, WorkspaceFactory, WorkspaceGroup from mantid.kernel import FloatTimeSeriesProperty, StringPropertyWithValue -from mantid.py3compat import iteritems, mock +from unittest import mock from Muon.GUI.Common.contexts.fitting_context import FittingContext, FitInformation, FitParameters @@ -76,7 +74,7 @@ def create_test_fit_parameters(test_parameters, global_parameters=None): 'Name': name, 'Value': value, 'Error': error - } for name, (value, error) in iteritems(test_parameters)] + } for name, (value, error) in test_parameters.items()] parameter_workspace = mock.MagicMock() parameter_workspace.workspace.__iter__.return_value = fit_table diff --git a/scripts/test/Muon/fitting_tab_widget/fitting_tab_model_test.py b/scripts/test/Muon/fitting_tab_widget/fitting_tab_model_test.py index 21e54e552cfd8d8063ea2056787afcc0d0b7c065..f2eb4885c7d9487efcf8735c4fc3f9e7027a58ab 100644 --- a/scripts/test/Muon/fitting_tab_widget/fitting_tab_model_test.py +++ b/scripts/test/Muon/fitting_tab_widget/fitting_tab_model_test.py @@ -9,7 +9,7 @@ from Muon.GUI.Common.fitting_tab_widget.fitting_tab_model import FittingTabModel from Muon.GUI.Common.test_helpers.context_setup import setup_context from mantid.api import FunctionFactory, AnalysisDataService from mantid.simpleapi import CreateWorkspace -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication diff --git a/scripts/test/Muon/fitting_tab_widget/fitting_tab_presenter_test.py b/scripts/test/Muon/fitting_tab_widget/fitting_tab_presenter_test.py index 7f4a8c776313047dcaa189902a1bdd848ec3e872..c88c97fd0fe1f8ffcb69554c0a429d0ff648fbf5 100644 --- a/scripts/test/Muon/fitting_tab_widget/fitting_tab_presenter_test.py +++ b/scripts/test/Muon/fitting_tab_widget/fitting_tab_presenter_test.py @@ -7,7 +7,7 @@ import unittest from mantid.api import FunctionFactory, MultiDomainFunction -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy import QtWidgets from Muon.GUI.Common.fitting_tab_widget.fitting_tab_widget import FittingTabWidget diff --git a/scripts/test/Muon/fitting_tab_widget/workspace_selector_dialog_presenter_test.py b/scripts/test/Muon/fitting_tab_widget/workspace_selector_dialog_presenter_test.py index 09318ac1db62673ca4a2cc2632a587874d3c8cbd..6a42735fd040c122cac0d1339618bdb0270d7bef 100644 --- a/scripts/test/Muon/fitting_tab_widget/workspace_selector_dialog_presenter_test.py +++ b/scripts/test/Muon/fitting_tab_widget/workspace_selector_dialog_presenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.fitting_tab_widget.workspace_selector_view import WorkspaceSelectorView diff --git a/scripts/test/Muon/frequency_domain_context_test.py b/scripts/test/Muon/frequency_domain_context_test.py index 7355d5a9730d520327c0c00d9de009166d36253f..8b4ba58bfcd69f0ce33ead88dc95fb9b3f20ce1b 100644 --- a/scripts/test/Muon/frequency_domain_context_test.py +++ b/scripts/test/Muon/frequency_domain_context_test.py @@ -4,14 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - -import six import sys import unittest from Muon.GUI.FrequencyDomainAnalysis.frequency_context import MaxEnt, FFT, FrequencyContext, FREQUENCY_EXTENSIONS -from mantid.py3compat import mock +from unittest import mock from mantid.simpleapi import CreateWorkspace, AnalysisDataService @@ -48,7 +45,7 @@ class MuonFreqContextTest(unittest.TestCase): self.assertEquals(self.context.maxEnt_freq, ["MUSR62260_raw_data FD; MaxEnt"]) def test_add_FFT(self): - six.assertCountEqual(self,list(self.context._FFT_freq.keys()),[FFT_NAME_RE_2, FFT_NAME_RE_MOD] ) + self.assertCountEqual(list(self.context._FFT_freq.keys()),[FFT_NAME_RE_2, FFT_NAME_RE_MOD] ) self.assertEquals(self.context._FFT_freq[FFT_NAME_RE_2].Re_run, "62260") self.assertEquals(self.context._FFT_freq[FFT_NAME_RE_2].Re, "fwd" ) self.assertEquals(self.context._FFT_freq[FFT_NAME_RE_2].Im, None ) @@ -59,7 +56,7 @@ class MuonFreqContextTest(unittest.TestCase): self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_RE, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_IM, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_MOD, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) - six.assertCountEqual(self,list(self.context._FFT_freq.keys()),[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD, FFT_NAME_RE_2, FFT_NAME_RE_MOD] ) + self.assertCountEqual(list(self.context._FFT_freq.keys()),[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD, FFT_NAME_RE_2, FFT_NAME_RE_MOD] ) self.assertEquals(self.context._FFT_freq[FFT_NAME_COMPLEX_RE].Re_run, "62260") self.assertEquals(self.context._FFT_freq[FFT_NAME_COMPLEX_RE].Re, "top" ) self.assertEquals(self.context._FFT_freq[FFT_NAME_COMPLEX_RE].Im, "fwd" ) @@ -72,19 +69,19 @@ class MuonFreqContextTest(unittest.TestCase): def test_get_freq_names_FFT_no_Im_all_parts(self): output = self.context.get_frequency_workspace_names(run_list=[["62260"]],group=["fwd","top"],pair=[],phasequad=False,frequency_type="FFT All") - six.assertCountEqual(self,output,[FFT_NAME_RE_2, FFT_NAME_RE_MOD]) + self.assertCountEqual(output,[FFT_NAME_RE_2, FFT_NAME_RE_MOD]) def test_get_freq_names_FFT_no_Im_Re_parts(self): output = self.context.get_frequency_workspace_names(run_list=[["62260"]],group=["fwd","top"],pair=[],phasequad=False,frequency_type="Re") - six.assertCountEqual(self,output,[FFT_NAME_RE_2]) + self.assertCountEqual(output,[FFT_NAME_RE_2]) def test_get_freq_names_FFT_no_Im_Mod_parts(self): output = self.context.get_frequency_workspace_names(run_list=[["62260"]],group=["fwd","top"],pair=[],phasequad=False,frequency_type="Mod") - six.assertCountEqual(self,output,[FFT_NAME_RE_MOD]) + self.assertCountEqual(output,[FFT_NAME_RE_MOD]) def test_get_freq_names_FFT_no_Im_Im_parts(self): output = self.context.get_frequency_workspace_names(run_list=[["62260"]],group=["fwd","top"],pair=[],phasequad=False,frequency_type="Im") - six.assertCountEqual(self,output,[]) + self.assertCountEqual(output,[]) def test_get_freq_names_FFT_run(self): self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_RE, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) @@ -92,7 +89,7 @@ class MuonFreqContextTest(unittest.TestCase): self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_MOD, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) output = self.context.get_frequency_workspace_names(run_list=[["62261","62262"]],group=["fwd","top"],pair=[],phasequad=False,frequency_type="FFT All") - six.assertCountEqual(self,output,[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD]) + self.assertCountEqual(output,[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD]) def test_get_freq_names_FFT_group(self): self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_RE, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) @@ -100,7 +97,7 @@ class MuonFreqContextTest(unittest.TestCase): self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_MOD, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) output = self.context.get_frequency_workspace_names(run_list=[["62260"]],group=["top"],pair=[],phasequad=False,frequency_type="FFT All") - six.assertCountEqual(self,output,[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD]) + self.assertCountEqual(output,[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD]) def test_get_freq_names_all(self): self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_RE, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) @@ -108,28 +105,28 @@ class MuonFreqContextTest(unittest.TestCase): self.context.add_FFT(ws_freq_name=FFT_NAME_COMPLEX_MOD, Re_run="62260",Re= "top", Im_run="62261", Im="fwd",phasequad=False) output = self.context.get_frequency_workspace_names(run_list=[[62260],[62261]],group=["fwd"],pair=[],phasequad=False,frequency_type="All") - six.assertCountEqual(self,output,[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD, FFT_NAME_RE_2, FFT_NAME_RE_MOD, "MUSR62260_raw_data FD; MaxEnt"]) + self.assertCountEqual(output,[FFT_NAME_COMPLEX_RE, FFT_NAME_COMPLEX_IM, FFT_NAME_COMPLEX_MOD, FFT_NAME_RE_2, FFT_NAME_RE_MOD, "MUSR62260_raw_data FD; MaxEnt"]) def test_get_freq_names_all_with_phasequad(self): self.context.add_FFT(ws_freq_name=PHASEQUAD_NAME_RE, Re_run="62261",Re= "", Im_run="", Im="",phasequad=True) self.context.add_FFT(ws_freq_name=PHASEQUAD_NAME_IM, Re_run="62261",Re= "", Im_run="62260", Im="",phasequad=True) output = self.context.get_frequency_workspace_names(run_list=[[62260],[62261]],group=["fwd"],pair=[],phasequad=True,frequency_type="All") - six.assertCountEqual(self,output,[PHASEQUAD_NAME_RE, PHASEQUAD_NAME_IM, FFT_NAME_RE_2, FFT_NAME_RE_MOD, "MUSR62260_raw_data FD; MaxEnt"]) + self.assertCountEqual(output,[PHASEQUAD_NAME_RE, PHASEQUAD_NAME_IM, FFT_NAME_RE_2, FFT_NAME_RE_MOD, "MUSR62260_raw_data FD; MaxEnt"]) def test_get_freq_names_all_with_phasequad_Re_run(self): self.context.add_FFT(ws_freq_name=PHASEQUAD_NAME_RE, Re_run="62261",Re= "", Im_run="", Im="",phasequad=True) self.context.add_FFT(ws_freq_name=PHASEQUAD_NAME_IM, Re_run="62261",Re= "", Im_run="62260", Im="",phasequad=True) output = self.context.get_frequency_workspace_names(run_list=[[62261]],group=["fwd"],pair=[],phasequad=True,frequency_type="All") - six.assertCountEqual(self,output,[PHASEQUAD_NAME_RE, PHASEQUAD_NAME_IM]) + self.assertCountEqual(output,[PHASEQUAD_NAME_RE, PHASEQUAD_NAME_IM]) def test_get_freq_names_all_with_phasequad_Im_run(self): self.context.add_FFT(ws_freq_name=PHASEQUAD_NAME_RE, Re_run="62261",Re= "", Im_run="", Im="",phasequad=True) self.context.add_FFT(ws_freq_name=PHASEQUAD_NAME_IM, Re_run="62261",Re= "", Im_run="62260", Im="",phasequad=True) output = self.context.get_frequency_workspace_names(run_list=[[62260]],group=["fwd"],pair=[],phasequad=True,frequency_type="All") - six.assertCountEqual(self,output,[PHASEQUAD_NAME_IM, FFT_NAME_RE_2, FFT_NAME_RE_MOD, "MUSR62260_raw_data FD; MaxEnt"]) + self.assertCountEqual(output,[PHASEQUAD_NAME_IM, FFT_NAME_RE_2, FFT_NAME_RE_MOD, "MUSR62260_raw_data FD; MaxEnt"]) if __name__ == '__main__': diff --git a/scripts/test/Muon/grouping_tab/grouping_tab_presenter_test.py b/scripts/test/Muon/grouping_tab/grouping_tab_presenter_test.py index 246ddc539a119e4614edc9aba9131f0ca53c8ae6..7e20a06f47a846dd55041fcd8aa633ec05ab9c0d 100644 --- a/scripts/test/Muon/grouping_tab/grouping_tab_presenter_test.py +++ b/scripts/test/Muon/grouping_tab/grouping_tab_presenter_test.py @@ -5,8 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -import six -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from mantid import ConfigService from mantid.api import FileFinder @@ -143,8 +142,8 @@ class GroupingTabPresenterTest(unittest.TestCase): mock_load.return_value = (groups, pairs, 'description', 'pair1') self.view.load_grouping_button.clicked.emit(True) - six.assertCountEqual(self, self.model.group_names, ["grp1", "grp2"]) - six.assertCountEqual(self, self.model.pair_names, ["pair1"]) + self.assertCountEqual(self.model.group_names, ["grp1", "grp2"]) + self.assertCountEqual(self.model.pair_names, ["pair1"]) self.assertEqual(self.grouping_table_view.num_rows(), 2) self.assertEqual(self.pairing_table_view.num_rows(), 1) self.assertEqual(self.pairing_table_view.pairing_table.cellWidget(0, 2).currentText(), "grp1") @@ -162,8 +161,8 @@ class GroupingTabPresenterTest(unittest.TestCase): self.view.load_grouping_button.clicked.emit(True) self.view.display_warning_box.assert_called_once_with('Invalid detectors in group grp2') - six.assertCountEqual(self, self.model.group_names, ["grp1"]) - six.assertCountEqual(self, self.model.pair_names, []) + self.assertCountEqual(self.model.group_names, ["grp1"]) + self.assertCountEqual(self.model.pair_names, []) self.assertEqual(self.grouping_table_view.num_rows(), 1) self.assertEqual(self.pairing_table_view.num_rows(), 0) diff --git a/scripts/test/Muon/grouping_tab/grouping_table_presenter_test.py b/scripts/test/Muon/grouping_tab/grouping_table_presenter_test.py index af7861836480f2779a05e681e87ef8ae339aa2bd..d6829685bdc2a6b98b78c7e7ae8b3e6be4a97425 100644 --- a/scripts/test/Muon/grouping_tab/grouping_table_presenter_test.py +++ b/scripts/test/Muon/grouping_tab/grouping_table_presenter_test.py @@ -5,7 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QWidget diff --git a/scripts/test/Muon/grouping_tab/pairing_table_alpha_test.py b/scripts/test/Muon/grouping_tab/pairing_table_alpha_test.py index 44414050c172d4bb4486e337aba0884b64879b1e..42805ad84b2d2f02d48a533890425e14c6f96dd0 100644 --- a/scripts/test/Muon/grouping_tab/pairing_table_alpha_test.py +++ b/scripts/test/Muon/grouping_tab/pairing_table_alpha_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QWidget diff --git a/scripts/test/Muon/grouping_tab/pairing_table_group_selector_test.py b/scripts/test/Muon/grouping_tab/pairing_table_group_selector_test.py index 0416f97783cb3ed118db8dfc34556164af0bb913..4bc8b9988130cd2a9fa7687294dd53cebd04b84d 100644 --- a/scripts/test/Muon/grouping_tab/pairing_table_group_selector_test.py +++ b/scripts/test/Muon/grouping_tab/pairing_table_group_selector_test.py @@ -5,7 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QWidget diff --git a/scripts/test/Muon/grouping_tab/pairing_table_presenter_test.py b/scripts/test/Muon/grouping_tab/pairing_table_presenter_test.py index 022b166a271c1fedcfd1fe816be819545e02cc05..7267782fe6290f3e3535759ebf9a59761f43d783 100644 --- a/scripts/test/Muon/grouping_tab/pairing_table_presenter_test.py +++ b/scripts/test/Muon/grouping_tab/pairing_table_presenter_test.py @@ -5,9 +5,8 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication -import six from qtpy.QtWidgets import QWidget from Muon.GUI.Common.grouping_tab_widget.grouping_tab_widget_model import GroupingTabModel @@ -257,7 +256,7 @@ class PairingTablePresenterTest(unittest.TestCase): self.assertEqual(str(self.view.get_table_item_text(0, 0)), "pair_1") self.assertEqual(str(self.view.get_table_item_text(1, 0)), "pair_2") self.assertEqual(str(self.view.get_table_item_text(2, 0)), "pair_3") - six.assertCountEqual(self, self.model.pair_names, ["pair_1", "pair_2", "pair_3"]) + self.assertCountEqual(self.model.pair_names, ["pair_1", "pair_2", "pair_3"]) if __name__ == '__main__': diff --git a/scripts/test/Muon/help_widget_presenter_test.py b/scripts/test/Muon/help_widget_presenter_test.py index 19405ce185f516501e8e7fa9a5798e43af1ab377..d358adbcc687b732db1d03351a572baccf2e3f13 100644 --- a/scripts/test/Muon/help_widget_presenter_test.py +++ b/scripts/test/Muon/help_widget_presenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from mantidqt.widgets import manageuserdirectories diff --git a/scripts/test/Muon/home_instrument_widget_test.py b/scripts/test/Muon/home_instrument_widget_test.py index 88b83e76f70ff4cc131253887b08f55fd7b5cb4d..2f8987454323f85ae62f6aa2fb84ea420d7ae2e3 100644 --- a/scripts/test/Muon/home_instrument_widget_test.py +++ b/scripts/test/Muon/home_instrument_widget_test.py @@ -8,7 +8,7 @@ import unittest from mantid.api import FileFinder, AnalysisDataService -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QWidget from mantid.simpleapi import LoadMuonNexus, CompareWorkspaces diff --git a/scripts/test/Muon/home_runinfo_presenter_test.py b/scripts/test/Muon/home_runinfo_presenter_test.py index 2d10bac54ccc6fbade7174510041146967a8cd73..c440d74ed74e93c739432ff495bcec5bebb1f3ad 100644 --- a/scripts/test/Muon/home_runinfo_presenter_test.py +++ b/scripts/test/Muon/home_runinfo_presenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest from mantid.api import FileFinder -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QWidget diff --git a/scripts/test/Muon/list_selector/list_selector_presenter_test.py b/scripts/test/Muon/list_selector/list_selector_presenter_test.py index 882c89f28bf26e1517b206a28bdf7356102575ce..73f2b5c0dffec870b07b724dd2fe8ef3d14c9c3f 100644 --- a/scripts/test/Muon/list_selector/list_selector_presenter_test.py +++ b/scripts/test/Muon/list_selector/list_selector_presenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.list_selector.list_selector_presenter import ListSelectorPresenter diff --git a/scripts/test/Muon/load_file_widget/loadfile_model_test.py b/scripts/test/Muon/load_file_widget/loadfile_model_test.py index dbf2335c28d2412ba520c1fee8659ad206712360..bf323863e83b858ae230e68b44495e8ef7b7fff1 100644 --- a/scripts/test/Muon/load_file_widget/loadfile_model_test.py +++ b/scripts/test/Muon/load_file_widget/loadfile_model_test.py @@ -8,8 +8,6 @@ import os import unittest from mantidqt.utils.qt.testing import start_qapplication -import six - from Muon.GUI.Common.load_file_widget.model import BrowseFileWidgetModel from Muon.GUI.Common.test_helpers.context_setup import setup_context_for_tests @@ -44,8 +42,8 @@ class LoadFileWidgetModelTest(unittest.TestCase): self.model.execute() - six.assertCountEqual(self, [os.path.split(filename)[-1] for filename in self.model.loaded_filenames], files) - six.assertCountEqual(self, self.model.loaded_runs, [[19489], [6473], [6475]]) + self.assertCountEqual([os.path.split(filename)[-1] for filename in self.model.loaded_filenames], files) + self.assertCountEqual(self.model.loaded_runs, [[19489], [6473], [6475]]) def test_model_is_cleared_correctly(self): files = ['EMU00019489.nxs', 'emu00006473.nxs', 'emu00006475.nxs'] @@ -64,9 +62,9 @@ class LoadFileWidgetModelTest(unittest.TestCase): with self.assertRaises(ValueError): self.model.execute() - six.assertCountEqual(self, [os.path.split(filename)[-1] for filename in self.model.loaded_filenames], + self.assertCountEqual([os.path.split(filename)[-1] for filename in self.model.loaded_filenames], ['EMU00019489.nxs', 'emu00006473.nxs']) - six.assertCountEqual(self, self.model.loaded_runs, [[19489], [6473]]) + self.assertCountEqual(self.model.loaded_runs, [[19489], [6473]]) if __name__ == '__main__': diff --git a/scripts/test/Muon/load_file_widget/loadfile_presenter_multiple_file_test.py b/scripts/test/Muon/load_file_widget/loadfile_presenter_multiple_file_test.py index bafb3549d7769682db1a9479331b6008de0b2008..268b90193d764ac34b89cf4df63e7158a3538a06 100644 --- a/scripts/test/Muon/load_file_widget/loadfile_presenter_multiple_file_test.py +++ b/scripts/test/Muon/load_file_widget/loadfile_presenter_multiple_file_test.py @@ -6,11 +6,9 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication -import six - from Muon.GUI.Common.load_file_widget.model import BrowseFileWidgetModel from Muon.GUI.Common.load_file_widget.presenter import BrowseFileWidgetPresenter from Muon.GUI.Common.load_file_widget.view import BrowseFileWidgetView @@ -147,9 +145,9 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase): self.wait_for_thread(self.presenter._load_thread) # Load will take the last occurrence of the run from the list - six.assertCountEqual(self, self.model.loaded_filenames, ["C:/dir1/file2.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [workspace_2]) - six.assertCountEqual(self, self.model.loaded_runs, [[1234]]) + self.assertCountEqual(self.model.loaded_filenames, ["C:/dir1/file2.nxs"]) + self.assertCountEqual(self.model.loaded_workspaces, [workspace_2]) + self.assertCountEqual(self.model.loaded_runs, [[1234]]) # @run_test_with_and_without_threading @@ -165,9 +163,9 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase): self.wait_for_thread(self.presenter._load_thread) # Load will take the last occurrence of the run from the user input - six.assertCountEqual(self, self.model.loaded_filenames, ["C:/dir1/file2.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [workspace_2]) - six.assertCountEqual(self, self.model.loaded_runs, [[1234]]) + self.assertCountEqual(self.model.loaded_filenames, ["C:/dir1/file2.nxs"]) + self.assertCountEqual(self.model.loaded_workspaces, [workspace_2]) + self.assertCountEqual(self.model.loaded_runs, [[1234]]) @run_test_with_and_without_threading def test_that_loading_two_files_from_browse_sets_model_and_interface_correctly(self): @@ -246,10 +244,10 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase): self.presenter.on_browse_button_clicked() self.wait_for_thread(self.presenter._load_thread) - six.assertCountEqual(self, self.model.loaded_filenames, + self.assertCountEqual(self.model.loaded_filenames, ["C:/dir1/file1.nxs", "C:/dir2/file2.nxs", "C:/dir1/file3.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [workspace_1, workspace_2, workspace_3]) - six.assertCountEqual(self, self.model.loaded_runs, [[1234], [1235], [1236]]) + self.assertCountEqual(self.model.loaded_workspaces, [workspace_1, workspace_2, workspace_3]) + self.assertCountEqual(self.model.loaded_runs, [[1234], [1235], [1236]]) self.assertEqual(self.view.get_file_edit_text(), "C:/dir1/file3.nxs") @@ -271,9 +269,9 @@ class LoadFileWidgetPresenterMultipleFileModeTest(unittest.TestCase): self.presenter.on_browse_button_clicked() self.wait_for_thread(self.presenter._load_thread) - six.assertCountEqual(self, self.model.loaded_filenames, ["C:/dir2/file1.nxs", "C:/dir2/file2.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [workspace_3, workspace_2]) - six.assertCountEqual(self, self.model.loaded_runs, [[1234], [1235]]) + self.assertCountEqual(self.model.loaded_filenames, ["C:/dir2/file1.nxs", "C:/dir2/file2.nxs"]) + self.assertCountEqual(self.model.loaded_workspaces, [workspace_3, workspace_2]) + self.assertCountEqual(self.model.loaded_runs, [[1234], [1235]]) self.assertEqual(self.view.get_file_edit_text(), "C:/dir2/file1.nxs") diff --git a/scripts/test/Muon/load_file_widget/loadfile_presenter_single_file_test.py b/scripts/test/Muon/load_file_widget/loadfile_presenter_single_file_test.py index ded224c8d3d9ddfbb647ba0ebf91b8947f733740..994a355ba90f1f60d683fd064b94f0174676a10f 100644 --- a/scripts/test/Muon/load_file_widget/loadfile_presenter_single_file_test.py +++ b/scripts/test/Muon/load_file_widget/loadfile_presenter_single_file_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication diff --git a/scripts/test/Muon/load_run_widget/loadrun_model_test.py b/scripts/test/Muon/load_run_widget/loadrun_model_test.py index 07a7d2f8259cf79e321738dd7029eae2a2ce094c..ba9a730c4164e71638eb50ab3495e94d7aa6e425 100644 --- a/scripts/test/Muon/load_run_widget/loadrun_model_test.py +++ b/scripts/test/Muon/load_run_widget/loadrun_model_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.load_run_widget.load_run_model import LoadRunWidgetModel diff --git a/scripts/test/Muon/load_run_widget/loadrun_presenter_current_run_test.py b/scripts/test/Muon/load_run_widget/loadrun_presenter_current_run_test.py index 0e7b0bfbf179ad79d5d6f10762f51d45af06d611..cc02c7cce379d0a97379aace27064b982ac4480b 100644 --- a/scripts/test/Muon/load_run_widget/loadrun_presenter_current_run_test.py +++ b/scripts/test/Muon/load_run_widget/loadrun_presenter_current_run_test.py @@ -5,8 +5,8 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock -from mantid.py3compat.mock import patch +from unittest import mock +from unittest.mock import patch from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication, QMessageBox, QWidget @@ -20,6 +20,8 @@ from Muon.GUI.Common.test_helpers.context_setup import setup_context_for_tests # this class is required to keep track of error signal emissions since the output is garbage collected by the time # we reach the equal assertion + + class MockSignalHandler(object): def __init__(self, parent=None): self.call_count = 0 @@ -27,6 +29,7 @@ class MockSignalHandler(object): def signalReceived(self): self.call_count+=1 + @start_qapplication class LoadRunWidgetLoadCurrentRunTest(unittest.TestCase): def run_test_with_and_without_threading(test_function): diff --git a/scripts/test/Muon/load_run_widget/loadrun_presenter_increment_decrement_test.py b/scripts/test/Muon/load_run_widget/loadrun_presenter_increment_decrement_test.py index 2972e6a8c34e1654f104daafad28f16e8f97ce10..2d9b5ec4d81aa48bb27a349f0787c179f6681b94 100644 --- a/scripts/test/Muon/load_run_widget/loadrun_presenter_increment_decrement_test.py +++ b/scripts/test/Muon/load_run_widget/loadrun_presenter_increment_decrement_test.py @@ -7,7 +7,7 @@ import os import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication, QWidget diff --git a/scripts/test/Muon/load_run_widget/loadrun_presenter_multiple_file_test.py b/scripts/test/Muon/load_run_widget/loadrun_presenter_multiple_file_test.py index 5e4b2b85795116b20e2fafcba4cba67dceff915f..2062f0dd861dea8fdeedb3dbd4201e6701737d12 100644 --- a/scripts/test/Muon/load_run_widget/loadrun_presenter_multiple_file_test.py +++ b/scripts/test/Muon/load_run_widget/loadrun_presenter_multiple_file_test.py @@ -6,11 +6,9 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication, QWidget -import six - from Muon.GUI.Common.load_run_widget.load_run_model import LoadRunWidgetModel from Muon.GUI.Common.load_run_widget.load_run_presenter import LoadRunWidgetPresenter from Muon.GUI.Common.load_run_widget.load_run_view import LoadRunWidgetView @@ -114,9 +112,9 @@ class LoadRunWidgetIncrementDecrementMultipleFileModeTest(unittest.TestCase): self.presenter.handle_decrement_run() self.wait_for_thread(self.presenter._load_thread) - six.assertCountEqual(self, self.model.loaded_filenames, ["file1.nxs", "file2.nxs", "file3.nxs", "file4.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [[1], [2], [3], [4]]) - six.assertCountEqual(self, self.model.loaded_runs, [[1], [2], [3], [4]]) + self.assertCountEqual(self.model.loaded_filenames, ["file1.nxs", "file2.nxs", "file3.nxs", "file4.nxs"]) + self.assertCountEqual(self.model.loaded_workspaces, [[1], [2], [3], [4]]) + self.assertCountEqual(self.model.loaded_runs, [[1], [2], [3], [4]]) self.assertEqual(self.view.get_run_edit_text(), "1") @@ -128,9 +126,9 @@ class LoadRunWidgetIncrementDecrementMultipleFileModeTest(unittest.TestCase): self.presenter.handle_increment_run() self.wait_for_thread(self.presenter._load_thread) - six.assertCountEqual(self, self.model.loaded_filenames, ["file2.nxs", "file3.nxs", "file4.nxs", "file5.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [[2], [3], [4], [5]]) - six.assertCountEqual(self, self.model.loaded_runs, [[2], [3], [4], [5]]) + self.assertCountEqual(self.model.loaded_filenames, ["file2.nxs", "file3.nxs", "file4.nxs", "file5.nxs"]) + self.assertCountEqual(self.model.loaded_workspaces, [[2], [3], [4], [5]]) + self.assertCountEqual(self.model.loaded_runs, [[2], [3], [4], [5]]) self.assertEqual(self.view.get_run_edit_text(), "5") @@ -143,9 +141,9 @@ class LoadRunWidgetIncrementDecrementMultipleFileModeTest(unittest.TestCase): self.presenter.handle_decrement_run() self.wait_for_thread(self.presenter._load_thread) - six.assertCountEqual(self, self.model.loaded_filenames, ["file2.nxs", "file3.nxs", "file4.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [[2], [3], [4]]) - six.assertCountEqual(self, self.model.loaded_runs, [[2], [3], [4]]) + self.assertCountEqual(self.model.loaded_filenames, ["file2.nxs", "file3.nxs", "file4.nxs"]) + self.assertCountEqual(self.model.loaded_workspaces, [[2], [3], [4]]) + self.assertCountEqual(self.model.loaded_runs, [[2], [3], [4]]) self.assertEqual(self.view.get_run_edit_text(), '2-4') @@ -158,9 +156,9 @@ class LoadRunWidgetIncrementDecrementMultipleFileModeTest(unittest.TestCase): self.presenter.handle_increment_run() self.wait_for_thread(self.presenter._load_thread) - six.assertCountEqual(self, self.model.loaded_filenames, ["file2.nxs", "file3.nxs", "file4.nxs"]) - six.assertCountEqual(self, self.model.loaded_workspaces, [[2], [3], [4]]) - six.assertCountEqual(self, self.model.loaded_runs, [[2], [3], [4]]) + self.assertCountEqual(self.model.loaded_filenames, ["file2.nxs", "file3.nxs", "file4.nxs"]) + self.assertCountEqual(self.model.loaded_workspaces, [[2], [3], [4]]) + self.assertCountEqual(self.model.loaded_runs, [[2], [3], [4]]) self.assertEqual(self.view.get_run_edit_text(), '2-4') diff --git a/scripts/test/Muon/load_run_widget/loadrun_presenter_single_file_test.py b/scripts/test/Muon/load_run_widget/loadrun_presenter_single_file_test.py index b1dcf15a3d96085c67ecae64d8417fafb35edee4..fe7039204c7bbc505c9d72621ee0379f5b521fe8 100644 --- a/scripts/test/Muon/load_run_widget/loadrun_presenter_single_file_test.py +++ b/scripts/test/Muon/load_run_widget/loadrun_presenter_single_file_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication, QWidget diff --git a/scripts/test/Muon/loading_tab/loadwidget_presenter_failure_test.py b/scripts/test/Muon/loading_tab/loadwidget_presenter_failure_test.py index debf6dce5808a228f1e8fa86f4a2a19581aa8724..cffe14f6f5ea95bafecff803cfc6f50cff6f34ac 100644 --- a/scripts/test/Muon/loading_tab/loadwidget_presenter_failure_test.py +++ b/scripts/test/Muon/loading_tab/loadwidget_presenter_failure_test.py @@ -5,7 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication, QWidget diff --git a/scripts/test/Muon/loading_tab/loadwidget_presenter_multiple_file_test.py b/scripts/test/Muon/loading_tab/loadwidget_presenter_multiple_file_test.py index ee6f53e7bfe72df22981e1969a05b041d72301da..fd0a9dc2c2312b5f6f8f5c7af4d4946ef41c1392 100644 --- a/scripts/test/Muon/loading_tab/loadwidget_presenter_multiple_file_test.py +++ b/scripts/test/Muon/loading_tab/loadwidget_presenter_multiple_file_test.py @@ -9,7 +9,7 @@ import time from mantid import ConfigService from mantid.api import FileFinder -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication, QWidget diff --git a/scripts/test/Muon/loading_tab/loadwidget_presenter_test.py b/scripts/test/Muon/loading_tab/loadwidget_presenter_test.py index 639f27c4d0e44642b1190c45d09f3bb5a0aed797..ac0b87936fb1c4ca722f105d59c02d15a7b7d09e 100644 --- a/scripts/test/Muon/loading_tab/loadwidget_presenter_test.py +++ b/scripts/test/Muon/loading_tab/loadwidget_presenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest from mantid.api import FileFinder -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication, QWidget diff --git a/scripts/test/Muon/max_ent_presenter_load_interaction_test.py b/scripts/test/Muon/max_ent_presenter_load_interaction_test.py index c8f17ec62ef18461a3668df90cc35d0274239c15..8c1852e70e07bc8c23f6cd55a53687a06b22a632 100644 --- a/scripts/test/Muon/max_ent_presenter_load_interaction_test.py +++ b/scripts/test/Muon/max_ent_presenter_load_interaction_test.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import FileFinder -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy import QtCore diff --git a/scripts/test/Muon/muon_context_with_frequency_test.py b/scripts/test/Muon/muon_context_with_frequency_test.py index e45ff09b51d8c1ab6f199d89231162361bf63895..b608b8e45beaf66e37b72f4988d8897dbddbf223 100644 --- a/scripts/test/Muon/muon_context_with_frequency_test.py +++ b/scripts/test/Muon/muon_context_with_frequency_test.py @@ -8,7 +8,7 @@ import unittest from mantidqt.utils.qt.testing import start_qapplication from mantid.api import AnalysisDataService, FileFinder -from mantid.py3compat import mock +from unittest import mock from mantid import ConfigService from mantid.dataobjects import Workspace2D from mantid.simpleapi import CreateWorkspace diff --git a/scripts/test/Muon/muon_data_context_test.py b/scripts/test/Muon/muon_data_context_test.py index 8a85f13df263e65632bf8990c98e6c49d230e24b..596d59ef762662968e77b225c8fa30f6f5742cda 100644 --- a/scripts/test/Muon/muon_data_context_test.py +++ b/scripts/test/Muon/muon_data_context_test.py @@ -9,7 +9,7 @@ import unittest from mantidqt.utils.qt.testing import start_qapplication from mantid.api import AnalysisDataService, FileFinder -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.Common.contexts.muon_data_context import MuonDataContext from Muon.GUI.Common.muon_load_data import MuonLoadData @@ -90,4 +90,4 @@ class MuonDataContextTest(unittest.TestCase): if __name__ == '__main__': - unittest.main(buffer=False, verbosity=2) \ No newline at end of file + unittest.main(buffer=False, verbosity=2) diff --git a/scripts/test/Muon/muon_group_pair_context_test.py b/scripts/test/Muon/muon_group_pair_context_test.py index 67f1c137a20e3075301c33aaa3f7607586f957b3..3477de36934cf48fcc20c9bf6ff8b84cf3d312f3 100644 --- a/scripts/test/Muon/muon_group_pair_context_test.py +++ b/scripts/test/Muon/muon_group_pair_context_test.py @@ -9,7 +9,7 @@ import unittest from Muon.GUI.Common.contexts.muon_group_pair_context import MuonGroupPairContext from Muon.GUI.Common.muon_group import MuonGroup from Muon.GUI.Common.muon_pair import MuonPair -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.Common.test_helpers.general_test_helpers import create_group_populated_by_two_workspace diff --git a/scripts/test/Muon/muon_gui_context_test.py b/scripts/test/Muon/muon_gui_context_test.py index 31d479c5431d59f1613cff111db4aac5e1c67308..1ddd58bf39a7d95d2373011ef71621f84d151caa 100644 --- a/scripts/test/Muon/muon_gui_context_test.py +++ b/scripts/test/Muon/muon_gui_context_test.py @@ -4,16 +4,15 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, unicode_literals) - import sys import unittest from Muon.GUI.Common.contexts.muon_gui_context import MuonGuiContext -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.observer_pattern import Observer from mantidqt.utils.qt.testing import start_qapplication + @start_qapplication class MuonGUIContextTest(unittest.TestCase): def test_can_set_variables(self): diff --git a/scripts/test/Muon/phase_table_widget/phase_table_presenter_test.py b/scripts/test/Muon/phase_table_widget/phase_table_presenter_test.py index c2bffaaf43c5218ee1dc454241e7447c3e64f787..edaaac7e289ca5d347b168154dfe1ff1ee9ca3e3 100644 --- a/scripts/test/Muon/phase_table_widget/phase_table_presenter_test.py +++ b/scripts/test/Muon/phase_table_widget/phase_table_presenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication from qtpy import QtCore diff --git a/scripts/test/Muon/plotting_widget_freq_test.py b/scripts/test/Muon/plotting_widget_freq_test.py index 70c8413aafcfa6579ad295946e96288228e55c40..affdd4d25163cc9ccf56485b66c0fb2d2abcc863 100644 --- a/scripts/test/Muon/plotting_widget_freq_test.py +++ b/scripts/test/Muon/plotting_widget_freq_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.plotting_widget.plotting_widget_presenter import PlotWidgetPresenter diff --git a/scripts/test/Muon/plotting_widget_model_test.py b/scripts/test/Muon/plotting_widget_model_test.py index 2925c404bab0caa7a4d27938716346035e063ed6..d48e00815bb09bf4e8a31c3a3458cdca1d7c2552 100644 --- a/scripts/test/Muon/plotting_widget_model_test.py +++ b/scripts/test/Muon/plotting_widget_model_test.py @@ -6,8 +6,8 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock -from mantid.py3compat.mock import patch +from unittest import mock +from unittest.mock import patch from Muon.GUI.Common.plotting_widget.plotting_widget_model import PlotWidgetModel from mantid.simpleapi import * diff --git a/scripts/test/Muon/plotting_widget_test.py b/scripts/test/Muon/plotting_widget_test.py index da98b429c563569ea85e71e5f0512551d68a5410..18a7ae44007bdbed3b8198fa0a1d3fe556cc94d3 100644 --- a/scripts/test/Muon/plotting_widget_test.py +++ b/scripts/test/Muon/plotting_widget_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.plotting_widget.plotting_widget_presenter import PlotWidgetPresenter diff --git a/scripts/test/Muon/plotting_widget_tiled_test.py b/scripts/test/Muon/plotting_widget_tiled_test.py index 5339cc0e7fa186f05a80d9ffe31e04742b47849c..49c13098d01168451756cd8d09d4ba99696524dd 100644 --- a/scripts/test/Muon/plotting_widget_tiled_test.py +++ b/scripts/test/Muon/plotting_widget_tiled_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.plotting_widget.plotting_widget_presenter import PlotWidgetPresenter from Muon.GUI.Common.contexts.fitting_context import FitInformation diff --git a/scripts/test/Muon/results_tab_widget/results_tab_model_test.py b/scripts/test/Muon/results_tab_widget/results_tab_model_test.py index f5fd29855c46d17e8719e10db9c1935cfaf33a56..a05bd82c2921219bad548d6f19914fae09104136 100644 --- a/scripts/test/Muon/results_tab_widget/results_tab_model_test.py +++ b/scripts/test/Muon/results_tab_widget/results_tab_model_test.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + # This file is part of the mantid workbench. -from __future__ import (absolute_import, print_function, unicode_literals) - from collections import OrderedDict from copy import deepcopy import datetime @@ -14,7 +12,7 @@ import unittest from mantid.api import AnalysisDataService, ITableWorkspace, WorkspaceFactory, WorkspaceGroup from mantid.kernel import FloatTimeSeriesProperty, StringPropertyWithValue -from mantid.py3compat import iteritems, mock, string_types +from unittest import mock from mantid.simpleapi import Load from mantidqt.utils.qt.testing import start_qapplication @@ -51,7 +49,7 @@ def create_test_fits(input_workspaces, 'Name': name, 'Value': value, 'Error': error - } for name, (value, error) in iteritems(parameters)] + } for name, (value, error) in parameters.items()] fits = [] for name in input_workspaces: @@ -382,7 +380,7 @@ class ResultsTabModelTest(unittest.TestCase): self.assertEqual(len(expected_row), len(actual_row)) for col_index, expected in enumerate(expected_row): actual = table.cell(row_index, col_index) - if isinstance(expected, string_types): + if isinstance(expected, str): self.assertEqual(expected, actual) else: # Fit pushes things back/forth through strings so exact match is not possible diff --git a/scripts/test/Muon/results_tab_widget/results_tab_presenter_test.py b/scripts/test/Muon/results_tab_widget/results_tab_presenter_test.py index 5b094817e14c16dd7a1d9a42d024c920ca0b52d9..85b6d348ac8e4c9e9f9e48b747a9a3b7d7d1eb9a 100644 --- a/scripts/test/Muon/results_tab_widget/results_tab_presenter_test.py +++ b/scripts/test/Muon/results_tab_widget/results_tab_presenter_test.py @@ -5,7 +5,7 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.Common.results_tab_widget.results_tab_presenter import ResultsTabPresenter RESULTS_TAB_MODEL_CLS = 'Muon.GUI.Common.results_tab_widget.results_tab_model.ResultsTabModel' diff --git a/scripts/test/Muon/seq_fitting_tab_widget/seq_fitting_tab_presenter_test.py b/scripts/test/Muon/seq_fitting_tab_widget/seq_fitting_tab_presenter_test.py index 96b3f6d400f58cb0b28bd7414eae2a84b3a7768d..18565d9c08d0a0bbd9941ccd7fce3a02eda70977 100644 --- a/scripts/test/Muon/seq_fitting_tab_widget/seq_fitting_tab_presenter_test.py +++ b/scripts/test/Muon/seq_fitting_tab_widget/seq_fitting_tab_presenter_test.py @@ -7,7 +7,7 @@ import unittest from mantid.api import FunctionFactory, MultiDomainFunction -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.seq_fitting_tab_widget.seq_fitting_tab_presenter import SeqFittingTabPresenter from Muon.GUI.Common.test_helpers.context_setup import setup_context diff --git a/scripts/test/Muon/transformWidget_test.py b/scripts/test/Muon/transformWidget_test.py index c1c6bc3d39e06ec04f5a882b7fa5d788c3dff3bf..3349f91756a9502611b34d12fa2e2e097825bba2 100644 --- a/scripts/test/Muon/transformWidget_test.py +++ b/scripts/test/Muon/transformWidget_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.utilities import load_utils diff --git a/scripts/test/Muon/transform_widget_new_test.py b/scripts/test/Muon/transform_widget_new_test.py index a8f3c21fe7929f9d06a2ce45960305e278d2ce1d..6150293de123a214421f53739f36f17be1c74202 100644 --- a/scripts/test/Muon/transform_widget_new_test.py +++ b/scripts/test/Muon/transform_widget_new_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication # need to write tests for new GUI diff --git a/scripts/test/Muon/utilities/load_utils_test.py b/scripts/test/Muon/utilities/load_utils_test.py index 4f4efaa045751b91553af1fb57dcdd6a0a07f3aa..adf6ac05fec2cc4ac6460306c6e7247c42b4b231 100644 --- a/scripts/test/Muon/utilities/load_utils_test.py +++ b/scripts/test/Muon/utilities/load_utils_test.py @@ -10,7 +10,7 @@ import unittest from mantid import simpleapi, ConfigService from mantid.api import AnalysisDataService, ITableWorkspace -from mantid.py3compat import mock +from unittest import mock def create_simple_workspace(data_x, data_y, run_number=0): diff --git a/scripts/test/Muon/utilities/muon_file_utils_test.py b/scripts/test/Muon/utilities/muon_file_utils_test.py index 8eb53adc91e4ff8d9c0a9be7046e2ef74d4ca3f9..abf1cc6f5e77d8b03d0b7454dd3662d4e187a49d 100644 --- a/scripts/test/Muon/utilities/muon_file_utils_test.py +++ b/scripts/test/Muon/utilities/muon_file_utils_test.py @@ -8,7 +8,7 @@ import os from io import StringIO import unittest -from mantid.py3compat import mock +from unittest import mock import Muon.GUI.Common.utilities.muon_file_utils as utils diff --git a/scripts/test/Muon/utilities/muon_load_data_test.py b/scripts/test/Muon/utilities/muon_load_data_test.py index 8562ecd03647646be36c4e1e99031264898dd762..28343b3a1ff3e747b9756163f84a7527a1f02e52 100644 --- a/scripts/test/Muon/utilities/muon_load_data_test.py +++ b/scripts/test/Muon/utilities/muon_load_data_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from Muon.GUI.Common.muon_load_data import MuonLoadData diff --git a/scripts/test/Muon/utilities/muon_workspace_wrapper_directory_test.py b/scripts/test/Muon/utilities/muon_workspace_wrapper_directory_test.py index 3fe2696e9629cbe2355b86bff9f46086273418df..c5b835c2563c04a38d04899cbc906d66422d47ed 100644 --- a/scripts/test/Muon/utilities/muon_workspace_wrapper_directory_test.py +++ b/scripts/test/Muon/utilities/muon_workspace_wrapper_directory_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid.simpleapi as simpleapi diff --git a/scripts/test/Muon/utilities/muon_workspace_wrapper_test.py b/scripts/test/Muon/utilities/muon_workspace_wrapper_test.py index 8fc91086fa1087cc1889e70fe513f2d82e5c33ce..1f741d8f7bd49d27a5f6288cf3f33ef8743db4e2 100644 --- a/scripts/test/Muon/utilities/muon_workspace_wrapper_test.py +++ b/scripts/test/Muon/utilities/muon_workspace_wrapper_test.py @@ -4,11 +4,7 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -import six - import mantid.simpleapi as simpleapi from mantid.api import ITableWorkspace, WorkspaceGroup from mantid.dataobjects import Workspace2D @@ -124,8 +120,8 @@ class MuonWorkspaceTest(unittest.TestCase): self.assertTrue(simpleapi.mtd.doesExist("test")) ads_workspace = simpleapi.mtd["test"] - six.assertCountEqual(self, ads_workspace.readX(0), [1, 2, 3, 4]) - six.assertCountEqual(self, ads_workspace.readY(0), [10, 10, 10, 10]) + self.assertCountEqual(ads_workspace.readX(0), [1, 2, 3, 4]) + self.assertCountEqual(ads_workspace.readY(0), [10, 10, 10, 10]) def test_that_hiding_the_workspace_removes_it_from_ADS(self): workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace) @@ -141,8 +137,8 @@ class MuonWorkspaceTest(unittest.TestCase): ws_property = workspace_handle.workspace - six.assertCountEqual(self, ws_property.readX(0), [1, 2, 3, 4]) - six.assertCountEqual(self, ws_property.readY(0), [10, 10, 10, 10]) + self.assertCountEqual(ws_property.readX(0), [1, 2, 3, 4]) + self.assertCountEqual(ws_property.readY(0), [10, 10, 10, 10]) def test_that_workspace_property_returns_workspace_when_in_ADS(self): workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace) @@ -150,8 +146,8 @@ class MuonWorkspaceTest(unittest.TestCase): workspace_handle.show("arbitrary_name") ws_property = workspace_handle.workspace - six.assertCountEqual(self, ws_property.readX(0), [1, 2, 3, 4]) - six.assertCountEqual(self, ws_property.readY(0), [10, 10, 10, 10]) + self.assertCountEqual(ws_property.readX(0), [1, 2, 3, 4]) + self.assertCountEqual(ws_property.readY(0), [10, 10, 10, 10]) def test_that_can_change_name_when_workspace_not_in_ADS(self): workspace_handle = MuonWorkspaceWrapper(workspace=self.workspace) diff --git a/scripts/test/Muon/utilities/thread_model_test.py b/scripts/test/Muon/utilities/thread_model_test.py index 151ca9497eca3e31f0a294c29a3fa2a7421fb27b..b323721483fc9d439cd3c202c6a17d986491fa6b 100644 --- a/scripts/test/Muon/utilities/thread_model_test.py +++ b/scripts/test/Muon/utilities/thread_model_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from qtpy.QtWidgets import QApplication diff --git a/scripts/test/Muon/workspace_finder_test.py b/scripts/test/Muon/workspace_finder_test.py index df5c62f0e0bf63fe9f3ebc3dd638be558333310a..016451b3727dacd87c2ad6c042f1baed9b6616f1 100644 --- a/scripts/test/Muon/workspace_finder_test.py +++ b/scripts/test/Muon/workspace_finder_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from mantidqt.utils.qt.testing import start_qapplication from Muon.GUI.Common.test_helpers.context_setup import setup_context from Muon.GUI.Common.plotting_widget.workspace_finder import WorkspaceFinder diff --git a/scripts/test/ReductionWrapperTest.py b/scripts/test/ReductionWrapperTest.py index da744f2275652ed55eb34cf2171d7bab027c2afa..3856b3b88c5e8b8561bc7b6b21292b92f41fcd93 100644 --- a/scripts/test/ReductionWrapperTest.py +++ b/scripts/test/ReductionWrapperTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os,sys from mantid.simpleapi import * @@ -18,6 +17,7 @@ import MariReduction as mr import unittest import imp + class test_helper(ReductionWrapper): def __init__(self,web_var=None): """ sets properties defaults for the instrument with Name""" @@ -81,6 +81,8 @@ class test_helper(ReductionWrapper): #----------------------------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------------------------------------- + + class ReductionWrapperTest(unittest.TestCase): def __init__(self, methodName): @@ -306,4 +308,3 @@ class ReductionWrapperTest(unittest.TestCase): if __name__=="__main__": unittest.main() - diff --git a/scripts/test/ReflectometryQuickAuxiliaryTest.py b/scripts/test/ReflectometryQuickAuxiliaryTest.py index d022db02487e49a453ccc449b3edd58587bdba05..310b15c286e2a8035c4aeefa8b0baf72af25d508 100644 --- a/scripts/test/ReflectometryQuickAuxiliaryTest.py +++ b/scripts/test/ReflectometryQuickAuxiliaryTest.py @@ -4,12 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import numpy from mantid.simpleapi import * from isis_reflectometry import quick + class ReflectometryQuickAuxiliaryTest(unittest.TestCase): __wsName = None diff --git a/scripts/test/RunDescriptorTest.py b/scripts/test/RunDescriptorTest.py index b19b56ddbfa00d203045f83002a4e736330cf15b..bbe774e063110353c7f70cb9c91203f35a1af11e 100644 --- a/scripts/test/RunDescriptorTest.py +++ b/scripts/test/RunDescriptorTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import os,sys,inspect from mantid.simpleapi import * from mantid import api diff --git a/scripts/test/SANS/algorithm_detail/batch_execution_test.py b/scripts/test/SANS/algorithm_detail/batch_execution_test.py index 61be4dd7e895032b53cda30bf56bf4f4e25e958a..191cd51349017280804148fe1e5cfea1fc904f4f 100644 --- a/scripts/test/SANS/algorithm_detail/batch_execution_test.py +++ b/scripts/test/SANS/algorithm_detail/batch_execution_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from mantid.simpleapi import CreateSampleWorkspace from sans.algorithm_detail.batch_execution import (get_all_names_to_save, get_transmission_names_to_save, ReductionPackage, select_reduction_alg, save_workspace_to_file) diff --git a/scripts/test/SANS/algorithm_detail/calculate_sans_transmission_test.py b/scripts/test/SANS/algorithm_detail/calculate_sans_transmission_test.py index b9f060ef1f569672eb6ea3ba8bc603a3e18377db..86c537c512a905bc3a22a3d32fa51095a1cb18df 100644 --- a/scripts/test/SANS/algorithm_detail/calculate_sans_transmission_test.py +++ b/scripts/test/SANS/algorithm_detail/calculate_sans_transmission_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import unittest diff --git a/scripts/test/SANS/algorithm_detail/calculate_transmission_helper_test.py b/scripts/test/SANS/algorithm_detail/calculate_transmission_helper_test.py index 80e0387948f44a5afb902210fbb2e2d768a00d70..a0e17a954ffed7c7d83968ab1670a289919998a3 100644 --- a/scripts/test/SANS/algorithm_detail/calculate_transmission_helper_test.py +++ b/scripts/test/SANS/algorithm_detail/calculate_transmission_helper_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import unittest diff --git a/scripts/test/SANS/algorithm_detail/centre_finder_new_test.py b/scripts/test/SANS/algorithm_detail/centre_finder_new_test.py index 69380d5f5457af0c18e57150fd6f60d89c203969..73a69ae600be1ba8b863d47edd6a7b02ae4d59dc 100644 --- a/scripts/test/SANS/algorithm_detail/centre_finder_new_test.py +++ b/scripts/test/SANS/algorithm_detail/centre_finder_new_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from sans.algorithm_detail.centre_finder_new import centre_finder_new, centre_finder_mass from sans.common.enums import (SANSDataType, FindDirectionEnum, DetectorType) from sans.test_helper.test_director import TestDirector diff --git a/scripts/test/SANS/algorithm_detail/convert_to_q_test.py b/scripts/test/SANS/algorithm_detail/convert_to_q_test.py index de9efbed3b62095d918d77e262423073d8f038aa..bb66b69399a7db943e2b175207ce47189d389b58 100644 --- a/scripts/test/SANS/algorithm_detail/convert_to_q_test.py +++ b/scripts/test/SANS/algorithm_detail/convert_to_q_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import DeleteWorkspace diff --git a/scripts/test/SANS/algorithm_detail/create_sans_adjustment_workspaces_test.py b/scripts/test/SANS/algorithm_detail/create_sans_adjustment_workspaces_test.py index 02bd80f13a71d5fdd7d69671c14b10d904a5b686..1d018ff39a25039ebc567f2b8b26eec9f712000f 100644 --- a/scripts/test/SANS/algorithm_detail/create_sans_adjustment_workspaces_test.py +++ b/scripts/test/SANS/algorithm_detail/create_sans_adjustment_workspaces_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.simpleapi import CreateSampleWorkspace, CloneWorkspace, Load, Rebin diff --git a/scripts/test/SANS/algorithm_detail/create_sans_wavelength_pixel_adjustment_test.py b/scripts/test/SANS/algorithm_detail/create_sans_wavelength_pixel_adjustment_test.py index 610a44c77faa0e558773e9d8f5050f2b83457fc7..20177caab952336d9ca0fbd8cc98e9e7b560c439 100644 --- a/scripts/test/SANS/algorithm_detail/create_sans_wavelength_pixel_adjustment_test.py +++ b/scripts/test/SANS/algorithm_detail/create_sans_wavelength_pixel_adjustment_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import numpy as np import os import unittest diff --git a/scripts/test/SANS/algorithm_detail/crop_helper_test.py b/scripts/test/SANS/algorithm_detail/crop_helper_test.py index b55e8e1f400631ee1bfb069ee1b294cbe3f68f85..ca9df6248e526a6a0b5f20335f21e51f561d0c2a 100644 --- a/scripts/test/SANS/algorithm_detail/crop_helper_test.py +++ b/scripts/test/SANS/algorithm_detail/crop_helper_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import FileFinder diff --git a/scripts/test/SANS/algorithm_detail/merge_reductions_test.py b/scripts/test/SANS/algorithm_detail/merge_reductions_test.py index f4be8a8351f5a1b37ad61f69e2dbf683f435c24f..2396dc7c17b3930c20b4357456920af827dd3685 100644 --- a/scripts/test/SANS/algorithm_detail/merge_reductions_test.py +++ b/scripts/test/SANS/algorithm_detail/merge_reductions_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.algorithm_detail.bundles import OutputPartsBundle diff --git a/scripts/test/SANS/algorithm_detail/move_sans_instrument_component_test.py b/scripts/test/SANS/algorithm_detail/move_sans_instrument_component_test.py index f214c9accb1604e1315432d74ede9cf49ac77052..d7076a810e43159787292ca1dc919243e3c1f074 100644 --- a/scripts/test/SANS/algorithm_detail/move_sans_instrument_component_test.py +++ b/scripts/test/SANS/algorithm_detail/move_sans_instrument_component_test.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + # pylint: disable=too-many-public-methods, invalid-name, too-many-arguments -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import (Quat, V3D) diff --git a/scripts/test/SANS/algorithm_detail/move_workspaces_test.py b/scripts/test/SANS/algorithm_detail/move_workspaces_test.py index 726329c05a5098f70e24ac7f0e7146a8a1ad8771..ae4b8692ac2f232e32e166ad6ff469586b2efdec 100644 --- a/scripts/test/SANS/algorithm_detail/move_workspaces_test.py +++ b/scripts/test/SANS/algorithm_detail/move_workspaces_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest import mantid.simpleapi diff --git a/scripts/test/SANS/algorithm_detail/normalize_to_sans_monitor_test.py b/scripts/test/SANS/algorithm_detail/normalize_to_sans_monitor_test.py index 11698b4d651fb9fb5a8cc867954d7ef858d9bfa8..59d3c26b8f1fd3e571817d12aada9528916ebf43 100644 --- a/scripts/test/SANS/algorithm_detail/normalize_to_sans_monitor_test.py +++ b/scripts/test/SANS/algorithm_detail/normalize_to_sans_monitor_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AnalysisDataService diff --git a/scripts/test/SANS/algorithm_detail/sans_slice_event_test.py b/scripts/test/SANS/algorithm_detail/sans_slice_event_test.py index e3c56a8840c1e6cda25566d5dd18e932777d25c5..c2271d8a46d85e1b752c01d65d83602958f77630 100644 --- a/scripts/test/SANS/algorithm_detail/sans_slice_event_test.py +++ b/scripts/test/SANS/algorithm_detail/sans_slice_event_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.dataobjects import Workspace2D diff --git a/scripts/test/SANS/algorithm_detail/scale_sans_workspace_test.py b/scripts/test/SANS/algorithm_detail/scale_sans_workspace_test.py index d24ad7961bfd474a2a5e2288cfa2e415537ddccc..2feeb5f06aaa32f3709bdc2f7e90ae4ffbff4b68 100644 --- a/scripts/test/SANS/algorithm_detail/scale_sans_workspace_test.py +++ b/scripts/test/SANS/algorithm_detail/scale_sans_workspace_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import math import unittest diff --git a/scripts/test/SANS/algorithm_detail/strip_end_nans_test.py b/scripts/test/SANS/algorithm_detail/strip_end_nans_test.py index cbc3b81c3d91fd51f918f7215033ac452499fa4a..64efcf849b189ac5b6ef2fc34ff543159fc591c3 100644 --- a/scripts/test/SANS/algorithm_detail/strip_end_nans_test.py +++ b/scripts/test/SANS/algorithm_detail/strip_end_nans_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmManager, FrameworkManager diff --git a/scripts/test/SANS/command_interface/batch_csv_file_parser_test.py b/scripts/test/SANS/command_interface/batch_csv_file_parser_test.py index cac6b5b9594c19f35247e3732915fec4fe84eafa..c0b2b1306014c434fd8feb1fb83ca227474f8d80 100644 --- a/scripts/test/SANS/command_interface/batch_csv_file_parser_test.py +++ b/scripts/test/SANS/command_interface/batch_csv_file_parser_test.py @@ -4,15 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import unittest -import six - import mantid -from mantid.py3compat import csv_open_type, mock +from unittest import mock from sans.command_interface.batch_csv_parser import BatchCsvParser from sans.common.constants import ALL_PERIODS from sans.gui_logic.models.RowEntries import RowEntries @@ -225,11 +221,11 @@ class BatchCsvParserTest(unittest.TestCase): expected_file_path = "/foo/bar.csv" parser = BatchCsvParser() - patchable = "__builtin__.open" if six.PY2 else "builtins.open" + patchable = "builtins.open" with mock.patch(patchable, mocked_handle): parser.save_batch_file(rows=[], file_path=expected_file_path) - mocked_handle.assert_called_with(expected_file_path, csv_open_type) + mocked_handle.assert_called_with(expected_file_path, "w") def test_parses_row_to_csv_correctly(self): test_row = RowEntries() @@ -257,7 +253,7 @@ class BatchCsvParserTest(unittest.TestCase): mocked_handle = mock.mock_open() parser = BatchCsvParser() - patchable = "__builtin__.open" if six.PY2 else "builtins.open" + patchable = "builtins.open" with mock.patch(patchable, mocked_handle): parser.save_batch_file(rows=[test_row], file_path='') diff --git a/scripts/test/SANS/command_interface/command_interface_state_director_test.py b/scripts/test/SANS/command_interface/command_interface_state_director_test.py index 0aa3a53b81ee3727438c6ebb93425220c66bf9a3..49b51b194efb0d3dfb61ee77eb91cbefb27ae638 100644 --- a/scripts/test/SANS/command_interface/command_interface_state_director_test.py +++ b/scripts/test/SANS/command_interface/command_interface_state_director_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.command_interface.command_interface_state_director import (NParameterCommand, NParameterCommandId, diff --git a/scripts/test/SANS/command_interface/isis_command_interface_test.py b/scripts/test/SANS/command_interface/isis_command_interface_test.py index d8f735253570fe988a75fe504f3d4ae0e0b7c9ea..04f1db90ec7b1affc041cdb273ad5da134dd668e 100644 --- a/scripts/test/SANS/command_interface/isis_command_interface_test.py +++ b/scripts/test/SANS/command_interface/isis_command_interface_test.py @@ -9,14 +9,10 @@ import tempfile import unittest import uuid -import six -from mantid.py3compat import mock +from unittest import mock from sans.command_interface.ISISCommandInterface import MaskFile -if six.PY2: - FileNotFoundError = IOError - class ISISCommandInterfaceTest(unittest.TestCase): def test_mask_file_raises_for_empty_file_name(self): diff --git a/scripts/test/SANS/common/file_information_test.py b/scripts/test/SANS/common/file_information_test.py index 897435d20482649017eab84f7069ed05aad76ea3..32a05b38d7319f6f87c9919f65646fd18a2d8829 100644 --- a/scripts/test/SANS/common/file_information_test.py +++ b/scripts/test/SANS/common/file_information_test.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import DateAndTime -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import SampleShape from sans.common.file_information import (SANSFileInformationFactory, FileType, SANSInstrument, get_instrument_paths_for_sans_file) diff --git a/scripts/test/SANS/common/general_functions_test.py b/scripts/test/SANS/common/general_functions_test.py index 12a68beb8607d78e38dd3afa19114cb52a40fac8..4c940b201794e2790405307be50d365cc988bcd5 100644 --- a/scripts/test/SANS/common/general_functions_test.py +++ b/scripts/test/SANS/common/general_functions_test.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AnalysisDataService, FrameworkManager from mantid.kernel import (V3D, Quat) -from mantid.py3compat import mock +from unittest import mock from sans.common.constants import (SANS2D, LOQ, LARMOR) from sans.common.enums import (ReductionMode, ReductionDimensionality, OutputParts, SANSInstrument, DetectorType, SANSFacility, DataType) diff --git a/scripts/test/SANS/common/log_tagger_test.py b/scripts/test/SANS/common/log_tagger_test.py index 8c51519ff626a36ec056834b171517b96471bd3e..45fe26fd041d07ff6b95b9f9424392de4e5e5e32 100644 --- a/scripts/test/SANS/common/log_tagger_test.py +++ b/scripts/test/SANS/common/log_tagger_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.api import AlgorithmManager, FrameworkManager diff --git a/scripts/test/SANS/common/xml_parsing_test.py b/scripts/test/SANS/common/xml_parsing_test.py index 88cb19776b1aa6e590c1e99be9a700aab6289ae4..4b3796c3ce153772fdafc9fe692731b856095648 100644 --- a/scripts/test/SANS/common/xml_parsing_test.py +++ b/scripts/test/SANS/common/xml_parsing_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import DateAndTime @@ -89,5 +87,3 @@ class XMLParsingTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - - diff --git a/scripts/test/SANS/gui_logic/add_runs_presenter_test.py b/scripts/test/SANS/gui_logic/add_runs_presenter_test.py index 406560eced2f6442675a42f8052cff17458af0d9..80ce7e4f6080dbfb6b1f1f169e3569b4ac7c992c 100644 --- a/scripts/test/SANS/gui_logic/add_runs_presenter_test.py +++ b/scripts/test/SANS/gui_logic/add_runs_presenter_test.py @@ -10,7 +10,7 @@ import unittest from assert_called import assert_called from fake_signal import FakeSignal from mantid.kernel import ConfigService -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import SANSInstrument from sans.gui_logic.models import SumRunsModel from sans.gui_logic.models.SumRunsModel import SumRunsModel @@ -179,6 +179,7 @@ def create_mocked_runs(start, len): mock_instance.display_name.return_value = start + x return run_selection + class BaseFileNameTest(AddRunsPagePresenterTestCase): def setUp(self): self.view = self._make_mock_view() diff --git a/scripts/test/SANS/gui_logic/batch_process_runner_test.py b/scripts/test/SANS/gui_logic/batch_process_runner_test.py index 23b26e0f3cbe2205eef4d2f388e20183e07b5af5..a1d45680e89e4671ce234e269925754d7f687d0c 100644 --- a/scripts/test/SANS/gui_logic/batch_process_runner_test.py +++ b/scripts/test/SANS/gui_logic/batch_process_runner_test.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from qtpy.QtCore import QThreadPool -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import (OutputMode) from sans.gui_logic.models.batch_process_runner import BatchProcessRunner diff --git a/scripts/test/SANS/gui_logic/beam_centre_model_test.py b/scripts/test/SANS/gui_logic/beam_centre_model_test.py index ba804546e688f3da30c1219e5ffa4be320d3a086..f91116221378441912b0547e0324e34a4b522f01 100644 --- a/scripts/test/SANS/gui_logic/beam_centre_model_test.py +++ b/scripts/test/SANS/gui_logic/beam_centre_model_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import FindDirectionEnum, SANSInstrument, DetectorType from sans.gui_logic.models.beam_centre_model import BeamCentreModel diff --git a/scripts/test/SANS/gui_logic/beam_centre_presenter_test.py b/scripts/test/SANS/gui_logic/beam_centre_presenter_test.py index 28dcdd74fd6ad426f29ded65c968cb6772c45afe..7648fe7051fe5cb1eec3560970a6f7757a49faa5 100644 --- a/scripts/test/SANS/gui_logic/beam_centre_presenter_test.py +++ b/scripts/test/SANS/gui_logic/beam_centre_presenter_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import SANSInstrument from sans.gui_logic.presenter.beam_centre_presenter import BeamCentrePresenter from sans.test_helper.mock_objects import create_mock_beam_centre_tab diff --git a/scripts/test/SANS/gui_logic/create_state_test.py b/scripts/test/SANS/gui_logic/create_state_test.py index 7f2b7126bc03100417d2e3ab5cabc102d419d4b6..a0899c819dd8b14d8767a43a71f2ec850d9cd3c9 100644 --- a/scripts/test/SANS/gui_logic/create_state_test.py +++ b/scripts/test/SANS/gui_logic/create_state_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import (SANSFacility, SaveType) from sans.gui_logic.models.RowEntries import RowEntries from sans.gui_logic.models.create_state import (create_states, create_gui_state_from_userfile) diff --git a/scripts/test/SANS/gui_logic/diagnostics_page_model_test.py b/scripts/test/SANS/gui_logic/diagnostics_page_model_test.py index 6e270a4ee832ef3bb0296278ac67cd18b17a5fd0..7f28064b00abb8e890e89ca8316a058aca07fb18 100644 --- a/scripts/test/SANS/gui_logic/diagnostics_page_model_test.py +++ b/scripts/test/SANS/gui_logic/diagnostics_page_model_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import SANSFacility diff --git a/scripts/test/SANS/gui_logic/diagnostics_page_presenter_test.py b/scripts/test/SANS/gui_logic/diagnostics_page_presenter_test.py index 04c7d9d33a70490bdbbf69ee07c7267eaa5cffac..293fa8d0a10a5d5007247d533cfb9230bc1e9897 100644 --- a/scripts/test/SANS/gui_logic/diagnostics_page_presenter_test.py +++ b/scripts/test/SANS/gui_logic/diagnostics_page_presenter_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import SANSInstrument, DetectorType, IntegralEnum, SANSFacility from sans.gui_logic.presenter.diagnostic_presenter import DiagnosticsPagePresenter from sans.test_helper.mock_objects import create_mock_diagnostics_tab diff --git a/scripts/test/SANS/gui_logic/gui_common_test.py b/scripts/test/SANS/gui_logic/gui_common_test.py index 00feccb4b840ab27e10f0f1b2cc03537eeb40e60..9dfd627c38f8f35f22ad73e4fe5c33636d089561 100644 --- a/scripts/test/SANS/gui_logic/gui_common_test.py +++ b/scripts/test/SANS/gui_logic/gui_common_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import (SANSInstrument, ReductionMode) from sans.gui_logic.gui_common import (get_reduction_mode_strings_for_gui, get_reduction_selection, get_string_for_gui_from_reduction_mode, diff --git a/scripts/test/SANS/gui_logic/gui_state_director_test.py b/scripts/test/SANS/gui_logic/gui_state_director_test.py index 5f9bd10dd46fcd981bb43c9f5c2ec1f72763b0d1..87b3696e4f7e5546f9e660af168bb0d42785ecdd 100644 --- a/scripts/test/SANS/gui_logic/gui_state_director_test.py +++ b/scripts/test/SANS/gui_logic/gui_state_director_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import unittest diff --git a/scripts/test/SANS/gui_logic/masking_table_presenter_test.py b/scripts/test/SANS/gui_logic/masking_table_presenter_test.py index a386998af70398f8f68d08003ce72bb16f49c34b..40e13f81515c63208cd2a1bf801c9aaeb1d5906a 100644 --- a/scripts/test/SANS/gui_logic/masking_table_presenter_test.py +++ b/scripts/test/SANS/gui_logic/masking_table_presenter_test.py @@ -4,11 +4,9 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from mantid.py3compat import mock +from unittest import mock from sans.gui_logic.presenter.masking_table_presenter import (MaskingTablePresenter, masking_information) from sans.test_helper.mock_objects import (FakeState, create_mock_masking_table, create_run_tab_presenter_mock) diff --git a/scripts/test/SANS/gui_logic/model_tests/RowEntriesTest.py b/scripts/test/SANS/gui_logic/model_tests/RowEntriesTest.py index 78a0bfb4ae57092b8b5264092925ed9f04ce606b..8d552c92886f8824ffd3c14de846ebbafdb7cd8f 100644 --- a/scripts/test/SANS/gui_logic/model_tests/RowEntriesTest.py +++ b/scripts/test/SANS/gui_logic/model_tests/RowEntriesTest.py @@ -6,8 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from six import iterkeys - from sans.common.enums import RowState from sans.gui_logic.models.RowEntries import RowEntries, _UserEntries @@ -16,7 +14,7 @@ class RowEntriesTest(unittest.TestCase): def test_settings_attr_resets_state(self): observed_attrs = vars(_UserEntries()) - for observed_attr in iterkeys(observed_attrs): + for observed_attr in observed_attrs.keys(): obj = RowEntries() obj.state = RowState.PROCESSED setattr(obj, observed_attr, "") @@ -47,7 +45,7 @@ class RowEntriesTest(unittest.TestCase): blank_obj = RowEntries() self.assertTrue(blank_obj.is_empty(), "Default Row Entries is not blank") - for attr in iterkeys(vars(_UserEntries())): + for attr in vars(_UserEntries()).keys(): obj = RowEntries() setattr(obj, attr, 1.0) self.assertFalse(obj.is_empty()) diff --git a/scripts/test/SANS/gui_logic/presenter_tests/presenter_common_test.py b/scripts/test/SANS/gui_logic/presenter_tests/presenter_common_test.py index 878613d3e88abc55da42c80215509f8533df02f0..aff1e6bf6ae22bbd6f16272d291234ccc4717534 100644 --- a/scripts/test/SANS/gui_logic/presenter_tests/presenter_common_test.py +++ b/scripts/test/SANS/gui_logic/presenter_tests/presenter_common_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from sans.gui_logic.presenter.presenter_common import PresenterCommon diff --git a/scripts/test/SANS/gui_logic/presenter_tests/settings_adjustment_presenter_test.py b/scripts/test/SANS/gui_logic/presenter_tests/settings_adjustment_presenter_test.py index f3b493ae9bb582b5ffb476c727fe1b3f7ad30f97..ab517513df4c6b61ad38820b8ebb86af6ba6807d 100644 --- a/scripts/test/SANS/gui_logic/presenter_tests/settings_adjustment_presenter_test.py +++ b/scripts/test/SANS/gui_logic/presenter_tests/settings_adjustment_presenter_test.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat.mock import Mock +from unittest.mock import Mock from sans.common.enums import SANSInstrument from sans.gui_logic.presenter.settings_adjustment_presenter import SettingsAdjustmentPresenter diff --git a/scripts/test/SANS/gui_logic/run_selector_presenter_test.py b/scripts/test/SANS/gui_logic/run_selector_presenter_test.py index a7796b5c40a2cab5cff95ed2d16597aeec1dfef9..89fe7ae1029b7ecd6bcae8866abbc2a5b1b20504 100644 --- a/scripts/test/SANS/gui_logic/run_selector_presenter_test.py +++ b/scripts/test/SANS/gui_logic/run_selector_presenter_test.py @@ -8,7 +8,7 @@ import unittest from assert_called import assert_called from fake_signal import FakeSignal -from mantid.py3compat import mock +from unittest import mock from sans.gui_logic.models.RunSelectionModel import RunSelectionModel from sans.gui_logic.models.run_file import SummableRunFile from sans.gui_logic.models.run_finder import SummableRunFinder diff --git a/scripts/test/SANS/gui_logic/run_tab_presenter_test.py b/scripts/test/SANS/gui_logic/run_tab_presenter_test.py index acefe8b09c8594870eea2fe65fdf53eb3f13dd48..d55b5055617f5e0fca715d12e8d5b9918acc9e9b 100644 --- a/scripts/test/SANS/gui_logic/run_tab_presenter_test.py +++ b/scripts/test/SANS/gui_logic/run_tab_presenter_test.py @@ -4,13 +4,11 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid.kernel import PropertyManagerDataService from mantid.kernel import config -from mantid.py3compat import mock +from unittest import mock from sans.command_interface.batch_csv_parser import BatchCsvParser from sans.common.enums import SANSInstrument from sans.common.enums import (SANSFacility, ReductionDimensionality, SaveType, ReductionMode, diff --git a/scripts/test/SANS/gui_logic/save_other_presenter_test.py b/scripts/test/SANS/gui_logic/save_other_presenter_test.py index 76d932e3004fe55c279c9676ba8e537da4e195f0..ba3d9c6c0a0cf739701050b760c0d637951a2c7a 100644 --- a/scripts/test/SANS/gui_logic/save_other_presenter_test.py +++ b/scripts/test/SANS/gui_logic/save_other_presenter_test.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from mantid import ConfigService -from mantid.py3compat import mock +from unittest import mock from sans.gui_logic.presenter.save_other_presenter import SaveOtherPresenter diff --git a/scripts/test/SANS/gui_logic/settings_diagnostic_presenter_test.py b/scripts/test/SANS/gui_logic/settings_diagnostic_presenter_test.py index e2e39cf0980e600cd64baa7d78bba95829adf8f4..6b8325149a207e9e3afe263bafd23eabf49e9022 100644 --- a/scripts/test/SANS/gui_logic/settings_diagnostic_presenter_test.py +++ b/scripts/test/SANS/gui_logic/settings_diagnostic_presenter_test.py @@ -4,14 +4,12 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import json import os import tempfile import unittest -from mantid.py3compat import mock +from unittest import mock from sans.gui_logic.presenter.settings_diagnostic_presenter import SettingsDiagnosticPresenter from sans.state.Serializer import Serializer from sans.test_helper.mock_objects import (create_run_tab_presenter_mock, FakeState, diff --git a/scripts/test/SANS/gui_logic/state_gui_model_test.py b/scripts/test/SANS/gui_logic/state_gui_model_test.py index 165dce58d291e3dfb39e0715d255add1052e9b08..a74cc8ae89bfdaf639b22f8163580d45f763c1d2 100644 --- a/scripts/test/SANS/gui_logic/state_gui_model_test.py +++ b/scripts/test/SANS/gui_logic/state_gui_model_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (ReductionDimensionality, ReductionMode, RangeStepType, SampleShape, SaveType, @@ -319,8 +317,8 @@ class StateGuiModelTest(unittest.TestCase): state_gui_model.q_1d_rebin_string = b"test" q_1d_rebin_string = state_gui_model.q_1d_rebin_string - self.assertEqual(type(q_1d_rebin_string), str) - self.assertEqual(q_1d_rebin_string, "test") + self.assertEqual(type(q_1d_rebin_string), bytes) + self.assertEqual(q_1d_rebin_string, b"test") # ------------------------------------------------------------------------------------------------------------------ # Gravity diff --git a/scripts/test/SANS/gui_logic/summation_settings_presenter_test.py b/scripts/test/SANS/gui_logic/summation_settings_presenter_test.py index 86effd2679231c4d03b3e139ecb1ce8c8d1d7138..5f5eea157804b18d56aac9a125926b5f501df1ad 100644 --- a/scripts/test/SANS/gui_logic/summation_settings_presenter_test.py +++ b/scripts/test/SANS/gui_logic/summation_settings_presenter_test.py @@ -8,7 +8,7 @@ import unittest from assert_called import assert_called from fake_signal import FakeSignal -from mantid.py3compat import mock +from unittest import mock from sans.common.enums import BinningType from sans.gui_logic.models.SummationSettingsModel import SummationSettingsModel from sans.gui_logic.presenter.summation_settings_presenter import SummationSettingsPresenter diff --git a/scripts/test/SANS/gui_logic/table_model_test.py b/scripts/test/SANS/gui_logic/table_model_test.py index 1e589a642e2fee08fdc2856947fa1378c83eb754..327cf168ed5a36ce894170ffa1397bf75885f062 100644 --- a/scripts/test/SANS/gui_logic/table_model_test.py +++ b/scripts/test/SANS/gui_logic/table_model_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import RowState diff --git a/scripts/test/SANS/state/JsonSerializerTest.py b/scripts/test/SANS/state/JsonSerializerTest.py index 069537451ab724d5bc0d82b4682c34ceeabd6f95..1cc5803ecc7132d046914256fe7bc17b82c8720e 100644 --- a/scripts/test/SANS/state/JsonSerializerTest.py +++ b/scripts/test/SANS/state/JsonSerializerTest.py @@ -4,14 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest -from six import with_metaclass - from mantid.api import Algorithm -from mantid.py3compat import Enum +from enum import Enum # ---------------------------------------------------------------------------------------------------------------------- @@ -23,7 +19,7 @@ from sans.state.JsonSerializable import JsonSerializable, json_serializable from sans.state.Serializer import Serializer -class TestClass(with_metaclass(JsonSerializable)): +class TestClass(metaclass=JsonSerializable): string_parameter = None # : Str() bool_parameter = None # : Bool float_parameter = None # : Float @@ -49,7 +45,7 @@ class FakeEnumClass(Enum): BAR = "2" -class ExampleWrapper(with_metaclass(JsonSerializable)): +class ExampleWrapper(metaclass=JsonSerializable): # This has to be at the top module level, else the module name finding will fail def __init__(self): self._foo = FakeEnumClass.FOO @@ -59,7 +55,7 @@ class ExampleWrapper(with_metaclass(JsonSerializable)): return True -class VerySimpleState(with_metaclass(JsonSerializable)): +class VerySimpleState(metaclass=JsonSerializable): string_parameter = None # : Str() def __init__(self): @@ -70,7 +66,7 @@ class VerySimpleState(with_metaclass(JsonSerializable)): pass -class SimpleState(with_metaclass(JsonSerializable)): +class SimpleState(metaclass=JsonSerializable): def __init__(self): super(SimpleState, self).__init__() self.string_parameter = "String_in_SimpleState" @@ -90,7 +86,7 @@ class SimpleState(with_metaclass(JsonSerializable)): pass -class ComplexState(with_metaclass(JsonSerializable)): +class ComplexState(metaclass=JsonSerializable): def __init__(self): super(ComplexState, self).__init__() self.float_parameter = 23. diff --git a/scripts/test/SANS/state/StateBuilderTest.py b/scripts/test/SANS/state/StateBuilderTest.py index 5c82072ef009d4ef2b633bf1ca856755dadd95e2..757439099e0bde135eee2c777e7619ffada0df09 100644 --- a/scripts/test/SANS/state/StateBuilderTest.py +++ b/scripts/test/SANS/state/StateBuilderTest.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from sans.state.IStateParser import IStateParser from sans.state.StateRunDataBuilder import StateRunDataBuilder diff --git a/scripts/test/SANS/state/StateRunDataBuilderTest.py b/scripts/test/SANS/state/StateRunDataBuilderTest.py index d56154dec0641687757c0db2a0d9c4c5c4be678a..23a17d85f58a35c01b83d3f915980d8797bcf6ea 100644 --- a/scripts/test/SANS/state/StateRunDataBuilderTest.py +++ b/scripts/test/SANS/state/StateRunDataBuilderTest.py @@ -6,7 +6,7 @@ # SPDX - License - Identifier: GPL - 3.0 + import unittest -from mantid.py3compat import mock +from unittest import mock from sans.state.StateRunDataBuilder import StateRunDataBuilder from sans.state.StateObjects.StateScale import StateScale diff --git a/scripts/test/SANS/state/adjustment_test.py b/scripts/test/SANS/state/adjustment_test.py index 05baee5dd614310637c934da251bb630b12a68f4..77d0150efe05b79ec600dc534e11725903673ce0 100644 --- a/scripts/test/SANS/state/adjustment_test.py +++ b/scripts/test/SANS/state/adjustment_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSFacility, SANSInstrument) diff --git a/scripts/test/SANS/state/calculate_transmission_test.py b/scripts/test/SANS/state/calculate_transmission_test.py index 0c96dfb22b7e76190eebb72cff49405642fd74c8..7dcbb41257f2b9ca5832f8a19774c8f32be379c0 100644 --- a/scripts/test/SANS/state/calculate_transmission_test.py +++ b/scripts/test/SANS/state/calculate_transmission_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (RebinType, RangeStepType, FitType, DataType, SANSFacility, SANSInstrument) diff --git a/scripts/test/SANS/state/convert_to_q_test.py b/scripts/test/SANS/state/convert_to_q_test.py index 00a2d5e49620318466519881efa82e974c97320c..0f9e2a5893d3d14e94c35d8cc6bb3475f21bb996 100644 --- a/scripts/test/SANS/state/convert_to_q_test.py +++ b/scripts/test/SANS/state/convert_to_q_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (RangeStepType, ReductionDimensionality, SANSFacility, SANSInstrument) diff --git a/scripts/test/SANS/state/data_test.py b/scripts/test/SANS/state/data_test.py index 1c65c4ffac3c04df3437655ce16d0532643eb8c9..813def2e7580acec1a252e56b3fe86c2ad1e5c40 100644 --- a/scripts/test/SANS/state/data_test.py +++ b/scripts/test/SANS/state/data_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSFacility, SANSInstrument) diff --git a/scripts/test/SANS/state/mask_test.py b/scripts/test/SANS/state/mask_test.py index 41f6fcd8e00799df0b63942bb1ca2d6431825d84..0383088e365bf5c8591ade2452fb02d82da2406b 100644 --- a/scripts/test/SANS/state/mask_test.py +++ b/scripts/test/SANS/state/mask_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSFacility, DetectorType) diff --git a/scripts/test/SANS/state/move_test.py b/scripts/test/SANS/state/move_test.py index f972ec4e3dced7953f696197822f662150d0537a..dea9d9bcc7dee3072098f3b3cf83343af75b7190 100644 --- a/scripts/test/SANS/state/move_test.py +++ b/scripts/test/SANS/state/move_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (CanonicalCoordinates, SANSFacility, DetectorType, SANSInstrument) diff --git a/scripts/test/SANS/state/normalize_to_monitor_test.py b/scripts/test/SANS/state/normalize_to_monitor_test.py index 08f469a37384ec26e47a6bdc372b7bdcb18c056e..7f6fdb15a519db6ea9121793926a014ae076e9aa 100644 --- a/scripts/test/SANS/state/normalize_to_monitor_test.py +++ b/scripts/test/SANS/state/normalize_to_monitor_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (RebinType, RangeStepType, SANSFacility, SANSInstrument) diff --git a/scripts/test/SANS/state/reduction_mode_test.py b/scripts/test/SANS/state/reduction_mode_test.py index 47d5051c12888508fd3b5bd7811880aec867e846..3e939a0acfdf4287284a43c17db2567e14caf1df 100644 --- a/scripts/test/SANS/state/reduction_mode_test.py +++ b/scripts/test/SANS/state/reduction_mode_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (ReductionMode, ReductionDimensionality, FitModeForMerge, diff --git a/scripts/test/SANS/state/save_test.py b/scripts/test/SANS/state/save_test.py index fb9a0240505158926ff0b73c861d04d28d2227dc..b68f555f9d89c6a65c0783391cea1be6d7816051 100644 --- a/scripts/test/SANS/state/save_test.py +++ b/scripts/test/SANS/state/save_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSFacility, SaveType, SANSInstrument) @@ -52,4 +50,4 @@ class StateReductionBuilderTest(unittest.TestCase): if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/scripts/test/SANS/state/scale_test.py b/scripts/test/SANS/state/scale_test.py index 685dd257c9ef262218a2f6b0d7ee408ec37ba105..2dc29c00af3167570dda0505e48a20f5559f4d8e 100644 --- a/scripts/test/SANS/state/scale_test.py +++ b/scripts/test/SANS/state/scale_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSFacility, SampleShape) diff --git a/scripts/test/SANS/state/slice_event_test.py b/scripts/test/SANS/state/slice_event_test.py index bdc76a18054f6543a801de4180955bf86b3b8f22..e4fc6f14deffb487b6f343fe042e66a6ab242bef 100644 --- a/scripts/test/SANS/state/slice_event_test.py +++ b/scripts/test/SANS/state/slice_event_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSFacility, SANSInstrument) diff --git a/scripts/test/SANS/state/state_functions_test.py b/scripts/test/SANS/state/state_functions_test.py index 0c7c823f2d304a634b8d762d9c26a533033c2daa..1330bbf4e3ba052c832db71bed4cf599e769e941 100644 --- a/scripts/test/SANS/state/state_functions_test.py +++ b/scripts/test/SANS/state/state_functions_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (ReductionDimensionality) diff --git a/scripts/test/SANS/state/state_test.py b/scripts/test/SANS/state/state_test.py index 678137e17a7752ac73b575c2e573f47ed96d58dc..28dc4d3e0aa6452b7a4916527b1a40775d81a488 100644 --- a/scripts/test/SANS/state/state_test.py +++ b/scripts/test/SANS/state/state_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSInstrument, SANSFacility) diff --git a/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py b/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py index c1091c061c2503e83288f14d9dc7c33a0dff1150..9f1e435ded63c5bbedd7b7cb0444cdd86a12aca3 100644 --- a/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py +++ b/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (RangeStepType, DetectorType, SANSFacility, SANSInstrument) diff --git a/scripts/test/SANS/state/wavelength_test.py b/scripts/test/SANS/state/wavelength_test.py index ae36df743d59ac68b3ccc26bda129179313dd98d..c5dd3cf435ce9e4898c28272ca172efeac5b37c1 100644 --- a/scripts/test/SANS/state/wavelength_test.py +++ b/scripts/test/SANS/state/wavelength_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (SANSFacility, SANSInstrument, RebinType, RangeStepType) diff --git a/scripts/test/SANS/user_file/user_file_parser_test.py b/scripts/test/SANS/user_file/user_file_parser_test.py index dd2ee7fde0130287584ae398dc0d259430c76455..019b20f9217c49d6f46e91dfc3493acb0a0f0ef3 100644 --- a/scripts/test/SANS/user_file/user_file_parser_test.py +++ b/scripts/test/SANS/user_file/user_file_parser_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import unittest from sans.common.enums import (ReductionMode, DetectorType, RangeStepType, FitType, DataType, SANSInstrument) diff --git a/scripts/test/SANS/user_file/user_file_reader_test.py b/scripts/test/SANS/user_file/user_file_reader_test.py index 68719c15df720ef159e4db8176f7c69e58989cd0..d4194cb3b1d632d035fa5fd1cda38d2ba968951e 100644 --- a/scripts/test/SANS/user_file/user_file_reader_test.py +++ b/scripts/test/SANS/user_file/user_file_reader_test.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - import os import unittest diff --git a/scripts/test/SANSBatchModeTest.py b/scripts/test/SANSBatchModeTest.py index 80fa251f30ccc3a10d9fd1525d7c6dff66afbc6d..7417155c0ee611df4c692ec9c4cc34a1cae01087 100644 --- a/scripts/test/SANSBatchModeTest.py +++ b/scripts/test/SANSBatchModeTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import re # Need to import mantid before we import SANSUtility diff --git a/scripts/test/SANSCentreFinderTest.py b/scripts/test/SANSCentreFinderTest.py index 6bd5298be7998ace7c840e6ad97ba7fd2718df4c..cb635ea71c1502e28b2792d89bae917b5d10c483 100644 --- a/scripts/test/SANSCentreFinderTest.py +++ b/scripts/test/SANSCentreFinderTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import mantid from mantid.simpleapi import * @@ -69,6 +68,7 @@ class SANSBeamCentrePositionUpdater(unittest.TestCase): self.assertEqual(x_expected, x_new, "The x value should have been incremented.") self.assertEqual(y_expected, y_new, "The y value should have been incremented.") + class TestPositionProvider(unittest.TestCase): workspace_name = 'dummy_ws' diff --git a/scripts/test/SANSCommandInterfaceTest.py b/scripts/test/SANSCommandInterfaceTest.py index 1ade0f6bb650fd8a84517fd934128f9ffccff12f..1fd68b67c5f02df0efa95eadd2a0ce453d74e445 100644 --- a/scripts/test/SANSCommandInterfaceTest.py +++ b/scripts/test/SANSCommandInterfaceTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import mantid import os @@ -17,6 +16,7 @@ from mantid.kernel import DateAndTime import random import math + class SANSCommandInterfaceGetAndSetTransmissionSettings(unittest.TestCase): def test_that_gets_transmission_monitor(self): # Arrange @@ -203,6 +203,7 @@ class SANSCommandInterfaceGetAndSetTransmissionSettings(unittest.TestCase): # Assert self.assertEqual(0, len(ReductionSingleton().transmission_calculator.mask_files), 'The transmission mask list should be empty.') + class TestEventWorkspaceCheck(unittest.TestCase): def _create_file_name(self, name): temp_save_dir = config['defaultsave.directory'] @@ -237,6 +238,7 @@ class TestEventWorkspaceCheck(unittest.TestCase): self._clean_up(file_name) DeleteWorkspace(ws) + class SANSCommandInterfaceGetAndSetQResolutionSettings(unittest.TestCase): #Test the input and output mechanims for the QResolution settings def test_full_setup_for_circular_apertures(self): @@ -364,6 +366,7 @@ class SANSCommandInterfaceGetAndSetQResolutionSettings(unittest.TestCase): delta_r_expected = delta_r/1000. self.assertEqual(delta_r_stored, delta_r_expected) + class TestLARMORCommand(unittest.TestCase): def test_that_default_idf_is_being_selected(self): command_iface.Clean() @@ -397,6 +400,7 @@ class TestLARMORCommand(unittest.TestCase): self.assertFalse(command_iface.LARMOR(selected_idf), "A non existent idf path should return false") + class TestMaskFile(unittest.TestCase): def test_throws_for_user_file_with_invalid_extension(self): # Arrange @@ -407,6 +411,7 @@ class TestMaskFile(unittest.TestCase): args = [file_name] self.assertRaises(RuntimeError, command_iface.MaskFile, *args) + class SANSCommandInterfaceGetAndSetBackgroundCorrectionSettings(unittest.TestCase): def _do_test_correct_setting(self, run_number, is_time, is_mon, is_mean, mon_numbers): # Assert that settings were set diff --git a/scripts/test/SANSIsisInstrumentTest.py b/scripts/test/SANSIsisInstrumentTest.py index 9fdcdec6fc86b9c8400a75d5c373eec0e5dfdb17..38f8b679f17462ef5753cdb10ec26e693fcaa8e0 100644 --- a/scripts/test/SANSIsisInstrumentTest.py +++ b/scripts/test/SANSIsisInstrumentTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import mantid from mantid.simpleapi import * @@ -41,6 +40,7 @@ class SANSIsisInstrumentTest(unittest.TestCase): self.assertEqual(None, start_Tof) self.assertEqual(None, end_Tof) + class TestParameterMapModifications(unittest.TestCase): def create_sample_workspace(self, ws_name, types, values, names): ws = CreateSampleWorkspace(OutputWorkspace = ws_name) diff --git a/scripts/test/SANSReducerTest.py b/scripts/test/SANSReducerTest.py index 7257f191e74b5e67200022f53914578e05e1814f..f4003f74ddb8c27ea6aa405762484980d23914e5 100644 --- a/scripts/test/SANSReducerTest.py +++ b/scripts/test/SANSReducerTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import mantid diff --git a/scripts/test/SANSReductionStepsUserFileTest.py b/scripts/test/SANSReductionStepsUserFileTest.py index f502e6d54c5af891ab28a4dc880eb3eb552c9f67..fdda1df601fb995678745d81b5337b181453bb48 100644 --- a/scripts/test/SANSReductionStepsUserFileTest.py +++ b/scripts/test/SANSReductionStepsUserFileTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import mantid import isis_instrument as instruments @@ -111,6 +110,7 @@ class SANSReductionStepsUserFileTest(unittest.TestCase): self.assertEqual(merge_Range.q_max, None, 'The q_max should have been read in') self.assertEqual(merge_Range.q_merge_range, False, 'q_merge_range should be true') + class MockConvertTOQISISQResolution(object): def __init__(self): super(MockConvertTOQISISQResolution, self).__init__() @@ -152,11 +152,13 @@ class MockConvertTOQISISQResolution(object): def set_use_q_resolution(self, enabled): self.on_off = enabled + class MockReducerQResolution(object): def __init__(self): super(MockReducerQResolution, self).__init__() self.to_Q = MockConvertTOQISISQResolution() + class TestQResolutionInUserFile(unittest.TestCase): def test_that_good_input_is_accepted(self): # Arrange diff --git a/scripts/test/SANSUtilityTest.py b/scripts/test/SANSUtilityTest.py index 65e9ca1a041a95b0a4b6b6d69d3cba0c03b446d7..632f7c3f4f2fe9d3e3627728321e0085031380d4 100644 --- a/scripts/test/SANSUtilityTest.py +++ b/scripts/test/SANSUtilityTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest # Need to import mantid before we import SANSUtility import mantid @@ -32,11 +31,13 @@ TEST_STRING_MON2 = TEST_STRING_MON + '_2' TEST_STRING_DATA3 = TEST_STRING_DATA + '_3' TEST_STRING_MON3 = TEST_STRING_MON + '_3' + def provide_group_workspace_for_added_event_data(event_ws_name, monitor_ws_name, out_ws_name): CreateWorkspace(DataX = [1,2,3], DataY = [2,3,4], OutputWorkspace = monitor_ws_name) CreateSampleWorkspace(WorkspaceType= 'Event', OutputWorkspace = event_ws_name) GroupWorkspaces(InputWorkspaces = [event_ws_name, monitor_ws_name ], OutputWorkspace = out_ws_name) + def addSampleLogEntry(log_name, ws, start_time, extra_time_shift, make_linear = False): number_of_times = 10 for i in range(0, number_of_times): @@ -49,6 +50,7 @@ def addSampleLogEntry(log_name, ws, start_time, extra_time_shift, make_linear = date += int(extra_time_shift*1e9) AddTimeSeriesLog(ws, Name=log_name, Time=date.__str__().strip(), Value=val) + def provide_event_ws_with_entries(name, start_time,number_events =0, extra_time_shift = 0.0, proton_charge = True, proton_charge_empty = False, log_names= None, make_linear = False): # Create the event workspace ws = CreateSampleWorkspace(WorkspaceType= 'Event', NumEvents = number_events, OutputWorkspace = name) @@ -68,17 +70,21 @@ def provide_event_ws_with_entries(name, start_time,number_events =0, extra_time_ addSampleLogEntry(name, ws, start_time, extra_time_shift, make_linear) return ws + def provide_event_ws_custom(name, start_time, extra_time_shift = 0.0, proton_charge = True, proton_charge_empty = False): return provide_event_ws_with_entries(name=name, start_time=start_time, number_events = 100, extra_time_shift = extra_time_shift, proton_charge=proton_charge, proton_charge_empty=proton_charge_empty) + def provide_event_ws(name, start_time, extra_time_shift): return provide_event_ws_custom(name = name, start_time = start_time, extra_time_shift = extra_time_shift, proton_charge = True) + def provide_event_ws_wo_proton_charge(name, start_time, extra_time_shift): return provide_event_ws_custom(name = name, start_time = start_time, extra_time_shift = extra_time_shift, proton_charge = False) + def provide_histo_workspace_with_one_spectrum(ws_name, x_start, x_end, bin_width): CreateSampleWorkspace(OutputWorkspace = ws_name, NumBanks=1, @@ -204,6 +210,7 @@ class SANSUtilityTest(unittest.TestCase): self.assertEqual([[1, 3], [5, 5], [7, 9]], su._merge_to_ranges([1, 2, 3, 5, 7, 8, 9])) self.assertEqual([[1, 1]], su._merge_to_ranges([1])) + class TestBundleAddedEventDataFilesToGroupWorkspaceFile(unittest.TestCase): def _prepare_workspaces(self, names): CreateSampleWorkspace(WorkspaceType = 'Event', OutputWorkspace = names[0]) @@ -258,6 +265,7 @@ class TestBundleAddedEventDataFilesToGroupWorkspaceFile(unittest.TestCase): if os.path.exists(file_names[0]): os.remove(file_names[0]) + class TestLoadingAddedEventWorkspaceNameParsing(unittest.TestCase): def do_test_load_check(self, event_name, monitor_name): @@ -323,6 +331,7 @@ class TestLoadingAddedEventWorkspaceNameParsing(unittest.TestCase): monitor_name3 = TEST_STRING_MON3 self.do_test_load_check(event_name = event_name3, monitor_name = monitor_name3) + class TestLoadingAddedEventWorkspaceExtraction(unittest.TestCase): _appendix = '_monitors' @@ -567,6 +576,7 @@ class TestCombineWorkspacesFactory(unittest.TestCase): alg = factory.create_add_algorithm(False) self.assertTrue(isinstance(alg, su.PlusWorkspaces)) + class TestOverlayWorkspaces(unittest.TestCase): def test_time_from_proton_charge_log_is_recovered(self): # Arrange @@ -649,6 +659,7 @@ class TestOverlayWorkspaces(unittest.TestCase): if name in mtd.getObjectNames(): DeleteWorkspace(name) + class TestTimeShifter(unittest.TestCase): def test_zero_shift_when_out_of_range(self): # Arrange @@ -672,6 +683,7 @@ class TestTimeShifter(unittest.TestCase): self.assertEqual(time_shifter.get_Nth_time_shift(2), -232.0) self.assertEqual(time_shifter.get_Nth_time_shift(3), 0.0) + class TestZeroErrorFreeWorkspace(unittest.TestCase): def _setup_workspace(self, name, type): ws = CreateSampleWorkspace(OutputWorkspace = name, WorkspaceType=type, Function='One Peak',NumBanks=1,BankPixelWidth=2,NumEvents=0,XMin=0.5,XMax=1,BinWidth=1,PixelSpacing=1,BankDistanceFromSample=1) @@ -856,6 +868,7 @@ class TestRenameMonitorsForMultiPeriodEventData(unittest.TestCase): if element in mtd: DeleteWorkspace(element) + class TestConvertibleToInteger(unittest.TestCase): def test_converts_true_to_integer_when_integer(self): # Arrange @@ -881,6 +894,7 @@ class TestConvertibleToInteger(unittest.TestCase): # Assert self.assertFalse(result) + class TestConvertibleToFloat(unittest.TestCase): def test_converts_true_to_float_when_float(self): # Arrange @@ -906,6 +920,7 @@ class TestConvertibleToFloat(unittest.TestCase): # Assert self.assertFalse(result) + class TestValidXmlFileList(unittest.TestCase): def test_finds_valid_xml_file_list(self): # Arrange @@ -931,6 +946,7 @@ class TestValidXmlFileList(unittest.TestCase): # Assert self.assertFalse(result) + class TestConvertToAndFromPythonStringList(unittest.TestCase): def test_converts_from_string_to_list(self): # Arrange @@ -949,6 +965,7 @@ class TestConvertToAndFromPythonStringList(unittest.TestCase): expected = "test1.xml,test2.xml,test3.xml" self.assertEqual(expected, result) + class HelperRescaleShift(object): def __init__(self, hasValues=True, min= 1, max= 2): super(HelperRescaleShift, self).__init__() @@ -956,6 +973,7 @@ class HelperRescaleShift(object): self.qMin = min self.qMax = max + class TestExtractionOfQRange(unittest.TestCase): def _delete_workspace(self, workspace_name): if workspace_name in mtd: @@ -1246,6 +1264,7 @@ class TestGetQResolutionForMergedWorkspaces(unittest.TestCase): DeleteWorkspace(rear) DeleteWorkspace(result) + class TestDetectingValidUserFileExtensions(unittest.TestCase): def _do_test(self, file_name, expected): result = su.is_valid_user_file_extension(file_name) diff --git a/scripts/test/SansIsisGuiSettings.py b/scripts/test/SansIsisGuiSettings.py index abbcde8c81193c6a3c846e2526e659e514a1b9aa..24bfa5e946b586b7f46b09ba9f7e82379052caac 100644 --- a/scripts/test/SansIsisGuiSettings.py +++ b/scripts/test/SansIsisGuiSettings.py @@ -4,13 +4,13 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest from mantid.simpleapi import * import ISISCommandInterface as i MASKFILE = 'MaskSANS2D.txt' + class Sans2DIsisGuiSettings(unittest.TestCase): def setUp(self): diff --git a/scripts/test/SettingsTest.py b/scripts/test/SettingsTest.py index 9be1fe2d74258655abd4dc7132644f89d0db195b..ba54d97a173f046f5ac5df1b2a5a0b1ad0d4fc17 100644 --- a/scripts/test/SettingsTest.py +++ b/scripts/test/SettingsTest.py @@ -4,7 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) import unittest import os from mantid.simpleapi import * @@ -15,6 +14,8 @@ RAII Test helper class. Equivalent to the ScopedFileHelper. If this proves useful. It would be sensible to make it more accessible for other testing classes. ''' + + class TempFile(object): __tempFile = None @@ -38,6 +39,8 @@ class TempFile(object): ''' Determine if all tests should be skipped. Check for the expat module to decide. ''' + + def skipAllTests(): skiptests = False try: diff --git a/scripts/test/TOFTOF/TOFTOFGUITest.py b/scripts/test/TOFTOF/TOFTOFGUITest.py index 38b089507ce1b4005fb1c23f5eb497d7f713b4a7..24254df8383b8ae19556debda9d5ab6949ba311d 100644 --- a/scripts/test/TOFTOF/TOFTOFGUITest.py +++ b/scripts/test/TOFTOF/TOFTOFGUITest.py @@ -4,12 +4,10 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from qtpy.QtWidgets import QApplication import unittest -from mantid.py3compat import mock +from unittest import mock from reduction_gui.reduction.toftof.toftof_reduction import TOFTOFScriptElement, OptionalFloat from reduction_gui.widgets.toftof.toftof_setup import TOFTOFSetupWidget diff --git a/scripts/test/TOFTOF/TOFTOFScriptElementTest.py b/scripts/test/TOFTOF/TOFTOFScriptElementTest.py index ef6a203f2cb1ff511ed260c568487f65909c99cd..1d9395ce7214b7d5d5f4f5c84bc7e8e370996bbb 100644 --- a/scripts/test/TOFTOF/TOFTOFScriptElementTest.py +++ b/scripts/test/TOFTOF/TOFTOFScriptElementTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - from reduction_gui.reduction.toftof.toftof_reduction import TOFTOFScriptElement, OptionalFloat import testhelpers import unittest diff --git a/scripts/test/directtools/DirectToolsTest.py b/scripts/test/directtools/DirectToolsTest.py index 64ca1fd151e772e158d24cce518d1a32e2e21eff..d20f3e449f6853b2dda73a1538f141b9c759a992 100644 --- a/scripts/test/directtools/DirectToolsTest.py +++ b/scripts/test/directtools/DirectToolsTest.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function) - # Set matplotlib backend to AGG before anything else. Otherwise some build servers # need to have extra packages (tkinter) installed. import matplotlib diff --git a/tools/Copyright/copyrightupdate.py b/tools/Copyright/copyrightupdate.py index 7233a60a94027675b9529450875c8573d4113613..698270d5eba52d3e487b6b4adfddab7b858cac13 100755 --- a/tools/Copyright/copyrightupdate.py +++ b/tools/Copyright/copyrightupdate.py @@ -11,7 +11,6 @@ import os import pprint import re - ###################################################################################################################### # Script level variables @@ -252,7 +251,7 @@ process_file_tree(root_path) if not args.noreport: #write out reporting files for reporting_filename, reporting_dict in reporting_dictionaries.items(): - with open(reporting_filename,"w") as reporting_file: + with open(reporting_filename, "w") as reporting_file: for key, value in reporting_dict.items(): reporting_file.write("{0}\t{1}{2}".format(key,value,os.linesep)) diff --git a/tools/DOI/doi.py b/tools/DOI/doi.py index 4c0cbf30a1297e85fe122ed26a8bdccb59b8fa26..9cc361880c494c929d9fee7d0b4ac00fe29ec51f 100644 --- a/tools/DOI/doi.py +++ b/tools/DOI/doi.py @@ -62,7 +62,6 @@ USEFUL LINKS: http://docs.python.org/2/library/httplib.html#httplib.HTTPS_PORT """ -from __future__ import (absolute_import, division, print_function) import argparse import getpass import os diff --git a/tools/DefaultConfigFiles/configToCpp.py b/tools/DefaultConfigFiles/configToCpp.py index ab1dc191a00ef5fbb5dfc14ad24f850e8564e3d5..75cfee1894d9687fbdffc48dbdb8549be4a0b090 100644 --- a/tools/DefaultConfigFiles/configToCpp.py +++ b/tools/DefaultConfigFiles/configToCpp.py @@ -9,7 +9,6 @@ ## Dan Nixon -from __future__ import (absolute_import, division, print_function) import sys with open(sys.argv[2]) as f: diff --git a/tools/Documentation/wiki2rst.py b/tools/Documentation/wiki2rst.py index 351be27e016af0a08c18c034697b0541868902f6..f0cff3f22a54b6fc98c0a1003a81ca5aef5415c3 100755 --- a/tools/Documentation/wiki2rst.py +++ b/tools/Documentation/wiki2rst.py @@ -20,7 +20,6 @@ The bulk of the work is done by pandoc, which is expected to be in the PATH. The the inline to normal format. 3. Image links cannot have spaces in the filename in rst. The spaces are removed in the downloaded file names, but not the links in the rst files.""" -from __future__ import (absolute_import, division, print_function) import argparse import json import os @@ -102,7 +101,7 @@ class WikiURL(object): raise RuntimeError("Failed to fetch JSON describing image page: {}".format(str(err))) apicall = json.loads(json_str) pages = apicall['query']['pages'] - for _, page in pages.iteritems(): + for _, page in pages.items(): return page['imageinfo'][0]['url'] # ------------------------------------------------------------------------------ diff --git a/tools/PeriodicTable/generate_atom_code.py b/tools/PeriodicTable/generate_atom_code.py index 16fe17194755daf39e0b82ce6c5b6bfe94def6fe..62f442d85873846677877761538637a9dc233532 100755 --- a/tools/PeriodicTable/generate_atom_code.py +++ b/tools/PeriodicTable/generate_atom_code.py @@ -6,8 +6,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) -from six.moves import range import optparse import sys try: diff --git a/tools/Pylint/fixPylint.py b/tools/Pylint/fixPylint.py index 781ba49cdf6011cbba26dab468792583ccec3622..1cb629669a697eaa2db5904c2cf64b607feb5849 100644 --- a/tools/Pylint/fixPylint.py +++ b/tools/Pylint/fixPylint.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name,anomalous-backslash-in-string -from __future__ import (absolute_import, division, print_function) -from __future__ import (absolute_import, division, print_function) import os import re import argparse diff --git a/tools/Pylint/run_pylint.py b/tools/Pylint/run_pylint.py index 47b0e7756bc9b22c1591998c320ef1109f327ec9..e71aa0952e07c1fcf35d9af81b86d361313c0718 100644 --- a/tools/Pylint/run_pylint.py +++ b/tools/Pylint/run_pylint.py @@ -12,7 +12,6 @@ """ -from __future__ import (absolute_import, division, print_function) import logging from optparse import OptionParser import os.path diff --git a/tools/Sanitizer/Address.supp b/tools/Sanitizer/Address.supp new file mode 100644 index 0000000000000000000000000000000000000000..ba6df22297f4694780b5f3578ddd9b4d277a7c7d --- /dev/null +++ b/tools/Sanitizer/Address.supp @@ -0,0 +1,2 @@ +# This file is a placeholder for future suppressions. It is passed through +# the ctest harness to the currently running test \ No newline at end of file diff --git a/tools/Sanitizer/Leak.supp b/tools/Sanitizer/Leak.supp new file mode 100644 index 0000000000000000000000000000000000000000..f900da7b50b962d2a515a997cd2d54e012b8cc05 --- /dev/null +++ b/tools/Sanitizer/Leak.supp @@ -0,0 +1,25 @@ +# NeXus has a known memory leak when reading attributes. +# It is fixed upstream but not made it to distribution packages +# Direct leak of 12114 byte(s) in 1346 object(s) allocated from: +# #0 0x7fb126db5538 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x77538) +# #1 0x7fb120a534cb (/usr/lib/libNeXus.so.0+0xc4cb) +# #2 0x7fb100000000 (<unknown module>) +leak:libNeXus + +# OpenCascade memory allocation seems to confuse ASAN +# Direct leak of 544 byte(s) in 1 object(s) allocated from: +# #0 0x7f77eec3a618 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0618) +# #1 0x7f77e4141b08 (/usr/lib/x86_64-linux-gnu/libTKernel.so.11+0x7bb08) +leak:libTKernel + +# TBB leaks some memory allocated in singleton depending on deinitialization order +# Direct leak of 1560 byte(s) in 3 object(s) allocated from: +# #0 0x7f7ae72a80a0 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc80a0) +# #1 0x7f7ae595d13e (/usr/lib/x86_64-linux-gnu/libtbb.so.2+0x2213e) +leak:libtbb + +# Python and associated libraries *appears* to leak memory. +leak:libpython +leak:umath +leak:multiarray +leak:_ctypes diff --git a/tools/VTKConverter/processISISData.py b/tools/VTKConverter/processISISData.py index facd6a02c4e3af9d1d6f5249961e18051e3c964e..b235e0578b54177f2f692a13b2c54e46bcd224a3 100644 --- a/tools/VTKConverter/processISISData.py +++ b/tools/VTKConverter/processISISData.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name #!/usr/bin/python -from __future__ import (absolute_import, division, print_function) import os import sys import VTKConvert diff --git a/tools/release_generator/patch.py b/tools/release_generator/patch.py index 1422b1d4a615247139ba9f189aabd2a12806eaf6..cc36d4948c7437ad9d8345bde4b17093f4524382 100755 --- a/tools/release_generator/patch.py +++ b/tools/release_generator/patch.py @@ -5,7 +5,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) import os import requests diff --git a/tools/release_generator/release.py b/tools/release_generator/release.py index a17550b4b6e02a8c6eb0badc506b5d48fd96347e..cf0b6dfe4dd10381b3f188713ed60ac75dff7138 100755 --- a/tools/release_generator/release.py +++ b/tools/release_generator/release.py @@ -5,7 +5,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) import os import sys diff --git a/tools/reports/commits-report.py b/tools/reports/commits-report.py new file mode 100644 index 0000000000000000000000000000000000000000..a974b9b58483038b5454d2204fb1109b205e60ef --- /dev/null +++ b/tools/reports/commits-report.py @@ -0,0 +1,285 @@ +# Mantid Repository : https://github.com/mantidproject/mantid +# +# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +# NScD Oak Ridge National Laboratory, European Spallation Source, +# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +# SPDX - License - Identifier: GPL - 3.0 + +#pylint: disable=invalid-name + +import datetime +import csv +import os +import re + +temp_filename = 'all-commits.stdout' +regex_git_log_entry = re.compile( + r"Author:\s+(.+?)\s+Date:\s+(.+?)\B\s+(\S+).*?((\d+)\sfile.+?)?((\d+)+\sinsertion.+?)?((\d+)+\sdeletion.+?)?(commit\s[0-9a-f]{40}|$)", + re.DOTALL) +regex_git_log_splitter = re.compile( + r"commit\s[0-9a-f]{40}") +regex_name_email_address = re.compile(r"(.*?)<(\S+)>") + +organisations = ['STFC', 'ORNL', 'ESS', 'ILL', 'PSI', 'ANSTO', 'KITWARE', 'JUELICH', 'OTHERS', 'CSNS'] + +domains = {'stfc.ac.uk': 'STFC', + 'clrc.ac.uk': 'STFC', + 'tessella.com': 'STFC', + 'ornl.gov': 'ORNL', + 'sns.gov': 'ORNL', + 'esss.se': 'ESS', + 'ill.fr': 'ILL', + 'ill.eu': 'ILL', + 'psi.ch': 'PSI', + 'ansto.gov.au': 'ANSTO', + 'ansto': 'ANSTO', + 'mantidproject.org': 'OTHERS', + 'MichaelWedel@users.noreply.github.com': 'PSI', + 'stuart.i.campbell@gmail.com': 'ORNL', + 'uwstout.edu': 'ORNL', + 'kitware.com': 'KITWARE', + 'juelich.de': 'JUELICH', + 'ian.bush@tessella.com': 'STFC', + 'dan@dan-nixon.com': 'STFC', + 'peterfpeterson@gmail.com': 'ORNL', + 'stuart@stuartcampbell.me': 'ORNL', + 'harry@exec64.co.uk': 'STFC', + 'martyn.gigg@gmail.com': 'STFC', + 'raquelalvarezbanos@users.noreply.github.com': 'STFC', + 'torben.nielsen@nbi.dk': 'ESS', + 'borreguero@gmail.com': 'ORNL', + 'raquel.alvarez.banos@gmail.com': 'STFC', + 'anton.piccardo-selg@tessella.com': 'STFC', + 'rosswhitfield@users.noreply.github.com': 'ORNL', + 'mareuternh@gmail.com': 'ORNL', + 'quantumsteve@gmail.com': 'ORNL', + 'ricleal@gmail.com': 'ORNL', + 'jawrainey@gmail.com': 'STFC', + 'xingxingyao@gmail.com': 'ORNL', + 'owen@laptop-ubuntu': 'STFC', + 'picatess@users.noreply.github.com': 'STFC', + 'Janik@Janik': 'ORNL', + 'debdepba@dasganma.tk': 'OTHERS', + 'matd10@yahoo.com': 'OTHERS', + 'diegomon93@gmail.com': 'OTHERS', + 'mgt110@ic.ac.uk': 'OTHERS', + 'granrothge@users.noreply.github.com': 'ORNL', + 'tom.g.r.brooks@gmail.com': 'STFC', + 'ross.whitfield@gmail.com': 'ORNL', + 'samueljackson@outlook.com': 'STFC', + 'AntonPiccardoSelg@users.noreply.github.com': 'STFC', + 'antibones@users.noreply.github.com': 'ILL', + 'MikeHart85@users.noreply.github.com': 'STFC', + 'dbt@aber.ac.uk': 'STFC', + 'DavidFair@users.noreply.github.com': 'STFC', + 'reimundILL@users.noreply.github.com': 'ILL', + 'jan@c53.be': 'JUELICH', + 'reimund@il.eu': 'ILL', + 'davidfair@users.noreply.github.com': 'STFC', + 'louisemccann@users.noreply.github.com': 'STFC', + 'DimitarTasev@users.noreply.github.com': 'STFC', + 'dimtasev@gmail.com': 'STFC', + 'fedepou@gmail.com': 'STFC', + 'cip.pruteanu@gmail.com': 'OTHERS', + 'kdymkowski84@gmail.com': 'OTHERS', + 'mayer.ali@t-online.de': 'OTHERS', + 'gagikvar@gmail.com': 'ILL', + 'bartomeu.llopis.vidal@gmail.com': 'STFC', + 'anton.piccardo-selg@tessella.ac.uk': 'STFC', + 'jamesphysics@users.noreply.github.com': 'STFC', + 'michaeljturner@live.com': 'STFC', + 'rprospero@gmail.com': 'STFC', + 'roman.tolchenov@gmail.com': 'STFC', + 'jiao.lin@gmail.com': 'ORNL', + 'erkn@fysik.dtu.dk': 'ESS', + 'daniel@pajerowski.com': 'ORNL', + 'ElliotAOram@users.noreply.github.com': 'STFC', + '37333817+thomueller@users.noreply.github.com': 'ESS', + 't.w.jubb@gmail.com': 'STFC', + 'edward.brown.96@live.co.uk': 'STFC', + 'bhuvan_777@outlook.com': 'STFC', + 'joachimcoenen@icloud.com': 'JUELICH', + 'anton.piccardo.selg@gmail.com': 'STFC', + '29330338+JoachimCoenen@users.noreply.github.com': 'JUELICH', + 'samjones714@gmail.com': 'STFC', + '5237234+ewancook@users.noreply.github.com': 'STFC', + '40766142+SamJenkins1@users.noreply.github.com': 'STFC', + 'aybamidele@gmail.com': 'STFC', + '5237234+ewancook@users.noreply.github.com': 'STFC', + 'samjones714@gmail.com': 'STFC', + '40830825+robertapplin@users.noreply.github.com': 'STFC', + 'robertgjapplin@gmail.com': 'STFC', + 'luzpaz@users.noreply.github.com': 'OTHERS', + 't.j.titcombe@gmail.com': 'STFC', + '32938439+TTitcombe@users.noreply.github.com': 'STFC', + '35809089+EdwardsLT@users.noreply.github.com': 'STFC', + 'EdwardsLT@cardiff.ac.uk': 'STFC', + '39047984+nvaytet@users.noreply.github.com': 'ESS', + 'igudich@gmail.com': 'ESS', + '46603316+alicerussell1@users.noreply.github.com': 'STFC', + '31194136+aybamidele@users.noreply.github.com': 'STFC', + '49688535+Harrietbrown@users.noreply.github.com': 'STFC', + 'takudzwamilli@gmail.com': 'STFC', + 'lorenzobasso@unseen.is': 'STFC', + 'a.j.jackson@physics.org': 'STFC', + '32895149+LolloB@users.noreply.github.com': 'STFC', + 'philipc99@hotmail.co.uk': 'STFC', + 'conor.m.finn.99@gmail.com': 'STFC', + '52415735+PhilColebrooke@users.noreply.github.com': 'STFC', + 'giodisiena@gmail.com': 'STFC', + 'matthew-d-jones@users.noreply.github.com': 'STFC', + '32419974+TakudzwaMakoni@users.noreply.github.com': 'STFC', + 'hankwu@Hanks-MacBook-Air.local': 'STFC', + '55147936+hankwustfc@users.noreply.github.com': 'STFC', + '55979119+RichardWaiteSTFC@users.noreply.github.com': 'STFC', + 'Waite': 'STFC', + '47181718+ConorMFinn@users.noreply.github.com': 'STFC', + '31892119+Fahima-Islam@users.noreply.github.com': 'ORNL', + '56431339+StephenSmith25@users.noreply.github.com': 'STFC', + 'williamfgc@yahoo.com': 'ORNL'} + +aliases = {'Anthony':'Anthony Lim', + 'AnthonyLim23':'Anthony Lim', + 'abuts':'Alex Buts', + 'Ayomide Bamidele':'Andre Bamidele', + 'DanielMurphy22':'Daniel Murphy', + 'Harrietbrown':'Harriet Brown', + 'PhilColebrooke':'Phil Colebrooke', + 'Phil':'Phil Colebrooke', + 'Richard':'Richard Waite', + 'RichardWaiteSTFC':'Richard Waite', + 'Stephen':'Stephen Smith', + 'StephenSmith25':'Stephen Smith', + 'StephenSmith':'Stephen Smith', + 'Anders-Markvardsen':'Anders Markvardsen', + 'AndreiSavici':'Andrei Savici', + 'Antti Soininnen':'Antti Soininen', + 'Bilheux':'Jean Bilheux', + 'brandonhewer':'Brandon Hewer', + 'celinedurniak':'Celine Durniak', + 'DavidFair':'David Fairbrother', + 'DiegoMonserrat':'Diego Monserrat', + 'Dimitar Borislavov Tasev':'Dimitar Tasev', + 'Tasev':'Dimitar Tasev', + 'giovannidisiena':'Giovanni Di Siena ', + 'hankwustfc':'Hank Wu ', + 'igudich':'Igor Gudich', + 'josephframsay':'Joseph Ramsay', + 'LamarMoore':'Lamar Moore', + 'Moore':'Lamar Moore', + 'LolloB':'Lorenzo Basso', + 'NickDraper':'Nick Draper', + 'Pete Peterson':'Peter Peterson', + 'Parker, Peter G':'Peter Parker', + 'Raquel Alvarez':'Raquel Alvarez Banos', + 'reimundILL':'Verena Reimund ', + 'Ricardo Leal':'Ricardo Ferraz Leal', + 'Ricardo M. Ferraz Leal':'Ricardo Ferraz Leal', + 'Rob':'Robert Applin', + 'Rob Applin':'Robert Applin', + 'robertapplin ':'Robert Applin', + 'Sam':'Sam Jenkins', + 'SamJenkins1':'Sam Jenkins', + 'simonfernandes':'Simon Fernandes', + 'MichaelWedel':'Michael Wedel', + 'Steven E. Hahn':'Steven Hahn', + 'VickieLynch':'Vickie Lynch' + } + + +def generate_commit_data(): + print('Generating git commit data...') + os.system("git --no-pager log --shortstat > " + temp_filename) + + +def parse_commit_data(): + print("Reading the file") + # Open a file: file + commit_entries = [] + commit_entry = "" + with open (temp_filename, "r", encoding="utf-8") as file: + # read all lines at once + log_line = file.readline() + while (log_line): + if regex_git_log_splitter.match(log_line): + commit_entries.append(commit_entry) + commit_entry = log_line + else: + commit_entry += log_line + log_line = file.readline() + + #find the matches + print("searching for regex matches") + with open('commits-report.csv', mode='w', newline='') as output_file: + commit_writer = csv.writer(output_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) + commit_writer.writerow(["Author", "Email", "Facility", "Date_time", "Year", "Quarter", "Month", "Week", "Commits", + "Files Changed", "Insertions", "Deletions", "Net Lines Changed"]) + for commit_text in commit_entries: + parse_log_entry(commit_text,commit_writer) + + +def parse_log_entry(commit_text,commit_writer): + if commit_text =="": + return + # black listed log entry that crashes the regex engine + if commit_text.startswith("commit 4a6c0077a1dff965d767dc45a1517c7411a69070") or \ + commit_text.startswith("commit 16a4f16c99e3dc3b59d214067781c932f5a9eb8a"): + return + try: + match = regex_git_log_entry.search(commit_text) + #skip merges + if match.group(3) != "Merge": + author = match.group(1) + name, email = extract_name_email_from_author(author) + date_time_str = match.group(2).strip() + date_time = None + try: + date_time = datetime.datetime.strptime(date_time_str, '%a %b %d %H:%M:%S %Y %z') + except ValueError as e: + print ("Date Parsing failed") + print(date_time_str, e) + print(commit_text) + return + files = 0 if match.group(5) is None else int(match.group(5)) + insertions = 0 if match.group(7) is None else int(match.group(7)) + deletions = 0 if match.group(9) is None else int(match.group(9)) + facility = get_user_facility(email,date_time) + commit_writer.writerow([name,email,facility,date_time.strftime("%Y-%m-%d %H:%M"), + date_time.strftime("%Y"), (date_time.month-1)//3 + 1, date_time.strftime("%m"), + date_time.isocalendar()[1], 1, + files,insertions,deletions, insertions-deletions]) + except RuntimeError as e: + print("Match failed", e) + print(commit_text) + + +def extract_name_email_from_author(author): + match = regex_name_email_address.search(author) + if match: + original_name = match.group(1).strip() + name = aliases[original_name] if original_name in aliases.keys() else original_name + return name,match.group(2) + else: + return None + + +def get_user_facility(email, datetime): + facility = "UNKNOWN" + for domain in domains.keys(): + if domain in email: + # ORNL didn't join until 2009 + if domains[domain] == 'ORNL' and datetime.year < 2009: + domain = 'stfc.ac.uk' + facility = domains[domain] + if facility == "UNKNOWN": + print("Unmatached email", email) + return facility + + +if __name__ == '__main__': + print("Generating github commit metrics...\n") + + generate_commit_data() + parse_commit_data() + os.remove(temp_filename) + + print("\n\nAll done!\n") diff --git a/tools/reports/display_jenkins_build_queue.py b/tools/reports/display_jenkins_build_queue.py index 2c2989ac629b48d2f42729cbe6b10a9b65186fd2..8cb5dbe279ff8c8d8bc439a5448dcb3995931275 100755 --- a/tools/reports/display_jenkins_build_queue.py +++ b/tools/reports/display_jenkins_build_queue.py @@ -5,8 +5,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import print_function - import posixpath as path import pprint diff --git a/tools/reports/facility-code-changes.py b/tools/reports/facility-code-changes.py index 09c2a2b8399a372bdaf3d3415cdbb7b7fb1ea75c..d01cd20e77bf2bf307557a1069edc48e7b0158cf 100644 --- a/tools/reports/facility-code-changes.py +++ b/tools/reports/facility-code-changes.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function, unicode_literals) - import datetime import subprocess import csv diff --git a/tools/reports/release-list.py b/tools/reports/release-list.py index 920974cd681573c47de02a57ac0b4ef9ba78e821..c7f19d46c6c08856ea3892f91954bea9898bad2c 100644 --- a/tools/reports/release-list.py +++ b/tools/reports/release-list.py @@ -5,8 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function, unicode_literals) - import datetime import os import requests diff --git a/tools/scripts/ConvertBadAlgmLinks.py b/tools/scripts/ConvertBadAlgmLinks.py index 1eab649ef0e076aded455b07857683d6a04cd8bb..a85fdfff6004dd1f4e6e9ae9629a0286d5759393 100644 --- a/tools/scripts/ConvertBadAlgmLinks.py +++ b/tools/scripts/ConvertBadAlgmLinks.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import re import glob import os diff --git a/tools/scripts/CorrectConceptLinksinAlgPages.py b/tools/scripts/CorrectConceptLinksinAlgPages.py index df40d8d8e6a02b7babc5158d27015ec6889371ad..7945c17f52c8bd2b7615c41b53dc16359e7fc3c1 100644 --- a/tools/scripts/CorrectConceptLinksinAlgPages.py +++ b/tools/scripts/CorrectConceptLinksinAlgPages.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import os import re from mantid.api import AlgorithmFactory diff --git a/tools/scripts/FindIncompleteAlgRSTPages.py b/tools/scripts/FindIncompleteAlgRSTPages.py index 2c5356aa374b4bb888e0dc44fa61b182d186b0ea..56c2bdc3fe9b2bb18343014a67eec12d5ed582ec 100644 --- a/tools/scripts/FindIncompleteAlgRSTPages.py +++ b/tools/scripts/FindIncompleteAlgRSTPages.py @@ -5,7 +5,6 @@ # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) import os import re import urllib2 diff --git a/tools/scripts/TestWikiPython.py b/tools/scripts/TestWikiPython.py index 58e8e760bd60b76d842dcc582ccfb5802ffeb35d..b33ec8e31c03af3d0445876d1a8f4480f63c6e0a 100644 --- a/tools/scripts/TestWikiPython.py +++ b/tools/scripts/TestWikiPython.py @@ -10,7 +10,6 @@ # run with -h for command line arguments # ########################################################################################## -from __future__ import (absolute_import, division, print_function) import os import re import sys diff --git a/tools/scripts/extractAlgorithmNames.py b/tools/scripts/extractAlgorithmNames.py index 70ae15f0233db55dfc295dc03041914b97ab241c..1dedd93046d8ea85dbf8eccb21c1fc2ca2d5674f 100644 --- a/tools/scripts/extractAlgorithmNames.py +++ b/tools/scripts/extractAlgorithmNames.py @@ -7,7 +7,6 @@ #pylint: disable=invalid-name # simply just print out all algorithm names in a directory which can be piped # to a file -from __future__ import (absolute_import, division, print_function) import os import glob diff --git a/tools/scripts/extractAuthorNamesFromGit.py b/tools/scripts/extractAuthorNamesFromGit.py index 5656ab8b36b18870bfa72c6affe1b47009d48777..c60bf23a777bed05a7d67c912f9c7d0fef07789d 100644 --- a/tools/scripts/extractAuthorNamesFromGit.py +++ b/tools/scripts/extractAuthorNamesFromGit.py @@ -12,7 +12,6 @@ # was original used in connection with creating usage examples for algorithms # and creating an algorithm list for each developer to have a go at -from __future__ import (absolute_import, division, print_function) import os import subprocess diff --git a/tools/scripts/pyqt4_to_qtpy.py b/tools/scripts/pyqt4_to_qtpy.py index 312eb14ddee02567e6dc5705adcbcbbf99d9b071..2473d04619942053a2215874812aecab209647f7 100755 --- a/tools/scripts/pyqt4_to_qtpy.py +++ b/tools/scripts/pyqt4_to_qtpy.py @@ -5,7 +5,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, division, print_function, unicode_literals) import os import sys diff --git a/tools/scripts/update-pr-base-branch.py b/tools/scripts/update-pr-base-branch.py index af8a8ef20a895bbed7ee27013892b86cb4e9e2dc..9093f865b4b7508f88613c41e2afcbf564304f19 100644 --- a/tools/scripts/update-pr-base-branch.py +++ b/tools/scripts/update-pr-base-branch.py @@ -4,8 +4,6 @@ # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + -from __future__ import (absolute_import, print_function) - # std library import argparse import json diff --git a/tools/sip/sipwrapper.py b/tools/sip/sipwrapper.py index fc256e99b5e484cc3568c3f63a7cdce8624a92ee..3825d8d51d386a30d38e28196bbeb61d0cb09a73 100755 --- a/tools/sip/sipwrapper.py +++ b/tools/sip/sipwrapper.py @@ -9,8 +9,6 @@ Wraps a call to the sip code generation executable to strip any throw specifications from the generated code as these have been removed from C++17. """ -from __future__ import (absolute_import, division, print_function, unicode_literals) - # system imports import argparse import logging diff --git a/tools/skipped_systemtests.py b/tools/skipped_systemtests.py index b699ee4f3d37593b98f32857f5cc9907e74b5f8f..dec309fd70085dd1b1358c30bd2c82447a49cfdf 100755 --- a/tools/skipped_systemtests.py +++ b/tools/skipped_systemtests.py @@ -6,7 +6,6 @@ # SPDX - License - Identifier: GPL - 3.0 + #pylint: disable=invalid-name #!/usr/bin/env python -from __future__ import absolute_import, division, print_function import datetime import requests # python-requests