DHLearn: Scatterer: Cast first to PyObject before casting to provided type #1539
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
JJ's DHLearn example doesn't work because this
scatter
method returns Object instead of PyObject. Thus the method that is picked is aObject
-> (double) cast. Which means that the PyObject fails when attempting to be converted to Double.If Scatterer is only to be used from python, then we could forcefully cast to PyObject before the type.
If Scatterer is to be used also from Groovy, then we might need to do some custom casting in
scatter
iff the result value is an instance of PyObject.The important bits of JJ's example is this:
Where that get_results method is treated as
Function<Object[], Object>
instead ofFunction<Object[], PyObject>
.