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 xlsx
import (
"fmt"
"math"
"strconv"
)
// CellType is an int type for storing metadata about the data type in the cell.
type CellType int
// Known types for cell values.
const (
CellTypeString CellType = iota
CellTypeFormula
CellTypeNumeric
CellTypeBool
CellTypeInline
CellTypeError
)
// Cell is a h... | Godeps/_workspace/src/github.com/tealeg/xlsx/cell.go | 0.599251 | 0.567877 | cell.go | starcoder |
package html
import (
"io"
g "github.com/christophersw/gomponents-htmx"
)
// Doctype returns a special kind of Node that prefixes its sibling with the string "<!doctype html>".
func Doctype(sibling g.Node) g.Node {
return g.NodeFunc(func(w io.Writer) error {
if _, err := w.Write([]byte("<!doctype html>")); err ... | html/elements.go | 0.707607 | 0.403273 | elements.go | starcoder |
package matrix
import "math/rand"
import "fmt"
// Matrix is a matrix
type Matrix struct {
Rows int
Cols int
Cells []float64
}
// Zeros generates a zeroed Matrix
func Zeros(r, c int) Matrix {
return Matrix{
Rows: r,
Cols: c,
Cells: make([]float64, r*c),
}
}
// RandomN generates a random r by c Matrix
... | matrix/matrix.go | 0.884639 | 0.648564 | matrix.go | starcoder |
package occlude
import (
"crypto/rand"
"io"
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/blake2b"
"golang.org/x/crypto/hkdf"
"golang.org/x/crypto/sha3"
ristretto "github.com/gtank/ristretto255"
)
const (
argonTime = 3
argonMemory = 1e5
)
// Compute and return a random ristretto scalar (←R Zq).
func... | crypto.go | 0.773473 | 0.461866 | crypto.go | starcoder |
package packing
type Point struct {
x int
y int
}
func (p Point) X() int {
return p.x
}
func (p Point) Y() int {
return p.y
}
// Partition represent the single cell that an image can be inserted in.
type Partition struct {
p1 Point
p2 Point
ratio float32
}
func CreatePartition(p1, p2 Point) Partition ... | packing/partition.go | 0.852045 | 0.658383 | partition.go | starcoder |
package clinical
import (
"github.com/savannahghi/firebasetools"
"github.com/savannahghi/scalarutils"
)
// FHIREncounter definition: an interaction between a patient and healthcare provider(s) for the purpose of providing healthcare service(s) or assessing the health status of a patient.
type FHIREncounter struct {... | graph/clinical/encounter.go | 0.662796 | 0.455441 | encounter.go | starcoder |
package nats
import (
"context"
"crypto/tls"
"fmt"
"strings"
"sync"
"time"
"github.com/Jeffail/benthos/v3/internal/bundle"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/impl/nats/auth"
"github.com/Jeffail/benthos/v3/internal/shutdown"
"github.com/Jeffail/benthos/v3/l... | internal/impl/nats/jetstream_input.go | 0.607081 | 0.456834 | jetstream_input.go | starcoder |
package rotations
func gcd(a, b int) int {
for a != 0 {
a, b = b%a, a
}
return b
}
// Juggling ... Perfoms left rotation of array by d steps
func juggling(a []int, d int) []int {
if d == 0 {
return a
}
n := len(a)
d = d % n
m := gcd(n, d)
var k, next, prev int
for i := 0; i < m; i++ {
k = i
prev = ... | ds/arrays/rotations.go | 0.611266 | 0.434821 | rotations.go | starcoder |
package merkleDag
import "github.com/AccumulateNetwork/ValidatorAccumulator/ValAcc/types"
type MDNode struct {
Type uint8 // Type of data in this chain, drives validation
SequenceNumber uint32 // sequence number of MDNodes in this chain
Previous types.Hash // Hash of the previous MDN... | ValAcc/merkleDag/mdnode.go | 0.512937 | 0.482246 | mdnode.go | starcoder |
package physics
import "github.com/mokiat/gomath/sprec"
// SBSolverContext contains information related to the
// single-body constraint processing.
type SBSolverContext struct {
Body *Body
ElapsedSeconds float32
}
// SBConstraintSolver represents the algorithm necessary
// to enforce a single-body const... | game/physics/solver.go | 0.84338 | 0.481637 | solver.go | starcoder |
package types
import "math"
type WordVector interface {
Words() []string
WordSet() Set
Frequencies() []int
FrequencyOf(key string) int
Put(key string, count int) WordVector
Inc(key string) WordVector
Contains(key string) bool
Length() int
Dot(otherWv WordVector) float64
VectorLength() float64
Copy() WordVe... | types/word_vector.go | 0.647241 | 0.409398 | word_vector.go | starcoder |
package complexMatrix
import "fmt"
type mutable [][]complex128
// Creates a mutable matrix from a 2-d array of complex numbers
func NewMutable(table [][]complex128) M {
if len(table) == 0 {
return nil
}
for _, row := range table[1:] {
if len(row) != len(table[0]) {
panic("complexMatrix.NewMutable parameter... | mutable.go | 0.77806 | 0.616012 | mutable.go | starcoder |
package smartsheet
import "time"
type Cell struct {
CellHistory
ColumnId int64 `json:"columnId,omitempty"` //The Id of the column that the cell is located in
ColumnType string `json:"columnType,omitempty"` //See type definition on the Column object. Only returned if... | pkg/smartsheet/cell.go | 0.667148 | 0.472257 | cell.go | starcoder |
package standarddashboard
import (
"errors"
"fmt"
"net/url"
"strconv"
log "github.com/golang/glog"
"github.com/google/mako/go/spec/mako"
pgpb "github.com/google/mako/spec/proto/mako_go_proto"
)
const (
hostURL = "mako.dev"
hostScheme = "https"
noSeriesID = -1
)
type dashboard struct{}
// New returns a... | go/clients/dashboard/standard_dashboard.go | 0.566019 | 0.408218 | standard_dashboard.go | starcoder |
package mgots
import (
"math"
"time"
)
// A Metric is a single aggregated metric in a sample.
type Metric struct {
Max float64
Min float64
Num int64
Sum float64
}
// A Sample is a single aggregated sample in a time series.
type Sample struct {
Start time.Time
Metrics map[string]Metric
}
// A TimeSeries is... | time_series.go | 0.915465 | 0.57946 | time_series.go | starcoder |
package main
import "encoding/json"
import "errors"
import "fmt"
import "io/ioutil"
import "os"
import "reflect"
// Standard mathematical min function
func min(a int, b int) int {
if a < b {
return a
}
return b
}
// Compares two objects and returns a list of differences relative to the json path
// If the obje... | json-diff.go | 0.640074 | 0.442275 | json-diff.go | starcoder |
package genlib
import (
"errors"
"fmt"
"math"
"sync"
)
// DataParams is for GenData
type DataParams struct {
Name string
GenConfig DataGen
}
// DataGen is the standard interface for the data types
type DataGen interface {
Gen() error
Extract(int) (interface{}, error)
PermutationCount() int
SetPermutat... | internal/genlib/data.go | 0.553505 | 0.438545 | data.go | starcoder |
package cycle
import (
"fmt"
)
// R is a total cyclic order relation, maintaining a left,right projection and a tracked index, both of which may cycle independent of each other.
type R struct {
o pro // set projection
n int // subset length
z int // zero index displacement; if o.l == index-z, index args of zero m... | cycle/cycle.go | 0.766643 | 0.505432 | cycle.go | starcoder |
package dijkstra
import (
"errors"
"fmt"
"strings"
)
type tArrayHeap struct {
comparator IComparator
items []interface{}
size int
version int64
}
func (t *tArrayHeap) Size() int {
return t.size
}
func (t *tArrayHeap) IsEmpty() bool {
return t.size <= 0
}
func (t *tArrayHeap) IsNotEmpty() boo... | algorithm/dijkstra/IArrayHeap.go | 0.565539 | 0.418756 | IArrayHeap.go | starcoder |
package go_fourier
import (
"errors"
)
var NumWorkers = 8
func dctWorker(rows <-chan int, jobReturns chan<- bool, signals [][]float64, forward bool) {
for i := range rows {
if forward {
signals[i], _ = DCT1D(signals[i])
} else {
signals[i], _ = DCTInverse1D(signals[i])
}
jobReturns <- true
}
}
func... | util.go | 0.671578 | 0.498596 | util.go | starcoder |
package ast
import (
"github.com/i-sevostyanov/NanoDB/internal/sql/parsing/token"
)
// Node represents AST-node of the syntax tree for SQL query.
type Node interface{}
// Statement represents syntax tree node of SQL statement (like: SELECT).
type Statement interface {
Node
statementNode()
}
// Expression represe... | internal/sql/parsing/ast/ast.go | 0.731826 | 0.44059 | ast.go | starcoder |
package render
import (
"image"
"image/color"
"github.com/stretchr/testify/mock"
"golang.org/x/image/font"
)
// MockCanvas is a mock implementation of the Canvas interface for testing purposes.
type MockCanvas struct {
mock.Mock
}
// SetUnderlyingImage returns the preset value(s).
func (m *MockCanvas) SetUnder... | render/mockcanvas.go | 0.8897 | 0.510558 | mockcanvas.go | starcoder |
package mist
import (
"encoding/gob"
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
"github.com/nlpodyssey/spago/nn"
)
var _ nn.Model[float32] = &Model[float32]{}
// Model contains the serializable parameters.
type Model[T mat.DType] struct {
nn.BaseModel[T]
Wx nn.Param[T] `spago:... | nn/recurrent/mist/mist.go | 0.788909 | 0.520131 | mist.go | starcoder |
package resolv
// Shape is a basic interface that describes a Shape that can be passed to collision testing and resolution functions and
// exist in the same Space.
type Shape interface {
IsColliding(Shape) bool
WouldBeColliding(Shape, float64, float64) bool
GetTags() []string
ClearTags()
AddTags(...string)
Remo... | resolv/shape.go | 0.841468 | 0.706722 | shape.go | starcoder |
package gorm
import (
"database/sql"
"github.com/jinzhu/gorm"
"github.com/stretchr/testify/mock"
)
type FakeGorm struct {
mock.Mock
}
func (f *FakeGorm) Close() error {
return f.Called().Error(0)
}
func (f *FakeGorm) DB() *sql.DB {
return f.Called().Get(0).(*sql.DB)
}
func (f *FakeGorm) New() Gorm {
return... | fake.go | 0.68056 | 0.559892 | fake.go | starcoder |
package connpass
import (
"errors"
"fmt"
"net/url"
"strconv"
"time"
)
// Param is a function which set a value to url.Values.
type Param func(vals url.Values) error
// EventID sets value to url.Values with key "event_id".
// eventID must be positive integer.
func EventID(eventID int) Param {
return func(vals u... | params.go | 0.608594 | 0.40392 | params.go | starcoder |
package vector
import (
"math"
)
const (
x = iota
y
z
)
func clone(a []float64) []float64 {
clone := make([]float64, len(a))
copy(clone, a)
return clone
}
func add(a, b []float64) []float64 {
dimA, dimB := len(a), len(b)
if (dimA == 1 || dimA == 2 || dimA == 3) && dimB == 1 {
a[x] += b[x]
return a
}
... | arithmetic.go | 0.613931 | 0.745549 | arithmetic.go | starcoder |
package util
import (
"encoding/binary"
"encoding/json"
"encoding/xml"
"fmt"
"strconv"
"time"
)
// Working Timetable time.
// WorkingTime is similar to PublicTime, except we can have seconds.
// In the Working Timetable, the seconds can be either 0 or 30.
type WorkingTime struct {
t int
}
const (
wor... | util/workingtime.go | 0.753467 | 0.420659 | workingtime.go | starcoder |
package emacs
import (
"fmt"
"math/big"
"reflect"
"time"
)
// Reflect is a type with underlying type reflect.Value that knows how to
// convert itself to and from an Emacs value.
type Reflect reflect.Value
// Emacs attempts to convert r to an Emacs value.
func (r Reflect) Emacs(e Env) (Value, error) {
v := ref... | reflect.go | 0.690768 | 0.487795 | reflect.go | starcoder |
package shared
/*title: Shared Data
First, we need to think about what data our module state contains.
The data types used to model this data will be used both at the server and in the web UI, so we need to place them in a common `shared` package.
As we want to display a calendar, we'll need to store a date.
Now than... | shared.go | 0.776792 | 0.781393 | shared.go | starcoder |
package obj
import (
"errors"
"fmt"
"strconv"
"strings"
)
// Intersection is a coordinate in the Self-driving Rides Problem
type Intersection [2]int
func distance(a, b Intersection) int {
x := a[0] - b[0]
if x < 0 {
x *= -1
}
y := a[1] - b[1]
if y < 0 {
y *= -1
}
return x + y
}
// Ride represents a p... | obj/rides.go | 0.597373 | 0.412885 | rides.go | starcoder |
package backtrack
/*
Write a program to solve a Sudoku puzzle by filling the empty cells.
A sudoku solution must satisfy all of the following rules:
Each of the digits 1-9 must occur exactly once in each row.
Each of the digits 1-9 must occur exactly once in each column.
Each of the the digits 1-9 must occur exactly... | backtrack/sudoku.go | 0.561455 | 0.57523 | sudoku.go | starcoder |
package impl
import (
"fmt"
"reflect"
"github.com/maargenton/go-testpredicate/pkg/utils/predicate"
)
// MapKeys is a transformation predicate that applies only to map values and
// extract its keys into an sequence for further evaluation. Note that the keys
// Will appear in no particular order.
func MapKeys() (d... | pkg/utils/predicate/impl/map.go | 0.634883 | 0.40698 | map.go | starcoder |
package machine
// Compiled version of the schema for use as a default schema - needs to be
// updated whenever the master copy gets updated
const SCHEMA = `
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://machinist.flapflap.io/machine.schema.json",
"title": "Machine",
"description... | core/simulation/machine/machine.schema.json.go | 0.845145 | 0.659549 | machine.schema.json.go | starcoder |
package maxpooling
import (
"math"
"math/rand"
"gitlab.com/akita/mgpusim/benchmarks/dnn/layers"
"gitlab.com/akita/mgpusim/driver"
)
// Parameters defines the parameters of the maxpooling benchmark.
type Parameters struct {
N, C, H, W int
KernelH, KernelW int
StrideH, StrideW int
PadH, PadW int
}
... | benchmarks/dnn/maxpooling/maxpooling.go | 0.800926 | 0.400749 | maxpooling.go | starcoder |
package btree
// Method indicate tree traversal method, pre-order, in-order, post-order
type Method int
// show tree traversal method
const (
PreOrder Method = iota
InOrder
PostOrder
)
// Iter is a tree iterator, Recursively traversal
type Iter struct {
nodeChain []*TreeNode
pleft *TreeNode
pright *Tre... | btree/treeiterator.go | 0.700075 | 0.501526 | treeiterator.go | starcoder |
package components
import (
"math"
"sort"
"github.com/factorion/graytracer/pkg/primitives"
"github.com/factorion/graytracer/pkg/patterns"
"github.com/factorion/graytracer/pkg/shapes"
)
// World Container for objects
type World struct {
objects []shapes.Shape
lights []PointLight
background patterns.RGB
}
// M... | pkg/components/world.go | 0.820397 | 0.473475 | world.go | starcoder |
package shape
import (
"fmt"
"math"
"github.com/fogleman/gg"
"github.com/golang/freetype/raster"
)
// Triangle represents a triangular shape
type Triangle struct {
X1, Y1 float64
X2, Y2 float64
X3, Y3 float64
MaxArea int
}
func NewTriangle() *Triangle {
return &Triangle{}
}
func NewMaxAreaTriangle(area... | primitive/shape/triangle.go | 0.800146 | 0.541773 | triangle.go | starcoder |
package main
import (
"fmt"
"sync"
)
// In this video, we'll discuss some fundamental components of sharing work between Goroutines.
// ST
// The simplest way to share data between goroutines is to pass a pointer to each goroutine which
// points to the same piece of memory. Each Goroutine can read and write to thi... | s2t3/main.go | 0.565179 | 0.631225 | main.go | starcoder |
package moretypes
import "fmt"
//Array possui um tamanho pré definido, enquanto slices não.
//Slices são muito mais comuns
//O retorno como ponteiro foi para permitir a instanciação por um slice
//no método sliceFunction. Mais informações aqui: https://stackoverflow.com/questions/50062243/error-addressing-the-returne... | go-tour/moretypes/slices.go | 0.665193 | 0.59131 | slices.go | starcoder |
package command
import (
"encoding/base64"
"fmt"
"image/color"
"strconv"
"strings"
)
// ChunkDataRequest produces the command used to get a string of chunk data of a certain chunk.
// The command is only available on education edition games. This may be enabled using minecraft://?edu=1.
func ChunkDataRequest(dim... | protocol/command/chunk_data.go | 0.767951 | 0.535584 | chunk_data.go | starcoder |
package stroke
import (
"math"
"sort"
)
// A Segment is a cubic bezier curve (or a line segment that has been converted
// into a bezier curve).
type Segment struct {
Start Point
CP1, CP2 Point
End Point
}
// LinearSegment returns a line segment connecting a and b, in the form of a
// cubic bezier curve... | segment.go | 0.897544 | 0.700087 | segment.go | starcoder |
package boolmap
// CrumbMap is a map of Crumbs (2-bits, values 0, 1, 2, 3)
type CrumbMap map[uint64]byte
// NewCrumbMap returns a new, initialised, CrumbMap
func NewCrumbMap() CrumbMap {
return make(CrumbMap)
}
// Get returns a crumb from the given position
func (c CrumbMap) Get(p uint64) byte {
d := c[p>>2]
swit... | crumbmap.go | 0.684791 | 0.53965 | crumbmap.go | starcoder |
package tables
import (
"math"
"github.com/notnil/chess"
)
// EvaluateBoard implements the Simplified Evaluation Function by <NAME>
// https://www.chessprogramming.org/Simplified_Evaluation_Function
func EvaluateBoard(game *chess.Game) int {
if game.Position().Status() == chess.Checkmate {
return math.MaxInt32
... | old_implementation/tables/evaluate.go | 0.689201 | 0.510069 | evaluate.go | starcoder |
package gokalman
import (
"fmt"
"math/rand"
"time"
"github.com/gonum/matrix/mat64"
"github.com/gonum/stat/distmv"
)
// Noise allows to handle the noise for a KF.
type Noise interface {
Process(k int) *mat64.Vector // Returns the process noise w at step k
Measurement(k int) *mat64.Vector // Returns t... | noise.go | 0.810291 | 0.61973 | noise.go | starcoder |
package countries
import (
"math"
"strconv"
"github.com/ltns35/go-vat/countries/utils"
)
type unitedKingdom struct {
Country
}
var UnitedKingdom = unitedKingdom{
Country: Country{
Name: "United Kingdom",
Codes: []string{
"GB",
"GBR",
"826",
},
Rules: CountryRules{
Multipliers: map[string][]... | countries/united_kingdom.go | 0.64791 | 0.444022 | united_kingdom.go | starcoder |
package geotiff
// DataSlice contains a 'slice' of data
type DataSlice struct {
dataView DataView
offset uint
littleEndian bool
bigTiff bool
}
// NewDataSlice create a new instance of dataSlice
func NewDataSlice(dataView DataView, offset uint, littleEndian bool, bigTiff bool) *DataSlice {
return &... | pkg/geotiff/dataslice.go | 0.893315 | 0.83025 | dataslice.go | starcoder |
package mathg
import "math"
type Vec3 struct {
X float64
Y float64
Z float64
}
func (v *Vec2) ToVec3() *Vec3 {
return &Vec3{v.X, v.Y, 0}
}
func (v *Vec3) IsZero() bool {
return math.Abs(v.X) < epsilon && math.Abs(v.Y) < epsilon && math.Abs(v.Z) < epsilon
}
func (v *Vec3) IsEqual(v1 *Vec3) bool {
return math.... | vec3.go | 0.906614 | 0.441613 | vec3.go | starcoder |
package crawl
import (
"math/rand"
"sync"
"time"
)
// NodePool implements an abstraction over a pool of nodes for which to crawl.
// It also contains a collection of nodes for which to reseed the pool when it's
// empty. Once the reseed list has reached capacity, a random node is removed
// when another is added. ... | crawl/pool.go | 0.638497 | 0.531392 | pool.go | starcoder |
package muxgo
import (
"encoding/json"
)
// RealTimeHistogramTimeseriesBucketValues struct for RealTimeHistogramTimeseriesBucketValues
type RealTimeHistogramTimeseriesBucketValues struct {
Percentage *float64 `json:"percentage,omitempty"`
Count *int64 `json:"count,omitempty"`
}
// NewRealTimeHistogramTimeseriesB... | model_real_time_histogram_timeseries_bucket_values.go | 0.858526 | 0.415492 | model_real_time_histogram_timeseries_bucket_values.go | starcoder |
Package goroutinemap implements a data structure for managing go routines
by name. It prevents the creation of new go routines if an existing go routine
with the same name exists.
*/
package goroutinemap
import (
"fmt"
"sync"
"k8s.io/kubernetes/pkg/util/runtime"
)
// GoRoutineMap defines the supported set of oper... | vendor/k8s.io/kubernetes/pkg/util/goroutinemap/goroutinemap.go | 0.639736 | 0.432183 | goroutinemap.go | starcoder |
package gpsutils
import "fmt"
// Coordinates basic structure to work with this package
type Coordinates struct {
N coordinate
E coordinate
CoordinateN string // N coordinates in the specified format
CoordinateE string // E coordinates in the specified format
Format string // format coord... | coordinates.go | 0.542379 | 0.453564 | coordinates.go | starcoder |
package bellmanford
import (
"math"
)
// Graph represents a graph consisting of edges and vertices
type Graph struct {
edges []*Edge
vertices []uint
}
// Edge represents a weighted line between two nodes
type Edge struct {
From, To uint
Weight float64
}
// NewEdge returns a pointer to a new Edge
func NewE... | internal/algo/bellmanford/bellmanford.go | 0.847227 | 0.617772 | bellmanford.go | starcoder |
package storetestcases
import (
"context"
"testing"
"time"
"github.com/stratumn/go-chainscript"
"github.com/stratumn/go-chainscript/chainscripttest"
"github.com/stratumn/go-core/store"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestStoreEvents tests store channel event n... | store/storetestcases/storeevents.go | 0.566258 | 0.415907 | storeevents.go | starcoder |
package finnhub
import (
"encoding/json"
)
// RevenueEstimates struct for RevenueEstimates
type RevenueEstimates struct {
// List of estimates
Data *[]RevenueEstimatesInfo `json:"data,omitempty"`
// Frequency: annual or quarterly.
Freq *string `json:"freq,omitempty"`
// Company symbol.
Symbol *string `json:"s... | model_revenue_estimates.go | 0.850779 | 0.416381 | model_revenue_estimates.go | starcoder |
package dynamic
import (
"fmt"
"github.com/sidheart/algorithms/util"
"math"
)
// A multiplicationResult represents the cost of multiplying 2 matrices and the index between the two matrices
// e.g. for a list of Matrices [A_0, A_1] the cost would be cost(A_0, A_1) and the split would be 1
type multiplicationResult ... | dynamic/matrix_chain_multiplication.go | 0.812421 | 0.555857 | matrix_chain_multiplication.go | starcoder |
// Package image generates images containing a logo and some text below.
package image
import (
"fmt"
"image"
"image/color"
"image/draw"
"io/ioutil"
"os"
// This registers the supported formats for image.Decode.
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"github.com/golang/freetype/truetype"
"golang.org... | image/image.go | 0.778439 | 0.522689 | image.go | starcoder |
package geom
import (
"github.com/golang/geo/s2"
"math"
)
func NewPolygon(lineStrings ...*LineString) *Polygon {
polygon := &Polygon{}
polygon.LineStrings = append(polygon.LineStrings, lineStrings...)
return polygon
}
func NewPolygonFrom(coordinates ...*LngLat) *Polygon {
polygon := &Polygon{... | go/pkg/mojo/geom/polygon.go | 0.829077 | 0.652352 | polygon.go | starcoder |
package nem12
import (
"fmt"
"strings"
)
const (
// TransactionUndefined is for undefined transaction flags.
TransactionUndefined TransactionCode = iota
// TransactionAlteration is the transaction code value for 'A', when alteration.
TransactionAlteration
// TransactionMeterReconfiguration is the transaction c... | nem12/transaction.go | 0.649467 | 0.442094 | transaction.go | starcoder |
package clusterfeature
import (
"context"
"emperror.dev/errors"
)
// Feature represents the state of a cluster feature.
type Feature struct {
Name string `json:"name"`
Spec FeatureSpec `json:"spec"`
Output FeatureOutput `json:"output"`
Status string `json:"status"`
}
// FeatureSpec repres... | internal/clusterfeature/interface.go | 0.804866 | 0.471284 | interface.go | starcoder |
package em
import (
"fmt"
"golang.org/x/exp/rand"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
"gonum.org/v1/gonum/stat/distmv"
"gonum.org/v1/gonum/stat/distuv"
"math"
)
func GenerateMVGaussian(means []float64, sigma *mat.DiagDense, numObs int, seed uint64) [][]float64{
nor... | em/emalgo.go | 0.560493 | 0.405625 | emalgo.go | starcoder |
package attributes
import "strings"
type Attribute struct {
Templ string
Data interface{}
Name string
}
// Begin of manually implemented attributes
func Dataset(key, value string) Attribute {
key_ := strings.Replace(key, "-", "_", -1)
return Attribute{
Data: map[string]... | attributes/attributes.go | 0.735262 | 0.513973 | attributes.go | starcoder |
package clustering
import (
"errors"
"github.com/tddhit/golearn/base"
"gonum.org/v1/gonum/mat"
"gonum.org/v1/gonum/stat"
"gonum.org/v1/gonum/stat/distmv"
"math"
"math/rand"
)
var (
NoTrainingDataError = errors.New("You need to Fit() before you can Predict()")
InsufficientComponentsError = errors.New(... | clustering/em.go | 0.75183 | 0.400573 | em.go | starcoder |
package features
// We want features that give the index of the nth occurrence of each letter in our alphabet in the
// input string. For example, for the string "edcba" we would have:
// firstOccurrences == [4, 3, 2, 1, 0, ...] ('a' occurs in 4th pos, 'b' in 3rd pos, etc.)
// When the character doesn't occur in th... | features/occurrence_positions.go | 0.637369 | 0.544801 | occurrence_positions.go | starcoder |
package par
import(
"github.com/dedis/kyber"
"github.com/dedis/kyber/proof"
)
// Map over a slices of Elgamal Ciphers with the given parallel for-loop.
func MapElgamalCiphers(loop ParallelForLoop, f func([2]kyber.Point, [2]kyber.Point, kyber.Point) ([2]kyber.Point, [2]kyber.Point, proof.Prover), x [][2]kyber.... | par/map.go | 0.786705 | 0.568116 | map.go | starcoder |
package renderer
import (
"errors"
"fmt"
"image"
"github.com/nfnt/resize"
"github.com/nightmarlin/murum/layout"
"github.com/nightmarlin/murum/provider"
)
// BasicRendererOption allows changes to the basic renderer.
type BasicRendererOption func(b *basicRenderer) error
// BasicWithInterpolationFunc sets the i... | renderer/basic.go | 0.796055 | 0.447219 | basic.go | starcoder |
// This package provides a graph data struture
// and graph functionality using ObjMetadata as
// vertices in the graph.
package graph
import (
"sort"
"sigs.k8s.io/cli-utils/pkg/object"
"sigs.k8s.io/cli-utils/pkg/object/validation"
"sigs.k8s.io/cli-utils/pkg/ordering"
)
// Graph is contains a directed set of ed... | pkg/object/graph/graph.go | 0.762424 | 0.415729 | graph.go | starcoder |
package tree
import (
"math/rand"
)
func (root *node) get(key int) (string, bool) {
if root == nil {
return "", false
}
if root.key == key {
return root.value, true
} else if key < root.key {
return root.left.get(key)
} else {
return root.right.get(key)
}
}
func (root *node) put(key int, v string) *no... | tree/binary_search.go | 0.590543 | 0.442817 | binary_search.go | starcoder |
package testing_
import (
"errors"
)
// LinkToExampleObjectOnFieldChildren links ExampleObject to ExampleObject on the fields ExampleObject.Children and ExampleObject.Parents
func (l *ExampleObject) LinkToExampleObjectOnFieldChildren(targets ...*ExampleObject) error {
if targets == nil {
return errors.New("start ... | testing_/linking.go | 0.757346 | 0.547646 | linking.go | starcoder |
package neptune
import (
"context"
"fmt"
"strconv"
"github.com/pkg/errors"
"github.com/ONSdigital/dp-graph/v2/models"
"github.com/ONSdigital/dp-graph/v2/neptune/query"
)
/*
GetCodeDatasets searches the database for datasets that are associated with
the given code list, code, and code list edition. Specificall... | neptune/codelistsdataset.go | 0.570331 | 0.429489 | codelistsdataset.go | starcoder |
package golang
import (
"errors"
"fmt"
"github.com/JosephNaberhaus/go-delta-sync/agnostic"
"github.com/JosephNaberhaus/go-delta-sync/agnostic/blocks/types"
"github.com/JosephNaberhaus/go-delta-sync/agnostic/blocks/value"
. "github.com/dave/jennifer/jen"
"strings"
)
type Implementation struct {
packageName st... | agnostic/targets/golang/implementation.go | 0.539711 | 0.435601 | implementation.go | starcoder |
package geometry
import "github.com/tidwall/boxtree/d2"
// DefaultIndex are the minumum number of points required before it makes
// sense to index the segments.
// 64 seems to be the sweet spot
const DefaultIndex = 64
// Series is just a series of points with utilities for efficiently accessing
// segments from re... | vendor/github.com/tidwall/geojson/geometry/series.go | 0.758868 | 0.646125 | series.go | starcoder |
package seriesgen
import (
"math/rand"
"time"
"github.com/prometheus/prometheus/tsdb/labels"
)
type sample struct {
T int64
V float64
}
// SeriesSet contains a set of series.
type SeriesSet interface {
Next() bool
At() Series
Err() error
}
// Series exposes a single time series.
type Series interface {
//... | pkg/seriesgen/seriesgen.go | 0.601945 | 0.465205 | seriesgen.go | starcoder |
package nvm
import (
"errors"
"gonum.org/v1/gonum/mat"
)
var (
_m *M
_ Matrix = _m
)
// M represents a dense matrix.
type M struct {
// O can be *mat.Dense or mat.Transpose.
O mat.Matrix
}
// NewM creates a new matrix of rows `r` and cols `c`,
// NewM will panic if `r <= 0` or `c <= 0`.
func NewM(r, c int)... | nvm/matrix_dense.go | 0.819965 | 0.532911 | matrix_dense.go | starcoder |
package order
import (
"fmt"
"reflect"
"github.com/posener/order/internal/reflectutil"
)
// Fns is a list of order functions, used to check the order between two T types.
type Fns []Fn
// Fn represent an order function.
type Fn struct {
// fns are the 3-way functions, of the form func(T, T) int.
fn func(lhs, r... | fn.go | 0.718693 | 0.569613 | fn.go | starcoder |
package mab
type Reward struct {
Count int
TotalCov float64 // sum(cov)
TotalTime float64 // sum(time)
TotalCov2 float64 // sum(cov * cov). Used to compute std
TotalTime2 float64 // sum(time * time). Used to compute std
}
type TotalReward struct {
// For Task Scheduling
EstimatedRewardGenerate float6... | pkg/mab/reward.go | 0.637369 | 0.589037 | reward.go | starcoder |
package pdu
import (
"encoding/hex"
)
type PDU struct {
buf []byte
leftIndex int
intiailLeftCap int
state int
}
func Alloc(headerCap int, dataLen int, dataCap int) *PDU {
assert(dataLen <= dataCap, "More data requested than capacity")
buf := make([]byte, headerCap+dataLen, headerCap+dataCap)
return ... | pdubuf/pdu.go | 0.675872 | 0.573977 | pdu.go | starcoder |
package tween
import (
"math"
)
func Linear(start, end, value float32) float32 {
return (end-start)*value + start
}
func Clerp(start, end, value float32) float32 {
var max, half, retval, diff float32 = 360.0, 180.0, 0.0, 0.0
if (end - start) < -half {
diff = ((max - start) + end) * value
retval = start + diff... | server/components/tween/algo.go | 0.703855 | 0.554953 | algo.go | starcoder |
package streams
import (
"github.com/go-fed/activity/vocab"
"net/url"
)
// A specialized Link that represents an @mention. This is a convenience wrapper of a type with the same name in the vocab package. Accessing it with the Raw function allows direct manipulaton of the object, and does not provide the same integr... | streams/gen_mention.go | 0.832781 | 0.400222 | gen_mention.go | starcoder |
package moment
import "time"
const (
// HoursPerDay specifies the number of hours in a day
HoursPerDay = 24
// MinutesPerHour specifies the number of minutes in an hour
MinutesPerHour = 60
// SecondsPerMinute specifies the number of seconds in a minute
SecondsPerMinute = 60
)
// Point defines an abstract point... | moment.go | 0.806434 | 0.499146 | moment.go | starcoder |
package dbustype
import (
"errors"
"fmt"
)
// Parse returns a DBusType corresponding to the signature |s|.
// |s| needs to be a signature made up of a single complete type.
// Note that this function does not support an extension about protobuf defined as an annotation
// of a MethodArg and a SignalArg. Consider u... | chromeos-dbus-bindings/go/src/chromiumos/dbusbindings/dbustype/parser.go | 0.695131 | 0.477676 | parser.go | starcoder |
package cli
import (
"fmt"
"github.com/spf13/cobra"
)
var genExamplesCmd = &cobra.Command{
Use: "example-data",
Short: "generate example SQL code suitable for use with CockroachDB",
Long: `This command generates example SQL code that shows various CockroachDB features and
is suitable to populate an example d... | cli/examples.go | 0.619701 | 0.547948 | examples.go | starcoder |
package hashtable
// ArraySize is the size of the hash table array
const ArraySize = 7
// HashTable will hold an array
type HashTable struct {
array [ArraySize]*bucket
}
// bucket is a linked list in each slot of the has
type bucket struct {
head *bucketNode
}
// bucketNode structure
type bucketNode struct {
key... | hashtable/hashtable.go | 0.728169 | 0.491212 | hashtable.go | starcoder |
package engine
/*
The metadata layer wraps basic micromagnetic functions (e.g. func SetDemagField())
in objects that provide:
- additional information (Name, Unit, ...) used for saving output,
- additional methods (Comp, Region, ...) handy for input scripting.
*/
import (
"fmt"
"github.com/mumax/3/cuda"
"github.c... | engine/outputquantities.go | 0.792745 | 0.476519 | outputquantities.go | starcoder |
package hex
import (
"fmt"
)
const (
// DirectionCount is const to be used for arrays and calculations.
DirectionCount = 6
)
// LineSign is alias for float64 to determine it from other real values.
type LineSign float64
// Line signs.
// LSPlus means counterclockwise path with ray connecting start hex with end o... | hex.go | 0.834339 | 0.463262 | hex.go | starcoder |
package counts
import (
"math"
)
// A count of something, capped at math.MaxUint32.
type Count32 uint32
func NewCount32(n uint64) Count32 {
if n > math.MaxUint32 {
return Count32(math.MaxUint32)
}
return Count32(n)
}
func (n Count32) ToUint64() uint64 {
return uint64(n)
}
// Return the sum of two Count32s, ... | counts/counts.go | 0.804214 | 0.40439 | counts.go | starcoder |
package ast
import (
"bytes"
"fmt"
"regexp"
"strings"
)
// Defines the different types a token can be
const (
TypeID = "ID"
TypeNumber = "Number"
TypeString = "String"
TypeKeyword = "Keyword"
TypeSymbol = "Symbol"
TypeNewline = "Newline"
TypeEOF = "EOF"
TypeComment = "C... | pkg/parser/ast/tokenizer.go | 0.645679 | 0.418697 | tokenizer.go | starcoder |
package e2e
import (
"context"
"fmt"
"testing"
"time"
"github.com/nuczzz/virtual-kubelet/internal/podutils"
stats "github.com/nuczzz/virtual-kubelet/node/api/statsv1alpha1"
"gotest.tools/assert"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
)
const (
// deleteGracePeriodForProvider... | test/e2e/basic.go | 0.586404 | 0.428891 | basic.go | starcoder |
package mutable
/*
307. 区域和检索 - 数组可修改
https://leetcode-cn.com/problems/range-sum-query-mutable
给定一个整数数组 nums,求出数组从索引 i 到 j (i ≤ j) 范围内元素的总和,包含 i, j 两点。
update(i, val) 函数可以通过将下标为 i 的数值更新为 val,从而对数列进行修改。
示例:
Given nums = [1, 3, 5]
sumRange(0, 2) -> 9
update(1, 2)
sumRange(0, 2) -> 8
说明:
数组仅可以在 update 函数下进行修改。
你... | solutions/range-sum-query-mutable/d.go | 0.563138 | 0.419232 | d.go | starcoder |
Get access to client objects
To initialize client objects you can use the setup function. It returns a clients struct
that contains initialized clients for accessing:
- Kubernetes objects
- Pipelines (https://github.com/knative/build-pipeline#pipeline)
For example, to create a Pipeline
_, err = clients.PipelineC... | test/clients.go | 0.669529 | 0.40869 | clients.go | starcoder |
package openflow
import (
"fmt"
"net"
"strings"
"github.com/contiv/libOpenflow/openflow13"
"github.com/contiv/ofnet/ofctrl"
)
type ofFlowBuilder struct {
ofFlow
}
func (b *ofFlowBuilder) Done() Flow {
if b.ctStates != nil {
b.Flow.Match.CtStates = b.ctStates
b.ctStates = nil
}
if b.ctStateString != "" ... | pkg/ovs/openflow/ofctrl_builder.go | 0.654232 | 0.454291 | ofctrl_builder.go | starcoder |
package en_US
import "github.com/rannoch/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, MMMM d, y", Long: "MMMM d, y", Medium: "MMM d, y", Short: "M/d/yy"},
Time: cldr.CalendarDateFormat{Full: "h:mm:ss a zzzz", Long: "h:mm:ss a z", Medium: "h... | resources/locales/en_US/calendar.go | 0.524882 | 0.436502 | calendar.go | starcoder |
package indicators
import (
"errors"
"github.com/jaybutera/gotrade"
)
// A Triangular Moving Average Indicator (Trima), no storage, for use in other indicators
type TrimaWithoutStorage struct {
*baseIndicatorWithFloatBounds
// private variables
sma1 *SmaWithoutStorage
sma2 *SmaWithoutStorage
curre... | indicators/trima.go | 0.744656 | 0.430028 | trima.go | starcoder |
package evaluator
import (
"github.com/niklaskorz/nklang/ast"
)
func evaluateExpression(n ast.Expression, scope *definitionScope) (Object, error) {
switch e := n.(type) {
case *ast.Function:
return &Function{Function: e, parentScope: scope}, nil
case *ast.Integer:
return (*Integer)(e), nil
case *ast.String:
... | evaluator/expressions.go | 0.623492 | 0.465509 | expressions.go | starcoder |
package validate
import (
"fmt"
"math"
"reflect"
"strconv"
"strings"
)
// Validator performs validation on a value.
type Validator interface {
Validate(Context) error
}
// ValidatorFunc is an adapter for a function that implements the Validator interface.
type ValidatorFunc func(Context) error
// Validate imp... | validators.go | 0.73173 | 0.433442 | validators.go | starcoder |
package model
import (
"path/filepath"
"github.com/pkg/errors"
"github.com/tilt-dev/tilt/internal/ospath"
)
type PathMatcher interface {
Matches(f string) (bool, error)
// If this matches the entire dir, we can often optimize filetree walks a bit
MatchesEntireDir(file string) (bool, error)
}
// A Matcher th... | pkg/model/matcher.go | 0.750187 | 0.561095 | matcher.go | starcoder |
MeteringD flows servicer provides the gRPC interface for the REST and
services to interact with traffic flows records.
The servicer require a backing Datastore (which is typically Postgres)
for storing and retrieving the data and access to Magmad to resolve the network.
*/
package servicers
import (
"magma/lte/cloud... | lte/cloud/go/services/meteringd_records/servicers/records.go | 0.690455 | 0.40987 | records.go | starcoder |
package backtest
import (
"sort"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
)
type PriceOrder struct {
Price fixedpoint.Value
Order types.Order
}
type PriceOrderSlice []PriceOrder
func (slice PriceOrderSlice) Len() int { return len(slice) }
func (slice PriceOrderSlice) Less... | pkg/backtest/priceorder.go | 0.746693 | 0.436142 | priceorder.go | starcoder |
package arrowutil
import (
"fmt"
"regexp"
"github.com/apache/arrow/go/arrow/array"
"github.com/influxdata/flux"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux/values"
)
func NewArrayValue(arr array.Interface, typ flux.ColType) values.Array {
switch elemType := flux.SemanticType(typ); elemT... | internal/arrowutil/array_values.gen.go | 0.726717 | 0.567337 | array_values.gen.go | starcoder |
package internal
import (
"reflect"
"github.com/tada/dgo/dgo"
"github.com/tada/dgo/util"
)
type (
errw struct {
error
}
errType int
)
// DefaultErrorType is the unconstrained Error type
const DefaultErrorType = errType(0)
var reflectErrorType = reflect.TypeOf((*error)(nil)).Elem()
func (t errType) Type()... | internal/error.go | 0.613005 | 0.411879 | error.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.