An ugly hack to convince newer version of numpy to save list of arrays

This commit is contained in:
Marek Nečada 2022-06-24 08:14:05 +03:00
parent e5270b54fb
commit 3a2fc6685c
1 changed files with 6 additions and 1 deletions

View File

@ -260,10 +260,15 @@ if not math.isnan(a.ccd_distance):
logging.info("Far fields done") logging.info("Far fields done")
outfile = defaultprefix + ".npz" if a.output is None else a.output outfile = defaultprefix + ".npz" if a.output is None else a.output
for sir in scattered_ir:# An ugly hack to convince newer versions of numpy that we indeed want to save a list of arrays
if sir is None:
break
else:
scattered_ir.append(None)
np.savez(outfile, meta={**vars(a), 'qpms_version' : qpms.__version__()}, np.savez(outfile, meta={**vars(a), 'qpms_version' : qpms.__version__()},
omega=omega, wavenumber=wavenumber, nelem=nelem, wavevector=np.array(a.wavevector), phases=phases, omega=omega, wavenumber=wavenumber, nelem=nelem, wavevector=np.array(a.wavevector), phases=phases,
positions = ss.positions[:,:2], positions = ss.positions[:,:2],
scattered_ir_packed = np.array(scattered_ir, dtype=np.object), scattered_ir_packed = np.array(scattered_ir, dtype=object),
scattered_full = scattered_full, scattered_full = scattered_full,
ir_contained = ir_contained, ir_contained = ir_contained,
t=t, l=l, m=m, t=t, l=l, m=m,