10000 BUG: longdouble with elsize 12 is never uint alignable by mattip · Pull Request #12611 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: longdouble with elsize 12 is never uint alignable #12611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
MAINT: improve comments
  • Loading branch information
mattip committed Dec 26, 2018
commit de4c4ef7e8a828331694de290582dced09c4df6f
2 changes: 1 addition & 1 deletion numpy/core/src/common/array_assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ raw_array_is_aligned(int ndim, npy_intp *shape,
return 1;
}
else {
/* always return false for alignment == 0, which means unaligned */
/* always return false for alignment == 0, which means cannot-be-aligned */
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is alignment == 0 even a legal argument to this function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there is a better way to organize it... but the idea is that npy_uint_alignment, which normally returns the uint alignment, returns 0 if the type is not uint-alignable.

Then, it turned out to be convenient to allow the result of npy_uint_alignment to be passed directly to raw_array_is_aligned.

An alternative would be to check the return value of npy_uint_alignment explicitly everywhere it is used. But since it is pretty much always used as an arg to raw_array_is_aligned it seemed less complicated this way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

}
}
Expand Down
5 changes: 3 additions & 2 deletions numpy/core/src/common/array_assign.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ broadcast_strides(int ndim, npy_intp *shape,

/*
* Checks whether a data pointer + set of strides refers to a raw
* array whose elements are all aligned to a given alignment.
* array whose elements are all aligned to a given alignment. Returns
* 1 if data is aligned to alignment or 0 if not.
* alignment should be a power of two, or may be the sentinel value 0 to mean
* unaligned, in which case false is always returned.
* cannot-be-aligned, in which case 0 (false) is always returned.
*/
NPY_NO_EXPORT int
raw_array_is_aligned(int ndim, npy_intp *shape,
Expand Down
0