String satisfies the fmt.Stringer interface for string of tensor data
()
| 86 | |
| 87 | // String satisfies the fmt.Stringer interface for string of tensor data |
| 88 | func (tsr *String) String() string { |
| 89 | str := tsr.Label() |
| 90 | sz := len(tsr.Values) |
| 91 | if sz > 1000 { |
| 92 | return str |
| 93 | } |
| 94 | var b strings.Builder |
| 95 | b.WriteString(str) |
| 96 | b.WriteString("\n") |
| 97 | oddRow := true |
| 98 | rows, cols, _, _ := Projection2DShape(&tsr.Shp, oddRow) |
| 99 | for r := 0; r < rows; r++ { |
| 100 | rc, _ := Projection2DCoords(&tsr.Shp, oddRow, r, 0) |
| 101 | b.WriteString(fmt.Sprintf("%v: ", rc)) |
| 102 | for c := 0; c < cols; c++ { |
| 103 | idx := Projection2DIndex(tsr.Shape(), oddRow, r, c) |
| 104 | vl := tsr.Values[idx] |
| 105 | b.WriteString(vl) |
| 106 | } |
| 107 | b.WriteString("\n") |
| 108 | } |
| 109 | return b.String() |
| 110 | } |
| 111 | |
| 112 | func (tsr *String) Float(i []int) float64 { |
| 113 | j := tsr.Shp.Offset(i) |
nothing calls this directly
no test coverage detected