httk.atomistic.structure_entries¶
An EntryProvider serving OPTIMADE structures from httk-atomistic.
StructureEntryProvider maps Structure objects to
the neutral httk-core entry-provider contract, so a serving module (such as
httk-optimade) can expose them as an OPTIMADE structures endpoint without
this module depending on the serving module. The served entry type is described
by the vendored OPTIMADE standard structures definition (loaded via
httk.core.load_entry_type_definition()).
Beyond the core structural fields, the provider auto-derives the standard
composition fields (nperiodic_dimensions, dimension_types,
elements_ratios, chemical_formula_reduced / _anonymous /
_descriptive) for ordered structures, may serve custom database-specific
properties layered on via an
extended() definition, and may map an entry
id to None (a known entry with no structure — structural properties serve
null).
Classes¶
Serves OPTIMADE |
Module Contents¶
- class httk.atomistic.structure_entries.StructureEntryProvider(entries: collections.abc.Mapping[str, httk.atomistic.structure_like.StructureLike | None], *, extra_definitions: collections.abc.Mapping[str, httk.core.PropertyDefinition] | None = None, properties: collections.abc.Mapping[str, collections.abc.Mapping[str, Any]] | None = None)[source]¶
Bases:
httk.core.EntryProviderServes OPTIMADE
structuresfrom a mapping of id to structure.entriesmaps each entry id to aStructure(or any structure exposing thecell/sites/species/species_at_sitesquartet, or a(cell, sites, species, species_at_sites)tuple), or toNonefor a known entry that has no structure (its structural properties then serve null).The always-served structural fields are
id,type,nsites,elements,nelements,species(as OPTIMADE species dicts),species_at_sites,lattice_vectors(the cell basis rows),cartesian_site_positions(reduced coordinates times the cell basis), andstructure_features(disorderwhen any species mixes several chemical symbols;site_attachmentswhen any species has attached atoms). The standard composition fieldsnperiodic_dimensions,dimension_types,elements_ratios,chemical_formula_reduced/_anonymous/_descriptiveare auto-derived for a fully ordered structure (every species a single, unattached element), else served as null.extra_definitionsextends the served entry-type definition with custom database-specific properties (each carrying a registered prefix), andpropertiessupplies their per-entry values as{entry_id: {name: value}}; every property named there MUST be described by the (extended) definition (aValueErrorat construction names any offender), and a value absent for an entry is served as null.- entry_types() collections.abc.Mapping[str, httk.core.EntryTypeDefinition][source]¶
Return the served entry types keyed by name.
Each value is an
EntryTypeDefinitiondescribing the entry type and its properties. The subset a provider actually serves is named byproperty_keys(); a definition may describe more properties than are served.
- property_keys(entry_type: str) collections.abc.Mapping[str, str][source]¶
Return the served-property-name to record-key map for
entry_type.The mapping MUST include entries for at least
idandtype. Every key names a property described byentry_types(); every value names the key under which that property’s value is found in a record fromrecords().
- records(entry_type: str) collections.abc.Iterable[collections.abc.Mapping[str, Any]][source]¶
Yield the records for
entry_typeas plain JSON-able mappings.Each record is a mapping keyed by the record keys named in
property_keys(); values are JSON-able (strings, numbers, booleans,None, or nested lists/dicts of the same).