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 geomfn
import (
"github.com/cockroachdb/cockroach/pkg/geo"
"github.com/cockroachdb/cockroach/pkg/geo/geopb"
"github.com/cockroachdb/errors"
"github.com/twpayne/go-geom"
)
// CollectionExtract returns a (multi-)geometry consisting only of the specified type.
// The type can only be point, line, or polygon... | pkg/geo/geomfn/collections.go | 0.817538 | 0.596286 | collections.go | starcoder |
package lzma
// DecodeX86 decodes LZMA data with the x86 extension.
func DecodeX86(encodedData []byte) ([]byte, error) {
decodedData, err := Decode(encodedData)
if err != nil {
return nil, err
}
var x86State uint32
x86Convert(decodedData, uint(len(decodedData)), 0, &x86State, false)
return decodedData, nil
}
... | pkg/lzma/x86.go | 0.672009 | 0.403156 | x86.go | starcoder |
package env
import (
"github.com/emer/etable/etable"
"github.com/emer/etable/etensor"
"github.com/goki/ki/kit"
)
// TimeScales are the different time scales associated with overall simulation running, and
// can be used to parameterize the updating and control flow of simulations at different scales.
// The defin... | env/time.go | 0.622115 | 0.634996 | time.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
// ContainedBag represents a bag that is contained inside another bag.
type ContainedBag struct {
Quantity int
Color string
}
// ShinyGold represents the targetBag in this exercise.
const ShinyGold = "shiny gold"
func main() {
// Part ... | 2020/day7/day7.go | 0.730097 | 0.452596 | day7.go | starcoder |
package aoc
import (
"fmt"
)
// Coordinate represents a two-dimensional (x,y) position on the grid.
type Coordinate struct {
X, Y int
}
// Add adds Coordinate s to the given Coordinate
func (c Coordinate) Add(s Coordinate) Coordinate {
return Coordinate{
X: c.X + s.X,
Y: c.Y + s.Y,
}
}
// Subtract substract... | grid.go | 0.855926 | 0.613439 | grid.go | starcoder |
package util
// FilterBitArray is an array of bits based on byte unit, so 8 bits at each
// index. The array automatically increases if the set index is larger than the
// current capacity. The bit index starts at 0.
type FilterBitArray []byte
// NewFilterBitArray creates an array with the specified bit-size. This is... | core/ledger/util/filterbitarray.go | 0.864038 | 0.605158 | filterbitarray.go | starcoder |
package trcs
import (
"github.com/spf13/cobra"
"github.com/scionproto/scion/go/lib/common"
)
var Cmd = &cobra.Command{
Use: "trcs",
Short: "Generate TRCs for the SCION control plane PKI",
Long: `
'trc' can be used to generate Trust Root Configuration (TRC) files used in the SCION control
plane PKI.
Generati... | go/tools/scion-pki/internal/v2/trcs/cmd.go | 0.703549 | 0.461138 | cmd.go | starcoder |
package models
import (
"fmt"
"math"
)
type Pendulum struct {
length float64
theta float64
thetaPrime float64
Ball PointMass
}
func (p *Pendulum) SetPosition(x, y float64) {
p.Ball.SetPosition(x, y)
}
func (p *Pendulum) SetVelocity(x, y float64) {
p.Ball.SetVelocity(x, y)
}
type DoublePendul... | src/models/pendulum.go | 0.746046 | 0.569972 | pendulum.go | starcoder |
package types
import (
"fmt"
"sort"
"github.com/attic-labs/noms/go/d"
)
type Set struct {
orderedSequence
}
func newSet(seq orderedSequence) Set {
return Set{seq}
}
func NewSet(vrw ValueReadWriter, v ...Value) Set {
data := buildSetData(v)
ch := newEmptySetSequenceChunker(vrw)
for _, v := range data {
... | go/types/set.go | 0.770724 | 0.490663 | set.go | starcoder |
package parser
import (
"errors"
"fmt"
"strings"
)
// Parser represents a parser, including a scanner and the underlying raw input.
// It also contains a small buffer to allow for two unscans.
type Parser struct {
s *Lexer
raw string
buf TokenStack
}
// NewParser returns a new instance of Parser.
func NewPar... | parser/parser.go | 0.656768 | 0.420064 | parser.go | starcoder |
package rainbow
import (
"time"
)
// IsExpiryAvailable takes the expiries from "func Expiries(" below and compare it with the option expiry.
func IsExpiryAvailable(expiries []time.Time, expiry time.Time) bool {
for _, e := range expiries {
if expiry.Equal(e) {
return true
}
}
return false
}
// Expiries re... | pkg/rainbow/expiry.go | 0.50293 | 0.503418 | expiry.go | starcoder |
package geoviewport
import (
"math"
sm "github.com/engelsjk/sphericalmercator"
)
type SMCache map[int]sm.SphericalMercator
var (
smCache = SMCache{}
)
func fetchMerc(tileSize int) sm.SphericalMercator {
if tileSize == 0 {
tileSize = 256
}
if _, ok := smCache[tileSize]; !ok {
smCache[tileSize] = sm.New(&... | geoviewport.go | 0.736116 | 0.455683 | geoviewport.go | starcoder |
package toml
import (
"fmt"
"math"
"strconv"
"time"
)
func parseInteger(b []byte) (int64, error) {
if len(b) > 2 && b[0] == '0' {
switch b[1] {
case 'x':
return parseIntHex(b)
case 'b':
return parseIntBin(b)
case 'o':
return parseIntOct(b)
default:
panic(fmt.Errorf("invalid base '%c', shoul... | vendor/github.com/pelletier/go-toml/v2/decode.go | 0.652574 | 0.47725 | decode.go | starcoder |
package binson
import (
"fmt"
"sort"
)
// Returns a new empty binson object.
func NewBinson() Binson {
b := make(map[binsonString]field)
return b
}
// Returns an ordered list of the field names of this Binson object.
// Can be used to iterate all fields of this Binson object.
func (b Binson) FieldNam... | binson.go | 0.811527 | 0.467089 | binson.go | starcoder |
package gone
import (
"encoding/json"
"strconv"
"strings"
"time"
)
const timeTpl string = "2006-01-02 15:04:05"
// https://github.com/dxvgef/gommon/blob/master/datatime/datetime.go
// const timeShortTpl string = "2006-01-02 15:04"
// TimeToStr 返回时间的字符串格式.
func TimeToStr(t time.Time, format ...string) string {
... | time.go | 0.562417 | 0.40028 | time.go | starcoder |
package set
import (
"errors"
"reflect"
"strconv"
)
// Set is an interface should be implemented as a mathematically set.
type Set interface {
// Add adds an `i` to the Set.
Add(i interface{}) error
// Remove removes an `i` from the Set.
Remove(i interface{}) error
// Cardinality returns the number of eleme... | set/set.go | 0.845145 | 0.485356 | set.go | starcoder |
package exploits
import (
"git.gobies.org/goby/goscanner/goutils"
)
func init() {
expJson := `{
"Name": "Elasticsearch Remote Code Execution CVE-2014-3120",
"Description": "The default configuration before Elasticsearch 1.2 enabled dynamic scripting, which allowed remote attackers to execute arbitrary MVEL expr... | 2014/CVE-2014-3120/poc/goby/Elasticsearch_Remote_Code_Execution_CVE_2014_3120.go | 0.579162 | 0.436802 | Elasticsearch_Remote_Code_Execution_CVE_2014_3120.go | starcoder |
package dotnotation
import "errors"
// Accessor provides two methods, Get and Set, that can be configured to handle custom data structures via the
// exported properties, Parser, Getter, and Setter.
type Accessor struct {
// Getter returns the property value of a given target, or an error.
Getter func(target interf... | dotnotation/accessor.go | 0.76856 | 0.545225 | accessor.go | starcoder |
package main
type number interface {
stackEntry
Add(number) number
Negate() number
Multiply(number) number
Divide(number) number
LessThan(number) Boolean
}
func isMathWord(w word) bool {
return w == "+" ||
w == "-" ||
w == "*" ||
w == "/" ||
// w == "div" ||
w == "mod" ||
w == "<" ||
w == "zero?"... | math.go | 0.567937 | 0.44083 | math.go | starcoder |
package texture
import (
"image"
"image/color"
"image/draw"
"math/rand"
)
// Ordered Dithers
var (
// B2Dither is the Bayer ordered dither matrix 2x2
B2Dither = [][]float64{
{1 / 4.0, 3 / 4.0},
{4 / 4.0, 2 / 4.0},
}
// B4Dither is the Bayer ordered dither matrix 4x4
B4Dither = [][]float64{
{1 / 16.0, ... | image/texture/dithers.go | 0.659844 | 0.458591 | dithers.go | starcoder |
package tabulate
import (
"fmt"
"strings"
)
var (
_ = Data((&Value{}))
_ = Data((&Lines{}))
_ = Data((&Slice{}))
)
// Data contains table cell data.
type Data interface {
Width(m Measure) int
Height() int
Content(row int) string
String() string
}
// Value implements the Data interface for single value, su... | data.go | 0.628521 | 0.491883 | data.go | starcoder |
package fp
// Sort - sort the list
func (slice intSlice) Sort() intSlice {
return SortInts(slice)
}
// SortDesc - sort the list
func (slice intSlice) SortDesc() intSlice {
return SortIntsDesc(slice)
}
// SortPtr - sort the list
func (slice intSlicePtr) SortPtr() intSlicePtr {
return SortIntsPtr(slice)
}
// SortD... | fp/methodchainsort.go | 0.693992 | 0.458591 | methodchainsort.go | starcoder |
package path
import (
"fmt"
"go-snake-ai/state"
"go-snake-ai/tile"
"math/rand"
)
func NewBreadthFirstSearchLongest(bfs *BreadthFirstSearch) *BreadthFirstSearchLongest {
return &BreadthFirstSearchLongest{
bfs: bfs,
}
}
type PrefParallelDirection int
const (
PrefRandom PrefParallelDirection = iota
PrefNegat... | path/breadthfirstlongest.go | 0.55929 | 0.419053 | breadthfirstlongest.go | starcoder |
package texture
import (
"log"
"time"
"github.com/kasworld/h4o/_examples/app"
"github.com/kasworld/h4o/appwindow"
"github.com/kasworld/h4o/eventtype"
"github.com/kasworld/h4o/geometry"
"github.com/kasworld/h4o/graphic"
"github.com/kasworld/h4o/light"
"github.com/kasworld/h4o/material"
"github.com/kasworld/h... | _examples/demos/texture/box.go | 0.543348 | 0.450722 | box.go | starcoder |
package storage
import (
"errors"
"fmt"
"math"
"strings"
)
var (
_fltDig uint = 15
)
func fltDig(precision uint) uint {
if precision > _fltDig {
precision = _fltDig
}
return precision
}
type sizeType struct {
unit string
value float64
}
var _units = []sizeType{
{
unit: "B",
value: 1024 * 1024 *... | storage/size.go | 0.686895 | 0.468061 | size.go | starcoder |
package gomega
import (
"errors"
"fmt"
"reflect"
"time"
)
type asyncActualType uint
const (
asyncActualTypeEventually asyncActualType = iota
asyncActualTypeConsistently
)
type asyncActual struct {
asyncType asyncActualType
actualInput interface{}
timeoutInterval time.Du... | repos/gomega/async_actual.go | 0.746324 | 0.432782 | async_actual.go | starcoder |
package fp
/*
Note:
=====
The current implementation always pre-fetches the first value.
This could be optimized. It would be a problem with long-running ops in the
atom-creation, in case the value is never fetched by an output call.
For now, we will leave it this way.
*/
// IntSeq is a sequence of integers.
type Int... | terex/fp/fp.go | 0.676299 | 0.416025 | fp.go | starcoder |
package fp
func (l BoolArray) TakeWhile(p func(bool) bool) BoolArray {
var n int
size := len(l)
for n = 0; n < size && p(l[n]); n ++ {}
acc := make([]bool, n)
copy(acc, l)
return acc
}
func (l StringArray) TakeWhile(p func(string) bool) StringArray {
var n int
size := len(l)
for n = 0; n < size && ... | fp/bootstrap_array_takewhile.go | 0.656988 | 0.550607 | bootstrap_array_takewhile.go | starcoder |
package dfutils
import (
"github.com/pkg/errors"
"github.com/tobgu/qframe"
"github.com/tobgu/qframe/config/newqf"
"github.com/tobgu/qframe/types"
)
// LeftJoin is to do left join of the two data frames using values from the col column as a keys. The provided
// names map allows to rename columns of the right tabl... | left_join.go | 0.562898 | 0.589332 | left_join.go | starcoder |
package gmatrix
import (
"errors"
"math/rand"
)
type Matrix struct {
rowNum int
colNum int
datas []float64
}
func NewMatrix(r, c int, datas []float64) (*Matrix, error) {
if r <= 0 {
return nil, errors.New("invalid row length")
}
if c <= 0 {
return nil, errors.New("invalid col length")
}
if len(datas)... | gmatrix.go | 0.532668 | 0.432063 | gmatrix.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPExpressionOperator244AllOf struct for BTPExpressionOperator244AllOf
type BTPExpressionOperator244AllOf struct {
BtType *string `json:"btType,omitempty"`
ForExport *bool `json:"forExport,omitempty"`
GlobalNamespace *bool `json:"globalNamespace,omitempty"`
ImportMic... | onshape/model_btp_expression_operator_244_all_of.go | 0.71123 | 0.415373 | model_btp_expression_operator_244_all_of.go | starcoder |
package rangechain
import "github.com/halprin/rangechain/internal/generator"
// MapParallel will run the `mapFunction` parameter function against all the values in the chain in parallel. In that function, return what you want to change the value into or an optional error if an error is encountered. There is overhea... | link_chain_parallel.go | 0.806052 | 0.432183 | link_chain_parallel.go | starcoder |
package simulation
import (
"bytes"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
"github.com/gauss/gauss/v4/x/defi/types"
)
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
// Value to the correspond... | x/defi/simulation/decoder.go | 0.635562 | 0.436622 | decoder.go | starcoder |
package query
import (
"github.com/golang/protobuf/proto"
"github.com/google/gapid/test/robot/search"
)
// Replace substitues expr for match in the expression tree.
func (b Builder) Replace(match Builder, expr Builder) Builder {
return Expression(replace(b.Expression(), match.Expression(), expr.Expression()))
}
... | test/robot/search/query/replace.go | 0.673084 | 0.455441 | replace.go | starcoder |
package testdata
// Interface1 is a dummy interface to test the program output.
// This interface tests //-style method comments.
type Interface1 interface {
// Method1 is the first method of Interface1.
Method1(arg1 string, arg2 string) (result string, err error)
// Method2 is the second method of Interface1.
Met... | testdata/interfaces.go | 0.685318 | 0.418637 | interfaces.go | starcoder |
package home
// Recursively creates a tree from an array of conditions using the logic below
/** Treat conditions like a queue. Rules:
* If you reach a (, pop the condition, drop down a depth and assign results to root's children
* If you reach a ), pop the condition, pop back up a depth with the root
* If you reac... | app/home/unserialize.go | 0.805517 | 0.679907 | unserialize.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTTorusDescription1834 struct for BTTorusDescription1834
type BTTorusDescription1834 struct {
BTSurfaceDescription1564
Axis *BTVector3d389 `json:"axis,omitempty"`
BtType *string `json:"btType,omitempty"`
MajorRadius *float64 `json:"majorRadius,omitempty"`
MinorRadiu... | onshape/model_bt_torus_description_1834.go | 0.753467 | 0.446374 | model_bt_torus_description_1834.go | starcoder |
package fixed
import "math/bits"
const (
oneValue56 int64 = int64(1) << 56
roundValue56 uint64 = uint64(1) << 55
)
// the constants are fixed-point numbers with 56-bit frac part
const ln2 = int64(0xb17217f7d1cf78) // logₑ(2)
const invLog2E = ln2 // log₂(2)/log₂(e) = logₑ(2) => 1/log₂(e) = l... | fixed56.go | 0.604516 | 0.453564 | fixed56.go | starcoder |
package findface
import (
"context"
)
type FaceVerifyOptions struct {
// The first image external URL
FirstPhoto string `json:"photo1"`
// Array of bounding boxes for the faces on the first photo.
FirstBoundingBoxes []*BoundingBox `json:"bbox1,omitempty"`
// The second image external URL
SecondPhoto string `... | faces_verify.go | 0.839734 | 0.438424 | faces_verify.go | starcoder |
package labels
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/concerto/api/types"
"github.com/ingrammicro/concerto/utils"
"github.com/stretchr/testify/assert"
)
// GetLabelListMocked test mocked function
func GetLabelListMocked(t *testing.T, labelsIn []*types.Label) []*types.Label {
assert ... | api/labels/labels_api_mocked.go | 0.702632 | 0.491151 | labels_api_mocked.go | starcoder |
package voronoi
import (
"fmt"
"image"
"image/color"
"github.com/quasoft/draw"
)
var colors = []color.Color{
color.RGBA{0xff, 0x00, 0x00, 0xff},
color.RGBA{0x00, 0x00, 0xff, 0xff},
color.RGBA{0x00, 0xff, 0x00, 0xff},
color.RGBA{0x00, 0x00, 0x8b, 0xff},
color.RGBA{0x00, 0x8b, 0x8b, 0xff},
color.RGBA{0xb8, 0... | plotter.go | 0.628749 | 0.435781 | plotter.go | starcoder |
package response
import (
"github.com/Vladimiroff/vec2d"
"warcluster/entities"
)
type Edge struct {
Start *vec2d.Vector
End *vec2d.Vector
}
type Polygon struct {
Edges []Edge
}
type VoronoiDiagram struct {
baseResponse
Polygons []Polygon
}
func NewVoronoiDiagram(position *vec2d.Vector, resolution []uint6... | server/response/voronoi_diagram.go | 0.632616 | 0.590218 | voronoi_diagram.go | starcoder |
package input
import (
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/util/tls"
)
//-----------------------------------------------------------------... | lib/input/kafka_balanced.go | 0.671147 | 0.752899 | kafka_balanced.go | starcoder |
package types
import (
"fmt"
)
// Position : Handles three types of positions:
// index : 0-63
// x, y : 1-8
// algebraic : letter (a-h) plus index (1-8), ex "d4", or "f1"
type Position struct {
x, y int
}
// NewPosXY returns a new position
func NewPosXY(x, y int) *Position {
pos := Position{}
pos.SetXY(x... | internal/softchess.types/position.go | 0.827271 | 0.524821 | position.go | starcoder |
package main
import "fmt"
type State struct {
config map[int]*Effect
tape *Tape
}
func NewState(tape *Tape) *State {
cfg := make(map[int]*Effect)
return &State{
cfg,
tape,
}
}
// addEffect to the state of the machine
func (s *State) addEffect(val int, effect *Effect) {
s.config[val] = effect
}
type Cur... | Day25-Touring-Machine/main.go | 0.558086 | 0.400984 | main.go | starcoder |
package square
// Payment include an` itemizations` field that lists the items purchased, along with associated fees, modifiers, and discounts. Each itemization has an `itemization_type` field that indicates which of the following the itemization represents: <ul> <li>An item variation from the merchant's item library... | square/model_v1_payment_itemization.go | 0.806243 | 0.447158 | model_v1_payment_itemization.go | starcoder |
package main
import (
"fmt"
"math"
"regexp"
"strconv"
"github.com/konsti/aoc2021/utils/color"
"github.com/konsti/aoc2021/utils/input"
"github.com/konsti/aoc2021/utils/logging"
)
type Point struct {
X, Y, count int
}
type Vector struct {
Y, X int
A, B Point
}
func pointsToVector(p1, p2 Point) Vector {
re... | day05/day05.go | 0.679604 | 0.665723 | day05.go | starcoder |
package lexer
import "io"
// reader represents a buffered rune reader used by the scanner.
// It provides a fixed-length circular buffer that can be unread.
type reader struct {
r io.RuneScanner
i int // buffer index
n int // buffer char count
pos Pos // last read rune position
buf [3]struct {
ch rune
... | lexer/util_reader.go | 0.670177 | 0.41253 | util_reader.go | starcoder |
package scalers
import (
"math"
"sort"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
)
// Scaler allows transformation and back of the depths.
// As an example, see the `ZScore` struct. Usually, these
// will be 0-centered
type Scaler interface {
// Scale Converts from AdjustedDepth to a scaled value
Scal... | dcnv/scalers/scalers.go | 0.733833 | 0.40251 | scalers.go | starcoder |
package dataselector
import (
"sort"
"strings"
"time"
"github.com/aaawoyucheng/wayne/src/backend/common"
"github.com/aaawoyucheng/wayne/src/backend/models"
)
// GenericDataCell describes the interface of the data cell that contains all the necessary methods needed to perform
// complex data selection
// Generic... | src/backend/resources/dataselector/dataselector.go | 0.559771 | 0.458652 | dataselector.go | starcoder |
package types
type Type interface {
IsType()
Clone() Type
Equals(to Type, compareFlags bool) bool
SetFlag(f Flag)
UnsetFlag(f Flag)
GetFlag(f Flag) bool
Flags() Flag
}
type Unresolved struct{ Base }
type Void struct{ Base }
type Int struct {
Base
Size int
Signed bool
}
type Named struct {
Base
Name... | pkg/types/type.go | 0.621771 | 0.518059 | type.go | starcoder |
package shapes
import (
. "github.com/gabz57/goledmatrix/canvas"
. "github.com/gabz57/goledmatrix/components"
)
type Ring struct {
*Graphic
center Point
radiusExt, radiusInt int
fill bool
pixels []Pixel
}
func NewRing(graphic *Graphic, center Point, radiusExt, radiu... | components/shapes/ring.go | 0.750644 | 0.462291 | ring.go | starcoder |
package core
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"math"
"math/rand"
"os"
"os/exec"
"strconv"
"strings"
)
// OnlineIndexer is used to execute online indexing. The user can supply a map containing
// distances from original datasets and the indexer returns the coordinates of the
// specified dataset.
typ... | core/onlineindexer.go | 0.586996 | 0.557424 | onlineindexer.go | starcoder |
package utils
const mockChannelCreateResp = `{
"ok": true,
"channel": {
"id": "C0DEL09A5",
"name": "endeavor",
"is_channel": true,
"created": 1502833204,
"creator": "U061F7AUR",
"is_archived": false,
"is_general": false,
"name_normalized": "endeav... | mock_resp.go | 0.559651 | 0.42674 | mock_resp.go | starcoder |
package object
import (
"math"
"github.com/carlosroman/aun-otra-ray-tracer/go/internal/ray"
)
type cone struct {
obj
minimum, maximum float64
closed bool
}
func (c cone) LocalIntersect(r ray.Ray) (xs Intersections) {
a := math.Pow(r.Direction().GetX(), 2) -
math.Pow(r.Direction().GetY(), 2) +
ma... | go/internal/object/cone.go | 0.804483 | 0.462412 | cone.go | starcoder |
package primitives
import (
"github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/algebra"
"github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/canvas"
"math"
)
type Triangle struct {
parent Shape
transform *algebra.Matrix
material *canvas.Material
p1 *algebra.Vector
p2 *algeb... | pkg/geometry/primitives/triangle.go | 0.679604 | 0.590012 | triangle.go | starcoder |
package arib
import (
"encoding/binary"
"github.com/drillbits/go-ts/ts"
)
// NetworkID is a network_id which serves as a label to identify the delivery
// system, about which the NIT informs, from any other delivery system.
// The standardization organization shall specify allocation of the value of
// this field... | arib/nit.go | 0.73029 | 0.463262 | nit.go | starcoder |
package slipstream
// Simple8bThresholdSamples defines the number of samples per message required before using simple-8b encoding
const Simple8bThresholdSamples = 16
// DefaultDeltaEncodingLayers defines the default number of layers of delta encoding. 0 is no delta encoding (just use varint), 1 is delta encoding, etc... | slipstream.go | 0.744285 | 0.501648 | slipstream.go | starcoder |
package text
import "fmt"
// Value types
// I32 signed int32 value type
const I32 Atom = "i32"
// Param creates a func parameter
func Param(id AtomIdentifier, valType Atom) SymbolicExpression {
return SymbolicExpressionList{
Atom("param"),
id,
valType,
}
}
// Result creates a func result
func Result(valTyp... | wasm/text/helpers.go | 0.595845 | 0.510252 | helpers.go | starcoder |
package hedera
import (
"fmt"
"github.com/pkg/errors"
"math"
"regexp"
"strconv"
)
// Hbar is a typesafe wrapper around values of HBAR providing foolproof conversions to other denominations.
type Hbar struct {
tinybar int64
}
// MaxHbar is the maximum amount the Hbar type can wrap.
var MaxHbar = Hbar{math.MaxIn... | vendor/github.com/hashgraph/hedera-sdk-go/v2/hbar.go | 0.820757 | 0.447943 | hbar.go | starcoder |
package expect
import (
"bytes"
"encoding/json"
"reflect"
"strings"
"time"
)
type JSON string
var NotNil = struct{}{}
type Expectation struct {
actual interface{}
others []interface{}
Greater *ThanAssertion
GreaterOrEqual *ToAssertion
Less *ThanAssertion
LessOrEqual *T... | expect.go | 0.562177 | 0.637031 | expect.go | starcoder |
package band
import (
pb_lorawan "github.com/TheThingsNetwork/ttn/api/protocol/lorawan"
"github.com/TheThingsNetwork/ttn/utils/errors"
"github.com/brocaar/lorawan"
lora "github.com/brocaar/lorawan/band"
)
// FrequencyPlan includes band configuration and CFList
type FrequencyPlan struct {
lora.Band
CFList *lora... | core/band/band.go | 0.66236 | 0.46794 | band.go | starcoder |
package math
import (
"bytes"
"encoding/gob"
"errors"
"fmt"
"io"
"os"
"strconv"
"github.com/bitflow-stream/go-bitflow/bitflow"
"github.com/bitflow-stream/go-bitflow/script/reg"
"github.com/bitflow-stream/go-bitflow/steps"
log "github.com/sirupsen/logrus"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"... | steps/math/pca.go | 0.610105 | 0.433382 | pca.go | starcoder |
package main
import (
"fmt"
"math"
)
func gaussianElimination(a [][]float64) {
singular := false
rows := len(a)
cols := len(a[0])
for c, r := 0, 0; c < cols && r < rows; c++ {
// 1. find highest value in column below row to be pivot
p, highest := r, 0.
for i, row := range a[r:] {
if abs := math.Abs(ro... | contents/gaussian_elimination/code/go/gaussian_elimination.go | 0.539226 | 0.477432 | gaussian_elimination.go | starcoder |
package chess
import (
"strconv"
"strings"
)
// bitboard is a board representation encoded in an unsigned 64-bit integer. The
// 64 board positions begin with A1 as the most significant bit and H8 as the least.
type bitboard uint64
func newBitboard(m map[Square]bool) bitboard {
s := ""
for sq := 0; sq < numOfSq... | vendor/github.com/notnil/chess/bitboard.go | 0.639286 | 0.463141 | bitboard.go | starcoder |
package ubigraph
type EdgeID int
type EdgeStyleID int
// NewEdge creates a edge on the graph connected to two vertices identified by arguments.
// It returns an Ubigraph server selected edge ID on success.
func (g *Graph) NewEdge(x, y VertexID) (EdgeID, error) {
method := "ubigraph.new_edge"
status, err := g.serve... | ubigraph/edges.go | 0.80213 | 0.434701 | edges.go | starcoder |
package funcs
import (
"fmt"
"math/big"
"math/cmplx"
"reflect"
)
const (
indexOfErrorMsg = "slc must be a slice"
valueOfKeyErrorMsg = "mp must be a map"
mapErrorMsg = "fn must be a non-nil function of one argument of any type that returns one value of any type"
mapToErrorMsg = "fn must be a no... | funcs/funcs.go | 0.710729 | 0.419826 | funcs.go | starcoder |
package elements
import "github.com/fileformats/graphics/jt/model"
// Point Light Attribute Element specifies a light source emitting light from a specified position, along a
// specified direction, and with a specified spread angle
type PointLightAttribute struct {
BaseLight
// Version Number is the version identi... | jt/segments/elements/PointLightAttribute.go | 0.850344 | 0.617801 | PointLightAttribute.go | starcoder |
package mathutil
import "math"
// MinFloat32 takes the min
func MinFloat32(a, b float32) float32 {
return float32(math.Min(float64(a), float64(b)))
}
// MinFloat64 takes the min
func MinFloat64(a, b float64) float64 {
return math.Min(a, b)
}
// MinInt takes the min
func MinInt(a, b int) int {
if a < b {
return... | pkg/mathutil/minmax.go | 0.759761 | 0.57529 | minmax.go | starcoder |
package sudoku
// iteration is a single iteration of a puzzle.
type iteration struct {
// index is the cell index that this iteration will effect
index int
// minValue is the min value this iteration used when effecting the cell
minValue int
puzzleSize int
sectionSize int
cells group
rows [][]in... | iteration.go | 0.666605 | 0.519765 | iteration.go | starcoder |
package mailbox
import (
"crypto/rand"
"runtime/debug"
"github.com/kkdai/bstream"
"github.com/lightningnetwork/lnd/aezeed"
"golang.org/x/crypto/scrypt"
)
const (
// NumPasswordWords is the number of words we use for the pairing
// phrase.
NumPasswordWords = 10
// NumPasswordBytes is the number of bytes we ... | mailbox/crypto.go | 0.664214 | 0.433202 | crypto.go | starcoder |
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
"github.com/spf13/cobra"
)
type job struct {
weight int
length int
}
var filePath string
var schedulesJobsDiffCmd = &cobra.Command{
Use: "diff",
Short: "Sum of weighted completion times of the resulting scheduled jobs in decreasing or... | algorithms-greedy/week1/main.go | 0.644449 | 0.509703 | main.go | starcoder |
package structs
type PacketHeader struct {
M_packetFormat uint16 // 2018
M_packetVersion uint8 // Version of this packet type, all start from 1
M_packetId uint8 // Identifier for the packet type, see below
... | f1_go/structs/structs.go | 0.613815 | 0.449634 | structs.go | starcoder |
package types
import (
"encoding/json"
"errors"
"fmt"
"strconv"
)
// Nilable is implemented by a type that acts as a wrapper round a native type to track whether a value has actually been set.
type Nilable interface {
// MarshalJSON converts the contained value to JSON or nil if no value is set.
MarshalJSON() ... | types/nilable.go | 0.782746 | 0.4856 | nilable.go | starcoder |
package imgproc
import (
"errors"
"github.com/disintegration/imaging"
"image"
_ "image/gif"
_ "image/jpeg"
"image/png"
_ "image/png"
"os"
)
// IsGrayscale : check if an image is in grayscale.
func IsGrayscale(img image.Image) bool {
// Gets the width and height of the image
bounds := img.Bounds()
w, h := b... | imgproc.go | 0.811713 | 0.572962 | imgproc.go | starcoder |
package simple
type ListNode struct {
Val int
Next *ListNode
}
/** Add two numbers in a linklist: https://leetcode.com/problems/add-two-numbers/
numbers in linked list are in reverse order
1. add them from 2 list from begin to end
2. if have carry after all done, need add additional node for carry
*/
func AddTwoN... | Algorithm-go/simple/linklist.go | 0.846419 | 0.415254 | linklist.go | starcoder |
package slice
import (
"fmt"
"math/rand"
"sort"
)
func Map[T, R any](slice []T, f func(T) R) []R {
result := make([]R, len(slice))
for i, v := range slice {
result[i] = f(v)
}
return result
}
func Reduce[T, R any](slice []T, f func(R, T) R, initial R) R {
result := initial
for _, v := range slice {
resu... | slice/slice.go | 0.625896 | 0.462776 | slice.go | starcoder |
package number
import (
"math"
)
// ConvDecimalToBinary converts decimal (base 10) to binary (base 2) in 0-1 array format
func ConvDecimalToBinary(value int) []int {
if value == 0 {
return []int{0}
}
binary := []int{}
for value != 0 {
binary = append([]int{value % 2}, binary...)
value = value / 2
}
re... | datastructures/number/number.go | 0.84489 | 0.501221 | number.go | starcoder |
package fsm
import (
"bytes"
"fmt"
"sort"
)
// VisualizeType the type of the visualization
type VisualizeType string
const (
// GRAPHVIZ the type for graphviz output (http://www.webgraphviz.com/)
GRAPHVIZ VisualizeType = "graphviz"
// MERMAID the type for mermaid output (https://mermaid-js.github.io/mermaid-li... | utils.go | 0.651909 | 0.516291 | utils.go | starcoder |
package main
/*
A channel is a communication mechanism that lets one goroutine
send values to another goroutine. Each channel is a conduit for values
of a particular type, called the channel's element type.
The type of a channel whose elements have type int is written:
chan int.
To create a channel, we use the built-... | src/chapter_8/channels.go | 0.808597 | 0.592519 | channels.go | starcoder |
package trie
type ternNode struct {
Value *interface{}
Code rune
left *ternNode
child *ternNode
right *ternNode
}
// TernaryST is a symbol table specifically for string indexed keys.
type TernaryST struct {
root *ternNode
count int
}
// NewTernaryST creates a trie.
func NewTernaryST() *TernaryST {
return... | ternary_st.go | 0.803097 | 0.456289 | ternary_st.go | starcoder |
package quickhull
type meshBuilder struct {
// Mesh data
faces []meshBuilderFace
halfEdges []HalfEdge
// When the mesh is modified and Faces and half edges are removed from it, we do not actually remove them from the container vectors.
// Insted, they are marked as disabled which means that the indices can b... | mesh_builder.go | 0.746601 | 0.592578 | mesh_builder.go | starcoder |
package table
import (
"fmt"
"strconv"
"strings"
"time"
)
// Columns represents a slice of string with tabular functions.
type Columns []string
// Index returns the column index of the requested column name.
// A value of `-1` is returned if the coliumn name is not found.
func (cols Columns) Index(colName string... | data/table/column.go | 0.778397 | 0.445831 | column.go | starcoder |
package series
import (
"fmt"
"log"
"github.com/ptiger10/pd/internal/values"
"github.com/ptiger10/pd/options"
)
// Element returns information about the value and index labels at this position but panics if an out-of-range position is provided.
func (s *Series) Element(p int) Element {
idxElems := s.index.Elem... | series/select.go | 0.757166 | 0.40592 | select.go | starcoder |
// Copyright 2018 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.
package main
const (
Upper = true
blas_Upper = 121
badTriangle = "bad triangle"
)
// Triangular represents a triangular matrix. Triangular matrices... | test/fixedbugs/issue25776.go | 0.83056 | 0.441372 | issue25776.go | starcoder |
package model
// Appflowlog. Enable logging of AppFlow information for the specified service group.<br>Default value: ENABLED<br>Possible values = ENABLED, DISABLED.
// Autoscale. Auto scale option for a servicegroup.<br>Default value: DISABLED<br>Possible values = DISABLED, DNS, POLICY.
// Boundtd. Integer value ... | model/server.go | 0.728265 | 0.441793 | server.go | starcoder |
package lib
import (
"fmt"
"sort"
"strings"
"github.com/dunelang/dune"
)
func init() {
dune.RegisterLib(libArray, `
interface Array<T> {
[n: number]: T
slice(start?: number, count?: number): Array<T>
range(start?: number, end?: number): Array<T>
append(v: T[]): T[]
push(...v: T[]): void
... | lib/array.go | 0.576065 | 0.459137 | array.go | starcoder |
Goiardi is an implementation of the Chef server (http://www.opscode.com) written
in Go. It can either run entirely in memory with the option to save and load the
in-memory data and search indexes to and from disk, drawing inspiration from
chef-zero, or it can use MySQL as its storage backend.
It is a work in progress... | doc.go | 0.632162 | 0.415136 | doc.go | starcoder |
package sqlite
// BindIndexStart is the index of the first parameter when using the Stmt.Bind*
// functions.
const BindIndexStart = 1
// BindIncrementor returns an Incrementor that starts on 1, the first index
// used in Stmt.Bind* functions. This is provided as syntactic sugar for
// binding parameter values to a St... | incrementor.go | 0.643777 | 0.650495 | incrementor.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTSurfaceDescription1564 struct for BTSurfaceDescription1564
type BTSurfaceDescription1564 struct {
BtType *string `json:"btType,omitempty"`
Type *string `json:"type,omitempty"`
}
// NewBTSurfaceDescription1564 instantiates a new BTSurfaceDescription1564 object
// Thi... | onshape/model_bt_surface_description_1564.go | 0.683525 | 0.531939 | model_bt_surface_description_1564.go | starcoder |
package ll
import (
"context"
"fmt"
"math"
"math/rand"
"github.com/pogodevorg/pgoapi-go/api"
"googlemaps.github.io/maps"
)
var GeoCodeFailure = fmt.Errorf("Unable to geocode requested location into a lat/lon pair")
type Coord struct {
maps.LatLng
Elevation float64
}
func (c *Coord) jitter(byUpTo int) *Coo... | ll/coord.go | 0.706899 | 0.425187 | coord.go | starcoder |
package nodeset
import (
"fmt"
"github.com/insolar/insolar/network/consensus/gcpv2/api/member"
"github.com/insolar/insolar/network/consensus/gcpv2/phasebundle/stats"
)
type ConsensusStat uint8
const (
ConsensusStatUnknown ConsensusStat = iota
ConsensusStatTrusted
ConsensusStatDoubted
ConsensusStatMissingTh... | network/consensus/gcpv2/phasebundle/nodeset/consensus_stats.go | 0.511717 | 0.439507 | consensus_stats.go | starcoder |
package iso8601
// ValidFlags is a bitset type used to configure the behavior of the Valid
//function.
type ValidFlags int
const (
// Strict is a validation flag used to represent a string iso8601 validation
// (this is the default).
Strict ValidFlags = 0
// AllowSpaceSeparator allows the presence of a space ins... | internal/encoding/iso8601/valid.go | 0.683842 | 0.588948 | valid.go | starcoder |
package dsl
import (
"regexp"
"time"
"github.com/pivotal-golang/lager"
)
//Matcher objects can test an Entry, returning true/false
type Matcher interface {
Match(entry Entry) bool
}
//MatcherFunc makes it easy to create Matchers from bare functions
type MatcherFunc func(Entry) bool
//Match satisifes the Matche... | dsl/matchers.go | 0.768733 | 0.550064 | matchers.go | starcoder |
package slab
import (
"fmt"
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"
)
// Decompose is based on Dobkin and Lipton's wor... | dcel/pointLoc/bench/slab/slabDecomp.go | 0.658637 | 0.424651 | slabDecomp.go | starcoder |
package DateUtils
import (
"time"
"github.com/sjsdfg/common-lang-in-go/IntUtils"
)
func GetStartOfHour(now time.Time) time.Time {
return time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location())
}
func GetEndOfHour(now time.Time) time.Time {
return time.Date(now.Year(), now.Month(), now... | DateUtils/date_utils.go | 0.643105 | 0.428353 | date_utils.go | starcoder |
package colony
import (
"image"
"image/color"
"image/draw"
"math"
"math/rand"
"engo.io/engo/common"
)
type DustRegion struct {
Region *Region
}
func (dr *DustRegion) GenerateTiles() {
dr.Region.MakeTiles()
for i, _ := range dr.Region.Tiles {
var tile *Tile
if rand.Float32() > 0.5 {
tile = dustpat... | lib-colony/dust.go | 0.708213 | 0.418637 | dust.go | starcoder |
package continuous
import (
"github.com/jtejido/linear"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Normal (A.K.A. Gaussian) distribution
// https://en.wikipedia.org/wiki/Normal_distribution
type Normal struct {
location, scale float64 // μ (location), σ (scale)
src ... | dist/continuous/normal.go | 0.797557 | 0.514522 | normal.go | starcoder |
package asciiturtle
import (
"fmt"
"math"
"strings"
)
const degToRad = math.Pi / 180.0
type Pen struct {
Canvas Canvas
X, Y int
char byte
heading float64
penUp bool
}
func NewPen(canvas Canvas, heading float64, x, y int) (*Pen, error) {
if canvas == nil {
return nil, fmt.Errorf("canvas must not ... | internal/asciiturtle/asciiturtle.go | 0.675765 | 0.519034 | asciiturtle.go | starcoder |
package physics
import "github.com/faiface/pixel"
type moveable interface {
move(float64) bool
pos() pixel.Vec
setPos(pixel.Vec)
vel() pixel.Vec
setVel(pixel.Vec)
dest() pixel.Vec
setDest(pixel.Vec)
}
type linearPointMovingStrategy struct {
p pixel.Vec
v pixel.Vec
dst pixel.Vec
st... | physics/moveable.go | 0.694717 | 0.487002 | moveable.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.