python - Cython 拒绝融合 dtype 中的 float32
问题描述
我正在尝试编写一个 Cython 函数,该函数能够使用包含 float32 的融合 dtype。但是,除非明确指定,否则它会拒绝输入。为什么 ?
例如:
cimport numpy as cnp
ctypedef fused floatdtype:
cnp.npy_float32
@cy.boundscheck(False)
@cy.wraparound(False)
cpdef void test(floatdtype smth):
print(smth)
然后在 Python 中,下面会引发“TypeError:未找到匹配的签名”错误:
import numpy as np
smth= np.float32(19700101.0)
test(smth)
然而,这工作得很好:
cimport numpy as cnp
@cy.boundscheck(False)
@cy.wraparound(False)
cpdef void test( cnp.npy_float32 smth):
print(smth)
解决方案
推荐阅读
- sql - 具有多个连接的东西查询
- azure - com.microsoft.azure.eventhubs.EventHubException:连接中止
- go - if/else 范围内的多个临时变量
- mysql - ActiveRecord 查找带有 Cyrillic 字段的元素
- mongodb - 获取 Ubuntu 服务器中的最新文件夹
- mongodb - MongoDB 无法通过命令“service mongod start”启动
- python-3.x - Keras 中的迁移学习
- go - 添加/减去两个数字字符串
- c++ - 如何使用 TBB 在单线程中运行函数
- c# - 表行服务器端单击转发器?