Skip to content

Commit ea988d3

Browse files
committed
Make Task User Guide hidden code cell expandable (#114)
1 parent 2cf043a commit ea988d3

File tree

1 file changed

+64
-55
lines changed

1 file changed

+64
-55
lines changed

docs/user-guide/task.ipynb

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,23 @@
6262
"In DeepSensor, a `Task` is a `dict`-like data structure that contains context sets, target sets, and other metadata.\n",
6363
"Before diving into the [](./task_loader) class which generates `Task` objects from `xarray` and `pandas` objects,\n",
6464
"we will first introduce the `Task` class itself.\n",
65-
"In the code cell below, `task` is a `Task` object.\n",
66-
"Printing a `Task` will print each of its entries and replace numerical arrays with their shape for convenience."
65+
"\n",
66+
"First, we will generate a `Task` using DeepSensor. These code cells are kept hidden because they includes\n",
67+
"features that are only covered later in the User Guide. Only expand them if you are curious!"
6768
]
6869
},
6970
{
7071
"cell_type": "code",
7172
"execution_count": 1,
73+
"metadata": {
74+
"ExecuteTime": {
75+
"start_time": "2023-11-01T14:28:15.732009455Z"
76+
},
77+
"collapsed": false,
78+
"tags": [
79+
"hide-cell"
80+
]
81+
},
7282
"outputs": [
7383
{
7484
"name": "stderr",
@@ -106,28 +116,19 @@
106116
"era5_ds = data_processor(era5_raw_ds)\n",
107117
"aux_ds, land_mask_ds = data_processor([auxiliary_raw_ds, land_mask_raw_ds], method=\"min_max\")\n",
108118
"station_df = data_processor(station_raw_df)"
109-
],
110-
"metadata": {
111-
"collapsed": false,
112-
"tags": [
113-
"hide-cell"
114-
],
115-
"ExecuteTime": {
116-
"start_time": "2023-11-01T14:28:15.732009455Z"
117-
}
118-
}
119+
]
119120
},
120121
{
121122
"cell_type": "code",
122123
"execution_count": 2,
123124
"metadata": {
124-
"tags": [
125-
"remove-cell"
126-
],
127125
"ExecuteTime": {
128126
"end_time": "2023-11-01T14:32:15.553656830Z",
129127
"start_time": "2023-11-01T14:32:15.548454739Z"
130-
}
128+
},
129+
"tags": [
130+
"hide-cell"
131+
]
131132
},
132133
"outputs": [],
133134
"source": [
@@ -136,6 +137,14 @@
136137
"task = task_loader(\"2016-06-25\", context_sampling=[52, 112], target_sampling=245)"
137138
]
138139
},
140+
{
141+
"cell_type": "markdown",
142+
"metadata": {},
143+
"source": [
144+
"In the code cell below, `task` is a `Task` object.\n",
145+
"Printing a `Task` will print each of its entries and replace numerical arrays with their shape for convenience."
146+
]
147+
},
139148
{
140149
"cell_type": "code",
141150
"execution_count": 3,
@@ -178,6 +187,9 @@
178187
},
179188
{
180189
"cell_type": "markdown",
190+
"metadata": {
191+
"collapsed": false
192+
},
181193
"source": [
182194
"**Exercise:**\n",
183195
"\n",
@@ -188,10 +200,7 @@
188200
"- The number of target sets\n",
189201
"- The number of observations in each target set\n",
190202
"- The dimensionality of each target set\n"
191-
],
192-
"metadata": {
193-
"collapsed": false
194-
}
203+
]
195204
},
196205
{
197206
"cell_type": "markdown",
@@ -206,33 +215,40 @@
206215
},
207216
{
208217
"cell_type": "markdown",
218+
"metadata": {
219+
"collapsed": false
220+
},
209221
"source": [
210222
"### Gridded data in Tasks\n",
211223
"\n",
212224
"For convenience, data that lies on a regular grid is given a compact tuple representation for the `\"X\"` entries:"
213-
],
214-
"metadata": {
215-
"collapsed": false
216-
}
225+
]
217226
},
218227
{
219228
"cell_type": "code",
220229
"execution_count": 4,
221-
"outputs": [],
222-
"source": [
223-
"task_with_gridded_data = task_loader(\"2016-06-25\", context_sampling=[\"all\", \"all\"], target_sampling=245)"
224-
],
225230
"metadata": {
226-
"collapsed": false,
227231
"ExecuteTime": {
228232
"end_time": "2023-11-01T14:32:15.620494504Z",
229233
"start_time": "2023-11-01T14:32:15.570462444Z"
230-
}
231-
}
234+
},
235+
"collapsed": false
236+
},
237+
"outputs": [],
238+
"source": [
239+
"task_with_gridded_data = task_loader(\"2016-06-25\", context_sampling=[\"all\", \"all\"], target_sampling=245)"
240+
]
232241
},
233242
{
234243
"cell_type": "code",
235244
"execution_count": 5,
245+
"metadata": {
246+
"ExecuteTime": {
247+
"end_time": "2023-11-01T14:32:15.628949091Z",
248+
"start_time": "2023-11-01T14:32:15.611675646Z"
249+
},
250+
"collapsed": false
251+
},
236252
"outputs": [
237253
{
238254
"name": "stdout",
@@ -249,23 +265,16 @@
249265
],
250266
"source": [
251267
"print(task_with_gridded_data)"
252-
],
253-
"metadata": {
254-
"collapsed": false,
255-
"ExecuteTime": {
256-
"end_time": "2023-11-01T14:32:15.628949091Z",
257-
"start_time": "2023-11-01T14:32:15.611675646Z"
258-
}
259-
}
268+
]
260269
},
261270
{
262271
"cell_type": "markdown",
263-
"source": [
264-
"In the above example, the first context set lies on a 141 x 221 grid, and the second context set lies on a 140 x 220 grid."
265-
],
266272
"metadata": {
267273
"collapsed": false
268-
}
274+
},
275+
"source": [
276+
"In the above example, the first context set lies on a 141 x 221 grid, and the second context set lies on a 140 x 220 grid."
277+
]
269278
},
270279
{
271280
"cell_type": "markdown",
@@ -306,17 +315,24 @@
306315
},
307316
{
308317
"cell_type": "markdown",
318+
"metadata": {
319+
"collapsed": false
320+
},
309321
"source": [
310322
"Gridded data in a `Task` can be flattened using the `.flatten_gridded_data` method.\n",
311323
"Notice how the `\"X\"` entries are now 2D arrays of shape `(2, M)` rather than tuples of two 1D arrays of shape `(M,)`."
312-
],
313-
"metadata": {
314-
"collapsed": false
315-
}
324+
]
316325
},
317326
{
318327
"cell_type": "code",
319328
"execution_count": 7,
329+
"metadata": {
330+
"ExecuteTime": {
331+
"end_time": "2023-11-01T14:32:15.970618528Z",
332+
"start_time": "2023-11-01T14:32:15.909066194Z"
333+
},
334+
"collapsed": false
335+
},
320336
"outputs": [
321337
{
322338
"name": "stdout",
@@ -333,14 +349,7 @@
333349
],
334350
"source": [
335351
"print(task_with_gridded_data.flatten_gridded_data())"
336-
],
337-
"metadata": {
338-
"collapsed": false,
339-
"ExecuteTime": {
340-
"end_time": "2023-11-01T14:32:15.970618528Z",
341-
"start_time": "2023-11-01T14:32:15.909066194Z"
342-
}
343-
}
352+
]
344353
}
345354
],
346355
"metadata": {

0 commit comments

Comments
 (0)