8

I'm trying to submit a PR for scikit-image, but I get a Travis-CI error:

  Traceback (most recent call last):
  File "doc/examples/edges/plot_canny.py", line 22, in <module>
    from skimage import feature
  File "/home/travis/build/scikit-image/scikit-image/skimage/feature/__init__.py", line 9, in <module>
    from .peak import peak_local_max
  File "/home/travis/build/scikit-image/scikit-image/skimage/feature/peak.py", line 3, in <module>
    from ..filters import rank_order
  File "/home/travis/build/scikit-image/scikit-image/skimage/filters/__init__.py", line 11, in <module>
    from ._frangi import frangi_filter, hessian_filter
  File "/home/travis/build/scikit-image/scikit-image/skimage/filters/_frangi.py", line 2, in <module>
    from skimage.feature import hessian_matrix, hessian_matrix_eigvals
ImportError: cannot import name hessian_matrix

I suppose that this might be a circular import error, but I don't quite get how to resolve the issue. I've already included frangi_filter and hessian_filter into filter's module __init__.py.

I've also tried relative import, which resulted into the same errors.

How can I do a proper import, so the circular import issue can be resolved?

1 Answer 1

6

One ugly hack to resolve this would be to move that import inside the function, like

def hessian_filter(image, scale=(1, 10), scale_ratio=2, beta1=0.5, beta2=15):
    """
       Blah-blah-blah
    """
    from ..feature import hessian_matrix, hessian_matrix_eigvals
    # function body

You might want to create separate "proxy" functions for hessian_matrix and hessian_matrix_eigvals to not pollute every function with imports.

Sign up to request clarification or add additional context in comments.

1 Comment

Image
Seems like it is the only way to do it. Thanks, appreciate!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.