| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|\
| |
| | |
BUG: fromregex: asbytes called on regexp objects
|
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| |/
|/| |
BUG: Resize bytes_ columns in genfromtxt
|
| |
| |
| |
| | |
Fixes gh-10394, due to regression in gh-10054
|
|/
|
| |
Found via `codespell`
|
|
|
|
| |
Minor cleanups of old code to reflect more modern usage.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
savetxt does not support saving arrays of dimension 0 or higher than 2.
This pull request improves the message of the error raised.
|
| |
|
|
|
|
|
|
|
| |
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/BUG: fromfile - fix test and expose bug with io class argument
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
| | |
|
|/
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
|
|
|
|
| |
Without the suffix, np.save creates a new file and the file
does not get cleaned up.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
The test is in numpy/lib/tests/test_io.py. This commit is intended
as a demonstration of using temppath.
|
| |
|
|
|
|
|
|
| |
Use a different strategy to detect whether np.load creates cycles.
Fixes gh-6571, I hope.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
The strings must be produced by the python float.hex method.
|
|\
| |
| | |
BUG: Fix genfromtext NameValidator arguments passed to easy_dtype.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
|/
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|\
| |
| |
| | |
BUG: fix genfromtxt check of converters when using usecols
|
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Resolves #2591. Adds more explicit error handling in line parsing loop.
|
| |
|