Closed jncots closed 1 year ago
I changed parents
-> mothers
and children
->daughters
.
-1
, therefore I restore -2
which will appear after subtraction by:# Fix special cases
if mothers is not None:
mothers[mothers == -2] = -1
if daughters is not None:
daughters[daughters == -2] = -1
I am not sure about this snippet.
pyhepmc
seems start indexing from 1, so 1 is added for genevent.from_hepevtparents=ev.mothers + 1 if ev.mothers is not None else None,
children=ev.daughters + 1 if ev.daughters is not None else None,
The failing tests may come from the rather complex rules how ranges of particle indices can be defined. There are probably some special cases that you need to handle.
I agree that we don't want -2. One option is
parent = np.maximum(-1, parent - 1)
Likewise for children. This is fairly elegant, but I am not sure wether this is faster than your option with the mask. If the speed difference does not matter, I would prefer this compact code over masking.
pyhepmc expecting indices starting with 1, that's a workaround for chromo's behavior. which I can remove then. I will adapt the pyhepmc interface in a separate PR.
I tested 2 variants and parent = np.maximum(-1, parent - 1)
is faster (~3 times) than 2 separate numpy operations. It is, probably, because numpy should not return to python level. So I changed the code to parent = np.maximum(-1, parent - 1)
.
It seems that tests are fixed. Most of the problems were because of _select_mothers
function. The tests passes, but the function should be checked on whether the initial logic is preserved.
Ok, I will have a look.
It seems that tests are fixed. Most of the problems were because of _select_mothers function. The tests passes, but the function should be checked on whether the initial logic is preserved.
It looks ok, but rather than checking the implementation manually, we should have tests that cover all the common and special cases.
It looks ok, but rather than checking the implementation manually, we should have tests that cover all the common and special cases.
_select_mothers
function seems to be used in many tests. I don't know whether we need additional one.
Sometime in the far future we can deprecate mothers and daughters and move back to the PC versions parents and children
Sure, parents
and children
are better.
This is PR to resolve issue #100