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 types
import (
"github.com/meshplus/gosdk/kvsql/util/hack"
"math"
"time"
)
// Kind constants.
const (
KindNull byte = 0
KindInt64 byte = 1
KindUint64 byte = 2
KindFloat32 byte = 3
KindFloat64 byte = 4
KindString byte = 5
KindBytes byte = 6
KindMysq... | kvsql/types/datum.go | 0.619817 | 0.445228 | datum.go | starcoder |
package ticketstats
import (
"fmt"
"log"
"time"
"github.com/montanaflynn/stats"
)
// Stats groups a average work statistics result for a ticket list.
type Stats struct {
Mean Work
Median Work
Count int
}
func (stats Stats) ToString() string {
return fmt.Sprintf("mean: %s, median: %s, count: %d",
format... | ticketstats/stats.go | 0.704872 | 0.421492 | stats.go | starcoder |
package dataframe
import (
"fmt"
"logarithmotechnia/vector"
"strconv"
)
type Column struct {
name string
vector vector.Vector
}
type Dataframe struct {
rowNum int
colNum int
columns []vector.Vector
columnNames []string
columnNamesVector vector.Vector
groupedBy ... | dataframe/dataframe.go | 0.597373 | 0.564699 | dataframe.go | starcoder |
package predictiongame
import "math"
import "fmt"
func evaluateConfidence(correct int, questions int, statedConfidence float64) string {
var message string
if correct < 0 || correct > questions {
return "Assertion failed in evaluateConfidence: variable questions out of bounds!"
}
// Two-sided binomial test
p... | confidence.go | 0.686475 | 0.596198 | confidence.go | starcoder |
// Package datastructure implements some data structure. eg. list, linklist, stack, queue, tree, graph.
package datastructure
import (
"reflect"
)
// List is a linear table, implemented with slice
type List[T any] struct {
data []T
}
// NewList return a pointer of List
func NewList[T any](data []T) *List[T] {
re... | datastructure/list/list.go | 0.691185 | 0.531939 | list.go | starcoder |
package graphql
import (
"fmt"
)
// nonNullTypeCreator is given to newTypeImpl for creating a NonNull.
type nonNullTypeCreator struct {
typeDef NonNullTypeDefinition
}
// nonNullTypeCreator implements typeCreator.
var _ typeCreator = (*nonNullTypeCreator)(nil)
// TypeDefinition implements typeCreator.
func (creat... | graphql/non_null.go | 0.74826 | 0.623692 | non_null.go | starcoder |
package geo
import (
"reflect"
"unsafe"
)
// Polygon represents a closed Polygon of vertices when
// the first and last vertices are equal.
type Polygon struct {
min, max LatLng // min and man LatLng
v []LatLng // Vertices
}
// NewPolygon returns a new empty Polygon
func NewPolygon() Polygon {
return ... | v2/geo/polygon.go | 0.875853 | 0.657153 | polygon.go | starcoder |
package runtime
import (
"github.com/zouzhihao-994/gvm/config"
"github.com/zouzhihao-994/gvm/oops"
"github.com/zouzhihao-994/gvm/utils"
"math"
)
type OperandStack struct {
// record the top position of the stack
size uint32
slots utils.Slots
}
func NewOperandStack(maxStack uint16) *OperandStack {
if maxStac... | runtime/operandStack.go | 0.587943 | 0.436682 | operandStack.go | starcoder |
package build
// Union returns the graph union g1 ∪ g2, which
// consists of the union of the two vertex sets
// and the union of the two edge sets of g1 and g2.
// The edges of the new graph will have zero cost.
func (g1 *Virtual) Union(g2 *Virtual) *Virtual {
return g1.union(g2, false)
}
// If cost is true keep co... | build/union.go | 0.71602 | 0.550003 | union.go | starcoder |
package models
// Paragraph format element.
type ParagraphFormat struct {
Link *WordsApiLink `json:"link,omitempty"`
// Gets or sets a flag indicating whether inter-character spacing is automatically adjusted between regions of Latin text and regions of East Asian text in the current paragraph. ... | v2005/api/models/paragraph_format.go | 0.784814 | 0.41253 | paragraph_format.go | starcoder |
package histogram
import (
"errors"
"github.com/kelvins/lbph/math"
"github.com/kelvins/lbph/metric"
)
// Calculate function generates a histogram based on the 'matrix' passed by parameter.
func Calculate(pixels [][]uint64, gridX, gridY uint8) ([]float64, error) {
var hist []float64
// Check the pixels 'matrix'... | histogram/histogram.go | 0.843863 | 0.602237 | histogram.go | starcoder |
package memory
import (
"fmt"
"reflect"
"github.com/google/gapid/core/math/u64"
"github.com/google/gapid/core/os/device"
)
// AlignOf returns the byte alignment of the type t.
func AlignOf(t reflect.Type, m *device.MemoryLayout) uint64 {
switch {
case t.Implements(tyPointer):
return uint64(m.GetPointer().Ge... | gapis/memory/alignof_sizeof.go | 0.626696 | 0.449816 | alignof_sizeof.go | starcoder |
package solver
import "github.com/heustis/tsp-solver-go/model"
// FindShortestPathNPHeap finds the shortest path by using a heap to grow the shortest circuit until in includes all the vertices.
// It accepts an unordered set of vertices, and returns the ordered list of vertices.
// This has a complexity of O(n!) and ... | solver/npsolverheap.go | 0.857231 | 0.754508 | npsolverheap.go | starcoder |
package distance
import (
"errors"
"github.com/ALTree/bigfloat"
v "github.com/cwchentw/algo-golang/vector/generics"
"math"
"math/big"
"reflect"
)
func Euclidean(p *v.Vector, q *v.Vector) (interface{}, error) {
return Minkowski(p, q, 2)
}
func Minkowski(p *v.Vector, q *v.Vector, n int) (interface{}, error) {
... | distance/generics/distance.go | 0.663233 | 0.537466 | distance.go | starcoder |
package sortedintlistgentest
import (
"fmt"
"github.com/comdiv/golang_course_comdiv/internal/sortedintlist"
"github.com/stretchr/testify/assert"
"math/rand"
"testing"
)
func GenericTestSorted_GetUnique(l sortedintlist.IIntSetMutable, t *testing.T) {
sortedintlist.InsertAllVar(l, 8, 1, 2, 4, 5, 4, 4, 5, 6, 1)
u... | internal/sortedintlistgentest/GenericSortedListTests.go | 0.690455 | 0.611411 | GenericSortedListTests.go | starcoder |
package dag
//go:generate stringer -type=Type,status -output=node.stringer.go
import (
"bytes"
"fmt"
"io"
"strings"
)
const (
// TypeMiddle represents the node type located in the middle of the graph.
TypeMiddle Type = iota
// TypeBeginning represents the node type that indicates beginning of the graph.
Type... | pkg/dag/node.go | 0.686895 | 0.467332 | node.go | starcoder |
package sctp
import (
"encoding/binary"
"github.com/pkg/errors"
)
/*
chunkHeader represents a SCTP Chunk header, defined in https://tools.ietf.org/html/rfc4960#section-3.2
The figure below illustrates the field format for the chunks to be
transmitted in the SCTP packet. Each chunk is formatted with a Chunk
Type f... | trunk/3rdparty/srs-bench/vendor/github.com/pion/sctp/chunkheader.go | 0.71413 | 0.435661 | chunkheader.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPLiteralMap256 struct for BTPLiteralMap256
type BTPLiteralMap256 struct {
Atomic *bool `json:"atomic,omitempty"`
BtType *string `json:"btType,omitempty"`
DocumentationType *string `json:"documentationType,omitempty"`
EndSourceLocation *int32 `json:"endSourceLocatio... | onshape/model_btp_literal_map_256.go | 0.701611 | 0.419648 | model_btp_literal_map_256.go | starcoder |
package kafkachannel
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"knative.dev/reconciler-test/pkg/feature"
)
// ConfigureDataPlane creates a Feature which sets up the specified KafkaChannel
// Subscription and EventsHub Receiver so that it is ready to receive CloudEvents.
func ConfigureData... | test/rekt/features/kafkachannel/dataplane.go | 0.765243 | 0.476032 | dataplane.go | starcoder |
package magica
import (
"github.com/mattkimber/gandalf/geometry"
"github.com/mattkimber/gandalf/magica/scenegraph"
"github.com/mattkimber/gandalf/magica/types"
"github.com/mattkimber/gandalf/utils"
)
type VoxelData [][][]byte
type VoxelObject struct {
Voxels [][][]byte
PaletteData []byte
Size geom... | magica/voxelobject.go | 0.7413 | 0.51312 | voxelobject.go | starcoder |
package backoff
import (
"fmt"
"time"
)
const (
// Default value to use for number of iterations: infinite
DefaultMaxIterations uint64 = 0
// Default value to use for maximum iteration time
DefaultMaxIterationTime = 60 * time.Second
// Default value to use for maximum execution time: infinite
DefaultMaxTotalT... | backoff/backoff.go | 0.754734 | 0.453383 | backoff.go | starcoder |
package main
import (
"fmt"
"sort"
"wheal-investments-algorithm/funds"
"wheal-investments-algorithm/ga"
)
func main() {
//The size of the population
sizeOfPopulation := 1000
//The number of generations
numGenerations := 1000
//The number of eliete members of the population
numElietes := 50
//The proabil... | main.go | 0.599837 | 0.44065 | main.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPStatementCompressedQuery1237 struct for BTPStatementCompressedQuery1237
type BTPStatementCompressedQuery1237 struct {
BTPStatement269
BtType *string `json:"btType,omitempty"`
Query *string `json:"query,omitempty"`
}
// NewBTPStatementCompressedQuery1237 instantiat... | onshape/model_btp_statement_compressed_query_1237.go | 0.662469 | 0.423041 | model_btp_statement_compressed_query_1237.go | starcoder |
// Package rla provides an implementation of RLA (Recurrent Linear Attention).
// See: "Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention" by Katharopoulos et al., 2020.
package rla
import (
"encoding/gob"
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
"github.com/... | nn/recurrent/rla/rla.go | 0.854019 | 0.530723 | rla.go | starcoder |
package main
import (
"container/heap"
"fmt"
"regexp"
"strconv"
"github.com/budavariam/advent_of_code/2018/utils"
)
func main() {
input := utils.LoadInput("23_2")
result := LNN(input)
fmt.Println(result)
}
// LNN gets the closest point that has the largest number of nanobot intersections. Based on a solutio... | 2018/23_2/solution.go | 0.70202 | 0.500488 | solution.go | starcoder |
package main
import "fmt"
// Set union.
func Union(a int, b int) int {
return a | b
}
// Set intersection.
func Intersection(a int, b int) int {
return a & b
}
// This is set subtraction, not regular subtraction.
func Subtraction(a int, b int) int {
return a & ^b
}
// This is binary negation, not a simple sign ... | archive/volkan.io/examples/bitwise/004_tricks.go | 0.7324 | 0.419053 | 004_tricks.go | starcoder |
package gpsutil
import (
"fmt"
"math"
)
// GetDistance returns distance in meters between 2 given points
func GetDistance(lng1, lat1, lng2, lat2 float64) float64 {
dLat := toRad(lat2 - lat1)
dLng := toRad(lng2 - lng1)
a := math.Pow(math.Sin(dLat/2), 2) + math.Pow(math.Sin(dLng/2), 2)*math.Cos(toRad(lat1))*math.... | distance.go | 0.82485 | 0.647269 | distance.go | starcoder |
package tuple
// Tuple1 is a tuple containing 1 value(s).
type Tuple1[T0 any] struct {
V0 T0
}
// New1 creates a new tuple of 1 value(s).
func New1[T0 any](v0 T0) *Tuple1[T0] {
return &Tuple1[T0]{v0}
}
// Tuple2 is a tuple containing 2 value(s).
type Tuple2[T0, T1 any] struct {
V0 T0
V1 T1
}
// New2 creates a ... | tuple/tuple.go | 0.708414 | 0.586819 | tuple.go | starcoder |
package neighbors
import (
"fmt"
"runtime"
"github.com/pa-m/sklearn/base"
"github.com/pa-m/sklearn/metrics"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
)
// KNeighborsRegressor is a Regression based on k-nearest neighbors.
// The target is predicted by local interpolation of the targets
// associated o... | neighbors/regression.go | 0.789274 | 0.453625 | regression.go | starcoder |
package catalog
const ProjectTemplate = `
{{range $name, $link := .Links}}
[{{$name}}]({{$link}})
{{end}}
# {{Base .Title}}
| Package |
----|{{range $val := Packages .Module}}
[{{$val}}]({{$val}}/README.md)|{{end}}
## Integration Diagram
<img src="{{CreateIntegrationDiagram .Module .Title false}}">
## End Point Ana... | pkg/catalog/template.go | 0.626581 | 0.41117 | template.go | starcoder |
package exp
import (
"regexp"
"strings"
"unicode"
)
import (
"github.com/pkg/errors"
)
func ParseValue(s string, remainder string) (Node, error) {
if len(remainder) == 0 {
return &Literal{Value: s}, nil
}
left := &Literal{Value: s}
root, err := Parse(remainder)
if err != nil {
return root, err
}
swi... | graph/exp/Parse.go | 0.578329 | 0.518973 | Parse.go | starcoder |
package gf
import (
"crypto/rand"
"encoding/binary"
"fmt"
)
// GF(64) under the irreducible polynomial R
// R = x^64 + x^4 + x^3 + x + 1
// R = x^64 + r
// gf64MOD is the lower part of the irreducible polynomial
// r = x^4 + x^3 + x + 1
var gf64MOD uint64 = 0x1b
// randGF64 generates a new random GF(64) element.
... | gf64_field.go | 0.557123 | 0.455925 | gf64_field.go | starcoder |
package clikit
import termbox "github.com/nsf/termbox-go"
// RelCoord is a coordinate relative to a Canvas's origin
type RelCoord int
// AbsCoord is a coordinate relative to the terminal's origin
type AbsCoord int
// Canvas represents an absolute rectange on the screen upon which drawing operations are applied.
typ... | draw.go | 0.735926 | 0.598048 | draw.go | starcoder |
package main
import (
"github.com/ByteArena/box2d"
"github.com/wdevore/Ranger-Go-IGE/api"
"github.com/wdevore/Ranger-Go-IGE/engine/rendering/color"
"github.com/wdevore/Ranger-Go-IGE/extras/shapes"
)
func (p *seesawPhysicsComponent) Build2(world api.IWorld, parent api.INode, phyWorld *box2d.B2World, position api.I... | examples/complex/physics/basic/p7_seesaw/seesaw_physics_component2.go | 0.625896 | 0.556761 | seesaw_physics_component2.go | starcoder |
package serialization
import (
"reflect"
"strings"
"sync"
"github.com/modern-go/reflect2"
"github.com/pkg/errors"
)
var cache sync.Map
// Type wraps reflect.Type with serialization support.
// To deserialize the type on the remote, it also needs be available and registered in the remote side.
type Type struct ... | internal/serialization/type.go | 0.719384 | 0.411879 | type.go | starcoder |
package curves
import (
"math/big"
)
// CurveSystem is a set of parameters and functions for a pairing based cryptosystem
// It has everything necessary to support all bgls functionality which we use.
type CurveSystem interface {
Name() string
MakeG1Point([]*big.Int, bool) (Point, bool)
MakeG2Point([]*big.Int, ... | curves/curve.go | 0.735357 | 0.629348 | curve.go | starcoder |
package v1
import (
"encoding/json"
"time"
)
// Timeframe struct for Timeframe
type Timeframe struct {
StartedAt time.Time `json:"started_at"`
EndedAt time.Time `json:"ended_at"`
}
// NewTimeframe instantiates a new Timeframe object
// This constructor will assign default values to properties that have it defin... | v1/model_timeframe.go | 0.78964 | 0.429549 | model_timeframe.go | starcoder |
package render
import (
geometry "basic-ray/pkg/geometry"
_ "fmt"
pb "github.com/cheggaaa/pb/v3"
"math"
)
func Main(origin geometry.Point, lightSources []LightSource, camera *Camera, triangles []*geometry.Triangle) {
var light Photon
bar := pb.StartNew(len(*camera.Pixels) * len((*camera.Pixels)[0]))
for i, ro... | pkg/render/ray_trace.go | 0.693577 | 0.524943 | ray_trace.go | starcoder |
package gohome
import (
"github.com/PucklaMotzer09/mathgl/mgl32"
"math"
)
const (
NEAR_LEFT_DOWN = 0
NEAR_RIGHT_DOWN = 1
NEAR_RIGHT_UP = 2
NEAR_LEFT_UP = 3
FAR_LEFT_DOWN = 4
FAR_RIGHT_DOWN = 5
FAR_RIGHT_UP = 6
FAR_LEFT_UP = 7
)
// A projection that is used to correctly display the objects o... | src/gohome/projection.go | 0.786336 | 0.549761 | projection.go | starcoder |
package gltf
import "encoding/json"
var (
// DefaultMatrix defines an identity matrix.
DefaultMatrix = [16]float64{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}
// DefaultRotation defines a quaternion without rotation.
DefaultRotation = [4]float64{0, 0, 0, 1}
// DefaultScale defines a scaling that does not mod... | const.go | 0.695235 | 0.49347 | const.go | starcoder |
package nomad
import (
"sort"
"sync"
"time"
"github.com/ugorji/go/codec"
)
// TimeTable is used to associate a Raft index with a timestamp.
// This is used so that we can quickly go from a timestamp to an
// index or visa versa.
type TimeTable struct {
granularity time.Duration
limit time.Duration
table... | vendor/github.com/hashicorp/nomad/nomad/timetable.go | 0.669096 | 0.409398 | timetable.go | starcoder |
package main
import (
"fmt"
"github.com/pkg/errors"
"gorgonia.org/gorgonia"
"gorgonia.org/tensor"
)
type convLayer struct {
filters int
padding int
kernelSize int
stride int
activation string
batchNormalize int
bias bool
layerIndex int
//learnables
means, vars ... | examples/tiny-yolo-v3-coco/conv_layer.go | 0.533884 | 0.40928 | conv_layer.go | starcoder |
package main
import (
"fmt"
"log"
"sort"
"strings"
"sync"
"github.com/nfisher/mdindexer/edit"
)
var (
ErrWordNotIndexed = fmt.Errorf("index does not contain word")
)
type Document struct {
Name string
WordCount map[string]int
}
// New creates an index that can accommodate the number of documents spec... | index.go | 0.576304 | 0.412234 | index.go | starcoder |
package basic
import "strings"
// DropWhilePtrTest returns a new list after dropping the given item
func DropWhilePtrTest() string {
return `
func TestDropWhile<FTYPE>Ptr(t *testing.T) {
// Test : drop the numbers as long as condition match and returns remaining number in the list once condition fails
var v2 <TYP... | internal/template/basic/dropwhileptrtest.go | 0.630116 | 0.475544 | dropwhileptrtest.go | starcoder |
package grouper
import (
"fmt"
"strings"
"github.com/go-openapi/strfmt"
"github.com/semi-technologies/weaviate/entities/models"
"github.com/semi-technologies/weaviate/entities/search"
)
type valueType int
const (
numerical valueType = iota
textual
boolean
reference
geo
unknown
)
type valueGroup struct ... | usecases/traverser/grouper/merge_group.go | 0.586641 | 0.431764 | merge_group.go | starcoder |
package buckettree
import (
"bytes"
"sort"
"github.com/abchain/fabric/core/ledger/statemgmt"
)
// Code for managing changes in data nodes
type dataNodes []*dataNode
func (dataNodes dataNodes) Len() int {
return len(dataNodes)
}
func (dataNodes dataNodes) Swap(i, j int) {
dataNodes[i], dataNodes[j] = dataNodes... | core/ledger/statemgmt/buckettree/data_nodes_delta.go | 0.557364 | 0.468547 | data_nodes_delta.go | starcoder |
// This file must be kept in sync with index_no_bound_checks.go.
// +build bounds
package mat
// At returns the element at row i, column j.
func (m *Dense) At(i, j int) float64 {
return m.at(i, j)
}
func (m *Dense) at(i, j int) float64 {
if uint(i) >= uint(m.mat.Rows) {
panic(ErrRowAccess)
}
if uint(j) >= ui... | vendor/gonum.org/v1/gonum/mat/index_bound_checks.go | 0.78535 | 0.464719 | index_bound_checks.go | starcoder |
package fcc
var HomeYML = map[string]string{
"2017-05-18T160934Z": `
name: home
modifiedon: 2017-05-18T160934Z
outputscheme:
show_unknown_devices: true
interval: 30
devices:
- id: 1
num: 0
addr: 0
type: JeeLink
alias: Schreibtisch
absent: false
locked: true
lon: 0
lat... | fcc/YMLdata.go | 0.654232 | 0.490114 | YMLdata.go | starcoder |
Package bender makes it easy to build load testing applications for services using protocols like
HTTP, Thrift, Protocol Buffers and many others.
Bender provides two different approaches to load testing. The first, LoadTestThroughput, gives the
tester control over the throughput (QPS), but not over the concurrency (nu... | internal/bender/doc.go | 0.861538 | 0.796253 | doc.go | starcoder |
package encoding
import (
"fmt"
"chromiumos/tast/local/coords"
"chromiumos/tast/local/media/videotype"
)
// StreamParams is the parameter for video_encode_accelerator_unittest.
type StreamParams struct {
// Name is the name of input raw data file.
Name string
// Size is the width and height of YUV image in th... | src/chromiumos/tast/local/media/encoding/stream_params.go | 0.50293 | 0.448245 | stream_params.go | starcoder |
package golang
import (
srccore "evergreen/dub/core"
src "evergreen/dub/flow"
dstcore "evergreen/go/core"
dst "evergreen/go/flow"
"evergreen/graph"
)
type flowMapper struct {
ctx *DubToGoContext
stitcher *graph.EdgeStitcher
builder *dst.GoFlowBuilder
original *src.LLFunc
}
func (mapper *flowMapper) si... | src/evergreen/dub/transform/golang/translate_flow.go | 0.539469 | 0.409988 | translate_flow.go | starcoder |
package distance
import (
"errors"
"math"
)
type DistMetric func(x []float64, y []float64) (dist float64, err error)
func Binary(x []float64, y []float64) (dist float64, err error) {
if len(x) != len(y) {
err = errors.New("Vectors for calculating distance must have equal length")
return
}
denominator := flo... | distance/distmetric.go | 0.616705 | 0.530723 | distmetric.go | starcoder |
package exp
type (
sqlFunctionExpression struct {
name string
args []interface{}
}
)
// Creates a new SQLFunctionExpression with the given name and arguments
func NewSQLFunctionExpression(name string, args ...interface{}) SQLFunctionExpression {
return sqlFunctionExpression{name: name, args: args}
}
func (sfe... | exp/func.go | 0.776029 | 0.447762 | func.go | starcoder |
package register
import (
"fmt"
"github.com/golang/glog"
)
const (
InitialSetup RegStep = "Initial Minikube Setup"
SelectingDriver RegStep = "Selecting Driver"
DownloadingArtifacts RegStep = "Downloading Artifacts"
StartingNode RegStep = "Starting Node"
RunningLocalhost RegStep = "Run... | pkg/minikube/out/register/register.go | 0.567457 | 0.404096 | register.go | starcoder |
package components
import (
"container/ring"
"context"
"math"
"sync"
"github.com/mitchellh/go-glint"
)
// SparklineComponent renders a sparkline graph.
type SparklineComponent struct {
sync.Mutex
// If set, this will style the peak value.
PeakStyle []glint.StyleOption
values *ring.Ring
}
// Sparkline cre... | components/sparkline.go | 0.672332 | 0.411347 | sparkline.go | starcoder |
package geom
// A MultiPolygon is a collection of Polygons.
type MultiPolygon struct {
geom3
}
// NewMultiPolygon returns a new MultiPolygon with no Polygons.
func NewMultiPolygon(Lay Layout) *MultiPolygon {
return NewMultiPolygonFlat(Lay, nil, nil)
}
// NewMultiPolygonFlat returns a new MultiPolygon w... | multipolygon.go | 0.790692 | 0.542379 | multipolygon.go | starcoder |
package easings
import (
"math"
)
// Linear Easing functions
// LinearNone easing
func LinearNone(t, b, c, d float32) float32 {
return c*t/d + b
}
// LinearIn easing
func LinearIn(t, b, c, d float32) float32 {
return c*t/d + b
}
// LinearOut easing
func LinearOut(t, b, c, d float32) float32 {
return c*t/d + b
... | easings/easings.go | 0.830319 | 0.579638 | easings.go | starcoder |
package assert
import (
"encoding/json"
)
// Equal checks if values equal to each other
func Equal(left, right interface{}) bool {
return isCompareTrue(equal, left, right)
}
// NotEqual checks if values not equal to each other
func NotEqual(left, right interface{}) bool {
return isCompareTrue(notEqual, left, righ... | assert.go | 0.658088 | 0.547404 | assert.go | starcoder |
package driver
type AuthenticationType int
const (
// AuthenticationTypeBasic uses username+password basic authentication
AuthenticationTypeBasic AuthenticationType = iota
// AuthenticationTypeJWT uses username+password JWT token based authentication
AuthenticationTypeJWT
// AuthenticationTypeRaw uses a raw val... | deps/github.com/arangodb/go-driver/authentication.go | 0.784649 | 0.406833 | authentication.go | starcoder |
package api
import (
"encoding/json"
)
// Cell struct for Cell
type Cell struct {
// The Cell Identity (for 2G and 3G networks), a 16 bit value represented in decimal form as an integer. (See 3GPP TS 23.003 4.3)
Ci *int32 `json:"ci,omitempty"`
// The E-UTRAN Cell Identifier (for LTE networks), a 28 bit value rep... | openapi/api/model_cell.go | 0.783823 | 0.500061 | model_cell.go | starcoder |
package skyhook
import (
"encoding/binary"
"encoding/json"
"io"
"os"
"strings"
)
type DataType string
const (
ImageType DataType = "image"
VideoType = "video"
DetectionType = "detection"
ShapeType = "shape"
IntType = "int"
FloatsType = "floats"
ImListType = "imlist"
TextType = "text"
StringType = "strin... | skyhook/data.go | 0.642208 | 0.415699 | data.go | starcoder |
package record
import (
"strings"
)
type Record struct {
data map[string]interface{}
}
// New creates a pointer to a Record which is ready to have values set.
func New() *Record {
return &Record{make(map[string]interface{})}
}
// Init creates a pointer to a Record whose underlying data is the input.
func Init(m ... | record.go | 0.582254 | 0.498169 | record.go | starcoder |
package scraper
import (
"database/sql"
"errors"
"fmt"
"math"
"regexp"
"time"
pq "gitee.com/opengauss/openGauss-connector-go-pq"
"github.com/blang/semver"
"github.com/gogf/gf/util/gconv"
"github.com/prometheus/client_golang/prometheus"
"opengauss_exporter/internal/core/scrape"
"opengauss_exporter/intern... | internal/scraper/postgresql_exporter.go | 0.6508 | 0.434221 | postgresql_exporter.go | starcoder |
package vgmath
import (
"fmt"
"math"
)
// AxisX x轴
var AxisX *Vector3 = NewVector3(1, 0, 0)
// AxisY y轴
var AxisY *Vector3 = NewVector3(0, 1, 0)
// AxisZ z轴
var AxisZ *Vector3 = NewVector3(0, 0, 1)
// Vector3 向量
type Vector3 struct {
x, y, z float64
}
// NewVector3 新建向量
func NewVector3(x, y, z float64) *Vector... | util/vgmath/vector.go | 0.517815 | 0.584064 | vector.go | starcoder |
package iso20022
// Specifies security rate details.
type CorporateActionRate77 struct {
// Quantity of additional intermediate securities/new equities awarded for a given quantity of securities derived from subscription.
AdditionalQuantityForSubscribedResultantSecurities *RatioFormat23Choice `xml:"AddtlQtyForSbcbd... | CorporateActionRate77.go | 0.880579 | 0.532911 | CorporateActionRate77.go | starcoder |
package render
import (
"image"
"image/color"
"math"
"github.com/oakmound/oak/v4/alg/floatgeom"
"github.com/oakmound/oak/v4/alg/span"
)
// A Polygon is a renderable that is represented by a set of in order points
// on a plane.
type Polygon struct {
*Sprite
floatgeom.Polygon2
}
// NewPointsPolygon is a helpe... | render/polygon.go | 0.843975 | 0.625667 | polygon.go | starcoder |
package container
import (
"fmt"
"io"
"unsafe"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/stl"
)
func NewStrVector[T any](opts ...*Options) *strVector[T] {
var capacity int
var alloc stl.MemAllocator
lenOpt := new(Options)
offOpt := new(Options)
dataOpt := new(Options)
if len(opts) > 0 {
opt :=... | pkg/vm/engine/tae/stl/container/strvec.go | 0.597256 | 0.407923 | strvec.go | starcoder |
// Command stats implements the stats Quick Start example from:
// https://opencensus.io/quickstart/go/metrics/
package main
import (
"bufio"
"bytes"
"context"
"fmt"
"io"
"log"
"os"
"time"
"net/http"
"go.opencensus.io/examples/exporter"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.openc... | vendor/go.opencensus.io/examples/quickstart/stats.go | 0.630116 | 0.527682 | stats.go | starcoder |
package v1
const (
// AnnotationCreated is the annotation key for the date and time on which the image was built (date-time string as defined by RFC 3339).
AnnotationCreated = "org.opencontainers.image.created"
// AnnotationAuthors is the annotation key for the contact details of the people or organization respon... | vendor/github.com/opencontainers/image-spec/specs-go/v1/annotations.go | 0.660501 | 0.436802 | annotations.go | starcoder |
package utils
import (
"errors"
"math/big"
"github.com/daoleno/uniswap-sdk-core/entities"
"github.com/daoleno/uniswapv3-sdk/constants"
)
var (
ErrSqrtPriceLessThanZero = errors.New("sqrt price less than zero")
ErrLiquidityLessThanZero = errors.New("liquidity less than zero")
ErrInvariant = errors.... | utils/sqrtprice_math.go | 0.711531 | 0.590455 | sqrtprice_math.go | starcoder |
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file tests type lists & structural constraints.
// Note: This test has been adjusted to use the new
// type set notation rather than type lists.... | test/typeparam/typelist.go | 0.806014 | 0.413477 | typelist.go | starcoder |
package cf
// CF is a main struct of changefinder.
type CF struct {
smooth int
order int
r float64
ts []float64
firstScores []float64
smoothedScores []float64
secondScores []float64
convolve []float64
smooth2 int
convolve2 []float64
sdarFirst ... | cf.go | 0.713831 | 0.515071 | cf.go | starcoder |
package cef
import (
"net"
"strconv"
"time"
"github.com/pkg/errors"
"github.com/elastic/beats/v7/libbeat/common"
)
// DataType specifies one of CEF data types.
type DataType uint8
// List of DataTypes.
const (
Unset DataType = iota
IntegerType
LongType
FloatType
DoubleType
StringType
BooleanType
IPTy... | x-pack/filebeat/processors/decode_cef/cef/types.go | 0.756537 | 0.4856 | types.go | starcoder |
// It is not always possible to be able to say the interface value itself will be enough context.
// Sometimes, it requires more context. For example, a networking problem can be really
// complicated. Error variables wouldn't work there.
// Only when the error variables wouldn't work, we should go ahead and start wor... | go/design/error_3.go | 0.634317 | 0.441673 | error_3.go | starcoder |
package parse
import (
"strings"
"unicode"
"unicode/utf8"
)
// token represents a unit of information found in an IDL file.
type token struct {
t int // The tokens on the form T_XXX defined in the parser. Mandatory.
v string // Any additional token value for strings, integers and floats. May be an empty strin... | data/train/go/687245c94e9dd4704980a050f04e00520dc25093token.go | 0.530723 | 0.505493 | 687245c94e9dd4704980a050f04e00520dc25093token.go | starcoder |
package convert
import (
"errors"
"strconv"
)
// IntToBool -- Converts a value from int64 to boolean
func IntToBool(value int64) (bool, error) {
if int64(1) == value {
return true, nil
} else if int64(0) == value {
return false, nil
}
return false, errors.New(cannotConvertErrMsg)
}
// IntToFloat32 -- Con... | int.go | 0.837387 | 0.50891 | int.go | starcoder |
package main
import "fmt"
// DeviceConverter is the representation of the wrist deviceConverter
type DeviceConverter struct {
registers [6]int
instructions []Instruction
ipBoundTo int
ip int
}
func (d DeviceConverter) isEqual(other DeviceConverter) bool {
for i, value := range d.registers {
if... | 2018/21_1/deviceConverter.go | 0.527317 | 0.441974 | deviceConverter.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// NumRangeFromIntArray2 returns a driver.Valuer that produces a PostgreSQL numrange from the given Go [2]int.
func NumRangeFromIntArray2(val [2]int) driver.Valuer {
return numRangeFromIntArray2{val: val}
}
// NumRangeToIntArray2 returns an ... | pgsql/numrange.go | 0.801354 | 0.740597 | numrange.go | starcoder |
package streamstats
import "fmt"
// BoxPlot represents a BoxPlot with interquartile range and whiskers backed by a P2-Quantile tracking the median, P=0.5
type BoxPlot struct {
P2Quantile
}
// NewBoxPlot returns a new BoxPlot
func NewBoxPlot() BoxPlot {
return BoxPlot{NewP2Quantile(0.5)}
}
// Median returns the es... | boxplot.go | 0.921852 | 0.768038 | boxplot.go | starcoder |
package lzfse
type lzvnOpCode byte
const (
nop lzvnOpCode = iota
end_of_stream
undefined
small_literal
large_literal
small_match
large_match
small_distance
large_distance
medium_distance
previous_distance
)
var opcode_table = [256]lzvnOpCode{
small_distance, small_distance, small_distance, small_dista... | pkg/lzfse/lzvn.go | 0.540681 | 0.566978 | lzvn.go | starcoder |
package chaikin
import (
"math/big"
"github.com/MicahParks/go-ad"
"github.com/MicahParks/go-ma"
)
// BigChaikin represents the state of the Chaikin Oscillator.
type BigChaikin struct {
ad *ad.BigAD
short *ma.BigEMA
long *ma.BigEMA
prevBuy bool
}
// BigResult holds the results of a BigChaikin calcul... | big.go | 0.75274 | 0.461138 | big.go | starcoder |
package model
import (
"path/filepath"
"github.com/gobwas/glob"
"github.com/pkg/errors"
)
type PathMatcher interface {
Matches(f string, isDir bool) (bool, error)
}
// A Matcher that matches nothing.
type emptyMatcher struct{}
func (m emptyMatcher) Matches(f string, isDir bool) (bool, error) {
return false, n... | internal/model/matcher.go | 0.722233 | 0.444625 | matcher.go | starcoder |
package sprite
import (
"bytes"
"encoding/binary"
"github.com/silbinarywolf/gml-go/gml/internal/dt"
"github.com/silbinarywolf/gml-go/gml/internal/geom"
)
type spriteStateSerialize struct {
SpriteIndex SpriteIndex
ImageScale geom.Vec
ImageIndex float64
}
type SpriteState struct {
spriteIndex SpriteIndex
I... | gml/internal/sprite/sprite_state.go | 0.615203 | 0.427994 | sprite_state.go | starcoder |
package quicksort
import (
"math/rand"
)
// QuickSort quick sort
func QuickSort(A []int, start, end int, isIncrement bool) []int {
if start < end {
r := partition(A, start, end, isIncrement)
QuickSort(A, start, r-1, isIncrement)
QuickSort(A, r+1, end, isIncrement)
}
return A
}
// Partition A with A[end], ... | sort/quick/quick.go | 0.544559 | 0.498474 | quick.go | starcoder |
package geom
import (
"fmt"
"io"
"math"
"math/rand"
)
// Vec represents a 3-element vector
type Vec struct {
E [3]float64
}
// NewVec creates a Vec from 3 float values
func NewVec(e0, e1, e2 float64) Vec {
return Vec{E: [3]float64{e0, e1, e2}}
}
// RandVecInSphere creates a random Vec within a unit sphere
// ... | src/renderer/pkg/geom/vec.go | 0.688678 | 0.635618 | vec.go | starcoder |
package gdnative
import (
"fmt"
"reflect"
"github.com/godot-go/godot-go/pkg/log"
)
// VariantToGoType will check the given variant type and convert it to its
// actual type. The value is returned as a reflect.Value.
func VariantToGoType(variant Variant) reflect.Value {
v := variant.GetType()
switch v {
case GO... | pkg/gdnative/convertvariant.go | 0.598312 | 0.4184 | convertvariant.go | starcoder |
package befunge
import "math"
// https://en.wikipedia.org/wiki/Befunge
// 0-9 Push this number on the stack.
const (
OpAdd = '+' // Addition: Pop a and b, then push a+b.
OpSub = '-' // Subtraction: Pop a and b, then push b-a.
OpMult = '*' // Multiplication: Pop a and b, then push a*b.
OpDiv... | const.go | 0.633183 | 0.473292 | const.go | starcoder |
package header
/**
* This interface represents the RAck header, as defined by
* <a href = "http://www.ietf.org/rfc/rfc3262.txt">RFC3262</a>, this
* header is not part of RFC3261.
* <p>
* The PRACK messages contain an RAck header field, which indicates the
* sequence number of the provisional response that is bei... | sip/header/RAckHeader.go | 0.905908 | 0.424114 | RAckHeader.go | starcoder |
package engine
// Exchange interaction (Heisenberg + Dzyaloshinskii-Moriya)
// See also opencl/exchange.cl and opencl/dmi.cl
import (
"github.com/mumax/3cl/data"
"github.com/mumax/3cl/opencl"
"github.com/mumax/3cl/util"
"unsafe"
)
var (
Aex = NewScalarParam("Aex", "J/m", "Exchange stiffness", &lex2)
Dind ... | engine/exchange.go | 0.602763 | 0.423398 | exchange.go | starcoder |
package projection
import (
"fmt"
"github.com/andrepxx/sydney/coordinates"
"math"
)
/*
* Mathematical constants.
*/
const (
MATH_HALF_PI = 0.5 * math.Pi
MATH_TWO_PI = 2.0 * math.Pi
MATH_QUARTER_PI = 0.25 * math.Pi
)
/*
* Interface type representing a projection from geographic locations to points
* ... | projection/projection.go | 0.694613 | 0.543893 | projection.go | starcoder |
// Package costs gets billing information from an ElasticSearch.
package costs
import (
"fmt"
"strings"
"time"
"github.com/olivere/elastic"
)
// aggregationBuilder is an alias for the function type that is used in the
// aggregationBuilder functions.
type aggregationBuilder func([]string) []paramAggrAndName
//... | costs/es_request_constructor.go | 0.671578 | 0.406391 | es_request_constructor.go | starcoder |
package client
// A StatefulSetSpec is the specification of a StatefulSet.
type V1beta1StatefulSetSpec struct {
// podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. The default policy is `OrderedReady`, where pods are created in increasing ... | vendor/github.com/kubernetes-client/go/kubernetes/client/v1beta1_stateful_set_spec.go | 0.791418 | 0.599573 | v1beta1_stateful_set_spec.go | starcoder |
package graphic
import (
"github.com/adamlenda/engine/core"
"github.com/adamlenda/engine/geometry"
"github.com/adamlenda/engine/gls"
"github.com/adamlenda/engine/material"
"github.com/adamlenda/engine/math32"
)
// Sprite is a potentially animated image positioned in space that always faces the camera.
type Spri... | graphic/sprite.go | 0.764716 | 0.4165 | sprite.go | starcoder |
package enum
import (
"database/sql/driver"
"errors"
"github.com/mwbrown/nagbot/ndb/nbsql"
)
// SchedType is the 'sched_type' enum type from schema 'Public'.
type SchedType uint16
const (
// UnknownSchedType defines an invalid SchedType.
UnknownSchedType SchedType = 0
OneshotSchedType SchedType = 1
Interva... | ndb/nbsql/enum/schedtype.go | 0.770206 | 0.42185 | schedtype.go | starcoder |
package iso20022
// Instruction, initiated by the creditor, to debit a debtor's account in favour of the creditor. A direct debit can be pre-authorised or not. In most countries, authorisation is in the form of a mandate between the debtor and creditor.
type DirectDebitMandate4 struct {
// Unambiguous identification... | DirectDebitMandate4.go | 0.651133 | 0.557123 | DirectDebitMandate4.go | starcoder |
QuadTrees
*/
//-----------------------------------------------------------------------------
package sdf
//-----------------------------------------------------------------------------
const (
ROOT = iota - 1 // root node
TL // top left
TR // top right
BL // bottom left
... | .wip/quadtree.go | 0.612078 | 0.436562 | quadtree.go | starcoder |
// The datatypes/collection package provides new structures and
// behaviours to the iteration of non-sorted unique element and homogeneous
// lists accepting primitives types and complex user structs as well.
// This part of package contains the core behaviour
package collection
import (
"reflect"
"github.com/j... | collection/collection.go | 0.819965 | 0.650883 | collection.go | starcoder |
package main
import (
"bufio"
"encoding/binary"
"flag"
"fmt"
"github.com/RedisAI/redisai-go/redisai/implementations"
"github.com/cheggaaa/pb/v3"
"image"
"image/jpeg"
"io"
"io/ioutil"
"log"
"math"
"os"
"strconv"
)
// Program option vars:
var (
inputDir string
outputFileName string
batchSize ... | cmd/aibench_generate_data_vision/aibench_generate_data_vision.go | 0.623835 | 0.432243 | aibench_generate_data_vision.go | starcoder |
package checks
import (
model "github.com/DataDog/agent-payload/v5/process"
)
// payloadList is an abstract list of payloads subject to chunking
type payloadList interface {
// Len returns the length of the list
Len() int
// WeightAt returns weight for the payload at position `idx` in the list
WeightAt(idx int)... | pkg/process/checks/chunking.go | 0.71423 | 0.461927 | chunking.go | starcoder |
package table
import (
"errors"
"fmt"
"strings"
"unicode"
)
// Options represents the options that can be set when creating a new table
type Options struct {
Data [][]string
}
// New returns a table by the given options
func New(o Options) *Table {
// Init vars
t := Table{
data: o.Data,
}
return &t
}
// ... | table/table.go | 0.68763 | 0.412116 | table.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.