From 2f41bb26b061821c77aff6982630de937ad9007a Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 24 Feb 2019 10:10:47 +0200 Subject: DOC: fixes from review --- numpy/doc/glossary.py | 62 +++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'numpy/doc/glossary.py') 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', '` 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 + ` to mean any optimization via specialized code. view An array that does not own its data, but refers to another array's -- cgit v1.2.1