{"id":26991,"library":"findiff","title":"findiff","description":"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.","status":"active","version":"0.13.1","language":"python","source_language":"en","source_url":"https://github.com/maroba/findiff","tags":["finite-differences","numerical-differentiation","partial-differential-equations","scientific-computing","numpy"],"install":[{"cmd":"pip install findiff","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for array operations and linear algebra.","package":"numpy","optional":false},{"reason":"Optional, used for sparse matrix support (e.g., to_sparse() method).","package":"scipy","optional":true},{"reason":"Optional, used for symbolic differentiation capabilities introduced in v0.10.0.","package":"sympy","optional":true}],"imports":[{"note":"The old submodule path was deprecated in v0.11.0. Use top-level import.","wrong":"from findiff.fin_diff import FinDiff","symbol":"FinDiff","correct":"from findiff import FinDiff"},{"note":"Introduced in v0.11.0 for easier definition of differential operators.","wrong":null,"symbol":"Diff","correct":"from findiff import Diff"},{"note":"Used to define variable coefficients on a grid.","wrong":null,"symbol":"Coefficient","correct":"from findiff import Coefficient"},{"note":"Identity operator for finite differences.","wrong":null,"symbol":"Id","correct":"from findiff import Id"},{"note":"Finite difference equation class.","wrong":null,"symbol":"FinEq","correct":"from findiff import FinEq"}],"quickstart":{"code":"import numpy as np\nfrom findiff import FinDiff\n\n# Define a grid and a function\nx = np.linspace(0, 1, 5)\nf = np.sin(x)\n\n# First derivative (second order accuracy)\nd_dx = FinDiff(0, x, 1, acc=2)\ndf_dx = d_dx(f)\nprint(df_dx)","lang":"python","description":"Compute the first derivative of sin(x) on a uniform grid with second-order accuracy."},"warnings":[{"fix":"Update import to `from findiff import FinDiff, Diff`. If using old positional arguments, ensure accuracy is passed correctly. Review migration guide in changelog.","message":"In 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.","severity":"breaking","affected_versions":">=0.11.0"},{"fix":"Install scipy: `pip install scipy` before calling to_sparse().","message":"The `to_sparse()` method returns a sparse matrix only if SciPy is installed. Without it, the method raises an ImportError.","severity":"gotcha","affected_versions":"all"},{"fix":"For non-uniform grids, consider using the `Diff` class with explicit grid coordinates. Check the documentation for `FinDiff` on non-uniform grids.","message":"When using non-uniform grids, the accuracy parameter may not behave as expected for high-order derivatives. The stencil generation assumes uniform spacing by default.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from findiff import FinDiff`.","message":"The old import path `from findiff.fin_diff import FinDiff` is deprecated since v0.11.0 and may be removed in future versions.","severity":"deprecated","affected_versions":">=0.11.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change import to `from findiff import FinDiff`.","cause":"The module path changed in v0.11.0. Old code using `from findiff.fin_diff import FinDiff` will fail.","error":"ModuleNotFoundError: No module named 'findiff.fin_diff'"},{"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)`.","cause":"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.","error":"ValueError: The dimension parameter must be an integer."},{"fix":"Upgrade findiff to 0.10.0 or later: `pip install --upgrade findiff`.","cause":"In older versions (<0.10.0), the Coefficient class did not have an eval method. Symbolic capabilities were introduced in v0.10.0.","error":"AttributeError: 'Coefficient' object has no attribute 'eval'"},{"fix":"Use `accuracy` instead of `acc` when initializing FinDiff or Diff. For example: `FinDiff(0, x, 1, accuracy=2)`.","cause":"In v0.11.0, the `acc` parameter was renamed to `accuracy` in some contexts, or the Diff class expects different arguments.","error":"TypeError: __init__() got an unexpected keyword argument 'acc'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}