/usr/share/pyshared/pywt/thresholding.py is in python-pywt 0.2.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # -*- coding: utf-8 -*-
# Copyright (c) 2006-2012 Filip Wasilewski <http://en.ig.ma/>
# See COPYING for license details.
"""Thresholding routines"""
__all__ = ['soft', 'hard', 'greater', 'less', 'zero', 'copy']
import numerix
def soft(data, value, substitute=0):
mvalue = -value
cond_less = numerix.less(data, value)
cond_greater = numerix.greater(data, mvalue)
data = numerix.where(cond_less & cond_greater, substitute, data)
data = numerix.where(cond_less, data + value, data)
data = numerix.where(cond_greater, data - value, data)
return data
def hard(data, value, substitute=0):
mvalue = -value
cond = numerix.less(data, value)
cond &= numerix.greater(data, mvalue)
return numerix.where(cond, substitute, data)
def greater(data, value, substitute=0):
return numerix.where(numerix.less(data, value), substitute, data)
def less(data, value, substitute=0):
return numerix.where(numerix.greater(data, value), substitute, data)
def zero(data, *args):
if isinstance(data, numerix.ndarray):
return numerix.zeros(data.shape, data.dtype)
return numerix.zeros(len(data))
def copy(data, *args):
return numerix.array(data)
|