GithubHelp home page GithubHelp logo

scikit-hep / root_numpy Goto Github PK

View Code? Open in Web Editor NEW
133.0 23.0 54.0 19.28 MB

The interface between ROOT and NumPy

Home Page: http://scikit-hep.org/root_numpy

License: BSD 3-Clause "New" or "Revised" License

Makefile 1.22% Shell 0.68% Python 53.12% C 0.19% C++ 5.78% TeX 1.39% Cython 37.62%
python root numpy cern cython hep

root_numpy's Introduction

⚠️root_numpy is deprecated and unmaintained⚠️

root_numpy has not been actively maintained or developed in several years. This is mostly due to the emergence of new alternatives which are both faster and more flexible.

root_numpy: The interface between ROOT and NumPy

https://api.travis-ci.org/scikit-hep/root_numpy.png https://coveralls.io/repos/github/scikit-hep/root_numpy/badge.svg?branch=master

[see the full documentation]

root_numpy is a Python extension module that provides an efficient interface between ROOT and NumPy. root_numpy's internals are compiled C++ and can therefore handle large amounts of data much faster than equivalent pure Python implementations.

With your ROOT data in NumPy form, make use of NumPy's broad library, including fancy indexing, slicing, broadcasting, random sampling, sorting, shape transformations, linear algebra operations, and more. See this tutorial to get started. NumPy is the fundamental library of the scientific Python ecosystem. Using NumPy arrays opens up many new possibilities beyond what ROOT offers. Convert your TTrees into NumPy arrays and use SciPy for numerical integration and optimization, matplotlib for plotting, pandas for data analysis, statsmodels for statistical modelling, scikit-learn for machine learning, and perform quick exploratory analysis in a Jupyter notebook.

At the core of root_numpy are powerful and flexible functions for converting ROOT TTrees into structured NumPy arrays as well as converting NumPy arrays back into ROOT TTrees. root_numpy can convert branches of strings and basic types such as bool, int, float, double, etc. as well as variable-length and fixed-length multidimensional arrays and 1D or 2D vectors of basic types and strings. root_numpy can also create columns in the output array that are expressions involving the TTree branches similar to TTree::Draw().

Did we mention that root_numpy is fast?

benchmarks/bench_tree2array.png

root_numpy's People

Contributors

cdeil avatar chrisburr avatar eduardo-rodrigues avatar ibab avatar jheuel avatar konstantinschubert avatar kratsg avatar ndawe avatar piti118 avatar pwaller avatar raymondehlers avatar remenska avatar vvolkl avatar xenoscopic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

root_numpy's Issues

root2array_fromFname doing more work than needed...

ret = root2array_fromTTree(<TTree*>ttree,branches,N,offset) should not be in the for loop:

def root2array_fromFname(fnames, treename, branches, N, offset):
    cdef TChain* ttree = NULL
    try:
        ttree = new TChain(treename)
        for fn in fnames:
            ttree.Add(fn)
            ret = root2array_fromTTree(<TTree*>ttree,branches,N,offset)
    finally:
        del ttree
    return ret

segmentation violation when using root_numpy with matplotlib

I am getting a crash that looks similar to that in #66

I can trigger it with the same 1 line example

python -c 'import ROOT as R; import root_numpy; import matplotlib.pyplot as P; f = R.TMemFile("test.root", "recreate"); P.figure(); P.show()'

I am using
ROOT 5.34.26 built from source
root_numpy built from git cb53ea3 (10 Mar 2015)
matplotlib 1.4.2 from ubuntu python-matplot 1.4.2-3.1 package
on ubuntu 15.04

backtrace

*** Break *** segmentation violation
 Generating stack trace...
 0x00007f8824446b36 in XGetDefault + 0xc6 from /usr/lib/x86_64-linux-gnu/libX11.so.6
 0x00007f88253f7e1f in <unknown> from /usr/lib/x86_64-linux-gnu/libcairo.so.2
 0x00007f88253fa390 in <unknown> from /usr/lib/x86_64-linux-gnu/libcairo.so.2
 0x00007f88253caf77 in cairo_surface_get_font_options + 0x87 from /usr/lib/x86_64-linux-gnu/libcairo.so.2
 0x00007f882538900c in <unknown> from /usr/lib/x86_64-linux-gnu/libcairo.so.2
 0x00007f882538d072 in <unknown> from /usr/lib/x86_64-linux-gnu/libcairo.so.2
 0x00007f882537f1b2 in cairo_glyph_path + 0x22 from /usr/lib/x86_64-linux-gnu/libcairo.so.2
 0x00007f8824766091 in <unknown> from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
 0x00007f882476648f in <unknown> from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
 0x00007f8824b97c59 in pango_renderer_draw_glyphs + 0x39 from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
 0x00007f8824b98648 in pango_renderer_draw_layout_line + 0x4a8 from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
 0x00007f8824b989d5 in pango_renderer_draw_layout + 0x115 from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
 0x00007f882476663a in <unknown> from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
 0x00007f881df73afd in <unknown> from /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
 0x00007f8825a50a49 in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825a5bd1f in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f882643e22f in g_closure_invoke + 0x9f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f882644ff32 in <unknown> from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264581a5 in g_signal_emit_valist + 0xae5 from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264588ff in g_signal_emit + 0x8f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f8825b7361c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259e1478 in gtk_container_propagate_expose + 0x198 from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259dff3c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825a5bd1f in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f882643e22f in g_closure_invoke + 0x9f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f882644ff32 in <unknown> from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264581a5 in g_signal_emit_valist + 0xae5 from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264588ff in g_signal_emit + 0x8f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f8825b7361c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259e1478 in gtk_container_propagate_expose + 0x198 from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825b24d7e in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825a5bd1f in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f882643e22f in g_closure_invoke + 0x9f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f882644ff32 in <unknown> from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264581a5 in g_signal_emit_valist + 0xae5 from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264588ff in g_signal_emit + 0x8f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f8825b7361c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259e1478 in gtk_container_propagate_expose + 0x198 from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259ac86a in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259dff3c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825a5bd1f in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f882643e22f in g_closure_invoke + 0x9f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f882644ff32 in <unknown> from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264581a5 in g_signal_emit_valist + 0xae5 from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264588ff in g_signal_emit + 0x8f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f8825b7361c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259e1478 in gtk_container_propagate_expose + 0x198 from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88259dff3c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825a5bd1f in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f882643e2d5 in g_closure_invoke + 0x145 from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f882644ff32 in <unknown> from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264581a5 in g_signal_emit_valist + 0xae5 from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f88264588ff in g_signal_emit + 0x8f from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
 0x00007f8825b7361c in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825a5aaa2 in gtk_main_do_event + 0x552 from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88256b4bdf in <unknown> from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
 0x00007f88256b16b8 in <unknown> from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
 0x00007f88256b1fe8 in gdk_window_process_all_updates + 0x118 from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
 0x00007f88259dfbd1 in <unknown> from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f8825690dd7 in <unknown> from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
 0x00007f8826fa2b4d in g_main_context_dispatch + 0x15d from /lib/x86_64-linux-gnu/libglib-2.0.so.0
 0x00007f8826fa2f20 in <unknown> from /lib/x86_64-linux-gnu/libglib-2.0.so.0
 0x00007f8826fa3242 in g_main_loop_run + 0xc2 from /lib/x86_64-linux-gnu/libglib-2.0.so.0
 0x00007f8825a59857 in gtk_main + 0xb7 from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
 0x00007f88261224e7 in <unknown> from /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/_gtk.so
 0x00000000004cda58 in PyEval_EvalFrameEx + 0x918 from python
 0x00000000004cbe31 in PyEval_EvalCodeEx + 0x411 from python
 0x00000000004ceeeb in PyEval_EvalFrameEx + 0x1dab from python
 0x00000000004e7ef8 in <unknown> from python
 0x000000000050bb38 in <unknown> from python
 0x00000000005735fd in <unknown> from python
 0x00000000004cf879 in PyEval_EvalFrameEx + 0x2739 from python
 0x00000000004cbe31 in PyEval_EvalCodeEx + 0x411 from python
 0x00000000004ceeeb in PyEval_EvalFrameEx + 0x1dab from python
 0x00000000004cbe31 in PyEval_EvalCodeEx + 0x411 from python
 0x000000000054266a in PyRun_StringFlags + 0x8a from python
 0x000000000054327a in PyRun_SimpleStringFlags + 0x3a from python
 0x000000000049ac82 in Py_Main + 0x3a2 from python
 0x00007f8834f1bec5 in __libc_start_main + 0xf5 from /lib/x86_64-linux-gnu/libc.so.6
 0x000000000049a7f0 in <unknown> from python

Install error on clean, up to date system

Hi,

I'm trying to install root-numpy on a clean, up-to-date system (Ubuntu 14.10) and get the following error, which is something to do with the gcc (11 or not) compiler flags.

https://gist.github.com/alexshires/2481d1368ffb90c2b105

I'm using ROOT6 (trunk) and the following versions:

uname -a
Linux greyarea 3.16.7-x86_64-linode49 #3 SMP Fri Nov 14 16:55:37 EST 2014 x86_64 x86_64 x86_64 GNU/Linux
:$ g++ --version
g++ (Ubuntu 4.9.1-16ubuntu6) 4.9.1
:
$ gcc --version
gcc (Ubuntu 4.9.1-16ubuntu6) 4.9.1
:~$ python --version
Python 2.7.8

Any thoughts on how to resolve this?

Regards,

Alex

impenetrable stack trace

Hi, I am trying root_numpy out of the box on a ROOT ntuple.
It has some complicated structures ( vector< vector >, and similar for float ), but I've removed all those branches in the list I pass to the tree2array() method.

Below is the stack trace I get, if its of any use.

I am running ROOT 5.30/06 on Fedora 16 with Python 2.7

Exception ValueError: 'negative dimensions are not allowed' in '_librootnumpy.create_numpyarray' ignored
Exception ValueError: 'negative dimensions are not allowed' in '_librootnumpy.create_numpyarray' ignored
Exception ValueError: 'negative dimensions are not allowed' in '_librootnumpy.create_numpyarray' ignored
Exception ValueError: 'negative dimensions are not allowed' in '_librootnumpy.create_numpyarray' ignored

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================

Thread 2 (Thread 0x7f05897bd700 (LWP 19503)):
#0  0x00007f0595ef9b70 in sem_wait () from /lib64/libpthread.so.0
#1  0x00007f0596214af5 in PyThread_acquire_lock () from /usr/lib64/libpython2.7.so.1.0
#2  0x00007f05962187c4 in ?? () from /usr/lib64/libpython2.7.so.1.0
#3  0x00007f05961e83db in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#4  0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#5  0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#6  0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#7  0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#8  0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#9  0x00007f0596176093 in ?? () from /usr/lib64/libpython2.7.so.1.0
#10 0x00007f0596151383 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#11 0x00007f05961e476f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#12 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#13 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#14 0x00007f05961e875e in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#15 0x00007f05961e875e in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#16 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#17 0x00007f0596175f9c in ?? () from /usr/lib64/libpython2.7.so.1.0
#18 0x00007f0596151383 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#19 0x00007f059616001f in ?? () from /usr/lib64/libpython2.7.so.1.0
#20 0x00007f0596151383 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#21 0x00007f05961e28f7 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.7.so.1.0
#22 0x00007f0596218b32 in ?? () from /usr/lib64/libpython2.7.so.1.0
#23 0x00007f0595ef3d90 in start_thread () from /lib64/libpthread.so.0
#24 0x00007f059559a19d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f05966bd700 (LWP 19502)):
#0  0x00007f059556663d in waitpid () from /lib64/libc.so.6
#1  0x00007f05954eb6be in do_system () from /lib64/libc.so.6
#2  0x00007f05954ebad0 in system () from /lib64/libc.so.6
#3  0x00007f05883ca48d in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.5.30
#4  0x00007f05883ccd03 in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib64/root/libCore.so.5.30
#5  <signal handler called>
#6  size (this=0x0) at /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/bits/stl_vector.h:571
#7  __pyx_f_13_librootnumpy_21VectorFloat_Converter_write (__pyx_v_self=<optimized out>, __pyx_v_col=<optimized out>, __pyx_v_buffer=0x7f057aefd928) at root_numpy/src/_librootnumpy.cpp:4250
#8  0x00007f057c1de778 in __pyx_f_13_librootnumpy_root2array_fromTTree (__pyx_v_tree=<optimized out>, __pyx_v_branches=0x44b6170, __pyx_v_entries=0x2909c98, __pyx_v_offset=0x21347d0) at root_numpy/src/_librootnumpy.cpp:6216
#9  0x00007f057c1df9c9 in __pyx_pf_13_librootnumpy_10root2array_fromCObj (__pyx_v_offset=0x21347d0, __pyx_v_entries=0x7f05964909c0, __pyx_v_branches=0x398fea8, __pyx_v_tree=<optimized out>, __pyx_self=<optimized out>) at root_numpy/src/_librootnumpy.cpp:6733
#10 __pyx_pw_13_librootnumpy_11root2array_fromCObj (__pyx_self=<optimized out>, __pyx_args=<optimized out>, __pyx_kwds=<optimized out>) at root_numpy/src/_librootnumpy.cpp:6659
#11 0x00007f05961e83db in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#12 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#13 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#14 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#15 0x00007f05961e9ad2 in PyEval_EvalCode () from /usr/lib64/libpython2.7.so.1.0
#16 0x00007f0596203d5c in ?? () from /usr/lib64/libpython2.7.so.1.0
#17 0x00007f0596204b60 in PyRun_FileExFlags () from /usr/lib64/libpython2.7.so.1.0
#18 0x00007f05961e0098 in ?? () from /usr/lib64/libpython2.7.so.1.0
#19 0x00007f05961e7b7d in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#20 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#21 0x00007f0596175f9c in ?? () from /usr/lib64/libpython2.7.so.1.0
#22 0x00007f0596151383 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#23 0x00007f05961e476f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#24 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#25 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#26 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#27 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#28 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#29 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#30 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#31 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#32 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#33 0x00007f0596176093 in ?? () from /usr/lib64/libpython2.7.so.1.0
#34 0x00007f0596151383 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#35 0x00007f05961e476f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#36 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#37 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#38 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#39 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#40 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#41 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#42 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#43 0x00007f05961e9ad2 in PyEval_EvalCode () from /usr/lib64/libpython2.7.so.1.0
#44 0x00007f0596203d5c in ?? () from /usr/lib64/libpython2.7.so.1.0
#45 0x00007f0596204b60 in PyRun_FileExFlags () from /usr/lib64/libpython2.7.so.1.0
#46 0x00007f05962055df in PyRun_SimpleFileExFlags () from /usr/lib64/libpython2.7.so.1.0
#47 0x00007f0596216f15 in Py_Main () from /usr/lib64/libpython2.7.so.1.0
#48 0x00007f05954ca69d in __libc_start_main () from /lib64/libc.so.6
#49 0x0000000000400651 in _start ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6  size (this=0x0) at /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../include/c++/4.6.3/bits/stl_vector.h:571
#7  __pyx_f_13_librootnumpy_21VectorFloat_Converter_write (__pyx_v_self=<optimized out>, __pyx_v_col=<optimized out>, __pyx_v_buffer=0x7f057aefd928) at root_numpy/src/_librootnumpy.cpp:4250
#8  0x00007f057c1de778 in __pyx_f_13_librootnumpy_root2array_fromTTree (__pyx_v_tree=<optimized out>, __pyx_v_branches=0x44b6170, __pyx_v_entries=0x2909c98, __pyx_v_offset=0x21347d0) at root_numpy/src/_librootnumpy.cpp:6216
#9  0x00007f057c1df9c9 in __pyx_pf_13_librootnumpy_10root2array_fromCObj (__pyx_v_offset=0x21347d0, __pyx_v_entries=0x7f05964909c0, __pyx_v_branches=0x398fea8, __pyx_v_tree=<optimized out>, __pyx_self=<optimized out>) at root_numpy/src/_librootnumpy.cpp:6733
#10 __pyx_pw_13_librootnumpy_11root2array_fromCObj (__pyx_self=<optimized out>, __pyx_args=<optimized out>, __pyx_kwds=<optimized out>) at root_numpy/src/_librootnumpy.cpp:6659
#11 0x00007f05961e83db in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#12 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#13 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#14 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#15 0x00007f05961e9ad2 in PyEval_EvalCode () from /usr/lib64/libpython2.7.so.1.0
#16 0x00007f0596203d5c in ?? () from /usr/lib64/libpython2.7.so.1.0
#17 0x00007f0596204b60 in PyRun_FileExFlags () from /usr/lib64/libpython2.7.so.1.0
#18 0x00007f05961e0098 in ?? () from /usr/lib64/libpython2.7.so.1.0
#19 0x00007f05961e7b7d in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#20 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#21 0x00007f0596175f9c in ?? () from /usr/lib64/libpython2.7.so.1.0
#22 0x00007f0596151383 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#23 0x00007f05961e476f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#24 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#25 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#26 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#27 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#28 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#29 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#30 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#31 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#32 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#33 0x00007f0596176093 in ?? () from /usr/lib64/libpython2.7.so.1.0
#34 0x00007f0596151383 in PyObject_Call () from /usr/lib64/libpython2.7.so.1.0
#35 0x00007f05961e476f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#36 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#37 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#38 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#39 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#40 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#41 0x00007f05961e7f03 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.7.so.1.0
#42 0x00007f05961e99a5 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.7.so.1.0
#43 0x00007f05961e9ad2 in PyEval_EvalCode () from /usr/lib64/libpython2.7.so.1.0
#44 0x00007f0596203d5c in ?? () from /usr/lib64/libpython2.7.so.1.0
#45 0x00007f0596204b60 in PyRun_FileExFlags () from /usr/lib64/libpython2.7.so.1.0
#46 0x00007f05962055df in PyRun_SimpleFileExFlags () from /usr/lib64/libpython2.7.so.1.0
#47 0x00007f0596216f15 in Py_Main () from /usr/lib64/libpython2.7.so.1.0
#48 0x00007f05954ca69d in __libc_start_main () from /lib64/libc.so.6
#49 0x0000000000400651 in _start ()
===========================================================

support for object branches

Say you have some branches of objects, like TLorentzVectors, and you want to include something about them in the output array. What if you could pass in a dictionary of [class name] -> [list of functions] and for every branch encountered of type [class name], N=len([list of functions]) columns in the output array would be included and filled with the output of each function called on the object. For example you could pass in a function pt() for TLorentzVectors that would return the transverse momentum:

def pt(v):
    return v.Pt()

and a column with the name of the original object branch suffixed with _pt would be filled with the output of that function. Do you think this would be difficult to implement?

Support expressions in the tree2array branches argument.

I think this should be fairly robust:

for branchname in branches:
    if tree.GetBranch(branchname):
        # handle as usual
    elif # try parsing with TTreeFormula:
        # handle expression columns separately and create double columns for each
    else:
        # complain

Use carray for more efficient memory usage.

https://github.com/FrancescAlted/carray/wiki
http://carray.pytables.org/docs/manual/index.html

At the moment I am converting a 34GB ROOT file containing one huge tree into HDF5 using rootpy's root2hdf5 utility that uses root_numpy. Since root_numpy currently reads everything into memory all at once, I almost hit the end of my 24GB of RAM before swapping (some branches were skipped since they are not basic types). Streaming a chunked carray would be more efficient for large arrays.

remove lt, lb, and lst

I don't think we need to pollute the namespace with these abbreviations. The user can always do this:

from root_numpy import list_branches as lb

Reading in ROOT files with vector <vector<Obj>>

It seems that root_numpy skips over the branches that contain a more complicated data structure (although I'm not sure why it does).

data = rnp.root2rec(filename, treename='%s/%s' % (directory,tree), start=0, stop=1)
/Library/Python/2.7/site-packages/root_numpy/_root_numpy.py:223: RootNumpyUnconvertibleWarning: cannot convert leaf trig_L1_jet_thrNames of branch trig_L1_jet_thrNames with type vector<vector<string> > (skipping)
  weight_name)
/Library/Python/2.7/site-packages/root_numpy/_root_numpy.py:223: RootNumpyUnconvertibleWarning: cannot convert leaf trig_L1_jet_thrValues of branch trig_L1_jet_thrValues with type vector<vector<float> > (skipping)
  weight_name)
/Library/Python/2.7/site-packages/root_numpy/_root_numpy.py:223: RootNumpyUnconvertibleWarning: cannot convert leaf jet_AntiKt10TrackZ_constit_index of branch jet_AntiKt10TrackZ_constit_index with type vector<vector<int> > (skipping)
  weight_name)
/Library/Python/2.7/site-packages/root_numpy/_root_numpy.py:223: RootNumpyUnconvertibleWarning: cannot convert leaf jet_AntiKt10TrackZ_Electron_X of branch jet_AntiKt10TrackZ_Electron_X with type vector<vector<float> > (skipping)
  weight_name)

Expose `get_tree_structure`

https://github.com/rootpy/root_numpy/blob/master/root_numpy/src/tree.pyx#L65-L83

I've got code that will want to grab a list of branches for a given TTree (well a TChain). All current methods require a filename. Probably would be nice to extend the functionality. Perhaps something like updating https://github.com/rootpy/root_numpy/blob/master/root_numpy/_tree.py#L56-L73 to be

def list_branches(*args, **kwargs):
    """Get a list of the branch names of a tree in a ROOT file.
    Parameters
    ----------
    filename : str
        Path to ROOT file.
    treename : str, optional (default=None)
        Name of tree in the ROOT file.
        (optional if the ROOT file has only one tree).
    ==========
    tree : ROOT TTree instance
        The ROOT TTree to list branches of
    Returns
    -------
    branches : list
        List of branch names
    """

    if args[0].Class() in ['TChain', 'TTree']:
        return list(_librootnumpy.get_tree_structure(args[0]))
    elif type(args[0]) is str:
        return _librootnumpy.list_branches(args[0], kwargs.get('treename', None))

Tree with identical leaf names gets copied values from root2hdf5

I have a TTree with struct branches, so that each branch has several leaves with identical names. When I convert a ROOT file containing this TTree to pytables using root2hdf5, all of the leaves have the values from the leaves of the first branch. The following ROOT macro creates a file and tree that demonstrates this.

{
    struct branchstruct {
        int intleaf;
        float floatleaf;
    };  

    TFile *f = new TFile("test.root", "RECREATE");
    TTree *t = new TTree("test", "Test tree with identical leaf names in different branches");

    branchstruct *br1 = new branchstruct;
    branchstruct *br2 = new branchstruct;

    br1->intleaf = 10;
    br1->floatleaf = 15.5;

    br2->intleaf = 20;
    br2->floatleaf = 781.2;

    t->Branch("branch1", br1, "intleaf/I:floatleaf/F");
    t->Branch("branch2", br2, "intleaf/I:floatleaf/F");

    t->Fill();

    t->Write();
    f->Close();
}
$ root -b -q test.C
$ root2hdf5 test.root
$ vitables test.h5

Then the table in test.h5 has four columns and one row:

branch1_intleaf 10
branch1_floatleaf 15.5
branch2_intleaf 10
branch2_floatleaf 15.5

branch2 should have had values 20 and 781.2 instead of 10 and 15.5.

scipy and root_numpy do not play well

When I import scipy.special:

>>> import scipy.special
>>>

No errors are generated. But when I import root_numpy first:

>>> import root_numpy
>>> import scipy.special
/Library/Python/2.7/site-packages/numpy/oldnumeric/__init__.py:11: ModuleDeprecationWarning: The oldnumeric module will be dropped in Numpy 1.9
  warnings.warn(_msg, ModuleDeprecationWarning)
>>> root_numpy.__version__
'3.1.0'
>>> scipy.__version__
'0.13.2'

However, reversing the order of imports

>>> import scipy.special
>>> import root_numpy
>>> root_numpy.__version__
'3.1.0'
>>> scipy.__version__
'0.13.2'

Both scipy and root_numpy were installed via pip.

Read from remote root file

I try to use root_numpy for reading remote root file

filename = 'root://eospublic.cern.ch//eos/opendata/cms/Run2010B/Mu/AOD/Apr21ReReco-v1/0000/00459D48-EB70-E011-AF09-90E6BA19A252.root'
root_numpy.list_trees(filename)

And I got the error:
ERROR:ROOT.TUnixSystem.DynamicPathName:Netx[.so | .dll | .dylib | .sl | .dl | .a] does not exist in /usr/local/lib/root:.:/usr/local/lib/root::/usr/local/lib/root/cint/cint/stl

Is it possible read it? TChain correctly read the root file.

Mac OS X 10.7 gets targeted as 10.4 during build, fails.

This is perhaps a disutils issue. The Extensions could not be built because of a targeting misunderstanding. Oddly enough, if one attempts to build three times (allowed to fail for each of the three extensions librootnumpy, libnumpyhist, libinnerjoin), the build process reports things are up to date and finishes.

    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.4-x86_64-2.7
    creating build/lib.macosx-10.4-x86_64-2.7/root_numpy
    copying root_numpy/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy
    copying root_numpy/info.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy
    copying root_numpy/root_numpy.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy
    copying root_numpy/root_numpy_warnings.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy
    copying root_numpy/tests.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy
    copying root_numpy/utils.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy
    creating build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    creating build/lib.macosx-10.4-x86_64-2.7/root_numpy/extern
    copying root_numpy/extern/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/extern
    copying root_numpy/extern/ordereddict.py -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/extern
    copying root_numpy/testdata/doubletree1.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/fixed1.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/fixed2.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/hvector.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/single1.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/single2.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/sprtest.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/structbranches.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/test.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/vary1.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    copying root_numpy/testdata/vary2.root -> build/lib.macosx-10.4-x86_64-2.7/root_numpy/testdata
    running build_ext
    building 'root_numpy._librootnumpy' extension
    creating build/temp.macosx-10.4-x86_64-2.7
    creating build/temp.macosx-10.4-x86_64-2.7/root_numpy
    creating build/temp.macosx-10.4-x86_64-2.7/root_numpy/src
    gcc -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/me/Documents/Programs/envs/research/lib/python2.7/site-packages/numpy/core/include -I/Users/me/School/Research/Software/root/include -Iroot_numpy/src -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c root_numpy/src/_librootnumpy.cpp -o build/temp.macosx-10.4-x86_64-2.7/root_numpy/src/_librootnumpy.o
    cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
    root_numpy/src/_librootnumpy.cpp: In function ‘PyObject* newarrayobject(PyTypeObject*, Py_ssize_t, arraydescr*)’:
    root_numpy/src/_librootnumpy.cpp:1301: warning: deprecated conversion from string constant to ‘char*’
    root_numpy/src/_librootnumpy.cpp: In function ‘TTree* __pyx_f_13_librootnumpy_array2tree(PyArrayObject*, __pyx_opt_args_13_librootnumpy_array2tree*)’:
    root_numpy/src/_librootnumpy.cpp:7949: warning: comparison between signed and unsigned integer expressions
    /Users/me/Documents/Programs/envs/research/lib/python2.7/site-packages/numpy/core/include/numpy/__ufunc_api.h: At global scope:
    /Users/me/Documents/Programs/envs/research/lib/python2.7/site-packages/numpy/core/include/numpy/__ufunc_api.h:226: warning: ‘int _import_umath()’ defined but not used
    g++ -bundle -undefined dynamic_lookup build/temp.macosx-10.4-x86_64-2.7/root_numpy/src/_librootnumpy.o -o build/lib.macosx-10.4-x86_64-2.7/root_numpy/_librootnumpy.so -L/Users/me/School/Research/Software/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -Wl,-rpath,/Users/me/School/Research/Software/root/lib -lm -ldl -lTreePlayer
    ld: -rpath can only be used when targeting Mac OS X 10.5 or later
    collect2: ld returned 1 exit status
    error: command 'g++' failed with exit status 1

root_numpy.tmva doesn't work without factory.PrepareTrainingAndTestTree

Hello!

I'm experimenting with tmva-related functions, try to run this example https://github.com/rootpy/root_numpy/blob/master/examples/tmva/plot_twoclass.py. It works. But I don't want to use factory.PrepareTrainingAndTestTree (as you can see I don't use it here https://github.com/yandex/rep/blob/master/rep/estimators/_tmvaFactory.py). To clarify, if I don't use it:

add_classification_events(factory, X_train, y_train, weights=w_train) # add all data for training
add_classification_events(factory, X_test, y_test, weights=w_test, test=True) #add all data for testing

In this case I get an error during training: ' <FATAL> Factory: No input data for the training provided!' ***> abort program execution

Maybe I can just add training data by

add_classification_events(factory, X_train, y_train, weights=w_train) # add all data for training

without adding test and without using factory.PrepareTrainingAndTestTree? (in the latter case the same fatal error arises)

I don't know much details about TMVA implementations, so probably there exist some simple solution.

release 2.1.0

I think we are in a position to release 2.1.0. What do you think @piti118? Then in rootpy I can make use of the new selection capabilities. I think the changes wrt the previous release justify a bump to 2.1.0 instead of 2.0.5. Do you agree?

Bootstrap installation of numpy in setup.py if it is not already installed

Hello,

I use root_numpy in a package of my own and want to make it possible to install it with pip. But the installation fails due to your import of numpy in the setup.py.

Is it possible to not import the package dependency in the setup.py so I don't have to install numpy by hand before?

Cheers
ziggi

Update installation to work with XCode 5.1.1 (breaking functionality)

Currently, sudo pip install root_numpy leads to the following (recently reported error among lots of packages)

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/local/Cellar/root/5.34.18/include/root -Iroot_numpy/src -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c root_numpy/src/_librootnumpy.cpp -o build/temp.macosx-10.9-intel-2.7/root_numpy/src/_librootnumpy.o

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

The current fix is to pass in flags:

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install root_numpy

which downgrades the error to a warning for now. More information is found in the release notes

Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:
-Wno-error=unused-command-line-argument-hard-error-in-future
Note: This option will not be supported in the future.
To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning. For example, you can install a Python native extension with:
$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install ExtensionName

root2array should disable glob for network files

When using XrootD or other network-based protocols to access ROOT files (e.g. on CERN's EOS) root2array fails because glob is not aware of how to handle the corresponding URLs and consequently returns an empty list.

Perhaps a check can be added before the glob call so that if the URL starts with a protocol supported by TFile::Open (e.g. root:, roots:, rootk:, http:) the glob step is skipped and the URL is just used directly. In the case if file:-prefixed URLs, glob may still be possible, but the URL will need to be adjusted.

This may pervade beyond root2array, this is just the only use case that I have had trouble with.

The obvious alternative is to use tree2array, but then one has to manually TChain files, and the fix here would save a lot of headache, especially since root2array's underlying implementation already correctly uses TFile::Open, supporting network-based access.

array2tree?

I dreamt about root_numpy last night (lame dream, I know...) but I imagined there was a way to convert a NumPy structured array back into a TTree. I think the signature should look something like this:

def array2tree(array, tree=None):

If tree is None, a new TTree is created (name it with a UUID) and branches for all array columns are created and filled. If tree is a TTree then existing branches with the same name as a field in the structured array will be extended and new branches will be created and filled for those fields that don't already exist as branches.

If tree was None then return the created TTree otherwise just return None (no return at all).

sudo install does not guarantee to have ROOTSYS set

When building the package, one needs ROOTSYS to be set. The problem is that when doing sudo python setup.py install, ROOTSYS is not preserved by sudo, and so I get :
cohen@arago:/sources/python/root_numpy$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 45, in
"root-config is not in PATH and ROOTSYS is not set. "
RuntimeError: root-config is not in PATH and ROOTSYS is not set. Is ROOT installed and setup properly?
cohen@arago:
/sources/python/root_numpy$ which root-config
/home/cohen/sources/root-svn/bin/root-config
cohen@arago:~/sources/python/root_numpy$ echo $ROOTSYS
/home/cohen/sources/root-svn

I am surprised that I did not have this problem with other python packages though

user defined ROOTSYS ignored

Hi,
I have a system with 2 versions of ROOT installed. Older one in /usr/local provided by package manager, and a new one installed from source in /opt/root5 which I use by default (environment setup in .bashrc).

_librootnumpy.so linked against the old version regardless of my settings
I tried the suggested:

sudo ROOTSYS=$ROOTSYS python setup.py install

which did not work

I tracked down the reason to the setup.py, line 47-48:

try:
    root_cflags, root_ldflags = root_flags()

This line finds the old version of root-config in PATH.
As a quick fix I put '/opt/root5/bin/root-config' as argument to the function. The flags are then correct.

In summary: in setup.py ROOTSYS environment variable does not take precedence over default ROOT installation.

p.s. my old version of root 5.34/00 resulted in the following error when trying to use function tree2rec:
*** glibc detected *** python: double free or corruption
new ROOT version 5.34/25 works fine

root_numpy.tmva: kCuts method requires to add Signal tree at first

I noticed some problem with kCuts methods, tested in REP using root_numpy.tmva. When

--- DataSetInfo              : Class index : 0  name : Signal
--- DataSetInfo              : Class index : 1  name : Background

test is ok (Signal tree was added at first):

--- Factory                  : You are running ROOT Version: 5.34/20, Aug 12, 2014
--- Factory                  : 
--- Factory                  : _/_/_/_/_/ _|      _|  _|      _|    _|_|   
--- Factory                  :    _/      _|_|  _|_|  _|      _|  _|    _| 
--- Factory                  :   _/       _|  _|  _|  _|      _|  _|_|_|_| 
--- Factory                  :  _/        _|      _|    _|  _|    _|    _| 
--- Factory                  : _/         _|      _|      _|      _|    _| 
--- Factory                  : 
--- Factory                  : ___________TMVA Version 4.2.0, Sep 19, 2013
--- Factory                  : 
--- DataSetInfo              : Added class "Signal"      with internal class number 0
--- DataSetInfo              : Added class "Background"  with internal class number 1
--- Factory                  : Add Tree TrainAssignTree_Signal of type Signal with 1001 events
--- Factory                  : Add Tree TestAssignTree_Signal of type Signal with 1001 events
--- Factory                  : Add Tree TrainAssignTree_Background of type Background with 1001 events
--- Factory                  : Add Tree TestAssignTree_Background of type Background with 1001 events
--- DataSetInfo              : Class index : 0  name : Signal
--- DataSetInfo              : Class index : 1  name : Background
--- Factory                  : Booking method: REP_Estimator
--- REP_Estimator            : Use optimization method: "Genetic Algorithm"
--- REP_Estimator            : Use efficiency computation method: "Event Selection"
--- DataSetFactory           : Splitmode is: "RANDOM" the mixmode is: "SAMEASSPLITMODE"
--- DataSetFactory           : Create training and testing trees -- looping over class "Signal" ...
--- DataSetFactory           : Weight expression for class 'Signal': "weight"
--- DataSetFactory           : Create training and testing trees -- looping over class "Background" ...
--- DataSetFactory           : Weight expression for class 'Background': "weight"
--- DataSetFactory           : Number of events in input trees (after possible flattening of arrays):
--- DataSetFactory           :     Signal          -- number of events       : 2002   / sum of weights: 2002 
--- DataSetFactory           :     Background      -- number of events       : 2002   / sum of weights: 2002 
--- DataSetFactory           :     Signal     tree -- total number of entries: 2002 
--- DataSetFactory           :     Background tree -- total number of entries: 2002 
--- DataSetFactory           : Preselection: (will NOT affect number of requested training and testing events)
--- DataSetFactory           :     Signal     requirement: "1"
--- DataSetFactory           :     Signal          -- number of events passed: 2002   / sum of weights: 2002 
--- DataSetFactory           :     Signal          -- efficiency             : 1     
--- DataSetFactory           :     Background requirement: "1"
--- DataSetFactory           :     Background      -- number of events passed: 2002   / sum of weights: 2002 
--- DataSetFactory           :     Background      -- efficiency             : 1     
--- DataSetFactory           : Weight renormalisation mode: "EqualNumEvents": renormalises all event classes ...
--- DataSetFactory           :  such that the effective (weighted) number of events in each class is the same 
--- DataSetFactory           :  (and equals the number of events (entries) given for class=0 )
--- DataSetFactory           : ... i.e. such that Sum[i=1..N_j]{w_i} = N_classA, j=classA, classB, ...
--- DataSetFactory           : ... (note that N_j is the sum of TRAINING events
--- DataSetFactory           :  ..... Testing events are not renormalised nor included in the renormalisation factor!)
--- DataSetFactory           : --> Rescale Signal     event weights by factor: 1
--- DataSetFactory           : --> Rescale Background event weights by factor: 1
--- DataSetFactory           : Number of training and testing events after rescaling:
--- DataSetFactory           : ------------------------------------------------------
--- DataSetFactory           : Signal     -- training events            : 1001 (sum of weights: 1001) - requested were 0 events
--- DataSetFactory           : Signal     -- testing events             : 1001 (sum of weights: 1001) - requested were 0 events
--- DataSetFactory           : Signal     -- training and testing events: 2002 (sum of weights: 2002)
--- DataSetFactory           : Background -- training events            : 1001 (sum of weights: 1001) - requested were 0 events
--- DataSetFactory           : Background -- testing events             : 1001 (sum of weights: 1001) - requested were 0 events
--- DataSetFactory           : Background -- training and testing events: 2002 (sum of weights: 2002)
--- DataSetFactory           : Create internal training tree
--- DataSetFactory           : Create internal testing tree
--- DataSetInfo              : Correlation matrix (Signal):
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetInfo              :           column0 column1 column2 column3 column4 column5 column6 column7 column8 column9 column10 column11 column12 column13 column14
--- DataSetInfo              :  column0:  +1.000  +0.036  -0.015  +0.030  +0.010  +0.001  +0.011  +0.021  -0.011  -0.011   -0.000   -0.009   +0.089   +0.049   -0.022
--- DataSetInfo              :  column1:  +0.036  +1.000  +0.025  +0.031  -0.008  -0.030  -0.013  -0.005  -0.013  +0.009   +0.000   +0.028   +0.025   +0.046   -0.050
--- DataSetInfo              :  column2:  -0.015  +0.025  +1.000  -0.006  -0.006  -0.034  -0.006  -0.003  +0.017  -0.057   +0.043   -0.028   -0.023   +0.005   -0.005
--- DataSetInfo              :  column3:  +0.030  +0.031  -0.006  +1.000  -0.040  -0.021  +0.032  +0.038  -0.058  +0.046   +0.022   +0.013   +0.031   -0.007   -0.029
--- DataSetInfo              :  column4:  +0.010  -0.008  -0.006  -0.040  +1.000  +0.058  -0.037  +0.055  +0.002  +0.005   +0.020   -0.003   -0.017   -0.012   +0.036
--- DataSetInfo              :  column5:  +0.001  -0.030  -0.034  -0.021  +0.058  +1.000  -0.029  -0.046  +0.003  +0.017   +0.005   +0.044   +0.023   -0.027   +0.046
--- DataSetInfo              :  column6:  +0.011  -0.013  -0.006  +0.032  -0.037  -0.029  +1.000  -0.012  -0.013  -0.056   -0.001   -0.053   -0.060   +0.035   +0.006
--- DataSetInfo              :  column7:  +0.021  -0.005  -0.003  +0.038  +0.055  -0.046  -0.012  +1.000  -0.039  +0.007   -0.002   -0.029   -0.002   -0.031   -0.006
--- DataSetInfo              :  column8:  -0.011  -0.013  +0.017  -0.058  +0.002  +0.003  -0.013  -0.039  +1.000  -0.015   +0.026   +0.020   +0.054   +0.005   +0.004
--- DataSetInfo              :  column9:  -0.011  +0.009  -0.057  +0.046  +0.005  +0.017  -0.056  +0.007  -0.015  +1.000   +0.000   +0.049   -0.024   -0.035   +0.069
--- DataSetInfo              : column10:  -0.000  +0.000  +0.043  +0.022  +0.020  +0.005  -0.001  -0.002  +0.026  +0.000   +1.000   +0.033   -0.058   +0.024   +0.003
--- DataSetInfo              : column11:  -0.009  +0.028  -0.028  +0.013  -0.003  +0.044  -0.053  -0.029  +0.020  +0.049   +0.033   +1.000   -0.030   -0.001   +0.009
--- DataSetInfo              : column12:  +0.089  +0.025  -0.023  +0.031  -0.017  +0.023  -0.060  -0.002  +0.054  -0.024   -0.058   -0.030   +1.000   -0.014   -0.032
--- DataSetInfo              : column13:  +0.049  +0.046  +0.005  -0.007  -0.012  -0.027  +0.035  -0.031  +0.005  -0.035   +0.024   -0.001   -0.014   +1.000   +0.003
--- DataSetInfo              : column14:  -0.022  -0.050  -0.005  -0.029  +0.036  +0.046  +0.006  -0.006  +0.004  +0.069   +0.003   +0.009   -0.032   +0.003   +1.000
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetInfo              : Correlation matrix (Background):
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetInfo              :           column0 column1 column2 column3 column4 column5 column6 column7 column8 column9 column10 column11 column12 column13 column14
--- DataSetInfo              :  column0:  +1.000  +0.018  +0.009  -0.064  +0.020  -0.013  +0.041  -0.010  -0.005  +0.015   +0.038   -0.052   -0.028   +0.029   +0.025
--- DataSetInfo              :  column1:  +0.018  +1.000  -0.028  +0.005  +0.006  +0.027  -0.050  -0.061  -0.030  -0.039   +0.016   +0.019   -0.016   +0.030   +0.039
--- DataSetInfo              :  column2:  +0.009  -0.028  +1.000  -0.006  +0.016  -0.011  +0.031  +0.032  +0.015  +0.074   -0.015   +0.056   -0.002   -0.037   +0.006
--- DataSetInfo              :  column3:  -0.064  +0.005  -0.006  +1.000  -0.036  +0.054  -0.012  +0.030  -0.048  +0.023   -0.016   +0.069   -0.026   -0.022   -0.011
--- DataSetInfo              :  column4:  +0.020  +0.006  +0.016  -0.036  +1.000  -0.012  +0.060  +0.008  -0.032  +0.047   +0.034   +0.062   -0.049   -0.010   -0.022
--- DataSetInfo              :  column5:  -0.013  +0.027  -0.011  +0.054  -0.012  +1.000  -0.030  +0.016  +0.021  +0.064   +0.033   -0.019   +0.004   -0.015   -0.023
--- DataSetInfo              :  column6:  +0.041  -0.050  +0.031  -0.012  +0.060  -0.030  +1.000  +0.022  -0.007  +0.046   +0.030   +0.006   -0.011   -0.028   -0.024
--- DataSetInfo              :  column7:  -0.010  -0.061  +0.032  +0.030  +0.008  +0.016  +0.022  +1.000  +0.005  -0.006   -0.006   +0.022   -0.046   -0.025   -0.003
--- DataSetInfo              :  column8:  -0.005  -0.030  +0.015  -0.048  -0.032  +0.021  -0.007  +0.005  +1.000  -0.009   +0.045   +0.009   -0.032   +0.029   +0.012
--- DataSetInfo              :  column9:  +0.015  -0.039  +0.074  +0.023  +0.047  +0.064  +0.046  -0.006  -0.009  +1.000   +0.058   -0.043   -0.019   -0.024   +0.022
--- DataSetInfo              : column10:  +0.038  +0.016  -0.015  -0.016  +0.034  +0.033  +0.030  -0.006  +0.045  +0.058   +1.000   +0.003   +0.036   -0.020   +0.056
--- DataSetInfo              : column11:  -0.052  +0.019  +0.056  +0.069  +0.062  -0.019  +0.006  +0.022  +0.009  -0.043   +0.003   +1.000   +0.023   +0.017   +0.017
--- DataSetInfo              : column12:  -0.028  -0.016  -0.002  -0.026  -0.049  +0.004  -0.011  -0.046  -0.032  -0.019   +0.036   +0.023   +1.000   +0.001   +0.003
--- DataSetInfo              : column13:  +0.029  +0.030  -0.037  -0.022  -0.010  -0.015  -0.028  -0.025  +0.029  -0.024   -0.020   +0.017   +0.001   +1.000   +0.032
--- DataSetInfo              : column14:  +0.025  +0.039  +0.006  -0.011  -0.022  -0.023  -0.024  -0.003  +0.012  +0.022   +0.056   +0.017   +0.003   +0.032   +1.000
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetFactory           :  
--- Factory                  : 
--- Factory                  : current transformation string: 'I'
--- Factory                  : Create Transformation "I" with events from all classes.
--- Id                       : Transformation, Variable selection : 
--- Id                       : Input : variable 'column0' (index=0).   <---> Output : variable 'column0' (index=0).
--- Id                       : Input : variable 'column1' (index=1).   <---> Output : variable 'column1' (index=1).
--- Id                       : Input : variable 'column2' (index=2).   <---> Output : variable 'column2' (index=2).
--- Id                       : Input : variable 'column3' (index=3).   <---> Output : variable 'column3' (index=3).
--- Id                       : Input : variable 'column4' (index=4).   <---> Output : variable 'column4' (index=4).
--- Id                       : Input : variable 'column5' (index=5).   <---> Output : variable 'column5' (index=5).
--- Id                       : Input : variable 'column6' (index=6).   <---> Output : variable 'column6' (index=6).
--- Id                       : Input : variable 'column7' (index=7).   <---> Output : variable 'column7' (index=7).
--- Id                       : Input : variable 'column8' (index=8).   <---> Output : variable 'column8' (index=8).
--- Id                       : Input : variable 'column9' (index=9).   <---> Output : variable 'column9' (index=9).
--- Id                       : Input : variable 'column10' (index=10).   <---> Output : variable 'column10' (index=10).
--- Id                       : Input : variable 'column11' (index=11).   <---> Output : variable 'column11' (index=11).
--- Id                       : Input : variable 'column12' (index=12).   <---> Output : variable 'column12' (index=12).
--- Id                       : Input : variable 'column13' (index=13).   <---> Output : variable 'column13' (index=13).
--- Id                       : Input : variable 'column14' (index=14).   <---> Output : variable 'column14' (index=14).
--- Id                       : Preparing the Identity transformation...
--- TFHandler_Factory        : -----------------------------------------------------------
--- TFHandler_Factory        : Variable        Mean        RMS   [        Min        Max ]
--- TFHandler_Factory        : -----------------------------------------------------------
--- TFHandler_Factory        :  column0:    0.76153     1.3030   [    -3.4212     4.8727 ]
--- TFHandler_Factory        :  column1:    0.74124     1.2400   [    -2.8975     4.8141 ]
--- TFHandler_Factory        :  column2:    0.75649     1.2493   [    -2.9133     4.4100 ]
--- TFHandler_Factory        :  column3:    0.70198     1.2468   [    -2.7344     5.2300 ]
--- TFHandler_Factory        :  column4:    0.79106     1.2641   [    -3.1572     5.3259 ]
--- TFHandler_Factory        :  column5:    0.75823     1.2274   [    -2.7462     4.4507 ]
--- TFHandler_Factory        :  column6:    0.75727     1.2315   [    -2.7784     4.4573 ]
--- TFHandler_Factory        :  column7:    0.74547     1.2429   [    -3.0140     4.5693 ]
--- TFHandler_Factory        :  column8:    0.74392     1.2137   [    -3.5081     4.5480 ]
--- TFHandler_Factory        :  column9:    0.73361     1.2851   [    -3.2943     4.9917 ]
--- TFHandler_Factory        : column10:    0.75179     1.2790   [    -3.4516     4.8086 ]
--- TFHandler_Factory        : column11:    0.77597     1.2855   [    -3.1242     4.8678 ]
--- TFHandler_Factory        : column12:    0.72895     1.2172   [    -3.3080     4.5352 ]
--- TFHandler_Factory        : column13:    0.75342     1.2671   [    -3.1352     4.9680 ]
--- TFHandler_Factory        : column14:    0.73740     1.2641   [    -3.1024     4.9320 ]
--- TFHandler_Factory        : -----------------------------------------------------------
--- TFHandler_Factory        : Plot event variables for Id
--- TFHandler_Factory        : Create scatter and profile plots in target-file directory: 
--- TFHandler_Factory        : /Users/antares/code/public_rep/rep/tests/tmp1x4zov/result.root:/InputVariables_Id/CorrelationPlots
--- TFHandler_Factory        :  
--- TFHandler_Factory        : Ranking input variables (method unspecific)...
--- IdTransformation         : Ranking result (top variable is best ranked)
--- IdTransformation         : ---------------------------------
--- IdTransformation         : Rank : Variable  : Separation
--- IdTransformation         : ---------------------------------
--- IdTransformation         :    1 : column4   : 4.160e-01
--- IdTransformation         :    2 : column0   : 4.066e-01
--- IdTransformation         :    3 : column9   : 4.046e-01
--- IdTransformation         :    4 : column3   : 4.011e-01
--- IdTransformation         :    5 : column10  : 3.972e-01
--- IdTransformation         :    6 : column6   : 3.909e-01
--- IdTransformation         :    7 : column1   : 3.907e-01
--- IdTransformation         :    8 : column13  : 3.906e-01
--- IdTransformation         :    9 : column7   : 3.809e-01
--- IdTransformation         :   10 : column11  : 3.806e-01
--- IdTransformation         :   11 : column14  : 3.784e-01
--- IdTransformation         :   12 : column12  : 3.777e-01
--- IdTransformation         :   13 : column5   : 3.765e-01
--- IdTransformation         :   14 : column8   : 3.757e-01
--- IdTransformation         :   15 : column2   : 3.631e-01
--- IdTransformation         : ---------------------------------
--- Factory                  :  
--- Factory                  : Train all methods for Classification ...
--- Factory                  : Train method: REP_Estimator for Classification
--- REP_Estimator            : Begin training
--- FitterBase               : <GeneticFitter> Optimisation, please be patient ... (inaccurate progress timing for GA)
--- FitterBase               : Elapsed time: 8.85 sec                             
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.1
--- REP_Estimator            : Corresponding background efficiency       : 0
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   -3.35867 <  column0 <=    3.58339
--- REP_Estimator            : Cut[ 1]:   -1.31708 <  column1 <=    2.23987
--- REP_Estimator            : Cut[ 2]:   0.576928 <  column2 <=    5.24782
--- REP_Estimator            : Cut[ 3]:   -1.05121 <  column3 <=    5.97134
--- REP_Estimator            : Cut[ 4]:   -1.09149 <  column4 <=    3.51565
--- REP_Estimator            : Cut[ 5]:  -0.977245 <  column5 <=    3.44292
--- REP_Estimator            : Cut[ 6]:  -0.885013 <  column6 <=    1.29957
--- REP_Estimator            : Cut[ 7]: -0.0281787 <  column7 <=    4.49364
--- REP_Estimator            : Cut[ 8]:  -0.779595 <  column8 <=    6.79705
--- REP_Estimator            : Cut[ 9]:    1.38359 <  column9 <=    4.89728
--- REP_Estimator            : Cut[10]:   -1.58167 < column10 <=    6.84177
--- REP_Estimator            : Cut[11]:   0.257146 < column11 <=    7.14402
--- REP_Estimator            : Cut[12]:   -0.72962 < column12 <=    4.08584
--- REP_Estimator            : Cut[13]:  -0.762941 < column13 <=    6.19841
--- REP_Estimator            : Cut[14]:   -1.52765 < column14 <=    5.03806
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.2
--- REP_Estimator            : Corresponding background efficiency       : 0
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   0.460298 <  column0 <=    5.13959
--- REP_Estimator            : Cut[ 1]:   -1.63769 <  column1 <=    5.67844
--- REP_Estimator            : Cut[ 2]:   -1.36761 <  column2 <=    3.17644
--- REP_Estimator            : Cut[ 3]:  0.0399832 <  column3 <=    3.98967
--- REP_Estimator            : Cut[ 4]:    -2.5388 <  column4 <=    4.49502
--- REP_Estimator            : Cut[ 5]: -0.0858669 <  column5 <=    5.88106
--- REP_Estimator            : Cut[ 6]:    0.92561 <  column6 <=    4.14842
--- REP_Estimator            : Cut[ 7]:  -0.167568 <  column7 <=    7.54516
--- REP_Estimator            : Cut[ 8]:   -1.81097 <  column8 <=     1.9465
--- REP_Estimator            : Cut[ 9]:  -0.176329 <  column9 <=     3.0575
--- REP_Estimator            : Cut[10]:    -3.2843 < column10 <=    4.13585
--- REP_Estimator            : Cut[11]:   0.671112 < column11 <=    3.20892
--- REP_Estimator            : Cut[12]:   -0.26806 < column12 <=    5.06208
--- REP_Estimator            : Cut[13]:  0.0504376 < column13 <=    6.73097
--- REP_Estimator            : Cut[14]:  -0.505344 < column14 <=    4.28214
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.3
--- REP_Estimator            : Corresponding background efficiency       : 0
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   -2.67663 <  column0 <=    2.97476
--- REP_Estimator            : Cut[ 1]:  -0.114162 <  column1 <=    3.44278
--- REP_Estimator            : Cut[ 2]:   0.828413 <  column2 <=    6.35531
--- REP_Estimator            : Cut[ 3]:   0.626161 <  column3 <=    8.40812
--- REP_Estimator            : Cut[ 4]:   -1.71335 <  column4 <=    4.03778
--- REP_Estimator            : Cut[ 5]:   0.109503 <  column5 <=    3.65579
--- REP_Estimator            : Cut[ 6]:   -0.61765 <  column6 <=    5.43113
--- REP_Estimator            : Cut[ 7]:  -0.976011 <  column7 <=    3.54581
--- REP_Estimator            : Cut[ 8]:   -2.39815 <  column8 <=    4.85061
--- REP_Estimator            : Cut[ 9]:   -1.48334 <  column9 <=    5.57272
--- REP_Estimator            : Cut[10]:   -2.98131 < column10 <=    5.12431
--- REP_Estimator            : Cut[11]:  -0.417723 < column11 <=    3.22566
--- REP_Estimator            : Cut[12]:  -0.127359 < column12 <=    3.93513
--- REP_Estimator            : Cut[13]:  -0.762941 < column13 <=    6.35348
--- REP_Estimator            : Cut[14]:  0.0529051 < column14 <=    3.43641
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.4
--- REP_Estimator            : Corresponding background efficiency       : 0
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   0.437409 <  column0 <=    7.54535
--- REP_Estimator            : Cut[ 1]:   -1.89198 <  column1 <=    4.49034
--- REP_Estimator            : Cut[ 2]:   -1.27795 <  column2 <=     5.5597
--- REP_Estimator            : Cut[ 3]:   -2.52326 <  column3 <=    4.19504
--- REP_Estimator            : Cut[ 4]:   -1.14162 <  column4 <=    7.28334
--- REP_Estimator            : Cut[ 5]:  -0.153019 <  column5 <=    5.47804
--- REP_Estimator            : Cut[ 6]:   -0.61765 <  column6 <=    4.31929
--- REP_Estimator            : Cut[ 7]:   0.757497 <  column7 <=    6.64971
--- REP_Estimator            : Cut[ 8]:   -1.47453 <  column8 <=    5.14569
--- REP_Estimator            : Cut[ 9]:  -0.909489 <  column9 <=     3.3405
--- REP_Estimator            : Cut[10]:  -0.402431 < column10 <=    6.82126
--- REP_Estimator            : Cut[11]:   0.748555 < column11 <=     3.8234
--- REP_Estimator            : Cut[12]:  -0.178288 < column12 <=    7.27367
--- REP_Estimator            : Cut[13]:   -2.56767 < column13 <=    4.54188
--- REP_Estimator            : Cut[14]:  -0.664374 < column14 <=    4.54496
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.5
--- REP_Estimator            : Corresponding background efficiency       : 0.000999001
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   -3.38811 <  column0 <=    4.07873
--- REP_Estimator            : Cut[ 1]:   -1.15135 <  column1 <=    4.62611
--- REP_Estimator            : Cut[ 2]:  -0.254224 <  column2 <=    5.31208
--- REP_Estimator            : Cut[ 3]:  -0.997454 <  column3 <=    4.26101
--- REP_Estimator            : Cut[ 4]:  -0.156509 <  column4 <=    6.41843
--- REP_Estimator            : Cut[ 5]:  -0.913037 <  column5 <=    6.03545
--- REP_Estimator            : Cut[ 6]:   -1.13086 <  column6 <=    4.18068
--- REP_Estimator            : Cut[ 7]: 0.00195074 <  column7 <=    4.13688
--- REP_Estimator            : Cut[ 8]:  -0.854785 <  column8 <=    6.33286
--- REP_Estimator            : Cut[ 9]:  -0.636598 <  column9 <=    4.28174
--- REP_Estimator            : Cut[10]:  -0.748177 < column10 <=    7.37741
--- REP_Estimator            : Cut[11]:  -0.156596 < column11 <=    6.72979
--- REP_Estimator            : Cut[12]:  -0.232745 < column12 <=    5.26344
--- REP_Estimator            : Cut[13]:   -2.22146 < column13 <=    3.90353
--- REP_Estimator            : Cut[14]:   0.914777 < column14 <=    8.77157
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.6
--- REP_Estimator            : Corresponding background efficiency       : 0.00599401
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   -3.00082 <  column0 <=    4.86387
--- REP_Estimator            : Cut[ 1]:  -0.382376 <  column1 <=     6.8242
--- REP_Estimator            : Cut[ 2]:   -1.27795 <  column2 <=    3.69415
--- REP_Estimator            : Cut[ 3]:  -0.578648 <  column3 <=    6.27879
--- REP_Estimator            : Cut[ 4]: -0.00908183 <  column4 <=    7.63818
--- REP_Estimator            : Cut[ 5]:   -1.95323 <  column5 <=    4.99526
--- REP_Estimator            : Cut[ 6]:   -1.57944 <  column6 <=    4.01577
--- REP_Estimator            : Cut[ 7]:  -0.988106 <  column7 <=    4.79435
--- REP_Estimator            : Cut[ 8]:   -1.33864 <  column8 <=    5.33811
--- REP_Estimator            : Cut[ 9]:   -1.68495 <  column9 <=    3.09654
--- REP_Estimator            : Cut[10]:   -2.84403 < column10 <=    4.88143
--- REP_Estimator            : Cut[11]:  -0.288259 < column11 <=    6.65518
--- REP_Estimator            : Cut[12]:  -0.127359 < column12 <=    5.98071
--- REP_Estimator            : Cut[13]:    -1.4641 < column13 <=    4.45118
--- REP_Estimator            : Cut[14]:    0.51935 < column14 <=    8.13411
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.7
--- REP_Estimator            : Corresponding background efficiency       : 0.00799201
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   -1.50144 <  column0 <=    5.60651
--- REP_Estimator            : Cut[ 1]:  -0.407544 <  column1 <=      7.286
--- REP_Estimator            : Cut[ 2]:  -0.570297 <  column2 <=    4.84946
--- REP_Estimator            : Cut[ 3]:   -1.83393 <  column3 <=    6.16324
--- REP_Estimator            : Cut[ 4]: -0.00908183 <  column4 <=    7.84247
--- REP_Estimator            : Cut[ 5]:  -0.907439 <  column5 <=    3.47828
--- REP_Estimator            : Cut[ 6]:   -1.34727 <  column6 <=    4.41738
--- REP_Estimator            : Cut[ 7]:    0.11574 <  column7 <=     5.3572
--- REP_Estimator            : Cut[ 8]:    -1.3107 <  column8 <=    5.99228
--- REP_Estimator            : Cut[ 9]:  -0.265203 <  column9 <=    4.66012
--- REP_Estimator            : Cut[10]:   -2.08363 < column10 <=    5.14936
--- REP_Estimator            : Cut[11]: -0.0311845 < column11 <=    7.00739
--- REP_Estimator            : Cut[12]:  -0.681883 < column12 <=    4.98665
--- REP_Estimator            : Cut[13]:   -1.89632 < column13 <=    4.85207
--- REP_Estimator            : Cut[14]:  -0.320684 < column14 <=    5.41995
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.8
--- REP_Estimator            : Corresponding background efficiency       : 0.011988
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   -1.19948 <  column0 <=    6.72505
--- REP_Estimator            : Cut[ 1]:  -0.767112 <  column1 <=    5.07379
--- REP_Estimator            : Cut[ 2]:  -0.495857 <  column2 <=    4.54563
--- REP_Estimator            : Cut[ 3]:  -0.784809 <  column3 <=    5.11581
--- REP_Estimator            : Cut[ 4]:  -0.215466 <  column4 <=    6.88112
--- REP_Estimator            : Cut[ 5]:  -0.786614 <  column5 <=    4.90712
--- REP_Estimator            : Cut[ 6]:  -0.976078 <  column6 <=     4.5936
--- REP_Estimator            : Cut[ 7]:  -0.703135 <  column7 <=    4.95575
--- REP_Estimator            : Cut[ 8]:   -1.31378 <  column8 <=    6.01543
--- REP_Estimator            : Cut[ 9]:    -0.9377 <  column9 <=    4.57022
--- REP_Estimator            : Cut[10]:   -0.32969 < column10 <=    7.20435
--- REP_Estimator            : Cut[11]:  -0.414268 < column11 <=    6.50371
--- REP_Estimator            : Cut[12]:   -1.67735 < column12 <=    4.43072
--- REP_Estimator            : Cut[13]:   -1.79303 < column13 <=    5.23288
--- REP_Estimator            : Cut[14]:  -0.380961 < column14 <=       7.68
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut values for requested signal efficiency: 0.9
--- REP_Estimator            : Corresponding background efficiency       : 0.032967
--- REP_Estimator            : Transformation applied to input variables : None
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : Cut[ 0]:   -1.38355 <  column0 <=    6.34362
--- REP_Estimator            : Cut[ 1]:  -0.632166 <  column1 <=    6.90682
--- REP_Estimator            : Cut[ 2]:  -0.543912 <  column2 <=    5.65552
--- REP_Estimator            : Cut[ 3]:   -1.22859 <  column3 <=    5.77936
--- REP_Estimator            : Cut[ 4]:  -0.717235 <  column4 <=    5.46875
--- REP_Estimator            : Cut[ 5]:  -0.915051 <  column5 <=    4.87841
--- REP_Estimator            : Cut[ 6]:  -0.865514 <  column6 <=    4.36979
--- REP_Estimator            : Cut[ 7]:   -1.59728 <  column7 <=     4.6704
--- REP_Estimator            : Cut[ 8]:   -2.33717 <  column8 <=    5.27469
--- REP_Estimator            : Cut[ 9]:  -0.803611 <  column9 <=    6.50116
--- REP_Estimator            : Cut[10]:   -1.24584 < column10 <=    5.58074
--- REP_Estimator            : Cut[11]:  -0.546006 < column11 <=    4.81453
--- REP_Estimator            : Cut[12]:  -0.841928 < column12 <=     7.0474
--- REP_Estimator            : Cut[13]:  -0.462465 < column13 <=    7.41804
--- REP_Estimator            : Cut[14]:   -1.24551 < column14 <=    6.62844
--- REP_Estimator            : --------------------------------------------
--- REP_Estimator            : End of training                                              
--- REP_Estimator            : Elapsed time for training with 2002 events: 8.9 sec         
--- REP_Estimator            : Create MVA output for classification on training sample
--- REP_Estimator            : Evaluation of REP_Estimator on training sample (2002 events)
--- REP_Estimator            : Elapsed time for evaluation of 2002 events: 0.0474 sec       
--- REP_Estimator            : Creating weight file in xml format: weights/TMVAEstimation_REP_Estimator.weights.xml
--- REP_Estimator            : Creating standalone response class: weights/TMVAEstimation_REP_Estimator.class.C
--- REP_Estimator            : /Users/antares/code/public_rep/rep/tests/tmp1x4zov/result.root:/Method_Cuts/REP_Estimator
--- Factory                  : Training finished
--- Factory                  : 
--- Factory                  : Ranking input variables (method specific)...
--- Factory                  : No variable ranking supplied by classifier: REP_Estimator
--- Factory                  : 
--- Factory                  : === Destroy and recreate all methods via weight files for testing ===
--- Factory                  : 
--- MethodBase               : Reading weight file: weights/TMVAEstimation_REP_Estimator.weights.xml
--- REP_Estimator            : Read method "REP_Estimator" of type "Cuts"
--- REP_Estimator            : MVA method was trained with TMVA Version: 4.2.0
--- REP_Estimator            : MVA method was trained with ROOT Version: 5.34/20
--- REP_Estimator            : Read cuts optimised using Genetic Algorithm
--- REP_Estimator            : Reading 100 signal efficiency bins for 15 variables

But in case of

--- DataSetInfo              : Class index : 0  name : Background
--- DataSetInfo              : Class index : 1  name : Signal

test is broken (Background tree was added at first):

--- Factory                  : You are running ROOT Version: 5.34/20, Aug 12, 2014
--- Factory                  : 
--- Factory                  : _/_/_/_/_/ _|      _|  _|      _|    _|_|   
--- Factory                  :    _/      _|_|  _|_|  _|      _|  _|    _| 
--- Factory                  :   _/       _|  _|  _|  _|      _|  _|_|_|_| 
--- Factory                  :  _/        _|      _|    _|  _|    _|    _| 
--- Factory                  : _/         _|      _|      _|      _|    _| 
--- Factory                  : 
--- Factory                  : ___________TMVA Version 4.2.0, Sep 19, 2013
--- Factory                  : 
--- DataSetInfo              : Added class "Background"  with internal class number 0
--- DataSetInfo              : Added class "Signal"      with internal class number 1
--- Factory                  : Add Tree TrainAssignTree_Background of type Background with 990 events
--- Factory                  : Add Tree TestAssignTree_Background of type Background with 990 events
--- Factory                  : Add Tree TrainAssignTree_Signal of type Signal with 990 events
--- Factory                  : Add Tree TestAssignTree_Signal of type Signal with 990 events
--- DataSetInfo              : Class index : 0  name : Background
--- DataSetInfo              : Class index : 1  name : Signal
--- Factory                  : Booking method: REP_Estimator
--- REP_Estimator            : Use optimization method: "Genetic Algorithm"
--- REP_Estimator            : Use efficiency computation method: "Event Selection"
--- DataSetFactory           : Splitmode is: "RANDOM" the mixmode is: "SAMEASSPLITMODE"
--- DataSetFactory           : Create training and testing trees -- looping over class "Background" ...
--- DataSetFactory           : Weight expression for class 'Background': "weight"
--- DataSetFactory           : Create training and testing trees -- looping over class "Signal" ...
--- DataSetFactory           : Weight expression for class 'Signal': "weight"
--- DataSetFactory           : Number of events in input trees (after possible flattening of arrays):
--- DataSetFactory           :     Background      -- number of events       : 1980   / sum of weights: 1980 
--- DataSetFactory           :     Signal          -- number of events       : 1980   / sum of weights: 1980 
--- DataSetFactory           :     Background tree -- total number of entries: 1980 
--- DataSetFactory           :     Signal     tree -- total number of entries: 1980 
--- DataSetFactory           : Preselection: (will NOT affect number of requested training and testing events)
--- DataSetFactory           :     Background requirement: "1"
--- DataSetFactory           :     Background      -- number of events passed: 1980   / sum of weights: 1980 
--- DataSetFactory           :     Background      -- efficiency             : 1     
--- DataSetFactory           :     Signal     requirement: "1"
--- DataSetFactory           :     Signal          -- number of events passed: 1980   / sum of weights: 1980 
--- DataSetFactory           :     Signal          -- efficiency             : 1     
--- DataSetFactory           : Weight renormalisation mode: "EqualNumEvents": renormalises all event classes ...
--- DataSetFactory           :  such that the effective (weighted) number of events in each class is the same 
--- DataSetFactory           :  (and equals the number of events (entries) given for class=0 )
--- DataSetFactory           : ... i.e. such that Sum[i=1..N_j]{w_i} = N_classA, j=classA, classB, ...
--- DataSetFactory           : ... (note that N_j is the sum of TRAINING events
--- DataSetFactory           :  ..... Testing events are not renormalised nor included in the renormalisation factor!)
--- DataSetFactory           : --> Rescale Background event weights by factor: 1
--- DataSetFactory           : --> Rescale Signal     event weights by factor: 1
--- DataSetFactory           : Number of training and testing events after rescaling:
--- DataSetFactory           : ------------------------------------------------------
--- DataSetFactory           : Background -- training events            : 990 (sum of weights: 990) - requested were 0 events
--- DataSetFactory           : Background -- testing events             : 990 (sum of weights: 990) - requested were 0 events
--- DataSetFactory           : Background -- training and testing events: 1980 (sum of weights: 1980)
--- DataSetFactory           : Signal     -- training events            : 990 (sum of weights: 990) - requested were 0 events
--- DataSetFactory           : Signal     -- testing events             : 990 (sum of weights: 990) - requested were 0 events
--- DataSetFactory           : Signal     -- training and testing events: 1980 (sum of weights: 1980)
--- DataSetFactory           : Create internal training tree
--- DataSetFactory           : Create internal testing tree
--- DataSetInfo              : Correlation matrix (Background):
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetInfo              :           column0 column1 column2 column3 column4 column5 column6 column7 column8 column9 column10 column11 column12 column13 column14
--- DataSetInfo              :  column0:  +1.000  -0.001  -0.025  -0.023  +0.021  -0.023  -0.048  +0.058  +0.025  +0.001   +0.070   -0.050   +0.000   -0.069   -0.000
--- DataSetInfo              :  column1:  -0.001  +1.000  -0.003  -0.007  +0.014  -0.009  +0.028  +0.022  +0.008  -0.015   -0.012   -0.041   -0.013   -0.011   +0.019
--- DataSetInfo              :  column2:  -0.025  -0.003  +1.000  -0.010  +0.007  -0.015  -0.055  -0.018  +0.034  -0.052   -0.008   +0.004   +0.075   -0.017   +0.012
--- DataSetInfo              :  column3:  -0.023  -0.007  -0.010  +1.000  +0.068  -0.006  -0.015  -0.018  -0.049  -0.016   -0.018   +0.040   -0.028   +0.059   -0.047
--- DataSetInfo              :  column4:  +0.021  +0.014  +0.007  +0.068  +1.000  -0.004  -0.023  -0.022  +0.060  -0.012   -0.020   -0.012   -0.036   +0.052   +0.031
--- DataSetInfo              :  column5:  -0.023  -0.009  -0.015  -0.006  -0.004  +1.000  +0.003  -0.000  -0.022  +0.047   -0.004   -0.013   +0.008   +0.027   +0.005
--- DataSetInfo              :  column6:  -0.048  +0.028  -0.055  -0.015  -0.023  +0.003  +1.000  +0.020  +0.036  +0.014   +0.016   +0.020   +0.029   -0.007   +0.010
--- DataSetInfo              :  column7:  +0.058  +0.022  -0.018  -0.018  -0.022  -0.000  +0.020  +1.000  -0.065  +0.030   -0.034   +0.027   -0.044   -0.048   +0.015
--- DataSetInfo              :  column8:  +0.025  +0.008  +0.034  -0.049  +0.060  -0.022  +0.036  -0.065  +1.000  +0.029   -0.019   +0.012   +0.041   +0.011   -0.014
--- DataSetInfo              :  column9:  +0.001  -0.015  -0.052  -0.016  -0.012  +0.047  +0.014  +0.030  +0.029  +1.000   -0.025   -0.030   +0.027   +0.023   -0.033
--- DataSetInfo              : column10:  +0.070  -0.012  -0.008  -0.018  -0.020  -0.004  +0.016  -0.034  -0.019  -0.025   +1.000   -0.022   +0.017   +0.054   +0.037
--- DataSetInfo              : column11:  -0.050  -0.041  +0.004  +0.040  -0.012  -0.013  +0.020  +0.027  +0.012  -0.030   -0.022   +1.000   -0.019   -0.014   +0.006
--- DataSetInfo              : column12:  +0.000  -0.013  +0.075  -0.028  -0.036  +0.008  +0.029  -0.044  +0.041  +0.027   +0.017   -0.019   +1.000   -0.019   +0.027
--- DataSetInfo              : column13:  -0.069  -0.011  -0.017  +0.059  +0.052  +0.027  -0.007  -0.048  +0.011  +0.023   +0.054   -0.014   -0.019   +1.000   -0.012
--- DataSetInfo              : column14:  -0.000  +0.019  +0.012  -0.047  +0.031  +0.005  +0.010  +0.015  -0.014  -0.033   +0.037   +0.006   +0.027   -0.012   +1.000
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetInfo              : Correlation matrix (Signal):
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetInfo              :           column0 column1 column2 column3 column4 column5 column6 column7 column8 column9 column10 column11 column12 column13 column14
--- DataSetInfo              :  column0:  +1.000  +0.012  +0.014  -0.014  -0.010  +0.036  -0.013  +0.007  -0.010  +0.054   +0.014   -0.082   +0.001   -0.008   -0.079
--- DataSetInfo              :  column1:  +0.012  +1.000  +0.013  +0.005  -0.001  -0.018  -0.023  -0.006  +0.005  -0.049   -0.014   +0.018   +0.005   +0.027   -0.018
--- DataSetInfo              :  column2:  +0.014  +0.013  +1.000  -0.013  +0.016  +0.021  -0.002  +0.038  -0.024  +0.001   +0.006   -0.019   -0.000   -0.001   -0.004
--- DataSetInfo              :  column3:  -0.014  +0.005  -0.013  +1.000  +0.028  +0.013  +0.001  -0.017  +0.030  +0.011   +0.014   -0.094   +0.005   -0.024   -0.020
--- DataSetInfo              :  column4:  -0.010  -0.001  +0.016  +0.028  +1.000  +0.021  -0.056  +0.006  +0.061  +0.006   +0.040   -0.007   +0.005   -0.007   +0.022
--- DataSetInfo              :  column5:  +0.036  -0.018  +0.021  +0.013  +0.021  +1.000  +0.009  +0.043  +0.036  +0.007   -0.013   -0.013   -0.007   -0.012   +0.066
--- DataSetInfo              :  column6:  -0.013  -0.023  -0.002  +0.001  -0.056  +0.009  +1.000  +0.015  +0.018  -0.030   -0.012   -0.017   -0.018   +0.053   -0.021
--- DataSetInfo              :  column7:  +0.007  -0.006  +0.038  -0.017  +0.006  +0.043  +0.015  +1.000  +0.023  -0.013   -0.002   -0.007   +0.045   -0.012   -0.001
--- DataSetInfo              :  column8:  -0.010  +0.005  -0.024  +0.030  +0.061  +0.036  +0.018  +0.023  +1.000  -0.031   +0.048   +0.008   +0.026   +0.019   -0.010
--- DataSetInfo              :  column9:  +0.054  -0.049  +0.001  +0.011  +0.006  +0.007  -0.030  -0.013  -0.031  +1.000   -0.018   +0.011   -0.003   +0.026   -0.029
--- DataSetInfo              : column10:  +0.014  -0.014  +0.006  +0.014  +0.040  -0.013  -0.012  -0.002  +0.048  -0.018   +1.000   +0.010   +0.036   +0.054   -0.026
--- DataSetInfo              : column11:  -0.082  +0.018  -0.019  -0.094  -0.007  -0.013  -0.017  -0.007  +0.008  +0.011   +0.010   +1.000   -0.055   +0.010   +0.083
--- DataSetInfo              : column12:  +0.001  +0.005  -0.000  +0.005  +0.005  -0.007  -0.018  +0.045  +0.026  -0.003   +0.036   -0.055   +1.000   -0.014   -0.022
--- DataSetInfo              : column13:  -0.008  +0.027  -0.001  -0.024  -0.007  -0.012  +0.053  -0.012  +0.019  +0.026   +0.054   +0.010   -0.014   +1.000   +0.036
--- DataSetInfo              : column14:  -0.079  -0.018  -0.004  -0.020  +0.022  +0.066  -0.021  -0.001  -0.010  -0.029   -0.026   +0.083   -0.022   +0.036   +1.000
--- DataSetInfo              : --------------------------------------------------------------------------------------------------------------------------------------
--- DataSetFactory           :  
--- Factory                  : 
--- Factory                  : current transformation string: 'I'
--- Factory                  : Create Transformation "I" with events from all classes.
--- Id                       : Transformation, Variable selection : 
--- Id                       : Input : variable 'column0' (index=0).   <---> Output : variable 'column0' (index=0).
--- Id                       : Input : variable 'column1' (index=1).   <---> Output : variable 'column1' (index=1).
--- Id                       : Input : variable 'column2' (index=2).   <---> Output : variable 'column2' (index=2).
--- Id                       : Input : variable 'column3' (index=3).   <---> Output : variable 'column3' (index=3).
--- Id                       : Input : variable 'column4' (index=4).   <---> Output : variable 'column4' (index=4).
--- Id                       : Input : variable 'column5' (index=5).   <---> Output : variable 'column5' (index=5).
--- Id                       : Input : variable 'column6' (index=6).   <---> Output : variable 'column6' (index=6).
--- Id                       : Input : variable 'column7' (index=7).   <---> Output : variable 'column7' (index=7).
--- Id                       : Input : variable 'column8' (index=8).   <---> Output : variable 'column8' (index=8).
--- Id                       : Input : variable 'column9' (index=9).   <---> Output : variable 'column9' (index=9).
--- Id                       : Input : variable 'column10' (index=10).   <---> Output : variable 'column10' (index=10).
--- Id                       : Input : variable 'column11' (index=11).   <---> Output : variable 'column11' (index=11).
--- Id                       : Input : variable 'column12' (index=12).   <---> Output : variable 'column12' (index=12).
--- Id                       : Input : variable 'column13' (index=13).   <---> Output : variable 'column13' (index=13).
--- Id                       : Input : variable 'column14' (index=14).   <---> Output : variable 'column14' (index=14).
--- Id                       : Preparing the Identity transformation...
--- TFHandler_Factory        : -----------------------------------------------------------
--- TFHandler_Factory        : Variable        Mean        RMS   [        Min        Max ]
--- TFHandler_Factory        : -----------------------------------------------------------
--- TFHandler_Factory        :  column0:    0.77453     1.2278   [    -3.3454     5.5804 ]
--- TFHandler_Factory        :  column1:    0.73053     1.2675   [    -3.0019     4.8326 ]
--- TFHandler_Factory        :  column2:    0.78313     1.2688   [    -3.1514     4.9866 ]
--- TFHandler_Factory        :  column3:    0.73403     1.2375   [    -3.0876     5.5230 ]
--- TFHandler_Factory        :  column4:    0.72412     1.2368   [    -3.3747     4.3972 ]
--- TFHandler_Factory        :  column5:    0.76044     1.2363   [    -3.2046     4.2989 ]
--- TFHandler_Factory        :  column6:    0.75584     1.2526   [    -2.8567     4.8490 ]
--- TFHandler_Factory        :  column7:    0.71977     1.2626   [    -3.3012     5.3506 ]
--- TFHandler_Factory        :  column8:    0.76067     1.2670   [    -3.3597     4.4980 ]
--- TFHandler_Factory        :  column9:    0.75305     1.2302   [    -3.0692     4.8289 ]
--- TFHandler_Factory        : column10:    0.75547     1.2656   [    -3.5163     4.5987 ]
--- TFHandler_Factory        : column11:    0.79031     1.2616   [    -3.2292     4.8469 ]
--- TFHandler_Factory        : column12:    0.72753     1.2559   [    -3.0845     5.1161 ]
--- TFHandler_Factory        : column13:    0.76034     1.2468   [    -3.6188     4.6934 ]
--- TFHandler_Factory        : column14:    0.77308     1.2222   [    -3.1909     4.5710 ]
--- TFHandler_Factory        : -----------------------------------------------------------
--- TFHandler_Factory        : Plot event variables for Id
--- TFHandler_Factory        : Create scatter and profile plots in target-file directory: 
--- TFHandler_Factory        : /Users/antares/code/public_rep/rep/tests/tmpRXuIQn/result.root:/InputVariables_Id/CorrelationPlots
--- TFHandler_Factory        :  
--- TFHandler_Factory        : Ranking input variables (method unspecific)...
--- IdTransformation         : Ranking result (top variable is best ranked)
--- IdTransformation         : ---------------------------------
--- IdTransformation         : Rank : Variable  : Separation
--- IdTransformation         : ---------------------------------
--- IdTransformation         :    1 : column2   : 4.093e-01
--- IdTransformation         :    2 : column10  : 4.036e-01
--- IdTransformation         :    3 : column11  : 3.988e-01
--- IdTransformation         :    4 : column3   : 3.953e-01
--- IdTransformation         :    5 : column6   : 3.857e-01
--- IdTransformation         :    6 : column7   : 3.818e-01
--- IdTransformation         :    7 : column1   : 3.794e-01
--- IdTransformation         :    8 : column13  : 3.780e-01
--- IdTransformation         :    9 : column0   : 3.748e-01
--- IdTransformation         :   10 : column4   : 3.747e-01
--- IdTransformation         :   11 : column8   : 3.747e-01
--- IdTransformation         :   12 : column9   : 3.725e-01
--- IdTransformation         :   13 : column12  : 3.723e-01
--- IdTransformation         :   14 : column14  : 3.704e-01
--- IdTransformation         :   15 : column5   : 3.583e-01
--- IdTransformation         : ---------------------------------
--- Factory                  :  
--- Factory                  : Train all methods for Classification ...
--- Factory                  : Train method: REP_Estimator for Classification
--- REP_Estimator            : Begin training
--- <FATAL> Interval                 : maximum lower than minimum
***> abort program execution

In case of kCuts signal tree must be the first added, see http://sourceforge.net/p/tmva/mailman/message/31952626/.

Maybe you know some details about this. Thanks

Strange crash if you import root_numpy, open a TFile and use matplotlib

The following code is currently giving me problems, clearly it should not. Commenting out import root_numpy fixes the problem. In addition, commenting out import _librootnumpy and import _libnumpyhist from root_numpy.py causes the crash not to happen. Both must be commented out, one or the other doesn't help.

import root_numpy
import ROOT as R
import matplotlib.pyplot as P

f = R.TMemFile("test.root", "recreate")
P.figure(); P.show()

As a pastable one liner:

python -c 'import ROOT as R; import root_numpy; import matplotlib.pyplot as P; f = R.TMemFile("test.root", "recreate"); P.figure(); P.show()'

I get the following stack trace.

#6  0x00000035f8209220 in pthread_mutex_lock () from /lib64/libpthread.so.0
#7  0x00000035faa49047 in XrmQGetResource () from /usr/lib64/libX11.so.6
#8  0x00000035faa274f0 in XGetDefault () from /usr/lib64/libX11.so.6
#9  0x0000003c46c3f5d3 in ?? () from /usr/lib64/libcairo.so.2
#10 0x0000003c46c3f8a5 in ?? () from /usr/lib64/libcairo.so.2
#11 0x0000003c46c3ffbc in ?? () from /usr/lib64/libcairo.so.2
#12 0x0000003c46c406cf in cairo_xlib_surface_create () from /usr/lib64/libcairo.so.2
#13 0x0000003c4743ef95 in gdk_window_begin_paint_region () from /usr/lib64/libgdk-x11-2.0.so.0
#14 0x0000003c4654c0e4 in gtk_main_do_event () from /usr/lib64/libgtk-x11-2.0.so.0
#15 0x0000003c4744317a in ?? () from /usr/lib64/libgdk-x11-2.0.so.0
#16 0x0000003c4743fc3b in ?? () from /usr/lib64/libgdk-x11-2.0.so.0
#17 0x0000003c474447b1 in gdk_window_process_all_updates () from /usr/lib64/libgdk-x11-2.0.so.0
#18 0x0000003c47444819 in ?? () from /usr/lib64/libgdk-x11-2.0.so.0
#19 0x0000003c4741d396 in ?? () from /usr/lib64/libgdk-x11-2.0.so.0
#20 0x00000035f9638f0e in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#21 0x00000035f963c938 in ?? () from /lib64/libglib-2.0.so.0
#22 0x00000035f963cd55 in g_main_loop_run () from /lib64/libglib-2.0.so.0
#23 0x0000003c4654c307 in gtk_main () from /usr/lib64/libgtk-x11-2.0.so.0
#24 0x00007f71a0479696 in ?? () from /usr/lib64/python2.6/site-packages/gtk-2.0/gtk/_gtk.so
#25 0x0000003612adea56 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#26 0x0000003612ae0797 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.6.so.1.0
#27 0x0000003612adebe4 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#28 0x0000003612ae0797 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.6.so.1.0
#29 0x0000003612ae0872 in PyEval_EvalCode () from /usr/lib64/libpython2.6.so.1.0
#30 0x0000003612afbbbc in ?? () from /usr/lib64/libpython2.6.so.1.0
#31 0x0000003612afbdca in PyRun_StringFlags () from /usr/lib64/libpython2.6.so.1.0
#32 0x0000003612afd030 in PyRun_SimpleStringFlags () from /usr/lib64/libpython2.6.so.1.0
#33 0x0000003612b09636 in Py_Main () from /usr/lib64/libpython2.6.so.1.0
#34 0x00000035f7a1ecdd in __libc_start_main () from /lib64/libc.so.6
#35 0x0000000000400649 in _start ()

SLC6, python 2.6.6, matplotlib 0.99.1.1.

it is not working with my data

I have some data in a special structure like each entry contain of several features and some features are vector instead of single value
Jet = 4
Jet_E = (vector)0x43a2760
Jet_Px = (vector
)0x43a3120
Jet_Py = (vector)0x4580ad0
Jet_Pz = (vector
)0x4580e70
Jet_Eta = (vector)0x43a37d0
Jet_Phi = (vector
)0x451fa90
Jet_PT = (vector)0x4520ea0
Jet_Btag = (vector
)0x4522330
Jet_NTracks = (vector)0x45237c0
Jet_EHoverEE = (vector
)0x4524c50
Jet_size = 4

is there any limitation for this case?

Use "entries" instead of "N" as arg name

def tree2rec(tree, branches=None, entries=None, offset=0,                             
        include_weight=False,                                                   
        weight_name='weight',                                                   
        weight_dtype='f4'):
def tree2array(tree, branches=None, entries=None, offset=0,                           
        include_weight=False,                                                   
        weight_name='weight',                                                   
        weight_dtype='f4'):

@piti118 what do you think?

Compiling _librootnumpy.cpp fails on Mac with clang

I get this compile error:

$ make
rm -rf build
find root_numpy -name "*.pyc" | xargs rm -f
find root_numpy -name "*.so" | xargs rm -f
rm -f tags
python setup.py build_ext -i
running build_ext
building 'root_numpy._librootnumpy' extension
creating build
creating build/temp.macosx-10.8-x86_64-2.7
creating build/temp.macosx-10.8-x86_64-2.7/root_numpy
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/deil/Library/Python/2.7/lib/python/site-packages/numpy/core/include -I/Users/deil/software/root/v5-34-03/include -Iroot_numpy -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c root_numpy/_librootnumpy.cpp -o build/temp.macosx-10.8-x86_64-2.7/root_numpy/_librootnumpy.o
In file included from root_numpy/_librootnumpy.cpp:253:
In file included from /Users/deil/Library/Python/2.7/lib/python/site-packages/numpy/core/include/numpy/arrayobject.h:15:
In file included from /Users/deil/Library/Python/2.7/lib/python/site-packages/numpy/core/include/numpy/ndarrayobject.h:17:
In file included from /Users/deil/Library/Python/2.7/lib/python/site-packages/numpy/core/include/numpy/ndarraytypes.h:1725:
/Users/deil/Library/Python/2.7/lib/python/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: "Using deprecated NumPy API,
      disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
 ^
In file included from root_numpy/_librootnumpy.cpp:271:
root_numpy/Column.h:65:17: warning: unused variable 'ok' [-Wunused-variable]
            int ok = find_coltype(leaf,ct,cv);
                ^
In file included from root_numpy/_librootnumpy.cpp:272:
root_numpy/BetterChain.h:152:21: warning: unused variable 'rt' [-Wunused-variable]
        const char* rt = leaf->GetTypeName();
                    ^
root_numpy/_librootnumpy.cpp:1151:9: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
        PyErr_BadInternalCall();
        ^
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyerrors.h:220:56: note: expanded from macro 'PyErr_BadInternalCall'
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
                                                       ^
<scratch space>:140:1: note: expanded from macro '__FILE__'
"root_numpy/_librootnumpy.cpp"
^
root_numpy/_librootnumpy.cpp:9877:26: error: expected the class name after '~' to name a destructor
  p->rtype.std::string::~string();
                         ^
4 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
make: *** [inplace] Error 1

This is on Mac OS X 10.8 with ROOT 5.34/03 with these versions:

$ which clang
/usr/bin/clang
$ clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1
Thread model: posix
$ python -c 'import numpy; print numpy.__file__; print numpy.__version__'
/Users/deil/Library/Python/2.7/lib/python/site-packages/numpy/__init__.pyc
1.8.0.dev-c5ccca9
$ xcodebuild -version
Xcode 4.5.2
Build version 4G2008a

Failure when reading complex root file

I'm having problems reading a complex ROOT file (containing many branches with variable-length arrays) using root_numpy.
I've uploaded the first entry of the dataset here

Running the following script

from root_numpy import *

arr = root2array('out_tree.root', 'tree')
print(arr)

produces the following stack trace:

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fdabed70aaa in waitpid () from /usr/lib/libc.so.6
#1  0x00007fdabecf840b in do_system () from /usr/lib/libc.so.6
#2  0x00007fdab629aed1 in TUnixSystem::StackTrace() () from /usr/lib/root/libCore.so.5.34
#3  0x00007fdab629cf5c in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib/root/libCore.so.5.34
#4  <signal handler called>
#5  OBJECT_getitem (ip=0x122deeb "C", ap=0x7fdab6c48b20) at numpy/core/src/multiarray/arraytypes.c.src:525
#6  0x00007fdabdf75758 in VOID_getitem (ip=0x122db50 "\345{\230\345\225w\250?kυ\t\317\024\v
", ap=0x7fdab6c48b20) at numpy/core/src/multiarray/arraytypes.c.src:617
#7  0x00007fdabe020fab in array_toscalar (self=0x7fdab6c48b20, args=<optimized out>) at numpy/core/src/multiarray/methods.c:680
#8  0x00007fdabfa7d153 in call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132018) at Python/ceval.c:4033
#9  PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#10 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b7b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=7, kws=0x7fdab6c70828, kwcount=0, defs=0x7fdab9b1d5a8, defcount=7, closure=0x0) at Python/ceval.c:3265
#11 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=7, n=<optimized out>, pp_stack=0x7ffc7f132218, func=0x7fdab9b229b0) at Python/ceval.c:4129
#12 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132218) at Python/ceval.c:4054
#13 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#14 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabfdcbc30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=1, kws=0x0, kwcount=0, defs=0x7fdabda931a8, defcount=3, closure=0x0) at Python/ceval.c:3265
#15 0x00007fdabf9fc851 in function_call (func=0x7fdab9b25398, arg=0x7fdab0af84d0, kw=0x0) at Objects/funcobject.c:526
#16 0x00007fdabf9cd323 in PyObject_Call (func=0x7fdab9b25398, arg=<optimized out>, kw=<optimized out>) at Objects/abstract.c:2529
#17 0x00007fdabfa76823 in PyEval_CallObjectWithKeywords (func=0x7fdab9b25398, arg=0x7fdab0af84d0, kw=<optimized out>) at Python/ceval.c:3902
#18 0x00007fdabdf5bac4 in array_str (self=<optimized out>) at numpy/core/src/multiarray/arrayobject.c:664
#19 0x00007fdabfa1999b in _PyObject_Str (v=0x7fdab6c48b20) at Objects/object.c:430
#20 0x00007fdabfa19a8a in PyObject_Str (v=<optimized out>) at Objects/object.c:451
#21 0x00007fdabe04e80e in gentype_repr (self=<optimized out>) at numpy/core/src/multiarray/scalartypes.c.src:372
#22 0x00007fdabfa19625 in PyObject_Repr (v=0x7fdab0b306c0) at Objects/object.c:381
#23 0x00007fdabfa7e2a2 in call_function (oparg=<optimized out>, pp_stack=0x7ffc7f1325b8) at Python/ceval.c:4021
#24 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#25 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b4b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=1, kws=0xd60ae0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3265
#26 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=1, n=<optimized out>, pp_stack=0x7ffc7f1327b8, func=0x7fdab9b22848) at Python/ceval.c:4129
#27 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f1327b8) at Python/ceval.c:4054
#28 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#29 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9ba30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=8, kws=0xd5e978, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3265
#30 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=8, n=<optimized out>, pp_stack=0x7ffc7f1329b8, func=0x7fdab9b22aa0) at Python/ceval.c:4129
#31 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f1329b8) at Python/ceval.c:4054
#32 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#33 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b5b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=6, kws=0x6ca8a0, kwcount=1, defs=0x7fdab9b151a8, defcount=3, closure=0x0) at Python/ceval.c:3265
#34 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=6, n=<optimized out>, pp_stack=0x7ffc7f132bb8, func=0x7fdab9b228c0) at Python/ceval.c:4129
#35 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132bb8) at Python/ceval.c:4054
#36 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#37 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b7b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=7, kws=0x7fdab6c70628, kwcount=0, defs=0x7fdab9b1d5a8, defcount=7, closure=0x0) at Python/ceval.c:3265
#38 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=7, n=<optimized out>, pp_stack=0x7ffc7f132db8, func=0x7fdab9b229b0) at Python/ceval.c:4129
#39 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132db8) at Python/ceval.c:4054
#40 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#41 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabfdcbc30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=1, kws=0x0, kwcount=0, defs=0x7fdabda931a8, defcount=3, closure=0x0) at Python/ceval.c:3265
#42 0x00007fdabf9fc851 in function_call (func=0x7fdab9b25398, arg=0x7fdabfe1ebd0, kw=0x0) at Objects/funcobject.c:526
#43 0x00007fdabf9cd323 in PyObject_Call (func=0x7fdab9b25398, arg=<optimized out>, kw=<optimized out>) at Objects/abstract.c:2529
#44 0x00007fdabfa76823 in PyEval_CallObjectWithKeywords (func=0x7fdab9b25398, arg=0x7fdabfe1ebd0, kw=<optimized out>) at Python/ceval.c:3902
#45 0x00007fdabdf5bac4 in array_str (self=<optimized out>) at numpy/core/src/multiarray/arrayobject.c:664
#46 0x00007fdabfa1999b in _PyObject_Str (v=0x7fdab0a48df0) at Objects/object.c:430
#47 0x00007fdabfa19a8a in PyObject_Str (v=<optimized out>) at Objects/object.c:451
#48 0x00007fdabfa19be2 in internal_print (op=0x7fdab0a48df0, fp=0x7fdabf057740 <_IO_2_1_stdout_>, flags=<optimized out>, nesting=0) at Objects/object.c:303
#49 0x00007fdabf9f4e48 in file_PyObject_Print (flags=1, f=0x7fdabff69150, op=0x7fdab0a48df0) at Objects/fileobject.c:110
#50 PyFile_WriteObject (v=<optimized out>, f=0x7fdabff69150, flags=1) at Objects/fileobject.c:2579
#51 0x00007fdabfa7b600 in PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:1771
#52 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabfe77e30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3265
#53 0x00007fdabfa7ed82 in PyEval_EvalCode (co=<optimized out>, globals=<optimized out>, locals=<optimized out>) at Python/ceval.c:667
#54 0x00007fdabfa9eba0 in run_mod (arena=0x6825b0, flags=0x7ffc7f133480, locals=0x7fdabff17168, globals=0x7fdabff17168, filename=<optimized out>, mod=0x6c4f48) at Python/pythonrun.c:1371
#55 PyRun_FileExFlags (fp=0x6c8d10, filename=<optimized out>, start=<optimized out>, globals=0x7fdabff17168, locals=0x7fdabff17168, closeit=1, flags=0x7ffc7f133480) at Python/pythonrun.c:1357
#56 0x00007fdabfa9ed7f in PyRun_SimpleFileExFlags (fp=0x6c8d10, filename=0x7ffc7f135031 "bla.py", closeit=1, flags=0x7ffc7f133480) at Python/pythonrun.c:949
#57 0x00007fdabfab4664 in Py_Main (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:645
#58 0x00007fdabecd9800 in __libc_start_main () from /usr/lib/libc.so.6
#59 0x0000000000400649 in _start ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  OBJECT_getitem (ip=0x122deeb "C", ap=0x7fdab6c48b20) at numpy/core/src/multiarray/arraytypes.c.src:525
#6  0x00007fdabdf75758 in VOID_getitem (ip=0x122db50 "345{230345225w250?kυt317024v
", ap=0x7fdab6c48b20) at numpy/core/src/multiarray/arraytypes.c.src:617
#7  0x00007fdabe020fab in array_toscalar (self=0x7fdab6c48b20, args=<optimized out>) at numpy/core/src/multiarray/methods.c:680
#8  0x00007fdabfa7d153 in call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132018) at Python/ceval.c:4033
#9  PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#10 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b7b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=7, kws=0x7fdab6c70828, kwcount=0, defs=0x7fdab9b1d5a8, defcount=7, closure=0x0) at Python/ceval.c:3265
#11 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=7, n=<optimized out>, pp_stack=0x7ffc7f132218, func=0x7fdab9b229b0) at Python/ceval.c:4129
#12 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132218) at Python/ceval.c:4054
#13 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#14 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabfdcbc30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=1, kws=0x0, kwcount=0, defs=0x7fdabda931a8, defcount=3, closure=0x0) at Python/ceval.c:3265
#15 0x00007fdabf9fc851 in function_call (func=0x7fdab9b25398, arg=0x7fdab0af84d0, kw=0x0) at Objects/funcobject.c:526
#16 0x00007fdabf9cd323 in PyObject_Call (func=0x7fdab9b25398, arg=<optimized out>, kw=<optimized out>) at Objects/abstract.c:2529
#17 0x00007fdabfa76823 in PyEval_CallObjectWithKeywords (func=0x7fdab9b25398, arg=0x7fdab0af84d0, kw=<optimized out>) at Python/ceval.c:3902
#18 0x00007fdabdf5bac4 in array_str (self=<optimized out>) at numpy/core/src/multiarray/arrayobject.c:664
#19 0x00007fdabfa1999b in _PyObject_Str (v=0x7fdab6c48b20) at Objects/object.c:430
#20 0x00007fdabfa19a8a in PyObject_Str (v=<optimized out>) at Objects/object.c:451
#21 0x00007fdabe04e80e in gentype_repr (self=<optimized out>) at numpy/core/src/multiarray/scalartypes.c.src:372
#22 0x00007fdabfa19625 in PyObject_Repr (v=0x7fdab0b306c0) at Objects/object.c:381
#23 0x00007fdabfa7e2a2 in call_function (oparg=<optimized out>, pp_stack=0x7ffc7f1325b8) at Python/ceval.c:4021
#24 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#25 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b4b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=1, kws=0xd60ae0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3265
#26 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=1, n=<optimized out>, pp_stack=0x7ffc7f1327b8, func=0x7fdab9b22848) at Python/ceval.c:4129
#27 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f1327b8) at Python/ceval.c:4054
#28 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#29 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9ba30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=8, kws=0xd5e978, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3265
#30 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=8, n=<optimized out>, pp_stack=0x7ffc7f1329b8, func=0x7fdab9b22aa0) at Python/ceval.c:4129
#31 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f1329b8) at Python/ceval.c:4054
#32 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#33 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b5b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=6, kws=0x6ca8a0, kwcount=1, defs=0x7fdab9b151a8, defcount=3, closure=0x0) at Python/ceval.c:3265
#34 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=6, n=<optimized out>, pp_stack=0x7ffc7f132bb8, func=0x7fdab9b228c0) at Python/ceval.c:4129
#35 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132bb8) at Python/ceval.c:4054
#36 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#37 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabda9b7b0, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=7, kws=0x7fdab6c70628, kwcount=0, defs=0x7fdab9b1d5a8, defcount=7, closure=0x0) at Python/ceval.c:3265
#38 0x00007fdabfa7d2aa in fast_function (nk=<optimized out>, na=7, n=<optimized out>, pp_stack=0x7ffc7f132db8, func=0x7fdab9b229b0) at Python/ceval.c:4129
#39 call_function (oparg=<optimized out>, pp_stack=0x7ffc7f132db8) at Python/ceval.c:4054
#40 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:2679
#41 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabfdcbc30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=1, kws=0x0, kwcount=0, defs=0x7fdabda931a8, defcount=3, closure=0x0) at Python/ceval.c:3265
#42 0x00007fdabf9fc851 in function_call (func=0x7fdab9b25398, arg=0x7fdabfe1ebd0, kw=0x0) at Objects/funcobject.c:526
#43 0x00007fdabf9cd323 in PyObject_Call (func=0x7fdab9b25398, arg=<optimized out>, kw=<optimized out>) at Objects/abstract.c:2529
#44 0x00007fdabfa76823 in PyEval_CallObjectWithKeywords (func=0x7fdab9b25398, arg=0x7fdabfe1ebd0, kw=<optimized out>) at Python/ceval.c:3902
#45 0x00007fdabdf5bac4 in array_str (self=<optimized out>) at numpy/core/src/multiarray/arrayobject.c:664
#46 0x00007fdabfa1999b in _PyObject_Str (v=0x7fdab0a48df0) at Objects/object.c:430
#47 0x00007fdabfa19a8a in PyObject_Str (v=<optimized out>) at Objects/object.c:451
#48 0x00007fdabfa19be2 in internal_print (op=0x7fdab0a48df0, fp=0x7fdabf057740 <_IO_2_1_stdout_>, flags=<optimized out>, nesting=0) at Objects/object.c:303
#49 0x00007fdabf9f4e48 in file_PyObject_Print (flags=1, f=0x7fdabff69150, op=0x7fdab0a48df0) at Objects/fileobject.c:110
#50 PyFile_WriteObject (v=<optimized out>, f=0x7fdabff69150, flags=1) at Objects/fileobject.c:2579
#51 0x00007fdabfa7b600 in PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:1771
#52 0x00007fdabfa7ec6e in PyEval_EvalCodeEx (co=0x7fdabfe77e30, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3265
#53 0x00007fdabfa7ed82 in PyEval_EvalCode (co=<optimized out>, globals=<optimized out>, locals=<optimized out>) at Python/ceval.c:667
#54 0x00007fdabfa9eba0 in run_mod (arena=0x6825b0, flags=0x7ffc7f133480, locals=0x7fdabff17168, globals=0x7fdabff17168, filename=<optimized out>, mod=0x6c4f48) at Python/pythonrun.c:1371
#55 PyRun_FileExFlags (fp=0x6c8d10, filename=<optimized out>, start=<optimized out>, globals=0x7fdabff17168, locals=0x7fdabff17168, closeit=1, flags=0x7ffc7f133480) at Python/pythonrun.c:1357
#56 0x00007fdabfa9ed7f in PyRun_SimpleFileExFlags (fp=0x6c8d10, filename=0x7ffc7f135031 "bla.py", closeit=1, flags=0x7ffc7f133480) at Python/pythonrun.c:949
#57 0x00007fdabfab4664 in Py_Main (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:645
#58 0x00007fdabecd9800 in __libc_start_main () from /usr/lib/libc.so.6
#59 0x0000000000400649 in _start ()
===========================================================

The error also changes depending on which variables are read in.

fill_hist error

Hi guys,

I get the error
" Error in TH2D::Fill: Invalid signature - do nothing"

whenever I use fill_hist with a TH2D histogram. I thought it was an issue with my code, but I tried running the example on the root_numpy examples webpage:
from ROOT import TH2D, TCanvas
from root_numpy import fill_hist
import numpy as np

Fill a ROOT histogram from a NumPy array

hist = TH2D('name', 'title', 20, -3, 3, 20, -3, 3)
fill_hist(hist, np.random.randn(1E6, 2))

and I get exactly the same errors.

I'm using Python 2.7.4, gcc 4.8.0, root_numpy 4.2.1 and root 5.34.25.

Any ideas?

EDIT: I upgraded to root_numpy 4.3.0 with pip and it's working now. Sorry for the noise.

Thanks
Tim

Symbol not found: __ZN7TObject13SavePrimitiveERSoPKc on Mac OS

Hi,

I'm getting an error when trying to import root_numpy on a mac; it's the same one that is referenced in #133 , but I don't think the cause is the same:

>>> import root_numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "root_numpy/__init__.py", line 1, in <module>
    from _tree import (
  File "root_numpy/_tree.py", line 4, in <module>
    import _librootnumpy
ImportError: dlopen(root_numpy/_librootnumpy.so, 2): Symbol not found: __ZN7TObject13SavePrimitiveERSoPKc
  Referenced from: root_numpy/_librootnumpy.so
  Expected in: flat namespace
 in root_numpy/_librootnumpy.so

I build root from source on my mac, and tried to install root_numpy with pip:

➜  root_numpy git:(master) pip install root-numpy --upgrade                                                         
Downloading/unpacking root-numpy from https://pypi.python.org/packages/source/r/root_numpy/root_numpy-3.3.1.tar.gz#md5=c071f232f6249d8b58f41a5925b9cc6e
  Downloading root_numpy-3.3.1.tar.gz (361kB): 361kB downloaded
  Running setup.py (path:/private/var/folders/79/0nrss18d0pnd4990l0sv4llc0000gn/T/pip_build_matt/root-numpy/setup.py) egg_info for package root-numpy

Installing collected packages: root-numpy
  Found existing installation: root-numpy 3.3.1.dev
    Uninstalling root-numpy:
      Successfully uninstalled root-numpy
  Running setup.py install for root-numpy

                     _
     _ __ ___   ___ | |_     _ __  _   _ _ __ ___  _ __  _   _
    | '__/ _ \ / _ \| __|   | '_ \| | | | '_ ` _ \| '_ \| | | |
    | | | (_) | (_) | |_    | | | | |_| | | | | | | |_) | |_| |
    |_|  \___/ \___/ \__|___|_| |_|\__,_|_| |_| |_| .__/ \__, |  3.3.1
                       |_____|                    |_|    |___/

    building 'root_numpy._librootnumpy' extension
    gcc -fno-strict-aliasing -I/Users/matt/venv/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/matt/venv/anaconda/lib/python2.7/site-packages/numpy/core/include -I/Users/matt/prefix/include/root -Iroot_numpy/src -I/Users/matt/venv/anaconda/include/python2.7 -c root_numpy/src/_librootnumpy.cpp -o build/temp.macosx-10.5-x86_64-2.7/root_numpy/src/_librootnumpy.o
    In file included from root_numpy/src/_librootnumpy.cpp:352:
    In file included from /Users/matt/venv/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4:
    In file included from /Users/matt/venv/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17:
    In file included from /Users/matt/venv/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1804:
    /Users/matt/venv/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: "Using deprecated NumPy API, disable it by "          "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
    #warning "Using deprecated NumPy API, disable it by " \
     ^
    /home/ndawe/workspace/root_numpy/root_numpy/src/tree.pyx:1007:9: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
            PyErr_BadInternalCall();
            ^
    /Users/matt/venv/anaconda/include/python2.7/pyerrors.h:220:56: note: expanded from macro 'PyErr_BadInternalCall'
    #define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
                                                           ^
    <scratch space>:104:1: note: expanded from here
    "/home/ndawe/workspace/root_numpy/root_numpy/src/tree.pyx"
    ^
    In file included from root_numpy/src/_librootnumpy.cpp:353:
    In file included from /Users/matt/venv/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/ufuncobject.h:317:
    /Users/matt/venv/anaconda/lib/python2.7/site-packages/numpy/core/include/numpy/__ufunc_api.h:241:1: warning: unused function '_import_umath' [-Wunused-function]
    _import_umath(void)
    ^
    cython_utility:2770:32: warning: unused function '__Pyx_PyUnicode_FromString' [-Wunused-function]
    static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
                                   ^
    root_numpy/src/_librootnumpy.cpp:459:29: warning: unused function '__Pyx_Py_UNICODE_strlen' [-Wunused-function]
    static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
                                ^
    cython_utility:2921:33: warning: unused function '__Pyx_PyInt_FromSize_t' [-Wunused-function]
    static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
                                    ^
    cython_utility:288:26: warning: unused function '__Pyx_PyUnicode_Equals' [-Wunused-function]
    static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
                             ^
    cython_utility:542:32: warning: unused function '__Pyx_GetItemInt_List_Fast' [-Wunused-function]
    static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                   ^
    cython_utility:556:32: warning: unused function '__Pyx_GetItemInt_Tuple_Fast' [-Wunused-function]
    static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                   ^
    /home/ndawe/workspace/root_numpy/root_numpy/src/tree.pyx:1038:26: warning: unused function 'resize' [-Wunused-function]
    static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
                             ^
    cython_utility:2013:36: warning: function '__Pyx_PyInt_As_unsigned_long' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) {
                                       ^
    cython_utility:2236:48: warning: unused function '__pyx_t_float_complex_from_parts' [-Wunused-function]
        static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
                                                   ^
    cython_utility:2356:49: warning: unused function '__pyx_t_double_complex_from_parts' [-Wunused-function]
        static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
                                                    ^
    array.pxd:128:35: warning: unused function '__pyx_f_7cpython_5array_clone' [-Wunused-function]
    static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobject *__pyx_v_template, Py_ssize_t __pyx_v_length, int __pyx_v_zero) {
                                      ^
    array.pxd:137:35: warning: unused function '__pyx_f_7cpython_5array_copy' [-Wunused-function]
    static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_copy(arrayobject *__pyx_v_self) {
                                      ^
    array.pxd:153:26: warning: unused function '__pyx_f_7cpython_5array_extend' [-Wunused-function]
    static CYTHON_INLINE int __pyx_f_7cpython_5array_extend(arrayobject *__pyx_v_self, arrayobject *__pyx_v_other) {
                             ^
    array.pxd:159:27: warning: unused function '__pyx_f_7cpython_5array_zero' [-Wunused-function]
    static CYTHON_INLINE void __pyx_f_7cpython_5array_zero(arrayobject *__pyx_v_self) {
                              ^
    /home/ndawe/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd:768:32: warning: unused function '__pyx_f_5numpy_PyArray_MultiIterNew1' [-Wunused-function]
    static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
                                   ^
    /home/ndawe/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd:771:32: warning: unused function '__pyx_f_5numpy_PyArray_MultiIterNew2' [-Wunused-function]
    static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
                                   ^
    /home/ndawe/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd:774:32: warning: unused function '__pyx_f_5numpy_PyArray_MultiIterNew3' [-Wunused-function]
    static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
                                   ^
    /home/ndawe/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd:777:32: warning: unused function '__pyx_f_5numpy_PyArray_MultiIterNew4' [-Wunused-function]
    static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
                                   ^
    /home/ndawe/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd:780:32: warning: unused function '__pyx_f_5numpy_PyArray_MultiIterNew5' [-Wunused-function]
    static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
                                   ^
    /home/ndawe/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd:966:27: warning: unused function '__pyx_f_5numpy_set_array_base' [-Wunused-function]
    static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
                              ^
    /home/ndawe/.local/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd:976:32: warning: unused function '__pyx_f_5numpy_get_array_base' [-Wunused-function]
    static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
                                   ^
    24 warnings generated.
    gcc -bundle -undefined dynamic_lookup -L/Users/matt/venv/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/root_numpy/src/_librootnumpy.o -L/Users/matt/venv/anaconda/lib -o build/lib.macosx-10.5-x86_64-2.7/root_numpy/_librootnumpy.so -L/Users/matt/prefix/lib/root -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -stdlib=libc++ -lm -ldl -lTreePlayer

Successfully installed root-numpy
Cleaning up...

No warnings about mismatched symbols or anything. Output of otool is fine:

➜  root_numpy git:(master) otool -L ./root_numpy/_librootnumpy.so
./root_numpy/_librootnumpy.so:
    /Users/matt/prefix/lib/root/libCore.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libCint.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libRIO.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libNet.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libHist.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libGraf.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libGraf3d.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libGpad.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libTree.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libRint.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libPostscript.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libMatrix.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libPhysics.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libMathCore.so (compatibility version 0.0.0, current version 0.0.0)
    /Users/matt/prefix/lib/root/libThread.so (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /Users/matt/prefix/lib/root/libTreePlayer.so (compatibility version 0.0.0, current version 0.0.0)

Any ideas?

problems with root-config on windows

Is it possible to install root_numpy on windows?
I am trying to install root_numpy on my windows machine, but always get an error:
Running setup.py (path:c:\users\dell\appdata\local\temp\pip_build_DELL\root-nu
mpy\setup.py) egg_info for package root-numpy
Traceback (most recent call last):
File "", line 17, in
File "c:\users\dell\appdata\local\temp\pip_build_DELL\root-numpy\setup.py"
, line 61, in
rootsys, root_config))
RuntimeError: ROOTSYS is C:\root but running C:\root\bin\root-config failed
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "c:\users\dell\appdata\local\temp\pip_build_DELL\root-numpy\setup.py", li
ne 61, in

although everything is already installed, ROOTSYS is correctly set to C:\root and root-config is in C:\root\bin.

reverted commits

@piti118 I just force pushed to upstream master by accident 😦. Can you push the now few missing commits?

Symbol not found: __ZN7TObject13SavePrimitiveERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEPKc

Hi, I tried to install root-numpy and ran into following problem:
when trying to call the function tree.to_array()

Symbol not found:  __ZN7TObject13SavePrimitiveERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEPKc

When trying to run tests.py in the package directory I get

$ python tests.py
Traceback (most recent call last):
  File "tests.py", line 12, in 
    import root_numpy as rnp
  File "/Library/Python/2.7/site-packages/root_numpy/__init__.py", line 1, in 
    from _root_numpy import (
  File "/Library/Python/2.7/site-packages/root_numpy/_root_numpy.py", line 6, in 
    import _librootnumpy
ImportError: dlopen(/Library/Python/2.7/site-packages/root_numpy/_librootnumpy.so, 2): Symbol not found: __ZN7TObject13SavePrimitiveERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEPKc
  Referenced from: /Library/Python/2.7/site-packages/root_numpy/_librootnumpy.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/root_numpy/_librootnumpy.so`

Even stranger thing is when I run

 nm -g _librootnumpy.so

I get that this symbol does really exists among the others

000000000002f320 T __ZN6ColumnD2Ev
U _ZN6TChainC1EPKcS1
U __ZN7TObject11HandleTimerEP6TTimer
U __ZN7TObject11SetUniqueIDEj
U __ZN7TObject11ShowMembersER16TMemberInspector
U __ZN7TObject12ExecuteEventEiii
U __ZN7TObject13SavePrimitiveERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEPKc
U __ZN7TObject13SetDrawOptionEPKc
U _ZN7TObject15RecursiveRemoveEPS

Software versions:

  • Mac OS 10.9
  • ROOT 5.34/05 (branches/v5-34-00-patches@48624, Feb 19 2013, 09:50:22 on macosx64)
  • Python 2.7.5
  • Numpy 1.6.2

Thanks in advance!

Automatic conversion of item fails if not branch data is not a list

This seems like a really obscure bug. I'll document it with the following code (message me for an example root file).

import numpy as np
import root_numpy as rnp
from ROOT import TFile

# open up the file and grab the tree
f = TFile.Open(args.filename)
t = f.Get(args.treename)

rho_column_name = 'Eventshape_rhoKt4LC'

data = rnp.tree2rec(t, branches=rho_column_name, start=(0), stop=(1))

Here are some example outputs:

>>> data[rho_column_name]
array([(17099.6875,)], 
      dtype=[('Eventshape_rhoKt4LC', '<f4')])
>>> row = data[0]
>>> event=np.array(data)
>>> event
array([(17099.6875,)], 
      dtype=[('Eventshape_rhoKt4LC', '<f4')])

And you can see this works fine. However, when I include another branch (this is the event rho, which there is a single value per event) such as gTowerE:

>>> data = rnp.tree2rec(t, branches=rho_column_name+['gTowerE'], start=(0), stop=(1))
>>> data[rho_column_name]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/numpy/core/records.py", line 459, in __getitem__
    obj = ndarray.__getitem__(self, indx)
  File "/Library/Python/2.7/site-packages/numpy/core/_internal.py", line 301, in _index_fields
    view = ary.view(dtype=view_dtype)
  File "/Library/Python/2.7/site-packages/numpy/core/records.py", line 499, in view
    return ndarray.view(self, dtype)
  File "/Library/Python/2.7/site-packages/numpy/core/records.py", line 441, in __setattr__
    raise exctype(value)
TypeError: Cannot change data-type for object array.

which throws an error. Below is the output of data

>>> data
rec.array([ (17099.6875, [3005.19091796875, 5374.39453125, 0.0, 3307.84619140625, 926.83349609375, 528.037109375, 1910.87255859375, 3223.212646484375, 0.0, 0.0, 0.0, 0.0, 538.441162109375, 0.0, 0.0, 5954.396484375, 2527.2216796875, 13252.11328125, 933.48974609375, 129.86752319335938, 5493.7548828125, 14049.7099609375, 131.4100341796875, 9340.47265625, 0.0, 14157.669921875, 5161.17626953125, 2178.783447265625, 1534.852294921875, 2264.365966796875, 4780.1748046875, 17662.501953125, 0.0, 1379.926513671875, 610.602783203125, 475.58203125, 0.0, 7619.7099609375, 13716.328125, 1187.78857421875, 0.0, 2955.497314453125, 0.0, 0.0, 653.010986328125, 1232.590576171875, 1726.1912841796875, 3286.91552734375, 805.7254028320312, 272.5866394042969, 3232.25146484375, 0.0, 24931.3046875, 385.4686279296875, 0.0, 667.2488403320312, 252.63491821289062, 9361.22265625, 2516.075439453125, 2449.251953125, 2210.966064453125, 87.72781372070312, 1653.453369140625, 0.0, 4571.958984375, 6833.212890625, 15502.748046875, 3597.8271484375, 4322.296875, 1203.1396484375, 2700.370849609375, 4138.5380859375, 3395.15283203125, 0.0, 480.05987548828125, 98.8602294921875, 0.0, 1304.0587158203125, 6145.7236328125, 383.7019958496094, 5090.6708984375, 941.1778564453125, 0.0, 510.8492736816406, 0.0, 0.0, 0.0, 197.98724365234375, 518.737060546875, 3876.399658203125, 5164.259765625, 693.9755859375, 1636.0096435546875, 1.015228271484375, 2110.52197265625, 6904.2861328125, 6318.69482421875, 2373.44921875, 3587.581298828125, 2277.179931640625, 6090.828125, 1930.030029296875, 4450.005859375, 15239.451171875, 15084.26953125, 6747.50341796875, 13652.931640625, 4261.79296875, 12221.7451171875, 6613.466796875, 8902.3720703125, 10690.865234375, 1329.4658203125, 4821.7666015625, 2249.980712890625, 980.9832763671875, 1411.89794921875, 6564.7001953125, 4020.1376953125, 4856.1591796875, 2834.5830078125, 11790.115234375, 2616.890625, 3899.8017578125, 4122.16259765625, 4366.6171875, 5937.5146484375, 6155.17578125, 1468.539794921875, 3841.5859375, 6464.54443359375, 1624.593017578125, 1897.549072265625, 4246.64697265625, 4017.99755859375, 2199.692138671875, 7182.8408203125, 3947.9208984375, 3317.2353515625, 4327.4677734375, 4240.1630859375, 2755.7470703125, 7323.06005859375, 6470.4091796875, 1608.2205810546875, 1193.488037109375, 12367.068359375, 4757.89306640625, 3793.223876953125, 4240.98095703125, 6403.197265625, 2965.29150390625, 5407.90185546875, 11707.009765625, 5358.1640625, 3930.99267578125, 1746.078857421875, 3267.52587890625, 8194.3359375, 4417.7685546875, 716.5361938476562, 1176.9102783203125, 5375.2197265625, 5061.5703125, 1557.1536865234375, 2452.12841796875, 10931.88671875, 7379.2939453125, 7088.8408203125, 3911.148193359375, 4942.1396484375, 1845.65234375, 7844.41943359375, 6490.861328125, 4567.09765625, 14025.298828125, 8987.68359375, 3815.644775390625, 7924.7421875, 7200.099609375, 5762.32421875, 3095.0732421875, 2288.775634765625, 6831.6171875, 8663.0029296875, 2884.6904296875, 5078.26904296875, 6257.1025390625, 9639.53125, 4519.33251953125, 4254.48388671875, 1501.1632080078125, 9305.1474609375, 7454.79443359375, 5382.9384765625, 19222.6953125, 7176.26708984375, 6128.81103515625, 8434.3583984375, 6823.28515625, 8573.443359375, 9912.2353515625, 3920.54736328125, 6064.5087890625, 10616.0390625, 4255.9091796875, 8334.05859375, 3672.953125, 7434.9150390625, 4765.5810546875, 3181.064697265625, 6562.3515625, 1807.5059814453125, 3991.38916015625, 1868.38720703125, 3947.02294921875, 2383.42333984375, 3722.717041015625, 10911.1845703125, 5917.6171875, 2892.2783203125, 749.3372802734375, 5265.2041015625, 4616.45556640625, 2404.9453125, 7061.1982421875, 12239.9111328125, 3421.968017578125, 2827.33203125, 5833.6201171875, 21470.4140625, 6052.15283203125, 3644.36181640625, 6150.02099609375, 3842.96875, 7910.705078125, 7006.5048828125, 4761.64892578125, 6728.06689453125, 3372.848388671875, 3774.2568359375, 5142.69970703125, 4782.287109375, 2025.6162109375, 2691.984619140625, 3916.785888671875, 4593.4052734375, 5529.69677734375, 3109.125, 4619.5966796875, 5311.07763671875, 5159.828125, 5319.904296875, 987.3319091796875, 4427.08447265625, 4523.49365234375, 3708.859619140625, 2083.320068359375, 2207.77587890625, 2388.431884765625, 3317.785400390625, 1253.403076171875, 3243.15869140625, 4396.837890625, 1569.30859375, 3839.703369140625, 4479.53466796875, 2907.111328125, 2321.645263671875, 1483.8397216796875, 2873.658447265625, 4134.72900390625, 2248.147705078125, 2299.61962890625, 2605.13671875, 1711.1744384765625, 2552.002685546875, 1036.319580078125, 2389.596923828125, 4121.421875, 2944.489501953125, 2009.18798828125, 3073.064208984375, 2250.270751953125, 1637.1353759765625, 1568.9346923828125, 2792.8916015625, 3510.38525390625, 3247.67431640625, 1837.58740234375, 3255.488037109375, 1915.151123046875, 1762.0904541015625, 5712.2919921875, 4504.14404296875, 4573.01025390625, 3262.462646484375, 2632.509033203125, 2523.518798828125, 4320.744140625, 2444.181396484375, 2981.3623046875, 3469.886962890625, 4836.068359375, 1031.2486572265625, 1659.6181640625, 552.2759399414062, 3681.4931640625, 2431.858154296875, 1689.151123046875, 2480.75830078125, 2289.9052734375, 1907.3330078125, 1869.119384765625, 1062.5616455078125, 2063.317626953125, 1424.4595947265625, 1744.8719482421875, 1745.21728515625, 896.6965942382812, 2001.675537109375, 3590.398681640625, 2991.721923828125, 4299.02392578125, 1562.430419921875, 1133.7080078125, 3591.896484375, 1860.0828857421875, 2084.341064453125, 3375.345703125, 2115.083251953125, 1438.5093994140625, 858.6090698242188, 3032.810302734375, 1127.2095947265625, 4385.72412109375, 2245.971435546875, 1261.4969482421875, 1736.2314453125, 3205.22314453125, 2978.97900390625, 1410.5509033203125, 266.1108093261719, 2400.2880859375, 4296.640625, 3647.12939453125, 1455.3787841796875, 1759.41748046875, 1946.32666015625, 2341.97509765625, 2088.301513671875, 2700.6904296875, 1132.2342529296875, 2833.14697265625, 2458.978271484375, 5989.7353515625, 1812.4532470703125, 1504.266357421875, 2127.9951171875, 1578.6053466796875, 1239.9483642578125, 2388.6376953125, 2106.660888671875, 1188.6875, 1152.1907958984375, 2689.165283203125, 2654.95849609375, 2367.7373046875, 1161.02978515625, 1929.822021484375, 3734.792236328125, 1402.875, 2826.191162109375, 3867.730224609375, 796.4616088867188, 3356.365234375, 3631.335205078125, 4175.22705078125, 1792.99609375, 1568.1572265625, 2397.253662109375, 1349.4830322265625, 1098.2691650390625, 2309.607177734375, 601.3020629882812, 2847.295166015625, 1994.444580078125, 2596.053955078125, 1213.1539306640625, 1789.9267578125, 3238.2236328125, 2375.626220703125, 2355.172119140625, 2481.303955078125, 3530.109130859375, 3191.28271484375, 1412.1878662109375, 558.6497192382812, 1906.2232666015625, 1217.619140625, 2588.033203125, 1453.1256103515625, 2744.654052734375, 766.616455078125, 1795.6153564453125, 822.8753662109375, 1693.9071044921875, 2733.426025390625, 2742.266845703125, 4024.84619140625, 1954.7086181640625, 2835.22998046875, 2418.33642578125, 2741.2890625, 2336.1435546875, 3743.46337890625, 2518.10888671875, 1753.2369384765625, 2480.426025390625, 2478.64306640625, 1165.75390625, 1985.113525390625, 3391.50341796875, 2004.2833251953125, 4249.16552734375, 1912.8970947265625, 1571.3663330078125, 1400.904296875, 2739.9697265625, 1418.242919921875, 1668.7679443359375, 1384.3902587890625, 1202.1971435546875, 1030.7725830078125, 2739.1357421875, 3008.49609375, 2821.423095703125, 3611.669921875, 2870.04541015625, 2351.05810546875, 4658.61328125, 2142.0478515625, 1430.112548828125, 3259.788330078125, 2749.8203125, 2278.02587890625, 2308.077392578125, 3344.107421875, 1539.1319580078125, 2684.682861328125, 4494.3330078125, 1178.612548828125, 1646.794921875, 1769.97265625, 2703.295654296875, 1653.346435546875, 1371.09521484375, 1695.002685546875, 1041.9193115234375, 3406.429443359375, 2581.458251953125, 2598.90576171875, 2808.635986328125, 4287.69970703125, 2329.563232421875, 4190.74658203125, 2052.5400390625, 2494.181640625, 2182.193359375, 850.8114013671875, 907.1988525390625, 1489.216552734375, 2398.435791015625, 1525.8470458984375, 586.5490112304688, 2343.562255859375, 2562.84716796875, 730.1206665039062, 2181.184326171875, 2252.220947265625, 2901.8212890625, 2001.706787109375, 2246.95458984375, 1147.297119140625, 1001.9070434570312, 1984.1556396484375, 2594.15966796875, 2134.284423828125, 3759.230712890625, 3670.362548828125, 1326.507568359375, 2056.304443359375, 1362.6512451171875, 2393.3203125, 1904.64599609375, 2671.021728515625, 1737.16748046875, 3761.75927734375, 5018.02978515625, 2047.673095703125, 2227.319580078125, 1642.17578125, 2407.448974609375, 2118.4189453125, 1523.202880859375, 2228.477783203125, 1736.66455078125, 3639.071533203125, 2229.29345703125, 1085.8232421875, 2614.6142578125, 4644.53564453125, 976.8319091796875, 2021.487060546875, 3568.057373046875, 1609.7310791015625, 1451.993408203125, 1181.513427734375, 1792.3480224609375, 1677.2325439453125, 2415.4140625, 2719.098388671875, 2135.420654296875, 2508.7109375, 1242.7640380859375, 2371.828369140625, 3814.690673828125, 1425.23779296875, 1339.868408203125, 1637.3310546875, 1736.393310546875, 2426.661376953125, 2606.019775390625, 2450.86669921875, 2444.612548828125, 1683.1229248046875, 2497.584716796875, 2738.813232421875, 4284.26806640625, 3646.726318359375, 1818.2672119140625, 3107.116943359375, 3028.860107421875, 2687.0, 1794.7213134765625, 1975.0963134765625, 3742.64111328125, 6098.87548828125, 836.9785766601562, 1472.049072265625, 1163.1136474609375, 1547.216552734375, 2165.197021484375, 1727.027587890625, 1493.1051025390625, 1951.992919921875, 4302.7421875, 3336.644775390625, 1356.539306640625, 2626.097412109375, 2192.270263671875, 2662.393798828125, 985.0213623046875, 2158.416259765625, 1634.908935546875, 2890.26513671875, 5976.00537109375, 3795.24853515625, 3975.068115234375, 1148.476806640625, 2814.520263671875, 982.2083740234375, 2056.56103515625, 3554.2265625, 2031.44921875, 2249.94873046875, 2255.074951171875, 3051.341796875, 3912.6376953125, 2390.506103515625, 1613.780517578125, 1996.33642578125, 2791.50439453125, 3634.898681640625, 2820.7021484375, 3776.443603515625, 660.6354370117188, 2298.5009765625, 1790.34912109375, 3165.298095703125, 1987.1556396484375, 2010.0146484375, 1196.530029296875, 1645.1021728515625, 3321.47509765625, 3180.4814453125, 3972.34521484375, 2726.7744140625, 5771.73388671875, 1029.5552978515625, 1932.0743408203125, 1747.6376953125, 1463.45458984375, 1583.1751708984375, 2649.65087890625, 1736.9383544921875, 3482.7412109375, 2227.879638671875, 2008.2462158203125, 1547.37548828125, 3065.088623046875, 3699.025634765625, 3145.07763671875, 3119.10693359375, 3935.00927734375, 1660.648681640625, 5275.64208984375, 3219.30078125, 3859.50439453125, 3048.89501953125, 2167.494140625, 4603.9296875, 3072.48974609375, 3019.7900390625, 2834.657470703125, 2242.470703125, 1996.482666015625, 3057.632080078125, 3941.524658203125, 3395.169921875, 2610.047119140625, 2054.88427734375, 2405.57861328125, 6151.85107421875, 2474.025146484375, 1993.12939453125, 2864.208984375, 1702.848876953125, 1721.1636962890625, 3116.126953125, 2975.50634765625, 2291.368896484375, 3252.061279296875, 2216.114990234375, 4841.6298828125, 2933.92138671875, 1598.4588623046875, 2129.500732421875, 2675.50244140625, 931.9230346679688, 2215.49853515625, 2452.681640625, 2350.9638671875, 1046.8560791015625, 1335.7501220703125, 1783.7515869140625, 2658.178955078125, 1167.5103759765625, 1891.849853515625, 3125.259765625, 3843.330078125, 2390.0302734375, 3898.050537109375, 1415.7200927734375, 2748.961669921875, 3552.72314453125, 4436.8623046875, 3019.842041015625, 2359.488037109375, 1781.154296875, 2842.0068359375, 1627.329345703125, 3520.331298828125, 4989.41748046875, 3685.349609375, 2400.94677734375, 4582.60205078125, 5008.4091796875, 2911.02197265625, 6513.740234375, 3901.745849609375, 1906.3614501953125, 3382.38671875, 3122.636962890625, 5931.984375, 2780.96435546875, 972.9447021484375, 3049.192138671875, 2068.720458984375, 2695.940185546875, 2955.719970703125, 2014.349365234375, 3637.6845703125, 3207.26220703125, 2743.301025390625, 7716.07080078125, 5645.9765625, 2569.959228515625, 2732.0439453125, 5764.46044921875, 1928.4991455078125, 1323.712646484375, 4763.716796875, 3701.017578125, 3483.376220703125, 3674.819580078125, 8346.9140625, 3301.56396484375, 5089.505859375, 4445.2041015625, 2885.901611328125, 9942.8935546875, 8811.9765625, 4718.1318359375, 4196.16357421875, 3655.057373046875, 1395.3944091796875, 2859.836181640625, 3623.74267578125, 4108.89794921875, 1725.6134033203125, 2792.726806640625, 3774.140625, 2641.548828125, 2025.1348876953125, 5192.17578125, 8172.4912109375, 32500.265625, 8076.74462890625, 6952.08984375, 1619.680908203125, 1969.2972412109375, 3529.75927734375, 4923.6943359375, 6429.8271484375, 5008.50146484375, 3564.26953125, 6728.3642578125, 4137.244140625, 4282.69677734375, 5573.3232421875, 8395.0556640625, 9834.275390625, 64911.015625, 40611.4921875, 4058.06201171875, 2914.968017578125, 5075.4580078125, 5003.11328125, 3660.564208984375, 4927.0341796875, 3752.33642578125, 4828.22265625, 1795.6334228515625, 5897.62353515625, 2934.096435546875, 9464.5087890625, 7496.7861328125, 6489.189453125, 203235.125, 14580.416015625, 3165.96484375, 8518.6708984375, 5983.396484375, 2966.931396484375, 5645.13525390625, 1849.267333984375, 1929.171142578125, 5261.0234375, 3029.642822265625, 1470.110107421875, 2266.612060546875, 5331.5625, 7182.90087890625, 3241.889892578125, 4307.52587890625, 6886.59423828125, 3407.98291015625, 9965.126953125, 7556.2265625, 4224.72412109375, 10278.2880859375, 6843.50048828125, 4073.515625, 8933.521484375, 2580.7177734375, 5631.54541015625, 1299.9239501953125, 2276.6640625, 3995.1279296875, 8263.453125, 2587.406494140625, 9589.8564453125, 9691.13671875, 3304.2041015625, 3926.3466796875, 4089.9462890625, 3407.9541015625, 3566.67724609375, 1085.481201171875, 3399.58740234375, 8435.92578125, 2515.7939453125, 4863.36181640625, 8050.65380859375, 8216.0234375, 7614.66455078125, 4509.26708984375, 5005.8486328125, 6238.66796875, 8141.32861328125, 3902.7314453125, 7223.69384765625, 6766.142578125, 12685.421875, 11063.501953125, 7917.14794921875, 8643.17578125, 2551.48388671875, 3647.812744140625, 5211.3427734375, 9405.576171875, 9628.1337890625, 2099.476806640625, 1771.256103515625, 4803.60595703125, 2148.595947265625, 4358.30517578125, 3097.355712890625, 4569.60595703125, 6377.04541015625, 4056.19140625, 7456.60546875, 23108.111328125, 8312.9814453125, 9280.1845703125, 3669.8310546875, 3265.31640625, 6365.2421875, 6897.28564453125, 1710.082275390625, 5514.60546875, 13137.626953125, 6399.18994140625, 9609.154296875, 4722.9521484375, 9548.5341796875, 1004.3084106445312, 11257.5234375, 13989.16015625, 8404.814453125, 4042.2490234375, 4862.220703125, 6707.3134765625, 5511.31396484375, 6911.8076171875, 11814.708984375, 4843.87548828125, 3896.5361328125, 3885.977294921875, 10778.55078125, 21656.671875, 4678.21044921875, 7684.1494140625, 17228.107421875, 10782.9306640625, 9257.63671875, 7665.01904296875, 6538.92236328125, 4641.73779296875, 9555.517578125, 20292.28125, 6546.93896484375, 7079.30078125, 2779.25927734375, 4532.419921875, 5528.3818359375, 3617.268310546875, 9143.0068359375, 4671.1611328125, 4825.205078125, 6245.2431640625, 6144.466796875, 4115.69921875, 7251.349609375, 5429.8701171875, 5909.09814453125, 7307.3037109375, 5633.36279296875, 10048.712890625, 7460.7724609375, 9139.203125, 9225.5107421875, 5540.955078125, 5979.11328125, 4822.12109375, 652.6008911132812, 0.0, 51.104217529296875, 9160.8232421875, 160.47560119628906, 934.0054931640625, 1273.878173828125, 2672.475341796875, 754.8969116210938, 5106.7958984375, 2261.35205078125, 2226.632568359375, 9105.00390625, 6587.16015625, 1805.392578125, 3854.208740234375, 3849.286865234375, 0.0, 2454.09716796875, 0.0, 7010.7294921875, 6191.1123046875, 18227.7421875, 8009.265625, 713.3704223632812, 8484.544921875, 974.621337890625, 2661.376708984375, 6376.05322265625, 8073.96142578125, 3070.855712890625, 1801.718505859375, 0.0, 0.0, 0.0, 0.0, 24899.310546875, 0.0, 1197.098876953125, 0.0, 14259.5849609375, 98.85546875, 0.0, 600.7032470703125, 1770.3671875, 0.0, 1012.6064453125, 210.63848876953125, 5606.42333984375, 8294.529296875, 6277.6376953125, 3646.5048828125, 3671.898193359375, 7997.9287109375, 13341.72265625, 7333.0361328125, 10963.9775390625, 12644.3505859375, 10102.6396484375, 2266.67431640625, 1778.1282958984375, 803.054931640625, 2295.77783203125, 2230.589111328125, 2172.4326171875, 21170.9375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 21983.537109375, 0.0, 0.0, 0.0, 34308.2109375, 0.0, 0.0, 846.8341674804688, 0.0, 29466.3203125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 24853.306640625, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 7490.306640625, 13870.34375, 0.0, 0.0, 0.0, 0.0, 0.0, 32872.875, 57443.703125, 0.0, 0.0, 0.0, 0.0, 0.0, 3787.77197265625, 0.0, 0.0, 0.0, 2065.521484375, 0.0, 20752.990234375, 7489.50927734375, 9740.375, 0.0, 6025.47314453125, 0.0, 116810.1640625, 10485.6123046875, 0.0, 0.0, 0.0, 0.0, 23344.328125, 0.0, 0.0, 1189.69580078125, 702.8663330078125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 30606.046875, 918.174560546875, 0.0, 0.0, 0.0, 38573.0078125, 2550.520263671875, 8702.677734375, 2569.463623046875, 0.0, 11270.2421875, 0.0, 601.422119140625, 6357.25244140625, 12130.869140625, 24942.83984375, 3035.90966796875, 0.0, 27995.3203125, 0.0, 36733.6875, 19952.3046875, 0.0, 34592.77734375, 8357.724609375, 0.0, 5461.1435546875, 0.0, 1794.744873046875, 0.0, 1828.7730712890625, 21752.86328125, 16213.5234375, 876.351318359375, 4681.07373046875, 0.0, 661.921875, 3115.583984375, 10879.76171875, 2982.8896484375, 5084.2880859375, 1190.7940673828125, 7317.83935546875, 0.0, 0.0, 9448.3203125, 10926.8017578125, 0.0, 2770.1259765625, 6824.6123046875, 299.63427734375, 4905.32763671875, 4832.1796875, 7796.2265625, 1721.9990234375, 29723.486328125, 20223.5390625, 6242.94140625, 175.20602416992188, 1325.4412841796875, 7065.20263671875, 12656.4169921875, 3327.2236328125, 382.660400390625, 4928.6044921875, 8202.240234375, 9095.6484375, 14420.3193359375, 1394.124267578125, 12374.748046875, 10014.39453125, 11045.7421875, 6565.77001953125, 35248.9375, 4573.3388671875, 13137.349609375, 13474.1513671875, 4649.12451171875, 10292.919921875, 13322.109375, 8661.44921875, 14371.4189453125, 24413.123046875, 8105.453125, 6189.65625, 722.3017578125, 15829.0048828125, 4323.93359375, 2780.80810546875, 35196.78515625, 0.0, 0.0, 18123.0859375, 3655.182861328125, 26844.044921875, 643.5576171875, 4444.05078125, 46086.49609375, 11447.98046875, 3504.86376953125, 1391.58544921875, 0.0, 631.3125, 1841.99609375, 0.0, 10520.171875, 2445.599365234375, 4247.61328125, 9771.7568359375, 0.0, 26885.625, 29366.501953125, 17659.935546875, 13241.267578125, 2655.89501953125, 0.0, 815.801025390625, 8139.99462890625, 0.0, 0.0, 3691.34716796875, 2777.9453125, 5296.6650390625, 23109.228515625, 51583.5390625, 1786.3955078125, 91963.28125, 5581.3779296875, 425.3928527832031, 39418.4921875, 19304.896484375, 0.0, 30644.201171875, 0.0, 6350.78857421875, 32851.640625, 18644.314453125, 216.18731689453125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 27895.240234375, 16506.67578125, 0.0, 0.0, 0.0, 0.0, 42158.2890625, 34210.66796875, 37848.83984375, 49937.02734375, 0.0, 0.0, 71465.890625, 0.0, 47592.9765625, 90805.953125, 33392.84375, 0.0, 0.0, 0.0, 0.0, 5935.7802734375, 0.0, 3191.91455078125, 0.0, 10571.9482421875, 0.0, 0.0, 1630.6845703125, 0.0, 0.0, 15874.60546875, 0.0, 0.0, 0.0, 17381.37890625, 0.0, 3911.630126953125, 14028.14453125, 43045.62890625, 536.9501342773438, 31539.02734375, 39711.796875, 49935.328125, 33648.3984375, 0.0, 18771.765625, 31468.44140625, 0.0, 0.0, 1342.72607421875, 22938.572265625, 5399.8828125, 0.0, 0.0, 21445.5546875, 0.0, 0.0, 48701.5, 48877.6171875, 49600.8203125, 65548.6328125, 0.0, 38407.1875, 0.0, 0.0, 0.0, 0.0, 13211.37890625])], 
      dtype=[('Eventshape_rhoKt4LC', '<f4'), ('gTowerE', 'O')])

I have a feeling that it becomes an issue since it's not "wrapped" in an object ndarray.

Dynamic allocation of branches

Basically - as the name suggests -- we have a ROOT file we wish to open, and we open it with some set number of branches via

data = rnp.root2rec(
                filename,\
                treename='%s/%s' % (directory,tree),\
                branches=initialBranches,\
                start=(event_num),\
                stop=(event_num+1)  )

and at this point, data contains the representation of that TTree for some given number of events (1 or many). Perhaps we make a call via

data['missingBranch'] # or data.missingBranch

for a branch that we didn't load up with the root2rec() at first, but we want to load that particular branch at this particular time during the analysis. Currently, the only way to do that is opening the file and loading that branch again, or just putting it in the list of initialBranches (but then it's included for all events, and not just select events). In other words - we don't know we need the branch until we do some processing with it.

Below is code that uses PyROOT and does dynamic allocation as it keeps the TFile() pointer and just grabs the missing branch via python's __missing__() constructor

from __future__ import with_statement
import os,sys,copy,time,cPickle
from tempfile import mkdtemp
from array import array
from functools import partial
#import numpy
import PyCintex; PyCintex.Cintex.Enable()
from math import (hypot,sqrt,pi)
from operator import (attrgetter,itemgetter)
import operator
import zlib
import sys,gc
gc.enable(); gc.set_threshold(7000)
from types import (ListType,StringType,FloatType)
import pprint
import ROOT
from ROOT import (TObject,gROOT,
                  AddressOf,
                  gDirectory,TDirectory,TFile,
                  TList,TClonesArray,TObjArray,
                  TH1,TH1F,TH1D,TH2,TH2F,TH2D,TH3F,
                  TProfile,TProfile2D,TProfile3D,
                  TF1,
                  TGraphErrors,
                  TVectorT,TMatrixT,
                  TChain,TTree,TCut,TEntryList,
                  TLegend,
                  TLorentzVector,
                  TPySelector,TDSet)
gROOT.ProcessLine("gErrorIgnoreLevel = 1;")
#
class TREEWRAPPER(dict):
    # this class has a memory leak.  does garbage collection help?
    def __init__(self,tree=None):
        self.TREE=tree
        #self.LEAVES=[i.GetName() for i in self.TREE.GetListOfLeaves()]  
        self.LEAVES=list(self.TREE.GetListOfLeaves())  
        if len(self.LEAVES)>0:
            self.TREE.SetBranchStatus("*",1)
        self.TREE.GetEntry(0)
        self.VARIABLES={}
        self.BRANCHES={}
        self.LOADED={}
        self.STORAGE={}
        for i in self.TREE.GetListOfLeaves():
            variable=i.GetName()
            vtype=i.GetTypeName()
            self.VARIABLES[variable]=vtype
            #if vtype.startswith('pair') and variable.endswith('.first'):
            #    self.VARIABLES[variable.split('.first')[0]]=vtype.replace('pair','map')
            if variable.endswith('.first'):
                self.VARIABLES[variable.split('.first')[0]]='map'
        # must have at least one active branch or GetEntry()==0 and TSelector fails
        if len(self.LEAVES)>0:
            self.TREE.SetBranchStatus("*",0)
            self.TREE.SetBranchStatus(variable,1)
        return

    def __missing__(self,k):
        try:
            self.activateBranches(k)
            ##self.Info(self.TREE.GetName(),'adding variable %s...%s' % (k,self.get(k)))
            return self.get(k)
        except:
            #print 'Variable %s is MISSING!!!!' % k
            return -666

    #def GetEntry(self,entry):
    #    if len(self)==0:
    #        return self.TREE.GetEntry(entry)
    #    else:
    #        #return sum([i(entry) for i in self.BRANCHPTR.values()])
    #        foo=0
    #        for i in self:
    #            #print i,self.TREE.GetBranch(i).GetEntry(entry)
    #            foo+=self.TREE.GetBranch(i).GetEntry(entry)
    #        return foo

    def loadBranch(self,i):
        #self.BRANCHPTR[i]=self.TREE.GetBranch(i).GetEntry
        #self.BRANCHPTR[i](self.TREE.GetReadEntry())
        #self.TREE.SetBranchStatus(i,1)
        #self.TREE.AddBranchToCache(i)
        #self.wrap(i,self.VARIABLES[i])
        #self.BRANCHPTR[i](self.TREE.GetReadEntry())
        self.TREE.GetBranch(i).GetEntry(self.TREE.GetReadEntry())
        self.TREE.SetBranchStatus(i,1)
        self.TREE.AddBranchToCache(i)
        self.wrap(i,self.VARIABLES[i])
        self.TREE.GetBranch(i).GetEntry(self.TREE.GetReadEntry())
        return

    def activateBranches(self,branches):
        if branches=='*': branches=self.VARIABLES.keys()
        if type(branches)!=ListType: branches=[branches]
        for i in branches:
            self.TREE.GetReadEntry()
            self.loadBranch(i)
        return

    def deactivateBranches(self,branches):
        if branches=='*': branches=self.VARIABLES.keys()
        if type(branches)!=ListType: branches=[branches]
        for i in branches:
            self.TREE.SetBranchStatus(i,0)
            del self[i]
            #del self.BRANCHPTR[i]
        # must have at least one active branch or GetEntry()==0 and TSelector fails
        self.activateBranches(i)
        return


    def __getitem__(self,k):
        foo=dict.__getitem__(self,k)
        if type(foo)==array:
            return foo[0]
        elif type(foo) in [ROOT.string]:
            return '%s' % foo
        else:
            return foo

    def __getattr__(self,name):
        return getattr(self.TREE,name)

    def dynamicCompile(self,vtype):
        ROOT.TClass.RemoveClass( ROOT.TClass.GetClass(vtype) )
        foo=mkdtemp()
        fn=foo+'/'+vtype.replace('>','_').replace('<','_').replace(' ','_')+'.C'
        f=open(fn,"w")
        f.write("#include <vector>\n#ifdef __MAKECINT__\n#pragma link C++ class %s+;\n#endif\n" % vtype)
        ##f.write("#include <vector>\n#ifdef __MAKECINT__\n#pragma link C++ class %s+;\n#endif\n" % vtype.replace('vector','std::vector'))
        f.close()
        ROOT.gInterpreter.AddIncludePath(foo)
        gROOT.ProcessLine(".L %s+" % fn)
        return

    def wrap(self,variable,vtype):
        # use self.get here instead of self[] due to predefined __getitem__
        ###############################################################
        #
        # To read variables from a TTree
        #
        ###############################################################        
        if vtype in   ['Char_t','Int_t','Bool_t']:
            self[variable]=array('i',1*[0])
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in   ['UInt_t']:
            self[variable]=array('L',1*[0])
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['Long64_t']:
            self[variable]=array('l',1*[0])
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['Float_t']:
            self[variable]=array('f',1*[0.0])
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['Double_t']:
            self[variable]=array('d',1*[0.0])
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['string']:
            self[variable]=ROOT.std.string()
            self.TREE.SetBranchAddress(variable,AddressOf(self.get(variable)))
        elif vtype.startswith('map'):
            #!Works but very SLOW and clumsy!#
            self[variable]=getattr(self.TREE,variable)
        elif vtype.startswith('vector<vector'):
            #!Works but SLOW and annoying!#
            try:
                self[variable] = getattr(ROOT,vtype)()
            except AttributeError:
                self.dynamicCompile(vtype)
                self[variable] = getattr(ROOT,vtype)()
            self[variable].resize(500)
            [i.resize(500) for i in self[variable]]
            self.TREE.SetBranchAddress(variable,AddressOf(self.get(variable))) 
        elif vtype.startswith('vector'):
            self[variable] = getattr(ROOT,vtype)()
            self[variable].resize(500)
            self.TREE.SetBranchAddress(variable,AddressOf(self.get(variable)))
        elif vtype in ['TClonesArray']:
            # python should fill the TClonesArray properly
            self.STORAGE[variable] = TClonesArray("TObject", 500)
            #self.STORAGE[variable].IsA().GetDataMember("fEditable")
            self.TREE.SetBranchAddress(variable, self.STORAGE[variable])
            self[variable] = getattr(self.TREE,variable)
        elif vtype in ['TObjArray']:
            self[variable] = TObjArray(500)
            self.TREE.SetBranchAddress(variable, AddressOf(self.get(variable)))
        ###############################################################
        #
        # To declare variables in a TTree
        #
        ###############################################################        
        elif vtype in ['S','s']:
            self[variable]=ROOT.std.string()
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable))
            self.TREE.SetBranchAddress(variable,AddressOf(self.get(variable)))
        #elif vtype in ['S','s']:
        #    self[variable]=array('c',1*[''])
        #    self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable),"%s/C" % variable)
        #    self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['I','i']:
            self[variable]=array('i',1*[0])
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable),"%s/I" % variable)
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['L','l']:
            self[variable]=array('l',1*[0])
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable),"%s/L" % variable)
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['F','f']:
            self[variable]=array('f',1*[0.0])
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable),"%s/F" % variable)
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype in ['D','d']:
            self[variable]=array('d',1*[0.0])
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable),"%s/D" % variable)
            self.TREE.SetBranchAddress(variable,self.get(variable))
        elif vtype.startswith('v<'):
            which=vtype.split('<')[1].split('>')[0]
            self[variable] = getattr(ROOT,'vector<%s>' % which)()
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable))
            self.TREE.SetBranchAddress(variable,AddressOf(self.get(variable))) 
        elif vtype.startswith(('TOA<')):
            which=vtype.split('<')[1].split('>')[0]
            self[variable] = TObjArray(500)
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable),32000,0)
            self.TREE.SetBranchAddress(variable,AddressOf(self.get(variable))) 
        #elif vtype.startswith(('TCA<')):
        #    which=vtype.split('<')[1].split('>')[0]
        #    self.STORAGE[variable] = TClonesArray(which,500)
        #    self.BRANCHES[variable]=self.TREE.Branch(variable,self.STORAGE[variable],32000,0)
        #    self.TREE.SetBranchAddress(variable,self.STORAGE[variable])
        #    self[variable] = getattr(self.TREE,variable)
        elif vtype.startswith(('TCA<')):
            which=vtype.split('<')[1].split('>')[0]
            self[variable] = TClonesArray(which,500)
            self.BRANCHES[variable]=self.TREE.Branch(variable,self.get(variable),32000,0)
            self.TREE.SetBranchAddress(variable,self.get(variable))
        else:
            #### this is very slow -- how can we do this with memory addresses?!?
            print 'SLOW ACCESS: ',variable,vtype
            #self[variable]=getattr(self.TREE,variable)
            pass

Variable-length arrays of type `unsigned short` causing crash

Hi everyone,

Whenever I try loading a ROOT file with a variable-length 1D array of type unsigned short, root_numpy will cause Python to crash with this error message

Python(74303,0x7fff7d3c3310) malloc: *** error for object 0x7f8abe3bd9c8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

This doesn't happen with variable-length 1D arrays of any other types (as far as I know). Here is an example script that generates a ROOT file with variable-length 1D arrays of different types (run with root -l var_array.c).

var_array.c:

#include "TFile.h"
#include "TTree.h"

void write() {

  const unsigned int max_capacity = 500;
  int elements;
  short short_[max_capacity];
  unsigned short ushort_[max_capacity];
  int int_[max_capacity];
  unsigned int uint_[max_capacity];
  long long_[max_capacity];
  unsigned long ulong_[max_capacity];
  float float_[max_capacity];
  double double_[max_capacity];
  bool bool_[max_capacity];

  TFile f("var_array.root", "recreate");
  TTree * t = new TTree("t", "");
  // http://root.cern.ch/root/html/TBranch.html#TBranch:TBranch@2
  t->Branch("elements", &elements, "elements/I");
  t->Branch("short_", short_, "short_[elements]/S");
  t->Branch("ushort_", ushort_, "ushort_[elements]/s");  // removing this line will make root_numpy run smoothly
  t->Branch("int_", int_, "int_[elements]/I");
  t->Branch("uint_", uint_, "uint_[elements]/i");
  t->Branch("long_", long_, "long_[elements]/L");
  t->Branch("ulong_", ulong_, "ulong_[elements]/l");
  t->Branch("float_", float_, "float_[elements]/F");
  t->Branch("double_", double_, "double_[elements]/D");
  t->Branch("bool_", bool_, "bool_[elements]/O");

  for (int i = 0; i < 1000; i++) {
    int rand = gRandom->Rndm() * (max_capacity-1);
    elements = rand;
    for (int j = 0; j < elements; j++) {
      short_[j] = 1;
      ushort_[j] = 1;
      int_[j] = 1;
      uint_[j] = 1;
      long_[j] = 1;
      ulong_[j] = 1;
      float_[j] = 1.0;
      double_[j] = 1.0;
      bool_[j] = true;
    }
    t->Fill();
  }
  t->Print();
  f.cd();
  t->Write();
}

void var_array()
{
  write();
}

If I try loading the generated ROOT file with root_numpy

from root_numpy import root2array
root2array("var_array.root")

I'll get the error shown at the top of this post. However, if I remove the line

      t->Branch("ushort_", ushort_, "ushort_[elements]/s");  // removing this line will make root_numpy run smoothly

from var_array.c, everything will work just fine.

Randomly missing columns

I have observed rare instances where root_numpy will produce an array with a missing column. I did not explicitly request certain columns but let root_numpy determine which ones it could convert. Very rarely, when using the root2hdf5 script in rootpy, pytables will complain that a recarray is not compatible with an existing table when converting a large tree in chunks because the next chunk for some reason is missing a column. All instances of this problem have been while converting on the order of 800 trees in one large ROOT file. Interestingly, rerunning the same conversion on the same file can then produce the correct tables without problems.

A more thorough investigation will be required. Just noting the issue here for now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.