-
Notifications
You must be signed in to change notification settings - Fork 2k
/
pyunit_download_csv.py
31 lines (21 loc) · 1.01 KB
/
pyunit_download_csv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
sys.path.insert(1,"../../")
import h2o
from tests import pyunit_utils
import os
import random
def download_csv():
iris1 = h2o.import_file(path=pyunit_utils.locate("smalldata/iris/iris.csv"))
h2o.download_csv(iris1,"iris_delete.csv")
iris2 = h2o.import_file(path=pyunit_utils.locate("iris_delete.csv"))
os.remove("iris_delete.csv")
rand_row = random.randint(0,iris1.nrow-1)
rand_col = random.randint(0,3)
assert abs(iris1[rand_row, rand_col] - iris2[rand_row, rand_col]) < 1e-10, "Expected elements from the datasets to " \
"be the same, but got {0} and {1}" \
"".format(iris1[rand_row, rand_col],
iris2[rand_row, rand_col])
if __name__ == "__main__":
pyunit_utils.standalone_test(download_csv)
else:
download_csv()