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 treemap
import (
"context"
"encoding/hex"
"encoding/json"
"fmt"
"math/rand"
"reflect"
)
// NewTree returns a Block with the received info with all the injected children
// already positioned and sized. This function is intended to be used when programmatically
// building the root node of a tree, but it... | block.go | 0.736211 | 0.488161 | block.go | starcoder |
package gsm7bit
/*
GSM 7-bit default alphabet and extension table
Source: https://en.wikipedia.org/wiki/GSM_03.38#GSM_7-bit_default_alphabet_and_extension_table_of_3GPP_TS_23.038_/_GSM_03.38
*/
const escapeSequence byte = 0x1B
var forwardLookup = map[rune]byte{
'@': 0x00, '£': 0x01, '$': 0x02, '¥': 0x03, 'è': 0x04,... | coding/gsm7bit/table.go | 0.522933 | 0.656177 | table.go | starcoder |
package gographviz
import (
"sort"
)
//Represents an Edge.
type Edge struct {
Src string
SrcPort string
Dst string
DstPort string
Dir bool
Attrs Attrs
}
//Represents a set of Edges.
type Edges struct {
SrcToDsts map[string]map[string][]*Edge
DstToSrcs map[string]map[string][]*Edge
Edges ... | vendor/github.com/awalterschulze/gographviz/edges.go | 0.597021 | 0.50531 | edges.go | starcoder |
package data
import (
mat "github.com/nlpodyssey/spago/pkg/mat32"
"github.com/nlpodyssey/spago/pkg/mat32/rand"
"github.com/nlpodyssey/spago/pkg/utils"
)
// GenerateBatches generates a list of batches so that the classes distribution among them is approximately the same.
// The class is given by the callback for e... | pkg/utils/data/data.go | 0.742235 | 0.410697 | data.go | starcoder |
package output
import (
"github.com/benthosdev/benthos/v4/internal/batch/policy"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/component/output"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/internal/impl/aws/session"
... | internal/old/output/aws_s3.go | 0.767516 | 0.670967 | aws_s3.go | starcoder |
package tui
import (
"image"
)
// Surface defines a surface that can be painted on.
type Surface interface {
SetCell(x, y int, ch rune, s Style)
SetCursor(x, y int)
Begin()
End()
Size() image.Point
}
// Painter provides operations to paint on a surface.
type Painter struct {
Theme *Theme
// Surface to paint... | vendor/github.com/marcusolsson/tui-go/painter.go | 0.767254 | 0.459137 | painter.go | starcoder |
// Package errors provides a simple API to create and compare errors.
// It captures the stacktrace when an error is created or wrapped, which can be then be inspected for debugging purposes.
// This package, compiled with the "debug" build tag is only meant to ease development and should not be used otherwise.
packag... | internal/errors/errors_debug.go | 0.660172 | 0.437223 | errors_debug.go | starcoder |
package output
import (
"github.com/Jeffail/benthos/v3/internal/component/output"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
"github.... | lib/output/amqp_0_9.go | 0.740174 | 0.47098 | amqp_0_9.go | starcoder |
* Implementation of the Secure Hashing Algorithm (SHA-256)
*
* Generates a 256 bit message digest. It should be impossible to come
* come up with two messages that hash to the same value ("collision free").
*
* For use with byte-oriented messages only.
*/
package amcl
const SHA256 int = 32
const hash256_H0 ui... | exchanger/vendor/github.com/hyperledger/fabric-amcl/amcl/HASH256.go | 0.629775 | 0.484075 | HASH256.go | starcoder |
package iterator
import (
"github.com/syndtr/goleveldb/leveldb/util"
)
// BasicArray is the interface that wraps basic Len and Search method.
type BasicArray interface {
// Len returns length of the array.
Len() int
// Search finds smallest index that point to a key that is greater
// than or equal to the give... | vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go | 0.716516 | 0.472927 | array_iter.go | starcoder |
Cylinder Pattern and Core Box
*/
//-----------------------------------------------------------------------------
package main
import (
"math"
"github.com/deadsy/sdfx/obj"
"github.com/deadsy/sdfx/sdf"
)
//-----------------------------------------------------------------------------
const cylinderBaseOffset = 3... | examples/midget/cylinder.go | 0.691393 | 0.40028 | cylinder.go | starcoder |
package element
import (
"github.com/bhollier/ui/pkg/ui/util"
"github.com/faiface/pixel"
)
// Function to initialise an image
// as if it were an SVG icon. Should
// be called if ImageIsSVG is true
func initIcon(e Element, i Image) error {
// If the SVG hasn't been loaded yet
if i.GetSVG() == nil {
// Load the ... | pkg/ui/element/icon.go | 0.514888 | 0.423279 | icon.go | starcoder |
package runtime
import (
"math"
)
func Unm(x Value) (Value, bool) {
switch x.iface.(type) {
case int64:
return IntValue(-x.AsInt()), true
case float64:
return FloatValue(-x.AsFloat()), true
default:
return NilValue, false
}
}
func Add(x, y Value) (Value, bool) {
switch x.iface.(type) {
case int64:
sw... | runtime/arith.go | 0.713831 | 0.571169 | arith.go | starcoder |
package hashtree
import (
"crypto/sha256"
"hash"
)
const (
//LeafBlockSize is the max size in bytes
//of a data block on the leaf of a hash tree.
LeafBlockSize = 1024
)
// fileDigest represents the partial evaluation of a file hash.
type fileDigest struct {
len int64 // processed length
l... | hashtree/file_processor.go | 0.647464 | 0.472866 | file_processor.go | starcoder |
package Euler2D
import (
"fmt"
"math"
"strings"
"github.com/notargets/gocfd/DG2D"
"github.com/notargets/gocfd/utils"
)
type SolutionLimiter struct {
limiterType LimiterType
Element *DG2D.LagrangeElement2D
Tris *DG2D.Triangulation
Partitions *PartitionMap
Shoc... | model_problems/Euler2D/filter.go | 0.569613 | 0.409575 | filter.go | starcoder |
package full
import (
"github.com/OpenWhiteBox/primitives/encoding"
"github.com/OpenWhiteBox/primitives/matrix"
)
// blockAffine is a modification of encoding.BlockAffine that allows non-bijective transformations.
type blockAffine struct {
linear matrix.Matrix
constant matrix.Row
}
func parseBlockAffine(in []b... | constructions/full/full.go | 0.706494 | 0.410343 | full.go | starcoder |
package shuffle
import (
"fmt"
"math"
"math/rand"
"github.com/spaolacci/murmur3"
)
// SimpleShuffleShard implementation uses simple probabilistic hashing to
// compute shuffle shards. This function takes an existing lattice and
// generates a new sharded lattice for the given indentification and
// required numb... | shard.go | 0.708616 | 0.579876 | shard.go | starcoder |
package distuv
import (
"math"
"golang.org/x/exp/rand"
)
// LogNormal represents a random variable whose log is normally distributed.
// The probability density function is given by
// 1/(x σ √2π) exp(-(ln(x)-μ)^2)/(2σ^2))
type LogNormal struct {
Mu float64
Sigma float64
Src rand.Source
}
// CDF compute... | stat/distuv/lognormal.go | 0.896246 | 0.718088 | lognormal.go | starcoder |
package tetra3d
const (
FogOff = iota // No fog
FogAdd // Additive blended fog
FogMultiply // Multiplicative blended fog
FogOverwrite // Color overwriting fog (mixing base with fog color over depth distance)
)
type FogMode int
// Scene represents a world of sorts, and can contai... | scene.go | 0.81648 | 0.549036 | scene.go | starcoder |
This library is compatible with the original Perl implementation:
http://search.cpan.org/dist/ShardedKV/
https://github.com/tsee/p5-ShardedKV
*/
package shardedkv
import (
"sync"
)
// Storage is a key-value storage backend
type Storage interface {
// Get returns the value for a given key and a bool indica... | shardedkv.go | 0.769384 | 0.490907 | shardedkv.go | starcoder |
package scheduling
import (
"time"
"go.thethings.network/lorawan-stack/v3/pkg/frequencyplans"
)
// ConcentratorTime is the time relative to the concentrator start time (nanoseconds).
type ConcentratorTime int64
// NewEmission returns a new Emission with the given values.
func NewEmission(starts ConcentratorTime,... | pkg/gatewayserver/scheduling/emission.go | 0.827619 | 0.532972 | emission.go | starcoder |
package css
import (
"errors"
"strings"
)
// A SegmentType is the type of a Segment.
type SegmentType uint32
const (
// ByteType is everything not of the other types below.
ByteType SegmentType = iota
// ImageURLType is a URL for an image. Note that the value has been
// stripped of the surrounding 'url' iden... | transformer/internal/css/cssurl.go | 0.593138 | 0.403567 | cssurl.go | starcoder |
package types
import (
"bytes"
"fmt"
"github.com/tendermint/tendermint/crypto"
)
// For event switch in entropy generator
const (
EventComputedEntropy = "EventComputedEntropy"
MaxEntropyShareSize = 500
MaxThresholdSignatureSize = 256
GenesisHeight = int64(0)
)
type ThresholdSignature =... | types/entropy_share.go | 0.744378 | 0.463201 | entropy_share.go | starcoder |
package props
import (
"github.com/bjgirl/maroto/pkg/color"
"github.com/bjgirl/maroto/pkg/consts"
)
// Proportion represents a proportion from a rectangle, example: 16x9, 4x3...
type Proportion struct {
// Width from the rectangle: Barcode, image and etc.
Width float64
// Height from the rectangle: Barcode, imag... | pkg/props/prop.go | 0.731251 | 0.732317 | prop.go | starcoder |
package ta
// MinMax returns the min/max over a period
// Update returns min
// UpdateAll returns [min, max]
func MinMax(period int) MultiVarStudy {
return &minmax{data: NewCapped(period)}
}
func Min(period int) Study {
return &minmax{data: NewCapped(period)}
}
func Max(period int) Study {
return &minmax{data: Ne... | studies_01.go | 0.870583 | 0.460532 | studies_01.go | starcoder |
package geom
// A LineString represents a single, unbroken line, linearly interpreted
// between zero or more control points.
type LineString struct {
geom1
}
// NewLineString returns a new LineString with layout l and no control points.
func NewLineString(l Layout) *LineString {
return NewLineStringFlat(l, nil)
}
... | vendor/github.com/twpayne/go-geom/linestring.go | 0.879153 | 0.487551 | linestring.go | starcoder |
package expression
import (
"github.com/dolthub/go-mysql-server/sql"
)
// IsUnary returns whether the expression is unary or not.
func IsUnary(e sql.Expression) bool {
return len(e.Children()) == 1
}
// IsBinary returns whether the expression is binary or not.
func IsBinary(e sql.Expression) bool {
return len(e.... | sql/expression/common.go | 0.820505 | 0.483709 | common.go | starcoder |
package types
import (
"math"
"reflect"
"github.com/lyraproj/pcore/px"
"github.com/lyraproj/pcore/utils"
)
// CommonType returns a type that both a and b are assignable to
func commonType(a px.Type, b px.Type) px.Type {
if isAssignable(a, b) {
return a
}
if isAssignable(b, a) {
return a
}
// Deal with ... | types/commonality.go | 0.6705 | 0.528229 | commonality.go | starcoder |
package vclock
// Vector clock is logically a list of tuple [(pid1, tick1), (pid2, tick2), ...]
// where pid is the process id and tick is the clock value.
type VClock map[string]uint64
type Relation uint8
const (
Equal = iota
Ancestor
Descendant
Conflict
)
// Advance tick for the given process id by 1
func... | vector_clock.go | 0.781664 | 0.515681 | vector_clock.go | starcoder |
package index
import (
"image/color"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/stat"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/plotutil"
"gonum.org/v1/plot/vg"
)
/*
Genplot takes an index and plots its keys, CDF, its approximation, and writes a plot.png file in assets/folder
*/... | index/genplot.go | 0.695131 | 0.403626 | genplot.go | starcoder |
package iso20022
// Specifies a collection of monetary totals for this settlement.
type SettlementMonetarySummation1 struct {
// Monetary value of the line amount total being reported for this settlement.
LineTotalAmount []*CurrencyAndAmount `xml:"LineTtlAmt,omitempty"`
// Monetary value of the allowance total be... | SettlementMonetarySummation1.go | 0.786254 | 0.447581 | SettlementMonetarySummation1.go | starcoder |
2D Spirals
https://math.stackexchange.com/questions/175106/distance-between-point-and-a-spiral
*/
//-----------------------------------------------------------------------------
package sdf
import (
"errors"
"math"
)
//-----------------------------------------------------------------------------
// polarDist2 ... | sdf/spiral.go | 0.895816 | 0.632645 | spiral.go | starcoder |
package year2021
import (
"strconv"
"strings"
"github.com/lanphiergm/adventofcodego/internal/utils"
)
// Seven Segment Search Part 1 computes the number of 1s, 4s, 7s, and 8s that
// appear in the output
func SevenSegmentSearchPart1(filename string) interface{} {
notes := utils.ReadStrings(filename)
counter := ... | internal/puzzles/year2021/day_08_seven_segment_search.go | 0.68637 | 0.491151 | day_08_seven_segment_search.go | starcoder |
package math32
// Box2 represents a 2D bounding box defined by two points:
// the point with minimum coordinates and the point with maximum coordinates.
type Box2 struct {
min Vector2
max Vector2
}
// NewBox2 creates and returns a pointer to a new Box2 defined
// by its minimum and maximum coordinates.
... | math32/box2.go | 0.9244 | 0.516413 | box2.go | starcoder |
package renderer
import (
"image/color"
"math"
"github.com/9600org/cubebit"
)
// Object is a thing to be rendered.
type Object interface {
// At returns the colour at the given point in space.
At(x, y, z float64) color.RGBA
}
// Sphere represents a sphere to be rendered
type Sphere struct {
// CentreX, Centre... | renderer/render.go | 0.840423 | 0.460895 | render.go | starcoder |
package model
import (
"fmt"
"github.com/reserve-trust/grule-rule-engine/pkg"
"reflect"
"strings"
)
// ValueNode is an abstraction layer to access underlying dom style data.
// the node have tree kind of structure which each node are tied to an underlying data node.
type ValueNode interface {
IdentifiedAs() str... | model/DataAccessLayer.go | 0.683736 | 0.458409 | DataAccessLayer.go | starcoder |
package evaluator
import (
"fmt"
"yokan/ast"
"yokan/object"
)
func Eval(node ast.Node, env *object.Environment) object.Object {
switch node := node.(type) {
case *ast.Program:
return evalStatements(node.Statements, env)
case *ast.ExpressionStatement:
return Eval(node.Expression, env)
case *ast.Assign:
... | evaluator/evaluator.go | 0.542621 | 0.416797 | evaluator.go | starcoder |
package game
import "fmt"
type mark = int
const (
// None represents no marking on a square
None mark = iota
// X represents an 'X' marking on a square
X mark = iota
// O represents an 'O' marking on a square
O mark = iota
)
// GridRef indicates a square on the grid surface
type GridRef = int
const (
// Top... | game/game.go | 0.679604 | 0.614857 | game.go | starcoder |
package sctp
import (
"github.com/pkg/errors"
)
/*
chunkHeartbeatAck represents an SCTP Chunk of type HEARTBEAT ACK
An endpoint should send this chunk to its peer endpoint as a response
to a HEARTBEAT chunk (see Section 8.3). A HEARTBEAT ACK is always
sent to the source IP address of the IP datagram containing the... | trunk/3rdparty/srs-bench/vendor/github.com/pion/sctp/chunk_heartbeat_ack.go | 0.73914 | 0.49646 | chunk_heartbeat_ack.go | starcoder |
package runtime
import (
"math"
)
func unm(t *Thread, x Value) (Value, *Error) {
nx, fx, kx := ToNumber(x)
switch kx {
case IsInt:
return IntValue(-nx), nil
case IsFloat:
return FloatValue(-fx), nil
}
res, err, ok := metaun(t, "__unm", x)
if ok {
return res, err
}
return NilValue, NewErrorS("cannot ne... | runtime/arith.go | 0.670069 | 0.420421 | arith.go | starcoder |
package iso20022
// Provides information about the rates related to securities movement.
type RateDetails3 struct {
// Rate used for additional tax that cannot be categorised.
AdditionalTax *RateAndAmountFormat14Choice `xml:"AddtlTax,omitempty"`
// Cash dividend amount per equity before deductions or allowances h... | RateDetails3.go | 0.843219 | 0.639652 | RateDetails3.go | starcoder |
package flat
import (
"go-simulate-a-city/common/commonmath"
"go-simulate-a-city/sim/core/dto/geometry"
"go-simulate-a-city/sim/core/gamegrid"
"go-simulate-a-city/sim/core/mailroom"
"go-simulate-a-city/sim/ui"
"github.com/go-gl/mathgl/mgl32"
)
// Defines how to render generic regions in a channel-based manner
... | sim/ui/flat/regionRenderer.go | 0.598899 | 0.420124 | regionRenderer.go | starcoder |
package math
import (
"fmt"
)
// Orientation represents a transformation matrix, written as a right and a down vector.
type Orientation struct {
Right Delta
Down Delta
}
// Concat returns the orientation o * o2 so that o.Concat(o2).Apply(d) == o.Apply(o2.Apply(d)).
func (o Orientation) Concat(o2 Orientation) Or... | internal/math/orientation.go | 0.903578 | 0.71638 | orientation.go | starcoder |
package polynomial
import (
"fmt"
"io"
"strconv"
)
type Action int
const (
ActDefault Action = iota
ActStore
ActLoad
ActDerive
ActZeroes
)
type InputStatement struct {
Request Action
Name string
Function Polynomial
}
// Parser represents a parser
type Parser struct {
s *Scanner
buf struct {
t... | polynomial/parser.go | 0.700997 | 0.428114 | parser.go | starcoder |
package holidays
func init() {
registerHolidayDataSource("de", holidaysDENational{})
registerHolidayDataSource("de-bb", holidaysDEBB{})
registerHolidayDataSource("de-be", holidaysDEBE{})
registerHolidayDataSource("de-bw", holidaysDEBW{})
registerHolidayDataSource("de-by", holidaysDEBY{})
registerHolidayDataSourc... | holidays/holidays_de.go | 0.500732 | 0.48377 | holidays_de.go | starcoder |
package util
import (
"crypto/sha256"
"math/big"
"github.com/ing-bank/zkrp/crypto/bn256"
"github.com/ing-bank/zkrp/crypto/p256"
"github.com/ing-bank/zkrp/util/bn"
"github.com/ing-bank/zkrp/util/byteconversion"
)
// Constants that are going to be used frequently, then we just need to compute t... | crypto/vendor/ing-bank/zkrp/util/util.go | 0.618435 | 0.483709 | util.go | starcoder |
package farm
import (
"encoding/binary"
"math/bits"
)
func uoH(x, y, mul uint64, r uint) uint64 {
a := (x ^ y) * mul
a ^= (a >> 47)
b := (y ^ a) * mul
return bits.RotateLeft64(b, -int(r)) * mul
}
// Hash64WithSeeds hashes a byte slice and two uint64 seeds and returns a uint64 hash value
func Hash64WithSeeds(s ... | vendor/github.com/dgryski/go-farm/farmhashuo.go | 0.731346 | 0.409575 | farmhashuo.go | starcoder |
package chart
import (
"math"
"sort"
)
// ValueSequence returns a sequence for a given values set.
func ValueSequence(values ...float64) Seq {
return Seq{NewArray(values...)}
}
// Sequence is a provider for values for a seq.
type Sequence interface {
Len() int
GetValue(int) float64
}
// Seq is a utility wrappe... | seq.go | 0.911156 | 0.511595 | seq.go | starcoder |
package crawl
import "github.com/cdipaolo/sentiment"
// SentimentAnalyzer defines an interface for retrieving the sentiment score of a tweet.
type SentimentAnalyzer interface {
GetScoreForTweet(tweet string) int32
}
type simpleSentimentAnalyzer struct {
model sentiment.Models
}
func calculateSentimentScore(analys... | crawl/sentiment.go | 0.808105 | 0.425605 | sentiment.go | starcoder |
package consentconstants
import base "github.com/aclrys/go-gdpr/consentconstants"
// TCF 2.0 Purposes:
const (
// InfoStorageAccess includes the storage of information, or access to information that is already stored,
// on your device such as advertising identifiers, device identifiers, cookies, and similar techno... | consentconstants/tcf2/purposes.go | 0.597843 | 0.554953 | purposes.go | starcoder |
package sys
import "tools/sysdec"
var GPIO = &sysdec.PeripheralDef{
Version: 1,
Description: `There are 54 general-purpose I/O (GPIO) lines split into
two banks. All GPIO pins have at least two alternative functions within BCM.
The alternate functions are usually peripheral IO and a single peripheral may
appear ... | src/tools/sysdec/sys/bcm-2837-gpio.go | 0.500244 | 0.621397 | bcm-2837-gpio.go | starcoder |
package iso20022
// Set of key elements of the original transaction being referred to.
type OriginalTransactionReference1 struct {
// Amount of money moved between the instructing agent and the instructed agent.
InterbankSettlementAmount *CurrencyAndAmount `xml:"IntrBkSttlmAmt,omitempty"`
// Amount of money to be... | OriginalTransactionReference1.go | 0.755457 | 0.544256 | OriginalTransactionReference1.go | starcoder |
package graphics
import (
"fmt"
"github.com/go-gl/gl/v4.6-core/gl"
"github.com/mokiat/gomath/sprec"
"github.com/mokiat/lacking/framework/opengl"
"github.com/mokiat/lacking/framework/opengl/game/graphics/internal"
"github.com/mokiat/lacking/game/graphics"
)
func NewEngine() *Engine {
return &Engine{
rendere... | framework/opengl/game/graphics/engine.go | 0.622345 | 0.417628 | engine.go | starcoder |
package bytes
import (
"math"
)
// SimpleBuilder builds a "sparse" array of replacement mappings based on the indexes that were added to it.
// The array will be from 0 to the maximum index given.
// All non-set indexes will contain nil (so it's not really a sparse array, just a pseudo sparse array).
type SimpleBuil... | escape/bytes/simplebuilder.go | 0.820218 | 0.47926 | simplebuilder.go | starcoder |
package graph
import (
"errors"
)
type tState int
const (
stateNew = iota
stateOpen
stateClosed
)
// NodeProvider is the interface between the vertices stored in the graph
// and various graph functions.
// This interface enables the consumers of graph functions to adopt their
// data structures for graph relat... | graph/top_sort.go | 0.805403 | 0.461502 | top_sort.go | starcoder |
package difference_digest
import (
"database/sql"
"fmt"
"math"
)
const (
stratumCount = 64
cellsCount = 80
)
// StrataEstimator is a data structure used to estimate the number of differences between 2 sets probablistically
type StrataEstimator struct {
Stratum []InvertibleBloomFilter
}
// NewStrataEstimator... | strata_estimator.go | 0.738198 | 0.517327 | strata_estimator.go | starcoder |
package goel
import (
"context"
"github.com/pkg/errors"
"go/ast"
"reflect"
)
type sliceCompiledExpression struct {
nopExpression
sliceExp *ast.SliceExpr
xexp, hexp, lexp, mexp compiledExpression
returnType reflect.Type
slice3 bool
}
func (sce *sliceCompiledExpressio... | slice.go | 0.538498 | 0.404184 | slice.go | starcoder |
package match
import (
"bytes"
"errors"
"fmt"
"unicode"
"github.com/gdey/ppc/parse"
)
// AnyRune will match one rune
func AnyRune() parse.Parser {
return Rune(func(_ rune) bool { return true }, errors.New("unable to match letter"))
}
// Digit matches one unicode digit
// result is a rune
func Digit() parse.Pa... | parse/match/match.go | 0.627609 | 0.468061 | match.go | starcoder |
package factory
import (
"github.com/Yiling-J/carrier/examples/ent_recipe/ent"
"context"
)
type EntIngredientMutator struct {
Name string
_creator *ent.IngredientCreate
}
func (m *EntIngredientMutator) EntCreator() *ent.IngredientCreate {
return m._creator
}
type entIngredientMutation struct {
nameType int
... | examples/ent_recipe/carrier/factory/ent_ingredient.go | 0.529263 | 0.462352 | ent_ingredient.go | starcoder |
package assert
import (
"errors"
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
)
// ErrInvalid is value invalid for operation
var ErrInvalid = errors.New("value if invalid")
// ErrLess is expect to be greater error
var ErrLess = errors.New("left is less the right")
// ErrGreater is expect to be less error
var ... | terraform/terraform/vendor/github.com/likexian/gokit/assert/values.go | 0.692642 | 0.476336 | values.go | starcoder |
package main
/*
In any comparison, the first operand must be assignable to the type of the second operand, or vice versa.
The equality operators == and != apply to operands that are comparable. The ordering operators <, <=, >, and >= apply
to operands that are ordered. These terms and the result of the comparisons ar... | go/projects/effective-go/comparision/doc.go | 0.763484 | 0.869991 | doc.go | starcoder |
package proximityhash
import (
"github.com/mmcloughlin/geohash"
)
func checkCircleIntersectsRectangleGeometrically(radius float64, center point, rect geohash.Box) bool {
nw := point{rect.MaxLat, rect.MinLng}
ne := point{rect.MaxLat, rect.MaxLng}
se := point{rect.MinLat, rect.MaxLng}
sw := point{rect.MinLat, rect... | proximityhash.go | 0.818628 | 0.437403 | proximityhash.go | starcoder |
package sort
/*
Source: https://en.wikipedia.org/wiki/Merge_sort
- Top-down implementation using lists
*/
//MergeSort -- Merge sort
func MergeSort(list []int) []int {
//Base Case: A list of zero or one elements is sorted
if len(list) <= 1 {
return list
}
//Recusive Case:
//First, divide the list into equal-si... | data_structures/sorting/mergesort.go | 0.801742 | 0.526282 | mergesort.go | starcoder |
package mki3d
/* data structures */
// 3D vector in MKI3D - represents coordinates and RGB colors
type Vector3dType [3]float32
// 3x3 Matrix in MKI3D - represents linear transformation
type Matrix3dType [3]Vector3dType
// Endpoint contains Position, Color, and Set index
type EndpointType struct {
Position Vector3d... | mki3d/data.go | 0.72594 | 0.612397 | data.go | starcoder |
package basematchers
import (
"fmt"
"math"
"strings"
)
// The following block enumerates numeric comparator prefixes.
const (
LessThanOrEqualTo = "<="
GreaterThanOrEqualTo = ">="
LessThan = "<"
GreaterThan = ">"
)
func intComparator(cmp string) (func(a, b int64) bool, error) {
switch ... | pkg/search/predicate/basematchers/comparator.go | 0.748076 | 0.496582 | comparator.go | starcoder |
package stream
import (
"fmt"
"reflect"
"github.com/google/gapid/core/data/protoutil"
)
var (
// U1 represents a 1-bit unsigned integer.
U1 = DataType{Signed: false, Kind: &DataType_Integer{&Integer{1}}}
// U2 represents a 2-bit unsigned integer.
U2 = DataType{Signed: false, Kind: &DataType_Integer{&Integer... | core/stream/datatype.go | 0.652463 | 0.771865 | datatype.go | starcoder |
package metrics
import (
"bytes"
"fmt"
"math/rand"
"runtime"
"strconv"
"sync"
"time"
)
type Client interface {
// Close closes the connection and cleans up.
Close() error
// Increments a statsd count type.
// stat is a string name for the metric.
// value is the integer value
// rate is the sample rat... | vendor/github.com/mailgun/metrics/client.go | 0.73678 | 0.402539 | client.go | starcoder |
package structure
import (
"regexp"
"time"
)
type Validatable interface {
Validate(validator Validator)
}
type Validator interface {
OriginReporter
SourceReporter
MetaReporter
ErrorReporter
Validate(validatable Validatable) error
Bool(reference string, value *bool) Bool
Float64(reference string, value *... | structure/validator.go | 0.654343 | 0.42674 | validator.go | starcoder |
package logger
import (
"bytes"
"context"
"fmt"
"io"
"os"
"sync"
"time"
"github.com/edoger/zkits-logger/internal"
)
// Log interface defines an extensible log.
type Log interface {
// Name returns the logger name.
Name() string
// WithField adds the given extended data to the log.
WithField(string, int... | log.go | 0.573917 | 0.445891 | log.go | starcoder |
package MathLibGO
type constantMathValues struct {
pi float64
goldDivision float64
}
func GoldDivision() float64 {
constantMathValues := constantMathValues{}
constantMathValues.goldDivision = 1.618033988749894848204586834366
return constantMathValues.goldDivision
}
func PI() float64 {
constantMathVal... | MathLibGO/libMainFile.go | 0.878679 | 0.515376 | libMainFile.go | starcoder |
package serve
import (
"math"
"sort"
)
//NearestObstacle() returns a integer corresponding to the stick that is nearest to the ball at that moment.
func (ball *ball) NearestObstacle(c1 chan int) {
distance := [8]int32{61, 136, 211, 286, 361, 436, 511, 586}
i := sort.Search(len(distance), func(i int) bool { retur... | src/server/collision.go | 0.724773 | 0.410047 | collision.go | starcoder |
package List
import (
coll "github.com/wushilin/gojava/Collection"
)
// Defines requirement for a list
type List[T any] interface {
// List must be a collection
coll.Collection[T]
//Add an element at specific location. It moves the element at the current location to the right
// [1,2,3,4,5].AddAt(0, 12) => [12,... | List/List.go | 0.724481 | 0.59305 | List.go | starcoder |
package ecschnorr
import (
"math/big"
"github.com/emmyzkp/crypto/common"
"github.com/emmyzkp/crypto/ec"
)
// BlindedTrans represents a blinded transcript.
type BlindedTrans struct {
Alpha_1 *big.Int
Alpha_2 *big.Int
Beta_1 *big.Int
Beta_2 *big.Int
Hash *big.Int
ZAlpha *big.Int
}
func NewBlindedTrans(... | ecschnorr/dlog_equality_bt.go | 0.707405 | 0.463323 | dlog_equality_bt.go | starcoder |
package faceutil
import (
"image"
"image/color"
"image/draw"
"math"
)
type ByCenterY []image.Rectangle
func (b ByCenterY) Len() int {
return len(b)
}
func (b ByCenterY) Swap(i, j int) {
b[i], b[j] = b[j], b[i]
}
func (b ByCenterY) Less(i, j int) bool {
var (
p1 = getRectCenter(b[i])
p2 = getRectCenter(b... | faceutil/utils.go | 0.707809 | 0.422505 | utils.go | starcoder |
package binpack
type Axis int
const (
AxisX Axis = iota
AxisY
AxisZ
)
type Item struct {
ID int
Score int
Size Vector
}
type Box struct {
Origin Vector
Size Vector
}
func (box Box) Cut(axis Axis, offset int) (Box, Box) {
o1 := box.Origin
o2 := box.Origin
s1 := box.Size
s2 := box.Size
switch axis... | binpack/pack.go | 0.544317 | 0.475179 | pack.go | starcoder |
package commands
import (
"f1-discord-bot/ergast"
"fmt"
)
// Results performs the actions for the "results" command sent to the bot
func Results(args ...string) (string, error) {
if len(args) < 1 {
return "", fmt.Errorf("command 'results' needs more arguments")
}
subCommand := args[0]
switch subCommand {
... | commands/results.go | 0.688573 | 0.403009 | results.go | starcoder |
package biome
import (
"image"
"image/color"
"log"
"math"
)
// Gray :
func Gray(imgSrc image.Image) image.Image {
w, h := imgSrc.Bounds().Dx(), imgSrc.Bounds().Dy()
img := image.NewRGBA(image.Rect(0, 0, w, h))
for y := 0; y < h; y++ {
for x := 0; x < w; x++ {
rr, gg, bb, _ := imgSrc.At(x, y).RGBA()
v :... | imgproc.go | 0.543348 | 0.433622 | imgproc.go | starcoder |
package avro
import (
"fmt"
"unsafe"
)
func createSkipDecoder(schema Schema) ValDecoder {
switch schema.Type() {
case Boolean:
return &boolSkipDecoder{}
case Int:
return &intSkipDecoder{}
case Long:
return &longSkipDecoder{}
case Float:
return &floatSkipDecoder{}
case Double:
return &doubleSkipD... | codec_skip.go | 0.596668 | 0.618233 | codec_skip.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/carbon_trading/schemas.go | 0.802633 | 0.700261 | schemas.go | starcoder |
package main
import (
"fmt"
"strings"
)
/**
--- Day 6: Custom Customs ---
As your flight approaches the regional airport where you'll switch to a much larger plane, customs declaration forms are distributed to the passengers.
The form asks a series of 26 yes-or-no questions marked a through z. All you need to do ... | day06.go | 0.671686 | 0.583381 | day06.go | starcoder |
package tile3d
import (
"math"
"github.com/flywave/go3d/vec3"
)
const rangeScale16 = 0xffff
const rangeScale8 = 0xff
func computeScale(extent float32, rangeScale uint16) float32 {
if extent == 0 {
return 1
}
return extent
}
func isInRange(qpos uint16, rangeScale uint16) bool {
return qpos >= 0 && qpos < ra... | quantization.go | 0.681091 | 0.627923 | quantization.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/open-farms/inventory/ent/location"
"github.com/open-farms/inventory/ent/vehicle"
)
// Vehicle is the model entity for the Vehicle schema.
type Vehicle struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`... | ent/vehicle.go | 0.663996 | 0.437163 | vehicle.go | starcoder |
package medtronic
import (
"log"
"time"
)
// CarbRatio represents an entry in a carb ratio schedule.
type CarbRatio struct {
Start TimeOfDay
Ratio Ratio
Units CarbUnitsType
}
// Newer pumps store carb ratios as 10x grams/unit or 1000x units/exchange.
// Older pumps store carb ratios as grams/unit or 10x units/e... | carbratios.go | 0.753285 | 0.493409 | carbratios.go | starcoder |
// Package day12 solves AoC 2018 day 12.
package day12
import (
"fmt"
"strings"
"github.com/fis/aoc/glue"
"github.com/fis/aoc/util"
)
func init() {
glue.RegisterSolver(2018, 12, glue.ChunkSolver(solve))
}
const initialPrefix = "initial state: "
func solve(chunks []string) ([]string, error) {
if len(chunks) ... | 2018/day12/day12.go | 0.558809 | 0.415551 | day12.go | starcoder |
// Deep equality test via reflection
package deepequalexplained
import (
"fmt"
"math"
"reflect"
"unsafe"
)
type visit struct {
a1 unsafe.Pointer
a2 unsafe.Pointer
typ reflect.Type
}
func deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, depth int) error {
if !v1.IsValid() || !v2.IsValid() {
... | deepequalexplained.go | 0.501953 | 0.461684 | deepequalexplained.go | starcoder |
package graphic
import (
"github.com/veandco/go-sdl2/img"
"github.com/veandco/go-sdl2/sdl"
)
//Instance position angle and the center of an instance of a sprite
type Instance struct {
destRect sdl.FRect
angle float64
center sdl.FPoint
parentSprite *Sprite
}
//Sprite contains the texture a list... | src/lib/graphic/sprite.go | 0.824921 | 0.550607 | sprite.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// AttributeMapping
type AttributeMapping struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used fo... | models/attribute_mapping.go | 0.869659 | 0.495545 | attribute_mapping.go | starcoder |
package openapi
import (
"encoding/json"
)
// RetentionPolicies struct for RetentionPolicies
type RetentionPolicies struct {
RetentionTimeInMinutes *int32 `json:"retentionTimeInMinutes,omitempty"`
RetentionSizeInMB *int64 `json:"retentionSizeInMB,omitempty"`
}
// NewRetentionPolicies instantiates a new Retention... | openapi/model_retention_policies.go | 0.733261 | 0.560914 | model_retention_policies.go | starcoder |
package sw
import (
"math/big"
"github.com/consensys/gnark/frontend"
"github.com/consensys/gnark/std/algebra/fields"
"github.com/consensys/gurvy/utils"
)
// PairingContext contains useful info about the pairing
type PairingContext struct {
AteLoop uint64 // stores the ate loop
Extension fields.Extension
}
/... | std/algebra/sw/pairing.go | 0.677261 | 0.418281 | pairing.go | starcoder |
package coinmarketcap
const Mapping = `[
{
"coin": 0,
"type": "coin",
"id": 1
},
{
"coin": 2,
"type": "coin",
"id": 2
},
{
"coin": 20000714,
"type": "token",
"token_id": "<KEY>",
"id": 2
},
{
"coin": 7,
... | services/markets/coinmarketcap/mapping.go | 0.587825 | 0.546738 | mapping.go | starcoder |
package geom
import (
"math"
)
var yAxis = Dir{0, 1, 0}
// Mtx handles matrix data and operations
// Column-major (as in math and Direct3D)
// https://fgiesen.wordpress.com/2012/02/12/row-major-vs-column-major-row-vectors-vs-column-vectors/
type Mtx struct {
el [4][4]float64
inv *Mtx
}
// NewMat constructs a ne... | pkg/geom/mtx.go | 0.827967 | 0.549036 | mtx.go | starcoder |
package eaopt
import (
"errors"
"math"
"math/rand"
)
// An oesPoint is a point that belongs to an OES instance.
type oesPoint struct {
x []float64
noise []float64
oes *OES
}
// Evaluate simply returns the value of the point's current position.
func (p *oesPoint) Evaluate() (float64, error) { return p.oes... | oes.go | 0.753829 | 0.541106 | oes.go | starcoder |
package ast
// Packge ast implement the Abstract Syntax Tree that represents the parsed
// source code before being passed on to the interpreter for evaluation.
import (
"bytes"
"fmt"
"strings"
"github.com/prologic/monkey-lang/token"
)
// Node defines an interface for all nodes in the AST.
type Node interface {... | ast/ast.go | 0.862091 | 0.518302 | ast.go | starcoder |
package slices
import (
// "constraints"
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
)
// Sort returns a sorted copy of `v` according to the comparison function
// `less`. The original slice is not modified.
func Sort[T any](v []T, less func(a, b T) bool) []T {
var r = append([]T{}, v...)
slices.Sor... | pkg/slices/ordered.go | 0.838614 | 0.583826 | ordered.go | starcoder |
package input
import (
"context"
"fmt"
"sync"
"sync/atomic"
"time"
"github.com/Jeffail/benthos/v3/lib/bloblang/x/mapping"
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.... | lib/input/bloblang.go | 0.77518 | 0.561395 | bloblang.go | starcoder |
package trie
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"math/big"
)
// ReadVarint reads a variable length number in big endian byte order
func ReadVarint(reader *bytes.Reader) (ret uint64) {
if reader.Len() == 8 {
var num uint64
binary.Read(reader, binary.BigEndian, &num)
ret = uint64(num)
... | vendor/github.com/c3systems/c3-go/trie/util.go | 0.57678 | 0.443359 | util.go | starcoder |
package topic
type source struct {
key string
}
type condAnd struct {
source Expr
targets []Expr
}
type condOr struct {
source Expr
targets []Expr
}
type condNot struct {
source Expr
targets []Expr
}
// And returns Expr
func And(source Expr, targets ...Expr) Expr {
if len(targets) == 0 {
return source... | cond.go | 0.632503 | 0.456591 | cond.go | starcoder |
package utils
import (
"sync"
"github.com/rcrowley/go-metrics"
)
//UniformSample is a metric sample
type UniformSample struct {
count int64
mutex sync.Mutex
reservoirSize int
values []int64
}
// NewUniformSample constructs a new uniform sample with the given reservoir
// size.
func NewU... | utils/metrics_utils.go | 0.800731 | 0.437523 | metrics_utils.go | starcoder |
package runner
import "io"
// Job is the struct that represents a Job to be executed in a Driver. Similar
// to the Runner it has an underlying io.Writer that will have progress of the
// Job execution written to it. Each Job will belong to a Stage, and will be
// executed in the order that Job was added to the Stage... | runner/job.go | 0.663233 | 0.515559 | job.go | starcoder |
package physics
import (
// anonymous import for png decoder
_ "image/png"
"os"
"github.com/hajimehoshi/ebiten/v2"
"github.com/jtbonhomme/asteboids/internal/vector"
)
const (
defaultMaxVelocity float64 = 3.5
)
const (
StarshipAgent string = "starship"
AsteroidAgent string = "asteroid"
RubbleAgent string... | internal/physics/physic.go | 0.617051 | 0.432303 | physic.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.