Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pfernique committed Sep 1, 2016
1 parent abb71c6 commit a69807d
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 31 deletions.
51 changes: 38 additions & 13 deletions doc/examples/basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"# Wrapping a basic library\n",
"\n",
"We here aim at presenting the interactive wrapping workflow.\n",
"For the sake of simplicity, we consider a basic example of *C++* library.\n",
"In the following we will use Conda package management system to compile and install this basic *C++* library."
"For the sake of simplicity, we consider a basic example of *C++* library."
]
},
{
Expand Down Expand Up @@ -46,7 +45,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We then need to install and compile the *C++* library."
"Then, to install and compile the *C++* library we use available **Conda** recipes."
]
},
{
Expand All @@ -66,7 +65,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Once the headers habe been installed in the system, we parse headers with relevant compilation flags."
"Once the headers have been installed in the system, we parse them with relevant compilation flags."
]
},
{
Expand All @@ -89,7 +88,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Since most of **AutoWIG** guidelines are respected, the `default` `controller` implementation is thus suitable."
"Since most of **AutoWIG** guidelines are respected, the `default` `controller` implementation is suitable."
]
},
{
Expand Down Expand Up @@ -120,17 +119,18 @@
"outputs": [],
"source": [
"autowig.generator.plugin = 'boost_python_internal'\n",
"wrappers = autowig.generator(asg, module = 'basic/src/py/_module.cpp',\n",
" decorator = 'basic/src/py/basic/_module.py',\n",
" prefix = 'wrapper_')"
"wrappers = autowig.generator(asg,\n",
" module = 'basic/src/py/_module.cpp',\n",
" decorator = 'basic/src/py/basic/_module.py',\n",
" prefix = 'wrapper_')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The wrappers are only generated in-memory.\n",
"We therefore need to write them on the disk to complete the process."
"It is therefore needed to write them on the disk to complete the process."
]
},
{
Expand All @@ -144,11 +144,34 @@
"wrappers.write()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"Here is an example of the generated wrappers.\n",
"We here present the wrappers for the `BinomialDistribution` class."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"asg['class ::BinomialDistribution'].boost_python_export"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once the wrappers are written on disk, we need to install the *Python* bindings."
"Once the wrappers are written on disk, we need to compile and install the *Python* bindings."
]
},
{
Expand All @@ -168,7 +191,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"And we can hereafter use the *C++* library in the *Python* interpreter"
"Finally, we can hereafter use the *C++* library in the *Python* interpreter."
]
},
{
Expand All @@ -180,7 +203,8 @@
"outputs": [],
"source": [
"import basic\n",
"binomial = basic.BinomialDistribution(1, .5)"
"binomial = basic.BinomialDistribution(1, .5)\n",
"binomial"
]
},
{
Expand Down Expand Up @@ -213,7 +237,8 @@
},
"outputs": [],
"source": [
"binomial.n = 0"
"binomial.n = 0\n",
"binomial"
]
},
{
Expand Down
8 changes: 7 additions & 1 deletion doc/examples/basic/src/py/basic/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
from __module import BinomialDistribution, Overload, ProbabilityError
from __module import BinomialDistribution, Overload, ProbabilityError

def _repr_latex_(self):
return r"$\mathcal{B}\left(" + str(self.n) + ", " str(round(self.get_pi(), 2)) + r"\right)$"

BinomialDistribution._repr_latex_ = _repr_latex_
del _repr_latex_
23 changes: 21 additions & 2 deletions doc/examples/subset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In order to wrap a subset of the **Clang** library, the user need to implements a `generator` that passes particular nodes to the `boost_python` `generator`."
"In order to wrap a subset of the **Clang** library, we need to select the `boost_python_internal` `generator` implementation."
]
},
{
Expand All @@ -425,7 +425,7 @@
"metadata": {},
"source": [
"The wrappers are only generated in-memory.\n",
"We therefore need to write them on the disk to complete the process."
"It is therefore needed to write them on the disk to complete the process."
]
},
{
Expand All @@ -439,6 +439,25 @@
"wrappers.write()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is an example of the generated wrappers.\n",
"We here present the wrappers for the `clang::Decl` class."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"asg['class ::clang::Decl'].boost_python_export"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading

0 comments on commit a69807d

Please sign in to comment.