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 main
import "math"
type Located interface {
GetXY() Point
}
type Sized interface {
GetWH() Size
}
type GeoSized interface {
GetWH() GeoSize
}
type GeoPoint struct {
X, Y int
}
type GeoSize struct {
W, H int
}
type Point struct {
X, Y float64
}
func (receiver Point) Equal(to Point, precision float6... | geomentry.go | 0.841142 | 0.416797 | geomentry.go | starcoder |
package formencoded
import (
"encoding/base64"
"strconv"
"github.com/jexia/semaphore/v2/pkg/specs/types"
)
// AddTypeKey encodes the given value into the given encoder
func castType(typed types.Type, value interface{}) string {
var casted string
switch typed {
case types.Double:
casted = Float64Empty(value)
... | pkg/codec/www-form-urlencoded/types.go | 0.814828 | 0.490785 | types.go | starcoder |
package schemax
import "sync"
/*
AttributeTypeCollection describes all of the following types:
• AttributeTypes
• RequiredAttributeTypes
• PermittedAttributeTypes
• ProhibitedAttributeTypes
• ApplicableAttributeTypes
*/
type AttributeTypeCollection interface {
// Get returns the *AttributeType instance retrieve... | at.go | 0.770119 | 0.568895 | at.go | starcoder |
package gohttpspeedtest
import (
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
)
// Provider is a struct to hold the data need to speed test, download and upload Urls
type Provider struct {
DownloadURL string
UploadURL string
}
const (
// magic number to fit the tests under 30 seconds
numMeasures = 5
... | speedtest.go | 0.674801 | 0.40987 | speedtest.go | starcoder |
package planbuilder
/*
The two core primitives built by this package are Route and Join.
The Route primitive executes a query and returns the result.
This can be either to a single keyspace or shard, or it can
be a scatter query that spans multiple shards. In the case
of a scatter, the rows can be returned in any ord... | vendor/github.com/youtube/vitess/go/vt/vtgate/planbuilder/doc.go | 0.795777 | 0.848502 | doc.go | starcoder |
package count
import (
"unsafe"
)
// Bool returns count of value in list.
func Bool(list []bool, value bool) int {
valueCount := 0
for _, listValue := range list {
if listValue == value {
valueCount++
}
}
return valueCount
}
// BoolD2 returns count of value in list.
func BoolD2(list [][]bool, value bool)... | count/count.go | 0.715523 | 0.46132 | count.go | starcoder |
package iplookuptree
import (
"encoding/binary"
"math"
"net"
)
// bitslen contstant must be a power of 2. It indicates how much space
// will be taken by a tree and maximum number of hops (treenode accesses). When bitslen is 4,
// the maximum number of hops will be 32 / bitslen and one node takes
// 1<< bitslen * ... | iplookuptree.go | 0.578805 | 0.415432 | iplookuptree.go | starcoder |
package nonogram
import (
"fmt"
"math/rand"
)
type Board interface {
Size() int32
Count(Cell) int
Percent(Cell) float32
Get(x, y int32) Cell
Set(x, y int32, cell Cell) error
Column(x int32) []uint8
ColumnStr(x int32) string
Line(x int32) []uint8
LineStr(x int32) string
RevealColumn(x int32)
RevealLine(y ... | nonogram/board.go | 0.560734 | 0.466846 | board.go | starcoder |
package intersect
import "math"
// Vector defines a struct for a 2d vector, or a point
type Vector struct {
X float64
Y float64
}
// NewVector creates a new vector
func NewVector(x, y float64) Vector {
return Vector{x, y}
}
// NewVectorMagDir creates a new vector by specifying the magnitude and direction
func Ne... | vector.go | 0.947064 | 0.820937 | vector.go | starcoder |
package ptp
const ptpVersion = uint8(5)
const (
floatBytes = 4
uint32Bytes = 4
)
// segments with all dimension deltas smaller than this will be skipped
const skipThreshold = 0.01
// tolerance used by collinearity-checking functions
const collinearityEpsilon = 10e-5
// in-file header only contains version ... | ptp/constants.go | 0.504394 | 0.491761 | constants.go | starcoder |
package convnet
import (
"encoding/json"
"math"
"math/rand"
)
// Layers that implement a loss. Currently these are the layers that
// can initiate a backward() pass. In future we probably want a more
// flexible system that can accomodate multiple losses to do multi-task
// learning, and stuff like that. But for n... | layers-loss.go | 0.738763 | 0.469824 | layers-loss.go | starcoder |
package v1alpha1
import (
internalinterfaces "kubeform.dev/provider-google-api/client/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.
type Interface interface {
// DataTransferConfigs returns a DataTransferConfigInformer.
DataTransferConfig... | client/informers/externalversions/bigquery/v1alpha1/interface.go | 0.796015 | 0.433802 | interface.go | starcoder |
package httpsrv
import (
"html/template"
"reflect"
"strings"
"time"
)
var TemplateFuncs = map[string]interface{}{
"eq": tfEqual,
// Skips sanitation on the parameter. Do not use with dynamic data.
"raw": func(text string) template.HTML {
return template.HTML(text)
},
// Returns a copy of the string s wit... | vendor/github.com/hooto/httpsrv/template-func.go | 0.738669 | 0.447219 | template-func.go | starcoder |
package nred
// FieldType defines the possible field types in nred definitions.
type FieldType int
const (
// ConstField identifies a field with a name and a constant value.
ConstField FieldType = iota
// GenericField identifies a field with a name and any arbitrary value as receieved from the backend
// (or an... | nred/nred.go | 0.829077 | 0.637793 | nred.go | starcoder |
Schob is a client for "shovey", a mechanism for pushing jobs to client nodes.
Currently it's specific to goiardi, but a more general implementation is
planned.
Dependencies
Running schob requires a goiardi server (both to send jobs to the schob client,
and for the schob client to send reports to) and serf running w... | doc.go | 0.652795 | 0.597021 | doc.go | starcoder |
package util
import (
"encoding/json"
"fmt"
"reflect"
"strconv"
"strings"
)
func ToBool(v interface{}) bool {
switch val := v.(type) {
case bool:
return val
case float32, float64:
// direct type conversion may cause data loss, use reflection instead
return reflect.ValueOf(v).Float() != 0
case int, int8... | util/conv.go | 0.539226 | 0.419588 | conv.go | starcoder |
package keyseq
type TernaryTrie struct {
root TernaryNode
}
func NewTernaryTrie() *TernaryTrie {
return &TernaryTrie{}
}
func (t *TernaryTrie) Root() Node {
return &t.root
}
func (t *TernaryTrie) GetList(k KeyList) Node {
return Get(t, k)
}
func (t *TernaryTrie) Get(k Key) Node {
return Get(t, KeyList{k})
}
... | internal/keyseq/ternary.go | 0.598195 | 0.522019 | ternary.go | starcoder |
package bitset
// Bits is a lightweight bitset implementation based on a uint64 number,
// it's not safety for concurrent.
type Bits uint64
func NewBits() *Bits {
var s Bits
return &s
}
// BitsList create a Bits, set all bits in list to 1
func BitsList(bits ...uint) *Bits {
var s uint64
for _, b := range bits {... | ds/bitset/bits.go | 0.704058 | 0.431285 | bits.go | starcoder |
package document
import (
"baliance.com/gooxml/color"
"baliance.com/gooxml/measurement"
"baliance.com/gooxml/schema/soo/wml"
)
// CellBorders are the borders for an individual
type CellBorders struct {
x *wml.CT_TcBorders
}
// X returns the inner wrapped type
func (b CellBorders) X() *wml.CT_TcBorders {
return... | document/cellborders.go | 0.807195 | 0.456591 | cellborders.go | starcoder |
package immutable
import (
"github.com/pkg/errors"
"github.com/chris-tomich/immutability-benchmarking"
)
// Matrix is an immutable matrix with non-mutating operations.
type Matrix struct {
matrix [immutabilitybenchmarking.MatrixHeight][immutabilitybenchmarking.MatrixWidth]int
}
// New creates a new immutable matr... | array/immutable/matrix.go | 0.900244 | 0.736756 | matrix.go | starcoder |
// hubbub provides an advanced in-memory search for GitHub using state machines
package hubbub
import (
"sync"
"time"
"github.com/google/triage-party/pkg/constants"
"github.com/google/triage-party/pkg/persist"
"github.com/google/triage-party/pkg/provider"
"k8s.io/klog/v2"
)
// Config is how to configure a new... | pkg/hubbub/hubbub.go | 0.556159 | 0.411229 | hubbub.go | starcoder |
package main
import (
"errors"
"fmt"
"github.com/go-gl/gl/v4.2-core/gl"
"github.com/hexaflex/wireworldgpu/math"
)
// SimulationState is an offscreen render target (framebuffer) which functions
// as the simulation state and applies the simulation rules.
type SimulationState struct {
size math.Vec2
fbo uint32
... | simulationstate.go | 0.711832 | 0.47658 | simulationstate.go | starcoder |
package series
import (
"fmt"
"math"
"strconv"
)
type intElement struct {
e int
nan bool
}
func (e *intElement) Set(value interface{}) {
e.nan = false
switch value.(type) {
case string:
if value.(string) == "NaN" {
e.nan = true
return
}
i, err := strconv.Atoi(value.(string))
if err != nil {
... | vendor/github.com/kniren/gota/series/type-int.go | 0.586404 | 0.440048 | type-int.go | starcoder |
package goglbackend
import (
"image"
"image/color"
"unsafe"
"github.com/tfriedel6/canvas/backend/goglbackend/gl"
)
// GetImageData returns an RGBA image of the current image
func (b *GoGLBackend) GetImageData(x, y, w, h int) *image.RGBA {
b.activate()
if x < 0 {
w += x
x = 0
}
if y < 0 {
h += y
y = ... | backend/goglbackend/imagedata.go | 0.656438 | 0.412708 | imagedata.go | starcoder |
package main
import (
"fmt"
"math"
"strconv"
"sync"
)
func main() {
/*
Maps are a data structure that holds key-value pairs. Keys need to be
unique, but the same value can be assigned to multiple keys. maps need to
have a defined key type and value type - they can be differ... | maps-channels-goroutines/mcg.go | 0.524882 | 0.401746 | mcg.go | starcoder |
package html
const (
bitRectTop = 1 << iota
bitRectTopPercentage
bitRectBottom
bitRectBottomPercentage
bitRectHeight
bitRectHeightPercentage
bitRectLeft
bitRectLeftPercentage
bitRectRight
bitRectRightPercentage
bitRectWidth
bitRectWidthPercentage
bitRectAll = bitRectTop | bitRectBottom | bitRectHeight | ... | html/rect.go | 0.832441 | 0.610657 | rect.go | starcoder |
package simplifier
import "github.com/twtiger/gosecco/tree"
// AcceptComparison implements Visitor
func (s *fullArgumentSplitterSimplifier) AcceptComparison(a tree.Comparison) {
l := s.Transform(a.Left)
r := s.Transform(a.Right)
pral, okal := potentialExtractFullArgument(l)
prnlLow, prnlHi, oknl := potentialExtr... | vendor/github.com/twtiger/gosecco/simplifier/full_argument_splitter_simplifier.go | 0.648355 | 0.446736 | full_argument_splitter_simplifier.go | starcoder |
package settings
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/cio/api/types"
"github.com/ingrammicro/cio/utils"
"github.com/stretchr/testify/assert"
)
// ListAssignmentsMocked test mocked function
func ListAssignmentsMocked(
t *testing.T,
cloudAccountID string,
policyAssignmentsIn []*ty... | api/settings/policy_assignments_api_mocked.go | 0.686055 | 0.522994 | policy_assignments_api_mocked.go | starcoder |
package gocb
// RemoveMt performs a Remove operation and includes MutationToken in the results.
func (b *Bucket) RemoveMt(key string, cas Cas) (Cas, MutationToken, error) {
if !b.mtEnabled {
panic("You must use OpenBucketMt with Mt operation variants.")
}
return b.remove(key, cas)
}
// UpsertMt performs a Upsert... | bucket_token.go | 0.78695 | 0.449936 | bucket_token.go | starcoder |
package bolt
import (
"fmt"
"math"
)
// Bolt - base property of bolt
type Bolt struct {
bc Class
bd Diameter
}
// New - create a new bolt
func New(bd Diameter, bc Class) Bolt {
return Bolt{bc: bc, bd: bd}
}
// Fyb - return Fyb stress.
// unit: Pa
func (b Bolt) Fyb() Fyb {
return Fyb{BoltClass: b.bc}
}
// Fub... | bolt.go | 0.845049 | 0.536556 | bolt.go | starcoder |
package main
import (
"image"
"image/color"
"image/png"
"os"
"path/filepath"
"github.com/unidoc/unipdf/v3/common"
)
const imageDir = "artificial.images" // Where image segments are stored.
func main() {
if _, err := os.Stat(imageDir); os.IsNotExist(err) {
os.Mkdir(imageDir, 0777)
}
if err := create("tri... | segmentation/create_images.go | 0.647798 | 0.406096 | create_images.go | starcoder |
package fileseq
import (
"fmt"
"regexp"
"strconv"
"strings"
)
type PadStyle int
const (
// Constants defining the style of padding to use
// when converting between padding characters ('#', '##', '@@@')
// and their equivalent numeric padding width
PadStyleHash1 PadStyle = 0 // '#' char == 1
PadStyleHash4... | pad.go | 0.70069 | 0.40439 | pad.go | starcoder |
package three
import (
"math"
"math/rand"
"strconv"
)
// NewVector2 :
func NewVector2(x, y float64) *Vector2 {
return &Vector2{x, y, true}
}
// Vector2 :
type Vector2 struct {
X float64
Y float64
IsVector2 bool
}
// Width :
func (v Vector2) Width() float64 {
return v.X
}
// SetWidth :
func... | server/three/vector2.go | 0.827201 | 0.740644 | vector2.go | starcoder |
package helper
import "github.com/eriklupander/rt/internal/pkg/mat"
var white = mat.NewColor(1, 1, 1)
// RenderPointAt transforms the passed world coordinate point into view coords and projects it onto the 2D canvas.
func RenderPointAt(canvas *mat.Canvas, camera mat.Camera, worldPoint mat.Tuple4, color mat.Tuple4) {... | internal/pkg/helper/helper.go | 0.736401 | 0.755163 | helper.go | starcoder |
package main
import (
"fmt"
"reflect"
)
type Employee struct {
Name string
Age int
Vacation int
Salary int
}
func Transform(slice, function interface{}) interface{} {
return transform(slice, function, false)
}
func TransformInPlace(slice, function interface{}) interface{} {
return transform(slice... | src/go/go-patterns/src/map_reduce/robust_generic_map.go | 0.690768 | 0.442637 | robust_generic_map.go | starcoder |
package lunar
import (
"time"
c "github.com/rtovey/astro-lib/common"
o "github.com/rtovey/astro-lib/orbit"
t "github.com/rtovey/astro-lib/time"
)
type LunarRiseSetTime struct {
Rise time.Time
Set time.Time
Debug LunarRiseSetTimeDebug
}
type LunarRiseSetTimeDebug struct {
date time.Time
ob... | lunar/lunarRiseSetTime.go | 0.630116 | 0.54952 | lunarRiseSetTime.go | starcoder |
package api
// GatewayIntents is an extension of the Bit structure used when identifying with discord
type GatewayIntents int64
// Constants for the different bit offsets of GatewayIntents
const (
GatewayIntentsGuilds GatewayIntents = 1 << iota
GatewayIntentsGuildMembers
GatewayIntentsGuildBans
GatewayIntentsGuil... | api/gateway_intents.go | 0.645343 | 0.540803 | gateway_intents.go | starcoder |
package day219
import "fmt"
// Possible winning positions.
// Vertical: 7 columns * 3 positions per column = 21 vertical winning positions.
// Horizontal: 6 rows * 4 positions per column = 24 horizontal winning positions.
// DiagUp: 12
// DiagDown: 12
// Total == 69 winning positions checking 4 positions == 276 check... | day219/problem.go | 0.784278 | 0.50531 | problem.go | starcoder |
package sprites
import (
"github.com/go-gl/mathgl/mgl32"
"github.com/wieku/danser-go/animation"
"github.com/wieku/danser-go/bmath"
"github.com/wieku/danser-go/render/batches"
"github.com/wieku/danser-go/render/texture"
"math"
"sort"
)
const (
storyboardArea = 640.0 * 480.0
maxLoad = 1.3328125 //480*48... | render/sprites/sprite.go | 0.620622 | 0.480722 | sprite.go | starcoder |
package rui
import "strconv"
const (
// ImageLoading is the image loading status: in the process of loading
ImageLoading = 0
// ImageReady is the image loading status: the image is loaded successfully
ImageReady = 1
// ImageLoadingError is the image loading status: an error occurred while loading
ImageLoadingEr... | image.go | 0.719482 | 0.45647 | image.go | starcoder |
package reflect
import (
"log"
"reflect"
)
// TypeMatcher represents a type that describes itself as a matcher of reflect.Type.
type TypeMatcher interface {
// MatchType returns true if matching was successful.
MatchType(reflect.Type) bool
}
// FuncMatcher matches in/out sections of the functions.
type FuncMatch... | reflect/matchers.go | 0.645343 | 0.554651 | matchers.go | starcoder |
package plotter
import (
"errors"
"math"
"sort"
"code.google.com/p/plotinum/plot"
"code.google.com/p/plotinum/vg"
)
// fiveStatPlot contains the shared fields for quartile
// and box-whisker plots.
type fiveStatPlot struct {
// Values is a copy of the values of the values used to
// create th... | src/code.google.com/p/plotinum/plotter/boxplot.go | 0.779238 | 0.557845 | boxplot.go | starcoder |
package utils
import (
"math"
)
func Prod(values *SlidingWindow) (float64, error) {
result := 1.0
for i := 0; i < values.Count(); i++ {
result *= values.Data()[i]
}
return result, nil
}
func Add(x float64, values *SlidingWindow) (*SlidingWindow, error) {
result, err := NewSlidingWindow(values.Count())
if er... | performance/utils/sliceoperation.go | 0.524638 | 0.421135 | sliceoperation.go | starcoder |
package utils
import (
"math/big"
)
// this library provides a golang equivalent of the "BMath" contracts
// see https://github.com/indexed-finance/indexed-core/blob/master/contracts/balancer/BNum.sol
var (
// BONE ...
bONE = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)
// BPOWPRECISION ...
BPOWPRECISI... | utils/bmath.go | 0.603348 | 0.519156 | bmath.go | starcoder |
package ionossdk
import (
"encoding/json"
)
// KubernetesAutoScaling struct for KubernetesAutoScaling
type KubernetesAutoScaling struct {
// The minimum number of worker nodes that the managed node group can scale in. Should be set together with 'maxNodeCount'. Value for this attribute must be greater than equal t... | cluster-autoscaler/cloudprovider/ionoscloud/ionos-cloud-sdk-go/model_kubernetes_auto_scaling.go | 0.705582 | 0.441613 | model_kubernetes_auto_scaling.go | starcoder |
package tree
import (
"fmt"
"github.com/anchore/stereoscope/pkg/tree/node"
)
// Tree represents a simple Tree data structure.
type Tree struct {
nodes map[node.ID]node.Node
children map[node.ID]map[node.ID]node.Node
parent map[node.ID]node.Node
}
// NewTree returns an instance of a Tree.
func NewTree() *T... | pkg/tree/tree.go | 0.776708 | 0.545709 | tree.go | starcoder |
package trisnake
import (
tl "github.com/JoelOtter/termloop"
)
// NewSnake will create a new snake and is called when the game is initialized.
func NewSnake() *Snake {
snake := new(Snake)
// Create a new entity for a 1x1 pixel.
snake.Entity = tl.NewEntity(5, 5, 1, 1)
// Sets a standard direction to right, do not... | game/snake.go | 0.78838 | 0.41745 | snake.go | starcoder |
package models
import (
"encoding/json"
"fmt"
"time"
)
type (
// DeviceDisconnectBehavior defines the disconnection behavior of the simulated device.
DeviceDisconnectBehavior string
// TelemetryFormat defines the format of the telemetry messages sent from the simulated device.
TelemetryFormat string
// Simu... | pkg/models/simulation.go | 0.743541 | 0.40751 | simulation.go | starcoder |
package asyncjobs
import (
"context"
"math/rand"
"time"
)
// RetryPolicy defines a period that failed jobs will be retried against
type RetryPolicy struct {
// Intervals is a range of time periods backoff will be based off
Intervals []time.Duration
// Jitter is a factor applied to the specific interval avoid r... | retrypolicy.go | 0.727685 | 0.543469 | retrypolicy.go | starcoder |
package execute
import (
"context"
"fmt"
"github.com/influxdata/flux"
"github.com/influxdata/flux/memory"
"github.com/influxdata/flux/plan"
)
// Transformation represents functions that stream a set of tables, performs
// data processing on them and produces an output stream of tables
type Transformation interf... | execute/transformation.go | 0.705785 | 0.403038 | transformation.go | starcoder |
package mysql_db
import (
"sort"
"strings"
"github.com/dolthub/go-mysql-server/sql"
)
// PrivilegeSet is a set containing privileges. Due to the nested sets potentially returning empty sets, this also acts
// as the singular location to modify all nested sets.
type PrivilegeSet struct {
globalStatic map[sql.Pr... | sql/mysql_db/privilege_set.go | 0.713232 | 0.518302 | privilege_set.go | starcoder |
package mesh
import (
"crypto/sha256"
"fmt"
"log"
"os"
"strconv"
"github.com/9elements/autorev/tracelog"
"github.com/emicklei/dot"
lcs "github.com/yudai/golcs"
)
// MeshNode - Describes a node in the Mesh
type MeshNode struct {
// Id is incremented for each node added. It's unique in the mesh.
Id uint64
... | mesh/mesh.go | 0.592313 | 0.415314 | mesh.go | starcoder |
package streamer
import (
"fmt"
"time"
"github.com/lyraproj/dgo/dgo"
"github.com/lyraproj/dgo/tf"
"github.com/lyraproj/dgo/vf"
)
type dataDecoder struct {
BasicCollector
dialect Dialect
aliasMap dgo.AliasAdder
}
// DataDecoder returns a decoder capable of decoding a stream of rich data representations into... | streamer/decoder.go | 0.656438 | 0.492615 | decoder.go | starcoder |
package spectral
import (
"math"
"github.com/ArkaGPL/gonum/graph"
"github.com/ArkaGPL/gonum/mat"
)
// Laplacian is a graph Laplacian matrix.
type Laplacian struct {
// Matrix holds the Laplacian matrix.
mat.Matrix
// Nodes holds the input graph nodes.
Nodes []graph.Node
// Index is a mapping from the grap... | graph/spectral/laplacian.go | 0.795857 | 0.555013 | laplacian.go | starcoder |
package datalog
import (
"fmt"
)
// Flags define atom flags
type Flags int
// Known atom flags.
const (
FlagPersistent Flags = 1 << iota
)
// Atom implements datalog atoms.
type Atom struct {
Predicate Symbol
Terms []Term
Flags Flags
}
// AtomID defines atom IDs.
type AtomID uint64
func (id AtomID) ... | atom.go | 0.785597 | 0.402539 | atom.go | starcoder |
package assert
import (
"fmt"
"path/filepath"
"reflect"
"runtime"
"testing"
"time"
)
func messageFromMsgAndArgs(msgAndArgs ...interface{}) string {
if len(msgAndArgs) == 0 || msgAndArgs == nil {
return ""
}
if len(msgAndArgs) == 1 {
return msgAndArgs[0].(string)
}
if len(msgAndArgs) > 1 {
return fm... | vendor/github.com/frozzare/go-assert/assert.go | 0.631708 | 0.434881 | assert.go | starcoder |
package bloom
import (
"github.com/ioeX/ioeX.Utility/common"
)
// MBlock is used to house intermediate information needed to generate a
// MerkleBlock according to a filter.
type MBlock struct {
NumTx uint32
AllHashes []*common.Uint256
FinalHashes []*common.Uint256
MatchedBits []byte
Bits []byte
... | bloom/mblock.go | 0.752286 | 0.494446 | mblock.go | starcoder |
package parser
const (
DEVICE_TYPE_INVALID = -1
DEVICE_TYPE_DESKTOP = 0
DEVICE_TYPE_SMARTPHONE = 1
DEVICE_TYPE_TABLET = 2
DEVICE_TYPE_FEATURE_PHONE = 3
DEVICE_TYPE_CONSOLE = 4
DEVICE_TYPE_TV = 5 // including set top boxes, b... | parser/device.go | 0.597608 | 0.555616 | device.go | starcoder |
package tree
import (
"github.com/timtadh/data-structures/types"
)
func pop(stack []types.TreeNode) ([]types.TreeNode, types.TreeNode) {
if len(stack) <= 0 {
return stack, nil
} else {
return stack[0 : len(stack)-1], stack[len(stack)-1]
}
}
func btn_expose_nil(node types.BinaryTreeNode) types.BinaryTreeNode ... | vendor/github.com/timtadh/data-structures/tree/util.go | 0.520496 | 0.446133 | util.go | starcoder |
package plaid
import (
"encoding/json"
)
// StudentLoan Contains details about a student loan account
type StudentLoan struct {
// The ID of the account that this liability belongs to.
AccountId NullableString `json:"account_id"`
// The account number of the loan. For some institutions, this may be a masked vers... | plaid/model_student_loan.go | 0.765155 | 0.66889 | model_student_loan.go | starcoder |
package iso20022
// Information used to calculate the tax.
type TaxCalculationInformation4 struct {
// Specifies whether capital gain is in the scope of the European directive on taxation of savings income in the form of interest payments (Council Directive 2003/48/EC 3 June), or an income realised upon sale, a refu... | TaxCalculationInformation4.go | 0.729905 | 0.682197 | TaxCalculationInformation4.go | starcoder |
// Package table allows read and write sorted key/value.
package table
import (
"encoding/binary"
)
/*
Table:
Table is consist of one or more data blocks, an optional filter block
a metaindex block, an index block and a table footer. Metaindex block
is a special block used to keep parameters of the table, such as ... | third_party/github.com/syndtr/goleveldb/leveldb/table/table.go | 0.787359 | 0.614972 | table.go | starcoder |
package ksh
import "github.com/ContextLogic/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, 'dä' d. MMMM y", Long: "d. MMMM y", Medium: "d. MMM. y", Short: "d. M. y"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Me... | resources/locales/ksh/calendar.go | 0.510496 | 0.436202 | calendar.go | starcoder |
package trakt
import (
"fmt"
"net/url"
"strconv"
)
// All the all constant, this is shared between different types
// so cant be allocated to a specific filter.
const All string = `all`
type ExtendedType string
func (e ExtendedType) String() string { return string(e) }
const (
ExtendedTypeGuestStars Ex... | filter.go | 0.74158 | 0.454654 | filter.go | starcoder |
package constant
import (
"fmt"
"github.com/llir/llvm/ir/types"
)
// --- [ Vector expressions ] --------------------------------------------------
// ~~~ [ extractelement ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ExprExtractElement is an LLVM IR extractelement expression.
type ExprExtractElemen... | ir/constant/expr_vector.go | 0.73659 | 0.545346 | expr_vector.go | starcoder |
package slice
import (
"fmt"
"math"
"math/rand"
)
// IndexOfString gets the index of a string element in a string slice
func IndexOfString(x []string, y string) int {
for i, v := range x {
if v == y {
return i
}
}
return -1
}
// ContainsString checks whether a string element is in a string slice
func Co... | slice/string.go | 0.729423 | 0.484685 | string.go | starcoder |
// The precise format and contents of this file are depended
// on by parse/helpgen.go. Do not edit without verifying that
// )help still works properly.
/*
Ivy is an interpreter for an APL-like language. It is a plaything and a work in
progress.
Unlike APL, the input is ASCII and the results are exact (but see the... | doc.go | 0.703651 | 0.704745 | doc.go | starcoder |
package pickle
import (
"encoding/binary"
"fmt"
"github.com/jingxil/leaves/util"
)
// SklearnNode represents tree node data structure
type SklearnNode struct {
LeftChild int
RightChild int
Feature int
Threshold float64
Impurity float64
NNodeSamples ... | internal/pickle/sklearn.go | 0.70028 | 0.500122 | sklearn.go | starcoder |
package segmentation
import (
"fmt"
"github.com/miguelfrde/image-segmentation/disjointset"
"github.com/miguelfrde/image-segmentation/graph"
"github.com/miguelfrde/image-segmentation/imagenoise"
"github.com/miguelfrde/image-segmentation/utils"
"math"
"sort"
"time"
)
/**
* Performs the image segmentation using... | segmentation/hmsf.go | 0.741487 | 0.468061 | hmsf.go | starcoder |
package gobrain
import (
"fmt"
"log"
"math"
)
// FeedForwad struct is used to represent a simple neural network
type FeedForward struct {
// Number of input, hidden and output nodes
NInputs, NHiddens, NOutputs int
// Whether it is regression or not
Regression bool
// Activations for nodes
InputActivations, H... | vendor/github.com/axamon/gobrain/feedforward.go | 0.616128 | 0.460046 | feedforward.go | starcoder |
package gohorizon
import (
"encoding/json"
)
// DatastoreSpaceRequirementInfo Information about Datastore Space Requirement.
type DatastoreSpaceRequirementInfo struct {
// Indicates the type of disk used for storage. * OS: Disk to store operating system related data. * REPLICA: Disk for placement of replica VMs cr... | model_datastore_space_requirement_info.go | 0.779657 | 0.409221 | model_datastore_space_requirement_info.go | starcoder |
package vfs
// Help contains text describing file and directory caching to add to
// the command help.
var Help = `
### Directory Cache
Using the ` + "`--dir-cache-time`" + ` flag, you can set how long a
directory should be considered up to date and not refreshed from the
backend. Changes made locally in the mount ma... | vfs/help.go | 0.739516 | 0.461381 | help.go | starcoder |
package other
import (
"time"
"github.com/kasworld/h4o/_examples/app"
"github.com/kasworld/h4o/geometry"
"github.com/kasworld/h4o/gls"
"github.com/kasworld/h4o/graphic"
"github.com/kasworld/h4o/material"
"github.com/kasworld/h4o/math32"
)
func init() {
app.DemoMap["other.curves"] = &Curves2{}
}
type Curves2... | _examples/demos/other/curves.go | 0.534127 | 0.606149 | curves.go | starcoder |
package core
// Buffer interface
type Buffer interface {
Push(elemt Elemt, running bool) error
Data() []Elemt
Apply() error
}
// DataBuffer that stores data.
// In synchronous mode, when pushed() is called data are stored.
// In asynchronous mode, when pushed() is called data are staged.
// Staged data are stored ... | core/buffer.go | 0.688887 | 0.414306 | buffer.go | starcoder |
package gographviz
import (
"github.com/awalterschulze/gographviz/ast"
)
//Creates a Graph structure by analysing an Abstract Syntax Tree representing a parsed graph.
func NewAnalysedGraph(graph *ast.Graph) *Graph {
g := NewGraph()
Analyse(graph, g)
return g
}
//Analyses an Abstract Syntax Tree representing a p... | vendor/github.com/awalterschulze/gographviz/analyse.go | 0.670824 | 0.411939 | analyse.go | starcoder |
package zipfian
import (
"math"
"math/rand"
"time"
)
/**
* Used to generate zipfian distributed random numbers where the distribution is
* skewed toward the lower integers; e.g. 0 will be the most popular, 1 the next
* most popular, etc.
*
* This class implements the core algorithm from YCSB's ZipfianGenerato... | src/zipfian/zipfian.go | 0.766468 | 0.502136 | zipfian.go | starcoder |
package main
import (
"container/heap"
"fmt"
)
/*
You are given two 0-indexed integer arrays servers and tasks of lengths n and m respectively. servers[i] is the weight of the ith server, and tasks[j] is the time needed to process the jth task in seconds.
You are running a simulatio... | golang/algorithms/others/process_tasks_using_servers/main.go | 0.655336 | 0.603932 | main.go | starcoder |
package sergeant
import (
"bytes"
"fmt"
"path/filepath"
"strings"
"time"
"github.com/albatross-org/go-albatross/entries"
"gopkg.in/yaml.v3"
)
// Card is the basic unit of the program. It's an abstraction over an Albatross entry and represents a question-answer pair.
type Card struct {
ID string
Path strin... | card.go | 0.750187 | 0.436442 | card.go | starcoder |
package constants
var WORDS = map[string]bool{
"which": true,
"there": true,
"their": true,
"about": true,
"would": true,
"these": true,
"other": true,
"words": true,
"could": true,
"write": true,
"first": true,
"water": true,
"after": true,
"where": true,
"r... | constants/wordlists.go | 0.5083 | 0.444022 | wordlists.go | starcoder |
Matrix Operations
*/
//-----------------------------------------------------------------------------
package sdf
import (
"math"
)
//-----------------------------------------------------------------------------
type M44 struct {
x00, x01, x02, x03 float64
x10, x11, x12, x13 float64
x20, x21, x22, x23 float64
... | sdf/matrix.go | 0.745769 | 0.603465 | matrix.go | starcoder |
package gojay
import "strconv"
// EncodeFloat encodes a float64 to JSON
func (enc *Encoder) EncodeFloat(n float64) error {
if enc.isPooled == 1 {
panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
}
_, _ = enc.encodeFloat(n)
_, err := enc.Write()
if err != nil {
return err
}
return ni... | encode_number_float.go | 0.869035 | 0.45944 | encode_number_float.go | starcoder |
package fitter
import "strings"
type sequenceKind int
const (
plainSequenceKind = iota
controlSequenceKind
)
type sequence struct {
data string
kind sequenceKind
}
func newSequence(data string) *sequence {
s := &sequence{}
s.data = data
s.kind = plainSequenceKind
return s
}
func (s *sequence) Append(data... | internal/stream/fitter/sequence.go | 0.657648 | 0.423995 | sequence.go | starcoder |
package assertions
import (
"fmt"
"reflect"
)
// ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality.
func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string {
if fail := need(1, expected); fail != success {
return fail
}
first := reflect... | Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions/type.go | 0.794903 | 0.556821 | type.go | starcoder |
package influxql
import (
"net/http"
"github.com/influxdata/flux"
)
const DialectType = "influxql"
// AddDialectMappings adds the influxql specific dialect mappings.
func AddDialectMappings(mappings flux.DialectMappings) error {
return mappings.Add(DialectType, func() flux.Dialect {
return new(Dialect)
})
}
... | query/influxql/dialect.go | 0.780913 | 0.534127 | dialect.go | starcoder |
package cmd
import (
"time"
)
//go:generate msgp -file $GOFILE
// ReplicationLatency holds information of bucket operations latency, such us uploads
type ReplicationLatency struct {
// Single & Multipart PUTs latency
UploadHistogram LastMinuteLatencies
}
// Merge two replication latency into a new one
func (rl ... | cmd/bucket-stats.go | 0.637257 | 0.429968 | bucket-stats.go | starcoder |
package ssm
import (
"errors"
"fmt"
)
// State represents a single state of the system.
type State struct {
// Name is the name of the state, give it something meaningful
Name string
}
// Trigger is a trigger that can move from one state to another.
type Trigger struct {
// Key is a unique key for the trigger
... | state_machine.go | 0.753285 | 0.420243 | state_machine.go | starcoder |
package box2d
import (
"math"
)
// Compute contact points for edge versus circle.
// This accounts for edge connectivity.
func B2CollideEdgeAndCircle(manifold *B2Manifold, edgeA *B2EdgeShape, xfA B2Transform, circleB *B2CircleShape, xfB B2Transform) {
manifold.PointCount = 0
// Compute circle in frame of edge
Q ... | CollisionB2CollideEdge.go | 0.804905 | 0.691654 | CollisionB2CollideEdge.go | starcoder |
package cluster
import (
"errors"
"math"
)
// UpdateNN calculates the row/column to add to a distance matrix for a new node.
// Methods supported: average, complete, mcquitty or ward.
func UpdateNN(method string) (updateFunc func(matrix [][]float64, a, b int, nodeSize []int) (newRow []float64), err error) {
if met... | cluster/updatenn.go | 0.626924 | 0.511534 | updatenn.go | starcoder |
package java
const numConstTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.Const }}
private final {{ javaTypeFor .}} {{ constantName . "Const" }} = {{ $r.GetConst }}{{ javaTypeLiteralSuffixFor . }};
{{- end -}}
{{- if $r.Lt }}
private final {{ javaTypeFor .}} {{ constantName . "Lt" }} = {{ $r.GetLt }}{{ jav... | templates/java/num.go | 0.549882 | 0.440048 | num.go | starcoder |
package component
import (
"encoding/json"
"github.com/pkg/errors"
)
// Operator represents a key's relationship to a set of values.
// Valid operators are In, NotIn, Exists and DoesNotExist.
type Operator string
const (
// OperatorIn means a key value is in a set of possible values
OperatorIn Operator = "In"
... | pkg/view/component/expression_selector.go | 0.783409 | 0.425009 | expression_selector.go | starcoder |
package projectron
import "math"
import "errors"
type impl interface {
Projection
init(paramset) error
}
func lookupImpl(pin *pj) impl {
switch pin.proj {
case "latlong", "longlat", "latlon", "lonlat":
return &LngLat{pin}
case "merc":
return &Mercator{pin}
case "lcc":
return &LCC{pj: pin}
case "eqc":
... | projections.go | 0.628407 | 0.483709 | projections.go | starcoder |
package monitoring
import (
"fmt"
"github.com/gravitational/trace"
humanize "github.com/dustin/go-humanize"
)
// StorageConfig describes checker configuration
type StorageConfig struct {
// Path represents volume to be checked
Path string
// WillBeCreated when true, then all checks will be applied to first ex... | vendor/github.com/gravitational/satellite/monitoring/storage.go | 0.71889 | 0.50769 | storage.go | starcoder |
package stringsmoar
import (
"bytes"
"errors"
"sort"
"strings"
"unicode/utf8"
)
// Runes returns a slice of runes from a string
func Runes(s string) []rune {
var runes []rune
for _, r := range s {
runes = append(runes, r)
}
return runes
}
// RuneFrequency returns a map of the count of each rune in the str... | stringsmoar.go | 0.547222 | 0.415788 | stringsmoar.go | starcoder |
package main
import (
"bytes"
"flag"
"fmt"
"log"
"math/rand"
"os"
"strconv"
"time"
)
// FieldLocation reifies the concept of identifying where a cell exists
// within a Field. This takes the distinct data points of row/column or
// x/y and forces them into a single entity, i.e. "reifies" them.
type FieldLocat... | life/life.go | 0.75101 | 0.401336 | life.go | starcoder |
package types
import (
"fmt"
"math"
"sort"
"strconv"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// VoteForTally is a convinience wrapper to reduct redundant lookup cost
type VoteForTally struct {
ExchangeRateVote
Power int64
}
// NewVoteForTally returns a new VoteForTally instance
func NewVoteForTally(vote E... | x/oracle/internal/types/ballot.go | 0.784236 | 0.510374 | ballot.go | starcoder |
package structmapper
// Original was https://github.com/jinzhu/copier
// extend mapping by struct tag
import (
"database/sql"
"fmt"
"reflect"
"strings"
"sync"
"github.com/pkg/errors"
)
// New Mapper
func New() Mapper {
return &mapper{
transformerRepository: newTransformerRepository(),
logger: ... | structmapper.go | 0.739893 | 0.410756 | structmapper.go | starcoder |
package graph
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// EducationAssignment
type EducationAssignment struct {
Entity
// Optional fi... | models/microsoft/graph/education_assignment.go | 0.793666 | 0.411761 | education_assignment.go | starcoder |
package pac
import (
"fmt"
"gopkg.in/jcmturner/gokrb5.v5/mstypes"
"gopkg.in/jcmturner/rpc.v0/ndr"
)
// DeviceInfo implements https://msdn.microsoft.com/en-us/library/hh536402.aspx
type DeviceInfo struct {
UserID uint32 // A 32-bit unsigned integer that contains the RID of the ... | vendor/gopkg.in/jcmturner/gokrb5.v5/pac/device_info.go | 0.557123 | 0.432842 | device_info.go | starcoder |
package finverse
import (
"encoding/json"
)
// SingleSourceIncomeIncomeTotal struct for SingleSourceIncomeIncomeTotal
type SingleSourceIncomeIncomeTotal struct {
EstmatedMonthlyIncome *IncomeEstimate `json:"estmated_monthly_income,omitempty"`
// Number of transactions counted towards income
TransactionCount *flo... | finverse/model_single_source_income_income_total.go | 0.742608 | 0.467514 | model_single_source_income_income_total.go | starcoder |
package main
// A demonstration of Strassen's subcubic runtime matrix multiplication
// algorithm on square matrices using the divide and conquer model.
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
func main() {
m1 := mat.NewDense(2, 2, []float64{
1, 2,
3, 4,
})
m2 := mat.NewDense(2, 2, []floa... | Stanford/03_DivideAndConquerModel/3B_StrassensSubcubicMatrixMultiplication/main.go | 0.615088 | 0.425486 | main.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.