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 validator
import (
"github.com/benchlab/asteroid/typing"
"github.com/benchlab/asteroid/ast"
)
func (v *Validator) validateStatement(node ast.Node) {
switch n := node.(type) {
case *ast.AssignmentStatementNode:
v.validateAssignment(n)
break
case *ast.ForStatementNode:
v.validateForStatement(n)
br... | validator/statements.go | 0.553023 | 0.423816 | statements.go | starcoder |
package fastconvert
import "encoding/binary"
// region 16 bit
// region int16 Converters
// ReadByteArrayToInt16LEArray reads a int16 array from specified byte buffer in Little Endian format.
// The number of items are len(data) / 2 or len(out). Which one is the lower.
func ReadByteArrayToInt16LEArray(data []byte, ou... | intconverters.go | 0.609873 | 0.400955 | intconverters.go | starcoder |
// Package rnd implements random numbers generators (wrapping the standard functions or the Mersenne
// Twister library). It also implements probability distribution functions.
package rnd
import (
"math/rand"
"time"
"gosl/utl"
)
// Init initialises random numbers generators
// Input:
// seed -- seed value; u... | rnd/random.go | 0.690768 | 0.574096 | random.go | starcoder |
package commons
import (
"errors"
"github.com/yuyenews/Beerus/commons/util"
"strconv"
"strings"
"time"
)
// BeeSession Session Management, Based on the aes algorithm
// The basic principle of creating a token is to convert the data into a json string, then splice a timeout to the end, then perform aes encryption... | network/http/commons/BeeSession.go | 0.643889 | 0.400544 | BeeSession.go | starcoder |
package temporal
import (
"fmt"
"math"
"time"
"github.com/m3db/m3/src/query/executor/transform"
)
const (
// HoltWintersType produces a smoothed value for time series based on the specified interval.
// The algorithm used comes from https://en.wikipedia.org/wiki/Exponential_smoothing#Double_exponential_smooth... | src/query/functions/temporal/holt_winters.go | 0.722625 | 0.510435 | holt_winters.go | starcoder |
package vec
import (
"bytes"
"fmt"
"math"
"sort"
)
type Vector []float64
func MakeVec(len int, source func(i int) float64) Vector {
var vector = make(Vector, 0, len)
for i := 0; i < len; i++ {
vector = append(vector, source(i))
}
return vector
}
func (vector Vector) New() Vector {
return make(Vector, 0, ... | vec/vector.go | 0.802362 | 0.575916 | vector.go | starcoder |
package core
import (
"fmt"
"math/bits"
"time"
)
const Int64MostSigBitSet = 0x8000000000000000
// Convert a board coordinate as a string - such as f6 or b2 -
// into a position into a 64-length array.
func CoordinateToPos(coordinate string) int {
file := coordinate[0] - 'a'
rank := charToDigit(coordinate[1]) - ... | core/utils.go | 0.71113 | 0.450541 | utils.go | starcoder |
package main
import (
"encoding/json"
"fmt"
"math"
"strings"
"time"
)
type Date struct {
time.Time
definition DateDefinition
}
type DateDefinition struct {
Date string `json:"date"`
Year int `json:"year"`
Month int `json:"month"`
Week int `json:"week"`
Year... | date.go | 0.71113 | 0.433562 | date.go | starcoder |
package schnorr
import (
"math/big"
"github.com/xlab-si/emmy/crypto/common"
)
// ProveEquality demonstrates how prover can prove the knowledge of log_g1(t1), log_g2(t2) and
// that log_g1(t1) = log_g2(t2).
func ProveEquality(secret, g1, g2, t1, t2 *big.Int, group *Group) bool {
eProver := NewEqualityProver(group)... | crypto/schnorr/dlog_equality.go | 0.721449 | 0.474449 | dlog_equality.go | starcoder |
package model
import (
"log"
"time"
"gonum.org/v1/gonum/mat"
)
// Perceptron for input classification.
type Perceptron struct {
inputSize int
outputSize int
input mat.Vector
output mat.Vector
weights []mat.Vector
biases mat.Vector
}
// CreatePerceptron with the given parameters.
func Creat... | internal/model/perceptron.go | 0.770206 | 0.495606 | perceptron.go | starcoder |
package sliceutils
import (
"sort"
)
type sortableFloat32Slice []float32
func (s sortableFloat32Slice) Len() int {
return len(s)
}
func (s sortableFloat32Slice) Less(i, j int) bool {
return s[i] < s[j]
}
func (s sortableFloat32Slice) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Float32Sort sorts the given s... | pkg/sliceutils/gen-builtins-generic_comparable.go | 0.778186 | 0.434761 | gen-builtins-generic_comparable.go | starcoder |
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package compiler
import (
"github.com/open2b/scriggo/ast"
)
// isTypeGuard reports whether node is a switch type guard, as x.(type) and
// v := x.(type).
func isTypeGuard(node ast.Node) bool {
switch v := node.... | vendor/github.com/open2b/scriggo/internal/compiler/parser_switch.go | 0.520253 | 0.442817 | parser_switch.go | starcoder |
// Data structures and helpers that describe Wikidata signature
// resources that we want to work with.
package mappings
import (
"encoding/json"
"fmt"
)
// WikidataMapping provides a way to persist Wikidata resources in
// memory.
var WikidataMapping = make(map[string]Wikidata)
// Wikidata stores information abo... | pkg/wikidata/internal/mappings/wikidata_mapping_structs.go | 0.598782 | 0.440048 | wikidata_mapping_structs.go | starcoder |
package countingsort
// IntsStable sorts integers slice using stable counting sort algorithm
// but it allocates more memory and works slower
func IntsStable(items []int, max int) {
sorted := GetSortedInts(items, max)
copy(items, sorted)
}
// Ints sorts integers slice using counting sort algorithm that is
// less s... | countingsort/countingsort.go | 0.85738 | 0.480113 | countingsort.go | starcoder |
// Memory Tracing gives us a general idea if our software is healthy as related to the GC and
// memory in the heap that we are working with.
// We are using a special environmental variable called GODEBUG. It gives us the ability to do
// a memory trace and a scheduler trace. Below is a sample program that causes me... | go/profiling/memory_tracing.go | 0.628977 | 0.632191 | memory_tracing.go | starcoder |
package animation
import "github.com/taylorza/go-gfx/pkg/gfx"
type rect struct {
x, y, w, h int
}
// Animation represents an animation sequence made up of 1 or more frames
type Animation struct {
t *gfx.Texture
frames []rect
frameTime float64
bidi bool
reverse bool
}
// Option is the signatu... | pkg/gfx/animation/animation.go | 0.821796 | 0.407098 | animation.go | starcoder |
package check
import (
"fmt"
)
var ErrLimitReached = fmt.Errorf("limit reached")
type StatusSeries struct {
index int
series []Status
}
func NewStatusSeries(size int) *StatusSeries {
return &StatusSeries{
series: make([]Status, size),
}
}
// Add adds a status to the series
func (ss *StatusSeries) Add(statu... | modules/500-upmeter/images/upmeter/pkg/check/series.go | 0.681197 | 0.521532 | series.go | starcoder |
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package quat
import "math"
// Sin returns the sine of q.
func Sin(q Quat) Quat {
w, uv := split(q)
if uv == zero {
return lift(math.Sin(w))
}
v := Abs(... | num/quat/trig.go | 0.900745 | 0.467271 | trig.go | starcoder |
package canvas
import (
"image"
"image/color"
"math"
)
// LinearGradient defines a Gradient travelling straight at a given angle.
// The only supported values for the angle are `0.0` (vertical) and `90.0` (horizontal), currently.
type LinearGradient struct {
baseObject
StartColor color.Color // The beginning RG... | canvas/gradient.go | 0.909733 | 0.706621 | gradient.go | starcoder |
package transform
import "github.com/frictionlessdata/tableschema-go/schema"
// Schema extends `schema.Schema` adding a `Headers()` method.
type Schema schema.Schema
// Headers returns an array with strings with the names of the fields.
func (s *Schema) Headers() []string {
var h []string
for _, f := range s.Field... | transform/descriptors.go | 0.674265 | 0.508788 | descriptors.go | starcoder |
package asciitree
import (
"fmt"
"reflect"
"strings"
)
// Caches the label and children field indices for a specific reflection type.
// Oh, and properties, and ... roots (to unify things slightly).
type fieldCacheItem struct {
labelIndex int
propertiesIndex int
childrenIndex int
rootsIndex int
}
... | fieldcache.go | 0.537041 | 0.4165 | fieldcache.go | starcoder |
package ent
import (
"fmt"
"opencensus/core/ent/infectedrecord"
"strings"
"time"
"entgo.io/ent/dialect/sql"
)
// InfectedRecord is the model entity for the InfectedRecord schema.
type InfectedRecord struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// ReportedDate holds the value of... | ent/infectedrecord.go | 0.682256 | 0.468365 | infectedrecord.go | starcoder |
package csr
import "math/rand"
// MatrixGenerator defines a matrix generator
type MatrixGenerator struct {
numNode, numConnection uint32
xCoords, yCoords []uint32
values []float32
positionOccupied map[uint32]bool
xCoordIndex, yCoordIndex map[uint32][]uint32
}
// MakeMatrixGen... | benchmarks/matrix/csr/matrixgenerator.go | 0.712032 | 0.53868 | matrixgenerator.go | starcoder |
package isbn
// Identifier represents ISBN identifier group and its prefix
type Identifier struct {
// GroupName is the identifying group name which can be National or Language name
GroupName string
// Abbreviation is the shorthand name of the GroupName
Abbreviation string
// Prefix is the ISBN prefix assigned ... | isbn/identifier_group.go | 0.527317 | 0.523542 | identifier_group.go | starcoder |
package pb
const (
swagger = `{
"swagger": "2.0",
"info": {
"title": "pb/profile.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/v1/create": {
"post": ... | vendor/github.com/gomeet-examples/svc-profile/pb/swagger.pb.go | 0.722037 | 0.421552 | swagger.pb.go | starcoder |
package container
import (
"encoding/json"
"golang.org/x/exp/constraints"
)
// List2D is a 2D slice with some helper methods. It is NOT thread safe.
type List2D[T any] struct {
data []T
width int
height int
}
func min[T constraints.Ordered](a T, b T) T {
if a < b {
return a
}
return b
}
func (l *List2... | list2d.go | 0.781539 | 0.500916 | list2d.go | starcoder |
package marker
import (
"errors"
"fmt"
"reflect"
"strconv"
)
type ArgumentType int
func (argumentType ArgumentType) String() string {
return argumentTypeText[argumentType]
}
const (
InvalidType ArgumentType = iota
RawType
AnyType
BoolType
IntegerType
StringType
SliceType
MapType
)
var argumentTypeText... | type.go | 0.706899 | 0.457379 | type.go | starcoder |
package input
import (
"github.com/lolopinto/ent/internal/schema/change"
"github.com/lolopinto/ent/internal/tsimport"
)
func NodeEqual(existing, node *Node) bool {
return existing.TableName == node.TableName &&
fieldsEqual(existing.Fields, node.Fields) &&
assocEdgesEqual(existing.AssocEdges, node.AssocEdges) &... | internal/schema/input/compare.go | 0.632957 | 0.462352 | compare.go | starcoder |
package hashing
import (
"bytes"
"math"
"math/big"
"github.com/ethereum/go-ethereum/common"
solsha3 "github.com/miguelmota/go-solidity-sha3"
"github.com/offchainlabs/arbitrum/packages/arb-util/protocol"
"github.com/offchainlabs/arbitrum/packages/arb-util/value"
"github.com/offchainlabs/arbitrum/packages/arb-... | packages/arb-validator/hashing/hashing.go | 0.598782 | 0.403214 | hashing.go | starcoder |
package analyze
import (
"fmt"
"io"
"math"
"sort"
"github.com/valyala/histogram"
)
// Bucket has the information for a collection of requests associated to the same memory size
type Bucket struct {
Size int64
Count int
DurationHist *histogram.Fast
MemoryHist ... | analyze/bucket.go | 0.70069 | 0.439807 | bucket.go | starcoder |
package cpu
import (
. "github.com/retroenv/nesgo/pkg/addressing"
)
// Opcode is a NES CPU opcode that contains the instruction info and used
// addressing mode.
type Opcode struct {
Instruction *Instruction
Addressing Mode
Timing byte
PageCrossCycle bool
}
// Opcodes maps first opcode bytes to ... | pkg/cpu/opcode.go | 0.569613 | 0.498291 | opcode.go | starcoder |
package lm
import (
"fmt"
"github.com/barnex/fmath"
)
type Vec3 [3]float32
func (v *Vec3) Pointer() *[3]float32 { return (*[3]float32)(v) }
func (v *Vec3) Slice() []float32 { return v[:] }
func (v Vec3) X() float32 { return v[0] }
func (v Vec3) Y() float32 ... | vec3.go | 0.769254 | 0.585249 | vec3.go | starcoder |
package render3d
import (
"math"
"github.com/unixpickle/essentials"
"github.com/unixpickle/model3d/model3d"
)
// A rayRenderer renders objects using any algorithm that
// can render pixels given an outgoing ray.
type rayRenderer struct {
RayColor func(g *goInfo, obj Object, ray *model3d.Ray) Color
Camera ... | render3d/ray_renderer.go | 0.70791 | 0.47658 | ray_renderer.go | starcoder |
package iso20022
// Payment instrument between a debtor and a creditor, which flows through one or more financial institutions or systems.
type CreditTransfer6 struct {
// Information supplied to enable the matching of an entry with the items that the transfer is intended to settle, such as commercial invoices in an... | CreditTransfer6.go | 0.630799 | 0.621053 | CreditTransfer6.go | starcoder |
package csvquery
import "strings"
// LogicalOperator describes logical operator type.
type LogicalOperator string
const (
// AndOperator describes AND logical operator.
AndOperator LogicalOperator = "AND"
// OrOperator describes OR logical operator.
OrOperator LogicalOperator = "OR"
)
// ComparisonOperator desc... | internal/csvquery/operators.go | 0.7478 | 0.405272 | operators.go | starcoder |
package _514_Freedom_Trail
/*
https://leetcode.com/problems/freedom-trail/description/
In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to spell a specific keyword in order to open the door.
Given a string ring, which re... | 514_Freedom_Trail/solution.go | 0.845528 | 0.693285 | solution.go | starcoder |
package search
import (
"container/heap"
"math"
"github.com/gonum/graph"
"github.com/gonum/graph/concrete"
)
var inf = math.Inf(1)
type searchFuncs struct {
successors, predecessors, neighbors func(graph.Node) []graph.Node
isSuccessor, isPredecessor, isNeighbor func(graph.Node, graph.Node) bool
cost ... | Godeps/_workspace/src/github.com/gonum/graph/search/internals.go | 0.699049 | 0.526221 | internals.go | starcoder |
package goOctree
import (
"strconv"
)
type Node struct {
Uid string
Center *Vector3
Size float32
// [0] = -X -Y -Z //left low back
// [1] = -X -Y +Z //left low front
// [2] = -X +Y -Z //left high back
// [3] = -X +Y +Z //left high front
// [4] = +X -Y -Z //right low back
// [5] = +X -Y +Z //right low f... | Node.go | 0.548674 | 0.432483 | Node.go | starcoder |
package adapters
import (
"database/sql"
"strings"
"time"
v1 "github.com/Ruscigno/ruscigno-gosdk/ticker-beats/v1"
model "github.com/Ruscigno/ticker-heart/internal/transaction/tradetransaction"
"github.com/Ruscigno/ticker-heart/internal/utils"
)
//ProtoToTradeTransaction transform an proto to an TradeTransactio... | internal/api/adapters/tradetransaction.go | 0.612657 | 0.449272 | tradetransaction.go | starcoder |
package slices
type (
// FilterFunc is a function that returns a boolean value
// that depends on the current element.
FilterFunc[Elem any] func(Elem) bool
// MapFunc is a function that transforms the current element into
// a new value of any type.
MapFunc[Elem, NewElem any] func(Elem) NewElem
// ReduceFunc ... | slices.go | 0.823293 | 0.4206 | slices.go | starcoder |
package proj
import (
"fmt"
"math"
)
func msfnz(eccent, sinphi, cosphi float64) float64 {
var con = eccent * sinphi
return cosphi / (math.Sqrt(1 - con*con))
}
func sign(x float64) float64 {
if x < 0 {
return -1
}
return 1
}
const (
twoPi = math.Pi * 2
// SPI is slightly greater than Math.PI, so values th... | proj/common.go | 0.736021 | 0.513668 | common.go | starcoder |
package psetter
import (
"errors"
"fmt"
"github.com/nickwells/golem/check"
"github.com/nickwells/golem/param"
"strconv"
)
// Float64Setter allows you to specify a parameter that can be used to set an
// float64 value. You can also supply a check function that will validate
// the Value. There are some helper fun... | param/psetter/float64Setter.go | 0.786746 | 0.426083 | float64Setter.go | starcoder |
package vm
import (
"encoding/binary"
"encoding/hex"
"math/big"
"xfsgo/common"
)
type CTypeUint8 [1]byte
type CTypeBool [1]byte
type CTypeUint16 [2]byte
type CTypeUint32 [4]byte
type CTypeUint64 [8]byte
type CTypeUint256 [32]byte
type CTypeString []byte
type CTypeAddress [25]byte
func (t CTypeUint8) uint8() uint... | vm/types.go | 0.566738 | 0.430985 | types.go | starcoder |
package bank
import (
"encoding/json"
"github.com/hyperledger/fabric/core/chaincode/shim"
sc "github.com/hyperledger/fabric/protos/peer"
"github.com/shopspring/decimal"
)
//BankChaincode is the struct that all chaincode methods are associated with
//The bank chaincode provides a simple representation of a bank. I... | chaincode/src/bank/bank.go | 0.565299 | 0.406509 | bank.go | starcoder |
package continuous
import (
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
smath "github.com/jtejido/stats/math"
"math"
"math/rand"
)
// Q-Exponential distribution
// https://en.wikipedia.org/wiki/Q-exponential_distribution
type QExponential struct {
rate, q float64 // λ, q
src rand.Source
}
fu... | dist/continuous/q_exponential.go | 0.81538 | 0.51379 | q_exponential.go | starcoder |
package plot
import "image/color"
// Grid implements faceted background.
type Grid struct {
GridTheme
}
// NewGrid creates a new grid plot.
func NewGrid() *Grid {
return &Grid{}
}
// Draw draws the element to canvas.
func (grid *Grid) Draw(plot *Plot, canvas Canvas) {
x, y := plot.X, plot.Y
size := canvas.Boun... | grid.go | 0.868046 | 0.595669 | grid.go | starcoder |
package bezout
import (
"math/big"
)
// BBPair is a Bachet-Bézout pair. The number X we are looking for
// verifies X == Remainder % Divisor
type BBPair struct {
Divisor big.Int
Remainder big.Int
}
// Solve a Chinese Remainder Theorem and returns the smallest positive value that matches
func Solve(c []BBPair) ... | internal/2020/dec13/bezout/bezout.go | 0.701304 | 0.48121 | bezout.go | starcoder |
package hplot
import (
"image/color"
"math"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg/draw"
)
// Band implements the plot.Plotter interface, drawing a colored band made of
// two lines.
type Band struct {
top plotter.XYs
bottom plotter.XYs
// LineStyle is the style of the lin... | hplot/band.go | 0.874091 | 0.454533 | band.go | starcoder |
package segments
import (
"fmt"
"math"
"github.com/pzduniak/unipdf/common"
"github.com/pzduniak/unipdf/internal/jbig2/bitmap"
"github.com/pzduniak/unipdf/internal/jbig2/reader"
)
// HalftoneRegion is the model for the jbig2 halftone region segment implementation - 7.4.5.1.
type HalftoneRegion struct {
r ... | bot/vendor/github.com/pzduniak/unipdf/internal/jbig2/segments/halftone-segment.go | 0.683208 | 0.446434 | halftone-segment.go | starcoder |
package aerospike
// OperationType determines operation type
type OperationType *struct{ op byte }
// Valid OperationType values that can be used to create custom Operations.
// The names are self-explanatory.
var (
READ OperationType = &struct{ op byte }{1}
// READ_HEADER *OperationType = &struct{op: 1 }
WRITE... | operation.go | 0.657978 | 0.401394 | operation.go | starcoder |
package siastats
import (
"encoding/json"
)
// ComparisonMatrix struct for ComparisonMatrix
type ComparisonMatrix struct {
Stored *int32 `json:"stored,omitempty"`
Price *float32 `json:"price,omitempty"`
Collateral *float32 `json:"collateral,omitempty"`
Up *float32 `json:"up,omitem... | model_comparison_matrix.go | 0.848769 | 0.40204 | model_comparison_matrix.go | starcoder |
package utils
import (
"bytes"
"io"
"strconv"
"strings"
)
// An Indenter helps building strings where all newlines are supposed to be followed by
// a sequence of zero or many spaces that reflect an indent level.
type Indenter struct {
b *bytes.Buffer
i int
}
// An Indentable can create build a string represen... | utils/indenter.go | 0.718496 | 0.41052 | indenter.go | starcoder |
package iso20022
// Set of elements providing the total sum of entries per bank transaction code.
type NumberAndSumOfTransactionsPerBankTransactionCode1 struct {
// Number of individual entries contained in the report.
NumberOfEntries *Max15NumericText `xml:"NbOfNtries,omitempty"`
// Total of all individual entri... | NumberAndSumOfTransactionsPerBankTransactionCode1.go | 0.768038 | 0.421552 | NumberAndSumOfTransactionsPerBankTransactionCode1.go | starcoder |
package czml
// Cartesian2 is two-dimensional Cartesian value specified as [X, Y]. If the array has two elements,
// the value is constant. If it has three or more elements, they are time-tagged samples arranged as
// [Time, X, Y, Time, X, Y, ...], where Time is an ISO 8601 date and time string or seconds since
// epo... | cartesian.go | 0.888753 | 0.755727 | cartesian.go | starcoder |
package image_generator
import (
"image/color"
"strings"
"github.com/minio/minio/pkg/env"
)
// image dimensions and margins
var (
height = float64(1920)
width = float64(1080)
marginTop = float64(250)
marginBottom = float64(250)
marginLeft = float64(100)
marginRight = float64(100)
fontSi... | internal/image-generator/constants.go | 0.539954 | 0.433142 | constants.go | starcoder |
package tempconv
// CToF converts a Celsius temperature to Fahrenheit.
func CToF (c Celsius) Fahrenheit {
return Fahrenheit(c*9/5 + 32)
}
// CToK converts a Celsius temperature to Kelvin.
func CToK (c Celsius) Kelvin {
return Kelvin(c + 273.15)
}
// CToRa converts a Celsius temperature to Rankine.
func CToRa (c Ce... | tempconv/conv.go | 0.90904 | 0.733571 | conv.go | starcoder |
package elref
import (
"reflect"
)
// If `v` is nil return true.
func IsNil(v interface{}) bool {
if v == nil {
return true
}
r := reflect.ValueOf(v)
switch r.Kind() {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice, reflect.Interface:
if r.IsNil() {
return true
}
}
return fa... | elref/ref.go | 0.656108 | 0.476762 | ref.go | starcoder |
package reflect
import (
"reflect"
)
func IndirectType(reflectType reflect.Type) reflect.Type {
kind := reflectType.Kind()
if kind == reflect.Ptr {
return reflectType.Elem()
}
return reflectType
}
func KindElemType(reflectType reflect.Type) reflect.Kind {
return IndirectType(reflectType).Kind()
}
type Cal... | support/reflect/type.go | 0.615435 | 0.47792 | type.go | starcoder |
package functions
import (
"strconv"
"strings"
"time"
"github.com/robjporter/go-functions/as"
"github.com/robjporter/go-functions/now"
)
func CurrentMonthName() string {
return time.Now().Month().String()
}
func CurrentYear() string {
return as.ToString(time.Now().Year())
}
func IsYear(input string) string ... | functions/functions.go | 0.52829 | 0.459925 | functions.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPTopLevelUserTypeDeclaration288 struct for BTPTopLevelUserTypeDeclaration288
type BTPTopLevelUserTypeDeclaration288 struct {
BTPTopLevelTypeDeclaration287
BtType *string `json:"btType,omitempty"`
Typecheck *BTPName261 `json:"typecheck,omitempty"`
}
// NewBTPTopLeve... | onshape/model_btp_top_level_user_type_declaration_288.go | 0.675658 | 0.439507 | model_btp_top_level_user_type_declaration_288.go | starcoder |
package cryptypes
import "database/sql/driver"
// EncryptedInt32 supports encrypting Int32 data
type EncryptedInt32 struct {
Field
Raw int32
}
// Scan converts the value from the DB into a usable EncryptedInt32 value
func (s *EncryptedInt32) Scan(value interface{}) error {
return decrypt(value.([]byte), &s.Raw)
}... | cryptypes/type_int32.go | 0.799521 | 0.566198 | type_int32.go | starcoder |
package main
import (
"fmt"
"math"
"sort"
"github.com/kissgyorgy/adventofcode2019/point"
)
const (
// mapFile = "day10-example3.txt"
mapFile = "day10-input.txt"
)
var (
// this comes from solution of part1
selectedPoint = point.Point{26, 36}
// selectedPoint = point.Point{3, 4} // example1
// selectedPoin... | day10/day10part2.go | 0.608129 | 0.457985 | day10part2.go | starcoder |
package solutions
import (
"fmt"
"github.com/encero/advent-of-code-2021/helpers"
)
func Day11DumboOcto() error {
var input = [][]DumboOctopus{
{{PowerLevel: 6}, {PowerLevel: 6}, {PowerLevel: 1}, {PowerLevel: 7}, {PowerLevel: 1}, {PowerLevel: 1}, {PowerLevel: 3}, {PowerLevel: 5}, {PowerLevel: 8}, {PowerLevel: 4}}... | solutions/day11_dumbo.go | 0.500732 | 0.6971 | day11_dumbo.go | starcoder |
package dmap
import (
"ditto/dfs"
"fmt"
"github.com/pterm/pterm"
)
type Md5Hash string
// Dmap structure will hold our file duplication data.
// It is the primary data structure that will house the results
// that will eventually be returned to the user.
type Dmap struct {
filesMap map[Md5Hash][]string
fileCo... | dmap/dmap.go | 0.585931 | 0.462716 | dmap.go | starcoder |
package blurhash
import (
"math"
"strings"
"github.com/sergeisadov/blurhash/internal/base83"
"github.com/sergeisadov/blurhash/pkg/utils"
)
const bytesPerPixel = 4
const (
minComponent = 1
maxComponent = 9
)
// Encode method takes custom img params and returns blurhash string as result
// components must be i... | pkg/blurhash/encode.go | 0.781289 | 0.416322 | encode.go | starcoder |
package objects
//Binary (0.0.0.0/4): Binary protocols
//This is a superclass for classes that are generally unreadable in their plain form and require translation.
const PONumBinary = 0
const PODFMaskBinary = `0.0.0.0/4`
const PODFBinary = `0.0.0.0`
const POMaskBinary = 4
//Text (192.168.127.12/4): Human readable t... | vendor/github.com/immesys/bw2/objects/poSymNames.go | 0.679604 | 0.486819 | poSymNames.go | starcoder |
package main
/*
You are given two strings s and p where p is a subsequence of s.
You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed).
You want to choose an integer k (0 <= k <= removable.length) such that,
after removing k characters from s using t... | golang/algorithms/others/maximum_number_of_removable_characters/main.go | 0.84124 | 0.596727 | main.go | starcoder |
package data
import (
"time"
)
// Condition defines parameters to look for in a sample. Either SampleType or SampleID
// (or both) can be set. They can't both be "".
type Condition struct {
ID string
Description string
NodeID string
PointType string
PointID string
PointIndex ... | data/rule.go | 0.681197 | 0.53206 | rule.go | starcoder |
package pnn
import (
"container/heap"
"github.com/fiwippi/go-quantise/pkg/colours"
"image"
"image/color"
"math"
"sort"
)
// Used as a variable for each pnn operation to determine what type of distance calculation to use,
// this variable is available for the whole scope of the pnn operation
type PNNMode uint8
... | internal/quantisers/pnn/colour.go | 0.649467 | 0.424173 | colour.go | starcoder |
package bsc
import (
"github.com/jesand/stats"
"github.com/jesand/stats/channel"
"github.com/jesand/stats/dist"
"github.com/jesand/stats/factor"
"github.com/jesand/stats/variable"
"math/rand"
)
// Create a new binary symmetric channel with the specified noise rates.
func NewBSCPair(noiseRate1, noiseRate2 float6... | channel/bsc/bsc_pair.go | 0.794903 | 0.631324 | bsc_pair.go | starcoder |
// Package vga provides the VGA 256-color default palette, famously used in
// video mode 13h.
// See also https://en.wikipedia.org/wiki/Video_Graphics_Array#Color_palette
package vga
import "image/color"
// DefaultPalette is the VGA 256-color default palette. It can be used as a
// color.Palette from the standard l... | palette.go | 0.755907 | 0.712145 | palette.go | starcoder |
package bow
import (
"fmt"
"github.com/apache/arrow/go/arrow/array"
"github.com/apache/arrow/go/arrow/bitutil"
)
func NewBuffer(size int, typ Type) Buffer {
switch typ {
case Int64:
return Buffer{
Data: make([]int64, size),
nullBitmapBytes: make([]byte, bitutil.CeilByte(size)/8),
}
case F... | bowbuffer.gen.go | 0.508056 | 0.424114 | bowbuffer.gen.go | starcoder |
package lib
import (
"encoding"
"encoding/base64"
"fmt"
"gopkg.in/dedis/crypto.v0/abstract"
"gopkg.in/dedis/crypto.v0/random"
"gopkg.in/dedis/onet.v1/log"
"gopkg.in/dedis/onet.v1/network"
"strings"
"sync"
)
// MaxHomomorphicInt is upper bound for integers used in messages, a failed decryption will return thi... | lib/crypto.go | 0.620507 | 0.449513 | crypto.go | starcoder |
package restaurants_us
const PAGE_SIZE_LIMIT = 50
const ROW_LIMIT = 500
type restuarantsUSData struct {
factual_id string "The Factual ID"
name string "Business/POI name"
address string "Address number and street name"
address_extended string "Additional address, inc... | social_integretions/factual-integretion/factual_go_driver/table/restaurants_us/restaurants_us.go | 0.631481 | 0.467089 | restaurants_us.go | starcoder |
package iso20022
// Safekeeping or investment account. A safekeeping account is an account on which a securities entry is made. An investment account is an account between an investor(s) and a fund manager or a fund. The account can contain holdings in any investment fund or investment fund class managed (or distribut... | SafekeepingAccount2.go | 0.693161 | 0.5169 | SafekeepingAccount2.go | starcoder |
package iso20022
// Specifies rates related to a corporate action option.
type CorporateActionRate79 struct {
// Rate used for additional tax that cannot be categorised.
AdditionalTax *RateAndAmountFormat46Choice `xml:"AddtlTax,omitempty"`
// Cash dividend amount per equity before deductions or allowances have be... | CorporateActionRate79.go | 0.863909 | 0.609873 | CorporateActionRate79.go | starcoder |
package gomfa
func Epb(dj1 float64, dj2 float64) float64 {
/*
** - - - -
** E p b
** - - - -
**
** Julian Date to Besselian Epoch.
**
** Given:
** dj1,dj2 float64 Julian Date (see note)
**
** Returned (function value):
** float64 Besselian Epoch.
**
** N... | epb.go | 0.766818 | 0.569853 | epb.go | starcoder |
package finance
import "github.com/hyperjiang/php"
// Loan is a loan, default method is EqualPayment
type Loan struct {
Amount float64
Periods int
AnnualRate float64
Method int
}
// Installment is an installment
type Installment struct {
Period int
Payment float64
Principal f... | installment.go | 0.687 | 0.598254 | installment.go | starcoder |
package led
import (
"bytes"
"github.com/pkg/term"
)
// StartTerm starts a terminal.
func StartTerm(ts ...Iterm) *Term {
t := Term{}
if len(ts) > 0 {
t.tty = ts[0]
} else {
t.tty = &termWrap{}
}
t.tty.Start()
return &t
}
// Term represents a terminal
type Term struct {
tty Iterm
pos int
}
// Read retu... | term.go | 0.698946 | 0.439988 | term.go | starcoder |
// Package function implements some functions for control the function execution and some is for functional programming.
package function
import (
"reflect"
"time"
)
// After creates a function that invokes func once it's called n or more times
func After(n int, fn any) func(args ...any) []reflect.Value {
// Catc... | function/function.go | 0.639961 | 0.414366 | function.go | starcoder |
package triangulate
import (
"fmt"
)
func cross(v0x, v0y, v1x, v1y float32) float32 {
return v0x*v1y - v0y*v1x
}
func triangleCross(pt0, pt1, pt2 Point) float32 {
return cross(pt1.X-pt0.X, pt1.Y-pt0.Y, pt2.X-pt1.X, pt2.Y-pt1.Y)
}
func adjacentIndices(indices []uint16, idx int) (uint16, uint16, uint16) {
return... | vector/internal/triangulate/triangulate.go | 0.606498 | 0.405566 | triangulate.go | starcoder |
package value
import (
"math/big"
)
// Binary operators.
// To avoid initialization cycles when we refer to the ops from inside
// themselves, we use an init function to initialize the ops.
// binaryArithType returns the maximum of the two types,
// so the smaller value is appropriately up-converted.
func binaryA... | vendor/robpike.io/ivy/value/binary.go | 0.794584 | 0.644868 | binary.go | starcoder |
Package cache implements data structures used by the kubelet plugin manager to
keep track of registered plugins.
*/
package cache
import (
"fmt"
"sync"
"time"
"k8s.io/klog"
)
// ActualStateOfWorld defines a set of thread-safe operations for the kubelet
// plugin manager's actual state of the world cache.
// This... | pkg/kubelet/pluginmanager/cache/actual_state_of_world.go | 0.678647 | 0.468973 | actual_state_of_world.go | starcoder |
Package stats implements statistics collection and reporting.
It is used by server to report internal statistics, such as number of
requests and responses.
*/
package stats
import (
"fmt"
"strings"
"sync"
ptp "github.com/facebook/time/ptp/protocol"
)
// Stats is a metric collection interface
type Stats interface... | ptp/ptp4u/stats/stats.go | 0.612541 | 0.457258 | stats.go | starcoder |
package types
import (
"encoding/json"
"math"
"testing"
"math/big"
"math/rand"
)
func newIntegerFromString(s string) (*big.Int, bool) {
return new(big.Int).SetString(s, 0)
}
func equal(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 0 }
func gt(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 1 }
fun... | types/int.go | 0.713132 | 0.422981 | int.go | starcoder |
package ir
import (
"fmt"
"reflect"
"strings"
)
// Operand is an interface for instruction operands.
type Operand interface {
fmt.Stringer
operand() // sealed
}
// Register is a machine word operand.
type Register string
func (r Register) String() string { return string(r) }
func (Register) operand() {}
// ... | arith/ir/isa.go | 0.709623 | 0.45048 | isa.go | starcoder |
package expression
import (
"fmt"
"github.com/dolthub/go-mysql-server/sql"
)
// InTuple is an expression that checks an expression is inside a list of expressions.
type InTuple struct {
BinaryExpression
}
// We implement Comparer because we have a Left() and a Right(), but we can't be Compare()d
var _ Comparer ... | vendor/github.com/dolthub/go-mysql-server/sql/expression/in.go | 0.801819 | 0.472744 | in.go | starcoder |
package conf
import "strings"
type queryStringValue map[string]string
func newQueryStringValue(val map[string]string, p *map[string]string) *queryStringValue {
*p = val
return (*queryStringValue)(p)
}
func (p queryStringValue) Set(val string) error {
// Clear the map from default values
for k := range p {
de... | value_query_string.go | 0.788461 | 0.48688 | value_query_string.go | starcoder |
package animation
import (
"math"
"time"
"github.com/go-game/go-game/gfx"
)
// NewTween returns a new Tween for two Params, where start and end are the two Params to be interpolated.
// offset indicates the duration after which the interpolation starts. looping indicates if the interpolation should go
// back to ... | gfx/animation/tween.go | 0.781831 | 0.436682 | tween.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"time"
)
// TstzRangeArrayFromTimeArray2Slice returns a driver.Valuer that produces a PostgreSQL tstzrange[] from the given Go [][2]time.Time.
func TstzRangeArrayFromTimeArray2Slice(val [][2]time.Time) driver.Valuer {
return tstzRangeArrayFromTimeArray2S... | pgsql/tstzrangearr.go | 0.668664 | 0.468791 | tstzrangearr.go | starcoder |
package storage
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/concerto/api/types"
"github.com/ingrammicro/concerto/utils"
"github.com/stretchr/testify/assert"
)
// TODO exclude from release compile
// GetVolumeListMocked test mocked function
func GetVolumeListMocked(t *testing.T, volumesIn ... | api/storage/volumes_api_mocked.go | 0.506591 | 0.465327 | volumes_api_mocked.go | starcoder |
package yologo
import (
"fmt"
"image"
"sort"
"gorgonia.org/tensor"
)
// DetectionRectangle Representation of detection
type DetectionRectangle struct {
conf float32
rect image.Rectangle
class string
score float32
}
func (dr *DetectionRectangle) String() string {
return fmt.Sprintf("Detection:\n\tClass = ... | detections.go | 0.706899 | 0.477189 | detections.go | starcoder |
package quicktime
import "errors"
import "fmt"
// A STBLAtom stores the three Atoms requires to look up the file offset of
// an individual frame ("sample") in the file: STSZ (sample size),
// STCO or CO64 (chunk offset) and STSC (samples per chunk)
type STBLAtom struct {
Stsz STSZAtom
Stco CO64Atom
Stsc STSCAtom... | stbl_atom.go | 0.657648 | 0.51879 | stbl_atom.go | starcoder |
package processor
import (
"bytes"
"encoding/json"
"fmt"
"time"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/tracing"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/b... | lib/processor/jq.go | 0.771155 | 0.719882 | jq.go | starcoder |
package gl
import (
"image/color"
"fyne.io/fyne"
"fyne.io/fyne/canvas"
"fyne.io/fyne/internal/cache"
"fyne.io/fyne/internal/painter"
)
func rectInnerCoords(size fyne.Size, pos fyne.Position, fill canvas.ImageFill, aspect float32) (fyne.Size, fyne.Position) {
if fill == canvas.ImageFillContain || fill == canvas... | internal/painter/gl/draw.go | 0.706494 | 0.438485 | draw.go | starcoder |
package qrcode
import (
"github.com/yeqown/go-qrcode/matrix"
)
// maskPatternModulo ...
// mask Pattern ref to: https://www.thonky.com/qr-code-tutorial/mask-patterns
type maskPatternModulo uint32
const (
// modulo0 (x+y) mod 2 == 0
modulo0 maskPatternModulo = iota
// modulo1 (x) mod 2 == 0
modulo1
// modulo2 (... | mask.go | 0.590307 | 0.548008 | mask.go | starcoder |
package main
import (
"fmt"
)
// Defines the minimum set of functions needed for a Feature.
type Feature interface {
Add(int64) // Add a particular value to a feature
Export() string // Export the contents of a feature in string form
Get() int64
Set(int64) // Reset the feature to a particular val... | features.go | 0.59972 | 0.462291 | features.go | starcoder |
package llvmutil
// This file contains utility functions to pack and unpack sets of values. It
// can take in a list of values and tries to store it efficiently in the pointer
// itself if possible and legal.
import (
"tinygo.org/x/go-llvm"
)
// EmitPointerPack packs the list of values into a single pointer value u... | compiler/llvmutil/wordpack.go | 0.626467 | 0.549278 | wordpack.go | starcoder |
package mutable
import (
"github.com/pkg/errors"
"github.com/chris-tomich/immutability-benchmarking"
)
// Matrix is a matrix with mutating operations.
type Matrix struct {
matrix [immutabilitybenchmarking.MatrixHeight][immutabilitybenchmarking.MatrixWidth]int
}
// New creates a new matrix with the given initial v... | array/mutable/matrix.go | 0.858526 | 0.726207 | matrix.go | starcoder |
package sedpf
import (
"fmt"
"math"
)
type Gaussian struct {
Mean float64
Variance float64
}
func sum(elems []float64) float64 {
var a float64 = 0
for i := 0; i < len(elems); i++ {
a += elems[i]
}
return a
}
func NewGaussian(Mean, Variance float64) Gaussian {
return Gaussian{
Mean: Mean,
Vari... | src/sedpf/gaussian.go | 0.924492 | 0.57087 | gaussian.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.