def __getitem__(self, key): shape = Shape(*ku.size(key, self.shape)) neg_mat = bu.index(self.sign.neg_mat, key) pos_mat = bu.index(self.sign.pos_mat, key) cvx_mat = bu.index(self.curvature.cvx_mat, key) conc_mat = bu.index(self.curvature.conc_mat, key) constant = self.curvature.constant return DCPAttr(Sign(neg_mat, pos_mat), Curvature(cvx_mat, conc_mat, constant), shape)
def __getitem__(self, key): """Determines the DCP attributes of an index/slice. Args: key: A (slice, slice) tuple. Returns: The DCPAttr of the index/slice into the matrix expression. """ shape = Shape(*ku.size(key, self.shape)) # Reduce 1x1 matrices to scalars. neg_mat = bu.to_scalar(bu.index(self.sign.neg_mat, key)) pos_mat = bu.to_scalar(bu.index(self.sign.pos_mat, key)) cvx_mat = bu.to_scalar(bu.index(self.curvature.cvx_mat, key)) conc_mat = bu.to_scalar(bu.index(self.curvature.conc_mat, key)) nonconst_mat = bu.to_scalar(bu.index(self.curvature.nonconst_mat, key)) return DCPAttr(Sign(neg_mat, pos_mat), Curvature(cvx_mat, conc_mat, nonconst_mat), shape)