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 kmeans
import (
"math"
)
type QualityIndex interface {
GetScore(clusters []Cluster) float64
Name() string
}
type DunnIndex struct{}
type DaviesBouldinIndex struct{}
func (q DunnIndex) Name() string {
return "Dunn Index"
}
func (q DaviesBouldinIndex) Name() string {
return "Davies-Bouldin Index"
}
fun... | kmeans/quality.go | 0.755547 | 0.472257 | quality.go | starcoder |
package helpers
type Vec2 struct {
X, Y int
}
func (v Vec2) Add(v2 Vec2) Vec2 {
return Vec2{v.X + v2.X, v.Y + v2.Y}
}
func (v Vec2) Equal(end Vec2) bool {
return v.X == end.X && v.Y == end.Y
}
func (v Vec2) ManhattanDistance(end Vec2) int {
return AbsInt(v.X-end.X) + AbsInt(v.Y-end.Y)
}
var (
UpVector = Ve... | helpers/vectors.go | 0.787646 | 0.753036 | vectors.go | starcoder |
package stackframes
import (
"errors"
"fmt"
"regexp"
"strings"
"github.com/deepvalue-network/software/pangolin/domain/middle/testables/executables/applications/instructions/instruction/variable/value/computable"
)
type computer struct {
builder computable.Builder
}
func createComputer(builder computable.Build... | pangolin/domain/interpreters/stackframes/computer.go | 0.640861 | 0.504761 | computer.go | starcoder |
package hit
import (
"github.com/Eun/go-hit/internal/minitest"
)
// IExpectString provides assertions for the string type.
type IExpectString interface {
// Equal expects the string to be equal to the specified value.
Equal(value string) IStep
// NotEqual expects the string to be not equal to the specified value... | expect_string.go | 0.613815 | 0.465145 | expect_string.go | starcoder |
package main
import (
"flag"
"fmt"
"math"
"sync"
)
const NUM_CONCURRENT_CUBOID_SEARCHES = 50
type Cuboid struct {
Length float64
Width float64
Height float64
BottomFaceDiagonalLength float64
SideFaceDiagonalLength float64
FrontFaceDiagonalLength float64
SpaceDiagonalLength float64
}
func (cuboid *Cuboid)... | perfectcuboid.go | 0.665845 | 0.521837 | perfectcuboid.go | starcoder |
package rtc
import (
"math"
)
// Cylinder creates a cylinder at the origin with its axis on the Y axis.
// It implements the Object interface.
func Cylinder() *CylinderT {
return &CylinderT{
Shape: Shape{Transform: M4Identity(), Material: GetMaterial()},
Minimum: math.Inf(-1),
Maximum: math.Inf(1),
Closed... | rtc/cylinder.go | 0.921948 | 0.575886 | cylinder.go | starcoder |
package esitag
import (
"bytes"
"fmt"
"io"
"github.com/corestoreio/errors"
)
// DataTag identifies an Tag tag by its start and end position in the HTML byte
// stream for replacing. If the HTML changes there needs to be a refresh call to
// re-parse the HTML.
type DataTag struct {
Data []byte // Data from the... | esitag/data_tag.go | 0.53607 | 0.528412 | data_tag.go | starcoder |
package tfplugin5
import (
"fmt"
"reflect"
"github.com/hashicorp/go-cty/cty"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)
// ctyToGo converts a cty.Value to a plain Go value with the notable exception of sets, which are left as-is. Sets can
// be converted to plain values by calling provider.IsSet... | pkg/tfshim/tfplugin5/cty.go | 0.652241 | 0.419797 | cty.go | starcoder |
package levels
import (
mgl "github.com/go-gl/mathgl/mgl32"
"github.com/inkyblackness/hacked/editor/render"
"github.com/inkyblackness/hacked/ss1/content/archive/level"
"github.com/inkyblackness/hacked/ui/opengl"
)
var mapColorsVertexShaderSource = `
#version 150
precision mediump float;
in vec4 vertexColor;
in ... | editor/levels/MapColors.go | 0.727104 | 0.460168 | MapColors.go | starcoder |
package track
import (
"fmt"
"github.com/anki/goverdrive/phys"
)
// Region defines a "rectangular" sub-region of the track. If the
// definition includes areas of curvature, the region bends to match the shape
// of the track.
// - The start corner's Dofs must satisfy (0 <= Dofs <= track.CenLen())
// - The le... | goverdrive/robo/track/trackregion.go | 0.788013 | 0.433322 | trackregion.go | starcoder |
package param
import (
"errors"
"fmt"
"reflect"
"time"
)
// Param is a value or a struct that has age and validity. Updating a
// Param also fires an event.
type Param struct {
Name string
value interface{}
updated time.Time
params *Params
final bool
}
// Ok return true if the value has been recen... | param/param.go | 0.6973 | 0.412412 | param.go | starcoder |
package types
import (
"strconv"
"strings"
"github.com/cznic/mathutil"
)
//Interval such as: [2,3],[5,9]
type Interval struct {
start uint64
end uint64
}
// IntervalSet is a set of Interval.
type IntervalSet struct {
intervalSet []*Interval
}
// NewIntervalSet create a new IntervalSet instance.
func NewInt... | core/types/interval_set.go | 0.504639 | 0.453625 | interval_set.go | starcoder |
package integration
import (
"bytes"
"net"
"testing"
. "github.com/onsi/gomega"
"github.com/dnsdb/go-dnsdb/pkg/dnsdb"
)
func LookupRRSet(t *testing.T, c dnsdb.Client) {
name := "farsightsecurity.com."
qf := func() dnsdb.Query { return c.LookupRRSet(name) }
bailiwick := "com."
rrtype := "NS"
t.Run("no ar... | test/integration/lookup.go | 0.541651 | 0.462291 | lookup.go | starcoder |
package graphql
// ObjectConfig provides specification to define a Object type. It is served as a convenient way to
// create a ObjectTypeDefinition for creating an object type.
type ObjectConfig struct {
ThisIsTypeDefinition
// Name of the defining Object
Name string
// Description for the Object type
Descript... | graphql/object.go | 0.733833 | 0.40592 | object.go | starcoder |
package gos
import (
"context"
"database/sql"
"fmt"
"reflect"
"strings"
"github.com/mitranim/refut"
)
/*
Executes an SQL query and prepares a `Scanner` that can decode individual rows
into structs or scalars. A `Scanner` is used similarly to `*sql.Rows`, but
automatically maps columns to struct fields. Just li... | querying.go | 0.763836 | 0.416263 | querying.go | starcoder |
package scene
import (
"de/vorlesung/projekt/raytracer/Helper"
objects "de/vorlesung/projekt/raytracer/SceneObjects"
)
//the surface implementation
type Surface struct {
plane *objects.Plane
color *objects.Vector
diffuse float64
specularIntensity float64
specularPower floa... | Raytracing/surface.go | 0.865281 | 0.67108 | surface.go | starcoder |
package amber
// CRC32 https://github.com/EgeBalci/CRC32_API
const CRC32 = `
api_call:
pushad ; We preserve all the registers for the caller, bar EAX and ECX.
mov ebp, esp ; Create a new stack frame
xor eax, eax ; Zero EAX (upper 3 bytes will remain zero until function is fou... | pkg/crc_api_x86.go | 0.653127 | 0.422862 | crc_api_x86.go | starcoder |
package objects
import (
"github.com/wieku/danser-go/app/bmath"
"math"
)
type TimingPoint struct {
Time float64
beatLengthBase float64
beatLength float64
SampleSet int
SampleIndex int
SampleVolume float64
Kiai bool
}
func (t TimingPoint) GetRatio() float64 {
if t.beatLength >= 0 || math.IsNaN(t.... | app/beatmap/objects/timing.go | 0.77569 | 0.547222 | timing.go | starcoder |
package bvtree
import (
"fmt"
)
/**
* BvFhTree is a struct that holds a bitvector representation
* of a set of integeres between 0 and n.
*/
type BvFhTree struct {
// The number of bits in the bitvector, size of the universe.
numBits uint64
sqNumBits uint64
empty bool
// Bit vector hold... | src/bvtree/bvfhtree.go | 0.760562 | 0.497559 | bvfhtree.go | starcoder |
package ui
// Button is a clickable button that performs some task.
type Button interface {
Control
// OnClicked sets the event handler for when the Button is clicked.
OnClicked(func())
// Text and SetText get and set the Button's label text.
Text() string
SetText(text string)
}
// NewButton creates a new Bu... | basicctrls.go | 0.668339 | 0.422564 | basicctrls.go | starcoder |
package signalfxreceiver
import (
sfxpb "github.com/signalfx/com_signalfx_metrics_protobuf/model"
"go.opentelemetry.io/collector/consumer/pdata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
)
// signalFxV2ToMetricsData converts SignalFx event proto data points to
// pdata.LogSlice.... | receiver/signalfxreceiver/signalfxv2_event_to_logdata.go | 0.621196 | 0.403714 | signalfxv2_event_to_logdata.go | starcoder |
package interval
// Adapted from Mao, Eran & Luo 2019
// DOI: 10.1038/s41598-019-41451-3
import (
"fmt"
"io"
"sort"
)
type Interval interface {
GetChrom() string
GetChromStart() int
GetChromEnd() int
WriteToFileHandle(io.Writer)
}
type IntervalNode struct {
val Interval // only stored in leaf nodes
data... | interval/interval.go | 0.502686 | 0.423518 | interval.go | starcoder |
package hyperopt
import (
"github.com/sudachen/go-ml/fu"
"github.com/sudachen/go-zorros/zorros"
"gonum.org/v1/gonum/floats"
"math"
"math/rand"
"sort"
)
type sampler struct {
numberOfStartupTrials int
numberOfEICandidates int
rng *rand.Rand
priorWeight float64
}
func (s *sampler) sample(name string, dist... | model/hyperopt/sampler.go | 0.729327 | 0.439447 | sampler.go | starcoder |
package level
import "github.com/inkyblackness/hacked/ss1/serial"
// TileMapEntry describes one tile of the map.
type TileMapEntry struct {
// Type indicates what kind of tile this is.
Type TileType
// Floor describes floor properties.
Floor FloorInfo
// Ceiling describes ceiling properties.
Ceiling CeilingInfo... | ss1/content/archive/level/TileMap.go | 0.808937 | 0.555556 | TileMap.go | starcoder |
package parquet
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"math"
"github.com/mindhash/arrow-parquet-go/gen-go/parquet"
)
func boolsToBytes(bs []bool) []byte {
size := (len(bs) + 7) / 8
result := make([]byte, size)
for i := range bs {
if bs[i] {
result[i/8] |= 1 << uint32(i%8)
}
}
return re... | encode.go | 0.532911 | 0.454835 | encode.go | starcoder |
package timekit
import (
"strconv"
"time"
)
// ParseJavaScriptTime will convert the number of milliseconds since the Unix Epoch parameter into Golang `time` format. As a result, the output of the JavaScript `getTime()` function can be used as the parameter in this function.
func ParseJavaScriptTime(i int64) time.Ti... | conversion.go | 0.863895 | 0.50952 | conversion.go | starcoder |
package newrelic
import (
"container/heap"
"encoding/json"
"time"
)
// Error is the datatype representing an error or exception captured by the
// instrumented application. Errors are instance data and are not aggregated
// together in any way. Therefore, the final JSON expected by the collector is
// created by... | vendor/newrelic/src/newrelic/errors.go | 0.723602 | 0.495667 | errors.go | starcoder |
package doltdb
import (
"errors"
"strconv"
"strings"
)
func isDigit(b byte) bool {
return b >= byte('0') && b <= byte('9')
}
func parseInstructions(aSpec string) ([]int, error) {
instructions := make([]int, 0)
for i := 0; i < len(aSpec); i++ {
currInst := aSpec[i]
start := i
for i+1 < len(aSpec) && is... | go/libraries/doltcore/doltdb/anscestor_spec.go | 0.685002 | 0.412116 | anscestor_spec.go | starcoder |
package timeseries
import (
"io"
"math"
"github.com/dgryski/go-bitstream"
)
// The first time stamp delta is sized at 14 bits, because that size is enough to span a bit more than 4 hours (16,384 seconds), If one chose a Gorilla block larger than 4 hours, this size would increase.
const nBitsFirstDelta = 14
// En... | encoder.go | 0.669637 | 0.472257 | encoder.go | starcoder |
package utils
import (
"log"
"net/http"
"strconv"
"strings"
)
const lookupURL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/UID_ISO_FIPS_LookUp_Table.csv"
// AbbreviationToCountry : mapping of abbreviation to country name
var AbbreviationToCountry map[string]string
// Co... | utils/countrylookup.go | 0.504394 | 0.431524 | countrylookup.go | starcoder |
package ztype
import (
"reflect"
)
// IsByte Is []byte
func IsByte(v interface{}) bool {
return GetType(v) == "[]byte"
}
// IsString Is String
func IsString(v interface{}) bool {
return GetType(v) == "string"
}
// IsBool Is Bool
func IsBool(v interface{}) bool {
return GetType(v) == "bool"
}
// IsFloat64 Is fl... | ztype/is.go | 0.586523 | 0.435841 | is.go | starcoder |
package bstree
import (
"reflect"
number "github.com/ray-g/goalgos/math/number-theory"
)
// https://en.wikipedia.org/wiki/Binary_search_tree
type Item interface {
Less(other interface{}) bool
}
type Node struct {
Value Item
Parent *Node
Left, Right *Node
}
func (n *Node) less(than *Node) bool {
... | data-structures/trees/binary-search-tree/binary_search_tree.go | 0.716615 | 0.432603 | binary_search_tree.go | starcoder |
package algo
import (
gbt "github.com/dirkolbrich/gobacktest"
)
type biggerThanAlgo struct {
gbt.Algo
first, second gbt.AlgoHandler
}
// BiggerThan compares the value of the two containing algos.
func BiggerThan(first, second gbt.AlgoHandler) gbt.AlgoHandler {
return &biggerThanAlgo{
first: first,
second: s... | algo/comparison.go | 0.799755 | 0.470493 | comparison.go | starcoder |
package parser
import (
"fmt"
"mutant/ast"
"testing"
)
func checkParserErrors(t *testing.T, p *Parser) {
errors := p.Errors()
if len(errors) == 0 {
return
}
t.Errorf("parser has %d errors: ", len(errors))
for _, msg := range errors {
t.Errorf("parser error: %q", msg)
}
t.FailNow()
}
func testLetStmt(... | parser/parser_conds.go | 0.591015 | 0.488893 | parser_conds.go | starcoder |
package gocunets
import (
act "github.com/dereklstinson/gocunets/devices/gpu/nvidia/cudnn/activation"
gocudnn "github.com/dereklstinson/gocudnn"
)
//DataType struct wrapper for gocudnn.Datatype. Look up methods in gocudnn.
type DataType struct {
gocudnn.DataType
}
//Float sets and returns the Float flag
func (d ... | flags.go | 0.820721 | 0.483344 | flags.go | starcoder |
package pqt
import "fmt"
// Type is a common interface that needs to be implemented so a type can be considered the Type in PQT sense.
type Type interface {
fmt.Stringer
// Fingerprint returns unique identifier of the type. Two different types can have same SQL representation.
Fingerprint() string
}
// BaseType .... | type.go | 0.748812 | 0.47384 | type.go | starcoder |
package main
import (
"fmt"
"math"
"github.com/dustin/go-humanize"
)
// histogramData stores information about a histogram
type histogramData struct {
bins []int64
countPerBin []int64
sumPerBin []int64
totalCount int64
min int64
max int64
sum int64
}
func newKeyHistogram... | cmd/heavy-badger/histogram.go | 0.605682 | 0.49109 | histogram.go | starcoder |
package quotemodule
import (
"math"
"math/rand"
"strconv"
"strings"
"github.com/bwmarrin/discordgo"
bot "github.com/erikmcclure/sweetiebot/sweetiebot"
)
// QuoteModule manages the quoting system
type QuoteModule struct {
}
// New QuoteModule
func New() *QuoteModule {
return &QuoteModule{}
}
// Name of the m... | quotemodule/QuoteModule.go | 0.668556 | 0.491395 | QuoteModule.go | starcoder |
package holidays
import (
"time"
)
// IsNewYears falls on the 1st of January
func IsNewYears(input time.Time, observed bool) bool {
if observed {
if input.Month() == time.January {
if input.Day() == 1 {
return true
}
if input.Day() == 2 && input.Weekday() == time.Monday {
return true
}
}
... | holidays/holidays.go | 0.621885 | 0.619471 | holidays.go | starcoder |
package avl
// Insert - insert a new node into the tree
// returns the possibly updated root
func (tree *Tree) Insert(key Item, value interface{}) bool {
added := false
tree.root, added, _ = insert(key, value, tree.root)
if added {
tree.count += 1
}
return added
}
// internal routine for insert
func insert(ke... | avl/insert.go | 0.667256 | 0.438605 | insert.go | starcoder |
package order
import (
"fmt"
"strings"
"github.com/burrbd/dip/game/order/board"
)
func Decode(order, country string) (interface{}, error) {
tokens := strings.Split(strings.ToLower(order), " ")
n := len(tokens)
switch n {
case 2:
return decodeMove(tokens, country)
case 3:
return decodeHold(tokens, country... | game/order/decoder.go | 0.625781 | 0.445831 | decoder.go | starcoder |
package yasup
import (
crypto "crypto/rand"
"math/big"
"math/rand"
)
var zeroValueFloat64 float64
//Float64Insert will append elem at the position i. Might return ErrIndexOutOfBounds.
func Float64Insert(sl *[]float64, elem float64, i int) error {
if i < 0 || i > len(*sl) {
return ErrIndexOutOfBounds
}
*sl =... | float64Slices.go | 0.72086 | 0.500061 | float64Slices.go | starcoder |
package model
import (
"math"
"time"
"github.com/prometheus/common/model"
"github.com/timescale/promscale/pkg/prompb"
)
type Metadata struct {
MetricFamily string `json:"metric,omitempty"`
Unit string `json:"unit"`
Type string `json:"type"`
Help string `json:"help"`
}
type Samples i... | pkg/pgmodel/model/samples.go | 0.835383 | 0.465266 | samples.go | starcoder |
package v1
// ObjectPhase is a label for the condition of different scipian objects(Workspace and Run) at the current time.
type ObjectPhase string
// Valid statuses for scipian objects (Workspace and Run)
const (
// ObjPending means that the scipian object has been accepted by the system, but the job and/or pod rel... | api/v1/types.go | 0.526586 | 0.517815 | types.go | starcoder |
package service
// Stability is a type that represents the relative stability of a service
// module
type Stability int
const (
// StabilityExperimental represents relative stability of the most immature
// service modules. At this level of stability, we're not even certain we've
// built the right thing!
Stabili... | pkg/service/types.go | 0.747339 | 0.547948 | types.go | starcoder |
package statistics
import (
"math"
. "github.com/badgerodon/lalg"
)
// Calculate the covariance between two return series
func Covariance(x, y Vector) float64 {
if len(x) != len(y) {
panic("Vector lengths must be the same")
}
n := len(x)
sum, xsum, xmean, ysum, ymean := 0.0, 0.0, 0.0, 0.0, 0.... | statistics.go | 0.689096 | 0.542197 | statistics.go | starcoder |
package iso20022
// Specifies the calculation and the resulting margin and independent amount needed to cover the risk exposure of one party versus another.
type MarginCall2 struct {
// Provides additional information on the collateral account of the party delivering/receiving the collateral.
CollateralAccountIdent... | MarginCall2.go | 0.832441 | 0.575051 | MarginCall2.go | starcoder |
package lisper
import (
"path/filepath"
"reflect"
"runtime"
"strings"
)
// Op is the basic Operator type
type Op func(args ...Value) Value
// Name returns the name of the current Operator
func (o Op) Name() string {
r := reflect.ValueOf(o).Pointer()
nameFull := runtime.FuncForPC(r).Name()
nameEnd := filepath.... | ops.go | 0.745491 | 0.49585 | ops.go | starcoder |
package terminal
// Line manages a very encapsulated version of a terminal line's state
type Line struct {
Text []rune
Pos int
}
// Set overwrites Text and Pos with t and p, respectively
func (l *Line) Set(t []rune, p int) {
l.Text = t
l.Pos = p
}
// Clear erases the input line
func (l *Line) Clear() {
l.Text ... | line.go | 0.692954 | 0.545891 | line.go | starcoder |
package spaceimageformat
import (
"fmt"
"math"
"strconv"
)
// Parse calculates the space image format layers of the encoded image using the given image width and height.
func Parse(encodedImage string, width, height int) [][]int {
layers := [][]int{}
for layer := 0; layer < len(encodedImage)/width/height; layer... | 08-space-image-format/spaceimageformat/spaceimageformat.go | 0.787482 | 0.417806 | spaceimageformat.go | starcoder |
package corenlp
type Annotator string
// TokenizerAnnotator tokenizes the text.
const TokenizerAnnotator Annotator = "tokenize"
// CleanXmlAnnotator removes XML tokens from the document.
const CleanXmlAnnotator Annotator = "cleanxml"
// DocDateAnnotator allows specifying dates for documents.
const DocDateAnnotator ... | pkg/corenlp/annotator.go | 0.623148 | 0.420659 | annotator.go | starcoder |
package function
import (
"fmt"
"github.com/dolthub/go-mysql-server/sql"
)
// Point is a function that returns a point type containing values Y and Y.
type Point struct {
X sql.Expression
Y sql.Expression
}
var _ sql.FunctionExpression = (*Point)(nil)
// NewPoint creates a new point expression.
func NewPoint(... | sql/expression/function/point.go | 0.770896 | 0.478712 | point.go | starcoder |
package widgets
// tableColumn manages width of a column possibly with multiple sub-columns
type tableColumn struct {
// row indices at which number of sub-columns changes
rows []int
// Total width of a column, consult this value when the cell is not divided
Width int
// widths of sub-columns, consult this ins... | pkg/widgets/table_column.go | 0.522689 | 0.473353 | table_column.go | starcoder |
// Package camera contains virtual cameras and associated controls.
package camera
import (
"github.com/kasworld/h4o/math32"
"github.com/kasworld/h4o/node"
)
// Axis represents a camera axis.
type Axis int
// The two possible camera axes.
const (
Vertical = Axis(iota)
Horizontal
)
// Projection represents a ca... | camera/camera.go | 0.906895 | 0.587174 | camera.go | starcoder |
package aws
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"sync"
"time"
"github.com/Jeffail/gabs/v2"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/cenkalti/backoff/v4"
"github.com/google/go... | internal/impl/aws/output_dynamodb.go | 0.589716 | 0.457258 | output_dynamodb.go | starcoder |
package aws
import (
"context"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/turbot/steampipe-plugin-sdk/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/plugin"
"github.com/turbot/steampipe-plugin-sdk/plugin/transform"
)
//// TABLE DEFINITION
func tableAwsCloud... | aws/table_aws_cloudwatch_alarm.go | 0.553988 | 0.408424 | table_aws_cloudwatch_alarm.go | starcoder |
package iso20022
// Specifies amounts in the framework of a corporate action event..
type CorporateActionAmounts1 struct {
// Amount of money before any deductions and allowances have been made.
GrossCashAmount *ActiveCurrencyAndAmount `xml:"GrssCshAmt,omitempty"`
// Amount of money after deductions and allowance... | CorporateActionAmounts1.go | 0.683947 | 0.42477 | CorporateActionAmounts1.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 SettlementParties40 struct {
// First party in the set... | SettlementParties40.go | 0.681833 | 0.5119 | SettlementParties40.go | starcoder |
package common
import (
"context"
"github.com/FerretDB/FerretDB/internal/wire"
)
// Command represents a handler command.
type Command struct {
// Help is shown in the help function
Help string
// Handler processes command
Handler func(Handler, context.Context, *wire.OpMsg) (*wire.OpMsg, error)
}
// Command... | internal/handlers/common/commands.go | 0.615666 | 0.425128 | commands.go | starcoder |
package rphys
import (
"fmt"
"reflect"
"go-hep.org/x/hep/groot/rbase"
"go-hep.org/x/hep/groot/rbytes"
"go-hep.org/x/hep/groot/root"
"go-hep.org/x/hep/groot/rtypes"
"go-hep.org/x/hep/groot/rvers"
)
type LorentzVector struct {
obj rbase.Object
p Vector3 // 3-vector component
e float64 // time or energy
... | groot/rphys/lorentzvector.go | 0.710427 | 0.410047 | lorentzvector.go | starcoder |
package polynomial
import (
"github.com/consensys/gkr-mimc/common"
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
)
func init() {
initLagrangePolynomials()
}
// GetLagrangePolynomial returns a precalculated array representing the univariate
// lagrange polynomials on domainSize.
func GetLagrangePolynomial(doma... | polynomial/lagrange.go | 0.780286 | 0.598107 | lagrange.go | starcoder |
package gol
import (
"bytes"
"math"
"strings"
)
// Cell type
type Cell struct {
X int
Y int
}
// Field is a map from cell to whetehr it is alive or not
type Field map[Cell]bool
// Counts is a map with the number of alive cells around each cell
type Counts map[Cell]int
// Writes the neighbors of a given cell i... | gol/gol.go | 0.731922 | 0.45538 | gol.go | starcoder |
package client
// StorageClass describes the parameters for a class of storage for which PersistentVolumes can be dynamically provisioned. StorageClasses are non-namespaced; the name of the storage class according to etcd is in ObjectMeta.Name.
type V1beta1StorageClass struct {
// AllowVolumeExpansion shows whether... | vendor/github.com/kubernetes-client/go/kubernetes/client/v1beta1_storage_class.go | 0.826607 | 0.438485 | v1beta1_storage_class.go | starcoder |
package accumulator
import (
"fmt"
"github.com/dB2510/kryptology/pkg/core/curves"
"math"
)
// dad constructs two polynomials - dA(x) and dD(x)
// dA(y) = prod(y_A,t - y), t = 1...n
// dD(y) = prod(y_D,t - y), t = 1...n
func dad(values []Element, y Element) (Element, error) {
if values == nil || y == nil {
retu... | pkg/accumulator/lib.go | 0.672117 | 0.602559 | lib.go | starcoder |
package v2
import (
"encoding/json"
"fmt"
)
// KnownTypeValidationFunc defines a function that can validate types.
type KnownTypeValidationFunc func(ttype string) error
// KnownTypes defines a set of known types.
type KnownTypes map[string]TypedObjectCodec
// Register adds a codec for a specific type to the list... | vendor/github.com/gardener/component-spec/bindings-go/apis/v2/codecs.go | 0.723212 | 0.47524 | codecs.go | starcoder |
package runtime
import (
"fmt"
"log"
"strings"
"github.com/dylanhitt/commander/v2/pkg/matcher"
)
// ValidationResult will be returned after the validation was executed
type ValidationResult struct {
Success bool
Diff string
}
func newValidationResult(m matcher.MatcherResult) ValidationResult {
return Vali... | pkg/runtime/validator.go | 0.734976 | 0.502991 | validator.go | starcoder |
package iterator
// SortedRecordIterators combines a list of iterators; always yeilding the lowest value (if the records are of type Lesser)
// available from all iterators. To do this it keeps a local "peak cache" of the next
// value for each iterator. This means that iterators that produces data from volatile
// so... | iterator/sorted_iterators.go | 0.627951 | 0.410106 | sorted_iterators.go | starcoder |
package timeago
import (
"time"
"fmt"
"math"
"errors"
)
type DateAgoValues int
const (
SecondsAgo DateAgoValues = iota
MinutesAgo
HoursAgo
DaysAgo
WeeksAgo
MonthsAgo
YearsAgo
)
func TimeAgoFromNowWithTime(end time.Time) (string, error) {
return TimeAgoWithTime(time.Now(), end)
}
... | vendor/github.com/ararog/timeago/timeago.go | 0.561936 | 0.442094 | timeago.go | starcoder |
// Package area provides functions working with image areas.
package area
import (
"fmt"
"image"
"github.com/mum4k/termdash/private/numbers"
)
// Size returns the size of the provided area.
func Size(area image.Rectangle) image.Point {
return image.Point{
area.Dx(),
area.Dy(),
}
}
// FromSize returns the ... | private/area/area.go | 0.96143 | 0.842604 | area.go | starcoder |
package chronobiology
import (
"errors"
"math"
"time"
)
/* BEGIN INTERNAL FUNCTIONS */
// Used to truncate a float64 value
func round(value float64) float64 {
return math.Floor(value + .5)
}
// Used to truncate a float64 value to a particular precision
func roundPlus(value float64, places int) float64 {
shift ... | chronobiology.go | 0.78535 | 0.496216 | chronobiology.go | starcoder |
package bitbytepack
import (
"errors"
"math"
"math/bits"
"reflect"
)
// Errors
var (
ErrNotEnoughBitsToEmbedValue = errors.New("not enough values to embed value")
ErrArrayShorterThanMask = errors.New("array is shorter than the mask")
ErrInterfaceTypeNotSupported = errors.New("deducted interface type is no... | bitbytepack.go | 0.748536 | 0.570989 | bitbytepack.go | starcoder |
package test
import (
"bytes"
"fmt"
"go/printer"
"io/ioutil"
"testing"
"github.com/smgladkovskiy/go-mutesting/pkg/infection"
"github.com/smgladkovskiy/go-mutesting/pkg/models"
"github.com/smgladkovskiy/go-mutesting/pkg/parser"
"github.com/stretchr/testify/assert"
)
// Mutator tests a mutator.
// It mutates ... | test/mutator.go | 0.52683 | 0.407893 | mutator.go | starcoder |
package iso20022
// Plan that allows investors to schedule periodical investments or divestments, according to pre-defined criteria.
type InvestmentPlan5 struct {
// Frequency of the investment or divestment.
Frequency *EventFrequency1Code `xml:"Frqcy"`
// Frequency of the investment or divestment.
ExtendedFrequ... | InvestmentPlan5.go | 0.7696 | 0.494568 | InvestmentPlan5.go | starcoder |
package plan
// This topological sort implementation from:
// https://github.com/philopon/go-toposort
// Copyright 2017 <NAME>
// MIT licensed.
// Added to support comparing graphs for equality
type edge struct {
from, to string
}
type graph struct {
nodes map[string]bool
edges map[string]map[string]boo... | pkg/plan/graph.go | 0.642881 | 0.403508 | graph.go | starcoder |
package verhoeff_algorithm
import "unicode"
// From https://en.wikibooks.org/wiki/Algorithm_Implementation/Checksums/Verhoeff_Algorithm
// based on the "C" implementation
// The multiplication table
var verhoeff_d = [][]int{
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 0, 6, 7, 8, 9, 5},
{2, 3, 4, 0, 1, 7, 8, 9, ... | ver.go | 0.729134 | 0.436202 | ver.go | starcoder |
package ff
import "fmt"
// Fp2Size is the length in bytes of an Fp2 element.
const Fp2Size = 2 * FpSize
type Fp2 [2]Fp
func (z Fp2) String() string { return fmt.Sprintf("0: %v\n1: %v", z[0], z[1]) }
func (z *Fp2) SetOne() { z[0].SetOne(); z[1] = Fp{} }
// IsNegative returns 1 if z is lexicographically larger... | ecc/bls12381/ff/fp2.go | 0.711732 | 0.484502 | fp2.go | starcoder |
package arrays
//QUESTION: Roate a NxN array by 90 degrees
// 1 2 3 4
// 5 6 7 8
// 9 a b c
// d e f 10
// d 9 5 1
// e a 6 2
// f b 7 3
// 10 c 8 4
//RotateNewMatrix solves the problem with a new array, that is, not in-place
//It will rotate the matrix 90º to the right
//This will assume an NxN (square) array
func... | arrays/matrices.go | 0.601594 | 0.576482 | matrices.go | starcoder |
package vnc2video
import (
"image"
"image/color"
)
// RGBA is an in-memory image whose At method returns color.RGBA values.
type RGBImage struct {
// Pix holds the image's pixels, in R, G, B, A order. The pixel at
// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*3].
Pix []uint8
// Stride is the Pi... | rgb-image.go | 0.844537 | 0.574096 | rgb-image.go | starcoder |
package neural
import (
"math"
)
type Net struct {
layers []*Layer
}
func NewNet(layers []*Layer) *Net {
return &Net{
layers,
}
}
func RandomNet(numInputs, numLayers, numOutputs int) *Net {
layers := make([]*Layer, numLayers)
for i := range layers {
if i == len(layers)-1 {
layers[i] = RandomLayer(numI... | net.go | 0.723114 | 0.433262 | net.go | starcoder |
package day3
import (
"errors"
"fmt"
"strconv"
"strings"
)
// Parses the list of binary numbers, converting it to a list of decimal integers. Also returns the number of bits.
func parseInput(input string) ([]uint64, int) {
binaries := strings.Split(input, "\n")
if len(binaries) == 0 {
panic(errors.New("empty... | advent-of-code-2021/day3/day3.go | 0.757705 | 0.454412 | day3.go | starcoder |
package xcf
import (
"image"
"image/color"
"io"
"vimagination.zapto.org/byteio"
"vimagination.zapto.org/limage/lcolor"
"vimagination.zapto.org/memio"
)
type compressedImage struct {
tiles [][][]byte
width int
tile int
decompressed [64 * 64 * 4]byte
}
func (c *compressedImage) decompr... | xcf/compressed.go | 0.798187 | 0.500427 | compressed.go | starcoder |
package scale
import (
"image"
)
// Scale2X performs the Scale2X algorithm on an input NRGBA image and returns the new scaled image
func Scale2X(img *image.NRGBA) *image.NRGBA {
rescale_factor := 2
total_rows := img.Bounds().Max.X
total_columns := img.Bounds().Max.Y
// ri stands for rescaled_image
ri := image... | scale/scale.go | 0.565899 | 0.683324 | scale.go | starcoder |
package expr
import (
"fmt"
"github.com/leftmike/maho/evaluate"
"github.com/leftmike/maho/sql"
)
type Expr interface {
fmt.Stringer
Equal(e Expr) bool
HasRef() bool
}
type Op int
const (
AddOp Op = iota
AndOp
BinaryAndOp
BinaryOrOp
ConcatOp
DivideOp
EqualOp
GreaterEqualOp
GreaterThanOp
LessEqualOp
... | evaluate/expr/expr.go | 0.594787 | 0.407039 | expr.go | starcoder |
package stateful
type (
// StateMachine handles the state of the StatefulObject
StateMachine struct {
StatefulObject Stateful
transitionRules TransitionRules
}
)
// AddTransition adds a transition to the state machine.
func (sm *StateMachine) AddTransition(
transition Transition,
sourceStates States,
desti... | stateMachine.go | 0.794624 | 0.434101 | stateMachine.go | starcoder |
package hamt
// adapted from https://github.com/ipfs/go-unixfs/blob/master/hamt/util.go
import (
"fmt"
"math/bits"
"github.com/Stebalien/go-bitfield"
"github.com/ipfs/go-unixfsnode/data"
dagpb "github.com/ipld/go-codec-dagpb"
"github.com/spaolacci/murmur3"
)
// hashBits is a helper that allows the reading of... | vendor/github.com/ipfs/go-unixfsnode/hamt/util.go | 0.786418 | 0.487978 | util.go | starcoder |
package treap
type dataType = string
var dataDefault dataType
type Node struct {
priority int
value dataType
left *Node
right *Node
}
// GetLeft returns the left child of this Node
func (currentNode *Node) GetLeft() *Node {
return currentNode.left
}
// GetRight returns the right child of this Node
f... | example/treap/treapNode.go | 0.818338 | 0.606673 | treapNode.go | starcoder |
package huffman
import (
"errors"
"fmt"
"github.com/mjjs/gompressor/datastructure/dictionary"
"github.com/mjjs/gompressor/datastructure/priorityqueue"
"github.com/mjjs/gompressor/datastructure/vector"
)
type huffmanTreeNode struct {
frequency int
value byte
left *huffmanTreeNode
right *huffmanT... | algorithm/huffman/huffman.go | 0.791982 | 0.571109 | huffman.go | starcoder |
package off
import (
"bufio"
"io"
"os"
compgeo "github.com/200sc/go-compgeo"
"github.com/200sc/go-compgeo/dcel"
)
// Decode converts an OFF struct into a dcel.
func Decode(o OFF) (*dcel.DCEL, error) {
dc := new(dcel.DCEL)
numVertices := o.NumVertices
numFaces := o.NumFaces
if numVertices == 0 || numFaces... | dcel/off/load.go | 0.654674 | 0.421611 | load.go | starcoder |
type NumArray struct {
prefixSumArr []int
}
func Constructor(nums []int) NumArray {
n := len(nums)
runningSum := 0
prefixSumArr := make([]int, n+1)
prefixSumArr[0] = 0
for idx, num := range nums {
runningSum += num
prefixSumArr[idx+1] = runningSum
}
return NumArra... | range-sum-query-immutable/range-sum-query-immutable.go | 0.700588 | 0.587115 | range-sum-query-immutable.go | starcoder |
package gobulk
import (
"time"
"go.uber.org/zap"
)
// Iteration is the task to import a format from the first to the last container
type Iteration struct {
// ID should be used as identifier of the iteration in tracker
ID uint64
// Number should be used to identify the iteration (re-importing a format should re... | iteration.go | 0.538012 | 0.452113 | iteration.go | starcoder |
package constants
// DefaultLocalNetGenesisConfig contains the private keys and node IDs that come from avalanchego for the 5 bootstrapper nodes.
// When using avalanchego with the 'local' testnet option, the P-chain comes preloaded with five bootstrapper nodes whose node
// IDs are hardcoded in avalanchego source. N... | kurtosis/avalanche/libs/constants/default_local_net_genesis_config.go | 0.52829 | 0.423577 | default_local_net_genesis_config.go | starcoder |
package gnosj
import (
"fmt"
"reflect"
"github.com/totherme/nosj"
)
// JSONTypeMatcher is a gomega matcher which tests if a given value represents
// json data of a given type.
type JSONTypeMatcher struct {
typ string
}
// BeAnObject returns a gomega matcher which tests if a given value represents
// a json obj... | gnosj/json_type_matcher.go | 0.804598 | 0.546557 | json_type_matcher.go | starcoder |
package solutions
import (
"fmt"
"github.com/encero/advent-of-code-2021/helpers"
"strings"
)
func Day5Vents() error {
var vents []VentCoordinate
helpers.ReadLines("inputs/day5.txt", func(s string) error {
vents = append(vents, ParseVentCoordinates(s))
return nil
})
plot := PlotVents(CardinalVentsOnly(ven... | solutions/day5_vents.go | 0.610337 | 0.489748 | day5_vents.go | starcoder |
package decisiontree
import (
"sugar-level-client/models"
)
type Tree struct {
nodes map[SugarClassification]*Tree
name string
classification SugarClassification
lowest float32
highest float32
}
type SugarClassification int
const (
Unknown SugarClassification = 0
Low ... | client/decisiontree/decisiontree.go | 0.560974 | 0.432543 | decisiontree.go | starcoder |
// nolint: lll
package binaryauthorization
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/go/pulumi"
)
type AttestorAttestationAuthorityNote struct {
DelegationServiceAccountEmail *string `pulumi:"delegationServiceAccountEmail"`
NoteReference string `pulumi:"noteReference"`
PublicKeys []AttestorAt... | sdk/go/gcp/binaryauthorization/pulumiTypes.go | 0.524638 | 0.691152 | pulumiTypes.go | starcoder |
package path
import (
"time"
"github.com/weworksandbox/lingo"
"github.com/weworksandbox/lingo/expr"
"github.com/weworksandbox/lingo/expr/operator"
"github.com/weworksandbox/lingo/expr/set"
"github.com/weworksandbox/lingo/sql"
)
func NewTimeWithAlias(e lingo.Table, name, alias string) Time {
return Time{
en... | expr/path/time.go | 0.688468 | 0.422564 | time.go | starcoder |
package finding
import (
"errors"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/go-ozzo/ozzo-validation/v4/is"
)
const (
// PutFindingBatchMaxLength is the max number of `finding` data per request.
PutFindingBatchMaxLength = 50
// PutResourceBatchMaxLength is the max number of `resource` data ... | proto/finding/validator.go | 0.706899 | 0.52275 | validator.go | starcoder |
package vec
import (
"github.com/chewxy/math32"
"github.com/foxis/EasyRobot/pkg/core/math"
)
type Vector4D [4]float32
func (v *Vector4D) Sum() float32 {
var sum float32
for _, val := range v {
sum += val
}
return sum
}
func (v *Vector4D) Vector() Vector {
return v[:]
}
func (v *Vector4D) Slice(start, end... | pkg/core/math/vec/vec4d.go | 0.779112 | 0.627752 | vec4d.go | starcoder |
package dga
// Service is the API to use the operation types with DGraphAccess.
type Service struct {
access *DGraphAccess
}
// AlterSchema uses a schema definition to change the current DGraph schema.
// This operation is idempotent.
// Requires a DGraphAccess with a Write transaction.
func (s Service) AlterSchema(... | service.go | 0.810966 | 0.412708 | service.go | starcoder |
package gqlstruct
import (
"github.com/graphql-go/graphql"
"reflect"
"time"
)
// GraphqlTyped is the interface implemented by types that will provide a
// special `graphql.Type`.
type GraphqlTyped interface {
// GraphqlType returns the `graphql.Type` that represents the data type that
// implements this interfac... | types.go | 0.763131 | 0.455925 | types.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.