diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-06-06 14:59:50 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-06-09 17:00:47 +0200 |
commit | a6a2c601c28687e8ff8b44f5319280b20a9c3f71 (patch) | |
tree | b6066041de856eaed70c440078073ca7e65502f4 /numpy | |
parent | 0e9dccd0b8375a487b435411eb58f00d5d4a8bdc (diff) | |
download | numpy-a6a2c601c28687e8ff8b44f5319280b20a9c3f71.tar.gz |
STY: Style fixes for integer deprecation changes
Also minor changes in the documentation.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/conversion_utils.c | 22 | ||||
-rw-r--r-- | numpy/core/tests/test_deprecations.py | 3 | ||||
-rw-r--r-- | numpy/lib/shape_base.py | 2 | ||||
-rw-r--r-- | numpy/random/tests/test_regression.py | 2 |
4 files changed, 15 insertions, 14 deletions
diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c index 91243d1b7..267b502d9 100644 --- a/numpy/core/src/multiarray/conversion_utils.c +++ b/numpy/core/src/multiarray/conversion_utils.c @@ -191,7 +191,7 @@ PyArray_AxisConverter(PyObject *obj, int *axis) *axis = NPY_MAXDIMS; } else { - *axis = (int) PyArray_PyIntAsInt(obj); + *axis = PyArray_PyIntAsInt(obj); if (PyErr_Occurred()) { return NPY_FAIL; } @@ -812,7 +812,7 @@ PyArray_PyIntAsIntp(PyObject *o) #if (NPY_SIZEOF_LONGLONG > NPY_SIZEOF_INTP) if ((long_value < NPY_MIN_INTP) || (long_value > NPY_MAX_INTP)) { PyErr_SetString(PyExc_OverflowError, - "Python int too large to convert to C numpy.intp"); + "Python int too large to convert to C numpy.intp"); return -1; } #endif @@ -820,7 +820,7 @@ PyArray_PyIntAsIntp(PyObject *o) #if (NPY_SIZEOF_LONG > NPY_SIZEOF_INTP) if ((long_value < NPY_MIN_INTP) || (long_value > NPY_MAX_INTP)) { PyErr_SetString(PyExc_OverflowError, - "Python int too large to convert to C numpy.intp"); + "Python int too large to convert to C numpy.intp"); return -1; } #endif @@ -849,13 +849,15 @@ PyArray_IntpFromIndexSequence(PyObject *seq, npy_intp *vals, npy_intp maxvals) */ nd = PySequence_Length(seq); if (nd == -1) { - if (PyErr_Occurred()) PyErr_Clear(); + if (PyErr_Occurred()) { + PyErr_Clear(); + } vals[0] = PyArray_PyIntAsIntp(seq); if(vals[0] == -1) { err = PyErr_Occurred(); - if (err && - PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) { + if (err && + PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) { PyErr_SetString(PyExc_ValueError, "Maximum allowed dimension exceeded"); } @@ -876,8 +878,8 @@ PyArray_IntpFromIndexSequence(PyObject *seq, npy_intp *vals, npy_intp maxvals) vals[i] = PyArray_PyIntAsIntp(op); if(vals[i] == -1) { err = PyErr_Occurred(); - if (err && - PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) { + if (err && + PyErr_GivenExceptionMatches(err, PyExc_OverflowError)) { PyErr_SetString(PyExc_ValueError, "Maximum allowed dimension exceeded"); } @@ -892,13 +894,13 @@ PyArray_IntpFromIndexSequence(PyObject *seq, npy_intp *vals, npy_intp maxvals) /*NUMPY_API * PyArray_IntpFromSequence - * Returns the number of dimensions or -1 if an error occurred. + * Returns the number of integers converted or -1 if an error occurred. * vals must be large enough to hold maxvals */ NPY_NO_EXPORT int PyArray_IntpFromSequence(PyObject *seq, npy_intp *vals, int maxvals) { - return (int)PyArray_IntpFromIndexSequence(seq, vals, (npy_intp)maxvals); + return PyArray_IntpFromIndexSequence(seq, vals, (npy_intp)maxvals); } diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index e993494ea..2b9fcdb69 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -6,13 +6,12 @@ to document how deprecations should eventually be turned into errors. from __future__ import division, absolute_import, print_function import sys - +import operator import warnings from nose.plugins.skip import SkipTest import numpy as np from numpy.testing import dec, run_module_suite, assert_raises -import operator class _DeprecationTestCase(object): diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index f8734ea5e..c63f8140d 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -830,5 +830,5 @@ def tile(A, reps): dim_in = shape[i] dim_out = dim_in*nrep shape[i] = dim_out - n //= max(dim_in,1) + n //= max(dim_in, 1) return c.reshape(shape) diff --git a/numpy/random/tests/test_regression.py b/numpy/random/tests/test_regression.py index 891345b6a..0edf580d2 100644 --- a/numpy/random/tests/test_regression.py +++ b/numpy/random/tests/test_regression.py @@ -74,7 +74,7 @@ class TestRegression(TestCase): np.random.seed(i) m.seed(4321) # If m.state is not honored, the result will change - assert_array_equal(m.choice(10, size=10, p=np.ones(10)/10), res) + assert_array_equal(m.choice(10, size=10, p=np.ones(10)/10.), res) if __name__ == "__main__": run_module_suite() |