summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-01-27 11:00:07 -0800
committerMark Wiebe <mwwiebe@gmail.com>2011-01-27 21:40:15 -0800
commit779b01b039e05150ec21047fc04061fab55e5f42 (patch)
treea8b6a1db994500cb14d3ccb174153268b6a75c8c /numpy
parent2a1706fd84b2970f7ab64d9d46f1c0951eac8cfa (diff)
downloadnumpy-779b01b039e05150ec21047fc04061fab55e5f42.tar.gz
WRN: iter: Fix half-float warnings, other small tweaks
Diffstat (limited to 'numpy')
-rw-r--r--numpy/add_newdocs.py6
-rw-r--r--numpy/core/src/multiarray/item_selection.c1
-rw-r--r--numpy/core/src/npymath/halffloat.c36
-rw-r--r--numpy/core/tests/test_regression.py2
-rw-r--r--numpy/ma/testutils.py5
5 files changed, 23 insertions, 27 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index c3876afb0..095eba15d 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -1239,8 +1239,7 @@ add_newdoc('numpy.core.multiarray', 'promote_types',
Returns the data type with the smallest size and smallest scalar
kind to which both ``type1`` and ``type2`` may be safely cast.
- The returned data type is always in native byte order. Promotion of
- string, unicode and void with numbers is disallowed.
+ The returned data type is always in native byte order.
Parameters
----------
@@ -1279,7 +1278,8 @@ add_newdoc('numpy.core.multiarray', 'min_scalar_type',
and smallest scalar kind which can hold its value. For non-scalar
array ``a``, returns the vector's dtype unmodified.
- As a special case, floating point values are not reduced to integers.
+ As a special case, floating point values are not demoted to integers,
+ and complex values are not demoted to floats.
Parameters
----------
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index 293b26326..bbdc6f61d 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -1755,7 +1755,6 @@ PyArray_CountNonzero(PyArrayObject *self)
data += stride;
}
- data = *dataptr;
} while(iternext(iter));
NpyIter_Deallocate(iter);
diff --git a/numpy/core/src/npymath/halffloat.c b/numpy/core/src/npymath/halffloat.c
index 79f77197b..38f52b86d 100644
--- a/numpy/core/src/npymath/halffloat.c
+++ b/numpy/core/src/npymath/halffloat.c
@@ -352,14 +352,14 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
npy_uint64 d_exp, d_sig;
npy_uint16 h_sgn, h_exp, h_sig;
- h_sgn = (d&0x8000000000000000u) >> 48;
- d_exp = (d&0x7ff0000000000000u);
+ h_sgn = (d&0x8000000000000000ULL) >> 48;
+ d_exp = (d&0x7ff0000000000000ULL);
/* Exponent overflow/NaN converts to signed inf/NaN */
- if (d_exp >= 0x40f0000000000000u) {
- if (d_exp == 0x7ff0000000000000u) {
+ if (d_exp >= 0x40f0000000000000ULL) {
+ if (d_exp == 0x7ff0000000000000ULL) {
/* Inf or NaN */
- d_sig = (d&0x000fffffffffffffu);
+ d_sig = (d&0x000fffffffffffffULL);
if (d_sig != 0) {
/* NaN - propagate the flag in the significand... */
npy_uint16 ret = (npy_uint16) (0x7c00u + (d_sig >> 42));
@@ -382,15 +382,15 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
}
/* Exponent underflow converts to subnormal half or signed zero */
- if (d_exp <= 0x3f00000000000000u) {
+ if (d_exp <= 0x3f00000000000000ULL) {
/*
* Signed zeros, subnormal floats, and floats with small
* exponents all convert to signed zero halfs.
*/
- if (d_exp < 0x3e60000000000000u) {
+ if (d_exp < 0x3e60000000000000ULL) {
#if NPY_HALF_GENERATE_UNDERFLOW
/* If d != 0, it underflowed to 0 */
- if ((d&0x7fffffffffffffffu) != 0) {
+ if ((d&0x7fffffffffffffffULL) != 0) {
npy_set_floatstatus_underflow();
}
#endif
@@ -398,7 +398,7 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
}
/* Make the subnormal significand */
d_exp >>= 52;
- d_sig = (0x0010000000000000u + (d&0x000fffffffffffffu));
+ d_sig = (0x0010000000000000ULL + (d&0x000fffffffffffffULL));
#if NPY_HALF_GENERATE_UNDERFLOW
/* If it's not exactly represented, it underflowed */
if ((d_sig&(((npy_uint64)1 << (1051 - d_exp)) - 1)) != 0) {
@@ -413,11 +413,11 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
* the remaining bit pattern is 1000...0, then we do not add one
* to the bit after the half significand. In all other cases, we do.
*/
- if ((d_sig&0x000007ffffffffffu) != 0x0000020000000000u) {
- d_sig += 0x0000020000000000u;
+ if ((d_sig&0x000007ffffffffffULL) != 0x0000020000000000ULL) {
+ d_sig += 0x0000020000000000ULL;
}
#else
- d_sig += 0x0000020000000000u;
+ d_sig += 0x0000020000000000ULL;
#endif
h_sig = (npy_uint16) (d_sig >> 42);
/*
@@ -429,20 +429,20 @@ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d)
}
/* Regular case with no overflow or underflow */
- h_exp = (npy_uint16) ((d_exp - 0x3f00000000000000u) >> 42);
+ h_exp = (npy_uint16) ((d_exp - 0x3f00000000000000ULL) >> 42);
/* Handle rounding by adding 1 to the bit beyond half precision */
- d_sig = (d&0x000fffffffffffffu);
+ d_sig = (d&0x000fffffffffffffULL);
#if NPY_HALF_ROUND_TIES_TO_EVEN
/*
* If the last bit in the half significand is 0 (already even), and
* the remaining bit pattern is 1000...0, then we do not add one
* to the bit after the half significand. In all other cases, we do.
*/
- if ((d_sig&0x000007ffffffffffu) != 0x0000020000000000u) {
- d_sig += 0x0000020000000000u;
+ if ((d_sig&0x000007ffffffffffULL) != 0x0000020000000000ULL) {
+ d_sig += 0x0000020000000000ULL;
}
#else
- d_sig += 0x0000020000000000u;
+ d_sig += 0x0000020000000000ULL;
#endif
h_sig = (npy_uint16) (d_sig >> 42);
@@ -520,7 +520,7 @@ npy_uint64 npy_halfbits_to_doublebits(npy_uint16 h)
return d_sgn + d_exp + d_sig;
case 0x7c00u: /* inf or NaN */
/* All-ones exponent and a copy of the significand */
- return d_sgn + 0x7ff0000000000000u +
+ return d_sgn + 0x7ff0000000000000ULL +
(((npy_uint64)(h&0x03ffu)) << 42);
default: /* normalized */
/* Just need to adjust the exponent and shift */
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 7c0b24953..03e1024a7 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -608,7 +608,7 @@ class TestRegression(TestCase):
assert_equal(np.dot(x,z),np.dot(x,y2))
def test_object_casting(self, level=rlevel):
- # This currently triggers the object-type version of
+ # This used to trigger the object-type version of
# the bitwise_or operation, because float64 -> object
# casting succeeds
def rs():
diff --git a/numpy/ma/testutils.py b/numpy/ma/testutils.py
index 235aac6e4..5cfc9f2ab 100644
--- a/numpy/ma/testutils.py
+++ b/numpy/ma/testutils.py
@@ -93,10 +93,7 @@ def assert_equal(actual, desired, err_msg=''):
return _assert_equal_on_sequences(actual, desired, err_msg='')
if not (isinstance(actual, ndarray) or isinstance(desired, ndarray)):
msg = build_err_msg([actual, desired], err_msg,)
- try:
- if not desired == actual:
- raise AssertionError(msg)
- except ValueError:
+ if not desired == actual:
raise AssertionError(msg)
return
# Case #4. arrays or equivalent