MCPcopy
hub / github.com/zju3dv/4K4D / test_searchsorted_reference

Function test_searchsorted_reference

tests/mipnerf360_tests.py:129–142  ·  view source on GitHub ↗

Test against torch.searchsorted, which behaves similarly to ours.

()

Source from the content-addressed store, hash-verified

127
128
129def test_searchsorted_reference():
130 """Test against torch.searchsorted, which behaves similarly to ours."""
131 eps = 1e-7
132 n = 30
133 m = 40
134
135 # Generate query points in [eps, 1-eps].
136 v = torch.rand([n]) * (1 - eps - eps) + eps
137
138 # Generate sorted reference points that span all of [0, 1].
139 a, _ = torch.sort(torch.rand([m]))
140 a = torch.cat([torch.tensor([0.]), a, torch.tensor([1.])])
141 _, idx_hi = searchsorted(a, v)
142 assert_true((np.array_equal(np.searchsorted(a, v), idx_hi.numpy())))
143
144
145def test_searchsorted():

Callers

nothing calls this directly

Calls 3

searchsortedFunction · 0.90
assert_trueFunction · 0.85
numpyMethod · 0.80

Tested by

no test coverage detected