-
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.
add h2o.trim() to python client and respective pyunit
- Loading branch information
1 parent
1944d80
commit 5496d10
Showing
3 changed files
with
53 additions
and
0 deletions.
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
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,31 @@ | ||
import sys | ||
sys.path.insert(1, "../../") | ||
import h2o | ||
|
||
def trim_check(ip,port): | ||
# Connect to a pre-existing cluster | ||
h2o.init(ip,port) | ||
|
||
frame = h2o.import_frame(path=h2o.locate("smalldata/junit/cars_trim.csv")) | ||
|
||
# single column (frame) | ||
trimmed_frame = h2o.trim(frame[["name"]]) | ||
assert trimmed_frame[0,0] == "AMC Ambassador Brougham", "Expected 'AMC Ambassador Brougham', but got " \ | ||
"{0}".format(trimmed_frame[0,0]) | ||
assert trimmed_frame[1,0] == "AMC Ambassador DPL", "Expected 'AMC Ambassador DPL', but got " \ | ||
"{0}".format(trimmed_frame[1,0]) | ||
assert trimmed_frame[2,0] == "AMC Ambassador SST", "Expected 'AMC Ambassador SST', but got " \ | ||
"{0}".format(trimmed_frame[2,0]) | ||
|
||
# single column (vec) | ||
vec = frame["name"] | ||
trimmed_vec = h2o.trim(vec) | ||
assert trimmed_vec[0] == "AMC Ambassador Brougham", "Expected 'AMC Ambassador Brougham', but got " \ | ||
"{0}".format(trimmed_frame[0]) | ||
assert trimmed_vec[1] == "AMC Ambassador DPL", "Expected 'AMC Ambassador DPL', but got " \ | ||
"{0}".format(trimmed_frame[1]) | ||
assert trimmed_vec[2] == "AMC Ambassador SST", "Expected 'AMC Ambassador SST', but got " \ | ||
"{0}".format(trimmed_frame[2]) | ||
|
||
if __name__ == "__main__": | ||
h2o.run_test(sys.argv, trim_check) |