Skip to content

Commit

Permalink
Merge pull request mantidproject#37137 from mantidproject/scipy_signa…
Browse files Browse the repository at this point in the history
…l_imports_update

Update scipy gaussian an tukey import locations
  • Loading branch information
SilkeSchomann authored Apr 8, 2024
2 parents bbd1b8c + eb5d41b commit 26d09ef
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
10 changes: 2 additions & 8 deletions Framework/PythonInterface/plugins/algorithms/DeltaPDF3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ def validateInputs(self):
if len(sphereMax) != 1 and len(sphereMax) != 3:
issues["SphereMax"] = "Must provide 1 or 3 diameters"

if self.getProperty("WindowFunction").value == "Tukey":
import scipy.signal

if not hasattr(scipy.signal, "tukey"):
issues["WindowFunction"] = "Tukey window requires scipy >= 0.16.0"

return issues

def PyExec(self):
Expand Down Expand Up @@ -383,7 +377,7 @@ def _gaussian_window(self, width, sigma):
sigma is based on the dat being in a range 0 to 1
"""
from scipy.signal import gaussian
from scipy.signal.windows import gaussian

return (
gaussian(width[0], sigma * width[0]).reshape((-1, 1, 1))
Expand All @@ -406,7 +400,7 @@ def _tukey_window(self, width, alpha):
alpha = 0 becomes rectangular
alpha = 1 becomes a Hann window
"""
from scipy.signal import tukey
from scipy.signal.windows import tukey

return tukey(width[0], alpha).reshape((-1, 1, 1)) * tukey(width[1], alpha).reshape((-1, 1)) * tukey(width[2], alpha)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def PyExec(self):
def fit_cubic_spline_with_gauss_conv(self, x_fit, y_fit, x, n_gouss=39, sigma=3.0):
# Fit with Cubic Spline using a Gaussian Convolution to get weights
def moving_average(y, n=n_gouss, sig=sigma):
from scipy.signal import gaussian
from scipy.signal.windows import gaussian

b = gaussian(n, sig)
average = ndimage.filters.convolve1d(y, b / b.sum())
Expand Down
3 changes: 1 addition & 2 deletions conda/recipes/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ pycifrw:
sphinx_bootstrap_theme:
- 0.8.1

#Some unit tests failures present in 1.13.0 from gaussian not being found
scipy:
- '>=1.10.0, !=1.13.0'
- '>=1.10.0'

pyqt:
- 5.15
Expand Down
2 changes: 1 addition & 1 deletion mantid-developer-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
- qtpy>=1.9.0
- qt-gtk-platformtheme # Use native theme on GTK-based systems, which provides a significantly better performing file browser.
- requests>=2.25.1
- scipy>=1.10.0,!=1.13.0 # 1.13.0 causing unit test failures due to gaussian not being found.
- scipy>=1.10.0
- setuptools
- sphinx>=4.5.*
- sphinx_bootstrap_theme>=0.8.1
Expand Down
2 changes: 1 addition & 1 deletion mantid-developer-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies:
- qtconsole>5.4.2,!=5.5.0 # 5.4.2 crashes the jupyter console. 5.5.0 raises a TypeError when using tab completion.
- qtpy>=1.9.0
- requests>=2.25.1
- scipy>=1.10.0,!=1.13.0 # 1.13.0 causing unit test failures due to gaussian not being found.
- scipy>=1.10.0
- setuptools
- sphinx>=4.5.*
- sphinx_bootstrap_theme=>0.8.1
Expand Down
2 changes: 1 addition & 1 deletion mantid-developer-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies:
- qtconsole>5.4.2,!=5.5.0 # 5.4.2 crashes the jupyter console. 5.5.0 raises a TypeError when using tab completion.
- qtpy>=1.9.0
- requests>=2.25.1
- scipy>=1.10.0,!=1.13.0 # 1.13.0 causing unit test failures due to gaussian not being found.
- scipy>=1.10.0
- setuptools
- sphinx>=4.5.*
- sphinx_bootstrap_theme=>0.8.1
Expand Down

0 comments on commit 26d09ef

Please sign in to comment.