id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 178887041,MDU6SXNzdWUxNzg4ODcwNDE=,1016,DataArray coords: tuple vs. list,5497186,closed,0,,,2,2016-09-23T14:08:15Z,2018-10-31T16:56:47Z,2018-10-31T16:56:47Z,NONE,,,,"is there a reason the `coords` dictionary values cannot be a tuple? I found this fairly baffling to debug when it tripped me up. ``` # this works xarray.DataArray(np.random.random((3, 3, 3)), dims=('one', 'two', 'three'), coords={ 'one': ['four', 'five', 'six'], } ) # this throws the following error # ValueError: dimensions ('four',) must have the same length as the number of data dimensions, ndim=0 xarray.DataArray(np.random.random((3, 3, 3)), dims=('one', 'two', 'three'), coords={ 'one': ('four', 'five', 'six'), } ) ``` even if there was a clearer error it would help quite a bit. As it stands you are thinking, 'what?! four isn't a dimension!' using 0.8.2 ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1016/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 134376872,MDU6SXNzdWUxMzQzNzY4NzI=,768,save/load DataArray to numpy npz functions,5497186,closed,0,,,11,2016-02-17T19:29:31Z,2016-12-24T11:55:40Z,2016-12-24T11:55:40Z,NONE,,,,"hey - Apologies if this is bad form: I wanted to pass this along but don't have time to do a proper pull request. I have found pickle to be really problematic for serializing data, so wrote these two functions to save to numpy's binary npz format and retrieve it. Generally, the numpy format is much less likely to bomb when attempting to load on another computer because of some unseen dependency. If there's interest, I could probably add this as a serialization method to DataArray in the next month or so. ``` python def to_npz(da, file_or_buffer): if 'dims' in da.dims: raise ValueError('Can\'t use ""dims"" as a dim name.') if 'values' in da.dims: raise ValueError('Can\'t use ""values"" as a dim name.') arrays = {} arrays['dims'] = da.dims for dim in da.dims: arrays[dim] = da.indexes[dim] arrays['values'] = da.values np.savez(file_or_buffer, **arrays) def from_npz(file_or_buffer): data = np.load(file_or_buffer) assert hasattr(data, 'keys'), ""np.load returned a {}, not a dict-like object"".format(type(data)) assert 'dims' in data, 'Can\'t locate ""dims"" key in file' assert 'values' in data, 'Can\'t locate ""values"" key in file' for dimname in data['dims']: assert dimname in data, 'Can\'t locate ""{}"" key in file'.format(dimname) return xray.DataArray(data['values'], dims=data['dims'], coords=dict(zip(data['dims'], [data[dimname] for dimname in data['dims']]))) ``` it's pretty speedy, here is an example for a (3, 4, 5) shaped DataArray: ``` In [42]: def save_and_load_again(da): with open('/path/to/datarray.npz', 'w') as f: to_npz(da, f) with open('/path/to/datarray.npz', 'r') as f: a = from_npz(f) return a %time (save_and_load_again(da) == da).all() CPU times: user 12.6 ms, sys: 0 ns, total: 12.6 ms Wall time: 26.2 ms Out[42]: array(True, dtype=bool) ``` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/768/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 126205116,MDU6SXNzdWUxMjYyMDUxMTY=,716,pandas date_range as index causes TypeError on repr,5497186,closed,0,,,2,2016-01-12T15:33:20Z,2016-01-13T22:17:00Z,2016-01-13T22:17:00Z,NONE,,,,"love this library btw, much thanks. ``` >>> import pandas as pd >>> import numpy as np >>> import xray >>> pd.__version__ u'0.17.1' >>> np.__version__ '1.10.4' >>> xray.__version__ '0.6.1' >>> import pytz >>> import datetime >>> datetime_index = pd.date_range(start=datetime.datetime.now(), tz=pytz.timezone('America/New_York'), periods=32, freq='1h') >>> da = xray.DataArray(data=a, dims=['example', 'channel', 'row', 'column'], coords={'example': datetime_index, 'channel': np.arange(1), 'row': np.arange(28), 'column': np.arange(28)}) >>> print da Traceback (most recent call last): [...] TypeError: data type not understood ``` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/716/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue