nasa-fornax / fornax-demo-notebooks

Demo notebooks for the Fornax project
https://nasa-fornax.github.io/fornax-demo-notebooks/
BSD 3-Clause "New" or "Revised" License
8 stars 19 forks source link

forced photometry notebooks failing at np.savez #312

Closed zoghbi-a closed 2 months ago

zoghbi-a commented 2 months ago

I am finding this cell failing at the np.savez line in the photometry notebook.

    from  multiprocessing import Pool
    t0 = time.time()
    with open('output/output.log', 'w') as fp: fp.write('')
    with Pool() as pool:
        results = pool.map(calculate_flux, paramlist)
    dtime = time.time() - t0
    np.savez(fname, results=results)
    print(f'Parallel calculation took {dtime} seconds')

with the error:

--> 740     val = np.asanyarray(val)
    741     # always force zip64, gh-10776
    742     with zipf.open(fname, 'w', force_zip64=True) as fid:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (600, 2) + inhomogeneous part.

results is a list of tuples, and cannot be converted to a numpy array. A dtype may need to be passed explicitly, e.g.

np.savez(fname, results=np.array(results, dtype=object))

Is this related to some numpy update?

I am using numpy 1.26.4