remove LazyImport

Change-Id: Ia78bd812fd6d890afcdfeb52fc9847a09992a49b
This commit is contained in:
2026-02-25 17:32:06 +01:00
parent 01e429dcb0
commit 22ff23bdb7
2 changed files with 13 additions and 23 deletions
-12
View File
@@ -492,15 +492,3 @@ def delayed_import(modname):
except Exception:
return _Raiser(modname)
return module
class LazyImport:
module = None
def __init__(self, modulename):
self.modulename = modulename
def __getattr__(self, name):
if self.module is None:
self.module = __import__(self.modulename)
return getattr(self.module, name)
+13 -11
View File
@@ -22,6 +22,8 @@ import time
import math
import random
import threading
import numpy as np
from numpy.testing import assert_approx_equal
from frappy.core import Module, Readable, Parameter, Property, \
HasIO, StringIO, Writable, IDLE, ERROR, BUSY, DISABLED, nopoll, Attached
@@ -30,15 +32,12 @@ from frappy.datatypes import IntRange, FloatRange, StringType, \
from frappy.errors import CommunicationFailedError, ConfigError, \
HardwareError, DisabledError, ImpossibleError, secop_error, SECoPError
from frappy.lib.units import NumberWithUnit, format_with_unit
from frappy.lib import formatStatusBits, LazyImport
from frappy.lib import formatStatusBits
from frappy_psi.calcurve import CalCurve
from frappy_psi.convergence import HasConvergence
from frappy.mixins import HasOutputModule, HasControlledBy
from frappy.extparams import StructParam
np = LazyImport('numpy')
np_testing = LazyImport('numpy.testing')
calcurve_module = LazyImport('frappy_psi.calcurve')
def string_to_num(string):
try:
@@ -420,7 +419,7 @@ class Device(HasLscIO, Module):
"""check whether a returned calibration point is equal within curve point precision"""
for v1, v2, eps in zip(left, right, fixeps):
try:
np_testing.assert_approx_equal(v1, v2, significant, verbose=False)
assert_approx_equal(v1, v2, significant, verbose=False)
except AssertionError:
return abs(v1 - v2) < eps
return True
@@ -465,7 +464,7 @@ class CurveRequest:
self.action = device.find_curve
self.new_sensors = set()
self.sensors = {sensor.channel: sensor}
calcurve = calcurve_module.CalCurve(sensor.calcurve)
calcurve = CalCurve(sensor.calcurve)
equipment_id = device.propertyValues.get('original_id') or device.secNode.equipment_id
name = f"{equipment_id.split('.')[0]}.{sensor.name}"
sn = calcurve.calibname
@@ -613,16 +612,19 @@ class Sensor(Base, Readable):
@nopoll
def read_value(self):
self.status, value, self.raw = self.get_data()
self.status, value, raw = self.get_data()
if isinstance(value, SECoPError):
raise value.copy()
raise value
if not isinstance(raw, SECoPError):
self.raw = raw
return value
@nopoll
def read_raw(self):
self.status, self.value, raw = self.get_data()
self.status, value, raw = self.get_data()
if isinstance(raw, SECoPError):
raise raw.copy()
raise raw
self.value = value
return raw
def read_status(self):