<commit_before>package main

import (
	"fmt"
	"log"
	"os"

	"github.com/ecc1/cc1101"
)

func main() {
	log.SetFlags(log.Ltime | log.Lmicroseconds | log.LUTC)
	if len(os.Args) != 2 {
		log.Fatalf("Usage: %s frequency\n", os.Args[0])
	}
	frequency := getFrequency(os.Args[1])
	log.Printf("setting frequency to %d\n", frequency)
	r, err := cc1101.Open()
	if err != nil {
		log.Fatal(err)
	}
	err = r.Init(frequency)
	if err != nil {
		log.Fatal(err)
	}
	for packet := range r.Incoming() {
		log.Printf("% X (RSSI = %d)\n", packet.Data, packet.Rssi)
	}
}

func getFrequency(s string) uint32 {
	MHz := 0.0
	n, err := fmt.Sscanf(s, "%f", &MHz)
	if err == nil && n == 1 && 860.0 <= MHz && MHz <= 920.0 {
		return uint32(MHz * 1000000.0)
	}
	Hz := uint32(0)
	n, err = fmt.Sscanf(s, "%d", &Hz)
	if err == nil && n == 1 && 860000000 <= Hz && Hz <= 920000000 {
		return Hz
	}
	if err != nil {
		log.Fatalf("Argument (%s): %v\n", s, err)
	}
	log.Fatalf("Argument (%s) should be the pump frequency in MHz or Hz\n", s)
	panic("unreachable")
}<commit_msg>Improve frequency parsing in receive test program<commit_after>package main

import (
	"log"
	"os"
	"strconv"

	"github.com/ecc1/cc1101"
)

func main() {
	log.SetFlags(log.Ltime | log.Lmicroseconds | log.LUTC)
	if len(os.Args) != 2 {
		log.Fatalf("Usage: %s frequency\n", os.Args[0])
	}
	frequency := getFrequency(os.Args[1])
	log.Printf("setting frequency to %d\n", frequency)
	r, err := cc1101.Open()
	if err != nil {
		log.Fatal(err)
	}
	err = r.Init(frequency)
	if err != nil {
		log.Fatal(err)
	}
	for packet := range r.Incoming() {
		log.Printf("% X (RSSI = %d)\n", packet.Data, packet.Rssi)
	}
}

func getFrequency(s string) uint32 {
	f, err := strconv.ParseFloat(s, 64)
	if err != nil {
		log.Fatal(err)
	}
	if 860.0 <= f && f <= 920.0 {
		return uint32(f * 1000000.0)
	}
	if 860000000.0 <= f && f <= 920000000.0 {
		return uint32(f)
	}
	log.Fatalf("%s: invalid pump frequency\n", s)
	panic("unreachable")
}
{'fraction_non_alphanumeric': 0.19232736572890025, 'fraction_numerical': 0.05780051150895141, 'mean_word_length': 3.415349887133183, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '7608586', 'n_tokens_mistral': 936, 'n_tokens_neox': 825, 'n_words': 199}