8000 issubdtype(<whatever>, bool) malfunctions (Trac #1739) · Issue #2334 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
issubdtype(<whatever>, bool) malfunctions (Trac #1739) #2334
Closed
@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/1739 on 2011-02-10 by @pv, assigned to unknown.

Interestingly,

>>> np.issubdtype(int, np.bool_)
False
>>> np.issubdtype(str, bool)
True

The issubdtype routine apparently does not work correctly for this case (and never has). What it does is

    if issubclass_(arg2, generic):
        return issubclass(dtype(arg1).type, arg2)
    mro = dtype(arg2).type.mro()
    if len(mro) > 1:
        val = mro[1]
    else:
        val = mro[0]
    return issubclass(dtype(arg1).type, val)

Using mro[1] makes e.g. the Python int type behave as the more general signedinteger.

For bool, it's directly generic, which results into strangeness.

It might be better to hardcode the special handling of Python types, than just picking mro[1]...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0