COO sparse matrix container.
| 99 | |
| 100 | |
| 101 | class COO(NamedTuple): |
| 102 | """ |
| 103 | COO sparse matrix container. |
| 104 | """ |
| 105 | |
| 106 | i: ArrayI |
| 107 | j: ArrayI |
| 108 | v: Array |
| 109 | shape: tuple[int, int] |
| 110 | |
| 111 | def coo(self): |
| 112 | |
| 113 | return sp.coo_matrix((self.v, (self.i, self.j)), shape=self.shape) |
| 114 | |
| 115 | def cooarr(self): |
| 116 | |
| 117 | return sp.coo_array((self.v, (self.i, self.j)), shape=self.shape) |
| 118 | |
| 119 | def csc(self): |
| 120 | |
| 121 | return self.coo().tocsc() |
| 122 | |
| 123 | def csr(self): |
| 124 | |
| 125 | return self.coo().tocsr() |
| 126 | |
| 127 | @classmethod |
| 128 | def fromSP(cls, sparr: sp.sparray | sp.spmatrix): |
| 129 | """ |
| 130 | Helper for converting from any SciPy sparse array or matrix. |
| 131 | """ |
| 132 | |
| 133 | tmp = sparr.tocoo() |
| 134 | |
| 135 | return cls(tmp.row, tmp.col, tmp.data, tmp.shape) |
| 136 | |
| 137 | |
| 138 | class Curve(NamedTuple): |
no outgoing calls
no test coverage detected