MCPcopy
hub / github.com/nlpodyssey/spago / testDenseSet

Function testDenseSet

mat/dense_test.go:144–220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

142}
143
144func testDenseSet[T float.DType](t *testing.T) {
145 t.Run("given matrix not 1×1", func(t *testing.T) {
146 d := NewDense[T](WithShape(2, 2))
147 require.Panics(t, func() {
148 d.SetAt(NewDense[T](WithShape(1, 2)), 1, 1)
149 })
150 })
151
152 t.Run("negative row", func(t *testing.T) {
153 d := NewDense[T](WithShape(2, 3))
154 require.Panics(t, func() {
155 d.SetAt(Scalar(T(42)), -1, 1)
156 })
157 })
158
159 t.Run("negative col", func(t *testing.T) {
160 d := NewDense[T](WithShape(2, 3))
161 require.Panics(t, func() {
162 d.SetAt(Scalar(T(42)), 1, -1)
163 })
164 })
165
166 t.Run("row out of upper bound", func(t *testing.T) {
167 d := NewDense[T](WithShape(2, 3))
168 require.Panics(t, func() {
169 d.SetAt(Scalar(T(42)), 2, 1)
170 })
171 })
172
173 t.Run("col out of upper bound", func(t *testing.T) {
174 d := NewDense[T](WithShape(2, 3))
175 require.Panics(t, func() {
176 d.SetAt(Scalar(T(42)), 1, 3)
177 })
178 })
179
180 testCases := []struct {
181 r int
182 c int
183 setR int
184 setC int
185 d []T
186 }{
187 {1, 1, 0, 0, []T{42}},
188
189 {2, 1, 0, 0, []T{42, 0}},
190 {2, 1, 1, 0, []T{0, 42}},
191
192 {1, 2, 0, 0, []T{42, 0}},
193 {1, 2, 0, 1, []T{0, 42}},
194
195 {2, 2, 0, 0, []T{
196 42, 0,
197 0, 0,
198 }},
199 {2, 2, 0, 1, []T{
200 0, 42,
201 0, 0,

Callers

nothing calls this directly

Calls 5

WithShapeFunction · 0.85
ScalarFunction · 0.85
RunMethod · 0.80
TInterface · 0.70
SetAtMethod · 0.65

Tested by

no test coverage detected