Skip to content

Commit

Permalink
Merge branch 'master' into cmake-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr authored May 6, 2022
2 parents 115675a + e4cafba commit cf363b8
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
pyver: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3.0.0
- uses: actions/checkout@v3.0.2
with:
submodules: "recursive"

- name: Build wheels
uses: pypa/cibuildwheel@v2.3.1
uses: pypa/cibuildwheel@2.5.0
env:
# Build for cpython >= 3.6.
CIBW_PROJECT_REQUIRES_PYTHON: "==${{ matrix.pyver }}.*"
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.0
- uses: actions/checkout@v3.0.2
with:
submodules: "recursive"

Expand Down
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ The format is based on
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## vX.Y.Z -- YYYY-MM-DD

### Added
* `include_input_points` argument to `freud.locality.PeriodicBuffer`.

### Changed
* `freud.data.UnitCell.generate_system` now generates positions in the same order as the basis positions.

## v2.9.0 -- 2022-04-19

### Added
Expand Down
4 changes: 2 additions & 2 deletions cpp/locality/PeriodicBuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace freud { namespace locality {

void PeriodicBuffer::compute(const freud::locality::NeighborQuery* neighbor_query, const vec3<float>& buff,
const bool use_images)
const bool use_images, const bool include_input_points)
{
m_box = neighbor_query->getBox();
if (buff.x < 0)
Expand Down Expand Up @@ -68,7 +68,7 @@ void PeriodicBuffer::compute(const freud::locality::NeighborQuery* neighbor_quer
for (int k = use_images ? 0 : -images.z; k <= images.z; k++)
{
// Skip the origin image
if (i == 0 && j == 0 && k == 0)
if (!include_input_points && i == 0 && j == 0 && k == 0)
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/locality/PeriodicBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PeriodicBuffer

//! Compute the periodic buffer
void compute(const freud::locality::NeighborQuery* neighbor_query, const vec3<float>& buff,
const bool use_images);
const bool use_images, const bool include_input_points);

//! Return the buffer points
std::vector<vec3<float>> getBufferPoints() const
Expand Down
2 changes: 1 addition & 1 deletion doc/source/gettingstarted/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ CMake Options

The scikit-build tool allows setup.py to accept three different sets of options separated by ``--``, where each set is provided directly to scikit-build, to CMake, or to the code generator of choice, respectively.
For example, the command ``python setup.py build_ext --inplace -- -DCOVERAGE=ON -G Ninja -- -j 4`` tell scikit-build to perform an in-place build, it tells CMake to turn on the ``COVERAGE`` option and use Ninja for compilation, and it tells Ninja to compile with 4 parallel threads.
For more information on these options, see the `scikit-build docs <scikit-build.readthedocs.io/>`__.
For more information on these options, see the `scikit-build docs <https://scikit-build.readthedocs.io/>`__.

In addition to standard CMake flags, the following CMake options are available for **freud**:

Expand Down
1 change: 1 addition & 0 deletions freud/_locality.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ cdef extern from "PeriodicBuffer.h" namespace "freud::locality":
void compute(
const NeighborQuery*,
const vec3[float],
const bool,
const bool) except +
vector[vec3[float]] getBufferPoints() const
vector[uint] getBufferIds() const
Expand Down
5 changes: 3 additions & 2 deletions freud/box.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,9 @@ cdef class Box:
def from_matrix(cls, box_matrix, dimensions=None):
r"""Initialize a Box instance from a box matrix.
For more information and the source for this code,
see: https://hoomd-blue.readthedocs.io/en/stable/box.html
For more information and the source for this code, see:
`HOOMD-blue's box documentation \
<https://hoomd-blue.readthedocs.io/en/stable/package-hoomd.html#hoomd.Box>`_.
Args:
box_matrix (array-like):
Expand Down
13 changes: 11 additions & 2 deletions freud/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def generate_system(self, num_replicas=1, scale=1, sigma_noise=0, seed=None):
tuple (:class:`freud.box.Box`, :class:`np.ndarray`):
A system-like object (see
:class:`~freud.locality.NeighborQuery.from_system`).
Note:
Positions are generated in the order of the instance's
``basis_positions``. The first :math:`N_{replica}`
positions come from the first basis position, the next
:math:`N_{replica}` the second, etc.
"""
try:
nx, ny, nz = num_replicas
Expand All @@ -87,10 +93,13 @@ def generate_system(self, num_replicas=1, scale=1, sigma_noise=0, seed=None):
pbuff = freud.locality.PeriodicBuffer()
abs_positions = self.box.make_absolute(self.basis_positions)
pbuff.compute(
(self.box, abs_positions), buffer=(nx - 1, ny - 1, nz - 1), images=True
(self.box, abs_positions),
buffer=(nx - 1, ny - 1, nz - 1),
images=True,
include_input_points=True,
)
box = pbuff.buffer_box * scale
positions = np.concatenate((abs_positions, pbuff.buffer_points))
positions = pbuff.buffer_points
else:
box = self.box * scale
positions = self.box.make_absolute(self.basis_positions)
Expand Down
7 changes: 5 additions & 2 deletions freud/locality.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ cdef class PeriodicBuffer(_Compute):
def __dealloc__(self):
del self.thisptr

def compute(self, system, buffer, cbool images=False):
def compute(self, system, buffer, cbool images=False, include_input_points=False):
r"""Compute the periodic buffer.
Args:
Expand All @@ -1099,6 +1099,9 @@ cdef class PeriodicBuffer(_Compute):
each side, meaning that one image doubles the box side lengths,
two images triples the box side lengths, and so on.
(Default value = :code:`False`).
include_input_points (bool, optional):
Whether the original points provided by ``system`` are
included in the buffer, (Default value = :code:`False`).
"""
cdef NeighborQuery nq = _make_default_nq(system)
cdef vec3[float] buffer_vec
Expand All @@ -1110,7 +1113,7 @@ cdef class PeriodicBuffer(_Compute):
else:
raise ValueError('buffer must be a scalar or have length 3.')

self.thisptr.compute(nq.get_ptr(), buffer_vec, images)
self.thisptr.compute(nq.get_ptr(), buffer_vec, images, include_input_points)
return self

@_Compute._computed_property
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-precommit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pre-commit==2.17.0
pre-commit==2.18.1
8 changes: 4 additions & 4 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
ase==3.22.1
cmake==3.22.3
cmake==3.22.4
codecov==2.1.12
coverage==6.3.2
cython==0.29.28
dynasor==1.1.1; platform_system != "Windows"
garnett==0.7.1
GitPython==3.1.27
gsd==2.5.1
gsd==2.5.2
matplotlib>=3.0.0
numpy==1.22.3
pillow>=8.0.0 --only-binary=pillow
pytest==7.1.1
pytest==7.1.2
pytest-cov==3.0.0
rowan==1.3.0.post1
scikit-build==0.13.1
scikit-build==0.14.1
scipy==1.8.0
sympy==1.10.1
16 changes: 16 additions & 0 deletions tests/test_locality_PeriodicBuffer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import numpy.testing as npt
import pytest

import freud

Expand Down Expand Up @@ -204,6 +205,21 @@ def test_triclinic(self):
assert len(pbuff.buffer_ids) == 3 * N
npt.assert_array_equal(pbuff.buffer_box.L, box.L * np.array([2, 1, 2]))

@pytest.mark.parametrize("is2d, points_fac", [(True, 9), (False, 27)])
def test_include_input_points(self, is2d, points_fac):
L = 10 # Box length
N = 50 # Number of points

box, positions = freud.data.make_random_system(L, N, is2D=is2d)
positions.flags["WRITEABLE"] = False

pbuff = freud.locality.PeriodicBuffer()
pbuff.compute(
(box, positions), buffer=2, images=True, include_input_points=True
)

assert len(pbuff.buffer_points) == points_fac * N

def test_repr(self):
pbuff = freud.locality.PeriodicBuffer()
assert str(pbuff) == str(eval(repr(pbuff)))

0 comments on commit cf363b8

Please sign in to comment.