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
ea65eed8
Commit
ea65eed8
authored
Jun 26, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved an example from memoryviews.rst to the examples directory.
parent
084a25f5
Changes
2
Hide 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 @
ea65eed8
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 @
ea65eed8
...
...
@@ -71,14 +71,9 @@ This also works conveniently as function arguments:
The ``not None`` declaration for the argument automatically rejects
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
arguments::
def process_buffer(int[:,:] input not None,
int[:,:] output = None):
if output is None:
output = ... # e.g. numpy.empty_like(input)
# process 'input' into 'output'
return output
arguments:
.. literalinclude:: ../../examples/userguide/memoryviews/not_none.pyx
Cython will reject incompatible buffers automatically, e.g. passing a
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