Skip to content

Commit 5fa6bc9

Browse files
Improving documentation and fixing little things.
1 parent f0840be commit 5fa6bc9

6 files changed

Lines changed: 79 additions & 70 deletions

File tree

docs/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# You can set these variables from the command line.
55
SPHINXOPTS =
66
SPHINXBUILD = python -msphinx
7-
SPHINXPROJ = HydraPython
7+
SPHINXPROJ = Hydra.Python
88
SOURCEDIR = .
99
BUILDDIR = _build
1010

@@ -17,4 +17,4 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/Vector.rst

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
Vector Classes
44
##############
55

6-
There are two Vector classes available that are ``Vector4R`` and ``Vector3R``.
6+
There are two vector classes available in Hydra, namely ``Vector4R`` and ``Vector3R``.
77

88
Vector4R
99
========
1010

11-
The Vector4R class is the wrapper of C++ Vector4R class. This class basically
12-
deals with the vector of 4 particles. We have three types of constructors
13-
to instantiate the Vector4R class:
11+
The ``Vector4R`` class available in Python wraps the C++ ``Vector4R`` class representing
12+
four-dimensional relativistic vectors.
13+
Three types of constructors allow to instantiate the ``Vector4R`` class:
1414

15-
- Default empty constructor
16-
- Copy constructor
17-
- Constructor with 4 real (``float``) numbers
15+
- Default empty constructor.
16+
- Copy constructor.
17+
- Constructor from 4 real (``float``) numbers.
1818

1919
.. code-block:: python
2020
@@ -28,19 +28,18 @@ to instantiate the Vector4R class:
2828
print (vec2) # (0.8385,0.1242,0.9821,1.2424)
2929
print (vec3) # (0.8385,0.1242,0.9821,1.2424)
3030
31-
The Vector4R class also provides a pretty convenient method to create an
32-
object from python list.
31+
The ``Vector4R`` class also provides a pretty convenient method to create an instance from a python list.
3332

3433
.. code-block:: python
3534
3635
list_ = [0.9241, 0.13223, 0.13121, 1.1141]
3736
vec4 = hp.Vector4R(list_)
3837
39-
This will construct a new Vector4R object with the values passed within
38+
This will construct a new ``Vector4R`` object with the values passed within
4039
a list. The list should contain exactly 4 elements otherwise a ``TypeError``
4140
will be raised.
4241
The ``set`` methods can be used to set all 4 values or a particular value
43-
in a Vector4R object, while the ``get`` method can be used with Vector4R
42+
in a ``Vector4R`` object, while the ``get`` method can be used with ``Vector4R``
4443
to get the value of a particular index. The ``__getitem__`` and
4544
``__setitem`` methods can also be used to get or set the value which comes
4645
very handy and maintain more pythonic way to access and set the values.
@@ -61,9 +60,9 @@ very handy and maintain more pythonic way to access and set the values.
6160
vec5[1] = 0.5678
6261
print (vec5) # (0.1234,0.5678,0.9101,0.1121)
6362
64-
The Vector4R object can be multiplied or divided by a real value while it
65-
can be added or subtracted with another Vector4R object. One Vector4R
66-
object can be multiplied by another Vector4R object.
63+
The ``Vector4R`` object can be multiplied or divided by a real value while it
64+
can be added or subtracted with another ``Vector4R`` object. One Vector4R
65+
object can be multiplied by another ``Vector4R`` object.
6766

6867
.. code-block:: python
6968
@@ -80,17 +79,17 @@ object can be multiplied by another Vector4R object.
8079
vec6 -= vec7
8180
print (vec6) # (1.50608,1.69418,0.01925,2.1989)
8281
83-
Two Vector4R objects can be easily added, subtracted or multiplied so:
82+
Two ``Vector4R`` objects can easily be added, subtracted or multiplied:
8483

8584
- ``v = v1 + v2`` # Returns a Vector4R object
8685
- ``v = v1 - v2`` # Returns a Vector4R object
8786
- ``v = v1 * v2`` # Returns a real number
8887

89-
All above three are valid for any Vector4R object. There are various
90-
other methods available in Vector4R. The list of Vector4R
88+
All above three are valid for any ``Vector4R`` object. There are various
89+
other methods available in ``Vector4R``. The list of ``Vector4R``
9190
methods can be found on [#f1]_.
9291

93-
The Vector4R provides an ``assign`` method to assign or copy the Vector4R
92+
The ``Vector4R`` provides an ``assign`` method to assign or copy the Vector4R
9493
object. This is a very useful method to avoid the nasty bugs for example:
9594

9695
.. code-block:: python
@@ -111,13 +110,13 @@ object. This is a very useful method to avoid the nasty bugs for example:
111110
Vector3R
112111
========
113112

114-
The Vector3R class is the wrapper of C++ Vector3R class. This class basically
115-
deals with the vector of 3 particles. We have three types of constructors
116-
to instantiate the Vector3R class:
113+
The ``Vector43`` class available in Python wraps the C++ ``Vector3R`` class representing
114+
three-dimensional Euclidian vectors.
115+
Three types of constructors allow to instantiate the ``Vector3R`` class:
117116

118-
- Default empty constructor
119-
- Copy constructor
120-
- Constructor with 3 real (``float``) numbers
117+
- Default empty constructor.
118+
- Copy constructor.
119+
- Constructor from 3 real (``float``) numbers.
121120

122121
.. code-block:: python
123122
@@ -131,19 +130,19 @@ to instantiate the Vector3R class:
131130
print (vec2) # (0.8385,0.1242,0.9821)
132131
print (vec3) # (0.8385,0.1242,0.9821)
133132
134-
The Vector3R class also provides a pretty convenient method to create an
133+
The ``Vector3R`` class also provides a pretty convenient method to create an
135134
object from python list.
136135

137136
.. code-block:: python
138137
139138
list_ = [0.9241, 0.13223, 0.13121]
140139
vec4 = hp.Vector3R(list_)
141140
142-
This will construct a new Vector3R object with the values passed within
141+
This will construct a new ``Vector3R`` object with the values passed within
143142
a list. The list should contain exactly 3 elements otherwise a ``TypeError``
144143
will be raised.
145144
The ``set`` methods can be used to set all 3 values or a particular value
146-
in a Vector3R object, while the ``get`` method can be used with Vector3R
145+
in a ``Vector3R`` object, while the ``get`` method can be used with ``Vector3R``
147146
to get the value of a particular index. The ``__getitem__`` and
148147
``__setitem`` methods can also be used to get or set the value which comes
149148
very handy and maintain more pythonic way to access and set the values.
@@ -164,9 +163,9 @@ very handy and maintain more pythonic way to access and set the values.
164163
vec5[1] = 0.5678
165164
print (vec5) # (0.1234,0.5678,0.9101)
166165
167-
The Vector3R object can be multiplied or divided by a real value while it
168-
can be added or subtracted with another Vector3R object. One Vector3R
169-
object can be multiplied by another Vector3R object.
166+
The ``Vector3R`` object can be multiplied or divided by a real value while it
167+
can be added or subtracted with another ``Vector3R`` object. One ``Vector3R``
168+
object can be multiplied by another ``Vector3R`` object.
170169

171170
.. code-block:: python
172171
@@ -183,17 +182,17 @@ object can be multiplied by another Vector3R object.
183182
vec6 -= vec7
184183
print (vec6) # (1.50608,1.69418,0.01925)
185184
186-
Two Vector3R objects can be easily added, subtracted or multiplied so:
185+
Two ``Vector3R`` objects can easily be added, subtracted or multiplied:
187186

188187
- ``v = v1 + v2`` # Returns a Vector3R object
189188
- ``v = v1 - v2`` # Returns a Vector3R object
190189
- ``v = v1 * v2`` # Returns a real number
191190

192-
All above three are valid for any Vector3R object. There are various
193-
other methods available in Vector3R. The list of Vector3R
191+
All above three are valid for any ``Vector3R`` object. There are various
192+
other methods available in ``Vector3R``. The list of ``Vector3R``
194193
methods can be found on [#f2]_.
195194

196-
The Vector3R provides an ``assign`` method to assign or copy the Vector3R
195+
The ``Vector3R`` provides an ``assign`` method to assign or copy the Vector3R
197196
object. This is a very useful method to avoid the nasty bugs for example:
198197

199198
.. code-block:: python

docs/conf.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
#
4-
# Hydra Python documentation build configuration file, created by
4+
# Hydra.Python documentation build configuration file, created by
55
# sphinx-quickstart on Fri Aug 11 18:15:40 2017.
66
#
77
# This file is execfile()d with the current directory set to its
@@ -48,8 +48,8 @@
4848
master_doc = 'index'
4949

5050
# General information about the project.
51-
project = 'Hydra Python'
52-
copyright = '2017, Deepanshu Thakur'
51+
project = 'Hydra.Python'
52+
copyright = '2017, Antonio Augusto Alves Junior'
5353
author = 'Deepanshu Thakur'
5454

5555
# The version info for the project you're documenting, acts as replacement for
@@ -144,7 +144,7 @@
144144
# (source start file, target name, title,
145145
# author, documentclass [howto, manual, or own class]).
146146
latex_documents = [
147-
(master_doc, 'HydraPython.tex', 'Hydra Python Documentation',
147+
(master_doc, 'HydraPython.tex', 'Hydra.Python Documentation',
148148
'Deepanshu Thakur', 'manual'),
149149
]
150150

@@ -154,7 +154,7 @@
154154
# One entry per manual page. List of tuples
155155
# (source start file, name, description, authors, manual section).
156156
man_pages = [
157-
(master_doc, 'hydrapython', 'Hydra Python Documentation',
157+
(master_doc, 'hydrapython', 'Hydra.Python Documentation',
158158
[author], 1)
159159
]
160160

@@ -165,10 +165,7 @@
165165
# (source start file, target name, title, author,
166166
# dir menu entry, description, category)
167167
texinfo_documents = [
168-
(master_doc, 'HydraPython', 'Hydra Python Documentation',
169-
author, 'HydraPython', 'One line description of project.',
168+
(master_doc, 'HydraPython', 'Hydra.Python Documentation',
169+
author, 'HydraPython', 'Python bindings for the Hydra C++ header-only library.',
170170
'Miscellaneous'),
171171
]
172-
173-
174-

docs/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
.. image:: hydra_mini_logo.png
44
5-
Hydra Python --- The Python wrapper of Hydra C++
6-
================================================
5+
Hydra.Python --- Python bindings for the Hydra C++ library
6+
==========================================================
77

88
.. only: not latex
99
@@ -15,7 +15,7 @@ Hydra Python --- The Python wrapper of Hydra C++
1515
intro
1616

1717
.. toctree::
18-
:caption: The Basics
18+
:caption: The basics
1919
:maxdepth: 2
2020

2121
basics
@@ -25,7 +25,7 @@ Hydra Python --- The Python wrapper of Hydra C++
2525
Random
2626

2727
.. toctree::
28-
:caption: PhaseSpace example
28+
:caption: Examples
2929
:maxdepth: 2
3030

3131
PhaseSpaceExample

docs/intro.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
.. image:: hydra_logo.png
2-
2+
:scale: 25 %
3+
34
About this project
45
==================
5-
**HydraPython** is a wrapper around the header-only C++ `Hydra`_ library that provides
6-
the abstraction over the C++ method. This library is an abstraction over the
7-
C++ library, so that you can work with much simpler Python language, concentrate
8-
more on the logic and leave all the memory management stuff up to the library. This
9-
library is written keeping ``Linux`` systems in mind, but you might apply some
10-
hacks to make compatible with other platforms.
6+
The **Hydra.Python** package provides the Python bindings for the header-only C++ `Hydra`_ library.
7+
This library is an abstraction over the C++ library, so that daily work can be code and run with the much simpler Python language,
8+
concentrating on the logic and leaving all the complex memory management and optimisations to the C++ library.
9+
10+
The bindings are produced with [pybind11](http://pybind11.readthedocs.io/). The project makes use of [CMAKE](https://cmake.org/).
11+
12+
The library is written with ``Linux`` systems in mind, but compatibility with other platforms may be achieved with "hacks".
13+
Python 2.7, and 3.x are supported.
14+
1115

1216
.. _Hydra: https://github.com/MultithreadCorner/Hydra
1317

1418

1519
Core features
1620
*************
17-
The following core C++ features can be mapped to Python
21+
The core functionality of Hydra has been exposed to Python.
22+
23+
The following core C++ features of Hydra can be mapped to Python:
1824

19-
- Python 2.7, and 3.x are supported.
2025
- The continuous expansion of the original Hydra library.
2126
- Support for ``particles`` with ``Vector4R`` class.
2227
- Support for containers like ``Events`` or ``Decay``.
@@ -25,5 +30,12 @@ The following core C++ features can be mapped to Python
2530
Supported compilers
2631
*******************
2732

28-
1. Clang/LLVM (any non-ancient version with C++11 support)
29-
2. GCC 4.8 or newer
33+
1. Clang/LLVM (any non-ancient version with C++11 support).
34+
2. GCC 4.8 or newer.
35+
36+
37+
History
38+
*******
39+
The development of **Hydra.Python** started as a
40+
[2017 Google Summer of Code project](https://summerofcode.withgoogle.com/projects/#6669304945704960)
41+
with student Deepanshu Thakur.

src/PyBindings.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*----------------------------------------------------------------------------
32
*
43
* Copyright (C) 2017 Antonio Augusto Alves Junior
@@ -24,8 +23,8 @@
2423
/*
2524
* PyBindings.cpp
2625
*
27-
* Created on: 30 de jul de 2017
28-
* Author: augalves
26+
* Created on: July 30, 2017
27+
* Author: Antonio Augusto Alves Junior
2928
*/
3029

3130
/*
@@ -39,33 +38,35 @@
3938
*
4039
*/
4140

42-
//pybind11
41+
// pybind11
4342
#include <pybind11/pybind11.h>
4443
#include <pybind11/stl.h>
45-
//Hydra.Python
44+
45+
//Hydra.Python helpers
4646
#include <add_object.h>
4747
#include <bind_container.h>
4848
#include <casters.h>
4949
#include <typedefs.h>
5050
#include <make_opaque.h>
51-
//Hydra.Python hydra classes
51+
// Hydra.Python binded Hydra classes
5252
#include <PyRandom.h>
5353
#include <PyEvents.h>
5454
#include <PyVector3R.h>
5555
#include <PyVector4R.h>
5656
#include <PyPhaseSpace.h>
5757

58+
5859
namespace py = pybind11;
5960
namespace hypy = hydra_python;
6061

6162

6263

6364
PYBIND11_MODULE(HydraPython, m) {
6465

65-
hypy::add_object< hydra::Random<thrust::random::default_random_engine> >(m);
66-
hypy::add_object< hydra::Events<4, hydra::host::sys_t> >(m);
6766
hypy::add_object< hydra::Vector3R >(m);
6867
hypy::add_object< hydra::Vector4R >(m);
68+
hypy::add_object< hydra::Random<thrust::random::default_random_engine> >(m);
69+
hypy::add_object< hydra::Events<4, hydra::host::sys_t> >(m);
6970
hypy::add_object< hydra::PhaseSpace<4, thrust::random::default_random_engine> >(m);
7071

7172
//decay container host
@@ -115,4 +116,4 @@ hypy::bind_vector< hypy::device_vector_float9 >(m,"device_vector_float9");
115116
hypy::bind_vector< hypy::device_vector_float10>(m,"device_vector_float10");
116117

117118

118-
}
119+
}

0 commit comments

Comments
 (0)