Skip to content

Commit

Permalink
Fix NumPy array indexing in 32-bit system in `analysis.chemenv.coordi…
Browse files Browse the repository at this point in the history
…nation_environments` (#4194)

* fix index in 32bit system

* pre-commit auto-fixes

---------

Co-authored-by: Haoyu Yang <yang@debian32bit.lan>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent 461b56c commit ac663b4
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def points_wcs_csc(self, permutation=None):
"""
if permutation is None:
return self._points_wcs_csc
return np.concatenate((self._points_wcs_csc[:1], self._points_wocs_csc.take(permutation, axis=0)))
return np.concatenate(
(self._points_wcs_csc[:1], self._points_wocs_csc.take(np.array(permutation, dtype=np.intp), axis=0))
)

def points_wocs_csc(self, permutation=None):
"""
Expand All @@ -227,7 +229,7 @@ def points_wocs_csc(self, permutation=None):
"""
if permutation is None:
return self._points_wocs_csc
return self._points_wocs_csc.take(permutation, axis=0)
return self._points_wocs_csc.take(np.array(permutation, dtype=np.intp), axis=0)

def points_wcs_ctwcc(self, permutation=None):
"""
Expand All @@ -239,7 +241,7 @@ def points_wcs_ctwcc(self, permutation=None):
return np.concatenate(
(
self._points_wcs_ctwcc[:1],
self._points_wocs_ctwcc.take(permutation, axis=0),
self._points_wocs_ctwcc.take(np.array(permutation, dtype=np.intp), axis=0),
)
)

Expand All @@ -250,7 +252,7 @@ def points_wocs_ctwcc(self, permutation=None):
"""
if permutation is None:
return self._points_wocs_ctwcc
return self._points_wocs_ctwcc.take(permutation, axis=0)
return self._points_wocs_ctwcc.take(np.array(permutation, dtype=np.intp), axis=0)

def points_wcs_ctwocc(self, permutation=None):
"""
Expand All @@ -262,7 +264,7 @@ def points_wcs_ctwocc(self, permutation=None):
return np.concatenate(
(
self._points_wcs_ctwocc[:1],
self._points_wocs_ctwocc.take(permutation, axis=0),
self._points_wocs_ctwocc.take(np.array(permutation, dtype=np.intp), axis=0),
)
)

Expand All @@ -273,7 +275,7 @@ def points_wocs_ctwocc(self, permutation=None):
"""
if permutation is None:
return self._points_wocs_ctwocc
return self._points_wocs_ctwocc.take(permutation, axis=0)
return self._points_wocs_ctwocc.take(np.array(permutation, dtype=np.intp), axis=0)

@property
def cn(self):
Expand Down Expand Up @@ -1976,6 +1978,7 @@ def _cg_csm_separation_plane_optim2(
stop_search = False
# TODO: do not do that several times ... also keep in memory
if sepplane.ordered_plane:
separation_indices = [arr.astype(np.intp) for arr in separation_indices]
inp = self.local_geometry.coords.take(separation_indices[1], axis=0)
if sepplane.ordered_point_groups[0]:
pp_s0 = self.local_geometry.coords.take(separation_indices[0], axis=0)
Expand Down

0 comments on commit ac663b4

Please sign in to comment.