higra / Higra

Hierarchical Graph Analysis
Other
98 stars 20 forks source link

Ambiguous array comparison in delinearize_vertex_weights #187

Closed PerretB closed 4 years ago

PerretB commented 4 years ago

delinearize_vertex_weights fails if one of the shape is given as a numpy array:

/usr/local/lib/python3.6/dist-packages/higra/hg_utils.py in delinearize_vertex_weights(vertex_weights, graph, shape)
    201 
    202     if len(v_shape) >= len(shape):
--> 203         if shape == v_shape[:len(shape)]:
    204             return vertex_weights
    205 

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

This happens with the functions khalimsky_2_graph_4_adjacency which initializes the shape of the returned graph with a numpy array (should be normalized with normalize_shape).