cmd/bosun: isnan func
merging ahead of documentation at craig's request
@@ -347,6 +347,12 @@ var builtins = map[string]parse.Func{
Tags: tagFirst,
F: Limit,
},
+ "isnan": {
+ Args: []models.FuncType{models.TypeNumberSet},
+ F: IsNaN,
+ Return: models.TypeNumberSet,
+ Tags: tagFirst,
+ },
"nv": {
Args: []models.FuncType{models.TypeNumberSet, models.TypeScalar},
Return: models.TypeNumberSet,
@@ -720,6 +726,17 @@ func Epoch(e *State) (*Results, error) {
}, nil
}
+func IsNaN(e *State, nSet *Results) (*Results, error) {
+ for _, res := range nSet.Results {
+ if math.IsNaN(float64(res.Value.Value().(Number))) {
+ res.Value = Number(1)
+ continue
+ }
+ res.Value = Number(0)
+ }
+ return nSet, nil
+}
+
func Month(e *State, offset float64, startEnd string) (*Results, error) {
if startEnd != "start" && startEnd != "end" {
return nil, fmt.Errorf("last parameter for mtod must be 'start' or 'end'")
