Skip to content

When should npyinitialize be called? #481

Closed
@JobJob

Description

@JobJob

Am I, mr user, supposed to call npyinitialize()? I'm guessing not, so this might be a bug.

Seems asscalar, and in turn convert(Int, numpy_array_element::PyObject), depends on npy_number being initialized

using PyCall
@pyimport numpy as np
pyoarr = pycall(np.array, PyObject, 1:3)
el = get(pyoarr, PyObject, 0)

@show pytypeof(el) pytypeof(PyCall.asscalar(el)) PyCall.npy_number
convert(Int, el)

outputs

pytypeof(el) = PyObject <class 'numpy.int64'>
pytypeof(PyCall.asscalar(el)) = PyObject <class 'numpy.int64'>  (should be int)
PyCall.npy_number = PyObject NULL  (shouldn't be null for asscalar to work)
ERROR: PyError (ccall(@pysym(PyInt_AsSsize_t), Int, (PyPtr,), asscalar(po))) <class 'TypeError'>
TypeError('an integer is required',)

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