Skip to content

Commit

Permalink
Merge pull request #1291 from glotzerlab/nanobind-environment
Browse files Browse the repository at this point in the history
Port environment to nanobind
  • Loading branch information
joaander authored Feb 4, 2025
2 parents ff46300 + 4100b3c commit af99cc9
Show file tree
Hide file tree
Showing 30 changed files with 1,329 additions and 818 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
pytest tests/test_data.py -v
pytest tests/test_pmft.py -v
pytest tests/test_util.py -v
pytest tests/test_environment*.py -v
pytest tests/test_diffraction*.py -v
pytest tests/test_interface.py -v
pytest tests/test_msd_msd.py -v
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ repos:
^extern/|
^freud/density/|
^freud/diffraction/|
^freud/environment/|
^freud/order/
)
args:
Expand Down
46 changes: 28 additions & 18 deletions freud/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ add_library(
diffraction/StaticStructureFactorDirect.h
diffraction/StaticStructureFactorDirect.cc
# environment
# environment/AngularSeparation.h
# environment/AngularSeparation.cc
# environment/BondOrder.h
# environment/BondOrder.cc
# environment/LocalBondProjection.h
# environment/LocalBondProjection.cc
# environment/LocalDescriptors.h
# environment/LocalDescriptors.cc
# environment/MatchEnv.h
# environment/MatchEnv.cc
# environment/Registration.h
environment/AngularSeparation.h
environment/AngularSeparation.cc
environment/BondOrder.h
environment/BondOrder.cc
environment/LocalBondProjection.h
environment/LocalBondProjection.cc
environment/LocalDescriptors.h
environment/LocalDescriptors.cc
environment/MatchEnv.h
environment/MatchEnv.cc
environment/Registration.h
# locality
locality/AABB.h
locality/AABBQuery.cc
Expand Down Expand Up @@ -152,15 +152,24 @@ nanobind_add_module(
target_link_libraries(_diffraction PUBLIC freud TBB::tbb)
target_set_install_rpath(_diffraction)

# environment nanobind_add_module(_environment environment/...)
# target_link_libraries(_environment PUBLIC freud TBB::tbb)
# target_set_install_rpath(_environment)

# box
nanobind_add_module(_box box/module-box.cc box/export-Box.cc box/export-Box.h)
target_link_libraries(_box PUBLIC TBB::tbb)
target_set_install_rpath(_box)

# environment
nanobind_add_module(
_environment
environment/module-environment.cc
environment/export-AngularSeparationNeighbor.cc
environment/export-AngularSeparationGlobal.cc
environment/export-LocalBondProjection.cc
environment/export-LocalDescriptors.cc
environment/export-BondOrder.cc
environment/export-MatchEnv.cc)
target_link_libraries(_environment PUBLIC freud TBB::tbb)
target_set_install_rpath(_environment)

# locality
nanobind_add_module(
_locality
Expand Down Expand Up @@ -213,6 +222,7 @@ set(python_files
box.py
cluster.py
data.py
environment.py
diffraction.py
errors.py
locality.py
Expand All @@ -223,7 +233,7 @@ set(python_files
interface.py
plot.py
util.py)
# cluster.py density.py diffraction.py environment.py interface.py msd.py)
# density.py)

copy_files_to_build("${python_files}" "freud" "*.py")

Expand All @@ -232,9 +242,9 @@ if(SKBUILD)
install(FILES ${python_files} DESTINATION freud)
install(TARGETS _box DESTINATION freud)
install(TARGETS _cluster DESTINATION freud)
# install(TARGETS _density DESTINATION freud)
install(TARGETS _environment DESTINATION freud)
install(TARGETS _diffraction DESTINATION freud)
# install(TARGETS _density DESTINATION freud) install(TARGETS _environment
# DESTINATION freud)
install(TARGETS _locality DESTINATION freud)
install(TARGETS _order DESTINATION freud)
install(TARGETS _parallel DESTINATION freud)
Expand Down
4 changes: 3 additions & 1 deletion freud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Copyright (c) 2010-2024 The Regents of the University of Michigan
# This file is from the freud project, released under the BSD 3-Clause License.

# density,
from . import (
box,
cluster,
data,
diffraction,
environment,
interface,
locality,
msd,
Expand All @@ -30,7 +32,7 @@
"data",
# "density",
"diffraction",
# "environment",
"environment",
"interface",
"locality",
"msd",
Expand Down
4 changes: 3 additions & 1 deletion freud/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def __init__(self, Lx, Ly, Lz=0, xy=0, xz=0, yz=0, is2D=None):
elif not (Lx and Ly and Lz):
msg = "Lx, Ly, and Lz must be nonzero for 3D boxes."
raise ValueError(msg)
self._cpp_obj = freud._box.Box(Lx, Ly, Lz, xy, xz, yz, is2D)
self._cpp_obj = freud._box.Box(
*[float(x) for x in [Lx, Ly, Lz, xy, xz, yz]], bool(is2D)
)

@property
def L(self):
Expand Down
Loading

0 comments on commit af99cc9

Please sign in to comment.