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

Method eliminate_zeros

ot/backend.py:3185–3196  ·  view source on GitHub ↗
(self, a, threshold=0.0)

Source from the content-addressed store, hash-verified

3183 return a
3184
3185 def eliminate_zeros(self, a, threshold=0.0):
3186 if self.issparse(a):
3187 values = a.values
3188 if threshold > 0:
3189 mask = self.abs(values) <= threshold
3190 else:
3191 mask = values == 0
3192 return tf.sparse.retain(a, ~mask)
3193 else:
3194 if threshold > 0:
3195 a = tnp.where(self.abs(a) > threshold, a, 0.0)
3196 return a
3197
3198 def todense(self, a):
3199 if self.issparse(a):

Callers

nothing calls this directly

Calls 3

issparseMethod · 0.95
absMethod · 0.95
whereMethod · 0.45

Tested by

no test coverage detected