diff --git a/src/scores/continuous/standard_impl.py b/src/scores/continuous/standard_impl.py index 68d19b20..43d46883 100644 --- a/src/scores/continuous/standard_impl.py +++ b/src/scores/continuous/standard_impl.py @@ -6,6 +6,8 @@ import scores.utils from scores.typing import FlexibleArrayType, FlexibleDimensionTypes import pandas +import numpy +import scores.utils def mse( @@ -77,6 +79,8 @@ def mse( if both_pandas: _mse = _mse.to_pandas() + if isinstance(_mse, numpy.ndarray): + _mse = numpy.float64(_mse) return _mse @@ -172,17 +176,17 @@ def mae( Alternatively, an xarray structure with dimensions preserved as appropriate containing the score along reduced dimensions """ - # as_pandas_series = False - # both_pandas = False - # if type(fcst) == pandas.Series: - # fcst = fcst.to_xarray() - # as_pandas_series = True + as_pandas_series = False + both_pandas = False + if type(fcst) == pandas.Series: + fcst = fcst.to_xarray() + as_pandas_series = True - # if type(obs) == pandas.Series: - # obs = obs.to_xarray() - # as_pandas_series = True - # if as_pandas_series == True: - # both_pandas = True + if type(obs) == pandas.Series: + obs = obs.to_xarray() + as_pandas_series = True + if as_pandas_series == True: + both_pandas = True error = fcst - obs @@ -197,7 +201,9 @@ def mae( else: _ae = ae.mean() - # if both_pandas: - # _ae = _ae.to_pandas() + if both_pandas: + _ae = _ae.to_pandas() + if isinstance(_ae, numpy.ndarray): + _ae = numpy.float64(_ae) return _ae