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

Method CopyCell

tensor/table/table.go:691–723  ·  view source on GitHub ↗

Copy Cell CopyCell copies into cell at given column, row from cell in other table. It is robust to differences in type; uses destination cell type. Returns error if column names are invalid.

(column string, row int, cpt *Table, cpColNm string, cpRow int)

Source from the content-addressed store, hash-verified

689// It is robust to differences in type; uses destination cell type.
690// Returns error if column names are invalid.
691func (dt *Table) CopyCell(column string, row int, cpt *Table, cpColNm string, cpRow int) bool {
692 ct := dt.ColumnByName(column)
693 if ct == nil {
694 return false
695 }
696 cpct := cpt.ColumnByName(cpColNm)
697 if cpct == nil {
698 return false
699 }
700 _, sz := ct.RowCellSize()
701 if sz == 1 {
702 if ct.IsString() {
703 ct.SetString1D(row, cpct.String1D(cpRow))
704 } else {
705 ct.SetFloat1D(row, cpct.Float1D(cpRow))
706 }
707 } else {
708 _, cpsz := cpct.RowCellSize()
709 st := row * sz
710 cst := cpRow * cpsz
711 msz := min(sz, cpsz)
712 if ct.IsString() {
713 for j := 0; j < msz; j++ {
714 ct.SetString1D(st+j, cpct.String1D(cst+j))
715 }
716 } else {
717 for j := 0; j < msz; j++ {
718 ct.SetFloat1D(st+j, cpct.Float1D(cst+j))
719 }
720 }
721 }
722 return true
723}

Callers 2

AppendRowsMethod · 0.95
AggsToTableCopyMethod · 0.80

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 7

ColumnByNameMethod · 0.95
RowCellSizeMethod · 0.65
IsStringMethod · 0.65
SetString1DMethod · 0.65
String1DMethod · 0.65
SetFloat1DMethod · 0.65
Float1DMethod · 0.65

Tested by

no test coverage detected