(self, Var)
| 3113 | |
| 3114 | @requires_sparse |
| 3115 | def test_from_sparse(self, Var): |
| 3116 | if Var is IndexVariable: |
| 3117 | pytest.skip("Can't have 2D IndexVariables") |
| 3118 | |
| 3119 | import sparse |
| 3120 | |
| 3121 | arr = np.diagflat([1, 2, 3]) |
| 3122 | coords = np.array([[0, 1, 2], [0, 1, 2]]) |
| 3123 | sparr = sparse.COO(coords=coords, data=[1, 2, 3], shape=(3, 3)) |
| 3124 | v = Variable(["x", "y"], sparr) |
| 3125 | |
| 3126 | assert_identical(v.as_numpy(), Variable(["x", "y"], arr)) |
| 3127 | np.testing.assert_equal(v.to_numpy(), arr) |
| 3128 | |
| 3129 | @requires_cupy |
| 3130 | def test_from_cupy(self, Var): |
nothing calls this directly
no test coverage detected