sort_pos_dist#

atomate2.common.schemas.defects.sort_pos_dist(list_in, s1, s2, dist)[source]#

Sort a list defined when we can only compute a positive-definite distance.

Sometimes, we can only compute a positive-definite distance between two objects. (E.g., the displacement between two structures). In these cases, standard sorting algorithms will not work. Here, we accept two reference points to give some sense of direction. We then sort the list based on the distance between the reference points. Note: this only works if the list falls on a line of some sort

Parameters:
  • list_in (list[Any]) – The list to sort.

  • s1 (Any) – The first reference point.

  • s2 (Any) – The second reference point.

  • dist (Callable) – The distance function.

Returns:

  • List[Any] – The sorted list.

  • List[float] – The signed distances to the reference point (s1).

Return type:

tuple[list[Any], list[float]]