blueloveTH 1 سال پیش
والد
کامیت
b053fe32a8
3فایلهای تغییر یافته به همراه8 افزوده شده و 8 حذف شده
  1. 2 2
      include/typings/array2d.pyi
  2. 3 3
      src/modules/array2d.c
  3. 3 3
      tests/90_array2d.py

+ 2 - 2
include/typings/array2d.pyi

@@ -76,8 +76,8 @@ class array2d(Generic[T]):
     def count_neighbors(self, value: T, neighborhood: Neighborhood) -> array2d[int]:
         """Counts the number of neighbors with the given value for each cell."""
 
-    def find_bounding_rect(self, value: T) -> tuple[int, int, int, int]:
-        """Finds the bounding rectangle of the given value.
+    def get_bounding_rect(self, value: T) -> tuple[int, int, int, int]:
+        """Gets the bounding rectangle of the given value.
         
         Returns a tuple `(x, y, width, height)` or raise `ValueError` if the value is not found.
         """

+ 3 - 3
src/modules/array2d.c

@@ -433,8 +433,8 @@ static bool array2d_count(int argc, py_Ref argv) {
     return true;
 }
 
-// find_bounding_rect(self, value: T) -> tuple[int, int, int, int]
-static bool array2d_find_bounding_rect(int argc, py_Ref argv) {
+// get_bounding_rect(self, value: T) -> tuple[int, int, int, int]
+static bool array2d_get_bounding_rect(int argc, py_Ref argv) {
     PY_CHECK_ARGC(2);
     c11_array2d* self = py_touserdata(argv);
     py_Ref value = py_arg(1);
@@ -761,7 +761,7 @@ void pk__add_module_array2d() {
     py_bindmethod(array2d, "tolist", array2d_tolist);
 
     py_bindmethod(array2d, "count", array2d_count);
-    py_bindmethod(array2d, "find_bounding_rect", array2d_find_bounding_rect);
+    py_bindmethod(array2d, "get_bounding_rect", array2d_get_bounding_rect);
     py_bindmethod(array2d, "count_neighbors", array2d_count_neighbors);
     py_bindmethod(array2d, "convolve", array2d_convolve);
 }

+ 3 - 3
tests/90_array2d.py

@@ -140,11 +140,11 @@ assert (a[1:4, 1:3] == b).all()
 """
 assert a.count(1) == 3*2
 
-assert a.find_bounding_rect(1) == (1, 1, 3, 2)
-assert a.find_bounding_rect(0) == (0, 0, 5, 5)
+assert a.get_bounding_rect(1) == (1, 1, 3, 2)
+assert a.get_bounding_rect(0) == (0, 0, 5, 5)
 
 try:
-    a.find_bounding_rect(2)
+    a.get_bounding_rect(2)
     exit(1)
 except ValueError:
     pass