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 gointgeo
// Defines a 2D line by two of its points.
// Two definitions of the same line
// which do not have points matching in the same order
// are not considered equal.
// Use the Line method to get a structure with equality
// which represents the equality of the defined lines.
type Line2DDefinition struct... | line_2d_definition.go | 0.89869 | 0.742748 | line_2d_definition.go | starcoder |
package runes
// CloneSlice return a copy of the supplied rune slice
func CloneSlice(r []rune) []rune {
return append([]rune(nil), r...)
}
// Concat joins a number of rune slices together
func Concat(r ...[]rune) []rune {
if len(r) == 0 {
return []rune(nil)
} else if len(r) == 1 {
return r[0]
} else {
res :... | runes.go | 0.802439 | 0.595228 | runes.go | starcoder |
package main
type IndexEntry struct {
K CompositeKey
V bool
}
type Index struct {
IndexEntry IndexEntry
h int
len int
children [2]*Index
}
func (node *Index) Height() int {
if node == nil {
return 0
}
return node.h
}
// suffix Index is needed because this will get specialised in codegen... | examples/composite_index/composite.go | 0.576065 | 0.411229 | composite.go | starcoder |
package rnd
import (
"math"
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/plt"
"github.com/cpmech/gosl/utl"
)
// DistFrechet implements the Frechet / Type II Extreme Value Distribution (largest value)
type DistFrechet struct {
L float64 // location. default = 0
C float64 // scale. default = 1
A float64... | rnd/dist_frechet.go | 0.76782 | 0.432962 | dist_frechet.go | starcoder |
package svgd
import (
"errors"
"fmt"
"github.com/ajstarks/svgo"
"io"
"math"
"math/rand"
)
type LinearCategory struct {
Name string
Color string
LineWidth int
values []float64
}
func (lc *LinearCategory) SetValues(vals []float64) {
lc.values = append(lc.values, vals...)
}
type LinearDiagram stru... | linear.go | 0.641085 | 0.421433 | linear.go | starcoder |
package mathx
import (
"bitbucket.org/dtolpin/infergo/ad"
"math"
)
// Sigmoid computes the sigmoid function 1/(1 + exp(-x)).
func Sigm(x float64) float64 {
return 1. / (1. + math.Exp(-x))
}
// LogDSigm is log d Sigm(x) / dx, used for computing log
// probability in the presence of sigmoid-transformed variables.
f... | mathx/mathx.go | 0.750278 | 0.559892 | mathx.go | starcoder |
package term
import (
"strconv"
)
const (
MinusOneMinusOne = 4294967295
)
type Position struct {
Row int
Column int
hash int
}
// Hash - combines a row and a column into a single integer. Note that it doesn't work with very large numbers.
func Hash(column, row int) int {
return ((column & 0xFFFF) << 16) ... | position.go | 0.757346 | 0.497742 | position.go | starcoder |
package eval
import (
"errors"
"reflect"
)
var (
intType reflect.Type = reflect.TypeOf(int(0))
i8 reflect.Type = reflect.TypeOf(int8(0))
i16 reflect.Type = reflect.TypeOf(int16(0))
i32 reflect.Type = reflect.TypeOf(int32(0))
i64 reflect.Type = reflect.TypeOf(int64(0))
uintType reflect.Type = reflect.TypeOf(u... | Godeps/_workspace/src/github.com/0xfaded/eval/builtins.go | 0.532182 | 0.629718 | builtins.go | starcoder |
package openflow
import (
"fmt"
"os/exec"
"strings"
"github.com/quilt/quilt/minion/ipdef"
"github.com/quilt/quilt/minion/ovsdb"
)
/* OpenFlow Psuedocode -- Please, for the love of God, keep this updated.
OpenFlow is extremely difficult to reason about -- especially when its buried in Go code.
This comment aims... | minion/network/openflow/openflow.go | 0.520496 | 0.524882 | openflow.go | starcoder |
package canvas
import (
"github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/algebra"
"github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/noise"
"math"
)
var PATTERNOFFSET float64 = 500
//Pattern represents a pattern of colors
type Pattern struct {
a *Color
b *Color
getPatter... | pkg/canvas/pattern.go | 0.820505 | 0.585101 | pattern.go | starcoder |
package draw2dAnimation
import (
"bufio"
"fmt"
imageLibrary "image"
"image/draw"
"image/png"
"image/color"
"os"
)
// The image struct contains a set of all figures and take operations over them like drawing, updating, adding, deleting or filtering figures. Can save the result as a .png file. The default clear ... | draw2dAnimation/image.go | 0.798462 | 0.534977 | image.go | starcoder |
package main
import (
"bufio"
"fmt"
"github.com/golang-demos/chalk"
"os"
"strings"
"time"
)
// ScoreItem holds data on a scoreboard item's name, current point value, and ID
type ScoreItem struct {
name string
points int
id int
}
// GenerateBoard creates blank (0's) data for each playable option
func G... | scoreboard.go | 0.543348 | 0.405066 | scoreboard.go | starcoder |
package gglm
//Note: We don't use the Swizzle interface for add/sub because the interface doesn't allow inling :(
import (
"fmt"
"math"
)
var _ Swizzle2 = &Vec2{}
var _ fmt.Stringer = &Vec2{}
type Vec2 struct {
Data [2]float32
}
func (v *Vec2) X() float32 {
return v.Data[0]
}
func (v *Vec2) Y() float32 {
ret... | gglm/vec2.go | 0.815894 | 0.439026 | vec2.go | starcoder |
package transformations
import (
"fmt"
"math"
"sort"
"github.com/apache/arrow/go/arrow/array"
"github.com/influxdata/flux"
"github.com/influxdata/flux/execute"
"github.com/influxdata/flux/memory"
"github.com/influxdata/flux/plan"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/tdigest"
"github... | vendor/github.com/influxdata/flux/functions/transformations/percentile.go | 0.821188 | 0.42674 | percentile.go | starcoder |
package govalidator
import (
"reflect"
"regexp"
"sync"
)
// Validator is a wrapper for a validator function that returns bool and accepts string.
type Validator func(str string) bool
// CustomTypeValidator is a wrapper for validator functions that returns bool and accepts any type.
// The second parameter should ... | vendor/github.com/go-swagger/go-swagger/vendor/github.com/asaskevich/govalidator/types.go | 0.690037 | 0.503235 | types.go | starcoder |
package datadog
import (
"encoding/json"
)
// DistributionWidgetYAxis Y Axis controls for the distribution widget.
type DistributionWidgetYAxis struct {
// True includes zero.
IncludeZero *bool `json:"include_zero,omitempty"`
// The label of the axis to display on the graph.
Label *string `json:"label,omitempty... | api/v1/datadog/model_distribution_widget_y_axis.go | 0.81538 | 0.404331 | model_distribution_widget_y_axis.go | starcoder |
package api
import (
"encoding/json"
)
// MeasurementSchemaColumn Definition of a measurement column
type MeasurementSchemaColumn struct {
Name string `json:"name" yaml:"name"`
Type ColumnSemanticType `json:"type" yaml:"type"`
DataType *ColumnDataType `json:"dataType,omitempty" yaml:"dataT... | api/model_measurement_schema_column.gen.go | 0.75392 | 0.432543 | model_measurement_schema_column.gen.go | starcoder |
package main
import "math"
const (
// Values for handling field of view algorithm execution.
FOVRays = 360 // Whole area around player; it may not work properly with other values.
FOVLength = 5 // Sight range.
FOVStep = 1
)
var (
// Slices to store FOV Rays values.
// Should be immutable, but Go doesn't ... | fov.go | 0.563138 | 0.405066 | fov.go | starcoder |
package processor
import (
"errors"
"fmt"
"sort"
"strconv"
"strings"
"time"
"github.com/Jeffail/benthos/v3/internal/bloblang"
"github.com/Jeffail/benthos/v3/internal/bloblang/field"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metr... | lib/processor/metric.go | 0.856663 | 0.572723 | metric.go | starcoder |
package vision
import (
"log"
pb "google.golang.org/genproto/googleapis/cloud/vision/v1"
)
// FaceLandmarks contains the positions of facial features detected by the service.
type FaceLandmarks struct {
Eyebrows Eyebrows
Eyes Eyes
Ears Ears
Nose Nose
Mouth Mouth
Chin Chin
Forehead *pb.Po... | vendor/cloud.google.com/go/vision/apiv1/face.go | 0.62601 | 0.431045 | face.go | starcoder |
2D Rendering Code
*/
//-----------------------------------------------------------------------------
package render
import (
"image"
"image/color"
"image/png"
"math"
"os"
"github.com/deadsy/sdfx/sdf"
"github.com/llgcode/draw2d/draw2dimg"
)
//-----------------------------------------------------------------... | render/png.go | 0.735831 | 0.498291 | png.go | starcoder |
package graph
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// AssignedPlan provides operations to manage the drive singleton.
type AssignedPlan st... | models/microsoft/graph/assigned_plan.go | 0.735547 | 0.401101 | assigned_plan.go | starcoder |
// Package aes implements AES encryption (formerly Rijndael), as defined in
// U.S. Federal Information Processing Standards Publication 197.
package aes
// This file contains AES constants - 8720 bytes of initialized data.
// http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf
// AES is based on the ma... | src/pkg/crypto/aes/const.go | 0.515864 | 0.660665 | const.go | starcoder |
package cbor
import (
"fmt"
"io"
"github.com/ipsn/go-ipfs/gxlibs/github.com/polydawn/refmt/shared"
. "github.com/ipsn/go-ipfs/gxlibs/github.com/polydawn/refmt/tok"
)
type Decoder struct {
r shared.SlickReader
stack []decoderStep // When empty, and step returns done, all done.
step decoderStep // Shortcut ... | gxlibs/github.com/polydawn/refmt/cbor/cborDecoder.go | 0.597725 | 0.44348 | cborDecoder.go | starcoder |
package smooth
type Interface interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
}
var leo []int
func init() {
leo = []int{1, 1}
length := 2
for leo[length-1] < 1000000000 {
leo = append(leo, leo[length-1]+leo[length-2]+1)
length++
}
}
// Stringify will reorder the root nodes to make sure that they... | data/go/3fcc40b96b7459e232242c557c5201f7_smooth.go | 0.595845 | 0.420094 | 3fcc40b96b7459e232242c557c5201f7_smooth.go | starcoder |
package types
import (
"math/big"
"sort"
"strings"
)
// Coin def
type CoinWs struct {
Denom string `json:"denom"`
Amount string `json:"amount"`
}
type Coin struct {
Denom string `json:"denom"`
Amount int64 `json:"amount"`
}
type Int struct {
I *big.Int
}
func (i *Int) Set(x int) {
if i.I == nil {
i.I... | common/types/coins.go | 0.639061 | 0.490114 | coins.go | starcoder |
package pcg
// T is a pcg generator. The zero value is valid.
type T struct{ state uint64 }
// mul is the multiplier for the LCG step.
const (
mul = 6364136223846793005
inc = 11981177638785157926
)
// New constructs a pcg with the given state.
func New(state uint64) T { return T{state} }
// next advances and retu... | pcg.go | 0.775095 | 0.439807 | pcg.go | starcoder |
package coapmsg
// OptionID identifies an option in a message.
type OptionId uint16
/*
+-----+----+---+---+---+----------------+--------+--------+---------+
| No. | C | U | N | R | Name | Format | Length | Default |
+-----+----+---+---+---+----------------+--------+--------+---------+
| 1 | x... | coapmsg/optionId.go | 0.597608 | 0.420778 | optionId.go | starcoder |
package gator
import (
"errors"
"reflect"
"strconv"
"github.com/ShaleApps/gator/Godeps/_workspace/src/github.com/onsi/gomega/matchers"
)
const (
regexEmail = `^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$`
regexHexColor = `^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`
regexURL = `^(https?:\/\/)?([\da-z\.-]+)... | func.go | 0.71103 | 0.409398 | func.go | starcoder |
package memqueue
import (
"fmt"
"github.com/elastic/elastic-agent-libs/logp"
)
// Internal event ring buffer.
// The ring is split into 2 contiguous regions.
// Events are appended to region A until it grows to the end of the internal
// buffer. Then region B is created at the beginning of the internal buffer,
//... | libbeat/publisher/queue/memqueue/ringbuf.go | 0.766905 | 0.513729 | ringbuf.go | starcoder |
package dns
// NameUsed sets the RRs in the prereq section to
// "Name is in use" RRs. RFC 2136 section 2.4.4.
func (u *Msg) NameUsed(rr []RR) {
if u.Answer == nil {
u.Answer = make([]RR, 0, len(rr))
}
for _, r := range rr {
u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: ... | vendor/github.com/miekg/dns/update.go | 0.546496 | 0.401629 | update.go | starcoder |
package menge
import (
"fmt"
"strings"
)
// Complex128Set represents a set of complex128 elements.
type Complex128Set map[complex128]struct{}
// Add adds zero or more elements to the set.
func (s Complex128Set) Add(elems ...complex128) {
for _, e := range elems {
s[e] = struct{}{}
}
}
// Remove removes zero o... | complex128.go | 0.794624 | 0.461441 | complex128.go | starcoder |
package neural
// backpropagate completes the backpropagation method.
import (
"errors"
"log"
"math/rand"
"time"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
)
var randSource = rand.NewSource(time.Now().UnixNano())
var randGen = rand.New(randSource)
// Network contains all of the information
// that d... | neural/network.go | 0.766381 | 0.468791 | network.go | starcoder |
package geom
// A MultiPolygon is a collection of Polygons.
type MultiPolygon struct {
geom3
}
// NewMultiPolygon returns a new MultiPolygon with no Polygons.
func NewMultiPolygon(layout Layout) *MultiPolygon {
return NewMultiPolygonFlat(layout, nil, nil)
}
// NewMultiPolygonFlat returns a new MultiPolygon with th... | vendor/github.com/twpayne/go-geom/multipolygon.go | 0.861626 | 0.649203 | multipolygon.go | starcoder |
package man
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderCommandPage() string {
figs := A{
"FigClient": RenderFigurePngSvg("Circuit client connected to a server.", "client", "500px"),
"FigServerAnchor": RenderFigurePngSvg("Circuit servers correspond to root-level anchors.", ... | gocircuit.org/man/cmd.go | 0.761095 | 0.636918 | cmd.go | starcoder |
package rx
import (
"sync"
)
//jig:template CombineLatest<Foo>
//jig:needs ObservableObservable<Foo> CombineLatestAll
// CombineLatest will subscribe to all ObservableFoos. It will then wait for
// all of them to emit before emitting the first slice. Whenever any of the
// subscribed observables emits, a new slice ... | generic/combining.go | 0.744842 | 0.542136 | combining.go | starcoder |
package wasmlib
import (
"encoding/binary"
"strconv"
)
type ScImmutableAddress struct {
objID int32
keyID Key32
}
func NewScImmutableAddress(objID int32, keyID Key32) ScImmutableAddress {
return ScImmutableAddress{objID: objID, keyID: keyID}
}
func (o ScImmutableAddress) Exists() bool {
return Exists(o.objID... | packages/vm/wasmlib/immutable.go | 0.692642 | 0.53127 | immutable.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTNotFilter165 struct for BTNotFilter165
type BTNotFilter165 struct {
BTQueryFilter183
BtType *string `json:"btType,omitempty"`
Operand *BTQueryFilter183 `json:"operand,omitempty"`
}
// NewBTNotFilter165 instantiates a new BTNotFilter165 object
// This constructor wi... | onshape/model_bt_not_filter_165.go | 0.660939 | 0.409044 | model_bt_not_filter_165.go | starcoder |
package tensor
import (
"github.com/pkg/errors"
"gorgonia.org/tensor/internal/storage"
)
// Gt performs a > b elementwise. Both a and b must have the same shape.
// Acceptable FuncOpts are: UseUnsafe(), AsSameType(), WithReuse().
//UseUnsafe() will ensure that the same type is returned.
// Tensors used in WithReus... | defaultengine_cmp.go | 0.638723 | 0.516108 | defaultengine_cmp.go | starcoder |
package geohash
import "math"
var (
// const used to interleave64 and deinterleave64
// From: https://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN
s = []uint32{0, 1, 2, 4, 8, 16}
b = []uint64{
0x5555555555555555,
0x3333333333333333,
0x0F0F0F0F0F0F0F0F,
0x00FF00FF00FF00FF,
0x0000FFFF0000F... | common/geohash/util.go | 0.766905 | 0.571886 | util.go | starcoder |
package main
import (
"github.com/gen2brain/raylib-go/raylib"
"math"
)
type Enemy struct {
lvl *Level
position rl.Vector2
texture rl.Texture2D
speed rl.Vector2
target rl.Vector2
defaultTarget rl.Vector2
savedState int
}
func (e *Enemy) SetTarget(target rl.Vector2) {
e... | enemy.go | 0.549399 | 0.577972 | enemy.go | starcoder |
package internal
import (
"fmt"
)
var deviceNames = map[uint16]string{
11: "DC Brick",
13: "Master Brick",
14: "Servo Brick",
15: "Stepper Brick",
16: "IMU Brick",
17: "RED Brick",
18: "IMU Brick 2.0",
19: "Silent Stepper Brick",
21: "Ambient Light Bricklet",
23: "Current12 Br... | internal/device_display_names.go | 0.500244 | 0.879923 | device_display_names.go | starcoder |
package manual
func manifesto() string {
return `Scarlet was built on the following ideas and principles:
1. Soft-Magic Themed
Scarlet is a soft-magic themed tool. Programming is a kind of hard-magic
with an unrelenting vortex of soul sucking rationalism veiled beneath
its technoshiny exterior --probably why... | _manual/manifesto.go | 0.512449 | 0.589953 | manifesto.go | starcoder |
package sql
import (
"database/sql/driver"
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
type Schema []*Column
func (s Schema) CheckRow(row Row) error {
expected := len(s)
got := len(row)
if expected != got {
return fmt.Errorf("expected %d values, got %d", expected, got)
}
for idx, f := range s {
v :=... | sql/type.go | 0.745398 | 0.416085 | type.go | starcoder |
// TeamShooterScenario is a scenario which is designed to emulate the
// approximate behavior to open match that a skill based team game would have.
// It doesn't try to provide good matchmaking for real players. There are three
// arguments used:
// mode: The game mode the players wants to play in. mode is a hard par... | examples/scale/scenarios/teamshooter/teamshooter.go | 0.635109 | 0.526951 | teamshooter.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// Simulation
type Simulation struct {
Entity
// The social engineering techn... | models/simulation.go | 0.560132 | 0.629618 | simulation.go | starcoder |
package macros
import (
"errors"
"fmt"
"math"
"strconv"
"time"
)
// Value is a value replacement for a macro
type Value struct {
macro Token
str string
num uint64
typ valueType
any interface{}
}
type valueType uint
const (
typeNone valueType = iota
typeString
typeFloat
typeInt
typeUint
typeA... | values.go | 0.718792 | 0.486149 | values.go | starcoder |
package trie
// most code from https://github.com/dghubble/trie
type Trie struct {
value interface{}
children map[rune]*Trie
}
func NewTrie() *Trie {
return new(Trie)
}
func (trie *Trie) Get(key string) interface{} {
node := trie
for _, r := range key {
node = node.children[r]
if node == nil {
retu... | gomisc/trie/trie.go | 0.605099 | 0.493164 | trie.go | starcoder |
package neuralnetwork
import (
"fmt"
"math"
"gonum.org/v1/gonum/mat"
)
type activationStruct struct{}
// ActivationFunctions is interface with Func and Grad for activation functions
type ActivationFunctions interface {
Func(z, h *mat.Dense)
Grad(z, h, grad *mat.Dense)
String() string
}
// IdentityActivation ... | neural_network/activation.go | 0.743075 | 0.468183 | activation.go | starcoder |
package field
import (
"gorm.io/gorm/clause"
)
type String Field
func (field String) Eq(value string) Expr {
return expr{e: clause.Eq{Column: field.RawExpr(), Value: value}}
}
func (field String) Neq(value string) Expr {
return expr{e: clause.Neq{Column: field.RawExpr(), Value: value}}
}
func (field String) Gt(... | field/string.go | 0.73659 | 0.500977 | string.go | starcoder |
package primitives
import (
"context"
atomixlock "github.com/atomix/go-client/pkg/client/lock"
"github.com/stretchr/testify/assert"
"sync/atomic"
"testing"
"time"
)
// TestAtomixLock : integration test
func (s *TestSuite) TestAtomixLock(t *testing.T) {
client, err := s.getClient(t)
assert.NoError(t, err)
d... | test/primitives/locktest.go | 0.511473 | 0.428592 | locktest.go | starcoder |
package transport
import (
"bytes"
"fmt"
"sync"
)
// numberRange is an inclusive range.
type numberRange struct {
start uint64
end uint64
}
// rangeSet is sorted ranges in ascending order.
type rangeSet []numberRange
func (s rangeSet) largest() uint64 {
if len(s) > 0 {
return s[len(s)-1].end
}
return 0
... | transport/range.go | 0.637369 | 0.407923 | range.go | starcoder |
package geometry
import (
"math"
"github.com/tab58/v1/spatial/pkg/numeric"
)
// Point2DReader is a write-only interface for vectors.
type Point2DReader interface {
GetX() float64
GetY() float64
Clone() *Point2D
AsVector() *Vector2D
DistanceTo(q Point2DReader) (float64, error)
IsEqualTo(q Point2DReader, tol ... | pkg/geometry/point2d.go | 0.888245 | 0.665288 | point2d.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// WorkbookTableColumn
type WorkbookTableColumn struct {
Entity
// Retrieve the filter applied to the column. Read-only.
filter *WorkbookFilter;
//... | models/microsoft/graph/workbook_table_column.go | 0.714329 | 0.461199 | workbook_table_column.go | starcoder |
package losses
import (
"github.com/nlpodyssey/spago/pkg/ml/ag"
)
// MAE measures the mean absolute error (a.k.a. L1 Loss) between each element in the input x and target y.
func MAE(g *ag.Graph, x ag.Node, y ag.Node, reduceMean bool) ag.Node {
loss := g.Abs(g.Sub(x, y))
if reduceMean {
return g.ReduceMean(loss)... | pkg/ml/losses/losses.go | 0.874553 | 0.641324 | losses.go | starcoder |
package harrypotter
//NumBooks is the number of books in the series
const NumBooks = 5
const pricePerBook = 8.0
const optimalDiscountSize = 4
var discounts = [NumBooks + 1]float64{1.0, 1.0, .95, .9, .8, .75}
//CalculatePrice computes and returns the price for the specified books
func CalculatePrice(books BookBasket)... | go/harrypotter/harrypotter.go | 0.698021 | 0.566198 | harrypotter.go | starcoder |
package vector
import "math"
type Vec4 struct {
W float64
X float64
Y float64
Z float64
}
func (v *Vec4) NormSquared() float64 {
return v.W*v.W + v.X*v.X + v.Y*v.Y + v.Z*v.Z
}
func (v *Vec4) HNormSquared() float64 {
return v.W*v.W - v.X*v.X - v.Y*v.Y - v.Z*v.Z
}
func (v *Vec4) Scale(a float64) {
v.W *= a
v... | vector/vector4.go | 0.829423 | 0.485417 | vector4.go | starcoder |
package kinesis
import (
"fmt"
"github.com/crowdmob/goamz/aws"
)
type ShardIteratorType string
type StreamStatus string
const (
// Start reading exactly from the position denoted by a specific sequence number.
ShardIteratorAtSequenceNumber ShardIteratorType = "AT_SEQUENCE_NUMBER"
// Start reading right after ... | go/src/github.com/crowdmob/goamz/kinesis/types.go | 0.780537 | 0.475544 | types.go | starcoder |
package xslice
import (
"fmt"
"math"
"math/rand"
"reflect"
)
// Version returns package version
func Version() string {
return "0.21.0"
}
// Author returns package author
func Author() string {
return "[<NAME>](https://www.likexian.com/)"
}
// License returns package license
func License() string {
return "L... | xslice/xslice.go | 0.799873 | 0.535645 | xslice.go | starcoder |
package instago
//The JSON type can be used when you do not directly want to parse JSON data into a Go
//struct, or when you are dealing with object types that are unknown or constantly
//changing. The API uses this because a) The structure of some Instagram API requests adds
//a lot of additional unnecessary data th... | jsonutil.go | 0.688468 | 0.42662 | jsonutil.go | starcoder |
package beacon
import (
"fmt"
"github.com/lightningnetwork/lnd/tlv"
"github.com/xplorfin/moneysocket-go/moneysocket/beacon/location"
"github.com/xplorfin/moneysocket-go/moneysocket/beacon/util"
"github.com/xplorfin/moneysocket-go/moneysocket/beacon/util/bigsize"
encodeUtils "github.com/xplorfin/moneysocket-go/m... | moneysocket/beacon/beacon.go | 0.682891 | 0.484563 | beacon.go | starcoder |
package telegraf
import (
"time"
)
// Accumulator allows adding metrics to the processing flow.
type Accumulator interface {
// AddFields adds a metric to the accumulator with the given measurement
// name, fields, and tags (and timestamp). If a timestamp is not provided,
// then the accumulator sets it to "now".... | accumulator.go | 0.608594 | 0.481149 | accumulator.go | starcoder |
// This package implements a basic LISP interpretor for embedding in a go program for scripting.
// This file implements data elements.
package golisp
// Cxr
func WalkList(d *Data, path string) *Data {
c := d
for index := len(path) - 1; index >= 0; index-- {
if c == nil {
return nil
}
if !PairP(c) && !Al... | list_access.go | 0.768993 | 0.451447 | list_access.go | starcoder |
package engine
import (
"fmt"
"github.com/notnil/chess"
)
type squareValues map[chess.Square]float32
var pieceValues map[chess.PieceType]float32 = map[chess.PieceType]float32{
chess.Pawn: 10,
chess.Knight: 30,
chess.Bishop: 30,
chess.Rook: 50,
chess.Queen: 90,
chess.King: 900,
}
var whitePawnValues ... | internal/engine/scoring.go | 0.587233 | 0.565119 | scoring.go | starcoder |
package sparse
import (
"math/rand"
"gonum.org/v1/gonum/mat"
)
// Sparser is the interface for Sparse matrices. Sparser contains the mat.Matrix interface so automatically
// exposes all mat.Matrix methods.
type Sparser interface {
mat.Matrix
// NNZ returns the Number of Non Zero elements in the sparse matrix.
... | vendor/github.com/james-bowman/sparse/matrix.go | 0.842086 | 0.726474 | matrix.go | starcoder |
package xsort
import (
"sort"
"github.com/leaxoy/x-go/types"
)
// isNaN64 is a copy of math.IsNaN to avoid a dependency on the math package.
func isNaN64(f float64) bool { return f != f }
// isNaN32 is a copy of math.IsNaN to avoid a dependency on the math package.
func isNaN32(f float32) bool { return f != f }
... | xsort/sort.go | 0.63307 | 0.579638 | sort.go | starcoder |
package mtreefilter
import (
"path/filepath"
"github.com/apex/log"
"github.com/vbatts/go-mtree"
)
// FilterFunc is a function used when filtering deltas with FilterDeltas.
type FilterFunc func(path string) bool
// makeRoot does a very simple job of converting a path to a lexical
// relative-to-root. In mtree we ... | pkg/mtreefilter/mask.go | 0.702428 | 0.430147 | mask.go | starcoder |
package util
import (
"time"
)
const (
// AllDaysMask is a bitmask of all the days of the week.
AllDaysMask = 1<<uint(time.Sunday) | 1<<uint(time.Monday) | 1<<uint(time.Tuesday) | 1<<uint(time.Wednesday) | 1<<uint(time.Thursday) | 1<<uint(time.Friday) | 1<<uint(time.Saturday)
// WeekDaysMask is a bitmask of all t... | util/date.go | 0.636692 | 0.466663 | date.go | starcoder |
package palette
import "github.com/Lexus123/gamut"
// source: https://gist.github.com/lunohodov/1995178
func init() {
RAL.AddColors(
gamut.Colors{
{"Green beige", gamut.Hex("#BEBD7F"), "1000"},
{"Beige", gamut.Hex("#C2B078"), "1001"},
{"Sand yellow", gamut.Hex("#C6A664"), "1002"},
{"Signal yellow", gam... | palette/ral.go | 0.631594 | 0.402627 | ral.go | starcoder |
package runners
import (
"errors"
"time"
"github.com/twitter/scoot/runner"
)
// polling.go: turns a StatusQueryNower into a StatusQuerier by polling
// NewPollingStatusQuerier creates a new StatusQuerier by polling a StatusQueryNower that polls every period
func NewPollingStatusQuerier(del runner.StatusQueryNowe... | runner/runners/polling.go | 0.805173 | 0.4206 | polling.go | starcoder |
package graphing
import (
"github.com/go-gl/gl/v4.1-core/gl"
mgl "github.com/go-gl/mathgl/mgl32"
)
type SingleVarFunc func(x float32) float32
type Params2D struct {
XBoarder float32
YBoarder float32
XRange mgl.Vec2
YRange mgl.Vec2
Dx float32
XAxisColor mgl.Vec3
YAxisColor mgl.Vec3
}
con... | graphing/graphing.go | 0.58522 | 0.464294 | graphing.go | starcoder |
package wann
import (
"errors"
"fmt"
"math/rand"
"github.com/dave/jennifer/jen"
)
// Neuron is a list of input-neurons, and an activation function.
type Neuron struct {
Net *Network
InputNodes []NeuronIndex // pointers to other neurons
ActivationFunction ActivationFunctionIn... | neuron.go | 0.624408 | 0.664568 | neuron.go | starcoder |
package mocks
import (
"github.com/steinfletcher/apitest"
"testing"
)
var _ apitest.Verifier = MockVerifier{}
// MockVerifier is a mock of the Verifier interface that is used in tests of apitest
type MockVerifier struct {
EqualFn func(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{}) boo... | mocks/verifier.go | 0.731059 | 0.426023 | verifier.go | starcoder |
package schema8
func init() {
gAssertionConstructorMap = map[string]assertionConstructorFunc{
"type": newAssertionType,
"enum": newAssertionEnum,
"const": newAssertionConst,
"multipleOf": newAssertionMultipleOf,
"maximum": newAssertionMaximum,
"minimum": newAssertionMinimum,
"... | schema8/init.go | 0.587825 | 0.404096 | init.go | starcoder |
package conversions
type Length struct {
//Yards in Metters, Kilometters and Centimeters
yardInMetter float32
yardInKilometer float32
yardInCentimeters float32
//Feats in Metters, Kilometters and Centimeters
featInKilometter float32
featInMetter float32
featInCentimetter float32
//Milles in Met... | length.go | 0.77081 | 0.401952 | length.go | starcoder |
package core
import "fmt"
type Scalar struct {
Val []float64
}
func NewScalar(v0 float64, v1 float64, v2 float64, v3 float64) (rcvr *Scalar) {
rcvr = &Scalar{}
rcvr.Val = []float64{v0, v1, v2, v3}
return
}
func NewScalar2(v0 float64, v1 float64, v2 float64) (rcvr *Scalar) {
rcvr = &Scalar{}
rcvr.Val = []float6... | opencv3/core/Scalar.java.go | 0.553023 | 0.41253 | Scalar.java.go | starcoder |
package term
import "fmt"
import "math/big"
// Integer represents an unbounded, signed integer value
type Integer big.Int
// NewInt parses an integer's string representation to create a new
// integer value. Panics if the string's is not a valid integer
func NewInt(text string) Number {
if len(text) == 0 {
panic(... | term/integer.go | 0.741393 | 0.461988 | integer.go | starcoder |
package tests
import (
"testing"
"github.com/fnproject/fn_go/client/routes"
"github.com/fnproject/fn_go/models"
)
func AssertRouteMatches(t *testing.T, expected *models.Route, got *models.Route) {
if expected.Path != got.Path {
t.Errorf("Route path mismatch. Expected: %v. Actual: %v", expected.Path, got.Path)... | test/fn-api-tests/routes_api.go | 0.683947 | 0.405684 | routes_api.go | starcoder |
package gittest
import (
"bytes"
"crypto/rand"
"fmt"
"io"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
)
// TestDeltaIslands is based on the tests in
// https://g... | internal/git/gittest/delta_islands.go | 0.8059 | 0.591428 | delta_islands.go | starcoder |
package swagger
const (
Lessondef = `{
"swagger": "2.0",
"info": {
"title": "api/exp/definitions/lessondef.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/exp/le... | api/exp/swagger/swagger.pb.go | 0.658966 | 0.439928 | swagger.pb.go | starcoder |
package imagic
import (
"image"
"image/color"
)
type Config struct {
SeparationMin, SeparationMax int
CrossEyed bool
InvertDepth bool
}
/**
* Given a depth map and background image, create an autostereogram.
*/
func Imagic(dm, bg image.Image, config Config) image.Image {
b... | imagic/imagic.go | 0.744006 | 0.471527 | imagic.go | starcoder |
package sizestr
import (
"errors"
"math"
"regexp"
"strconv"
"strings"
)
//String representations of each scale
var scaleStrings = []string{"B", "KB", "MB", "GB", "TB", "PB", "XB"}
var parseRegexp = regexp.MustCompile(
// byte value[1] scales[4] 1024[5]? B
`(?i)\b(\d+(\.(\d+))?)(k|m|g|t|p|x)?(i?)(b?)\b`... | Godeps/_workspace/src/github.com/jpillora/sizestr/sizestr.go | 0.618435 | 0.4133 | sizestr.go | starcoder |
package core
func NewFlightData() FlightDataConcrete {
return FlightDataConcrete{0, make([]DataSegment, 0), Coordinate{}}
}
func (f *FlightDataConcrete) AppendData(segments []DataSegment) {
f.Segments = append(f.Segments, segments...)
}
func (f *FlightDataConcrete) SetBasePressure(bp float64) {
f.Base = bp
}
fun... | ground/core/flight_data.go | 0.821868 | 0.598782 | flight_data.go | starcoder |
package geometry
import (
"math"
"github.com/tab58/v1/spatial/pkg/numeric"
"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
)
// Vector3DReader is a read-only interface for a 3D vector.
type Vector3DReader interface {
GetX() float64
GetY() float64
GetZ() float64
GetComponents() (float64, float64, ... | pkg/geometry/vector3d.go | 0.883563 | 0.70304 | vector3d.go | starcoder |
package win3cards
type HandCard struct {
Cards [3]int `json:"cards"`
v string `json:"v"`
}
func (self HandCard) Version() string {
return self.v
}
func Compare(h1 HandCard, h2 HandCard) bool {
return h1.Score() > h2.Score()
}
func (self HandCard) Score() (score int) {
if self.isLeopard() {
score = 500
}... | my/royalpoker/win3cards/cards.go | 0.64579 | 0.469034 | cards.go | starcoder |
package rateengine
import (
"time"
"github.com/pkg/errors"
"go.uber.org/zap"
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/unit"
)
// LinehaulCostComputation represents the results of a computation.
type LinehaulCostComputation struct {
BaseLinehaul unit.Cents
OriginLin... | pkg/rateengine/linehaul.go | 0.724578 | 0.453443 | linehaul.go | starcoder |
package cvsgeolookup
import (
"encoding/binary"
"encoding/csv"
"io"
"net"
"sort"
"strconv"
)
type Metrics interface {
}
type nometrics struct{}
type record struct {
begin uint32 // first ip of segment
end uint32 // last ip of segment
lantitude float32 // lantitude
longtitude float32 // long... | geolookup.go | 0.566498 | 0.418578 | geolookup.go | starcoder |
package openapi
import (
"encoding/json"
)
// DispatchRateImpl struct for DispatchRateImpl
type DispatchRateImpl struct {
DispatchThrottlingRateInMsg *int32 `json:"dispatchThrottlingRateInMsg,omitempty"`
DispatchThrottlingRateInByte *int64 `json:"dispatchThrottlingRateInByte,omitempty"`
RelativeToPublishRate *bo... | openapi/model_dispatch_rate_impl.go | 0.777131 | 0.400339 | model_dispatch_rate_impl.go | starcoder |
package testonly
// MerkleTreeLeafTestInputs returns a slice of leaf inputs that may be used in
// compact Merkle tree test cases. They are intended to be added successively,
// so that after each addition the corresponding root from MerkleTreeLeafTestRoots
// gives the expected Merkle tree root hash.
func MerkleTre... | testonly/compact_merkle_tree.go | 0.798029 | 0.527377 | compact_merkle_tree.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTAndFilter110AllOf struct for BTAndFilter110AllOf
type BTAndFilter110AllOf struct {
BtType *string `json:"btType,omitempty"`
Operand1 *BTQueryFilter183 `json:"operand1,omitempty"`
Operand2 *BTQueryFilter183 `json:"operand2,omitempty"`
}
// NewBTAndFilter110AllOf ins... | onshape/model_bt_and_filter_110_all_of.go | 0.695338 | 0.410756 | model_bt_and_filter_110_all_of.go | starcoder |
package protocol
// Attribute is an entity attribute, that holds specific data such as the health of the entity. Each attribute
// holds a default value, maximum and minimum value, name and its current value.
type Attribute struct {
// Name is the name of the attribute, for example 'minecraft:health'. These names mus... | minecraft/protocol/attribute.go | 0.809163 | 0.46041 | attribute.go | starcoder |
package goqueue
//Owner provides functions that directly affect the underlying pointers
// and data structures of a queue pointers. The Close() function should
// ready the underlying pointer for garbage collection and return a slice
// of any items that remain in the queue
type Owner interface {
Close() (items []int... | types.go | 0.512449 | 0.417984 | types.go | starcoder |
package qmath
import (
"time"
"math/rand"
)
type Quote struct {
Name, Summary, Author string
}
var Quotes []Quote = []Quote{
{
Name: "Natural numbers",
Summary: "Natural numbers are the simple counting numbers (0, 1, 2, 3, ...). The skill of counting is intimatelty linked to the development of complex societ... | qmath.go | 0.661376 | 0.665864 | qmath.go | starcoder |
package detection
import (
"fmt"
"math"
"time"
"github.com/VividCortex/ewma"
"github.com/tencent/caelus/pkg/caelus/detection/ring"
"github.com/tencent/caelus/pkg/caelus/types"
)
// MinData is the minimum length of data for AnomalyDetector to work
const MinData = 11
// EwmaDetector using ewma alg to detect ano... | pkg/caelus/detection/ewma.go | 0.806472 | 0.40031 | ewma.go | starcoder |
package sentiment
/*
Base data, as per the paper "PANAS-t: A Pychometric Scale for Measuring Sentiments on Twitter",
which can be accessed at https://arxiv.org/abs/1308.1857.
*/
// SelfReferences indicates the references to the subject in a sentence, as recognized by the PANAS-t paper.
var SelfReferences = []string{"... | pkg/sentiment/base.go | 0.648911 | 0.545044 | base.go | starcoder |
package main
import (
"fmt"
"math"
"code.google.com/p/gomatrix/matrix"
"eurobot/extkalman"
)
type position struct {
X float64
Y float64
}
func newPos(X, Y float64) *position {
return &position{X,Y}
}
func main() {
// Beacon positions
var beaconA = newPos( 0.0, 0.0)
var beaconB = newPos( 0.0, 2000.... | examples/extkalman_robotpositioning.go | 0.604983 | 0.504333 | extkalman_robotpositioning.go | starcoder |
package msm
import (
"fmt"
"math"
"os"
"sort"
"math/bits"
"golang.org/x/exp/rand"
"gonum.org/v1/gonum/mat"
"time"
"gonum.org/v1/gonum/stat"
"gonum.org/v1/gonum/stat/distuv"
"gonum.org/v1/gonum/optimize"
)
const ISPI = 1.0 / math.Sqrt2 / math.SqrtPi
// Compute transition probability matrix
func prob... | model.go | 0.677794 | 0.501465 | model.go | starcoder |
package test
import (
"io"
"testing"
"github.com/stretchr/testify/assert"
"github.com/icon-project/goloop/module"
)
func AssertBlock(
t *testing.T, blk module.Block,
version int, height int64, id []byte, prevID []byte,
) {
assert.EqualValues(t, version, blk.Version())
assert.EqualValues(t, height, blk.Heigh... | test/blockmanager.go | 0.54359 | 0.476275 | blockmanager.go | starcoder |
package elasticsearch
const IndexTemplate string = `
{
"template" : "logstash-*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true, "omit_norms" : true},
"dynamic_templates" : [ {
"message_field" : {
"match" : "mes... | output/elasticsearch/index-template.go | 0.688783 | 0.504455 | index-template.go | starcoder |
package forGraphBLASGo
import "github.com/intel/forGoParallel/pipeline"
type vectorApply[Dw, Du any] struct {
op UnaryOp[Dw, Du]
u *vectorReference[Du]
}
func newVectorApply[Dw, Du any](op UnaryOp[Dw, Du], u *vectorReference[Du]) computeVectorT[Dw] {
return vectorApply[Dw, Du]{op: op, u: u}
}
func (compute vect... | functional_Vector_ComputedApply.go | 0.654011 | 0.718705 | functional_Vector_ComputedApply.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.