"""Module for defining data type used for type hinting."""fromsympyimportMatrix,MatrixBaseimportnumpyasnpfromtypingimportTuple,Hashablefromcollections.abcimportSequencefromnumbersimportNumberVertex=Hashable"""Any hashable type can be used for a Vertex."""Edge=set[Vertex]|Tuple[Vertex,Vertex]|list[Vertex]"""An Edge is an unordered pair of :obj:`Vertices <pyrigi.data_type.Vertex>`."""DirectedEdge=Tuple[Vertex,Vertex]|list[Vertex]"""A DirectedEdge is an ordered pair of :obj:`Vertices <pyrigi.data_type.Vertex>`."""Coordinate=int|float|str"""An integer, float or a string interpretable by :func:`~sympy.core.sympify.sympify`."""Point=Sequence[Coordinate]"""A Point is a Sequence of Coordinates whose length is the dimension of its affine space."""Stress=Sequence[int|float|str]"""A Stress is a Sequence of `int | float | str`."""Inf=Number"""Provides a data type that can become infinite."""
[docs]defpoint_to_vector(point:Point)->Matrix:""" Return point as single column sympy Matrix. """ifisinstance(point,MatrixBase)orisinstance(point,np.ndarray):if(len(point.shape)>1andpoint.shape[0]!=1andpoint.shape[1]!=1)orlen(point.shape)>2:raiseValueError("Point could not be interpreted as column vector.")ifisinstance(point,np.ndarray):point=np.array([point])iflen(point.shape)==1elsepointpoint=Matrix([[float(point[i,j])foriinrange(point.shape[0])]forjinrange(point.shape[1])])returnpointif(point.shape[1]==1)elsepoint.transpose()ifnotisinstance(point,Sequence)orisinstance(point,str):raiseTypeError("The point must be a Sequence of Coordinates.")try:res=Matrix(point)exceptExceptionase:raiseValueError("A coordinate could not be interpreted by sympify:\n"+str(e))ifres.shape[0]!=1andres.shape[1]!=1:raiseValueError("Point could not be interpreted as column vector.")returnresif(res.shape[1]==1)elsepoint.transpose()