Skip to content

Commit

Permalink
Minor.
Browse files Browse the repository at this point in the history
  • Loading branch information
hhoppe committed Jan 14, 2025
1 parent d0d0abe commit 2526d97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
12 changes: 4 additions & 8 deletions resampler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

__docformat__ = 'google'
__version__ = '0.8.7'
__version__ = '0.8.8'
__version_info__ = tuple(int(num) for num in __version__.split('.'))

from collections.abc import Callable, Iterable, Sequence
Expand Down Expand Up @@ -52,7 +52,7 @@ def _noop_decorator(*args: Any, **kwargs: Any) -> Any:
import torch

_DType = np.dtype[Any] # (Requires Python 3.9 or TYPE_CHECKING.)
_NDArray = np.ndarray[Any, Any]
_NDArray = numpy.typing.NDArray[Any]
_DTypeLike = numpy.typing.DTypeLike
_ArrayLike = numpy.typing.ArrayLike
_TensorflowTensor: typing.TypeAlias = tf.Tensor
Expand Down Expand Up @@ -394,6 +394,7 @@ def make_sparse_matrix(

class _NumpyArraylib(_Arraylib[_NDArray]):
"""Numpy implementation of the array abstraction."""
# pylint: disable=missing-function-docstring

def __init__(self, array: _NDArray) -> None:
super().__init__(arraylib='numpy', array=np.asarray(array))
Expand Down Expand Up @@ -587,11 +588,9 @@ def make_sparse_matrix(
return tf.sparse.SparseTensor(indices, data, shape)


# pylint: disable=missing-function-docstring


class _TorchArraylib(_Arraylib[_TorchTensor]):
"""Torch implementation of the array abstraction."""
# pylint: disable=missing-function-docstring

def __init__(self, array: _NDArray) -> None:
import torch
Expand Down Expand Up @@ -704,9 +703,6 @@ def make_sparse_matrix(
# .coalesce() is unnecessary because indices/data are already merged.


# pylint: enable=missing-function-docstring


class _JaxArraylib(_Arraylib[_JaxArray]):
"""Jax implementation of the array abstraction."""

Expand Down
9 changes: 5 additions & 4 deletions resampler_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
import matplotlib.pyplot as plt
import mediapy as media # https://github.com/google/mediapy
import numpy as np
import numpy.typing
import pdoc
import scipy.signal
import skimage
Expand All @@ -359,8 +360,8 @@
# pylint: disable=protected-access, missing-function-docstring
# mypy: allow-incomplete-defs, allow-untyped-defs

_ArrayLike = resampler._ArrayLike
_NDArray = resampler._NDArray
_ArrayLike = numpy.typing.ArrayLike
_NDArray = numpy.typing.NDArray[Any]
_TensorflowTensor = resampler._TensorflowTensor
_TorchTensor = resampler._TorchTensor
_JaxArray = resampler._JaxArray
Expand Down Expand Up @@ -479,8 +480,8 @@ def must_be_int(x: _ArrayLike) -> _NDArray:
# %%
def get_rms(a: _ArrayLike, b: _ArrayLike) -> float:
"""Return the root-mean-square difference between two arrays."""
a2: _NDArray = media.to_float01(a)
b2: _NDArray = media.to_float01(b)
a2 = media.to_float01(a)
b2 = media.to_float01(b)
rms: float = np.sqrt(np.mean(np.square(a2 - b2))).item()
return rms

Expand Down
5 changes: 3 additions & 2 deletions test_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import warnings

import numpy as np
import numpy.typing
import scipy

import resampler

_ArrayLike = Any
_NDArray = Any
_ArrayLike = numpy.typing.ArrayLike
_NDArray = numpy.typing.NDArray[Any]
_TensorflowTensor = Any

# pylint: disable=protected-access, missing-function-docstring, too-many-public-methods
Expand Down

0 comments on commit 2526d97

Please sign in to comment.