extend loadtxt documentation
This commit is contained in:
parent
9ba136acd4
commit
6dcad4424c
6 changed files with 73 additions and 29 deletions
|
|
@ -33,7 +33,7 @@
|
|||
#include "user/user.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define ULAB_VERSION 4.4.0
|
||||
#define ULAB_VERSION 4.4.2
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ copyright = '2019-2022, Zoltán Vörös and contributors'
|
|||
author = 'Zoltán Vörös'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '4.4.1'
|
||||
release = '4.4.2'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1027,11 +1027,16 @@ https://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html
|
|||
|
||||
The function reads data from a text file, and returns the generated
|
||||
array. It takes a file name as the single positional argument, and the
|
||||
``dtype`` (with a default value of ``float``), the ``comments`` (with a
|
||||
default value of ``#``), the ``delimiter`` (with a default value of
|
||||
``,``), ``usecols`` (with a default of all columns), and the
|
||||
``max_rows`` (with a default of all rows) keyword arguments. If
|
||||
``dtype`` is supplied and is not ``float``, the data entries will be
|
||||
following keyword arguments:
|
||||
|
||||
1. ``comments='#'``
|
||||
2. ``dtype=float``
|
||||
3. ``delimiter=','``
|
||||
4. ``max_rows`` (with a default of all rows)
|
||||
5. ``skip_rows=0``
|
||||
6. ``usecols`` (with a default of all columns)
|
||||
|
||||
If ``dtype`` is supplied and is not ``float``, the data entries will be
|
||||
converted to the appropriate integer type by rounding the values.
|
||||
|
||||
.. code::
|
||||
|
|
@ -1046,8 +1051,11 @@ converted to the appropriate integer type by rounding the values.
|
|||
print('\nread maximum 5 rows (first row is a comment line)')
|
||||
print(np.loadtxt('loadtxt.dat', max_rows=5))
|
||||
|
||||
print('\nread maximum 5 rows, convert dtype')
|
||||
print('\nread maximum 5 rows, convert dtype (first row is a comment line)')
|
||||
print(np.loadtxt('loadtxt.dat', max_rows=5, dtype=np.uint8))
|
||||
|
||||
print('\nskip the first 3 rows, convert dtype (first row is a comment line)')
|
||||
print(np.loadtxt('loadtxt.dat', skiprows=3, dtype=np.uint8))
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
|
|
@ -1068,12 +1076,21 @@ converted to the appropriate integer type by rounding the values.
|
|||
[8.0, 9.0, 10.0, 11.0],
|
||||
[12.0, 13.0, 14.0, 15.0]], dtype=float64)
|
||||
|
||||
read maximum 5 rows, convert dtype
|
||||
read maximum 5 rows, convert dtype (first row is a comment line)
|
||||
array([[0, 1, 2, 3],
|
||||
[4, 5, 6, 7],
|
||||
[8, 9, 10, 11],
|
||||
[12, 13, 14, 15]], dtype=uint8)
|
||||
|
||||
skip the first 3 rows, convert dtype (first row is a comment line)
|
||||
array([[8, 9, 10, 11],
|
||||
[12, 13, 14, 15],
|
||||
[16, 17, 18, 19],
|
||||
[20, 21, 22, 23],
|
||||
[24, 25, 26, 27],
|
||||
[28, 29, 30, 31],
|
||||
[32, 33, 34, 35]], dtype=uint8)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-01-29T21:24:54.931042Z",
|
||||
"start_time": "2022-01-29T21:24:54.927243Z"
|
||||
"end_time": "2022-02-01T17:37:25.505687Z",
|
||||
"start_time": "2022-02-01T17:37:25.493850Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
|
|
@ -49,11 +49,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-01-29T21:24:55.649634Z",
|
||||
"start_time": "2022-01-29T21:24:55.626921Z"
|
||||
"end_time": "2022-02-01T17:37:25.717714Z",
|
||||
"start_time": "2022-02-01T17:37:25.532299Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
|
|
@ -1474,16 +1474,25 @@
|
|||
"\n",
|
||||
"`numpy`: https://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html\n",
|
||||
"\n",
|
||||
"The function reads data from a text file, and returns the generated array. It takes a file name as the single positional argument, and the `dtype` (with a default value of `float`), the `comments` (with a default value of `#`), the `delimiter` (with a default value of `,`), `usecols` (with a default of all columns), and the `max_rows` (with a default of all rows) keyword arguments. If `dtype` is supplied and is not `float`, the data entries will be converted to the appropriate integer type by rounding the values."
|
||||
"The function reads data from a text file, and returns the generated array. It takes a file name as the single positional argument, and the following keyword arguments:\n",
|
||||
"\n",
|
||||
"1. `comments='#'`\n",
|
||||
"1. `dtype=float`\n",
|
||||
"1. `delimiter=','`\n",
|
||||
"1. `max_rows` (with a default of all rows) \n",
|
||||
"1. `skip_rows=0`\n",
|
||||
"1. `usecols` (with a default of all columns)\n",
|
||||
"\n",
|
||||
"If `dtype` is supplied and is not `float`, the data entries will be converted to the appropriate integer type by rounding the values."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 4,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-01-29T21:26:36.258135Z",
|
||||
"start_time": "2022-01-29T21:26:36.236256Z"
|
||||
"end_time": "2022-02-01T17:41:22.384706Z",
|
||||
"start_time": "2022-02-01T17:41:22.362821Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
|
|
@ -1508,12 +1517,21 @@
|
|||
" [8.0, 9.0, 10.0, 11.0],\n",
|
||||
" [12.0, 13.0, 14.0, 15.0]], dtype=float64)\n",
|
||||
"\n",
|
||||
"read maximum 5 rows, convert dtype\n",
|
||||
"read maximum 5 rows, convert dtype (first row is a comment line)\n",
|
||||
"array([[0, 1, 2, 3],\n",
|
||||
" [4, 5, 6, 7],\n",
|
||||
" [8, 9, 10, 11],\n",
|
||||
" [12, 13, 14, 15]], dtype=uint8)\n",
|
||||
"\n",
|
||||
"skip the first 3 rows, convert dtype (first row is a comment line)\n",
|
||||
"array([[8, 9, 10, 11],\n",
|
||||
" [12, 13, 14, 15],\n",
|
||||
" [16, 17, 18, 19],\n",
|
||||
" [20, 21, 22, 23],\n",
|
||||
" [24, 25, 26, 27],\n",
|
||||
" [28, 29, 30, 31],\n",
|
||||
" [32, 33, 34, 35]], dtype=uint8)\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
|
|
@ -1529,8 +1547,11 @@
|
|||
"print('\\nread maximum 5 rows (first row is a comment line)')\n",
|
||||
"print(np.loadtxt('loadtxt.dat', max_rows=5))\n",
|
||||
"\n",
|
||||
"print('\\nread maximum 5 rows, convert dtype')\n",
|
||||
"print(np.loadtxt('loadtxt.dat', max_rows=5, dtype=np.uint8))"
|
||||
"print('\\nread maximum 5 rows, convert dtype (first row is a comment line)')\n",
|
||||
"print(np.loadtxt('loadtxt.dat', max_rows=5, dtype=np.uint8))\n",
|
||||
"\n",
|
||||
"print('\\nskip the first 3 rows, convert dtype (first row is a comment line)')\n",
|
||||
"print(np.loadtxt('loadtxt.dat', skiprows=3, dtype=np.uint8))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
Tue, 1 Feb 2022
|
||||
|
||||
version 4.4.2
|
||||
|
||||
add skiprows keyword to loadtxt
|
||||
|
||||
Sat, 29 Jan 2022
|
||||
|
||||
version 4.4.1
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-01-29T21:27:54.988801Z",
|
||||
"start_time": "2022-01-29T21:27:54.980856Z"
|
||||
"end_time": "2022-02-01T17:41:38.040350Z",
|
||||
"start_time": "2022-02-01T17:41:38.023988Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
"author = 'Zoltán Vörös'\n",
|
||||
"\n",
|
||||
"# The full version, including alpha/beta/rc tags\n",
|
||||
"release = '4.4.1'\n",
|
||||
"release = '4.4.2'\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# -- General configuration ---------------------------------------------------\n",
|
||||
|
|
@ -218,8 +218,8 @@
|
|||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-01-29T21:27:59.573556Z",
|
||||
"start_time": "2022-01-29T21:27:57.323819Z"
|
||||
"end_time": "2022-02-01T17:41:42.215395Z",
|
||||
"start_time": "2022-02-01T17:41:40.650763Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
|
|
@ -259,8 +259,8 @@
|
|||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2022-01-29T21:28:16.742315Z",
|
||||
"start_time": "2022-01-29T21:28:11.284954Z"
|
||||
"end_time": "2022-02-01T17:42:04.318049Z",
|
||||
"start_time": "2022-02-01T17:41:59.671788Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
|
|
|
|||
Loading…
Reference in a new issue