Skip to content

getsource yields python scalars for numpy scalars  #674

@mmckerns

Description

@mmckerns

dill.source.getsource correctly identifies numpy scalars, but doesn't create them, and instead returns the python equivalent. Should apply code to cast to the appropriate dtype.

$ python
Python 3.8.20 (default, Sep  7 2024, 10:50:45) 
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dill
>>> import numpy
>>> oo = 0
>>> ll = numpy.int64(1)
>>> print(dill.source.getsource(oo, force=True))
0

>>> print(dill.source.getsource(ll, force=True))
from numpy import int64
1

>>> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions