Skip to content
forked from pydata/xarray

Commit 3fb945e

Browse files
author
dcherian
committed
Merge branch 'master' into fix/norm
* 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)
2 parents 2888724 + bb87a94 commit 3fb945e

39 files changed

+976
-500
lines changed

.travis.yml

+28-52
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Based on http://conda.pydata.org/docs/travis.html
2-
language: python
2+
language: minimal
33
sudo: false # use container based build
44
notifications:
55
email: false
@@ -10,74 +10,48 @@ branches:
1010
matrix:
1111
fast_finish: true
1212
include:
13-
- python: 2.7
14-
env: CONDA_ENV=py27-min
15-
- python: 2.7
16-
env: CONDA_ENV=py27-cdat+iris+pynio
17-
- python: 3.5
18-
env: CONDA_ENV=py35
19-
- python: 3.6
20-
env: CONDA_ENV=py36
21-
- python: 3.6 # TODO: change this to 3.7 once https://github.com/travis-ci/travis-ci/issues/9815 is fixed
22-
env: CONDA_ENV=py37
23-
- python: 3.6
24-
env:
13+
- env: CONDA_ENV=py27-min
14+
- env: CONDA_ENV=py27-cdat+iris+pynio
15+
- env: CONDA_ENV=py35
16+
- env: CONDA_ENV=py36
17+
- env: CONDA_ENV=py37
18+
- env:
2519
- CONDA_ENV=py36
2620
- EXTRA_FLAGS="--run-flaky --run-network-tests"
27-
- python: 3.6
28-
env: CONDA_ENV=py36-netcdf4-dev
21+
- env: CONDA_ENV=py36-netcdf4-dev
2922
addons:
3023
apt_packages:
3124
- libhdf5-serial-dev
3225
- netcdf-bin
3326
- libnetcdf-dev
34-
- python: 3.6
35-
env: CONDA_ENV=py36-dask-dev
36-
- python: 3.6
37-
env: CONDA_ENV=py36-pandas-dev
38-
- python: 3.6
39-
env: CONDA_ENV=py36-bottleneck-dev
40-
- python: 3.6
41-
env: CONDA_ENV=py36-condaforge-rc
42-
- python: 3.6
43-
env: CONDA_ENV=py36-pynio-dev
44-
- python: 3.6
45-
env: CONDA_ENV=py36-rasterio-0.36
46-
- python: 3.6
47-
env: CONDA_ENV=py36-zarr-dev
48-
- python: 3.5
49-
env: CONDA_ENV=docs
50-
- python: 3.6
51-
env: CONDA_ENV=py36-hypothesis
27+
- env: CONDA_ENV=py36-dask-dev
28+
- env: CONDA_ENV=py36-pandas-dev
29+
- env: CONDA_ENV=py36-bottleneck-dev
30+
- env: CONDA_ENV=py36-condaforge-rc
31+
- env: CONDA_ENV=py36-pynio-dev
32+
- env: CONDA_ENV=py36-rasterio-0.36
33+
- env: CONDA_ENV=py36-zarr-dev
34+
- env: CONDA_ENV=docs
35+
- env: CONDA_ENV=py36-hypothesis
36+
5237
allow_failures:
53-
- python: 3.6
54-
env:
38+
- env:
5539
- CONDA_ENV=py36
5640
- EXTRA_FLAGS="--run-flaky --run-network-tests"
57-
- python: 3.6
58-
env: CONDA_ENV=py36-netcdf4-dev
41+
- env: CONDA_ENV=py36-netcdf4-dev
5942
addons:
6043
apt_packages:
6144
- libhdf5-serial-dev
6245
- netcdf-bin
6346
- libnetcdf-dev
64-
- python: 3.6
65-
env: CONDA_ENV=py36-pandas-dev
66-
- python: 3.6
67-
env: CONDA_ENV=py36-bottleneck-dev
68-
- python: 3.6
69-
env: CONDA_ENV=py36-condaforge-rc
70-
- python: 3.6
71-
env: CONDA_ENV=py36-pynio-dev
72-
- python: 3.6
73-
env: CONDA_ENV=py36-zarr-dev
47+
- env: CONDA_ENV=py36-pandas-dev
48+
- env: CONDA_ENV=py36-bottleneck-dev
49+
- env: CONDA_ENV=py36-condaforge-rc
50+
- env: CONDA_ENV=py36-pynio-dev
51+
- env: CONDA_ENV=py36-zarr-dev
7452

7553
before_install:
76-
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
77-
wget http://repo.continuum.io/miniconda/Miniconda-3.16.0-Linux-x86_64.sh -O miniconda.sh;
78-
else
79-
wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh;
80-
fi
54+
- wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh;
8155
- bash miniconda.sh -b -p $HOME/miniconda
8256
- export PATH="$HOME/miniconda/bin:$PATH"
8357
- hash -r
@@ -97,6 +71,8 @@ install:
9771
- python xarray/util/print_versions.py
9872

9973
script:
74+
- which python
75+
- python --version
10076
- python -OO -c "import xarray"
10177
- if [[ "$CONDA_ENV" == "docs" ]]; then
10278
conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc;

doc/api-hidden.rst

+2
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,5 @@
151151
plot.FacetGrid.set_titles
152152
plot.FacetGrid.set_ticks
153153
plot.FacetGrid.map
154+
155+
CFTimeIndex.shift

doc/data-structures.rst

-7
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,6 @@ operations keep around coordinates:
408408
list(ds[['x']])
409409
list(ds.drop('temperature'))
410410
411-
If a dimension name is given as an argument to ``drop``, it also drops all
412-
variables that use that dimension:
413-
414-
.. ipython:: python
415-
416-
list(ds.drop('time'))
417-
418411
As an alternate to dictionary-like modifications, you can use
419412
:py:meth:`~xarray.Dataset.assign` and :py:meth:`~xarray.Dataset.assign_coords`.
420413
These methods return a new dataset with additional (or replaced) or values:

doc/interpolation.rst

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ by specifing the time periods required.
6363
6464
da_dt64.interp(time=pd.date_range('1/1/2000', '1/3/2000', periods=3))
6565
66+
Interpolation of data indexed by a :py:class:`~xarray.CFTimeIndex` is also
67+
allowed. See :ref:`CFTimeIndex` for examples.
68+
6669
.. note::
6770

6871
Currently, our interpolation only works for regular grids.

doc/time-series.rst

+37-19
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ You can manual decode arrays in this form by passing a dataset to
7070
One unfortunate limitation of using ``datetime64[ns]`` is that it limits the
7171
native representation of dates to those that fall between the years 1678 and
7272
2262. When a netCDF file contains dates outside of these bounds, dates will be
73-
returned as arrays of ``cftime.datetime`` objects and a ``CFTimeIndex``
74-
can be used for indexing. The ``CFTimeIndex`` enables only a subset of
75-
the indexing functionality of a ``pandas.DatetimeIndex`` and is only enabled
73+
returned as arrays of :py:class:`cftime.datetime` objects and a :py:class:`~xarray.CFTimeIndex`
74+
can be used for indexing. The :py:class:`~xarray.CFTimeIndex` enables only a subset of
75+
the indexing functionality of a :py:class:`pandas.DatetimeIndex` and is only enabled
7676
when using the standalone version of ``cftime`` (not the version packaged with
7777
earlier versions ``netCDF4``). See :ref:`CFTimeIndex` for more information.
7878

@@ -219,20 +219,20 @@ Non-standard calendars and dates outside the Timestamp-valid range
219219
------------------------------------------------------------------
220220

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

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

237237
.. ipython:: python
238238
@@ -247,28 +247,28 @@ coordinate with a no-leap calendar within a context manager setting the
247247
248248
.. note::
249249

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

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

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

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

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

273273
- `Partial datetime string indexing`_ using strictly `ISO 8601-format`_ partial
274274
datetime strings:
@@ -294,7 +294,25 @@ For data indexed by a ``CFTimeIndex`` xarray currently supports:
294294
.. ipython:: python
295295
296296
da.groupby('time.month').sum()
297-
297+
298+
- Interpolation using :py:class:`cftime.datetime` objects:
299+
300+
.. ipython:: python
301+
302+
da.interp(time=[DatetimeNoLeap(1, 1, 15), DatetimeNoLeap(1, 2, 15)])
303+
304+
- Interpolation using datetime strings:
305+
306+
.. ipython:: python
307+
308+
da.interp(time=['0001-01-15', '0001-02-15'])
309+
310+
- Differentiation:
311+
312+
.. ipython:: python
313+
314+
da.differentiate('time')
315+
298316
- And serialization:
299317

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

307325
Currently resampling along the time dimension for data indexed by a
308-
``CFTimeIndex`` is not supported.
326+
:py:class:`~xarray.CFTimeIndex` is not supported.
309327

310328
.. _Timestamp-valid range: https://pandas.pydata.org/pandas-docs/stable/timeseries.html#timestamp-limitations
311329
.. _ISO 8601-format: https://en.wikipedia.org/wiki/ISO_8601

doc/whats-new.rst

+33-2
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,51 @@ What's New
3030
v0.11.0 (unreleased)
3131
--------------------
3232

33+
Breaking changes
34+
~~~~~~~~~~~~~~~~
35+
36+
- Reduction of :py:meth:`DataArray.groupby` and :py:meth:`DataArray.resample`
37+
without dimension argument will change in the next release.
38+
Now we warn a FutureWarning.
39+
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
40+
41+
Documentation
42+
~~~~~~~~~~~~~
3343
Enhancements
3444
~~~~~~~~~~~~
3545

3646
- Added support for Python 3.7. (:issue:`2271`).
3747
By `Joe Hamman <https://github.com/jhamman>`_.
38-
3948
- ``xarray.plot()`` now properly accepts a ``norm`` argument and does not override
4049
the norm's ``vmin`` and ``vmax``.
4150
(:issue:`2381`)
4251
By `Deepak Cherian <https://github.com/dcherian>`_.
43-
52+
- Added :py:meth:`~xarray.CFTimeIndex.shift` for shifting the values of a
53+
CFTimeIndex by a specified frequency. (:issue:`2244`). By `Spencer Clark
54+
<https://github.com/spencerkclark>`_.
55+
- Added support for using ``cftime.datetime`` coordinates with
56+
:py:meth:`~xarray.DataArray.differentiate`,
57+
:py:meth:`~xarray.Dataset.differentiate`,
58+
:py:meth:`~xarray.DataArray.interp`, and
59+
:py:meth:`~xarray.Dataset.interp`.
60+
By `Spencer Clark <https://github.com/spencerkclark>`_
61+
4462
Bug fixes
4563
~~~~~~~~~
4664

65+
- Addition and subtraction operators used with a CFTimeIndex now preserve the
66+
index's type. (:issue:`2244`). By `Spencer Clark <https://github.com/spencerkclark>`_.
67+
- ``xarray.DataArray.roll`` correctly handles multidimensional arrays.
68+
(:issue:`2445`)
69+
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
70+
71+
- ``xarray.DataArray.std()`` now correctly accepts ``ddof`` keyword argument.
72+
(:issue:`2240`)
73+
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
74+
- Restore matplotlib's default of plotting dashed negative contours when
75+
a single color is passed to ``DataArray.contour()`` e.g. ``colors='k'``.
76+
By `Deepak Cherian <https://github.com/dcherian>`_.
77+
4778

4879
.. _whats-new.0.10.9:
4980

properties/test_encode_decode.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import xarray as xr
1414

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

1819

1920
an_array = npst.arrays(

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@
6969
install_requires=INSTALL_REQUIRES,
7070
tests_require=TESTS_REQUIRE,
7171
url=URL,
72+
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
7273
packages=find_packages(),
7374
package_data={'xarray': ['tests/data/*']})

xarray/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@
3434
from . import tutorial
3535
from . import ufuncs
3636
from . import testing
37+
38+
from .core.common import ALL_DIMS

0 commit comments

Comments
 (0)