Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions kiva/agg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,22 @@ def __init__(self, size, pix_format=default_pix_format,
warnings.warn("Error initializing Agg: %s" % ex, Warning, 2)

GraphicsContextSystem = None


def points_in_polygon(pts, poly_pts, use_winding=False):
"""Keep this function around for old code, but warn anyone who calls it.
"""
import inspect
import warnings
from kiva.api import points_in_polygon as new_points_in_polygon

msg = "points_in_polygon() has moved to kiva.api"
frame = inspect.currentframe().f_back
warnings.warn_explicit(
msg,
category=DeprecationWarning,
filename=inspect.getfile(frame.f_code),
lineno=frame.f_lineno,
)

new_points_in_polygon(pts, poly_pts, use_winding=use_winding)
14 changes: 14 additions & 0 deletions kiva/tests/test_points_in_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@
#
# Thanks for using Enthought open source!
import unittest
import warnings

from numpy import allclose, array, zeros

from kiva.agg import points_in_polygon as points_in_polygon_deprecated
from kiva.api import points_in_polygon


class TestPointsInPolygon(unittest.TestCase):
def test_deprecated_import(self):
polygon = array(((0.0, 0.0), (10.0, 0.0), (0.0, 10.0)))
points = array(((5.0, 5.0),))

with warnings.catch_warnings(record=True) as collector:
warnings.simplefilter("always")
points_in_polygon_deprecated(points, polygon)

assert len(collector) == 1
warn = collector[0]
assert issubclass(warn.category, DeprecationWarning)

def test_empty_points_in_polygon(self):
polygon = array(((0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)))
points = zeros((0, 2))
Expand Down