-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
DocumentationIssues related to the SciPy documentation. Also check https://github.com/scipy/scipy.orgIssues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org
Milestone
Description
Is there a typo in the ndimage LowLevelCallable tutorial example?
AFAICT the C-extension exports the Python function example.get_transform
which is imported in the next section, but then it's passed as transform()
to LowLevelCallable
, shouldn't it be passed as get_transform()
?
I'm working on implementing LowLevelCallable
for cython_optimize
, and I was looking at the tutorial examples for ndimage
, but I'm having a hard time interpreting when the C methods are passed to the LowLevelCallable
. If this is indeed a typo, I'm happy to send a PR to fix it, but just wanted to check that I wasn't misunderstanding the usage. Thanks!
Reproducing code example:
import ctypes
import numpy as np
from scipy import ndimage, LowLevelCallable
from example import get_transform # <- this line never used?
shift = 0.5
user_data = ctypes.c_double(shift)
ptr = ctypes.cast(ctypes.pointer(user_data), ctypes.c_void_p)
callback = LowLevelCallable(transform(), ptr) # <- shouldn't this be get_transform() ?
im = np.arange(12).reshape(4, 3).astype(np.float64)
print(ndimage.geometric_transform(im, callback))
Error message:
>>> callback = LowLevelCallable(transform(), ptr)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-88e997e74745> in <module>()
----> 1 callback = LowLevelCallable(transform(), ptr)
NameError: name 'transform' is not defined
Scipy/Numpy/Python version information:
import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
1.1.0 1.15.0 sys.version_info(major=3, minor=6, micro=6, releaselevel='final', serial=0)
Metadata
Metadata
Assignees
Labels
DocumentationIssues related to the SciPy documentation. Also check https://github.com/scipy/scipy.orgIssues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org