From 39e1bb50dcf663f61f14061a118a8581382e096e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Sun, 29 Mar 2020 23:02:03 +0200 Subject: [PATCH] fix: wrong SI units assigend to fit results parameters --- CHANGELOG | 1 + pyjibe/fd/tab_fit.py | 12 ++++++------ pyjibe/units.py | 4 ++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cc02176..9e1c103 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 0.7.1 + - fix: wrong SI units assigend to fit results parameters - setup: bump afmformats from 0.9.0 to 0.10.0 (new formats: JPK (.jpk-qi-data), AFM workshop (.csv), NT-MDT (.txt exported by Nova)) diff --git a/pyjibe/fd/tab_fit.py b/pyjibe/fd/tab_fit.py index d2a4a1c..a12f7c6 100644 --- a/pyjibe/fd/tab_fit.py +++ b/pyjibe/fd/tab_fit.py @@ -220,10 +220,10 @@ def fit_approach_retract(self, fdist, update_ui=True): read_only=True) for ii, p in enumerate(varps): # Get the human readable name of the parameter - name = self.fit_model.parameter_keys.index(p.name) - hrname = self.fit_model.parameter_names[name] + idp = self.fit_model.parameter_keys.index(p.name) + hrname = self.fit_model.parameter_names[idp] # SI unit - si_unit = self.fit_model.parameter_units[ii] + si_unit = self.fit_model.parameter_units[idp] # Determine unit scale, e.g. 1e6 [sic] for µm scale = units.hrscale(hrname, si_unit=si_unit) label = units.hrscname(hrname, si_unit=si_unit) @@ -237,9 +237,9 @@ def fit_approach_retract(self, fdist, update_ui=True): read_only=True) for ii, p in enumerate(varps): # Get the human readable name of the parameter - name = self.fit_model.parameter_keys.index(p.name) - hrname = self.fit_model.parameter_names[name] - si_unit = self.fit_model.parameter_units[ii] + idp = self.fit_model.parameter_keys.index(p.name) + hrname = self.fit_model.parameter_names[idp] + si_unit = self.fit_model.parameter_units[idp] label = units.hrscname(hrname, si_unit=si_unit) ftab.verticalHeaderItem(ii).setText(label) ftab.item(ii, 0).setText("nan") diff --git a/pyjibe/units.py b/pyjibe/units.py index e068c66..a2c7f12 100644 --- a/pyjibe/units.py +++ b/pyjibe/units.py @@ -59,6 +59,10 @@ def hrunit(name, si_unit=None): if name in human_units: scalename, unit = human_units[name] scaleunit = scalename + unit + if si_unit is not None and si_unit != unit: + raise ValueError( + "Bad `si_unit` '{}' given for '{}', expected '{}'! ".format( + si_unit, name, unit)) elif si_unit in default_scales: scaleunit = default_scales[si_unit] + si_unit elif si_unit is not None: