Skip to content

Commit 01ab873

Browse files
committed
More improvements to expression basics tutorial
1 parent 395da8e commit 01ab873

File tree

1 file changed

+55
-59
lines changed

1 file changed

+55
-59
lines changed

doc/getting_started/tutorials/02.lazyarray-expressions.ipynb

Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Expressions containing NDArray objects (and others)\n",
7+
"# Expressions containing NDArray objects\n",
88
"\n",
99
"Python-Blosc2 implements a powerful way to operate with NDArray (and other flavors) objects. In this section, we will see how to do computations with NDArray arrays in a simple way.\n"
1010
]
@@ -14,8 +14,8 @@
1414
"execution_count": 1,
1515
"metadata": {
1616
"ExecuteTime": {
17-
"end_time": "2024-11-30T11:48:12.189587Z",
18-
"start_time": "2024-11-30T11:48:11.952641Z"
17+
"end_time": "2024-11-30T11:59:11.569049Z",
18+
"start_time": "2024-11-30T11:59:11.338703Z"
1919
}
2020
},
2121
"outputs": [],
@@ -30,16 +30,16 @@
3030
"metadata": {},
3131
"source": [
3232
"## A simple example\n",
33-
"First, let's create a couple of NDArrays. We will use NumPy arrays to fill them."
33+
"First, let's create a couple of NDArrays."
3434
]
3535
},
3636
{
3737
"cell_type": "code",
3838
"execution_count": 2,
3939
"metadata": {
4040
"ExecuteTime": {
41-
"end_time": "2024-11-30T11:48:12.395804Z",
42-
"start_time": "2024-11-30T11:48:12.306016Z"
41+
"end_time": "2024-11-30T11:59:11.661667Z",
42+
"start_time": "2024-11-30T11:59:11.572125Z"
4343
}
4444
},
4545
"outputs": [],
@@ -52,17 +52,15 @@
5252
{
5353
"cell_type": "markdown",
5454
"metadata": {},
55-
"source": [
56-
"Now, let's create an expression that involves `a` and `b`"
57-
]
55+
"source": "Now, let's create an expression that involves `a` and `b`."
5856
},
5957
{
6058
"cell_type": "code",
6159
"execution_count": 3,
6260
"metadata": {
6361
"ExecuteTime": {
64-
"end_time": "2024-11-30T11:48:12.401911Z",
65-
"start_time": "2024-11-30T11:48:12.399543Z"
62+
"end_time": "2024-11-30T11:59:11.772071Z",
63+
"start_time": "2024-11-30T11:59:11.769736Z"
6664
}
6765
},
6866
"outputs": [
@@ -100,8 +98,8 @@
10098
"execution_count": 4,
10199
"metadata": {
102100
"ExecuteTime": {
103-
"end_time": "2024-11-30T11:48:12.423922Z",
104-
"start_time": "2024-11-30T11:48:12.412047Z"
101+
"end_time": "2024-11-30T11:59:11.791376Z",
102+
"start_time": "2024-11-30T11:59:11.778962Z"
105103
}
106104
},
107105
"outputs": [
@@ -130,8 +128,8 @@
130128
"execution_count": 5,
131129
"metadata": {
132130
"ExecuteTime": {
133-
"end_time": "2024-11-30T11:48:12.461794Z",
134-
"start_time": "2024-11-30T11:48:12.428595Z"
131+
"end_time": "2024-11-30T11:59:11.826878Z",
132+
"start_time": "2024-11-30T11:59:11.797784Z"
135133
}
136134
},
137135
"outputs": [
@@ -159,8 +157,8 @@
159157
"execution_count": 6,
160158
"metadata": {
161159
"ExecuteTime": {
162-
"end_time": "2024-11-30T11:48:12.828117Z",
163-
"start_time": "2024-11-30T11:48:12.468481Z"
160+
"end_time": "2024-11-30T11:59:12.185170Z",
161+
"start_time": "2024-11-30T11:59:11.831829Z"
164162
}
165163
},
166164
"outputs": [
@@ -169,7 +167,7 @@
169167
"output_type": "stream",
170168
"text": [
171169
"Detected ARM ...\r\n",
172-
"-rw-r--r--@ 1 francesc staff 2.0M Nov 30 12:48 result.b2nd\r\n"
170+
"-rw-r--r--@ 1 francesc staff 2.0M Nov 30 12:59 result.b2nd\r\n"
173171
]
174172
}
175173
],
@@ -195,8 +193,8 @@
195193
"execution_count": 7,
196194
"metadata": {
197195
"ExecuteTime": {
198-
"end_time": "2024-11-30T11:48:12.840670Z",
199-
"start_time": "2024-11-30T11:48:12.835617Z"
196+
"end_time": "2024-11-30T11:59:12.198022Z",
197+
"start_time": "2024-11-30T11:59:12.193106Z"
200198
}
201199
},
202200
"outputs": [
@@ -239,8 +237,8 @@
239237
"execution_count": 8,
240238
"metadata": {
241239
"ExecuteTime": {
242-
"end_time": "2024-11-30T11:48:12.858983Z",
243-
"start_time": "2024-11-30T11:48:12.849134Z"
240+
"end_time": "2024-11-30T11:59:12.215155Z",
241+
"start_time": "2024-11-30T11:59:12.206100Z"
244242
}
245243
},
246244
"outputs": [],
@@ -261,8 +259,8 @@
261259
"execution_count": 9,
262260
"metadata": {
263261
"ExecuteTime": {
264-
"end_time": "2024-11-30T11:48:12.868774Z",
265-
"start_time": "2024-11-30T11:48:12.865496Z"
262+
"end_time": "2024-11-30T11:59:12.231923Z",
263+
"start_time": "2024-11-30T11:59:12.227980Z"
266264
}
267265
},
268266
"outputs": [
@@ -296,8 +294,8 @@
296294
"execution_count": 10,
297295
"metadata": {
298296
"ExecuteTime": {
299-
"end_time": "2024-11-30T11:48:12.897559Z",
300-
"start_time": "2024-11-30T11:48:12.882768Z"
297+
"end_time": "2024-11-30T11:59:12.267991Z",
298+
"start_time": "2024-11-30T11:59:12.251241Z"
301299
}
302300
},
303301
"outputs": [
@@ -328,8 +326,8 @@
328326
"execution_count": 11,
329327
"metadata": {
330328
"ExecuteTime": {
331-
"end_time": "2024-11-30T11:48:12.920154Z",
332-
"start_time": "2024-11-30T11:48:12.903102Z"
329+
"end_time": "2024-11-30T11:59:12.288117Z",
330+
"start_time": "2024-11-30T11:59:12.274284Z"
333331
}
334332
},
335333
"outputs": [
@@ -364,8 +362,8 @@
364362
"execution_count": 12,
365363
"metadata": {
366364
"ExecuteTime": {
367-
"end_time": "2024-11-30T11:48:12.937937Z",
368-
"start_time": "2024-11-30T11:48:12.927201Z"
365+
"end_time": "2024-11-30T11:59:12.306896Z",
366+
"start_time": "2024-11-30T11:59:12.296261Z"
369367
}
370368
},
371369
"outputs": [
@@ -404,8 +402,8 @@
404402
"execution_count": 13,
405403
"metadata": {
406404
"ExecuteTime": {
407-
"end_time": "2024-11-30T11:48:12.961918Z",
408-
"start_time": "2024-11-30T11:48:12.944721Z"
405+
"end_time": "2024-11-30T11:59:12.329122Z",
406+
"start_time": "2024-11-30T11:59:12.311904Z"
409407
}
410408
},
411409
"outputs": [
@@ -453,8 +451,8 @@
453451
"execution_count": 14,
454452
"metadata": {
455453
"ExecuteTime": {
456-
"end_time": "2024-11-30T11:48:12.969686Z",
457-
"start_time": "2024-11-30T11:48:12.967688Z"
454+
"end_time": "2024-11-30T11:59:12.336815Z",
455+
"start_time": "2024-11-30T11:59:12.334800Z"
458456
}
459457
},
460458
"outputs": [
@@ -481,8 +479,8 @@
481479
"execution_count": 15,
482480
"metadata": {
483481
"ExecuteTime": {
484-
"end_time": "2024-11-30T11:48:12.997265Z",
485-
"start_time": "2024-11-30T11:48:12.985699Z"
482+
"end_time": "2024-11-30T11:59:12.373343Z",
483+
"start_time": "2024-11-30T11:59:12.360688Z"
486484
}
487485
},
488486
"outputs": [
@@ -509,18 +507,18 @@
509507
"cell_type": "markdown",
510508
"metadata": {},
511509
"source": [
512-
"## Selections\n",
510+
"## Querying NDArray arrays\n",
513511
"\n",
514-
"We can also perform selections on NDArray arrays with structured types. Let's see an example. First, we will create a structured array:"
512+
"A powerful feature of Blosc2 compute engine is its ability to do queries on NDArray arrays with structured types. Let's see an example."
515513
]
516514
},
517515
{
518516
"cell_type": "code",
519517
"execution_count": 16,
520518
"metadata": {
521519
"ExecuteTime": {
522-
"end_time": "2024-11-30T11:48:13.503854Z",
523-
"start_time": "2024-11-30T11:48:13.002220Z"
520+
"end_time": "2024-11-30T11:59:12.875545Z",
521+
"start_time": "2024-11-30T11:59:12.379506Z"
524522
}
525523
},
526524
"outputs": [
@@ -555,8 +553,8 @@
555553
"execution_count": 17,
556554
"metadata": {
557555
"ExecuteTime": {
558-
"end_time": "2024-11-30T11:48:13.536079Z",
559-
"start_time": "2024-11-30T11:48:13.509269Z"
556+
"end_time": "2024-11-30T11:59:12.905085Z",
557+
"start_time": "2024-11-30T11:59:12.881552Z"
560558
}
561559
},
562560
"outputs": [
@@ -590,8 +588,8 @@
590588
"execution_count": 18,
591589
"metadata": {
592590
"ExecuteTime": {
593-
"end_time": "2024-11-30T11:48:13.564174Z",
594-
"start_time": "2024-11-30T11:48:13.542368Z"
591+
"end_time": "2024-11-30T11:59:12.935985Z",
592+
"start_time": "2024-11-30T11:59:12.910429Z"
595593
}
596594
},
597595
"outputs": [
@@ -624,8 +622,8 @@
624622
"execution_count": 19,
625623
"metadata": {
626624
"ExecuteTime": {
627-
"end_time": "2024-11-30T11:48:13.590671Z",
628-
"start_time": "2024-11-30T11:48:13.569331Z"
625+
"end_time": "2024-11-30T11:59:12.964089Z",
626+
"start_time": "2024-11-30T11:59:12.941286Z"
629627
}
630628
},
631629
"outputs": [
@@ -649,17 +647,15 @@
649647
{
650648
"cell_type": "markdown",
651649
"metadata": {},
652-
"source": [
653-
"We can also do selections and extract a single field:"
654-
]
650+
"source": "We can also query and extract a single field:"
655651
},
656652
{
657653
"cell_type": "code",
658654
"execution_count": 20,
659655
"metadata": {
660656
"ExecuteTime": {
661-
"end_time": "2024-11-30T11:48:13.613433Z",
662-
"start_time": "2024-11-30T11:48:13.595773Z"
657+
"end_time": "2024-11-30T11:59:12.985929Z",
658+
"start_time": "2024-11-30T11:59:12.969471Z"
663659
}
664660
},
665661
"outputs": [
@@ -681,15 +677,15 @@
681677
{
682678
"cell_type": "markdown",
683679
"metadata": {},
684-
"source": "We can also perform reductions on selections on a single field:"
680+
"source": "We can also perform reductions on queries on a single field:"
685681
},
686682
{
687683
"cell_type": "code",
688684
"execution_count": 21,
689685
"metadata": {
690686
"ExecuteTime": {
691-
"end_time": "2024-11-30T11:48:13.633578Z",
692-
"start_time": "2024-11-30T11:48:13.618291Z"
687+
"end_time": "2024-11-30T11:59:13.023912Z",
688+
"start_time": "2024-11-30T11:59:13.004519Z"
693689
}
694690
},
695691
"outputs": [
@@ -711,15 +707,15 @@
711707
{
712708
"cell_type": "markdown",
713709
"metadata": {},
714-
"source": "Finally, we can perform more complex selections using the `where()` function. For example, let's sum all the rows with the maximum of field `A` or field `B`:"
710+
"source": "Finally, we can perform more complex queries using the `where()` function. For example, let's sum all the rows with the maximum of field `A` or field `B`:"
715711
},
716712
{
717713
"cell_type": "code",
718714
"execution_count": 22,
719715
"metadata": {
720716
"ExecuteTime": {
721-
"end_time": "2024-11-30T11:48:13.721522Z",
722-
"start_time": "2024-11-30T11:48:13.703644Z"
717+
"end_time": "2024-11-30T11:59:13.046205Z",
718+
"start_time": "2024-11-30T11:59:13.030709Z"
723719
}
724720
},
725721
"outputs": [
@@ -741,15 +737,15 @@
741737
{
742738
"cell_type": "markdown",
743739
"metadata": {},
744-
"source": "Combining all the different weaponry of selections can make querying your data very effective. As the computation is lazy, all the operations are grouped and executed together for maximum performance. The only exception is that, when a reduction is found, it is computed eagerly, but it still can be part of more general expressions, as well as being able to be saved and loaded from disk."
740+
"source": "Combining all this weaponry allows to query your data on a simple and efficient way. As the computation is lazy, all the operations are grouped and executed together for maximum performance. The only exception is that, when a reduction is found, it is computed eagerly, but it still can be part of more general expressions, as well as being able to be saved and loaded from disk."
745741
},
746742
{
747743
"cell_type": "markdown",
748744
"metadata": {},
749745
"source": [
750746
"## Summary\n",
751747
"\n",
752-
"In this section, we have seen how to perform computations with NDArray arrays, and more in particular, how to create expressions, compute them, and save them to disk. Also, we have looked at performing reductions, selections and combinations of both. Finally, we have seen how expressions containing operators having different (but compatible) shapes can be computed too. Lazy expressions are a very powerful feature that allows you to build and compute complex computations from operands that can be in-memory, on-disk or in remote boxes (`C2Array`) in a simple way, and very effectively."
748+
"In this section, we have seen how to perform computations with NDArray arrays, and more in particular, how to create expressions, compute them, and save them to disk. Also, we have looked at performing reductions, broadcasting, selections and combinations of both. Lazy expressions allow you to build and compute complex computations from operands that can be in-memory, on-disk or remote (`C2Array`) in a simple and effective way."
753749
]
754750
}
755751
],

0 commit comments

Comments
 (0)