Skip to content

Commit

Permalink
GH-15947: fix R test error message change, fix Python column_names co…
Browse files Browse the repository at this point in the history
…ntain only columns not skipped.
  • Loading branch information
wendycwong committed May 23, 2024
1 parent da7946f commit e82f0e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions h2o-py/h2o/h2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,11 +871,10 @@ def parse_setup(raw_frames, destination_frame=None, header=0, separator=None, co
if column_names is not None: # used when python object is converted to H2O Frame
if not isinstance(column_names, list): raise ValueError("col_names should be a list")
if (skipped_columns is not None) and len(skipped_columns)>0:
# if ((len(column_names)-len(skipped_columns)) != parse_column_len) and (len(column_names) != parse_column_len):
if (len(column_names)-len(skipped_columns)) != parse_column_len:
if len(column_names) != parse_column_len:
raise ValueError(
"length of col_names minus length of skipped_columns should equal the number of columns parsed: "
"%d vs %d" % ((len(column_names)-len(skipped_columns), parse_column_len)))
"%d vs %d" % (len(column_names), parse_column_len))
else: # no skipped columns here
if len(column_names) != len(j["column_types"]): raise ValueError(
"length of col_names should be equal to the number of columns: %d vs %d"
Expand Down
3 changes: 2 additions & 1 deletion h2o-r/tests/testdir_jira/runit_hexdev_29_import_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ source("../../scripts/h2o-r-test-setup.R")
test.continuous.or.categorical <- function() {
df.hex <- h2o.uploadFile(locate("smalldata/jira/hexdev_29.csv"),
col.types = c("enum", "enum", "enum"))
browser()

expect_true(is.factor(df.hex$h1))
expect_true(is.factor(df.hex$h2))
Expand All @@ -36,7 +37,7 @@ test.continuous.or.categorical <- function() {

e <- tryCatch(h2o.importFile(locate("smalldata/iris/iris.csv"), col.names=c("C1","C2","C3","C4","C5","C6"),
col.types=list(by.col.name=c("C4"),types=c("Enum"))), error = function(x) x)
expect_true(e[[1]] == "length of col.names must equal to the number of columns in dataset")
expect_true(e[[1]] == "length of col.names (minus length of skipped_columns if present) must equal to the number of columns in dataset")

# col.types as character vector
df.hex2 <- h2o.importFile(locate("smalldata/iris/iris.csv"), col.types=c("Numeric","Numeric","Enum","Numeric","Enum"))
Expand Down

0 comments on commit e82f0e1

Please sign in to comment.