Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# ruff PyBispectra
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.22
rev: v0.16.0
hooks:
- id: ruff
name: ruff lint pybispectra
Expand All @@ -10,7 +10,7 @@ repos:

# ruff examples
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.22
rev: v0.16.0
hooks:
- id: ruff
name: ruff lint examples
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_compute_time_resolved.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from matplotlib import pyplot as plt
from numpy.random import RandomState

from pybispectra import WaveShape, get_example_data_paths, compute_tfr
from pybispectra import WaveShape, compute_tfr, get_example_data_paths

########################################################################################
# Background
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ ignore_roles = [
report_level = "WARNING"

[tool.ruff]
extend-exclude = ["docs", "examples/compute_*.py"]
extend-exclude = [
"docs",
"examples/compute_*.py",
"src/pybispectra/utils/_docs.py",
]
line-length = 88

[tool.ruff.lint.per-file-ignores]
Expand Down
10 changes: 5 additions & 5 deletions src/pybispectra/cfc/aac.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from pybispectra.utils._defaults import _precision
from pybispectra.utils._process import _ProcessFreqBase
from pybispectra.utils._utils import (
_compute_in_parallel,
_compute_pearsonr_2d,
_fast_find_first,
_compute_in_parallel,
)


Expand Down Expand Up @@ -61,7 +61,7 @@ class AAC(_ProcessFreqBase):

verbose : bool
Whether or not to report the progress of the processing.
""" # noqa: E501
"""

_data_precision: type = _precision.real # Real-valued TFR power

Expand All @@ -72,9 +72,9 @@ class AAC(_ProcessFreqBase):
def compute(
self,
indices: tuple[tuple[int]] | None = None,
f1s: tuple[int | float] | None = None,
f2s: tuple[int | float] | None = None,
times: tuple[int | float] | None = None,
f1s: tuple[float] | None = None,
f2s: tuple[float] | None = None,
times: tuple[float] | None = None,
n_jobs: int = 1,
) -> None:
r"""Compute AAC, averaged over epochs.
Expand Down
8 changes: 4 additions & 4 deletions src/pybispectra/cfc/pac.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class PAC(_ProcessBispectrum):
def compute(
self,
indices: tuple[tuple[int]] | None = None,
f1s: tuple[int | float] | None = None,
f2s: tuple[int | float] | None = None,
times: tuple[int | float] | None = None,
f1s: tuple[float] | None = None,
f2s: tuple[float] | None = None,
times: tuple[float] | None = None,
antisym: bool | tuple[bool] = False,
norm: bool | tuple[bool] = False,
n_jobs: int = 1,
Expand Down Expand Up @@ -181,7 +181,7 @@ def compute(
References
----------
.. footbibliography::
""" # noqa: E501
"""
self._reset_attrs()

self._sort_metrics(antisym, norm)
Expand Down
8 changes: 4 additions & 4 deletions src/pybispectra/cfc/ppc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pybispectra.utils import ResultsCFC
from pybispectra.utils._defaults import _precision
from pybispectra.utils._process import _ProcessFreqBase
from pybispectra.utils._utils import _fast_find_first, _compute_in_parallel
from pybispectra.utils._utils import _compute_in_parallel, _fast_find_first


class PPC(_ProcessFreqBase):
Expand Down Expand Up @@ -73,9 +73,9 @@ class PPC(_ProcessFreqBase):
def compute(
self,
indices: tuple[tuple[int]] | None = None,
f1s: tuple[int | float] | None = None,
f2s: tuple[int | float] | None = None,
times: tuple[int | float] | None = None,
f1s: tuple[float] | None = None,
f2s: tuple[float] | None = None,
times: tuple[float] | None = None,
n_jobs: int = 1,
) -> None:
r"""Compute PPC, averaged over epochs.
Expand Down
32 changes: 15 additions & 17 deletions src/pybispectra/general/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ class _General(_ProcessBispectrum):
def _sort_indices(self, indices: tuple[tuple[int]] | None) -> None:
"""Sort kmn channel indices inputs."""
if indices is None:
indices = tuple(
[
tuple(np.tile(range(self._n_chans), self._n_chans**2).tolist()),
tuple(
np.repeat(
np.tile(range(self._n_chans), self._n_chans), self._n_chans
).tolist()
),
tuple(np.repeat(range(self._n_chans), self._n_chans**2).tolist()),
]
indices = (
tuple(np.tile(range(self._n_chans), self._n_chans**2).tolist()),
tuple(
np.repeat(
np.tile(range(self._n_chans), self._n_chans), self._n_chans
).tolist()
),
tuple(np.repeat(range(self._n_chans), self._n_chans**2).tolist()),
)
if not isinstance(indices, tuple):
raise TypeError("`indices` must be a tuple.")
Expand Down Expand Up @@ -118,9 +116,9 @@ class Bispectrum(_General):
def compute(
self,
indices: tuple[tuple[int]] | None = None,
f1s: tuple[int | float] | None = None,
f2s: tuple[int | float] | None = None,
times: tuple[int | float] | None = None,
f1s: tuple[float] | None = None,
f2s: tuple[float] | None = None,
times: tuple[float] | None = None,
n_jobs: int = 1,
) -> None:
r"""Compute the bispectrum, averaged over epochs.
Expand Down Expand Up @@ -167,7 +165,7 @@ def compute(
.. warning::
For values of ``f1s`` higher than ``f2s`` or where ``f2s + f1s`` exceeds the
Nyquist frequency, a :obj:`numpy.nan` value is returned.
""" # noqa: E501
"""
self._reset_attrs()

self._sort_indices(indices)
Expand Down Expand Up @@ -305,9 +303,9 @@ class Threenorm(_General):
def compute(
self,
indices: tuple[tuple[int]] | None = None,
f1s: tuple[int | float] | None = None,
f2s: tuple[int | float] | None = None,
times: tuple[int | float] | None = None,
f1s: tuple[float] | None = None,
f2s: tuple[float] | None = None,
times: tuple[float] | None = None,
n_jobs: int = 1,
) -> None:
r"""Compute the threenorm, averaged over epochs.
Expand Down
19 changes: 9 additions & 10 deletions src/pybispectra/tde/tde.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Tools for handling TDE analysis."""

from collections.abc import Callable
from copy import deepcopy
from typing import Callable
from typing import ClassVar

import numpy as np
from numba import njit
Expand All @@ -10,7 +11,7 @@
from pybispectra.utils import ResultsTDE
from pybispectra.utils._defaults import _precision
from pybispectra.utils._process import _ProcessBispectrum
from pybispectra.utils._utils import _compute_in_parallel, _number_like, _int_like
from pybispectra.utils._utils import _compute_in_parallel, _int_like, _number_like


class TDE(_ProcessBispectrum):
Expand Down Expand Up @@ -97,7 +98,7 @@ class TDE(_ProcessBispectrum):
_tde_iv_nosym: np.ndarray = None
_tde_iv_antisym: np.ndarray = None

_kmn: dict = {
_kmn: ClassVar[dict] = {
"xxx": (0, 0, 0),
"yyy": (1, 1, 1),
"xyx": (0, 1, 0),
Expand All @@ -109,9 +110,9 @@ def __init__(
self,
data: np.ndarray,
freqs: np.ndarray,
sampling_freq: int | float,
sampling_freq: float,
verbose: bool = True,
) -> None: # noqa: D107
) -> None:
super().__init__(data, freqs, sampling_freq, times=None, verbose=verbose)
self._sort_fft_coeffs()

Expand All @@ -130,8 +131,8 @@ def _sort_fft_coeffs(self) -> None:
def compute(
self,
indices: tuple[tuple[int]] | None = None,
fmin: int | float | tuple[int | float] = 0.0,
fmax: int | float | tuple[int | float] = np.inf,
fmin: float | tuple[float] = 0.0,
fmax: float | tuple[float] = np.inf,
antisym: bool | tuple[bool] = False,
method: int | tuple[int] = 1,
n_jobs: int = 1,
Expand Down Expand Up @@ -284,9 +285,7 @@ def _reset_attrs(self) -> None:
self._xyz = None

def _sort_freq_bands(
self,
fmin: int | float | tuple[int | float],
fmax: int | float | tuple[int | float],
self, fmin: float | tuple[float], fmax: float | tuple[float]
) -> None:
"""Sort inputs for the frequency bounds."""
if not isinstance(fmin, _number_like + (tuple,)):
Expand Down
2 changes: 1 addition & 1 deletion src/pybispectra/utils/_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class _Precision:
Double precision (i.e., float64 and complex128) used by default.
"""

def __init__(self) -> None: # noqa: D107
def __init__(self) -> None:
self.type = "double"
self.real = np.float64
self.complex = np.complex128
Expand Down
Loading