banyan_sigma icon indicating copy to clipboard operation
banyan_sigma copied to clipboard

logsumexp has moved

Open astromark opened this issue 4 years ago • 2 comments

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.

astromark avatar Mar 09 '20 16:03 astromark

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)

Will-Cooper avatar Oct 18 '21 16:10 Will-Cooper

+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)

sylacour avatar Jul 08 '22 19:07 sylacour