Ejemplo n.º 1
0
 def test_get_coulomb_matrix(self):
     res = get_coulomb_matrix([1, 1], [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]])
     expected_results = numpy.array([[0.5, 1.0], [1.0, 0.5]])
     try:
         numpy.testing.assert_array_almost_equal(res, expected_results)
     except AssertionError as e:
         self.fail(e)
Ejemplo n.º 2
0
 def test_get_coulomb_matrix_alpha(self):
     nums = [1, 1]
     coords = [[0.0, 0.0, 0.0], [0.0, 0.0, .5]]
     res = get_coulomb_matrix(nums, coords, alpha=2)
     expected_results = numpy.array([[0.5, 4.], [4., 0.5]])
     try:
         numpy.testing.assert_array_almost_equal(res, expected_results)
     except AssertionError as e:
         self.fail(e)
Ejemplo n.º 3
0
 def test_get_coulomb_matrix_use_decay(self):
     nums = [1, 1, 1]
     coords = [[0.0, 0.0, 0.0], [0.0, 0.0, .5], [0.0, 0.5, 0.0]]
     res = get_coulomb_matrix(nums, coords, use_decay=True)
     expected_results = numpy.array([[0.5, 1., 1.], [1., 0.5, 0.585786],
                                     [1., 0.585786, 0.5]])
     try:
         numpy.testing.assert_array_almost_equal(res, expected_results)
     except AssertionError as e:
         self.fail(e)
Ejemplo n.º 4
0
 def test_get_coulomb_matrix(self):
     res = get_coulomb_matrix([1, 1], [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]])
     expected_results = numpy.array([
         [0.5, 1.0],
         [1.0, 0.5]])
     try:
         numpy.testing.assert_array_almost_equal(
             res,
             expected_results)
     except AssertionError as e:
         self.fail(e)
Ejemplo n.º 5
0
 def test_get_coulomb_matrix_alpha(self):
     nums = [1, 1]
     coords = [[0.0, 0.0, 0.0], [0.0, 0.0, .5]]
     res = get_coulomb_matrix(nums, coords, alpha=2)
     expected_results = numpy.array([
         [0.5, 4.],
         [4., 0.5]])
     try:
         numpy.testing.assert_array_almost_equal(
             res,
             expected_results)
     except AssertionError as e:
         self.fail(e)
Ejemplo n.º 6
0
 def test_get_coulomb_matrix_use_decay(self):
     nums = [1, 1, 1]
     coords = [[0.0, 0.0, 0.0], [0.0, 0.0, .5], [0.0, 0.5, 0.0]]
     res = get_coulomb_matrix(nums, coords, use_decay=True)
     expected_results = numpy.array([
         [0.5, 1., 1.],
         [1., 0.5, 0.585786],
         [1., 0.585786, 0.5]])
     try:
         numpy.testing.assert_array_almost_equal(
             res,
             expected_results)
     except AssertionError as e:
         self.fail(e)
Ejemplo n.º 7
0
    def _para_transform(self, X):
        """
        A single instance of the transform procedure.

        This is formulated in a way that the transformations can be done
        completely parallel with map.

        Parameters
        ----------
        X : object
            An object to use for the transform

        Returns
        -------
        value : array
            The features extracted from the molecule

        Raises
        ------
        ValueError
            If the transformer has not been fit.

        ValueError
            If the size of the transforming molecules are larger than the fit.
        """
        if self._max_size is None:
            msg = "This %s instance is not fitted yet. Call 'fit' first."
            raise ValueError(msg % type(self).__name__)

        data = self.convert_input(X)
        if len(data.numbers) > self._max_size:
            msg = "The fit molecules (%d) were not as large as the ones that"
            msg += " are being transformed (%d)."
            raise ValueError(msg % (self._max_size, len(data.numbers)))

        padding_difference = self._max_size - len(data.numbers)
        values = get_coulomb_matrix(data.numbers, data.coords)
        if self.sort:
            order = numpy.argsort(values.sum(0))[::-1]
            values = values[order, :][:, order]

        if self.eigen:
            values = numpy.linalg.eig(values)[0]

        values = numpy.pad(values,
                           (0, padding_difference),
                           mode="constant")
        return values