Skip to content
forked from pydata/xarray

Commit

Permalink
Merge branch 'master' into refactor-plot-utils
Browse files Browse the repository at this point in the history
* master:
  stale requires a label (pydata#2701)
  Update indexing.rst (pydata#2700)
  add line break to message posted (pydata#2698)
  Config for closing stale issues (pydata#2684)
  to_dict without data (pydata#2659)
  Update asv.conf.json (pydata#2693)
  try no rasterio in py36 env (pydata#2691)
  Detailed report for testing.assert_equal and testing.assert_identical (pydata#1507)
  Hotfix for pydata#2662 (pydata#2678)
  Update README.rst (pydata#2682)
  Fix test failures with numpy=1.16 (pydata#2675)
  • Loading branch information
dcherian committed Jan 24, 2019
2 parents 792291c + 79fa060 commit 43057ef
Show file tree
Hide file tree
Showing 19 changed files with 430 additions and 53 deletions.
58 changes: 58 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Configuration for probot-stale - https://github.com/probot/stale

# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 700 # start with a large number and reduce shortly

# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 30

# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- pinned
- security
- "[Status] Maybe Later"

# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false

# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false

# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: true

# Label to use when marking as stale
staleLabel: stale

# Comment to post when marking as stale. Set to `false` to disable
markComment: |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity
If this issue remains relevant, please comment here; otherwise it will be marked as closed automatically
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.

# Comment to post when closing a stale Issue or Pull Request.
# closeComment: >
# Your comment here.

# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 1 # start with a small number


# Limit to only `issues` or `pulls`
# only: issues

# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
# pulls:
# daysUntilStale: 30
# markComment: >
# This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions.

# issues:
# exemptLabels:
# - confirmed
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ script:
- python --version
- python -OO -c "import xarray"
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc;
conda install -c conda-forge --override-channels sphinx sphinx_rtd_theme sphinx-gallery numpydoc "gdal>2.2.4";
sphinx-build -n -j auto -b html -d _build/doctrees doc _build/html;
elif [[ "$CONDA_ENV" == "lint" ]]; then
pycodestyle xarray ;
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ __ http://climate.com/
License
-------

Copyright 2014-2018, xarray Developers
Copyright 2014-2019, xarray Developers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
"pythons": ["2.7", "3.6"],
"pythons": ["3.6"],

// The matrix of dependencies to test. Each key is the name of a
// package (in PyPI) and the values are version numbers. An empty
Expand Down
6 changes: 3 additions & 3 deletions ci/requirements-py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ dependencies:
- scipy
- seaborn
- toolz
- rasterio
# - rasterio # xref #2683
- bottleneck
- zarr
- pseudonetcdf>=3.0.1
- eccodes
- cdms2
- pynio
- iris>=1.10
# - pynio # xref #2683
# - iris>=1.10 # xref #2683
- pydap
- lxml
- pip:
Expand Down
2 changes: 1 addition & 1 deletion doc/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ Vectorized indexing also works with ``isel``, ``loc``, and ``sel``:
ind = xr.DataArray([['a', 'b'], ['b', 'a']], dims=['a', 'b'])
da.loc[:, ind] # same as da.sel(y=ind)
These methods may and also be applied to ``Dataset`` objects
These methods may also be applied to ``Dataset`` objects

.. ipython:: python
Expand Down
12 changes: 11 additions & 1 deletion doc/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ require external libraries and dicts can easily be pickled, or converted to
json, or geojson. All the values are converted to lists, so dicts might
be quite large.

To export just the dataset schema, without the data itself, use the
``data=False`` option:

.. ipython:: python
ds.to_dict(data=False)
This can be useful for generating indices of dataset contents to expose to
search indices or other automated data discovery tools.

.. _io.netcdf:

netCDF
Expand Down Expand Up @@ -665,7 +675,7 @@ To read a consolidated store, pass the ``consolidated=True`` option to
:py:func:`~xarray.open_zarr`::

ds = xr.open_zarr('foo.zarr', consolidated=True)

Xarray can't perform consolidation on pre-existing zarr datasets. This should
be done directly from zarr, as described in the
`zarr docs <https://zarr.readthedocs.io/en/latest/tutorial.html#consolidating-metadata>`_.
Expand Down
7 changes: 7 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Breaking changes
Enhancements
~~~~~~~~~~~~

- Add ``data=False`` option to ``to_dict()`` methods. (:issue:`2656`)
By `Ryan Abernathey <https://github.com/rabernat>`_
- :py:meth:`~xarray.DataArray.coarsen` and
:py:meth:`~xarray.Dataset.coarsen` are newly added.
See :ref:`comput.coarsen` for details.
Expand All @@ -36,6 +38,11 @@ Enhancements
- Upsampling an array via interpolation with resample is now dask-compatible,
as long as the array is not chunked along the resampling dimension.
By `Spencer Clark <https://github.com/spencerkclark>`_.
- :py:func:`xarray.testing.assert_equal` and
:py:func:`xarray.testing.assert_identical` now provide a more detailed
report showing what exactly differs between the two objects (dimensions /
coordinates / variables / attributes) (:issue:`1507`).
By `Benoit Bovy <https://github.com/benbovy>`_.

Bug fixes
~~~~~~~~~
Expand Down
9 changes: 7 additions & 2 deletions xarray/core/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,21 @@ def _auto_combine_all_along_first_dim(combined_ids, dim, data_vars,
return new_combined_ids


def vars_as_keys(ds):
return tuple(sorted(ds))


def _auto_combine_1d(datasets, concat_dim=_CONCAT_DIM_DEFAULT,
compat='no_conflicts',
data_vars='all', coords='different'):
# This is just the old auto_combine function (which only worked along 1D)
if concat_dim is not None:
dim = None if concat_dim is _CONCAT_DIM_DEFAULT else concat_dim
grouped = itertools.groupby(datasets, key=lambda ds: tuple(sorted(ds)))
sorted_datasets = sorted(datasets, key=vars_as_keys)
grouped_by_vars = itertools.groupby(sorted_datasets, key=vars_as_keys)
concatenated = [_auto_concat(list(ds_group), dim=dim,
data_vars=data_vars, coords=coords)
for id, ds_group in grouped]
for id, ds_group in grouped_by_vars]
else:
concatenated = datasets
merged = merge(concatenated, compat=compat)
Expand Down
22 changes: 10 additions & 12 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ def to_netcdf(self, *args, **kwargs):

return dataset.to_netcdf(*args, **kwargs)

def to_dict(self):
def to_dict(self, data=True):
"""
Convert this xarray.DataArray into a dictionary following xarray
naming conventions.
Expand All @@ -1769,22 +1769,20 @@ def to_dict(self):
Useful for coverting to json. To avoid datetime incompatibility
use decode_times=False kwarg in xarrray.open_dataset.
Parameters
----------
data : bool, optional
Whether to include the actual data in the dictionary. When set to
False, returns just the schema.
See also
--------
DataArray.from_dict
"""
d = {'coords': {}, 'attrs': decode_numpy_dict_values(self.attrs),
'dims': self.dims}

d = self.variable.to_dict(data=data)
d.update({'coords': {}, 'name': self.name})
for k in self.coords:
data = ensure_us_time_resolution(self[k].values).tolist()
d['coords'].update({
k: {'data': data,
'dims': self[k].dims,
'attrs': decode_numpy_dict_values(self[k].attrs)}})

d.update({'data': ensure_us_time_resolution(self.values).tolist(),
'name': self.name})
d['coords'][k] = self.coords[k].variable.to_dict(data=data)
return d

@classmethod
Expand Down
21 changes: 9 additions & 12 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3221,7 +3221,7 @@ def to_dask_dataframe(self, dim_order=None, set_index=False):

return df

def to_dict(self):
def to_dict(self, data=True):
"""
Convert this dataset to a dictionary following xarray naming
conventions.
Expand All @@ -3230,25 +3230,22 @@ def to_dict(self):
Useful for coverting to json. To avoid datetime incompatibility
use decode_times=False kwarg in xarrray.open_dataset.
Parameters
----------
data : bool, optional
Whether to include the actual data in the dictionary. When set to
False, returns just the schema.
See also
--------
Dataset.from_dict
"""
d = {'coords': {}, 'attrs': decode_numpy_dict_values(self.attrs),
'dims': dict(self.dims), 'data_vars': {}}

for k in self.coords:
data = ensure_us_time_resolution(self[k].values).tolist()
d['coords'].update({
k: {'data': data,
'dims': self[k].dims,
'attrs': decode_numpy_dict_values(self[k].attrs)}})
d['coords'].update({k: self[k].variable.to_dict(data=data)})
for k in self.data_vars:
data = ensure_us_time_resolution(self[k].values).tolist()
d['data_vars'].update({
k: {'data': data,
'dims': self[k].dims,
'attrs': decode_numpy_dict_values(self[k].attrs)}})
d['data_vars'].update({k: self[k].variable.to_dict(data=data)})
return d

@classmethod
Expand Down
Loading

0 comments on commit 43057ef

Please sign in to comment.