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
Gwenaël Samain
cython
Commits
b260846e
Commit
b260846e
authored
Jul 06, 2018
by
scoder
Committed by
GitHub
Jul 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2428 from gabrieldemarmiesse/test_memoryviews_1
Added tests for "typed memoryviews" part 1
parents
e2742e7b
ea65eed8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
docs/examples/userguide/memoryviews/not_none.pyx
docs/examples/userguide/memoryviews/not_none.pyx
+11
-0
docs/src/userguide/memoryviews.rst
docs/src/userguide/memoryviews.rst
+3
-8
No files found.
docs/examples/userguide/memoryviews/not_none.pyx
0 → 100644
View file @
b260846e
import
numpy
as
np
def
process_buffer
(
int
[:,:]
input_view
not
None
,
int
[:,:]
output_view
=
None
):
if
output_view
is
None
:
# Creating a default view, e.g.
output_view
=
np
.
empty_like
(
input_view
)
# process 'input_view' into 'output_view'
return
output_view
docs/src/userguide/memoryviews.rst
View file @
b260846e
...
@@ -71,14 +71,9 @@ This also works conveniently as function arguments:
...
@@ -71,14 +71,9 @@ This also works conveniently as function arguments:
The ``not None`` declaration for the argument automatically rejects
The ``not None`` declaration for the argument automatically rejects
None values as input, which would otherwise be allowed. The reason why
None values as input, which would otherwise be allowed. The reason why
None is allowed by default is that it is conveniently used for return
None is allowed by default is that it is conveniently used for return
arguments::
arguments:
def process_buffer(int[:,:] input not None,
.. literalinclude:: ../../examples/userguide/memoryviews/not_none.pyx
int[:,:] output = None):
if output is None:
output = ... # e.g. numpy.empty_like(input)
# process 'input' into 'output'
return output
Cython will reject incompatible buffers automatically, e.g. passing a
Cython will reject incompatible buffers automatically, e.g. passing a
three dimensional buffer into a function that requires a two
three dimensional buffer into a function that requires a two
...
...
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