Browse Source

docs(functional): replace utils testcode with doctest format

GitOrigin-RevId: 8618918ff3
release-1.10
Megvii Engine Team 3 years ago
parent
commit
fd5031f8eb
1 changed files with 4 additions and 14 deletions
  1. +4
    -14
      imperative/python/megengine/functional/utils.py

+ 4
- 14
imperative/python/megengine/functional/utils.py View File

@@ -35,21 +35,11 @@ def _assert_equal(


Examples: Examples:


.. testcode::
>>> x = Tensor([1, 2, 3], dtype="float32")
>>> y = Tensor([1, 2, 3], dtype="float32")
>>> F.utils._assert_equal(x, y, maxerr=0)
Tensor([1. 2. 3.], device=xpux:0)


import numpy as np
from megengine import tensor
import megengine.functional as F

x = tensor([1, 2, 3], np.float32)
y = tensor([1, 2, 3], np.float32)
print(F.utils._assert_equal(x, y, maxerr=0).numpy())

Outputs:

.. testoutput::

[1. 2. 3.]
""" """
err = ( err = (
abs(expect - actual) abs(expect - actual)


Loading…
Cancel
Save