2016-06-13 16 views
8

Tôi đang cố gắng để nộp PR cho scikit-hình ảnh, nhưng tôi nhận được một Travis-CI error:Rắc rối với các chức năng tương đối/tuyệt đối nhập khẩu trong scikit-image

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 

Tôi cho rằng điều này có thể là một lỗi nhập vòng tròn, nhưng tôi không hoàn toàn hiểu cách giải quyết vấn đề. Tôi đã có includedfrangi_filterhessian_filter vào mô-đun của bộ lọc __init__.py.

Tôi cũng đã thử nhập relative, trong đó resulted vào cùng một lỗi.

Làm cách nào để nhập một cách thích hợp, do đó vấn đề nhập vòng tròn có thể được giải quyết?

Trả lời

6

Một hack xấu xí để giải quyết này sẽ được di chuyển nhập khẩu mà bên trong hàm, như

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 

Bạn có thể muốn tạo riêng biệt "proxy" chức năng cho hessian_matrixhessian_matrix_eigvals để không gây ô nhiễm mỗi chức năng với hàng nhập khẩu.

+0

Có vẻ như đó là cách duy nhất để làm điều đó. Cảm ơn, đánh giá cao! –

Các vấn đề liên quan