Skip to content

Commit

Permalink
Minor.
Browse files Browse the repository at this point in the history
  • Loading branch information
hhoppe committed Jan 21, 2025
1 parent 2526d97 commit 8714e35
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
10 changes: 5 additions & 5 deletions resampler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
.. include:: ../README.md
"""

from __future__ import annotations

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

from collections.abc import Callable, Iterable, Sequence
Expand Down Expand Up @@ -394,6 +392,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:
Expand Down Expand Up @@ -557,7 +556,7 @@ def best_dims_order_for_resize(self, dst_shape: tuple[int, ...]) -> list[int]:
return dims

def premult_with_sparse(
self, sparse: tf.sparse.SparseTensor, num_threads: int | Literal['auto']
self, sparse: 'tf.sparse.SparseTensor', num_threads: int | Literal['auto']
) -> _TensorflowTensor:
import tensorflow as tf

Expand Down Expand Up @@ -590,6 +589,7 @@ def make_sparse_matrix(

class _TorchArraylib(_Arraylib[_TorchTensor]):
"""Torch implementation of the array abstraction."""

# pylint: disable=missing-function-docstring

def __init__(self, array: _NDArray) -> None:
Expand Down Expand Up @@ -763,7 +763,7 @@ def best_dims_order_for_resize(self, dst_shape: tuple[int, ...]) -> list[int]:
return dims

def premult_with_sparse(
self, sparse: jax.experimental.sparse.BCOO, num_threads: int | Literal['auto']
self, sparse: 'jax.experimental.sparse.BCOO', num_threads: int | Literal['auto']
) -> _JaxArray:
del num_threads
return sparse @ self.array # Calls jax.bcoo_multiply_dense().
Expand Down
9 changes: 5 additions & 4 deletions resampler_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@
"import matplotlib.pyplot as plt\n",
"import mediapy as media # https://github.com/google/mediapy\n",
"import numpy as np\n",
"import numpy.typing\n",
"import pdoc\n",
"import scipy.signal\n",
"import skimage\n",
Expand All @@ -490,8 +491,8 @@
"# pylint: disable=protected-access, missing-function-docstring\n",
"# mypy: allow-incomplete-defs, allow-untyped-defs\n",
"\n",
"_ArrayLike = resampler._ArrayLike\n",
"_NDArray = resampler._NDArray\n",
"_ArrayLike = numpy.typing.ArrayLike\n",
"_NDArray = numpy.typing.NDArray[Any]\n",
"_TensorflowTensor = resampler._TensorflowTensor\n",
"_TorchTensor = resampler._TorchTensor\n",
"_JaxArray = resampler._JaxArray\n",
Expand Down Expand Up @@ -853,8 +854,8 @@
"source": [
"def get_rms(a: _ArrayLike, b: _ArrayLike) -> float:\n",
" \"\"\"Return the root-mean-square difference between two arrays.\"\"\"\n",
" a2: _NDArray = media.to_float01(a)\n",
" b2: _NDArray = media.to_float01(b)\n",
" a2 = media.to_float01(a)\n",
" b2 = media.to_float01(b)\n",
" rms: float = np.sqrt(np.mean(np.square(a2 - b2))).item()\n",
" return rms\n",
"\n",
Expand Down
2 changes: 0 additions & 2 deletions resampler_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@

# %%
"""Python notebook demonstrating the `resampler` package."""
from __future__ import annotations

import collections
from collections.abc import Callable, Iterable, Mapping, Sequence
import concurrent.futures
Expand Down
2 changes: 0 additions & 2 deletions test_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
c:/windows/sysnative/wsl -e bash -lc 'flake8 --indent-size 2 --max-line-length=1000 --extend-ignore E302,E741,E131,E305,E402 test_resampler.py && python3 test_resampler.py'
"""
from __future__ import annotations

from collections.abc import Callable
import functools
import itertools
Expand Down

0 comments on commit 8714e35

Please sign in to comment.