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 v1
import (
"time"
"encoding/json"
)
type Time struct {
time.Time `json:"-"`
}
func (t Time) DeepCopy() Time {
return t
}
// String returns the representation of the time.
func (t Time) String() string {
return t.Time.String()
}
// NewTime returns a wrapped instance of the provided time
func NewTime(t... | apimachinery/pkg/apigroups/meta/v1/time.go | 0.87266 | 0.464476 | time.go | starcoder |
package redis_rate
import "github.com/go-redis/redis/v8"
// Copyright (c) 2017 <NAME>
// https://github.com/rwz/redis-gcra/blob/master/vendor/perform_gcra_ratelimit.lua
var allowN = redis.NewScript(`
-- this script has side-effects, so it requires replicate commands mode
-- redis-cli --ldb --eval allown.lua mykey , 3... | lua.go | 0.726911 | 0.408041 | lua.go | starcoder |
package kernel
/*
A numeric-heavy and struct heavy bench where we get a sequence of triangle
strips and a transform and find the geometric center of them all. Intentionally
written with some unneeded complexity to include that in the optimization testing.
*/
import (
"math"
"runtime"
"sync"
"testing"
)
var sha... | test/benchmarks/bench_transtri.go | 0.583441 | 0.52902 | bench_transtri.go | starcoder |
package main
import (
"fmt"
tor "github.com/NullHypothesis/zoossh"
cluster "github.com/NullHypothesis/mlgo/cluster"
levenshtein "github.com/arbovm/levenshtein"
statistics "github.com/mcgrew/gostats"
)
// RelayDistances contains a slice for relays and their corresponding distance
// to another relay.
type RelayD... | distance.go | 0.778733 | 0.456168 | distance.go | starcoder |
package kv
import (
"encoding/json"
"reflect"
)
//KV is a key/value entry and a struct which implements helper methods to help with retrial of data types from value.
type KV struct {
key string
value interface{}
}
func New(key string, value interface{}) *KV {
return &KV{
key: key,
value: value,
}
}
fu... | vendor/github.com/modfin/kv/kv.go | 0.786254 | 0.441974 | kv.go | starcoder |
package orbits
import (
"image"
"image/color"
"image/png"
"math"
"os"
"github.com/Balise42/marzipango/params"
)
type PointOrbit struct {
X float64
Y float64
Translation float64
Factor float64
}
type LineOrbit struct {
A float64
B float64
C float64
... | fractales/orbits/orbit.go | 0.774413 | 0.505188 | orbit.go | starcoder |
package toml
// tomlType represents any Go type that corresponds to a TOML type.
// While the first draft of the TOML spec has a simplistic type system that
// probably doesn't need this level of sophistication, we seem to be militating
// toward adding real composite types.
type tomlType interface {
typeStrin... | vendor/github.com/BurntSushi/toml/type_check.go | 0.803598 | 0.403743 | type_check.go | starcoder |
package kyber
import (
"golang.org/x/crypto/sha3"
)
//Poly represents a polynomial of deg n with coefs in [0, Q)
type Poly [n]int16
func add(a, b Poly) Poly {
var c Poly
for i := 0; i < n; i++ {
c[i] = a[i] + b[i]
}
return c
}
//sub substracts b from a without normalization
func sub(a, b Poly) Poly {
var c ... | crystals-kyber/poly.go | 0.635222 | 0.417271 | poly.go | starcoder |
package main
import "errors"
import "fmt"
import "math"
type coordinate struct {
x int
y int
}
/*
iterate through the 2-d int slice to find all the guard locations, and store them somewhere
iterate through entire array, push all elements onto a queue
pop elements off the queue and calcuate distance from a... | floorPlan.go | 0.687 | 0.405478 | floorPlan.go | starcoder |
package main
import (
"AoC2021/aoc_fun"
"io/ioutil"
"log"
"os"
"strings"
)
type Record struct {
signal []string
expect []string
}
type Data struct {
states []Record
}
func parse(line string, data *Data) {
if len(line) == 0 {
return
}
parts := strings.Split(line, " | ")
signal := strings.Fields(parts[0... | d08/d08.go | 0.511473 | 0.418756 | d08.go | starcoder |
// This file implements type parameter inference given
// a list of concrete arguments and a parameter list.
package types
import (
"go/token"
"strings"
)
// infer returns the list of actual type arguments for the given list of type parameters tparams
// by inferring them from the actual arguments args for the pa... | src/go/types/infer.go | 0.520253 | 0.466238 | infer.go | starcoder |
package typegraph
const ASSIGNABLE_OP_VALUE = "value"
type typerefGetter func(containingType TypeReference) TypeReference
// operatorParameter represents a single expected parameter on an operator.
type operatorParameter struct {
Name string // The name of the parameter.
getParameterType typere... | graphs/typegraph/operators.go | 0.826887 | 0.633934 | operators.go | starcoder |
package giamesoft
import (
"image/draw"
"github.com/GUMI-golang/giame"
"image/color"
"image"
)
func RasterFiller(dst draw.Image, ws *Workspace, min image.Point, f giame.Filler) {
f.ToBound(image.Rect(0,0,ws.Width, ws.Height))
for x := 0; x < ws.Width; x++ {
for y := 0; y < ws.Height; y++ {
v := ws.Get(x, ... | giamesoft/DST_Filler.go | 0.54698 | 0.471953 | DST_Filler.go | starcoder |
package state
import . "api"
func (l *luaState) Compare(idx1, idx2 int, op CompareOp) bool {
a := l.stack.get(idx1)
b := l.stack.get(idx2)
switch op {
case LUA_OPEQ: return _eq(a, b)
case LUA_OPLT: return _lt(a, b)
case LUA_OPLE: return _le(a, b)
case LUA_OPGT: return _gt(a, b)
case LUA_OPGE: return _ge(a, b)... | src/state/api_ compare.go | 0.529507 | 0.510192 | api_ compare.go | starcoder |
package internal
type expr interface {
accept(exprVisitor) R
}
type exprVisitor interface {
visitListExpr(expr *listExpr) R
visitDictionaryExpr(expr *dictionaryExpr) R
visitAssignExpr(expr *assignExpr) R
visitAccessExpr(expr *accessExpr) R
visitBinaryExpr(expr *binaryExpr) R
visitCallExpr(expr *callExpr) R
vi... | internal/expr.go | 0.530723 | 0.435421 | expr.go | starcoder |
package templatecheck
import (
"reflect"
"text/template/parse"
)
func checkLen(s *state, dot reflect.Type, args []parse.Node) reflect.Type {
arg := args[0]
argType, isLiteral := s.evalArg(dot, arg)
if isLiteral {
if argType == stringType {
return intType
}
s.errorf("len of %s", arg)
}
argType = indir... | funcs.go | 0.566978 | 0.430985 | funcs.go | starcoder |
package calc
import "math"
type binaryExpr struct {
left Expr
right Expr
}
type addExpr binaryExpr
func (x addExpr) Eval(ctx EvalContext) Number {
return x.left.Eval(ctx) + x.right.Eval(ctx)
}
type minusExpr binaryExpr
func (x minusExpr) Eval(ctx EvalContext) Number {
return x.left.Eval(ctx) - x.right.Eval(c... | internal/calc/exprs.go | 0.825167 | 0.524577 | exprs.go | starcoder |
package ent
import (
"fmt"
"strings"
"entgo.io/ent/dialect/sql"
"github.com/robinhuiser/fca-emu/ent/bank"
"github.com/robinhuiser/fca-emu/ent/branch"
)
// Branch is the model entity for the Branch schema.
type Branch struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// BranchCode ho... | ent/branch.go | 0.661923 | 0.416263 | branch.go | starcoder |
package core
import (
"math"
)
// Bounds3d represents a 3D bounding box
type Bounds3d struct {
MinPos *Vector3d // Minimum position
MaxPos *Vector3d // Maximum position
}
// NewBounds3d returns a new Bounds3d pointer
func NewBounds3d() *Bounds3d {
b := new(Bounds3d)
b.MinPos = NewVector3d(Infinity, Infinity, In... | src/core/bounds3d.go | 0.867162 | 0.661014 | bounds3d.go | starcoder |
package assert
import (
"fmt"
"regexp"
"strconv"
"strings"
)
const (
Nil = iota
Boolean
Number
String
)
type Value struct {
val interface{}
vType uint8
}
func NewValue(v interface{}) Value {
res := Value{
val: v,
vType: Nil,
}
if v == nil {
return res
}
switch r := v.(type) {
case bool:
... | assert/value.go | 0.579876 | 0.425486 | value.go | starcoder |
package ijson
// Set sets the provide value to the path. It creates the structure if not present.
// An error is returned if it fails to resolve the path OR encounters different type than expected by path.
func Set(data, value interface{}, path ...string) (interface{}, error) {
return set(data, value, false, path...)... | set.go | 0.754553 | 0.566318 | set.go | starcoder |
package logr
import (
"fmt"
"time"
)
// Any picks the best supported field type based on type of val.
// For best performance when passing a struct (or struct pointer),
// implement `logr.LogWriter` on the struct, otherwise reflection
// will be used to generate a string representation.
func Any(key string, val int... | vendor/github.com/mattermost/logr/v2/fieldapi.go | 0.873956 | 0.465387 | fieldapi.go | starcoder |
package vector
import (
"fmt"
"math"
"strings"
)
type Algorithm interface {
Compare(v1, v2 *Vector) (float64, error)
}
type simpsonComparator struct {
}
func (sc *simpsonComparator) Compare(v1, v2 *Vector) (float64, error) {
intersect := v1.Intersect(v2)
return intersect.Length() / math.Min(v1.Length(), v2.Le... | vector/compare.go | 0.665845 | 0.521532 | compare.go | starcoder |
package packp
/*
A nice way to trace the real data transmitted and received by git, use:
GIT_TRACE_PACKET=true git ls-remote http://github.com/src-d/go-git
GIT_TRACE_PACKET=true git clone http://github.com/src-d/go-git
Here follows a copy of the current protocol specification at the time of
this writing.
(Please n... | vendor/gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/doc.go | 0.725746 | 0.415788 | doc.go | starcoder |
package goheaps
import (
"errors"
"math"
)
// The Heap type that holds a list of Nodes and a Type
type Heap struct {
Nodes []Node
Type string
}
// Create a new Heap strucutre with the given nodes and heapType (type is a reserved word)
func NewHeap(nodes []Node, heapType string) (*Heap, error) {
// 'Validat... | heap.go | 0.635449 | 0.507446 | heap.go | starcoder |
package cryptotrader
import (
"fmt"
"strings"
)
// TradeVolumeType represents the way to calculate the trade volume
type TradeVolumeType int
const (
// TVTFixed use a fixed volume (quote asset) for trading
TVTFixed TradeVolumeType = iota
// TVTPercent use a percentage of the available quote asset for trading
... | tradeconfig.go | 0.680454 | 0.54958 | tradeconfig.go | starcoder |
package aiplatform
import (
context "context"
cmpopts "github.com/google/go-cmp/cmp/cmpopts"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
proto "google.golang.org/protobuf/proto"
protocmp "google.golang.org/protobuf/testing/protocmp"
fieldmaskpb "google.golang.org/protobuf/types/... | proto/gen/googleapis/cloud/aiplatform/v1/featurestore_service_aiptest.pb.go | 0.610105 | 0.48182 | featurestore_service_aiptest.pb.go | starcoder |
package solver
const (
nbMaxRecent = 50 // How many recent LBD values we consider; "X" in papers about LBD.
triggerRestartK = 0.8
nbMaxTrail = 5000 // How many elements in queueTrail we consider; "Y" in papers about LBD.
postponeRestartT = 1.4
)
type queueData struct {
totalNb int // Current to... | vendor/github.com/crillab/gophersat/solver/lbd.go | 0.501953 | 0.437042 | lbd.go | starcoder |
package assert
import (
"encoding/json"
"math/big"
"reflect"
"github.com/zoncoen/scenarigo/errors"
)
type compareType int
const (
compareGreater compareType = iota
compareGreaterOrEqual
compareLess
compareLessOrEqual
)
// compareNumber compares expected with actual based on compareType.
// If the compariso... | assert/compare.go | 0.627723 | 0.492798 | compare.go | starcoder |
package core
import (
"bytes"
"io/ioutil"
"log"
"strconv"
"strings"
"github.com/Knetic/govaluate"
)
// CompositeEstimator returns a similarity function based on
// compositions of simpler similarity expressions. The user needs to provide a
// formula containing the expression of the similarity function, e.g.:
... | core/similaritycomposite.go | 0.698638 | 0.560493 | similaritycomposite.go | starcoder |
package unicode
// Bit masks for each code point under U+0100, for fast lookup.
const (
pC = 1 << iota // a control character.
pP // a punctuation character.
pN // a numeral.
pS // a symbolic character.
pZ // a spacing character.
pLu ... | src/unicode/graphic.go | 0.650911 | 0.4856 | graphic.go | starcoder |
package docs
import (
"bytes"
"fmt"
"strings"
"text/template"
"github.com/Jeffail/benthos/v3/internal/bloblang"
"github.com/Jeffail/benthos/v3/internal/bloblang/parser"
"github.com/Jeffail/benthos/v3/internal/bloblang/query"
)
// LintBloblangMapping is function for linting a config field expected to be a
// b... | internal/docs/bloblang.go | 0.657428 | 0.470433 | bloblang.go | starcoder |
package modbus
import (
"errors"
"fmt"
"github.com/aldas/go-modbus-client/packet"
)
const (
// FieldTypeBit represents single bit out 16 bit register. Use `Field.Bit` (0-15) to indicate which bit is meant.
FieldTypeBit FieldType = 1
// FieldTypeByte represents single byte of 16 bit, 2 byte, single register. Use... | builder.go | 0.811003 | 0.520618 | builder.go | starcoder |
package main
import (
utils "github.com/Jordi-Jaspers/AdventOfCode2021/Util"
"log"
"math"
)
type Vector struct {
start Coordinate
end Coordinate
slope float64
}
type Coordinate struct {
x int
y int
}
type Space struct {
width int
height int
overlap [][]int
}
const MINIMUM_OVERLAP = 2
func main() {... | Day 5 - Hydrothermal Venture/5.2/main.go | 0.610918 | 0.442938 | main.go | starcoder |
package tick
import (
"sort"
"github.com/influxdata/kapacitor/pipeline"
"github.com/influxdata/kapacitor/tick/ast"
)
// AlertNode converts the Alert pipeline node into the TICKScript AST
type AlertNode struct {
Function
}
// NewAlert creates an Alert function builder
func NewAlert(parents []ast.Node) *AlertNode... | pipeline/tick/alert.go | 0.531209 | 0.408513 | alert.go | starcoder |
package simplemerkle
import (
"math"
"github.com/zarbchain/zarb-go/crypto/hash"
)
var hasher func([]byte) hash.Hash
func init() {
hasher = hash.CalcHash
}
type Tree struct {
merkles []*hash.Hash
}
// nextPowerOfTwo returns the next highest power of two from a given number if
// it is not already a power of tw... | libs/merkle/merkle.go | 0.768646 | 0.562357 | merkle.go | starcoder |
// Package day12 solves AoC 2020 day 12.
package day12
import (
"fmt"
"github.com/fis/aoc/glue"
"github.com/fis/aoc/util"
)
func init() {
glue.RegisterSolver(2020, 12, glue.LineSolver(solve))
}
func solve(lines []string) ([]string, error) {
actions := parseInput(lines)
t := newTurtle()
t.move(actions)
p1 ... | 2020/day12/day12.go | 0.688887 | 0.409752 | day12.go | starcoder |
package collection
import (
"encoding/json"
"errors"
"math"
"math/rand"
"time"
"github.com/shopspring/decimal"
)
type NumberArrayCollection struct {
value []decimal.Decimal
BaseCollection
}
// Sum returns the sum of all items in the collection.
func (c NumberArrayCollection) Sum(key ...string) decimal.Decim... | number_array_collection.go | 0.763043 | 0.417034 | number_array_collection.go | starcoder |
package binary
import (
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/encoding"
"github.com/matrixorigin/matrixone/pkg/vectorize/power"
"github.com/ma... | pkg/sql/plan2/function/builtin/binary/power.go | 0.5564 | 0.51013 | power.go | starcoder |
package zkbpp
//This file contains declaration for all fast sha gates for Z2
import "math/big"
//================================================================
// UTILS
//================================================================
func bit(x uint32, i int) uint32 {
return x >> i & 1
}
func setBit(x uint32,... | CRISP_go/zkbpp/gates_z2_shaFast.go | 0.534612 | 0.431045 | gates_z2_shaFast.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// WorkbookChartPoint
type WorkbookChartPoint struct {
Entity
// Encapsulates the format properties chart point. Read-only.
format WorkbookChartPointF... | models/workbook_chart_point.go | 0.742141 | 0.429908 | workbook_chart_point.go | starcoder |
package block
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/entity"
"github.com/df-mc/dragonfly/server/entity/damage"
"github.com/df-mc/dragonfly/server/event"
"github.com/df-mc/dragonfly/server/world"
"github.com/df-mc/dragonfly/server/world/sound"
"math/rand"
"tim... | server/block/lava.go | 0.64791 | 0.414306 | lava.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
func main() {
lines := readFile("input.txt")
validPolicyOne := 0
validPolicyTwo := 0
for _, line := range lines {
if IsValidPasswordPolicyOne(line) {
validPolicyOne++
}
if IsValidPasswordPolicyTwo(line) {
validPolicyTwo++
}
... | 2020/day2/day2.go | 0.725551 | 0.437944 | day2.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/co... | opc/pattern-diamond.go | 0.627152 | 0.576661 | pattern-diamond.go | starcoder |
package kea
import "github.com/MaxSlyugrov/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, d 'di' MMMM 'di' y", Long: "d 'di' MMMM 'di' y", Medium: "d MMM y", Short: "d/M/y"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:s... | resources/locales/kea/calendar.go | 0.510252 | 0.403626 | calendar.go | starcoder |
package easing
import "math"
const pi2 = math.Pi / 2
/**
* Easing equation function for a simple linear tweening, with no easing.
*
* @param t Current time (in frames or seconds).
* @return The correct value.
*/
//func None(t float64) float64
//{
// return t;
//}
/**
* Easing equation function for a quad... | animation/easing/easing.go | 0.970933 | 0.735689 | easing.go | starcoder |
package matutil
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
// New safely creates a new dense matrix.
func New(r, c int, data []float64) (*mat.Dense, error) {
var o *mat.Dense
if err := safe(func() error {
o = mat.NewDense(r, c, data)
return nil
}); err != nil {
return nil, err
}
return o, nil
}
// Dot p... | matutil/dense.go | 0.777975 | 0.511839 | dense.go | starcoder |
package set
import (
"fmt"
"reflect"
)
const minSize = 8
// Set is set collection of general type.
// The zero value of Set is an empty instance ready to use. A zero Set
// value shall not be copied, or it may result incorrect behavior.
type Set struct {
m map[interface{}]struct{}
}
// NewSet creates a Set insta... | set/set.go | 0.728362 | 0.562657 | set.go | starcoder |
package holtwinters
// This holt-winters code copied from graphite's functions.py)
// It's "mostly" the same as a standard HW forecast
import (
"math"
)
func holtWintersIntercept(alpha, actual, lastSeason, lastIntercept, lastSlope float64) float64 {
return alpha*(actual-lastSeason) + (1-alpha)*(lastIntercept+lastS... | expr/holtwinters/hw.go | 0.757525 | 0.561515 | hw.go | starcoder |
package optimus
import (
"fmt"
"math"
"go.uber.org/zap"
)
type GreedyLinearRegressionModelConfig struct {
WeightLimit float64 `yaml:"weight_limit" default:"1e-3"`
ExhaustionLimit int `yaml:"exhaustion_limit" default:"128"`
Model regressionModelFactory `yaml:"regr... | optimus/engine_greedy.go | 0.765769 | 0.415492 | engine_greedy.go | starcoder |
package tensor
type maskedReduceFn func(Tensor) interface{}
// MaskedReduce applies a reduction function of type maskedReduceFn to mask, and returns
// either an int, or another array
func MaskedReduce(t *Dense, retType Dtype, fn maskedReduceFn, axis ...int) interface{} {
if len(axis) == 0 || t.IsVector() {
return... | dense_mask_inspection.go | 0.876291 | 0.544438 | dense_mask_inspection.go | starcoder |
package cflag
import (
"flag"
"time"
"github.com/goaltools/xflag/cflag/types"
)
// Strings is an equivalent of flag.String but for []string value.
// It defines a slice flag with the specified name, default value,
// and usage string. The returned value is the address of a string
// slice variable that stores the... | cflag/slices.go | 0.728748 | 0.454775 | slices.go | starcoder |
package transcoder
import (
"fmt"
"v.io/v23/vdl"
)
// an array where the index corresponds to the bit index in the allocation
// and the value is the tag (here representing vdlIndex+1)
type structBitAllocation []int
// allocateStructBits performs the naive allocation of fields in the struct,
// literally laying ... | go/src/v.io/x/mojo/transcoder/struct_layout.go | 0.664214 | 0.460956 | struct_layout.go | starcoder |
package ciphertools
type Cipher struct {
p [18]uint32
s0, s1, s2, s3 [256]uint32
Buffer []byte
}
func (c *Cipher) initCipher() {
copy(c.p[0:], p[0:])
copy(c.s0[0:], s0[0:])
copy(c.s1[0:], s1[0:])
copy(c.s2[0:], s2[0:])
copy(c.s3[0:], s3[0:])
c.Buffer = make([... | blowfish/ciphertools/cipher.go | 0.796015 | 0.449695 | cipher.go | starcoder |
package util
import (
"fmt"
"math"
)
// IntersectionTValsP obtains values of t for each line for where they intersect. Actual intersection =>
// both are in [0,1]
func IntersectionTValsP(p1, p2, p3, p4 []float64) ([]float64, error) {
return IntersectionTVals(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], p4[0], p4[1])
... | util/math.go | 0.827898 | 0.57069 | math.go | starcoder |
package ln
import (
"math"
"math/rand"
)
type Sphere struct {
Center Vector
Radius float64
Box Box
}
func NewSphere(center Vector, radius float64) *Sphere {
min := Vector{center.X - radius, center.Y - radius, center.Z - radius}
max := Vector{center.X + radius, center.Y + radius, center.Z + radius}
box := ... | ln/sphere.go | 0.710226 | 0.469824 | sphere.go | starcoder |
package main
import (
"fmt"
"math/rand"
"time"
)
func degrees() int {
return rand.Intn((450 - 300) + 400)
}
func preheat() string {
firstStep := fmt.Sprintf("Preheat oven to %d degrees \n", degrees())
return firstStep
}
func cookTime() int {
rand.Seed(time.Now().Unix())
return rand.Intn((30 - 20) + 30)
}
fun... | steps.go | 0.54359 | 0.466785 | steps.go | starcoder |
package stringfuncs
// (c) <NAME> 2022
import (
"strings"
)
func In(LookingIn string, LookingFor rune) (int) {
for Index, Element := range LookingIn {
if Element == LookingFor {
return Index
}
}
return -1
}
func In_string(LookingIn []string, LookingFor string) (int) ... | StringFuncs.go | 0.682256 | 0.430327 | StringFuncs.go | starcoder |
package ffnn
import (
"gonum.org/v1/gonum/mat"
"../utils/matrices/ops"
)
type FFNetwork struct {
// The layers, in strict order.
layers []*FFLayer
// ********************************
// Training-related fields start here.
// ********************************
// The default learning rate, needed for training.
... | ffnn/network.go | 0.717606 | 0.620507 | network.go | starcoder |
package main
import (
"fmt"
"math"
"os"
"time"
"github.com/ChristopherRabotin/gokalman"
"github.com/ChristopherRabotin/smd"
"github.com/gonum/matrix/mat64"
)
func main() {
// Define the times
startDT := time.Now()
endDT := startDT.Add(time.Duration(24) * time.Hour)
// Define the orbits
leo := smd.NewOrbi... | examples/statOD/batch/main.go | 0.660063 | 0.461563 | main.go | starcoder |
Discrete Fourier Transform
See:
https://en.wikipedia.org/wiki/Discrete_Fourier_transform
https://github.com/takatoh/fft
*/
//-----------------------------------------------------------------------------
package core
import (
"math"
"math/bits"
"math/cmplx"
)
//--------------------------------------------------... | core/dft.go | 0.832849 | 0.54468 | dft.go | starcoder |
package finnhub
import (
"encoding/json"
)
// FinancialStatements struct for FinancialStatements
type FinancialStatements struct {
// Symbol of the company.
Symbol *string `json:"symbol,omitempty"`
// An array of map of key, value pairs containing the data for each period.
Financials *[]map[string]interface{} `... | model_financial_statements.go | 0.683314 | 0.431405 | model_financial_statements.go | starcoder |
package processor
import (
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/message"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/response"
"github.com/Jeffail/benthos/lib/types"
)
//------------------------------------------------------------------------------
f... | lib/processor/split.go | 0.765374 | 0.418756 | split.go | starcoder |
package staticarray
import (
"github.com/influxdata/flux/array"
"github.com/influxdata/flux/memory"
"github.com/influxdata/flux/semantic"
)
type booleans struct {
data []bool
alloc *memory.Allocator
}
func Boolean(data []bool) array.Boolean {
return &booleans{data: data}
}
func (a *booleans) Type() semantic.... | internal/staticarray/bool.go | 0.64969 | 0.466542 | bool.go | starcoder |
package image2d
import (
"errors"
"image"
"image/color"
"image/draw"
"github.com/adrianderstroff/pbr/pkg/cgm"
gl "github.com/adrianderstroff/pbr/pkg/core/gl"
"github.com/mdouchement/hdr"
"github.com/mdouchement/hdr/hdrcolor"
)
// ConvertToPowerOfTwo subsamples an image to be quadratic and be a power of two.
... | pkg/view/image/image2d/util.go | 0.81928 | 0.436982 | util.go | starcoder |
// Package kunstruct provides unstructured from api machinery and factory for creating unstructured
package kunstruct
import (
"fmt"
"strconv"
"strings"
)
// A PathSection contains a list of nested fields, which may end with an
// indexable value. For instance, foo.bar resolves to a PathSection with 2
// fields a... | api/k8sdeps/kunstruct/helper.go | 0.551332 | 0.591251 | helper.go | starcoder |
package gm
import (
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/utl"
)
// ExtractSurfaces returns a new NURBS representing a boundary of this NURBS
func (o *Nurbs) ExtractSurfaces() (surfs []*Nurbs) {
if o.gnd == 1 {
return
}
nsurf := o.gnd * 2
surfs = make([]*Nurbs, nsurf)
var ords [][]int
var kn... | gm/topologynurbs.go | 0.655115 | 0.420957 | topologynurbs.go | starcoder |
package wordchain
import (
"errors"
)
// Errors that can be returned from the Build function.
var (
// ErrEmpty is returned when both of the words are empty strings.
ErrEmpty = errors.New("both words must not be empty")
// ErrNotInDictionary is returned when either of the words could not be found in the provided... | wordchain/build.go | 0.737253 | 0.470615 | build.go | starcoder |
package list
import (
"fmt"
"github.com/flowonyx/functional"
"github.com/flowonyx/functional/errors"
"golang.org/x/exp/constraints"
)
// Min finds the minimum value in values.
func Min[T constraints.Ordered](values ...T) (T, error) {
if len(values) == 0 {
return *(new(T)), fmt.Errorf("%w: Min cannot operate o... | list/compare.go | 0.826991 | 0.620938 | compare.go | starcoder |
package iso20022
// Specifies corporate action dates.
type CorporateActionDate4 struct {
// Date/time at which the coupons are to be/were submitted for payment of interest.
CouponClippingDate *DateFormat4Choice `xml:"CpnClpngDt,omitempty"`
// Last date/time at which a holder can consent to the changes sought by t... | CorporateActionDate4.go | 0.758332 | 0.469885 | CorporateActionDate4.go | starcoder |
package mandelbrot
import (
"image"
"image/color"
"image/jpeg"
"image/png"
"io"
)
// ColorFucn is what is used to generate the colorscheme
// It takes the number of iterations from the mandelbrot
// calculation and returns a color DefaultColorize is an
// extremely basic example
type ColorFunc func(int) color.RG... | generator.go | 0.748904 | 0.51623 | generator.go | starcoder |
package iterator
import (
"context"
"github.com/cayleygraph/cayley/graph/refs"
"github.com/cayleygraph/quad"
)
// Count iterator returns one element with size of underlying iterator.
type Count struct {
it Shape
qs refs.Namer
}
// NewCount creates a new iterator to count a number of results from a provided sub... | graph/iterator/count.go | 0.727492 | 0.452899 | count.go | starcoder |
package input
import (
"errors"
"fmt"
"strconv"
"github.com/benthosdev/benthos/v4/internal/batch/policy"
"github.com/benthosdev/benthos/v4/internal/component/input"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
iprocessor "github.com/benthosdev/benthos/v4/internal/component/processor"
"github.... | internal/old/input/broker.go | 0.734024 | 0.662169 | broker.go | starcoder |
package poly
import "github.com/adamcolton/geom/calc/fbuf"
// Coefficients wraps the concept of a list of float64. It can express the order
// of the polynomial and return any coeffcient.
type Coefficients interface {
Coefficient(idx int) float64
Len() int
}
// Slice fulfills Coefficients with a []float64.
type Sl... | calc/poly/coefficients.go | 0.881608 | 0.79909 | coefficients.go | starcoder |
package tallytest
import (
"fmt"
"sort"
"testing"
"github.com/stretchr/testify/assert"
"github.com/uber-go/tally"
)
// AssertCounterValue asserts that the given counter has the expected value.
func AssertCounterValue(t *testing.T, expected int64, s tally.Snapshot, name string, tags map[string]string) bool {
i... | src/x/tallytest/tallytest.go | 0.732113 | 0.569613 | tallytest.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// PlannerAssignedToTaskBoardTaskFormat
type PlannerAssignedToTaskBoardTaskFormat struct {
Entity
// Dictionary of hints used to order tasks on the Assign... | models/planner_assigned_to_task_board_task_format.go | 0.602763 | 0.417925 | planner_assigned_to_task_board_task_format.go | starcoder |
package interpreter
import (
"strconv"
)
/*
* This file contains the defnition of tokens in the system
*/
//Token is the parsed word and possible nodes a word associated to
type Token struct {
//Pos is the position of the token in the root sentence
Pos int
//Word is the match word corresponding to the token
... | interpreter/token.go | 0.542136 | 0.477615 | token.go | starcoder |
package detect
import (
"context"
"errors"
"github.com/rs/zerolog/log"
)
// DetectOptions contains the options for detecting the environment.
type DetectOptions struct {
// Platform limits the detection to find only environments for the given platform.
Platform string
// TargetType limits the detection to fin... | internal/detect/autodetect.go | 0.798423 | 0.418459 | autodetect.go | starcoder |
package godouble
import "fmt"
// An Expectation verifies a count against an expected Value
type Expectation interface {
// Is the expectation met, complete with count?
Met(count int) bool
}
//A Completion is an expectation that can indicate that further calls will fail to meet the expectation
//Expectations that a... | godouble/expectation.go | 0.739046 | 0.650398 | expectation.go | starcoder |
package digit
import (
"math/big"
"sort"
"strconv"
"github.com/jackytck/gowboy/common"
)
// SliceInt returns the individual digits as a slice of int.
func SliceInt(n int) []int {
if n == 0 {
return []int{0}
}
var d []int
for n > 0 {
d = append([]int{n % 10}, d...)
n /= 10
}
return d
}
// SliceIntBig... | digit/digit.go | 0.735737 | 0.407687 | digit.go | starcoder |
package graphql
// listTypeCreator is given to newTypeImpl for creating a List.
type listTypeCreator struct {
typeDef ListTypeDefinition
}
// listTypeCreator implements typeCreator.
var _ typeCreator = (*listTypeCreator)(nil)
// TypeDefinition implements typeCreator.
func (creator *listTypeCreator) TypeDefinition()... | graphql/list.go | 0.789356 | 0.530419 | list.go | starcoder |
package cart
// NewMBC3 returns a new MBC3 memory controller.
func NewMBC3(data []byte) BankingController {
return &MBC3{
rom: data,
romBank: 1,
ram: make([]byte, 0x8000),
rtc: make([]byte, 0x10),
latchedRtc: make([]byte, 0x10),
}
}
// MBC3 is a GameBoy cartridge that supports rom ... | pkg/cart/mbc3.go | 0.724091 | 0.505737 | mbc3.go | starcoder |
package world
import (
"gonum.org/v1/gonum/graph"
"gonum.org/v1/gonum/graph/simple"
"maze/common"
)
// 1 - 5 - 9
// | X | |
// 2 - 6 10
// | | |
// 3 7 11
// | | |
// 4 - 8 - 12
//CreateWorld generates a network of 12 nodes
func CreateWorld(tm common.TaskManager) common.World {
w := simpleWorld{}
v... | common/world/world.go | 0.520984 | 0.413181 | world.go | starcoder |
package intset
import (
"bytes"
"fmt"
)
const bitsize = 32 << (^uint(0) >> 63)
// An IntSet is a set of small non-negative integers.
// Its zero value represents the empty set.
type IntSet struct {
words []uint
}
// Has reports whether the set contains the non-negative value x.
func (s *IntSet) Has(x int) bool {... | ch06/ex5/intset.go | 0.620737 | 0.404213 | intset.go | starcoder |
package threefish
import (
"crypto/cipher"
)
const (
// Size of a 512-bit block in bytes
blockSize512 = 64
// Number of 64-bit words per 512-bit block
numWords512 = blockSize512 / 8
// Number of rounds when using a 512-bit cipher
numRounds512 = 72
)
type cipher512 struct {
t [(tweakSize / 8) + 1]uint64
k... | threefish/threefish512.go | 0.593963 | 0.469459 | threefish512.go | starcoder |
// encapsulates standard host entities into a simple interface
package wasmlib
import (
"encoding/binary"
"strconv"
)
// used to retrieve any information that is related to colored token balances
type ScBalances struct {
balances ScImmutableMap
}
// retrieve the balance for the specified token color
func (ctx S... | packages/vm/wasmlib/go/wasmlib/context.go | 0.832203 | 0.541954 | context.go | starcoder |
package quantity
import (
"errors"
"fmt"
"math"
"strconv"
"strings"
"time"
)
// Quantity represents a physical quantity: a value and a unit.
// The units have to be registered in the unit table with DefineUnit.
type Quantity struct {
value float64
*Unit
}
// String returns a default string representation of ... | quantity/quantity.go | 0.912787 | 0.613381 | quantity.go | starcoder |
package dungeongen
import (
"errors"
"log"
)
//RoomData ...
type RoomData struct {
X int
Y int
Width int
Height int
IsConnected bool
Visited bool
Section uint8
doors []RoomDoor
}
//NewRoomData creates a new room data instance
func NewRoomData(x int, y int, width int, height int) *... | pkg/dungeongen/roomdata.go | 0.661923 | 0.415492 | roomdata.go | starcoder |
package b1t8
import (
"errors"
"fmt"
"github.com/iotaledger/iota.go/trinary"
)
const (
tritsPerByte = 8
)
// EncodedLen returns the trit-length of an encoding of n source bytes.
func EncodedLen(n int) int { return n * tritsPerByte }
// Encode encodes src into EncodedLen(len(src)) trits of dst. As a convenience... | pkg/encoding/b1t8/b1t8.go | 0.743168 | 0.437163 | b1t8.go | starcoder |
// Command custommetric creates a custom metric and writes TimeSeries value
// to it. It writes a GAUGE measurement, which is a measure of value at a
// specific point in time. This means the startTime and endTime of the interval
// are the same. To make it easier to see the output, a random value is written.
// When ... | monitoring/custommetric/custommetric.go | 0.801509 | 0.412057 | custommetric.go | starcoder |
package aduket
import (
"encoding/json"
"encoding/xml"
"io"
"io/ioutil"
"net/http"
"net/url"
"testing"
"github.com/clbanning/mxj"
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
)
type RequestRecorder struct {
Body Body
Header http.Header
Data []byte
Params map[... | requestrecorder.go | 0.586286 | 0.471527 | requestrecorder.go | starcoder |
package gen_mmo
import (
"math"
)
type Vector struct {
x float64
y float64
z float64
}
const (
TOLERANCE float64 = 0.000001
)
func NewVector2(x, y float64) *Vector {
v := new(Vector)
v.x = x
v.y = y
v.z = 0
return v
}
func NewVector(x, y, z float64) *Vector {
v := new(Vector)
v.x = x
v.y = y
v.z = z
... | toolkit/gen_mmo/vector.go | 0.840521 | 0.742888 | vector.go | starcoder |
package main
import "fmt"
type position struct {
X int
Y int
}
func (pos position) E() position {
return position{pos.X + 1, pos.Y}
}
func (pos position) SE() position {
return position{pos.X + 1, pos.Y + 1}
}
func (pos position) NE() position {
return position{pos.X + 1, pos.Y - 1}
}
func (pos position) N()... | pos.go | 0.608478 | 0.737442 | pos.go | starcoder |
package volume
import (
vector3 "github.com/louis030195/protometry/api/vector3"
)
func cuboidTris() []int32 {
return []int32{
0, 2, 1, //face front
0, 3, 2,
2, 3, 4, //face top
2, 4, 5,
1, 2, 5, //face right
1, 5, 6,
0, 7, 4, //face left
0, 4, 3,
5, 4, 7, //face back
5, 7, 6,
0, 6, 7, //fac... | api/volume/mesh.go | 0.789274 | 0.663049 | mesh.go | starcoder |
package cp
/*
#include "chipmunk/include/chipmunk/chipmunk.h"
*/
import "C"
// Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)
type BB struct {
L float64
B float64
R float64
T float64
}
// c converts a BB to a C.cpBB.
func (b BB) c() C.cpBB {
var cp C.cpBB
cp.l = C.cpFloat(b.L)
cp.b ... | native/cp/bb.go | 0.88785 | 0.530784 | bb.go | starcoder |
package gm64
import (
"fmt"
"math"
"strings"
"text/tabwriter"
)
type Mat struct {
M, N int
Data []float64
}
func NewMat(m, n int) func(data ...float64) *Mat {
if m <= 0 || n <= 0 {
err := fmt.Errorf("the m and n parameters must be positive (got %d and %d)", m, n)
panic(err)
}
ctor := func(data ...float... | gm64/mat.go | 0.525612 | 0.535463 | mat.go | starcoder |
package gozxing
type ResultMetadataType int
const (
/**
* Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
*/
ResultMetadataType_OTHER = ResultMetadataType(iota)
/**
* Denotes the likely approximate orientation of the barcode in the image. This value
* is given as degrees... | result_metadata_type.go | 0.844665 | 0.510252 | result_metadata_type.go | starcoder |
package consistenthash
import (
"hash/crc32"
"math/bits"
"sort"
"strconv"
)
type Hash func(data []byte) uint32
const defaultHashExpansion = 6
type Map struct {
// Inputs
// hash is the hash function that will be applied to both added
// keys and fetched keys
hash Hash
// replicas is the number of virtual... | consistenthash/consistenthash.go | 0.706393 | 0.449574 | consistenthash.go | starcoder |
package raster
import (
"math"
"sort"
)
type Statistic struct {
Mean float64 `bson:"mean"`
Median float64 `bson:"median"`
Cells int `bson:"cells"`
Sum float64 `bson:"sum"`
Min float64 `bson:"min"`
Max float64 `bson:"max"`
Most ... | pkg/raster/statistic.go | 0.709623 | 0.42668 | statistic.go | starcoder |
package vis
import (
"image"
"image/color"
"math"
"gitlab.cs.fau.de/since/radolan"
)
// A ColorFunc can be used to assign colors to data values for image creation.
type ColorFunc func(val float64) color.RGBA
// Sample color and grayscale gradients for visualization with the image method.
var (
// HeatmapReflect... | radolan2png/vis/vis.go | 0.825801 | 0.625867 | vis.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.