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

DHLearn: Scatterer: Cast first to PyObject before casting to provided type #1539

Closed

Conversation

nbauernfeind
Copy link
Member

JJ's DHLearn example doesn't work because this scatter method returns Object instead of PyObject. Thus the method that is picked is a Object -> (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:

# A function to extract a result
def get_results(data, idx):
    return data[idx]

result = learn.learn(
    table = source,
    model_func = sum_columns,
    inputs = [learn.Input(["X", "Y"], table_to_array)],
    outputs = [learn.Output("Z", get_results, "double")],
    batch_size = 1000

Where that get_results method is treated as Function<Object[], Object> instead of Function<Object[], PyObject>.

@nbauernfeind nbauernfeind added bug Something isn't working NoDocumentationNeeded labels Nov 9, 2021
@nbauernfeind nbauernfeind added this to the Nov 2021 milestone Nov 9, 2021
@nbauernfeind nbauernfeind requested a review from rcaudy November 9, 2021 00:36
@nbauernfeind nbauernfeind self-assigned this Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working NoDocumentationNeeded
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant