-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-15572: Check if headers were set before setting them to null in si…
…ngle entry ARFF parsing [nocheck] (#15589) * Do not let xgboost loading exception to go to void (#15560) * Check if headers were set before setting them to null in single entry ARFF parsing --------- Co-authored-by: Adam Valenta <[email protected]>
- Loading branch information
1 parent
7bef068
commit e6ca341
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
h2o-py/tests/testdir_parser/pyunit_parse_single_entry_arff.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import sys | ||
import tempfile | ||
|
||
sys.path.insert(1, "../../") | ||
import h2o | ||
from tests import pyunit_utils | ||
|
||
|
||
def test_single_entry_arff_file(): | ||
with open(pyunit_utils.locate("smalldata/junit/arff/iris.arff"), "r") as input_: | ||
arff = input_.readlines() | ||
data_start = arff.index("@DATA\n") | ||
subsample = arff[:data_start + 2] | ||
print(subsample[-3:]) | ||
_fd, tmp = tempfile.mkstemp(".arff") | ||
try: | ||
with open(tmp, "w") as output: | ||
output.write(''.join(subsample)) | ||
|
||
train = h2o.import_file(pyunit_utils.locate("smalldata/junit/arff/iris.arff")) | ||
test = h2o.import_file(tmp) | ||
|
||
print(f"{train.columns} == {test.columns}: {train.columns == test.columns}") | ||
assert train.columns == test.columns | ||
finally: | ||
os.unlink(tmp) | ||
|
||
|
||
if __name__ == "__main__": | ||
pyunit_utils.standalone_test(test_single_entry_arff_file) | ||
else: | ||
test_single_entry_arff_file() |