Elliptic integrals are available in scipy.special
, but are not implemented in jax.scipy.special
, making them neither differentiable nor compatible with JAX’s JIT compilation. This package provides JAX-compatible implementations of several elliptic integrals from scipy.special
: ellipk
, ellipkm1
, and ellipe
. The results have been tested against scipy.special
to ensure accuracy and performance (see tests).
- Install
jaxellip
.
pip install jaxellip
- Import
jaxellip
in your Python code and use it.
import jaxellip
import jax.numpy as jnp
input = jnp.linspace(-10, 10, 1000)
jaxellip.ellipk(input) # Complete elliptic integral of the first kind
jaxellip.ellipkm1(input) # Complete elliptic integral of the first kind around m = 1
jaxellip.ellipe(input) # Complete elliptic integral of the second kind
The elliptic integrals in jaxellip
follow the same parameter conventions as scipy.special
. In particular, the input parameter
The function ellipkm1(m)
computes the complete elliptic integral of the first kind with argument
-
Install Hatch. The installation guide for Hatch can be found here.
Hatch is a Python project manager. It mainly allows you to define the virtual environments you need in
pyproject.toml
. Then, it takes care of the rest. Also, you don't need to install Python. Hatch will install it when you follow the steps below. -
Clone the repository.
git clone https://github.com/sinaatalay/jaxellip.git
-
Go to the
jaxellip
directory.cd jaxellip
-
Start using one of the virtual environments by activating it in the terminal.
Default development environment with Python 3.13:
hatch shell default
The same environment, but with Python 3.10 (or 3.11, 3.12, 3.13):
hatch shell test.py3.10
-
Finally, activate the virtual environment in your integrated development environment (IDE). In Visual Studio Code:
- Press
Ctrl+Shift+P
. - Type
Python: Select Interpreter
. - Select one of the virtual environments created by Hatch.
- Press
Hatch allows you to run scripts defined in pyproject.toml
.
Format the code with black
and ruff
:
hatch run format
Lint the code with ruff
:
hatch run lint
Check the types with pyright
:
hatch run check-types
Run the pre-commit hooks:
hatch run precommit
Run the tests:
hatch run test
Run the tests and generate a coverage report:
hatch run test-and-report