def is_point_in_poly_array(test_x, test_y, poly):
    """Implements the ray casting/crossing number algorithm. Returns TRUE if the point is within the bounds of the points that specify the polygon (poly is a list of points)."""

    # Sanity checks.
    if not isinstance(poly, list):
        return False

    num_crossings = 0
    num_vertices = len(poly)
    if num_vertices < 3: # Need at least three points to make a polygon
        return False

    for i in range(0, num_vertices):

        # Cache the y coordinate for the first point on the edge.
        poly_pt = poly[i]
        if len(poly_pt) != 2:
            return False
        poly_pt1_y = poly_pt[1]

        # Cache the second point on the edge, handling the wrap around that happens when we close the polygon.
        if i == num_vertices - 1:
            poly_pt = poly[0]
            poly_pt2_x = poly_pt[0]
            poly_pt2_y = poly_pt[1]
        else:
            poly_pt = poly[i + 1]
            poly_pt2_x = poly_pt[0]
            poly_pt2_y = poly_pt[1]

        # Test if the point is within the y limits of the edge.
        crosses_y = ((poly_pt1_y <= test_y) and (poly_pt2_y > test_y)) or ((poly_pt1_y > test_y) and (poly_pt2_y <= test_y))
        if crosses_y:

            # Test if the ray extending to the right of the point crosses the edge.
            poly_pt1_x = (poly[i])[0]
            if test_x <  poly_pt1_x + ((test_y - poly_pt1_y) / (poly_pt2_y - poly_pt1_y)) * (poly_pt2_x - poly_pt1_x):
                num_crossings = num_crossings + 1

    return num_crossings & 1