Skip to main content

SciJIT (scijit)

📖 Documentation: https://shmuel-gilbaum.github.io/SciJit/

A scipy-equivalent library callable from inside numba @njit code. scijit either wraps the same Fortran packs scipy wraps, or re-implements scipy's pure-Python routines as @njit. Results match scipy, verified against it in the test suite. Where a routine differs from scipy, its Notes say so; an argument it does not implement raises rather than silently returning something else. It pays off most when the same routine runs many times inside a compiled loop, where scipy would pay Python's per-call overhead on every iteration. Same namespaces, same names, same grouping. Not every scipy subpackage is mirrored; see docs/roadmap.md for the gaps.

scijit is not affiliated with, or endorsed by, the NumPy, SciPy or Numba projects. It is also distinct from numba-scipy, which provides numba support for a small part of scipy.special.

The approach comes from NumbaMinpack (Nicholas Wogan): reach a compiled Fortran pack from @njit through a @cfunc address and a bind(c) wrapper. scijit applies it across many packs. See docs/credits.md.

scipy's classes are called like spl(x), but a numba jitclass has no __call__, so a compiled class cannot be called that way. To mirror scipy, scijit uses scijitclass, a companion package that adds __call__ to numba jitclasses, so scijit's classes keep scipy's call syntax inside @njit. It is a standalone @jitclass replacement, usable in any numba project.

Anything numba already handles is out of scope: the numpy features numba supports, and the scipy.special subset numba-scipy covers.

scijit was written mostly with Anthropic's Claude (via Claude Code) under my direction. I set the architecture and the design choices, and every routine is verified against SciPy in the test suite.

Subpackages

Three scipy subpackages, callable from inside @njit:

  • scijit.interpolate — splines and the interpolator classes (scipy.interpolate).
  • scijit.optimize — roots, least squares, and minimization (scipy.optimize).
  • scijit.integratequad, solve_ivp, odeint, and quadrature (scipy.integrate).

Each routine's coverage, backing Fortran, and scipy parity are in the usage guides and API reference. More subpackages (fft, linalg, stats, special, and others) are in development; see docs/roadmap.md.

Install

pip install scijit

The wheels bundle the compiled Fortran, so nothing extra is needed on that path. A source install compiles each Fortran pack and requires gfortran on the PATH. Full instructions and troubleshooting are in docs/install.md.

Example

Build an interpolant once, then use it inside compiled code:

import numpy as np
from numba import njit
from scijit.interpolate import CubicSpline
from scijit.integrate import simpson

# a coarse lookup table: opacity sampled at a few log-temperatures
logT   = np.array([3.0, 4.0, 5.0, 6.0, 7.0, 8.0])
logkap = np.array([0.1, 0.4, 1.2, 2.0, 1.5, 0.6])
opacity = CubicSpline(logT, logkap)        # build the interpolant once

@njit
def mean_opacity(opacity, T_lo, T_hi, n_cells=101):
    T = np.linspace(T_lo, T_hi, n_cells)
    return simpson(opacity(T), T) / (T_hi - T_lo)   # band-averaged, all in @njit

mean_opacity(opacity, 3.5, 7.5)            # -> 1.260677088

opacity(...) evaluates the spline, from Python and inside @njit, exactly as in scipy, and simpson integrates it in the same compiled function. Build the interpolant once and reuse it. A full walkthrough is in docs/getting_started.md.

Performance: when this helps

The gain comes from removing interpreter overhead, so it shows up in large or nested loops. scipy cannot be called from @njit, so it pays the interpreter on every iteration. Reproduce with python benchmarks/<name>.py:

benchmark workload speedup
bench_pde_front.py 1-D Burgers front (MOL + LSODA), a 2-var fsolve per gridpoint per adaptive step 20-30x
bench_ode_implicit.py 400 stiff ODEs, a 3-var fsolve inside every LSODA step 15-25x
speed_grid.py 18000-cell grid: root solve + opacity spline + simpson 10-20x

Speedups are approximate and vary with machine, problem size and thread count. Intel SVML has been unsupported by numba since 0.62, which costs some vectorized performance on both sides of these comparisons.

The speedup tracks how much of each iteration is interpreter overhead, since that is what the compiler removes. It is not a claim about the numerics: where scijit calls Fortran, the same Fortran runs in both cases. numba also compiles on first call, which can make a single isolated call slower.

Rule of thumb:

  • one large vectorized call from Python (bench_where_scipy_wins.py) → use scipy. The shipped subpackages wrap the same Fortran, so a single big call ties: a 200k-point bivariate spline evaluation matched scipy within 4%, with identical results (max|diff| 0).
  • a small solve repeated many times, or nested loops → use scijit.

Documentation

The full documentation site is at https://shmuel-gilbaum.github.io/SciJit/ (Markdown sources under docs/).

  • docs/getting_started.md: a first end-to-end @njit workflow.
  • docs/install.md: wheel install, source install, and the import-failure note.
  • docs/usage/index.md: task-by-task usage guides, one tested runnable example per function.
  • docs/compatibility.md: supported versions, where agreement with scipy is bit-for-bit and where it is not, thread safety, and the prange-safety matrix.
  • docs/architecture.md: what a call passes through, from the entry points down through the callback adapter, the ctypes boundary, the return types, and the jitclass rules.
  • docs/roadmap.md: what is not covered yet, and why.
  • docs/credits.md: provenance and the upstream library and license table.

How this project started

In 2021, during my PhD in astrophysics I was running an AGN accretion-disk simulation: a large coupled ODE system where every integration step had to solve 3 nonlinear equations at each of thousands of grid points. Both the root-solving and the variable extraction that followed depended on opacity tables, read through bivariate spline interpolation.

NumbaMinpack let me do the root-finding inside @njit code, but scipy's spline evaluators cannot be called there. So I followed NumbaMinpack's approach and wrapped the two FITPACK routines I needed for the table lookups, bispev and bispeu. The runtime dropped from unusable to a few hours.

scijit is the follow-up, built together with Claude: the whole of FITPACK instead of those two routines, then the other Fortran packs behind scipy, plus @njit versions of the routines scipy writes in Python.

License & citation

scijit wraps established numerical libraries; each subpackage carries its upstream license in src/<pack>/, and the full citation list is in CITATION.cff (GitHub "Cite this repository"). Credit details are in docs/credits.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scijit-0.1.0.tar.gz (5.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

scijit-0.1.0-py3-none-win_amd64.whl (7.3 MB view details)

Uploaded Python 3Windows x86-64

scijit-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

scijit-0.1.0-py3-none-macosx_14_0_arm64.whl (6.3 MB view details)

Uploaded Python 3macOS 14.0+ ARM64

File details

Details for the file scijit-0.1.0.tar.gz.

File metadata

  • Download URL: scijit-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scijit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3cc31e74c4dea418da397a8942c34445469e73514c31753e02290fdb595775a5
MD5 e9b1c2282e59606278095b90b5a5e15c
BLAKE2b-256 600469a550eb8a2f3d31b1879aad23f71e2be8b8f6bb04c2c8f29ad487c8a1d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.0.tar.gz:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scijit-0.1.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: scijit-0.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 7.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scijit-0.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c8adae2e3b9e932bb2ca9acbf13109c3cb742a9df769ff3a76031ea5f4d37c4f
MD5 3be3cba51318acfca0799b083208412a
BLAKE2b-256 44e3035d69610043fdc9b0dbe7cedb791b2b8cdd253b305556a76480a85a1100

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.0-py3-none-win_amd64.whl:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scijit-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scijit-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 19c571a6f186d87b26b9e28cd8fbfc1e3e420a01d2fca3884de4181661eca1fd
MD5 d2ef0048e3c6d09de50bd6f8e2bcf107
BLAKE2b-256 97f15dc38803c6db237b9194f5bb4f6f617c6d076518bae8fb7cf9fb7c1d921f

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scijit-0.1.0-py3-none-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for scijit-0.1.0-py3-none-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fb3ffccb02a0323389e1eaa5a66e3c31d2ede9df264f33c4340d73f12d7cf50c
MD5 26f00b9b0c4b862e254623ddb1f49b8e
BLAKE2b-256 1788ecfa6b6d4bb7698221eeb0112e418ff64c5e846a2b98ae9d0369f0a1a926

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.0-py3-none-macosx_14_0_arm64.whl:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.1

4 files

This release

0.1.0 This release

4 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page