diff options
author | mattip <matti.picus@gmail.com> | 2019-02-24 10:10:47 +0200 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2019-02-28 11:46:34 +0200 |
commit | 2f41bb26b061821c77aff6982630de937ad9007a (patch) | |
tree | 8e6f8988fd3cf08adbf99e72d2589b072cb8e9f2 /numpy/doc/glossary.py | |
parent | 62433284d65a3629a199958da2df3a807c60fab4 (diff) | |
download | numpy-2f41bb26b061821c77aff6982630de937ad9007a.tar.gz |
DOC: fixes from review
Diffstat (limited to 'numpy/doc/glossary.py')
-rw-r--r-- | numpy/doc/glossary.py | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/numpy/doc/glossary.py b/numpy/doc/glossary.py index 162288b14..292f293b7 100644 --- a/numpy/doc/glossary.py +++ b/numpy/doc/glossary.py @@ -348,31 +348,31 @@ Glossary Painting the city red! slice - Used to select only certain elements from a sequence:: + Used to select only certain elements from a sequence: - >>> x = range(5) - >>> x - [0, 1, 2, 3, 4] + >>> x = range(5) + >>> x + [0, 1, 2, 3, 4] - >>> x[1:3] # slice from 1 to 3 (excluding 3 itself) - [1, 2] + >>> x[1:3] # slice from 1 to 3 (excluding 3 itself) + [1, 2] - >>> x[1:5:2] # slice from 1 to 5, but skipping every second element - [1, 3] + >>> x[1:5:2] # slice from 1 to 5, but skipping every second element + [1, 3] - >>> x[::-1] # slice a sequence in reverse - [4, 3, 2, 1, 0] + >>> x[::-1] # slice a sequence in reverse + [4, 3, 2, 1, 0] Arrays may have more than one dimension, each which can be sliced - individually:: + individually: - >>> x = np.array([[1, 2], [3, 4]]) - >>> x - array([[1, 2], - [3, 4]]) + >>> x = np.array([[1, 2], [3, 4]]) + >>> x + array([[1, 2], + [3, 4]]) - >>> x[:, 1] - array([2, 4]) + >>> x[:, 1] + array([2, 4]) structure See :term:`structured data type` @@ -380,9 +380,14 @@ Glossary structured data type A data type composed of other datatypes - subarray + subarray data type A :term:`structured data type` may contain a :term:`ndarray` with its - own dtype and shape. + own dtype and shape: + + >>> dt = np.dtype([('a', np.int32), ('b', np.float32, (3,))]) + >>> np.zeros(3, dtype=dt) + array([(0, [0., 0., 0.]), (0, [0., 0., 0.]), (0, [0., 0., 0.])], + dtype=[('a', '<i4'), ('b', '<f4', (3,))]) title In addition to field names, structured array fields may have an @@ -425,14 +430,17 @@ Glossary 'alpha' ufunc - Universal function. A fast element-wise array operation. Examples include - ``add``, ``sin`` and ``logical_or``. - - vectorized - A loop-based function that operates on data with fixed strides. - Compilers know how to take advantage of well-constructed loops and - match the data to specialized hardware that can operate on a number - of operands in parallel. + Universal function. A fast element-wise, :term:`vectorized + <vectorization>` array operation. Examples include ``add``, ``sin`` and + ``logical_or``. + + vectorization + Optimizing a looping block by specialized code. In a traditional send, + vectorization operates on data with fixed strides via specialized + hardware. Compilers know how to take advantage of well-constructed loops + and match the data to specialized hardware that can operate on a number + of operands in parallel. NumPy uses :ref:`vectorization + <whatis-vectorization>` to mean any optimization via specialized code. view An array that does not own its data, but refers to another array's |