Skip to content

Commit

Permalink
Adjust return from values to match what would be more consistent for …
Browse files Browse the repository at this point in the history
…pandas users
  • Loading branch information
tennlee committed Oct 19, 2023
1 parent aabc71d commit e5a2e19
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/scores/continuous/standard_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import scores.utils
from scores.typing import FlexibleArrayType, FlexibleDimensionTypes
import pandas
import numpy
import scores.utils


def mse(
Expand Down Expand Up @@ -77,6 +79,8 @@ def mse(

if both_pandas:
_mse = _mse.to_pandas()
if isinstance(_mse, numpy.ndarray):
_mse = numpy.float64(_mse)

return _mse

Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit e5a2e19

Please sign in to comment.