Closed tkittel closed 5 years ago
So this only affects files with universal weights. Consider the two files, differing only in whether or not they use universal weights (uw):
import mcpl
for fn in ('mcplissue49_uw.mcpl.gz','mcplissue49_nouw.mcpl.gz'):
with mcpl.MCPLFile(fn) as f:
print('Opened %s with %i particles and blocklength %i'%(fn,f.nparticles,f.blocklength))
for i,p in enumerate(f.particle_blocks):
print(' block#%i: len(p.x)=%i, len(p.weight)=%i'%(i,len(p.x),len(p.weight)))
yields:
Opened mcplissue49_uw.mcpl.gz with 10900 particles and blocklength 10000
block#0: len(p.x)=10000, len(p.weight)=10000
block#1: len(p.x)=900, len(p.weight)=10000
Opened mcplissue49_nouw.mcpl.gz with 10900 particles and blocklength 10000
block#0: len(p.x)=10000, len(p.weight)=10000
block#1: len(p.x)=900, len(p.weight)=900
The bug is that len(p.weight) in block 1 of the _uw
file is 10000 instead of 900.
I figured out a fix, I guess we need a 1.3.1 release in the near future.
The issue actually concerns all variables not stored on-disk in a given file, but inferred from meta-data (universal pdgcode, polarisation, ...).
I am assuming this was not discovered before since my testing now used a newer Numpy version than previously. Probably Numpy was previously more tolerant of multiplying arrays of unequal length.
Fixed in MCPL 1.3.1.
I am not sure when this was introduced, but for instance the file at:
http://tkittel.web.cern.ch/tkittel/mcplissue49.mcpl.gz
Gives an error when combining the last block with the others:
(note: the default particle block size is 10000 and this file has 10017 particles)