summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
Commit message (Collapse)AuthorAgeFilesLines
...
| * 2to3: Apply zip fixer.Charles Harris2013-04-131-6/+6
| | | | | | | | | | | | | | | | | | | | In Python 3 zip returns an iterator instead of a list. Consequently, in places where an iterator won't do it must be enclosed in list(...). Lists instead of iterators are also used in array constructors as using iterators there usually results in an object array containing an iterator object. Closes #3094
* | 2to3: Apply basestring fixer.Charles Harris2013-04-131-1/+1
|/ | | | | | | | | | | The basestring class is not defined in Python 3 and the fixer replaces it with str. In order to have a common code base we define basestring in numpy/compat/py3k.py to be str when the Python version is >= 3, otherwise basestring and import it where needed. That works for most cases, but there are a few files where the version dependent define needs to be in the file. Closes #3042.
* 2to3: Apply itertools fixer.Charles Harris2013-04-121-1/+3
| | | | | | | | | | | | | In Python 3 zip, map, and filter are all iterators, consequently the itertools variants izip, imap, and ifilter have been removed and the itertools fixer replaces them with the unprefixed names. Because the places where the iterator variants are used in current look like places where the iterator version might be useful, the approach taken here is to define the prefixed versions to the unprefixed versions for Python 3, but otherwise import them from itertools. Closes #3233.
* 2to3: Apply `map` fixer.Charles Harris2013-04-101-10/+11
| | | | | | | | | | | | | | | | | | | In Python 3 `map` is an iterator while in Python 2 it returns a list. The simple fix applied by the fixer is to inclose all instances of map with `list(...)`. This is not needed in all cases, and even where appropriate list comprehensions may be preferred for their clarity. Consequently, this patch attempts to use list comprehensions where it makes sense. When the mapped function has two arguments there is another problem that can arise. In Python 3 map stops execution when the shortest argument list is exhausted, while in Python 2 it stops when the longest argument list is exhausted. Consequently the two argument case might need special care. However, we have been running Python3 converted versions of numpy since 1.5 without problems, so it is probably not something that affects us. Closes #3068
* 2to3: apply `dict` fixer.Charles Harris2013-04-061-2/+2
| | | | | | | | | | | | | | | In Python3 `dict.items()`, `dict.keys()`, and `dict.values()` are iterators. This causes problems when a list is needed so the 2to3 fixer explicitly constructs a list when is finds on of those functions. However, that is usually not necessary, so a lot of the work here has been cleaning up those places where the fix is not needed. The big exception to that is the `numpy/f2py/crackfortran.py` file. The code there makes extensive use of loops that modify the contents of the dictionary being looped through, which raises an error. That together with the obscurity of the code in that file made it safest to let the `dict` fixer do its worst. Closes #3050.
* 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.
* Merge pull request #3191 from charris/2to3-apply-imports-fixerCharles Harris2013-04-061-8/+10
|\ | | | | 2to3: Apply `imports` fixer.
| * 2to3: Apply `imports` fixer.Charles Harris2013-04-021-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #460 from endolith/regex_formattingCharles Harris2013-04-031-1/+1
|\ \ | |/ |/| DOC: Formatting fixes using regex
| * DOC: regex-assisted fixes of definition list formattingendolith2013-03-191-1/+1
| |
* | 2to3: Use absolute imports.Charles Harris2013-03-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Replace xrange by range and use list(range(...)) where neededCharles Harris2013-03-271-3/+3
|/ | | | | | | | | | | | | | | In python3 range is an iterator and `xrange` has been removed. This has two consequence for code: 1) Where a list is needed `list(range(...))` must be used. 2) `xrange` must be replaced by `range` Both of these changes also work in python2 and this patch makes both. There are three places fixed that do not need it, but I left them in so that the result would be `xrange` clean. Closes #3092
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-011-0/+2
| | | | | | | | 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.
* BUG: make genfromtxt work with comments=None. Closes Github issue 329.martingoodson2012-07-101-1/+2
|
* DOC: merge wiki edits. Add percentile to statistics routines (ML suggestion).Ralf Gommers2012-07-071-2/+1
|
* BF: removed too much -- own_fid should be False while working with .npzYaroslav Halchenko2012-07-051-0/+1
|
* ENH: Since file handle could not be reopened (during load()) -- no need for ↵Yaroslav Halchenko2012-07-051-17/+3
| | | | "isclosed" logic
* BF: PY3 and PY2 < 2.7 compatibility fixes for prev 2 commitsYaroslav Halchenko2012-07-021-6/+10
|
* BUG: do not "own" the FID for GzipFile and file if provided to load already ↵Yaroslav Halchenko2012-07-021-4/+12
| | | | | | opened (ticket #2178) Also made all assignments of own_file go in pair with assignments to fid to make things clearer
* DOC: Change versionadded from 2.0.0 to 1.7.0 where needed.Charles Harris2012-03-041-2/+2
|
* DOC: merge wiki doc edits.Ralf Gommers2012-03-031-30/+39
|
* ENH: lib: break reference cycle in NpzFile (#2048)Pauli Virtanen2012-02-161-1/+4
| | | | | This allows these objects to be freed by refcount, rather than requiring the gc, which can be useful in some situations.
* BUG: savetxt now handles complex arrays. Closes #1573.Paul Anton Letnes2011-12-281-10/+32
|
* ENH: add context manager for NpzFile class.David Cournapeau2011-10-101-0/+13
|
* DOC: mention that NpzFile instances must be closed.David Cournapeau2011-10-101-1/+13
|
* BUG: loadtxt: There was some extra nesting for subarray dtypes (Ticket #1936)Mark Wiebe2011-08-201-5/+10
|
* ENH: Add provision for headers and footers to savetxt, fixes ticket 1236.Paul Anton Letnes2011-08-151-4/+22
| | | | | I suggest using a separate keyword argument for structured arrays. It might also be nice to be able to add a manual header.
* BUG: fix failing npyio test under py3k. Thanks to Derek Homeier. Closes #1793.Ralf Gommers2011-08-101-1/+2
|
* ENH: let genfromtxt return empty array for empty input file instead of an error.Paul Anton Letnes2011-07-311-2/+4
| | | | A warning for empty files is issued, including file name. Closes #1793.
* STY: Remove trailing whitespaceMark Wiebe2011-07-261-2/+2
|
* use np.atleast_Nd() to boost dimensions to ndminDerek Homeier2011-05-071-5/+8
|
* changed ndmin option in loadtxt to return shape (1, X.size) for single-row ↵Derek Homeier2011-05-071-1/+4
| | | | inputs
* STY: Fix up some remaining old-style exceptions.Charles Harris2011-04-051-3/+3
| | | | I think that is the end of it.
* STY: Update exception styles, trickier ones.Charles Harris2011-04-051-2/+2
|
* STY: Update exception style, easy ones.Charles Harris2011-04-051-1/+1
|
* BUG: Workaround for the fact the Python 2.4 doesn't accept 'Ub' as a fileCharles Harris2011-04-051-1/+1
| | | | | | | | | mode, but does accept 'rbU'. Note that with either of these modes Python 3 fails to split files with '\r' line endings on linux. This is either a bug in Python 3 or something that requires more extensive modifications to genfromtxt. Because genfromtxt now accepts generators it should be possible to write a generator that opens files in text mode and encodes the lines as byte streams, and this should provide a workaround.
* moved import statement in npyio.py for ease of readingPaul Anton Letnes2011-04-041-1/+1
|
* BUG: ticket #1071, fix loadtxt to handle tab delimited data with missingDerek Homeir2011-04-041-3/+4
| | | | values in the last column and add test for same.
* ENH: Let genfromtxt accept generators as text sources. Add testCharles Harris2011-04-031-19/+27
| | | | for that case.
* ENH: ticket #1616, let loadtxt accept generators in additions toCharles Harris2011-04-031-37/+34
| | | | file names and file like objects. Add test for for new functionality.
* ENH: add ndmin keyword to loadtxt. Closes #1562.Ralf Gommers2011-04-031-2/+19
| | | | Thanks to Paul Anton Letnes and Derek Homeier.
* ENH: return empty array from loadtxt for an empty file. Closes #1752.Ralf Gommers2011-04-031-1/+4
| | | | Thanks to Paul Anton Letnes and Derek Homeier.
* ENH: ticket #1458, make loadtxt(..., unpack=True) unpack structured arrayDerek Homier2011-04-021-2/+7
| | | | fields.
* BUG: ticket #1565, fix conversion of int64 and uint64 types by loadtxt.Christoph Gohlke2011-04-021-0/+4
| | | | Add some tests for these types.
* BUG: open genfromtxt file as binary; add test for filename useMatthew Brett2011-03-301-1/+1
|
* DEP: Update deprecation messages in genloadtxt with a version number.rgommers2011-03-111-12/+14
| | | | | Because the docstring was still using `skiprows` explicitly, that keyword can not yet be removed. Should be done for 2.0.
* DOC: commit some more fixes from the doc wiki.rgommers2011-03-031-1/+1
|
* BUG: correct file name in fromregex.rgommers2011-03-011-2/+2
| | | | Thanks to Mattieu Brucher for reporting.
* ENH: core: Implement PyArray_CopyInto using the new iteratorMark Wiebe2011-01-161-22/+38
| | | | | | | | This change also uses the dtype conversion code implemented for new iterator buffering, which differs slightly from the previous casting behavior. In particular, fields are matched up by name instead of position, so code depending on that behavior breaks. The loadtxt function has been fixed to not depend on this casting behavior.
* BUG: Try fix for python 2.4, use list instead of tuple.Charles Harris2010-12-021-1/+1
|