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 speculative
import (
"bufio"
"fmt"
"os"
"reflect"
"strings"
"log"
sp "github.com/sensssz/spinner"
)
func min(num1 int, num2 int) int {
if num1 <= num2 {
return num1
}
return num2
}
func max(num1 int, num2 int) int {
if num1 >= num2 {
return num1
}
return num2
}
func nonNegative(num int) i... | prediction.go | 0.682679 | 0.495606 | prediction.go | starcoder |
package plain
import (
"bytes"
"image"
"image/draw"
"image/gif"
"image/jpeg"
"image/png"
"io"
"github.com/kpacha/treemap"
)
// NewPNG returns the image of the received tree encoded as a PNG
func NewPNG(tree *treemap.Block, width, height float64) (io.WriterTo, error) {
return newEncoder(tree, width, height, ... | plain/render.go | 0.848062 | 0.4016 | render.go | starcoder |
package tuple
import (
"math"
"github.com/anolson/rtc/util"
)
const (
pointType = float64(1)
vectorType = float64(0)
)
// Tuple represents a position
type Tuple struct {
X float64
Y float64
Z float64
W float64
}
// New returns a new a Tuple object
func New(x, y, z, w float64) *Tuple {
return &Tuple{
X:... | tuple/tuple.go | 0.885186 | 0.637327 | tuple.go | starcoder |
package basic
import "strings"
// FilterMapIONumber is template to generate itself for different combination of data type.
func FilterMapIONumber() string {
return `
func TestFilterMap<FINPUT_TYPE><FOUTPUT_TYPE>(t *testing.T) {
// Test : some logic
expectedList := []<OUTPUT_TYPE>{3, 4}
newList := FilterMap<FINPUT... | internal/template/basic/filtermapiotest.go | 0.575707 | 0.415136 | filtermapiotest.go | starcoder |
package leetcode
/**
* @title 设计循环队列
*
* 设计你的循环队列实现。 循环队列是一种线性数据结构,其操作表现基于 FIFO(先进先出)原则并且队尾被连接在队首之后以形成一个循环。它也被称为“环形缓冲器”。
* 循环队列的一个好处是我们可以利用这个队列之前用过的空间。在一个普通队列里,一旦一个队列满了,我们就不能插入下一个元素,即使在队列前面仍有空间。
* 但是使用循环队列,我们能使用这些空间去存储新的值。
*
* 你的实现应该支持如下操作:
* MyCircularQueue(k): 构造器,设置队列长度为 k 。
* Front: 从队首获取元素。如果队列为空,返回 -1 。... | src/0622.design-circular-queue.go | 0.620966 | 0.681952 | 0622.design-circular-queue.go | starcoder |
package world
import "math"
// Globe is centered at (0,0) with radius 1.0
const InRadian = (math.Pi / 180.0)
const InDegree = (180.0 / math.Pi)
// ------------------------------------------------------------------------
// Longitude/Latitude => X/Y/Z
// -------------------------------------------------------------... | world/geography.go | 0.641085 | 0.580501 | geography.go | starcoder |
package iso20022
// Provides the details of each individual overnight index swap transaction.
type OvernightIndexSwapTransaction3 struct {
// Defines the status of the reported transaction, that is details on whether the transaction is a new transaction, an amendment of a previously reported transaction, a cancellat... | OvernightIndexSwapTransaction3.go | 0.807688 | 0.612078 | OvernightIndexSwapTransaction3.go | starcoder |
package ast
// exp ::= `nil` | `false` | `true` | Numeral | LiteralString | `...` | functiondef |
// prefixexp | tableconstructor | exp binop exp | unop exp
// Exp is expression interface
type Exp interface{}
// NilExp is `nil` expression
type NilExp struct {
Line int
}
// TrueExp is `true` expression
ty... | compiler/ast/exp.go | 0.652906 | 0.533944 | exp.go | starcoder |
package trie
import (
"context"
"encoding/hex"
"github.com/pkg/errors"
)
// TwoLayerTrie is a trie data structure with two layers
type TwoLayerTrie struct {
layerOne Trie
layerTwo map[string]Trie
kvStore KVStore
rootKey string
}
// NewTwoLayerTrie creates a two layer trie
func NewTwoLayerTrie(dbForTrie KV... | db/trie/twolayertrie.go | 0.771672 | 0.475179 | twolayertrie.go | starcoder |
package rui
import (
"strings"
"unicode"
)
// DataValue interface of a data node value
type DataValue interface {
IsObject() bool
Object() DataObject
Value() string
}
// DataObject interface of a data object
type DataObject interface {
DataValue
Tag() string
PropertyCount() int
Property(index int) DataNode
... | data.go | 0.531939 | 0.524577 | data.go | starcoder |
package taskmaster
import (
"time"
"github.com/go-ole/go-ole"
"github.com/rickb777/date/period"
)
// Day is a day of the week.
type Day int
const (
Sunday Day = 0x01
Monday Day = 0x02
Tuesday Day = 0x04
Wednesday Day = 0x08
Thursday Day = 0x10
Friday Day = 0x20
Saturday Day = 0x40
)
// DayI... | types.go | 0.594434 | 0.470311 | types.go | starcoder |
package matrix
import (
"bytes"
"fmt"
)
var weight [4]uint64 = [4]uint64{
0x6996966996696996, 0x9669699669969669,
0x9669699669969669, 0x6996966996696996,
}
// A binary row / vector in GF(2)^n.
type Row []byte
// NewRow returns an empty n-component row.
func NewRow(n int) Row {
return Row(make([]byte, rowsToCol... | matrix/row.go | 0.722723 | 0.449211 | row.go | starcoder |
package polo
import (
"fmt"
"math/rand"
"strings"
"github.com/emicklei/dot"
)
// State is a string.
type State = string
// Chain is a Sequence of random states -> probabilities.
type Chain struct {
StateTransitions map[State]Probabilities
Order int
}
// Probabilities gives the probabilities of goi... | polo/polo.go | 0.771241 | 0.478773 | polo.go | starcoder |
package main
import (
"errors"
"fmt"
"os"
)
const (
rows, columns = 9, 9
empty = 0
)
// Cell is a square on the Sudoku grid.
type Cell struct {
digit int8
fixed bool
}
// Grid is a Sudoku grid.
type Grid [rows][columns]Cell
// Errors that could occur.
var (
ErrBounds = errors.New("out of bounds... | solutions/capstone29/sudoku/sudoku.go | 0.572006 | 0.437824 | sudoku.go | starcoder |
//go:build go1.18
// +build go1.18
/*
Command govulncheck reports known vulnerabilities that affect Go code. It uses
static analysis or a binary's symbol table to narrow down reports to only those
that potentially affect the application. For more information about the API
behind govulncheck, see https://go.dev/securi... | cmd/govulncheck/doc.go | 0.544801 | 0.568296 | doc.go | starcoder |
package output
import (
"fmt"
"github.com/Jeffail/benthos/v3/internal/component/output"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/interop"
"github.com/Jeffail/benthos/v3/lib/broker"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
... | lib/output/fallback.go | 0.687945 | 0.746162 | fallback.go | starcoder |
package checkup
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"strings"
"time"
"github.com/sourcegraph/checkup/utils"
)
/*
```
Summary: Get node information.
https://docs.binance.org/api-reference/node-rpc.html#node-rpc
URL for mainnet: http://dataseed1.binance.org:80/status... | bncchecker.go | 0.686055 | 0.440409 | bncchecker.go | starcoder |
package money
import (
"errors"
)
// Amount is a datastructure that stores the amount being used for calculations.
type Amount struct {
val int64
}
// Money represents monetary value information, stores
// currency and amount value.
type Money struct {
amount *Amount
currency *Currency
}
// New creates and re... | money.go | 0.918535 | 0.640762 | money.go | starcoder |
package usecase
import (
"context"
"strings"
"github.com/orvosi/api/entity"
)
// CreateMedicalRecord defines the business logic
// to create a medical record.
type CreateMedicalRecord interface {
// Create creates a new medical record.
Create(ctx context.Context, record *entity.MedicalRecord) *entity.Error
}
/... | usecase/medical_record_creator.go | 0.609757 | 0.473536 | medical_record_creator.go | starcoder |
package main
import (
"net/http"
"time"
chart "github.com/regorov/go-chart"
)
func drawChart(res http.ResponseWriter, req *http.Request) {
/*
This is an example of using the `TimeSeries` to automatically coerce time.Time values into a continuous xrange.
Note: chart.TimeSeries implements `ValueFormatterPr... | examples/timeseries/main.go | 0.705684 | 0.430147 | main.go | starcoder |
package geojson
import "github.com/tidwall/tile38/geojson/geohash"
// MultiPolygon is a geojson object with the type "MultiPolygon"
type MultiPolygon struct {
Coordinates [][][]Position
BBox *BBox
}
func fillMultiPolygon(coordinates [][][]Position, bbox *BBox, err error) (MultiPolygon, error) {
if err == n... | vendor/github.com/tidwall/tile38/geojson/multipolygon.go | 0.810854 | 0.584953 | multipolygon.go | starcoder |
package main
import "math"
func simpleGreyscale(iterations, iterationCap int, z, c complex) (R, G, B, A float64) {
col := float64(255*iterations) / float64(iterationCap)
return col, col, col, 255
}
func simpleGreyscaleShip(iterations, iterationCap int, z complex) (R, G, B, A float64) {
col := float64(255*iteratio... | ColourFunctions.go | 0.764628 | 0.511412 | ColourFunctions.go | starcoder |
package memo
import (
plannercore "github.com/pingcap/tidb/planner/core"
)
// Operand is the node of a pattern tree, it represents a logical expression operator.
// Different from logical plan operator which holds the full information about an expression
// operator, Operand only stores the type information.
// An ... | planner/memo/pattern.go | 0.698329 | 0.675576 | pattern.go | starcoder |
package processors
import (
"regexp"
"github.com/golangci/golangci-lint/pkg/result"
)
type replacePattern struct {
re string
repl string
}
type replaceRegexp struct {
re *regexp.Regexp
repl string
}
var replacePatterns = []replacePattern{
// unparam
{`^(\S+) - (\S+) is unused$`, "`${1}` - `${2}` is unu... | vendor/github.com/golangci/golangci-lint/pkg/result/processors/identifier_marker.go | 0.659953 | 0.634798 | identifier_marker.go | starcoder |
package trie
import (
"fmt"
"sort"
"go.skia.org/infra/go/util"
)
// Trie is a struct used for efficient searching on sets of strings.
type Trie struct {
root *trieNode
}
// New returns a Trie instance.
func New() *Trie {
return &Trie{
root: newTrieNode(),
}
}
func sorted(s []string) []string {
cpy := make... | go/trie/trie.go | 0.650911 | 0.49939 | trie.go | starcoder |
package utils
import (
"reflect"
"strconv"
"strings"
)
const (
StringType = "string"
NumberType = "number"
BoolType = "bool"
Unknown = "unknown"
)
func TypeOf(obj interface{}) string {
if obj == nil {
return ""
}
typ := reflect.TypeOf(obj)
return typeOf(typ)
}
func typeOf(typ reflect.Type) strin... | modules/monitor/utils/convert.go | 0.519034 | 0.437884 | convert.go | starcoder |
package iso20022
// Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another.
type DeliveringPartiesAndAccount8 struct {
// Party that se... | DeliveringPartiesAndAccount8.go | 0.624523 | 0.462898 | DeliveringPartiesAndAccount8.go | starcoder |
package funcs
// Func is general function, f:T -> R.
type Func[T, R any] func(T) R
// Predict is a function (f:T -> bool) predicts given value is true or false.
type Predict[T any] func(T) bool
// Unit is a function (f:empty -> R) mapping to R from empty set.
type Unit[R any] func() R
// Condition is a function (f... | funcs/funcs.go | 0.681091 | 0.826677 | funcs.go | starcoder |
package version220
// https://raw.githubusercontent.com/devfile/api/main/schemas/latest/devfile.json
const JsonSchema220 = `{
"description": "Devfile describes the structure of a cloud-native devworkspace and development environment.",
"type": "object",
"title": "Devfile schema - Version 2.2.0-alpha",
"require... | pkg/devfile/parser/data/v2/2.2.0/devfileJsonSchema220.go | 0.836721 | 0.455986 | devfileJsonSchema220.go | starcoder |
package versionbundle
import (
"fmt"
"sort"
"github.com/giantswarm/microerror"
"github.com/giantswarm/micrologger"
)
/*
Core design behind Aggregate() implementation:
Aggregate() function takes list of bundles and it builds all possible
combinations of them. Only restrictions are possibly conflicting Bundle
dep... | vendor/github.com/giantswarm/versionbundle/aggregate.go | 0.666605 | 0.413773 | aggregate.go | starcoder |
package positionallist
import (
"fmt"
)
type PositionalList[T any] struct {
header *Node[T] // header is a sentinel node. header.Next is the first element in the list.
trailer *Node[T] // trailer is a sentinel node. trailer.Prev is the last element in the list.
Size int
}
// New constructs and returns an emp... | positionallist/positional_list.go | 0.788909 | 0.556882 | positional_list.go | starcoder |
package processor
import (
"fmt"
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
jmespath "github.com/jmespath/go-jmespath"
)
//------------------------------------------------------------------------------
func init() {
Constructor... | lib/processor/jmespath.go | 0.677581 | 0.815085 | jmespath.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"strings"
"strconv"
)
type coord struct {
x, y, size int
invalid bool
}
func (self *coord) dist(other coord) int {
return abs(self.x - other.x) + abs(self.y - other.y)
}
type point struct {
nearest *coord
dist int
}
func main() {
// Input parsing
file, _ := iouti... | 2018/Day6.go | 0.620507 | 0.497131 | Day6.go | starcoder |
package experimental
import (
"encoding/json"
"fmt"
"math"
"sort"
"github.com/heustis/tsp-solver-go/model"
)
// ConvexConcaveWeightedEdges is significantly worse than the other greedy algorithms, see `results_2d_comp_greedy_3.tsv`.
// I tested it with 8, 4, and 1 points in the weighting array (see below).
// Wi... | circuit/experimental/convexconcave_weighted_edges_impl.go | 0.812496 | 0.558357 | convexconcave_weighted_edges_impl.go | starcoder |
package iterator
import (
"sync/atomic"
"github.com/apache/arrow/go/arrow"
"github.com/apache/arrow/go/arrow/array"
"github.com/gomem/gomem/internal/debug"
)
// BooleanValueIterator is an iterator for reading an Arrow Column value by value.
type BooleanValueIterator struct {
refCount int64
chunkIterator ... | pkg/iterator/booleanvalueiterator.go | 0.791015 | 0.403479 | booleanvalueiterator.go | starcoder |
package model
import (
"reflect"
"strconv"
"time"
"github.com/emmettwoo/EMM-MoneyBox/util"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type DayFlowEntity struct {
Id primitive.ObjectID `bson:"_id,omitempty"`
CashFlows []primitive.ObjectID `json:"cashFlows" bson:... | model/day_flow.go | 0.529993 | 0.425009 | day_flow.go | starcoder |
package vectormath
const g_PI_OVER_2 = 1.570796327
func M3Copy(result *Matrix3, mat *Matrix3) {
V3Copy(&result.col0, &mat.col0)
V3Copy(&result.col1, &mat.col1)
V3Copy(&result.col2, &mat.col2)
}
func M3MakeFromScalar(result *Matrix3, scalar float32) {
V3MakeFromScalar(&result.col0, scalar)
V3MakeFromScalar(&res... | mat_aos.go | 0.731155 | 0.590632 | mat_aos.go | starcoder |
package elements
const defaultElementsJSON string = `
[
{
"Symbol": "H",
"Name": "hydrogen",
"Number": 1,
"Isotope": [
{
"Mass": 1.00782503223,
"Abundance": 0.999885
},
{
"Mass": 2.01410177812,
"Abundance": 0.000115
}
]
},
{
"Symbol... | elements/defaults.go | 0.623721 | 0.574037 | defaults.go | starcoder |
package filters
import "math"
/*
Filters used for grid-based interpolation.
Filter code adapted from https://github.com/disintegration/imaging/
MIT License - https://github.com/disintegration/imaging/blob/master/LICENSE
*/
var (
// Box filter (averaging pixels).
Box = GridFilter{
Size: 0.5,
Kernel: func(x ... | f64/filters/grid.go | 0.83346 | 0.600188 | grid.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// AssignmentFilterEvaluationSummary represent result summary for assignment filter ev... | models/assignment_filter_evaluation_summary.go | 0.673406 | 0.41185 | assignment_filter_evaluation_summary.go | starcoder |
package describe
import (
"errors"
"fmt"
"time"
"github.com/theothertomelliott/meetingtime"
)
// Schedule generates an English description of an instance of meetingtime.Schedule
func Schedule(schedule meetingtime.Schedule) (string, error) {
switch schedule.Type {
case meetingtime.Daily:
return daily(schedule... | describe/schedule.go | 0.606964 | 0.444987 | schedule.go | starcoder |
package navmeshv2
import (
"github.com/g3n/engine/math32"
)
const (
BlocksX = 6
BlocksY = 6
BlocksTotal = BlocksX * BlocksY
TilesX = 96
TilesY = 96
TilesTotal = TilesX * TilesY
VerticesX = TilesX + 1
VerticesY = TilesY + 1
VerticesTotal = VerticesX * VerticesY
TerrainWidth = ... | navmeshv2/rt_navmesh_terrain.go | 0.654895 | 0.423637 | rt_navmesh_terrain.go | starcoder |
package digit
const (
// LinkRelationAlternate designates a substitute for the link's context.
LinkRelationAlternate = "alternate"
// LinkRelationAppendix refers to an appendix.
LinkRelationAppendix = "appendix"
// LinkRelationBookmark refers to a bookmark or entry point.
LinkRelationBookmark = "bookmark"
/... | linkRelationName.go | 0.624866 | 0.421433 | linkRelationName.go | starcoder |
package ui
// A Label is a static line of text used to mark other controls.
// Label text is drawn on a single line; text that does not fit is truncated.
// A Label can appear in one of two places: bound to a control or standalone.
// This determines the vertical alignment of the label.
type Label struct {
created ... | label.go | 0.671901 | 0.405566 | label.go | starcoder |
package datatype
import (
"fmt"
"math"
"github.com/i-sevostyanov/NanoDB/internal/sql"
)
type Integer struct {
value int64
}
func NewInteger(v int64) Integer {
return Integer{value: v}
}
func (i Integer) Raw() interface{} {
return i.value
}
func (i Integer) DataType() sql.DataType {
return sql.Integer
}
fu... | internal/sql/datatype/integer.go | 0.693265 | 0.496155 | integer.go | starcoder |
package softwarebackend
import (
"image/color"
"math"
"github.com/gsvigruha/canvas/backend/backendbase"
)
func triangleLR(tri []backendbase.Vec, y float64) (l, r float64, outside bool) {
a, b, c := tri[0], tri[1], tri[2]
// sort by y
if a[1] > b[1] {
a, b = b, a
}
if b[1] > c[1] {
b, c = c, b
if a[1] ... | backend/softwarebackend/triangles.go | 0.598664 | 0.447279 | triangles.go | starcoder |
package accel3xdigital
// Mode The sensor has three power modes: Off Mode, Standby Mode, and Active Mode to offer the customer different power
// consumption options. The sensor is only capable of running in one of these modes at a time.
type Mode byte
var (
downMask = [3]bool{true, false, true}
upMask = [3]boo... | grove/accel3xdigital/protocol.go | 0.594787 | 0.46642 | protocol.go | starcoder |
package processor
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/itchyny/gojq"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/component/processor"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/intern... | internal/old/processor/jq.go | 0.765418 | 0.635166 | jq.go | starcoder |
package encryptor
import (
"strings"
"github.com/jrapoport/chestnut/encryptor/crypto"
)
// ChainEncryptor is an encryptor that supports an chain of other Encryptors.
// Bytes will be encrypted by chaining the Encryptors in a FIFO order.
type ChainEncryptor struct {
id string
name string
ids ... | encryptor/chain.go | 0.716318 | 0.40342 | chain.go | starcoder |
package cmdargs
import (
"strconv"
)
// Generic provides a set of methods that can be used to convert the value into specific types.
type Generic interface {
String() (string, bool)
ToString() string
Bool() (bool, bool)
ToBool() bool
Int() (int64, bool)
ToInt() int64
Uint() (uint64, bool)
ToUint() u... | datatypes.go | 0.800926 | 0.514949 | datatypes.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_perceptron
#include <capi/perceptron.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type PerceptronOptionalParam struct {
InputModel *perceptronModel
Labels *mat.Dense
MaxIterations int
Test *mat.Dense... | perceptron.go | 0.763572 | 0.518729 | perceptron.go | starcoder |
package videosource
import (
"image"
"math"
)
// CorrectRectangle will fix a rectangle to fit within the Image i
func CorrectRectangle(i Image, rect image.Rectangle) (result image.Rectangle) {
if !i.IsFilled() {
return
}
result = rect
if result.Min.X < 0 {
result.Min.X = 0
}
if result.Min.Y < 0 {
result... | videosource/rect.go | 0.764628 | 0.560373 | rect.go | starcoder |
package xhuman
import (
"errors"
"math"
"strconv"
"strings"
"unicode"
)
// Bytes unit convert
const (
B = 1 << (10 * iota)
KB
MB
GB
TB
PB
EB
)
// Version returns package version
func Version() string {
return "0.1.0"
}
// Author returns package author
func Author() string {
return "[<NAME>](https://ww... | xhuman/xhuman.go | 0.787768 | 0.419172 | xhuman.go | starcoder |
package note
import (
"hash/fnv"
"sort"
"strconv"
"strings"
"sync"
)
// Word index data structure
type Word struct {
WordIndex uint
}
var sortedWords []Word
var sortedWordsInitialized = false
var sortedWordsInitLock sync.RWMutex
// Class used to sort an index of words
type byWord []Word
func (a byWord) Len(... | note/words.go | 0.558327 | 0.416381 | words.go | starcoder |
package timetable
import (
"time"
"github.com/mtneug/pkg/ulid"
)
// Type represents some category of timetables.
type Type string
const (
// TypeJSON is a hypochronos JSON timetable.
TypeJSON Type = "json"
)
// Spec specifies a timetable.
type Spec struct {
// Type of the timetable.
Type Type
// JSONSpec f... | timetable/timetable.go | 0.709321 | 0.448849 | timetable.go | starcoder |
package iso20022
// Amount of money for which goods or services are offered, sold, or bought.
type UnitPrice15 struct {
// Type and information about a price.
Type *TypeOfPrice9Code `xml:"Tp"`
// Type and information about a price.
ExtendedType *Extended350Code `xml:"XtndedTp"`
// Type of pricing calculation m... | UnitPrice15.go | 0.805364 | 0.510496 | UnitPrice15.go | starcoder |
package day11
import (
aoc "github.com/TipsyPixie/advent-of-code-2020"
)
type state string
const (
EMPTY = state("L")
OCCUPIED = state("#")
NONEXISTENT = state(".")
)
type board struct {
alternativeCounting bool
states [][]state
occupationCount int
}
func parseLine(signs string) []... | day11/day11.go | 0.510496 | 0.429549 | day11.go | starcoder |
package execution
import (
"reflect"
"github.com/pkg/errors"
"gorgonia.org/tensor/internal/storage"
)
func (e E) Gt(t reflect.Type, a *storage.Header, b *storage.Header, retVal *storage.Header) (err error) {
as := isScalar(a, t)
bs := isScalar(b, t)
rs := isScalar(retVal, Bool)
rt := retVal.Bools()
if ((as... | internal/execution/eng_cmp.go | 0.550366 | 0.538559 | eng_cmp.go | starcoder |
package iso20022
// Cash movements from or to a fund as a result of investment funds transactions, eg, subscriptions or redemptions.
type EstimatedFundCashForecast2 struct {
// Date and, if required, the time, at which the price has been applied.
TradeDateTime *DateAndDateTimeChoice `xml:"TradDtTm"`
// Previous d... | data/train/go/43d5a80a0f2632885a098b490e1ac5438a95e284EstimatedFundCashForecast2.go | 0.849784 | 0.546496 | 43d5a80a0f2632885a098b490e1ac5438a95e284EstimatedFundCashForecast2.go | starcoder |
package common
const (
// MbInBytes is the number of bytes in one mebibyte.
MbInBytes = int64(1024 * 1024)
// GbInBytes is the number of bytes in one gibibyte.
GbInBytes = int64(1024 * 1024 * 1024)
// DefaultGbDiskSize is the default disk size in gibibytes.
DefaultGbDiskSize = int64(10)
// DiskTypeString is ... | pkg/csi/service/common/constants.go | 0.606498 | 0.412353 | constants.go | starcoder |
package mbserver
import (
"encoding/binary"
"errors"
"math"
)
type (
bigEndian struct{}
littleEndian struct{}
)
// LittleEndian is the little-endian implementation of ByteOrder.
var LittleEndian littleEndian
// BigEndian is the big-endian implementation of ByteOrder.
var BigEndian bigEndian
// BytesToUint1... | mbserver/binary.go | 0.629888 | 0.572036 | binary.go | starcoder |
package dev
import (
"errors"
"time"
"golang.org/x/exp/io/i2c"
)
const (
// ConversionRegiserPointer ...
ConversionRegiserPointer byte = 0x00
// ConfigRegiserPointer ...
ConfigRegiserPointer byte = 0x01
//LoThreshRegiserPointer ...
LoThreshRegiserPointer byte = 0x10
// HiThreshRegiserPointer ...
HiThreshR... | dev/ads1015.go | 0.552781 | 0.426023 | ads1015.go | starcoder |
package equileader
import "math"
// We utilize the Leader implementation internals
// to maintain a list of subleaders in a map
func thirdpartySolution(A []int) int {
leadersCount := 0
arrayLen := len(A)
l := NewIntStack(arrayLen)
candidate := -1
leader := -1
count := 0
leftLeadersCount := 0
leftSequenceLengt... | codility/8.leader/equileader/thirdparty-solution.go | 0.669745 | 0.422803 | thirdparty-solution.go | starcoder |
package transactioncounter
import (
"errors"
"fmt"
"time"
"github.com/amoskyler/fake_stock_alerts/transaction"
)
type (
// TickerMap is a hash keyed by the Ticker id with a value being the total count of transactions
TickerMap map[transaction.Ticker]int
// Counter is responsible for enumerating and describing... | transactioncounter/transactioncounter.go | 0.807537 | 0.448004 | transactioncounter.go | starcoder |
package gokalman
import (
"fmt"
"strings"
"github.com/gonum/matrix/mat64"
"github.com/gonum/stat"
)
// MonteCarloRuns stores MC runs.
type MonteCarloRuns struct {
runs, steps int
Runs []MonteCarloRun
}
// Mean returns the mean of all the samples for the given time step.
func (mc MonteCarloRuns) Mean(st... | montecarlo.go | 0.707203 | 0.514217 | montecarlo.go | starcoder |
package main
import (
"fmt"
"strings"
"github.com/AntonKosov/advent-of-code-2021/aoc"
)
/*
All algorithms for all digits are similar. There are differences in three variables only and z which
is the only value which goes outside. This algorithm may be simplified.
inp w | w = [1..9]
mul x 0 | x = 0
... | day24/part2/main.go | 0.564339 | 0.628778 | main.go | starcoder |
package float
import (
"errors"
"github.com/itrabbit/go-stp/conversion"
"reflect"
"strconv"
"time"
)
// Get Float reflect Type
func Type(bitSize int) reflect.Type {
switch bitSize {
case 32:
return reflect.TypeOf(float32(0))
case 64:
return reflect.TypeOf(float64(0))
default:
return reflect.TypeOf(floa... | conversion/float/float.go | 0.6508 | 0.446133 | float.go | starcoder |
package gocvsimd
import (
"unsafe"
)
//go:noescape
func _SimdSse2AbsDifferenceSum(a unsafe.Pointer, aStride uint64, b unsafe.Pointer, bStride uint64, width, height uint64, sum unsafe.Pointer)
//go:noescape
func _SimdSse2AbsDifferenceSumMasked(a unsafe.Pointer, aStride uint64, b unsafe.Pointer, bStride uint64, mask ... | sse2/SimdSse2AbsDifferenceSum_amd64.go | 0.703855 | 0.595463 | SimdSse2AbsDifferenceSum_amd64.go | starcoder |
package iso20022
// Information regarding the total amount of taxes.
type TotalTaxes3 struct {
// Total value of the taxes for a specific order.
TotalAmountOfTaxes *ActiveCurrencyAnd13DecimalAmount `xml:"TtlAmtOfTaxs,omitempty"`
// Amount included in the dividend that corresponds to gains directly or indirectly d... | TotalTaxes3.go | 0.771843 | 0.6466 | TotalTaxes3.go | starcoder |
package optional
import "time"
// Duration represents optional duration value
type Duration struct {
value time.Duration
presents bool
}
func (d *Duration) set(dd time.Duration) {
d.value = dd
d.presents = true
}
// OfDuration creates new optional time.Duration containing provided value
func OfDuration(d tim... | duration.go | 0.841337 | 0.486149 | duration.go | starcoder |
package main
import (
"github.com/ByteArena/box2d"
"github.com/wdevore/RangerGo/api"
"github.com/wdevore/RangerGo/engine/nodes"
"github.com/wdevore/RangerGo/engine/nodes/custom"
"github.com/wdevore/RangerGo/engine/rendering"
)
type gameLayer struct {
nodes.Node
textColor api.IPalette
circleNode api.INod... | examples/physics/basics/ground/basic_game_layer.go | 0.615435 | 0.408808 | basic_game_layer.go | starcoder |
package newhope
import (
"encoding/binary"
//"git.schwanenlied.me/yawning/chacha20.git"
"github.com/Yawning/chacha20"
"golang.org/x/crypto/sha3"
)
const (
// PolyBytes is the length of an encoded polynomial in bytes.
PolyBytes = 1792
shake128Rate = 168 // Stupid that this isn't exposed.
)
type poly struct ... | poly.go | 0.514156 | 0.413063 | poly.go | starcoder |
package world
import (
"fmt"
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/go-gl/mathgl/mgl64"
"math"
)
// ChunkPos holds the position of a chunk. The type is provided as a utility struct for keeping track of a
// chunk's position. Chunks do not themselves keep track of that. Chunk positions are diff... | server/world/position.go | 0.878432 | 0.616907 | position.go | starcoder |
package nexus
// Alignment is a collection of equal length sequences
type Alignment []string
// Column is the letters from each internal sequence at position p
func (aln Alignment) Column(p uint) []byte {
pos := make([]byte, aln.NSeq())
for i := uint(0); i < aln.NSeq(); i++ {
pos[i] = aln.Seq(i)[p]
}
return pos... | internal/nexus/alignment.go | 0.777933 | 0.487185 | alignment.go | starcoder |
package leb128
import (
"math/bits"
)
// Based on the explanation here: https://en.wikipedia.org/wiki/LEB128.
// UnsignedEncode encodes an uint64 to LEB128 encoded byte array
func UnsignedEncode(value uint64) []byte {
if value == 0 { // Special case
return []byte{0x00}
}
var enc []byte
for value > 0 {
bits... | leb128.go | 0.728459 | 0.491395 | leb128.go | starcoder |
package pgs
// Node represents any member of the proto descriptor AST. Typically, the
// highest level Node is the Package.
type Node interface {
accept(Visitor) error
}
// A Visitor exposes methods to walk an AST Node and its children in a depth-
// first manner. If the returned Visitor v is non-nil, it will be use... | node.go | 0.803328 | 0.434281 | node.go | starcoder |
package iso20022
// Provides the additional information for an NDF as supplied on a fixing instruction.
type FixingConditions1 struct {
// The date on which the trade was executed.
TradeDate *ISODate `xml:"TradDt"`
// Represents the original reference of the instruction for which the status is given, as assigned ... | FixingConditions1.go | 0.839635 | 0.471406 | FixingConditions1.go | starcoder |
package unit
import (
"fmt"
"math"
)
type Time float64
const (
Nanosecond Time = 1
Microsecond = Nanosecond * 1000
Millisecond = Microsecond * 1000
Second = Millisecond * 1000
Minute = Second * 60
Hour = Minute * 60
Day = Hour * 24
Week = ... | time.go | 0.825906 | 0.40592 | time.go | starcoder |
package opengl
import "github.com/go-gl/gl/v3.3-core/gl"
// Mesh is a mesh that can be drawn
type Mesh struct {
vertices []float32
indices []uint32
vao uint32
vbo uint32
ebo uint32
Shader *Shader
ownshader bool
}
// MakeMesh creates a mesh with given vertices and an optional shader
fun... | opengl/mesh.go | 0.808408 | 0.423041 | mesh.go | starcoder |
package raytracing
import (
"math"
"math/rand"
)
type Material interface {
scatter(hr hitRecord) (ray, bool)
attenuation() Color
}
type lambertian struct {
albedo Color
}
func NewLambertian(c Color) Material {
return lambertian{albedo: c}
}
func (l lambertian) scatter(hr hitRecord) (ray, bool) {
phi := 2 * ... | material.go | 0.837985 | 0.446736 | material.go | starcoder |
package level
// TileFlag describes simple properties of a map tile.
type TileFlag uint32
// RealWorldFlag describes simple properties of a map tile in the real world.
type RealWorldFlag TileFlag
// CyberspaceFlag describes simple properties of a map tile in cyberspace.
type CyberspaceFlag TileFlag
// ForRealWorld ... | ss1/content/archive/level/TileFlag.go | 0.817028 | 0.6955 | TileFlag.go | starcoder |
package serialization
import (
i "io"
"time"
"github.com/google/uuid"
)
// Defines an interface for serialization of objects to a byte array.
type SerializationWriter interface {
i.Closer
// Writes a String value to the byte array.
// Parameters:
// - key - the key of the value to write (optional).
// - valu... | abstractions/go/serialization/serialization_writer.go | 0.661704 | 0.45302 | serialization_writer.go | starcoder |
package cnns
import (
"math"
"gonum.org/v1/gonum/mat"
)
// Pool2D Pooling of matrix with defined window: windowSize/stride/pooling_type. See ref. https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer
/*
matrix - source matrix
outRows - number of output rows
outCols - number of output columns
... | pool_2d.go | 0.736211 | 0.470797 | pool_2d.go | starcoder |
package stl
import (
"bytes"
"encoding/binary"
"fmt"
"github.com/stefanom/peano/geom"
"io"
"io/ioutil"
"strconv"
)
type Model struct {
Header [80]byte
Length int32
Facets []geom.Facet
}
type Parser struct {
r io.Reader
s *Scanner
buf struct {
tok Token // last read token
lit string // last read... | stl/parser.go | 0.676192 | 0.428114 | parser.go | starcoder |
package insulter
import (
"math/rand"
"time"
)
// https://github.com/aimxhaisse/fuu/blob/master/cfuu/dictionnary.json
type insultGender struct {
Prefix, Name, Suffix []string
}
// Insults struct
type Insults struct {
Prefix []string
Man, Woman insultGender
}
// CreateInsultDict generate the insult dict
fun... | insulter/main.go | 0.53437 | 0.40204 | main.go | starcoder |
package ciede2000
import (
"image/color"
"math"
)
type LAB struct {
L float64
A float64
B float64
}
func ToXYZ(c color.Color) (float64, float64, float64) {
ta, tg, tb, _ := c.RGBA()
r := float64(ta) / 65535.0
g := float64(tg) / 65535.0
b := float64(tb) / 65535.0
if r > 0.04045 {
r = math.Pow(((r + 0.055... | vendor/github.com/mattn/go-ciede2000/ciede2000.go | 0.577138 | 0.42925 | ciede2000.go | starcoder |
package texture
import (
"github.com/jphsd/graphics2d"
"github.com/jphsd/graphics2d/util"
"image/color"
"math"
)
// Reflect contains a line along which a reflection is performed. The line defines where the
// mirror is. Points on the + side of the line remain untransformed, points on the other are
// reflected th... | reflect.go | 0.774285 | 0.587085 | reflect.go | starcoder |
package gosort
// heapsort performs an in-place sort of the provided values.
func heapsort(values []int) {
lv := len(values)
// STAGE 1: Re-order elements to satisfy the heap property by creating a max
// heap, where no child has a greater value than its parent.
debug("stage 1: build max heap: %v\n", values)
//... | heap.go | 0.539469 | 0.441553 | heap.go | starcoder |
package json
import (
"encoding/base64"
"fmt"
"math"
"strconv"
"time"
"unicode/utf8"
"github.com/novln/soba/encoder"
)
// Source forked from https://github.com/uber-go/zap and from https://github.com/rs/zerolog
// For JSON-escaping. See Encoder.safeAddString(string) below.
const hex = "0123456789abcdef"
// ... | encoder/json/types.go | 0.731251 | 0.408277 | types.go | starcoder |
package semver
import (
"fmt"
"testing"
)
type ValuesGenerator struct {
valueDefs []valueConstraint
}
type valueConstraint struct {
min int
max int
}
func NewValuesGenerator() *ValuesGenerator {
return &ValuesGenerator{}
}
func (g *ValuesGenerator) AddValue(min, max int) *ValuesGenerator {
g.valueDefs = app... | values_generator.go | 0.565779 | 0.413181 | values_generator.go | starcoder |
package rand
import (
"errors"
"io"
"math/big"
)
const uint64Max = (1 << 64) - 1
var smallPrimes = []uint8{
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
}
var smallPrimesProduct = new(big.Int).SetUint64(16294579238595022365)
var oneInt = new(big.Int).SetUint64(1)
// Prime generates a random pr... | rand/prime.go | 0.567817 | 0.409044 | prime.go | starcoder |
package trie
// Trie defines a search tree based on runes.
type Trie struct {
root *Node
}
// Node defines a node in a trie.
type Node struct {
value *Value
nodes map[rune]*Node
end bool
}
// New creates a new trie.
func New() *Trie {
root := &Node{nodes: make(map[rune]*Node), end: false}
return &Trie{root}... | src/common/trie/trie.go | 0.712932 | 0.534673 | trie.go | starcoder |
package seal
import (
"github.com/rumis/seal/expr"
)
// Eq generates a Standard equal expression
func Eq(col string, val interface{}) expr.Expr {
return expr.Op(col, "=", val)
}
// StaticEq generates a static equal expression which without params
func StaticEq(col1 string, col2 string) expr.Expr {
return StaticOp... | stmt.go | 0.770119 | 0.510435 | stmt.go | starcoder |
package fb
const (
///< No Halt Type
HaltTypenone = 0
///< Unspecified news-related halt
HaltTypenews = 1
///< Denotes a regulatory trading halt when relevant news influencing the security is being disseminated. Trading is suspended until the primary market determines that an adequate publication or disclosure o... | go/schemas/fb/HaltType.go | 0.670608 | 0.463869 | HaltType.go | starcoder |
package timezones
// Source https://github.com/dmfilipenko/timezones.json
var data = `
[
{
"value": "Dateline Standard Time",
"abbr": "DST",
"offset": -12,
"isdst": false,
"text": "(UTC-12:00) International Date Line West",
"utc": [
"Etc/GMT+12"
]
},
{
"value": "UTC-11",
... | data.go | 0.570092 | 0.428353 | data.go | starcoder |
package cmd
import (
"github.com/spf13/cobra"
"go.borchero.com/cuckoo/ci"
"go.borchero.com/cuckoo/providers"
"go.borchero.com/typewriter"
)
const deployDescription = `
The deploy command deploys a Helm chart to a Kubernetes cluster. A Helm chart may be defined in
multiple ways:
* Remote Charts: In this case, the... | source/cmd/deploy.go | 0.606964 | 0.408041 | deploy.go | starcoder |
package fp
func (l BoolList) TakeRight(n int) BoolList { return l.Reverse().Take(n).Reverse() }
func (l StringList) TakeRight(n int) StringList { return l.Reverse().Take(n).Reverse() }
func (l IntList) TakeRight(n int) IntList { return l.Reverse().Take(n).Reverse() }
func (l Int64List) TakeRight(n int) Int64List { r... | fp/bootstrap_list_takeright.go | 0.693473 | 0.479869 | bootstrap_list_takeright.go | starcoder |
// Package queueimpl4 implements an unbounded, dynamically growing FIFO queue.
// Internally, queue store the values in fixed sized arrays that are linked using
// a singly linked list.
// This implementation tests the queue performance when controlling the length and
// current positions in the arrays using simple lo... | queueimpl4/queueimpl4.go | 0.876621 | 0.598782 | queueimpl4.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"text/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "https://github.co... | docs/docs.go | 0.680348 | 0.405861 | docs.go | starcoder |
package byteutils
// Endian represents the endianness for conversion.
type Endian bool
const (
// LittleEndian places the least significant byte at the end (right side) of
// a byte sequence.
LittleEndian Endian = false
// BigEndian places the most significant byte at the end (right side) of a
// byte sequence
... | endianness.go | 0.801897 | 0.69641 | endianness.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.