Skip to content

Commit

Permalink
avoid numba 0.42.0 problem: failed in object mode when nopython=False.
Browse files Browse the repository at this point in the history
  • Loading branch information
traveller59 committed Jan 9, 2019
1 parent 8ece472 commit 57efcc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion second/core/box_np_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ def points_in_rbbox(points, rbbox, lidar=True):
return indices


@numba.jit(nopython=False)
def corner_to_surfaces_3d(corners):
"""convert 3d box corners from corner function above
to surfaces that normal vectors all direct to internal.
Expand Down
17 changes: 13 additions & 4 deletions second/core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def is_line_segment_cross(lines1, lines2):
_ccw(A, B, C) != _ccw(A, B, D))


@numba.jit(nopython=False)
def surface_equ_3d_jit(polygon_surfaces):
def surface_equ_3d(polygon_surfaces):
# return [a, b, c], d in ax+by+cz+d=0
# polygon_surfaces: [num_polygon, num_surfaces, num_points_of_polygon, 3]
surface_vec = polygon_surfaces[:, :, :2, :] - polygon_surfaces[:, :, 1:3, :]
Expand All @@ -94,7 +93,6 @@ def surface_equ_3d_jit(polygon_surfaces):
return normal_vec, -d


@numba.jit(nopython=False)
def points_in_convex_polygon_3d_jit(points,
polygon_surfaces,
num_surfaces=None):
Expand All @@ -115,9 +113,20 @@ def points_in_convex_polygon_3d_jit(points,
num_polygons = polygon_surfaces.shape[0]
if num_surfaces is None:
num_surfaces = np.full((num_polygons,), 9999999, dtype=np.int64)
normal_vec, d = surface_equ_3d_jit(polygon_surfaces[:, :, :3, :])
normal_vec, d = surface_equ_3d(polygon_surfaces[:, :, :3, :])
# normal_vec: [num_polygon, max_num_surfaces, 3]
# d: [num_polygon, max_num_surfaces]
return _points_in_convex_polygon_3d_jit(points, polygon_surfaces, normal_vec, d, num_surfaces)


@numba.njit
def _points_in_convex_polygon_3d_jit(points,
polygon_surfaces,
normal_vec, d,
num_surfaces):
max_num_surfaces, max_num_points_of_surface = polygon_surfaces.shape[1:3]
num_points = points.shape[0]
num_polygons = polygon_surfaces.shape[0]
ret = np.ones((num_points, num_polygons), dtype=np.bool_)
sign = 0.0
for i in range(num_points):
Expand Down

0 comments on commit 57efcc8

Please sign in to comment.