[Fix] Fix warning capture (#1494)
parent
f79111ecc0
commit
ba5eed8409
|
@ -1,5 +1,6 @@
|
||||||
# Copyright (c) OpenMMLab. All rights reserved.
|
# Copyright (c) OpenMMLab. All rights reserved.
|
||||||
import pytest
|
import warnings
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from mmengine.utils.dl_utils import torch_meshgrid
|
from mmengine.utils.dl_utils import torch_meshgrid
|
||||||
|
@ -7,9 +8,8 @@ from mmengine.utils.dl_utils import torch_meshgrid
|
||||||
|
|
||||||
def test_torch_meshgrid():
|
def test_torch_meshgrid():
|
||||||
# torch_meshgrid should not throw warning
|
# torch_meshgrid should not throw warning
|
||||||
with pytest.warns(None) as record:
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter('error')
|
||||||
x = torch.tensor([1, 2, 3])
|
x = torch.tensor([1, 2, 3])
|
||||||
y = torch.tensor([4, 5, 6])
|
y = torch.tensor([4, 5, 6])
|
||||||
grid_x, grid_y = torch_meshgrid(x, y)
|
grid_x, grid_y = torch_meshgrid(x, y)
|
||||||
|
|
||||||
assert len(record) == 0
|
|
||||||
|
|
Loading…
Reference in New Issue