Conversation
… (3.4.0) Unblocks build123d#1270 Materials-class adapt pass. Fixes two bugs and adds a cell-style example file wired into pytest so API drift breaks the example before it breaks downstream. #88 — Grades inherit parent Vis at load time - Loader deep-copies parent._vis for grades without [vis] TOML section - Vis.merge_from_toml() handles partial overrides (grade with just roughness=0.7 inherits rest from parent) - Matches existing _add_child properties-inheritance pattern - Runtime mutation stays isolated per-material (documented, intentional) - 21 tests in tests/test_vis_inheritance.py #89 — Exact lookup + normalization + grade targets - pymat["..."] via module-level __getitem__ (PEP 562-style class swap) - Matches key / name / grade with NFKC + case-fold + whitespace-collapse - KeyError on miss lists fuzzy close matches; KeyError on ambiguity lists candidates - search(exact=True) matches grade too (caught by falsify review) - __contains__ mirrors __getitem__ - 28 tests in tests/test_lookup.py examples/build123d_integration.py - Cell-style (# %%) runnable script covering the full integration surface: pymat[...] lookup, search, vis inheritance, adapter output, shape.material + export_gltf - tests/test_build123d_integration_examples.py runs the whole file via runpy; cells assert inline. Any API drift goes red here first. Falsify review - Original deep-copy-at-access proxy design was refuted on three orthogonal angles (Python idioms, edge cases, implementation reality) - Load-time deep-copy-with-merge chosen instead: simpler, matches existing convention, documented trade-off on runtime parent mutation Replaces 3.3.0 with 3.4.0 — minor bump because new public API (pymat[...], exact=True) is additive, no existing behavior changes except the #88 inheritance fix which was surprising-but-fixing. 329 → 386 tests (+57 new).
This was referenced Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unblocks build123d#1270 Materials-class adapt pass. Fixes the two bugs Bernhard reported (#88, #89) and adds a runnable cell-style example file wired into pytest.
Closes #88. Closes #89.
What's in
#88 — Grades inherit parent
VisBefore 3.4, a grade without its own
[vis]TOML section hadvis.source = None, forcing consumers to walk the parent chain manually. Fixed insrc/pymat/loader.py— deep-copiesparent._visfor grades without their own[vis], merges TOML overrides on top when present via newVis.merge_from_toml()classmethod.Matches the existing
_add_childproperty-inheritance pattern. Runtime mutations stay per-material (isolated) — documented trade-off.#89 — Exact lookup surface
pymat["Stainless Steel 304"]— module-level subscript via PEP 562-style class swap. Matches key / name / grade (case-insensitive, NFKC + whitespace-collapse). RaisesKeyErroron miss (with fuzzy suggestions) or ambiguity (with candidates).pymat.search(q, exact=True)— list-returning exact variant. Now matchesgradetoo (was missing — caught by falsify review).inoperator works via__contains__.Examples + test wiring
examples/build123d_integration.py— cell-style (# %%) runnable script mirroring the pattern build123d's author uses. Covers lookup, search, inheritance, adapters, shape integration, glTF export.tests/test_build123d_integration_examples.py— executes the file top-to-bottom viarunpyon every CI run. Any API drift breaks the example before it breaks downstream copy-paste.Falsify review
Before implementing, the original design (deep-copy-at-access proxy for Vis) was refuted by three orthogonal reviewers:
pymat.get()collides withdict.get()convention,name_or_keyis a polymorphic-string smell,__getitem__is the idiomatic shape.exact=Truemissing grade targets, ambiguity handling, normalization silence.Vis.from_tomlcan't merge — needs an explicit merger classmethod.Final design consolidates all three → load-time deep-copy-with-merge,
__getitem__subscript, grade-awareexact=True, full NFKC normalization.Test plan
examples/build123d_integration.pyruns top-to-bottom green.Versioning
Minor bump 3.3.0 → 3.4.0 — additive public API, one behavior change (the #88 inheritance fix, which was surprising-but-fixing). No breaking deprecations.