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 models
import (
"../../common"
"fmt"
"strconv"
)
type Company struct {
id int `json:id`
name string `json:name`
street string `json:street`
city string `json:city`
state string `json:state`
country ... | jmserver/src/classes/jmserver/models/Company.go | 0.54359 | 0.540196 | Company.go | starcoder |
package x32
import (
"math"
"github.com/golang/glog"
)
// x32LogToHz returns the frquency in Hz which coresponds to the 0..1 float
// value sent by the X32 when the Eq Frequency knob is turned.
func x32EqFreqLogToHz(f float32) float32 {
if f < 0 {
f = 0
} else if f > 1 {
f = 1
}
// =EXP(2.9957322738+A1*6.9... | maths.go | 0.785514 | 0.606935 | maths.go | starcoder |
package heap
import (
"fmt"
"strings"
)
type Heap struct {
data []int
}
// Init initializes the heap with the given data.
func (h *Heap) Init(data []int) {
h.data = data
for i := len(data) / 2; i >= 0; i-- {
h.down(i)
}
}
// New returns a new heap with the given data.
func New(data []int) *Heap {
h := new(... | data-structures/linear/heap/heap.go | 0.804175 | 0.473901 | heap.go | starcoder |
package services
import (
"os"
)
// GENERICS TOOD: When Go has generics, parameterize this to be <N, S extends N> where S is the
// specific service interface and N represents the interface that every node on the network has
/*
Tells Kurtosis how to create a Docker container representing a user-defined service in t... | lib/services/service_initializer_core.go | 0.732783 | 0.507873 | service_initializer_core.go | starcoder |
package iso20022
// Valuation information of the portfolio.
type TotalPortfolioValuation1 struct {
// Total value of the portfolio (sum of the assets, liabilities and unrealised gain/loss) calculated according to the accounting rules.
TotalPortfolioValue *AmountAndDirection30 `xml:"TtlPrtflVal"`
// Previous total... | TotalPortfolioValuation1.go | 0.754192 | 0.600364 | TotalPortfolioValuation1.go | starcoder |
package circle
import (
"github.com/gravestench/pho/geom/point"
"github.com/gravestench/pho/geom/rectangle"
)
type CircleNamespace interface {
New(x, y, radius float64) *Circle
Clone(c *Circle) *Circle
Contains(c *Circle, x, y float64) bool
ContainsPoint(c *Circle, p *point.Point) bool
ContainsRectangle(c *Cir... | geom/circle/namespace.go | 0.92853 | 0.612049 | namespace.go | starcoder |
package main
import (
"fmt"
"math"
)
func leftmostDigit(n int) int {
for n >= 10 {
n = n / 10
}
return n
}
func numDigits(n int) int {
var count int = 0
for n > 0 {
n = n / 10
count = count + 1
}
return count
}
// assumes leftDigit and E are valid constraints for producing a sequential number, per v... | puzzles/sequential-digits/sequential-digits.go | 0.819785 | 0.463748 | sequential-digits.go | starcoder |
package godis
import (
"fmt"
"math"
"strconv"
)
//BoolToByteArr convert bool to byte array
func BoolToByteArr(a bool) []byte {
if a {
return bytesTrue
}
return bytesFalse
}
//IntToByteArr convert int to byte array
func IntToByteArr(a int) []byte {
buf := make([]byte, 0)
return strconv.AppendInt(buf, int64(... | convert_util.go | 0.550849 | 0.562958 | convert_util.go | starcoder |
package geodist
import (
"fmt"
"math"
)
// WGS-84 ellipsoid
const (
a float64 = 6378137
f float64 = 1 / 298.257223563
b float64 = 6356752.314245
)
const (
epsilon = 1e-12
maxIterations = 200
)
// VincentyDistance returns the geographical distance in km between the points p1 and p2 using Vincenty's inve... | vincenty.go | 0.824921 | 0.527803 | vincenty.go | starcoder |
package lcd
// Value is a uint that can be converted into a string representation
type Value uint
// Dimension defines the width and height of each digit as it's printed
type Dimension interface {
Width() uint
Height() uint
}
type dimension struct {
width uint
height uint
}
func (d dimension) Width() uint {
r... | go/lcd/lcd.go | 0.779112 | 0.620708 | lcd.go | starcoder |
package elf_code
import (
"errors"
"strconv"
"strings"
)
type OpCode int
const (
AddR OpCode = iota // `addr` (add register) stores into register `C` the result of adding register `A` and register `B`.
AddI // `addi` (add immediate) stores into register `C` the result of adding register `A` and va... | lib/elf_code/OpCodes.go | 0.731538 | 0.636381 | OpCodes.go | starcoder |
package testdata
// GetPaymentLink response sample.
const GetPaymentLinkResponse = `{
"resource": "payment-link",
"id": "pl_4Y0eZitmBnQ6IDoMqZQKh",
"mode": "test",
"profileId": "pfl_QkEhN94Ba",
"createdAt": "2021-03-20T09:13:37+00:00",
"paidAt": "2021-03-21T09:13:37+00:00",
"updatedAt": "20... | testdata/payment_links.go | 0.783947 | 0.482124 | payment_links.go | starcoder |
package core
import (
"fmt"
"time"
"github.com/Sirupsen/logrus"
"github.com/demizer/go-humanize"
)
// Maximum number of points used to calculate the average
var windowSize = 10
// ProgressPoint is a progress point containing bytes written in the last second added to the bps tracker.
type ProgressPoint struct {
... | src/core/bps.go | 0.668015 | 0.554169 | bps.go | starcoder |
package itype
import "sort"
// Recti is a 2D rectangle with int coordinates.
type Recti struct {
Left, Top int
Width, Height int
}
// Rectf is a 2D rectangle with float32 coordinates.
type Rectf struct {
Left, Top float32
Width, Height float32
}
func (r Rectf) MinPoint() Vec2f {
return Vec2f{r.Left, r.... | itype/rect.go | 0.827584 | 0.66769 | rect.go | starcoder |
package rect
import (
"math"
"sort"
"strings"
disc "github.com/briannoyama/bvh/discreet"
)
// A Bounding Volume for orthotopes. Wraps the orthotope and contains descendents.
type BVol struct {
vol *Orthotope
desc [2]*BVol
depth int32
}
func (bvol *BVol) minBound() {
if bvol.depth > 0 {
bvol.vol.MinBoun... | rect/bvh.go | 0.682468 | 0.431045 | bvh.go | starcoder |
package v2
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/client-v1"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid"
)
// NetworkList Encapsulates information about each network list.
type NetworkList struct {
// Name of this network list... | list.go | 0.783326 | 0.50769 | list.go | starcoder |
package go_
func IsDefaultValue(a interface{}) bool {
switch a.(type) {
case int:
return a.(int) == 0
case int8:
return a.(int8) == 0
case int16:
return a.(int16) == 0
case int32:
return a.(int32) == 0
case int64:
return a.(int64) == 0
case []int:
return len(a.([]int)) == 0
case []int8:
return le... | funcs.go | 0.509032 | 0.522811 | funcs.go | starcoder |
package memio
import (
"errors"
"io"
)
// ReadWriteMem is a combination of both the ReadMem and WriteMem types,
// allowing both all reads and writes to the same underlying byte slice.
type ReadWriteMem struct {
WriteMem
}
// OpenMem uses a byte slice for reading and writing. Implements io.Reader,
// io.Writer, i... | readwrite.go | 0.621426 | 0.466359 | readwrite.go | starcoder |
package core
import (
"git.maze.io/go/math32"
)
type Camera struct {
Width uint32
Height uint32
Aspect float32
DX float32
DY float32
Origin Vector3
Forward Vector3
Right Vector3
Up Vector3
LensRadius float32
}
func (camera *Camera) LookAt(eye, at, up Vector3) {
forward := NormalizeVecto... | core/camera.go | 0.815857 | 0.641296 | camera.go | starcoder |
package manifold
import (
"encoding/json"
"strings"
"github.com/manifoldco/go-manifold/number"
"github.com/pkg/errors"
)
// FeatureMap stores the selected feature values for a Manifold resource
type FeatureMap map[string]interface{}
// Equals checks the equality of another FeatureMap against this one
func (f Fe... | types.go | 0.793106 | 0.406509 | types.go | starcoder |
Package xdr implements the data representation portion of the External Data
Representation (XDR) standard protocol as specified in RFC 4506 (obsoletes
RFC 1832 and RFC 1014).
The XDR RFC defines both a data specification language and a data
representation standard. This package implements methods to encode and d... | vendor/github.com/elastic/beats/metricbeat/module/kvm/vendor/github.com/davecgh/go-xdr/xdr2/doc.go | 0.842248 | 0.847968 | doc.go | starcoder |
package ElementaryCyclesSearch
/**
* Searches all elementary cycles in a given directed graph. The implementation
* is independent from the concrete objects that represent the graphnodes, it
* just needs an array of the objects representing the nodes of the graph
* and an adjacency-matrix of type boolean, represen... | ElementaryCyclesSearch.go | 0.802207 | 0.725989 | ElementaryCyclesSearch.go | starcoder |
package bytesutil
import (
"bytes"
"fmt"
"sort"
)
// Sort sorts a slice of byte slices.
func Sort(a [][]byte) {
sort.Sort(byteSlices(a))
}
func IsSorted(a [][]byte) bool {
return sort.IsSorted(byteSlices(a))
}
func SearchBytes(a [][]byte, x []byte) int {
return sort.Search(len(a), func(i int) bool { return by... | vendor/github.com/influxdata/influxdb/pkg/bytesutil/bytesutil.go | 0.775265 | 0.593786 | bytesutil.go | starcoder |
package _841_Keys_and_Rooms
/*https://leetcode.com/problems/keys-and-rooms/
There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room.
Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an int... | 841_Keys_and_Rooms/solution.go | 0.802788 | 0.514766 | solution.go | starcoder |
package discrete
// lnFunc log function type
type lnFunc func(float64) float64
// Create2D creates a 2-dimensional slice
func Create2D(xDim, yDim int) [][]float64 {
r := make([][]float64, xDim)
for x := 0; x < xDim; x++ {
r[x] = make([]float64, yDim)
}
return r
}
// Create2DInt creates a 2-dimensional slice
fu... | discrete/defs.go | 0.641198 | 0.688292 | defs.go | starcoder |
package ln
import "math"
type Cone struct {
Radius float64
Height float64
}
func NewCone(radius, height float64) *Cone {
return &Cone{radius, height}
}
func (c *Cone) Compile() {
}
func (c *Cone) BoundingBox() Box {
r := c.Radius
return Box{Vector{-r, -r, 0}, Vector{r, r, c.Height}}
}
func (c *Cone) Contains... | ln/cone.go | 0.810816 | 0.449211 | cone.go | starcoder |
package pipeline
// ReadableMap is an interface that provides read only access to map properties
type ReadableMap interface {
// Get retrieves an element from the map, and a bool which says if there was a property that exists with that
// name at all
Get(propName string) (interface{}, bool)
}
// NoProps is an emp... | go/libraries/utils/pipeline/item.go | 0.822474 | 0.486636 | item.go | starcoder |
package main
// CorporateFiller1 is the filler in the first column of "Synergy Ipsum" demo
const CorporateFiller1 = `
CORPORATE SYNERGY: WIN-WIN FOR ALL STAKEHOLDERS
Dramatically mesh low-risk high-yield alignments
before transparent e-tailers. Completely pursue
scalable customer service through sustainable
potential... | demo/filler_text.go | 0.547948 | 0.535038 | filler_text.go | starcoder |
package main
import (
"errors"
"math/rand"
"sort"
)
// Parameters is parameters used in the genetic algorithm solver
type Parameters struct {
// CrossoverProbability is the probability of one chromosome crossover with
// another chromosome to produce two offspring chromosomes in one evolving
// process
Crossov... | go/ga.go | 0.714329 | 0.49408 | ga.go | starcoder |
package model
import (
"github.com/jung-kurt/gofpdf"
"github.com/tcd/md2pdf/internal/lib"
)
// TableContent represents the contents of a table element.
type TableContent struct {
Rows [][]Contents `json:"rows"`
Alignments []string `json:"alignments"` // "L", "C", or "R"
}
// AddRows to TableContent.
fu... | internal/model/table_content.go | 0.809201 | 0.470311 | table_content.go | starcoder |
package shapes
import (
"github.com/juan-medina/goecs"
"github.com/juan-medina/gosge/components/geometry"
)
//Box is a rectangular outline that we could draw in a geometry.Point with a color.Solid
type Box struct {
Size geometry.Size // The box size
Scale float32 // The box scale
Thickness int32 ... | components/shapes/shapes.go | 0.832611 | 0.553747 | shapes.go | starcoder |
package main
// MapToString allows for a safe transformation of a maybe of type string to a maybe
// of type string. Note that the function f is only called if the StringMaybe is a
// some-type.
func (m *StringMaybe) MapToString(f func(string) string) *StringMaybe {
if m.empty {
return &StringMaybe{
empty: true... | examples/gen_maybe_compose.go | 0.756627 | 0.449695 | gen_maybe_compose.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPStatementReturn281 struct for BTPStatementReturn281
type BTPStatementReturn281 struct {
BTPStatement269
BtType *string `json:"btType,omitempty"`
SpaceAfterReturn *BTPSpace10 `json:"spaceAfterReturn,omitempty"`
Value *BTPExpression9 `json:"value,omitempty"`
}
// N... | onshape/model_btp_statement_return_281.go | 0.765681 | 0.45048 | model_btp_statement_return_281.go | starcoder |
package tree
import (
"strings"
"github.com/Allenxuxu/dsa/queue"
)
type Element interface {
Less(e Element) bool
String() string
}
type Node struct {
data Element
parent *Node
left *Node
right *Node
}
type BinaryTree struct {
root *Node
}
func NewBinaryTree() *BinaryTree {
return &BinaryTree{}
}
f... | tree/binary_tree.go | 0.624523 | 0.422743 | binary_tree.go | starcoder |
package consistenthash
import (
"github.com/zjbztianya/go-misc/hashkit"
"errors"
"math/big"
"sort"
)
// Maglev consistent hashing algorithm
// paper:https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/44824.pdf
type Maglev struct {
permutation map[string][]uint32
entry []in... | consistenthash/maglev.go | 0.626238 | 0.418935 | maglev.go | starcoder |
package main
/*
A Function which parses a line of code and returns the new position of the pointer and the new memory value
- It also executes the actions of the line of code like printing, moving the pointer, conditionals, loops, etc.
- The Function gets a slice of tokens from the lexer by passing the line to it. ... | parser.go | 0.673729 | 0.723712 | parser.go | starcoder |
package gown
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
"strings"
)
/*
From wndb(5WN):
For each syntactic category, two files are needed to represent the contents of
the WordNet database - index. pos and data. pos, where pos is noun, verb,
adj and adv . The other auxiliary files are used by th... | data_file.go | 0.582491 | 0.541591 | data_file.go | starcoder |
package signature
import (
"crypto/rand"
"crypto/sha512"
"errors"
"math/big"
"strconv"
"github.com/alecthomas/binary"
"github.com/qantik/ratcheted/primitives"
)
const (
bellareSecurity = 512 // security parameter in bits.
bellareNumPoints = 10 // number of points in the keys.
bellareMaxPeriod = 1000 ... | primitives/signature/bellare.go | 0.732496 | 0.444263 | bellare.go | starcoder |
// verify is a simple example that shows how a verifiable map can be used to
// demonstrate inclusion.
package main
import (
"bytes"
"crypto"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"path/filepath"
"github.com/golang/glog"
"github.com/google/trillian/experimental/batchmap"
coniks "github.com/google/trilli... | experimental/batchmap/cmd/verify/verify.go | 0.574634 | 0.475118 | verify.go | starcoder |
package box2d
import (
"fmt"
"math"
)
/// Rope joint definition. This requires two body anchor points and
/// a maximum lengths.
/// Note: by default the connected objects will not collide.
/// see collideConnected in b2JointDef.
type B2RopeJointDef struct {
B2JointDef
/// The local anchor point relative to body... | DynamicsB2JointRope.go | 0.848282 | 0.625795 | DynamicsB2JointRope.go | starcoder |
package main
import "fmt"
// Slices are a key data type in Go, giving a more powerful interface to sequences than arrays.
// Unlike arrays, slices are typed only by the elements they contain (not the number of elements).
func main() {
s := createSlice()
inlineDeclaration()
getSet(s)
lengthCapacity(s)
appendT... | slice/functionalities.go | 0.716219 | 0.492066 | functionalities.go | starcoder |
package main
import (
"fmt"
"math"
"math/rand"
)
type BinTree struct {
root *Node
}
type pointerDescription int
const (
noLinks pointerDescription = 0
leftIsLinked = 1
rightIsLinked = 2
bothAreLinked = leftIsLinked | rightIsLinked
)
type Node ... | threadtree/threadthree.go | 0.601477 | 0.403802 | threadthree.go | starcoder |
package utils
import (
"fmt"
)
// Node of a tree
type Node struct {
left *Node
right *Node
val interface{}
}
// Tree struct
type Tree struct {
comparator Comparator
node *Node
length int
}
// NewIntTree creates a new int tree
func NewIntTree() *Tree {
return &Tree{comparator: intAscComparator}
... | utils/tree.go | 0.760651 | 0.452717 | tree.go | starcoder |
package statsd
import "time"
type NoopClient struct {
// prefix for statsd name
prefix string
}
// Close closes the connection and cleans up.
func (s *NoopClient) Close() error {
return nil
}
// Increments a statsd count type.
// stat is a string name for the metric.
// value is the integer value
// rate is the ... | src/code.cloudfoundry.org/vendor/github.com/cactus/go-statsd-client/statsd/client_noop.go | 0.878692 | 0.522994 | client_noop.go | starcoder |
This is a b-link tree in progress from the following paper:
http://www.csd.uoc.gr/~hy460/pdf/p650-lehman.pdf
This is still a work in progress and the CRUD methods on the tree
need to be parallelized. Until this is complete, there is no
constructor method for this package.
Time complexities:
Space: O(n)
Search: O(log... | vendor/src/github.com/Workiva/go-datastructures/btree/_link/tree.go | 0.626238 | 0.485844 | tree.go | starcoder |
// More information about Google Distance Matrix API is available on
// https://developers.google.com/maps/documentation/distancematrix/
package maps
import (
"encoding/json"
"net/url"
"github.com/gronka/google-maps-services-go/internal"
//"googlemaps.github.io/maps/internal"
)
// safeLeg is a raw version of L... | encoding.go | 0.856468 | 0.402157 | encoding.go | starcoder |
package loom
import (
"container/list"
"fmt"
"github.com/kpmy/lomo/ir"
"github.com/kpmy/lomo/ir/types"
"github.com/kpmy/trigo"
"github.com/kpmy/ypk/assert"
"github.com/kpmy/ypk/halt"
"math/big"
"reflect"
)
type value struct {
typ types.Type
val interface{}
}
func (v *value) String() string {
return fmt.S... | loom/val.go | 0.514888 | 0.454291 | val.go | starcoder |
package collector
import (
"go.etcd.io/etcd/raft/raftpb"
)
type BriefSegment struct {
Term uint64
PrevLogTerm uint64
FirstIndex uint64
LastIndex uint64
}
func (b *BriefSegment) Hit(term, index uint64) bool {
return term == b.Term && b.FirstIndex <= index && index <= b.LastIndex
}
func (b *BriefSegme... | draft/collector/brief.go | 0.628977 | 0.446072 | brief.go | starcoder |
package isc
func Associate[T any, K comparable, V any](list []T, transform func(T) Pair[K, V]) map[K]V {
r := make(map[K]V)
for _, e := range list {
item := transform(e)
r[item.First] = item.Second
}
return r
}
func AssociateTo[T any, K comparable, V any](list []T, destination *map[K]V, transform func(T) Pair... | isc/associate.go | 0.82251 | 0.487124 | associate.go | starcoder |
package grouped
// BoolFuncs helps starting and waiting for a group of bool-returning functions.
type BoolFuncs struct {
// Sets a recovery callback for any functions added after this is set.
// If a function has a recovery set, and the function panics, the recovery will be called with
// the panic value. In the ag... | boolfuncs.go | 0.614278 | 0.557123 | boolfuncs.go | starcoder |
package datatypes
// ModelInfo enumerates all of the different options for customizing
// the character model
type ModelInfo struct {
Race byte // 2 Elezen, 3 Lalafell, 4 Miqo'te, 5 Roe, 6 Au Ra, else Hyur
Gender byte // 0 is male, 1 is female
BodyType byte // CHANGE AT OWN RI... | datatypes/spawn.go | 0.541166 | 0.50653 | spawn.go | starcoder |
package money
import (
"errors"
"fmt"
"regexp"
"strconv"
"strings"
)
// Amount represents a quantity of money with a currency.
type Amount struct {
// Quantity is the quantity of the amount.
Quantity float64
// Currency is the currency of the amount.
Currency string
}
// NewAmount creates a new amount with ... | money.go | 0.756447 | 0.470372 | money.go | starcoder |
package dao
import (
"database/sql"
"fmt"
"github.com/squat/and/dab/simple-temple-test-group/util"
"github.com/google/uuid"
// pq acts as the driver for SQL requests
_ "github.com/lib/pq"
)
// BaseDatastore provides the basic datastore methods
type BaseDatastore interface {
CreateSimpleTempleTestGroup(input ... | src/e2e/resources/simple-temple-expected/simple-temple-test-group/dao/dao.go | 0.537284 | 0.438605 | dao.go | starcoder |
package common
import "fmt"
// FileData contains the summarized data about the file, including its
// package, its base name, the total number of statements, and the
// number of executed statements.
type FileData struct {
Package string // Name of the package
Name string // Name of the file (basename)
Count ... | common/types.go | 0.659295 | 0.501831 | types.go | starcoder |
package tegola
import (
"fmt"
"math"
"github.com/go-spatial/geom"
"github.com/go-spatial/tegola/maths/webmercator"
)
const (
DefaultEpislon = 10.0
DefaultExtent = 4096
DefaultTileBuffer = 64.0
MaxZ = 22
)
var UnknownConversionError = fmt.Errorf("do not know how to convert value to reques... | tile.go | 0.749271 | 0.435121 | tile.go | starcoder |
package lnchat
import "github.com/lightningnetwork/lnd/lntypes"
// LightningNode represents a Lightning network node.
type LightningNode struct {
// Alias is the Lightning network alias of the node.
Alias string
// Address is the Lightning address of the node.
Address string
}
// Chain represents a blockchain an... | lnchat/types.go | 0.591605 | 0.575558 | types.go | starcoder |
package horserace
import (
"fmt"
"strings"
)
// GetClassAndDistance returns the classification of the race and the distance, given the name of the race (as returned by the betfair API).
func GetClassAndDistance(marketName string) (name string, distance string) {
words := strings.Fields(marketName)
if len(words) <... | horserace/horserace.go | 0.748812 | 0.520435 | horserace.go | starcoder |
package stats
import "runtime"
// BasicMemStats includes a few of the fields from runtime.MemStats suitable for
// general logging.
type BasicMemStats struct {
// General statistics.
Alloc uint64 // bytes allocated and still in use
TotalAlloc uint64 // bytes allocated (even if freed)
Sys uint64 // by... | stats/mem.go | 0.589716 | 0.427158 | mem.go | starcoder |
package indicators
import "math"
// mean returns mean value for an array of float64 values
func mean(values []float64) float64 {
var total float64 = 0
for x := range values {
total += values[x]
}
return total / float64(len(values))
}
func evenSlice(inA, inB []float64) (outA, outB []float64) {
offsetA := int(m... | indicators/indicators.go | 0.62498 | 0.513546 | indicators.go | starcoder |
package main
// https://projecteuler.net/problem=12
import (
"flag"
"fmt"
"math"
)
type Maps map[int]map[int]int
// The triangle number sum is a simple AP sum
func getTriangleNumber(n int) int {
return n * (n + 1) / 2
}
// Every single natural number is a mutiple of a prime
// So we can decomp... | Problem_12_Euler/main.go | 0.766556 | 0.400368 | main.go | starcoder |
package ion
import "fmt"
// A Type represents the type of an Ion Value.
type Type uint8
const (
// NoType is returned by a Reader that is not currently pointing at a value.
NoType Type = iota
// NullType is the type of the (unqualified) Ion null value.
NullType
// BoolType is the type of an Ion boolean, true ... | ion/type.go | 0.7413 | 0.597021 | type.go | starcoder |
package loader
import (
"context"
"fmt"
"regexp"
"strings"
"github.com/xo/xo/models"
)
func init() {
Register(&Loader{
Driver: "oracle",
Kind: map[Kind]string{
KindTable: "TABLE",
KindView: "VIEW",
},
ParamN: func(i int) string {
return fmt.Sprintf(":%d", i+1)
},
MaskFunc: func() string {... | loader/oracle.go | 0.517571 | 0.408011 | oracle.go | starcoder |
package notebook
import (
"gioui.org/f32"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/op/paint"
"image"
"image/color"
)
func rrect(ops *op.Ops, width, height, se, sw, nw, ne float32) {
w, h := float32(width), float32(height)
const c = 0.55228475 // 4*(sqrt(2)-1)/3
var b clip.Path
b.Beg... | notebook/paint.go | 0.763836 | 0.400192 | paint.go | starcoder |
package cluster
import (
"encoding/gob"
"errors"
"fmt"
"math"
"math/rand"
"os"
"time"
"gonum.org/v1/gonum/mat"
)
// KPrototypes is a basic class for the k-prototypes algorithm, it contains all
// necessary information as alg. parameters, labels, centroids, ...
type KPrototypes struct {
DistanceFunc D... | cluster/kprototypes.go | 0.70028 | 0.547343 | kprototypes.go | starcoder |
package input
import (
"github.com/benthosdev/benthos/v4/internal/component/input"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/internal/impl/amqp1/shared"
"github.com/benthosdev/benthos/v4/internal/interop"
"gith... | internal/old/input/amqp_1.go | 0.689619 | 0.530723 | amqp_1.go | starcoder |
package gfilter
import (
"image"
"image/color/palette"
"image/png"
"os"
// but is imported for its initialization side-effect, which allows
// image.Decode to understand JPEG formatted images. Uncomment these
// two lines to also understand GIF and PNG images:
_ "image/gif"
_ "image/jpeg"
_ "image/png"
)
/... | reader.go | 0.782538 | 0.49823 | reader.go | starcoder |
package jigo
import (
"fmt"
"reflect"
)
// vartype is a simplified version of the notion of Kind in reflect, modified
// to reflect the slightly different semantics in jigo.
type vartype int
const (
intType vartype = iota
floatType
stringType
boolType
sliceType
mapType
unknownType
)
func (v vartype) String... | types.go | 0.692746 | 0.441131 | types.go | starcoder |
package header
import (
"fmt"
"strings"
"unsafe"
)
const (
// HeaderSize the allocated size of the header
HeaderSize = 48
)
// Header data header stores
// info about a given data value
type Header struct {
xmin uint64 // transaction id that created the node's data
xmax uint64 // transaction id that upd... | header/header.go | 0.706798 | 0.489015 | header.go | starcoder |
package stats
import (
"strings"
"time"
"github.com/hashicorp/go-memdb"
)
const (
// TimeUnitDays is an identifier that means a metrics values should be grouped by day
TimeUnitDays = "days"
// TimeUnitMonths is an identifier that means a metrics values should be grouped by month
TimeUnitMonths = "months"
/... | internal/stats/date.go | 0.823257 | 0.424412 | date.go | starcoder |
package network
import (
"errors"
"fmt"
neatmath "github.com/yaricom/goNEAT/v2/neat/math"
"math"
)
// FastNetworkLink The connection descriptor for fast network
type FastNetworkLink struct {
// The index of source neuron
SourceIndex int
// The index of target neuron
TargetIndex int
// The weight of this link... | neat/network/fast_network.go | 0.714827 | 0.533215 | fast_network.go | starcoder |
package cloudexport
import (
"encoding/json"
)
// V202101beta1BgpProperties Optional BGP related settings.
type V202101beta1BgpProperties struct {
// If true, apply BGP data discovered via another device to the flow from this export.
ApplyBgp *bool `json:"applyBgp,omitempty"`
UseBgpDeviceId *string `json... | apiv6/kentikapi/cloudexport/model_v202101beta1_bgp_properties.go | 0.782538 | 0.433742 | model_v202101beta1_bgp_properties.go | starcoder |
package blowfish
// getNextWord returns the next big-endian uint32 value from the byte slice
// at the given position in a circular manner, updating the position.
func getNextWord(b []byte, pos *int) uint32 {
var w uint32
j := *pos
for i := 0; i < 4; i++ {
w = w<<8 | uint32(b[j])
j++
if j >= len(b) {
j = ... | vendor/golang.org/x/crypto/blowfish/block.go | 0.640636 | 0.443841 | block.go | starcoder |
package xxhash
import (
"encoding/binary"
"errors"
"hash"
)
const (
prime32x1 uint32 = 2654435761
prime32x2 uint32 = 2246822519
prime32x3 uint32 = 3266489917
prime32x4 uint32 = 668265263
prime32x5 uint32 = 374761393
prime64x1 uint64 = 11400714785074694791
prime64x2 uint64 = 14029467366897019727
prime64x3 ... | vendor/github.com/OneOfOne/xxhash/xxhash.go | 0.688678 | 0.442215 | xxhash.go | starcoder |
package entities
import (
"github.com/rpaloschi/dxf-go/core"
)
// Polyline Entity representation
type Polyline struct {
BaseEntity
Elevation float64
Thickness float64
Closed bool
CurveFitVerticesAdded bool
SplineFitVerticesAdded bool
Is3dPolyline bool
Is3d... | vendor/github.com/rpaloschi/dxf-go/entities/polyline.go | 0.663124 | 0.59072 | polyline.go | starcoder |
package geometry
import (
"encoding/binary"
"math"
)
const rDims = 2
const rMaxEntries = 16
type rRect struct {
data interface{}
min, max [rDims]float64
}
type rNode struct {
count int
rects [rMaxEntries + 1]rRect
}
// rTree ...
type rTree struct {
height int
root rRect
count int
reinsert []... | geometry/rtree.go | 0.566618 | 0.476032 | rtree.go | starcoder |
package nist_sp800_22
import (
"math"
)
func RandomExcursions(n uint64) ([]float64, []bool, error) {
var State_X []int64 = []int64{-4, -3, -2, -1, 1, 2, 3, 4}
var X []int64 = make([]int64, n)
// (1) Form a normalized (-1, +1) sequence X
for i := range epsilon {
X[i] = 2*int64(epsilon[i]) - 1
}
// (2) Co... | nist_sp800_22/randomExcursions.go | 0.523664 | 0.455865 | randomExcursions.go | starcoder |
// Color delta / comparison math.
// Functions to calculate color differences. All of them refers to the CIE-L*ab color space.
// http://www.easyrgb.com/index.php?X=DELT
package delta
import "math"
// Returns H° value
func cieLab2Hue(a, b float64) (h float64) {
rad2deg := 180 / math.Pi
bias := 0.
notAssigned :=... | f64/delta/cie_lab_delta.go | 0.713731 | 0.547827 | cie_lab_delta.go | starcoder |
package gander
import (
"errors"
"fmt"
"sort"
"strconv"
"sync"
)
// A DataFrame is a slice of *Series. As a Series
// contains a slice of float64, a DataFrame can be thought of
// as a two dimensional table of data, somewhat like a spreadsheet.
type DataFrame []*Series
// NewDataFrame creates a D... | dataframe.go | 0.673192 | 0.583263 | dataframe.go | starcoder |
package day24
import (
"bytes"
"fmt"
"io"
"math"
"aoc"
)
type Eris struct {
a, b *aoc.Grid
parent, child *Eris
recursive bool
depth int
}
func NewEris(recursive bool) *Eris {
g := aoc.NewGrid(5, 5)
for i := 0; i < len(g.Data); i++ {
g.Data[i] = '.'
}
if recursive {
g.Set(aoc.Ne... | go/2019/day24/day24.go | 0.558809 | 0.436922 | day24.go | starcoder |
package planar
import (
"math/big"
"github.com/go-spatial/geom"
)
const (
// Experimental testing produced this result.
// For finding the intersect we need higher precision.
// Then geom.PrecisionLevelBigFloat
PrecisionLevelBigFloat = 110
)
func AreLinesColinear(l1, l2 geom.Line) bool {
x1, y1 := l1[0][0],... | planar/line_intersect.go | 0.757525 | 0.607023 | line_intersect.go | starcoder |
package plane
import (
_ "embed"
"image"
_ "image/png"
"math"
"github.com/moniquelive/demoscenetuts/internal/utils"
)
//go:embed texture.png
var textureBytes []byte
type Plane struct {
screenWidth int
screenHeight int
frameCount int
texture *image.Paletted
A, B, C Vector
}
func (p *Plane) Dr... | internal/plane/plane.go | 0.530966 | 0.457924 | plane.go | starcoder |
package linear
import (
"math"
)
// Implementation of a diagonal matrix.
type DiagonalMatrix struct {
data []float64
}
func NewDiagonalMatrixWithDimension(dimension int) (*DiagonalMatrix, error) {
if dimension < 1 {
return nil, notStrictlyPositiveErrorf(float64(dimension))
}
ans := new(DiagonalMatrix)
ans.d... | diagonal_matrix.go | 0.818701 | 0.744285 | diagonal_matrix.go | starcoder |
package opc
// Spatial Stripes
// Creates spatial sine wave stripes: x in the red channel, y--green, z--blue
// Also makes a white dot which moves down the strip non-spatially in the order
// that the LEDs are indexed.
import (
"github.com/longears/pixelslinger/colorutils"
"github.com/longears/pixelslinger/mi... | opc/pattern-aqua.go | 0.570571 | 0.533884 | pattern-aqua.go | starcoder |
package binarytree
import "fmt"
// BTree Returns a binary tree structure which contains only a root Node
type BTree struct {
Root *Node
}
// calculateDepth helper function for BTree's depth()
func calculateDepth(n *Node, depth int) int {
if n == nil {
return depth
}
return Max(calculateDepth(n.left, depth+1), ... | data_structures/binary_tree/btree.go | 0.840259 | 0.567937 | btree.go | starcoder |
package mui
import (
"bytes"
"image"
"path"
"time"
"github.com/blitzprog/imageoutput"
)
const (
// BookImageLargeWidth is the minimum width in pixels of a large book image.
BookImageLargeWidth = 512
// BookImageLargeHeight is the minimum height in pixels of a large book image.
BookImageLargeHeight = 512
... | mui/BookImage.go | 0.660391 | 0.455017 | BookImage.go | starcoder |
package bits
/*
BitwiseLSBCount return the number of 1's in the given integer.
Description:
It AND's the LSB of the given number with 0x01 and increment the counter if
it is 1.
*/
func BitwiseLSBCount(x uint32) uint32 {
if x == 0 {
return 0
}
var cnt uint32
cnt = 0
for x != 0 {
if x&1 == 1 {
cnt++
}
... | bits/numBitsSet.go | 0.669637 | 0.777384 | numBitsSet.go | starcoder |
package talibcdl
import (
"math"
)
type Series interface {
Len() int
High(i int) float64
Open(i int) float64
Close(i int) float64
Low(i int) float64
}
type SimpleSeries struct {
Highs []float64
Opens []float64
Closes []float64
Lows []float64
Volumes []float64
Rands []float64
}
func (s SimpleSe... | series.go | 0.751375 | 0.402304 | series.go | starcoder |
package prng
// https://en.wikipedia.org/wiki/Lehmer_random_number_generator
import (
"math"
"math/bits"
)
// A MCG implements 64-bit multiplicative congruential pseudorandom number
// generator (MCG) modulo 2^64 with 64-bit state and maximun period of 2^62.
type MCG struct {
state uint64
}
// Stee... | mcg.go | 0.70477 | 0.464416 | mcg.go | starcoder |
package trie
/*
* ASCII tries are a special case because the maximum size of the
* children is already known.
* Mulitple implementations are provided, depending on the need:
* - ASCIITrie: simple naive approach. Use for small alphabets.
* - ASCIIReduxTrie: uses alphabet reduction. Use for larger alphabets.
*/
i... | stringtrie.go | 0.835316 | 0.488954 | stringtrie.go | starcoder |
package target
import (
"errors"
"fmt"
"github.com/spf13/pflag"
)
// TargetFlags represents the target cobra flags.
//nolint
type TargetFlags interface {
// GardenName returns the value that is tied to the corresponding cobra flag.
GardenName() string
// ProjectName returns the value that is tied to the corres... | pkg/target/target_flags.go | 0.598899 | 0.436202 | target_flags.go | starcoder |
package systems
import (
"fmt"
"sync"
"time"
"github.com/Ariemeth/quantum-pulse/components"
"github.com/Ariemeth/quantum-pulse/entity"
)
const (
// TypeMovement is the name of the movement system.
TypeMovement = "mover"
)
// Movement represents a system that knows how to alter an Entity's position based on i... | systems/movement.go | 0.710327 | 0.436322 | movement.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPOperatorDeclaration264AllOf struct for BTPOperatorDeclaration264AllOf
type BTPOperatorDeclaration264AllOf struct {
BtType *string `json:"btType,omitempty"`
Operator *string `json:"operator,omitempty"`
SpaceAfterOperator *BTPSpace10 `json:"spaceAfterOperator,omitemp... | onshape/model_btp_operator_declaration_264_all_of.go | 0.730963 | 0.422207 | model_btp_operator_declaration_264_all_of.go | starcoder |
package physics
import (
"encoding/json"
"fmt"
"github.com/stnma7e/betuol/common"
"github.com/stnma7e/betuol/component"
"github.com/stnma7e/betuol/math"
)
// PhysicsManager implements a basic physics manager that handles collision detection and resolution.
// The structure also satisifies the component.SceneMan... | component/physics/manager.go | 0.688573 | 0.41739 | manager.go | starcoder |
package collection
import (
"github.com/rkbodenner/parallel_universe/game"
)
func NewTicTacToe() *game.Game {
var setup = []*game.SetupRule{
game.NewSetupRule("Draw 3x3 grid", "Once"),
game.NewSetupRule("Choose X or O", "Each player"),
}
return game.NewGame("Tic-Tac-Toe", setup, 2, 2)
}
func NewForb... | collection/collection.go | 0.549157 | 0.446676 | collection.go | starcoder |
package nlp
import (
"strconv"
"github.com/gnames/bayes"
"github.com/gnames/gnfinder/ent/token"
"github.com/gnames/gnfinder/io/dict"
)
// BayesF implements bayes.Featurer
type BayesF struct {
name string
value string
}
// FeatureSet splits features into Uninomial, Species, Ifraspecies groups
type FeatureSet ... | ent/nlp/features.go | 0.566258 | 0.474022 | features.go | starcoder |
package main
import (
"errors"
"fmt"
"io"
"os"
"time"
)
// In this video, we'll implement a non-concurrent, non-linear version of the barycenter finder.
// It won't be particularly fast, but it will get the job done.
// ST
// First, though, we need some data to operate on, so we'll write a command line utility
/... | linearBarycenter/main.go | 0.675122 | 0.577793 | main.go | starcoder |
package yamlpath
import (
"fmt"
"regexp"
"strconv"
"strings"
"gopkg.in/yaml.v3"
)
type filter func(node, root *yaml.Node) bool
func newFilter(n *filterNode) filter {
if n == nil {
return never
}
switch n.lexeme.typ {
case lexemeFilterAt, lexemeRoot:
path := pathFilterScanner(n)
return func(node, roo... | pkg/yamlpath/filter.go | 0.68437 | 0.470858 | filter.go | starcoder |
package unit
import (
"github.com/brettbuddin/shaden/dsp"
)
func newReverb(io *IO, c Config) (*Unit, error) {
var (
aTravelFreq = dsp.Frequency(0.5, c.SampleRate).Float64()
bTravelFreq = dsp.Frequency(0.3, c.SampleRate).Float64()
r = &reverb{
a: io.NewIn("a", dsp.Float64(0)),
b: ... | unit/reverb.go | 0.617051 | 0.536374 | reverb.go | starcoder |
package bls12381
import (
"crypto/subtle"
"fmt"
"github.com/cloudflare/circl/ecc/bls12381/ff"
)
// G2Size is the length in bytes of an element in G2 in uncompressed form..
const G2Size = 2 * ff.Fp2Size
// G2SizeCompressed is the length in bytes of an element in G2 in compressed form.
const G2SizeCompressed = ff.... | ecc/bls12381/g2.go | 0.683736 | 0.435301 | g2.go | starcoder |
package domain
type Block struct {
X, Y int
Colour BlockColour
}
type Board struct {
cells [][]*Block
}
func NewBoard() Board {
b := Board{}
// fill with blank cells
b.cells = make([][]*Block, BoardWidth)
for x := 0; x < BoardWidth; x++ {
b.cells[x] = make([]*Block, BoardHeight)
for y := 0; y < BoardH... | domain/board.go | 0.643441 | 0.488466 | board.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.