[Numpy-tickets] [NumPy] #496: ones and zeros return floats by default (not ints)
NumPy
numpy-tickets@scipy....
Thu Apr 5 17:47:04 CDT 2007
#496: ones and zeros return floats by default (not ints)
------------------------+---------------------------------------------------
Reporter: socha | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0.2 Release
Component: numpy.core | Version: none
Severity: normal | Keywords: ones zeros
------------------------+---------------------------------------------------
Despite what the documentation says, ones and zeros return floats by
default, not ints. Here's an example:
{{{
C:\Documents and Settings\socha>python
Python 2.4.3 - Enthought Edition 1.0.0 (#69, Aug 2 2006, 12:09:59) [MSC
v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.0.2'
>>> from numpy import ones
>>> ones(3)
array([ 1., 1., 1.])
>>> from numpy import zeros
>>> zeros(3)
array([ 0., 0., 0.])
>>>
}}}
Yet on page 88 of the manual, it says:
{{{
zeros (shape=, dtype=int, order=’C’)
...
ones (shape=, dtype=int, order=’C’)
}}}
which indicates that the default type is int.
- David Socha & Daniel Terhorst, UrbanSim Project, http://www.urbansim.org
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/496>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list