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 onshape
import (
"encoding/json"
)
// BTVector2d1812 struct for BTVector2d1812
type BTVector2d1812 struct {
BtType *string `json:"btType,omitempty"`
X *float64 `json:"x,omitempty"`
Y *float64 `json:"y,omitempty"`
}
// NewBTVector2d1812 instantiates a new BTVector2d1812 object
// This constructor will ass... | onshape/model_bt_vector2d_1812.go | 0.740174 | 0.545165 | model_bt_vector2d_1812.go | starcoder |
package text
//------------------------------------------------------------------------------
// InterpolatedString holds a string that potentially has interpolation
// functions. Each time Get is called any functions are replaced with their
// evaluated results in the string.
type InterpolatedString struct {
str ... | lib/util/text/util.go | 0.839125 | 0.557665 | util.go | starcoder |
package build
import "sort"
// VertexSet represents a set of vertices in a graph.
// The zero value of a VertexSet is the universe;
// the set containing all vertices.
type VertexSet struct {
// A set is an immutable sorted list of non-empty disjoint intervals.
// The zero value VertexSet{nil} represents the univer... | build/vertexset.go | 0.772616 | 0.545951 | vertexset.go | starcoder |
package main
/**
请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度。
示例1:
输入: "abcabcbb"
输出: 3
解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
示例 2:
输入: "bbbbb"
输出: 1
解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。
示例 3:
输入: "pwwkew"
输出: 3
解释: 因为无重复字符的最长子串是"wke",所以其长度为 3。
请注意,你的答案必须是 子串 的长度,"pwke"是一个子序列,不是子串。
提示:
s.length <= 40000
*/
func lengthOfLonge... | lcof/lengthOfLongestSubstring/lengthOfLongestSubstring.go | 0.587943 | 0.446796 | lengthOfLongestSubstring.go | starcoder |
package geographiclibgo
import "math"
type DirectAndInverse interface {
DirectCalcAll(lat1_deg, lon1_deg, azi1_deg, s12_m float64) AllDirectResults
DirectCalcLatLon(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLon
DirectCalcLatLonAzi(lat1_deg, lon1_deg, azi1_deg, s12_m float64) LatLonAzi
DirectCalcLatLonAziGeo... | geodesic.go | 0.776369 | 0.598488 | geodesic.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPTopLevelConstantDeclaration283 struct for BTPTopLevelConstantDeclaration283
type BTPTopLevelConstantDeclaration283 struct {
BTPTopLevelNode286
BtType *string `json:"btType,omitempty"`
Declaration *BTPStatementConstantDeclaration273 `json:"declaration,omitempty"`
}
... | onshape/model_btp_top_level_constant_declaration_283.go | 0.67822 | 0.52342 | model_btp_top_level_constant_declaration_283.go | starcoder |
package neural
import (
"github.com/gonum/matrix/mat64";
"math"
)
type ActivationFunction func(x mat64.Matrix, y *mat64.Dense)
func NewActivationFunction(name ActivationName) ActivationFunction {
switch name {
case ActivationName_LINEAR:
return func(x mat64.Matrix, y *mat64.Dense) { y.Clone(x) }
case A... | neural/activation_function.go | 0.653459 | 0.671995 | activation_function.go | starcoder |
// Package georef implements the rec.georef command,
// i.e. set the georeference of an specimen record.
package georef
import (
"strings"
"github.com/js-arias/biodv/cmdapp"
"github.com/js-arias/biodv/geography"
"github.com/js-arias/biodv/records"
"github.com/pkg/errors"
)
var cmd = &cmdapp.Command{
UsageLin... | cmd/biodv/internal/records/georef/georef.go | 0.749454 | 0.527134 | georef.go | starcoder |
package biquad
// Bilinear transform for filter use.
// Comes from the following biquad transfer function (see http://shepazu.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html):
// H(z) = (b_0 + b_1*z^{-1} + b_2*z^{-2}) / (a_0 + a_1*z^{-1} + a_2*z^{-2})
type blt struct {
// 5 coefficients normalized respect a0.
b0... | blt.go | 0.787114 | 0.662646 | blt.go | starcoder |
// The byte order fallacy. By <NAME>
// http://commandcenter.blogspot.de/2012/04/byte-order-fallacy.html
package image
import (
"fmt"
"image"
"image/draw"
"reflect"
colorExt "github.com/chai2010/image/color"
)
var (
_ Image = (*Gray)(nil)
_ Image = (*Gray16)(nil)
_ Image = (*Gray32i)(nil)
_ Image = (*Gray... | image.go | 0.646572 | 0.500488 | image.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// PlannerCategoryDescriptions
type PlannerCategoryDescriptions struct {
// Stores additional data not described in the OpenAPI description found when deseria... | models/planner_category_descriptions.go | 0.706393 | 0.408749 | planner_category_descriptions.go | starcoder |
package packed
// Efficient sequential read/write of packed integers.
type BulkOperationPacked19 struct {
*BulkOperationPacked
}
func newBulkOperationPacked19() BulkOperation {
return &BulkOperationPacked19{newBulkOperationPacked(19)}
}
func (op *BulkOperationPacked19) decodeLongToInt(blocks []int64, values []int... | core/util/packed/bulkOperation19.go | 0.572962 | 0.661834 | bulkOperation19.go | starcoder |
package cm
import "github.com/m3db/m3/src/x/pool"
// Sample represents a sampled value.
type Sample struct {
value float64 // sampled value
numRanks int64 // number of ranks represented
delta int64 // delta between min rank and max rank
prev *Sample // previous sample
next *Sample // next samp... | src/aggregator/aggregation/quantile/cm/types.go | 0.783285 | 0.459682 | types.go | starcoder |
package jsonlogic
import (
"encoding/json"
"fmt"
"io"
"math"
"sort"
"strings"
"github.com/mitchellh/copystructure"
)
type ErrInvalidOperator struct {
operator string
}
func (e ErrInvalidOperator) Error() string {
return fmt.Sprintf("The operator \"%s\" is not supported", e.operator)
}
func between(operato... | jsonlogic.go | 0.614278 | 0.405154 | jsonlogic.go | starcoder |
package fp
func (a BoolArray) ZipAllBoolArray(a2 BoolArray, thisDefault Bool, thatDefault Bool) Tuple2Array {
len1 := len(a); len2 := len(a2); maxLen := int(Int(len1).Max(Int(len2)))
zipped := make([]Tuple2, maxLen)
var e1, e2 Any
for i := 0; i < maxLen; i ++ {
if i < len1 { e1 = a[i] } else { e1 = thisD... | fp/bootstrap_array_zipall.go | 0.524882 | 0.407333 | bootstrap_array_zipall.go | starcoder |
package actions
import (
"github.com/LindsayBradford/crem/internal/pkg/dataset/tables"
"github.com/LindsayBradford/crem/internal/pkg/model/action"
"github.com/LindsayBradford/crem/internal/pkg/model/models/catchment/parameters"
"github.com/LindsayBradford/crem/internal/pkg/model/planningunit"
)
type RiverBankRes... | internal/pkg/model/models/catchment/actions/RiverBankRestorationGroup.go | 0.643217 | 0.423756 | RiverBankRestorationGroup.go | starcoder |
package surface
import (
"math"
"math/rand"
"github.com/hunterloftis/pbr/pkg/geom"
"github.com/hunterloftis/pbr/pkg/render"
"github.com/hunterloftis/pbr/pkg/rgb"
)
// Sphere describes a 3d sphere
type Sphere struct {
mtx *geom.Mtx
mat Material
bounds *geom.Bounds
}
// UnitSphere returns a pointer to a... | pkg/surface/sphere.go | 0.627951 | 0.437463 | sphere.go | starcoder |
package paunch
// bounding is an object that represents a bounding box. It is meant to be
// used through the Collider interface.
type bounding struct {
start *point
end *point
}
func newBounding(start *point, end *point) *bounding {
var checkStart, checkEnd point
if start.x >= end.x {
checkEnd.x = start.x
... | bounding.go | 0.878262 | 0.603026 | bounding.go | starcoder |
package solid
import (
"math"
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/fun"
"github.com/cpmech/gosl/fun/dbf"
)
// RjointM1 implements a 1D plasticity model for rod-joints (links/interface)
// Note: σc has opposite sign convention: positive means compressive
type RjointM1 struct {
A_ks float64 // ... | mdl/solid/rjointm1.go | 0.667473 | 0.419113 | rjointm1.go | starcoder |
package neuralNetwork
import (
"fmt"
"math"
"gonum.org/v1/gonum/mat"
)
type lossBaseStruct struct{}
// LossFunctions is the interface for matLoss (matSquareLoss,...)
type LossFunctions interface {
Loss(Ytrue, Ypred, Grad *mat.Dense) float64
}
type squareLoss struct{ lossBaseStruct }
func (squareLoss) Loss(Ytr... | neural_network/loss.go | 0.730386 | 0.457985 | loss.go | starcoder |
package main
// Owner structure contains the name of the Company and the name of the Lessor of the basic machine
//type Owner struct {
// Company string `json:"company"`
// Lessor string `json:"lessor"`
//}
// BasicMachine structure contains all the features of a basic machine
type BasicMachine struct {
ID ... | smart-contract/contract-tutorial/basic-asset.go | 0.526343 | 0.434581 | basic-asset.go | starcoder |
package zebra
// Solution holds the info who drinks water and who owns the zebra
type Solution struct {
DrinksWater, OwnsZebra string
}
// House accomodates a person of certain nationality and so on
type House struct {
n Nationality
c Colour
a Animal
d Drink
s Smoke
}
// HouseSet has all five houses
type House... | zebra-puzzle/zebra_puzzle.go | 0.556882 | 0.469824 | zebra_puzzle.go | starcoder |
package expr
import (
"errors"
"fmt"
"math"
"strconv"
"unicode"
)
type Num float64
var (
ErrParen = errors.New("parenthesis mismatch")
ErrUnexpectedNumber = errors.New("unexpected number")
ErrUnexpectedIdentifier = errors.New("unexpected identifier")
ErrBadCall = errors.New("funct... | expr.go | 0.605449 | 0.437523 | expr.go | starcoder |
package shingo
import (
"math"
"time"
"github.com/pkg/errors"
)
// AppendMACD appends Moving Average Convergence Divergence indicators to each candlestick
func (cs *Candlesticks) AppendMACD(args IndicatorInputArg) error {
period1 := args.MacdLarge
period2 := args.MacdSmall
signalLine := args.MacdSignal
limit ... | macd.go | 0.57332 | 0.420421 | macd.go | starcoder |
package semver
import (
"fmt"
"github.com/spf13/cast"
"regexp"
"strings"
)
var (
aliasRegex = regexp.MustCompile(`^([^,\s]+)\s+as\s+([^,\s]+)$`)
stabilityRegex = `[._-]?(?:(dev|stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*)?)`
branchRegex = regexp.MustCompile(`^v?(\d+)(\.(?:\d+|[xX*]))?(\.(?:\d+|[xX*]))... | parser.go | 0.510008 | 0.438905 | parser.go | starcoder |
package plaid
import (
"encoding/json"
)
// AuthGetNumbers An object containing identifying numbers used for making electronic transfers to and from the `accounts`. The identifying number type (ACH, EFT, IBAN, or BACS) used will depend on the country of the account. An account may have more than one number type. If... | plaid/model_auth_get_numbers.go | 0.727975 | 0.434281 | model_auth_get_numbers.go | starcoder |
package animation
import (
"image/color"
"math"
"time"
"github.com/misterikkit/tinytimer/graphics"
)
// Interface provides a frame of pixels that changes over time.
type Interface interface {
// Frame returns the animation's current pixel values.
Frame() []color.RGBA
// Update updates an animation's frame bas... | animation/animation.go | 0.799833 | 0.477067 | animation.go | starcoder |
package xcore
import (
"log"
"sync"
"time"
)
// XCacheEntry is the cache basic structure to save some data in memory.
type XCacheEntry struct {
// The cache entry has a time to measure expiration if needed, or time of entry in cache:
// - ctime is the creation time (used to validate the object against its source... | xcache.go | 0.540924 | 0.513485 | xcache.go | starcoder |
package structures
import (
"errors"
"fmt"
"log"
"math/big"
"math/rand"
"github.com/offchainlabs/arbitrum/packages/arb-checkpointer/ckptcontext"
"github.com/offchainlabs/arbitrum/packages/arb-util/common"
"github.com/offchainlabs/arbitrum/packages/arb-util/hashing"
"github.com/offchainlabs/arbitrum/packages/... | packages/arb-validator/structures/node.go | 0.531939 | 0.432902 | node.go | starcoder |
package main
import (
"fmt"
"io"
"text/tabwriter"
"time"
"github.com/srishanbhattarai/nepcal/dateconv"
)
// calendar struct represents the state required to render the B.S. calendar using a tabwriter
// that writes out to an io.Writer.
type calendar struct {
val int
w *tabwriter.Writer
}
// newCalendar ret... | calendar.go | 0.775605 | 0.408395 | calendar.go | starcoder |
package meta
import (
"fmt"
"sort"
"strconv"
"strings"
"time"
)
const (
installedMetsensorMake = iota
installedMetsensorModel
installedMetsensorSerial
installedMetsensorMark
installedMetsensorIMSComment
installedMetsensorHumidityAccuracy
installedMetsensorPressureAccuracy
installedMetsensorTemperatureAcc... | meta/metsensor.go | 0.628521 | 0.415847 | metsensor.go | starcoder |
package main
import (
"bufio"
"flag"
"fmt"
"image/color"
"io"
"os"
"strconv"
"strings"
"gioui.org/app"
"gioui.org/io/key"
"gioui.org/io/system"
"gioui.org/unit"
gc "github.com/ajstarks/giocanvas"
)
// NameValue defines data
type NameValue struct {
name string
note string
value float64
}
// ChartOp... | chartest/main.go | 0.509032 | 0.465752 | main.go | starcoder |
package reports
import (
"bytes"
"encoding/binary"
"fmt"
"math"
"strconv"
)
// ZWaveSensorType describes the sensor type in a sensormultilevel report
type ZWaveSensorType byte
const (
Undefined = iota
Temperature
General
Luminance
Power
RelativeHumidity
Velocity
Direction
AtmosphericPressure
Barometri... | commands/reports/sensor_multi_level.go | 0.583322 | 0.470189 | sensor_multi_level.go | starcoder |
package polling
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/concerto/api/types"
"github.com/ingrammicro/concerto/utils"
"github.com/stretchr/testify/assert"
)
// PingMocked test mocked function
func PingMocked(t *testing.T, pingIn *types.PollingPing) *types.PollingPing {
assert := assert... | api/polling/polling_api_mocked.go | 0.694406 | 0.522629 | polling_api_mocked.go | starcoder |
package boolq
import (
"fmt"
"github.com/kylebrandt/boolq/parse"
)
// An Asker is something that can be queried using boolq. The string passed
// to Ask will be the component in an expression. For example with the expression
// `(foo:bar AND baz:biz)` Ask will be called twice, once with the argument "foo:bar"
// ... | vendor/github.com/kylebrandt/boolq/boolq.go | 0.733833 | 0.505554 | boolq.go | starcoder |
package treap
import (
"math"
"math/rand"
"time"
)
const (
// Random priorities in the Treap will be in the range of [1, MaxInt64].
maxPriority = math.MaxInt64
minPriority = 1
// The priority given to Treap nodes during deletion.
deletePriority = 0
)
// Treap is a balanced binary search tree.
type Treap str... | treap.go | 0.830353 | 0.586464 | treap.go | starcoder |
// Package sgrad provides facilities for the computation of a finite-difference
// gradient image from a source SippImage and a 2x2 kernel.
// There are two versions, one using float64s and complex128s, and another using
// int32s. The latter makes it easier to guarantee bit accuracy and numerical
// stability. It is ... | sgrad/sgrad.go | 0.65379 | 0.700107 | sgrad.go | starcoder |
package main
import (
"crypto/sha256"
"fmt"
"math/big"
"golang.org/x/crypto/ripemd160"
)
type Point struct {
x, y *big.Int
}
func NewPoint() Point {
return Point{new(big.Int), new(big.Int)}
}
func (P Point) String() string {
return fmt.Sprintf("Point(%d, %d)", P.x, P.y)
}
func (P Point) Equals(Q Point) boo... | btcbook_addr_03.go | 0.712832 | 0.501465 | btcbook_addr_03.go | starcoder |
package continuous
import (
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"github.com/jtejido/trig"
"math"
"math/rand"
)
// Log-logistic distribution
// Also known as the Fisk distribution.
// https://en.wikipedia.org/wiki/Log-logistic_distribution
// https://en.wikipedia.org/wiki/Shifted_log-logisti... | dist/continuous/log_logistic.go | 0.783823 | 0.456834 | log_logistic.go | starcoder |
package main
import (
"errors"
"fmt"
"log"
)
const emptyByte byte = 0b00000000
// Masks to set a particular bit to 1
const (
mask0 byte = 0b10000000
mask1 byte = 0b01000000
mask2 byte = 0b00100000
mask3 byte = 0b00010000
mask4 byte = 0b00001000
mask5 byte = 0b00000100
mask6 byte = 0b00000010
mask7 byte = ... | shuffler.go | 0.503418 | 0.438004 | shuffler.go | starcoder |
package bitty
/*
Copyright 2020 IBM
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, so... | base.go | 0.805096 | 0.40754 | base.go | starcoder |
package adagrad
import (
"github.com/nlpodyssey/spago/gd"
"github.com/nlpodyssey/spago/mat"
"github.com/nlpodyssey/spago/nn"
)
var _ gd.MethodConfig = &Config[float32]{}
// Config provides configuration settings for an AdaGrad optimizer.
type Config[T mat.DType] struct {
gd.MethodConfig
LR T
Epsilon T
}
... | gd/adagrad/adagrad.go | 0.76454 | 0.427576 | adagrad.go | starcoder |
package nlp
const (
Ins = iota
Del
Sub
Match
)
// DefaultOptions is the default options: insertion cost is 1, deletion cost is
// 1, substitution cost is 2, and two runes match iff they are the same.
var DefaultOptions Options = Options{
InsCost: 1,
DelCost: 1,
SubCost: 2,
Matches: func(sourceCharacter rune, ... | bot/nlp/comparisons.go | 0.756178 | 0.465873 | comparisons.go | starcoder |
package algo
// InsSort sorts list using the insertion sort algorithm. It works by extending
// a sorted subset of the list by one element at the time.
func InsSort(list []int) []int {
// u represent the start position of the unsorted portion of the list. The
// first element is always sorted, thus start checking th... | archive/cs/algo/sort.go | 0.609524 | 0.533397 | sort.go | starcoder |
package stream
import "math"
// Accumulator used to calculate statistics for a period of time by processing provided values
type Accumulator struct {
streamKey string
intervalStart int64
intervalEnd int64
intervalType IntervalType
mini... | stream/accumulator.go | 0.872476 | 0.624666 | accumulator.go | starcoder |
package rango
import "math"
type Matrix struct {
m00, m01, m02, m03 float64
m10, m11, m12, m13 float64
m20, m21, m22, m23 float64
m30, m31, m32, m33 float64
}
func deg2rad(deg float64) float64 {
return (math.Pi * deg) / 180.0
}
func Identity() Matrix {
return Matrix{
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
... | rango/matrix.go | 0.770637 | 0.66794 | matrix.go | starcoder |
package main
import (
"bufio"
"bytes"
"io"
)
// eof represents a marker rune for the end of the reader, defining it here
// gives us a possibility to recognize it in the Scanner
var eof = rune(0)
type Scanner struct {
r *reader
}
// NewScanner creates a Scanner struct, which contains a buffered rune reader.
fun... | scanner.go | 0.680029 | 0.422505 | scanner.go | starcoder |
package combination
import (
"github.com/tidepool-org/platform/data"
"github.com/tidepool-org/platform/data/types/bolus"
"github.com/tidepool-org/platform/structure"
)
const (
SubType = "dual/square" // TODO: Rename Type to "bolus/combination"; remove SubType
DurationMaximum = 86400000
DurationMinimum = 0
Ext... | data/types/bolus/combination/combination.go | 0.59514 | 0.406273 | combination.go | starcoder |
package measurements
import "fmt"
type MassUnit int32
const (
Kilogram MassUnit = iota
Gram
Pound
Ounce
)
var MassUnitName = map[MassUnit]string{
Kilogram: "kg",
Gram: "g",
Pound: "lb",
Ounce: "oz",
}
var MassUnitValue = map[string]MassUnit{
"kg": Kilogram,
"g": Gram,
"lb": Pound,
"oz": Ounc... | mass.go | 0.703957 | 0.515986 | mass.go | starcoder |
package iso20022
// Set of characteristics that apply to the credit side of the payment transactions included in the direct debit initiation.
type PaymentInstructionInformation4 struct {
// Unique identification, as assigned by a sending party, to unambiguously identify the payment information group within the messa... | PaymentInstructionInformation4.go | 0.807992 | 0.470311 | PaymentInstructionInformation4.go | starcoder |
package genetic
import (
"fmt"
"math"
)
/**
The likelihood of a given gene mutating. (e.g. 0.06 is a 6% chance)
*/
var mutationRate float64
/**
Gene is atructure intended to represent a single gene
A, B, and C are constant coefficients that are used by f
f is a function that evalutes the three constant coefficient... | genetic/gene.go | 0.793586 | 0.74556 | gene.go | starcoder |
package p126
/**
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:
Only one letter can be changed at a time
Each transformed word must exist in the word list. Note that beginWord is not a transformed word.
For exam... | algorithms/p126/126.go | 0.772788 | 0.420659 | 126.go | starcoder |
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime"
"strconv"
"github.com/crhym3/imgdiff"
)
const usageText = `Compare two images and optionally output resulting diff image.
Supported image formats: png, jpeg, gif, tiff, bmp and webp.
Exit code will be non-zero if the difference is above specified thres... | cmd/imgdiff/main.go | 0.67405 | 0.490114 | main.go | starcoder |
package asm
import (
"encoding/binary"
. "github.com/mmcloughlin/avo/build"
"github.com/mmcloughlin/avo/operand"
)
func ConstBytes(name string, data []byte) operand.Mem {
m := GLOBL(name, RODATA|NOPTR)
switch {
case len(data)%8 == 0:
constBytes8(0, data)
case len(data)%4 == 0:
constBytes4(0, data)
def... | build/internal/asm/asm.go | 0.54577 | 0.42316 | asm.go | starcoder |
package query
import (
"fmt"
"math"
"strings"
"github.com/JODA-Explore/BETZE/dataset"
)
//TODO Unique and count
// A Predicate represents operations performed during the filter phase
type Predicate interface {
// Returns the estimated selectivity of filtering the given dataset with the predicate
Selectivity(d... | query/predicates.go | 0.595845 | 0.558628 | predicates.go | starcoder |
package lowess
import (
"errors"
"math"
"sort"
)
type Coord struct {
X float64
Y float64
}
type CoordSlice []Coord
func (s CoordSlice) Len() int {
return len(s)
}
func (s CoordSlice) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s CoordSlice) Less(i, j int) bool {
return s[i].X < s[j].X
}
type coordDi... | lowess.go | 0.803868 | 0.453141 | lowess.go | starcoder |
package parser
import (
"bufio"
"bytes"
"io"
"strconv"
)
// Scanner is a lexical scanner.
type Scanner struct {
r *bufio.Reader
pos TokenPos
}
// NewScanner returns a new instance of Scanner.
func NewScanner(r io.Reader) *Scanner {
return &Scanner{r: bufio.NewReader(r), pos: TokenPos{Char: 0, Lines: []int{}... | parser/scanner.go | 0.580947 | 0.496765 | scanner.go | starcoder |
package unit
import (
"path"
"strings"
)
// UnitType provides an enumeration over the different types of systemd unit
// file types
type UnitType uint
const (
// UnitTypeUnknown represents a generic or unknown unit type
UnitTypeUnknown UnitType = iota
// UnitTypeService represents a systemd.service(5)
UnitTy... | resource/systemd/unit/types.go | 0.738952 | 0.60577 | types.go | starcoder |
package topdown
import (
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/topdown/builtins"
)
// Helper: sets of vertices can be represented as Arrays or Sets.
func foreachVertex(collection *ast.Term, f func(*ast.Term)) {
switch v := collection.Value.(type) {
case ast.Set:
v.Foreach(f)
... | topdown/reachable.go | 0.751648 | 0.404125 | reachable.go | starcoder |
package draw
import "fmt"
type Rect struct {
X int
Y int
Width int
Height int
}
func NewRect(s *Size) *Rect {
return &Rect{0, 0, s.Width, s.Height}
}
func NewRectFromSize(lt *Point, s *Size) *Rect {
return &Rect{lt.X, lt.Y, s.Width, s.Height}
}
func NewRectFromPoint(lt *Point, rb *Point) *Rect {
... | rect.go | 0.78789 | 0.477006 | rect.go | starcoder |
package runningvariance
import (
"fmt"
"math"
)
// Stat assumulates the data required for computing the statistics.
type Stat struct {
N int64
M1, M2, M3, M4 float64
}
// String implements Stringer.
func (s *Stat) String() string {
return fmt.Sprintf("N=%d μ=%f σ=%f skew=%f ek=%f", s.N, s.Mean(), s.StdDev(), s... | runningvariance.go | 0.807271 | 0.561275 | runningvariance.go | starcoder |
package scenegraph
import (
"github.com/mattkimber/gandalf/geometry"
"github.com/mattkimber/gandalf/magica/types"
)
func (n *Node) Decompose() (graph Map, pointData []types.PointData, sizeData []types.Size) {
id := 0
shapeID := 0
graph = make(Map)
pointData = make([]types.PointData, 0)
sizeData = make([]types... | magica/scenegraph/compose.go | 0.569853 | 0.415136 | compose.go | starcoder |
package unit
const (
// DATA represents the unit used for data volume (e.g., bytes)
DATA = iota
// TIME represents the unit used for time mesurements (e.g., seconds)
TIME
// BW represents the unit used for bandwidth mesurements (e.g., B/s)
BW
)
func getDataUnits() map[int]string {
return map[int]string{
0... | tools/internal/pkg/unit/unit.go | 0.743075 | 0.643343 | unit.go | starcoder |
package client
import (
"encoding/json"
)
// RuleMatch struct for RuleMatch
type RuleMatch struct {
// An array of HTTP methods (e.g. GET, POST, PUT, DELETE, ...). When ORY Oathkeeper searches for rules to decide what to do with an incoming request to the proxy server, it compares the HTTP method of the incoming r... | clients/oathkeeper/go/model_rule_match.go | 0.821403 | 0.409693 | model_rule_match.go | starcoder |
package gokalman
import "github.com/gonum/matrix/mat64"
// FilterType allows for quick comparison of filters.
type FilterType uint8
func (f FilterType) String() string {
switch f {
case CKFType:
return "CKF"
case EKFType:
return "EKF"
case UKFType:
return "UKF"
case SRIFType:
return "SRIF"
default:
p... | kalman.go | 0.729809 | 0.440951 | kalman.go | starcoder |
Package app contains OpenEBS Dynamic Local PV provisioner
Provisioner is created using the external storage provisioner library:
https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner
Local PVs are an extension to hostpath volumes, but are more secure.
https://kubernetes.io/docs/concepts/policy/pod-... | cmd/provisioner-localpv/app/doc.go | 0.90188 | 0.542379 | doc.go | starcoder |
package dependencygraph2
import (
"github.com/google/gapid/core/math/interval"
)
// memoryWrite stores a WriteMemEffect, together with a memory span affected by that write.
// The span may be smaller than the whole write.
type memoryWrite struct {
// effect WriteMemEffect
node NodeID
span interval.U64Span
}
// ... | gapis/resolve/dependencygraph2/memory_intervals.go | 0.835785 | 0.426979 | memory_intervals.go | starcoder |
package reflecthelper
import "reflect"
// GetKind gets the kind of the val of reflect.Value.
func GetKind(val reflect.Value) (res reflect.Kind) {
if !val.IsValid() {
return
}
res = val.Type().Kind()
return
}
// GetElemKind gets the elem kind from the val of reflect.Value.
func GetElemKind(val reflect.Value) (... | vendor/github.com/fairyhunter13/reflecthelper/v4/kind.go | 0.722429 | 0.66386 | kind.go | starcoder |
package base
import (
"bytes"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
"github.com/persistenceOne/persistenceSDK/constants/errors"
"github.com/persistenceOne/persistenceSDK/schema/types"
"github.com/persistenceOne/persistenceSDK/utilities/meta"
)
var _, _ types.Data = (*Data_AccAddressData)(nil), (*AccAddr... | schema/types/base/accAddressData.go | 0.641759 | 0.406862 | accAddressData.go | starcoder |
package binomial
import . "github.com/howz97/algorithm/util"
const (
isNil = 0
notNil = 1
)
// Binomial is a binomial queue
type Binomial struct {
size int
trees []*node
}
// New return a binomial queue with default capacity
func New() *Binomial {
return &Binomial{
trees: make([]*node, 8),
}
}
// Merge b... | pq/binomial/binomial.go | 0.601242 | 0.404802 | binomial.go | starcoder |
package texture
import (
g2d "github.com/jphsd/graphics2d"
"math"
)
// Fractal holds the pieces necessary for fractal generation. Xfm defines the affine transformation
// applied successively to the coordinate space and CFunc, how the multiple resultant values should be combined.
// An optional filter can be specif... | fractal.go | 0.882276 | 0.587085 | fractal.go | starcoder |
package pix
// Implementation of functions in this file based on
// https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/
type MortonCode uint32
func smoosh2(x MortonCode) uint32 {
x &= 0x09249249 // x = ---- 9--8 --7- -6-- 5--4 --3- -2-- 1--0
x = (x ^ (x >> 2)) & 0x030c30c3 // x = --... | morton.go | 0.726911 | 0.509215 | morton.go | starcoder |
package mathg
import "math"
type Quaternion Vec4
func (q *Quaternion) IsZero() bool {
return math.Abs(q.X) < epsilon && math.Abs(q.Y) < epsilon && math.Abs(q.Z) < epsilon && math.Abs(q.W) < epsilon
}
func (q *Quaternion) IsEqual(q1 *Quaternion) bool {
return math.Abs(q.X-q1.X) < epsilon && math.Abs(q.Y-q1.Y) < ep... | quaternion.go | 0.862352 | 0.627038 | quaternion.go | starcoder |
package loganal
import (
"regexp"
"strings"
)
// A matcher implements incrementally consuming a string using
// regexps.
type matcher struct {
str string // string being matched
pos int
groups []string // match groups
// matchPos is the byte position of the beginning of the
// match in str.
matchPos i... | internal/loganal/matcher.go | 0.603114 | 0.503235 | matcher.go | starcoder |
package SetSimilaritySearch
import (
"errors"
"sort"
)
// Pair is a pair of slice indexes to the sets in the input to all-pairs
// algorithms.
type Pair struct {
X int
Y int
Similarity float64
}
type postingListEntry struct {
setIndex int
tokenPosition int
setSize int
}
// AllPa... | allpairs.go | 0.600423 | 0.488405 | allpairs.go | starcoder |
package main
import (
"fmt"
"sort"
"strconv"
"strings"
"github.com/konsti/aoc2021/utils/color"
"github.com/konsti/aoc2021/utils/input"
"github.com/konsti/aoc2021/utils/logging"
)
type Point struct {
number int
neighbours []*Point
}
func setNeighbours(input [][]Point) [][]Point {
maxX := len(input[0])
... | day09/day09.go | 0.549882 | 0.458106 | day09.go | starcoder |
package validate_binary_search_tree
/*
98. 验证二叉搜索树 https://leetcode-cn.com/problems/validate-binary-search-tree
给定一个二叉树,判断其是否是一个有效的二叉搜索树。
假设一个二叉搜索树具有如下特征:
节点的左子树只包含小于当前节点的数。
节点的右子树只包含大于当前节点的数。
所有左子树和右子树自身必须也是二叉搜索树。
示例 1:
输入:
2
/ \
1 3
输出: true
示例 2:
输入:
5
/ \
1 4
/ \
3 6
输出: false
... | solutions/validate-binary-search-tree/d.go | 0.550607 | 0.425963 | d.go | starcoder |
package main
/*****************************************************************************************************
*
* Design a HashMap without using any built-in hash table libraries.
*
* To be specific, your design should include these functions:
*
* put(key, value) : Insert a (key, value) pair into the Ha... | leetcode/706.design_hashmap/706.DesignHashMap_zhangsl.go | 0.545528 | 0.441854 | 706.DesignHashMap_zhangsl.go | starcoder |
package main
import (
"errors"
"glycodist/pdb"
"glycodist/uniprot"
"math"
"sort"
)
type residueDistance struct {
UnpPos int64
Residue *pdb.Residue
Distance float64
}
func distance(atom1 *pdb.Atom, atom2 *pdb.Atom) float64 {
return math.Sqrt(math.Pow(atom1.X-atom2.X, 2) + math.Pow(atom1.Y-atom2.Y, 2) + ma... | distance.go | 0.6705 | 0.407098 | distance.go | starcoder |
package lib
import (
"fmt"
"reflect"
)
// A Decomp (short for Decomposition) consists of a labelled tree which
// subdivides a graph in a certain way
type Decomp struct {
Graph Graph
Root Node
SkipRerooting bool //needed for BalDetK
}
func (d Decomp) String() string {
return d.Root.String()
}
... | lib/decomp.go | 0.65379 | 0.448789 | decomp.go | starcoder |
package slippy
import (
"math"
"errors"
"github.com/go-spatial/geom"
"fmt"
)
const MaxZoom = 22
func NewTile(z, x, y uint) *Tile {
return &Tile{
Z: z,
X: x,
Y: y,
}
}
// Tile describes a slippy tile.
type Tile struct {
// zoom
Z uint
// column
X uint
// row
Y uint
}
// This function returns the ... | slippy/tile.go | 0.72662 | 0.466359 | tile.go | starcoder |
package pointu
import (
"math"
)
// A rectangle has an upper left point (Min) and a lower right point (Max).
type rectangle struct {
min, max Point
}
type kdNode struct {
p Point
splitByX bool
left, right *kdNode
}
type kdTree struct {
root *kdNode
bounds rectangle
}
func makeKdTree(pts Point... | pointu/kd_tree.go | 0.770508 | 0.528898 | kd_tree.go | starcoder |
package spec
const data_identifier_map_json = `
{
"01": {
"id": "01",
"max": "Aucune",
"min": "0",
"shortDesc": "Identifiant unique du document.",
"type": "Alphanumérique"
},
"02": {
"id": "02",
"max": "Aucune",
"min": "0",
"shortDesc"... | pkg/spec/spec_data_identifier.go | 0.501953 | 0.558086 | spec_data_identifier.go | starcoder |
package day17
import (
"fmt"
"math"
)
type PixelType int
type Pixel struct {
X int
Y int
}
func NewPixel(x, y int) Pixel {
return Pixel{X: x, Y: y}
}
type Pixels map[Pixel]PixelType
func (pixels Pixels) CountByType() map[PixelType]int {
counts := map[PixelType]int{}
for _, pixelType := range pixels {
cou... | day17/computer.go | 0.553988 | 0.433082 | computer.go | starcoder |
package catalog
// GetDatasetQueryParams represents valid query parameters for the GetDataset operation
// For convenience GetDatasetQueryParams can be formed in a single statement, for example:
// `v := GetDatasetQueryParams{}.SetMaxstale(...)`
type GetDatasetQueryParams struct {
// Maxstale : The number of seco... | services/catalog/param_generated.go | 0.94252 | 0.763175 | param_generated.go | starcoder |
package common
import (
"errors"
"log"
"github.com/EngoEngine/engo"
"github.com/EngoEngine/engo/math"
"github.com/EngoEngine/gl"
)
var spritesheetCache = make(map[string]*Spritesheet)
// Spritesheet is a class that stores a set of tiles from a file, used by tilemaps and animations
type Spritesheet struct {
te... | common/spritesheet.go | 0.736874 | 0.444565 | spritesheet.go | starcoder |
package merkletree
import (
"errors"
"hash"
)
// A CachedTree can be used to build Merkle roots and proofs from the cached
// Merkle roots of smaller blocks of data. Each CachedTree has a height,
// meaning every element added to the CachedTree is the root of a full Merkle
// tree containing 2^height leaves.
type C... | cachedtree.go | 0.718397 | 0.554893 | cachedtree.go | starcoder |
package simulations
import (
"context"
"time"
"github.com/DxChainNetwork/godx/p2p/enode"
)
// Simulation provides a framework for running actions in a simulated network
// and then waiting for expectations to be met
type Simulation struct {
network *Network
}
// NewSimulation returns a new simulation which run... | p2p/simulations/simulation.go | 0.702836 | 0.480479 | simulation.go | starcoder |
package texture
import (
"unsafe"
gl "github.com/adrianderstroff/pbr/pkg/core/gl"
"github.com/adrianderstroff/pbr/pkg/view/image/image2d"
)
// MakeEmpty creates a Texture with no image data.
func MakeEmpty() Texture {
return Texture{0, gl.TEXTURE_2D, 0}
}
// Make creates a texture the given width and height.
//... | pkg/view/texture/simple.go | 0.825062 | 0.593315 | simple.go | starcoder |
package test
import (
"fmt"
"strconv"
"testing"
"github.com/codeready-toolchain/api/pkg/apis/toolchain/v1alpha1"
"github.com/codeready-toolchain/host-operator/pkg/counter"
"github.com/codeready-toolchain/host-operator/pkg/metrics"
commontest "github.com/codeready-toolchain/toolchain-common/pkg/test"
"github.c... | test/counter.go | 0.560493 | 0.434041 | counter.go | starcoder |
package vg
import (
"math"
)
// DegToRad converts degree to radian.
func DegToRad(deg float32) float32 {
return deg / 180.0 * PI
}
// RadToDeg converts radian to degree.
func RadToDeg(rad float32) float32 {
return rad / PI * 180.0
}
func signF(a float32) float32 {
if a > 0.0 {
return 1.0
}
return -1.0
}
fu... | vg/util.go | 0.807764 | 0.585842 | util.go | starcoder |
package health
// Status represents the overall health status of a component
type Status string
const (
// StatusUp indicates that the checked component is up and running
StatusUp Status = "UP"
// StatusDown indicates the the checked component has an issue and is unavailable
StatusDown Status = "DOWN"
// StatusU... | pkg/health/types.go | 0.79732 | 0.486088 | types.go | starcoder |
package cl
import "sync"
// StringClosure is a function that returns a string, used to defer execution of expensive logging operations
type StringClosure func() string
// Value is the generic list of things processed by the log chan
type Value []interface{}
type (
// Fatal is a log value that indicates level an... | pkg/util/cl/types.go | 0.550849 | 0.563558 | types.go | starcoder |
package field
import "gorm.io/gorm/clause"
type Float64 Field
func (field Float64) Eq(value float64) Expr {
return expr{e: clause.Eq{Column: field.RawExpr(), Value: value}}
}
func (field Float64) Neq(value float64) Expr {
return expr{e: clause.Neq{Column: field.RawExpr(), Value: value}}
}
func (field Float64) Gt... | field/float.go | 0.833934 | 0.751283 | float.go | starcoder |
package mat
// Add matrices together
func Add(a, b Matrix) (Matrix, error) {
// Check matrix dimensions
sizeA := a.Size()
sizeB := b.Size()
if (sizeA[0] != sizeB[0]) || sizeA[1] != sizeB[1] {
return Matrix{}, ErrDimMisMatch
}
c := Zeros(sizeA[0], sizeA[1])
for i := range a {
for j := range a[i] {
c[i]... | mat/math.go | 0.83868 | 0.528594 | math.go | starcoder |
package dyngeo
import (
"math"
"strconv"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/golang/geo/s2"
)
type GeoPoint struct {
Latitude float64
Longitude float64
}
type GeoJSONAttribute struct {
Type string `json:"type"`
Coordinates []float64 `json:"coordinates"`
}
func newGeoJSONAttr... | model.go | 0.764628 | 0.523299 | model.go | starcoder |
package audio
import (
"fmt"
"io"
)
// InfiniteLoop represents a looped stream which never ends.
type InfiniteLoop struct {
src io.ReadSeeker
lstart int64
llength int64
pos int64
}
// NewInfiniteLoop creates a new infinite loop stream with a source stream and length in bytes.
func NewInfiniteLoop(src... | audio/loop.go | 0.586878 | 0.417984 | loop.go | starcoder |
package kvt
import (
"fmt"
"github.com/arr-ai/frozen/errors"
"github.com/arr-ai/frozen/internal/fu"
)
type leaf struct {
data [2]elementT
}
func newLeaf(data ...elementT) *leaf {
switch len(data) {
case 1:
return newLeaf1(data[0])
case 2:
return newLeaf2(data[0], data[1])
default:
panic(errors.Errorf(... | internal/tree/kvt/leaf.go | 0.54577 | 0.428771 | leaf.go | starcoder |
package schemax
import "sync"
/*
DITContentRuleCollection describes all DITContentRules-based types.
*/
type DITContentRuleCollection interface {
// Get returns the *DITContentRule instance retrieved as a result
// of a term search, based on Name or OID. If no match is found,
// nil is returned.
Get(interface{}) ... | dcr.go | 0.788013 | 0.460592 | dcr.go | starcoder |
package doublearray
import (
"fmt"
)
// DoubleArray implements an associative array whose key is a string and value is int.
// The data structure is based on a double-array minimal-prefix trie.
type DoubleArray struct {
array []node
tail []byte
numKeys int
numNodes int
}
// Build returns a DoubleArray o... | doublearray.go | 0.762954 | 0.656452 | doublearray.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.