diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-02-09 19:58:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-09 19:58:15 -0700 |
commit | b52be49a702862a44f18237c5a9a6c7f5173ddab (patch) | |
tree | 33283a7a9ef8d0261dd8ca41dc0dcba20902ff94 | |
parent | 04bfa6233473e3ffb7fb3fe2e9c1623d63f62cad (diff) | |
parent | 40ce834f854827b39c98a6e32d061195edad6662 (diff) | |
download | numpy-b52be49a702862a44f18237c5a9a6c7f5173ddab.tar.gz |
Merge pull request #8575 from godaygo/doc-typos-1
DOC: fix several typos #8537.
-rw-r--r-- | doc/source/reference/arrays.scalars.rst | 15 | ||||
-rw-r--r-- | doc/source/user/quickstart.rst | 27 | ||||
-rw-r--r-- | numpy/doc/indexing.py | 4 |
3 files changed, 26 insertions, 20 deletions
diff --git a/doc/source/reference/arrays.scalars.rst b/doc/source/reference/arrays.scalars.rst index 4acaf1b3b..f76087ce2 100644 --- a/doc/source/reference/arrays.scalars.rst +++ b/doc/source/reference/arrays.scalars.rst @@ -248,7 +248,8 @@ Indexing Array scalars can be indexed like 0-dimensional arrays: if *x* is an array scalar, -- ``x[()]`` returns a 0-dimensional :class:`ndarray` +- ``x[()]`` returns a copy of array scalar +- ``x[...]`` returns a 0-dimensional :class:`ndarray` - ``x['field-name']`` returns the array scalar in the field *field-name*. (*x* can have fields, for example, when it corresponds to a structured data type.) @@ -282,10 +283,10 @@ Defining new types ================== There are two ways to effectively define a new array scalar type -(apart from composing structured types :ref:`dtypes <arrays.dtypes>` from -the built-in scalar types): One way is to simply subclass the -:class:`ndarray` and overwrite the methods of interest. This will work to -a degree, but internally certain behaviors are fixed by the data type of -the array. To fully customize the data type of an array you need to -define a new data-type, and register it with NumPy. Such new types can only +(apart from composing structured types :ref:`dtypes <arrays.dtypes>` from +the built-in scalar types): One way is to simply subclass the +:class:`ndarray` and overwrite the methods of interest. This will work to +a degree, but internally certain behaviors are fixed by the data type of +the array. To fully customize the data type of an array you need to +define a new data-type, and register it with NumPy. Such new types can only be defined in C, using the :ref:`NumPy C-API <c-api>`. diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst index 65840c724..f69eb3ace 100644 --- a/doc/source/user/quickstart.rst +++ b/doc/source/user/quickstart.rst @@ -713,27 +713,32 @@ Several arrays can be stacked together along different axes:: The function `column_stack` stacks 1D arrays as columns into a 2D array. It is equivalent to -`vstack` only for 1D arrays:: +`hstack` only for 2D arrays:: >>> from numpy import newaxis - >>> np.column_stack((a,b)) # With 2D arrays + >>> np.column_stack((a,b)) # with 2D arrays array([[ 8., 8., 1., 8.], [ 0., 0., 0., 4.]]) >>> a = np.array([4.,2.]) - >>> b = np.array([2.,8.]) - >>> a[:,newaxis] # This allows to have a 2D columns vector + >>> b = np.array([3.,8.]) + >>> np.column_stack((a,b)) # returns a 2D array + array([[ 4., 3.], + [ 2., 8.]]) + >>> np.hstack((a,b)) # the result is different + array([ 4., 2., 3., 8.]) + >>> a[:,newaxis] # this allows to have a 2D columns vector array([[ 4.], [ 2.]]) >>> np.column_stack((a[:,newaxis],b[:,newaxis])) - array([[ 4., 2.], + array([[ 4., 3.], + [ 2., 8.]]) + >>> np.hstack((a[:,newaxis],b[:,newaxis])) # the result is the same + array([[ 4., 3.], [ 2., 8.]]) - >>> np.vstack((a[:,newaxis],b[:,newaxis])) # The behavior of vstack is different - array([[ 4.], - [ 2.], - [ 2.], - [ 8.]]) -For arrays of with more than two dimensions, +On the other hand, the function `row_stack` is equivalent to `vstack` +for any input arrays. +In general, for arrays of with more than two dimensions, `hstack` stacks along their second axes, `vstack` stacks along their first axes, and `concatenate` diff --git a/numpy/doc/indexing.py b/numpy/doc/indexing.py index 3e3e95641..39b2c73ed 100644 --- a/numpy/doc/indexing.py +++ b/numpy/doc/indexing.py @@ -200,8 +200,8 @@ one index array with y: :: What results is the construction of a new array where each value of the index array selects one row from the array being indexed and the -resultant array has the resulting shape (size of row, number index -elements). +resultant array has the resulting shape (number of index elements, +size of row). An example of where this may be useful is for a color lookup table where we want to map the values of an image into RGB triples for |