-
-
Notifications
You must be signed in to change notification settings - Fork 517
Enhance _cwt.py by introducing a configurable hop size parameter #804
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
base: main
Are you sure you want to change the base?
Changes from all commits
4edcc2c
9a8bf1a
ad41521
6b7d7f1
3c9289b
0a53e69
6776f98
82a4ef0
81cd1bb
dc93c83
a8a9aee
f607aa0
5cda18e
6f4e57a
099f895
7282d9f
20838a7
d986733
5eed6aa
8189d35
85482d4
bd5134b
ce87862
fc90fec
20d2af4
f6fa074
84c3fcb
f4231a1
fe2a9f3
fef6593
f5640ae
368f272
9c2b414
00fb8d4
c7da227
79acb20
8996c80
746d569
0f0ffc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,9 +379,10 @@ def test_cwt_complex(dtype, tol, method): | |
dt = time[1] - time[0] | ||
wavelet = 'cmor1.5-1.0' | ||
scales = np.arange(1, 32) | ||
hop_size = 128 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surely the right way to test that |
||
|
||
# real-valued tranfsorm as a reference | ||
[cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method) | ||
[cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method, hop_size=hop_size) | ||
|
||
# verify same precision | ||
assert_equal(cfs.real.dtype, sst.dtype) | ||
|
@@ -390,7 +391,7 @@ def test_cwt_complex(dtype, tol, method): | |
# and imaginary components | ||
sst_complex = sst + 1j*sst | ||
[cfs_complex, f] = pywt.cwt(sst_complex, scales, wavelet, dt, | ||
method=method) | ||
method=method, hop_size=hop_size) | ||
assert_allclose(cfs + 1j*cfs, cfs_complex, atol=tol, rtol=tol) | ||
# verify dtype is preserved | ||
assert_equal(cfs_complex.dtype, sst_complex.dtype) | ||
|
@@ -401,6 +402,7 @@ def test_cwt_batch(axis, method): | |
dtype = np.float64 | ||
time, sst = pywt.data.nino() | ||
n_batch = 8 | ||
hop_size = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change does nothing, as do the |
||
batch_axis = 1 - axis | ||
sst1 = np.asarray(sst, dtype=dtype) | ||
sst = np.stack((sst1, ) * n_batch, axis=batch_axis) | ||
|
@@ -409,10 +411,10 @@ def test_cwt_batch(axis, method): | |
scales = np.arange(1, 32) | ||
|
||
# non-batch transform as reference | ||
[cfs1, f] = pywt.cwt(sst1, scales, wavelet, dt, method=method, axis=axis) | ||
[cfs1, f] = pywt.cwt(sst1, scales, wavelet, dt, method=method, axis=axis, hop_size=hop_size) | ||
|
||
shape_in = sst.shape | ||
[cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method, axis=axis) | ||
[cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method, axis=axis, hop_size=hop_size) | ||
|
||
# shape of input is not modified | ||
assert_equal(shape_in, sst.shape) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be better not to change the existing examples, but rather to add a new one at the end of the Examples section. And above it, explain what
hopsize
actually does: subsample, so the computation is faster, for limited reduction in accuracy. Two images below each other, the first one with the full accuracy and the second one with reduced accuracy, allow the reader to then actually see the effect of usinghopsize
.