From cd50fb2460ef6d19c68daa9e38d427a32abb9384 Mon Sep 17 00:00:00 2001 From: whitews Date: Tue, 28 May 2024 17:01:45 -0400 Subject: [PATCH] add tests for Matrix equality (closes #200) --- tests/matrix_tests.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/matrix_tests.py b/tests/matrix_tests.py index c41311a4..769de765 100644 --- a/tests/matrix_tests.py +++ b/tests/matrix_tests.py @@ -1,6 +1,7 @@ """ Matrix class tests """ +import copy import unittest import numpy as np import pandas as pd @@ -81,6 +82,30 @@ def test_parse_csv_file(self): self.assertIsInstance(comp_mat, fk.Matrix) + def test_matrix_equals(self): + comp_mat = fk.Matrix( + 'my_spill', + csv_8c_comp_file_path, + detectors_8c + ) + + comp_mat2 = copy.deepcopy(comp_mat) + + self.assertEqual(comp_mat, comp_mat2) + + def test_matrix_equals_fails(self): + comp_mat = fk.Matrix( + 'my_spill', + csv_8c_comp_file_path, + detectors_8c + ) + + # copy & modify matrix array + comp_mat2 = copy.deepcopy(comp_mat) + comp_mat2.matrix[0, 1] = comp_mat2.matrix[0, 1] + 0.01 + + self.assertNotEqual(comp_mat, comp_mat2) + def test_matrix_as_dataframe(self): comp_mat = fk.Matrix( 'my_spill',