I'm having trouble using functools.partial with np.multiply and I'm don't understand why I'm getting this error. I'm just learning how partial
works so it's possible I'm just making a silly error.
The error is Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_umd.py", line 194, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/shilo/PycharmProjects/Video/testing/test_functools.py", line 7, in <module>
f(x1=image,x2=2.0)
ValueError: invalid number of arguments
The code that I'm attempting to use is below:
from functools import partial
import cv2
import numpy as np
path = '/Users/shilo/Desktop/Goliath_preview.jpg'
image = cv2.imread(path)
f = partial(np.multiply,x1=image,x2=2.0)
f()
The np.multiply function definition looks like this:
def multiply(x1, x2, *args, **kwargs)
I assumed that I only needed to supply x1 and x2 but it doesn't seem to work even when I include args/kwargs
I've also tried including all of the kwargs listed in the docstring but still got the same invalid number of arguments error.
multiply(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])