From b776565021393ee2dc7bec7892421b4ff85a73b1 Mon Sep 17 00:00:00 2001 From: ndaelman Date: Wed, 16 Oct 2024 15:03:06 +0200 Subject: [PATCH] Add error raising to `BaseElectronicEigenvalues.n_bands` --- .../schema_packages/properties/band_structure.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nomad_simulations/schema_packages/properties/band_structure.py b/src/nomad_simulations/schema_packages/properties/band_structure.py index c5e169b0..4edc42cd 100644 --- a/src/nomad_simulations/schema_packages/properties/band_structure.py +++ b/src/nomad_simulations/schema_packages/properties/band_structure.py @@ -27,7 +27,7 @@ class BaseElectronicEigenvalues(PhysicalProperty): """ - A base section used to define basic quantities for the `ElectronicEigenvalues` and `ElectronicBandStructure` properties. + A base section used to define basic quantities for the `ElectronicEigenvalues` and `ElectronicBandStructure` properties. """ iri = '' @@ -52,7 +52,13 @@ def __init__( ) -> None: super().__init__(m_def, m_context, **kwargs) # ! `n_bands` need to be set up during initialization of the class - self.rank = [int(kwargs.get('n_bands'))] + if ( + n_bands := kwargs.get('n_bands') + ) is None: # ! alt: derive n_bands from value + raise ValueError( + '`n_bands` is not defined during initialization of the class.' + ) + self.rank = [int(n_bands)] def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: super().normalize(archive, logger)