forked from pypose/pypose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix bugs in test_spline.py Signed-off-by: Xiangyu Chen <[email protected]> * add testing Signed-off-by: Xiangyu Chen <[email protected]> * add testing.rst Signed-off-by: Xiangyu Chen <[email protected]> * add testing Signed-off-by: Xiangyu Chen <[email protected]> * Update __init__.py Signed-off-by: Xiangyu Chen <[email protected]> * Update test_spline.py Signed-off-by: Xiangyu Chen <[email protected]> * Update test_spline.py Signed-off-by: Xiangyu Chen <[email protected]> * rename the assert_clase * Update test_spline.py --------- Signed-off-by: Xiangyu Chen <[email protected]> Co-authored-by: Chen Wang <[email protected]> Co-authored-by: Chen Wang <[email protected]>
- Loading branch information
1 parent
6421ae2
commit c71c6fb
Showing
7 changed files
with
89 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ PyPose Documentation | |
modules | ||
optim | ||
utils | ||
testing | ||
|
||
|
||
Indices and tables | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Testing | ||
========= | ||
|
||
|
||
.. currentmodule:: pypose | ||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
|
||
:template: autosummary/class-no-inherit.rst | ||
testing.assert_close |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .comparison import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import torch | ||
from ..function.checking import is_lietensor | ||
|
||
|
||
def assert_close(actual, expected, *args, **kwargs): | ||
''' | ||
Asserts that ``actual`` and ``expected`` are close. This function is exactly the same | ||
with `torch.testing.assert_close <https://tinyurl.com/3bm33ps7>`_ except for that it | ||
also accepts ``pypose.LieTensor``. | ||
Args: | ||
actual(:obj:`Tensor` or :obj:`LieTensor`): Actual input. | ||
expected(:obj:`Tensor` or :obj:`LieTensor`): Expected input. | ||
rtol (Optional[float]): Relative tolerance. If specified ``atol`` must also be | ||
specified. If omitted, default values based on the :attr:`~torch.Tensor.dtype` | ||
are selected with the below table. | ||
atol (Optional[float]): Absolute tolerance. If specified ``rtol`` must also be | ||
specified. If omitted, default values based on the :attr:`~torch.Tensor.dtype` | ||
are selected with the below table. | ||
If :math:`T_e` and :math:`T_a` are Lietensor, they are considered close if | ||
:math:`T_e*T_a^{-1} = \mathbf{O}`, where :math:`\mathbf{O}` is close to zero tensor in | ||
the sense of ``torch.testing.assert_close`` is ``True.`` | ||
Warning: | ||
The prerequisites for the other arguments align precisely with | ||
`torch.testing.assert_close <https://tinyurl.com/3bm33ps7>`_. Kindly consult it | ||
for further details. | ||
Examples: | ||
>>> import pypose as pp | ||
>>> actual = pp.randn_SE3(3) | ||
>>> expected = actual.Log().Exp() | ||
>>> pp.testing.assert_close(actual, expected, rtol=1e-5, atol=1e-5) | ||
''' | ||
if is_lietensor(actual) and is_lietensor(expected): | ||
source = (actual.Inv() @ expected).Log().tensor() | ||
target = torch.zeros_like(source) | ||
else: | ||
source, target = actual, expected | ||
torch.testing.assert_close(source, target, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters