Skip to content

Commit 1a0ff25

Browse files
author
dcherian
committed
doc fixes.
Fixes #2610
1 parent 9e8707d commit 1a0ff25

File tree

10 files changed

+38
-19
lines changed

10 files changed

+38
-19
lines changed

doc/api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ Computation
343343
:py:attr:`~DataArray.searchsorted`
344344
:py:attr:`~DataArray.round`
345345
:py:attr:`~DataArray.real`
346-
:py:attr:`~DataArray.T`
347346
:py:attr:`~DataArray.cumsum`
348347
:py:attr:`~DataArray.cumprod`
349348
:py:attr:`~DataArray.rank`

doc/dask.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Explicit conversion by wrapping a DataArray with ``np.asarray`` also works:
179179
Alternatively you can load the data into memory but keep the arrays as
180180
Dask arrays using the :py:meth:`~xarray.Dataset.persist` method:
181181

182-
.. ipython::
182+
.. ipython:: python
183183
184184
ds = ds.persist()
185185

doc/examples/multidimensional-coords.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ As an example, consider this dataset from the
2525

2626
.. ipython:: python
2727
28-
ds = xr.tutorial.load_dataset('rasm')
28+
ds = xr.tutorial.open_dataset('rasm').load()
2929
ds
3030
3131
In this example, the *logical coordinates* are ``x`` and ``y``, while
@@ -107,7 +107,8 @@ function to specify the output coordinates of the group.
107107
# define a label for each bin corresponding to the central latitude
108108
lat_center = np.arange(1, 90, 2)
109109
# group according to those bins and take the mean
110-
Tair_lat_mean = ds.Tair.groupby_bins('xc', lat_bins, labels=lat_center).mean()
110+
Tair_lat_mean = (ds.Tair.groupby_bins('xc', lat_bins, labels=lat_center)
111+
.mean(xr.ALL_DIMS))
111112
# plot the result
112113
@savefig xarray_multidimensional_coords_14_1.png width=5in
113114
Tair_lat_mean.plot();

doc/examples/weather-data.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ The :py:func:`~xarray.Dataset.fillna` method on grouped objects lets you easily
123123
fill missing values by group:
124124

125125
.. ipython:: python
126+
:okwarning:
126127
127128
# throw away the first half of every month
128129
some_missing = ds.tmin.sel(time=ds['time.day'] > 15).reindex_like(ds)

doc/groupby.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ dimensions *other than* the provided one:
118118

119119
.. ipython:: python
120120
121-
ds.groupby('x').std()
121+
ds.groupby('x').std(xr.ALL_DIMS)
122122
123123
First and last
124124
~~~~~~~~~~~~~~
@@ -129,7 +129,7 @@ values for group along the grouped dimension:
129129

130130
.. ipython:: python
131131
132-
ds.groupby('letters').first()
132+
ds.groupby('letters').first(xr.ALL_DIMS)
133133
134134
By default, they skip missing values (control this with ``skipna``).
135135

@@ -144,7 +144,7 @@ coordinates. For example:
144144

145145
.. ipython:: python
146146
147-
alt = arr.groupby('letters').mean()
147+
alt = arr.groupby('letters').mean(xr.ALL_DIMS)
148148
alt
149149
ds.groupby('letters') - alt
150150
@@ -197,7 +197,7 @@ __ http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html#_two_dimen
197197
'lat': (['ny','nx'], [[10,10],[20,20]] ),},
198198
dims=['ny','nx'])
199199
da
200-
da.groupby('lon').sum()
200+
da.groupby('lon').sum(xr.ALL_DIMS)
201201
da.groupby('lon').apply(lambda x: x - x.mean(), shortcut=False)
202202
203203
Because multidimensional groups have the ability to generate a very large

doc/pandas.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ So you can represent a Panel, in two ways:
173173
Let's take a look:
174174

175175
.. ipython:: python
176+
:okwarning:
176177
177178
panel = pd.Panel(np.random.rand(2, 3, 4), items=list('ab'), major_axis=list('mno'),
178179
minor_axis=pd.date_range(start='2000', periods=4, name='date'))

doc/plotting.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ axes created by ``plt.subplots``.
144144
plt.tight_layout()
145145
146146
@savefig plotting_example_existing_axes.png width=6in
147-
plt.show()
147+
plt.draw()
148148
149149
On the right is a histogram created by :py:func:`xarray.plot.hist`.
150150

@@ -343,7 +343,7 @@ matplotlib is available.
343343
plt.tight_layout()
344344
345345
@savefig plotting_2d_call_matplotlib.png width=4in
346-
plt.show()
346+
plt.draw()
347347
348348
.. note::
349349

@@ -359,7 +359,7 @@ matplotlib is available.
359359
air2d.plot()
360360
361361
@savefig plotting_2d_call_matplotlib2.png width=4in
362-
plt.show()
362+
plt.draw()
363363
364364
Colormaps
365365
~~~~~~~~~
@@ -444,9 +444,11 @@ if using ``imshow`` or ``pcolormesh`` (but not with ``contour`` or ``contourf``,
444444
since levels are chosen automatically).
445445

446446
.. ipython:: python
447+
:okwarning:
447448
448449
@savefig plotting_seaborn_palette.png width=4in
449450
air2d.plot(levels=10, cmap='husl')
451+
plt.draw()
450452
451453
.. _plotting.faceting:
452454

@@ -519,6 +521,11 @@ Other features
519521

520522
Faceted plotting supports other arguments common to xarray 2d plots.
521523

524+
.. ipython:: python
525+
:suppress:
526+
527+
plt.close('all')
528+
522529
.. ipython:: python
523530
524531
hasoutliers = t.isel(time=slice(0, 5)).copy()
@@ -528,7 +535,7 @@ Faceted plotting supports other arguments common to xarray 2d plots.
528535
@savefig plot_facet_robust.png
529536
g = hasoutliers.plot.pcolormesh('lon', 'lat', col='time', col_wrap=3,
530537
robust=True, cmap='viridis',
531-
cbar_kwargs={'label': 'this has outliers'})
538+
cbar_kwargs={'label': 'this has outliers'})
532539
533540
FacetGrid Objects
534541
~~~~~~~~~~~~~~~~~
@@ -568,7 +575,7 @@ they have been plotted.
568575
bottomright.annotate('bottom right', (240, 40))
569576
570577
@savefig plot_facet_iterator.png
571-
plt.show()
578+
plt.draw()
572579
573580
TODO: add an example of using the ``map`` method to plot dataset variables
574581
(e.g., with ``plt.quiver``).
@@ -603,7 +610,7 @@ by faceting are accessible in the object returned by ``plot``:
603610
ax.coastlines()
604611
ax.gridlines()
605612
@savefig plotting_maps_cartopy_facetting.png width=100%
606-
plt.show();
613+
plt.draw();
607614
608615
609616
Details
@@ -634,7 +641,7 @@ These are provided for user convenience; they all call the same code.
634641
xplt.line(da, ax=axes[1, 1])
635642
plt.tight_layout()
636643
@savefig plotting_ways_to_use.png width=6in
637-
plt.show()
644+
plt.draw()
638645
639646
Here the output is the same. Since the data is 1 dimensional the line plot
640647
was used.

doc/reshaping.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ labels for one or several dimensions:
186186
array
187187
array['c'] = ('x', ['a', 'b', 'c'])
188188
array.set_index(x='c')
189-
array.set_index(x='c', inplace=True)
190-
array.reset_index('x', drop=True)
189+
array = array.set_index(x='c')
190+
array = array.reset_index('x', drop=True)
191191
192192
.. _reshape.shift_and_roll:
193193

@@ -201,7 +201,7 @@ To adjust coordinate labels, you can use the :py:meth:`~xarray.Dataset.shift` an
201201
202202
array = xr.DataArray([1, 2, 3, 4], dims='x')
203203
array.shift(x=2)
204-
array.roll(x=2)
204+
array.roll(x=2, roll_coords=True)
205205
206206
.. _reshape.sort:
207207

doc/time-series.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ Datetime components couple particularly well with grouped operations (see
163163
calculate the mean by time of day:
164164

165165
.. ipython:: python
166+
:okwarning:
166167
167168
ds.groupby('time.hour').mean()
168169
@@ -176,6 +177,7 @@ same api as ``resample`` `in pandas`_.
176177
For example, we can downsample our dataset from hourly to 6-hourly:
177178

178179
.. ipython:: python
180+
:okwarning:
179181
180182
ds.resample(time='6H')
181183
@@ -184,6 +186,7 @@ necessary for resampling. All of the reduction methods which work with
184186
``Resample`` objects can also be used for resampling:
185187

186188
.. ipython:: python
189+
:okwarning:
187190
188191
ds.resample(time='6H').mean()
189192
@@ -326,6 +329,7 @@ For data indexed by a :py:class:`~xarray.CFTimeIndex` xarray currently supports:
326329
:py:meth:`~xarray.CFTimeIndex.to_datetimeindex` method:
327330

328331
.. ipython:: python
332+
:okwarning:
329333
330334
modern_times = xr.cftime_range('2000', periods=24, freq='MS', calendar='noleap')
331335
da = xr.DataArray(range(24), [('time', modern_times)])

doc/whats-new.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Bug fixes
174174
By `Spencer Clark <https://github.com/spencerkclark>`_.
175175
- We now properly handle arrays of ``datetime.datetime`` and ``datetime.timedelta``
176176
provided as coordinates. (:issue:`2512`)
177-
By `Deepak Cherian <https://github.com/dcherian`_.
177+
By `Deepak Cherian <https://github.com/dcherian>`_.
178178
- ``xarray.DataArray.roll`` correctly handles multidimensional arrays.
179179
(:issue:`2445`)
180180
By `Keisuke Fujii <https://github.com/fujiisoup>`_.
@@ -2216,6 +2216,7 @@ Enhancements
22162216
for shifting/rotating datasets or arrays along a dimension:
22172217

22182218
.. ipython:: python
2219+
:okwarning:
22192220
22202221
array = xray.DataArray([5, 6, 7, 8], dims='x')
22212222
array.shift(x=2)
@@ -2723,6 +2724,7 @@ Enhancements
27232724
need to supply the time dimension explicitly:
27242725

27252726
.. ipython:: python
2727+
:verbatim:
27262728
27272729
time = pd.date_range('2000-01-01', freq='6H', periods=10)
27282730
array = xray.DataArray(np.arange(10), [('time', time)])
@@ -2732,26 +2734,30 @@ Enhancements
27322734
options such as ``closed`` and ``label`` let you control labeling:
27332735

27342736
.. ipython:: python
2737+
:verbatim:
27352738
27362739
array.resample('1D', dim='time', how='sum', label='right')
27372740
27382741
If the desired temporal resolution is higher than the original data
27392742
(upsampling), xray will insert missing values:
27402743

27412744
.. ipython:: python
2745+
:verbatim:
27422746
27432747
array.resample('3H', 'time')
27442748
27452749
- ``first`` and ``last`` methods on groupby objects let you take the first or
27462750
last examples from each group along the grouped axis:
27472751

27482752
.. ipython:: python
2753+
:verbatim:
27492754
27502755
array.groupby('time.day').first()
27512756
27522757
These methods combine well with ``resample``:
27532758

27542759
.. ipython:: python
2760+
:verbatim:
27552761
27562762
array.resample('1D', dim='time', how='first')
27572763

0 commit comments

Comments
 (0)