From 0f92eb9ea0468f7417f30fd0edc0a2f76abfdbdc Mon Sep 17 00:00:00 2001 From: EBB2675 Date: Wed, 20 Nov 2024 13:32:31 +0100 Subject: [PATCH] check whether n_primitive matches the lengths of exponents and contraction coefficients --- src/nomad_simulations/schema_packages/basis_set.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/nomad_simulations/schema_packages/basis_set.py b/src/nomad_simulations/schema_packages/basis_set.py index 84c4c261..5fd5ac03 100644 --- a/src/nomad_simulations/schema_packages/basis_set.py +++ b/src/nomad_simulations/schema_packages/basis_set.py @@ -242,7 +242,19 @@ class AtomCenteredFunction(ArchiveSection): def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: super().normalize(archive, logger) - # self.name = self.m_def.name + + # Validation: Check that n_primitive matches the lengths of exponents and contraction coefficients + if self.n_primitive is not None: + if len(self.exponents or []) != self.n_primitive: + logger.error( + f"Mismatch in number of exponents: expected {self.n_primitive}, " + f"found {len(self.exponents or [])}." + ) + if len(self.contraction_coefficients or []) != self.n_primitive: + logger.error( + f"Mismatch in number of contraction coefficients: expected {self.n_primitive}, " + f"found {len(self.contraction_coefficients or [])}." + ) class AtomCenteredBasisSet(BasisSetComponent):