summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
Commit message (Collapse)AuthorAgeFilesLines
...
* MAINT: Remove use of unittest in NumPy tests.xoviat2018-03-211-2/+2
| | | | | | | | | | | | | | | | This removes a few left over uses of unittest. The main changes apart from removal of Test case are: * `setUp` replaced by nose and pytest compatible `setup` * `tearDown` replaced by nose and pytest compatible `teardown` * `assertRaises` replaced by `assert_raises` * `assertEqual` replaced by `assert_equal` The last two are in `numpy/testings/tests/test_utils.py`, so may seem a but circular, but at least are limited to those two functions. The use of `setup` and `teardown`, can be fixed up with the pytest equivalents after we have switched to pytest.
* Fix low-hanging Pypy compatibility issues (#10737)Pauli Virtanen2018-03-121-1/+2
| | | | | | | | | | | | | * TST: skip refcount-requiring tests if sys.refcount is missing * ENH: io: add refcheck=False to a safe .resize() call The array is allocated immediately above, and the resize always succeeds so it is not necessary to check it. Fixes Pypy compatibility. * TST: remove unused code * TST: factor skipif(not HAS_REFCOUNT) into a separate decorator
* Merge pull request #10501 from msornay/fromregex-bytesEric Wieser2018-02-201-1/+8
|\ | | | | BUG: fromregex: asbytes called on regexp objects
| * BUG: fromregex: asbytes called on regexp objectsMathieu Sornay2018-02-051-1/+8
| | | | | | | | | | | | When calling fromregex() with a binary stream and a regular expression object, asbytes() was called on the regexp object, resulting in an incorrect regular expression being compiled and used.
* | Merge pull request #10401 from eric-wieser/fix-10394Charles Harris2018-02-061-0/+7
|\ \ | |/ |/| BUG: Resize bytes_ columns in genfromtxt
| * BUG: Resize bytes_ columns in genfromtxtEric Wieser2018-01-151-0/+7
| | | | | | | | Fixes gh-10394, due to regression in gh-10054
* | More misc. typosluz.paz2018-01-041-4/+4
|/ | | Found via `codespell`
* MAINT: Various minor code cleanups.Charles Harris2017-11-241-56/+59
| | | | Minor cleanups of old code to reflect more modern usage.
* ENH: Add encoding option to numpy text IO.Julian Taylor2017-11-211-31/+361
| | | | | | | | | | | This modifies loadtxt and genfromtxt in several ways intended to add unicode support for text files by adding an `encoding` keyword to np.load, np.genfromtxt, np.savetxt, and np.fromregex. The original treatment of the relevant files was to open them as byte files, whereas they are now opened as text files with an encoding. When read, they are decoded to unicode strings for Python3 compatibility, and when written, they are encoded as specified. For backward compatibility, the default encoding in both cases is latin1.
* ENH Better error message for savetxt when X.ndim > 2Nelle Varoquaux2017-09-201-0/+6
| | | | | savetxt does not support saving arrays of dimension 0 or higher than 2. This pull request improves the message of the error raised.
* TST: Fix/Remove old unit tests for structure assignmentAllan Haldane2017-09-071-2/+2
|
* MAINT/DOC: Use builtin when np.{x} is builtins.{x}.Eric Wieser2017-08-051-20/+20
| | | | | | | This is the case for x in {int, bool, str, float, complex, object}. Using the np.{x} version is deceptive as it suggests that there is a difference. This change doesn't affect any external behaviour. The `long` type is missing in python 3, so np.long is still useful
* TST: Remove unittest dependencies in numpy/lib/tests.Charles Harris2017-07-241-16/+16
|
* Merge pull request #6632 from mcmtroffaes/feature/fromfile-ioopen-bugCharles Harris2017-04-141-2/+3
|\ | | | | TST/BUG: fromfile - fix test and expose bug with io class argument
| * BUG: npy_PyFile_Dup2 - fix PyFile_AsFile failing on io style classesMatthias C. M. Troffaes2016-09-081-2/+3
| | | | | | | | | | | | | | | | | | | | This bug only manifests itself in the Python 2 code path. Falls back to the current Python 3 code path also on Python 2 because the Python 3 code path is written precisely to handle this situation. Also fix tests, and clarify in the documentation that the current implementation requires the stream to be seekable.
* | MAINT: Replace unicode() with u prefixEric Wieser2017-03-251-1/+1
| |
* | MAINT: Other cleanup Python < 2.7 and Python3 < 3.4Alexandr Shadchin2016-12-091-6/+4
| |
* | BUG: Apply more robust string converts in loadtxtgfyoung2016-12-081-0/+9
|/ | | | | | | | | | The original dtype converters for bytes and str did not account for converting objects of str or bytes dtype respectively. Replace the original converters with those from numpy.compat, which are much more robust. Closes gh-8033.
* TST: Use new warnings context manager in all testsSebastian Berg2016-09-021-16/+13
| | | | | | | | In some places, just remove aparently unnecessary filters. After this, all cases of ignore filters should be removed from the tests, making testing (even multiple runs) normally fully predictable.
* ENH: skip or avoid gc/objectmodel differences btwn pypy and cpythonmattip2016-08-151-1/+2
|
* TST: mark two tests in numpy.lib as slow, speeds up numpy.lib tests by 5xRalf Gommers2016-05-161-2/+2
|
* TST: fix test errors for Pathlib usage tests in io.py.Ralf Gommers2016-05-151-10/+13
| | | | | | | | | | | | | | | | | Pathlib was only added to the stdlib in Python 3.4, and there it can handle string type input for a file with UTF8 encoding. But the Patlib version on PyPi that can be installed for Python 2.7 doesn't accept strings, gives errors like: ====================================================================== ERROR: test_ndfromtxt (test_io.TestPathUsage) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/rgommers/Code/numpy/numpy/testing/decorators.py", line 147, in skipper_func return f(*args, **kwargs) File "/home/rgommers/Code/numpy/numpy/lib/tests/test_io.py", line 1888, in test_ndfromtxt f.write('1 2\n3 4') TypeError: must be unicode, not str
* ENH: Add support for pathlib.Path objects to save/load functionsWendell Smith2016-04-061-1/+101
|
* ENH: usecols now accepts an int when only one column has to be readI--P2016-02-011-0/+38
|
* TST: Add missing suffix to temppath managerSebastian Berg2016-01-301-1/+1
| | | | | Without the suffix, np.save creates a new file and the file does not get cleaned up.
* MAINT: Simplify some tests using temppath context manager.Charles Harris2015-12-261-55/+31
| | | | | | | | | | | | | | | | | | | | | | | | This replaces code of the pattern ``` fd, name = tempfile.mkstemp(...) os.close(fd) try: do stuff with name finally: os.remove(name) ``` with ``` with temppath() as name: do stuff with name ``` A few more complicated cases are also handled. The remains some particularly gnarly code the could probably be refactored to use temppath, but that is a more demanding project.
* MAINT: Use temppath in test_not_closing_opened_fid.Charles Harris2015-12-201-21/+12
| | | | | The test is in numpy/lib/tests/test_io.py. This commit is intended as a demonstration of using temppath.
* MAINT: Replace assert with assert_(...) in some tests.Charles Harris2015-12-101-3/+3
|
* TST: attempt to make test_load_refcount deterministicNathaniel J. Smith2015-10-281-6/+11
| | | | | | Use a different strategy to detect whether np.load creates cycles. Fixes gh-6571, I hope.
* STY: PEP8 and pyflakes fixes for numpy/lib/testsCharles Harris2015-07-251-82/+73
|
* BUG: Fix imports in test_io.py and test_recfunctions.py.Charles Harris2015-07-041-7/+9
| | | | | | | | | Those test functions were incorrectly importing test functions from numpy/ma/testutils that were actually not defined there, but rather in numpy/testing. That did not cause an error when testutils was '*' importing all the test functions, but it was deceptive as some of the functions might appear to support masked arrays when they do not.
* ENH: Multiple comment tokens in loadtxtJoseph Martinot-Lagarde2015-04-221-3/+37
|
* BUG: loadtxt fails with complex data in Python 3.Charles Harris2015-03-111-0/+8
| | | | | | | | | | | The problem is that the Python complex type constructor only accepts a pair of numbers or a string, unlike other numeric types it does not work with byte strings. The numpy error is subtle, as loadtxt opens the file in the default text mode, but then converts the input lines to byte strings when they are split into separate values. The fix here is to convert the values back to strings in the complex converter. Closes #5655.
* BUG: genfromtxt gave OverflorError for large integersThomas Robitaille2015-03-061-2/+27
| | | | | | | | | Fix StringConverter to avoid OverflowError in genfromtxt. Before, int(2**66) would work (and return a ‘long’) but then np.array([2**66], dtype=np.integer) would not work and return an OverflowError which would propagate to genfromtxt. This commit fixes this by ensuring testing in advance whether an OverflowError will occur. In addition, this adds an explicit np.int64 entry on systems where integer means int32. Values larger than 2**63-1 will be cast as float. This includes a regression test and adds an entry to the release notes.
* TST: Make loadtxt able to load floats as hex strings.Charles Harris2015-02-131-0/+13
| | | | The strings must be produced by the python float.hex method.
* Merge pull request #5495 from charris/cleanup-gh-4649Charles Harris2015-01-241-2/+26
|\ | | | | BUG: Fix genfromtext NameValidator arguments passed to easy_dtype.
| * TST: Fix bug in test_dtype_with_converters_and_usecols.Charles Harris2015-01-231-2/+2
| | | | | | | | | | | | | | The case_sensitive argument to np.recfromcsv has a default value of 'lower'. That value was not previously correctly passed on, but is now, so the previous expected values in this test were incorrectly upper cased.
| * BUG: Fix genfromtext NameValidator arguments passed to easy_dtype.Alan Briolat2015-01-231-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | np.genfromtxt validates field names twice: once in genfromtxt and once in easy_dtype. Whilst the arguments to genfromtxt are used in the first validation, they aren't passed to easy_dtype (which is used only when dtype != None) and therefore in this case the default validation (strip non-alphanum, replace spaces) gets confusingly applied, ignoring genfromtxt's arguments. This patch adds fixes genfromtxt by passing the appropriate arguments onwards to easy_dtype. That is probably the least invasive way to fix the issue.
* | ENH: genfromtxt: Change 'nrows' to 'max_rows'.Warren Weckesser2015-01-231-12/+40
| |
* | ENH:Add keyword nrows to genfromtxt.styr2015-01-231-0/+26
|/ | | | | | | | | | This allows one to specify the maximum number of row processed in in a call. The new functionality allows for reading more complex data formats. For instance, multiple calls can be used to read in multiple arrays stored in a single file. Closes #5084. Closes #5093.
* TST: Add test for loadtxt with None as string type.Charles Harris2015-01-231-0/+8
|
* TEST: added test of BagObjWendell Smith2014-11-181-0/+11
|
* Merge pull request #5006 from dhomeier/ioconv_usecolsJulian Taylor2014-08-271-0/+15
|\ | | | | | | BUG: fix genfromtxt check of converters when using usecols
| * BUG: fix genfromtxt check of converters when using usecolsDerek Homeier2014-08-271-0/+15
| | | | | | | | | | | | fixes an issue reported by Adrian Altenhoff where user-supplied converters in genfromtxt were not tested with the right first_values when also specifying usecols.
* | BUG: io: genfromtxt did not handle filling_values=0 correctly. Closes gh-2317.Warren Weckesser2014-08-151-0/+10
| |
* | Move tempdir context manager to numpy.testing.utilsOlivier Grisel2014-06-301-12/+4
|/
* TST: add a format 2.0 roundtrip testJulian Taylor2014-06-031-0/+7
|
* BUG: fix test deleting temporary file before using it on windowsJulian Taylor2014-06-031-22/+28
| | | | | | | The version check was not valid for python3, though the whole logic can be removed with a finally clause. This requires that the savez tests need to cleanup the NpyzFile results which still hold an open file descriptor.
* ENH: Better error w/ line num for bad column count in np.loadtxt()Daniel da Silva2014-04-051-2/+13
| | | | Resolves #2591. Adds more explicit error handling in line parsing loop.
* TST: Added regression test for recfromcsv dtype error, as suggested by @hpauljYaron de Leeuw2014-02-281-0/+8
|