summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorJarrod Millman <millman@berkeley.edu>2009-11-13 17:49:06 +0000
committerJarrod Millman <millman@berkeley.edu>2009-11-13 17:49:06 +0000
commitf07c79d3709a7f81219abc3c516fd772f469c167 (patch)
treeeaff2baba0176a7c41e749fd61b88a421dcfb188 /numpy/core/numeric.py
parent3122ee546fc0617e195aeb288abe65b9ae95d983 (diff)
downloadnumpy-f07c79d3709a7f81219abc3c516fd772f469c167.tar.gz
first set of checkins from the doc editor
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py43
1 files changed, 31 insertions, 12 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 3ca2d988f..be10d5005 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -105,29 +105,43 @@ def zeros_like(a):
def empty_like(a):
"""
- Create a new array with the same shape and type as another.
+ Return a new array with the same shape and type as a given array.
Parameters
----------
- a : ndarray
- Returned array will have same shape and type as `a`.
+ a : array_like
+ The shape and data-type of `a` define the parameters of the
+ returned array.
+
+ Returns
+ -------
+ out : ndarray
+ Array of random data with the same shape and type as `a`.
See Also
--------
- zeros_like, ones_like, zeros, ones, empty
+ ones_like : Return an array of ones with shape and type of input.
+ zeros_like : Return an array of zeros with shape and type of input.
+ empty : Return a new uninitialized array.
+ ones : Return a new array setting values to one.
+ zeros : Return a new array setting values to zero.
Notes
-----
This function does *not* initialize the returned array; to do that use
- `zeros_like` or `ones_like` instead.
+ `zeros_like` or `ones_like` instead. It may be marginally faster than the
+ functions that do set the array values.
Examples
--------
- >>> a = np.array([[1,2,3],[4,5,6]])
+ >>> a = ([1,2,3], [4,5,6]) # a is array-like
>>> np.empty_like(a)
+ array([[-1073741821, -1073741821, 3], #random
+ [ 0, 0, -1073741821]])
+ >>> a = np.array([[1., 2., 3.],[4.,5.,6.]])
>>> np.empty_like(a)
- array([[-1073741821, -1067702173, 65538], #random data
- [ 25670, 23454291, 71800]])
+ array([[ -2.00000715e+000, 1.48219694e-323, -2.00000572e+000], #random
+ [ 4.38791518e-305, -2.00000715e+000, 4.17269252e-309]])
"""
if isinstance(a, ndarray):
@@ -1661,11 +1675,11 @@ def base_repr (number, base=2, padding=0):
----------
number : scalar
The value to convert. Only positive values are handled.
- base : int
+ base : int, optional
Convert `number` to the `base` number system. The valid range is 2-36,
the default value is 2.
padding : int, optional
- Number of zeros padded on the left.
+ Number of zeros padded on the left. Default is 0 (no padding).
Returns
-------
@@ -1679,13 +1693,18 @@ def base_repr (number, base=2, padding=0):
Examples
--------
- >>> np.base_repr(3, 5)
- '3'
+ >>> np.base_repr(5)
+ '101'
>>> np.base_repr(6, 5)
'11'
>>> np.base_repr(7, base=5, padding=3)
'00012'
+ >>> np.base_repr(10, base=16)
+ 'A'
+ >>> np.base_repr(32, base=16)
+ '20'
+
"""
if number < 0:
raise ValueError("negative numbers not handled in base_repr")