Skip to content

Commit 24a8295

Browse files
Migrate test_tensor.py to TF 2.0
Need to add tf.errors.InvalidArgumentError to errors caused by invalid shape addition
1 parent 76530cc commit 24a8295

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test_tensor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
import logging
33
import numpy as np
4+
import tensorflow as tf
45
import pyhf
56
from pyhf.simplemodels import hepdata_like
67

@@ -147,13 +148,13 @@ def test_shape(backend):
147148
assert tb.shape(tb.astensor(0.0)) == tb.shape(tb.astensor([0.0]))
148149
assert tb.shape(tb.astensor((1.0, 1.0))) == tb.shape(tb.astensor([1.0, 1.0]))
149150
assert tb.shape(tb.astensor((0.0, 0.0))) == tb.shape(tb.astensor([0.0, 0.0]))
150-
with pytest.raises((ValueError, RuntimeError)):
151+
with pytest.raises((ValueError, RuntimeError, tf.errors.InvalidArgumentError)):
151152
_ = tb.astensor([1, 2]) + tb.astensor([3, 4, 5])
152-
with pytest.raises((ValueError, RuntimeError)):
153+
with pytest.raises((ValueError, RuntimeError, tf.errors.InvalidArgumentError)):
153154
_ = tb.astensor([1, 2]) - tb.astensor([3, 4, 5])
154-
with pytest.raises((ValueError, RuntimeError)):
155+
with pytest.raises((ValueError, RuntimeError, tf.errors.InvalidArgumentError)):
155156
_ = tb.astensor([1, 2]) < tb.astensor([3, 4, 5])
156-
with pytest.raises((ValueError, RuntimeError)):
157+
with pytest.raises((ValueError, RuntimeError, tf.errors.InvalidArgumentError)):
157158
_ = tb.astensor([1, 2]) > tb.astensor([3, 4, 5])
158159
with pytest.raises((ValueError, RuntimeError)):
159160
tb.conditional(

0 commit comments

Comments
 (0)