MCPcopy Create free account
hub / github.com/cvxpy/cvxpy / test_get_variable_tensor

Method test_get_variable_tensor

cvxpy/tests/test_python_backends.py:3069–3078  ·  view source on GitHub ↗

Test CooCanonBackend.get_variable_tensor.

(self, coo_backend)

Source from the content-addressed store, hash-verified

3067 assert np.allclose(dense, expected)
3068
3069 def test_get_variable_tensor(self, coo_backend):
3070 """Test CooCanonBackend.get_variable_tensor."""
3071 outer = coo_backend.get_variable_tensor((2,), 1)
3072 assert outer.keys() == {1}, "Should only be in variable with ID 1"
3073 inner = outer[1]
3074 assert inner.keys() == {-1}, "Should only be in parameter slice -1"
3075 tensor = inner[-1]
3076 assert isinstance(tensor, CooTensor)
3077 assert tensor.m == 2 and tensor.n == 2
3078 assert np.all(tensor.toarray() == np.eye(2))
3079
3080 def test_get_data_tensor(self, coo_backend):
3081 """Test CooCanonBackend.get_data_tensor."""

Callers

nothing calls this directly

Calls 4

keysMethod · 0.80
toarrayMethod · 0.80
get_variable_tensorMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected