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 gomaddness
import "math"
// Hash is the data structure for MADDNESS hash function.
// It holds the learned balanced binary regression tree and the prototype
// vectors.
type Hash[F Float] struct {
TreeLevels []*HashingTreeLevel[F]
Prototypes Vectors[F]
}
// HashingTreeLevel is one level of the binary tree... | hash.go | 0.620852 | 0.533094 | hash.go | starcoder |
package regionagogo
import (
"github.com/akhenakh/regionagogo/geostore"
"github.com/golang/geo/s2"
"github.com/kpawlik/geojson"
)
// Fences a slice of *Fence (type used mainly to return one GeoJSON of the regions)
type Fences []*Fence
// Fence is an s2 represented FenceStorage
// it contains an S2 loop and the as... | fence.go | 0.814459 | 0.400632 | fence.go | starcoder |
package rt90
import "math"
// ToWGS84 transforms RT90 coordinates to WGS84 coordinates.
func ToWGS84(x, y float64) (lat float64, long float64) {
lat, long = gaussKrüger(x, y)
return
}
func gaussKrüger(x, y float64) (float64, float64) {
var axis float64 = 6378137.0
var flattening float64 = 1.0 / 298.257222101
va... | rt90.go | 0.702326 | 0.540439 | rt90.go | starcoder |
package postgres
func args(a ...int) map[int]struct{} {
m := map[int]struct{}{}
for _, arg := range a {
m[arg] = struct{}{}
}
return m
}
var Functions = map[string]map[int]struct{}{
// https://www.postgresql.org/docs/current/functions-math.html
// Table 9.5. Mathematical Functions
"abs": args(1),
... | internal/postgres/funcs.go | 0.590897 | 0.507202 | funcs.go | starcoder |
package collector
import (
"encoding/json"
"fmt"
"github.com/prometheus/client_golang/prometheus"
)
var (
phasesSubsystem = "phases"
phasesLabels = []string{"id", "name"}
phasesStatusLabels = append(phasesLabels, "status_type")
phasesDesc = map[string]*prometheus.Desc{
"watts": colPromDesc... | collector/phases.go | 0.655887 | 0.414958 | phases.go | starcoder |
package main
import (
//"fmt"
"github.com/golang/geo/r2"
"github.com/golang/geo/s2"
"github.com/paulmach/go.geojson"
"math"
)
func computeBounds(g *geojson.Geometry) s2.Rect {
r := s2.EmptyRect()
if g == nil {
return r
}
switch g.Type {
case geojson.GeometryPoint:
if len(g.Point) >= 2 {
r = r.AddPoi... | geometry.go | 0.676406 | 0.572245 | geometry.go | starcoder |
package encoding
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"github.com/lindb/lindb/pkg/stream"
)
// FixedOffsetEncoder represents the offset encoder with fixed length
// Make sure that added offset is increasing
type FixedOffsetEncoder struct {
values []int
max int
ensureIncreasin... | pkg/encoding/fixed_offset.go | 0.734596 | 0.406391 | fixed_offset.go | starcoder |
package plaid
import (
"encoding/json"
"time"
)
// TransferSweep Describes a sweep of funds to / from the sweep account. A sweep is associated with many sweep events (events of type `swept` or `reverse_swept`) which can be retrieved by invoking the `/transfer/event/list` endpoint with the corresponding `sweep_id`... | plaid/model_transfer_sweep.go | 0.757705 | 0.443359 | model_transfer_sweep.go | starcoder |
package iso20022
// Provides the elements related to the interest amount calculation.
type InterestAmount1 struct {
// Indicates whether the interest request is new or updated.
InterestRequestSequence *InterestRequestSequence1Code `xml:"IntrstReqSeq"`
// Period for which the calculation has been performed.
Inter... | InterestAmount1.go | 0.859015 | 0.518424 | InterestAmount1.go | starcoder |
package parser
import "github.com/google/gapid/gapis/gfxapi/gles/glsl/ast"
// This variable contains stub declarations of symbols normally present in a shader, but which
// are not yet fully supported. This allows us to parse programs referencing these symbols, even
// though the later stages (semantic analysis will... | gapis/gfxapi/gles/glsl/parser/shader_symbols.go | 0.519278 | 0.685027 | shader_symbols.go | starcoder |
package design
import "github.com/shogo82148/goa-v1/dslengine"
// Dup creates a copy the given data type.
func Dup(d DataType) DataType {
return newDupper().DupType(d)
}
// DupAtt creates a copy of the given attribute.
func DupAtt(att *AttributeDefinition) *AttributeDefinition {
return newDupper().DupAttribute(att... | design/dup.go | 0.670393 | 0.522933 | dup.go | starcoder |
package models
import (
"reflect"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"xorm.io/builder"
)
// consistencyCheckable a type that can be tested for database consistency
type consistencyCheckable interface {
checkForConsistency(t *testing.T)
}
// CheckConsistencyForAll test that the entire da... | models/consistency.go | 0.611962 | 0.692889 | consistency.go | starcoder |
package writer
import (
"time"
as "github.com/whisperverse/activitystream"
)
type Object map[string]interface{}
func NewObject() Object {
return Object{}
}
// ID provides the globally unique identifier for an Object or Link
func (object Object) ID(value string) Object {
object[as.PropertyID] = value
return ob... | writer/writer.go | 0.8474 | 0.481149 | writer.go | starcoder |
Package spew implements a deep pretty printer for Go data structures to aid in
debugging.
A quick overview of the additional features spew provides over the built-in
printing facilities for Go data types are as follows:
* Pointers are dereferenced and followed
* Circular data structures are detected and handled pro... | spew/doc.go | 0.730001 | 0.713606 | doc.go | starcoder |
package keeper
import (
"fmt"
"math"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
hardtypes "github.com/kava-labs/kava/x/hard/types"
"github.com/kava-labs/kava/x/incentive/types"
)
// AccumulateHardSupplyRewards updates the rewards accumulated for the input reward period
func (k Keeper) AccumulateHardSuppl... | x/incentive/keeper/rewards_supply.go | 0.73659 | 0.46217 | rewards_supply.go | starcoder |
package main
import (
"fmt"
"os"
"specify"
"strings"
t "../src/_test/specify"
)
func HavePassing(expected interface{}) reporterMatcher {
return reporterMatcher{expected, func(r t.ReporterSummary) interface{} { return r.PassingCount() }}
}
func HavePending(expected interface{}) reporterMatcher {
return report... | src/spec_matchers.go | 0.742235 | 0.412589 | spec_matchers.go | starcoder |
package v1
// ImageConfig defines the execution parameters which should be used as a base when running a container using an image.
type ImageConfig struct {
// User defines the username or UID which the process in the container should run as.
User string `json:"User"`
// Memory defines the memory limit.
Memory i... | vendor/github.com/coreos/rkt/vendor/github.com/opencontainers/image-spec/specs-go/v1/config.go | 0.798619 | 0.411939 | config.go | starcoder |
package nune
import (
"errors"
"github.com/vorduin/slices"
)
// Cast casts a Tensor's underlying type to the given numeric type.
func Cast[T Number, V Number](t Tensor[V]) Tensor[T] {
if t.Err != nil {
if EnvConfig.Interactive {
panic(t.Err)
} else {
return Tensor[T]{
Err: t.Err,
}
}
}
data... | manip.go | 0.804713 | 0.596463 | manip.go | starcoder |
package core
import (
"fmt"
"math"
)
// Vector3d is a 3D vector.
type Vector3d struct {
X, Y, Z Float
}
// NewVector3d creates a new vector with specified coordinates.
func NewVector3d(x, y, z Float) *Vector3d {
ret := new(Vector3d)
ret.X = x
ret.Y = y
ret.Z = z
return ret
}
// NewVector3dWithString parses ... | src/core/vector3d.go | 0.822225 | 0.673077 | vector3d.go | starcoder |
package bst
import "errors"
// Node ...
type Node struct {
Begin int
End int
Left *Node
Right *Node
}
// IsOverlap test if any range between begin and end overlap with the node.
// Assume begin >= end
func (n *Node) IsOverlap(begin, end int) bool {
return begin >= n.Begin || end < n.End || (begin <= n.Begin ... | bst/bst.go | 0.72526 | 0.494812 | bst.go | starcoder |
The flow package implements a dataflow mechanism in Go. It was greatly inspired
by <NAME>'s Flow-based Programming (FBP) and <NAME>'s "goflow"
implementation - see also https://en.wikipedia.org/wiki/Flow-based_programming.
The flow library is available as import, along with some supporting packages:
import "githu... | doc.go | 0.817902 | 0.653611 | doc.go | starcoder |
package tda
import (
"math"
"sort"
)
// Landscape supports construction of landscape diagrams for
// describing the persistence homology of an image.
type Landscape struct {
// Birth times
birth []float64
// Death times
death []float64
// Average of birth and death times
bda []float64
// Distinct birth o... | landscape.go | 0.79649 | 0.530236 | landscape.go | starcoder |
package cp
type HashSetEqualArbiter func(ptr []*Shape, elt *Arbiter) bool
type HashSetTransArbiter func(ptr []*Shape, space *Space) *Arbiter
type HashSetIteratorArbiter func(elt *Arbiter)
type HashSetFilterArbiter func(arb *Arbiter, space *Space) bool
type HashSetBinArbiter struct {
elt *Arbiter
hash HashValue
ne... | vendor/github.com/jakecoffman/cp/hashset_arbiter.go | 0.543227 | 0.426262 | hashset_arbiter.go | starcoder |
package internal
import (
"reflect"
"github.com/lyraproj/dgo/dgo"
)
type (
sensitive struct {
value dgo.Value
}
sensitiveType struct {
wrapped dgo.Type
}
)
// DefaultSensitiveType is the unconstrained Sensitive type
var DefaultSensitiveType = &sensitiveType{wrapped: DefaultAnyType}
// SensitiveType retu... | internal/sensitive.go | 0.714628 | 0.410106 | sensitive.go | starcoder |
package gomfa
func Fw2xy(gamb float64, phib float64, psi float64, eps float64,
x *float64, y *float64) {
/*
** - - - - - -
** F w 2 x y
** - - - - - -
**
** CIP X,Y given Fukushima-Williams bias-precession-nutation angles.
**
** Given:
** gamb float64 F-W angle gamma_bar (radians)
... | fw2xy.go | 0.770206 | 0.666877 | fw2xy.go | starcoder |
package orm
import (
"bytes"
"context"
"github.com/goradd/goradd/web/examples/gen/goradd/model"
"github.com/goradd/goradd/web/examples/gen/goradd/model/node"
)
func (ctrl *RefPanel) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error) {
buf.WriteString(`
<h1>References</h1>
<h2>Foreign Keys</h2>
<... | web/examples/tutorial/orm/5-ref.tpl.go | 0.657978 | 0.409693 | 5-ref.tpl.go | starcoder |
package sprite
import (
"math"
"github.com/losinggeneration/hge"
"github.com/losinggeneration/hge/gfx"
"github.com/losinggeneration/hge/helpers/rect"
)
type Sprite struct {
gfx.Quad
TX, TY, W, H float64
TexW, TexH float64
HotX, HotY float64
XFlip, YFlip, HSFlip bool
}
func New(t... | helpers/sprite/sprite.go | 0.59561 | 0.551996 | sprite.go | starcoder |
package slice
// Inserts one or more elements to the end of the slice
func SlicePush(slice *[]interface{}, elementsToAdd ...interface{}) int {
*slice = append(*slice, elementsToAdd...)
return len(*slice)
}
// Removes the last element from an slice and returns that removed element
func SlicePop(slice *[]interface{})... | slice/slice.go | 0.848972 | 0.487307 | slice.go | starcoder |
package tensor
import (
"github.com/pkg/errors"
"gorgonia.org/tensor/internal/storage"
)
// Add performs a + b elementwise. Both a and b must have the same shape.
// Acceptable FuncOpts are: UseUnsafe(), WithReuse(T), WithIncr(T)
func (e StdEng) Add(a Tensor, b Tensor, opts ...FuncOpt) (retVal Tensor, err error) {... | defaultengine_arith.go | 0.561095 | 0.594551 | defaultengine_arith.go | starcoder |
package tree
type Node struct {
key int
left *Node
right *Node
}
func NewNode(value int) *Node {
return &Node{key: value}
}
type BinarySearch struct {
root *Node
}
func NewBinary() *BinarySearch {
return &BinarySearch{}
}
func (b *BinarySearch) Insert(key int) {
var (
newNode = NewNode(key)
)
if b.ro... | tree/binary.go | 0.724578 | 0.404272 | binary.go | starcoder |
package index
import "math"
// normPoint takes the latitude and longitude of one point and return the x,y position on a world map.
// The map bounds are minimum -180,-90 and maximum 180,90. These values are x,y; not lat,lon.
func normPoint(lat, lon float64) (x, y float64, normd bool) {
// Check if the rect is comple... | pkg/index/norm.go | 0.644225 | 0.606819 | norm.go | starcoder |
package rtc
import "math"
// WorldT represents the world to be rendered.
type WorldT struct {
Objects []Object
Lights []*PointLightT // TODO: Replace with light interfaces.
}
// World creates an empty world.
func World() *WorldT {
return &WorldT{}
}
// DefaultWorld returns a default test world.
func DefaultWorl... | rtc/world.go | 0.708717 | 0.598107 | world.go | starcoder |
package parser
import (
"fmt"
"time"
"github.com/ebay/akutan/api"
"github.com/ebay/akutan/rpc"
"github.com/ebay/akutan/util/unicode"
"github.com/vektah/goparsify"
)
func unit(n *goparsify.Result) {
switch t := n.Child[1].Result.(type) {
case *QName:
n.Result = &Unit{Value: t.Value}
case *Entity:
n.Resu... | src/github.com/ebay/akutan/query/parser/lang_callbacks.go | 0.699357 | 0.410697 | lang_callbacks.go | starcoder |
package date
import (
"fmt"
"math"
"time"
"github.com/influxdata/flux"
"github.com/influxdata/flux/codes"
"github.com/influxdata/flux/internal/errors"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux/values"
)
var SpecialFns map[string]values.Function
func init() {
SpecialFns = map[string]... | stdlib/date/date.go | 0.57344 | 0.48438 | date.go | starcoder |
package turfgo
const (
infinity = 0x7FF0000000000000
)
// Unit for distance
type Unit int
// Unit constants
const (
Kilometers Unit = iota
Miles
Meters
Centimeters
Degrees
Radians
NauticalMiles
Inches
Yards
Feet
)
var radius = map[Unit]float64{
Kilometers: 6373,
Miles: 3960,
Meters: ... | types.go | 0.835249 | 0.40869 | types.go | starcoder |
package fbast
type Operator = int8
const (
OperatorMultiplicationOperator Operator = 0
OperatorDivisionOperator Operator = 1
OperatorModuloOperator Operator = 2
OperatorPowerOperator Operator = 3
OperatorAdditionOperator Operator = 4
OperatorSubtractionOperator Opera... | ast/internal/fbast/Operator.go | 0.602646 | 0.525856 | Operator.go | starcoder |
package prime
import (
"bytes"
"crypto/sha256"
"github.com/gogo/protobuf/proto"
"github.com/ibalajiarun/go-consensus/peer/peerpb"
pb "github.com/ibalajiarun/go-consensus/protocols/prime/primepb"
)
type oinstance struct {
s *prime
is pb.OInstanceState
pCert *oquorum
cCert *oquorum
}
func makeOInstance(m *... | protocols/prime/oinstance.go | 0.571527 | 0.403567 | oinstance.go | starcoder |
package matrix
import (
crand "crypto/rand"
"encoding/binary"
"errors"
"math"
"math/rand"
"time"
)
func (m *Matrix) newByFloatArray(vector []float64) {
if len(vector) == 0 {
m.matrix = make([]float64, m.row*m.column)
return
}
vec := make([]float64, len(vector))
copy(vec, vector)
m.matrix = vec
if err ... | create.go | 0.544317 | 0.527925 | create.go | starcoder |
package electreIII
import (
"fmt"
"github.com/Azbesciak/RealDecisionMaker/lib/utils"
)
var DefaultDistillationFunc = utils.LinearFunctionParameters{A: -.15, B: .3}
type CompareFunction = func(old int, new int) bool
func RankAscending(matrix *AlternativesMatrix, distillationFun *utils.LinearFunctionParameters) *[]... | lib/logic/preference-func/electreIII/distilation.go | 0.671471 | 0.442396 | distilation.go | starcoder |
package primitives
import (
"github.com/zimmski/tavor/token"
)
// Scope implements a general scope token which references a token
type Scope struct {
token token.Token
}
// NewScope returns a new instance of a Scope token
func NewScope(tok token.Token) *Scope {
return &Scope{
token: tok,
}
}
// Token interfac... | token/primitives/scope.go | 0.852245 | 0.458046 | scope.go | starcoder |
package graph
import "errors"
type Node struct {
Key string
Data interface{}
}
type edge struct {
Dest *Node
Cost int
}
type value struct {
start *Node
edges []edge
}
// DirectedGraph represents a directed graph as an adjacency list.
type DirectedGraph struct {
adjList map[string]value
}
// NewDirectedGra... | internal/graph/graph.go | 0.753829 | 0.466238 | graph.go | starcoder |
package game
import "math/rand"
// Point point of a shape
type Point struct {
row int
col int
}
// Shape shape of a piece consisting of 4 points
type Shape [4]Point
// PieceType type of a Tetris piece
type PieceType int
// Different piece types
const (
IType PieceType = iota
JType
LType
OType
SType
TType
... | pkg/game/piece.go | 0.687525 | 0.657318 | piece.go | starcoder |
package glm
import (
"sort"
"gonum.org/v1/gonum/optimize"
"gonum.org/v1/gonum/stat/distuv"
)
// ScaleProfiler is used to do likelihood profile analysis on the scale
// parameter. Set the Results field to a fitted GLMResults value.
// This is suitable for models with no additional parameters, if there
// are othe... | glm/profile.go | 0.812198 | 0.46223 | profile.go | starcoder |
package engine
import "errors"
type graph struct {
// names contains the keys of the "edges" field.
// It allows the vertices to be sorted.
// It makes the structure deterministic.
names []string
// vertices ordered by name.
vertices map[string]*graphVertex
}
// graphVertex contains the vertex data.
type graph... | vendor/github.com/puper/ppgo/v2/engine/graph.go | 0.736116 | 0.545467 | graph.go | starcoder |
package lex
import (
"fmt"
"github.com/goki/ki/nptime"
"github.com/goki/pi/token"
)
// Lex represents a single lexical element, with a token, and start and end rune positions
// within a line of a file. Critically it also contains the nesting depth computed from
// all the parens, brackets, braces. Todo: also ... | lex/lex.go | 0.773216 | 0.413359 | lex.go | starcoder |
package reactor
import (
"fmt"
"math"
"strconv"
"strings"
"time"
)
// QuantumFraction applies a quantum fraction to a rate given in minutes.
func QuantumFraction(rate float64, quantum time.Duration) float64 {
return rate * (float64(quantum) / float64(time.Minute))
}
// Thresholds returns a new serverity provid... | pkg/reactor/util.go | 0.842345 | 0.614076 | util.go | starcoder |
package spec
import (
"fmt"
. "github.com/sdboyer/gocheck"
. "github.com/sdboyer/gogl"
)
/* DataGraphSuite - tests for data graphs */
type DataGraphSuite struct {
Factory func(GraphSource) DataGraph
}
func (s *DataGraphSuite) SuiteLabel() string {
return fmt.Sprintf("%T", s.Factory(NullGraph))
}
func (s *Dat... | spec/suite_data.go | 0.662469 | 0.401805 | suite_data.go | starcoder |
package avatar
import (
"crypto/sha1"
"errors"
"image"
"image/color"
"strings"
)
const nblock = 5
// DefaultBG is the default image background color.
var DefaultBG = color.NRGBA{0xed, 0xed, 0xed, 0xff}
// Avatar defines the properties to make an avatar image.
type Avatar struct {
// Case insensitive text
Tex... | avatar/avatar.go | 0.720368 | 0.44571 | avatar.go | starcoder |
package spec
// Schema The Schema Object allows the definition of input and output data types.
// These types can be objects, but also primitives and arrays.
// This object is an extended subset of the JSON Schema Specification Wright Draft 00.
// For more information about the properties, see JSON Schema Core and JSO... | internal/oapi/spec/schema.go | 0.841793 | 0.472014 | schema.go | starcoder |
package matrix
import (
"fmt"
"log"
"math"
"math/rand"
"time"
)
//Matrix type does matrix math
type Matrix struct {
slice [][]float64
}
//NewMatrix returns a matrix and an error
func NewMatrix(slice [][]float64) Matrix {
rows := sliceRows(slice)
columns := sliceColumns(slice)
if columns... | matrix.go | 0.777258 | 0.484014 | matrix.go | starcoder |
package matrix
import (
"fmt"
)
func rowsToColumns(x int) int {
out := x / 8
if x%8 != 0 {
out++
}
return out
}
// Matrix is a logical, or (0, 1)-matrix
type Matrix []Row
// Mul right-multiplies a matrix by a row.
func (e Matrix) Mul(f Row) Row {
out, in := e.Size()
if in != f.Size() {
panic("Can't mult... | matrix/matrix.go | 0.859295 | 0.452596 | matrix.go | starcoder |
// Interrupter encoder driver.
package hand
import (
"log"
)
// GetStep provides a method to read the absolute location of the stepper motor.
type GetStep interface {
GetStep() int64
}
// Syncer provides an interface for a callback when the encoder mark is hit.
// The measured steps in a revolution is provided.
... | hand/encoder.go | 0.664758 | 0.533397 | encoder.go | starcoder |
package influxql
import (
"bytes"
"container/heap"
"fmt"
"math"
"sort"
)
/*
This file contains iterator implementations for each function call available
in InfluxQL. Call iterators are separated into two groups:
1. Map/reduce-style iterators - these are passed to IteratorCreator so that
processing can be at ... | vendor/github.com/influxdata/influxdb/influxql/call_iterator.go | 0.712132 | 0.421016 | call_iterator.go | starcoder |
package main
import (
"bytes"
"fmt"
)
const wordLength int = 32 << (^uint(0) >> 63)
// PopCount returns the population count using the "shift off rightmost set bit and check" method
func PopCount(x uint) int {
var result uint
for x&(x-1) != x {
result++
x = x & (x - 1)
}
return int(result)
}
// An IntSet ... | ch6/intset/main.go | 0.68056 | 0.439807 | main.go | starcoder |
package schemes
import "image/color"
// OMG is a gradient color scheme from purple through red to white.
var OMG []color.Color
func init() {
OMG = []color.Color{
color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff},
color.RGBA{R: 0xff, G: 0xfe, B: 0xfe, A: 0xff},
color.RGBA{R: 0xff, G: 0xfd, B: 0xfd, A: 0xff},
co... | schemes/omg.go | 0.540196 | 0.690918 | omg.go | starcoder |
package repairdroid
import (
"fmt"
"math"
"time"
"github.com/chr-ras/advent-of-code-2019/util/geometry"
"github.com/chr-ras/advent-of-code-2019/util/intcode"
q "github.com/enriquebris/goconcurrentqueue"
"github.com/gosuri/uilive"
)
// FindShortestWayToOxygenTank controls the repair droid to explore the ship a... | 15-oxygen-system/repairdroid/repairdroid.go | 0.754644 | 0.539469 | repairdroid.go | starcoder |
package dynamodb
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/guregu/dynamo"
)
type (
// Scan : Request to scan all the data in a table.
Scan interface {
// StartFrom : Makes this scan continue from a previous one.
StartFrom(key dynamo.PagingKey) Scan
// Index : Specifies the name of the index that ... | scan.go | 0.761982 | 0.422028 | scan.go | starcoder |
package kcp
import (
"crypto/aes"
"crypto/cipher"
"crypto/des"
"crypto/sha1"
"github.com/templexxx/xor"
"golang.org/x/crypto/blowfish"
"golang.org/x/crypto/cast5"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/salsa20"
"golang.org/x/crypto/tea"
"golang.org/x/crypto/twofish"
"golang.org/x/crypto/xtea"
... | vendor/github.com/xtaci/kcp-go/crypt.go | 0.752922 | 0.403449 | crypt.go | starcoder |
package aoc2019
import (
"io"
"io/ioutil"
"math"
"os"
"sort"
"github.com/pkg/errors"
)
type day10MonitorGrid struct {
asteroidMap []byte
width int
}
func (d day10MonitorGrid) asteroidCount() int {
var count int
for _, c := range d.asteroidMap {
if c == '#' {
count++
}
}
return count
}
fun... | day10.go | 0.711431 | 0.495239 | day10.go | starcoder |
package compilergraph
import (
"fmt"
"github.com/cayleygraph/cayley/quad"
)
// Cayley type mappings:
// GraphNodeId <-> quad.Raw
// Predicate <-> quad.IRI
// TaggedValue <-> quad.Raw
// Other values <-> quad.Value
// nodeIdToValue returns a Cayley value for a Graph Node ID.
func nodeIdToValue(nodeId Grap... | compilergraph/quad.go | 0.85931 | 0.464719 | quad.go | starcoder |
package voltage
import . "github.com/deinspanjer/units/unit"
// Voltage represents a unit of voltage (in volt, V)
type Voltage Unit
// ...
const (
// SI
Yoctovolt = Volt * 1e-24
Zeptovolt = Volt * 1e-21
Attovolt = Volt * 1e-18
Femtovolt = Volt * 1e-15
Picovolt = Volt *... | voltage/voltage.go | 0.85183 | 0.637257 | voltage.go | starcoder |
package metric
import (
"math/rand"
"time"
)
const (
cosineMetricsMaxIteration = 200
cosineMetricsMaxTargetSample = 100
cosineMetricsTwoMeansThreshold = 0.7
cosineMetricsCentroidCalcRatio = 0.0001
)
func init() {
rand.Seed(time.Now().UnixNano())
}
type cosineDistance struct {
dim int
}
// NewCosineM... | metric/cosine.go | 0.793506 | 0.434221 | cosine.go | starcoder |
package quantile
import (
"math/rand"
)
/*
"Space-Efficient Online Computation of Quantile Summaries" (<NAME> 2001)
http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf
This implementation is backed by a skiplist to make inserting elements into the
summary faster. Querying is still O(n).
*/
//... | quantile/summary.go | 0.752013 | 0.459137 | summary.go | starcoder |
package set
import "sort"
// The Op type can be used to represent any of the mutating functions, such
// as Inter.
type Op func(data sort.Interface, pivot int) (size int)
// Uniq swaps away duplicate elements in data, returning the size of the
// unique set. data is expected to be pre-sorted, and the resulting set ... | vendor/github.com/xtgo/set/mutators.go | 0.737631 | 0.545346 | mutators.go | starcoder |
package oddsengine
// Unit represents a specific unit within a game, identifing a lot of specific
// information related to the unit.
type Unit struct {
Alias string
Name string
Cost int
Attack int
Defend int
IsShip bool
IsAAA bool
IsS... | units.go | 0.671363 | 0.617369 | units.go | starcoder |
package deep
import (
"fmt"
"unsafe"
"github.com/dhairyyas/leabra-sleepmod/leabra"
)
// deep.Neuron holds the extra neuron (unit) level variables for DeepLeabra computation.
// DeepLeabra includes both attentional and predictive learning functions of the deep layers
// and thalamocortical circuitry.
// These are... | deep/neuron.go | 0.758958 | 0.68305 | neuron.go | starcoder |
package margaid
import (
"fmt"
"io"
"math"
"github.com/erkkah/margaid/brackets"
"github.com/erkkah/margaid/svg"
)
// Margaid == diagraM
type Margaid struct {
g *svg.SVG
width float64
height float64
inset float64
padding float64 // padding [0..1]
projections map[Axis]Projection
ranges map[Axis... | margaid.go | 0.762689 | 0.420719 | margaid.go | starcoder |
package graph
import (
"errors"
"reflect"
"sort"
"strconv"
)
// VerSet represents a set of vertices.
type VerSet map[Vertex]struct{}
// NewVerSet constructs a new VerSet.
func NewVerSet() VerSet {
return make(VerSet, 0)
}
// Contains checks whether an `v` exists in `s` or not.
func (s VerSet) Contains(v Vertex... | graph/undirect.go | 0.832645 | 0.460228 | undirect.go | starcoder |
package graphics
import (
"github.com/inkyblackness/shocked-client/opengl"
)
// BitmapTexture contains a bitmap stored as OpenGL texture.
type BitmapTexture struct {
gl opengl.OpenGl
width, height float32
u, v float32
handle uint32
}
// BitmapRetriever is a thunk that retrieves a cached bitmap.... | src/github.com/inkyblackness/shocked-client/graphics/BitmapTexture.go | 0.860516 | 0.570989 | BitmapTexture.go | starcoder |
package math
import (
stdmath "math"
)
// Pow raises a to the power of b (a^b).
// If a and b are both (unsigned-)integers, then returns an int. Otherwise, returns a float64.
// Supports types uint8, int32, int64, int, and float64.
func Pow(a interface{}, b interface{}) (out interface{}, err error) {
// Catch an... | pkg/math/Pow.go | 0.708213 | 0.66124 | Pow.go | starcoder |
package graphics
import "image/color"
import "github.com/banthar/Go-SDL/sdl"
// A Primitive is a basic shape which can be drawn directly by the artist.
type Primitive interface {
draw(s *sdl.Surface)
}
// A Point is as it sounds, a single point in space.
type Point struct {
x, y int
c color.Color
}
// Points ... | graphics/primitive.go | 0.708515 | 0.442094 | primitive.go | starcoder |
package core
import (
"database/sql/driver"
"fmt"
"strconv"
"time"
)
type DateType struct {
int64
}
func (tt DateType) String() string {
return fmt.Sprintf("%v", tt.int64)
}
func NewDateType(year, month, day int) DateType {
return DateType{
time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.Local).Un... | core/dateType.go | 0.544075 | 0.426023 | dateType.go | starcoder |
package array
/* -------------------------------------------------------------------------------- */
// -- Metadata: attributes that every array must carry.
/* -------------------------------------------------------------------------------- */
// Metadata contains information that must accompany an array, but not the... | metadata.go | 0.76207 | 0.42483 | metadata.go | starcoder |
package main
import (
"fmt"
"strings"
"github.com/fatih/color"
)
// 2d Direction vectors
var (
North = Point{X: 0, Y: -1}
South = Point{X: 0, Y: 1}
East = Point{X: 1, Y: 0}
West = Point{X: -1, Y: 0}
Up = North
Down = South
Left = West
Right = East
)
// Point represents a point (or vector) in 2d sp... | 2019/grid.go | 0.758779 | 0.497742 | grid.go | starcoder |
package interval
// U64Span is the base interval type understood by the algorithms in this package.
// It is a half open interval that includes the lower bound, but not the upper.
type U64Span struct {
Start uint64 // the value at which the interval begins
End uint64 // the next value not included in the interval... | core/math/interval/u64.go | 0.749546 | 0.561275 | u64.go | starcoder |
package synthetics
import (
"encoding/json"
"time"
)
// V202101beta1MeshMetrics struct for V202101beta1MeshMetrics
type V202101beta1MeshMetrics struct {
Time *time.Time `json:"time,omitempty"`
Latency *V202101beta1MeshMetric `json:"latency,omitempty"`
PacketLoss *V202101beta1MeshMetric `js... | kentikapi/synthetics/model_v202101beta1_mesh_metrics.go | 0.798226 | 0.436442 | model_v202101beta1_mesh_metrics.go | starcoder |
package eval
import (
"github.com/dito/src/ast"
"github.com/dito/src/object"
"math/rand"
"time"
)
func init() {
// need random number generator for builtin function rand.
rand.Seed(time.Now().UTC().UnixNano())
}
// Eval :
func Eval(node ast.Node, env *object.Environment) object.Object {
switch node := node.(t... | src/eval/exec.go | 0.576304 | 0.441312 | exec.go | starcoder |
package prestgo
const (
// This type captures boolean values true and false
Boolean = "boolean"
// A 64-bit signed two’s complement integer with a minimum value of -2^63 and a maximum value of 2^63 - 1.
BigInt = "bigint"
// Integer assumed to be an alias for BigInt.
Integer = "integer"
// A double is a 64-bi... | types.go | 0.840259 | 0.407746 | types.go | starcoder |
package counter
import (
"encoding/json"
"sort"
"github.com/marcsantiago/collections"
)
type DataMap map[collections.Data]int
// NewDataMap takes in hash data, counts, and returns a concrete type that implements a CounterMap
func NewDataMap(hash map[collections.Data]int) DataMap {
var nh DataMap
if hash != nil... | counter/data_map.go | 0.755997 | 0.476884 | data_map.go | starcoder |
package runtime
// RawEqual returns two values. The second one is true if raw equality makes
// sense for x and y. The first one returns whether x and y are raw equal.
func RawEqual(x, y Value) (bool, bool) {
if x.Equals(y) {
return true, true
}
switch x.NumberType() {
case IntType:
if fy, ok := y.TryFloat()... | runtime/comp.go | 0.696887 | 0.67254 | comp.go | starcoder |
package tokens
import (
"encoding/json"
"fmt"
"strconv"
alaTypes "github.com/onmax/go-alastria/types"
)
// Checks if list contains the given string
func stringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
}
var emptyPayloadField = "the value ... | tokens/utils.go | 0.639286 | 0.419588 | utils.go | starcoder |
package abi
import (
"math/big"
"reflect"
"github.com/ethereum/go-ethereum/common"
)
var big_t = reflect.TypeOf(&big.Int{})
var ubig_t = reflect.TypeOf(&big.Int{})
var byte_t = reflect.TypeOf(byte(0))
var byte_ts = reflect.TypeOf([]byte(nil))
var uint_t = reflect.TypeOf(uint(0))
var uint8_t = reflect.TypeOf(uint8... | accounts/abi/numbers.go | 0.582135 | 0.422326 | numbers.go | starcoder |
package ztype
import (
"math/bits"
zserio "github.com/woven-planet/go-zserio"
)
const (
maxBitNumberBits = 6
maxBitNumberLimit = 62
)
// DeltaContext is a packing context used when writing data using delta
// packing, i.e. instead of storing all values, only stores the deltas.
type DeltaContext[T any] struct {... | ztype/delta_context.go | 0.687 | 0.52476 | delta_context.go | starcoder |
package distance_calculator
import (
"math"
)
const (
// Unit in Meter
UnitMeter = "METER"
// Unit in Mile
UnitMile = "MILE"
// Unit in Kilometer
UnitKilometer = "KILOMETER"
// Unit in Nautical
UnitNauticalMile = "NAUTICAL_MILE"
)
type Coordinate struct {
Latitude float64
Longitude float64
}
// deg2r... | calculator.go | 0.874734 | 0.792464 | calculator.go | starcoder |
package timekit
import (
"time"
)
// FirstDayOfLastYear returns first date (with 0:00 hour) from last calendar year.
func FirstDayOfLastYear(now func() time.Time) time.Time {
dt := now()
return time.Date(dt.Year()-1, 1, 1, 0, 0, 0, 0, dt.Location())
}
// FirstDayOfThisYear returns the date (with 0:00 hour) from t... | timekit.go | 0.788543 | 0.668833 | timekit.go | starcoder |
package level
const (
// ObjectCrossReferenceEntrySize describes the size, in bytes, of a ObjectCrossReferenceEntry.
ObjectCrossReferenceEntrySize = 10
defaultObjectCrossReferenceEntryCount = 1600
)
func offMapReferencePosition() TilePosition {
return TilePosition{X: 0xFF, Y: 0}
}
// ObjectCrossReferenceEntry l... | ss1/content/archive/level/ObjectCrossReferenceTable.go | 0.76882 | 0.47859 | ObjectCrossReferenceTable.go | starcoder |
package jsonschema
import (
"reflect"
)
// File named in respect to https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.7
var andAnyOfType = reflect.TypeOf((*andAnyOf)(nil)).Elem()
var anyOfType = reflect.TypeOf((*anyOf)(nil)).Elem()
var andOneOfType = reflect.TypeOf((*andOneOf)(nil)).Elem()
var... | subschemas_boolean.go | 0.664649 | 0.522629 | subschemas_boolean.go | starcoder |
package bcns
import (
"unsafe"
)
type fftCtx struct {
x1 [64][64]uint32
y1 [64][64]uint32
z1 [64][64]uint32
t1 [64]uint32
}
// Reduction modulo p = 2^32 - 1.
// This is not a prime since 2^32-1 = (2^1+1)*(2^2+1)*(2^4+1)*(2^8+1)*(2^16+1).
// But since 2 is a unit in Z/pZ we can use it for computing FFTs in
// Z... | fft.go | 0.601945 | 0.593433 | fft.go | starcoder |
package sorts
import (
"math/bits"
"sort"
)
// Just some useful utility functions. Most of them
// wind up being inlined.
func lte(s sort.Interface, a, b int) bool {
return !s.Less(b, a)
}
func log2(s uint64) int {
return 64 - bits.LeadingZeros64(s) - 1
}
func median(a, b int) int {
return int(uint(a+b) >> 1)
... | utils.go | 0.692746 | 0.41117 | utils.go | starcoder |
package listsandstrings
import (
"fmt"
"math/rand"
"time"
)
// Implement the following sorting algorithms:
// Selection sort,
// Insertion sort,
// Merge sort,
// Quick sort,
// Stooge Sort.
// Check Wikipedia for descriptions.
func exercise17() {
size := 30000
slice := makeRandIntSlice(size)
fmt.Println("... | listsandstrings/exercise17sorting.go | 0.554712 | 0.452657 | exercise17sorting.go | starcoder |
package types
import (
"fmt"
"strings"
)
// guardState is used to ensure the DelayLine's low-level Read and Write
// functions are used correctly
type guardState bool
const (
readyToRead guardState = false
readyToWrite guardState = true
)
// DelayLine represents a circular buffer that can be used to delay a si... | types/delay_line.go | 0.551332 | 0.414069 | delay_line.go | starcoder |
package snapio
/* This file handles codes related to the generic Buffer object. Much of this
code is just type switches. It'll be obsolete if Guppy is ever ported to Go 2.
After writing and testing this, I realized that the code can be made much
simpler if Buffer just has an array of interface{} values instead of dif... | lib/snapio/buffer.go | 0.609408 | 0.433262 | buffer.go | starcoder |
package buffer
import (
"math"
xmath2 "github.com/drakos74/go-ex-machina/xmath"
)
// Ring acts like a ring buffer keeping the last x elements
type Ring struct {
index int
count int
values []float64
}
// Size returns the number of non-nil elements within the ring.
func (r *Ring) Size() int {
if r.count == r.... | xmath/buffer/ring.go | 0.862163 | 0.617599 | ring.go | starcoder |
package ui
import (
"image"
"math/rand"
"time"
"gioui.org/io/event"
"gioui.org/io/key"
"gioui.org/layout"
"gioui.org/op"
)
type blockID uint8
const (
I blockID = iota
J
L
O
S
T
Z
)
type blockRotation uint8
// clockwise block rotations.
const (
block0 blockRotation = iota
block90
block180
block27... | blocks/internal/ui/block.go | 0.636918 | 0.446495 | block.go | starcoder |
package hex
var HexByteToString = [256]string{
0: `00`,
1: `01`,
2: `02`,
3: `03`,
4: `04`,
5: `05`,
6: `06`,
7: `07`,
8: `08`,
9: `09`,
10: `0a`,
11: `0b`,
12: `0c`,
13: `0d`,
14: `0e`,
15: `0f`,
16: `10`,
17: `11`,
18: `12`,
19: `13`,
20: `14`,
21: `15`,
22: `1... | pkg/reader/byteFormatters/hex/hex_lookup.go | 0.635788 | 0.557243 | hex_lookup.go | starcoder |
package gofun
// Unzippable is the interface for unzipping.
type Unzippable interface {
// Unzip creates two Zippables where two elements from two Zippables are
// contained the pair from Unzippable. Fail must be a failure Zippable.
Unzip(fail Zippable) (Zippable, Zippable)
}
// UnzippableOrElse returns x... | unzippable.go | 0.677261 | 0.454533 | unzippable.go | starcoder |
package steganography
import (
"bytes"
"errors"
"fmt"
"github.com/stegoer/server/gqlgen"
"github.com/stegoer/server/pkg/util"
)
const (
metadataLength = 13
metadataBinaryLength = metadataLength * util.BitLength
metadataPixelOffset = 0
metadataLsbPos by... | pkg/steganography/metadata.go | 0.81468 | 0.40031 | metadata.go | starcoder |
package object
import (
"math"
"github.com/carlosroman/aun-otra-ray-tracer/go/internal/ray"
)
type cylinder struct {
obj
minimum, maximum float64
closed bool
}
func checkCap(r ray.Ray, t float64) bool {
x := r.Origin().GetX() + t*r.Direction().GetX()
z := r.Origin().GetZ() + t*r.Direction().GetZ()
... | go/internal/object/cylinder.go | 0.833019 | 0.432483 | cylinder.go | starcoder |
package ermahgerd
import (
"fmt"
"regexp"
"strings"
)
const beginNotWords string = `^\W+`
const endNotWords string = `\W+$`
/*
To replace substrings matched with the provided regular expression with another substring
*/
func replace(regex, replaceWith string, s *string) {
r := regexp.MustCompile(... | ermahgerd.go | 0.723016 | 0.401629 | ermahgerd.go | starcoder |
package main
import (
"bufio"
"errors"
"log"
"strings"
"time"
)
// measure defines the information needed to analyse the data passed
// to the reader.
type measure struct {
start string // defines the start of the task to measure
end string // defines the end of the ... | measure.go | 0.660063 | 0.463262 | measure.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.