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 grid
import (
"fmt"
"github.com/callum-oakley/fgwm/wmutils"
)
func (g *Grid) getRectangle(wid wmutils.WindowID) (Rectangle, error) {
pPos, pSize, err := wmutils.GetAttributes(wid)
if err != nil {
return Rectangle{}, fmt.Errorf(
"error getting rectangle for wid %v: %v",
wid,
err,
)
}
return... | grid/utils.go | 0.722135 | 0.452354 | utils.go | starcoder |
package economist
import (
"github.com/coschain/contentos-go/common/constants"
. "github.com/coschain/contentos-go/dandelion"
"github.com/coschain/contentos-go/prototype"
"github.com/stretchr/testify/assert"
"math/big"
"testing"
)
type VoteTester struct {
acc0,acc1,acc2,acc3,acc4 *DandelionAccount
}
func (tes... | tests/economist/vote.go | 0.505859 | 0.47244 | vote.go | starcoder |
package compositions
/*
Centered log ratio transform of a (dataset of) composition(s) and its inverse.
Arguments
data a composition or a data matrix of compositions, not necessarily closed
clr the clr-transform of a composition or a data matrix of clr-transforms of compositions, not necessarily centered (i.e. s... | comp.go | 0.830972 | 0.743145 | comp.go | starcoder |
package main
import (
. "go-guide/datastruct/binaryTree/treeNode"
"log"
)
/***
路径总和 II:https://leetcode-cn.com/problems/path-sum-ii/
给你二叉树的根节点 root 和一个整数目标和 targetSum ,找出所有 从根节点到叶子节点 路径总和等于给定目标和的路径。
叶子节点 是指没有子节点的节点。
*/
func main() {
root := NewNormalTree()
targetSum := 11
log.Println("所有路径总和II-递归:", pathSum(ro... | datastruct/binaryTree/leetcodeQuestion/pathSum/pathSum.go | 0.522933 | 0.454896 | pathSum.go | starcoder |
package managers
import (
"github.com/juan-medina/gosge/components/geometry"
"github.com/juan-medina/gosge/components/sprite"
)
// CollisionManager is a manager for manage collisions
type CollisionManager struct {
sm *StorageManager
}
// getSpriteRectAt return a geometry.Rect for a given sprite.Sprite at a geomet... | managers/collisionmng.go | 0.833663 | 0.587707 | collisionmng.go | starcoder |
package main
import (
"bufio"
"fmt"
"os"
)
const (
top = 0
bottom = 1
left = 2
right = 3
)
type tile struct {
id int
edges []string // 0: top, 1: bottom, 2: left, 3: right
inner []string // horizontal lines of the binary image
}
type tileMatch struct {
edge int
otherTile int
otherEdge ... | 2020/day20/jurassicJigsaw.go | 0.510008 | 0.542379 | jurassicJigsaw.go | starcoder |
package input
import (
"github.com/benthosdev/benthos/v4/internal/component/input"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/internal/impl/nats/auth"
"github.com/benthosdev/benthos/v4/internal/interop"
"github.... | internal/old/input/nats_stream.go | 0.810329 | 0.637482 | nats_stream.go | starcoder |
package sliceutil
import (
"reflect"
"sort"
)
// Compare will check if two slices are equal
// even if they aren't in the same order
// Inspired by github.com/stephanbaker white board sudo code
func Compare(s1, s2 interface{}) bool {
if s1 == nil || s2 == nil {
return false
}
// Convert slices to correct type... | sliceutil/sliceutil.go | 0.650467 | 0.406744 | sliceutil.go | starcoder |
package generator
import (
"github.com/drakos74/oremi/internal/data/model"
)
// Line is a collection of points adhering to a graph evolution model in 2D space
type Line model.Series
// NewLine creates a new collection of a number of vectors forming a line
func NewLine(num int, a, b, step float64) model.Collection {... | internal/data/source/generator/geometry.go | 0.837587 | 0.567008 | geometry.go | starcoder |
package influx2otel
import (
"errors"
"fmt"
"strings"
"time"
"github.com/influxdata/influxdb-observability/common"
"go.opentelemetry.io/collector/model/pdata"
)
type LineProtocolToOtelMetrics struct {
logger common.Logger
}
func NewLineProtocolToOtelMetrics(logger common.Logger) (*LineProtocolToOtelMetrics, ... | influx2otel/metrics.go | 0.564219 | 0.488283 | metrics.go | starcoder |
package templates
// README is the contents of the README.md file
const README = `# dslink-{{.Lang}}-{{.Name}}
## {{.Node}} DSLink
A DSLink for <complete this>
`
const LICENSE = ` Copyright <Year> <Person/Company>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file exc... | templates/common_templates.go | 0.778439 | 0.447762 | common_templates.go | starcoder |
package numbers
var Context = &TransformManager {}
type MethodTransform func() Operate
// define transform method
type Operator interface {
// transform to string
Transform2String(value Value, defaultValue Value) interface{}
// transform to int64
Transform2Int64(value Value, defaultValue Value) interface{}
//... | numbers/transfromer_register.go | 0.667256 | 0.518912 | transfromer_register.go | starcoder |
package box2d
func B2CollideCircles(manifold *B2Manifold, circleA *B2CircleShape, xfA B2Transform, circleB *B2CircleShape, xfB B2Transform) {
manifold.PointCount = 0
pA := B2TransformVec2Mul(xfA, circleA.M_p)
pB := B2TransformVec2Mul(xfB, circleB.M_p)
d := B2Vec2Sub(pB, pA)
distSqr := B2Vec2Dot(d, d)
rA := ci... | CollisionB2CollideCircle.go | 0.817429 | 0.809088 | CollisionB2CollideCircle.go | starcoder |
package geometry_msgs_msg
import (
"unsafe"
"github.com/tiiuae/rclgo/pkg/rclgo"
"github.com/tiiuae/rclgo/pkg/rclgo/types"
"github.com/tiiuae/rclgo/pkg/rclgo/typemap"
primitives "github.com/tiiuae/rclgo/pkg/rclgo/primitives"
)
/*
#include <rosidl_runtime_c/message_type_support_struct.h>
#include <geometry_msgs... | internal/msgs/geometry_msgs/msg/AccelWithCovariance.gen.go | 0.73914 | 0.462716 | AccelWithCovariance.gen.go | starcoder |
package sparsetable
import (
"bytes"
"encoding/gob"
"fmt"
"sort"
"unicode/utf8"
"github.com/pkg/errors"
)
// State represents a the state of a DFA.
// It is a simple integer that points to the active state of the DFA's
// cell table.
type State int
// Valid returns true if the state is still valid.
func (s St... | dfa.go | 0.764979 | 0.492005 | dfa.go | starcoder |
package main
const contributors = `[
{
"login": "ardan-bkennedy",
"id": 2280005,
"avatar_url": "https://avatars3.githubusercontent.com/u/2280005?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ardan-bkennedy",
"html_url": "https://github.com/ardan-bkennedy",
"followers_url":... | topics/go/exercises/contributors/githubmock/contributors.go | 0.508056 | 0.454412 | contributors.go | starcoder |
package httpassert
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"strconv"
"testing"
"time"
)
func renderJSONError(t *testing.T, expected interface{}, b []byte) {
t.Errorf(
"error: unexpected value.\nwant response:\n%s\ngot json:\n%s\n",
renderInterface(expected, 0),
renderJSON(b),
)
}
func renderI... | render_json_error.go | 0.587115 | 0.422683 | render_json_error.go | starcoder |
package color
// XTerm256 is a 256 color palette.
func XTerm256() *IndexedPalette {
p := NewIndexedPalette()
p.add(
index{rgb: MakeRGB(0, 0, 0), labels: []string{"Black"}},
index{rgb: MakeRGB(128, 0, 0), labels: []string{"Maroon"}},
index{rgb: MakeRGB(0, 128, 0), labels: []string{"Green"}},
index{rgb: MakeRG... | ui/color/xterm.go | 0.662469 | 0.459561 | xterm.go | starcoder |
package substring
import (
"bytes"
"regexp"
"github.com/toqueteos/trie"
)
type BytesMatcher interface {
Match(b []byte) bool
MatchIndex(b []byte) int
}
// regexp
type regexpBytes struct{ re *regexp.Regexp }
func BytesRegexp(pat string) *regexpBytes { return ®expBytes{regexp.MustCompile(pat)} }
func (m *re... | vendor/gopkg.in/toqueteos/substring.v1/bytes.go | 0.68056 | 0.403449 | bytes.go | starcoder |
package template
import (
"bytes"
"io"
"strings"
"text/template"
"github.com/golang/gddo/doc"
"github.com/posener/goreadme/internal/markdown"
)
// Execute is used to execute the README.md template
func Execute(w io.Writer, data interface{}) error {
return main.Execute(&multiNewLineEliminator{w: w}, data)
}
v... | internal/template/template.go | 0.55447 | 0.568476 | template.go | starcoder |
package datatype
import (
"fmt"
)
type tempType int
// Temperature units - Celsius, Fahrenheit, Kelvin
const (
Celsius tempType = iota
Fahrenheit
Kelvin
)
// TemperatureType - struct for implementing convertions of temperature
type TemperatureType struct {
b *BaseDataType
tempUnit tempType
c... | frontend/core/datatype/temperature.go | 0.58818 | 0.499939 | temperature.go | starcoder |
package event_service
import (
"code-test/server/model"
"code-test/server/repository"
"log"
)
// this mapping functions isolate the datamodel object construction to a single file - if the data model changes, the mapping related changes will happen in the same place
// also, status validation related to the event i... | server/services/event_service/eventMapping.go | 0.718792 | 0.401805 | eventMapping.go | starcoder |
Package migrations houses the orc8r data migration executables.
This doc.go describes how to write an orc8r data migration.
Functionality
Migrations are expected to conform to the following descriptions
- Idempotent
- Running the migration multiple times has same effect as running once
- Self-contained
- M... | orc8r/cloud/go/tools/migrations/doc.go | 0.53777 | 0.571527 | doc.go | starcoder |
package lexers
import . "github.com/johnsto/go-highlight"
var CSS = Lexer{
Name: "css",
MimeTypes: []string{"text/css"},
Filenames: []string{"*.css"},
States: StatesSpec{
"root": {
{Include: "whitespace"},
{Include: "singleLineComment"},
{Include: "multiLineComment"},
{Include: "selector"},
... | lexers/lexer_css.go | 0.53607 | 0.416856 | lexer_css.go | starcoder |
package typeinfo
import (
"context"
"fmt"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/dolt/go/store/types"
)
// This is a dolt implementation of the MySQL type Geometry, thus most of the functionality
// within is directly reliant on the go-mysql-server implementation.
type geometryType struct... | go/libraries/doltcore/schema/typeinfo/geometry.go | 0.716219 | 0.629091 | geometry.go | starcoder |
package geometry
import (
"errors"
"math"
"github.com/benjamin-rood/abm-cp/calc"
)
// Vector : Any sized dimension representation of a point of vector space.
type Vector []float64
// VectorEquality – Trying to implement a quick version of checking for Vector equality
type VectorEquality interface {
Equal(Vector... | geometry/geometry.go | 0.830388 | 0.652144 | geometry.go | starcoder |
package rangeproof
import (
"encoding/binary"
"fmt"
"io"
"math/big"
"github.com/pkg/errors"
ristretto "github.com/bwesterb/go-ristretto"
"github.com/dusk-network/dusk-blockchain/pkg/crypto/rangeproof/fiatshamir"
"github.com/dusk-network/dusk-blockchain/pkg/crypto/rangeproof/innerproduct"
"github.com/dusk-ne... | pkg/crypto/rangeproof/rangeproof.go | 0.667039 | 0.472014 | rangeproof.go | starcoder |
package gt
import (
"database/sql/driver"
"time"
)
/*
Shortcut: parses successfully or panics. Should be used only in root scope. When
error handling is relevant, use `.Parse`.
*/
func ParseNullInterval(src string) (val NullInterval) {
try(val.Parse(src))
return
}
// Simplified interval constructor without a tim... | gt_null_interval.go | 0.845656 | 0.538316 | gt_null_interval.go | starcoder |
package trie
import "github.com/zainkai/go-collections/queue"
type TrieNode struct {
Key byte
Conns map[byte]*TrieNode
IsWord bool
Word string
}
// Trie implementation
type Trie struct {
root *TrieNode
}
// New create a Trie
func New() *Trie {
root := &TrieNode{
Key: byte(0),
Conns: make(map[byt... | trie/trie.go | 0.709221 | 0.427755 | trie.go | starcoder |
package haar
import (
"image"
"image/color"
"math"
)
// ColourChannels is the number of channels for one color. We will be using
// three colour channels per pixel at all times.
const ColourChannels = 3
// Coef is the union of coefficients for all channels of the original image.
type Coef [ColourChannels]float64
... | duplo/haar/haar.go | 0.753829 | 0.54577 | haar.go | starcoder |
package node
import (
"github.com/densify-dev/Container-Optimization-Data-Forwarder/internal/common"
"github.com/prometheus/common/model"
)
//Gets node metrics from prometheus (and checks to see if they are valid)
func getNodeMetric(result model.Value, node model.LabelName, metric string) {
if result == nil {
r... | internal/node/collection.go | 0.504883 | 0.419529 | collection.go | starcoder |
package graph
// Edge represents an edge in a graph with access to its node endpoints.
// If its in a directed graph, it also has access to the node the edge comes from
// and the node the edge goes into. It can also store a value.
type Edge interface {
// GetTo returns the node the edge goes into in a directed graph... | graph/edge.go | 0.851768 | 0.627267 | edge.go | starcoder |
package main
import (
"chaincode/errors"
"strconv"
)
// ------------------------------------------
// Methods on receivers composite traintuple
// ------------------------------------------
// SetFromInput is a method of the receiver CompositeTraintuple.
// It uses the inputCompositeTraintuple to check and set th... | chaincode/traintuple_composite.go | 0.521471 | 0.460835 | traintuple_composite.go | starcoder |
package holtwinters
import "fmt"
// PredictAdditive takes in a seasonal historical series of data and produces a prediction of what the data will be in the future using triple
// exponential smoothing using the additive method. Existing data will also be smoothed alongside predictions. Returns the entire dataset with... | holtwinters.go | 0.811788 | 0.881002 | holtwinters.go | starcoder |
package server
import (
"fmt"
"reflect"
"strconv"
)
// SafeStringFromMap returns the value referenced by `key` in `values`. as a string.
// If not found, it returns an empty string.
func SafeStringFromMap(values map[string]interface{}, key string) string {
if values[key] == nil {
return ""
}
return values[key... | components/infra-proxy-service/server/util.go | 0.843959 | 0.438725 | util.go | starcoder |
package material
import (
"dasa.cc/simplex"
"golang.org/x/mobile/exp/f32"
)
type Box struct {
l, r, b, t, z simplex.Var
world f32.Mat4
}
func NewBox(prg *simplex.Program) (a Box) {
a.l, a.r, a.b, a.t, a.z = prg.Var(1), prg.Var(1), prg.Var(1), prg.Var(1), prg.Var(1)
return
}
func (a Box) Width(x float3... | layout.go | 0.718496 | 0.563678 | layout.go | starcoder |
package resize
import "image"
// Keep value in [0,255] range.
func clampUint8(in int32) uint8 {
// casting a negative int to an uint will result in an overflown
// large uint. this behavior will be exploited here and in other functions
// to achieve a higher performance.
if uint32(in) < 256 {
return uint8(in)
... | converter.go | 0.672117 | 0.428592 | converter.go | starcoder |
package actrf
import (
"github.com/emer/etable/etensor"
"github.com/emer/etable/norm"
)
// RF is used for computing an activation-based receptive field.
// It simply computes the activation weighted average of other
// *source* patterns of activation -- i.e., sum(act * src) / sum(src)
// which then shows you the p... | actrf/actrf.go | 0.704364 | 0.54698 | actrf.go | starcoder |
package util
import (
"fmt"
"reflect"
structpb "github.com/golang/protobuf/ptypes/struct"
)
func StructProto(v map[string]interface{}) *structpb.Struct {
size := len(v)
if size == 0 {
return nil
}
fields := make(map[string]*structpb.Value, size)
for k, v := range v {
fields[k] = ValueProto(v)
}
return ... | core/util/proto.go | 0.647575 | 0.436682 | proto.go | starcoder |
package main
import (
"math"
"math/rand"
"time"
)
type Boid struct {
position Vector2D
velocity Vector2D
id int
}
func createBoid(bid int) {
b := Boid{
position: Vector2D{x: rand.Float64() * screenWidth, y: rand.Float64() * screenHeight},
velocity: Vector2D{x: (rand.Float64() * 2) - 1.0, y: (rand.Fl... | boids/boid.go | 0.636579 | 0.520374 | boid.go | starcoder |
package solve_equation
import "fmt"
/*
* @lc app=leetcode id=640 lang=golang
*
* [640] Solve the Equation
*
* https://leetcode.com/problems/solve-the-equation/description/
*
* algorithms
* Medium (40.95%)
* Total Accepted: 20.6K
* Total Submissions: 50.2K
* Testcase Example: '"x+5-3+x=6+x-2"'
*
*
* ... | 640-solve-the-equation/640.solve-the-equation.go | 0.882933 | 0.402187 | 640.solve-the-equation.go | starcoder |
package distuv
import (
"math"
"golang.org/x/exp/rand"
)
// Triangle represents a triangle distribution (https://en.wikipedia.org/wiki/Triangular_distribution).
type Triangle struct {
a, b, c float64
Src *rand.Rand
}
// NewTriangle constructs a new triangle distribution with lower limit a, upper limit b, a... | vendor/gonum.org/v1/gonum/stat/distuv/triangle.go | 0.890948 | 0.690872 | triangle.go | starcoder |
package giu
import (
"image"
"image/color"
"github.com/AllenDang/giu/imgui"
)
type Canvas struct {
drawlist imgui.DrawList
}
func GetCanvas() *Canvas {
return &Canvas{
drawlist: imgui.GetWindowDrawList(),
}
}
func (c *Canvas) AddLine(p1, p2 image.Point, color color.RGBA, thickness float32) {
c.drawlist.Ad... | Canvas.go | 0.75101 | 0.57821 | Canvas.go | starcoder |
package sort
import (
"fmt"
"math"
)
type IndexMaxHeap struct {
/**real data**/
datas []int
/**
binary heap of index for data
**/
indexs []int
revs []int
}
func NewIndexMaxHeap(cap int) *IndexMaxHeap {
heap := &IndexMaxHeap{make([]int, 0, cap+1), make([]int, 0, cap+1),
make([]int, 0, cap+1)}
heap.... | indexMaxHeap.go | 0.605682 | 0.449332 | indexMaxHeap.go | starcoder |
package merkleblock
import (
"github.com/gcash/bchd/blockchain"
"github.com/gcash/bchd/chaincfg/chainhash"
"github.com/gcash/bchd/wire"
"github.com/gcash/bchutil"
"github.com/gcash/bchutil/bloom"
)
// MerkleBlock is used to house intermediate information needed to generate a
// wire.MsgMerkleBlock
type MerkleBl... | merkleblock/encode.go | 0.751739 | 0.406332 | encode.go | starcoder |
package square
// A payment represents a paid transaction between a Square merchant and a customer. Payment details are usually available from Connect API endpoints within a few minutes after the transaction completes. Each Payment object includes several fields that end in `_money`. These fields describe the various... | square/model_v1_payment.go | 0.824179 | 0.671969 | model_v1_payment.go | starcoder |
package gofinancial
import (
"time"
"github.com/shopspring/decimal"
"github.com/razorpay/go-financial/enums/paymentperiod"
"github.com/razorpay/go-financial/enums/interesttype"
"github.com/razorpay/go-financial/enums/frequency"
)
// Config is used to store details used in generation of amortization table.
ty... | config.go | 0.68763 | 0.426322 | config.go | starcoder |
package main
import "fmt"
type maxHeap struct {
array []int
}
//insert adds an element to the heap
func (h *maxHeap) insert(key int) {
h.array = append(h.array, key)
h.maxHeapifyUp(len(h.array) - 1)
}
//extract returns the largest key, and removes it from the heap
func (h *maxHeap) extract() int {
extracted := ... | heap/main.go | 0.654674 | 0.40698 | main.go | starcoder |
package yamltags
import (
"errors"
"fmt"
"reflect"
"strconv"
"strings"
)
// ProcessStruct validates and processes the provided pointer to a struct.
func ProcessStruct(s interface{}) error {
parentStruct := reflect.ValueOf(s).Elem()
t := parentStruct.Type()
// Loop through the fields on the struct, looking fo... | pkg/skaffold/yamltags/tags.go | 0.589244 | 0.403773 | tags.go | starcoder |
package storj
// RedundancyScheme specifies the parameters and the algorithm for redundancy
type RedundancyScheme struct {
// Algorithm determines the algorithm to be used for redundancy.
Algorithm RedundancyAlgorithm
// ShareSize is the size in bytes for each erasure shares.
ShareSize int32
// RequiredShares ... | vendor/storj.io/common/storj/redundancy.go | 0.76986 | 0.423041 | redundancy.go | starcoder |
package iso20022
// Specifies the details relative to the submission of the certificate data set.
type RequiredSubmission4 struct {
// Specifies with party(ies) is authorised to submit the data set as part of the transaction.
Submitter []*BICIdentification1 `xml:"Submitr"`
// Specifies the type of the certificate... | RequiredSubmission4.go | 0.802285 | 0.407687 | RequiredSubmission4.go | starcoder |
package cpu
// Good reference with some info Z80 heaven doesn't contain:
// http://www.devrs.com/gb/files/GBCPU_Instr.html
// RLCr -> e.g. RLC B
// Performs 8-bit rotation to the left
// Rotated bit is copied to carry
// Flags: Z00C
func (gbcpu *GBCPU) RLCr(reg *byte) {
carry := *reg >> 7
*reg = (*reg<<1 | carry)
... | cpu/executors-cb.go | 0.606382 | 0.42937 | executors-cb.go | starcoder |
package rbtree
// This file contains all RB tree modification methods implementations
// Insert inserts new node into Red-Black tree. Creates Root if tree is empty
func (tree *rbTree) Insert(z Comparable) {
if z == nil {
return
}
n := newNode(z)
tree.insert(n)
}
// ReplaceOrInsert inserts new node into Red-Bla... | rbtree/modification.go | 0.788949 | 0.463262 | modification.go | starcoder |
package doltcore
import (
"fmt"
"strconv"
"github.com/liquidata-inc/dolt/go/store/types"
)
type ConversionError struct {
fromKind types.NomsKind
toKind types.NomsKind
err error
}
func (ce ConversionError) Error() string {
toKindStr := types.KindToString[ce.toKind]
fromKindStr := types.KindToString[c... | go/libraries/doltcore/type_conversion.go | 0.702428 | 0.482368 | type_conversion.go | starcoder |
package types
import (
"fmt"
"regexp"
"strings"
)
var DEBUG_LABEL_FILTER_PARSING = false
type LabelFilter func([]string) bool
func matchLabelAction(label string) LabelFilter {
expected := strings.ToLower(label)
return func(labels []string) bool {
for i := range labels {
if strings.ToLower(labels[i]) == ex... | vendor/github.com/onsi/ginkgo/v2/types/label_filter.go | 0.504639 | 0.413951 | label_filter.go | starcoder |
package serialization
import (
"time"
"github.com/google/uuid"
)
// ParseNode Interface for a deserialization node in a parse tree. This interace provides an abstraction layer over serialization formats, libraries and implementations.
type ParseNode interface {
// GetChildNode returns a new parse node for the giv... | abstractions/go/serialization/parse_node.go | 0.664758 | 0.532607 | parse_node.go | starcoder |
package gorgonia
import (
"fmt"
"hash"
"github.com/chewxy/hm"
"github.com/pkg/errors"
"gorgonia.org/tensor"
)
func SoftMax(x *Node, axes ...int) (*Node, error) {
op := newSoftmaxOp(x.Shape(), axes...)
return ApplyOp(op, x)
}
type softmaxOp struct {
shape tensor.Shape
axis int
isLog bool
}
func newSoftm... | op_softmax.go | 0.757705 | 0.446796 | op_softmax.go | starcoder |
package entities
import (
"fmt"
tl "github.com/JoelOtter/termloop"
"github.com/zladovan/gorched/gmath"
"github.com/zladovan/gorched/physics"
)
// Label is text entity with one row of text.
type Label struct {
// position is reference position of this label
position gmath.Vector2i
// format defines text format... | entities/label.go | 0.73659 | 0.42674 | label.go | starcoder |
package ga
import "github.com/rannoch/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "dd/MM/y"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:mm:ss"... | resources/locales/ga/calendar.go | 0.508544 | 0.455925 | calendar.go | starcoder |
package timeseries
import (
"math"
"sort"
"time"
)
// Aligns point's time stamps according to provided interval.
func (ts TimeSeries) Align(interval time.Duration) TimeSeries {
if interval <= 0 || ts.Len() < 2 {
return ts
}
alignedTs := NewTimeSeries()
var frameTs = ts[0].GetTimeFrame(interval)
var pointFr... | pkg/timeseries/align.go | 0.809728 | 0.605857 | align.go | starcoder |
package lcwidgets
import (
"fmt"
"image"
ui "github.com/gizak/termui/v3"
)
// Table renders rows and each row has columns which can be strings or Blocks
type Table struct {
ui.Block
ColumnNames []string
ColumnWidths []int
Rows [][]interface{}
firstRow int
}
// NewTable creates a new scrollable ... | lc-admin/lcwidgets/table.go | 0.596786 | 0.506897 | table.go | starcoder |
package schedule
import (
"fmt"
"time"
)
type ScheduleSpec struct {
StartTime WeekdayTime // Monday 8am
EndTime WeekdayTime // Friday 5pm
}
type WeekdayTime struct {
Weekday time.Weekday
TimeOfDay TimeOfDay
}
type TimeOfDay struct {
Hour int
Minute int
}
type Schedule struct {
spec *ScheduleSpec
}
... | pkg/schedule/schedule.go | 0.588771 | 0.514339 | schedule.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// SLOHistoryMetricsSeries A representation of `metric` based SLO time series for the provided queries. This is the same response type from `batch_query` endpoint.
type SLOHistoryMetricsSeries struct {
// Count of submitted metrics.
Count int64 ... | api/v1/datadog/model_slo_history_metrics_series.go | 0.829112 | 0.422683 | model_slo_history_metrics_series.go | starcoder |
package network
import (
"bytes"
"fmt"
"github.com/yaricom/goNEAT/v2/neat"
"github.com/yaricom/goNEAT/v2/neat/math"
)
// NNode is either a NEURON or a SENSOR.
// - If it's a sensor, it can be loaded with a value for output
// - If it's a neuron, it has a list of its incoming input signals ([]*Link is used)
//... | neat/network/nnode.go | 0.663451 | 0.452294 | nnode.go | starcoder |
package kiwi
import "strconv"
type Term struct {
Variable *Variable
Coefficient float64
}
var _ Constrainer = Term{}
func (t Term) GetValue() float64 {
return t.Coefficient * t.Variable.Value
}
func (t Term) Multiply(coefficient float64) Term {
return Term{Variable: t.Variable, Coefficient: t.Coefficient *... | term.go | 0.815233 | 0.469034 | term.go | starcoder |
package gi3d
import (
"math"
"github.com/goki/ki/kit"
"github.com/goki/mat32"
)
// Torus is a torus mesh, defined by the radius of the solid tube and the
// larger radius of the ring.
type Torus struct {
MeshBase
Radius float32 `desc:"larger radius of the torus ring"`
TubeRadius float32 `desc:"radius of t... | gi3d/torus.go | 0.824921 | 0.425307 | torus.go | starcoder |
package object
// initialize built-in objects like Int, Arr, Str...
// NOTE: Props are inserted in package eval not to make
// package object and package BuiltIn circular reference
// BuiltInIntObj is an object of Int (proto of each int).
var BuiltInIntObj = NewPanObj(&map[SymHash]Pair{}, BuiltInNumObj, WithZero(Buil... | object/builtinobj.go | 0.575111 | 0.517266 | builtinobj.go | starcoder |
package eval
import (
"fmt"
"reflect"
"strings"
"github.com/alecthomas/participle/lexer"
)
// ErrInvalidPattern is returned for an invalid regular expression
type ErrInvalidPattern struct {
Pattern string
}
func (e ErrInvalidPattern) Error() string {
return fmt.Sprintf("invalid pattern `%s`", e.Pattern)
}
/... | pkg/security/secl/eval/errors.go | 0.861159 | 0.410225 | errors.go | starcoder |
package klog
import (
"errors"
"fmt"
"regexp"
"strconv"
)
// Duration represents a time span.
type Duration interface {
InMinutes() int
// Plus adds up two durations and returns a new duration.
// It doesn’t alter the original duration object.
Plus(Duration) Duration
// Minus subtracts the second from the ... | src/duration.go | 0.814717 | 0.440168 | duration.go | starcoder |
package plot
import "math"
// SetScreenLog1P sets axis to logarithm space.
func (axis *Axis) SetScreenLog1P(compress float64) {
if compress == 0 {
axis.Transform = nil
return
}
invert := compress < 0
if invert {
compress = -compress
}
mul := 1 / math.Log1p(compress)
invCompress := 1 / compress
tx := &... | axis_log.go | 0.883739 | 0.40987 | axis_log.go | starcoder |
package utils
import (
"fmt"
"strconv"
"strings"
"regexp"
"time"
)
// Date represents a date in a search query. FHIR search params may define
// dates to varying levels of precision, and the amount of precision affects
// the behavior of the query. Date's value should only be interpreted in the
// context of ... | vendor/github.com/eug48/fhir/utils/date.go | 0.738952 | 0.469216 | date.go | starcoder |
package miner
import (
abi "github.com/filecoin-project/specs-actors/actors/abi"
big "github.com/filecoin-project/specs-actors/actors/abi/big"
power "github.com/filecoin-project/specs-actors/actors/builtin/power"
)
// An approximation to chain state finality (should include message propagation time as well).
const... | actors/builtin/miner/policy.go | 0.675551 | 0.452717 | policy.go | starcoder |
package cmd
import (
"fmt"
"strconv"
"strings"
"github.com/jaredbancroft/aoc2020/pkg/docking"
"github.com/jaredbancroft/aoc2020/pkg/helpers"
"github.com/spf13/cobra"
)
// day14Cmd represents the day14 command
var day14Cmd = &cobra.Command{
Use: "day14",
Short: "Advent of Code 2020 - Day14: Docking Data",
... | cmd/day14.go | 0.597373 | 0.493226 | day14.go | starcoder |
package influxql
import (
"sort"
"github.com/gogo/protobuf/proto"
"github.com/influxdata/influxdb/influxql/internal"
)
// ZeroTime is the Unix nanosecond timestamp for time.Time{}.
const ZeroTime = int64(-6795364578871345152)
// Point represents a value in a series that occurred at a given time.
type Point inter... | vendor/github.com/influxdata/influxdb/influxql/point.go | 0.686475 | 0.444203 | point.go | starcoder |
package it
// Volume defines a volume value
type Volume uint8
// Value returns the value of the volume as a floating point value between 0 and 1, inclusively
func (p Volume) Value() float32 {
switch {
case p <= 64:
return float32(p) / 64
default:
panic("unexpected value")
}
}
// FineVolume defines a volume v... | music/tracked/it/util.go | 0.850142 | 0.733714 | util.go | starcoder |
package shell
import (
"encoding/binary"
"errors"
"math"
"strconv"
"strings"
"fmt"
"encoding/hex"
)
type Token struct {
Buf string
DataType uint
}
func (t *Token) ToMustValue() interface{} {
v, err := t.ToValue()
if err != nil {
panic(err)
}
return v
}
func (t *Token) ToValue() (interface{}, err... | shell/tokenize.go | 0.566019 | 0.410461 | tokenize.go | starcoder |
package storetestcases
import (
"context"
"testing"
"github.com/stratumn/go-chainscript"
"github.com/stratumn/go-chainscript/chainscripttest"
"github.com/stratumn/go-core/store"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestEvidenceStore runs all tests for the store.Evid... | store/storetestcases/evidencestore.go | 0.55447 | 0.447702 | evidencestore.go | starcoder |
package spatial
import (
"encoding/json"
"math"
"reflect"
)
func coordToSlice(fs ...float64) []*float64 {
cs := make([]*float64, len(fs))
for i, f := range fs {
if !math.IsNaN(f) {
cs[i] = &fs[i]
}
}
return cs
}
func (c Coord) coordToSlice() []*float64 { return coordToSlice(c.X, c.Y) }
func (c Coord... | driver/spatial/geojson.go | 0.70477 | 0.459197 | geojson.go | starcoder |
package blog_posts
import (
"encoding/json"
)
// BackgroundImage struct for BackgroundImage
type BackgroundImage struct {
ImageUrl string `json:"imageUrl"`
BackgroundSize string `json:"backgroundSize"`
BackgroundPosition string `json:"backgroundPosition"`
}
// NewBackgroundImage instantiates a new... | generated/blog_posts/model_background_image.go | 0.818845 | 0.425486 | model_background_image.go | starcoder |
package binarytree
// BinaryTree represents a corresponding abstract data structure
type BinaryTree struct {
Root *Node
}
// NewBinaryTree is a function that creates new "instance" for structure
func NewBinaryTree(nodes ...int) BinaryTree {
if len(nodes) == 0 {
return BinaryTree{nil}
}
tree := BinaryTree{nil}
... | BinaryTree/binary_tree.go | 0.800302 | 0.605741 | binary_tree.go | starcoder |
package pure
import (
"errors"
"fmt"
"strconv"
"github.com/benthosdev/benthos/v4/internal/batch/policy"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component/input"
iprocessor "github.com/benthosdev/benthos/v4/internal/component/processor"
"github.com/benthosd... | internal/impl/pure/input_broker.go | 0.694199 | 0.61173 | input_broker.go | starcoder |
package test_decl
func assert(want int, act int, code string)
func println(format string)
func strcmp(s1 string, s2 string) int
var g1, g2, g3 bool
var g4, g5, g6 = 2.0, 8, "foo"
var (
g7 int
g8, g9, g10 = 2.0, 3.0, "bar"
)
func main() {
var x1 byte
assert(1, Sizeof(x1), "var x1 byte; Sizeof(x1)")
va... | testdata/esc/decl.go | 0.561936 | 0.465813 | decl.go | starcoder |
package bild
import (
"image"
"image/color"
"math"
)
// Invert returns a negated version of the image.
func Invert(src image.Image) *image.RGBA {
fn := func(c color.RGBA) color.RGBA {
return color.RGBA{255 - c.R, 255 - c.G, 255 - c.B, c.A}
}
img := apply(src, fn)
return img
}
// Grayscale returns a copy o... | effects.go | 0.900139 | 0.624007 | effects.go | starcoder |
package table
import (
"fmt"
"github.com/nboughton/rollt"
)
// OneRoll represents the oft used one-roll systems spread throughout SWN
type OneRoll struct {
D4 rollt.Able
D6 rollt.Able
D8 rollt.Able
D10 rollt.Able
D12 rollt.Able
D20 rollt.Able
}
// Roll performs all rolls for a OneRoll and returns the res... | table/table.go | 0.530601 | 0.41561 | table.go | starcoder |
package geoindex
var (
minLon = -180.0
minLat = -90.0
latDegreeLength = Km(111.0)
lonDegreeLength = Km(85.0)
)
type Meters float64
func Km(km float64) Meters {
return Meters(km * 1000)
}
func Meter(meters float64) Meters {
return Meters(meters)
}
type cell struct {
x int
y int
}
func cel... | hotelReservation/vendor/github.com/hailocab/go-geoindex/geo-index.go | 0.851089 | 0.492432 | geo-index.go | starcoder |
package mon
// SLOFreshnessTiles freshness SLO dashboard JSON template
const SLOFreshnessTiles = `
[
{
"height": 2,
"width": 4,
"widget": {
"title": "<scope> <flow> <sloText> < <thresholdText>",
"text": {
"content": "**Freshness**: <sloText> of <scope> configurations from <flow> flow over the last 28... | utilities/mon/const_dashboardslofreshness.go | 0.617513 | 0.466663 | const_dashboardslofreshness.go | starcoder |
package ldraw
import (
"fmt"
"log"
"math"
"strconv"
)
// TransMatrix TransMatrix
type TransMatrix [16]float64
/* InitMatrix 1
/ a d g 0 \ / a b c x \
| b e h 0 | | d e f y |
| c f i 0 | | g h i z |
\ x y z 1 / \ 0 0 0 1 /
*/
var InitMatrix = &TransMatrix{
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0... | matrix.go | 0.589835 | 0.512937 | matrix.go | starcoder |
// The Carrier Package provides a framework for communicating with
// Carrier Infinity and Bryant Evolution Furnaces.
package Carrier
import (
"bytes"
"encoding/binary"
"github.com/npat-efault/crc16"
)
// Frame provides a structure to capture the Carrier Framing.
// See Docs/framing.md for details.
type Frame st... | Carrier/Frame.go | 0.669313 | 0.408808 | Frame.go | starcoder |
package geojson
import "github.com/tidwall/geojson/geometry"
// Spatial ...
type Spatial interface {
WithinRect(rect geometry.Rect) bool
WithinPoint(point geometry.Point) bool
WithinLine(line *geometry.Line) bool
WithinPoly(poly *geometry.Poly) bool
IntersectsRect(rect geometry.Rect) bool
IntersectsPoint(point ... | spatial.go | 0.792745 | 0.765987 | spatial.go | starcoder |
package taxi
import (
"github.com/golang/geo/s2"
)
// Service interface to apply business logic to dataset and transforming to the output.
// GetTotalTripsByStartEndDate: Returns the TotalTripsByDay data from the repository.
// GetAverageSpeedByDate: Returns the AverageSpeedByDay data from the repository.
// GetAver... | taxi/service.go | 0.768299 | 0.478529 | service.go | starcoder |
package main
import (
"bufio"
"flag"
"fmt"
"os"
"regexp"
"strconv"
)
var (
methodP *string
)
func parseFlags() {
methodP = flag.String("method", "all", "The method/part that should be run, valid are p1,p2 and test")
flag.Parse()
}
func main() {
parseFlags()
switch *methodP {
case "all":
fmt.Println(... | 2021/17-TrickShot/main.go | 0.554953 | 0.41182 | main.go | starcoder |
package ast
import "errors"
// Variant represents a value at runtime.
type Variant struct {
Type TypeKind
Int int64
String string
Bool bool
IsReturn bool
VariableReferenceFailed bool
VectorData []*Variant
Na... | ast/variant.go | 0.673406 | 0.432243 | variant.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTExportTessellatedFacesBody1321AllOf struct for BTExportTessellatedFacesBody1321AllOf
type BTExportTessellatedFacesBody1321AllOf struct {
Appearance *BTGraphicsAppearance1152 `json:"appearance,omitempty"`
BodyType *string `json:"bodyType,omitempty"`
BtType *string `j... | onshape/model_bt_export_tessellated_faces_body_1321_all_of.go | 0.713831 | 0.455865 | model_bt_export_tessellated_faces_body_1321_all_of.go | starcoder |
package prop
import (
"fmt"
"math"
"strings"
)
// FloatConstraint is an interface to represent float value constraint.
type FloatConstraint interface {
Compare(float32) (float64, bool)
Value() (float32, bool)
}
// Float specifies ideal float value.
// Any value may be selected, but closest value takes priority.... | pkg/prop/float.go | 0.855866 | 0.46041 | float.go | starcoder |
package leveldb
/*
level
Copyright (c) 2019 beito
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
import "fmt"
import "math"
// GetStorageTypeFromSize returns
func GetStorageTypeFromSize(size uint) StorageType {
size--
size |= (size >> 1)
size |= (size >> ... | leveldb/subchunk.go | 0.737725 | 0.454835 | subchunk.go | starcoder |
package gofa
/*
Tpxes Project celestial to tangent plane, spherical
In the tangent plane projection, given celestial spherical
coordinates for a star and the tangent point, solve for the star's
rectangular coordinates in the tangent plane.
Given:
a,b float64 star's spherical coordinates
a0,b0 flo... | projection.go | 0.928161 | 0.848031 | projection.go | starcoder |
package it
import (
"github.com/m4gshm/gollections/c"
"github.com/m4gshm/gollections/check"
"github.com/m4gshm/gollections/it/impl/it"
"github.com/m4gshm/gollections/op"
)
//Of creates the Iterator of predefined elements.
func Of[T any](elements ...T) c.Iterator[T] {
iter := it.NewHead(elements)
return &iter
}
... | it/api.go | 0.840848 | 0.496643 | api.go | starcoder |
package physics
import (
"github.com/g3n/engine/experimental/collision/shape"
"github.com/g3n/engine/experimental/physics"
"github.com/g3n/engine/experimental/physics/object"
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/gls"
"github.com/g3n/engine/graphic"
"github.com/g3n/engine/light"
"github.com/g... | demos/experimental/physics/spheres.go | 0.596668 | 0.468791 | spheres.go | starcoder |
package geo
import (
"errors"
"math"
"github.com/haiyiyun/mongodb/geometry"
)
// these constants are used for vincentyDistance()
const a = 6378137
const b = 6356752.3142
const f = 1 / 298.257223563 // WGS-84 ellipsiod
/*
VincentyDistance computes the distances between two georgaphic coordinates
Args:
p1: the 's... | geo/vincenty.go | 0.824638 | 0.596257 | vincenty.go | starcoder |
package matrix
import (
"math"
"github.com/kieron-pivotal/rays/tuple"
)
func Translation(x, y, z float64) Matrix {
m := Identity(4, 4)
m.Set(0, 3, x)
m.Set(1, 3, y)
m.Set(2, 3, z)
return m
}
func (m Matrix) Translate(x, y, z float64) Matrix {
t := Translation(x, y, z)
return t.Multiply(m)
}
func Scaling(x... | matrix/transformation.go | 0.858778 | 0.684432 | transformation.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.