radiasoft/rswarp

ConductorTemplates _norm_factor field no longer available in scipy

Opened this issue · 1 comments

A recent change to scipy.stats.gaussian_kde is the removal of the _norm_factor field which rswarp is depending on here:

s = kernel(mesh).T * kernel._norm_factor

This is causing sirepo/warpvnd simulations to fail on the Visualization page with the error 'gaussian_kde' object has no attribute '_norm_factor'.

@moellep It looks like the commit scipy/scipy@e04c172 to scipy.stats removed the _norm_factor as an attribute for the kde, and replaced it with some slightly different intermediary calculations. The previous calculation relied on computing the determinant of the covariance matrix for the kernel to compute a normalization factor. Unfortunately, for singular matrices, some decomposition methods will fail and throw an error.

I've added a fix eadb1be which recreates the previous calculation of the _norm_factor, and excepts LinAlgErrors when the matrix is singular or the determinant cannot be computed.

This fix should allow you to use the most recent version of SciPy.