Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace deprecated scipy.integrate.cumtrapz with cumulative_trapezoid #2545

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gpytorch/kernels/spectral_delta_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def initialize_from_data(self, train_x, train_y):
"""
import numpy as np
from scipy.fftpack import fft
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid

N = train_x.size(-2)
emp_spect = np.abs(fft(train_y.cpu().detach().numpy())) ** 2 / N
Expand All @@ -65,7 +65,7 @@ def initialize_from_data(self, train_x, train_y):
emp_spect = emp_spect[: M + 1]

total_area = np.trapz(emp_spect, freq)
spec_cdf = np.hstack((np.zeros(1), cumtrapz(emp_spect, freq)))
spec_cdf = np.hstack((np.zeros(1), cumulative_trapezoid(emp_spect, freq)))
spec_cdf = spec_cdf / total_area

a = np.random.rand(self.raw_Z.size(-2), 1)
Expand Down
4 changes: 2 additions & 2 deletions gpytorch/kernels/spectral_mixture_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def initialize_from_data_empspect(self, train_x: torch.Tensor, train_y: torch.Te

import numpy as np
from scipy.fftpack import fft
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid

with torch.no_grad():
if not torch.is_tensor(train_x) or not torch.is_tensor(train_y):
Expand All @@ -192,7 +192,7 @@ def initialize_from_data_empspect(self, train_x: torch.Tensor, train_y: torch.Te
emp_spect = emp_spect[: M + 1]

total_area = np.trapz(emp_spect, freq)
spec_cdf = np.hstack((np.zeros(1), cumtrapz(emp_spect, freq)))
spec_cdf = np.hstack((np.zeros(1), cumulative_trapezoid(emp_spect, freq)))
spec_cdf = spec_cdf / total_area

a = np.random.rand(1000, self.ard_num_dims)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def find_version(*file_paths):
"jaxtyping>=0.2.9",
"mpmath>=0.19,<=1.3", # avoid incompatibiltiy with torch+sympy with mpmath 1.4
"scikit-learn",
"scipy",
"scipy>=1.6.0",
"linear_operator>=0.5.2",
]
# if recent dev version of PyTorch is installed, no need to install stable
Expand Down
Loading