question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Default arguments are not supported with Dispatch (regression from 0.2.5)

See original GitHub issue

This was working in 0.2.5,

import plum
from plum import dispatch

@dispatch
def test(a:int, b: int = 1):
	print('int, int')

@dispatch
def test(a:float, b: int = 1):
	print('float, int')

In [33]: 

In [33]: test(1,1)
---------------------------------------------------------------------------
NotFoundLookupError                       Traceback (most recent call last)
<ipython-input-33-9b86683066a3> in <module>
----> 1 test(1,1)

~/Documents/pythonenvs/netket_env/lib64/python3.8/site-packages/plum/function.cpython-38-x86_64-linux-gnu.so in plum.function.Function.__call__()

~/Documents/pythonenvs/netket_env/lib64/python3.8/site-packages/plum/function.cpython-38-x86_64-linux-gnu.so in plum.function.Function.resolve_method()

~/Documents/pythonenvs/netket_env/lib64/python3.8/site-packages/plum/function.cpython-38-x86_64-linux-gnu.so in plum.function.Function.resolve_signature()

NotFoundLookupError: For function "test", signature Signature(builtins.int, builtins.int) could not be resolved.

In [34]: test(1)
int, int

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
wesselbcommented, Apr 22, 2021

You’re right. That seems like a relatively easy and handy feature. Actual keyword arguments should then be specified using *:

from plum import dispatch

@dispatch
def test(a: int, b_with_default:int = 3, *, c_kw_only = 4):
   pass
2reactions
wesselbcommented, May 3, 2021

Hey guys!

Just letting you know that I’m a little busy at the moment, but I hope to get to this in the near future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dispatch behavior of optional arguments · Issue #7357 - GitHub
I think it's ultimately a good thing that default arguments are not a special feature, and just reduce to dispatch.
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
(was: =dev-java/jdbm-1.0 is available)" status:RESOLVED resolution:OBSOLETE severity:enhancement · Bug:107027 - "dev-vcs/cvsd init script for is not ...
Read more >
Bug #9593: Keyword arguments default argument assignment ...
Personally, I prefer 2.0.0 behaviour, but the way 2.1.1 handles default arguments in non keyword arguments is inconsistent.
Read more >
Bioconductor 3.11 Released
It supports pseudotemporal ordering algorithms and visualization ... This does not affect default prior, only empirical Bayes approach.
Read more >
"Least Astonishment" and the Mutable Default Argument
Actually, this is not a design flaw, and it is not because of internals or performance. It comes simply from the fact that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found