Skip to content

Make DoubleFloats & Quadmath weak dependencies (package extensions)#14

Merged
lucifer1004 merged 1 commit into
mainfrom
weaken-precision-deps
Jun 7, 2026
Merged

Make DoubleFloats & Quadmath weak dependencies (package extensions)#14
lucifer1004 merged 1 commit into
mainfrom
weaken-precision-deps

Conversation

@lucifer1004

@lucifer1004 lucifer1004 commented Jun 7, 2026

Copy link
Copy Markdown
Member

Float64-only users no longer load DoubleFloats or Quadmath (and thus the libquadmath C library): both are now [weakdeps] activated via package extensions, so they are pulled in only when the user does using DoubleFloats / using Quadmath.

These two are purely user-opt-in numeric types (Double64 / Float128) — the core (Float64) path never needs them. Their type-specific glue moves to extensions:

  • ext/TransitionMatricesDoubleFloatsExt.jl: precision(Complex{Double64}), Arblib.set!(::Double64), and the Double64 cbrt (∛) workaround.
  • ext/TransitionMatricesQuadmathExt.jl: Float128⇄Arb conversions, precision(ComplexF128), Arblib.set!(::Float128), and the _beta_prec(::Float128) volume-precision fallback.

Note: weakening Quadmath ALONE has no effect, because DoubleFloats (a hard dep) lists Quadmath in its own deps and so transitively loads it — both had to be weakened together for Float64-only loads to drop them. Verified: with only using TransitionMatrices, neither extension is loaded and a Float64 EBCM computation runs unchanged.

Arblib stays a hard dependency: it is the arbitrary-precision + special-function backbone (gausslegendre for non-Float64, factorial(n>20) via gamma! in the Wigner-d functions — reached even on the Float64 path — plus Arb/Acb as first-class numeric types in the EBCM Arb-matrix inversion and the IITM Acb FFT backend).

Re-exports of Double64 / Float128 / ComplexF128 are dropped (use the respective package); Arb/Acb stay exported. Tests updated to load the weak deps explicitly; test/Project.toml gains DoubleFloats and Quadmath. Full suite: 48,290 tests pass.

Summary by CodeRabbit

  • Chores

    • Reorganized optional numeric precision packages into on-demand extensions for cleaner packaging and maintenance.
    • Reduced default exports so extended numeric types are now opt-in.
  • New Features

    • Optional support for high-precision Float128, Double64, and Generic FFT can be enabled via extensions.
  • Bug Fixes

    • Applied a compatibility workaround for a broken Double64 cube-root behavior.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a3651802-b592-492c-81e0-50b5ca2b68ac

📥 Commits

Reviewing files that changed from the base of the PR and between b865ebf and e0469b2.

📒 Files selected for processing (14)
  • Project.toml
  • benchmark/Project.toml
  • benchmark/benchmarks.jl
  • ext/TransitionMatricesDoubleFloatsExt.jl
  • ext/TransitionMatricesGenericFFTExt.jl
  • ext/TransitionMatricesQuadmathExt.jl
  • packages/EBCMPrecisionLossEstimators/Project.toml
  • src/IITM/fourier.jl
  • src/IITM/nfold.jl
  • src/TransitionMatrices.jl
  • src/compat/index.jl
  • src/shapes/superspheroid.jl
  • test/Project.toml
  • test/compat.jl
✅ Files skipped from review due to trivial changes (2)
  • packages/EBCMPrecisionLossEstimators/Project.toml
  • benchmark/benchmarks.jl
🚧 Files skipped from review as they are similar to previous changes (7)
  • ext/TransitionMatricesQuadmathExt.jl
  • test/Project.toml
  • test/compat.jl
  • ext/TransitionMatricesDoubleFloatsExt.jl
  • src/TransitionMatrices.jl
  • src/shapes/superspheroid.jl
  • src/compat/index.jl

📝 Walkthrough

Walkthrough

Move DoubleFloats/GenericFFT/Quadmath from direct deps into weakdeps + extension modules; add ext/ modules with precision, conversion, and FFT hooks; remove core re-exports and compat shims; update tests and benchmarks to import numeric types directly.

Changes

Weak Dependency Extension Architecture

Layer / File(s) Summary
Project and package wiring
Project.toml, Project.toml (weakdeps/extensions), benchmark/Project.toml, test/Project.toml, packages/.../Project.toml
Bump package version, move DoubleFloats/GenericFFT/Quadmath to [weakdeps], add [extensions] entries, and update benchmark/test manifests.
Extension modules: DoubleFloats, GenericFFT, Quadmath
ext/TransitionMatricesDoubleFloatsExt.jl, ext/TransitionMatricesGenericFFTExt.jl, ext/TransitionMatricesQuadmathExt.jl
Add extensions that declare precision for Double64/Float128, conversions between ArbLike and Float128, Arblib.set! overloads, a guarded Double64 cbrt workaround, and GenericFFT azimuthal plan/DFT plumbing.
Core module and compat refactor
src/TransitionMatrices.jl, src/compat/index.jl
Remove top-level imports/re-exports of Double64/Float128/ComplexF128 and relocate their compatibility/precision helpers into ext/; keep core Arb/Acb shims in compat.
FFT dispatch and GenericFFT routing
src/IITM/fourier.jl
Restrict _iitm_fft_capable to ComplexF64 and Acb; remove generic Complex{<:AbstractFloat} _azimuthal_fft_plan and _apply_forward_dft! implementations (moved to GenericFFT extension).
Tests, benchmarks, and numeric-precision callsites
src/IITM/nfold.jl, benchmark/benchmarks.jl, test/compat.jl, src/shapes/superspheroid.jl
Tests and benchmarks now explicitly using DoubleFloats/Quadmath/GenericFFT; superspheroid _beta_lgamma uses max(precision(x), precision(y)); test assertions/imports updated accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 With whiskers twitching, hopped the code so clean,
Weak deps now live in extensions seen,
No more re-export of types we share,
Extensions load them only when they’re there,
The rabbit danced — dependencies lean!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: converting DoubleFloats and Quadmath to weak dependencies via package extensions, which is the primary objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch weaken-precision-deps

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/TransitionMatrices.jl`:
- Around line 79-81: The public export surface was reduced in
TransitionMatrices.jl (exports now only RotZYZ, Arb, Acb and no longer export
Double64 / Float128 / ComplexF128), so bump the package version in Project.toml
from "0.5.0" to "0.6.0" to reflect the breaking API change; open Project.toml
and update the version field to "0.6.0" (alternatively restore deprecated
aliases for Double64/Float128/ComplexF128 in src/TransitionMatrices.jl for one
cycle if you prefer not to bump).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5bdeee27-151f-4928-b13d-a35a61b05042

📥 Commits

Reviewing files that changed from the base of the PR and between 9383750 and b865ebf.

📒 Files selected for processing (9)
  • Project.toml
  • ext/TransitionMatricesDoubleFloatsExt.jl
  • ext/TransitionMatricesQuadmathExt.jl
  • src/IITM/nfold.jl
  • src/TransitionMatrices.jl
  • src/compat/index.jl
  • src/shapes/superspheroid.jl
  • test/Project.toml
  • test/compat.jl

Comment thread src/TransitionMatrices.jl
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.98%. Comparing base (9383750) to head (e0469b2).

Files with missing lines Patch % Lines
src/IITM/fourier.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #14   +/-   ##
=======================================
  Coverage   95.98%   95.98%           
=======================================
  Files          38       41    +3     
  Lines        5004     5004           
=======================================
  Hits         4803     4803           
  Misses        201      201           
Flag Coverage Δ
julia-1-macos-latest 97.07% <70.83%> (-0.05%) ⬇️
julia-1-ubuntu-latest 97.07% <70.83%> (-0.05%) ⬇️
julia-1-windows-latest 97.07% <70.83%> (-0.05%) ⬇️
julia-1.10-ubuntu-latest 95.91% <96.00%> (ø)
julia-nightly-ubuntu-latest 97.01% <70.83%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@lucifer1004 lucifer1004 force-pushed the weaken-precision-deps branch from b865ebf to aa7e3b5 Compare June 7, 2026 12:19
…xtensions)

Float64-only users no longer load DoubleFloats, Quadmath (and thus the libquadmath C
library), or GenericFFT: all three are `[weakdeps]` activated via package extensions,
pulled in only when the user does `using DoubleFloats` / `using Quadmath` / `using
GenericFFT`. Verified: `using TransitionMatrices` alone loads none of the three
extensions, and a Float64 EBCM computation runs unchanged.

These are all opt-in extras — the core (Float64, FFTW, Arblib) path never needs them:
- ext/TransitionMatricesDoubleFloatsExt.jl: Double64 — precision(Complex{Double64}),
  Arblib.set!(::Double64), and the Double64 `cbrt`/`∛` workaround.
- ext/TransitionMatricesQuadmathExt.jl: Float128 — Float128⇄Arb conversions,
  precision(ComplexF128), the instance precision(::Float128) fix (Quadmath leaves it
  unimplemented), and Arblib.set!(::Float128).
- ext/TransitionMatricesGenericFFTExt.jl: the generic-type azimuthal FFT for the n-fold
  IITM — `_iitm_fft_capable(Complex{<:AbstractFloat})`, the GenericFFT plan, and the
  generic `_apply_forward_dft!`. Without GenericFFT, Complex{Double64}/Complex{BigFloat}
  n-fold IITM gracefully falls back to the direct azimuthal sum (correct, just no FFT
  acceleration); ComplexF64 stays on FFTW and Acb on Arblib.dft! (both hard deps).

Note: weakening Quadmath alone would have no effect, because DoubleFloats lists Quadmath
in its own deps and so transitively loads it — they had to be weakened together for
Float64-only loads to drop libquadmath.

Arblib stays a hard dependency: the arbitrary-precision + special-function backbone
(gausslegendre for non-Float64, factorial(n>20) via gamma! in the Wigner-d functions —
reached even on the Float64 path — and Arb/Acb as first-class numeric types in the EBCM
Arb-matrix inversion and the IITM Acb FFT backend).

Re-exports of Double64 / Float128 / ComplexF128 are dropped (use the respective package);
Arb/Acb stay exported. Tests and the benchmark load the weak deps explicitly;
test/Project.toml and benchmark/Project.toml gain them. Full suite: 48,290 tests pass.
@lucifer1004 lucifer1004 force-pushed the weaken-precision-deps branch from aa7e3b5 to e0469b2 Compare June 7, 2026 12:20
@lucifer1004 lucifer1004 merged commit c336d9f into main Jun 7, 2026
11 of 12 checks passed
@lucifer1004 lucifer1004 deleted the weaken-precision-deps branch June 7, 2026 12:46
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