Skip to content

Commit

Permalink
Add lazy loading to skimage.draw submodule (#6971)
Browse files Browse the repository at this point in the history
  • Loading branch information
decorouz committed May 31, 2023
1 parent 907d272 commit 0c17a8f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 30 deletions.
30 changes: 2 additions & 28 deletions skimage/draw/__init__.py
@@ -1,29 +1,3 @@
from .draw import (ellipse, set_color, polygon_perimeter,
line, line_aa, polygon, ellipse_perimeter,
circle_perimeter, circle_perimeter_aa,
disk, bezier_curve, rectangle, rectangle_perimeter)
from .draw3d import ellipsoid, ellipsoid_stats
from ._draw import _bezier_segment
from ._random_shapes import random_shapes
from ._polygon2mask import polygon2mask
import lazy_loader as lazy

from .draw_nd import line_nd

__all__ = ['line',
'line_aa',
'line_nd',
'bezier_curve',
'polygon',
'polygon_perimeter',
'ellipse',
'ellipse_perimeter',
'ellipsoid',
'ellipsoid_stats',
'circle_perimeter',
'circle_perimeter_aa',
'disk',
'set_color',
'random_shapes',
'rectangle',
'rectangle_perimeter',
'polygon2mask']
__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)
44 changes: 44 additions & 0 deletions skimage/draw/__init__.pyi
@@ -0,0 +1,44 @@
# Explicitly setting `__all__` is necessary for type inference engines
# to know which symbols are exported. See
# https://peps.python.org/pep-0484/#stub-files

__all__ = [
'line',
'line_aa',
'line_nd',
'bezier_curve',
'polygon',
'polygon_perimeter',
'ellipse',
'ellipse_perimeter',
'ellipsoid',
'ellipsoid_stats',
'circle_perimeter',
'circle_perimeter_aa',
'disk',
'set_color',
'random_shapes',
'rectangle',
'rectangle_perimeter',
'polygon2mask'
]

from .draw3d import ellipsoid, ellipsoid_stats
from ._draw import _bezier_segment
from ._random_shapes import random_shapes
from ._polygon2mask import polygon2mask
from .draw_nd import line_nd
from .draw import (
ellipse,
set_color,
polygon_perimeter,
line,
line_aa,
polygon,
ellipse_perimeter,
circle_perimeter,
circle_perimeter_aa,
disk, bezier_curve,
rectangle,
rectangle_perimeter
)
4 changes: 2 additions & 2 deletions skimage/draw/_random_shapes.py
Expand Up @@ -2,8 +2,8 @@

import numpy as np

from . import (polygon as draw_polygon, disk as draw_disk,
ellipse as draw_ellipse)
from .draw import (polygon as draw_polygon, disk as draw_disk,
ellipse as draw_ellipse)
from .._shared.utils import deprecate_kwarg, warn


Expand Down
1 change: 1 addition & 0 deletions skimage/draw/meson.build
Expand Up @@ -8,6 +8,7 @@ py3.extension_module('_draw',

python_sources = [
'__init__.py',
'__init__.pyi',
'_polygon2mask.py',
'_random_shapes.py',
'draw3d.py',
Expand Down

0 comments on commit 0c17a8f

Please sign in to comment.