From 23e156856841d0894fb840a1175e48607eb6c7ce Mon Sep 17 00:00:00 2001
From: Jibril Mammeri <jibril.mammeri@esrf.fr>
Date: Tue, 4 Mar 2025 16:39:34 +0100
Subject: [PATCH] Remove from_value

---
 tomoscan/esrf/scan/nxtomoscan.py | 2 +-
 tomoscan/scanbase.py             | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tomoscan/esrf/scan/nxtomoscan.py b/tomoscan/esrf/scan/nxtomoscan.py
index 26b1b61e..931dfde6 100644
--- a/tomoscan/esrf/scan/nxtomoscan.py
+++ b/tomoscan/esrf/scan/nxtomoscan.py
@@ -1345,7 +1345,7 @@ class NXtomoScan(TomoScanBase):
         # handle Diamond dataset where unit is stored as bytes
         if hasattr(unit, "decode"):
             unit = unit.decode()
-        return value * default_unit.from_value(unit).value
+        return value * default_unit(unit)
 
     def _check_hdf5scan_validity(self):
         """some basic check to make sure both the master file (.nx file) and requested entry (data_path) exists"""
diff --git a/tomoscan/scanbase.py b/tomoscan/scanbase.py
index 7add1894..9a0a6235 100644
--- a/tomoscan/scanbase.py
+++ b/tomoscan/scanbase.py
@@ -365,7 +365,7 @@ class TomoScanBase(TomoObject):
 
     def get_pixel_size(self, unit="m") -> float | None:
         if self.pixel_size:
-            return self.pixel_size / MetricSystem.from_value(unit).value
+            return self.pixel_size / MetricSystem(unit)
         else:
             return None
 
@@ -471,7 +471,7 @@ class TomoScanBase(TomoObject):
         :return: sample / detector distance with the requested unit
         """
         if self.sample_detector_distance:
-            return self.distance / MetricSystem.from_value(unit).value
+            return self.distance / MetricSystem(unit)
         else:
             return None
 
-- 
GitLab