| 1 | package dstream |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestReplaceColumn1(t *testing.T) { |
| 6 | |
| 7 | x := [][]interface{}{ |
| 8 | { |
| 9 | []float64{5, 8, 1}, |
| 10 | []float64{2, 1, 3, 1}, |
| 11 | }, |
| 12 | { |
| 13 | []float64{5, 8, 1}, |
| 14 | []float64{2, 1, 3, 1}, |
| 15 | }, |
| 16 | { |
| 17 | []float64{2, 3, 4}, |
| 18 | []float64{1, 2, 1, 1}, |
| 19 | }, |
| 20 | } |
| 21 | |
| 22 | da := NewFromArrays(x, []string{"x0", "x1", "x2"}) |
| 23 | |
| 24 | v := []float64{2, 3, 4, 5, 6, 7, 8} |
| 25 | dx := ReplaceColumn(da, "x2", v) |
| 26 | |
| 27 | x[2] = []interface{}{ |
| 28 | []float64{2, 3, 4}, |
| 29 | []float64{5, 6, 7, 8}, |
| 30 | } |
| 31 | db := NewFromArrays(x, []string{"x0", "x1", "x2"}) |
| 32 | |
| 33 | for j := 0; j < 2; j++ { |
| 34 | if !EqualReport(dx, db, true) { |
| 35 | t.Fail() |
| 36 | } |
| 37 | dx = MemCopy(dx, true) |
| 38 | } |
| 39 | } |