MCPcopy Create free account
hub / github.com/apple/ml-pointersect / test_1

Method test_1

tests/plib/test_utils.py:277–294  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

275class Test_Sample_Patch(unittest.TestCase):
276
277 def test_1(self):
278 b, c, h, w = 2, 1, 5, 6
279 bchw = b * c * h * w
280 arr = torch.arange(bchw).reshape(b, c, h, w).float()
281
282 center = torch.tensor([
283 [1., 1.],
284 [1.5, 2.5,]
285 ])
286
287 out = utils.sample_patch(
288 arr=arr,
289 patch_center=center,
290 patch_width_px=3,
291 patch_width_pitch_scale=1,
292 )
293 assert out.shape == (b, c, 3, 3)
294 assert torch.allclose(out[1], arr[1, :, 1:4, 0:3])
295
296 def test_2(self):
297 b, c, h, w = 2, 1, 5, 6

Callers

nothing calls this directly

Calls 1

reshapeMethod · 0.45

Tested by

no test coverage detected