From bb9fa7d38a12cfab85ecdeeb86183ed07c2f0c0d Mon Sep 17 00:00:00 2001 From: ndaelman Date: Mon, 16 Sep 2024 17:31:28 +0200 Subject: [PATCH 1/2] Handle cases where Jacob's Ladder's is or --- src/nomad_simulations/schema_packages/model_method.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nomad_simulations/schema_packages/model_method.py b/src/nomad_simulations/schema_packages/model_method.py index 36822191..e2879aa5 100644 --- a/src/nomad_simulations/schema_packages/model_method.py +++ b/src/nomad_simulations/schema_packages/model_method.py @@ -352,6 +352,9 @@ def resolve_jacobs_ladder( highest_rung_abbrev = max(abbrevs, key=lambda x: rung_order[x]) except KeyError: return 'unavailable' + except (ValueError, TypeError): + if not abbrevs: + return 'unavailable' return self._jacobs_ladder_map.get(highest_rung_abbrev, 'unavailable') def resolve_exact_exchange_mixing_factor( From d39ddcb4d7d665fb7335a0f3fcd1ecfe9341b084 Mon Sep 17 00:00:00 2001 From: ndaelman Date: Mon, 16 Sep 2024 17:58:49 +0200 Subject: [PATCH 2/2] Move paqtch into definition `highest_rung_abbrev` --- src/nomad_simulations/schema_packages/model_method.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/nomad_simulations/schema_packages/model_method.py b/src/nomad_simulations/schema_packages/model_method.py index e2879aa5..2ef35b89 100644 --- a/src/nomad_simulations/schema_packages/model_method.py +++ b/src/nomad_simulations/schema_packages/model_method.py @@ -202,7 +202,7 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: self.libxc_name = libxc_name_weight + self.libxc_name # ! check with @ndaelman-hu if this makes sense (COMMENTED OUT FOR NOW) - # Appending `"+alpha"` in `libxc_name` for hybrids in which the `exact_exchange_mixing_factoris` included + # Appending `"+alpha"` in `libxc_name` for hybrids in which the `exact_exchange_mixing_factor` is included # libxc_name_alpha = '' # if ( # self.name == 'hybrid' @@ -349,12 +349,11 @@ def resolve_jacobs_ladder( continue try: - highest_rung_abbrev = max(abbrevs, key=lambda x: rung_order[x]) + highest_rung_abbrev = ( + max(abbrevs, key=lambda x: rung_order[x]) if abbrevs else None + ) except KeyError: return 'unavailable' - except (ValueError, TypeError): - if not abbrevs: - return 'unavailable' return self._jacobs_ladder_map.get(highest_rung_abbrev, 'unavailable') def resolve_exact_exchange_mixing_factor(