diff options
Diffstat (limited to 'doc')
23 files changed, 52 insertions, 118 deletions
diff --git a/doc/neps/nep-0044-restructuring-numpy-docs.rst b/doc/neps/nep-0044-restructuring-numpy-docs.rst index fd41e0c2a..3fd703455 100644 --- a/doc/neps/nep-0044-restructuring-numpy-docs.rst +++ b/doc/neps/nep-0044-restructuring-numpy-docs.rst @@ -233,7 +233,7 @@ Discussion around this NEP can be found on the NumPy mailing list: References and Footnotes ======================== -.. [1] `What nobody tells you about documentation <https://www.divio.com/blog/documentation/>`_ +.. [1] `Diátaxis - A systematic framework for technical documentation authoring <https://diataxis.fr/>`_ .. [2] `Preparing to Teach <https://carpentries.github.io/instructor-training/15-lesson-study/index.html>`_ (from the `Software Carpentry <https://software-carpentry.org/>`_ Instructor Training materials) diff --git a/doc/neps/nep-0050-scalar-promotion.rst b/doc/neps/nep-0050-scalar-promotion.rst index b3e29f8dc..fccf794bc 100644 --- a/doc/neps/nep-0050-scalar-promotion.rst +++ b/doc/neps/nep-0050-scalar-promotion.rst @@ -91,7 +91,7 @@ more important than the casting change itself. We recommend using it mainly to track down a *specific* change rather than running it on a full test-suite or program. - The following futher API exists: + The following further API exists: * ``np._set_promotion_state()`` and ``np._get_promotion_state()`` which is equivalent to the environment variable. @@ -546,7 +546,7 @@ retaining the previous datatype is intuitive. Replacing this example with ``np.float32`` is maybe even more clear, as float will rarely have overflows. Without this behaviour, the above example would require writing ``np.uint8(4)`` -and lack of the behaviour would make the following suprising:: +and lack of the behaviour would make the following surprising:: result = np.array([1, 2, 3], dtype=np.float32) * 2. result.dtype == np.float32 @@ -609,7 +609,7 @@ or be unspecified though: Implementation ============== -Implemeting this NEP requires some additional machinery to be added to all +Implementing this NEP requires some additional machinery to be added to all binary operators (or ufuncs), so that they attempt to use the "weak" logic if possible. There are two possible approaches to this: @@ -676,7 +676,7 @@ This has advantages and disadvantages: * The main advantage is that limiting it to Python operators means that these "weak" types/dtypes are clearly ephemeral to short Python statements. -* A disadvantage is that ``np.multiply`` and ``*`` are less interchangable. +* A disadvantage is that ``np.multiply`` and ``*`` are less interchangeable. * Using "weak" promotion only for operators means that libraries do not have to worry about whether they want to "remember" that an input was a Python scalar initially. On the other hand, it would add a the need for slightly @@ -703,7 +703,7 @@ are "stronger" than Python scalars, but NumPy scalars are not). Such a distinction is very much possible, however, at this time NumPy will often (and silently) convert 0-D arrays to scalars. It may thus make sense, to only consider this alternative if we also -change this silent conversion (sometimes refered to as "decay") behaviour. +change this silent conversion (sometimes referred to as "decay") behaviour. Handling conversion of scalars when unsafe diff --git a/doc/release/upcoming_changes/21437.improvement.rst b/doc/release/upcoming_changes/21437.improvement.rst index 8ad1c3303..291483b5f 100644 --- a/doc/release/upcoming_changes/21437.improvement.rst +++ b/doc/release/upcoming_changes/21437.improvement.rst @@ -21,7 +21,7 @@ be platform dependent. For example:: arr = np.full(100, value=1000, dtype=np.float64) arr.astype(np.int8) -May give a result equivalent to (the intermediat means no warning is given):: +May give a result equivalent to (the intermediate cast means no warning is given):: arr.astype(np.int64).astype(np.int8) diff --git a/doc/release/upcoming_changes/21807.improvement.rst b/doc/release/upcoming_changes/21807.improvement.rst index c0043cad3..bfad55fb7 100644 --- a/doc/release/upcoming_changes/21807.improvement.rst +++ b/doc/release/upcoming_changes/21807.improvement.rst @@ -1,5 +1,5 @@ F2PY supports the value attribute -================================= +--------------------------------- The Fortran standard requires that variables declared with the ``value`` attribute must be passed by value instead of reference. F2PY now supports this diff --git a/doc/release/upcoming_changes/22014.improvement.rst b/doc/release/upcoming_changes/22014.improvement.rst index 14df1c118..b32590c85 100644 --- a/doc/release/upcoming_changes/22014.improvement.rst +++ b/doc/release/upcoming_changes/22014.improvement.rst @@ -1,5 +1,5 @@ Added pickle support for third-party BitGenerators -================================================== +-------------------------------------------------- The pickle format for bit generators was extended to allow each bit generator to supply its own constructor when during pickling. Previous versions of NumPy diff --git a/doc/release/upcoming_changes/22313.deprecation.rst b/doc/release/upcoming_changes/22313.deprecation.rst new file mode 100644 index 000000000..c4a0a4a9a --- /dev/null +++ b/doc/release/upcoming_changes/22313.deprecation.rst @@ -0,0 +1,10 @@ +Deprecate fastCopyAndTranspose and PyArray_CopyAndTranspose +----------------------------------------------------------- + +The ``numpy.fastCopyAndTranspose`` function has been deprecated. Use the +corresponding copy and transpose methods directly:: + + arr.T.copy() + +The underlying C function ``PyArray_CopyAndTranspose`` has also been +deprecated from the NumPy C-API. diff --git a/doc/release/upcoming_changes/22357.improvement.rst b/doc/release/upcoming_changes/22357.improvement.rst new file mode 100644 index 000000000..a0332eaa0 --- /dev/null +++ b/doc/release/upcoming_changes/22357.improvement.rst @@ -0,0 +1,6 @@ +``numpy.typing`` protocols are now runtime checkable +---------------------------------------------------- + +The protocols used in `~numpy.typing.ArrayLike` and `~numpy.typing.DTypeLike` +are now properly marked as runtime checkable, making them easier to use for +runtime type checkers. diff --git a/doc/source/dev/development_workflow.rst b/doc/source/dev/development_workflow.rst index b49a96d7a..33bd0126d 100644 --- a/doc/source/dev/development_workflow.rst +++ b/doc/source/dev/development_workflow.rst @@ -231,7 +231,7 @@ https://anaconda.org/scipy-wheels-nightly/ on the following conditions: - by a weekly cron job or - if the github action or travis build has been manually triggered, which requires appropriate permissions -The wheels wil be uploaded to https://anaconda.org/multibuild-wheels-staging/ +The wheels will be uploaded to https://anaconda.org/multibuild-wheels-staging/ if the build was triggered by a tag to the repo that begins with ``v`` .. _Action: https://github.com/numpy/numpy/actions diff --git a/doc/source/f2py/python-usage.rst b/doc/source/f2py/python-usage.rst index c3379f6c5..db1ee1ec8 100644 --- a/doc/source/f2py/python-usage.rst +++ b/doc/source/f2py/python-usage.rst @@ -15,12 +15,13 @@ Routine wrappers are callable ``fortran`` type objects while wrappers to Fortran data have attributes referring to data objects. All ``fortran`` type objects have an attribute ``_cpointer`` that contains a -``CObject`` referring to the C pointer of the corresponding Fortran/C function -or variable at the C level. Such ``CObjects`` can be used as callback arguments -for F2PY generated functions to bypass the Python C/API layer for calling Python -functions from Fortran or C. This can be useful when the computational aspects -of such functions are implemented in C or Fortran and wrapped with F2PY (or any -other tool capable of providing the ``CObject`` of a function). +:c:type:`PyCapsule` referring to the C pointer of the corresponding Fortran/C function +or variable at the C level. Such ``PyCapsule`` objects can be used as callback +arguments for F2PY generated functions to bypass the Python C/API layer for +calling Python functions from Fortran or C. This can be useful when the +computational aspects of such functions are implemented in C or Fortran and +wrapped with F2PY (or any other tool capable of providing the ``PyCapsule`` +containing a function). Consider a Fortran 77 file ```ftype.f``: diff --git a/doc/source/f2py/windows/conda.rst b/doc/source/f2py/windows/conda.rst index b16402bbc..08a79b29d 100644 --- a/doc/source/f2py/windows/conda.rst +++ b/doc/source/f2py/windows/conda.rst @@ -4,7 +4,7 @@ F2PY and Conda on Windows ========================= -As a convienience measure, we will additionally assume the +As a convenience measure, we will additionally assume the existence of ``scoop``, which can be used to install tools without administrative access. diff --git a/doc/source/f2py/windows/index.rst b/doc/source/f2py/windows/index.rst index aee96cb13..c1e6b4128 100644 --- a/doc/source/f2py/windows/index.rst +++ b/doc/source/f2py/windows/index.rst @@ -83,7 +83,7 @@ LFortran (FOSS) Baseline ======== -For this document we will asume the following basic tools: +For this document we will assume the following basic tools: - The IDE being considered is the community supported `Microsoft Visual Studio Code`_ - The terminal being used is the `Windows Terminal`_ diff --git a/doc/source/f2py/windows/pgi.rst b/doc/source/f2py/windows/pgi.rst index 3139d9c5b..644259abe 100644 --- a/doc/source/f2py/windows/pgi.rst +++ b/doc/source/f2py/windows/pgi.rst @@ -19,10 +19,10 @@ as classic Flang requires a custom LLVM and compilation from sources. **As of November 2021** - As of 29-01-2022, `PGI compiler toolchains`_ have been superceeded by the Nvidia + As of 29-01-2022, `PGI compiler toolchains`_ have been superseded by the Nvidia HPC SDK, with no `native Windows support`_. However, .. _PGI compiler toolchains: https://www.pgroup.com/index.html -.. _native Windows support: https://developer.nvidia.com/nvidia-hpc-sdk-downloads#collapseFour
\ No newline at end of file +.. _native Windows support: https://developer.nvidia.com/nvidia-hpc-sdk-downloads#collapseFour diff --git a/doc/source/reference/array_api.rst b/doc/source/reference/array_api.rst index 8c7c6508b..01c8787eb 100644 --- a/doc/source/reference/array_api.rst +++ b/doc/source/reference/array_api.rst @@ -508,7 +508,7 @@ Linear Algebra Functions * - ``vector_norm`` (*) - Floating-point -(*) Thes functions are split from ``norm`` from the main ``numpy`` namespace. +(*) These functions are split from ``norm`` from the main ``numpy`` namespace. See :ref:`array_api-name-changes`. (**) These functions are new in the array API and are not in the main diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst index ccff2ae91..bb22a1b03 100644 --- a/doc/source/reference/c-api/array.rst +++ b/doc/source/reference/c-api/array.rst @@ -152,7 +152,7 @@ and its sub-types). .. c:function:: int PyArray_FinalizeFunc(PyArrayObject* arr, PyObject* obj) - The function pointed to by the CObject + The function pointed to by the :c:type:`PyCapsule` :obj:`~numpy.class.__array_finalize__`. The first argument is the newly created sub-type. The second argument (if not NULL) is the "parent" array (if the array was created using @@ -1337,7 +1337,7 @@ Special functions for NPY_OBJECT by NumPy. Users **should** also ensure to pass fully initialized buffers to NumPy, since NumPy may make this a strong requirement in the future. - There is currently an intention to ensure that NumPy always initalizes + There is currently an intention to ensure that NumPy always initializes object arrays before they may be read. Any failure to do so will be regarded as a bug. In the future, users may be able to rely on non-NULL values when reading diff --git a/doc/source/reference/security.rst b/doc/source/reference/security.rst index 13e2436f7..5b1e7b532 100644 --- a/doc/source/reference/security.rst +++ b/doc/source/reference/security.rst @@ -3,7 +3,7 @@ NumPy security Security issues can be reported privately as described in the project README and when opening a `new issue on the issue tracker <https://github.com/numpy/numpy/issues/new/choose>`_. -The `Python security reporting guidlines <https://www.python.org/dev/security/>`_ +The `Python security reporting guidelines <https://www.python.org/dev/security/>`_ are a good resource and its notes apply also to NumPy. NumPy's maintainers are not security experts. However, we are conscientious diff --git a/doc/source/user/absolute_beginners.rst b/doc/source/user/absolute_beginners.rst index a4a82afb6..dae2c4f06 100644 --- a/doc/source/user/absolute_beginners.rst +++ b/doc/source/user/absolute_beginners.rst @@ -1504,7 +1504,7 @@ You can use ``np.load()`` to reconstruct your array. :: >>> b = np.load('filename.npy') -If you want to check your array, you can run::: +If you want to check your array, you can run:: >>> print(b) [1 2 3 4 5 6] diff --git a/doc/source/user/c-info.beyond-basics.rst b/doc/source/user/c-info.beyond-basics.rst index a1523e514..c566b4595 100644 --- a/doc/source/user/c-info.beyond-basics.rst +++ b/doc/source/user/c-info.beyond-basics.rst @@ -470,13 +470,14 @@ The __array_finalize\__ method __new_\_ method nor the __init\__ method gets called. Instead, the sub-type is allocated and the appropriate instance-structure members are filled in. Finally, the :obj:`~numpy.class.__array_finalize__` - attribute is looked-up in the object dictionary. If it is present - and not None, then it can be either a CObject containing a pointer - to a :c:func:`PyArray_FinalizeFunc` or it can be a method taking a - single argument (which could be None) + attribute is looked-up in the object dictionary. If it is present and not + None, then it can be either a :c:type:`PyCapsule` containing a pointer to a + :c:func:`PyArray_FinalizeFunc` or it can be a method taking a single argument + (which could be None) - If the :obj:`~numpy.class.__array_finalize__` attribute is a CObject, then the pointer - must be a pointer to a function with the signature: + If the :obj:`~numpy.class.__array_finalize__` attribute is a + :c:type:`PyCapsule`, then the pointer must be a pointer to a function with + the signature: .. code-block:: c @@ -488,9 +489,9 @@ The __array_finalize\__ method is present). This routine can do anything it wants to. It should return a -1 on error and 0 otherwise. - If the :obj:`~numpy.class.__array_finalize__` attribute is not None nor a CObject, - then it must be a Python method that takes the parent array as an - argument (which could be None if there is no parent), and returns + If the :obj:`~numpy.class.__array_finalize__` attribute is not None nor a + :c:type:`PyCapsule`, then it must be a Python method that takes the parent + array as an argument (which could be None if there is no parent), and returns nothing. Errors in this method will be caught and handled. diff --git a/doc/source/user/plot_approx.py b/doc/source/user/plot_approx.py deleted file mode 100644 index a2d6981d9..000000000 --- a/doc/source/user/plot_approx.py +++ /dev/null @@ -1,19 +0,0 @@ -from scipy import misc -import matplotlib.pyplot as plt -import numpy as np -from numpy import linalg - -img = misc.face() -img_array = img / 255 -img_gray = img_array @ [0.2126, 0.7152, 0.0722] - -U, s, Vt = linalg.svd(img_gray) - -Sigma = np.zeros((768, 1024)) -for i in range(768): - Sigma[i, i] = s[i] - -k = 10 - -approx = U @ Sigma[:, :k] @ Vt[:k, :] -plt.imshow(approx, cmap="gray") diff --git a/doc/source/user/plot_face.py b/doc/source/user/plot_face.py deleted file mode 100644 index c0891e770..000000000 --- a/doc/source/user/plot_face.py +++ /dev/null @@ -1,5 +0,0 @@ -from scipy import misc -import matplotlib.pyplot as plt - -img = misc.face() -plt.imshow(img) diff --git a/doc/source/user/plot_final.py b/doc/source/user/plot_final.py deleted file mode 100644 index 10cb097dd..000000000 --- a/doc/source/user/plot_final.py +++ /dev/null @@ -1,19 +0,0 @@ -from scipy import misc -import matplotlib.pyplot as plt -import numpy as np -from numpy import linalg - -img = misc.face() -img_array = img / 255 -img_array_transposed = np.transpose(img_array, (2, 0, 1)) - -U, s, Vt = linalg.svd(img_array_transposed) - -Sigma = np.zeros((3, 768, 1024)) -for j in range(3): - np.fill_diagonal(Sigma[j, :, :], s[j, :]) - -k = 10 - -approx_img = U @ Sigma[..., :k] @ Vt[..., :k, :] -plt.imshow(np.transpose(approx_img, (1, 2, 0))) diff --git a/doc/source/user/plot_gray.py b/doc/source/user/plot_gray.py deleted file mode 100644 index 6cb46bbe4..000000000 --- a/doc/source/user/plot_gray.py +++ /dev/null @@ -1,8 +0,0 @@ -from scipy import misc -import matplotlib.pyplot as plt -import numpy as np - -img = misc.face() -img_array = img / 255 -img_gray = img_array @ [0.2126, 0.7152, 0.0722] -plt.imshow(img_gray, cmap="gray") diff --git a/doc/source/user/plot_gray_svd.py b/doc/source/user/plot_gray_svd.py deleted file mode 100644 index 95439939d..000000000 --- a/doc/source/user/plot_gray_svd.py +++ /dev/null @@ -1,16 +0,0 @@ -from scipy import misc -import matplotlib.pyplot as plt -import numpy as np -from numpy import linalg - -img = misc.face() -img_array = img / 255 -img_gray = img_array @ [0.2126, 0.7152, 0.0722] - -U, s, Vt = linalg.svd(img_gray) - -Sigma = np.zeros((768, 1024)) -for i in range(768): - Sigma[i, i] = s[i] - -plt.plot(s) diff --git a/doc/source/user/plot_reconstructed.py b/doc/source/user/plot_reconstructed.py deleted file mode 100644 index 37cf3c626..000000000 --- a/doc/source/user/plot_reconstructed.py +++ /dev/null @@ -1,17 +0,0 @@ -from scipy import misc -import matplotlib.pyplot as plt -import numpy as np -from numpy import linalg - -img = misc.face() -img_array = img / 255 -img_array_transposed = np.transpose(img_array, (2, 0, 1)) - -U, s, Vt = linalg.svd(img_array_transposed) - -Sigma = np.zeros((3, 768, 1024)) -for j in range(3): - np.fill_diagonal(Sigma[j, :, :], s[j, :]) - -reconstructed = U @ Sigma @ Vt -plt.imshow(np.transpose(reconstructed, (1, 2, 0))) |