MESMER-group / mesmer

spatially-resolved ESM-specific multi-scenario initial-condition ensemble emulator
https://mesmer-emulator.readthedocs.io/en/latest/
GNU General Public License v3.0
23 stars 18 forks source link

allow passing Dataset as linear regression predictors #320

Open mathause opened 1 year ago

mathause commented 1 year ago

Currently we only allow passing dict as linear regression predictors. We should also allow passing Dataset (a Dataset is also a Mapping)

https://github.com/MESMER-group/mesmer/blob/69cb102c3080fce1abb193dc5aa73803e127c2a8/mesmer/stats/linear_regression.py#L173

Could be done as:

if isinstance(predictors, xr.Dataset):
    predictors = dict(predictors.data_vars)
mathause commented 10 months ago

As far as I can see this is possible as xr.Dataset() is a Mapping. So we should advertise it correctly in the docs and add tests.