conda-forge / root-feedstock

A conda-smithy repository for root.
BSD 3-Clause "New" or "Revised" License
28 stars 24 forks source link

Add ROOT R bindings #106

Open greg814 opened 4 years ago

greg814 commented 4 years ago

When building ROOT from source there is a cmake option to build ROOT against R. It would be great to add the ROOTR bindings and its dependencies to the conda package. Only reason for me to still go through the tedious build process manually. Thanks!

chrisburr commented 4 years ago

This should be doable, though I've never used R so I don't know how conda-forge compatible ROOT's bindings are. Do you have any recommendations of quick tests that can be used to verify if they're working? It doesn't need to be comprehensive and is only intended to catch obviously broken builds. For reference I test PyROOT using:

python -c "import ROOT"
python -c "import JupyROOT"
python -c 'import JsMVA'
python -c "import ROOT; ROOT.ROOT.EnableImplicitMT(); rdf = ROOT.RDataFrame('DecayTree', 'root://eospublic.cern.ch//eos/opendata/lhcb/AntimatterMatters2017/data/B2HHH_MagnetUp.root'); print(rdf.Cache('H1_PX').AsNumpy())"
python test_pyroot.py

where test_pyroot.py is

#!/usr/bin/env python
import sys
import ROOT

@ROOT.Numba.Declare(["float"], "float")
def fn(x):
    return x**2

assert fn(6) == 36

# ROOT doesn't like how conda-forge's Python 3.6 binaries are linked
# This is expected to fail but it should be fixed upstream rather than patched here
if sys.version_info >= (3, 7):
    assert ROOT.TPython.Exec("print(1+1)")
    assert int(ROOT.TPython.Eval("1+1")) == 2

I've opened a PR to see if it builds in https://github.com/conda-forge/root-feedstock/pull/108, if you see the CI has failed and have chance to figure out why please do! :)

greg814 commented 4 years ago

Thanks for looking into this! And BTW I believe a lot of people will move to the conda install and thus save themselves some valuable life time and quality once it's getting more popular...

In contrast to using ROOT from python, you rather use R from ROOT (at least I'm not aware that it even works the other way round). That said I'd just use one of the ROOT R tutorials to test functionality.

Interpolation.C looks like a good one because it gives you a pretty R plot when executing root -l $ROOTSYS/tutorials/Interpolation.C and alternatively in batch mode some R function output root -l -b $ROOTSYS/tutorials/Interpolation.C

Actually, I meant a simple R plot. You can do much much prettier than that...

greg814 commented 3 years ago

Did anything ever happen on that end? Thanks.

greg814 commented 3 years ago

@chrisburr Has anybody been looking into this yet? I'm doing yet another tedious install from source and I'd really like to switch to conda. However without R interaction it's not feasible for me... :/ Thanks