| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
correctly against `start` and `stop`.
|
|
|
|
| |
Also add links to this document from the functions' docstrings.
|
| |
|
|
|
| |
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
| |
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
|
| |
|
|
|
| |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
|
|
|
| |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
|
| |
|
|
|
|
|
| |
Same clarification for these functions as gh-16433
made for linspace. @Qiyu8 spotted these additional cases.
|
|
|
|
|
| |
DOC: Fix description of dtype default in linspace
Clarify that inferred type will never be integer. Fixes gh-8597.
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
* 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)
|
|
|
|
|
| |
As numpy is Python 3 only, these import statements are now unnecessary
and don't alter runtime behavior.
|
|
|
|
|
|
| |
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
|
| |
|
|\
| |
| | |
MAINT: Warn if `_add_newdocs.py` is used to add docstrings to pure-python objects
|
| |
| |
| |
| |
| |
| | |
objects
This caught the duplication of docstrings between multiarray.py and _add_newdocs
|
|\ \
| |/
| | |
DOC: Add a numpy-doc docstring to add_newdoc
|
| | |
|
| |
| |
| |
| | |
Previously this would silently ignore extra items
|
| | |
|
|\ \
| |/
| | |
MAINT,BUG,DOC: Fix errors in _add_newdocs
|
| |
| |
| |
| | |
This caught us trying to document members that don't exist.
|
| |
| |
| |
| | |
This reverts commit 7ac7fa9a4621f7392f534b20f0cdd64967e9c7eb.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* 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.
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| | |
* as requested by review in gh-12634,
the vast majority of docstring matplotlib
imports can be simplified to a single line
|
| |
| |
| |
| |
| |
| |
| | |
* there is no longer any usage of "agg"
backend switching in our docstrings because
this backend is already activated in
the refguide_check machinery
|
|/
|
|
|
|
|
|
| |
* 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
|
| |
|
| |
|
| |
|
|
|
|
| |
Fixes gh-12379
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 :).
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|\ |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| | |
added optional flag to the step
|