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

Method UpdateColumnNameMap

tensor/table/table.go:127–144  ·  view source on GitHub ↗

UpdateColumnNameMap updates the column name map, returning an error if any of the column names are duplicates.

()

Source from the content-addressed store, hash-verified

125// UpdateColumnNameMap updates the column name map, returning an error
126// if any of the column names are duplicates.
127func (dt *Table) UpdateColumnNameMap() error {
128 nc := dt.NumColumns()
129 dt.ColumnNameMap = make(map[string]int, nc)
130 var errs []error
131 for i, nm := range dt.ColumnNames {
132 if _, has := dt.ColumnNameMap[nm]; has {
133 err := fmt.Errorf("table.Table duplicate column name: %s", nm)
134 slog.Warn(err.Error())
135 errs = append(errs, err)
136 } else {
137 dt.ColumnNameMap[nm] = i
138 }
139 }
140 if len(errs) > 0 {
141 return errors.Join(errs...)
142 }
143 return nil
144}
145
146// AddColumn adds a new column to the table, of given type and column name
147// (which must be unique). The cells of this column hold a single scalar value:

Callers 3

AddColumnMethod · 0.95
InsertColumnMethod · 0.95
DeleteColumnIndexMethod · 0.95

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 3

NumColumnsMethod · 0.95
ErrorfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected