-
Notifications
You must be signed in to change notification settings - Fork 24
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
Should erfa ufuncs accept correctly structured input independent of field names? #77
Comments
@seberg - sorry to ping you outside of numpy, but in the C API, is there currently a way to ask whether two structured dtypes have the same structure but possibly different names? Right now, we use |
No, I don't think there isn't. We still need to fix the casting safety for structured dtypes, but I don't think that would help you. I think the only way is to access |
OK, thanks. So that is what happens in things like |
Yes, it uses this code/pattern (this is part of the casting code): for (i = 0; i < field_count; ++i) {
key = PyTuple_GET_ITEM(dst_dtype->names, i);
tup = PyDict_GetItem(dst_dtype->fields, key);
if (!PyArg_ParseTuple(tup, "Oi|O", &dst_fld_dtype,
&dst_offset, &title)) {
NPY_AUXDATA_FREE((NpyAuxData *)data);
return NPY_FAIL;
}
/* identical code for the source here */ Not sure about iterating the dictionary in C, but maybe it always ordered in any case (since the I guess this is effectively public API, so I think you can just copy the pattern. |
Actually, the problem here is just the That would seem better to me, since this whole custom type resolution is pretty iffy, especially for casting safety. (I realize that fixing the casting safety has been on the "Not Done" list for too long, but...) |
Yes, I'd love |
I think we should go with "safe" rather than "equiv", but yeah. That seems fine to me, and its probably enough of a mess that we can just change it. |
This PR replaces the old numpygh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses liberfa/pyerfa#77 and replaces numpygh-15509 (the implementation has changed too much). Fixes numpygh-15494 (and probably a few more) Co-authored-by: Allan Haldane <[email protected]>
This PR replaces the old numpygh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses liberfa/pyerfa#77 and replaces numpygh-15509 (the implementation has changed too much). Fixes numpygh-15494 (and probably a few more) Co-authored-by: Allan Haldane <[email protected]>
This PR replaces the old numpygh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses liberfa/pyerfa#77 and replaces numpygh-15509 (the implementation has changed too much). Fixes numpygh-15494 (and probably a few more) Co-authored-by: Allan Haldane <[email protected]>
This PR replaces the old numpygh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses liberfa/pyerfa#77 and replaces numpygh-15509 (the implementation has changed too much). Fixes numpygh-15494 (and probably a few more) Co-authored-by: Allan Haldane <[email protected]>
This PR replaces the old numpygh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses liberfa/pyerfa#77 and replaces numpygh-15509 (the implementation has changed too much). Fixes numpygh-15494 (and probably a few more) Co-authored-by: Allan Haldane <[email protected]>
This PR replaces the old numpygh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses liberfa/pyerfa#77 and replaces numpygh-15509 (the implementation has changed too much). Fixes numpygh-15494 (and probably a few more) Co-authored-by: Allan Haldane <[email protected]>
This PR replaces the old numpygh-15509 implementing proper type promotion for structured voids. It further fixes the casting safety to consider casts with equivalent field number and matching order as "safe" and if the names, titles, and offsets match as "equiv". The change perculates into the void comparison, and since it fixes the order, it removes the current FutureWarning there as well. This addresses liberfa/pyerfa#77 and replaces numpygh-15509 (the implementation has changed too much). Fixes numpygh-15494 (and probably a few more) Co-authored-by: Allan Haldane <[email protected]>
EDIT: note it is not completely obvious what is right, since it may not be so easy to ensure that, e.g.,
erfa.cpv
produces output with the same field names as the input.Right now, the erfa functions insist on the correct field names:
Yet, numpy works by position and allows e.g. the following:
The text was updated successfully, but these errors were encountered: