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 battleship
import "io"
// NewGame returns a new zero game object, filled in with default values.
func NewGame() *G {
/* Fill in this Function */
return &G{}
}
// G represents the game, and the state of the game. This is the main structure the run loop should interact with.
type G struct{}
// PlaceShip all... | battleship/game.go | 0.74872 | 0.479991 | game.go | starcoder |
package gompatible
import (
"go/types"
)
// FuncChange represents a change between functions.
type FuncChange struct {
Before *Func
After *Func
}
func (fc FuncChange) TypesObject() types.Object {
return fc.Before.Types
}
func (fc FuncChange) ShowBefore() string {
f := fc.Before
if f == nil || f.Doc == nil {
... | func.go | 0.743634 | 0.464719 | func.go | starcoder |
package mysql_db
import (
flatbuffers "github.com/google/flatbuffers/go"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/mysql_db/serial"
)
// serializePrivilegeTypes writes the given PrivilegeTypes into the flatbuffer Builder using the given flatbuffer start function, and return... | sql/mysql_db/mysql_db_serialize.go | 0.553505 | 0.487429 | mysql_db_serialize.go | starcoder |
package main
/**
题目介绍:https://www.nowcoder.com/practice/e3769a5f49894d49b871c09cadd13a61?tpId=117&tqId=1006010&tab=answerKey
* 题目描述
设计LRU缓存结构,该结构在构造时确定大小,假设大小为K,并有如下两个功能
set(key, value):将记录(key, value)插入该结构
get(key):返回key对应的value值
[要求]
set和get方法的时间复杂度为O(1)
某个key的set或get操作一旦发生,认为这个key的记录成了最常使用的。
当缓存的大小超过K时,移除最不经常使用的记录,... | cache/lru.go | 0.61659 | 0.474083 | lru.go | starcoder |
package kubernetes
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/cio/api/types"
"github.com/ingrammicro/cio/utils"
"github.com/stretchr/testify/assert"
)
// ListClustersMocked test mocked function
func ListClustersMocked(t *testing.T, clustersIn []*types.Cluster) []*types.Cluster {
assert... | api/kubernetes/clusters_api_mocked.go | 0.731155 | 0.489076 | clusters_api_mocked.go | starcoder |
package vetsql
// INTS
const minU = 0
const minInt = -2147483648
const maxInt = 2147483647
const maxUInt = 4294967295
const minTinyInt = -128
const maxTinyInt = 127
const maxUTinyInt = 255
const minSmallInt = -32768
const maxSmallInt = 32767
const maxUSmallInt = 65535
const minMediumInt = -8388608
const maxMediumI... | govetsql.go | 0.637369 | 0.430387 | govetsql.go | starcoder |
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"math"
"os"
"strconv"
)
// squaredError returns the error associted with a particular
// pair of prediction and observation.
func squaredError(observation, prediction float64) float64 {
return math.Pow(observation-prediction, 2)
}
// sgdTrain calculates t... | linear_regression/example3/example3.go | 0.823435 | 0.512449 | example3.go | starcoder |
package xiao
import (
"github.com/OpenWhiteBox/primitives/encoding"
"github.com/OpenWhiteBox/primitives/matrix"
)
// When you compose a matrix with 16-by-16 blocks with ShiftRows, you get a matrix with one 16-by-8 block in each
// column. The value in blockPos at position i is the vertical position of the ith block... | cryptanalysis/xiao/affine.go | 0.760473 | 0.537588 | affine.go | starcoder |
package assert
import (
"testing"
"time"
"github.com/ppapapetrou76/go-testing/internal/pkg/types"
)
// AssertableTime is the assertable structure for time.Time values.
type AssertableTime struct {
t *testing.T
actual types.TimeValue
}
// ThatTime returns an AssertableTime structure initialized with the te... | assert/time.go | 0.81637 | 0.782372 | time.go | starcoder |
package vector
import (
"fmt"
"github.com/go-gl/mathgl/mgl32"
"math"
)
type Vector2d struct {
X, Y float64
}
func NewVec2d(x, y float64) Vector2d {
return Vector2d{x, y}
}
func NewVec2dRad(rad, length float64) Vector2d {
return Vector2d{math.Cos(rad) * length, math.Sin(rad) * length}
}
func (v Vector2d) X32(... | framework/math/vector/vector2d.go | 0.872198 | 0.753625 | vector2d.go | starcoder |
package parser
import "fmt"
// state is the state of the parsing FSA.
type state int
const (
// psEmpty states that we haven't read anything yet.
psEmpty state = iota
// psPreTest states that we haven't hit the actual test yet.
// In this state, we feed any line that isn't the 'Test' line to the implementation.... | internal/serviceimpl/backend/herdstyle/parser/fsa.go | 0.605099 | 0.556821 | fsa.go | starcoder |
package export
import (
color2 "github.com/RH12503/Triangula/color"
"github.com/RH12503/Triangula/geom"
"github.com/RH12503/Triangula/image"
"github.com/RH12503/Triangula/normgeom"
"github.com/RH12503/Triangula/rasterize"
"github.com/RH12503/Triangula/render"
"github.com/RH12503/Triangula/triangulation"
"githu... | export/effect.go | 0.597021 | 0.416797 | effect.go | starcoder |
package main
import (
"log"
"math/rand"
"github.com/go-gl/gl/v4.1-core/gl"
)
var (
squarePoints = []float32{
// Bottom left right-angle triangle
-1, 1, 0,
1, -1, 0,
-1, -1, 0,
// Top right right-angle triangle
-1, 1, 0,
1, 1, 0,
1, -1, 0,
}
squarePointCount = int32(len(squarePoints) / 3)
)
t... | cell.go | 0.663996 | 0.52074 | cell.go | starcoder |
package day267
// Chessboard is a slice of strings. The first string represents the top row
// and the last string represents the bottom row of the board.
// The top is the black player's side and the bottom is the white player's side.
type Chessboard []string
// IsSoloBlackKingInCheck answers if a solo black king is... | day267/problem.go | 0.725843 | 0.566139 | problem.go | starcoder |
package physics2d
import (
"github.com/ByteArena/box2d"
"github.com/PucklaMotzer09/GoHomeEngine/src/gohome"
"github.com/PucklaMotzer09/mathgl/mgl32"
"github.com/PucklaMotzer09/tmx"
"runtime"
"strconv"
"strings"
"sync"
)
var (
// Defines how big one meter is
PIXEL_PER_METER float32 = 100.0
// Defines th... | src/physics2d/physicsmanager2d.go | 0.721939 | 0.701731 | physicsmanager2d.go | starcoder |
package a
import (
"fmt"
"strings"
)
// Color represents a color in RGBA format.
type Color struct {
R, G, B, A byte
}
// Creates new Color struct using the specified arguments.
// This function can accept the following arguments:
// - a color hex string,
// - 1 byte value for grayscale color,
// - 3 byte values ... | common/a/color.go | 0.823257 | 0.486758 | color.go | starcoder |
package problem
import (
"github.com/water-vapor/euclidea-solver/pkg/geom"
"math"
)
// Problem 1: Angel Of 60 Degree
func angelOf60Degree() *Statement {
problem := geom.NewBoard()
pt1 := geom.NewPoint(0, 0)
pt2 := geom.NewPoint(1, math.Sqrt(3))
problem.AddPoint(pt1)
problem.HalfLines.Add(geom.NewHalfLineFromD... | problem/alpha.go | 0.779196 | 0.40031 | alpha.go | starcoder |
package decoder
import (
"fmt"
"math"
"github.com/rqme/neat"
)
// Special case: 1 layer of nodes in this case, examine nodes to separate out "vitural layers" by neuron type
// othewise connect every neuron in one layer to the subsequent layer
type HyperNEATSettings interface {
SubstrateLayers() []SubstrateNodes... | decoder/hyperneat.go | 0.594434 | 0.415195 | hyperneat.go | starcoder |
package mm
import (
"fmt"
"math"
)
type Box3 struct {
Min *Vector3
Max *Vector3
}
func NewBox3() *Box3 {
return &Box3{
Vector3_Max(),
Vector3_Min(),
}
}
func (b *Box3) String() string {
return fmt.Sprintf("&Box3{Min: %s, Max: %s}", b.Min, b.Max)
}
func (b *Box3) Set(min... | box3.go | 0.710025 | 0.605595 | box3.go | starcoder |
package main
/*
Write a program to sort an array of integers. The program should partition the array into 4 parts,
each of which is sorted by a different goroutine. Each partition should be of approximately equal size.
Then the main goroutine should merge the 4 sorted subarrays into one large sorted array.
The progra... | src/course3/module3/gosort.go | 0.568895 | 0.467149 | gosort.go | starcoder |
package api
import (
"encoding/binary"
"log"
)
// Copy returns an ImageData with a separate Data slice copied from the original.
func (img ImageData) Copy() ImageData {
data := make([]byte, len(img.Data))
copy(data, img.Data)
return ImageData{
BitsPerPixel: img.BitsPerPixel,
Size_: &Size2DI{X: img.Si... | api/image.go | 0.864682 | 0.689946 | image.go | starcoder |
package vehicle
import "github.com/dpb587/go-schemaorg"
var (
// Indicates whether the vehicle has been used for special purposes, like
// commercial rental, driving school, or as a taxi. The legislation in many
// countries requires this information to be revealed when offering a car for
// sale.
VehicleSpecial... | things/vehicle/properties.go | 0.582016 | 0.402891 | properties.go | starcoder |
package types
import (
"math"
"strconv"
)
// Color3 represents a color in RGB space.
type Color3 struct {
R, G, B float32
}
// NewColor3FromRGB returns a Color3 from the given red, green, and blue
// components, each having an interval of [0, 255].
func NewColor3FromRGB(r, g, b int) Color3 {
return Color3{
R: ... | Color3.go | 0.913484 | 0.522446 | Color3.go | starcoder |
package archive
import "math"
// GameVariableLimits describes limits of a game variable.
type GameVariableLimits struct {
Minimum int16
Maximum int16
}
// GameVariableInfo describes a variable in the game state of the archive.
type GameVariableInfo struct {
// InitValue is nil if the initial value is system depen... | ss1/content/archive/Variables.go | 0.816004 | 0.54359 | Variables.go | starcoder |
package corgi
import (
"os"
"time"
"strconv"
)
var predefineVariables []*Variable = []*Variable {
&Variable {
Name : "hostname",
Get : predefineVariableHostname,
Flags : VARIABLE_CHANGEABLE,
},
&Variable {
Name : "time_local",
Get : predefineVar... | predefine.go | 0.533884 | 0.4016 | predefine.go | starcoder |
package world
import (
"fmt"
"math"
"github.com/go-gl/mathgl/mgl32"
"github.com/samuelyuan/openbiohazard2/fileio"
)
func RemoveCollisionEntity(collisionEntities []fileio.CollisionEntity, entityId int) {
for i, entity := range collisionEntities {
if entity.ScaIndex == entityId {
collisionEntities = append(c... | world/collision.go | 0.711932 | 0.514888 | collision.go | starcoder |
package mocks
import "time"
// MetricsProvider implements a mock ActivityPub metrics provider.
type MetricsProvider struct{}
// OutboxPostTime records the time it takes to post a message to the outbox.
func (m *MetricsProvider) OutboxPostTime(value time.Duration) {
}
// OutboxResolveInboxesTime records the time it ... | pkg/mocks/metricsprovider.go | 0.705582 | 0.450359 | metricsprovider.go | starcoder |
package enigma
import (
"fmt"
)
// Enigma represents the whole Enigma machine
type Enigma struct {
Model
plugboard plugboard
entryWheel etw
rotors []rotor
reflector reflector
}
// RotorSlot represents the slot for the rotor. Most Enigmas had three
type RotorSlot int
// all available rotor slots
const (
... | enigma.go | 0.785267 | 0.424173 | enigma.go | starcoder |
package elastic
// The geo_distance facet is a facet providing information for ranges of
// distances from a provided geo_point including count of the number of hits
// that fall within each range, and aggregation information (like total).
// See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/... | Godeps/_workspace/src/github.com/google/cadvisor/Godeps/_workspace/src/gopkg.in/olivere/elastic.v2/search_facets_geo_distance.go | 0.933476 | 0.600481 | search_facets_geo_distance.go | starcoder |
package aoc2020
/*
Day 08 - Handheld Halting
https://adventofcode.com/2020/day/8
Your flight to the major airline hub reaches cruising altitude without incident. While you consider checking the in-flight menu for one of those drinks that come with a little umbrella, you are interrupted by the kid sitting next to you.... | app/aoc2020/aoc2020_08.go | 0.685844 | 0.7003 | aoc2020_08.go | starcoder |
package streams
import "io"
// ByteFilterr filters all intercepted bytes based on the passed ByteFilterFunc. It should
// be safe to use either a statefull or idempotent function in this. However you should avoid reuse
// of a stateful ByteFilterFunc as correct behavior is difficult and error prone to implement.
type... | byte_filter.go | 0.763131 | 0.464719 | byte_filter.go | starcoder |
package kneedle
import (
"math"
"github.com/pkg/errors"
)
/*
Given set of values, look for the elbow/knee points.
See paper: "Finding a Kneedle in a Haystack: Detecting Knee Points in System Behavior"
@author Jagatheesan
*/
// findCancidateIndices finds the indices of all local minimum or local maximum value... | kneedle.go | 0.584508 | 0.520862 | kneedle.go | starcoder |
package bingo
import (
"encoding/base64"
"errors"
"math/rand"
"strconv"
"strings"
"time"
)
type (
// Game represents a bingo game. The zero value can be used to start a new game.
Game struct {
numbers [MaxNumber - MinNumber + 1]Number
numbersDrawn int
}
// Resetter resets games to valid, shuffled ... | bingo/game.go | 0.565299 | 0.470433 | game.go | starcoder |
package aut
import (
"bufio"
"bytes"
"io"
"strconv"
)
// Scanner is a lexical scanner.
type Scanner struct {
r *bufio.Reader
pos TokenPos
}
// NewScanner returns a new instance of Scanner.
func NewScanner(r io.Reader) *Scanner {
return &Scanner{r: bufio.NewReader(r), pos: TokenPos{Char: 0, Lines: []int{}}}
... | scanner.go | 0.585931 | 0.501526 | scanner.go | starcoder |
package influxql
import (
"bytes"
"container/heap"
"fmt"
"math"
"sort"
"time"
)
/*
This file contains iterator implementations for each function call available
in InfluxQL. Call iterators are separated into two groups:
1. Map/reduce-style iterators - these are passed to IteratorCreator so that
processing ca... | influxql/call_iterator.go | 0.741768 | 0.476397 | call_iterator.go | starcoder |
package trie
// Trie is a trie. It doesn't support unicode strings.
type Trie struct {
name byte
terminal bool
children []*Trie
pfxMap map[string][]string
}
func (t *Trie) getNode(c byte) *Trie {
for _, n := range t.children {
if n.name == c {
return n
}
}
return nil
}
func (t *Trie) addChar(c b... | trie/trie.go | 0.665084 | 0.427576 | trie.go | starcoder |
package vmath
import (
"math"
"math/rand"
"strconv"
)
// Vector 3 is represented by a x,y,z values.
type Vector3 struct {
X float64
Y float64
Z float64
}
// Create new vector3 with values.
func NewVector3(x float64, y float64, z float64) *Vector3 {
var v = new(Vector3)
v.X = x
v.Y = y
v.Z = z
return v
}
... | vmath/vector3.go | 0.875335 | 0.684584 | vector3.go | starcoder |
package packed
// Efficient sequential read/write of packed integers.
type BulkOperationPacked18 struct {
*BulkOperationPacked
}
func newBulkOperationPacked18() BulkOperation {
return &BulkOperationPacked18{newBulkOperationPacked(18)}
}
func (op *BulkOperationPacked18) decodeLongToInt(blocks []int64, values []int... | core/util/packed/bulkOperation18.go | 0.598195 | 0.671793 | bulkOperation18.go | starcoder |
package vector
import (
"fmt"
"math"
)
type Vector struct {
X float32
Y float32
Z float32
}
func (v *Vector) String() string {
str := fmt.Sprintf("(%g,%g,%g)", v.X, v.Y, v.Z)
return str
}
func VGet(x float32, y float32, z float32) Vector {
var v Vector
v.X = x
v.Y = y
v.Z = z
return v
}
func VAdd(lhs... | vector/vector.go | 0.847179 | 0.461441 | vector.go | starcoder |
package statistics
import (
"encoding/binary"
"math"
"time"
"github.com/cznic/mathutil"
"github.com/whtcorpsinc/BerolinaSQL/allegrosql"
"github.com/whtcorpsinc/milevadb/stochastikctx/stmtctx"
"github.com/whtcorpsinc/milevadb/types"
)
// calcFraction is used to calculate the fraction of the interval [lower, u... | causetstore/milevadb-server/statistics/scalar.go | 0.760917 | 0.47524 | scalar.go | starcoder |
package curves
import (
"github.com/wieku/danser-go/app/bmath"
"github.com/wieku/danser-go/framework/math/vector"
"sort"
)
const minPartWidth = 0.0001
type MultiCurve struct {
sections []float32
lines []Linear
length float32
firstPoint vector.Vector2f
}
func NewMultiCurve(typ string, points []vect... | framework/math/curves/multicurve.go | 0.636692 | 0.451266 | multicurve.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// PrintJobConfiguration
type PrintJobConfiguration struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can b... | models/microsoft/graph/print_job_configuration.go | 0.718989 | 0.422207 | print_job_configuration.go | starcoder |
package zltest
import "time"
// Entries represents zerolog log entries.
type Entries struct {
e []*Entry
t T // Test manager.
}
// Get returns the list of Entry in Entries
func (ets Entries) Get() []*Entry {
return ets.e
}
// ExpStr tests that at least one log entry has key, its value is a
// string and it's equ... | entries.go | 0.617513 | 0.654936 | entries.go | starcoder |
package service
import (
"github.com/Jeffail/benthos/v3/lib/metrics"
)
// Metrics allows plugin authors to emit custom metrics from components that are
// exported the same way as native Benthos metrics.
type Metrics struct {
t metrics.Type
}
func newReverseAirGapMetrics(t metrics.Type) *Metrics {
return &Metrics... | public/x/service/metrics.go | 0.851614 | 0.407805 | metrics.go | starcoder |
package primitives
import (
"bytes"
"fmt"
)
type ProtocolVersion uint32
func (x ProtocolVersion) String() string {
return fmt.Sprintf("%x", uint32(x))
}
func (x ProtocolVersion) Equal(y ProtocolVersion) bool {
return x == y
}
func (x ProtocolVersion) KeyForMap() uint32 {
return uint32(x)
}
type VirtualChainI... | types/go/primitives/protocol.mb.go | 0.743075 | 0.541045 | protocol.mb.go | starcoder |
package raytrc
import (
"image"
"image/color"
"image/png"
"math"
"os"
)
// Vector - struct holding X Y Z values of a 3D vector
type Vector struct {
X, Y, Z float64
}
// Add - adds two vectors together
func (a Vector) Add(b Vector) Vector {
return Vector{
X: a.X + b.X,
Y: a.Y + b.Y,
Z: a.Z + b.Z,
}
}
/... | raytrc/rayt.go | 0.89597 | 0.774626 | rayt.go | starcoder |
package graphics
import (
"fmt"
mgl "github.com/go-gl/mathgl/mgl32"
"github.com/inkyblackness/shocked-client/opengl"
)
var bitmapTextureVertexShaderSource = `
#version 150
precision mediump float;
in vec2 vertexPosition;
in vec2 uvPosition;
uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projec... | src/github.com/inkyblackness/shocked-client/graphics/BitmapTextureRenderer.go | 0.828627 | 0.524151 | BitmapTextureRenderer.go | starcoder |
package main
import (
"fmt"
"sort"
)
// infinite ...
const infinite = int(^uint(0) >> 1)
// DijkstraTable ...
type DijkstraTable struct {
Vertex *Vertex
Weight int
}
// NewTable ...
func (g *Graph) NewTable() map[*Vertex]int {
return make(map[*Vertex]int, 0)
}
// InitializeTable ...
func (g *Graph) Initializ... | go/graph/dijsktra.go | 0.750004 | 0.473231 | dijsktra.go | starcoder |
// +build gofuzz
package bn256
import (
"bytes"
"math/big"
cloudflare "github.com/matrix/go-matrix/crypto/bn256/cloudflare"
google "github.com/matrix/go-matrix/crypto/bn256/google"
)
// FuzzAdd fuzzez bn256 addition between the Google and Cloudflare libraries.
func FuzzAdd(data []byte) int {
// Ensure we have... | crypto/bn256/bn256_fuzz.go | 0.614394 | 0.408867 | bn256_fuzz.go | starcoder |
package govcd
/*
* Copyright 2020 VMware, Inc. All rights reserved. Licensed under the Apache v2 License.
*/
import (
"fmt"
"regexp"
"github.com/kr/pretty"
)
// A conditionDef is the data being carried by the filter engine when performing comparisons
type conditionDef struct {
conditionType string // i... | govcd/filter_condition.go | 0.751648 | 0.4575 | filter_condition.go | starcoder |
package header
import (
"encoding/binary"
"github.com/brewlin/net-protocol/tcpip"
)
// ICMPv6 represents an ICMPv6 header stored in a byte array.
type ICMPv6 []byte
const (
// ICMPv6MinimumSize is the minimum size of a valid ICMP packet.
ICMPv6MinimumSize = 4
// ICMPv6ProtocolNumber is the ICMP transport pro... | tcpip/header/icmpv6.go | 0.700588 | 0.461684 | icmpv6.go | starcoder |
package matchers
import (
"fmt"
"reflect"
"regexp"
"strings"
logger "github.com/ViaQ/logerr/log"
"github.com/onsi/gomega/types"
"github.com/openshift/cluster-logging-operator/test"
testtypes "github.com/openshift/cluster-logging-operator/test/helpers/types"
)
type LogMatcher struct {
expected interface{}
f... | test/matchers/log_format.go | 0.524638 | 0.409693 | log_format.go | starcoder |
package game
import (
"time"
"github.com/oakmound/lowrez17/game/forceSpace"
"github.com/oakmound/lowrez17/game/layers"
"github.com/oakmound/oak/collision"
"github.com/oakmound/oak/physics"
"github.com/oakmound/oak/render"
)
func NetLeft(label collision.Label) func(*Entity) {
return func(p *Entity) {
PlayAt... | game/net.go | 0.610686 | 0.431944 | net.go | starcoder |
package main
import (
"math"
. "github.com/jakecoffman/cp"
"github.com/jakecoffman/cp/examples"
)
func main() {
space := NewSpace()
space.Iterations = 10
space.SetGravity(Vector{0, -100})
space.SleepTimeThreshold = 0.5
walls := []Vector{
{-320, 240}, {320, 240},
{-320, 120}, {320, 120},
{-320, 0}, {32... | examples/joints/joints.go | 0.654895 | 0.59131 | joints.go | starcoder |
package types
import (
"regexp"
"strings"
"unicode"
"github.com/tableauio/tableau/internal/atom"
"github.com/tableauio/tableau/proto/tableaupb"
"google.golang.org/protobuf/encoding/prototext"
)
var mapRegexp *regexp.Regexp
var listRegexp *regexp.Regexp
var keyedListRegexp *regexp.Regexp
var structRegexp *regex... | internal/types/types.go | 0.606732 | 0.418994 | types.go | starcoder |
package v1alpha1 // import "istio.io/api/rbac/v1alpha1"
/*
Istio RBAC (Role Based Access Control) defines ServiceRole and ServiceRoleBinding
objects.
A ServiceRole specification includes a list of rules (permissions). Each rule has
the following standard fields:
* services: a list of services.
* methods: HTTP method... | vendor/istio.io/api/rbac/v1alpha1/rbac.pb.go | 0.62601 | 0.674037 | rbac.pb.go | starcoder |
package ioc
// ComponentState represents what state (stopped, running) or transition between states (stopping, starting) a component is currently in.
type ComponentState int
const (
//StoppedState indicates that a component has stopped
StoppedState = iota
//StoppingState indicates that a component is in the proces... | ioc/component.go | 0.737158 | 0.448728 | component.go | starcoder |
package nune
import (
"fmt"
"math"
"reflect"
"strings"
)
// String returns a string representation of the Tensor.
func (t Tensor[T]) String() string {
if t.Err != nil {
if EnvConfig.Interactive {
panic(t.Err)
} else {
return "Tensor(error)"
}
}
template := "Tensor({})"
f := newFmtState(template,... | string.go | 0.731346 | 0.497742 | string.go | starcoder |
package twistededwards
import (
"math/bits"
"github.com/consensys/gurvy/bn256/fr"
)
// Point point on a twisted Edwards curve
type Point struct {
X, Y fr.Element
}
// PointProj point in projective coordinates
type PointProj struct {
X, Y, Z fr.Element
}
// Set sets p to p1 and return it
func (p *PointProj) Set... | bn256/twistededwards/point.go | 0.677687 | 0.412589 | point.go | starcoder |
package calc
import (
"bytes"
"errors"
"math/big"
)
// associativity of an operator.
type associativity int
// associativity values.
const (
leftassociative associativity = iota
rightassociative
)
// operator is a binary operator.
type operator struct {
precedence int
associativity associativity
apply ... | internal/calc/calc.go | 0.763131 | 0.5144 | calc.go | starcoder |
package climate
import (
"context"
"github.com/ironarachne/world/pkg/geography/region"
"github.com/ironarachne/world/pkg/geometry"
)
// Climate is a geographic climate
type Climate struct {
CloudCover int `json:"cloud_cover"` // 0-99
WindStrength int `json:"wind_strength"... | pkg/geography/climate/climate.go | 0.880142 | 0.400661 | climate.go | starcoder |
package matcher
import (
"errors"
"fmt"
"reflect"
"runtime/debug"
"github.com/onsi/gomega/format"
errorsutil "github.com/onsi/gomega/gstruct/errors"
"github.com/onsi/gomega/types"
)
// Simplify element matcher
// See https://github.com/onsi/gomega/blob/master/gstruct/elements.go
// MatchSlice succeeds if eve... | matcher/slice.go | 0.69451 | 0.401453 | slice.go | starcoder |
package vibe
import (
"github.com/spf13/cast"
"time"
)
//GetString returns the value associated with the key as a string.
func GetString(key string) string { return v.GetString(key) }
func (v *Vibe) GetString(key string) string {
return cast.ToString(v.Get(key))
}
//GetBool returns the value associated with the ... | get.go | 0.84858 | 0.417153 | get.go | starcoder |
package render
import (
"image"
"image/draw"
"github.com/oakmound/oak/v3/alg/floatgeom"
"github.com/oakmound/oak/v3/render/mod"
)
// CompositeM Types display all of their parts at the same time,
// and respect the positions of their parts as relative to the
// position of the composite itself
type CompositeM str... | render/compositeM.go | 0.737914 | 0.476823 | compositeM.go | starcoder |
package espressopp
import (
"io"
"github.com/alecthomas/participle"
"github.com/alecthomas/participle/lexer"
"github.com/alecthomas/participle/lexer/ebnf"
"github.com/alecthomas/repr"
)
type Term struct {
Identifier *string ` @Ident`
Integer *int `| @Int`
Decimal *float64 `| @Float`
String *... | parser.go | 0.671794 | 0.406509 | parser.go | starcoder |
// Package kmeans implements Lloyd's k-means clustering for ℝⁿ data.
package kmeans
import (
"code.google.com/p/biogo.cluster/cluster"
"errors"
"math/rand"
)
type point []float64
func (p point) V() []float64 { return p }
type value struct {
point
w float64
clu... | ML/kmeans.go | 0.87289 | 0.638525 | kmeans.go | starcoder |
package compute
import (
"bytes"
"compress/gzip"
"io/ioutil"
"github.com/golang/protobuf/proto" //nolint need to update to new protobuf api
protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/pkg/errors"
log "github.com/unchartedsoftware/plog"
"github.com/uncharted-distil/distil-compu... | primitive/compute/ta3ta2.go | 0.599954 | 0.552359 | ta3ta2.go | starcoder |
package optimize
import (
"math"
"sort"
"github.com/ivan-pindrop/hclust/matrixop"
"github.com/ivan-pindrop/hclust/typedef"
)
type constraints struct {
left int
right int
}
type leafs struct {
a []int
b []int
}
// Optimal implements the "fast" leaf optimization approach of Bar-Joseph et al.
// 2001. See Fi... | optimize/optimize.go | 0.824391 | 0.455622 | optimize.go | starcoder |
package ssz
import (
"encoding/binary"
"errors"
)
// Proof represents a merkle proof against a general index.
type Proof struct {
Index int
Leaf []byte
Hashes [][]byte
}
// Multiproof represents a merkle proof of several leaves.
type Multiproof struct {
Indices []int
Leaves [][]byte
Hashes [][]byte
}
/... | tree.go | 0.749546 | 0.497742 | tree.go | starcoder |
package configuration
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
const sliceSeparator = ";"
// SetField sets field with `valStr` value (converts to the proper type beforehand)
func SetField(field reflect.StructField, v reflect.Value, valStr string) error {
if v.Kind() == reflect.Ptr {
return setPt... | fieldSetter.go | 0.655336 | 0.407157 | fieldSetter.go | starcoder |
package life
import (
"image"
"image/color"
"time"
"fyne.io/fyne"
"fyne.io/fyne/canvas"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"
"github.com/fyne-io/examples/img/icon"
)
type board struct {
cells [][]bool
width int
height int
}
func (b *board) ifAlive(x, y int) int {
if x < 0 || x >= b.width {
ret... | life/main.go | 0.545528 | 0.437884 | main.go | starcoder |
package ahtree
import "crypto/sha256"
func VerifyInclusion(iproof [][sha256.Size]byte, i, j uint64, iLeaf, jRoot [sha256.Size]byte) bool {
if i > j || i == 0 || (i < j && len(iproof) == 0) {
return false
}
ciRoot := EvalInclusion(iproof, i, j, iLeaf)
return jRoot == ciRoot
}
func EvalInclusion(iproof [][sha2... | embedded/ahtree/verification.go | 0.566978 | 0.589835 | verification.go | starcoder |
package main
import (
"flag"
"fmt"
"math"
)
// https://projecteuler.net/problem=7
// We can offset unncessary computation by setting the prime check startpoint
// using the prime count function
// https://mathworld.wolfram.com/PrimeNumberTheorem.html
// For simplicity, the table listed in the @findPr... | Problem_7_Euler/main.go | 0.790207 | 0.445047 | main.go | starcoder |
package geometry
import (
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/graphic"
"github.com/g3n/engine/light"
"github.com/g3n/engine/material"
"github.com/g3n/engine/math32"
"github.com/g3n/g3nd/app"
"github.com/g3n/g3nd/demos"
"math"
)
type Torus struct {
torus1 *graphic.Mesh
normals *graphic.... | geometry/torus.go | 0.695855 | 0.41478 | torus.go | starcoder |
// Package livelog provides a buffer that can be simultaneously written to by
// one writer and read from by many readers.
package livelog
import (
"io"
"sync"
)
const MaxBufferSize = 2 << 20 // 2MB of output is way more than we expect.
// Buffer is a WriteCloser that provides multiple Readers that each yield the... | livelog/livelog.go | 0.643217 | 0.466603 | livelog.go | starcoder |
// Package coordsparser is a library for parsing (geographic) coordinates in various string formats
package coordsparser
import (
"fmt"
"regexp"
"strconv"
)
// Parse parses a coordinate string and returns a lat/lng pair or an error
func Parse(s string) (float64, float64, error) {
lat, lng, err := ParseD(s)
if e... | vendor/github.com/flopp/go-coordsparser/coordsparser.go | 0.823648 | 0.519034 | coordsparser.go | starcoder |
package test_version1
import (
"testing"
"github.com/pip-services-users/pip-clients-roles-go/version1"
"github.com/pip-services3-go/pip-services3-commons-go/data"
"github.com/stretchr/testify/assert"
)
type RolesClientFixtureV1 struct {
Client version1.IRolesClientV1
}
var ROLES = []string{"Role 1", "Role 2", ... | test/version1/RolesClientFixtureV1.go | 0.668772 | 0.476092 | RolesClientFixtureV1.go | starcoder |
// Package spreadsheet provides simple a interface to read spreadsheet files
// including XLSX and CSV.
package spreadsheet
import (
"fmt"
"path/filepath"
"strconv"
"strings"
"github.com/pkg/errors"
)
// Open opens a spreadsheet file.
// filePath is the path to the spreadsheet file to be opened. Supported file... | spreadsheet.go | 0.786418 | 0.478102 | spreadsheet.go | starcoder |
package cloudsmith_api
type EntitlementsPartialUpdate struct {
// If enabled, the token will allow downloads based on configured restrictions (if any).
IsActive bool `json:"is_active,omitempty"`
// The maximum download bandwidth allowed for the token. Values are expressed as the selected unit of bandwidth. Please... | bindings/go/src/entitlements_partial_update.go | 0.787319 | 0.400251 | entitlements_partial_update.go | starcoder |
package main
//https://projecteuler.net/problem=9
import (
"fmt"
"math"
"flag"
)
func BinetFormula(n float64) float64 {
sqrt5 := math.Sqrt(5)
phi := (1 + sqrt5) / 2
ans := math.Round(math.Pow(phi, n) / sqrt5)
fmt.Printf("Value at n: %f in fibonnaci sequence is: %f\n", n, ans)
return ans
}
func get... | Problem_9_Euler/main.go | 0.711631 | 0.471771 | main.go | starcoder |
package main
import (
"bytes"
"crypto/sha256"
"encoding/binary"
"fmt"
"math"
"math/big"
"time"
)
const Difficulty = 16 // Static difficulty for PoW calculation
var Empty [sha256.Size]byte // All zero sha256 value
// encodeUint64 encodes a uint64 to big endian notation. This code uses big
// endian in order t... | 1_1_pow/blockchain.go | 0.756807 | 0.512876 | blockchain.go | starcoder |
package iso20022
// Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another.
type SettlementParties36 struct {
// First party in the set... | SettlementParties36.go | 0.680666 | 0.490602 | SettlementParties36.go | starcoder |
package funk
import (
"reflect"
)
// Intersect returns the intersection between two collections.
func Intersect(x interface{}, y interface{}) interface{} {
if !IsCollection(x) {
panic("First parameter must be a collection")
}
if !IsCollection(y) {
panic("Second parameter must be a collection")
}
hash := ma... | vendor/github.com/thoas/go-funk/intersection.go | 0.801548 | 0.491578 | intersection.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SignInActivity
type SignInActivity struct {
// Stores additional data not desc... | models/sign_in_activity.go | 0.793626 | 0.418459 | sign_in_activity.go | starcoder |
package year2018day06
import (
"strings"
"github.com/alokmenghrajani/adventofcode2021/utils"
"github.com/alokmenghrajani/adventofcode2021/utils/grids"
)
func Part1(input string) int {
grid := grids.NewGrid(-1)
nodesX := []int{}
nodesY := []int{}
lines := strings.Split(input, "\n")
for n, line := range lines... | 2018/year2018day06/day06.go | 0.554229 | 0.473049 | day06.go | starcoder |
package golden
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"path/filepath"
"testing"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
)
// G is the object that assertions are made on.
type G struct {
t testing.TB
fs afero.Fs
ShouldUpdate bool
FixtureDir string
FixturePrefix str... | golden.go | 0.644113 | 0.425187 | golden.go | starcoder |
package parser
import (
"bytes"
"path"
"path/filepath"
)
// isInclude parses {{...}}[...], that contains a path between the {{, the [...] syntax contains
// an address to select which lines to include. It is treated as an opaque string and just given
// to readInclude.
func (p *Parser) isInclude(data []byte) (file... | vendor/github.com/gomarkdown/markdown/parser/include.go | 0.552298 | 0.583203 | include.go | starcoder |
package g3d
import (
"errors"
"math"
"github.com/angelsolaorbaiceta/inkgeom/nums"
)
var (
IVersor, _ = MakeVersor(1, 0, 0)
JVersor, _ = MakeVersor(0, 1, 0)
KVersor, _ = MakeVersor(0, 0, 1)
Zero = MakeVector(0, 0, 0)
)
var (
// ErrZeroVersor happens when a versor is created either from all zero project... | g3d/vector.go | 0.862163 | 0.739352 | vector.go | starcoder |
package main
type MinHeap struct {
array []*Node
nodePositionsInHeap map[string]int
}
func newMinHeap(array []*Node) *MinHeap {
nodePositionsInHeap := map[string]int{}
for i, node := range array {
nodePositionsInHeap[node.id] = i
}
heap := &MinHeap{array: array, nodePositionsInHeap: nodePosition... | src/famous-algorithms/a-star/go/heap.go | 0.652684 | 0.528168 | heap.go | starcoder |
package compchain
import (
"github.com/abc-inc/goava/primitives/bools"
"github.com/abc-inc/goava/primitives/floats"
"github.com/abc-inc/goava/primitives/ints"
"github.com/abc-inc/goava/primitives/uints"
"strings"
)
type active struct{}
func (c active) CompareFunc(left, right interface{}, cmp func(l, r interface... | collect/compchain/active.go | 0.701304 | 0.433382 | active.go | starcoder |
package evaluation
import (
"fmt"
"regexp"
"strings"
)
// String type for clause attribute evaluation
type String string
// NewString creates a string with the object value
func NewString(value interface{}) (String, error) {
str, ok := value.(string)
if ok {
newStr := String(str)
return newStr, nil
}
retu... | string.go | 0.72487 | 0.48182 | string.go | starcoder |
package udf
type ExtentInterface interface {
GetLocation() uint64
GetLength() uint32
SetLength(uint32)
GetPartition() uint16
IsNotRecorded() bool
HasExtended() bool
}
type Extent struct {
Length uint32
Location uint32
}
func (e Extent) GetPartition() uint16 {
return 0
}
func (e Extent) GetLocation() uint... | extent.go | 0.584627 | 0.436922 | extent.go | starcoder |
package curves
import (
math2 "github.com/wieku/danser-go/bmath"
"math"
)
type Bezier struct {
points []math2.Vector2d
ApproxLength float64
lengthCalculated bool
lastPos math2.Vector2d
lastC float64
lastWidth float64
lastT float64
}
func NewBezier(points []math2.Vector2d) *Bezier {
bz := &Bez... | bmath/curves/bezier.go | 0.747524 | 0.645916 | bezier.go | starcoder |
package physics
import (
"fmt"
"math"
"math/big"
"strings"
"time"
"git.sr.ht/~kisom/proxima/rat"
)
var (
lyInMeters = rat.Float(9.46073047258e+15)
oneAU = rat.Int64(149597870691)
hundredthLY = LightyearsToMeters(0.01)
hundredthAU = AstronomicalUnit(0.01)
tenthAU = AstronomicalUnit(0.1)
)
// Li... | physics/conv.go | 0.826397 | 0.550245 | conv.go | starcoder |
package proj
import (
"github.com/everystreet/go-proj/v6/cproj"
"github.com/golang/geo/r2"
"github.com/golang/geo/r3"
"github.com/golang/geo/s1"
"github.com/golang/geo/s2"
)
// XY is a 2D cartesian coordinate.
type XY r2.Point
// PutCoordinate updates coord with the values in c.
func (c XY) PutCoordinate(coord ... | proj/coord.go | 0.790611 | 0.618521 | coord.go | starcoder |
package core
import (
"math"
"github.com/Laughs-In-Flowers/warhola/lib/canvas"
)
type ResampleFilter = canvas.ResampleFilter
func stringToFilter(s string) ResampleFilter {
switch s {
case "box":
return Box
case "linear":
return Linear
case "gaussian":
return Gaussian
case "mitchellnetravali":
return ... | lib/core/resample_filter.go | 0.567098 | 0.484197 | resample_filter.go | starcoder |
package waf
/*
This file contains operations and types specific to WAF Custom Rule Sets.
*/
import (
"fmt"
)
// CustomRuleSetDetail is a detailed representation of a custom rule set.
// A custom rule set defines custom threat assessment criteria.
type CustomRuleSetDetail struct {
// Contains custom rules.
// E... | edgecast/waf/custom_rule.go | 0.654122 | 0.465995 | custom_rule.go | starcoder |
package i6502
const (
aciaData = iota
aciaStatus
aciaCommand
aciaControl
)
/*
ACIA 6551 Serial IO
This Asynchronous Communications Interface Adapater can be
directly attached to the 6502's address and data busses.
It provides serial IO.
The supplied Rx and Tx channels can be used to read and wirte
data to the ... | acia6551.go | 0.503662 | 0.403861 | acia6551.go | starcoder |
package measure
import (
"io"
"time"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query"
"github.com/ipfs/go-metrics-interface"
)
var (
// sort latencies in buckets with following upper bounds in seconds
datastoreLatencyBuckets = []float64{1e-4, 1e-3, 1e-2, 1e-1, 1}
// sort sizes in buckets ... | tmp1/go-ds-measure@v0.1.0/measure.go | 0.622459 | 0.485417 | measure.go | starcoder |
package plaid
import (
"encoding/json"
"time"
)
// LinkTokenCreateRequestUser An object specifying information about the end user who will be linking their account.
type LinkTokenCreateRequestUser struct {
// A unique ID representing the end user. Typically this will be a user ID number from your application. Per... | plaid/model_link_token_create_request_user.go | 0.746601 | 0.41253 | model_link_token_create_request_user.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.