Skip to content

Commit

Permalink
GH-15947: Incorporate Seb code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
wendycwong committed May 21, 2024
1 parent 1f17a8f commit 57b323a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions h2o-py/h2o/h2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,14 +868,15 @@ def parse_setup(raw_frames, destination_frame=None, header=0, separator=None, co
if ind in skipped_columns:
use_type[ind]=False

if column_names is not None:
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) and (len(column_names) != parse_column_len):
if (len(column_names)-len(skipped_columns)) != parse_column_len:
raise ValueError(
"length of col_names minus lenght of skipped_columns should equal the number of columns parsed: "
"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)))
else:
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"
% (len(column_names), len(j["column_types"])))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def H2OFrame_from_H2OFrame():
assert dupl4.columns == ["n1", "s1"]


def H2OFrame_skipped_columns_is_BUGGY():
def H2OFrame_skipped_columns_BUG_fixed():
f1 = h2o.H2OFrame(data, skipped_columns=[1])
f2 = h2o.H2OFrame(data)
assert f1.ncol == (f2.ncol-1), "expected number of columns: {0}, actual column numbers: {1}".format(f1.ncol, (f2.ncol-1))
Expand All @@ -139,5 +139,5 @@ def H2OFrame_skipped_columns_is_BUGGY():
H2OFrame_from_pandas,
H2OFrame_from_scipy,
H2OFrame_from_H2OFrame,
H2OFrame_skipped_columns_is_BUGGY
H2OFrame_skipped_columns_BUG_fixed
])

0 comments on commit 57b323a

Please sign in to comment.