Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
thocevar committed Jul 27, 2018
1 parent bffe1ff commit 27ac0c2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Orange/tests/test_basic_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# pylint: disable=missing-docstring
from unittest import TestCase

import numpy as np
import time

from Orange.data import Table
from Orange.statistics.basic_stats import DomainBasicStats, BasicStats

Expand All @@ -24,6 +27,15 @@ def test_domain_basic_stats(self):
self.assertStatsEqual(domain_stats.stats,
attr_stats + class_var_stats + meta_stats)

def test_speed(self):
n, m = 10, 10000
data = Table.from_numpy(None, np.random.rand(n, m))
start = time.time()
for i in range(m):
s = data._compute_basic_stats([i])
elapsed = time.time() - start
self.assertLess(elapsed, 10.0)

def assertStatsEqual(self, stats1, stats2):
self.assertEqual(len(stats1), len(stats2))
for stat1, stat2 in zip(stats1, stats2):
Expand Down

0 comments on commit 27ac0c2

Please sign in to comment.