Exemple #1
0
def test_no_reported_statistics():
    'Look at the log file and report if it contains a statistics line'

    with LogCapture() as l_cap:
        as_pandas(f_single \
            .Select('lambda e: e.Jets("AntiKt4EMTopoJets").First().pt()/1000.0'))
        assert str(l_cap).find('TFileAccessTracer   INFO    Sending') == -1
Exemple #2
0
def test_First_two_outer_loops():
    # THis is a little tricky because the First there is actually running over one jet in the event. Further, the Where
    # on the number of tracks puts us another level down. So it is easy to produce code that compiles, but the First's if statement
    # is very much in the wrong place.
    training_df = as_pandas(f_single \
            .Select('lambda e: e.Jets("AntiKt4EMTopoJets").Select(lambda j: e.Tracks("InDetTrackParticles").Where(lambda t: t.pt() > 1000.0)).First().Count()'))
    assert training_df.iloc[0]['col1'] == 693
Exemple #3
0
def test_flatten_array():
    # A very simple flattening of arrays
    training_df = as_pandas(f_single \
        .SelectMany('lambda e: e.Jets("AntiKt4EMTopoJets")') \
        .Select('lambda j: j.pt()/1000.0'))
    assert int(training_df.iloc[0]['col1']) == 257
    assert int(training_df.iloc[0]['col1']) != int(training_df.iloc[1]['col1'])
Exemple #4
0
def test_single_column_output():
    # A very simple flattening of arrays
    training_df = as_pandas(f_single \
        .SelectMany(lambda e: e.Jets("AntiKt4EMTopoJets")) \
        .Select(lambda j: j.pt()/1000.0))
    print(training_df)
    assert int(training_df.iloc[0]['col1']) == 257
    assert int(training_df.iloc[0]['col1']) != int(training_df.iloc[1]['col1'])
Exemple #5
0
def test_select_first_of_array():
    # The hard part is that First() here does not return a single item, but, rather, an array that
    # has to be aggregated over.
    training_df = as_pandas(f_single \
            .Select('lambda e: e.Jets("AntiKt4EMTopoJets").Select(lambda j: e.Tracks("InDetTrackParticles")).First().Count()'))
    assert training_df.iloc[0]['col1'] == 1897
    assert training_df.iloc[1]['col1'] == 605
    assert training_df.iloc[-1]['col1'] == 336
Exemple #6
0
def test_truth_particles():
    training_df = as_pandas(f_single \
        .Select("lambda e: e.TruthParticles('TruthParticles').Count()"))
    assert training_df.iloc[0]['col1'] == 1557
Exemple #7
0
def test_first_object_in_event_with_where():
    # Make sure First puts it's if statement in the right place.
    training_df = as_pandas(f_single \
        .Select('lambda e: e.Jets("AntiKt4EMTopoJets").Select(lambda j: j.pt()/1000.0).Where(lambda jpt: jpt > 10.0).First()'))
    assert int(training_df.iloc[0]['col1']) == 257
    assert len(training_df) == 10
Exemple #8
0
def test_first_object_in_event():
    # Make sure First puts it if statement in the right place.
    training_df = as_pandas(f_single \
        .Select('lambda e: e.Jets("AntiKt4EMTopoJets").First().pt()/1000.0'))
    assert int(training_df.iloc[0]['col1']) == 257