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 graph
import (
"errors"
"math"
)
//Node represents a graph node
type Node struct {
data interface{}
graph *Graph
edges map[*Node]*Edge
}
//NewNode creates a new node
func NewNode(data interface{}) *Node {
return &Node{
data: &data,
}
}
//Data of the node
func (n *Node) Data() interface{} {
return... | graph/node.go | 0.655115 | 0.461684 | node.go | starcoder |
package sip
import (
"container/list"
"gosips/sip/message"
)
/**
* This interface represents the management interface of a SIP stack
* implementing this specification and as such is the interface that defines
* the management/architectural view of the SIP stack. It defines the methods
* required to represent and pr... | sip/SipStack.go | 0.723114 | 0.502197 | SipStack.go | starcoder |
package i18n
import (
"sort"
"strings"
)
// Country represents a country information. ISO 3166-1
type Country struct {
Alpha2Code string // ISO alpha-2 country code
Alpha3Code string // ISO alpha-3 country code
NumericCode string // ISO numeric country code
Name String
Aliases StringArray
}
// Ea... | i18n/country.go | 0.739046 | 0.477006 | country.go | starcoder |
package parcom
type position struct {
lineIndex, columnIndex int // -1 indicates invalid position.
}
// PositionalState is a position-aware parser state.
type PositionalState struct {
State
position position
}
// NewPositionalState creates a parser state.
func NewPositionalState(s string) *PositionalState {
retu... | positional_state.go | 0.824285 | 0.639497 | positional_state.go | starcoder |
package typ
import "sort"
func NewAlt(alts ...Type) (res Type) {
res = Type{KindAlt, &Info{Params: make([]Param, 0, len(alts)*2)}}
return addAlts(res, alts)
}
// Alt returns a new type alternative for a list of types. Other alternatives are flattened.
// If the first type is already an alternative, the following t... | typ/alts.go | 0.617167 | 0.404096 | alts.go | starcoder |
package bsoncore
import (
"errors"
"io"
"go.mongodb.org/mongo-driver/bson/bsontype"
)
// DocumentSequenceStyle is used to represent how a document sequence is laid out in a slice of
// bytes.
type DocumentSequenceStyle uint32
// These constants are the valid styles for a DocumentSequence.
const (
_ DocumentSequ... | vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/document_sequence.go | 0.623033 | 0.438064 | document_sequence.go | starcoder |
package mtest
import (
"github.com/MaxBreida/mongo-go-driver/bson"
)
// BatchIdentifier specifies the keyword to identify the batch in a cursor response.
type BatchIdentifier string
// These constants specify valid values for BatchIdentifier.
const (
FirstBatch BatchIdentifier = "firstBatch"
NextBatch BatchIden... | mongo/integration/mtest/deployment_helpers.go | 0.693369 | 0.441011 | deployment_helpers.go | starcoder |
package block
import (
"fmt"
"github.com/df-mc/dragonfly/server/item"
)
// CoralType represents a type of coral of a block. CoralType, coral fans, and coral blocks carry one of these types.
type CoralType struct {
coral
}
// TubeCoral returns the tube coral variant
func TubeCoral() CoralType {
return CoralType{0... | server/block/coral_type.go | 0.740831 | 0.44565 | coral_type.go | starcoder |
package stringnorm
import (
"errors"
)
// ErrNormalizeComplete is a sentinel value returned by a normalizer to
// request that no other normalizers be run.
var ErrNormalizeComplete = errors.New("ErrNormalizeComplete")
// A Normalizer normalizes a string value.
type Normalizer interface {
// Normalize copies the gi... | stringnorm/stringnorm.go | 0.551332 | 0.446495 | stringnorm.go | starcoder |
package classics
/*
Alice is taking a cryptography class and finding anagrams to be very useful.
We consider two strings to be anagrams of each other if the first string's
letters can be rearranged to form the second string. In other words, both
strings must contain the same exact letters in the same exact frequency
F... | classics/makingAnagrams.go | 0.674801 | 0.67209 | makingAnagrams.go | starcoder |
package tracer
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"sort"
"strings"
"github.com/Jeffail/benthos/v3/lib/util/config"
yaml "gopkg.in/yaml.v3"
)
//------------------------------------------------------------------------------
// Errors for the tracer package.
var (
ErrInvalidTracerType = errors.N... | lib/tracer/constructor.go | 0.794505 | 0.411939 | constructor.go | starcoder |
package hash
import (
"fmt"
"math/big"
"math/rand"
"reflect"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
const (
// HashLength is the expected length of the hash
HashLength = 32
)
var (
// Zero is an empty hash.
Zero = Hash{}
hashT = reflect.Typ... | hash/hash.go | 0.76986 | 0.449211 | hash.go | starcoder |
package chart
import (
"fmt"
"math"
util "github.com/t-mw/go-chart/util"
)
// AnnotationSeries is a series of labels on the chart.
type AnnotationSeries struct {
Name string
Style Style
YAxis YAxisType
Annotations []Value2
}
// GetName returns the name of the time series.
func (as Annotati... | annotation_series.go | 0.835013 | 0.462048 | annotation_series.go | starcoder |
package api
import (
"fmt"
"regexp"
"strings"
"github.com/mattermost/chewbacca/internal/utils"
"github.com/mattermost/chewbacca/model"
"github.com/google/go-github/v31/github"
"k8s.io/apimachinery/pkg/util/sets"
)
const (
// ReleaseNoteLabelNeeded defines the label used when a missing release-note label is ... | internal/api/release_notes.go | 0.539954 | 0.512937 | release_notes.go | starcoder |
package mathutil
import "math"
// Sum return the summation value of float64 values.
func Sum(vals []float64) float64 {
var total float64
for i := 0; i < len(vals); i++ {
total += vals[i]
}
return total
}
// Average returns the mean value of float64 values.
// Returns zero if the vals length is 0.
func Average(... | util/mathutil/mathutil.go | 0.859428 | 0.587973 | mathutil.go | starcoder |
package neuralnetwork
import "math"
//JaccardIndex returns the Jaccard index.
func JaccardIndex(predicted, actual []float64) int {
var sum int
for i := range predicted {
if predicted[i] == actual[i] {
sum++
}
}
return sum / len(predicted)
}
//F1Score returns the F1 Score
func F1Score(predicted, actual []f... | nn/metrics.go | 0.851089 | 0.552902 | metrics.go | starcoder |
package xeval
import (
"github.com/juju/errors"
"github.com/pingcap/tidb/util/types"
"github.com/pingcap/tipb/go-tipb"
)
// evalLogicOps computes LogicAnd, LogicOr, LogicXor results of two operands.
func (e *Evaluator) evalLogicOps(expr *tipb.Expr) (types.Datum, error) {
if expr.GetTp() == tipb.ExprType_Not {
... | distsql/xeval/eval_logic_ops.go | 0.571767 | 0.422922 | eval_logic_ops.go | starcoder |
package shapes
import (
"fmt"
"image"
"image/color"
"image/draw"
"image/jpeg"
"image/png"
"log"
"math"
"os"
"path/filepath"
"runtime"
"strings"
)
var saneLength, saneRadius, saneSides func(int) int
func init() {
saneLength = makeBoundedIntFunc(1, 4096)
saneRad... | src/shaper1/shapes/shapes.go | 0.815085 | 0.462109 | shapes.go | starcoder |
package mp4
import (
"encoding/binary"
)
// SliceWriter - write numbers to a []byte slice
type SliceWriter struct {
buf []byte
pos int
}
// NewSliceWriter - create writer around slice
func NewSliceWriter(data []byte) *SliceWriter {
return &SliceWriter{
buf: data,
pos: 0,
}
}
// WriteUint8 - write byte to s... | mp4/slicewriter.go | 0.598782 | 0.432303 | slicewriter.go | starcoder |
package challenges
import (
"errors"
"github.com/offchainlabs/arbitrum/packages/arb-util/machine"
"github.com/offchainlabs/arbitrum/packages/arb-validator-core/valprotocol"
)
type AssertionDefender struct {
precondition *valprotocol.Precondition
numSteps uint64
initState machine.Machine
}
func NewAsser... | packages/arb-validator/challenges/defender.go | 0.57344 | 0.424472 | defender.go | starcoder |
package utils
import (
"bytes"
"encoding/binary"
"fmt"
"math/big"
"strconv"
"github.com/pkg/errors"
"github.com/ethereum/go-ethereum/common"
"github.com/tidwall/gjson"
)
const (
// FormatBytes encodes the output as bytes
FormatBytes = "bytes"
// FormatUint256 encodes the output as bytes containing a uint... | core/utils/ethabi.go | 0.736021 | 0.42668 | ethabi.go | starcoder |
package integration
import (
"fmt"
"testing"
"github.com/m3db/m3/src/dbnode/client"
"github.com/m3db/m3/src/dbnode/integration/generate"
"github.com/m3db/m3/src/x/ident"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type verifyQueryMetadataResultsOptions struct {
namespace i... | src/dbnode/integration/integration_index_verify.go | 0.567817 | 0.490053 | integration_index_verify.go | starcoder |
package types
import (
"math"
"gonum.org/v1/gonum/floats"
)
type Float64Slice []float64
func (s *Float64Slice) Push(v float64) {
*s = append(*s, v)
}
func (s *Float64Slice) Pop(i int64) (v float64) {
v = (*s)[i]
*s = append((*s)[:i], (*s)[i+1:]...)
return v
}
func (s Float64Slice) Max() float64 {
return fl... | pkg/types/float_slice.go | 0.773131 | 0.540985 | float_slice.go | starcoder |
package logic
import (
"github.com/tajtiattila/joyster/block"
"math"
)
func init() {
// add value to input
block.RegisterScalarFunc("offset", func(p block.Param) (func(float64) float64, error) {
ofs := p.Arg("Value")
return func(v float64) float64 {
return v + ofs
}, nil
})
// zero input under abs. va... | block/logic/axis.go | 0.540196 | 0.462837 | axis.go | starcoder |
package resize
import (
"math"
)
func nearest(in float64) float64 {
if in >= -0.5 && in < 0.5 {
return 1
}
return 0
}
func linear(in float64) float64 {
in = math.Abs(in)
if in <= 1 {
return 1 - in
}
return 0
}
func cubic(in float64) float64 {
in = math.Abs(in)
if in <= 1 {
return in*in*(1.5*in-2.5) ... | vendor/resize/filters.go | 0.68595 | 0.480296 | filters.go | starcoder |
package geom
import (
"errors"
"math"
)
// ErrNilPoint is thrown when a point is null but shouldn't be
var ErrNilPoint = errors.New("geom: nil Point")
var nan = math.NaN()
// EmptyPoint describes an empty 2D point object.
var EmptyPoint = Point{nan, nan}
// Point describes a simple 2D point
type Point [2]float64... | vendor/github.com/go-spatial/geom/point.go | 0.82748 | 0.677448 | point.go | starcoder |
package monday
import "strings"
func findInString(where string, what string, foundIndex *int, trimRight *int) (found bool) {
ind := strings.Index(strings.ToLower(where), strings.ToLower(what))
if ind != -1 {
*foundIndex = ind
*trimRight = len(where) - ind - len(what)
return true
}
return false
}
// common... | vendor/github.com/goodsign/monday/format_common.go | 0.520496 | 0.428652 | format_common.go | starcoder |
package common
// Annotations
const (
// AnnotationResumeTestrun is the annotation name to trigger resume on the testrun
AnnotationResumeTestrun = "testmachinery.sapcloud.io/resume"
// AnnotationCollectTestrun is the annotation to trigger collection and persistence of testrun results
AnnotationCollectTestrun = "... | pkg/common/common.go | 0.506103 | 0.439928 | common.go | starcoder |
package vclock
import (
"bytes"
"encoding/gob"
"fmt"
"log"
"sort"
)
// Condition constants define how to compare a vector clock against another,
// and may be ORed together when being provided to the Compare method.
type Condition int
//Constants define compairison conditions between pairs of vector
//clocks
co... | govec/vclock/vclock.go | 0.761095 | 0.453201 | vclock.go | starcoder |
package engine
// Boundries in horizontal direction for a piece
type XBoundry struct {
left int
right int
}
// Boundries in vertical direction for a piece
type YBoundry struct {
top int
bottom int
}
// Diagonal boundries for a piece
type DiagonalBoundry struct {
topLeft int
topRight int
bottomLeft ... | engine/boundries.go | 0.787482 | 0.424352 | boundries.go | starcoder |
package plaid
import (
"encoding/json"
)
// InvestmentsTransactionsOverride Specify the list of investments transactions on the account.
type InvestmentsTransactionsOverride struct {
// Posting date for the transaction. Must be formatted as an [ISO 8601](https://wikipedia.org/wiki/ISO_8601) date.
Date string `jso... | plaid/model_investments_transactions_override.go | 0.879509 | 0.499146 | model_investments_transactions_override.go | starcoder |
package graphics2D
import (
"fmt"
"math"
)
type BoundingBox struct {
XMin [2]float32
XMax [2]float32
}
func NewBoundingBox(Geometry []Point) (Box *BoundingBox) {
if len(Geometry) == 0 {
return nil
}
Box = new(BoundingBox)
Box.XMin[0], Box.XMin[1] = Geometry[0].X[0], Geometry[0].X[1]
Box.XMax[0], Box.XMax[... | geometry/graphics.go | 0.684264 | 0.557845 | graphics.go | starcoder |
package app
//discuss @iso13818-1.pdf, page 61
import (
"encoding/binary"
"go_srs/srs/utils"
)
type SrsTsPayloadPATProgram struct {
// 4B
/**
* Program_number is a 16-bit field. It specifies the program to which the program_map_PID is
* applicable. When set to 0x0000, then the following PID reference shall be... | srs/app/srs_ts_pat.go | 0.526586 | 0.436862 | srs_ts_pat.go | starcoder |
package graph
import (
"fmt"
"math"
"github.com/moorara/algo/pkg/graphviz"
)
// FlowEdge represents a capacitated edge data type.
type FlowEdge struct {
from, to int
capacity, flow float64
}
// From returns the tail vertex of the edge.
func (e *FlowEdge) From() int {
return e.from
}
// To returns the h... | graph/flow.go | 0.897063 | 0.686958 | flow.go | starcoder |
package sortedset
import (
"encoding/json"
"fmt"
"github.com/dusk-network/dusk-blockchain/pkg/util"
)
// Cluster is a sortedset that keeps track of duplicates.
type Cluster struct {
Set
elements map[string]int
}
// NewCluster returns a new empty Cluster.
func NewCluster() Cluster {
return Cluster{
Set: ... | pkg/util/nativeutils/sortedset/cluster.go | 0.824674 | 0.417331 | cluster.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTFSValueWithUnits1817 struct for BTFSValueWithUnits1817
type BTFSValueWithUnits1817 struct {
BTFSValue1888
BtType *string `json:"btType,omitempty"`
QuantityType *string `json:"quantityType,omitempty"`
UnitToPower *map[string]int32 `json:"unitToPower,omitempty"`
Val... | onshape/model_btfs_value_with_units_1817.go | 0.713731 | 0.419826 | model_btfs_value_with_units_1817.go | starcoder |
package leetcode
type Trie struct {
root *node
}
/** Initialize your data structure here. */
func Constructor7() Trie {
return Trie{
root: &node{},
}
}
type node struct {
val []byte
flag bool
children []*node
}
func newNode(val []byte, flag bool) *node {
return &node{
children: make([]*node, 0),
val:... | 208_implement-trie-prefix-tree.go | 0.559531 | 0.455562 | 208_implement-trie-prefix-tree.go | starcoder |
package random
import (
"fmt"
"github.com/LuighiV/payload-generator/generator/converter"
"math/rand"
"time"
)
// GenerateRandom returns a random value receiving the a base value and
// variation value which determines the range of variation.
func GenerateRandom(basevalue float64, rangevariation float64) float64 {... | generator/random/metheorological.go | 0.889018 | 0.581689 | metheorological.go | starcoder |
package other
import (
"time"
"github.com/kasworld/h4o/_examples/app"
"github.com/kasworld/h4o/appwindow"
"github.com/kasworld/h4o/eventtype"
"github.com/kasworld/h4o/experimental/collision"
"github.com/kasworld/h4o/geometry"
"github.com/kasworld/h4o/gls"
"github.com/kasworld/h4o/graphic"
"github.com/kasworl... | _examples/demos/other/raycast.go | 0.591015 | 0.468487 | raycast.go | starcoder |
package index
import (
"github.com/jtejido/golucene/core/util"
)
/*
IndexInput that knows how to read the byte slices written by Posting
and PostingVector. We read the bytes in each slice until we hit the
end of that slice at which point we read the forwarding address of
the next slice and then jump to it.
*/
type B... | core/index/byteSliceReader.go | 0.608478 | 0.493531 | byteSliceReader.go | starcoder |
package fractales
import (
"math"
"math/big"
"math/cmplx"
"github.com/Balise42/marzipango/params"
)
const r = 1000
// MandelbrotContinuousValueLow returns the fractional number of iterations corresponding to a complex in the Mandelbrot set with low precision input
func MandelbrotContinuousValueLow(c complex128,... | fractales/mandelbrot.go | 0.787155 | 0.59075 | mandelbrot.go | starcoder |
package monthlypayments
import (
"fmt"
"math"
"sort"
"time"
"github.com/jinzhu/now"
"github.com/lealoureiro/mortgage-calculator-api/model"
)
// CalculateLinearMonthlyPayments : calculate the monthly payments for a Linear Mortgage
func CalculateLinearMonthlyPayments(r model.MonthlyPaymentsRequest) model.Monthly... | monthlypayments/monthly_payments.go | 0.696991 | 0.550909 | monthly_payments.go | starcoder |
package bloom
import (
"github.com/iotexproject/go-pkgs/hash"
"github.com/pkg/errors"
)
type (
// bloom2048b implements a 2048-bit bloom filter
bloom2048b struct {
array [256]byte
numHash uint // number of hash function
}
)
// newBloom2048 returns a 2048-bit bloom filter
func newBloom2048(h uint) (BloomF... | bloom/bloom2048b.go | 0.787237 | 0.515864 | bloom2048b.go | starcoder |
package tables
type OrderedTable struct {
data map[string][]string
order []string
}
func NewOrderedTable() OrderedTable {
return OrderedTable{
data: make(map[string][]string, 0),
order: make([]string, 0),
}
}
// Create a new ordered table given a two dimensional slice.
func NewOrderedTableFromMatrix(data [... | tables/ordered.go | 0.80765 | 0.665608 | ordered.go | starcoder |
package trianglem
import (
"errors"
"fmt"
)
// M represents a triangle matrix.
/*
Some optimizations hold where:
1 2 3 4 1=6=11=16= 🤷♂️
5 6 7 8 2 = -5 7 = -10
9 10 11 12 3 = -9 8 = -11
13 14 15 16 4 = -13 12 = -15
As we can represent the matrix with only half the values, the memory representa... | internal/trianglem/matrix.go | 0.720565 | 0.428293 | matrix.go | starcoder |
package runtime
import (
"github.com/golang/protobuf/proto"
)
// StringP returns a pointer to a string whose pointee is same as the given string value.
func StringP(val string) (*string, error) {
return proto.String(val), nil
}
// BoolP parses the given string representation of a boolean value,
// and ... | vendor/github.com/kubernetes-incubator/service-catalog/vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/proto2_convert.go | 0.76074 | 0.434461 | proto2_convert.go | starcoder |
package unordered
import ()
// A Comparable can be checked for equality against others of the same underlying type and follows the pattern of Item. You define what a comparable item is.
type Comparable interface {
Equal(Comparable) bool
}
// An EqualSet follows the same patterns as Set but holds items that are com... | equalset.go | 0.755366 | 0.55266 | equalset.go | starcoder |
package query
import (
"config"
"connectordb/datastream"
"github.com/connectordb/pipescript"
"github.com/connectordb/pipescript/transforms" // Load all available transforms
"github.com/connectordb/pipescript/interpolator/interpolators" // Load all available interpolators
)
// Register all of pipescript's s... | src/connectordb/query/transformrange.go | 0.759939 | 0.502197 | transformrange.go | starcoder |
package mock
var exampleCurrentWeather string = `
[
{
"ApparentTemperature": {
"Imperial": {
"Unit": "F",
"UnitType": 18,
"Value": 42
},
"Metric": {
"Unit": "C",
"UnitType": 17,
"Value": 5.6
}
},
"Ceiling"... | mock/examples_current_weather.go | 0.723602 | 0.465813 | examples_current_weather.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"math"
"sort"
)
type position struct {
x int
y int
}
func inputToAsteroid(data string) []position {
asteroids := make([]position, 0)
row := 0
col := 0
for i := range data {
if data[i] == 13 {
} else if data[i] == 10 {
row++
col = 0
} else if data[i] ==... | 10/main.go | 0.640523 | 0.472136 | main.go | starcoder |
package shuffle
import (
"math/rand"
"sort"
)
// Interface is a type, typically a collection, that satisfies shuffle.Interface can be
// shuffled by the routines in this package.
type Interface interface {
// Len is the number of elements in the collection.
Len() int
// Swap swaps the elements with indexes i and... | vendor/github.com/shogo82148/go-shuffle/shuffle.go | 0.68215 | 0.508544 | shuffle.go | starcoder |
package timex
import (
"fmt"
"time"
)
// Interval describes a time interval between start and end time values
type Interval struct {
start time.Time
end time.Time
}
// NewInterval returns a new instance of Interval between start and end
// Input is order-independent, the smaller value will be used as the start... | interval.go | 0.82425 | 0.57821 | interval.go | starcoder |
package tensor
import (
"unsafe"
"github.com/lordlarker/nune/internal/slice"
"github.com/lordlarker/nune/internal/utils"
)
// Ravel returns a copy of the Tensor's 1-dimensional data buffer.
func (t *Tensor[T]) Ravel() []T {
return t.storage.Load()
}
// Numel returns the number of elements in the Tensor's data ... | tensor/attr.go | 0.819821 | 0.588919 | attr.go | starcoder |
package ml
import (
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/plt"
)
// PlotterClass defines a plotter to plot classification data
type PlotterClass struct {
// input
data *Data // x-data
classes []int // y-data
// constants
MgridNpts int // nubmer of poitns for mes... | ml/plotclass.go | 0.672869 | 0.412589 | plotclass.go | starcoder |
package pedantic
const (
unicodeLetter = `\p{L}`
unicodeLetterNumber = `[\p{L}\p{N}]`
unicodeC1Control = `\x80-\x9f`
unicodeSurrogateHigh = `\x{d800}-\x{dbff}`
unicodeSurrogateLow = `\x{dc00}-\x{dfff}`
unicodeSurrogate = `\x{d800}-\x{dfff}`
unicodeReplacement = `\x{fffd}`
// every codepoint... | unicode.go | 0.525856 | 0.445288 | unicode.go | starcoder |
package pointer
import "time"
// Bool creates a pointer to the provided boolean value
func Bool(v bool) *bool { return &v }
// Uint creates a pointer to the provided uint value
func Uint(v uint) *uint { return &v }
// Uint8 creates a pointer to the provided uint8 value
func Uint8(v uint8) *uint8 { return &v }
// U... | pointer.go | 0.705785 | 0.432603 | pointer.go | starcoder |
package matrix
import (
"fmt"
"github.com/kieron-pivotal/rays/tuple"
)
type Matrix struct {
rows int
cols int
values []float64
}
func New(rows, cols int, vals ...float64) Matrix {
valsCopy := make([]float64, rows*cols)
copy(valsCopy, vals)
m := Matrix{
rows: rows,
cols: cols,
values: valsCopy,... | matrix/matrix.go | 0.724578 | 0.591428 | matrix.go | starcoder |
package gifbounce
import (
"math"
"github.com/sgreben/yeetgif/pkg/box2d"
)
type World struct {
*Params
Box2d *box2d.World
Things struct {
Dynamic []*Thing
Static []*Thing
}
}
func (w *World) ContainsDynamicThings(aabb box2d.AABB) bool {
found := false
w.Box2d.QueryAABB(func(fixture *box2d.Fixture) boo... | pkg/gifbounce/world.go | 0.629775 | 0.438485 | world.go | starcoder |
package main
/*
This is a test module that does the following:
1) Creates an OpenGL window
2) Creates an RGB texture from noise described in a JSON config file
3) Displays the noise as a texture on a plane in the window
It requires the GLFW3 and GLEW libraries as well as the Go wrappers
for them: go-gl/gl and go-gl... | examples/noise_from_json_gl.go | 0.711732 | 0.44565 | noise_from_json_gl.go | starcoder |
package chipmunk
import (
"github.com/Dethrail/chipmunk/transform"
"github.com/Dethrail/chipmunk/vect"
)
// Convenience wrapper around PolygonShape.
type BoxShape struct {
Shape *Shape
// The polygon that represents this box. Do not touch!
Polygon *PolygonShape
verts [4]vect.Vect
// The width of the box. Cal... | chipmunk/boxShape.go | 0.837088 | 0.563798 | boxShape.go | starcoder |
package main
import (
"fmt"
"math"
)
// OpenShape je uživatelsky definovaná datová struktura
// představující otevřené geometrické tvary (úsečka, oblouk, křivka)
type OpenShape interface {
length() float64
}
// ClosedShape je uživatelsky definovaná datová struktura
// představující uzavřené geometrické tvary (ús... | article_04/08_more_implementations.go | 0.549399 | 0.581244 | 08_more_implementations.go | starcoder |
package ngin
import (
"bufio"
"bytes"
)
const (
szKB = 1 << 10
szMB = 1 << 20
szGB = 1 << 30
szHeader = 16
szPage = 4 * szKB
)
// alignBytes takes n number of input bytes (should be length of the data) and returns
// a page aligned byte count, making sure to include the header in the calculation... | pkg/ngin/_record.go | 0.591605 | 0.450662 | _record.go | starcoder |
package logicalpermissions
type LogicalPermissionsInterface interface {
/**
* Adds a permission type.
* @param {string} name - The name of the permission type
* @param {func(string, map[string]interface{}) (bool, error)} callback - The callback that evaluates the permission type. Upon calling CheckAccess() the... | logicalpermissionsinterface.go | 0.899678 | 0.491151 | logicalpermissionsinterface.go | starcoder |
package utils
import (
"errors"
"fmt"
"math"
)
// NodeActivationType defines the type of activation function to use for the neuron node
type NodeActivationType byte
// The neuron Activation function Types
const (
// The sigmoid activation functions
SigmoidPlainActivation NodeActivationType = iota + 1
SigmoidRe... | neat/utils/activations.go | 0.826292 | 0.65276 | activations.go | starcoder |
package iso20022
// Provides further details on the agents specific to the individual transaction.
type TransactionAgents3 struct {
// Financial institution servicing an account for the debtor.
DebtorAgent *BranchAndFinancialInstitutionIdentification5 `xml:"DbtrAgt,omitempty"`
// Financial institution servicing a... | TransactionAgents3.go | 0.69946 | 0.463262 | TransactionAgents3.go | starcoder |
package plot
// Plot defines a combination of elements that can be drawn to the canvas.
type Plot struct {
// X, Y are the axis information
X, Y *Axis
Margin Rect
Elements
// DefaultStyle
Theme
}
// Element is a drawable plot element.
type Element interface {
Draw(plot *Plot, canvas Canvas)
}
// Dataset rep... | plot.go | 0.782995 | 0.587677 | plot.go | starcoder |
package transform
import "errors"
// Sort by Rank Transform is a family of transforms typically used after
// a BWT to reduce the variance of the data prior to entropy coding.
// SBR(alpha) is defined by sbr(x, alpha) = (1-alpha)*(t-w1(x,t)) + alpha*(t-w2(x,t))
// where x is an item in the data list, t is the current... | go/src/kanzi/transform/SBRT.go | 0.765155 | 0.468122 | SBRT.go | starcoder |
package interpolation ; import ( "math" ; "github.com/sjbog/math_tools" )
/* Calculates the point ( by offset percent ) from a Bézier curve
Uses formulas for special cases : single point, linear, quadratic and cubic curves. See http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Examination_of_cases
Arguments
0.0 <=... | interpolation/bezier.go | 0.681515 | 0.537102 | bezier.go | starcoder |
package equipables
import (
"github.com/lquesada/cavernal/assets"
"github.com/lquesada/cavernal/helpers"
"github.com/lquesada/cavernal/entity"
"github.com/lquesada/cavernal/model"
"github.com/lquesada/cavernal/lib/g3n/engine/math32"
)
// --
var woodenShieldModel = &model.NodeSpec{
Decoder: model.Load(dir, "woode... | assets/equipables/shields.go | 0.520984 | 0.487734 | shields.go | starcoder |
package rmath
import (
"fmt"
"math"
)
// NewVector3 creates a Vector3 initialized to 0.0, 0.0, 0.0
func NewVector3() *Vector3 {
v := new(Vector3)
v.X = 0.0
v.Y = 0.0
v.Z = 0.0
return v
}
// NewVector3With3Components creates a Vector3 initialized with x,y,z
func NewVector3With3Components(x, y, z float32) *Vect... | ranger/rmath/vector3.go | 0.906382 | 0.703549 | vector3.go | starcoder |
package graph
import (
"container/list"
"fmt"
"math/rand"
"time"
)
type GraphGenerator struct {
// EnableAsymetricDistances (it true, default false) allows the graph to have different edge lengths from A to B than B to A
// (e.g. to simulate different routes between two locations due to one-way streets).
Enabl... | graph/graphgenerator.go | 0.632957 | 0.528412 | graphgenerator.go | starcoder |
package assert
import (
"fmt"
"testing"
"github.com/slcjordan/poc"
)
type Board struct {
assertion *Assertion
scoreCheckers []Int32Checker
Piles PositionedCardArray2D
}
func newBoard(assertion *Assertion) Board {
return Board{
assertion: assertion,
Piles: newPositionedCardArray2D(assertion),
}... | test/assert/model.go | 0.753829 | 0.615983 | model.go | starcoder |
package gridserver
import (
"math"
)
const (
earthRadiusMeters = 6378137
earthCircumferenceMeters = 2 * math.Pi * earthRadiusMeters
)
// Projection defines the interface for types that convert between pixel and lat/lng coordinates.
type Projection interface {
TileOrigin(tx, ty, zoom int) (float64, float64... | tile_server/gridserver/projection.go | 0.904595 | 0.612541 | projection.go | starcoder |
package main
import (
"fmt"
"log"
"github.com/LdDl/cnns"
"github.com/LdDl/cnns/tensor"
"gonum.org/v1/gonum/mat"
)
func main() {
ExampleConv()
// ExampleConv2()
}
// ExampleConv Check how convolutional network's layers works with single channel image. Corresponding file is "step_by_step_cnn(dense inertia).xls... | examples/simple_cnn/main.go | 0.731059 | 0.415966 | main.go | starcoder |
// Package pipeline contains Beam pipeline library functions for the SumDB
// verifiable map.
package pipeline
import (
"errors"
"fmt"
"github.com/apache/beam/sdks/v2/go/pkg/beam"
"github.com/golang/glog"
"github.com/google/trillian/experimental/batchmap"
)
// InputLog allows access to entries from the SumDB.
... | experimental/batchmap/sumdb/build/pipeline/pipeline.go | 0.835618 | 0.471102 | pipeline.go | starcoder |
package precedence
import (
"strconv"
"github.com/metalnem/parsing-algorithms/ast"
"github.com/metalnem/parsing-algorithms/parse"
"github.com/metalnem/parsing-algorithms/scan"
"github.com/pkg/errors"
)
type assoc int
const (
left assoc = iota
right
)
type symbol struct {
value string
lbp int
nud func... | parse/precedence/precedence.go | 0.762513 | 0.420957 | precedence.go | starcoder |
package main
import (
`fmt`
)
/**
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
Example:
Input: "23"
Outpu... | main/letterCombinations.go | 0.550849 | 0.497681 | letterCombinations.go | starcoder |
package tagexpr
import (
"math"
)
// --------------------------- Operator ---------------------------
type additionExprNode struct{ exprBackground }
func newAdditionExprNode() ExprNode { return &additionExprNode{} }
func (ae *additionExprNode) Run(currField string, tagExpr *TagExpr) interface{} {
// positive nu... | spec_operator.go | 0.629433 | 0.508849 | spec_operator.go | starcoder |
package types
import (
"errors"
"fmt"
"strconv"
)
// PlmnID is a globally unique network identifier (Public Land Mobile Network)
type PlmnID uint32
// GnbID is a 5G gNodeB Identifier
type GnbID uint64
// EnbID is an eNodeB Identifier
type EnbID uint32
// CellID is a node-local cell identifier; 4 bits for 4G; 1... | go/onos/ransim/types/types.go | 0.617397 | 0.595728 | types.go | starcoder |
package timeseries
import "math"
func (ts TimeSeries) SimpleMovingAverage(n int) TimeSeries {
if ts.Len() == 0 {
return ts
}
sma := []TimePoint{ts[0]}
// It's not possible to calculate MA if n greater than number of points
n = int(math.Min(float64(ts.Len()), float64(n)))
// Initial window, use simple movin... | pkg/timeseries/moving_average.go | 0.782953 | 0.573678 | moving_average.go | starcoder |
package webp
import (
"image/color"
"reflect"
)
type MemPColor struct {
Channels int
DataType reflect.Kind
Pix PixSlice
}
func (c MemPColor) RGBA() (r, g, b, a uint32) {
if len(c.Pix) == 0 {
return
}
switch c.Channels {
case 1:
switch reflect.Kind(c.DataType) {
case reflect.Uint8:
return colo... | image_color.go | 0.550607 | 0.575111 | image_color.go | starcoder |
package redux
// Prerequisite from a source to a target.
type Prerequisite struct {
Path string // path back to target of prerequisite.
*Metadata // target's metadata upon record creation.
}
// PutPrerequisite stores the given prerequisite using a key based on the event and hash.
func (f *File) PutPrer... | prerequisite.go | 0.775265 | 0.540318 | prerequisite.go | starcoder |
package bindings
import "strconv"
type tFloat32 struct {
listeners []Float32Listener
value float32
filter Float32Filter
}
type tFloat32AB struct {
tFloat32
parentA Float32
parentB Float32
}
type tFloat32BooleanAB struct {
tBoolean
parentA Float32
parentB Float32
}
type tFloat32Divide struct {
tFlo... | float32.go | 0.760473 | 0.504883 | float32.go | starcoder |
package proto
import "github.com/go-faster/errors"
// Compile-time assertions for ColNullableOf.
var (
_ ColInput = (*ColNullableOf[string])(nil)
_ ColResult = (*ColNullableOf[string])(nil)
_ Column = (*ColNullableOf[string])(nil)
_ ColumnOf[Nullable[string]]... | proto/col_nullable_of.go | 0.665519 | 0.423995 | col_nullable_of.go | starcoder |
package dhcpv6
// This module defines the OptIAForPrefixDelegation structure.
// https://www.ietf.org/rfc/rfc3633.txt
import (
"encoding/binary"
"fmt"
)
type OptIAForPrefixDelegation struct {
iaId [4]byte
t1 uint32
t2 uint32
options []byte
}
func (op *OptIAForPrefixDelegation) Code() OptionCode {... | dhcpv6/option_prefixdelegation.go | 0.698741 | 0.424293 | option_prefixdelegation.go | starcoder |
package origins
// Comparator is a function type that compares two facts for the purposes of sorting.
// It returns true if the first fact should come before the second fact.
type Comparator func(f1, f2 *Fact) bool
const (
compTrue int8 = iota - 1
compEqual
compFalse
)
// identComparator compares two Ident values... | comparator.go | 0.837587 | 0.552238 | comparator.go | starcoder |
package biooperators
import (
"fmt"
"math"
"sort"
"github.com/CRAB-LAB-NTNU/PPS-BS/types"
)
/*CalculateIdealPoints calculates the ideal point in a population,
IE. the point in the search space by picking the best function value for all objective functions.
*/
func CalculateIdealPoints(population []types.Individu... | biooperators/populations.go | 0.607197 | 0.484441 | populations.go | starcoder |
package p352
/**
Given a data stream input of non-negative integers a1, a2, ..., an, ...,
summarize the numbers seen so far as a list of disjoint intervals.
For example, suppose the integers from the data stream are 1, 3, 7, 2, 6, ...,
then the summary will be:
[1, 1]
[1, 1], [3, 3]
[1, 1], [3, 3], [7, 7]
[1, 3], ... | algorithms/p352/352.go | 0.91181 | 0.835316 | 352.go | starcoder |
package algo
import (
"github.com/puppetlabs/leg/datastructure"
"github.com/puppetlabs/leg/graph"
)
const (
PrimMinimumSpanningTreeSupportedFeatures = graph.DeterministicIteration
)
type PrimMinimumSpanningTree struct {
TotalWeight float64
features graph.GraphFeature
es graph.MutableEdgeSet
}
func (ms... | graph/algo/prim.go | 0.653459 | 0.446917 | prim.go | starcoder |
package src
import (
"bytes"
"math/rand"
)
// Field represents a two-dimensional field of cells.
type Field struct {
states [][]bool
width int
height int
}
// NewField returns an empty field of the specified width and height.
func NewField(w, h int) *Field {
s := make([][]bool, h)
for i := range s {
s[i] =... | src/conways_game_of_life.go | 0.797281 | 0.451266 | conways_game_of_life.go | starcoder |
package yrsensor
import (
"fmt"
"github.com/perbu/yrpoller/timestream"
log "github.com/sirupsen/logrus"
"time"
)
func interpolateObservations(first *Observation, last *Observation, when time.Time) Observation {
var obs Observation
timeDelta := last.Time.Sub(first.Time).Seconds() // Typically 60mins
howFarInto ... | yrsensor/emitter.go | 0.668772 | 0.46393 | emitter.go | starcoder |
package scene
import (
"image/color"
"github.com/pankona/gomo-simra/simra"
"github.com/pankona/gomo-simra/simra/image"
)
const (
// ScreenWidth is screen width
ScreenWidth = 1080 / 2
// ScreenHeight is screen height
ScreenHeight = 1920 / 2
)
// Title represents a scene object for Title
type Title struct {
s... | examples/animation1/scene/title.go | 0.616936 | 0.437283 | title.go | starcoder |
package util
import (
"fmt"
"math"
"reflect"
)
// Reads a packed struct.
// place must point to a struct with primitive members only
func ReadPackedStruct(bytes []byte, place interface{}) error {
if place == nil {
return fmt.Errorf("error: ReadPackedStruct(): place is nil")
}
val := reflect.Indirect(reflect.... | util/struct.go | 0.580709 | 0.409132 | struct.go | starcoder |
package ast
import (
"github.com/ajz01/calc/token"
)
type Node interface {
Pos() token.Pos // position of first character belonging to the node
End() token.Pos // position of first character immediately after the node
}
type Expr interface {
Node
exprNode()
}
type Field struct {
Names []*Ident
Type Expr
Ta... | ast/ast.go | 0.628179 | 0.411998 | ast.go | starcoder |
package iso20022
// Instruction from an investor to sell investment fund units back to the fund.
type RedemptionOrder15 struct {
// Unique and unambiguous identifier for the order, as assigned by the instructing party.
OrderReference *Max35Text `xml:"OrdrRef"`
// Unique and unambiguous investor's identification o... | RedemptionOrder15.go | 0.867836 | 0.423935 | RedemptionOrder15.go | starcoder |
package main
import (
"fmt"
"math"
"os"
yaml "github.com/goccy/go-yaml"
"github.com/soypat/godesim"
"github.com/soypat/godesim/state"
)
// Declare simulation constants: softening coefficient and big G
const softening, G float64 = 1.0, 6.6743e-11
var sin, pi = math.Sin, math.Pi
type body struct {
name string... | _examples/n-body/nbody.go | 0.556882 | 0.423875 | nbody.go | starcoder |
package ast
import (
"fmt"
"strings"
"github.com/huandu/go-clone"
"github.com/stackoverflow/novah-go/data"
)
type KindType = int
const (
STAR KindType = iota
CTOR
)
type Kind struct {
Type KindType
Arity int
}
func (k Kind) String() string {
if k.Type == STAR {
return "Type"
}
return data.JoinToStri... | compiler/ast/type.go | 0.572723 | 0.451568 | type.go | starcoder |
package successor
func (s *State) feasible(index1 int) []int {
f := make([]int, 0, len(s.domain))
for _, index2 := range s.domain {
// (i j) would create a cycle
if s.partial[index1] == s.partial[index2] {
continue
}
if intersect(s.partial[index1], s.succ[index2]) || intersect(s.pred[index1], s.partial[... | tsppd/solvers/successor/next.go | 0.566258 | 0.419886 | next.go | starcoder |
// the fastcheck.OppoBloomFilter provides two methods instead of one, a contains and an add. This makes it possible to
// check and then optionally add the value. It is possible that two threads may race and add it multiple times
package fastcheck
import (
"bytes"
"context"
"crypto/md5" //nolint:gosec
"errors"
"... | fastcheck/oppobloom.go | 0.622459 | 0.500061 | oppobloom.go | starcoder |
package lexer
import (
"regexp"
"token"
)
type Pattern struct {
expr *regexp.Regexp
kind token.TokenType
}
type Error struct {
RowIndex int
ColumnIndex int
Value string
}
type Lexer struct {
patterns []Pattern
whiteSpacesReg *regexp.Regexp
absorbErrorReg *regexp.Regexp
rowIndex int
columtIndex int
to... | src/lexer/lexer.go | 0.661923 | 0.448426 | lexer.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.