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
Boxiang Sun
cython
Commits
9dc28bd4
Commit
9dc28bd4
authored
Apr 14, 2013
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow arbitrary strides and zero- and one-sized dimensions
parent
65706856
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
188 additions
and
90 deletions
+188
-90
Cython/Utility/MemoryView_C.c
Cython/Utility/MemoryView_C.c
+138
-90
tests/memoryview/relaxed_strides.pyx
tests/memoryview/relaxed_strides.pyx
+50
-0
No files found.
Cython/Utility/MemoryView_C.c
View file @
9dc28bd4
This diff is collapsed.
Click to expand it.
tests/memoryview/relaxed_strides.pyx
0 → 100644
View file @
9dc28bd4
# tag: numpy
# mode: run
"""
Test accepting NumPy arrays with arbitrary strides for zero- or one-sized
dimensions.
Thanks to Nathaniel Smith and Sebastian Berg.
See also:
Mailing list threads:
http://thread.gmane.org/gmane.comp.python.cython.devel/14762
http://thread.gmane.org/gmane.comp.python.cython.devel/14634
Detailed discussion of the difference between numpy/cython's current
definition of "contiguity", and the correct definition:
http://thread.gmane.org/gmane.comp.python.cython.devel/14634/focus=14640
The PR implementing NPY_RELAXED_STRIDES_CHECKING:
https://github.com/numpy/numpy/pull/3162
Another test case:
https://github.com/numpy/numpy/issues/2956
"""
import
numpy
as
np
def
test_one_sized
(
array
):
"""
>>> a = np.ascontiguousarray(np.arange(10, dtype=np.double)[::100])
>>> test_one_sized(a)[0]
1.0
>>> a = np.arange(10, dtype=np.double)[::100]
>>> test_one_sized(a)[0]
1.0
"""
cdef
double
[::
1
]
a
=
array
a
[
0
]
+=
1.
return
array
def
test_zero_sized
(
array
):
"""
>>> a = np.ascontiguousarray(np.arange(10, dtype=np.double)[100:200:10])
>>> a = test_zero_sized(a)
>>> a = np.arange(10, dtype=np.double)[100:200:10]
>>> a = test_zero_sized(a)
"""
cdef
double
[::
1
]
a
=
array
return
a
\ No newline at end of file
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