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 zgraph
import (
"errors"
"image"
"image/color"
"math"
)
// ColorChannel is used to distinguish color channel (RGBA) for ZGraph functions
type ColorChannel int
const (
// ChannelR the Red channel of the pixel
ChannelR ColorChannel = 0
// ChannelG the Green channel of the pixel
ChannelG ColorChannel = ... | zgraph/zgraph.go | 0.774498 | 0.658596 | zgraph.go | starcoder |
package sql
import (
"fmt"
"golang.org/x/net/context"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/pkg/errors"
)
// collectSpans collects the upper bound set of read and write spans that the
// planNode expects to touch when executed. The two sets do not need to be
// disjoint, and any span in th... | pkg/sql/plan_spans.go | 0.729712 | 0.425187 | plan_spans.go | starcoder |
package simpletime
import "time"
// Range is a simple tuple of earliest and latest time
type Range struct {
Start time.Time
End time.Time
}
// Duration returns the duration between start and end of the range
func (r Range) Duration() time.Duration {
return r.End.Sub(r.Start)
}
// Combine returns a Range which ... | time/range.go | 0.901105 | 0.665336 | range.go | starcoder |
package brotli
import "encoding/binary"
/* Copyright 2016 Google Inc. All Rights Reserved.
Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
func (*h10) HashTypeLength() uint {
return 4
}
func (*h10) StoreLookahead() uint {
return 128
}
func hashB... | vendor/github.com/andybalholm/brotli/h10.go | 0.721841 | 0.447762 | h10.go | starcoder |
package parametric2d
import (
"math"
"github.com/gmlewis/go-poly2tri"
"github.com/gmlewis/go3d/float64/vec2"
"github.com/gmlewis/go3d/float64/vec3"
)
// Line represents a straight line segment and implements interface T.
type Line struct {
p0, p1 vec2.T
bbox vec2.Rect
}
// NewLine returns a new 2D Line from... | line2d.go | 0.885409 | 0.714591 | line2d.go | starcoder |
package polynomial
import (
"math"
)
// Sum obtains a Polynomial representing the sum of the caller and other Polynomial
func (p Polynomial) Sum(other Polynomial) Polynomial {
m := make(map[uint]float64)
grade := max(p.grade, other.grade)
for i := uint(0); i <= grade; i++ {
sum := p.coefficients[i] + other.co... | polynomial/operations.go | 0.843348 | 0.710679 | operations.go | starcoder |
package beta
import (
"bytes"
"fmt"
"math"
)
// BetaDistribution :
// http://en.wikipedia.org/wiki/Beta_distribution
// alpha shape parameter (alpha > 0)
// beta shape parameter (beta > 0)
type BetaDistribution struct {
alpha float64
beta float64
isValid bool
firstMoment float64
second... | beta/betaDist.go | 0.779783 | 0.576661 | betaDist.go | starcoder |
Package debug transforms Kubernetes pod-bearing resources so as to configure containers
for remote debugging as suited for a container's runtime technology. This package defines
a _container transformer_ interface. Each transformer implementation should do the following:
1. The transformer should modify the container... | pkg/skaffold/debug/transform.go | 0.843734 | 0.600393 | transform.go | starcoder |
package gedcom
import (
"io/ioutil"
"strconv"
"strings"
)
// Tree contains a node structure of a GEDCOM file.
type Tree struct {
Nodes []*Node
Families []*Family
Individuals []*Individual
}
// ParseFromFile loads a file into memory and parses it to a Tree.
func ParseFromFile(file string) (*Tree, error... | tree.go | 0.613931 | 0.410697 | tree.go | starcoder |
package intersect
import "reflect"
func Interface(x interface{}, y interface{}) reflect.Value {
xValue, yValue := reflect.Value{}, reflect.Value{}
if xValueNode, ok := x.(reflect.Value); ok {
xValue = xValueNode
} else {
xValue = reflect.ValueOf(x)
}
if yValueNode, ok := y.(reflect.Value); ok {
yValue = yV... | helper/intersect/intersect.go | 0.577972 | 0.428233 | intersect.go | starcoder |
package graph
import (
"bytes"
"fmt"
"io"
)
// WeightGraph is a graph with weighted edges.
type WeightGraph struct {
adj [][]Edge
e int
}
// NewWeightGraph creates an empty graph with v vertices
func NewWeightGraph(v int) WeightGraph {
return WeightGraph{
adj: make([][]Edge, v),
e: 0,
}
}
// ReadWeig... | weightgraph.go | 0.837321 | 0.579757 | weightgraph.go | starcoder |
package geobuf_raw
import (
"github.com/paulmach/go.geojson"
)
// BoundingBox implementation as per https://tools.ietf.org/html/rfc7946
// BoundingBox syntax: "bbox": [west, south, east, north]
// BoundingBox defaults "bbox": [-180.0, -90.0, 180.0, 90.0]
func BoundingBox_Points(pts [][]float64) []float64 {
// setti... | geobuf_raw/bb.go | 0.822011 | 0.518302 | bb.go | starcoder |
package util
import (
"container/list"
"fmt"
"strings"
)
// Tree definition
type Tree struct {
Root *Node
}
// Depth the largest depth of the node
func (t *Tree) Depth() int {
var d int
t.BFS(func(n *Node) {
dep := n.Depth()
if dep > d {
d = dep
}
})
return d
}
// Height is the length of the longes... | tree.go | 0.655115 | 0.582847 | tree.go | starcoder |
package turfgo
import (
"math"
)
// Along takes a line and returns a point at a specified distance along the line.
// Returns the last point if distance is more than the span of the line.
func Along(lineString *LineString, distance float64, unit Unit) *Point {
travelled := float64(0)
points := lineString.getPoints... | measurement.go | 0.921565 | 0.746255 | measurement.go | starcoder |
package metrics
import (
"fmt"
"math"
"strconv"
"strings"
"time"
"github.com/codahale/hdrhistogram"
)
type HistogramOptions struct {
Name string
Buckets []float64
MaxDuration time.Duration
}
type Histogram struct {
name string
buckets []float64
// this is the max number of values to store... | metrics/histogram.go | 0.703753 | 0.612599 | histogram.go | starcoder |
package graphics
import "github.com/inkyblackness/hacked/ui/opengl"
// BitmapTexture wraps an OpenGL handle for a downloaded image.
type BitmapTexture struct {
gl opengl.OpenGL
handle uint32
width, height float32
u, v float32
pixelData []byte
}
func powerOfTwo(value int) int {
result := 2
for ... | editor/graphics/BitmapTexture.go | 0.867976 | 0.584775 | BitmapTexture.go | starcoder |
package dpsortint
const insertionSortThreshold = 27
func dataequal(data []int, i, k int) bool { return !(dataless(data, i, k) || dataless(data, k, i)) }
func dataless(data []int, i, k int) bool { return data[i] < data[k] }
func dataswap(data []int, i, k int) { data[i], data[k] = data[k], data[i] }
func inser... | sorts/dpsortint/sort.go | 0.582016 | 0.513851 | sort.go | starcoder |
package gosql
import (
"fmt"
"strings"
)
// Builder represents SQL query builder.
type Builder interface {
// Dialect returns SQL dialect.
Dialect() Dialect
// Select creates a new select query.
Select(table string) SelectQuery
// Update creates a new update query.
Update(table string) UpdateQuery
// Delete ... | builder.go | 0.837985 | 0.419232 | builder.go | starcoder |
package mongo
// Format represents the currency's currencyFormat.
type currencyFormat struct {
code string // The ISO 4217 currency code.
subunits int // The number of subunits.
thouSep string // The thousand separator.
subSep string // The subunit separator.
template string // The string format templat... | format.go | 0.529507 | 0.59302 | format.go | starcoder |
package shape
import "github.com/mokiat/gomath/sprec"
type Intersection struct {
Depth float32
FirstContact sprec.Vec3
FirstDisplaceNormal sprec.Vec3
SecondContact sprec.Vec3
SecondDisplaceNormal sprec.Vec3
}
func (i Intersection) Flipped() Intersection {
i.FirstContact, i.Second... | shape/intersection.go | 0.566978 | 0.407157 | intersection.go | starcoder |
package sequences
import . "github.com/objecthub/containerkit"
type Sequence interface {
SequenceBase
SequenceDerived
}
type SequenceBase interface {
IndexedBase
}
type SequenceDerived interface {
IndexedDerived
Container
Subsequence(start int, maxSize int) DependentSequence
MapValues(f Mapping) Dep... | sequences/sequence.go | 0.879949 | 0.406626 | sequence.go | starcoder |
package testcase
import (
"bytes"
"fmt"
"path/filepath"
"reflect"
"runtime"
"sort"
"testing"
"unsafe"
)
// TestCase represents a test case.
type TestCase struct {
tc testCase
}
// Copy copies the test case and returns a clone.
func (tc *TestCase) Copy() (clone *TestCase) { return tc.tc.Copy().TestCase() }
... | testcase.go | 0.655667 | 0.501038 | testcase.go | starcoder |
package data
type (
// List represents a singly-linked List
List interface {
list() // marker
Sequence
Indexed
Counted
Prepend(Value) Sequence
Reverse() Sequence
}
list struct {
first Value
rest List
count int
}
)
// NewList creates a new List instance
func NewList(v ...Value) List {
var res... | data/list.go | 0.825555 | 0.495789 | list.go | starcoder |
package clac
import (
"github.com/kpmy/ypk/halt"
)
func b_(fn func(Value, Value) bool) func(Value, Value) Value {
return func(l Value, r Value) (ret Value) {
ret = Value{T: BOOLEAN}
ret.V = fn(l, r)
return
}
}
func b_i_(fn func(int64, Value) bool) func(Value, Value) bool {
return func(l Value, r Value) boo... | fn.go | 0.580114 | 0.607343 | fn.go | starcoder |
package typ
// Compare checks if either value is greater or equal to the other.
// The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
func Compare[T Ordered](a, b T) int {
if a > b {
return 1
}
if a < b {
return -1
}
return 0
}
// Less returns true if the first argument is less than the second.
f... | util.go | 0.754282 | 0.620291 | util.go | starcoder |
// Package geo contains the base types for spatial data type operations.
package geo
import (
"encoding/binary"
"encoding/hex"
"strings"
"github.com/cockroachdb/cockroach/pkg/geo/geopb"
"github.com/golang/geo/s2"
"github.com/twpayne/go-geom"
"github.com/twpayne/go-geom/encoding/ewkb"
)
var ewkbEncodingFormat... | pkg/geo/geo.go | 0.725454 | 0.474753 | geo.go | starcoder |
package projecteuler
import (
"fmt"
"math/big"
)
// BigIntMatrix struct
type BigIntMatrix struct {
m [][]*big.Int
}
// Dim returns length of the BigIntMatrix
func (a *BigIntMatrix) Dim() (x, y int) {
return len(a.m[0]), len(a.m)
}
// At returns element at (y,x)
func (a *BigIntMatrix) At(y, x int) (result *big.I... | bigIntMatrix.go | 0.737253 | 0.48987 | bigIntMatrix.go | starcoder |
package objprop
const (
// CommonPropertiesLength specifies the length a common properties structure has.
CommonPropertiesLength = uint32(27)
)
// StandardProperties returns an array of class descriptors that represent the standard
// configuration of the existing file
func StandardProperties() []ClassDescriptor {
... | objprop/Constants.go | 0.68342 | 0.506652 | Constants.go | starcoder |
package logic
import (
"fmt"
"image/color"
"math"
"strings"
"time"
"janrobas/spacefetcher/constants"
graphics "janrobas/spacefetcher/graphics"
"janrobas/spacefetcher/models"
"github.com/hajimehoshi/ebiten"
)
func initialize(state *models.GameState) {
state.GameRunning = false
state.Countdown = 3
state.... | logic/gamelogic.go | 0.663778 | 0.425546 | gamelogic.go | starcoder |
package main
// Only the plain math package is needed for the formulas.
import (
"fmt"
"math"
)
// The lengths of the two segments of the robot’s arm. Using the same length for both segments allows the robot to reach the (0,0) coordinate.
const (
len1 = 100.0
len2 = 100.0
)
// The law of cosines, transfomred s... | Tests/ScaraSingleArmCalcs/ScaraSingleArmCalcs.go | 0.817502 | 0.762667 | ScaraSingleArmCalcs.go | starcoder |
package sdkv2provider
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourcePingAccessPingFederateRuntimeMetadata() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourcePingAccessPingFederateRuntimeMeta... | internal/sdkv2provider/data_source_pingaccess_pingfederate_runtime_metadata.go | 0.67854 | 0.440951 | data_source_pingaccess_pingfederate_runtime_metadata.go | starcoder |
package engine
import "math"
// DefaultEvaluableFunctors is a EvaluableFunctors with builtin functions.
var DefaultEvaluableFunctors = EvaluableFunctors{
Constant: map[Atom]Number{
`pi`: Float(math.Pi),
},
Unary: map[Atom]func(Number) (Number, error){
`-`: Neg,
`abs`: Ab... | engine/number.go | 0.636805 | 0.671471 | number.go | starcoder |
package qwak
import (
"encoding/json"
"errors"
"fmt"
"github.com/qwak-ai/go-sdk/qwak/http"
)
// PredictionRequest represents a fluent API to build a prediction request on your model
type PredictionRequest struct {
modelId string
featuresVector []*FeatureVector
}
// NewPredictionRequest is a constructor... | qwak/request.go | 0.765769 | 0.524943 | request.go | starcoder |
package logf
import (
"strconv"
)
// PageSize is the recommended buffer size.
const (
PageSize = 4 * 1024
)
// NewBuffer creates the new instance of Buffer with default capacity.
func NewBuffer() *Buffer {
return NewBufferWithCapacity(PageSize)
}
// NewBufferWithCapacity creates the new instance of Buffer with t... | buffer.go | 0.814643 | 0.42662 | buffer.go | starcoder |
package schema
import (
"errors"
"fmt"
"unicode"
)
type DataType string
const (
// DataTypeCRef The data type is a cross-reference, it is starting with a capital letter
DataTypeCRef DataType = "cref"
// DataTypeString The data type is a value of type string
DataTypeString DataType = "string"
// DataTypeInt T... | database/schema/data_types.go | 0.638385 | 0.620219 | data_types.go | starcoder |
package main
import (
"math"
"sort"
)
/**
A block is defined by 6 planes. Each plane is defined by a normal to the plane with an origin
at the center of the coordinate system (0, 0, 0) and a scalar k along that normal where the
plane exists.
So, for a single plane if we have a normal (xn, yn, zn) and a value k, t... | cmd/weekend/block.go | 0.84556 | 0.666918 | block.go | starcoder |
package data
import (
"fmt"
)
// treeMap is a map whose key is a data id and the value is the list of data id.
// This map is used to map the children data to their parents (the key is a
// parent data id and the value is the list of ID of its children)
type treeMap map[TaskID]TaskIDArray
// addChild adds a child i... | src/todogo/data/tree.go | 0.573559 | 0.54256 | tree.go | starcoder |
package light
import (
"unsafe"
"github.com/leapar/engine/core"
"github.com/leapar/engine/gls"
"github.com/leapar/engine/math32"
)
// Spot represents a spotlight
type Spot struct {
core.Node // Embedded node
color math32.Color // Light color
intensity float32 // Light intensity
uni ... | light/spot.go | 0.853333 | 0.481576 | spot.go | starcoder |
package orb
// Geometry is an interface that represents the shared attributes
// of a geometry.
type Geometry interface {
GeoJSONType() string
Dimensions() int // e.g. 0d, 1d, 2d
Bound() Bound
GCJ02ToWGS84()
BD09ToWGS84()
WGS84ToGCJ02()
WGS84ToBD09()
// requiring because sub package type switch over all poss... | geometry.go | 0.868367 | 0.435001 | geometry.go | starcoder |
package filters
import (
"math"
"github.com/bspaans/bleep/audio"
)
// Cutoff frequency = Alpha / ((1 - Alpha) * 2 * Pi * dt
// Alpha = 2Pi * dt * Cutoff / (2Pi * dt * Cutoff + 1)
type LowPassFilter struct {
Cutoff float64
PreviousLeft float64
PreviousRight float64
}
func NewLowPassFilter(cutoff float64... | filters/lpf.go | 0.72027 | 0.426142 | lpf.go | starcoder |
package xrand
var (
letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
digits = []rune("0123456789")
)
// Meet randomly calculate whether the given probability <num>/<total> is met.
func Meet(num, total int) bool {
return Intn(total) < num
}
// MeetProb randomly calculate whether ... | utils/xrand/xrand.go | 0.733165 | 0.426322 | xrand.go | starcoder |
package yqlib
import (
"bytes"
"container/list"
"fmt"
"strconv"
"strings"
logging "gopkg.in/op/go-logging.v1"
yaml "gopkg.in/yaml.v3"
)
type xmlPreferences struct {
AttributePrefix string
ContentName string
}
var log = logging.MustGetLogger("yq-lib")
// GetLogger returns the yq logger instance.
func G... | pkg/yqlib/lib.go | 0.50293 | 0.52902 | lib.go | starcoder |
package plan
import (
"github.com/dolthub/go-mysql-server/sql"
)
// Visitor visits nodes in the plan.
type Visitor interface {
// Visit method is invoked for each node encountered by Walk.
// If the result Visitor is not nil, Walk visits each of the children
// of the node with that visitor, followed by a call o... | sql/plan/walk.go | 0.694095 | 0.532729 | walk.go | starcoder |
package shape
import (
"fmt"
"math"
"strings"
"github.com/fogleman/gg"
"github.com/golang/freetype/raster"
)
const LineMutate = 4 // 5 for line width
type Line struct {
X1, Y1 float64
X2, Y2 float64
Width float64
MaxLineWidth float64
}
func NewLine() *Line {
l := &Line{}
l.MaxLineWidt... | primitive/shape/line.go | 0.564819 | 0.424472 | line.go | starcoder |
package goglbackend
import (
"github.com/gsvigruha/canvas/backend/backendbase"
"github.com/gsvigruha/canvas/backend/goglbackend/gl"
)
// LinearGradient is a gradient with any number of
// stops and any number of colors. The gradient will
// be drawn such that each point on the gradient
// will correspond to a strai... | backend/goglbackend/gradients.go | 0.761716 | 0.421492 | gradients.go | starcoder |
package knapsack
import (
"crypto/rand"
"crypto/sha256"
"errors"
"math/big"
)
// Knapsack contains the private data used to generate the public key and decrypt messages
type Knapsack struct {
PublicKey []*big.Int
PrivateKey []*big.Int
M *big.Int // modulus
W *big.Int // random mutating cons... | crypto.go | 0.762513 | 0.420719 | crypto.go | starcoder |
package types
// Reference: https://www.ietf.org/rfc/rfc4120.txt
// Section: 5.2.7
import (
"fmt"
"time"
"github.com/jcmturner/gofork/encoding/asn1"
"github.com/wangzhengzh/gokrb5/v8/iana/patype"
)
// PAData implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7
type PAData struct {
PAData... | v8/types/PAData.go | 0.774583 | 0.437103 | PAData.go | starcoder |
package graphic
import (
"github.com/lquesada/cavernal/lib/g3n/engine/core"
"github.com/lquesada/cavernal/lib/g3n/engine/geometry"
"github.com/lquesada/cavernal/lib/g3n/engine/gls"
"github.com/lquesada/cavernal/lib/g3n/engine/material"
"github.com/lquesada/cavernal/lib/g3n/engine/math32"
)
// Sprite is a potent... | lib/g3n/engine/graphic/sprite.go | 0.774157 | 0.506103 | sprite.go | starcoder |
package gohome
type RenderType uint16
// The different render types.
// Determines which projection, back buffer, camera etc. will be used for the RenderObject
const (
TYPE_3D_NORMAL RenderType = (1 << 1)
TYPE_2D_NORMAL RenderType = (1 << 2)
TYPE_3D_INSTANCED RenderType = (1 << 3)
TYPE_2D_INSTANCED Rend... | src/gohome/renderobject.go | 0.75985 | 0.425784 | renderobject.go | starcoder |
// Design your implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly linked list should have two attributes: val and next. val is the value of the current node, and next is a pointer/reference to the next node. If you want to use the doubly linked... | 0707/code.go | 0.697609 | 0.618032 | code.go | starcoder |
package filter
import "github.com/nerdynick/ccloud-go-sdk/telemetry/labels"
const (
//OpAnd is a static def for AND Operand
OpAnd string = "AND"
//OpOr is a static def for OR Operand
OpOr string = "OR"
)
// CompoundFilter to use for a query
type CompoundFilter struct {
Op string `json:"op"`
Filters []Fi... | telemetry/query/filter/compound.go | 0.790166 | 0.451931 | compound.go | starcoder |
package main
import (
"fmt"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
var scaleStaticBody, ballBody *Body
func main() {
space := NewSpace()
space.Iterations = 30
space.SetGravity(Vector{0, -300})
space.SetCollisionSlop(0.5)
space.SleepTimeThreshold = 1
var body *Body
var shape ... | examples/contactgraph/contactgraph.go | 0.70069 | 0.519704 | contactgraph.go | starcoder |
package utm
import (
"fmt"
"strconv"
"unicode"
)
// Zone specifies the zone number and hemisphere
type Zone struct {
Number int // Zone number 1 to 60
Letter rune // Zone letter C to X (omitting O, I)
North bool // Zone hemisphere
}
// String returns a text representation of the zone
func (z Zone) String() s... | zone.go | 0.782372 | 0.415551 | zone.go | starcoder |
package output
import (
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/x/docs"
)
//------------------------------------------------------------------... | lib/output/redis_hash.go | 0.749912 | 0.762159 | redis_hash.go | starcoder |
package util
import (
"bytes"
"crypto/rand"
"errors"
"math/big"
"strings"
)
// OptionalBool a boolean that can be "null"
type OptionalBool byte
const (
// OptionalBoolNone a "null" boolean value
OptionalBoolNone = iota
// OptionalBoolTrue a "true" boolean value
OptionalBoolTrue
// OptionalBoolFalse a "fal... | modules/util/util.go | 0.767429 | 0.4831 | util.go | starcoder |
package radius
import (
"github.com/dayaftereh/stargen/stargen/constants"
"github.com/dayaftereh/stargen/types"
)
func gasRadius4point5Gyr1960K0coreMass(planet *types.Planet) float64 {
totalEarthMasses := planet.Mass * constants.SunMassInEarthMasses
var jupiterRadii float64
if totalEarthMasses < 28.0 {
//jupi... | stargen/radius/gas-5-gyr-radius.go.go | 0.630912 | 0.563558 | gas-5-gyr-radius.go.go | starcoder |
package geometry
// Rect ...
type Rect struct {
Min, Max Point
}
// Move ...
func (rect Rect) Move(deltaX, deltaY float64) Rect {
return Rect{
Min: Point{X: rect.Min.X + deltaX, Y: rect.Min.Y + deltaY},
Max: Point{X: rect.Max.X + deltaX, Y: rect.Max.Y + deltaY},
}
}
// Index ...
func (rect Rect) Index() inte... | vendor/github.com/tidwall/geojson/geometry/rect.go | 0.835383 | 0.617599 | rect.go | starcoder |
package types
import (
"io"
"github.com/lyraproj/pcore/px"
)
type (
IteratorType struct {
typ px.Type
}
)
var iteratorTypeDefault = &IteratorType{typ: DefaultAnyType()}
var IteratorMetaType px.ObjectType
func init() {
IteratorMetaType = newObjectType(`Pcore::IteratorType`,
`Pcore::AnyType {
attributes... | types/iteratortype.go | 0.734786 | 0.433622 | iteratortype.go | starcoder |
package postscript
import ()
//int array array -> Create array of length int
func array(interpreter *Interpreter) {
interpreter.Push(make([]Value, interpreter.PopInt()))
}
//array length int -> Return number of elements in array
func lengtharray(interpreter *Interpreter) {
interpreter.Push(float64(len(interpreter... | postscript/operators_array.go | 0.54819 | 0.400105 | operators_array.go | starcoder |
package jubjub
import (
"math/big"
"math/bits"
)
// FieldElement is an element of an arbitrary integer field.
type FieldElement struct {
n *big.Int
fieldOrder *big.Int
}
// newFieldElement returns a new element of the curve's base field initialized to the value of `n`.
func (curve *Jubjub) newFieldEleme... | field_element.go | 0.864739 | 0.504822 | field_element.go | starcoder |
package timeseries
import (
"fmt"
"os"
"strconv"
"text/tabwriter"
"time"
)
// a DataUnit is the smallest unity of communication. The DataUnit is supposed to be transferred through any context,
// internet amongst others. It is supposed to be informative enough to live on its own, a bit like a packet in TCP/IP pr... | timeseries/dataunit.go | 0.551332 | 0.526891 | dataunit.go | starcoder |
package util
import (
"encoding/binary"
)
// BinaryReader reads primitive data types as binary values.
type BinaryReader struct {
buffer []byte
pos int
}
// NewBinaryReader returns a new instance of the BinaryReader class based on the specified byte array.
func NewBinaryReader(packet []byte) *BinaryReader {
r... | util/reader.go | 0.832032 | 0.48121 | reader.go | starcoder |
package sv
import "github.com/rannoch/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "y-MM-dd"},
Time: cldr.CalendarDateFormat{Full: "'kl'. HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:... | resources/locales/sv/calendar.go | 0.520984 | 0.455138 | calendar.go | starcoder |
package course
import (
"sort"
"strconv"
"github.com/pkg/errors"
)
type TaskType uint8
const (
ManualCheckingType TaskType = iota + 1
AutoCodeCheckingType
TestingType
)
func (t TaskType) String() string {
switch t {
case ManualCheckingType:
return "manual checking"
case AutoCodeCheckingType:
return "a... | internal/domain/course/task.go | 0.527803 | 0.479138 | task.go | starcoder |
package num
import (
"github.com/cpmech/gosl/fun"
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/plt"
"github.com/cpmech/gosl/utl"
)
// LineSolver finds the scalar λ that zeroes or minimizes f(x+λ⋅n)
type LineSolver struct {
// configuration
UseDeriv bool // use Jacobian func... | num/linesolver.go | 0.732783 | 0.512449 | linesolver.go | starcoder |
package onedb
import (
"net"
"reflect"
"time"
"github.com/pkg/errors"
)
// QueryValues runs a query against the provided Backender and populates result values
func QueryValues(backend Backender, query *Query, result ...interface{}) error {
if query == nil {
return ErrQueryIsNil
}
row := backend.QueryRow(que... | onedb.go | 0.754825 | 0.435841 | onedb.go | starcoder |
package show
import (
"fmt"
"path/filepath"
"strings"
"github.com/oakmound/oak/v3/render/mod"
"github.com/oakmound/oak/v3/render"
)
var (
width, height float64
)
// SetDims for the whole presentation global
func SetDims(w, h float64) {
width = w
height = h
}
var (
titleFont *render.Font
)
// SetTitleFon... | examples/slide/show/helpers.go | 0.668447 | 0.512815 | helpers.go | starcoder |
package main
import (
"math"
"math/rand"
"github.com/faiface/beep"
)
var noise = beep.StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
for i := range samples {
samples[i][0] = rand.Float64()*2 - 1
samples[i][1] = rand.Float64()*2 - 1
}
return len(samples), true
})
func wave(sr beep.SampleRate, w... | synth.go | 0.599837 | 0.632701 | synth.go | starcoder |
package clock
import (
"encoding/xml"
"fmt"
"io"
"math"
"time"
)
const (
secondsInHalfClock = 30
secondsInClock = 2 * secondsInHalfClock
minutesInHalfClock = 30
minutesInClock = 2 * minutesInHalfClock
hoursInHalfClock = 6
hoursInClock = 2 * hoursInHalfClock
secondHandLength = 90.0
minute... | basics/clock/clock.go | 0.764276 | 0.403567 | clock.go | starcoder |
package utils
import (
"fmt"
"reflect"
"strings"
"time"
"cloud.google.com/go/spanner"
)
func GetTableName(model interface{}) string {
results := reflect.Indirect(reflect.ValueOf(model))
if reflect.TypeOf(model).Kind() == reflect.String {
return model.(string)
}
if kind := results.Kind(); kind == reflect... | utils/utils.go | 0.52683 | 0.44083 | utils.go | starcoder |
package utils
import (
"time"
)
type ti int
const Time ti = iota
const ymd = "2006-01-02"
const hms = "15:04:05"
const full = "2006-01-02 15:04:05"
const year = 1
const month = 2
const day = 3
const hour = 4
const minute = 5
const second = 6
type date struct {
err error
time time.Time
}
type tickerInfo struc... | time.go | 0.547464 | 0.449997 | time.go | starcoder |
package chart
import (
"fmt"
"strconv"
"time"
)
// ValueFormatter is a function that takes a value and produces a string.
type ValueFormatter func(v interface{}) string
// TimeValueFormatter is a ValueFormatter for timestamps.
func TimeValueFormatter(v interface{}) string {
return formatTime(v, DefaultDateFormat... | vendor/github.com/wcharczuk/go-chart/v2/value_formatter.go | 0.82425 | 0.526099 | value_formatter.go | starcoder |
package sql
// A Visitor's Visit method is invoked for each node encountered by Walk.
// If the result visitor w is not nil, Walk visits each of the children
// of node with the visitor w, followed by a call of w.Visit(nil).
type Visitor interface {
Visit(node Node) (w Visitor, err error)
VisitEnd(node Node) error
}... | walk.go | 0.689619 | 0.450541 | walk.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
)
// BitArrayFromBoolSlice returns a driver.Valuer that produces a PostgreSQL bit[] from the given Go []bool.
func BitArrayFromBoolSlice(val []bool) driver.Valuer {
return bitArrayFromBoolSlice{val: val}
}
// BitArrayToBoolSlice returns an sql.Scanner th... | pgsql/bitarr.go | 0.67104 | 0.402803 | bitarr.go | starcoder |
package multipleconversions
import (
"math"
"strconv"
"strings"
)
// RPN returns the result of an expression using reverse polish notation (postfix) by exploding the string
// to a slice and editing the slice by replacing each op by its result until only a number is left or
// failing if the expression is invalid.... | multipleconversions/multipleconversions.go | 0.631822 | 0.511961 | multipleconversions.go | starcoder |
package math
import "math"
type Vector2 struct {
X float64
Y float64
}
func (v *Vector2) GetWidth() float64 {
return v.X
}
func (v *Vector2) SetWidth( width float64 ) {
v.X = width
}
func (v *Vector2) GetHeight() float64 {
return v.Y
}
func (v *Vector2) SetHeight( height float64 ) {
v.Y = height
}
func (v ... | math/vector2.go | 0.899423 | 0.767733 | vector2.go | starcoder |
package spdg
import (
"bytes"
"context"
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
)
/*
Layer is the lowest level of the core SPDG model. It takes in byte buffers
which are commonly known as the "last known datatype" in the SPDG model.
That means it is the only other datatype next to SPDGs themselves that
can tr... | layer.go | 0.568416 | 0.604136 | layer.go | starcoder |
package gmtls
type certificateRequestMsgGM struct {
raw []byte
// hasSignatureAlgorithm indicates whether this message includes a list of
// supported signature algorithms. This change was introduced with TLS 1.2.
hasSignatureAlgorithm bool
supportedSignatureAlgorithms []SignatureScheme
certificateTypes ... | gmtls/gm_handshake_messages.go | 0.572723 | 0.415373 | gm_handshake_messages.go | starcoder |
Marching Squares
Convert an SDF2 boundary to a set of line segments.
*/
//-----------------------------------------------------------------------------
package sdf
//-----------------------------------------------------------------------------
// lineCache is a cache of SDF2 evaluations samples over a 2d line.
ty... | sdf/march2.go | 0.7181 | 0.547343 | march2.go | starcoder |
package asm
func (o Opcodes) Aad(ops ...Operand) { o.a.op("AAD", ops...) }
func (o Opcodes) AAD(ops ...Operand) { o.a.op("AAD", ops...) }
func (o Opcodes) Aam(ops ...Operand) { o.a.op("AAM", ops...) }
func (o Opcodes) AAM(ops ...Operand) { o.a.op("AAM", ops...) }
fu... | vendor/github.com/tmthrgd/asm/opcode.go | 0.548432 | 0.503662 | opcode.go | starcoder |
package timeseries
import (
"encoding/csv"
"io"
"math"
"strconv"
"strings"
"time"
)
// TODO: create a new type for map[string]Data.
type Datum struct {
Date time.Time
Value float64
}
// Data holds timeseries data.
type Data struct {
Name string
Data []Datum
}
func (h Data) String() string {
return h.Na... | timeseries/timeseries.go | 0.583441 | 0.437283 | timeseries.go | starcoder |
package impl
import (
"errors"
"github.com/xichen2020/eventdb/document/field"
"github.com/xichen2020/eventdb/filter"
"github.com/xichen2020/eventdb/values"
"github.com/xichen2020/eventdb/values/iterator"
iterimpl "github.com/xichen2020/eventdb/values/iterator/impl"
"github.com/xichen2020/eventdb/x/pool"
)
var... | values/impl/array_based_bool_values.go | 0.543348 | 0.411377 | array_based_bool_values.go | starcoder |
package bitfield
import (
"math/bits"
)
var _ = Bitfield(Bitvector32{})
// Bitvector32 is a bitfield with a fixed defined size of 32. There is no length bit
// present in the underlying byte array.
type Bitvector32 []byte
const bitvector32ByteSize = 4
const bitvector32BitSize = bitvector32ByteSize * 8
// NewBitve... | bitvector32.go | 0.776453 | 0.436262 | bitvector32.go | starcoder |
package main
import (
"fmt"
"math"
"math/rand"
"sort"
"time"
)
// point is a k-dimensional point.
type point []float64
// sqd returns the square of the euclidean distance.
func (p point) sqd(q point) float64 {
var sum float64
for dim, pCoord := range p {
d := pCoord - q[dim]
sum += d * d
}
return sum
}
... | tasks/K-d-tree/k-d-tree.go | 0.781414 | 0.594581 | k-d-tree.go | starcoder |
package three
import (
"fmt"
"image"
"image/color"
"image/png"
"os"
"strconv"
"strings"
)
func FindDistanceToCross(wireOne, wireTwo string) int {
wOne := PointsFromString(wireOne)
wTwo := PointsFromString(wireTwo)
crossPoints := FindCrossPointsV2(wOne, wTwo)
shortestDist := -1
for _, d := range crossPoint... | nbutton/three/crossed_wires.go | 0.591487 | 0.55652 | crossed_wires.go | starcoder |
package sirpent
import (
"fmt"
"log"
)
type DirectionError struct {
DirectionValue Direction
}
func (e DirectionError) Error() string {
return fmt.Sprintf("Direction '%s' not found.", e.DirectionValue)
}
type Direction string
type Vector struct {
X int
Y int
}
func (v Vector) Eq(v2 Vector) bool {
return v... | src/grid.go | 0.783947 | 0.455804 | grid.go | starcoder |
package raft
import (
"fmt"
pb "github.com/coreos/etcd/raft/raftpb"
)
// nextEnts returns the appliable entries and updates the applied index
func nextEnts(r *raft, s *MemoryStorage) (ents []pb.Entry) {
// Transfer all unstable entries to "stable" storage.
s.Append(r.raftLog.unstableEntries())
r.raftLog.stableT... | doc/etcd_go_fuzz/code/fuzz_raft_2.go | 0.528047 | 0.400105 | fuzz_raft_2.go | starcoder |
package expression
import (
"fmt"
"github.com/dolthub/go-mysql-server/sql"
)
// Literal represents a literal expression (string, number, bool, ...).
type Literal struct {
value interface{}
val2 sql.Value
fieldType sql.Type
}
var _ sql.Expression = &Literal{}
var _ sql.Expression2 = &Literal{}
// New... | sql/expression/literal.go | 0.786295 | 0.421969 | literal.go | starcoder |
package renderers
import (
"fmt"
"image/color"
"github.com/tdewolff/canvas"
"github.com/tdewolff/canvas/pdf"
"github.com/winkula/dragons/pkg/model"
)
var size = 5 // 5mm
var sizeFactor = float64(size)
var padding = 1 // 1mm
var gridLine = 0.05
var gridBorder = 0.3
var gridColor = canvas.Black
var symbolLine = 0... | pkg/renderers/pdf.go | 0.642545 | 0.406273 | pdf.go | starcoder |
package levenshtein2
import (
"fmt"
"math"
)
const SinkState = uint32(0)
type DFA struct {
transitions [][256]uint32
distances []Distance
initState int
ed uint8
}
/// Returns the initial state
func (d *DFA) initialState() int {
return d.initState
}
/// Returns the Levenshtein distance associat... | vendor/github.com/couchbase/vellum/levenshtein2/dfa.go | 0.783906 | 0.421671 | dfa.go | starcoder |
package std
import (
"github.com/mb0/xelf/cor"
"github.com/mb0/xelf/exp"
"github.com/mb0/xelf/lit"
"github.com/mb0/xelf/typ"
)
// failSpec returns an error, if c is an execution context it fails expression string as error,
// otherwise it uses ErrUnres. This is primarily useful for testing.
var failSpec = core.ad... | std/logic.go | 0.627495 | 0.412767 | logic.go | starcoder |
package funk
import (
"reflect"
)
type JoinFnc func(lx, rx reflect.Value) reflect.Value
// Join combines two collections using the given join method.
func Join(larr, rarr interface{}, fnc JoinFnc) interface{} {
if !IsCollection(larr) {
panic("First parameter must be a collection")
}
if !IsCollection(rarr) {
... | vendor/github.com/thoas/go-funk/join.go | 0.696062 | 0.412944 | join.go | starcoder |
package sphere
import (
"github.com/austingebauer/go-ray-tracer/material"
"github.com/austingebauer/go-ray-tracer/matrix"
"github.com/austingebauer/go-ray-tracer/point"
"github.com/austingebauer/go-ray-tracer/vector"
)
// Sphere is a sphere object with an origin and radius.
type Sphere struct {
Id string
... | sphere/sphere.go | 0.879134 | 0.465995 | sphere.go | starcoder |
package tally
// ITally is a counter of type int.
type ITally int
// Cur returns the current int value of this ITally.
func (t ITally) Cur() int {
return int(t)
}
// Add increases this counter by the given value, returning the previous
// int value of this ITally.
func (t *ITally) Add(i int) (cur int) {
cur = int(... | v1/tally/ints.go | 0.769687 | 0.490114 | ints.go | starcoder |
package hashfill
import (
"github.com/mmcloughlin/geohash"
"github.com/paulsmith/gogeos/geos"
geom "github.com/twpayne/go-geom"
)
// Container tests if a hash is contained.
type Container interface {
Contains(*geom.Polygon, string) (bool, error)
}
// Intersector tests if a hash intersects.
type Intersector inter... | predicates.go | 0.839734 | 0.476701 | predicates.go | starcoder |
package btree
import (
"encoding/binary"
"fmt"
)
/*
Node is the BTree logical implementation
order: btree order which is the same number of pointers
in the node and the number of keys plus one
cells: key pointer pairs ordered by the key value
*/
type Node struct {
nodeType
order int
cells ... | internal/backend/btree/node.go | 0.567817 | 0.477554 | node.go | starcoder |
package psinterpreter
import (
"errors"
"fmt"
)
// PathBounds represents a control bounds for
// a glyph outline (in font units).
type PathBounds struct {
Min, Max Point
}
// Enlarge enlarges the bounds to include pt
func (b *PathBounds) Enlarge(pt Point) {
if pt.X < b.Min.X {
b.Min.X = pt.X
}
if pt.X > b.Ma... | fonts/psinterpreter/charstrings.go | 0.732687 | 0.422803 | charstrings.go | starcoder |
package continuous
import (
gsl "github.com/jtejido/ggsl"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Rayleigh distribution
// https://en.wikipedia.org/wiki/Rayleigh_distribution
type Rayleigh struct {
scale float64 // σ
src rand.Source
}
func NewRayleigh(scale float64)... | dist/continuous/rayleigh.go | 0.837885 | 0.550607 | rayleigh.go | starcoder |
package solutions
import (
"reflect"
"pokman/bulbasaur/leetcode/ds"
)
func maxProfitIII(prices []int) int {
size := len(prices)
if size < 2 {
return 0
}
pre := make([]int, size)
min := prices[0]
for i := 1; i < len(prices); i++ {
if prices[i] < min {
min = prices[i]
}
pre[i] = ds.MaxInt(pre[i-1],... | solutions/0123.go | 0.614741 | 0.5144 | 0123.go | starcoder |
package maybe
import (
"fmt"
)
// Maybe is an minimal interface definition for the Just and Nothing types to share
type Maybe[T any] interface {
// Helper method to be used for the monadic functions and extracting values from the Maybe interface
Unwrap() (T, error)
}
// Just is a struct that contains a value of t... | pkg/struct/maybe/maybe.go | 0.556882 | 0.473596 | maybe.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.