Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

c API documentation inconsistencies #10977

Copy link
Copy link
Open
@ndevenish

Description

@ndevenish
Issue body actions

I've been working on updating some old API-using code, and appear to have found some inconsistencies/misdocumented API calls. I was using 1.13, but these all seem to be present on the current documentation.

Reference Counting

PyArray_CastToType appears to steal the PyArray_Descr* object it is passed, but isn't documented as such. Many functions are documented as stealing this parameter, so not being there seems to imply that it won't. (I found this out the hard way whilst chasing reference count problems).

In fact, assuming that https://github.com/numpy/numpy/blob/master/numpy/core/code_generators/numpy_api.py is an accurate representation of the API, I looked over everything marked as stealing and there there are several other functions that steal but aren't documented as such:

  • PyArray_FromScalar
  • PyArray_GetField
  • PyArray_SetField
  • PyArray_CheckFromAny (though it says derived from PyArray_FromAny, which is documented as stealing the parameter, so perhaps this one doesn't count)
  • PyArray_FromArray (same)
  • PyArray_View
  • PyArray_AsCArray (except the parameter listed is documented as an integer parameter?)
  • PyArray_Zeros
  • PyArray_Empty
  • PyArray_SetUpdateIfCopyBase

(PyArray_EnsureAnyArray, PyArray_FromDimsAndDataAndDescr and PyArray_FromIter are listed as stealing, but don't appear to have documentation entries). I didn't double-check anything not listed as stealing.

Mislabelled parameters

PyArray_SIZE and PyArray_Size are labelled as both taking PyArrayObject*. However, my compiler appears to complain when PyArray_Size is used with such - needing to be cast to a PyObject* first.


If these are just missing I'm happy to update the documentation myself to add the "This function steals a reference to x" text to each function, but I'm new to the numpy code and some of the structure confuses me, so I'm not completely certain it's me that is incorrect, or if the documentation is correct but the implementation wrong (in which case, I suspect there's nothing to do but make the documentation match...)

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.