make points2volumes feature rescaling optional

Summary: Add option to not rescale the features, giving more control. https://github.com/facebookresearch/pytorch3d/issues/1137

Reviewed By: nikhilaravi

Differential Revision: D35219577

fbshipit-source-id: cbbb643b91b71bc908cedc6dac0f63f6d1355c85
This commit is contained in:
Jeremy Reizenstein
2022-04-13 04:39:47 -07:00
committed by Facebook GitHub Bot
parent 0a7c354dc1
commit 78fd5af1a6
3 changed files with 47 additions and 8 deletions

View File

@@ -192,12 +192,22 @@ class TestCaseMixin(unittest.TestCase):
self.fail(f"{msg} {err}")
self.fail(err)
def assertConstant(self, input: TensorOrArray, value: Real) -> None:
def assertConstant(
self, input: TensorOrArray, value: Real, *, atol: float = 0
) -> None:
"""
Asserts input is entirely filled with value.
Args:
input: tensor or array
value: expected value
atol: tolerance
"""
self.assertEqual(input.min(), value)
self.assertEqual(input.max(), value)
mn, mx = input.min(), input.max()
msg = f"values in range [{mn}, {mx}], not {value}, shape {input.shape}"
if atol == 0:
self.assertEqual(input.min(), value, msg=msg)
self.assertEqual(input.max(), value, msg=msg)
else:
self.assertGreater(input.min(), value - atol, msg=msg)
self.assertLess(input.max(), value + atol, msg=msg)