#ifndef PYTHONIC_NUMPY_NANTONUM_HPP #define PYTHONIC_NUMPY_NANTONUM_HPP #include "pythonic/include/numpy/nan_to_num.hpp" #include "pythonic/utils/functor.hpp" #include "pythonic/types/ndarray.hpp" #include "pythonic/utils/numpy_traits.hpp" #include "pythonic/numpy/isinf.hpp" #include "pythonic/numpy/isnan.hpp" #include PYTHONIC_NS_BEGIN namespace numpy { namespace wrapper { template I nan_to_num(I const &a) { if (functor::isinf{}(a)) { if (a >= 0) return std::numeric_limits::max(); else return std::numeric_limits::lowest(); } else if (functor::isnan{}(a)) return 0; else return a; } } #define NUMPY_NARY_FUNC_NAME nan_to_num #define NUMPY_NARY_FUNC_SYM wrapper::nan_to_num #include "pythonic/types/numpy_nary_expr.hpp" } PYTHONIC_NS_END #endif