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

Method validate

plot/plotcore/tablexy.go:75–103  ·  view source on GitHub ↗

validate returns error message if column indexes are invalid, else nil it also sets column indexes to 0 so nothing crashes.

()

Source from the content-addressed store, hash-verified

73// validate returns error message if column indexes are invalid, else nil
74// it also sets column indexes to 0 so nothing crashes.
75func (txy *tableXY) validate() error {
76 if txy.table == nil {
77 return errors.New("eplot.TableXY table is nil")
78 }
79 nc := txy.table.Table.NumColumns()
80 if txy.xColumn >= nc || txy.xColumn < 0 {
81 txy.xColumn = 0
82 return errors.New("eplot.TableXY XColumn index invalid -- reset to 0")
83 }
84 if txy.yColumn >= nc || txy.yColumn < 0 {
85 txy.yColumn = 0
86 return errors.New("eplot.TableXY YColumn index invalid -- reset to 0")
87 }
88 xc := txy.table.Table.Columns[txy.xColumn]
89 yc := txy.table.Table.Columns[txy.yColumn]
90 if xc.NumDims() > 1 {
91 _, txy.xRowSize = xc.RowCellSize()
92 // note: index already validated
93 }
94 if yc.NumDims() > 1 {
95 _, txy.yRowSize = yc.RowCellSize()
96 if txy.yIndex >= txy.yRowSize || txy.yIndex < 0 {
97 txy.yIndex = 0
98 return errors.New("eplot.TableXY Y TensorIndex invalid -- reset to 0")
99 }
100 }
101 txy.filterValues()
102 return nil
103}
104
105// filterValues removes items with NaN values, and out of Y range
106func (txy *tableXY) filterValues() {

Callers 2

newTableXYFunction · 0.95
newTableXYNameFunction · 0.95

Calls 5

filterValuesMethod · 0.95
NewMethod · 0.65
NumColumnsMethod · 0.65
NumDimsMethod · 0.65
RowCellSizeMethod · 0.65

Tested by

no test coverage detected