Search code examples
pythonscipynumerical-integration

Why scipy.integrate shows has no "simpson" attribute?


I have some python code which uses function scipy.integrate.simpson So for example I import scipy using import scipy.integrate as scp_int and then use it in following way:

vol_r = scp_int.simpson(f_integrand_r,dx=_dx1,axis=0)

I get this error

    vol_r = scp_int.simpson(f_integrand_r,dx=_dx1,axis=0)
AttributeError: module 'scipy.integrate' has no attribute 'simpson'`

I have made sure that I have scipy package installed, using pip install scipy, and I have restarted computer. I don't know why is this happening? Can someone give the reason or help me solve this issue?


Solution

  • I suspect you are using version 1.5 (or an older version) of SciPy. If you don't know which version you have installed, you can check with

    import scipy
    print(scipy.__version__)
    

    simpson was added in 1.6.0; it is the new name for the old function called simps. If you can't upgrade, you should be able to use simps instead of simpson.