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 geotex
import (
"github.com/mmcloughlin/geohash"
"github.com/pkg/errors"
)
var (
accuracyToLength = map[uint]*quarterLength{
2: {lat: 1.40625, lng: 2.8125},
3: {lat: 0.3515625, lng: 0.3515625},
4: {lat: 0.0439453125, lng: 0.087890625},
5: {lat: 0.010986328125, lng: 0.010986328125},
6: {lat: ... | geotex.go | 0.640636 | 0.471588 | geotex.go | starcoder |
package algorithm
import (
"github.com/alecj1240/astart/api"
)
// ChaseTail returns the coordinate of the position behind my tail
func ChaseTail(You []api.Coord) api.Coord {
return You[len(You)-1]
}
func abs(x int) int {
if x < 0 {
return -x
}
return x
}
// Manhatten gives the difference between two points
f... | algorithm/mathfunctions.go | 0.758242 | 0.459804 | mathfunctions.go | starcoder |
package summary
import (
"math"
)
// Mean: Returns the man of the dataset
func Mean(dataset []map[string]float64) map[string]float64 {
result := make(map[string]float64)
for key, values := range groupByKey(dataset) {
result[key] = meanOfArray(values)
}
return result
}
// Median: Returns the median of the da... | summary/summary.go | 0.874185 | 0.707373 | summary.go | starcoder |
package datastructs
import "fmt"
// BTreeNode Binary TreeNode
type BTreeNode struct {
key interface{}
parent *BTreeNode
left *BTreeNode
right *BTreeNode
}
// PrintBinaryTree preorder recursion
func PrintBinaryTree(root *BTreeNode) {
if root == nil {
return
}
fmt.Print(root.key, "\t")
if root.left != ... | datastructs/tree.go | 0.691185 | 0.432003 | tree.go | starcoder |
package list
import (
. "github.com/flowonyx/functional"
"github.com/flowonyx/functional/option"
)
// Indexed converts values into Pairs of each value with its index.
func Indexed[T any](values []T) []Pair[int, T] {
output := make([]Pair[int, T], len(values))
for i := range values {
output[i] = PairOf(i, values... | list/index.go | 0.69368 | 0.473596 | index.go | starcoder |
package simulations
import (
"fmt"
"image"
"image/color"
"math/rand"
"strings"
"github.com/domtriola/automata/internal/models"
"github.com/domtriola/automata/internal/palette"
)
var _ models.Simulation = &CellularAutomata{}
// CellularAutomata simulates a scenario where cells in a 2-dimensional world
// can ... | internal/simulations/cellularAutomata.go | 0.810254 | 0.409044 | cellularAutomata.go | starcoder |
package pkg
import (
"io"
"regexp"
"strings"
"github.com/rotisserie/eris"
)
type BoolNode interface {
Eval(map[string]bool) bool
}
type boolAnd struct {
left BoolNode
right BoolNode
}
func (n boolAnd) Eval(vars map[string]bool) bool {
return n.left.Eval(vars) && n.right.Eval(vars)
}
type boolOr struct {
... | packages/build-tools/pkg/bool_parser.go | 0.587943 | 0.432543 | bool_parser.go | starcoder |
package list1
import "math"
/*
Given an array of ints, return True if 6 appears as either the first or last element in the array. The array will be length 1 or more.
*/
func first_last6(nums []int) bool {
return nums[0] == 6 || nums[len(nums)-1] == 6
}
/*
Given an array of ints, return True if the array is l... | Go/CodingBat/list-1.go | 0.716219 | 0.602851 | list-1.go | starcoder |
package float
import (
"fmt"
"strconv"
"strings"
)
// Parse a float string compatible with Format.
// If a separator was not detected, then zero will be returned for thousandsSep or decimalSep.
// See: https://en.wikipedia.org/wiki/Decimal_separator
func Parse(str string) (float64, error) {
f, _, _, _, err := Par... | float/parse.go | 0.747984 | 0.527803 | parse.go | starcoder |
package index
import (
"github.com/lfritz/clustering/geometry"
)
// A LeafKDTree is a k-d tree for 2-D points that stores one point in each leaf node.
type LeafKDTree struct {
points [][2]float64
root leafTreeNode
}
type leafTreeNode interface {
boundingBox(result []int, points [][2]float64, bb *geometry.Bound... | index/leaf_kdtree.go | 0.827061 | 0.484319 | leaf_kdtree.go | starcoder |
package fullCopy
import (
"math"
"fmt"
"github.com/nylen/go-compgeo/geom"
"github.com/nylen/go-compgeo/printutil"
"github.com/nylen/go-compgeo/search"
)
// FullPersistentBST is an implementation of a persistent
// binary search tree using full copies, with each
// instant represented by a separate BST.
type Fu... | search/tree/fullCopy/fullCopy.go | 0.79854 | 0.574246 | fullCopy.go | starcoder |
package vmath
import (
"unsafe"
)
const (
m3col0 = 0
m3col1 = 3
m3col2 = 6
)
const g_PI_OVER_2 = 1.570796327
func (result *Matrix3) MakeFromScalar(scalar float32) {
result[m3col0+x] = scalar
result[m3col0+y] = scalar
result[m3col0+z] = scalar
result[m3col1+x] = scalar
result[m3col1+y] = scalar
result[m3... | matrix.go | 0.672117 | 0.499268 | matrix.go | starcoder |
package equationdisassembler
import (
"errors"
"fmt"
"log"
"strings"
"unicode"
"unicode/utf8"
)
const secondDegreeSize = 3 // size of "x^2"
const firstDegreeSize = 1 // size of "x"
func Disassemble(equation string, variable string) DisassembledEquationMessage {
log.Printf("Start disassemble equation %s", equa... | src/equationdisassembler/equation_disassembler.go | 0.569853 | 0.472805 | equation_disassembler.go | starcoder |
package processor
import (
"errors"
"fmt"
"strings"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
"github.com/Jeffail/gabs"
)
//------------------------------------------------------------------------------
func init() {
Constructors["p... | lib/processor/process_map.go | 0.771672 | 0.692353 | process_map.go | starcoder |
package common
import (
"fmt"
)
// ValidateString validates string field base on min/max length limit.
func ValidateString(name, data string, minLen, maxLen int) error {
length := len(data)
if minLen > 0 && length == 0 {
return fmt.Errorf("invalid input data, %s is required", name)
}
if length < minLen {
r... | bmsf-configuration/pkg/common/validation.go | 0.727782 | 0.436982 | validation.go | starcoder |
Package fork implements a pattern for forking sub-processes as new Pods.
This can be used when some code that's part of the operator (usually an entire
controller) needs to run under a different Pod context (e.g. different service
account, volume mounts, etc.). The forked Pod runs the same container image as
the paren... | pkg/operator/fork/fork.go | 0.695752 | 0.471467 | fork.go | starcoder |
package proto
import (
"bytes"
"log"
"reflect"
"strings"
)
/*
Equal returns true iff protocol buffers a and b are equal.
The arguments must both be pointers to protocol buffer structs.
Equality is defined in this way:
- Two messages are equal iff they are the same type,
corresponding fields are equal, unk... | vendor/github.com/golang/protobuf/proto/equal.go | 0.664214 | 0.428831 | equal.go | starcoder |
package main
import (
"fmt"
"strings"
)
const (
// operators
addition = "abcd"
subtraction = "bcde"
multiplication = "dede"
division = "abab"
)
var worthOfAlphabets = map[byte]byte{
byte('a'): 1,
byte('b'): 2,
byte('c'): 3,
byte('d'): 4,
byte('e'): 5,
}
type Noun string
func (n Noun) pro... | challanges/rabex/main.go | 0.581778 | 0.405508 | main.go | starcoder |
package main
// https://en.wikipedia.org/wiki/Siamese_method
func siamese(sq Square, offset int) {
dim := sq.Dim()
if dim%2 == 0 {
panic("square is even")
}
sq.Clear()
i, j := 0, dim/2
for n := 1; n < dim*dim; n++ {
sq[i][j] = n + offset
i1, j1 := i, j
if i1 == 0 {
i1 = dim
}
i1--
j1++
if j1 ... | magic.go | 0.580233 | 0.448004 | magic.go | starcoder |
package common
import (
"bytes"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"github.com/libp2p/go-libp2p-peer"
"github.com/tinychain/tinychain/p2p/pb"
"math/big"
)
const (
HashLength = 32
AddressLength = 20
)
type Hash [HashLength]byte
// BigToHash sets byte representation of b to hash.
// If b is ... | common/types.go | 0.726523 | 0.420719 | types.go | starcoder |
package wkb
import (
"fmt"
"strings"
)
import "github.com/airmap/tegola"
/*
This purpose of this file is to house the wkt functions. These functions are
use to take a tagola.Geometry and convert it to a wkt string. It will, also,
contain functions to parse a wkt string into a wkb.Geometry.
*/
func wkt(geo tegola.... | wkb/wkt.go | 0.57332 | 0.422683 | wkt.go | starcoder |
package timeseries
import (
"time"
"github.com/grokify/mogo/time/timeutil"
)
// ToYear aggregates time values into months. `inflate` is used to add months with `0` values.
func (set *TimeSeriesSet) ToYear(inflate, popLast bool) (TimeSeriesSet, error) {
newTSS := TimeSeriesSet{
Name: set.Name,
Series: ma... | data/timeseries/time_series_set_mod.go | 0.677261 | 0.441252 | time_series_set_mod.go | starcoder |
package i6502
import "fmt"
/*
The Cpu only contains the AddressBus, through which 8-bit values can be read and written
at 16-bit addresses.
The Cpu has an 8-bit accumulator (A) and two 8-bit index registers (X,Y). There is a 16-bit
Program Counter (PC) and an 8-bit Stack Pointer (SP), pointing to addresses in 0x0100... | cpu.go | 0.650134 | 0.47457 | cpu.go | starcoder |
package cart
// NewMBC1 returns a new MBC1 memory controller.
func NewMBC1(data []byte) BankingController {
return &MBC1{
rom: data,
romBank: 1,
ram: make([]byte, 0x8000),
}
}
// MBC1 is a GameBoy cartridge that supports rom and ram banking.
type MBC1 struct {
rom []byte
romBank uint32
ram ... | pkg/cart/mbc1.go | 0.731634 | 0.472927 | mbc1.go | starcoder |
package agg
import (
"github.com/brimdata/zed"
)
// Schema constructs a fused type for types passed to Mixin. Values of any
// mixed-in type can be shaped to the fused type without loss of information.
type Schema struct {
zctx *zed.Context
typ zed.Type
}
func NewSchema(zctx *zed.Context) *Schema {
return &Sch... | runtime/expr/agg/schema.go | 0.606382 | 0.417271 | schema.go | starcoder |
package perfcounters
import (
"fmt"
"sync"
)
/*
AverageCount32
An average counter that shows how many items are processed, on average, during an operation. Counters of this type display a ratio of the items processed to the number of operations
completed. The ratio is calculated by comparing the number of items p... | perfcounters/averagecount32.go | 0.783492 | 0.645092 | averagecount32.go | starcoder |
package distance
import (
"log"
"math"
"sync"
seq "github.com/bkaraceylan/goophy/sequence"
)
//DistMat is a distance matrix structure
type DistMat struct {
Ids []string
Matrix [][]float64
Method string
Alignment *seq.DNAPool
}
//PDist calculates p-distance between two sequences
func PDist(dna1 s... | distance/distance.go | 0.690037 | 0.460046 | distance.go | starcoder |
package shape
import (
"fmt"
"math"
"strings"
"github.com/fogleman/gg"
"github.com/golang/freetype/raster"
)
// Polygon represents a polygonal shape with Order vertices.
type Polygon struct {
Order int
Convex bool
X, Y []float64
}
func NewPolygon(order int, convex bool) *Polygon {
p := &Polygon{}
p.Ord... | primitive/shape/polygon.go | 0.66356 | 0.413122 | polygon.go | starcoder |
package index
import (
"fmt"
"math"
)
type Datom struct {
entity int
attribute int
value Value
transaction int
added bool
}
var MinDatom = Datom{0, 0, MinValue, 0, false}
var MaxDatom = Datom{math.MaxInt64, math.MaxInt64, MaxValue, math.MaxInt64, true}
func NewDatom(e int, a int, v interfa... | index/datom.go | 0.723798 | 0.400134 | datom.go | starcoder |
package xcom
import (
"github.com/DomBlack/advent-of-code-2018/lib/vectors"
"strconv"
"strings"
)
const DefaultHealth = 200
// All adjacent cells in "reading order"
var AdjacentCells = [4]vectors.Vec2{
{0, -1},
{-1, 0},
{1, 0},
{0, 1},
}
type Unit struct {
IsElf bool // Is this unit an elf? If not the... | day-15/xcom/Unit.go | 0.763484 | 0.425963 | Unit.go | starcoder |
package restruct
import (
"encoding/binary"
"reflect"
)
/*
Unpack reads data from a byteslice into a structure.
Each structure field will be read sequentially based on a straightforward
interpretation of the type. For example, an int32 will be read as a 32-bit
signed integer, taking 4 bytes of memory. Structures a... | vendor/gopkg.in/restruct.v1/packing.go | 0.70416 | 0.519704 | packing.go | starcoder |
package gokalman
import (
"fmt"
"math"
"github.com/gonum/matrix/mat64"
)
// NewVanilla returns a new Vanilla KF. To get the next estimate, simply push to
// the MeasChan the next measurement and read from StateEst and MeasEst to get
// the next state estimate (\hat{x}_{k+1}^{+}) and next measurement estimate (\ha... | vanilla.go | 0.796411 | 0.586848 | vanilla.go | starcoder |
package tile
import (
"bufio"
"encoding/binary"
"io"
)
const lower = 0x0F
type reader interface {
io.Reader
}
// Decoder for Tiles
type Decoder struct {
r reader
Dimensions int // Dimensions is the size of the Tile(s) to make
buf []byte
t Tile
}
// DecodeOption just an alias
type D... | pkg/tile/reader.go | 0.67971 | 0.441191 | reader.go | starcoder |
package main
import (
"container/list"
)
/*
127 word ladder I
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words such that:
The first word in the sequence is beginWord.
The last word in the sequence is endWord.
Only one letter is different between e... | bfs/127-word-ladder.go | 0.612657 | 0.481149 | 127-word-ladder.go | starcoder |
// We change our concrete type System. Instead of using two concrete types Xenia and Pillar, we
// use 2 interface types Puller and Storer. Our concrete type System where we can have concrete
// behaviors is now based on the embedding of 2 interface types. It means that we can inject any
// data, not based on the comm... | go/design/decoupling_4.go | 0.63624 | 0.634331 | decoupling_4.go | starcoder |
package preflight
import (
"crypto/sha256"
"encoding/hex"
"log"
"math"
"math/big"
"strconv"
"github.com/airbnb/rudolph/pkg/clock"
"github.com/airbnb/rudolph/pkg/model/syncstate"
"github.com/pkg/errors"
)
// Select a MOD that will enable a proper dithering technique such as a proven cyclic group
// https://m... | internal/handlers/preflight/clean_sync.go | 0.682997 | 0.410579 | clean_sync.go | starcoder |
It includes a variety of resampling filters to handle interpolation in case that upsampling or downsampling is required.*/
package transform
import "math"
// ResampleFilter is used to evaluate sample points and interpolate between them.
// Support is the number of points required by the filter per 'side'.
// For exam... | transform/filters.go | 0.746971 | 0.867654 | filters.go | starcoder |
package rom
// seasonsChest constructs a MutableSlot from a treasure name and an address in
// bank $15, where the ID and sub-ID are two consecutive bytes at that address.
// This applies to almost all chests, and exclusively to chests.
func seasonsChest(treasure string, addr uint16,
group, room, mode, coords byte) *... | rom/seasons_slots.go | 0.681091 | 0.612078 | seasons_slots.go | starcoder |
package runners
// AutoResizeEnabledKey is the key of flag that enables pvc-autoresizer.
const AutoResizeEnabledKey = "resize.kubesphere.io/enabled"
// ResizeThresholdAnnotation is the key of resize threshold.
const ResizeThresholdAnnotation = "resize.kubesphere.io/threshold"
// ResizeInodesThresholdAnnotation is th... | vendor/github.com/kubesphere/pvc-autoresizer/runners/constants.go | 0.566978 | 0.415254 | constants.go | starcoder |
package deepequals
import (
"math"
"reflect"
"time"
"unsafe"
"github.com/hasSalil/customdeepequal"
ch "gopkg.in/check.v1"
)
// DeltaDeepEquals is the standard deltaDeepEqualsChecker instance
var DeltaDeepEquals = deltaDeepEqualsChecker(0.001, time.Second)
// marginOfErrorDeepEqualsChecker does deep equals bet... | deepequals/deltadeepequals.go | 0.78572 | 0.447219 | deltadeepequals.go | starcoder |
package main
import (
"fmt"
"github.com/NOX73/go-neural"
"github.com/NOX73/go-neural/learn"
"github.com/NOX73/go-neural/persist"
"github.com/cheggaaa/pb"
"math"
"math/rand"
"sort"
"time"
)
// Board consists of 4 x 4 cells, but we're training on a single slice which can
// represent either a horizontal or ver... | golang/nn1/main.go | 0.617974 | 0.432663 | main.go | starcoder |
package quadtree
import (
"SpreadSimulator/util"
)
//Quadtree constants
const (
NodeCapacity = 4
)
//Quadtree struct
type Quadtree struct {
boundary util.Rect
entries []util.PositionIndexPair
northWest *Quadtree
northEast *Quadtree
southWest *Quadtree
southEast *Quadtree
}
//NewQuadtree creates a new Quad... | quadtree/Quadtree.go | 0.765769 | 0.470007 | Quadtree.go | starcoder |
package imghash
import (
"image"
"image/color"
)
// grayscale turns the image into a grayscale image.
func grayscale(img image.Image) image.Image {
rect := img.Bounds()
gray := image.NewGray(rect)
var x, y int
for y = rect.Min.Y; y < rect.Max.Y; y++ {
for x = rect.Min.X; x < rect.Max.X; x++ {
gray.Set(x,... | vendor/github.com/jteeuwen/imghash/image.go | 0.823257 | 0.552962 | image.go | starcoder |
package main
import "math/rand"
type Universe struct {
height uint32
width uint32
cells []uint8
}
func NewUniverse(livePopulation int) *Universe {
width := uint32(64)
height := uint32(64)
cells := make([]uint8, width*height)
for i := range cells {
if rand.Intn(100) < livePopulation {
cells[i] = alive
... | universe.go | 0.590661 | 0.420064 | universe.go | starcoder |
package numf
import (
"fmt"
"math"
"strconv"
"strings"
"github.com/Akkurate/utils/str"
)
type Rounded struct {
Rawvalue float64 // raw value with given digits but no prefix
Prefix string // prefix string
Value float64 // rounded value with given digits and prefix
Response string // response string as... | numf/rounding.go | 0.769514 | 0.409811 | rounding.go | starcoder |
package utils
import (
"reflect"
"sort"
)
func AppendEmptySliceField(slice reflect.Value) reflect.Value {
newField := reflect.Zero(slice.Type().Elem())
return reflect.Append(slice, newField)
}
func SetSliceLengh(slice reflect.Value, length int) reflect.Value {
if length > slice.Len() {
for i := slice.Len(); i... | core/utils/slices.go | 0.750004 | 0.406744 | slices.go | starcoder |
package slice
// ContainsBool checks if a value exists in a bool slice
func ContainsBool(a []bool, x bool) bool {
if len(a) == 0 {
return false
}
for k := range a {
if a[k] == x {
return true
}
}
return false
}
// ContainsByte checks if a value exists in a byte slice
func ContainsByte(a []byte, x byte) ... | contains.go | 0.737158 | 0.529446 | contains.go | starcoder |
package vit
import (
"fmt"
"math"
"os"
"strings"
)
// position describes a specific position in a file
type Position struct {
FilePath string
Line int // line inside the file starting at 1
Column int // column inside the line starting at 1 (this is pointing to the rune, not the byte)
}
// String returns... | vit/position.go | 0.713132 | 0.522994 | position.go | starcoder |
package geometry
import (
"errors"
)
type TriangleZZ struct {
p1 *PointZZ
p2 *PointZZ
p3 *PointZZ
extent Extent
}
func CreateTriangleZZ(a *PointZZ, b *PointZZ, c *PointZZ) TriangleZZ {
var minx, miny, maxx, maxy float64
minx = 180
miny = 180
maxx = -180
maxy = -180
if maxx < a.X {
maxx = a.X... | geometry/trianglezz.go | 0.526586 | 0.457924 | trianglezz.go | starcoder |
package reflects
import (
"fmt"
"reflect"
)
func IsPtr(a interface{}) bool {
return reflect.TypeOf(a).Kind() == reflect.Ptr
}
func IsBool(a interface{}) bool {
return reflect.TypeOf(a).Kind() == reflect.Bool
}
func IsNumber(a interface{}) bool {
if a == nil {
return false
}
kind := reflect.TypeOf(a).Kind()... | reflects/type_support.go | 0.699768 | 0.641731 | type_support.go | starcoder |
package adjust
import (
"image"
"image/color"
"math"
"github.com/anthonynsimon/bild/math/f64"
"github.com/anthonynsimon/bild/util"
)
// Brightness returns a copy of the image with the adjusted brightness.
// Change is the normalized amount of change to be applied (range -1.0 to 1.0).
func Brightness(src image.I... | adjust/adjustment.go | 0.879794 | 0.589923 | adjustment.go | starcoder |
package server
import (
"math"
"github.com/armsnyder/othelgo/pkg/common"
)
// doAIPlayerMove takes a turn as the AI player.
func doAIPlayerMove(board common.Board, difficulty int) (common.Board, [2]int) {
aiState := &aiGameState{
board: board,
maximizingPlayer: 2,
turn: 2,
}
var de... | pkg/server/ai.go | 0.649912 | 0.558989 | ai.go | starcoder |
package binarytree
import (
"github.com/Thrimbda/dune/utils"
)
type RBNode struct {
BinNodePtr
color bool
}
const (
black = true
red = false
)
// black for black, red for red
func (node RBNode) SetColor(color bool) {
node.color = color
}
func (node RBNode) Color() bool {
return node.color
}
type RBTree ... | binarytree/red_black_tree.go | 0.563498 | 0.562056 | red_black_tree.go | starcoder |
package task
import (
"fmt"
"strings"
"github.com/spf13/cobra"
"github.com/PaddlePaddle/PaddleDTX/dai/blockchain"
pbCom "github.com/PaddlePaddle/PaddleDTX/dai/protos/common"
requestClient "github.com/PaddlePaddle/PaddleDTX/dai/requester/client"
"github.com/PaddlePaddle/PaddleDTX/dai/util/file"
"github.com/P... | dai/requester/cmd/cli/task/publish.go | 0.58948 | 0.404507 | publish.go | starcoder |
package bdd
import (
"fmt"
"strings"
"github.com/onsi/gomega"
"github.com/onsi/gomega/format"
)
// HasSubstr succeeds if actual is a string or stringer that contains the
// passed-in substring.
var HasSubstr = &matcher{
minArgs: 1,
maxArgs: 1,
name: "HasSubstr",
apply: func(actual interface{}, expected []... | matcher_str.go | 0.556882 | 0.486027 | matcher_str.go | starcoder |
package table
import (
"fmt"
"sort"
)
// SortDirection indicates whether a column should sort by ascending or descending.
type SortDirection int
const (
// SortDirectionAsc indicates the column should be in ascending order.
SortDirectionAsc SortDirection = iota
// SortDirectionDesc indicates the column should ... | table/sort.go | 0.76533 | 0.477554 | sort.go | starcoder |
package goldengine
import sf "github.com/manyminds/gosfml"
//Transformer : Wrapper arround sfml Transformer
type Transformer interface {
sf.Drawer
sf.Transformer
}
//TransformerPrefab : Info to create a Transformer from JSON Prefab
type TransformerPrefab struct {
Kind string
Arguments map[string]interface{}... | transform.go | 0.5769 | 0.401952 | transform.go | starcoder |
package fake
import (
"encoding/json"
"errors"
"fmt"
"math/rand"
)
// Random generates true/false values based on a predetermined percentage.
type Random struct {
id string
rnd *rand.Rand
pctGood float64
keepStats bool
Stats *RandomStats
v bool
}
// RandomStats keeps track of var... | random.go | 0.754915 | 0.408572 | random.go | starcoder |
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type ConsistOfMatcher struct {
Elements []interface{}
}
func (matcher *ConsistOfMatcher) Match(actual interface{}) (success bool, err error) {
if !isArrayOrSlice(actual) && !isMap(actual) {
return false, fmt.Errorf("ConsistOf matcher... | vendor/github.com/onsi/gomega/matchers/consist_of.go | 0.654784 | 0.415492 | consist_of.go | starcoder |
package dlframework
const (
dlframework_swagger = `{
"swagger": "2.0",
"info": {
"title": "MLModelScope",
"version": "0.2.18",
"description": "MLModelScope is a hardware/software agnostic platform to facilitate the evaluation, measurement, and introspection of ML models within AI pipelines. MLModelSco... | vendor/github.com/rai-project/dlframework/swagger.go | 0.826887 | 0.467332 | swagger.go | starcoder |
package prometheusextension
import (
"errors"
"time"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
)
// GaugeOps is the part of `prometheus.Gauge` that is relevant to
// instrumented code.
// This factoring should be in prometheus, analogous to the way
// it already... | staging/src/k8s.io/component-base/metrics/prometheusextension/timing_histogram.go | 0.808974 | 0.423577 | timing_histogram.go | starcoder |
package pckg
import (
"sort"
"github.com/gonum/floats"
"github.com/gonum/stat"
)
// Group is a slice of package stats.
type Group []*Stats
// SetEstimatedStmtCountFrom sets the estimated statement count based on the
// average number of statements in other packages in the group.
func (g *Group) SetEstimatedStmtC... | drygopher/coverage/pckg/group.go | 0.836655 | 0.432902 | group.go | starcoder |
package countrymaam
import (
"errors"
"math"
"math/rand"
"github.com/ar90n/countrymaam/collection"
"github.com/ar90n/countrymaam/number"
)
type CutPlane[T number.Number, U any] interface {
Evaluate(feature []T) bool
Distance(feature []T) float64
Construct(elements []treeElement[T, U], indice []int) (CutPlane... | cut_plane.go | 0.622 | 0.427815 | cut_plane.go | starcoder |
package geometry
import "math"
type Vector3D struct {
X float32
Y float32
Z float32
}
func NewVector(x float32, y float32, z float32) Vector3D {
return Vector3D{
X: x,
Y: y,
Z: z,
}
}
func NewVector_BetweenPoints(from Point3D, to Point3D) Vector3D {
return Vector3D{
X: to.X - from.X,
Y: to.Y - from.... | geometry/Vector3D.go | 0.885928 | 0.966851 | Vector3D.go | starcoder |
package math
var (
clipSpacePlanePoints = []Vector3{
Vec3(-1, -1, -1),
Vec3(1, -1, -1),
Vec3(1, 1, -1),
Vec3(-1, 1, -1),
Vec3(-1, -1, 1),
Vec3(1, -1, 1),
Vec3(1, 1, 1),
Vec3(-1, 1, 1)}
)
// A truncated rectangular pyramid.
// Used to define the viewable region and it's projection onto the screen.
typ... | frustum.go | 0.628863 | 0.587618 | frustum.go | starcoder |
package camt
import (
"encoding/xml"
"github.com/fairxio/finance-messaging/iso20022"
)
type Document02700104 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.027.001.04 Document"`
Message *ClaimNonReceiptV04 `xml:"ClmNonRct"`
}
func (d *Document02700104) AddMessage() *ClaimNonRecei... | iso20022/camt/ClaimNonReceiptV04.go | 0.732783 | 0.519643 | ClaimNonReceiptV04.go | starcoder |
package world
import (
"github.com/spkaeros/rscgo/pkg/game/entity"
"sync"
)
//Pathway Represents a path for a mobile entity to traverse across the virtual world.
type Pathway struct {
sync.RWMutex
StartX, StartY int
WaypointsX []int
WaypointsY []int
CurrentWaypoint int
}
//NewPathwayToCoords retur... | pkg/game/world/pathway.go | 0.832169 | 0.431464 | pathway.go | starcoder |
package wardleyToGo
import (
"errors"
"fmt"
"image"
"image/draw"
"strings"
"gonum.org/v1/gonum/graph/simple"
)
// a Map is a directed graph whose components knows their own position wrt to an anchor.
// The anchor is the point A of a rectangle as defined by
// A := image.Point{}
// image.Rectangle{A, Pt(100,... | map.go | 0.720172 | 0.488588 | map.go | starcoder |
package ssa
import (
"cmd_local/internal/src"
"math"
)
// A biasedSparseMap is a sparseMap for integers between J and K inclusive,
// where J might be somewhat larger than zero (and K-J is probably much smaller than J).
// (The motivating use case is the line numbers of statements for a single function.)
// Not al... | src/cmd_local/compile/internal/ssa/biasedsparsemap.go | 0.75183 | 0.478833 | biasedsparsemap.go | starcoder |
package tuple
import (
"fmt"
"golang.org/x/exp/constraints"
)
// T2 is a tuple type holding 2 generic values.
type T2[Ty1, Ty2 any] struct {
V1 Ty1
V2 Ty2
}
// Len returns the number of values held by the tuple.
func (t T2[Ty1, Ty2]) Len() int {
return 2
}
// Values returns the values held by the tuple.
func (... | tuple2.go | 0.848878 | 0.554832 | tuple2.go | starcoder |
package main
import (
"crypto/elliptic"
"math/big"
)
type Secp256k1CurveParams struct {
elliptic.CurveParams
}
var secp256k1 *Secp256k1CurveParams
func InitSecp256k1() {
secp256k1 = &Secp256k1CurveParams{}
secp256k1.Name = "Secp256k1"
secp256k1.BitSize = 256
p, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFFFF... | secp256k1.go | 0.672224 | 0.431345 | secp256k1.go | starcoder |
// Copied from Go's text/template/parse package and modified for yacc.
// Package yacc parses .y files.
package yacc
import (
"fmt"
"runtime"
)
// Tree is the representation of a single parsed file.
type Tree struct {
Name string // name of the template represented by the tree.
Productions []*ProductionN... | pkg/internal/rsg/yacc/parse.go | 0.703549 | 0.474022 | parse.go | starcoder |
package beacon
import (
"context"
"github.com/filecoin-project/go-state-types/abi"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
)
var log = logging.Logger("beacon")
type Response struct {
Entry types.Beac... | chain/beacon/beacon.go | 0.525856 | 0.47457 | beacon.go | starcoder |
package pain
import (
"encoding/xml"
"github.com/figassis/bankiso/iso20022"
)
type Document00100102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:pain.001.001.02 Document"`
Message *CustomerCreditTransferInitiationV02 `xml:"pain.001.001.02"`
}
func (d *Document001001... | generate/iso20022/pain/CustomerCreditTransferInitiationV02.go | 0.740174 | 0.428532 | CustomerCreditTransferInitiationV02.go | starcoder |
package command
import (
"encoding/json"
"fmt"
"os"
"strings"
"testing"
"time"
"github.com/infracloudio/botkube/pkg/config"
"github.com/infracloudio/botkube/pkg/execute"
"github.com/infracloudio/botkube/test/e2e/utils"
"github.com/nlopes/slack"
"github.com/stretchr/testify/assert"
"k8s.io/api/core/v1"
me... | test/e2e/command/botkube.go | 0.597021 | 0.535038 | botkube.go | starcoder |
package chunk
import (
"strconv"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/json"
)
// Row represents a row of data, can be used to access values.
type Row struct {
c *Chunk
idx int
}
// Chunk returns the Chunk which the row belongs to.
func (r Row) Chu... | util/chunk/row.go | 0.729038 | 0.581065 | row.go | starcoder |
package encoder
// Algorithm 3-way Radix Quicksort, d means the radix.
// Reference: https://algs4.cs.princeton.edu/51radix/Quick3string.java.html
func radixQsort(kvs []_MapPair, d, maxDepth int) {
for len(kvs) > 11 {
// To avoid the worst case of quickSort (time: O(n^2)), use introsort here.
// Re... | encoder/sort.go | 0.830147 | 0.53279 | sort.go | starcoder |
package main
import (
"math"
"time"
)
type Moon struct {
phase float64
illum float64
age float64
dist float64
angdia float64
sundist float64
sunangdia float64
pdata float64
quarters [8]float64
timespace float64
longitude ... | moon_phase.go | 0.734976 | 0.555857 | moon_phase.go | starcoder |
package heap
import "fmt"
type MinIntHeap struct {
capacity int
size int
items []int
}
//Operations to get Indexes of nodes
func (m *MinIntHeap) getLeftChildIndex(parentIndex int) int { return 2*parentIndex + 1 }
func (m *MinIntHeap) getRightChildIndex(parentIndex int) int { return 2*parentIndex + 2 }
fu... | src/heap/heap.go | 0.625896 | 0.420897 | heap.go | starcoder |
package model
import (
"fmt"
"github.com/hyperjumptech/grule-rule-engine/pkg"
"reflect"
)
// NewGoValueNode creates new instance of ValueNode backed by golang reflection
func NewGoValueNode(value reflect.Value, identifiedAs string) ValueNode {
return &GoValueNode{
parentNode: nil,
identifiedAs: identifiedA... | model/GoDataAccessLayer.go | 0.774711 | 0.525491 | GoDataAccessLayer.go | starcoder |
package matchers
import "bytes"
// Png matches a Portable Network Graphics file.
func Png(in []byte) bool {
return bytes.HasPrefix(in, []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A})
}
// Jpg matches a Joint Photographic Experts Group file.
func Jpg(in []byte) bool {
return bytes.HasPrefix(in, []byte{0xFF,... | vendor/github.com/gabriel-vasile/mimetype/internal/matchers/image.go | 0.676834 | 0.60133 | image.go | starcoder |
package rapid
import (
"fmt"
"math"
"math/bits"
"reflect"
)
const (
float32ExpBits = 8
float32SignifBits = 23
float64ExpBits = 11
float64SignifBits = 52
floatExpLabel = "floatexp"
floatSignifLabel = "floatsignif"
)
var (
float32Type = reflect.TypeOf(float32(0))
float64Type = reflect.TypeOf(fl... | vendor/pgregory.net/rapid/floats.go | 0.646125 | 0.453322 | floats.go | starcoder |
package jodaTime
/*
jodaTime provides a date formatter using the yoda syntax.
http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html
*/
import (
"strconv"
"time"
)
/*
Symbol Meaning Presentation Examples
------ ------- ------------ -------
... | format.go | 0.530236 | 0.440229 | format.go | starcoder |
package spec_util
import (
"bytes"
"encoding/base64"
protohash "github.com/akitasoftware/objecthash-proto"
"github.com/golang/protobuf/proto"
"github.com/pkg/errors"
pb "github.com/akitasoftware/akita-ir/go/api_spec"
)
// Given 2 DataTemplates that may contain references to Data in the common
// prefix, retur... | spec_util/equiv.go | 0.621311 | 0.412353 | equiv.go | starcoder |
This file contains the implementation of the ZKRP scheme proposed in the paper:
Efficient Protocols for Set Membership and Range Proofs
<NAME>, <NAME>, <NAME>
Asiacrypt 2008
*/
package ccs08
import (
"bytes"
"crypto/rand"
"errors"
"math"
"math/big"
"strconv"
"github.com/ing-bank/zkrp/cryp... | crypto/vendor/ing-bank/zkrp/ccs08/ccs08.go | 0.793426 | 0.584686 | ccs08.go | starcoder |
package parcom
import "strings"
// Char creates a parser to parse a character.
func (s *State) Char(r rune) Parser {
return func() (interface{}, error) {
if s.currentRune() != r {
return nil, newInvalidCharacterError(s)
}
s.readRune()
return r, nil
}
}
// NotChar creates a parser to parse a character ... | combinators.go | 0.803058 | 0.507446 | combinators.go | starcoder |
package npm
import (
"fmt"
"regexp"
"strings"
"golang.org/x/xerrors"
"github.com/aquasecurity/go-version/pkg/part"
"github.com/aquasecurity/go-version/pkg/semver"
)
const cvRegex string = `v?([0-9|x|X|\*]+)(\.[0-9|x|X|\*]+)?(\.[0-9|x|X|\*]+)?` +
`(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
`(\+([0-9A-Za-z\-]... | vendor/github.com/aquasecurity/go-npm-version/pkg/constraint.go | 0.65379 | 0.420897 | constraint.go | starcoder |
package primitive
import (
"fmt"
"strings"
"github.com/fogleman/gg"
"github.com/golang/freetype/raster"
)
type Quadratic struct {
Worker *Worker
X1, Y1 float64
X2, Y2 float64
X3, Y3 float64
Width float64
}
func NewRandomQuadratic(worker *Worker) *Quadratic {
rnd := worker.Rnd
x1 := rnd.Float64() * float... | primitive/quadratic.go | 0.511473 | 0.499695 | quadratic.go | starcoder |
package plaid
import (
"encoding/json"
)
// StandaloneInvestmentTransactionType Valid values for investment transaction types and subtypes. Note that transactions representing inflow of cash will appear as negative amounts, outflow of cash will appear as positive amounts.
type StandaloneInvestmentTransactionType st... | plaid/model_standalone_investment_transaction_type.go | 0.726231 | 0.407157 | model_standalone_investment_transaction_type.go | starcoder |
package slice
import (
"math/rand"
"time"
)
// ShuffleBool shuffles (in place) a bool slice
func ShuffleBool(a []bool) []bool {
if len(a) <= 1 {
return a
}
r := rand.New(rand.NewSource(time.Now().UnixNano()))
r.Shuffle(len(a), func(i, j int) {
a[i], a[j] = a[j], a[i]
})
return a
}
// ShuffleByte shuffl... | shuffle.go | 0.706494 | 0.536374 | shuffle.go | starcoder |
package client
import (
"github.com/summerwind/h2spec/config"
"github.com/summerwind/h2spec/spec"
)
func FrameFormat() *spec.ClientTestGroup {
tg := NewTestGroup("4.1", "Frame Format")
// Type: The 8-bit type of the frame. The frame type determines
// the format and semantics of the frame. Implementations MUST
... | vendor/github.com/summerwind/h2spec/client/4_1_frame_format.go | 0.59796 | 0.410845 | 4_1_frame_format.go | starcoder |
// Error handling has to be part of our code and usually it is bounded to logging.
// The main goal of logging is to debug.
// We only log things that are actionable. Only log the contexts that are allowed us to identify
// what is going on. Anything else ideally is noise and would be better suited up on the dashboar... | go/design/error_6.go | 0.690559 | 0.420183 | error_6.go | starcoder |
Joko Engineering Part
https://www.youtube.com/c/JokoEngineeringhelp
https://grabcad.com/library/freecad-practice-part-1
*/
//-----------------------------------------------------------------------------
package main
import (
"log"
"math"
"github.com/deadsy/sdfx/obj"
"github.com/deadsy/sdfx/render"
"github.co... | examples/joko/main.go | 0.632957 | 0.482917 | main.go | starcoder |
package main
import (
"fmt"
"reflect"
)
func isBool(in reflect.Type) bool {
return in.Kind() == reflect.Bool
}
func isInt(in reflect.Type) bool {
switch in.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.U... | hack/gen-tf-code/reflect.go | 0.572364 | 0.550668 | reflect.go | starcoder |
package hr
import "github.com/rannoch/cldr"
var currencies = []cldr.Currency{
{Currency: "ADP", DisplayName: "andorska pezeta", Symbol: "ADP"},
{Currency: "AED", DisplayName: "UAE dirham", Symbol: "AED"},
{Currency: "AFA", DisplayName: "afganistanski afgani (1927.–2002.)", Symbol: "AFA"},
{Currency: "AFN", Displa... | resources/locales/hr/currency.go | 0.511473 | 0.469338 | currency.go | starcoder |
package statefulset_spec
import (
apps "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
"reactive-tech.io/kubegres/controllers/ctx"
"reflect"
)
type VolumeSpecEnforcer struct {
kubegresContext ctx.KubegresContext
}
func CreateVolumeSpecEnforcer(kubegresContext ctx.KubegresContext) VolumeSpecEnforcer {
return Volum... | controllers/spec/enforcer/statefulset_spec/VolumeSpecEnforcer.go | 0.659624 | 0.409398 | VolumeSpecEnforcer.go | starcoder |
package models
import (
"strconv"
"github.com/cuttle-ai/brain/log"
"github.com/cuttle-ai/octopus/interpreter"
"github.com/google/uuid"
"github.com/jinzhu/gorm"
)
/*
* This file contains the model implementation of node's db model
*/
const (
//NodeMetadataPropWord is the metadata property of a node for word... | models/node.go | 0.617513 | 0.540257 | node.go | starcoder |
package incrdelaunay
import (
"math"
)
// CircumcircleGrid is a data structure that uses spatial partitioning to allowed fast operations
// involving multiple Triangle's and their Circumcircle's.
type CircumcircleGrid struct {
triangles [][][]uint16 // The grid used to store triangles
cols, rows ... | triangulation/incrdelaunay/grid.go | 0.79162 | 0.733583 | grid.go | starcoder |
package checkdigit
import "errors"
type (
// A Verifier is verifying to code by implemented algorithm or calculator.
Verifier interface {
Verify(code string) bool
}
// A Generator generates a check digit by implemented algorithm or calculator.
Generator interface {
Generate(seed string) (int, error)
}
// A... | checkdigit.go | 0.791418 | 0.440409 | checkdigit.go | starcoder |
package tabulate
import (
"encoding"
"fmt"
"reflect"
"sort"
"strings"
)
// Flags control how reflection tabulation operates on different
// values.
type Flags int
// Flag values for reflection tabulation.
const (
OmitEmpty Flags = 1 << iota
InheritHeaders
)
const nilLabel = "<nil>"
// Reflect tabulates the... | reflect.go | 0.588061 | 0.525491 | reflect.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.