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 main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"os"
"regexp"
"strconv"
)
// FindCycleAndSimulate compute the given system's total energy after the
// requested number of steps along with the step count needed to reach a state
// that exactly matches a previous state.
func FindCycleAndSimulate(system *... | day12/main.go | 0.67405 | 0.530176 | main.go | starcoder |
package cpebiten
import (
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/inpututil"
"github.com/jakecoffman/cp"
"math"
)
var GrabbableMaskBit uint = 1 << 31
var Grabbable = cp.ShapeFilter{
cp.NO_GROUP, GrabbableMaskBit, GrabbableMaskBit,
}
var NotGrabbable = cp.ShapeFilter{
cp.NO_GROUP, ^Grabba... | input.go | 0.557604 | 0.496216 | input.go | starcoder |
// Package grand provides high performance random string generation functionality.
package grand
import (
"unsafe"
)
var (
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" // 52
symbols = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" // 32
digits = "0123456789" ... | util/grand/grand.go | 0.741393 | 0.401482 | grand.go | starcoder |
package set
import (
"sort"
)
// Ints represents the classic "set" data structure, and contains ints.
type Ints map[int]bool
// NewInts creates and initializes an Ints and populates it with
// initial values as specified in the parameters.
func NewInts(initial ...int) Ints {
result := make(Ints)
for _, value := ... | vendor/github.com/juju/utils/set/ints.go | 0.834845 | 0.631452 | ints.go | starcoder |
package predict
import (
"context"
"github.com/Applifier/go-tensorflow/types/tensorflow/core/example"
"github.com/Applifier/go-tensorflow/utils"
)
// An Example is a mostly-normalized data format for storing data for
// training and inference. It contains a key-value store (features); where
// each key (string) ... | predict/api.go | 0.835249 | 0.551272 | api.go | starcoder |
package mutations
import "log"
import "fmt"
import "time"
import "github.com/dadleyy/charlestown/engine/objects"
import "github.com/dadleyy/charlestown/engine/constants"
// Interact mutates the state based on the current mode.
func Interact() Mutation {
return interact{}
}
type interact struct {
}
func (i interact... | engine/mutations/interact.go | 0.634204 | 0.401834 | interact.go | starcoder |
package ast2
import (
"go/ast"
"go/token"
r "reflect"
mt "github.com/cosmos72/gomacro/token"
)
// ToNode converts Ast back ast.Node, or panics on failure
// (it fails if the argument is not AstWithNode)
func ToNode(x Ast) ast.Node {
switch x := x.(type) {
case nil:
return nil
case AstWithNode:
return x.No... | vendor/github.com/cosmos72/gomacro/ast2/unwrap.go | 0.589244 | 0.558086 | unwrap.go | starcoder |
package basiccolor
import (
"image/color"
"math"
)
var _ color.Color = HSL{}
// HSL represents the HSL value for a color.
type HSL struct {
H, S, L float64
A uint8
}
func (c HSL) RGBA() (uint32, uint32, uint32, uint32) {
r, g, b := hslToNRGB(c.H, c.S, c.L)
return color.NRGBA{r, g, b, c.A}.RGBA()
}
// ... | appengine/basiccolor/hsl.go | 0.781747 | 0.439868 | hsl.go | starcoder |
package dlx
import (
"errors"
)
/*
New constructs a new matrix.
primary - The amount of primary columns to be in the matrix.
optional - The amount of optional columns to be in the matrix.
*/
func New(primary, optional int) (*Matrix, error) {
if primary <= 0 {
return nil, errors.New("primary must be positive")
... | dlx.go | 0.549399 | 0.492859 | dlx.go | starcoder |
package main
import (
"math"
"github.com/qeedquan/go-media/math/f64"
)
const (
LUT_SIZE = 21 // number of importance index entries in the lookup table
NUM_STRUCT_INDEX_BITS = 6 // Number of significant bits taken from F-Code.
GOLDEN_RATIO = PHI
PHI = 1.6180339887498948482045868343656 //... | gfx/pdsample/quasisampler.go | 0.659186 | 0.400486 | quasisampler.go | starcoder |
package main
import (
"fmt"
"strings"
)
// Node is a server and instance value used in the hash ring. A key is
// mapped to one or more of the configured Node structs in the hash ring.
type Node struct {
Server string
Instance string
}
// XorShift generates a predictable random-ish hash from the given integer... | jump.go | 0.756178 | 0.451568 | jump.go | starcoder |
package utils
import "strconv"
//ODSAData is the structure for the compressed data
type ODSAData struct {
//pMap is the position map of the compressed data
pMap map[byte]int
//lPosition is the last position of the compressed data
lPosition int
//lLetter is the last letter in the transformed data
lLetter byte
/... | utils/datastructures.go | 0.576661 | 0.458591 | datastructures.go | starcoder |
package golist
import (
"fmt"
"math/rand"
"time"
)
// SliceError is a slice of type error.
type SliceError struct {
data []error
}
// NewSliceError returns a pointer to a new SliceError initialized with the specified elements.
func NewSliceError(elems ...error) *SliceError {
s := new(SliceError)
s.data = make... | slice_error.go | 0.762247 | 0.443058 | slice_error.go | starcoder |
package xex
import (
"fmt"
"math"
"reflect"
)
//Set up built-in number functions
func registerNumberBuiltins() {
RegisterFunction(
NewFunction(
"add",
FunctionDocumentation{
Text: `adds two numbers returning a single numerical result`,
Parameters: map[string]string{
"num1": "The first number ... | builtins_numbers.go | 0.653459 | 0.560012 | builtins_numbers.go | starcoder |
package band
import (
"fmt"
"math"
)
// ChMaskCntlPair pairs a ChMaskCntl with a mask.
type ChMaskCntlPair struct {
Cntl uint8
Mask [16]bool
}
func parseChMask(offset uint8, mask ...bool) map[uint8]bool {
if len(mask)-1 > int(math.MaxUint8-offset) {
panic(fmt.Sprintf("channel mask overflows uint8, offset: %d... | pkg/band/channel_mask.go | 0.522689 | 0.458773 | channel_mask.go | starcoder |
package gopherplot
import (
"errors"
"fmt"
)
// Shape is the description of a matrix's dimensions
type Shape []int
// Equals determines if two shapes are the same
func (s Shape) Equals(s2 Shape) bool {
if len(s) != len(s2) {
return false
}
for i := range s {
if s[i] != s2[i] {
return false
}
}
return... | transforms.go | 0.768081 | 0.618521 | transforms.go | starcoder |
package jsonio
import (
"bytes"
"encoding/hex"
"encoding/json"
"time"
"github.com/brimdata/zed"
"github.com/brimdata/zed/zcode"
"github.com/brimdata/zed/zson"
)
func marshalAny(typ zed.Type, bytes zcode.Bytes) interface{} {
if bytes == nil {
return nil
}
switch typ := typ.(type) {
case *zed.TypeNamed:
... | zio/jsonio/marshal.go | 0.560493 | 0.406214 | marshal.go | starcoder |
package pipeline
import (
"fmt"
"strings"
"github.com/gcla/sklearn/base"
"github.com/gcla/sklearn/preprocessing"
"gonum.org/v1/gonum/mat"
)
// Estimator is an interface for Predict
type Estimator interface {
Predict(X, Y *mat.Dense)
}
// NamedStep represents a pipeline named Step
type NamedStep struct {
Nam... | pipeline/pipeline.go | 0.708616 | 0.423041 | pipeline.go | starcoder |
package signalfxformat
import (
"fmt"
"github.com/signalfx/golib/v3/trace"
)
// JSONDatapointV1 is the JSON API format for /v1/datapoint
//easyjson:json
type JSONDatapointV1 struct {
//easyjson:json
Source string `json:"source"`
Metric string `json:"metric"`
Value float64 `json:"value"`
}
// JSONDatapointV... | protocol/signalfx/format/signalfx_format.go | 0.705176 | 0.444987 | signalfx_format.go | starcoder |
package fv
// the references, in order, of the Extended set of Fighter Verses
var ExtendedSet = []entry{
{SetOrder: 101, BibleOrder: 0, Set: "Extended", Ref: "Philippians 1:1-2"},
{SetOrder: 102, BibleOrder: 0, Set: "Extended", Ref: "Philippians 1:3-6"},
{SetOrder: 103, BibleOrder: 0, Set: "Extended", Ref: "Philipp... | fv/extended.go | 0.54819 | 0.553807 | extended.go | starcoder |
package advent2018
import (
"bufio"
"errors"
"io"
"math"
"sort"
"strconv"
"strings"
)
type grid struct {
coordinates []point
min, max point
}
func (g grid) largestFiniteArea() int {
closestPointsByLandmark := map[point][]point{}
for x := g.min.x; x <= g.max.x; x++ {
for y := g.min.y; y <= g.max.y; y... | advent2018/coordinates.go | 0.719384 | 0.419232 | coordinates.go | starcoder |
package day18
import (
"fmt"
"strings"
"advent2021.com/util"
)
type Node struct {
Value int
Parent, Left, Right *Node
}
func NewNode(value int, parent *Node) *Node {
return &Node{Value: value, Parent: parent, Left: nil, Right: nil}
}
func (n *Node) IsRoot() bool {
return n.Parent == nil
}
fun... | day18/node.go | 0.610221 | 0.421135 | node.go | starcoder |
package check
import (
"go/ast"
"go/token"
"strconv"
"strings"
"unicode"
"golang.org/x/tools/go/ast/astutil"
)
// Exposed here for unit tests.
const (
notOnlyTopAddTestMsg = `testing.AddTest() should be the only top level statement of init()`
addTestArgLitMsg = `testing.AddTest() should take &testing.Te... | cmd/tast-lint/internal/check/declarations.go | 0.717408 | 0.410166 | declarations.go | starcoder |
package natural
import (
"fmt"
"math"
"math/big"
"regexp"
"strconv"
"strings"
"github.com/shopspring/decimal"
)
var (
multiplierMap = map[string]int{
// eng
"hundred": 100,
"thousand": 1000,
"million": 1000000,
// swe
// https://sv.wikipedia.org/wiki/Miljard
// https://sv.wikipedia.org/wiki/B... | number.go | 0.523908 | 0.404743 | number.go | starcoder |
package maths
import (
"fmt"
"math"
"github.com/wdevore/Ranger-Go-IGE/api"
)
// vector3 contains base components
type vector3 struct {
x, y, z float32
}
// NewVector3 creates a Vector3 initialized to 0.0, 0.0, 0.0
func NewVector3() api.IVector3 {
v := new(vector3)
v.x = 0.0
v.y = 0.0
v.z = 0.0
return v
}
... | engine/maths/vector3.go | 0.901891 | 0.554109 | vector3.go | starcoder |
package types
import "github.com/centrifuge/go-substrate-rpc-client/v4/scale"
type BodyID struct {
IsUnit bool
IsNamed bool
Body []U8
IsIndex bool
Index U32
IsExecutive bool
IsTechnical bool
IsLegislative bool
IsJudicial bool
}
func (b *BodyID) Decode(decoder scale.Decoder) error {
bb, err := d... | types/body.go | 0.633524 | 0.405861 | body.go | starcoder |
package main
import (
"flag"
"github.com/SOMAS2020/SOMAS2020/internal/common/config"
"github.com/SOMAS2020/SOMAS2020/internal/common/shared"
"github.com/pkg/errors"
)
var (
// config.Config
maxSeasons = flag.Uint(
"maxSeasons",
100,
"The maximum number of 1-indexed seasons to run the game.",
)
maxTurns... | params.go | 0.500732 | 0.494324 | params.go | starcoder |
package govaluate
// ExprNode is a structured representation of an expression.
// There are three types of nodes: literal, variable and operator. The latter
// can have child nodes. They form a tree, where each node is an expression itself.
type ExprNode struct {
Type ExprNodeType
Name string
Value interface{}
A... | ExprNode.go | 0.710025 | 0.751625 | ExprNode.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
"contact": {},
"l... | api/docs/docs.go | 0.504639 | 0.406626 | docs.go | starcoder |
package vm
import "errors"
import "fmt"
import "math"
import "time"
// Flips the X and Y axes of all moves
func (vm *Machine) FlipXY() {
for idx := range vm.Positions {
pos := vm.Positions[idx]
vm.Positions[idx].X, vm.Positions[idx].Y = pos.Y, pos.X
}
}
// Limit feedrate.
func (vm *Machine) LimitFeedrate(feed ... | vm/utils.go | 0.697197 | 0.40539 | utils.go | starcoder |
package three
import "github.com/gopherjs/gopherjs/js"
// Matrix4 - represents a Matrix4.
type Matrix4 struct {
*js.Object
// A column-major list of matrix values.
A *js.Object `js:"A"`
}
func NewMatrix4() *Matrix4 {
return &Matrix4{
Object: three.Get("Matrix4").New(),
}
}
// Sets this matrix to the transfo... | math_matrix4.go | 0.918242 | 0.679275 | math_matrix4.go | starcoder |
package redblack
// Element represents the constituent of any Node
type Element interface {
Key() int
Merge(Element) Element
}
type color bool
const (
red color = false
black color = true
)
// Node is what the tree is made of.
type Node struct {
color color
element Element
left *Node
right *Node
}
... | internal/redblack/redblack.go | 0.855625 | 0.513485 | redblack.go | starcoder |
package pattern_matching_lcci
/*
面试题 16.18. 模式匹配 https://leetcode-cn.com/problems/pattern-matching-lcci/
你有两个字符串,即pattern和value。
pattern字符串由字母"a"和"b"组成,用于描述字符串中的模式。
例如,字符串"catcatgocatgo"匹配模式"aabab"(其中"cat"是"a","go"是"b"),该字符串也匹配像"a"、"ab"和"b"这样的模式。
但需注意"a"和"b"不能同时表示相同的字符串。编写一个方法判断value字符串是否匹配pattern字符串。
示例 1:
输入: patte... | solutions/pattern-matching-lcci/d.go | 0.581303 | 0.47859 | d.go | starcoder |
package wavelet
import (
"errors"
"jpeg2000/data"
"strconv"
"strings"
)
type Wavelet interface {
WaveletTransform(l data.Layer) data.Layer
WaveletInverse(l data.Layer) data.Layer
ToProtobuf() *data.WaveletConfig
}
func scaleX(f1, f2 data.Layer) data.Layer {
sizeX1, sizeY1 := f1.GetDimensions()
sizeX2, sizeY... | labo-2/jpeg2000/wavelet/wavelet.go | 0.503906 | 0.530419 | wavelet.go | starcoder |
package expectations
import (
"fmt"
"reflect"
"runtime"
"strings"
)
// FailFunction is normally an instance of testing.T
type FailFunction interface {
Fail()
}
// Logger prints out the validation failures
type Logger interface {
Log(message string)
}
type defaultLogger struct{}
// Log writes a message to std... | expectations.go | 0.669637 | 0.617686 | expectations.go | starcoder |
package dendrolog
type renderedNode struct {
block stringBlock
// Defines at which x coord in this block on which the zone we can connect lines to starts
start int
// Defines at which x coord in this block on which the zone we can connect lines to end
end int
}
const baseSpacing = 3
//const debugConnections = f... | connectionRenderer.go | 0.543348 | 0.429788 | connectionRenderer.go | starcoder |
//go:generate ./genCode.sh
// Package align provide basic sequence alignment types and helpers.
package align
import (
"github.com/biogo/biogo/alphabet"
"github.com/biogo/biogo/feat"
"github.com/biogo/biogo/seq"
"errors"
"fmt"
)
type AlphabetSlicer interface {
Alphabet() alphabet.Alphabet
Slice() alphabet.S... | align/align.go | 0.588889 | 0.449574 | align.go | starcoder |
package condition
import (
"encoding/json"
"errors"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/util/text"
)
//-------------------------------------... | lib/condition/check_interpolation.go | 0.724773 | 0.611324 | check_interpolation.go | starcoder |
package matrix
import "errors"
type Matrix struct {
rows int
columns int
cells []float64
}
func New(rows, columns int) Matrix {
return Matrix{
rows: rows,
columns: columns,
cells: make([]float64, rows*columns),
}
}
func NewWithValues(rows, columns int, vals ...float64) (Matrix, error) {
if len... | matrix.go | 0.80112 | 0.63273 | matrix.go | starcoder |
package bes
import (
"github.com/OpenWhiteBox/primitives/gfmatrix"
"github.com/OpenWhiteBox/primitives/number"
)
// Powers of x mod M(x).
var powx = [16]byte{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f}
type Construction struct {
// A 128-byte BES key.
Key gfmat... | constructions/bes/bes.go | 0.613468 | 0.475666 | bes.go | starcoder |
package symbol
import (
"github.com/kocircuit/kocircuit/lang/circuit/model"
"github.com/kocircuit/kocircuit/lang/go/kit/tree"
)
func Unify(span *model.Span, x, y Type) (Type, error) {
ctx := &typingCtx{Span: span}
return ctx.Unify(x, y)
}
func UnifyTypes(span *model.Span, tt []Type) (Type, error) {
ctx := &typ... | lang/go/eval/symbol/unify.go | 0.52975 | 0.468304 | unify.go | starcoder |
package layers
import (
"fmt"
"github.com/nathanleary/reticulum/volume"
)
// NewRegressionLayer creates a new regression layer.
func NewRegressionLayer(def LayerDef) Layer {
if def.Type != Regression {
panic(fmt.Errorf("Invalid layer type: %s != regression", def.Type))
}
// Get config
conf, ok := def.LayerC... | layers/regression.go | 0.761627 | 0.41117 | regression.go | starcoder |
package game
import (
"strings"
"strconv"
"regexp"
"errors"
"constants"
)
type Board struct {
Quadrants [4][3][3]string
}
type TwoDimensionArrayBoard struct {
Board [][]int `json:"board"`
CurrentPlayer int `json:"currentPlayer"`
}
func DeserializeTwoDimensionArrayBoard(arr TwoDimensionArrayBoard) Board {
v... | src/game/game.go | 0.727685 | 0.483648 | game.go | starcoder |
package validator
import "regexp"
var postCodePatternDict = map[string]string{
"GB": `^GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|N... | vendor/github.com/go-playground/validator/v10/postcode_regexes.go | 0.512693 | 0.68431 | postcode_regexes.go | starcoder |
package nav
import (
"fmt"
"math"
"github.com/golang/geo/s1"
"github.com/golang/geo/s2"
)
// A Speed represents the change in position
// as a float64 meters per second count.
type Speed float64
type Distance float64
const (
Meters Distance = 1
Kilometers = Meters * 1000
)
func (d Distance) Met... | pkg/nav/nav.go | 0.89662 | 0.58673 | nav.go | starcoder |
package geom
//MultiPolygon is a collection of two-dimensional geometries representing polygons
type MultiPolygon []Polygon
//MultiPolygonZ is a collection of three-dimensional geometries representing polygons
type MultiPolygonZ []PolygonZ
//MultiPolygonM is a collection of two-dimensional geometries representing p... | multipolygon.go | 0.899105 | 0.734048 | multipolygon.go | starcoder |
package mat
// MulGaxpy is a General AXPY algorithm to multiple 2 matrices.
// Author: @james-bowman
func MulGaxpy(c, a, b *Dense) error {
aCols := a.Columns()
aRows := a.Rows()
bCols := b.Columns()
var data = c.data
// IKJ
for i := 0; i < aRows; i++ {
for k := 0; k < aCols; k++ {
s := a.data[i*aCols+k]
... | mat/product.go | 0.828592 | 0.449574 | product.go | starcoder |
package benefit
/*******************************************************************************
* The ssa package an implementation of the algorithms that are used to
* calculate or estimate the Social Security benefits for a retiree.
*
* Here's a simple description of how it all works:
* - The Average Wage Inde... | benefit/calc.go | 0.694199 | 0.481088 | calc.go | starcoder |
package fmom
import (
"fmt"
"math"
)
// Equal returns true if p1==p2
func Equal(p1, p2 P4) bool {
return p4equal(p1, p2, 1e-14)
}
func p4equal(p1, p2 P4, epsilon float64) bool {
if cmpeq(p1.E(), p2.E(), epsilon) &&
cmpeq(p1.Px(), p2.Px(), epsilon) &&
cmpeq(p1.Py(), p2.Py(), epsilon) &&
cmpeq(p1.Pz(), p2.P... | fmom/ops.go | 0.640748 | 0.539529 | ops.go | starcoder |
package schema
import (
"encoding/json"
"fmt"
"reflect"
"regexp"
"strconv"
)
// Formats specific to GeoPoint field type.
const (
GeoPointArrayFormat = "array"
GeoPointObjectFormat = "object"
)
// GeoPoint represents a "geopoint" cell.
// More at: https://specs.frictionlessdata.io/table-schema/#geopoint
type ... | schema/geopoint.go | 0.699973 | 0.404949 | geopoint.go | starcoder |
package vmath
import (
"fmt"
"math"
"github.com/maja42/vmath/mathi"
)
type Vec3i [3]int
func (v Vec3i) String() string {
return fmt.Sprintf("Vec3i[%d x %d x %d]", v[0], v[1], v[2])
}
// Format the vector to a string.
func (v Vec3i) Format(format string) string {
return fmt.Sprintf(format, v[0], v[1], v[2])
}
... | vec3i.go | 0.913061 | 0.683043 | vec3i.go | starcoder |
package verzettler
// Page represents a set of items and a grid of Rows and Cols.
type Page struct {
Items []string
Rows int
Cols int
}
// NewPage creats a Page with an empty Items slice of size Rows*Cols.
func NewPage(rows, cols int) Page {
n := rows * cols
items := make([]string, n)
return Page{items, rows,... | paging.go | 0.756447 | 0.427098 | paging.go | starcoder |
package mesh
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"github.com/weqqr/panorama/lm"
)
func parseVector3(fields []string) (lm.Vector3, error) {
if len(fields) < 3 {
return lm.Vector3{}, fmt.Errorf("expected at least 3 vector elements, found %d", len(fields))
}
x, err := strconv.ParseFloat(fields[0... | mesh/obj.go | 0.584745 | 0.522324 | obj.go | starcoder |
package util
import (
"math"
"sort"
"strconv"
"github.com/zvandehy/DataTrain/nba_graphql/graph/model"
)
//SimilarPlayers uses the euclidean distance formula to calculate the similarity between the given list of players and the target player
// and returns the 10 closest players to the target player "toPlayer"
fu... | nba_graphql/util/similarity.go | 0.750918 | 0.442094 | similarity.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_bayesian_linear_regression
#include <capi/bayesian_linear_regression.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type BayesianLinearRegressionOptionalParam struct {
Center bool
Input *mat.Dense
InputMod... | bayesian_linear_regression.go | 0.722918 | 0.606906 | bayesian_linear_regression.go | starcoder |
package cornellbox
import (
"math"
"github.com/peterstace/grayt/scene"
"github.com/peterstace/grayt/scene/dsl"
"github.com/peterstace/grayt/xmath"
)
func CornellCam(d float64) scene.Camera {
c := dsl.DefaultCamera()
c.Location = xmath.Vect(0.5, 0.5, d)
c.LookingAt = xmath.Vect(0.5, 0.5, -0.5)
c.FieldOfViewIn... | scene/cornellbox/shared.go | 0.571288 | 0.532182 | shared.go | starcoder |
package main
import "fmt"
// tag::ops[]
const (
// Ops.
opInp = 'i'
opAdd = 'a'
opMul = 'm'
opDiv = 'd'
opMod = 'o'
opEql = 'e'
// Registers.
inReg = 'w'
regW = 'w'
regX = 'x'
regY = 'y'
regZ = 'z'
)
type op struct {
act rune
reg rune
dat interface{}
}
// String gets a string rep.
func (o op) S... | day24/go/razziel89/ops.go | 0.536313 | 0.582432 | ops.go | starcoder |
package enigmamachine
import (
"fmt"
"strings"
)
// MachineSetup describes the setup of an Enigma Machine. This describes the
// Reflector, Rotors and Plugboard setup. This passed to New to describe the
// setup of a new Machine instance.
type MachineSetup struct {
Reflector ReflectorSpec
Rotors []Roto... | machine.go | 0.704058 | 0.431824 | machine.go | starcoder |
package matrix
import (
"math"
"github.com/anolson/rtc/tuple"
)
// Transform returns the result of applying a transformation to a Tuple
func Transform(m *Matrix, t *tuple.Tuple) *tuple.Tuple {
return MultiplyByTuple(m, t)
}
// Chain returns the result of applying a multiple transformations to a Tuple
func Chain(... | matrix/transformation.go | 0.893242 | 0.705798 | transformation.go | starcoder |
package conditions
import (
"math"
"sort"
"github.com/smartems/smartems/pkg/components/null"
"github.com/smartems/smartems/pkg/tsdb"
)
// queryReducer reduces an timeserie to a nullable float
type queryReducer struct {
// Type is how the timeserie should be reduced.
// Ex avg, sum, max, min, count
Type stri... | pkg/services/alerting/conditions/reducer.go | 0.606382 | 0.421076 | reducer.go | starcoder |
package geogoth
// MultiPolygon ...
type MultiPolygon struct {
Coords [][][][]float64
}
// NewMultiPolygon creates MultiPolygon
func NewMultiPolygon(coords [][][][]float64) MultiPolygon {
return MultiPolygon{
Coords: coords,
}
}
// Coordinates returns array of longitude, latitude of the MultiPolygon
func (m Mul... | multipolygon.go | 0.890526 | 0.749294 | multipolygon.go | starcoder |
package bulletproofs
import (
"fmt"
"github.com/incognitochain/go-incognito-sdk-v2/crypto"
"github.com/incognitochain/go-incognito-sdk-v2/privacy/utils"
)
// ConvertUint64ToBinary represents a integer number in binary.
func ConvertUint64ToBinary(number uint64, n int) []*crypto.Scalar {
if number == 0 {
res := m... | privacy/v1/zkp/bulletproofs/bulletproofs_helper.go | 0.655557 | 0.541045 | bulletproofs_helper.go | starcoder |
package geometry
import (
"math"
)
type Vector struct {
X, Y float64
}
func New(x float64, y float64) Vector {
return Vector{X: x, Y: y}
}
func (v *Vector) Hashcode() (hash uint64) {
x, y := uint64(v.X), uint64(v.Y)
hash = x + y
return
}
func (v *Vector) Equals(oi interface{}) (equals bool) {
o, equals := o... | geometry/vector.go | 0.885996 | 0.746924 | vector.go | starcoder |
package raytrace
import (
"errors"
"image/color"
"math"
)
// Element ...
type Element struct {
element Intersectable
albedo float32
}
// Sphere ...
type Sphere struct {
center Point
radius float64
color color.Color
}
// Plane ...
type Plane struct {
origin Point
normal Vector
color color.Color
}
// I... | raytrace/objects.go | 0.850096 | 0.432303 | objects.go | starcoder |
package testutil
import (
"flag"
"os"
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
var updateGolden = flag.Bool("update-golden", false, "Update golden test files")
var dryGolden = flag.Bool("dry-golden", false, "Used together with -update-golden. If set, write to separate, ignored... | testutil/golden_util.go | 0.514888 | 0.403009 | golden_util.go | starcoder |
package idemix
import (
"github.com/sinochem-tech/fabric-amcl/amcl"
"github.com/sinochem-tech/fabric-amcl/amcl/FP256BN"
"github.com/pkg/errors"
)
// NewSignature creates a new idemix pseudonym signature
func NewNymSignature(sk *FP256BN.BIG, Nym *FP256BN.ECP, RNym *FP256BN.BIG, ipk *IssuerPublicKey, msg []byte, rng... | idemix/nymsignature.go | 0.696887 | 0.446434 | nymsignature.go | starcoder |
package cimg
import (
"errors"
"image"
)
// Image is the concrete image type that is used by all functions
// inside cimg.
type Image struct {
Width int
Height int
Stride int
NChan int
Pixels []byte
}
// NewImage creates a new 8-bit image
func NewImage(width, height, nchan int) *Image {
return &Image{
Wi... | image.go | 0.714628 | 0.474936 | image.go | starcoder |
package main
import (
"encoding/xml"
"strings"
"golang.org/x/net/html/charset"
)
/*RSSV2 - What is RSS?
RSS is a Web content syndication format.
Its name is an acronym for Really Simple Syndication.
RSS is dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide We... | server/rss-v2-parser.go | 0.684897 | 0.410166 | rss-v2-parser.go | starcoder |
package typeutil
import (
"errors"
"fmt"
"strconv"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/proto/schemapb"
"go.uber.org/zap"
)
func GetMaxLengthOfVarLengthField(fieldSchema *schemapb.FieldSchema) (int, error) {
maxLength := 0
var err error
paramsMap := make(map[str... | internal/util/typeutil/schema.go | 0.658637 | 0.441432 | schema.go | starcoder |
package match
import (
"go/types"
"github.com/yndd/ndd-tools/internal/comments"
"github.com/yndd/ndd-tools/internal/fields"
)
// An Object matcher is a function that returns true if the supplied object
// matches.
type Object func(o types.Object) bool
// Managed returns an Object matcher that returns true if the... | internal/match/match.go | 0.732687 | 0.454714 | match.go | starcoder |
package taipei
// As defined by the bittorrent protocol, this bitset is big-endian, such that
// the high bit of the first byte is block 0
type Bitset struct {
b []byte
n int
endIndex int
endMask byte // Which bits of the last byte are valid
}
func NewBitset(n int) *Bitset {
endIndex, endOffset :... | bitset.go | 0.613237 | 0.429549 | bitset.go | starcoder |
package optimus
import "sync"
// Table is a representation of a table of data.
type Table interface {
// Rows returns a channel that provides the Rows in the table.
Rows() <-chan Row
// Err returns the first non-EOF error that was encountered by the Table.
Err() error
// Stop signifies that a Table should stop s... | plugins/data/transform/optimus/optimus.go | 0.634656 | 0.518059 | optimus.go | starcoder |
package tree
import (
"fmt"
"sync"
)
type TreeNode struct {
value int
left *TreeNode
right *TreeNode
}
type BinarySearchTree struct {
root *TreeNode
lock sync.RWMutex
}
func (tree *BinarySearchTree) InsertElement(value int) {
tree.lock.Lock()
defer tree.lock.Unlock()
var currTree *TreeNode
currTree = &T... | Tree/binaryTree.go | 0.617513 | 0.410874 | binaryTree.go | starcoder |
package year2021
import (
"io/ioutil"
"math"
"regexp"
"github.com/lanphiergm/adventofcodego/internal/utils"
)
// Trick Shot Part 1 computes the highest Y position the probe reaches
func TrickShotPart1(filename string) interface{} {
xMin, xMax, yMin, yMax := parseTargetArea(filename)
// Use a finite sum to det... | internal/puzzles/year2021/day_17_trick_shot.go | 0.646014 | 0.40987 | day_17_trick_shot.go | starcoder |
package store
import (
"bytes"
"errors"
"fmt"
"math"
"github.com/DataDog/sketches-go/ddsketch/pb/sketchpb"
)
const (
arrayLengthOverhead = 64
arrayLengthGrowthIncrement = 0.1
// Grow the bins with an extra growthBuffer bins to prevent growing too often
growthBuffer = 128
)
// DenseStore is a dynam... | ddsketch/store/dense_store.go | 0.721253 | 0.451145 | dense_store.go | starcoder |
package gui
import (
"github.com/Glenn-Gray-Labs/g3n/gls"
"github.com/Glenn-Gray-Labs/g3n/math32"
"github.com/Glenn-Gray-Labs/g3n/text"
"github.com/Glenn-Gray-Labs/g3n/texture"
)
// Label is a panel which contains a texture with text.
// The content size of the label panel is the exact size of the texture.
type ... | gui/label.go | 0.734501 | 0.445952 | label.go | starcoder |
package breathFirstSearch
// An image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image.
// You are also given three integers sr, sc, and newColor. You should perform a flood fill on the image starting from the pixel image[sr][sc].
// To perform a flood fill, consi... | algorithmsI/breathFirstSearch/breathFirstSearch.go | 0.87866 | 0.884987 | breathFirstSearch.go | starcoder |
package assert
import (
"reflect"
"strings"
)
// isNil returns true if value v is nil.
func isNil(v interface{}) bool {
if v == nil {
return true
} else { // a `interface{}` that returns false on an equality check against nil isn't necessarily not nil and requires further attention
switch reflect.TypeOf(v).Ki... | assert/util.go | 0.804943 | 0.600423 | util.go | starcoder |
package hunter
import (
"errors"
"github.com/eaglerock1337/gobat/pkg/board"
)
// These two variables allow for conversion of each square status to
// the status string and vice-versa. This allows for statuses to be stored
// as integers for faster lookup and comparison.
var (
values = map[string]int{
"Empty": 0... | pkg/hunter/hunter.go | 0.739516 | 0.469155 | hunter.go | starcoder |
package list
// Iterator defines a list iterator
type Iterator interface {
// Next iterates to the next element in the list and returns the iterator, or nil if there is no next element
Next() Iterator
// Previous iterates to the previous element in the list and returns the iterator, or nil if there is no previous e... | list/list.go | 0.725746 | 0.512815 | list.go | starcoder |
package imap
type Imap struct {
tree avlTree
}
type avlNode struct {
key uint64 // Interval low
left, right *avlNode
parent *avlNode
heightCache int
high uint64
value interface{}
}
func (n *avlNode) interval() Interval {
return Interval{n.key, n.high}
}
func (m *Imap) Insert(key Interval, va... | internal/imap/imap.go | 0.710025 | 0.437403 | imap.go | starcoder |
package binary
import (
"math"
"github.com/m3db/m3/src/query/block"
"github.com/m3db/m3/src/query/executor/transform"
)
const (
// EqType checks that lhs is equal to rhs
EqType = "=="
// NotEqType checks that lhs is equal to rhs
NotEqType = "!="
// GreaterType checks that lhs is equal to rhs
GreaterType ... | src/query/functions/binary/comparison.go | 0.725746 | 0.436142 | comparison.go | starcoder |
package helpers
import (
"fmt"
"log"
"runtime/debug"
"github.com/DimensionDataResearch/go-dd-cloud-compute/compute"
"github.com/DimensionDataResearch/packer-plugins-ddcloud/artifacts"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
)
// ForStateBag ... | helpers/state.go | 0.666497 | 0.448185 | state.go | starcoder |
package advent
import (
. "github.com/davidparks11/advent2021/internal/advent/day18"
)
var _ Problem = &snailFish{}
type snailFish struct {
dailyProblem
}
func NewSnailFish() Problem {
return &snailFish{
dailyProblem{
day: 18,
},
}
}
func (s *snailFish) Solve() interface{} {
input := s.GetInputLines()
... | internal/advent/day18.go | 0.53048 | 0.506286 | day18.go | starcoder |
package smartagentreceiver
import (
"fmt"
"time"
sfx "github.com/signalfx/golib/v3/datapoint"
"go.opentelemetry.io/collector/consumer/pdata"
"go.uber.org/zap"
)
var (
errUnsupportedMetricTypeTimestamp = fmt.Errorf("unsupported metric type timestamp")
errNoIntValue = fmt.Errorf("no valid va... | internal/receiver/smartagentreceiver/convert.go | 0.715026 | 0.403978 | convert.go | starcoder |
package dataframe
import (
"fmt"
"strings"
"github.com/isuruceanu/gota/series"
)
type combineFuncType func(a, b series.Series) bool
type combineHeaderBuilderFuncType func(a, b series.Series) (string, interface{}, bool)
// Merge struct definition
type Merge struct {
a DataFrame
b ... | dataframe/merge.go | 0.567457 | 0.541651 | merge.go | starcoder |
package services
import "fmt"
type Vertex struct {
Data string
Vertices map[string]*Vertex
}
func NewVertex(data string) *Vertex {
return &Vertex{
Data: data,
Vertices: make(map[string]*Vertex),
}
}
type Graph struct {
Vertices map[string]*Vertex
directed bool
}
func NewDirectedGraph() *Graph {
return ... | pkg/server/services/graph.go | 0.710528 | 0.485539 | graph.go | starcoder |
package ical
import (
"encoding/base64"
"fmt"
"net/url"
"strconv"
"strings"
"time"
)
// MIME type and file extension for iCal, defined in RFC 5545 section 8.1.
const (
MIMEType = "text/calendar"
Extension = "ics"
)
// Params is a set of property parameters.
type Params map[string][]string
func (params Para... | ical.go | 0.634543 | 0.426262 | ical.go | starcoder |
package evolution
import "fmt"
// DualTreeNode represents a a treeNode with a maximum of two children.
// It is not technically a binary treeNode as it DOES not place any ordering on left and right children as binary trees
// prototypically do.
type DualTreeNode struct {
key string
value string
left *DualTreeNo... | evolution/dualtreenode.go | 0.819821 | 0.630656 | dualtreenode.go | starcoder |
package feedforward
// Represents a layer of a feedforward neural network.
type layer interface {
initialize(Initializer)
processInput([]float64) []float64
getOutputCache() []float64
processError([]float64) []float64
getWeights() [][]float64
getBiases() []float64
}
// Base layer implementation
type baseLayer st... | layers.go | 0.88 | 0.461199 | layers.go | starcoder |
package accounting
import (
"encoding/json"
)
// TaxType Represents a tax in the external accounting system.
type TaxType struct {
// The code/ID of the tax in the external accounting system.
Code string `json:"code"`
// The display name of the tax.
Name *string `json:"name,omitempty"`
}
// NewTaxType instanti... | generated/accounting/model_tax_type.go | 0.757705 | 0.426083 | model_tax_type.go | starcoder |
package cast
import (
"fmt"
"time"
)
// ToDuration casts an interface{} to a time.Duration.
func ToDuration(i interface{}, unit ...string) time.Duration {
v, _ := ToDurationE(i, unit...)
return v
}
// ToDurationE casts an interface{} to a time.Duration.
func ToDurationE(i interface{}, unit ...string) (time.Durat... | cast/duration.go | 0.758689 | 0.515193 | duration.go | starcoder |
package runematcher
import (
"fmt"
"strings"
"unicode/utf8"
)
func negate(m Matcher) Matcher {
return negatedMatcher{m}
}
func and(first, second Matcher) Matcher {
return andMatcher{first, second}
}
func or(first, second Matcher) Matcher {
return orMatcher{first, second}
}
func matchesAnyOf(m Matcher, str st... | base/runematcher/common.go | 0.508544 | 0.431045 | common.go | starcoder |
package main
/*
--- Day 2: Dive! ---
Now, you need to figure out how to pilot this thing.
It seems like the submarine can take a series of commands like forward 1, down 2, or up 3:
forward X increases the horizontal position by X units.
down X increases the depth by X units.
up X decreases the depth by ... | day2/day2.go | 0.591015 | 0.687902 | day2.go | starcoder |
package list
const WithParamFunctions = `
//-------------------------------------------------------------------------------------------------
// List:With[{{.TypeParameter}}]
// FoldLeft{{.TypeParameter.LongName}} applies a binary operator to a start value and all elements of this list, going left to right.
func (lis... | internal/list/withT.go | 0.692642 | 0.64607 | withT.go | starcoder |
package vp8
// filter2 modifies a 2-pixel wide or 2-pixel high band along an edge.
func filter2(pix []byte, level, index, iStep, jStep int) {
for n := 16; n > 0; n, index = n-1, index+iStep {
p1 := int(pix[index-2*jStep])
p0 := int(pix[index-1*jStep])
q0 := int(pix[index+0*jStep])
q1 := int(pix[inde... | vendor/golang.org/x/image/vp8/filter.go | 0.553143 | 0.415729 | filter.go | starcoder |
package cmd
import (
"fmt"
"image"
"image/draw"
"os"
"github.com/spf13/cobra"
i "github.com/davidwarshaw/tiletool/cmd/internal"
)
var extrudeCmd *cobra.Command
var thickness int
func extrudeTile(tileImage *image.NRGBA, thickness int) (extruded *image.NRGBA) {
extrudedRect := tileImage.Bounds().Inset(-thickn... | cmd/extrude.go | 0.542379 | 0.436562 | extrude.go | starcoder |
package cross_validation
import (
"fmt"
mat "github.com/gonum/matrix/mat64"
"math/rand"
"sync"
"time"
)
func shuffleMatrix(returnDatasets []*mat.Dense, dataset mat.Matrix, testSize int, seed int64, wg *sync.WaitGroup) {
numGen := rand.New(rand.NewSource(seed))
// We don't want to alter the original dataset.
... | cross_validation/cross_validation.go | 0.655667 | 0.527134 | cross_validation.go | starcoder |
package main
import (
"regexp"
"strconv"
s "strings"
)
/**
--- Day 3: Crossed Wires ---
The gravity assist was successful, and you're well on your way to the Venus refuelling station. During the rush back on Earth, the fuel management system wasn't completely installed, so that's next on the priority list.
Openi... | go/2019/2019_3.go | 0.770378 | 0.63392 | 2019_3.go | starcoder |
package mat
// Point is a vector type with X and Y coordinates.
type Point struct {
X, Y int
}
// ZP is zero value Point
var ZP Point
// P returns a new vector with the given coordinates.
func P(x, y int) Point {
return Point{x, y}
}
// XY returns the components of the vector in two return values.
func (v Poin... | mat/gogen-output.go | 0.940953 | 0.588416 | gogen-output.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.