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 myers
// Myer's diff algorithm in golang
// Ported from https://blog.robertelder.org/diff-algorithm/
type OpType int
const (
OpDelete OpType = iota
OpInsert
)
type Op struct {
OpType OpType // Insert or delete, as above
OldPos int // Position in the old list of item to be inserted or delete... | myers.go | 0.517083 | 0.409575 | myers.go | starcoder |
package transform
import (
"encoding/base64"
"fmt"
"github.com/francescomari/nu/parser"
)
const (
// StatsNodeDepthBucketSize is the size of a bucket for the NodesPerDepth
// field in Stats.
StatsNodeDepthBucketSize = 10
// StatsPropertyDepthBucketSize is the size of a bucket for the
// PropertiesPerDepth fi... | transform/stats.go | 0.656108 | 0.452113 | stats.go | starcoder |
package txsort
import (
"bytes"
"github.com/parallelcointeam/pod/chaincfg/chainhash"
"github.com/parallelcointeam/pod/wire"
"sort"
)
// InPlaceSort modifies the passed transaction inputs and outputs to be sorted based on BIP 69.
// WARNING: This function must NOT be called with published transactions since it wil... | btcutil/txsort/txsort.go | 0.722918 | 0.420421 | txsort.go | starcoder |
package accounting
import (
"encoding/json"
)
// UnitPrice Represents a unit price
type UnitPrice struct {
// The actual unit price amount.
Amount *float32 `json:"amount,omitempty"`
// Indicates if the unit price amount already includes taxes.
TaxIncluded bool `json:"taxIncluded"`
}
// NewUnitPrice instantiate... | generated/accounting/model_unit_price.go | 0.848219 | 0.472683 | model_unit_price.go | starcoder |
package eaopt
import (
"math"
)
func copyFloat64s(fs []float64) []float64 {
var fsc = make([]float64, len(fs))
copy(fsc, fs)
return fsc
}
func newInts(n uint) []int {
var ints = make([]int, n)
for i := range ints {
ints[i] = i
}
return ints
}
// Divide each element in a float64 slice by a given value.
fun... | util.go | 0.745213 | 0.416619 | util.go | starcoder |
package toms
import (
"github.com/dreading/gospecfunc/machine"
"github.com/dreading/gospecfunc/utils"
"math"
)
// STROM calculates Stromgren's integral
// ∫ 0 to x { t^7 exp(2t)/[exp(t)-1]^3 } dt
// The code uses Chebyshev expansions with the coefficients
// given to 20 decimal places
func STROM(XVALUE float64)... | integrals/internal/toms/stromgren.go | 0.505371 | 0.425009 | stromgren.go | starcoder |
package rings
import (
"image/color"
"gonum.org/v1/plot"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
// Highlight implements rendering a colored arc.
type Highlight struct {
// Base describes the arc through which the highlight should be drawn.
Base Arc
// Color determines the fill color of the hig... | plotter/rings/highlight.go | 0.854415 | 0.496399 | highlight.go | starcoder |
package layout
import (
"github.com/negrel/paon/geometry"
"github.com/negrel/paon/styles"
)
// BoxedObject define an object with a BoxModel.
type BoxedObject interface {
BoxModel() BoxModel
}
// BoxModel define a box with margin, border and padding in a 2D geometric plane.
type BoxModel interface {
MarginBox() g... | pdk/layout/box.go | 0.904481 | 0.449151 | box.go | starcoder |
package gozxing
const (
LUMINANCE_BITS = 5
LUMINANCE_SHIFT = 8 - LUMINANCE_BITS
LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS
)
type GlobalHistogramBinarizer struct {
source LuminanceSource
luminances []byte
buckets []int
}
func NewGlobalHistgramBinarizer(source LuminanceSource) Binarizer {
return &Glob... | global_histogram_binarizer.go | 0.693784 | 0.400779 | global_histogram_binarizer.go | starcoder |
package options
// InsertOneOptions represents all possible options to the insertOne()
type InsertOneOptions struct {
BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation
}
// InsertOne returns a pointer to a new InsertOneOptions
func InsertOne() *InsertOneOptions {
r... | vendor/github.com/mongodb/mongo-go-driver/mongo/options/insertoptions.go | 0.830663 | 0.44348 | insertoptions.go | starcoder |
Package dsp has a set of digital signal processing functions that are primarily
designed to support the discrete wavelet transform
("https://github.com/goccmack/dsp/dwt")
*/
package godsp
import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"math"
"strconv"
"strings"
myioutil "github.com/goccmack/goutil/ioutil"
)
// A... | dsp.go | 0.802981 | 0.611469 | dsp.go | starcoder |
package leetcode
import "math"
/*
* @lc app=leetcode id=8 lang=golang
*
* [8] String to Integer (atoi)
*
* https://leetcode.com/problems/string-to-integer-atoi/description/
*
* algorithms
* Medium (15.59%)
* Likes: 2085
* Dislikes: 11270
* Total Accepted: 679.4K
* Total Submissions: 4.4M
* Testcase... | leetcode/8/8.string-to-integer-atoi.go | 0.890975 | 0.432063 | 8.string-to-integer-atoi.go | starcoder |
package agent
import (
"fmt"
"strconv"
"github.com/pkg/errors"
"github.com/determined-ai/determined/master/internal/sproto"
"github.com/determined-ai/determined/master/internal/task"
"github.com/determined-ai/determined/master/pkg/actor"
"github.com/determined-ai/determined/master/pkg/aproto"
"github.com/det... | master/internal/resourcemanagers/agent/agent_state.go | 0.709925 | 0.420243 | agent_state.go | starcoder |
package daemon
// Gauge is a Metric that represents a single numerical value that can
// arbitrarily go up and down.
type Gauge interface {
// Inc increments the Gauge by 1. Use Add to increment it by arbitrary
// values.
Inc()
}
// GaugeVec is a Collector that bundles a set of Gauges that all share the same
// De... | pkg/daemon/metrics.go | 0.786541 | 0.52074 | metrics.go | starcoder |
package rgass
import (
"errors"
)
// Node represents a node of text inside an RGASS
type Node struct {
ID ID // The identifier of this node
List []*Node // A list of nodes this node has been split into
Str string // The string contents of this node
Split bool //... | rgass/node.go | 0.667364 | 0.499817 | node.go | starcoder |
<tutorial>
Getting started example of using 51Degrees device detection. The example
shows how to:
<ol>
<li>Instantiate the 51Degrees device detection provider.
<p><pre class="prettyprint lang-go">
provider := FiftyOneDegreesPatternV3.NewProvider(dataFile)
</pre></p>
<li>Produce a match for a single HTTP User-Agent head... | GettingStarted.go | 0.667581 | 0.593668 | GettingStarted.go | starcoder |
package axis
import (
"context"
"image"
"github.com/zeebo/rothko/draw"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
const (
tickSize = 10 // px
axisWidth = 1 // px
tickPadding = 2 // px
horizLabelSpacing = 10 // px
vertLabelSpacing = 2 // px
textOffset = axisWid... | draw/axis/axis.go | 0.658966 | 0.438725 | axis.go | starcoder |
package main
import (
"fmt"
"container/list"
)
// Matrix represents the matrix graph
type Matrix [][]int
// Position defines the current position in the graph (matrix)
type Position struct {
row, col int
}
// Direction indicates the movement (delta between positions)
type Direction struct {
// We can move +/- 1... | struct/graph/matrix/traversal/traversal.go | 0.672332 | 0.522568 | traversal.go | starcoder |
package operator
import (
"errors"
"fmt"
"github.com/weworksandbox/lingo"
"github.com/weworksandbox/lingo/check"
"github.com/weworksandbox/lingo/sql"
)
func NewBinary(left lingo.Expression, op Operator, right lingo.Expression) Binary {
return Binary{
left: left,
op: op,
right: right,
}
}
type Binar... | expr/operator/binary.go | 0.840979 | 0.547585 | binary.go | starcoder |
// Package exe defines QoL functions to simplify and unify creating executables
package exe
import (
"fmt"
"strings"
"gopkg.in/alecthomas/kingpin.v2"
"microsoft.com/pkggen/internal/logger"
)
// ToolkitVersion specifies the version of the toolkit and the reported version of all tools in it.
const ToolkitVersion ... | toolkit/tools/internal/exe/exe.go | 0.716615 | 0.453564 | exe.go | starcoder |
package ann
import (
"errors"
"math/rand"
"github.com/azuwey/gonetwork/activationfn"
"github.com/azuwey/gonetwork/matrix"
)
// LayerDescriptor used to generate the layers in the artificial neural network.
type LayerDescriptor struct {
Nodes int `json:"nodes"`
ActivationFunction string `js... | ann/ann.go | 0.737158 | 0.565719 | ann.go | starcoder |
package linear
import (
"math"
)
/**
* Class defining a real-valued vector with basic algebraic operations.
*
* vector element indexing is 0-based -- e.g., At(0) returns the first element of the vector.
*
* The map method operate on vectors element-wise, i.e. they perform the same operation (adding a scalar,
*... | real_vector.go | 0.942115 | 0.715325 | real_vector.go | starcoder |
package stdlib
import "github.com/asukakenji/go-benchmarks"
// --- LeadingZeros ---
// LeadingZeros returns the number of leading zero bits in x; the result is the size of uint in bits for x == 0.
func LeadingZeros(x uint) int { return int(benchmarks.SizeOfUintInBits) - Len(x) }
// LeadingZeros8 returns the number ... | math/bits/impl/leadingzeros/stdlib/bits.go | 0.687735 | 0.665105 | bits.go | starcoder |
package vector2
import (
"fmt"
"math"
)
const Epsilon = 0.00001
type Vector2 struct {
X, Y float64
}
func Dot(ihs *Vector2, rhs *Vector2) float64 {
return ihs.X*rhs.X + ihs.Y*rhs.Y
}
func Lerp(a *Vector2, b *Vector2, t float64) *Vector2 {
return New(
a.X+(b.X-a.X)*t,
a.Y+(b.Y-a.Y)*t,
)
}
func Distance(a... | vector2/vector2.go | 0.858274 | 0.77437 | vector2.go | starcoder |
package bitarray
// Join concatenates the elements of its first parameter to create a single
// bit array. The separator sep is placed between elements in the result.
func Join(elems []*BitArray, sep BitArrayer) *BitArray {
var basep *BitArray
if sep != nil {
basep = sep.BitArray()
}
switch len(elems) {
case 0... | bitarray_concat.go | 0.737442 | 0.54958 | bitarray_concat.go | starcoder |
package common
// The size of a SHABAL256 checksum in bytes.
const Size = 32
// The blocksize of SHABAL256 in bytes.
const BlockSize = 64
const ivSize = 44
var iv []uint32
// digest represents the partial evaluation of a checksum.
type Digest struct {
buf [64]byte
state [44]uint32
ptr uint32
w int64
}
... | shabal256.go | 0.66356 | 0.470676 | shabal256.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_random_forest
#include <capi/random_forest.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type RandomForestOptionalParam struct {
InputModel *randomForestModel
Labels *mat.Dense
MaximumDepth int
Minimu... | random_forest.go | 0.733452 | 0.474814 | random_forest.go | starcoder |
package expr
import (
"bytes"
"fmt"
"io"
)
// Program represents a parsed expression.
type Program struct {
root node
}
// Parse parses an expression into a program.
func Parse(r io.RuneScanner) *Program {
return &Program{newparser(newscanner(r)).parse()}
}
// ParseString parses an expression from a string.
fu... | sgx-tools/vendor/github.com/go-restruct/restruct/expr/parse.go | 0.628863 | 0.434761 | parse.go | starcoder |
package evaluator
import (
"fmt"
"github.com/bradford-hamilton/monkey-lang/ast"
"github.com/bradford-hamilton/monkey-lang/object"
)
// No need to create new true/false or null objects every time we encounter one, they will
// be the same. Let's reference them instead
var (
True = &object.Boolean{Value: true}
F... | evaluator/evaluator.go | 0.702734 | 0.439928 | evaluator.go | starcoder |
package blockchain
import (
"encoding/hex"
"fmt"
"github.com/parallelcointeam/pod/chaincfg/chainhash"
"github.com/parallelcointeam/pod/fork"
"math"
"math/big"
"math/rand"
"time"
)
var (
scryptPowLimit = func() big.Int {
mplb, _ := hex.DecodeString("000000039fcaa04ac30b6384471f337748ef5c87c7aeffce5e51770ce6... | blockchain/difficulty.go | 0.708112 | 0.486575 | difficulty.go | starcoder |
package tuile
import (
"image/color"
"math"
)
type HBlank func(line int)
type Plot func(x, y int, r, g, b, a byte)
// Engine structure
type Engine struct {
hBlank HBlank
backgroundColor color.Color
width int
height int
plot Plot
layers []*Layer
}
func abs(a in... | tuile.go | 0.70069 | 0.401746 | tuile.go | starcoder |
package chapter09
import "reflect"
// Apply takes a slice of type []T and a function of type func(T) T. (If the
// input conditions are not satisfied, Apply panics.) It returns a newly
// allocated slice where each element is the result of calling the function on
// successive elements of the slice.
func Apply(slice,... | chapter09/apply.go | 0.688783 | 0.49109 | apply.go | starcoder |
package selector
import (
"strings"
)
// Selector represents a field or label selector that declares one or more
// operations.
type Selector struct {
Operations []Operation
}
// Matches returns the logical intersection of the evaluations of each of the
// operations in s.
func (s *Selector) Matches(set map[string... | backend/selector/selector.go | 0.674158 | 0.561816 | selector.go | starcoder |
package lexnum
import (
"fmt"
"strconv"
)
// an Encoder may be used to encode or decode an integer as a string. The
// produced strings will have the property that any set of numbers will have
// the same lexical sorting and numeric sorting.
type Encoder struct {
pos rune
neg rune
}
// NewEncoder creates a new ... | lexnum.go | 0.651466 | 0.501038 | lexnum.go | starcoder |
package stats
import (
"math"
"time"
)
// timeseries holds the history of a changing value over a predefined period of
// time.
type timeseries struct {
size int // The number of time slots. Equivalent to len(slots).
resolution time.Duration // The time resolution of each slot.
stepCount int64 ... | vendor/github.com/aristanetworks/goarista/monitor/stats/timeseries.go | 0.868437 | 0.716169 | timeseries.go | starcoder |
package gofpdf
import "math"
const bezierSampleCardinality = 10000
type BezierCurve struct {
Cx1, Cx2, Cx3, Cx4, Cy1, Cy2, Cy3, Cy4, Length float64
}
type BezierSpline []BezierCurve
type BezierSplineSample [][]float64
type BezierPoint struct {
pt Point
normaldir float64
}
func NewBezierCurve(x0, y0, cx... | bezier.go | 0.800341 | 0.474022 | bezier.go | starcoder |
// This package implements a parser for the subset of the CommonMark spec necessary for us to do
// server-side processing. It is not a full implementation and lacks many features. But it is
// complete enough to efficiently and accurately allow us to do what we need to like rewrite image
// URLs for proxying.
package... | shared/markdown/markdown.go | 0.66454 | 0.487612 | markdown.go | starcoder |
package main
// Problem link: https://leetcode-cn.com/problems/cousins-in-binary-tree/
// this is a recursion solution
func isCousins(root *TreeNode, x int, y int) bool {
if root == nil {
return false
}
xLevel, yLevel := getLevel993(root, x, 1), getLevel993(root, y, 1)
if xLevel != yLevel {
return false
}
... | Go-Solutions/993.go | 0.843186 | 0.485417 | 993.go | starcoder |
package indicators
import (
"errors"
"github.com/thetruetrade/gotrade"
)
// A Chaikin Oscillator Indicator (ChaikinOsc), no storage, for use in other indicators
type ChaikinOscWithoutStorage struct {
*baseIndicatorWithFloatBounds
// private variables
fastTimePeriod int
slowTimePeriod int
adl ... | indicators/chainkinosc.go | 0.656658 | 0.418637 | chainkinosc.go | starcoder |
package protoutil
import (
"fmt"
"reflect"
"time"
structpb "github.com/golang/protobuf/ptypes/struct"
log "github.com/sirupsen/logrus"
)
//StructSet take value and add it to Struct s using key
func StructSet(s *structpb.Struct, key string, value interface{}) {
vw := WrapValue(value)
s.Fields[key] = vw
}
// W... | protoutil/protoutil.go | 0.609292 | 0.481759 | protoutil.go | starcoder |
package semantic
import (
"errors"
"fmt"
"strconv"
"time"
"github.com/influxdata/flux/ast"
)
// New creates a semantic graph from the provided AST
func New(prog *ast.Program) (*Program, error) {
return analyzeProgram(prog)
}
func analyzeProgram(prog *ast.Program) (*Program, error) {
p := &Program{
loc: lo... | semantic/analyze.go | 0.671471 | 0.511168 | analyze.go | starcoder |
package pyg
// #include "utils.h"
// static inline void incref(PyObject *obj) { Py_INCREF(obj); }
// static inline void decref(PyObject *obj) { Py_DECREF(obj); }
// static inline void xdecref(PyObject *obj) { Py_XDECREF(obj); }
import "C"
import "fmt"
// Error represents a Python exception as a Go struct that imple... | err.go | 0.680666 | 0.400105 | err.go | starcoder |
package resolver
import (
"github.com/google/gapid/gapil/ast"
"github.com/google/gapid/gapil/semantic"
)
func block(rv *resolver, in *ast.Block, owner semantic.Node) *semantic.Block {
out := &semantic.Block{AST: in}
if in == nil {
return out
}
rv.with(semantic.VoidType, func() {
rv.scope.block = &out.State... | gapil/resolver/statement.go | 0.580233 | 0.409693 | statement.go | starcoder |
package json
import (
"encoding/binary"
"fmt"
"math"
time2 "time"
"github.com/yorkie-team/yorkie/pkg/document/time"
)
type ValueType int
const (
Null ValueType = iota
Boolean
Integer
Long
Double
String
Bytes
Date
)
// ValueFromBytes parses the given bytes into value.
func ValueFromBytes(valueType Valu... | pkg/document/json/primitive.go | 0.687525 | 0.407216 | primitive.go | starcoder |
package eaprm
import (
"fmt"
"time"
)
// Hour returns a two dimensional array of 1 or zero values, where
// the first dimension of the array is of length 24 and corresponds
// to the hours of the day, and the second dimension of the array is
// the same length as t. Values in the returned array [i,j] will be
// 1 i... | time.go | 0.675978 | 0.799481 | time.go | starcoder |
package data
import (
"fmt"
"math"
"math/big"
"math/rand"
"strconv"
"github.com/kode4food/ale/types"
"github.com/kode4food/ale/types/basic"
)
type (
// Float represents a 64-bit floating point number
Float float64
// Ratio represents a number having a numerator and denominator
Ratio big.Rat
)
var (
rat... | data/rational.go | 0.770637 | 0.40439 | rational.go | starcoder |
package pvoc
import(
"math"
)
var gOmegaPiImag []float64 = make([]float64, 31, 31)
var gOmegaPiReal []float64 = make([]float64, 31, 31)
func init() {
var N uint32 = 2
for i := 0; i < 31; i++ {
NFloat := float64(N)
gOmegaPiImag[i] = math.Sin(twoPi / NFloat)
gOmegaPiReal[i] = -2 * math.Sin(pi / NFlo... | pvoc/fft.go | 0.626353 | 0.494812 | fft.go | starcoder |
package swagger
// It includes links to several endpoints (e.g. /oauth2/token) and exposes information on supported signature algorithms among others.
type WellKnown struct {
// URL of the OP's OAuth 2.0 Authorization Endpoint.
AuthorizationEndpoint string `json:"authorization_endpoint"`
// Boolean value specifyi... | sdk/go/hydra/swagger/well_known.go | 0.849347 | 0.486332 | well_known.go | starcoder |
package collection
import (
"errors"
"reflect"
"runtime"
"sync"
)
// Enumerable offers a means of easily converting into a channel. It is most
// useful for types where mutability is not in question.
type Enumerable interface {
Enumerate(cancel <-chan struct{}) Enumerator
}
// Enumerator exposes a new syntax fo... | query.go | 0.68941 | 0.479565 | query.go | starcoder |
package canvas
import (
"image/color"
"github.com/tfriedel6/canvas/backend/backendbase"
)
// LinearGradient is a gradient with any number of
// stops and any number of colors. The gradient will
// be drawn such that each point on the gradient
// will correspond to a straight line
type LinearGradient struct {
cv ... | gradients.go | 0.771241 | 0.535706 | gradients.go | starcoder |
package static
// Countries contains a static mapping of two-letter country codes to their
// geographic center. Source: https://developers.google.com/public-data/docs/canonical/countries_csv
var Countries = map[string]string{
"AD": "42.546245,1.601554",
"AE": "23.424076,53.847818",
"AF": "33.93911,67.709953",
"AG... | static/countries.go | 0.513912 | 0.439026 | countries.go | starcoder |
package mixins
import (
"io"
"github.com/ipld/go-ipld-prime/datamodel"
)
type ListTraits struct {
PkgName string
TypeName string // see doc in kindTraitsGenerator
TypeSymbol string // see doc in kindTraitsGenerator
}
func (ListTraits) Kind() datamodel.Kind {
return datamodel.Kind_List
}
func (g ListTrait... | schema/gen/go/mixins/listGenMixin.go | 0.520009 | 0.437523 | listGenMixin.go | starcoder |
package wl
const DisplayErrorSinceVersion = 1
const DisplayDeleteIdSinceVersion = 1
const DisplaySyncSinceVersion = 1
const DisplayGetRegistrySinceVersion = 1
const RegistryGlobalSinceVersion = 1
const RegistryGlobalRemoveSinceVersion = 1
const RegistryBindSinceVersion = 1
const CallbackDoneSinceVersion = 1
const Comp... | wl/constants.go | 0.5 | 0.400398 | constants.go | starcoder |
package diff
import (
"fmt"
"reflect"
"github.com/arr-ai/wbnf/parser"
)
type Report interface {
Equal() bool
}
type InterfaceDiff struct {
A, B interface{}
}
func (d InterfaceDiff) Equal() bool {
return d.A == d.B
}
func diffInterfaces(a, b interface{}) InterfaceDiff {
if diff := (InterfaceDiff{A: a, B: b}... | parser/diff/terms.go | 0.604632 | 0.461017 | terms.go | starcoder |
package layer
import tf "github.com/galeone/tensorflow/tensorflow/go"
type LSpatialDropout1D struct {
dtype DataType
inputs []Layer
name string
noiseShape interface{}
rate float64
seed interface{}
shape tf.Shape
trainable bool
layerWeights []*tf.Tensor
}
func... | layer/SpatialDropout1D.go | 0.67104 | 0.402833 | SpatialDropout1D.go | starcoder |
package main
import (
reflect "reflect"
groo "github.com/grolang/gro/ops"
assert "github.com/grolang/gro/assert"
time "time"
)
import ops "github.com/grolang/gro/ops"
var v int
const c = 2
type t int
func init() {
{
assert.AssertTrue(groo.IsEqual(groo.Mod(reflect.TypeOf(7), groo.MakeText("v")), groo.MakeT... | dynamic/basic.go | 0.575827 | 0.699158 | basic.go | starcoder |
package convert
import (
"github.com/hashicorp/go-cty/cty"
)
// conversion is an internal variant of Conversion that carries around
// a cty.Path to be used in error responses.
type conversion func(cty.Value, cty.Path) (cty.Value, error)
func getConversion(in cty.Type, out cty.Type, unsafe bool) conversion {
conv ... | vendor/github.com/hashicorp/go-cty/cty/convert/conversion.go | 0.640074 | 0.427337 | conversion.go | starcoder |
// Package deepequalerrors defines an Analyzer that checks for the use
// of reflect.DeepEqual with error values.
package deepequalerrors
import (
"go/ast"
"go/types"
"github.com/kdy1/tools/go/analysis"
"github.com/kdy1/tools/go/analysis/passes/inspect"
"github.com/kdy1/tools/go/ast/inspector"
"github.com/kdy1... | go/analysis/passes/deepequalerrors/deepequalerrors.go | 0.712132 | 0.476762 | deepequalerrors.go | starcoder |
package assert
// The example in the package doc above can't be demonstrated by an Example test file.
import (
"fmt"
"reflect"
"testing"
)
//================================================================================
// T is a struct extending the one from standard library package testing with assertion cap... | assert/assert.go | 0.61555 | 0.659254 | assert.go | starcoder |
package login
import (
"context"
"testing"
"github.com/bxcodec/faker/v3"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/ory/kratos/identity"
"github.com/ory/kratos/selfservice/flow"
"github.com/ory/kratos/selfservice/form"
"github.com/ory/krat... | selfservice/flow/login/persistence.go | 0.512693 | 0.569045 | persistence.go | starcoder |
// Package kinesisiface provides an interface for the Amazon Kinesis.
package kinesisiface
import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/kinesis"
)
// KinesisAPI is the interface type for kinesis.Kinesis.
type KinesisAPI interface {
AddTagsToStreamRequest(*kinesis.AddTagsToSt... | Godeps/_workspace/src/github.com/aws/aws-sdk-go/service/kinesis/kinesisiface/interface.go | 0.610221 | 0.407392 | interface.go | starcoder |
package iterator
import (
"context"
"github.com/cayleygraph/cayley/graph"
"github.com/cayleygraph/quad"
)
var _ graph.IteratorFuture = &Count{}
// Count iterator returns one element with size of underlying iterator.
type Count struct {
it *count
graph.Iterator
}
// NewCount creates a new iterator to count a n... | graph/iterator/count.go | 0.765418 | 0.462534 | count.go | starcoder |
package common
import (
"math"
"math/rand"
)
// Distribution provides an interface to model a statistical distribution.
type Distribution interface {
Advance()
Get() float64 // should be idempotent
}
// NormalDistribution models a normal distribution.
type NormalDistribution struct {
Mean float64
StdDev floa... | bulk_data_gen/common/distribution.go | 0.908537 | 0.626895 | distribution.go | starcoder |
package distuv
import (
"math"
"golang.org/x/exp/rand"
"gonum.org/v1/gonum/mathext"
"gonum.org/v1/gonum/stat/combin"
)
// Binomial implements the binomial distribution, a discrete probability distribution
// that expresses the probability of a given number of successful Bernoulli trials
// out of a total of n,... | stat/distuv/binomial.go | 0.871543 | 0.590691 | binomial.go | starcoder |
package engine
// Cropped quantity refers to a cut-out piece of a large quantity
import (
"fmt"
data "github.com/seeder-research/uMagNUS/data"
opencl "github.com/seeder-research/uMagNUS/opencl"
util "github.com/seeder-research/uMagNUS/util"
)
func init() {
DeclFunc("Crop", Crop, "Crops a quantity to cell range... | engine/crop.go | 0.667473 | 0.500061 | crop.go | starcoder |
// Package h28 contains the data structures for HL7 v2.8.
package h28
// Registry implements the required interface for unmarshalling data.
var Registry = registry{}
type registry struct{}
func (registry) Version() string {
return Version
}
func (registry) ControlSegment() map[string]any {
return ControlSegmentRe... | h28/registry.go | 0.590425 | 0.418222 | registry.go | starcoder |
package nmea
import (
"fmt"
"github.com/martinlindhe/unit"
)
const (
// TypeMWD type for MWD sentences
TypeMWD = "MWD"
)
// Sentence info:
// 1 Wind direction, 0.0 to 359.9 degrees True, to the nearest 0.1 degree
// 2 T: True
// 3 Wind direction, 0.0 to 359.9 degrees Magnetic, to the nearest 0.1 degree... | mwd.go | 0.669637 | 0.439386 | mwd.go | starcoder |
package graphics
import (
"fmt"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/mathgl/mgl32"
"github.com/go-gl/mathgl/mgl64"
"github.com/maxfish/gojira2d/pkg/utils"
)
const (
// Float32Size is the size (in bytes) of a float32
Float32Size = 4
)
// ModelMatrix matrix representing the primitive transforma... | pkg/graphics/primitive_2d.go | 0.81772 | 0.620334 | primitive_2d.go | starcoder |
package cryptypes
import "database/sql/driver"
// EncryptedInt supports encrypting Int data
type EncryptedInt struct {
Field
Raw int
}
// Scan converts the value from the DB into a usable EncryptedInt value
func (s *EncryptedInt) Scan(value interface{}) error {
return decrypt(value.([]byte), &s.Raw)
}
// Value c... | cryptypes/type_int.go | 0.8059 | 0.585131 | type_int.go | starcoder |
package base36
// Simplified code based on https://godoc.org/github.com/mr-tron/base58
// which in turn is based on https://github.com/trezor/trezor-crypto/commit/89a7d7797b806fac
import (
"fmt"
)
const UcAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const LcAlphabet = "0123456789abcdefghijklmnopqrstuvwxyz"
con... | base36.go | 0.690037 | 0.443661 | base36.go | starcoder |
package main
/* Day 10 part A
For a given sequence of lenghts (input) apply the following rules to a circular
list of size 256 ints (numbered 0 to 255):
Starting with the first item in the list of numbers reverse the order of the
first n digits where n is the first length (input).
Once the reversal is complete move ... | 2017/day10.go | 0.770594 | 0.768168 | day10.go | starcoder |
package expression
import (
"fmt"
"reflect"
)
type numberOp func(x float64, y float64) interface{}
type stringOp func(x string, y string) interface{}
type boolOp func(x bool, y bool) interface{}
type timeOp func(x *DateTime, y *DateTime) interface{}
type opOther func() (interface{}, error)
func op(x interface{}, y... | mg/expression/operators.go | 0.690037 | 0.502747 | operators.go | starcoder |
package primitive
import (
"fmt"
"math"
"math/rand"
"github.com/fogleman/gg"
)
type Rectangle struct {
W, H int
X1, Y1 int
X2, Y2 int
}
func NewRandomRectangle(w, h int) *Rectangle {
x1 := rand.Intn(w)
y1 := rand.Intn(h)
x2 := rand.Intn(w)
y2 := rand.Intn(h)
return &Rectangle{w, h, x1, y1, x2, y2}
}
... | primitive/rectangle.go | 0.716913 | 0.489076 | rectangle.go | starcoder |
package config
import (
"math"
"math/rand"
"github.com/paulwrubel/photolum/config/geometry"
)
// A Camera holds information about the scene's camera
// and facilitates the casting of Rays into the scene
type Camera struct {
EyeLocation geometry.Point
TargetLocation geometry.Point
UpVector geometry.Vec... | config/camera.go | 0.792384 | 0.708994 | camera.go | starcoder |
package chart
import (
"strings"
util "github.com/beevee/go-chart/util"
)
// TextHorizontalAlign is an enum for the horizontal alignment options.
type TextHorizontalAlign int
const (
// TextHorizontalAlignUnset is the unset state for text horizontal alignment.
TextHorizontalAlignUnset TextHorizontalAlign = 0
/... | text.go | 0.585457 | 0.428712 | text.go | starcoder |
package openapi
// CheckDetailAddendumB struct for CheckDetailAddendumB
type CheckDetailAddendumB struct {
// CheckDetailAddendumB ID
ID string `json:"ID,omitempty"`
// ImageReferenceKeyIndicator identifies whether ImageReferenceKeyLength contains a variable value within the allowable range, or contains a defined v... | client/model_check_detail_addendum_b.go | 0.678114 | 0.414721 | model_check_detail_addendum_b.go | starcoder |
package pgmodel
import (
"fmt"
"github.com/timescale/timescale-prometheus/pkg/prompb"
)
const (
MetricNameLabelName = "__name__"
)
var (
ErrNoMetricName = fmt.Errorf("metric name missing")
)
// SeriesID represents a globally unique id for the series. This should be equivalent
// to the PostgreSQL type in the ... | pkg/pgmodel/ingestor.go | 0.654564 | 0.428951 | ingestor.go | starcoder |
package store
import (
"math"
enc "github.com/KoddiDev/sketches-go/ddsketch/encoding"
)
// CollapsingLowestDenseStore is a dynamically growing contiguous (non-sparse) store.
// The lower bins get combined so that the total number of bins do not exceed maxNumBins.
type CollapsingLowestDenseStore struct {
DenseSto... | ddsketch/store/collapsing_lowest_dense_store.go | 0.699357 | 0.435181 | collapsing_lowest_dense_store.go | starcoder |
package manual
func syntax() string {
return `
Comments
Comments are nonsensical remarks that accompany code but are ignored by
the compiler. Comments start with a '#' hash symbol (or pound for some
Americans) and ends at the end of the line.
# Write whatever you want here
# Put two or more comment lines tog... | _manual/syntax.go | 0.619126 | 0.72577 | syntax.go | starcoder |
package float128ppc
import (
"math"
"math/big"
)
const (
// precision specifies the number of bits in the mantissa (including the
// implicit lead bit).
precision = 106
)
// Positive and negative Not-a-Number, infinity and zero.
var (
// +NaN
NaN = Float{high: math.NaN(), low: 0}
// -NaN
NegNaN = Float{high... | float128ppc/float128ppc.go | 0.869424 | 0.627466 | float128ppc.go | starcoder |
package specs
import (
"reflect"
"testing"
"time"
"github.com/Fs02/grimoire"
"github.com/Fs02/grimoire/changeset"
"github.com/Fs02/grimoire/params"
"github.com/stretchr/testify/assert"
)
// Insert tests insert specifications.
func Insert(t *testing.T, repo grimoire.Repo) {
user := User{}
repo.From(users).Mu... | adapter/specs/insert.go | 0.545286 | 0.502686 | insert.go | starcoder |
package plotter
import (
"image/color"
"code.google.com/p/plotinum/plot"
"code.google.com/p/plotinum/vg"
)
// Line implements the Plotter interface, drawing a line.
type Line struct {
// XYs is a copy of the points for this line.
XYs
// LineStyle is the style of the line connecting
// the points.
plot.Line... | plotter/line.go | 0.83128 | 0.415195 | line.go | starcoder |
package largest_rectangle_in_histogram
import "container/list"
/*
84. 柱状图中最大的矩形 https://leetcode-cn.com/problems/largest-rectangle-in-histogram/
给定 n 个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。
求在该柱状图中,能够勾勒出来的矩形的最大面积。
以上是柱状图的示例,其中每个柱子的宽度为 1,给定的高度为 [2,1,5,6,2,3]。
图中阴影部分为所能勾勒出的最大矩形面积,其面积为 10 个单位。
示例:
输入: [2,1,5,6,2,3]
输出... | solutions/largest-rectangle-in-histogram/d.go | 0.60743 | 0.594698 | d.go | starcoder |
package stat
import "math"
// SummaryStatistics keeps track of the count, the sum, the min and the max of
// recorded values. We use a compensated sum to avoid accumulating rounding
// errors (see https://en.wikipedia.org/wiki/Kahan_summation_algorithm).
type SummaryStatistics struct {
count float64
sum ... | ddsketch/stat/summary.go | 0.802556 | 0.633509 | summary.go | starcoder |
package k2tree
import (
"fmt"
"math/bits"
"github.com/barakmich/k2tree/bytearray"
)
type byteArray struct {
bytes bytearray.ByteArray
length int
total int
}
var _ bitarray = (*byteArray)(nil)
func newByteArray(bytes bytearray.ByteArray) *byteArray {
return &byteArray{
bytes: bytes,
length: 0,
total... | bytearray.go | 0.576661 | 0.426322 | bytearray.go | starcoder |
package okclient
import (
"encoding/json"
)
// RelationDTO struct for RelationDTO
type RelationDTO struct {
Id string `json:"id"`
FromCIID string `json:"fromCIID"`
ToCIID string `json:"toCIID"`
PredicateID string `json:"predicateID"`
State RelationState `json:"state"`
}
// NewRelationDTO instantiates a new Re... | model_relation_dto.go | 0.738009 | 0.429908 | model_relation_dto.go | starcoder |
package resourcetree
import (
"reflect"
)
const (
v1TimeType = "v1.Time"
volatileTimeType = "apis.VolatileTime"
)
// StructKindNode represents nodes in the resource tree of type reflect.Kind.Struct
type StructKindNode struct {
NodeData
}
// GetData returns node data
func (s *StructKindNode) GetData() Node... | tools/webhook-apicoverage/resourcetree/structkindnode.go | 0.671255 | 0.470493 | structkindnode.go | starcoder |
package ro
import "github.com/MaxSlyugrov/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "dd.MM.y"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:m... | resources/locales/ro/calendar.go | 0.503906 | 0.416322 | calendar.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"math"
"os"
"strconv"
"strings"
)
type point struct {
X, Y int
}
type wirePoint struct {
direction string
length int
}
type wire struct {
Path []point
}
func newPoint(x int, y int) *point {
return &point{X: x, Y: y}
}
func (p1 point) addPoint(p2 point) poin... | 2019/day3/day_3.go | 0.604632 | 0.5047 | day_3.go | starcoder |
package sdl
// #include "includes.h"
import "C"
// Header file for SDL_rect definition and management functions.
// The structure that defines a point.
//
// See also: SDL_EnclosePoints
//
// See also: SDL_PointInRect
//
// ↪ https://wiki.libsdl.org/SDL_Point
type Point struct {
X int
Y int
}
f... | sdl/SDL_rect.h.go | 0.713931 | 0.737678 | SDL_rect.h.go | starcoder |
package render
import (
"strings"
"github.com/weaveworks/scope/probe/kubernetes"
"github.com/weaveworks/scope/report"
)
// KubernetesVolumesRenderer is a Renderer which combines all Kubernetes
// volumes components such as stateful Pods, Persistent Volume, Persistent Volume Claim, Storage Class.
var KubernetesVol... | render/persistentvolume.go | 0.685002 | 0.452899 | persistentvolume.go | starcoder |
package decoder
import (
"github.com/rqme/neat"
"github.com/rqme/neat/network"
)
// Helper that decodes the genome into a neural network
type Classic struct{}
// Decodes the genome into a phenome
func (d Classic) Decode(g neat.Genome) (p neat.Phenome, err error) {
// Return the phenome
net, e := d.decode(g)
if ... | decoder/classic.go | 0.700997 | 0.467575 | classic.go | starcoder |
package main
var schemas = `
{
"API": {
"createAsset": {
"description": "Create an asset. One argument, a JSON encoded event. AssetID is required with zero or more writable properties. Establishes an initial asset state.",
"properties": {
"args": {
... | contracts/industry/cashMachine/schemas.go | 0.885903 | 0.567098 | schemas.go | starcoder |
package main
// Move contains the information needed to transition from one Position to another.
type Move struct {
From Square
To Square // invariant: not equal to From
Piece Piece // the moving Piece; invariant: not None
CapturePiece Piece // the Piece being captured, or else None
EP ... | move.go | 0.699973 | 0.608187 | move.go | starcoder |
package types
import (
"github.com/vron/compute/glbind/input"
)
type Types struct {
m map[string]*GlslType
l []*GlslType
}
func New(inp input.Input) *Types {
ts := &Types{
m: map[string]*GlslType{},
l: []*GlslType{},
}
ts.createBasicBuiltinTypes()
ts.createComplexBuiltinTypes()
for _, str := range inp.St... | glbind/types/types.go | 0.502197 | 0.54698 | types.go | starcoder |
package strings
import (
"unicode/utf8"
)
// NumericLess compares strings with respect to values of positive integer groups.
// For example, 'a9z' is considered less than 'a11z', because 9 < 11.
// If two numbers with leading zeroes have the same value, the shortest of them is considered less, i.e. 12 < 012.
// Digi... | strings/sort.go | 0.642208 | 0.568476 | sort.go | starcoder |
package dda
import "gonum.org/v1/gonum/graph"
func graphDegeneracy(g graph.Undirected) int {
nodes := graph.NodesOf(g.Nodes())
// The algorithm used here is essentially as described at
// http://en.wikipedia.org/w/index.php?title=Degeneracy_%28graph_theory%29&oldid=640308710
// Initialize an output list L in re... | dda/degeneracy.go | 0.62395 | 0.467818 | degeneracy.go | starcoder |
package dither
import (
"image"
"image/color"
)
var white = color.Gray{Y: 255}
var black = color.Gray{Y: 0}
func threshold(pixel color.Gray) color.Gray {
if pixel.Y > 123 {
return white
}
return black
}
func Threshold(input *image.Gray) *image.Gray {
bounds := input.Bounds()
dithered := image.NewGray(bound... | dither.go | 0.710528 | 0.514766 | dither.go | starcoder |
package cmd
import (
"fmt"
"strconv"
"strings"
"github.com/bpicode/fritzctl/fritz"
"github.com/bpicode/fritzctl/logger"
"github.com/spf13/cobra"
)
var temperatureCmd = &cobra.Command{
Use: "temperature [value in °C, on, off, sav, comf] [device/group names]",
Short: "Set the temperature of HKR devices/group... | cmd/temperature.go | 0.730386 | 0.450299 | temperature.go | starcoder |
package solution
import "sort"
/*
leetcode: https://leetcode.com/problems/design-search-autocomplete-system/
*/
/*
We build trie data structure.
Each trie will keep freq times and 3 hot sentences all trie below it and itself.
In AutocompleteSystem struct, we have root trie.
We also need Cursor and Buff to keep... | lesson-15/trie/642-design-search-autocomplete-system/solution.go | 0.708313 | 0.408926 | solution.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.