| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
| |
This PR replaces the import of platform and a call to platform.python_implementation() with a check using sys.implementation.name to improve the numpy import time. The improvement is about 5-10 ms (system dependent).
Also see #22061
Co-authored-by: Matti Picus <matti.picus@gmail.com>
|
|
|
|
|
|
|
|
| |
structured dtypes
Identical means here that the promotion is between the same dtype *and* promoting it
does not modify any of the included dtypes *and* does not modify the offset layout
or itemsize.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This PR replaces the old gh-15509 implementing proper type promotion
for structured voids. It further fixes the casting safety to consider
casts with equivalent field number and matching order as "safe"
and if the names, titles, and offsets match as "equiv".
The change perculates into the void comparison, and since it fixes
the order, it removes the current FutureWarning there as well.
This addresses https://github.com/liberfa/pyerfa/issues/77
and replaces gh-15509 (the implementation has changed too much).
Fixes gh-15494 (and probably a few more)
Co-authored-by: Allan Haldane <allan.haldane@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
None of the functions decorated with `@recursive` actually need to close
over internal variables, so they can be lifted to become toplevel
recursive functions which avoid the need for an `@recursive` decorator.
(No change was made to the logic of any of the functions.)
As it turns out, the `@recursive` decorator adds a lot of overhead:
`python runtests.py --bench bench_io` reports a ~15-20% perf gain(!)
for `loadtxt` from this PR. (`_recursive_mask_or` seems less likely to
matter performance-wise, but I also lifted it out for good measure...
and just deleted the decorator's implementation.)
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* DEP: Deprecate 4 `ndarray.ctypes` methods
* `get_data`
* `get_shape`
* `get_strides`
* `get_as_parameter`
* TST: Add deprecation tests for 4 `ndarray.ctypes` methods
* DOC: Add a release note for the `ndarray.ctypes` method deprecation
* MAINT: Deprecate via `__getattr__` instead of `__getattribute__
Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net>
* MAINT: Deprecate the methods via proper function definitions
Co-Authored-By: Eric Wieser <425260+eric-wieser@users.noreply.github.com>
* DOC: Added a missing "the"
* DOC: typo fix: property -> properties
Co-Authored-By: Eric Wieser <425260+eric-wieser@users.noreply.github.com>
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
Co-authored-by: Eric Wieser <425260+eric-wieser@users.noreply.github.com>
|
|
|
|
|
|
| |
* removed redundant parenthesis
* use f-strings
* use dict.items in _makenames_list
|
|
|
|
| |
- chaining exceptions from None
|
|
|
|
| |
- updated %formatted string to f strings
|
|
|
|
|
| |
types (#15816)
Cleanup from the dropping of python 2
|
|
|
|
| |
This implements NEP 34.
|
|\
| |
| | |
MAINT: cleanup sys.version dependant code
|
| | |
|
|/
|
|
|
|
|
|
| |
* The instance in `_internal` is parsing tuples and integers, so `ast.literal_eval` is just fine
* The instance in `crack_fortran` is just trying to lookup a function name dynamically
* The instance in `f90mod_rules` is looking at the result of `capi_maps.getarrdims(...)['rank']`, which is always a string representation of an integer
The f2py code is still littered with `eval`, but the remaining cases were harder to reason about.
|
|
|
|
|
|
|
| |
Right now, we convert `str` objects to `bytes`, and then work with those.
Since this is a human convenience API, the input really ought to be a string.
A future patch will suggest deprecating `dtype(b'i8,i8')`, but for now it will continue to work.
|
|
|
|
|
|
|
| |
Inheriting from object was necessary for Python 2 compatibility to use
new-style classes. In Python 3, this is unnecessary as there are no
old-style classes.
Dropping the object is more idiomatic Python.
|
|
|
|
|
| |
As numpy is Python 3 only, these import statements are now unnecessary
and don't alter runtime behavior.
|
|\
| |
| | |
MAINT: reduce the number of doc build warnings
|
| | |
|
| |
| |
| |
| | |
https://bugs.python.org/issue12836
|
| | |
|
| | |
|
| | |
|
| | |
|
|/
|
|
|
| |
In _ctypes class, ctypes.cast() was called twice. It causes circular reference
for _ctypes._data due to the CPython bug https://bugs.python.org/issue12836.
|
|\ |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |\ |
|
| | |\
| | | |
| | | | |
BUG: Make `arr.ctypes.data` hold onto a reference to the underlying array
|
| | | | |
|
| | |/
| |/|
| | |
| | | |
These would previously fail in `from_buffer`, since these arrays cannot be used with the buffer protocol.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
We do this by going through ctypes.from_buffer, which keeps the object the buffer came from alive.
A bunch of hacks are required to produce a sufficiently simple buffer for ctypes to accept.
Fixes #9647
|
| |/
|/|
| |
| |
| |
| | |
In these instances the behavior isn't changed, since the for loop below acts like an if.
However, in general this is an antipattern that crashes on 0-field structured types, and is warned against in the docs.
If we remove instances of the antipattern, it will hopefully not reappear via copy-paste code.
|
|\ \
| | |
| | | |
ENH: set correct __module__ for objects in numpy's public API
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes GH-12271
Tests verify that everything in ``dir(numpy)`` either has ``__module__`` set to
``'numpy'``, or appears in an explicit whitelist of undocumented functions and
exported bulitins. These should eventually be documented or removed.
I also identified a handful of functions for which I had accidentally not setup
dispatch for with ``__array_function__`` before, because they were listed under
"ndarray methods" in ``_add_newdocs.py``. I guess that should be a lesson in
trusting code comments :).
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Relates to #12369
Traceback is now:
```
In [1]: from array import array
...: import numpy as np
...:
...: buf = array('u', ['q', 'w', 'e', 'r', 't'])
...: view = memoryview(buf)
...:
In [2]: np.array(view)
NotImplementedError: Unsupported PEP 3118 data type 'u' (UCS-2 strings)
The above exception was the direct cause of the following exception:
ValueError: 'u' is not a valid PEP 3118 buffer format string
```
|
| |
|
| |
|
| |
|
|\
| |
| | |
DOC: Move documentation from `help(ndarray.ctypes)` to `help(some_array.ctypes)`
|
| |
| |
| |
| |
| |
| | |
Method docstrings make more sense in the type itself rather than in a function that produces the type.
These docstring are pretty sub-par for numpy, but I'd prefer to leave improving them to a later commit.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fixes for unicode field names in Python 2
* Allow specifying a single comma-separated unicode string of names in np.rec.fromarrays
* Allow sorting on unicode field names.
This addresses some of the problems raised in issue #2407
* Use skipif decorator, check constructed array has correct data
* cleaner isinstance() check, have new tests to run on py3 as well
* Fix silly mistake in test
|