Пример #1
0
def test_csv():
    f = testdata.get_file('test_csv.root')
    tree = f.ParTree_Postselect
    tree.create_buffer(ignore_unsupported=True)
    output = StringIO()
    tree.csv(stream=output)
    f.close()
    # compare with existing txt output
    if sys.version_info[0] < 3:
        true_output_filename = testdata.get_filepath('test_csv.txt')
    else:
        true_output_filename = testdata.get_filepath('test_csv_new.txt')
    with open(true_output_filename, 'r') as true_output_file:
        true_output = true_output_file.read()
        assert_equal(output.getvalue(), true_output)
Пример #2
0
def test_csv():
    f = testdata.get_file('test_csv.root')
    tree = f.ParTree_Postselect
    tree.create_buffer(ignore_unsupported=True)
    output = StringIO()
    tree.csv(stream=output)
    f.close()
    # compare with existing txt output
    if sys.version_info[0] < 3:
        true_output_filename = testdata.get_filepath('test_csv.txt')
    else:
        true_output_filename = testdata.get_filepath('test_csv_new.txt')
    with open(true_output_filename, 'r') as true_output_file:
        true_output = true_output_file.read()
        assert_equal(output.getvalue(), true_output)
Пример #3
0
def test_csv():

    from cStringIO import StringIO

    f = testdata.get_file("test_csv.root")
    tree = f.ParTree_Postselect
    tree.create_buffer(ignore_unsupported=True)
    output = StringIO()
    tree.csv(stream=output)
    f.close()
    # compare with existing txt output
    true_output_filename = testdata.get_filepath("test_csv.txt")
    with open(true_output_filename, "r") as true_output_file:
        true_output = true_output_file.read()
        assert_equal(output.getvalue(), true_output)
Пример #4
0
ROOT.TFile made easy by rootpy
==============================

This example demonstrates how basic file operations are made easier in rootpy.
"""
print __doc__
import os
import shutil
import rootpy
rootpy.log.basic_config_colorized()
from rootpy.io import root_open, DoesNotExist
from rootpy.plotting import Hist, Hist2D
from rootpy import testdata
from rootpy import asrootpy

shutil.copyfile(testdata.get_filepath('test_file_2.root'), 'data.root')
f = root_open('data.root')

print f.a
print f.a.b

try:
    print f.a.b.c.d.e.f
except AttributeError, e:
    print e

for thing in f.walk():
    print thing

f.close()
Пример #5
0
"""
==============================
ROOT.TFile made easy by rootpy
==============================

This example demonstrates how basic file operations are made easier in rootpy.
"""
print(__doc__)
import os
import shutil
from rootpy.io import root_open, DoesNotExist
from rootpy.plotting import Hist, Hist2D
from rootpy import testdata
from rootpy import asrootpy

shutil.copyfile(testdata.get_filepath('test_file_2.root'), 'data.root')
f = root_open('data.root')

print(f.a)
print(f.a.b)

try:
    print(f.a.b.c.d.e.f)
except AttributeError as e:
    print(e)

for thing in f.walk():
    print(thing)

f.close()