Skip to content

Commit

Permalink
segfaulting test
Browse files Browse the repository at this point in the history
  • Loading branch information
hmacdope committed Sep 6, 2024
1 parent e13a092 commit 2fe6b65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions distopia/_distopia.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,8 @@ def calc_self_distance_array_triclinic(
@cython.wraparound(False)
def calc_bonds_no_box_idx(
floating[:, ::1] coords,
integral[::1] a_idx,
integral[::1] b_idx,
int[::1] a_idx,
int[::1] b_idx,
floating[::1] results=None):
"""Calculate pairwise distances between coords[a_idx] and coords[b_idx] with no periodic boundary conditions
Expand All @@ -1013,6 +1013,7 @@ def calc_bonds_no_box_idx(

_check_shapes(a_idx, b_idx)


if results is None:
if floating is float:
results = cnp.PyArray_EMPTY(1, dims, cnp.NPY_FLOAT32, 0)
Expand All @@ -1033,8 +1034,8 @@ def calc_bonds_no_box_idx(
@cython.wraparound(False)
def calc_bonds_ortho_idx(
floating[:, ::1] coords,
integral[::1] a_idx,
integral[::1] b_idx,
int[::1] a_idx,
int[::1] b_idx,
floating[::1] box,
floating[::1] results=None):
"""Calculate pairwise distances between coords[a_idx] and coords[b_idx] under orthorhombic boundary conditions
Expand Down Expand Up @@ -1062,6 +1063,7 @@ def calc_bonds_ortho_idx(

_check_shapes(a_idx, b_idx)


if results is None:
if floating is float:
results = cnp.PyArray_EMPTY(1, dims, cnp.NPY_FLOAT32, 0)
Expand All @@ -1082,8 +1084,8 @@ def calc_bonds_ortho_idx(
@cython.wraparound(False)
def calc_bonds_triclinic_idx(
floating[:, ::1] coords,
integral[::1] a_idx,
integral[::1] b_idx,
int[::1] a_idx,
int[::1] b_idx,
floating[:, ::1] box,
floating[::1] results=None):
"""Calculate pairwise distances between coords[a_idx] and coords[b_idx] under triclinic boundary conditions
Expand Down Expand Up @@ -1111,6 +1113,7 @@ def calc_bonds_triclinic_idx(

_check_shapes(a_idx, b_idx)


if results is None:
if floating is float:
results = cnp.PyArray_EMPTY(1, dims, cnp.NPY_FLOAT32, 0)
Expand Down
8 changes: 4 additions & 4 deletions distopia/tests/test_distopia.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ def result_shim(self, make_arr, N, dtype):


@pytest.mark.parametrize("dtype", (np.float32, np.float64))
@pytest.mark.parametrize("N", (0, 10, 1000, 10000))
@pytest.mark.parametrize("N", (10, 1000, 10000))
@pytest.mark.parametrize("use_result_buffer", (True, False))
def test_calc_bonds_no_box_idx(self, N, use_result_buffer, dtype):
c = self.arange_input(N, dtype)
a_idx = np.asarray([0, 1, 2, 3, 4, 5])
b_idx = np.asarray([6, 7, 8, 9, 10, 11])
result_buffer = self.result_shim(use_result_buffer, N, dtype)
a_idx = np.asarray(np.arange(N -3)).astype(np.int32)
b_idx = np.asarray(np.arange(N -3)).astype(np.int32)
result_buffer = self.result_shim(use_result_buffer, len(a_idx), dtype)
result = distopia.calc_bonds_no_box_idx(
c, a_idx, b_idx, results=result_buffer
)
Expand Down

0 comments on commit 2fe6b65

Please sign in to comment.