File: comparison.rst

package info (click to toggle)
python-boost-histogram 1.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,236 kB
  • sloc: python: 7,940; cpp: 3,243; makefile: 22; sh: 1
file content (70 lines) | stat: -rw-r--r-- 2,845 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
.. _usage-comparison:

Comparison with Boost.Histogram
===============================

``boost-histogram`` was based on the C++ library Boost.Histogram. In most ways,
it mimics the spirit of this library; if you learn to use one, you probably can use
the other. There are a few differences, however, mostly around adhering to Python
conventions:

Removals
^^^^^^^^

There are a few parts of the Boost.Histogram interface that are not bound. They are:

The call operator
   This is provided in C++ to allow single item filling, and was designed to mimic the
   accumulator syntax used elsewhere in Boost. It also works nicely with some STL
   algorithms. It was not provided in Python because using call to modify an object
   is not common in Python, using call makes duck-typing more dangerous, and single-item
   fills are not encouraged in Python due to poor performance. The ``.fill`` method from
   Boost.Histogram 1.72 is bound, however - this provides fast fills without the drawbacks.
   If you want to fill with a single item, Python's ``.fill`` does support single item fills.

Histogram make functions
   These functions, such as ``make_histogram`` and ``make_weighted_histogram``, are provided
   in Boost.Histogram to make the template syntax easier in C++14. In C++17, they are replaced
   by directly using the ``histogram`` constructor; the Python bindings are not limited by old
   templating syntax, and choose to only provide the newer spelling.

Custom components
   Many components in Boost.Histogram are configurable or replaceable at compile time; since
   Python code is precompiled, a comprehensive but static subset was selected for the Python bindings.

Changes
^^^^^^^

Naming
   The bindings follow modern Python conventions, with CamelCase for classes,
   etc. The Boost.Histogram library follows Boost conventions.

Serialization
   The Python bindings use a pickle-based binary serialization, so cannot read
   files saved in C++ using Boost.Serialize.

Properties
   Many methods in C++ are properties in Python. ``.axis(i)`` is replaced with ``.axes[i]``.

Indexing
  The Python bindings use standard Python indexing for selection and setting.
  You can recover the functionality of ``.at(i)`` at endpoints with
  ``bh.tag.at(i)``.

Renames
  The ``.rank()`` method is replaced by the ``.ndim`` property to match the common NumPy spelling.

Additions
^^^^^^^^^

Unified Histogram Indexing
   The Python bindings support UHI, a proposal to unify and simplify histogram
   indexing in Python.

Custom transforms
   Custom transforms are possible using Numba or a C pointer. In
   Boost.Histogram, you can use templating to make arbitrary transforms, so a
   run time transform is not as necessary (but may be added).

NumPy compatibility
   The Python bindings do several things to simplify NumPy compatibility.