diff --git a/tests/statistics/test_collector.py b/tests/statistics/test_collector.py index 24d7cfb418aa8a8a7500266b0c10f4191953177d..8ca45f9cc8583387318dc950a5df319f63640717 100644 --- a/tests/statistics/test_collector.py +++ b/tests/statistics/test_collector.py @@ -135,17 +135,19 @@ class TestXSTCollector(base.TestCase): f"but was written to the XST matrix.", ) - def test_conjugated_packet(self): - """Test packet payload conjugation with a baseline (a,b) where a<b""" + def test_conjugated_transposed_packet(self): + """Test packet payload conjugation & transposewith a baseline (a,b) where a<b""" collector = XSTCollector() - # a valid packet as obtained from SDP, with 64-bit BE 1+1j as payload, at - # baseline (0,12) VV VV + # a valid packet as obtained from SDP. + # the first 72 samples are 1+1j, the second 72 samples are 2+2j (64-bit BE). + # at baseline (0,12) VV VV packet = ( b"X\x05\x00\x00\x00\x00\x00\x00\x10\x08\x00\x02\xfa\xef\x00f\x00\x0c\x0c" b"\x08\x01 \x14\x00\x00\x01!\xd9&z\x1b\xb3" - + 288 * b"\x00\x00\x00\x00\x00\x00\x00\x01" + + 144 * b"\x00\x00\x00\x00\x00\x00\x00\x01" + + 144 * b"\x00\x00\x00\x00\x00\x00\x00\x02" ) # parse it ourselves to extract info nicely @@ -165,6 +167,11 @@ class TestXSTCollector(base.TestCase): # zero xst_values = collector.xst_values()[0] + # number of complex values that should end up in the XST matrix + correct_nr_values = 144 + # number of values we've counted so far + actual_nr_values = 0 + for baseline_a in range(collector.MAX_INPUTS): for baseline_b in range(collector.MAX_INPUTS): if baseline_b > baseline_a: @@ -184,12 +191,25 @@ class TestXSTCollector(base.TestCase): ) if baseline_a_was_in_packet and baseline_b_was_in_packet: - self.assertEqual( - 1 - 1j, - xst_values[baseline_a][baseline_b], - msg=f"element [{baseline_a}][{baseline_b}] did not end up " - f"conjugated in XST matrix.", - ) + # through conjugation, the imaginary part is made negative + # through transposition, the second dimension (b) now is the divider + # between the two distinct values + if baseline_b - fields.first_baseline[0] < 6: + self.assertEqual( + 1 - 1j, + xst_values[baseline_a][baseline_b], + msg=f"element [{baseline_a}][{baseline_b}] did not end up " + f"conjugated & transposed in XST matrix.", + ) + else: + self.assertEqual( + 2 - 2j, + xst_values[baseline_a][baseline_b], + msg=f"element [{baseline_a}][{baseline_b}] did not end up " + f"conjugated & transposed in XST matrix.", + ) + + actual_nr_values += 1 else: self.assertEqual( 0 + 0j, @@ -198,6 +218,8 @@ class TestXSTCollector(base.TestCase): f"but was written to the XST matrix.", ) + self.assertEqual(correct_nr_values, actual_nr_values, "Mismatch between number of values in the packet and in the resulting matrix") + def test_multiple_subbands(self): collector = XSTCollector()