Skip to content
Open
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
3 changes: 2 additions & 1 deletion etils/enp/numpy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from etils import epy
import numpy as np
import pandas as pd

if typing.TYPE_CHECKING:
from etils.enp.typing import Array
Expand All @@ -42,7 +43,7 @@

# When `strict=False` (in `get_xnp`, `is_array`,...), those types are also
# accepted:
_ARRAY_LIKE_TYPES = (int, bool, float, list, tuple)
_ARRAY_LIKE_TYPES = (int, bool, float, list, tuple, pd.Series)

# During the class construction, pytype fails because of name conflict between
# the `np` `@property` and the module.
Expand Down
2 changes: 2 additions & 0 deletions etils/enp/numpy_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import jax
import jax.numpy as jnp
import numpy as np
import pandas as pd
import pytest
import tensorflow as tf
import tensorflow.experimental.numpy as tnp
Expand Down Expand Up @@ -78,6 +79,7 @@ def test_lazy():
assert lazy.get_xnp(np.array([123])) is np
assert lazy.get_xnp(torch.Tensor([123])) is torch
assert lazy.get_xnp([123], strict=False) is np
assert lazy.get_xnp(pd.Series([123]), strict=False)

with pytest.raises(TypeError, match='Cannot infer the numpy'):
lazy.get_xnp([123])
Expand Down