Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap_hindcast probabilistic bug #317

Closed
aaronspring opened this issue Feb 3, 2020 · 3 comments
Closed

bootstrap_hindcast probabilistic bug #317

aaronspring opened this issue Feb 3, 2020 · 3 comments
Assignees

Comments

@aaronspring
Copy link
Collaborator

aaronspring commented Feb 3, 2020

You are encouraged to add information about all relevant sections, but not required to submit an issue.

Code Sample, a copy-pastable example if possible

A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you:
http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

hind = load_dataset('CESM-DP-SST')
hist = load_dataset('CESM-LE')
obs = load_dataset('ERSST')
kw=dict()
kw['metric']='crpss'
kw['comparison']='m2o'
s = compute_hindcast(hind,obs,**kw)  # works
bs = bootstrap_hindcast(hind,hist,obs,bootstrap=3,**kw)  # fails

Problem description

0
---------------------------------------------------------------------------
InvalidIndexError                         Traceback (most recent call last)
<ipython-input-26-71ef6f1607c5> in <module>
----> 1 bs = bootstrap_hindcast(hind,hist,obs,bootstrap=3,**kw)

~/Coding/climpred/climpred/bootstrap.py in bootstrap_hindcast(hind, hist, verif, metric, comparison, dim, sig, bootstrap, pers_sig, **metric_kwargs)
    665         compute=compute_hindcast,
    666         resample_uninit=bootstrap_uninitialized_ensemble,
--> 667         **metric_kwargs,
    668     )
    669 

~/Coding/climpred/climpred/bootstrap.py in bootstrap_compute(hind, verif, hist, metric, comparison, dim, sig, bootstrap, pers_sig, compute, resample_uninit, **metric_kwargs)
    437             add_attrs=False,
    438             dim=dim,
--> 439             **metric_kwargs,
    440         )
    441         print('shuffle_dim', shuffle_dim, '\n')

~/Coding/climpred/climpred/checks.py in wrapper(*args, **kwargs)
    144         # to the actual function call rather than showing a simple Exception
    145         # (probably IndexError from trying to subselect an empty dec_args list)
--> 146         return func(*args, **kwargs)
    147 
    148     return wrapper

~/Coding/climpred/climpred/prediction.py in compute_hindcast(hind, verif, metric, comparison, dim, max_dof, add_attrs, **metric_kwargs)
    258             )
    259         )
--> 260     skill = xr.concat(plag, 'lead')
    261     skill['lead'] = forecast.lead.values
    262     # rename back to init

~/anaconda3/envs/climpred-dev/lib/python3.6/site-packages/xarray/core/concat.py in concat(objs, dim, data_vars, coords, compat, positions, fill_value, join)
    133             "objects, got %s" % type(first_obj)
    134         )
--> 135     return f(objs, dim, data_vars, coords, compat, positions, fill_value, join)
    136 
    137 

~/anaconda3/envs/climpred-dev/lib/python3.6/site-packages/xarray/core/concat.py in _dataset_concat(datasets, dim, data_vars, coords, compat, positions, fill_value, join)
    301     datasets = [ds.copy() for ds in datasets]
    302     datasets = align(
--> 303         *datasets, join=join, copy=False, exclude=[dim], fill_value=fill_value
    304     )
    305 

~/anaconda3/envs/climpred-dev/lib/python3.6/site-packages/xarray/core/alignment.py in align(join, copy, indexes, exclude, fill_value, *objects)
    296                 if join == "exact":
    297                     raise ValueError(f"indexes along dimension {dim!r} are not equal")
--> 298                 index = joiner(matching_indexes)
    299                 joined_indexes[dim] = index
    300             else:

~/anaconda3/envs/climpred-dev/lib/python3.6/site-packages/pandas/core/indexes/base.py in __or__(self, other)
   2383 
   2384     def __or__(self, other):
-> 2385         return self.union(other)
   2386 
   2387     def __xor__(self, other):

~/anaconda3/envs/climpred-dev/lib/python3.6/site-packages/pandas/core/indexes/base.py in union(self, other, sort)
   2517             return self._union_incompatible_dtypes(other, sort=sort)
   2518 
-> 2519         return self._union(other, sort=sort)
   2520 
   2521     def _union(self, other, sort):

~/anaconda3/envs/climpred-dev/lib/python3.6/site-packages/pandas/core/indexes/base.py in _union(self, other, sort)
   2566                 result.extend([x for x in rvals if x not in value_set])
   2567         else:
-> 2568             indexer = self.get_indexer(other)
   2569             indexer, = (indexer == -1).nonzero()
   2570 

~/anaconda3/envs/climpred-dev/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_indexer(self, target, method, limit, tolerance)
   2983         if not self.is_unique:
   2984             raise InvalidIndexError(
-> 2985                 "Reindexing only valid with uniquely" " valued Index objects"
   2986             )
   2987 

InvalidIndexError: Reindexing only valid with uniquely valued Index objects

Expected Output

no error

Output of climpred.show_versions()

# Paste the output here xr.show_versions() here
@aaronspring aaronspring self-assigned this Feb 3, 2020
@aaronspring aaronspring mentioned this issue Feb 3, 2020
12 tasks
@aaronspring
Copy link
Collaborator Author

aaronspring commented Feb 3, 2020

this error isn't present for dim='member'

@aaronspring
Copy link
Collaborator Author

unsure whether dim='init' should even be allowed to a probabilistic metric... maybe I need to reimplement the checks for dim from compute_ also in bootstrap_. I hoped just handling this in compute_ would be enough

@aaronspring
Copy link
Collaborator Author

I wouldnt say its a bug. users have to be careful about the resampling_dim, with PR #320 more user control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant