Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
00cf5cd5
Commit
00cf5cd5
authored
May 16, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cython.view.array cast step error
parent
37d13c94
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
5 deletions
+32
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-1
tests/compile/memview_declaration.pyx
tests/compile/memview_declaration.pyx
+9
-0
tests/run/cythonarray.pyx
tests/run/cythonarray.pyx
+20
-3
tests/run/numpy_test.pyx
tests/run/numpy_test.pyx
+0
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
00cf5cd5
...
@@ -7336,6 +7336,7 @@ class CythonArrayNode(ExprNode):
...
@@ -7336,6 +7336,7 @@ class CythonArrayNode(ExprNode):
first_or_last
=
axis_no
in
(
0
,
ndim
-
1
)
first_or_last
=
axis_no
in
(
0
,
ndim
-
1
)
if
not
axis
.
step
.
is_none
and
first_or_last
:
if
not
axis
.
step
.
is_none
and
first_or_last
:
# '1' in the first or last dimension denotes F or C contiguity
axis
.
step
.
analyse_types
(
env
)
axis
.
step
.
analyse_types
(
env
)
if
(
not
axis
.
step
.
type
.
is_int
and
axis
.
step
.
is_literal
and
not
if
(
not
axis
.
step
.
type
.
is_int
and
axis
.
step
.
is_literal
and
not
axis
.
step
.
type
.
is_error
):
axis
.
step
.
type
.
is_error
):
...
@@ -7347,7 +7348,8 @@ class CythonArrayNode(ExprNode):
...
@@ -7347,7 +7348,8 @@ class CythonArrayNode(ExprNode):
if
axis_no
==
0
:
if
axis_no
==
0
:
self
.
mode
=
"fortran"
self
.
mode
=
"fortran"
elif
axis
.
step
and
not
first_or_last
:
elif
not
axis
.
step
.
is_none
and
not
first_or_last
:
# step provided in some other dimension
return
error
(
axis
.
step
.
pos
,
ERR_STEPS
)
return
error
(
axis
.
step
.
pos
,
ERR_STEPS
)
if
not
self
.
operand
.
is_name
:
if
not
self
.
operand
.
is_name
:
...
...
tests/compile/memview_declaration.pyx
View file @
00cf5cd5
...
@@ -60,3 +60,12 @@ my_c_contig = a33[0, :, :]
...
@@ -60,3 +60,12 @@ my_c_contig = a33[0, :, :]
my_f_contig
=
a32
[
0
,
...]
my_f_contig
=
a32
[
0
,
...]
my_c_contig
=
a33
[
0
,
...]
my_c_contig
=
a33
[
0
,
...]
# Test casting to cython.view.array
cdef
double
[:,
:]
m1
=
<
double
[:
10
,
:
10
]
>
NULL
cdef
double
[:,
:]
m2
=
<
double
[:
10
,
:
10
:
1
]
>
NULL
cdef
double
[:,
:]
m3
=
<
double
[:
10
:
1
,
:
10
]
>
NULL
cdef
double
[:,
:,
:]
m4
=
<
double
[:
10
,
:
10
,
:
10
]
>
NULL
cdef
double
[:,
:,
:]
m5
=
<
double
[:
10
,
:
10
,
:
10
:
1
]
>
NULL
cdef
double
[:,
:,
:]
m6
=
<
double
[:
10
:
1
,
:
10
,
:
10
]
>
NULL
\ No newline at end of file
tests/run/cythonarray.pyx
View file @
00cf5cd5
...
@@ -102,15 +102,15 @@ def test_cython_array_index():
...
@@ -102,15 +102,15 @@ def test_cython_array_index():
print
f_array
[
9
,
8
]
print
f_array
[
9
,
8
]
print
f_array
[
6
,
1
]
print
f_array
[
6
,
1
]
cdef
int
*
getp
(
int
dim1
=
10
,
int
dim2
=
10
)
except
NULL
:
cdef
int
*
getp
(
int
dim1
=
10
,
int
dim2
=
10
,
dim3
=
1
)
except
NULL
:
print
"getp()"
print
"getp()"
cdef
int
*
p
=
<
int
*>
malloc
(
dim1
*
dim2
*
sizeof
(
int
))
cdef
int
*
p
=
<
int
*>
malloc
(
dim1
*
dim2
*
dim3
*
sizeof
(
int
))
if
p
==
NULL
:
if
p
==
NULL
:
raise
MemoryError
raise
MemoryError
for
i
in
range
(
dim1
*
dim2
):
for
i
in
range
(
dim1
*
dim2
*
dim3
):
p
[
i
]
=
i
p
[
i
]
=
i
return
p
return
p
...
@@ -161,6 +161,23 @@ def test_array_from_pointer():
...
@@ -161,6 +161,23 @@ def test_array_from_pointer():
c_arr
.
callback_free_data
=
callback_free_data
c_arr
.
callback_free_data
=
callback_free_data
print
c_arr
[
m
-
1
,
n
-
1
]
print
c_arr
[
m
-
1
,
n
-
1
]
def
test_array_from_pointer_3d
():
"""
>>> test_array_from_pointer_3d()
getp()
3 3
1 1
"""
cdef
int
*
p
=
getp
(
2
,
2
,
2
)
cdef
array
c_arr
=
<
int
[:
2
,
:
2
,
:
2
:
1
]
>
p
cdef
array
f_arr
=
<
int
[:
2
:
1
,
:
2
,
:
2
]
>
p
cdef
int
[:,
:,
::
1
]
m1
=
c_arr
cdef
int
[::
1
,
:,
:]
m2
=
f_arr
print
m1
[
0
,
1
,
1
],
m2
[
1
,
1
,
0
]
print
m1
.
is_c_contig
(),
m2
.
is_f_contig
()
def
test_cyarray_from_carray
():
def
test_cyarray_from_carray
():
"""
"""
>>> test_cyarray_from_carray()
>>> test_cyarray_from_carray()
...
...
tests/run/numpy_test.pyx
View file @
00cf5cd5
...
@@ -847,5 +847,4 @@ def test_dispatch_memoryview_object():
...
@@ -847,5 +847,4 @@ def test_dispatch_memoryview_object():
cdef
int
[:]
m3
=
<
object
>
m
cdef
int
[:]
m3
=
<
object
>
m
test_fused_memslice
(
m3
)
test_fused_memslice
(
m3
)
include
"numpy_common.pxi"
include
"numpy_common.pxi"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment