Conversation
docs/source/tutorial/arrays.rst
Outdated
|
|
||
| Let's write function to sum an array: | ||
|
|
||
| .. code-block:: c++ |
There was a problem hiding this comment.
This could just include from libpy_tutorials/arrays.cc
There was a problem hiding this comment.
I am not sure I like the includes. If I change the code, I need to go change the lines in source, but probably won't remember to do that so the docs are just broken.
There was a problem hiding this comment.
But this way you're only changing the underlying code in one place, rather than needing to make x updates anytime we change tutorial content.
Plus if everything is referring to source we compile it is more likely to be correct.
docs/source/tutorial/arrays.rst
Outdated
| From Python | ||
| ----------- | ||
|
|
||
| To call ``simple_sum`` from Python, we must first use :cpp:func:`py::automethod` to adapt the function and then attach it to a module. | ||
| For example: | ||
|
|
||
| .. code-block:: | ||
|
|
||
| LIBPY_AUTOMODULE(libpy_tutorial, | ||
| arrays, | ||
| ({py::autofunction<simple_sum>("simple_sum")})) | ||
| (py::borrowed_ref<>) { | ||
| return false; | ||
| } | ||
|
|
||
| Now, we can import the function and pass it numpy arrays: | ||
|
|
||
| .. ipython:: python | ||
|
|
||
| import numpy as np | ||
| from libpy_tutorial.arrays import simple_sum | ||
| arr = np.arange(10); arr | ||
| simple_sum(arr) | ||
|
|
There was a problem hiding this comment.
I think we should keep the from python stuff (autofunction, autoclass, automodule) all in one place and link to it, otherwise we're going to be repeating it in every section. Maybe it goes under something like a "Concepts" or some other more general category.
There was a problem hiding this comment.
I think the first two intro sections probably should include it so that they mostly stand alone. I won't need this in some of the other sections
No description provided.