summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Merge pull request #4273 from juliantaylor/test-file-leakJulian Taylor2014-02-091-7/+8
|\ | | | | TST: clean up tempfile in test_closing_zipfile_after_load
| * TST: clean up tempfile in test_closing_zipfile_after_loadJulian Taylor2014-02-081-7/+8
| |
* | TST: fix test_io.TestSavezLoadJulian Taylor2014-02-081-1/+1
|/
* ENH: remove insecure mktemp useJulian Taylor2014-02-061-8/+16
| | | | | mktemp only returns a filename, a malicous user could replace it before it gets used.
* TST: Increase test coverage of numpy.save/load roundtripsOlivier Grisel2013-11-261-6/+36
|
* MAINT: io: handle a bad fmt argument in savetxt by raising a ValueError.Warren Weckesser2013-10-201-0/+4
|
* STY: Make numpy/lib/test/*.py PEP8 compliant.Charles Harris2013-09-031-129/+110
| | | | | | | Run autopep8 over the test files in numpy/lib/test and make fixes to the result. Also remove Python5 workaround.
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-2/+2
| | | | | | | Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
* TST: Test that savetxt works with objects having a write method.Daniel2013-08-151-0/+12
|
* MAINT: Remove uses of the WarningManager class.Charles Harris2013-07-121-26/+10
| | | | | | | | | | | | WarningManager was a workaround for the lack of the with statement in Python versions < 2.6. As those versions are no longer supported it can be removed. Deprecation notes are added to WarningManager and WarningMessage, but to avoid a cascade of messages in third party apps, no warnings are raised at this time, that can be done later. Closes #3519.
* BUG: Make np.load transfer file ownership to the returned NpzFile.Charles Harris2013-06-221-1/+13
| | | | | | | This assures that when the loaded file is closed it also closes the file descriptor, avoiding a resource warning in Python3. Closes #3457.