[python-dtcwt] 04/497: let reflect take non-array inputs

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:05:41 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 a05b8e550b62af0372dc9aeea704a3771ac85fc0
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date:   Tue Aug 6 12:53:38 2013 +0100

    let reflect take non-array inputs
---
 dtcwt/reflect.py     | 2 +-
 tests/testreflect.py | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/dtcwt/reflect.py b/dtcwt/reflect.py
index 4cffa7b..990e995 100644
--- a/dtcwt/reflect.py
+++ b/dtcwt/reflect.py
@@ -12,7 +12,7 @@ def reflect(x, minx, maxx):
     """
 
     # Copy x to avoid in-place modification
-    y = np.copy(x)
+    y = np.array(x, copy=True)
 
     # Reflect y in maxx.
     y[y > maxx] = 2*maxx - y[y > maxx]
diff --git a/tests/testreflect.py b/tests/testreflect.py
index e9c50c0..46cba0d 100644
--- a/tests/testreflect.py
+++ b/tests/testreflect.py
@@ -20,4 +20,13 @@ def test_linear_ramp_values():
     assert np.any(r)
     assert np.all(reflected[r] == ramp[r])
 
+def test_non_array_input():
+    ramp = np.linspace(-100, 100, 500).tolist()
+    reflected = reflect(ramp, 30, 40)
+
+    # Check boundaries
+    assert not np.any(reflected < 30)
+    assert not np.any(reflected > 40)
+
+
 # vim:sw=4:sts=4:et

-- 
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