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 parser
import (
"fmt"
"reflect"
)
type Kind int
const (
KindScalar Kind = iota
KindCustomScalar
KindObject
KindInterface
KindInterfaceDefinition
KindUnion
KindEnum
KindList
KindNullable
KindInvalidType
)
func (kind Kind) String() string {
typeMap := map[Kind]string{
KindScalar: "... | parser/type.go | 0.575349 | 0.479626 | type.go | starcoder |
package bytecode
import (
"encoding/binary"
"math"
"strings"
)
func Float32ToBinary(value float32) []byte {
bytes := make([]byte, 4)
bits := math.Float32bits(value)
binary.BigEndian.PutUint32(bytes, bits)
return bytes
}
func Float64ToBinary(value float64) []byte {
bytes := make([]byt... | converters.go | 0.788176 | 0.448064 | converters.go | starcoder |
package sandbox
import (
"encoding/json"
)
// SandboxBeamCounts struct for SandboxBeamCounts
type SandboxBeamCounts struct {
Count *int64 `json:"count,omitempty"`
}
// NewSandboxBeamCounts instantiates a new SandboxBeamCounts object
// This constructor will assign default values to properties that have it defined... | openapi/sandbox/model_sandbox_beam_counts.go | 0.757256 | 0.5425 | model_sandbox_beam_counts.go | starcoder |
package signals
import (
"fmt"
"strconv"
"time"
"github.com/google/edf"
)
// GetSignals return the signals from an EDF dataset.
func GetSignals(e *edf.Edf) ([]Signal, error) {
signals := make([]Signal, e.Header.NumSignals)
for i := range e.Header.Signals {
signal, err := newEdfSignal(e, i)
if err != nil {... | signals/parser.go | 0.632616 | 0.414188 | parser.go | starcoder |
package kv
import (
"bytes"
"encoding"
)
// KeyValue represents a recursive string key to arbitrary value container.
type KeyValue interface {
// Type returns the node's Type.
Type() Type
// SetType sets the node's Type and returns the receiver.
SetType(Type) KeyValue
// Key returns the node's Key.
Key() stri... | kv/kv.go | 0.821474 | 0.434701 | kv.go | starcoder |
package bloomfilter
import (
"fmt"
"strconv"
"strings"
)
// Encode handles encoding the bloom filter.
// An example string before encoding: "AAAABBCCCDZZZRTTT"
// An example string after encoding "A4B2C3D1Z3R1T3".
// Please note: This could essentially return an inoptimal compression, as if
// we have a string wit... | bloomfilter/rle.go | 0.688154 | 0.414069 | rle.go | starcoder |
package zarray
import (
"errors"
"fmt"
)
// Array Array insert, delete, random access according to the subscript operation, the data is interface type
type Array struct {
data []interface{}
size int
}
// ERR_ILLEGAL_INDEX illegal index
var ERR_ILLEGAL_INDEX = errors.New("illegal index")
// New array initializat... | zarray/array.go | 0.542621 | 0.447762 | array.go | starcoder |
package oopmix
import (
"errors"
)
// ThousandOp holds the data necessary to call ten HunredOps.
type ThousandOp struct {
InPort func(int)
op1 *HundredOp
op2 *HundredOp
op3 *HundredOp
op4 *HundredOp
op5 *HundredOp
op6 *HundredOp
op7 *HundredOp
op8 *HundredOp
op9 *HundredOp
op10 ... | oopmix/oopmix.go | 0.528533 | 0.611498 | oopmix.go | starcoder |
package sql
import (
"fmt"
"io"
"strings"
"github.com/dolthub/vitess/go/vt/proto/query"
"github.com/dolthub/go-mysql-server/sql/values"
)
// Row is a tuple of values.
type Row []interface{}
// NewRow creates a row from the given values.
func NewRow(values ...interface{}) Row {
row := make([]interface{}, len... | sql/row.go | 0.697197 | 0.552902 | row.go | starcoder |
package qesygo
import (
"math/rand"
"strconv"
"time"
)
/*
people := []Person{
{"Bob", 31},
{"John", 42},
{"Michael", 17},
{"Jenny", 26},
}
fmt.Println(people)
// There are two ways to sort a slice. First, one can define
// a set of methods for the slice type, as wit... | array.go | 0.611846 | 0.407392 | array.go | starcoder |
package main
import (
"aoc/utils"
"container/ring"
"fmt"
"io/ioutil"
"path/filepath"
"strconv"
)
type position struct {
x, y int
dir string
}
func createCardinalRing(start string) *ring.Ring {
entries := []string{"N", "E", "S", "W"}
ring := ring.New(len(entries))
for _, entry := range entries {
ring.V... | 12/main.go | 0.695648 | 0.410461 | main.go | starcoder |
package runtime
import (
"log"
"github.com/dcaiafa/go-expr/expr/types"
)
// Builder builds a Program using low level primitives.
type Builder struct {
labels []*Label
strings []string
stringMap map[string]int
values []interface{}
instr []Instruction
exprs []Expr
consts []Value
inputs ... | expr/runtime/builder.go | 0.741487 | 0.422326 | builder.go | starcoder |
package qtable
import (
"fmt"
"math"
"strconv"
)
// ActionType are cache possible actions
type ActionType int
const (
// ActionStore indicates to store an element in cache
ActionStore ActionType = iota
// ActionNotStore indicates to not store an element in cache
ActionNotStore
)
// QTable implements the Q-le... | qLearning_smartCache/qtable/qtable.go | 0.605333 | 0.474144 | qtable.go | starcoder |
package recurly
import ()
type SubscriptionChangeCreate struct {
// The timeframe parameter controls when the upgrade or downgrade takes place. The subscription change can occur now, when the subscription is next billed, or when the subscription term ends. Generally, if you're performing an upgrade, you will want t... | subscription_change_create.go | 0.747339 | 0.400222 | subscription_change_create.go | starcoder |
package tree
import "sort"
// Tree uniformly defines the data structure of the menu tree, you can also customize other fields to add
type Tree struct {
Title string `json:"title"`
Data interface{} `json:"data"`
Leaf bool `json:"leaf"`
Selected bool `json:"... | tree/index.go | 0.743541 | 0.426979 | index.go | starcoder |
package climbing
import (
"strconv"
"github.com/metalnem/parsing-algorithms/ast"
"github.com/metalnem/parsing-algorithms/parse"
"github.com/metalnem/parsing-algorithms/scan"
"github.com/pkg/errors"
)
type assoc int
const (
left assoc = iota
right
)
type opInfo struct {
prec int
assoc assoc
}
var binOps ... | parse/climbing/climbing.go | 0.650023 | 0.432363 | climbing.go | starcoder |
package cryptopals
import (
"crypto/rand"
"errors"
"fmt"
"math/big"
)
var minPkscs15Len = 11
var errInvalidPadding = errors.New("invalid padding")
type rsaPkcs15PaddingOracle struct {
key *privateKey
}
func gt(x, y *big.Int) bool {
return x.Cmp(y) == 1
}
func gte(x, y *big.Int) bool {
return x.Cmp(y) >= 0
}... | cryptopals/6_47_rsa_pkcs1_padding_oracle.go | 0.588416 | 0.42913 | 6_47_rsa_pkcs1_padding_oracle.go | starcoder |
package accounting
import (
"encoding/json"
)
// Tax Representation of a tax defined in the external accounting system.
type Tax struct {
// The code/ID of the tax in the external accounting system.
Code string `json:"code"`
// The tax percentage. For example, 8.05 represents a 8.05% tax rate.
Percentage float... | generated/accounting/model_tax.go | 0.827898 | 0.454775 | model_tax.go | starcoder |
package schwordler
import (
"fmt"
"github.com/brensch/battleword"
)
func (s *Store) GuessWord(prevGuessResults []battleword.GuessResult, defaultFirst string) (string, error) {
if len(prevGuessResults) == 0 {
return defaultFirst, nil
}
possibleAnswers, err := s.GetPossibleWords(prevGuessResults)
if err != n... | logic.go | 0.51562 | 0.44089 | logic.go | starcoder |
package main
import (
"fmt"
)
type depthSlice struct {
depth int
value int
}
func snailFishTreeToDepthSlice(node *snailfishNumber, depth int) (result []depthSlice) {
if node == nil {
return
}
result = append(result, snailFishTreeToDepthSlice(node.leftPair, depth+1)...)
if node.isLeaf() {
result = append... | day-18/first.go | 0.630344 | 0.499207 | first.go | starcoder |
package api
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderChannelPage() string {
return RenderHtml("Using server", Render(channelBody, nil))
}
const channelBody = `
<h2>Using channels</h2>
<p>Channel elements are FIFO queues for binary messages.
A channel physically lives on a parti... | gocircuit.org/api/channel.go | 0.704872 | 0.561756 | channel.go | starcoder |
package templates
import (
"math/rand"
"time"
"github.com/luisfcofv/indexter/models"
)
func GetEventTemplates(world models.World) []models.Event {
return []models.Event{
getFirstTemplate(world),
getSecondTemplate(world),
getThirdTemplate(world),
getFourthTemplate(world),
getFifthTemplate(world),
}
}
... | templates/events.go | 0.564819 | 0.406243 | events.go | starcoder |
package kate
import (
"crypto/rand"
"math/big"
)
var _modulus big.Int
func init() {
bigNum((*Big)(&_modulus), "52435875175126190479447740508185965837690552500527637822603658699938581184513")
initGlobals()
}
type Big big.Int
// BigNumFrom32 mutates the big num. The value v is little-endian 32-bytes.
func BigNu... | bignum_pure.go | 0.627723 | 0.457621 | bignum_pure.go | starcoder |
package lzw
import (
"errors"
"fmt"
"github.com/mjjs/gompressor/datastructure/dictionary"
"github.com/mjjs/gompressor/datastructure/vector"
)
// DictionarySize determines how large the dictionary used in compression can
// grow before needing to be reset. Larger values result in more efficient
// compression.
ty... | algorithm/lzw/lzw.go | 0.737064 | 0.484075 | lzw.go | starcoder |
package discovery
import "fmt"
type BinarySensor struct {
// A list of MQTT topics subscribed to receive availability (online/offline) updates. Must not be used together with `availability_topic`
// Default: <no value>
Availability []Availability `json:"availability,omitempty"`
// When `availability` is configu... | binarysensor.go | 0.846831 | 0.451508 | binarysensor.go | starcoder |
package game
import (
"github.com/gitfyu/mable/biome"
"github.com/gitfyu/mable/block"
"math"
)
const (
// chunkSectionBlocksSize is the number of bytes used for block data per chunkSection.
chunkSectionBlocksSize = 16 * 16 * 16 * 2
// chunkSectionsPerChunk is the maximum number of chunkSection instances within... | game/chunk.go | 0.642769 | 0.452596 | chunk.go | starcoder |
package main
import "fmt"
/**
"10100000100100110110010000010101111011011001101110111111111101000000101111001110001111100001101"
"110101001011101110001111100110001010100001101011101010000011011011001011101111001100000011011110011"
Given two binary strings, return their sum (also a binary string).
The input strings ... | main/addBinary.go | 0.587233 | 0.507263 | addBinary.go | starcoder |
package matrigo
import (
"fmt"
"strings"
)
// Mapper is the function type used for the Map function
type Mapper func(val float64, x int, y int) float64
// Folder is the function type used for the Fold function
type Folder func(accumulator, val float64, x int, y int) float64
// Matrix represents a matrix
type Matr... | matrix.go | 0.844473 | 0.719938 | matrix.go | starcoder |
package imports
import (
. "reflect"
"image/color"
)
// reflection: allow interpreted code to import "image/color"
func init() {
Packages["image/color"] = Package{
Binds: map[string]Value{
"Alpha16Model": ValueOf(&color.Alpha16Model).Elem(),
"AlphaModel": ValueOf(&color.AlphaModel).Elem(),
"Black": ValueOf... | vendor/github.com/cosmos72/gomacro/imports/image_color.go | 0.619356 | 0.441553 | image_color.go | starcoder |
package prime
import (
"math/rand"
"github.com/TheAlgorithms/Go/math/modular"
)
// formatNum accepts a number and returns the
// odd number d such that num = 2^s * d + 1
func formatNum(num int64) (d int64, s int64) {
d = num - 1
for num%2 == 0 {
d /= 2
s++
}
return
}
// isTrivial checks if num's primalit... | math/prime/millerrabinprimalitytest.go | 0.733261 | 0.633623 | millerrabinprimalitytest.go | starcoder |
package trie
import (
"github.com/caravan/go-immutable-trie/key"
"github.com/caravan/go-immutable-trie/nibble"
)
type (
// Trie maps a set of Keys to another set of Values
Trie[Key key.Keyable, Value any] interface {
trie() // marker
Read[Key, Value]
Split[Key, Value]
Write[Key, Value]
}
Read[Key key.K... | trie.go | 0.663015 | 0.49884 | trie.go | starcoder |
package shape
import (
"fmt"
"github.com/veandco/go-sdl2/sdl"
)
// Object describes default API of the scene object.
type Object interface {
Update()
Paint(r *sdl.Renderer) error
Restart()
Destroy()
}
// Triangle represent a triangle shape.
type Triangle struct {
ps [3]*sdl.Point
color *sdl.Color
}
// N... | types/shape/shape.go | 0.825273 | 0.449332 | shape.go | starcoder |
package gota
import (
"math"
)
// KER - Kaufman's Efficiency Ratio (http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:kaufman_s_adaptive_moving_average#efficiency_ratio_er)
type KER struct {
points []kerPoint
noise float64
count int
idx int // index of newest point
}
type kerPoint... | influxql/query/internal/gota/kama.go | 0.675229 | 0.481698 | kama.go | starcoder |
package iso20022
// Details of the closing of the securities financing transaction.
type SecuritiesFinancingTransactionDetails7 struct {
// Unambiguous identification of the underlying securities financing trade as assigned by the instructing party. The identification is common to all collateral pieces (one or many)... | SecuritiesFinancingTransactionDetails7.go | 0.82559 | 0.414958 | SecuritiesFinancingTransactionDetails7.go | starcoder |
package mathgl
import (
"math"
)
type Quatf struct {
W float32
V Vec3f
}
func QuatIdentf() Quatf {
return Quatf{1., Vec3f{0, 0, 0}}
}
func QuatRotatef(angle float32, axis Vec3f) Quatf {
angle = (float32(math.Pi) * angle) / 180.0
c, s := float32(math.Cos(float64(angle/2))), float32(math.Sin(float64(angle/2)))... | quatf.go | 0.831861 | 0.636833 | quatf.go | starcoder |
package tv
import (
"github.com/mmcloughlin/random"
"github.com/mmcloughlin/trunnel/ast"
"github.com/mmcloughlin/trunnel/fault"
"github.com/mmcloughlin/trunnel/inspect"
)
// Vector is a test vector.
type Vector struct {
Data []byte
Constraints Constraints
}
// NewVector builds a test vector with empty ... | tv/generator.go | 0.656438 | 0.412767 | generator.go | starcoder |
// Package codec provides support for interpreting byte slices as slices of
// other basic types such as runes, int64's or strings.
package codec
// Decoder represents the ability to decode a byte slice into a slice of
// some other data type.
type Decoder[T any] interface {
Decode(input []byte) []T
}
type options ... | algo/codec/codec.go | 0.808181 | 0.425068 | codec.go | starcoder |
package graph
import (
"math"
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/plt"
"github.com/cpmech/gosl/utl"
)
// Plotter draws graphs
type Plotter struct {
G *Graph // the graph
Parts []int32 // [nverts] partitions
VertsLabels map[int]st... | graph/plotting.go | 0.603815 | 0.466238 | plotting.go | starcoder |
package aggregaterange
import (
"errors"
"math"
"math/big"
"sync"
"github.com/incognitochain/incognito-chain/common"
"github.com/incognitochain/incognito-chain/privacy"
)
// pad returns number has format 2^k that it is the nearest number to num
func pad(num int) int {
if num == 1 || num == 2 {
return num
}... | privacy/zeroknowledge/aggregaterange/aggregaterangeutils.go | 0.531209 | 0.511107 | aggregaterangeutils.go | starcoder |
package coops
const (
// ResponseFormatJSON represents the JSON format.
ResponseFormatJSON ResponseFormat = iota
// ResponseFormatXML represents the XML format.
ResponseFormatXML
// ResponseFormatCSV represents the CSV format.
ResponseFormatCSV
)
// ResponseFormatStrings contains all the allowed string values... | src/coops/constants.go | 0.825449 | 0.411525 | constants.go | starcoder |
package challenge
import "strconv"
/* Problem:
Given an array a that contains only numbers in the range from 1 to a.length,
find the first duplicate number for which the second occurrence has the minimal index.
In other words, if there are more than 1 duplicated numbers,
return the number for which the second occurre... | arrays/arrays.go | 0.760651 | 0.6508 | arrays.go | starcoder |
package rawv2
import (
"bytes"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
)
// DataRAWv2 is a concrete implementation of AdvertisementData interface
// Data format is described here: https://docs.ruuvi.com/communication/bluetooth-advertisements/data-format-5-rawv2
type DataRAWv2 struct {
r... | internal/pkg/rawv2/dataformat.go | 0.818954 | 0.409545 | dataformat.go | starcoder |
package satellite
import (
"math"
"strconv"
"strings"
)
// Constants
const TWOPI float64 = math.Pi * 2.0
const DEG2RAD float64 = math.Pi / 180.0
const RAD2DEG float64 = 180.0 / math.Pi
const XPDOTP float64 = 1440.0 / (2.0 * math.Pi)
// LatLong holds latitude and Longitude in either degrees or radians
type LatLong... | helpers.go | 0.717309 | 0.531453 | helpers.go | starcoder |
package main
import (
"fmt"
"strings"
"github.com/fernomac/advent2019/lib"
)
type state int
func parse(in string) state {
lines := strings.Split(strings.TrimSpace(in), "\n")
if len(lines) != 5 {
panic(fmt.Sprint("too many lines of input:", lines))
}
ret := state(0)
for y, line := range lines {
if len(... | week4/day24/day24.go | 0.633183 | 0.504578 | day24.go | starcoder |
package curve
import (
"math"
"github.com/bradfitz/iter"
"github.com/shopspring/decimal"
)
var (
nCoins = decimal.NewFromInt(2)
one = decimal.NewFromInt(1)
two = decimal.NewFromInt(2)
precision int32 = 8
)
type Swap struct {
// Amplification coefficient
A decimal.Decimal
}
... | swap/curve/curve.go | 0.795658 | 0.490053 | curve.go | starcoder |
package testdata
const MultipleSitesResponse = `{
"data": [
{
"id": 1,
"url": "http://yoursite.tld",
"sort_url": "yoursite.tld",
"label": "your-site",
"team_id": 1,
"latest_run_date": "2019-09-16 07:29:02",
"summarized_check_result": "succeeded",
"created_at": "201... | testdata/sites.go | 0.546496 | 0.428473 | sites.go | starcoder |
package radialcells
func (rc *RadialCells) radiusQueryGridIntersection(centerX, centerY, radius float32) cellsheap {
const radiusEps = 1e-06
radius -= radiusEps
step := rc.step
r2 := radius * radius
visitadd := step / 2
rc.heapcache.reset()
vertstart := rc.anchor(centerX-radius, 1)
vertend := rc.anchor(cente... | algo.go | 0.686895 | 0.521106 | algo.go | starcoder |
package resolv
import (
"github.com/ClessLi/2d-game-engin/core/render"
"github.com/ClessLi/2d-game-engin/resource"
"github.com/go-gl/mathgl/mgl32"
)
// Rectangle represents a rectangle
type Rectangle struct {
MoveShape
W, H int32
}
// NewRectangle creates a new Rectangle and returns a pointer to it.
func NewRec... | core/resolv/rectangle.go | 0.847495 | 0.505188 | rectangle.go | starcoder |
package numerology
import (
"errors"
"strings"
)
// NameNumerology is used as a struct to store the name and configuration information that is required
// to calculate the numerological values of names.
type NameNumerology struct {
Name string
*NameOpts
*NameSearchOpts
mask *maskStruct
counts *map[int32... | numerology/calculateNames.go | 0.822759 | 0.433862 | calculateNames.go | starcoder |
package main
import (
RLBot "github.com/Trey2k/RLBotGo"
vector "github.com/xonmello/BotKoba/vector3"
// rotator "github.com/xonmello/BotKoba/rotator"
math "github.com/chewxy/math32"
)
type State int
const (
ATBA State = iota
Kickoff
DefensiveCorner
Air
OffensiveCorner
OnWall
)
type StateInfo struct {
cur... | states.go | 0.595728 | 0.454472 | states.go | starcoder |
package deregexp
// sequenceable parts are parts that are allowed in a sequence.
type sequenceable interface {
part
isSequenceable()
}
func (word) isSequenceable() {}
func (separator) isSequenceable() {}
// sequence is a simplified concatenation in which all concatenations and orParts have been resolved.
type... | sequences.go | 0.569613 | 0.433502 | sequences.go | starcoder |
package playbook
import (
"fmt"
)
// Inventory represents a set of variable to apply to the templates (see config).
// Namespace is the namespace dedicated files where to apply the variables contains into Values
// Values is map of string that contains whatever the user set in the default inventory from a playbook
t... | pkg/playbook/inventory.go | 0.801703 | 0.44746 | inventory.go | starcoder |
package nelson
import (
"container/list"
"fmt"
"math"
"github.com/gonum/stat"
)
type Rule struct {
Name string
Description string
f func(d *Data, v float64) bool
}
var Rule1 = Rule{
"Rule1",
"One point is more than 3 standard deviations from the mean.",
(*Data).rule1,
}
var Rule2 = Rule{
... | nelson/nelson.go | 0.757974 | 0.614452 | nelson.go | starcoder |
package greeso
/*
#include "matrix.h"
*/
import "C"
import (
"errors"
"fmt"
"strconv"
)
type (
vector []byte
row []uint
matrix []row
)
var (
ErrDimensionMismatch = errors.New("dimension mismatch")
ErrNonInvert = errors.New("matrix not invertible")
)
// NewMatrix initializes a zero matrix of m r... | matrix.go | 0.624064 | 0.45744 | matrix.go | starcoder |
// The board is made up of an m x n grid of cells, where each cell has an initial state: live (represented by a 1) or dead (represented by a 0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article):
// Any live cell with ... | 0289-game-of-life.go | 0.747892 | 0.69581 | 0289-game-of-life.go | starcoder |
package input
import (
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/util/tls"
)
//-------------------... | lib/input/amqp_0_9.go | 0.727685 | 0.670797 | amqp_0_9.go | starcoder |
package fakedata
import "strconv"
//DummyDataFaker is used in tests
type DummyDataFaker struct {
Dummy string
}
func NewDummyDataFaker(dummyString string) DummyDataFaker {
result := DummyDataFaker{Dummy: dummyString}
return result
}
func (ddf DummyDataFaker) Brand() string {
return ddf.Dummy
}
func (ddf DummyDa... | vars/fakedata/dummy_data_faker.go | 0.647018 | 0.723688 | dummy_data_faker.go | starcoder |
package arn
import (
"bytes"
"image"
"path"
"time"
"github.com/akyoto/imageserver"
)
const (
// AnimeImageLargeWidth is the minimum width in pixels of a large anime image.
AnimeImageLargeWidth = 250
// AnimeImageLargeHeight is the minimum height in pixels of a large anime image.
AnimeImageLargeHeight = 350... | arn/AnimeImage.go | 0.556641 | 0.437523 | AnimeImage.go | starcoder |
---------------------------------------------------------------------------
Copyright (c) 2013-2015 AT&T Intellectual Property
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
h... | clike/atoll.go | 0.675444 | 0.439687 | atoll.go | starcoder |
package constraint
import (
"github.com/g3n/engine/experimental/physics/equation"
"github.com/g3n/engine/math32"
)
// Hinge constraint.
// Think of it as a door hinge.
// It tries to keep the door in the correct place and with the correct orientation.
type Hinge struct {
PointToPoint
axisA *math32.Vector3 // R... | experimental/physics/constraint/hinge.go | 0.836755 | 0.5867 | hinge.go | starcoder |
package block
import (
"github.com/df-mc/dragonfly/dragonfly/item"
"github.com/df-mc/dragonfly/dragonfly/world"
"github.com/go-gl/mathgl/mgl64"
)
type (
// Quartz is a mineral block used only for decoration.
Quartz struct {
noNBT
solid
bassDrum
// Smooth specifies if the quartz block is smooth or not.
... | dragonfly/block/quartz_block.go | 0.710126 | 0.415017 | quartz_block.go | starcoder |
package ga
//The Populatio type
type Population struct {
Chromosomes []Chromosome
TotalFitness float64
}
//Create a new population of a given size
func NewPopulation(size int) Population {
var population Population
//Loop through the new population
for index := 0; index < size; index++ {
//Generate a new chr... | ga/population.go | 0.778481 | 0.600305 | population.go | starcoder |
// Package internal is for internal use.
package internal
import (
"fmt"
"reflect"
"runtime"
"testing"
)
const (
compareNotEqual int = iota - 2
compareLess
compareEqual
compareGreater
)
// Assert is a simple implementation of assertion, only for internal usage
type Assert struct {
T *testing.T
Case... | internal/assert.go | 0.70028 | 0.678507 | assert.go | starcoder |
package unit
// Pressure represents a SI derived unit of pressure (in pascal, Pa)
type Pressure Unit
// ...
const (
// SI derived
Yoctopascal = Pascal * 1e-24
Zeptopascal = Pascal * 1e-21
Attopascal = Pascal * 1e-18
Femtopascal = Pascal * 1e-15
Picopascal = Pascal ... | pressure.go | 0.762424 | 0.609321 | pressure.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// Int8RangeArrayFromIntArray2Slice returns a driver.Valuer that produces a PostgreSQL int8range[] from the given Go [][2]int.
func Int8RangeArrayFromIntArray2Slice(val [][2]int) driver.Valuer {
return int8RangeArrayFromIntArray2Slice{val: va... | pgsql/int8rangearr.go | 0.819929 | 0.503113 | int8rangearr.go | starcoder |
package parser
import (
"github.com/PuerkitoBio/goquery"
"github.com/Rhymond/go-money"
"github.com/ed-fx/go-soft4fx/internal/simulator"
"github.com/pkg/errors"
"strconv"
)
func parseClosedTransactions(sim *simulator.Simulator, row *goquery.Selection) (*goquery.Selection, error) {
if err := validateSectionHeader... | internal/simulator/parser/parser_closed_transactions.go | 0.584864 | 0.471223 | parser_closed_transactions.go | starcoder |
package types
import (
"encoding/json"
"fmt"
"strings"
"github.com/AccumulateNetwork/accumulate/internal/encoding"
)
// TransactionType is the type of a transaction.
type TransactionType uint64
// TxType is an alias for TransactionType
// Deprecated: use TransactionType
type TxType = TransactionType
const (
/... | types/transaction_types.go | 0.635109 | 0.441432 | transaction_types.go | starcoder |
package matrigo
import "math"
// Map applies f to every element of the matrix and returns the result.
func Map(m Matrix, f Mapper) Matrix {
n := New(m.Rows, m.Columns, nil)
for i := 0; i < m.Rows; i++ {
for j := 0; j < m.Columns; j++ {
val := m.Data[i][j]
n.Data[i][j] = f(val, i, j)
}
}
return n
}
//... | funcs.go | 0.912843 | 0.679209 | funcs.go | starcoder |
package graphql
// Errors is a linked list that contains Error values.
type Errors struct {
Data Error
next *Errors
pos int
}
// Add appends a Error to this linked list and returns this new head.
func (es *Errors) Add(data Error) *Errors {
var pos int
if es != nil {
pos = es.pos + 1
}
return &Errors{
Da... | graphql/lists.go | 0.7917 | 0.4133 | lists.go | starcoder |
package fractales
import (
"math"
"math/big"
"math/cmplx"
"github.com/Balise42/marzipango/params"
)
// JuliaContinuousValueLow returns the fractional number of iterations corresponding to a complex in the Julia set in low precision
func JuliaContinuousValueLow(z complex128, maxiter int) (float64, bool) {
c := -... | fractales/julia.go | 0.866472 | 0.509276 | julia.go | starcoder |
package edlib
import "github.com/xybydy/go-edlib/internal/utils"
// LevenshteinDistance calculate the distance between two string
// This algorithm allow insertions, deletions and substitutions to change one string to the second
// Compatible with non-ASCII characters
func LevenshteinDistance(str1, str2 string) int {... | levenshtein.go | 0.564819 | 0.438244 | levenshtein.go | starcoder |
package storetest
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/store"
)
func TestRoleStore(t *testing.T, ss store.Store, s SqlStore) {
t.Run("Save"... | store/storetest/role_store.go | 0.581065 | 0.488588 | role_store.go | starcoder |
package language
import (
"bytes"
"fmt"
"reflect"
"strconv"
)
// Eval runs the expression in the environment
func Eval(n Node, env *Environment) Object {
switch node := n.(type) {
case *ConditionalExpression:
return Eval(node.Expression, env)
case *UpdateExpression:
return Eval(node.Expression, env)
case ... | interpreter/language/evaluator.go | 0.728169 | 0.441492 | evaluator.go | starcoder |
package main
import (
"bytes"
"fmt"
"github.com/ecc1/crossword"
)
const (
Across = crossword.Across
Down = crossword.Down
blackSquare = '.'
emptySquare = ' '
wrongSquare = '?'
)
var (
cells crossword.Grid
homePos crossword.Position
endPos crossword.Position
cur crossword.Po... | cmd/playpuz/game.go | 0.503906 | 0.414543 | game.go | starcoder |
package avl
import (
"golang.org/x/exp/constraints"
)
// Comparator is to compare keys
type Comparator[Key any] func(a, b Key) int
// Tree : AVL tree
type Tree[Key any, Value any] struct {
root *Node[Key, Value]
comparator Comparator[Key]
}
// NewTree creates a new AVL tree
func NewTree[Key any, Value any](comp... | tree.go | 0.74826 | 0.439988 | tree.go | starcoder |
package mocks
import "github.com/control-center/serviced/dfs"
import "github.com/stretchr/testify/mock"
import "io"
import "time"
import "github.com/control-center/serviced/domain/service"
type DFS struct {
mock.Mock
}
// Lock provides a mock function with given fields: opName
func (_m *DFS) Lock(opName string) {... | dfs/mocks/DFS.go | 0.679817 | 0.409811 | DFS.go | starcoder |
package block
import (
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/block/model"
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/world"
"github.com/go-gl/mathgl/mgl64"
)
// WoodSlab is a half block that allows entities to walk up blocks without jum... | server/block/wood_slab.go | 0.642657 | 0.409752 | wood_slab.go | starcoder |
package main
import "fmt"
// Stack is the Abstract Data type following FIFO (First In First Out) principle which has certain functionalities like-
// (a) push- Insert new data at one end
// (b) pop- Remove (and return) data from the end insertion has happened
// (c) peek- Return the data from the end insertion has ha... | Arpit Mishra/Go practice/stack.go | 0.615088 | 0.536252 | stack.go | starcoder |
package missing_identity_propagation
import (
"github.com/damianmcgrath/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-identity-propagation",
Title: "Missing Identity Propagation",
Description: "Technical assets (especially multi-tenant systems), which usual... | risks/built-in/missing-identity-propagation/missing-identity-propagation-rule.go | 0.656328 | 0.465205 | missing-identity-propagation-rule.go | starcoder |
// +build ignore
package main
import (
"math"
"math/cmplx"
"github.com/cpmech/gosl/fun"
"github.com/cpmech/gosl/plt"
"github.com/cpmech/gosl/rnd"
)
func main() {
// fix seed
rnd.Init(1111)
// generate data
π := math.Pi // 3.14159265359...
Fs := 1000.0 // Sampling frequency
T :=... | examples/fun_fft01.go | 0.5144 | 0.490663 | fun_fft01.go | starcoder |
package parser
// IfBlock is the equivalent of [IFB stmt.Condition] stmt.Body [ELSE] stmt.Else [ENDIF], the stmt.Else may be nil
type IfBlock struct {
*BasicStatement
Condition Statement
Body []Statement
Else []Statement
}
// Type gets the type of an IFB statement (NULL)
func (i *IfBlock) Type() DataTy... | old/parser/blocks.go | 0.590071 | 0.499878 | blocks.go | starcoder |
package speg
import (
"github.com/SimplePEG/Go/rd"
)
func peg() rd.ParserFunc {
return rd.Action("peg", rd.Sequence([]rd.ParserFunc{
rd.ZeroOrMore(noop()),
parsingHeader(),
rd.OneOrMore(noop()),
parsingBody(),
rd.EndOfFile(),
}))
}
func parsingHeader() rd.ParserFunc {
return rd.Action("noop", rd.Sequen... | speg/speg_parser.go | 0.552057 | 0.462291 | speg_parser.go | starcoder |
// Package scene encodes and decodes graphics commands in the format used by the
// compute renderer.
package scene
import (
"fmt"
"image/color"
"math"
"unsafe"
"gioui.org/f32"
)
type Op uint32
type Command [sceneElemSize / 4]uint32
// GPU commands from scene.h
const (
OpNop Op = iota
OpLine
OpQuad
OpCub... | internal/scene/scene.go | 0.674908 | 0.493714 | scene.go | starcoder |
package pattern
import (
"image"
"image/color"
"math"
"github.com/c0nscience/yastgt/pkg/parse/svg"
"github.com/c0nscience/yastgt/pkg/unit"
)
var gap = 10.0
var dpi = 96.0
var degrees = 45.0
var clr = color.Color(color.NRGBA{R: 255})
var threshold = 4.0
func SetGap(f float64) {
gap = f
}
func SetDpi(f float64... | pkg/pattern/fill.go | 0.680666 | 0.422743 | fill.go | starcoder |
package adaptive
import (
"errors"
"fmt"
mc "github.com/kwesiRutledge/ModelChecking"
)
type TransitionSystem struct {
X []TransitionSystemState
U []string
Transition map[TransitionSystemState]map[string][]TransitionSystemState
Pi []mc.AtomicProposition
O map[TransitionSyste... | adaptive/transitionsystem.go | 0.651687 | 0.401512 | transitionsystem.go | starcoder |
package tetra3d
import (
"strconv"
"strings"
"github.com/kvartborg/vector"
)
// INode represents an object that exists in 3D space and can be positioned relative to an origin point.
// By default, this origin point is {0, 0, 0} (or world origin), but Nodes can be parented
// to other Nodes to change this origin (... | node.go | 0.87728 | 0.562898 | node.go | starcoder |
package bayes
import (
. "code.google.com/p/probab/dst"
"fmt"
"math"
)
// PMF of the posterior distribution of unknown Normal μ, with KNOWN σ, and discrete prior, for single observation.
// Bolstad 2007 (2e): 200-201.
func NormMuSinglePMFDPri(y, σ float64, μ []float64, μPri []float64) (post []float64) {
// y si... | bayes/normal_mu.go | 0.701611 | 0.566438 | normal_mu.go | starcoder |
package rle
import "io"
// Compress compresses the given byte array into the given writer.
// The optional reference array is used as a delta basis. If provided, bytes will be skipped
// where the data equals the reference.
func Compress(writer io.Writer, data []byte, reference []byte) error {
end := len(data)
refL... | ss1/serial/rle/Compress.go | 0.566498 | 0.556159 | Compress.go | starcoder |
package heraldry
import (
"math/rand"
"github.com/ironarachne/random"
)
// Tincture is a tincture
type Tincture struct {
Type string
Name string
Hexcode string
}
// Charge is a charge
type Charge struct {
Identifier string
Name string
Noun string
NounPlural string
Descriptor string
Arti... | heraldry.go | 0.573917 | 0.408218 | heraldry.go | starcoder |
package rotateflip
import (
"image"
"image/color"
"github.com/ncruces/go-image/imageutil"
)
// Operation specifies a clockwise rotation and flip operation to apply to an image.
type Operation int
const (
None Operation = iota
Rotate90
Rotate180
Rotate270
FlipX
Transpose
FlipY
Transverse
FlipXY = Rotat... | rotateflip/rotateflip.go | 0.773644 | 0.41947 | rotateflip.go | starcoder |
package geom
import (
"fmt"
"math"
"github.com/peterstace/simplefeatures/rtree"
)
// XY represents a pair of X and Y coordinates. This can either represent a
// location on the XY plane, or a 2D vector in the real vector space.
type XY struct {
X, Y float64
}
// validate checks if the XY value contains NaN, -in... | geom/xy.go | 0.901877 | 0.653521 | xy.go | starcoder |
package main
import (
"context"
"fmt"
"strconv"
"strings"
"github.com/pkg/errors"
)
// performanceExpectations is a map from workload to a map from core count to
// expected throughput below which we consider the test to have failed.
var performanceExpectations = map[string]map[int]float64{
// The below numbe... | pkg/cmd/roachtest/ycsb.go | 0.624179 | 0.46557 | ycsb.go | starcoder |
package common
import (
"fmt"
"sort"
"go.opentelemetry.io/collector/model/pdata"
)
func SortResourceMetrics(rm pdata.ResourceMetricsSlice) {
for i := 0; i < rm.Len(); i++ {
r := rm.At(i)
for j := 0; j < r.InstrumentationLibraryMetrics().Len(); j++ {
il := r.InstrumentationLibraryMetrics().At(j)
for k :... | common/metrics_sort.go | 0.559531 | 0.487978 | metrics_sort.go | starcoder |
package packed
import (
"github.com/gzg1984/golucene/core/util"
)
// Direct wrapping of 32-bits values to a backing array.
type Direct32 struct {
*MutableImpl
values []int32
}
func newDirect32(valueCount int) *Direct32 {
ans := &Direct32{
values: make([]int32, valueCount),
}
ans.MutableImpl = newM... | core/util/packed/direct32.go | 0.523177 | 0.497986 | direct32.go | starcoder |
package toml
import (
"fmt"
"reflect"
"time"
)
// supported values:
// string, bool, int64, uint64, float64, time.Time, int, int8, int16, int32, uint, uint8, uint16, uint32, float32
var kindToTypeMapping = map[reflect.Kind]reflect.Type{
reflect.Bool: reflect.TypeOf(true),
reflect.String: reflect.TypeOf(""),... | vendor/github.com/pelletier/go-toml/tomltree_create.go | 0.59408 | 0.424651 | tomltree_create.go | starcoder |
package mlmetrics
import (
"math"
"sync"
)
// ConfusionMatrix can be used to visualize the performance of a binary
// classifier.
type ConfusionMatrix struct {
mat resizableMatrix
mu sync.RWMutex
}
// NewConfusionMatrix inits a new ConfusionMatrix.
func NewConfusionMatrix() *ConfusionMatrix {
return new(Confus... | confusion.go | 0.844088 | 0.583767 | confusion.go | starcoder |
package main
import (
"flag"
"fmt"
"log"
"math"
"os"
"strconv"
)
func main() {
flag.Parse()
if flag.NArg() != 3 {
usage()
}
val, _ := strconv.ParseFloat(flag.Arg(0), 64)
from := flag.Arg(1)
to := flag.Arg(2)
val, err := conv(val, from, to)
if err != nil {
log.Fatal(err)
}
fmt.Println(val)
}
func... | gis/units.go | 0.670608 | 0.400222 | units.go | starcoder |
package tilearea
import (
"github.com/kasworld/goguelike-single/enum/tile_flag"
"github.com/kasworld/goguelike-single/game/terrain/corridor"
"github.com/kasworld/goguelike-single/game/terrain/room"
"github.com/kasworld/goguelike-single/lib/boolmatrix"
"github.com/kasworld/walk2d"
)
func (ta TileArea) DrawRooms(... | game/tilearea/tilearea_draw.go | 0.502197 | 0.44065 | tilearea_draw.go | starcoder |
package trea
import (
"encoding/xml"
"github.com/figassis/bankiso/iso20022"
)
type Document00100102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:trea.001.001.02 Document"`
Message *CreateNonDeliverableForwardOpeningV02 `xml:"CretNDFOpngV02"`
}
func (d *Document001... | generate/iso20022/trea/CreateNonDeliverableForwardOpeningV02.go | 0.778228 | 0.423696 | CreateNonDeliverableForwardOpeningV02.go | starcoder |
package bn256
import (
"crypto/cipher"
"crypto/sha256"
"crypto/subtle"
"errors"
"io"
"math/big"
"go.dedis.ch/kyber/v3"
"go.dedis.ch/kyber/v3/group/mod"
)
type pointG1 struct {
g *curvePoint
group kyber.Group
}
func newPointG1(group kyber.Group) *pointG1 {
p := &pointG1{g: &curvePoint{}, group: group}... | vendor/go.dedis.ch/kyber/v3/pairing/bn256/point.go | 0.691185 | 0.481941 | point.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.