Skip to content

Commit

Permalink
Remove _add_parameters and just insert the record names when they're …
Browse files Browse the repository at this point in the history
…constructed. (#69)
  • Loading branch information
jpivarski authored Sep 1, 2021
1 parent fd6a433 commit 920095a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 130 deletions.
41 changes: 11 additions & 30 deletions src/fastjet/_generalevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,23 +555,6 @@ def replace(self, layout, cluster, level):
else:
raise AssertionError(layout)

def _add_parameters(self, out_dat):
if self._check_record(ak.Array(out_dat.layout.content)):
temp_dict = out_dat.layout.content.parameters
temp_dict["__record__"] = "Momentum4D"
out_dat.layout.content.parameters = temp_dict
return out_dat
elif self._check_record(ak.Array(out_dat.layout.content.content)):
temp_dict = out_dat.layout.content.content.parameters
temp_dict["__record__"] = "Momentum4D"
out_dat.layout.content.content.parameters = temp_dict
return out_dat
elif self._check_record(ak.Array(out_dat.layout.content.content.content)):
temp_dict = out_dat.layout.content.content.content.parameters
temp_dict["__record__"] = "Momentum4D"
out_dat.layout.content.content.content.parameters = temp_dict
return out_dat

def inclusive_jets(self, min_pt):
self._out = []
self._input_flag = 0
Expand All @@ -590,12 +573,12 @@ def inclusive_jets(self, min_pt):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand All @@ -619,9 +602,7 @@ def constituents(self, min_pt):
total = np.sum(shape)
duplicate = ak.unflatten(np.zeros(total, np.int64), shape)
prepared = self._clusterable_level[i][:, np.newaxis][duplicate]
out = prepared[outputs_to_inputs]
out = self._add_parameters(out)
self._out.append(out)
self._out.append(prepared[outputs_to_inputs])
res = ak.Array(self._replace_multi())
return res

Expand Down Expand Up @@ -664,12 +645,12 @@ def unclustered_particles(self):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand Down Expand Up @@ -709,12 +690,12 @@ def childless_pseudojets(self):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand All @@ -736,12 +717,12 @@ def jets(self):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand Down Expand Up @@ -773,12 +754,12 @@ def exclusive_jets(self, n_jets, dcut):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand All @@ -800,12 +781,12 @@ def exclusive_jets_ycut(self, ycut):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand Down Expand Up @@ -915,12 +896,12 @@ def get_parents(self, data_inp):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])

res = ak.Array(self._replace_multi())
return res
Expand Down Expand Up @@ -1008,12 +989,12 @@ def exclusive_subjets(self, data_inp, dcut, nsub):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand Down Expand Up @@ -1055,12 +1036,12 @@ def exclusive_subjets_up_to(self, data_inp, nsub):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res

Expand Down Expand Up @@ -1240,11 +1221,11 @@ def get_child(self, data_inp):
ak.layout.NumpyArray(np_results[3]),
),
("px", "py", "pz", "E"),
parameters={"__record__": "Momentum4D"},
),
),
behavior=self.data.behavior,
)
)
self._out[-1] = self._add_parameters(self._out[-1])
res = ak.Array(self._replace_multi())
return res
Loading

0 comments on commit 920095a

Please sign in to comment.