Skip to content

Commit

Permalink
bug: Enable AxesArray in FiniteDifference internals
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Stevens-Haas committed Jan 15, 2024
1 parent c93ca16 commit 690aa06
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pysindy/differentiation/finite_difference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import Union

import numpy as np
from numpy.typing import NDArray

from .base import BaseDifferentiation
from pysindy.utils.axes import AxesArray
Expand Down Expand Up @@ -218,7 +221,9 @@ def _accumulate(self, coeffs, x):
np.roll(np.arange(x.ndim), self.axis),
)

def _differentiate(self, x, t):
def _differentiate(
self, x: NDArray, t: Union[NDArray, float, list[float]]
) -> NDArray:
"""
Apply finite difference method.
"""
Expand Down Expand Up @@ -249,6 +254,7 @@ def _differentiate(self, x, t):
s[self.axis] = slice(start, stop)
interior = interior + x[tuple(s)] * coeffs[i]
else:
t = AxesArray(np.array(t), axes={"ax_time": 0})
coeffs = self._coefficients(t)
interior = self._accumulate(coeffs, x)
s[self.axis] = slice((self.n_stencil - 1) // 2, -(self.n_stencil - 1) // 2)
Expand Down

0 comments on commit 690aa06

Please sign in to comment.