From 17e0de3d9b27d79ea49587a249e54bf0d23d0fd4 Mon Sep 17 00:00:00 2001 From: Killian Date: Tue, 15 Aug 2023 18:54:08 -0400 Subject: [PATCH] fix error when atom types neighbors are unique --- src/WarrenCowleyParameters/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/WarrenCowleyParameters/__init__.py b/src/WarrenCowleyParameters/__init__.py index 37f577b..632bd35 100644 --- a/src/WarrenCowleyParameters/__init__.py +++ b/src/WarrenCowleyParameters/__init__.py @@ -50,9 +50,11 @@ def get_wc_from_neigh_in_shell_types( for i in range(ntypes): neight_type_aroud_itype = neigh_in_shell_types[central_atom_type_mask[i]] neight_type_aroud_itype_flat = neight_type_aroud_itype.flatten() - counts = np.bincount(neight_type_aroud_itype_flat) - pij = counts[unique_types] / (neight_type_aroud_itype.shape[0] * neight_in_shell) + counts = np.bincount(neight_type_aroud_itype_flat, minlength=ntypes + 1) + + pij = counts[unique_types] / (neight_type_aroud_itype.shape[0] * neight_in_shell) + wc[i, :] = 1 - pij / c return wc @@ -110,6 +112,6 @@ def modify(self, data: DataCollection, frame: int, **kwargs): neigh_in_shell_types, central_atom_type_mask, c, unique_types ) wc_for_shells[m] = wc - + data.attributes["Warren-Cowley parameters"] = wc_for_shells - self.create_visualization_tables(unique_types, nshells, wc_for_shells, data) \ No newline at end of file + self.create_visualization_tables(unique_types, nshells, wc_for_shells, data)