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 graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// ColumnDefinition provides operations to manage the drive singleton.
type ColumnDefinition struct {
Entity
// This column stores boolean values.
boole... | models/microsoft/graph/column_definition.go | 0.746878 | 0.435601 | column_definition.go | starcoder |
package pgverify
import (
"fmt"
log "github.com/sirupsen/logrus"
)
const (
// A full test is the default test mode. It is the only test mode that checks all
// of the rows of a given table, guaranteeing equivalent values between targets.
TestModeFull = "full"
// The bookend test is similar to the full test mo... | config.go | 0.75392 | 0.469581 | config.go | starcoder |
package parser
import (
"code.google.com/p/goyaml/token"
)
// Document stores data related to a single document in a stream.
type Document struct {
MajorVersion int
MinorVersion int
Content Node
}
// Node defines a node of the representation graph.
type Node interface {
Start() token.Position
Tag() strin... | parser/ast.go | 0.837387 | 0.566678 | ast.go | starcoder |
package multiMeasurement
import (
"fmt"
"time"
"math/rand"
"github.com/influxdata/influxdb-comparisons/bulk_data_gen/common"
)
const MeasSig = "Measurement-%d"
const FieldSig = "Field-%d"
const NumFields = 1 // number of fields for each measurement
const MeasMultiplier = 50 // scaleVar * measMultiplier = ... | bulk_data_gen/multi_measurement/generate_data.go | 0.653348 | 0.419886 | generate_data.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// OptionalClaim
type OptionalClaim struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for seria... | models/microsoft/graph/optional_claim.go | 0.776623 | 0.436622 | optional_claim.go | starcoder |
package server
import (
"github.com/openzipkin/zipkin-go-opentracing"
"github.com/openzipkin/zipkin-go-opentracing/thrift/gen-go/zipkincore"
"github.com/prometheus/client_golang/prometheus"
"strings"
"time"
)
// PrometheusCollector is a custom Collector
// which sends ZipKin traces to Prometheus
type PrometheusC... | server/prom_zip_collector.go | 0.820469 | 0.586345 | prom_zip_collector.go | starcoder |
// Package treepath implements the selection of nodes in an arbitrary tree
// of objects with XPath-like espressions.
// See path_test.go for usage example.
package treepath
import (
"strconv"
"strings"
)
// Element is the interface that must be satifsfied by a tree node in order to
// enable the treepath FindElem... | path.go | 0.849909 | 0.583945 | path.go | starcoder |
package multiplicity
import (
"github.com/00security/grammes/query/cardinality"
"github.com/00security/grammes/query/direction"
)
// Titan:
// http://titan.thinkaurelius.com/javadoc/1.0.0/com/thinkaurelius/titan/core/Multiplicity.html
// Wikipedia:
// http://en.wikipedia.org/wiki/Class_diagram#Multiplicity
// Obj... | query/multiplicity/multiplicity.go | 0.855263 | 0.422683 | multiplicity.go | starcoder |
package wasmtypes
// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\
const ScChainIDLength = 33
type ScChainID struct {
id [ScChainIDLength]byte
}
// Address returns the alias address that the chain ID actually represents
func (o ScChainID) Address() ScAddress {
return AddressFromBytes... | packages/wasmvm/wasmlib/go/wasmlib/wasmtypes/scchainid.go | 0.67694 | 0.604049 | scchainid.go | starcoder |
package vector
import (
"errors"
"fmt"
"reflect"
"strings"
)
// Vector implements a persistent bit-partitioned vector trie, an array-like
// persistent data structure.
type Vector struct {
count uint64
shift uint
root *node
tail *node
start int
}
// New returns a new vector containing the given elements.
... | vector.go | 0.836955 | 0.653072 | vector.go | starcoder |
package reads
import (
"bytes"
"strconv"
"github.com/influxdata/influxdb/v2/storage/reads/datatypes"
)
// NodeVisitor can be called by Walk to traverse the Node hierarchy.
// The Visit() function is called once per node.
type NodeVisitor interface {
Visit(*datatypes.Node) NodeVisitor
}
func WalkChildren(v NodeV... | storage/reads/predicate.go | 0.549399 | 0.408277 | predicate.go | starcoder |
package main
import (
"fmt"
"sort"
)
// measurements
type AdvMeasure struct {
medianEtaHonestThisRound float64
meanOpinionHonestLastRound float64
CurrentAdvOpinionForNode []bool
CurrentNHonestForNode []int
}
// measure the mean honest opinion of the round
func (sim *Sim) measureMeanHonestOpinionLastRo... | measurements.go | 0.52342 | 0.41561 | measurements.go | starcoder |
package tetris
import (
"github.com/nsf/termbox-go"
)
// A map from a point on a board to the color of that cell.
type ColorMap map[Vector]termbox.Attribute
// Returns whether a vector is a member of the color map.
func (cm ColorMap) contains(v Vector) bool {
_, ok := cm[v]
return ok
}
// A Board represents the ... | tetris/board.go | 0.852107 | 0.652228 | board.go | starcoder |
package iso20022
// Set of elements providing information on the original amount and currency information.
type AmountAndCurrencyExchange2 struct {
// Identifies the amount of money to be moved between the debtor and creditor, before deduction of charges, expressed in the currency as ordered by the initiating party ... | AmountAndCurrencyExchange2.go | 0.77552 | 0.691054 | AmountAndCurrencyExchange2.go | starcoder |
package squares
import (
"image"
"image/color"
"io"
"math"
svg "github.com/ajstarks/svgo"
"github.com/taironas/tinygraphs/draw"
)
//Grid builds an image with 6X6 quadrants of alternate colors.
func Grid(m *image.RGBA, color1, color2 color.RGBA) {
size := m.Bounds().Size()
quad := size.X / 6
for x := 0; x < ... | draw/squares/squares.go | 0.658088 | 0.481332 | squares.go | starcoder |
package gorbi
import (
"fmt"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/mat"
"math"
)
// Radial basis functions based on the euclidean distance
func multiquadric(epsilon, r float64) float64 {
return math.Sqrt(math.Pow(1.0/epsilon*r, 2.0) + 1)
}
// Radial basis interpolator
type RBF struct {
xi [][]float64... | rbf.go | 0.575349 | 0.564699 | rbf.go | starcoder |
package date
import "fmt"
import "time"
// TimeOfDayRange specifies a duration within a day
type TimeOfDayRange struct {
Hour, Minute int
Length time.Duration
}
func (tr TimeOfDayRange)IsInitialized() bool { return tr.Length > 0 }
func (tr TimeOfDayRange)Start() time.Time {
return time.Date(1970,0,0, tr.... | date/timeofday.go | 0.761361 | 0.547646 | timeofday.go | starcoder |
package types
import (
"fmt"
"math"
)
// Grid outlines the default word search grid.
type Grid struct {
Rows []*Row // Rows
}
/* BEGIN EXPORTED METHODS */
// NewGrid initializes a new grid with a given width and height.
func NewGrid(width, height uint64) *Grid {
grid := &Grid{
Rows: []*Row{}, // Set rows
} /... | types/grid.go | 0.68721 | 0.52476 | grid.go | starcoder |
package fixture
const (
// Simple schema with definitions and refs
TestSchemaWithDefinitions = `
{
"definitions": {
"movie": {
"type": "object",
"required": ["id", "name"],
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
... | fixture/fixture.go | 0.577972 | 0.441191 | fixture.go | starcoder |
package stats
import (
"container/heap"
"math"
"math/rand"
"sort"
"time"
)
type Histogram struct {
decay float64
horizon time.Time
resample time.Duration
sample sample
size int
start time.Time
values []int64
}
func (h *Histogram) Len() int {
return len(h.sample)
}
func (h *Histogram) Me... | pkg/stats/stats.go | 0.629319 | 0.445349 | stats.go | starcoder |
package steps
import (
"bytes"
"fmt"
"log"
"math"
"sort"
"strconv"
"time"
"github.com/bitflow-stream/go-bitflow/bitflow"
"github.com/bitflow-stream/go-bitflow/script/reg"
)
func RegisterLoggingSteps(b reg.ProcessorRegistry) {
b.RegisterStep("print_header", print_header, "Print every changing header to the ... | steps/logging.go | 0.575707 | 0.408808 | logging.go | starcoder |
package svgparser
import (
"fmt"
"gioui.org/f32"
"strings"
)
// This file defines the basic path structure
// Operation groups the different SVG commands
type Operation interface {
// SVG text representation of the command
fmt.Stringer
// add itself on the driver `d`, after aplying the transform `M`
drawTo(d... | internal/svgparser/path.go | 0.78535 | 0.598077 | path.go | starcoder |
package exp
// AndExpression combines a series of sub-expressions using AND logic
type AndExpression []Expression
// And combines one or more expression parameters into an AndExpression
func And(expressions ...Expression) AndExpression {
return AndExpression(expressions)
}
func (andExpression AndExpression) And(exp... | and.go | 0.802826 | 0.591192 | and.go | starcoder |
package graphql_models
import (
"fmt"
"io"
"strconv"
boilergql "github.com/web-ridge/utils-go/boilergql/v3"
)
type Node interface {
IsNode()
}
type BooleanFilter struct {
EqualTo *bool `json:"equalTo"`
NotEqualTo *bool `json:"notEqualTo"`
}
type FloatFilter struct {
EqualTo *float64 `json:"e... | issue-6-edges-connections/graphql_models/generated_models.go | 0.632049 | 0.427217 | generated_models.go | starcoder |
package require2
import (
"errors"
"reflect"
"runtime"
"strconv"
"strings"
"testing"
"golang.org/x/exp/constraints"
)
func Equal[T comparable](t *testing.T, expected T, actual T) {
if expected != actual {
fatalf(t, "assertion failed: %#v == %#v", expected, actual)
}
}
func DeepEqual[T any](t *testing.T, ... | internal/require2/require.go | 0.575469 | 0.629604 | require.go | starcoder |
package coins
import "sort"
const maxUint = ^uint(0)
const maxInt = int(maxUint >> 1)
// Coin is a coin with a value and quantity
type Coin struct {
value int
Quantity int
}
// Coins is a slice of Coins
type Coins []Coin
// ByValue implements sort.Interface for Coins based on Coin.value
type ByValue Coins
fu... | coins/coins.go | 0.806091 | 0.515803 | coins.go | starcoder |
package lib
import (
"fmt"
"math"
)
// Sum To sum all values of int slice
func Sum(values []int) (count int) {
for _, v := range values {
count += v
}
return
}
// Mult To sum all values of int slice
func Mult(values []int) (count int) {
count = 1
for _, v := range values {
count *= v
}
return
}
// Un... | lib/slice.go | 0.805135 | 0.440048 | slice.go | starcoder |
package numeric
// UniqueInts takes an input slice of ints and
// returns a new slice of ints without duplicate values.
func UniqueInts(a []int) []int {
l := len(a)
if l <= 1 {
return a
}
m := make(map[int]struct{}, l)
r := make([]int, 0, l)
for _, v := range a {
if _, ok := m[v]; !ok {
m[v] = struct{}{... | numeric/unique.go | 0.862395 | 0.487063 | unique.go | starcoder |
package config
import (
"fmt"
"time"
"github.com/mitchellh/mapstructure"
"github.com/ti-mo/conntracct/pkg/bpf"
)
// DefaultProbeConfig is the default probe configuration.
var DefaultProbeConfig = ProbeConfig{
RateCurve: &Curve{
Zero: &CurvePoint{
Age: durationPtr(0),
Rate: durationPtr(20 * time.Second... | internal/config/probe.go | 0.710025 | 0.411702 | probe.go | starcoder |
package forGraphBLASGo
import (
"github.com/intel/forGoParallel/pipeline"
)
type matrixAsMask[T Number] struct {
v *matrixReference[T]
}
func newMatrixAsMask[T Number](v *matrixReference[T]) functionalMatrix[bool] {
return matrixAsMask[T]{v: v}
}
func (matrix matrixAsMask[T]) resize(ref *matrixReference[bool], n... | functional_MatrixAsMask.go | 0.569733 | 0.55435 | functional_MatrixAsMask.go | starcoder |
package velocypack
// builderBuffer is a byte slice used for building slices.
type builderBuffer []byte
const (
minGrowDelta = 128 // Minimum amount of extra bytes to add to a buffer when growing
maxGrowDelta = 1024 * 1024 // Maximum amount of extra bytes to add to a buffer when growing
)
// IsEmpty retur... | deps/github.com/arangodb/go-velocypack/builder_buffer.go | 0.802246 | 0.46557 | builder_buffer.go | starcoder |
package advent
import (
"fmt"
"log"
"sort"
)
func oneAndThreeGaps(filename string) (ones int, threes int) {
values, err := readIntFile(filename, "\n")
if err != nil {
log.Fatal(err)
}
sort.Ints(values)
values = append(values, values[len(values)-1]+3)
old := 0
for _, value := range values {
switch value ... | cmd/day10.go | 0.624179 | 0.51068 | day10.go | starcoder |
package satellite
import (
"fmt"
"math"
"strconv"
"strings"
)
// Constants
const TWOPI float64 = math.Pi * 2.0
const DEG2RAD float64 = math.Pi / 180.0
const RAD2DEG float64 = 180.0 / math.Pi
const XPDOTP float64 = 1440.0 / (2.0 * math.Pi)
// Holds latitude and Longitude in either degrees or radians
type LatLong ... | helpers.go | 0.728265 | 0.509642 | helpers.go | starcoder |
package fun
import "math"
// ModBesselI0 returns the modified Bessel function I0(x) for any real x.
func ModBesselI0(x float64) (ans float64) {
ax := math.Abs(x)
if ax < 15.0 { // Rational approximation.
y := x * x
return mbpoly(i0p, 13, y) / mbpoly(i0q, 4, 225.0-y)
}
// rational approximation with exp(x)/sq... | fun/modbessel.go | 0.827759 | 0.495972 | modbessel.go | starcoder |
package bst
// Item - the type to be sorted
type Item interface{}
// Node of a binary tree
type Node struct {
value Item
left *Node
right *Node
parent *Node // doubly linked
}
// PrioritizeTreeItem - custom comparison for prioritizing tree items
// basic sort would need "a < b" ("a > b" for hight to low)
t... | bst/bst.go | 0.829665 | 0.454835 | bst.go | starcoder |
package easybind
import (
"reflect"
"strconv"
"strings"
"time"
)
func stringBinder(val string, typ reflect.Type) reflect.Value {
return reflect.ValueOf(val)
}
func uintBinder(val string, typ reflect.Type) reflect.Value {
if len(val) == 0 {
return reflect.Zero(typ)
}
uintValue, err := strconv.ParseUint(val... | binder.go | 0.580947 | 0.44071 | binder.go | starcoder |
package vector
import (
"math"
)
// IVector is the interface of Vector class.
type IVector interface {
Len() int
GetAt(int) float64
SetAt(int, float64)
}
// Vector class implements IVector interface.
// Internally, it stores data into a float64 slice.
type Vector struct {
vec []float64
}
// New creates a vecto... | vector/float64/vector.go | 0.864411 | 0.673165 | vector.go | starcoder |
package ast
//Written by the generator, do not over write
type AnnotatedNodeVisitor interface {
VisitAnnotatedNode(n *AnnotatedNode) (Node, error)
}
type AssignmentNodeVisitor interface {
VisitAssignmentNode(n *AssignmentNode) (Node, error)
}
type BoolOpVisitor interface {
VisitBoolOp(n *BoolOp) (Node, error)
}
... | internal/parser/ast/ast_visitors.go | 0.504883 | 0.583737 | ast_visitors.go | starcoder |
package shunting
import (
"strconv"
"github.com/metalnem/parsing-algorithms/ast"
"github.com/metalnem/parsing-algorithms/parse"
"github.com/metalnem/parsing-algorithms/scan"
"github.com/pkg/errors"
)
type assoc int
const (
left assoc = iota
right
)
type kind int
const (
unary kind = iota
binary
)
type o... | parse/shunting/shunting.go | 0.620392 | 0.464841 | shunting.go | starcoder |
package gomfa
func Ldsun(p *[3]float64, e *[3]float64, em float64, p1 *[3]float64) {
/*
** - - - - - -
** L d s u n
** - - - - - -
**
** Deflection of starlight by the Sun.
**
** Given:
** p *[3] float64 direction from observer to star (unit vector)
** e *[3] float64 direct... | ldsun.go | 0.76986 | 0.645762 | ldsun.go | starcoder |
package mangerattack
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"log"
"math/big"
)
// countQueries is a counter to know how many queries were necessary
var countQueries int
// Constants
const (
byteSize = 8
)
// A few useful big.Int :
var (
zero = new(big.Int).SetInt64(int64(0))
two = new(big.Int).SetIn... | mangerattack/attack.go | 0.557123 | 0.496216 | attack.go | starcoder |
package geom
import "math"
// Withiner is an interface for types that can be determined to be
// within a polygon or not.
type Withiner interface {
Within(Polygonal) WithinStatus
}
// pointInPolygonal determines whether "pt" is
// within any of the polygons in "pg".
// adapted from https://rosettacode.org/wiki/Ray-... | within.go | 0.741206 | 0.506347 | within.go | starcoder |
package parsehtml
import (
"strings"
"golang.org/x/net/html"
)
// Node wraps html.Node so we can define additional convenience methods
type Node struct {
*html.Node
}
// Attribute wraps html.Attribute so we can define additional convenience methods
type Attribute struct {
*html.Attribute
}
// NodeP represents ... | src/common/parsehtml/parsehtml.go | 0.875946 | 0.484136 | parsehtml.go | starcoder |
package template
import (
"fmt"
"math"
"strconv"
"github.com/coveooss/gotemplate/v3/collections"
)
func toInt(value interface{}) int {
// We convert to the string representation to ensure that any type is converted to int
return must(strconv.Atoi(fmt.Sprintf("%v", value))).(int)
}
func toInt64(value interface... | template/math_utilities.go | 0.644561 | 0.452173 | math_utilities.go | starcoder |
package dataset
import (
"sort"
"time"
)
type ordered interface {
time.Time | string
}
// Indexer holds a unique set of values, and records the order in which they were added.
// Currently, it supports string and time.Time data.
type Indexer[T ordered] struct {
values []T
indices map[T]int
inOrder bool
}
// ... | dataset/indexer.go | 0.706697 | 0.518485 | indexer.go | starcoder |
package vec3
import (
"math"
)
// Vec3 defines a 3-dimension vector
type Vec3 struct {
I float64
J float64
K float64
}
// New returns a new Vec3 pointer
func New(i float64, j float64, k float64) *Vec3 {
return &Vec3{i, j, k}
}
// Add takes a vec3 transforming v1 by adding their dimensions
func (v1 *Vec3) Add(v... | vec3/vec3.go | 0.934649 | 0.521654 | vec3.go | starcoder |
package bzone
import (
"math"
)
import vec "github.com/tflovorn/scExplorer/vector"
type BzFunc func(k vec.Vector) float64
type bzConsumer func(next, total float64) float64
// Sum values of fn over all Brillouin zone points.
// Uses Kahan summation algorithm for increased accuracy.
func Sum(pointsPerSide int, dimens... | bzone/bzone.go | 0.672332 | 0.459743 | bzone.go | starcoder |
package mappers
// TestHelper describes a *testing.T helper.
// See: https://golang.org/pkg/testing/#T.Helper
type TestHelper interface {
Helper()
}
// AdvancedMap maps a standard logger to an advanced logger interface.
type AdvancedMap struct {
standardMap
t TestHelper
}
// NewAdvancedMap returns an advanced log... | mappers/advanced.go | 0.756178 | 0.454654 | advanced.go | starcoder |
package keyvaluestoretest
import (
"fmt"
"math"
"strconv"
"strings"
"sync"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/ccbrown/keyvaluestore"
)
type testBinaryMarshaler struct{}
func (testBinaryMarshaler) MarshalBinary() ([]byte, error) {
return []byte... | keyvaluestoretest/backend.go | 0.524882 | 0.635449 | backend.go | starcoder |
package slice
// DeduplicateBool performs order preserving, in place deduplication of a bool slice
func DeduplicateBool(a []bool) []bool {
if len(a) < 2 {
return a
}
seen := make(map[bool]struct{})
j := 0
for k := range a {
if _, ok := seen[a[k]]; ok {
continue
}
seen[a[k]] = struct{}{}
a[j] = a[k]... | deduplicate.go | 0.80479 | 0.609059 | deduplicate.go | starcoder |
package stats
import (
"fmt"
"math"
"sort"
)
// Sum returns the sum of values in a sample.
func Sum(a []float64) float64 {
sum := 0.0
for _, v := range a {
sum += v
}
return sum
}
// Mean returns the mean value of the sample.
func Mean(a []float64) float64 {
return Sum(a) / float64(len(a))
}
// Cov return... | stats/stats.go | 0.888885 | 0.65435 | stats.go | starcoder |
package eval
import (
"fmt"
)
// ScoreType represents the type of score.
type ScoreType int8
const (
Invalid ScoreType = iota
Heuristic
MateInX
Inf // Won position (= opponent checkmate)
NegInf // Lost position (= in checkmate)
)
// Pawns presents a fractional number of pawns.
type Pawns float32
func (p P... | pkg/eval/score.go | 0.806738 | 0.686777 | score.go | starcoder |
package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
)
// machineConfig contains the configuration information of a single machine.
// This can be used to construct a machine object.
type machineConfig struct {
Name string `json:"name"`
Nodes [][]string `json:"nodes"`
ConsoleIn struct ... | machine.go | 0.578329 | 0.460653 | machine.go | starcoder |
package collections
// Element represents (key, value) with backed by the Data interface
type Element struct {
Key Data
Value Data
}
// ElementsByKeyStringAsc used to used low to high where key is of type string
type ElementsByKeyStringAsc []Element
func (e ElementsByKeyStringAsc) Len() int { return le... | element_sorters.go | 0.717408 | 0.442275 | element_sorters.go | starcoder |
package sparsemat
import (
"encoding/json"
"fmt"
"reflect"
"sort"
"strings"
"github.com/olekukonko/tablewriter"
)
type DOKVector struct {
length int
values map[int]int
}
type dokVector struct {
Length int
Values map[int]int
}
func (vec *DOKVector) MarshalJSON() ([]byte, error) {
return json.Marshal(dokV... | dokvec.go | 0.715921 | 0.562357 | dokvec.go | starcoder |
package chit
import "context"
// FirstN produces an iterator containing the first n elements of the input
// (or all of the input, if there are fewer than n elements).
// Excess elements in the input are discarded by calling inp.Cancel.
func FirstN[T any](ctx context.Context, inp *Iter[T], n int) *Iter[T] {
return N... | n.go | 0.581778 | 0.412885 | n.go | starcoder |
package differs
import (
"context"
"time"
"github.com/dolthub/dolt/go/libraries/doltcore/table/typed/noms"
"github.com/dolthub/dolt/go/store/diff"
"github.com/dolthub/dolt/go/store/types"
)
var _ Differ = (*MapRowsAsDiffs)(nil)
// MapRowsAsDiffs takes a map of rows and provides a Differ interface to it's data... | go/payments/pkg/doltutils/differs/row_iter_as_differ.go | 0.637031 | 0.415551 | row_iter_as_differ.go | starcoder |
package constants
// AzureDescriptions enumerates Microsoft Azure instance offerings
var AzureDescriptions = []Description{
{Size: "Basic_A0", CPU: 1, RAM: 0.750000, Disk: "20", Region: "centralus", Price: 0.018000},
{Size: "Basic_A0", CPU: 1, RAM: 0.750000, Disk: "20", Region: "eastus", Price: 0.018000},
{Size: "B... | constants/azureConstants.go | 0.642545 | 0.592991 | azureConstants.go | starcoder |
package main
import (
"fmt"
)
const gridSerial int = 8868
const sideSize int = 300
type Point struct {
x, y, power int
}
func main() {
data := make([][]int, sideSize+1)
for i := range data {
data[i] = make([]int, sideSize+1)
}
for y := 1; y < len(data); y++ {
for x := 1; x < len(data[y]); x++ {
data[y]... | level_11/level_11.go | 0.684475 | 0.561936 | level_11.go | starcoder |
package map180
type Region string
// Named regions allow for installing map180 with different regions of zoomable data.
// If you change the zoom region bbox etc in the DB then add another Region and bbox
// to allZoomRegions.
// In the db 0 is always the global region
// The region number for the zoom region just ha... | vendor/github.com/GeoNet/kit/map180/regions.go | 0.605449 | 0.421552 | regions.go | starcoder |
package params
import (
"NN-512/internal/compile/author/cgen"
"NN-512/internal/compile/plan"
"fmt"
"sort"
)
const (
indent = space + space + space + space
space = " "
suffix = "Params"
)
func Name(pl *plan.Plan) string {
return pl.Config.Prefix + suffix
}
func Fwd(name string) cgen.Gen {
comment := cgen.C... | internal/compile/author/params/params.go | 0.648689 | 0.400398 | params.go | starcoder |
package ilium
import "fmt"
type TracerWeightTracker struct {
beta float32
pVertexCount int
lastPs []float32
qVertexCount int
firstQs []float32
middleRatio float32
}
// TracerWeightTracker objects are safely copyable, as long as only
// one copy is used for computing weights at a time.
func... | ilium/tracer_weight_tracker.go | 0.67104 | 0.53965 | tracer_weight_tracker.go | starcoder |
package adatypes
import (
"bytes"
"math"
"strconv"
)
// unpackedValue handle Adabas fields with the Packed format
// type. The unpacked value is defined with corresponding
// values in an byte.
type unpackedValue struct {
adaValue
value []byte
}
// newUnpackedValue creates new unpacked value
func newUnpackedVal... | adatypes/unpacked_value.go | 0.731634 | 0.469277 | unpacked_value.go | starcoder |
package timestamp
import (
"math"
"sync/atomic"
"time"
"github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/timestamp"
)
const (
microsecondsPerSecond = 1000000
nanosecondsPerMicrosecond = 1000
)
// MicroTS is a microsecond-granularity Unix UTC timestamp.
type MicroTS int64
// InfiniteFut... | pkg/timestamp/microts.go | 0.888698 | 0.449211 | microts.go | starcoder |
package playtak
import (
"errors"
"github.com/nelhage/taktician/tak"
)
type FPARule interface {
Greeting(tak.Color) []string
LegalMove(p *tak.Position, m tak.Move) error
GetMove(p *tak.Position) (tak.Move, bool)
SurveyURL() string
}
type CenterBlack struct{}
func (c *CenterBlack) Greeting(color tak.Color) []... | cmd/internal/playtak/fpa.go | 0.526586 | 0.412057 | fpa.go | starcoder |
package main
import (
"encoding/json"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"time"
)
/**
* @info The generic data structure extended by other documentation structures
* @property {string} [Name] The Name of the structure
* @property {string} [Type] The type of the structure
* @property {str... | docgen.go | 0.696578 | 0.47524 | docgen.go | starcoder |
package core
import (
"encoding/json"
"errors"
)
// FeatureOfInterest in SensorThings represents the phenomena an Observation is detecting. In some cases a FeatureOfInterest
// can be the Location of the Sensor and therefore of the Observation. A FeatureOfInterest is linked to a single Observation
type FeatureOfInt... | featureofinterest.go | 0.786623 | 0.437283 | featureofinterest.go | starcoder |
package jwt
import (
"encoding/json"
"reflect"
"time"
)
// TimePrecision determines how precisely time is measured
// by this library. When serializing and deserialzing tokens,
// time values are automatically truncated to this precision.
// See the time package's Truncate method for more detail
const TimePrecisio... | vendor/github.com/dgrijalva/jwt-go/v4/time.go | 0.853303 | 0.403214 | time.go | starcoder |
package input
var Example = []string{
"light red bags contain 1 bright white bag, 2 muted yellow bags.",
"dark orange bags contain 3 bright white bags, 4 muted yellow bags.",
"bright white bags contain 1 shiny gold bag.",
"muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.",
"shiny gold bags contain ... | day7/input/input.go | 0.595257 | 0.840946 | input.go | starcoder |
package ffmpeg
import (
"fmt"
"runtime"
)
// Arger is an interface that can be used to append arguments to an Args slice.
type Arger interface {
Args() []string
}
// Args represents a slice of arguments to be passed to ffmpeg.
type Args []string
// LogLevel sets the LogLevel to l and returns the result.
func (a ... | pkg/ffmpeg/options.go | 0.826991 | 0.445891 | options.go | starcoder |
package engine
import (
"math"
"regexp"
"strconv"
"strings"
"github.com/golang/glog"
"github.com/minio/minio/pkg/wildcard"
)
// Operator is string alias that represents selection operators enum
type Operator string
const (
// Equal stands for ==
Equal Operator = ""
// MoreEqual stands for >=
MoreEqual Op... | pkg/engine/pattern.go | 0.535827 | 0.401189 | pattern.go | starcoder |
package processor
import (
"encoding/json"
"reflect"
"strconv"
)
const (
stringType = "string"
)
// EventAggregator summarizes a set of events.
type EventAggregator struct {
// CriticalPercent is the threshold percent of events that contain a given property, under which a property will be ommitted from the even... | schema_suggestor/processor/event_aggregator.go | 0.697197 | 0.495972 | event_aggregator.go | starcoder |
package main
import (
"math"
)
// V4 represents a 4-dimensional (or homogeneous 3-dimensional) vector.
type V4 struct {
x, y, z, w float64
}
func NewV4(x float64, y float64, z float64) *V4 {
return &V4{x: x, y: y, z: z, w: 1}
}
// Length returns the length or magnitude of this vector.
func (v *V4) Length() float... | matrix.go | 0.89306 | 0.593963 | matrix.go | starcoder |
package sqrt
import (
"math/big"
)
// sqrtLittleSquaresBigInt is the original algorithm trying to deal with integer overflows
// caused by the increasing/recursive behavior of the algorithm that requires getting the
// square root of larger and larger integers.
// Since big numbers allocate memory, this algorithm i... | sqrt_by_hand_using_big_number.go | 0.793266 | 0.513912 | sqrt_by_hand_using_big_number.go | starcoder |
package merkletree
import (
"crypto"
"encoding/binary"
"fmt"
)
// PathElement is a single element within a path.
type PathElement struct {
IsLeaf bool // Is this node a leaf?
IsLeft bool // Is the left child of its father.
Depths uint32 // Depths to this node.
Hash []byte // Hash of content.
IsEmpty... | merkletree/path.go | 0.68342 | 0.46223 | path.go | starcoder |
package sexpconv
import (
"go/ast"
"go/token"
"sexp"
"xast"
)
func (conv *converter) Stmt(node ast.Stmt) sexp.Form {
switch node := node.(type) {
case *ast.IfStmt:
return conv.IfStmt(node)
case *ast.ReturnStmt:
return conv.ReturnStmt(node)
case *ast.BlockStmt:
return conv.BlockStmt(node)
case *ast.Decl... | src/sexpconv/stmt.go | 0.504639 | 0.438545 | stmt.go | starcoder |
package asm
func (o Opcodes) Aad(ops ...Operand) { o.a.op("AAD", ops...) }
func (o Opcodes) AAD(ops ...Operand) { o.a.op("AAD", ops...) }
func (o Opcodes) Aam(ops ...Operand) { o.a.op("AAM", ops...) }
func (o Opcodes) AAM(ops ...Operand) { o.a.op("AAM", ops...) ... | vendor/github.com/tmthrgd/asm/opcode.go | 0.551574 | 0.526465 | opcode.go | starcoder |
// Package verifier allows client to verify a tree proof.
package verifier
import (
"bytes"
"errors"
"fmt"
"github.com/google/key-transparency/core/tree"
"github.com/google/key-transparency/core/tree/sparse"
)
var (
// ErrNeighborsLen occurs when the neighbor list length is longer than
// the maximum allowed... | core/tree/sparse/verifier/verifier.go | 0.680029 | 0.482917 | verifier.go | starcoder |
package tracker
import (
"time"
"github.com/tellor-io/telliot/pkg/apiOracle"
)
type Ampl struct {
granularity float64
}
func (a Ampl) Require(at time.Time) map[string]IndexProcessor {
return map[string]IndexProcessor{
"AMPL/USD": VolumeWeightedAPIs(TimeWeightedAvg(24*time.Hour, NoDecay)),
"AMPL/BTC": Amp... | pkg/tracker/ampl.go | 0.647241 | 0.41478 | ampl.go | starcoder |
package tsm1
// boolean encoding uses 1 bit per value. Each compressed byte slice contains a 1 byte header
// indicating the compression type, followed by a variable byte encoded length indicating
// how many booleans are packed in the slice. The remaining bytes contains 1 byte for every
// 8 boolean values encoded.... | tsdb/tsm1/bool.go | 0.883009 | 0.541773 | bool.go | starcoder |
package binomial_theorem
import (
"fmt"
"math"
"strings"
"strconv"
)
type expression struct {
literals []literal
value int
exp int
}
func Multiply(a *expression, b *expression) *expression {
expr := expression{literals: []literal{}, value: 0, exp: 1}
a = a.Expand()
b = b.Expand()
expr.value = a.value * b.... | expression.go | 0.506347 | 0.415432 | expression.go | starcoder |
package dist
import (
"bitbucket.org/dtolpin/infergo/ad"
"bitbucket.org/dtolpin/infergo/mathx"
"fmt"
"math"
)
var (
logpi, log2pi float64
)
func init() {
log2 := math.Log(2)
logpi = math.Log(math.Pi)
log2pi = log2 + logpi
}
type normal struct{}
var Normal normal
func (dist normal) Observe(x []float64) flo... | dist/ad/dist.go | 0.616705 | 0.437163 | dist.go | starcoder |
package graph
import (
"github.com/hasansino/gobasics/structures/queue"
"github.com/hasansino/gobasics/structures/stack"
)
// Graph is ... well, a graph
type Graph struct {
size int
nodes []*Node
edges [][]*Edge // Adjacency Matrix
}
// Node of a graph
type Node struct {
value interface{}
}
// Edge of graph
... | structures/graph/graph.go | 0.739893 | 0.417153 | graph.go | starcoder |
package types
import (
"fmt"
"sort"
"strconv"
"strings"
)
var (
// NullPath means no path
NullPath = Path([]string{})
// Dot means self - this.
Dot = Path([]string{"."})
)
// RFC6901ToPath takes a path expression in the format of IETF RFC6901 (JSON pointer) and convert it to a Path
func RFC6901ToPath(path s... | pkg/types/path.go | 0.688468 | 0.528473 | path.go | starcoder |
package forGraphBLASGo
type scalarApply[Dt, Df any] struct {
op UnaryOp[Dt, Df]
s *scalarReference[Df]
}
func newScalarApply[Dt, Df any](op UnaryOp[Dt, Df], s *scalarReference[Df]) computeScalarT[Dt] {
return scalarApply[Dt, Df]{op: op, s: s}
}
func (compute scalarApply[Dt, Df]) computeElement() (result Dt, ok b... | functional_Scalar_ComputedApply.go | 0.808483 | 0.659193 | functional_Scalar_ComputedApply.go | starcoder |
package collector
import (
"time"
"github.com/codragonzuo/beats/libbeat/common"
)
// CounterCache keeps a cache of the last value of all given counters
// and allows to calculate their rate since the last call.
// All methods are thread-unsafe and must not be called concurrently
type CounterCache interface {
// ... | x-pack/metricbeat/module/prometheus/collector/counter.go | 0.731826 | 0.526343 | counter.go | starcoder |
// Copyright 2015, <NAME>, see LICENSE for details.
// Copyright 2019, Minio, Inc.
package reedsolomon
import (
"sync"
)
//go:noescape
func _galMulAVX512Parallel81(in, out [][]byte, matrix *[matrixSize81]byte, addTo bool)
//go:noescape
func _galMulAVX512Parallel82(in, out [][]byte, matrix *[matrixSize82]byte, add... | galoisAvx512_amd64.go | 0.59408 | 0.531088 | galoisAvx512_amd64.go | starcoder |
package reticulum
import (
"errors"
layers "github.com/eliquious/reticulum/layers"
volume "github.com/eliquious/reticulum/volume"
)
const (
// DefaultDropout is the default dropout rate of 0.5 or 50%. Everything less than the dropout rate will be dropped.
DefaultDropout float64 = 0.5
)
// Network is the neural... | net.go | 0.82887 | 0.460289 | net.go | starcoder |
package datapb
import (
"reflect"
"fmt"
)
func ToDataHash(h map[string]reflect.Value) (*DataHash, error) {
cnt := len(h)
els := make([]*DataEntry, 0, cnt)
for k, v := range h {
dev, err := ToData(v)
if err != nil {
return nil, err
}
els = append(els, &DataEntry{k, dev})
}
return &DataHash{els}, nil
... | datapb/reflect.go | 0.510008 | 0.42316 | reflect.go | starcoder |
package fnv1
const (
// FNV-1
offset64 = uint64(14695981039346656037)
prime64 = uint64(1099511628211)
// Init64 is what 64 bits hash values should be initialized with.
Init64 = offset64
)
// HashString64 returns the hash of s.
func HashString64(s string) uint64 {
return AddString64(Init64, s)
}
// HashBytes6... | vendor/github.com/segmentio/fasthash/fnv1/hash.go | 0.705379 | 0.427217 | hash.go | starcoder |
package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
)
type cardinalDir int
const (
north cardinalDir = iota
east
south
west
)
type position struct {
x int
y int
}
type waypoint struct {
pos position
facing cardinalDir
}
type ship struct {
pos position
wp waypoint
}
func (wp *waypoint) mo... | day12/pt2.go | 0.587707 | 0.474814 | pt2.go | starcoder |
package iris16
import "fmt"
const (
// Compare operations
CompareOpEq = iota
CompareOpEqAnd
CompareOpEqOr
CompareOpEqXor
CompareOpNeq
CompareOpNeqAnd
CompareOpNeqOr
CompareOpNeqXor
CompareOpLessThan
CompareOpLessThanAnd
CompareOpLessThanOr
CompareOpLessThanXor
CompareOpGreaterThan
CompareOpGreaterThanA... | iris16/compare.go | 0.547222 | 0.467757 | compare.go | starcoder |
package scalar
import (
"fmt"
"reflect"
"time"
"unsafe"
"github.com/apache/arrow/go/arrow"
"golang.org/x/xerrors"
)
type op int8
const (
convDIVIDE = iota
convMULTIPLY
)
var timestampConversion = [...][4]struct {
op op
factor int64
}{
arrow.Nanosecond: {
arrow.Nanosecond: {convMULTIPLY, int64(ti... | go/arrow/scalar/temporal.go | 0.808937 | 0.402744 | temporal.go | starcoder |
package treap
import "math/rand"
type KeyT int64
const (
maxKey = KeyT(0x7fffffffffffffff)
minKey = -maxKey - 1
)
type node struct {
key KeyT
left, right *node
prio uint
}
type Treap struct {
rng *rand.Rand
root *node
}
func New() *Treap {
var t Treap
t.Init()
return &t
}
func (t *Treap... | Chapter 13-4- Treaps/src/treap/treap.go | 0.641422 | 0.464841 | treap.go | starcoder |
// Package diff implements a linewise diff algorithm.
package diff
import (
"bytes"
"fmt"
"strings"
)
// Chunk represents a piece of the diff. A chunk will not have both added and
// deleted lines. Equal lines are always after any added or deleted lines.
// A Chunk may or may not have any lines in it, especiall... | vendor/github.com/kylelemons/godebug/diff/diff.go | 0.702938 | 0.459197 | diff.go | starcoder |
package graph
import (
"fmt"
"reflect"
"github.com/mariomac/pipes/pkg/graph/stage"
"github.com/mariomac/pipes/pkg/node"
)
type codecKey struct {
In reflect.Type
Out reflect.Type
}
type outTyper interface {
OutType() reflect.Type
}
type inTyper interface {
InType() reflect.Type
}
type inOutTyper interface... | pkg/graph/builder.go | 0.598899 | 0.512815 | builder.go | starcoder |
package gobang
import (
"fmt"
"strings"
)
func NewBoard(size *Size) *Board {
cells := make([]*Cell, size.CellCount())
for i := range cells {
y := (i / size.Width)
x := i - (y * size.Width)
cells[i] = &Cell{NewPoint(x, y), 0}
}
return &Board{
Size: size,
Cells: cells,
}
}
type Board struct {
*Size... | gobang/board.go | 0.660501 | 0.431105 | board.go | starcoder |
package x52
import (
"fmt"
)
// String returns a string representation of the LED
func (led LED) String() string {
switch led {
case LedFire:
return "Fire"
case LedA:
return "A"
case LedB:
return "B"
case LedD:
return "D"
case LedE:
return "E"
case LedT1:
return "T1"
case LedT2:
return "T... | x52/led.go | 0.789153 | 0.512937 | led.go | starcoder |
package hexgridgeo
import (
"math"
hexgrid "github.com/gojuno/go.hexgrid"
morton "github.com/gojuno/go.morton"
)
type Point struct {
lon float64
lat float64
}
type Projection interface {
GeoToPoint(geoPoint Point) hexgrid.Point
PointToGeo(point hexgrid.Point) Point
}
type projectionNoOp struct {
}
type pro... | hexgridgeo.go | 0.80784 | 0.575737 | hexgridgeo.go | starcoder |
package resolv
import (
"math"
"sort"
)
// Line represents a line, from one point to another.
type Line struct {
BasicShape
X2, Y2 float64
}
// NewLine returns a new Line instance.
func NewLine(x, y, x2, y2 float64) *Line {
l := &Line{}
l.X = x
l.Y = y
l.X2 = x2
l.Y2 = y2
return l
}
// BUG(SolarLune): Lin... | resolv/line.go | 0.843122 | 0.543469 | line.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.