Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autowrap of python functions with variable arity fails #181

Closed
bgribble opened this issue Aug 8, 2014 · 1 comment
Closed

Autowrap of python functions with variable arity fails #181

bgribble opened this issue Aug 8, 2014 · 1 comment
Milestone

Comments

@bgribble
Copy link
Owner

bgribble commented Aug 8, 2014

Autowrap of a python function of variable args (such as min) will create a processor with 1 inlet. That's fine. Sending it an iterable should apply the function to the args. But it doesn't:

[(3,4,5)(
|
[min]
|
[print]

Should print 3, but instead:

Error: <mfp.builtins.var.Message object at 0x7ffd58970750>
Traceback (most recent call last):
  File "/home/grib/devel/mfp/wafbuild/virtual/local/lib/python2.7/dist-packages/mfp-0.05_git_05c941b-py2.7.egg/mfp/processor.py", line 545, in send
    work[:1] = w_target._send(w_val, w_inlet)
  File "/home/grib/devel/mfp/wafbuild/virtual/local/lib/python2.7/dist-packages/mfp-0.05_git_05c941b-py2.7.egg/mfp/processor.py", line 568, in _send
    self.trigger()
  File "/home/grib/devel/mfp/wafbuild/virtual/local/lib/python2.7/dist-packages/mfp-0.05_git_05c941b-py2.7.egg/mfp/builtins/pyfunc.py", line 207, in trigger
    self.outlets[0] = self.thunk(*args)
TypeError: min expected 1 arguments, got 0
@bgribble
Copy link
Owner Author

The above commit wraps variable-arity or unknown-arity Python functions as processors with one inlet. A sequence sent to that inlet is unpacked and applied to the thunk. So this works as expected:

[3,4,1,5(
|
[max]
|
[print]

prints 5

Closing this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant