Ejemplo n.º 1
0
 def __init__(self, array_a, array_b, translate=False, scale=False, hide_padding=True):
     self.hide_padding = hide_padding
     self.translate = translate
     self.scale = scale
     Procrustes.__init__(
         self, array_a, array_b, translate=self.translate, scale=self.scale, hide_padding=self.hide_padding
     )
    def __init__(self,
                 array_a,
                 array_b,
                 translate=False,
                 scale=False,
                 preserve_symmetry=True,
                 hide_padding=True,
                 translate_symmetrically=False):
        self.hide_padding = hide_padding
        self.translate = translate
        self.scale = scale
        self.preserve_symmetry = preserve_symmetry
        self.translate_symmetrically = translate_symmetrically

        Procrustes.__init__(
            self,
            array_a,
            array_b,
            translate=self.translate,
            scale=self.scale,
            preserve_symmetry=self.preserve_symmetry,
            hide_padding=self.hide_padding,
            translate_symmetrically=self.translate_symmetrically)
        if (abs(self.array_a - self.array_a.T) > 1.e-10).all() or (
                abs(self.array_b - self.array_b.T) > 1.e-10).all():
            raise ValueError(
                'Arrays array_a and array_b must both be symmetric for this analysis.'
            )
Ejemplo n.º 3
0
 def __init__(self, array_a, array_b, translate=False, scale=False, preserve_symmetry=False, hide_padding=True,
              translate_symmetrically=False):
     self.hide_padding = hide_padding
     self.translate = translate
     self.scale = scale
     self.preserve_symmetry = preserve_symmetry
     self.translate_symmetrically=translate_symmetrically
     Procrustes.__init__(self, array_a, array_b, translate=self.translate, scale=self.scale,
                         preserve_symmetry=self.preserve_symmetry, hide_padding=self.hide_padding,
                         translate_symmetrically=self.translate_symmetrically)
    def __init__(self, array_a, array_b, translate=False, scale=False, preserve_symmetry=True, hide_padding=True, translate_symmetrically=False):
        self.hide_padding = hide_padding
        self.translate = translate
        self.scale = scale
        self.preserve_symmetry = preserve_symmetry
        self.translate_symmetrically = translate_symmetrically

        Procrustes.__init__(self, array_a, array_b, translate=self.translate, scale=self.scale,
                preserve_symmetry=self.preserve_symmetry, hide_padding=self.hide_padding, translate_symmetrically=self.translate_symmetrically)

        if (abs(self.array_a - self.array_a.T) > 1.e-10).all() or (abs(self.array_b - self.array_b.T) > 1.e-10).all():
            raise ValueError('Arrays array_a and array_b must both be symmetric for this analysis.')
Ejemplo n.º 5
0
 def __init__(self,
              array_a,
              array_b,
              translate=False,
              scale=False,
              hide_padding=True):
     self.hide_padding = hide_padding
     self.translate = translate
     self.scale = scale
     Procrustes.__init__(self,
                         array_a,
                         array_b,
                         translate=self.translate,
                         scale=self.scale,
                         hide_padding=self.hide_padding)
Ejemplo n.º 6
0
    def test_zero_padding_columns(self):
        """
        This test verifies that zero_padding_array applied to two arrays with a differing number of columns
        returns the two input arrays, where the array with the least number of columns is zero padded so that
        it matches the number of rows of the other array.
        """
        array1 = np.array([[4, 7, 2], [1, 3, 5]])
        array2 = np.array([[5], [2]])
        procrust = Procrustes(array1, array2)
        assert array1.shape == (2, 3)
        assert array2.shape == (2, 1)
        assert procrust.array_a.shape == (2, 3)
        assert procrust.array_b.shape == (2, 1)
        expected = np.array([[5, 0, 0], [2, 0, 0]])
        assert (abs(procrust.array_a - array1) < 1.e-10).all()
        assert (abs(procrust.array_b - array2) < 1.e-10).all()

        # match the number of columns of the 1st array
        padded_array2, padded_array1 = zero_padding(array2,
                                                    array1,
                                                    column=True)
        assert array1.shape == (2, 3)
        assert array2.shape == (2, 1)
        assert padded_array1.shape == (2, 3)
        assert padded_array2.shape == (2, 3)
        assert (abs(padded_array1 - array1) < 1.e-10).all()
        assert (abs(padded_array2 - expected) < 1.e-10).all()

        # match the number of columns of the 1st array
        array3 = np.arange(8).reshape(8, 1)
        array4 = np.arange(8).reshape(2, 4)
        padded_array3, padded_array4 = zero_padding(array3,
                                                    array4,
                                                    row=False,
                                                    column=True)
        assert array3.shape == (8, 1)
        assert array4.shape == (2, 4)
        assert padded_array3.shape == (8, 4)
        assert padded_array4.shape == (2, 4)
        assert (abs(array4 - padded_array4) < 1.e-10).all()
        expected = list(range(8))
        expected.extend([0] * 24)
        expected = np.array(expected).reshape(4, 8).T
        assert (abs(expected - padded_array3) < 1.e-10).all()

        # padding the padded_arrays should not change anything
        padded_array5, padded_array6 = zero_padding(padded_array3,
                                                    padded_array4,
                                                    row=False,
                                                    column=True)
        assert padded_array3.shape == (8, 4)
        assert padded_array4.shape == (2, 4)
        assert padded_array5.shape == (8, 4)
        assert padded_array6.shape == (2, 4)
        assert (abs(padded_array5 - padded_array3) < 1.e-10).all()
        assert (abs(padded_array6 - padded_array4) < 1.e-10).all()
Ejemplo n.º 7
0
 def __init__(self,
              array_a,
              array_b,
              translate=False,
              scale=False,
              preserve_symmetry=False,
              hide_padding=True,
              translate_symmetrically=False):
     self.hide_padding = hide_padding
     self.translate = translate
     self.scale = scale
     self.preserve_symmetry = preserve_symmetry
     self.translate_symmetrically = translate_symmetrically
     Procrustes.__init__(
         self,
         array_a,
         array_b,
         translate=self.translate,
         scale=self.scale,
         preserve_symmetry=self.preserve_symmetry,
         hide_padding=self.hide_padding,
         translate_symmetrically=self.translate_symmetrically)
Ejemplo n.º 8
0
    def test_zero_padding_rows(self):
        """
        This test verifies that zero_padding_array applied to two arrays with a differing number of rows
        returns the two input arrays, where the array with the least number of rows is zero padded so that
        it matches the number of rows of the other array
        """
        array1 = np.array([[1, 2], [3, 4]])
        array2 = np.array([[5, 6]])
        procrust = Procrustes(array1, array2)
        # match the number of rows of the 2nd array (automatically down when initiating the class)
        assert array1.shape == (2, 2)
        assert array2.shape == (1, 2)
        assert procrust.array_a.shape == (2, 2)
        assert procrust.array_b.shape == (2, 2)
        expected = np.array([[5, 6], [0, 0]])
        assert (abs(procrust.array_a - array1) < 1.e-10).all()
        assert (abs(procrust.array_b - expected) < 1.e-10).all()

        # match the number of rows of the 1st array
        padded_array2, padded_array1 = zero_padding(array2, array1, row=True)
        assert array1.shape == (2, 2)
        assert array2.shape == (1, 2)
        assert padded_array1.shape == (2, 2)
        assert padded_array2.shape == (2, 2)
        assert (abs(padded_array1 - array1) < 1.e-10).all()
        assert (abs(padded_array2 - expected) < 1.e-10).all()

        # match the number of rows of the 1st array
        array3 = np.arange(8).reshape(2, 4)
        array4 = np.arange(8).reshape(4, 2)
        padded_array3, padded_array4 = zero_padding(array3, array4, row=True)
        assert array3.shape == (2, 4)
        assert array4.shape == (4, 2)
        assert padded_array3.shape == (4, 4)
        assert padded_array4.shape == (4, 2)
        assert (abs(array4 - padded_array4) < 1.e-10).all()
        expected = list(range(8))
        expected.extend([0] * 8)
        expected = np.array(expected).reshape(4, 4)
        assert (abs(expected - padded_array3) < 1.e-10).all()

        # padding the padded_arrays should not change anything
        padded_array5, padded_array6 = zero_padding(padded_array3,
                                                    padded_array4,
                                                    row=True)
        assert padded_array3.shape == (4, 4)
        assert padded_array4.shape == (4, 2)
        assert padded_array5.shape == (4, 4)
        assert padded_array6.shape == (4, 2)
        assert (abs(padded_array5 - padded_array3) < 1.e-10).all()
        assert (abs(padded_array6 - padded_array4) < 1.e-10).all()