@@ -221,21 +221,27 @@ performs the inverse transformation.
221
221
222
222
In the following an example on how to use the coders ``decode `` method:
223
223
224
- .. ipython :: python
225
- :suppress :
224
+ .. jupyter-execute ::
225
+ :hide-code :
226
226
227
227
import xarray as xr
228
+ import numpy as np
228
229
229
- .. ipython :: python
230
+ .. jupyter-execute ::
230
231
231
232
var = xr.Variable(
232
233
dims=("x",), data=np.arange(10.0), attrs={"scale_factor": 10, "add_offset": 2}
233
234
)
234
235
var
235
236
237
+ .. jupyter-execute ::
238
+
236
239
coder = xr.coding.variables.CFScaleOffsetCoder()
237
240
decoded_var = coder.decode(var)
238
241
decoded_var
242
+
243
+ .. jupyter-execute ::
244
+
239
245
decoded_var.encoding
240
246
241
247
Some of the transformations can be common to more backends, so before
@@ -432,36 +438,55 @@ In the ``BASIC`` indexing support, numbers and slices are supported.
432
438
433
439
Example:
434
440
435
- .. ipython ::
436
- :verbatim:
441
+ .. jupyter-input ::
442
+
443
+ # () shall return the full array
444
+ backend_array._raw_indexing_method(())
445
+
446
+ .. jupyter-output ::
447
+
448
+ array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]])
449
+
450
+ .. jupyter-input ::
451
+
452
+ # shall support integers
453
+ backend_array._raw_indexing_method(1, 1)
437
454
438
- In [1]: # () shall return the full array
439
- ...: backend_array._raw_indexing_method(())
440
- Out[1]: array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]])
455
+ .. jupyter-output ::
441
456
442
- In [2]: # shall support integers
443
- ...: backend_array._raw_indexing_method(1, 1)
444
- Out[2]: 5
457
+ 5
445
458
446
- In [3]: # shall support slices
447
- ...: backend_array._raw_indexing_method(slice(0, 3), slice(2, 4))
448
- Out[3]: array([[2, 3], [6, 7], [10, 11]])
459
+ .. jupyter-input ::
460
+
461
+ # shall support slices
462
+ backend_array._raw_indexing_method(slice(0, 3), slice(2, 4))
463
+
464
+ .. jupyter-output ::
465
+
466
+ array([[2, 3], [6, 7], [10, 11]])
449
467
450
468
**OUTER **
451
469
452
470
The ``OUTER `` indexing shall support number, slices and in addition it shall
453
471
support also lists of integers. The outer indexing is equivalent to
454
472
combining multiple input list with ``itertools.product() ``:
455
473
456
- .. ipython ::
457
- :verbatim:
474
+ .. jupyter-input ::
475
+
476
+ backend_array._raw_indexing_method([0, 1], [0, 1, 2])
458
477
459
- In [1]: backend_array._raw_indexing_method([0, 1], [0, 1, 2])
460
- Out[1]: array([[0, 1, 2], [4, 5, 6]])
478
+ .. jupyter-output ::
479
+
480
+ array([[0, 1, 2], [4, 5, 6]])
481
+
482
+ .. jupyter-input ::
461
483
462
484
# shall support integers
463
- In [2]: backend_array._raw_indexing_method(1, 1)
464
- Out[2]: 5
485
+ backend_array._raw_indexing_method(1, 1)
486
+
487
+ .. jupyter-output ::
488
+
489
+ 5
465
490
466
491
467
492
**OUTER_1VECTOR **
0 commit comments