| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
* BUG: properly handle tuple keys in NpZFile.__getitem__
* TST: test tuple rendering specifically.
---------
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
|
|
|
|
|
|
| |
NpzFile inherits from collections.abc.Mapping,
which provides __contains__().
However, it calls __getitem__(),
which can be slow because it performs file decompression on success.
|
|
|
|
|
|
|
|
|
|
|
| |
Improves the repr to include information about the arrays contained, e.g.:
>>> npzfile = np.load('arr.npz')
>>> npzfile
NpzFile 'arr.npz' with keys arr_0, arr_1, arr_2, arr_3, arr_4...
closes #23319
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, the following code:
```
import numpy as np
with open('foo.npy', 'wb') as f:
for i in range(np.random.randint(10)):
np.save(f, 1)
with open('foo.npy', 'rb') as f:
while True:
np.load(f)
```
Will raise:
```
ValueError: Cannot load file containing pickled data when allow_pickle=False
```
While there is no pickled data in the file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This moves dispatching for `__array_function__` into a C-wrapper. This
helps speed for multiple reasons:
* Avoids one additional dispatching function call to C
* Avoids the use of `*args, **kwargs` which is slower.
* For simple NumPy calls we can stay in the faster "vectorcall" world
This speeds up things generally a little, but can speed things up a lot
when keyword arguments are used on lightweight functions, for example::
np.can_cast(arr, dtype, casting="same_kind")
is more than twice as fast with this.
There is one alternative in principle to get best speed: We could inline
the "relevant argument"/dispatcher extraction. That changes behavior in
an acceptable but larger way (passes default arguments).
Unless the C-entry point seems unwanted, this should be a decent step
in the right direction even if we want to do that eventually, though.
Closes gh-20790
Closes gh-18547 (although not quite sure why)
|
|
|
|
|
|
|
| |
whitespace (#22906)
Fix issue with `delimiter=None` and quote character not working properly (not using whitespace delimiter mode).
Closes gh-22899
|
|\
| |
| | |
MAINT: Ensure graceful handling of large header sizes
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This ensures graceful handling of large header files. Unfortunately,
it may be a bit inconvenient for users, thus the new kwarg and the
work-around of also accepting allow-pickle.
See also the documation here:
https://docs.python.org/3.10/library/ast.html#ast.literal_eval
|
| | |
|
|/
|
|
|
| |
Explicitly state that only single-character delimiters
are supported.
|
|
|
|
|
|
|
|
|
| |
* DOC: Make converters param description more concise.
A wording proposal to hopefully make the description of the
converters parameter of loadtxt more clear, and direct readers
to the example section.
* DOC: Combine both suggestions for param descr.
|
| |
|
|
|
|
| |
Also add an example to illustrate how usecols can be used
to read a file with varying number of fields.
|
|
|
|
|
| |
* DOC: mention changes to `max_rows` behaviour
* Clarify how line counting works in max_rows
|
| |
|
| |
|
|\
| |
| | |
ENH: Move `loadtxt` to C for much better speed
|
| |
| |
| |
| |
| | |
- Floats with underscores
- Floats + hex floats.
|
| | |
|
| |
| |
| |
| | |
Includes comments param, which is handled on the Python side.
|
| |
| |
| | |
Adds some tests for the behavior of control characters, e.g. comments, delimiter and quotechar, when they have the same value. At this stage, these tests are more to frame the discussion about what the behavior should be, not to test what it currently is. I personally think raising an exception is correct for most of these situations, though it's worth noting that np.loadtxt currently doesn't for most of these corner cases (and seems to randomly assign precedence to delimiter over comments or vice versa depending on the values).
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
Skiplines is just the more clear names since "rows" make a lot of
sense for output rows (which implies that a line is not empty for
example)
|
| |
| |
| |
| |
| |
| |
| |
| | |
Of course to actually use that many columns you need A LOT of memory
right now. Each field stores at least a UCS4 NUL character, but
the field is padded enough to require 16 bytes.
We always parse a full row, so that requires 20 bytes per field...
(i.e. 32 GiB RAM is not enough to test this :)).
|
| | |
|
| | |
|
| |
| |
| |
| | |
Also correct exception message.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`None` is forced instead in all cases (mainly applies to comments).
This is not really a change in behaviour: It was always utterly
broken.
The one weird thing about it is that `delimiter=None` means
"any whitespace", while `quote=None` and `comments=None` means
that no quote/comment character exists at all.
|
| |
| |
| |
| | |
(Mainly revising the doc strings)
|
| |
| |
| |
| |
| | |
Note that one of the long lines is a link that cannot be split
reasonably.
|
| |
| |
| |
| | |
This is always used if it is a callable.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This replaces `np.loadtxt` with the new textreader.
The file has a few minor cleanups compared to the npreadtext version.
npreadtext was started by Warren Weckesser for inclusion in NumPy
and then very heavily modified by me (Sebastian Berg) to improve it and
slim it down slightly.
Some parts of this code is inspired or even taken from the pandas parser
(mainly the integer parsers are fairly verbatim still).
Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
|
| |
| |
| |
| |
| | |
In 44118aedbac7c1c4465443ec23d104a83b9a24f9 (2010), so this docs
examples would raise a `ValueError`.
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
In fromregex, add a check that verifies that the given dtype is
a structured datatype. This avoids confusing error messages that
can occur when the given data type is not structured.
Also tweaked the code in the Examples section.
Closes gh-8891.
|
| |
|
| |
|
|\
| |
| | |
MAINT: Use a contextmanager to ensure loadtxt closes the input file.
|
| |
| |
| |
| |
| |
| |
| |
| | |
This seems easier to track that a giant try... finally.
Also move the `fencoding` initialization to within the contextmanager,
in the rather unlikely case an exception occurs during the call to
`getpreferredencoding`.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As of Py3, np.compat.unicode == str, but that's not entirely obvious
(it could correspond to some numpy dtype too), so just use plain str.
Likewise for np.compat.int.
tests are intentionally left unchanged, as they can be considered as
implicitly testing the np.compat.py3k interface as well.
|