<commit_before>package pgtype

import (
	"database/sql/driver"
	"encoding/binary"
	"fmt"
	"math"
	"strconv"
	"strings"

	"github.com/jackc/pgio"
	errors "golang.org/x/xerrors"
)

type Polygon struct {
	P      []Vec2
	Status Status
}

func (dst *Polygon) Set(src interface{}) error {
	if src == nil {
		dst.Status = Null
		return nil
	}
	err := errors.Errorf("cannot convert %v to Polygon", src)
	var p *Polygon
	switch value := src.(type) {
	case string:
		p, err = parseString(value)
	case []Vec2:
		p = &Polygon{Status: Present, P: value}
		err = nil
	case []float64:
		p, err = parseFloat64(value)
	default:
		return err
	}
	if err != nil {
		return err
	}
	*dst = *p
	return nil
}

func parseString(src string) (*Polygon, error) {
	p := &Polygon{}
	err := p.DecodeText(nil, []byte(src))
	return p, err
}

func parseFloat64(src []float64) (*Polygon, error) {
	p := &Polygon{Status: Null}
	if len(src) == 0 {
		return p, nil
	}
	if len(src)%2 != 0 {
		return p, errors.Errorf("invalid length for polygon: %v", len(src))
	}
	p.Status = Present
	p.P = make([]Vec2, 0)
	for i := 0; i < len(src); i += 2 {
		p.P = append(p.P, Vec2{X: src[i], Y: src[i+1]})
	}
	return p, nil
}<commit_msg>Add Undefined status to invalid Polygon<commit_after>package pgtype

import (
	"database/sql/driver"
	"encoding/binary"
	"fmt"
	"math"
	"strconv"
	"strings"

	"github.com/jackc/pgio"
	errors "golang.org/x/xerrors"
)

type Polygon struct {
	P      []Vec2
	Status Status
}

func (dst *Polygon) Set(src interface{}) error {
	if src == nil {
		dst.Status = Null
		return nil
	}
	err := errors.Errorf("cannot convert %v to Polygon", src)
	var p *Polygon
	switch value := src.(type) {
	case string:
		p, err = parseString(value)
	case []Vec2:
		p = &Polygon{Status: Present, P: value}
		err = nil
	case []float64:
		p, err = parseFloat64(value)
	default:
		return err
	}
	if err != nil {
		return err
	}
	*dst = *p
	return nil
}

func parseString(src string) (*Polygon, error) {
	p := &Polygon{}
	err := p.DecodeText(nil, []byte(src))
	return p, err
}

func parseFloat64(src []float64) (*Polygon, error) {
	p := &Polygon{Status: Null}
	if len(src) == 0 {
		return p, nil
	}
	if len(src)%2 != 0 {
		p.Status = Undefined
		return p, errors.Errorf("invalid length for polygon: %v", len(src))
	}
	p.Status = Present
	p.P = make([]Vec2, 0)
	for i := 0; i < len(src); i += 2 {
		p.P = append(p.P, Vec2{X: src[i], Y: src[i+1]})
	}
	return p, nil
}
{'fraction_non_alphanumeric': 0.1653575857792476, 'fraction_numerical': 0.015708970649028525, 'mean_word_length': 3.4649446494464944, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4953977', 'n_tokens_mistral': 1037, 'n_tokens_neox': 984, 'n_words': 277}