Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ecf3a8d

Browse files
committed
Add native numpy handling when plotting vectors of (unsigned) long long
1 parent d741050 commit ecf3a8d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

matplotlibcpp.h

+8
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ template <> struct select_npy_type<uint16_t> { const static NPY_TYPES type = NPY
296296
template <> struct select_npy_type<uint32_t> { const static NPY_TYPES type = NPY_ULONG; };
297297
template <> struct select_npy_type<uint64_t> { const static NPY_TYPES type = NPY_UINT64; };
298298

299+
// Sanity checks; comment them out or change the numpy type below if you're compiling on
300+
// a platform where they don't apply
301+
static_assert(sizeof(long long) == 8);
302+
template <> struct select_npy_type<long long> { const static NPY_TYPES type = NPY_INT64; };
303+
static_assert(sizeof(unsigned long long) == 8);
304+
template <> struct select_npy_type<unsigned long long> { const static NPY_TYPES type = NPY_UINT64; };
305+
// TODO: add int, long, etc.
306+
299307
template<typename Numeric>
300308
PyObject* get_array(const std::vector<Numeric>& v)
301309
{

0 commit comments

Comments
 (0)