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 eestream
import (
"bytes"
"io"
"io/ioutil"
"github.com/jtolds/eestream/ranger"
)
// A Transformer is a data transformation that may change the size of the blocks
// of data it operates on in a deterministic fashion.
type Transformer interface {
InBlockSize() int // The block size prior to transformati... | transform.go | 0.678433 | 0.460592 | transform.go | starcoder |
package storage
import (
"sort"
)
type Cursor struct {
db *DB
level uint16
reducer map[string]string
stack []elemRef
}
// fix position to insert data.
func (c *Cursor) fix(t *Time, n *node) error {
e := elemRef{node: n}
c.stack = append(c.stack, e)
if e.isLeaf() {
if t.Level()>>1 <= n.level {
... | storage/cursor.go | 0.606848 | 0.423518 | cursor.go | starcoder |
package crypto
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"time"
"unicode/utf8"
"golang.org/x/crypto/ed25519"
)
const (
// PasswordMinLength defines the minimum size accepted for a password
PasswordMinLength = 16
// NameMinLen is the minimum length of a name
NameMinLen = 1
// NameMaxLen is the ma... | crypto/validators.go | 0.672762 | 0.413152 | validators.go | starcoder |
package eZmaxApi
import (
"encoding/json"
)
// EzsignsignerRequestCompound An Ezsignsigner Object and children to create a complete structure
type EzsignsignerRequestCompound struct {
ObjContact EzsignsignerRequestCompoundContact `json:"objContact"`
// The unique ID of the Taxassignment. Valid values: |Value|De... | model_ezsignsigner_request_compound.go | 0.645232 | 0.465813 | model_ezsignsigner_request_compound.go | starcoder |
package constant
// NamespaceScope Operator CR
const NamespaceScopeCR = `
apiVersion: operator.ibm.com/v1
kind: NamespaceScope
metadata:
name: common-service
namespace: placeholder
spec:
namespaceMembers:
- placeholder
restartLabels:
intent: projected
`
// NamespaceScope Operator RBAC
const NamespaceS... | controllers/constant/namespace.go | 0.83104 | 0.403949 | namespace.go | starcoder |
package main
// Day 3: Binary Diagnostic
// Part 1: Calculate most common & least common bit in a list of binary numbers
// Part 1: Answer is the decimal product of above
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
"strings"
)
func check(e error) {
if e != nil {
panic(e)
}
}
// 2d slice
// dy is number o... | vsherr/03/main.go | 0.66769 | 0.411702 | main.go | starcoder |
package lm
import "math"
type Vector3 struct {
X, Y, Z float32
}
func Vec3(x, y, z float32) Vector3 {
return Vector3{
X: x,
Y: y,
Z: z,
}
}
func (lhs Vector3) Add(rhs Vector3) Vector3 {
x := lhs.X + rhs.X
y := lhs.Y + rhs.Y
z := lhs.Z + rhs.Z
return Vec3(x, y, z)
}
func (lhs Vector3) MulScalar(rhs flo... | lm/vector3.go | 0.878484 | 0.583797 | vector3.go | starcoder |
package stats
import (
"errors"
"github.com/hscells/cqr"
"github.com/hscells/groove/pipeline"
"github.com/hscells/trecresults"
"math"
"strconv"
)
// SearchOptions are options that the statistics source will use for retrieval.
type SearchOptions struct {
Size int
RunName string
}
// TermVectorTerm is a ter... | stats/statisticssource.go | 0.821474 | 0.505188 | statisticssource.go | starcoder |
package cardlib
import (
"fmt"
"github.com/fatih/color"
"math/rand"
"time"
)
var Spades = []string{`๐ก`, `๐ข`, `๐ฃ`, `๐ค`, `๐ฅ`, `๐ฆ`, `๐ง`, `๐จ`, `๐ฉ`, `๐ช`, `๐ซ`, `๐ญ`, `๐ฎ`}
var Hearts = []string{`๐ฑ`, `๐ฒ`, `๐ณ`, `๐ด`, `๐ต`, `๐ถ`, `๐ท`, `๐ธ`, `๐น`, `๐บ`, `๐ป`, `๐ฝ`, `๐พ`}
var Diamonds = []string{`๐`, `๐`, `... | cardlib/cards.go | 0.539954 | 0.519643 | cards.go | starcoder |
package plaid
import (
"encoding/json"
)
// VerificationAttribute Details about a certain reason as to why a document could potentially be fraudulent
type VerificationAttribute struct {
// Message indicating the reason as to why the verification failed
Type NullableString `json:"type"`
AdditionalProperties map[s... | plaid/model_verification_attribute.go | 0.781289 | 0.419529 | model_verification_attribute.go | starcoder |
package main
import "fmt"
import "github.com/a-h/linear"
import "flag"
import "github.com/a-h/round"
var quiz = flag.Int("quiz", 0, "The quiz to return the answers for.")
func main() {
flag.Parse()
fmt.Printf("Printing answers for quiz %d.\n", *quiz)
switch *quiz {
case 1:
quiz1()
case 2:
quiz2()
case 3:... | cmd/main.go | 0.50952 | 0.411554 | main.go | starcoder |
package cpu
// Register is an internal type for simple referencing of registers.
type register byte
// an enum is used to represent the register names including the 16bit values.
const (
a register = 0x7
b = 0x0
c = 0x1
d = 0x2
e = 0x3
h = 0x4
l = 0x5
f ... | cpu/registers.go | 0.777849 | 0.419529 | registers.go | starcoder |
package graph
import (
"github.com/K-Phoen/grabana/alert"
"github.com/K-Phoen/grabana/axis"
"github.com/K-Phoen/grabana/target/prometheus"
"github.com/K-Phoen/grabana/target/stackdriver"
"github.com/grafana-tools/sdk"
)
// Option represents an option that can be used to configure a graph panel.
type Option func(... | graph/graph.go | 0.801159 | 0.503357 | graph.go | starcoder |
package nb
import "github.com/ContextLogic/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE d. MMMM y", Long: "d. MMMM y", Medium: "d. MMM y", Short: "dd.MM.y"},
Time: cldr.CalendarDateFormat{Full: "HH.mm.ss zzzz", Long: "HH.mm.ss z", Medium: "H... | resources/locales/nb/calendar.go | 0.527317 | 0.444022 | calendar.go | starcoder |
package client
const chatAPIDoc = `"keybase chat api" provides a JSON API to the Keybase chat service.
EXAMPLES:
List inbox:
{"method": "list"}
Read a conversation:
{"method": "read", "params": {"options": {"channel": {"name": "you,them"}}}}
Read a conversation (paginated):
{"method": "read", "params":... | go/client/chat_api_doc.go | 0.502441 | 0.48054 | chat_api_doc.go | starcoder |
package topo
import (
"fmt"
"strings"
"github.com/youtube/vitess/go/vt/key"
pb "github.com/youtube/vitess/go/vt/proto/topodata"
)
// This file contains the methods to convert topo structures to proto3.
// Eventually we will use the proto3 data structures directly.
// TabletTypeToProto turns a TabletType into ... | go/vt/topo/proto3.go | 0.558809 | 0.483344 | proto3.go | starcoder |
package aws
var USGovWest = Region{
"us-gov-west-1",
"https://ec2.us-gov-west-1.amazonaws.com",
"https://s3-fips-us-gov-west-1.amazonaws.com",
"",
true,
true,
"",
"",
"https://sns.us-gov-west-1.amazonaws.com",
"https://sqs.us-gov-west-1.amazonaws.com",
"https://iam.us-gov.amazonaws.com",
"https://elasticlo... | vendor/github.com/goamz/goamz/aws/regions.go | 0.608594 | 0.421909 | regions.go | starcoder |
package magic
import (
"fmt"
"reflect"
)
// Converter is a custom converter for differect types
type Converter func(from, to reflect.Value) (bool, error)
// isPtrOf checks that v1.Type is ptr of v2.Type
func isPtrOf(v1, v2 reflect.Value) bool {
if v1.Type().Kind() != reflect.Ptr {
return false
}
return v1.Ty... | magic.go | 0.603932 | 0.557243 | magic.go | starcoder |
package npcolor
import (
"image/color"
)
// GrayM represents an 8-bit grayscale value and the value to represent 100%
// white. Because GrayM does not support alpha channels it does make sense to
// describe it as either "alpha-premultiplied" or "non-alpha-premultiplied".
type GrayM struct {
Y, M uint8
}
// RGBA ... | npcolor/npcolor.go | 0.878523 | 0.488344 | npcolor.go | starcoder |
package kiwi
import (
"fmt"
"math"
"strings"
)
type row struct {
constant float64
cells map[*symbol]float64
}
type rowOption func(*row)
func withConstant(constant float64) rowOption {
return func(r *row) {
r.constant = constant
}
}
func newRow(options ...rowOption) *row {
r := &row{cells: map[*symbol... | row.go | 0.813461 | 0.578091 | row.go | starcoder |
package bn256
// For details of the algorithms used, see "Multiplication and Squaring on
// Pairing-Friendly Fields, Devegili et al.
// http://eprint.iacr.org/2006/471.pdf.
// gfP2 implements a field of size pยฒ as a quadratic extension of the base field
// where iยฒ=-1.
type gfP2 struct {
x, y gfP // value is xi+y.
}... | ioporaclenode/internal/pkg/kyber/pairing/bn256/gfp2.go | 0.784443 | 0.418875 | gfp2.go | starcoder |
package assert
import (
"testing"
"github.com/ppapapetrou76/go-testing/internal/pkg/values"
)
// AssertableString is the implementation of CommonAssertable for string types
type AssertableString struct {
t *testing.T
actual values.StringValue
}
// ThatString returns an AssertableString structure initialize... | assert/string.go | 0.774541 | 0.725211 | string.go | starcoder |
package query
import (
sitter "github.com/smacker/go-tree-sitter"
"go.lsp.dev/protocol"
"go.lsp.dev/uri"
)
// PositionToPoint converts an LSP protocol file location to a Tree-sitter file location.
func PositionToPoint(pos protocol.Position) sitter.Point {
return sitter.Point{
Row: pos.Line,
Column: pos.Cha... | vendor/github.com/tilt-dev/starlark-lsp/pkg/query/location.go | 0.782247 | 0.620909 | location.go | starcoder |
package ast
import "github.com/lukasmalkmus/spl/internal/app/spl/token"
// Node represents an element in the simple programming languages abstract
// syntax tree (AST).
type Node interface {
// Pos returns the position of the first character belonging to the node.
Pos() token.Position
// End returns the position ... | internal/app/spl/ast/ast.go | 0.743447 | 0.507141 | ast.go | starcoder |
package anomalyFilters
import (
"fmt"
"github.com/trackit/trackit/costs/anomalies/anomalyType"
)
type (
// genericFilter implements valid called to validate
// the data received by postAnomaliesFilters and apply
// to apply the filter to anomaly results.
// All filters have to implement genericFilter.
generic... | costs/anomalies/anomalyFilters/generic.go | 0.640299 | 0.452899 | generic.go | starcoder |
package interp
import (
"image"
"image/color"
"math"
)
// Bilinear implements bilinear interpolation.
var Bilinear Interp = bilinear{}
type bilinear struct{}
func (i bilinear) Interp(src image.Image, x, y float64) color.Color {
if src, ok := src.(*image.RGBA); ok {
return i.RGBA(src, x, y)
}
return bilinea... | interp/bilinear.go | 0.809125 | 0.682005 | bilinear.go | starcoder |
package base58
import (
"fmt"
)
// Encode encodes the passed bytes into a base58 encoded string.
func Encode(bin []byte) string {
return FastBase58EncodingAlphabet(bin, BTCAlphabet)
}
// EncodeAlphabet encodes the passed bytes into a base58 encoded string with the
// passed alphabet.
func EncodeAlphabet(bin []byte... | util/base58/base58.go | 0.760562 | 0.405449 | base58.go | starcoder |
package bls12381
const coefficientsG2 = 68
type Engine struct {
pairs []pair
}
type pair struct {
g1 G1
g2 G2
}
type g2Prepared struct {
identity int
coefficients []coefficients
}
type coefficients struct {
a, b, c fp2
}
func (c *coefficients) CMove(arg1, arg2 *coefficients, choice int) *coefficients {
... | pkg/core/curves/native/bls12381/pairings.go | 0.642769 | 0.438605 | pairings.go | starcoder |
package plan
import (
"fmt"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
)
// InSubquery is an expression that checks an expression is in the result of a subquery. It's in the plan package,
// instead of the expression package, because Subquery is itself in the pla... | sql/plan/insubquery.go | 0.599016 | 0.48688 | insubquery.go | starcoder |
package gotest
import (
"regexp"
"github.com/openshift/origin/tools/junitreport/pkg/api"
)
func newTestDataParser() testDataParser {
return testDataParser{
// testStartPattern matches the line in verbose `go test` output that marks the declaration of a test.
// The first submatch of this regex is the name of ... | tools/junitreport/pkg/parser/gotest/data_parser.go | 0.641198 | 0.603932 | data_parser.go | starcoder |
package ftree
import (
"fmt"
"sort"
"golang.org/x/exp/rand"
"gonum.org/v1/gonum/stat/distuv"
)
// A Config describes the parameters used to generate a filetree with the
// Generate call.
type Config struct {
// The random source fo the generation
Src rand.Source
// Number of files to generate
NumFiles uint6... | ftree/gen.go | 0.604983 | 0.511778 | gen.go | starcoder |
package input
import (
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/mqttconf"
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffai... | lib/input/mqtt.go | 0.662469 | 0.63751 | mqtt.go | starcoder |
package hash
// CyclicPoly provides a cyclic polynomial rolling hash.
type CyclicPoly struct {
h uint64
p []uint64
i int
}
// ror rotates the unsigned 64-bit integer to right. The argument s must be
// less than 64.
func ror(x uint64, s uint) uint64 {
return (x >> s) | (x << (64 - s))
}
// NewCyclicPoly creates... | vendor/github.com/ulikunitz/xz/internal/hash/cyclic_poly.go | 0.733165 | 0.47384 | cyclic_poly.go | starcoder |
package copypasta
import "sort"
/* ๆ ็ถๆฐ็ป๏ผFenwick Tree๏ผ๏ผไบๅ็ดขๅผๆ ๏ผBinary Index Tree, BIT๏ผ
https://en.wikipedia.org/wiki/Fenwick_tree
ๆ ็ถๆฐ็ป็ๅบๆฌ็จ้ๆฏ็ปดๆคๅบๅ็ๅ็ผๅ
tree[i] = a[i-lowbit(i)+1] + ... + a[i]
ๅฏไปฅ็ๅๆฏไธไธชๅ ๅปไบๅณๅฟๅญ็็บฟๆฎตๆ
ๆจ่้
่ฏปใ็ฎๆณ็ซ่ต่ฟ้ถๆๅใ0x42 ่
https://oi-wiki.org/ds/bit/
todo ๆ ็ถๆฐ็ปๅปถ็ณๅบ็จ https://www.luogu.com.cn/blog/kingxbz/shu-zhuang-s... | copypasta/fenwick_tree.go | 0.59561 | 0.409634 | fenwick_tree.go | starcoder |
package migrate
import (
"regexp"
"strings"
)
type AssertResult struct {
match bool
caller string
actual string
checker string
expect string
}
func Equals(line string) (*AssertResult, error) {
p := `(?P<caller>\w+)\.Assert\((?P<actual>.+),(?P<checker>\s*Equals),(?P<expect>.+)\)`
return Assert(line, p)
... | migrate/assert.go | 0.566498 | 0.460895 | assert.go | starcoder |
package world
import (
"github.com/df-mc/atomic"
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/sirupsen/logrus"
"math/rand"
"time"
)
// Config may be used to create a new World. It holds a variety of fields that influence the World.
type Config struct {
// Log is the Logger that will be used to log... | server/world/conf.go | 0.575469 | 0.456107 | conf.go | starcoder |
package state
import (
"errors"
"io"
"os"
"github.com/NebulousLabs/Sia/siacrypto"
"github.com/NebulousLabs/Sia/siaencoding"
"github.com/NebulousLabs/Sia/sialog"
)
type StorageProof struct {
AtomBase [AtomSize]byte
HashStack []*siacrypto.Hash
}
var ErrEmptyQuorum = errors.New("quorum is not storing any data... | state/proofofstorage.go | 0.625781 | 0.546799 | proofofstorage.go | starcoder |
package stats
import (
"fmt"
"io"
"log"
"sort"
"github.com/edotau/goFish/simpleio"
"github.com/vertgenlab/gonomics/numbers"
)
type PeakStats struct {
Chr string
Start int
End int
Score int
Matrix *FisherExact
LeftPvalue float64
RightPvalue float64
}
type DiffPeak struc... | stats/fisher.go | 0.563378 | 0.416025 | fisher.go | starcoder |
package Models
import (
"bytes"
"crypto/sha256"
)
type Tree struct {
RootNode *Node
}
type Node struct {
Data []byte
LeftNode *Node
RightNode *Node
}
func CreateTree(transactions []*Transaction) *Tree {
if transactions == nil || len(transactions) == 0 {
return nil
}
treeArray := createTreeArray(tra... | Models/MerkleTreeModel.go | 0.607314 | 0.408749 | MerkleTreeModel.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Benini distribution
// https://en.wikipedia.org/wiki/Benini_distribution
type Benini struct {
baseContinuousWithSource
alpha, beta, sigma float64
}
func NewBenini(al... | dist/continuous/benini.go | 0.80784 | 0.498901 | benini.go | starcoder |
package metricdata
import (
"time"
)
// Point is a single data point of a time series.
type Point struct {
// Time is the point in time that this point represents in a time series.
Time time.Time
// Value is the value of this point. Prefer using ReadValue to switching on
// the value type, since new... | vendor/github.com/elastic/beats/vendor/go.opencensus.io/metric/metricdata/point.go | 0.758958 | 0.538194 | point.go | starcoder |
package iso20022
// Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another.
type SettlementParties44 struct {
// First party in the set... | SettlementParties44.go | 0.680985 | 0.482124 | SettlementParties44.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// SyntheticsAssertionJSONPathTarget An assertion for the `validatesJSONPath` operator.
type SyntheticsAssertionJSONPathTarget struct {
Operator SyntheticsAssertionJSONPathOperator `json:"operator"`
// The associated assertion property.
Property *string ... | api/v1/datadog/model_synthetics_assertion_json_path_target.go | 0.745398 | 0.418994 | model_synthetics_assertion_json_path_target.go | starcoder |
package sudoku
import (
"errors"
"fmt"
"strings"
)
// Numerical constants related to the board, such as number of cells, number of cells on one side or maximal cell value.
const (
BoardSize = 81 // Size of the board, the number of cells
BoardSide = 9 // Size of one side of the board
BoardBoxSize = 3 // ... | solver.go | 0.685529 | 0.478651 | solver.go | starcoder |
package number
import (
"math"
"math/rand"
"strconv"
"strings"
)
/*
* Return random int value between 0 and max-1
*/
func RandomInt(max int) int {
return rand.Intn(max)
}
/*
* Return the min value between a1 and a2
*/
func Min(a1, a2 float64) float64 {
if a1 < a2 {
return a1
}
return a2
}
/*
* Return th... | number/number_helper.go | 0.561696 | 0.455441 | number_helper.go | starcoder |
package ring
import (
"github.com/dedis/lago/bigint"
"github.com/dedis/lago/polynomial"
)
type Ring struct {
N uint32
Q bigint.Int
Poly *polynomial.Poly
}
// NewRing creates a new polynomial ring with given parameters.
func NewRing(n uint32, q bigint.Int, nttParams *polynomial.NttParams) (*Ring, error) {
r := ... | ring/ring.go | 0.808294 | 0.452838 | ring.go | starcoder |
package k8saudit
import (
"github.com/falcosecurity/plugin-sdk-go/pkg/sdk"
)
// Fields returns the list of extractor fields exported for K8S Audit events.
func Fields() []sdk.FieldEntry {
return []sdk.FieldEntry{
{
Type: "string",
Name: "ka.auditid",
Desc: "The unique id of the audit event",
},
{
... | plugins/k8saudit/pkg/k8saudit/fields.go | 0.555676 | 0.453564 | fields.go | starcoder |
package document
import (
"baliance.com/gooxml"
"baliance.com/gooxml/measurement"
"baliance.com/gooxml/schema/soo/wml"
)
// TableProperties are the properties for a table within a document
type TableProperties struct {
x *wml.CT_TblPr
}
// X returns the inner wrapped XML type.
func (t TableProperties) X() *wml.... | document/tableproperties.go | 0.774285 | 0.485783 | tableproperties.go | starcoder |
package gomel
import (
"fmt"
)
// DataError represents incorrect data received from a process.
// Indicates a problem with the process providing the data.
type DataError struct {
msg string
}
// Error returns a string description of a DataError.
func (e *DataError) Error() string {
return "DataError: " + e.msg
}
... | pkg/gomel/errors.go | 0.856062 | 0.436142 | errors.go | starcoder |
package main
import "fmt"
/*
Problem:
Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container co... | Programs/011Container With Most Water/011Container With Most Water.go | 0.545528 | 0.551634 | 011Container With Most Water.go | starcoder |
3D Printable Nuts and Bolts
*/
//-----------------------------------------------------------------------------
package main
import (
"fmt"
"github.com/deadsy/sdfx/sdf"
)
//-----------------------------------------------------------------------------
// Tolerance: Measured in mm. Typically 0.0 to 0.4. Larger is... | examples/3dp_nutbolt/main.go | 0.670608 | 0.421552 | main.go | starcoder |
package boids
import (
//"fmt"
"math"
"math/rand"
)
type PVector struct {
X float64
Y float64
Z float64
}
func NewPVector2D(x float64, y float64) PVector {
return PVector{x, y, 0}
}
func NewPVectorFromAngle(angle float64) PVector {
result := PVector{}
result.X = math.Cos(angle)
result.Y = math.Sin(angle)... | pvector.go | 0.876278 | 0.667043 | pvector.go | starcoder |
package p224
import "math/bits"
type uint1 uint8
type int1 int8
/* The function addcarryxU64 is a thin wrapper around bits.Add64 that uses uint1 rather than uint64 */
func addcarryxU64(x uint64, y uint64, carry uint1) (uint64, uint1) {
var sum uint64
var carryOut uint64
sum, carryOut = bits.Add64(x, y, uint64(... | fiat-go/64/p224/p224.go | 0.502197 | 0.407864 | p224.go | starcoder |
package linear
// Implementation of RealMatrix using a [][]float64 to store entries.
type Array2DRowRealMatrix struct {
data [][]float64
}
func NewArray2DRowRealMatrix(rowDimension, columnDimension int) (*Array2DRowRealMatrix, error) {
if rowDimension < 1 {
return nil, notStrictlyPositiveErrorf(float64(rowDimensi... | array_2d_row_real_matrix.go | 0.803791 | 0.552721 | array_2d_row_real_matrix.go | starcoder |
package dmc
import "image/color"
func NewColorBank() *DmcColors {
cb := fillColorBank()
return cb
}
// Determine DMC color from RBG (Red, Green, Blue) values
func (d *DmcColors) RgbA(col color.Color) (float64, float64, float64) {
return d.RgbaToRgb(col)
}
// Determine DMC color from RBG (Red, Green, Blue) val... | dmc.go | 0.869271 | 0.635844 | dmc.go | starcoder |
package api
import (
"context"
"encoding/json"
)
// AnomalyType is the type of a task.
type AnomalyType string
const (
AnomalyInstanceConnection AnomalyType = "bb.anomaly.instance.connection"
AnomalyInstanceMigrationSchema AnomalyType = "bb.anomaly.instance.migration-schema"
AnomalyDatabaseBack... | api/anomaly.go | 0.665954 | 0.422803 | anomaly.go | starcoder |
package labels
import (
"fmt"
pf "github.com/estuary/flow/go/protocols/flow"
)
// ShardLabeling is a parsed and validated representation of the Flow
// labels which are attached to Gazette ShardSpecs, that are understood
// by the Flow runtime and influence its behavior with respect to the shard.
type ShardLabelin... | go/labels/shard.go | 0.642096 | 0.450903 | shard.go | starcoder |
package common
import (
"bytes"
"encoding/binary"
"fmt"
"strconv"
"strings"
)
// PadZero Fills the zero into the byte slice.
// parameter "count", the number of zreo to be filled.
func PadZero(count int) []byte {
zero := make([]byte, 0)
for i := 0; i < count; i++ {
zero = append(zero, 0x00)
}
return zero
}... | worksys/common/byteutil.go | 0.556882 | 0.453625 | byteutil.go | starcoder |
package bban
// EntryType represents a type of bban part.
type EntryType int
// charType represents a character type of given bban part.
type charType int
const (
// BankCode represents bank code part of iban.
BankCode EntryType = iota
// BranchCode represents branch code part of iban.
BranchCode
// AccountNu... | bban/structure.go | 0.803212 | 0.462473 | structure.go | starcoder |
package zrrtest
import (
"fmt"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/rzajac/zrr"
)
// AssertCause asserts err is instance of zrr.Error and has error
// message (without key value pairs) equal to cause.
func AssertCause(t *testing.T, ... | zrrtest/assertions.go | 0.572006 | 0.458591 | assertions.go | starcoder |
package tsragg
import (
"math"
"github.com/emer/etable/agg"
"github.com/emer/etable/etensor"
)
// Count returns the count of non-Null, non-NaN elements in given Tensor.
func Count(tsr etensor.Tensor) float64 {
return tsr.Agg(0, agg.CountFunc)
}
// Sum returns the sum of non-Null, non-NaN elements in given Tenso... | tsragg/tsragg.go | 0.872225 | 0.744703 | tsragg.go | starcoder |
// Package transform2 contains the elements to be able to transform
// commands which consist of interfaces for individual transform operations
// and a transform chain to run all of them.
package transform2
import (
"context"
"github.com/google/gapid/gapis/api"
)
// Transform is the interface that wraps the basi... | gapis/api/transform2/transform.go | 0.560012 | 0.4953 | transform.go | starcoder |
package testtools
import (
"crypto/ecdsa"
"crypto/rsa"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"github.com/smartedge/codechallenge"
"github.com/smartedge/codechallenge/crypt"
"github.com/smartedge/codechallenge/deps"
"github.com/xeipuuv/gojsonschema"
"os"
"path/filepath"
"reflect"
"regexp"
"sort"
... | testtools/utils.go | 0.624637 | 0.484807 | utils.go | starcoder |
package imagex
import (
"github.com/maxfish/go-libs/pkg/geom"
"image"
"image/draw"
)
// BuildAtlas generates an atlas image and returns it. It also returns info on how the rects have been packed
func BuildAtlas(images []*image.RGBA, paddingX, paddingY int, allowRotation bool) (*image.RGBA, []geom.RectNode) {
resu... | pkg/imagex/atlas.go | 0.59408 | 0.520009 | atlas.go | starcoder |
package interlace
import (
"fmt"
"log"
"math"
"strconv"
"strings"
)
const debug = false
// TwoDimensionalInterlace64 takes two float64 arguments (latitude, longitude) and returns an int64.
// The return value is the address to the corresponding geographic block according to this algorithm.
func TwoDimensionalIn... | interlace.go | 0.608594 | 0.419707 | interlace.go | starcoder |
package v1alpha1
func (DataVolume) SwaggerDoc() map[string]string {
return map[string]string{
"": "DataVolume provides a representation of our data volume\n+genclient\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object",
}
}
func (DataVolumeSpec) SwaggerDoc() map[string]string {
return map[stri... | vendor/kubevirt.io/containerized-data-importer/pkg/apis/core/v1alpha1/types_swagger_generated.go | 0.814607 | 0.475362 | types_swagger_generated.go | starcoder |
package matchers
import (
"github.com/onsi/gomega/types"
"github.com/sclevine/agouti/matchers/internal/selection"
)
// HaveText passes when the expected text is equal to the actual element text.
// This matcher will fail if the provided selection refers to more than one element.
func HaveText(text string) types.Gom... | src/acceptance-tests/vendor/src/github.com/sclevine/agouti/matchers/selection_matchers.go | 0.877883 | 0.597021 | selection_matchers.go | starcoder |
package telegrafreceiver
import (
"time"
"github.com/influxdata/telegraf"
"go.opentelemetry.io/collector/model/pdata"
)
// MetricOpt is an option func that takes in a pdata.Metric and manipulates it.
type MetricOpt func(m pdata.Metric)
// WithName returns a MetricOpt which will set the returned metric name.
fun... | pkg/receiver/telegrafreceiver/metric_opt.go | 0.832134 | 0.402627 | metric_opt.go | starcoder |
package main
import (
"fmt"
"time"
)
// Function sum sums all the elements of the input slice,
// then sends the computed sum value inside a channel that
// receives integer values
func sum(sl []int, ch chan int) {
sum := 0
for _, v := range sl {
sum += v
}
// Wait till ch is ready to receive values, then sen... | go-code-examples/concurrency/channels/channels.go | 0.539954 | 0.448426 | channels.go | starcoder |
package core
import (
"math"
"runtime"
"sort"
"github.com/go-gl/mathgl/mgl64"
"github.com/golang/glog"
)
// Scene represents a scenegraph and contains information about how it should be composed with other scenes on
// a scene stack. Scenes are not meant to be wrapped by users, but to be data configured for the... | core/scene.go | 0.821188 | 0.419053 | scene.go | starcoder |
package probability
import (
"github.com/hscells/groove/analysis"
"github.com/hscells/groove/pipeline"
"github.com/hscells/groove/stats"
)
// Probability computes the likelihood of a Measurement affecting precision and recall. For this interface
// to be properly implemented, four probabilities must be implemented... | analysis/probability/measurement.go | 0.895388 | 0.633495 | measurement.go | starcoder |
package forGraphBLASGo
import "github.com/intel/forGoParallel/pipeline"
type matrixApply[DC, DA any] struct {
op UnaryOp[DC, DA]
A *matrixReference[DA]
}
func newMatrixApply[DC, DA any](op UnaryOp[DC, DA], A *matrixReference[DA]) computeMatrixT[DC] {
return matrixApply[DC, DA]{op: op, A: A}
}
func (compute matr... | functional_Matrix_ComputedApply.go | 0.718397 | 0.685423 | functional_Matrix_ComputedApply.go | starcoder |
// Copyright ยฉ2019 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build go1.14,!go1.15
package yaegi
import (
"reflect"
"gonum.org/v1/gonum/unit"
)
func init() {
Symbols["gonum.org/v1/gonum/unit"] = map[string]... | yaegi/go1_14_gonum.org_v1_gonum_unit.go | 0.670393 | 0.421671 | go1_14_gonum.org_v1_gonum_unit.go | starcoder |
package datadog
// A standard histogram
type Histogram struct {
BaseMetric
sample Sample
}
// NewCustomHistogram creates a new custom histogram
func NewCustomHistogram(name string, sample Sample, tags ...string) *Histogram {
return &Histogram{BaseMetric: BaseMetric{name: name, tags: tags}, sample: sample}
}
// Fe... | histogram.go | 0.854475 | 0.499451 | histogram.go | starcoder |
package eve
// DL allows to write display list commands.
type DL struct {
Writer
}
// SwapDL closes the write transaction, clears the IntSwap interrupt flag and
// schedules the display lists swap to be performed after rendering the current
// frame. It returns the address just after the last write operation.
func ... | eve/dl.go | 0.697815 | 0.476092 | dl.go | starcoder |
package types
import (
"encoding/binary"
"io"
"math"
)
// Len returns the length of the MessagePack encoded integer.
func (i Int) Len() int {
var length int
switch {
case i >= NegativeFixIntMin && i <= math.MaxInt8:
length = 1
case i >= math.MinInt8 && i < NegativeFixIntMin:
length = 2
case i >= math.Min... | internal/types/number.go | 0.758421 | 0.426202 | number.go | starcoder |
// Maintains the summary of aggregated minute, hour, and day stats.
// For a container running for more than a day, amount of tracked data can go up to
// 40 KB when cpu and memory are tracked. We'll start by enabling collection for the
// node, followed by docker, and then all containers as we understand the usage pa... | vertical-pod-autoscaler/e2e/vendor/github.com/google/cadvisor/summary/summary.go | 0.500977 | 0.447158 | summary.go | starcoder |
package hbook
import (
"fmt"
"math"
)
// DivideH1D divides 2 1D-histograms and returns a 2D scatter.
// DivideH1D returns an error if the binning of the 1D histograms are not compatible.
func DivideH1D(num, den *H1D) (*S2D, error) {
var s2d S2D
bins1 := num.Binning().Bins()
bins2 := den.Binning().Bins()
for ... | hbook/ops.go | 0.54359 | 0.471041 | ops.go | starcoder |
package vmath
import (
"unsafe"
)
const g_SLERP_TOL = 0.999
//Vector3
func (v *Vector3) MakeFromP3(pnt *Point3) {
v[x] = pnt[x]
v[y] = pnt[y]
v[z] = pnt[z]
}
func (v *Vector3) MakeFromScalar(scalar float32) {
v[x] = scalar
v[y] = scalar
v[z] = scalar
}
func (v *Vector3) Copy(other *Vector3) {
v[x] = other... | vector.go | 0.722233 | 0.567517 | vector.go | starcoder |
package main
import (
"errors"
"io"
)
// Machine is the virtual brainfuck machine
type Machine struct {
code []*Instruction // the program thatโs executed by the machine
ip int // Instruction pointer: It points to the instruction in the code thatโs to be executed next
memory [30000]int // a brainfu... | machine.go | 0.587115 | 0.403978 | machine.go | starcoder |
package internal
import (
"reflect"
"github.com/tada/catch"
"github.com/tada/dgo/dgo"
)
type (
// functionType is a dynamically created (typically by the parser) dgo.FunctionType
functionType struct {
arguments dgo.TupleType
returns dgo.TupleType
}
// exactFunctionType is a dgo.FunctionType representat... | internal/function.go | 0.741206 | 0.549278 | function.go | starcoder |
package logey
import "fmt"
import "strings"
// Defines the log data structure
type Log struct {
// Is an array of entry objects
Entries []Entry
}
func GetSeparator() string {
return "|"
}
// Creates an empty log without entries
func EmptyLog() Log {
return Log{Entries: make([]Entry, 0)}
}
// Starts... | vendor/github.com/ishiikurisu/logey/log.go | 0.617974 | 0.499695 | log.go | starcoder |
package utils
//FindStridesInt32 returns the strides of the dims given for an array.
//example if for an array of NCHW it will return [C*H*W,H*W,W,1] those can be used for traversing a 4d array
func FindStridesInt32(dims []int32) (strides []int32) {
mult := int32(1)
strides = make([]int32, len(dims))
for i := len(... | utils/volumestride.go | 0.748812 | 0.540196 | volumestride.go | starcoder |
package aggregation
import (
"math"
)
const (
// SumType adds all non nan elements in a list of series
SumType = "sum"
// MinType takes the minimum all non nan elements in a list of series
MinType = "min"
// MaxType takes the maximum all non nan elements in a list of series
MaxType = "max"
// AverageType ave... | src/query/functions/aggregation/function.go | 0.788868 | 0.619327 | function.go | starcoder |
package main
import "fmt"
// Standard Square root using an intial guess z
func Sqrt(x float64, z float64) (float64, int) {
// counter
counter := 0
last := float64(999999999)
difference := float64(1)
for difference > 2e-15{
counter += 1
z -= (z*z - x) / (2*z)
difference = last - z
last = z... | website/sqrt.go | 0.682045 | 0.501526 | sqrt.go | starcoder |
package parse
var helpLines = []string{
"Ivy is an interpreter for an APL-like language. It is a plaything and a work in",
"progress.",
"",
"Unlike APL, the input is ASCII and the results are exact (but see",
"the next paragraph). It uses exact rational arithmetic so it can",
"handle arbitrary precision. Value... | parse/help.go | 0.661376 | 0.682646 | help.go | starcoder |
package pairwise
type s1 struct{ m1 int }
type s2 struct{ m1, m2 int }
type s5 struct{ m1, m2, m3, m4, m5 int }
func testStructIndex1() int {
x := s1{m1: 1}
return x.m1
}
func testStructIndex2() int {
x := s2{m1: 1, m2: 2}
return x.m1 + x.m2
}
func testStructIndex5() int {
x := s5{m1: 1, m2: 2, m3: 3, m4: 4, m... | src/emacs/conformance/pairwise/structs.go | 0.627837 | 0.560313 | structs.go | starcoder |
package gb
import (
"github.com/Humpheh/goboy/pkg/bits"
)
// Perform a ADD instruction on the values and store the value using the set
// function. Will also update the CPU flags using the result of the operation.
func (gb *Gameboy) instAdd(set func(byte), val1 byte, val2 byte, addCarry bool) {
carry := int16(bits.... | pkg/gb/functions.go | 0.531696 | 0.408867 | functions.go | starcoder |
package stroke
import (
"math"
"sort"
)
// simpleOffset returns a Segment that is approximately parallel to s, d units
// to the right. It just offsets the endpoints and control points; it doesn't
// subdivide the curve into smaller segments.
func simpleOffset(s Segment, d float32) Segment {
t0, t1 := s.tangents()... | offset.go | 0.832032 | 0.568895 | offset.go | starcoder |
package Test
import "math"
func NewPlane() *Mesh {
v1 := Vector{-0.5, -0.5, 0}
v2 := Vector{0.5, -0.5, 0}
v3 := Vector{0.5, 0.5, 0}
v4 := Vector{-0.5, 0.5, 0}
return NewTriangleMesh([]*Triangle{
NewTriangleForPoints(v1, v2, v3),
NewTriangleForPoints(v1, v3, v4),
})
}
func NewCube() *Mesh {
v := []Vector{
... | shapes.go | 0.652684 | 0.645923 | shapes.go | starcoder |
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
)
var helpMsg = `
USAGE
%[1]v [OPTIONS] [<DIRS>]
DESCRIPTION
Searches directory trees for files that match regular expressions
using parallelism to improve performance. It is written in go.
It was developed to allow me to find symbols in... | src/jlinoff/grok/help.go | 0.694095 | 0.402392 | help.go | starcoder |
package bufferutil
import (
"encoding/binary"
"math"
)
func WriteInt32(buf []byte, pos int32, v int32, isBigEndian bool) {
s := buf[pos:]
if isBigEndian {
binary.BigEndian.PutUint32(s, uint32(v))
} else {
binary.LittleEndian.PutUint32(s, uint32(v))
}
}
func ReadInt32(buf []byte, pos int32, isBigEndian boo... | internal/serialization/bufferutil/buffer_util.go | 0.583678 | 0.401043 | buffer_util.go | starcoder |
package outlay
import (
"image"
"gioui.org/f32"
"gioui.org/io/event"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/unit"
)
// Cell lays out the Table cell located at column x and row y.
type Cell func(gtx layout.Context, x, y int) layout.Dimensions
// Table lays out... | outlay/table.go | 0.606382 | 0.546133 | table.go | starcoder |
package ann
import (
// "fmt"
"math"
)
type NeuralNetwork struct {
NumberInputs int
NumberOutputs int
NumberHiddenNodes int
LearningRate float64
InputWeights Matrix
OutputWeights Matrix
}
// Sigmoidal function
func ActivationFunction(x float64) float64 {
return 1.0 / (1.0 + math.Exp(-... | ann/ann.go | 0.773986 | 0.443781 | ann.go | starcoder |
package ovsdb
import (
"encoding/json"
"fmt"
"io"
)
// DatabaseSchema represents the schema of a ovsdb database
type DatabaseSchema struct {
// Name identifies the database as a whole
Name ID `json:"name"`
// Version reports the version of the database schema
Version Version `json:"version"`
// Checksum optio... | schema.go | 0.852905 | 0.402304 | schema.go | starcoder |
package gpsd
import "time"
type gpsdReport struct {
Class string `json:"class"`
}
/*
TPVReport is a Time-Position-Velocity report
The "class" and "mode" fields will reliably be present.
The "mode" field will be emitted before optional fields that may be absent when there is no fix.
Error estimates will be emitted ... | reports.go | 0.560493 | 0.423637 | reports.go | starcoder |
package typ
import (
"encoding/json"
"strconv"
"strings"
"github.com/mb0/xelf/bfr"
"github.com/mb0/xelf/cor"
)
// Type represents the full type details. It consists of a kind and additional information.
type Type struct {
Kind Kind
*Info
}
func (t Type) Typ() Type { return Typ }
// Info represents the refer... | typ/type.go | 0.667364 | 0.41253 | type.go | starcoder |
package aseprite
import (
"encoding/json"
"gitlab.com/c0b/go-ordered-json"
)
// FrameData contains all the frames in the animation and their data.
type FrameData struct {
frameSlice []Frame // used for reference.
frameMap map[string]Frame // used primarily.
IsMap bool `json:"-"`
}
/... | frame.go | 0.749729 | 0.428054 | frame.go | starcoder |
package main
import (
"math"
"github.com/lucasb-eyer/go-colorful"
)
type Gradient struct {
colors []colorful.Color
positions []float64
}
type GradientKeyFrame struct {
color colorful.Color
position float64
index int
}
func newGradient(colors []colorful.Color, wrap bool) Gradient {
var gradient Gra... | gradient.go | 0.700178 | 0.420838 | gradient.go | starcoder |
package day05
import (
"embed"
"errors"
"fmt"
"math"
"strconv"
"strings"
"advent2021.com/util"
)
type point struct {
x int
y int
}
type line struct {
start point
end point
}
func (l line) isDiagonal() bool {
rise := math.Abs(float64(l.end.y - l.start.y))
run := math.Abs(float64(l.end.x - l.start.x))... | day05/day05.go | 0.586286 | 0.422147 | day05.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.