diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2017-06-10 15:56:14 +1200 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@gmail.com> | 2017-06-10 18:19:17 +1200 |
commit | 34075a54e7aa10e80d41ef33ec7102292ecff0d5 (patch) | |
tree | 537ce22035ad4a22e7eba29720124b5eb82d4574 /doc/source/user | |
parent | fa913a8ea6a8b363962dec6d656049a1371b53d9 (diff) | |
download | numpy-34075a54e7aa10e80d41ef33ec7102292ecff0d5.tar.gz |
DOC: BLD: fix lots of Sphinx warnings/errors.
Diffstat (limited to 'doc/source/user')
-rw-r--r-- | doc/source/user/basics.io.genfromtxt.rst | 92 | ||||
-rw-r--r-- | doc/source/user/c-info.beyond-basics.rst | 4 |
2 files changed, 48 insertions, 48 deletions
diff --git a/doc/source/user/basics.io.genfromtxt.rst b/doc/source/user/basics.io.genfromtxt.rst index 1048ab725..2bdd5a0d0 100644 --- a/doc/source/user/basics.io.genfromtxt.rst +++ b/doc/source/user/basics.io.genfromtxt.rst @@ -46,12 +46,12 @@ ends with ``'.gz'``, a :class:`gzip` archive is expected; if it ends with Splitting the lines into columns ================================ -The :keyword:`delimiter` argument ---------------------------------- +The ``delimiter`` argument +-------------------------- Once the file is defined and open for reading, :func:`~numpy.genfromtxt` splits each non-empty line into a sequence of strings. Empty or commented -lines are just skipped. The :keyword:`delimiter` keyword is used to define +lines are just skipped. The ``delimiter`` keyword is used to define how the splitting should take place. Quite often, a single character marks the separation between columns. For @@ -71,7 +71,7 @@ spaces are considered as a single white space. Alternatively, we may be dealing with a fixed-width file, where columns are defined as a given number of characters. In that case, we need to set -:keyword:`delimiter` to a single integer (if all the columns have the same +``delimiter`` to a single integer (if all the columns have the same size) or to a sequence of integers (if columns can have different sizes):: >>> data = " 1 2 3\n 4 5 67\n890123 4" @@ -86,13 +86,13 @@ size) or to a sequence of integers (if columns can have different sizes):: [ 4., 567., 9.]]) -The :keyword:`autostrip` argument ---------------------------------- +The ``autostrip`` argument +-------------------------- By default, when a line is decomposed into a series of strings, the individual entries are not stripped of leading nor trailing white spaces. This behavior can be overwritten by setting the optional argument -:keyword:`autostrip` to a value of ``True``:: +``autostrip`` to a value of ``True``:: >>> data = "1, abc , 2\n 3, xxx, 4" >>> # Without autostrip @@ -107,10 +107,10 @@ This behavior can be overwritten by setting the optional argument dtype='|U5') -The :keyword:`comments` argument --------------------------------- +The ``comments`` argument +------------------------- -The optional argument :keyword:`comments` is used to define a character +The optional argument ``comments`` is used to define a character string that marks the beginning of a comment. By default, :func:`~numpy.genfromtxt` assumes ``comments='#'``. The comment marker may occur anywhere on the line. Any character present after the comment @@ -143,15 +143,15 @@ marker(s) is simply ignored:: Skipping lines and choosing columns =================================== -The :keyword:`skip_header` and :keyword:`skip_footer` arguments +The ``skip_header`` and ``skip_footer`` arguments --------------------------------------------------------------- The presence of a header in the file can hinder data processing. In that -case, we need to use the :keyword:`skip_header` optional argument. The +case, we need to use the ``skip_header`` optional argument. The values of this argument must be an integer which corresponds to the number of lines to skip at the beginning of the file, before any other action is performed. Similarly, we can skip the last ``n`` lines of the file by -using the :keyword:`skip_footer` attribute and giving it a value of ``n``:: +using the ``skip_footer`` attribute and giving it a value of ``n``:: >>> data = "\n".join(str(i) for i in range(10)) >>> np.genfromtxt(BytesIO(data),) @@ -164,12 +164,12 @@ By default, ``skip_header=0`` and ``skip_footer=0``, meaning that no lines are skipped. -The :keyword:`usecols` argument -------------------------------- +The ``usecols`` argument +------------------------ In some cases, we are not interested in all the columns of the data but only a few of them. We can select which columns to import with the -:keyword:`usecols` argument. This argument accepts a single integer or a +``usecols`` argument. This argument accepts a single integer or a sequence of integers corresponding to the indices of the columns to import. Remember that by convention, the first column has an index of 0. Negative integers behave the same as regular Python negative indexes. @@ -183,7 +183,7 @@ can use ``usecols=(0, -1)``:: [ 4., 6.]]) If the columns have names, we can also select which columns to import by -giving their name to the :keyword:`usecols` argument, either as a sequence +giving their name to the ``usecols`` argument, either as a sequence of strings or a comma-separated string:: >>> data = "1 2 3\n4 5 6" @@ -203,12 +203,12 @@ Choosing the data type ====================== The main way to control how the sequences of strings we have read from the -file are converted to other types is to set the :keyword:`dtype` argument. +file are converted to other types is to set the ``dtype`` argument. Acceptable values for this argument are: * a single type, such as ``dtype=float``. The output will be 2D with the given dtype, unless a name has been - associated with each column with the use of the :keyword:`names` argument + associated with each column with the use of the ``names`` argument (see below). Note that ``dtype=float`` is the default for :func:`~numpy.genfromtxt`. * a sequence of types, such as ``dtype=(int, float, float)``. @@ -223,7 +223,7 @@ Acceptable values for this argument are: In all the cases but the first one, the output will be a 1D array with a structured dtype. This dtype has as many fields as items in the sequence. -The field names are defined with the :keyword:`names` keyword. +The field names are defined with the ``names`` keyword. When ``dtype=None``, the type of each column is determined iteratively from @@ -242,8 +242,8 @@ significantly slower than setting the dtype explicitly. Setting the names ================= -The :keyword:`names` argument ------------------------------ +The ``names`` argument +---------------------- A natural approach when dealing with tabular data is to allocate a name to each column. A first possibility is to use an explicit structured dtype, @@ -254,7 +254,7 @@ as mentioned previously:: array([(1, 2, 3), (4, 5, 6)], dtype=[('a', '<i8'), ('b', '<i8'), ('c', '<i8')]) -Another simpler possibility is to use the :keyword:`names` keyword with a +Another simpler possibility is to use the ``names`` keyword with a sequence of strings or a comma-separated string:: >>> data = BytesIO("1 2 3\n 4 5 6") @@ -267,7 +267,7 @@ By giving a sequence of names, we are forcing the output to a structured dtype. We may sometimes need to define the column names from the data itself. In -that case, we must use the :keyword:`names` keyword with a value of +that case, we must use the ``names`` keyword with a value of ``True``. The names will then be read from the first line (after the ``skip_header`` ones), even if the line is commented out:: @@ -276,7 +276,7 @@ that case, we must use the :keyword:`names` keyword with a value of array([(1.0, 2.0, 3.0), (4.0, 5.0, 6.0)], dtype=[('a', '<f8'), ('b', '<f8'), ('c', '<f8')]) -The default value of :keyword:`names` is ``None``. If we give any other +The default value of ``names`` is ``None``. If we give any other value to the keyword, the new names will overwrite the field names we may have defined with the dtype:: @@ -288,8 +288,8 @@ have defined with the dtype:: dtype=[('A', '<i8'), ('B', '<f8'), ('C', '<i8')]) -The :keyword:`defaultfmt` argument ----------------------------------- +The ``defaultfmt`` argument +--------------------------- If ``names=None`` but a structured dtype is expected, names are defined with the standard NumPy default of ``"f%i"``, yielding names like ``f0``, @@ -308,7 +308,7 @@ dtype, the missing names will be defined with this default template:: array([(1, 2.0, 3), (4, 5.0, 6)], dtype=[('a', '<i8'), ('f0', '<f8'), ('f1', '<i8')]) -We can overwrite this default with the :keyword:`defaultfmt` argument, that +We can overwrite this default with the ``defaultfmt`` argument, that takes any format string:: >>> data = BytesIO("1 2 3\n 4 5 6") @@ -333,16 +333,16 @@ correspond to the name of a standard attribute (like ``size`` or ``shape``), which would confuse the interpreter. :func:`~numpy.genfromtxt` accepts three optional arguments that provide a finer control on the names: - :keyword:`deletechars` + ``deletechars`` Gives a string combining all the characters that must be deleted from the name. By default, invalid characters are ``~!@#$%^&*()-=+~\|]}[{';: /?.>,<``. - :keyword:`excludelist` + ``excludelist`` Gives a list of the names to exclude, such as ``return``, ``file``, ``print``... If one of the input name is part of this list, an underscore character (``'_'``) will be appended to it. - :keyword:`case_sensitive` + ``case_sensitive`` Whether the names should be case-sensitive (``case_sensitive=True``), converted to upper case (``case_sensitive=False`` or ``case_sensitive='upper'``) or to lower case @@ -353,15 +353,15 @@ accepts three optional arguments that provide a finer control on the names: Tweaking the conversion ======================= -The :keyword:`converters` argument ----------------------------------- +The ``converters`` argument +--------------------------- Usually, defining a dtype is sufficient to define how the sequence of strings must be converted. However, some additional control may sometimes be required. For example, we may want to make sure that a date in a format ``YYYY/MM/DD`` is converted to a :class:`datetime` object, or that a string like ``xx%`` is properly converted to a float between 0 and 1. In such -cases, we should define conversion functions with the :keyword:`converters` +cases, we should define conversion functions with the ``converters`` arguments. The value of this argument is typically a dictionary with column indices or @@ -427,16 +427,16 @@ float. However, user-defined converters may rapidly become cumbersome to manage. The :func:`~nummpy.genfromtxt` function provides two other complementary -mechanisms: the :keyword:`missing_values` argument is used to recognize -missing data and a second argument, :keyword:`filling_values`, is used to +mechanisms: the ``missing_values`` argument is used to recognize +missing data and a second argument, ``filling_values``, is used to process these missing data. -:keyword:`missing_values` -------------------------- +``missing_values`` +------------------ By default, any empty string is marked as missing. We can also consider more complex strings, such as ``"N/A"`` or ``"???"`` to represent missing -or invalid data. The :keyword:`missing_values` argument accepts three kind +or invalid data. The ``missing_values`` argument accepts three kind of values: a string or a comma-separated string @@ -451,8 +451,8 @@ of values: define a default applicable to all columns. -:keyword:`filling_values` -------------------------- +``filling_values`` +------------------ We know how to recognize missing data, but we still need to provide a value for these missing entries. By default, this value is determined from the @@ -469,8 +469,8 @@ Expected type Default ============= ============== We can get a finer control on the conversion of missing values with the -:keyword:`filling_values` optional argument. Like -:keyword:`missing_values`, this argument accepts different kind of values: +``filling_values`` optional argument. Like +``missing_values``, this argument accepts different kind of values: a single value This will be the default for all columns @@ -497,13 +497,13 @@ and second column, and to -999 if they occur in the last column:: dtype=[('a', '<i8'), ('b', '<i8'), ('c', '<i8')]) -:keyword:`usemask` ------------------- +``usemask`` +----------- We may also want to keep track of the occurrence of missing data by constructing a boolean mask, with ``True`` entries where data was missing and ``False`` otherwise. To do that, we just have to set the optional -argument :keyword:`usemask` to ``True`` (the default is ``False``). The +argument ``usemask`` to ``True`` (the default is ``False``). The output array will then be a :class:`~numpy.ma.MaskedArray`. diff --git a/doc/source/user/c-info.beyond-basics.rst b/doc/source/user/c-info.beyond-basics.rst index 1f19c8405..5c321088d 100644 --- a/doc/source/user/c-info.beyond-basics.rst +++ b/doc/source/user/c-info.beyond-basics.rst @@ -390,8 +390,8 @@ an error condition set if it was not successful. (optional) Specify any optional data needed by the function which will be passed when the function is called. - .. index:: - pair: dtype; adding new +.. index:: + pair: dtype; adding new Subtyping the ndarray in C |