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

Method AddColumn

tensor/table/table.go:182–193  ·  view source on GitHub ↗

AddColumn adds the given tensor as a column to the table, returning an error and not adding if the name is not unique. Automatically adjusts the shape to fit the current number of rows.

(tsr tensor.Tensor, name string)

Source from the content-addressed store, hash-verified

180// returning an error and not adding if the name is not unique.
181// Automatically adjusts the shape to fit the current number of rows.
182func (dt *Table) AddColumn(tsr tensor.Tensor, name string) error {
183 dt.ColumnNames = append(dt.ColumnNames, name)
184 err := dt.UpdateColumnNameMap()
185 if err != nil {
186 dt.ColumnNames = dt.ColumnNames[:len(dt.ColumnNames)-1]
187 return err
188 }
189 dt.Columns = append(dt.Columns, tsr)
190 rows := max(1, dt.Rows)
191 tsr.SetNumRows(rows)
192 return nil
193}
194
195// InsertColumn inserts the given tensor as a column to the table at given index,
196// returning an error and not adding if the name is not unique.

Callers 6

AddColumnOfTypeMethod · 0.95
AddTensorColumnOfTypeMethod · 0.95
AggsToTableCopyMethod · 0.80
AddColumnFunction · 0.80
AddTensorColumnFunction · 0.80
CloneMethod · 0.80

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 2

UpdateColumnNameMapMethod · 0.95
SetNumRowsMethod · 0.65

Tested by

no test coverage detected