feat: add preset for dataset
This commit is contained in:
@@ -72,6 +72,83 @@ class Dataset:
|
||||
legal_lines = filter(lambda line: line != "", (line.strip() for line in f))
|
||||
return Dataset.from_iterable(legal_lines)
|
||||
|
||||
@staticmethod
|
||||
def resistor_preset() -> "Dataset":
|
||||
return Dataset.from_iterable(
|
||||
(
|
||||
"100",
|
||||
"220",
|
||||
"270",
|
||||
"390",
|
||||
"470",
|
||||
"680",
|
||||
"1k",
|
||||
"1.2k",
|
||||
"1.5k",
|
||||
"2.2k",
|
||||
"3.3k",
|
||||
"4.7k",
|
||||
"6.8k",
|
||||
"10k",
|
||||
"47k",
|
||||
"100k",
|
||||
"1M",
|
||||
)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def capacitor_preset() -> "Dataset":
|
||||
return Dataset.from_iterable(
|
||||
(
|
||||
"10p",
|
||||
"22p",
|
||||
"33p",
|
||||
"47p",
|
||||
"68p",
|
||||
"100p",
|
||||
"150p",
|
||||
"220p",
|
||||
"330p",
|
||||
"470p",
|
||||
"560p",
|
||||
"1u",
|
||||
"2.2u",
|
||||
"3.3u",
|
||||
"4.7u",
|
||||
"10u",
|
||||
"22u",
|
||||
"47u",
|
||||
"100u",
|
||||
"220u",
|
||||
"470u",
|
||||
)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def inductor_preset() -> "Dataset":
|
||||
return Dataset.from_iterable(
|
||||
(
|
||||
"0.1u",
|
||||
"0.15u",
|
||||
"0.47u",
|
||||
"0.68u",
|
||||
"1u",
|
||||
"1.5u",
|
||||
"2.2u",
|
||||
"3.3u",
|
||||
"4.7u",
|
||||
"6.8u",
|
||||
"8.2u",
|
||||
"10u",
|
||||
"15u",
|
||||
"22u",
|
||||
"33u",
|
||||
"47u",
|
||||
"68u",
|
||||
"100u",
|
||||
)
|
||||
)
|
||||
|
||||
def __save(self) -> Iterator[str]:
|
||||
return map(lambda i: i.str_value, self.__values)
|
||||
|
||||
@@ -164,6 +241,14 @@ class DatasetCollection:
|
||||
Dataset.from_file(inductor),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def devices_preset() -> "DatasetCollection":
|
||||
return DatasetCollection(
|
||||
Dataset.resistor_preset(),
|
||||
Dataset.capacitor_preset(),
|
||||
Dataset.inductor_preset(),
|
||||
)
|
||||
|
||||
def save_iterator(self) -> tuple[Iterator[str], Iterator[str], Iterator[str]]:
|
||||
"""
|
||||
Get the iterator of available standard values for resistor, capacitor and inductor respectively.
|
||||
|
||||
Reference in New Issue
Block a user