def createTPString(self, lep, efficiency): lepType = lep[0] effName = self.effNames[efficiency.lower()] fName = '_'.join([effName, lepType]) codeFile = os.path.join(self.path, fName+'.C') ROOTComp.register_file(codeFile, [fName]) # force to compile, save as Python function self.functions[lepType][effName] = getattr(ROOTComp, fName) # String to call the function from a draw string self.fStrings[lepType][effName] = self.fStrTemp.format(fName)
import rootpy.compiled as C C.register_file("test_compiled.cxx", ["AnswerToLtUaE", "RootpyTestCompiled"]) C.register_code(""" #include <string> std::string _rootpy_test() { return "Hello, world"; } """, "_rootpy_test".split()) def test_compiled(): assert C.AnswerToLtUaE() == 42 assert C.RootpyTestCompiled().blah() == 84 assert C._rootpy_test() == "Hello, world"
import rootpy.compiled as C import os HERE = os.path.dirname(os.path.abspath(__file__)) PATH = os.path.join(HERE, 'src', 'AsymptoticsCLs.C') C.register_file(PATH, ['AsymptoticsCLs']) from rootpy.compiled import AsymptoticsCLs __all__ = ['AsymptoticsCLs']
import rootpy.compiled as C import os HERE = os.path.dirname(os.path.abspath(__file__)) C.register_file(os.path.join(HERE, '1p_odd_BDT_1p_odd.class.C'), ['ReadBDT_1p_odd']) C.register_file(os.path.join(HERE, 'mp_odd_BDT_mp_odd.class.C'), ['ReadBDT_mp_odd']) C.register_file(os.path.join(HERE, '1p_even_BDT_1p_even.class.C'), ['ReadBDT_1p_even']) C.register_file(os.path.join(HERE, 'mp_even_BDT_mp_even.class.C'), ['ReadBDT_mp_even']) from rootpy.compiled import ( ReadBDT_1p_odd, ReadBDT_1p_even, ReadBDT_mp_odd, ReadBDT_mp_even) __all__ = [ 'ReadBDT_1p_odd', 'ReadBDT_mp_odd', 'ReadBDT_1p_even', 'ReadBDT_mp_even', ]
# Copyright 2012 the rootpy developers # distributed under the terms of the GNU General Public License import rootpy.compiled as C C.register_file("test.cxx", ["AnswerToLtUaE", "RootpyTestCompiled"]) C.register_code( """ #include <string> std::string _rootpy_test() { return "Hello, world"; } """, "_rootpy_test".split()) def test_compiled(): assert C.AnswerToLtUaE() == 42 assert C.RootpyTestCompiled().blah() == 84 assert C._rootpy_test() == "Hello, world"
try: import ROOT ROOT.PyConfig.IgnoreCommandLineOptions = True # do not hijack # cmdline options from rootpy.interactive import wait pass except ImportError as e: print e sys.stderr.write("To run this script pyROOT and rootpy" " has to be properly installed.\n") exit(1) import rootpy.compiled as C pwd = os.path.dirname(__file__) C.register_file( pwd + "/mylangaus.cxx", ["langaufun"]) CHAN_COL = 1 DATA_COL = 2 COLORS=[2,8,4,6,7,9] colors = cycle(COLORS) def parse_infile(infile, chans=None, chan_col = CHAN_COL, data_col = DATA_COL ): """ Parses a file with data records. chans: a list of channel names; if specified, skip channels which are not in list. Returns a dict {channel_0: values_0, ... channel_N: values_N} """
import rootpy.compiled as C import os HERE = os.path.dirname(os.path.abspath(__file__)) C.register_file(os.path.join(HERE, 'runSig.C'), ['significance', 'make_asimov_data']) from rootpy.compiled import significance, make_asimov_data C.register_file(os.path.join(HERE, 'AsymptoticsCLs.C'), ['AsymptoticsCLs']) from rootpy.compiled import AsymptoticsCLs __all__ = [ 'AsymptoticsCLs', 'significance', 'make_asimov_data', ]
import rootpy.compiled as C import os HERE = os.path.dirname(os.path.abspath(__file__)) C.register_file(os.path.join(HERE, '1p_odd_BDT_1p_odd.class.C'), ['ReadBDT_1p_odd']) C.register_file(os.path.join(HERE, 'mp_odd_BDT_mp_odd.class.C'), ['ReadBDT_mp_odd']) C.register_file(os.path.join(HERE, '1p_even_BDT_1p_even.class.C'), ['ReadBDT_1p_even']) C.register_file(os.path.join(HERE, 'mp_even_BDT_mp_even.class.C'), ['ReadBDT_mp_even']) from rootpy.compiled import (ReadBDT_1p_odd, ReadBDT_1p_even, ReadBDT_mp_odd, ReadBDT_mp_even) __all__ = [ 'ReadBDT_1p_odd', 'ReadBDT_mp_odd', 'ReadBDT_1p_even', 'ReadBDT_mp_even', ]
return a_return_values def close(self): self.map('exit', [[0] for i in xrange(self.num_gpus - len(self.q_dead.queue))]) print 'Closed children' time.sleep(2) import matplotlib.pyplot as plt import matplotlib.mlab as mlab import rootpy.compiled as C from numpy.random import normal, binomial, seed, poisson from rootpy.plotting import root2matplotlib as rplt C.register_file('../../python_modules/mc_code/c_log_likelihood.C', ['smart_log_likelihood']) c_log_likelihood = C.smart_log_likelihood #import gc #gc.disable() """ import warnings #warnings.filterwarnings('error') # this turns runtime warnings into errors to # catch unexpected behavior warnings.simplefilter('error', RuntimeWarning) # this turns off a deprecation warning in general but aimed # at corners plot creation (should try to only put there) # and move back to all warnings as errors) warnings.simplefilter('ignore', DeprecationWarning) warnings.simplefilter('ignore', FutureWarning)
import rootpy.compiled as C import os HERE = os.path.dirname(os.path.abspath(__file__)) PATH = os.path.join(HERE, 'src', 'runSig.C') C.register_file(PATH, ['runSig']) from rootpy.compiled import runSig __all__ = ['runSig']
} """ import sys, os, random, time import numpy as np import cuda_full_observables_production from pycuda.compiler import SourceModule import pycuda.driver as drv import pycuda.tools import pycuda.gpuarray import rootpy.compiled as C C.register_file('c_full_observables_production_no_eff.C', ['full_matching_loop']) c_full_matching_loop = C.full_matching_loop drv.init() dev = drv.Device(0) ctx = dev.make_context(drv.ctx_flags.SCHED_AUTO | drv.ctx_flags.MAP_HOST) grid_d1 = 512 block_d1 = 1024 num_entries = int(grid_d1 * block_d1) num_iterations = 100 """ practie_kernel = pycuda.compiler.SourceModule(\""" __global__ void krnl(float *a) { int i = blockIdx.x * blockDim.x + threadIdx.x; a[i] = a[i]+1;
import ROOT ROOT.PyConfig.IgnoreCommandLineOptions = True # do not hijack # cmdline options from rootpy.interactive import wait pass except ImportError as e: print e sys.stderr.write("To run this script pyROOT and rootpy" " has to be properly installed.\n") exit(1) import rootpy.compiled as C pwd = os.path.dirname(__file__) C.register_file(pwd + "/mylangaus.cxx", ["langaufun"]) CHAN_COL = 1 DATA_COL = 2 COLORS = [2, 8, 4, 6, 7, 9] colors = cycle(COLORS) def parse_infile(infile, chans=None, chan_col=CHAN_COL, data_col=DATA_COL): """ Parses a file with data records. chans: a list of channel names; if specified, skip channels which are not in list. Returns a dict {channel_0: values_0, ... channel_N: values_N} """