BUG: Loadtxt should pass `checkref=False` to resize to avoid problems when tracing
See original GitHub issuenumpy version: 1.14.3 python version: 3.6.5
This was originally reported in https://github.com/Microsoft/ptvsd/issues/465 (error was on numpy.loadtxt
, but the real issue lies in resize
itself).
A sample to reproduce is:
import sys
def trace_dispatch(frame, event, arg):
return trace_dispatch
sys.settrace(trace_dispatch)
def method():
import numpy
Y = numpy.array([1] * 10, numpy.float32)
Y.resize([20, 20])
method()
When Y.resize()
is reached, the following error is thrown:
ValueError: cannot resize an array that references or is referenced
by another array in this way. Use the resize function.
So, it seems it’s that way by design, but this also means that by design, any function which calls array.resize
is not traceable (which I don’t think is expected).
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ValueError when debugging numpy app · Issue #465 - GitHub
As a note, any debugger which had tracing always on would fail consistently ... BUG: Loadtxt should pass checkref=False to resize to avoid...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems a reasonable tradeoff to me (although if it’s really important, I’d say that it should be
True
when running numpy tests to make sure that some future contributor won’t add a new reference to the array by mistake insidenumpy.loadtxt
).Fixed in #10737, which is part of the 1.15 release
refcheck=True
in tests must be inside aif HAS_REFCOUNT
block sincerefcheck=True
will raise an exception on PyPy, it has no refcount semantics.