MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / __init__

Method __init__

SwissArmyTransformer/sat/data_utils/datasets.py:51–62  ·  view source on GitHub ↗
(self, path, process_fn, length_per_sample=64+1024+4096, dtype='int32', preload=False, **kwargs)

Source from the content-addressed store, hash-verified

49
50class BinaryDataset(Dataset):
51 def __init__(self, path, process_fn, length_per_sample=64+1024+4096, dtype='int32', preload=False, **kwargs):
52 assert length_per_sample is not None
53 self.length_per_sample = length_per_sample
54 self.dtype = np.dtype(dtype)
55 self.process_fn = process_fn
56 if preload:
57 self.bin = np.fromfile(path, dtype=self.dtype).reshape(-1, length_per_sample)
58 else:
59 with open(path, 'r') as fid:
60 nbytes = fid.seek(0, 2)
61 flen = fid.tell() // self.dtype.itemsize
62 self.bin = np.memmap(path, dtype=self.dtype, shape=(flen // length_per_sample, length_per_sample))
63
64 def __len__(self):
65 return self.bin.shape[0]

Callers

nothing calls this directly

Calls 1

dtypeMethod · 0.80

Tested by

no test coverage detected