Coverage for tests / tests_library / tests_functions / test_base_operations_functions.py: 100%
18 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-09 16:40 +0100
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-09 16:40 +0100
1# SPDX-FileCopyrightText: Copyright INRIA
2#
3# SPDX-License-Identifier: LGPL-3.0-only
4#
5# Copyright INRIA
6#
7# This file is part of PhysioBlocks, a library mostly developed by the
8# [Ananke project-team](https://team.inria.fr/ananke) at INRIA.
9#
10# Authors:
11# - Colin Drieu
12# - Dominique Chapelle
13# - François Kimmig
14# - Philippe Moireau
15#
16# PhysioBlocks is free software: you can redistribute it and/or modify it under the
17# terms of the GNU Lesser General Public License as published by the Free Software
18# Foundation, version 3 of the License.
19#
20# PhysioBlocks is distributed in the hope that it will be useful, but WITHOUT ANY
21# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
22# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
23#
24# You should have received a copy of the GNU Lesser General Public License along with
25# PhysioBlocks. If not, see <https://www.gnu.org/licenses/>.
27import pytest
29from physioblocks.library.functions.base_operations import (
30 Product,
31 Sum,
32)
35def test_eval_sum_quantities():
36 scalar_list = [0.1, 0.2, 0.3]
37 func = Sum(scalar_list)
38 assert func.eval() == pytest.approx(0.6)
40 vector_list = [scalar_list, scalar_list, scalar_list]
41 func = Sum(vector_list)
42 assert func.eval() == pytest.approx([0.3, 0.6, 0.9])
44 func = Sum(vector_list, vector_list)
45 assert func.eval() == pytest.approx([0.0, 0.0, 0.0])
48def test_eval_product_blocks_quantity():
49 scalar_list = [0.1, 0.1, 0.1]
50 func = Product(scalar_list)
51 assert func.eval() == pytest.approx(1.0e-3)
53 # vector
54 vector_list = [scalar_list, scalar_list, scalar_list]
55 func = Product(vector_list)
56 assert func.eval() == pytest.approx([1.0e-3, 1.0e-3, 1.0e-3])