scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturns
is_valid_dm(D, tol=0.0, throw=False, name='D', warning=False)

Distance matrices must be 2-dimensional numpy arrays. They must have a zero-diagonal, and they must be symmetric.

Notes

Small numerical differences in D and :None:None:`D.T` and non-zeroness of the diagonal are ignored if they are within the tolerance specified by :None:None:`tol`.

Parameters

D : array_like

The candidate object to test for validity.

tol : float, optional

The distance matrix should be symmetric. :None:None:`tol` is the maximum difference between entries ij and ji for the distance metric to be considered symmetric.

throw : bool, optional

An exception is thrown if the distance matrix passed is not valid.

name : str, optional

The name of the variable to checked. This is useful if throw is set to True so the offending variable can be identified in the exception message when an exception is thrown.

warning : bool, optional

Instead of throwing an exception, a warning message is raised.

Returns

valid : bool

True if the variable D passed is a valid distance matrix.

Return True if input array is a valid distance matrix.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/spatial/distance.py#2387
type: <class 'function'>
Commit: