<commit_before>package series

import (
	"fmt"
	"math"
	"strconv"
	"strings"
)

type stringElement struct {
	e *string
}

func (e stringElement) Set(value interface{}) Element {
	var val string
	switch value.(type) {
	case string:
		val = value.(string)
	case int:
		val = strconv.Itoa(value.(int))
	case float64:
		val = strconv.FormatFloat(value.(float64), 'f', 6, 64)
	case bool:
		b := value.(bool)
		if b {
			val = "true"
		} else {
			val = "false"
		}
	case Element:
		val = value.(Element).String()
	default:
		e.e = nil
		return e
	}
	e.e = &val
	return e
}

func (e stringElement) Copy() Element {
	if e.e == nil {
		return stringElement{nil}
	}
	copy := *e.e
	return stringElement{&copy}
}

func (e stringElement) IsNA() bool {
	if e.e == nil {
		return true
	}
	return false
}

func (e stringElement) Type() Type {
	return String
}

func (e stringElement) Val() ElementValue {
	if e.IsNA() {
		return nil
	}
	return *e.e
}

func (e stringElement) String() string {
	if e.e == nil {
		return "NaN"
	}
	return *e.e
}

func (e stringElement) Int() (int, error) {
	if e.IsNA() {
		return 0, fmt.Errorf("can't convert NaN to int")
	}
	return strconv.Atoi(*e.e)
}

func (e stringElement) Float() float64 {
	if e.IsNA() {
		return math.NaN()
	}
	f, _ := strconv.ParseFloat(*e.e, 64)
	return f
}

func (e stringElement) Bool() (bool, error) {
	if e.IsNA() {
		return false, fmt.Errorf("can't convert NaN to bool")
	}
	switch strings.ToLower(*e.e) {
	case "true", "t", "1":
		return true, nil
	case "false", "f", "0":
		return false, nil
	}
	return false, fmt.Errorf("can't convert String \"%v\" to bool", *e.e)
}
<commit_msg>Fix stringElement.Float returning 0 when should be NaN<commit_after>package series

import (
	"fmt"
	"math"
	"strconv"
	"strings"
)

type stringElement struct {
	e *string
}

func (e stringElement) Set(value interface{}) Element {
	var val string
	switch value.(type) {
	case string:
		val = value.(string)
	case int:
		val = strconv.Itoa(value.(int))
	case float64:
		val = strconv.FormatFloat(value.(float64), 'f', 6, 64)
	case bool:
		b := value.(bool)
		if b {
			val = "true"
		} else {
			val = "false"
		}
	case Element:
		val = value.(Element).String()
	default:
		e.e = nil
		return e
	}
	e.e = &val
	return e
}

func (e stringElement) Copy() Element {
	if e.e == nil {
		return stringElement{nil}
	}
	copy := *e.e
	return stringElement{&copy}
}

func (e stringElement) IsNA() bool {
	if e.e == nil {
		return true
	}
	return false
}

func (e stringElement) Type() Type {
	return String
}

func (e stringElement) Val() ElementValue {
	if e.IsNA() {
		return nil
	}
	return *e.e
}

func (e stringElement) String() string {
	if e.e == nil {
		return "NaN"
	}
	return *e.e
}

func (e stringElement) Int() (int, error) {
	if e.IsNA() {
		return 0, fmt.Errorf("can't convert NaN to int")
	}
	return strconv.Atoi(*e.e)
}

func (e stringElement) Float() float64 {
	if e.IsNA() {
		return math.NaN()
	}
	f, err := strconv.ParseFloat(*e.e, 64)
	if err != nil {
		return math.NaN()
	}
	return f
}

func (e stringElement) Bool() (bool, error) {
	if e.IsNA() {
		return false, fmt.Errorf("can't convert NaN to bool")
	}
	switch strings.ToLower(*e.e) {
	case "true", "t", "1":
		return true, nil
	case "false", "f", "0":
		return false, nil
	}
	return false, fmt.Errorf("can't convert String \"%v\" to bool", *e.e)
}

{'fraction_non_alphanumeric': 0.15913849835477117, 'fraction_numerical': 0.008674842955429255, 'mean_word_length': 3.2653061224489797, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3910291', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1323, 'n_words': 391}