diff --git a/CMake/freud-macros.cmake b/CMake/freud-macros.cmake index 031318e4b..f43d555fc 100644 --- a/CMake/freud-macros.cmake +++ b/CMake/freud-macros.cmake @@ -43,6 +43,7 @@ function(target_set_install_rpath _target) endif() if(_using_conda OR DEFINED ENV{CIBUILDWHEEL}) - set_target_properties(${_target} PROPERTIES INSTALL_RPATH_USE_LINK_PATH True) + set_target_properties(${_target} PROPERTIES INSTALL_RPATH_USE_LINK_PATH + True) endif() endfunction() diff --git a/cpp/box/export_Box.cc b/cpp/box/export_Box.cc index f1ba7eca5..55b380b37 100644 --- a/cpp/box/export_Box.cc +++ b/cpp/box/export_Box.cc @@ -7,8 +7,7 @@ namespace nb = nanobind; namespace freud { namespace box { namespace wrap { -void makeAbsolute(const std::shared_ptr& box, nb_array vecs, - nb_array out) +void makeAbsolute(const std::shared_ptr& box, nb_array vecs, nb_array out) { unsigned int Nvecs = vecs.shape(0); auto* vecs_data = reinterpret_cast*>(vecs.data()); @@ -16,8 +15,7 @@ void makeAbsolute(const std::shared_ptr& box, nb_array vecs, box->makeAbsolute(vecs_data, Nvecs, out_data); } -void makeFractional(const std::shared_ptr& box, nb_array vecs, - nb_array out) +void makeFractional(const std::shared_ptr& box, nb_array vecs, nb_array out) { unsigned int Nvecs = vecs.shape(0); auto* vecs_data = reinterpret_cast*>(vecs.data()); @@ -25,8 +23,7 @@ void makeFractional(const std::shared_ptr& box, nb_array vecs, box->makeFractional(vecs_data, Nvecs, out_data); } -void getImages(const std::shared_ptr& box, nb_array vecs, - nb_array images) +void getImages(const std::shared_ptr& box, nb_array vecs, nb_array images) { const unsigned int Nvecs = vecs.shape(0); auto* vecs_data = reinterpret_cast*>(vecs.data()); @@ -34,8 +31,7 @@ void getImages(const std::shared_ptr& box, nb_array vecs, box->getImages(vecs_data, Nvecs, images_data); } -void wrap(const std::shared_ptr& box, nb_array vecs, - nb_array out) +void wrap(const std::shared_ptr& box, nb_array vecs, nb_array out) { const unsigned int Nvecs = vecs.shape(0); auto* vecs_data = reinterpret_cast*>(vecs.data()); diff --git a/cpp/box/export_Box.h b/cpp/box/export_Box.h index 3223ae343..788d2ae1a 100644 --- a/cpp/box/export_Box.h +++ b/cpp/box/export_Box.h @@ -13,32 +13,26 @@ namespace freud { namespace box { namespace wrap { template> using nb_array = nanobind::ndarray; -void makeAbsolute(const std::shared_ptr& box, nb_array vecs, - nb_array out); +void makeAbsolute(const std::shared_ptr& box, nb_array vecs, nb_array out); -void makeFractional(const std::shared_ptr& box, nb_array vecs, - nb_array out); +void makeFractional(const std::shared_ptr& box, nb_array vecs, nb_array out); -void getImages(const std::shared_ptr& box, nb_array vecs, - nb_array images); +void getImages(const std::shared_ptr& box, nb_array vecs, nb_array images); -void wrap(const std::shared_ptr& box, nb_array vecs, - nb_array out); +void wrap(const std::shared_ptr& box, nb_array vecs, nb_array out); -void unwrap(const std::shared_ptr& box, nb_array vecs, - nb_array images, nb_array out); +void unwrap(const std::shared_ptr& box, nb_array vecs, nb_array images, nb_array out); std::vector centerOfMass(const std::shared_ptr& box, nb_array vecs, nb_array> masses); -void center(const std::shared_ptr& box, nb_array vecs, - nb_array> masses); +void center(const std::shared_ptr& box, nb_array vecs, nb_array> masses); -void computeDistances(const std::shared_ptr& box, nb_array query_points, - nb_array points, nb_array> distances); +void computeDistances(const std::shared_ptr& box, nb_array query_points, nb_array points, + nb_array> distances); void computeAllDistances(const std::shared_ptr& box, nb_array query_points, - nb_array points, nb_array> distances); + nb_array points, nb_array> distances); void contains(const std::shared_ptr& box, nb_array points, nb_array> contains_mask); diff --git a/cpp/locality/CMakeLists.txt b/cpp/locality/CMakeLists.txt index 1f1ea58c3..b29c19984 100644 --- a/cpp/locality/CMakeLists.txt +++ b/cpp/locality/CMakeLists.txt @@ -1,9 +1,6 @@ set(locality_extension_sources - export_NeighborQuery.cc - export_NeighborList.cc - export_Filter.cc - export_PeriodicBuffer.cc - export_Voronoi.cc) + export_NeighborQuery.cc export_NeighborList.cc export_Filter.cc + export_PeriodicBuffer.cc export_Voronoi.cc) # create the target and add the needed properties nanobind_add_module(_locality SHARED module-locality.cc diff --git a/cpp/locality/PeriodicBuffer.h b/cpp/locality/PeriodicBuffer.h index fb1671200..96c8a1ad9 100644 --- a/cpp/locality/PeriodicBuffer.h +++ b/cpp/locality/PeriodicBuffer.h @@ -4,8 +4,8 @@ #ifndef PERIODIC_BUFFER_H #define PERIODIC_BUFFER_H -#include #include +#include #include "Box.h" #include "NeighborQuery.h" diff --git a/cpp/locality/export_Filter.cc b/cpp/locality/export_Filter.cc index 0586821ec..1cd3cc738 100644 --- a/cpp/locality/export_Filter.cc +++ b/cpp/locality/export_Filter.cc @@ -13,9 +13,8 @@ namespace freud { namespace locality { namespace wrap { -void compute(std::shared_ptr filter, std::shared_ptr nq, - nb_array query_points, std::shared_ptr nlist, - const QueryArgs& qargs) +void compute(std::shared_ptr filter, std::shared_ptr nq, nb_array query_points, + std::shared_ptr nlist, const QueryArgs& qargs) { const auto num_query_points = query_points.shape(0); const auto* query_points_data = (vec3*) query_points.data(); @@ -48,4 +47,3 @@ void export_FilterSANN(nb::module_& m) }; // namespace detail }; }; // namespace freud::locality - diff --git a/cpp/locality/export_Filter.h b/cpp/locality/export_Filter.h index 535a4cd34..09f7975a5 100644 --- a/cpp/locality/export_Filter.h +++ b/cpp/locality/export_Filter.h @@ -18,9 +18,8 @@ namespace wrap { template> using nb_array = nanobind::ndarray; -void compute(std::shared_ptr filter, std::shared_ptr nq, - nb_array query_points, std::shared_ptr nlist, - const QueryArgs& qargs); +void compute(std::shared_ptr filter, std::shared_ptr nq, nb_array query_points, + std::shared_ptr nlist, const QueryArgs& qargs); }; // namespace wrap diff --git a/cpp/locality/export_NeighborList.cc b/cpp/locality/export_NeighborList.cc index 419525168..a3938a2e9 100644 --- a/cpp/locality/export_NeighborList.cc +++ b/cpp/locality/export_NeighborList.cc @@ -27,9 +27,8 @@ void ConstructFromArrays(NeighborList* nlist, nb_array num_points, vectors_data, weights_data); } -void ConstructAllPairs(NeighborList* nlist, nb_array points, - nb_array query_points, const box::Box& box, - const bool exclude_ii) +void ConstructAllPairs(NeighborList* nlist, nb_array points, nb_array query_points, + const box::Box& box, const bool exclude_ii) { const unsigned int num_points = points.shape(0); const auto* points_data = (const vec3*) points.data(); @@ -88,4 +87,3 @@ void export_NeighborBond(nb::module_& m) }; // namespace detail }; }; // namespace freud::locality - diff --git a/cpp/locality/export_NeighborList.h b/cpp/locality/export_NeighborList.h index f7b2518b5..178e05518 100644 --- a/cpp/locality/export_NeighborList.h +++ b/cpp/locality/export_NeighborList.h @@ -17,13 +17,12 @@ template> using nb_array = nanobind::ndarray; void ConstructFromArrays(NeighborList* nlist, nb_array> query_point_indices, - unsigned int num_query_points, nb_array> point_indices, - unsigned int num_points, nb_array vectors, - nb_array> weights); + unsigned int num_query_points, + nb_array> point_indices, unsigned int num_points, + nb_array vectors, nb_array> weights); -void ConstructAllPairs(NeighborList* nlist, nb_array points, - nb_array query_points, const box::Box& box, - const bool exclude_ii); +void ConstructAllPairs(NeighborList* nlist, nb_array points, nb_array query_points, + const box::Box& box, const bool exclude_ii); unsigned int filter(std::shared_ptr nlist, nb_array> filter); diff --git a/cpp/locality/export_NeighborQuery.cc b/cpp/locality/export_NeighborQuery.cc index c0e4ccade..15e470f77 100644 --- a/cpp/locality/export_NeighborQuery.cc +++ b/cpp/locality/export_NeighborQuery.cc @@ -13,8 +13,7 @@ namespace freud { namespace locality { namespace wrap { -std::shared_ptr query(std::shared_ptr nq, - nb_array query_points, +std::shared_ptr query(std::shared_ptr nq, nb_array query_points, const QueryArgs& qargs) { unsigned int n_query_points = query_points.shape(0); @@ -29,8 +28,7 @@ void AABBQueryConstructor(AABBQuery* nq, const box::Box& box, nb_array po new (nq) AABBQuery(box, points_data, n_points); } -void LinkCellConstructor(LinkCell* nq, const box::Box& box, nb_array points, - float cell_width) +void LinkCellConstructor(LinkCell* nq, const box::Box& box, nb_array points, float cell_width) { unsigned int n_points = points.shape(0); vec3* points_data = (vec3*) points.data(); @@ -98,4 +96,3 @@ void export_NeighborQueryIterator(nb::module_& m) }; // namespace detail }; }; // namespace freud::locality - diff --git a/cpp/locality/export_NeighborQuery.h b/cpp/locality/export_NeighborQuery.h index ac0ea91ed..8a8810087 100644 --- a/cpp/locality/export_NeighborQuery.h +++ b/cpp/locality/export_NeighborQuery.h @@ -19,18 +19,14 @@ namespace wrap { template> using nb_array = nanobind::ndarray; -std::shared_ptr query(std::shared_ptr nq, - nb_array query_points, +std::shared_ptr query(std::shared_ptr nq, nb_array query_points, const QueryArgs& qargs); -void AABBQueryConstructor(AABBQuery* nq, const box::Box& box, - nb_array points); +void AABBQueryConstructor(AABBQuery* nq, const box::Box& box, nb_array points); -void LinkCellConstructor(LinkCell* nq, const box::Box& box, - nb_array points, float cell_width); +void LinkCellConstructor(LinkCell* nq, const box::Box& box, nb_array points, float cell_width); -void RawPointsConstructor(RawPoints* nq, const box::Box& box, - nb_array points); +void RawPointsConstructor(RawPoints* nq, const box::Box& box, nb_array points); }; // namespace wrap diff --git a/cpp/locality/export_PeriodicBuffer.cc b/cpp/locality/export_PeriodicBuffer.cc index 4659b5801..24608152c 100644 --- a/cpp/locality/export_PeriodicBuffer.cc +++ b/cpp/locality/export_PeriodicBuffer.cc @@ -3,14 +3,12 @@ #include "export_PeriodicBuffer.h" -#include #include +#include namespace nb = nanobind; -namespace freud { namespace locality { - -namespace detail { +namespace freud { namespace locality { namespace detail { void export_PeriodicBuffer(nb::module_& m) { @@ -23,5 +21,4 @@ void export_PeriodicBuffer(nb::module_& m) .def("getBufferIds", &PeriodicBuffer::getBufferIds); }; -}; }; }; // namespace freud::locality::detail - +}; }; }; // namespace freud::locality::detail diff --git a/cpp/locality/export_PeriodicBuffer.h b/cpp/locality/export_PeriodicBuffer.h index 6ffc8e518..dde94aa70 100644 --- a/cpp/locality/export_PeriodicBuffer.h +++ b/cpp/locality/export_PeriodicBuffer.h @@ -8,14 +8,10 @@ #include -namespace freud { namespace locality { - -namespace detail { +namespace freud { namespace locality { namespace detail { void export_PeriodicBuffer(nanobind::module_& m); -}; // namespace detail - -}; }; // namespace freud::locality +}; }; }; // namespace freud::locality::detail #endif diff --git a/cpp/locality/export_Voronoi.cc b/cpp/locality/export_Voronoi.cc index e6f18f17e..3b5abea11 100644 --- a/cpp/locality/export_Voronoi.cc +++ b/cpp/locality/export_Voronoi.cc @@ -38,7 +38,7 @@ nb::object getPolytopes(std::shared_ptr voro) return polytopes_python; } -}; +}; // namespace wrap namespace detail { @@ -56,4 +56,3 @@ void export_Voronoi(nb::module_& m) }; // namespace detail }; }; // namespace freud::locality - diff --git a/cpp/locality/export_Voronoi.h b/cpp/locality/export_Voronoi.h index fc757876a..6d0cb6c2b 100644 --- a/cpp/locality/export_Voronoi.h +++ b/cpp/locality/export_Voronoi.h @@ -20,8 +20,8 @@ namespace detail { void export_Voronoi(nanobind::module_& m); -}; // namespace detail +}; // namespace detail -}; }; // namespace freud::locality +}; }; // namespace freud::locality #endif diff --git a/cpp/util/export_ManagedArray.h b/cpp/util/export_ManagedArray.h index b0be0bd41..42f55d092 100644 --- a/cpp/util/export_ManagedArray.h +++ b/cpp/util/export_ManagedArray.h @@ -42,7 +42,7 @@ template nanobind::ndarray toNumpyArrayVec return nanobind::ndarray((void*) data_ptr, ndim, &dims[0], self); } -}; // namespace wrap +}; // namespace wrap namespace detail { diff --git a/cpp/util/export_Vector.h b/cpp/util/export_Vector.h index fb64e27bc..8da29c398 100644 --- a/cpp/util/export_Vector.h +++ b/cpp/util/export_Vector.h @@ -6,8 +6,8 @@ #include #include -#include #include +#include #include "VectorMath.h" @@ -18,7 +18,7 @@ namespace wrap { template nanobind::ndarray vectorToNumpyArray(nanobind::object self) { std::vector* self_cpp = nanobind::cast*>(self); - auto dims = { self_cpp->size() }; + auto dims = {self_cpp->size()}; auto ndim = 1; auto data_ptr = self_cpp->data(); return nanobind::ndarray((void*) data_ptr, dims, self); @@ -31,7 +31,7 @@ template nanobind::ndarray vectorToNumpyAr // get array data like before size_t size = self_cpp->size(); - std::initializer_list dims = { size, 3 }; + std::initializer_list dims = {size, 3}; auto ndim = 2; auto data_ptr = self_cpp->data(); @@ -39,14 +39,13 @@ template nanobind::ndarray vectorToNumpyAr return nanobind::ndarray((void*) data_ptr, dims, self); } -}; // namespace wrap +}; // namespace wrap namespace detail { template void export_Vector(nanobind::module_& m, const std::string& name) { - nanobind::class_>(m, name.c_str()) - .def("toNumpyArray", &wrap::vectorToNumpyArray); + nanobind::class_>(m, name.c_str()).def("toNumpyArray", &wrap::vectorToNumpyArray); } template void export_VectorVec3(nanobind::module_& m, const std::string& name) @@ -55,7 +54,7 @@ template void export_VectorVec3(nanobind::module_& m, const std::str .def("toNumpyArray", &wrap::vectorToNumpyArrayVec3); } -}; // namespace detail +}; // namespace detail }; }; // namespace freud::util diff --git a/cpp/util/module-util.cc b/cpp/util/module-util.cc index aa01684b5..3f3492cfb 100644 --- a/cpp/util/module-util.cc +++ b/cpp/util/module-util.cc @@ -21,5 +21,4 @@ NB_MODULE(_util, m) export_Vector(m, "Vector_double"); export_Vector(m, "Vector_unsignedint"); export_VectorVec3(m, "VectorVec3_float"); - } diff --git a/freud/CMakeLists.txt b/freud/CMakeLists.txt index bea04da1e..74fa2c029 100644 --- a/freud/CMakeLists.txt +++ b/freud/CMakeLists.txt @@ -1,4 +1,11 @@ -set(python_files box.py data.py errors.py locality.py parallel.py plot.py util.py) +set(python_files + box.py + data.py + errors.py + locality.py + parallel.py + plot.py + util.py) # cluster.py density.py diffraction.py environment.py order.py pmft.py) install(FILES ${python_files} DESTINATION freud) diff --git a/freud/locality.py b/freud/locality.py index 6c89c17b1..2720a23e2 100644 --- a/freud/locality.py +++ b/freud/locality.py @@ -540,7 +540,9 @@ def from_arrays( if weights is None: weights = np.ones(query_point_indices.shape, dtype=np.float32) - weights = freud.util._convert_array(weights, shape=query_point_indices.shape).copy() + weights = freud.util._convert_array( + weights, shape=query_point_indices.shape + ).copy() result = cls() result._cpp_obj = freud._locality.NeighborList( @@ -840,7 +842,9 @@ class _RawPoints(NeighborQuery): def __init__(self, box, points): # Assume valid set of arguments is passed b = freud.util._convert_box(box) - self._points = freud.util._convert_array(points, shape=(None, 3), dtype=np.float32).copy() + self._points = freud.util._convert_array( + points, shape=(None, 3), dtype=np.float32 + ).copy() self._cpp_obj = freud._locality.RawPoints(b._cpp_obj, self._points)