Преглед на файлове

use np.empty instead of np.zeros in pairwise_intersection

quarrying преди 3 години
родител
ревизия
edd3c194cc
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      khandy/boxes/boxes_overlap.py

+ 4 - 3
khandy/boxes/boxes_overlap.py

@@ -41,13 +41,14 @@ def pairwise_intersection(boxes1, boxes2):
     """
     rows = boxes1.shape[0]
     cols = boxes2.shape[0]
-    intersect_areas = np.zeros((rows, cols), dtype=boxes1.dtype)
     if rows * cols == 0:
-        return intersect_areas
+        return np.zeros((rows, cols), dtype=boxes1.dtype)
+
+    intersect_areas = np.empty((rows, cols), dtype=boxes1.dtype)
     swap = False
     if boxes1.shape[0] > boxes2.shape[0]:
         boxes1, boxes2 = boxes2, boxes1
-        intersect_areas = np.zeros((cols, rows), dtype=boxes1.dtype)
+        intersect_areas = np.empty((cols, rows), dtype=boxes1.dtype)
         swap = True
 
     for i in range(boxes1.shape[0]):