From c6d32e79228f777eae080561cf38e351946856e6 Mon Sep 17 00:00:00 2001 From: Hantao Cui Date: Wed, 26 Jul 2023 17:58:18 +0000 Subject: [PATCH 1/7] Add curly brackets for LaTeX symbols from sub-blocks. --- andes/core/discrete.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/andes/core/discrete.py b/andes/core/discrete.py index 07c4d403b..e285565cd 100644 --- a/andes/core/discrete.py +++ b/andes/core/discrete.py @@ -111,7 +111,7 @@ def get_tex_names(self): A list of tex_names for all exported flags. """ - return [rf'{flag_tex}^{self.tex_name}' for flag_tex in self.export_flags_tex] + return [rf'{flag_tex}^{{{self.tex_name}}}' for flag_tex in self.export_flags_tex] def get_values(self): return [self.__dict__[flag] for flag in self.export_flags] From 39e325d78863912bb9d99115bf3fce71b72e2847 Mon Sep 17 00:00:00 2001 From: Hantao Cui Date: Wed, 26 Jul 2023 17:58:53 +0000 Subject: [PATCH 2/7] Fix a bug in processing tex names of discrete flags. --- andes/core/symprocessor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/andes/core/symprocessor.py b/andes/core/symprocessor.py index 7405c3568..8c54314dc 100644 --- a/andes/core/symprocessor.py +++ b/andes/core/symprocessor.py @@ -112,9 +112,10 @@ def generate_symbols(self): # ----------------------------------------------------------- for key in self.parent.tex_names.keys(): self.tex_names[key] = sp.Symbol(self.parent.tex_names[key]) + for instance in self.parent.discrete.values(): for name, tex_name in zip(instance.get_names(), instance.get_tex_names()): - self.tex_names[name] = tex_name + self.tex_names[name] = sp.Symbol(tex_name) # ----------------------------------------------------------- for var in self.cache.all_params_names: From ed0619853c438bf899e48532742a6398790249f1 Mon Sep 17 00:00:00 2001 From: Hantao Cui Date: Thu, 10 Aug 2023 09:33:05 -0500 Subject: [PATCH 3/7] Inclusion of Jumper in connectivity check. --- andes/system.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/andes/system.py b/andes/system.py index d5c69864e..26fd85d2f 100644 --- a/andes/system.py +++ b/andes/system.py @@ -1221,6 +1221,11 @@ def connectivity(self, info=True): to.extend(self.Line.a2.a.tolist()) u.extend(self.Line.u.v.tolist()) + # collect from Jumper + fr.extend(self.Jumper.a1.a.tolist()) + to.extend(self.Jumper.a2.a.tolist()) + u.extend(self.Jumper.u.v.tolist()) + # collect from Fortescue fr.extend(self.Fortescue.a.a.tolist()) to.extend(self.Fortescue.aa.a.tolist()) From af9e4e6a34b477610f0b85cafea9492a2abd3d09 Mon Sep 17 00:00:00 2001 From: Hantao Cui Date: Thu, 10 Aug 2023 09:39:07 -0500 Subject: [PATCH 4/7] Improve error message for missing mandatory parameters. --- andes/core/param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/andes/core/param.py b/andes/core/param.py index fb6853c8d..eb3ba9716 100644 --- a/andes/core/param.py +++ b/andes/core/param.py @@ -177,7 +177,7 @@ def _sanitize(self, value): # check for mandatory if value is None: if self.get_property('mandatory'): - raise ValueError(f'Mandatory parameter {self.name} for {self.owner.class_name} missing') + raise ValueError(f'Mandatory parameter {self.owner.class_name}.{self.name} is missing') else: value = self.default From 0289e0017079d4e16f728e14a0d5af6f02b85b24 Mon Sep 17 00:00:00 2001 From: Hantao Cui Date: Thu, 10 Aug 2023 12:11:55 -0500 Subject: [PATCH 5/7] The xlsx parser no longer assume column 0 as the index column. It allows sheets without `uid` to be parsed correctly. --- andes/core/model/modeldata.py | 2 ++ andes/io/xlsx.py | 2 +- andes/system.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/andes/core/model/modeldata.py b/andes/core/model/modeldata.py index 7e5d51c05..29b21308f 100644 --- a/andes/core/model/modeldata.py +++ b/andes/core/model/modeldata.py @@ -176,6 +176,8 @@ def as_dict(self, vin=False): An additional `uid` key is added with the value default to range(n). """ out = dict() + + # append 0-indexed `uid` out['uid'] = np.arange(self.n) for name, instance in self.params.items(): diff --git a/andes/io/xlsx.py b/andes/io/xlsx.py index 9603a3ea8..6c781ceb9 100644 --- a/andes/io/xlsx.py +++ b/andes/io/xlsx.py @@ -103,7 +103,7 @@ def read(system, infile): """ df_models = pd.read_excel(infile, sheet_name=None, - index_col=0, + index_col=None, engine='openpyxl', ) diff --git a/andes/system.py b/andes/system.py index 26fd85d2f..973b17fbd 100644 --- a/andes/system.py +++ b/andes/system.py @@ -549,6 +549,9 @@ def add(self, model, param_dict=None, **kwargs): if kwargs is not None: param_dict.update(kwargs) + # remove `uid` field + param_dict.pop('uid', None) + idx = param_dict.pop('idx', None) if idx is not None and (not isinstance(idx, str) and np.isnan(idx)): idx = None From eb977176de929e59f750dc7ea87a9ce4e42d37a3 Mon Sep 17 00:00:00 2001 From: Hantao Cui Date: Thu, 10 Aug 2023 12:46:21 -0500 Subject: [PATCH 6/7] Update. --- docs/source/release-notes.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/source/release-notes.rst b/docs/source/release-notes.rst index f2abb4db3..3b65c165f 100644 --- a/docs/source/release-notes.rst +++ b/docs/source/release-notes.rst @@ -9,6 +9,16 @@ The APIs before v3.0.0 are in beta and may change without prior notice. v1.8 Notes ========== +v1.8.10 (2023-08-10) +-------------------- +- An internal change to the xlsx parser option. Previously, the index column was + set to 0, which assumes the existence of `uid` as the header. Manually input + sheets without `uid` will fail. This version unsets the index column when + using pandas to parse the xlsx file. +- `Jumper` is included for connectivity check. +- Add curly brackets for LaTeX symbols from sub-blocks. Nested symbols with + subscripts and superscripts now display properly. + v1.8.9 (2023-06-22) ------------------- - Fix `Model.alter()` for parameters that are time constants for differential From 9c8f6eda4f654bbaba8e770744d6c0239af046d9 Mon Sep 17 00:00:00 2001 From: Hantao Cui Date: Thu, 10 Aug 2023 12:47:20 -0500 Subject: [PATCH 7/7] Improve description of `save_every`. --- andes/routines/tds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/andes/routines/tds.py b/andes/routines/tds.py index 329ecdf1a..9f29ad699 100644 --- a/andes/routines/tds.py +++ b/andes/routines/tds.py @@ -84,7 +84,7 @@ def __init__(self, system=None, config=None): store_i='store RHS of external algeb. equations', limit_store='limit in-memory timeseries storage', max_store='maximum steps of data stored in memory before offloading', - save_every='save results for one step every "save_every" steps', + save_every='save one step to memory every N simulation steps', save_mode='automatically or manually save output data when done', no_tqdm='disable tqdm progressbar and outputs', chatter_iter='minimum iterations to detect chattering',