summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test__iotools.py
Commit message (Collapse)AuthorAgeFilesLines
* BUG: Fix default fallback in genfromtxtSebastian Berg2020-05-181-2/+2
| | | | | | | | | This affected (for example?) if the `dtype=object` was used without a converter, meaning that the default one is used. And this is currently the last one, which is `string_` (and thus bytes). Closes gh-16189
* MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-261-4/+3
| | | | | types (#15816) Cleanup from the dropping of python 2
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-4/+4
| | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* BUG: Refcount fixes (#13860)Sebastian Berg2019-07-031-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * BUG: Fix leaking of object descriptor on dtype discovery of `None` * BUG: Fix reference count leak in string discovery code path * BUG: Fix two more datetime related reference count bugs One is leaking only the python integer 1, the other a descriptor. * BUG: Fix bugs in vectorized string functions error paths Fixes reference count issues (a leak) in TestVecString::test_non_existent_method and TestVecString::test_non_string_array * BUG: Fix Reference count leak in in128 C-level tests * BUG: Fix refcount leak in advanced indexing error path * BUG,MAINT: Refactor indexing dtypes handling in mapiter constructor Using borrowed references for the dtypes seems much easier to get the reference counts right. * BUG: Reference leaks in deprecated datetime with timezone coercion * BUG: Refcount issue in nonzero 0-d path * BUG: Fix ufunc.at dtype refcount handling in resolver * BUG: Fix reference count in nditer python op_axes setup * BUG: Reference leak in writebackifcopy non-array error path * BUG: Add missing DECREF in ufunc with dtype type resolution * BUG: Reference count bugs in io functions * BUG: Reference count loss in as_c_array C-side tests * BUG: Leaking of method in object method based ufunc loops The function could possibly be optimized nicely by checking that the method will be the same because the types are identical. OTOH, that may not be correct in dynamically adapted types. * TST: Clean up cyclic ctypes reference to simplify leak debugging If we do not clean it up in this test, the collection can take so long that it affects the following tests when running with reference leak debugging tools (pytest-leaks). * BUG: Reference count of raw data for 0-sized unpickling * TST: Mark tests which must leak references It really may be time to remove this, considering how annoying this is, may want to think about getting rid of that behaviour. Could probably write a multiearraytests C-side function instead. * BUG: Fix refcount leaks in arr.getield and setfield error paths * BUG: Fix refcount issue in wheremask This fix is not the prettiest, since it relies on the wheremask to be formatted to boolean beforehand correctly. * TST: Reset StringConvert after mutating it in tests Or maybe just mark the test? * BUG: Fix missing static for npy_cache_import in umath funcs.inc.src * BUG: Fix refcount in multiternew error path * BUG: Fix npy_ObjectGCD and LCM reference counting * BUG: Decrement already wrapped outputs on failure This is not super pretty, but not sure how to do it much better right now. * FIXUP: iotools StringConverter._mapper * FIXUP: as_c_array tests * FIXUP: String/dtype discovery comment * FIXUP: Nonzero comment * FIXUP: mapiternew -- check error return of dtype creation In principle, at least at this time, this is not possible
* MAINT: Review F401,F841,F842 flake8 errors (unused variables and imports) ↵Roman Yurchak2018-12-061-1/+0
| | | | | | | | | | | | (#12448) * Review F401,F841,F842 flake8 errors (unused variables, imports) * Review comments * More tests in test_installed_npymath_ini * Review comments
* Use set litteralsRoman Yurchak2018-11-241-1/+1
|
* BUG: delimiter/comments in genfromtxt should be encodedAllan Haldane2018-05-301-0/+5
| | | | Fixes #11028
* MAINT: Remove all uses of run_module_suite.Charles Harris2018-04-061-4/+1
| | | | | That function is nose specific and has not worked since `__init__` files were added to the tests directories.
* MAINT: Various minor code cleanups.Charles Harris2017-11-241-6/+14
| | | | Minor cleanups of old code to reflect more modern usage.
* MAINT: Refactor some code in npyio.py.Charles Harris2017-11-211-2/+0
|
* ENH: Add encoding option to numpy text IO.Julian Taylor2017-11-211-62/+61
| | | | | | | | | | | 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.
* MAINT/DOC: Use builtin when np.{x} is builtins.{x}.Eric Wieser2017-08-051-1/+1
| | | | | | | 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-6/+5
|
* MAINT: Remove asbytes_nested where b prefixes would sufficeEric Wieser2017-03-251-15/+14
|
* MAINT: Remove asbytes where a b prefix would sufficeEric Wieser2017-03-251-42/+42
| | | | | | | | Since we only need to support python 2, we can remove any case where we just pass a single string literal and use the b prefix instead. What we can't do is transform asbytes("tests %d" % num), because %-formatting fails on bytes in python 3.x < 3.5.
* BUG: genfromtxt gave OverflorError for large integersThomas Robitaille2015-03-061-2/+16
| | | | | | | | | 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.
* MAINT: Make argument determination in NameValidator more precise.Charles Harris2015-01-231-1/+5
| | | | | | | The function was useing `'u' in case_sensitive` to detect `upper`. Make that more precise with `case_sensitive.startswith('u'). Raise ValueError if case_sensitive has unrecognized value.
* BUG: Closes #2917: numpy.lib._iotools.StringConverter.upgrade returnGarrett-R2014-11-301-7/+11
| | | | numpy.lib._iotools.StringConverter.upgrade should have a return value
* STY: PEP8 compliance for numpy/lib/tests.Charles Harris2014-07-311-1/+1
| | | | | | | The possibly controversial part of this is making the nested array value lists PEP8 compliant, as there is something to be said aligning the values for clarity. In the end, it seemed like the easiest thing to do was to make them PEP8 compliant. The eye can get used to that.
* MAINT: Fix problems noted by pyflakes in numpy/lib/tests.Charles Harris2014-07-311-2/+4
|
* STY: Make numpy/lib/test/*.py PEP8 compliant.Charles Harris2013-09-031-28/+31
| | | | | | | Run autopep8 over the test files in numpy/lib/test and make fixes to the result. Also remove Python5 workaround.
* 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-131-3/+3
| | | | | | | | | | | | | | | | | | | The numliterals fixer replaces the old style octal number like '01' by '0o1' removes the 'L' suffix. Octal values were previously mistakenly specified in some dates, those uses have been corrected by removing the leading zeros. Simply Removing the 'L' suffix should not be a problem, but in some testing code it looks neccesary, so in those places the Python long constructor is used instead. The 'long' type is no longer defined in Python 3. Because we need to have it defined for Python 2 it is added to numpy/compat/np3k.py where it is defined as 'int' for Python 3 and 'long' for Python 2. The `long` fixer then needs to be skipped so that it doesn't undo the good work. Closes #3074, #3067.
* 2to3: Apply `print` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Apply `imports` fixer.Charles Harris2013-04-021-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The `imports` fixer deals with the standard packages that have been renamed, removed, or methods that have moved. cPickle -- removed, use pickle commands -- removed, getoutput, getstatusoutput moved to subprocess urlparse -- removed, urlparse moved to urllib.parse cStringIO -- removed, use StringIO or io.StringIO copy_reg -- renamed copyreg _winreg -- renamed winreg ConfigParser -- renamed configparser __builtin__ -- renamed builtins In the case of `cPickle`, it is imported as `pickle` when python < 3 and performance may be a consideration, but otherwise plain old `pickle` is used. Dealing with `StringIO` is a bit tricky. There is an `io.StringIO` function in the `io` module, available since Python 2.6, but it expects unicode whereas `StringIO.StringIO` expects ascii. The Python 3 equivalent is then `io.BytesIO`. What I have done here is used BytesIO for anything that is emulating a file for testing purposes. That is more explicit than using a redefined StringIO as was done before we dropped support for Python 2.4 and 2.5. Closes #3180.
* 2to3: Use absolute imports.Charles Harris2013-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-011-0/+3
| | | | | | | | This should be harmless, as we already are division clean. However, placement of this import takes some care. In the future a script can be used to append new features without worry, at least until such time as it exceeds a single line. Having that ability will make it easier to deal with absolute imports and printing updates.
* STY: Replace assert by assert_ in tests. There remain 124 uses ofCharles Harris2011-04-051-2/+2
| | | | assert in non-testing files that should be checked for correctness.
* BUG: ticket #1428, allow int64 and uint64 integer types to be specified inCharles Harris2011-04-021-0/+16
| | | | genfromtxt.
* * fixed 'flatten_dtype' to support fields w/ titles (bug #1591). Thx to ↵pierregm2010-09-131-11/+33
| | | | | | Stefan vdW for the fix. * added a unittest for flatten_dtype
* 3K: lib: more str vs bytes issues in the lib/io loadtxt, savetxt and genfromtxtPauli Virtanen2010-02-201-13/+14
|
* 3K: lib: fix some bytes vs. str issues in _iotools.py and io.py -- mainly ↵Pauli Virtanen2010-02-201-50/+65
| | | | genfromtxt
* Hard tab removal.Charles Harris2009-10-201-5/+5
| | | | | Trailing whitespace removal. Some coding style cleanups.
* * _iotools.StringConverterpierregm2009-10-141-1/+10
| | | | | | | | | | - prevents a `default` of 0 to be overwritten during initialization - allows the `missing_values` to be a comma-separated string * io.genfromtxt - `usecols` can now be a single integer - for `usecols` and `names` to list (for compatibility w/ Python 2.5) - negative values in `usecols` are properly transformed to positive integers - fixed `usecols` with named columns
* * _iotools.StringConverterpierregm2009-10-121-0/+12
| | | | | | | | | | - prevents an explicit default to be overwritten during upgrade * io.genfromtxt - deprecate `skiprows` for `skip_header` - deprecate `missing` for `missing_values` - `missing_values` can now be a sequence - add support for `filling_values` * fixed ticket #1257
* * ma.masked_equal : force the `fill_value` of the output to `value` (ticket ↵pierregm2009-10-091-1/+86
| | | | | | | | | | | | | #1253) * lib._iotools: - NameValidator : add the `nbfields` optional argument to validate - add easy_dtype * lib.io.genfromtxt : - add the `autostrip` optional argument (ticket #1238) - use `invalid_raise=True` as default - use the easy_dtype mechanism (ticket #1252)
* * genfromtxt : fixed case when using explicit converters and explicit dtype.pierregm2009-02-141-0/+8
|
* * genfromtxt : Fixed when a dtype involving objects is explicitly given. ↵pierregm2009-02-051-1/+16
| | | | | | Raise a NotImplementedError if the dtype is nested. * _iotools : make sure StringConverter gets properly initiated when a function returning a np.object is used as input parameter.
* test_upgrademapper : got rid of the dateutil importpierregm2009-02-041-10/+11
|
* * test__iotools : prevent test_upgrademapper if dateutil is not installedpierregm2009-02-041-7/+10
| | | | * MaskedArray.__rmul__ : switch to multiply(self, other)
* * lib : introduced _iotoolspierregm2009-01-191-0/+140
* lib.io : introduced genfromtxt, ndfromtxt, mafromtxt, recfromtxt, recfromcsv.