Skip to content

Commit 51762de

Browse files
Make all nbval notebook Python3 notebooks
Toward 2020!
1 parent fdafc5f commit 51762de

File tree

4 files changed

+100
-54
lines changed

4 files changed

+100
-54
lines changed

pythran/tests/notebooks/capsule.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,21 @@
209209
],
210210
"metadata": {
211211
"kernelspec": {
212-
"display_name": "Python 2",
212+
"display_name": "Python 3",
213213
"language": "python",
214-
"name": "python2"
214+
"name": "python3"
215215
},
216216
"language_info": {
217217
"codemirror_mode": {
218218
"name": "ipython",
219-
"version": 2
219+
"version": 3
220220
},
221221
"file_extension": ".py",
222222
"mimetype": "text/x-python",
223223
"name": "python",
224224
"nbconvert_exporter": "python",
225-
"pygments_lexer": "ipython2",
226-
"version": "2.7.14+"
225+
"pygments_lexer": "ipython3",
226+
"version": "3.6.3"
227227
}
228228
},
229229
"nbformat": 4,

pythran/tests/notebooks/export.ipynb

Lines changed: 80 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,60 @@
358358
"cell_type": "markdown",
359359
"metadata": {},
360360
"source": [
361-
"It also works correctly for ndarray of different dimension and dtype:"
361+
"It works fine for scalars of differents size / sign"
362362
]
363363
},
364364
{
365365
"cell_type": "code",
366366
"execution_count": 19,
367367
"metadata": {},
368368
"outputs": [],
369+
"source": [
370+
"%%pythran\n",
371+
"#pythran export dtype(complex64)\n",
372+
"#pythran export dtype(complex128)\n",
373+
"#pythran export dtype(complex256)\n",
374+
"import numpy as np\n",
375+
"def dtype(x): return x.real, x.imag"
376+
]
377+
},
378+
{
379+
"cell_type": "code",
380+
"execution_count": 20,
381+
"metadata": {},
382+
"outputs": [
383+
{
384+
"name": "stdout",
385+
"output_type": "stream",
386+
"text": [
387+
"(1.5, -1.5) <class 'numpy.float32'>\n",
388+
"(1.5, -1.5) <class 'float'>\n",
389+
"(1.5, -1.5) <class 'numpy.float128'>\n"
390+
]
391+
}
392+
],
393+
"source": [
394+
"import numpy as np\n",
395+
"x64 = dtype(np.complex64(1.5 + -1.5j))\n",
396+
"print(x64, type(x64[0]))\n",
397+
"x128 = dtype(np.complex128(1.5 + -1.5j))\n",
398+
"print(x128, type(x128[0]))\n",
399+
"x256 = dtype(np.complex256(1.5 + -1.5j))\n",
400+
"print(x256, type(x256[0]))"
401+
]
402+
},
403+
{
404+
"cell_type": "markdown",
405+
"metadata": {},
406+
"source": [
407+
"It also works correctly for ndarray of different dimension and dtype:"
408+
]
409+
},
410+
{
411+
"cell_type": "code",
412+
"execution_count": 21,
413+
"metadata": {},
414+
"outputs": [],
369415
"source": [
370416
"%%pythran\n",
371417
"#pythran export array(int8[])\n",
@@ -377,7 +423,7 @@
377423
},
378424
{
379425
"cell_type": "code",
380-
"execution_count": 20,
426+
"execution_count": 22,
381427
"metadata": {},
382428
"outputs": [
383429
{
@@ -401,28 +447,28 @@
401447
"cell_type": "markdown",
402448
"metadata": {},
403449
"source": [
404-
"It is however ambiguous to use numpy's dtype of different size/sign as scalar across overloads"
450+
"It is however ambiguous to use numpy's dtype that actually have the same sign and size (in that case on a 64bit machine)"
405451
]
406452
},
407453
{
408454
"cell_type": "code",
409-
"execution_count": 21,
455+
"execution_count": 23,
410456
"metadata": {},
411457
"outputs": [
412458
{
413459
"name": "stdout",
414460
"output_type": "stream",
415461
"text": [
416462
"Ambiguous overloads\n",
417-
"\tambiguous(float64)\n",
418-
"\tambiguous(float32).\n"
463+
"\tambiguous(int64)\n",
464+
"\tambiguous(int).\n"
419465
]
420466
}
421467
],
422468
"source": [
423469
"code = '''\n",
424-
"#pythran export ambiguous(float32)\n",
425-
"#pythran export ambiguous(float64)\n",
470+
"#pythran export ambiguous(int)\n",
471+
"#pythran export ambiguous(int64)\n",
426472
"def ambiguous(x): return x\n",
427473
"'''\n",
428474
"try:\n",
@@ -440,7 +486,7 @@
440486
},
441487
{
442488
"cell_type": "code",
443-
"execution_count": 22,
489+
"execution_count": 24,
444490
"metadata": {},
445491
"outputs": [],
446492
"source": [
@@ -452,7 +498,7 @@
452498
},
453499
{
454500
"cell_type": "code",
455-
"execution_count": 23,
501+
"execution_count": 25,
456502
"metadata": {},
457503
"outputs": [
458504
{
@@ -484,7 +530,7 @@
484530
},
485531
{
486532
"cell_type": "code",
487-
"execution_count": 24,
533+
"execution_count": 26,
488534
"metadata": {},
489535
"outputs": [],
490536
"source": [
@@ -495,7 +541,7 @@
495541
},
496542
{
497543
"cell_type": "code",
498-
"execution_count": 25,
544+
"execution_count": 27,
499545
"metadata": {},
500546
"outputs": [
501547
{
@@ -504,7 +550,7 @@
504550
"(1, '1')"
505551
]
506552
},
507-
"execution_count": 25,
553+
"execution_count": 27,
508554
"metadata": {},
509555
"output_type": "execute_result"
510556
}
@@ -522,7 +568,7 @@
522568
},
523569
{
524570
"cell_type": "code",
525-
"execution_count": 26,
571+
"execution_count": 28,
526572
"metadata": {},
527573
"outputs": [],
528574
"source": [
@@ -533,7 +579,7 @@
533579
},
534580
{
535581
"cell_type": "code",
536-
"execution_count": 27,
582+
"execution_count": 29,
537583
"metadata": {},
538584
"outputs": [
539585
{
@@ -542,7 +588,7 @@
542588
"'stuff that matter'"
543589
]
544590
},
545-
"execution_count": 27,
591+
"execution_count": 29,
546592
"metadata": {},
547593
"output_type": "execute_result"
548594
}
@@ -560,7 +606,7 @@
560606
},
561607
{
562608
"cell_type": "code",
563-
"execution_count": 28,
609+
"execution_count": 30,
564610
"metadata": {},
565611
"outputs": [],
566612
"source": [
@@ -572,7 +618,7 @@
572618
},
573619
{
574620
"cell_type": "code",
575-
"execution_count": 29,
621+
"execution_count": 31,
576622
"metadata": {},
577623
"outputs": [
578624
{
@@ -581,7 +627,7 @@
581627
"'<capsule object \"corp(int, float)\" at 0x...'"
582628
]
583629
},
584-
"execution_count": 29,
630+
"execution_count": 31,
585631
"metadata": {},
586632
"output_type": "execute_result"
587633
}
@@ -599,7 +645,7 @@
599645
},
600646
{
601647
"cell_type": "code",
602-
"execution_count": 30,
648+
"execution_count": 32,
603649
"metadata": {},
604650
"outputs": [],
605651
"source": [
@@ -618,7 +664,7 @@
618664
},
619665
{
620666
"cell_type": "code",
621-
"execution_count": 31,
667+
"execution_count": 33,
622668
"metadata": {},
623669
"outputs": [],
624670
"source": [
@@ -633,7 +679,7 @@
633679
},
634680
{
635681
"cell_type": "code",
636-
"execution_count": 32,
682+
"execution_count": 34,
637683
"metadata": {},
638684
"outputs": [
639685
{
@@ -642,7 +688,7 @@
642688
"4"
643689
]
644690
},
645-
"execution_count": 32,
691+
"execution_count": 34,
646692
"metadata": {},
647693
"output_type": "execute_result"
648694
}
@@ -660,7 +706,7 @@
660706
},
661707
{
662708
"cell_type": "code",
663-
"execution_count": 33,
709+
"execution_count": 35,
664710
"metadata": {},
665711
"outputs": [
666712
{
@@ -691,7 +737,7 @@
691737
},
692738
{
693739
"cell_type": "code",
694-
"execution_count": 34,
740+
"execution_count": 36,
695741
"metadata": {},
696742
"outputs": [],
697743
"source": [
@@ -702,7 +748,7 @@
702748
},
703749
{
704750
"cell_type": "code",
705-
"execution_count": 35,
751+
"execution_count": 37,
706752
"metadata": {},
707753
"outputs": [
708754
{
@@ -735,7 +781,7 @@
735781
},
736782
{
737783
"cell_type": "code",
738-
"execution_count": 36,
784+
"execution_count": 38,
739785
"metadata": {},
740786
"outputs": [],
741787
"source": [
@@ -747,7 +793,7 @@
747793
},
748794
{
749795
"cell_type": "code",
750-
"execution_count": 37,
796+
"execution_count": 39,
751797
"metadata": {},
752798
"outputs": [
753799
{
@@ -756,7 +802,7 @@
756802
"((5, 1), (1, 5))"
757803
]
758804
},
759-
"execution_count": 37,
805+
"execution_count": 39,
760806
"metadata": {},
761807
"output_type": "execute_result"
762808
}
@@ -770,21 +816,21 @@
770816
],
771817
"metadata": {
772818
"kernelspec": {
773-
"display_name": "Python 2",
819+
"display_name": "Python 3",
774820
"language": "python",
775-
"name": "python2"
821+
"name": "python3"
776822
},
777823
"language_info": {
778824
"codemirror_mode": {
779825
"name": "ipython",
780-
"version": 2
826+
"version": 3
781827
},
782828
"file_extension": ".py",
783829
"mimetype": "text/x-python",
784830
"name": "python",
785831
"nbconvert_exporter": "python",
786-
"pygments_lexer": "ipython2",
787-
"version": "2.7.14+"
832+
"pygments_lexer": "ipython3",
833+
"version": "3.6.3"
788834
}
789835
},
790836
"nbformat": 4,

0 commit comments

Comments
 (0)