MCPcopy Create free account
hub / github.com/PythonOT/POT / coo_matrix

Method coo_matrix

ot/backend.py:3162–3177  ·  view source on GitHub ↗
(self, data, rows, cols, shape=None, type_as=None)

Source from the content-addressed store, hash-verified

3160 return int(np.max(tensor)) + 1
3161
3162 def coo_matrix(self, data, rows, cols, shape=None, type_as=None):
3163 if shape is None:
3164 shape = (
3165 self._convert_to_index_for_coo(rows),
3166 self._convert_to_index_for_coo(cols),
3167 )
3168 if type_as is not None:
3169 data = self.from_numpy(data, type_as=type_as)
3170
3171 sparse_tensor = tf.sparse.SparseTensor(
3172 indices=tnp.stack([rows, cols]).T, values=data, dense_shape=shape
3173 )
3174 # if type_as is not None:
3175 # sparse_tensor = self.from_numpy(sparse_tensor, type_as=type_as)
3176 # SparseTensor are not subscriptable so we use dense tensors
3177 return self.todense(sparse_tensor)
3178
3179 def issparse(self, a):
3180 return isinstance(a, tf.sparse.SparseTensor)

Callers

nothing calls this directly

Calls 4

todenseMethod · 0.95
from_numpyMethod · 0.80
stackMethod · 0.45

Tested by

no test coverage detected