Skip to content
Snippets Groups Projects
Commit c69f5c29 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Histogram2D: template -> regular

parent 3ecd7694
No related branches found
No related tags found
1 merge request!237ArrayUtils now w/o templates
......@@ -44,6 +44,20 @@ Histogram2D::Histogram2D(std::vector<std::vector<double>> data)
this->setContent(data);
}
void Histogram2D::initFromShape(const std::vector<std::vector<double>>& data)
{
auto shape = DataUtils::Array::getShape(data);
const size_t nrows = shape.first;
const size_t ncols = shape.second;
if (nrows == 0 || ncols == 0)
throw std::runtime_error("Histogram2D::Histogram2D() -> Error. "
"Not a two-dimensional numpy array");
m_data.addAxis(FixedBinAxis("x-axis", ncols, 0.0, static_cast<double>(ncols)));
m_data.addAxis(FixedBinAxis("y-axis", nrows, 0.0, static_cast<double>(nrows)));
}
Histogram2D* Histogram2D::clone() const
{
return new Histogram2D(*this);
......
......@@ -100,7 +100,7 @@ public:
void addContent(const std::vector<std::vector<double>>& data);
protected:
template <typename T> void initFromShape(const T& data);
void initFromShape(const std::vector<std::vector<double>>& data);
//! Creates projection along X. The projections is made by collecting the data in the range
//! between [ybinlow, ybinup].
......@@ -111,18 +111,4 @@ protected:
Histogram1D* create_projectionY(int xbinlow, int xbinup);
};
template <typename T> void Histogram2D::initFromShape(const T& data)
{
auto shape = DataUtils::Array::getShape(data);
const size_t nrows = shape.first;
const size_t ncols = shape.second;
if (nrows == 0 || ncols == 0)
throw std::runtime_error("Histogram2D::Histogram2D() -> Error. "
"Not a two-dimensional numpy array");
m_data.addAxis(FixedBinAxis("x-axis", ncols, 0.0, static_cast<double>(ncols)));
m_data.addAxis(FixedBinAxis("y-axis", nrows, 0.0, static_cast<double>(nrows)));
}
#endif // BORNAGAIN_DEVICE_HISTO_HISTOGRAM2D_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment