Skip to content

Commit af8c216

Browse files
Update to notebook for new Format syntax.
1 parent 45110db commit af8c216

File tree

2 files changed

+67
-452
lines changed

2 files changed

+67
-452
lines changed

doc/bitformat_tour.ipynb

Lines changed: 67 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,16 @@
3434
"id": "8e03b8012da3337d",
3535
"metadata": {
3636
"ExecuteTime": {
37-
"end_time": "2024-09-17T17:24:18.215206Z",
38-
"start_time": "2024-09-17T17:24:06.989356Z"
37+
"end_time": "2024-11-02T11:51:02.033863Z",
38+
"start_time": "2024-11-02T11:50:54.849849Z"
3939
}
4040
},
4141
"source": [
4242
"!pip install -q git+https://github.com/scott-griffiths/bitformat\n",
4343
"from bitformat import Bits, Dtype, Array, Field, Format"
4444
],
45-
"outputs": [
46-
{
47-
"name": "stdout",
48-
"output_type": "stream",
49-
"text": [
50-
"\r\n",
51-
"\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip is available: \u001B[0m\u001B[31;49m23.2.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m24.2\u001B[0m\r\n",
52-
"\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n"
53-
]
54-
}
55-
],
56-
"execution_count": 42
45+
"outputs": [],
46+
"execution_count": 19
5747
},
5848
{
5949
"cell_type": "markdown",
@@ -92,8 +82,8 @@
9282
"id": "53c713fcc45e4e5a",
9383
"metadata": {
9484
"ExecuteTime": {
95-
"end_time": "2024-09-17T17:24:18.227607Z",
96-
"start_time": "2024-09-17T17:24:18.223296Z"
85+
"end_time": "2024-11-02T11:51:02.053650Z",
86+
"start_time": "2024-11-02T11:51:02.047066Z"
9787
}
9888
},
9989
"source": [
@@ -105,7 +95,7 @@
10595
"f = Bits('0b001, u32=90, 0x5e') # Three Bits objects concatenated together"
10696
],
10797
"outputs": [],
108-
"execution_count": 43
98+
"execution_count": 20
10999
},
110100
{
111101
"cell_type": "markdown",
@@ -120,8 +110,8 @@
120110
"id": "396522c67c8e64cf",
121111
"metadata": {
122112
"ExecuteTime": {
123-
"end_time": "2024-09-17T17:24:18.310652Z",
124-
"start_time": "2024-09-17T17:24:18.306640Z"
113+
"end_time": "2024-11-02T11:51:02.137466Z",
114+
"start_time": "2024-11-02T11:51:02.132874Z"
125115
}
126116
},
127117
"source": [
@@ -131,7 +121,7 @@
131121
"j = Bits.pack('f16', -13.81) # A 16-bit IEEE floating point number"
132122
],
133123
"outputs": [],
134-
"execution_count": 44
124+
"execution_count": 21
135125
},
136126
{
137127
"cell_type": "markdown",
@@ -150,8 +140,8 @@
150140
"id": "d3d60f076765ee43",
151141
"metadata": {
152142
"ExecuteTime": {
153-
"end_time": "2024-09-17T17:24:18.367620Z",
154-
"start_time": "2024-09-17T17:24:18.363383Z"
143+
"end_time": "2024-11-02T11:51:02.191967Z",
144+
"start_time": "2024-11-02T11:51:02.187871Z"
155145
}
156146
},
157147
"source": [
@@ -168,7 +158,7 @@
168158
]
169159
}
170160
],
171-
"execution_count": 45
161+
"execution_count": 22
172162
},
173163
{
174164
"cell_type": "markdown",
@@ -183,16 +173,16 @@
183173
"id": "5351ff48f143d54",
184174
"metadata": {
185175
"ExecuteTime": {
186-
"end_time": "2024-09-17T17:24:18.427715Z",
187-
"start_time": "2024-09-17T17:24:18.423992Z"
176+
"end_time": "2024-11-02T11:51:02.247179Z",
177+
"start_time": "2024-11-02T11:51:02.243844Z"
188178
}
189179
},
190180
"source": [
191181
"assert g.u == 65\n",
192182
"assert h.hex == 'abcde'"
193183
],
194184
"outputs": [],
195-
"execution_count": 46
185+
"execution_count": 23
196186
},
197187
{
198188
"cell_type": "markdown",
@@ -207,8 +197,8 @@
207197
"id": "5bbb6591db1061c6",
208198
"metadata": {
209199
"ExecuteTime": {
210-
"end_time": "2024-09-17T17:24:18.492369Z",
211-
"start_time": "2024-09-17T17:24:18.488226Z"
200+
"end_time": "2024-11-02T11:51:02.307120Z",
201+
"start_time": "2024-11-02T11:51:02.303324Z"
212202
}
213203
},
214204
"source": [
@@ -231,7 +221,7 @@
231221
]
232222
}
233223
],
234-
"execution_count": 47
224+
"execution_count": 24
235225
},
236226
{
237227
"cell_type": "markdown",
@@ -265,13 +255,13 @@
265255
"id": "18c65a86-b4c1-47a8-8cde-ff7b8f4e4345",
266256
"metadata": {
267257
"ExecuteTime": {
268-
"end_time": "2024-09-17T17:24:18.547130Z",
269-
"start_time": "2024-09-17T17:24:18.543580Z"
258+
"end_time": "2024-11-02T11:51:02.363632Z",
259+
"start_time": "2024-11-02T11:51:02.360543Z"
270260
}
271261
},
272262
"source": [
273263
"f_str = \"\"\"\n",
274-
"sequence_header: [\n",
264+
"sequence_header = (\n",
275265
" sequence_header_code: const hex8 = 0x000001b3,\n",
276266
" horizontal_size_value: u12,\n",
277267
" vertical_size_value: u12,\n",
@@ -282,12 +272,12 @@
282272
" vbv_buffer_size_value: u10,\n",
283273
" constrained_parameters_flag: bool,\n",
284274
" load_intra_quantiser_matrix: u1\n",
285-
"]\n",
275+
")\n",
286276
"\"\"\"\n",
287277
"f = Format(f_str) "
288278
],
289279
"outputs": [],
290-
"execution_count": 48
280+
"execution_count": 25
291281
},
292282
{
293283
"cell_type": "markdown",
@@ -305,8 +295,8 @@
305295
"metadata": {
306296
"scrolled": true,
307297
"ExecuteTime": {
308-
"end_time": "2024-09-17T17:24:18.610760Z",
309-
"start_time": "2024-09-17T17:24:18.605490Z"
298+
"end_time": "2024-11-02T11:51:02.429022Z",
299+
"start_time": "2024-11-02T11:51:02.420085Z"
310300
}
311301
},
312302
"source": [
@@ -318,22 +308,22 @@
318308
"name": "stdout",
319309
"output_type": "stream",
320310
"text": [
321-
"\u001B[32msequence_header\u001B[0m: [\n",
322-
" \u001B[32msequence_header_code\u001B[0m: \u001B[35mconst hex8\u001B[0m = \u001B[36m000001b3\u001B[0m,\n",
323-
" \u001B[32mhorizontal_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m352\u001B[0m,\n",
324-
" \u001B[32mvertical_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m288\u001B[0m,\n",
325-
" \u001B[32maspect_ratio_information\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m0\u001B[0m,\n",
326-
" \u001B[32mframe_rate_code\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m1\u001B[0m,\n",
327-
" \u001B[32mbit_rate_value\u001B[0m: \u001B[35mu18\u001B[0m = \u001B[36m104000\u001B[0m,\n",
328-
" \u001B[32mmarker_bit\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mTrue\u001B[0m,\n",
329-
" \u001B[32mvbv_buffer_size_value\u001B[0m: \u001B[35mu10\u001B[0m = \u001B[36m880\u001B[0m,\n",
330-
" \u001B[32mconstrained_parameters_flag\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mFalse\u001B[0m,\n",
311+
"\u001B[32msequence_header\u001B[0m = (\n",
312+
" \u001B[32msequence_header_code\u001B[0m: \u001B[35mconst hex8\u001B[0m = \u001B[36m000001b3\u001B[0m\n",
313+
" \u001B[32mhorizontal_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m352\u001B[0m\n",
314+
" \u001B[32mvertical_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m288\u001B[0m\n",
315+
" \u001B[32maspect_ratio_information\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m0\u001B[0m\n",
316+
" \u001B[32mframe_rate_code\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m1\u001B[0m\n",
317+
" \u001B[32mbit_rate_value\u001B[0m: \u001B[35mu18\u001B[0m = \u001B[36m104000\u001B[0m\n",
318+
" \u001B[32mmarker_bit\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mTrue\u001B[0m\n",
319+
" \u001B[32mvbv_buffer_size_value\u001B[0m: \u001B[35mu10\u001B[0m = \u001B[36m880\u001B[0m\n",
320+
" \u001B[32mconstrained_parameters_flag\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mFalse\u001B[0m\n",
331321
" \u001B[32mload_intra_quantiser_matrix\u001B[0m: \u001B[35mu1\u001B[0m = \u001B[36m1\u001B[0m\n",
332-
"]\n"
322+
")\n"
333323
]
334324
}
335325
],
336-
"execution_count": 49
326+
"execution_count": 26
337327
},
338328
{
339329
"cell_type": "markdown",
@@ -348,8 +338,8 @@
348338
"id": "66e47d06-b52f-4d47-a6ff-06932443663f",
349339
"metadata": {
350340
"ExecuteTime": {
351-
"end_time": "2024-09-17T17:24:18.673749Z",
352-
"start_time": "2024-09-17T17:24:18.666730Z"
341+
"end_time": "2024-11-02T11:51:02.516644Z",
342+
"start_time": "2024-11-02T11:51:02.512263Z"
353343
}
354344
},
355345
"source": [
@@ -367,7 +357,7 @@
367357
]
368358
}
369359
],
370-
"execution_count": 50
360+
"execution_count": 27
371361
},
372362
{
373363
"cell_type": "markdown",
@@ -383,8 +373,8 @@
383373
"id": "a5d48d44-b53f-442b-8ebc-b8336fd8e323",
384374
"metadata": {
385375
"ExecuteTime": {
386-
"end_time": "2024-09-17T17:24:18.736429Z",
387-
"start_time": "2024-09-17T17:24:18.731133Z"
376+
"end_time": "2024-11-02T11:51:02.587897Z",
377+
"start_time": "2024-11-02T11:51:02.584278Z"
388378
}
389379
},
390380
"source": [
@@ -397,22 +387,22 @@
397387
"name": "stdout",
398388
"output_type": "stream",
399389
"text": [
400-
"\u001B[32msequence_header\u001B[0m: [\n",
401-
" \u001B[32msequence_header_code\u001B[0m: \u001B[35mconst hex8\u001B[0m = \u001B[36m000001b3\u001B[0m,\n",
402-
" \u001B[32mhorizontal_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m352\u001B[0m,\n",
403-
" \u001B[32mvertical_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m288\u001B[0m,\n",
404-
" \u001B[32maspect_ratio_information\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m0\u001B[0m,\n",
405-
" \u001B[32mframe_rate_code\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m1\u001B[0m,\n",
406-
" \u001B[32mbit_rate_value\u001B[0m: \u001B[35mu18\u001B[0m = \u001B[36m26000\u001B[0m,\n",
407-
" \u001B[32mmarker_bit\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mTrue\u001B[0m,\n",
408-
" \u001B[32mvbv_buffer_size_value\u001B[0m: \u001B[35mu10\u001B[0m = \u001B[36m880\u001B[0m,\n",
409-
" \u001B[32mconstrained_parameters_flag\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mFalse\u001B[0m,\n",
390+
"\u001B[32msequence_header\u001B[0m = (\n",
391+
" \u001B[32msequence_header_code\u001B[0m: \u001B[35mconst hex8\u001B[0m = \u001B[36m000001b3\u001B[0m\n",
392+
" \u001B[32mhorizontal_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m352\u001B[0m\n",
393+
" \u001B[32mvertical_size_value\u001B[0m: \u001B[35mu12\u001B[0m = \u001B[36m288\u001B[0m\n",
394+
" \u001B[32maspect_ratio_information\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m0\u001B[0m\n",
395+
" \u001B[32mframe_rate_code\u001B[0m: \u001B[35mu4\u001B[0m = \u001B[36m1\u001B[0m\n",
396+
" \u001B[32mbit_rate_value\u001B[0m: \u001B[35mu18\u001B[0m = \u001B[36m26000\u001B[0m\n",
397+
" \u001B[32mmarker_bit\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mTrue\u001B[0m\n",
398+
" \u001B[32mvbv_buffer_size_value\u001B[0m: \u001B[35mu10\u001B[0m = \u001B[36m880\u001B[0m\n",
399+
" \u001B[32mconstrained_parameters_flag\u001B[0m: \u001B[35mbool\u001B[0m = \u001B[36mFalse\u001B[0m\n",
410400
" \u001B[32mload_intra_quantiser_matrix\u001B[0m: \u001B[35mu1\u001B[0m = \u001B[36m1\u001B[0m\n",
411-
"]\n"
401+
")\n"
412402
]
413403
}
414404
],
415-
"execution_count": 51
405+
"execution_count": 28
416406
},
417407
{
418408
"cell_type": "markdown",
@@ -433,8 +423,8 @@
433423
"id": "747a972f-0271-4b17-bc56-22068bfb3054",
434424
"metadata": {
435425
"ExecuteTime": {
436-
"end_time": "2024-09-17T17:24:18.804561Z",
437-
"start_time": "2024-09-17T17:24:18.797601Z"
426+
"end_time": "2024-11-02T11:51:02.655856Z",
427+
"start_time": "2024-11-02T11:51:02.650103Z"
438428
}
439429
},
440430
"source": [
@@ -450,12 +440,12 @@
450440
"2"
451441
]
452442
},
453-
"execution_count": 52,
443+
"execution_count": 29,
454444
"metadata": {},
455445
"output_type": "execute_result"
456446
}
457447
],
458-
"execution_count": 52
448+
"execution_count": 29
459449
},
460450
{
461451
"cell_type": "markdown",
@@ -483,8 +473,8 @@
483473
"id": "b36a7c6e-b19d-418c-b08f-138c512c2fb8",
484474
"metadata": {
485475
"ExecuteTime": {
486-
"end_time": "2024-09-17T17:24:21.423465Z",
487-
"start_time": "2024-09-17T17:24:18.869214Z"
476+
"end_time": "2024-11-02T11:51:10.662557Z",
477+
"start_time": "2024-11-02T11:51:02.782292Z"
488478
}
489479
},
490480
"source": [
@@ -515,7 +505,7 @@
515505
]
516506
}
517507
],
518-
"execution_count": 53
508+
"execution_count": 30
519509
},
520510
{
521511
"cell_type": "markdown",
@@ -532,20 +522,20 @@
532522
"id": "fe303d2f-9828-47e5-ab23-c22ac088e207",
533523
"metadata": {
534524
"ExecuteTime": {
535-
"end_time": "2024-09-17T17:24:21.503012Z",
536-
"start_time": "2024-09-17T17:24:21.493958Z"
525+
"end_time": "2024-11-02T11:51:10.674308Z",
526+
"start_time": "2024-11-02T11:51:10.669487Z"
537527
}
538528
},
539529
"source": [
540530
"import sys\n",
541-
"is_prime[0:1000].pp(width=80)"
531+
"is_prime[0:1000].pp()"
542532
],
543533
"outputs": [
544534
{
545535
"name": "stdout",
546536
"output_type": "stream",
547537
"text": [
548-
"<Bits, fmt='\u001B[35mbin\u001B[0m, \u001B[34mhex\u001B[0m', length=\u001B[32m1000\u001B[0m bits> [\n",
538+
"<Bits, dtype1='\u001B[35mbin\u001B[0m', dtype2='\u001B[34mhex\u001B[0m', length=\u001B[32m1000\u001B[0m bits> [\n",
549539
"\u001B[32m 0: \u001B[0m\u001B[35m00110101 00010100 01010001 00000101 00000100 01010001\u001B[0m : \u001B[34m35 14 51 05 04 51\u001B[0m\n",
550540
"\u001B[32m 48: \u001B[0m\u001B[35m00000100 00010100 00010001 01000001 00010000 01000000\u001B[0m : \u001B[34m04 14 11 41 10 40\u001B[0m\n",
551541
"\u001B[32m 96: \u001B[0m\u001B[35m01000101 00010100 01000000 00000001 00010000 01010000\u001B[0m : \u001B[34m45 14 40 01 10 50\u001B[0m\n",
@@ -571,7 +561,7 @@
571561
]
572562
}
573563
],
574-
"execution_count": 54
564+
"execution_count": 31
575565
},
576566
{
577567
"cell_type": "markdown",

0 commit comments

Comments
 (0)