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 scroll
import (
"fmt"
)
type (
// Position represents a point in text but is decoupled from its exact
// source, i.e. it does not hold a file or pointer to the source code.
Position struct {
Offset int // Byte offset from start of text
Line int // Current line index
ColByte int // Byte offset f... | mmxxi/scarlet/scroll/position.go | 0.804598 | 0.410904 | position.go | starcoder |
package effect
import (
s3mfile "github.com/gotracker/goaudiofile/music/tracked/s3m"
"github.com/gotracker/voice/oscillator"
"gotracker/internal/comparison"
"gotracker/internal/format/s3m/layout/channel"
"gotracker/internal/format/s3m/playback/util"
"gotracker/internal/player/intf"
"gotracker/internal/song/not... | internal/format/s3m/playback/effect/util.go | 0.631481 | 0.427815 | util.go | starcoder |
package sizes
import (
"fmt"
"github.com/github/git-sizer/counts"
"github.com/github/git-sizer/git"
)
type Size interface {
fmt.Stringer
}
type BlobSize struct {
Size counts.Count32
}
type TreeSize struct {
// The maximum depth of trees and blobs starting at this object
// (including this object).
MaxPathD... | sizes/sizes.go | 0.786541 | 0.442215 | sizes.go | starcoder |
package compliance
import (
"context"
"fmt"
"testing"
"time"
"github.com/gomods/athens/pkg/errors"
"github.com/gomods/athens/pkg/index"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/technosophos/moniker"
)
// RunTests runs compliance tests for the given Indexer implementa... | pkg/index/compliance/compliance.go | 0.505859 | 0.446434 | compliance.go | starcoder |
package qdb
/*
#include <qdb/ts.h>
*/
import "C"
import (
"math"
"time"
"unsafe"
)
// TsTimestampPoint : timestamped timestamp data point
type TsTimestampPoint struct {
timestamp time.Time
content time.Time
}
// Timestamp : return data point timestamp
func (t TsTimestampPoint) Timestamp() time.Time {
return... | entry_timeseries_timestamp.go | 0.76207 | 0.525612 | entry_timeseries_timestamp.go | starcoder |
package shapes
import (
"errors"
"fmt"
"math"
"github.com/xyproto/num"
)
// Addition, subtraction, multiplication and division for
// 2D points that are (int, int) and 2D points that are (float64, float64)
// The functions starting with "Must" will not return an error but
// panic instead. Functions that return ... | point.go | 0.806891 | 0.539044 | point.go | starcoder |
package util
import (
"fmt"
"math"
"strconv"
"time"
"github.com/prometheus/common/model"
)
// LatencyMetric represent 50th, 90th and 99th duration quantiles.
type LatencyMetric struct {
Perc50 time.Duration `json:"Perc50"`
Perc90 time.Duration `json:"Perc90"`
Perc99 time.Duration `json:"Perc99"`
}
// SetQua... | clusterloader2/pkg/measurement/util/latency_metric.go | 0.818845 | 0.584834 | latency_metric.go | starcoder |
package pricing
import (
"fmt"
"github.com/tealeg/xlsx"
"go.uber.org/zap"
"github.com/transcom/mymove/pkg/models"
)
var parseShipmentManagementServicesPrices processXlsxSheet = func(params ParamConfig, sheetIndex int, logger Logger) (interface{}, error) {
// XLSX Sheet consts
const xlsxDataSheetNum int = 16 /... | pkg/parser/pricing/parse_management_counseling_transition_prices.go | 0.535341 | 0.464112 | parse_management_counseling_transition_prices.go | starcoder |
package processor
var TriggerParameter = ProcessorParameter{
Name: "trigger",
Description: "A yaml struct to define the condition when the rule, should be applied.",
}
var PathParameter = ProcessorParameter{
Name: "path",
Description: "A string array to define the path of the transformation in the k... | api/v2/processor/default_parameter.go | 0.810554 | 0.570451 | default_parameter.go | starcoder |
package reducers
import (
"github.com/paulmach/go.geo"
)
// A DouglasPeuckerReducer wraps the DouglasPeucker function
// to fulfill the geo.Reducer and geo.GeoReducer interfaces.
type DouglasPeuckerReducer struct {
Threshold float64
}
// NewDouglasPeucker creates a new DouglasPeuckerReducer.
func NewDouglasPeucker... | lab138/vendor/github.com/paulmach/go.geo/reducers/douglas_peucker.go | 0.835819 | 0.513668 | douglas_peucker.go | starcoder |
package util
import (
"math"
"time"
)
// ToFixed rounds passed num to target precision.
func ToFixed(num float64, precision int) float64 {
output := math.Pow(10, float64(precision))
return float64(round(num*output)) / output
}
// GetToday returns today timeTime object.
func GetToday(location *time.Location) time... | internal/pkg/util/functions.go | 0.710226 | 0.444685 | functions.go | starcoder |
package websocket
// Chain contains data relevant for Chain Reaction Game
// Satisfies the Game interface
type Chain struct {
Len int
Squares []*Squares
Hub *Hub
}
// Squares contains data about a row of squares
// Each index is a square
type Squares struct {
Len int // Length of a row
Cur []int... | websocket/chain.go | 0.776369 | 0.59611 | chain.go | starcoder |
package cm
// minHeap is a typed min heap for floating point numbers. Unlike the generic
// heap in the container/heap package, pushing data to or popping data off of
// the heap doesn't require conversion between floats and interface{} objects,
// therefore avoiding the memory and GC overhead due to the additional a... | src/aggregator/aggregation/quantile/cm/heap.go | 0.735167 | 0.513729 | heap.go | starcoder |
package ticker
import (
"fmt"
"github.com/bitfinexcom/bitfinex-api-go/pkg/convert"
)
type Ticker struct {
Symbol string
Frr float64
Bid float64
BidPeriod int64
BidSize float64
Ask float64
AskPeriod int64
AskSize float64
DailyChange ... | pkg/models/ticker/ticker.go | 0.556159 | 0.451085 | ticker.go | starcoder |
package day17
import (
"errors"
"math"
"regexp"
"strconv"
"advent2021.com/util"
)
type TargetArea struct {
MinX, MaxX, MinY, MaxY int
}
func NewTargetArea(minX, maxX, minY, maxY int) *TargetArea {
return &TargetArea{MinX: minX, MaxX: maxX, MinY: minY, MaxY: maxY}
}
func ParseTargetArea(line string) (*Target... | day17/day17.go | 0.640973 | 0.456834 | day17.go | starcoder |
package ints
// IsSortedUint64s returns true if the given nums are sorted,
// and false otherwise.
func IsSortedUint64s(nums []uint64) bool {
if len(nums) == 0 {
return true
}
prev := nums[0]
for _, n := range nums[1:] {
if prev > n {
return false
}
prev = n
}
return true
}
// IsSortedInt64s retur... | pkg/ints/sorted.go | 0.842701 | 0.502075 | sorted.go | starcoder |
package aqi
// Info represents the information based on Air Quality Index.
type Info struct {
Level, Implications, Caution string
}
var (
// Good represents the information when AQI is below 50.
Good = Info{"Good", "Air quality is considered satisfactory, and air pollution poses little or no risk", "-"}
// Moder... | pkg/aqi/aqi.go | 0.545286 | 0.568895 | aqi.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
)
// HStoreFromStringMap returns a driver.Valuer that produces a PostgreSQL hstore from the given Go map[string]string.
func HStoreFromStringMap(val map[string]string) driver.Valuer {
return hstoreFromStringMap{val: val}
}
// HStoreToStringMap returns an... | pgsql/hstore.go | 0.680454 | 0.406509 | hstore.go | starcoder |
package ihex
// RecordType defines what the type of a single record in a HEX file.
type RecordType byte
const (
// RecordData indicates the record contains data and a 16-bit starting address for the data.
// The byte count specifies number of data bytes in the record.
RecordData RecordType = 0x00
// RecordEOF in... | recordType.go | 0.540924 | 0.802942 | recordType.go | starcoder |
package tests
/*
Find valid ZQ examples in markdown, run them against
https://github.com/brimsec/zq-sample-data/zeek-default, and compare results in
docs with results produced.
In separate patches:
- Find files as opposed to hard-coding them
Use markers in markdown fenced code blocks to denote either a zq command or... | tests/zq_example.go | 0.727104 | 0.752456 | zq_example.go | starcoder |
package types
import (
"bytes"
"io"
"reflect"
"github.com/lyraproj/pcore/px"
)
type taggedType struct {
typ reflect.Type
puppetTags map[string]string
annotations px.OrderedMap
tags map[string]map[string]string
parsedPuppetTags map[string]px.OrderedMap
}
var TagsAnnotatio... | types/taggedtype.go | 0.547706 | 0.41739 | taggedtype.go | starcoder |
package datefmt
import (
"bytes"
"io"
"text/template"
"time"
"github.com/tigorlazuardi/datefmt/parser"
)
type Formatter struct {
parser.Parser
Day uint8
DayLong string
DayShort string
Hour uint8
Minute uint8
Month uint8
MonthLong string
MonthShort string
Pad... | datefmt.go | 0.697506 | 0.40869 | datefmt.go | starcoder |
package metrics
import (
"time"
e2eperftype "github.com/divinerapier/learn-kubernetes/test/e2e/perftype"
)
// LatencyMetric is a struct for dashboard metrics.
type LatencyMetric struct {
Perc50 time.Duration `json:"Perc50"`
Perc90 time.Duration `json:"Perc90"`
Perc99 time.Duration `json:"Perc99"`
Perc100 ti... | test/e2e/framework/metrics/pod.go | 0.756897 | 0.487917 | pod.go | starcoder |
package stats
import (
"context"
"time"
"github.com/dustin/go-humanize"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
)
type ctxKeyType string
const (
trailersKey ctxKeyType = "trailers"
chunksKey ctxKeyType = "chunks"
ingesterKey ctxKeyType = "ingester"
storeKey ctxKeyType = "store"
)... | pkg/logql/stats/context.go | 0.661595 | 0.465873 | context.go | starcoder |
package roman
import (
"fmt"
"strings"
)
var (
decimals = map[string]int{"": 0, "I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000}
values = []int{1, 5, 10, 50, 100, 500, 1000}
romans = map[int]string{0: "", 1: "I", 2: "II", 3: "III", 4: "IV", 5: "V", 6: "VI", 7: "VII", 8: "VIII", 9: "IX", 10: "... | roman.go | 0.650023 | 0.426262 | roman.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_kernel_pca
#include <capi/kernel_pca.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type KernelPcaOptionalParam struct {
Bandwidth float64
Center bool
Degree float64
KernelScale float64
NewDimensio... | kernel_pca.go | 0.726911 | 0.449091 | kernel_pca.go | starcoder |
// Package tdt contains Tag Data Translation module from binary to Pure Identity
package tdt
import (
"fmt"
"math"
"strconv"
"github.com/iomz/go-llrp/binutil"
)
// PartitionTableKey is used for PartitionTables
type PartitionTableKey int
// PartitionTable is used to get the related values for each coding scheme... | tdt/epc.go | 0.680454 | 0.489748 | epc.go | starcoder |
// Package errors implements functions to manipulate compression errors.
//
// In idiomatic Go, it is an anti-pattern to use panics as a form of error
// reporting in the API. Instead, the expected way to transmit errors is by
// returning an error value. Unfortunately, the checking of "err != nil" in
// tight l... | vendor/github.com/dsnet/compress/internal/errors/errors.go | 0.59302 | 0.400955 | errors.go | starcoder |
package luminance
import (
"image"
"image/color"
"math"
"sync"
colorful "github.com/lucasb-eyer/go-colorful"
"gonum.org/v1/gonum/mat"
)
const (
maxrange = 65535
dimension = 3
// padding space
paddingS = 2
// padding range (luminance)
paddingR = 2
)
// A FastBilateral filter is a non-linear, edge-preser... | luminance/fast_bilateral.go | 0.774071 | 0.543469 | fast_bilateral.go | starcoder |
package sdl2
import (
"fmt"
"github.com/veandco/go-sdl2/img"
"github.com/veandco/go-sdl2/sdl"
"github.com/evelritual/goose/graphics"
)
// TextureAtlas wraps an SDL Texture. It splits the texture into tiles to
// allow for easy drawing of sprites in a spritesheet.
type TextureAtlas struct {
renderer *sdl.Render... | internal/drivers/sdl2/textureatlas.go | 0.561696 | 0.46557 | textureatlas.go | starcoder |
package grid
import "math"
// Coordinate is an x, y location
type Coordinate struct {
X int
Y int
}
// Distance returns the distance between two points
func Distance(a Coordinate, b Coordinate) float64 {
distance := math.Sqrt(math.Pow(float64(b.X-a.X), 2) + math.Pow(float64(b.Y-a.Y), 2))
return distance
}
// E... | pkg/grid/coordinates.go | 0.922735 | 0.644519 | coordinates.go | starcoder |
package creator
import (
"github.com/pzduniak/unipdf/contentstream/draw"
"github.com/pzduniak/unipdf/model"
)
// Rectangle defines a rectangle with upper left corner at (x,y) and a specified width and height. The rectangle
// can have a colored fill and/or border with a specified width.
// Implements the Drawable ... | bot/vendor/github.com/pzduniak/unipdf/creator/rectangle.go | 0.851583 | 0.55917 | rectangle.go | starcoder |
package dct
import (
"fmt"
"math"
"gonum.org/v1/gonum/mat"
)
// F computes the forward discrete cosine transform of src and places it in dst,
// also returning dst.
// If dst is nil, a new matrix is allocated and returned.
func F(src, dst *mat.Dense) *mat.Dense {
r, c := src.Dims()
if r%2 != 0 || c%2 != 0 {
p... | dct.go | 0.685529 | 0.425426 | dct.go | starcoder |
package op
import (
"github.com/coschain/contentos-go/common/constants"
. "github.com/coschain/contentos-go/dandelion"
"github.com/coschain/contentos-go/prototype"
"github.com/coschain/contentos-go/tests/economist"
"github.com/stretchr/testify/assert"
"strconv"
"testing"
)
type VoteTester struct {
acc0, acc1,... | tests/op/vote.go | 0.568655 | 0.464962 | vote.go | starcoder |
package fields
import (
bls12377 "github.com/consensys/gnark-crypto/ecc/bls12-377"
"github.com/consensys/gnark/frontend"
)
// E6 element in a quadratic extension
type E6 struct {
B0, B1, B2 E2
}
// Add creates a fp6elmt from fp elmts
func (e *E6) Add(cs *frontend.ConstraintSystem, e1, e2 *E6) *E6 {
e.B0.Add(cs,... | std/algebra/fields/e6.go | 0.701917 | 0.5984 | e6.go | starcoder |
package geolite2v2
import (
"encoding/csv"
"errors"
"io"
"log"
"strconv"
"strings"
"github.com/m-lab/annotation-service/iputils"
)
var (
ipNumColumnsGlite2 = 10
)
// GeoIPNode defines IPv4 and IPv6 databases
type GeoIPNode struct {
iputils.BaseIPNode
LocationIndex int // Index to slice of locations
Posta... | geolite2v2/geo-ip-ip-loader.go | 0.52756 | 0.465995 | geo-ip-ip-loader.go | starcoder |
package convert
import (
"strconv"
"strings"
)
// StringToBool -- Converts a value from string to boolean
func StringToBool(value string) (bool, error) {
return strconv.ParseBool(strings.TrimSpace(value))
}
// StringToFloat32 -- Converts a value from string to float32
func StringToFloat32(value string) (float32,... | string.go | 0.856498 | 0.572364 | string.go | starcoder |
package lowest_common_ancestor_of_a_binary_search_tree
/*
235. 二叉搜索树的最近公共祖先 https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-search-tree
给定一个二叉搜索树, 找到该树中两个指定结点的最近公共祖先。
百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,
满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个结点也可以是它自己的祖先)。”
例如,给定如下二叉搜索树: root = [6,2,8,0,4,7,... | solutions/lowest-common-ancestor-of-a-binary-search-tree/d.go | 0.641759 | 0.515071 | d.go | starcoder |
package pcircle
import (
"strconv"
"strings"
)
// Background specifies parameters of beatmap background.
// Example of an Background:
// 0,0,"bg.jpg",0,0
type Background struct {
FileName string
XOffset, YOffset int
}
// String returns string of Background as it would be in .osu file
func (b Background)... | special.go | 0.864896 | 0.486454 | special.go | starcoder |
package input
import (
"encoding/json"
"errors"
"fmt"
"sync/atomic"
"time"
"github.com/Jeffail/benthos/v3/lib/condition"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/x/docs"
)
//-------------... | lib/input/read_until.go | 0.678007 | 0.581303 | read_until.go | starcoder |
package smd
import (
"fmt"
"strings"
"time"
"github.com/soniakeys/meeus/planetposition"
)
const (
// AU is one astronomical unit in kilometers.
AU = 1.49597870700e8
)
// CelestialObject defines a celestial object.
// Note: globe and elements may be nil; does not support satellites yet.
type CelestialObject st... | celestial.go | 0.682045 | 0.508117 | celestial.go | starcoder |
package grader
var _ BlockGrader = (*V5BlockGrader)(nil)
// V5BlockGrader implements the V5 grading algorithm.
// Entries are encoded in Protobuf with 25 winners each block.
// Valid assets can be found in ´opr.V5Assets´
type V5BlockGrader struct {
baseGrader
}
// Version 5
func (v5 *V5BlockGrader) Version() uint8 ... | modules/grader/v5grader.go | 0.795301 | 0.432183 | v5grader.go | starcoder |
package heap
import "github.com/badgerodon/goreify/generics"
//go:generate goreify github.com/badgerodon/container/heap.PairingHeap,pairingHeapNode numeric,string
// A PairingHeap implements the Heap interface using the Pairing Heap data structure
// see: wikipedia.org/wiki/Pairing_heap
type PairingHeap struct {
le... | heap/pairingheap.go | 0.703346 | 0.456591 | pairingheap.go | starcoder |
package kamakiri
import "math"
// Body is a physics body.
type Body struct {
World *World
ID uint // Reference unique identifier
Enabled bool // Enabled dynamics state (collisions are calculated anyway)
UseGravity bool // Apply gravity force to dynamics
IsGrounded ... | body.go | 0.790854 | 0.533337 | body.go | starcoder |
package apiclient
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
type Anomaly_AnomalyLevel int32
const (
Anomaly_UNKNOWN_ANOMALY_LEVEL Anomaly_Anom... | anomaly.pb.go | 0.593845 | 0.426859 | anomaly.pb.go | starcoder |
package prometheus
import (
"encoding/json"
"fmt"
"math"
"sort"
"strconv"
"strings"
)
// Response represents Prometheus's query response.
type Response struct {
// Status is the response status.
Status string `json:"status"`
// Data is the response data.
Data data `json:"data"`
}
type data struct {
// Re... | src/query/api/v1/handler/prometheus/response.go | 0.765637 | 0.424949 | response.go | starcoder |
package enum
import (
"errors"
"strconv"
"strings"
)
//RangeEnum is a special type of Enum that also allows indexing via numbers.
type RangeEnum interface {
Enum
NewImmutableRangeVal(indexes ...int) (ImmutableRangeVal, error)
NewRangeVal() RangeVal
MustNewImmutableRangeVal(indexes ...int) ImmutableRangeVal
... | enum/range.go | 0.732879 | 0.470493 | range.go | starcoder |
package assert
import (
"fmt"
"reflect"
"github.com/ppapapetrou76/go-testing/types"
)
func shouldBeEqual(actual types.Assertable, expected interface{}) string {
return fmt.Sprintf("assertion failed: expected value of = %+v, to be equal to %+v", actual.Value(), expected)
}
func shouldNotBeEqual(actual types.Asse... | assert/error.go | 0.79854 | 0.820937 | error.go | starcoder |
package potato
// DataList object is a list of something data
type DataList []interface{}
// Len implements length function for using sort
func (l DataList) Len() int {
return len(l)
}
// Swap implements swap function for using sort
func (l DataList) Swap(i, j int) {
l[i], l[j] = l[j], l[i]
}
// ByName is decorat... | potato/model_cache_datalist.go | 0.649579 | 0.523786 | model_cache_datalist.go | starcoder |
package linear
import (
"math"
)
/**
* Calculates the rank-revealing QR-decomposition of a matrix, with column pivoting.
* The rank-revealing QR-decomposition of a matrix A consists of three matrices Q,
* R and P such that AP=QR. Q is orthogonal (Q<sup>T</sup>Q = I), and R is upper triangular.
* If A is m×... | rrqr_decomposition.go | 0.866782 | 0.647534 | rrqr_decomposition.go | starcoder |
package constant
const CreatePolicyDocument = `
mutation createPolicy($namespace: String, $code: String!, $description: String, $statements: [PolicyStatementInput!]!) {
createPolicy(namespace: $namespace, code: $code, description: $description, statements: $statements) {
namespace
code
isDefault
desc... | lib/constant/gql_manage_policy.go | 0.728169 | 0.479016 | gql_manage_policy.go | starcoder |
package myplot
import "image/color"
// Maps a value to a color
type Colormapper interface {
Colormap(float64) color.Color
}
// Single Color is a colormap which returns a single color regardless
// of the value of the input
type Uniform struct {
Value color.Color
}
// Returns the color present in the struct
func (... | colormap.go | 0.879082 | 0.559471 | colormap.go | starcoder |
package bitarray
// ToggleBitAt flips a single bit at the position specified by off in the
// buffer.
func (buf *Buffer) ToggleBitAt(off int) {
switch {
case off < 0:
panicf("ToggleBitAt: negative off %d.", off)
case buf.nBits <= off:
panicf("ToggleBitAt: out of range: off=%d >= len=%d.", off, buf.nBits)
}
o... | buffer_bitwise.go | 0.608361 | 0.652823 | buffer_bitwise.go | starcoder |
package types
import (
"go/ast"
"github.com/redneckbeard/thanos/bst"
)
type Regexp struct {
*proto
}
var RegexpType = Regexp{newProto("Regexp", "Object", ClassRegistry)}
var RegexpClass = NewClass("Regexp", "Object", RegexpType, ClassRegistry)
func (t Regexp) Equals(t2 Type) bool { return t == t2 }
func (t Reg... | types/regexp.go | 0.550366 | 0.461441 | regexp.go | starcoder |
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
/* Solution rationale
*
* Consider a subtree t = [3,2,1] of a bigger tree T.
* The two leaves and its parent look, from a
* programmatic perspective, like this:
*
*
* ... | leetcode/104.maximum-depth-of-binary-tree.go | 0.833257 | 0.51562 | 104.maximum-depth-of-binary-tree.go | starcoder |
package main
import (
"errors"
"fmt"
)
type GraphType string
const (
DIRECTED = "DIRECTED"
UNDIRECTED = "UNDIRECTED"
)
type Node struct {
Next *Node
Weight int
Key int
}
type AdjacencyList struct {
Vertices int
Edges int
GraphType GraphType
AdjList []*Node
}
//Recursive method to add node... | Graphs/graphs_adjacency_list.go | 0.643441 | 0.42471 | graphs_adjacency_list.go | starcoder |
package gnat
import (
"bytes"
"math/big"
"net"
"strconv"
)
// NetworkNode is the over-the-wire representation of a node
type NetworkNode struct {
// ID is a 32 byte unique identifier
ID []byte
// IP is the IPv4 address of the node
IP net.IP
// Port is the port of the node
Port int
}
// node represents a ... | node.go | 0.684053 | 0.466724 | node.go | starcoder |
package bungieapigo
// Data regarding the progress of a Quest for a specific character. Quests are composed of
// multiple steps, each with potentially multiple objectives: this QuestStatus will return
// Objective data for the *currently active* step in this quest.
type DestinyQuestStatus struct {
// The hash ident... | pkg/models/DestinyQuestStatus.go | 0.510741 | 0.478833 | DestinyQuestStatus.go | starcoder |
package runes
import "unicode"
// IndexRune returns the index of the first instance of the Unicode code point
// r, or -1 if rune is not present in s.
func IndexRune(s []rune, c rune) int {
for i, b := range s {
if b == c {
return i
}
}
return -1
}
// Equal reports whether a and b
// are the same length an... | runes/runes.go | 0.761538 | 0.410343 | runes.go | starcoder |
Contains functions that manage the reading and writing of files related to package summarize.
This includes reading and interpreting JSON files as actionable data, memoizing function
results to JSON, and outputting results once the summarization process is complete.
*/
package summarize
import (
"bufio"
"encoding/j... | triage/summarize/files.go | 0.811377 | 0.474814 | files.go | starcoder |
package common
import (
"encoding/hex"
"fmt"
"math/big"
"github.com/altair-lab/xoreum/common/math"
)
const (
HashLength = 32
AddressLength = 32 // can be changed later
)
var (
// original
Difficulty = math.BigPow(2, 256-1) // mining difficulty: 10
// this is for test
//Difficulty = math.BigPow(2, 260... | common/types.go | 0.747247 | 0.406567 | types.go | starcoder |
package common
import (
s "github.com/uber/cadence/.gen/go/shared"
)
// IntPtr makes a copy and returns the pointer to an int.
func IntPtr(v int) *int {
return &v
}
// Int32Ptr makes a copy and returns the pointer to an int32.
func Int32Ptr(v int32) *int32 {
return &v
}
// Int64Ptr makes a copy and returns the ... | common/convert.go | 0.589007 | 0.436502 | convert.go | starcoder |
package main
import (
"github.com/go-gl/gl/v2.1/gl"
"github.com/go-gl/glfw/v3.1/glfw"
"github.com/vova616/chipmunk"
"github.com/vova616/chipmunk/vect"
"math"
"log"
"math/rand"
"os"
"runtime"
"time"
)
var (
ballRadius = 25
ballMass = 1
space *chipmunk.Space
balls []*chipmunk.Shape
staticL... | examples/glfw3/bouncing_balls/bouncing_balls.go | 0.53048 | 0.403537 | bouncing_balls.go | starcoder |
package discovery
import "fmt"
type Cover struct {
// A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic`
// Default: <no value>
Availability []Availability `json:"availability,omitempty"`
// When `availability` is configured, th... | cover.go | 0.850562 | 0.472379 | cover.go | starcoder |
package instasarama
import (
"bytes"
"encoding/hex"
"fmt"
"strings"
)
// The following functions perform the packing and unpacking of the trace context
// according to https://github.com/instana/technical-documentation/tree/master/tracing/specification#kafka
// PackTraceContextHeader packs the trace and span ID... | instrumentation/instasarama/record_header.go | 0.773388 | 0.4184 | record_header.go | starcoder |
package nmea0183
func DefaultSentances() *Sentences {
var defaults Sentences
defaults.formats = GetDefaultFormats()
defaults.variables = GetDefaultVars()
return &defaults
}
func GetDefaultVars() map[string]string{
vars := map[string]string {
"arrived_circle": "A",
"passed_waypt": "... | defaults.go | 0.76454 | 0.405154 | defaults.go | starcoder |
package list
import (
"testing"
"github.com/calebcase/base/data"
"github.com/calebcase/base/data/eq"
"github.com/calebcase/base/data/monoid"
)
type Class[A any] interface {
monoid.Class[List[A]]
}
type Type[
A any,
] struct {
monoid.Type[List[A]]
}
// Ensure Type implements Class.
var _ Class[int] = Type[in... | data/list/list.go | 0.665737 | 0.643133 | list.go | starcoder |
// Package jp provides holiday definitions for Japan.
package jp
import (
"github.com/rickar/cal/v2"
"github.com/rickar/cal/v2/aa"
"math"
"time"
)
var (
// Standard Japan weekend substitution rules: Sundays move to Monday
weekendAlt = []cal.AltDay{
{Day: time.Sunday, Offset: 1},
}
// NewYear represents Ne... | v2/jp/jp_holidays.go | 0.588416 | 0.665057 | jp_holidays.go | starcoder |
package xmath
type Evolution struct {
i int
combinations [][]float64
procedures []*Sequence
}
func NewEvolution(procedures ...*Sequence) *Evolution {
// build the parameter space
parameters := make([][]float64, len(procedures))
for i, proc := range procedures {
parameters[i] = proc.Run()
}
c... | oremi/vendor/github.com/drakos74/go-ex-machina/xmath/evolution.go | 0.82485 | 0.531209 | evolution.go | starcoder |
package iso20022
// Instruction to pay an amount of money to an ultimate beneficiary, on behalf of an originator. This instruction may have to be forwarded several times to complete the settlement chain.
type PaymentInstruction11 struct {
// Reference assigned by a sending party to unambiguously identify the payment... | PaymentInstruction11.go | 0.72952 | 0.427397 | PaymentInstruction11.go | starcoder |
package searchalg
import (
"math"
"math/rand"
"time"
)
const BOLTZMAN_CONSTANT = 8.6173432e-5
// Interface that has behavior for a model used to search the optimum solution
type Function interface {
// Return the value of objective function for the problem.
Compute() float64
// Reconfigure the value(s) of the ... | annealing.go | 0.633183 | 0.545286 | annealing.go | starcoder |
package network
import (
"bytes"
"strings"
"github.com/AnneNamuli/go-stellar/hash"
"github.com/AnneNamuli/go-stellar/support/errors"
"github.com/AnneNamuli/go-stellar/xdr"
)
const (
// PublicNetworkPassphrase is the pass phrase used for every transaction intended for the public stellar network
PublicNetworkP... | network/main.go | 0.819569 | 0.436502 | main.go | starcoder |
package effects
import (
"math"
"github.com/faiface/beep"
)
type (
// This parametric equalizer is based on the GK Nilsen's post at:
// https://octovoid.com/2017/11/04/coding-a-parametric-equalizer-for-audio-applications/
equalizer struct {
streamer beep.Streamer
sections []section
}
section struct {
... | effects/equalizer.go | 0.777511 | 0.703736 | equalizer.go | starcoder |
package bigcache
import (
"bytes"
)
type ringBuf struct {
begin int
size int
data []byte
}
func newRingBuf(size int) ringBuf {
return ringBuf{
begin: 0,
size: 0,
data: make([]byte, size),
}
}
func (r *ringBuf) append(data []byte) int {
n := len(data)
max := len(r.data)
end := r.getEnd()
copy(r.d... | ringbuf.go | 0.608245 | 0.416381 | ringbuf.go | starcoder |
package main
import (
"math"
"sync"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
// ZipfGenerator is a random number generator that generates draws from a Zipf
// distribution. Unlike rand.Zipf, this generator supports incrementing the
// imax parameter without performing an expensive recomputatio... | ycsb/zipfgenerator.go | 0.709523 | 0.433981 | zipfgenerator.go | starcoder |
package textures
// The Vers-0 Image Format Description is a collection of data defining the pixel format, data type, size, and other
// miscellaneous characteristics of the monolithic block of image data
type ImageV0 struct {
// Pixel format specifies the format of the texture image pixel data. Depending on the form... | jt/segments/textures/ImageV0.go | 0.682256 | 0.805096 | ImageV0.go | starcoder |
package mathexp
import (
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/expr/mathexp/parse"
)
// Results is a container for Value interfaces.
type Results struct {
Values Values
}
// Values is a slice of Value interfaces
type Values []Value
// AsDataFrames returns each value as a... | pkg/expr/mathexp/types.go | 0.852107 | 0.507507 | types.go | starcoder |
package table
/*
The table file format looks like:
<start_of_file>
[data block 0]
[data block 1]
...
[data block N-1]
[meta block 0]
[meta block 1]
...
[meta block K-1]
[metaindex block]
[index block]
[footer]
<end_of_file>
Each block consists of some data and a 5 byte trailer: a 1 byte block type and
a 4 byte check... | third_party/code.google.com/p/leveldb-go/leveldb/table/table.go | 0.59749 | 0.576304 | table.go | starcoder |
package types
import (
"fmt"
"math"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/trace_util_0"
)
// AddUint64 adds uint64 a and b if no overflow, else returns error.
func AddUint64(a uint64, b uint64) (uint64, error) {
trace_util_0.Count(_overflow_00000, 0)
if math.MaxUint64-a < b {
trace_util_0.Cou... | types/overflow.go | 0.63273 | 0.412057 | overflow.go | starcoder |
package reporting
import (
metrics "github.com/rcrowley/go-metrics"
"github.com/wavefronthq/wavefront-sdk-go/histogram"
)
// Histogram wrapper of Wavefront Histogram so it can be used with metrics.Registry
type Histogram struct {
delegate histogram.Histogram
}
// NewHistogram create a new Wavefront Histogram and ... | reporting/histogram.go | 0.892334 | 0.594669 | histogram.go | starcoder |
package moving_average
import (
"github.com/apache/arrow/go/arrow/array"
"github.com/wolffcm/flux/arrow"
"github.com/wolffcm/flux/values"
)
type ArrayContainer struct {
array array.Interface
}
func NewArrayContainer(a array.Interface) *ArrayContainer {
return &ArrayContainer{a}
}
func (a *ArrayContainer) IsNul... | internal/moving_average/array_container.go | 0.685529 | 0.517693 | array_container.go | starcoder |
package ec
import (
"crypto/elliptic"
"math/big"
)
// Koblitz curve math
// http://www.secg.org/sec2-v2.pdf 2.4.1
// https://github.com/mndrix/btcutil/blob/master/secp256k1.go
// https://github.com/btcsuite/btcd/blob/master/btcec/btcec.go
// KoblitzCurve A Koblitz Curve with a=0.
type KoblitzCurve struct {
*ellip... | commons/ec/secp256k1.go | 0.850453 | 0.487307 | secp256k1.go | starcoder |
// Package utf16 implements encoding and decoding of UTF-16 sequences.
package utf16
// The conditions replacementChar==unicode.ReplacementChar and
// maxRune==unicode.MaxRune are verified in the tests.
// Defining them locally avoids this package depending on package unicode.
const (
replacementChar = '\uFFFD' ... | src/pkg/unicode/utf16/utf16.go | 0.546496 | 0.436322 | utf16.go | starcoder |
package vectors
import (
"fmt"
"reflect"
)
var Bool = reflect.TypeOf(true)
var Int = reflect.TypeOf(int(1))
var Int8 = reflect.TypeOf(int8(1))
var Int16 = reflect.TypeOf(int16(1))
var Int32 = reflect.TypeOf(int32(1))
var Int64 = reflect.TypeOf(int64(1))
var Uint = reflect.TypeOf(uint(1))
var Uint8 = reflect.TypeOf(... | vectors/vectors.go | 0.642657 | 0.51129 | vectors.go | starcoder |
package neighbors
import (
"fmt"
"runtime"
"sort"
"github.com/pa-m/sklearn/base"
"github.com/pa-m/sklearn/metrics"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
)
// KNeighborsRegressor is a Regression based on k-nearest neighbors.
// The target is predicted by local interpolation of the targets
// asso... | neighbors/regression.go | 0.79649 | 0.44559 | regression.go | starcoder |
package strutil
import (
"math"
"strings"
)
// FillBytes fill the destination byte array with the given pattern.
func FillBytes(dst []byte, pattern []byte) {
for i := 0; i < len(dst); i++ {
dst[i] = pattern[i%len(pattern)]
}
}
// FillByte fills the destination byte array with a single byte.
func FillByte(dst [... | strutil/format.go | 0.703346 | 0.417153 | format.go | starcoder |
package f32
import (
"log"
"reflect"
"context"
)
func init() {
RegisterMatrix(reflect.TypeOf((*CSCMatrix)(nil)).Elem())
}
// CSCMatrix compressed storage by columns (CSC)
type CSCMatrix struct {
r int // number of rows in the sparse matrix
c int // number of columns in the sparse matrix
values... | f32/cscMatrix.go | 0.796292 | 0.49762 | cscMatrix.go | starcoder |
package pgs
// FieldType describes the type of a Field.
type FieldType interface {
// Field returns the parent Field of this type. While two FieldTypes might be
// equivalent, each instance of a FieldType is tied to its Field.
Field() Field
// Name returns the TypeName for this Field, which represents the type of... | ev/external/protoc-gen-validate/vendor/github.com/lyft/protoc-gen-star/field_type.go | 0.909868 | 0.46563 | field_type.go | starcoder |
package main
import (
"fmt"
"math"
"sort"
)
/*
The following program is implementation of Algorithm to find the shortest distance between 2 points from a set of points.
Time Complexity: O( n Log n )
*/
type Point struct {
X float64
Y float64
}
func NotEq(a Point, b Point) bool {
return !(a.X == b.X && a.Y =... | shortestDistance.go | 0.549157 | 0.566858 | shortestDistance.go | starcoder |
package giu
import (
"image"
"image/color"
"github.com/ImmortalHax/giu/imgui"
)
type Canvas struct {
drawlist imgui.DrawList
}
func GetCanvas() *Canvas {
return &Canvas{
drawlist: imgui.GetWindowDrawList(),
}
}
func (c *Canvas) AddLine(p1, p2 image.Point, color color.RGBA, thickness float32) {
c.drawlist.... | Canvas.go | 0.675122 | 0.441613 | Canvas.go | starcoder |
package matrix
func (P *PivotMatrix) Minus(A MatrixRO) (Matrix, error) {
if P.rows != A.Rows() || P.cols != A.Cols() {
return nil, ErrorDimensionMismatch
}
B := P.DenseMatrix()
B.Subtract(A)
return B, nil
}
func (P *PivotMatrix) Plus(A MatrixRO) (Matrix, error) {
if P.rows != A.Rows() || P.cols != A.Cols() {... | pivot_arithmetic.go | 0.789071 | 0.459986 | pivot_arithmetic.go | starcoder |
package iterables
type SliceIterable[K any] struct {
abstractIterable[K]
data []K
index int
}
func NewSliceIterable[K any](elements []K) Iterable[K] {
iter := &SliceIterable[K]{data: elements, index: 0}
iter.Iterable = iter
return iter
}
func (si *SliceIterable[K]) Next() (K, bool) {
if si.index < len(si.dat... | pkg/iterables/iterables.go | 0.597725 | 0.440529 | iterables.go | starcoder |
package models
type Currency struct {
Query struct {
Apikey string `json:"apikey"`
BaseCurrency string `json:"base_currency"`
Timestamp int `json:"timestamp"`
} `json:"query"`
Data struct {
JPY float64 `json:"JPY"`
CNY float64 `json:"CNY"`
CHF float64 `json:"CHF"`
CAD float64 `json:"CAD"`
... | models/Currency.go | 0.596668 | 0.463323 | Currency.go | starcoder |
package aoc2019
import (
"strconv"
"strings"
)
type step struct {
dir string
len int
}
type point struct {
x int
y int
}
func init() {
registerFun("03", SolveDay03)
}
func SolveDay03(input string) (interface{}, interface{}) {
firstPath, secondPath := parseInput(input)
var m = make(map[point]int)
walk(f... | aoc2019/day03.go | 0.588298 | 0.414129 | day03.go | starcoder |
package faststats
import (
"math"
"sort"
"sync/atomic"
)
// Percentile implements an efficient percentile calculation of
// arbitrary float64 samples.
type Percentile struct {
percentile float64
samples int64
offset int64
values []float64
value uint64 // These bits are really a float64.
}
// NewPercenti... | percentile.go | 0.832985 | 0.653438 | percentile.go | starcoder |
package collision
import (
"github.com/teomat/mater/vect"
"math"
)
// Used to keep a linked list of all arbiters on a body.
type ArbiterEdge struct {
Arbiter *Arbiter
Next, Prev *ArbiterEdge
Other *Body
}
// The maximum number of ContactPoints a single Arbiter can have.
const MaxPoints = 2
type Arbiter... | collision/arbiter.go | 0.773473 | 0.520253 | arbiter.go | starcoder |
package midi
import (
"encoding/binary"
"errors"
"fmt"
"io"
)
type timeFormat int
type nextChunkType int
const (
MetricalTF timeFormat = iota + 1
TimeCodeTF
)
const (
eventChunk nextChunkType = iota + 1
trackChunk
)
/*Decoder Format documented there: http://www.music.mcgill.ca/~ich/classes/mumt306/midiform... | decoder.go | 0.716615 | 0.493348 | decoder.go | starcoder |
package parser
import (
"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/google/cel-go/common"
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)
type parserHelper struct {
source common.Source
nextID int64
positions map[int64]int32
}
func newParserHelper(source common.Source) *par... | parser/helper.go | 0.572962 | 0.462352 | helper.go | starcoder |
package types
import (
"bytes"
"fmt"
"sync"
)
type Node interface {
Uses() []Usage
}
type Type interface {
Sizeof() int
Kind() Kind
GoType() GoType
}
func UnkT(size int) Type {
if size <= 0 {
panic("size must be specified; set to ptr size, for example")
}
return &unkType{size: size}
}
type unkType stru... | types/types.go | 0.52683 | 0.446555 | types.go | starcoder |
package influxdb
import (
"fmt"
"github.com/influxdata/flux/ast"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/influxdb/v2/models"
"github.com/influxdata/influxdb/v2/storage/reads/datatypes"
"github.com/pkg/errors"
)
// ToStoragePredicate will convert a FunctionExpression into a predicate that c... | query/stdlib/influxdata/influxdb/storage_predicate.go | 0.646572 | 0.600188 | storage_predicate.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.