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κ° int64κ° μλ λ€λ₯Έ μννΈμ¨μ΄μμ int32 λ° float64λ₯Ό μΈμν μ μλλ‘ νλ μμ μ μνν κ² κ°μ΅λλ€.
μ΄κ²μ μ νν©λλ€. python 'int'λ 32λΉνΈ λλ 64λΉνΈμ
λλ€(μ¬μ©μμ λ°λΌ
μ§λ€; 32λΉνΈ νμ΄μ¬μ μ¬μ©νκ³ μμΌλ―λ‘ np.int32 λλ np.int64
κ·Έκ²μμ νμλ©λλ€. np.float32λ 'float'μ μΈμ€ν΄μ€λ μλλλ€.
λ§μ°¬κ°μ§λ‘ Python 'float'μ νΉν λ°°μ λ°λλ‘ μ μ₯λ©λλ€.
(numpy intsλ 'int'μ μΈμ€ν΄μ€κ° _μλλλ€.
λλ 'νλ‘νΈ', κ·Έλ¬λ 무μμ΄λ .)
isinstance(..., int)λ μννλ €λ μμ
μ λν μλͺ»λ λꡬμ
λλ€. λ§μ½ λλΌλ©΄
numpy μ νμ μ¬μ©νμ¬ μΌλ°μ μΌλ‘ μ μλ₯Ό κ°μ§νκ³ μΆμ΅λλ€.
doλ isinstance(..., np.integer)μ
λλ€.
2013λ 1μ 26μΌ ν μμΌ μ€ν 8μ 15λΆμ Daniel Vianna [email protected]μ΄ λ€μκ³Ό κ°μ΄ μμ±νμ΅λλ€.
xlwt https://github.com/python-excel/xlwt/issues/15μ λ³΄κ³ λ λλ‘ :
λ€μμ numpy λμμ λν κ²μ¬μ λλ€(Python 2.7.3, numpy 1.6.2).
import numpy >>> λ°μ΄ν° = [t(123456) for t in (numpy.int32, numpy.int64, numpy.float64)]>>> [λ°μ΄ν°μ dμ λν μ ν(d)][
, , ]>>> 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)... μ§μ€ κ±°μ§ κ±°μ§ κ±°μ§ κ±°μ§ κ±°μ§ κ±°μ§ κ±°μ§ μ°Έ>>> numpyκ° int32 λ° float64λ₯Ό λ§λλ μμ μ μλ£ν κ² κ°μ΅λλ€.
λ€λ₯Έ μννΈμ¨μ΄μμλ μΈμν μ μμ§λ§ int64μμλ μΈμν μ μμ΅λλ€.β
μ΄ μ΄λ©μΌμ μ§μ λ΅μ₯νκ±°λ Gi tHubhttps://github.com/numpy/numpy/issues/2951μμ νμΈνμΈμ.
λν Python 3μμ Numpyμ μ μ μ νμ κΈ°λ³Έ int μ ν(κ°λ³ ν¬κΈ° μ μ)κ³Ό κ΄λ ¨μ΄ μμ΅λλ€.
λλ Nathanielμ΄ μλ λ³΄κ³ μμ λν κ·Έμ λ©λͺ¨μμ μμ ν μ ννλ€κ³ μκ°ν©λλ€. Numpyλ numbers.Integral
λ±μ μμ/λ±λ‘ν΄μΌ ν©λλ€. μ΄λ python 2.4 λ° 2.5μ μμ μ μ λ§μ΅λλ€. λꡬλ μ§ μ μ μ’μνλ κ²μ λν κ΄λ²μν μΈμμ μνλ©΄ μ΄μ¨λ numbers.Integral
νμΈν΄μΌ ν©λλ€(λλ λΉμ·ν λ νμ΄ν __index__
λ°©λ²μ μλν μ μμ).
#4547 λ° 1.9.0λΆν° numpyλ number λͺ¨λμ μ«μλ₯Ό λ±λ‘ν©λλ€. κ΄λ ¨ λ΄μ©μΌλ‘ μ’ λ£ν©λλ€.
κ°μ₯ μ μ©ν λκΈ
μ΄κ²μ μ νν©λλ€. python 'int'λ 32λΉνΈ λλ 64λΉνΈμ λλ€(μ¬μ©μμ λ°λΌ
μ§λ€; 32λΉνΈ νμ΄μ¬μ μ¬μ©νκ³ μμΌλ―λ‘ np.int32 λλ np.int64
κ·Έκ²μμ νμλ©λλ€. np.float32λ 'float'μ μΈμ€ν΄μ€λ μλλλ€.
λ§μ°¬κ°μ§λ‘ Python 'float'μ νΉν λ°°μ λ°λλ‘ μ μ₯λ©λλ€.
(numpy intsλ 'int'μ μΈμ€ν΄μ€κ° _μλλλ€.
λλ 'νλ‘νΈ', κ·Έλ¬λ 무μμ΄λ .)
isinstance(..., int)λ μννλ €λ μμ μ λν μλͺ»λ λꡬμ λλ€. λ§μ½ λλΌλ©΄
numpy μ νμ μ¬μ©νμ¬ μΌλ°μ μΌλ‘ μ μλ₯Ό κ°μ§νκ³ μΆμ΅λλ€.
doλ isinstance(..., np.integer)μ λλ€.
2013λ 1μ 26μΌ ν μμΌ μ€ν 8μ 15λΆμ Daniel Vianna [email protected]μ΄ λ€μκ³Ό κ°μ΄ μμ±νμ΅λλ€.