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 tflite
import (
"strconv"
flatbuffers "github.com/google/flatbuffers/go"
)
type SparseIndexVector byte
const (
SparseIndexVectorNONE SparseIndexVector = 0
SparseIndexVectorInt32Vector SparseIndexVector = 1
SparseIndexVectorUint16Vector SparseIndexVector = 2
SparseIndexVectorUint8Vector Spar... | SparseIndexVector.go | 0.573201 | 0.646739 | SparseIndexVector.go | starcoder |
package tensor
import (
"github.com/lordlarker/nune/internal/cpd"
"github.com/lordlarker/nune/internal/slice"
)
// Add takes a Tensor and performs element-wise addition,
// by reference, over the two Tensor's elements, and then
// returns the resulting Tensor.
func (t *Tensor[T]) Add(other *Tensor[T]) *Tensor[T] {... | tensor/ops.go | 0.857022 | 0.673214 | ops.go | starcoder |
package compiler
// This file contains utility functions to pack and unpack sets of values. It
// can take in a list of values and tries to store it efficiently in the pointer
// itself if possible and legal.
import (
"tinygo.org/x/go-llvm"
)
// emitPointerPack packs the list of values into a single pointer value u... | compiler/wordpack.go | 0.589126 | 0.637976 | wordpack.go | starcoder |
package transformers
import (
"math"
"sort"
)
// Identity is a transformer that returns unmodified input value
type Identity struct{}
// Fit is not used, it is here only to keep same interface as rest of transformers
func (t *Identity) Fit(_ []float64) {}
// Transform returns same value as input
func (t *Identity... | transformers/scalers.go | 0.842442 | 0.523664 | scalers.go | starcoder |
package storage
// Provider represents a storage provider.
type Provider interface {
// CreateStore creates a new store with the given name.
CreateStore(name string) error
// OpenStore opens an existing store and returns it.
OpenStore(name string) (Store, error)
// CloseStore closes the store with the given nam... | pkg/storage/store.go | 0.529507 | 0.431464 | store.go | starcoder |
package virustotal
import (
"context"
virustotal "github.com/VirusTotal/vt-go"
"github.com/turbot/steampipe-plugin-sdk/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/plugin"
"github.com/turbot/steampipe-plugin-sdk/plugin/transform"
)
func tableVirusTotalURL(ctx context.Context) *plugin.Table {
return &pl... | virustotal/table_virustotal_url.go | 0.651687 | 0.450722 | table_virustotal_url.go | starcoder |
package spec3
// Callback A map of possible out-of band callbacks related to the parent operation.
// Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses.
// The key value used to identify the callback object is an expression... | callback.go | 0.584153 | 0.515925 | callback.go | starcoder |
package display
import (
"fmt"
"github.com/inkyblackness/shocked-client/graphics"
"github.com/inkyblackness/shocked-client/opengl"
)
var gridVertexShaderSource = `
#version 150
precision mediump float;
in vec3 vertexPosition;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;
out vec4 gridColor;
out vec3 ... | src/github.com/inkyblackness/shocked-client/editor/display/GridRenderable.go | 0.753013 | 0.482063 | GridRenderable.go | starcoder |
package timsort
import ()
// IntLessThan is a Delegate type that sorting uses as a comparator
type IntLessThan func(a, b int) bool
type timSortHandlerI struct {
/**
* The array being sorted.
*/
a []int
/**
* The comparator for this sort.
*/
lt IntLessThan
/**
* This controls when we get *into* gall... | v2/timsortint.go | 0.742328 | 0.463444 | timsortint.go | starcoder |
package p464
/**
In the "100 game," two players take turns adding, to a running total, any integer from 1..10.
The player who first causes the running total to reach or exceed 100 wins.
What if we change the game so that players cannot re-use integers?
For example, two players might take turns drawing from a common ... | algorithms/p464/464.go | 0.7413 | 0.622488 | 464.go | starcoder |
package vm
import (
"fmt"
"math/big"
"gonum.org/v1/gonum/mat"
)
func MatMathOp(vm *VM, e1 *Elem, e2 *Elem, op int) (*Elem, error) {
if e1.Type == "MAT" && e2.Type == "MAT" {
vm.Debug("MAT operation %v requested", op)
switch v1 := e1.Value.(type) {
case *mat.Dense:
switch v2 := e2.Value.(type) {
case ... | internal/vm/matmath.go | 0.529507 | 0.401658 | matmath.go | starcoder |
package codegen
import (
"github.com/dave/jennifer/jen"
"sort"
"unicode"
)
// Typedef defines a non-struct-based type, its functions, and its methods for
// Go code generation.
type Typedef struct {
comment string
name string
concreteType jen.Code
methods map[string]*Method
constructors map[... | astool/codegen/typedef.go | 0.500977 | 0.400925 | typedef.go | starcoder |
package exhibit
import "testing"
func (e E) A(evidence Evidence, t *testing.T) {
e.present(evidence, "a", t)
}
func (e E) B(evidence Evidence, t *testing.T) {
e.present(evidence, "b", t)
}
func (e E) C(evidence Evidence, t *testing.T) {
e.present(evidence, "c", t)
}
func (e E) D(evidence Evidence, t *testing.T)... | alphabet.go | 0.713432 | 0.618665 | alphabet.go | starcoder |
package ach
import (
"fmt"
"strconv"
"strings"
"unicode/utf8"
)
// ADVEntryDetail contains the actual transaction data for an individual entry.
// Fields include those designating the entry as a deposit (credit) or
// withdrawal (debit), the transit routing number for the entry recipient’s financial
// instituti... | advEntryDetail.go | 0.722135 | 0.407569 | advEntryDetail.go | starcoder |
package glicko
import (
"math"
)
type RatingPeriod struct {
tau float64
players []*Player
}
func NewRatingPeriod() *RatingPeriod {
tau := 0.5
return &RatingPeriod{
tau: tau,
players: []*Player{},
}
}
func (period *RatingPeriod) AddPlayer(player *Player) {
// @todo... | vendor/github.com/zelenin/go-glicko2/period.go | 0.792585 | 0.550728 | period.go | starcoder |
package builders
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/juliosueiras/terraform-provider-packer/packer/communicators"
)
func VMWareVMXResource() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString... | packer/builders/vmwarevmx.go | 0.632162 | 0.426979 | vmwarevmx.go | starcoder |
package chart
import (
"errors"
"fmt"
"io"
"math"
"github.com/golang/freetype/truetype"
util "github.com/t-mw/go-chart/util"
)
// Chart is what we're drawing.
type Chart struct {
Title string
TitleStyle Style
ColorPalette ColorPalette
Width int
Height int
DPI float64
Background Style
Canvas... | chart.go | 0.649579 | 0.501831 | chart.go | starcoder |
package macie
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/go/pulumi"
)
type S3BucketAssociationClassificationType struct {
// A string value indicating that Macie perform a one-time classification of all of the existing objects in the bucket.
// The only valid value is the default value, `FULL`.... | sdk/go/aws/macie/pulumiTypes.go | 0.80837 | 0.404566 | pulumiTypes.go | starcoder |
package main
var redisCommandsJSON = `
{
"APPEND": {
"summary": "Append a value to a key",
"complexity": "O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space av... | commands.go | 0.625896 | 0.486636 | commands.go | starcoder |
package typeio
import (
"encoding/binary"
"io"
"math"
)
// ReadFloat32BE reads 4 bytes in big-endian byte order from r and returns them
// as an float32 as defined in IEEE 754.
func ReadFloat32BE(r io.Reader) (float32, error) {
b, err := readN(r, 4)
if err != nil {
return 0, err
}
return math.Float32frombit... | float.go | 0.817756 | 0.442456 | float.go | starcoder |
package token
import (
"fmt"
"math/big"
"strconv"
"github.com/pkg/errors"
)
// Quantity models an immutable token quantity and its basic operations.
type Quantity interface {
// Add returns this + b without modify this.
// If an overflow occurs, it returns an error.
Add(b Quantity) Quantity
// Add returns ... | token/token/quantity.go | 0.851706 | 0.428293 | quantity.go | starcoder |
package iso20022
// Provides information about the rates related to securities movement.
type RateDetails24 struct {
// Rate used for additional tax that cannot be categorised.
AdditionalTax *RateAndAmountFormat43Choice `xml:"AddtlTax,omitempty"`
// Rate used to calculate the amount of the charges/fees that canno... | RateDetails24.go | 0.840619 | 0.562777 | RateDetails24.go | starcoder |
package vm
import (
"fmt"
"math"
"reflect"
)
// Object interface encapsulates all values in rune.
type Object interface {
Type() Type
String() string
// Value is used for passing values to external functions.
Value() reflect.Value
Equal(other Object) bool
}
// ObjectFromValue creates new instance of Object ... | vm/object.go | 0.705785 | 0.434041 | object.go | starcoder |
package da
import "github.com/MaxSlyugrov/cldr"
var currencies = []cldr.Currency{
{Currency: "ADP", DisplayName: "Andorransk peseta", Symbol: ""},
{Currency: "AED", DisplayName: "Dirham fra de Forenede Arabiske Emirater", Symbol: "AED"},
{Currency: "AFA", DisplayName: "Afghansk afghani (1927–2002)", Symbol: ""},
... | resources/locales/da/currency.go | 0.506591 | 0.441131 | currency.go | starcoder |
package fapi
import "fmt"
// OutOfBoundsInt is an error returned when attempting to set an Int or List to
// a value which is out of the parameter's defined limits.
type OutOfBoundsInt struct {
// Param is the parameter which the caller attempted to set.
Param Param
// Value is the value which the caller attempted... | fapi/error.go | 0.786131 | 0.452294 | error.go | starcoder |
package analyzer
import (
"fmt"
"github.com/sirupsen/logrus"
"git.abyle.org/hps/alolstats/logging"
"git.abyle.org/hps/alolstats/riotclient"
"git.abyle.org/hps/alolstats/storage"
"git.abyle.org/hps/alolstats/utils"
)
// SingleRunesReforgedCombiStatistics contains all the statistics for one given item combinati... | statsrunner/analyzer/runesreforgedanalyzer.go | 0.555194 | 0.503052 | runesreforgedanalyzer.go | starcoder |
package gokalman
import (
"fmt"
"github.com/gonum/matrix/mat64"
)
// BatchGroundTruth computes the error of a given estimate from a known batch of states and measurements.
type BatchGroundTruth struct {
states []*mat64.Vector
measurements []*mat64.Vector
}
// Error returns an ErrorEstimate after comparing... | truth.go | 0.78316 | 0.647875 | truth.go | starcoder |
package util
// ManagedClusterActionCreateTemplate is json template for create action
const ManagedClusterActionCreateTemplate = `{
"apiVersion": "action.open-cluster-management.io/v1beta1",
"kind": "ManagedClusterAction",
"metadata": {
"labels": {
"test-automation": "true"
},
"generateName": "test-a... | test/e2e/util/template.go | 0.510985 | 0.413536 | template.go | starcoder |
package models
import (
"github.com/AntoineAugusti/moduluschecking/helpers"
)
// Represents a UK bank account
type BankAccount struct {
SortCode string
AccountNumber string
}
// The sort code has an integers slice
func (b BankAccount) SortCodeSlice() []int {
return helpers.StringToIntSlice(b.SortCode)
}
//... | models/bankAccount.go | 0.630912 | 0.553204 | bankAccount.go | starcoder |
package hash
// This file contains the implementation of the subsetting algorithm for
// choosing a subset of input values in a consistent manner.
import (
"bytes"
"hash"
"hash/fnv"
"sort"
"strconv"
"k8s.io/apimachinery/pkg/util/sets"
)
const (
startSalt = "start-angle-salt"
stepSalt = "step-angle-salt"
... | vendor/knative.dev/pkg/hash/hash.go | 0.755366 | 0.47384 | hash.go | starcoder |
package mount
// On Solaris we can't invoke the mount system call directly. First,
// the mount system call takes more than 6 arguments, and go doesn't
// support invoking system calls that take more than 6 arguments. Past
// that, the mount system call is a private interfaces. For example,
// the arguments and dat... | vendor/github.com/containerd/containerd/mount/mount_solaris.go | 0.522446 | 0.404449 | mount_solaris.go | starcoder |
package bitmap
import (
"image"
"image/color"
)
// Reader is a view into a bitmap.
type Reader interface {
At(x, y int) bool
Bounds() image.Rectangle
}
// Writer is a writable view into a bitmap.
type Writer interface {
Set(x, y int, b bool)
Bounds() image.Rectangle
}
// ReaderWriter is a readable/writable vi... | internal/bitmap/image.go | 0.823648 | 0.505737 | image.go | starcoder |
package value
import "strconv"
// Bool holds a single boolean value.
type Bool struct {
valPtr *bool
}
// NewBool makes a new Bool with the given boolean value.
func NewBool(val bool) *Bool {
valPtr := new(bool)
*valPtr = val
return &Bool{valPtr: valPtr}
}
// NewBoolFromPtr makes a new Bool with the given poin... | value/bool.go | 0.826397 | 0.559471 | bool.go | starcoder |
package draw2d
type DashVertexConverter struct {
command VertexCommand
next VertexConverter
x, y, distance float64
dash []float64
currentDash int
dashOffset float64
}
func NewDashConverter(dash []float64, dashOffset float64, converter VertexConverter) *DashVertexConverter {
v... | draw2d/dasher.go | 0.550124 | 0.406567 | dasher.go | starcoder |
package parser
import (
"fmt"
"github.com/puppetlabs/wash/cmd/util"
"github.com/puppetlabs/wash/cmd/internal/find/parser/expression"
"github.com/puppetlabs/wash/cmd/internal/find/primary"
"github.com/puppetlabs/wash/cmd/internal/find/types"
)
/*
See the comments of expression.Parser#Parse for the grammar. Subst... | cmd/internal/find/parser/parseExpression.go | 0.668015 | 0.435721 | parseExpression.go | starcoder |
package criteria
import (
"github.com/viant/assertly"
"github.com/viant/toolbox"
"github.com/viant/toolbox/data"
)
//Criterion represent evaluation criterion
type Criterion struct {
*Predicate
LeftOperand interface{}
Operator string
RightOperand interface{}
}
func (c *Criterion) expandOperand(opperand in... | criteria/criterion.go | 0.696681 | 0.446012 | criterion.go | starcoder |
package xmath
import (
"fmt"
"math"
"math/rand"
"strconv"
"strings"
"time"
)
// Vop is generic operation that returns a vector out of a number.
type Vop func(x float64) Vector
// VecOp is a generic operation on a vector that returns another vector.
type VecOp func(x Vector) Vector
// Unary is a unary vector o... | xmath/vector.go | 0.848188 | 0.646558 | vector.go | starcoder |
package isogrids
import (
"image/color"
"io"
svg "github.com/ajstarks/svgo"
"github.com/taironas/tinygraphs/colors"
"github.com/taironas/tinygraphs/draw"
)
// RandomGradientColor builds a isogrid image with with x colors selected at random for each quadrant.
// the background color stays the same the other colo... | draw/isogrids/gradient.go | 0.640299 | 0.464902 | gradient.go | starcoder |
package sp2p
import (
"fmt"
"math/rand"
"net"
"time"
"strings"
)
func errs(err ... string) string {
return strings.Join(err, "\n")
}
var f = fmt.Sprintf
// DistCmp compares the distances a->target and b->target.
// Returns -1 if a is closer to target, 1 if b is closer to target
// and 0 if they are equal.
fun... | utils.go | 0.552781 | 0.528716 | utils.go | starcoder |
package ingredient
type EffectMeasure struct {
value string
}
func (em EffectMeasure) String() string {
return em.value
}
type EffectType struct {
value int
}
type Effect struct {
name string
positive bool
eType EffectType
baseCost float64
measure EffectMeasure
}
func (e Effect) Name() string {
re... | pkg/alchemy/ingredient/effect.go | 0.697815 | 0.508178 | effect.go | starcoder |
package main
import (
"math"
"image"
"image/color"
)
// round rounds float number to it's nearest integer part.
func round(x float64) float64 {
t := math.Trunc(x)
if math.Abs(x-t) >= 0.5 {
return t + math.Copysign(1, x)
}
return t
}
// clamp255 converts a float64 number to uint8.
func clamp255(x float64) ui... | utils.go | 0.7641 | 0.414366 | utils.go | starcoder |
package ints
import "math/bits"
// SortUint64s sorts the given uint64 slice in O(n) time.
func SortUint64s(nums []uint64) {
const bits = 8
const size = uint64(1) << bits
tmps := make([]uint64, len(nums))
max := Uint64sMax(nums...)
for bit := 0; bit < 64 && max>>bit > 0; bit += bits {
buckets := [size]uint{}
... | pkg/ints/radixsort.go | 0.602997 | 0.412234 | radixsort.go | starcoder |
package wasmtypes
// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\
const ScColorLength = 32
type ScColor struct {
id [ScColorLength]byte
}
var (
IOTA = ScColor{}
MINT = ScColor{}
)
func init() {
for i := range MINT.id {
MINT.id[i] = 0xff
}
}
func (o ScColor) Bytes() []byte {
... | packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/sccolor.go | 0.626353 | 0.467149 | sccolor.go | starcoder |
package eventsourcing
import "fmt"
// ConcurrencyFault represents an error that occurred when updating an aggregate:
// specifically that we have tried to insert events at an index that is already
// defined. This means the client likely needs to re-run the command to break
// the deadlock, as someone else executed f... | fault.go | 0.834811 | 0.41739 | fault.go | starcoder |
package voronoi
import (
"fmt"
"log"
"math"
)
// GetParabolaABC returns the a, b and c coefficients of the standard form of
// a parabola equation, given only x and y of the focus and y of the directrix.
// Math behind this is explained at https://math.stackexchange.com/q/2700061/543428.
func GetParabolaABC(focus ... | parabola.go | 0.854551 | 0.721007 | parabola.go | starcoder |
package convey
import "github.com/smartystreets/assertions"
var (
ShouldEqual = assertions.ShouldEqual
ShouldNotEqual = assertions.ShouldNotEqual
ShouldAlmostEqual = assertions.ShouldAlmostEqual
ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual
ShouldResemble = assertions.Sh... | vendor/github.com/smartystreets/goconvey/convey/assertions.go | 0.63023 | 0.633212 | assertions.go | starcoder |
package draw2dAnimation
import (
"math"
)
// An abstract figure type. Represents a composition of figures kept as collection. Updates to this figure affect it as hole including each part.
type ComposedFigure struct {
*Figure
figures *figuresCollection
}
// Constructor setting current struct's fields and default v... | draw2dAnimation/composedFigure.go | 0.917178 | 0.598283 | composedFigure.go | starcoder |
package iforest
import (
"encoding/json"
"errors"
"fmt"
"math"
"math/rand"
"os"
"sort"
"sync"
)
// Euler is an Euler's constant as described in algorithm specification
const Euler float64 = 0.5772156649
type kv struct {
Key int
Value float64
}
func computeC(n float64) float64 {
return 2*(math.Log(n-1)+... | iforest/iforest.go | 0.715821 | 0.508666 | iforest.go | starcoder |
package httpspec
import (
"io"
"net/http"
"github.com/adamluzsi/testcase"
)
func ItBehavesLikeRoundTripperMiddleware(s *testcase.Spec, subject func(t *testcase.T, next http.RoundTripper) http.RoundTripper) {
testcase.RunContract(s, RoundTripperMiddlewareContract{Subject: subject})
}
type RoundTripperMiddlewareC... | httpspec/contracts.go | 0.62223 | 0.467332 | contracts.go | starcoder |
package runtime
import (
"fmt"
"math"
)
// OpAdd implements the '+' function. It tries to determine automatically the
// type based on the first argument.
func OpAdd(values ...interface{}) interface{} {
if len(values) < 1 {
panic("Function '+' should take at least one argument")
}
var (
totalInt int64
to... | runtime/operators.go | 0.702224 | 0.503845 | operators.go | starcoder |
package lm
import "math"
type (
Vec2 [2]float64
Vec3 [3]float64
Vec4 [4]float64
)
func (v Vec2) Add(b Vec2) (r Vec2) {
for i := 0; i < 2; i++ {
r[i] = v[i] + b[i]
}
return r
}
func (v Vec3) Add(b Vec3) (r Vec3) {
for i := 0; i < 3; i++ {
r[i] = v[i] + b[i]
}
return r
}
func (v Vec4) Add(b Vec4) (r Vec... | vec.go | 0.668556 | 0.528716 | vec.go | starcoder |
package challenge
type Slot uint64
type Epoch uint64
type Shard uint64
type Gwei uint64
type Timestamp uint64
type ValidatorIndex uint64
type DepositIndex uint64
type BLSDomain uint64
// byte arrays
type Root [32]byte
type Bytes32 [32]byte
type BLSPubkey [48]byte
type BLSSignature [96]byte
type ValueFunction func(in... | challenge/data_types.go | 0.667581 | 0.547646 | data_types.go | starcoder |
package go_tsuro
import (
"errors"
"math"
"math/rand"
)
type token struct {
Row int
Col int
Notch string
}
func newToken(row, col int, notch string) *token {
return &token{
Row: row,
Col: col,
Notch: notch,
}
}
func randomToken(random *rand.Rand) *token {
options := "ABCDEFGH"
notch := strin... | token.go | 0.587825 | 0.410874 | token.go | starcoder |
package chart
import "math"
const (
_2pi = 2 * math.Pi
_d2r = (math.Pi / 180.0)
_r2d = (180.0 / math.Pi)
)
// MinMax returns the minimum and maximum of a given set of values.
func MinMax(values ...float64) (min, max float64) {
if len(values) == 0 {
return
}
max = values[0]
min = values[0]
var value float6... | mathutil.go | 0.876092 | 0.639032 | mathutil.go | starcoder |
package tzpro
import (
"fmt"
)
// Indexer operation and event type
type OpType byte
// enums are allocated in chronological order with most often used ops first
const (
OpTypeBake OpType = iota // 0
OpTypeEndorsement // 1
OpTypeTransaction ... | optype.go | 0.597021 | 0.46873 | optype.go | starcoder |
package common
import (
"fmt"
"math"
)
// This is an improved version of Viterbi map matching, where we handle sparse traces by
// applying multiple transitions based on the distance between observations. For example,
// if two consecutive samples are k*VITERBI2_GRANULARITY apart, then we will apply (k-1)
// tra... | common/viterbi2.go | 0.784319 | 0.633098 | viterbi2.go | starcoder |
package ezaoc
// Stack is a naive, non-concurrent Stack implementation purely meant to reduce
// boilerplate of the most common pure-go "simple stack".
type Stack[T any] []T
// Push adds all ...T elements to the stack.
func (s *Stack[T]) Push(t ...T) {
(*s) = append((*s), t...)
}
// Peek returns the last element pu... | pkg/ezaoc/aoc.go | 0.843766 | 0.464294 | aoc.go | starcoder |
package components
import (
"fmt"
"math"
"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
)
// CollisionShape generic interface for implementing different types of collisions
type CollisionShape interface {
Type() string
Collides(other CollisionShape) bool
Anchor() *CLocation
Render() *imdraw.IMD... | examples/gopherPlatformer/components/collisionShape.go | 0.731059 | 0.415907 | collisionShape.go | starcoder |
package expr
import (
"fmt"
"github.com/genjidb/genji/document"
)
// A Param represents a parameter passed by the user to the statement.
type Param struct {
// Name of the param
Name string
// Value is the parameter value.
Value interface{}
}
// NamedParam is an expression which represents the name of a para... | sql/query/expr/param.go | 0.808861 | 0.415254 | param.go | starcoder |
package spelunk
import (
"errors"
"fmt"
"reflect"
"strings"
)
// A Handler operates on struct field values and is called by the Spelunker for each appropriately-tagged field.
// The name is the field name, the path the field path, and the tagValue the value of the tag.
// Returning a non-nil error immediately cau... | spelunk.go | 0.656108 | 0.42674 | spelunk.go | starcoder |
// Package crc16 implements the 16-bit cyclic redundancy check, or CRC-16,
// checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for
// information.
package crc16
// The size of a CRC-16 checksum in bytes.
const Size = 2
// https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Standards_and_common_us... | crc16.go | 0.885774 | 0.408159 | crc16.go | starcoder |
package reedsolomon
import (
"errors"
"fmt"
)
type GenericGFPoly struct {
field *GenericGF
coefficients []int
}
func NewGenericGFPoly(field *GenericGF, coefficients []int) (*GenericGFPoly, error) {
if len(coefficients) == 0 {
return nil, errors.New("IllegalArgumentException")
}
this := &GenericGFPoly... | common/reedsolomon/generic_gf_poly.go | 0.655115 | 0.511534 | generic_gf_poly.go | starcoder |
package noise
import (
"github.com/willbeason/worldproc/pkg/geodesic"
"math"
"math/rand"
)
type Perlin struct {
Dim int
Dim2 int
Noise []geodesic.Vector
}
func NewPerlin(r *rand.Rand, dim int) *Perlin {
dim2 := dim*dim
result := &Perlin{
Dim: dim,
Dim2: dim2,
Noise: make([]geodesic.Vector, dim*dim*dim... | pkg/noise/perlin.go | 0.588061 | 0.61173 | perlin.go | starcoder |
package evoli
import "sync"
type populationSync struct {
population
sync.RWMutex
}
// NewPopulationSync creates a threadsafe population
func NewPopulationSync(capacity int) Population {
pop := NewPopulation(capacity)
return &populationSync{
*pop.(*population),
sync.RWMutex{},
}
}
// Len returns the current... | populationSync.go | 0.696475 | 0.443179 | populationSync.go | starcoder |
package axon
import (
"fmt"
"reflect"
"unsafe"
"github.com/goki/ki/bitflag"
"github.com/goki/ki/kit"
"github.com/goki/mat32"
)
// NeuronVarStart is the byte offset of fields in the Neuron structure
// where the float32 named variables start.
// Note: all non-float32 infrastructure variables must be at the sta... | axon/neuron.go | 0.805096 | 0.681786 | neuron.go | starcoder |
package main
import (
rl "github.com/gen2brain/raylib-go/raylib"
)
func main() {
// Initialization
//--------------------------------------------------------------------------------------
var screenWidth int32 = 800
var screenHeight int32 = 450
rl.InitWindow(screenWidth, screenHeight, "raylib [models] example ... | examples/models/first_person_maze/main.go | 0.536556 | 0.4953 | main.go | starcoder |
package te
import (
"strconv"
"strings"
"time"
)
type parser struct {
loc *time.Location
pos int
tokens []token
exprs []Expression
join bool
}
// Parse parses the provided string into an Expression.
func Parse(s string, loc *time.Location) (Expression, error) {
s = strings.TrimSpace(s)
tokens, err... | parser.go | 0.582729 | 0.573738 | parser.go | starcoder |
package app
import (
"errors"
"sort"
"github.com/oysterpack/oysterpack.go/pkg/app/config"
"github.com/prometheus/client_golang/prometheus"
)
// NewHistogramMetricSpec is the HistogramMetricSpec factory method
func NewHistogramMetricSpec(spec config.HistogramMetricSpec) (HistogramMetricSpec, error) {
metricSpec... | pkg/app/metric_histograms.go | 0.613931 | 0.405537 | metric_histograms.go | starcoder |
package dealer
import (
"sync"
"sync/atomic"
"github.com/sirupsen/logrus"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
)
// OrderKey struct implements the `Key` interface of the sync.Map, which used for type assertion of the key
type OrderKey struct {
ExchangeName string
OrderID string
}
// ... | internal/dealer/order_registry.go | 0.743354 | 0.501099 | order_registry.go | starcoder |
package chron
import (
"time"
"github.com/dustinevan/chron/dura"
"fmt"
"reflect"
"database/sql/driver"
"strings"
)
type Month struct {
time.Time
}
func NewMonth(year int, month time.Month) Month {
return Month{time.Date(year, month, 1, 0, 0, 0, 0, time.UTC)}
}
func ThisMonth() Month {
return Now().AsMonth... | month.go | 0.609175 | 0.464476 | month.go | starcoder |
package unit
import "fmt"
// Unit represents a systemd unit
type Unit struct {
// the global embedded properties of the unit
Properties
// the name of the unit
Name string
// the description of the unit
Description string
// the units current active state
ActiveState string
// the units current load sta... | resource/systemd/unit/unit.go | 0.781331 | 0.427636 | unit.go | starcoder |
package paint
import (
"image"
"image/color"
"math"
"github.com/anthonynsimon/bild/clone"
"github.com/anthonynsimon/bild/util"
)
type fillPoint struct {
X, Y int
MarkedFromBelow bool
MarkedFromAbove bool
PreviousFillEdgeLeft int
PreviousFillEdgeRight int
}
// FloodFill fills ... | paint/fill.go | 0.78108 | 0.528412 | fill.go | starcoder |
package owm
// Coord defines the longitude and latitude for a location.
type Coord struct {
Lon, Lat float64
}
// Sys defines the country and sunset and sunrise timestamps.
type Sys struct {
Country string
Sunrise, Sunset int64
}
// Weather defines basic information about the weather.
type Weather struct ... | current.go | 0.674479 | 0.403743 | current.go | starcoder |
package base
import (
"bytes"
"fmt"
"io"
"gonum.org/v1/gonum/blas/blas64"
"gonum.org/v1/gonum/mat"
)
// MatConst is a matrix where all cless have the same value
type MatConst struct {
Rows, Columns int
Value float64
}
// Dims for MatConst
func (m MatConst) Dims() (int, int) { return m.Rows, m.Columns... | base/matrix.go | 0.723895 | 0.524212 | matrix.go | starcoder |
package rpg2d
import (
"bufio"
"bytes"
"errors"
"fmt"
"strings"
"github.com/ghthor/filu/rpg2d/coord"
)
// Represents a type of terrain in the world.
type TerrainType rune
const (
TT_UNKNOWN TerrainType = 'U'
TT_GRASS TerrainType = 'G'
TT_DIRT TerrainType = 'D'
TT_ROCK TerrainType = 'R'
)
type Ter... | rpg2d/terrain.go | 0.627495 | 0.41478 | terrain.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// AccessReviewStageSettings
type AccessReviewStageSettings struct {
// Stores additional data not described in the OpenAPI description found when deserializi... | models/access_review_stage_settings.go | 0.757436 | 0.502319 | access_review_stage_settings.go | starcoder |
package sudoku
import (
"errors"
"fmt"
"log"
"math"
"math/rand"
"regexp"
"strconv"
"strings"
"time"
)
func init() {
rand.Seed(time.Now().Unix())
}
// Board contains all fields of a simple, unannotated sudoku.
type Board [][]int
// NewEmptyBoard builds an empty board with provided size.
func NewEmptyBoard(... | sudoku.go | 0.680879 | 0.475057 | sudoku.go | starcoder |
package imgutil
import "image"
// img 图像, 顺时针旋转90°
func RotationRight(m image.Image) *image.RGBA {
bounds := m.Bounds()
rotate90 := image.NewRGBA(image.Rect(0, 0, bounds.Dy(), bounds.Dx()))
for x := bounds.Min.Y; x < bounds.Max.Y; x++ {
for y := bounds.Max.X - 1; y >= bounds.Min.X; y-- {
rotate90.Set(bounds.M... | src/imgutil/angle.go | 0.508788 | 0.424233 | angle.go | starcoder |
package gorough
import (
"math"
)
type Point struct {
X float64
Y float64
}
func (p Point) Eq(point Point) bool {
return p.X == point.X && p.Y == point.Y
}
type Line struct {
P1 Point
P2 Point
}
func (l Line) length() float64 {
return Distance(l.P1, l.P2)
}
// Distance returns the distance between 2 points... | geometry.go | 0.873323 | 0.593904 | geometry.go | starcoder |
package engine
// Exchange interaction (Heisenberg + Dzyaloshinskii-Moriya) for AF implementation
// See also cuda/exchange.cu and cuda/dmi.cu
import (
"github.com/mumax/3/cuda"
"github.com/mumax/3/data"
"github.com/mumax/3/util"
)
var (
Bex12 = NewScalarParam("Bex12", "J/m", "Exchange stiffness interlattice sam... | engine/ext_AF_exchange.go | 0.732974 | 0.400984 | ext_AF_exchange.go | starcoder |
package kdtree
import (
"sort"
datastructures "github.com/deepfabric/go-datastructures"
"github.com/keegancsmith/nth"
)
type Point struct {
Vals []uint64
UserData interface{}
}
type PointArray interface {
sort.Interface
GetPoint(idx int) Point
GetValue(idx int) uint64
SubArray(begin, end int) PointArra... | point.go | 0.641085 | 0.414721 | point.go | starcoder |
package doc
import (
"fmt"
"io"
"sort"
"strings"
"text/template"
"github.com/ovh/cds/sdk"
)
const sectionTemplate = `+++
title = "{{.Title}}"
+++
{{range .Routes}}
## {{.Title}}
URL | **` + "`{{.URL}}`" + `**
----------- |----------
Method | {{.Method}}
{{- if .QueryParams -}}
{{range .Query... | sdk/doc/print.go | 0.620507 | 0.529142 | print.go | starcoder |
package ast
// Packge ast implement the Abstract Syntax Tree (AST) that represents the
// parsed source code before being passed on to the interpreter for evaluation.
import (
"bytes"
"strings"
"github.com/cedrickchee/hou/token"
)
// Node defines an interface for all nodes in the AST.
type Node interface {
// R... | ast/ast.go | 0.88311 | 0.549218 | ast.go | starcoder |
package metrics
// Precision measures the fraction of times a class was correctly predicted.
type Precision struct {
Class float64
}
// Apply Precision.
func (precision Precision) Apply(yTrue, yPred, weights []float64) (float64, error) {
var cm, err = MakeConfusionMatrix(yTrue, yPred, weights)
if err != nil {
re... | metrics/precision.go | 0.927536 | 0.442938 | precision.go | starcoder |
package model
// aclaction <String> Read-write Action to perform on incoming IPv4 packets that match the extended ACL rule. Available settings function as follows: * ALLOW - The NetScaler appliance processes the packet. * BRIDGE - The NetScaler appliance bridges the packet to the destination without processing it. *... | model/nsacl.go | 0.512937 | 0.530784 | nsacl.go | starcoder |
package main
import (
"path/filepath"
"strconv"
"strings"
)
type (
// LineNumber is a number from 1 to the last line (counts lines from 1)
LineNumber int
// LineIndex is a number from 0 to the last line (counts lines from 0)
LineIndex int
// CharacterPosition is a number from 0 to the last character (counts... | linenumber.go | 0.623721 | 0.558929 | linenumber.go | starcoder |
package main
import (
"math"
)
// Mat is a struct wrapping 2D float64 array
type Mat struct {
mat [][]float64
}
// MatShape returns shape of the matrix
func (mat Mat) MatShape() [2]int {
return [2]int{len(mat.mat[0]), len(mat.mat)}
// ^~~~~width~~~~~ ^~~height~~~
}
// MatTranspose t... | matrix.go | 0.726717 | 0.692018 | matrix.go | starcoder |
package brotli
import "github.com/andybalholm/pack"
// An Encoder implements the pack.Encoder interface, writing in Brotli format.
type Encoder struct {
wroteHeader bool
bw bitWriter
distCache []distanceCode
}
func (e *Encoder) Reset() {
e.wroteHeader = false
e.bw = bitWriter{}
}
func (e *Encoder) E... | brotli/encoder.go | 0.566258 | 0.453504 | encoder.go | starcoder |
package rel
import (
"reflect"
)
// diffExpr implements a set difference in relational algebra
// This is one of the operations which consumes memory. In addition, no values
// can be sent before all values from the second source are consumed.
type diffExpr struct {
source1 Relation
source2 Relation
err err... | diff.go | 0.526343 | 0.434521 | diff.go | starcoder |
package file
import (
"bufio"
"bytes"
"regexp"
"golang.org/x/text/encoding"
)
// NewLineStartSplitFunc creates a bufio.SplitFunc that splits an incoming stream into
// tokens that start with a match to the regex pattern provided
func NewLineStartSplitFunc(re *regexp.Regexp) bufio.SplitFunc {
return func(data [... | operator/builtin/input/file/line_splitter.go | 0.649134 | 0.453927 | line_splitter.go | starcoder |
package lexer
import "fmt"
type Token struct {
Type TokenType
Literal string
Line int
Col int
Err error
}
type TokenType int
const (
// EOF is the token type returned when a lexer has reached the end of its input.
EOF = iota
// Illegal is the token type used for unknown tokens.
Illegal
// ... | lexer/token.go | 0.624408 | 0.414899 | token.go | starcoder |
package stream
import (
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
)
type sliceOrderedStream[Elem constraints.Ordered] struct {
sliceComparableStream[Elem]
}
// NewSliceByOrdered new stream instance, generics constraints based on constraints.Ordered
func NewSliceByOrdered[Elem constraints.Ordered](v... | slice_ordered.go | 0.897208 | 0.453806 | slice_ordered.go | starcoder |
package ds
import (
quadrilleError "github.com/quadrille/quadrille/core/errors"
"sort"
"sync"
)
type QuadTreeNode struct {
boundingBox Rectangle //Bounds of the current node
children *[4]*QuadTreeNode //Quadrants of the current node. This is lazily initialized to conserve memory
once sync.Onc... | core/ds/quadtree.go | 0.693369 | 0.415077 | quadtree.go | starcoder |
package ui
import "fmt"
// NewBounds creates a new Bounds object.
func NewBounds(x, y, width, height int) Bounds {
return Bounds{
Position: NewPosition(x, y),
Size: NewSize(width, height),
}
}
// Bounds represents a content area on the screen. It
// consists of a Position and Size.
type Bounds struct {
Po... | ui/bounds.go | 0.877516 | 0.637595 | bounds.go | starcoder |
package main
import "fmt"
const (
start = 136818
end = 685979
)
type Rule func(int) bool
// compareDigits compares digits in a number one-by-one, applying the condition function
// and returning with successResult if the condition is true for any two digits.
// returns the negation of successResult at the end i... | day4/day4.go | 0.707304 | 0.401394 | day4.go | starcoder |
package geohash
import "errors"
const (
/* These are constraints from EPSG:900913 / EPSG:3785 / OSGEO:41001
We can't geocode at the north/south pole.*/
WGS84_LAT_MIN = -85.05112878
WGS84_LAT_MAX = 85.05112878
WGS84_LONG_MIN = -180
WGS84_LONG_MAX = 180
/* Use 26*2 = 52bits to encode a position in WGS84, the... | common/geohash/geohash.go | 0.783906 | 0.530419 | geohash.go | starcoder |
package main
/*
An interface is a set of methods certain values are expected to have.
Any type that has all the methods listed in an interface definition
is said to satisfy that interface.
A type that satisfies an interface can be assigned to any variable
or function parameter that uses that interface as its type.
An ... | headfirstgo/myinterface.go | 0.704058 | 0.419113 | myinterface.go | starcoder |
// Package big implements arithmetic on rational numbers
// as a subset of the methods of "math/big":
// Num, Denom, Set, String
// Add, Mul, Sub, Neg.
// Nominator and Denominator are int64.
package big
// A Rat represents a quotient a/b of arbitrary precision.
// The zero value for a Rat represents the value 0.
t... | rat/rat.go | 0.847873 | 0.509337 | rat.go | starcoder |
package api
func init() {
Swagger.Add("authz_authz", `{
"swagger": "2.0",
"info": {
"title": "components/automate-gateway/api/authz/authz.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/auth/introspect": {... | components/automate-gateway/api/authz_authz.pb.swagger.go | 0.684475 | 0.444746 | authz_authz.pb.swagger.go | starcoder |
package gopiv
import (
"github.com/Knetic/govaluate"
)
// NumericColumn represents a column in a pivot table
type NumericColumn struct {
Data []float64
Name string
}
// Append a value to the row
func (nc *NumericColumn) Append(v float64) {
nc.Data = append(nc.Data, v)
}
// Len returns the length of the underlyi... | gopiv/table.go | 0.819713 | 0.474449 | table.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.