(self,
op,
a,
b,
expected,
equality_test=None,
rtol=None,
atol=None)
| 39 | """Test cases for binary operators.""" |
| 40 | |
| 41 | def _testBinary(self, |
| 42 | op, |
| 43 | a, |
| 44 | b, |
| 45 | expected, |
| 46 | equality_test=None, |
| 47 | rtol=None, |
| 48 | atol=None): |
| 49 | with self.session() as session: |
| 50 | with self.test_scope(): |
| 51 | pa = array_ops.placeholder(dtypes.as_dtype(a.dtype), a.shape, name="a") |
| 52 | pb = array_ops.placeholder(dtypes.as_dtype(b.dtype), b.shape, name="b") |
| 53 | output = op(pa, pb) |
| 54 | result = session.run(output, {pa: a, pb: b}) |
| 55 | if equality_test is None: |
| 56 | equality_test = self.assertAllCloseAccordingToType |
| 57 | if rtol is None: |
| 58 | rtol = 1e-15 if a.dtype == np.float64 else 1e-3 |
| 59 | if atol is None: |
| 60 | atol = 1e-15 if a.dtype == np.float64 else 1e-6 |
| 61 | equality_test(result, expected, rtol=rtol, atol=atol) |
| 62 | |
| 63 | def _testSymmetricBinary(self, op, a, b, expected, equality_test=None): |
| 64 | self._testBinary(op, a, b, expected, equality_test) |
no test coverage detected