def testPercentileExecution(self): raw = np.random.rand(20, 10) q = np.random.RandomState(0).randint(100, size=11) a = tensor(raw, chunk_size=7) r = percentile(a, q) result = self.executor.execute_tensor(r, concat=True)[0] expected = np.percentile(raw, q) np.testing.assert_array_equal(result, expected) mq = tensor(q) this = self class MockSession: def __init__(self): self.executor = this.executor ctx = LocalContext(MockSession()) executor = ExecutorForTest('numpy', storage=ctx) with ctx: r = percentile(a, mq) result = executor.execute_tensors([r])[0] np.testing.assert_array_equal(result, expected)
def testPercentile(self): raw = np.random.rand(100) q = [101] a = tensor(raw, chunk_size=100) with self.assertRaises(ValueError) as cm: percentile(a, q) the_exception = cm.exception self.assertIn('Percentiles', str(the_exception))
def test_percentile(): raw = np.random.rand(100) q = [101] a = tensor(raw, chunk_size=100) with pytest.raises(ValueError) as cm: percentile(a, q) the_exception = cm.value.args[0] assert 'Percentiles' in the_exception
def test_percentile_execution(setup): raw = np.random.rand(20, 10) q = np.random.RandomState(0).randint(100, size=11) a = tensor(raw, chunk_size=7) r = percentile(a, q) result = r.execute().fetch() expected = np.percentile(raw, q) np.testing.assert_almost_equal(result, expected) mq = tensor(q) r = percentile(a, mq) result = r.execute().fetch() np.testing.assert_almost_equal(result, expected)
def testPercentileExecution(self): raw = np.random.rand(20, 10) q = np.random.RandomState(0).randint(100, size=11) a = tensor(raw, chunk_size=7) r = percentile(a, q) result = self.executor.execute_tensor(r, concat=True)[0] expected = np.percentile(raw, q) np.testing.assert_almost_equal(result, expected) mq = tensor(q) ctx, executor = self._create_test_context(self.executor) with ctx: r = percentile(a, mq) result = executor.execute_tensors([r])[0] np.testing.assert_almost_equal(result, expected)