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

Switch from deprecated scipy.misc.factorial #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
40 changes: 20 additions & 20 deletions wavelets_pytorch/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,29 +299,29 @@ def cwt(self, x):
self.signal_length = signal_length

# Move to GPU and perform CWT computation
x = torch.from_numpy(x).type(torch.FloatTensor)
x.requires_grad_(requires_grad=False)
#x = torch.from_numpy(x).type(torch.FloatTensor)
#x.requires_grad_(requires_grad=False)

if self._cuda: x = x.cuda()
cwt = self._extractor(x)

# Move back to CPU
cwt = cwt.detach()
if self._cuda: cwt = cwt.cpu()
cwt = cwt.numpy()

if self.complex_wavelet:
# Combine real and imag parts, returns object of shape
# [n_batch,n_scales,signal_length] of type np.complex128
cwt = (cwt[:,:,0,:] + cwt[:,:,1,:]*1j).astype(self.output_dtype)
else:
# Just squeeze the chn_out dimension (=1) to obtain an object of shape
# [n_batch,n_scales,signal_length] of type np.float64
cwt = np.squeeze(cwt, 2).astype(self.output_dtype)

# Squeeze batch dimension if single example
if num_examples == 1:
cwt = cwt.squeeze(0)
## Move back to CPU
#cwt = cwt.detach()
#if self._cuda: cwt = cwt.cpu()
#cwt = cwt.numpy()

#if self.complex_wavelet:
# # Combine real and imag parts, returns object of shape
# # [n_batch,n_scales,signal_length] of type np.complex128
# cwt = (cwt[:,:,0,:] + cwt[:,:,1,:]*1j).astype(self.output_dtype)
#else:
# # Just squeeze the chn_out dimension (=1) to obtain an object of shape
# # [n_batch,n_scales,signal_length] of type np.float64
# cwt = np.squeeze(cwt, 2).astype(self.output_dtype)

## Squeeze batch dimension if single example
#if num_examples == 1:
# cwt = cwt.squeeze(0)
return cwt

@property
Expand All @@ -340,4 +340,4 @@ def signal_length(self):
@signal_length.setter
def signal_length(self, value):
super(WaveletTransformTorch, self.__class__).signal_length.fset(self, value)
self._extractor.set_filters(self._filters)
self._extractor.set_filters(self._filters)
4 changes: 2 additions & 2 deletions wavelets_pytorch/wavelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import scipy.signal
import scipy.optimize
import scipy.special
from scipy.misc import factorial
from scipy.special import factorial

__all__ = ['Morlet', 'Paul', 'DOG', 'Ricker', 'Marr', 'Mexican_hat']

Expand Down Expand Up @@ -380,4 +380,4 @@ def __init__(self):

# aliases for DOG2
Marr = Ricker
Mexican_hat = Ricker
Mexican_hat = Ricker