Skip to content

Commit 93cf91d

Browse files
committed
refactor(structure): extract constants, fix cyclic imports, improve repr/docs/tests
- Extract shared constants into src/aiida_atomistic/data/structure/constants.py and update imports across the package to break a circular import chain that caused Sphinx AutoAPI warnings. - Make `Site.__repr__` robust to missing positions to avoid TypeError in notebooks. - Rework `Structure.__repr__` and add `__str__` to present a safe, informative summary without calling `super().__repr__()` (prevents recursion with AiiDA Node repr). - Update `utils.sites_from_kinds` to accept both list and dict kinds formats for more flexible initialization. - Add comprehensive tests for property setters/removers: tests/data/test_property_setters.py. - Document remove-property methods and clarify property-setting vs validation semantics; clarify `StructureBuilder` role; document that `magmom` and `magnetization` are mutually exclusive per site. - Minor validator and utility fixes (freeze_pbc validator ordering, small import fixes). Why: - Removes AutoAPI cyclic import warnings and prevents runtime repr-related errors in notebooks and interactive sessions. - Improves developer ergonomics and documents expected behaviour for magnetic properties and property removal. Testing: - Run unit tests: pytest -q - Rebuild docs: cd docs && make html Notes: - Internal refactor only: no intended public API breaking changes. Maintainers should note the new `constants.py` location for internal imports.
1 parent 8066a3c commit 93cf91d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6792
-6305
lines changed

conftest.py

Lines changed: 0 additions & 202 deletions
This file was deleted.

docs/source/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@
9797
myst_substitutions = {
9898
'aiida_logo': '<img src="../_static/logo_aiida.svg" alt="aiida" class="aiida-logo">',
9999
'StructureData': '{class}`~aiida_atomistic.data.structure.structure.StructureData`',
100-
'StructureDataMutable': '{class}`~aiida_atomistic.data.structure.structure.StructureDataMutable`',
100+
'StructureBuilder': '{class}`~aiida_atomistic.data.structure.structure.StructureBuilder`',
101101
'Site': '{class}`~aiida_atomistic.data.structure.site.Site`',
102102
'Kind': '{class}`~aiida_atomistic.data.structure.kind.Kind`',
103103
'LegacyStructureData': '{class}`~aiida.orm.StructureData`',
104104
'from_ase': '{meth}`~aiida_atomistic.data.structure.structure.StructureData.from_ase`',
105105
'from_pymatgen': '{meth}`~aiida_atomistic.data.structure.structure.StructureData.from_pymatgen`',
106106
'from_file': '{meth}`~aiida_atomistic.data.structure.structure.StructureData.from_file`',
107-
'from_legacy': '{meth}`~aiida_atomistic.data.structure.structure.StructureData.from_legacy`',
107+
'legacy_structure.to_atomistic()': '{meth}`~aiida_atomistic.data.structure.structure.StructureData.legacy_structure.to_atomistic()`',
108108
}
109109

110110
# -- Options for HTML output ----------------------------------------------
@@ -119,6 +119,8 @@
119119
'twitter_url': 'https://twitter.com/aiidateam',
120120
'use_edit_page_button': True,
121121
'navigation_with_keys': False,
122+
'show_navbar_depth': 2, # Show 2 levels in navbar
123+
'show_toc_level': 2, # Show 2 levels in right sidebar TOC
122124
'logo': {
123125
'text': 'AiiDA Atomistic',
124126
'image_light': '_static/logo_aiida_atomistic-light.png',

0 commit comments

Comments
 (0)