jgagneastro / banyan_sigma

A Bayesian classifier to identify members of the 27 nearest young associations within 150 pc of the Sun
MIT License
17 stars 8 forks source link

logsumexp has moved #2

Open astromark opened 4 years ago

astromark commented 4 years ago

In the latest version of scipy, logsumexp has been moved scipy.misc to scipy.special.

There also seems to be some change in functionality as this line in bayan_sigma caused a ValueError: 'object arrays are not supported' for coli in output_str_multimodel.columns.get_level_values(0): output_str[coli] = logsumexp(logweights_2d+output_str_multimodel[coli],axis=1) I found that this could be prevented by adding [0] after logweights_2d, although I'm not sure if similar changes need to be made for other calls to logsumexp.

Will-Cooper commented 3 years ago

I also made the same change, additionally I found I had to ensure the arguments were a non-masked array as for some reason the code thought the data was masked (it had no reason to be though! and none of my input data was masked):

output_str[coli] = logsumexp((logweights_2d[0] + output_str_multimodel[coli]).filled(), axis=1)
sylacour commented 2 years ago

+1, I got the masked error:

site-packages/scipy/_lib/_util.py in _asarray_validated(a, check_finite, sparse_ok, objects_ok, mask_ok, as_inexact) 283 if not mask_ok: 284 if np.ma.isMaskedArray(a): --> 285 raise ValueError('masked arrays are not supported') 286 toarray = np.asarray_chkfinite if check_finite else np.asarray 287 a = toarray(a)

ValueError: masked arrays are not supported

To make it work, I had to change the line 420 to (with the .data): output_str[coli] = logsumexp(logweights_2d[0].data+output_str_multimodel[coli].values,axis=1)