Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed Sep 4, 2024
1 parent 39915c6 commit 55a0296
Show file tree
Hide file tree
Showing 55 changed files with 200 additions and 184 deletions.
4 changes: 2 additions & 2 deletions freud/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ target_link_libraries(_pmft PUBLIC freud)
target_set_install_rpath(_pmft)

# util
nanobind_add_module(_util util/module-util.cc util/export-ManagedArray.cc util/export-Vector.cc
util/export-Vector.h)
nanobind_add_module(_util util/module-util.cc util/export-ManagedArray.cc
util/export-Vector.cc util/export-Vector.h)
target_link_libraries(_util PUBLIC freud)
target_set_install_rpath(_util)

Expand Down
5 changes: 3 additions & 2 deletions freud/box/Box.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,9 @@ class Box
for (size_t i = 0; i < Nvecs; ++i)
{
vec3<float> const phase(constants::TWO_PI * makeFractional(vecs[i]));
vec3<std::complex<float>> const xi(std::polar(float(1.0), phase.x), std::polar(float(1.0), phase.y),
std::polar(float(1.0), phase.z));
vec3<std::complex<float>> const xi(std::polar(float(1.0), phase.x),
std::polar(float(1.0), phase.y),
std::polar(float(1.0), phase.z));
float const mass = (masses != nullptr) ? masses[i] : float(1.0);
total_mass += mass;
xi_mean += std::complex<float>(mass, 0) * xi;
Expand Down
12 changes: 7 additions & 5 deletions freud/box/export-Box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <vector>

#include "Box.h"
#include "export-Box.h"
#include "VectorMath.h"
#include "export-Box.h"
#include "nanobind/ndarray.h"

namespace nb = nanobind;
Expand Down Expand Up @@ -46,7 +46,8 @@ void wrap(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb
box->wrap(vecs_data, Nvecs, out_data);
}

void unwrap(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb_array<int>& images, const nb_array<float>& out)
void unwrap(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb_array<int>& images,
const nb_array<float>& out)
{
const unsigned int Nvecs = vecs.shape(0);
auto* vecs_data = reinterpret_cast<vec3<float>*>(vecs.data());
Expand All @@ -65,16 +66,17 @@ std::vector<float> centerOfMass(const std::shared_ptr<Box>& box, const nb_array<
return {com.x, com.y, com.z};
}

void center(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb_array<float, nb::ndim<1>>& masses)
void center(const std::shared_ptr<Box>& box, const nb_array<float>& vecs,
const nb_array<float, nb::ndim<1>>& masses)
{
const unsigned int Nvecs = vecs.shape(0);
auto* vecs_data = reinterpret_cast<vec3<float>*>(vecs.data());
auto* masses_data = reinterpret_cast<float*>(masses.data());
box->center(vecs_data, Nvecs, masses_data);
}

void computeDistances(const std::shared_ptr<Box>& box, const nb_array<float>& query_points, const nb_array<float>& points,
const nb_array<float, nb::ndim<1>>& distances)
void computeDistances(const std::shared_ptr<Box>& box, const nb_array<float>& query_points,
const nb_array<float>& points, const nb_array<float, nb::ndim<1>>& distances)
{
const unsigned int n_query_points = query_points.shape(0);
auto* query_points_data = reinterpret_cast<vec3<float>*>(query_points.data());
Expand Down
10 changes: 6 additions & 4 deletions freud/box/export-Box.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ void getImages(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, con

void wrap(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb_array<float>& out);

void unwrap(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb_array<int>& images, const nb_array<float>& out);
void unwrap(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb_array<int>& images,
const nb_array<float>& out);

std::vector<float> centerOfMass(const std::shared_ptr<Box>& box, const nb_array<float>& vecs,
const nb_array<float, nanobind::shape<-1>>& masses);

void center(const std::shared_ptr<Box>& box, const nb_array<float>& vecs, const nb_array<float, nanobind::ndim<1>>& masses);
void center(const std::shared_ptr<Box>& box, const nb_array<float>& vecs,
const nb_array<float, nanobind::ndim<1>>& masses);

void computeDistances(const std::shared_ptr<Box>& box, const nb_array<float>& query_points, const nb_array<float>& points,
const nb_array<float, nanobind::ndim<1>>& distances);
void computeDistances(const std::shared_ptr<Box>& box, const nb_array<float>& query_points,
const nb_array<float>& points, const nb_array<float, nanobind::ndim<1>>& distances);

void computeAllDistances(const std::shared_ptr<Box>& box, const nb_array<float>& query_points,
const nb_array<float>& points, const nb_array<float, nanobind::ndim<2>>& distances);
Expand Down
8 changes: 5 additions & 3 deletions freud/box/module-box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@

#include <nanobind/nanobind.h>
#include <nanobind/nb_defs.h>
#include <nanobind/stl/shared_ptr.h> // NOLINT(misc-include-cleaner): used implicitly
#include <nanobind/stl/vector.h> // NOLINT(misc-include-cleaner): used implicitly
#include <nanobind/stl/shared_ptr.h> // NOLINT(misc-include-cleaner): used implicitly
#include <nanobind/stl/vector.h> // NOLINT(misc-include-cleaner): used implicitly

#include "Box.h"
#include "export-Box.h"

using namespace freud::box;

NB_MODULE(_box, module) // NOLINT(misc-use-anonymous-namespace): We have no control over nanobind module definitions.
NB_MODULE(
_box,
module) // NOLINT(misc-use-anonymous-namespace): We have no control over nanobind module definitions.
{
nanobind::class_<Box>(module, "Box")
// constructors
Expand Down
8 changes: 4 additions & 4 deletions freud/locality/AABB.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ inline bool overlap(const AABB& a, const AABB& b)
return (r0 == 0 && r1 == 0);

#else
return b.upper.x >= a.lower.x && b.lower.x <= a.upper.x && b.upper.y >= a.lower.y && b.lower.y <= a.upper.y
&& b.upper.z >= a.lower.z && b.lower.z <= a.upper.z;
return b.upper.x >= a.lower.x && b.lower.x <= a.upper.x && b.upper.y >= a.lower.y
&& b.lower.y <= a.upper.y && b.upper.z >= a.lower.z && b.lower.z <= a.upper.z;

#endif
}
Expand All @@ -317,8 +317,8 @@ inline bool overlap(const AABB& a, const AABBSphere& b)

#else
vec3<float> const dr = vec3<float>(std::min(std::max(b.position.x, a.lower.x), a.upper.x) - b.position.x,
std::min(std::max(b.position.y, a.lower.y), a.upper.y) - b.position.y,
std::min(std::max(b.position.z, a.lower.z), a.upper.z) - b.position.z);
std::min(std::max(b.position.y, a.lower.y), a.upper.y) - b.position.y,
std::min(std::max(b.position.z, a.lower.z), a.upper.z) - b.position.z);
float const dr2 = dot(dr, dr);
return dr2 < b.radius * b.radius;

Expand Down
15 changes: 8 additions & 7 deletions freud/locality/AABBQuery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// This file is from the freud project, released under the BSD 3-Clause License.

#include <algorithm>
#include <memory>
#include <cmath>
#include <memory>
#include <stdexcept>

#include "AABB.h"
#include "AABBQuery.h"
#include "Box.h"
#include "VectorMath.h"
#include "NeighborQuery.h"
#include "NeighborBond.h"
#include "AABB.h"
#include "NeighborQuery.h"
#include "VectorMath.h"

namespace freud { namespace locality {

Expand Down Expand Up @@ -239,9 +239,10 @@ NeighborBond AABBQueryIterator::next()
m_current_neighbors.clear();
m_all_bonds_minimum_distance.clear();
m_query_points_below_r_min.clear();
std::shared_ptr<NeighborQueryPerPointIterator> const ball_it = std::make_shared<AABBQueryBallIterator>(
static_cast<const AABBQuery*>(m_neighbor_query), m_query_point, m_query_point_idx,
std::min(m_r_cur, m_r_max), 0, m_exclude_ii, false);
std::shared_ptr<NeighborQueryPerPointIterator> const ball_it
= std::make_shared<AABBQueryBallIterator>(static_cast<const AABBQuery*>(m_neighbor_query),
m_query_point, m_query_point_idx,
std::min(m_r_cur, m_r_max), 0, m_exclude_ii, false);
while (!ball_it->end())
{
NeighborBond nb = ball_it->next();
Expand Down
22 changes: 11 additions & 11 deletions freud/locality/AABBQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ class AABBQueryIterator : public AABBIterator
AABBQueryIterator(const AABBQuery* neighbor_query, const vec3<float>& query_point,
unsigned int query_point_idx, unsigned int num_neighbors, float r_guess, float r_max,
float r_min, float scale, bool exclude_ii)
: AABBIterator(neighbor_query, query_point, query_point_idx, r_max, r_min, exclude_ii),
m_num_neighbors(num_neighbors), m_r_cur(r_guess), m_scale(scale),
m_all_bonds_minimum_distance(), m_query_points_below_r_min()
: AABBIterator(neighbor_query, query_point, query_point_idx, r_max, r_min, exclude_ii),
m_num_neighbors(num_neighbors), m_r_cur(r_guess), m_scale(scale), m_all_bonds_minimum_distance(),
m_query_points_below_r_min()
{
updateImageVectors(0);
}
Expand All @@ -166,11 +166,11 @@ class AABBQueryIterator : public AABBIterator
NeighborBond next() override;

protected:
unsigned int m_count{0}; //!< Number of neighbors returned for the current point.
unsigned int m_count {0}; //!< Number of neighbors returned for the current point.
unsigned int m_num_neighbors; //!< Number of nearest neighbors to find
std::vector<NeighborBond> m_current_neighbors; //!< The current set of found neighbors.
bool m_search_extended{false}; //!< Flag to see whether we've gone past the safe cutoff distance and have to be
//!< worried about finding duplicates.
bool m_search_extended {false}; //!< Flag to see whether we've gone past the safe cutoff distance and have
//!< to be worried about finding duplicates.
float
m_r_cur; //!< Current search ball cutoff distance in use for the current particle (expands as needed).
float m_scale; //!< The amount to scale m_r by when the current ball is too small.
Expand All @@ -189,7 +189,7 @@ class AABBQueryBallIterator : public AABBIterator
AABBQueryBallIterator(const AABBQuery* neighbor_query, const vec3<float>& query_point,
unsigned int query_point_idx, float r_max, float r_min, bool exclude_ii,
bool _check_r_max = true)
: AABBIterator(neighbor_query, query_point, query_point_idx, r_max, r_min, exclude_ii)
: AABBIterator(neighbor_query, query_point, query_point_idx, r_max, r_min, exclude_ii)
{
updateImageVectors(m_r_max, _check_r_max);
}
Expand All @@ -201,10 +201,10 @@ class AABBQueryBallIterator : public AABBIterator
NeighborBond next() override;

private:
unsigned int cur_image{0}; //!< The current node in the tree.
unsigned int cur_node_idx{0}; //!< The current node in the tree.
unsigned int
cur_ref_p{0}; //!< The current index into the reference particles in the current node of the tree.
unsigned int cur_image {0}; //!< The current node in the tree.
unsigned int cur_node_idx {0}; //!< The current node in the tree.
unsigned int cur_ref_p {
0}; //!< The current index into the reference particles in the current node of the tree.
};
}; }; // end namespace freud::locality

Expand Down
6 changes: 3 additions & 3 deletions freud/locality/BondHistogramCompute.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "NeighborComputeFunctional.h"
#include "NeighborList.h"
#include "NeighborQuery.h"
#include "VectorMath.h"
#include <cstddef>
#include <memory>
#include <vector>
#include <utility>
#include <cstddef>
#include "VectorMath.h"
#include <vector>

namespace freud { namespace locality {

Expand Down
6 changes: 3 additions & 3 deletions freud/locality/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include "NeighborQuery.h"
#include "VectorMath.h"
#include <iostream>
#include <memory>
#include <vector>
#include <string>
#include <limits>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>

namespace freud { namespace locality {

Expand Down
6 changes: 3 additions & 3 deletions freud/locality/FilterRAD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include "Filter.h"
#include "NeighborBond.h"
#include "NeighborComputeFunctional.h"
#include "NeighborList.h"
#include "NeighborQuery.h"
#include "VectorMath.h"
#include "NeighborList.h"
#include "utils.h"
#include <memory>
#include <cstddef>
#include <limits>
#include <memory>
#include <oneapi/tbb/enumerable_thread_specific.h>
#include <cstddef>
#include <oneapi/tbb/parallel_sort.h>
#include <tbb/enumerable_thread_specific.h>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion freud/locality/FilterRAD.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include "NeighborList.h"
#include "NeighborQuery.h"
#include <memory>
#include "VectorMath.h"
#include <memory>

namespace freud { namespace locality {

Expand Down
6 changes: 3 additions & 3 deletions freud/locality/FilterSANN.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include "Filter.h"
#include "NeighborBond.h"
#include "NeighborComputeFunctional.h"
#include "NeighborList.h"
#include "NeighborQuery.h"
#include "VectorMath.h"
#include "NeighborList.h"
#include "utils.h"
#include <cstddef>
#include <limits>
#include <memory>
#include <oneapi/tbb/enumerable_thread_specific.h>
#include <limits>
#include <cstddef>
#include <oneapi/tbb/parallel_sort.h>
#include <tbb/enumerable_thread_specific.h>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion freud/locality/FilterSANN.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include "NeighborList.h"
#include "NeighborQuery.h"
#include <memory>
#include "VectorMath.h"
#include <memory>
#include <vector>

namespace freud { namespace locality {
Expand Down
14 changes: 6 additions & 8 deletions freud/locality/LinkCell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <stdexcept>
#include <vector>

#include "LinkCell.h"
#include "NeighborQuery.h"
#include "Box.h"
#include "VectorMath.h"
#include "LinkCell.h"
#include "ManagedArray.h"
#include "NeighborBond.h"
#include "NeighborQuery.h"
#include "VectorMath.h"

/*! \file LinkCell.cc
\brief Build a cell list from a set of points.
Expand Down Expand Up @@ -350,9 +350,7 @@ unsigned int LinkCell::coordToIndex(unsigned int x, unsigned int y, unsigned int
// For backwards compatibility with the Index1D layout, the indices and
// the dimensions are passed in reverse to the indexer. Changing this would
// also require updating the logic in IteratorCellShell.
return util::ManagedArray<unsigned int>::getIndex(
{m_celldim.z, m_celldim.y, m_celldim.x},
{z, y, x});
return util::ManagedArray<unsigned int>::getIndex({m_celldim.z, m_celldim.y, m_celldim.x}, {z, y, x});
}

vec3<unsigned int> LinkCell::getCellCoord(const vec3<float>& p) const
Expand Down Expand Up @@ -551,7 +549,7 @@ NeighborBond LinkCellQueryBallIterator::next()
const unsigned int neighbor_cell_index = m_linkcell->getCellIndex(
vec3<int>(point_cell.x, point_cell.y, point_cell.z) + (*m_neigh_cell_iter));
// NOLINTEND(bugprone-narrowing-conversions)

// Insertion to an unordered set returns a pair, the second
// element indicates insertion success or failure (if it
// already exists)
Expand Down Expand Up @@ -637,7 +635,7 @@ NeighborBond LinkCellQueryIterator::next()
const unsigned int neighbor_cell_index = m_linkcell->getCellIndex(
vec3<int>(point_cell.x, point_cell.y, point_cell.z) + (*m_neigh_cell_iter));
// NOLINTEND(bugprone-narrowing-conversions)

// Insertion to an unordered set returns a pair, the second
// element indicates insertion success or failure (if it
// already exists)
Expand Down
4 changes: 2 additions & 2 deletions freud/locality/LinkCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class LinkCellQueryIterator : public LinkCellIterator
unsigned int query_point_idx, unsigned int num_neighbors, float r_max, float r_min,
bool exclude_ii)
: LinkCellIterator(neighbor_query, query_point, query_point_idx, r_max, r_min, exclude_ii),
m_num_neighbors(num_neighbors)
m_num_neighbors(num_neighbors)
{}

//! Empty Destructor
Expand All @@ -301,7 +301,7 @@ class LinkCellQueryIterator : public LinkCellIterator
NeighborBond next() override;

protected:
unsigned int m_count{0}; //!< Number of neighbors returned for the current point.
unsigned int m_count {0}; //!< Number of neighbors returned for the current point.
unsigned int m_num_neighbors; //!< Number of nearest neighbors to find
std::vector<NeighborBond> m_current_neighbors; //!< The current set of found neighbors.
};
Expand Down
2 changes: 1 addition & 1 deletion freud/locality/NeighborComputeFunctional.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// This file is from the freud project, released under the BSD 3-Clause License.

#include "NeighborComputeFunctional.h"
#include <memory>
#include "NeighborList.h"
#include "NeighborQuery.h"
#include "VectorMath.h"
#include <memory>

/*! \file NeighborComputeFunctional.h
\brief Implements logic for generic looping over neighbors and applying a compute function.
Expand Down
5 changes: 3 additions & 2 deletions freud/locality/NeighborComputeFunctional.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ void loopOverNeighborsIterator(const NeighborQuery* neighbor_query, const vec3<f
*/
template<typename ComputePairType>
void loopOverNeighbors(const std::shared_ptr<NeighborQuery>& neighbor_query, const vec3<float>* query_points,
unsigned int n_query_points, QueryArgs qargs, const std::shared_ptr<NeighborList>& nlist,
const ComputePairType& cf, bool parallel = true)
unsigned int n_query_points, QueryArgs qargs,
const std::shared_ptr<NeighborList>& nlist, const ComputePairType& cf,
bool parallel = true)
{
// check if nlist exists
if (nlist != nullptr)
Expand Down
Loading

0 comments on commit 55a0296

Please sign in to comment.