From: Paul Brossier Date: Tue, 18 Nov 2025 08:39:41 +0000 (+0100) Subject: [py] improve cvec test using assert_equal and aubio float_type (closes gh-405) X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=c3a4ec421cde908f750184d18ef305f458678db3;p=aubio.git [py] improve cvec test using assert_equal and aubio float_type (closes gh-405) --- diff --git a/python/tests/test_cvec.py b/python/tests/test_cvec.py index 1b7b1ec1..90876bff 100755 --- a/python/tests/test_cvec.py +++ b/python/tests/test_cvec.py @@ -1,7 +1,7 @@ #! /usr/bin/env python import numpy as np -from numpy.testing import TestCase, assert_equal, assert_almost_equal +from numpy.testing import TestCase, assert_equal from aubio import cvec, fvec, float_type wrong_type = 'float32' if float_type == 'float64' else 'float64' @@ -40,10 +40,14 @@ class aubio_cvec_test_case(TestCase): assert_equal(spec.phas, 0) def test_assign_cvec_phas_slice(self): + if float_type == 'float64': + pi = np.float64(np.pi) + else: + pi = np.float32(np.pi) spec = cvec(1024) - spec.phas[39:-1] = -np.pi + spec.phas[39:-1] = -pi assert_equal(spec.phas[0:39], 0) - assert_almost_equal(spec.phas[39:-1], -np.pi, decimal=7) + assert_equal(spec.phas[39:-1], -pi) assert_equal(spec.norm, 0) def test_assign_cvec_with_other_cvec(self):