diff --git a/src/scgenerator/__init__.py b/src/scgenerator/__init__.py index d5e5c7b..4c9e73d 100644 --- a/src/scgenerator/__init__.py +++ b/src/scgenerator/__init__.py @@ -4,5 +4,5 @@ from .physics import fiber, materials, pulse, simulate, units from .physics.simulate import RK4IP, parallel_RK4IP, run_simulation from .plotting import mean_values_plot, plot_spectrogram, propagation_plot, single_position_plot from .spectra import Pulse, Spectrum -from .utils import Paths, open_config +from .utils import Paths, open_config, parameter from .utils.parameter import Configuration, Parameters, PlotRange diff --git a/src/scgenerator/utils/__init__.py b/src/scgenerator/utils/__init__.py index b3296ac..9ca5ac3 100644 --- a/src/scgenerator/utils/__init__.py +++ b/src/scgenerator/utils/__init__.py @@ -116,7 +116,7 @@ def open_config(path: os.PathLike): dico.setdefault("variable", {}) for key in {"simulation", "fiber", "gas", "pulse"} & dico.keys(): - section = dico.pop(key, {}) + section = dico.pop(key) dico["variable"].update(section.pop("variable", {})) dico.update(section) if len(dico["variable"]) == 0: diff --git a/src/scgenerator/utils/parameter.py b/src/scgenerator/utils/parameter.py index 53bb8b5..6822aa7 100644 --- a/src/scgenerator/utils/parameter.py +++ b/src/scgenerator/utils/parameter.py @@ -1227,11 +1227,21 @@ def format_variable_list(l: list[tuple[str, Any]], add_iden=False) -> str: tmp_name = PARAM_SEPARATOR.join(str_list) if not add_iden: return tmp_name - unique_id = "u_" + utils.to_62(hash(str(l))) - branch_id = "b_" + utils.to_62(hash(str([el for el in l if el[0] != "num"]))) + unique_id = unique_identifier(l) + branch_id = branch_identifier(l) return unique_id + PARAM_SEPARATOR + branch_id + PARAM_SEPARATOR + tmp_name +def branch_identifier(l): + branch_id = "b_" + utils.to_62(hash(str([el for el in l if el[0] != "num"]))) + return branch_id + + +def unique_identifier(l): + unique_id = "u_" + utils.to_62(hash(str(l))) + return unique_id + + def format_value(name: str, value) -> str: if value is True or value is False: return str(value)