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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
6704d23e
Commit
6704d23e
authored
Feb 16, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-allow copy assignments from const memory views into read/write memory views.
parent
7c63e2d1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+5
-2
tests/memoryview/numpy_memoryview_readonly.pyx
tests/memoryview/numpy_memoryview_readonly.pyx
+22
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
6704d23e
...
@@ -782,8 +782,8 @@ class MemoryViewSliceType(PyrexType):
...
@@ -782,8 +782,8 @@ class MemoryViewSliceType(PyrexType):
src
=
self
src
=
self
if
self
.
writable_needed
and
not
dst
.
writable_needed
:
#if not copying and
self.writable_needed and not dst.writable_needed:
return
False
#
return False
src_dtype
,
dst_dtype
=
src
.
dtype
,
dst
.
dtype
src_dtype
,
dst_dtype
=
src
.
dtype
,
dst
.
dtype
if
dst_dtype
.
is_const
:
if
dst_dtype
.
is_const
:
...
@@ -792,6 +792,9 @@ class MemoryViewSliceType(PyrexType):
...
@@ -792,6 +792,9 @@ class MemoryViewSliceType(PyrexType):
if
src_dtype
.
is_const
:
if
src_dtype
.
is_const
:
# When assigning between read-only views, compare only the non-const base types.
# When assigning between read-only views, compare only the non-const base types.
src_dtype
=
src_dtype
.
const_base_type
src_dtype
=
src_dtype
.
const_base_type
elif
copying
and
src_dtype
.
is_const
:
# Copying by value => ignore const on source.
src_dtype
=
src_dtype
.
const_base_type
if
src_dtype
!=
dst_dtype
:
if
src_dtype
!=
dst_dtype
:
return
False
return
False
...
...
tests/memoryview/numpy_memoryview_readonly.pyx
View file @
6704d23e
...
@@ -88,3 +88,25 @@ def test_const_mmview_ro(x):
...
@@ -88,3 +88,25 @@ def test_const_mmview_ro(x):
x
.
setflags
(
write
=
False
)
x
.
setflags
(
write
=
False
)
assert
x
.
flags
.
writeable
is
False
assert
x
.
flags
.
writeable
is
False
return
getconst
(
x
)
return
getconst
(
x
)
def
test_two_views
(
x
):
"""
>>> test_two_views(new_array())
23.0
"""
cdef
double
[:]
rw
=
x
cdef
const
double
[:]
ro
=
rw
rw
[
0
]
=
23
return
ro
[
0
]
def
test_assign_ro_to_rw
(
x
):
"""
>>> test_assign_ro_to_rw(new_array())
2.0
"""
cdef
const
double
[:]
ro
=
x
cdef
double
[:]
rw
=
np
.
empty_like
(
ro
)
rw
[:]
=
ro
return
rw
[
2
]
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