57 SpectrumTester(Mantid::HistogramData::Histogram::XMode xmode, Mantid::HistogramData::Histogram::YMode ymode)
63 Mantid::HistogramData::Histogram::YMode ymode)
93 std::fill(yValues.begin(), yValues.end(), 0.0);
95 std::fill(eValues.begin(), eValues.end(), 0.0);
113 const std::string
id()
const override {
return "FakeWorkspace"; }
116 const std::string
toString()
const override {
return "FakeWorkspace instance"; }
128 throw std::runtime_error(
"Vector data is empty, cannot check for ragged workspace.");
130 const auto numberOfBins =
m_vec[0].dataY().size();
131 return std::any_of(
m_vec.cbegin(),
m_vec.cend(),
132 [&numberOfBins](
const auto &spectrum) { return numberOfBins != spectrum.dataY().size(); });
138 const std::string
id()
const override {
return "AxeslessWorkspaceTester"; }
140 return std::accumulate(
m_vec.cbegin(),
m_vec.cend(),
static_cast<size_t>(0),
141 [](
size_t total,
const SpectrumTester &i) { return total + i.dataY().size(); });
147 size_t numY =
m_vec[0].dataY().size();
148 if (std::any_of(
m_vec.cbegin(),
m_vec.cend(), [numY](
auto it) { return it.dataY().size() != numY; })) {
149 throw std::logic_error(
"non-constant number of bins");
153 return m_vec.empty() ? 0 :
m_vec[0].dataY().size();
168 return s1.dataY().size() < s2.dataY().size();
170 return iter->dataY().size();
184 void init(
const size_t &numspec,
const size_t &j,
const size_t &k)
override {
187 Mantid::HistogramData::Histogram::YMode::Counts));
188 for (
size_t i = 0; i <
m_spec; i++) {
189 m_vec[i].setMatrixWorkspace(
this, i);
190 m_vec[i].dataX().resize(j, 1.0);
191 m_vec[i].dataY().resize(k, 1.0);
192 m_vec[i].dataE().resize(k, 1.0);
200 for (
size_t i = 0; i <
m_spec; i++) {
209 throw std::runtime_error(
"Cloning of AxeslessWorkspaceTester is not implemented.");
226 const std::string
id()
const override {
return "WorkspaceTester"; }
229 std::unique_ptr<WorkspaceTester>
clone()
const {
return std::unique_ptr<WorkspaceTester>(
doClone()); }
235 void init(
const size_t &numspec,
const size_t &j,
const size_t &k)
override {
240 m_axes[0] = std::make_unique<Mantid::API::RefAxis>(
this);
241 m_axes[1] = std::make_unique<Mantid::API::SpectraAxis>(
this);
248 m_axes[0] = std::make_unique<Mantid::API::RefAxis>(
this);
249 m_axes[1] = std::make_unique<Mantid::API::SpectraAxis>(
this);
261 std::unique_ptr<TableWorkspaceTester>
clone()
const {
return std::unique_ptr<TableWorkspaceTester>(
doClone()); }
265 return std::unique_ptr<TableWorkspaceTester>(
doCloneEmpty());
268 const std::string
id()
const override {
return "TableWorkspaceTester"; }
270 size_t getMemorySize()
const override {
throw std::runtime_error(
"getMemorySize not implemented"); }
273 throw std::runtime_error(
"addColumn not implemented");
280 void removeColumn(
const std::string &)
override {
throw std::runtime_error(
"removeColumn not implemented"); }
282 size_t columnCount()
const override {
throw std::runtime_error(
"columnCount not implemented"); }
284 Column_sptr getColumn(
const std::string &)
override {
throw std::runtime_error(
"getColumn(str) not implemented"); }
287 throw std::runtime_error(
"getColumn(str) const not implemented");
293 throw std::runtime_error(
"getColumn(size_t) const not implemented");
297 throw std::runtime_error(
"getColumnNames not implemented");
300 size_t rowCount()
const override {
throw std::runtime_error(
"rowCount not implemented"); }
302 void setRowCount(
size_t)
override {
throw std::runtime_error(
"setRowCount not implemented"); }
304 size_t insertRow(
size_t)
override {
throw std::runtime_error(
"insertRow not implemented"); }
306 void removeRow(
size_t)
override {
throw std::runtime_error(
"removeRow not implemented"); }
308 void find(
size_t,
size_t &,
size_t)
override {
throw std::runtime_error(
"find not implemented"); }
310 void find(
double,
size_t &,
size_t)
override {
throw std::runtime_error(
"find not implemented"); }
312 void find(
float,
size_t &,
size_t)
override {
throw std::runtime_error(
"find not implemented"); }
314 void find(
Boolean,
size_t &,
size_t)
override {
throw std::runtime_error(
"find not implemented"); }
316 void find(
const std::string &,
size_t &,
size_t)
override {
throw std::runtime_error(
"find not implemented"); }
319 throw std::runtime_error(
"find not implemented");
324 throw std::runtime_error(
"Cloning of TableWorkspaceTester is not implemented.");
327 throw std::runtime_error(
"Cloning of TableWorkspaceTester is not implemented.");
330 throw std::runtime_error(
"Cloning of TableWorkspaceTester is not implemented.");
336 size_t size()
const override {
throw std::runtime_error(
"size not implemented"); }
338 std::type_info &
get_type_info()
const override {
throw std::runtime_error(
"get_type_info not implemented"); }
341 throw std::runtime_error(
"get_pointer_type_info not implemented");
344 void print(
size_t, std::ostream &)
const override {
throw std::runtime_error(
"print not implemented"); }
346 bool isBool()
const override {
throw std::runtime_error(
"isBool not implemented"); }
348 bool isNumber()
const override {
throw std::runtime_error(
"isNumber not implemented"); }
350 long int sizeOfData()
const override {
throw std::runtime_error(
"sizeOfData not implemented"); }
352 Column *
clone()
const override {
throw std::runtime_error(
"clone not implemented"); }
354 double toDouble(
size_t)
const override {
throw std::runtime_error(
"toDouble not implemented"); }
356 void fromDouble(
size_t,
double)
override {
throw std::runtime_error(
"fromDouble not implemented"); }
359 void resize(
size_t)
override {
throw std::runtime_error(
"resize not implemented"); }
360 void insert(
size_t)
override {
throw std::runtime_error(
"insert not implemented"); }
361 void remove(
size_t)
override {
throw std::runtime_error(
"remove not implemented"); }
362 void *
void_pointer(
size_t)
override {
throw std::runtime_error(
"void_pointer not implemented"); }
363 const void *
void_pointer(
size_t)
const override {
throw std::runtime_error(
"void_pointer const not implemented"); }
370 uint64_t
getNPoints()
const override {
throw std::runtime_error(
"Not Implemented"); }
371 uint64_t
getNEvents()
const override {
throw std::runtime_error(
"Not Implemented"); }
373 std::vector<std::unique_ptr<IMDIterator>>
378 throw std::runtime_error(
"Not Implemented");
384 throw std::runtime_error(
"Not Implemented");
391 throw std::runtime_error(
"Not Implemented");
394 void setMDMasking(std::unique_ptr<Mantid::Geometry::MDImplicitFunction> maskingRegion)
override {
396 throw std::runtime_error(
"Not Implemented");
421 throw std::runtime_error(
"Not Implemented");
426 throw std::runtime_error(
"Not Implemented");
432 throw std::runtime_error(
"Not Implemented");
438 throw std::runtime_error(
"Not Implemented");
443 throw std::runtime_error(
"Not Implemented");
449 throw std::runtime_error(
"Not Implemented");
456 throw std::runtime_error(
"Not Implemented");
464 throw std::runtime_error(
"Not Implemented");
469 throw std::runtime_error(
"Not Implemented");
475 throw std::runtime_error(
"Not Implemented");
482 throw std::runtime_error(
"Not Implemented");
490 throw std::runtime_error(
"Not Implemented");
495 throw std::runtime_error(
"Not Implemented");
501 throw std::runtime_error(
"Not Implemented");
508 throw std::runtime_error(
"Not Implemented");
516 throw std::runtime_error(
"Not Implemented");
521 throw std::runtime_error(
"Not Implemented");
527 throw std::runtime_error(
"Not Implemented");
534 throw std::runtime_error(
"Not Implemented");
542 throw std::runtime_error(
"Not Implemented");
547 throw std::runtime_error(
"Not Implemented");
552 throw std::runtime_error(
"Not Implemented");
558 throw std::runtime_error(
"Not Implemented");
561 size_t getLinearIndex(
size_t index1,
size_t index2,
size_t index3)
const override {
565 throw std::runtime_error(
"Not Implemented");
568 size_t getLinearIndex(
size_t index1,
size_t index2,
size_t index3,
size_t index4)
const override {
573 throw std::runtime_error(
"Not Implemented");
581 throw std::runtime_error(
"Not Implemented");
586 throw std::runtime_error(
"Not Implemented");
591 throw std::runtime_error(
"Not Implemented");
596 throw std::runtime_error(
"Not Implemented");
602 size_t getMemorySize()
const override {
throw std::runtime_error(
"Not Implemented"); }
604 const std::string
id()
const override {
throw std::runtime_error(
"Not Implemented"); }
605 const std::string &
getName()
const override {
throw std::runtime_error(
"Not Implemented"); }
606 bool threadSafe()
const override {
throw std::runtime_error(
"Not Implemented"); }
607 const std::string
toString()
const override {
throw std::runtime_error(
"Not Implemented"); }
610 std::vector<IMDDimension_sptr> dimensions{dimX, dimY, dimZ};
624 throw std::length_error(
"Mismatched bins sizes");
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
ISpectrum & getSpectrum(const size_t index) override
Return the underlying ISpectrum ptr at the given workspace index.
std::size_t getMaxNumberBins() const override
Returns the maximum number of bins in a workspace (works on ragged data).
size_t blocksize() const override
Returns the size of each block of data returned by the dataY accessors.
AxeslessWorkspaceTester * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
size_t size() const override
Returns the number of single indexable items in the workspace.
ISpectrum & getSpectrumWithoutInvalidation(const size_t index) override
void init(const Mantid::HistogramData::Histogram &histogram) override
Mantid::Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override
void init(const size_t &numspec, const size_t &j, const size_t &k) override
std::vector< SpectrumTester > m_vec
AxeslessWorkspaceTester(const Mantid::Parallel::StorageMode storageMode=Mantid::Parallel::StorageMode::Cloned)
const ISpectrum & getSpectrum(const size_t index) const override
Return the underlying ISpectrum ptr (const version) at the given workspace index.
std::size_t getNumberBins(const std::size_t &index) const override
Returns the number of bins for a given histogram index.
size_t getNumberHistograms() const override
Returns the number of histograms in the workspace.
const std::string id() const override
A string ID for the class.
void generateHistogram(const std::size_t, const MantidVec &, MantidVec &, MantidVec &, bool) const override
bool isRaggedWorkspace() const override
Returns true if the workspace is ragged (has differently sized spectra).
AxeslessWorkspaceTester * doCloneEmpty() const override
Virtual cloneEmpty method.
bool isBool() const override
Specialized type check.
double toDouble(size_t) const override
Cast an element to double if possible.
void print(size_t, std::ostream &) const override
Prints out the value to a stream.
std::type_info & get_pointer_type_info() const override
Returns typeid for the pointer type to the data element in the column.
Column * clone() const override
Virtual constructor. Fully clone any column.
void fromDouble(size_t, double) override
Assign an element from double if possible.
void * void_pointer(size_t) override
Pointer to a data element.
std::type_info & get_type_info() const override
Returns typeid for the data in the column.
long int sizeOfData() const override
Must return overall memory size taken by the column.
void insert(size_t) override
Inserts an item.
bool isNumber() const override
Are elements of the column interpretable as a number?
void resize(size_t) override
Sets the new column size.
const void * void_pointer(size_t) const override
Pointer to a data element.
void remove(size_t) override
Removes an item.
size_t size() const override
Number of individual elements in the column.
size_t getMemorySize() const override
Get the footprint in memory in bytes.
const std::string toString() const override
Serializes the object to a string.
Workspace * doCloneEmpty() const override
Virtual cloneEmpty method.
const std::string id() const override
A string ID for the class.
Workspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
signal_t getSignalAt(size_t index1, size_t index2, size_t index3) const override
signal_t getErrorNormalizedAt(size_t index1, size_t index2) const override
void setCoordinateSystem(const SpecialCoordinateSystem coordinateSystem) override
void setTo(signal_t signal, signal_t errorSquared, signal_t numEvents) override
double & operator[](const size_t &index) override
signal_t getSignalAt(size_t index1, size_t index2) const override
signal_t getSignalAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
signal_t getErrorAt(size_t index) const override
LinePlot getLineData(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const override
size_t getLinearIndex(size_t index1, size_t index2, size_t index3, size_t index4) const override
SpecialCoordinateSystem getSpecialCoordinateSystem() const override
uint64_t getNEvents() const override
signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
coord_t getInverseVolume() const override
See the MDHistoWorkspace definition for descriptions of these.
signal_t & signalAt(size_t index) override
signal_t getErrorAt(size_t index1, size_t index2) const override
const std::string & getName() const override
Get the workspace name.
const signal_t * getNumEventsArray() const override
signal_t getSignalNormalizedAt(size_t index1, size_t index2, size_t index3) const override
void setErrorSquaredAt(size_t index, signal_t value) override
signal_t getSignalAt(size_t index) const override
MDHistoWorkspaceTester(const MDHistoDimension_sptr &dimX, const MDHistoDimension_sptr &dimY, const MDHistoDimension_sptr &dimZ)
IMDHistoWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
size_t getMemorySize() const override
Get the footprint in memory in bytes.
signal_t * mutableSignalArray() override
std::vector< std::unique_ptr< IMDIterator > > createIterators(size_t suggestedNumCores=1, Mantid::Geometry::MDImplicitFunction *function=nullptr) const override
Creates a new iterator pointing to the first cell in the workspace.
signal_t getErrorAt(size_t index1, size_t index2, size_t index3) const override
size_t getLinearIndex(size_t index1, size_t index2, size_t index3) const override
Mantid::Kernel::VMD getCenter(size_t linearIndex) const override
const std::string toString() const override
Serializes the object to a string.
signal_t * mutableNumEventsArray() override
signal_t getErrorNormalizedAt(size_t index) const override
uint64_t getNPoints() const override
Get the number of points associated with the workspace.
signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
size_t getLinearIndex(size_t index1, size_t index2) const override
signal_t * mutableErrorSquaredArray() override
signal_t getErrorNormalizedAt(size_t index1, size_t index2, size_t index3) const override
signal_t getErrorAt(size_t index1, size_t index2, size_t index3, size_t index4) const override
const std::string id() const override
A string ID for the class.
bool hasOrientedLattice() const override
bool threadSafe() const override
Marks the workspace as safe for multiple threads to edit data simutaneously.
signal_t getSignalWithMaskAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
signal_t getSignalNormalizedAt(size_t index) const override
void clearMDMasking() override
Clear existing masks.
void setMDMasking(std::unique_ptr< Mantid::Geometry::MDImplicitFunction > maskingRegion) override
Setter for the masking region.
const signal_t * getSignalArray() const override
void setDisplayNormalization(const Mantid::API::MDNormalization &preferredNormalization) override
IMDHistoWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
void setSignalAt(size_t index, signal_t value) override
const signal_t * getErrorSquaredArray() const override
signal_t getSignalNormalizedAt(size_t index1, size_t index2) const override
signal_t & errorSquaredAt(size_t index) override
Column is the base class for columns of TableWorkspace.
size_t numberOfDetectorGroups() const
Returns the number of detector groups.
Abstract interface to MDHistoWorkspace, for use in exposing to Python.
A "spectrum" is an object that holds the data for a particular spectrum, in particular:
virtual MantidVec & dataY()=0
virtual const MantidVec & readY() const
Deprecated, use y() instead. Returns the y data const.
virtual void copyDataInto(DataObjects::EventList &) const
Override in child classes for polymorphic copying of data.
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
void initGeometry(const std::vector< std::shared_ptr< Geometry::IMDDimension > > &dimensions)
Initialize the geometry.
Base MatrixWorkspace Abstract Class.
std::vector< std::unique_ptr< Axis > > m_axes
A vector of pointers to the axes for this workspace.
void invalidateCommonBinsFlag()
Invalidates the commons bins flag.
HistogramData::Histogram histogram(const size_t index) const
Returns the Histogram at the given workspace index.
virtual MantidVec & dataY(const std::size_t index)
Deprecated, use mutableY() instead. Returns the y data.
bool hasOrientedLattice() const
Base Workspace Abstract Class.
Parallel::StorageMode storageMode() const
Returns the storage mode (used for MPI runs)
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
Implements a copy on write data template.
Helper class that implements ISpectrum.
const MantidVec & dataX() const override
const MantidVec & readDx() const override
void setX(const Mantid::Kernel::cow_ptr< Mantid::HistogramData::HistogramX > &X) override
MantidVec & dataX() override
Mantid::Kernel::cow_ptr< Mantid::HistogramData::HistogramX > ptrX() const override
void clearData() override
Mask the spectrum to this value.
MantidVec & dataE() override
SpectrumTester(Mantid::HistogramData::Histogram::XMode xmode, Mantid::HistogramData::Histogram::YMode ymode)
const Mantid::HistogramData::Histogram & histogramRef() const override
void copyDataFrom(const ISpectrum &other) override
Copy data from another ISpectrum with double-dynamic dispatch.
Mantid::HistogramData::Histogram & mutableHistogramRef() override
MantidVec & dataDx() override
const MantidVec & readX() const override
void copyDataInto(SpectrumTester &other) const override
Override in child classes for polymorphic copying of data.
Mantid::HistogramData::Histogram m_histogram
const MantidVec & dataE() const override
const MantidVec & dataDx() const override
SpectrumTester(const specnum_t specNo, Mantid::HistogramData::Histogram::XMode xmode, Mantid::HistogramData::Histogram::YMode ymode)
MantidVec & dataY() override
const MantidVec & dataY() const override
size_t getMemorySize() const override
std::unique_ptr< TableWorkspaceTester > cloneEmpty() const
Returns a default-initialized clone of the workspace.
LogManager_const_sptr getLogs() const override
Get constant access to shared pointer containing workspace properties.
TableWorkspaceTester * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
Column_sptr getColumn(const std::string &) override
Gets the shared pointer to a column by name.
Column_const_sptr getColumn(size_t) const override
Gets the shared pointer to a column by index - return none-modifyable column.
void find(double, size_t &, size_t) override
find method to get the index of double cell value in a table workspace
void find(Boolean, size_t &, size_t) override
find method to get the index of API::Boolean value cell in a table workspace
void removeColumn(const std::string &) override
Removes a column.
Column_sptr getColumn(size_t) override
Gets the shared pointer to a column by index.
size_t insertRow(size_t) override
Inserts a row before row pointed to by index and fills it with default vales.
size_t getMemorySize() const override
Get the footprint in memory in bytes.
void removeRow(size_t) override
Delets a row if it exists.
void find(const Mantid::Kernel::V3D &, size_t &, size_t) override
find method to get the index of Mantid::Kernel::V3D cell value in a table workspace
std::unique_ptr< TableWorkspaceTester > clone() const
Returns a clone of the workspace.
void find(const std::string &, size_t &, size_t) override
find method to get the index of cellstd::string value in a table workspace
const std::string id() const override
Return the workspace typeID.
LogManager_sptr logs() override
Get access to shared pointer containing workspace properties.
size_t columnCount() const override
Number of columns in the workspace.
TableWorkspaceTester * doCloneEmpty() const override
Virtual cloneEmpty method.
void setRowCount(size_t) override
Resizes the workspace.
void find(float, size_t &, size_t) override
find method to get the index of float cell value in a table workspace
void find(size_t, size_t &, size_t) override
find method to get the index of integer cell value in a table workspace
Column_sptr addColumn(const std::string &, const std::string &) override
Creates a new column.
ITableWorkspace * doCloneColumns(const std::vector< std::string > &) const override
size_t rowCount() const override
Number of rows in the workspace.
std::vector< std::string > getColumnNames() const override
Returns a vector of all column names.
Column_const_sptr getColumn(const std::string &) const override
Gets the shared pointer to a column by name.
size_t blocksize() const override
Returns the size of each block of data returned by the dataY accessors.
void init(const Mantid::HistogramData::Histogram &histogram) override
WorkspaceTester(const Mantid::Parallel::StorageMode storageMode=Mantid::Parallel::StorageMode::Cloned)
WorkspaceTester * doCloneEmpty() const override
Virtual cloneEmpty method.
std::unique_ptr< WorkspaceTester > cloneEmpty() const
Returns a default-initialized clone of the workspace.
void init(const size_t &numspec, const size_t &j, const size_t &k) override
std::unique_ptr< WorkspaceTester > clone() const
Returns a clone of the workspace.
WorkspaceTester * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
const std::string id() const override
A string ID for the class.
std::shared_ptr< const LogManager > LogManager_const_sptr
shared pointer to the logManager base class (const version)
std::shared_ptr< Column > Column_sptr
std::shared_ptr< LogManager > LogManager_sptr
shared pointer to the logManager base class
std::shared_ptr< const Column > Column_const_sptr
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
std::shared_ptr< MDHistoDimension > MDHistoDimension_sptr
Shared pointer to a MDHistoDimension.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
int32_t detid_t
Typedef for a detector ID.
double signal_t
Typedef for the signal recorded in a MDBox, etc.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
int32_t specnum_t
Typedef for a spectrum Number.
As TableColumn stores its data in a std::vector bool type cannot be used in the same way as the other...
Holds X, Y, E for a line plot.