ternary_diagram.utils module

ternary_diagram.utils.check_1d_vector(vector: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], scale: bool = True) numpy.ndarray

check 1d vector

Parameters
  • vector (ArrayLike | shape = (3,)) – ratio

  • scale (bool, optional) – minmaxscale or not, by default True

Examples

>>> check_1d_vector([1, 2, 3], scale=False)
array([[1, 2, 3]])
>>> check_1d_vector([2, 2, 4], scale=True)
array([[0.25, 0.25, 0.5 ]])
Return type

np.ndarray | shape = (1, 3)

ternary_diagram.utils.check_2d_vector(vector: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], scale: bool = True) numpy.ndarray

check 2d vector

Parameters
  • vector (ArrayLike | shape = (n, 3)) – ratio

  • scale (bool, optional) – minmaxscale or not, by default True

Return type

numpy.ndarray | shape = (n, 3)

Raises

ValueError – when shape is not (n, 3)

ternary_diagram.utils.check_ax(ax: Optional[matplotlib.axes._axes.Axes]) matplotlib.axes._axes.Axes

check ax

Parameters

ax (None or Axes object) – if None, get current axes

Return type

Axes object

Raises

TypeError – when ax is not None or Axes object

ternary_diagram.utils.get_label(compound_name: str) str

Convert the chemical composition to LaTeX notation.

Parameters

compound_name (str) – A compound name, like ‘Li2O’

Returns

Chemical composition converted to LaTeX notation.

Return type

str

Examples

>>> get_label('Li2O')
'Li$_{2}$O'
>>> get_label('(LiLa)0.5TiO3')
'(LiLa)$_{0.5}$TiO$_{3}$'
Raises

ValueError – when compound_name is not str.

ternary_diagram.utils.three2two(vector: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) Tuple[numpy.ndarray, numpy.ndarray]

Converted 3D proportions to 2D in order to generate a triangular diagram.

Parameters

vector (ArrayLike | shape = (n, 3)) – ratio

Examples

>>> three2two(check_2d_vector([[2, 2, 4]]))
(array([0.625]), array([0.21650635]))
Return type

numpy.ndarray | shape = (n, 2)