Skip to content

ENH: Enable assert_almost_equal to test numpy-like zero-dimensional arrays #48919

Open
@andrewgsavage

Description

@andrewgsavage

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

is_list_like was updated to return False for scalars of numpy-like array implementations. #35131 This has helped pass more extensionarray in pint-pandas .

Some tests now fail at assert_..._equal instead of at is_list_like, as isiterable in assert_almost_equal recognises pint-pandas' scalar, a Quantity, as iterable since it has an __iter__ method. The Quantity will TypeError since it isn't iterable.

cdef bint isiterable(obj):
    return hasattr(obj, '__iter__')

I've had a go at this #48920

Feature Description

Add a check for ndim == 0, like was done for is_list_like

cdef bint isiterable(obj):
    if hasattr(obj, '__iter__'):
        if hasattr(obj, "ndim") and obj.ndim == 0:
            return False
        return True
    return False

Alternative Solutions

Currently these tests are xpassed.

Additional Context

No response

Metadata

Metadata

Assignees

Labels

EnhancementNested DataData where the values are collections (lists, sets, dicts, objects, etc.).Testingpandas testing functions or related to the test suite

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions