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

fix: Revert "fix: updates from review" #1133

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
39 changes: 16 additions & 23 deletions src/coffea/nanoevents/methods/candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy

from coffea.nanoevents.methods import vector
from coffea.util import register_projection_classes

behavior = dict(vector.behavior)

Expand Down Expand Up @@ -71,29 +70,23 @@ class PtEtaPhiECandidate(Candidate, vector.PtEtaPhiELorentzVector):
pass


behavior.update(awkward._util.copy_behaviors(vector.LorentzVector, Candidate, behavior))

register_projection_classes(
CandidateArray, # noqa: F821
vector.PolarTwoVectorArray,
vector.SphericalThreeVectorArray,
vector.LorentzVectorArray,
CandidateArray, # noqa: F821
)
register_projection_classes(
PtEtaPhiMCandidateArray, # noqa: F821
vector.PolarTwoVectorArray,
vector.SphericalThreeVectorArray,
vector.LorentzVectorArray,
PtEtaPhiMCandidateArray, # noqa: F821
)
register_projection_classes(
PtEtaPhiECandidateArray, # noqa: F821
vector.PolarTwoVectorArray,
vector.SphericalThreeVectorArray,
vector.LorentzVectorArray,
PtEtaPhiECandidateArray, # noqa: F821
awkward.behavior.update(
awkward._util.copy_behaviors(vector.LorentzVector, Candidate, behavior)
)
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved

CandidateArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
CandidateArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
CandidateArray.ProjectionClass4D = vector.LorentzVectorArray # noqa: F821
CandidateArray.MomentumClass = CandidateArray # noqa: F821

PtEtaPhiMCandidateArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
PtEtaPhiMCandidateArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
PtEtaPhiMCandidateArray.ProjectionClass4D = vector.LorentzVectorArray # noqa: F821
PtEtaPhiMCandidateArray.MomentumClass = PtEtaPhiMCandidateArray # noqa: F821

PtEtaPhiECandidateArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
PtEtaPhiECandidateArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
PtEtaPhiECandidateArray.ProjectionClass4D = vector.LorentzVectorArray # noqa: F821
PtEtaPhiECandidateArray.MomentumClass = PtEtaPhiECandidateArray # noqa: F821

__all__ = ["Candidate", "PtEtaPhiMCandidate", "PtEtaPhiECandidate"]
134 changes: 57 additions & 77 deletions src/coffea/nanoevents/methods/delphes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy

from coffea.nanoevents.methods import base, candidate, vector
from coffea.util import register_projection_classes

behavior = {}
behavior.update(base.behavior)
Expand Down Expand Up @@ -131,16 +130,15 @@ def z(self):


_set_repr_name("Vertex")
behavior.update(awkward._util.copy_behaviors(vector.LorentzVector, Vertex, behavior))

register_projection_classes(
VertexArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
VertexArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
awkward.behavior.update(
awkward._util.copy_behaviors(vector.LorentzVector, Vertex, behavior)
)
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved

VertexArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
VertexArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
VertexArray.ProjectionClass4D = VertexArray # noqa: F821
VertexArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
class Particle(vector.PtEtaPhiMLorentzVector):
Expand Down Expand Up @@ -180,17 +178,14 @@ def mass(self):


_set_repr_name("Particle")
behavior.update(
awkward.behavior.update(
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved
awkward._util.copy_behaviors(vector.PtEtaPhiMLorentzVector, Particle, behavior)
)

register_projection_classes(
ParticleArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
ParticleArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
)
ParticleArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
ParticleArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
ParticleArray.ProjectionClass4D = ParticleArray # noqa: F821
ParticleArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
Expand All @@ -201,95 +196,83 @@ def mass(self):


_set_repr_name("MasslessParticle")
behavior.update(awkward._util.copy_behaviors(Particle, MasslessParticle, behavior))

register_projection_classes(
MasslessParticleArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
MasslessParticleArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
awkward.behavior.update(
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved
awkward._util.copy_behaviors(Particle, MasslessParticle, behavior)
)

MasslessParticleArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
MasslessParticleArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
MasslessParticleArray.ProjectionClass4D = MasslessParticleArray # noqa: F821
MasslessParticleArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
class Photon(MasslessParticle, base.NanoCollection): ...


_set_repr_name("Photon")
behavior.update(awkward._util.copy_behaviors(MasslessParticle, Photon, behavior))

register_projection_classes(
PhotonArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
PhotonArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
awkward.behavior.update(
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved
awkward._util.copy_behaviors(MasslessParticle, Photon, behavior)
)

PhotonArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
PhotonArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
PhotonArray.ProjectionClass4D = PhotonArray # noqa: F821
PhotonArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
class Electron(MasslessParticle, base.NanoCollection): ...


_set_repr_name("Electron")
behavior.update(awkward._util.copy_behaviors(MasslessParticle, Electron, behavior))

register_projection_classes(
ElectronArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
ElectronArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
awkward.behavior.update(
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved
awkward._util.copy_behaviors(MasslessParticle, Electron, behavior)
)

ElectronArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
ElectronArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
ElectronArray.ProjectionClass4D = ElectronArray # noqa: F821
ElectronArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
class Muon(MasslessParticle, base.NanoCollection): ...


_set_repr_name("Muon")
behavior.update(awkward._util.copy_behaviors(MasslessParticle, Muon, behavior))

register_projection_classes(
MuonArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
MuonArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
)
awkward.behavior.update(awkward._util.copy_behaviors(MasslessParticle, Muon, behavior))
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved

MuonArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
MuonArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
MuonArray.ProjectionClass4D = MuonArray # noqa: F821
MuonArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
class Jet(Particle, base.NanoCollection): ...


_set_repr_name("Jet")
behavior.update(awkward._util.copy_behaviors(Particle, Jet, behavior))

register_projection_classes(
JetArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
JetArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
)
awkward.behavior.update(awkward._util.copy_behaviors(Particle, Jet, behavior))
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved

JetArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
JetArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
JetArray.ProjectionClass4D = JetArray # noqa: F821
JetArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
class Track(Particle, base.NanoCollection): ...


_set_repr_name("Track")
behavior.update(awkward._util.copy_behaviors(Particle, Track, behavior))

register_projection_classes(
TrackArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
TrackArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
)
awkward.behavior.update(awkward._util.copy_behaviors(Particle, Track, behavior))
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved

TrackArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
TrackArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
TrackArray.ProjectionClass4D = TrackArray # noqa: F821
TrackArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


@awkward.mixin_class(behavior)
Expand All @@ -300,15 +283,12 @@ def pt(self):


_set_repr_name("Tower")
behavior.update(awkward._util.copy_behaviors(MasslessParticle, Tower, behavior))

register_projection_classes(
TowerArray, # noqa: F821
vector.TwoVectorArray, # noqa: F821
vector.ThreeVectorArray, # noqa: F821
TowerArray, # noqa: F821
vector.LorentzVectorArray, # noqa: F821
)
awkward.behavior.update(awkward._util.copy_behaviors(MasslessParticle, Tower, behavior))
Saransh-cpp marked this conversation as resolved.
Show resolved Hide resolved

TowerArray.ProjectionClass2D = vector.TwoVectorArray # noqa: F821
TowerArray.ProjectionClass3D = vector.ThreeVectorArray # noqa: F821
TowerArray.ProjectionClass4D = TowerArray # noqa: F821
TowerArray.MomentumClass = vector.LorentzVectorArray # noqa: F821


__all__ = [
Expand Down
Loading
Loading