summaryrefslogtreecommitdiff
path: root/numpy/lib/_datasource.py
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Tidy exception handling in _datasource.py (#16761)Sarthak Vineet Kumar2020-07-081-7/+3
| | | Remove unnecessary try/except from DataSource.
* MAINT: cleanup unused imports; avoid redefinition of importsMike Taves2020-02-061-1/+0
| | | | | | | * Cleanup unused imports (F401) of mostly standard Python modules, or some internal but unlikely referenced modules * Where internal imports are potentially used, mark with noqa * Avoid redefinition of imports (F811)
* Merge pull request #15398 from mwtoews/urllibCharles Harris2020-01-231-15/+5
|\ | | | | MAINT: Revise imports from urllib modules
| * MAINT: Revise imports from urllib modulesMike Taves2020-01-241-15/+5
| |
* | MAINT: Clean up, mostly unused imports.Warren Weckesser2020-01-231-1/+0
|/
* [MAINT] Cleanup python2 sys.version checksSeth Troisi2020-01-201-79/+5
|
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-2/+2
| | | | | | | 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: Ensure that the url request is closed if the file cannot be openedEric Wieser2019-06-041-7/+4
|
* ENH: Changed the sequence of checking for locale existence of a file and ↵EelcoPeacs2019-01-161-4/+5
| | | | | | importing urllib modules in numpy._datasource.py to prevent the import in case the local file was found See #12536
* MAINT: address several reviewer commentsTyler Reddy2018-12-141-2/+2
|
* TST, DOC: enable refguide_checkTyler Reddy2018-12-141-10/+12
| | | | | | | | * ported the refguide_check module from SciPy for usage in NumPy docstring execution/ verification; added the refguide_check run to Azure Mac OS CI * adjusted NumPy docstrings such that refguide_check passes
* Merge pull request #12381 from tylerjereddy/datasource_del_handlingCharles Harris2018-11-151-1/+1
|\ | | | | BUG: graceful DataSource __del__ when __init__ fails
| * BUG: improve DataSource __del__Tyler Reddy2018-11-131-1/+1
| | | | | | | | | | | | | | | | * DataSource __del__ could raise an AttributeError if __init__ failed for any reason; __del__ now gracefully handles the case where __init__ fails, as happens in the internals of refguide_check when handling DataSource with an unexpected kwarg
* | ENH: set correct __module__ for objects in numpy's public APIStephan Hoyer2018-11-131-1/+6
|/ | | | | | | | | | | | | Fixes GH-12271 Tests verify that everything in ``dir(numpy)`` either has ``__module__`` set to ``'numpy'``, or appears in an explicit whitelist of undocumented functions and exported bulitins. These should eventually be documented or removed. I also identified a handful of functions for which I had accidentally not setup dispatch for with ``__array_function__`` before, because they were listed under "ndarray methods" in ``_add_newdocs.py``. I guess that should be a lesson in trusting code comments :).
* BUG: Fix regression in loadtxt for bz2 text files in Python 2.Charles Harris2018-08-101-3/+5
| | | | | | | | | | | Text bz2 files are not well supported in Python2, and, following the NumPy upgrade in text handling, loadtxt was raising an error when they were detected. This led to problems for those few who were using such files. This patch is a quick fix that issues a RuntimeWarning, then opens those files under the assumption that they are latin1 encoded. Caveat emptor. Closes #11633.
* MAINT: Various minor code cleanups.Charles Harris2017-11-241-0/+15
| | | | Minor cleanups of old code to reflect more modern usage.
* MAINT: Refactor some code in npyio.py.Charles Harris2017-11-211-1/+7
|
* DOC: Add some docstrings and edit others.Charles Harris2017-11-211-2/+42
| | | | | | | Add docstrings for some of the support functions in _datasource and npyio in order to aid future maintainers. [ci skip]
* ENH: Add encoding option to numpy text IO.Julian Taylor2017-11-211-14/+74
| | | | | | | | | | | 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: Spelling fixesVille Skyttä2017-05-091-1/+1
|
* DOC: Fix more typos in docs and comments.Dongjoon Hyun2016-02-251-2/+2
|
* STY: Make files in numpy/lib PEP8 compliant.Charles Harris2014-07-311-59/+70
| | | | The rules enforced are the same as those used for scipy.
* MAINT: Fixes for problems in numpy/lib revealed by pyflakes.Charles Harris2014-07-311-5/+4
| | | | | | Some of those problems look like potential coding errors. In those cases a Fixme comment was made and the offending code, usually an unused variable, was commented out.
* BUG: close file-like objects returned by urlopencgohlke2013-10-151-0/+2
| | | Fix `ResourceWarning: unclosed file` on Python 3
* 2to3: Apply urllib fixer.Charles Harris2013-04-141-4/+12
| | | | | | | | | | | Various functions have been moved around in the stdlib for Python 3, this fixes that up so that the code is valid in both Python 2 and Python 3. Note: monkey patching the stlib urlopen for testing looks a bit hokey to me, but I don't see an easier, more reliable way to do the test. Closes #3090.
* 2to3: apply `dict` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | | | | | | | | | 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.
* 2to3: Apply `imports` fixer.Charles Harris2013-04-021-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | 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: Fix up some remaining old-style exceptions.Charles Harris2011-04-051-2/+2
| | | | I think that is the end of it.
* 3K: lib: Make _datasource and its tests Py3 compatible + slight cleanup of ↵Pauli Virtanen2010-02-201-8/+9
| | | | the code
* 3K: lib: make _datasource 2to3 friendlyPauli Virtanen2009-12-061-2/+4
|
* first set of checkins from the doc editorJarrod Millman2009-11-131-2/+1
|
* Docstring update: libPauli Virtanen2009-10-021-121/+167
|
* Import documentation from doc wiki (part 2, work-in-progress docstrings, but ↵Pauli Virtanen2008-10-281-43/+138
| | | | they are still an improvement)
* reindenting prior to releaseJarrod Millman2008-09-021-2/+2
|
* Apply modified version of Andrew Dalke's patch in #874 to create a ↵Travis Oliphant2008-08-271-13/+37
| | | | quicker-loading numpy.
* Merge from documentation editor.Stefan van der Walt2008-08-051-2/+3
|
* Defer tempfile import to improve startup time.Stefan van der Walt2008-07-311-1/+1
|
* BUG: Correctly stub out urllib2.urlopen() for tests given the refactoring of ↵Robert Kern2008-07-031-1/+1
| | | | the local imports.
* BUG: need to create exceptions correctly.Robert Kern2008-07-031-2/+2
|
* Reduce numpy's import times by delaying a few time consuming imports to the ↵Robert Kern2008-07-031-1/+6
| | | | point of actual use and global instantiations of finfo. Thanks to David Cournapeau for tracking down and fixing the import part of the problem.
* Fixing #738: Even more careful drive letter handling. And make the tests ↵Pauli Virtanen2008-04-191-1/+1
| | | | actually pass on Windows.
* Fixing #738: remember to sanitize away also Windows drive lettersPauli Virtanen2008-04-191-1/+2
|
* Fix bug #738 and add corresponding tests.Pauli Virtanen2008-04-191-1/+16
| | | | | | | | lib._datasource.DataSource.abspath now sanitizes path names more carefully, making sure that all file paths reside in destdir, also on Windows. (Where both '/' and os.sep function as path separators, as far as os.path.join is concerned.)
* Don't require gzip or bz2 until the actual functionality is requested.Robert Kern2008-04-171-4/+11
|
* Merge the lib_for_io branch back into the trunk.Travis Oliphant2007-12-301-0/+443