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

Method TableHeaders

tensor/table/io.go:529–569  ·  view source on GitHub ↗

TableHeaders generates special header strings from the table with full information about type and tensor cell dimensionality.

()

Source from the content-addressed store, hash-verified

527// TableHeaders generates special header strings from the table
528// with full information about type and tensor cell dimensionality.
529func (dt *Table) TableHeaders() []string {
530 hdrs := []string{}
531 for i := range dt.Columns {
532 tsr := dt.Columns[i]
533 nm := dt.ColumnNames[i]
534 nm = string([]byte{TableHeaderChar(tsr.DataType())}) + nm
535 if tsr.NumDims() == 1 {
536 hdrs = append(hdrs, nm)
537 } else {
538 csh := tensor.NewShape(tsr.Shape().Sizes[1:]) // cell shape
539 tc := csh.Len()
540 nd := csh.NumDims()
541 fnm := nm + fmt.Sprintf("[%v:", nd)
542 dn := fmt.Sprintf("<%v:", nd)
543 ffnm := fnm
544 for di := 0; di < nd; di++ {
545 ffnm += "0"
546 dn += fmt.Sprintf("%v", csh.DimSize(di))
547 if di < nd-1 {
548 ffnm += ","
549 dn += ","
550 }
551 }
552 ffnm += "]" + dn + ">"
553 hdrs = append(hdrs, ffnm)
554 for ti := 1; ti < tc; ti++ {
555 idx := csh.Index(ti)
556 ffnm := fnm
557 for di := 0; di < nd; di++ {
558 ffnm += fmt.Sprintf("%v", idx[di])
559 if di < nd-1 {
560 ffnm += ","
561 }
562 }
563 ffnm += "]"
564 hdrs = append(hdrs, ffnm)
565 }
566 }
567 }
568 return hdrs
569}

Callers 2

WriteCSVHeadersMethod · 0.95
TestTableHeadersFunction · 0.95

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 9

LenMethod · 0.95
NumDimsMethod · 0.95
DimSizeMethod · 0.95
IndexMethod · 0.95
NewShapeFunction · 0.92
TableHeaderCharFunction · 0.85
DataTypeMethod · 0.65
NumDimsMethod · 0.65
ShapeMethod · 0.65

Tested by 1

TestTableHeadersFunction · 0.76