MCPcopy Index your code
hub / github.com/apple/ml-pointersect / chunk

Method chunk

pointersect/inference/structures.py:1622–1641  ·  view source on GitHub ↗
(self, chunks: int, dim: int = 0)

Source from the content-addressed store, hash-verified

1620 return camera
1621
1622 def chunk(self, chunks: int, dim: int = 0) -> T.List['Camera']:
1623 out_dict = dict()
1624 total = None
1625 for attr_name in ['H_c2w', 'intrinsic']:
1626 arr = getattr(self, attr_name, None)
1627 if arr is not None:
1628 chunked_arr = arr.chunk(chunks=chunks, dim=dim)
1629 out_dict[attr_name] = chunked_arr
1630 if total is None:
1631 total = len(chunked_arr)
1632 else:
1633 assert len(chunked_arr) == total
1634 cameras = []
1635 for i in range(total):
1636 d = dict()
1637 for attr_name in out_dict:
1638 d[attr_name] = out_dict[attr_name][i]
1639 camera = Camera(**d, width_px=self.width_px, height_px=self.height_px)
1640 cameras.append(camera)
1641 return cameras
1642
1643 def to(self, device: torch.device) -> 'Camera':
1644 self.H_c2w = self.H_c2w.to(device=device)

Callers

nothing calls this directly

Calls 2

CameraClass · 0.85
chunkMethod · 0.45

Tested by

no test coverage detected