1 #ifndef PYTHONIC_NUMPY_ISNAN_HPP 2 #define PYTHONIC_NUMPY_ISNAN_HPP 3 4 #include "pythonic/include/numpy/isnan.hpp" 5 6 #include "pythonic/types/ndarray.hpp" 7 #include "pythonic/utils/functor.hpp" 8 #include "pythonic/utils/numpy_traits.hpp" 9 10 PYTHONIC_NS_BEGIN 11 12 namespace numpy 13 { 14 namespace wrapper 15 { 16 template <class T> isnan(std::complex<T> const & v)17 bool isnan(std::complex<T> const &v) 18 { 19 return std::isnan(v.real()) || std::isnan(v.imag()); 20 } 21 22 template <class T> isnan(T const & v)23 auto isnan(T const &v) -> typename std::enable_if< 24 std::is_floating_point<typename std::decay<T>::type>::value, bool>::type 25 { 26 return std::isnan(v); 27 } 28 29 template <class T> isnan(T const & v)30 auto isnan(T const &v) -> typename std::enable_if< 31 !std::is_floating_point<typename std::decay<T>::type>::value, 32 bool>::type 33 { 34 return false; 35 } 36 } 37 38 #define NUMPY_NARY_FUNC_NAME isnan 39 #define NUMPY_NARY_FUNC_SYM wrapper::isnan 40 #include "pythonic/types/numpy_nary_expr.hpp" 41 } 42 PYTHONIC_NS_END 43 44 #endif 45