Skip to content

Commit

Permalink
Merge pull request #1227 from glotzerlab/remove-translational
Browse files Browse the repository at this point in the history
Remove Translational OP
  • Loading branch information
tommy-waltmann committed Mar 1, 2024
2 parents 6e78725 + 5da702b commit 403eb9e
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 212 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to
### Added
* New continuous coordination number compute `freud.order.ContinuousCoordination`.

### Removed
* `freud.order.Translational`.

## v3.0.0 -- 2024-02-22

### Added
Expand Down
42 changes: 0 additions & 42 deletions benchmarks/benchmark_order_Translational.py

This file was deleted.

9 changes: 0 additions & 9 deletions cpp/order/HexaticTranslational.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,4 @@ void Hexatic::compute(const freud::locality::NeighborList* nlist,
nlist, points, qargs, false);
}

Translational::Translational(float k, bool weighted) : HexaticTranslational<float>(k, weighted) {}

void Translational::compute(const freud::locality::NeighborList* nlist,
const freud::locality::NeighborQuery* points, freud::locality::QueryArgs qargs)
{
computeGeneral([](const vec3<float>& delta) { return std::complex<float>(delta.x, delta.y); }, nlist,
points, qargs, true);
}

}; }; // namespace freud::order
19 changes: 1 addition & 18 deletions cpp/order/HexaticTranslational.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace freud { namespace order {

//! Parent class for Hexatic and Translational
//! Parent class for Hexatic
/*!
*/
template<typename T> class HexaticTranslational
Expand Down Expand Up @@ -77,23 +77,6 @@ class Hexatic : public HexaticTranslational<unsigned int>
freud::locality::QueryArgs qargs);
};

//! Compute the translational order parameter for a set of points
/*! THIS CLASS IS DEPRECATED AND WILL BE REMOVED IN THE NEXT MAJOR RELEASE OF FREUD.
*/
class Translational : public HexaticTranslational<float>
{
public:
//! Constructor
Translational(float k = 6, bool weighted = false);

//! Destructor
~Translational() override = default;

//! Compute the translational order parameter
void compute(const freud::locality::NeighborList* nlist, const freud::locality::NeighborQuery* points,
freud::locality::QueryArgs qargs);
};

}; }; // end namespace freud::order

#endif // HEXATIC_TRANSLATIONAL_H
3 changes: 3 additions & 0 deletions doc/source/gettingstarted/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ Overview of API Changes
* - Compute nematic order parameter.
- ``freud.order.Nematic(u=director).compute(orientations=quaternions)``
- ``freud.order.Nematic().compute(orientations=orientation_vectors)``
* - Find translational order in 2D systems.
- Use ``freud.order.Translational`` or ``freud.order.Hexatic``.
- Use ``freud.order.Hexatic``.
1 change: 0 additions & 1 deletion doc/source/modules/order.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Order Module
freud.order.Cubatic
freud.order.Nematic
freud.order.Hexatic
freud.order.Translational
freud.order.Steinhardt
freud.order.SolidLiquid
freud.order.RotationalAutocorrelation
Expand Down
9 changes: 0 additions & 9 deletions freud/_order.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ cdef extern from "HexaticTranslational.h" namespace "freud::order":
unsigned int getK()
bool isWeighted() const

cdef cppclass Translational:
Translational(float, bool)
void compute(const freud._locality.NeighborList*,
const freud._locality.NeighborQuery*,
freud._locality.QueryArgs) except +
const freud.util.ManagedArray[fcomplex] &getOrder() const
float getK() const
bool isWeighted() const


cdef extern from "Steinhardt.h" namespace "freud::order":
cdef cppclass Steinhardt:
Expand Down
88 changes: 0 additions & 88 deletions freud/order.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -412,94 +412,6 @@ cdef class Hexatic(_PairCompute):
return None


cdef class Translational(_PairCompute):
r"""Compute the translational order parameter for each particle.
The translational order parameter is used to measure order in the bonds
of 2D systems. The translational order parameter for a particle :math:`i`
and its :math:`N_b` neighbors :math:`j` is given by a sum over the
neighbors, treating the 2D vectors between each pair of particles as a
complex number with real part corresponding to the x-component of the
vector and imaginary part corresponding to the y-component of the vector,
divided by a normalization constant :math:`k`:
:math:`\psi\left( i \right) = \frac{1}{k} \sum \limits_{j=1}^{N_b} x_{ij} + y_{ij} i`
The translational order parameter as written above is **complex-valued**.
.. note::
**2D:** :class:`freud.order.Translational` is only defined for 2D
systems. The points must be passed in as :code:`[x, y, 0]`.
.. note::
This class is slated for deprecation and will be removed in freud 3.0.
Args:
k (float, optional):
Normalization of order parameter (Default value = :code:`6.0`).
""" # noqa E501
cdef freud._order.Translational * thisptr

def __cinit__(self, k=6.0):
warnings.warn("This class is deprecated and will be removed in "
"version 3.0", FreudDeprecationWarning)
self.thisptr = new freud._order.Translational(k, False)

def __dealloc__(self):
del self.thisptr

def compute(self, system, neighbors=None):
r"""Calculates the local descriptors.
Args:
system:
Any object that is a valid argument to
:class:`freud.locality.NeighborQuery.from_system`.
neighbors (:class:`freud.locality.NeighborList` or dict, optional):
Either a :class:`NeighborList <freud.locality.NeighborList>` of
neighbor pairs to use in the calculation, or a dictionary of
`query arguments
<https://freud.readthedocs.io/en/stable/topics/querying.html>`_
(Default value: None).
"""
cdef:
freud.locality.NeighborQuery nq
freud.locality.NeighborList nlist
freud.locality._QueryArgs qargs
const float[:, ::1] l_query_points
unsigned int num_query_points

nq, nlist, qargs, l_query_points, num_query_points = \
self._preprocess_arguments(system, neighbors=neighbors)

self.thisptr.compute(nlist.get_ptr(),
nq.get_ptr(), dereference(qargs.thisptr))
return self

@property
def default_query_args(self):
"""The default query arguments are
:code:`{'mode': 'nearest', 'num_neighbors': int(self.k)}`."""
return dict(mode="nearest", num_neighbors=int(self.k))

@_Compute._computed_property
def particle_order(self):
""":math:`\\left(N_{particles} \\right)` :class:`numpy.ndarray`: Order
parameter."""
return freud.util.make_managed_numpy_array(
&self.thisptr.getOrder(),
freud.util.arr_type_t.COMPLEX_FLOAT)

@property
def k(self):
"""float: Normalization of the order parameter."""
return self.thisptr.getK()

def __repr__(self):
return "freud.order.{cls}(k={k})".format(
cls=type(self).__name__, k=self.k)


cdef class Steinhardt(_PairCompute):
r"""Compute one or more of the rotationally invariant Steinhardt order
parameter :math:`q_l` or :math:`w_l` for a set of points
Expand Down
45 changes: 0 additions & 45 deletions tests/test_order_Translational.py

This file was deleted.

0 comments on commit 403eb9e

Please sign in to comment.