Skip to content

Commit

Permalink
Merge pull request #36597 from rushabh-v:er-poly
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 294598208
Change-Id: I7d17dfc9ae5984d6303798aa7c09aba42703355f
  • Loading branch information
tensorflower-gardener committed Feb 12, 2020
2 parents 8159f59 + b664a40 commit 0ec37eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tensorflow/python/kernel_tests/cwise_ops_test.py
Expand Up @@ -1228,6 +1228,12 @@ def testEmpty(self):
tf_val = math_ops.polyval(coeffs, x)
self.assertAllClose(np_val, self.evaluate(tf_val))

def test_coeffs_raise(self):
x = np.random.rand(2, 2).astype(np.float32)
coeffs = {}
with self.assertRaisesRegexp(ValueError, "Argument coeffs must be list"):
math_ops.polyval(coeffs, x)


class SingularGradientOpTest(test.TestCase):

Expand Down
3 changes: 3 additions & 0 deletions tensorflow/python/ops/math_ops.py
Expand Up @@ -4411,6 +4411,9 @@ def polyval(coeffs, x, name=None):
Equivalent to numpy.polyval.
@end_compatibility
"""
if not isinstance(coeffs, list):
raise ValueError("Argument coeffs must be list type "
"found {}.".format(type(coeffs)))

with ops.name_scope(name, "polyval", nest.flatten(coeffs) + [x]) as name:
x = ops.convert_to_tensor(x, name="x")
Expand Down

0 comments on commit 0ec37eb

Please sign in to comment.