Skip to content

[codex] rerun notebooks for 2.11.0#467

Open
daquinteroflex wants to merge 3 commits intodevelopfrom
codex/rerun-notebooks-2026-04-06
Open

[codex] rerun notebooks for 2.11.0#467
daquinteroflex wants to merge 3 commits intodevelopfrom
codex/rerun-notebooks-2026-04-06

Conversation

@daquinteroflex
Copy link
Copy Markdown
Collaborator

@daquinteroflex daquinteroflex commented Apr 6, 2026

Rerun the affected notebooks and regenerate the optimized reflector GDS output.

Files updated:

  • DirectionalCouplerSurrogate.ipynb
  • GeneticAlgorithmReflector.ipynb
  • MaxwellStressTensor.ipynb
  • ParticleSwarmOptimizedPBS.ipynb
  • misc/optimized_reflector.gds

Reverted (need library-side fixes, not notebook changes):

  • HeatSolver.ipynb — TemperatureMonitor now defaults unstructured=True, returning TetrahedralGridDataset instead of SpatialDataArray. Notebook needs updating after the library API stabilizes.
  • MetasurfaceBIC.ipynb — dictionary changed size during iteration in batch.run() is a tidy3d library bug.

Validation: rerun locally and committed the resulting notebook outputs / generated asset changes.

@daquinteroflex
Copy link
Copy Markdown
Collaborator Author

daquinteroflex commented Apr 6, 2026

Notebook Fixes Summary

This PR fixes 4 notebooks that were failing in CI (run #23868661354) due to API changes, type validation, and deprecated NumPy functions. All notebooks were re-executed locally to regenerate outputs.

Fixes by notebook

1. MaxwellStressTensor.ipynb — NumPy 2.x API removal

  • Error: AttributeError: module 'numpy' has no attribute 'trapz'
  • Fix: Replaced all 9 calls of np.trapz(...)np.trapezoid(...) (cell 7). np.trapz was removed in NumPy 2.0.

2. GeneticAlgorithmReflector.ipynb — Pydantic string_type validation

  • Error: ValidationError: Input should be a valid string on tdd.ParameterInt(name=i, ...)
  • Fix: Changed name=iname=str(i) (cell 20). Pydantic v2 strict mode rejects integers where strings are expected.

3. ParticleSwarmOptimizedPBS.ipynb — Pydantic string_type validation

  • Error: Same Pydantic validation as above on tdd.ParameterFloat(name=i, ...)
  • Fix: Changed name=iname=str(i) (cell 36).

4. DirectionalCouplerSurrogate.ipynb — Multi-element array to scalar conversion

  • Error: TypeError: only 0-dimensional arrays can be converted to Python scalars
  • Fix: Added np.squeeze() and .values before float() conversion after explode() (cell 20), since individual entries remain as 1-element DataArrays rather than 0-d scalars.

These two notebooks need library-side fixes (unstructured grid API
change and dict mutation in batch runner respectively), not notebook
code changes. Reverting to develop to keep this PR scoped to
notebook-level fixes only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@daquinteroflex daquinteroflex changed the title [codex] rerun notebooks [codex] rerun notebooks for 2.11.0 Apr 6, 2026
@daquinteroflex daquinteroflex marked this pull request as ready for review April 6, 2026 09:26
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Spell Check Report

DirectionalCouplerSurrogate.ipynb:

Cell 21, Line 14: '-element'
  > # We use .values to get the numpy array and .item() to safely convert a 1-element array to a float

Checked 5 notebook(s). Found spelling errors in 1 file(s).
Generated by GitHub Action run: https://github.com/flexcompute/tidy3d-notebooks/actions/runs/24026563069

@momchil-flex
Copy link
Copy Markdown
Collaborator

Not urgent but I guess best to clear this

image

I am confused about the HeatSolver. It was fixed in this PR. I am not sure why your changes here seem to apply to an older version of the notebook.

@momchil-flex
Copy link
Copy Markdown
Collaborator

Oh regarding the HeatSolver it's supposed to be a revert? But I'm confused about the diff it shows here. Maybe some issue in notebook diff.

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.

2 participants