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 zipcodes
import (
"bufio"
"errors"
"fmt"
"io"
"log"
"math"
"os"
"strconv"
"strings"
)
const (
earthRadiusKm = 6371
earthRadiusMi = 3958
)
// ZipCodeLocation struct represents each line of the dataset
type ZipCodeLocation struct {
ZipCode string
PlaceName string
AdminName... | zipcodes.go | 0.78785 | 0.500549 | zipcodes.go | starcoder |
package rotate
import (
"fluorescence/geometry"
"fluorescence/geometry/primitive"
"fluorescence/geometry/primitive/aabb"
"fluorescence/shading/material"
"fmt"
"strings"
"github.com/go-gl/mathgl/mgl64"
)
// Quaternion is a quaternion rotation
type Quaternion struct {
AxisAngles [3]float64 `json:"axis_angles"... | geometry/primitive/transform/rotate/quaternion.go | 0.865452 | 0.562777 | quaternion.go | starcoder |
package dna
import (
"log"
)
// ToUpper changes the input base to uppercase.
func ToUpper(b Base) Base {
switch b {
case LowerA:
return A
case LowerC:
return C
case LowerG:
return G
case LowerT:
return T
case LowerN:
return N
default:
return b
}
}
// ToLower changes the input base to lowercase.
... | dna/modify.go | 0.696062 | 0.504089 | modify.go | starcoder |
package ratelimiter
import (
"sync"
"time"
)
type MultiLimiter struct {
mu *sync.RWMutex
limitChanMap map[string]*singleLimiter
ticker *time.Ticker
cancelChan chan struct{}
}
type singleLimiter struct {
chunk int // size of increase
limitChan chan struct{}
}
// NewMultiLimiter returns ... | multi-tenant-limiter.go | 0.578329 | 0.400251 | multi-tenant-limiter.go | starcoder |
package pgo
type PairFlags uint32
const (
/**
\brief Process the contacts of this collision pair in the dynamics solver.
\note Only takes effect if the colliding actors are rigid bodies.
*/
PairFlags_eSOLVE_CONTACT PairFlags = (1 << 0)
/**
\brief Call contact modification callback for this collision pair
\... | pgo/pairFlags.go | 0.802362 | 0.603552 | pairFlags.go | starcoder |
package fastbytes
import (
"reflect"
"github.com/yehan2002/errors"
"github.com/yehan2002/fastbytes/v2/internal"
)
const (
// ErrUnsupported the given type is not supported.
// All signed and unsigned intergers except uint and int, and floats are supported
// uint and int are unsupported since their size is pl... | bytes.go | 0.63023 | 0.423637 | bytes.go | starcoder |
package filebuf
/* A binary node that holds Data */
type node struct {
left, right, parent *node
data data
size int64 //left.size + data.size + right.size
}
func mkNode(d data) *node {
return &node{data: d, size: d.Size()}
}
//Copy this node
func (t *node) Copy() *node {
if t == ni... | node.go | 0.607547 | 0.438725 | node.go | starcoder |
package bsonkit
import (
"fmt"
"sort"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// MustConvert will call Convert and panic on errors.
func MustConvert(v interface{}) Doc {
doc, err := Convert(v)
if err != nil {
panic("bsonkit: " + err.Error())
}
return doc
}... | bsonkit/convert.go | 0.675229 | 0.414543 | convert.go | starcoder |
package scenario
import (
"fmt"
"math"
"math/rand"
"sort"
)
func Generate(name string) (Execution, error) {
g, ok := generators[name]
if !ok {
return Execution{}, fmt.Errorf("generator %q not found", name)
}
return generate(g()), nil
}
func Generators() []string {
var s []string
for name := range generat... | scenario/generators.go | 0.515132 | 0.411052 | generators.go | starcoder |
package tok
import (
"strings"
)
// Tracker is an interface that can be coupled with a Scannar and track the movemend.
type Tracker interface {
Update(m Marker)
}
// Returns a new empty Basket that is coupled as Tracker on the scanner.
func (s *Scanner) NewBasket() *Basket {
b := &Basket{}
s.Tracker = b
return ... | tracker.go | 0.791015 | 0.450239 | tracker.go | starcoder |
package neuron
import (
"fmt"
)
// A Net is a neural network consisting of a sequence of layers, each of which
// contains one or more Units. Arch defines the layer sizes. Layers points to
// each of the units in each of the layers.
type Net struct {
// Size of each layer
Arch []int
// Pointers to the units in ea... | net.go | 0.60743 | 0.511412 | net.go | starcoder |
package interp
import (
"fmt"
"math"
"math/cmplx"
"strconv"
"strings"
)
type valueType uint8
const (
typeNil valueType = iota
typeStr
typeNum
)
// An AWK value (these are passed around by value)
type value struct {
typ valueType // Value type
isNumStr bool // An AWK "numeric string" from user... | interp/value.go | 0.677154 | 0.442877 | value.go | starcoder |
package mandelbrot
import (
"image"
"image/color"
"image/draw"
"image/gif"
"image/png"
"math"
"os"
"sync"
)
type Drawer interface {
Draw(minX, maxX, minY, maxY float64, colors []color.Color) *image.RGBA
Gif(frames uint16, x, y, scaleIn float64, colors []color.Color) *gif.GIF
SetSize(sizeX, sizeY uint16)
S... | mandelbrot.go | 0.736116 | 0.458894 | mandelbrot.go | starcoder |
package projecteuler
import (
"fmt"
"math"
"math/big"
)
// ChakravalaTriplet holds X, Y, K which are solution to X^2 - N*Y^2 = K
type ChakravalaTriplet struct {
X *big.Int
Y *big.Int
K int64
}
func (c *ChakravalaTriplet) assign(rhs ChakravalaTriplet) {
c.X.Set(rhs.X)
c.Y.Set(rhs.Y)
c.K = rhs.K
}
func (c Ch... | chakravala.go | 0.632957 | 0.462959 | chakravala.go | starcoder |
package backend
type Instruction interface {
Generate() []byte
}
// Halt
// - takes no arguments, unconditionally stops program execution
// - typically appended to the end of the top-level main function
type Halt struct{}
// Generate converts this instruction to raw bytes
func (inst Halt) Generate() (blob []byte... | backend/instructions.go | 0.756627 | 0.50177 | instructions.go | starcoder |
package resourcefilter
import (
"fmt"
"cloud.google.com/go/spanner/spansql"
"github.com/google/cel-go/common/operators"
expr "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)
func exprToSpannerSQL(e *expr.Expr) (spansql.Expr, error) {
switch e := e.ExprKind.(type) {
case *expr.Expr_CallExpr:
switch... | internal/resourcefilter/spansql.go | 0.538741 | 0.461623 | spansql.go | starcoder |
package batch
import "github.com/Jeffail/benthos/v3/lib/x/docs"
// FieldSpec returns a spec for a common batching field.
func FieldSpec() docs.FieldSpec {
return docs.FieldSpec{
Name: "batching",
Description: `
Allows you to configure a [batching policy](/docs/configuration/batching).`,
Examples: []interface{}... | lib/message/batch/docs.go | 0.788909 | 0.44065 | docs.go | starcoder |
package series
import (
"fmt"
"reflect"
"github.com/go-gota/gota/series"
"github.com/gojek/merlin/pkg/transformer/types/converter"
)
type Type string
const (
String Type = "string"
Int Type = "int"
Float Type = "float"
Bool Type = "bool"
)
var numericTypes = []Type{Int, Float}
type Series struct {
... | api/pkg/transformer/types/series/series.go | 0.665193 | 0.470068 | series.go | starcoder |
package dyff
import (
"regexp"
"github.com/gonvenience/ytbx"
)
func (r Report) filter(hasPath func(*ytbx.Path) bool) (result Report) {
result = Report{
From: r.From,
To: r.To,
}
for _, diff := range r.Diffs {
if hasPath(diff.Path) {
result.Diffs = append(result.Diffs, diff)
}
}
return result
}
... | pkg/dyff/reports.go | 0.743634 | 0.419291 | reports.go | starcoder |
package nn
import (
"fmt"
"math/rand"
"sync"
)
// Layer is a layer of neural network.
type Layer interface {
InputShape() Shape
OutputShape() Shape
Init(inputShape Shape, factory OptimizerFactory) error
Call(inputs []*Tensor) []*Tensor
Forward(inputs []*Tensor) []*Tensor
Backward(douts []*Tensor) []*Tensor
... | nn/layer.go | 0.728941 | 0.534309 | layer.go | starcoder |
package doudizhu
import (
"game/internal/poker"
"reflect"
)
type cardPatternQuadrupletWithPairs struct {
cardPatternBase
}
func (r cardPatternQuadrupletWithPairs) Name() string {
return reflect.TypeOf(r).Name()
}
func (r cardPatternQuadrupletWithPairs) Valid() bool {
r.Cards().Sort(DoudizhuValueRanks)
if r.Ca... | internal/poker/doudizhu/cardPatternQuadrupletWithPairs.go | 0.524395 | 0.445952 | cardPatternQuadrupletWithPairs.go | starcoder |
package elastic
// The geo_distance facet is a facet providing information for ranges of
// distances from a provided geo_point including count of the number of hits
// that fall within each range, and aggregation information (like total).
// See: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/... | search_facets_geo_distance.go | 0.899689 | 0.52616 | search_facets_geo_distance.go | starcoder |
package output
import (
"fmt"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message/batch"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
)
//---------------------------------------------------... | lib/output/dynamodb.go | 0.796094 | 0.790369 | dynamodb.go | starcoder |
package gomovie
import "io"
//SampleInt16 describes a single 16 bit sample
type SampleInt16 int16
//ToFloat Normalizes the sample to a value between -1 and 1
func (p SampleInt16) Float() float32 {
return float32(p) / float32(32768.)
}
//SampleInt32 describes a single 32 bit sample
type SampleInt32 int32
//ToFloat... | sample.go | 0.786582 | 0.562657 | sample.go | starcoder |
package enhanced
import "github.com/samuel/go-zookeeper/zk"
type nsBasicOperations struct {
basicOperations
*namespace
}
func newNSBasicOperations(conner Conner, ns *namespace) nsBasicOperations {
return nsBasicOperations{
basicOperations: newBasicOperations(conner),
namespace: ns,
}
}
// Get fetches ... | enhanced/ns_basic_operations.go | 0.736874 | 0.466846 | ns_basic_operations.go | starcoder |
package modis
import (
"errors"
"fmt"
"math"
"github.com/nordicsense/gdal"
)
// ModisKWT defines the MODIS projection.
const ModisWKT = `PROJCS["MODIS",
GEOGCS["Unknown datum based upon the custom spheroid",
DATUM["Not specified (based on custom spheroid)",
SPHEROID["Custom spheroid",6371... | units.go | 0.762336 | 0.412294 | units.go | starcoder |
package main
/*
1. think of pre-processing steps: sort, arrange the data, index the data, prefix sums!
2. split into small functions which you will implement later
3. solution scanning and offer alternatives (always talk about complexity in space and time)
1. pattern matching (find similar problems)
2. simplify and ... | go/interview/codility/7_3_fish/main.go | 0.630685 | 0.648327 | main.go | starcoder |
package main
func (e *event) date() string {
// 0 - date
// example: ["09/Jul/2020 16:34:27",
return e.raw[0].(string)
}
func (e *event) device() string {
// 1 - device
// example: "RockBLOCK 18388",
return e.raw[1].(string)
}
func (e *event) direction() string {
// 2 - direction. MO: from... | btm/event_fields.go | 0.860369 | 0.434941 | event_fields.go | starcoder |
package packet
import (
"bytes"
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
const (
BlockToEntityTransition = iota + 1
EntityToBlockTransition
)
// UpdateBlockSynced is sent by the server to synchronise the falling of a falling block entity with the
// transitioning back and forth from and to a solid... | minecraft/protocol/packet/update_block_synced.go | 0.593374 | 0.442275 | update_block_synced.go | starcoder |
package protocol
import (
"errors"
"fmt"
"io"
"math/big"
"github.com/ethereum/go-ethereum/common"
solsha3 "github.com/miguelmota/go-solidity-sha3"
"github.com/offchainlabs/arbitrum/packages/arb-util/value"
)
type Identity [32]byte
type TokenType [21]byte
func TokenTypeFromIntValue(val value.IntValue) TokenT... | packages/arb-util/protocol/message.go | 0.621656 | 0.409162 | message.go | starcoder |
package stick
// Registry is a multi-key index of typed values.
type Registry[T any] struct {
validator func(T) error
indexer []func(T) string
indexes []map[string]T
list []T
}
// NewRegistry will create and return a new registry using the specified index
// functions that must return unique keys.
func N... | stick/registry.go | 0.60871 | 0.419053 | registry.go | starcoder |
package caseconversion
import (
"fmt"
"go/token"
"strings"
"unicode"
"unicode/utf8"
)
// DecodeCasingFunc takes in an identifier in a case such as camelCase or
// snake_case and splits it up into a DecodedIdentifier for encoding by an
// EncodeCasingFunc into a different case.
type DecodeCasingFunc func(string) ... | tagformat/caseconversion/case_conversion.go | 0.525125 | 0.447521 | case_conversion.go | starcoder |
package sparql
import (
"io"
)
// reader represents a buffered rune reader used by the scanner.
// It provides a fixed-length circular buffer that can be unread.
type reader struct {
r io.RuneScanner
i int // buffer index
n int // buffer char count
pos Pos // last read rune position
buf [3]struct {
ch ... | sparql/reader.go | 0.695648 | 0.413122 | reader.go | starcoder |
package calculator
import (
"fmt"
"math"
)
// Add takes two numbers and returns the
// result of adding them together
func Add(inputs ...float64) float64 {
var result float64 = 0
for _, input := range inputs {
result += input
}
return result
}
// Substract takes two numbers and returns the
// result of subst... | calculator.go | 0.745954 | 0.588268 | calculator.go | starcoder |
package statsrunner
import (
"fmt"
"sort"
"gonum.org/v1/gonum/stat"
)
// calcRelativeFrequency calculates the relative frequency for a given set of observations obs
func calcRelativeFrequency(obs []string) map[string]float64 {
result := make(map[string]float64)
totalObservations := len(obs)
if totalObservation... | statsrunner/statistics.go | 0.861553 | 0.565599 | statistics.go | starcoder |
package epochdate
import (
"database/sql/driver"
"errors"
"time"
)
const (
day = 60 * 60 * 24
nsPerSec = 1e9
maxUnix = (1<<16)*day - 1
)
const (
RFC3339 = "2006-01-02"
AmericanShort = "1-2-06"
AmericanCommon = "01-02-06"
)
var ErrOutOfRange = errors.New("The given date is out of range")
type... | epochdate.go | 0.770206 | 0.462776 | epochdate.go | starcoder |
package random
import (
"math"
"math/rand"
"github.com/DexterLB/traytor/maths"
)
// Random is a random generator with convenient methods
type Random struct {
generator *rand.Rand
}
// New returns a new Random object initialized with the given seed
func New(seed int64) *Random {
r := &Random{}
source := rand.N... | random/random.go | 0.840095 | 0.483648 | random.go | starcoder |
package stcdetail
import (
"github.com/xdrpp/goxdr/xdr"
"reflect"
"strings"
)
type trivSprintf struct{}
func (trivSprintf) Sprintf(f string, args ...interface{}) string {
return ""
}
// Marshal an XDR type to the raw binary bytes defined in RFC4506.
// The return value is binary, not UTF-8. For most marshaling... | stcdetail/xdrmisc.go | 0.59749 | 0.420957 | xdrmisc.go | starcoder |
package grid
import (
"math"
"sort"
"strconv"
"strings"
)
func stringToDir(token string) direction {
switch strings.ToLower(token) {
case "u":
return up
case "r":
return right
case "d":
return down
case "l":
return left
default:
return up
}
}
func parse(arg string) (movementSlice, error) {
spli... | pkg/grid/grid.go | 0.546496 | 0.490175 | grid.go | starcoder |
package main
import (
"fmt"
"math"
"math/rand"
)
// Vec3 is a vector of three items X, Y, Z.
type Vec3 struct {
X float64
Y float64
Z float64
}
// NewRandomVec3 generate a random Vec3.
func NewRandomVec3() *Vec3 {
return &Vec3{
X: rand.Float64(),
Y: rand.Float64(),
Z: rand.Float64(),
}
}
// NewRandomI... | vector.go | 0.837487 | 0.532486 | vector.go | starcoder |
package expectation
import (
"fmt"
"reflect"
"github.com/goldenspider/gspec/errors"
)
// Checker is the type of function that checks between actual and expected value
// then returns an Error if the expectation fails.
type Checker func(actual, expected interface{}, name string, skip int) error
// Equal checks f... | expectation/checker.go | 0.812644 | 0.607896 | checker.go | starcoder |
package jsonassert
import (
"fmt"
"reflect"
)
type JSONComparator interface {
CompareJSONObject(expected, actual JSONNode) *JSONCompareResult
CompareJSONArray(expected, actual JSONNode) *JSONCompareResult
CompareJSONObjectWithPrefix(prefix string, expected, actual JSONNode, result *JSONCompareResult)
CompareJSO... | comparators.go | 0.610453 | 0.534248 | comparators.go | starcoder |
Goom Voice
https://www.quinapalus.com/goom.html
*/
//-----------------------------------------------------------------------------
package goom
import (
"github.com/deadsy/babi/core"
"github.com/deadsy/babi/module/env"
"github.com/deadsy/babi/module/filter"
"github.com/deadsy/babi/module/osc"
"github.com/dead... | module/goom/voice.go | 0.63307 | 0.469885 | voice.go | starcoder |
package test_clients
import (
"testing"
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
cerr "github.com/pip-services3-go/pip-services3-commons-go/errors"
tdata "github.com/pip-services3-go/pip-services3-rpc-go/test/data"
"github.com/stretchr/testify/assert"
)
type DummyClientFixture struct {
... | test/clients/DummyClientFixture.go | 0.590543 | 0.454593 | DummyClientFixture.go | starcoder |
package master
import (
"math/rand"
"sync"
"time"
"github.com/chubaofs/chubaofs/proto"
"github.com/chubaofs/chubaofs/util"
)
// DataNode stores all the information about a data node
type DataNode struct {
Total uint64 `json:"TotalWeight"`
Used uint64 `json:"UsedWeight"`
AvailableSpace uin... | master/data_node.go | 0.52342 | 0.403508 | data_node.go | starcoder |
package chunk
import (
"github.com/df-mc/dragonfly/server/block/cube"
"sync"
)
// Chunk is a segment in the world with a size of 16x16x256 blocks. A chunk contains multiple sub chunks
// and stores other information such as biomes.
// It is not safe to call methods on Chunk simultaneously from multiple goroutines.
... | server/world/chunk/chunk.go | 0.729231 | 0.605187 | chunk.go | starcoder |
// Package pointer provides the access to the pointing device of the device,
// either of the mouse or the touch.
package pointer
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/uiauto"
"chromiumos/tast/local/chrome/uiau... | src/chromiumos/tast/local/chrome/uiauto/pointer/pointer.go | 0.753104 | 0.401101 | pointer.go | starcoder |
//go:generate go run gen-benchmarks.go
// Package mathNodes defines the floating-point function collection available for the GEP algorithm.
package mathNodes
import (
"log"
"math"
"github.com/gmlewis/gep/v2/functions"
)
// MathNode is a floating-point function used for the formation of GEP expressions.
type Mat... | functions/math_nodes/math.go | 0.572006 | 0.720528 | math.go | starcoder |
package distuv
import (
"math"
"golang.org/x/exp/rand"
)
// Bernoulli represents a random variable whose value is 1 with probability p and
// value of zero with probability 1-P. The value of P must be between 0 and 1.
// More information at https://en.wikipedia.org/wiki/Bernoulli_distribution.
type Bernoulli stru... | stat/distuv/bernoulli.go | 0.919737 | 0.787278 | bernoulli.go | starcoder |
package common
import (
"github.com/keshav-kk/tsbs/pkg/data"
"time"
)
// SubsystemMeasurement represents a collection of measurement distributions and a start time.
type SubsystemMeasurement struct {
Timestamp time.Time
Distributions []Distribution
}
// NewSubsystemMeasurement creates a new SubsystemMeasurem... | pkg/data/usecases/common/measurement.go | 0.779448 | 0.48377 | measurement.go | starcoder |
package mapper
import (
"fmt"
"strconv"
"strings"
"github.com/7vars/leikari/query"
)
func ApplyFilter(node query.Node, v interface{}, mapname ...MapName) bool {
switch n := node.(type) {
case query.All:
return true
case query.Comparsion:
switch n.Value().Type() {
case query.INT:
if va, ok := Int64Val... | mapper/node.go | 0.541166 | 0.429071 | node.go | starcoder |
package fastjson
import (
"fmt"
"strconv"
)
func (arr *jsonArray) Size() int {
return len(arr.value)
}
func (arr *jsonArray) IsZero() bool {
return arr.Size() == 0
}
func (arr *jsonArray) ContainsIndex(index int) bool {
return arr.Size() > index
}
func (arr *jsonArray) GetInt(index int) (int, error) {
if !ar... | json_array.go | 0.539226 | 0.429908 | json_array.go | starcoder |
package internal
import (
"github.com/Vale-sail/maroto/pkg/color"
"github.com/Vale-sail/maroto/pkg/consts"
"github.com/Vale-sail/maroto/pkg/props"
)
// MarotoGridPart is the abstraction to deal with the gris system inside the table list
type MarotoGridPart interface {
// Grid System
Row(height float64, closure f... | internal/tablelist.go | 0.577972 | 0.448849 | tablelist.go | starcoder |
package stripe
import "encoding/json"
// A unit of time.
type ShippingRateDeliveryEstimateMaximumUnit string
// List of values that ShippingRateDeliveryEstimateMaximumUnit can take
const (
ShippingRateDeliveryEstimateMaximumUnitBusinessDay ShippingRateDeliveryEstimateMaximumUnit = "business_day"
ShippingRateDeliv... | shippingrate.go | 0.886948 | 0.459501 | shippingrate.go | starcoder |
package runtime
import (
"fmt"
"github.com/onflow/cadence"
"github.com/onflow/cadence/runtime/common"
"github.com/onflow/cadence/runtime/sema"
"github.com/onflow/cadence/runtime/stdlib"
)
// exportType converts a runtime type to its corresponding Go representation.
func exportType(t sema.Type, results map[sema.... | runtime/convertTypes.go | 0.641871 | 0.465509 | convertTypes.go | starcoder |
package stats
// Coverage represents a REST API statistics
type Coverage struct {
UniqueHits int `json:"uniqueHits"`
ExpectedUniqueHits int `json:"expectedUniqueHits"`
Percent float64 `json:"percent"`
Endpoints ... | vendor/github.com/mfranczy/crd-rest-coverage/pkg/stats/types.go | 0.863607 | 0.447038 | types.go | starcoder |
package byteutil
// GfnDouble computes 2 * input in the field of 2^n elements.
// The irreducible polynomial in the finite field for n=128 is
// x^128 + x^7 + x^2 + x + 1 (equals 0x87)
// Constant-time execution in order to avoid side-channel attacks
func GfnDouble(input []byte) []byte {
if len(input) != 16 {
pani... | byteutil/byteutil.go | 0.757794 | 0.563798 | byteutil.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// EducationCourse
type EducationCourse struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for s... | models/microsoft/graph/education_course.go | 0.650023 | 0.408218 | education_course.go | starcoder |
package kate
// warning: the values in `a` are modified in-place to become the outputs.
// Make a deep copy first if you need to use them later.
func (fs *FFTSettings) dASFFTExtension(ab []Big, domainStride uint64) {
if len(ab) == 2 {
aHalf0 := &ab[0]
aHalf1 := &ab[1]
var x Big
addModBig(&x, aHalf0, aHalf1)
... | das_extension.go | 0.52829 | 0.450057 | das_extension.go | starcoder |
package evaluator
import (
"math"
"strings"
"github.com/mzrimsek/zip-lang/src/zip/ast"
"github.com/mzrimsek/zip-lang/src/zip/object"
)
func evalPrefixExpression(operator string, right object.Object) object.Object {
switch operator {
case "!":
return evalBangOperatorExpression(right)
case "-":
return evalM... | src/zip/evaluator/expression_evaluating.go | 0.582016 | 0.513181 | expression_evaluating.go | starcoder |
// +build go1.14,!go1.15
package symbols
import (
"gonum.org/v1/plot"
"gonum.org/v1/plot/vg/draw"
"reflect"
)
func init() {
Symbols["gonum.org/v1/plot"] = map[string]reflect.Value{
// function, constant and variable definitions
"Align": reflect.ValueOf(plot.Align),
"DefaultFont": reflect.ValueOf(&pl... | pkg/internal/runtime/symbols/go1_14_gonum.org_v1_plot.go | 0.630571 | 0.429609 | go1_14_gonum.org_v1_plot.go | starcoder |
package parser
import (
"github.com/mzrimsek/zip-lang/src/zip/ast"
"github.com/mzrimsek/zip-lang/src/zip/token"
)
func (p *Parser) parseStatement() ast.Statement {
switch p.curToken.Type {
case token.LET:
return p.parseLetStatement()
case token.RETURN:
return p.parseReturnStatement()
case token.IDENT:
swi... | src/zip/parser/statement_parsing.go | 0.526099 | 0.447581 | statement_parsing.go | starcoder |
package query
import (
"bytes"
"encoding/gob"
"log"
"strings"
)
// A ManyManyNode is an association node that links one table to another table with a many-to-many relationship.
// Some of the columns have overloaded meanings depending on SQL or NoSQL mode.
type ManyManyNode struct {
nodeAlias
nodeCondition
nod... | pkg/orm/query/manyManyNode.go | 0.717309 | 0.498657 | manyManyNode.go | starcoder |
package geojson
import (
"encoding/json"
"github.com/ctessum/geom"
)
func decodeCoordinates(jsonCoordinates interface{}) []float64 {
array, ok := jsonCoordinates.([]interface{})
if !ok {
panic(&InvalidGeometryError{})
}
coordinates := make([]float64, len(array))
for i, element := range array {
var ok bool... | encoding/geojson/decode.go | 0.589362 | 0.464841 | decode.go | starcoder |
package analyze
import (
"github.com/Rhymond/go-money"
"github.com/ed-fx/go-soft4fx/internal/simulator"
"github.com/pkg/errors"
"math"
"strconv"
"time"
)
type Day struct {
day time.Weekday
NoOfTrades int
NoOfProfitTrades int
ProfitTradesInPips float64
ProfitTradesInMoney *money.Money
NoOfLos... | internal/simulator/analyze/weekday.go | 0.625438 | 0.501221 | weekday.go | starcoder |
package mathval
import (
"errors"
"io"
"math/big"
)
// Parser is a parser including a Scanner and a buffer
type Parser struct {
s *Scanner
buf struct {
tok Token // last read token
lit string // last read literal
n int // buffer size. Currently max=1 as no lookahead
}
}
// NewParser returns a new... | parser.go | 0.649023 | 0.456531 | parser.go | starcoder |
package wordvectors
import (
"bufio"
"encoding/gob"
"io"
"os"
"strconv"
"strings"
"sync"
log "github.com/sirupsen/logrus"
)
var mutex = &sync.RWMutex{}
const WordVectorsFile = "wv.gob"
// Config contains configuration for fasttext word vectors
type Config struct {
// WordVectorsFile is the path to the wor... | internal/clf/wordvectors/wordvectors.go | 0.692226 | 0.516047 | wordvectors.go | starcoder |
package docs
import (
"bytes"
"encoding/json"
"strings"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{.Description}}",
"title": "{{.Title}}",
"contact": {},
"v... | docs/docs.go | 0.523664 | 0.426441 | docs.go | starcoder |
// Package image implements functions to validate that the fields of image entities being passed
// into the API meet our requirements.
package image
import (
"errors"
"fmt"
ipb "github.com/grafeas/grafeas/proto/v1/image_go_proto"
)
// ValidateBasis validates that an image basis has all its required fields fille... | go/v1/api/validators/image/image.go | 0.627837 | 0.404272 | image.go | starcoder |
package main
import (
"math"
"strconv"
"github.com/TomasCruz/projecteuler"
)
/*
Problem 37; Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits
from left to right, and remain prime at each stage: 3797, 797, 97, and 7.
Similarly we can w... | 001-100/031-040/037/main.go | 0.636918 | 0.551574 | main.go | starcoder |
package mdutil
import (
"fmt"
"strings"
"github.com/gomarkdown/markdown/ast"
)
// RenderCode renders one-line code into a string.
func RenderCode(code string) string {
return fmt.Sprintf("`%s`", code)
}
// RenderCodeNode wraps RenderCode for *ast.Code node.
func RenderCodeNode(node *ast.Code) string {
return R... | pkg/markdown/render.go | 0.738858 | 0.796213 | render.go | starcoder |
package main
import "fmt"
func main() {
// --------------
// Built-in types
// --------------
// Type provides integrity and readability.
// - What is the amount of memory that we allocate?
// - What does that memory represent?
// Type can be specific such as int32 or int64.
// For example,
// - uint8 cont... | go/language/variable.go | 0.528047 | 0.473231 | variable.go | starcoder |
package render
import (
"image"
"image/color"
"math"
"github.com/oakmound/oak/alg/floatgeom"
"github.com/oakmound/oak/oakerr"
)
// A Polygon is a renderable that is represented by a set of in order points
// on a plane.
type Polygon struct {
*Sprite
Rect2 floatgeom.Rect2
points []floatgeom.Point2
}
// NewS... | render/polygon.go | 0.79166 | 0.67452 | polygon.go | starcoder |
package core
import "math"
const STEP_MAX = 26 /* 26*2 = 52 bits. */
/* Limits from EPSG:900913 / EPSG:3785 / OSGEO:41001 */
const LAT_MIN = -85.05112878
const LAT_MAX = 85.05112878
const LONG_MIN = -180
const LONG_MAX = 180
const D_R = (math.Pi / 180.0)
/// @brief Earth's quatratic mean radius for WGS-84
const EAR... | core/zhash.go | 0.782122 | 0.447219 | zhash.go | starcoder |
package stats
import (
"context"
"sync"
"sync/atomic" //lint:ignore faillint we can't use go.uber.org/atomic with a protobuf struct without wrapping it.
"time"
"github.com/dustin/go-humanize"
"github.com/go-kit/log"
)
type (
ctxKeyType string
Component int64
)
const (
statsKey ctxKeyType = "stats"
)
// C... | pkg/logqlmodel/stats/context.go | 0.746231 | 0.436862 | context.go | starcoder |
package storage
import (
"bytes"
"github.com/mkawserm/flamed/pkg/iface"
"os"
"testing"
)
func setKeyValuePair(t *testing.T, stateStorage iface.IStateStorage, inputDataTable []string) {
txn := stateStorage.NewTransaction()
if txn == nil {
t.Fatal("unexpected nil pointer")
return
}
for _, v := range inputDa... | testsuite/storage/state.go | 0.667906 | 0.449513 | state.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
smath "github.com/jtejido/stats/math"
"math"
"math/rand"
)
// F-distribution
// https://en.wikipedia.org/wiki/F-distribution
type F struct {
baseContinuousWithSource
d1, d2 int
}
func NewF... | dist/continuous/f.go | 0.757436 | 0.491944 | f.go | starcoder |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
type bot struct {
x int
y int
direction direct
}
type direct struct {
x int
y int
}
func main() {
memory := []int{}
dimension := 0
scanner := bufio.NewScanner(os.Stdin)
// Read and process input fr... | 2019/day11p2.go | 0.602296 | 0.432003 | day11p2.go | starcoder |
// Package skein1024 implements the Skein1024 hash function
// based on the Threefish1024 tweakable block cipher.
package skein1024
import (
"github.com/esrrhs/go-engine/src/crypto/cryptonight/inter/skein"
"hash"
)
// Sum512 computes the 512 bit Skein1024 checksum (or MAC if key is set) of msg
// and writes it to ... | src/crypto/cryptonight/inter/skein/skein1024/skein.go | 0.835986 | 0.404743 | skein.go | starcoder |
// Package databaseio provides transformations and utilities to interact with
// generic database database/sql API. See also: https://golang.org/pkg/database/sql/
package databaseio
import (
"database/sql"
"fmt"
"reflect"
"strings"
"time"
)
//rowMapper represents a record mapper
type rowMapper func(value reflec... | sdks/go/pkg/beam/io/databaseio/mapper.go | 0.643105 | 0.47098 | mapper.go | starcoder |
package main
import (
"image/color"
"image/jpeg"
"image/png"
"strings"
"strconv"
"image"
"bufio"
"math"
"flag"
"time"
"log"
"fmt"
"os"
)
const BlockSize = 16
const BlockMaxOffset = 8
const BlockMaxFractOffset = 0.5
const BlockFractStep = 0.25
/*
* struct ImageData
*/
type ImageData struct {
Width, He... | scripts/encoder/encoder-pred.go | 0.580709 | 0.41947 | encoder-pred.go | starcoder |
package integration
import (
"fmt"
json "github.com/bitly/go-simplejson"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
//Validates rules are equal
//`actual` is a representation of an entry from the ConfigMap handled by the Controller
func validateRuleEquals(actual *json.Json, ... | tests/integration/validation.go | 0.691706 | 0.507751 | validation.go | starcoder |
package htest
import (
"bytes"
"encoding/json"
"encoding/xml"
"github.com/basgys/goxml2json"
"github.com/stretchr/testify/assert"
"github.com/tidwall/gjson"
"io/ioutil"
"testing"
"time"
)
type (
JSON struct {
body []byte
*testing.T
}
XML struct {
*JSON
body []byte
}
MD5 struct {
body []byte
... | body.go | 0.64512 | 0.435781 | body.go | starcoder |
package timeseries
import (
"fmt"
"strconv"
"time"
"github.com/grokify/gocharts/v2/data/table"
)
// ParseTableTimeSeriesSetMatrix create a `TimeSeriesSet` from a `table.Table` using the least
// amount of input to populate the data structure. The time must be in column 0 and the series
// names must be in the co... | data/timeseries/time_series_set_parse.go | 0.729712 | 0.710302 | time_series_set_parse.go | starcoder |
package data
import (
"encoding/csv"
"fmt"
. "github.com/woojiahao/govid-19/pkg/utility"
"io"
"os"
"strings"
"time"
)
var TimeSeriesPaths = map[TimeSeriesType]RepoPath{
Confirmed: ConfirmedTimeSeries,
Deaths: DeathsTimeSeries,
Recovered: RecoveredTimeSeries,
}
type (
// Single day of data fo... | pkg/data/time_series.go | 0.741768 | 0.486271 | time_series.go | starcoder |
package function
// Simple implementation of a Run Length Codec
// Length is transmitted as 1 or 2 bytes (minus 1 bit for the mask that indicates
// whether a second byte is used). The run threshold can be provided.
// For a run threshold of 2:
// EG input: 0x10 0x11 0x11 0x17 0x13 0x13 0x13 0x13 0x13 0x13 0x12 (160 t... | go/src/kanzi/function/RLT.go | 0.757077 | 0.475666 | RLT.go | starcoder |
package graphmatrix
import (
"errors"
"fmt"
"sort"
)
// GraphMatrix holds a row index and vector of column pointers.
// If a point is defined at a particular row i and column j, an
// edge exists between vertex i and vertex j.
// GraphMatrices thus represent directed graphs; undirected graphs
// must explicitly se... | graphmatrix.go | 0.762822 | 0.586197 | graphmatrix.go | starcoder |
package data
import (
"fmt"
"time"
)
// vector represents a Field's collection of Elements.
type vector interface {
Set(idx int, i interface{})
Append(i interface{})
Extend(i int)
At(i int) interface{}
Len() int
Type() FieldType
PointerAt(i int) interface{}
CopyAt(i int) interface{}
ConcreteAt(i int) (val ... | vendor/github.com/grafana/grafana-plugin-sdk-go/data/vector.go | 0.5769 | 0.480479 | vector.go | starcoder |
package recurrence
import (
"math"
"time"
)
const (
day = 24 * time.Hour
)
func round(valD time.Duration) int {
val := float64(valD)
_, div := math.Modf(val)
if div >= 0.5 {
return int(math.Ceil(val))
}
return int(math.Floor(val))
}
func (p Recurrence) GetNextDate(d time.Time) time.Time {
if p.Interval =... | calculator.go | 0.646906 | 0.433442 | calculator.go | starcoder |
package main
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderIndexPage() string {
figs := A{
"FigFacade": RenderFigurePngSvg(
"Circuit API provides a dynamic hierarchical view of a compute cluster.", "view", "550px"),
}
return RenderHtml(
"Circuit: Self-managed infrastructure, p... | gocircuit.org/build/index.go | 0.716814 | 0.65624 | index.go | starcoder |
package inverted
import (
"sort"
"github.com/pkg/errors"
"github.com/semi-technologies/weaviate/entities/filters"
)
func mergeAndOptimized(children []*propValuePair,
acceptDuplicates bool) (*docPointers, error) {
sets := make([]*docPointers, len(children))
// Since the nested filter could have further childr... | adapters/repos/db/inverted/merge.go | 0.676086 | 0.532364 | merge.go | starcoder |
package geom
// Union returns a geometry that represents the parts from either geometry A or
// geometry B (or both). An error may be returned in pathological cases of
// numerical degeneracy. GeometryCollections are not supported.
func Union(a, b Geometry) (Geometry, error) {
if a.IsEmpty() && b.IsEmpty() {
return... | geom/alg_set_op.go | 0.898697 | 0.567038 | alg_set_op.go | starcoder |
package fn
import (
"github.com/nlpodyssey/spago/mat"
)
// MaxPooling is an operator to perform max pooling.
type MaxPooling[T mat.DType, O Operand[T]] struct {
x O
rows int
cols int
// initialized during the forward pass
y mat.Matrix[T]
argmaxI [][]int
argmaxJ [][]int
operands []O
}
// NewMaxP... | ag/fn/maxpooling.go | 0.775137 | 0.446555 | maxpooling.go | starcoder |
package main
import "fmt"
func DoSomething(v interface{}) {
// ...
}
// will accept any parameter whatsoever.
// Here’s where it gets confusing: inside of the DoSomething function, what is v’s type? Beginner gophers are led to believe that “v is of any type”, but that is wrong. v is not of any type; it is of inter... | 01 | Go by Example/internal/20_Interfaces/ref/How to use interfaces in Go/interfaces2.go | 0.583441 | 0.456591 | interfaces2.go | starcoder |
package layer
import tf "github.com/galeone/tensorflow/tensorflow/go"
type LPreprocessingLayer struct {
dtype DataType
inputs []Layer
name string
shape tf.Shape
trainable bool
layerWeights []*tf.Tensor
}
func PreprocessingLayer() *LPreprocessingLayer {
return &LPreprocessingLaye... | layer/PreprocessingLayer.go | 0.657318 | 0.444022 | PreprocessingLayer.go | starcoder |
package gripql
import (
"errors"
"fmt"
//"sort"
"strings"
"google.golang.org/protobuf/types/known/structpb"
)
// GetDataMap obtains data attached to vertex in the form of a map
func (vertex *Vertex) GetDataMap() map[string]interface{} {
return vertex.Data.AsMap()
}
// SetDataMap obtains data attached to vert... | gripql/util.go | 0.719679 | 0.434521 | util.go | starcoder |
package maybe
import "go/types"
type nillable interface {
any | types.Nil
}
/*
Maybe is a monadic pattern allowing for data manipulation while abstracting whether the value actually exists or is nil.
For example, if we fetch data from an external API that could be nil, we can still perform manipulation on it while ... | maybe/maybe.go | 0.665954 | 0.487612 | maybe.go | starcoder |
package series
import (
"fmt"
"math"
"time"
)
type timeElement struct {
e *time.Time
}
func (e timeElement) Addr() string {
return fmt.Sprint(e.e)
}
func (e timeElement) Set(value interface{}) Element {
var val time.Time
var err error
switch value.(type) {
case string:
if value.(string) == "NaN" {
e.e... | series/type-time.go | 0.655887 | 0.401306 | type-time.go | starcoder |
package gift
import (
"image"
"image/draw"
"math"
"runtime"
"sync"
)
// parallelize parallelizes the data processing.
func parallelize(enabled bool, start, stop int, fn func(start, stop int)) {
procs := 1
if enabled {
procs = runtime.GOMAXPROCS(0)
}
var wg sync.WaitGroup
splitRange(start, stop, procs, fun... | utils.go | 0.687945 | 0.45042 | utils.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// AssignedTrainingInfo
type AssignedTrainingInfo struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be... | models/assigned_training_info.go | 0.57093 | 0.490724 | assigned_training_info.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.