nifty-solve
Fit very flexible linear models using Fourier bases without ever constructing the design matrix.
Install
uv add nifty-solve
If you plan to use JAX operators, you will need to use:
uv add nifty-solve[jax]
If that fails:
uv add "git+https://github.com/andycasey/nifty-solve"
Examples
1D real-valued signal with unknown uncertainties
import numpy as np
import matplotlib.pyplot as plt
from nifty_solve.operators import Finufft1DRealOperator
np.random.seed(1)
N = 128 # number of data points
K = 5 # number of Fourier modes
# Generate data
t = np.random.uniform(size=N)
y = np.random.uniform(size=3) @ np.array([t**2, t, np.ones(N)]) + np.random.normal(size=N) * 0.02
# Create a linear operator and solve the system
A = Finufft1DRealOperator(t, n_modes=K)
θ = A / y
# Make a plot
ti = np.linspace(0, 1, 1000)
Ai = Finufft1DRealOperator(ti, n_modes=K)
# Make a plot
fig, ax = plt.subplots()
ax.scatter(t, y, c="k")
ax.plot(ti, Ai @ θ)
ax.set_xlabel("t")
ax.set_ylabel("y")
[!TIP] The
A / yis just syntactic sugar for finding the least-squares solution:from scipy.sparse.linalg import lsqr θ_1 = A / y θ_2, *extras = lsqr(A, y) assert np.allclose(θ_1, θ_2)
1D real-valued signal with uncertainties
import numpy as np
import matplotlib.pyplot as plt
from nifty_solve.operators import Finufft1DRealOperator
from pylops import Diagonal
np.random.seed(1)
N = 128 # number of data points
K = 5 # number of Fourier modes
# Generate data
t = np.random.uniform(size=N)
y_true = np.random.uniform(size=3) @ np.array([t**2, t, np.ones(N)])
y_err = 0.05 + np.abs(np.random.normal(size=N) * 0.02)
Y = y_true + y_err * np.random.normal(size=N)
C_inv = Diagonal(y_err**-2)
# Create a linear operator and solve the system
A = Finufft1DRealOperator(t, n_modes=K)
θ = (A.T @ C_inv @ A) / (A.T @ C_inv @ Y)
# Make a plot
ti = np.linspace(0, 1, 1000)
Ai = Finufft1DRealOperator(ti, n_modes=K)
# Make a plot
fig, ax = plt.subplots()
ax.errorbar(t, Y, yerr=y_err, c="k", fmt="o")
ax.plot(ti, Ai @ θ)
ax.set_xlabel("t")
ax.set_ylabel("y")
Metadata
Release files for nifty-solve 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nifty_solve-0.1.2.tar.gz | 10.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nifty_solve-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.9 kB
Release files / nifty_solve-0.1.2.tar.gz
| Download URL | nifty_solve-0.1.2.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
081f8edf8a505e473a8049fdb555689261ac391737bb88308ecf90b565014bb4
|
|
BLAKE2b-256 checksum How to use checksums |
b9df9cd2b76ed57e6649cf73fac6db05e3f47bab7262f74524c6eb9ca1311cf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 31, 2025.
Transparency logRelease files / nifty_solve-0.1.2-py3-none-any.whl
| Download URL | nifty_solve-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b5f206709e03c517e53a7e19f5eded4581ff9e6281cf9f360953788836fb8d5
|
|
BLAKE2b-256 checksum How to use checksums |
62b56d0c4fefb650ce0f1ef4761498121f8b89124ddbfca97ee9e99c4be31592
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 31, 2025.
Transparency log