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 xatomic
import (
"sync/atomic"
)
// AtomicInt32 is an atomic wrapper around an int32.
type AtomicInt32 struct{ v int32 }
// NewAtomicInt32 creates an AtomicInt32.
func NewAtomicInt32(i int32) *AtomicInt32 {
return &AtomicInt32{i}
}
// Load atomically loads the wrapped value.
func (i *AtomicInt32) Load() i... | xsync/xatomic/atomic_integer.go | 0.864868 | 0.477371 | atomic_integer.go | starcoder |
package view
import (
"math"
"strings"
"github.com/hailongz/golang/canvas"
"github.com/hailongz/golang/dynamic"
)
func init() {
AddElementConstructor("view", func(id int64, name string) IElement {
v := &ViewElement{}
v.SetId(id)
v.SetName(name)
return v
})
}
type IViewElement interface {
IElement
X(... | view/ViewElement.go | 0.655115 | 0.408867 | ViewElement.go | starcoder |
package Topological_Sort
/*
* Topological Sort
Topological Sort of a directed graph (a graph with unidirectional edges) is a linear ordering of its vertices
such that for every directed edge (U, V) from vertex U to vertex V, U comes before V in the ordering.
Given a directed graph, find the topological ordering of it... | Pattern16 - Topological Sort/Topological_Sort/solution.go | 0.807157 | 0.835953 | solution.go | starcoder |
package loadtest
import "fmt"
type unorderedStringMapValue struct {
index int
content interface{}
}
// UnorderedStringMap represents a map from strings to interface{}s that can be looped using zero-based indexes with order based on previously executed Set/Remove operations
type UnorderedStringMap struct {
strin... | loadtest/unordered_string_map.go | 0.820073 | 0.416144 | unordered_string_map.go | starcoder |
Package planbuilder allows you to build execution
plans that describe how to fulfill a query that may
span multiple keyspaces or shards.
The main entry point for the planbuilder is the
Build function that accepts a query and vschema
and returns the plan.
*/
package planbuilder
/*
The two core primitives built by this... | lab055/lab001/vendor/github.com/youtube/vitess/go/vt/vtgate/planbuilder/doc.go | 0.783699 | 0.878158 | doc.go | starcoder |
package query
import (
"regexp"
"strconv"
"strings"
"time"
)
// Converter is an interface that converts strings to known types.
type Converter interface {
// Convert checks a string val and converts it when possible to some
// type.
Convert(val string) (i interface{}, err error)
}
// ConvertFunc is a function... | convert.go | 0.705278 | 0.415254 | convert.go | starcoder |
package claimsheader
import "strconv"
// CompressionType defines the compression used.
type CompressionType int
const (
// CompressionTypeNone implies no compression
CompressionTypeNone CompressionType = iota
// CompressionTypeV1 is version 1 of compression
CompressionTypeV1
// CompressionTypeV2 is version 2 of... | controller/pkg/claimsheader/ct.go | 0.715722 | 0.735119 | ct.go | starcoder |
package serie
import (
"math"
"sort"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/stat"
)
// An aggregate function performs a calculation on a set of values, and returns a single value.
// Aggregate functions ignore null values.
type StatOptions struct {
Missing *float64 // replaces missing values with a va... | serie/stat.go | 0.842604 | 0.421909 | stat.go | starcoder |
package lor
import "time"
func Heartbeat() []byte {
return []byte{0x00, 0xFF, 0x81, 0x56, 0x00}
}
func On(unit Unit, ch Channel) []byte {
return ofCommand(commandOn, unit, ch)
}
func MaskedOn(unit Unit, mask *Mask) []byte {
return ofMaskedCommand(commandOn|mask.offset, unit, mask)
}
func SetBrightness(unit Unit... | pkg/lor/direct.go | 0.702836 | 0.484746 | direct.go | starcoder |
package frango
import (
"strconv"
"strings"
)
/* -----------Int----------- */
func IntToString(dataInt int) string {
dataString := strconv.Itoa(dataInt)
return dataString
}
func IntToByteArray(dataInt int) []byte {
dataByteArray := StringToByteArray(IntToString(dataInt))
return dataByteArray
}
func IntToBool... | vendor/github.com/liteByte/frango/type_conversions.go | 0.637031 | 0.422981 | type_conversions.go | starcoder |
package trigmath
import "math"
const PI = 3.1415
const SQUARED_PI = PI * PI
const HALF_PI = PI / 2
const QUARTER_PI = HALF_PI / 2
const TWO_PI = 2 * PI
const THREE_PI_HALVES = TWO_PI - HALF_PI
const DEG_TO_RAD = PI / 180
const HALF_DEG_TO_RAD = PI / 360
const RAD_TO_DEG = 180 / PI
const SQRT_OF_TWO = 1.41421356237
co... | go/trigmath/trigmath.go | 0.574872 | 0.459319 | trigmath.go | starcoder |
package types
import (
"fmt"
"strings"
"dyego0/assert"
"dyego0/symbols"
)
// TypeKind is the kind of type
type TypeKind int
const (
// Record is a linear block of memory separated into files
Record TypeKind = iota
// Reference to a record or array
Reference
// Array is a linear block of memory of homomor... | types/types.go | 0.803868 | 0.529324 | types.go | starcoder |
package d3
import (
"math"
"strconv"
"strings"
"github.com/adamcolton/geom/angle"
"github.com/adamcolton/geom/calc/cmpr"
"github.com/adamcolton/geom/geomerr"
)
// V is a 3D vector.
type V D3
// Mag2 Returns the sqaure of the magnitude of the vector.
func (v V) Mag2() float64 {
return v.X*v.X + v.Y*v.Y + v.Z*... | d3/v.go | 0.856887 | 0.530054 | v.go | starcoder |
package draw
import (
"image"
"image/color"
"github.com/adamcolton/geom/d2"
"github.com/adamcolton/geom/d2/grid"
"github.com/adamcolton/geom/d2/shape/boxmodel"
"github.com/adamcolton/geom/iter"
"github.com/fogleman/gg"
)
// Ctx is meant to represent *gg.Context.
type Ctx interface {
Stroke()
Fill()
DrawLin... | d2/draw/ctx.go | 0.767516 | 0.417806 | ctx.go | starcoder |
package testData
var UserDefinition = `
"User": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email"
},
"token": {
"type": "string"
},
"username": {
"type": "string"
},
"bio": {
"type": "string"
},
"image": {
"type"... | testData/jsonShemas.go | 0.590307 | 0.489259 | jsonShemas.go | starcoder |
package decorated
import (
"fmt"
"sort"
"github.com/swamp/compiler/src/ast"
"github.com/swamp/compiler/src/decorated/dtype"
dectype "github.com/swamp/compiler/src/decorated/types"
"github.com/swamp/compiler/src/token"
)
type ByAssignmentName []*RecordLiteralAssignment
func (a ByAssignmentName) Len() int ... | src/decorated/expression/record_literal.go | 0.563138 | 0.406361 | record_literal.go | starcoder |
package timelearn
import (
"context"
"math"
"math/rand"
"time"
)
// A problem is a single problem retrieved.
type Problem struct {
id int64
Question string // The question to be asked.
Answer string // The correct answer.
Next time.Time // When to next ask this question.
Interva... | timelearn/learn.go | 0.569613 | 0.428652 | learn.go | starcoder |
package triangle
import (
"image"
"image/color"
"math"
"golang.org/x/exp/constraints"
)
// Grayscale converts the image to grayscale mode.
func Grayscale(src *image.NRGBA) *image.NRGBA {
dx, dy := src.Bounds().Max.X, src.Bounds().Max.Y
dst := image.NewNRGBA(src.Bounds())
for x := 0; x < dx; x++ {
for y := 0... | imop.go | 0.80502 | 0.549943 | imop.go | starcoder |
package maps
import (
"golang.org/x/exp/constraints"
)
// HasKey returns a function that tests if a key exists in the map.
func HasKey[K comparable, V any](pairs map[K]V) func(k K) bool {
return func(k K) bool { _, ok := pairs[k]; return ok }
}
// Key returns the key of a map key/value pair.
func Key[K comparable,... | maps/maps.go | 0.838515 | 0.487124 | maps.go | starcoder |
package recurring
import (
"github.com/keep94/gofunctional3/functional"
"github.com/keep94/sunrise"
tasks_recurring "github.com/keep94/tasks/recurring"
"time"
)
// EachSunset returns the sunsets for a given latitude and longitude.
// lat is the latitude where north is positive and south is negative.
// lon is the... | recurring/recurring.go | 0.76145 | 0.427217 | recurring.go | starcoder |
package v1
import (
"encoding/json"
)
// SpotPricesPerBaremetal struct for SpotPricesPerBaremetal
type SpotPricesPerBaremetal struct {
Price *float32 `json:"price,omitempty"`
}
// NewSpotPricesPerBaremetal instantiates a new SpotPricesPerBaremetal object
// This constructor will assign default values to propertie... | v1/model_spot_prices_per_baremetal.go | 0.750278 | 0.434641 | model_spot_prices_per_baremetal.go | starcoder |
package aperture
import (
"math"
)
// ring maps the indices [0, `size`) uniformly around a coordinate space [0.0, 1.0).
type ring struct {
size int
unitWidth float64
}
const (
floatOne float64 = 1.0
intOne int = 1
)
func newRing(size int) *ring {
return &ring{
size: size,
unitWidth: floatO... | aperture/ring.go | 0.929664 | 0.601213 | ring.go | starcoder |
package test_clients1
import (
"testing"
clients1 "github.com/pip-services-samples/client-beacons-go/clients/version1"
data1 "github.com/pip-services-samples/service-beacons-go/data/version1"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
"github.com/stretchr/testify/assert"
)
type BeaconsCli... | test/clients/version1/BeaconsClientV1Fixture.go | 0.651687 | 0.564609 | BeaconsClientV1Fixture.go | starcoder |
package params
/*
Package params provides a globally available parameter store.
There are two main types, Keeper and Subspace. Subspace is an isolated namespace for a
paramstore, where keys are prefixed by preconfigured spacename. Keeper has a
permission to access all existing spaces.
Subspace can be used by the ind... | x/params/doc.go | 0.702734 | 0.47725 | doc.go | starcoder |
package polygen
import (
"encoding/gob"
"image"
"image/color"
"log"
"math/rand"
"github.com/llgcode/draw2d/draw2dimg"
)
const (
MutationAlpha = iota
MutationColor = iota
MutationPoint = iota
MutationZOrder = iota
MutationAddOrDeletePoint = iota
)
const (
Popula... | candidate.go | 0.630002 | 0.504394 | candidate.go | starcoder |
package postaggregation
// QuantilesDoublesSketchToQuantile struct based on
// PostAggregator section in https://druid.apache.org/docs/latest/development/extensions-core/datasketches-quantiles.html#quantile
type QuantilesDoublesSketchToQuantile struct {
Base
Field *QuantilesDoublesSketchToQuantileField `json:"fie... | builder/postaggregation/quantiles_doubles_sketch_to_quantile.go | 0.821331 | 0.405743 | quantiles_doubles_sketch_to_quantile.go | starcoder |
package tokenizer
import "github.com/sqlabble/sqlabble/token"
var (
EmptyLine = Line{}
)
func ParamsToLine(values ...interface{}) (Line, []interface{}) {
if len(values) == 0 {
return EmptyLine, nil
}
return NewLine(token.Placeholders(len(values))...), values
}
type Line struct {
tokens []token.Token
}
func ... | tokenizer/line.go | 0.55254 | 0.450722 | line.go | starcoder |
package nadasensio
import (
"math"
"time"
perlin "github.com/aquilax/go-perlin"
)
type SimParam struct {
Noise_seed int
Origin_latitude float64
Origin_longitude float64
Origin_altitude float64
TimeStamp time.Time
}
func GetMeasureValue(measureType string, params SimParam) float64 {
var measu... | internal/app/nada-sensio/simulation/nadasim.go | 0.776199 | 0.47658 | nadasim.go | starcoder |
package pso
import (
"math"
"github.com/applied-math-coding/heuristic/common"
"gonum.org/v1/gonum/mat"
)
type Params = struct {
Omega float64
Phi_p float64
Phi_g float64
N_particles int
LearningRate float64
Max_iter int
}
func Optimize(f common.Target, b_low mat.Vector, b_up mat.... | pso/pso.go | 0.608012 | 0.581986 | pso.go | starcoder |
package container
import "github.com/srirampatil/gostl/common"
// listNode represents a node in a doubly linked list. It implements the Iterator
// interface.
type listNode struct {
value interface{}
next, prev *listNode
}
func (node listNode) Value() interface{} {
return node.value
}
// List type implement... | container/list.go | 0.822403 | 0.432303 | list.go | starcoder |
package drawing
import (
"encoding/json"
"fmt"
"math"
"strings"
)
const arrowHeadLength = 21
type Point struct {
x, y float64
}
// Shape
type Connector struct {
Shape1 int `json:"shape1"`
Shape2 int `json:"shape2"`
}
func connectorSlope(d Drawing, c Connector) float64 {
if len(d.Shapes) <= c.Shape1 || len... | connector.go | 0.667256 | 0.408749 | connector.go | starcoder |
package gokalman
import "github.com/gonum/matrix/mat64"
type measurementInfo struct {
RealObs *mat64.Vector
ComputedObs *mat64.Vector
ObservationDev *mat64.Vector
Φ, H *mat64.Dense
}
// BatchKF defines a vanilla kalman filter. Use NewVanilla to initialize.
type BatchKF struct {
Λ ... | batch.go | 0.749546 | 0.69579 | batch.go | starcoder |
package volume
import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
"github.com/ortiye/molsolvent/pkg/util"
)
// readCfgFirst reads the first configuration. It reads the number of atoms, the
// columns and performs the usual calculations like in readCfg.
func (v *Volume) readCfgFirst(r *bufio.Reader) (XYZ, [3]float... | pkg/volume/read.go | 0.673943 | 0.435301 | read.go | starcoder |
package comptop
import (
"gonum.org/v1/gonum/mat"
)
// BoundaryMap is the bonudary map between chain groups of dimensions p and p-1.
type BoundaryMap struct {
mat mat.Matrix
sn *mat.Dense
u *mat.Dense
ui *mat.Dense
v *mat.Dense
dl *int
zp *int
bpl *int
}
// BoundaryMatrix returns the matrix representa... | boundaryMap.go | 0.823541 | 0.564699 | boundaryMap.go | starcoder |
package cowslices
import (
"fmt"
"github.com/phelmkamp/immut/roslices"
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
)
// Slice wraps a copy-on-write slice.
type Slice[E any] struct {
RO roslices.Slice[E] // wraps a read-only slice
}
// SetIndex sets the element at i to v.
// Note: The underlying s... | cowslices/cowslices.go | 0.851768 | 0.416797 | cowslices.go | starcoder |
package tiletype
type bufferFunc func([]byte) bool
// TileHeader provides string values to content encoding and types
// that was translated from a buffer.
type TileHeader struct {
ContentType string
ContentEncoding string
}
// Jpeg determines if buffer data is file type jpg.
func Jpeg(buf []byte) bool {
retu... | tiletype.go | 0.648466 | 0.521227 | tiletype.go | starcoder |
package sp800108
import (
"crypto/aes"
"crypto/hmac"
"fmt"
"hash"
"github.com/aead/cmac" // FIXME: look into this implementation security-wise
)
// PRF is a Pseudorandom Function acceptable to the NIST KBKDF
type PRF interface {
// Compute generates new data from a key and keying material data.
Compute(key, d... | goimpl/nist/sp800108/prf.go | 0.564459 | 0.44354 | prf.go | starcoder |
// go build
// ./example2
// Sample program to quality control a persisted regression model.
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"math"
"os"
"path/filepath"
)
// ModelInfo includes the information about the
// model that is output from the training.
type ModelInfo struct {
... | machine-learning-with-go/ml_workflow/exercise2/solutions/solution2/solution2b/solution2b.go | 0.712732 | 0.431165 | solution2b.go | starcoder |
package storetest
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/store"
)
func TestSchemeStore(t *testing.T, ss store.Store) {
createDefaultRoles(t, ss)
t.Run("Save"... | store/storetest/scheme_store.go | 0.521715 | 0.517266 | scheme_store.go | starcoder |
package labels
import (
"sort"
"strings"
)
// LabelArray is an array of labels forming a set
type LabelArray []Label
// Sort is an internal utility to return all LabelArrays in sorted
// order, when the source material may be unsorted. 'ls' is sorted
// in-place, but also returns the sorted array for convenience... | pkg/labels/array.go | 0.6973 | 0.521471 | array.go | starcoder |
// Package merger performs recursive merge of maps or structures into new one.
// Non-zero values from the right side has higher precedence. Slices do not
// merging, because main use case of this package is merging configuration
// parameters, and in this case merging of slices is unacceptable. Slices from
// the rig... | vendor/github.com/iph0/merger/merger.go | 0.824921 | 0.674119 | merger.go | starcoder |
package metrics
import (
"github.com/Azure/azure-container-networking/npm/util"
"github.com/prometheus/client_golang/prometheus"
)
var ipsetInventoryMap = make(map[string]int)
// IncNumIPSets increments the number of IPSets.
func IncNumIPSets() {
numIPSets.Inc()
}
// DecNumIPSets decrements the number of IPSets.... | npm/metrics/ipsets.go | 0.527803 | 0.542863 | ipsets.go | starcoder |
package golang
func ABI() string {
return `[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
... | golang/abi.go | 0.63409 | 0.520679 | abi.go | starcoder |
package humansolver
import (
"fmt"
)
type Coord struct {
Y int
X int
}
var CList = []Coord{{0,0}, {0,1}, {0,2}, {1,0}, {1,1}, {1,2}, {2,0}, {2,1}, {2,2}}
func GetNonZeros(all [10]int8) []int8 {
res := make([]int8, 0, 9)
for _, num := range all {
if num != 0 {
res = append(res, num)
}
}
return res
}
f... | humansolver/humansolver.go | 0.578091 | 0.42931 | humansolver.go | starcoder |
package evaluator
import (
"fmt"
"monkeylang/ast"
"monkeylang/object"
)
var (
NULL = &object.Null{}
TRUE = &object.Boolean{Value: true}
FALSE = &object.Boolean{Value: false}
)
func Eval(env *object.Environment, node ast.Node) object.Object {
switch castedNode := node.(type) {
case *ast.Program:
return ev... | evaluator/evaluator.go | 0.600657 | 0.458652 | evaluator.go | starcoder |
package frontend
import (
"unicode/utf8"
"github.com/isaacev/Plaid/source"
)
/**
* # Handling of Line & File terminations
*
* The first character in each line is considered to be in column 1. A newline
* at the end of a line with `N` characters is considered to be in column
* `N + 1`.
*
* The scanner's hand... | frontend/scanner.go | 0.835148 | 0.438304 | scanner.go | starcoder |
package crypto
import (
"bytes"
"encoding/binary"
"fmt"
"github.com/HyperspaceApp/fastrand"
"github.com/dchest/threefish"
)
const (
// threefishOverhead is the number of bytes added by EncryptBytes.
threefishOverhead = 0
)
type (
// threefishKey is a key used for encrypting and decrypting data.
threefishKe... | crypto/threefish.go | 0.79538 | 0.419886 | threefish.go | starcoder |
package tentsuyu
import (
"math"
"github.com/rs/xid"
"github.com/hajimehoshi/ebiten"
)
//GameObject is any renderable object
type GameObject interface {
GetPosition() (float64, float64)
SetPosition(float64, float64)
GetWidth() int
GetHeight() int
//Update()
Draw(*ebiten.Image) error
Contains(float64, floa... | gameobject.go | 0.843573 | 0.5425 | gameobject.go | starcoder |
package csg
/*
This is a defunct OctTree implementation, this was an attempt to optimize the polygon
splitting using and OctTree, essentially try to remove as many polygons from the
evaluation of polygons to BSP tree planes, but the results were dissappointing
because the primary overhead is in the number of recursive... | csg/octtree.go | 0.565779 | 0.716405 | octtree.go | starcoder |
package constraints
import (
"reflect"
"github.com/seeruk/go-validation"
)
// AtLeastNRequired ...
func AtLeastNRequired(n int, fields ...string) validation.ConstraintFunc {
if n < 1 {
// At least 0 required is saying that at least none of the fields must be set, which is the
// same as not using this constra... | constraints/at_least_n_required.go | 0.636014 | 0.416441 | at_least_n_required.go | starcoder |
package leetcode
type item struct {
x int
y int
}
func orangesRotting(grid [][]int) int {
// init slice for rotting oranges and fresh oranges
rotting := make([]item, 0)
fresh := make([]item, 0)
m, n := len(grid), len(grid[0])
// iterate over the grid and append rotting and fresh oranges to respective group
f... | solutions/0994_Rotting_Oranges/0994_Rotting_Oranges.go | 0.602763 | 0.462776 | 0994_Rotting_Oranges.go | starcoder |
package main
import (
"crypto/elliptic"
"errors"
"math/big"
"sync"
)
var (
initonce sync.Once
secp256k1 *secp256k1Curve
three = new(big.Int).SetUint64(3)
)
type secp256k1Curve struct {
elliptic.CurveParams
}
func initSECP256K1() {
// http://www.secg.org/sec2-v2.pdf
secp256k1 = &secp256k1Curve{ellipti... | secp256k1.go | 0.719186 | 0.512937 | secp256k1.go | starcoder |
package core
import (
"math/rand"
"sort"
)
type LEACH struct {
Clusters int // A number of clusters in the network.
Nodes int // A number of nodes in the network.
}
// Setup implements Protocol.Setup.
func (l *LEACH) Setup(net *Network) ([]int64, error) {
r := rand.New(rand.NewSource(seed))
// Clean previo... | core/leach.go | 0.596081 | 0.455744 | leach.go | starcoder |
package rpm
import (
"bytes"
"fmt"
"io"
"github.com/tarantool/cartridge-cli/cli/common"
)
type rpmValueType int32
type rpmTagType struct {
ID int
Type rpmValueType
Value interface{}
}
type rpmTagSetType []rpmTagType
type packedTagType struct {
Count int
Data *bytes.Buffer
}
func (tagSet *rpmTagSetT... | cli/rpm/tagset.go | 0.707101 | 0.537345 | tagset.go | starcoder |
package solrmonitor
// ugh... seems silly to have to define this
const maxInt = int(^uint(0) >> 1)
// fifoTaskQueue is a FIFO queue using a ring buffer. A worker goroutine processes elements in
// a queue. This uses a ring buffer instead of a simpler approach that only uses Go slices
// (e.g. q = append(q, e) to enqu... | solrmonitor/fifo.go | 0.621885 | 0.416797 | fifo.go | starcoder |
package core
import (
"math/big"
"sync"
"time"
)
// Balance holds the credit balance for a broadcast session
type Balance struct {
manifestID ManifestID
balances *Balances
}
// NewBalance returns a Balance instance
func NewBalance(manifestID ManifestID, balances *Balances) *Balance {
return &Balance{
manif... | core/accounting.go | 0.681409 | 0.411111 | accounting.go | starcoder |
package keccakf1600
import (
"unsafe"
"github.com/cloudflare/circl/internal/sha3"
"golang.org/x/sys/cpu"
)
// StateX4 contains state for the four-way permutation including the four
// interleaved [25]uint64 buffers. Call Initialize() before use to initialize
// and get a pointer to the interleaved buffer.
type St... | simd/keccakf1600/f1600x.go | 0.603815 | 0.653224 | f1600x.go | starcoder |
package yin
func YinPitch1(samples *[]float64, sampleRate float64) (float64, float64) {
df := DF(samples)
ath := AbsoluteThreshold(&df)
return sampleRate / ath, ath
}
func YinPitch2(samples *[]float64, sampleRate float64) (float64, float64) {
df := DF(samples)
CMNDF(&df)
ath := AbsoluteThreshold(&df)
return sa... | misc/yin/pitch.go | 0.718199 | 0.625953 | pitch.go | starcoder |
package simulation
import (
"math/rand"
"sort"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// PriceGenerator allows deterministic price generation in simulations
type PriceGenerator struct {
markets []string
currentPrice map[string]sdk.Dec
maxPrice map[string]sdk.Dec
minPrice ... | x/pricefeed/simulation/types.go | 0.705886 | 0.416263 | types.go | starcoder |
package nano
import (
"fmt"
v "github.com/spate/vectormath"
"math"
"math/rand"
)
const (
Anisotropy = 4000.
Saturation = 800.
Damping = (20. * Anisotropy) / Saturation
Radius = 20.e-7
GyromagneticRatio = 1.76e+7
)
func Calculate(field *v.Vector3, dt, epsillon float32) (ma... | nano/nano.go | 0.621081 | 0.460835 | nano.go | starcoder |
package fbe
import "time"
import "github.com/google/uuid"
import "github.com/shopspring/decimal"
// Decimal struct
type Decimal struct {
decimal.Decimal
}
// Create a new decimal from the given float value
func DecimalFromFloat(value float64) Decimal {
result := decimal.NewFromFloat(value)
return Decima... | projects/Go/proto/fbe/Types.go | 0.866768 | 0.473596 | Types.go | starcoder |
// Package consensus implements different Matrix consensus engines.
package consensus
import (
"math/big"
"github.com/MatrixAINetwork/go-matrix/common"
"github.com/MatrixAINetwork/go-matrix/core/state"
"github.com/MatrixAINetwork/go-matrix/core/types"
"github.com/MatrixAINetwork/go-matrix/mc"
"github.com/Matri... | consensus/consensus.go | 0.715424 | 0.430387 | consensus.go | starcoder |
package filter
import (
"strconv"
"github.com/zimmski/tavor/token"
"github.com/zimmski/tavor/token/lists"
"github.com/zimmski/tavor/token/primitives"
)
func init() {
Register("PositiveBoundaryValueAnalysis", NewPositiveBoundaryValueAnalysis)
}
// NewPositiveBoundaryValueAnalysis implements a fuzzing filter for... | fuzz/filter/positiveboundaryvalueanalysis.go | 0.74872 | 0.50354 | positiveboundaryvalueanalysis.go | starcoder |
package goDataStructure
import "fmt"
type MaxHeap struct {
array []Comparable
}
func CreateMaxHeap() *MaxHeap {
return &MaxHeap{
array: []Comparable{},
}
}
func (mh *MaxHeap) parent(index int) int {
if index == 0 {
panic("index haven't parent ")
}
return (index - 1) / 2
}
func (mh *MaxHeap) leftChild(ind... | maxHeap.go | 0.576065 | 0.541469 | maxHeap.go | starcoder |
package qlng
import (
"fmt"
"strings"
)
// SelectStatement represents a SQL SELECT statement.
type (
parserNode interface {
fmt.Stringer
Validate() error
ToAST() *ASTNode
}
parserNodeSet []parserNode // Stream of comma delimited nodes
parserNodes []parserNode // Stream of space delimited nodes
lNull... | pkg/qlng/parser_nodes.go | 0.57344 | 0.560433 | parser_nodes.go | starcoder |
package xlist
// List is a doubly-linked list.
type List[T any] struct {
front *Node[T]
back *Node[T]
size int
}
// Len returns the number of items in the list.
func (l *List[T]) Len() int { return l.size }
// Front returns the node at the front of the list.
func (l *List[T]) Front() *Node[T] { return l.front }... | container/xlist/xlist.go | 0.76986 | 0.401688 | xlist.go | starcoder |
package support
//---------------------------------------------------------------------
// ProjectionTableEntry holds a projection entry
type ProjectionTableEntry struct {
ID string
Description string
}
// ProjectionsTable is the global list of projections
var ProjectionsTable = map[string]*ProjectionTab... | vendor/github.com/go-spatial/proj/support/ProjectionsTable.go | 0.537284 | 0.425844 | ProjectionsTable.go | starcoder |
package gfx
import (
"image/color"
"image/draw"
)
// DrawIntLine draws a line between two points
func DrawIntLine(dst draw.Image, x0, y0, x1, y1 int, c color.Color) {
if x0 == x1 {
if y0 > y1 {
y0, y1 = y1, y0
}
for ; y0 <= y1; y0++ {
dst.Set(x0, y0, c)
}
} else if y0 == y1 {
if x0 > x1 {
x0, ... | draw_int.go | 0.63477 | 0.680819 | draw_int.go | starcoder |
package datadog
import (
"encoding/json"
)
// UsageLogsByRetentionHour The number of indexed logs for each hour for a given organization broken down by retention period.
type UsageLogsByRetentionHour struct {
// Total logs indexed with this retention period during a given hour.
IndexedEventsCount *int64 `json:"in... | api/v1/datadog/model_usage_logs_by_retention_hour.go | 0.781622 | 0.433022 | model_usage_logs_by_retention_hour.go | starcoder |
package main
import (
"regexp"
"strconv"
"strings"
. "github.com/asuahsahua/advent2019/cmd/common"
)
// --- Day 14: Space Stoichiometry ---
// As you approach the rings of Saturn, your ship's low fuel indicator turns on.
// There isn't any fuel here, but the rings have plenty of raw material. Perhaps
// your s... | cmd/day14/main.go | 0.662469 | 0.446253 | main.go | starcoder |
package gogeom
import (
"math"
)
//sides of the right triangle
type RightTriangleSides struct {
Base, Height, Hypotenuse float64
}
//sides of the isosceles triangle
type IsoscelesTriangleSides struct {
Base, Slants float64
}
//sides of the equilateral triangle
type EquilateralTriangleSides struct {
Side float64... | triangles.go | 0.85443 | 0.606469 | triangles.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
)
/*
A different program might have to wait for user input.
And another might have to wait while data is read in from a file.
There are lots of situations where programs are just sitting around waiting.
`Concurrency` allows a program to pause one ta... | headfirstgo/retrievingpages.go | 0.563858 | 0.414247 | retrievingpages.go | starcoder |
package main
import (
"fmt"
)
var cnt int
// This function calls the DFS recursively for adjacency list of a vertex
func DFS_VISIT(Graph [][]int, source int, sorted, visited []int) {
// Mark the current vertex as visited
visited[source] = 1
// Visit its adjacency list recursively
for i := 0; i < len(Graph[sour... | Go/graphs/topological_sort/topological_sort.go | 0.536799 | 0.436802 | topological_sort.go | starcoder |
package filter
import (
"math"
"time"
"github.com/kwoodhouse93/audio-playground/source"
"github.com/kwoodhouse93/audio-playground/types"
"github.com/kwoodhouse93/audio-playground/utils"
)
// Delay stores the samples for a given duration then plays them back delayed
func Delay(src source.Source, delay time.Durat... | filter/filter.go | 0.742702 | 0.439086 | filter.go | starcoder |
package actions
import (
"fmt"
"regexp"
"github.com/tokenized/pkg/bitcoin"
"github.com/pkg/errors"
)
const (
max1ByteInteger = 255
max2ByteInteger = 65535
max4ByteInteger = 4294967295
maxArticleDepth = 4
)
func (a *ContractOffer) Validate() error {
if a == nil {
return errors.New("Empty")
}
// Field... | dist/golang/actions/validate.go | 0.529263 | 0.415373 | validate.go | starcoder |
package junit
import "time"
// Result represents the outcome of a test (eg. Pass, Fail, etc.).
type Result int
const (
// Unknown represents a result which is unknown.
Unknown Result = iota
// Pass represents a successful test result.
Pass
// Fail represents an unsuccessful test result.
Fail
// Skip represent... | pkg/junit/report.go | 0.728748 | 0.407834 | report.go | starcoder |
package openapi
// CreditItem struct for CreditItem
type CreditItem struct {
// CreditItem ID
ID string `json:"ID,omitempty"`
// AuxiliaryOnUs identifies a code used at the discretion of the creating bank. The handling of dashes and spaces shall be determined between the exchange partners.
AuxiliaryOnUs string `js... | client/model_credit_item.go | 0.623835 | 0.445409 | model_credit_item.go | starcoder |
package capnp
// pointerOffset is an address offset in multiples of word size.
type pointerOffset int32
// resolve returns an absolute address relative to a base address.
// For near pointers, the base is the end of the near pointer.
// For far pointers, the base is zero (the beginning of the segment).
func (off poin... | rawpointer.go | 0.818664 | 0.422564 | rawpointer.go | starcoder |
package prometheus
import (
"github.com/lomik/graphite-clickhouse/helper/point"
"github.com/lomik/graphite-clickhouse/render/data"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage"
)
// SeriesIterator iterates over the data of a time series.
type seriesIterator struct {
m... | prometheus/series_set.go | 0.756447 | 0.494202 | series_set.go | starcoder |
package schema
import (
"fmt"
"github.com/dolthub/dolt/go/store/types"
)
// ColConstraint is an interface used for evaluating whether a columns value is valid
type ColConstraint interface {
// SatisfiesConstraint takes in a value and returns true if the value satisfies the constraint
SatisfiesConstraint(value t... | go/libraries/doltcore/schema/constraint.go | 0.792183 | 0.532486 | constraint.go | starcoder |
package v1alpha1 // import "istio.io/api/rbac/v1alpha1"
/*
Istio RBAC (Role Based Access Control) defines ServiceRole and ServiceRoleBinding
objects.
A ServiceRole specification includes a list of rules (permissions). Each rule has
the following standard fields:
* services: a list of services.
* methods: HTTP method... | vendor/istio.io/api/rbac/v1alpha1/rbac.pb.go | 0.62601 | 0.603815 | rbac.pb.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"github.com/facebook/ent/dialect/sql"
"github.com/gobench-io/gobench/ent/application"
)
// Application is the model entity for the Application schema.
type Application struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the val... | ent/application.go | 0.666605 | 0.401277 | application.go | starcoder |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package to
import "time"
// BoolPtr returns a pointer to the provided bool.
func BoolPtr(b bool) *bool {
return &b
}
// Float32Ptr returns a pointer to the provided float32.
func Float32Ptr(i float32) *float32 {
retur... | sdk/to/to.go | 0.755547 | 0.421492 | to.go | starcoder |
package promql
import (
"fmt"
"time"
"github.com/influxdata/flux"
"github.com/influxdata/flux/execute"
"github.com/influxdata/flux/plan"
"github.com/influxdata/flux/runtime"
"github.com/influxdata/flux/values"
)
const InstantRateKind = "instantRate"
type InstantRateOpSpec struct {
IsRate bool `json:"isRate... | stdlib/internal/promql/instant_rate.go | 0.67694 | 0.51013 | instant_rate.go | starcoder |
package dataplane
import (
"fmt"
"github.com/submariner-io/submariner/test/e2e/framework"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("[dataplane] Basic TCP connectivity tests across clusters without discovery", func() {
f := framework.NewDefaultFramework("dataplane-conn-nd")
var ... | test/e2e/dataplane/tcp_pod_connectivity.go | 0.60778 | 0.545286 | tcp_pod_connectivity.go | starcoder |
Package logger provides logging mechanism for SLAV projects. It was created, as we didn't find a
logger fitting our requirements:
* have syslog-like levels;
* do not panic with highest priority log;
* have structured log entities (to allow automated parsing).
Basics
The usage of logger is really simple:
if data, ... | logger/doc.go | 0.503418 | 0.428592 | doc.go | starcoder |
package lib
import (
"fmt"
"math"
"math/rand"
"time"
"github.com/dunelang/dune"
)
func init() {
rand.Seed(time.Now().UnixNano())
dune.RegisterLib(Math, `
declare namespace math {
/**
* returns, as an int, a non-negative pseudo-random number in (0,n)
*/
export function rand(n: number): numb... | lib/math.go | 0.663669 | 0.474327 | math.go | starcoder |
package assert
import (
"strconv"
"strings"
)
type Int struct {
logFacade *logFacade
actual int
}
func (a *Int) IsZero() *Int {
return a.isTrue(a.actual == 0,
"Expected zero, but was <%d>.", a.actual)
}
func (a *Int) IsNonZero() *Int {
return a.isTrue(a.actual != 0,
"Expected nonzero, but was zero.")
}... | vendor/github.com/assertgo/assert/int.go | 0.746878 | 0.679332 | int.go | starcoder |
package polyutils
type Point struct {
X float64
Y float64
}
type BoundingBox struct {
Max Point
Min Point
}
type Polygon struct {
Points []Point
BoundingBox BoundingBox
XVerts []float64
YVerts []float64
}
// NewPolygon returns a pointer to a polygon given a set of points.
func NewPolygon(poin... | polygon.go | 0.910029 | 0.590868 | polygon.go | starcoder |
package pdfcpu
import (
"encoding/binary"
"encoding/hex"
"fmt"
"github.com/pkg/errors"
)
// ICC profiles are not yet supported.
// We fall back to the alternate color space and if there is none to whatever color space makes sense.
//ICC profiles use big endian always.
type iccProfile struct {
b []byte... | pkg/pdfcpu/iccProfile.go | 0.683947 | 0.460895 | iccProfile.go | starcoder |
package expressions
import (
"github.com/jictyvoo/fitpiece/cimenteiro/internal/elements"
)
// ArrayExpression create a new ArrayElementExpression object with values that will be wrapped in '[' ']'
func ArrayExpression[T any](values ...T) ArrayElementExpression[T] {
return ArrayElementExpression[T]{
values: values... | cimenteiro/builder/expressions/general.go | 0.804021 | 0.57684 | general.go | starcoder |
package rtsengine
import (
"image"
"math/rand"
"time"
)
/*
World 2D grid. That is an array of acre structures.
*/
// World maintains the world state. This is the big one!
type World struct {
Grid
}
// NewWorld will construct a random world of width and height specified.
// works on 'this'. Another way of thin... | src/rtsengine/world.go | 0.696578 | 0.568895 | world.go | starcoder |
package common
import (
"fmt"
"time"
"github.com/m3db/m3/src/query/graphite/ts"
)
// bootstrapWithIDs mocks fetches for now as the seriesList names are not actually IDs that are fetchable
// NaN vals will be returned for the period of startTime to EndTime
func bootstrapWithIDs(ctx *Context, seriesList ts.SeriesL... | src/query/graphite/common/bootstrap.go | 0.662906 | 0.419945 | bootstrap.go | starcoder |
package model
import (
"github.com/jesand/stats/channel/bsc"
"github.com/jesand/stats/dist"
"github.com/jesand/stats/factor"
"github.com/jesand/stats/variable"
"math"
)
// Create a new MultipleBSCPairModel
func NewMultipleBSCPairModel() *MultipleBSCPairModel {
return &MultipleBSCPairModel{
Noise1Rates: make(m... | model/multiple_bsc_pair.go | 0.698741 | 0.602588 | multiple_bsc_pair.go | starcoder |
package skyline
import (
"container/heap"
"sort"
)
// Point represents a 0-dimensional geometric point.
type Point struct {
X, Y int
}
// Building represents a 2-dimensional representation of a building in a skyline.
type Building struct {
LeftX, RightX, Height int
}
type edge struct {
X, Height int
Up ... | skyline/problem.go | 0.76074 | 0.435481 | problem.go | starcoder |
package mydynamo
import "encoding/json"
//The vector clock data type for dynamo server events
type VectorClock struct {
NodeClocks map[string]uint64
}
//Creates a new VectorClock
func NewVectorClock() VectorClock {
return VectorClock{
NodeClocks: make(map[string]uint64),
}
}
//Returns true if the other VectorC... | src/mydynamo/Dynamo_VectorClock.go | 0.774242 | 0.526708 | Dynamo_VectorClock.go | starcoder |
package graph
/*
Gabow's path-based strong component algorithm
Gabow's algorithm is basicly Tarjan's algorithm by using a stack to track root vertices instead of calculating low point values.
The crux of the algorithm comes in determining whether a node is the root of a strongly connected component. The root node i... | strong.go | 0.800341 | 0.769817 | strong.go | starcoder |
package geo
import (
"github.com/golang/geo/s2"
)
// circularLoop is a circular loop of points
type circularLoop struct {
s2.Point
Intersection bool
Done bool
next, prev *circularLoop
}
func newCircularLoop(p s2.Point) *circularLoop {
c := &circularLoop{Point: p}
c.next = c
c.prev = c
return c
}
/... | geo/circular.go | 0.692434 | 0.519704 | circular.go | starcoder |
package main
import (
"time"
"math/rand"
"math"
)
type Position struct {
X float64
Y float64
}
func PositionFromInt(x, y int) Position {
return Position{float64(x), float64(y)}
}
func (p Position) RoundX() int {
return int(p.X + 0.5)
}
func (p Position) RoundY() int {
return int(p.Y... | player.go | 0.741393 | 0.401248 | player.go | starcoder |
package assert
import (
"reflect"
"testing"
"github.com/addreas/keycloak-operator/pkg/common"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/apps/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
func ReplicasCount(t *testing.T, state common.DesiredClusterState, expectedCount int32) {
assert.Equal(t, &[]... | test/assert/asserts.go | 0.674587 | 0.412708 | asserts.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.