File tree Expand file tree Collapse file tree 1 file changed +139
-0
lines changed Expand file tree Collapse file tree 1 file changed +139
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "cells" : [
3
+ {
4
+ "cell_type" : " code" ,
5
+ "execution_count" : null ,
6
+ "metadata" : {},
7
+ "outputs" : [],
8
+ "source" : [
9
+ " # NBVAL_IGNORE_OUTPUT\n " ,
10
+ " import numpy as np\n " ,
11
+ " from juliacall import Main as jl"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type" : " code" ,
16
+ "execution_count" : 2 ,
17
+ "metadata" : {},
18
+ "outputs" : [
19
+ {
20
+ "name" : " stdout" ,
21
+ "output_type" : " stream" ,
22
+ "text" : [
23
+ " 3\n "
24
+ ]
25
+ }
26
+ ],
27
+ "source" : [
28
+ " %%julia\n " ,
29
+ " \n " ,
30
+ " # Automatically activates Julia magic\n " ,
31
+ " \n " ,
32
+ " x = 1\n " ,
33
+ " println(x + 2)"
34
+ ]
35
+ },
36
+ {
37
+ "cell_type" : " code" ,
38
+ "execution_count" : 3 ,
39
+ "metadata" : {},
40
+ "outputs" : [
41
+ {
42
+ "name" : " stdout" ,
43
+ "output_type" : " stream" ,
44
+ "text" : [
45
+ " 4\n "
46
+ ]
47
+ }
48
+ ],
49
+ "source" : [
50
+ " %julia println(x + 3)"
51
+ ]
52
+ },
53
+ {
54
+ "cell_type" : " code" ,
55
+ "execution_count" : 4 ,
56
+ "metadata" : {},
57
+ "outputs" : [
58
+ {
59
+ "data" : {
60
+ "text/plain" : [
61
+ " 1.0"
62
+ ]
63
+ },
64
+ "execution_count" : 4 ,
65
+ "metadata" : {},
66
+ "output_type" : " execute_result"
67
+ }
68
+ ],
69
+ "source" : [
70
+ " jl.cos(0)"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type" : " code" ,
75
+ "execution_count" : 5 ,
76
+ "metadata" : {},
77
+ "outputs" : [
78
+ {
79
+ "data" : {
80
+ "text/plain" : [
81
+ " f (generic function with 1 method)"
82
+ ]
83
+ },
84
+ "execution_count" : 5 ,
85
+ "metadata" : {},
86
+ "output_type" : " execute_result"
87
+ }
88
+ ],
89
+ "source" : [
90
+ " %%julia\n " ,
91
+ " \n " ,
92
+ " function f(x::AbstractArray)\n " ,
93
+ " sum(x)\n " ,
94
+ " end"
95
+ ]
96
+ },
97
+ {
98
+ "cell_type" : " code" ,
99
+ "execution_count" : 6 ,
100
+ "metadata" : {},
101
+ "outputs" : [
102
+ {
103
+ "data" : {
104
+ "text/plain" : [
105
+ " 6"
106
+ ]
107
+ },
108
+ "execution_count" : 6 ,
109
+ "metadata" : {},
110
+ "output_type" : " execute_result"
111
+ }
112
+ ],
113
+ "source" : [
114
+ " jl.f(np.array([1, 2, 3]))"
115
+ ]
116
+ }
117
+ ],
118
+ "metadata" : {
119
+ "kernelspec" : {
120
+ "display_name" : " Python 3 (ipykernel)" ,
121
+ "language" : " python" ,
122
+ "name" : " python3"
123
+ },
124
+ "language_info" : {
125
+ "codemirror_mode" : {
126
+ "name" : " ipython" ,
127
+ "version" : 3
128
+ },
129
+ "file_extension" : " .py" ,
130
+ "mimetype" : " text/x-python" ,
131
+ "name" : " python" ,
132
+ "nbconvert_exporter" : " python" ,
133
+ "pygments_lexer" : " ipython3" ,
134
+ "version" : " 3.10.10"
135
+ }
136
+ },
137
+ "nbformat" : 4 ,
138
+ "nbformat_minor" : 2
139
+ }
You can’t perform that action at this time.
0 commit comments