Skip to content

Commit

Permalink
numpy: More faithfully reflect npy_common.h aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
EricCousineau-TRI committed Mar 22, 2018
1 parent 82953f8 commit fd937bb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions include/pybind11/numpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,17 @@ struct npy_api {
NPY_UINT8_ = NPY_UBYTE_,
NPY_INT16_ = NPY_SHORT_,
NPY_UINT16_ = NPY_USHORT_,
NPY_INT32_ = platform_lookup<std::int32_t, short, int, long>({{
NPY_SHORT_, NPY_INT_, NPY_LONG_}}),
NPY_UINT32_ = platform_lookup<std::uint32_t, unsigned short, unsigned int, unsigned long>({{
NPY_USHORT_, NPY_UINT_, NPY_ULONG_}}),
NPY_INT64_ = platform_lookup<std::int64_t, int, long, long long>({{
NPY_INT_, NPY_LONG_, NPY_LONGLONG_}}),
NPY_UINT64_ = platform_lookup<std::uint64_t, unsigned int, unsigned long, unsigned long long>({{
NPY_UINT_, NPY_ULONG_, NPY_ULONGLONG_}}),
// `npy_common.h` defines the integer aliases. In order, it checks:
// NPY_BITSOF_LONG, NPY_BITSOF_LONGLONG, NPY_BITSOF_INT, NPY_BITSOF_SHORT, NPY_BITSOF_CHAR
// and assigns the alias to the first matching size, so we should check in this order.
NPY_INT32_ = platform_lookup<std::int32_t, long, int, short>({{
NPY_LONG_, NPY_INT_, NPY_SHORT_}}),
NPY_UINT32_ = platform_lookup<std::uint32_t, unsigned long, unsigned int, unsigned short>({{
NPY_ULONG_, NPY_UINT_, NPY_USHORT_}}),
NPY_INT64_ = platform_lookup<std::int64_t, long, long long, int>({{
NPY_LONG_, NPY_LONGLONG_, NPY_INT_}}),
NPY_UINT64_ = platform_lookup<std::uint64_t, unsigned long, unsigned long long, unsigned int>({{
NPY_ULONG_, NPY_ULONGLONG_, NPY_UINT_}}),
};

typedef struct {
Expand Down

0 comments on commit fd937bb

Please sign in to comment.