POSYDON-code / POSYDON

POSYDON is a next-generation single and binary-star population synthesis code incorporating full stellar structure and evolution modeling with the use of MESA.
BSD 3-Clause "New" or "Revised" License
25 stars 19 forks source link

Broken from_hdf by casting lists as floats with np.float64 #321

Closed ka-rocha closed 4 weeks ago

ka-rocha commented 1 month ago

https://github.com/POSYDON-code/POSYDON/blob/1640a3eb977c97e1d646ac19c9e64bfbc7a83c68/posydon/utils/common_functions.py#L255-L258

The function separation_from_orbital_period as called in BinaryStar.from_oneline_df is now broken when loading systems from hdf. Somehow when numpy arrays are passed they are cast as floats which breaks when trying to set the history attributes for BinaryStar. (e.g. list(separation) is now being called on a float instead of a np.array)

np.float64( np.array([10]) ), np.float64([10])

produces the very unexpected behavior:

>>> 10.0, array([10.])
maxbriel commented 1 month ago

This is an interesting issue. Using a different casting method seems to work both ways.

I've implemented this in this commit: f92911f9d35e6f6c7716440a4178e32b89cb99db