BUG: Fix order='K' behavior for tobytes#16328
Conversation
2756323 to
9fbc4ba
Compare
numpy/core/src/multiarray/convert.c
Outdated
There was a problem hiding this comment.
not sure if we need this here just as a micro opt or if there is a deeper reason ?
numpy/core/src/multiarray/convert.c
Outdated
There was a problem hiding this comment.
would appreciate input on a better name here.
|
Sorry, I see I misjudged this a bit. The current algorithm uses an iterator while
Avoiding the second copy, can be done by either using the new iterator: although that is a bit annoying, but if yo 8000 u would like to get to know that iterator API maybe not a bad exercise. |
|
Or maybe we just put the axis-reorganizing ravel does into an internal helper, so that we do not have to duplicate it. |
717c597 to
f2b6d3f
Compare
numpy/core/src/multiarray/convert.c
Outdated
There was a problem hiding this comment.
i was a bit confused about the needs api stuff and the macros for NPY_BEGIN_THREADS_DEF , NPY_BEGIN_THREADS_NDITER etc. My understanding is that we just want to hold the GIL and I wasn't sure if we need any of this stuff.
f2b6d3f to
6cdfcc9
Compare
There was a problem hiding this comment.
This will give a wrong result as LHS = 2 whereas the RHS = 3.
When the order of 'x' will be in K, then the tobytes function should hold.
|
|
||
| def test_tobytes_order(self): | ||
| x = np.array([[1, 2, 3], [4, 5, 6]], order='F') | ||
| assert_(x.tobytes('F') == x.tobytes('K')) |
There was a problem hiding this comment.
This will give a wrong result as LHS = 2 whereas the RHS = 3.
When the order of 'x' will be in K, then the tobytes function should hold.
|
The test looks correct to me. If it fails, the code needs fixing, not the test. |
|
@anirudh2290 Needs a rebase. Do you want to pursue this? |
|
Hi @charris, I won't be able to pursue this in the near future, feel free to close/reassign. |
Simplify PyArray_ToString to call PyArray_Ravel internally.
This addresses #16569 (see also: #16291 (comment))