From d9461c123b852b33338f31f5ef0f9f8ecae1adde Mon Sep 17 00:00:00 2001 From: Seb James Date: Mon, 7 Oct 2024 11:43:06 +0100 Subject: [PATCH] Refactor Scale::compute_scaling_from for more clarity --- docs/ref/coremaths/scale.md | 4 ++-- examples/scale.cpp | 2 +- morph/Scale.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/ref/coremaths/scale.md b/docs/ref/coremaths/scale.md index 180aacba..3d0e36df 100644 --- a/docs/ref/coremaths/scale.md +++ b/docs/ref/coremaths/scale.md @@ -142,12 +142,12 @@ s.output_range.max = 5; s.compute_scaling (-10, 10); ``` -You can also trigger the computation of the scaling function if you have a container of data by using `compute_scaling_from`, which is the function that is automatically called by `transform` when `do_autoscale` is `true`. +You can also trigger the computation of the scaling function if you have a container of data by using `compute_scaling_from_data`, which is the function that is automatically called by `transform` when `do_autoscale` is `true`. ```c++ morph::Scale s; std::vector input_data = { 1, 2, 3, 6, 100 }; -s.compute_scaling_from (input_data); +s.compute_scaling_from_data (input_data); ``` ### Logarithmic scaling diff --git a/examples/scale.cpp b/examples/scale.cpp index 5da1b551..a0dfe206 100644 --- a/examples/scale.cpp +++ b/examples/scale.cpp @@ -45,7 +45,7 @@ int main() } // If you need to reset the scaling in s (our Scale object), then you can do this: - s.compute_scaling_from (vf2); // will immediately compute the scaling function from the container of values vf2. + s.compute_scaling_from_data (vf2); // will immediately compute the scaling function from the container of values vf2. // OR you can do this, which forces automatic scaling when s.transform() is next // called (as long as s.do_autoscale is true). diff --git a/morph/Scale.h b/morph/Scale.h index fc1a0e8e..7b1f0b64 100644 --- a/morph/Scale.h +++ b/morph/Scale.h @@ -157,7 +157,7 @@ namespace morph { throw std::runtime_error ("ScaleImplBase::transform(): Ensure data.size()==output.size()"); } if (this->do_autoscale == true && !this->ready()) { - this->compute_scaling_from (data); // not const + this->compute_scaling_from_data (data); // not const } else if (this->do_autoscale == false && !this->ready()) { throw std::runtime_error ("ScaleImplBase::transform(): Params are not set and do_autoscale is set false. Can't transform."); } @@ -221,7 +221,7 @@ namespace morph { */ template std::enable_if_t::value, void> - compute_scaling_from (const Container& data) + compute_scaling_from_data (const Container& data) { morph::range mm = MathAlgo::maxmin (data); this->compute_scaling (mm.min, mm.max);