From 587fd887a8ee8d1f1cdeaa8671a1d56402d7a988 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:24:09 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cpp/pmft/CMakeLists.txt | 3 +- cpp/pmft/PMFTXYZ.cc | 2 +- cpp/pmft/PMFTXYZ.h | 9 +++-- cpp/pmft/export-PMFTXYZ.cc | 14 ++++--- cpp/pmft/module-pmft.cc | 4 +- freud/pmft.py | 79 ++++++++++++++++++++------------------ 6 files changed, 60 insertions(+), 51 deletions(-) diff --git a/cpp/pmft/CMakeLists.txt b/cpp/pmft/CMakeLists.txt index 89b1f8ce6..4e953cafd 100644 --- a/cpp/pmft/CMakeLists.txt +++ b/cpp/pmft/CMakeLists.txt @@ -1,4 +1,5 @@ -nanobind_add_module(_pmft ${freud_nanobind_linking} module-pmft.cc export-PMFTXY.cc export-PMFTXYZ.cc) +nanobind_add_module(_pmft ${freud_nanobind_linking} module-pmft.cc + export-PMFTXY.cc export-PMFTXYZ.cc) target_link_libraries(_pmft PUBLIC libfreud) target_set_install_rpath(_pmft) diff --git a/cpp/pmft/PMFTXYZ.cc b/cpp/pmft/PMFTXYZ.cc index 2131adb38..2f4397c8e 100644 --- a/cpp/pmft/PMFTXYZ.cc +++ b/cpp/pmft/PMFTXYZ.cc @@ -78,7 +78,7 @@ void PMFTXYZ::reduce() // reallocate the data arrays so we don't overwrite copies of the data the user may have made m_pcf_array = std::make_shared>(m_pcf_array->shape()); m_histogram = BondHistogram(m_histogram.getAxes()); - + float inv_num_dens = m_box.getVolume() / (float) m_n_query_points; float norm_factor = (float) 1.0 / ((float) m_frame_counter * (float) m_n_points * (float) m_num_equiv_orientations); diff --git a/cpp/pmft/PMFTXYZ.h b/cpp/pmft/PMFTXYZ.h index fec2970b0..8b28b1d58 100644 --- a/cpp/pmft/PMFTXYZ.h +++ b/cpp/pmft/PMFTXYZ.h @@ -21,10 +21,11 @@ class PMFTXYZ : public PMFT /*! Compute the PCF for the passed in set of points. The function will be added to previous values of the pcf */ - void accumulate(std::shared_ptr neighbor_query, const quat* query_orientations, - const vec3* query_points, unsigned int n_query_points, - const quat* equiv_orientations, unsigned int num_equiv_orientations, - std::shared_ptr nlist, const freud::locality::QueryArgs& qargs); + void accumulate(std::shared_ptr neighbor_query, + const quat* query_orientations, const vec3* query_points, + unsigned int n_query_points, const quat* equiv_orientations, + unsigned int num_equiv_orientations, std::shared_ptr nlist, + const freud::locality::QueryArgs& qargs); //! Reset the PMFT /*! Override the parent method to also reset the number of equivalent orientations. diff --git a/cpp/pmft/export-PMFTXYZ.cc b/cpp/pmft/export-PMFTXYZ.cc index b4d1ef21c..178eea29c 100644 --- a/cpp/pmft/export-PMFTXYZ.cc +++ b/cpp/pmft/export-PMFTXYZ.cc @@ -15,17 +15,18 @@ using nb_array = nanobind::ndarray self, std::shared_ptr nq, - nb_array> query_orientations, - nb_array> query_points, - nb_array> equivalent_orientations, - std::shared_ptr nlist, const locality::QueryArgs& qargs) + nb_array> query_orientations, + nb_array> query_points, + nb_array> equivalent_orientations, + std::shared_ptr nlist, const locality::QueryArgs& qargs) { unsigned int num_query_points = query_points.shape(0); auto* query_orientations_data = reinterpret_cast*>(query_orientations.data()); auto* query_points_data = reinterpret_cast*>(query_points.data()); auto* equivalent_orientations_data = reinterpret_cast*>(equivalent_orientations.data()); unsigned int num_equivalent_orientations = equivalent_orientations.shape(0); - self->accumulate(nq, query_orientations_data, query_points_data, num_query_points, equivalent_orientations_data, num_equivalent_orientations, nlist, qargs); + self->accumulate(nq, query_orientations_data, query_points_data, num_query_points, + equivalent_orientations_data, num_equivalent_orientations, nlist, qargs); } }; // namespace wrap @@ -37,7 +38,8 @@ void export_PMFTXYZ(nanobind::module_& m) nanobind::class_(m, "PMFTXYZ") .def(nanobind::init()) .def("accumulate", &wrap::accumulateXYZ, nanobind::arg("nq"), nanobind::arg("query_orientations"), - nanobind::arg("query_points"), nanobind::arg("equiv_orientations"), nanobind::arg("nlist").none(), nanobind::arg("qargs")); + nanobind::arg("query_points"), nanobind::arg("equiv_orientations"), + nanobind::arg("nlist").none(), nanobind::arg("qargs")); } } // namespace detail diff --git a/cpp/pmft/module-pmft.cc b/cpp/pmft/module-pmft.cc index 76a582c6a..1a9ccb492 100644 --- a/cpp/pmft/module-pmft.cc +++ b/cpp/pmft/module-pmft.cc @@ -4,11 +4,11 @@ #include namespace freud::pmft::detail { - + void export_PMFT(nanobind::module_& m); void export_PMFTXY(nanobind::module_& m); void export_PMFTXYZ(nanobind::module_& m); -} +} // namespace freud::pmft::detail using namespace freud::pmft::detail; diff --git a/freud/pmft.py b/freud/pmft.py index e62079f86..9f8b45b1e 100644 --- a/freud/pmft.py +++ b/freud/pmft.py @@ -480,7 +480,12 @@ def __init__(self, x_max, y_max, z_max, bins, shiftvec=[0, 0, 0]): n_x = n_y = n_z = bins self._cpp_obj = freud._pmft.PMFTXYZ( - x_max, y_max, z_max, n_x, n_y, n_z, + x_max, + y_max, + z_max, + n_x, + n_y, + n_z, ) self.shiftvec = np.array(shiftvec, dtype=np.float32) self.r_max = np.sqrt(x_max**2 + y_max**2 + z_max**2) @@ -496,42 +501,42 @@ def compute( ): r"""Calculates the PMFT. - .. note:: - The orientations of the system points are irrelevant for this - calculation because that dimension is integrated out. The provided - ``query_orientations`` are therefore always associated with - ``query_points`` (which are equal to the system points if no - ``query_points`` are explicitly provided. - - Args: - system: - Any object that is a valid argument to - :class:`freud.locality.NeighborQuery.from_system`. - query_orientations ((:math:`N_{points}`, 4) :class:`numpy.ndarray`): - Query orientations associated with query points that are used - to calculate bonds. - query_points ((:math:`N_{query\_points}`, 3) :class:`numpy.ndarray`, optional): - Query points used to calculate the PMFT. Uses the system's - points if :code:`None` (Default value = :code:`None`). - equiv_orientations ((:math:`N_{faces}`, 4) :class:`numpy.ndarray`, optional): - Orientations to be treated as equivalent to account for - symmetry of the points. For instance, if the - :code:`query_points` are rectangular prisms with the long axis - & corresponding to the x-axis, then a point at :math:`(1, 0, 0)` - and a point at :math:`(-1, 0, 0)` are symmetrically equivalent - and can be counted towards both the positive and negative bins. - If not supplied by user or :code:`None`, a unit quaternion will - be used (Default value = :code:`None`). - neighbors (:class:`freud.locality.NeighborList` or dict, optional): - Either a :class:`NeighborList ` of - neighbor pairs to use in the calculation, or a dictionary of - `query arguments - `_ - (Default value: None). - reset (bool): - Whether to erase the previously computed values before adding - the new computation; if False, will accumulate data (Default - value: True). + .. note:: + The orientations of the system points are irrelevant for this + calculation because that dimension is integrated out. The provided + ``query_orientations`` are therefore always associated with + ``query_points`` (which are equal to the system points if no + ``query_points`` are explicitly provided. + + Args: + system: + Any object that is a valid argument to + :class:`freud.locality.NeighborQuery.from_system`. + query_orientations ((:math:`N_{points}`, 4) :class:`numpy.ndarray`): + Query orientations associated with query points that are used + to calculate bonds. + query_points ((:math:`N_{query\_points}`, 3) :class:`numpy.ndarray`, optional): + Query points used to calculate the PMFT. Uses the system's + points if :code:`None` (Default value = :code:`None`). + equiv_orientations ((:math:`N_{faces}`, 4) :class:`numpy.ndarray`, optional): + Orientations to be treated as equivalent to account for + symmetry of the points. For instance, if the + :code:`query_points` are rectangular prisms with the long axis + & corresponding to the x-axis, then a point at :math:`(1, 0, 0)` + and a point at :math:`(-1, 0, 0)` are symmetrically equivalent + and can be counted towards both the positive and negative bins. + If not supplied by user or :code:`None`, a unit quaternion will + be used (Default value = :code:`None`). + neighbors (:class:`freud.locality.NeighborList` or dict, optional): + Either a :class:`NeighborList ` of + neighbor pairs to use in the calculation, or a dictionary of + `query arguments + `_ + (Default value: None). + reset (bool): + Whether to erase the previously computed values before adding + the new computation; if False, will accumulate data (Default + value: True). """ # noqa: E501 if reset: self._reset()