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

Function get_LazyTensor

test/test_utils.py:38–56  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

36
37
38def get_LazyTensor(nx):
39 n1 = 100
40 n2 = 200
41
42 rng = np.random.RandomState(42)
43 a = rng.rand(n1)
44 a /= a.sum()
45 b = rng.rand(n2)
46 b /= b.sum()
47
48 a, b = nx.from_numpy(a, b)
49
50 def getitem(i, j, a, b):
51 return a[i, None] * b[None, j]
52
53 # create a lazy tensor
54 T = ot.utils.LazyTensor((n1, n2), getitem, a=a, b=b)
55
56 return T, a, b
57
58
59def test_proj_simplex(nx):

Callers 2

test_OTResult_LazyTensorFunction · 0.85
test_LazyTensor_reduceFunction · 0.85

Calls 3

from_numpyMethod · 0.80
randMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected