code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
package lexer
// A structure that represents a Lexer
type Lexer struct {
// Represents the input to the lexer
input string
// Represents the position in the input (current char)
positionCurrent int
// Represents the current reading position (after current char)
positionNext int
// Represents the current char... | lexer/lexer.go | 0.735737 | 0.465813 | lexer.go | starcoder |
package geomfn
import (
"github.com/cockroachdb/cockroach/pkg/geo"
"github.com/twpayne/go-geom"
)
// Reverse returns a modified geometry by reversing the order of its vertexes
func Reverse(geometry geo.Geometry) (geo.Geometry, error) {
g, err := geometry.AsGeomT()
if err != nil {
return geo.Geometry{}, err
}
... | pkg/geo/geomfn/reverse.go | 0.835986 | 0.401365 | reverse.go | starcoder |
package i18n
// This can be used as independent library
var iso3166_1_alpha2 map[string]string
func EnglishCountryName(code string) string {
name, ok := Countries()[code]
if !ok {
return code
}
return name
}
// Countries returns a map of ISO 3166-1 alpha-2 country codes
// to the corresponding english country... | i18n/countries.go | 0.525125 | 0.482734 | countries.go | starcoder |
package quickfix
import "honnef.co/go/tools/analysis/lint"
var Docs = lint.Markdownify(map[string]*lint.RawDocumentation{
"QF1001": {
Title: "Apply De Morgan's law",
Since: "2021.1",
Severity: lint.SeverityHint,
},
"QF1002": {
Title: "Convert untagged switch to tagged switch",
Text: `
An untagged ... | hack/tools/vendor/honnef.co/go/tools/quickfix/doc.go | 0.603231 | 0.615146 | doc.go | starcoder |
package bn256
import (
"math/big"
)
// twistPoint implements the elliptic curve y²=x³+3/ξ over GF(p²). Points are
// kept in Jacobian form and t=z² when valid. The group G₂ is the set of
// n-torsion points of this curve over GF(p²) (where n = Order)
type twistPoint struct {
x, y, z, t *gfP2
}
var twistB = &gfP2{... | vendor/golang.org/x/crypto/bn256/twist.go | 0.764804 | 0.512205 | twist.go | starcoder |
package twilight
import (
"time"
)
func lenToDuration(len float64) time.Duration {
return time.Duration(float64(time.Hour) * len)
}
type SunriseStatus int
const (
SunriseStatusOK = SunriseStatus(0)
SunriseStatusAboveHorizon = SunriseStatus(1)
SunriseStatusBelowHorizon = SunriseStatus(-1)
)
func DayL... | twilight.go | 0.828523 | 0.565239 | twilight.go | starcoder |
package tin
import "math"
const (
MAX_AVERAGING_SAMPLES = 64
)
func average(toAverage [MAX_AVERAGING_SAMPLES]float64, avgCount int) float64 {
if avgCount == 0 {
return math.NaN()
}
sum := float64(0)
for i := 0; i < MAX_AVERAGING_SAMPLES; i++ {
sum += toAverage[i]
}
avg := sum / float64(avgCount)
return a... | raster_tools.go | 0.656438 | 0.436922 | raster_tools.go | starcoder |
package circle
import (
//. "github.com/y0ssar1an/q"
"image"
"image/color"
"math"
)
func Simple(x, y, radius int) *Circle {
return &Circle{
Point: image.Pt(x, y),
Radius: radius,
}
}
// Circle implements image.Image
// godoc image Image
type Circle struct {
Point image.Point
Radius int
}
func (c *Circ... | circle/circle.go | 0.817064 | 0.507385 | circle.go | starcoder |
package network
import (
"math/rand"
)
// Matrix is an alias for [][]float64
type Matrix [][]float64
// RandomMatrix returns the value of a random matrix of *rows* and *columns* dimensions and
// where the values are between *lower* and *upper*.
func RandomMatrix(rows, columns int) (matrix Matrix) {
matrix = make(... | back/network/matrix.go | 0.887211 | 0.8321 | matrix.go | starcoder |
package main
import (
"github.com/anaseto/gruid"
)
func distance(from, to gruid.Point) int {
delta := to.Sub(from)
return abs(delta.X) + abs(delta.Y)
}
func distanceChebyshev(from, to gruid.Point) int {
delta := to.Sub(from)
deltaX := abs(delta.X)
deltaY := abs(delta.Y)
if deltaX > deltaY {
return deltaX
}... | pos.go | 0.723798 | 0.476519 | pos.go | starcoder |
package httpref
var Headers = References{
{
Name: "Headers",
IsTitle: true,
Summary: "Guidance about headers",
Description: `HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:),... | headers.go | 0.84367 | 0.434521 | headers.go | starcoder |
package topo
import (
"gonum.org/v1/gonum/graph"
"gonum.org/v1/gonum/graph/internal/set"
)
// VertexOrdering returns the vertex ordering and the k-cores of
// the undirected graph g.
func VertexOrdering(g graph.Undirected) (order []graph.Node, cores [][]graph.Node) {
nodes := g.Nodes()
// The algorithm used her... | graph/topo/bron_kerbosch.go | 0.604399 | 0.477432 | bron_kerbosch.go | starcoder |
package processor
import (
"encoding/json"
"errors"
"fmt"
"strings"
"time"
"github.com/Jeffail/benthos/v3/lib/bloblang/x/field"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.c... | lib/processor/json.go | 0.811713 | 0.789153 | json.go | starcoder |
package bindata
// fmtInt formats v into the tail of buf.
// It returns the index where the output begins.
func fmtInt(buf []byte, v uint64) int {
w := len(buf)
if v == 0 {
w--
buf[w] = '0'
} else {
for v > 0 {
w--
buf[w] = byte(v%10) + '0'
v /= 10
}
}
return w
}
// fmtFrac formats the fraction ... | vendor/github.com/kevinburke/go-bindata/bits.go | 0.762778 | 0.536434 | bits.go | starcoder |
package pixelate
import (
"image"
"image/color"
"image/draw"
"runtime"
"hawx.me/code/img/utils"
)
// Triangle types for Pxl
type Triangle int
const (
// Decide base on closeness of colours in each quadrant
BOTH Triangle = iota
// Create only left triangles
LEFT
// Create only right triangles
RIGHT
)
f... | pixelate/pxl.go | 0.75401 | 0.444444 | pxl.go | starcoder |
package is
import (
"fmt"
"github.com/corbym/gocrest"
"reflect"
"strings"
)
//ValueContaining finds if x is contained in y.
// Acts like "ContainsAll", all elements given must be present (or must match) in actual in the same order as the expected values.
// If "expected" is an array or slice, we assume that actua... | is/contains.go | 0.67662 | 0.684429 | contains.go | starcoder |
package dicom
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"io/ioutil"
)
// BulkDataReference describes the location of a contiguous sequence of bytes in a file
type BulkDataReference struct {
Reference ByteRegion
}
// ByteRegion is a contiguous sequence of bytes in a file described by an Offset and a length... | dicom/bulkdata.go | 0.857932 | 0.458834 | bulkdata.go | starcoder |
package ast
import (
"fmt"
"github.com/gogo/protobuf/proto"
"github.com/katydid/katydid/relapse/token"
"github.com/katydid/katydid/relapse/types"
"strconv"
"strings"
"unicode/utf8"
)
//NewKeyword is a parser utility function that returns a Keyword given a space and a token.
func NewKeyword(space interface{}, ... | relapse/ast/util.go | 0.704364 | 0.477676 | util.go | starcoder |
package gojacego
type optimizer struct {
executor interpreter
}
func (this *optimizer) optimize(op operation, functionRegistry *functionRegistry, constantRegistry *constantRegistry) operation {
return optimize(this.executor, op, functionRegistry, constantRegistry)
}
func optimize(executor interpreter, op operation,... | optimizer.go | 0.665193 | 0.417331 | optimizer.go | starcoder |
package tableimage
import (
"image"
"image/draw"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
func (ti *TableImage) setRgba() {
img := image.NewRGBA(image.Rect(0, 0, ti.width, ti.height))
//set image background
draw.Draw(img, img.Bounds(), &image.Uniform{getColorByHex(ti.backgroundColor)}, imag... | table-image/basic.go | 0.542136 | 0.447279 | basic.go | starcoder |
package conformance
import "reflect"
// MutateFields modifies the value of each field of structs recursively.
func MutateFields(x interface{}) {
mut(reflect.TypeOf(x), reflect.ValueOf(x))
}
func mut(t reflect.Type, v reflect.Value) {
switch t.Kind() {
case reflect.String:
v.SetString("blip blop")
case reflec... | conformance/internal/conformance/mutate_fields.go | 0.619011 | 0.488649 | mutate_fields.go | starcoder |
package treepalette
import (
"fmt"
)
// Color express A color as A n-dimensional point in the RGBA space for usage in the kd-tree search algorithm.
// This supports both RGBA and RGB(no alpha) spaces since latter would reduce computing for cases where transparency is not important.
type Color interface {
// Dimens... | colors.go | 0.849504 | 0.609437 | colors.go | starcoder |
package trie
import (
"bufio"
"fmt"
"io"
"os"
"strings"
)
// The TrieNode interface provides information about the set of words
// after a particular prefix (which is implicit).
type TrieNode interface {
IsPrefix() bool // Is there any continuation which will result in a word?
IsWord() bool /... | trie.go | 0.680029 | 0.448366 | trie.go | starcoder |
package graph
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// AccessReviewScheduleDefinition provides operations to manage the identityGovernance ... | models/microsoft/graph/access_review_schedule_definition.go | 0.671471 | 0.419588 | access_review_schedule_definition.go | starcoder |
package options
import (
"time"
)
// CreateIndexesOptions represents all possible options for the CreateOne() and CreateMany() functions.
type CreateIndexesOptions struct {
MaxTime *time.Duration // The maximum amount of time to allow the query to run.
}
// CreateIndexes creates a new CreateIndexesOptions instanc... | vendor/go.mongodb.org/mongo-driver/mongo/options/indexoptions.go | 0.845528 | 0.607605 | indexoptions.go | starcoder |
package limiter
import (
"github.com/momokatte/go-backoff"
)
/*
FailRateLimiter combines a FailLimiter and a RateLimiter to act as a single FailLimiter.
*/
type FailRateLimiter struct {
failLimiter FailLimiter
rateLimiter RateLimiter
}
/*
NewFailRateLimiter instantiates a new FailRateLimiter with the provided max... | fail-rate.go | 0.580709 | 0.435541 | fail-rate.go | starcoder |
package bloom
import (
"github.com/pmylund/go-bitset"
"hash"
"hash/crc64"
"hash/fnv"
"math"
)
type filter64 struct {
m uint64
k uint64
h hash.Hash64
oh hash.Hash64
}
func (f *filter64) bits(data []byte) []uint64 {
f.h.Reset()
_, _ = f.h.Write(data)
a := f.h.Sum64()
f.oh.Reset()
_, _ = f.oh.Write(d... | bloom64.go | 0.843638 | 0.424293 | bloom64.go | starcoder |
package ratelimit
import (
"math"
"sync"
"time"
)
// Note: This file is inspired by:
// https://github.com/prashantv/go-bench/blob/master/ratelimit
// Limiter is used to rate limit some process, possibly across goroutines.
// The process is expected to call Take() before every iteration, which
// may block to th... | ratelimit/time_period.go | 0.725843 | 0.446434 | time_period.go | starcoder |
package steven
import (
"image"
"math"
"github.com/thinkofdeath/steven/render"
"github.com/thinkofdeath/steven/type/direction"
)
type processedModel struct {
faces []processedFace
ambientOcclusion bool
weight int
}
type processedFace struct {
cullFace direction.Type
facing ... | modelrender.go | 0.523664 | 0.450722 | modelrender.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// CloudPcOnPremisesConnection
type CloudPcOnPremisesConnection struct {
Entity
// The fully qualified domain name (FQDN) of the Active Directory domain y... | models/cloud_pc_on_premises_connection.go | 0.717903 | 0.456107 | cloud_pc_on_premises_connection.go | starcoder |
package feature
import (
"fmt"
)
type Table struct {
features []Feature
featureMap map[TypeKey]int
items []*Instance
numColumns int
numRows int
}
func CreateTable(features []Feature) *Table {
table := Table{}
featureMap := map[TypeKey]int{}
for index, feature := range features {
featureMap[feat... | feature/feature_table.go | 0.597021 | 0.44746 | feature_table.go | starcoder |
package util
import (
"bufio"
"fmt"
"log"
"os"
"os/user"
"strconv"
"unsafe"
"golang.org/x/sys/unix"
)
// Ptr converts a Go byte array to a pointer to the start of the array.
func Ptr(slice []byte) unsafe.Pointer {
if len(slice) == 0 {
return nil
}
return unsafe.Pointer(&slice[0])
}
// ByteSlice takes a... | util/util.go | 0.581065 | 0.404155 | util.go | starcoder |
// Package les implements the Light Matrix Subprotocol.
package les
import (
"math/rand"
)
// wrsItem interface should be implemented by any entries that are to be selected from
// a weightedRandomSelect set. Note that recalculating monotonously decreasing item
// weights on-demand (without constantly calling updat... | les/randselect.go | 0.7413 | 0.410047 | randselect.go | starcoder |
package assertions
import (
"fmt"
"regexp"
"strings"
"testing"
h "github.com/buildpacks/pack/testhelpers"
)
type OutputAssertionManager struct {
testObject *testing.T
assert h.AssertionManager
output string
}
func NewOutputAssertionManager(t *testing.T, output string) OutputAssertionManager {
retu... | acceptance/assertions/output.go | 0.688992 | 0.529081 | output.go | starcoder |
package advent
import (
. "github.com/davidparks11/advent2021/internal/advent/day16"
)
type packetDecoder struct {
dailyProblem
}
func NewPacketDecoder() Problem {
return &packetDecoder{
dailyProblem{
day: 16,
},
}
}
func (p *packetDecoder) Solve() interface{} {
input := p.GetInputLines()
var results [... | internal/advent/day16.go | 0.806396 | 0.625981 | day16.go | starcoder |
package bed
import (
"bytes"
"log"
"sort"
"strconv"
"strings"
"github.com/edotau/goFish/simpleio"
"github.com/vertgenlab/gonomics/numbers"
)
// Bed interface is a data structure that implements the following methods:
// Chrom() []byte returns the chromosome name
// ChrStart() int returns starting the position... | bed/bed.go | 0.746231 | 0.413181 | bed.go | starcoder |
package jsonschema
import (
"reflect"
)
const (
tTypeObject = "object"
tTypeString = "string"
tTypeInteger = "integer"
tTypeNumber = "number"
tTypeBoolean = "boolean"
tTypeArray = "array"
)
// Reflect reflects to Schema from a value.
func Reflect(v interface{}) *Schema {
valueOf := reflect.ValueOf(v)
t... | reflect.go | 0.648355 | 0.462959 | reflect.go | starcoder |
// Package fibHeap implements the Fibonacci Heap priority queue.
// This implementation is a bit different from the traditional Fibonacci Heap by having an index map to achieve better encapsulation.
package fibHeap
import (
"bytes"
"container/list"
"errors"
"fmt"
"math"
)
// Value is the interface that all valu... | BirthdayServer/src/BirthdayBot/fibonacci/FibonacciHeap.go | 0.87456 | 0.462655 | FibonacciHeap.go | starcoder |
package num
// Int a wrapper to a signed big int
type Int struct {
// The unsigned version of the integer
U *Uint
// The sign of the integer true = positive, false = negative
s bool
}
// IntFromUint ...
func IntFromUint(u *Uint, s bool) *Int {
copy := &Int{s: s,
U: u.Clone()}
return copy
}
// IsNegative test... | types/num/int.go | 0.758063 | 0.446012 | int.go | starcoder |
package graph
import (
"fmt"
"github.com/cycloidio/inframap/errcode"
)
// Graph defines the standard format of a Graph
type Graph struct {
Edges []*Edge
Nodes []*Node
// nodesCans canonical -> struct{}{}
nodesCans map[string]*Node
// nodesIDs id -> struct{}{}
nodesIDs map[string]*Node
// nodesWithEdge id... | graph/graph.go | 0.572842 | 0.517327 | graph.go | starcoder |
package less
import "sort"
func lessThan(a, b string, less func(a, b string) bool) bool {
return less(a, b)
}
func lessThanOrEqualTo(a, b string, less func(a, b string) bool) bool {
return less(a, b) || !less(b, a)
}
func greaterThan(a, b string, less func(a, b string) bool) bool {
return less(b, a)
}
func greater... | vendor/github.com/tidwall/less/less.go | 0.872143 | 0.688629 | less.go | starcoder |
package marchingsquares
import (
"math/rand"
"time"
"github.com/hajimehoshi/ebiten"
)
func init() {
rand.Seed(time.Now().UTC().UnixNano())
}
// MapGenerator contains map generator state
type MapGenerator struct {
width, height int
squareSize float32
seed string
useRandomSeed bool
randomFillPer... | map_generator.go | 0.716913 | 0.435181 | map_generator.go | starcoder |
package any
import (
"reflect"
"emperror.dev/emperror"
"emperror.dev/errors"
)
// Merge returns the merge of its first and second arguments.
func Merge(fst, snd Value, options ...MergeOption) (Value, error) {
return MergeWithContext(NewMergeContext(options...), fst, snd)
}
// MustMerge returns the merge of its... | pkg/any/merge.go | 0.717903 | 0.454775 | merge.go | starcoder |
package object
import "fmt"
// DamageType classifies damage.
type DamageType byte
// String returns the textual representation of the value.
func (damageType DamageType) String() string {
if int(damageType) >= len(damageTypeNames) {
return fmt.Sprintf("Unknown 0x%02X", int(damageType))
}
return damageTypeNames[... | ss1/content/object/DamageType.go | 0.829008 | 0.474266 | DamageType.go | starcoder |
package prayer
import (
"math"
"time"
"github.com/hablullah/go-juliandays"
)
// Times is the result of calculation.
type Times struct {
Fajr time.Time
Sunrise time.Time
Zuhr time.Time
Asr time.Time
Maghrib time.Time
Isha time.Time
}
// TimeCorrections is correction for each prayer time.
type T... | calculator.go | 0.774583 | 0.51501 | calculator.go | starcoder |
package parser
import (
"github.com/pkg/errors"
"net"
)
func filterPrefix(prefix net.IPNet) error {
// filter submasks with zero size
if size, _ := prefix.Mask.Size(); size == 0 {
return errors.New("prefix size of 0")
}
if !prefix.IP.Mask(prefix.Mask).Equal(prefix.IP) {
return errors.New("prefix contains b... | parser/filter.go | 0.554953 | 0.497864 | filter.go | starcoder |
package internal
import (
"fmt"
"strconv"
)
func ToString(value interface{}) (string, error) {
switch v := value.(type) {
case string:
return v, nil
case []byte:
return string(v), nil
case int:
return strconv.FormatInt(int64(v), 10), nil
case int8:
return strconv.FormatInt(int64(v), 10), nil
case int1... | internal/type_conversions.go | 0.52074 | 0.513059 | type_conversions.go | starcoder |
package policy
import (
"errors"
"github.com/joshdk/callcheck/graph"
)
type Decl struct {
Position string
Name string
Calls []Call
}
type Call struct {
Position string
Name string
Decl Decl
Index int
}
type Goal struct {
startDecl string
endCall string
}
func MatchingPaths(graph ma... | policy/match.go | 0.664867 | 0.40486 | match.go | starcoder |
package ent
import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"github.com/karashiiro/gacha/ent/series"
)
// Series is the model entity for the Series schema.
type Series struct {
config `json:"-"`
// ID of the ent.
ID uint32 `json:"id,omitempty"`
// Name holds the value of the "name" field.
Name string `... | ent/series.go | 0.694406 | 0.403596 | series.go | starcoder |
package memory
import (
"errors"
"fmt"
"github.com/ottotech/riskmanagement/pkg/adding"
"github.com/ottotech/riskmanagement/pkg/listing"
"image/color"
"os"
"path/filepath"
"time"
)
// matrix setup
const (
imWidth = 600
imHeight = imWidth
matrixNrRows = 3
matrixNrCols = 3
matrixSize = matrixNrRo... | pkg/storage/memory/repository.go | 0.638046 | 0.453988 | repository.go | starcoder |
package stats
// StatType is the type of different statistics
type StatType int
// Different statistics for different benchmark tools.
const (
None StatType = iota
OPS
P99
P95
TPS
QPS
)
// String returns the name of statistics
func (s StatType) String() string {
switch s {
case OPS:
return "ops"
case P99:... | pkg/stats/stats.go | 0.695958 | 0.473231 | stats.go | starcoder |
package collision
import (
"github.com/galaco/kero/framework/physics/collision/bullet"
"github.com/galaco/studiomodel"
"github.com/go-gl/mathgl/mgl32"
)
type CollisionBodyType int8
const (
RigidBodyTypeConvexHull = CollisionBodyType(0)
RigidBodyTypeOrientedBoundingBox = CollisionBodyType(1)
Rigi... | framework/physics/collision/rigidBody.go | 0.790085 | 0.507507 | rigidBody.go | starcoder |
package pythonimports
import "fmt"
const (
// None represents the zero value for Kind
None Kind = iota
// Function is the classification for nodes representing functions
Function
// Type is the classification for nodes representing types
Type
// Module is the classification for nodes representing modules
Modu... | kite-go/lang/python/pythonimports/node.go | 0.723993 | 0.516047 | node.go | starcoder |
// Package murmur3 provides functions implementing the Murmur3 hashing algorithm.
// The ClojureJVM version imported the Guava Murmur3 implementation
// and made some changes.
// For ClojureCLR and here, I copied the API stubs, then implemented the API
// based on the algorithm description at
// http://en.wikipedi... | murmur3/murmur3.go | 0.725065 | 0.66182 | murmur3.go | starcoder |
package lexer
import "lookageek.com/ode/token"
// Lexer holds the input string, the current tokenizing position
// and next position, and the current character as a byte
type Lexer struct {
input string
position int
readPosition int
ch byte
}
func New(input string) *Lexer {
l := &Lexer{inpu... | lexer/lexer.go | 0.548674 | 0.4206 | lexer.go | starcoder |
package spider
// DataProvider allows alternate implementations of a backing service that provides configuration data. Ex. Zookeeper, Consul, etcd.
type DataProvider interface {
Get(key string) (*Node, error) // Get an existing key's currently set value.
Set(key string, value []byte) error ... | provider.go | 0.629091 | 0.5816 | provider.go | starcoder |
package funcs
import (
"bytes"
)
type float64Ge struct {
V1 Float64
V2 Float64
}
func (this *float64Ge) Eval() bool {
return this.V1.Eval() >= this.V2.Eval()
}
func init() {
Register("ge", new(float64Ge))
}
type float32Ge struct {
V1 Float32
V2 Float32
}
func (this *float32Ge) Eval() bool {
return this.V... | funcs/compare.gen.go | 0.742608 | 0.541894 | compare.gen.go | starcoder |
package placement
import (
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/pd/server/core"
)
// RegionFit is the result of fitting a region's peers to rule list.
// All peers are divided into corresponding rules according to the matching
// rules, and the remaining Peers are placed in the OrphanPeers l... | server/schedule/placement/fit.go | 0.763219 | 0.425784 | fit.go | starcoder |
package champ
import (
math "github.com/chewxy/math32"
"github.com/r4stl1n/micro-hal/code/pkg/champ/cbase"
"github.com/r4stl1n/micro-hal/code/pkg/champ/cstructs"
"time"
)
type LegController struct {
quadBase *cbase.QuadBase
trajectoryPlanners [4]*TrajectoryPlanner
phaseGenerator *PhaseGenerator
leftFrontTr... | code/pkg/champ/leg-controller.go | 0.729038 | 0.447581 | leg-controller.go | starcoder |
package main
import (
"container/list"
"fmt"
"github.com/arbovm/levenshtein"
)
// DistanceFunc a distance function which calculates the distance between two
// strings. This distance function must satisfy a set of axioms in order to
// ensure it's well-behaved. See https://en.wikipedia.org/wiki/Metric_space.
type... | bktree.go | 0.753829 | 0.470433 | bktree.go | starcoder |
package lshensemble
import (
"math"
)
// Computes the expected number of false positives caused by using the
// upper bound set size of the set size interval given by indexes l and u.
func computeNFP(l, u int, sizes, counts []int) float64 {
if l > u {
panic("l must be less or equal to u")
}
var sum float64
for... | optimal_partition.go | 0.755727 | 0.630927 | optimal_partition.go | starcoder |
package ontograph
import (
"errors"
"fmt"
"strconv"
"time"
)
// GenericLiteral represents a generic literal term (i.e. containing a value and a corresponding datatype).
// Generic literals can be parsed into specific literals using the corresponding methods.
type GenericLiteral struct {
value T... | ontology_literal.go | 0.819244 | 0.609757 | ontology_literal.go | starcoder |
package ring
import (
"encoding/binary"
"errors"
"math/bits"
)
// Poly is the structure that contains the coefficients of a polynomial.
type Poly struct {
Coeffs [][]uint64 // Coefficients in CRT representation
}
// NewPoly creates a new polynomial with N coefficients set to zero and nbModuli moduli.
func NewPol... | ring/ring_poly.go | 0.781997 | 0.539711 | ring_poly.go | starcoder |
package main
import (
"crypto/sha256"
"encoding/binary"
"fmt"
)
var pc [256]byte
// Length of the returned sha byte slice.
const (
SHA256 = 32
)
func init() {
for i := range pc {
pc[i] = pc[i/2] + byte(i&1)
}
}
func bitCount(x uint64) int {
x = x - ((x >> 1) & 0x5555555555555555)
x = (x & 0x3333333333333... | ex_04.01-counting_sha256/counting_sha.go | 0.604632 | 0.429609 | counting_sha.go | starcoder |
package nmea
import "time"
// MagneticCourseOverGround retrieves the magnetic course over ground from the sentence
type MagneticCourseOverGround interface {
GetmagneticCourseOverGround() (float64, error)
}
// MagneticHeading retrieves the magnetic heading from the sentence
type MagneticHeading interface {
GetMagne... | signalk.go | 0.765111 | 0.591753 | signalk.go | starcoder |
package kalman_filter
import (
"github.com/pkg/errors"
"gonum.org/v1/gonum/mat"
)
// KalmanFilterLinear Implementation of linear Kalman filter
// A - Transition State Matrix
// B - Control input
// C - Measure Matrix C
// P - State covariance
// Q - Process covariance
// R - Measurement covariance
// X - State (ini... | linear_kalman_filter.go | 0.661048 | 0.483344 | linear_kalman_filter.go | starcoder |
package gollection
func LinkedStackOf[T any](elements ...T) LinkedStack[T] {
var inner = &linkedStack[T]{0, nil}
var stack = LinkedStack[T]{inner}
for _, v := range elements {
stack.Push(v)
}
return stack
}
func LinkedStackFrom[T any](collection Collection[T]) LinkedStack[T] {
var stack = LinkedStackOf[T]()
... | linked_stack.go | 0.726037 | 0.483466 | linked_stack.go | starcoder |
package number_of_ships_in_a_rectangle
/*
1274. 矩形内船只的数目
https://leetcode-cn.com/problems/number-of-ships-in-a-rectangle
(此题是 交互式问题 )
在用笛卡尔坐标系表示的二维海平面上,有一些船。每一艘船都在一个整数点上,且每一个整数点最多只有 1 艘船。
有一个函数 Sea.hasShips(topRight, bottomLeft) ,输入参数为右上角和左下角两个点的坐标,
当且仅当这两个点所表示的矩形区域(包含边界)内至少有一艘船时,这个函数才返回 true ,否则返回 false 。
给你矩形的右上... | solutions/number-of-ships-in-a-rectangle/d.go | 0.572723 | 0.511046 | d.go | starcoder |
package game
import (
"github.com/mokiat/lacking-js/internal"
"github.com/mokiat/lacking/game/graphics"
)
func newAmbientLightShaderSet() graphics.ShaderSet {
vsBuilder := internal.NewShaderSourceBuilder(ambientLightVertexShader)
fsBuilder := internal.NewShaderSourceBuilder(ambientLightFragmentShader)
return gra... | game/shader_amb_light.go | 0.638497 | 0.493287 | shader_amb_light.go | starcoder |
package validator
import "fmt"
// DigitsBetweenInt64 returns true if value lies between left and right border
func DigitsBetweenInt64(value, left, right int64) bool {
if left > right {
left, right = right, left
}
return value >= left && value <= right
}
// compareInt64 determine if a comparison passes between ... | validator_int.go | 0.759315 | 0.554772 | validator_int.go | starcoder |
package types
import (
"fmt"
"time"
)
const (
TERM_BEG_FINISHED int16 = 32
TERM_END_FINISHED int16 = 0
WEEKMON_SUNDAY int16 = 7
TIME_MULTIPLY_SIXTY int16 = 60
WEEKDAYS_COUNT int16 = 7
)
// Max returns the largest of x or y.
func max(x, y int16) int16 {
if x < y {
return y
}
return x
}
// Min returns the... | internal/types/operations_period.go | 0.665519 | 0.431524 | operations_period.go | starcoder |
package avail
import (
"fmt"
"regexp"
"strings"
"time"
)
// fieldType is an enum which represents different parts of a total cron expression.
// For example in the expression "0 10 15 * * *", 0 would be of type "minute".
type fieldType string
const (
minute fieldType = "minute"
hour fieldType = "hour"
day... | avail.go | 0.593374 | 0.44083 | avail.go | starcoder |
package elm
import (
"fmt"
"protoc-gen-elm/pkg/stringextras"
"text/template"
"google.golang.org/protobuf/types/descriptorpb"
)
// WellKnownType - information to handle Google well known types
type WellKnownType struct {
Type Type
Encoder VariableName
Decoder VariableName
}
var (
// WellKnownTypeMap - map... | protoc-gen-elm/pkg/elm/type_alias.go | 0.562177 | 0.483344 | type_alias.go | starcoder |
package util
import (
"time"
)
// Days is the duration of a day.
const Days = time.Hour * 24
// GetLowerBound returns the earlier of two times. A nil time is considered infinitely late so won't be
// used if the other time is not nil.
func GetLowerBound(t1 *time.Time, t2 *time.Time) time.Time {
return getBound(t1,... | util/time_util.go | 0.809615 | 0.460289 | time_util.go | starcoder |
package valuerange
import (
"github.com/iotaledger/hive.go/marshalutil"
"github.com/iotaledger/hive.go/stringify"
"golang.org/x/xerrors"
)
// EndPoint contains information about where ValueRanges start and end. It combines a threshold value with a BoundType.
type EndPoint struct {
value Value
boundType Bound... | datastructure/valuerange/endpoint.go | 0.700588 | 0.493164 | endpoint.go | starcoder |
package graphs
import "sort"
type ccGraph struct {
graph Graph // Input graph
ccIndex []int // ccIndex[v] returns the component ID of a vertex v
ccSize []int // ccSize[i] shows the size of i-th component
marked []bool // internal data structure used for DFS
count int // number of connected compo... | connected_components.go | 0.705278 | 0.523238 | connected_components.go | starcoder |
package assert
import (
"fmt"
"reflect"
"runtime"
"testing"
"unicode/utf8"
)
var callStackAdjust = 0
func CallStackAdjust(l int) {
callStackAdjust = l
}
func CallStackReset() {
callStackAdjust = 0
}
// Equal tries to establish if the two values are compareEquality via reflection and if that fails then via c... | assert.go | 0.655777 | 0.526038 | assert.go | starcoder |
package metrics
import (
"net/http"
"sort"
)
// Namespaced wraps a child metrics exporter and exposes a Type API that
// adds namespacing labels and name prefixes to new
type Namespaced struct {
labels map[string]string
mappings []*Mapping
child Type
}
// NewNamespaced wraps a metrics exporter and adds pre... | internal/component/metrics/namespaced.go | 0.814754 | 0.500916 | namespaced.go | starcoder |
package parser
import (
"fmt"
"errors"
"strings"
"github.com/xrash/gonf/tokens"
)
type state func(p *Parser) error
func err(got tokens.Token, expected ...string) error {
msg := "Expected %s at line %d:%d. Got %s."
for k, e := range(expected) {
expected[k] = "'" + e + "'"
}
return errors.New(fmt.Sprintf(m... | parser/states.go | 0.650467 | 0.483526 | states.go | starcoder |
package semantic
// rInt is an instance of the int primitive type, necessary where a *PrimitiveType is required.
var rInt = PrimitiveTypeInt
// rByte is an instance of the byte primitive type, necessary where a *PrimitiveType is required.
var rByte = PrimitiveTypeByte
// stdlib is the collection of standard library ... | semantic/stdlib.go | 0.529993 | 0.597549 | stdlib.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
smath "github.com/jtejido/stats/math"
"math"
"math/rand"
)
// Q-Weibull distribution
// https://en.wikipedia.org/wiki/Q-exponential_distribution
type QWeibull struct {
rate, shape, q float64... | dist/continuous/q_weibull.go | 0.748536 | 0.486941 | q_weibull.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// ExpressionInputObject
type ExpressionInputObject struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can ... | models/expression_input_object.go | 0.680348 | 0.420064 | expression_input_object.go | starcoder |
package fastly
import (
"fmt"
"sort"
)
// Snippet is the Fastly Snippet object
type Snippet struct {
// Priority determines the ordering for multiple snippets. Lower numbers execute first.
Priority int `mapstructure:"priority"`
// Dynamic sets the snippet version to regular (0) or dynamic (1).
Dynamic int `map... | fastly/vcl_snippets.go | 0.728748 | 0.439567 | vcl_snippets.go | starcoder |
package eventstore
import (
"context"
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/get-eventually/go-eventually"
"github.com/get-eventually/go-eventually/eventstore/stream"
"github.com/get-eventually/go-eventually/internal"
)
var (
firstInstance = stream.ID{
T... | eventstore/store_suite.go | 0.689096 | 0.451689 | store_suite.go | starcoder |
package numgo
import (
"fmt"
"math"
"runtime"
"sync"
"github.com/Kunde21/numgo/internal"
)
var nan float64
func init() {
nan = math.NaN()
}
// Add performs element-wise addition
// Arrays must be the same size or able to broadcast.
// This will modify the source array.
func (a *Array64) Add(b *Array64) *Arra... | arithmetic.go | 0.723798 | 0.453383 | arithmetic.go | starcoder |
package ckks
import (
"github.com/ldsec/lattigo/ring"
"math"
"math/big"
)
// Encoder is an interface implenting the encoding algorithms.
type Encoder interface {
Encode(plaintext *Plaintext, values []complex128, slots uint64)
EncodeNew(values []complex128, slots uint64) (plaintext *Plaintext)
Decode(plaintext *... | ckks/encoder.go | 0.711932 | 0.459258 | encoder.go | starcoder |
package pipelines
import (
"encoding/json"
"time"
)
// PipelineStage A pipeline stage definition.
type PipelineStage struct {
// The date the pipeline stage was created. The stages on default pipelines will have createdAt = 0.
CreatedAt time.Time `json:"createdAt"`
// The date the pipeline was archived. `archiv... | generated/pipelines/model_pipeline_stage.go | 0.867289 | 0.535645 | model_pipeline_stage.go | starcoder |
package client
import (
"encoding/json"
)
// MonthlyScheduleSettings struct for MonthlyScheduleSettings
type MonthlyScheduleSettings struct {
TimeLocal Time `json:"timeLocal"`
DayNumberInMonth DayNumbersInMonth `json:"dayNumberInMonth"`
DayOfWeek *DaysOfWeek... | client/model_monthly_schedule_settings.go | 0.787482 | 0.470676 | model_monthly_schedule_settings.go | starcoder |
package alt
// #include "Module.h"
import "C"
import "math"
const (
DefaultDimension int32 = 0
MaxDimension int32 = math.MaxInt32
MinDimension int32 = math.MinInt32
)
type WorldObject struct {
BaseObject
}
type World interface {
Position() *Vector3
SetPosition()
Dimension() int32
SetDimension()
}
f... | alt/world_object.go | 0.517571 | 0.560373 | world_object.go | starcoder |
Package airac provides calculations on Aeronautical Information Regulation And
Control (AIRAC) cycles, i.e. cycle identifiers and effective calendar dates.
Regular, planned Aeronautical Information Publications (AIP) as defined by the
International Civil Aviation Organization (ICAO) are published and become
effective ... | doc.go | 0.711431 | 0.724974 | doc.go | starcoder |
package qif
import "github.com/pkg/errors"
// A BankingTransaction contains the information associated with non-investment
// transactions (i.e. Cash, Bank and CCard account types).
type BankingTransaction interface {
Transaction
// Num contains the check or reference number for the transaction. Wikipedia
// sug... | banking_transaction.go | 0.621081 | 0.47317 | banking_transaction.go | starcoder |
package exec
// sortedDistinctInt64Op runs a distinct on the column in sortedDistinctCol,
// writing true to the resultant bool column for every value that differs from
// the previous one.
type sortedDistinctInt64Op struct {
input Operator
// sortedDistinctCol is the index of the column to distinct upon.
sortedD... | pkg/sql/exec/distinct.go | 0.76366 | 0.571468 | distinct.go | starcoder |
package f5api
// This describes a message sent to or received from some operations
type LtmMonitorFirepass struct {
// The application service to which the object belongs.
AppService string `json:"appService,omitempty"`
// Specifies the username, if the monitored target requires authentication.
Username string `... | ltm_monitor_firepass.go | 0.86806 | 0.504455 | ltm_monitor_firepass.go | starcoder |
package interpreter
import (
"errors"
)
var (
zeroi = IntegerLiteral{0}
zerof = FloatLiteral{0.0}
emptys = StringLiteral{""}
falseb = BooleanLiteral{false}
)
/**
* Shorthand functions to easily create instances of supported types.
*/
func NewString(str string) Value {
emptyl := List{[]Value{}}
emptym := ... | src/interpreter/helpers.go | 0.671901 | 0.436502 | helpers.go | starcoder |
package trie
import (
"encoding/hex"
"sort"
"sync"
"github.com/qlcchain/go-qlc/common/types"
"github.com/qlcchain/go-qlc/common/util"
)
const (
UnknownNode = byte(iota)
FullNode
ShortNode
ValueNode
HashNode
)
type TrieNode struct {
hash *types.Hash
nodeType byte
// fullNode
children map[byte]*Tri... | trie/node.go | 0.555194 | 0.425307 | node.go | starcoder |
package core
import (
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/stat"
"math"
)
/* Table */
// DataTable is an array of (userId, itemId, rating).
type DataTable struct {
Ratings []float64
Users []int
Items []int
}
// NewDataTable creates a new raw Data set.
func NewDataTable(users, items []int, ratin... | core/table.go | 0.721253 | 0.411288 | table.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// UserExperienceAnalyticsBatteryHealthDevicePerformance
type UserExperienceAnalyticsBatteryHealthDevicePerformance struct {
Entity
// Estimated battery a... | models/user_experience_analytics_battery_health_device_performance.go | 0.718002 | 0.444203 | user_experience_analytics_battery_health_device_performance.go | starcoder |
package integer
import "sort"
type Int32Slice []int32
func (x Int32Slice) Len() int { return len(x) }
func (x Int32Slice) Less(i, j int) bool { return x[i] < x[j] }
func (x Int32Slice) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
type Int64Slice []int64
func (x Int64Slice) Len() int { return... | helper/basic/integer/equal.go | 0.517815 | 0.437884 | equal.go | starcoder |
package packet
import (
"bytes"
"encoding/binary"
"fmt"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
// TFTPOpCode defines the TFTP packet operation.
type TFTPOpCode uint16
const (
_ TFTPOpCode = iota
// TFTPOpRead performs a read operation.
TFTPOpRead
// TFTPOpWrite performs a write... | tftp.go | 0.677581 | 0.417331 | tftp.go | starcoder |
package toml
import (
"fmt"
"reflect"
"strings"
"time"
)
var typeOfStringSlice = reflect.TypeOf([]string(nil))
var typeOfIntSlice = reflect.TypeOf([]int(nil))
func isPointer(v interface{}) bool {
vkind := reflect.ValueOf(v).Type().Kind()
return vkind == reflect.Ptr
}
// Same as PrimitiveDecode but adds a stri... | vendor/github.com/bbangert/toml/decode_strict.go | 0.667906 | 0.436022 | decode_strict.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.