Skip to content

ENH: [Draft] Fix issue #35131 Identify zero-dimensional duck arrays as non-iterable #44626

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

Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Add __array__ method to mock numpy-like
  • Loading branch information
znicholls authored and burnpanck committed Nov 26, 2021
commit 764a44edacb6af01900a9c42955488ee4718a326
17 changes: 11 additions & 6 deletions pandas/tests/dtypes/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,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 @@ -237,10 +239,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 test_assert_almost_equal(eg):
tm.assert_almost_equal(eg, eg)

Expand Down