===========
NumPy C-API
===========
::
unsigned int
PyArray_GetNDArrayCVersion(void )
Included at the very first so not auto-grabbed and thus not labeled.
::
int
PyArray_SetNumericOps(PyObject *dict)
Set internal structure with number functions that all arrays will use
::
PyObject *
PyArray_GetNumericOps(void )
Get dictionary showing number functions that all arrays will use
::
int
PyArray_INCREF(PyArrayObject *mp)
For object arrays, increment all internal references.
::
int
PyArray_XDECREF(PyArrayObject *mp)
Decrement all internal references for object arrays.
(or arrays with object fields)
::
void
PyArray_SetStringFunction(PyObject *op, int repr)
Set the array print function to be a Python function.
::
PyArray_Descr *
PyArray_DescrFromType(int type)
Get the PyArray_Descr structure for a type.
::
PyObject *
PyArray_TypeObjectFromType(int type)
Get a typeobject from a type-number -- can return NULL.
New reference
::
char *
PyArray_Zero(PyArrayObject *arr)
Get pointer to zero of correct type for array.
::
char *
PyArray_One(PyArrayObject *arr)
Get pointer to one of correct type for array
::
PyObject *
PyArray_CastToType(PyArrayObject *arr, PyArray_Descr *dtype, int
is_f_order)
For backward compatibility
Cast an array using typecode structure.
steals reference to dtype --- cannot be NULL
This function always makes a copy of arr, even if the dtype
doesn't change.
::
int
PyArray_CastTo(PyArrayObject *out, PyArrayObject *mp)
Cast to an already created array.
::
int
PyArray_CastAnyTo(PyArrayObject *out, PyArrayObject *mp)
Cast to an already created array. Arrays don't have to be "broadcastable"
Only requirement is they have the same number of elements.
::
int
PyArray_CanCastSafely(int fromtype, int totype)
Check the type coercion rules.
::
npy_bool
PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to)
leaves reference count alone --- cannot be NULL
PyArray_CanCastTypeTo is equivalent to this, but adds a 'casting'
parameter.
::
int
PyArray_ObjectType(PyObject *op, int minimum_type)
Return the typecode of the array a Python object would be converted to
Returns the type number the result should have, or NPY_NOTYPE on error.
::
PyArray_Descr *
PyArray_DescrFromObject(PyObject *op, PyArray_Descr *mintype)
new reference -- accepts NULL for mintype
::
PyArrayObject **
PyArray_ConvertToCommonType(PyObject *op, int *retn)
::
PyArray_Descr *
PyArray_DescrFromScalar(PyObject *sc)
Return descr object from array scalar.
New reference
::
PyArray_Descr *
PyArray_DescrFromTypeObject(PyObject *type)
::
npy_intp
PyArray_Size(PyObject *op)
Compute the size of an array (in number of items)
::
PyObject *
PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
Get scalar-equivalent to a region of memory described by a descriptor.
::
PyObject *
PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode)
Get 0-dim array from scalar
0-dim array from array-scalar object
always contains a copy of the data
unless outcode is NULL, it is of void type and the referrer does
not own it either.
steals reference to outcode
::
void
PyArray_ScalarAsCtype(PyObject *scalar, void *ctypeptr)
Convert to c-type
no error checking is performed -- ctypeptr must be same type as scalar
in case of flexible type, the data is not copied
into ctypeptr which is expected to be a pointer to pointer
::
int
PyArray_CastScalarToCtype(PyObject *scalar, void
*ctypeptr, PyArray_Descr *outcode)
Cast Scalar to c-type
The output buffer must be large-enough to receive the value
Even for flexible types which is different from ScalarAsCtype
where only a reference for flexible types is returned
This may not work right on narrow builds for NumPy unicode scalars.
::
int
PyArray_CastScalarDirect(PyObject *scalar, PyArray_Descr
*indescr, void *ctypeptr, int outtype)
Cast Scalar to c-type
::
PyObject *
PyArray_ScalarFromObject(PyObject *object)
Get an Array Scalar From a Python Object
Returns NULL if unsuccessful but error is only set if another error occurred.
Currently only Numeric-like object supported.
::
PyArray_VectorUnaryFunc *
PyArray_GetCastFunc(PyArray_Descr *descr, int type_num)
Get a cast function to cast from the input descriptor to the
output type_number (must be a registered data-type).
Returns NULL if un-successful.
::
PyObject *
PyArray_FromDims(int NPY_UNUSED(nd) , int *NPY_UNUSED(d) , int
NPY_UNUSED(type) )
Deprecated, use PyArray_SimpleNew instead.
::
PyObject *
PyArray_FromDimsAndDataAndDescr(int NPY_UNUSED(nd) , int
*NPY_UNUSED(d) , PyArray_Descr
*descr, char *NPY_UNUSED(data) )
Deprecated, use PyArray_NewFromDescr instead.
::
PyObject *
PyArray_FromAny(PyObject *op, PyArray_Descr *newtype, int
min_depth, int max_depth, int flags, PyObject
*context)
Does not check for NPY_ARRAY_ENSURECOPY and NPY_ARRAY_NOTSWAPPED in flags
Steals a reference to newtype --- which can be NULL
::
PyObject *
PyArray_EnsureArray(PyObject *op)
This is a quick wrapper around
PyArray_FromAny(op, NULL, 0, 0, NPY_ARRAY_ENSUREARRAY, NULL)
that special cases Arrays and PyArray_Scalars up front
It *steals a reference* to the object
It also guarantees that the result is PyArray_Type
Because it decrefs op if any conversion needs to take place
so it can be used like PyArray_EnsureArray(some_function(...))
::
PyObject *
PyArray_EnsureAnyArray(PyObject *op)
::
PyObject *
PyArray_FromFile(FILE *fp, PyArray_Descr *dtype, npy_intp num, char
*sep)
Given a ``FILE *`` pointer ``fp``, and a ``PyArray_Descr``, return an
array corresponding to the data encoded in that file.
The reference to `dtype` is stolen (it is possible that the passed in
dtype is not held on to).
The number of elements to read is given as ``num``; if it is < 0, then
then as many as possible are read.
If ``sep`` is NULL or empty, then binary data is assumed, else
text data, with ``sep`` as the separator between elements. Whitespace in
the separator matches any length of whitespace in the text, and a match
for whitespace around the separator is added.
For memory-mapped files, use the buffer interface. No more data than
necessary is read by this routine.
::
PyObject *
PyArray_FromString(char *data, npy_intp slen, PyArray_Descr
*dtype, npy_intp num, char *sep)
Given a pointer to a string ``data``, a string length ``slen``, and
a ``PyArray_Descr``, return an array corresponding to the data
encoded in that string.
If the dtype is NULL, the default array type is used (double).
If non-null, the reference is stolen.
If ``slen`` is < 0, then the end of string is used for text data.
It is an error for ``slen`` to be < 0 for binary data (since embedded NULLs
would be the norm).
The number of elements to read is given as ``num``; if it is < 0, then
then as many as possible are read.
If ``sep`` is NULL or empty, then binary data is assumed, else
text data, with ``sep`` as the separator between elements. Whitespace in
the separator matches any length of whitespace in the text, and a match
for whitespace around the separator is added.
::
PyObject *
PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type, npy_intp
count, npy_intp offset)
::
PyObject *
PyArray_FromIter(PyObject *obj, PyArray_Descr *dtype, npy_intp count)
steals a reference to dtype (which cannot be NULL)
::
PyObject *
PyArray_Return(PyArrayObject *mp)
Return either an array or the appropriate Python object if the array
is 0d and matches a Python type.
steals reference to mp
::
PyObject *
PyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int

程序员张小妍
- 粉丝: 2w+
最新资源
- hopeKV_一款基于Golang语言开发的高性能键值存储引擎_模仿LevelDB架构设计_支持快速数据写入与读取_提供持久化存储能力_适用于嵌入式系统与分布式场景_具备高并发处理.zip
- 基于PHP和AJAX技术实现前端图片选择与Base64编码转换并通过异步请求上传至服务器端进行解码存储的完整图片上传解决方案_包含HTML文件选择控件JavaScript的File.zip
- Webpack构建后智能同步文件至七牛云存储的插件_支持并发上传与增量分析的自动化部署工具_通过多线程差异计算和哈希校验实现高效文件传输_专为前端工程化设计的云端资源管理解决方案_.zip
- 基于Bmob后端云服务实现用户信息注册与表单数据收集功能的轻量级模块化组件库_信息注册_表单提交_数据存储_用户管理_移动应用开发_快速集成_云端同步_数据校验_自动化处理_简化开.zip
- 峰谷易和团队家庭联网储能调峰设备开源项目_物联网设计竞赛参赛作品_家庭能源管理系统_储能设备调峰_智能电网优化_峰谷电价调节_可再生能源整合_家庭用电数据分析_远程监控与控制_能源.zip
- Android轻量级图片选择与裁剪库_支持从相册或相机快速选取图片_提供灵活的裁剪配置选项_包含图片压缩和异步处理功能_适用于头像上传和图片编辑场景_基于Android原生API开.zip
- 项目极简说明_一个用于存储和整理各类技术图表与架构文档的GitHub仓库_内容关键词_架构图时序图功能逻辑图系统设计图流程图数据流图网络拓扑图UML图ER图部署图.zip
- 1808577500_spcDemo_28016_1755687695572.zip
- 基于iOS10系统深度开发并集成Realm数据库封装的轻量级多线程下载管理器示例项目_支持多任务并发下载与持久化存储管理_后台下载任务保活与断点续传功能_APP进程终止后自动恢复下.zip
- 基于 baichuan-7B 微调的 C++ 面试大模型
- 基于Java开发的高性能非关系型数据库系统_借鉴关系型数据库特性支持多类型数据存储如图片二进制文件视频文本数据等_适用于需要高效处理非结构化数据的应用场景如大数据分析云存储和多媒体.zip
- HKBaiduMapDemo项目极简说明_百度地图iOS集成与CoreData数据库版本迁移完整解决方案_内容关键词_百度地图SDK集成坐标定位地理围栏路径规划离线地图数.zip
- 自我成长型Android应用_自律辅助软件_手机应用使用情况统计_任务清单管理_学习运动睡眠时间追踪_本地数据存储_无网络运行支持_后台应用监听_周期性数据统计_每日每周每月年度分.zip
- 基于HTML5Canvas的矢量图形信息存储与管理库_支持图形数据序列化与反序列化_实现Canvas绘制对象的持久化存储与动态交互_通过JavaScript对象模型记录图形属性_.zip
- 基于Vue-Electron框架构建的跨平台代码与项目管理工具_支持多语言编程环境集成智能代码高亮与自动补全实时协作编辑版本控制可视化任务进度追踪团队权限管理云端同步备.zip
- ruogu-coder_spring-boot-init_28016_1755687714038.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



- 1
- 2
前往页