Skip to content

Add color export (PLY/3MF), synthetic data mode, vectorize fix_orientation - #4

Merged
Moredread merged 1 commit into
mainfrom
claude/apply-review-patch-B5Voh
May 1, 2026
Merged

Moredread merged 1 commit into
mainfrom
claude/apply-review-patch-B5Voh

Conversation

@Moredread

Copy link
Copy Markdown
Owner
  • Output format selected by extension: .stl (geometry only, unchanged
    numpy-stl path), .ply (per-vertex color via trimesh, native PLY
    support), .3mf (per-vertex color via lib3mf using the Materials
    Extension - one ColorGroup entry per vertex, referenced per-corner
    from each triangle).

    Note: trimesh's own 3MF exporter currently drops vertex colors
    silently, so the 3MF path uses lib3mf directly. Verified by inspecting
    the resulting <m:colorgroup> XML.

  • New --synthetic flag generates a low-l Gaussian random field with a
    red C_l ~ 1/(l+1)^2 spectrum scaled to ~100 uK RMS. Lets the whole
    pipeline run end-to-end without the 1 GB Planck FITS file - useful
    for CI, demos, and offline iteration. Reproducible via --seed.

  • fix_orientation() vectorized with np.cross + np.einsum over all faces
    at once. Bit-identical output to the previous loop, ~73x faster at
    nside=128 (8.5s -> 0.12s on a typical machine).

  • Mesh construction split into build_displaced_sphere() and
    build_faces() so each step is unit-testable in isolation. Output
    dispatch lives in save() with a small per-format helper each.

  • New tests cover: synthetic generator shape/seed/amplitude,
    outward-normal invariant after fix_orientation, PLY round-trips
    per-vertex color, 3MF contains <m:colorgroup> with one entry per
    vertex, STL still works, unknown extension raises.

@Moredread
Moredread force-pushed the claude/apply-review-patch-B5Voh branch from e44fa33 to 1c7841e Compare May 1, 2026 09:04
…ation

* Output format selected by extension: .stl (geometry only, unchanged
  numpy-stl path), .ply (per-vertex color via trimesh, native PLY
  support), .3mf (per-vertex color via lib3mf using the Materials
  Extension - one ColorGroup entry per vertex, referenced per-corner
  from each triangle).

  Note: trimesh's own 3MF exporter currently drops vertex colors
  silently, so the 3MF path uses lib3mf directly. Verified by inspecting
  the resulting <m:colorgroup> XML.

* New --synthetic flag generates a low-l Gaussian random field with a
  red C_l ~ 1/(l+1)^2 spectrum scaled to ~100 uK RMS. Lets the whole
  pipeline run end-to-end without the 1 GB Planck FITS file - useful
  for CI, demos, and offline iteration. Reproducible via --seed.

* fix_orientation() vectorized with np.cross + np.einsum over all faces
  at once. Bit-identical output to the previous loop, ~73x faster at
  nside=128 (8.5s -> 0.12s on a typical machine).

* Mesh construction split into build_displaced_sphere() and
  build_faces() so each step is unit-testable in isolation. Output
  dispatch lives in save() with a small per-format helper each.

* New tests cover: synthetic generator shape/seed/amplitude,
  outward-normal invariant after fix_orientation, PLY round-trips
  per-vertex color, 3MF contains <m:colorgroup> with one entry per
  vertex, STL still works, unknown extension raises.

Update uv.lock for new trimesh and lib3mf dependencies

Sync lockfile to match the dependencies added in the previous commit
for PLY and 3MF colored output.

Add GitHub Actions CI for synthetic tests

Runs tests/test_color_and_synthetic.py on Python 3.10/3.11/3.12 using
uv. test_end2end.py is excluded because it requires the 1 GB Planck
FITS file.

Fix e2e tests and enable them in CI

The e2e tests in tests/test_end2end.py had three problems:

1. The temp fixture used tempfile.mkstemp() with no suffix, so the
   new extension-based dispatch in save() rejected the path with
   ValueError. Fixed by passing suffix=".stl" (and closing the
   leaked fd while we're here).

2. test_vertex_number_is_correct_for_nside_default compared
   normals.shape[0] (= triangle count, ~2*npix for a closed
   convex hull) against npix. Now compares unique vertex count.

3. test_vertex_number_is_correct_for_nside_from_parameter built a
   set() of ndarray rows, which raises TypeError: unhashable type.
   Also only looked at v0, missing vertices that aren't a face's
   first corner. Now collects v0+v1+v2 and dedups as tuples.

All four e2e tests now pass under --synthetic, so they no longer
need the 1 GB FITS file and are included in CI.

Add Planck and IRSA attributions to README

Co-Authored-By: Claude <noreply@anthropic.com>
@Moredread
Moredread force-pushed the claude/apply-review-patch-B5Voh branch from 1c7841e to b49d7ee Compare May 1, 2026 09:08
@Moredread
Moredread merged commit 3d1f64c into main May 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant