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 tile
import "fungo/sdl"
// One frame of animation of a tile or a sprite.
type Frame (*sdl.Surface)
// Offset describes where something, like a sprite should be drawn
type Offset struct {
X, Y int
}
// Moves the offset to x and y
func (o Offset) MoveTo(x, y int) {
o.X = x
o.Y = y
}
// Moves the o... | tile/tile.go | 0.773131 | 0.537041 | tile.go | starcoder |
// Exercise 3.3: Color each polygon based on its height, so that the
// peaks are colored red (#ff0000) and the valleys blue (#0000ff).
// Surface computes an SVG rendering of a 3-D surface function.
package main
import (
"fmt"
"math"
"strconv"
)
const (
width, height = 600, 320 // canvas size in pix... | ch3/surface.go | 0.771069 | 0.611208 | surface.go | starcoder |
package core
type collection interface {
Value
assign(Value, Value) Value
include(Value) Value
index(Value) Value
merge(...Value) Value
delete(Value) Value
toList() Value
size() Value
}
// Assign inserts an element into a sequence.
var Assign = NewLazyFunction(
NewSignature([]string{"collection"}, "keyValue... | src/lib/core/collection.go | 0.708011 | 0.411879 | collection.go | starcoder |
package aoc2021
import (
"fmt"
utils "github.com/simonski/aoc/utils"
)
/*
--- Day 1: Sonar Sweep ---
You're minding your own business on a ship at sea when the overboard alarm goes off! You rush to see if you can help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying into the ocean... | app/aoc2021/aoc2021_01.go | 0.509032 | 0.631395 | aoc2021_01.go | starcoder |
package assets
// EKSPlanSchema is the JSON schema used to describe and validate EKS Plans
const EKSPlanSchema = `
{
"$id": "https://appvia.io/schemas/eks/plan.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "EKS Cluster Plan Schema",
"type": "object",
"additionalProperties": false,
"... | pkg/kore/assets/plan_schema_eks.go | 0.565299 | 0.555435 | plan_schema_eks.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_linear_svm
#include <capi/linear_svm.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type LinearSvmOptionalParam struct {
Delta float64
Epochs int
InputModel *linearsvmModel
Labels *mat.Dense
Lambda... | linear_svm.go | 0.740268 | 0.488527 | linear_svm.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTSectionPlaneInfo struct for BTSectionPlaneInfo
type BTSectionPlaneInfo struct {
Center *[]float64 `json:"center,omitempty"`
Normal *[]float64 `json:"normal,omitempty"`
Tangent *[]float64 `json:"tangent,omitempty"`
}
// NewBTSectionPlaneInfo instantiates a new BTSec... | onshape/model_bt_section_plane_info.go | 0.73307 | 0.422028 | model_bt_section_plane_info.go | starcoder |
package sema
type RuntimeTypeConstructor struct {
Name string
Value *FunctionType
DocString string
}
var OptionalTypeFunctionType = &FunctionType{
Parameters: []*Parameter{
{
Label: ArgumentLabelNotRequired,
Identifier: "type",
TypeAnnotation: NewTypeAnnotation(MetaType),
},
},... | runtime/sema/runtime_type_constructors.go | 0.63341 | 0.525004 | runtime_type_constructors.go | starcoder |
package algebra
// Grid is a "2D array" generic type.
type Grid[T any] [][]T
// MakeGrid makes a Grid of width w and height h.
func MakeGrid[T any](h, w int) Grid[T] {
g := make(Grid[T], h)
for i := range g {
g[i] = make([]T, w)
}
return g
}
// Clone makes a copy of the grid.
func (g Grid[T]) Clone() Grid[T] {... | algebra/grid.go | 0.850344 | 0.636339 | grid.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
"time"
)
var data []digitsAndValues
type digitsAndValues struct {
digits [10]map[rune]bool
values [4]map[rune]bool
}
func preCompute() {
file, err := os.Open("input.txt")
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.New... | day08/main.go | 0.505615 | 0.444022 | main.go | starcoder |
package parser
import (
"strconv"
"time"
"github.com/zac-garby/booleang/ast"
"github.com/zac-garby/booleang/token"
)
func (p *Parser) next() {
p.cur = p.peek
p.peek = p.lex()
if p.peek.Type == token.Illegal {
p.err(
"illegal token found: `%s`",
p.peek.Range, p.peek.Literal,
)
}
}
func (p *Parser)... | parser/helpers.go | 0.635449 | 0.41117 | helpers.go | starcoder |
package level
import "fmt"
// CyberspaceFlightPull describes a directed pull of hacker in cyberspace.
type CyberspaceFlightPull byte
// String returns a textual representation.
func (pull CyberspaceFlightPull) String() string {
switch pull {
case CyberspaceFlightPullNone:
return "None"
case CyberspaceFlightPull... | ss1/content/archive/level/CyberspaceFlightPull.go | 0.723016 | 0.547222 | CyberspaceFlightPull.go | starcoder |
package main
import (
"strings"
"github.com/gdamore/tcell"
"github.com/rivo/tview"
)
const tableData = `OrderDate|Region|Rep|Item|Units|UnitCost|Total
1/6/2017|East|Jones|Pencil|95|1.99|189.05
1/23/2017|Central|Kivell|Binder|50|19.99|999.50
2/9/2017|Central|Jardine|Pencil|36|4.99|179.64
2/26/2017|Central|Gill|Pen... | teonet/app/teoroom/table/main.go | 0.503174 | 0.50061 | main.go | starcoder |
package model
// Node is a Node in a Binary Tree
type Node struct {
Left *Node
Right *Node
Key string
Value *Row
}
// NewNode Return a new empty node
func NewNode(row *Row) *Node {
return &Node{Left: nil, Right: nil, Value: row, Key: row.Name}
}
// HasDependencyOf is True if the Row have a dependancy with th... | internal/app/model/Tree.go | 0.771972 | 0.446977 | Tree.go | starcoder |
package metrics
// Item is an object containing current value for a given metrics.
type Item struct {
Name string
Value float64
Params interface{}
}
// Collector is a main object that stores the values and provides methods for setting and retrieving them,
type Collector struct {
data map[string]*Item
op... | internal/metrics/collector.go | 0.740737 | 0.467271 | collector.go | starcoder |
package cu
// AllocStatus represents the allocation status of SGPRs, VGPRs, or LDS units
type AllocStatus byte
// A list of possible status for CU binded storage allocation
const (
AllocStatusFree AllocStatus = iota
AllocStatusToReserve // A value that is used for reservation caculation
AllocStatu... | timing/cu/resourcemask.go | 0.709019 | 0.432723 | resourcemask.go | starcoder |
package zeroformatter
func (s *serializer) writeSize1Int64(value int64, offset uint32) {
s.create[offset] = byte(value)
}
func (s *serializer) writeSize2Int64(value int64, offset uint32) {
s.create[offset] = byte(value)
s.create[offset+1] = byte(value >> 8)
}
func (s *serializer) writeSize4Int64(value int64, offs... | write.go | 0.628635 | 0.410047 | write.go | starcoder |
package perceptron
import (
"fmt"
"math/rand"
)
type Perceptron struct {
Weights []float64
Threshold float64
}
// New creates a new Perceptron with the specified number of inputs.
// It assigns random weights to each of the inputs and generates a
// random activation threshold for the Perceptron.
func New(numI... | perceptron.go | 0.779909 | 0.514888 | perceptron.go | starcoder |
package nlpbench
import (
"math"
"github.com/gonum/matrix/mat64"
"github.com/james-bowman/sparse"
)
type Transformer interface {
Fit(mat64.Matrix) Transformer
Transform(mat mat64.Matrix) (*mat64.Dense, error)
FitTransform(mat mat64.Matrix) (*mat64.Dense, error)
}
type TfidfTransformer1 struct {
transform *ma... | weightings.go | 0.868896 | 0.630557 | weightings.go | starcoder |
package iobuf
// Slice refers to an iobuf and the byte slice for the actual data.
type Slice struct {
iobuf *buf
free uint // Free area before base, if any.
base uint // Index into the underlying iobuf.
Contents []byte // iobuf.Contents[base:bound]
}
// Size returns the number of bytes in the Slic... | x/ref/runtime/internal/lib/iobuf/slice.go | 0.756807 | 0.459501 | slice.go | starcoder |
package parser
import (
"bufio"
"io"
)
// SyntacticParser performs lexical parsing of the input according definition
// of some lexemes like terminal or non-terminal symbol.
type SyntacticParser struct {
Reader io.Reader
buf []byte
pos int
}
func NewSyntacticParser(reader io.Reader) *SyntacticParser {
return ... | pkg/parser/syntactic.go | 0.683736 | 0.478529 | syntactic.go | starcoder |
package tests
import (
"context"
"strings"
"testing"
"github.com/IPFS-eX/interface-go-ipfs-core"
opt "github.com/IPFS-eX/interface-go-ipfs-core/options"
)
func (tp *TestSuite) TestKey(t *testing.T) {
tp.hasApi(t, func(api iface.CoreAPI) error {
if api.Key() == nil {
return apiNotImplemented
}
return n... | tests/key.go | 0.52829 | 0.468973 | key.go | starcoder |
package g5
import (
gl "github.com/chsc/gogl/gl33"
)
type _TextureRect struct {
program *_Program
vao gl.Uint
vbo gl.Uint
}
func newTextureRect(vertexShaderFilename, fragmentShaderFilename string) *_TextureRect {
r := &_TextureRect{}
r.program = newProgram(vertexShaderFilename, fragmentShaderFilename)
gl.... | texture-rect.go | 0.645343 | 0.437703 | texture-rect.go | starcoder |
package core
import (
"math"
)
// Largest triangle three buckets (LTTB) data downsampling algorithm implementation
// - Require: data . The original data
// - Require: threshold . Number of data points to be returned
func LTTB(data []Point, threshold int) []Point {
if threshold >= len(data) || threshold == 0 {
... | core/lttb.go | 0.73678 | 0.510252 | lttb.go | starcoder |
package fieldmap
import (
"fmt"
"reflect"
)
// FieldPath represents the fields we need to access to get to the field we care about.
type FieldPath []reflect.StructField
// visitFields calls the input function on all paths to a field in the input toWalk type.
func visitFields(toWalk interface{}, visitField func(fie... | pkg/search/fieldmap/field_visitor.go | 0.633524 | 0.428174 | field_visitor.go | starcoder |
package rangetree
import "go-structures-algorithm/src/structures/slice"
type immutableRangeTree struct {
number uint64
top orderedNodes
dimensions uint64
}
func newCache(dimensions uint64) []slice.Int64Slice {
cache := make([]slice.Int64Slice, 0, dimensions-1)
for i := uint64(0); i < dimensions; i++ ... | src/structures/rangetree/immutable.go | 0.70069 | 0.464234 | immutable.go | starcoder |
package stream
import (
"time"
"math"
)
// IntervalRouter sends stream data to an accumulator based matching the ordinal value to an interval
type IntervalRouter struct {
key string
intervalSize int64
intervalType IntervalType
maxIntervalLag uint32... | stream/intervalrouter.go | 0.73029 | 0.427158 | intervalrouter.go | starcoder |
package gohbv
import (
"math"
"gonum.org/v1/gonum/floats"
"gonum.org/v1/gonum/stat"
)
func Q_obs_to_array(inData []InputData) []float64 {
var Q_values []float64
for _, value := range inData {
Q_values = append(Q_values, value.Discharge)
}
return Q_values
}
func Q_sim_to_array(mState []ModelState) []float64... | hbv_fit_measures.go | 0.753013 | 0.505371 | hbv_fit_measures.go | starcoder |
package output
import (
"fmt"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message/batch"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/util/aws/session"
"... | lib/output/dynamodb.go | 0.766162 | 0.792906 | dynamodb.go | starcoder |
package util
import (
"fmt"
"net"
"reflect"
"strconv"
"strings"
"time"
utilnet "k8s.io/apimachinery/pkg/util/net"
)
// findNestedElement uses reflection to find the element corresponding to the dot-separated string parameter.
func findNestedElement(s string, c interface{}) (reflect.Value, error) {
fields := ... | pkg/util/config.go | 0.717012 | 0.413892 | config.go | starcoder |
package traversal
import (
"errors"
"fmt"
"io"
"math"
"reflect"
"strconv"
"time"
"github.com/skydive-project/skydive/common"
"github.com/skydive-project/skydive/topology/graph"
)
type (
// GremlinTraversalSequence describes a sequence of steps
GremlinTraversalSequence struct {
GraphTraversal *GraphTrave... | topology/graph/traversal/traversal_parser.go | 0.695131 | 0.432962 | traversal_parser.go | starcoder |
package fusetesting
import (
"fmt"
"os"
"reflect"
"syscall"
"time"
"github.com/jacobsa/oglematchers"
)
// Match os.FileInfo values that specify an mtime equal to the given time.
func MtimeIs(expected time.Time) oglematchers.Matcher {
return oglematchers.NewMatcher(
func(c interface{}) error { return mtimeI... | vendor/github.com/jacobsa/fuse/fusetesting/stat.go | 0.661595 | 0.470007 | stat.go | starcoder |
package main
import (
"aoc2021/utils"
"fmt"
"log"
"strconv"
"github.com/beefsack/go-astar"
)
type Grid struct {
g [][]*Point
maxX, maxY int
}
type Point struct {
p utils.Point[int]
weight int
g Grid // back reference to containing map for A* algo
}
func (p *Point) PathNeighbors() []ast... | daphillips/15/day15.go | 0.553023 | 0.449091 | day15.go | starcoder |
package table
import (
"fmt"
"reflect"
"github.com/mysza/go-service-template/Godeps/_workspace/src/github.com/onsi/ginkgo"
)
/*
DescribeTable describes a table-driven test.
For example:
DescribeTable("a simple table",
func(x int, y int, expected bool) {
Ω(x > y).Should(Equal(expected))
... | Godeps/_workspace/src/github.com/onsi/ginkgo/extensions/table/table.go | 0.717111 | 0.599427 | table.go | starcoder |
package parquet
import (
sch "github.com/viant/parquet/schema"
)
// SchemeOption is used to set some of the metadata for each column
type SchemeOption func(*sch.SchemaElement)
// RepetitionRequired sets the repetition type to required
func RepetitionRequired(se *sch.SchemaElement) {
t := sch.FieldRepetitionType_RE... | options.go | 0.569972 | 0.430088 | options.go | starcoder |
package techan
//lint:file-ignore S1038 prefer Fprintln
import (
"fmt"
"io"
"time"
"github.com/sdcoffey/big"
)
// Analysis is an interface that describes a methodology for taking a TradingRecord as input,
// and giving back some float value that describes it's performance with respect to that methodology.
type ... | analysis.go | 0.676086 | 0.63576 | analysis.go | starcoder |
package gotalib
// The Triple Exponential Moving Average (TEMA) reduces the lag of traditional
// EMAs, making it more responsive and better-suited for short-term trading.
// Shortly after developing the Double Exponential Moving Average (DEMA) in 1994,
// <NAME> took the concept a step further and created the Triple
... | tema.go | 0.803829 | 0.491517 | tema.go | starcoder |
package managers
import (
"GIG-SDK/models"
"GIG/app/utilities/managers"
)
/*
New entity title is within lifetime of existing entity returns false if entity is terminated
*/
func (t *TestManagers) TestThatNewEntityTitleIsWithinLifetimeOfExistingEntityReturnsFalseIfEntityIsTerminated() {
testValue := managers.Entit... | tests/app/utilities/managers/entity_manager.go | 0.680135 | 0.423518 | entity_manager.go | starcoder |
package models
import (
"fmt"
"math"
"raytracer/utility"
"github.com/go-gl/mathgl/mgl32"
)
// Bounding volume hierarchy for accelerated
// ray hit detection
type BVH struct {
Root *BVHNode
}
type BVHNode struct {
Depth int
Index int
LeftChild *BVHNode
RightChild *BVHNode
Bounds *AABB
// L... | src/backend/models/bvh.go | 0.705379 | 0.475484 | bvh.go | starcoder |
package astmodel
import (
"fmt"
"strings"
"github.com/dave/dst"
"github.com/gobuffalo/flect"
"github.com/Azure/azure-service-operator/v2/tools/generator/internal/astbuilder"
)
// TypeName is a name associated with another Type (it also is usable as a Type)
type TypeName struct {
PackageReference PackageRefere... | v2/tools/generator/internal/astmodel/type_name.go | 0.786664 | 0.406567 | type_name.go | starcoder |
package xerrs
import (
"errors"
"fmt"
"runtime"
"strings"
)
// This value represents the offset in the stack array. We want to keep this
// number at 2 so that we do not see XErr functions in the stack
const stackFunctionOffset = 2
type xerr struct {
data map[string]interface{}
cause error
mask error
stack... | xerrs.go | 0.761982 | 0.40028 | xerrs.go | starcoder |
package fake
// Latitude generates latitude (from -90.0 to 90.0)
func Latitude() float32 {
return f.Latitude()
}
// LatitudeDegrees generates latitude degrees (from -90 to 90)
func LatitudeDegrees() int {
return f.LatitudeDegrees()
}
// LatitudeMinutes generates latitude minutes (from 0 to 60)
func LatitudeMinutes... | geo.go | 0.88372 | 0.62949 | geo.go | starcoder |
package plot
import (
"math"
"sort"
)
// Density implements density plot using cubic-pulse kernel.
type Density struct {
Style
Label string
Kernel Length
Normalized bool
Data []float64 // sorted
}
// NewDensity creates a density plot from the given values.
func NewDensity(label string, values []flo... | density.go | 0.825765 | 0.55917 | density.go | starcoder |
package kafka
import (
"strings"
"time"
"justledger/common/metrics"
gometrics "github.com/rcrowley/go-metrics"
)
/*
Per the documentation at: https://godoc.org/github.com/Shopify/sarama Sarama exposes the following set of metrics:
+----------------------------------------------+------------+----------------... | orderer/consensus/kafka/metrics.go | 0.691497 | 0.420302 | metrics.go | starcoder |
package structomancer
import (
"errors"
"fmt"
"reflect"
)
func IsZero(v reflect.Value) bool {
switch v.Kind() {
case reflect.Invalid:
return true
case reflect.Func, reflect.Map, reflect.Slice, reflect.Chan:
return v.IsNil()
case reflect.Array:
z := true
for i := 0; i < v.Len(); i++ {
z = z && IsZero... | utils.go | 0.53777 | 0.575528 | utils.go | starcoder |
package miner
import (
"errors"
"golang.org/x/xerrors"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/util/adt"
)
// Deadline calculations with respect to a current epoch.
// "Deadline" refers to the window during which proofs may be submitted.
// Windows ... | actors/builtin/miner/deadlines.go | 0.772616 | 0.488222 | deadlines.go | starcoder |
package activation
import (
"fmt"
"reflect"
"strings"
"github.com/nlpodyssey/spago/ag"
"github.com/nlpodyssey/spago/mat"
)
// Name is the enumeration-like type used for the set of built-in activations.
type Name int
const (
// Identity identifies the Graph.Identity operator.
Identity Name = iota
// Tan ide... | nn/activation/types.go | 0.764012 | 0.417806 | types.go | starcoder |
package benchmark
import (
"reflect"
"testing"
)
func isBoolPredicateCalibrated(supplier func() bool) bool {
return isCalibrated(reflect.Bool, reflect.Bool, reflect.ValueOf(supplier).Pointer())
}
func isIntPredicateCalibrated(supplier func() int) bool {
return isCalibrated(reflect.Int, reflect.Bool, reflect.Valu... | common/benchmark/01_predicate.go | 0.718002 | 0.706975 | 01_predicate.go | starcoder |
package expreduce
import (
"math/big"
)
type singleParamQType (func(Ex) bool)
type singleParamQLogType (func(Ex, *CASLogger) bool)
type doubleParamQLogType (func(Ex, Ex, *CASLogger) bool)
type evalFnType (func(*Expression, *EvalState) Ex)
func singleParamQEval(fn singleParamQType) evalFnType {
return (func(this *E... | expreduce/qfunctions.go | 0.54698 | 0.412353 | qfunctions.go | starcoder |
package furex
import (
"image"
"github.com/hajimehoshi/ebiten/v2"
)
// Drawable represents a UI component that can be added to a Flex container.
type Drawable interface {
// Draw function draws the content of the component inside the frame.
// The frame parameter represents the location (x,y) and size (width,hei... | component.go | 0.655557 | 0.481941 | component.go | starcoder |
package gllrb
import "bytes"
// Comparer is an interface that we use to compare LLRB keys
type Comparer interface {
Compare(treeKey Comparer) int
Value() interface{}
}
// ByteComparer is a wrapper struct around a []byte value that enables us
// to use it with our red black tree
type ByteComparer []byte
// UIntCom... | compare.go | 0.737536 | 0.405419 | compare.go | starcoder |
package fairqueuing
import (
"math"
"sync"
"time"
"k8s.io/apiserver/pkg/util/flowcontrol/metrics"
"k8s.io/utils/clock"
)
// Integrator computes the moments of some variable X over time as
// read from a particular clock. The integrals start when the
// Integrator is created, and ends at the latest operation on... | staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/integrator.go | 0.713731 | 0.435001 | integrator.go | starcoder |
package sliceutil
import (
"fmt"
"reflect"
"errors"
)
/*
Usage: find(a, func(i interface{}) bool { return i == 5 })
returns index of a value in a given slice
Accepts:
- slice : slice of an array
f : filter function for finding the element
*/
func Find(slice interface{}, f func(interface{}) bool) int {... | sliceutil/sliceutil.go | 0.616705 | 0.544801 | sliceutil.go | starcoder |
package data
import (
"sort"
"sync"
"time"
)
type Point struct {
Timestamp time.Time
Value float64
}
func (p *Point) Less(o Point) bool {
return p.Timestamp.Before(o.Timestamp)
}
func (p *Point) Equal(o Point) bool {
return p.Timestamp.Equal(o.Timestamp) && p.Value == o.Value
}
type Points []Point
func... | data/datapoint.go | 0.631367 | 0.44734 | datapoint.go | starcoder |
package schnorr
import (
"crypto/dsa"
"crypto/rand"
"fmt"
"math/big"
"github.com/xlab-si/emmy/crypto/common"
)
// Group is a cyclic group in modular arithmetic. It holds P = Q * R + 1 for some R.
// The actual value R is never used (although a random element from this group could be computed
// by a^R for some ... | crypto/schnorr/group.go | 0.793586 | 0.430746 | group.go | starcoder |
package continuous
import (
"github.com/jtejido/linear"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Pareto distribution
// https://en.wikipedia.org/wiki/Pareto_distribution
type Pareto struct {
shape, xmin float64 // α, xm
src rand.Source
natural linear.RealVe... | dist/continuous/pareto.go | 0.800146 | 0.614914 | pareto.go | starcoder |
package stats
import (
"bytes"
"fmt"
"io"
"math"
"time"
)
// Stats is a simple helper for gathering additional statistics like histogram
// during benchmarks. This is not thread safe.
type Stats struct {
numBuckets int
unit time.Duration
min, max int64
histogram *Histogram
durations durationSlice
... | vendor/google.golang.org/grpc/benchmark/stats/stats.go | 0.69181 | 0.439928 | stats.go | starcoder |
package httpref
// Methods represents all of the defined HTTP methods
var Methods = References{
{
Name: "Methods",
IsTitle: true,
Summary: "https://developer.mozilla.org/en-US/docs/Web/HTTP/MEthods",
Description: `HTTP defines a set of request methods to indicate the desired action to be performed for a gi... | methods.go | 0.922452 | 0.451508 | methods.go | starcoder |
package matrixutils
import (
"fmt"
"math"
"github.com/mjibson/go-dsp/dsputils"
)
func positiveMod(n, k int) int {
if n < 0 {
return k - ((-1 * n) % k)
}
return n % k
}
func RasterToCartesian(matrix *dsputils.Matrix) (*dsputils.Matrix, error) {
dims := matrix.Dimensions()
if len(dims) > 2 {
return nil, ... | utils.go | 0.797793 | 0.720725 | utils.go | starcoder |
package memory
import (
"github.com/google/gapid/core/data/binary"
"github.com/google/gapid/core/math/u64"
"github.com/google/gapid/core/os/device"
)
// Encoder provides methods to write primitives to a binary.Writer, respecting
// a given MemoryLayout.
// Encoder will automatically handle alignment and types siz... | gapis/memory/encoder.go | 0.756088 | 0.416975 | encoder.go | starcoder |
package validate
import "github.com/pkg/errors"
// SimpleBoolValidationFunc is a custom validation function that can be applied to a bool value with no arguments.
type SimpleBoolValidationFunc func(i bool) error
// Validate implements Validation.
func (v SimpleBoolValidationFunc) Validate(i interface{}, args ...int... | validate/validations_simple.go | 0.85344 | 0.489564 | validations_simple.go | starcoder |
package plotter
import (
"image/color"
"gonum.org/v1/plot"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
// StepKind specifies a form of a connection of two consecutive points.
type StepKind int
const (
// NoStep connects two points by simple line
NoStep StepKind = iota
// PreStep connects two point... | plotter/line.go | 0.825941 | 0.51818 | line.go | starcoder |
package ray
import (
"math"
)
// BoundingBox ...
type BoundingBox struct {
Transform
childs []Object
name string
min Point3
max Point3
}
// NewBoundingBox ...
func NewBoundingBox() *BoundingBox {
return &BoundingBox{
Transform: IDTransform,
}
}
// SetName ...
func (bb *BoundingBox) SetName(name st... | boundingbox.go | 0.639849 | 0.453746 | boundingbox.go | starcoder |
package cosinus
import (
"math"
"github.com/wearelumenai/distclus/core"
"github.com/wearelumenai/distclus/euclid"
)
// Space represents a space that uses cosinus distance
type Space struct {
vspace euclid.Space
}
// NewSpace creates a new Space instance
func NewSpace() Space {
return Space{
vspace: euclid.Ne... | cosinus/cosinus.go | 0.883142 | 0.457561 | cosinus.go | starcoder |
package timeago
import (
"errors"
"fmt"
"math"
"time"
)
type DateAgoValues int
const (
SecondsAgo DateAgoValues = iota
MinutesAgo
HoursAgo
DaysAgo
WeeksAgo
MonthsAgo
YearsAgo
)
// TimeAgoFromNowWithTime takes a specific end Time value
// and the current Time to return how much has been passed
// between ... | vendor/src/github.com/ararog/timeago/timeago.go | 0.595728 | 0.596257 | timeago.go | starcoder |
package trdsql
import (
"fmt"
"io"
"reflect"
)
// SliceReader is a structure for reading tabular data in memory.
// It can be used as the trdsql reader interface.
type SliceReader struct {
tableName string
names []string
types []string
data [][]interface{}
}
// NewSliceReader takes a tableName an... | input_slice.go | 0.622804 | 0.427397 | input_slice.go | starcoder |
package clusters
import (
"math"
)
// DistanceFunc represents a function for measuring distance
// between n-dimensional vectors.
type DistanceFunc func([]float64, []float64) float64
// Online represents parameters important for online learning in
// clustering algorithms.
type Online struct {
Alpha float64
D... | clusters.go | 0.68742 | 0.729375 | clusters.go | starcoder |
package http
// HTTP headers let the client and the server pass additional information with an HTTP request or response.
/*
ENUM(
All
// Authentication
WWW-Authenticate //Defines the authService method that should be used to access a resource.
Authorization // Contains the credentials to authenticate a user-agent wi... | pkg/common/config/model/http/httpHeaderType.go | 0.791378 | 0.525795 | httpHeaderType.go | starcoder |
package merge
import (
"fmt"
"math"
"reflect"
govaluate "github.com/wuhuizuo/govaluate"
)
// Sum get sum from values
func Sum(vals ...interface{}) interface{} {
if len(vals) == 1 {
return vals[0]
}
if len(vals) > 1 {
t := reflect.TypeOf(vals[0])
for _, v := range vals[1:] {
if t != reflect.TypeOf(v)... | merge/algorithm.go | 0.553264 | 0.47025 | algorithm.go | starcoder |
package pricespecification
import "github.com/dpb587/go-schemaorg"
var (
// The lowest price if the price is a range.
MinPrice = schemaorg.NewProperty("minPrice")
// The transaction volume, in a monetary unit, for which the offer or price
// specification is valid, e.g. for indicating a minimal purchasing volume... | things/pricespecification/properties.go | 0.772101 | 0.483892 | properties.go | starcoder |
package main
import (
"math"
"math/rand"
"time"
)
type Perceptron struct {
input [][]float64
actualOutput []float64
weights []float64
bias float64
epochs int
}
// Dot Product of Two Vectors of same size
func dotProduct(v1, v2 []float64) float64 {
dot := 0.0
for i := 0; i < len(v1)... | perceptron/main.go | 0.763748 | 0.440349 | main.go | starcoder |
package geom
//MultiLineString is a collection of two-dimensional geometries representing multi-vertex lines
type MultiLineString []LineString
//MultiLineStringZ is a collection of three-dimensional geometries representing multi-vertex lines
type MultiLineStringZ []LineStringZ
//MultiLineStringM is a collection of ... | multilinestring.go | 0.881564 | 0.432723 | multilinestring.go | starcoder |
package govector
import (
"errors"
)
// ErrorCastToVector error is returned when we cannot cast the interface to a vector
var ErrorCastToVector = errors.New("unable to cast input into vector")
// AsVector converts slices of numeric types into a Vector.
func AsVector(any interface{}) (Vector, error) {
switch x := a... | convert.go | 0.756178 | 0.682058 | convert.go | starcoder |
package image
import (
"fmt"
"image"
"image/color"
"math/big"
"github.com/google/tiff"
)
/* Baseline Bilevel
Color
Tag 262 (PhotometricInterpretation)
0 = WhiteIsZero (normal when Compression=2)
1 = BlackIsZero (If Compression=2, the image should display and print reversed)
Compression
Tag 259 (Compres... | image/baseline_bilevel.go | 0.634656 | 0.543045 | baseline_bilevel.go | starcoder |
package iconvg
import (
"image/color"
"math"
"golang.org/x/image/math/f32"
)
const magic = "\x89IVG"
var magicBytes = []byte(magic)
var (
negativeInfinity = math.Float32frombits(0xff800000)
positiveInfinity = math.Float32frombits(0x7f800000)
)
func isNaNOrInfinity(f float32) bool {
return math.Float32bits(... | vendor/golang.org/x/exp/shiny/iconvg/iconvg.go | 0.755997 | 0.477189 | iconvg.go | starcoder |
package integer
import (
"math/big"
"github.com/calebcase/bsv/control"
)
// Block is a signed integer number.
type Block struct {
Value []byte
Negative bool
}
// MarshalBinary implements encoding.BinaryMarshaler.
func (b Block) MarshalBinary() (data []byte, err error) {
i := new(big.Int).SetBytes(b.Value)
... | integer/integer.go | 0.636918 | 0.585457 | integer.go | starcoder |
package validators
import (
"github.com/loveandpeople-DAG/goClient/bundle"
. "github.com/loveandpeople-DAG/goClient/consts"
. "github.com/loveandpeople-DAG/goClient/guards"
. "github.com/loveandpeople-DAG/goClient/trinary"
"github.com/pkg/errors"
"net/url"
)
// Validatable is a function which validates somethin... | guards/validators/validator.go | 0.648466 | 0.479626 | validator.go | starcoder |
package main
import (
"math"
"github.com/life4/gweb/canvas"
"github.com/life4/gweb/web"
)
type Platform struct {
circle *Circle
rect *Rectangle
context canvas.Context2D
element web.Canvas
// movement
mouseX int
// borders
windowWidth int
windowHeight int
}
func (pl Platform) Contains(point Point) bo... | examples/breakout/platform.go | 0.700075 | 0.408395 | platform.go | starcoder |
package rfb
import (
"encoding/binary"
"fmt"
"image"
"image/color"
)
// PixelFormatImage represents an image using the wire format specified by PixelFormat. Supports arbitrary drawing with At and Set, but for speed, use CopyToRGBA and CopyFromRGBA.
type PixelFormatImage struct {
Pix []uint8
Rect ... | rfb/image.go | 0.844088 | 0.441432 | image.go | starcoder |
package types
// The details of an Elastic Inference Accelerator type.
type AcceleratorType struct {
// The name of the Elastic Inference Accelerator type.
AcceleratorTypeName *string
// The memory information of the Elastic Inference Accelerator type.
MemoryInfo *MemoryInfo
// The throughput information of t... | service/elasticinference/types/types.go | 0.626581 | 0.518546 | types.go | starcoder |
// Package fun (functions) implements special functions such as elliptical, orthogonal polynomials,
// Bessel, discrete Fourier transform, polynomial interpolators, and more.
package fun
import (
"math"
"github.com/cpmech/gosl/la"
)
// π = 3.141592653589...
const π = math.Pi
// Ss defines a scalar function f(s) ... | fun/definitions.go | 0.797162 | 0.607925 | definitions.go | starcoder |
package types
import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Delegation represents a single delegation made from a delegator
// to a specific validator at a specific height (and timestamp)
// containing a given amount of tokens
type Delegation struct {
DelegatorAddress string
ValidatorOperAddr st... | types/staking_delegations.go | 0.793106 | 0.445469 | staking_delegations.go | starcoder |
package samples
func init() {
sampleDataProposalCreateOperation[18] = `{
"expiration_time": "2016-02-10T23:59:59",
"extensions": [],
"fee": {
"amount": 4033593,
"asset_id": "1.3.0"
},
"fee_paying_account": "1.2.282",
"proposed_ops": [
{
"op": [
0,
{
"amount": ... | gen/samples/proposalcreateoperation_18.go | 0.574753 | 0.509825 | proposalcreateoperation_18.go | starcoder |
package main
import (
"fmt"
"sort"
"github.com/james-wallis/adventofcode/utils"
)
// DiffNumbersEqualNumber : returns true if num1 and num2 are different and they equal the result when added together
func DiffNumbersEqualNumber(num1, num2, result int) bool {
if num1 != num2 && num1+num2 == result {
return true... | 9/encodingError.go | 0.657209 | 0.491944 | encodingError.go | starcoder |
package s2geojson
import (
"encoding/json"
"github.com/golang/geo/s2"
)
const (
TypePoint Type = "Point"
TypePolygon Type = "Polygon"
TypeMultiPolygon Type = "MultiPolygon"
TypeFeature Type = "Feature"
TypeFeatureCollection Type = "FeatureCollection"
)
type Type string
t... | cmd/example/app/server/handler/s2geojson/geojson.go | 0.841793 | 0.60326 | geojson.go | starcoder |
package schema
// language=JSON
const V2 = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"id": "https://github.com/fe3dback/go-arch-lint/v2",
"title": "Go Arch Lint V2",
"type": "object",
"description": "Arch file scheme version 2",
"required": ["version", "components", "deps"],
"additionalProperties... | internal/schema/v2.go | 0.536799 | 0.481698 | v2.go | starcoder |
package conf
// Uint16Var defines a uint16 flag and environment variable with specified name, default value, and usage string.
// The argument p points to a uint16 variable in which to store the value of the flag and/or environment variable.
func (c *Configurator) Uint16Var(p *uint16, name string, value uint16, usage ... | value_uint16.go | 0.750095 | 0.530054 | value_uint16.go | starcoder |
package maps
import (
"fmt"
"image"
"image/draw"
"math"
"github.com/tumasgiu/go-mapbox/lib/base"
"image/color"
)
// Tile is a wrapper around an image that includes positioning data
type Tile struct {
draw.Image
Level uint64 // Tile zoom level
Size uint64 // Tile size
X, Y uint64 // Tile X and Y postions ... | lib/maps/tile.go | 0.816516 | 0.541894 | tile.go | starcoder |
package set
type empty struct{}
// Set implements set using hash table
type Set[T comparable] map[T]empty
// Make create new Set
func Make[T comparable](values ...T) Set[T] {
s := Set[T]{}
s.AddAll(values...)
return s
}
// Add adds new element to Set
func (s Set[T]) Add(value T) {
s[value] = empty{}
}
// AddAl... | container/set/set.go | 0.80784 | 0.457985 | set.go | starcoder |
package aoc
import (
"bufio"
"constraints"
"os"
"regexp"
"strconv"
"strings"
)
// Numeric is a type constraint that accepts all go number types.
type Numeric interface {
constraints.Integer | constraints.Float
}
// Feels janky, but proving a point/theory...
func Sum9[N Numeric](nums [9]N) N {
var value N
fo... | cicavey/aoc/io.go | 0.663015 | 0.455683 | io.go | starcoder |
package hashtimelock
import (
"bytes"
"encoding/gob"
"fmt"
"hash"
"github.com/mit-dci/opencx/crypto"
)
// HashTimelock is a struct that holds all data necessary to implement a timelock
type HashTimelock struct {
// timelockSeed is the initial data that then gets hashed by a hash function
TimelockSeed []byte
... | crypto/hashtimelock/hashtimelock.go | 0.646014 | 0.425367 | hashtimelock.go | starcoder |
package transforms
import (
"github.com/facebookgo/errgroup"
"gopkg.in/Clever/optimus.v3"
)
// RowIdentifier takes in a row and returns something that uniquely identifies the Row.
type RowIdentifier func(optimus.Row) (interface{}, error)
// KeyIdentifier is a convenience function that returns a RowIdentifier that ... | plugins/data/transform/optimus/transforms/pair.go | 0.78083 | 0.45181 | pair.go | starcoder |
// Package histogram provides methods to compute approximate
// color histograms in the HSV color space.
package histogram
import (
"github.com/AlessandroPomponio/hsv/conversion"
"image"
"math"
"runtime"
)
const (
// RoundClosest will round to the closest value using math.Round
RoundClosest = iota
// RoundUp... | histogram/32_bins.go | 0.881971 | 0.581422 | 32_bins.go | starcoder |
package rady
import (
"fmt"
"github.com/labstack/echo"
"github.com/tidwall/gjson"
"io/ioutil"
"os"
"reflect"
"strings"
"testing"
)
/*
Application is the bootstrap of a Rady app
Root is pointer of app for config, controller and handler registry
BeanMap is map to find *Bean by `Type` and `Name`(when type is t... | application.go | 0.570451 | 0.400398 | application.go | starcoder |
package text
import (
"bytes"
"fmt"
"io"
"strconv"
)
// Line represents a parsed data Line.
type Line struct {
// N holds the line number.
N uint64
// Data holds the data payload part of the line.
Data string
// CRC holds the lines checksum or if data is nil, for the whole document.
CRC uint32
}
// Parser ... | format/text/parser.go | 0.71103 | 0.490846 | parser.go | starcoder |
package goslices
import (
"github.com/shayanh/gcl/internal"
"github.com/shayanh/gcl/iters"
)
// Iter returns an forward iterator to the beginning. Initially, the returned
// iterator is located at one step before the first element (one-before-first).
func Iter[S ~[]T, T any](s S) *FrwIter[T] {
return &FrwIter[T]{
... | goslices/goslices.go | 0.820326 | 0.464355 | goslices.go | starcoder |
package output
import (
"context"
"fmt"
"time"
"github.com/benthosdev/benthos/v4/internal/component"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/component/output"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/int... | internal/old/output/resource.go | 0.544075 | 0.681005 | resource.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
)
// TSQueryArrayFromStringSlice returns a driver.Valuer that produces a PostgreSQL tsquery[] from the given Go []string.
func TSQueryArrayFromStringSlice(val []string) driver.Valuer {
return tsQueryArrayFromStringSlice{val: val}
}
// TSQueryArrayToStrin... | pgsql/tsqueryarr.go | 0.668447 | 0.552359 | tsqueryarr.go | starcoder |
package main
import "sync"
// ConcurrentCutoff sets the number of elements/sub-elements above which
// concurrency is used.
const ConcurrentCutoff = 8 * 1024
// Introsort implements a concurrent version of the introsort algorithm.
type Introsort struct {
Concurrent bool
wg sync.WaitGroup
}
// Sort sorts t... | introsort.go | 0.622574 | 0.44559 | introsort.go | starcoder |
package custplotter
import (
"image/color"
"math"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
"gonum.org/v1/plot/vg/draw"
)
// DefaultTickWidth is the default width of the open and close ticks.
var DefaultTickWidth = vg.Points(2)
// OHLCBars implements the Plotter interface, drawin... | custplotter/ohlcbars.go | 0.81648 | 0.524882 | ohlcbars.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.