Skip to content

Commit

Permalink
Minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
CeliaBenquet authored and stes committed Jun 30, 2023
1 parent d2ca04c commit 87bc21e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cebra/integrations/sklearn/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@


def _is_integer(y: Union[npt.NDArray, torch.Tensor]) -> bool:
"""Check if the values in `y` are :py:class:`int`.
"""Check if the values in ``y`` are :py:class:`int`.
Args:
y: An array, either as a :py:func:`numpy.array` or a :py:class:`torch.Tensor`.
Returns:
`True` if `y` contains :py:class:`int`.
``True`` if ``y`` contains :py:class:`int`.
"""
return (isinstance(y, np.ndarray) and np.issubdtype(y.dtype, np.integer)
) or (isinstance(y, torch.Tensor) and
(not torch.is_floating_point(y) and not torch.is_complex(y)))


def _is_floating(y: Union[npt.NDArray, torch.Tensor]) -> bool:
"""Check if the values in `y` are :py:class:`int`.
"""Check if the values in ``y`` are :py:class:`int`.
Note:
There is no `torch` method to check that the `dtype` of a :py:class:`torch.Tensor`
There is no ``torch`` method to check that the ``dtype`` of a :py:class:`torch.Tensor`
is a :py:class:`float`, consequently, we check that it is not :py:class:`int` nor
:py:class:`complex`.
Args:
y: An array, either as a :py:func:`numpy.array` or a :py:class:`torch.Tensor`.
Returns:
`True` if `y` contains :py:class:`float`.
``True`` if ``y`` contains :py:class:`float`.
"""

return (isinstance(y, np.ndarray) and
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sklearn_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ def test_dtype_checker():
assert cebra_sklearn_decoder._is_floating(torch.Tensor([4.5]))
assert cebra_sklearn_decoder._is_integer(torch.LongTensor([4]))
assert cebra_sklearn_decoder._is_floating(np.array([4.5]))
assert cebra_sklearn_decoder._is_integer(np.array([4]))
assert cebra_sklearn_decoder._is_integer(np.array([4]))

0 comments on commit 87bc21e

Please sign in to comment.