h2oai / h2o-3

H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc.
http://h2o.ai
Apache License 2.0
6.93k stars 2k forks source link

R fails to save the result of an element insert when returning from a function #8202

Open exalate-issue-sync[bot] opened 1 year ago

exalate-issue-sync[bot] commented 1 year ago

This function does not return the correct sequence: The following function should return the equivalent of cumsum(c(10, 2, 2, 2, 2, 2)) but actually returns the equivalent of cumsum(c(2, 2, 2, 2, 2, 2)).

test_fn <- function() { requireNamespace("h2o") seq.hex <- h2o::h2o.rep_len(2, length.out = 6) seq.hex[1,"C1"] <- 10 out.hex <- h2o::h2o.cumsum(x = seq.hex, axis = 0)

return(out.hex) } test_fn()

It appears to be "forgetting" the line seq.hex[1, "C1"] <- 10. Adding another step makes it "remember" and return the correct output:

test_fn <- function() { requireNamespace("h2o") seq.hex <- h2o::h2o.rep_len(2, length.out = 6) seq.hex[1,"C1"] <- 10 out.hex <- h2o::h2o.cumsum(x = seq.hex, axis = 0)

sum(seq.hex) # need this or something similar, such as print(seq.hex), to make this function work.

return(out.hex) } test_fn() # correctly returns 10, 12, 14, 16, 18, 20

Sometimes ignoring a line in the middle of a function is of course undesirable behavior! I suspect a problem with how the element insert is being cached or sent to h2o. I would describe this as a major bug, because it results in the function working in an undocumented manner with unpredictable results without any warnings.

Running on R 3.6.2 with h2o 3.28.1.1.

h2o-ops commented 1 year ago

JIRA Issue Migration Info

Jira Issue: PUBDEV-7435 Assignee: New H2O Bugs Reporter: Michael State: Open Fix Version: N/A Attachments: N/A Development PRs: N/A