Skip to content

DEP: Deprecate silent ignoring of bad data in fromfile/fromstring - #13605

Merged
mattip merged 1 commit into
numpy:masterfrom
seberg:fromfile-eof-deprecation
Sep 13, 2019
Merged

mattip merged 1 commit into
numpy:masterfrom
seberg:fromfile-eof-deprecation

Conversation

@seberg

@seberg seberg commented May 22, 2019

Copy link
Copy Markdown
Member

When the read functions reach bad data the loop is stopped. This adds
a check whether the file/string was actually read to its end, and
if not gives a DeprecationWarning.

Closes gh-6076


Thought it would close more issues, I am not a specialist on file objects, but since it is here and probably works...

Comment thread numpy/core/src/multiarray/ctors.c Resolved
@seberg
seberg force-pushed the fromfile-eof-deprecation branch from 37b5e44 to f9c3197 Compare May 23, 2019 05:22
Comment thread numpy/core/tests/test_multiarray.py Resolved
Comment thread numpy/core/tests/test_multiarray.py Resolved
Comment thread numpy/core/src/multiarray/ctors.c Resolved
@seberg
seberg force-pushed the fromfile-eof-deprecation branch 2 times, most recently from 9227d04 to b2c5f6c Compare May 24, 2019 00:06
Comment thread numpy/core/src/multiarray/ctors.c Resolved
Comment thread numpy/core/src/multiarray/ctors.c Resolved
@seberg
seberg force-pushed the fromfile-eof-deprecation branch 2 times, most recently from facf937 to f92823b Compare June 1, 2019 00:13
Comment thread numpy/core/src/multiarray/ctors.c Resolved
@eric-wieser

Copy link
Copy Markdown
Member

C code looks good now, although tests nits still apply.

CI is failing with:

=================================== FAILURES ===================================
________ TestCommaDecimalPointLocale.test_fromstring_best_effort_float _________

self = <numpy.core.tests.test_longdouble.TestCommaDecimalPointLocale object at 0xf057ac0c>

    def test_fromstring_best_effort_float(self):
>       assert_equal(np.fromstring("1,234", dtype=float, sep=" "),
                     np.array([1.]))
E       DeprecationWarning: string or file could not be read to its end due to unmatched data; this will raise an error in the future.

self       = <numpy.core.tests.test_longdouble.TestCommaDecimalPointLocale object at 0xf057ac0c>

/usr/local/lib/python3.6/dist-packages/numpy/core/tests/test_longdouble.py:195: DeprecationWarning
___________ TestCommaDecimalPointLocale.test_fromstring_best_effort ____________

self = <numpy.core.tests.test_longdouble.TestCommaDecimalPointLocale object at 0xf03bae2c>

    def test_fromstring_best_effort(self):
>       assert_equal(np.fromstring("1,234", dtype=np.longdouble, sep=" "),
                     np.array([1.]))
E       DeprecationWarning: string or file could not be read to its end due to unmatched data; this will raise an error in the future.

self       = <numpy.core.tests.test_longdouble.TestCommaDecimalPointLocale object at 0xf03bae2c>

/usr/local/lib/python3.6/dist-packages/numpy/core/tests/test_longdouble.py:199: DeprecationWarning
__________ TestCommaDecimalPointLocale.test_fromstring_foreign_value ___________

self = <numpy.core.tests.test_longdouble.TestCommaDecimalPointLocale object at 0xf058d4ec>

    def test_fromstring_foreign_value(self):
>       b = np.fromstring("1,234", dtype=np.longdouble, sep=" ")
E       DeprecationWarning: string or file could not be read to its end due to unmatched data; this will raise an error in the future.

self       = <numpy.core.tests.test_longdouble.TestCommaDecimalPointLocale object at 0xf058d4ec>

/usr/local/lib/python3.6/dist-packages/numpy/core/tests/test_longdouble.py:213: DeprecationWarning
--------- generated xml file: /numpy/build/test/junit/test-results.xml ---------
=========================== short test summary info ============================

Would be nice to finish this up.

@seberg
seberg force-pushed the fromfile-eof-deprecation branch from f92823b to dae1540 Compare June 8, 2019 19:47
@seberg

seberg commented Jun 8, 2019

Copy link
Copy Markdown
Member Author

Still not sure which version we would put this in. There was still a hairy issue with separator being invalid, and if the count was correct. Those should be fixed, but may warrant a bit closer look.

@eric-wieser

Copy link
Copy Markdown
Member

Same CI failures as I mention above, should be as simple as adding assert_warns to those locations

@seberg

seberg commented Jun 13, 2019

Copy link
Copy Markdown
Member Author

Ack, yes sorry. I did not realize those tests were skipped because they need french locale.

@seberg

seberg commented Jun 13, 2019

Copy link
Copy Markdown
Member Author

Test failures now look like a CI issue.

Comment thread numpy/core/tests/test_deprecations.py Resolved
@tylerjereddy

Copy link
Copy Markdown
Contributor

Matti & I have seen that Azure issue before. It is sporadic, but perhaps more common as of late. Ideally, we'd not need to keep pulling in mingw from the internet to get gcc / gfortran runtime libs of a rather specific version.

It is possible to remove those dependencies upstream, but that discussion didn't go so well re: static links. Perhaps Microsoft might expand the breadth of mingw local install versions available some day or we might just host the file somewhere more reliable / use another manager to pull it in.

Not sure about LGTM issue offhand--looks like they've been doing some overhauls lately.

@seberg
seberg force-pushed the fromfile-eof-deprecation branch 2 times, most recently from f947373 to 1524d06 Compare July 24, 2019 22:35
@seberg

seberg commented Jul 24, 2019

Copy link
Copy Markdown
Member Author

Added release notes.

@seberg seberg removed the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Jul 24, 2019
@seberg
seberg force-pushed the fromfile-eof-deprecation branch from 1524d06 to eb712bd Compare August 20, 2019 15:06
Comment thread numpy/core/tests/test_deprecations.py Resolved
Comment thread numpy/core/src/multiarray/ctors.c Resolved
@mattip

mattip commented Sep 12, 2019

Copy link
Copy Markdown
Member

@seberg a few last cleanups

@seberg
seberg force-pushed the fromfile-eof-deprecation branch from eb712bd to 83fed9c Compare September 12, 2019 16:04
@seberg

seberg commented Sep 12, 2019

Copy link
Copy Markdown
Member Author

Sorry, forgot. Fixed the last three small comments and squashed.

When the read functions reach bad data the loop is stopped. This adds
a check whether the file/string was actually read to its end, and
if not gives a DeprecationWarning.

Closes numpygh-6076
@seberg
seberg force-pushed the fromfile-eof-deprecation branch from 83fed9c to bf6809a Compare September 12, 2019 23:43
@mattip
mattip merged commit 79ee678 into numpy:master Sep 13, 2019
@seberg
seberg deleted the fromfile-eof-deprecation branch September 13, 2019 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: np.fromstring ignores invalid data.

4 participants