Skip to content
forked from pydata/xarray

Commit

Permalink
Merge branch 'master' into fix/norm
Browse files Browse the repository at this point in the history
* master:
  Replace the last of unittest with pytest (pydata#2467)
  Add python_requires to setup.py (pydata#2465)
  Clean up _parse_array_of_cftime_strings (pydata#2464)
  plot.contour: Don't make cmap if colors is a single color. (pydata#2453)
  np.AxisError was added in numpy 1.13 (pydata#2455)
  Add CFTimeIndex.shift (pydata#2431)
  Fix FutureWarning in CFTimeIndex.date_type (pydata#2448)
  fix:2445 (pydata#2446)
  Enable use of cftime.datetime coordinates with differentiate and interp (pydata#2434)
  restore ddof support in std (pydata#2447)
  Future warning for default reduction dimension of groupby (pydata#2366)
  Remove incorrect statement about "drop" in the text docs (pydata#2439)
  Use profile mechanism, not no-op mutation (pydata#2442)
  switch travis language to generic (pydata#2432)
  • Loading branch information
dcherian committed Oct 7, 2018
2 parents 2888724 + bb87a94 commit 3fb945e
Show file tree
Hide file tree
Showing 39 changed files with 976 additions and 500 deletions.
80 changes: 28 additions & 52 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Based on http://conda.pydata.org/docs/travis.html
language: python
language: minimal
sudo: false # use container based build
notifications:
email: false
Expand All @@ -10,74 +10,48 @@ branches:
matrix:
fast_finish: true
include:
- python: 2.7
env: CONDA_ENV=py27-min
- python: 2.7
env: CONDA_ENV=py27-cdat+iris+pynio
- python: 3.5
env: CONDA_ENV=py35
- python: 3.6
env: CONDA_ENV=py36
- python: 3.6 # TODO: change this to 3.7 once https://github.com/travis-ci/travis-ci/issues/9815 is fixed
env: CONDA_ENV=py37
- python: 3.6
env:
- env: CONDA_ENV=py27-min
- env: CONDA_ENV=py27-cdat+iris+pynio
- env: CONDA_ENV=py35
- env: CONDA_ENV=py36
- env: CONDA_ENV=py37
- env:
- CONDA_ENV=py36
- EXTRA_FLAGS="--run-flaky --run-network-tests"
- python: 3.6
env: CONDA_ENV=py36-netcdf4-dev
- env: CONDA_ENV=py36-netcdf4-dev
addons:
apt_packages:
- libhdf5-serial-dev
- netcdf-bin
- libnetcdf-dev
- python: 3.6
env: CONDA_ENV=py36-dask-dev
- python: 3.6
env: CONDA_ENV=py36-pandas-dev
- python: 3.6
env: CONDA_ENV=py36-bottleneck-dev
- python: 3.6
env: CONDA_ENV=py36-condaforge-rc
- python: 3.6
env: CONDA_ENV=py36-pynio-dev
- python: 3.6
env: CONDA_ENV=py36-rasterio-0.36
- python: 3.6
env: CONDA_ENV=py36-zarr-dev
- python: 3.5
env: CONDA_ENV=docs
- python: 3.6
env: CONDA_ENV=py36-hypothesis
- env: CONDA_ENV=py36-dask-dev
- env: CONDA_ENV=py36-pandas-dev
- env: CONDA_ENV=py36-bottleneck-dev
- env: CONDA_ENV=py36-condaforge-rc
- env: CONDA_ENV=py36-pynio-dev
- env: CONDA_ENV=py36-rasterio-0.36
- env: CONDA_ENV=py36-zarr-dev
- env: CONDA_ENV=docs
- env: CONDA_ENV=py36-hypothesis

allow_failures:
- python: 3.6
env:
- env:
- CONDA_ENV=py36
- EXTRA_FLAGS="--run-flaky --run-network-tests"
- python: 3.6
env: CONDA_ENV=py36-netcdf4-dev
- env: CONDA_ENV=py36-netcdf4-dev
addons:
apt_packages:
- libhdf5-serial-dev
- netcdf-bin
- libnetcdf-dev
- python: 3.6
env: CONDA_ENV=py36-pandas-dev
- python: 3.6
env: CONDA_ENV=py36-bottleneck-dev
- python: 3.6
env: CONDA_ENV=py36-condaforge-rc
- python: 3.6
env: CONDA_ENV=py36-pynio-dev
- python: 3.6
env: CONDA_ENV=py36-zarr-dev
- env: CONDA_ENV=py36-pandas-dev
- env: CONDA_ENV=py36-bottleneck-dev
- env: CONDA_ENV=py36-condaforge-rc
- env: CONDA_ENV=py36-pynio-dev
- env: CONDA_ENV=py36-zarr-dev

before_install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget http://repo.continuum.io/miniconda/Miniconda-3.16.0-Linux-x86_64.sh -O miniconda.sh;
else
wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh;
fi
- wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
Expand All @@ -97,6 +71,8 @@ install:
- python xarray/util/print_versions.py

script:
- which python
- python --version
- python -OO -c "import xarray"
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc;
Expand Down
2 changes: 2 additions & 0 deletions doc/api-hidden.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,5 @@
plot.FacetGrid.set_titles
plot.FacetGrid.set_ticks
plot.FacetGrid.map

CFTimeIndex.shift
7 changes: 0 additions & 7 deletions doc/data-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,6 @@ operations keep around coordinates:
list(ds[['x']])
list(ds.drop('temperature'))
If a dimension name is given as an argument to ``drop``, it also drops all
variables that use that dimension:

.. ipython:: python
list(ds.drop('time'))
As an alternate to dictionary-like modifications, you can use
:py:meth:`~xarray.Dataset.assign` and :py:meth:`~xarray.Dataset.assign_coords`.
These methods return a new dataset with additional (or replaced) or values:
Expand Down
3 changes: 3 additions & 0 deletions doc/interpolation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ by specifing the time periods required.
da_dt64.interp(time=pd.date_range('1/1/2000', '1/3/2000', periods=3))
Interpolation of data indexed by a :py:class:`~xarray.CFTimeIndex` is also
allowed. See :ref:`CFTimeIndex` for examples.

.. note::

Currently, our interpolation only works for regular grids.
Expand Down
56 changes: 37 additions & 19 deletions doc/time-series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ You can manual decode arrays in this form by passing a dataset to
One unfortunate limitation of using ``datetime64[ns]`` is that it limits the
native representation of dates to those that fall between the years 1678 and
2262. When a netCDF file contains dates outside of these bounds, dates will be
returned as arrays of ``cftime.datetime`` objects and a ``CFTimeIndex``
can be used for indexing. The ``CFTimeIndex`` enables only a subset of
the indexing functionality of a ``pandas.DatetimeIndex`` and is only enabled
returned as arrays of :py:class:`cftime.datetime` objects and a :py:class:`~xarray.CFTimeIndex`
can be used for indexing. The :py:class:`~xarray.CFTimeIndex` enables only a subset of
the indexing functionality of a :py:class:`pandas.DatetimeIndex` and is only enabled
when using the standalone version of ``cftime`` (not the version packaged with
earlier versions ``netCDF4``). See :ref:`CFTimeIndex` for more information.

Expand Down Expand Up @@ -219,20 +219,20 @@ Non-standard calendars and dates outside the Timestamp-valid range
------------------------------------------------------------------

Through the standalone ``cftime`` library and a custom subclass of
``pandas.Index``, xarray supports a subset of the indexing functionality enabled
through the standard ``pandas.DatetimeIndex`` for dates from non-standard
calendars or dates using a standard calendar, but outside the
`Timestamp-valid range`_ (approximately between years 1678 and 2262). This
behavior has not yet been turned on by default; to take advantage of this
functionality, you must have the ``enable_cftimeindex`` option set to
:py:class:`pandas.Index`, xarray supports a subset of the indexing
functionality enabled through the standard :py:class:`pandas.DatetimeIndex` for
dates from non-standard calendars or dates using a standard calendar, but
outside the `Timestamp-valid range`_ (approximately between years 1678 and
2262). This behavior has not yet been turned on by default; to take advantage
of this functionality, you must have the ``enable_cftimeindex`` option set to
``True`` within your context (see :py:func:`~xarray.set_options` for more
information). It is expected that this will become the default behavior in
xarray version 0.11.

For instance, you can create a DataArray indexed by a time
coordinate with a no-leap calendar within a context manager setting the
``enable_cftimeindex`` option, and the time index will be cast to a
``CFTimeIndex``:
:py:class:`~xarray.CFTimeIndex`:

.. ipython:: python
Expand All @@ -247,28 +247,28 @@ coordinate with a no-leap calendar within a context manager setting the
.. note::

With the ``enable_cftimeindex`` option activated, a ``CFTimeIndex``
With the ``enable_cftimeindex`` option activated, a :py:class:`~xarray.CFTimeIndex`
will be used for time indexing if any of the following are true:

- The dates are from a non-standard calendar
- Any dates are outside the Timestamp-valid range

Otherwise a ``pandas.DatetimeIndex`` will be used. In addition, if any
Otherwise a :py:class:`pandas.DatetimeIndex` will be used. In addition, if any
variable (not just an index variable) is encoded using a non-standard
calendar, its times will be decoded into ``cftime.datetime`` objects,
calendar, its times will be decoded into :py:class:`cftime.datetime` objects,
regardless of whether or not they can be represented using
``np.datetime64[ns]`` objects.

xarray also includes a :py:func:`cftime_range` function, which enables creating a
``CFTimeIndex`` with regularly-spaced dates. For instance, we can create the
same dates and DataArray we created above using:
xarray also includes a :py:func:`~xarray.cftime_range` function, which enables
creating a :py:class:`~xarray.CFTimeIndex` with regularly-spaced dates. For instance, we can
create the same dates and DataArray we created above using:

.. ipython:: python
dates = xr.cftime_range(start='0001', periods=24, freq='MS', calendar='noleap')
da = xr.DataArray(np.arange(24), coords=[dates], dims=['time'], name='foo')
For data indexed by a ``CFTimeIndex`` xarray currently supports:
For data indexed by a :py:class:`~xarray.CFTimeIndex` xarray currently supports:

- `Partial datetime string indexing`_ using strictly `ISO 8601-format`_ partial
datetime strings:
Expand All @@ -294,7 +294,25 @@ For data indexed by a ``CFTimeIndex`` xarray currently supports:
.. ipython:: python
da.groupby('time.month').sum()
- Interpolation using :py:class:`cftime.datetime` objects:

.. ipython:: python
da.interp(time=[DatetimeNoLeap(1, 1, 15), DatetimeNoLeap(1, 2, 15)])
- Interpolation using datetime strings:

.. ipython:: python
da.interp(time=['0001-01-15', '0001-02-15'])
- Differentiation:

.. ipython:: python
da.differentiate('time')
- And serialization:

.. ipython:: python
Expand All @@ -305,7 +323,7 @@ For data indexed by a ``CFTimeIndex`` xarray currently supports:
.. note::

Currently resampling along the time dimension for data indexed by a
``CFTimeIndex`` is not supported.
:py:class:`~xarray.CFTimeIndex` is not supported.

.. _Timestamp-valid range: https://pandas.pydata.org/pandas-docs/stable/timeseries.html#timestamp-limitations
.. _ISO 8601-format: https://en.wikipedia.org/wiki/ISO_8601
Expand Down
35 changes: 33 additions & 2 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,51 @@ What's New
v0.11.0 (unreleased)
--------------------

Breaking changes
~~~~~~~~~~~~~~~~

- Reduction of :py:meth:`DataArray.groupby` and :py:meth:`DataArray.resample`
without dimension argument will change in the next release.
Now we warn a FutureWarning.
By `Keisuke Fujii <https://github.com/fujiisoup>`_.

Documentation
~~~~~~~~~~~~~
Enhancements
~~~~~~~~~~~~

- Added support for Python 3.7. (:issue:`2271`).
By `Joe Hamman <https://github.com/jhamman>`_.

- ``xarray.plot()`` now properly accepts a ``norm`` argument and does not override
the norm's ``vmin`` and ``vmax``.
(:issue:`2381`)
By `Deepak Cherian <https://github.com/dcherian>`_.

- Added :py:meth:`~xarray.CFTimeIndex.shift` for shifting the values of a
CFTimeIndex by a specified frequency. (:issue:`2244`). By `Spencer Clark
<https://github.com/spencerkclark>`_.
- Added support for using ``cftime.datetime`` coordinates with
:py:meth:`~xarray.DataArray.differentiate`,
:py:meth:`~xarray.Dataset.differentiate`,
:py:meth:`~xarray.DataArray.interp`, and
:py:meth:`~xarray.Dataset.interp`.
By `Spencer Clark <https://github.com/spencerkclark>`_

Bug fixes
~~~~~~~~~

- Addition and subtraction operators used with a CFTimeIndex now preserve the
index's type. (:issue:`2244`). By `Spencer Clark <https://github.com/spencerkclark>`_.
- ``xarray.DataArray.roll`` correctly handles multidimensional arrays.
(:issue:`2445`)
By `Keisuke Fujii <https://github.com/fujiisoup>`_.

- ``xarray.DataArray.std()`` now correctly accepts ``ddof`` keyword argument.
(:issue:`2240`)
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
- Restore matplotlib's default of plotting dashed negative contours when
a single color is passed to ``DataArray.contour()`` e.g. ``colors='k'``.
By `Deepak Cherian <https://github.com/dcherian>`_.


.. _whats-new.0.10.9:

Expand Down
3 changes: 2 additions & 1 deletion properties/test_encode_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import xarray as xr

# Run for a while - arrays are a bigger search space than usual
settings.deadline = None
settings.register_profile("ci", deadline=None)
settings.load_profile("ci")


an_array = npst.arrays(
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
install_requires=INSTALL_REQUIRES,
tests_require=TESTS_REQUIRE,
url=URL,
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
packages=find_packages(),
package_data={'xarray': ['tests/data/*']})
2 changes: 2 additions & 0 deletions xarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
from . import tutorial
from . import ufuncs
from . import testing

from .core.common import ALL_DIMS
Loading

0 comments on commit 3fb945e

Please sign in to comment.