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 types
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"time"
null "gopkg.in/guregu/null.v3"
)
// NullDecoder converts data with expected type f to a guregu/null value
// of equivalent type t. It returns an error if a type mismatch occurs.
func NullDecoder(f reflect.Type, t reflect.Type, data interface... | k6/lib/types/types.go | 0.716615 | 0.4474 | types.go | starcoder |
package grid
import (
"errors"
"fmt"
"strconv"
"strings"
"github.com/pietrodll/aoc2021/utils/base"
)
type Grid struct {
values [][]int
Height int
Width int
}
// Constructor
func NewGrid(values [][]int) Grid {
height := len(values)
width := len(values[0])
valuesCopy := make([][]int, height)
for i, lin... | advent-of-code-2021/utils/grid/grid.go | 0.71602 | 0.439687 | grid.go | starcoder |
package petstore
import (
"encoding/json"
)
// Whale struct for Whale
type Whale struct {
HasBaleen *bool `json:"hasBaleen,omitempty"`
HasTeeth *bool `json:"hasTeeth,omitempty"`
ClassName string `json:"className"`
}
// NewWhale instantiates a new Whale object
// This constructor will assign default values to pro... | samples/openapi3/client/petstore/go-experimental/go-petstore/model_whale.go | 0.703448 | 0.427994 | model_whale.go | starcoder |
package intmat
import (
"encoding/json"
"fmt"
"strings"
"github.com/olekukonko/tablewriter"
)
type Vector struct {
mat *Matrix
}
type vector struct {
Mat *Matrix
}
func (vec *Vector) MarshalJSON() ([]byte, error) {
return json.Marshal(vector{
Mat: vec.mat,
})
}
func (vec *Vector) UnmarshalJSON(bytes []b... | vec.go | 0.778565 | 0.5425 | vec.go | starcoder |
package io
import (
"math/big"
"reflect"
"time"
"unsafe"
"github.com/modern-go/reflect2"
)
// DecodeHandler is an decode handler.
type DecodeHandler func(dec *Decoder, t reflect.Type, p unsafe.Pointer)
func invalidDecode(dec *Decoder, t reflect.Type, p unsafe.Pointer) {
dec.decodeError(t, dec.NextByte())
}
f... | io/decode_handler.go | 0.637934 | 0.548371 | decode_handler.go | starcoder |
package genetic
import (
"errors"
"sort"
"sync"
)
type facebook struct {
distribution func() float64
quality func(c *Chromosome) (float64, error)
fitness func(population []*Chromosome, q ...float64) error
selection func(population []*Chromosome, size int, d func() float64, fitness func(population ... | core/genetic/facebook.go | 0.644561 | 0.417212 | facebook.go | starcoder |
package parser
import "errors"
type mathNode struct {
Item interface{}
Left *mathNode
Right *mathNode
}
func (m *mathNode) Value(ctx SystemContext) (Value, error) {
switch i := m.Item.(type) {
case Valuer:
return i.Value(ctx), nil
case Operator:
var left Value
if m.Left != nil {
var err error
le... | internal/parser/math_node.go | 0.569374 | 0.447641 | math_node.go | starcoder |
package sortutil
import (
"errors"
"sort"
"strings"
"time"
)
// For now, use only for slices < 100 in length for performance.
// To do: more scalable implementation that uses sorting/searching.
func InArrayStringCaseInsensitive(haystack []string, needle string) (string, error) {
needleLower := strings.ToLower(st... | sort/sortutil/sortutil.go | 0.693161 | 0.460653 | sortutil.go | starcoder |
package tago
import (
"fmt"
"math"
)
/*
StandardDeviation returns the standard deviation of the last n values.
# Formula

Where:
* _σ_ - value of standard deviation for N given probes.
* _N_ - number o... | standard_deviation.go | 0.553505 | 0.757234 | standard_deviation.go | starcoder |
package io
import (
"bytes"
"compress/gzip"
"context"
"errors"
"fmt"
"io"
"mime"
"mime/multipart"
"net/http"
"net/textproto"
"strconv"
"strings"
"sync"
"time"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"github.com/benthosdev/benthos/v4/internal/bloblang/field"
"github.com/benthosdev/be... | internal/impl/io/input_http_server.go | 0.755366 | 0.453201 | input_http_server.go | starcoder |
package rawv1
import (
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
)
// DataRAWv1 is a concrete implementation of AdvertisementData interface
// Data format is described here: https://docs.ruuvi.com/communication/bluetooth-advertisements/data-format-3-rawv1
type DataRAWv1 struct {
rawBytes [... | internal/pkg/rawv1/dataformat.go | 0.812123 | 0.475484 | dataformat.go | starcoder |
package geom
import "image"
// Projector types can be used to project 3D coordinates into 2D. It only
// supports projecting Z into a 2D offset (i.e. not a general projection).
type Projector interface {
// Sign returns a {-1, 0, 1}-valued 2D vector pointing in the direction that
// positive Z values are projected ... | geom/projection.go | 0.873633 | 0.73756 | projection.go | starcoder |
package metrics
import "time"
// Meters count events to produce exponentially-weighted moving average rates
// at one-, five-, and fifteen-minutes and a mean rate.
type Meter interface {
Count() int64
Mark(int64)
Rate1() float64
Rate5() float64
Rate15() float64
RateMean() float64
Snapshot() Meter
}
// GetOrRe... | Godeps/_workspace/src/github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics/meter.go | 0.894914 | 0.566318 | meter.go | starcoder |
package main
/*
Procces Description:
===================
A bank employs three tellers and the customers form a queue for all three tellers.
The doors of the bank close after eight hours.
The simulation is ended when the last customer has been served.
Task
====
Execute multiple simulation runs, calculate Average, Stan... | examples/example7/example7.go | 0.67854 | 0.602588 | example7.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// PlannerTask
type PlannerTask struct {
PlannerDelta
// Number of checklist ... | models/planner_task.go | 0.659186 | 0.407009 | planner_task.go | starcoder |
package parser
import (
"github.com/8pockets/hi/ast"
"github.com/8pockets/hi/token"
)
func (p *Parser) parseExpression(precedence int) ast.Expression {
prefix := p.prefixParseFns[p.curToken.Type]
if prefix == nil {
p.noPrefixParseFnError(p.curToken.Type)
return nil
}
leftExp := prefix()
/*
Precedence ex... | parser/expr_parsing.go | 0.650245 | 0.6852 | expr_parsing.go | starcoder |
package main
const defaultInfoMapping string = `
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"_doc": {
"dynamic": "strict",
"properties": {
"ip_address": {
"type": "ip_range",
"coerce": false,
"index": true
... | elasticsearch/cmd/mappings.go | 0.675551 | 0.456591 | mappings.go | starcoder |
package goutil
import (
`database/sql`
`fmt`
`reflect`
`strings`
)
// ObjectDbCols is a convenience method that returns relevant and valid
// database column names for use in constructing SQL statements. Only
// columns representing fields that will not cause a panic are included.
// Columns are further filtered... | db.go | 0.665737 | 0.435361 | db.go | starcoder |
package ll
import (
_ "fmt"
)
// Car returns the head of the list.
func Car(x List) interface{} {
if x == nil || x.Head == nil {
return nil
}
l, ok := x.Head.(List)
if ok {
return l
}
return x.Head
}
// Cdr returns the tail of the list.
func Cdr(x List) interface{} {
if x == nil || x.Tail == nil {
ret... | carcdr.go | 0.706596 | 0.620765 | carcdr.go | starcoder |
package world
import (
"github.com/austingebauer/go-ray-tracer/color"
"github.com/austingebauer/go-ray-tracer/light"
"github.com/austingebauer/go-ray-tracer/material"
"github.com/austingebauer/go-ray-tracer/matrix"
"github.com/austingebauer/go-ray-tracer/point"
"github.com/austingebauer/go-ray-tracer/ray"
"gith... | world/world.go | 0.89434 | 0.42656 | world.go | starcoder |
package action
import "github.com/rsteube/carapace"
func ActionLints() carapace.Action {
return carapace.Batch(
actionLintCategories(),
actionLints(),
).ToA()
}
func actionLintCategories() carapace.Action {
return carapace.ActionValuesDescribed(
"clippy::all", "all lints that are on by default",
"clippy::... | completers/cargo_completer/cmd/action/clippy.go | 0.815416 | 0.506347 | clippy.go | starcoder |
package isodates
import (
"errors"
"time"
)
// ParseYearMonth accepts an ISO string such as "2019-04" and returns the individual date
// components for the year and month (e.g. 2019 and time.April). We also support the variant
// where you can prefix the year with either "+" or "-".
func ParseYearMonth(input string... | year_month.go | 0.731922 | 0.437223 | year_month.go | starcoder |
package godenticon
import (
"errors"
"image"
"image/color"
"image/draw"
)
// Dermines blocky image size and output image multiplication coefficient
const blockSize = 7
const multiplier = 6
const bgOffset = 10
// GenarateImage creates image based on [16]byte hash and color slice
func GenarateImage(hash [16]byte,... | godenticon.go | 0.604632 | 0.433682 | godenticon.go | starcoder |
package util
type valueEntry struct {
Index int
Value interface{}
}
type orderedMapIterator struct {
orderedMap *OrderedMap
nextIndex int
}
// OrderedMap is similar implementation of OrderedDict in Python.
type OrderedMap struct {
Keys []string
ValueMap map[string]*valueEntry
}
// NewOrderedMap returns ... | vendor/knative.dev/client/pkg/util/orderedmap.go | 0.757166 | 0.416025 | orderedmap.go | starcoder |
package appkit
// #include "bezier_path.h"
import "C"
import (
"unsafe"
"github.com/hsiafan/cocoa/coregraphics"
"github.com/hsiafan/cocoa/foundation"
"github.com/hsiafan/cocoa/objc"
)
type BezierPath interface {
objc.Object
MoveToPoint(point foundation.Point)
LineToPoint(point foundation.Point)
CurveToPoint_... | appkit/bezier_path.go | 0.716913 | 0.555737 | bezier_path.go | starcoder |
package value
import "math/big"
// domain: [-1, 1] - complex solution outside of domain
// range: (−π/2, π/2)
func asin(c Context, v Value) Value {
x := floatSelf(c, v).(BigFloat).Float
if x.Cmp(floatMinusOne) < 0 || x.Cmp(floatOne) > 0 {
return newComplexReal(v).Asin(c).shrink()
}
return evalFloatFunc(c, v, f... | value/asin.go | 0.797439 | 0.534309 | asin.go | starcoder |
package zbor
// genericDictionary is a byte slice that contains the result of running the Zstandard training mode
// on the DPS index. This allows zstandard to achieve a better compression ratio, specifically for
// small data.
// See http://facebook.github.io/zstd/#small-data
// See https://github.com/facebook/zstd/... | codec/zbor/generic.go | 0.639511 | 0.627652 | generic.go | starcoder |
package plaid
import (
"encoding/json"
)
// ExternalPaymentScheduleRequest The schedule that the payment will be executed on. If a schedule is provided, the payment is automatically set up as a standing order. If no schedule is specified, the payment will be executed only once.
type ExternalPaymentScheduleRequest s... | plaid/model_external_payment_schedule_request.go | 0.78108 | 0.572544 | model_external_payment_schedule_request.go | starcoder |
package match
import (
"strings"
"github.com/gingraslab/pep2gene/digestion"
"github.com/gingraslab/pep2gene/helpers"
"github.com/gingraslab/pep2gene/types"
)
// addPeptide intializes a gene entry if it doesn't exist add adds
// a peptide to its matches. If it does exist, it just appends the peptide.
func addPept... | match/peptides.go | 0.593609 | 0.410461 | peptides.go | starcoder |
package sixtwo
import (
"fmt"
"github.com/pevans/erc/pkg/data"
)
type decodeMap map[uint8]uint8
type decoder struct {
ls *data.Segment
ps *data.Segment
decMap decodeMap
imageType int
loff int
poff int
}
// Decode returns a new segment that is the six-and-two decoded form
// (tran... | pkg/sixtwo/decode.go | 0.712532 | 0.422624 | decode.go | starcoder |
package markup
import (
"fmt"
"html"
"strings"
)
// HyphaExists holds function that checks that a hypha is present.
var HyphaExists func(string) bool
// HyphaAccess holds function that accesses a hypha by its name.
var HyphaAccess func(string) (rawText, binaryHtml string, err error)
// HyphaIterate is a function... | markup/lexer.go | 0.537527 | 0.432663 | lexer.go | starcoder |
package barycentric
import (
"strconv"
"strings"
"github.com/adamcolton/geom/calc/cmpr"
"github.com/adamcolton/geom/geomerr"
)
// B is a barycentric coordinate
type B struct {
U, V float64
}
// Edge will return true if B is within d of an edge.
func (b B) Edge(d float64) bool {
if b.U < -d || b.V < -d {
ret... | barycentric/barycentric.go | 0.698021 | 0.476336 | barycentric.go | starcoder |
package hbase
import (
pb "github.com/golang/protobuf/proto"
"github.com/lazyshot/go-hbase/proto"
"bytes"
)
type Put struct {
key []byte
families [][]byte
qualifiers [][][]byte
values [][][]byte
timestamp [][]int64
}
func CreateNewPut(key []byte) *Put {
return &Put{
key: key,
famil... | put.go | 0.566738 | 0.451024 | put.go | starcoder |
package gglm
import (
"fmt"
"math"
)
var _ Swizzle3 = &Vec3{}
var _ fmt.Stringer = &Vec3{}
type Vec3 struct {
Data [3]float32
}
func (v *Vec3) X() float32 {
return v.Data[0]
}
func (v *Vec3) Y() float32 {
return v.Data[1]
}
func (v *Vec3) Z() float32 {
return v.Data[2]
}
func (v *Vec3) R() float32 {
retur... | gglm/vec3.go | 0.767254 | 0.406332 | vec3.go | starcoder |
package ent
import (
"fmt"
"opencensus/core/ent/deathrecord"
"strings"
"time"
"entgo.io/ent/dialect/sql"
)
// DeathRecord is the model entity for the DeathRecord schema.
type DeathRecord struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// ReportedDate holds the value of the "report... | ent/deathrecord.go | 0.69233 | 0.440289 | deathrecord.go | starcoder |
package math
import (
"math"
)
type Quaternion struct {
X, Y, Z, W float32
}
func NewQuaternion(x, y, z, w float32) *Quaternion {
return &Quaternion{x, y, z, w}
}
func (q *Quaternion) Set(x, y, z, w float32) *Quaternion {
q.X = x
q.Y = y
q.Z = z
q.W = w
return q
}
func (q *Quaternion) Cpy() *Quaternion {
... | quaternion.go | 0.897031 | 0.651244 | quaternion.go | starcoder |
package accountaggregator
// The formulas used by insurance companies are researched
// over long periods of time by a team of dedicated
// statisticians, I do not know the art of that trade, so
// here, I am mocking the output of the formulas.
// However, in the spirit of completeness, I will provide,
// the datapoin... | src/server/controllers/accountaggregator/score_calculator.go | 0.659624 | 0.466603 | score_calculator.go | starcoder |
package commandline
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/ni/systemlink-cli/internal/model"
)
// ValueConverter provides functions to convert between input data
// of the command line and the data types in the model
type ValueConverter struct{}
func (c ValueConverter) convertToIntegerA... | internal/commandline/value_converter.go | 0.6488 | 0.420421 | value_converter.go | starcoder |
package cudnn
// #include <cudnn.h>
import "C"
import (
"runtime"
"github.com/pkg/errors"
)
type TensorDescriptor struct {
internal C.cudnnTensorDescriptor_t // ptr to struct
// internal data for fast
format TensorFormat
dataType DataType
shape []int // NCHW format for 4-tensors
strides []int
}
func ... | vendor/gorgonia.org/cu/dnn/tensor.go | 0.632503 | 0.421492 | tensor.go | starcoder |
package column
import (
"fmt"
"github.com/kelindar/bitmap"
"github.com/kelindar/column/commit"
)
// --------------------------- Float32s ----------------------------
// float32Column represents a generic column
type float32Column struct {
fill bitmap.Bitmap // The fill-list
data []float32 // The actual va... | column_numbers.go | 0.785185 | 0.497131 | column_numbers.go | starcoder |
package three
import "math"
// NewSphere :
func NewSphere(center Vector3, radius float64) *Sphere {
return &Sphere{center, radius}
}
// Sphere :
type Sphere struct {
Center Vector3
Radius float64
}
// Set :
func (s Sphere) Set(center Vector3, radius float64) *Sphere {
s.Center.Copy(center)
s.Radius = radius
... | server/three/sphere.go | 0.892522 | 0.559832 | sphere.go | starcoder |
Package serialization contains serialization functions and types for Hazelcast Go client.
Serialization is the process of converting an object into a stream of bytes to store the object in the memory, a file or database, or transmit it through the network.
Its main purpose is to save the state of an object in order to... | serialization/doc.go | 0.898705 | 0.738822 | doc.go | starcoder |
package collector
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
countStaleConfigErrors = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: "sharding_statistics",
Name: "count_stale_config_errors_total",
Help: "The total number of times that threads hit ... | collector/sharding_statistics.go | 0.542379 | 0.40392 | sharding_statistics.go | starcoder |
package in_toto
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)
/*
KeyVal contains the actual values of a key, as opposed to key metadata such as
a key identifier or key type. For RSA keys, the key value is a pair of public
and private keys in PEM format stored as strings. For public keys the Private
field ma... | in_toto/model.go | 0.621081 | 0.423398 | model.go | starcoder |
package spn
import (
"crypto/rand"
"github.com/OpenWhiteBox/primitives/encoding"
"github.com/OpenWhiteBox/primitives/matrix"
)
// findIntersections returns the incremental matrix containing only the rowspace that a set of given incremental
// matrices have in common.
func findIntersections(ims []matrix.Incrementa... | cryptanalysis/spn/affine.go | 0.843927 | 0.616272 | affine.go | starcoder |
package heap
// Heap is a functional representation of a heap
type Heap interface {
Insert(interface{})
RemoveMin() interface{}
}
// AHeap is a heap implemented with an array
type AHeap struct {
arr []interface{}
isSmaller func(int, int) bool
size int
}
// NewHeap returns a new heap
// A heap can be ... | datastructures/heap/heap.go | 0.743913 | 0.40295 | heap.go | starcoder |
package geometry
import (
"SimpleTriangleRasterizer/src/api"
"image/color"
)
// Triangle is a single triangle without shared edges.
// It can decompose into two triangles: flat-top and flat-bottom
// Each decompose triangle is made of Edges.
type Triangle struct {
// Indices into the vertex transformation buffer.
... | src/geometry/triangle.go | 0.727395 | 0.555134 | triangle.go | starcoder |
package hole
import (
"math/rand"
"strconv"
"strings"
)
// a bounding box (bbox) is defined in
// terms of its top-left vertex coordinates
// (x, y) and its width and height (w, h).
type bbox struct{ x, y, w, h int }
// couldn't find a quick way to loop a struct
func strconvbox(box bbox) (out string) {
var outs ... | hole/intersection.go | 0.558207 | 0.420659 | intersection.go | starcoder |
package ezconf
import "reflect"
// Parser provides mechanisms to parse and transform configuration structures.
type Parser struct {
typeTransforms map[FilterType]TransformFunc
keyTransforms map[string]TransformFunc
}
// A Filter determines what parts of a configuration structure should be transformed.
type Filter... | parser.go | 0.716417 | 0.511839 | parser.go | starcoder |
package amd64
import (
"github.com/tetratelabs/wazero/internal/asm"
)
// Assembler is the interface used by amd64 compiler.
type Assembler interface {
asm.AssemblerBase
// CompileJumpToMemory adds jump-type instruction whose destination is stored in the memory address specified by `baseReg+offset`,
// and return... | internal/asm/amd64/assembler.go | 0.717012 | 0.500671 | assembler.go | starcoder |
Bit String
A package to operate on bit strings of arbitrary length.
Notes:
The least signifcant bit of the bit string is bit 0.
The transmit order is right to left (as per the string representation).
In the bitstream "head" bits are transmitted before "tail" bits.
That is:
[tail]...[body]...[head] <- Tx First
Th... | bitstr/bitstr.go | 0.810479 | 0.5867 | bitstr.go | starcoder |
package ndarray
// Transpose
func (this *Array) T() *Array {
r, c := this.Dims()
trans := Zeros(c, r)
for i := 0; i < r; i++ { // i
for j := 0; j < c; j++ { // j
trans.Set(j, i, this.At(i, j))
}
}
return trans
}
// Apply a function over each element of the ndarray
func (this *Array) ForEach(fn func(x flo... | ndarray_manip.go | 0.76207 | 0.407157 | ndarray_manip.go | starcoder |
package block
import (
"github.com/fxamacker/cbor/v2"
)
const (
BLOCK_TYPE_BYRON_EBB = 0
BLOCK_TYPE_BYRON_MAIN = 1
BLOCK_HEADER_TYPE_BYRON = 0
TX_TYPE_BYRON = 0
)
type ByronMainBlockHeader struct {
// Tells the CBOR decoder to convert to/from a struct and a CBOR array
_ struct{} `cbor:",toarray... | block/byron.go | 0.574156 | 0.438244 | byron.go | starcoder |
package nn
import (
"encoding/json"
"fmt"
tsr "../tensor"
)
// DenseLayer is a fully connected layer for a neural network.
type DenseLayer struct {
inputShape LayerShape
outputShape LayerShape
inputs *tsr.Tensor
outputs *tsr.Tensor
Weights *tsr.Tensor
Bias *tsr.Tensor
PrevUpdate *tsr.... | nn/denseLayer.go | 0.860105 | 0.651812 | denseLayer.go | starcoder |
package engine
import (
"github.com/mumax/3/cuda"
"github.com/mumax/3/data"
"github.com/mumax/3/util"
"reflect"
)
var DU firstDerivative // firstDerivative (unit [m/s])
func init() { DeclLValue("du", &DU, `firstDerivative (unit [m/s])`) }
// Special buffered quantity to store firstDerivative
type firstDerivativ... | engine/firstDerivative.go | 0.512205 | 0.4231 | firstDerivative.go | starcoder |
package maxflow
import (
"fmt"
"github.com/wangyoucao577/algorithms_practice/bfs"
"github.com/wangyoucao577/algorithms_practice/dfs"
"github.com/wangyoucao577/algorithms_practice/flownetwork"
"github.com/wangyoucao577/algorithms_practice/graph"
)
// residualNetwork has same structure as flownetwork, but will ha... | maxflow/maxflow.go | 0.632049 | 0.402451 | maxflow.go | starcoder |
package identicon
import (
"image"
"strconv"
)
// Canvas contains what is needed to generate an image. It contains properties
// that could be useful when rendering the image.
// - Having MinY and MaxY allows you to vertically center the figure.
// - VisitedYPoints could be useful to determine whether there is a ... | backend/vendor/github.com/nullrocks/identicon/canvas.go | 0.719778 | 0.543893 | canvas.go | starcoder |
package interpreter
import (
"errors"
"github.com/YuriyLisovskiy/borsch-lang/Borsch/builtin/types"
"github.com/YuriyLisovskiy/borsch-lang/Borsch/common"
"github.com/YuriyLisovskiy/borsch-lang/Borsch/util"
)
type Scope map[string]common.Value
func (p *Package) Evaluate(state common.State) (common.Value, error) {... | Borsch/interpreter/eval.go | 0.717111 | 0.486088 | eval.go | starcoder |
package chess
import (
"fmt"
)
// RANKS defines the number of rows on the board
// FILES defines the number of columns on the board
const (
RANKS int = 8
FILES int = 8
)
const (
initWhiteRooks = Bitboard(0x0000000000000081)
initWhiteKnights = Bitboard(0x0000000000000042)
initWhiteBishops = Bitboard(0x0000000... | pkg/chess/board.go | 0.750827 | 0.438905 | board.go | starcoder |
package golorp
import (
"fmt"
"github.com/tcolgate/golorp/term"
)
// Cell implements an interface for items that can be stored on the heap
type Cell interface {
IsCell()
fmt.Stringer
}
type CellPtr struct {
Store *[]Cell
Offset int
}
func (c CellPtr) Cell() Cell {
return (*c.Store)[c.Offset]
}
func (c Ce... | machine.go | 0.664649 | 0.430866 | machine.go | starcoder |
package dst
// Dirichlet distribution. It is the multivariate generalization of the beta distribution.
// Parameters:
// αi > 0 concentration parameters
// Support:
// θi ∈ [0, 1] and Σθi = 1
// DirichletPDF returns the PDF of the Dirichlet distribution.
func DirichletPDF(α []float64) func(θ []float64) float64 ... | dst/dirichlet.go | 0.791338 | 0.468 | dirichlet.go | starcoder |
package chaincfg
import (
"math/big"
"strings"
chainhash "git.parallelcoin.io/dev/pod/pkg/chain/hash"
)
// String returns the hostname of the DNS seed in human-readable form.
func (d DNSSeed) String() string {
return d.Host
}
// Register registers the network parameters for a Bitcoin network. This may error w... | pkg/chain/config/params.go | 0.836521 | 0.53437 | params.go | starcoder |
package fpdf
import (
"fmt"
"github.com/jung-kurt/gofpdf"
)
// Describes a grid we're going to plot ov`er, and the location of its top-left corner in PDF space
type BaseGrid struct {
*gofpdf.Fpdf // Embed the thing we're writing to
// Describe the portion of PDF page space the grid will be drawn over (lab... | fpdf/basegrid.go | 0.783119 | 0.467271 | basegrid.go | starcoder |
package bayesian_filter
import (
"errors"
m "math"
. "github.com/skelterjohn/go.matrix"
)
var (
ClassSet = []int{1, 2, 3, 4, 5}
NA = m.NaN()
)
// returns the matrix of ratings.
func MakeRatingMatrix(ratings []float64, rows, cols int) *DenseMatrix {
return MakeDenseMatrix(ratings, rows, cols)
}
func arg... | plugins/data/learn/ml-filters-bayesian/bayesian_filter.go | 0.795658 | 0.485722 | bayesian_filter.go | starcoder |
package main
import "math"
// AtomType values are types of atoms that you can find in a nucleotide (P, C1', N1...)
type AtomType uint8
// The various types of atoms that you can find in a nucleotide
const (
P AtomType = iota // Phosphate
OP1 // Phosphate
OP2 // Phosphate
C1P ... | rnaProblem.go | 0.603114 | 0.405213 | rnaProblem.go | starcoder |
package views
import (
goa "goa.design/goa/v3/pkg"
)
// NeatThing is the viewed result type that is projected based on a view.
type NeatThing struct {
// Type to project
Projected *NeatThingView
// View to render
View string
}
// NeatThingView is a type that runs validations on a projected type.
type NeatThing... | gen/neat_thing/views/view.go | 0.572245 | 0.415017 | view.go | starcoder |
package astutil
import (
"fmt"
"github.com/open2b/scriggo/ast"
)
// CloneTree returns a complete copy of tree.
func CloneTree(tree *ast.Tree) *ast.Tree {
return CloneNode(tree).(*ast.Tree)
}
// CloneNode returns a deep copy of node.
func CloneNode(node ast.Node) ast.Node {
switch n := node.(type) {
case *as... | ast/astutil/clone.go | 0.639286 | 0.560914 | clone.go | starcoder |
package czml
// BoundingRectangle holds a bounding rectangle specified by a corner, width and height.
// https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/BoundingRectangle
type BoundingRectangle struct {
BoundingRectangle *BoundingRectangleValue `json:"boundingRectangle,omitempty"`
Reference Referen... | shapes.go | 0.924103 | 0.610279 | shapes.go | starcoder |
// F2 illuminant conversion functions
package white
// F2_A functions
func F2_A_Bradford(xs, ys, zs float64) (xd, yd, zd float64) {
m := [3][3]float64{
{1.1108436, 0.0654914, -0.1020770},
{0.0892593, 0.9359084, -0.0362665},
{-0.0166489, 0.0256618, 0.5144475}}
xd = m[0][0]*xs + m[0][1]*ys + m[0][2]*zs
yd = m... | f64/white/f2.go | 0.505371 | 0.614307 | f2.go | starcoder |
package gotalib
// The Slow Stochastic Oscillator is a momentum indicator that shows the location
// of the close relative to the high-low range over a set number of periods. The
// indicator can range from 0 to 100. The difference between the Slow and Fast
// Stochastic Oscillator is the Slow %K incorporates a %K slo... | stochslow.go | 0.866895 | 0.519399 | stochslow.go | starcoder |
package g5
import (
gl "github.com/chsc/gogl/gl33"
)
type _ColorRect struct {
program *_Program
vao gl.Uint
vbo gl.Uint
}
func newColorRect() *_ColorRect {
r := &_ColorRect{}
r.program = newProgram("github.com/amortaza/go-g5/shader/rgb.vertex.txt", "github.com/amortaza/go-g5/shader/rgb.fragment.txt")
gl.... | color-rect.go | 0.670285 | 0.470068 | color-rect.go | starcoder |
package parse
import (
"fmt"
"sort"
"strings"
)
// Node is an item in the AST.
type Node interface {
String() string // String representation of the Node, for debugging.
Start() Pos // The position of the Node in the source code.
All() []Node // All children of the Node.
}
// A TrimmableNode contains in... | parse/node.go | 0.759047 | 0.569733 | node.go | starcoder |
package steven
import (
"math"
"github.com/thinkofdeath/steven/protocol"
"github.com/thinkofdeath/steven/type/vmath"
)
// Network
type networkComponent struct {
NetworkID int
entityID int
}
func (n *networkComponent) SetEntityID(id int) { n.entityID = id }
func (n *networkComponent) EntityID() int { re... | entityparts.go | 0.801276 | 0.405684 | entityparts.go | starcoder |
package array
import "reflect"
// ArrStr struct
type ArrStr string
// InArray check is in array
func (s ArrStr) InArray(val string, array []string) (exists bool, index int) {
exists = false
index = -1
for i, s := range array {
if s == val {
exists = true
index = i
return
}
}
return
}
// Remove m... | lib/array/array.go | 0.515132 | 0.570152 | array.go | starcoder |
package click
import (
"github.com/barkimedes/go-deepcopy"
"github.com/chewxy/math32"
"sort"
)
// EvaluateRegression evaluates factorization machines in regression task.
func EvaluateRegression(estimator FactorizationMachine, testSet *Dataset) Score {
sum := float32(0)
// For all UserFeedback
for i := 0; i < t... | model/click/evaluator.go | 0.665193 | 0.567637 | evaluator.go | starcoder |
package qoi
import (
"bufio"
"image"
"image/color"
"io"
)
type opRGB color.NRGBA
func newOpRGB(r *imageReader, previous color.NRGBA) chunk {
if r.c.A != previous.A {
return nil
}
defer r.next()
return &opRGB{R: r.c.R, G: r.c.G, B: r.c.B}
}
func (op *opRGB) decode(r *bufio.Reader) error {
var buf [4]uint8... | ops.go | 0.664323 | 0.51623 | ops.go | starcoder |
package ecs
const MaxFlagCapacity = 256
// Flag is a 256 bit binary flag
type Flag [4]uint64
// Clone returns a new flag with identical data
func (f Flag) Clone() Flag {
return Flag{f[0], f[1], f[2], f[3]}
}
// Equals checs if g contains the same bits
func (f Flag) Equals(g Flag) bool {
return f[0] == g[0] && f[1... | flag.go | 0.702836 | 0.428712 | flag.go | starcoder |
package main
// Shapable provides the basic geometry of a primitive shape
type Shapable interface {
Bounds() Box
LocalNormalAt(Tuple) Tuple
LocalIntersect(Ray) []float64
NormalAtHit(Tuple, *IntersectionInfo) Tuple
}
// Shape is an higher level object that represents a geometric primitive,
// it uses the Shapable... | shape.go | 0.901781 | 0.620449 | shape.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPStatementLoopForIn279AllOf struct for BTPStatementLoopForIn279AllOf
type BTPStatementLoopForIn279AllOf struct {
BtType *string `json:"btType,omitempty"`
Container *BTPExpression9 `json:"container,omitempty"`
IsVarDeclaredHere *bool `json:"isVarDeclaredHere,omitempt... | onshape/model_btp_statement_loop_for_in_279_all_of.go | 0.685423 | 0.461381 | model_btp_statement_loop_for_in_279_all_of.go | starcoder |
// Advent of Code 2017 Day 10 Part 2 hash function.
package hashaoc17;
// In-place reverse a subsequence of the circular buffer
// ring starting at posn and with length length.
func circularReverse(ring *[256]uint8, posn int, length uint8) {
// Swap start position within the reversal.
i := 0
// Loop until the ind... | src/hashaoc17/hashaoc17.go | 0.617859 | 0.411702 | hashaoc17.go | starcoder |
package alt
// #include <stdlib.h>
// #include "Module.h"
import "C"
import (
"unsafe"
"github.com/shockdev04/altv-go-pkg/internal/module"
)
type ColShape struct {
WorldObject
}
func NewColShape(c unsafe.Pointer) *ColShape {
colShape := &ColShape{}
colShape.Ptr = c
colShape.Type = ColshapeObject
return colSh... | alt/colshape.go | 0.521715 | 0.585338 | colshape.go | starcoder |
package ai
import (
"math"
"math/rand"
"time"
"github.com/lukechampine/tenten/game"
)
const monteC = 1.414 // uct tradeoff parameter; low = choose high value nodes, high = choose unexplored nodes
type Move struct {
Piece game.Piece
X, Y int
}
func BestMoves(b *game.Board, bag [3]game.Piece, timeLimit time.D... | ai/ai.go | 0.50708 | 0.550728 | ai.go | starcoder |
package layer
import tf "github.com/galeone/tensorflow/tensorflow/go"
type LTextVectorization struct {
dtype DataType
inputs []Layer
maxTokens interface{}
name string
ngrams interface{}
outputMode string
outputSequenceLength interf... | layer/TextVectorization.go | 0.633297 | 0.463201 | TextVectorization.go | starcoder |
package adsbtype
import (
"fmt"
)
// ATS is the altitude type subfield.
type ATS uint64
// Altitude Type Subfield values.
const (
ATS0 ATS = 0 // Barometric altitude
ATS1 ATS = 1 // Navigation-derived altitude
)
var mATS = map[ATS]string{
ATS0: "Barometric altitude",
ATS1: "Navigation-derived altitude",
}
//... | adsbtype/commb.go | 0.683314 | 0.535706 | commb.go | starcoder |
package service
// Task describes a service task.
type Task struct {
// Key is the key of task.
Key string `hash:"name:1"`
// Name is the name of task.
Name string `hash:"name:2"`
// Description is the description of task.
Description string `hash:"name:3"`
// Inputs are the definition of the execution input... | service/task.go | 0.718496 | 0.444625 | task.go | starcoder |
package recurrence
import (
"encoding/json"
"fmt"
"time"
)
// A TimeRange represents a range of time, with a start and an end.
type TimeRange struct {
Start time.Time
End time.Time
}
// IsOccurring implements the Schedule interface.
func (tr TimeRange) IsOccurring(t time.Time) bool {
return !(t.Before(tr.Sta... | time_range.go | 0.795301 | 0.483892 | time_range.go | starcoder |
package timeseries
import (
"math"
"sync"
"github.com/toolsparty/regression"
)
// TrendType type
type TrendType int
// TrendType enum
const (
TrendTypeDecreasing TrendType = -1
TrendTypeNeutral TrendType = 0
TrendTypeIncreasing TrendType = 1
)
// DataPoint struct
type DataPoint struct {
Time int64 `j... | timeseries/timeseries.go | 0.661595 | 0.507202 | timeseries.go | starcoder |
package byteslice
import (
"errors"
"math"
)
// Reverse change the order of the byte slice.
func Reverse(data []byte) []byte {
if len(data) < 2 {
return data
}
sliceLength := len(data)
sliceHalfLength := int(float64(sliceLength / 2))
reversedSlice := make([]byte, sliceLength)
for i := 0; i <= sliceHalfLeng... | byteslice.go | 0.737158 | 0.590779 | byteslice.go | starcoder |
package importer
import (
"fmt"
"github.com/mescanne/goledger/cmd/utils"
"github.com/mescanne/goledger/script"
)
var ImportUsage = `Import Detailed Help
============================
Format
------
The format for the import configuration:
type:key=value[,key=value,...]
Configuration file uses "configType" fo... | cmd/importer/import_op.go | 0.7917 | 0.431045 | import_op.go | starcoder |
package ast
// These are the available root node types. In JSON it will either be an
// object or an array at the base.
const (
ObjectRoot RootNodeType = iota
ArrayRoot
)
// RootNodeType is a type alias for an int
type RootNodeType int
// RootNode is what starts every parsed AST. There is a `Type` field so that
//... | pkg/ast/ast.go | 0.72086 | 0.549036 | ast.go | starcoder |
package evolution
import (
"fmt"
"strings"
)
// EquationPairing refers to a set dependent and independent values for a given equation.
// For example the equation x^2 + 1 has an equation pairing of {1, 0}, {2, 1}, {5,
// 2} for dependent and independent pairs respectively
type EquationPairing struct {
Independents... | evolution/spec.go | 0.805288 | 0.610686 | spec.go | starcoder |
package transforms
// Copyright 2017 The goimagehash Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import (
"math"
"sync"
)
// DCT1D function returns result of DCT-II.
// DCT type II, unscaled. Algorithm by <NAME>, 1984.
func D... | imagehash/transforms/dct.go | 0.682574 | 0.465205 | dct.go | starcoder |
package bip38
import (
"golang.org/x/crypto/scrypt"
"crypto/aes"
"crypto/rand"
"conseweb.com/wallet/icebox/common/address"
"github.com/sour-is/koblitz/kelliptic"
)
type BIP38Key struct {
Flag byte
Hash [4]byte
Data [32]byte
}
func Encrypt(p *address.PrivateKey, passphrase string) string {
bip38 := new(BIP38... | bip38/bip38.go | 0.591841 | 0.421909 | bip38.go | starcoder |
package v1alpha1
import (
v1alpha1 "kubeform.dev/kubeform/apis/google/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// BigqueryDatasetLister helps list BigqueryDatasets.
type BigqueryDatasetLister interface {
// List lists all BigqueryDatasets ... | client/listers/google/v1alpha1/bigquerydataset.go | 0.627267 | 0.435841 | bigquerydataset.go | starcoder |
package BronKerbosch
type VertexVisitor interface {
visit(Vertex)
Close()
}
type SimpleVertexVisitor struct {
vertices []Vertex
}
type ChannelVertexVisitor struct {
vertices chan<- Vertex
}
func (g *SimpleVertexVisitor) visit(v Vertex) {
g.vertices = append(g.vertices, v)
}
func (g *SimpleVertexVisitor) Close... | go/lib/graph_degeneracy.go | 0.568416 | 0.482612 | graph_degeneracy.go | starcoder |
package moves
import (
"github.com/jkomoros/boardgame"
)
//Optional returns a MoveProgressionGroup that matches the provided group
//either 0 or 1 times. Equivalent to Repeat() with a count of Between(0, 1).
func Optional(group MoveProgressionGroup) MoveProgressionGroup {
return Repeat(CountBetween(0, 1), group)
}
... | moves/group_repeat.go | 0.808408 | 0.494385 | group_repeat.go | starcoder |
package extstorage
import "context"
// Interface is the ganeti-extstorage interface according to
// https://docs.ganeti.org/docs/ganeti/3.0/html/man-ganeti-extstorage-interface.html#executable-scripts
type Interface interface {
/*
The create command is used for creating a new volume inside the external storage. Th... | pkg/ganeti/extstorage/interface.go | 0.580233 | 0.487612 | interface.go | starcoder |
package set1
import (
"encoding/hex"
)
/**
* Cryptopal Set 1
* Challenge 3 - Single Byte Xor Cipher
* https://cryptopals.com/sets/1/challenges/3
*/
// SingleByteXorCrackFromByte tries to decrypt a cipher xor'd against a single character
func SingleByteXorCrackFromByte(cipher []byte) (bestScore int, bestKey byte... | set1/single-byte-xor-cipher.go | 0.724773 | 0.420064 | single-byte-xor-cipher.go | starcoder |
package lib
import (
"errors"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
)
type card struct {
name string
}
func Card(name string) card {
return card{name: name}
}
func (self *card) Pretty() string {
return GetCardData(self.name).Pretty
}
func (self *card) ToJSON() string {
var t tag... | lib/card.go | 0.726523 | 0.403684 | card.go | starcoder |
package storage
import (
"encoding"
"encoding/json"
"fmt"
"reflect"
"strconv"
"github.com/fatih/structs"
)
// StringStringMapDecoder is used to decode a map[string]string to a struct
type StringStringMapDecoder func(input map[string]string) (interface{}, error)
func decodeToType(typ reflect.Kind, value strin... | core/storage/decoder.go | 0.646572 | 0.476884 | decoder.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.