Skip to content

Commit

Permalink
added split=None test for cov
Browse files Browse the repository at this point in the history
  • Loading branch information
coquelin77 committed Jul 1, 2020
1 parent c731720 commit 2390d48
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions heat/core/tests/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,28 @@ def test_cov(self):
data = np.loadtxt("heat/datasets/data/iris.csv", delimiter=";")
np_cov = np.cov(data[:, 0], data[:, 1:3], rowvar=False)

# split = None tests
htdata = ht.load("heat/datasets/data/iris.csv", sep=";", split=None)
ht_cov = ht.cov(htdata[:, 0], htdata[:, 1:3], rowvar=False)
comp = ht.array(np_cov, dtype=ht.float)
self.assertTrue(ht.allclose(comp - ht_cov, 0, atol=1e-4))

np_cov = np.cov(data, rowvar=False)
ht_cov = ht.cov(htdata, rowvar=False)
self.assertTrue(ht.allclose(ht.array(np_cov, dtype=ht.float) - ht_cov, 0, atol=1e-4))

np_cov = np.cov(data, rowvar=False, ddof=1)
ht_cov = ht.cov(htdata, rowvar=False, ddof=1)
self.assertTrue(ht.allclose(ht.array(np_cov, dtype=ht.float) - ht_cov, 0, atol=1e-4))

np_cov = np.cov(data, rowvar=False, bias=True)
ht_cov = ht.cov(htdata, rowvar=False, bias=True)
self.assertTrue(ht.allclose(ht.array(np_cov, dtype=ht.float) - ht_cov, 0, atol=1e-4))

# split = 0 tests
data = np.loadtxt("heat/datasets/data/iris.csv", delimiter=";")
np_cov = np.cov(data[:, 0], data[:, 1:3], rowvar=False)

htdata = ht.load("heat/datasets/data/iris.csv", sep=";", split=0)
ht_cov = ht.cov(htdata[:, 0], htdata[:, 1:3], rowvar=False)
comp = ht.array(np_cov, dtype=ht.float)
Expand All @@ -360,6 +382,7 @@ def test_cov(self):
self.assertTrue(ht.allclose(ht.array(np_cov, dtype=ht.float) - ht_cov, 0, atol=1e-4))

if 1 < x.comm.size < 5:
# split 1 tests
htdata = ht.load("heat/datasets/data/iris.csv", sep=";", split=1)
np_cov = np.cov(data, rowvar=False)
ht_cov = ht.cov(htdata, rowvar=False)
Expand Down

0 comments on commit 2390d48

Please sign in to comment.