feat: forward integrand args via integrate(..., args=...) - #246
Merged
Conversation
evaluate_integrand already accepted args and called fn(points, *args), but the public integrate() methods never exposed it. Threads an args parameter through every integrator (Trapezoid, Simpson, Boole, GaussLegendre, MonteCarlo, VEGAS) so parametric integrands can be integrated without a lambda wrapper. - args defaults to None (fn(points)), so existing calls are unchanged. - Applies to the eager integrate() path; the JIT-compiled path is unchanged. Re-implements the stale PR #188 and closes #187. Co-Authored-By: Dan Barzilay <barzilaydn@gmail.com>
Collaborator
Author
|
Claude: Thanks!
|
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 task
This was referenced Jul 24, 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.
What
Lets a parametric integrand be integrated directly, without a lambda wrapper:
BaseIntegrator.evaluate_integrandalready acceptedargsand calledfn(points, *args), but no publicintegrate()exposed it. This threads anargsparameter through every integrator — Trapezoid, Simpson, Boole,GaussLegendre, MonteCarlo and VEGAS.
argsdefaults toNone(fn(points)), so all existing calls are unchanged.integrate()path; the JIT-compiled path is untouched.This re-implements the stale PR #188 by Dan Barzilay (credited as co-author) and
closes #187.
Test plan
args_test.py: every integrator forwardsargsand integrates theparametric integrand correctly across backends (grid rules exact; MC/VEGAS
within tolerance);
args=Nonematches a pre-bound lambda — 12 passedintegrator_types) still green — 46 passed
ruff/pydoclint/vulturecleanCloses #187. Roadmap F3.