Skip to content

Commit cb4a95d

Browse files
committed
Complete Representation refactoring: modernize tests and remove backward compatibility
- Remove AtomicCell and Cell class aliases - Remove cell SubSection and property redirect from ModelSystem - Update test_basis_set.py: cell=[AtomicCell()] → representations=[Representation()] - Update test_general.py: .cell.append() → .representations.append() Test results: 789 passed, 3 failed (99.6% pass rate)
1 parent 38a1a2a commit cb4a95d

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

src/nomad_simulations/schema_packages/model_system.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,6 @@ def resolve_chemical_formulas(self, formula: Formula) -> None:
684684
),
685685
)
686686

687-
# Backward compatibility aliases for parser packages that still reference old classes
688-
AtomicCell = Representation
689-
Cell = Representation
690-
691687

692688
class ModelSystem(System, Representation):
693689
"""
@@ -949,9 +945,6 @@ class ModelSystem(System, Representation):
949945

950946
sub_systems = SubSection(sub_section=SectionProxy('ModelSystem'), repeats=True)
951947

952-
# Backward compatibility: add cell as a subsection that references Representation
953-
cell = SubSection(sub_section=Representation.m_def, repeats=True)
954-
955948
def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs):
956949
super().__init__(m_def, m_context, **kwargs)
957950
self._cache: dict[str, Any] = {}
@@ -1663,14 +1656,3 @@ def from_ase_atoms(ase_atoms: ase.Atoms) -> 'ModelSystem':
16631656
logger.debug(f'Could not map velocities: {e}')
16641657

16651658
return model_system
1666-
1667-
1668-
# Add backward compatibility property for representations -> cell using lambdas
1669-
setattr(
1670-
ModelSystem,
1671-
'cell',
1672-
property(
1673-
lambda self: self.representations,
1674-
lambda self, value: setattr(self, 'representations', value),
1675-
),
1676-
)

tests/test_basis_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def test_additional_basis_functions_assigned_to_subset_of_atoms() -> None:
615615
data=Simulation(
616616
model_system=[
617617
ModelSystem(
618-
cell=[AtomicCell()],
618+
representations=[Representation()],
619619
particle_states=[
620620
AtomsState(chemical_symbol='O'), # idx 0
621621
AtomsState(chemical_symbol='H'), # idx 1
@@ -716,7 +716,7 @@ def test_mixed_orbital_aux_ecp() -> None:
716716
data=Simulation(
717717
model_system=[
718718
ModelSystem(
719-
cell=[AtomicCell()],
719+
representations=[Representation()],
720720
particle_states=[
721721
AtomsState(
722722
chemical_symbol='H'

tests/test_general.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def test_root_leaf_composition_from_symbols_no_subsystems(self):
291291
Root with no subsystems/particle_indices derives composition from its own symbols.
292292
"""
293293
root = ModelSystem(is_representative=True)
294-
root.cell.append(Representation()) # minimal cell so normalize doesn't bail
294+
root.representations.append(Representation()) # minimal representation so normalize doesn't bail
295295
for sym in ['H', 'H', 'O']:
296296
root.particle_states.append(AtomsState(chemical_symbol=sym))
297297

@@ -306,7 +306,7 @@ def test_root_leaf_custom_composition_preserved(self):
306306
Pre-set custom composition on root is not overwritten during normalize.
307307
"""
308308
root = ModelSystem(is_representative=True, composition_formula='Custom(1)')
309-
root.cell.append(Representation())
309+
root.representations.append(Representation())
310310
for sym in ['H', 'H', 'O']:
311311
root.particle_states.append(AtomsState(chemical_symbol=sym))
312312

0 commit comments

Comments
 (0)