1
0

feat: finish lut resolver

This commit is contained in:
2026-06-15 15:58:04 +08:00
parent 7721672b8e
commit ed8f5e1943
6 changed files with 312 additions and 238 deletions

View File

@@ -20,7 +20,9 @@ class Dataset:
# Check redundant parts
valueset = set(values)
if len(valueset) != len(values):
raise LcrConnException(f"Duplicate standard value")
raise LcrConnException(f"Duplicate item in standard value list")
if len(valueset) == 0:
raise LcrConnException(f"Empty standard value list is not allowed")
# Ok, assign it
self.__values = values
@@ -45,7 +47,8 @@ class Dataset:
legal_lines = filter(lambda line: line != "", (line.strip() for line in f))
return Dataset.from_iterable(legal_lines)
def get_values(self) -> tuple[float, ...]:
@property
def values(self) -> tuple[float, ...]:
"""
Get the available standard values
@@ -99,29 +102,32 @@ class DatasetCollection:
Dataset.from_file(inductor),
)
def get_resistor_values(self) -> tuple[float, ...]:
@property
def resistor_values(self) -> Dataset:
"""
Get the available standard values for resistor
:return: A tuple of available standard values for resistor
"""
return self.__resistor.get_values()
return self.__resistor
def get_capacitor_values(self) -> tuple[float, ...]:
@property
def capacitor_values(self) -> Dataset:
"""
Get the available standard values for capacitor
:return: A tuple of available standard values for capacitor
"""
return self.__capacitor.get_values()
return self.__capacitor
def get_inductor_values(self) -> tuple[float, ...]:
@property
def inductor_values(self) -> Dataset:
"""
Get the available standard values for inductor
:return: A tuple of available standard values for inductor
"""
return self.__inductor.get_values()
return self.__inductor
def from_human_readable_value(strl: str) -> float: