summaryrefslogtreecommitdiff
path: root/numpy/core/_internal.py
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Rename to DTypePromotionErrorSebastian Berg2022-12-021-3/+3
|
* ENH: Add an InvalidPromotion exceptionSebastian Berg2022-12-011-2/+5
|
* PERF: Eliminate slow check for pypy during numpy import (#22163)Pieter Eendebak2022-08-231-2/+1
| | | | | | | 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>
* MAINT,ENH: Adjust metadata preservation, preserving it for identical ↵Sebastian Berg2022-05-091-1/+16
| | | | | | | | 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.
* API: Fix structured dtype cast-safety, promotion, and comparisonSebastian Berg2022-05-091-1/+41
| | | | | | | | | | | | | | | | | 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>
* PERF: Avoid using `@recursive`.Antony Lee2021-08-031-31/+0
| | | | | | | | | | | | | 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.)
* DOC: Add documentation for `np.ctypeslib.c_intp`Bas van Beek2021-06-221-5/+4
|
* DOC: Add the `axis` and `axes` keywords to gufunc signaturesBas van Beek2021-05-201-3/+5
|
* DEP: Deprecate 4 `ndarray.ctypes` methods (#19031)Bas van Beek2021-05-181-5/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* STY: core._internaldanielhrisca2020-08-111-18/+16
| | | | | | * removed redundant parenthesis * use f-strings * use dict.items in _makenames_list
* MAINT: Chaining exceptions in numpy/core/_internal.pytabhi07972020-07-041-5/+5
| | | | - chaining exceptions from None
* MAINT: Chaining exceptions in numpy/core/_internal.pytabhi07972020-07-041-6/+7
| | | | - updated %formatted string to f strings
* MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-261-2/+1
| | | | | types (#15816) Cleanup from the dropping of python 2
* NEP: issue deprecation warning when creating ragged array (NEP 34)Matti Picus2020-01-211-1/+1
| | | | This implements NEP 34.
* Merge pull request #15307 from sethtroisi/sys_version_preMatti Picus2020-01-161-1/+0
|\ | | | | MAINT: cleanup sys.version dependant code
| * MAINT: cleanup sys.version dependant codeSeth Troisi2020-01-121-1/+0
| |
* | MAINT: Eliminate some calls to `eval`Eric Wieser2020-01-111-1/+2
|/ | | | | | | | * 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.
* MAINT: Work with unicode strings in `dtype('i8,i8')`Eric Wieser2020-01-111-14/+14
| | | | | | | 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.
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-6/+6
| | | | | | | 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.
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* Merge pull request #14699 from mattip/doc-warningsRalf Gommers2019-10-181-1/+1
|\ | | | | MAINT: reduce the number of doc build warnings
| * DOC: no `data_as` reference is availablemattip2019-10-151-1/+1
| |
* | MAINT: Refer numpy issue #13808 to upstream CPython bug ↵Qiming Sun2019-10-051-1/+2
| | | | | | | | https://bugs.python.org/issue12836
* | TEST: Fix broken pypy ctypes testQiming Sun2019-09-191-24/+0
| |
* | MAINT: Remove _get_void_ptr functionQiming Sun2019-09-151-17/+4
| |
* | BUG: typo in _ctypes classQiming Sun2019-09-101-1/+1
| |
* | BUG: _ctypes._as_parameter_ did not hold the array objectQiming Sun2019-09-101-1/+1
| |
* | BUG: Fix _ctypes class cirular reference. (#13808)Qiming Sun2019-09-101-3/+4
|/ | | | | 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.
* Merge remote-tracking branch 'upstream/master' into fix-if-fieldsEric Wieser2019-08-191-41/+98
|\
| * BUG: test and fix np.dtype('i,L')kirienko2019-04-291-1/+1
| |
| * MAINT: use openblas, gfortran, tweak azure and comment mro (from review)mattip2019-04-211-0/+2
| |
| * TEST: update for PyPymattip2019-04-171-1/+7
| |
| * MAINT: Move exceptions from core._internal to core._exceptionsEric Wieser2019-04-131-24/+0
| |
| * ENH: port __array_function__ overrides to CStephan Hoyer2018-12-191-0/+7
| |
| * Merge commit '7ce7382d5eacbc3da026289483a841184a609928' into fix-9647Eric Wieser2018-12-161-0/+14
| |\
| | * Merge pull request #11721 from eric-wieser/fix-9647Charles Harris2018-12-161-15/+58
| | |\ | | | | | | | | BUG: Make `arr.ctypes.data` hold onto a reference to the underlying array
| * | | BUG: Fix regression in _missing_ctypes.cast that is not tested in CIEric Wieser2018-12-161-1/+1
| | | |
| * | | BUG: Ensure that arr.ctypes works on arrays with overlapping fieldsEric Wieser2018-12-161-8/+31
| | |/ | |/| | | | | | | These would previously fail in `from_buffer`, since these arrays cannot be used with the buffer protocol.
| * | MAINT: Use property decorators for clarityEric Wieser2018-11-041-8/+18
| | |
| * | BUG: Make `arr.ctypes.data` hold onto a reference to the underlying arrayEric Wieser2018-10-301-7/+40
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | | MAINT: Test names against None for consistencyEric Wieser2019-08-191-1/+1
| |/ |/| | | | | | | | | 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.
* | Merge pull request #12382 from shoyer/finish-set-moduleCharles Harris2018-11-141-0/+3
|\ \ | | | | | | ENH: set correct __module__ for objects in numpy's public API
| * | ENH: set correct __module__ for objects in numpy's public APIStephan Hoyer2018-11-131-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | 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 :).
* | MAINT: Improve error message for legal but unsupported PEP3118 typesEric Wieser2018-11-131-0/+11
|/ | | | | | | | | | | | | | | | | | | | | | 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 ```
* MAINT: Extract `_is_from_ctypes` to a header so that it can be sharedEric Wieser2018-10-251-3/+3
|
* MAINT: remove unused importsEmil Hessman2018-09-291-2/+1
|
* MAINT: refactor design of recursive closures (#11910)Matti Picus2018-09-161-1/+33
|
* Merge pull request #11765 from eric-wieser/ctypes-docsMatti Picus2018-08-181-3/+42
|\ | | | | DOC: Move documentation from `help(ndarray.ctypes)` to `help(some_array.ctypes)`
| * DOC: Move documentation from `help(ndarray.ctypes)` to `help(some_array.ctypes)`Eric Wieser2018-08-171-3/+42
| | | | | | | | | | | | 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.
* | BUG: Fixes for unicode field names in Python 2 (#11642)Chris Billington2018-08-161-2/+2
|/ | | | | | | | | | | | | | | * 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