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 entropy
import (
kanzi "github.com/flanglet/kanzi-go"
)
// AdaptiveProbMap maps a probability and a context to a new probability
// that the next bit will be 1. After each guess, it updates
// its state to improve future predictions.
type AdaptiveProbMap struct {
index int // last prob, context
rate ... | entropy/AdaptiveProbMap.go | 0.789802 | 0.704262 | AdaptiveProbMap.go | starcoder |
package forGraphBLASGo
func VectorEWiseMultBinaryOp[Dw, Du, Dv any](w *Vector[Dw], mask *Vector[bool], accum BinaryOp[Dw, Dw, Dw], op BinaryOp[Dw, Du, Dv], u *Vector[Du], v *Vector[Dv], desc Descriptor) error {
size, err := w.Size()
if err != nil {
return err
}
if err = u.expectSize(size); err != nil {
return ... | api_EWise.go | 0.745028 | 0.72086 | api_EWise.go | starcoder |
package test
import (
"bytes"
"net/http/httptest"
"os"
"strings"
"testing"
"time"
)
// StrEquals tests two strings for equality and fails t if they are not equal
func StrEquals(t *testing.T, expected string, actual string) {
if actual != expected {
t.Fatalf("expected %s, got %s", expected, actual)
}
}
// S... | test/assert.go | 0.565779 | 0.498535 | assert.go | starcoder |
package data
import (
"gogen/matchers"
"time"
)
type Subject struct {
ID string
Name string
DOB time.Time
Convictions []*DOJRow
seenConvictions map[string]bool
PC290Registration bool
CyclesWithProp64Charges map[string]bool
... | data/subject.go | 0.52829 | 0.438785 | subject.go | starcoder |
package graph
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// Subscription provides operations to manage the drive singleton.
type Subscription st... | models/microsoft/graph/subscription.go | 0.868158 | 0.410225 | subscription.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// Location
type Location struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization ... | models/location.go | 0.7181 | 0.432423 | location.go | starcoder |
package storage
import (
"encoding/binary"
"math"
"github.com/john-nguyen09/phpintel/internal/lsp/protocol"
)
// PutUInt64 appends an uint64 to the byte slice
func PutUInt64(dst []byte, v uint64) []byte {
return append(dst, byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8),... | analysis/storage/encoding.go | 0.789518 | 0.473779 | encoding.go | starcoder |
package export
import "github.com/prometheus/client_golang/prometheus"
// QueryHistoricalExporter contains all the Prometheus metrics that are possible to gather from the historicals
type QueryHistoricalExporter struct {
QueryTime *prometheus.HistogramVec `description:"milliseconds taken to complete a... | pkg/export/query_historical.go | 0.793586 | 0.523603 | query_historical.go | starcoder |
package lib
import (
"container/list"
"fmt"
)
type TreeNode struct {
Val, size int
Left *TreeNode
Right *TreeNode
Parent *TreeNode
}
func NewTreeNode(v int) *TreeNode {
return &TreeNode{
Val: v,
size: 1,
}
}
func (t *TreeNode) setLeftChild(left *TreeNode) {
t.Left = left
if left != nil ... | golang/lib/tree_node.go | 0.520009 | 0.431225 | tree_node.go | starcoder |
package cluster
import (
"encoding/gob"
"errors"
"fmt"
"math"
"math/rand"
"os"
"time"
"gonum.org/v1/gonum/mat"
)
// DistanceFunction compute distance between two vectors.
type DistanceFunction func(a, b *DenseVector) (float64, error)
// InitializationFunction compute initial vales for cluster_centroids_.
ty... | cluster/kmodes.go | 0.739328 | 0.600833 | kmodes.go | starcoder |
package godal
// Block is a window inside a dataset, starting at pixel X0,Y0 and spanning
// W,H pixels.
type Block struct {
X0, Y0 int
W, H int
bw, bh int //block size
sx, sy int //img size
nx, ny int //num blocks
i, j int //cur
}
// Next returns the following block in scanline order. It returns Block{},f... | structure.go | 0.754915 | 0.499207 | structure.go | starcoder |
package main
import (
"fmt"
)
// tag::set[]
// This file contains the exact same counting set as used for day 3.
// CountingSet is a set that also knows how often each element has been added. It does support
// non-empty strings only.
type CountingSet map[string]int
// Add adds an entry to the set. The empty stri... | day06/go/razziel89/set.go | 0.760028 | 0.417212 | set.go | starcoder |
package chapter10
import (
"math"
)
// MatrixCoordinate represents teh coordinates of a matrix
type MatrixCoordinate struct {
row int
column int
}
// NewMatrixCoordinate creates a new coordinate
func NewMatrixCoordinate(row, col int) MatrixCoordinate {
return MatrixCoordinate{
row: row,
column: col,
}... | chapter10/9_matrix_sort.go | 0.877837 | 0.600686 | 9_matrix_sort.go | starcoder |
package neat
import (
"errors"
"fmt"
"github.com/yaricom/goNEAT/v2/neat/math"
"math/rand"
)
// NumTraitParams The number of parameters used in neurons that learn through habituation, sensitization or Hebbian-type processes
const NumTraitParams = 8
var (
ErrTraitsParametersCountMismatch = errors.New("traits para... | neat/trait.go | 0.657868 | 0.40116 | trait.go | starcoder |
package droid
import (
"fmt"
"github.com/bogosj/advent-of-code/2019/computer"
"github.com/bogosj/advent-of-code/intmath"
)
type state struct {
// Whether these directions have been explored.
eN, eS, eW, eE bool
isWall bool
isO2 bool
}
// Droid represents a repair droid.
type Droid struct {
... | 2019/day15/droid/droid.go | 0.634543 | 0.461563 | droid.go | starcoder |
package geom
//GeometryCollection is a collection of two-dimensional geometries
type GeometryCollection []Geometry
//GeometryCollectionZ is a collection of three-dimensional geometries
type GeometryCollectionZ []GeometryZ
//GeometryCollectionM is a collection of two-dimensional geometries, with an additional value ... | geometrycollection.go | 0.911535 | 0.594257 | geometrycollection.go | starcoder |
package helpers
import "github.com/lquesada/cavernal/model"
import "github.com/lquesada/cavernal/entity"
import "github.com/lquesada/cavernal/entity/humanoid"
import "github.com/lquesada/cavernal/lib/g3n/engine/math32"
type BasicHumanoidEquipable struct {
BasicEquipable
cloneSpecification *BasicHumanoidEquipableSp... | helpers/basichumanoidequipable.go | 0.541409 | 0.515681 | basichumanoidequipable.go | starcoder |
package strassen
import (
"math"
"github.com/Rongcong/algorithms/data-structures/matrix"
)
func Multiply(A *matrix.Matrix, B *matrix.Matrix) *matrix.Matrix {
n := A.CountRows()
bigN := scaleSize(n)
bigA := matrix.MakeMatrix(make([]float64, bigN*bigN), bigN, bigN)
bigB := matrix.MakeMatrix(make([]float64, bigN... | algorithms/maths/strassen/strassen.go | 0.640861 | 0.522141 | strassen.go | starcoder |
package ghist
// Percentile returns a float64 of the percentile of a given value in the histogram
func (h *Histogram) Percentile(value float64) (percentile float64) {
var position uint64
for i := h.Size - 1; i >= 0; i-- { // iterate in reverse to get a percentile
if h.Bins[i].Count == 0 {
continue
}
if valu... | statistics.go | 0.829871 | 0.669286 | statistics.go | starcoder |
package deps
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/pip-services/pip-services-runtime-go"
"github.com/pip-services/pip-clients-quotes-go/version1"
)
type QuotesClientFixture struct {
client quotes_v1.IQuotesClient
}
func NewQuotesClientFixture(client quotes_v1.IQuotes... | test/version1/QuotesClientFixture.go | 0.634656 | 0.404096 | QuotesClientFixture.go | starcoder |
package main
import (
"cloud.google.com/go/bigquery"
"github.com/maruel/subcommands"
"go.chromium.org/luci/auth"
"go.chromium.org/luci/common/cli"
"go.chromium.org/luci/common/data/text"
"go.chromium.org/luci/common/errors"
)
func cmdFetchRejections(authOpt *auth.Options) *subcommands.Command {
return &subco... | go/src/infra/rts/cmd/rts-chromium/rejections.go | 0.593138 | 0.401717 | rejections.go | starcoder |
package engine
// Cropped quantity refers to a cut-out piece of a large quantity
import (
"fmt"
"github.com/mumax/3/cuda"
"github.com/mumax/3/data"
"github.com/mumax/3/util"
)
func init() {
DeclFunc("Crop", Crop, "Crops a quantity to cell ranges [x1,x2[, [y1,y2[, [z1,z2[")
DeclFunc("CropX", CropX, "Crops a qua... | engine/crop.go | 0.712332 | 0.52275 | crop.go | starcoder |
package bits
import "unicode/utf8"
/**
This class is used for traversing the succinctly encoded trie.
*/
type FrozenTrieNode struct {
trie *FrozenTrie
index uint
letter string
final bool
firstChild uint
childCount uint
}
/**
Returns the number of children.
*/
func (f *FrozenTrieNode) Ge... | frozentrie.go | 0.754644 | 0.476397 | frozentrie.go | starcoder |
package expect
import (
"fmt"
"reflect"
"regexp"
"testing"
"vincent.click/pkg/preflight/expect/kind"
)
// ExpectedValue is an expectation on a realized value
type ExpectedValue struct {
*testing.T
actual interface{}
}
// Value returns a new value-based Expectation
func Value(t *testing.T, actual interface{}... | expect/value.go | 0.841956 | 0.621684 | value.go | starcoder |
package dusl
import (
"fmt"
)
// Undent transforms a source text into a syntax tree of unparsed sentences.
func Undent(src *Source) *Syntax {
ambit := src.FullAmbit()
return undent(ambit)
}
func undent(ambit *Ambit) *Syntax {
for !ambit.IsEmpty() {
indentedLineAmbit, remainderAmbit := ambit.SplitLine()
... | undent.go | 0.649023 | 0.414543 | undent.go | starcoder |
package basic
import (
"encoding/json"
"fmt"
)
/*
This file contains helper functions for json marshaling.
*/
type basicGeometry struct {
Type string `json:"type"`
Coordinates json.RawMessage `json:"coordinates,omitempty"`
Geometries []basicGeometry `json:"geometries,omitempty"`
}
func point(p... | basic/json_marshal.go | 0.567457 | 0.402862 | json_marshal.go | starcoder |
package gft
import "github.com/infastin/gul/gm32"
type ResamplingFilter interface {
Kernel(x float32) float32
Support() float32
}
type resampFilter struct {
kernel func(x float32) float32
support float32
}
func (f *resampFilter) Kernel(x float32) float32 {
return f.kernel(x)
}
func (f *resampFilter) Support(... | gft/resampling_filter.go | 0.733547 | 0.550547 | resampling_filter.go | starcoder |
package resources
// The payload for a simple fuse integration based on timer and logger
const FuseIntegrationPayload = `
{
"name": "test-integration",
"tags": [
"timer"
],
"flows": [
{
"id": "-M30tHvcORdr7SjkRAjn",
"name": "",
"steps": [
{
"id": "-M30tMT1ORdr7SjkRAj... | test/resources/fuse_payload.go | 0.657318 | 0.503174 | fuse_payload.go | starcoder |
package heap
import (
g "github.com/zyedidia/generic"
)
// Heap implements a binary heap.
type Heap[T any] struct {
data []T
less func(a, b T) bool
}
// New returns a new heap with the given less function.
func New[T any](less g.LessFn[T]) *Heap[T] {
return &Heap[T]{
data: make([]T, 0),
less: less,
}
}
// ... | heap/heap.go | 0.881334 | 0.598606 | heap.go | starcoder |
package iterate
// KeyValue represents a key value pair.
type KeyValue[K comparable, V any] struct {
Key K
Value V
}
// Split return the key and the value.
func (kv KeyValue[K, V]) Split() (K, V) {
return kv.Key, kv.Value
}
// Zip returns an iterator of key/value pairs produced by the given key/value
// iterat... | keyvalue.go | 0.76986 | 0.449574 | keyvalue.go | starcoder |
package fb
// You must have flatc installed to regenerate these files. Get it here:
// https://google.github.io/flatbuffers/
//go:generate flatc --go -o ../../../../.. state.fbs
/*
The curator stores metadata in BoltDB, encoded with FlatBuffers.
Why FlatBuffers? They encode somewhat larger than another obvious cho... | internal/curator/durable/state/fb/doc.go | 0.631594 | 0.553988 | doc.go | starcoder |
package guitar
var Larrivee = Levels{
Gradient: []float32{10, 20, 25, 35, 42, 55, 70, 85, 90, 100},
Risk: []Danger{Extreme, Severe, High, Elevated, Moderate, Low, Moderate, Elevated, High, Severe},
Details: &Notification{
SubjectTmpl: `Your guitar is in {{.Risk}} danger!`,
BodyTmpl: `Your guitar is not in ... | guitar/larrivee.go | 0.694821 | 0.563258 | larrivee.go | starcoder |
package comb
import (
"fmt"
"strings"
)
// Char creates a parser parsing a character.
func (s *State) Char(r rune) Parser {
return func() (interface{}, error) {
if s.currentRune() != r {
return nil, fmt.Errorf("invalid character, '%c'", s.currentRune())
}
s.increment()
return r, nil
}
}
// NotChar c... | src/lib/parse/comb/combinator.go | 0.793666 | 0.412116 | combinator.go | starcoder |
package imageutil
import (
"fmt"
"image"
"image/color"
"github.com/grokify/simplego/reflect/reflectutil"
"golang.org/x/image/draw"
)
func ImageToRGBA(img image.Image) *image.RGBA {
// https://stackoverflow.com/questions/31463756/convert-image-image-to-image-nrgba
switch img := img.(type) {
case *image.NRGBA:... | image/imageutil/convert.go | 0.84759 | 0.529628 | convert.go | starcoder |
package polygon
import (
"math"
"strings"
"github.com/adamcolton/geom/d2"
"github.com/adamcolton/geom/d2/curve/line"
)
// Polygon represents a Convex Polygon
type Polygon []d2.Pt
// Pt2c1 returns line.Segments as d2.Pt1 that adheres to the Shape rules
func (p Polygon) Pt2c1(t0 float64) d2.Pt1 {
n := (len(p) - ... | d2/shape/polygon/polygon.go | 0.843975 | 0.58883 | polygon.go | starcoder |
package triangle
import (
"math"
"strings"
"github.com/adamcolton/geom/d2"
"github.com/adamcolton/geom/d2/curve/line"
)
// Triangle is a 2D triangle
type Triangle [3]d2.Pt
// Contains checks if a point is inside the triangle.
func (t *Triangle) Contains(pt d2.Pt) bool {
// If a point is inside the triangle, th... | d2/shape/triangle/triangle.go | 0.837952 | 0.694474 | triangle.go | starcoder |
package math
import "math"
type Box3 struct {
Min *Vector3
Max *Vector3
}
func NewBox3() *Box3 {
b := &Box3{
Min:&Vector3{ X:math.Inf(0), Y:math.Inf(0), Z:math.Inf(0)},
Max:&Vector3{ X:math.Inf(-1), Y:math.Inf(-1), Z:math.Inf(-1)},
}
return b
}
func (b *Box3) Set( min, max *Vector3 ) *Box3 {
b.Min.Copy(... | math/box3.go | 0.519278 | 0.568715 | box3.go | starcoder |
package statsd
import (
"errors"
"fmt"
"math/rand"
"net"
)
type Statter interface {
Inc(stat string, value int64, rate float32) error
Dec(stat string, value int64, rate float32) error
Gauge(stat string, value int64, rate float32) error
GaugeDelta(stat string, value int64, rate float32) error
Timing(stat stri... | statsd/main.go | 0.824921 | 0.482612 | main.go | starcoder |
package triangle
import (
"errors"
"fmt"
"math"
"math/big"
"strings"
)
type side float64
type angle float64
func (triangle AbstractTriangle) isEqual(otherTriangle AbstractTriangle) bool {
return triangle.A.isEqual(otherTriangle.A) &&
triangle.B.isEqual(otherTriangle.B) &&
triangle.C.isEqual(otherTriangle.C... | pkg/triangle/triangle.go | 0.879121 | 0.613237 | triangle.go | starcoder |
package bn256
import (
"errors"
"math/big"
)
// G1 is an abstract cyclic group. The zero value is suitable for use as the
// output of an operation, but cannot be used as an input.
type G1 struct {
p *curvePoint
}
func (g *G1) String() string {
return "bn256.G1" + g.p.String()
}
// Base set e to g where g is th... | bn256/bn256g1.go | 0.822403 | 0.443721 | bn256g1.go | starcoder |
package tic
import (
"fmt"
"strconv"
"strings"
"github.com/jwalton/gchalk"
"github.com/shurcooL/tictactoe"
i "devzat/pkg/interfaces"
"devzat/pkg/models"
)
const (
name = "tic"
argsInfo = ""
info = "start a game of tic tac toe"
)
type state = struct {
Board *tictactoe.Board
currentPlayer... | pkg/commands/tic/command.go | 0.523177 | 0.436682 | command.go | starcoder |
package bigquery
import (
"errors"
"fmt"
"strconv"
"time"
bq "google.golang.org/api/bigquery/v2"
)
// Value stores the contents of a single cell from a BigQuery result.
type Value interface{}
// ValueLoader stores a slice of Values representing a result row from a Read operation.
// See Iterator.Get for more ... | vendor/google.golang.org/cloud/bigquery/value.go | 0.751466 | 0.53777 | value.go | starcoder |
package main
import "sort"
/*****************************************************************************************************
*
* Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find
* all unique triplets in the array which gives the sum of zero.
*
* Note:
*
*... | leetcode/15.3sum/15.3Sum_zhangsl.go | 0.544317 | 0.504272 | 15.3Sum_zhangsl.go | starcoder |
package assets
// GKEPlanSchema is the JSON schema used to describe and validate GKE Plans
const GKEPlanSchema = `
{
"$id": "https://appvia.io/schemas/gke/plan.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GKE Cluster Plan Schema",
"type": "object",
"additionalProperties": false,
"... | pkg/kore/assets/plan_schema_gke.go | 0.660063 | 0.498962 | plan_schema_gke.go | starcoder |
package training
import (
"bufio"
"fmt"
"math"
"os"
"github.com/AlessandroPomponio/go-gibberish/analysis"
"github.com/AlessandroPomponio/go-gibberish/persistence"
"github.com/AlessandroPomponio/go-gibberish/structs"
)
// TrainModel computes the probabilities of having a certain
// digraph by reading a big fil... | training/training.go | 0.708313 | 0.488649 | training.go | starcoder |
package gorgonia
import (
"fmt"
tf32 "github.com/chewxy/gorgonia/tensor/f32"
tf64 "github.com/chewxy/gorgonia/tensor/f64"
"github.com/chewxy/gorgonia/tensor/types"
"github.com/pkg/errors"
)
// Functions in this file returns *Node and panics if an error happens
/* Helper functions to create new input nodes */
... | gorgonia.go | 0.741487 | 0.453685 | gorgonia.go | starcoder |
Package clustertemplates provides information and interaction with the cluster-templates through
the OpenStack Container Infra service.
Example to Create Cluster Template
boolFalse := false
boolTrue := true
createOpts := clustertemplates.CreateOpts{
Name: "test-cluster-template",
Labels: ... | vendor/github.com/gophercloud/gophercloud/openstack/containerinfra/v1/clustertemplates/doc.go | 0.521471 | 0.556641 | doc.go | starcoder |
package main
import (
"fmt"
"strconv"
"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/pkg/managerclient"
"github.com/scylladb/scylla-manager/pkg/service/scheduler"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
const parallelLongDesc = `
The --parallel flag specifies the maximum number of Sc... | pkg/cmd/sctool/repair.go | 0.651133 | 0.424352 | repair.go | starcoder |
package ween
import (
"korok.io/korok/math/f32"
"korok.io/korok/gfx"
"log"
)
func U8Lerp(from, to uint8, f float32) uint8 {
v1, v2 := float32(from), float32(to)
return uint8(v1+(v2-v1)*f)
}
func U16Lerp(from, to uint16, f float32) uint16 {
v1, v2 := float32(from), float32(to)
return uint16(v1+(v2-v1)*f)
}
fu... | anim/ween/tweens.go | 0.859059 | 0.479626 | tweens.go | starcoder |
package scf
import (
"encoding/binary"
"errors"
"fmt"
"math"
"reflect"
)
// Validate checks that command has a type that is compatible with the
// requirements of this package and can be safely passed to Serialize and Parse.
// Command must be a struct and all fields must be supported data types (see package des... | pkg/scf/scf.go | 0.727782 | 0.432483 | scf.go | starcoder |
package config
import (
"strings"
)
// Doc: https://core.telegram.org/bots/api#markdownv2-style
var (
bracketsRepl *strings.Replacer
sqBracketsRepl *strings.Replacer
codeRepl *strings.Replacer
htmlRepl *strings.Replacer
mdv2Repl *strings.Replacer
)
// EscapeBrackets provede escape syntax ... | internal/config/tpl_filters.go | 0.500488 | 0.513973 | tpl_filters.go | starcoder |
package proto
import (
"time"
)
// TimeSinceEpoch UTC time in seconds, counted from January 1, 1970.
// To convert a time.Time to TimeSinceEpoch, for example:
// proto.TimeSinceEpoch(time.Now().Unix())
// For session cookie, the value should be -1.
type TimeSinceEpoch float64
// Time interface
func (t TimeSinc... | lib/proto/a_patch.go | 0.848062 | 0.527012 | a_patch.go | starcoder |
package bitset
type FixedBitSet struct {
data []byte
maxBits int
}
// Non-resizable bitset with basic operations.
func NewFixed(maxBits int) *FixedBitSet {
var bytes = maxBits / 8
if maxBits > bytes*8 {
bytes++
}
return &FixedBitSet{data: make([]byte, bytes), maxBits: maxBits}
}
// Write one at the given ... | bitset/fixed.go | 0.757525 | 0.41947 | fixed.go | starcoder |
package main
/*
import (
"fmt"
"github.com/hashicorp/terraform/dag"
"math"
"time"
)
type largeVertex struct {
value int
}
// implement the Vertex's interface method String()
func (v largeVertex) String() string {
return fmt.Sprintf("%d", v.value)
}
// implement the Vertex's interface method ID()
func (v large... | cmd/terraform/main.go | 0.624064 | 0.45532 | main.go | starcoder |
package mario_go
type Ground struct {
Sprite
sx float32
sy float32
}
func NewGround() *Ground {
s := &Ground{}
return s
}
func (s Ground) Dots() Dots {
var m int32 = 0x9B4808
var l int32 = 0xFECDC6
var b int32 = 0x000000
indices := []int32{
0, 15, m, 1, 15, l, 2, 15, l, 3, 15, l, 4, 15, l, 5, 15, l, 6, 15... | ground.go | 0.569374 | 0.491944 | ground.go | starcoder |
package recordio
import (
"fmt"
"io"
"io/fs"
"strings"
)
// DecoderIterator is an iterator over Decoders, for use with the MultiDecoder.
type DecoderIterator interface {
io.Closer
Next() (*Decoder, error)
Done() bool
}
// MultiDecoder wraps multiple readers, either specified directly or through a
// reader i... | recordio/multi.go | 0.679179 | 0.431464 | multi.go | starcoder |
package obj7
type LightType int
const (
LightType_Other LightType = 0
LightType_RedNavigation LightType = 1
LightType_GreenNavigation LightType = 2
LightType_Beacon LightType = 3
LightType_Strobe LightType = 4
LightType_Landing LightType = 5
LightType_Taxi LightType = 6
)
type LightInfo struct {
XYZ [... | internal/obj7/LightInfo.go | 0.67405 | 0.431584 | LightInfo.go | starcoder |
package goval
import (
"bytes"
"strconv"
"github.com/shunsukuda/forceconv"
)
type Bytes struct {
Bytes []byte
}
// func (e Bytes) GoBytes() []byte { return e.Bytes }
func (e Bytes) Type() Type { return ValTypes.Bytes }
func (e Bytes) Equal(x Bytes) bool { return bytes.Equal(e.Bytes, x.Bytes) }
func (e B... | string.gen.go | 0.730482 | 0.567218 | string.gen.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// PathArrayFromFloat64Array2SliceSlice returns a driver.Valuer that produces a PostgreSQL path[] from the given Go [][][2]float64.
func PathArrayFromFloat64Array2SliceSlice(val [][][2]float64) driver.Valuer {
return pathArrayFromFloat64Array... | pgsql/patharr.go | 0.677047 | 0.498047 | patharr.go | starcoder |
package gogm
import (
"fmt"
"math"
)
// Vec3 is a vector with 3 components, of type T.
type Vec3[T number] [3]T
// Vec3CopyVec3 copies the content of src to dst.
func Vec3CopyVec3[T1, T2 number](dst *Vec3[T1], src *Vec3[T2]) {
dst[0] = T1(src[0])
dst[1] = T1(src[1])
dst[2] = T1(src[2])
}
// Vec3CopyVec2 copies... | vec3.go | 0.718792 | 0.565299 | vec3.go | starcoder |
package util
import "math"
func Div(num, denom int32) (uint32, uint32, uint32) {
const I32_MIN = -2147483647 - 1
if denom == 0 {
// If abs(num) > 1, this should hang, but that would be painful to
// emulate in HLE, and no game will get into a state under normal
// operation where it hangs...
if num < 0 {
... | pkg/util/bios.go | 0.581303 | 0.515315 | bios.go | starcoder |
package data
import "bytes"
type (
// Sequence interfaces expose a lazily resolved sequence
Sequence interface {
Value
First() Value
Rest() Sequence
Split() (Value, Sequence, bool)
IsEmpty() bool
}
// Appender is a Sequence that can be appended to
Appender interface {
Sequence
Append(Value) Sequen... | data/sequence.go | 0.778186 | 0.455078 | sequence.go | starcoder |
package jbtracer
import "math"
const (
Axis_X = iota
Axis_Y
Axis_Z
Degrees180 = 3.1415926536 // pi
Degrees90 = 1.5707963268 // pi/2
Degrees60 = 1.0471975512 // pi/3
Degrees45 = 0.7853981634 // pi/4
Degrees30 = 0.5235987756 // pi/6
Degrees10 = 0.1745329252 // pi/18
Pi = 3.1415926536 // pi
Pi2 ... | transformations.go | 0.832509 | 0.619644 | transformations.go | starcoder |
// TODO: How exactly are sensitivity and delta related to each other? How does the
// inclusion of delta in this scheme change these calculations?
package wdp
import "math"
// Provide a qualitative explanation for what a particular epsilon value means.
func QualEps(eps, p float64) float64 {
// Recommended desc... | wdp/math.go | 0.717012 | 0.733857 | math.go | starcoder |
package scw
import (
"encoding/json"
"fmt"
"io"
"time"
"github.com/scaleway/scaleway-sdk-go/internal/errors"
)
// ServiceInfo contains API metadata
// These metadata are only here for debugging. Do not rely on these values
type ServiceInfo struct {
// Name is the name of the API
Name string `json:"name"`
//... | scw/custom_types.go | 0.882162 | 0.425486 | custom_types.go | starcoder |
package main
import (
"fmt"
)
type TZLabel struct {
Abbreviation string
Full string
UTCOffset int
}
// lookupFullTZ returns the full name of an abbreviation of a timezone.
// If two tzs exist for an abbreviation, the closest tz to offset is returned.
func lookupFullTZ(abbrev string, utcOffset int) (TZ... | tztable.go | 0.577495 | 0.522446 | tztable.go | starcoder |
package leaves
import (
"math"
"github.com/fredrikluo/leaves/util"
)
const (
categorical = 1 << 0
defaultLeft = 1 << 1
leftLeaf = 1 << 2
rightLeaf = 1 << 3
missingZero = 1 << 4
missingNan = 1 << 5
catOneHot = 1 << 6
catSmall = 1 << 7
)
const zeroThreshold = 1e-35
type lgNode struct {
Threshol... | lgtree.go | 0.629319 | 0.411998 | lgtree.go | starcoder |
package c8y
import (
"regexp"
"strconv"
"time"
)
// GetDateRange returns the dateFrom and dateTo based on an interval string, i.e. 1d, is 1 day
func GetDateRange(dateInterval string) (string, string) {
pattern := regexp.MustCompile(`^(\d+)\s*([a-zA-Z]+)$`)
result := pattern.FindStringSubmatch(dateInterval)
if... | pkg/c8y/dateHelper.go | 0.747708 | 0.511046 | dateHelper.go | starcoder |
package matrixexp
import (
"fmt"
"github.com/gonum/blas/blas64"
)
// General is a typical matrix literal.
type General struct {
blas64.General
}
// String implements the Stringer interface.
func (m1 *General) String() string {
return fmt.Sprintf("%#v", m1)
}
// Dims returns the matrix dimensions.
func (m1 *Gen... | general.go | 0.859605 | 0.500793 | general.go | starcoder |
package main
import (
"strings"
. "../lib"
)
type strategy func([]string, int, int) int
var tolerance = 4
func part1(state []string) (int, error) {
var stable bool
for {
state, stable = iterate(state, countAdjacent, 4)
if stable {
break
}
}
occupied := 0
for _, row := range state {
occupied += s... | 2020/day-11/main.go | 0.580828 | 0.447641 | main.go | starcoder |
package yeelight
import (
"context"
"fmt"
"time"
)
// FlowExpression is the expression of the state changing series.
type FlowExpression struct {
// Duration Gradual change time or sleep time. Minimum value 50 milliseconds.
Duration time.Duration
// Mode can be FlowModeColor, FlowColorTemperature, FlowSleep
M... | flow.go | 0.798265 | 0.45417 | flow.go | starcoder |
package main
import (
"fmt"
"math"
"math/cmplx"
)
// a type to represent matrices
type matrix struct {
ele []complex128
cols int
}
// conjugate transpose, implemented here as a method on the matrix type.
func (m *matrix) conjTranspose() *matrix {
r := &matrix{make([]complex128, len(m.ele)), len(m.ele) / m.col... | tasks/Conjugate-transpose/conjugate-transpose.go | 0.577972 | 0.669029 | conjugate-transpose.go | starcoder |
package parser
import (
"fmt"
)
// Abstract, should not get called but needed to cast abstract struct to Expression
func (e *Positioned) Label() string { return "Positioned" }
// Concrete
func (e *ActivityExpression) Label() string { return "Activity" }
func (e *AccessExpression) Label() string ... | parser/label.go | 0.632616 | 0.418043 | label.go | starcoder |
package fn
import (
"sort"
"github.com/nlpodyssey/spago/mat"
"github.com/nlpodyssey/spago/mat/float"
)
// SparseMax function implementation, based on https://github.com/gokceneraslan/SparseMax.torch
type SparseMax[O Operand] struct {
x O
y mat.Matrix // initialized during the forward pass, requir... | ag/fn/sparsemax.go | 0.765506 | 0.53959 | sparsemax.go | starcoder |
package stats
// QueryTiming identifies the code area or functionality in which time is spent
// during a query.
type QueryTiming int
// Query timings.
const (
EvalTotalTime QueryTiming = iota
ResultSortTime
QueryPreparationTime
InnerEvalTime
ResultAppendTime
ExecQueueTime
ExecTotalTime
)
// Return a string ... | monitoring/prometheus/busybox-prometheus/util/stats/query_stats.go | 0.798423 | 0.44553 | query_stats.go | starcoder |
package movers
import (
"danser/beatmap/objects"
"danser/bmath"
"danser/bmath/curves"
. "danser/osuconst"
"danser/settings"
"math"
)
type BezierMover struct {
pt bmath.Vector2d
bz curves.Bezier
beginTime, endTime int64
previousSpeed float64
invert float64
}
... | dance/movers/bezier.go | 0.609873 | 0.401776 | bezier.go | starcoder |
package oauth2test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
// AccessTokenTest validates the specified access token by requesting the
// protected resource.
func AccessTokenTest(t *testing.T, spec *Spec, accessToken string) {
// check token functionality
Do(spec.... | oauth2test/general.go | 0.514644 | 0.405449 | general.go | starcoder |
package fp25519
import (
"errors"
"circl/internal/conv"
)
// Size in bytes of an element.
const Size = 32
// Elt is a prime field element.
type Elt [Size]byte
func (e Elt) String() string { return conv.BytesLe2Hex(e[:]) }
// p is the prime modulus 2^255-19.
var p = Elt{
0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff... | src/circl/math/fp25519/fp.go | 0.602179 | 0.523299 | fp.go | starcoder |
package triplestore
// Triple consists of a subject, a predicate and a object
type Triple interface {
Subject() string
Predicate() string
Object() Object
Equal(Triple) bool
}
// Object is a resource (i.e. IRI), a literal or a blank node.
type Object interface {
Literal() (Literal, bool)
Resource() (string, bool... | vendor/github.com/wallix/triplestore/rdf.go | 0.731922 | 0.455199 | rdf.go | starcoder |
package data
import (
"errors"
"fmt"
"github.com/PolymerGuy/golmes/fileutils"
"github.com/PolymerGuy/golmes/maths"
"github.com/pkelchte/spline"
"gonum.org/v1/gonum/floats"
"log"
"math"
"sort"
)
type DataReader interface {
Read() []float64
}
type DataReaderWithArgs interface {
Read() []float64
ReadArgs() ... | data/data.go | 0.553747 | 0.432183 | data.go | starcoder |
package suffixtree
import (
"sort"
)
type Node struct {
/*
* The payload array used to store the data (indexes) associated with this node.
* In this case, it is used to store all property indexes.
*/
Data []int
/**
* The set of edges starting from this Node
*/
Edges []*Edge
/**
* The suffix link as ... | node.go | 0.653348 | 0.491273 | node.go | starcoder |
package ast
import (
"fmt"
"go.etcd.io/bbolt"
"time"
)
type NodeType int
const (
NodeTypeBool NodeType = iota
NodeTypeDatetime
NodeTypeFloat64
NodeTypeInt64
NodeTypeString
NodeTypeAnyType
NodeTypeOther
)
func NodeTypeName(nodeType NodeType) string {
return nodeTypeNames[nodeType]
}
var nodeTypeNames = ... | storage/ast/node.go | 0.612541 | 0.42919 | node.go | starcoder |
package square
// Represents a tax that applies to one or more line item in the order. Fixed-amount, order-scoped taxes are distributed across all non-zero line item totals. The amount distributed to each line item is relative to the amount the item contributes to the order subtotal.
type OrderLineItemTax struct {
/... | square/model_order_line_item_tax.go | 0.846419 | 0.489442 | model_order_line_item_tax.go | starcoder |
// This package implements translation between
// unsigned integer values and byte sequences.
package binary
import (
"math";
"io";
"os";
"reflect";
)
// A ByteOrder specifies how to convert byte sequences into
// 16-, 32-, or 64-bit unsigned integers.
type ByteOrder interface {
Uint16(b []byte) uint16;
Uint32... | src/pkg/encoding/binary/binary.go | 0.678966 | 0.418043 | binary.go | starcoder |
package geometry
import (
"math"
"time"
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/graphic"
"github.com/g3n/engine/light"
"github.com/g3n/engine/material"
"github.com/g3n/engine/math32"
"github.com/g3n/engine/util/helper"
"github.com/g3n/g3nd/app"
)
func init() {
app.DemoMap["geometry.torus"] ... | demos/geometry/torus.go | 0.667364 | 0.458106 | torus.go | starcoder |
package main
import (
"time"
"math/rand"
sf "bitbucket.org/krepa098/gosfml2"
)
type Enemy struct {
HasChild bool
HasFather bool
HasMother bool
FatherHasWeapon bool
Shape *sf.RectangleShape
}
func NewEnemy(WorldWidth int, Textures []Texture) *Enemy {
Enemy := new(Enemy)
rand.Seed(time.Now().UnixNano())
En... | enemy.go | 0.506836 | 0.501648 | enemy.go | starcoder |
package metadata
const (
// Equals is a mathematical symbol used to indicate equality.
// It is also a Drama/Science fiction film from 2015.
Equals Operator = "="
// GreaterThan is a mathematical symbol that denotes an inequality between two values.
// It is typically placed between the two values being compared ... | metadata/matcher.go | 0.866486 | 0.798265 | matcher.go | starcoder |
// Package algorithm contain some basic algorithm functions. eg. sort, search
package algorithm
import "github.com/duke-git/lancet/v2/lancetconstraints"
// BubbleSort use bubble to sort slice.
func BubbleSort[T any](slice []T, comparator lancetconstraints.Comparator) {
for i := 0; i < len(slice); i++ {
for j := 0... | algorithm/sorter.go | 0.586404 | 0.600598 | sorter.go | starcoder |
package display
import (
"math"
"sync"
)
// RectangleRasterInput part of options that is passed to rasterizer workers.
type RectangleRasterInput struct {
// Pixel buffer. Shader needs to output color to buffer with
// boffs offset and value calculated by shader. Buffer can use multiple
// bytes for pixel. Multip... | pkg/display/rectangle.go | 0.740456 | 0.527195 | rectangle.go | starcoder |
package main
import (
XPression "github.com/FlowingSPDG/XPression-go"
"github.com/c-bata/go-prompt"
)
func completer(in prompt.Document) []prompt.Suggest {
s := []prompt.Suggest{
{Text: "CLFB",Description: "Clears framebuffer number buffer. For example, CLFB 0000 clears framebuffer 1."},
{Text: "CLRA",Descrip... | examples/cui/main.go | 0.571647 | 0.453262 | main.go | starcoder |
package utility
import (
"encoding/json"
"math"
"math/rand"
"syscall/js"
"github.com/go-gl/mathgl/mgl32"
"github.com/udhos/gwob"
)
func ProgressUpdate(progress float32, event string, taskId int, rays uint64) {
data := struct {
Progress float32 `json:"progress"`
Event string `json:"event"`
TaskID i... | src/backend/utility/utility.go | 0.765856 | 0.430028 | utility.go | starcoder |
package require
import (
"bytes"
"fmt"
"reflect"
"runtime"
"strings"
"testing"
"unicode"
"unicode/utf8"
"github.com/wdvxdr1123/tengo/v2"
"github.com/wdvxdr1123/tengo/v2/parser"
"github.com/wdvxdr1123/tengo/v2/token"
)
// NoError asserts err is not an error.
func NoError(t *testing.T, err error, msg ...int... | require/require.go | 0.518059 | 0.506225 | require.go | starcoder |
package plaid
import (
"encoding/json"
)
// PaystubDetails An object representing details that can be found on the paystub.
type PaystubDetails struct {
// Beginning date of the pay period on the paystub in the 'YYYY-MM-DD' format.
PayPeriodStartDate NullableString `json:"pay_period_start_date,omitempty"`
// End... | plaid/model_paystub_details.go | 0.737725 | 0.42054 | model_paystub_details.go | starcoder |
package main
import (
"fmt"
"time"
"math/rand"
"os"
"strconv"
"sort"
)
func MergeSort(slice []int) []int {
if len(slice) < 2 {
return slice
}
mid := len(slice) / 2
return Merge(
MergeSort(slice[:mid]),
MergeSort(slice[mid:]),
)
}
func Merge(left, right []int) []int {
... | go/merge.go | 0.566019 | 0.410343 | merge.go | starcoder |
package mfi
import (
"time"
)
//Ticker ticker price information
type Ticker struct {
Open float64
Close float64
High float64
Low float64
Vol float64
Date time.Time
}
//moneyFlow money flow
type moneyFlow struct {
positive float64
negative float64
}
//mfiCalculator MFI calculator
type mfiCalculator s... | mfi/mfi.go | 0.604049 | 0.517449 | mfi.go | starcoder |
package patterns
import (
"bytes"
"github.com/sniperkit/xfilter/internal/persist"
)
// BMH turns patterns into BMH sequences if possible.
func BMH(p Pattern, rev bool) Pattern {
s, ok := p.(Sequence)
if !ok {
return p
}
if rev {
return NewRBMHSequence(s)
}
return NewBMHSequence(s)
}
// BMHSequence is a... | internal/bytematcher/patterns/bmh.go | 0.765067 | 0.415254 | bmh.go | starcoder |
package cmath
import (
"fmt"
"math"
)
type Matrix struct {
n, m int
a []float64
}
func (a *Matrix) Vector(i int) IVector {
v := newVector(a.m)
for j := 0; j < a.m; j++ {
v.Set(j, a.At(i, j))
}
return v
}
func (a *Matrix) VectorT(i int) IVector {
v := newVector(a.m)
for j := 0; j < a.m; j++ {
v.Set(... | math/matrix.go | 0.727589 | 0.436502 | matrix.go | starcoder |
package gxtime
import (
"strconv"
"time"
)
func TimeDayDuration(day float64) time.Duration {
return time.Duration(day * 24 * float64(time.Hour))
}
func TimeHourDuration(hour float64) time.Duration {
return time.Duration(hour * float64(time.Hour))
}
func TimeMinuteDuration(minute float64) time.Duration {
return... | vendor/github.com/dubbogo/gost/time/time.go | 0.738575 | 0.460107 | time.go | starcoder |
package types
import (
"github.com/lyraproj/issue/issue"
"github.com/lyraproj/puppet-evaluator/eval"
"github.com/lyraproj/semver/semver"
"math"
"reflect"
"strings"
)
const tagName = "puppet"
type reflector struct {
c eval.Context
}
var pValueType = reflect.TypeOf((*eval.Value)(nil)).Elem()
func NewReflector... | types/reflector.go | 0.550607 | 0.412648 | reflector.go | starcoder |
package main
import (
"fmt"
r "github.com/lachee/raylib-goplus/raylib"
)
func main() {
screenWidth := 800
screenHeight := 450
r.SetConfigFlags(r.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
r.SetTraceLogLevel(r.LogAll)
r.SetTraceLogCallback(func(logType r.TraceLogType, text string... | raylib-example/render-texture/rendertexture.go | 0.605799 | 0.428114 | rendertexture.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.