Inconsistent python api and documentation in mathutils. #47337

Closed
opened 2016-02-06 09:11:46 +01:00 by Shane Ambler · 4 comments

Blender Version
Broken: blender/blender@a6ca8a1b73

Short description of error
While the api docs show mathutils.bvhtree.BVHTree.find_nearest() this does not exist in the python api.

Exact steps for others to reproduce the error

In blender's pythjon console we get the following -

>>> bvhtree.BVHTree.FromObject(C.object, C.scene).find()

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: find_nearest() takes at least 1 argument (0 given)

>>> bvhtree.BVHTree.FromObject(C.object, C.scene).find_nearest()

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
AttributeError: 'BVHTree' object has no attribute 'find_nearest'

I expect that the method name find_nearest would be correct as it is the most used within the code and better describes the function. This mismatch stems from the api definition in mathutils_bvhtree.c with a fix being -

diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index 20baf6c..08b1f53 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -1132,7 +1132,7 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO
 
 static PyMethodDef py_bvhtree_methods[] = {
        {"ray_cast", (PyCFunction)py_bvhtree_ray_cast, METH_VARARGS, py_bvhtree_ray_cast_doc},
-       {"find", (PyCFunction)py_bvhtree_find_nearest, METH_VARARGS, py_bvhtree_find_nearest_doc},
+       {"find_nearest", (PyCFunction)py_bvhtree_find_nearest, METH_VARARGS, py_bvhtree_find_nearest_doc},
        {"overlap", (PyCFunction)py_bvhtree_overlap, METH_O, py_bvhtree_overlap_doc},
 
        /* class methods */

There is a possibility that BVHTree.find() is already in wide use and adjusting the documentation to match the use of BVHTree.find() will be less disruptive.

**Blender Version** Broken: blender/blender@a6ca8a1b73 **Short description of error** While the api docs show [mathutils.bvhtree.BVHTree.find_nearest()](https://www.blender.org/api/blender_python_api_current/mathutils.bvhtree.html#mathutils.bvhtree.BVHTree.find_nearest) this does not exist in the python api. **Exact steps for others to reproduce the error** In blender's pythjon console we get the following - ``` >>> bvhtree.BVHTree.FromObject(C.object, C.scene).find() Traceback (most recent call last): File "<blender_console>", line 1, in <module> TypeError: find_nearest() takes at least 1 argument (0 given) >>> bvhtree.BVHTree.FromObject(C.object, C.scene).find_nearest() Traceback (most recent call last): File "<blender_console>", line 1, in <module> AttributeError: 'BVHTree' object has no attribute 'find_nearest' ``` I expect that the method name `find_nearest` would be correct as it is the most used within the code and better describes the function. This mismatch stems from the api definition in `mathutils_bvhtree.c` with a fix being - ``` diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c index 20baf6c..08b1f53 100644 --- a/source/blender/python/mathutils/mathutils_bvhtree.c +++ b/source/blender/python/mathutils/mathutils_bvhtree.c @@ -1132,7 +1132,7 @@ static PyObject *C_BVHTree_FromObject(PyObject *UNUSED(cls), PyObject *args, PyO static PyMethodDef py_bvhtree_methods[] = { {"ray_cast", (PyCFunction)py_bvhtree_ray_cast, METH_VARARGS, py_bvhtree_ray_cast_doc}, - {"find", (PyCFunction)py_bvhtree_find_nearest, METH_VARARGS, py_bvhtree_find_nearest_doc}, + {"find_nearest", (PyCFunction)py_bvhtree_find_nearest, METH_VARARGS, py_bvhtree_find_nearest_doc}, {"overlap", (PyCFunction)py_bvhtree_overlap, METH_O, py_bvhtree_overlap_doc}, /* class methods */ ``` There is a possibility that `BVHTree.find()` is already in wide use and adjusting the documentation to match the use of `BVHTree.find()` will be less disruptive.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @sambler

Added subscriber: @sambler

This issue was referenced by blender/blender@c7608ef359

This issue was referenced by blender/blender@c7608ef359d109998ccafd8251e4e099d4fce090

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#47337
No description provided.