From 0d2c6dc1aed23e888df18a9c58464db1150eff4b Mon Sep 17 00:00:00 2001 From: mamunm Date: Tue, 7 Aug 2018 14:10:56 -0700 Subject: [PATCH 01/11] pawprint modified. --- catkit/pawprint/online_learning.py | 23 +++++++++ catkit/pawprint/operations.py | 67 ++++++++++++++++++++++++- catkit/pawprint/tests/test_generator.py | 16 +++++- 3 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 catkit/pawprint/online_learning.py diff --git a/catkit/pawprint/online_learning.py b/catkit/pawprint/online_learning.py new file mode 100644 index 00000000..5f2e2199 --- /dev/null +++ b/catkit/pawprint/online_learning.py @@ -0,0 +1,23 @@ +import numpy as np +import matplotlib.pyplot as plt +import sklearn.gaussian_process as gp + + +class OnlineLeaener(): + """ online_learner + + A class for incremental gaussian process learning. This will + learn from the available labelled data and from the computed + acquisition function it will output the point that needs to + be evaluated next. Based on the chosen acquisition function, + it will foucs on exploration and exploitation of the machine + learning space. + + """ + + def __init__(self, + kernel=None, + n_batches=10, + batch_policy='equal_spacing', + acquisition_function='prob_improv', + ) diff --git a/catkit/pawprint/operations.py b/catkit/pawprint/operations.py index d3534788..d74245ee 100644 --- a/catkit/pawprint/operations.py +++ b/catkit/pawprint/operations.py @@ -44,7 +44,6 @@ def bonding_convolution( """Perform convolution of metal atoms with bonded adsorbates.""" # This is a CatKit convention bond_index = np.where(atoms.get_tags() == -1)[0] - V = np.dot(atoms_parameters, connectivity)[:, bond_index] P = np.dot(V, atoms_parameters[:, bond_index].T).diagonal() convolution = P / connectivity[bond_index].sum() @@ -66,3 +65,69 @@ def autocorrelation( AC = np.dot(np.dot(atoms_parameters, S), atoms_parameters.T).diagonal() return AC + + +def layered_sum( + atoms=None, + atoms_parameters=None, + connectivity=None): + """Sum of the properties in a layer as indicated by catkit tags.""" + tags = atoms.get_tags() + tags -= min(tags) + LS = np.array([np.bincount(tags, weights=ap) for ap in atoms_parameters]) + LS = LS[LS != 0] + + return LS + + +def local_ads_metal_fp( + atoms=None, + atoms_parameters=None, + connectivity=None, + fuse=False): + """Sum of the properties of the atoms in the metal-adsorbate interface""" + bond_index = np.where(atoms.get_tags() == -1)[0] + ads_parameters = atoms_parameters[:, bond_index] + fp = np.empty([len(atoms_parameters), len(bond_index)]) + for i, bi in enumerate(bond_index): + bonded_ap = atoms_parameters[:, np.where(connectivity[bi] == 1)[0]] + fp[:, i] = np.mean(bonded_ap - + ads_parameters[:, i].reshape(-1, 1), axis=1) + if not fuse: + return fp.reshape(-1) + else: + return fp.sum(axis=1) + + +def derived_fp( + atoms=None, + atoms_parameters=None, + connectivity=None, + fp_1=None, + fp_2=None, + n_1=None, + n_2=None, + op=None): + """ + NOTE : This is a work in progress. I'll redesign the whole thing to allow + for arithmetic manipulation of two fingerprints. + Given two fingerprints vector, it will perform arithmetic operation to + design new fingerprints. + + Availabel operations: + add : adds two fingerprints of equal length raised to their given + power. + subtract : subtracts two fingerprints of equal length raised to + their given power. + mulltiply : multiply two fingerprints of equal length raised to + their given power. + divide : divide two fingerprints of equal length raised to their + given power.""" + if op == 'add': + return fp_1 ** n_1 + fp_2 ** n_2 + elif op == 'subtract': + return fp_1 ** n_1 - fp_2 ** n_2 + elif op == 'divide': + return fp_1 ** n_1 / fp_2 ** n_2 + elif op == 'multiply': + return fp_1 ** n_1 * fp_2 ** n_2 diff --git a/catkit/pawprint/tests/test_generator.py b/catkit/pawprint/tests/test_generator.py index 4942c5eb..64f4a525 100644 --- a/catkit/pawprint/tests/test_generator.py +++ b/catkit/pawprint/tests/test_generator.py @@ -61,14 +61,26 @@ def test_local_fingerprinting(self): ] operations = [ - 'bonding_convolution' + 'bonding_convolution', + 'layered_sum', + 'local_ads_metal_fp' ] fp = Fingerprinter(atoms) fingerprints = fp.get_fp(parameters, operations) truth = np.array([276.0, 1.2467000000000001, 17406300.0, - 1.0147, np.nan, np.nan, 140.0, 10.0]) + 1.0147, np.nan, np.nan, 140.0, 10.0, + 6.0000e+00, 1.8400e+02, 1.8400e+02, 1.8400e+02, + 9.1000e-01, 5.4800e+00, 5.4800e+00, 5.4800e+00, + 5.1000e+03, 1.3652e+04, 1.3652e+04, 1.3652e+04, + 7.3000e-01, 5.5600e+00, 5.5600e+00, 5.5600e+00, + np.nan, 1.4896e+03, 1.4896e+03, 1.4896e+03, + np.nan, 6.8960e+01, 6.8960e+01, 6.8960e+01, + 1.4000e+01, 4.0000e+01, 4.0000e+01, 4.0000e+01, + 2.0000e+00, 2.0000e+01, 2.0000e+01, 2.0000e+01, + 4.0000e+01, 4.6000e-01,-1.6870e+03, 6.6000e-01, + np.nan, np.nan,-4.0000e+00, 3.0000e+00]) np.testing.assert_allclose(fingerprints[0], truth) From bddec56f68179b1960e4216a6c9ab9daa13560bf Mon Sep 17 00:00:00 2001 From: mamunm Date: Wed, 8 Aug 2018 16:40:39 -0700 Subject: [PATCH 02/11] Modified generators and operations to allow individual properties for individual fp types. --- catkit/pawprint/generator.py | 10 ++++++++-- catkit/pawprint/operations.py | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/catkit/pawprint/generator.py b/catkit/pawprint/generator.py index b3efb5b3..aed1c72e 100644 --- a/catkit/pawprint/generator.py +++ b/catkit/pawprint/generator.py @@ -70,7 +70,7 @@ def _get_atoms_parameters(self, atoms, parameters): return atoms_parameters - def get_fp(self, parameters, operation_list): + def get_fp(self, parameters_list, operation_list): """Return the fingerprints for a list of images of single atoms object for the given parameters. @@ -90,7 +90,6 @@ def get_fp(self, parameters, operation_list): """ fingerprints = [[] for _ in self._images] for i, atoms in enumerate(self._images): - atoms_parameters = self._get_atoms_parameters(atoms, parameters) method = None if np.all(atoms.pbc): @@ -108,6 +107,13 @@ def get_fp(self, parameters, operation_list): if isinstance(operation, str): operation = getattr(operations, operation) + + if all(isinstance(pl, list) for pl in parameters_list): + atoms_parameters = self._get_atoms_parameters(atoms, + parameters_list[j]) + else: + atoms_parameters = self._get_atoms_parameters(atoms, + parameters_list) fingerprint = _generate_fingerprint( operation, diff --git a/catkit/pawprint/operations.py b/catkit/pawprint/operations.py index d74245ee..40c4d1b2 100644 --- a/catkit/pawprint/operations.py +++ b/catkit/pawprint/operations.py @@ -85,14 +85,14 @@ def local_ads_metal_fp( atoms_parameters=None, connectivity=None, fuse=False): - """Sum of the properties of the atoms in the metal-adsorbate interface""" + """Sum of the differences in properties of the atoms in the + metal-adsorbate interface""" bond_index = np.where(atoms.get_tags() == -1)[0] - ads_parameters = atoms_parameters[:, bond_index] fp = np.empty([len(atoms_parameters), len(bond_index)]) for i, bi in enumerate(bond_index): bonded_ap = atoms_parameters[:, np.where(connectivity[bi] == 1)[0]] fp[:, i] = np.mean(bonded_ap - - ads_parameters[:, i].reshape(-1, 1), axis=1) + atoms_parameters[:, bi].reshape(-1, 1), axis=1) if not fuse: return fp.reshape(-1) else: From f8210ec9125e39f05e2943776f7b0040ff4b96ee Mon Sep 17 00:00:00 2001 From: mamunm Date: Fri, 24 Aug 2018 20:43:46 -0700 Subject: [PATCH 03/11] pawprint stuffs. --- catkit/pawprint/tests/test_generator.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/catkit/pawprint/tests/test_generator.py b/catkit/pawprint/tests/test_generator.py index 64f4a525..94546164 100644 --- a/catkit/pawprint/tests/test_generator.py +++ b/catkit/pawprint/tests/test_generator.py @@ -71,13 +71,13 @@ def test_local_fingerprinting(self): truth = np.array([276.0, 1.2467000000000001, 17406300.0, 1.0147, np.nan, np.nan, 140.0, 10.0, - 6.0000e+00, 1.8400e+02, 1.8400e+02, 1.8400e+02, - 9.1000e-01, 5.4800e+00, 5.4800e+00, 5.4800e+00, - 5.1000e+03, 1.3652e+04, 1.3652e+04, 1.3652e+04, - 7.3000e-01, 5.5600e+00, 5.5600e+00, 5.5600e+00, + 6.0000e+00, 1.8400e+02, 1.8400e+02, 1.8400e+02, + 9.1000e-01, 5.4800e+00, 5.4800e+00, 5.4800e+00, + 5.1000e+03, 1.3652e+04, 1.3652e+04, 1.3652e+04, + 7.3000e-01, 5.5600e+00, 5.5600e+00, 5.5600e+00, np.nan, 1.4896e+03, 1.4896e+03, 1.4896e+03, - np.nan, 6.8960e+01, 6.8960e+01, 6.8960e+01, - 1.4000e+01, 4.0000e+01, 4.0000e+01, 4.0000e+01, + np.nan, 6.8960e+01, 6.8960e+01, 6.8960e+01, + 1.4000e+01, 4.0000e+01, 4.0000e+01, 4.0000e+01, 2.0000e+00, 2.0000e+01, 2.0000e+01, 2.0000e+01, 4.0000e+01, 4.6000e-01,-1.6870e+03, 6.6000e-01, np.nan, np.nan,-4.0000e+00, 3.0000e+00]) From a2d4e538a889112fc598bf146c8d8441151ccd47 Mon Sep 17 00:00:00 2001 From: mamunm Date: Wed, 29 Aug 2018 23:13:47 -0700 Subject: [PATCH 04/11] new pawprint pull request --- .idea/CatKit.iml | 11 +++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 139 +++++++++++++++++++++++++++++ catkit/gratoms.py | 17 ++++ catkit/pawprint/generator.py | 6 +- catkit/pawprint/online_learning.py | 23 ----- catkit/pawprint/operations.py | 20 ++--- 9 files changed, 198 insertions(+), 36 deletions(-) create mode 100644 .idea/CatKit.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml delete mode 100644 catkit/pawprint/online_learning.py diff --git a/.idea/CatKit.iml b/.idea/CatKit.iml new file mode 100644 index 00000000..67116063 --- /dev/null +++ b/.idea/CatKit.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..0ed3b438 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..1c9f231a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..a5ebc0ba --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - 1535336124201 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From dbe684ae5f4214a12986c09dd306210fe57b553e Mon Sep 17 00:00:00 2001 From: mamunm Date: Tue, 25 Sep 2018 14:05:25 -0700 Subject: [PATCH 10/11] Changed db.py to allow metadata storing and retrieval. --- catkit/db.py | 175 ++++++++++++++++++- catkit/pawprint/generator.py | 5 +- catkit/pawprint/operations.py | 48 ++++- catkit/pawprint/tests/.test_generator.py.swp | Bin 0 -> 20480 bytes catkit/pawprint/tests/test_generator.py | 10 +- 5 files changed, 228 insertions(+), 10 deletions(-) create mode 100644 catkit/pawprint/tests/.test_generator.py.swp diff --git a/catkit/db.py b/catkit/db.py index a82b1d58..5870e897 100644 --- a/catkit/db.py +++ b/catkit/db.py @@ -427,6 +427,12 @@ def create_table(self): description TEXT )""") + self.c.execute("""CREATE TABLE IF NOT EXISTS metadata_params( + pid INTEGER PRIMARY KEY AUTOINCREMENT, + symbol CHAR(10) UNIQUE NOT NULL, + description TEXT + )""") + self.c.execute("""CREATE TABLE IF NOT EXISTS fingerprints( entry_id INTEGER PRIMARY KEY AUTOINCREMENT, image_id INT NOT NULL, @@ -439,6 +445,18 @@ def create_table(self): UNIQUE(image_id, param_id) )""") + self.c.execute("""CREATE TABLE IF NOT EXISTS metadata( + entry_id INTEGER PRIMARY KEY AUTOINCREMENT, + image_id INT NOT NULL, + param_id INT NOT NULL, + value TEXT, + FOREIGN KEY(image_id) REFERENCES images(image_id) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY(param_id) REFERENCES parameters(param_id) + ON DELETE CASCADE ON UPDATE CASCADE, + UNIQUE(image_id, param_id) + )""") + def image_entry(self, d, identity=None): """Enters a single ase-db image into the fingerprint database. The ase-db ID with identity must be unique. If not, it will be skipped. @@ -535,6 +553,72 @@ def get_parameters(self, selection=None, display=False): return parameter_ids + def metadata_params_entry(self, symbol=None, description=None): + """Enters a unique metadata parameter into the database. + + Parameters + ---------- + symbol : str + A unique symbol the entry can be referenced by. If None, + the symbol will be the ID of the parameter + as a string. + description : str + A description of the parameter. + """ + if not symbol: + self.c.execute("""SELECT MAX(pid) FROM metadata_params""") + symbol = str(int(self.c.fetchone()[0]) + 1) + + # The symbol must be unique. If not, it will be skipped. + try: + self.c.execute("""INSERT INTO metadata_params (symbol, description) + VALUES(?, ?)""", (symbol, description)) + except (IntegrityError): + if self.verbose: + print('Symbol already defined: {}'.format(symbol)) + + # Each instance needs to be commited to ensure no overwriting. + # This could potentially result in slowdown. + self.con.commit() + + def get_metadata_params(self, selection=None, display=False): + """Get an array of integer values which correspond to the + metadata parameter IDs for a set of provided symbols. + + Parameters + ---------- + selection : list + Symbols in parameters table to be selected. If no selection + is made, return all parameters. + display : bool + Print parameter descriptions. + + Returns + ------- + metadata_params_ids : array (n,) + Integer values of selected parameters. + """ + if not selection: + self.c.execute("""SELECT pid, symbol, description + FROM metadata_params""") + res = self.c.fetchall() + else: + res = [] + for i, s in enumerate(selection): + self.c.execute("""SELECT pid, symbol, description + FROM metadata_params WHERE symbol = '{}'""".format(s)) + res += [self.c.fetchone()] + + if display: + print('[ID ]: key - Description') + print('---------------------------') + for r in res: + print('[{0:^3}]: {1:<10} - {2}'.format(*r)) + + metadata_params_ids = np.array(res).T[0].astype(int) + + return metadata_params_ids + def fingerprint_entry(self, ase_id, param_id, value): """Enters a fingerprint value to the database for a given ase and parameter id. @@ -594,8 +678,8 @@ def get_fingerprints(self, ase_ids=None, params=[]): psel = ','.join(np.array(params).astype(str)) if ase_ids is None: - cmd = """SELECT GROUP_CONCAT(value) FROM fingerprints - JOIN images on fingerprints.image_id = images.iid + cmd = """SELECT GROUP_CONCAT(IFNULL(value, 'nan')) FROM + fingerprints JOIN images on fingerprints.image_id = images.iid WHERE param_id IN ({}) GROUP BY ase_id ORDER BY images.iid""".format(psel) @@ -603,8 +687,8 @@ def get_fingerprints(self, ase_ids=None, params=[]): else: asel = ','.join(np.array(ase_ids).astype(str)) - cmd = """SELECT GROUP_CONCAT(value) FROM fingerprints - JOIN images on fingerprints.image_id = images.iid + cmd = """SELECT GROUP_CONCAT(IFNULL(value, 'nan')) FROM + fingerprints JOIN images on fingerprints.image_id = images.iid WHERE param_id IN ({}) AND ase_id IN ({}) GROUP BY ase_id""".format(psel, asel) @@ -616,3 +700,86 @@ def get_fingerprints(self, ase_ids=None, params=[]): fingerprint[i] = f[0].split(',') return fingerprint + + def metadata_entry(self, ase_id, param_id, value): + """Enters a metadata value to the database for a given ase and + parameter id. + + Parameters + ---------- + ase_id : int + The unique id associated with an atoms object in the database. + param_id : int or str + The parameter ID or symbol associated with and entry in the + parameters table. + value : str + The value of the metadata for the atoms object. + """ + # If parameter symbol is given, get the ID + if isinstance(param_id, str): + self.c.execute("""SELECT pid FROM metadata_params + WHERE symbol = '{}'""".format(param_id)) + param_id = self.c.fetchone() + + if param_id: + param_id = param_id[0] + else: + raise (KeyError, 'metadata symbol not found') + + self.c.execute("""SELECT iid FROM images + WHERE ase_id = {}""".format(ase_id)) + image_id = self.c.fetchone()[0] + + self.c.execute("""INSERT INTO metadata (image_id, param_id, value) + VALUES(?, ?, ?)""", (int(image_id), int(param_id), value)) + + def get_metadata(self, ase_ids=None, params=[]): + """Get the array of values associated with the provided metadata + parameters for each ase_id. + + Parameters + ---------- + ase_id : list + The ase-id associated with an atoms object in the database. + params : list + List of symbols or int in metadata parameters table to be selected. + + Returns + ------- + metadata : array (n,) + An array of values associated with the given metadata parameters + for each ase_id. + """ + if isinstance(params, np.ndarray): + params = params.tolist() + + if not params or isinstance(params[0], str): + params = self.get_metadata_params(selection=params) + psel = ','.join(params.astype(str)) + elif isinstance(params[0], int): + psel = ','.join(np.array(params).astype(str)) + + if ase_ids is None: + cmd = """SELECT GROUP_CONCAT(IFNULL(value, 'nan')) FROM + metadata JOIN images on metadata.image_id = images.iid + WHERE param_id IN ({}) + GROUP BY ase_id + ORDER BY images.iid""".format(psel) + + else: + asel = ','.join(np.array(ase_ids).astype(str)) + + cmd = """SELECT GROUP_CONCAT(IFNULL(value, 'nan')) FROM + metadata JOIN images on metadata.image_id = images.iid + WHERE param_id IN ({}) AND ase_id IN ({}) + GROUP BY ase_id""".format(psel, asel) + + self.c.execute(cmd) + fetch = self.c.fetchall() + + metadata = [] + for i, f in enumerate(fetch): + metadata += [f[0].split(',')] + + return metadata + diff --git a/catkit/pawprint/generator.py b/catkit/pawprint/generator.py index 94735cc9..5c07ca0d 100644 --- a/catkit/pawprint/generator.py +++ b/catkit/pawprint/generator.py @@ -122,7 +122,10 @@ def get_fp(self, parameters_list, operation_list): connectivity, **kwargs) fingerprints[i] += [fingerprint] - fingerprints = np.block(fingerprints) + try: + fingerprints = np.block(fingerprints) + except ValueError: + fingerprints = 'I\'m outta here.' return fingerprints diff --git a/catkit/pawprint/operations.py b/catkit/pawprint/operations.py index b2185993..bd4f7684 100644 --- a/catkit/pawprint/operations.py +++ b/catkit/pawprint/operations.py @@ -86,7 +86,19 @@ def local_ads_metal_fp( connectivity=None, fuse=False): """Sum of the differences in properties of the atoms in the - metal-adsorbate interface""" + metal-adsorbate interface + + Parameters + ---------- + atoms : ase Atoms or catkit gratoms object. + atoms_parameters : ndarray(n, ) + a list of chemical properties to construct the fingerprints. + connectivity : ndarray (n,) + Connectivity of the adsorption sites + weigthed : boolean + fingerprints are weightd by the stoichiometric ratio of + the bimetals. + """ bond_index = np.where(atoms.get_tags() == -1)[0] fp = np.empty([len(atoms_parameters), len(bond_index)]) for i, bi in enumerate(bond_index): @@ -98,6 +110,40 @@ def local_ads_metal_fp( else: return fp.sum(axis=1) +def bimetal_fp( + atoms=None, + atoms_parameters=None, + connectivity=None): + """The differences in properties of the atoms in the + metal-adsorbate interface + + Parameters + ---------- + atoms : ase Atoms or catkit gratoms object. + atoms_parameters : ndarray(n, ) + a list of chemical properties to construct the fingerprints. + """ + fp = np.zeros([len(atoms_parameters)]) + metals = set(atoms.get_chemical_symbols()) + uap = [] + for ap in atoms_parameters: + if not np.isnan(ap).any(): + uap += [np.unique(np.round(ap, 3)).tolist()] + else: + uap += [[np.nan, np.nan]] + for i, ap in enumerate(uap): + if len(ap) == 1: + uap[i] = [ap[0], ap[0]] + + if len(metals) == 1: + fp = fp.reshape(-1) + elif len(metals) == 2: + fp = np.diff(uap).reshape(-1) + else: + raise NotImplementedError("""This operation is restricted to single + and binary metal system only.""") + return fp + def derived_fp( atoms=None, diff --git a/catkit/pawprint/tests/.test_generator.py.swp b/catkit/pawprint/tests/.test_generator.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..28a755aa266b04424f7c674f6854187f20f2524a GIT binary patch literal 20480 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 literal 0 HcmV?d00001 diff --git a/catkit/pawprint/tests/test_generator.py b/catkit/pawprint/tests/test_generator.py index 94546164..e7031ec0 100644 --- a/catkit/pawprint/tests/test_generator.py +++ b/catkit/pawprint/tests/test_generator.py @@ -27,15 +27,17 @@ def test_nonlocal_fingerprinting(self): operations = [ 'periodic_convolution', - ['periodic_convolution', {'d': 1}] + ['periodic_convolution', {'d': 1}], + 'bimetal_fp' ] fp = Fingerprinter(images) fingerprints = fp.get_fp(parameters, operations) truth = np.array([ - [12432.0, 7.562800000000001, 320.44, 136896.0, 90.7488, 3844.8], - [2028.0, 24.53879999999999, 1200.0, 20280.0, 245.388, 12000.0]]) + [12432.0, 7.562800000000001, 320.44, 136896.0, 90.7488, 3844.8, + 3.20000e+01, 2.00000e-02, 2.00000e-01], [2028.0, 24.5387999999999, + 1200.0, 20280.0, 245.388, 12000.0, 0.00, 0.00, 0.00]]) np.testing.assert_allclose(fingerprints, truth) @@ -63,7 +65,7 @@ def test_local_fingerprinting(self): operations = [ 'bonding_convolution', 'layered_sum', - 'local_ads_metal_fp' + 'local_ads_metal_fp', ] fp = Fingerprinter(atoms) From 27bdf81885a8692882667f67eb6275318b85e855 Mon Sep 17 00:00:00 2001 From: Osman Mamun Date: Tue, 25 Sep 2018 16:10:22 -0700 Subject: [PATCH 11/11] Update generator.py --- catkit/pawprint/generator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/catkit/pawprint/generator.py b/catkit/pawprint/generator.py index 5c07ca0d..d904f426 100644 --- a/catkit/pawprint/generator.py +++ b/catkit/pawprint/generator.py @@ -70,7 +70,7 @@ def _get_atoms_parameters(self, atoms, parameters): return atoms_parameters - def get_fp(self, parameters_list, operation_list): + def get_fp(self, parameters, operation_list): """Return the fingerprints for a list of images of single atoms object for the given parameters. @@ -108,12 +108,12 @@ def get_fp(self, parameters_list, operation_list): if isinstance(operation, str): operation = getattr(operations, operation) - if all(isinstance(pl, list) for pl in parameters_list): + if all(isinstance(pl, list) for pl in parameters): atoms_parameters = self._get_atoms_parameters(atoms, - parameters_list[j]) + parameters[j]) else: atoms_parameters = self._get_atoms_parameters(atoms, - parameters_list) + parameters) fingerprint = _generate_fingerprint( operation,