1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
Origin: upstream, https://bitbucket.org/nigma/pywt/changeset/75bee65cd484
Description: Format float arrays in doctests to fix representation issues
accross Python versions.
Last-Update: 2012-05-22
--- a/doc/source/ref/wavelets.rst
+++ b/doc/source/ref/wavelets.rst
@@ -174,6 +174,9 @@
.. sourcecode:: python
+ >>> def format_array(arr):
+ ... return "[%s]" % ", ".join(["%.14f" % x for x in arr])
+
>>> import pywt
>>> wavelet = pywt.Wavelet('db1')
>>> print wavelet
@@ -184,10 +187,10 @@
Orthogonal: True
Biorthogonal: True
Symmetry: asymmetric
- >>> print wavelet.dec_lo, wavelet.dec_hi
- [0.70710678118654757, 0.70710678118654757] [-0.70710678118654757, 0.70710678118654757]
- >>> print wavelet.rec_lo, wavelet.rec_hi
- [0.70710678118654757, 0.70710678118654757] [0.70710678118654757, -0.70710678118654757]
+ >>> print format_array(wavelet.dec_lo), format_array(wavelet.dec_hi)
+ [0.70710678118655, 0.70710678118655] [-0.70710678118655, 0.70710678118655]
+ >>> print format_array(wavelet.rec_lo), format_array(wavelet.rec_hi)
+ [0.70710678118655, 0.70710678118655] [0.70710678118655, -0.70710678118655]
Approximating wavelet and scaling functions - ``Wavelet.wavefun()``
--- a/doc/source/regression/wavelet.rst
+++ b/doc/source/regression/wavelet.rst
@@ -78,14 +78,17 @@
corresponds to lowpass and highpass decomposition filters and lowpass and
highpass reconstruction filters respectively:
- >>> w.dec_lo
- [0.035226291882100656, -0.085441273882241486, -0.13501102001039084, 0.45987750211933132, 0.80689150931333875, 0.33267055295095688]
- >>> w.dec_hi
- [-0.33267055295095688, 0.80689150931333875, -0.45987750211933132, -0.13501102001039084, 0.085441273882241486, 0.035226291882100656]
- >>> w.rec_lo
- [0.33267055295095688, 0.80689150931333875, 0.45987750211933132, -0.13501102001039084, -0.085441273882241486, 0.035226291882100656]
- >>> w.rec_hi
- [0.035226291882100656, 0.085441273882241486, -0.13501102001039084, -0.45987750211933132, 0.80689150931333875, -0.33267055295095688]
+ >>> def print_array(arr):
+ ... print "[%s]" % ", ".join(["%.14f" % x for x in arr])
+
+ >>> print_array(w.dec_lo)
+ [0.03522629188210, -0.08544127388224, -0.13501102001039, 0.45987750211933, 0.80689150931334, 0.33267055295096]
+ >>> print_array(w.dec_hi)
+ [-0.33267055295096, 0.80689150931334, -0.45987750211933, -0.13501102001039, 0.08544127388224, 0.03522629188210]
+ >>> print_array(w.rec_lo)
+ [0.33267055295096, 0.80689150931334, 0.45987750211933, -0.13501102001039, -0.08544127388224, 0.03522629188210]
+ >>> print_array(w.rec_hi)
+ [0.03522629188210, 0.08544127388224, -0.13501102001039, -0.45987750211933, 0.80689150931334, -0.33267055295096]
Another way to get the filters data is to use the :attr:`~Wavelet.filter_bank`
attribute, which returns all four filters in a tuple:
|