module 'scipy.special' has no attribute 'sph_jnyn'

早过忘川 提交于 2019-12-11 15:53:55

问题


I have these lines of codes in python 3.7 ,But when I want to compile them, I got some errors means new version of python libraries do not recognize previous version libraries. I searched but at all python said special.sph_jnyn deprecated and removed as:

https://docs.scipy.org/doc/scipy/reference/release.0.18.0.html#deprecated-features

https://docs.scipy.org/doc/scipy/reference/release.1.0.0.html#backwards-incompatible-changes

EDITED #2

here is the code:

...
    Rad = [0, {}, {}]
    Radd = [0, {}, {}]
    kis = [0, bnd.k1, bnd.k2]
for i in [1, 2]:
                krs = kis[i] * r
                JY = array([special.sph_jnyn(self.n, kr) for kr in krs])[:, :, :]
                Rad[i] = {'j': JY[:, 0, :], 'h': JY[:, 0, :] + 1j * JY[:, 2, :]}
                Radd[i] = {'j': JY[:, 1, :], 'h': JY[:, 1, :] + 1j * JY[:, 3, :]}
…

def Rad(self, m, ij, i):
    return self.data_layers[self._lay]['Rad'][i][ij][:, m:]

def Radd(self, m, ij, i):
    return self.data_layers[self._lay]['Radd'][i][ij][:, m:]  

…
def get_Jn(n, x):
    return array([special.sph_jn(n, xl) for xl in x])


def get_JnHn(n, x):
    JnYn = array([special.sph_jnyn(n, xl) for xl in x])
    return JnYn[:, :2, :], JnYn[:, :2, :] + 1j * JnYn[:, 2:, :]
...

and the error is

module 'scipy.special' has no attribute 'sph_jnyn'

So , any help would be appreciated.

EDITED #3:

I am not sure it could solve the problem but something like this is the answer:

Some codes like below:

for i in [1, 2]:
                krs = kis[i] * r
                JY = array([[((special.spherical_jn(self.n, kr)),(special.spherical_jn(self.n, kr,1) ),(special.spherical_yn(self.n, kr) ),(special.spherical_yn(self.n, kr,1)) ) for kr in krs],])[:,:,:]

                print("+++++++++++++++++++++++")
                print (JY.shape)
                print (JY)
                print (self.n)
                print("+++++++++++++++++++++++")

                Rad[i] = {'j': JY[:, :, 0], 'h': JY[:, :, 0] + 1j * JY[:, :,2]}
                Radd[i] = {'j': JY[:, :, 1], 'h': JY[:, :, 1] + 1j * JY[:, :, 3]}

                print (Rad[i])
                print (Radd[i])

so the output is:

+++++++++++++++++++++++
(1, 1, 4)
[[[ 0.04816103  0.10417659 -5.16810074 16.02904971]]]
2
+++++++++++++++++++++++
{'j': array([[0.04816103]]), 'h': array([[0.04816103-5.16810074j]])}
{'j': array([[0.10417659]]), 'h': array([[0.10417659+16.02904971j]])}
+++++++++++++++++++++++
(1, 1, 4)
[[[ 0.08151801+0.00775045j  0.12687981+0.00386415j
   -2.42490018+0.31887469j  5.12230738-1.05692606j]]]
2
+++++++++++++++++++++++
{'j': array([[0.08151801+0.00775045j]]), 'h': array([[-0.23735668-2.41714974j]])}
{'j': array([[0.12687981+0.00386415j]]), 'h': array([[1.18380587+5.12617153j]])}

来源:https://stackoverflow.com/questions/57451631/module-scipy-special-has-no-attribute-sph-jnyn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!