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 commands
import (
"github.com/c-bata/go-prompt"
)
type Commands struct {
DockerSuggestions []prompt.Suggest
DockerSubSuggestions map[string][]prompt.Suggest
}
func New() Commands {
return Commands{
DockerSuggestions: []prompt.Suggest{
{Text: "attach", Description: "Attach local standard input, ou... | lib/commands.go | 0.530723 | 0.438845 | commands.go | starcoder |
package common
import (
"image/color"
"math"
"math/rand"
)
type HSV struct {
H, S, V int
}
// ToRGB converts a HSV color mode to RGB mode
// mh, ms, mv are used to set the maximum number for HSV.
func (hs HSV) ToRGB(mh, ms, mv int) color.RGBA {
if hs.H > mh {
hs.H = mh
}
if hs.S > ms {
hs.S = ms
}
if ... | common/utils.go | 0.805326 | 0.451508 | utils.go | starcoder |
package dymessage
import "fmt"
type (
// Represents a collection of message definitions. The messages
// defined in the registry may refer only these messages, which are
// also defined in the same registry.
Registry struct {
// A collection of message definitions at the positions by
// which these definition... | registry.go | 0.725843 | 0.476032 | registry.go | starcoder |
package ui
import (
"regexp"
"strconv"
"strings"
)
// Expand expands a format string using `git log` message syntax.
func Expand(format string, values map[string]string, colorize bool) string {
f := &expander{values: values, colorize: colorize}
return f.Expand(format)
}
// An expander is a stateful helper to ex... | ui/format.go | 0.598312 | 0.422266 | format.go | starcoder |
package validpositions
// A Tree represents a tree of valid array positions. It's a data structure very specifically designed to store
// valid Bleve array positions, and computing their intersections.
// An array position is a []uint64 that denotes the array positions of a certain match
// Example: if we have a field... | pkg/search/blevesearch/validpositions/tree.go | 0.882592 | 0.807309 | tree.go | starcoder |
package mat64
import (
"github.com/gonum/blas"
"github.com/gonum/blas/blas64"
"github.com/gonum/lapack/lapack64"
)
const badTriangle = "mat64: invalid triangle"
// Cholesky calculates the Cholesky decomposition of the matrix A and returns
// whether the matrix is positive definite. The returned matrix is either ... | vendor/github.com/gonum/matrix/mat64/cholesky.go | 0.627837 | 0.560974 | cholesky.go | starcoder |
package math
import (
"math"
)
// Delta represents a move between two pixel positions.
type Delta struct {
DX, DY int
}
func (d Delta) Norm0() int {
norm := 0
if d.DX > norm {
norm = d.DX
} else if -d.DX > norm {
norm = -d.DX
}
if d.DY > norm {
norm = d.DY
} else if -d.DY > norm {
norm = -d.DY
}
r... | internal/math/delta.go | 0.777933 | 0.561455 | delta.go | starcoder |
package DG2D
import (
"fmt"
"github.com/notargets/gocfd/utils"
)
type LagrangeElement2D struct {
N, Nfp, Np, NFaces int
R, S utils.Vector
Dr, Ds utils.Matrix
MassMatrix utils.Matrix
Cub *Cubature
JB2D *JacobiBasis2D
}
type Cubature struct {
r, ... | DG2D/LagrangeElement.go | 0.621311 | 0.581303 | LagrangeElement.go | starcoder |
package awsemfexporter
import (
"time"
"go.opentelemetry.io/collector/model/pdata"
"go.uber.org/zap"
aws "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/metrics"
)
var deltaMetricCalculator = aws.NewFloat64DeltaCalculator()
var summaryMetricCalculator = aws.NewMetricCalculator(calculate... | exporter/awsemfexporter/datapoint.go | 0.774328 | 0.572364 | datapoint.go | starcoder |
package values
import (
"fmt"
"reflect"
"github.com/ppapapetrou76/go-testing/types"
)
// AnyValue is a struct that holds any type of value.
type AnyValue struct {
value interface{}
}
// IsEqualTo returns true if the value is equal to the expected value, else false.
func (s AnyValue) IsEqualTo(expected interface... | internal/pkg/values/any_value.go | 0.853806 | 0.607838 | any_value.go | starcoder |
package cryptolib
import (
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"math/big"
"strconv"
)
// GetBlockSubsidyForHeight func
func GetBlockSubsidyForHeight(height uint64) uint64 {
halvings := height / 210000
// Force block reward to zero when right shift is undefined.
if halvings >= 64 {
return 0
}
... | vendor/bitbucket.org/simon_ordish/cryptolib/utils.go | 0.59561 | 0.416441 | utils.go | starcoder |
// Package rla provides an implementation of RLA (Recurrent Linear Attention).
// See: "Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention" by Katharopoulos et al., 2020.
// TODO: support arbitrary mapping functions
package rla
import (
"encoding/gob"
mat "github.com/nlpodyssey/spago/pkg/... | pkg/ml/nn/recurrent/rla/rla.go | 0.646237 | 0.50708 | rla.go | starcoder |
package main
import (
"crypto/rsa"
"fmt"
)
type PresentDto struct {
Type string
// name of the server
Data string
}
func MakePresent(address string) PresentDto {
return PresentDto{Type: "present", Data: address}
}
type PeerList struct {
Peers []string
SequencerPk rsa.PublicKey
}
type PeersListDto str... | handins/8/requests.go | 0.560734 | 0.413181 | requests.go | starcoder |
package types
import (
"time"
"github.com/spf13/pflag"
)
// The following types are used internally in problem detector. In the future this could be the
// interface between node problem detector and other problem daemons.
// We added these types because:
// 1) The kubernetes api packages are too heavy.
// 2) We w... | pkg/types/types.go | 0.579162 | 0.441312 | types.go | starcoder |
package goavro
import (
"fmt"
"sort"
"strconv"
"strings"
)
// pcfProcessor is a function type that given a parsed JSON object, returns its
// Parsing Canonical Form according to the Avro specification.
type pcfProcessor func(s interface{}) (string, error)
// parsingCanonialForm returns the "Parsing Canonical Fo... | vendor/github.com/linkedin/goavro/v2/canonical.go | 0.804598 | 0.453443 | canonical.go | starcoder |
As a way to play with functions and loops, let's implement a square root function: given a number x, we want to find the number z for which z² is most nearly x.
Computers typically compute the square root of x using a loop. Starting with some guess z, we can adjust z based on how close z² is to x, producing a better g... | interview_questions/byos.go | 0.843444 | 0.974508 | byos.go | starcoder |
package ast
import (
"bytes"
"fmt"
"strings"
)
// IntegerLiteral contains the node expression and its value
type IntegerLiteral struct {
*BaseNode
Value int
}
func (il *IntegerLiteral) expressionNode() {}
// TokenLiteral is a polymorphic function to return a token literal
func (il *IntegerLiteral) TokenLiteral... | compiler/ast/expressions.go | 0.776029 | 0.591369 | expressions.go | starcoder |
package poset
import (
"bytes"
"sort"
"github.com/Fantom-foundation/go-lachesis/hash"
"github.com/Fantom-foundation/go-lachesis/inter"
"github.com/Fantom-foundation/go-lachesis/inter/idx"
)
func (p *Poset) frameConsensusTime(frame idx.Frame) inter.Timestamp {
if frame == 0 {
return p.PrevEpoch.Time
}
retu... | poset/event_ordering.go | 0.752013 | 0.448909 | event_ordering.go | starcoder |
package image
import (
"encoding/binary"
"math"
colorExt "github.com/chai2010/image/color"
)
func pGrayAt(pix []byte) colorExt.Gray {
return colorExt.Gray{
Y: pix[1*0],
}
}
func pSetGray(pix []byte, c colorExt.Gray) {
pix[1*0] = c.Y
}
func pGray16At(pix []byte) colorExt.Gray16 {
return colorExt.Gray16{
... | utils.go | 0.773815 | 0.543772 | utils.go | starcoder |
package geojson
import (
"encoding/json"
"errors"
"fmt"
)
// A GeometryType serves to enumerate the different GeoJSON geometry types.
type GeometryType string
// The geometry types supported by GeoJSON 1.0
const (
GeometryPoint GeometryType = "Point"
GeometryMultiPoint GeometryType = "MultiPoint"... | vendor/github.com/paulmach/go.geojson/geometry.go | 0.852966 | 0.620737 | geometry.go | starcoder |
// Package leb128 provides functions for reading integer values encoded in the
// Little Endian Base 128 (LEB128) format: https://en.wikipedia.org/wiki/LEB128
package leb128
import (
"io"
)
// ReadVarUint32Size reads a LEB128 encoded unsigned 32-bit integer from r.
// It returns the integer value, the size of the e... | vm/wasmvm/wasm/leb128/read.go | 0.815012 | 0.536374 | read.go | starcoder |
package symexpr
import (
"sort"
// "fmt"
)
func (n *Time) AmILess(r Expr) bool { return TIME < r.ExprType() }
func (n *Time) AmIEqual(r Expr) bool { return r.ExprType() == TIME }
func (n *Time) AmISame(r Expr) bool { return r.ExprType() == TIME }
func (n *Time) AmIAlmostSame(r Expr) bool { return ... | compare.go | 0.571647 | 0.477432 | compare.go | starcoder |
package tak
import "fmt"
type position3 struct {
Position
alloc struct {
Height [3 * 3]uint8
Stacks [3 * 3]uint64
Groups [6]uint64
}
}
type position4 struct {
Position
alloc struct {
Height [4 * 4]uint8
Stacks [4 * 4]uint64
Groups [8]uint64
}
}
type position5 struct {
Position
alloc struct {
H... | tak/alloc.go | 0.577257 | 0.472257 | alloc.go | starcoder |
package http
import (
"fmt"
"net/http"
"strconv"
"strings"
)
// Range represents an RFC7233 (suffix) byte range spec. See https://tools.ietf.org/html/rfc7233#page-7
type Range struct {
// FirstBytePos is -1 if a suffix-byte-range-spec is represented.
// Otherwise, FirstBytePos is the offset of the first byte in... | http/range.go | 0.582729 | 0.429609 | range.go | starcoder |
package tdigest
import (
"fmt"
"math"
"sort"
)
type centroid struct {
mean float64
count uint32
index int
}
func (c centroid) isValid() bool {
return !math.IsNaN(c.mean) && c.count > 0
}
func (c *centroid) Update(x float64, weight uint32) {
c.count += weight
c.mean += float64(weight) * (x - c.mean) / floa... | src/toolkits/go-tdigest/summary.go | 0.66454 | 0.417331 | summary.go | starcoder |
package kmeans
import (
"fmt"
"math/rand"
"time"
)
// Kmeans configuration/option struct
type Kmeans struct {
// when a plotter is set, Plot gets called after each iteration
plotter Plotter
// deltaThreshold (in percent between 0.0 and 0.1) aborts processing if
// less than n% of data points shifted clusters i... | vendor/github.com/muesli/kmeans/kmeans.go | 0.729712 | 0.536313 | kmeans.go | starcoder |
package grue
import "math"
// Types here are abstracted from specific graphics library.
// Although pixel has same types, we need not to create dependency
// on pixel.
// Vec decribes point or vector on surface.
type Vec struct {
X, Y float64
}
// Add returns sum of vectors
func (v Vec) Add(u Vec) Vec {
return Ve... | geometry.go | 0.92597 | 0.604574 | geometry.go | starcoder |
package magi
import (
"image"
"image/color"
"github.com/golang/freetype/raster"
)
type RepeatOp int
const (
RepeatBoth RepeatOp = iota
RepeatX
RepeatY
RepeatNone
)
type Pattern interface {
ColorAt(x, y int) color.Color
}
// Solid Pattern
type solidPattern struct {
color color.Color
}
func (p *solidPatte... | pattern.go | 0.701202 | 0.409044 | pattern.go | starcoder |
package benchstat
import (
"fmt"
"strings"
)
// A Scaler is a function that scales and formats a measurement.
// All measurements within a given table row are formatted
// using the same scaler, so that the units are consistent
// across the row.
type Scaler func(float64) string
// NewScaler returns a Scaler appr... | benchstat/scaler.go | 0.778733 | 0.522811 | scaler.go | starcoder |
package cipher
var (
upperCase = [26]byte{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}
lowerCase = [26]byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',... | Extra exercises/Easy/simple-cipher/simple_cipher.go | 0.734596 | 0.470189 | simple_cipher.go | starcoder |
package main
import (
"fmt"
"math"
)
// ResultTable store the results after apply Dijsktra algorithm
type ResultTable struct {
origin *Row
table []*Row
}
// Exported methods
// Print in console the result for each vertex
func (t *ResultTable) Print() {
for _, row := range t.table {
fmt.Println(row)
}
}
//... | graphs/dijkstras_algorithm/results_table.go | 0.644896 | 0.498108 | results_table.go | starcoder |
package chess
const (
numOfSquaresInBoard = 64
numOfSquaresInRow = 8
)
// A Square is one of the 64 rank and file combinations that make up a chess board.
type Square int8
// File returns the square's file.
func (sq Square) File() File {
return File(int(sq) % numOfSquaresInRow)
}
// Rank returns the square's r... | square.go | 0.823506 | 0.407039 | square.go | starcoder |
package dmap
import (
"bytes"
"fmt"
"math"
)
// Point is a representation of a point on a map
type Point interface {
GetXY() (int, int)
}
// Map is a map to calculate dmaps with. All methods should be linear
// time, as the algorithm will call them a lot. Also your map should
// be statically sized; if the map i... | dijkstra.go | 0.743354 | 0.548553 | dijkstra.go | starcoder |
package epb
// Regulator represents an energy regulator.
type Regulator string
// Energy regulators
const (
RegulatorBrussels Regulator = "brussels"
RegulatorFlanders Regulator = "flanders"
RegulatorFrance Regulator = "france"
RegulatorWallonia Regulator = "wallonia"
)
// EnergyClass returns the energy class o... | epb.go | 0.666714 | 0.719421 | epb.go | starcoder |
package lib
import (
"fmt"
"math/big"
)
// This library implements basic float functions using big.Float objects.
// This is necessary in order to ensure interoperability across different
// machines. If we instead were to use float64's for our computations
// naively, then machines with different rounding rules or... | lib/bitclout_math.go | 0.541651 | 0.487795 | bitclout_math.go | starcoder |
package types
import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Delegation represents a single delegation made from a delegator
// to a specific validator at a specific height (and timestamp)
// containing a given amount of tokens
type Delegation struct {
DelegatorAddress string
ValidatorAddress stri... | x/staking/types/delegations.go | 0.738198 | 0.417806 | delegations.go | starcoder |
package iso20022
// Set of elements used to provide information on the settlement of the instruction.
type SettlementInformation13 struct {
// Method used to settle the (batch of) payment instructions.
SettlementMethod *SettlementMethod1Code `xml:"SttlmMtd"`
// A specific purpose account used to post debit and cr... | SettlementInformation13.go | 0.723016 | 0.451689 | SettlementInformation13.go | starcoder |
package sqlb
import r "reflect"
/*
Variant of `[]interface{}` conforming to the `ArgDict` interface. Supports only
ordinal parameters, not named parameters. Used for `StrQ`. See the `ListQ`
shortcut.
*/
type List []interface{}
// Implement part of the `ArgDict` interface.
func (self List) IsEmpty() bool { return sel... | sqlb_dict.go | 0.818229 | 0.487673 | sqlb_dict.go | starcoder |
package dominance
type Float64Vector []float64
var _ Candidate = &Float64Vector{}
func NewFloat64(size int) *Float64Vector {
vector := make(Float64Vector, size)
return &vector
}
func (v *Float64Vector) IsComparable(otherCandidate Candidate) bool {
if !isFloat64Vector(otherCandidate) {
return false
}
otherC... | pkg/dominance/Float64Vector.go | 0.744842 | 0.550849 | Float64Vector.go | starcoder |
package evm
func memorySha3(stack *Stack) (uint64, bool) {
return calcMemSize64(stack.Back(0), stack.Back(1))
}
func memoryCallDataCopy(stack *Stack) (uint64, bool) {
return calcMemSize64(stack.Back(0), stack.Back(2))
}
func memoryReturnDataCopy(stack *Stack) (uint64, bool) {
return calcMemSize64(stack.Back(0), s... | evm/memory_table.go | 0.78899 | 0.440108 | memory_table.go | starcoder |
package mod
import (
"image"
"image/color"
"math"
"github.com/oakmound/oak/v2/dlog"
)
// A Filter modifies an input image in place. This is useful notably for modifying
// a screen buffer, as they will refuse to be modified in any other way. This cannot
// change the dimensions of the underlying image.
type Filt... | render/mod/filter.go | 0.713631 | 0.453262 | filter.go | starcoder |
package kata
/*
Introduction
The wave (known as the Mexican wave in the English-speaking world outside North America) is an example of metachronal rhythm achieved in a packed stadium when successive groups of spectators briefly stand, yell, and raise their arms. Immediately upon stretching to full height, the spectato... | katas/kyu6/mexican_wave/wave.go | 0.625209 | 0.655164 | wave.go | starcoder |
package iso20022
// Completion of a securities settlement instruction, wherein securities are delivered/debited from a securities account and received/credited to the designated securities account.
type Transfer7 struct {
// Unique and unambiguous identifier for a group of individual transfers as assigned by the ins... | Transfer7.go | 0.821044 | 0.413477 | Transfer7.go | starcoder |
package change
import "math"
type Stats struct {
N int
Mean float64
Variance float64
}
func (s Stats) Stddev() float64 { return math.Sqrt(s.Variance) }
// cohen computes Cohen's d effect size between two means.
func cohen(s1, s2 Stats) float64 {
return (s1.Mean - s2.Mean) / pooledStddev(s1, s2)
}
//... | app/change/stats.go | 0.877962 | 0.510069 | stats.go | starcoder |
package testutil
import (
"fmt"
"io/ioutil"
"os"
"reflect"
"regexp"
"sort"
"testing"
"github.com/go-test/deep"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/diff"
)
func AssertNoErr(t *testing.T, err error, msg string, args ...interface{}) {
t.Helper()
if err != nil {
t.Fatalf(errors.Wrapf(err,... | testutil/assertions.go | 0.53437 | 0.447038 | assertions.go | starcoder |
package cios
import (
"encoding/json"
)
// DataStoreObjectLocation struct for DataStoreObjectLocation
type DataStoreObjectLocation struct {
Latitude *float32 `json:"latitude,omitempty"`
Longitude *float32 `json:"longitude,omitempty"`
Altitude *float32 `json:"altitude,omitempty"`
}
// NewDataStoreObjectLocation ... | cios/model_data_store_object_location.go | 0.818302 | 0.510435 | model_data_store_object_location.go | starcoder |
package bresenham
// 2016-10-22, <NAME>
// * Do not use in production. It's just an exercise
import (
"image/color"
"image/draw"
)
// Floating point
func Bresenham_1(img draw.Image, x1, y1, x2, y2 int, col color.Color) {
dx, dy := x2-x1, y2-y1
a := float64(dy) / float64(dx)
b := int(float64(y1) - a*fl... | bresenham/line.go | 0.538983 | 0.563018 | line.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
"termsOfService": "http:/... | docs/docs.go | 0.616474 | 0.453383 | docs.go | starcoder |
package hmath
import (
"fmt"
"github.com/barnex/fmath"
)
type Mat4 [16]float32
func (mat4 *Mat4) Pointer() *[16]float32 { return (*[16]float32)(mat4) }
func (mat4 *Mat4) Slice() []float32 { return mat4[:] }
func (mat4 *Mat4) String() string {
return fmt.Sprintf("[%f,%f,%f,%f,\n %f,%f,%f,%f,\n %f,%f,%f,%f,\... | code/pkg/hmath/mat4.go | 0.658747 | 0.6372 | mat4.go | starcoder |
package geojson
import (
"encoding/json"
"errors"
"github.com/go-courier/geography"
"github.com/go-courier/geography/coordstransform"
"github.com/go-courier/geography/maptile"
)
type FeatureCollection struct {
coordsTransform *coordstransform.CoordsTransform
Type string `json:"type"... | encoding/geojson/feature_collection.go | 0.644449 | 0.412885 | feature_collection.go | starcoder |
package main
import (
"math"
)
// Sphere Maps a sphere object
type Sphere ObjectElement
func generateSphereFromObject(object *Object) (Sphere) {
return generateSphere(object.Radius, object.Compression, object.Radiate)
}
func generateSphere(radius float32, compression float32, radiate bool) (Sphere) {
var (
... | sphere.go | 0.836521 | 0.572603 | sphere.go | starcoder |
package agg
import (
"fmt"
"strings"
"github.com/emer/etable/etable"
"github.com/goki/ki/kit"
)
// Aggs is a list of different standard aggregation functions, which can be used
// to choose an aggregation function
type Aggs int
const (
// Count of number of elements
AggCount Aggs = iota
// Sum of elements
... | agg/aggs.go | 0.730866 | 0.422743 | aggs.go | starcoder |
package xmobilebackend
import (
"image"
"image/color"
"unsafe"
"golang.org/x/mobile/gl"
)
// GetImageData returns an RGBA image of the current image
func (b *XMobileBackend) GetImageData(x, y, w, h int) *image.RGBA {
b.activate()
if x < 0 {
w += x
x = 0
}
if y < 0 {
h += y
y = 0
}
if w > b.w {
w... | backend/xmobilebackend/imagedata.go | 0.61659 | 0.433502 | imagedata.go | starcoder |
package bn256
import (
"errors"
"math/big"
)
// G2 is an abstract cyclic group. The zero value is suitable for use as the
// output of an operation, but cannot be used as an input.
type G2 struct {
p *twistPoint
}
func (e *G2) String() string {
return "bn256.G2" + e.p.String()
}
// Base set e to g where g is th... | bn256/bn256g2.go | 0.754825 | 0.495117 | bn256g2.go | starcoder |
package spatial
import (
"fmt"
"github.com/qoeg/aoc2019/util"
)
// Grid represents a two dimensional grid of cells
type Grid [][]Cell
// Draw updates cells in the Grid with new cells
func (g Grid) Draw(line []Cell) {
for i := range line {
coord := line[i].Pos()
if i > 0 && g[coord.X][coord.Y].Mark() != '.' {... | spatial/grid.go | 0.730866 | 0.524943 | grid.go | starcoder |
package object
import (
"math"
"github.com/carlosroman/aun-otra-ray-tracer/go/internal/ray"
)
type Pattern struct {
Transform ray.Matrix
TransformInverse ray.Matrix
At func(point ray.Vector) RGB
IsNotEmpty bool
}
func (p Pattern) AtObj(obj Object, worldPoint ray.Vector) RGB {
objPo... | go/internal/object/pattern.go | 0.829181 | 0.606848 | pattern.go | starcoder |
package math
import "math"
type Box2 struct {
Min *Vector2
Max *Vector2
}
func NewBox2() *Box2 {
b := &Box2{
Min:&Vector2{X:math.Inf(0), Y:math.Inf(0)},
Max:&Vector2{X:math.Inf(-1), Y:math.Inf(-1)},
}
return b
}
func (b *Box2) Set(min, max *Vector2) *Box2 {
b.Min.Copy( min )
b.Max.Copy( max )
return ... | math/box2.go | 0.830732 | 0.558929 | box2.go | starcoder |
package data
import (
"math/big"
"time"
)
// expects all arguments to match the type passed in as flag
func NewUnboxed(flag TyNat, args ...Native) Sliceable {
var d Sliceable
switch flag {
case Nil:
d = NilVec{}
for _, _ = range args {
d = append(d.(NilVec), struct{}{})
}
case Bool:
d = BoolVec{}
... | data/unboxedArray.go | 0.534612 | 0.425665 | unboxedArray.go | starcoder |
package qrad
import (
"fmt"
"math"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().Unix())
}
type Vector struct {
Elements []Complex
}
func (v Vector) Log2Size() int {
return int(math.Log2(float64(len(v.Elements))))
}
func (c Vector) At(i int) Complex {
if i > len(c.Elements) {
panic("Invalid off... | vector.go | 0.712332 | 0.533397 | vector.go | starcoder |
package plru
import (
"math"
)
const (
blockSize = 64
blockMask = blockSize - 1
blockFull = math.MaxUint64
)
// Policy is the
type Policy struct {
blocks []uint64
counter uint64
}
// NewPolicy returns an empty Policy where size is the number of entries to
// track. The size param is rounded up to the next mu... | plru.go | 0.599485 | 0.466846 | plru.go | starcoder |
package tilemap
import (
"image"
"math/rand"
"os"
_ "image/png"
"github.com/faiface/pixel"
"../config"
"../hex"
)
var (
spritesheet pixel.Picture
sprites = make([]*pixel.Sprite, Max)
Batch *pixel.Batch
)
type Tile struct {
hex.Hex
Type TileType
Sprite *pixel.Sprite
Rect pixel.Rect
}
f... | tilemap/tilemap.go | 0.600071 | 0.407687 | tilemap.go | starcoder |
package xtesting
import (
"fmt"
"path"
"reflect"
"runtime"
"testing"
)
// failTest outputs the error message and fails the test. Default skip is 1.
func failTest(t testing.TB, skip int, msg string, msgAndArgs ...interface{}) bool {
flag := ""
if skip >= 0 {
_, file, line, _ := runtime.Caller(skip + 1)
msg... | xtesting/xtesting.go | 0.753104 | 0.578805 | xtesting.go | starcoder |
package parser
import (
"fmt"
"strconv"
"github.com/robotii/lito/compiler/ast"
"github.com/robotii/lito/compiler/parser/errors"
"github.com/robotii/lito/compiler/parser/precedence"
"github.com/robotii/lito/compiler/token"
)
// parseIntegerLiteral parses an integer from the current token
func (p *Parser) parseI... | compiler/parser/data_type_parsing.go | 0.640411 | 0.437463 | data_type_parsing.go | starcoder |
package ent
import (
"fmt"
"strings"
"github.com/facebook/ent/dialect/sql"
"github.com/tennashi/ent-sample/ent/namespace"
)
// Namespace is the model entity for the Namespace schema.
type Namespace struct {
config `json:"-"`
// ID of the ent.
ID string `json:"id,omitempty"`
// Name holds the value of the "n... | ent/namespace.go | 0.63409 | 0.415907 | namespace.go | starcoder |
package api
import (
"fmt"
"strconv"
"strings"
)
/*AssertValidType returns whether a given value is of the expected type
if the initial conversion fails, it will convert to string then convert to type where appropriate */
func AssertValidType(value interface{}, expectedType string) bool {
switch {
case expectedT... | pkg/api/typeUtils.go | 0.66454 | 0.540378 | typeUtils.go | starcoder |
package metric
import (
"fmt"
"sort"
)
// average is a helper for calculating an average value of something
type average struct {
Sum float64
Count int
}
// Calculate divides Sum by Count
func (a average) Calculate() float64 {
return a.Sum / float64(a.Count)
}
// averageMap is a map which contains an average... | metric/util.go | 0.838581 | 0.501587 | util.go | starcoder |
// Package frames describes the Frame interface.
// A set of standard frames are also defined in this package. These are: Fixed, Window, Wild and WildMin.
package frames
import (
"errors"
"strconv"
"github.com/richardlehane/siegfried/pkg/core/bytematcher/patterns"
"github.com/richardlehane/siegfried/pkg/core/sig... | pkg/core/bytematcher/frames/frames.go | 0.839898 | 0.474936 | frames.go | starcoder |
package main
import (
"fmt"
"image"
"math/rand"
"github.com/emer/emergent/env"
"github.com/emer/etable/etensor"
)
// ExEnv is an example environment, that sets a single input point in a 2D
// input state and two output states as the X and Y coordinates of point.
// It can be used as a starting point for writin... | examples/env/env.go | 0.660282 | 0.439928 | env.go | starcoder |
package rel
import (
"reflect"
)
// mapLiteral is an implementation of Relation using a map
type mapLiteral struct {
// the map of tuples in the relation, with tuples in the key
rbody reflect.Value // should always hold a map
// set of candidate keys
cKeys CandKeys
// the type of the tuples contained within... | mapliteral.go | 0.720467 | 0.458591 | mapliteral.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// WorkbookTableRow
type WorkbookTableRow struct {
Entity
// Returns the index number of the row within the rows collection of the table. Zero-indexed. Re... | models/workbook_table_row.go | 0.743168 | 0.484136 | workbook_table_row.go | starcoder |
// D55 illuminant conversion functions
package white
// D55_A functions
func D55_A_Bradford(xs, ys, zs float64) (xd, yd, zd float64) {
m := [3][3]float64{
{1.1802853, 0.0968577, -0.1385564},
{0.1334256, 0.9182995, -0.0498798},
{-0.0216899, 0.0327363, 0.3731642}}
xd = m[0][0]*xs + m[0][1]*ys + m[0][2]*zs
yd ... | f64/white/d55.go | 0.52074 | 0.583945 | d55.go | starcoder |
package main
/*****************************************************************************************************
*
* Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two
* sorted arrays.
*
* Follow up: The overall run time complexity should be O(log (m+n)).
*
* E... | basic/Algorithm/array/4.median_of_two_sorted_arrays/4.MedianofTwoSortedArrays_zmillionaire.go | 0.536313 | 0.686954 | 4.MedianofTwoSortedArrays_zmillionaire.go | starcoder |
package state
import (
"bytes"
"errors"
"fmt"
dbm "github.com/tendermint/tm-db"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/types"
)
//-----------------------------------------------------
// Validate block
func validateBlock(evidencePool EvidencePool, stateDB dbm.DB, blockSto... | state/validation.go | 0.596903 | 0.430207 | validation.go | starcoder |
package common
import (
"math"
"sort"
"github.com/m3db/m3/src/query/graphite/ts"
)
// Range distills down a set of inputs into the range of the series.
func Range(ctx *Context, series ts.SeriesList, renamer SeriesListRenamer) (*ts.Series, error) {
numSeries := series.Len()
if numSeries == 0 {
return nil, Err... | src/query/graphite/common/aggregation.go | 0.773345 | 0.444685 | aggregation.go | starcoder |
package clusterhealth
import (
"log"
"github.com/monitoring-tools/prom-elasticsearch-exporter/elasticsearch"
"github.com/monitoring-tools/prom-elasticsearch-exporter/elasticsearch/model"
"github.com/monitoring-tools/prom-elasticsearch-exporter/metrics"
"github.com/prometheus/client_golang/prometheus"
)
// Clust... | collector/clusterhealth/collector.go | 0.651466 | 0.40645 | collector.go | starcoder |
package medtronic
import (
"fmt"
"log"
)
// Carbs represents a carb value as either grams or 10x exchanges.
type Carbs int
// CarbUnitsType represents the pump's carb unit type (grams or exchanges).
type CarbUnitsType byte
//go:generate stringer -type CarbUnitsType
const (
// Grams represents the pump's use of ... | units.go | 0.721056 | 0.547706 | units.go | starcoder |
package mock
import (
"github.com/pkg/errors"
D "github.com/vikneshwara-r-b/chaosmonkey/deploy"
)
const cloudProvider = "aws"
// Dep returns a mock implementation of deploy.Deployment
// Dep has 4 apps: foo, bar, baz, quux
// Each app runs in 1 account:
// foo, bar, baz run in prod
// quux runs in test
// ... | mock/deployment.go | 0.587352 | 0.414662 | deployment.go | starcoder |
package popcount
// bithacks-based implementation in go for 32-bit values.
func PopCount32(v uint32) int {
/*
This is taken from bithacks.
0xf = 1111
0x5 = 0101
0x3 = 0011
0x1 = 0001
We wish to map each 2-bit pair as follows to its pop count
stored in 2 counter bits:
nibble count
... | popcount.go | 0.642096 | 0.598342 | popcount.go | starcoder |
package xcounter
import (
"math"
"sync"
"sync/atomic"
"time"
"github.com/m3db/m3x/clock"
)
type frequencyBucket struct {
sync.RWMutex
timestamp time.Time
count int64
}
// record records the frequency value n for a given time.
// If the frequency value is too old, it's discarded.
// Returns true if the... | src/dbnode/x/xcounter/frequency_counter.go | 0.712932 | 0.410047 | frequency_counter.go | starcoder |
package z80
import (
"fmt"
"strings"
"github.com/blackchip-org/pac8/pkg/memory"
"github.com/blackchip-org/pac8/pkg/proc"
"github.com/blackchip-org/pac8/pkg/util/bits"
)
func ReaderZ80(e proc.Eval) proc.Statement {
e.Statement.Address = e.Cursor.Pos
opcode := e.Cursor.Fetch()
e.Statement.Bytes = append(e.Stat... | pkg/z80/reader.go | 0.503662 | 0.400251 | reader.go | starcoder |
package manual
func future() string {
return `Expected in next chapter
- Semicolon statement terminator
- Void assignments
- Native variable deletion
- Spell returns
- Spells
- @Args() number
- @Exists(identifier) bool
- @Len(value) number
- @Str(value) string
- @Panic(exitcode, message)
Assignments
Some of ... | _manual/future.go | 0.709523 | 0.498596 | future.go | starcoder |
package sac
import (
"github.com/seqsense/pcgol/mat"
"github.com/seqsense/pcgol/pc"
"github.com/seqsense/pcgol/pc/storage/voxelgrid"
)
type voxelGridSurfaceModel struct {
vg *voxelgrid.VoxelGrid
ra pc.Vec3RandomAccessor
vgMin, vgMax, vgSize mat.Vec3
}
const (
sqrt3 = 1.73... | pc/sac/surface.go | 0.619701 | 0.404949 | surface.go | starcoder |
package bst
// T is the internal representation of a binary search tree.
type T struct {
root *node
count int
}
// node is the internal representation of a binary tree node.
type node struct {
key int
val interface{}
l, r *node
}
// TraversalType represents one of the three know traversals.
type TraversalTyp... | bst/bst.go | 0.822296 | 0.548674 | bst.go | starcoder |
package expression
import (
"strconv"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/trace_util_0"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
)
// Vectorizable checks whether a list of expressions can e... | expression/chunk_executor.go | 0.506103 | 0.412589 | chunk_executor.go | starcoder |
package bls
import (
"encoding/binary"
"errors"
"fmt"
"math/big"
"math/bits"
)
//go:generate go run asm/asm.go -out primitivefuncs_amd64.s
// FQRepr represents a uint384. The least significant bits are first.
type FQRepr [6]uint64
// IsOdd checks if the FQRepr is odd.
func (f FQRepr) IsOdd() bool {
return f[0... | fqrepr.go | 0.596668 | 0.505066 | fqrepr.go | starcoder |
// Package remap handles tracking the locations of Go tokens in a source text
// across a rewrite by the Go formatter.
package remap
import (
"fmt"
"go/scanner"
"go/token"
)
// A Location represents a span of byte offsets in the source text.
type Location struct {
Pos, End int // End is exclusive
}
// A Map rep... | vendor/github.com/golang/protobuf/protoc-gen-go/generator/internal/remap/remap.go | 0.743354 | 0.485295 | remap.go | starcoder |
package fq12over6over2
// Fq2FallBack ...
const Fq2FallBack = `
func addE2(z, x, y *e2) {
z.A0.Add(&x.A0, &y.A0)
z.A1.Add(&x.A1, &y.A1)
}
func subE2(z, x, y *e2) {
z.A0.Sub(&x.A0, &y.A0)
z.A1.Sub(&x.A1, &y.A1)
}
func doubleE2(z, x *e2) {
z.A0.Double(&x.A0)
z.A1.Double(&x.A1)
}
func negE2(z, x *e2) {
z.A0.Ne... | internal/templates/fq12over6over2/fq2.go | 0.769817 | 0.583856 | fq2.go | starcoder |
package cmd
import (
"fmt"
"strconv"
"strings"
"github.com/spf13/cobra"
)
var queryFPRCmd = &cobra.Command{
Use: "query-fpr",
Short: "Compute the maximal false positive rate of a query",
Long: `Compute the maximal false positive rate of a query
Solomon and Kingsford apply a Chernoff bound and show that th... | kmcp/cmd/query-fpr.go | 0.675122 | 0.403273 | query-fpr.go | starcoder |
package vfilter
import (
"image"
"sync"
"github.com/emer/etable/etensor"
"github.com/emer/vision/nproc"
)
// Conv performs convolution of filter over img into out.
// img *must* have border (padding) so that filters are
// applied without any bounds checking -- wrapping etc is all
// done in the padding process... | vfilter/conv.go | 0.592902 | 0.426799 | conv.go | starcoder |
package models
import (
"math"
"time"
)
// Position contains positional data of a vehicle
type Position struct {
Lat float64 `json:"lat"` // Latitude in degrees * 1E7
Lon float64 `json:"lon"` // Longitude in degrees * 1E7
Alt float64 `json:"alt"` // Altitude in millimeters
RelAl... | models/position.go | 0.873552 | 0.633793 | position.go | starcoder |
package bow
import (
"github.com/apache/arrow/go/arrow"
)
type Type int
// How to add a Type:
// - Seek corresponding arrow.DataType and add it in `mapArrowToBowTypes`
// - add a convert function with desired logic and add case in other conversion func
// - add necessary case in buffer file
// - complete GetValue b... | bowtypes.go | 0.671686 | 0.434821 | bowtypes.go | starcoder |
// SPDX-License-Identifier: MIT
// see https://spdx.org/licenses/
package tapfile
import (
"math"
)
/*
TAP file format definitions.
The TAP file contains an arbitrary numbery of data. The data is organized into a data block preceded
by a header of an appropriate type. Each header and data blocks are preceeded by ... | tapfile/tapfile.go | 0.584153 | 0.477189 | tapfile.go | starcoder |
package rui
// ResizeEvent is the constant for "resize-event" property tag.
// The "resize-event" is fired when the view changes its size.
// The main listener format:
// func(View, Frame).
// The additional listener formats:
// func(Frame), func(View), and func().
const ResizeEvent = "resize-event"
func (view *v... | resizeEvent.go | 0.639398 | 0.448245 | resizeEvent.go | starcoder |
package server
import (
"errors"
"image"
)
const maxInt = int(^uint(0) >> 1)
type MaxRectsBin struct {
Width, Height int
Padding int
usedRectangles []image.Rectangle
freeRectangles []image.Rectangle
}
func NewBin(width, height, padding int) *MaxRectsBin {
return &MaxRectsBin{
Width: width,... | server/MaxRectsBin.go | 0.718397 | 0.70797 | MaxRectsBin.go | starcoder |
package stats
import (
"fmt"
"golina/matrix"
"math"
)
// Independent Component Analysis
// https://en.wikipedia.org/wiki/Independent_component_analysis
// The following explanation are from wiki.
// Two assumptions:
// 1. The source signals are independent of each other.
// 2. The values in each source signal ha... | stats/ICA.go | 0.643105 | 0.800146 | ICA.go | starcoder |
package fib
// Basic recursive algorithm, with exponential run time. Simply makes two extra
// calls for level. In testing benchmarks, we do not go above 32 for this
// function due to the extreme length of time it takes to complete, it is not
// worth benchmarking. Needless to say, this function is terrible and slo... | fib.go | 0.74158 | 0.481576 | fib.go | starcoder |
package date
import (
"strings"
"time"
)
const (
DefaultDateTime = "Y-m-d h:i:s"
DefaultDate = "Y-m-d"
)
type formatReplace struct {
from string
to string
}
var formatFromTo = [...]formatReplace{
{"d", "02"}, // Day: Day of the month, 2 digits with leading zeros. Eg: 01 to 31.... | date/date.go | 0.647352 | 0.589657 | date.go | starcoder |
package op
import(
"fmt"
"math"
)
// Wrapper for a unary operation.
func wrap1(a any,f func(float64)float64)any{
var t string = fmt.Sprintf("%T", a)
switch t {
case "int": return f(float64(a.(int)))
case "int8": return f(float64(a.(int8)))
case "int16": return f(float64(a.(int16)))
case "int32... | op/math_functions.go | 0.754553 | 0.456289 | math_functions.go | starcoder |
package snomed
import (
"golang.org/x/text/language"
"unicode"
)
// DefinitionStatusID is an indication as to whether a concept is fully defined or primitive.
// A concept may be primitive if
// a) it is inherently impossible to define the concept by defining relationships with other concepts
// b) because attribu... | snomed/model.go | 0.766731 | 0.580174 | model.go | starcoder |
package main
import (
"math"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
var balanceBody *Body
var balanceSin float64
var wheelBody *Body
func biasCoef(errorBias, dt float64) float64 {
return 1.0 - math.Pow(errorBias, dt)
}
func motorPreSolve(motor *Constraint, space *Space) {
dt := ... | examples/unicycle/unicycle.go | 0.756447 | 0.576751 | unicycle.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.