Registry / data / findiff

findiff

JSON →
library0.13.1pypypi✓ verified 86d ago

A Python package for finite difference derivatives in any number of dimensions. Current version 0.13.1, released on PyPI. Provides tools to compute partial derivatives of discrete functions on uniform and non-uniform grids with automatic stencil generation. Supports periodic boundary conditions and symbolic capabilities. Active development with periodic releases.

pip install findiff
INSTALL
IMPORT
SIG · FINDIFF
F
findiff
datapythonv0.13.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FinDiff
from findiff import FinDiff
from findiff.fin_diff import FinDiff
The old submodule path was deprecated in v0.11.0. Use top-level import.
Diff
from findiff import Diff
Introduced in v0.11.0 for easier definition of differential operators.
Coefficient
from findiff import Coefficient
Used to define variable coefficients on a grid.
Id
from findiff import Id
Identity operator for finite differences.
FinEq
from findiff import FinEq
Finite difference equation class.

Compute the first derivative of sin(x) on a uniform grid with second-order accuracy.

import numpy as np from findiff import FinDiff # Define a grid and a function x = np.linspace(0, 1, 5) f = np.sin(x) # First derivative (second order accuracy) d_dx = FinDiff(0, x, 1, acc=2) df_dx = d_dx(f) print(df_dx)
Debug
Known issues
breakingIn v0.11.0, the API was significantly restructured. The old `FinDiff` initialization with positional arguments may break if you relied on old defaults. The `Diff` class was introduced; stencils are now lazy.
fix
Update import to `from findiff import FinDiff, Diff`. If using old positional arguments, ensure accuracy is passed correctly. Review migration guide in changelog.
affects: >=0.11.0
gotchaThe `to_sparse()` method returns a sparse matrix only if SciPy is installed. Without it, the method raises an ImportError.
fix
Install scipy: `pip install scipy` before calling to_sparse().
affects: all
gotchaWhen using non-uniform grids, the accuracy parameter may not behave as expected for high-order derivatives. The stencil generation assumes uniform spacing by default.
fix
For non-uniform grids, consider using the `Diff` class with explicit grid coordinates. Check the documentation for `FinDiff` on non-uniform grids.
affects: all
deprecatedThe old import path `from findiff.fin_diff import FinDiff` is deprecated since v0.11.0 and may be removed in future versions.
fix
Use `from findiff import FinDiff`.
affects: >=0.11.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'findiff.fin_diff'
The module path changed in v0.11.0. Old code using `from findiff.fin_diff import FinDiff` will fail.
fix
Change import to `from findiff import FinDiff`.
ValueError: The dimension parameter must be an integer.
When initializing `FinDiff` with a tuple for grid coords (like `FinDiff(0, x, 1)`), the grid coords were passed incorrectly if x is a 1D array but you intended to use a multi-dimensional grid.
fix
Ensure the second argument is the list of grid coordinates for each dimension. For 1D, `FinDiff(0, x, 1)` is correct. For higher dimensions, pass a list of arrays, e.g., `FinDiff(0, [x, y], 1)`.
AttributeError: 'Coefficient' object has no attribute 'eval'
In older versions (<0.10.0), the Coefficient class did not have an eval method. Symbolic capabilities were introduced in v0.10.0.
fix
Upgrade findiff to 0.10.0 or later: `pip install --upgrade findiff`.
TypeError: __init__() got an unexpected keyword argument 'acc'
In v0.11.0, the `acc` parameter was renamed to `accuracy` in some contexts, or the Diff class expects different arguments.
fix
Use `accuracy` instead of `acc` when initializing FinDiff or Diff. For example: `FinDiff(0, x, 1, accuracy=2)`.
Upgrade
Version history
0.13.1latest on PyPI · released Feb 19, 2026
Audit
Dependencies
numpyrequiredCore dependency for array operations and linear algebra.
scipyoptionalOptional, used for sparse matrix support (e.g., to_sparse() method).
sympyoptionalOptional, used for symbolic differentiation capabilities introduced in v0.10.0.
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources