def testBlkDiagMatrixInPlace(self): """ Tests sequence of in place optimized arithmetic (add, sub, mul) """ _ = [x + x + 10.0 for x in self.blk_a] _ = [np.ones(x.shape) * 5.0 for x in self.blk_a] # make a block diagonal object to mutate blk_c = self.blk_a.copy() # store the python object ids of each array in blk_c # we want to ensure the actual object refs are _not_ changing # for in place operations. id0 = [id(x) for x in blk_c] blk_c += self.blk_a self.allallid(blk_c, id0) blk_c += 10.0 self.allallid(blk_c, id0) blk_a5 = BlkDiagMatrix.ones(self.blk_partition) id1 = [id(x) for x in blk_a5] blk_a5 *= 5.0 self.allallid(blk_a5, id1) blk_c -= blk_a5 blk_c -= blk_a5 self.allallid(blk_c, id0) blk_c -= self.blk_a self.allallid(blk_c, id0) self.allallfunc(blk_c, self.blk_a)
def testBlkDiagMatrixOnes(self): blk_ones = BlkDiagMatrix.ones(self.blk_partition) self.allallfunc(blk_ones, self.blk_ones)