changeset 6:0339eb694129 draft default tip

planemo upload for repository https://github.com/MaterialsGalaxy/larch-tools/tree/main/larch_plot commit 7f52c8654581d23a2acffc818e0c197cf8e04504
author muon-spectroscopy-computational-project
date Tue, 03 Sep 2024 11:51:45 +0000
parents 3584db5902b5
children
files common.py larch_plot.xml
diffstat 2 files changed, 35 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/common.py	Fri Aug 23 14:10:50 2024 +0000
+++ b/common.py	Tue Sep 03 11:51:45 2024 +0000
@@ -75,22 +75,22 @@
             bkg_parameters = None
 
     keys = (
-        ("e0", "e0", None),
-        ("pre1", "pre1", None),
-        ("pre2", "pre2", None),
-        ("norm1", "nor1", None),
-        ("norm2", "nor2", None),
-        ("nnorm", "nnorm", None),
-        ("make_flat", "flatten", None),
-        ("step", "step", None),
-        ("nvict", "nvict", None),
+        ("e0", ("e0"), None),
+        ("pre1", ("pre1"), None),
+        ("pre2", ("pre2"), None),
+        ("norm1", ("nor1"), None),
+        ("norm2", ("nor2"), None),
+        ("nnorm", ("nnorm"), None),
+        ("make_flat", ("flatten"), None),
+        ("step", ("step"), None),
+        ("nvict", ("nvict"), None),
     )
-    for key, parameters_key, default in keys:
+    for key, parameter_keys, default in keys:
         extract_attribute(
             merged_settings=merged_settings,
             key=key,
             parameters_group=bkg_parameters,
-            parameters_key=parameters_key,
+            parameter_keys=parameter_keys,
             default=default,
         )
 
@@ -125,19 +125,18 @@
         fft_parameters = None
 
     keys = (
-        ("kmin", "kmin", 0),
-        ("kmax", "kmax", 20),
-        ("dk", "dk", 1),
-        ("kweight", "kw", 2),
-        ("kweight", "kweight", 2),
-        ("window", "kwindow", "kaiser"),
+        ("kmin", ("kmin",), 0),
+        ("kmax", ("kmax",), 20),
+        ("dk", ("dk",), 1),
+        ("kweight", ("kw", "kweight"), 2),
+        ("window", ("kwindow",), "kaiser"),
     )
-    for key, parameters_key, default in keys:
+    for key, parameter_keys, default in keys:
         extract_attribute(
             merged_settings=merged_settings,
             key=key,
             parameters_group=fft_parameters,
-            parameters_key=parameters_key,
+            parameter_keys=parameter_keys,
             default=default,
         )
 
@@ -156,15 +155,26 @@
     merged_settings: dict,
     key: str,
     parameters_group: Group,
-    parameters_key: str,
+    parameter_keys: "tuple[str]",
     default: "str|int" = None,
 ):
     if parameters_group is not None:
-        try:
-            merged_settings[key] = getattr(parameters_group, parameters_key)
+        values = []
+        for parameter_key in parameter_keys:
+            try:
+                values.append(getattr(parameters_group, parameter_key))
+            except AttributeError:
+                pass
+
+        if len(values) > 1:
+            print(
+                f"WARNING: values {values} for for keys {parameter_keys}, "
+                "using first entry"
+            )
+
+        if len(values) > 0:
+            merged_settings[key] = values[0]
             return
-        except AttributeError:
-            pass
 
     if default is not None:
         merged_settings[key] = default
--- a/larch_plot.xml	Fri Aug 23 14:10:50 2024 +0000
+++ b/larch_plot.xml	Tue Sep 03 11:51:45 2024 +0000
@@ -4,7 +4,7 @@
         <!-- version of underlying tool (PEP 440) -->
         <token name="@TOOL_VERSION@">0.9.80</token>
         <!-- version of this tool wrapper (integer) -->
-        <token name="@WRAPPER_VERSION@">0</token>
+        <token name="@WRAPPER_VERSION@">1</token>
         <!-- citation should be updated with every underlying tool version -->
         <!-- typical fields to update are version, month, year, and doi -->
         <token name="@TOOL_CITATION@">10.1088/1742-6596/430/1/012007</token>