Skip to content

build_function tier1 & tier3 - #18

Merged
s-celles merged 2 commits into
mainfrom
067-build-function-tier3
May 2, 2026
Merged

build_function tier1 & tier3#18
s-celles merged 2 commits into
mainfrom
067-build-function-tier3

Conversation

@s-celles

@s-celles s-celles commented May 2, 2026

Copy link
Copy Markdown
Collaborator

Related #17

s-celles added 2 commits May 2, 2026 17:35
`build_function(expr::GiacExpr, vars::GiacExpr...)` returns a Julia
callable equivalent to `to_julia(substitute(expr, Pair.(vars, vals)...))`,
suitable as a drop-in argument to `Plots.plot`, `Plots.surface`,
broadcasting, and matrix comprehensions. Tier 1 wrapper only — Tier 2
(in-house codegen) and Tier 3 (Symbolics.build_function delegation)
remain follow-ups per issue #17. Closes #17. (066-build-function)

- src/build_function.jl: thin wrapper via private fixed-arity callable
  struct (`<: Function`) so wrong-arity calls raise MethodError.
- docs/src/julia_functions.md: new `Using build_function` section with
  comparison table to Symbolics.build_function and SymPy.lambdify.
- examples/04_plotting.jl: new section 2b demonstrating the multivariate
  surface plot with build_function alongside the existing manual cells.
- test/test_build_function.jl: 10 testsets covering clauses C1–C10
  including a 3-expression × 100-sample behavioral equivalence sweep.
- Project.toml: 0.12.0 -> 0.13.0 (additive MINOR); Random added to test
  extras / compat for the equivalence sweep.
`build_function` gains a `backend::Symbol = :giac` keyword. The default is
unchanged from v0.13. The new `backend = :symbolics` (requires `using
Symbolics`) round-trips the expression through `to_symbolics` and compiles
it via `Symbolics.build_function`, returning a native Julia callable that
is autodiff-friendly (ForwardDiff, SciML solvers) and ~140× faster than
the :giac backend on hot-loop workloads. Closes #17 tier 3.

- src/build_function.jl: backend keyword + missing-Symbolics ArgumentError
  + internal `_build_function_symbolics_impl` hook (declared with no
  methods so the extension's method doesn't trigger the precompile-time
  "method overwriting" error).
- ext/GiacSymbolicsExt.jl: extension's method on the hook does the
  to_symbolics + Symbolics.build_function compilation, with build-time
  free-symbol validation (clause B6).
- test/test_build_function_tier3.jl: 6 testsets covering clauses B1-B4,
  B6, B7, B8 + behavioral equivalence sweep (3 expressions x 100 samples)
  + ForwardDiff smoke (B3).
- Project.toml: 0.13.0 -> 0.14.0; ForwardDiff added to test extras and
  compat. Symbolics stays a weakdep (FR-003).
- docs/src/julia_functions.md: new "Choosing a backend" subsection with
  comparison table, equivalence example, benchmark snippet, autodiff
  example, naming-conflict caveat, error-paths summary.

Naming caveat (Option B from design discussion): `Symbolics` also exports
`build_function`, so `using Giac, Symbolics` requires qualification —
`Giac.build_function(...)`. Documented in the docstring and docs page.
@codecov-commenter

codecov-commenter commented May 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.50%. Comparing base (9ce43b7) to head (8083492).

Files with missing lines Patch % Lines
src/build_function.jl 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
+ Coverage   79.28%   79.50%   +0.21%     
==========================================
  Files          21       22       +1     
  Lines        2810     2840      +30     
==========================================
+ Hits         2228     2258      +30     
  Misses        582      582              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@s-celles
s-celles merged commit 84d569d into main May 2, 2026
8 checks passed
@s-celles
s-celles deleted the 067-build-function-tier3 branch July 26, 2026 14:53
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