def __slice__(self, slc): Lambda_slc = process_slice(slc, self._Lambda.shape, 0) J_slc = process_slice(slc, self._J_diff.shape, 1) Z_slc = process_slice(slc, self._Z_diff.shape, 0) X_slc = process_slice(slc, self._X.shape, 1) return Conditionals(self._Lambda[Lambda_slc], self._J_diff[J_slc], self._Z_diff[Z_slc], self._X[X_slc])
def __setslice__(self, slc, other): if not self.mutable: raise RuntimeError('Attempt to modify immutable potential') J_slc = process_slice(slc, self._J.shape, 1) Lambda_slc = process_slice(slc, self._Lambda.shape, 0) Z_slc = process_slice(slc, self._Z.shape, 0) self._J[J_slc] = other._J self._Lambda[Lambda_slc] = other._Lambda self._Z[Z_slc] = other._Z
def __slice__(self, slc): d_slc = process_slice(slc, self._d.shape, 0) Q_slc = process_slice(slc, self._Q.shape, 0) sp_slc = process_slice(slc, self._s_perp.shape, 0) if all([type(s) == int for s in slc]): # NumPy doesn't like zero-dimensional object arrays return FixedEigMatrix(self._d[d_slc], self._Q[Q_slc], self._s_perp[sp_slc]) else: return EigMatrix(self._d[d_slc], self._Q[Q_slc], self._s_perp[sp_slc], self.dim)
def __setslice__(self, slc, other): if not self.mutable: raise RuntimeError('Attempt to modify an immutable matrix') if isinstance(other, DiagonalMatrix): slc = process_slice(slc, self._s.shape, 1) self._s[slc] = other._s else: raise RuntimeError('Cannot assign a DiagonalMatrix to a %s' % other.__class__)
def __slice__(self, slc): d_slc = process_slice(slc, self._d.shape, 1) Q_slc = process_slice(slc, self._Q.shape, 2) sp_slc = process_slice(slc, self._s_perp.shape, 0) return FixedEigMatrix(self._d[d_slc], self._Q[Q_slc], self._s_perp[sp_slc])
def __setslice__(self, slc, other): if not self.mutable: raise RuntimeError('Attempt to modify an immutable matrix') S_slc = process_slice(slc, self._S.shape, 2) self._S[S_slc] += other.full()._S
def __slice__(self, slc): S_slc = process_slice(slc, self._S.shape, 2) return FullMatrix(self._S[S_slc])
def __slice__(self, slc): slc = process_slice(slc, self._s.shape, 1) return DiagonalMatrix(self._s[slc])
def __slice__(self, slc): J_slc = process_slice(slc, self._J.shape, 1) Lambda_slc = process_slice(slc, self._Lambda.shape, 0) Z_slc = process_slice(slc, self._Z.shape, 0) return Potential(self._J[J_slc], self._Lambda[Lambda_slc], self._Z[Z_slc])
def __slice__(self, slc): mu_slc = process_slice(slc, self._mu.shape, 1) Sigma_slc = process_slice(slc, self._Sigma.shape, 0) Z_slc = process_slice(slc, self._Z.shape, 0) return Distribution(self._mu[mu_slc], self._Sigma[Sigma_slc], self._Z[Z_slc])