xlwtで報告されている
これがnumpyの動作の調査です(Python 2.7.3、numpy 1.6.2)
>>> import numpy
>>> data = [t(123456) for t in (numpy.int32, numpy.int64, numpy.float64)]
>>> [type(d) for d in data]
[<type 'numpy.int32'>, <type 'numpy.int64'>, <type 'numpy.float64'>]
>>> data
[123456, 123456, 123456.0]
>>> check_types = (int, long, float)
>>> for d in data:
... for c in check_types:
... print type(d), repr(c), isinstance(d, c)
...
<type 'numpy.int32'> <type 'int'> True
<type 'numpy.int32'> <type 'long'> False
<type 'numpy.int32'> <type 'float'> False
<type 'numpy.int64'> <type 'int'> False
<type 'numpy.int64'> <type 'long'> False
<type 'numpy.int64'> <type 'float'> False
<type 'numpy.float64'> <type 'int'> False
<type 'numpy.float64'> <type 'long'> False
<type 'numpy.float64'> <type 'float'> True
>>>
numpyは、int32とfloat64を他のソフトウェアで認識できるようにする作業を行ったようですが、int64では認識できません。
これは正しいです-python'int 'は32ビットまたは64ビットのいずれかです(
建てる; 32ビットのPythonを使用しているため、np.int32またはnp.int64のいずれかです。
それから派生します。 np.float32も、「float」のインスタンスではありません。
同様に、Pythonの「float」は特に倍精度で格納されます。
(これでさえ、numpyintsは 'int'のインスタンスではないのでばかげています
または「フロート」ですが、何でもです。)
isinstance(...、int)は、あなたがやろうとしていることに対して間違ったツールです。 もし、あんたが
numpy型を使用して一般的に整数を検出したい、最も簡単なこと
doはisinstance(...、np.integer)です。
20:15時土、2013年1月26日には、ダニエル・ヴァイアナの[email protected] :
xlwt https://github.com/python-excel/xlwt/issues/15で報告されているように:
これがnumpyの動作の調査です(Python 2.7.3、numpy 1.6.2)
import numpy >>> data = [t(123456)for t in(numpy.int32、numpy.int64、numpy.float64)] >>> [type(d)for d in data] [
、 、 ] >>> data [123456、123456、123456.0] >>> check_types =(int、long、float)>>> for d in data:... for c in check_ types:... print type(d)、 repr(c)、isinstance(d、c)..。 NS NS NS NS NS NS NS NS 本当>>> numpyがint32とfloat64を作成する作業を行ったようです
他のソフトウェアでは認識できますが、int64では認識できません。—
このメールに直接返信するか、 GitHubhttps://github.com/numpy/numpy/issues/2951で表示して
また、Python 3では、Numpyの整数型はいずれもネイティブのint型(可変サイズの整数)に関連していません。
ナサニエルは元のレポートの彼のメモで完全に正しいと思います。 Numpyはnumbers.Integral
などを継承/登録する必要があります。これはPython2.4および2.5のドロップにうまく適合します。 整数のいいねを広く認識したい場合は、とにかくnumbers.Integral
チェックする必要があります(または、同様のダックタイピング__index__
メソッドを試してみてください)。
#4547および1.9.0以降、numpyは数値モジュールに数値を登録します。 関連するものとしてこれを閉じます。
最も参考になるコメント
これは正しいです-python'int 'は32ビットまたは64ビットのいずれかです(
建てる; 32ビットのPythonを使用しているため、np.int32またはnp.int64のいずれかです。
それから派生します。 np.float32も、「float」のインスタンスではありません。
同様に、Pythonの「float」は特に倍精度で格納されます。
(これでさえ、numpyintsは 'int'のインスタンスではないのでばかげています
または「フロート」ですが、何でもです。)
isinstance(...、int)は、あなたがやろうとしていることに対して間違ったツールです。 もし、あんたが
numpy型を使用して一般的に整数を検出したい、最も簡単なこと
doはisinstance(...、np.integer)です。
20:15時土、2013年1月26日には、ダニエル・ヴァイアナの[email protected] :