def test_bitmap_save_load(): # Test init for slabs of points in x left_edge = np.array([0.0, 0.0, 0.0]) right_edge = np.array([1.0, 1.0, 1.0]) periodicity = np.array([0, 0, 0], "bool") npart = NPART file_hash = 12345 nfiles = 32 order1 = 2 order2 = 2 fname_fmt = "temp_bitmasks{}.dat" i = 0 fname = fname_fmt.format(i) while os.path.isfile(fname): i += 1 fname = fname_fmt.format(i) # Create bitmap and save to file reg0 = FakeBitmap(npart, nfiles, order1, order2, left_edge, right_edge, periodicity) reg0.save_bitmasks(fname) # Attempt to load bitmap reg1 = ParticleBitmap( left_edge, right_edge, periodicity, file_hash, nfiles, order1, order2 ) reg1.load_bitmasks(fname) assert_true(reg0.iseq_bitmask(reg1)) # Remove file os.remove(fname)
def test_ds_hold(): ds1 = fake_random_ds(64) ds2 = fake_random_ds(128) dd = ds1.all_data() assert_true( dd.ds.__hash__() == ds1.__hash__() ) # dd.ds is a weakref, so can't use "is" assert_true(dd.index is ds1.index) assert_equal(dd["ones"].size, 64 ** 3) with dd._ds_hold(ds2): assert_true(dd.ds.__hash__() == ds2.__hash__()) assert_true(dd.index is ds2.index) assert_equal(dd["ones"].size, 128 ** 3) assert_true(dd.ds.__hash__() == ds1.__hash__()) assert_true(dd.index is ds1.index) assert_equal(dd["ones"].size, 64 ** 3)
def check_bounds(arr, blower, bupper): assert_true(np.all(blower <= arr)) assert_true(np.all(bupper >= arr))
def check_monotonic_inc(arr): assert_true(np.all(0.0 <= (arr[1:] - arr[:-1])))