Skip to content

feat: add transplanted 1D quadrature maps, docs, tests#159

Merged
inducer merged 22 commits intoinducer:mainfrom
xywei:transplanted-rules
Mar 20, 2026
Merged

feat: add transplanted 1D quadrature maps, docs, tests#159
inducer merged 22 commits intoinducer:mainfrom
xywei:transplanted-rules

Conversation

@xywei
Copy link
Copy Markdown
Contributor

@xywei xywei commented Feb 24, 2026

Summary

This PR adds transplanted 1D quadrature support to modepy using Hale–Trefethen/Kosloff–Tal-Ezer style maps, with docs and tests.

  • Add new module: modepy/quadrature/transplanted.py
    • map functions:
      • map_identity
      • map_sausage
      • map_kosloff_tal_ezer (kte / kosloff_tal_ezer)
      • map_strip
    • dispatcher:
      • map_trefethen_transplant
    • quadrature wrappers:
      • transplanted_1d_quadrature
      • transplanted_legendre_gauss_quadrature
  • Export wrappers at top level from modepy.__init__.
  • Add dedicated transplanted quadrature docs in doc/quadrature.rst with map-specific guidance and references.
  • Add transplanted-focused tests in modepy/test/test_quadrature.py (map consistency, strip endpoint rejection, KTE validation, sausage degree checks).

What for

These quadrature rules are good at integrating QBX coefficients:

image

API Notes

  • Canonical sausage API is now:
    • map_name="sausage" with sausage_degree=<odd int>
  • Backward-compatible map-name alias is still accepted in dispatcher:
    • map_name="sausage_d{odd}"
  • Public API for this feature is function/wrapper-based (no Transplanted* class API introduced).
  • exact_to is preserved for identity-preserving mappings (identity and sausage degree 1), and unset otherwise.

Documentation Updates

  • Added a dedicated transplanted section anchor in docs.
  • Clarified transformed-weight notation (w_i^{(s)} vs mapped weights).
  • Improved citation formatting (italic journal names + clickable DOI links).
  • Reduced duplicated reference text between module docstrings and doc/quadrature.rst.

Validation

  • ruff check
  • basedpyright
  • pytest modepy/test/test_quadrature.py -k transplanted
  • Full CI on PR (including docs and downstream jobs)

@inducer
Copy link
Copy Markdown
Owner

inducer commented Feb 24, 2026

Thanks! Could you look at those linter failures? The biggest one is probably adding types.

@inducer
Copy link
Copy Markdown
Owner

inducer commented Feb 24, 2026

(I can help if there's an issue.)

@inducer
Copy link
Copy Markdown
Owner

inducer commented Feb 24, 2026

cc @ShawnL00

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds transplanted 1D quadrature rules/maps (Hale–Trefethen and Kosloff–Tal-Ezer) to modepy, with accompanying docs, tests, and a QBX comparison example.

Changes:

  • Introduces modepy.quadrature.transplanted with transplant maps, a dispatcher, and transplanted quadrature classes.
  • Exports transplanted quadrature classes through package init modules (modepy.quadrature and top-level modepy).
  • Adds docs + tests for map dispatch/validation and includes a 2D QBX comparison example script.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
modepy/quadrature/transplanted.py New transplanted-map implementations and transplanted quadrature classes.
modepy/quadrature/__init__.py Re-exports transplanted quadrature classes from the quadrature package.
modepy/__init__.py Exposes transplanted quadrature classes at the top-level modepy API.
modepy/test/test_quadrature.py Adds unit tests for transplanted quadrature mapping/validation behavior.
examples/plot-qbx-transplanted-vs-gauss.py New QBX comparison example for Gauss vs transplanted rules.
doc/quadrature.rst Adds documentation section describing transplanted quadrature usage and references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +44
OUT = "/tmp/qbx-transplanted-vs-gauss-2d.png"

Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example writes output to a hard-coded /tmp/... path, which will fail on non-POSIX platforms (e.g. Windows) and can be surprising for users.

Consider using tempfile.gettempdir()/pathlib.Path, saving relative to the current working directory, or making the output path a CLI argument.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@alexfikl alexfikl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nifty! 😁

I took a quick look and left some nitpicks and questions.

@xywei xywei changed the title feat: add transplanted 1D quadrature maps, docs, tests, and QBX example feat: add transplanted 1D quadrature maps, docs, tests Feb 25, 2026
Copy link
Copy Markdown
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this! Pretty close, just a few small wrinkles.

@inducer inducer force-pushed the transplanted-rules branch from 8988606 to 250c95c Compare March 20, 2026 19:43
@inducer inducer force-pushed the transplanted-rules branch from 250c95c to c02d6be Compare March 20, 2026 19:49
@inducer inducer requested a review from alexfikl March 20, 2026 19:52
@inducer
Copy link
Copy Markdown
Owner

inducer commented Mar 20, 2026

I've addressed the review feedback. LGTM now. @alexfikl?

Copy link
Copy Markdown
Collaborator

@alexfikl alexfikl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a bunch of nitpicks in the docs and the example, but otherwise looks good to me too 😁

inducer and others added 3 commits March 20, 2026 15:29
Co-authored-by: Alex Fikl <alexfikl@gmail.com>
Co-authored-by: Andreas Klöckner <inform@tiker.net>
@inducer inducer enabled auto-merge (rebase) March 20, 2026 20:50
@inducer inducer disabled auto-merge March 20, 2026 20:50
@inducer inducer enabled auto-merge (squash) March 20, 2026 20:50
@inducer inducer merged commit ff7cc82 into inducer:main Mar 20, 2026
9 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.

4 participants