diff --git a/include/typings/array2d.pyi b/include/typings/array2d.pyi index 32d0946c..dae03220 100644 --- a/include/typings/array2d.pyi +++ b/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. """ diff --git a/src/modules/array2d.c b/src/modules/array2d.c index 27492860..e1784ab1 100644 --- a/src/modules/array2d.c +++ b/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); } diff --git a/tests/90_array2d.py b/tests/90_array2d.py index 16fe6ee5..bb3d6e30 100644 --- a/tests/90_array2d.py +++ b/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