#628 Add cropping feature

Merged Kelly Wang k-l-wang Pseudo commit used to compare (37abafd...b559809)
Missing base report.

Unable to compare commits because the base of the pull request did not upload a coverage report.

Changes found in between 37abafd...b559809 (pseudo...base) which prevent comparing this pull request.

Showing 1 of 7 files from the diff.
Newly tracked file
freud/box.pyx changed.
Other files ignored by Codecov

@@ -15,6 +15,7 @@
Loading
15 15
16 16
from freud.util cimport vec3
17 17
from cpython.object cimport Py_EQ, Py_NE
18 +
from libcpp cimport bool as cpp_bool
18 19
19 20
cimport freud._box
20 21
cimport numpy as np
@@ -241,8 +242,8 @@
Loading
241 242
        cdef const float[:, ::1] l_points = vecs
242 243
        cdef const int[:, ::1] l_result = images
243 244
        cdef unsigned int Np = l_points.shape[0]
244 -
        self.thisptr.getImage(<vec3[float]*> &l_points[0, 0], Np,
245 -
                              <vec3[int]*> &l_result[0, 0])
245 +
        self.thisptr.getImages(<vec3[float]*> &l_points[0, 0], Np,
246 +
                               <vec3[int]*> &l_result[0, 0])
246 247
247 248
        return np.squeeze(images) if flatten else images
248 249
@@ -494,6 +495,37 @@
Loading
494 495
495 496
        return np.asarray(distances)
496 497
498 +
    def crop(self, points):
499 +
        R"""Returns boolean array (mask) corresponding to particle membership in a box.
500 +
501 +
        Args:
502 +
            points (:math:`\left(N, 3\right)` :class:`numpy.ndarray`):
503 +
                Array of points.
504 +
505 +
        Returns:
506 +
            :math:`\left(N, \right)` :class:`numpy.ndarray`:
507 +
                Array of booleans, where `True` corresponds to points within the box,
508 +
                and `False` corresponds to points outside the box.
509 +
        """  # noqa: E501
510 +
        points = freud.util._convert_array(
511 +
            np.atleast_2d(points), shape=(None, 3))
512 +
513 +
        cdef:
514 +
            const float[:, ::1] l_points = points
515 +
            size_t n_all_points = points.shape[0]
516 +
517 +
        # cropped_mask = freud.util._convert_array(
518 +
        #    np.ones(n_all_points), dtype=np.uint8)
519 +
        cropped_mask = freud.util._convert_array(
520 +
            np.ones(n_all_points), dtype=np.bool)
521 +
        cdef cpp_bool[::1] l_cropped_mask = cropped_mask
522 +
523 +
        self.thisptr.crop(
524 +
            <vec3[float]*> &l_points[0, 0], n_all_points,
525 +
            <cpp_bool*> &l_cropped_mask[0])
526 +
527 +
        return np.array(l_cropped_mask).astype(np.bool)
528 +
497 529
    @property
498 530
    def periodic(self):
499 531
        """:math:`\\left(3, \\right)` :class:`numpy.ndarray`: Get or set the

Unable to process changes.

No base report to compare against.

24 Commits

Hiding 1 contexual commits Hiding 1 contexual commits
Hiding 1 contexual commits
+12
+12
-12
-12
+12
+12
-12
-12
Hiding 3 contexual commits
Hiding 10 contexual commits
+12
+12
Pull Request Base Commit
Files Coverage
freud 92.82%
Project Totals (16 files) 92.82%
Loading