MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testComplexOps

Method testComplexOps

tensorflow/compiler/tests/unary_ops_test.py:544–699  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

542 expected=np.array([-1., -0.5, 0., 0.296875], dtype=dtype))
543
544 def testComplexOps(self):
545 for dtype in self.complex_types:
546
547 self._assertOpOutputMatchesExpected(
548 math_ops.acosh,
549 np.array([0.1, 0.2j, 0.3 - 0.1j, 0.4 + 0.5j], dtype=dtype),
550 expected=np.arccosh(
551 np.array([0.1, 0.2j, 0.3 - 0.1j, 0.4 + 0.5j], dtype=dtype)))
552
553 self._assertOpOutputMatchesExpected(
554 math_ops.asinh,
555 np.array([0.1, 0.2j, 0.3 - 0.1j, 0.4 + 0.5j], dtype=dtype),
556 expected=np.arcsinh(
557 np.array([0.1, 0.2j, 0.3 - 0.1j, 0.4 + 0.5j], dtype=dtype)))
558
559 self._assertOpOutputMatchesExpected(
560 math_ops.atanh,
561 np.array([0.1, 0.2j, 0.3 - 0.1j, 0.4 + 0.5j], dtype=dtype),
562 expected=np.arctanh(
563 np.array([0.1, 0.2j, 0.3 - 0.1j, 0.4 + 0.5j], dtype=dtype)))
564
565 self._assertOpOutputMatchesExpected(
566 math_ops.cosh,
567 np.array([1j, 2 - 3j, 3, 4 + 2j], dtype=dtype),
568 expected=np.cosh(np.array([1j, 2 - 3j, 3, 4 + 2j], dtype=dtype)))
569
570 self._assertOpOutputMatchesExpected(
571 math_ops.sinh,
572 np.array([1, 2j, 2 - 3j, 4 + 5j], dtype=dtype),
573 expected=np.sinh(np.array([1, 2j, 2 - 3j, 4 + 5j], dtype=dtype)))
574
575 self._assertOpOutputMatchesExpected(
576 math_ops.exp,
577 np.array([[-1 + 2j, 3j, 2 - 3j]], dtype=dtype),
578 expected=np.exp(np.array([[-1 + 2j, 3j, 2 - 3j]], dtype=dtype)))
579
580 self._assertOpOutputMatchesExpected(
581 math_ops.expm1,
582 np.array([[-1 + 2j, 3j, 2 - 3j]], dtype=dtype),
583 expected=np.expm1(np.array([[-1 + 2j, 3j, 2 - 3j]], dtype=dtype)),
584 rtol=1e-6,
585 atol=1e-6)
586
587 # For real part close to zero, or imaginary part close to a multiple of
588 # pi.
589
590 self._assertOpOutputMatchesExpected(
591 math_ops.expm1,
592 np.array([[1e-11 + 1j, -1e-11 - 1j, 1. + 1e-11j,
593 -1. - 1e-11j, 1e-13j + 1e-13j]], dtype=dtype),
594 # TODO(srvasude): Use numpy as the source of truth after we depend on
595 # latest numpy with this pull request:
596 # https://github.com/numpy/numpy/pull/15110.
597 # The numbers below were generated by scipy.special.expm1.
598 expected=np.array([[
599 -4.59697694e-01+8.41470985e-01j,
600 -4.59697694e-01-8.41470985e-01j,
601 1.71828183e+00+2.71828183e-11j,

Callers

nothing calls this directly

Calls 3

logMethod · 0.45
log1pMethod · 0.45

Tested by

no test coverage detected