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

Method from_numpy

ot/backend.py:274–279  ·  view source on GitHub ↗

Creates tensors cloning a numpy array, with the given precision (defaulting to input's precision) and the given device (in case of GPUs)

(self, *arrays, type_as=None)

Source from the content-addressed store, hash-verified

272
273 # convert batch of arrays from numpy
274 def from_numpy(self, *arrays, type_as=None):
275 """Creates tensors cloning a numpy array, with the given precision (defaulting to input's precision) and the given device (in case of GPUs)"""
276 if len(arrays) == 1:
277 return self._from_numpy(arrays[0], type_as=type_as)
278 else:
279 return [self._from_numpy(array, type_as=type_as) for array in arrays]
280
281 # convert an array from numpy
282 def _from_numpy(self, a, type_as=None):

Callers 15

test_empty_backendFunction · 0.95
_init_lr_sinkhornFunction · 0.80
phiFunction · 0.80
line_search_armijoFunction · 0.80
list_to_arrayFunction · 0.80
distFunction · 0.80
fun_numpyFunction · 0.80
_benchMethod · 0.80
coo_matrixMethod · 0.80
_benchMethod · 0.80

Calls 1

_from_numpyMethod · 0.95

Tested by 15

test_empty_backendFunction · 0.76
test_partial_wassersteinFunction · 0.64
test_solveFunction · 0.64
test_solve_gridFunction · 0.64
test_solve_gromovFunction · 0.64
test_solve_gromov_gridFunction · 0.64
test_solve_sampleFunction · 0.64
test_solve_sample_lazyFunction · 0.64