summaryrefslogtreecommitdiff
path: root/numpy/lib/ufunclike.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-03-24 22:25:21 +0000
committerPauli Virtanen <pav@iki.fi>2009-03-24 22:25:21 +0000
commit7b751f66c7feb71646f0c2540aca2e5e67cd5db5 (patch)
tree3c33eab7a5933af7300ee4949c541511ebb7f915 /numpy/lib/ufunclike.py
parent940a7d3b4e6398a742873347a2f3c605ceffe481 (diff)
downloadnumpy-7b751f66c7feb71646f0c2540aca2e5e67cd5db5.tar.gz
Merge from the doc wiki
Diffstat (limited to 'numpy/lib/ufunclike.py')
-rw-r--r--numpy/lib/ufunclike.py94
1 files changed, 59 insertions, 35 deletions
diff --git a/numpy/lib/ufunclike.py b/numpy/lib/ufunclike.py
index 8ea7c6662..5dbc3f225 100644
--- a/numpy/lib/ufunclike.py
+++ b/numpy/lib/ufunclike.py
@@ -27,7 +27,7 @@ def fix(x, y=None):
See Also
--------
- floor : Round downwards
+ trunc, floor, ceil
around : Round to given number of decimals
Examples
@@ -50,48 +50,40 @@ def fix(x, y=None):
def isposinf(x, y=None):
"""
- Shows which elements of the input are positive infinity.
-
- Returns a numpy array resulting from an element-wise test for positive
- infinity.
+ Test element-wise for positive infinity, return result as bool array.
Parameters
----------
x : array_like
- The input array.
- y : array_like
- A boolean array with the same shape as `x` to store the result.
+ The input array.
+ y : array_like, optional
+ A boolean array with the same shape as `x` to store the result.
Returns
-------
y : ndarray
- A numpy boolean array with the same dimensions as the input.
- If second argument is not supplied then a numpy boolean array is returned
- with values True where the corresponding element of the input is positive
- infinity and values False where the element of the input is not positive
- infinity.
+ A boolean array with the same dimensions as the input.
+ If second argument is not supplied then a boolean array is returned
+ with values True where the corresponding element of the input is
+ positive infinity and values False where the element of the input is
+ not positive infinity.
- If second argument is supplied then an numpy integer array is returned
- with values 1 where the corresponding element of the input is positive
- positive infinity.
+ If a second argument is supplied the result is stored there. If the
+ type of that array is a numeric type the result is represented as zeros
+ and ones, if the type is boolean then as False and True.
+ The return value `y` is then a reference to that array.
See Also
--------
- isinf : Shows which elements are negative or positive infinity.
- isneginf : Shows which elements are negative infinity.
- isnan : Shows which elements are Not a Number (NaN).
- isfinite: Shows which elements are not: Not a number, positive and
- negative infinity
+ isinf, isneginf, isfinite, isnan
Notes
-----
Numpy uses the IEEE Standard for Binary Floating-Point for Arithmetic
- (IEEE 754). This means that Not a Number is not equivalent to infinity.
- Also that positive infinity is not equivalent to negative infinity. But
- infinity is equivalent to positive infinity.
+ (IEEE 754).
- Errors result if second argument is also supplied with scalar input or
- if first and second arguments have different shapes.
+ Errors result if the second argument is also supplied when `x` is a
+ scalar input, or if first and second arguments have different shapes.
Examples
--------
@@ -103,9 +95,10 @@ def isposinf(x, y=None):
array(False, dtype=bool)
>>> np.isposinf([-np.inf, 0., np.inf])
array([False, False, True], dtype=bool)
- >>> x=np.array([-np.inf, 0., np.inf])
- >>> y=np.array([2,2,2])
- >>> np.isposinf(x,y)
+
+ >>> x = np.array([-np.inf, 0., np.inf])
+ >>> y = np.array([2, 2, 2])
+ >>> np.isposinf(x, y)
array([1, 0, 0])
>>> y
array([1, 0, 0])
@@ -119,29 +112,60 @@ def isposinf(x, y=None):
def isneginf(x, y=None):
"""
- Return True where x is -infinity, and False otherwise.
+ Test element-wise for negative infinity, return result as bool array.
Parameters
----------
x : array_like
- The input array.
- y : array_like
- A boolean array with the same shape as `x` to store the result.
+ The input array.
+ y : array_like, optional
+ A boolean array with the same shape and type as `x` to store the
+ result.
Returns
-------
y : ndarray
- A boolean array where y[i] = True only if x[i] = -Inf.
+ A boolean array with the same dimensions as the input.
+ If second argument is not supplied then a numpy boolean array is
+ returned with values True where the corresponding element of the
+ input is negative infinity and values False where the element of
+ the input is not negative infinity.
+
+ If a second argument is supplied the result is stored there. If the
+ type of that array is a numeric type the result is represented as
+ zeros and ones, if the type is boolean then as False and True. The
+ return value `y` is then a reference to that array.
See Also
--------
- isposinf, isfinite
+ isinf, isposinf, isnan, isfinite
+
+ Notes
+ -----
+ Numpy uses the IEEE Standard for Binary Floating-Point for Arithmetic
+ (IEEE 754).
+
+ Errors result if the second argument is also supplied when x is a scalar
+ input, or if first and second arguments have different shapes.
Examples
--------
+ >>> np.isneginf(np.NINF)
+ array(True, dtype=bool)
+ >>> np.isneginf(np.inf)
+ array(False, dtype=bool)
+ >>> np.isneginf(np.PINF)
+ array(False, dtype=bool)
>>> np.isneginf([-np.inf, 0., np.inf])
array([ True, False, False], dtype=bool)
+ >>> x = np.array([-np.inf, 0., np.inf])
+ >>> y = np.array([2, 2, 2])
+ >>> np.isneginf(x, y)
+ array([1, 0, 0])
+ >>> y
+ array([1, 0, 0])
+
"""
if y is None:
x = nx.asarray(x)