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 draw
// braille_line.go contains code that draws lines on a braille canvas.
import (
"fmt"
"image"
"github.com/joegruffins/termdash/cell"
"github.com/joegruffins/termdash/internal/canvas/braille"
"github.com/joegruffins/termdash/internal/numbers"
)
// braillePixelChange represents an action on a pixel... | internal/draw/braille_line.go | 0.784938 | 0.429728 | braille_line.go | starcoder |
package adam
import (
"github.com/nlpodyssey/spago/gd"
"github.com/nlpodyssey/spago/mat"
"github.com/nlpodyssey/spago/nn"
)
var _ gd.MethodConfig = &Config[float32]{}
// Config provides configuration settings for an Adam optimizer.
type Config[T mat.DType] struct {
gd.MethodConfig
StepSize T
Beta1 T
Beta2... | gd/adam/adam.go | 0.804713 | 0.616676 | adam.go | starcoder |
package geometry
import (
"gotracer/material"
"gotracer/vmath"
)
// Triangle is hittable object represented by three points.
type Triangle struct {
A *vmath.Vector3
B *vmath.Vector3
C *vmath.Vector3
// Normal direction of the triangle plane
Normal *vmath.Vector3
// Material used to render the sphere.
Mater... | geometry/triangle.go | 0.847747 | 0.512022 | triangle.go | starcoder |
package resolv
import (
"math"
"github.com/kvartborg/vector"
)
// Space represents a collision space. Internally, each Space contains a 2D array of Cells, with each Cell being the same size. Cells contain information on which
// Objects occupy those spaces.
type Space struct {
Cells [][]*Cell
Cel... | space.go | 0.838746 | 0.766381 | space.go | starcoder |
package vector
import (
"logarithmotechnia/util"
"time"
)
// Vector is an interface for a different vector types. This structure is similar to R-vectors: it starts from 1,
// allows for an extensive indexing, supports IsNA-values and named variables
type Vector interface {
Type() string
Len() int
Payload() Paylo... | vector/vector.go | 0.719088 | 0.436562 | vector.go | starcoder |
package numopt
import (
"math"
"github.com/rpalmaotero/linalg"
)
const (
CONVERGENCE_EPSILON = 0.00001
GRADIENT_EPSILON = 0.00001
)
type Solution struct {
currentPoint linalg.VectorStructure
optimal bool
}
func GradientDescent(f func(linalg.VectorStructure) float64, x0 linalg.VectorStructure, lambda ... | main.go | 0.501953 | 0.552178 | main.go | starcoder |
package lwwes
import (
"fmt"
)
// Node with id, same id means same node
type Node struct {
ID string
}
var nodeEqual = func(d1 interface{}, d2 interface{}) bool {
return d1.(*Node).ID == d2.(*Node).ID
}
func (node *Node) String() string {
return fmt.Sprintf("node: %s", node.ID)
}
// Edge between two nodes, dir... | lwwes/graph.go | 0.68342 | 0.581392 | graph.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SideLoadingKey
type SideLoadingKey struct {
Entity
// Side Loading Key description displayed to the ITPro Admins..
description *string
// Side ... | models/side_loading_key.go | 0.651798 | 0.407333 | side_loading_key.go | starcoder |
package discovery
import (
"strings"
"github.com/pole-group/pole/utils"
)
// {operator : AND, expressions : [
// {key : label.{key}, operator : = or > or <, value : if start with label.{key} mean consumer and provider about this value must be equals},
// {key : label.{key}, operator : = or > or <, value : if st... | server/discovery/label_selector.go | 0.630116 | 0.528655 | label_selector.go | starcoder |
package main
import "math"
/**
给你一个 m x n 的矩阵 matrix 和一个整数 k ,找出并返回矩阵内部矩形区域的不超过 k 的最大数值和。
题目数据保证总会存在一个数值和不超过 k 的矩形区域。
示例 1:
输入:matrix = [[1,0,1],[0,-2,3]], k = 2
输出:2
解释:蓝色边框圈出来的矩形区域[[0, 1], [-2, 3]]的数值和是 2,且 2 是不超过 k 的最大数字(k = 2)。
示例 2:
输入:matrix = [[2,2,-1]], k = 3
输出:3
提示:
m == matrix.length
n == matrix[i].leng... | leetcode/maxSumSubmatrix/maxSumSubmatrix.go | 0.523908 | 0.449393 | maxSumSubmatrix.go | starcoder |
package wunderground
import "github.com/ebarkie/http/query"
// WxObs is weather observation info for the associated timestamp.
type WxObs struct {
Bar float64 `xml:"pressure_in"`
DewPoint float64 `xml:"dewpoint_f"`
RainAccumDay float64 `xml:"precip_today_in"`
RainAccumHour float64 `xml:"precip_1h... | wx.go | 0.792585 | 0.454048 | wx.go | starcoder |
package typecomp
import (
"reflect"
"time"
"github.com/ake-persson/typeconv"
)
// Comparer interface to extend structs.
type Comparer interface {
Eq(b interface{}) (bool, error)
Lt(b interface{}) (bool, error)
}
// Eq compare values and return true if they are the same.
func Eq(a, b interface{}) (bool, error) ... | compare.go | 0.702836 | 0.453988 | compare.go | starcoder |
package nats
import (
"context"
"crypto/tls"
"fmt"
"strings"
"sync"
"time"
"github.com/nats-io/nats.go"
"github.com/benthosdev/benthos/v4/internal/impl/nats/auth"
"github.com/benthosdev/benthos/v4/internal/old/input"
"github.com/benthosdev/benthos/v4/internal/shutdown"
"github.com/benthosdev/benthos/v4/pu... | internal/impl/nats/input_jetstream.go | 0.553264 | 0.417212 | input_jetstream.go | starcoder |
package opt
import (
"fmt"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
)
// Operator describes the type of operation that a memo expression performs.
// Some operators are relational (join, select, project) and others are scalar
// (and, or, plus, variable).
type Operator uint16
// MaxOperands is the max... | pkg/sql/opt/operator.go | 0.78083 | 0.483953 | operator.go | starcoder |
package common
import (
"bytes"
"fmt"
)
/*
KeyRange is an object representing a range of keys going from start_key to
end_key, whereas start_key is part of the range and end_key is not.
If end_key is empty, it is considered to be the end of the key range.
*/
type KeyRange struct {
StartKey, EndKey []byte
}
/*
New... | common/key_range.go | 0.637934 | 0.406567 | key_range.go | starcoder |
package actions
import (
"github.com/LindsayBradford/crem/internal/pkg/model/planningunit"
"math"
"github.com/LindsayBradford/crem/internal/pkg/dataset/tables"
"github.com/LindsayBradford/crem/internal/pkg/model/models/catchment/parameters"
assert "github.com/LindsayBradford/crem/pkg/assert/debug"
)
const (
p... | internal/pkg/model/models/catchment/actions/BankSedimentContribution.go | 0.760562 | 0.470189 | BankSedimentContribution.go | starcoder |
package imageutil
import (
"image"
"golang.org/x/image/draw"
)
type Images []image.Image
func (imgs Images) Dimensions() []image.Point {
points := []image.Point{}
for _, img := range imgs {
points = append(points, image.Point{
X: img.Bounds().Canon().Max.X,
Y: img.Bounds().Canon().Max.Y})
}
return poi... | image/imageutil/images.go | 0.703346 | 0.442877 | images.go | starcoder |
package tensor
import (
"fmt"
"log"
"math/rand"
)
// Tensor represents a multi-dimensional set of values.
type Tensor struct {
Frames int
Rows int
Cols int
values [][][]float32
}
// NewEmptyTensor1D creates a new tensor with a single frame, row and given number of columns.
func NewEmptyTensor1D(cols int) ... | tensor/tensor.go | 0.839109 | 0.72783 | tensor.go | starcoder |
package xtime
import (
"errors"
"fmt"
"regexp"
"strconv"
"time"
)
// ===
// set
// ===
// SetYear sets the year value to given time and returns a new time.Time.
func SetYear(t time.Time, year int) time.Time {
return time.Date(year, t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), t.Locatio... | xtime/xtime.go | 0.854354 | 0.590691 | xtime.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"
)
// ListNodePoolsMocked test mocked function
func ListNodePoolsMocked(t *testing.T, clusterID string, nodePoolsIn []*types.NodePool) []*ty... | api/kubernetes/node_pools_api_mocked.go | 0.66628 | 0.522994 | node_pools_api_mocked.go | starcoder |
package strings
import (
"fmt"
"io"
"strings"
"unicode"
)
// SplitPrefixNumber slices s into number prefix and unparsed and
// returns a slice of those substrings.
// If s does not start with number, SplitPrefixNumber returns
// a slice of length 1 whose only element is s.
// If s is with number only, SplitPrefi... | go/strings/trim.go | 0.75037 | 0.403773 | trim.go | starcoder |
package chronix
import (
"bytes"
"compress/gzip"
"fmt"
"io/ioutil"
"math"
"github.com/ChronixDB/chronix.go/chronix/pb"
"github.com/golang/protobuf/proto"
)
// decode decodes a serialized stream of points.
func decode(compressed []byte, tsStart, tsEnd, from, to int64) ([]Point, error) {
if from == -1 || to ==... | vendor/github.com/ChronixDB/chronix.go/chronix/codec.go | 0.767211 | 0.4881 | codec.go | starcoder |
// Functions to determine the size of an encoded protocol buffer.
package proto
import (
"log"
"reflect"
"strings"
)
// Size returns the encoded size of a protocol buffer.
// This function is expensive enough to be avoided unless proven worthwhile with instrumentation.
func Size(pb Message) int {
in := reflect.... | vendor/code.google.com/p/goprotobuf/proto/size.go | 0.670285 | 0.519826 | size.go | starcoder |
package japanesestats
import (
"github.com/TomRomeo/japanesestats/internal/util"
"unicode/utf8"
)
// Kyoiku returns count of kyōiku kanji inside text
func Kyoiku(text string) int {
return util.Wc(text, BelongsToKyoiku)
}
// KyoikuRatio returns percentage of kyoiku characters inside of text
// result is between 0 ... | kyoiku.go | 0.681621 | 0.417806 | kyoiku.go | starcoder |
package udwStrconv
import (
"fmt"
"strconv"
"strings"
"time"
)
const TB = 1024 * 1024 * 1024 * 1024
const GB = 1024 * 1024 * 1024
const MB = 1024 * 1024
const KB = 1024
func GbPaddingFromFloat64(byteNum float64) string {
return GbFromFloat64(byteNum)
}
func GbFromFloat64(byteNum float64) string {
if byteNum >... | udwStrconv/gb.go | 0.644449 | 0.484685 | gb.go | starcoder |
package maths
import (
"encoding/json"
"fmt"
"math"
)
// Vec3 is a 3 dimensional vector
type Vec3 struct {
X, Y, Z float64
}
// NewVec3 returns new 3 dimensional vector
func NewVec3(x, y, z float64) *Vec3 {
return &Vec3{X: x, Y: y, Z: z}
}
// MakeZero makes all the dimentsions of the vector zero
func (v *Vec3)... | maths/vector.go | 0.854733 | 0.671704 | vector.go | starcoder |
package claimhandler
import (
"github.com/insolar/insolar/insolar"
"github.com/insolar/insolar/insolar/utils"
"github.com/insolar/insolar/network/consensusv1/packets"
)
// NodesToJoinPercent how many nodes from active list can connect to the network.
const NodesToJoinPercent = 1.0 / 3.0
func maxJoinersForPulse(a... | network/consensusv1/claimhandler/claimhandler.go | 0.5564 | 0.435841 | claimhandler.go | starcoder |
package integration
// CloneAST creates a deep clone of the input.
func CloneAST(in AST) AST {
if in == nil {
return nil
}
switch in := in.(type) {
case BasicType:
return in
case Bytes:
return CloneBytes(in)
case InterfaceContainer:
return CloneInterfaceContainer(in)
case InterfaceSlice:
return Clone... | go/tools/asthelpergen/integration/ast_clone.go | 0.69181 | 0.496643 | ast_clone.go | starcoder |
package assertions
import (
"errors"
"fmt"
"reflect"
m "github.com/LuigiAndrea/test-helper/messages"
)
//AssertSlicesEqual checks if two slices have the same values and in the same order
func AssertSlicesEqual(slices CheckSlices) error {
if !slices.SameLength() {
return &LengthError{Err: "Slices with differen... | assertions/slices_assert.go | 0.758958 | 0.554712 | slices_assert.go | starcoder |
package dotc
import (
"io"
"text/template"
)
// UnionStream implements stream functionality for unions
type UnionStream Union
// StreamType provides the stream type of the struct
func (s UnionStream) StreamType() string {
return (Field{Type: s.Type}).ToStreamType()
}
// Pointer specifies if the struct type is i... | x/dotc/unions.go | 0.822724 | 0.402686 | unions.go | starcoder |
package image
import (
"image"
"image/color"
lib_color "github.com/mchapman87501/go_mars_2020_img_utils/lib/image/color"
)
type HSV struct {
// Pix, Stride, Rect
Pix []float64
Stride int
Rect image.Rectangle
}
func (p *HSV) ColorModel() color.Model { return lib_color.HSVModel }
func (p *HSV) Bounds() i... | lib/image/hsv.go | 0.746786 | 0.481515 | hsv.go | starcoder |
package geozip
import (
"fmt"
"strconv"
"strings"
"github.com/shopspring/decimal"
)
const maxPrecision int = 18
//Encode generates a geozip bucket id for a given latitude and longitude.
//Argument validate is true if a validation is to be performed.
//Precision is a number in the range of [0, 18] such that 0 gi... | geozip.go | 0.782288 | 0.485173 | geozip.go | starcoder |
// Package data provides data types for the TKR Resolver.
package data
import (
"fmt"
"k8s.io/apimachinery/pkg/labels"
runv1 "github.com/vmware-tanzu/tanzu-framework/apis/run/v1alpha3"
)
// Query sets constraints for resolution of TKRs. Its structure reflects Cluster API cluster topology.
type Query struct {
/... | pkg/v2/tkr/resolver/data/types.go | 0.748444 | 0.418935 | types.go | starcoder |
package goel
import (
"context"
"github.com/pkg/errors"
"go/ast"
"go/token"
"reflect"
)
var (
intr interface{}
// StringType is a reflect.Type for strings
StringType = reflect.TypeOf("")
// IntType is a reflect.Type for int
IntType = reflect.TypeOf(0)
// DoubleType is a reflect.Type for float64
DoubleType... | eval.go | 0.600305 | 0.492249 | eval.go | starcoder |
// Spectral Power Distribution of a CIE D-Illuminant
// The relative spectral power distribution of a CIE D-Illuminant is computed from its chromaticity coordinates.
// The chromaticity coordinates may be computed from the correlated color temperature.
// Ref.: [28]
package white
import "math"
func s(λ float64) (... | f64/white/spectral.go | 0.627267 | 0.528412 | spectral.go | starcoder |
package fp
func (l BoolList) NonEmpty() bool { return !l.IsEmpty() }
func (l StringList) NonEmpty() bool { return !l.IsEmpty() }
func (l IntList) NonEmpty() bool { return !l.IsEmpty() }
func (l Int64List) NonEmpty() bool { return !l.IsEmpty() }
func (l ByteList) NonEmpty() bool { return !l.IsEmpty() }
func (l RuneLi... | fp/bootstrap_list_nonempty.go | 0.616359 | 0.613729 | bootstrap_list_nonempty.go | starcoder |
package cp
import (
"math"
"unsafe"
)
const MAX_CONTACTS_PER_ARBITER = 2
const CONTACTS_BUFFER_SIZE = 1024
type Space struct {
Iterations uint // must be non-zero
gravity Vector
damping float64
idleSpeedThreshold float64
SleepTimeThreshold float64
collisionSlop float64
collisionBias float64... | space.go | 0.645679 | 0.492859 | space.go | starcoder |
package tag
import (
"sort"
"strings"
protoMetricsV1 "github.com/lindb/lindb/proto/gen/v1/metrics"
)
type KeyValues []*protoMetricsV1.KeyValue
func (kvs KeyValues) Len() int { return len(kvs) }
func (kvs KeyValues) Less(i, j int) bool { return kvs[i].Key < kvs[j].Key }
func (kvs KeyValues) Swap(i, j i... | series/tag/tag.go | 0.630912 | 0.409811 | tag.go | starcoder |
package simpleregtest
import (
"fmt"
"strconv"
"strings"
"github.com/decred/dcrd/dcrutil"
"github.com/decred/dcrd/integration"
"github.com/decred/dcrd/integration/harness"
)
// DeploySimpleChain defines harness setup sequence for this package:
// 1. obtains a new mining wallet address
// 2. restart harness no... | integration/harness/simpleregtest/simplechainbuilder.go | 0.537284 | 0.488039 | simplechainbuilder.go | starcoder |
package digraph
// Most nodes have few edges. For those nodes, a slice is a better
// storage than a map. The edgeSet interface allows usings both slices
// and maps as needed
type edgeSet interface {
addEdge(Edge)
hasEdges() bool
removeEdge(Edge)
getEdges() Edges
getEdgesWith(interface{}) Edges
length() int
ne... | edgeset.go | 0.742608 | 0.508605 | edgeset.go | starcoder |
package main
import (
"fmt"
"math"
"github.com/derat/advent-of-code/lib"
)
func main() {
// First, read in all the clay regions so we can determine the region we care about.
var clay []region
bnd := region{math.MaxInt32, -1, math.MaxInt32, -1}
for _, ln := range lib.InputLines("2018/17") {
var reg region
... | 2018/17/main.go | 0.584627 | 0.528229 | main.go | starcoder |
package navigation
type Response_t struct {
// Unique identifier of a direction request.
TransId string `json:"trans_id"`
// Route data. If alternatives is set to true, one or more routes are returned.
Routes []Route_t `json:"routes"`
}
type Route_t struct {
// Result code of dire... | domain/navigation/navigation.go | 0.860677 | 0.452657 | navigation.go | starcoder |
package binarytree
import (
"go-dsa/common"
"math"
"reflect"
)
type AVLTreeNode struct {
ele common.ComparableElement
left *AVLTreeNode
right *AVLTreeNode
parent *AVLTreeNode
height int
}
func (atn *AVLTreeNode) GetParent() Node {
return atn.parent
}
func (atn *AVLTreeNode) SetParent(node Node) {
if... | binarytree/AVL_tree.go | 0.620392 | 0.470433 | AVL_tree.go | starcoder |
package express
import (
"errors"
"strconv"
)
// NumericEval returns the result for an expression with provided variables
func NumericEval(expression string, variables map[string]float64) (float64, error) {
tokens, err := tokenize(expression)
if err != nil {
return 0, err
}
ast, err := createNumericAST(token... | numericevaluator.go | 0.794704 | 0.492066 | numericevaluator.go | starcoder |
package coo
type Geocentric struct {
*Geocentric
Tx, Ty, Tz, Ds, Rx, Ry, Rz float64
}
type Geographic struct {
*Geocentric
*Ellipsoid
}
type Ellipsoid struct {
A, Fi float64
}
var DefaultEllipsoid = WGS84
type Projected struct {
*Geographic
*System
}
type System struct {
toGeographic func(east, north fl... | coo.go | 0.77343 | 0.643035 | coo.go | starcoder |
package record
import (
"errors"
)
// ErrStreamClosed is used to indicate that a stream must be closed.
var ErrStreamClosed = errors.New("stream closed")
// An Iterator can iterate over records.
type Iterator interface {
// Iterate goes through all the records and calls the given function by passing each one of th... | record/stream.go | 0.773045 | 0.429489 | stream.go | starcoder |
package succinct_tree
import "math"
/**
Fixed values for the L1 and L2 table sizes in the Rank Directory
*/
var L1 uint = 32 * 32
var L2 uint = 32
/**
The rank directory allows you to build an index to quickly compute the
rank() and select() functions. The index can itself be encoded as a binary
string.
*/
t... | succinct_tree/rankdirectory.go | 0.666714 | 0.501587 | rankdirectory.go | starcoder |
package layer
import (
"github.com/rubenwo/cnn-go/pkg/cnn/maths"
"math"
)
type MaxPoolingLayer struct {
strides []int
sizes []int
outputTensor maths.Tensor
inputTensor maths.Tensor
maxIndices []int
}
func NewMaxPoolingLayer(strides, sizes, inputDims []int) *MaxPoolingLayer {
m := &MaxPoolingLayer{stride... | pkg/cnn/layer/maxpooling.go | 0.826046 | 0.551332 | maxpooling.go | starcoder |
package main
import (
"fmt"
"log"
)
var thermostatParameters = map[string]Parameter{
"LowAngle": IntParameter{
ID: "LowAngle",
Name: "Low Angle",
Description: "This is the smallest angle your thermostat can be at",
Min: 0,
Max: 180,
Default: 80,
},
"HighAngle": Int... | services/usecaseserver/thermostat.go | 0.691602 | 0.408218 | thermostat.go | starcoder |
package mux
// checkPairs returns the count of strings passed in, and an error if
import (
"fmt"
"net/http"
"regexp"
"strings"
)
// the count is not an even number.
func isEvenPairs(pairs ...string) (int, error) {
length := len(pairs)
if length%2 != 0 {
return length, fmt.Errorf("mux: number of parameters mus... | helper.go | 0.799638 | 0.449997 | helper.go | starcoder |
package ellipsoids
/*
This file contains the constant definitions for the WGS-84 ellipsoid
See https://es.wikipedia.org/wiki/WGS84, https://ahrs.readthedocs.io/en/latest/wgs84.html and
https://espace.curtin.edu.au/bitstream/handle/20.500.11937/41042/146669_24797_compend.pdf?isAllowed=y&sequence=2 ("A Compendium Of ... | ellipsoids/WGS-84.go | 0.856212 | 0.574813 | WGS-84.go | starcoder |
package gbytebuffer
import (
"bytes"
"encoding/binary"
)
// VERSION is the version of the package.
const VERSION = "0.2.0"
// ByteBuffer is used to read and write data to a byte array.
type ByteBuffer struct {
data []byte
index int
length int
}
// ByteBufferFrom creates a new ByteBuffer from a byte array.
f... | byteBuffer.go | 0.811303 | 0.445831 | byteBuffer.go | starcoder |
package utils
import (
"github.com/go-gl/mathgl/mgl32"
)
// L3D L-System
type L3D struct {
Seed string
Angle float64
Rules map[rune]string
}
//GenLString3D GenLString
func GenLString3D(l L3D, count uint) (oldSeed string) {
oldSeed = l.Seed
for i := uint(0); i < count; i++ {
newSeed := ""
for _, n := range... | internal/utils/Lsystem3D.go | 0.610337 | 0.550124 | Lsystem3D.go | starcoder |
package twodeeparticles
import (
"image/color"
"math"
"time"
)
// A Particle is a part of a particle system.
type Particle struct {
system *ParticleSystem
lifetime time.Duration
birthTime time.Time
deathTime time.Time
lastUpdateTime time.Time
isAlive bool
data interface{}
posi... | particle.go | 0.851243 | 0.527317 | particle.go | starcoder |
// By looking at the API (functions), we need to decouple the API from the concrete implementation. The decoupling
// that we do must get all the way down into initialization. To do this right, the only piece of
// code that we need to change is initialization. Everything else should be able to act on the
// behavior ... | go/design/decoupling_2.go | 0.540924 | 0.754983 | decoupling_2.go | starcoder |
package qson
type Stage interface {
Ensurer
stageProof()
}
type stage func(m M) M
func (s stage) Ensure(m M) M { return s(initializer().Ensure(m)) }
func (s stage) stageProof() {}
// AddFields adds new fields to documents. Similar to $project, $addFields
// reshapes each document in the stream; specifically, by ... | aggregation_pipeline_stages.go | 0.737442 | 0.428831 | aggregation_pipeline_stages.go | starcoder |
package ast
import (
"github.com/jensneuse/graphql-go-tools/internal/pkg/unsafebytes"
"github.com/jensneuse/graphql-go-tools/pkg/lexer/position"
)
// ScalarTypeDefinition
// example:
// scalar JSON
type ScalarTypeDefinition struct {
Description Description // optional, describes the scalar
ScalarLiteral ... | pkg/ast/ast_scalar_type_definition.go | 0.758153 | 0.401834 | ast_scalar_type_definition.go | starcoder |
// Author: <NAME> (<EMAIL>)
// Port of Raymond Hill's (<EMAIL>) JavaScript implementation
// of Steven Forune's algorithm to compute Voronoi diagrams
package voronoi
import (
"math"
)
// Vertex on 2D plane
type Vertex struct {
X float64
Y float64
}
// NoVertex is a Vertex representing lack of vertex (or bad ver... | geometry.go | 0.667256 | 0.487734 | geometry.go | starcoder |
package render
import (
"image"
"image/color"
"math"
"github.com/fogleman/gg"
)
var DefaultPlotColor = color.RGBA{0xff, 0xff, 0xff, 0xff}
// surface fill gets line color with this alpha
var FillAlpha uint8 = 0x55
type Plot struct {
Widget
// Coordinates of points to plot
X []float64
Y []float64
// Overa... | render/plot.go | 0.73914 | 0.406509 | plot.go | starcoder |
package io
import (
"bufio"
"bytes"
"io"
bytes_ "github.com/searKing/golang/go/bytes"
)
// Count counts the number of non-overlapping instances of sep in r.
// If sep is an empty slice, Count returns 1 + the number of UTF-8-encoded code points in s.
// tailMatch returns true if tail bytes match sep
func Count(r ... | go/io/counter.go | 0.736401 | 0.452778 | counter.go | starcoder |
package ast
import (
"fmt"
)
// Convert converts an AST with a given function.
// This function visits all expressions and statements at least.
func Convert(f func(interface{}) interface{}, x interface{}) interface{} {
if y := f(x); y != nil {
return y
}
convert := func(x interface{}) interface{} {
return Co... | src/lib/ast/util.go | 0.710327 | 0.618665 | util.go | starcoder |
// Package reflectvaluecompare defines an Analyzer that checks for accidentally
// using == or reflect.DeepEqual to compare reflect.Value values.
// See issues 43993 and 18871.
package reflectvaluecompare
import (
"go/ast"
"go/token"
"go/types"
"github.com/polaris1119/tools/go/analysis"
"github.com/polaris1119/... | go/analysis/passes/reflectvaluecompare/reflectvaluecompare.go | 0.722723 | 0.447521 | reflectvaluecompare.go | starcoder |
package nqtree
type TreeNode struct {
Rect Orthotope
Childs []TreeNode
DataPoints []DataPoint
MaxPoints int
Divided bool
}
func (t *TreeNode) Insert(dp *DataPoint) (bool, error) {
contains, err := t.Rect.Contains(&dp.Position)
if err != nil {
return false, err
}
if !contains {
return false,... | tree.go | 0.527317 | 0.55917 | tree.go | starcoder |
package dataloader
import (
"bufio"
"encoding/csv"
"io"
"os"
"strconv"
"github.com/patrikeh/go-deep/training"
)
//Load load the dataset at path and return a set of examples for go-deep
//library to digest data with neural network model
func Load(dataset string, path string) (training.Examples, error) {
f, er... | dataloader/dataloader.go | 0.608012 | 0.452838 | dataloader.go | starcoder |
package modular
import (
"math/big"
"crypto/rand"
"errors"
)
type Int big.Int
// Default prime (256-bit secp256k1 EC order)
var (
p, _ = IntFromString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
)
// SetP resets the (prime) modulus across the package
func SetP(new_prime *Int) *Int {
... | modular/operations.go | 0.712632 | 0.403655 | operations.go | starcoder |
package radius
import (
"github.com/dayaftereh/stargen/stargen/constants"
"github.com/dayaftereh/stargen/types"
)
func gasRadius1Gyr1960K10coreMass(planet *types.Planet) float64 {
totalEarthMasses := planet.Mass * constants.SunMassInEarthMasses
massRadii10 := RadiusImproved(10.0/constants.SunMassInEarthMasses, pl... | stargen/radius/gas-1-gyr-radius.go | 0.54359 | 0.457682 | gas-1-gyr-radius.go | starcoder |
package blueflood
import (
"math"
"github.com/square/metrics/api"
"github.com/square/metrics/timeseries"
)
type sampler struct {
fieldName string // Name of field in Blueflood JSON response
selectField func(point metricPoint) float64 // Function for extracting field from metricPoin... | timeseries/blueflood/sampler.go | 0.715722 | 0.481698 | sampler.go | starcoder |
package slider
import "strings"
// Sector contains all of the information for a single sector captured by a weather satellite.
type Sector struct {
// CropRatioX is the amount to crop the image on the X-axis from 0 to 1
CropRatioX float32
// CropRatioY is the amount to crop the image on the X-axis from 0 to 1
Cr... | slider/sector.go | 0.827445 | 0.472014 | sector.go | starcoder |
package entity
// ID describes the numeric ID of an entity.
type ID uint32
// Entity describes information about a type of entity.
type Entity struct {
ID ID
InternalID uint32
DisplayName string
Name string
Width float64
Height float64
Type string
}
var (
AreaEffectCloud ... | data/entity/entity.go | 0.710327 | 0.512266 | entity.go | starcoder |
package polynomial
import (
"math"
"github.com/ready-steady/adapt/grid/equidistant"
)
// Closed is a basis in [0, 1]^n.
type Closed struct {
nd uint
np uint
grid equidistant.Closed
}
// NewClosed creates a basis.
func NewClosed(dimensions uint, power uint) *Closed {
return &Closed{
nd: dimensions,
n... | basis/polynomial/closed.go | 0.858437 | 0.533458 | closed.go | starcoder |
package smoother
import (
"math"
)
type Method int
const (
Exponential Method = iota
DoubleExponential
FilterFIR
)
type Smoother struct {
state float64
initialState float64
previousState interface{}
coefficients interface{}
method Method
t int
}
/*
A Smoother must not be crea... | smoother.go | 0.687 | 0.437583 | smoother.go | starcoder |
package gltf
import "math"
// NormalizeByte normalize a float32 into a int8
func NormalizeByte(v float32) int8 {
return int8(math.Round(float64(v) * 127))
}
// NormalizeByte denormalize a int8 into a float32
func DenormalizeByte(v int8) float32 {
return float32(math.Max(float64(v)/127, -1))
}
// NormalizeUbyte no... | math.go | 0.87588 | 0.628151 | math.go | starcoder |
package ckks
import (
"github.com/ldsec/lattigo/ring"
"math"
"math/big"
)
// Encoder is a struct storing the necessary parameters to encode a slice of complex number on a plaintext.
type Encoder struct {
ckkscontext *CkksContext
values []complex128
valuesfloat []float64
bigint_coeffs []*big.Int
q_h... | HE/ckks/encoder.go | 0.714528 | 0.438545 | encoder.go | starcoder |
package squares
import "fmt"
const (
//SIZE is the size of the nxn board
SIZE = 5
)
//Position represents the position of a move
type Position struct {
y, x int
}
func (p Position) String() string {
return fmt.Sprintf("y=%d,x=%d", p.y, p.x)
}
//Add takes 2 positions and performs a vector addition
func (p Posit... | board.go | 0.813201 | 0.55941 | board.go | starcoder |
package main
import (
"encoding/csv"
"flag"
"fmt"
"io"
"log"
"math/rand"
"os"
"strings"
"github.com/jbrukh/bayesian"
)
// Example groups a string with a class.
type Example struct {
Value string
Class string
}
// Dataset for spam.
type Dataset struct {
Examples []Example
}
// ByClass returns examples o... | examples/spam/main.go | 0.720762 | 0.409516 | main.go | starcoder |
package eval
import (
"fmt"
"io"
"math"
"os"
"strings"
)
type T int
const (
tString T = iota
tFloat64
)
type Response struct {
Type T
value interface{}
}
func (r Response) String() string {
switch r.Type {
case tString:
return r.value.(string)
case tFloat64:
return fmt.Sprintf("%f", r.value.(float... | ex_07.15-Expr_cli_calculator/eval/eval.go | 0.659076 | 0.433981 | eval.go | starcoder |
package jsonpath
import (
"bytes"
"encoding/json"
"fmt"
"github.com/PaesslerAG/jsonpath"
"reflect"
"strings"
)
// https://github.com/steinfletcher/apitest-jsonpath/blob/master/jsonpath.go
// Contains is a convenience function to assert that a jsonpath expression extracts a value in an array
func Contains(bytes... | pkg/jsonpath/jsonpath.go | 0.745028 | 0.498474 | jsonpath.go | starcoder |
package path
import (
"fmt"
"strings"
)
// Comments from https://css-tricks.com/svg-path-syntax-illustrated-guide/
// Better docs here: https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands
func New() *Path {
return &Path{b: strings.Builder{}}
}
type Path struct {
b strings.Builder
}
func (p *Path) ... | pkg/path/path.go | 0.660829 | 0.755434 | path.go | starcoder |
package gs
import slice "github.com/gyuho/goraph/gosequence"
// Grapher is a set of methods for gs graph data structure
// that receives Graph as an input.
type Grapher interface {
// ToJSON converts a receiver graph data structure to JSON format.
ToJSON() string
// ToJSONFile converts a graph to a JSON file.
To... | graph/gs/graph_method_interface.go | 0.701713 | 0.536374 | graph_method_interface.go | starcoder |
package utils
import (
"encoding/json"
"errors"
"testing"
"github.com/stretchr/testify/require"
)
// RemoveKey Remove Values from the map based on the list of keys
func RemoveKey(input map[string]interface{}, keys []string) (map[string]interface{}, error) {
for _, key := range keys {
if _, ok := input[key];... | utils/utils.go | 0.708515 | 0.443179 | utils.go | starcoder |
package drawimg
import (
"errors"
"fmt"
"image"
"image/draw"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
"github.com/golang/freetype/raster"
"github.com/golang/freetype/truetype"
)
const (
nGlyphs = 256
nXFractions = 4
nYFractions = 1
)
type cacheEntry struct {
valid bool
glyp... | app/interface/main/creative/dao/drawimg/freetype.go | 0.692226 | 0.473779 | freetype.go | starcoder |
package day10
import (
"bufio"
"fmt"
"math"
"os"
"sort"
)
type point struct {
x, y int
}
func (p point) dist(other point) float64 {
return findDist(float64(p.x-other.x), float64(p.y-other.y))
}
func (p point) findAngle(other point) (angle float64) {
dx := p.x - other.x
dy := p.y - other.y
if dx == 0 {
i... | pkg/day10/asteroids.go | 0.687525 | 0.550245 | asteroids.go | starcoder |
package colfmt
import (
"fmt"
"github.com/nickwells/col.mod/v3/col"
)
// Int records the values needed for the formatting of an int value
type Int struct {
// W gives the minimum space to be taken by the formatted value
W int
// IgnoreNil, if set to true will make nil values print as the empty string
IgnoreNil... | col/colfmt/intFormatter.go | 0.626696 | 0.42322 | intFormatter.go | starcoder |
package geosconverter
import (
"github.com/paulsmith/gogeos/geos"
"github.com/xeonx/geographic"
"github.com/xeonx/raster"
)
//GetBoundingBox computes the bounding box for a given geometry
func GetBoundingBox(g *geos.Geometry) (geographic.BoundingBox, error) {
bbox := geographic.BoundingBox{}
envelope, err := g.... | geosconverter/geosconverter.go | 0.693888 | 0.471467 | geosconverter.go | starcoder |
// Package str contains helper functions for commonly useful string
// operations.
package str
// Stdlib imports.
import (
"bytes"
"strconv"
"strings"
)
// DelimToStrArray takes a data string, delimited by a specified separator,
// and splits the string by that separator, also trimming whitespace and
//... | lib/str/string.go | 0.675229 | 0.447823 | string.go | starcoder |
package suite
import (
"flag"
"fmt"
"os"
"reflect"
"regexp"
"runtime/debug"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var matchMethod = flag.String("testify.m", "", "regular expression to select tests of the testify suite to run")
// T is a basic testing... | suite/suite.go | 0.567577 | 0.623377 | suite.go | starcoder |
package rtc
// Object is an interface that represents an object in the scene.
type Object interface {
// LocalIntersect returns a slice of IntersectionT values where the
// transformed (object space) ray intersects the object.
LocalIntersect(ray RayT) []IntersectionT
// Parent returns the object's parent object.
... | rtc/object.go | 0.903761 | 0.618348 | object.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// SunburstWidgetLegendInlineAutomatic Configuration of inline or automatic legends.
type SunburstWidgetLegendInlineAutomatic struct {
// Whether to hide the percentages of the groups.
HidePercent *bool `json:"hide_percent,omitempty"`
// Whether to hide the value... | api/v1/datadog/model_sunburst_widget_legend_inline_automatic.go | 0.705886 | 0.420421 | model_sunburst_widget_legend_inline_automatic.go | starcoder |
package pcaparser
/*
Refs:
https://www.cnblogs.com/qishui/p/5437301.html
https://github.com/dominikh/go-pcap/blob/master/pcap.go
https://github.com/Lukasa/gopcap
File format:
|Pcap header| Packet header1 | packet Data1| Packet header2 | packet Data2|
Pcap header format: 24bytes
-----------------------
| ma... | doc.go | 0.765593 | 0.748053 | doc.go | starcoder |
package utils
import (
"strconv"
"strings"
)
// Abs returns the absolute value of x.
func Abs(x int) int {
if x < 0 {
return -x
}
return x
}
// Min returns the smaller of x or y.
func Min(x int, y int) int {
if x < y {
return x
}
return y
}
// Max returns the larger of x or y.
func Max(x int, y int) int... | utils/utils.go | 0.771069 | 0.432902 | utils.go | starcoder |
package binaryTree
import "math"
/**
1 终止条件
2 divide
3 conquer
*/
func levelOrder(root *TreeNode) [][]int {
if root == nil {
return nil
}
res := make([][]int, 0)
queue := make([]*TreeNode, 0)
queue = append(queue, root)
for len(queue) > 0 {
list := make([]int, 0)
l := len(queue)
for i := 0;... | v1/binaryTree/divide.go | 0.592549 | 0.409339 | divide.go | starcoder |
package xchacha20blake2b
import (
"bytes"
"crypto/cipher"
"errors"
"fmt"
"github.com/aead/chacha20"
"golang.org/x/crypto/blake2b"
)
// KeySize specifies the expected size of the key in bytes
const KeySize = 32
const chachaPolyNonceSize = 24
// xchacha20SIV
type xchacha20SIV struct {
encKey, macKey []byte
}
... | siv.go | 0.769514 | 0.511168 | siv.go | starcoder |
package lang
import (
"github.com/lohvht/went/lang/token"
)
var textFormat = "%s" // change to "%q" in tests for better error messages
// Interfaces
type (
// Node is the AST node interface
Node interface {
NScope() Scope // returns the scope of a Node
Pos() token.Pos // starting position i... | lang/node.go | 0.586049 | 0.401101 | node.go | starcoder |
package game
import (
"fmt"
"sort"
)
type node byte
type nodestring []int
type Board struct {
size int
board []node
}
const (
empty node = iota
white node = iota
black node = iota
edge node = iota
)
func NewBoard(size int) *Board {
board := make([]node, size*size)
return &Board{
size: size,
board:... | game/board.go | 0.623377 | 0.466359 | board.go | starcoder |
package game
import (
"Palette/player"
"log"
"math/rand"
"strings"
"sync"
"time"
"github.com/gorilla/websocket"
)
//Data describes all the data a game object holds
type Data struct {
live bool
duration, rounds, current int
host, word string
artistData *p... | v1/game/Game.go | 0.660939 | 0.408749 | Game.go | starcoder |
// Package golf provides API to read ELF files from first principles.
package golf
import (
"encoding/binary"
"fmt"
"os"
)
// ELF encapsulates the data of an ELF file. It is the enrty point to reading
// symbols, strings etc. from an ELF file.
type ELF struct {
header ELFHeader
progHdrTbl []SegH... | golf/golf.go | 0.724968 | 0.545165 | golf.go | starcoder |
package graph
import (
"errors"
"fmt"
)
// Graph represents the graph structure, which has the list of Nodes
// and the Edges(links) between the Nodes
type Graph struct {
Nodes []*Node
Edges map[*Node][]*Edge
}
// Node represents a Graph Node (vertex)
// where Value is a discretionary value associated to the nod... | graph/graph.go | 0.624523 | 0.636042 | graph.go | starcoder |
package bdd
import (
"fmt"
"github.com/onsi/gomega"
"github.com/onsi/gomega/format"
)
// HasLen succeeds if actual has the passed-in length. Actual must be of type
// string, array, map, chan, or slice.
var HasLen = &matcher{
minArgs: 1,
maxArgs: 1,
name: "HasLen",
apply: func(actual interface{}, expected ... | matcher_coll.go | 0.587352 | 0.413862 | matcher_coll.go | starcoder |
// Package merger performs recursive merge of maps or structures into new one.
// Non-zero values from the right side has higher precedence. Slices do not
// merging, because main use case of this package is merging configuration
// parameters, and in this case merging of slices is unacceptable. Slices from
// the rig... | merger.go | 0.829768 | 0.642783 | merger.go | starcoder |
package chron
import (
"time"
"github.com/dustinevan/chron/dura"
"fmt"
"reflect"
"database/sql/driver"
"strings"
)
type Micro struct {
time.Time
}
func NewMicro(year int, month time.Month, day, hour, min, sec, micro int) Micro {
return Micro{time.Date(year, month, day, hour, min, sec, micro*1000, time.UTC)}... | micro.go | 0.649023 | 0.458652 | micro.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.