diff --git a/pytorch3d/renderer/utils.py b/pytorch3d/renderer/utils.py index d2024d34..5ffd4c37 100644 --- a/pytorch3d/renderer/utils.py +++ b/pytorch3d/renderer/utils.py @@ -3,6 +3,7 @@ import numpy as np +import warnings from typing import Any, Union import torch @@ -111,7 +112,7 @@ class TensorProperties(object): args_to_broadcast[k] = v else: msg = "Arg %s with type %r is not broadcastable" - print(msg % (k, type(v))) + warnings.warn(msg % (k, type(v))) names = args_to_broadcast.keys() # convert from type dict.values to tuple diff --git a/pytorch3d/transforms/transform3d.py b/pytorch3d/transforms/transform3d.py index 5c59859b..c0483513 100644 --- a/pytorch3d/transforms/transform3d.py +++ b/pytorch3d/transforms/transform3d.py @@ -2,6 +2,7 @@ # Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. import math +import warnings import torch @@ -663,7 +664,7 @@ def _check_valid_rotation_matrix(R, tol: float = 1e-7): Returns: None - Prints an warning if R is an invalid rotation matrix. Else return. + Emits a warning if R is an invalid rotation matrix. """ N = R.shape[0] eye = torch.eye(3, dtype=R.dtype, device=R.device) @@ -673,5 +674,5 @@ def _check_valid_rotation_matrix(R, tol: float = 1e-7): no_distortion = torch.allclose(det_R, torch.ones_like(det_R)) if not (orthogonal and no_distortion): msg = "R is not a valid rotation matrix" - print(msg) + warnings.warn(msg) return