Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

[MRG] docs fixes #146

Merged
merged 1 commit into from Mar 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/index.rst
Expand Up @@ -10,7 +10,6 @@ Documentation
-------------

.. toctree::
:numbered:
:maxdepth: 2

install
Expand Down
39 changes: 20 additions & 19 deletions docs/reference/index.rst
Expand Up @@ -41,26 +41,27 @@ what they are and what they do.
Type Conversion Table
---------------------

The primitive types are converted according to this table:
Types are converted according to this table:

=========== =========================
ROOT NumPy
=========== =========================
Char_t np.int8
UChar_t np.uint8
Short_t np.int16
UShort_t np.uint16
Int_t np.int32
UInt_t np.uint32
Float_t np.float32
Double_t np.float64
Long64_t np.int64
ULong64_t np.uint64
Bool_t np.bool
x[10] (np.primitivetype, (10,))
x[nx] np.object
vector<t> np.object
=========== =========================
================== =========================
ROOT NumPy
================== =========================
Bool_t np.bool
Char_t np.int8
UChar_t np.uint8
Short_t np.int16
UShort_t np.uint16
Int_t np.int32
UInt_t np.uint32
Float_t np.float32
Double_t np.float64
Long64_t np.int64
ULong64_t np.uint64
x[10] (np.primitivetype, (10,))
x[nx] np.object
vector<t> np.object
vector<vector<t> > np.object
================== =========================

Variable length arrays (such as ``particletype[nparticle]``) and vectors
(such as ``vector<int>``) are converted to NumPy arrays of the corresponding
Expand Down
6 changes: 1 addition & 5 deletions root_numpy/_array.py
Expand Up @@ -8,15 +8,12 @@


def array(arr, copy=True):
"""
Convert a ROOT TArray into a NumPy array.
"""Convert a ROOT TArray into a NumPy array.

Parameters
----------

arr : ROOT TArray
A ROOT TArrayD, TArrayF, TArrayL, TArrayI or TArrayS

copy : bool, optional (default=True)
If True (the default) then copy the underlying array, otherwise
the NumPy array will view the same memory as the ROOT array.
Expand All @@ -28,7 +25,6 @@ def array(arr, copy=True):

Examples
--------

>>> from root_numpy import array
>>> from ROOT import TArrayD
>>> a = TArrayD(5)
Expand Down
5 changes: 2 additions & 3 deletions root_numpy/_evaluate.py
Expand Up @@ -8,9 +8,7 @@


def evaluate(root_object, array):
"""
Evaluate a ROOT histogram, function, graph, or spline at all values
in a NumPy array and return the resulting array.
"""Evaluate a ROOT histogram, function, graph, or spline over an array.

Parameters
----------
Expand Down Expand Up @@ -44,6 +42,7 @@ def evaluate(root_object, array):
>>> func = TF2("f2", "x*y")
>>> evaluate(func, [[1, 1], [1, 2], [3, 1]])
array([ 1., 2., 3.])

"""
import ROOT
array = np.asarray(array, dtype=np.double)
Expand Down
5 changes: 1 addition & 4 deletions root_numpy/_graph.py
Expand Up @@ -8,15 +8,12 @@


def fill_graph(graph, array):
"""
Fill a ROOT graph with a NumPy array.
"""Fill a ROOT graph with a NumPy array.

Parameters
----------

hist : a ROOT TGraph or TGraph2D
The ROOT graph to fill.

array : numpy array of shape [n_samples, n_dimensions]
The values to fill the graph with. The number of columns
must match the dimensionality of the graph.
Expand Down
8 changes: 1 addition & 7 deletions root_numpy/_hist.py
Expand Up @@ -8,30 +8,24 @@


def fill_hist(hist, array, weights=None, return_indices=False):
"""
Fill a ROOT histogram with a NumPy array.
"""Fill a ROOT histogram with a NumPy array.

Parameters
----------

hist : a ROOT TH1, TH2, or TH3
The ROOT histogram to fill.

array : numpy array of shape [n_samples, n_dimensions]
The values to fill the histogram with. The number of columns
must match the dimensionality of the histogram. Supply a flat
numpy array when filling a 1D histogram.

weights : numpy array
A flat numpy array of weights for each sample in ``array``.

return_indices : bool, optional (default=False)
If True then return an array of the bin indices filled for each element
in ``array``.

Returns
-------

indices : numpy array or None
If ``return_indices`` is True, then return an array of the bin indices
filled for each element in ``array`` otherwise return None.
Expand Down
6 changes: 1 addition & 5 deletions root_numpy/_matrix.py
Expand Up @@ -7,24 +7,20 @@


def matrix(mat):
"""
Convert a ROOT TMatrix into a NumPy matrix.
"""Convert a ROOT TMatrix into a NumPy matrix.

Parameters
----------

mat : ROOT TMatrixT
A ROOT TMatrixD or TMatrixF

Returns
-------

mat : numpy.matrix
A NumPy matrix

Examples
--------

>>> from root_numpy import matrix
>>> from ROOT import TMatrixD
>>> a = TMatrixD(4, 4)
Expand Down
9 changes: 1 addition & 8 deletions root_numpy/_sample.py
Expand Up @@ -7,19 +7,14 @@


def random_sample(root_object, n_samples, seed=None):
"""
Construct a NumPy array from a random sampling of a ROOT function or
histogram.
"""Create a random array by sampling a ROOT function or histogram.

Parameters
----------

root_object : a ROOT function (TF1, TF2, TF3) or histogram (TH1, TH2, TH3)
The ROOT function or histogram to sample.

n_samples : positive int
The number of random samples to generate.

seed : None, positive int or 0, optional (default=None)
The random seed, set via ROOT.gRandom.SetSeed(seed):
http://root.cern.ch/root/html/TRandom3.html#TRandom3:SetSeed
Expand All @@ -28,7 +23,6 @@ def random_sample(root_object, n_samples, seed=None):

Returns
-------

array : a numpy array
A numpy array with a shape corresponding to the dimensionality
of the function or histogram. A flat array is returned when sampling
Expand All @@ -37,7 +31,6 @@ def random_sample(root_object, n_samples, seed=None):

Examples
--------

>>> from root_numpy import random_sample
>>> from ROOT import TF1, TF2, TF3
>>> random_sample(TF1("f1", "TMath::DiLog(x)"), 1E4, seed=1)
Expand Down