CopyValues returns a Values that is a copy of the values from a Valuer, or an error if there are no values, or if one of the copied values is a Infinity. NaN values are skipped in the copying process.
(vs Valuer)
| 96 | // the copied values is a Infinity. |
| 97 | // NaN values are skipped in the copying process. |
| 98 | func CopyValues(vs Valuer) (Values, error) { |
| 99 | if vs.Len() == 0 { |
| 100 | return nil, ErrNoData |
| 101 | } |
| 102 | cpy := make(Values, 0, vs.Len()) |
| 103 | for i := 0; i < vs.Len(); i++ { |
| 104 | v := vs.Value(i) |
| 105 | if math32.IsNaN(v) { |
| 106 | continue |
| 107 | } |
| 108 | if err := CheckFloats(v); err != nil { |
| 109 | return nil, err |
| 110 | } |
| 111 | cpy = append(cpy, v) |
| 112 | } |
| 113 | return cpy, nil |
| 114 | } |
| 115 | |
| 116 | ////////////////////////////////////////////////// |
| 117 | // XYer |
no test coverage detected