Example #1
0
    def test_trivial_basis_change(self):
        """
        Test the change of basis from standard basis to standard basis.
        """
        extent = np.linspace(0, 10, 10, dtype=np.int)
        xx, yy, zz = np.meshgrid(extent, extent, extent)

        XX, YY, ZZ = tr.change_basis_mesh(
            xx=xx, yy=yy, zz=zz, basis1=np.eye(3), basis2=np.eye(3)
        )
        self.assertTrue(np.allclose(xx, XX))
        self.assertTrue(np.allclose(yy, YY))
        self.assertTrue(np.allclose(zz, ZZ))
Example #2
0
    def test_scaling(self):
        extent = np.linspace(0, 10, 10, dtype=np.int)
        xx, yy, zz = np.meshgrid(extent, extent, extent)

        e1, e2, e3 = np.eye(3)

        scaled_basis = [0.5 * e1, 0.5 * e2, 0.5 * e3]

        XX, YY, ZZ = tr.change_basis_mesh(
            xx=xx, yy=yy, zz=zz, basis1=np.eye(3), basis2=scaled_basis
        )
        self.assertTrue(np.allclose(2 * xx, XX))
        self.assertTrue(np.allclose(2 * yy, YY))
        self.assertTrue(np.allclose(2 * zz, ZZ))
Example #3
0
    def test_coordinate_swap(self):
        """
        Tests the change of basis from (x, y, z) to (x, z, y)
        """
        extent = np.linspace(0, 10, 10, dtype=np.int)
        xx, yy, zz = np.meshgrid(extent, extent, extent)

        e1, e2, e3 = np.eye(3)
        swapped_basis = [e1, e3, e2]

        XX, YY, ZZ = tr.change_basis_mesh(
            xx=xx, yy=yy, zz=zz, basis1=np.eye(3), basis2=swapped_basis
        )
        self.assertTrue(np.allclose(xx, XX))
        self.assertTrue(np.allclose(yy, ZZ))
        self.assertTrue(np.allclose(zz, YY))