58 auto result = std::lower_bound(begin,
m_coordinates.end(), value);
59 size_t index =
static_cast<size_t>(std::distance(begin, result));
65 std::vector<double> result;
67 result.reserve(v_size + 1);
68 for (
size_t i = 0; i < v_size; ++i)
77 throw std::runtime_error(
"Error in PointwiseAxis::createClippedAxis: "
78 "'left' should be smaller than 'right'");
80 using diff_t = std::vector<double>::iterator::difference_type;
89 std::ostringstream result;
90 const std::string py_def_call =
"numpy.asarray([";
91 const size_t total_offset = offset + py_def_call.size();
92 result << py_def_call;
94 for (
auto iter = points.begin(); iter != points.end() - 1; ++iter) {
104 auto precision = std::setprecision(std::numeric_limits<double>::digits10 + 2);
105 ostr <<
"PointwiseAxis(\"" <<
getName() <<
"\", "
107 for (
size_t i = 0, fin =
m_coordinates.size() - 1; i < fin; ++i)
139 std::string message =
"Error in PointwiseAxis::getBinCenter: passed index ";
140 message += std::to_string(index) +
" exceeds the size ";
141 message += std::to_string(
m_coordinates.size()) +
" of the axis";
142 throw std::runtime_error(message);
148 throw std::runtime_error(
149 "Error in PointwiseAxis::PointwiseAxis: the size of passed coordinate array is "
150 "less than minimum acceptable value");
155 if (!std::is_sorted(begin, end))
156 throw std::runtime_error(
"Error in PointwiseAxis::PointwiseAxis: passed coordinates are "
157 "not sorted in ascending order");
159 if (std::adjacent_find(begin, end) != end)
160 throw std::runtime_error(
"Error in PointwiseAxis::PointwiseAxis: passed coordinate vector "
161 "contains repeating values");
const size_t min_axis_size
Defines class PointwiseAxis.
Defines functions in namespace pyfmt.
Interface for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string getName() const
retrieve the label of the axis
Axis containing arbitrary (non-equidistant) coordinate values.
double upperBoundary(size_t index) const
double lowerBoundary(size_t index) const
PointwiseAxis(String &&name, Vector &&coordinate_values)
Bin1D getBin(size_t index) const override
retrieve a 1d bin for the given index
PointwiseAxis * clone() const override
clone function
std::vector< double > getBinCenters() const override
void checkIndex(size_t index) const
double getBinCenter(size_t index) const override
Returns the coordinate corresponding to the given index.
std::vector< double > m_coordinates
PointwiseAxis * createClippedAxis(double left, double right) const override
Creates a new clipped axis.
std::string pyString(const std::string &units, size_t offset) const final
std::vector< double > getBinBoundaries() const override
double getMax() const override
Returns value of last on-axis point.
size_t findClosestIndex(double value) const override
find index of the coordinate closest to the given value
double getMin() const override
Returns value of first on-axis point.
bool equals(const IAxis &other) const override
void print(std::ostream &ostr) const override
std::string indent(size_t width)
Returns a string of blanks with given width.
std::string printValue(double value, const std::string &units)