<commit_before>package local

import (
	"math"

	"github.com/ready-steady/adapt/algorithm/external"
)

// Target is a function to be interpolated.
type Target interface {
	// Dimensions returns the number of inputs and outputs.
	Dimensions() (uint, uint)

	// Continue decides if the interpolation process should go on.
	Continue(*external.Progress) bool

	// Compute evaluates the target function at a point.
	Compute([]float64, []float64)

	// Score assigns a score to a location.
	Score(*Location) float64
}

// Location contains information about a spacial location.
type Location struct {
	Index   []uint64  // Index of the grid node
	Volume  float64   // Volume of the basis function
	Value   []float64 // Target-function value
	Surplus []float64 // Hierarchical surplus
}

// BasicTarget is a basic target satisfying the Target interface.
type BasicTarget struct {
	ContinueHandler func(*external.Progress) bool
	ComputeHandler  func([]float64, []float64) // != nil
	ScoreHandler    func(*Location) float64

	ni uint
	no uint

	absolute float64
}

// NewTarget creates a basic target.
func NewTarget(inputs, outputs uint, absolute float64,
	compute func([]float64, []float64)) *BasicTarget {

	return &BasicTarget{
		ni: inputs,
		no: outputs,

		absolute: absolute,

		ComputeHandler: compute,
	}
}

func (self *BasicTarget) Dimensions() (uint, uint) {
	return self.ni, self.no
}

func (self *BasicTarget) Continue(progress *external.Progress) bool {
	if self.ContinueHandler != nil {
		return self.ContinueHandler(progress)
	} else {
		return true
	}
}

func (self *BasicTarget) Compute(node, value []float64) {
	self.ComputeHandler(node, value)
}

func (self *BasicTarget) Score(location *Location) (score float64) {
	if self.ScoreHandler != nil {
		score = self.ScoreHandler(location)
	} else {
		for _, ε := range location.Surplus {
			if math.Abs(ε) > self.absolute {
				score = 1.0
				break
			}<commit_msg>a/local: make a cosmetic adjustment<commit_after>package local

import (
	"math"

	"github.com/ready-steady/adapt/algorithm/external"
)

// Target is a function to be interpolated.
type Target interface {
	// Dimensions returns the number of inputs and outputs.
	Dimensions() (uint, uint)

	// Continue decides if the interpolation process should go on.
	Continue(*external.Progress) bool

	// Compute evaluates the target function at a point.
	Compute([]float64, []float64)

	// Score assigns a score to a location.
	Score(*Location) float64
}

// Location contains information about a spacial location.
type Location struct {
	Index   []uint64  // Index of the grid node
	Volume  float64   // Volume of the basis function
	Value   []float64 // Target-function value
	Surplus []float64 // Hierarchical surplus
}

// BasicTarget is a basic target satisfying the Target interface.
type BasicTarget struct {
	ContinueHandler func(*external.Progress) bool
	ComputeHandler  func([]float64, []float64) // != nil
	ScoreHandler    func(*Location) float64

	ni uint
	no uint

	absolute float64
}

// NewTarget creates a basic target.
func NewTarget(inputs, outputs uint, absolute float64,
	compute func([]float64, []float64)) *BasicTarget {

	return &BasicTarget{
		ComputeHandler: compute,

		ni: inputs,
		no: outputs,

		absolute: absolute,
	}
}

func (self *BasicTarget) Dimensions() (uint, uint) {
	return self.ni, self.no
}

func (self *BasicTarget) Continue(progress *external.Progress) bool {
	if self.ContinueHandler != nil {
		return self.ContinueHandler(progress)
	} else {
		return true
	}
}

func (self *BasicTarget) Compute(node, value []float64) {
	self.ComputeHandler(node, value)
}

func (self *BasicTarget) Score(location *Location) (score float64) {
	if self.ScoreHandler != nil {
		score = self.ScoreHandler(location)
	} else {
		for _, ε := range location.Surplus {
			if math.Abs(ε) > self.absolute {
				score = 1.0
				break
			}
{'fraction_non_alphanumeric': 0.10496380558428128, 'fraction_numerical': 0.017580144777662874, 'mean_word_length': 3.9475703324808182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '740019', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1148, 'n_words': 394}