summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
Commit message (Collapse)AuthorAgeFilesLines
* DOC: add back reference.Ross Barnowski2023-05-021-3/+3
|
* DOC: fix reference formatting.Ross Barnowski2023-05-021-3/+3
|
* DOC: fix indexing inconsistency in outer docstring.Ross Barnowski2023-05-021-6/+5
|
* MAINT: switch min/max with amin/amax, and add them to html docsRalf Gommers2023-03-011-2/+3
| | | | Closes gh-13877
* MAINT: Use `np._using_numpy2_behavior()` and initialize it in CSebastian Berg2023-02-101-2/+4
|
* STY: Make linter happy in numeric.py changesSebastian Berg2023-01-171-2/+5
|
* ENH: Improve array function overhead by using vectorcallSebastian Berg2023-01-171-29/+8
| | | | | | | | | | | | | | | | | | | | | | | | This moves dispatching for `__array_function__` into a C-wrapper. This helps speed for multiple reasons: * Avoids one additional dispatching function call to C * Avoids the use of `*args, **kwargs` which is slower. * For simple NumPy calls we can stay in the faster "vectorcall" world This speeds up things generally a little, but can speed things up a lot when keyword arguments are used on lightweight functions, for example:: np.can_cast(arr, dtype, casting="same_kind") is more than twice as fast with this. There is one alternative in principle to get best speed: We could inline the "relevant argument"/dispatcher extraction. That changes behavior in an acceptable but larger way (passes default arguments). Unless the C-entry point seems unwanted, this should be a decent step in the right direction even if we want to do that eventually, though. Closes gh-20790 Closes gh-18547 (although not quite sure why)
* API: Add new exceptions module and move exception exposed via numericSebastian Berg2022-11-301-23/+10
| | | | This means moving ComplexWarning, TooHardError, and AxisError.
* DEP: fastCopyAndTranspose and PyArray_CopyAndTransposeRoss Barnowski2022-10-061-1/+1
| | | | | | | | Deprecate the fastCopyAndTranspose function from the Python API, and the underlying PyArray_CopyAndTranspose function from the C-API. Also removes an internal, private function _fastCopyAndTranspose which was the original Python wrapper around the C-function.
* DOC: Clarify that `like` is not passed to `function`Matt Williams2022-09-051-1/+1
|
* DOC: correct docstring for numpy.correlate()Ari Cooper Davis2022-07-121-1/+1
|
* BUG: cross product: add dtype conversions of inputs (#20659)Omar2022-07-041-0/+4
| | | | Closes #19138
* API: Add leading underscore to `no_nep50_warning` and `get/set_promotion_state`Sebastian Berg2022-06-151-4/+4
|
* API: Expose `get_promotion_state` and `set_promotion_state`Sebastian Berg2022-06-151-2/+3
| | | | | We need to be able to query the state for testing, probably should be renamed before the end, but need to have something for now.
* WIP: Add warning context manager and fix min_scalar for new promotionSebastian Berg2022-06-151-2/+2
| | | | | Even the new promotion has to use the min-scalar logic to avoid picking up a float16 loop for `np.int8(3) * 3.`.
* DOC: Simplify explanation/markup of correlate transformationKilian Lieret2022-04-241-2/+2
|
* DOC: Use r-string/escape math codeKilian Lieret2022-04-231-1/+1
|
* DOC: Improve math typesettingKilian Lieret2022-04-231-5/+5
|
* DOC: Use math modeKilian Lieret2022-04-231-5/+5
|
* DOC: misc fixes:Matthias Bussonnier2022-03-211-1/+1
| | | | | | | | | | - improper urls - a few use of single bakcticks where many are expected - Proper numpydoc format [ci skip] [skip azp] [skip circle]
* Merge pull request #21145 from tirthasheshpatel/fix-gh20743Matti Picus2022-03-101-2/+2
|\ | | | | MAINT, DOC: make np._from_dlpack public
| * MAINT: make np._from_dlpack publicTirth Patel2022-03-031-2/+2
| |
* | DOC: Fix syntax highlighting for numpy.flatnonzero (#21150)Felix Divo2022-03-041-2/+2
|/
* DOC: change fill_value of full_like from scalar to array_likelorenzomammana2022-02-101-1/+7
| | | | Add example using array_like type. See #21011
* MAINT, DOC: discard repeated wordsDimitri Papadopoulos2022-01-131-1/+1
|
* DOC: np.fromfunction documentation not clear (#20396)Soumya2021-11-181-0/+8
| | | | | | | * DOC: fromfunction documentation edited * DOC: Example added in fromfunction documentation Added one more example to numpy.fromfunction documentation that will help to clarify how parameters are passed to the function.
* change from_dlpack to _dlpack, remove unused headermattip2021-11-021-2/+2
|
* ENH, TST: Add the from_dlpack method and test DLPack.Hameer Abbasi2021-11-021-3/+3
|
* DOC: Add multi-axis examples to numpy.roll docstring (#20267)vinith22021-11-011-1/+7
| | | | | Added exampled where we use tuple in for axis and shifts separately. This shows how the multiple shift examples works Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* DOC: update isclose and allclose notes works with bools (#19613)Yashasvi Misra2021-08-061-0/+2
|
* MAINT: Remove unused function _move_axis_to_0Anirudh Dagar2021-07-281-5/+0
|
* Merge pull request #18642 from seberg/splitup-faster-argparsing-optimize-asarrayMatti Picus2021-03-211-4/+5
|\ | | | | ENH: Use new argument parsing for array creation functions
| * ENH: Use new argument parsing for array creation functionsSebastian Berg2021-03-181-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The array creation functions have the most to gain: 1. np.asarray is 4 times faster and commonly used. 2. Other functions are wrapped using __array_function__ in Python making it more difficult This commit (unfortunatly) has to do a few things: * Modify __array_function__ C-side dispatching to accomodate the fastcall argument convention. * Move asarray, etc. to C after removing all "fast paths" from np.array (simplifying the code) * Fixup imports, since asarray was imported directly in a few places * Replace some places where `np.array` was probably used for speed instead of np.asarray or similar. (or by accident in 1 or 2 places)
* | DEP: Deprecate inexact matches of mode, shift parameter parsing to CAitik Gupta2021-03-181-13/+0
|/
* Update numpy/core/numeric.pymdubravski2021-02-141-1/+3
| | | Co-authored-by: Matti Picus <matti.picus@gmail.com>
* Update numpy/core/numeric.py mdubravski2021-02-131-1/+1
| | | | | rewording to eliminate redundancy Co-authored-by: Melissa Weber Mendonça <melissawm@gmail.com>
* Update numpy/core/numeric.py mdubravski2021-02-131-2/+1
| | | | | rewording to eliminate redundancy Co-authored-by: Melissa Weber Mendonça <melissawm@gmail.com>
* correlate fixmdubravski2021-02-121-0/+5
|
* BUG: Allow unmodified use of isclose, allclose, etc. with timedeltaSebastian Berg2021-02-041-2/+7
| | | | | | | | | | | | | | Disallowing timedelta64+float promotion (to timedelta64) in all cases (previously it was assymetric and "half allowed") meant that isclose, allclose, np.ma.allclose, and assert_arrays_almost_equal (which uses isclose), would stop work for timedelta64. Hardcoding that timedelta64 is passed on unmodified retains the old behaviour. It may make sense to deprecate or change this behaviour in the future, but for the 1.20 release, the behaviour should be as much unmodified as possible. Closes gh-18286
* DOC: Misc numpydoc format fixesMatthias Bussonnier2021-01-271-3/+2
| | | | | | | | | Via prototype docstring autoreformatter; and cherry-picked to mostly include spacing issues around colons in parameters and see also. When no space is present numpydoc tend to miss-parse those sections A couple of typos are fixed as well.
* DOC: Double backticks for inline code example.Matthias Bussonnier2021-01-231-1/+1
| | | | | Single backticks are supposed to be use for reference to other object, In this context double backticks (verbatim) appear to be better suited.
* Harmonize quoting in (ones/fill/zeros/empty)_like documentationserge-sans-paille2020-11-211-3/+3
|
* TST: Fix doctest for full_likeJulia Signell2020-10-061-1/+1
|
* ENH: implement NEP-35's `like=` argument (gh-16935)Peter Andreas Entschev2020-08-281-6/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds the implementation of NEP-35's like= argument, allowing dispatch of array creation functions with __array_function__ based on a reference array. * ENH: Add like= kwarg via __array_function__ dispatcher to asarray * ENH: Add new function for __array_function__ dispatching from C This new function allows dispatching from C directly, while also implementing the new `like=` argument, requiring only minimal changes to existing array creation functions that need to add support for that argument. * ENH: Add like= support to numpy.array The implementation uses array_implement_c_array_function, thus introducing minimal complexity to the original _array_fromobject code. * BUG: Fix like= dispatcher for np.full * ENH: Remove np.asarray like= dispatcher via Python np.asarray can rely on np.array's C dispatcher instead. * TST: Add some tests for like= argument Tests comprise some of the functions that have been implemented already: * np.array (C dispatcher) * np.asarray (indirect C dispatcher via np.array) * np.full (Python dispatcher) * np.ones (Python dispatcher) * ENH: Remove like= argument during array_implement_array_function * ENH: Add like= kwarg to ones and full * BUG: prevent duplicate removal of `like=` argument * ENH: Make `like=` a keyword-only argument * ENH: Use PyUnicode_InternFromString in arrayfunction_override Replace PyUnicode_FromString by PyUnicode_InternFromString to cache "like" string. * ENH: Check for arrayfunction_override import errors Check and handle errors on importing NumPy's Python functions * BUG: Fix array_implement_c_array_function error handling * ENH: Handle exceptions with C implementation of `like=` * ENH: Add `like=` dispatch for all asarray functions Using Python dispatcher for all of them. Using the C dispatcher directly on the `np.array` call can result in incorrect behavior. Incorrect behavior may happen if the downstream library's implementation is different or if not all keyword arguments are supported. * ENH: Simplify handling of exceptions with `like=` * TST: Add test for exception handling with `like=` * ENH: Add support for `like=` to `np.empty` and `np.zeros` * TST: Add `like=` tests for `np.empty` and `np.zeros` * ENH: Add `like=` to remaining multiarraymodule.c functions Functions are: * np.arange * np.frombuffer * np.fromfile * np.fromiter * np.fromstring * TST: Add tests for multiarraymodule.c functions with like= Functions are: * np.arange * np.frombuffer * np.fromfile * np.fromiter * np.fromstring * ENH: Add `like=` support to more creation functions Support for the following functions is added: * np.eye * np.fromfunction * np.genfromtxt * np.identity * np.loadtxt * np.tri * TST: Add `like=` tests for multiple functions Tests for the following functions are added: * np.eye * np.fromfunction * np.genfromtxt * np.identity * np.loadtxt * np.tri * TST: Reduce code duplication in `like=` tests * DOC: Document `like=` in functions that support it Add documentations for the following functions: * np.array * np.arange * np.asarray * np.asanyarray * np.ascontiguousarray * np.asfortranarray * np.require * np.empty * np.full * np.ones * np.zeros * np.identity * np.eye * np.tri * np.frombuffer * np.fromfile * np.fromiter * np.fromstring * np.loadtxt * np.genfromtxt * ENH: Add `like=` to numpy/__init__.pyi stubs * BUG: Remove duplicate `like=` dispatching in as*array Functions `np.asanyarray`, `np.contiguousarray` and `np.fortranarray` were dispatching both via their definitions and `np.array` calls, the latter should be avoided. * BUG: Fix missing check in array_implement_array_function * BUG: Add missing keyword-only markers in stubs * BUG: Fix duplicate keyword-only marker in array stub * BUG: Fix syntax error in numpy/__init__.pyi * BUG: Fix more syntax errors in numpy/__init__.pyi * ENH: Intern arrayfunction_override strings in multiarraymodule * STY: Add missing brackets to arrayfunction_override.c * MAINT: Remove arrayfunction_override dict check for kwarg * TST: Assert that 'like' is not in TestArrayLike kwargs * MAINT: Rename array_implement_c_array_function(_creation) This is done to be more explicit as to its usage being intended for array creation functions only. * MAINT: Use NotImplemented to indicate fallback to default * TST: Test that results with `like=np.array` are correct * TST: Avoid duplicating MyArray code in TestArrayLike * TST: Don't delete temp file, it may cause issues with Windows * TST: Don't rely on eval in TestArrayLike * TST: Use lambda with StringIO in TestArrayLike * ENH: Avoid unnecessary Py_XDECREF in arrayfunction_override * TST: Make TestArrayLike more readable * ENH: Cleaner error handling in arrayfunction_override * ENH: Simplify array_implement_c_array_function_creation * STY: Add missing spaces to multiarraymodule.c * STY: C99 declaration style in arrayfunction_override.c * ENH: Simplify arrayfunction_override.c further Remove cleanup label from array_implementation_c_array_function, simplifying the code. Fix unitialized variable warning in array_implementation_array_function_internal. * DOC: Use string replacement for `like=` documentation Avoid repeating the full text for the `like=` argument by storing it as a variable and using `replace` on each docstring. * DOC: Update `like=` docstring * TST: Test like= with array not implementing __array_function__ * TST: Add missing asanyarray to TestArrayLike * ENH: Use helper function for like= dispatching Avoid dispatching like= from Python implementation functions to improve their performance. This is achieved by only calling a dispatcher function when like is passed by the users. * ENH: Rename array_function_dispatch kwarg to public_api * BUG: Add accidentally removed decorator for np.eye back * DOC: Add set_array_function_like_doc function The function keeps Python files cleaner and resolve errors when __doc__ is not defined due to PYTHONOPTIMIZE or -OO . * DOC: Add mention to like= kwarg being experimental * TST: Test like= with not implemented downstream function * DOC: Fix like= docstring reference to NEP 35. * ENH: Prevent silent errors if public_api is not callable * ENH: Make set_array_function_like_doc a decorator * ENH: Simplify `_*_with_like` functions * BUG: Fix multiple `like=` dispatching in `require` * MAINT: Remove now unused public_api from array_function_dispatch Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* DOC: Add note that allclose and isclose do not accept non-numeric types (#16835)Brian Soto2020-08-041-0/+4
| | | Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
* MAINT: Improve performance of np.full (gh-16644)dojafrat2020-06-261-1/+2
| | | | | Implement more performant np.full and add test See #16180
* DOC: Add math.isclose to See Also (#16283)Ben Elliston2020-05-191-0/+1
| | | * DOC: Move math.isclose note to See Also.
* ENH: Add equal_nan keyword argument to array_equal (gh-16128)Ross Barnowski2020-05-111-3/+31
| | | | | | Match the corresponding kwarg and behavior from related functions like allclose. Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* DOC: Update np.rollaxis docstring (#15939)Guilherme Leobas2020-05-111-3/+31
| | | | | * DOC: Update np.rollaxis docstring to correct parameter explanation Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* Update Docs : point users of np.outer to np.multiply.outer (#16182)Tina Oberoi2020-05-091-2/+5
| | | | | | * Update notes for numpy.outer and numpy.multiply.outer * Add tenserdot to numpy.outer documentation Co-authored-by: Eric Wieser <wieser.eric@gmail.com>