Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 24, 2024
1 parent 007cb90 commit 19be3de
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
48 changes: 24 additions & 24 deletions cpp/box/export_Box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,73 +11,73 @@ void makeAbsolute(const std::shared_ptr<Box>& box, nb_array<float, nb::shape<-1,
nb_array<float, nb::shape<-1, 3>> out)
{
unsigned int Nvecs = vecs.shape(0);
auto *vecs_data = reinterpret_cast<vec3<float>*>(vecs.data());
auto *out_data = reinterpret_cast<vec3<float>*>(out.data());
auto* vecs_data = reinterpret_cast<vec3<float>*>(vecs.data());
auto* out_data = reinterpret_cast<vec3<float>*>(out.data());
box->makeAbsolute(vecs_data, Nvecs, out_data);
}

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

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

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

void unwrap(const std::shared_ptr<Box>& box, nb_array<float> vecs, nb_array<int> images, nb_array<float> out)
{
const unsigned int Nvecs = vecs.shape(0);
auto *vecs_data = reinterpret_cast<vec3<float>*>(vecs.data());
auto *images_data = reinterpret_cast<vec3<int>*>(images.data());
auto *out_data = reinterpret_cast<vec3<float>*>(out.data());
auto* vecs_data = reinterpret_cast<vec3<float>*>(vecs.data());
auto* images_data = reinterpret_cast<vec3<int>*>(images.data());
auto* out_data = reinterpret_cast<vec3<float>*>(out.data());
box->unwrap(vecs_data, images_data, Nvecs, out_data);
}

std::vector<float> centerOfMass(const std::shared_ptr<Box>& box, nb_array<float> vecs,
nb_array<float, nb::shape<-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());
auto *com = box->centerOfMass(vecs_data, Nvecs, masses_data);
auto* vecs_data = reinterpret_cast<vec3<float>*>(vecs.data());
auto* masses_data = reinterpret_cast<float*>(masses.data());
auto* com = box->centerOfMass(vecs_data, Nvecs, masses_data);
return {com.x, com.y, com.z};
}

void center(const std::shared_ptr<Box>& box, nb_array<float> vecs, 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());
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, nb_array<float> query_points, nb_array<float> points,
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());
auto* query_points_data = reinterpret_cast<vec3<float>*>(query_points.data());
const unsigned int n_points = points.shape(0);
auto *points_data = reinterpret_cast<vec3<float>*>(points.data());
auto *distances_data = reinterpret_cast<float*>(distances.data());
auto* points_data = reinterpret_cast<vec3<float>*>(points.data());
auto* distances_data = reinterpret_cast<float*>(distances.data());
if (n_query_points != n_points)
{
throw std::invalid_argument("The number of query points and points must match.");
Expand All @@ -89,19 +89,19 @@ void computeAllDistances(const std::shared_ptr<Box>& box, nb_array<float> query_
nb_array<float> points, nb_array<float, nb::ndim<2>> distances)
{
const unsigned int n_query_points = query_points.shape(0);
auto *query_points_data = reinterpret_cast<vec3<float>*>(query_points.data());
auto* query_points_data = reinterpret_cast<vec3<float>*>(query_points.data());
const unsigned int n_points = points.shape(0);
auto *points_data = reinterpret_cast<vec3<float>*>(points.data());
auto *distances_data = reinterpret_cast<float*>(distances.data());
auto* points_data = reinterpret_cast<vec3<float>*>(points.data());
auto* distances_data = reinterpret_cast<float*>(distances.data());
box->computeAllDistances(query_points_data, n_query_points, points_data, n_points, distances_data);
}

void contains(const std::shared_ptr<Box>& box, nb_array<float> points,
nb_array<bool, nb::ndim<1>> contains_mask)
{
const unsigned int n_points = points.shape(0);
auto *points_data = reinterpret_cast<vec3<float>*>(points.data());
auto *contains_mask_data = reinterpret_cast<bool*>(contains_mask.data());
auto* points_data = reinterpret_cast<vec3<float>*>(points.data());
auto* contains_mask_data = reinterpret_cast<bool*>(contains_mask.data());
box->contains(points_data, n_points, contains_mask_data);
}

Expand Down
22 changes: 11 additions & 11 deletions cpp/box/export_Box.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ namespace freud { namespace box { namespace wrap {
template<typename T, typename shape = nanobind::shape<-1, 3>>
using nb_array = nanobind::ndarray<T, shape, nanobind::device::cpu, nanobind::c_contig>;

void makeAbsolute(const std::shared_ptr<Box> &box, nb_array<float, nanobind::shape<-1, 3>> vecs,
void makeAbsolute(const std::shared_ptr<Box>& box, nb_array<float, nanobind::shape<-1, 3>> vecs,
nb_array<float, nanobind::shape<-1, 3>> out);

void makeFractional(const std::shared_ptr<Box> &box, nb_array<float, nanobind::shape<-1, 3>> vecs,
void makeFractional(const std::shared_ptr<Box>& box, nb_array<float, nanobind::shape<-1, 3>> vecs,
nb_array<float, nanobind::shape<-1, 3>> out);

void getImages(const std::shared_ptr<Box> &box, nb_array<float, nanobind::shape<-1, 3>> vecs,
void getImages(const std::shared_ptr<Box>& box, nb_array<float, nanobind::shape<-1, 3>> vecs,
nb_array<int, nanobind::shape<-1, 3>> images);

void wrap(const std::shared_ptr<Box> &box, nb_array<float, nanobind::shape<-1, 3>> vecs,
void wrap(const std::shared_ptr<Box>& box, nb_array<float, nanobind::shape<-1, 3>> vecs,
nb_array<float, nanobind::shape<-1, 3>> out);

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

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

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

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

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

void contains(const std::shared_ptr<Box> &box, nb_array<float> points,
void contains(const std::shared_ptr<Box>& box, nb_array<float> points,
nb_array<bool, nanobind::ndim<1>> contains_mask);

}; }; }; // namespace freud::box::wrap
Expand Down

0 comments on commit 19be3de

Please sign in to comment.