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

Method IndexIsValid

tensor/shape.go:96–106  ·  view source on GitHub ↗

IndexIsValid() returns true if given index is valid (within ranges for all dimensions)

(idx []int)

Source from the content-addressed store, hash-verified

94
95// IndexIsValid() returns true if given index is valid (within ranges for all dimensions)
96func (sh *Shape) IndexIsValid(idx []int) bool {
97 if len(idx) != sh.NumDims() {
98 return false
99 }
100 for i, v := range sh.Sizes {
101 if idx[i] < 0 || idx[i] >= v {
102 return false
103 }
104 }
105 return true
106}
107
108// IsEqual returns true if this shape is same as other (does not compare names)
109func (sh *Shape) IsEqual(oth *Shape) bool {

Callers 3

UseColorIndexMethod · 0.45
configSpritesMethod · 0.45
drawSpritesMethod · 0.45

Calls 1

NumDimsMethod · 0.95

Tested by

no test coverage detected