dlib
dlib copied to clipboard
Don't use __code__ to detect Python callable object
Expected Behavior
dlib.find_max_global (Python) should work on every callable object.
Current Behavior
It only works on objects with attribute __code__.
Steps to Reproduce
import dlib
from functools import partial
def f(arg0):
return 0
dlib.find_max_global(partial(f, 2), [0.], [1.], 100)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-112-da98f75572a0> in <module>
----> 1 dlib.find_max_global(partial(f, 2), [0.], [1.], 100)
AttributeError: 'functools.partial' object has no attribute '__code__'
- Version: dlib==19.19.0 (Python package)
- Where did you get dlib: pip/pypi
- Platform: Linux 5.0.0-38-generic #41-Ubuntu
- Compiler: gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1)
Suggestion: https://docs.python.org/3/library/functions.html#callable
That would be cool. You should submit a PR :)
But I don't know C++ :face_with_head_bandage: