Skip to content

Commit 60afc9c

Browse files
committed
Adapt for Cython 3.x
1 parent 962c4bf commit 60afc9c

File tree

3 files changed

+111
-26
lines changed

3 files changed

+111
-26
lines changed

source-code/cython/Numpy/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build
22
*.so
3+
array_init.c
34
array_sum.c

source-code/cython/Numpy/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = cpython-34m
1+
VERSION = cpython-311-x86_64-linux-gnu
22
ARRAY_SUM_LIB = array_sum.$(VERSION).so
33
ARRAY_INIT_LIB = array_init.$(VERSION).so
44
PROFILE = array_sums_prof.txt

source-code/cython/Numpy/init_test.ipynb

Lines changed: 109 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 2,
66
"metadata": {
7-
"collapsed": true
7+
"tags": []
88
},
99
"outputs": [],
1010
"source": [
1111
"import pyximport\n",
12-
"pyximport.install();"
12+
"pyximport.install(reload_support=True, pyximport=True, pyimport=True, language_level='3str');"
1313
]
1414
},
1515
{
1616
"cell_type": "code",
1717
"execution_count": 2,
1818
"metadata": {
19-
"collapsed": true
19+
"tags": []
2020
},
2121
"outputs": [],
2222
"source": [
@@ -27,7 +27,11 @@
2727
"cell_type": "code",
2828
"execution_count": 3,
2929
"metadata": {
30-
"collapsed": false
30+
"collapsed": false,
31+
"jupyter": {
32+
"outputs_hidden": false
33+
},
34+
"tags": []
3135
},
3236
"outputs": [],
3337
"source": [
@@ -38,15 +42,19 @@
3842
"cell_type": "code",
3943
"execution_count": 4,
4044
"metadata": {
41-
"collapsed": false
45+
"collapsed": false,
46+
"jupyter": {
47+
"outputs_hidden": false
48+
},
49+
"tags": []
4250
},
4351
"outputs": [
4452
{
4553
"data": {
4654
"text/plain": [
47-
"array([[ 0., 1.],\n",
48-
" [ 2., 3.],\n",
49-
" [ 4., 5.]])"
55+
"array([[0., 1.],\n",
56+
" [2., 3.],\n",
57+
" [4., 5.]])"
5058
]
5159
},
5260
"execution_count": 4,
@@ -60,9 +68,13 @@
6068
},
6169
{
6270
"cell_type": "code",
63-
"execution_count": 7,
71+
"execution_count": 5,
6472
"metadata": {
65-
"collapsed": false
73+
"collapsed": false,
74+
"jupyter": {
75+
"outputs_hidden": false
76+
},
77+
"tags": []
6678
},
6779
"outputs": [],
6880
"source": [
@@ -71,24 +83,28 @@
7183
},
7284
{
7385
"cell_type": "code",
74-
"execution_count": 8,
86+
"execution_count": 6,
7587
"metadata": {
76-
"collapsed": false
88+
"collapsed": false,
89+
"jupyter": {
90+
"outputs_hidden": false
91+
},
92+
"tags": []
7793
},
7894
"outputs": [
7995
{
8096
"data": {
8197
"text/plain": [
82-
"array([[[ 0., 1., 2., 3.],\n",
83-
" [ 4., 5., 6., 7.],\n",
84-
" [ 8., 9., 10., 11.]],\n",
98+
"array([[[ 0., 1., 2., 3.],\n",
99+
" [ 4., 5., 6., 7.],\n",
100+
" [ 8., 9., 10., 11.]],\n",
85101
"\n",
86-
" [[ 12., 13., 14., 15.],\n",
87-
" [ 16., 17., 18., 19.],\n",
88-
" [ 20., 21., 22., 23.]]])"
102+
" [[12., 13., 14., 15.],\n",
103+
" [16., 17., 18., 19.],\n",
104+
" [20., 21., 22., 23.]]])"
89105
]
90106
},
91-
"execution_count": 8,
107+
"execution_count": 6,
92108
"metadata": {},
93109
"output_type": "execute_result"
94110
}
@@ -99,17 +115,85 @@
99115
},
100116
{
101117
"cell_type": "code",
102-
"execution_count": null,
118+
"execution_count": 7,
119+
"metadata": {
120+
"tags": []
121+
},
122+
"outputs": [],
123+
"source": [
124+
"import array_sum"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": 8,
130+
"metadata": {
131+
"tags": []
132+
},
133+
"outputs": [
134+
{
135+
"data": {
136+
"text/plain": [
137+
"15.0"
138+
]
139+
},
140+
"execution_count": 8,
141+
"metadata": {},
142+
"output_type": "execute_result"
143+
}
144+
],
145+
"source": [
146+
"array_sum.array_sum(a)"
147+
]
148+
},
149+
{
150+
"cell_type": "code",
151+
"execution_count": 3,
103152
"metadata": {
104-
"collapsed": true
153+
"tags": []
105154
},
106155
"outputs": [],
156+
"source": [
157+
"import array_init_pure"
158+
]
159+
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": 4,
163+
"metadata": {
164+
"tags": []
165+
},
166+
"outputs": [
167+
{
168+
"data": {
169+
"text/plain": [
170+
"array([[ 0., 1., 2.],\n",
171+
" [ 3., 4., 5.],\n",
172+
" [ 6., 7., 8.],\n",
173+
" [ 9., 10., 11.],\n",
174+
" [12., 13., 14.]])"
175+
]
176+
},
177+
"execution_count": 4,
178+
"metadata": {},
179+
"output_type": "execute_result"
180+
}
181+
],
182+
"source": [
183+
"array_init_pure.cons((5, 3))"
184+
]
185+
},
186+
{
187+
"cell_type": "code",
188+
"execution_count": null,
189+
"metadata": {},
190+
"outputs": [],
107191
"source": []
108192
}
109193
],
110194
"metadata": {
111195
"kernelspec": {
112-
"display_name": "Python 3",
196+
"display_name": "Python 3 (ipykernel)",
113197
"language": "python",
114198
"name": "python3"
115199
},
@@ -123,9 +207,9 @@
123207
"name": "python",
124208
"nbconvert_exporter": "python",
125209
"pygments_lexer": "ipython3",
126-
"version": "3.4.3"
210+
"version": "3.11.5"
127211
}
128212
},
129213
"nbformat": 4,
130-
"nbformat_minor": 0
214+
"nbformat_minor": 4
131215
}

0 commit comments

Comments
 (0)