Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/Tests failing #215

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions func_adl_xAOD/common/ast_to_cpp_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ def visit_Call(self, call_node: ast.Call):
crep.set_rep(call_node, r)

def visit_Attribute(self, node: ast.Attribute) -> Any:

obj = self.get_rep(node.value)
variable = node.attr
if not isinstance(obj, crep.cpp_value):
Expand Down Expand Up @@ -790,7 +789,7 @@ def visit_special_BinOp(self, node: ast.BinOp):
node (ast.BinOp): The binary node to process

"""
if type(node.op) == ast.Pow:
if type(node.op) is ast.Pow:
left = cast(crep.cpp_value, self.get_rep(node.left))
right = cast(crep.cpp_value, self.get_rep(node.right))
best_type = ctyp.terminal("double", False)
Expand Down Expand Up @@ -888,7 +887,7 @@ def visit_Compare(self, node):
right = cast(crep.cpp_value, self.get_rep(node.comparators[0]))

r = crep.cpp_value(
f"({left.as_cpp()}{compare_operations[type(node.ops[0])]}{right.as_cpp()})",
f"({left.as_cpp()}{compare_operations[type(node.ops[0])]}{right.as_cpp()})", # type: ignore
self._gc.current_scope(),
ctyp.terminal("bool"),
)
Expand All @@ -910,7 +909,7 @@ def visit_BoolOp(self, node):

# How we check and short-circuit depends on if we are doing and or or.
check_expr = (
result.as_cpp() if type(node.op) == ast.And else f"!{result.as_cpp()}"
result.as_cpp() if type(node.op) is ast.And else f"!{result.as_cpp()}"
)
check = crep.cpp_value(
check_expr, self._gc.current_scope(), cpp_type=ctyp.terminal("bool")
Expand Down
10 changes: 6 additions & 4 deletions tests/atlas/xaod/test_integrated_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
from func_adl_xAOD.common.math_utils import DeltaR # NOQA
from testfixtures import LogCapture
from testfixtures import LogCapture # type: ignore
from tests.atlas.xaod.config import f_single, run_long_running_tests
from tests.atlas.xaod.utils import as_awkward, as_pandas, as_pandas_async

Expand Down Expand Up @@ -169,9 +169,11 @@ def test_md_job_options():
def test_event_info_includes():
"Make sure event info is pulling in the correct includes"
training_df = as_pandas(
f_single.Select(lambda e: e.EventInfo("EventInfo")).Select(
lambda e: e.runNumber()
)
# fmt: off
f_single
.Select(lambda e: e.EventInfo("EventInfo"))
.Select(lambda e: e.runNumber())
# fmt: on
)
print(training_df)
assert len(training_df) == 10
Expand Down
51 changes: 34 additions & 17 deletions tests/cms/miniaod/test_integrated_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def turn_on_logging():

def test_select_pt_of_muons():
training_df = as_pandas(
f_single.SelectMany(lambda e: e.Muons("slimmedMuons")).Select(lambda m: m.pt())
# fmt: off
f_single
.SelectMany(lambda e: e.Muons("slimmedMuons"))
.Select(lambda m: m.pt())
# fmt: on
)

assert training_df.iloc[0]["col1"] == 12.901309967041016
Expand All @@ -34,9 +38,11 @@ def test_select_pt_of_muons():

def test_select_pt_of_electrons():
training_df = as_pandas(
f_single.SelectMany(lambda e: e.Electrons("slimmedElectrons")).Select(
lambda m: m.pt()
)
# fmt: off
f_single
.SelectMany(lambda e: e.Electrons("slimmedElectrons"))
.Select(lambda m: m.pt())
# fmt: on
)

assert training_df.iloc[0]["col1"] == 4.862127780914307
Expand All @@ -46,9 +52,11 @@ def test_select_pt_of_electrons():

def test_select_twice_pt_of_global_muons():
training_df = as_pandas(
f_single.SelectMany(lambda e: e.Muons("slimmedMuons")).Select(
lambda m: m.pt() * 2
)
# fmt: off
f_single
.SelectMany(lambda e: e.Muons("slimmedMuons"))
.Select(lambda m: m.pt() * 2)
# fmt: on
)

assert training_df.iloc[0]["col1"] == 25.80261993408203
Expand All @@ -58,7 +66,11 @@ def test_select_twice_pt_of_global_muons():

def test_select_eta_of_global_muons():
training_df = as_pandas(
f_single.SelectMany(lambda e: e.Muons("slimmedMuons")).Select(lambda m: m.eta())
# fmt: off
f_single
.SelectMany(lambda e: e.Muons("slimmedMuons"))
.Select(lambda m: m.eta())
# fmt: on
)

assert training_df.iloc[0]["col1"] == -1.2982407808303833
Expand All @@ -68,9 +80,11 @@ def test_select_eta_of_global_muons():

def test_select_pt_eta_of_global_muons():
training_df = as_pandas(
f_single.SelectMany(lambda e: e.Muons("slimmedMuons")).Select(
lambda m: m.pt() + m.eta()
)
# fmt: off
f_single
.SelectMany(lambda e: e.Muons("slimmedMuons"))
.Select(lambda m: m.pt() + m.eta())
# fmt: on
)

assert training_df.iloc[0]["col1"] == 11.603069186210632
Expand All @@ -87,9 +101,10 @@ def test_select_hitpattern_of_global_muons():
.Select(lambda m: m.globalTrack())
.Select(lambda m: m.hitPattern())
.Select(
lambda hp: Range(0, hp.numberOfHits(hp.TRACK_HITS)).Select(
lambda i: hp.getHitPattern(hp.TRACK_HITS, i)
)
# fmt: off
lambda hp: Range(0, hp.numberOfHits(hp.TRACK_HITS))
.Select(lambda i: hp.getHitPattern(hp.TRACK_HITS, i))
# fmt: on
)
)
)
Expand All @@ -113,9 +128,11 @@ def test_isnonull_call():

def test_sumChargedHadronPt():
training_df = as_pandas(
f_single.SelectMany(lambda e: e.Muons("slimmedMuons")).Select(
lambda m: (m.pfIsolationR04()).sumChargedHadronPt
)
# fmt: off
f_single
.SelectMany(lambda e: e.Muons("slimmedMuons"))
.Select(lambda m: (m.pfIsolationR04()).sumChargedHadronPt)
# fmt: on
)
assert training_df.iloc[0]["col1"] == 0.0
assert training_df.iloc[2]["col1"] == 26.135541915893555
Expand Down