Skip to content
Snippets Groups Projects
Commit 6a958ef6 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

rm code duplication from crop()

parent 7e42e655
No related branches found
No related tags found
1 merge request!2416Add `angularFrame `and `qSpaceFrame` to Frame Python API
...@@ -285,19 +285,15 @@ Datafield* Datafield::crop(double xmin, double ymin, double xmax, double ymax) c ...@@ -285,19 +285,15 @@ Datafield* Datafield::crop(double xmin, double ymin, double xmax, double ymax) c
out[iout++] = m_values[i]; out[iout++] = m_values[i];
} }
return new Datafield(frame().clone(), out); return new Datafield(frame().clone(), out);
ASSERT(rank() == 2);
} }
Datafield* Datafield::crop(double xmin, double xmax) const Datafield* Datafield::crop(double xmin, double xmax) const
{ {
ASSERT(rank() == 1); ASSERT(rank() == 1);
std::vector<Bin1D> outbins;
for (size_t i = 0; i < xAxis().size(); ++i) {
const double x = xAxis().binCenter(i);
if (xmin <= x && x <= xmax)
outbins.push_back(xAxis().bin(i));
}
auto* xclipped = new Scale(xAxis().axisLabel(), outbins); Scale* xclipped = xAxis().clipped(xmin, xmax).clone();
const size_t N = size(); const size_t N = size();
std::vector<double> out; std::vector<double> out;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment