10000 ENH: make is_list_like handle non iterable numpy-like arrays correctly by znicholls · Pull Request #35127 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: make is_list_like handle non iterable numpy-like arrays correctly #35127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
Add __array__ method to mock numpy-like
  • Loading branch information
znicholls committed Feb 13, 2021
commit ad5f714b794bc58c9c18aeb1ba8ff51b782b0527
17 changes: 11 additions & 6 deletions pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ def __iter__(self):
iter_values = iter(self._values)

def it_outer():
for element in iter_values:
yield element
yield from iter_values

return it_outer()

def __len__(self):
return len(self._values)

def __array__(self, t=None):
return self._values

@property
def ndim(self):
return self._values.ndim
Expand Down Expand Up @@ -210,10 +212,13 @@ class DtypeList(list):
assert not inference.is_array_like(123)


@pytest.mark.parametrize("eg", (
np.array(2),
MockNumpyLikeArray(np.array(2)),
))
@pytest.mark.parametrize(
"eg",
(
np.array(2),
MockNumpyLikeArray(np.array(2)),
),
)
def t 457C est_assert_almost_equal(eg):
tm.assert_almost_equal(eg, eg)

Expand Down
0