Skip to content

Commit

Permalink
Merge pull request #18988 from rosswhitfield/IsoRotDiff_sph_jn_18
Browse files Browse the repository at this point in the history
Fix *IsoRotDiff doc-tests for scipy 1.18
  • Loading branch information
quantumsteve committed Feb 24, 2017
2 parents 852903b + e84d3ce commit e244280
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
8 changes: 2 additions & 6 deletions docs/source/fitfunctions/ElasticIsoRotDiff.rst
Expand Up @@ -56,11 +56,7 @@ following model:
.. testcode:: ExampleElasticIsoRotDiff

import numpy as np
import scipy
if int(scipy.__version__.split('.')[1]) < 18:
from scipy.special import sph_jn as jn
else:
from scipy.special import spherical_jn as jn
from scipy.special import sph_jn
"""Generate resolution function with the following properties:
1. Normal distribution along the energy axis, same for all Q-values
2. FWHM = 0.005 meV
Expand Down Expand Up @@ -94,7 +90,7 @@ following model:
noise = dataY*np.random.random(nE)*0.1 # noise is up to 10% of the elastic signal
background = np.random.random()+np.random.random()*dataX # linear background
background = (0.01*H*max(dataY)) * (background/max(np.abs(background))) # up to 1% of H
j0 = jn(0,Q*R)[0][0]
j0 = sph_jn(0,Q*R)[0][0]
qdataY=np.append(qdataY, H*j0**2*(dataY+noise) + background)
# Create data workspace
data=CreateWorkspace(np.tile(dataX,nQ), qdataY, NSpec=nQ, UnitX="deltaE",
Expand Down
8 changes: 2 additions & 6 deletions docs/source/fitfunctions/InelasticIsoRotDiff.rst
Expand Up @@ -60,11 +60,7 @@ and the overal intensity of the signal with a fit to the following model:
.. testcode:: ExampleInelasticIsoRotDiff

import numpy as np
import scipy
if int(scipy.__version__.split('.')[1]) < 18:
from scipy.special import sph_jn as jn
else:
from scipy.special import spherical_jn as jn
from scipy.special import sph_jn
"""Generate resolution function with the following properties:
1. Gaussian in Energy
2. Dynamic range = [-0.1, 0.1] meV with spacing 0.0004 meV
Expand All @@ -91,7 +87,7 @@ and the overal intensity of the signal with a fit to the following model:
for Q in Qs:
centre=dE*np.random.random() # some shift along the energy axis
dataY=np.zeros(nE) # holds the inelastic signal for this Q-value
js=jn(N,Q*R)[0] # spherical bessel functions from L=0 to L=N
js=sph_jn(N,Q*R)[0] # spherical bessel functions from L=0 to L=N
for L in range(1,N+1):
HWHM = L*(L+1)*hbar/tau; aL=(2*L+1)*js[L]**2
dataY += H*aL/np.pi * HWHM/(HWHM**2+(dataX-centre)**2) # add component
Expand Down
8 changes: 2 additions & 6 deletions docs/source/fitfunctions/IsoRotDiff.rst
Expand Up @@ -59,11 +59,7 @@ and the overal intensity of the signal with a fit to the following model:
.. testcode:: ExampleIsoRotDiff

import numpy as np
import scipy
if int(scipy.__version__.split('.')[1]) < 18:
from scipy.special import sph_jn as jn
else:
from scipy.special import spherical_jn as jn
from scipy.special import sph_jn
"""Generate resolution function with the following properties:
1. Gaussian in Energy
2. Dynamic range = [-0.1, 0.1] meV with spacing 0.0004 meV
Expand Down Expand Up @@ -94,7 +90,7 @@ and the overal intensity of the signal with a fit to the following model:
for Q in Qs:
centre=0 # some shift along the energy axis
dataY=np.zeros(nE)
js=jn(N,Q*R)[0] # spherical bessel functions from L=0 to L=N
js=sph_jn(N,Q*R)[0] # spherical bessel functions from L=0 to L=N
for L in range(1,N+1):
HWHM = L*(L+1)*hbar/tau
aL = (2*L+1)*js[L]**2
Expand Down

0 comments on commit e244280

Please sign in to comment.