-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from jorenham/complete/scipy.fftpack
complete `scipy.fftpack`
- Loading branch information
Showing
11 changed files
with
441 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
from . import basic as basic, helper as helper, pseudo_diffs as pseudo_diffs, realtransforms as realtransforms | ||
from . import basic as basic, helper as helper, pseudo_diffs as pseudo_diffs, realtransforms as realtransforms # deprecated | ||
from ._basic import * | ||
from ._helper import * | ||
from ._pseudo_diffs import * | ||
from ._realtransforms import * | ||
|
||
__all__ = [ | ||
"cc_diff", | ||
"cs_diff", | ||
"dct", | ||
"dctn", | ||
"diff", | ||
"dst", | ||
"dstn", | ||
"fft", | ||
"fft2", | ||
"fftfreq", | ||
"fftn", | ||
"fftshift", | ||
"hilbert", | ||
"idct", | ||
"idctn", | ||
"idst", | ||
"idstn", | ||
"ifft", | ||
"ifft2", | ||
"ifftn", | ||
"ifftshift", | ||
"ihilbert", | ||
"irfft", | ||
"itilbert", | ||
"next_fast_len", | ||
"rfft", | ||
"rfftfreq", | ||
"sc_diff", | ||
"shift", | ||
"ss_diff", | ||
"tilbert", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,68 @@ | ||
from scipy._typing import Untyped | ||
|
||
def fft(x: Untyped, n: Untyped | None = None, axis: int = -1, overwrite_x: bool = False) -> Untyped: ... | ||
def ifft(x: Untyped, n: Untyped | None = None, axis: int = -1, overwrite_x: bool = False) -> Untyped: ... | ||
def rfft(x: Untyped, n: Untyped | None = None, axis: int = -1, overwrite_x: bool = False) -> Untyped: ... | ||
def irfft(x: Untyped, n: Untyped | None = None, axis: int = -1, overwrite_x: bool = False) -> Untyped: ... | ||
def fftn(x: Untyped, shape: Untyped | None = None, axes: Untyped | None = None, overwrite_x: bool = False) -> Untyped: ... | ||
def ifftn(x: Untyped, shape: Untyped | None = None, axes: Untyped | None = None, overwrite_x: bool = False) -> Untyped: ... | ||
def fft2(x: Untyped, shape: Untyped | None = None, axes: Untyped = (-2, -1), overwrite_x: bool = False) -> Untyped: ... | ||
def ifft2(x: Untyped, shape: Untyped | None = None, axes: Untyped = (-2, -1), overwrite_x: bool = False) -> Untyped: ... | ||
from typing import Protocol, TypeAlias, type_check_only | ||
|
||
import numpy as np | ||
import numpy.typing as npt | ||
from numpy._typing import _ArrayLikeFloat_co, _ArrayLikeNumber_co | ||
from optype import CanIndex | ||
from scipy._typing import AnyBool, AnyShape | ||
|
||
__all__ = ["fft", "fft2", "fftn", "ifft", "ifft2", "ifftn", "irfft", "rfft"] | ||
|
||
_ArrayReal: TypeAlias = npt.NDArray[np.float32 | np.float64 | np.longdouble] # no float16 | ||
_ArrayComplex: TypeAlias = npt.NDArray[np.complex64 | np.complex128 | np.clongdouble] | ||
|
||
@type_check_only | ||
class _OrderedIndex(CanIndex, Protocol): | ||
def __lt__(self, other: CanIndex, /) -> bool: ... | ||
def __le__(self, other: CanIndex, /) -> bool: ... | ||
|
||
### | ||
|
||
def fft( | ||
x: _ArrayLikeNumber_co, | ||
n: _OrderedIndex | None = None, | ||
axis: CanIndex = -1, | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayComplex: ... | ||
def ifft( | ||
x: _ArrayLikeNumber_co, | ||
n: _OrderedIndex | None = None, | ||
axis: CanIndex = -1, | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayComplex: ... | ||
def rfft( | ||
x: _ArrayLikeFloat_co, | ||
n: _OrderedIndex | None = None, | ||
axis: CanIndex = -1, | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayReal: ... | ||
def irfft( | ||
x: _ArrayLikeFloat_co, | ||
n: _OrderedIndex | None = None, | ||
axis: CanIndex = -1, | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayReal: ... | ||
def fftn( | ||
x: _ArrayLikeNumber_co, | ||
shape: AnyShape | None = None, | ||
axes: AnyShape | None = None, | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayComplex: ... | ||
def ifftn( | ||
x: _ArrayLikeNumber_co, | ||
shape: AnyShape | None = None, | ||
axes: AnyShape | None = None, | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayComplex: ... | ||
def fft2( | ||
x: _ArrayLikeNumber_co, | ||
shape: AnyShape | None = None, | ||
axes: tuple[CanIndex, CanIndex] = (-2, -1), | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayComplex: ... | ||
def ifft2( | ||
x: _ArrayLikeNumber_co, | ||
shape: AnyShape | None = None, | ||
axes: tuple[CanIndex, CanIndex] = (-2, -1), | ||
overwrite_x: AnyBool = False, | ||
) -> _ArrayComplex: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import numpy as np | ||
import optype.numpy as onpt | ||
from numpy.fft import fftfreq, fftshift, ifftshift # noqa: ICN003 | ||
from scipy._typing import Untyped | ||
from scipy._typing import AnyInt, AnyReal | ||
|
||
__all__ = ["fftfreq", "fftshift", "ifftshift", "next_fast_len", "rfftfreq"] | ||
|
||
def rfftfreq(n: Untyped, d: float = 1.0) -> Untyped: ... | ||
def next_fast_len(target: Untyped) -> Untyped: ... | ||
def rfftfreq(n: AnyInt, d: AnyReal = 1.0) -> onpt.Array[tuple[int], np.float64]: ... | ||
def next_fast_len(target: AnyInt) -> int: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,76 @@ | ||
from scipy._typing import Untyped | ||
from typing import TypeAlias, overload | ||
|
||
import numpy as np | ||
import optype.numpy as onpt | ||
from numpy._typing import _ArrayLikeFloat_co, _ArrayLikeNumber_co | ||
from scipy._typing import AnyReal | ||
|
||
__all__ = ["cc_diff", "cs_diff", "diff", "hilbert", "ihilbert", "itilbert", "sc_diff", "shift", "ss_diff", "tilbert"] | ||
|
||
def diff(x: Untyped, order: int = 1, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
def tilbert(x: Untyped, h: Untyped, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
def itilbert(x: Untyped, h: Untyped, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
def hilbert(x: Untyped, _cache: Untyped = ...) -> Untyped: ... | ||
def ihilbert(x: Untyped) -> Untyped: ... | ||
def cs_diff(x: Untyped, a: Untyped, b: Untyped, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
def sc_diff(x: Untyped, a: Untyped, b: Untyped, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
def ss_diff(x: Untyped, a: Untyped, b: Untyped, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
def cc_diff(x: Untyped, a: Untyped, b: Untyped, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
def shift(x: Untyped, a: Untyped, period: Untyped | None = None, _cache: Untyped = ...) -> Untyped: ... | ||
# the suffix correspond to the relevant dtype charcode(s) | ||
_Vec_d: TypeAlias = onpt.Array[tuple[int], np.float64] | ||
_Vec_dD: TypeAlias = onpt.Array[tuple[int], np.float64 | np.complex128] | ||
|
||
_Cache: TypeAlias = dict[tuple[AnyReal, ...], _Vec_d] # {n: kernel} | ||
|
||
### | ||
|
||
# | ||
@overload | ||
def diff(x: _ArrayLikeFloat_co, order: int = 1, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def diff(x: _ArrayLikeNumber_co, order: int = 1, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def tilbert(x: _ArrayLikeFloat_co, h: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def tilbert(x: _ArrayLikeNumber_co, h: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def itilbert(x: _ArrayLikeFloat_co, h: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def itilbert(x: _ArrayLikeNumber_co, h: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def hilbert(x: _ArrayLikeFloat_co, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def hilbert(x: _ArrayLikeNumber_co, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def ihilbert(x: _ArrayLikeFloat_co) -> _Vec_d: ... | ||
@overload | ||
def ihilbert(x: _ArrayLikeNumber_co) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def cs_diff(x: _ArrayLikeFloat_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def cs_diff(x: _ArrayLikeNumber_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def sc_diff(x: _ArrayLikeFloat_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def sc_diff(x: _ArrayLikeNumber_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def ss_diff(x: _ArrayLikeFloat_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def ss_diff(x: _ArrayLikeNumber_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def cc_diff(x: _ArrayLikeFloat_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def cc_diff(x: _ArrayLikeNumber_co, a: AnyReal, b: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... | ||
|
||
# | ||
@overload | ||
def shift(x: _ArrayLikeFloat_co, a: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_d: ... | ||
@overload | ||
def shift(x: _ArrayLikeNumber_co, a: AnyReal, period: AnyReal | None = None, _cache: _Cache = ...) -> _Vec_dD: ... |
Oops, something went wrong.