Commit f2dadc47 authored by Federico Montesino Pouzols's avatar Federico Montesino Pouzols
Browse files

Merge remote-tracking branch 'origin/master' into 15246_reduce_recursive_includes_in_Algorithm.h

Fixed conflicts with last few days changes in master, especially with InstrumentWidget files that
have been moved and revamped, re #15246.
parents ad814ae0 7888407a
......@@ -470,11 +470,11 @@ void CreateSampleWorkspace::replaceAll(std::string &str,
Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular(
API::Progress &progress, int num_banks, int pixels, double pixelSpacing,
const double bankDistanceFromSample, const double sourceSampleDistance) {
boost::shared_ptr<Instrument> testInst(new Instrument("basic_rect"));
auto testInst = boost::make_shared<Instrument>("basic_rect");
// The instrument is going to be set up with z as the beam axis and y as the
// vertical axis.
testInst->setReferenceFrame(
boost::shared_ptr<ReferenceFrame>(new ReferenceFrame(Y, Z, Left, "")));
boost::make_shared<ReferenceFrame>(Y, Z, Left, ""));
const double cylRadius(pixelSpacing / 2);
const double cylHeight(0.0002);
......
......@@ -8,6 +8,7 @@
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/CompositeValidator.h"
#include "MantidKernel/VectorHelper.h"
#include <boost/iterator/counting_iterator.hpp>
#include <numeric>
#include <sstream>
......@@ -96,13 +97,10 @@ void CrossCorrelate::exec() {
throw std::runtime_error(
"Must specify WorkspaceIndexMin<WorkspaceIndexMax");
// Get the number of spectra in range specmin to specmax
int nspecs = 0;
std::vector<size_t> indexes; // Indexes of all spectra in range
indexes.reserve(specmax - specmin); // reserve at leat enough space
for (int i = specmin; i <= specmax; ++i) {
indexes.push_back(i); // If spectrum found then add its index to a vector.
++nspecs;
}
int nspecs = 1 + specmax - specmin;
// Indexes of all spectra in range
std::vector<size_t> indexes(boost::make_counting_iterator(specmin),
boost::make_counting_iterator(specmax + 1));
std::ostringstream mess;
if (nspecs == 0) // Throw if no spectra in range
......
......@@ -5,14 +5,17 @@
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidDataObjects/EventWorkspaceHelpers.h"
#include "MantidDataObjects/MaskWorkspace.h"
#include "MantidKernel/MultiThreaded.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidKernel/EnabledWhenProperty.h"
#include "MantidKernel/Exception.h"
#include "MantidKernel/MultiThreaded.h"
#include "MantidKernel/VisibleWhenProperty.h"
#include <boost/iterator/counting_iterator.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <gsl/gsl_statistics.h>
#include <cfloat>
#include "MantidKernel/BoundedValidator.h"
namespace Mantid {
......@@ -530,14 +533,9 @@ DetectorDiagnostic::generateEmptyMask(API::MatrixWorkspace_const_sptr inputWS) {
std::vector<std::vector<size_t>>
DetectorDiagnostic::makeInstrumentMap(API::MatrixWorkspace_sptr countsWS) {
std::vector<std::vector<size_t>> mymap;
std::vector<size_t> single;
for (size_t i = 0; i < countsWS->getNumberHistograms(); i++) {
single.push_back(i);
}
mymap.push_back(single);
return mymap;
return {
{boost::counting_iterator<std::size_t>(0),
boost::counting_iterator<std::size_t>(countsWS->getNumberHistograms())}};
}
/** This function will check how to group spectra when calculating median
*
......
......@@ -192,10 +192,7 @@ void DiffractionFocussing::RebinWorkspace(
double step = 0;
calculateRebinParams(workspace, min, max, step);
std::vector<double> paramArray;
paramArray.push_back(min);
paramArray.push_back(-step);
paramArray.push_back(max);
std::vector<double> paramArray{min, -step, max};
g_log.information() << "Rebinning from " << min << " to " << max << " in "
<< step << " logaritmic steps.\n";
......
......@@ -653,7 +653,7 @@ void DiffractionFocussing2::determineRebinParameters() {
// Build up the X vector.
boost::shared_ptr<MantidVec> xnew =
boost::shared_ptr<MantidVec>(new MantidVec(xPoints)); // New X vector
boost::make_shared<MantidVec>(xPoints); // New X vector
(*xnew)[0] = Xmin;
for (int64_t j = 1; j < xPoints; j++) {
(*xnew)[j] = Xmin * (1.0 + step);
......
......@@ -187,6 +187,7 @@ void EQSANSTofStructure::execEvent(
clean_events.push_back(TofEvent(newtof, it->pulseTime()));
}
events.clear();
events.reserve(clean_events.size());
for (it = clean_events.begin(); it < clean_events.end(); ++it) {
events.push_back(*it);
}
......
......@@ -110,9 +110,16 @@ double GravitySANSHelper::gravitationalDrop(API::MatrixWorkspace_const_sptr ws,
g * NeutronMass * NeutronMass / (2.0 * h * h);
const V3D samplePos = ws->getInstrument()->getSample()->getPos();
const double pathLength = det->getPos().distance(samplePos) + extraLength;
// Perform a path length correction if an Lextra is specified.
// The correction is Lcorr^2 = (L + Lextra)^2 -(LExtra)^2
const auto pathLengthWithExtraLength =
det->getPos().distance(samplePos) + extraLength;
const auto pathLengthSquared =
std::pow(pathLengthWithExtraLength, 2) - std::pow(extraLength, 2);
// Want L2 (sample-pixel distance) squared, times the prefactor g^2/h^2
const double L2 = gm2_OVER_2h2 * std::pow(pathLength, 2);
const double L2 = gm2_OVER_2h2 * pathLengthSquared;
return waveLength * waveLength * L2;
}
......
......@@ -258,9 +258,7 @@ DECLARE_ALGORITHM(PerformIndexOperations)
//------------------------------------------------------------------------------
/** Constructor
*/
PerformIndexOperations::PerformIndexOperations() {
useAlgorithm("GroupDetectors", 2);
}
PerformIndexOperations::PerformIndexOperations() {}
//------------------------------------------------------------------------------
/** Destructor
......@@ -340,11 +338,6 @@ VecCommands interpret(const std::string &processingInstructions) {
/** Execute the algorithm.
*/
void PerformIndexOperations::exec() {
g_log.error("PerformIndexOperations has been deprecated. It will be "
"removed in the next release of Mantid. The same functionality "
"is provided by GroupDetectors-v2. Its GroupingPattern "
"property accepts the same syntax as PerformIndexOperations' "
"ProcessingInstructions property.");
MatrixWorkspace_sptr inputWorkspace = this->getProperty("InputWorkspace");
const std::string processingInstructions =
this->getProperty("ProcessingInstructions");
......
......@@ -185,7 +185,7 @@ void RingProfile::exec() {
// the horizontal axis is configured as degrees and copy the values of X
API::Axis *const horizontal = new API::NumericAxis(refX.size());
horizontal->unit() = boost::shared_ptr<Kernel::Unit>(new Kernel::Units::Phi);
horizontal->unit() = boost::make_shared<Kernel::Units::Phi>();
horizontal->title() = "Ring Angle";
for (size_t j = 0; j < refX.size(); j++)
horizontal->setValue(j, refX[j]);
......
......@@ -122,8 +122,7 @@ private:
}
Mantid::API::IAlgorithm_sptr createAlgorithm() {
auto alg =
boost::shared_ptr<Mantid::API::IAlgorithm>(new AnnularRingAbsorption());
auto alg = boost::make_shared<AnnularRingAbsorption>();
alg->initialize();
alg->setChild(true);
alg->setRethrows(true);
......
......@@ -232,13 +232,10 @@ public:
void
test_buildBinaryOperationTable_simpleLHS_by_groupedRHS_mismatched_throws() {
std::vector<std::vector<int>> lhs(6), rhs(2);
for (int i = 0; i < 6; i++) {
// one detector per pixel in lhs, but they start at 3
lhs[i].push_back(i + 3);
// 3 detectors in each on the rhs
rhs[i / 3].push_back(i);
}
// one detector per pixel in lhs, but they start at 3
std::vector<std::vector<int>> lhs{{3}, {4}, {5}, {6}, {7}, {8}};
// 3 detectors in each on the rhs
std::vector<std::vector<int>> rhs{{0, 1, 2}, {3, 4, 5}};
auto table = do_test_buildBinaryOperationTable(lhs, rhs, false);
TS_ASSERT_EQUALS((*table)[0], 1);
TS_ASSERT_EQUALS((*table)[1], 1);
......@@ -249,13 +246,12 @@ public:
}
void test_buildBinaryOperationTable_groupedLHS_by_groupedRHS() {
std::vector<std::vector<int>> lhs(8), rhs(4);
for (int i = 0; i < 16; i++) {
// two detectors per pixel in lhs
lhs[i / 2].push_back(i);
// 4 detectors in each on the rhs
rhs[i / 4].push_back(i);
}
// two detectors per pixel in lhs
std::vector<std::vector<int>> lhs{
{0, 1}, {2, 3}, {4, 5}, {6, 7}, {8, 9}, {10, 11}, {12, 13}, {14, 15}};
// 4 detectors in each on the rhs
std::vector<std::vector<int>> rhs{
{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}};
auto table = do_test_buildBinaryOperationTable(lhs, rhs);
for (int i = 0; i < 8; i++) {
TS_ASSERT_EQUALS((*table)[i], i / 2);
......@@ -264,13 +260,19 @@ public:
void
test_buildBinaryOperationTable_groupedLHS_by_groupedRHS_bad_overlap_throws() {
std::vector<std::vector<int>> lhs(6), rhs(4);
for (int i = 0; i < 24; i++) {
// 4 detectors per pixel in lhs
lhs[i / 4].push_back(i);
// 6 detectors in each on the rhs
rhs[i / 6].push_back(i);
}
// 4 detectors per pixel in lhs
std::vector<std::vector<int>> lhs{{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11},
{12, 13, 14, 15},
{16, 17, 18, 19},
{20, 21, 22, 23}};
// 6 detectors in each on the rhs
std::vector<std::vector<int>> rhs{{0, 1, 2, 3, 4, 5},
{6, 7, 8, 9, 10, 11},
{12, 13, 14, 15, 16, 17},
{18, 19, 20, 21, 22, 23}};
auto table = do_test_buildBinaryOperationTable(lhs, rhs, false);
TS_ASSERT_EQUALS((*table)[0], 0); // 0-3 go into 0-5
TS_ASSERT_EQUALS((*table)[1], -1); // 4-7 fails to go anywhere
......
......@@ -64,27 +64,8 @@ public:
/** Generate a workspace for test
*/
MatrixWorkspace_sptr generateTestWorkspace() {
vector<double> data;
data.push_back(12);
data.push_back(13);
data.push_back(9);
data.push_back(18);
data.push_back(7);
data.push_back(9);
data.push_back(14);
data.push_back(16);
data.push_back(10);
data.push_back(12);
data.push_back(7);
data.push_back(13);
data.push_back(14);
data.push_back(19);
data.push_back(10);
data.push_back(16);
data.push_back(12);
data.push_back(16);
data.push_back(19);
data.push_back(11);
vector<double> data{12, 13, 9, 18, 7, 9, 14, 16, 10, 12,
7, 13, 14, 19, 10, 16, 12, 16, 19, 11};
MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>(
WorkspaceFactory::Instance().create("Workspace2D", 1, data.size(),
......
......@@ -31,12 +31,15 @@ public:
Workspace_sptr space =
WorkspaceFactory::Instance().create("Workspace2D", 256, 11, 10);
Workspace2D_sptr space2D = boost::dynamic_pointer_cast<Workspace2D>(space);
boost::shared_ptr<Mantid::MantidVec> x(new Mantid::MantidVec(11));
boost::shared_ptr<Mantid::MantidVec> x =
boost::make_shared<Mantid::MantidVec>(11);
for (int i = 0; i < 11; ++i) {
(*x)[i] = i * 1000;
}
boost::shared_ptr<Mantid::MantidVec> a(new Mantid::MantidVec(10));
boost::shared_ptr<Mantid::MantidVec> e(new Mantid::MantidVec(10));
boost::shared_ptr<Mantid::MantidVec> a =
boost::make_shared<Mantid::MantidVec>(10);
boost::shared_ptr<Mantid::MantidVec> e =
boost::make_shared<Mantid::MantidVec>(10);
for (int i = 0; i < 10; ++i) {
(*a)[i] = i;
(*e)[i] = sqrt(double(i));
......
......@@ -62,13 +62,7 @@ public:
// get some value to check
double l1 = 43.754;
vector<size_t> checkrows;
checkrows.push_back(0);
checkrows.push_back(100);
checkrows.push_back(1000);
checkrows.push_back(5000);
for (size_t i = 0; i < checkrows.size(); ++i) {
for (size_t i = 0; i < 4; ++i) {
TableRow row = outws->getRow(i);
int detid;
double correction, l2;
......@@ -108,13 +102,7 @@ public:
// get some value to check
double l1 = 43.754;
vector<size_t> checkrows;
checkrows.push_back(0);
checkrows.push_back(100);
checkrows.push_back(1000);
checkrows.push_back(5000);
for (size_t i = 0; i < checkrows.size(); ++i) {
for (size_t i = 0; i < 4; ++i) {
TableRow row = outws->getRow(i);
int detid;
double correction, l2;
......
......@@ -19,11 +19,7 @@ public:
Mantid::Algorithms::CreateWorkspace alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize());
std::vector<double> dataEYX;
for (int i = 0; i < 3; i++) {
dataEYX.push_back(i * 1.234);
}
std::vector<double> dataEYX{0.0, 1.234, 2.468};
std::vector<std::string> qvals{"9.876"};
......@@ -94,11 +90,7 @@ public:
alg.setProperty<std::vector<std::string>>("VerticalAxisValues", textAxis);
alg.setProperty<int>("NSpec", 4);
std::vector<double> values;
values.push_back(1.0);
values.push_back(2.0);
values.push_back(3.0);
values.push_back(4.0);
std::vector<double> values{1.0, 2.0, 3.0, 4.0};
alg.setProperty<std::vector<double>>("DataX", std::vector<double>(2, 1.1));
alg.setProperty<std::vector<double>>("DataY", values);
......
......@@ -148,7 +148,7 @@ private:
boost::shared_ptr<Object> shape =
ShapeFactory().createShape(xmlShape, addTypeTag);
boost::shared_ptr<Instrument> instrument(new Instrument);
boost::shared_ptr<Instrument> instrument = boost::make_shared<Instrument>();
space2D->setInstrument(instrument);
ObjComponent *sample = new ObjComponent("sample", shape, NULL);
sample->setPos(0, 0, 0);
......
......@@ -105,7 +105,7 @@ public:
WorkspaceFactory::Instance().create("Workspace2D", Nhist, NXs, NXs - 1);
Workspace2D_sptr inputA = boost::dynamic_pointer_cast<Workspace2D>(spaceA);
Workspace2D_sptr inputB = boost::dynamic_pointer_cast<Workspace2D>(spaceB);
boost::shared_ptr<MantidVec> x(new MantidVec(NXs));
boost::shared_ptr<MantidVec> x = boost::make_shared<MantidVec>(NXs);
for (int i = 0; i < NXs; ++i) {
(*x)[i] = i * 1000;
}
......@@ -120,7 +120,8 @@ public:
// the error values aren't used and aren't tested so we'll use some basic
// data
boost::shared_ptr<MantidVec> errors(new MantidVec(ySize, 1));
boost::shared_ptr<MantidVec> errors =
boost::make_shared<MantidVec>(ySize, 1);
boost::shared_ptr<MantidVec> forInputA, forInputB;
for (int j = 0; j < Nhist; ++j) {
......
......@@ -39,16 +39,14 @@ public:
ExtractMaskToTable alg;
vector<int> vecA;
vector<int> vecB;
// Case: A constains B
vecA.reserve(20);
for (size_t i = 0; i < 20; ++i) {
vecA.push_back(static_cast<int>(i) + 5);
}
for (size_t i = 0; i < 4; ++i) {
vecB.push_back(static_cast<int>(i) * 4 + 1 + 5);
}
vector<int> vecB{6, 10, 14, 18};
vector<int> vecC = alg.subtractVector(vecA, vecB);
......
......@@ -34,7 +34,8 @@ public:
testWS->getAxis(0)->unit() =
Mantid::Kernel::UnitFactory::Instance().create("Wavelength");
boost::shared_ptr<Instrument> testInst(new Instrument("testInst"));
boost::shared_ptr<Instrument> testInst =
boost::make_shared<Instrument>("testInst");
testWS->setInstrument(testInst);
// Define a source and sample position
......
......@@ -176,7 +176,7 @@ public:
WorkspaceFactory::Instance().create("Workspace2D", Nhist, 11, 10);
m_2DWS = boost::dynamic_pointer_cast<Workspace2D>(space);
const short specLength = 22;
boost::shared_ptr<MantidVec> x(new MantidVec(specLength));
boost::shared_ptr<MantidVec> x = boost::make_shared<MantidVec>(specLength);
for (int i = 0; i < specLength; ++i) {
(*x)[i] = i * 1000;
}
......@@ -197,12 +197,13 @@ public:
boost::shared_ptr<MantidVec> almostBigEnough(
new MantidVec(specLength - 1, 0));
(*almostBigEnough)[0] = 0.9 * m_YSum * (0.5 * Nhist - 1);
boost::shared_ptr<MantidVec> bigEnough(new MantidVec(specLength - 1, 0));
boost::shared_ptr<MantidVec> bigEnough =
boost::make_shared<MantidVec>(specLength - 1, 0);
(*bigEnough)[0] = 1.2 * m_YSum * (0.5 * Nhist);
for (int j = 0; j < Nhist; ++j) {
m_2DWS->setX(j, x);
boost::shared_ptr<MantidVec> spectrum(new MantidVec);
boost::shared_ptr<MantidVec> spectrum = boost::make_shared<MantidVec>();
// the spectravalues will be multiples of the random numbers above
for (int l = 0; l < specLength - 1; ++l) {
spectrum->push_back(j * yArray[l]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment