summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
Commit message (Collapse)AuthorAgeFilesLines
* BUG: properly handle tuple keys in NpZFile.__getitem__ (#23757)Nathan Goldbaum2023-05-121-0/+11
| | | | | | | | | * BUG: properly handle tuple keys in NpZFile.__getitem__ * TST: test tuple rendering specifically. --------- Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* ENH: ``__repr__`` for NpzFile object (#23357)Ganesh Kathiresan2023-04-061-2/+17
| | | | | | | | | | | 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>
* MAINT, DOC: string_ → bytes_ and unicode_ → str_Dimitri Papadopoulos2023-02-101-12/+12
|
* API: Raise EOFError when trying to load past the end of a `.npy` file (#23105)Noé Rubinstein2023-01-271-0/+10
| | | | | | | | | | | | | | | | | | 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.
* TST: Skip tests that are not currently supported in wasmHood Chatham2022-11-111-1/+3
|
* STY: Make linter happySebastian Berg2022-10-271-0/+1
| | | | Not new things, but in touched lines...
* TST,MAINT: Replace most `setup` with `setup_method` (also teardown)Sebastian Berg2022-10-271-2/+2
| | | | | | | | In some cases, the replacement is clearly not what is intended, in those (where setup was called explicitly), I mostly renamed `setup` to `_setup`. The `test_ccompile_opt` is a bit confusing, so left it right now (this will probably fail)
* MAINT: remove u-prefix for former Unicode strings (#22479)Mike Taves2022-10-261-14/+14
|
* MAINT: Fix typos found by codespellDimitri Papadopoulos2022-10-071-1/+1
|
* TST,BUG: Us context from spawn to fork in (#22204)Jyn Spring 琴春2022-09-071-2/+7
| | | | | | | | | | | | | | | Since Python 3.8, the default start method for multiprocessing has been changed from fork to spawn on macOS The default start method is still fork on other Unix platforms[1], causing inconsistency on memory sharing model It will cause a memory-sharing problem for the test test_large_zip on macOS as the memory sharing model between spawn and fork is different The fix Change the start method for this test back to fork under this testcase context In this test case context, the bug that caused default start method changed to spawn for macOS will not be triggered It is context limited, so this change will not affect default start method other than test_large_zip All platforms have the same memory sharing model now After the change, test_large_zip is passed on macOS https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods Closes gh-22203
* TEST: on PyPy, skip hanging slow test [wheel build]mattip2022-05-021-0/+1
|
* TST: Skip unparsable field error tests on PyPySebastian Berg2022-01-191-0/+6
| | | | | | PyPy has a small bug with error formatting, so these cause it to crash. Simply skip the tests on old PyPy versions for now. (Matti fixed the issue long ago, just waiting for a new PyPy release :))
* TST,STY: Add small additional tests for converters/usecolsSebastian Berg2022-01-141-1/+1
| | | | | Also fix style a bit to silence linter (hopefully), removes some black style, but I am not too opinionated about that :)
* TST: Move most new loadtxt tests to its own fileSebastian Berg2022-01-141-767/+0
| | | | | | | | | | | | | | | | This also adds two basic new tests around files/strings containing the \0 character (prooving that we handle that gracefully). Also adds tests for: * the `_` thousands delimiter (should fail, but doesn't for float128 right now) * Failure modes when the number of rows changes (negative specifically) Many of these tests came originally from Warren Weckesser and others were added by Ross Barnowsky: Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* TST: Add test for hard/impossible to reach universal-newline support pathsSebastian Berg2022-01-141-0/+15
|
* TST: Improve test coverage, replace impossible error with assertSebastian Berg2022-01-141-0/+49
|
* TST,MAINT: New tests, byteswap cleanups and fixed assertSebastian Berg2022-01-141-6/+25
|
* TST,BUG: Additional bad-file-like test, add missing error path freeSebastian Berg2022-01-141-0/+14
| | | | And remove one silly leftover struct member that was unused
* MAINT,TST,BUG: Simplify streamer init, fix issues, and add testsSebastian Berg2022-01-141-0/+45
|
* ENH: Give warning for empty-lines not counting towards max-rowsSebastian Berg2022-01-141-0/+24
| | | | | | This also slightly cleans up the empty-line handling: previously we sometimes just had some extra empty-lines that just effectively never mattered
* MAINT: Move usecol handling to C and support more than integer colsSebastian Berg2022-01-141-2/+13
| | | | | | | | 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 :)).
* TST: Add test to cover copyswap (byte-swap and unaligned)Sebastian Berg2022-01-141-0/+13
|
* BUG,TST: Add test for huge-float buffer path and ensure error returnSebastian Berg2022-01-141-0/+9
| | | | If a memory error happens, we should at least not crash the interpreter
* BUG: Fix complex parser and add tests for whitespace and failure pathsSebastian Berg2022-01-141-0/+27
|
* Add warning on empty file + tests.Ross Barnowski2022-01-141-4/+2
|
* Add UserWarning when reading no data.Ross Barnowski2022-01-141-0/+23
|
* rm incorrect comment.Ross Barnowski2022-01-141-1/+0
|
* Add tests for empty quotes and escaped quotechars.Ross Barnowski2022-01-141-0/+14
|
* TST: structured dtype w/ quotes.Ross Barnowski2022-01-141-0/+29
|
* Add tests for quote+multichar comments.Ross Barnowski2022-01-141-0/+23
| | | | Also correct exception message.
* Add test to check quoting support disabled by default.Ross Barnowski2022-01-141-0/+16
|
* TST: Add tests for quote character support.Ross Barnowski2022-01-141-0/+15
|
* TST: Fix test to align with stricter integer parsingSebastian Berg2022-01-141-24/+4
|
* TST: Small fixups for tests to make sure they pass againSebastian Berg2022-01-141-3/+3
|
* Port over tests from npreadtext test suiteRoss Barnowski2022-01-141-0/+484
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add test for parsing scientific notation. - Add multiple-char comment test. - Port over tests for structured dtypes. - Add tests for exceptions on skiprows/max_rows. - port over ndmin tests. - Make structured data reusable, add unpack tests. - Port over delimiter tests. - Port over maxrows test w/ various dtypes. - Port over test of exception msg on parse failure. - Port over test for converters w/neg indices. - Port over usecols tests - Port over unicode tests. - Port over more converter tests. - Port over test for large rows. - Port over test for string-len discovery. - Port over float conversion accuracy test. - Port over bool test. - Add test for implicit float->int conversion. - Port over complex parsing tests. - Port over tests for reading from generator. - Port over object cleanup test. - Port over bytes incompat test. - Port over converters tests. Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* ENH: Raise an error for (most) stray newline charactersSebastian Berg2022-01-141-2/+2
| | | | | | | | This makes it strict that newline characters _within_ a single line (which is only possible if the user passes in a manual iterator of strings), is considered weird and rejected. An example is: `np.loadtxt(['1\n1', "2 2"], dtype=np.int64)`
* TST: Fixup current loadtxt tests for changesSebastian Berg2022-01-141-8/+7
|
* ENH: add ndmin to `genfromtxt` behaving the same as `loadtxt` (#20500)Ivan Gonzalez2021-12-161-0/+11
|
* BUG: Fix types of errors raised by genfromtxt (#20389)André Elimelek de Weber2021-12-031-0/+4
|
* MAINT: lib: Check that the dtype given to fromregex is structured.warren2021-09-221-0/+8
| | | | | | | | | | 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.
* ENH: Allow `np.fromregex` to accept `os.PathLike` implementationsBas van Beek2021-08-161-2/+4
|
* Rm numpy.lib.npyio.mafromtxt.Ross Barnowski2021-08-051-11/+0
|
* Rm numpy.lib.npyio.ndfromtxt.Ross Barnowski2021-08-051-11/+0
|
* PERF: Speed-up common case of loadtxt()ing non-hex floats. (#19598)Antony Lee2021-08-051-0/+22
| | | | | | | | | | | | | * PERF: Speed-up common case of loadtxt()ing non-hex floats. `python runtests.py --bench bench_io` reports a ~5-10% perf gain. * TST: Add tests to check fromhex not called unintentionally. Adds regression tests to check that the logic surrounding when the default floatconv applies the fromhex conversion does not change. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* fix from reviewmattip2021-01-241-2/+5
|
* TST: raise memory limit for testmattip2021-01-221-1/+1
|
* ENH: Allow genfromtxt to unpack structured arrays (#16650)Andrew Eckart2020-09-111-1/+46
| | | | | | | | | | | | | * ENH: Allow genfromtxt to unpack structured arrays genfromtxt failed to transpose output when unpack=True and `dtype` was structured (or None). This patch resolves the issue by returning a list of arrays, as in `loadtxt`. Co-authored-by: Matti Picus <matti.picus@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* MAINT: Remove users of `numpy.compat.bytes`Eric Wieser2020-08-311-1/+1
| | | | Some more Python 2 cleanup.
* TST: fix tests for windows + PyPymattip2020-07-301-1/+8
|
* TST, BUG: Re-raise MemoryError exception in test_large_zip's process (gh-16890)Antonio Larrosa2020-07-181-8/+22
| | | | | | | | | | | | Since #15893, test_large_zip's actual test is run in a child process, so when this test raises a MemoryError exception, the exception is lost and the @requires_memory decorator can't catch it to return an xfail. This commit uses a boolean variable in shared memory to flag if the exception was raised, and in that case, re-raise it in the parent process. Fixes #16889