summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/include/numpy/npy_3kcompat.h1
-rw-r--r--numpy/core/include/numpy/random/distributions.h4
-rwxr-xr-xnumpy/f2py/rules.py12
-rw-r--r--numpy/f2py/src/fortranobject.c7
-rw-r--r--numpy/f2py/src/fortranobject.h25
-rw-r--r--numpy/linalg/linalg.py2
-rw-r--r--numpy/random/_generator.pyx16
-rw-r--r--numpy/random/src/distributions/random_mvhg_count.c4
-rw-r--r--numpy/random/src/distributions/random_mvhg_marginals.c4
9 files changed, 29 insertions, 46 deletions
diff --git a/numpy/core/include/numpy/npy_3kcompat.h b/numpy/core/include/numpy/npy_3kcompat.h
index 832bc0599..7ed263796 100644
--- a/numpy/core/include/numpy/npy_3kcompat.h
+++ b/numpy/core/include/numpy/npy_3kcompat.h
@@ -45,6 +45,7 @@ static NPY_INLINE int PyInt_Check(PyObject *op) {
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AsLong
#define PyInt_AsSsize_t PyLong_AsSsize_t
+#define PyNumber_Int PyNumber_Long
/* NOTE:
*
diff --git a/numpy/core/include/numpy/random/distributions.h b/numpy/core/include/numpy/random/distributions.h
index 0e69fc508..c474c4d14 100644
--- a/numpy/core/include/numpy/random/distributions.h
+++ b/numpy/core/include/numpy/random/distributions.h
@@ -169,14 +169,14 @@ DECLDIR void random_multinomial(bitgen_t *bitgen_state, RAND_INT_TYPE n, RAND_IN
double *pix, npy_intp d, binomial_t *binomial);
/* multivariate hypergeometric, "count" method */
-DECLDIR int random_mvhg_count(bitgen_t *bitgen_state,
+DECLDIR int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state,
int64_t total,
size_t num_colors, int64_t *colors,
int64_t nsample,
size_t num_variates, int64_t *variates);
/* multivariate hypergeometric, "marginals" method */
-DECLDIR void random_mvhg_marginals(bitgen_t *bitgen_state,
+DECLDIR void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state,
int64_t total,
size_t num_colors, int64_t *colors,
int64_t nsample,
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py
index f2f713bde..28eb9da30 100755
--- a/numpy/f2py/rules.py
+++ b/numpy/f2py/rules.py
@@ -1064,8 +1064,10 @@ if (#varname#_capi==Py_None) {
'\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,#varname#_capi);'},
"""\
\tif (capi_#varname#_tmp == NULL) {
-\t\tif (!PyErr_Occurred())
-\t\t\tPyErr_SetString(#modulename#_error,\"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array\" );
+\t\tPyObject *exc, *val, *tb;
+\t\tPyErr_Fetch(&exc, &val, &tb);
+\t\tPyErr_SetString(exc ? exc : #modulename#_error,\"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array\" );
+\t\tnpy_PyErr_ChainExceptionsCause(exc, val, tb);
\t} else {
\t\t#varname# = (#ctype# *)(PyArray_DATA(capi_#varname#_tmp));
""",
@@ -1081,8 +1083,10 @@ if (#varname#_capi==Py_None) {
\t\t\twhile ((_i = nextforcomb()))
\t\t\t\t#varname#[capi_i++] = #init#; /* fortran way */
\t\t} else {
-\t\t\tif (!PyErr_Occurred())
-\t\t\t\tPyErr_SetString(#modulename#_error,\"Initialization of #nth# #varname# failed (initforcomb).\");
+\t\t\tPyObject *exc, *val, *tb;
+\t\t\tPyErr_Fetch(&exc, &val, &tb);
+\t\t\tPyErr_SetString(exc ? exc : #modulename#_error,\"Initialization of #nth# #varname# failed (initforcomb).\");
+\t\t\tnpy_PyErr_ChainExceptionsCause(exc, val, tb);
\t\t\tf2py_success = 0;
\t\t}
\t}
diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c
index 8aa55555d..eb1050dd7 100644
--- a/numpy/f2py/src/fortranobject.c
+++ b/numpy/f2py/src/fortranobject.c
@@ -839,9 +839,10 @@ PyArrayObject* array_from_pyobj(const int type_num,
if ((intent & F2PY_INTENT_INOUT) ||
(intent & F2PY_INTENT_INPLACE) ||
(intent & F2PY_INTENT_CACHE)) {
- PyErr_SetString(PyExc_TypeError,
- "failed to initialize intent(inout|inplace|cache) "
- "array, input not an array");
+ PyErr_Format(PyExc_TypeError,
+ "failed to initialize intent(inout|inplace|cache) "
+ "array, input '%s' object is not an array",
+ Py_TYPE(obj)->tp_name);
return NULL;
}
diff --git a/numpy/f2py/src/fortranobject.h b/numpy/f2py/src/fortranobject.h
index 5d0dcf676..21f1977eb 100644
--- a/numpy/f2py/src/fortranobject.h
+++ b/numpy/f2py/src/fortranobject.h
@@ -11,30 +11,7 @@ extern "C" {
#endif
#define PY_ARRAY_UNIQUE_SYMBOL _npy_f2py_ARRAY_API
#include "numpy/arrayobject.h"
-
-/*
- * Python 3 support macros
- */
-#if PY_VERSION_HEX >= 0x03000000
-#define PyString_Check PyBytes_Check
-#define PyString_GET_SIZE PyBytes_GET_SIZE
-#define PyString_AS_STRING PyBytes_AS_STRING
-#define PyString_FromString PyBytes_FromString
-#define PyUString_FromStringAndSize PyUnicode_FromStringAndSize
-#define PyString_ConcatAndDel PyBytes_ConcatAndDel
-#define PyString_AsString PyBytes_AsString
-
-#define PyInt_Check PyLong_Check
-#define PyInt_FromLong PyLong_FromLong
-#define PyInt_AS_LONG PyLong_AsLong
-#define PyInt_AsLong PyLong_AsLong
-
-#define PyNumber_Int PyNumber_Long
-
-#else
-
-#define PyUString_FromStringAndSize PyString_FromStringAndSize
-#endif
+#include "numpy/npy_3kcompat.h"
#ifdef F2PY_REPORT_ATEXIT
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index f1b2c2228..6249a57c2 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -2355,7 +2355,7 @@ def norm(x, ord=None, axis=None, keepdims=False):
Notes
-----
- For values of ``ord <= 0``, the result is, strictly speaking, not a
+ For values of ``ord < 1``, the result is, strictly speaking, not a
mathematical 'norm', but it may still be useful for various numerical
purposes.
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx
index 74b379da8..d76cde44c 100644
--- a/numpy/random/_generator.pyx
+++ b/numpy/random/_generator.pyx
@@ -124,12 +124,12 @@ cdef extern from "numpy/random/distributions.h":
void random_multinomial(bitgen_t *bitgen_state, int64_t n, int64_t *mnix,
double *pix, np.npy_intp d, binomial_t *binomial) nogil
- int random_mvhg_count(bitgen_t *bitgen_state,
+ int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state,
int64_t total,
size_t num_colors, int64_t *colors,
int64_t nsample,
size_t num_variates, int64_t *variates) nogil
- void random_mvhg_marginals(bitgen_t *bitgen_state,
+ void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state,
int64_t total,
size_t num_colors, int64_t *colors,
int64_t nsample,
@@ -4010,18 +4010,18 @@ cdef class Generator:
if method == 'count':
with self.lock, nogil:
- result = random_mvhg_count(&self._bitgen, total,
- num_colors, colors_ptr, nsamp,
- num_variates, variates_ptr)
+ result = random_multivariate_hypergeometric_count(&self._bitgen,
+ total, num_colors, colors_ptr, nsamp,
+ num_variates, variates_ptr)
if result == -1:
raise MemoryError("Insufficent memory for multivariate_"
"hypergeometric with method='count' and "
"sum(colors)=%d" % total)
else:
with self.lock, nogil:
- random_mvhg_marginals(&self._bitgen, total,
- num_colors, colors_ptr, nsamp,
- num_variates, variates_ptr)
+ random_multivariate_hypergeometric_marginals(&self._bitgen,
+ total, num_colors, colors_ptr, nsamp,
+ num_variates, variates_ptr)
return variates
def dirichlet(self, object alpha, size=None):
diff --git a/numpy/random/src/distributions/random_mvhg_count.c b/numpy/random/src/distributions/random_mvhg_count.c
index 0c46ea417..7cbed1f9e 100644
--- a/numpy/random/src/distributions/random_mvhg_count.c
+++ b/numpy/random/src/distributions/random_mvhg_count.c
@@ -5,7 +5,7 @@
#include "numpy/random/distributions.h"
/*
- * random_mvhg_count
+ * random_multivariate_hypergeometric_count
*
* Draw variates from the multivariate hypergeometric distribution--
* the "count" algorithm.
@@ -57,7 +57,7 @@
* * the product num_variates * num_colors does not overflow
*/
-int random_mvhg_count(bitgen_t *bitgen_state,
+int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state,
int64_t total,
size_t num_colors, int64_t *colors,
int64_t nsample,
diff --git a/numpy/random/src/distributions/random_mvhg_marginals.c b/numpy/random/src/distributions/random_mvhg_marginals.c
index 7e4c24988..809d129de 100644
--- a/numpy/random/src/distributions/random_mvhg_marginals.c
+++ b/numpy/random/src/distributions/random_mvhg_marginals.c
@@ -8,7 +8,7 @@
/*
- * random_mvhg_marginals
+ * random_multivariate_hypergeometric_marginals
*
* Draw samples from the multivariate hypergeometric distribution--
* the "marginals" algorithm.
@@ -95,7 +95,7 @@
* * the product num_variates * num_colors does not overflow
*/
-void random_mvhg_marginals(bitgen_t *bitgen_state,
+void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state,
int64_t total,
size_t num_colors, int64_t *colors,
int64_t nsample,