Python NumPy recfunctions通过TypeError连接\u

Python NumPy recfunctions通过TypeError连接\u,python,python-3.x,numpy,structured-array,Python,Python 3.x,Numpy,Structured Array,在NumPy 1.11或1.12(Python 3.5)中,尝试将“uint16”字段连接到结构化数组时,我遇到一个类型错误 这就是错误: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/lib/recfunctions.py", line 986,

在NumPy 1.11或1.12(Python 3.5)中,尝试将“uint16”字段连接到结构化数组时,我遇到一个类型错误

这就是错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/lib/recfunctions.py", line 986, in join_by
    output.sort(order=key)
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 5420, in sort
    sidx = self.filled(filler).argsort(axis=axis, kind=kind,
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 3668, in filled
    fill_value = _check_fill_value(fill_value, self.dtype)
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 470, in _check_fill_value
    fill_value = np.array(_recursive_set_fill_value(fill_value, ndtype),
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 436, in _recursive_set_fill_value
    output_value.append(np.array(fval, dtype=cdtype).item())
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
这只是一个bug吗?或者有什么方法可以防止这个问题?

这是一个bug。部分修复了它,但您似乎偶然发现了一罐与
np.ma
和子类型相关的蠕虫

至于它为什么在
float16
-
None
中起作用,是被强制进入
nan
(一个有问题的特性),而不是出错


编辑:PR被合并,这将在numpy 1.14中修复

对我来说似乎是一个bug-你应该在bug追踪器上报告它该bug更简单地显示为
bar.view(np.ma.MaskedArray).sort()
@Eric-Ah。。。因此,它可能与。很好的发现-这确实是一个很好的发现。感谢您的研究!我会看看现在是否能找到一个解决方法。虽然不是这个问题的具体答案,但为我提供了足够的信息来开发使用merge_阵列的解决方法。
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/lib/recfunctions.py", line 986, in join_by
    output.sort(order=key)
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 5420, in sort
    sidx = self.filled(filler).argsort(axis=axis, kind=kind,
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 3668, in filled
    fill_value = _check_fill_value(fill_value, self.dtype)
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 470, in _check_fill_value
    fill_value = np.array(_recursive_set_fill_value(fill_value, ndtype),
  File "/home/user/anaconda3/lib/python3.5/site-packages/numpy/ma/core.py", line 436, in _recursive_set_fill_value
    output_value.append(np.array(fval, dtype=cdtype).item())
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
import numpy as np
from numpy.lib import recfunctions as rfn
foo = np.array([(1,)],
               dtype=[('key', int)])
bar = np.array([(1,np.array([1,2,3]))],
               dtype=[('key', int), ('value', 'float16', 3)])
rfn.join_by('key', foo, bar)