The repository or configuration that created this release differ from a previous release. View details.
crystal-scene
crystal-scene converts one CIF string or a pymatgen Structure into a deterministic,
renderer-neutral Pydantic scene. It resolves bonds and periodic images on the backend
so HSC, Materiae, and other consumers can draw the same scientific structure consistently.
The package consumes source-neutral values from matdomain-structure and owns
only renderer-facing scene derivation.
The package intentionally does not depend on Crystal Toolkit, Dash, a database, or a frontend framework.
Python 3.12 or newer is required.
Installation
Install the published distribution with:
pip install crystal-scene
From a matdomain checkout, install both workspace distributions into an active
environment:
python -m pip install -e ./packages/matdomain-structure -e ./packages/crystal-scene
Usage
from pathlib import Path
from crystal_scene import build_crystal_scene
cif_text = Path("structure.cif").read_text(encoding="utf-8")
scene = build_crystal_scene(cif_text)
payload = scene.model_dump(mode="json")
build_crystal_scene also accepts a pymatgen Structure. Structure inputs are copied,
then fractional coordinates along periodic lattice axes are wrapped into the input unit
cell; nonperiodic axes retain their input values and callers are not mutated. CIF input
must contain exactly one non-empty structure. Blank input, parser errors, multiple
structures, and empty structures raise ValueError or a pymatgen parser exception.
JSON contract
scene.model_dump(mode="json") is the canonical TypeScript-facing payload. Field names
are camel case and schemaVersion is currently "1.0". A payload contains:
generator: the CrystalNN implementation, exact pymatgen and pymatgen-core versions, disorder policy, and whether every input species has an oxidation state;lattice.matrix: three row vectors in angstroms;sites: stable input-cell indices, source labels, full species occupancies and oxidation states, and wrapped fractional coordinates;siteImages: every input-cell site plus the one-hop periodic site images needed as endpoints of the emitted bonds;bonds: each input-cell site's complete CrystalNN neighbor view, including distance in angstroms and CrystalNN topology weight.
A physical CrystalNN bond is undirected. Each serialized bond anchors one view of that
connection at sourceSite in the input cell, while targetImage translates targetSite
by an integer linear combination of the three lattice rows. The reverse neighbor view is
also emitted, so every input-cell site retains its complete coordination environment. In
fractional coordinates, the anchored bond vector is:
sites[targetSite].fractional + targetImage - sites[sourceSite].fractional
Swapping the source and target therefore also requires negating targetImage. Renderers
can materialize siteImages directly and deduplicate coincident undirected segments.
Distinct images remain distinct connections, including bonds from a site to its own
periodic images.
For disordered sites, the scene always retains every species and occupancy. CrystalNN
uses pymatgen's take_max_species policy only to choose a representative species for
bond inference; equal maximum occupancies use pymatgen's deterministic first-maximum
behavior. Isotope mass numbers and idealized species spin are accepted as structure
identity, while scene schema 1.0 retains its legacy projection of element, occupancy,
and oxidation state only.
The input cell is preserved deliberately. Primitive, conventional, refined, or reduced
cells change site indices and may depend on symmetry tolerances, so they are not implicit
view switches in schema 1.0. Callers that need another cell must supply that pymatgen
Structure explicitly.
Colors, atomic radii, bond-cylinder dimensions, boundary-face duplicates, incomplete-bond
stubs, labels, and camera state are renderer policy and are not scene data. Magnetic
moments and coordination polyhedra are not part of scene schema 1.0: moments require an
explicit basis/unit contract, while polyhedra are derived geometry that renderers can
construct from the complete neighbor topology when needed. CrystalNN weight is a
method-specific topology value (and is normally 1 in the default unweighted mode), not
a chemical bond order.
The project is distributed under the terms of the MIT License. See LICENSE.
Metadata
Release files for crystal-scene 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| crystal_scene-0.1.1.tar.gz | 9.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crystal_scene-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / crystal_scene-0.1.1.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | crystal_scene-0.1.1.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bee880242d1ff399a3b796322cb7b184c9303b23795bff9185594f455a912baf
|
|
BLAKE2b-256 checksum How to use checksums |
67ca409a12fb1cf8136afe7291685795257afbeeda937f2fc5de17c3c84000ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency logRelease files / crystal_scene-0.1.1-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | crystal_scene-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f4c4727ac0a0a3422b05bf18d3a8644337b77ac617ffd99a4478885da3872b6
|
|
BLAKE2b-256 checksum How to use checksums |
18c5cd6c43af64b15f4a9ebb08313b6a0ca3d6e08902d87dd52f66bc26a590d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency logSecurity for crystal-scene 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Change of provenance
The repository that created this release differs from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
- Removed 0.1.0 GitHub: tiannianzhu/crystal-scene
- Added 0.1.1 GitHub: tiannianzhu/matdomain
Attestation for crystal_scene-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.