| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
| |
Fixes gh-15325
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This was not used previously due to it requiring C99. Python
itself acknowledges that it can be used (they do almost not use it
as of now), except inside header files due to C++ compatibility.
See also (Found by Eric Wieser in PR):
https://mail.python.org/pipermail/python-dev/2017-January/147154.html
and PEP 7: https://www.python.org/dev/peps/pep-0007/#c-dialect
|
|
|
|
|
|
|
|
| |
This means we no longer interpret `MemoryError` or `KeyboardInterrupt` as `keyword arg not provided`, for instance.
This function is python 3 only, hence this was difficult to do in older versions of numpy.
Inspired by https://bugs.python.org/issue35459
|
| |
|
| |
|
|
|
|
|
|
| |
Marking these arguments as const makes it easier to reason about these functions, and prevent accidental mutation.
The C99 standard (6.2.5/26 "Types") guarantees that ABI compatibility is preserved here.
|
| |
|
|
|
|
|
|
| |
I just got this error while hacking some scipy internals, and had nowhere near enough information to debug it.
This is a little closer to useful.
|
| |
|
|
|
|
|
|
| |
Using `PyMem_Del` is incorrect, it should be `PyObject_Del` here, while
this worked most of the time, it would lead to crashes at least on python
2.5 (after the reference counts were fixed)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The warning
[...]/fortranobject.c:138:18: warning: comparison of integers of different signs: 'Py_ssize_t' (aka 'long') and 'unsigned long' [-Wsign-compare]
if (size < sizeof(notalloc)) {
~~~~ ^ ~~~~~~~~~~~~~~~~
occurs 17 times when scipy is built. The change in this pull request casts
`size` to `size_t` before comparing it to `sizeof(...)`. A previous check
has already eliminated the possibility that `size` is negative, so this cast
is safe.
|
|
|
|
|
|
|
|
|
| |
User- and non-user-facing typos.
Some source typos fixes as well.
Found via `codespell`.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Up until now, f2py throw an error when arrays were declared which had
dimension of length 0. This, however, is a perfectly legal case, and in
fact occurs frequently in the context of linear algrebra. This bug was
discovered, for example, in an interface that does matrix
tridiagonalization. If the matrix is 1x1, the super- and subdiagonal are
of length 0.
Note that negative dimensions continue to produce errors although
Fortran also allows this (it always allocates to size max(0, n)).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In f2py/src/fortranobject.c, the function `check_and_fix_dimensions` does
pretty much what it says on the tin:
/*
This function fills in blanks (that are -1\'s) in dims list using
the dimensions from arr. It also checks that non-blank dims will
match with the corresponding values in arr dimensions.
*/
There are several error conditions detected by the function. In the code
before this change, when the function detected such an error, it would
print a message to stderr and return 1.
In this change, when an error is detected in `check_and_fix_dimensions`,
an exception is set.
This new feature of `check_and_fix_dimensions` is used in three places
in the function `array_from_pyobj()`.
In each case, there was an old comment of the form:
/* XXX: set exception */
In this change, the exception is now set in `check_and_fix_dimensions()`,
so those comments have been removed.
For some error conditions, the new code changes the exception that is
raised. For example, here's a scipy test before this change:
```
In [5]: from scipy.linalg import _fblas as fblas
In [6]: a = np.array([[1., 0.], [0., -2.], [2., 3.]])
In [7]: b = np.array([[0., 1.], [1., 0.], [0, 1.]])
In [8]: fblas.dsyr2k(a=a, b=b, alpha=1.0, c=np.zeros((15, 8)))
0-th dimension must be fixed to 3 but got 15
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-8-bc4d51f8d016> in <module>()
----> 1 f(a=a, b=b, alpha=1.0, c=np.zeros((15, 8)))
error: failed in converting 2nd keyword `c' of _fblas.dsyr2k to C/Fortran array
```
After this change, we get:
```
In [2]: from scipy.linalg import _fblas as fblas
In [3]: a = np.array([[1., 0.], [0., -2.], [2., 3.]])
In [4]: b = np.array([[0., 1.], [1., 0.], [0, 1.]])
In [5]: fblas.dsyr2k(a=a, b=b, alpha=1.0, c=np.zeros((15, 8)))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-bc4d51f8d016> in <module>()
----> 1 f(a=a, b=b, alpha=1.0, c=np.zeros((15, 8)))
ValueError: 0-th dimension must be fixed to 3 but got 15
```
The spurious print has been changed to the exception message, but some
potentially useful information in the old exception message has been
lost.
|
|
|
|
|
|
|
| |
When building the __doc__ string for Fortran objects, the ')'
character, closing the dimensions list, is written 1 position
beyond the allowed buffer size, instead of the current pointer in
the buffer.
|
| |
|
| |
|
| |
|
|\
| |
| | |
MAINT: remove NPY_NO_DEPRECATED_API define from f2py.
|
| |
| |
| |
| |
| | |
See gh-5281 for discussion. With the defines in, compiling scipy 0.14.0 and
below isn't possible.
|
|\ \
| |/
|/|
| | |
Reconcile C API with docs
|
| |
| |
| |
| | |
return type depends on API version used
|
| |
| |
| |
| | |
Using NPY_INTP_FMT to format PyArray_ITEMSIZE
|
|/
|
|
|
| |
This makes sure to undef at the end, and by putting the define in the
C code it ensures that the error message is understandable.
|
| |
|
| |
|
|
|
|
| |
dump_attrs functions
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Should not use sprintf, and certainly not with incorrect error checking
(gh-5044). Entirely rewritten for readability.
Also replaced a few sprintf calls that were just copying strings without
interpretation by the simpler and possibly faster strcpy/strcat.
(These need to be replaced by something more sensible.)
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The original was generating an exception message and, after aliasing,
calling PyBytes_AsString on a unicode string -> error. It was also
leaking references, although that probably didn't matter in context.
The fix here is on the cheap side, just use a C string for the message
without including the extra information about the erroneous type that
led to the exception.
No test, I don't know how to evoke this error.
Closes #2408.
|
| |
|
| |
|
| |
|
|
|
|
| |
on Python 2.x
|
|
|
|
|
|
|
| |
compatibility functions in npy_3kcompat.h to replace the current calls.
This gets rid of a number of version checks and is easier to maintain.
Fix bug that was present in the ufunc _loop1d_list_free destructor in
the python3k case.
|
| |
|
| |
|
| |
|
|
|
|
| |
after using intent(align8) in the corresponding scipy pyf files.
|