Skip to content

is_int check fails for Numpy integers #86

@ThibeauWouters

Description

@ThibeauWouters

The is_int check function defined here will fail in case the argument is a Numpy integer (numpy version 1.26.4):

>>> my_int = np.int64(6)
>>> type(my_int)
<class 'numpy.int64'>
>>> isinstance(my_int, int)
False

This will interrupt a program if it generates a Numpy integer rather than regular Python integer. This can easily be resolved by importing Numpy in the utils/typechecks.py script and changing

return isinstance(x, int)

to, e.g.

return isinstance(x, (int, np.integer))

Alternatively, one can call int(x) before doing the check. I can create a PR to implement this easy fix if the developers tell me which solution would be preferable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions