Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: force contiguous calling find_points_in_spheres #3108

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions pymatgen/core/tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down