From b5d6897e230d13232104906faf88def4b3ed0828 Mon Sep 17 00:00:00 2001 From: TIM ANDERSON Date: Wed, 18 Nov 2026 20:33:16 +1000 Subject: [PATCH] Fix NumPy scalar assignments in conform7 covariance propagation --- geodepy/tests/test_transform.py | 15 +++++++++++++++ geodepy/transform.py | 16 +++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/geodepy/tests/test_transform.py b/geodepy/tests/test_transform.py index 01a56ec..522fd8c 100644 --- a/geodepy/tests/test_transform.py +++ b/geodepy/tests/test_transform.py @@ -1,5 +1,7 @@ import unittest +import numpy as np + from geodepy.transform import ( conform7, conform14, @@ -30,6 +32,19 @@ def test_conform7(self): assert abs(alic_gda1994_comp[1] - alic_gda1994[1]) < 5e-5 assert abs(alic_gda1994_comp[2] - alic_gda1994[2]) < 5e-5 + def test_conform7_covariance(self): + # ALIC coordinates from the GDA2020 Technical Manual, section 3.1.1. + alic_gda1994 = (-4052051.7643, 4212836.2017, -2545106.0245) + _, _, _, covariance = conform7( + *alic_gda1994, gda94_to_gda2020, vcv=np.eye(3) * 1e-4 + ) + expected = [ + [1.007199e-4, -1.221569e-7, 7.888910e-8], + [-1.221569e-7, 1.006026e-4, -7.672700e-8], + [7.888910e-8, -7.672700e-8, 1.006438e-4], + ] + np.testing.assert_allclose(covariance, expected, rtol=1e-6, atol=0) + def test_conform14(self): # Replication of tests in GDA2020 Tech Manual v1.2 - Sect 3.3.1 alic_gda2020 = (-4052052.7373, 4212835.9835, -2545104.5867) diff --git a/geodepy/transform.py b/geodepy/transform.py index 536f261..9e7baa2 100644 --- a/geodepy/transform.py +++ b/geodepy/transform.py @@ -95,17 +95,15 @@ def conform7(x, y, z, trans, vcv=None): j_mat[2, 2] = scale # XYZ rotated - j_mat[0, 3] = rot_xyz[0] - j_mat[1, 3] = rot_xyz[1] - j_mat[2, 3] = rot_xyz[2] + j_mat[:, 3] = rot_xyz[:, 0] # scaled XYZ - j_mat[0, 5] = -scale * xyz_before[2] - j_mat[0, 6] = scale * xyz_before[1] - j_mat[1, 4] = scale * xyz_before[2] - j_mat[1, 6] = -scale * xyz_before[0] - j_mat[2, 4] = -scale * xyz_before[1] - j_mat[2, 5] = scale * xyz_before[0] + j_mat[0, 5] = -scale * xyz_before[2, 0] + j_mat[0, 6] = scale * xyz_before[1, 0] + j_mat[1, 4] = scale * xyz_before[2, 0] + j_mat[1, 6] = -scale * xyz_before[0, 0] + j_mat[2, 4] = -scale * xyz_before[1, 0] + j_mat[2, 5] = scale * xyz_before[0, 0] # Identity j_mat[0, 7] = 1