Skip to content

Commit

Permalink
Important bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
annndruha committed Dec 29, 2023
1 parent 2aa24ee commit 35eef77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# ivc-circuit-detector [IN DEVELOPMENT]

Этот модуль предназначен для распознавания эквивалентной цепи по ВАХ.
Этот модуль предназначен для распознавания эквивалентной цепи по ВАХ. (Ещё не готов)

Пошаговые инструкции располагаются в папке [./docs](./docs)

Предполагается что модуль должен использоваться как сторонний в других проектах, однако в нём должно быть всё для воспроизводимости моделей, которые используются для распознавания.

Пошаговые инструкции располагаются в папке [./docs](./docs)
19 changes: 15 additions & 4 deletions generate_dataset/parameters_changer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def _generate_circuit_with_params_set(self, named_param_sets):
self.generated_circuits.append(self._params_set_to_circuit(named_param_set))

def _params_set_to_circuit(self, params_set):
"""
Make from params-dict circuit with this params.
:param params_set:
:return:
"""
circuit = self.base_circuit.clone() # TODO: Fix clone without change PySpice
for el_name, el_params in params_set.items():
# Some crutch or define what element has DeviceModel and what hasn't
Expand Down Expand Up @@ -109,19 +114,22 @@ def _get_params_sets(existed_elements):
_all_intervals = []
params_keys = []

# Create a list of intervals lists
# Get all params intervals. Make list of intervals lists (need for itertools.product)
for k, params in existed_elements.items():
for i, param in enumerate(params):
_all_intervals.append(param['interval'])
params_keys.append({k: param})
clean_param = copy.deepcopy(param)
del clean_param['interval']
del clean_param['nominal']
params_keys.append({k: clean_param})

# Generate all possible params combinations
params_sets = list(itertools.product(*_all_intervals))

# Create a named params dict from every combination
# Create a named params dict for every combination
named_param_sets = []
for params_set in params_sets:
named_param_set = list(params_keys.copy())
named_param_set = copy.deepcopy(params_keys)
for i, param_value in enumerate(params_set):
named_param_set[i][tuple(named_param_set[i].keys())[0]]['value'] = param_value

Expand All @@ -137,6 +145,7 @@ def _get_params_sets(existed_elements):
return named_param_sets

def _find_variate_parameters(self):
# Find parameters variation settings for every element in schema
elem_names = [x for x in list(self.base_circuit.element_names) if x not in ['Print', 'print']]
existed_elements = {}
for elem_name in elem_names:
Expand All @@ -147,13 +156,15 @@ def _find_variate_parameters(self):
return existed_elements

def _generate_intervals(self, existed_elements):
# See _description_to_interval_points
for k, params in existed_elements.items():
for i, param in enumerate(params):
existed_elements[k][i]['interval'] = self._description_to_interval_points(param['nominal'])
return existed_elements

@staticmethod
def _description_to_interval_points(nominal):
# Make from interval description interval with points itself
if nominal['type'] == 'constant':
return [nominal['value']]
elif nominal['type'] == 'uniform_interval':
Expand Down

0 comments on commit 35eef77

Please sign in to comment.