Skip to content
Snippets Groups Projects
Verified Commit a90c054b authored by Tobias Hangleiter's avatar Tobias Hangleiter
Browse files

Rename deriv_order -> order

parent bb920dd4
Branches
Tags
1 merge request!175Add missing imaginary unit in fourier_space.derivative
......@@ -46,6 +46,7 @@ import numpy as np
from qutil import math
from qutil.caching import cache
from qutil.functools import wraps
from qutil.misc import deprecate_kwarg
from qutil.signal_processing._common import _parse_filter_edges
from qutil.typecheck import check_literals
from scipy import integrate
......@@ -113,7 +114,8 @@ def Id(x: _S, f: _T, *_, **__) -> Tuple[_S, _T]:
return x, f
def derivative(x, f, deriv_order: int = 0, overwrite_x: bool = False,
@deprecate_kwarg('deriv_order', 'order')
def derivative(x, f, order: int = 0, overwrite_x: bool = False,
**_) -> Tuple[np.ndarray, np.ndarray]:
r"""Compute the (anti-)derivative.
......@@ -127,8 +129,8 @@ def derivative(x, f, deriv_order: int = 0, overwrite_x: bool = False,
e^{i\omega t} \hat{f}(\omega)
.. note::
For negative ``deriv_order`` (antiderivatives), the
zero-frequency component is set to zero (due to zero-division).
For negative ``order`` (antiderivatives), the zero-frequency
component is set to zero (due to zero-division).
Parameters
----------
......@@ -136,7 +138,7 @@ def derivative(x, f, deriv_order: int = 0, overwrite_x: bool = False,
Target data.
f : array_like
Frequencies corresponding to the last axis of `x`.
deriv_order : int
order : int
The order of the derivative. If negative, the antiderivative is
computed (indefinite integral). Default: 0.
overwrite_x : bool, default False
......@@ -145,8 +147,8 @@ def derivative(x, f, deriv_order: int = 0, overwrite_x: bool = False,
x = np.array(x, copy=not overwrite_x)
f = np.asanyarray(f)
with np.errstate(invalid='ignore', divide='ignore'):
x *= (2j*np.pi*f)**deriv_order
if deriv_order < 0:
x *= (2j*np.pi*f)**order
if order < 0:
x[..., (f == 0).nonzero()] = 0
return x, f
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment