From 83e8dd1ccfa271f273a3b838297ff81fac5d0cd1 Mon Sep 17 00:00:00 2001 From: "Anders S. Christensen" Date: Fri, 2 Mar 2018 15:21:45 +0100 Subject: [PATCH 1/5] Updated FCHL documentation --- docs/source/examples.rst | 136 +++++++++++++++++++++++++++-------- docs/source/qml.rst | 12 ++-- qml/compound.py | 13 ++-- qml/fchl.py | 57 --------------- setup.py | 2 +- tests/test_fchl.py | 152 ++++++++++++++++++++++++++++++++++++++- 6 files changed, 271 insertions(+), 101 deletions(-) diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 32d5fbbce..0a90dd6aa 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -1,4 +1,4 @@ -xamples +Examples -------- Generating representations using the ``Compound`` class @@ -132,12 +132,14 @@ The easiest way to calculate the kernel matrix using an explicit, local represen (3, 7101, 7101) +Note that ``mol.representation`` is just a 1D numpy array. + Generating the SLATM representation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Spectrum of London and Axillrod-Teller-Muto potential (SLATM) representation requires additional input to reduce the size of the representation. -This input (the types of many-body terms) is generate via the ``get_slatm_mbtypes()`` function. The function takes a list of the nuclearges for each molecule in the dataset as input. E.g.: +This input (the types of many-body terms) is generate via the ``get_slatm_mbtypes()`` function. The function takes a list of the nuclear charges for each molecule in the dataset as input. E.g.: .. code:: python @@ -171,59 +173,137 @@ The ``local`` keyword in this example specifies that a local representation is p # Generate one representation rep = generate_slatm(coordinates, nuclear_charges, mbtypes) -Generating the ARAD representation and kernels +Here ``coordinates`` is an Nx3 numpy array, and ``nuclear_charges`` is simply a list of charges. + +Generating the FCHL representation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The ARAD representation does not have an explicit representation in the form of a vector, and the L2-distance must be calculated analytically in a separate kernel function. -The syntax is analogous to the explicit representations (e.g. Coulomb matrix, BoB, SLATM, etc), but is handled by kernels from the separate ``qml.arad`` module. +The FCHL representation does not have an explicit representation in the form of a vector, and the kernel elements must be calculated analytically in a separate kernel function. +The syntax is analogous to the explicit representations (e.g. Coulomb matrix, BoB, SLATM, etc), but is handled by kernels from the separate ``qml.fchl`` module. -.. code:: python +The code below show three ways to create the input representations for the FHCL kernel functions. - from qml.arad import get_local_kernels_arad +First using the ``Compound`` class: - # Assume the QM7 dataset is loaded into a list of Compound() - for compound in qm7: +.. code:: python - # Generate the desired representation for each compound - compound.generate_arad_representation(size=23) + # Assume the dataset is loaded into a list of Compound() + for compound in mols: + + # Generate the desired representation for each compound, cut off in angstrom + compound.generate_fchl_representation(size=23, cut_off=10.0) - # Make Numpy array of the representation - X = np.array([c.representation for c in qm7]) + # Make Numpy array of the representation, which can be parsed to the kernel + X = np.array([c.representation for c in mols]) - # List of kernel-widths - sigmas = [50.0, 100.0, 200.0] + +The dimensions of the array should be ``(number_molecules, size, 5, size)``, where ``size`` is the +size keyword used when generating the representations. + +In addition to using the ``Compound`` class to generate the representations, FCHL representations can also be generated via the ``qml.fchl.generate_fchl_representation()`` function, using similar notation to the functions in the ``qml.representations.*`` functions. + + +.. code:: python + + from qml.fchl import generate_representation + + # Dummy coordinates for a water molecule + coordinates = np.array([[1.464, 0.707, 1.056], + [0.878, 1.218, 0.498], + [2.319, 1.126, 0.952]]) + + # Oxygen, Hydrogen, Hydrogen + nuclear_charges = np.array([8, 1, 1]) + + rep = generate_representation(coordinates, nuclear_charges) + +To create the representation for a crystal, the notation is as follows: + + +.. code:: python + + from qml.fchl import generate_representation + + # Dummy fractional coordinates + fractional_coordinates = np.array( + [[ 0. , 0. , 0. ], + [ 0.75000042, 0.50000027, 0.25000015], + [ 0.15115386, 0.81961403, 0.33154037], + [ 0.51192691, 0.18038651, 0.3315404 ], + [ 0.08154025, 0.31961376, 0.40115401], + [ 0.66846017, 0.81961403, 0.48807366], + [ 0.08154025, 0.68038678, 0.76192703], + [ 0.66846021, 0.18038651, 0.84884672], + [ 0.23807355, 0.31961376, 0.91846033], + [ 0.59884657, 0.68038678, 0.91846033], + [ 0.50000031, 0. , 0.50000031], + [ 0.25000015, 0.50000027, 0.75000042]] + ) + + # Dummy nuclear charges + nuclear_charges = np.array( + [58, 58, 8, 8, 8, 8, 8, 8, 8, 8, 23, 23] + ) + + # Dummy unit cell + unit_cell = np.array( + [[ 3.699168, 3.699168, -3.255938], + [ 3.699168, -3.699168, 3.255938], + [-3.699168, -3.699168, -3.255938]] + ) + + # Generate the representation + rep = generate_representation(fractional_coordinates, nuclear_charges, + cell=unit_cell, neighbors=100, cut_distance=7.0) + + +The neighbors keyword is the max number of atoms with the cutoff-distance + +Generating the FCHL kernel +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following example demonstrates how to calculate the local FCHL kernel elements between FCHL representations. ``X1`` and ``X2`` are numpy arrays with the shape ``(number_compounds,max_size, 5,neighbors)``, as generated in one of the previous examples. You MUST use the same cut-off distance to generate the representation and calculate the kernel. + + +.. code:: python + + from qml.fchl import get_local_kernels + + # You can get kernels for multiple kernel-widths + sigmas = [2.5, 5.0, 10.0] # Calculate the kernel-matrices for each sigma - K = get_local_kernels_arad(X, X, sigmas) + K = get_local_kernels(X1, X2, sigmas, cut_distance=10.0) print(K.shape) -.. code:: - (3, 7101, 7101) +As output you will get a kernel for each kernel-width. -The dimensions of the input should be ``(number_molecules, size, 5, size)``, where ``size`` is the -size keyword used when generating the representations. +.. code:: + + (3, 100, 200) -In addition to using the ``Compound`` class to generate the representations, ARAD representations can also be generated via the ``qml.arad.generate_arad_representation()`` function, using similar notation to the functions in the ``qml.representations.*`` functions. -In case the two datasets used to calculate the kernel matrix are identical -- resulting in a symmetric kernel matrix - it is possible use a faster kernel, -since only half of the kernel elements must be calculated explicitly: +In case ``X1`` and ``X2`` are identical, K will be symmetrical. This is handled by a separate function with exploits this symmetry (thus being twice as fast). .. code:: python + + from qml.fchl import get_local_symmetric_kernels - from qml.arad import get_local_symmetric_kernels_arad + # You can get kernels for multiple kernel-widths + sigmas = [2.5, 5.0, 10.0] # Calculate the kernel-matrices for each sigma - K = get_local_symmetric_kernels_arad(X, sigmas) + K = get_local_kernels(X1, sigmas, cut_distance=10.0) print(K.shape) + .. code:: - (3, 7101, 7101) + (3, 100, 100) -In addition to the local kernel, the ARAD module also provides kernels for atomic properties (e.g. chemical shifts, partial charges, etc). These have the name "atomic", rather than "local". +In addition to the local kernel, the FCHL module also provides kernels for atomic properties (e.g. chemical shifts, partial charges, etc). These have the name "atomic", rather than "local". .. code:: python diff --git a/docs/source/qml.rst b/docs/source/qml.rst index 28eb6d94d..f89e239ff 100644 --- a/docs/source/qml.rst +++ b/docs/source/qml.rst @@ -45,12 +45,12 @@ qml\.Compound class :undoc-members: :show-inheritance: -qml\.arad module ----------------- - -.. automodule:: qml.arad - :members: - :show-inheritance: +.. qml\.arad module +.. ---------------- +.. +.. .. automodule:: qml.arad +.. :members: +.. :show-inheritance: qml\.fchl module ---------------- diff --git a/qml/compound.py b/qml/compound.py index 47eabfc93..b7568a638 100644 --- a/qml/compound.py +++ b/qml/compound.py @@ -33,7 +33,7 @@ from .representations import generate_eigenvalue_coulomb_matrix from .representations import generate_slatm -from .arad import generate_arad_representation +from .fchl import generate_representation as generate_fchl_representation class Compound(object): """ The ``Compound`` class is used to store data from @@ -245,16 +245,15 @@ def generate_bob(self, size=23, asize = {"O":3, "C":7, "N":3, "H":16, "S":1}): self.representation = generate_bob(self.nuclear_charges, self.coordinates, self.atomtypes, asize = asize) - def generate_arad_representation(self, size = 23): - """Generates the representation for the ARAD-kernel. Note that this representation is incompatible with generic ``qml.kernel.*`` kernels. + def generate_fchl_representation(self, max_size = 23, cell=None, neighbors=24,cut_distance=5.0): + """Generates the representation for the FCHL-kernel. Note that this representation is incompatible with generic ``qml.kernel.*`` kernels. :param size: Max number of atoms in representation. :type size: integer """ - self.representation = generate_arad_representation(self.coordinates, - self.nuclear_charges, size=size) + self.representation = generate_fchl_representation(self.coordinates, + self.nuclear_charges, max_size=max_size, cell=cell, neighbors=neighbors,cut_distance=cut_distance) - assert (self.representation).shape[0] == size, "ERROR: Check ARAD descriptor size!" - assert (self.representation).shape[2] == size, "ERROR: Check ARAD descriptor size!" + assert (self.representation).shape[0] == max_size, "ERROR: Check FCHL descriptor size!" def generate_slatm(self, mbtypes, local=False, sigmas=[0.05,0.05], dgrids=[0.03,0.03], rcut=4.8, pbc='000', diff --git a/qml/fchl.py b/qml/fchl.py index b76a72d20..7c1c3f18c 100644 --- a/qml/fchl.py +++ b/qml/fchl.py @@ -101,63 +101,6 @@ def generate_representation(coordinates, nuclear_charges, return M -def dummy_fchl(A, B, sigmas, - two_body_scaling=np.sqrt(8), three_body_scaling=1.6, - two_body_width=0.2, three_body_width=np.pi, - two_body_power=4.0, three_body_power=2.0, - cut_start=1.0, cut_distance=5.0, - fourier_order=1, alchemy="periodic-table", - alchemy_period_width=1.6, alchemy_group_width=1.6): - """ Calculates the Gaussian kernel matrix K, where :math:`K_{ij}`: - - :math:`K_{ij} = \\exp \\big( -\\frac{\\|A_i - B_j\\|_2^2}{2\sigma^2} \\big)` - - Where :math:`A_{i}` and :math:`B_{j}` are FCHL representations. - K is calculated analytically using an OpenMP parallel Fortran routine. - Note, that this kernel will ONLY work with FCHL representations as input. - - :param A: Array of FCHL representation - shape=(N, maxsize, 5, maxneighbors). - :type A: numpy array - :param B: Array of FCHL representation - shape=(M, maxsize, 5, maxneighbors). - :type B: numpy array - :param sigma: List of kernel-widths. - :type sigma: list - - :param two_body_scaling: Weight for 2-body terms. - :type two_body_scaling: float - :param three_body_scaling: Weight for 3-body terms. - :type three_body_scaling: float - - :param two_body_width: Gaussian width for 2-body terms - :type two_body_width: float - :param three_body_width: Gaussian width for 3-body terms. - :type three_body_width: float - - :param two_body_power: Powerlaw for :math:`r^{-n}` 2-body terms. - :type two_body_power: float - :param three_body_power: Powerlaw for Axilrod-Teller-Muto 3-body term - :type three_body_power: float - - :param cut_start: The fraction of the cut-off radius at which cut-off damping start. - :type cut_start: float - :param cut_distance: Cut-off radius. (default=5 angstrom) - :type cut_distance: float - - :param fourier_order: 3-body Fourier-expansion truncation order. - :type fourier_order: integer - :param alchemy: Type of alchemical interpolation ``"periodic-table"`` or ``"off"`` are possible options. Disabling alchemical interpolation can yield dramatic speedups. - :type alchemy: string - - :param alchemy_period_width: Gaussian width along periods (columns) in the periodic table. - :type alchemy_period_width: float - :param alchemy_group_width: Gaussian width along groups (rows) in the periodic table. - :type alchemy_group_width: float - - :return: Array of FCHL kernel matrices matrix - shape=(n_sigmas, N, M), - :rtype: numpy array - """ - - def get_local_kernels(A, B, sigmas, \ two_body_scaling=np.sqrt(8), three_body_scaling=1.6, two_body_width=0.2, three_body_width=np.pi, diff --git a/setup.py b/setup.py index 0b4eb9670..9ffdeaefd 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ __copyright__ = "Copyright 2016" __credits__ = ["Anders S. Christensen et al. (2016) https://github.com/qmlcode/qml"] __license__ = "MIT" -__version__ = "0.4.0" +__version__ = "0.4.0.10" __maintainer__ = "Anders S. Christensen" __email__ = "andersbiceps@gmail.com" __status__ = "Beta" diff --git a/tests/test_fchl.py b/tests/test_fchl.py index 3c6480e9d..32bd0e1e2 100644 --- a/tests/test_fchl.py +++ b/tests/test_fchl.py @@ -72,8 +72,7 @@ def test_krr_fchl_local(): mol.properties = data[xyz_file] # This is a Molecular Coulomb matrix sorted by row norm - mol.representation = generate_representation(mol.coordinates, \ - mol.nuclear_charges, cut_distance=1e6) + mol.generate_fchl_representation(cut_distance=1e6) mols.append(mol) # Shuffle molecules @@ -234,9 +233,158 @@ def test_krr_fchl_atomic(): assert np.allclose(K, K_test), "Error in FCHL atomic kernels" +def test_fchl_local_periodic(): + + nuclear_charges = [ + np.array([13, 13, 58, 58, 58, 58, 58, 58, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 23, 23]), + np.array([34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 73, 73, 73, 73, 81, 81, 81, 81]), + np.array([48, 8, 8, 8, 8, 8, 8, 51, 51]), + np.array([16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]), + np.array([58, 58, 8, 8, 8, 8, 8, 8, 8, 8, 23, 23])] + + cells = np.array([ +[[ 1.01113290e+01, -1.85000000e-04, 0.00000000e+00], + [ -5.05582400e+00, 8.75745400e+00, 0.00000000e+00], + [ 0.00000000e+00, 0.00000000e+00, 6.15100100e+00]], +[[ 9.672168, 0. , 0. ], + [ 0. , 3.643786, 0. ], + [ 0. , 0. , 14.961818]], +[[ 5.28208000e+00, -1.20000000e-05, 1.50000000e-05], + [ -2.64105000e+00, 4.57443400e+00, -3.00000000e-05], + [ 1.40000000e-05, -2.40000000e-05, 4.77522000e+00]], +[[ -1.917912, 3.321921, 0. ], + [ 3.835824, 0. , 0. ], + [ 1.917912, -1.107307, -56.423542]], +[[ 3.699168, 3.699168, -3.255938], + [ 3.699168, -3.699168, 3.255938], + [-3.699168, -3.699168, -3.255938]]]) + + fractional_coordinates = [ +[[ 0.6666706 , 0.33333356, 0.15253127], + [ 0.33332896, 0.66666655, 0.65253119], + [ 0.14802736, 0.375795 , 0.23063888], + [ 0.62422269, 0.77225019, 0.23063888], + [ 0.22775607, 0.85196133, 0.23063888], + [ 0.77224448, 0.14803879, 0.7306388 ], + [ 0.37577687, 0.22774993, 0.7306388 ], + [ 0.8519722 , 0.62420512, 0.7306388 ], + [ 0.57731818, 0.47954083, 0.0102715 ], + [ 0.52043884, 0.09777799, 0.01028288], + [ 0.90211803, 0.4226259 , 0.01032677], + [ 0.33335216, 0.6666734 , 0.01482035], + [ 0.90959766, 0.77585201, 0.30637615], + [ 0.86626106, 0.09040873, 0.3063794 ], + [ 0.22415808, 0.13374794, 0.30638265], + [ 0.42268138, 0.52045928, 0.51027142], + [ 0.47956114, 0.90222098, 0.5102828 ], + [ 0.09788153, 0.57737421, 0.51032669], + [ 0.6666474 , 0.33332671, 0.51482027], + [ 0.09040133, 0.22414696, 0.80637769], + [ 0.13373793, 0.90959025, 0.80637932], + [ 0.77584247, 0.86625217, 0.80638257], + [ 0. , 0. , 0.05471142], + [ 0. , 0. , 0.55471134]], +[[ 0.81615001, 0.75000014, 0.00116296], + [ 0.52728096, 0.25000096, 0.0993275 ], + [ 0.24582596, 0.75000014, 0.2198563 ], + [ 0.74582658, 0.75000014, 0.28014376], + [ 0.02728137, 0.25000096, 0.40067257], + [ 0.31615042, 0.75000014, 0.49883711], + [ 0.68384978, 0.25000096, 0.50116236], + [ 0.97271884, 0.75000014, 0.59932757], + [ 0.25417362, 0.25000096, 0.71985637], + [ 0.75417321, 0.25000096, 0.78014383], + [ 0.47271925, 0.75000014, 0.90067263], + [ 0.1838502 , 0.25000096, 0.99883717], + [ 0.33804831, 0.75000014, 0.07120258], + [ 0.83804789, 0.75000014, 0.42879749], + [ 0.16195232, 0.25000096, 0.57120198], + [ 0.6619519 , 0.25000096, 0.92879756], + [ 0.98245812, 0.25000096, 0.17113829], + [ 0.48245853, 0.25000096, 0.32886177], + [ 0.51754167, 0.75000014, 0.67113836], + [ 0.01754209, 0.75000014, 0.82886184]], +[[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], + [ 3.66334233e-01, 1.96300000e-07, 2.70922493e-01], + [ 6.33665197e-01, 6.33666177e-01, 2.70923540e-01], + [ 3.62000000e-08, 3.66333081e-01, 2.70923851e-01], + [ 6.70000000e-09, 6.33664733e-01, 7.29076149e-01], + [ 6.33664135e-01, 9.99998055e-01, 7.29076460e-01], + [ 3.66336157e-01, 3.66334260e-01, 7.29077507e-01], + [ 3.33333635e-01, 6.66667395e-01, 4.99998953e-01], + [ 6.66667720e-01, 3.33333042e-01, 5.00000000e-01]], +[[ 0.3379644 , 0.66203644, 0.01389048], + [ 0.02316309, 0.97683587, 0.06948926], + [ 0.70833843, 0.29165976, 0.12501892], + [ 0.39352259, 0.60647824, 0.18056506], + [ 0.74538243, 0.25461577, 0.2361509 ], + [ 0.09722803, 0.90277092, 0.2916841 ], + [ 0.44907919, 0.55092165, 0.34723485], + [ 0.8009281 , 0.1990701 , 0.4027879 ], + [ 0.15278103, 0.84721793, 0.45834308], + [ 0.83797345, 0.16202475, 0.51392396], + [ 0.52315813, 0.4768427 , 0.56947169], + [ 0.20833916, 0.7916598 , 0.62501748], + [ 0.89352691, 0.10647128, 0.68058436], + [ 0.57870427, 0.42129656, 0.73611012], + [ 0.93056329, 0.06943491, 0.79169347], + [ 0.28241704, 0.71758191, 0.84725114], + [ 0.63426956, 0.36573128, 0.90280596], + [ 0.98611817, 0.01388002, 0.95835813], + [ 0. , 0. , 0. ], + [ 0.35185434, 0.64814649, 0.05556032], + [ 0.03704151, 0.96295744, 0.11112454], + [ 0.72221887, 0.27777932, 0.16666022], + [ 0.40741437, 0.59258647, 0.22224039], + [ 0.75926009, 0.24073811, 0.27778387], + [ 0.11111195, 0.888887 , 0.33333586], + [ 0.46296234, 0.53703849, 0.38888431], + [ 0.81480954, 0.18518866, 0.44443222], + [ 0.16667233, 0.83332662, 0.500017 ], + [ 0.85185117, 0.14814703, 0.55555711], + [ 0.53704217, 0.46295866, 0.61112381], + [ 0.22222196, 0.777777 , 0.66666587], + [ 0.90740847, 0.09258972, 0.72222903], + [ 0.59259328, 0.40740756, 0.77777712], + [ 0.94444213, 0.05555607, 0.83333 ], + [ 0.29630132, 0.70369764, 0.88890396], + [ 0.64815247, 0.35184836, 0.94445471]], +[[ 0. , 0. , 0. ], + [ 0.75000042, 0.50000027, 0.25000015], + [ 0.15115386, 0.81961403, 0.33154037], + [ 0.51192691, 0.18038651, 0.3315404 ], + [ 0.08154025, 0.31961376, 0.40115401], + [ 0.66846017, 0.81961403, 0.48807366], + [ 0.08154025, 0.68038678, 0.76192703], + [ 0.66846021, 0.18038651, 0.84884672], + [ 0.23807355, 0.31961376, 0.91846033], + [ 0.59884657, 0.68038678, 0.91846033], + [ 0.50000031, 0. , 0.50000031], + [ 0.25000015, 0.50000027, 0.75000042]]] + + n = 5 + + X = np.array([generate_representation(fractional_coordinates[i], nuclear_charges[i], + cell=cells[i], max_size=36, neighbors=200, cut_distance=7.0) for i in range(5)]) + + + sigmas = [2.5] + K = get_local_symmetric_kernels(X, sigmas, cut_distance=7.0, cut_start=0.7) + + K_ref = np.array( + [[ 530.03184304, 435.65196293, 198.61245535, 782.49428327, 263.53562172], + [ 435.65196293, 371.35281119, 163.83766549, 643.99777576, 215.04338938], + [ 198.61245535, 163.83766549, 76.12134823, 295.02739281, 99.89595704], + [ 782.49428327, 643.99777576, 295.02739281, 1199.61736141, 389.31169487], + [ 263.53562172, 215.04338938, 99.89595704, 389.31169487, 133.36920188]] + ) + + assert np.allclose(K, K_ref), "Error in periodic FCHL" + if __name__ == "__main__": test_krr_fchl_local() test_krr_fchl_global() test_krr_fchl_atomic() + test_fchl_local_periodic() From a417f6a333be212018af538f2ccd31bcbd4e539f Mon Sep 17 00:00:00 2001 From: "Anders S. Christensen" Date: Fri, 2 Mar 2018 15:23:52 +0100 Subject: [PATCH 2/5] Fixed arad-> fchl in docs --- docs/source/examples.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 0a90dd6aa..78efd5017 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -307,8 +307,8 @@ In addition to the local kernel, the FCHL module also provides kernels for atomi .. code:: python - from qml.arad import get_atomic_kernels_arad - from qml.arad import get_atomic_symmetric_kernels_arad + from qml.fchl import get_atomic_kernels + from qml.fchl import get_atomic_symmetric_kernels The only difference between the local and atomic kernels is the shape of the input. Since the atomic kernel outputs kernels with atomic resolution, the atomic input has the shape ``(number_atoms, 5, size)``. From 7d4b0c98be50e7085e90f49c3f19fb46150e76e4 Mon Sep 17 00:00:00 2001 From: "Anders S. Christensen" Date: Fri, 2 Mar 2018 15:30:27 +0100 Subject: [PATCH 3/5] removed deprecated arad test from test_wrappers --- tests/test_wrappers.py | 95 +++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py index ab1683769..5047c6c83 100644 --- a/tests/test_wrappers.py +++ b/tests/test_wrappers.py @@ -25,53 +25,54 @@ def get_energies(filename): return energies -def test_arad_wrapper(): - - test_dir = os.path.dirname(os.path.realpath(__file__)) - - # Parse file containing PBE0/def2-TZVP heats of formation and xyz filenames - data = get_energies("%s/data/hof_qm7.txt" % test_dir) - - # Generate a list of qml.Compound() objects - mols = [] - - for xyz_file in sorted(data.keys())[:50]: - - # Initialize the qml.Compound() objects - mol = qml.Compound(xyz="%s/qm7/" % test_dir + xyz_file) - - # Associate a property (heat of formation) with the object - mol.properties = data[xyz_file] - - # This is a Molecular Coulomb matrix sorted by row norm - mol.generate_arad_representation(size=23) - - mols.append(mol) - - - # Shuffle molecules - np.random.seed(666) - np.random.shuffle(mols) - - # Make training and test sets - n_test = 10 - n_train = 40 - - training = mols[:n_train] - test = mols[-n_test:] - - sigmas = [10.0, 100.0] - - - K1 = arad_local_symmetric_kernels(training, sigmas) - assert np.all(K1 > 0.0), "ERROR: ARAD symmetric kernel negative" - assert np.invert(np.all(np.isnan(K1))), "ERROR: ARAD symmetric kernel contains NaN" - - - K2 = arad_local_kernels(training, test, sigmas) - assert np.all(K2 > 0.0), "ERROR: ARAD symmetric kernel negative" - assert np.invert(np.all(np.isnan(K2))), "ERROR: ARAD symmetric kernel contains NaN" +# def test_arad_wrapper(): +# +# test_dir = os.path.dirname(os.path.realpath(__file__)) +# +# # Parse file containing PBE0/def2-TZVP heats of formation and xyz filenames +# data = get_energies("%s/data/hof_qm7.txt" % test_dir) +# +# # Generate a list of qml.Compound() objects +# mols = [] +# +# for xyz_file in sorted(data.keys())[:50]: +# +# # Initialize the qml.Compound() objects +# mol = qml.Compound(xyz="%s/qm7/" % test_dir + xyz_file) +# +# # Associate a property (heat of formation) with the object +# mol.properties = data[xyz_file] +# +# # This is a Molecular Coulomb matrix sorted by row norm +# mol.generate_arad_representation(size=23) +# +# mols.append(mol) +# +# +# # Shuffle molecules +# np.random.seed(666) +# np.random.shuffle(mols) +# +# # Make training and test sets +# n_test = 10 +# n_train = 40 +# +# training = mols[:n_train] +# test = mols[-n_test:] +# +# sigmas = [10.0, 100.0] +# +# +# K1 = arad_local_symmetric_kernels(training, sigmas) +# assert np.all(K1 > 0.0), "ERROR: ARAD symmetric kernel negative" +# assert np.invert(np.all(np.isnan(K1))), "ERROR: ARAD symmetric kernel contains NaN" +# +# +# K2 = arad_local_kernels(training, test, sigmas) +# assert np.all(K2 > 0.0), "ERROR: ARAD symmetric kernel negative" +# assert np.invert(np.all(np.isnan(K2))), "ERROR: ARAD symmetric kernel contains NaN" if __name__ == "__main__": - test_arad_wrapper() + pass + # test_arad_wrapper() From 4c6dc655a4f6bca529d7bd79d6e3c3e6aa20771f Mon Sep 17 00:00:00 2001 From: "Anders S. Christensen" Date: Fri, 2 Mar 2018 15:32:33 +0100 Subject: [PATCH 4/5] Updated travis yml to publish docs properly --- .travis.yml | 80 +++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index 843efb074..0880d5546 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,12 @@ language: python + sudo: required dist: trusty + group: edge + deploy: -# matrix: -# - provider: pypi -# user: andersx -# on: -# branch: master -# condition: ${TRAVIS_PYTHON_VERSION} = "2.7" -# password: -# secure: OhTw5j/R9a2kZ/jkz6ZXcQcLoqq/Z5sslQ5j+OxnssyZUfgeeqNyWj8T74aVoRtrWVz20i756opLd8cgGcKOYesXAjNFJHmymABnQQnYrpBBk8NSyfaJ8CnNHiGhJCAFRp9x+Jbb+9BpDswg2UBQPj5b4krOZVcT53JIM5qEGDo3bpOCgy5VlMtSCKOjyUxYwgcHTGDnpDNSa2QwIcMcT1R0cyEMZ/AOKAwbkh99s6x/bwi2PYutfdxIwnuWMSAPzvbKJfb82xQzkGf4+JS/elr583zT0QyXP3BRvWyHfLh/K+fUGSc805Ay/GIE2ZHKUHiuHo/DunmbjlxHrBuJWXpuyMHJwiRLngo80OY/5dMnVLiz84MfxdrSzNsZoV9/fPM1W6OSsuX75axUjYyZsf23hmVHKUJNmMa8wGp/KYo6i/ZoVwKDmKB1Ap0Qr7Qigwn/N7DYg2oSi9ypdtgkFnBGhovXtbCNqSUM5hTBxc+jl1xlxZMvPjxagbyut9F+5JjI/PO+zva0uL9jjKgsMeOarQfsETfxfC8x4oZ0+Pe/5lLeBlVkqepCvtBpBEyZnHYvD7G4LFLbNpxTAL84BjwA5C1C4gTQVbEs8tw02rN7Ro91+0Qh1cSY4L3qFuCZdvWfBTxWT2NvpuxSlM+ywO8S8c9tInGdtGEPyu9RvfI= -- provider: pages + provider: pages local_dir: ${TRAVIS_BUILD_DIR}/docs/build/html skip_cleanup: true repo: qmlcode/qmlcode.github.io @@ -20,40 +15,47 @@ deploy: on: branch: master condition: ${TRAVIS_PYTHON_VERSION} = "2.7" + python: -- '2.7' -- '3.5' -- '3.6' + - "2.7" + - "3.5" + - "3.6" + before_install: -- sudo apt-get update -qq + - sudo apt-get update -qq + install: -- sudo apt-get install -qq gcc gfortran libblas-dev liblapack-dev -- sudo apt-get install -qq gcc-4.8 gfortran-4.8 -- | - if [ ${TRAVIS_PYTHON_VERSION:0:1} = 3 ]; then - sudo apt-get install python3-numpy - pip3 install scipy - python3 setup.py build - python3 setup.py install - pip3 install sphinx - pip3 install sphinx-rtd-theme - cd ${TRAVIS_BUILD_DIR}/docs - make html - elif [ ${TRAVIS_PYTHON_VERSION} = "2.7" ]; then - sudo apt-get install python-numpy - pip2 install scipy - python2 setup.py build - python2 setup.py install - pip2 install sphinx - pip2 install sphinx-rtd-theme - cd ${TRAVIS_BUILD_DIR}/docs - make html - else - echo "ERROR: Unknown Python version." - fi + - sudo apt-get install -qq gcc gfortran libblas-dev liblapack-dev + - sudo apt-get install -qq gcc-4.8 gfortran-4.8 + - | + if [ ${TRAVIS_PYTHON_VERSION:0:1} = 3 ]; then + sudo apt-get install python3-numpy + pip3 install scipy + python3 setup.py build + python3 setup.py install + pip3 install sphinx + pip3 install sphinx-rtd-theme + cd ${TRAVIS_BUILD_DIR}/docs + make html + elif [ ${TRAVIS_PYTHON_VERSION} = "2.7" ]; then + sudo apt-get install python-numpy + pip2 install scipy + python2 setup.py build + python2 setup.py install + pip2 install sphinx + pip2 install sphinx-rtd-theme + cd ${TRAVIS_BUILD_DIR}/docs + make html + else + echo "ERROR: Unknown Python version." + fi + + before_script: -- cd ${TRAVIS_BUILD_DIR}/tests/ + - cd ${TRAVIS_BUILD_DIR}/tests/ + script: -- nosetests -v + - nosetests -v + notifications: email: false From e0a58b086713e33e91f2713fd40ace480e8c5c61 Mon Sep 17 00:00:00 2001 From: "Anders S. Christensen" Date: Fri, 2 Mar 2018 15:46:05 +0100 Subject: [PATCH 5/5] Updated increment version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9ffdeaefd..4a87f28dd 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ __copyright__ = "Copyright 2016" __credits__ = ["Anders S. Christensen et al. (2016) https://github.com/qmlcode/qml"] __license__ = "MIT" -__version__ = "0.4.0.10" +__version__ = "0.4.0.11" __maintainer__ = "Anders S. Christensen" __email__ = "andersbiceps@gmail.com" __status__ = "Beta"