[v2,2/2] utils: tuning: Change Tuner.add() to accept a list of modules
diff mbox series

Message ID 20240814094134.73333-3-stefan.klug@ideasonboard.com
State Accepted
Commit 53108b6ff1c5ea93bee9f8c5329c840e24f24a8d
Headers show
Series
  • Two small tuning script cleanups
Related show

Commit Message

Stefan Klug Aug. 14, 2024, 9:41 a.m. UTC
Change the first parameter of Tuner.add() to accept either a list of
modules or a single module. This allows more compact code and is in sync
with Tuner.set_output_order().

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 utils/tuning/libtuning/libtuning.py |  5 ++++-
 utils/tuning/rkisp1.py              | 10 +---------
 2 files changed, 5 insertions(+), 10 deletions(-)

Comments

Paul Elder Aug. 14, 2024, 10:52 a.m. UTC | #1
On Wed, Aug 14, 2024 at 11:41:31AM +0200, Stefan Klug wrote:
> Change the first parameter of Tuner.add() to accept either a list of
> modules or a single module. This allows more compact code and is in sync
> with Tuner.set_output_order().
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

\o/

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  utils/tuning/libtuning/libtuning.py |  5 ++++-
>  utils/tuning/rkisp1.py              | 10 +---------
>  2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py
> index e7c63535fefd..bac573235040 100644
> --- a/utils/tuning/libtuning/libtuning.py
> +++ b/utils/tuning/libtuning/libtuning.py
> @@ -95,7 +95,10 @@ class Tuner(object):
>          self.output = {}
>  
>      def add(self, module):
> -        self.modules.append(module)
> +        if isinstance(module, list):
> +            self.modules.extend(module)
> +        else:
> +            self.modules.append(module)
>  
>      def set_input_parser(self, parser):
>          self.parser = parser
> diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py
> index 5d7a69fc4a13..f5c42a61d15e 100755
> --- a/utils/tuning/rkisp1.py
> +++ b/utils/tuning/rkisp1.py
> @@ -45,15 +45,7 @@ lsc = LSCRkISP1(debug=[lt.Debug.Plot],
>                  smoothing_function=lt.smoothing.MedianBlur(3),)
>  
>  tuner = lt.Tuner('RkISP1')
> -tuner.add(agc)
> -tuner.add(awb)
> -tuner.add(blc)
> -tuner.add(ccm)
> -tuner.add(color_processing)
> -tuner.add(filter)
> -tuner.add(gamma_out)
> -tuner.add(lsc)
> -
> +tuner.add([agc, awb, blc, ccm, color_processing, filter, gamma_out, lsc])
>  tuner.set_input_parser(YamlParser())
>  tuner.set_output_formatter(YamlOutput())
>  tuner.set_output_order([agc, awb, blc, ccm, color_processing,
> -- 
> 2.43.0
>

Patch
diff mbox series

diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py
index e7c63535fefd..bac573235040 100644
--- a/utils/tuning/libtuning/libtuning.py
+++ b/utils/tuning/libtuning/libtuning.py
@@ -95,7 +95,10 @@  class Tuner(object):
         self.output = {}
 
     def add(self, module):
-        self.modules.append(module)
+        if isinstance(module, list):
+            self.modules.extend(module)
+        else:
+            self.modules.append(module)
 
     def set_input_parser(self, parser):
         self.parser = parser
diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py
index 5d7a69fc4a13..f5c42a61d15e 100755
--- a/utils/tuning/rkisp1.py
+++ b/utils/tuning/rkisp1.py
@@ -45,15 +45,7 @@  lsc = LSCRkISP1(debug=[lt.Debug.Plot],
                 smoothing_function=lt.smoothing.MedianBlur(3),)
 
 tuner = lt.Tuner('RkISP1')
-tuner.add(agc)
-tuner.add(awb)
-tuner.add(blc)
-tuner.add(ccm)
-tuner.add(color_processing)
-tuner.add(filter)
-tuner.add(gamma_out)
-tuner.add(lsc)
-
+tuner.add([agc, awb, blc, ccm, color_processing, filter, gamma_out, lsc])
 tuner.set_input_parser(YamlParser())
 tuner.set_output_formatter(YamlOutput())
 tuner.set_output_order([agc, awb, blc, ccm, color_processing,