SpringPy

raw JSON →
0.1.0 verified Sat May 09 auth: no python

SpringPy is a Python library for visualizing distance matrices as force-directed spring layouts. Version 0.1.0, released with an unspecified cadence. It supports Python >=3.4 and provides an easy interface to generate spring-based visualizations from distance matrices.

pip install springpy
error ImportError: No module named 'springpy'
cause springpy is not installed or the Python environment does not include it.
fix
Run 'pip install springpy' to install the package.
error AttributeError: module 'springpy' has no attribute 'draw'
cause The import statement might be incorrect (e.g., from springpy import springpy) or an outdated version.
fix
Use 'import springpy' then 'springpy.draw(...)'. If using an older version, upgrade with 'pip install --upgrade springpy'.
error ValueError: The truth value of an array with more than one element is ambiguous
cause Passing a non-square or non-numeric matrix that causes internal boolean operations.
fix
Ensure the input is a square numeric matrix (list of lists or numpy array).
gotcha The distance matrix must be symmetric and non-negative. The library does not explicitly validate this; providing an asymmetric matrix may produce unexpected behavior.
fix Ensure input matrix is symmetric (dist_matrix == dist_matrix.T) and contains only non-negative values.
deprecated The library version 0.1.0 is early-stage and APIs may change without notice. Not recommended for production use.
fix Consider pinning the version and testing thoroughly before upgrading.
gotcha The library requires matplotlib for plotting, but it is not declared as a strict dependency. If matplotlib is missing, calling springpy.draw() will raise an ImportError.
fix Install matplotlib separately: pip install matplotlib

Visualize a distance matrix using SpringPy's force-directed layout. Provide a square distance matrix as a 2D array-like (list of lists or numpy array). The draw function will display a matplotlib plot.

import springpy
import numpy as np

# Example distance matrix
dist_matrix = np.array([[0, 1, 2],
                        [1, 0, 3],
                        [2, 3, 0]])

# Visualize using default settings
springpy.draw(dist_matrix)