Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rag.merge_hierarchical mean boundary fails with in_place_merge=False #2132

Open
jni opened this issue Jun 7, 2016 · 5 comments
Open

rag.merge_hierarchical mean boundary fails with in_place_merge=False #2132

jni opened this issue Jun 7, 2016 · 5 comments
Labels

Comments

@jni
Copy link
Member

jni commented Jun 7, 2016

See the call to merge_hierarchical in this example:

labels2 = graph.merge_hierarchical(labels, g, thresh=0.08, rag_copy=False,
                                   in_place_merge=True,
                                   merge_func=merge_boundary,
                                   weight_func=weight_boundary)

If we change in_place_merge to False, we get the following traceback:

/Users/jni/conda/envs/ana3/lib/python3.5/site-packages/skimage/future/graph/graph_merge.py in merge_hierarchical(labels, rag, thresh, rag_copy, in_place_merge, merge_func, weight_func)
    127 
    128             merge_func(rag, src, dst)
--> 129             new_id = rag.merge_nodes(src, dst, weight_func)
    130             _revalidate_node_edges(rag, new_id, edge_heap)
    131 

<ipython-input-41-3e98b81231d5> in merge_nodes(self, src, dst, weight_func, in_place, extra_arguments, extra_keywords)
     13     for neighbor in neighbors:
     14         data = weight_func(self, src, new, neighbor, *extra_arguments,
---> 15                            **extra_keywords)
     16         self.add_edge(neighbor, new, attr_dict=data)
     17 

<ipython-input-69-dc9c8b5456f9> in weight_boundary(graph, src, dst, n)
      5 
      6     count_src = graph[src].get(n, default)['count']
----> 7     count_dst = graph[dst].get(n, default)['count']
      8 
      9     weight_src = graph[src].get(n, default)['weight']

KeyError: 'count'

> <ipython-input-69-dc9c8b5456f9>(7)weight_boundary()
      5 
      6     count_src = graph[src].get(n, default)['count']
----> 7     count_dst = graph[dst].get(n, default)['count']
      8 
      9     weight_src = graph[src].get(n, default)['weight']

I think it's because new edges are created with only a weight key, not a full complement of data attributes.

@jni
Copy link
Member Author

jni commented Jun 7, 2016

CC @vighneshbirodkar

@DanielGutmann
Copy link

Same call to 'graph.merge_hierarchical' yet different error:

  • Error occurs for any True/False combination of rag_copy= and in_place_merge=

TypeError                                 Traceback (most recent call last)
/Users/danielgutmann/anaconda/envs/med35/lib/python3.5/site-packages/skimage/future/graph/graph_merge.py in merge_hierarchical(labels, rag, thresh, rag_copy, in_place_merge, merge_func, weight_func)
    101         wt = data['weight']
    102         heap_item = [wt, n1, n2, True]
--> 103         heapq.heappush(edge_heap, heap_item)
    104 
    105         # Reference to the heap item in the graph

TypeError: unorderable types: float() < dict()`

@rfezzani
Copy link
Member

graph.merge_hierarchical is no more in the API 😕. Closing

@jni
Copy link
Member Author

jni commented Oct 19, 2021

@rfezzani I appreciate you trying to clean up many issues quickly, but except in very unambiguous cases, please give the original authors a chance to determine whether an issue can indeed be closed. In this case, the function is skimage.future.graph.merge_hierarchical and remains in the API, and this is still an issue that needs addressing.

@jni jni reopened this Oct 19, 2021
@rfezzani
Copy link
Member

Of course @jni and sorry if I am too quick closing issues 🙏 . It's a chance to revive some 😄. Maybe updating issue description may help 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants