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 templateutils
import (
"fmt"
"reflect"
"strings"
)
// Equal will check whether two value is equal.
func Equal(a, b reflect.Value) bool {
aType := reflect.TypeOf(a)
if aType == nil {
return false
}
bType := reflect.ValueOf(b)
if bType.IsValid() && bType.Type().ConvertibleTo(aType) {
// Attempt comp... | utils.go | 0.677474 | 0.441312 | utils.go | starcoder |
package set
type StringSet map[string]struct{}
// NewStringSet creates a new string set with optional input values.
func NewStringSet(values ...string) StringSet {
s := make(map[string]struct{}, len(values))
for _, value := range values {
s[value] = struct{}{}
}
return s
}
// NewStringSetFromMap creates a new... | pkg/set/stringset.go | 0.885477 | 0.578746 | stringset.go | starcoder |
package infra
import (
"sort"
"github.com/rboyer/devconsul/util"
)
type NetworkShape string
const (
// NetworkShapeIslands describes an isolated island topology where only the
// mesh gateways are on the WAN.
NetworkShapeIslands = NetworkShape("islands")
// NetworkShapeDual describes a private/public lan/wan... | infra/topology.go | 0.59796 | 0.457985 | topology.go | starcoder |
package phomath
import "math"
func qNoop(_ *Quaternion) { /* no operation, the default OnChangeCallback */ }
func NewQuaternion(x, y, z, w float64) *Quaternion {
return &Quaternion{
X: x,
Y: y,
Z: z,
W: w,
OnChangeCallback: qNoop,
}
}
// Quater... | phomath/quaternion.go | 0.910512 | 0.684898 | quaternion.go | starcoder |
package gl
import (
"errors"
"github.com/alivesay/modex/core"
)
// Mesh manages structured vertex data.
type Mesh struct {
vertices []Vertex
VBO *VBO
attribs []VertexAttrib
primitiveType GLPrimitiveType
}
var DefaultVertexAttribs = []VertexAttrib{
VertexAttrib{0, 3, GLFloat, false, 5 * 4... | gfx/gl/mesh.go | 0.537041 | 0.44354 | mesh.go | starcoder |
package unassert
// ErrorHandler handles an error.
// See unassert_panic & unassert_stderr
type ErrorHandler func(format string, v ...interface{})
// Error promotes an error according to 'unassert_' build tags.
// Formats according to a format specifier.
func Error(format string, v ...interface{}) {
if !enabled {
... | unassert.go | 0.808672 | 0.482185 | unassert.go | starcoder |
package option
import (
m "../measures"
)
func FiniteDifferenceGrid(NAS int, SInf float64) func(option Option, t m.Time, sigma m.Return, rf m.Rate) (S []float64, V [][]float64) {
return func(option Option, t m.Time, sigma m.Return, rf m.Rate) (S []float64, V [][]float64) {
Vol := float64(sigma)
RF := float64(rf... | src/option/grid.go | 0.721841 | 0.45417 | grid.go | starcoder |
package main
import (
"encoding/base64"
"encoding/binary"
"fmt"
"net"
)
// ChainState represent the state of the current chain
type ChainState byte
const (
// ChainCreating means that the chain got created but not completly filled yet
ChainCreating ChainState = 0x00
// ChainCreated means... | chainid.go | 0.601125 | 0.416263 | chainid.go | starcoder |
package fp
func (q BoolQueue) FoldLeftBool(z bool, f func(bool, bool) bool) bool {
acc := z
q.Foreach(func(e bool) { acc = f(acc, e) })
return acc
}
func (q BoolQueue) FoldLeftString(z string, f func(string, bool) string) string {
acc := z
q.Foreach(func(e bool) { acc = f(acc, e) })
return acc
}
func (q BoolQue... | fp/bootstrap_queue_foldleft.go | 0.764276 | 0.458349 | bootstrap_queue_foldleft.go | starcoder |
package forGraphBLASGo
import (
"math"
"reflect"
)
type (
Signed interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
}
Unsigned interface {
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
Integer interface {
Signed | Unsigned
}
Float interface {
~float32 | ~float64
}
Number interface ... | api_operators.go | 0.650911 | 0.666497 | api_operators.go | starcoder |
package cvefeed
import (
"encoding/json"
"math/bits"
"github.com/facebookincubator/nvdtools/cvefeed/nvd"
"github.com/facebookincubator/nvdtools/cvefeed/nvd/schema"
)
type bag map[string]interface{}
// ChunkKind is the type of chunks produced by a diff.
type ChunkKind string
const (
// ChunkDescription indica... | cvefeed/diff.go | 0.635109 | 0.431764 | diff.go | starcoder |
// Package nulls wrap up functions for the manipulation of bitmap library roaring.
// MatrixOne uses nulls to store all NULL values in a column.
// You can think of Nulls as a bitmap.
package nulls
import (
"bytes"
"fmt"
"unsafe"
roaring "github.com/RoaringBitmap/roaring/roaring64"
)
// Or performs union operat... | pkg/container/nulls/nulls.go | 0.700485 | 0.472805 | nulls.go | starcoder |
package bit
import "io"
// ReadBit return bit from special offset of byte.
// If offset outside byt length(0 - 7), return zero.
// Byte 0b10000000 get by offset - 0 return One, other is Zero
func ReadBit(byt byte, offset int) Bit {
if offset < ByteMinBit || offset >= ByteMaxBit {
return Zero
}
return (byt >> (By... | bit.go | 0.621196 | 0.420957 | bit.go | starcoder |
package bloom
import (
"bytes"
"errors"
"math"
"sync"
conv "github.com/BOXFoundation/boxd/p2p/convert"
"github.com/BOXFoundation/boxd/util"
"github.com/BOXFoundation/boxd/util/murmur3"
)
const ln2Squared = math.Ln2 * math.Ln2
const (
// MaxFilterHashFuncs is the maximum number of hash functions of bloom fi... | util/bloom/filter.go | 0.699254 | 0.451992 | filter.go | starcoder |
package unicornify
import (
. "github.com/balpha/go-unicornify/unicornify/core"
. "github.com/balpha/go-unicornify/unicornify/elements"
. "github.com/balpha/go-unicornify/unicornify/rendering"
"github.com/balpha/gopyrand"
"image"
"math"
)
func MakeAvatar(hash string, size int, withBackground bool, zoomOut bool,... | unicornify/avatar.go | 0.563378 | 0.463748 | avatar.go | starcoder |
package main
import (
"fmt"
"github.com/emer/emergent/patgen"
"github.com/emer/etable/etensor"
)
// Proof of concept for replacing the environment with a simpler environment that uses the network.
type ExampleWorld struct {
WorldInterface
Nm string `desc:"name of this environment"`
Dsc string `desc:"descripti... | examples/ra25example_world/example_world.go | 0.7478 | 0.4575 | example_world.go | starcoder |
package engine
import (
"fmt"
"image"
"image/color"
"image/draw"
"math"
)
// ChannelImage represents a discrete image.
type ChannelImage struct {
Width int
Height int
Buffer []uint8
}
// NewChannelImageWidthHeight returns a channel image of specific width and height.
func NewChannelImageWidthHeight(width, h... | engine/channel_image.go | 0.773216 | 0.427456 | channel_image.go | starcoder |
package stats
import (
"errors"
"math"
)
// Normal is used to represent the normal distribution parameters.
// Mu is the mean.
// Sigma is the standard deviation.
type Normal struct {
Mu float64
Sigma float64
}
// NewNormal is used to initialize normal parameters. What is different from
// Normal type is that... | probdist/normal.go | 0.848267 | 0.716367 | normal.go | starcoder |
package utils
/*findPosition returns the position and insert position of the given character in the PCArray.
-> If character found, then its position and insert position -1 is returned
-> If character not found, then its position would be -1 and its insert position is returned
-> insert Position would be -1 if the... | utils/utils.go | 0.575827 | 0.543469 | utils.go | starcoder |
package go3mf
import (
"errors"
"github.com/qmuntal/go3mf/geo"
)
// SliceResolution defines the resolutions for a slice.
type SliceResolution uint8
const (
// ResolutionFull defines a full resolution slice.
ResolutionFull SliceResolution = iota
// ResolutionLow defines a low resolution slice.
ResolutionLow
)
... | slices.go | 0.800887 | 0.476945 | slices.go | starcoder |
package diff
// ConvertTypes enables values that are convertible to the target type to be converted when patching
func ConvertCompatibleTypes() func(d *Differ) error {
return func(d *Differ) error {
d.ConvertCompatibleTypes = true
return nil
}
}
// FlattenEmbeddedStructs determines whether fields of embedded st... | vendor/github.com/r3labs/diff/v2/options.go | 0.83508 | 0.477981 | options.go | starcoder |
package spriter
import (
"math"
)
func ternary(c bool, a float64, b float64) float64 {
if c {
return a
} else {
return b
}
}
func signum(f float64) float64 {
return ternary(f == 0.0 || math.IsNaN(f), f, math.Copysign(1.0, f))
}
func angleDifference(a float64, b float64) float64 {
return math.Min((2*math.P... | math.go | 0.845656 | 0.675855 | math.go | starcoder |
package maths
import (
"fmt"
"math"
"github.com/wdevore/RangerGo/api"
)
type vector struct {
x, y float64
}
// NewVector constructs a new IVector
func NewVector() api.IVector {
o := new(vector)
return o
}
// NewVectorUsing constructs a new IVector using components
func NewVectorUsing(x, y float64) api.IVecto... | engine/maths/vector.go | 0.830663 | 0.516656 | vector.go | starcoder |
package billsutil
import (
"sort"
)
/* These are "mapping" functions common to collections classes in other languages
I need t think about how to make these more elegant in the absence of generics in Go
See: https://gobyexample.com/collection-functions for good examples
*/
// MapInt returns a new slice contai... | billsutil/sliceutil.go | 0.746046 | 0.497498 | sliceutil.go | starcoder |
package ast
import (
"github.com/magic003/liza/token"
)
// Type is the base type for all type tree node.
type Type interface {
Node
typeNode()
}
// BasicType node represents a basic type provided by the language.
type BasicType struct {
Ident *token.Token // identifier for a basic type
}
// Pos implementation f... | ast/type.go | 0.798305 | 0.514339 | type.go | starcoder |
package man
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderElementDnsPage() string {
return RenderHtml("Circuit DNS element", Render(dnsBody, nil))
}
const dnsBody = `
<h2>Example: Make a DNS server element</h2>
<p>Circuit allows you to create and dynamically configure one or more DN... | gocircuit.org/man/element-dns.go | 0.632049 | 0.47457 | element-dns.go | starcoder |
package histogram
import (
"image"
"math"
"runtime"
"github.com/AlessandroPomponio/hsv/conversion"
)
// With64Bins returns a color histogram with 64 bins for the input image.
// The values in the bins will represent the percentage of pixels mapped
// to a certain Hue, Saturation and Value level. The output can ... | histogram/64_bins.go | 0.857723 | 0.593639 | 64_bins.go | starcoder |
package day15
import (
"math"
"github.com/mjm/advent-of-code-2019/pkg/point"
)
// PathFinder finds paths between a start and goal point on a map.
type PathFinder struct {
canvas *Canvas
start point.Point2D
goal point.Point2D
fs map[point.Point2D]int
gs map[point.Point2D]int
}
// NewPathFinder crea... | day15/path_finder.go | 0.733261 | 0.5769 | path_finder.go | starcoder |
package day03
import (
"fmt"
"math"
"strconv"
"strings"
)
type direction rune
const (
up direction = 'U'
right direction = 'R'
down direction = 'D'
left direction = 'L'
)
type segment struct {
direction direction
length int
}
type wire []segment
type port struct {
x, y int
}
var centralPort = ... | day03/day03.go | 0.775009 | 0.410166 | day03.go | starcoder |
package Test
var clipPlanes = []clipPlane{
{VectorW{1, 0, 0, 1}, VectorW{-1, 0, 0, 1}},
{VectorW{-1, 0, 0, 1}, VectorW{1, 0, 0, 1}},
{VectorW{0, 1, 0, 1}, VectorW{0, -1, 0, 1}},
{VectorW{0, -1, 0, 1}, VectorW{0, 1, 0, 1}},
{VectorW{0, 0, 1, 1}, VectorW{0, 0, -1, 1}},
{VectorW{0, 0, -1, 1}, VectorW{0, 0, 1, 1}},
... | clipping.go | 0.503418 | 0.603581 | clipping.go | starcoder |
package gl
import (
"fyne.io/fyne"
"fyne.io/fyne/canvas"
"fyne.io/fyne/widget"
"github.com/go-gl/gl/v3.2-core/gl"
)
func walkObjects(obj fyne.CanvasObject, pos fyne.Position,
f func(object fyne.CanvasObject, pos fyne.Position)) {
switch co := obj.(type) {
case *fyne.Container:
offset := co.Position().Add(po... | driver/gl/draw.go | 0.68658 | 0.419826 | draw.go | starcoder |
package datadog
import (
"encoding/json"
)
// SLOResponse A service level objective response containing a single service level objective.
type SLOResponse struct {
Data *SLOResponseData `json:"data,omitempty"`
// An array of error messages. Each endpoint documents how/whether this field is used.
Errors *[]string... | api/v1/datadog/model_slo_response.go | 0.762689 | 0.410638 | model_slo_response.go | starcoder |
package board
import (
"math/rand"
"time"
"stabbey/interfaces"
)
/* How many rooms can spawn on a wall (will be 0 to max_wal_rooms-1) */
const max_wall_rooms int = 3
const max_rooms int = (max_wall_rooms - 1) * 4 + 1
type growingGen struct {
board *Board
}
/* Idea of this generator is to pick semi-... | src/stabbey/board/growing-generator.go | 0.57081 | 0.419588 | growing-generator.go | starcoder |
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
type space struct {
energy int
flashing bool
}
type World struct {
m [][]space
flashes int
}
type coordinate struct {
x int
y int
}
func (w *World) Push(arr []space) {
w.m = append(w.m, arr)
}
func (w *World) maxX() int {
return len(w.m[0]... | 11/main.go | 0.536799 | 0.412471 | main.go | starcoder |
package iso20022
// Specifies corporate action dates.
type CorporateActionDate27 struct {
// Date/time at which the issuer announced that a corporate action event will occur.
AnnouncementDate *DateFormat19Choice `xml:"AnncmntDt,omitempty"`
// Deadline by which the beneficial ownership of securities must be declar... | CorporateActionDate27.go | 0.786008 | 0.446072 | CorporateActionDate27.go | starcoder |
package ytypes
import (
"fmt"
"github.com/openconfig/goyang/pkg/yang"
)
// Refer to: https://tools.ietf.org/html/rfc6020#section-9.5.
// validateBool validates value, which must be a Go bool type, against the
// given schema.
func validateBool(schema *yang.Entry, value interface{}) error {
// Check that the sch... | ytypes/bool_type.go | 0.758242 | 0.417539 | bool_type.go | starcoder |
Small library on top of reflect for make lookups to Structs or Maps. Using a
very simple DSL you can access to any property, key or value of any value of Go.
*/
package lookup
import (
"errors"
"reflect"
"strconv"
"strings"
)
const (
SplitToken = "."
IndexCloseChar = "]"
IndexOpenChar = "["
)
var (
ErrM... | lookup/lookup.go | 0.786008 | 0.558568 | lookup.go | starcoder |
package draw
import (
"image"
)
// Op represents a Porter-Duff compositing operator.
type Op int
const (
/* Porter-Duff compositing operators */
Clear Op = 0
SinD Op = 8
DinS Op = 4
SoutD Op = 2
DoutS Op = 1
S = SinD | SoutD
SoverD = SinD | SoutD | DoutS
SatopD = SinD | DoutS
SxorD = SoutD | Dou... | _vendor/src/code.google.com/p/goplan9/draw/draw.go | 0.725649 | 0.505676 | draw.go | starcoder |
package hplot
import (
"image/color"
"math"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
// S2D plots a set of 2-dim points with error bars.
type S2D struct {
Data plotter.XYer
// GlyphStyle is the style of the glyphs drawn
// at each point.
draw.Gl... | hplot/s2d.go | 0.735926 | 0.501099 | s2d.go | starcoder |
package main
import (
"math/rand"
)
func Smoke(x, y, power float64) {
for i := 0; i < 50; i++ {
// smoke
color := rand.Float32() * 0xFFFF
particles.NewParticle(particle{
r: color,
g: color,
b: color,
a: color,
size: float64(1 + rand.Intn(2)),
Phys: Phys{
x: x,
y... | effects.go | 0.505371 | 0.411584 | effects.go | starcoder |
package day08
import (
"fmt"
"math"
mapset "github.com/deckarep/golang-set"
)
type Entry struct {
Patterns []string
OutputDigits []string
}
func (e *Entry) Solve() (int, error) {
var digits [10]mapset.Set
fiveDigitPatterns, sixDigitPatterns := make([]string, 0, 3), make([]string, 0, 3)
for _, p := rang... | day08/entry.go | 0.582966 | 0.549822 | entry.go | starcoder |
package arbor
import (
"encoding/json"
"fmt"
)
const (
// WelcomeType should be used as the `Type` field of a WELCOME ProtocolMessage
WelcomeType = 0
// QueryType should be used as the `Type` field of a QUERY ProtocolMessage
QueryType = 1
// NewMessageType should be used as the `Type` field of a NEW_MESSAGE Pr... | protocol_message.go | 0.567218 | 0.428174 | protocol_message.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
)
// TSVectorArrayFromStringSliceSlice returns a driver.Valuer that produces a PostgreSQL tsvector[] from the given Go [][]string.
func TSVectorArrayFromStringSliceSlice(val [][]string) driver.Valuer {
return tsVectorArrayFromStringSliceSlice{val: val}
}
... | pgsql/tsvectorarr.go | 0.596081 | 0.643238 | tsvectorarr.go | starcoder |
package block
import (
"github.com/df-mc/dragonfly/dragonfly/world"
)
// Crop is an interface for all crops that are grown on farmland. A crop has a random chance to grow during random ticks.
type Crop interface {
// GrowthStage returns the crop's current stage of growth. The max value is 7.
GrowthStage() int
// ... | dragonfly/block/crop.go | 0.786131 | 0.504944 | crop.go | starcoder |
package main
import (
"math"
)
type SunEventInfo struct {
Hour, Minute int
TimeZone string
}
func calculateDayOfYear(month int, day int, year int) int {
var one = math.Floor((float64(275) * float64(month) / float64(9.0)))
var two = math.Floor((float64(month) + float64(9)) / float64(12.0))
var three = (1 + ... | suncalculator.go | 0.720368 | 0.460592 | suncalculator.go | starcoder |
package service
import "github.com/GoogleCloudPlatform/compute-image-tools/proto/go/pb"
type literalLoggable struct {
strings map[string]string
int64s map[string][]int64
bools map[string]bool
traceLogs []string
inspectionResults *pb.InspectionResults
}
func (w literalLo... | cli_tools/common/utils/logging/service/literal_loggable.go | 0.658857 | 0.440108 | literal_loggable.go | starcoder |
package internal
import (
"fmt"
)
var (
squareDigitToLetterLat map[int]string
squareLetterToDigitLat map[string]float64
squareDigitToLetterLon map[int]string
squareLetterToDigitLon map[string]float64
squareDegLatitudes = [...]float64{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
}
squareDegLongitudes ... | geo/internal/square.go | 0.568176 | 0.487368 | square.go | starcoder |
package infobip
import (
"encoding/json"
)
// TfaApplicationConfiguration struct for TfaApplicationConfiguration
type TfaApplicationConfiguration struct {
// Tells if multiple PIN verifications are allowed.
AllowMultiplePinVerifications *bool `json:"allowMultiplePinVerifications,omitempty"`
// Number of possible... | v2/model_tfa_application_configuration.go | 0.841207 | 0.470858 | model_tfa_application_configuration.go | starcoder |
package steps
import (
"bufio"
"bytes"
"math"
"github.com/antongulenko/go-onlinestats"
"github.com/bitflow-stream/go-bitflow/bitflow"
"gonum.org/v1/gonum/mat"
)
func ValuesToVector(input []bitflow.Value) []float64 {
values := make([]float64, len(input))
for i, val := range input {
values[i] = float64(val)
... | steps/helpers.go | 0.606498 | 0.50769 | helpers.go | starcoder |
package compare
import "github.com/benpate/derp"
// Interface tries its best to muscle value2 and value2 into compatable types so that they can be compared.
// If value1 is LESS THAN value2, it returns -1, nil
// If value1 is EQUAL TO value2, it returns 0, nil
// If value1 is GREATER THAN value2, it returns 1, nil
//... | interface.go | 0.593609 | 0.499817 | interface.go | starcoder |
package chart
import (
"fmt"
"github.com/wcharczuk/go-chart/seq"
)
// BollingerBandsSeries draws bollinger bands for an inner series.
// Bollinger bands are defined by two lines, one at SMA+k*stddev, one at SMA-k*stdev.
type BollingerBandsSeries struct {
Name string
Style Style
YAxis YAxisType
Period in... | vendor/github.com/wcharczuk/go-chart/bollinger_band_series.go | 0.847242 | 0.574454 | bollinger_band_series.go | starcoder |
package dbf
import (
"math"
"github.com/cpmech/gosl/chk"
)
// CutSin implements a sine function such as:
// if find["cps"]: # means cut_positive is True
// if y < 0: y(t) = a * sin(b*t) + c
// else: y(t) = 0
// else: # means cut_positive is False so cut negative values
// if y > 0: y(t) = a * sin(b*t) + c
... | fun/dbf/f_cutsin.go | 0.52975 | 0.400603 | f_cutsin.go | starcoder |
package goment
// StartOf mutates the original Goment by setting it to the start of a unit of time.
func (g *Goment) StartOf(units string) *Goment {
switch units {
case "y", "year", "years":
g.startOfYear()
case "Q", "quarter", "quarters":
g.startOfQuarter()
case "M", "month", "months":
g.startOfMonth()
cas... | start_end_of.go | 0.70619 | 0.663683 | start_end_of.go | starcoder |
package optimize
import (
"math"
"github.com/gonum/floats"
)
// LinesearchMethod represents an abstract optimization method in which a
// function is optimized through successive line search optimizations.
type LinesearchMethod struct {
// NextDirectioner specifies the search direction of each linesearch.
NextD... | vendor/github.com/gonum/optimize/linesearch.go | 0.688678 | 0.40645 | linesearch.go | starcoder |
package dsp
// region Complex Fir Filter
type FirFilter struct {
taps []float32
sampleHistory []complex64
tapsLen int
decimation int
}
func MakeFirFilter(taps []float32) *FirFilter {
return &FirFilter{
taps: taps,
sampleHistory: make([]complex64, len(taps)),
tapsLen: len(t... | dsp/fir.go | 0.557123 | 0.4206 | fir.go | starcoder |
package schema
// SiteSchemaJSON is the content of the file "site.schema.json".
const SiteSchemaJSON = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "site.schema.json#",
"title": "Site configuration",
"description": "Configuration for a Sourcegraph site.",
"allowComments": true,
"type": ... | schema/site_stringdata.go | 0.843122 | 0.463687 | site_stringdata.go | starcoder |
package core
type Distance struct {
root *Cell
cellDists map[*Cell]int
maximum int // cache
farthest *Cell // cache
}
func NewDistance(root *Cell) Distance {
return Distance{root: root,
cellDists: map[*Cell]int{
root: 0,
}}
}
func (d Distance) distanceTo(cell *Cell) (int, bool) {
v, ok := d.ce... | core/distance.go | 0.78968 | 0.516474 | distance.go | starcoder |
package container
import (
"fmt"
"reflect"
"strings"
)
// LabelledTuple is a labelled tuple containing a list of fields and a label set.
// Fields can be any data type and is used to store data.
// TupleLabels is a label set that is associated to the tuple itself.
type LabelledTuple Tuple
// NewLabelledTuple crea... | container/labelled_tuple.go | 0.688154 | 0.507629 | labelled_tuple.go | starcoder |
package dmc
import (
"strconv"
"github.com/lucasb-eyer/go-colorful"
)
func (d *DmcColors) LabToDmc(l float64, a float64, b float64) (string, string) {
var previousDistance float64
var dmc string
var floss string
// ic is Color struct holding the Lab values passed in to LabToDmc
ic := colorful.Lab(l, a, b)
... | lab.go | 0.735926 | 0.538134 | lab.go | starcoder |
package complex
import "math"
type Complex struct {
Re float64 `json:"re"`
Im float64 `json:"im"`
}
func (a Complex) Add(b Complex) (c Complex) {
c.Re = a.Re + b.Re
c.Im = a.Im + b.Im
return
}
func (a Complex) Sub(b Complex) (c Complex) {
c.Re = a.Re - b.Re
c.Im = a.Im - b.Im
return
}
func (a Complex) Mul(... | complex/complex.go | 0.932661 | 0.489931 | complex.go | starcoder |
package ciede2000
import (
"math"
"github.com/zarken-go/colorspace"
)
const (
pow25To7 = 6103515625.0 // math.Pow(25, 7)
)
func deg2Rad(deg float64) float64 {
return deg * (math.Pi / 180.0)
}
func DeltaE(Lab1, Lab2 colorspace.Lab) float64 {
c1 := math.Sqrt(math.Pow(Lab1.A, 2) + math.Pow(Lab1.B, 2))
c2 := mat... | ciede2000/delta.go | 0.616128 | 0.538316 | delta.go | starcoder |
package paralleltest
import (
"go/ast"
"strings"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
)
const Doc = `check that tests use t.Parallel() method
It also checks that the t.Parallel is used if multiple tests cases are run as part of si... | vendor/github.com/kunwardeep/paralleltest/pkg/paralleltest/paralleltest.go | 0.622115 | 0.494019 | paralleltest.go | starcoder |
package multipivotquicksort
import (
"fmt"
"sort"
"sync"
)
/*MultiPivot uses a variant of the QuickSort with multiple pivots, splitting the arrays in multiple segments (pivots+1).
It consumes more space (memory), is not yet optimized to work with only 1 slice, it copies the data in each step.
singleThread should b... | sort/multipivotquicksort/sort.go | 0.558809 | 0.427695 | sort.go | starcoder |
package entity
import (
"fmt"
)
// JourneyPlace represents one URL in visitor history
// Some nodes are not directly logged to the access logs due to caching layers.
// In that case, we will replicate missing information based on referer URL and access log records
type JourneyPlace struct {
ID string
WasLog... | internal/domain/entity/journey.go | 0.671471 | 0.462048 | journey.go | starcoder |
package tfengine
// Schema is the Terraform engine input schema.
// TODO(https://github.com/golang/go/issues/35950): Move this to its own file.
const Schema = `
title = "Terraform Engine Config Schema"
additionalProperties = false
properties = {
version = {
description = <<EOF
Optional constraint on the... | internal/tfengine/schema.go | 0.558327 | 0.456228 | schema.go | starcoder |
package behaviours
import (
"fmt"
"github.com/MaximeWeyl/goTestifyRecursive/formatting"
"github.com/stretchr/testify/assert"
"reflect"
)
//ExpectedStruct Assert/Require a struct. The values are the behaviours we expect for each element
type ExpectedStruct map[string]interface{}
//CheckField Assert that a value s... | behaviours/expectedStruct.go | 0.650689 | 0.459319 | expectedStruct.go | starcoder |
package nmea
/**
$WIMWV
NMEA 0183 standard Wind Speed and Angle, in relation to the vessel’s bow/centerline.
Syntax
$WIMWV,<1>,<2>,<3>,<4>,<5>*hh<CR><LF>
Fields
<1> Wind angle, 0.0 to 359.9 degrees, in relation to the vessel’s bow/centerline, to the nearest 0.1
degree. If the data for this field is no... | mwv.go | 0.649579 | 0.55923 | mwv.go | starcoder |
package model
/*
ModelType defines a type for use by models.
*/
type ModelType int
const (
// ModelTypeList causes the model to behave as a list (keys are unsigned,
// contiguous integers beginning at 0).
ModelTypeList ModelType = iota
// ModelTypeHash causes the model to behave as a hash (keys are strings,
// o... | model/model.go | 0.606032 | 0.470676 | model.go | starcoder |
// Package advsearch searches elements in sorted slices or user defined collections of any kind
// Because of the generic interfaces, advsearch can also be used to define possible insertion
// positions in a data structure or a position in a data structure based on other criteria
// based on the user's implementation ... | advsearch.go | 0.83104 | 0.633779 | advsearch.go | starcoder |
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
const usage = `The following instructions are supported:
Directives:
".begin"
".end"
".org"
Memory:
"ld"
"st"
Arithmetic:
"add", "addcc"
"sub", "subcc"
Logic:
"and", "andcc"
"or", "orcc"
"orn", "orncc"
"xor", "xorcc"
"sll", "sra"
Control:
"be"
"bne"
"bneg"... | cmd/arc/cmd/usage.go | 0.745861 | 0.563498 | usage.go | starcoder |
package feature
import (
"github.com/shuLhan/numerus"
"github.com/shuLhan/tekstus"
"github.com/shuLhan/wvcgen/revision"
"math"
)
/*
KullbackLeiblerDivergence comput and return the divergence of two string based
on their character probabability.
*/
func KullbackLeiblerDivergence(a, b string) (divergence float64) ... | feature/algorithm.go | 0.655887 | 0.412826 | algorithm.go | starcoder |
package query
import (
"fmt"
"strconv"
"strings"
)
// Querier provides the interface to query using a given command and provide
// the resultant string. The command string should include the appropriate
// terminator for the instrument.
type Querier interface {
Query(cmd string) (value string, err error)
}
// B... | query.go | 0.744471 | 0.411643 | query.go | starcoder |
package ansi8
import (
"fmt"
"github.com/shyang107/pencil"
)
// Print formats using the default formats for its operands and writes to
// standard output. Spaces are added between operands when neither is a
// string. It returns the number of bytes written and any write error
// encountered. This is the standard f... | ansi8/print.go | 0.763748 | 0.405478 | print.go | starcoder |
package tournify
import (
"errors"
"fmt"
"sort"
)
// TeamStatsInterface is used to show team statistics. Currently this is specifically made for
// group tournaments where there is a need to rank teams.
type TeamStatsInterface interface {
GetGroup() GroupInterface
GetTeam() TeamInterface
GetPlayed() int
GetWin... | teamstats.go | 0.616012 | 0.451508 | teamstats.go | starcoder |
package tree
/*
This package support the generation of an "at glance" view of a Cluster API cluster designed to help the user in quickly
understanding if there are problems and where.
The "at glance" view is based on the idea that we should avoid to overload the user with information, but instead
surface problems, if... | cmd/clusterctl/client/tree/doc.go | 0.857589 | 0.774413 | doc.go | starcoder |
package transform
type WHT16 struct {
fScale uint
iScale uint
data []int
}
// For perfect reconstruction, forward results are scaled by 8 unless the
// parameter is set to false (in which case rounding may roduce errors)
func NewWHT16(scale bool) (*WHT16, error) {
this := new(WHT16)
this.data = make([]int, 256... | go/src/kanzi/transform/WHT16.go | 0.552781 | 0.42483 | WHT16.go | starcoder |
package tracker
import "github.com/vsariola/sointu"
type SongRow struct {
Pattern int
Row int
}
type SongPoint struct {
Track int
SongRow
}
type SongRect struct {
Corner1 SongPoint
Corner2 SongPoint
}
func (r SongRow) AddRows(rows int) SongRow {
return SongRow{Row: r.Row + rows, Pattern: r.Pattern}
}
f... | tracker/songpoint.go | 0.698638 | 0.472136 | songpoint.go | starcoder |
// Package pipeline provides the ability to construct and run a pipeline.
package pipeline
import (
"container/list"
"fmt"
"github.com/abitofhelp/minipipeline/stage"
)
// The type Pipeline implements the IPipeline interface and to make it possible
// to easily construct and rearrange a pipeline using a fluent int... | pipeline/pipeline.go | 0.832781 | 0.434101 | pipeline.go | starcoder |
package algorithms
import (
"github.com/dploop/golib/stl/iterators"
"github.com/dploop/golib/stl/types"
)
func AllOf(first, last iterators.InputIterator, pred types.UnaryPredicate) bool {
for !first.Equal(last) {
if !pred(first.Read()) {
return false
}
first = first.Next().(iterators.InputIterator)
}
... | stl/algorithms/non_modifying_sequence.go | 0.721056 | 0.543833 | non_modifying_sequence.go | starcoder |
package platformsnotificationevents
import (
"encoding/json"
)
// Amount struct for Amount
type Amount struct {
// The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes).
Currency string `json:"currency"`
// The amount of the transaction, in [minor units](https://doc... | src/platformsnotificationevents/model_amount.go | 0.808974 | 0.450359 | model_amount.go | starcoder |
package protobufquery
import (
"bytes"
"google.golang.org/protobuf/reflect/protoreflect"
)
// A NodeType is the type of a Node.
type NodeType uint
const (
// DocumentNode is a document object that, as the root of the document tree,
// provides access to the entire XML document.
DocumentNode NodeType = iota
//... | node.go | 0.666931 | 0.411406 | node.go | starcoder |
package godash
import (
"errors"
"reflect"
)
// Without removes values from a slice and returns the new slice.
// It accepts a slice of any type as the first parameter, followed by a list of parameter values to remove from the slice.
// The additional values must be of the same type as the provided slice.
// If usi... | without.go | 0.824002 | 0.528777 | without.go | starcoder |
package leetcode
/**
* @title 设计链表
*
* 设计链表的实现。您可以选择使用单链表或双链表。
* 单链表中的节点应该具有两个属性:val 和 next。val 是当前节点的值,next 是指向下一个节点的指针/引用。
* 如果要使用双向链表,则还需要一个属性 prev 以指示链表中的上一个节点。假设链表中的所有节点都是 0-index 的。
*
* 在链表类中实现这些功能:
* get(index):获取链表中第 index 个节点的值。如果索引无效,则返回-1。
* addAtHead(val):在链表的第一个元素之前添加一个值为 val 的节点。插入后,新节点将成为链表的第一个... | src/0707.design-linked-list.go | 0.580709 | 0.442817 | 0707.design-linked-list.go | starcoder |
package evaluate
import (
"fmt"
"github.com/haunt98/evaluator/expression"
"github.com/haunt98/evaluator/token"
)
func (v *visitor) visitOr(expr *expression.BinaryExpression) (expression.Expression, error) {
left, err := v.Visit(expr.Left)
if err != nil {
return nil, err
}
leftLit, ok := left.(*expression.B... | evaluate/binary.go | 0.622689 | 0.47025 | binary.go | starcoder |
package hilbert
import (
"sort"
"github.com/Workiva/go-datastructures/rtree"
)
type hilbert int64
type hilberts []hilbert
func getParent(parent *node, key hilbert, r1 rtree.Rectangle) *node {
var n *node
for parent != nil && !parent.isLeaf {
n = parent.searchNode(key)
parent = n
}
if parent != nil && r1... | vendor/src/github.com/Workiva/go-datastructures/rtree/hilbert/node.go | 0.550849 | 0.420302 | node.go | starcoder |
package binp
import "errors"
// Parser type. Don't touch the internals.
type Parser struct {
r []byte
off int
}
// Create a new parser with the given buffer. Panics on error.
func NewParser(b []byte) *Parser {
return &Parser{b, 0}
}
// Parse a byte from the buffer.
func (p *Parser) Byte(d *byte) *Parser {
if ... | binparser_common.go | 0.68679 | 0.520009 | binparser_common.go | starcoder |
package integration
import (
"image/color"
)
// ColourFromARGB creates a colour from the separate A/R/G/B quantities.
func ColourFromARGB(a uint8, r uint8, g uint8, b uint8) uint32 {
return (uint32(a) << 24) | (uint32(r) << 16) | (uint32(g) << 8) | (uint32(b) << 0)
}
// ColourToARGB splits a colour apart.
func Col... | frenyard/integration/imagingColours.go | 0.830078 | 0.531209 | imagingColours.go | starcoder |
package infoblox
import (
"github.com/CARFAX/skyinfoblox/api/common/v261/model"
"github.com/carfax/terraform-provider-infoblox/infoblox/util"
"github.com/hashicorp/terraform/helper/schema"
)
func resourceNetwork() *schema.Resource {
return &schema.Resource{
Create: resourceNetworkCreate,
Read: resourceNetwo... | infoblox/resource_network.go | 0.5 | 0.463019 | resource_network.go | starcoder |
package kata
import "strings"
// All commands are implemented as functions on the machine structure
type command = func(work *machine)
// Dataset of the running Custom Paintfuck machine
// The code string is stored as array of command functions
type machine struct {
grid [][]bool
gridXN int ... | 4_kyu/Esolang_Interpreters_3_Custom_Paintfk_Interpreter.go | 0.593374 | 0.415847 | Esolang_Interpreters_3_Custom_Paintfk_Interpreter.go | starcoder |
package astcopy
import (
"go/ast"
)
// CopyNodeMap hold mapping copied node to original node.
type CopyNodeMap map[ast.Node]ast.Node
// Node returns x node deep copy.
// Copy of nil argument is nil.
func Node(x ast.Node, nMap CopyNodeMap) ast.Node {
return copyNode(x, nMap)
}
// NodeList returns xs node slice dee... | astcopy.go | 0.694613 | 0.477676 | astcopy.go | starcoder |
package yangtree
// yangtree consists of the data node.
type DataNode interface {
IsDataNode()
IsNil() bool // IsNil() is used to check the data node is null.
IsBranchNode() bool // IsBranchNode() returns true if the data node is a DataBranch (a container or a list node).
IsLeafNode() bool ... | interface.go | 0.608594 | 0.677654 | interface.go | starcoder |
// Package image provides functions to operate on container images efficiently.
package image
import (
"fmt"
"log"
"sort"
"github.com/google/go-containerregistry/pkg/v1/google"
)
// List represents the container images of the application we check.
// It provides conveniences to access/operate images by the imag... | go/src/infra/cros/cmd/k8s-management/tag-manager/internal/image/list.go | 0.737914 | 0.426083 | list.go | starcoder |
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
fmt.Println("Let's simulate an election!")
// Seed the PRNG
rand.Seed(time.Now().UnixNano())
numTrials := 10000
marginOfError := 0.10
fileName := "debates.txt"
// Read in the 2 files we are interested in
electoralVotes := ReadElectoralVotes("e... | election/main.go | 0.683102 | 0.457561 | main.go | starcoder |
package gl
import (
"unsafe"
"github.com/go-gl/gl/v3.2-core/gl"
)
func Init() error {
return gl.Init()
}
func NeedVao() bool {
return true
}
func GetError() uint32 {
return gl.GetError()
}
func Viewport(x, y, width, height int32) {
gl.Viewport(x, y, width, height)
}
func ClearColor(r, g, b, a float32) {
... | hid/gl/gl_gl3.go | 0.625667 | 0.430447 | gl_gl3.go | starcoder |
package mod256
import (
. "math/bits"
)
// z = 1/x mod m if it exists, otherwise 0
// Returns true if the inverse exists
// Inv computes the (multiplicative) inverse of a residue, if it exists.
func (z *Residue) Inv() bool {
var (
b, c, // Borrow & carry
a4, a3, a2, a1, a0,
b4, b3, b2, b1, b0,
c4, c3, c2... | inv.go | 0.536313 | 0.518059 | inv.go | starcoder |
package render
import (
"errors"
"fmt"
"strange-secrets.com/mantra/algebra"
"strange-secrets.com/mantra/render/sampling"
"strange-secrets.com/mantra/scene"
"strange-secrets.com/mantra/scene/shading"
"time"
)
const (
TestImageWidth = 1024 * 2 // 640
TestImageHeight = 1024 // 480
)
type Renderer struct {
... | render/renderer.go | 0.724578 | 0.402803 | renderer.go | starcoder |
package dh
import (
crand "crypto/rand"
"crypto/sha1"
"math/big"
mrand "math/rand"
"time"
)
// cryptoRandomBigInt returns a random big int.
// It returns nil if failed to get random bytes from crypto/rand.
func cryptoRandomBigInt(nb int) *big.Int {
b := make([]byte, nb)
_, err := crand.Read(b)
if err != nil {... | dh.go | 0.512205 | 0.406037 | dh.go | starcoder |
package funl
// OperatorInfo contains information about one operator
type OperatorInfo struct{}
// NewOperatorDocs returns documentation for operators
func NewOperatorDocs() map[string]string {
return map[string]string{
"and": `
Operator: and
Performs logical and -operation for arguments.
All arguments are ass... | funl/operators.go | 0.863823 | 0.587056 | operators.go | starcoder |
package problem0641
// MyCircularDeque 结构体
type MyCircularDeque struct {
f, r *node
len, cap int
}
type node struct {
value int
pre, next *node
}
// Constructor initialize your data structure here. Set the size of the deque to be k.
func Constructor(k int) MyCircularDeque {
return MyCircularDeque{
cap:... | Algorithms/0641.design-circular-deque/design-circular-deque.go | 0.556641 | 0.537527 | design-circular-deque.go | starcoder |
package naro
import (
"context"
"sync"
"time"
"github.com/jonboulle/clockwork"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// AnomalyDetector is a type that can be trained to detect issues
// within new NodeTimePeriodSummaries.
type AnomalyDetector interface {
String() string
Train(summaries []*No... | pkg/naro/anomaly_detection.go | 0.662251 | 0.407274 | anomaly_detection.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.