PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
2.04k stars 470 forks source link

ContinuousWavelet: add tests for dtype and remove unused **kwargs #547

Closed grlee77 closed 4 years ago

grlee77 commented 4 years ago

The ContinuousWavelet object allows specifying single or double precision via a dtype argument. This seems to work as expected, although is undocumented. This PR documents this dtype parameter and adds tests for it. I also removed an unused **kwargs parameter from the __cinit__.

Finally, this adds validation during wavelet creation to give a clear error when specifying an unsupported dtype. Prior to this PR the wavelet can be created with unsupported dtypes, but then when trying to use it via wavefun or integrate_wavelet, one would get errors like:

pywt.integrate_wavelet(wavelet=pywt.ContinuousWavelet('cmor1.5-1.0', np.complex64), precision=8)
Traceback (most recent call last):

  File "<ipython-input-79-c5c9ef8f093b>", line 1, in <module>
    pywt.integrate_wavelet(wavelet=pywt.ContinuousWavelet('cmor1.5-1.0', np.complex64), precision=8)

  File "/home/lee8rx/my_git/pyir/pywt/pywt/_functions.py", line 104, in integrate_wavelet
    functions_approximations = wavelet.wavefun(precision)

  File "pywt/_extensions/_pywt.pyx", line 953, in pywt._extensions._pywt.ContinuousWavelet.wavefun

ValueError: Buffer dtype mismatch, expected 'float32_t' but got 'complex float'
codecov-io commented 4 years ago

Codecov Report

Merging #547 into master will increase coverage by 1.82%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #547      +/-   ##
==========================================
+ Coverage   85.86%   87.68%   +1.82%     
==========================================
  Files          23       23              
  Lines        3962     3882      -80     
  Branches      738      467     -271     
==========================================
+ Hits         3402     3404       +2     
+ Misses        491      409      -82     
  Partials       69       69              
Impacted Files Coverage Δ
pywt/_extensions/_pywt.pyx 84.13% <100.00%> (+0.27%) :arrow_up:
pywt/_extensions/c/cwt.template.c 97.84% <0.00%> (+2.05%) :arrow_up:
pywt/_extensions/c/convolution.template.c 98.95% <0.00%> (+2.34%) :arrow_up:
pywt/_extensions/c/wavelets.c 87.06% <0.00%> (+6.60%) :arrow_up:
pywt/_extensions/c/wt.template.c 94.21% <0.00%> (+14.29%) :arrow_up:
pywt/_extensions/c/common.c 100.00% <0.00%> (+16.12%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6c7bfa4...a10c3b6. Read the comment docs.

rgommers commented 4 years ago

LGTM, merged. Thanks @grlee77