How to pass a kwarg named ref
to a Python function
#3431
-
from python import Python
fn main() raises:
var librosa = Python.import_module("librosa")
var np = Python.import_module("numpy")
var y = librosa.load(librosa.ex('trumpet'))[0]
librosa.power_to_db(y, ref=np.max) > mojo run p.mojo
/Users/aw/Projects/rectalogic/experiments/mojo/p.mojo:8:28: error: unexpected token in expression
librosa.power_to_db(y, ref=np.max)
^
mojo: error: failed to parse the provided Mojo source module In Python I would pass a dict literal like Constructing a dict and unpacking is also not supported: var kwargs = Python.dict()
kwargs["ref"] = np.max
librosa.power_to_db(y, **kwargs) /Users/aw/Projects/rectalogic/experiments/mojo/p2.mojo:10:28: error: keyword unpacking not supported yet
librosa.power_to_db(y, **kwargs)
^
mojo: error: failed to parse the provided Mojo source module |
Beta Was this translation helpful? Give feedback.
Answered by
soraros
Aug 29, 2024
Replies: 1 comment 1 reply
-
You can write librosa.power_to_db(y, `ref`=np.max) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rectalogic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can write