Skip to content

Commit

Permalink
fix and test for issue h2oai#15947
Browse files Browse the repository at this point in the history
  • Loading branch information
Devanshusisodiya committed Feb 13, 2024
1 parent 6d2d82a commit fc73e2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions h2o-py/h2o/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ def _upload_python_object(self, python_obj, destination_frame=None, header=0, se
if not column_names:
column_names = col_header

if skipped_columns:
column_names = [column_name for column_name in column_names[:len(column_names)-len(skipped_columns)]]

if not column_names:
raise H2OValueError("skipped_columns cannot contain all columns")

# create a temporary file that will be written to
tmp_handle, tmp_path = tempfile.mkstemp(suffix=".csv")
tmp_file = os.fdopen(tmp_handle, 'w', **H2OFrame.__fdopen_kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,16 @@ def H2OFrame_from_H2OFrame():
assert dupl4.columns == ["n1", "s1"]


def H2OFrame_skipped_columns_is_BUGGY():
def H2OFrame_skipped_columns():
try:
h2o.H2OFrame(data, skipped_columns=[1])
assert False, "skipped_columns handling may be fixed now" # parse_setup is absolutely weird, with only half parameters passed to build the ParseSetup, and then a bunch of logic done locally, that's why it's buggy: see issue https://github.com/h2oai/h2o-3/issues/15947
fr = h2o.H2OFrame([
[1, "a", 1],
[2, "b", 0],
[3, "", 1],
]
)
skipped_columns_frame = h2o.H2OFrame(data, skipped_columns=[1])
assert skipped_columns_frame == fr # parse_setup is absolutely weird, with only half parameters passed to build the ParseSetup, and then a bunch of logic done locally, that's why it's buggy: see issue https://github.com/h2oai/h2o-3/issues/15947
except ValueError as e:
assert "length of col_names should be equal to the number of columns parsed: 4 vs 3" in str(e)

Expand Down

0 comments on commit fc73e2f

Please sign in to comment.