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 pathtree
import "fmt"
// ValKey is the map key used when a value is assigned to an intermediate node
// as Branch only supports a single value, either a terminal value or a branch.
// It is expected that intermediate nodes will generally not have values but
// when they do, this will ensure they will be repre... | proto/openconfig/reference/telemetry/pathtree/pathtree.go | 0.646349 | 0.560974 | pathtree.go | starcoder |
package sqlutil
import (
"strings"
"github.com/huandu/go-sqlbuilder"
)
func parseIn(value string) []interface{} {
values := strings.Split(value, ",")
result := make([]interface{}, len(values))
for i := range values {
result[i] = values[i]
}
return result
}
func parseFilter(sb *sqlbuilder.SelectBuilder, key... | query.go | 0.583441 | 0.403156 | query.go | starcoder |
package char
import (
"image/color"
)
// Charer represents the properties a char in an Area should have to be able to be represented in a terminal.
type Charer interface {
Content() string
Background() color.Color
Foreground() color.Color
Bold() bool
Faint() bool
Italic() bool
Underline() bool
Blink() bool
... | char/char.go | 0.837753 | 0.410756 | char.go | starcoder |
package obsreport
import (
"context"
"go.opencensus.io/stats"
"go.opencensus.io/tag"
"go.opencensus.io/trace"
"go.opentelemetry.io/collector/config/configtelemetry"
)
const (
// Key used to identify exporters in metrics and traces.
ExporterKey = "exporter"
// Key used to track spans sent by exporters.
Se... | obsreport/obsreport_exporter.go | 0.673514 | 0.419588 | obsreport_exporter.go | starcoder |
package lib
import (
"fmt"
"log"
)
/* Mappers work by replacing a range of memory addressable by the cpu.
* For example, the program memory normally used to hold instructions
* lives between 0x8000 and 0xffff, which is 32k of memory. If a game
* wants to use 64kb worth of instructions then some or all of t... | lib/mapper.go | 0.593609 | 0.532607 | mapper.go | starcoder |
package blobtesting
import (
"bytes"
"context"
"reflect"
"sort"
"testing"
"time"
"github.com/pkg/errors"
"github.com/kopia/kopia/repo/blob"
)
// AssertGetBlob asserts that the specified BLOB has correct content.
func AssertGetBlob(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, expected [... | internal/blobtesting/asserts.go | 0.713631 | 0.503479 | asserts.go | starcoder |
package graph
import (
"container/list"
"math"
)
type residualGraph interface {
flowGraph
RCap(edge) int
}
type adjacencyMatrixResidual struct {
adjacencyMatrixWithFlow
}
func (g *adjacencyMatrixResidual) init() *adjacencyMatrixResidual {
g.adjacencyMatrixWithFlow.init()
return g
}
func (g *adjacencyMatrixR... | graph/flowGraph.go | 0.730866 | 0.499268 | flowGraph.go | starcoder |
package dsl
import (
"math"
"github.com/peterstace/grayt/colour"
"github.com/peterstace/grayt/scene"
"github.com/peterstace/grayt/xmath"
)
var (
White = colour.Colour{1, 1, 1}
Red = colour.Colour{1, 0, 0}
Green = colour.Colour{0, 1, 0}
Blue = colour.Colour{0, 0, 1}
)
func Vect(x, y, z float64) xmath.Vect... | scene/dsl/dsl.go | 0.798698 | 0.512327 | dsl.go | starcoder |
package validate
import (
"reflect"
"regexp"
"unicode/utf8"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// Enum validates if the data is a member of the enum
func Enum(path, in string, data interface{}, enum interface{}) *errors.Validation {
val := reflect.Val... | vendor/github.com/go-openapi/validate/values.go | 0.757346 | 0.433082 | values.go | starcoder |
package chart
import (
"fmt"
"math"
util "github.com/iesreza/go-chart/util"
)
var (
// BoxZero is a preset box that represents an intentional zero value.
BoxZero = Box{IsSet: true}
)
// NewBox returns a new (set) box.
func NewBox(top, left, right, bottom int) Box {
return Box{
IsSet: true,
Top: top,
... | box.go | 0.851706 | 0.5 | box.go | starcoder |
package sergeant
import (
"math"
"math/rand"
"path/filepath"
"sort"
"strings"
"time"
"github.com/dghubble/trie"
"github.com/sirupsen/logrus"
exprand "golang.org/x/exp/rand"
"gonum.org/v1/gonum/stat/distuv"
wr "github.com/mroth/weightedrand"
)
// DefaultViews is a map containing the default Views used by ... | views.go | 0.717309 | 0.47098 | views.go | starcoder |
package toggl
import (
"fmt"
"github.com/andreaskoch/togglapi/model"
"github.com/pkg/errors"
)
type modelConverter interface {
// ConvertTimeEntryToTimeRecord converts the given TimeEntry model into a TimeRecord model.
// Returns an error if the given TimeEntry could not be converted.
ConvertTimeEntryToTimeRec... | toggl/modelconverter.go | 0.779238 | 0.48182 | modelconverter.go | starcoder |
package lzma
import (
"errors"
"fmt"
"io"
)
// decoder decodes a raw LZMA stream without any header.
type decoder struct {
// dictionary; the rear pointer of the buffer will be used for
// reading the data.
Dict *decoderDict
// decoder state
State *state
// range decoder
rd *rangeDecoder
// start stores t... | vendor/github.com/ulikunitz/xz/lzma/decoder.go | 0.599602 | 0.501404 | decoder.go | starcoder |
package pixel
import (
"image/color"
"math"
)
type Pixel struct {
// RGB comes from Color
R uint32
G uint32
B uint32
A uint32
X int
Y int
// HSV and lum are calculated
h float64
s float64
v float64
h2 int64
lum2 int64
v2 int64
}
type AGreaterThanB struct {
Name string
Exec func(a, b *P... | pixel/pixel.go | 0.661814 | 0.409752 | pixel.go | starcoder |
package openapi
import (
"encoding/json"
)
// Value struct for Value
type Value struct {
ContentInclusion *string `json:"contentInclusion,omitempty"`
ValueInclusion *string `json:"valueInclusion,omitempty"`
}
// NewValue instantiates a new Value object
// This constructor will assign default values to properties... | openapi/model_value.go | 0.788827 | 0.489564 | model_value.go | starcoder |
package math
import (
"math"
"github.com/go-gl/mathgl/mgl32"
)
// AABB is an axis aligned bounding box, used for all collision detection.
type AABB struct {
Center mgl32.Vec3
Size mgl32.Vec3
}
// MinX returns the minimum x bound for the AABB.
func (a AABB) MinX() float32 { return a.Center.X() - a.Size.X()/2.0... | math/aabb.go | 0.904427 | 0.531513 | aabb.go | starcoder |
package bits2str
const (
Bit Bits = 1
Byte = 8 * Bit
// https://en.wikipedia.org/wiki/Orders_of_magnitude_(data)
KB = 1000 * Byte
MB = 1000 * KB
GB = 1000 * MB
TB = 1000 * GB
PB = 1000 * TB
EB = 1000 * PB
)
// Bits represents a quantity of Bits, bytes, kilobytes or megabytes. Bits are
// parsed and for... | bits2str.go | 0.818229 | 0.558267 | bits2str.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// LogsLookupProcessor Use the Lookup Processor to define a mapping between a log attribute and a human readable value saved in the processors mapping table. For example, you can use the Lookup Processor to map an internal service ID into a human readable service na... | api/v1/datadog/model_logs_lookup_processor.go | 0.728265 | 0.439206 | model_logs_lookup_processor.go | starcoder |
package bits
import (
"encoding/binary"
"errors"
"fmt"
"io"
)
const (
startCodeEmulationPreventionByte = 0x03
)
// ESBPReader errors
var (
ErrNotReedSeeker = errors.New("Reader does not support Seek")
)
// NewEBSPReader - return a new Reader.
func NewEBSPReader(rd io.Reader) *EBSPReader {
return &EBSPReader{... | bits/ebsp.go | 0.525856 | 0.408336 | ebsp.go | starcoder |
package iso20022
// Specifies the elements of an entry in the report.
type StatementEntry1 struct {
// Amount of money in the cash entry.
Amount *CurrencyAndAmount `xml:"Amt"`
// Specifies if an entry is a credit or a debit.
CreditDebitIndicator *CreditDebitCode `xml:"CdtDbtInd"`
// Indicates whether the entry... | StatementEntry1.go | 0.814127 | 0.451568 | StatementEntry1.go | starcoder |
package ospf
type NeighborState interface {
HelloReceived(n *Neighbor) (*NeighborState, error)
Start(n *Neighbor) (*NeighborState, error)
TwoWayReceived(n *Neighbor) (*NeighborState, error)
NegotiationDone(n *Neighbor) (*NeighborState, error)
ExchangeDone(n *Neighbor) (*NeighborState, error)
BadLSReq(n *Neighbor... | src/ospf/nfsm.go | 0.717606 | 0.483405 | nfsm.go | starcoder |
package collector
import (
"github.com/opencontainers/runc/libcontainer/cgroups"
)
const (
kbInBytes = 1024
)
type valueExtractor = func(state State) uint64
type durationExtractor = func(thisState State, lastState State) int64
func extractMicroseconds(thisState State, lastState State) int64 {
return thisState.Ti... | collector/util.go | 0.726037 | 0.44559 | util.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// WidgetLayout The layout for a widget on a `free` or **new dashboard layout** dashboard.
type WidgetLayout struct {
// The height of the widget. Should be a non-negative integer.
Height int64 `json:"height"`
// Whether the widget should be the first one on the ... | api/v1/datadog/model_widget_layout.go | 0.794863 | 0.415581 | model_widget_layout.go | starcoder |
package components
import (
"fmt"
"strconv"
)
type HexaconvRecognizer struct {
blueprint [][]string
}
func (h HexaconvRecognizer) Blueprint() [][]string {
return h.blueprint
}
func (h HexaconvRecognizer) NewComponent(id string, x int, y int, input map[string]string) Component {
ina, inb, inc, in... | components/hexaconvcomponent.go | 0.673621 | 0.419707 | hexaconvcomponent.go | starcoder |
package bls
import (
"crypto/cipher"
"errors"
"io"
"github.com/drand/kyber"
bls12381 "github.com/kilic/bls12-381"
)
type Fr32 struct {
V *bls12381.Fr // Integer value from 0 through N-1
}
func NewKyberScalar() kyber.Scalar {
return NewFr32()
}
// NewInt creaters a new Int with a given big.Int and a big.Int ... | kyber_scalar.go | 0.814864 | 0.454533 | kyber_scalar.go | starcoder |
package v1alpha1
// ByteMatchSetListerExpansion allows custom methods to be added to
// ByteMatchSetLister.
type ByteMatchSetListerExpansion interface{}
// ByteMatchSetNamespaceListerExpansion allows custom methods to be added to
// ByteMatchSetNamespaceLister.
type ByteMatchSetNamespaceListerExpansion interface{}
... | client/listers/wafregional/v1alpha1/expansion_generated.go | 0.531453 | 0.428771 | expansion_generated.go | starcoder |
package values
import (
"fmt"
"strings"
"unicode"
)
// StringValue value represents a string value.
type StringValue struct {
value string
decorators []StringDecorator
}
// StringDecorator is a function type to decorate a string.
type StringDecorator func(value string) string
// RemoveSpaces removes all s... | internal/pkg/values/string_value.go | 0.873255 | 0.635123 | string_value.go | starcoder |
package solver
import (
"math"
"github.com/heustis/tsp-solver-go/graph"
"github.com/heustis/tsp-solver-go/model"
)
// FindShortestPathNPNoChecks checks all possible combinations of paths to find the shortest path.
// It accepts an unordered set of vertices, and returns the ordered list of vertices.
// To minimize... | solver/npsolver.go | 0.835349 | 0.624923 | npsolver.go | starcoder |
package spec3
// Link represents a possible design-time link for a response.
// The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.
type Link struct {
VendorExtensible
Referen... | link.go | 0.60871 | 0.495178 | link.go | starcoder |
package linear
import (
"math"
)
const (
default_too_small_lud = 1e-11
)
/**
* Calculates the LUP-decomposition of a square matrix.
* The LUP-decomposition of a matrix A consists of three matrices L, U and
* P that satisfy: P×A = L×U. L is lower triangular (with unit
* diagonal terms), U is upper t... | lu_decomposition.go | 0.848094 | 0.570032 | lu_decomposition.go | starcoder |
package forge
import (
"image/color"
"math"
"sync"
)
// Minimum threshold of pixel difference that categorizes image for a sequential comparision
const threshold float64 = 1500
// Minimum amount of pixel required in a row in order to progress in the sequential comparison
const minReqPixInRow int = 10
// Compare ... | forge/compare.go | 0.77569 | 0.543833 | compare.go | starcoder |
package comptop
import (
"gonum.org/v1/gonum/mat"
)
// CycleGroup Z_p is a subgroup of the ChainGroup C_p of the same dimension p.
// A cycle group Z_p consists of all chains in in the chain group C_p with a zero / empty boundary (ie cycles).
type CycleGroup struct {
chainGroup *ChainGroup
basis []*Chain
}
func ... | homologyGroup.go | 0.767254 | 0.445409 | homologyGroup.go | starcoder |
package lclock
import (
"errors"
"sync"
"time"
)
// VectorTimestamp is the container for vector timestamps.
type VectorTimestamp []uint32
// VectorTimestampMax is the maximum possible timestamp to be committed to a specific position of the VectorTimestamp.
const VectorTimestampMax = ^uint32(0)
// VectorEventCall... | Vector.go | 0.769946 | 0.542015 | Vector.go | starcoder |
package drawgl
import (
"errors"
"image"
"image/draw"
)
type Mask struct {
Image image.Image
Rect image.Rectangle
hasImage bool
hasRect bool
}
type EdgeHandler int
const (
Extend EdgeHandler = iota
Wrap
)
var (
ErrOutOfBounds = errors.New("out of bounds")
)
func NewMask(image image.Image, rect image.... | operation.go | 0.575946 | 0.450178 | operation.go | starcoder |
package validator
import (
"reflect"
)
// IsMap determines if i is a map
func IsMap(i interface{}) bool {
return reflect.ValueOf(i).Kind() == reflect.Map
}
// IsArray determines if i is a slice or array
func IsArray(i interface{}) bool {
kind := reflect.ValueOf(i).Kind()
return kind == reflect.Array || kind == r... | validator/util.go | 0.813683 | 0.545407 | util.go | starcoder |
package main
import (
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/carbocation/pfx"
"cloud.google.com/go/bigquery"
"google.golang.org/api/iterator"
)
type Result struct {
SampleID int64 `bigquery:"sample_id"`
HasDisease bigquery.NullInt64 `bigquery:"has_di... | cmd/ukbb2disease/result.go | 0.722821 | 0.440349 | result.go | starcoder |
package cp
import "math"
type Circle struct {
*Shape
c, tc Vector
r float64
}
func NewCircle(body *Body, radius float64, offset Vector) *Shape {
circle := &Circle{
c: offset,
r: radius,
}
circle.Shape = NewShape(circle, body, CircleShapeMassInfo(0, radius, offset))
return circle.Shape
}
func CircleSh... | circle.go | 0.807157 | 0.460956 | circle.go | starcoder |
package objects
type SourcePolicyList struct {
Sources string `DESCRIPTION: Source Protocol(s) which BGP is interested in. Multiple sources can be specified as comma separated strings when the same policy needs to be applied", SELECTION:"CONNECTED"/"STATIC"/"OSPF"`
Policy string `DESCRIPTION: "Policy that needs to... | objects/bgpObjects.go | 0.784402 | 0.431524 | bgpObjects.go | starcoder |
package brotli
import "math"
/* Copyright 2013 Google Inc. All Rights Reserved.
Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
/* Computes the bit cost reduction by combining out[idx1] and out[idx2] and if
it is below a threshold, stores the pai... | vendor/github.com/andybalholm/brotli/cluster_literal.go | 0.587707 | 0.481149 | cluster_literal.go | starcoder |
* Package BitVector
*
* Here's a problem for you: The germany.osm.pbf file contains 101628726 nodes.
* That's more than 2^26 (actually ~3 * 2^25) nodes.
* The usual way to implement a set in go is as:
* map[int64] bool
* and for a small number of items, say less than 2^23 this is very much acceptable.
* Beyon... | src/alg/bitvector.go | 0.80871 | 0.595787 | bitvector.go | starcoder |
package core
// Command é a struct responsável por guardar informações referentes a um comando
type Command struct {
Cmd string `json:"command"`
Description string `json:"description"`
Usage string `json:"usage"`
Lint string `json:"lint"`
IsActive bool `json:"isActive"`
}
// Commands é ... | src/core/commands.go | 0.660829 | 0.438725 | commands.go | starcoder |
package bits
import "github.com/pkg/errors"
// Block contains a sequence of 0–64 bits. If fewer than 64 bits are needed,
// the sequence is right-aligned and padded with zeros on the left. It is up
// to the caller to interpret how many bits are used.
type Block uint64
// Bitmap represents a fixed-length, sequence o... | bits.go | 0.817793 | 0.55911 | bits.go | starcoder |
package eestream
import (
"io"
"sync"
)
// PieceBuffer is a synchronized buffer for storing erasure shares for a piece.
type PieceBuffer struct {
buf []byte
shareSize int
cond *sync.Cond
newDataCond *sync.Cond
rpos, wpos int
full bool
currentShare int64 // current erasure shar... | private/eestream/piecebuf.go | 0.5083 | 0.402451 | piecebuf.go | starcoder |
package responder
/**
* Configuration for responder action resource.
*/
type Responderaction struct {
/**
* Name for the responder action. Must begin with a letter, number, or the underscore character (_), and must contain only letters, numbers, and the hyphen (-), period (.) hash (#), space ( ), at (@), equals (=),... | resource/config/responder/responderaction.go | 0.796253 | 0.40295 | responderaction.go | starcoder |
package meter
import (
"io"
"time"
)
// NoopMeter is an noop implementation of Meter
type noopMeter struct {
opts Options
}
// NewMeter returns a configured noop reporter:
func NewMeter(opts ...Option) Meter {
return &noopMeter{opts: NewOptions(opts...)}
}
// Clone return old meter with new options
func (r *noo... | meter/noop.go | 0.840095 | 0.478773 | noop.go | starcoder |
package lep
import (
"strings"
)
type SliceX struct {
Values []Value
}
var _ Value = (*SliceX)(nil)
func Slice(values ...Value) *SliceX {
return &SliceX{Values: values}
}
func (e SliceX) Equals(other Expression) bool {
if expr, ok := other.(*SliceX); ok {
if len(e.Values) != len(expr.Values) {
return fals... | slice.go | 0.667148 | 0.419232 | slice.go | starcoder |
package rangedbtest
import (
"bytes"
"fmt"
"math"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/inklabs/rangedb"
)
// VerifyRecordIoStream verifies the RecordIoStream interface.
func VerifyRecordIoStream(t *testing.T, newIoStream func() rangedb.RecordIoStrea... | rangedbtest/verify_record_io_stream.go | 0.599368 | 0.567218 | verify_record_io_stream.go | starcoder |
package state
import . "luago/api"
/*
http://www.lua.org/manual/5.3/manual.html#lua_compare
int lua_compare (lua_State *L, int index1, int index2, int op);
Compares two Lua values. Returns 1 if the value at index index1 satisfies op
when compared with the value at index index2, following the semantics of the
corres... | luago/go/ch06/src/luago/state/api_compare.go | 0.629205 | 0.450903 | api_compare.go | starcoder |
package parallel
import (
"sync"
"golang.org/x/sync/errgroup"
)
// Map manipulates a slice and transforms it to a slice of another type.
// `iteratee` is called in parallel. Result keep the same order.
func Map[T any, R any](collection []T, iteratee func(T, int) R) []R {
result := make([]R, len(collection))
var... | parallel/slice.go | 0.773601 | 0.400515 | slice.go | starcoder |
package slices
import (
"reflect"
"github.com/pkg/errors"
)
func Union(arr1, arr2 interface{}) (reflect.Value, error) {
// Make sure inputs are slices.
if reflect.TypeOf(arr1).Kind() != reflect.Slice ||
reflect.TypeOf(arr2).Kind() != reflect.Slice {
return reflect.Value{}, errors.New("not a slice")
}
// M... | internal/helpers/slices/slices.go | 0.752286 | 0.410047 | slices.go | starcoder |
package main
import (
"log"
"github.com/unixpickle/model3d/model3d"
"github.com/unixpickle/model3d/render3d"
)
func main() {
wedge := Wedge{}
createTopHole := func(c model3d.Coord3D, r float64) *model3d.Sphere {
c.Z = wedge.ZForY(c.Y) + r/2
return &model3d.Sphere{
Center: c,
Radius: r,
}
}
creat... | examples/parody/swiss_cheese/main.go | 0.627951 | 0.411229 | main.go | starcoder |
package main
import (
"github.com/otyg/threagile/model"
"github.com/otyg/threagile/model/confidentiality"
)
type credentialStoredOutsideOfVault string
var RiskRule credentialStoredOutsideOfVault
func (r credentialStoredOutsideOfVault) Category() model.RiskCategory {
return model.RiskCategory{
Id: ... | risks/credential-stored-outside-of-vault/credential-stored-outside-of-vault.go | 0.726134 | 0.400544 | credential-stored-outside-of-vault.go | starcoder |
package render
import (
"image"
"github.com/go-gl/mathgl/mgl32"
"github.com/samuelyuan/openbiohazard2/fileio"
"github.com/samuelyuan/openbiohazard2/geometry"
)
const (
CAMERA_MASK_WIDTH = 256
CAMERA_MASK_HEIGHT = 256
BACKGROUND_IMAGE_WIDTH = 320
BACKGROUND_IMAGE_HEIGHT = 240
)
// Normalize the z coordina... | render/cameramask.go | 0.789761 | 0.564879 | cameramask.go | starcoder |
package cmd
var SbrFormatMd = `
# sbr File
'.sbr' file is a simple easy to read, easy to write format for both human and
computers.
- 'sbr' commands are permissive when reading '.sbr' files, allowing human-ish edition
- 'sbr' commands are strict while writing '.sbr' files, they always generate the same output.... | cmd/sbrformat.md.go | 0.748904 | 0.446615 | sbrformat.md.go | starcoder |
package histogram
const (
// Label holds the string label denoting the histogram type in the database.
Label = "histogram"
// FieldID holds the string denoting the id field in the database.
FieldID = "id" // FieldTime holds the string denoting the time vertex property in the database.
FieldTime = "time... | ent/histogram/histogram.go | 0.588653 | 0.485051 | histogram.go | starcoder |
package table
import (
"sort"
)
// Columns are prioritized by the order their index appears in
// "columnSortPriority". Column indecies that are not provided are prioritized
// the lowest and from first to last. Integers are compared as numbers, but all
// other data types are compared as strings. Nil values are giv... | internal/table/sort.go | 0.596668 | 0.451327 | sort.go | starcoder |
package schema
// ExtensionSchemaJSON is the content of the file "extension.schema.json".
const ExtensionSchemaJSON = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://sourcegraph.com/v1/extension.schema.json#",
"title": "Sourcegraph extension manifest",
"description": "The Sourcegraph ... | schema/extension_stringdata.go | 0.823931 | 0.45042 | extension_stringdata.go | starcoder |
package graphics
import (
"github.com/relnod/evo/pkg/math32"
)
// Renderer defines an interface for a render device.
type Renderer interface {
SetViewport(x, y, width, height float32)
}
// Camera defines a 2D camera, that can zoom and move in all four directions.
type Camera struct {
// window size
windowWidth ... | pkg/graphics/camera.go | 0.844537 | 0.52829 | camera.go | starcoder |
package geom
//Envelope is the bounding box of a geometry
type Envelope struct {
MinX float64
MinY float64
MaxX float64
MaxY float64
}
func NewEnvelope(x1, x2, y1, y2 float64) *Envelope {
var e Envelope
if x1 < x2 {
e.MinX = x1
e.MaxX = x2
} else {
e.MinX = x2
e.MaxX = x1
}
if y1 < y2 {
e.MinY = y... | pkg/geom/envelope.go | 0.829527 | 0.625896 | envelope.go | starcoder |
package cbor
import (
"math/big"
"strconv"
"strings"
)
// Decimal represents an arbitrary-precision signed decimal number. It consists
// of an arbitrary precision integer unscaled value and a scale. If zero or
// positive, the scale is the number of digits to the right of the decimal
// point. If negative, the un... | dax/internal/cbor/decimal.go | 0.697609 | 0.554893 | decimal.go | starcoder |
package bandit
// Package bandit inclludes different strategies/algorithems for the
//stochastic multi-armed bandit problem
import (
"math"
"math/rand"
)
// Given a group of variant the round index is the sum of the observation count.
func RoundIndex(variants []Variant) (roundIndex int) {
for _, v := range varia... | bandit.go | 0.876951 | 0.754644 | bandit.go | starcoder |
package controllers
import "math"
var Zero2 = Vector2{}
type Vector2 struct{ X, Y float64 }
// XY returns both components
func (a Vector2) XY() (x, y float64) { return a.X, a.Y }
// Add adds two vectors and returns the result
func (a Vector2) Add(b Vector2) Vector2 { return Vector2{a.X + b.X, a.Y +... | controllers/vector.go | 0.944048 | 0.892046 | vector.go | starcoder |
package lmath
import (
"math"
"gonet/base"
"unsafe"
)
const(
POINT_EPSILON = (1e-4)
)
type(
Point3F struct {
X float32
Y float32
Z float32
}
IPoint3F interface {
Set(float32 , float32, float32)
SetF([] float32)
SetMin(Point3F)
SetMax(Point3F)
Interpolate(Point3F, Point3F, float32)
Zero()
... | server/game/lmath/point3f.go | 0.683842 | 0.621311 | point3f.go | starcoder |
package embed
import "fmt"
// Gopher is an example struct to show off embedding
type Gopher struct {
Name string
Age int
IsCoding bool
privateField string
}
// GopherV2 has a Gopher embedded inside of it and has some additional fields.
type GopherV2 struct {
// We can make this private if we want like... | basics/completed/embed/embed.go | 0.642096 | 0.430806 | embed.go | starcoder |
package graph
import (
"container/list"
"github.com/Tom-Johnston/mamba/ints"
)
//Distance returns the length of the shortest path from i to j in g and -1 if there is no path
//It finds this by doing a BFS search.
func Distance(g Graph, i, j int) int {
if i == j {
return 0
}
n := g.N()
distances := make([]int... | graph/distances.go | 0.693888 | 0.475301 | distances.go | starcoder |
package main
import (
"encoding/base64"
"fmt"
"fractal/entity"
"image"
"image/color"
"image/draw"
"log"
"math"
"net/url"
proto "github.com/golang/protobuf/proto"
)
func GenerateFractalImage(imageMaxX int, imageMaxY int, b Borders) image.Image {
imgRect := image.Rect(0, 0, imageMaxX, imageMaxY)
img := ima... | apps/fractal/generator.go | 0.660172 | 0.405743 | generator.go | starcoder |
package template
import (
"github.com/apaxa-go/helper/strconvh"
"reflect"
)
var buildinFuncs map[string]interface{} = map[string]interface{}{
"len": func(a interface{}) int { return reflect.ValueOf(a).Len() },
"cap": func(a interface{}) int { return reflect.ValueOf(a).Cap() },
"not": func(a bool) bool { return !... | buildin-functions.go | 0.510741 | 0.449091 | buildin-functions.go | starcoder |
package bayer
import (
"encoding/binary"
"fmt"
)
// Based and adapted/corrected from https://github.com/BryceCicada/demosaic (MIT License)
type (
// A Bayer allows colors' interpolation from a Color Filter Array data.
Bayer interface {
// At returns the RGB pixel.
At(x, y int) (r, g, b float64)
}
// Optio... | bayer/bayer.go | 0.789071 | 0.685381 | bayer.go | starcoder |
package declare
import (
"github.com/robloxapi/rbxfile"
"strings"
)
// Type corresponds to a rbxfile.Type.
type Type byte
// String returns a string representation of the type. If the type is not
// valid, then the returned value will be "Invalid".
func (t Type) String() string {
s, ok := typeStrings[t]
if !ok {... | declare/type.go | 0.737725 | 0.434821 | type.go | starcoder |
package czml
// PolylineMaterial is a definition of how a polyline is colored or shaded
// https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineMaterial
type PolylineMaterial struct {
SolidColor *SolidColorMaterial `json:"solidColor,omitempty"`
PolylineOutline *PolylineOutlineMaterial `json:"p... | polyline_materials.go | 0.86012 | 0.418875 | polyline_materials.go | starcoder |
package circuit
import (
"fmt"
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
"github.com/consensys/gnark/frontend"
)
// Gate assumes the gate can only have 2 inputs
type Gate interface {
// ID returns an ID that is unique for the gate
ID() string
// GnarkEval performs the same computation as Eval but on Gna... | circuit/gates.go | 0.774071 | 0.46308 | gates.go | starcoder |
package game
import (
"errors"
"fmt"
"math/rand"
"github.com/logrusorgru/aurora"
)
const BoardSide = 4
type Direction int
const (
DirRight Direction = iota
DirDown Direction = iota
DirLeft Direction = iota
DirUp Direction = iota
)
type tileMap [BoardSide * BoardSide]int
type freezeMap [BoardSide * Bo... | game/board.go | 0.67971 | 0.415195 | board.go | starcoder |
package ptime
import (
"time"
"github.com/haraldrudell/parl"
)
const (
// RFC 3339 (email) time format
rfc3339 = "2006-01-02 15:04:05-07:00"
// RFC3339NanoSpace RFC3339 format, ns precision, space separator
RFC3339NanoSpace string = "2006-01-02 15:04:05.999999999Z07:00"
)
// Rfc3339 converts local time to str... | ptime/ptime.go | 0.706798 | 0.417093 | ptime.go | starcoder |
package letter_combinations_of_a_phone_number
import (
"strings"
)
func LetterCombinations(digits string) []string {
// If the input is empty, immediately return an empty answer array
if len(digits) == 0 {
return []string{}
}
// Initiate backtracking with an empty path and starting index of 0
combinations :=... | golang/letter_combinations_of_a_phone_number/letter_combinations.go | 0.581778 | 0.424173 | letter_combinations.go | starcoder |
package lowring
import (
"math"
"time"
"github.com/gholt/holdme"
)
type Node uint16
const NilNode Node = math.MaxUint16
type Ring struct {
NodeToCapacity []int
NodeToGroup []int
GroupToGroup []int
ReplicaToPartitionToNode [][]Node
MaxPartitionCount i... | lowring/ring.go | 0.585931 | 0.51013 | ring.go | starcoder |
package casting
import (
"reflect"
"strconv"
"strings"
)
type Converter struct {
inputTypeMap map[string]string
}
func NewConverter(inputTypeMap map[string]string) *Converter {
converter := &Converter{
inputTypeMap: inputTypeMap}
return converter
}
func (converter *Converter) CastSingleElement(inputName str... | internal/casting/converter.go | 0.558086 | 0.405684 | converter.go | starcoder |
package xdeep
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
// Equal Option
type Option struct {
// Fields than in IgnoreFields will skip compare with each other.
// This is useful when you compare with object which come from create api results, which auto create id, create_at, updated_at.
IgnoreField... | equal.go | 0.692954 | 0.630116 | equal.go | starcoder |
package v1alpha1
import (
v1alpha1 "kubeform.dev/kubeform/apis/aws/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// WafRateBasedRuleLister helps list WafRateBasedRules.
type WafRateBasedRuleLister interface {
// List lists all WafRateBasedRules... | client/listers/aws/v1alpha1/wafratebasedrule.go | 0.601359 | 0.405566 | wafratebasedrule.go | starcoder |
package iso20022
// Net position of a segregated holding, in a single security, within the overall position held in a securities account. A securities balance is calculated from the sum of securities' receipts minus the sum of securities' deliveries.
type AggregateBalanceInformation1 struct {
// Total quantity of fi... | AggregateBalanceInformation1.go | 0.873902 | 0.475484 | AggregateBalanceInformation1.go | starcoder |
package main
import (
"github.com/ByteArena/box2d"
"github.com/wdevore/RangerGo/api"
)
// CircleComponent represents both the visual and physic components
type CircleComponent struct {
visual api.INode
b2Body *box2d.B2Body
b2Shape box2d.B2CircleShape
b2Fixture *box2d.B2Fixture
}
// NewCircleComponent con... | examples/physics/basics/slope/circle_component.go | 0.738292 | 0.599133 | circle_component.go | starcoder |
package section
import (
"fmt"
"math"
)
// Rectangle - elementary rectangle element for section design
type Rectangle struct {
XCenter, ZCenter float64 // coordinate of center // meter
Height, Width float64 // size of rectangle // meter
}
// RectangleSection - section created only with rectangle
type Recta... | section/sectionRectangePart.go | 0.745491 | 0.402598 | sectionRectangePart.go | starcoder |
package onshape
import (
"encoding/json"
)
// BodyPartMediaType struct for BodyPartMediaType
type BodyPartMediaType struct {
Type *string `json:"type,omitempty"`
Subtype *string `json:"subtype,omitempty"`
Parameters *map[string]string `json:"parameters,omitempty"`
WildcardType *bool `json:"wildcardType,omitempty... | onshape/model_body_part_media_type.go | 0.746878 | 0.407687 | model_body_part_media_type.go | starcoder |
package matrix
import (
"errors"
"sync"
)
// AddScalar adds a value to all elements in matrix.
func (m *Matrix) AddScalar(val float64) {
for i := range m.data {
m.data[i] += val
}
}
// Add adds a value to first matrix and saves result in its data.
// Both matrices should have the same dimensions.
func (m *Matr... | ops_methods.go | 0.757615 | 0.610773 | ops_methods.go | starcoder |
package scenemanager
import (
"fmt"
"github.com/stnma7e/betuol/common"
"github.com/stnma7e/betuol/component"
"github.com/stnma7e/betuol/event"
"github.com/stnma7e/betuol/math"
)
// TransformManager implements a basic location manager that satisfies the component.SceneManager interface
type TransformManager stru... | component/scenemanager/manager.go | 0.733547 | 0.463566 | manager.go | starcoder |
package indicators
import (
"errors"
"github.com/jaybutera/gotrade"
)
// A Bollinger Band Indicator (BollingerBand), no storage, for use in other indicators
type BollingerBandsWithoutStorage struct {
*baseIndicatorWithFloatBoundsBollinger
// private variables
valueAvailableAction ValueAvailableActionBollinger
... | indicators/bollingerbands.go | 0.683842 | 0.577138 | bollingerbands.go | starcoder |
package ui
// Button is a clickable button that performs some task.
type Button interface {
Control
// OnClicked sets the event handler for when the Button is clicked.
OnClicked(func())
// Text and SetText get and set the Button's label text.
Text() string
SetText(text string)
}
// NewButton creates a new Bu... | basicctrls.go | 0.813535 | 0.401453 | basicctrls.go | starcoder |
package aips
import (
"image"
"image/color"
"math"
)
func ColorDiff(a, b color.Color) float64 {
ra, ga, ba, _ := a.RGBA()
rb, gb, bb, _ := b.RGBA()
return math.Sqrt((30*float64(ra-rb)*float64(ra-rb) + 59*float64(ga-gb)*float64(ga-gb) + 11*float64(ba-bb)*float64(ba-bb)) / 100)
}
func Gaussian(x, y int, sigma fl... | calco.go | 0.73914 | 0.439146 | calco.go | starcoder |
package image
import (
"bytes"
"fmt"
"github.com/google/gapid/core/data/endian"
"github.com/google/gapid/core/math/sint"
"github.com/google/gapid/core/os/device"
)
type rgbaF32 struct {
r, g, b, a float32
}
func rgbaAvg(a, b rgbaF32) rgbaF32 {
return rgbaF32{(a.r + b.r) * 0.5, (a.g + b.g) * 0.5, (a.b + b.b)... | core/image/rgba_f32.go | 0.731155 | 0.424561 | rgba_f32.go | starcoder |
package util
import (
"math"
"reflect"
"sort"
"strconv"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/model"
"k8s.io/component-base/metrics/testutil"
)
// Histogram is a structure that represents distribution of data.
type Histogram struct {
Labels map[string]string `json:"labels... | clusterloader2/pkg/measurement/util/histogram.go | 0.819857 | 0.492127 | histogram.go | starcoder |
package boid
import (
"image/color"
v "github.com/BozeBro/boids/vector"
"github.com/hajimehoshi/ebiten/v2"
)
// Triangle is an image object for the game screen.
// It satisfies the boid interface.
type Triangle struct {
ImageWidth int
ImageHeight int
SightAngle float64
SightDis int ... | boid/triangle.go | 0.655667 | 0.601038 | triangle.go | starcoder |
* The original versions of the files are MIT licensed
*/
package assert
import (
"fmt"
"reflect"
)
// Greater asserts that the first element is greater than the second
func Greater(e1 interface{}, e2 interface{}) (bool, string) {
e1Kind := reflect.ValueOf(e1).Kind()
e2Kind := reflect.ValueOf(e2).Kind()
if e1... | pkg/assert/numberic.go | 0.741861 | 0.463444 | numberic.go | starcoder |
package tree
import (
"fmt"
"strconv"
"strings"
"unsafe"
)
type binTree struct {
root *binTreeNode
}
// GetRoot returns the root node of this trie, which can be nil for a zero-valued uninitialized trie, but not for any other trie
func (tree *binTree) GetRoot() *binTreeNode {
return tree.root
}
// Size return... | tree/bintree.go | 0.78403 | 0.435541 | bintree.go | starcoder |
package quickselect
import (
"container/heap"
"errors"
"fmt"
"math/rand"
)
const (
partitionThreshold = 8
naiveSelectionLengthThreshold = 100
naiveSelectionThreshold = 10
heapSelectionKRatio = 0.001
heapSelectionThreshold = 1e3
)
/*
A type, typically a collection, which sat... | vendor/github.com/wangjohn/quickselect/quickselect.go | 0.691185 | 0.498718 | quickselect.go | starcoder |
For more information,
http://research.neustar.biz/2012/07/09/sketch-of-the-day-k-minimum-values/
MinHashing:
http://infolab.stanford.edu/~ullman/mmds/ch3.pdf
https://en.wikipedia.org/wiki/MinHash
BottomK:
http://www.math.tau.ac.il/~haimk/papers/p225-cohen.pdf
http://cohenwang.org/edith/Pa... | vendor/github.com/dgryski/go-minhash/bottomk.go | 0.817064 | 0.534187 | bottomk.go | starcoder |
package convutil
import (
"fmt"
"strings"
"unicode"
)
type UnitFamily int
const (
GeneralUnits UnitFamily = iota
TemperatureUnits
LengthUnits
SpeedUnits
)
type Unit int
const (
Invalid Unit = iota
AU
Celsius
Fahrenheit
Feet
Kelvin
KilometersPerHour
Lightseconds
Lightminutes
Lightyears
Meters
Met... | convutil/types.go | 0.709321 | 0.545467 | types.go | starcoder |
package dlx
// Matrix returns a the possibility-constraint matrix as a slice of slices.
// The sizes of the matrix need to be provided.
func Matrix(root *Node, rowLen, colLen int) [][]int {
matrix := make([][]int, rowLen)
for i := range matrix {
matrix[i] = make([]int, colLen)
}
c := 0
for col := root.right; ro... | dlx/dlx.go | 0.905885 | 0.65608 | dlx.go | starcoder |
package storage
import (
"unsafe"
"github.com/yohamta/donburi/internal/component"
)
// SimpleStorage is a structure that stores the pointer to data of each component.
// It stores the pointers in the two dimensional slice.
// First dimension is the archetype index.
// Second dimension is the component index.
// Th... | internal/storage/storage.go | 0.575111 | 0.628664 | storage.go | starcoder |
package util
import (
"gotracker/internal/comparison"
"gotracker/internal/song/note"
"github.com/gotracker/voice/period"
)
// AmigaPeriod defines a sampler period that follows the Amiga-style approach of note
// definition. Useful in calculating resampling.
type AmigaPeriod float32
// AddInteger truncates the cu... | internal/format/xm/playback/util/period_amiga.go | 0.888843 | 0.637398 | period_amiga.go | starcoder |
package geometry
import (
"fmt"
"github.com/everystreet/go-geojson/v2"
"github.com/golang/geo/r2"
"github.com/golang/geo/s2"
)
// Project a geographic coordinate to a projected CRS.
type Project func(s2.LatLng) r2.Point
// Marshal returns the encoded sequence of a GeoJSON geometry.
func Marshal(v geojson.Geomet... | internal/geometry/marshal.go | 0.74872 | 0.465995 | marshal.go | starcoder |
package f32
import (
"context"
"log"
"reflect"
)
func init() {
RegisterMatrix(reflect.TypeOf((*CSRMatrix)(nil)).Elem())
}
// CSRMatrix compressed storage by rows (CSR)
type CSRMatrix struct {
r int // number of rows in the sparse matrix
c int // number of columns in the sparse matrix
values [... | f32/csrMatrix.go | 0.764716 | 0.563138 | csrMatrix.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.