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)
| 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. |
| 182 | func (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. |
no test coverage detected