1
0

fix: fix legacy error

This commit is contained in:
2026-06-16 22:37:05 +08:00
parent a27c5505df
commit a26116e5e9
4 changed files with 22 additions and 9 deletions

View File

@@ -1,3 +1,5 @@
# LCR Connector (Legacy)
在3个元器件内使用给定元器件数值列表快速找到目标数值元器件的最好拼接方式支持电阻电容电感
执行`uv run lcr-connector --help`来查阅参数手册。

View File

@@ -177,12 +177,15 @@ class App:
# fetch item and print it
item = response[index]
print(
"Plan {0}\t{1}\t{2:.2%}".format(
"Plan {0}\tValue: {1}\tDiff: {2} ({3:.2%})".format(
index + 1,
to_human_readable_value(item.value),
to_human_readable_value(item.difference),
item.relative_difference,
)
)
self.__illustrate_circuit(item.circuit)
# print page footer
print("")
print("Page {} of {}.".format(current_page + 1, all_page + 1))
@@ -204,15 +207,19 @@ class App:
:return: The command. It is an instance of `cmd_enum`.
"""
while True:
print("> ", end=None)
words = input()
words = words.strip()
if words in cmd_enum:
self.__show_prompt_arrow()
words = input().strip()
if words == "":
continue
try:
return cmd_enum(words)
print("Unknown command, please try again.")
except ValueError:
print("Unknown command, please try again.")
def __accept_device_value(self) -> float:
while True:
self.__show_prompt_arrow()
words = input()
value = self.__parse_human_readable_value(words)
if value is None:
@@ -222,6 +229,7 @@ class App:
def __accept_device_value_tolerance(self, target_value: float) -> float:
while True:
self.__show_prompt_arrow()
words = input()
if words.endswith("%"):
@@ -238,6 +246,9 @@ class App:
else:
return value
def __show_prompt_arrow(self) -> None:
print("> ", end="")
def __parse_plain_float(
self, user_value: str, checker: Callable[[float], bool]
) -> float | None:

View File

@@ -184,7 +184,7 @@ def WriteBoolean(fs, num):
def OutputAsHuman(v):
if v / 1e-12 < 1e3:
return "{:e} n".format(v / 1e-12)
return "{:.4f} n".format(v / 1e-12)
if v / 1e-9 < 1e3:
return "{:.4f} p".format(v / 1e-9)
if v / 1e-6 < 1e3:

View File

@@ -60,7 +60,7 @@ class ResponseItem:
:return: The circuit.
"""
return self.circuit
return self.__circuit
@cached_property
def device_count(self) -> int:
@@ -69,7 +69,7 @@ class ResponseItem:
:return: The device count.
"""
return self.circuit.device_scale.to_device_count()
return self.__circuit.device_scale.to_device_count()
@cached_property
def value(self) -> float: