[python-dtcwt] 353/497: move lowlevel functions to backend-specific modules
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:25 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.
commit baec839fe513d979af58c635e96b5030bb170b85
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Fri Feb 7 14:41:08 2014 +0000
move lowlevel functions to backend-specific modules
---
docs/implementations.rst | 26 +++
docs/index.rst | 1 +
docs/reference.rst | 16 --
dtcwt/lowlevel.py | 74 ---------
dtcwt/numpy/lowlevel.py | 383 ++++++++++++++++++++++---------------------
dtcwt/numpy/transform2d.py | 61 ++++---
dtcwt/transform1d.py | 2 +-
dtcwt/transform3d.py | 2 +-
scripts/benchmark_opencl.py | 6 +-
tests/testagainstmatlab.py | 2 +-
tests/testcoldfilt.py | 2 +-
tests/testcolfilter.py | 2 +-
tests/testcolifilt.py | 2 +-
tests/testopenclcoldfilt.py | 2 +-
tests/testopenclcolfilter.py | 2 +-
tests/testopenclcolifilt.py | 2 +-
16 files changed, 260 insertions(+), 325 deletions(-)
diff --git a/docs/implementations.rst b/docs/implementations.rst
new file mode 100644
index 0000000..05bda6b
--- /dev/null
+++ b/docs/implementations.rst
@@ -0,0 +1,26 @@
+Backend API Reference
+=====================
+
+The following modules provide backend-specific implementations. Usually you
+won't need to import these modules directly; the main API will use an
+appropriate implementation. Occasionally, however, you may want to benchmark
+one implementation against the other.
+
+NumPy
+'''''
+
+.. automodule:: dtcwt.numpy
+ :members:
+
+.. automodule:: dtcwt.numpy.lowlevel
+ :members:
+
+OpenCL
+''''''
+
+.. automodule:: dtcwt.opencl
+ :members:
+
+.. automodule:: dtcwt.opencl.lowlevel
+ :members:
+
diff --git a/docs/index.rst b/docs/index.rst
index f7167eb..86733f0 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -17,6 +17,7 @@ Contents
algorithms
examples
reference
+ implementations
Features of note
````````````````
diff --git a/docs/reference.rst b/docs/reference.rst
index d71dec2..0866558 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -7,19 +7,6 @@ Main interface
.. automodule:: dtcwt
:members:
-NumPy
-'''''
-
-.. automodule:: dtcwt.numpy
- :members:
- :inherited-members:
-
-OpenCL
-''''''
-
-.. automodule:: dtcwt.opencl
- :inherited-members:
-
Keypoint analysis
`````````````````
@@ -59,8 +46,5 @@ here just in case you do.
.. automodule:: dtcwt.coeffs
:members:
-.. automodule:: dtcwt.lowlevel
- :members:
-
.. automodule:: dtcwt.utils
:members:
diff --git a/dtcwt/lowlevel.py b/dtcwt/lowlevel.py
deleted file mode 100644
index 7239fc7..0000000
--- a/dtcwt/lowlevel.py
+++ /dev/null
@@ -1,74 +0,0 @@
-from dtcwt.numpy.lowlevel import LowLevelBackendNumPy
-
-_BACKEND = LowLevelBackendNumPy()
-
-def colfilter(X, h):
- """Filter the columns of image *X* using filter vector *h*, without decimation.
- If len(h) is odd, each output sample is aligned with each input sample
- and *Y* is the same size as *X*. If len(h) is even, each output sample is
- aligned with the mid point of each pair of input samples, and Y.shape =
- X.shape + [1 0].
-
- :param X: an image whose columns are to be filtered
- :param h: the filter coefficients.
- :returns Y: the filtered image.
-
- """
- return _BACKEND.colfilter(X, h)
-
-def coldfilt(X, ha, hb):
- """Filter the columns of image X using the two filters ha and hb =
- reverse(ha). ha operates on the odd samples of X and hb on the even
- samples. Both filters should be even length, and h should be approx linear
- phase with a quarter sample advance from its mid pt (i.e. :math:`|h(m/2)| >
- |h(m/2 + 1)|`).
-
- .. code-block:: text
-
- ext top edge bottom edge ext
- Level 1: ! | ! | !
- odd filt on . b b b b a a a a a a a a b b b b
- odd filt on . a a a a b b b b b b b b a a a a
- Level 2: ! | ! | !
- +q filt on x b b a a a a b b
- -q filt on o a a b b b b a a
-
- The output is decimated by two from the input sample rate and the results
- from the two filters, Ya and Yb, are interleaved to give Y. Symmetric
- extension with repeated end samples is used on the composite X columns
- before each filter is applied.
-
- Raises ValueError if the number of rows in X is not a multiple of 4, the
- length of ha does not match hb or the lengths of ha or hb are non-even.
-
- """
- return _BACKEND.coldfilt(X, ha, hb)
-
-def colifilt(X, ha, hb):
- """ Filter the columns of image X using the two filters ha and hb =
- reverse(ha). ha operates on the odd samples of X and hb on the even
- samples. Both filters should be even length, and h should be approx linear
- phase with a quarter sample advance from its mid pt (i.e `:math:`|h(m/2)| >
- |h(m/2 + 1)|`).
-
- .. code-block:: text
-
- ext left edge right edge ext
- Level 2: ! | ! | !
- +q filt on x b b a a a a b b
- -q filt on o a a b b b b a a
- Level 1: ! | ! | !
- odd filt on . b b b b a a a a a a a a b b b b
- odd filt on . a a a a b b b b b b b b a a a a
-
- The output is interpolated by two from the input sample rate and the
- results from the two filters, Ya and Yb, are interleaved to give Y.
- Symmetric extension with repeated end samples is used on the composite X
- columns before each filter is applied.
-
- .. codeauthor:: Rich Wareham <rjw57 at cantab.net>, August 2013
- .. codeauthor:: Cian Shaffrey, Cambridge University, August 2000
- .. codeauthor:: Nick Kingsbury, Cambridge University, August 2000
-
- """
- return _BACKEND.colifilt(X, ha, hb)
diff --git a/dtcwt/numpy/lowlevel.py b/dtcwt/numpy/lowlevel.py
index e3d4029..9df5389 100644
--- a/dtcwt/numpy/lowlevel.py
+++ b/dtcwt/numpy/lowlevel.py
@@ -1,5 +1,7 @@
from __future__ import absolute_import
+__all__ = [ 'colfilter', 'colifilt', 'coldfilt', ]
+
import numpy as np
from six.moves import xrange
from dtcwt.utils import as_column_vector, asfarray, appropriate_complex_type_for, reflect
@@ -42,221 +44,220 @@ def _column_convolve(X, h):
outShape[0] = abs(X.shape[0] - h_size) + 1
return _centered(out, outShape)
-class LowLevelBackendNumPy(object):
- def colfilter(self, X, h):
- """Filter the columns of image *X* using filter vector *h*, without decimation.
- If len(h) is odd, each output sample is aligned with each input sample
- and *Y* is the same size as *X*. If len(h) is even, each output sample is
- aligned with the mid point of each pair of input samples, and Y.shape =
- X.shape + [1 0].
-
- :param X: an image whose columns are to be filtered
- :param h: the filter coefficients.
- :returns Y: the filtered image.
-
- .. codeauthor:: Rich Wareham <rjw57 at cantab.net>, August 2013
- .. codeauthor:: Cian Shaffrey, Cambridge University, August 2000
- .. codeauthor:: Nick Kingsbury, Cambridge University, August 2000
-
- """
-
- # Interpret all inputs as arrays
- X = asfarray(X)
- h = as_column_vector(h)
-
- r, c = X.shape
- m = h.shape[0]
- m2 = np.fix(m*0.5)
-
- # Symmetrically extend with repeat of end samples.
- # Use 'reflect' so r < m2 works OK.
- xe = reflect(np.arange(-m2, r+m2, dtype=np.int), -0.5, r-0.5)
+def colfilter(X, h):
+ """Filter the columns of image *X* using filter vector *h*, without decimation.
+ If len(h) is odd, each output sample is aligned with each input sample
+ and *Y* is the same size as *X*. If len(h) is even, each output sample is
+ aligned with the mid point of each pair of input samples, and Y.shape =
+ X.shape + [1 0].
- # Perform filtering on the columns of the extended matrix X(xe,:), keeping
- # only the 'valid' output samples, so Y is the same size as X if m is odd.
- Y = _column_convolve(X[xe,:], h)
-
- return Y
+ :param X: an image whose columns are to be filtered
+ :param h: the filter coefficients.
+ :returns Y: the filtered image.
- def coldfilt(self, X, ha, hb):
- """Filter the columns of image X using the two filters ha and hb =
- reverse(ha). ha operates on the odd samples of X and hb on the even
- samples. Both filters should be even length, and h should be approx linear
- phase with a quarter sample advance from its mid pt (i.e. :math:`|h(m/2)| >
- |h(m/2 + 1)|`).
+ .. codeauthor:: Rich Wareham <rjw57 at cantab.net>, August 2013
+ .. codeauthor:: Cian Shaffrey, Cambridge University, August 2000
+ .. codeauthor:: Nick Kingsbury, Cambridge University, August 2000
- .. code-block:: text
-
- ext top edge bottom edge ext
- Level 1: ! | ! | !
- odd filt on . b b b b a a a a a a a a b b b b
- odd filt on . a a a a b b b b b b b b a a a a
- Level 2: ! | ! | !
- +q filt on x b b a a a a b b
- -q filt on o a a b b b b a a
-
- The output is decimated by two from the input sample rate and the results
- from the two filters, Ya and Yb, are interleaved to give Y. Symmetric
- extension with repeated end samples is used on the composite X columns
- before each filter is applied.
+ """
+
+ # Interpret all inputs as arrays
+ X = asfarray(X)
+ h = as_column_vector(h)
+
+ r, c = X.shape
+ m = h.shape[0]
+ m2 = np.fix(m*0.5)
+
+ # Symmetrically extend with repeat of end samples.
+ # Use 'reflect' so r < m2 works OK.
+ xe = reflect(np.arange(-m2, r+m2, dtype=np.int), -0.5, r-0.5)
+
+ # Perform filtering on the columns of the extended matrix X(xe,:), keeping
+ # only the 'valid' output samples, so Y is the same size as X if m is odd.
+ Y = _column_convolve(X[xe,:], h)
+
+ return Y
+
+def coldfilt(X, ha, hb):
+ """Filter the columns of image X using the two filters ha and hb =
+ reverse(ha). ha operates on the odd samples of X and hb on the even
+ samples. Both filters should be even length, and h should be approx linear
+ phase with a quarter sample advance from its mid pt (i.e. :math:`|h(m/2)| >
+ |h(m/2 + 1)|`).
+
+ .. code-block:: text
+
+ ext top edge bottom edge ext
+ Level 1: ! | ! | !
+ odd filt on . b b b b a a a a a a a a b b b b
+ odd filt on . a a a a b b b b b b b b a a a a
+ Level 2: ! | ! | !
+ +q filt on x b b a a a a b b
+ -q filt on o a a b b b b a a
+
+ The output is decimated by two from the input sample rate and the results
+ from the two filters, Ya and Yb, are interleaved to give Y. Symmetric
+ extension with repeated end samples is used on the composite X columns
+ before each filter is applied.
+
+ Raises ValueError if the number of rows in X is not a multiple of 4, the
+ length of ha does not match hb or the lengths of ha or hb are non-even.
+
+ .. codeauthor:: Rich Wareham <rjw57 at cantab.net>, August 2013
+ .. codeauthor:: Cian Shaffrey, Cambridge University, August 2000
+ .. codeauthor:: Nick Kingsbury, Cambridge University, August 2000
- Raises ValueError if the number of rows in X is not a multiple of 4, the
- length of ha does not match hb or the lengths of ha or hb are non-even.
+ """
+ # Make sure all inputs are arrays
+ X = asfarray(X)
+ ha = asfarray(ha)
+ hb = asfarray(hb)
+
+ r, c = X.shape
+ if r % 4 != 0:
+ raise ValueError('No. of rows in X must be a multiple of 4')
+
+ if ha.shape != hb.shape:
+ raise ValueError('Shapes of ha and hb must be the same')
+
+ if ha.shape[0] % 2 != 0:
+ raise ValueError('Lengths of ha and hb must be even')
+
+ m = ha.shape[0]
+ m2 = np.fix(m*0.5)
+
+ # Set up vector for symmetric extension of X with repeated end samples.
+ xe = reflect(np.arange(-m, r+m), -0.5, r-0.5)
+
+ # Select odd and even samples from ha and hb. Note that due to 0-indexing
+ # 'odd' and 'even' are not perhaps what you might expect them to be.
+ hao = as_column_vector(ha[0:m:2])
+ hae = as_column_vector(ha[1:m:2])
+ hbo = as_column_vector(hb[0:m:2])
+ hbe = as_column_vector(hb[1:m:2])
+ t = np.arange(5, r+2*m-2, 4)
+ r2 = r/2;
+ Y = np.zeros((r2,c), dtype=X.dtype)
+
+ if np.sum(ha*hb) > 0:
+ s1 = slice(0, r2, 2)
+ s2 = slice(1, r2, 2)
+ else:
+ s2 = slice(0, r2, 2)
+ s1 = slice(1, r2, 2)
+
+ # Perform filtering on columns of extended matrix X(xe,:) in 4 ways.
+ Y[s1,:] = _column_convolve(X[xe[t-1],:],hao) + _column_convolve(X[xe[t-3],:],hae)
+ Y[s2,:] = _column_convolve(X[xe[t],:],hbo) + _column_convolve(X[xe[t-2],:],hbe)
+
+ return Y
+
+def colifilt(X, ha, hb):
+ """ Filter the columns of image X using the two filters ha and hb =
+ reverse(ha). ha operates on the odd samples of X and hb on the even
+ samples. Both filters should be even length, and h should be approx linear
+ phase with a quarter sample advance from its mid pt (i.e `:math:`|h(m/2)| >
+ |h(m/2 + 1)|`).
+
+ .. code-block:: text
+
+ ext left edge right edge ext
+ Level 2: ! | ! | !
+ +q filt on x b b a a a a b b
+ -q filt on o a a b b b b a a
+ Level 1: ! | ! | !
+ odd filt on . b b b b a a a a a a a a b b b b
+ odd filt on . a a a a b b b b b b b b a a a a
+
+ The output is interpolated by two from the input sample rate and the
+ results from the two filters, Ya and Yb, are interleaved to give Y.
+ Symmetric extension with repeated end samples is used on the composite X
+ columns before each filter is applied.
+
+ .. codeauthor:: Rich Wareham <rjw57 at cantab.net>, August 2013
+ .. codeauthor:: Cian Shaffrey, Cambridge University, August 2000
+ .. codeauthor:: Nick Kingsbury, Cambridge University, August 2000
- .. codeauthor:: Rich Wareham <rjw57 at cantab.net>, August 2013
- .. codeauthor:: Cian Shaffrey, Cambridge University, August 2000
- .. codeauthor:: Nick Kingsbury, Cambridge University, August 2000
+ """
+ # Make sure all inputs are arrays
+ X = asfarray(X)
+ ha = asfarray(ha)
+ hb = asfarray(hb)
- """
- # Make sure all inputs are arrays
- X = asfarray(X)
- ha = asfarray(ha)
- hb = asfarray(hb)
+ r, c = X.shape
+ if r % 2 != 0:
+ raise ValueError('No. of rows in X must be a multiple of 2')
- r, c = X.shape
- if r % 4 != 0:
- raise ValueError('No. of rows in X must be a multiple of 4')
+ if ha.shape != hb.shape:
+ raise ValueError('Shapes of ha and hb must be the same')
- if ha.shape != hb.shape:
- raise ValueError('Shapes of ha and hb must be the same')
+ if ha.shape[0] % 2 != 0:
+ raise ValueError('Lengths of ha and hb must be even')
- if ha.shape[0] % 2 != 0:
- raise ValueError('Lengths of ha and hb must be even')
+ m = ha.shape[0]
+ m2 = np.fix(m*0.5)
- m = ha.shape[0]
- m2 = np.fix(m*0.5)
+ Y = np.zeros((r*2,c), dtype=X.dtype)
+ if not np.any(np.nonzero(X[:])[0]):
+ return Y
+ if m2 % 2 == 0:
+ # m/2 is even, so set up t to start on d samples.
# Set up vector for symmetric extension of X with repeated end samples.
- xe = reflect(np.arange(-m, r+m), -0.5, r-0.5)
-
+ # Use 'reflect' so r < m2 works OK.
+ xe = reflect(np.arange(-m2, r+m2, dtype=np.int), -0.5, r-0.5)
+
+ t = np.arange(3, r+m, 2)
+ if np.sum(ha*hb) > 0:
+ ta = t
+ tb = t - 1
+ else:
+ ta = t - 1
+ tb = t
+
# Select odd and even samples from ha and hb. Note that due to 0-indexing
# 'odd' and 'even' are not perhaps what you might expect them to be.
hao = as_column_vector(ha[0:m:2])
hae = as_column_vector(ha[1:m:2])
hbo = as_column_vector(hb[0:m:2])
hbe = as_column_vector(hb[1:m:2])
- t = np.arange(5, r+2*m-2, 4)
- r2 = r/2;
- Y = np.zeros((r2,c), dtype=X.dtype)
+
+ s = np.arange(0,r*2,4)
+
+ Y[s,:] = _column_convolve(X[xe[tb-2],:],hae)
+ Y[s+1,:] = _column_convolve(X[xe[ta-2],:],hbe)
+ Y[s+2,:] = _column_convolve(X[xe[tb ],:],hao)
+ Y[s+3,:] = _column_convolve(X[xe[ta ],:],hbo)
+ else:
+ # m/2 is odd, so set up t to start on b samples.
+ # Set up vector for symmetric extension of X with repeated end samples.
+ # Use 'reflect' so r < m2 works OK.
+ xe = reflect(np.arange(-m2, r+m2, dtype=np.int), -0.5, r-0.5)
+ t = np.arange(2, r+m-1, 2)
if np.sum(ha*hb) > 0:
- s1 = slice(0, r2, 2)
- s2 = slice(1, r2, 2)
+ ta = t
+ tb = t - 1
else:
- s2 = slice(0, r2, 2)
- s1 = slice(1, r2, 2)
-
- # Perform filtering on columns of extended matrix X(xe,:) in 4 ways.
- Y[s1,:] = _column_convolve(X[xe[t-1],:],hao) + _column_convolve(X[xe[t-3],:],hae)
- Y[s2,:] = _column_convolve(X[xe[t],:],hbo) + _column_convolve(X[xe[t-2],:],hbe)
-
- return Y
-
- def colifilt(self, X, ha, hb):
- """ Filter the columns of image X using the two filters ha and hb =
- reverse(ha). ha operates on the odd samples of X and hb on the even
- samples. Both filters should be even length, and h should be approx linear
- phase with a quarter sample advance from its mid pt (i.e `:math:`|h(m/2)| >
- |h(m/2 + 1)|`).
-
- .. code-block:: text
-
- ext left edge right edge ext
- Level 2: ! | ! | !
- +q filt on x b b a a a a b b
- -q filt on o a a b b b b a a
- Level 1: ! | ! | !
- odd filt on . b b b b a a a a a a a a b b b b
- odd filt on . a a a a b b b b b b b b a a a a
+ ta = t - 1
+ tb = t
- The output is interpolated by two from the input sample rate and the
- results from the two filters, Ya and Yb, are interleaved to give Y.
- Symmetric extension with repeated end samples is used on the composite X
- columns before each filter is applied.
+ # Select odd and even samples from ha and hb. Note that due to 0-indexing
+ # 'odd' and 'even' are not perhaps what you might expect them to be.
+ hao = as_column_vector(ha[0:m:2])
+ hae = as_column_vector(ha[1:m:2])
+ hbo = as_column_vector(hb[0:m:2])
+ hbe = as_column_vector(hb[1:m:2])
- .. codeauthor:: Rich Wareham <rjw57 at cantab.net>, August 2013
- .. codeauthor:: Cian Shaffrey, Cambridge University, August 2000
- .. codeauthor:: Nick Kingsbury, Cambridge University, August 2000
-
- """
- # Make sure all inputs are arrays
- X = asfarray(X)
- ha = asfarray(ha)
- hb = asfarray(hb)
-
- r, c = X.shape
- if r % 2 != 0:
- raise ValueError('No. of rows in X must be a multiple of 2')
-
- if ha.shape != hb.shape:
- raise ValueError('Shapes of ha and hb must be the same')
-
- if ha.shape[0] % 2 != 0:
- raise ValueError('Lengths of ha and hb must be even')
-
- m = ha.shape[0]
- m2 = np.fix(m*0.5)
-
- Y = np.zeros((r*2,c), dtype=X.dtype)
- if not np.any(np.nonzero(X[:])[0]):
- return Y
-
- if m2 % 2 == 0:
- # m/2 is even, so set up t to start on d samples.
- # Set up vector for symmetric extension of X with repeated end samples.
- # Use 'reflect' so r < m2 works OK.
- xe = reflect(np.arange(-m2, r+m2, dtype=np.int), -0.5, r-0.5)
-
- t = np.arange(3, r+m, 2)
- if np.sum(ha*hb) > 0:
- ta = t
- tb = t - 1
- else:
- ta = t - 1
- tb = t
-
- # Select odd and even samples from ha and hb. Note that due to 0-indexing
- # 'odd' and 'even' are not perhaps what you might expect them to be.
- hao = as_column_vector(ha[0:m:2])
- hae = as_column_vector(ha[1:m:2])
- hbo = as_column_vector(hb[0:m:2])
- hbe = as_column_vector(hb[1:m:2])
-
- s = np.arange(0,r*2,4)
-
- Y[s,:] = _column_convolve(X[xe[tb-2],:],hae)
- Y[s+1,:] = _column_convolve(X[xe[ta-2],:],hbe)
- Y[s+2,:] = _column_convolve(X[xe[tb ],:],hao)
- Y[s+3,:] = _column_convolve(X[xe[ta ],:],hbo)
- else:
- # m/2 is odd, so set up t to start on b samples.
- # Set up vector for symmetric extension of X with repeated end samples.
- # Use 'reflect' so r < m2 works OK.
- xe = reflect(np.arange(-m2, r+m2, dtype=np.int), -0.5, r-0.5)
-
- t = np.arange(2, r+m-1, 2)
- if np.sum(ha*hb) > 0:
- ta = t
- tb = t - 1
- else:
- ta = t - 1
- tb = t
-
- # Select odd and even samples from ha and hb. Note that due to 0-indexing
- # 'odd' and 'even' are not perhaps what you might expect them to be.
- hao = as_column_vector(ha[0:m:2])
- hae = as_column_vector(ha[1:m:2])
- hbo = as_column_vector(hb[0:m:2])
- hbe = as_column_vector(hb[1:m:2])
-
- s = np.arange(0,r*2,4)
-
- Y[s,:] = _column_convolve(X[xe[tb],:],hao)
- Y[s+1,:] = _column_convolve(X[xe[ta],:],hbo)
- Y[s+2,:] = _column_convolve(X[xe[tb],:],hae)
- Y[s+3,:] = _column_convolve(X[xe[ta],:],hbe)
+ s = np.arange(0,r*2,4)
+
+ Y[s,:] = _column_convolve(X[xe[tb],:],hao)
+ Y[s+1,:] = _column_convolve(X[xe[ta],:],hbo)
+ Y[s+2,:] = _column_convolve(X[xe[tb],:],hae)
+ Y[s+3,:] = _column_convolve(X[xe[ta],:],hbe)
- return Y
+ return Y
# vim:sw=4:sts=4:et
diff --git a/dtcwt/numpy/transform2d.py b/dtcwt/numpy/transform2d.py
index 531ca82..bd29ec4 100644
--- a/dtcwt/numpy/transform2d.py
+++ b/dtcwt/numpy/transform2d.py
@@ -9,10 +9,7 @@ from dtcwt.coeffs import biort as _biort, qshift as _qshift
from dtcwt.defaults import DEFAULT_BIORT, DEFAULT_QSHIFT
from dtcwt.utils import appropriate_complex_type_for, asfarray
-from dtcwt.numpy.lowlevel import LowLevelBackendNumPy
-
-# Use the NumPy low-level backend
-_BACKEND = LowLevelBackendNumPy()
+from dtcwt.numpy.lowlevel import *
class Pyramid(object):
"""A representation of a transform domain signal.
@@ -135,20 +132,20 @@ class Transform2d(object):
if nlevels >= 1:
# Do odd top-level filters on cols.
- Lo = _BACKEND.colfilter(X,h0o).T
- Hi = _BACKEND.colfilter(X,h1o).T
+ Lo = colfilter(X,h0o).T
+ Hi = colfilter(X,h1o).T
if len(self.biort) >= 6:
- Ba = _BACKEND.colfilter(X,h2o).T
+ Ba = colfilter(X,h2o).T
# Do odd top-level filters on rows.
- LoLo = _BACKEND.colfilter(Lo,h0o).T
+ LoLo = colfilter(Lo,h0o).T
Yh[0] = np.zeros((LoLo.shape[0] >> 1, LoLo.shape[1] >> 1, 6), dtype=complex_dtype)
- Yh[0][:,:,0:6:5] = q2c(_BACKEND.colfilter(Hi,h0o).T) # Horizontal pair
- Yh[0][:,:,2:4:1] = q2c(_BACKEND.colfilter(Lo,h1o).T) # Vertical pair
+ Yh[0][:,:,0:6:5] = q2c(colfilter(Hi,h0o).T) # Horizontal pair
+ Yh[0][:,:,2:4:1] = q2c(colfilter(Lo,h1o).T) # Vertical pair
if len(self.biort) >= 6:
- Yh[0][:,:,1:5:3] = q2c(_BACKEND.colfilter(Ba,h2o).T) # Diagonal pair
+ Yh[0][:,:,1:5:3] = q2c(colfilter(Ba,h2o).T) # Diagonal pair
else:
- Yh[0][:,:,1:5:3] = q2c(_BACKEND.colfilter(Hi,h1o).T) # Diagonal pair
+ Yh[0][:,:,1:5:3] = q2c(colfilter(Hi,h1o).T) # Diagonal pair
if include_scale:
Yscale[0] = LoLo
@@ -164,21 +161,21 @@ class Transform2d(object):
LoLo = np.hstack((LoLo[:,:1], LoLo, LoLo[:,-1:]))
# Do even Qshift filters on rows.
- Lo = _BACKEND.coldfilt(LoLo,h0b,h0a).T
- Hi = _BACKEND.coldfilt(LoLo,h1b,h1a).T
+ Lo = coldfilt(LoLo,h0b,h0a).T
+ Hi = coldfilt(LoLo,h1b,h1a).T
if len(self.qshift) >= 12:
- Ba = _BACKEND.coldfilt(LoLo,h2b,h2a).T
+ Ba = coldfilt(LoLo,h2b,h2a).T
# Do even Qshift filters on columns.
- LoLo = _BACKEND.coldfilt(Lo,h0b,h0a).T
+ LoLo = coldfilt(Lo,h0b,h0a).T
Yh[level] = np.zeros((LoLo.shape[0]>>1, LoLo.shape[1]>>1, 6), dtype=complex_dtype)
- Yh[level][:,:,0:6:5] = q2c(_BACKEND.coldfilt(Hi,h0b,h0a).T) # Horizontal
- Yh[level][:,:,2:4:1] = q2c(_BACKEND.coldfilt(Lo,h1b,h1a).T) # Vertical
+ Yh[level][:,:,0:6:5] = q2c(coldfilt(Hi,h0b,h0a).T) # Horizontal
+ Yh[level][:,:,2:4:1] = q2c(coldfilt(Lo,h1b,h1a).T) # Vertical
if len(self.qshift) >= 12:
- Yh[level][:,:,1:5:3] = q2c(_BACKEND.coldfilt(Ba,h2b,h2a).T) # Diagonal
+ Yh[level][:,:,1:5:3] = q2c(coldfilt(Ba,h2b,h2a).T) # Diagonal
else:
- Yh[level][:,:,1:5:3] = q2c(_BACKEND.coldfilt(Hi,h1b,h1a).T) # Diagonal
+ Yh[level][:,:,1:5:3] = q2c(coldfilt(Hi,h1b,h1a).T) # Diagonal
if include_scale:
Yscale[level] = LoLo
@@ -269,19 +266,19 @@ class Transform2d(object):
hh = c2q(Yh[current_level-1][:,:,[1, 4]], gain_mask[[1, 4], current_level-1])
# Do even Qshift filters on columns.
- y1 = _BACKEND.colifilt(Z,g0b,g0a) + _BACKEND.colifilt(lh,g1b,g1a)
+ y1 = colifilt(Z,g0b,g0a) + colifilt(lh,g1b,g1a)
if len(self.qshift) >= 12:
- y2 = _BACKEND.colifilt(hl,g0b,g0a)
- y2bp = _BACKEND.colifilt(hh,g2b,g2a)
+ y2 = colifilt(hl,g0b,g0a)
+ y2bp = colifilt(hh,g2b,g2a)
# Do even Qshift filters on rows.
- Z = (_BACKEND.colifilt(y1.T,g0b,g0a) + _BACKEND.colifilt(y2.T,g1b,g1a) + _BACKEND.colifilt(y2bp.T, g2b, g2a)).T
+ Z = (colifilt(y1.T,g0b,g0a) + colifilt(y2.T,g1b,g1a) + colifilt(y2bp.T, g2b, g2a)).T
else:
- y2 = _BACKEND.colifilt(hl,g0b,g0a) + _BACKEND.colifilt(hh,g1b,g1a)
+ y2 = colifilt(hl,g0b,g0a) + colifilt(hh,g1b,g1a)
# Do even Qshift filters on rows.
- Z = (_BACKEND.colifilt(y1.T,g0b,g0a) + _BACKEND.colifilt(y2.T,g1b,g1a)).T
+ Z = (colifilt(y1.T,g0b,g0a) + colifilt(y2.T,g1b,g1a)).T
# Check size of Z and crop as required
[row_size, col_size] = Z.shape
@@ -302,19 +299,19 @@ class Transform2d(object):
hh = c2q(Yh[current_level-1][:,:,[1, 4]],gain_mask[[1, 4],current_level-1])
# Do odd top-level filters on columns.
- y1 = _BACKEND.colfilter(Z,g0o) + _BACKEND.colfilter(lh,g1o)
+ y1 = colfilter(Z,g0o) + colfilter(lh,g1o)
if len(self.biort) >= 6:
- y2 = _BACKEND.colfilter(hl,g0o)
- y2bp = _BACKEND.colfilter(hh,g2o)
+ y2 = colfilter(hl,g0o)
+ y2bp = colfilter(hh,g2o)
# Do odd top-level filters on rows.
- Z = (_BACKEND.colfilter(y1.T,g0o) + _BACKEND.colfilter(y2.T,g1o) + _BACKEND.colfilter(y2bp.T, g2o)).T
+ Z = (colfilter(y1.T,g0o) + colfilter(y2.T,g1o) + colfilter(y2bp.T, g2o)).T
else:
- y2 = _BACKEND.colfilter(hl,g0o) + _BACKEND.colfilter(hh,g1o)
+ y2 = colfilter(hl,g0o) + colfilter(hh,g1o)
# Do odd top-level filters on rows.
- Z = (_BACKEND.colfilter(y1.T,g0o) + _BACKEND.colfilter(y2.T,g1o)).T
+ Z = (colfilter(y1.T,g0o) + colfilter(y2.T,g1o)).T
return Z
diff --git a/dtcwt/transform1d.py b/dtcwt/transform1d.py
index 6bb74a6..65f3a0b 100644
--- a/dtcwt/transform1d.py
+++ b/dtcwt/transform1d.py
@@ -7,7 +7,7 @@ from six.moves import xrange
from dtcwt.coeffs import biort as _biort, qshift as _qshift
from dtcwt.defaults import DEFAULT_BIORT, DEFAULT_QSHIFT
-from dtcwt.lowlevel import colfilter, coldfilt, colifilt
+from dtcwt.numpy.lowlevel import colfilter, coldfilt, colifilt
from dtcwt.utils import as_column_vector, asfarray
def dtwavexfm(X, nlevels=3, biort=DEFAULT_BIORT, qshift=DEFAULT_QSHIFT, include_scale=False):
diff --git a/dtcwt/transform3d.py b/dtcwt/transform3d.py
index 0f233f4..7274c16 100644
--- a/dtcwt/transform3d.py
+++ b/dtcwt/transform3d.py
@@ -7,7 +7,7 @@ from six.moves import xrange
from dtcwt.coeffs import biort as _biort, qshift as _qshift
from dtcwt.defaults import DEFAULT_BIORT, DEFAULT_QSHIFT
-from dtcwt.lowlevel import colfilter, coldfilt, colifilt
+from dtcwt.numpy.lowlevel import colfilter, coldfilt, colifilt
from dtcwt.utils import asfarray
def dtwavexfm3(X, nlevels=3, biort=DEFAULT_BIORT, qshift=DEFAULT_QSHIFT, ext_mode=4, discard_level_1=False):
diff --git a/scripts/benchmark_opencl.py b/scripts/benchmark_opencl.py
index d6e3fef..fe6730a 100644
--- a/scripts/benchmark_opencl.py
+++ b/scripts/benchmark_opencl.py
@@ -57,7 +57,7 @@ def main():
print('Running NumPy colfilter...')
a = benchmark('colfilter(lena, h1o)',
- 'from dtcwt.lowlevel import colfilter; from __main__ import lena, h1o')
+ 'from dtcwt.numpy.lowlevel import colfilter; from __main__ import lena, h1o')
print('Running OpenCL colfilter...')
b = benchmark('colfilter(lena, h1o)',
'from dtcwt.opencl.lowlevel import colfilter; from __main__ import lena, h1o')
@@ -66,7 +66,7 @@ def main():
print('Running NumPy coldfilt...')
a = benchmark('coldfilt(lena, h0b, h0a)',
- 'from dtcwt.lowlevel import coldfilt; from __main__ import lena, h0b, h0a')
+ 'from dtcwt.numpy.lowlevel import coldfilt; from __main__ import lena, h0b, h0a')
print('Running OpenCL coldfilt...')
b = benchmark('coldfilt(lena, h0b, h0a)',
'from dtcwt.opencl.lowlevel import coldfilt; from __main__ import lena, h0b, h0a')
@@ -75,7 +75,7 @@ def main():
print('Running NumPy colifilt...')
a = benchmark('colifilt(lena, h0b, h0a)',
- 'from dtcwt.lowlevel import colifilt; from __main__ import lena, h0b, h0a')
+ 'from dtcwt.numpy.lowlevel import colifilt; from __main__ import lena, h0b, h0a')
print('Running OpenCL colifilt...')
b = benchmark('colifilt(lena, h0b, h0a)',
'from dtcwt.opencl.lowlevel import colifilt; from __main__ import lena, h0b, h0a')
diff --git a/tests/testagainstmatlab.py b/tests/testagainstmatlab.py
index 14c7231..8b61690 100644
--- a/tests/testagainstmatlab.py
+++ b/tests/testagainstmatlab.py
@@ -5,7 +5,7 @@ from nose.plugins.attrib import attr
import numpy as np
from dtcwt.compat import dtwavexfm2, dtwaveifm2, dtwavexfm2b, dtwaveifm2b
from dtcwt.coeffs import biort, qshift
-from dtcwt.lowlevel import coldfilt, colifilt
+from dtcwt.numpy.lowlevel import coldfilt, colifilt
from dtcwt.sampling import rescale_highpass
from .util import assert_almost_equal, summarise_mat, assert_percentile_almost_equal
diff --git a/tests/testcoldfilt.py b/tests/testcoldfilt.py
index 8c59c0e..3f5dd2d 100644
--- a/tests/testcoldfilt.py
+++ b/tests/testcoldfilt.py
@@ -1,7 +1,7 @@
import os
import numpy as np
-from dtcwt.lowlevel import coldfilt
+from dtcwt.numpy.lowlevel import coldfilt
from nose.tools import raises
diff --git a/tests/testcolfilter.py b/tests/testcolfilter.py
index 9241788..22074f4 100644
--- a/tests/testcolfilter.py
+++ b/tests/testcolfilter.py
@@ -2,7 +2,7 @@ import os
import numpy as np
from dtcwt.coeffs import biort, qshift
-from dtcwt.lowlevel import colfilter
+from dtcwt.numpy.lowlevel import colfilter
import tests.datasets as datasets
diff --git a/tests/testcolifilt.py b/tests/testcolifilt.py
index 3af4132..7c0262e 100644
--- a/tests/testcolifilt.py
+++ b/tests/testcolifilt.py
@@ -1,7 +1,7 @@
import os
import numpy as np
-from dtcwt.lowlevel import colifilt
+from dtcwt.numpy.lowlevel import colifilt
from nose.tools import raises
diff --git a/tests/testopenclcoldfilt.py b/tests/testopenclcoldfilt.py
index c5ee603..f303f98 100644
--- a/tests/testopenclcoldfilt.py
+++ b/tests/testopenclcoldfilt.py
@@ -1,7 +1,7 @@
import os
import numpy as np
-from dtcwt.lowlevel import coldfilt as coldfilt_gold
+from dtcwt.numpy.lowlevel import coldfilt as coldfilt_gold
from dtcwt.opencl.lowlevel import coldfilt, NoCLPresentError
from dtcwt.coeffs import biort, qshift
diff --git a/tests/testopenclcolfilter.py b/tests/testopenclcolfilter.py
index be3660a..9d9a1e5 100644
--- a/tests/testopenclcolfilter.py
+++ b/tests/testopenclcolfilter.py
@@ -3,7 +3,7 @@ import os
import numpy as np
from dtcwt.coeffs import biort, qshift
from dtcwt.opencl.lowlevel import colfilter
-from dtcwt.lowlevel import colfilter as colfilter_gold
+from dtcwt.numpy.lowlevel import colfilter as colfilter_gold
from .util import assert_almost_equal, skip_if_no_cl
import tests.datasets as datasets
diff --git a/tests/testopenclcolifilt.py b/tests/testopenclcolifilt.py
index de44bc5..0abf8c9 100644
--- a/tests/testopenclcolifilt.py
+++ b/tests/testopenclcolifilt.py
@@ -2,7 +2,7 @@ import os
import numpy as np
from dtcwt.opencl.lowlevel import colifilt
-from dtcwt.lowlevel import colifilt as colifilt_gold
+from dtcwt.numpy.lowlevel import colifilt as colifilt_gold
from dtcwt.coeffs import biort, qshift
from nose.tools import raises
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git
More information about the debian-science-commits
mailing list