diff options
author | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2018-07-31 16:22:25 +0200 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2018-07-31 16:22:25 +0200 |
commit | 159ef14fb9e198bb0066ea14e6b980f065de63dd (patch) | |
tree | bc37c7d4ba09ee59deb708897fa0571709aec293 /silx/math/combo.pyx | |
parent | 270d5ddc31c26b62379e3caa9044dd75ccc71847 (diff) |
New upstream version 0.8.0+dfsg
Diffstat (limited to 'silx/math/combo.pyx')
-rw-r--r-- | silx/math/combo.pyx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/silx/math/combo.pyx b/silx/math/combo.pyx index 95676af..3fd9f66 100644 --- a/silx/math/combo.pyx +++ b/silx/math/combo.pyx @@ -30,20 +30,10 @@ of first occurrences (i.e., argmin/argmax) in a single pass. __authors__ = ["T. Vincent"] __license__ = "MIT" -__date__ = "18/10/2017" +__date__ = "24/04/2018" cimport cython - -# Windows compatibility: Cross-platform INFINITY -from libc.float cimport DBL_MAX -cdef double INFINITY = DBL_MAX + DBL_MAX -# from libc.math cimport INFINITY - -# Replacement from libc.math cimport isnan -# which is not available on Windows for Python2.7 -cdef extern from "isnan.h": - bint isnan(double x) nogil - bint isfinite(double x) nogil +from math_compatibility cimport isnan, isfinite, INFINITY import numpy @@ -281,6 +271,11 @@ def min_max(data not None, bint min_positive=False, bint finite=False): NaNs are ignored while computing min/max unless all data is NaNs, in which case returned min/max are NaNs. + The result data type is that of the input data, except for the following cases. + For input using non-native bytes order, the result is returned as native + floating-point or integers. For input using 16-bits floating-point, + the result is returned as 32-bits floating-point. + Examples: >>> import numpy @@ -324,6 +319,9 @@ def min_max(data not None, bint min_positive=False, bint finite=False): """ data = numpy.array(data, copy=False) native_endian_dtype = data.dtype.newbyteorder('N') + if native_endian_dtype.kind == 'f' and native_endian_dtype.itemsize == 2: + # Use native float32 instead of float16 + native_endian_dtype = "=f4" data = numpy.ascontiguousarray(data, dtype=native_endian_dtype).ravel() if finite and data.dtype.kind == 'f': return _finite_min_max(data, min_positive) |