def __init__(self, lib_dir, shape, lsides, mmap_mode=None): assert len(shape) == 2 and len(lsides) == 2 assert shape[0] % 2 == 0 and shape[1] % 2 == 0 assert shape[0] < 2**16 and shape[1] < 2**16 self.shape = tuple(shape) self.rshape = (shape[0], shape[1] / 2 + 1) self.lsides = tuple(lsides) self.lib_dir = lib_dir self.mmap_mode = mmap_mode # Dumping ell mat in lib_dir. Overwrites if already present. if pbs.rank == 0: if not os.path.exists(lib_dir): os.makedirs(lib_dir) if not os.path.exists(lib_dir + "/ellmat_hash.pk"): pk.dump(self.hash_dict(), open(lib_dir + "/ellmat_hash.pk", 'w')) pbs.barrier() hash_check(pk.load(open(lib_dir + "/ellmat_hash.pk", 'r')), self.hash_dict()) if pbs.rank == 0 and not os.path.exists(self.lib_dir + '/ellmat.npy'): print 'ell_mat:caching ells in ', self.lib_dir + '/ellmat.npy' np.save(self.lib_dir + '/ellmat.npy', self._build_ellmat()) pbs.barrier() # FIXME self.ellmax = int(self._get_ellmax()) self._ell_counts = self._build_ell_counts() self._nz_counts = self._ell_counts.nonzero()
def check_compatible(self, ellmat): hash_check(self.hash_dict(), ellmat.hash_dict())