Showing the changes to python/tests (1 of 1 file). Show all
Unified · Split
| @@ -46,6 +46,38 @@ class aubio_cvec_test_case(TestCase): · 45 unmodified lines | ||
| 46 | 46 | assert_equal(spec.phas[39:-1], -np.pi) |
| 47 | 47 | assert_equal(spec.norm, 0) |
| 48 | 48 | |
| 49 | + def test_assign_cvec_with_other_cvec(self): | |
| 50 | + """ check dest cvec is still reachable after source was deleted """ | |
| 51 | + spec = cvec(1024) | |
| 52 | + a = np.random.rand(1024/2+1).astype(float_type) | |
| 53 | + b = np.random.rand(1024/2+1).astype(float_type) | |
| 54 | + spec.norm = a | |
| 55 | + spec.phas = b | |
| 56 | + new_spec = spec | |
| 57 | + del spec | |
| 58 | + assert_equal(a, new_spec.norm) | |
| 59 | + assert_equal(b, new_spec.phas) | |
| 60 | + assert_equal(id(a), id(new_spec.norm)) | |
| 61 | + assert_equal(id(b), id(new_spec.phas)) | |
| 62 | + | |
| 63 | + def test_pass_to_numpy(self): | |
| 64 | + spec = cvec(1024) | |
| 65 | + norm = spec.norm | |
| 66 | + phas = spec.phas | |
| 67 | + del spec | |
| 68 | + new_spec = cvec(1024) | |
| 69 | + new_spec.norm = norm | |
| 70 | + new_spec.phas = phas | |
| 71 | + assert_equal(norm, new_spec.norm) | |
| 72 | + assert_equal(phas, new_spec.phas) | |
| 73 | + assert_equal(id(norm), id(new_spec.norm)) | |
| 74 | + assert_equal(id(phas), id(new_spec.phas)) | |
| 75 | + del norm | |
| 76 | + del phas | |
| 77 | + assert_equal(new_spec.norm, 0.) | |
| 78 | + assert_equal(new_spec.phas, 0.) | |
| 79 | + del new_spec | |
| 80 | + | |
| 49 | 81 | if __name__ == '__main__': |
| 50 | 82 | from nose2 import main |
| 51 | 83 | main() |