Tags: bjmorgan/hofmann
Tags
Retire AtomData range/labels caches (closes #68) AtomData computes global_range and global_labels eagerly in __setitem__. The global_range() and global_labels() methods are replaced by read-only ad.ranges and ad.labels mapping attributes backed by MappingProxyType via @Property. Callers substitute ad.global_range(key) with ad.ranges[key] and ad.global_labels(key) with ad.labels[key]. AtomData.__setitem__ rejects unsupported dtypes at assignment time with a clear ValueError. Supported dtypes are bool, integer, float, string, and object; complex, datetime, bytes, and other dtypes previously stored successfully but failed later in the rendering pipeline with opaque numpy errors. _resolve_numerical also gained a local precondition check at its values.astype(float) site to catch any future regression in the validation chain. resolve_atom_colours is no longer part of the public API. Colour resolution goes through StructureScene rendering methods. Additional correctness fixes: labels stored as immutable tuples (previously mutable lists); empty 2-D arrays return None for ranges instead of raising; __setitem__ computes derived metadata into locals before mutating state. Version bumped to 0.18.0.
Freeze AtomData entries on assignment (closes #64) AtomData.__setitem__ now copies incoming values via numpy.array and sets writeable=False on the stored copy. In-place mutation of a returned array (e.g. scene.atom_data["charge"][0] = 99) raises ValueError: assignment destination is read-only instead of silently bypassing shape validation and cache invalidation. Callers update values by building a new array and reassigning the key. This is a breaking change for any code that was mutating atom_data arrays in place, so the version is bumped to 0.17.0.
Add configurable light direction for polyhedra shading (closes #49) New light_direction parameter on RenderStyle controls the virtual light source for polyhedra face shading. Specified in screen space (x=right, y=up, z=towards viewer) so users can set it in terms of figure aesthetics ("light from the upper-left") without doing 3D geometry in their heads. The default changes from the viewing axis (0, 0, 1) to the upper- left (-1, 1, 1), giving visible face brightness variation from all viewing angles -- including top-down views of layered structures that previously produced flat, uniform shading. The previous behaviour can be restored with light_direction=(0, 0, 1). Legend polyhedron icons use the same light direction as the scene for visual consistency. render_legend() also accepts light_direction for standalone legend rendering. Closes #49. Bumps version to 0.16.0.
Warn when rendering species with no AtomStyle A new _warn_missing_atom_styles helper in precompute.py emits a single batched UserWarning per render call, listing all species in the rendering set that lack an AtomStyle. Called once from _precompute_scene after species resolution and before any per-atom work, so both the radius and colour fallbacks are covered by one upstream check. Python's default warning filter handles deduplication: identical messages from the same call site are shown once per process. Bumps version to 0.15.1 since this is new user-visible behaviour that could affect downstream CI with strict warning filters.
Per-frame colouring and validated AtomData container Introduce per-frame colourmap-based colouring for animations and the interactive viewer. set_atom_data now accepts 2-D arrays of shape (n_frames, n_atoms); the rendering pipeline slices per frame and uses cached global ranges (numeric) and global label sets (categorical) for consistent colour scaling across frames. Polyhedra inherit per-frame colours from their centre atoms. Replace the plain dict backing atom_data with a validated AtomData container (MutableMapping) that checks array shapes on assignment. Convert StructureScene from a dataclass to a plain class with an explicit __init__, view property with validating setter, and atom_data property that prevents replacement with a non-AtomData value. The constructor API is unchanged. Closes #44.
PreviousNext