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 square
// Represents a customer subscription to a subscription plan. For an overview of the `Subscription` type, see [Subscription object](/docs/subscriptions-api/overview#subscription-object-overview).
type Subscription struct {
// The Square-assigned ID of the subscription.
Id string `json:"id,omitempty"`... | square/model_subscription.go | 0.88782 | 0.409575 | model_subscription.go | starcoder |
package blockchain
import (
"time"
"pandora/pkg/pb"
"pandora/pkg/utils/crypto/sha256"
)
// Blockchain
type Blockchain struct {
mc *pb.MasterChain
// last index master block
limb int
}
// New returns new blockchain
func New() *Blockchain {
bc := &Blockchain{limb: 0}
bc.mc = &pb.MasterChain{MasterChain: []*pb... | pkg/blockchain/blockchain.go | 0.676406 | 0.463444 | blockchain.go | starcoder |
package gapbuffer
type GapBuffer struct {
buffer []rune
preGapLen int
postGapLen int
}
// gapStart returns the index at which the gap is starting
func (g *GapBuffer) gapStart() int {
return g.preGapLen
}
// gapLen returns the length of the gap
func (g *GapBuffer) gapLen() int {
return g.postGapStart() - ... | gap-buffer.go | 0.789396 | 0.53959 | gap-buffer.go | starcoder |
package byteconverter
//LittleEndian binary converter
import (
"bytes"
"encoding/binary"
"math"
)
const (
BigEndian = iota
LittleEndian = iota
)
//Converts 4 byte array representation of a float32 back into a float32.
func Read_float32(endian int, bytes []byte) float32 {
var bits = uint32(0)
if endian == ... | byteconverter-univ.go | 0.797714 | 0.501892 | byteconverter-univ.go | starcoder |
package variance
import (
"math"
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/ring"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/encoding"
"git... | pkg/container/ring/variance/variance.go | 0.581778 | 0.42054 | variance.go | starcoder |
package raytracer
import (
"math"
"math/rand"
"fmt"
"time"
)
func SeedRandom() {
rand.Seed(time.Now().UTC().UnixNano())
}
func RandomFloat64() float64 {
return rand.Float64()
}
func RandomFloat64Range(min float64, max float64) float64 {
return min + rand.Float64() * (max - min)
}
... | raytracer/utility.go | 0.716119 | 0.459622 | utility.go | starcoder |
package data
// Get returns the data as a json string
func Get() string {
return `
{
"Instagram": {
"url": "https://www.instagram.com/{}",
"errorType": "status_code"
},
"Twitter": {
"url": "https://www.twitter.com/{}",
"errorType": "status_code"
},
"Facebook": {
"url": "https://www.facebook.com/{}",
... | data/data.go | 0.607547 | 0.64919 | data.go | starcoder |
package global
import (
"bytes"
"fmt"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed"
"image"
"image/color"
_ "image/jpeg"
_ "image/png"
"io"
)
// https://github.com/xrlin/AsciiArt
func Convert(f io.Reader, chars []string, subWidth, subHeight int, imageSwitch b... | global/art.go | 0.698844 | 0.436442 | art.go | starcoder |
package igloo
// Transform holds all data associated to a location
type Transform struct {
position Vec2
rotation float64
isDirty bool
}
// IsDirty returns whether or not we have changed since the last update
func (t *Transform) IsDirty() bool {
return t.isDirty
}
// Clean will clean up the dirty status back to... | transform.go | 0.877791 | 0.670416 | transform.go | starcoder |
package main
import "fmt"
//ArraySize is the size of the hash table array
const ArraySize = 7
// HashTable will hold an array
type HashTable struct {
array [ArraySize]*bucket
}
// bucket is a linked list in each slot of the hash table array
type bucket struct {
head *bucketNode
}
// bucketNode is a linked list n... | Go/Data-Structures/hash-table/main.go | 0.641984 | 0.422624 | main.go | starcoder |
package gomel
import "gitlab.com/alephledger/core-go/pkg/core"
// Preunit defines the most general interface for units. It describes unit "in a vacuum", without references to its parents.
type Preunit interface {
// EpochID is used a unique identifier of a set of creators who participate in creation of a dag to whic... | pkg/gomel/preunit.go | 0.671901 | 0.512815 | preunit.go | starcoder |
package main
import (
"fmt"
"image"
"image/color"
"github.com/fzipp/canvas"
)
type game struct {
started bool
quit bool
score int
round int
size vec2
bricks []brick
paddle paddle
ball ball
}
func newGame(size vec2) *game {
g := &game{size: size}
g.resetGame()
return g
}
func (g *game... | example/breakout/game.go | 0.55254 | 0.421671 | game.go | starcoder |
package schemalang
// Schema is our internal representation of a schema.
// It should be one of Primitive, Array, Nullable, Fixed, Enum, Record, RecordField.
// It is largely inspired by Avro (see https://avro.apache.org/docs/current/spec.html).
// Notable differences from Avro: a) unions replaced with Nullable, b) th... | pkg/schemalang/schema.go | 0.814717 | 0.512327 | schema.go | starcoder |
package table
import (
"github.com/Connor1996/badger/y"
)
// MergeTowIterator is a specialized MergeIterator that only merge tow iterators.
// It is an optimization for compaction.
type MergeIterator struct {
smaller mergeIteratorChild
bigger mergeIteratorChild
// when the two iterators has the same value, the ... | table/merge_iterator.go | 0.731059 | 0.406332 | merge_iterator.go | starcoder |
// Package area provides functions working with image areas.
package area
import (
"fmt"
"image"
"github.com/mum4k/termdash/internal/numbers"
)
// Size returns the size of the provided area.
func Size(area image.Rectangle) image.Point {
return image.Point{
area.Dx(),
area.Dy(),
}
}
// FromSize returns the... | vendor/github.com/mum4k/termdash/internal/area/area.go | 0.904265 | 0.793866 | area.go | starcoder |
package Euler2D
import (
"fmt"
"math"
"sync"
"syscall"
"time"
"github.com/notargets/gocfd/model_problems/Euler2D/sod_shock_tube"
"github.com/notargets/gocfd/types"
"github.com/notargets/gocfd/DG2D"
"github.com/notargets/gocfd/utils"
"github.com/pkg/profile"
)
/*
In the DFR scheme, we have two sets of ... | model_problems/Euler2D/euler.go | 0.744935 | 0.417093 | euler.go | starcoder |
package main
import (
"image"
"math"
)
type Point64 struct {
X, Y float64
}
func MakePoint64(p image.Point) Point64 {
return Point64{float64(p.X), float64(p.Y)}
}
func (p Point64) Div(q Point64) Point64 {
return Point64{p.X / q.X, p.Y / q.Y}
}
func (p Point64) Mul(q Point64) Point64 {
return Point64{p.X * q.... | geometry.go | 0.870101 | 0.675112 | geometry.go | starcoder |
package types
import (
"io"
"github.com/lyraproj/puppet-evaluator/errors"
"github.com/lyraproj/puppet-evaluator/eval"
"reflect"
)
type OptionalType struct {
typ eval.Type
}
var Optional_Type eval.ObjectType
func init() {
Optional_Type = newObjectType(`Pcore::OptionalType`,
`Pcore::AnyType {
attributes => ... | types/optionaltype.go | 0.710628 | 0.424233 | optionaltype.go | starcoder |
package main
import "math"
const minIntQuotient = math.MinInt32 / 10
const minIntRemainder = math.MinInt32 % 10
const maxIntQuotient = math.MaxInt32 / 10
const maxIntRemainder = math.MaxInt32 % 10
func main() {}
func myAtoi(input string) int {
// Convert input string to slice of runes to make
// indexing easier
... | 8-string-to-integer/p8.go | 0.749087 | 0.506897 | p8.go | starcoder |
package network
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/cio/api/types"
"github.com/ingrammicro/cio/utils"
"github.com/stretchr/testify/assert"
)
// ListLoadBalancersMocked test mocked function
func ListLoadBalancersMocked(t *testing.T, loadBalancersIn []*types.LoadBalancer) []*types.L... | api/network/load_balancers_api_mocked.go | 0.712432 | 0.413477 | load_balancers_api_mocked.go | starcoder |
package plot
import (
"encoding/json"
"fmt"
"io"
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
)
// Canvas describes the canvas on which we'll draw
type Canvas struct {
Size XY
DPI int
Bleed XY
}
// Middle returns the middle point of the canvas
func (p Canvas) Middle() XY {
return XY{X... | pkg/plot/plot.go | 0.785061 | 0.474144 | plot.go | starcoder |
package main
import (
"github.com/ByteArena/box2d"
"github.com/wdevore/RangerGo/api"
"github.com/wdevore/RangerGo/engine/rendering"
)
// CircleSensor is a box
type CircleSensor struct {
visual api.INode
b2Body *box2d.B2Body
scale float64
categoryBits uint16 // I am a...
maskBits uint16 // I can collide ... | examples/physics/intermediate/sensors/circle_sensor.go | 0.735071 | 0.450903 | circle_sensor.go | starcoder |
package convert
import (
"reflect"
)
// NilValue represents a nil value to convert (from/to)
type NilValue struct {
reflect.Value
}
// MapValue represents a map value to convert (from/to)
type MapValue struct {
reflect.Value
}
// StructValue represents a struct value to convert (from/to)
type StructValue struct ... | vendor/github.com/Eun/go-convert/converter.go | 0.708313 | 0.524699 | converter.go | starcoder |
package jet
// TimestampExpression interface
type TimestampExpression interface {
Expression
EQ(rhs TimestampExpression) BoolExpression
NOT_EQ(rhs TimestampExpression) BoolExpression
IS_DISTINCT_FROM(rhs TimestampExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs TimestampExpression) BoolExpression
LT(rhs Tim... | internal/jet/timestamp_expression.go | 0.801081 | 0.523968 | timestamp_expression.go | starcoder |
package interpreter
import (
"fmt"
"github.com/smackem/ylang/internal/lang"
"image"
"math"
"reflect"
)
type Point image.Point
func (p Point) Compare(other Value) (Value, error) {
if r, ok := other.(Point); ok {
if p == r {
return Number(0), nil
}
}
return nil, nil
}
func (p Point) Add(other Value) (V... | internal/interpreter/point.go | 0.793026 | 0.584508 | point.go | starcoder |
package box2d
// Find the max separation between poly1 and poly2 using edge normals from poly1.
func B2FindMaxSeparation(edgeIndex *int, poly1 *B2PolygonShape, xf1 B2Transform, poly2 *B2PolygonShape, xf2 B2Transform) float64 {
count1 := poly1.M_count
count2 := poly2.M_count
n1s := poly1.M_normals
v1s := poly1.M_ve... | CollisionB2CollidePolygon.go | 0.744842 | 0.805861 | CollisionB2CollidePolygon.go | starcoder |
package jsonpath
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"reflect"
regex "regexp"
"strings"
"github.com/PaesslerAG/jsonpath"
"github.com/steinfletcher/apitest"
)
// Contains is a convenience function to assert that a jsonpath expression extracts a value in an array
fun... | vendor/github.com/steinfletcher/apitest-jsonpath/jsonpath.go | 0.582372 | 0.427636 | jsonpath.go | starcoder |
package genlsystem
func Hilbert3d(fname string, n int) error {
path := Lindenmayer([]string{"X"}, map[string][]string{
"X": {"^", "<", "X", "F", "^", "<", "X", "F", "X", "-", "F", "^", ">", ">", "X", "F", "X", "&", "F", "+", ">", ">", "X", "F", "X", "-", "F", ">", "X", "-", ">"},
}, n)
turtle := NewTurtle3d(map[... | genlsystem/turtlesamples3d.go | 0.570212 | 0.668224 | turtlesamples3d.go | starcoder |
package generator
func (g *Grid) skLoops(verbose uint) (res bool) {
solved := make(map[point]bool)
for r := zero; r < rows; r++ {
for c := zero; c < cols; c++ {
if bitCount[g.cells[r][c]] == 1 {
solved[point{r, c}] = true
}
}
}
rectangles := make(map[[4]point]bool)
for p1 := range solved {
for p2... | generator/skLoops.go | 0.666497 | 0.517083 | skLoops.go | starcoder |
package bitmap
import (
"sync/atomic"
"unsafe"
)
var oobPanic = "SetAtomic not allowed on a bitmapSlice of cap() < 4"
// SetAtomic is similar to Set except that it performs the operation atomically.
func SetAtomic(bitmap []byte, targetBit int, targetValue bool) {
ov := (*[1]uint32)(unsafe.Pointer(&bitmap[targetBi... | atomic.go | 0.723114 | 0.466603 | atomic.go | starcoder |
package taxreturn
import (
"fmt"
"strings"
)
// Bill describes a bill for a period of time.
type Bill struct {
Period BillPeriod
Due float32
Paid float32
}
// PaidDaily shows an average payment amount per day.
func (b Bill) PaidDaily() float32 {
days := b.Period.Days()
return b.Paid / float32(days)
}
//... | bill.go | 0.767167 | 0.519643 | bill.go | starcoder |
package comm
import (
"fmt"
"time"
)
// Day, week, month, quarter, year duration on nanosecond
const (
Day = time.Hour * 24
Week = Day * 7
Month = Day * 30
Quarter = Month * 3
Year = Day * 365
)
// Day, week, month, quarter, year duration on millisecond
const (
DayMs = Day / time.Millisecond... | comm/times.go | 0.72594 | 0.409693 | times.go | starcoder |
package stnccollection
import (
"strconv"
)
//FloatToString float 2 string
func FloatToString(inputNum float64) string {
// to convert a float number to a string
return strconv.FormatFloat(inputNum, 'f', 10, 64)
}
//StringToFloat to convert a float number to a string
func StringToFloat(str string) (returnData fl... | app/domain/helpers/stnccollection/conventor.go | 0.59302 | 0.466481 | conventor.go | starcoder |
package timecalc
import (
"math"
"time"
)
type FullDate struct {
*time.Time
}
type DateDiff struct {
Years int
Months int
Days int
}
type Duration struct {
Years int
Months int
Days int
IsFinished bool
Error error
}
// Age returns the number of years, months, and days passed at th... | full_date.go | 0.804713 | 0.458531 | full_date.go | starcoder |
package add
import (
"fmt"
"github.com/knutsonchris/stackilackey/cmd"
)
type storage struct {
}
/*
Controller will add a global storage controller configuration for all the hosts in the cluster.
Parameters
{arrayid=string}
The 'arrayid' is used to determine which disks are grouped as part
of the same array. ... | add/storage.go | 0.756268 | 0.479016 | storage.go | starcoder |
package structs
import (
"errors"
"fmt"
"math"
"math/big"
"strings"
)
var (
tenInt = big.NewInt(10)
)
func (t *TransactionAmount) GetFloat() *big.Float {
divider := new(big.Int).Exp(tenInt, big.NewInt(int64(t.Exp)), nil)
dvdr := new(big.Float).SetInt(divider)
value := new(big.Float).SetInt(t.Numeric)
value... | structs/utils.go | 0.503906 | 0.411052 | utils.go | starcoder |
// Package values implements various gNMI value manipulation facilities.
package values
import (
"fmt"
"github.com/onosproject/onos-config/pkg/store/change"
pb "github.com/openconfig/gnmi/proto/gnmi"
)
// GnmiTypedValueToNativeType converts gnmi type based values in to native byte array types
func GnmiTypedValueT... | pkg/utils/values/gnmiValueUtil.go | 0.61231 | 0.480113 | gnmiValueUtil.go | starcoder |
package imageutils
import (
"image"
"image/color"
"log"
"github.com/telecoda/go-saic/db"
"github.com/telecoda/go-saic/models"
)
func CreateImageMosaic(inputImagePath string, outputImagePath string, outputImageWidth int, tileSize int, mosaicType string) error {
log.Println("input_image_path:", inputImagePath)
... | imageutils/mosaic.go | 0.685529 | 0.466359 | mosaic.go | starcoder |
package kinase
// CaParams has rate constants for integrating spike-driven Ca calcium
// at different time scales, including final CaP = CaMKII and CaD = DAPK1
// timescales for LTP potentiation vs. LTD depression factors.
type CaParams struct {
Rule Rules `desc:"selects the specific variant of the Kinase learn... | kinase/params.go | 0.812123 | 0.711443 | params.go | starcoder |
package graphblas
import (
"log"
"reflect"
"context"
"github.com/rossmerr/graphblas/constraints"
)
func init() {
RegisterMatrix(reflect.TypeOf((*CSCMatrix[float64])(nil)).Elem())
}
// CSCMatrix compressed storage by columns (CSC)
type CSCMatrix[T constraints.Number] struct {
r int // number of rows i... | cscMatrix.go | 0.798423 | 0.579698 | cscMatrix.go | starcoder |
package components
import (
"github.com/go-gl/mathgl/mgl32"
)
const (
// TypeCamera represents a Camera component's type.
TypeCamera = "Camera"
)
// Camera represents the behaviors of any camera.
type Camera interface {
// SetView sets the view matrix.
SetView(camEye, camLookAt, camUp [3]float32)
// SetProject... | components/camera.go | 0.879781 | 0.71282 | camera.go | starcoder |
package iso20022
// Details about the investment fund class.
type InvestmentFund1 struct {
// Identification of the investment fund or investment fund class.
FinancialInstrumentIdentification *SecurityIdentification14 `xml:"FinInstrmId,omitempty"`
// Features of units offered by a fund. For example, a unit may ha... | InvestmentFund1.go | 0.822011 | 0.425247 | InvestmentFund1.go | starcoder |
package histogram
import (
"github.com/Ernyoke/Imger/utils"
"image"
"image/color"
)
const hsize = 256
const channels = 3
// HistogramGray computes the histogram for a grayscale image. Returns an array of 256 uint64 values containing
// distribution of the pixel values.
func HistogramGray(img *image.Gray) [hsize]u... | histogram/histogram.go | 0.872239 | 0.789112 | histogram.go | starcoder |
Package guid implements interface to generate k-ordered unique identifiers in
lock-free and decentralized manner for Golang applications. We says that
sequence A is k-ordered if it consists of strictly ordered subsequences of
length k:
𝑨[𝒊 − 𝒌] ≤ 𝑨[𝒊] ≤ 𝑨[𝒊 + 𝒌] for all 𝒊 such that 𝒌 < 𝒊 ≤ 𝒏−𝒌.
Key fe... | doc.go | 0.909088 | 0.838548 | doc.go | starcoder |
package astcmp
import (
"fmt"
"reflect"
"github.com/albrow/fo/ast"
)
// A Mode value is a set of flags (or 0). They control how nodes are compared.
type Mode uint
const (
// IgnorePos means that position information will be ignored and two nodes
// will be considered equal even if they have different positions... | astcmp/compare.go | 0.557845 | 0.605741 | compare.go | starcoder |
package vec
import (
"github.com/chewxy/math32"
"github.com/itohio/EasyRobot/pkg/core/math"
)
type Vector []float32
func New(size int) Vector {
return make(Vector, size)
}
func NewFrom(v ...float32) Vector {
return v[:]
}
func (v Vector) Sum() float32 {
var sum float32
for _, val := range v {
sum += val
... | pkg/core/math/vec/vec.go | 0.805096 | 0.588121 | vec.go | starcoder |
package ilium
import "math/rand"
type Sample1D struct {
U float32
}
type Sample2D struct {
U1, U2 float32
}
type Sample1DArray []Sample1D
type Sample2DArray []Sample2D
func (sample1DArray Sample1DArray) GetSample(i int, rng *rand.Rand) Sample1D {
if i < len(sample1DArray) {
return sample1DArray[i]
}
return... | ilium/sampler.go | 0.630457 | 0.421016 | sampler.go | starcoder |
package curve
import (
"encoding/csv"
"errors"
"fmt"
"io"
"math"
"os"
"strconv"
"github.com/csweichel/go-pen/pkg/plot"
"github.com/sirupsen/logrus"
)
type Opts struct {
Size plot.XY
Center plot.XY
}
// Continuous samples a continuous function and draws it within the bounding box
func Continuous(f func(... | pkg/curve/curve.go | 0.656218 | 0.401629 | curve.go | starcoder |
package brotli
const fastOnePassCompressionQuality = 0
const fastTwoPassCompressionQuality = 1
const zopflificationQuality = 10
const hqZopflificationQuality = 11
const maxQualityForStaticEntropyCodes = 2
const minQualityForBlockSplit = 4
const minQualityForNonzeroDistanceParams = 4
const minQualityForOptimizeH... | vendor/github.com/andybalholm/brotli/quality.go | 0.636014 | 0.4881 | quality.go | starcoder |
package mag
import (
"fmt"
d "github.com/mumax/3/data"
"github.com/mumax/3/util"
"math"
)
// Kernel for the vertical derivative of the force on an MFM tip due to mx, my, mz.
// This is the 2nd derivative of the energy w.r.t. z.
func MFMKernel(mesh *d.Mesh, lift, tipsize float64) (kernel [3]*d.Slice) {
const Tip... | mag/mfmkernel.go | 0.583678 | 0.636946 | mfmkernel.go | starcoder |
package timestamp
import (
"bytes"
"encoding/hex"
"fmt"
"github.com/edouardparis/ancre/attestation"
"github.com/edouardparis/ancre/operation"
)
const RECURSION_LIMIT = 256
type StepData interface {
Match(int) bool
Exec([]byte) []byte
}
type Step struct {
Data StepData
Output []byte
Next []*Step
}
fu... | timestamp/timestamp.go | 0.639061 | 0.433981 | timestamp.go | starcoder |
package client
import (
"encoding/json"
)
// SummaryStatistics struct for SummaryStatistics
type SummaryStatistics struct {
AlarmsCount int32 `json:"alarmsCount"`
AlarmsCountChangesTrend SummaryChangesTrends `json:"alarmsCountChangesTrend"`
InstancesCount int32 `json:"instancesCount"`
InstancesCountChangesTrend... | client/model_summary_statistics.go | 0.860105 | 0.41561 | model_summary_statistics.go | starcoder |
package api
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderServerPage() string {
return RenderHtml("Using server", Render(serverBody, nil))
}
const serverBody = `
<h2>Using servers</h2>
<p>As we explain in the <a href="api.html">system abstraction</a> section, the
first level of anch... | gocircuit.org/api/server.go | 0.726231 | 0.644596 | server.go | starcoder |
package exp
import (
"github.com/mb0/xelf/bfr"
"github.com/mb0/xelf/cor"
"github.com/mb0/xelf/lex"
"github.com/mb0/xelf/lit"
"github.com/mb0/xelf/typ"
)
// El is the common interface of all language elements.
type El interface {
// WriteBfr writes the element to a bfr.Ctx.
WriteBfr(*bfr.Ctx) error
// String r... | exp/exp.go | 0.601477 | 0.405096 | exp.go | starcoder |
package fields
import (
"fmt"
"sort"
"strings"
"github.com/contiv/client-go/pkg/selection"
)
// Selector represents a field selector.
type Selector interface {
// Matches returns true if this selector matches the given set of fields.
Matches(Fields) bool
// Empty returns true if this selector does not restri... | pkg/fields/selector.go | 0.743634 | 0.470858 | selector.go | starcoder |
package main
import (
"strings"
"code.rocketnine.space/tslocum/cview"
"github.com/gdamore/tcell/v2"
)
const treeAllCode = `[green]package[white] main
[green]import[white] [red]"code.rocketnine.space/tslocum/cview"[white]
[green]func[white] [yellow]main[white]() {
$$$
root := cview.[yellow]NewTreeNode[white](... | demos/presentation/treeview.go | 0.58818 | 0.434641 | treeview.go | starcoder |
package dists
/*
Created using
https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)
*/
import (
"math"
"math/rand"
"github.com/deathly809/gomath"
"github.com/deathly809/gostats"
)
// Uniform holds all information about the distribution
type Uniform struct {
a, b float64
pdf ... | dists/uniform.go | 0.832237 | 0.504761 | uniform.go | starcoder |
package game
import (
"errors"
"math"
"reflect"
"sort"
"time"
)
type Node struct {
Cost int
Heuristic int
Grid Grid
Moves []Coords
}
const SUGGEST_DURATION time.Duration = 1
func CountMisplacedTiles(grid Grid, grid2 Grid) int {
sum := 0
size := len(grid)
y := 0
for y < size {
x := 0
f... | src/game/suggest.go | 0.712132 | 0.494751 | suggest.go | starcoder |
package arts
import (
"math"
"math/rand"
"github.com/andrewwatson/generativeart"
"github.com/andrewwatson/generativeart/common"
"github.com/fogleman/gg"
)
type circle struct {
x, y float64
radius float64
dx, dy float64
}
type randCircle struct {
maxCircle int
maxStepsPerCircle int
minSteps ... | arts/randcircle.go | 0.664976 | 0.436922 | randcircle.go | starcoder |
package types
import (
"math"
"time"
"github.com/pingcap/tidb/util/collate"
)
// CompareInt64 returns an integer comparing the int64 x to y.
func CompareInt64(x, y int64) int {
if x < y {
return -1
} else if x == y {
return 0
}
return 1
}
// CompareUint64 returns an integer comparing the uint64 x to y.... | types/compare.go | 0.714827 | 0.549097 | compare.go | starcoder |
package graphic
import (
"github.com/g3n/engine/core"
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/gls"
"github.com/g3n/engine/material"
"github.com/g3n/engine/math32"
)
// Lines is a Graphic which is rendered as a collection of independent lines.
type Lines struct {
Graphic // Embedded ... | graphic/lines.go | 0.81538 | 0.460592 | lines.go | starcoder |
package query
// Select starts a new query builder with some selected columns
func Select(columnNames ...string) Builder {
return (Builder{}).Select(columnNames...)
}
// Select add column names (string) to the select clause
func (b Builder) Select(columnNames ...string) Builder {
for _, name := range columnNames {... | query.go | 0.842053 | 0.482002 | query.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security transfer.
type Transfer15 struct {
// Unique and unambiguous identifier for a transfer instruction, as assigned by the instructing party.
TransferReference *Max35Text `xml:"TrfRef"`
// Unique and unambiguous investor's identification of a tran... | data/train/go/8de71f2520d7c98fb58b4ba8e5c29991a6e7a040Transfer15.go | 0.816077 | 0.414366 | 8de71f2520d7c98fb58b4ba8e5c29991a6e7a040Transfer15.go | starcoder |
package datadog
import (
"encoding/json"
)
// DistributionWidgetXAxis X Axis controls for the distribution widget.
type DistributionWidgetXAxis struct {
// True includes zero.
IncludeZero *bool `json:"include_zero,omitempty"`
// Specifies maximum value to show on the x-axis. It takes a number, percentile (p90 ==... | api/v1/datadog/model_distribution_widget_x_axis.go | 0.792143 | 0.449695 | model_distribution_widget_x_axis.go | starcoder |
package trending
import (
"sort"
"time"
timeseries "github.com/codesuki/go-time-series"
"github.com/codesuki/go-trending/slidingwindow"
)
// Algorithm:
// 1. Divide one week into 5 minutes bins
// The algorithm uses expected probability to compute its ranking.
// By choosing a one week span to compute the expect... | trending.go | 0.797439 | 0.649995 | trending.go | starcoder |
package sample
import (
"crypto/rand"
"math"
"math/big"
"github.com/pkg/errors"
)
// NormalNegative samples random values from the possible
// outputs of Normal (Gaussian) probability distribution centered on 0 and
// accepts or denies each sample with probability defined by the distribution
type NormalNegative ... | sample/normal_negative.go | 0.688154 | 0.459561 | normal_negative.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// UserTrainingEventInfo
type UserTrainingEventInfo struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can ... | models/user_training_event_info.go | 0.594198 | 0.401101 | user_training_event_info.go | starcoder |
package datadog
import (
"encoding/json"
)
// SyntheticsTiming Object containing all metrics and their values collected for a Synthetic API test. Learn more about those metrics in [Synthetics documentation](https://docs.datadoghq.com/synthetics/#metrics).
type SyntheticsTiming struct {
// The duration in milliseco... | api/v1/datadog/model_synthetics_timing.go | 0.81257 | 0.505737 | model_synthetics_timing.go | starcoder |
package tensor
import "github.com/pkg/errors"
// this file handles matops. While by default most of these matops should already have been defined as part of the
// Tensor interface, not all are possible(for example, concatenating a sparse tensor), hence the need for the following functions
// Repeat repeats a Tensor... | api_matop.go | 0.859693 | 0.693376 | api_matop.go | starcoder |
package layer
import (
"github.com/rubenwo/cnn-go/pkg/cnn/maths"
)
type FullyConnectedLayer struct {
weights maths.Tensor
biases []float64
inputDims []int
outputDims []int
recentOutput []float64
recentInput maths.Tensor
}
func NewFullyConnectedLayer(outputLength int, inputDims []int) *FullyConnectedLayer... | pkg/cnn/layer/fullyconnected.go | 0.714528 | 0.48688 | fullyconnected.go | starcoder |
package ms
import (
"encoding/binary"
"fmt"
)
func getNibble(word []byte, index int) uint8 {
b := word[index/4] //Which byte we want from within the word (4 bytes per word)
var res uint8 //value
i := index % 4 //which nibble we want from within the byte (4 ni... | vendor/github.com/GeoNet/kit/seis/ms/steim.go | 0.595257 | 0.41401 | steim.go | starcoder |
package common
import "github.com/DrJosh9000/awakengine"
const (
munroHeight = 11
munroYOffset = -2
)
var (
munroMap = map[byte]awakengine.CharInfo{
' ': {Width: 0, X: 1, Y: 9, XOffset: 0, Height: 0, YOffset: 11, XAdvance: 3},
'!': {Width: 1, X: 2, Y: 2, XOffset: 0, Height: 7, YOffset: 4, XAdvance: 2},
... | common/munro.go | 0.628065 | 0.666985 | munro.go | starcoder |
package clip
import (
"fmt"
"strings"
)
// Point is a 2-d point.
type Point struct {
X, Y float64
}
func (p Point) add(d Point) Point {
return Point{p.X + d.X, p.Y + d.Y}
}
func (p Point) sub(d Point) Point {
return Point{p.X - d.X, p.Y - d.Y}
}
func (p Point) mul(g float64) Point {
return Point{p.X * g, p.Y... | types.go | 0.867303 | 0.481271 | types.go | starcoder |
package input
import (
"github.com/benthosdev/benthos/v4/internal/component/input"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/internal/impl/nats/auth"
"github.com/benthosdev/benthos/v4/internal/interop"
"github.... | internal/old/input/nats.go | 0.709221 | 0.536252 | nats.go | starcoder |
package eaopt
import (
"fmt"
"math"
"math/rand"
)
// An Individual wraps a Genome and contains the fitness assigned to the Genome.
type Individual struct {
Genome Genome `json:"genome"`
Fitness float64 `json:"fitness"`
Evaluated bool `json:"-"`
ID string `json:"id"`
}
// NewIndividual returns... | individual.go | 0.747247 | 0.427277 | individual.go | starcoder |
package geogoth
// MultiLineString ...
type MultiLineString struct {
Coords [][][]float64
}
// NewMultiLineString creates MultiLineString
func NewMultiLineString(coords [][][]float64) MultiLineString {
return MultiLineString{
Coords: coords,
}
}
// Coordinates returns array of longitude, latitude of the MultiLi... | multilinestring.go | 0.878757 | 0.438244 | multilinestring.go | starcoder |
package colour
import "fmt"
// Colour represents the colour of a block. Typically, Minecraft blocks have a total of 16 different colours.
type Colour struct {
colour
}
// White returns the white colour.
func White() Colour {
return Colour{colour(0)}
}
// Orange returns the orange colour.
func Orange() Colour {
r... | dragonfly/block/colour/colour.go | 0.894899 | 0.571229 | colour.go | starcoder |
package processor
import (
"fmt"
"time"
"github.com/Jeffail/benthos/v3/internal/bloblang"
"github.com/Jeffail/benthos/v3/internal/bloblang/mapping"
"github.com/Jeffail/benthos/v3/internal/bloblang/parser"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail... | lib/processor/bloblang.go | 0.782081 | 0.690111 | bloblang.go | starcoder |
// Package imgd (image-data) adds functionality to process image-data,
// e.g. for pattern recognition using images.
package imgd
import (
"image"
"image/color"
"math"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/rnd"
"github.com/cpmech/gosl/utl"
)
// GraySample holds sample data corresponding go grays... | ml/imgd/sample.go | 0.780412 | 0.459864 | sample.go | starcoder |
package enums
import "fmt"
// FilterSortDataTypeCategory defines a collection of filter data type categories
type FilterSortDataTypeCategory struct {
FilterSortCategory FilterSortCategoryType
FilterSort []FilterSortDataType
}
// Create a struct with a combined list of counties of sort and filter
var filter... | pkg/mycarehub/application/enums/filter_types_validator.go | 0.672977 | 0.570032 | filter_types_validator.go | starcoder |
package registration
import (
"context"
"encoding/json"
"testing"
"github.com/bxcodec/faker/v3"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zzpu/ums/identity"
"github.com/zzpu/ums/selfservice/form"
"github.com/zzpu/ums/x"
)
type FlowPe... | selfservice/flow/registration/persistence.go | 0.612889 | 0.58062 | persistence.go | starcoder |
package types
import (
"time"
"go.mongodb.org/mongo-driver/bson"
)
const (
// GasPricePeriodTypeSuggestion represents the type of gas price period data from the Photon node suggestion call.
GasPricePeriodTypeSuggestion = iota
)
const (
// FiGasPriceTimeFrom is the name of the starting time stamp column in the ... | internal/types/gas_price.go | 0.674694 | 0.450178 | gas_price.go | starcoder |
package defaults
import (
"encoding/json"
"reflect"
"strings"
"github.com/gravitational/trace"
"github.com/santhosh-tekuri/jsonschema"
)
// Apply applies defaults from schema to the given object v
// which is expected to conform to said schema
func Apply(v interface{}, schema *jsonschema.Schema) error {
if sch... | lib/schema/defaults/defaults.go | 0.649467 | 0.40645 | defaults.go | starcoder |
package windowsupdates
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// RolloutSettings
type RolloutSettings struct {
// Stores additional dat... | models/windowsupdates/rollout_settings.go | 0.680454 | 0.402979 | rollout_settings.go | starcoder |
// Renders a textured spinning cube using GLFW 3 and OpenGL 4.1 core forward-compatible profile.
package main
import (
_ "image/png"
"unsafe"
"github.com/go-gl/gl/v4.6-core/gl"
"github.com/go-gl/glfw/v3.3/glfw"
"github.com/go-gl/mathgl/mgl32"
"github.com/purelazy/modlib/internal/utils"
)
func main() {
// Th... | cmd/Basics/05-Lighting/main.go | 0.775732 | 0.412057 | main.go | starcoder |
package circonus
import (
"github.com/circonus-labs/circonus-gometrics"
"github.com/go-kit/kit/metrics"
)
// Circonus wraps a CirconusMetrics object and provides constructors for each of
// the Go kit metrics. The CirconusMetrics object manages aggregation of
// observations and emission to the Circonus server.
ty... | vendor/github.com/go-kit/kit/metrics/circonus/circonus.go | 0.864654 | 0.577495 | circonus.go | starcoder |
package xconv
import (
"errors"
"reflect"
"strconv"
)
func StringInt(s string) (i int, err error) {
return strconv.Atoi(s)
}
func StringInt64 (s string) (int64, error) {
return strconv.ParseInt(s, 10, 64)
}
func StringFloat64 (s string) (float64, error) {
return strconv.ParseFloat(s, 64)
}
func StringFloat32 (... | string.go | 0.531453 | 0.444746 | string.go | starcoder |
package resolver
import (
"strconv"
"github.com/google/gapid/gapil/ast"
"github.com/google/gapid/gapil/semantic"
)
func inferNumber(rv *resolver, in *ast.Number, infer semantic.Type) semantic.Expression {
var out semantic.Expression
switch infer {
case semantic.Int8Type:
if v, err := strconv.ParseInt(in.Val... | gapil/resolver/inference.go | 0.654784 | 0.494385 | inference.go | starcoder |
package flagday
import (
"errors"
"sort"
"time"
)
var cache = make(map[int][]Holiday)
// InYear returns holiadys in given year.
func InYear(year int) []Holiday {
if dates, ok := cache[year]; ok {
return dates
}
defs := DefsInYear(year)
dates := Holidays(defs, year)
sort.Slice(dates, func(i, j int) bool {
... | flagday.go | 0.659953 | 0.585012 | flagday.go | starcoder |
package integration
import (
"github.com/20kdc/CCUpdaterUI/frenyard"
"encoding/base64"
"image"
"image/png"
"strings"
)
// GoImageToTexture imports an image from Go's "image" library to a texture.
func GoImageToTexture(img image.Image, ct []ColourTransform) frenyard.Texture {
min := img.Bounds().Min
sizePreTran... | frenyard/integration/imaging.go | 0.663342 | 0.440229 | imaging.go | starcoder |
package sliceutil
import (
"fmt"
"reflect"
)
// Diff3 calculates difference between two slices and return three
// new slices: onlyA with items belongs only to A slice, AandB with items common to A and B
// and onlyB with items belongs only to B. A and B must be slices of the same type and
// their items must have ... | diff3.go | 0.569374 | 0.511717 | diff3.go | starcoder |
package maze
import (
"bytes"
"fmt"
"image"
"image/color"
"image/png"
"io"
"math/rand"
"strings"
)
// Maze cell configurations
// The paths of the maze is represented in the binary representation.
const (
Up = 1 << iota
Down
Left
Right
)
// The solution path is represented by (Up|Down|Left|Right) << Solu... | maze.go | 0.776581 | 0.411613 | maze.go | starcoder |
package vegeta
import (
"strconv"
"time"
"github.com/bmizerany/perks/quantile"
)
// Metrics holds the stats computed out of a slice of Results
// that is used for some of the Reporters
type Metrics struct {
Latencies struct {
Mean time.Duration `json:"mean"`
P50 time.Duration `json:"50th"` // P50 is the 50t... | lib/metrics.go | 0.842831 | 0.433142 | metrics.go | starcoder |
package models
import (
"image"
)
// Grid represents the simulation area. It contains Spaces that organisms occupy
// and move through.
type Grid struct {
// Rows is a 2-dimensional array that contains Spaces in the inner-array.
Rows [][]*Space
}
// NewGrid initializes and returns a Grid with the given width and ... | internal/models/grid.go | 0.878184 | 0.726426 | grid.go | starcoder |
package vm
import (
"fmt"
"math"
"strconv"
)
// AddºFloatInt adds float and int
func AddºFloatInt(left float64, right int64) float64 {
return left + float64(right)
}
// AddºIntFloat adds int and float
func AddºIntFloat(left int64, right float64) float64 {
return float64(left) + right
}
// AssignAddºFloatFloat... | vm/float.go | 0.81457 | 0.655584 | float.go | starcoder |
package collection
// using reflect package for manage array data
import (
"encoding/json"
"reflect"
)
// create a type of array with array data
type Collection struct {
Data interface{}
}
// make a new instance from Collection type
func New(data interface{}) *Collection {
return &Collection{data}
}
// check va... | collection.go | 0.728845 | 0.653155 | collection.go | starcoder |
package function
import (
"errors"
"fmt"
"math"
"reflect"
"github.com/golang/geo/s2"
"github.com/mmcloughlin/geohash"
"github.com/gojek/merlin/pkg/transformer/types/converter"
)
const (
earthRadiusKm = 6371 // radius of the earth in kilometers.
pointFive = 0.5
zero = 0
mini... | api/pkg/transformer/symbol/function/geospatial.go | 0.900048 | 0.517571 | geospatial.go | starcoder |
package models
import (
"encoding/binary"
"encoding/hex"
"transactions/utils"
)
//TxIn represents one incoming transaction object
type TxIn struct {
PrevTx string
PrevIndex uint32
ScriptSig Script
Sequence uint32
}
// @dev As seen, the TxIn object has no amount in the struct. How then can we get the amoun... | models/TxIn.go | 0.749729 | 0.425009 | TxIn.go | starcoder |
package optional
// Optional represents an immutable object that may contain a non-nil reference to another object.
// Each instance of this type either contains a non-nil reference, or contains nothing (in which
// case we say thatthe reference is "absent"); it is never said to "contain nil".
type Optional interface ... | optional.go | 0.844633 | 0.427397 | optional.go | starcoder |
package language
import (
"fmt"
lang "github.com/matihost/learning/go/internal/language"
)
var (
// a is an array of 10 strings,
// size is the part of array type
// arrays cannot be resized
a [10]string
// slice is like table but with size declaration
// slices are more common than tables
// zero value of ... | go/learning/pkg/language/array.go | 0.600657 | 0.500732 | array.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.