Returns X without the row(s) at index/indices I
(
X: modALinput, I: Union[int, List[int], np.ndarray]
)
| 123 | |
| 124 | |
| 125 | def drop_rows( |
| 126 | X: modALinput, I: Union[int, List[int], np.ndarray] |
| 127 | ) -> Union[sp.csc_matrix, np.ndarray, pd.DataFrame]: |
| 128 | """ |
| 129 | Returns X without the row(s) at index/indices I |
| 130 | """ |
| 131 | if sp.issparse(X): |
| 132 | mask = np.ones(X.shape[0], dtype=bool) |
| 133 | mask[I] = False |
| 134 | return retrieve_rows(X, mask) |
| 135 | elif isinstance(X, pd.DataFrame): |
| 136 | return X.drop(I, axis=0) |
| 137 | elif isinstance(X, np.ndarray): |
| 138 | return np.delete(X, I, axis=0) |
| 139 | elif isinstance(X, list): |
| 140 | return np.delete(X, I, axis=0).tolist() |
| 141 | |
| 142 | try: |
| 143 | if torch.is_tensor(blocks[0]): |
| 144 | return torch.cat(blocks) |
| 145 | except: |
| 146 | X[[True if row not in I else False for row in range(X.size(0))]] |
| 147 | |
| 148 | raise TypeError("%s datatype is not supported" % type(X)) |
| 149 | |
| 150 | |
| 151 | def enumerate_data(X: modALinput): |
no test coverage detected
searching dependent graphs…