def func(shape, ndim, ordering, value): table = PackedTable(shape, ndim=ndim, ordering=ordering, value=value) table_local = table.scatter() table_global = table_local.gather() assert_equal(table_global.shape, table.shape) assert_equal(table_global.ndim, table.ndim) assert_equal(table_global._index, table._index) assert_equal(table_global.removed, table.removed) assert_equal(table_global.value, table.value)
def test_scatter(): np.random.seed(0) n = 4 x = np.random.random(n) layout = PackedTable(n, x=x) s = split(n, size, rank) scattered = layout.scatter() assert_same(scattered.x, x[s]) assert_same(scattered.all.x, x)
def test(): scene = Scene(1024) instrument = Instrument('instrument', PackedTable((32, 32))) sampling = Sampling(1000) acq = Acquisition(instrument, sampling, scene, nprocs_sampling=max(size // 2, 1)) print(acq.comm.rank, acq.instrument.detector.comm.rank, '/', acq.instrument.detector.comm.size, acq.sampling.comm.rank, '/', acq.sampling.comm.size)
def func3(shape): instrument = Instrument('', PackedTable(shape)) acq = MyAcquisition3(instrument, sampling, scene) noise = acq.get_noise() assert noise.shape == (len(acq.instrument), len(acq.sampling)) assert_allclose(np.std(noise), sigma, rtol=1e-2)
def func(cls, keywords): instrument = cls(name, PackedTable(shape), **keywords) assert instrument.name == name assert instrument.detector.shape == shape assert len(instrument.detector) == len(instrument.detector.all) assert instrument
def test_pack_unpack(): layout = PackedTable(4, selection=[True, False, True, True]) instrument = Instrument('instrument', layout) v = [1, 2, 3, 4] assert_same(instrument.pack(v), [1, 3, 4]) assert_same(instrument.unpack([1, 3, 4]), [1, -1, 3, 4])