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 search
import (
"github.com/ebay/beam/util/cmp"
)
// A Definition is the interface that users of this package need to define.
type Definition interface {
// ExplorationRules returns the set of exploration rules that the optimizer may
// apply in searching for a low-cost plan.
ExplorationRules() []Explora... | src/github.com/ebay/beam/query/planner/search/definition.go | 0.694303 | 0.625295 | definition.go | starcoder |
package gohome
import (
// "fmt"
"github.com/PucklaMotzer09/mathgl/mgl32"
)
const (
LOOK_DIRECTION_MAGNIFIER float32 = 100.0
)
// A 3D camera used to show different parts of the world
type Camera3D struct {
// It's position in world space
Position mgl32.Vec3
// The direction in which the ca... | src/gohome/camera3d.go | 0.687105 | 0.503357 | camera3d.go | starcoder |
package parser
type ControlFlowExpr interface {
Expr
isControlFlowExpr()
}
type controlFlowExpr struct {
expr
}
func (controlFlowExpr) isControlFlowExpr() {}
// Placeholder for comments at the end of file
type Noop struct {
Location
controlFlowExpr
Value *Token
}
func (noop *Noop) String() string {
return... | parser/control_flow_expr.go | 0.761184 | 0.486392 | control_flow_expr.go | starcoder |
package controller
type DecodeUnit struct {
InstructionMap
instructionCode string
instructionType1 string
instructionType2 string
instructionName string
instructionFormat map[string]string
opcode string
gapAddress bool
}
func NewDecodeUnit() *DecodeUnit {
decodeunit := new(DecodeUnit... | controller/decodeunit.go | 0.636692 | 0.530845 | decodeunit.go | starcoder |
package types
// TrafficAccidents holds the data for the traffic accidents.
type TrafficAccidents struct {
Year int `json:"year" fake:"{year}"`
DeadlyAccidents int `json:"deadly_accidents" fake:"{number:0,100}"`
Deaths int `json:"deaths" fake:"{number:0,100}"`
Jurisdiction strin... | types/crime_justice.go | 0.57081 | 0.533154 | crime_justice.go | starcoder |
package script
import (
"fmt"
"math"
"strconv"
"time"
"unsafe"
)
const (
ValueTypeInterface uint16 = iota // must be zero here
ValueTypeBool
ValueTypeInt
ValueTypeFloat
)
type pointer = unsafe.Pointer
type Value struct {
pointer *interface{}
}
func (value *Value) GetType() uint16 {
return uint16(*(*uint... | value.go | 0.559531 | 0.420897 | value.go | starcoder |
package binarysearch
/*
# https://leetcode.com/explore/learn/card/binary-search/138/background/1038/
Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists, then return its index, otherwise return -1.
Example 1:
Input: num... | binarysearch/array.go | 0.810291 | 0.61734 | array.go | starcoder |
package board
import (
"fmt"
"strings"
)
// MoveType indicates the type of move. The no-progress counter is reset with any non-Normal move.
type MoveType uint8
const (
Normal MoveType = 1 + iota
Push // Pawn move
Jump // Pawn 2-square move
EnPassant // Implicitly a pawn ... | pkg/board/move.go | 0.605799 | 0.422445 | move.go | starcoder |
package render
import (
"fmt"
"github.com/jschaf/bibtex/ast"
"io"
)
type NodeRenderer interface {
Render(w io.Writer, n ast.Node, entering bool) (ast.WalkStatus, error)
}
type NodeRendererFunc func(w io.Writer, n ast.Node, entering bool) (ast.WalkStatus, error)
func (nf NodeRendererFunc) Render(w io.Writer, n a... | render/render.go | 0.70619 | 0.460168 | render.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"
)
type quadBoxPhysicsComponent struct {
physicsComponent
boxes []api.INode
}
func newQuadBoxPhysicsComponent() *q... | examples/complex/physics/basic/p5_bouncy_blocks/quadbox_physics_component.go | 0.665193 | 0.464234 | quadbox_physics_component.go | starcoder |
package main
import (
"fmt"
"math"
"runtime"
"sort"
"github.com/fluhus/biostuff/formats/newick"
"github.com/fluhus/gostuff/ppln"
)
// Converts an abundance map to a list of flat nodes. Returns the sum of
// abundances under the given tree.
func abundanceToFlatNodes(abnd map[string]float64, tree *newick.Node,
... | frcfrc/unifrac.go | 0.641984 | 0.406538 | unifrac.go | starcoder |
package tire
import (
"log"
)
type Tire struct {
root *Node
count int
}
func New() Tire {
return Tire{root: NewNode('0'), count: 0}
}
func (t *Tire) Count() int {
return t.count
}
func (t *Tire) Find(values []byte) *Node {
if t.count == 0 {
return nil
}
return t.root.Find(v... | tire/tire.go | 0.580709 | 0.549218 | tire.go | starcoder |
package num
import (
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/exp/constraints"
)
type Class[A any] interface {
Add(A, A) A
Sub(A, A) A
Mul(A, A) A
Negate(A) A
Abs(A) A
SigNum(A) A
// FIXME: FromInteger(integer.Integer) A
}
type Numeric interface {
constraints.Integer | constraints.... | num/num.go | 0.571527 | 0.697937 | num.go | starcoder |
package geometry
import (
"fmt"
"math"
)
// Two dimensional line.
type Line2 struct {
A, B, C float64
}
// Allocates and returns a new 2D line in canonical form.
func NewLine2(a, b, c float64) *Line2 {
if a == 0 && b == 0 {
panic(fmt.Sprintf("coefficients a and b simultaneously 0"))
}
return &Line2{a, b, c}... | performance/contadortest/vendor/gopkg.in/karalabe/cookiejar.v2/geometry/line.go | 0.867766 | 0.593462 | line.go | starcoder |
package graph
import (
"container/heap"
"fmt"
"strings"
"sync"
)
// Type enumerates type of Graph.
type Type int8
const (
// Directional graph. A -> B != B -> A.
Directional Type = iota
// Bidirectional graph. A <-> B.
Bidirectional
)
// Graph implements an adjacency list. You should create a Graph by calli... | graph.go | 0.785884 | 0.428054 | graph.go | starcoder |
package design
/*
# Insert Delete GetRandom O(1)
# https://leetcode.com/explore/interview/card/top-interview-questions-medium/112/design/813/
Design a data structure that supports all following operations in average O(1) time.
insert(val): Inserts an item val to the set if not already present.
remove(val): Removes ... | interview/medium/design/set.go | 0.833765 | 0.41941 | set.go | starcoder |
package documents
// DocList is an array of all available document types currently supported.
// It is necessary because the envelope body can store many different types of proto structs
// You can't make an instance of a struct by the name of its type in golang, so this list
// facilitates the creation of empty obje... | libs/documents/docList.go | 0.501465 | 0.410284 | docList.go | starcoder |
package parser
import (
"fmt"
"regexp"
"strings"
)
type Scanner struct {
src string
slice string
offset int
}
func NewScanner(src string) *Scanner {
return &Scanner{src: src, slice: src, offset: 0}
}
func NewScannerAt(src string, offset, size int) *Scanner {
return &Scanner{src: src, slice: src[offset :... | parser/scanner.go | 0.591015 | 0.446253 | scanner.go | starcoder |
package grid
import (
"fmt"
"image"
)
type DrawableGrid interface {
GridSize() image.Rectangle
Set(x, y, r int, fore, back Color)
}
type Grid struct {
screenwidth int
screenheight int
runewidth int
runeheight int
texwidth int
texheight int
cols int
rows int
padx int
pady int
texcols in... | grid/grid.go | 0.751466 | 0.479382 | grid.go | starcoder |
// Package bar allows a user to create a go binary that follows the i3bar protocol.
package bar
// TextAlignment defines the alignment of text within a block.
// Using TextAlignment rather than string opens up the possibility of i18n without
// requiring each module to know the current locale.
type TextAlignment stri... | bar/bar.go | 0.815343 | 0.477006 | bar.go | starcoder |
package murmur2
import (
crand "crypto/rand"
"encoding/binary"
"hash"
"math/rand"
)
// New64a returns a MurmurHash64A hashing algorithm.
func New64a() hash.Hash64 {
return New64aWithSeed(rand.Uint64())
}
func New64aWithSeed(seed uint64) hash.Hash64 {
return &Murmur64A{
seed: seed,
}
}
// Murmur64A is an im... | hash/murmur2/murmur2.go | 0.704364 | 0.433202 | murmur2.go | starcoder |
package elements
import "github.com/fileformats/graphics/jt/model"
type BaseLight struct {
BaseAttribute
// Version number is the version identifier for this element
VersionNumber uint8
// Ambient Color specifies the ambient red, green, blue, alpha color values of the light.
AmbientColor model.RGBA
// Diffuse C... | jt/segments/elements/BaseLight.go | 0.721253 | 0.444324 | BaseLight.go | starcoder |
package tasks
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"reflect"
"strings"
)
var (
typesMap = map[string]reflect.Type{
// base types
"bool": reflect.TypeOf(true),
"int": reflect.TypeOf(int(1)),
"int8": reflect.TypeOf(int8(1)),
"int16": reflect.TypeOf(int16(1)),
"int32"... | vendor/github.com/RichardKnop/machinery/v1/tasks/reflect.go | 0.557604 | 0.432123 | reflect.go | starcoder |
package system
import (
"github.com/tubelz/macaw/entity"
"github.com/tubelz/macaw/math"
"github.com/veandco/go-sdl2/sdl"
)
// RenderSystem is probably one of the most important system. It is responsible to render (draw) the entities
type RenderSystem struct {
EntityManager *entity.Manager
Window *sdl.Wind... | system/render.go | 0.632957 | 0.407451 | render.go | starcoder |
package plan
import (
"sync"
"github.com/linanh/go-mysql-server/sql"
)
// NewHashLookup returns a node that performs an indexed hash lookup
// of cached rows for fulfilling RowIter() calls. In particular, this
// node sits directly on top of a `CachedResults` node and has two
// expressions: a projection for hash... | sql/plan/hash_lookup.go | 0.575111 | 0.400075 | hash_lookup.go | starcoder |
package kdtree
import "math"
var (
_ Interface = Points(nil)
_ Comparable = Point(nil)
)
// Point represents a point in a k-d space that satisfies the Comparable interface.
type Point []float64
// Compare returns the signed distance of p from the plane passing through c and
// perpendicular to the dimension d. ... | spatial/kdtree/points.go | 0.89818 | 0.704377 | points.go | starcoder |
package entities
import "github.com/rpaloschi/dxf-go/core"
// Spline Entity representation
type Spline struct {
BaseEntity
NormalVector core.Point
Closed bool
Periodic bool
Rational bool
Planar bool
Linear bool
Degree ... | vendor/github.com/rpaloschi/dxf-go/entities/spline.go | 0.663887 | 0.518607 | spline.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// ServicePrincipalRiskDetection
type ServicePrincipalRiskDetection struct {
Enti... | models/service_principal_risk_detection.go | 0.750644 | 0.429728 | service_principal_risk_detection.go | starcoder |
package sema
import (
"github.com/onflow/cadence/runtime/ast"
)
func (checker *Checker) VisitSwitchStatement(statement *ast.SwitchStatement) ast.Repr {
testType := checker.VisitExpression(statement.Expression, nil)
testTypeIsValid := !testType.IsInvalidType()
// The test expression must be equatable
if testT... | runtime/sema/check_switch.go | 0.617051 | 0.475971 | check_switch.go | starcoder |
package clusters
import (
"fmt"
"math/rand"
"time"
)
// A Cluster which data points gravitate around
type Cluster struct {
Center Coordinates
Observations Observations
}
// Clusters is a slice of clusters
type Clusters []Cluster
// New sets up a new set of clusters and randomly seeds their initial positi... | cluster.go | 0.827863 | 0.544983 | cluster.go | starcoder |
package logic
import (
"fmt"
"github.com/inkyblackness/res/data"
)
// LevelObjectChainLinkGetter is a function to return links from a chain.
type LevelObjectChainLinkGetter func(index data.LevelObjectChainIndex) LevelObjectChainLink
// LevelObjectChain handles the logic for a chain of level objects.
type LevelObj... | logic/LevelObjectChain.go | 0.690246 | 0.431045 | LevelObjectChain.go | starcoder |
package main
import "math"
/**
给定两个整数,被除数dividend和除数divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。
返回被除数dividend除以除数divisor得到的商。
整数除法的结果应当截去(truncate)其小数部分,例如:truncate(8.345) = 8 以及 truncate(-2.7335) = -2
示例1:
输入: dividend = 10, divisor = 3
输出: 3
解释: 10/3 = truncate(3.33333..) = truncate(3) = 3
示例2:
输入: dividend = 7, divisor =... | leetcode/divide/divide.go | 0.514888 | 0.455562 | divide.go | starcoder |
package main
import (
"fmt"
"sync"
"github.com/go-playground/validator"
"github.com/rs/zerolog/log"
"gorm.io/gorm"
)
var (
resourceLock sync.Mutex
)
// Formation is the lowest-level object that is directly addressable by the user (within the context of Captain). A
// formation manages a group of planes that a... | ATC/Formation.go | 0.672547 | 0.444806 | Formation.go | starcoder |
package material
import (
"github.com/Glenn-Gray-Labs/g3n/gls"
"github.com/Glenn-Gray-Labs/g3n/math32"
)
// Standard material supports the classic lighting model with
// ambient, diffuse, specular and emissive lights.
// The lighting calculation is implemented in the vertex shader.
type Standard struct {
Material... | material/standard.go | 0.872836 | 0.517449 | standard.go | starcoder |
package line
import (
"github.com/gravestench/pho/geom/point"
)
type LineNamespace interface {
New(x1, y1, x2, y2 float64) *Line
BresenhamPoints(l *Line, stepRate int, out []*point.Point) []*point.Point
Length(l *Line) float64
GetPoint(l *Line, position float64, out *point.Point) *point.Point
GetPoints(l *Line,... | geom/line/namespace.go | 0.902287 | 0.542318 | namespace.go | starcoder |
package distuv
import (
"math"
"golang.org/x/exp/rand"
"gonum.org/v1/gonum/mathext"
)
// Poisson implements the Poisson distribution, a discrete probability distribution
// that expresses the probability of a given number of events occurring in a fixed
// interval.
// The poisson distribution has density functi... | stat/distuv/poisson.go | 0.903084 | 0.655818 | poisson.go | starcoder |
package test
import (
"reflect"
"testing"
"time"
)
func ExpectedError(t *testing.T, err error, expected string) {
t.Helper()
ExpectedErrorF(t, err, expected, "")
}
func ExpectedErrorF(t *testing.T, err error, expected, msg string) {
t.Helper()
var actual string
if err == nil {
actual = "<no error>"
} e... | test.go | 0.690976 | 0.632049 | test.go | starcoder |
// Package byteutil provides utilities for working with bytes using little endian binary encoding.
package byteutil
// MaxUint24 is the maximum value representable 3-octet uint.
const MaxUint24 = 1<<24 - 1
// ParseUint32 parses uint32 from b assuming little endian binary encoding.
func ParseUint32(b []byte) uint32 {... | pkg/util/byteutil/byteutil.go | 0.632843 | 0.600364 | byteutil.go | starcoder |
package datadog
import (
"encoding/json"
)
// AuditLogsQueryFilter Search and filter query settings.
type AuditLogsQueryFilter struct {
// Minimum time for the requested events. Supports date, math, and regular timestamps (in milliseconds).
From *string `json:"from,omitempty"`
// Search query following the Audit... | api/v2/datadog/model_audit_logs_query_filter.go | 0.770724 | 0.40928 | model_audit_logs_query_filter.go | starcoder |
package hbook
// Bin2D models a bin in a 2-dim space.
type Bin2D struct {
xrange Range
yrange Range
dist dist2D
}
// Rank returns the number of dimensions for this bin.
func (Bin2D) Rank() int { return 2 }
func (b *Bin2D) scaleW(f float64) {
b.dist.scaleW(f)
}
func (b *Bin2D) fill(x, y, w float64) {
b.dist.... | hbook/bin2d.go | 0.947745 | 0.806129 | bin2d.go | starcoder |
package helpers // github.com/openshift-online/ocm-sdk-go/helpers
import (
"context"
"fmt"
"net/http"
"net/url"
"strings"
"time"
)
// AddValue creates the given set of query parameters if needed, an then adds
// the given parameter.
func AddValue(query *url.Values, name string, value interface{}) {
if *query ... | vendor/github.com/openshift-online/ocm-sdk-go/helpers/helpers.go | 0.680029 | 0.402333 | helpers.go | starcoder |
package particle
import (
"math"
"math/rand"
"time"
gaussian "github.com/chobie/go-gaussian"
)
type ParticleFilter struct {
N int // Number of particles to sample
Dimensions int // Number of dimensions to record
Particles []Particle // Slice of particles sampled
resampler Resampler ... | particle/filter.go | 0.649801 | 0.646962 | filter.go | starcoder |
package graphics2d
import (
"github.com/jphsd/graphics2d/util"
"math"
)
// RoundedProc replaces adjacent line segments in a path with line-arc-line where the radius of the
// arc is the minimum of Radius or the maximum allowable for the length of the shorter line segment.
// This ensures that the rounded corner doe... | roundedproc.go | 0.708414 | 0.45538 | roundedproc.go | starcoder |
package check
import (
"fmt"
"regexp"
)
// String is the type of a check function for a string. It takes a string as
// a parameter and returns an error or nil if the check passes
type String func(s string) error
// StringLenEQ returns a function that will check that the
// length of the string is equal to the lim... | check/string.go | 0.675015 | 0.586434 | string.go | starcoder |
package funk
import (
"fmt"
"math/rand"
"reflect"
)
// Chunk creates an array of elements split into groups with the length of size.
// If array can't be split evenly, the final chunk will be
// the remaining element.
func Chunk(arr interface{}, size int) interface{} {
if !IsIteratee(arr) {
panic("First paramet... | vendor/github.com/thoas/go-funk/transform.go | 0.705785 | 0.512022 | transform.go | starcoder |
package geom
//Polygon对象 多变形对象是一个LinearRing(线环)的集合。第一个LinearRing作为外边界,
//随后的LinearRing对象作为内边界
type Polygon struct {
geom2
}
// NewPolygon函数 创建一个空的多边形
func NewPolygon(layout Layout) *Polygon {
return NewPolygonFlat(layout, nil, nil)
}
// NewPolygonFlat函数 根据传入的坐标和视图类型创建多边形
func NewPolygonFlat(layout Layout, flatCoor... | polygon.go | 0.538255 | 0.60778 | polygon.go | starcoder |
package volume
import (
"fmt"
"io"
"github.com/sirupsen/logrus"
"github.com/vatine/3dmandel/pkg/coords"
)
type Volume interface {
Set(coords.Coord)
Render(io.Writer)
IsFull() bool
IsEmpty() bool
mini() coords.Coord
}
type empty struct {
min coords.Coord
side float64
}
func (e empty) Set(c coords.Coor... | pkg/volume/volume.go | 0.667473 | 0.404919 | volume.go | starcoder |
package gopdf
// Margins type.
type Margins struct {
Left, Top, Right, Bottom float64
}
// SetLeftMargin sets left margin.
func (gp *GoPdf2) SetLeftMargin(margin float64) {
gp.UnitsToPointsVar(&margin)
gp.margins.Left = margin
}
// SetTopMargin sets top margin.
func (gp *GoPdf2) SetTopMargin(margin float64) {
gp... | margin.go | 0.891179 | 0.458531 | margin.go | starcoder |
package es_mx
import "github.com/rannoch/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, d 'de' MMMM 'de' y", Long: "d 'de' MMMM 'de' y", Medium: "d MMM y", Short: "d/M/yy"},
Time: cldr.CalendarDateFormat{Full: "H:mm:ss (zzzz)", Long: "H:mm:ss... | resources/locales/es_MX/calendar.go | 0.54698 | 0.401336 | calendar.go | starcoder |
package surface
import (
"math/rand"
"github.com/hunterloftis/pbr/pkg/geom"
"github.com/hunterloftis/pbr/pkg/render"
"github.com/hunterloftis/pbr/pkg/rgb"
)
// Triangle describes a triangle
type Triangle struct {
Points [3]geom.Vec // TODO: private fields?
Normals [3]geom.Dir
Texture [3]geom.Vec
Mat Mat... | pkg/surface/triangle.go | 0.542863 | 0.544862 | triangle.go | starcoder |
package main
import (
"math"
"math/rand"
)
// The Source interface represents a source of randomized data.
type Source interface {
Advance(int) // Advance sets the source's time.
Value() float64 // Value gets the source's current value
}
// Generator is a generic type implemening Source that's based on a ran... | demo/emit/source.go | 0.826642 | 0.568715 | source.go | starcoder |
package parser
import (
"fmt"
"log"
"sort"
"strconv"
"github.com/facebookresearch/clinical-trial-parser/src/common/col/set"
"github.com/facebookresearch/clinical-trial-parser/src/ct/relation"
"github.com/facebookresearch/clinical-trial-parser/src/ct/variables"
)
// Tree defines the parse tree.
type Tree stru... | src/ct/parser/tree.go | 0.754101 | 0.422386 | tree.go | starcoder |
package main
import (
"math/rand"
)
type Individ struct {
ps []Point2f
distance float64
fitness float64
}
func NewIndivid(ps []Point2f, distance float64) *Individ {
d := &Individ{
ps: ps,
distance: distance,
}
d.calcFitness()
return d
}
func RandIndivid(r *rand.Rand, n int, distance float64... | ga/closedist/individ.go | 0.778649 | 0.47025 | individ.go | starcoder |
package gstr
import "strings"
// Str returns part of `haystack` string starting from and including
// the first occurrence of `needle` to the end of `haystack`.
// See http://php.net/manual/en/function.strstr.php.
func Str(haystack string, needle string) string {
if needle == "" {
return ""
}
pos := strings.Ind... | text/gstr/gstr_sub.go | 0.794225 | 0.513607 | gstr_sub.go | starcoder |
package migrator
import (
"database/sql"
)
var (
// DefaultBatchSize represents the default size of extracted batches
DefaultBatchSize = 1000
// TrackingTableName represents the name of the database table used
// to track TrackingStatus instances, and exists within the target
// database.
TrackingTableName = "... | types.go | 0.604282 | 0.478285 | types.go | starcoder |
package write
import (
"bytes"
"fmt"
"github.com/lukasaron/data-discogs/model"
"io"
"strings"
)
// SQLWriter is one of few provided writers that implements the Writer interface and provides the ability to save
// decoded data in the format of SQL insert commands.
type SQLWriter struct {
o Options
w io.Wri... | write/sql.go | 0.610453 | 0.407687 | sql.go | starcoder |
package xy
// Cell is a 64-bit integer that interleaves two coordinates.
type Cell uint64
func (c Cell) String() string {
s := make([]byte, 0, 32)
const hex = "0123456789abcdef"
for i := 0; i < 64; i += 4 {
s = append(s, hex[(c>>(60-i))&15])
}
return string(s)
}
// Quad returns a value or 0, 1, 2, or 3 repres... | xy/cell.go | 0.846054 | 0.518059 | cell.go | starcoder |
package paseto
import (
"encoding/json"
"fmt"
"time"
)
// JSONToken defines standard token payload claims and allows for additional
// claims to be added. All of the standard claims are optional.
type JSONToken struct {
// Audience identifies the intended recipients of the token.
// It should be a string or a UR... | vendor/github.com/o1egl/paseto/json_token.go | 0.660063 | 0.456531 | json_token.go | starcoder |
package main
import (
"fmt"
"strings"
)
// R1: representation is a slice of int8 digits of -1, 0, or 1.
// digit at index 0 is least significant. zero value of type is
// representation of the number 0.
type bt []int8
// R2: string conversion:
// btString is a constructor. valid input is a string of any length
... | tasks/Balanced-ternary/balanced-ternary.go | 0.559892 | 0.484258 | balanced-ternary.go | starcoder |
package main
import (
// "fmt" // tests
// "errors"
// "github.com/go-gl/gl/v3.3-core/gl"
// "github.com/go-gl/glfw/v3.2/glfw"
"github.com/go-gl/mathgl/mgl32"
// "github.com/mki1967/go-mki3d/mki3d"
// "github.com/mki1967/go-mki3d/glmki3d"
"math"
"math/rand"
)
// Random position in the game stage box with the... | mki3dgame/gamemath.go | 0.724481 | 0.485295 | gamemath.go | starcoder |
package runtime
import (
"bytes"
"fmt"
"os/exec"
"strings"
)
type DefaultRuntime struct {
scope *Scope
}
func CreateDefaultRuntime() *DefaultRuntime {
return &DefaultRuntime{
scope: CreateScope(nil, ScopeTypeGlobal),
}
}
func (runtime *DefaultRuntime) Add(left *Value, right *Value) *Value {
runtime.assert... | runtime/defaultruntime.go | 0.68679 | 0.426531 | defaultruntime.go | starcoder |
package papernet
var arxivCategories = map[string]string{
"stat.AP": "Statistics - Applications",
"stat.CO": "Statistics - Computation",
"stat.ML": "Statistics - Machine Learning",
"stat.ME": "Statistics - Methodology",
"stat.TH": "Statistics - Theory",
"q-b... | arxiv_categories.go | 0.702836 | 0.685601 | arxiv_categories.go | starcoder |
package stream
import (
"reflect"
"github.com/wesovilabs/koazee/errors"
)
// Output structure for returning single values
type Output struct {
value reflect.Value
error *errors.Error
}
// Val reurn the Output of the Stream
func (o Output) Val() interface{} {
v := (o.value)
if !o.value.IsValid() {
return nil... | stream/stream.go | 0.719482 | 0.499878 | stream.go | starcoder |
package byteconv
import (
"fmt"
"strconv"
"strings"
"unicode"
)
const (
BYTE float64 = 1 << (10 * iota)
KiB // 1024
MiB // 1048576
GiB // 1073741824
TiB // 1099511627776 (exceeds 1 << 32)
PiB // 1125899906842624
EiB // 1152921504606846976
KB float64 = 1e3 // 1000
MB float64 = 1e6 // 1000000
GB ... | byteconv.go | 0.654895 | 0.429489 | byteconv.go | starcoder |
package data
import (
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
)
// Type denotes a data type
type Type int
//var intSize = strconv.IntSize
const (
TypeUnknown Type = iota // interface{}
TypeAny // interface{}
// simple types
TypeString // string
TypeInt // int
TypeInt32 // int32
TypeI... | data/types.go | 0.621885 | 0.419707 | types.go | starcoder |
package monotone
import (
compgeo "github.com/200sc/go-compgeo"
"github.com/200sc/go-compgeo/dcel"
"github.com/200sc/go-compgeo/dcel/pointLoc"
"github.com/200sc/go-compgeo/geom"
"github.com/200sc/go-compgeo/search"
"github.com/200sc/go-compgeo/search/tree"
)
// DoubleIntervalTree converts a monotonized f into a... | dcel/pointLoc/monotone/doubleInsertionTree.go | 0.737631 | 0.423637 | doubleInsertionTree.go | starcoder |
package ln
import (
"math"
"math/rand"
)
type Vector struct {
X, Y, Z float64
}
func RandomUnitVector() Vector {
for {
x := rand.Float64()*2 - 1
y := rand.Float64()*2 - 1
z := rand.Float64()*2 - 1
if x*x+y*y+z*z > 1 {
continue
}
return Vector{x, y, z}.Normalize()
}
}
func (a Vector) Length() flo... | ln/vector.go | 0.847274 | 0.795499 | vector.go | starcoder |
package graphblas
import (
"context"
"log"
"reflect"
"github.com/rossmerr/graphblas/constraints"
)
// type Ordered interface {
// Integer | Float | ~string
// }
func init() {
RegisterMatrix(reflect.TypeOf((*SparseVector[float64])(nil)).Elem())
}
// SparseVector compressed storage by indices
type SparseVecto... | sparseVector.go | 0.759671 | 0.588712 | sparseVector.go | starcoder |
package jsonlog
import (
"encoding/json"
"time"
)
// An Event represents a structured logeevent inspired by the semantic model of OTEL (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md)
type Event struct {
Time *time.Time `json:"time,omitempty"` // Ti... | jsonlog/event.go | 0.875268 | 0.542136 | event.go | starcoder |
package parser
import (
"errors"
"io"
"github.com/golangee/tadl/token"
)
// TreeNode is a node in the parse tree.
// For regular nodes Text and Comment will always be nil.
// For terminal text nodes Children and Name will be empty and Text will be set.
// For comment nodes Children and Name will be empty and onl... | parser/parser.go | 0.654564 | 0.543287 | parser.go | starcoder |
package internal
import (
"fmt"
"math"
"math/big"
"reflect"
"strconv"
"github.com/tada/catch"
"github.com/tada/dgo/dgo"
)
type (
// intVal is an int64 that implements the dgo.Value interface
intVal int64
defaultIntegerType int
integerType struct {
min dgo.Integer
max dgo.Integer
inclus... | internal/integer.go | 0.7478 | 0.433142 | integer.go | starcoder |
package voxelgrid
import (
"github.com/seqsense/pcgol/mat"
)
type VoxelGrid struct {
voxel [][]int
size [3]int
origin mat.Vec3
resolution float32
resolutionInv float32
}
func New(resolution float32, size [3]int, origin mat.Vec3) *VoxelGrid {
return &VoxelGrid{
voxel: make(... | pc/storage/voxelgrid/voxelgrid.go | 0.666822 | 0.490846 | voxelgrid.go | starcoder |
package generator
import (
_ "embed"
"encoding/json"
"github.com/m2q/siam-cs/model"
"time"
)
// refRaw contains real reference match data as a raw json string. The data is sorted, so
// that ALL past matches (i.e. matches that have a non-empty `Winner` field) occur BEFORE
// all future or live matches (i.e. match... | generator/generator.go | 0.689201 | 0.449997 | generator.go | starcoder |
package level0
import (
"github.com/sfomuseum/go-edtf"
"github.com/sfomuseum/go-edtf/common"
"github.com/sfomuseum/go-edtf/re"
)
/*
Time Interval
EDTF Level 0 adopts representations of a time interval where both the start and end are dates: start and end date only; that is, both start and duration, and duration ... | vendor/github.com/sfomuseum/go-edtf/level0/time_interval.go | 0.745861 | 0.543893 | time_interval.go | starcoder |
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
// Grid represents the cluster computing grid
type Grid map[string]string
// A function to perform a burst of activity by the carrier
type burstFunc func(grid Grid, x, y int, direction Direction) (int, int, Direction, bool)
// CLEAN state
const CLEAN = "."
/... | 2017/day22/day22.go | 0.62223 | 0.459197 | day22.go | starcoder |
package ecc
import (
"fmt"
"math/big"
)
// Point represents a point in an elliptic curve.
type Point struct {
X FieldInteger
Y FieldInteger
A FieldInteger
B FieldInteger
}
// NewPoint returns a Point.
func NewPoint(x FieldInteger, y FieldInteger, a FieldInteger, b FieldInteger) (*Point, error) {
if x == nil &... | ecc/point.go | 0.811489 | 0.653597 | point.go | starcoder |
package twodee
import (
"github.com/go-gl/mathgl/mgl32"
)
type Point struct {
mgl32.Vec2
}
func Pt(x, y float32) Point {
return Point{mgl32.Vec2{x, y}}
}
func (p Point) Scale(a float32) Point {
return Point{p.Vec2.Mul(a)}
}
func (p Point) Add(pt Point) Point {
return Point{p.Vec2.Add(pt.Vec2)}
}
func (p Poi... | geometry.go | 0.852337 | 0.592755 | geometry.go | starcoder |
package FlatGeobuf
import "strconv"
type GeometryType byte
const (
GeometryTypeUnknown GeometryType = 0
GeometryTypePoint GeometryType = 1
GeometryTypeLineString GeometryType = 2
GeometryTypePolygon GeometryType = 3
GeometryTypeMultiPoint GeometryType = 4
Geo... | src/go/FlatGeobuf/GeometryType.go | 0.696165 | 0.587825 | GeometryType.go | starcoder |
package tf32
import (
"io/ioutil"
"math"
"os"
"github.com/golang/protobuf/proto"
pro "github.com/pointlander/gradient/tf32/proto_tf32"
)
// LFSRMask is a LFSR mask with a maximum period
const LFSRMask = 0x80000057
type (
// RNG is a random number generator
RNG uint32
// V is a tensor value
V struct {
N... | tf32/gradient.go | 0.796728 | 0.420124 | gradient.go | starcoder |
package spin
import (
"fmt"
"io"
"os"
"sync/atomic"
"time"
)
// ClearLine go to the beginning of the line and clear it
const ClearLine = "\r\033[K"
// Spinner types.
var (
Box1 = `⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`
Box2 = `⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓`
Box3 = `⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆`
Box4 = `⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋`
Box5 = `⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚... | spin.go | 0.602529 | 0.458106 | spin.go | starcoder |
package main
import (
"fmt"
"sort"
)
var board = []string{
".00.00.",
"0000000",
"0000000",
".00000.",
"..000..",
"...0...",
}
var moves = [][2]int{
{-3, 0}, {0, 3}, {3, 0}, {0, -3},
{2, 2}, {2, -2}, {-2, 2}, {-2, -2},
}
var grid [][]int
var totalToFill = 0
func solve(r, c,... | lang/Go/solve-a-hopido-puzzle-1.go | 0.571288 | 0.419945 | solve-a-hopido-puzzle-1.go | starcoder |
package xiso
import (
"regexp"
"strings"
"time"
)
// iso3166LastUpdate is used in tests to trigger an check to update the data.
// This is the best thing for now, as there is no good way to check this online.
var iso3166LastUpdate = time.Date(2021, 12, 5, 0, 0, 0, 0, time.UTC)
type Country struct {
Name stri... | xiso/iso_3166.go | 0.514156 | 0.474327 | iso_3166.go | starcoder |
package bayes
import (
"fmt"
"math"
s "gostat.googlecode.com/hg/stat"
)
// Quantile, Flat prior
func BinomFlatPriQtl(k, n int64, p float64) float64 {
var α, β float64
if k>n {
panic(fmt.Sprintf("The number of observed successes (k) must be <= number of trials (n)"))
}
α=float64(k+1)
β=float64(n-k+1)
if... | stat/bayes/binom_p.go | 0.737253 | 0.507446 | binom_p.go | starcoder |
package calculator
import (
"errors"
"fmt"
"go/token"
"go/types"
"math"
"regexp"
"strconv"
"strings"
)
// Precision is used to calculate when square root is satisfied.
const Precision = 0.0000000001
// Add takes two or more numbers and returns the result of adding them together.
func Add(a, b float64, extra ... | calculator.go | 0.838548 | 0.492127 | calculator.go | starcoder |
package DG2D
import "C"
import (
"fmt"
"math"
"github.com/notargets/gocfd/types"
"github.com/notargets/gocfd/readfiles"
"github.com/notargets/gocfd/DG1D"
"github.com/notargets/gocfd/utils"
)
type NDG2D struct {
Element *LagrangeElement2D
K int
NOD... | DG2D/ndg_startup.go | 0.519765 | 0.433262 | ndg_startup.go | starcoder |
package codecs
import (
"bytes"
"time"
)
// EncodedSize returns the number of bytes required to encode the value v.
func EncodedSize(v interface{}) (int, error) {
if v == nil {
return 1, nil
}
switch t := v.(type) {
case bool:
return sizeBool, nil
case uint8:
return sizeUint8, nil
case int8:
return si... | codecs/size.go | 0.665737 | 0.441974 | size.go | starcoder |
package depot
import "time"
// Values contains the persistent column values for an entity either after reading
// the values from the database to re-create the entity value or to persist the
// entity's values in the database (either for insertion or update).
type Values map[string]interface{}
// IsNull returns tru... | values.go | 0.800965 | 0.566438 | values.go | starcoder |
package str
import (
"errors"
"math/rand"
"sort"
"strings"
"time"
)
var (
rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
)
type Vector []string
func (vector Vector) FirstNonEmpty() string {
for _, str := range vector {
if str != "" {
return str
}
}
return ""
}
func (vector Vector) Len() int ... | str/vector.go | 0.612773 | 0.484685 | vector.go | starcoder |
package dealer
import (
"context"
"errors"
"sync"
"github.com/thrasher-corp/gocryptotrader/exchanges/fill"
"github.com/thrasher-corp/gocryptotrader/exchanges/trade"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
"github.com/thrasher-co... | internal/dealer/strategy_root.go | 0.76908 | 0.472866 | strategy_root.go | starcoder |
package mem
import (
"bufio"
"os"
"strconv"
"strings"
"github.com/alexdreptu/sysinfo/convert"
"golang.org/x/sys/unix"
)
type fetchFunc func(info *unix.Sysinfo_t) error
type Mem struct {
Procs uint16
TotalMem uint64
TotalHighMem uint64
FreeMem uint64
FreeHighMem uint64
AvailMem uint6... | mem/mem.go | 0.615666 | 0.403097 | mem.go | starcoder |
package nbs
import (
"context"
"encoding/binary"
"errors"
"io"
"sort"
"sync/atomic"
"github.com/golang/snappy"
"golang.org/x/sync/errgroup"
"github.com/dolthub/dolt/go/store/chunks"
"github.com/dolthub/dolt/go/store/hash"
)
// Do not read more than 128MB at a time.
const maxReadSize = 128 * 1024 * 1024
... | go/store/nbs/table_reader.go | 0.671147 | 0.465448 | table_reader.go | starcoder |
package bandersnatch
import (
"math/big"
"github.com/consensys/gnark/frontend"
)
// Point point on a twisted Edwards curve in a Snark cs
type Point struct {
X, Y frontend.Variable
}
// MustBeOnCurve checks if a point is on the reduced twisted Edwards curve
// a*x^2 + y^2 = 1 + d*x^2*y^2.
func (p *Point) MustBeOn... | std/algebra/twistededwards/bandersnatch/point.go | 0.834542 | 0.429429 | point.go | starcoder |
package cmd
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"os"
"github.com/disintegration/imaging"
"github.com/spf13/cobra"
)
var img *image.RGBA
var col color.Color
// HLine draws a horizontal line
func HLine(x1, y, x2 int) {
for ; x1 <= x2; x1++ {
img.Set(x1, y, col)
}
}
// VLine draws a ve... | cmd/checkpoint.go | 0.712032 | 0.469399 | checkpoint.go | starcoder |
package telemetry
// LocalQuery contains the serviceID for a local query
const LocalQuery string = "weaviate.local.query"
// LocalQueryMeta contains the serviceID for a local meta query
const LocalQueryMeta string = "weaviate.local.query.meta"
// NetworkQuery contains the serviceID for a network query
const Network... | usecases/telemetry/constants.go | 0.549157 | 0.422922 | constants.go | starcoder |
package digest
import (
"fmt"
)
// Type - Multihash algorithm ID.
type Type uint64
// Source of constants: https://godoc.org/github.com/multiformats/go-multihash#pkg-constants
const (
// Sha1 - SHA1 hashing algorithm.
Sha1 Type = 0x11
// Sha2_256 - SHA2 256bit hashing algorithm.
Sha2_256 Type = 0x12
// Sha2_5... | digest/type.go | 0.590661 | 0.439146 | type.go | starcoder |
package calculator
import (
"errors"
"math"
"strconv"
"strings"
)
// Add takes two numbers and returns the result of adding them together.
func Add(a, b float64, c ...float64) float64 {
total := a + b
for _, num := range c {
total += num
}
return total
}
// Subtract takes two numbers and returns the result... | calculator.go | 0.803714 | 0.559471 | calculator.go | starcoder |
package day24
import "strings"
// Grid is a rectangular grid of bugs.
type Grid struct {
bugs uint64
width int
height int
}
// EmptyGrid creates an empty bug grid of a given size.
func EmptyGrid(width, height int) *Grid {
return &Grid{
width: width,
height: height,
}
}
// GridFromString reads a string ... | day24/grid.go | 0.832611 | 0.536374 | grid.go | starcoder |
package config
/**
* Configuration for PQ policy resource.
*/
type Pqpolicy struct {
/**
* Name for the priority queuing policy. Must begin with a letter, number, or the underscore symbol (_). Other characters allowed, after the first character, are the hyphen (-), period (.) hash (#), space ( ), at (@), equals (=)... | resource/config/pqpolicy.go | 0.82347 | 0.528229 | pqpolicy.go | starcoder |
package ternary
// Int returns int on any condition value
func Int(cond bool, onTrue int, onFalse int) int {
if cond {
return onTrue
}
return onFalse
}
// IntStr returns int on true or string on false condition
func IntStr(cond bool, onTrue int, onFalse string) interface{} {
if cond {
return onTrue
}
return... | int.go | 0.667256 | 0.404978 | int.go | starcoder |
package ease
import "math"
var (
// Linear does a linear interpolation.
Linear = &ease{
fp: func(t float64) float64 {
return t
},
fd: func(t float64) float64 {
return 1
},
}
// InCubic does a cubic interpolation.
InCubic = &ease{
fp: func(t float64) float64 {
return t * t * t
},
fd: func(t... | functions.go | 0.685423 | 0.630685 | functions.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.