| |
@@ -0,0 +1,864 @@
|
| |
+ From b0501d3d6e11d00c8c839adcc2694820ecfa519e Mon Sep 17 00:00:00 2001
|
| |
+ From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
|
| |
+ Date: Sun, 8 Dec 2019 21:36:38 +0100
|
| |
+ Subject: [PATCH] Support more numpy type conversion operators
|
| |
+
|
| |
+ ---
|
| |
+ pythran/pythonic/__builtin__/type.hpp | 58 ++++++++++++--------
|
| |
+ pythran/pythonic/include/numpy/byte.hpp | 29 ++++++++++
|
| |
+ pythran/pythonic/include/numpy/int_.hpp | 28 ++++++++++
|
| |
+ pythran/pythonic/include/numpy/longlong.hpp | 29 ++++++++++
|
| |
+ pythran/pythonic/include/numpy/short_.hpp | 29 ++++++++++
|
| |
+ pythran/pythonic/include/numpy/ubyte.hpp | 20 ++++++-
|
| |
+ pythran/pythonic/include/numpy/uint.hpp | 28 ++++++++++
|
| |
+ pythran/pythonic/include/numpy/ulonglong.hpp | 29 ++++++++++
|
| |
+ pythran/pythonic/include/numpy/ushort.hpp | 29 ++++++++++
|
| |
+ pythran/pythonic/include/types/int.hpp | 1 +
|
| |
+ pythran/pythonic/numpy/byte.hpp | 37 +++++++++++++
|
| |
+ pythran/pythonic/numpy/int_.hpp | 37 +++++++++++++
|
| |
+ pythran/pythonic/numpy/longlong.hpp | 37 +++++++++++++
|
| |
+ pythran/pythonic/numpy/short_.hpp | 37 +++++++++++++
|
| |
+ pythran/pythonic/numpy/ubyte.hpp | 32 ++++++++++-
|
| |
+ pythran/pythonic/numpy/uint.hpp | 37 +++++++++++++
|
| |
+ pythran/pythonic/numpy/ulonglong.hpp | 37 +++++++++++++
|
| |
+ pythran/pythonic/numpy/ushort.hpp | 37 +++++++++++++
|
| |
+ pythran/pythonic/types/int.hpp | 5 ++
|
| |
+ pythran/tables.py | 6 ++
|
| |
+ pythran/tests/test_ndarray.py | 15 +++++
|
| |
+ 21 files changed, 570 insertions(+), 27 deletions(-)
|
| |
+ create mode 100644 pythran/pythonic/include/numpy/byte.hpp
|
| |
+ create mode 100644 pythran/pythonic/include/numpy/int_.hpp
|
| |
+ create mode 100644 pythran/pythonic/include/numpy/longlong.hpp
|
| |
+ create mode 100644 pythran/pythonic/include/numpy/short_.hpp
|
| |
+ create mode 100644 pythran/pythonic/include/numpy/uint.hpp
|
| |
+ create mode 100644 pythran/pythonic/include/numpy/ulonglong.hpp
|
| |
+ create mode 100644 pythran/pythonic/include/numpy/ushort.hpp
|
| |
+ create mode 100644 pythran/pythonic/numpy/byte.hpp
|
| |
+ create mode 100644 pythran/pythonic/numpy/int_.hpp
|
| |
+ create mode 100644 pythran/pythonic/numpy/longlong.hpp
|
| |
+ create mode 100644 pythran/pythonic/numpy/short_.hpp
|
| |
+ create mode 100644 pythran/pythonic/numpy/uint.hpp
|
| |
+ create mode 100644 pythran/pythonic/numpy/ulonglong.hpp
|
| |
+ create mode 100644 pythran/pythonic/numpy/ushort.hpp
|
| |
+
|
| |
+ diff --git a/pythran/pythonic/__builtin__/type.hpp b/pythran/pythonic/__builtin__/type.hpp
|
| |
+ index f222597a4..04232b0f8 100644
|
| |
+ --- a/pythran/pythonic/__builtin__/type.hpp
|
| |
+ +++ b/pythran/pythonic/__builtin__/type.hpp
|
| |
+ @@ -15,14 +15,16 @@
|
| |
+ #include "pythonic/__builtin__/dict.hpp"
|
| |
+ #include "pythonic/__builtin__/tuple.hpp"
|
| |
+ #include "pythonic/numpy/array.hpp"
|
| |
+ -#include "pythonic/numpy/int8.hpp"
|
| |
+ -#include "pythonic/numpy/uint8.hpp"
|
| |
+ -#include "pythonic/numpy/int16.hpp"
|
| |
+ -#include "pythonic/numpy/uint16.hpp"
|
| |
+ -#include "pythonic/numpy/int32.hpp"
|
| |
+ -#include "pythonic/numpy/uint32.hpp"
|
| |
+ -#include "pythonic/numpy/int64.hpp"
|
| |
+ -#include "pythonic/numpy/uint64.hpp"
|
| |
+ +#include "pythonic/numpy/byte.hpp"
|
| |
+ +#include "pythonic/numpy/ubyte.hpp"
|
| |
+ +#include "pythonic/numpy/short_.hpp"
|
| |
+ +#include "pythonic/numpy/ushort.hpp"
|
| |
+ +#include "pythonic/numpy/intc.hpp"
|
| |
+ +#include "pythonic/numpy/uintc.hpp"
|
| |
+ +#include "pythonic/numpy/int_.hpp"
|
| |
+ +#include "pythonic/numpy/uint.hpp"
|
| |
+ +#include "pythonic/numpy/longlong.hpp"
|
| |
+ +#include "pythonic/numpy/ulonglong.hpp"
|
| |
+ #include "pythonic/numpy/float32.hpp"
|
| |
+ #include "pythonic/numpy/float128.hpp"
|
| |
+
|
| |
+ @@ -87,36 +89,44 @@ namespace __builtin__
|
| |
+ using type = numpy::functor::array;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<int8_t> {
|
| |
+ - using type = numpy::functor::int8;
|
| |
+ + struct type_functor<signed char> {
|
| |
+ + using type = numpy::functor::byte;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<uint8_t> {
|
| |
+ - using type = numpy::functor::uint8;
|
| |
+ + struct type_functor<unsigned char> {
|
| |
+ + using type = numpy::functor::ubyte;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<int16_t> {
|
| |
+ - using type = numpy::functor::int16;
|
| |
+ + struct type_functor<short> {
|
| |
+ + using type = numpy::functor::short_;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<uint16_t> {
|
| |
+ - using type = numpy::functor::uint16;
|
| |
+ + struct type_functor<unsigned short> {
|
| |
+ + using type = numpy::functor::ushort;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<int32_t> {
|
| |
+ - using type = numpy::functor::int32;
|
| |
+ + struct type_functor<int> {
|
| |
+ + using type = numpy::functor::intc;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<uint32_t> {
|
| |
+ - using type = numpy::functor::uint32;
|
| |
+ + struct type_functor<unsigned int> {
|
| |
+ + using type = numpy::functor::uintc;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<int64_t> {
|
| |
+ - using type = numpy::functor::int64;
|
| |
+ + struct type_functor<long> {
|
| |
+ + using type = numpy::functor::int_;
|
| |
+ };
|
| |
+ template <>
|
| |
+ - struct type_functor<uint64_t> {
|
| |
+ - using type = numpy::functor::uint64;
|
| |
+ + struct type_functor<unsigned long> {
|
| |
+ + using type = numpy::functor::uint;
|
| |
+ + };
|
| |
+ + template <>
|
| |
+ + struct type_functor<long long> {
|
| |
+ + using type = numpy::functor::longlong;
|
| |
+ + };
|
| |
+ + template <>
|
| |
+ + struct type_functor<unsigned long long> {
|
| |
+ + using type = numpy::functor::ulonglong;
|
| |
+ };
|
| |
+ template <>
|
| |
+ struct type_functor<float> {
|
| |
+ diff --git a/pythran/pythonic/include/numpy/byte.hpp b/pythran/pythonic/include/numpy/byte.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..79f388e5a
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/include/numpy/byte.hpp
|
| |
+ @@ -0,0 +1,29 @@
|
| |
+ +#ifndef PYTHONIC_INCLUDE_NUMPY_BYTE_HPP
|
| |
+ +#define PYTHONIC_INCLUDE_NUMPY_BYTE_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + char byte();
|
| |
+ + template <class V>
|
| |
+ + char byte(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME byte
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::byte
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = char;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/include/numpy/int_.hpp b/pythran/pythonic/include/numpy/int_.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..57df3fe4b
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/include/numpy/int_.hpp
|
| |
+ @@ -0,0 +1,28 @@
|
| |
+ +#ifndef PYTHONIC_INCLUDE_NUMPY_INT__HPP
|
| |
+ +#define PYTHONIC_INCLUDE_NUMPY_INT__HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ + long int_();
|
| |
+ + template <class V>
|
| |
+ + long int_(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME int_
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::int_
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = long;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/include/numpy/longlong.hpp b/pythran/pythonic/include/numpy/longlong.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..cde5bf455
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/include/numpy/longlong.hpp
|
| |
+ @@ -0,0 +1,29 @@
|
| |
+ +#ifndef PYTHONIC_INCLUDE_NUMPY_LONGLONG_HPP
|
| |
+ +#define PYTHONIC_INCLUDE_NUMPY_LONGLONG_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + long long longlong();
|
| |
+ + template <class V>
|
| |
+ + long long longlong(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME longlong
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::longlong
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = long long;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/include/numpy/short_.hpp b/pythran/pythonic/include/numpy/short_.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..74e744368
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/include/numpy/short_.hpp
|
| |
+ @@ -0,0 +1,29 @@
|
| |
+ +#ifndef PYTHONIC_INCLUDE_NUMPY_SHORT__HPP
|
| |
+ +#define PYTHONIC_INCLUDE_NUMPY_SHORT__HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + short short_();
|
| |
+ + template <class V>
|
| |
+ + short short_(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME short_
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::short_
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = short;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/include/numpy/ubyte.hpp b/pythran/pythonic/include/numpy/ubyte.hpp
|
| |
+ index 7cf72a3c7..51327e593 100644
|
| |
+ --- a/pythran/pythonic/include/numpy/ubyte.hpp
|
| |
+ +++ b/pythran/pythonic/include/numpy/ubyte.hpp
|
| |
+ @@ -1,12 +1,28 @@
|
| |
+ #ifndef PYTHONIC_INCLUDE_NUMPY_UBYTE_HPP
|
| |
+ #define PYTHONIC_INCLUDE_NUMPY_UBYTE_HPP
|
| |
+
|
| |
+ -#include "pythonic/include/numpy/uint8.hpp"
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+
|
| |
+ PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ namespace numpy
|
| |
+ {
|
| |
+ - USING_FUNCTOR(ubyte, uint8);
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + unsigned char ubyte();
|
| |
+ + template <class V>
|
| |
+ + unsigned char ubyte(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME ubyte
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::ubyte
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = unsigned char;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ }
|
| |
+ PYTHONIC_NS_END
|
| |
+
|
| |
+ diff --git a/pythran/pythonic/include/numpy/uint.hpp b/pythran/pythonic/include/numpy/uint.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..ec4773dae
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/include/numpy/uint.hpp
|
| |
+ @@ -0,0 +1,28 @@
|
| |
+ +#ifndef PYTHONIC_INCLUDE_NUMPY_UINT_HPP
|
| |
+ +#define PYTHONIC_INCLUDE_NUMPY_UINT_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ + unsigned long uint();
|
| |
+ + template <class V>
|
| |
+ + unsigned long uint(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME uint
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::uint
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = unsigned long;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/include/numpy/ulonglong.hpp b/pythran/pythonic/include/numpy/ulonglong.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..8811bd2cc
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/include/numpy/ulonglong.hpp
|
| |
+ @@ -0,0 +1,29 @@
|
| |
+ +#ifndef PYTHONIC_INCLUDE_NUMPY_ULONGLONG_HPP
|
| |
+ +#define PYTHONIC_INCLUDE_NUMPY_ULONGLONG_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + unsigned long long ulonglong();
|
| |
+ + template <class V>
|
| |
+ + unsigned long long ulonglong(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME ulonglong
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::ulonglong
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = unsigned long long;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/include/numpy/ushort.hpp b/pythran/pythonic/include/numpy/ushort.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..11d298001
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/include/numpy/ushort.hpp
|
| |
+ @@ -0,0 +1,29 @@
|
| |
+ +#ifndef PYTHONIC_INCLUDE_NUMPY_USHORT_HPP
|
| |
+ +#define PYTHONIC_INCLUDE_NUMPY_USHORT_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/utils/functor.hpp"
|
| |
+ +#include "pythonic/include/utils/meta.hpp"
|
| |
+ +#include "pythonic/include/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/include/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + unsigned short ushort();
|
| |
+ + template <class V>
|
| |
+ + unsigned short ushort(V v);
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME ushort
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::ushort
|
| |
+ +#define NUMPY_NARY_EXTRA_METHOD using type = unsigned short;
|
| |
+ +#include "pythonic/include/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/include/types/int.hpp b/pythran/pythonic/include/types/int.hpp
|
| |
+ index 003f9d59e..56b27bc53 100644
|
| |
+ --- a/pythran/pythonic/include/types/int.hpp
|
| |
+ +++ b/pythran/pythonic/include/types/int.hpp
|
| |
+ @@ -26,6 +26,7 @@ PYTHONIC_NS_BEGIN
|
| |
+ static PyObject *convert(TYPE l); \
|
| |
+ }
|
| |
+
|
| |
+ +PYTHONIC_INT_TO_PYTHON(char);
|
| |
+ PYTHONIC_INT_TO_PYTHON(unsigned char);
|
| |
+ PYTHONIC_INT_TO_PYTHON(signed char);
|
| |
+ PYTHONIC_INT_TO_PYTHON(unsigned short);
|
| |
+ diff --git a/pythran/pythonic/numpy/byte.hpp b/pythran/pythonic/numpy/byte.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..423b280d2
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/numpy/byte.hpp
|
| |
+ @@ -0,0 +1,37 @@
|
| |
+ +#ifndef PYTHONIC_NUMPY_BYTE_HPP
|
| |
+ +#define PYTHONIC_NUMPY_BYTE_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/numpy/byte.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + char byte()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + char byte(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME byte
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::byte
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/numpy/int_.hpp b/pythran/pythonic/numpy/int_.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..3854b44eb
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/numpy/int_.hpp
|
| |
+ @@ -0,0 +1,37 @@
|
| |
+ +#ifndef PYTHONIC_NUMPY_INT__HPP
|
| |
+ +#define PYTHONIC_NUMPY_INT__HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/numpy/int_.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + long int_()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + long int_(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME int_
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::int_
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/numpy/longlong.hpp b/pythran/pythonic/numpy/longlong.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..00623cba1
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/numpy/longlong.hpp
|
| |
+ @@ -0,0 +1,37 @@
|
| |
+ +#ifndef PYTHONIC_NUMPY_LONGLONG_HPP
|
| |
+ +#define PYTHONIC_NUMPY_LONGLONG_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/numpy/longlong.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + long long longlong()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + long long longlong(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME longlong
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::longlong
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/numpy/short_.hpp b/pythran/pythonic/numpy/short_.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..0e29f34b9
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/numpy/short_.hpp
|
| |
+ @@ -0,0 +1,37 @@
|
| |
+ +#ifndef PYTHONIC_NUMPY_SHORT__HPP
|
| |
+ +#define PYTHONIC_NUMPY_SHORT__HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/numpy/short_.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + short short_()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + short short_(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME short_
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::short_
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/numpy/ubyte.hpp b/pythran/pythonic/numpy/ubyte.hpp
|
| |
+ index 1838b375b..c9718aadb 100644
|
| |
+ --- a/pythran/pythonic/numpy/ubyte.hpp
|
| |
+ +++ b/pythran/pythonic/numpy/ubyte.hpp
|
| |
+ @@ -2,6 +2,36 @@
|
| |
+ #define PYTHONIC_NUMPY_UBYTE_HPP
|
| |
+
|
| |
+ #include "pythonic/include/numpy/ubyte.hpp"
|
| |
+ -#include "pythonic/numpy/uint8.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + unsigned char ubyte()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + unsigned char ubyte(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME ubyte
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::ubyte
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+
|
| |
+ #endif
|
| |
+ diff --git a/pythran/pythonic/numpy/uint.hpp b/pythran/pythonic/numpy/uint.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..b6592db88
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/numpy/uint.hpp
|
| |
+ @@ -0,0 +1,37 @@
|
| |
+ +#ifndef PYTHONIC_NUMPY_UINT_HPP
|
| |
+ +#define PYTHONIC_NUMPY_UINT_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/numpy/uint.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + unsigned long uint()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + unsigned long uint(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME uint
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::uint
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/numpy/ulonglong.hpp b/pythran/pythonic/numpy/ulonglong.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..2210ac475
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/numpy/ulonglong.hpp
|
| |
+ @@ -0,0 +1,37 @@
|
| |
+ +#ifndef PYTHONIC_NUMPY_ULONGLONG_HPP
|
| |
+ +#define PYTHONIC_NUMPY_ULONGLONG_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/numpy/ulonglong.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + unsigned long long ulonglong()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + unsigned long long ulonglong(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME ulonglong
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::ulonglong
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/numpy/ushort.hpp b/pythran/pythonic/numpy/ushort.hpp
|
| |
+ new file mode 100644
|
| |
+ index 000000000..0a700385c
|
| |
+ --- /dev/null
|
| |
+ +++ b/pythran/pythonic/numpy/ushort.hpp
|
| |
+ @@ -0,0 +1,37 @@
|
| |
+ +#ifndef PYTHONIC_NUMPY_USHORT_HPP
|
| |
+ +#define PYTHONIC_NUMPY_USHORT_HPP
|
| |
+ +
|
| |
+ +#include "pythonic/include/numpy/ushort.hpp"
|
| |
+ +
|
| |
+ +#include "pythonic/utils/functor.hpp"
|
| |
+ +#include "pythonic/utils/meta.hpp"
|
| |
+ +#include "pythonic/utils/numpy_traits.hpp"
|
| |
+ +#include "pythonic/types/numpy_op_helper.hpp"
|
| |
+ +
|
| |
+ +PYTHONIC_NS_BEGIN
|
| |
+ +
|
| |
+ +namespace numpy
|
| |
+ +{
|
| |
+ +
|
| |
+ + namespace details
|
| |
+ + {
|
| |
+ +
|
| |
+ + unsigned short ushort()
|
| |
+ + {
|
| |
+ + return {};
|
| |
+ + }
|
| |
+ +
|
| |
+ + template <class V>
|
| |
+ + unsigned short ushort(V v)
|
| |
+ + {
|
| |
+ + return v;
|
| |
+ + }
|
| |
+ + }
|
| |
+ +
|
| |
+ +#define NUMPY_NARY_FUNC_NAME ushort
|
| |
+ +#define NUMPY_NARY_FUNC_SYM details::ushort
|
| |
+ +#include "pythonic/types/numpy_nary_expr.hpp"
|
| |
+ +}
|
| |
+ +PYTHONIC_NS_END
|
| |
+ +
|
| |
+ +#endif
|
| |
+ diff --git a/pythran/pythonic/types/int.hpp b/pythran/pythonic/types/int.hpp
|
| |
+ index 96d66d733..b0a0fd6e1 100644
|
| |
+ --- a/pythran/pythonic/types/int.hpp
|
| |
+ +++ b/pythran/pythonic/types/int.hpp
|
| |
+ @@ -102,6 +102,10 @@ struct c_type_to_numpy_type<unsigned short>
|
| |
+ : std::integral_constant<int, NPY_USHORT> {
|
| |
+ };
|
| |
+
|
| |
+ +template <>
|
| |
+ +struct c_type_to_numpy_type<char> : std::integral_constant<int, NPY_BYTE> {
|
| |
+ +};
|
| |
+ +
|
| |
+ template <>
|
| |
+ struct c_type_to_numpy_type<signed char>
|
| |
+ : std::integral_constant<int, NPY_BYTE> {
|
| |
+ @@ -136,6 +140,7 @@ struct c_type_to_numpy_type<bool> : std::integral_constant<int, NPY_BOOL> {
|
| |
+ nullptr); \
|
| |
+ }
|
| |
+
|
| |
+ +PYTHONIC_INT_TO_PYTHON(char)
|
| |
+ PYTHONIC_INT_TO_PYTHON(unsigned char)
|
| |
+ PYTHONIC_INT_TO_PYTHON(signed char)
|
| |
+ PYTHONIC_INT_TO_PYTHON(unsigned short)
|
| |
+ diff --git a/pythran/tables.py b/pythran/tables.py
|
| |
+ index 851b30782..4fbb38f3c 100644
|
| |
+ --- a/pythran/tables.py
|
| |
+ +++ b/pythran/tables.py
|
| |
+ @@ -3407,6 +3407,7 @@ def partialsum(seq):
|
| |
+ ),
|
| |
+ "bool": ConstFunctionIntr(signature=_bool_signature),
|
| |
+ "broadcast_to": ConstFunctionIntr(),
|
| |
+ + "byte": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "cbrt": ConstFunctionIntr(
|
| |
+ signature=_numpy_unary_op_float_signature
|
| |
+ ),
|
| |
+ @@ -3835,6 +3836,7 @@ def partialsum(seq):
|
| |
+ BINARY_UFUNC,
|
| |
+ signature=_numpy_int_binary_op_signature
|
| |
+ ),
|
| |
+ + "longlong": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "max": ConstMethodIntr(signature=_numpy_unary_op_axis_signature),
|
| |
+ "maximum": UFunc(
|
| |
+ BINARY_UFUNC,
|
| |
+ @@ -3993,6 +3995,7 @@ def partialsum(seq):
|
| |
+ "select": ConstFunctionIntr(),
|
| |
+ "setdiff1d": ConstFunctionIntr(),
|
| |
+ "shape": ConstFunctionIntr(),
|
| |
+ + "short_": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "sign": ConstFunctionIntr(),
|
| |
+ "signbit": ConstFunctionIntr(),
|
| |
+ "sin": ConstFunctionIntr(signature=_numpy_unary_op_float_signature),
|
| |
+ @@ -4012,6 +4015,7 @@ def partialsum(seq):
|
| |
+ ),
|
| |
+ "sum": ConstMethodIntr(signature=_numpy_unary_op_sum_axis_signature),
|
| |
+ "swapaxes": ConstMethodIntr(),
|
| |
+ + "short": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "take": ConstMethodIntr(),
|
| |
+ "tan": ConstFunctionIntr(signature=_numpy_unary_op_float_signature),
|
| |
+ "tanh": ConstFunctionIntr(signature=_numpy_unary_op_float_signature),
|
| |
+ @@ -4031,10 +4035,12 @@ def partialsum(seq):
|
| |
+ "uintc": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "uintp": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "uint8": ConstFunctionIntr(signature=_int_signature),
|
| |
+ + "ulonglong": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "union1d": ConstFunctionIntr(),
|
| |
+ "unique": ConstFunctionIntr(),
|
| |
+ "unwrap": ConstFunctionIntr(),
|
| |
+ "unravel_index": ConstFunctionIntr(),
|
| |
+ + "ushort": ConstFunctionIntr(signature=_int_signature),
|
| |
+ "var": ConstMethodIntr(),
|
| |
+ "vstack": ConstFunctionIntr(),
|
| |
+ "stack": ConstFunctionIntr(),
|
| |
+ diff --git a/pythran/tests/test_ndarray.py b/pythran/tests/test_ndarray.py
|
| |
+ index 44577ff51..9461249c6 100644
|
| |
+ --- a/pythran/tests/test_ndarray.py
|
| |
+ +++ b/pythran/tests/test_ndarray.py
|
| |
+ @@ -703,6 +703,21 @@ def test_ndarray_ubyte(self):
|
| |
+ 4,
|
| |
+ ndarray_ubyte=[int])
|
| |
+
|
| |
+ + def test_ndarray_byte(self):
|
| |
+ + self.run_test("def ndarray_byte(n): import numpy; return numpy.arange(-n, n, 1, dtype=numpy.byte)",
|
| |
+ + 4,
|
| |
+ + ndarray_byte=[int])
|
| |
+ +
|
| |
+ + def test_ndarray_ushort(self):
|
| |
+ + self.run_test("def ndarray_ushort(n): import numpy; return numpy.arange(0, n, 1, dtype=numpy.ushort)",
|
| |
+ + 4,
|
| |
+ + ndarray_ushort=[int])
|
| |
+ +
|
| |
+ + def test_ndarray_short(self):
|
| |
+ + self.run_test("def ndarray_short(n): import numpy; return numpy.arange(-n, n, 1, dtype=numpy.short)",
|
| |
+ + 4,
|
| |
+ + ndarray_short=[int])
|
| |
+ +
|
| |
+ def test_ndarray_1d_index(self):
|
| |
+ self.run_test(
|
| |
+ 'def ndarray_1d_index(a): return a[1], a[-1]',
|
| |