summaryrefslogtreecommitdiff
path: root/numpy/core/function_base.py
Commit message (Collapse)AuthorAgeFilesLines
* DEP: deprecate scalar conversions for arrays with ndim > 0 (#10615)Nico Schlömer2023-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR reflects some of the progress achieved in issue #10404 and is used to asses the impact of the changes. With the changes in this PR, `float(numpy.array([1.0])` now gives a warning; likewise some other things: ```python import numpy a = numpy.random.rand(10, 1) a[0] = numpy.array([1.0]) # okay a[0] = numpy.array(1.0) # okay a[0] = 1.0 # okay b = numpy.random.rand(10) b[0] = numpy.array([1.0]) # ValueError: setting an array element with a sequence. b[0, ...] = numpy.array([1.0]) # okay b[0] = numpy.array(1.0) # okay b[0] = 1.0 # okay ``` This aligns the behavior of numpy arrays with that of lists: ```python float([3.14]) ``` ``` TypeError: float() argument must be a string or a number, not 'list' ``` ```python import numpy as np a = np.random.rand(5) a[0] = [3.14] ``` ``` ValueError: setting an array element with a sequence. ``` Fixes #10404.
* ENH: Modify `numpy.logspace` so that the `base` argument broadcasts ↵Roy Smart2023-03-061-5/+19
| | | | correctly against `start` and `stop`.
* DOC: Improve how-to-partition contents.melissawm2022-10-111-0/+3
| | | | Also add links to this document from the functions' docstrings.
* Apply suggestions from code reviewSebastian Berg2022-07-061-1/+1
|
* Update numpy/core/function_base.pyPieter Eendebak2022-06-271-2/+2
| | | Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* fix lintPieter Eendebak2022-06-231-1/+2
|
* PERF: Micro optimize np.linspacePieter Eendebak2022-06-231-3/+7
|
* [DOC] Replace verbatim to reference to local parameterMatthias Bussonnier2020-12-131-1/+1
| | | | | | The rest of the docstring and other function tend to have this convention and sphinx – as well as other tools – will be able to infer this actually refers to one of the function parameters.
* DOC: Clarify that the `base` parameter in `logspace` can be array_likeBas van Beek2020-08-231-2/+2
|
* Apply suggestions from code reviewMatti Picus2020-08-131-1/+2
| | | Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* DOC: Added versionchanged to linspace docstring.Ross Barnowski2020-08-031-0/+4
|
* Update numpy/core/function_base.pyWansoo Kim2020-08-031-1/+1
| | | Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* Update numpy/core/function_base.pyWansoo Kim2020-08-031-1/+1
| | | Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* BUG: linspace should round towards -infinitymarload2020-08-031-0/+3
|
* DOC: Clarify dtype default for logspace and geomspaceBen Nathanson2020-06-121-7/+11
| | | | | Same clarification for these functions as gh-16433 made for linspace. @Qiyu8 spotted these additional cases.
* DOC: Fix description of dtype default in linspace (#16433)bjnath2020-06-101-2/+4
| | | | | DOC: Fix description of dtype default in linspace Clarify that inferred type will never be integer. Fixes gh-8597.
* BUG: endpoints of array returned by geomspace() should match arguments (#16411)Kaspar Thommen2020-06-101-2/+12
| | | | | * BUG: make sure the endpoints of the array returned by geomspace() matches the 'start' and 'stop' arguments exactly Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
* BUG: Avoid duplication in stack trace of `linspace(a, b, num=1.5)`Eric Wieser2020-04-151-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, the stack trace was: ``` Traceback (most recent call last): File "C:\Users\wiese\Repos\numeric-python\numpy\build\testenv\Lib\site-packages\numpy\core\function_base.py", line 114, in linspace num = operator.index(num) TypeError: 'float' object cannot be interpreted as an integer During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<ipython-input-13-802b8c6e85f6>", line 1, in <module> np.linspace(1, 2, 1.5) File "<__array_function__ internals>", line 5, in linspace File "C:\Users\wiese\Repos\numeric-python\numpy\build\testenv\Lib\site-packages\numpy\core\function_base.py", line 116, in linspace raise TypeError( TypeError: object of type <class 'float'> cannot be safely interpreted as an integer. ``` Now it is ``` Traceback (most recent call last): File "C:\Users\wiese\Repos\numeric-python\numpy\build\testenv\Lib\site-packages\numpy\core\function_base.py", line 114, in linspace num = operator.index(num) TypeError: 'float' object cannot be interpreted as an integer ``` This noisy traceback was introduced in f4dfe833e3e037bb69113f7250fad3699f918cfc.
* MAINT: cleanup unused imports; avoid redefinition of importsMike Taves2020-02-061-2/+1
| | | | | | | * Cleanup unused imports (F401) of mostly standard Python modules, or some internal but unlikely referenced modules * Where internal imports are potentially used, mark with noqa * Avoid redefinition of imports (F811)
* 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.
* BUG: Fix step returned by linspace when num=1 and endpoint=False (#14929)David Zwicker2019-11-211-2/+3
| | | | | | Changed the the behavior of linspace to return a proper step size for arguments num=1 and endpoint=False, where previously NaN was returned. closes gh-14927
* Dep: Deprecation of float index in linespaceSeth Troisi2019-10-011-14/+7
|
* Merge pull request #13935 from eric-wieser/forbid-_add_newdocs-python-v2Matti Picus2019-07-141-6/+34
|\ | | | | MAINT: Warn if `_add_newdocs.py` is used to add docstrings to pure-python objects
| * MAINT: Warn on the use of `_add_newdocs.py` to add docstrings to pure-python ↵Eric Wieser2019-07-141-6/+34
| | | | | | | | | | | | objects This caught the duplication of docstrings between multiarray.py and _add_newdocs
* | Merge pull request #13946 from eric-wieser/add_newdoc_docsMatti Picus2019-07-111-11/+33
|\ \ | |/ | | DOC: Add a numpy-doc docstring to add_newdoc
| * DOC: point out the shortcomings of add_newdocsmattip2019-07-091-0/+10
| |
| * MAINT: Enforce that `add_newdocs` is called with sequences of the right sizeEric Wieser2019-07-081-3/+4
| | | | | | | | Previously this would silently ignore extra items
| * DOC: Add a numpy-doc docstring to add_newdocEric Wieser2019-07-081-8/+19
| |
* | Merge pull request #13944 from eric-wieser/forbid-_add_newdocs-pythonEric Wieser2019-07-081-12/+17
|\ \ | |/ | | MAINT,BUG,DOC: Fix errors in _add_newdocs
| * BUG: Don't silence errors in add_newdoc caused by bad argumentsEric Wieser2019-06-301-12/+17
| | | | | | | | This caught us trying to document members that don't exist.
* | Revert "MAINT/BUG/DOC: Fix errors in _add_newdocs (#13876)"revert-13876-forbid-_add_newdocs-pythonEric Wieser2019-07-081-17/+12
| | | | | | | | This reverts commit 7ac7fa9a4621f7392f534b20f0cdd64967e9c7eb.
* | MAINT/BUG/DOC: Fix errors in _add_newdocs (#13876)Eric Wieser2019-07-061-12/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * BUG: Remove items from `multiarray.__all__` which do not exist on python 3 Avoid using `_add_newdocs` if these functions do not exist. Leaving the version-checking here so that we can backport to 1.16 * BUG: Add missing `np.core.multiarray._get_ndarray_c_version` function This must have been lost in the multiarray / umath merge. Found by noticing that `add_newdocs` was being called on an object that does not exist. * DOC: Remove documentation for property that does not exist `ndarray._as_parameter_` is not a real thing * DOC: Remove docstrings which are duplicated from `numpy/core/multiarray.py` * BUG: Don't silence errors in add_newdoc caused by bad arguments This caught us trying to document members that don't exist.
* | BUG: ensure linspace works on object input.Marten van Kerkwijk2019-03-041-2/+2
| | | | | | | | | | | | As it was, the difference between stop and start was calculated and it was assumed that that would be a numpy scalar or array. This is not true for object input.
* | DOC, TST: clean up matplotlib importsTyler Reddy2019-01-021-5/+0
| | | | | | | | | | | | * as requested by review in gh-12634, the vast majority of docstring matplotlib imports can be simplified to a single line
* | DOC, TST: remove agg setting from docsTyler Reddy2019-01-021-3/+0
| | | | | | | | | | | | | | * there is no longer any usage of "agg" backend switching in our docstrings because this backend is already activated in the refguide_check machinery
* | TST, DOC: enable refguide_checkTyler Reddy2018-12-141-11/+22
|/ | | | | | | | * ported the refguide_check module from SciPy for usage in NumPy docstring execution/ verification; added the refguide_check run to Azure Mac OS CI * adjusted NumPy docstrings such that refguide_check passes
* DOC: Note the version in which we start supporting array_like start, stopMarten van Kerkwijk2018-12-061-6/+15
|
* ENH: allow user choice of sample axis in {lin,log,geom}space.Marten van Kerkwijk2018-12-051-19/+41
|
* ENH: Allow {lin,log,geom}space start and stop to be arrays.Marten van Kerkwijk2018-12-051-31/+42
|
* ENH: override support for np.linspace and friendsStephan Hoyer2018-12-011-5/+24
| | | | Fixes gh-12379
* ENH: set correct __module__ for objects in numpy's public APIStephan Hoyer2018-11-131-0/+4
| | | | | | | | | | | | | 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 :).
* DOC: Add geomspace to "See also" of linspaceStefan Otte2018-08-071-1/+4
|
* MAINT: Move add_newdocs into core, since it only adds docs to those piecesEric Wieser2018-07-021-0/+36
|
* MAINT: When delta is a NumPy scalar, do multiplication in-placeOleksandr Pavlyk2017-09-281-5/+12
| | | | | | | | This is faster and more memory efficient. Out-of-place operation was preventing me from using linspace to create over 2**31 equispaced doubles on my machine due to insufficient memory.
* MAINT: Stop using the undocumented coercion-then-downcast feature of subdtypeEric Wieser2017-08-051-1/+1
|
* DOC: BLD: fix lots of Sphinx warnings/errors.Ralf Gommers2017-06-101-4/+4
|
* Merge branch 'master' into asarrayFrançois Bissey2016-08-231-43/+147
|\
| * DOC: link geomspace from logspaceendolith2016-06-211-0/+1
| |
| * ENH: Add geomspace functionEndolith2016-06-201-12/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like logspace, but specifying start and stop directly, without having to specify the base. Purely imaginary or purely negative real sequences are converted to positive real, computed, and converted back, so there are no negligible real or imaginary parts. Instead of array([ 6.12323400e-17 +1.00000000e+00j, 6.12323400e-16 +1.00000000e+01j, 6.12323400e-15 +1.00000000e+02j, 6.12323400e-14 +1.00000000e+03j]) it outputs array([ 0. +1.j, 0. +10.j, 0. +100.j, 0.+1000.j]) If dtype is complex it does the math in complex so it can leave the real line and follow a spiral. TST: Added tests for geomspace and more tests for logspace, making PhysicalQuantities tests work for all types of functions PEP8: __all__ after imports, line wrapping
| * DOC : minor changes to linspace docstringEkaterina Tuzova2016-05-161-1/+1
| | | | | | | | added optional flag to the step