Migrating from FinDiff to Diff
Starting with version 0.11 the recommended API uses the Diff class.
The old FinDiff class still works but emits a DeprecationWarning
and will be removed in a future release.
This page maps old patterns to their new equivalents.
Basic Derivatives
Old ( |
New ( |
|---|---|
|
|
|
|
|
|
Mixed Partial Derivatives
Old ( |
New ( |
|---|---|
|
|
|
|
Accuracy Control
Old ( |
New ( |
|---|---|
|
|
|
|
Coefficient and Identity
Old |
New |
|---|---|
|
|
|
|
Operator Arithmetic
Both old and new APIs support the same arithmetic. The main difference is how you express higher-order and mixed derivatives:
Old style:
from findiff import FinDiff, Coef, Id
L = Coef(2) * FinDiff(0, dx, 2) + Coef(3) * FinDiff(1, dy, 2)
New style:
from findiff import Diff
L = 2 * Diff(0, dx)**2 + 3 * Diff(1, dy)**2
Lazy Grid Setting
With Diff you can define operators without specifying the grid
and set it later:
L = Diff(0)**2 + Diff(1)**2
L.set_grid({0: dx, 1: dy})
result = L(f)
This was not possible with FinDiff.
Matrix Representation
Both APIs use the same matrix() method:
# Old
mat = FinDiff(0, dx, 2).matrix(shape)
# New
mat = (Diff(0, dx) ** 2).matrix(shape)
Suppressing the Deprecation Warning
If you need to keep using FinDiff temporarily, suppress the warning:
import warnings
warnings.filterwarnings('ignore', message='FinDiff is deprecated')