From 5dc1abc932ef8040f2d66da5b3530741cfa65faa Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 2 May 2016 14:56:40 +0200 Subject: [PATCH] python/tests/test_cvec.py: more tests --- python/tests/test_cvec.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/python/tests/test_cvec.py b/python/tests/test_cvec.py index 00751c7a..a645a14d 100755 --- a/python/tests/test_cvec.py +++ b/python/tests/test_cvec.py @@ -46,6 +46,38 @@ class aubio_cvec_test_case(TestCase): assert_equal(spec.phas[39:-1], -np.pi) assert_equal(spec.norm, 0) + def test_assign_cvec_with_other_cvec(self): + """ check dest cvec is still reachable after source was deleted """ + spec = cvec(1024) + a = np.random.rand(1024/2+1).astype(float_type) + b = np.random.rand(1024/2+1).astype(float_type) + spec.norm = a + spec.phas = b + new_spec = spec + del spec + assert_equal(a, new_spec.norm) + assert_equal(b, new_spec.phas) + assert_equal(id(a), id(new_spec.norm)) + assert_equal(id(b), id(new_spec.phas)) + + def test_pass_to_numpy(self): + spec = cvec(1024) + norm = spec.norm + phas = spec.phas + del spec + new_spec = cvec(1024) + new_spec.norm = norm + new_spec.phas = phas + assert_equal(norm, new_spec.norm) + assert_equal(phas, new_spec.phas) + assert_equal(id(norm), id(new_spec.norm)) + assert_equal(id(phas), id(new_spec.phas)) + del norm + del phas + assert_equal(new_spec.norm, 0.) + assert_equal(new_spec.phas, 0.) + del new_spec + if __name__ == '__main__': from nose2 import main main() -- 2.11.0