Add an end-to-end OLS tutorial#42
Merged
Merged
Conversation
A small ordinary-least-squares library wrapped end-to-end as a
worked example for the docs: write the Julia source, run
`build_library` to compile and generate wrappers, `pip install` the
resulting package into a clean virtualenv, and call it from Python.
The example deliberately covers the full recognized JLWInterop
vocabulary in one library — `CMatrix{Float64}` for the design
matrix, `CVector{Float64}` for response / coefficients / predictions,
`CString` for a report buffer, `JLWStatus` both as a direct return
(`predict`) and embedded in a result struct (`fit`'s `FitResult`),
and a scalar `r_squared`.
Lives at `examples/ols/`; new tutorial page `docs/src/tutorial.md`
sits between Home and Concepts in the docs nav so it acts as the
on-ramp.
Known blocker: the example *builds* end-to-end (`build_library`
succeeds and produces an importable Python package), but the
compiled `.so` cannot yet *run* its `fit` entrypoint from a host
process. `X \ y` reaches BLAS through `Base.Libc.Libdl.LazyLibrary`,
whose untyped fields and runtime-hook (`jl_libdl_dlopen_func`)
dispatch put the cold load path outside what `juliac --trim=safe`'s
static call-graph analysis can keep alive — the first BLAS call
from Python aborts with `MethodError: no method matching
Base.Libc.Libdl.dlopen(::LazyLibrary, ::UInt32)`. The tutorial is
written as if that works (and once the fix lands it will, with no
further changes here); merging it now documents the intended
workflow and gives the JLW release docs something to point at.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #42 +/- ##
==========================================
- Coverage 95.01% 94.66% -0.35%
==========================================
Files 5 5
Lines 822 825 +3
==========================================
Hits 781 781
- Misses 41 44 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
A small ordinary-least-squares library wrapped end-to-end as a worked example for the docs: write the Julia source, run
build_libraryto compile and generate wrappers,pip installthe resulting package into a clean virtualenv, and call it from Python. The example deliberately covers the full recognized JLWInterop vocabulary in one library —CMatrix{Float64}for the design matrix,CVector{Float64}for response / coefficients / predictions,CStringfor a report buffer,JLWStatusboth as a direct return (predict) and embedded in a result struct (fit'sFitResult), and a scalarr_squared.Lives at
examples/ols/; new tutorial pagedocs/src/tutorial.mdsits between Home and Concepts in the docs nav so it acts as the on-ramp.Known blocker: the example builds end-to-end (
build_librarysucceeds and produces an importable Python package), but the compiled.socannot yet run itsfitentrypoint from a host process.X \ yreaches BLAS throughBase.Libc.Libdl.LazyLibrary, whose untyped fields and runtime-hook (jl_libdl_dlopen_func) dispatch put the cold load path outside whatjuliac --trim=safe's static call-graph analysis can keep alive — the first BLAS call from Python aborts withMethodError: no method matching Base.Libc.Libdl.dlopen(::LazyLibrary, ::UInt32). The tutorial is written as if that works (and once the fix lands it will, with no further changes here); merging it now documents the intended workflow and gives the JLW release docs something to point at.