MCPcopy Create free account
hub / github.com/cogentcore/core / String

Method String

tensor/string.go:88–110  ·  view source on GitHub ↗

String satisfies the fmt.Stringer interface for string of tensor data

()

Source from the content-addressed store, hash-verified

86
87// String satisfies the fmt.Stringer interface for string of tensor data
88func (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
112func (tsr *String) Float(i []int) float64 {
113 j := tsr.Shp.Offset(i)

Callers

nothing calls this directly

Calls 7

Projection2DShapeFunction · 0.85
Projection2DCoordsFunction · 0.85
Projection2DIndexFunction · 0.85
WriteStringMethod · 0.80
LabelMethod · 0.65
ShapeMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected