Package: python-pywt
Version: 0.1.7~svn97-1
Severity: normal
if you get an example from
www.pybytes.com/pywavelets/demo/wp_simple_compression.py
and add at the end a line
d = wp.get_level(4, "freq")
you would get (after running and possibly replacing arrayrange to arange
if you have up-to-date matplotlib):
,--
| ...
| Retaining 99.93% energy
| Traceback (most recent call last):
| File "wp_simple_compression_2.py", line 54, in <module>
| d = wp.get_level(4, "freq")
| File "/usr/lib/python2.5/site-packages/pywt/wavelet_packets.py", line 318,
in get_level
| self.walk(collect)
| File "/usr/lib/python2.5/site-packages/pywt/wavelet_packets.py", line 292,
in walk
| self.getChild("d").walk(func, args)
| File "/usr/lib/python2.5/site-packages/pywt/wavelet_packets.py", line 178,
in walk
| a.walk(func, args)
| AttributeError: 'NoneType' object has no attribute 'walk'
|
`---
so get_level (or walk) has no clue how to behave nicely if some nodes
were pruned
For your convinience I am attaching that script with line added and
modification in place to run it on sid
Also I put another remark with XXX since it seems to me that logic is not
correct:
,---
| ## simple energy based criteria, not very efficient
| def select(node, min_energy):
| # XXX shouldn't either both be with log or none of them?
| if node.energy() < math.log(min_energy):
`---
Thank you in advance for looking at it, or simply forward it upstream please
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (991, 'testing'), (990, 'unstable'), (300, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages python-pywt depends on:
ii libc6 2.7-15 GNU C Library: Shared libraries
ii python 2.5.2-2 An interactive high-level object-o
ii python-central 0.6.8 register and build utility for Pyt
ii python-numpy 1:1.1.0-3 Numerical Python adds a fast array
python-pywt recommends no packages.
python-pywt suggests no packages.
-- debconf-show failed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pywt import WaveletPacket
import pylab
import math
import numpy
# XXX was deprecated
# x = pylab.arrayrange(612-80, 20, -0.5)/150.
x = pylab.arange(612-80, 20, -0.5)/150.
data = pylab.sin(20*pylab.log(x)) * pylab.sign((pylab.log(x)))
#from sample_data import ecg as data
#data = numpy.array(data, numpy.float64) / 100.
## simple energy based criteria, not very efficient
def select(node, min_energy):
# XXX shouldn't either both be with log or none of them?
if node.energy() < math.log(min_energy):
print node.path, "marked as ZT", len(node.data)
node.markZeroTree()
return False # stop processing child nodes
return True
## create our tree
wp = WaveletPacket(data, wavelet='sym3', mode='sp1', maxlevel=6)
treshold = 0.0021
base_energy = wp.energy()
wp.walk(select, (treshold*base_energy,))
print "Non-zero trees:"
for node in wp.get_nonzero():
print node.path, len(node.data)
new_data = wp.reconstruct()
print "Reconstructing %d samples using %d coefficients" % (wp.data_size, sum([len(node.data) for node in wp.get_nonzero()]))
print "Mean difference:", sum(abs(new_data - data))/len(data)
print "Retaining %.2f%% energy" % (100-(base_energy-wp.energy())*100./base_energy)
pylab.plot(x, data, label="orig")
pylab.plot(x, wp.data, label="rec")
pylab.xlim(min(x), max(x))
#pylab.plot(data, label="orig")
#pylab.plot(wp.data, label="rec")
#pylab.xlim(0, len(data)-1)
pylab.legend()
pylab.show()
d = wp.get_level(4, "freq")
_______________________________________________
Python-modules-team mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/python-modules-team