OCR-D / ocropy

Python-based tools for document analysis and OCR
Apache License 2.0
0 stars 1 forks source link

morph: wrong import of scikit-image #1

Closed bertsky closed 2 years ago

bertsky commented 2 years ago

The imports in https://github.com/OCR-D/ocropy/blob/d3e5cc60b64d070b60d606a16baeda6b436cc23b/ocrolib/morph.py#L10-L11

starting with Python 3.8 (and seemingly irrespective of the actual scikit-image version – at least from v0.15 to v0.19.2) yield the following:

DeprecationWarning: Please use `iterate_structure` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `generate_binary_structure` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `binary_erosion` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `binary_dilation` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `binary_opening` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `binary_closing` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `binary_hit_or_miss` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `binary_propagation` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `binary_fill_holes` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `grey_erosion` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `grey_dilation` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `grey_opening` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `grey_closing` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `morphological_gradient` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `morphological_laplace` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `white_tophat` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `black_tophat` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `distance_transform_bf` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `distance_transform_cdt` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
 DeprecationWarning: Please use `distance_transform_edt` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
DeprecationWarning: Please use `filters` from the `scipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is deprecated.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/python3.8/site-packages/scipy/ndimage/morphology.py", line 35, in __getattr__
    return getattr(_morphology, name)
AttributeError: module 'scipy.ndimage._morphology' has no attribute 'filters'

So it is not possible to import ocrolib.morph anymore.

Since (as the warning hints and is in fact the case all the morphology exports are now available on ndimage as well) I suggest we just rewrite the second line:

    from scipy.ndimage import *
bertsky commented 2 years ago

Done in #2