Skip to content

Commit

Permalink
[Fix] Fix warning capture
Browse files Browse the repository at this point in the history
  • Loading branch information
fanqiNO1 committed Feb 18, 2024
1 parent 5b64bee commit c51a235
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/test_utils/test_dl_utils/test_torch_ops.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import warnings

import torch

from mmengine.utils.dl_utils import torch_meshgrid


def test_torch_meshgrid():
# torch_meshgrid should not throw warning
with pytest.warns(UserWarning) as record:
with warnings.catch_warnings():
warnings.simplefilter('error')
x = torch.tensor([1, 2, 3])
y = torch.tensor([4, 5, 6])
grid_x, grid_y = torch_meshgrid(x, y)
assert len(record) == 0

0 comments on commit c51a235

Please sign in to comment.