提交 5041d9bb authored 作者: John Salvatier's avatar John Salvatier

refactor advinc test skipping

上级 705fd905
...@@ -3721,6 +3721,11 @@ class TestIncSubtensor1(unittest.TestCase): ...@@ -3721,6 +3721,11 @@ class TestIncSubtensor1(unittest.TestCase):
self.assertRaises(TypeError, self.assertRaises(TypeError,
lambda: inc_subtensor(self.v[self.adv1q], fmatrix())) lambda: inc_subtensor(self.v[self.adv1q], fmatrix()))
def check_increment_available():
if not AdvancedIncSubtensor.increment_available:
raise SkipTest("inc_subtensor with advanced indexing not enabled. "
"Installing NumPy 1.8 or the latest development version "
"should make that feature available.")
class TestAdvancedSubtensor(unittest.TestCase): class TestAdvancedSubtensor(unittest.TestCase):
# test inc_subtensor # test inc_subtensor
...@@ -3750,10 +3755,7 @@ class TestAdvancedSubtensor(unittest.TestCase): ...@@ -3750,10 +3755,7 @@ class TestAdvancedSubtensor(unittest.TestCase):
a.broadcastable, self.ix2.broadcastable) a.broadcastable, self.ix2.broadcastable)
def test_inc_adv_subtensor_w_matrix(self): def test_inc_adv_subtensor_w_matrix(self):
if not AdvancedIncSubtensor.increment_available: check_increment_available()
raise SkipTest("inc_subtensor with advanced indexing not enabled. "
"Installing NumPy 1.8 or the latest development version "
"should make that feature available.")
a = inc_subtensor(self.v[self.ix2], self.v[self.ix2]) a = inc_subtensor(self.v[self.ix2], self.v[self.ix2])
...@@ -3764,10 +3766,8 @@ class TestAdvancedSubtensor(unittest.TestCase): ...@@ -3764,10 +3766,8 @@ class TestAdvancedSubtensor(unittest.TestCase):
assert numpy.allclose(aval, [.4, .9 * 3, .1 * 3]) assert numpy.allclose(aval, [.4, .9 * 3, .1 * 3])
def test_inc_adv_subtensor_w_2vec(self): def test_inc_adv_subtensor_w_2vec(self):
if not AdvancedIncSubtensor.increment_available: check_increment_available()
raise SkipTest("inc_subtensor with advanced indexing not enabled. "
"Installing NumPy 1.8 or the latest development version "
"should make that feature available.")
subt = self.m[self.ix1, self.ix12] subt = self.m[self.ix1, self.ix12]
a = inc_subtensor(subt, subt) a = inc_subtensor(subt, subt)
...@@ -3786,10 +3786,8 @@ class TestAdvancedSubtensor(unittest.TestCase): ...@@ -3786,10 +3786,8 @@ class TestAdvancedSubtensor(unittest.TestCase):
[.5, .3 * 2, .15]]), aval [.5, .3 * 2, .15]]), aval
def test_inc_adv_subtensor_with_broadcasting(self): def test_inc_adv_subtensor_with_broadcasting(self):
if not AdvancedIncSubtensor.increment_available: check_increment_available()
raise SkipTest("inc_subtensor with advanced indexing not enabled. "
"Installing NumPy 1.8 or the latest development version "
"should make that feature available.")
a = inc_subtensor(self.m[self.ix1, self.ix12], 2.1) a = inc_subtensor(self.m[self.ix1, self.ix12], 2.1)
assert a.type == self.m.type, (a.type, self.m.type) assert a.type == self.m.type, (a.type, self.m.type)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论