diff --git a/numpy_groupies/aggregate_numpy.py b/numpy_groupies/aggregate_numpy.py index 0bfc9a0..9dd82a8 100644 --- a/numpy_groupies/aggregate_numpy.py +++ b/numpy_groupies/aggregate_numpy.py @@ -88,20 +88,24 @@ def _any(group_idx, a, size, fill_value, dtype=None): def _min(group_idx, a, size, fill_value, dtype=None): dtype = minimum_dtype(fill_value, dtype or a.dtype) dmax = maxval(fill_value, dtype) - ret = np.full(size, fill_value, dtype=dtype) + with np.errstate(invalid="ignore"): + ret = np.full(size, fill_value, dtype=dtype) if fill_value != dmax: ret[group_idx] = dmax # min starts from maximum - np.minimum.at(ret, group_idx, a) + with np.errstate(invalid="ignore"): + np.minimum.at(ret, group_idx, a) return ret def _max(group_idx, a, size, fill_value, dtype=None): dtype = minimum_dtype(fill_value, dtype or a.dtype) dmin = minval(fill_value, dtype) - ret = np.full(size, fill_value, dtype=dtype) + with np.errstate(invalid="ignore"): + ret = np.full(size, fill_value, dtype=dtype) if fill_value != dmin: ret[group_idx] = dmin # max starts from minimum - np.maximum.at(ret, group_idx, a) + with np.errstate(invalid="ignore"): + np.maximum.at(ret, group_idx, a) return ret diff --git a/numpy_groupies/aggregate_pandas.py b/numpy_groupies/aggregate_pandas.py index 02cb625..54a0202 100644 --- a/numpy_groupies/aggregate_pandas.py +++ b/numpy_groupies/aggregate_pandas.py @@ -29,7 +29,8 @@ def _wrapper(group_idx, a, size, fill_value, func="sum", dtype=None, ddof=0, **k ret = grouped.values[:, 0] else: ret = np.full(size, fill_value, dtype=dtype) - ret[grouped.index] = grouped.values[:, 0] + with np.errstate(invalid="ignore"): + ret[grouped.index] = grouped.values[:, 0] return ret diff --git a/numpy_groupies/utils.py b/numpy_groupies/utils.py index 6d1b96f..e2af7a3 100644 --- a/numpy_groupies/utils.py +++ b/numpy_groupies/utils.py @@ -208,7 +208,8 @@ def minimum_dtype(x, dtype=np.bool_): def check_type(x, dtype): try: - converted = np.array(x).astype(dtype) + with np.errstate(invalid="ignore"): + converted = np.array(x).astype(dtype) except (ValueError, OverflowError, RuntimeWarning): return False # False if some overflow has happened