diff --git a/pymatgen/core/structure.py b/pymatgen/core/structure.py index c525959a391..93ff02d250d 100644 --- a/pymatgen/core/structure.py +++ b/pymatgen/core/structure.py @@ -1522,10 +1522,10 @@ def get_neighbor_list( else: if sites is None: sites = self.sites - site_coords = np.array([site.coords for site in sites], dtype=float) - cart_coords = np.array(self.cart_coords, dtype=float) - lattice_matrix = np.array(self.lattice.matrix, dtype=float) - pbc = np.array(self.pbc, dtype=int) + site_coords = np.ascontiguousarray([site.coords for site in sites], dtype=float) + cart_coords = np.ascontiguousarray(self.cart_coords, dtype=float) + lattice_matrix = np.ascontiguousarray(self.lattice.matrix, dtype=float) + pbc = np.ascontiguousarray(self.pbc, dtype=int) center_indices, points_indices, images, distances = find_points_in_spheres( cart_coords, site_coords, diff --git a/pymatgen/core/tests/test_structure.py b/pymatgen/core/tests/test_structure.py index b6cb73db5ba..25f30c215f5 100644 --- a/pymatgen/core/tests/test_structure.py +++ b/pymatgen/core/tests/test_structure.py @@ -538,6 +538,12 @@ def test_get_neighbor_list(self): p_indices1, p_indices2, p_offsets, p_distances = s._get_neighbor_list_py(3) self.assert_all_close(sorted(c_distances), sorted(p_distances)) + s = Structure(s.lattice, s.species, s.frac_coords) + s.apply_strain(0.01) + c_indices1, c_indices2, c_offsets, c_distances = s.get_neighbor_list(3) + p_indices1, p_indices2, p_offsets, p_distances = s._get_neighbor_list_py(3) + self.assert_all_close(sorted(c_distances), sorted(p_distances)) + # @skipIf(not os.getenv("CI"), "Only run this in CI tests") # def test_get_all_neighbors_crosscheck_old(self): # warnings.simplefilter("ignore")