Skip to content

Commit

Permalink
Merge branch 'master' into 11056_loadsqw_v2
Browse files Browse the repository at this point in the history
Conflicts:
	Framework/DataObjects/test/MDBoxBaseTest.h
Refs #11056
  • Loading branch information
martyngigg committed Mar 9, 2016
2 parents e4d1640 + 200cec1 commit 78bd30c
Show file tree
Hide file tree
Showing 686 changed files with 6,445 additions and 4,910 deletions.
23 changes: 9 additions & 14 deletions Framework/API/inc/MantidAPI/BoxController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <nexus/NeXusFile.hpp>

#include <boost/optional.hpp>
#include <numeric>
#include <vector>

namespace Mantid {
Expand Down Expand Up @@ -294,10 +295,10 @@ class DLLExport BoxController {
// We need to account for optional top level splitting
if (depth == 0 && m_splitTopInto) {

size_t numSplitTop = 1;
for (size_t d = 0; d < m_splitTopInto.get().size(); d++)
numSplitTop *= m_splitTopInto.get()[d];

const auto &splitTopInto = m_splitTopInto.get();
size_t numSplitTop =
std::accumulate(splitTopInto.cbegin(), splitTopInto.cend(), size_t{1},
std::multiplies<size_t>());
m_numMDBoxes[depth + 1] += numSplitTop;
} else {
m_numMDBoxes[depth + 1] += m_numSplit;
Expand All @@ -321,20 +322,14 @@ class DLLExport BoxController {

/** Return the total number of MD Boxes, irrespective of depth */
size_t getTotalNumMDBoxes() const {
size_t total = 0;
for (size_t depth = 0; depth < m_numMDBoxes.size(); depth++) {
total += m_numMDBoxes[depth];
}
return total;
return std::accumulate(m_numMDBoxes.cbegin(), m_numMDBoxes.cend(),
size_t{0}, std::plus<size_t>());
}

/** Return the total number of MDGridBox'es, irrespective of depth */
size_t getTotalNumMDGridBoxes() const {
size_t total = 0;
for (size_t depth = 0; depth < m_numMDGridBoxes.size(); depth++) {
total += m_numMDGridBoxes[depth];
}
return total;
return std::accumulate(m_numMDGridBoxes.cbegin(), m_numMDGridBoxes.cend(),
size_t{0}, std::plus<size_t>());
}

/** Return the average recursion depth of gridding.
Expand Down
11 changes: 5 additions & 6 deletions Framework/API/inc/MantidAPI/FunctionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ const std::vector<std::string> &FunctionFactoryImpl::getFunctionNames() const {
// Create the entry in the cache and work with it directly
std::vector<std::string> &typeNames = m_cachedFunctionNames[soughtType];
const std::vector<std::string> names = this->getKeys();
for (auto it = names.begin(); it != names.end(); ++it) {
boost::shared_ptr<IFunction> func = this->createFunction(*it);
if (func && dynamic_cast<FunctionType *>(func.get())) {
typeNames.push_back(*it);
}
}
std::copy_if(names.cbegin(), names.cend(), std::back_inserter(typeNames),
[this](const std::string &name) {
boost::shared_ptr<IFunction> func = this->createFunction(name);
return boost::dynamic_pointer_cast<FunctionType>(func);
});
return typeNames;
}

Expand Down
10 changes: 5 additions & 5 deletions Framework/API/inc/MantidAPI/MatrixWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ class MANTID_API_DLL MatrixWorkspace : public IMDWorkspace,
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighbours(const Geometry::IDetector *comp, const double radius = 0.0,
const bool ignoreMaskedDetectors = false) const;
/// Query the NearestNeighbours object for a given spectrum index using a
/// Query the NearestNeighbours object for a given spectrum number using a
/// search radius
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighbours(specnum_t spec, const double radius,
const bool ignoreMaskedDetectors = false) const;
/// Query the NearestNeighbours object for a given spectrum index using the
/// Query the NearestNeighbours object for a given spectrum number using the
/// direct number of nearest neighbours
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighboursExact(specnum_t spec, const int nNeighbours,
Expand Down Expand Up @@ -315,7 +315,7 @@ class MANTID_API_DLL MatrixWorkspace : public IMDWorkspace,

/**
* Probes if DX (X Error) values were set on a particular spectrum
* @param index: the spectrum index
* @param index: the workspace index
*/
virtual bool hasDx(const std::size_t index) const {
return getSpectrum(index)->hasDx();
Expand Down Expand Up @@ -364,7 +364,7 @@ class MANTID_API_DLL MatrixWorkspace : public IMDWorkspace,
// Methods to set and access masked bins
void maskBin(const size_t &workspaceIndex, const size_t &binIndex,
const double &weight = 1.0);
void flagMasked(const size_t &spectrumIndex, const size_t &binIndex,
void flagMasked(const size_t &index, const size_t &binIndex,
const double &weight = 1.0);
bool hasMaskedBins(const size_t &workspaceIndex) const;
/// Masked bins for each spectrum are stored as a set of pairs containing <bin
Expand Down Expand Up @@ -512,7 +512,7 @@ class MANTID_API_DLL MatrixWorkspace : public IMDWorkspace,
/// Flag indicating whether the data has common bins. False by default
mutable bool m_isCommonBinsFlag;

/// The set of masked bins in a map keyed on spectrum index
/// The set of masked bins in a map keyed on workspace index
std::map<int64_t, MaskList> m_masks;

/// A workspace holding monitor data relating to the main data in the
Expand Down
2 changes: 1 addition & 1 deletion Framework/API/inc/MantidAPI/ParameterTie.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MANTID_API_DLL ParameterTie final : public ParameterReference {
ParameterTie(IFunction *funct, const std::string &parName,
const std::string &expr = "", bool isDefault = false);
/// Destructor
virtual ~ParameterTie();
~ParameterTie() override;
/// Set the tie expression
virtual void set(const std::string &expr);
/// Evaluate the expression
Expand Down
4 changes: 2 additions & 2 deletions Framework/API/inc/MantidAPI/SingleValueParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ std::string SingleValueParameter<Derived, ValType>::toXMLString() const {
static std::string parameterName() { return #classname; } \
classname(type_ value) : SuperType(value) {} \
classname() : SuperType() {} \
std::string getName() const { return #classname; } \
classname *clone() const { return new classname(m_value); } \
std::string getName() const override { return #classname; } \
classname *clone() const override { return new classname(m_value); } \
};
}
}
Expand Down
3 changes: 1 addition & 2 deletions Framework/API/inc/MantidAPI/WorkspaceProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ class WorkspaceProperty
std::string error;

// Cycle through each workspace in the group ...
for (auto it = wsGroupNames.begin(); it != wsGroupNames.end(); ++it) {
std::string memberWsName = *it;
for (const auto &memberWsName : wsGroupNames) {
boost::shared_ptr<Workspace> memberWs =
AnalysisDataService::Instance().retrieve(memberWsName);

Expand Down
12 changes: 6 additions & 6 deletions Framework/API/src/AlgorithmFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,17 @@ AlgorithmFactoryImpl::getDescriptors(bool includeHidden) const {
// results vector
std::vector<Algorithm_descriptor> res;

for (auto s = sv.cbegin(); s != sv.cend(); ++s) {
if (s->empty())
for (const auto &s : sv) {
if (s.empty())
continue;
Algorithm_descriptor desc;
size_t i = s->find('|');
size_t i = s.find('|');
if (i == std::string::npos) {
desc.name = *s;
desc.name = s;
desc.version = 1;
} else if (i > 0) {
desc.name = s->substr(0, i);
std::string vers = s->substr(i + 1);
desc.name = s.substr(0, i);
std::string vers = s.substr(i + 1);
desc.version = vers.empty() ? 1 : atoi(vers.c_str());
} else
continue;
Expand Down
4 changes: 2 additions & 2 deletions Framework/API/src/GroupingLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ ITableWorkspace_sptr Grouping::toTable() const {

newTable->addColumn("vector_int", "Detectors");

for (auto it = this->groups.begin(); it != this->groups.end(); ++it) {
for (const auto &group : this->groups) {
TableRow newRow = newTable->appendRow();
newRow << Kernel::Strings::parseRange(*it);
newRow << Kernel::Strings::parseRange(group);
}

return newTable;
Expand Down
2 changes: 1 addition & 1 deletion Framework/API/src/HistoryView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void HistoryView::unroll(std::vector<HistoryItem>::iterator &it) {
tmpHistory.emplace_back(item);
}
// since we are using a std::vector, do all insertions at the same time.
#if !defined(GCC_VERSION) || GCC_VERSION >= 409000
#if !defined(GCC_VERSION) || GCC_VERSION >= 40900
++it; // move iterator forward to insertion position
it = m_historyItems.insert(it, tmpHistory.begin(), tmpHistory.end());
#else
Expand Down
14 changes: 7 additions & 7 deletions Framework/API/src/MatrixWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ void MatrixWorkspace::maskWorkspaceIndex(const std::size_t index) {
* on the same spectrum. Writing to
* the mask set is marked parrallel critical so different spectra can be
* analysised in parallel
* @param workspaceIndex :: The workspace spectrum index of the bin
* @param workspaceIndex :: The workspace index of the bin
* @param binIndex :: The index of the bin in the spectrum
* @param weight :: 'How heavily' the bin is to be masked. =1 for full
* masking (the default).
Expand Down Expand Up @@ -1065,20 +1065,20 @@ void MatrixWorkspace::maskBin(const size_t &workspaceIndex,
}

/** Writes the masking weight to m_masks (doesn't alter y-values). Contains a
* parrallel critical section
* parallel critical section
* and so is thread safe
* @param spectrumIndex :: The workspace spectrum index of the bin
* @param index :: The workspace index of the spectrum
* @param binIndex :: The index of the bin in the spectrum
* @param weight :: 'How heavily' the bin is to be masked. =1 for full
* masking (the default).
*/
void MatrixWorkspace::flagMasked(const size_t &spectrumIndex,
const size_t &binIndex, const double &weight) {
void MatrixWorkspace::flagMasked(const size_t &index, const size_t &binIndex,
const double &weight) {
// Writing to m_masks is not thread-safe, so put in some protection
PARALLEL_CRITICAL(maskBin) {
// First get a reference to the list for this spectrum (or create a new
// list)
MaskList &binList = m_masks[spectrumIndex];
MaskList &binList = m_masks[index];
auto it = binList.find(binIndex);
if (it != binList.end()) {
binList.erase(it);
Expand All @@ -1088,7 +1088,7 @@ void MatrixWorkspace::flagMasked(const size_t &spectrumIndex,
}

/** Does this spectrum contain any masked bins
* @param workspaceIndex :: The workspace spectrum index to test
* @param workspaceIndex :: The workspace index to test
* @return True if there are masked bins for this spectrum
*/
bool MatrixWorkspace::hasMaskedBins(const size_t &workspaceIndex) const {
Expand Down
6 changes: 4 additions & 2 deletions Framework/API/src/SpectrumDetectorMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,17 @@ std::set<specnum_t> SpectrumDetectorMapping::getSpectrumNumbers() const {
const std::set<detid_t> &SpectrumDetectorMapping::getDetectorIDsForSpectrumNo(
const specnum_t spectrumNo) const {
if (!m_indexIsSpecNo)
throw std::runtime_error("Indices are in spectrum index, not number.");
throw std::runtime_error(
"Indices are in the spectrum detector map, not spectrum number.");
return m_mapping.at(spectrumNo);
}

const std::set<detid_t> &
SpectrumDetectorMapping::getDetectorIDsForSpectrumIndex(
const size_t spectrumIndex) const {
if (m_indexIsSpecNo)
throw std::runtime_error("Indices are in spectrum number, not index.");
throw std::runtime_error(
"Spectrum numbers are in the spectrum detector map, not index.");
return m_mapping.at(static_cast<int>(spectrumIndex));
}

Expand Down
2 changes: 1 addition & 1 deletion Framework/API/test/AlgorithmFactoryTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AlgorithmFactoryTest : public CxxTest::TestSuite {

AlgorithmFactoryTest() {}

~AlgorithmFactoryTest() {}
~AlgorithmFactoryTest() override {}

void testSubscribe() {
Mantid::Kernel::Instantiator<ToyAlgorithmTwo, Algorithm> *newTwo =
Expand Down
40 changes: 22 additions & 18 deletions Framework/API/test/AlgorithmHasPropertyTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,43 @@ class AlgorithmHasPropertyTest : public CxxTest::TestSuite {
private:
class AlgorithmWithWorkspace : public Algorithm {
public:
const std::string name() const { return "AlgorithmWithWorkspace"; }
int version() const { return 1; }
const std::string category() const { return "Cat"; }
const std::string summary() const { return "Test summary"; }
const std::string name() const override { return "AlgorithmWithWorkspace"; }
int version() const override { return 1; }
const std::string category() const override { return "Cat"; }
const std::string summary() const override { return "Test summary"; }

void init() { declareProperty("OutputWorkspace", ""); }
void exec() {}
void init() override { declareProperty("OutputWorkspace", ""); }
void exec() override {}
};

class AlgorithmWithNoWorkspace : public Algorithm {
public:
const std::string name() const { return "AlgorithmWithNoWorkspace"; }
int version() const { return 1; }
const std::string category() const { return "Cat"; }
const std::string summary() const { return "Test summary"; }
const std::string name() const override {
return "AlgorithmWithNoWorkspace";
}
int version() const override { return 1; }
const std::string category() const override { return "Cat"; }
const std::string summary() const override { return "Test summary"; }

void init() { declareProperty("NotOutputWorkspace", ""); }
void exec() {}
void init() override { declareProperty("NotOutputWorkspace", ""); }
void exec() override {}
};

class AlgorithmWithInvalidProperty : public Algorithm {
public:
const std::string name() const { return "AlgorithmWithInvalidProperty"; }
int version() const { return 1; }
const std::string category() const { return "Cat"; }
const std::string summary() const { return "Test summary"; }
const std::string name() const override {
return "AlgorithmWithInvalidProperty";
}
int version() const override { return 1; }
const std::string category() const override { return "Cat"; }
const std::string summary() const override { return "Test summary"; }

void init() {
void init() override {
auto lower = boost::make_shared<Mantid::Kernel::BoundedValidator<int>>();
lower->setLower(0);
declareProperty("OutputValue", -1, lower);
}
void exec() {}
void exec() override {}
};

public:
Expand Down
18 changes: 10 additions & 8 deletions Framework/API/test/AlgorithmHistoryTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ using namespace Mantid::Kernel;
class testalg : public Algorithm {
public:
testalg() : Algorithm() {}
virtual ~testalg() {}
const std::string name() const {
~testalg() override {}
const std::string name() const override {
return "testalg";
} ///< Algorithm's name for identification
int version() const { return 1; } ///< Algorithm's version for identification
const std::string category() const {
} ///< Algorithm's name for identification
int version() const override {
return 1;
} ///< Algorithm's version for identification
const std::string category() const override {
return "Cat";
} ///< Algorithm's category for identification
const std::string summary() const { return "Test summary"; }
const std::string summary() const override { return "Test summary"; }

void init() {
void init() override {
declareProperty("arg1_param", "x", Direction::Input);
declareProperty("arg2_param", 23);
}
void exec() {}
void exec() override {}
};

class AlgorithmHistoryTest : public CxxTest::TestSuite {
Expand Down

0 comments on commit 78bd30c

Please sign in to comment.