8000 BUG: Fix use and errorchecking of ObjectType use by seberg · Pull Request #22566 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix use and errorchecking of ObjectType use #22566

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 2 commits into from
Nov 10, 2022
Merged
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: Ensure that datetime dot, correlate, and vdot cannot happen
This is by just undefining the function that should never have been
defined to begin with.
  • Loading branch information
seberg committed Nov 9, 2022
commit 7c317d9e2bb0ed04778fb0b2ef5661e2bb742347
12 changes: 9 additions & 3 deletions numpy/core/src/multiarray/arraytypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -3803,17 +3803,23 @@ BOOL_dot(char *ip1, npy_intp is1, char *ip2, npy_intp is2, char *op, npy_intp n,
*((npy_bool *)op) = tmp;
}

/*
* `dot` does not make sense for times, for DATETIME it never worked.
* For timedelta it does/did , but should probably also just be removed.
*/
#define DATETIME_dot NULL

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a bit of a madness, but np.result_type(bool, "M8") never worked, and that prevented us (correctly) from even trying to get a datetime dot, vdot, or correlate.

Now it doesn't make any sense for timedelta as well (nor does it really work right, since units are always dropped), but not doing that here. This just "preserves" breaking things reliably, becuase we definitely cannot call the functions if they are not defined ;).

/**begin repeat
*
* #name = BYTE, UBYTE, SHORT, USHORT, INT, UINT,
* LONG, ULONG, LONGLONG, ULONGLONG,
* LONGDOUBLE, DATETIME, TIMEDELTA#
* LONGDOUBLE, TIMEDELTA#
* #type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint,
* npy_long, npy_ulong, npy_longlong, npy_ulonglong,
* npy_longdouble, npy_datetime, npy_timedelta#
* npy_longdouble, npy_timedelta#
* #out = npy_long, npy_ulong, npy_long, npy_ulong, npy_long, npy_ulong,
* npy_long, npy_ulong, npy_longlong, npy_ulonglong,
* npy_longdouble, npy_datetime, npy_timedelta#
* npy_longdouble, npy_timedelta#
*/
static void
@name@_dot(char *ip1, npy_intp is1, char *ip2, npy_intp is2, char *op, npy_intp n,
Expand Down
0