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 convert
import (
"database/sql"
"fmt"
"math/big"
"reflect"
"strconv"
)
// AsFloat64 convets interface as float64
func AsFloat64(src interface{}) (float64, error) {
switch v := src.(type) {
case int:
return float64(v), nil
case int16:
return float64(v), nil
case int32:
return float64(v), nil
c... | vendor/xorm.io/xorm/convert/float.go | 0.567937 | 0.473962 | float.go | starcoder |
package main
import "fmt"
/*
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.
Return the quotient after dividing dividend by divisor.
The integer division should truncate toward zero.
Example 1:
Input: dividend = 10, divisor = 3
Output: 3
Exampl... | Programs/029Divide Two Integers/029Divide Two Integers.go | 0.551574 | 0.548915 | 029Divide Two Integers.go | starcoder |
package unitpacking
import "github.com/EliCDavis/vector"
// Quadrant2D represents a quadrant in a 2D space.
type Quadrant2D int
const (
TopLeft Quadrant2D = iota
TopRight
BottomLeft
BottomRight
)
// QuadRecurse recursively builds a quad tree based on the given Vector2. The
// tree's depth is determined by the n... | unitpacking/quad.go | 0.824037 | 0.693239 | quad.go | starcoder |
package console
import (
"fmt"
"io"
"github.com/martinohmann/neat/style"
)
// Print formats using the default formats for its operands and writes to
// standard output. Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
func Print... | console/printer.go | 0.64646 | 0.533094 | printer.go | starcoder |
package ga
import (
"math"
"wheal-investments-algorithm/funds"
)
//The FundAllocation type
type FundAllocation [11]float64
//The Chromosome type
type Chromosome struct {
FundAllocation FundAllocation
Fitness float64
}
//Calculate the fitness of a chromosome
func (chromosome *Chromosome) CalculateFitness(... | ga/chromosome.go | 0.697197 | 0.483526 | chromosome.go | starcoder |
package plausible
import "strconv"
// BreakdownQuery represents an API query for detailed information about a property over a period of time.
// In an breakdown query, the Property field and the Period fields are mandatory, all the others are optional.
type BreakdownQuery struct {
// Property is the property name fo... | plausible/breakdown_query.go | 0.817028 | 0.493531 | breakdown_query.go | starcoder |
package xi
import "github.com/zephyrtronium/xirho"
// Mobius implements Mobius transformations over quaternions.
type Mobius struct {
Ar xirho.Real `xirho:"A.scalar"`
Avec xirho.Vec3 `xirho:"A.vector"`
Br xirho.Real `xirho:"B.scalar"`
Bvec xirho.Vec3 `xirho:"B.vector"`
Cr xirho.Real `xirho:"C.scalar"`
Cve... | xi/mobius.go | 0.613931 | 0.678513 | mobius.go | starcoder |
package geography
import (
"database/sql/driver"
"encoding/binary"
"errors"
"fmt"
"strconv"
"github.com/go-courier/geography/encoding/mvt"
"github.com/go-courier/geography/encoding/wkb"
"github.com/go-courier/geography/encoding/wkt"
)
// Polygon is a closed area.
// The first Polygon is the outer ring.
// Th... | geom_polygon.go | 0.719778 | 0.466056 | geom_polygon.go | starcoder |
package lazyledger
import (
"encoding/binary"
)
// Message represents a namespaced message.
type Message struct {
namespace [namespaceSize]byte
data []byte
}
// NewMessage returns a new message from its namespace and data.
func NewMessage(namespace [namespaceSize]byte, data []byte) *Message {
return ... | message.go | 0.780244 | 0.402099 | message.go | starcoder |
package instances
// VerifiedStatus captures the verification status for each Instance type.
type VerifiedStatus struct {
// Attempted denotes whether a verification attempt has been made.
Attempted bool
// Verified denotes whether the instance type is verified to work for Reflow.
Verified bool
// ApproxETASecon... | ec2cluster/instances/verified.go | 0.795896 | 0.408513 | verified.go | starcoder |
package geom
import "fmt"
// The Margin type represent 2D margins of a rectangle area.
type Margin struct {
Top float64
Bottom float64
Left float64
Right float64
}
// MakeMargin takes a numeric value as argument that defines the top, left,
// right, and bottom components of the returned margin value.
func ... | margin.go | 0.933363 | 0.677727 | margin.go | starcoder |
package bayes
import (
"math"
"strings"
"github.com/sboehler/knut/lib/journal"
"github.com/sboehler/knut/lib/journal/ast"
)
// Model is a model trained from a journal
type Model struct {
accounts int
accountCounts map[*journal.Account]int
tokenCounts map[string]map[*journal.Account]int
}
// NewModel ... | lib/journal/ast/bayes/bayes.go | 0.612657 | 0.415314 | bayes.go | starcoder |
package day18
type Map [][]string //uint8 ?
func (m Map) ToString() string {
result := ""
for y, line := range m {
if y > 0 {
result += "\n"
}
for _, s := range line {
result += s
}
}
return result
}
func (m Map) ToStringModified(transform func(Point) *string) string {
result := ""
for y, line :=... | day18/lib/map.go | 0.588061 | 0.451387 | map.go | starcoder |
package day3
func GetPowerConsumption(diagReport []uint16, resultBitMask uint16) uint64 {
gamma := getMostCommonBits(diagReport)
epsilon := uint16(^gamma)
epsilon = epsilon & resultBitMask
powerRating := uint64(gamma) * uint64(epsilon)
return powerRating
}
func GetLifeSupportRating(diagReport []uint16, positio... | internal/pkg/day3/diagparser.go | 0.697918 | 0.421076 | diagparser.go | starcoder |
package main
import (
"math"
"strconv"
"strings"
)
type Position struct {
x, y, z int
}
func ParsePositions(lines []string) []Position {
reading := []Position{}
for _, line := range lines {
parts := strings.Split(line, ",")
x, _ := strconv.Atoi(parts[0])
y, _ := strconv.Atoi(parts[1])
z, _ := strconv.... | day19/position.go | 0.692434 | 0.426083 | position.go | starcoder |
package angular
import (
"time"
)
// Units for Acceleration values. Always multiply with a unit when setting the initial value like you would for
// time.Time. This prevents you from having to worry about the internal storage format.
const (
MilliradianPerSecondSquared Acceleration = Acceleration(MilliradianPerSec... | angular/acceleration_generated.go | 0.931634 | 0.607605 | acceleration_generated.go | starcoder |
package main
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/spf13/cobra"
"github.com/koalacxr/nodescan"
)
const ConstNodeScanLogo = `
$$\ $$\ $$\ $$$$$$\
$$$\ $$ | $$ | $$ __$$\ ... | cmds/nodescan/main.go | 0.503174 | 0.741171 | main.go | starcoder |
package uitheme
import (
"image/color"
"fyne.io/fyne"
"fyne.io/fyne/theme"
)
type DarkBlueNormal struct{}
func NewDarkBlueNormal() *DarkBlueNormal {
return &DarkBlueNormal{}
}
func (DarkBlueNormal) BackgroundColor() color.Color {
return ColorDark
}
//func (DarkBlueNormal) ButtonColor() color.Color { return c... | uitheme/darkBlueNormal.go | 0.670716 | 0.429669 | darkBlueNormal.go | starcoder |
package qset
import (
"errors"
"regexp"
"strconv"
"sync"
"time"
"github.com/garyburd/redigo/redis"
"github.com/kavehmz/lww"
)
/*QSet structure defines the structure connects to Redis and needs two connections one for read and write and one for subscribing to channel.
QSet can only store data which is accepta... | qset.go | 0.54577 | 0.41401 | qset.go | starcoder |
package frontend
import (
"fmt"
"strings"
"github.com/isaacev/Plaid/feedback"
"github.com/isaacev/Plaid/source"
)
type Type interface {
Equals(Type) bool
CastsTo(Type) bool
AddMethod(*Method)
HasMethod(string, Type) (bool, Type)
String() string
isType()
}
type Method struct {
operator string
root Ty... | frontend/types.go | 0.697609 | 0.496826 | types.go | starcoder |
package day72
import (
"errors"
)
var errInfiniteLoop = errors.New("loop detected")
// AdjacencyMatrix represents a sparse adjacency matrix.
type AdjacencyMatrix map[int]map[int]struct{}
// Node is a character representation of a node in a graph.
type Node rune
// Edge represents a directed edge going 'From' and ... | day72/problem.go | 0.790854 | 0.498901 | problem.go | starcoder |
package models
// Deployment provides declarative updates for Pods and ReplicaSets (the next-generation ReplicationController).
type Deployment struct {
APIVersion string `yaml:"apiVersion"`
Kind string
Metadata struct {
Name string
Namespace string
Labels struct {
Version string
Date ... | models/deployment.go | 0.708918 | 0.41401 | deployment.go | starcoder |
package packet
import (
"bytes"
"encoding/binary"
"fmt"
"github.com/sandertv/gophertunnel/minecraft/protocol"
"image/color"
)
const (
MapUpdateFlagTexture = 1 << (iota + 1)
MapUpdateFlagDecoration
MapUpdateFlagInitialisation
)
// ClientBoundMapItemData is sent by the server to the client to update the data o... | minecraft/protocol/packet/client_bound_map_item_data.go | 0.608129 | 0.437463 | client_bound_map_item_data.go | starcoder |
package intrusive
import "unsafe"
// List presents a doubly-linked list.
type List struct {
nil ListNode
}
// Init initializes the list and then returns the list.
func (l *List) Init() *List {
l.nil = ListNode{&l.nil, &l.nil}
return l
}
// AppendNode inserts the given node at the end of the list.
// The given no... | list.go | 0.863392 | 0.504394 | list.go | starcoder |
package slice
import "errors"
// PopBool removes and returns the last value a bool slice and the remaining slice.
// An error is returned in case of a nil or empty slice.
func PopBool(a []bool) (bool, []bool, error) {
if len(a) == 0 {
return false, nil, errors.New("Cannot pop from a nil or empty slice")
}
retur... | pop.go | 0.837786 | 0.58163 | pop.go | starcoder |
package minecontract
const MineABI = `[
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "freezeOf",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutabi... | pkg/mine/minecontract/contract_abi.go | 0.540924 | 0.439026 | contract_abi.go | starcoder |
package grid
import (
. "github.com/golangee/forms"
)
const Path = "/demo/grid"
type ContentView struct {
*VStack
}
func NewContentView() *ContentView {
view := &ContentView{}
view.VStack = NewVStack().AddViews(
NewText("Grid").Style(Font(Headline1)),
NewText("A grid allows complex grid based layouts.").St... | demo/grid/component.go | 0.707708 | 0.41561 | component.go | starcoder |
package quasigo
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[opInvalid-0]
_ = x[opPop-1]
_ = x[opDup-2]
_ = x[opPushParam-3]
_ = x[opPushIntParam-4]
_ = x... | vendor/github.com/quasilyte/go-ruleguard/ruleguard/quasigo/opcode_string.go | 0.533884 | 0.422445 | opcode_string.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// IdentityProtectionRoot
type IdentityProtectionRoot struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Ca... | models/identity_protection_root.go | 0.727685 | 0.401923 | identity_protection_root.go | starcoder |
package verb
// init regular verbs
// each entry is a verb that we conjugate
func init() {
for _, present := range regular {
past := VBD.solveRegex(present)
pastParticiple := VBN.solveRegex(present)
present3rd := VBZ.solveRegex(present)
gerund := VBG.solveRegex(present)
entry := []string{
present,
pas... | verb/regular.go | 0.560253 | 0.418103 | regular.go | starcoder |
package common
import (
"image/color"
"github.com/EngoEngine/engo"
"github.com/EngoEngine/gl"
)
// TriangleType is the type of triangle: Right or Isosceles.
type TriangleType uint8
const (
// TriangleIsosceles indicates a Triangle where two sides have equal length
TriangleIsosceles TriangleType = iota
// Tria... | common/render_shapes.go | 0.916489 | 0.667229 | render_shapes.go | starcoder |
package utils
import (
crand "crypto/rand"
"fmt"
"math/rand"
"net/url"
"strings"
"time"
"unicode"
)
// IsStringAbsURL checks a string can be parsed as a URL and that is IsAbs and if it can't it returns an error
// describing why.
func IsStringAbsURL(input string) (err error) {
parsedURL, err := url.Parse(inpu... | internal/utils/strings.go | 0.767254 | 0.410756 | strings.go | starcoder |
package types
import (
"regexp"
)
const (
IntType Datatype = iota
FloatType
StringType
ObjectType
BooleanType
ArrayType
)
type Datatype int
type Column struct {
Name string
items orderedMapType
Dtype Datatype
}
// Returns a list of Items
func (c *Column) Items() []interface{} {
return c.items.ToSlice(... | projects/dataframe/types/column.go | 0.660829 | 0.557123 | column.go | starcoder |
package jwt
import (
"crypto/rsa"
"time"
"gopkg.in/square/go-jose.v2"
"gopkg.in/square/go-jose.v2/jwt"
)
// Encoder is an interface which contains the methods to encode and decode JWT tokens
// given the token claims. It allows to abstract from the details of cryptography, focusing
// only in the token contents.... | jwt/jwt.go | 0.80329 | 0.535098 | jwt.go | starcoder |
package zap
import (
"time"
"github.com/liranbg/uberzap/zapcore"
)
// Array constructs a field with the given key and ArrayMarshaler. It provides
// a flexible, but still type-safe and efficient, way to add array-like types
// to the logging context. The struct's MarshalLogArray method is called lazily.
func Arra... | array.go | 0.803752 | 0.543348 | array.go | starcoder |
package util
import "time"
var (
// Combinatorics is a namespace containing combinatoric functions.
Combinatorics = combinatorics{}
)
type combinatorics struct{}
// CombinationsOfInt returns the "power set" of values less the empty set.
// Use "combinations" when the order of the resulting sets do not matter.
fun... | golang/vendor/github.com/blendlabs/go-util/combinatorics.go | 0.683736 | 0.494934 | combinatorics.go | starcoder |
package lsap
import "github.com/ryanjoneil/ap"
// LSAP solves linear sum assignment problems.
type LSAP struct {
M int64 // A large cost to avoid using edges (default: math.Pow(1000, 3))
n int // n of assignment problem
a [][]int64 // a[i][j] = cost of assigning row i to column j
u []int64 // u[i] = dual pri... | lsap/lsap.go | 0.671686 | 0.431285 | lsap.go | starcoder |
package capnp
// An Address is an index inside a segment's data (in bytes).
type Address uint32
// addSize returns the address a+sz.
func (a Address) addSize(sz Size) Address {
return a.element(1, sz)
}
// element returns the address a+i*sz.
func (a Address) element(i int32, sz Size) Address {
return a + Address(s... | address.go | 0.878393 | 0.430686 | address.go | starcoder |
package main
import "sort"
type dungeonPath struct {
dungeon *dungeon
neighbors [8]position
wcost int
}
func (dp *dungeonPath) Neighbors(pos position) []position {
nb := dp.neighbors[:0]
return pos.Neighbors(nb, position.valid)
}
func (dp *dungeonPath) Cost(from, to position) int {
if dp.dungeon.Cell(to... | path.go | 0.599368 | 0.511046 | path.go | starcoder |
package character
import (
"fmt"
"strconv"
"strings"
"github.com/ironarachne/world/pkg/measurement"
"github.com/ironarachne/world/pkg/random"
"github.com/ironarachne/world/pkg/words"
)
// Description is a description object of a character
type Description struct {
Age string
Culture ... | pkg/character/description.go | 0.776199 | 0.455622 | description.go | starcoder |
package condition
import (
"fmt"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeResource] = TypeSpec{
constructor: NewResour... | lib/processor/condition/resource.go | 0.781497 | 0.682303 | resource.go | starcoder |
package go2d
import (
"math"
"math/rand"
"time"
)
const TICK_DURATION = time.Duration(0)
type VelocityVector struct {
Vector
Duration time.Duration
}
func NewVelocityVector(x, y float64, d time.Duration) VelocityVector {
return VelocityVector{
Vector: Vector{
X: x,
... | go2d/vector.go | 0.888051 | 0.876582 | vector.go | starcoder |
package metrics
import (
"context"
"github.com/prometheus/client_golang/prometheus"
)
// NewHistogram returns a new Histogram and sets its namespace.
func NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram {
opts.Namespace = Namespace
return prometheus.NewHistogram(opts)
}
// MustRegisterHistogra... | pkg/metrics/histogram.go | 0.846324 | 0.407628 | histogram.go | starcoder |
2D Signed Distance Functions
*/
//-----------------------------------------------------------------------------
package sdf
import (
"errors"
"math"
)
//-----------------------------------------------------------------------------
// SDF2 is the interface to a 2d signed distance function object.
type SDF2 inter... | sdf/sdf2.go | 0.843605 | 0.547767 | sdf2.go | starcoder |
package gemini
import (
"bufio"
"fmt"
"io"
"strings"
)
// Line represents a line of a Gemini text response.
type Line interface {
// String formats the line for use in a Gemini text response.
String() string
line() // private function to prevent other packages from implementing Line
}
// LineLink is a link li... | text.go | 0.657978 | 0.437042 | text.go | starcoder |
package histwriter
import (
"fmt"
"io"
"os"
"github.com/HdrHistogram/HdrHistogram"
)
// WriteDistribution writes the percentile distribution of a Histogram in a
// format plottable by http://hdrhistogram.github.io/HdrHistogram/plotFiles.html
// to the given Writer. Percentiles is a list of percentiles to include... | writer.go | 0.730578 | 0.443239 | writer.go | starcoder |
package planparserv2
import (
"fmt"
"github.com/milvus-io/milvus/internal/util/typeutil"
"github.com/milvus-io/milvus/internal/proto/planpb"
"github.com/milvus-io/milvus/internal/proto/schemapb"
)
func IsBool(n *planpb.GenericValue) bool {
switch n.GetVal().(type) {
case *planpb.GenericValue_BoolVal:
return... | internal/parser/planparserv2/utils.go | 0.565299 | 0.513425 | utils.go | starcoder |
package utils
import (
//"fmt"
"fmt"
"math"
"math/big"
"math/rand"
"time"
)
type TupleInt struct {
A int
B int
}
type TupleFloat struct {
A float64
B float64
}
//Euclidean modulous
func Mod(a, b int) int {
ab := big.NewInt(int64(a))
bb := big.NewInt(int64(b))
return int(ab.Mod(ab, bb).Int64())
}
//Dot... | utils/utils.go | 0.644896 | 0.458712 | utils.go | starcoder |
package common
import (
integreatlyv1alpha1 "github.com/integr8ly/integreatly-operator/apis/v1alpha1"
)
var (
rhmiProductOperatorVersions = map[integreatlyv1alpha1.StageName]map[integreatlyv1alpha1.ProductName]integreatlyv1alpha1.OperatorVersion{
integreatlyv1alpha1.AuthenticationStage: {
integreatlyv1alpha1.P... | test/common/operator_versions.go | 0.544559 | 0.402216 | operator_versions.go | starcoder |
package function
import (
"image"
"math"
"sync"
"gocv.io/x/gocv"
)
// Etf is the main entry struct for the edge tangent flow computation.
// It encompass the basic operational entities needed for the matrix operations.
type Etf struct {
flowField gocv.Mat
gradientField gocv.Mat
refinedEtf gocv.Mat
gr... | colidr-openfaas/etf.go | 0.728265 | 0.527195 | etf.go | starcoder |
package llrp
/// Compliance requirement: Compliant Readers and Clients SHALL implement this parameter.
func AccessSpecStopTrigger(AccessSpecStopTriggerType ,OperationCountValue uint) []interface{} {
return commonSpec(
P_AccessSpecStopTrigger,
[]interface{}{
uint8(AccessSpecStopTriggerType),
uint16(Operation... | llrp/params_operations.go | 0.726911 | 0.441372 | params_operations.go | starcoder |
// Package graph defines an abstraction of the SSA graph that facilitates rendering.
package graph
import (
"log"
"golang.org/x/tools/go/ssa"
)
type relationship int
const (
// Referrer represents a node that is referred to as per ssa.Value.Referrers
Referrer relationship = iota
// Operand represents a node t... | internal/pkg/debug/graph/graph.go | 0.745676 | 0.499756 | graph.go | starcoder |
package block
import (
"fmt"
"sort"
"strings"
"time"
"github.com/m3db/m3/src/query/models"
)
// Metadata is metadata for a block, describing size and common tags across
// constituent series.
type Metadata struct {
// Bounds represents the time bounds for all series in the block.
Bounds models.Bounds
// Tag... | src/query/block/meta.go | 0.755907 | 0.459197 | meta.go | starcoder |
package simple
import "k8s.io/kubernetes/third_party/forked/gonum/graph"
// edgeHolder represents a set of edges, with no more than one edge to or from a particular neighbor node
type edgeHolder interface {
// Visit invokes visitor with each edge and the id of the neighbor node in the edge
Visit(visitor func(neighb... | third_party/forked/gonum/graph/simple/edgeholder.go | 0.672654 | 0.760006 | edgeholder.go | starcoder |
package thumbnail
import (
"fmt"
"image"
"math"
"strconv"
"strings"
"github.com/pkg/errors"
)
const (
_resolutionSeperator = "x"
)
// ParseResolution returns an image.Rectangle representing the resolution given as a string
func ParseResolution(s string) (image.Rectangle, error) {
parts := strings.Split(s, _... | thumbnails/pkg/thumbnail/resolutions.go | 0.842475 | 0.494141 | resolutions.go | starcoder |
package tango
// An Axis is an input which is a spectrum of values. An example of this is the horizontal movement in a game, or how far a joystick is pressed.
type Axis struct {
// Name represents the name of the axis (Horizontal, Vertical)
Name string
// Pairs represents the axis pairs of this acis
Pairs []AxisPa... | axis.go | 0.864625 | 0.607168 | axis.go | starcoder |
package cios
import (
"encoding/json"
)
// MultipleDataStoreDataLatest struct for MultipleDataStoreDataLatest
type MultipleDataStoreDataLatest struct {
Total *float32 `json:"total,omitempty"`
Objects *[]PackerFormatJson `json:"objects,omitempty"`
Errors *[]DataError `json:"errors,omitempty"`
}
// NewMultipleDat... | cios/model_multiple_data_store_data_latest.go | 0.78789 | 0.458409 | model_multiple_data_store_data_latest.go | starcoder |
// The heappermutations package implements primitives to generate all
// possible permutations following Heap's algorithm on typed collection.
package heappermutations
// An internal type that defines the generic structure of permutable collections
type heapInterface interface {
// Len returns the number of elements... | heappermutations.go | 0.711932 | 0.460895 | heappermutations.go | starcoder |
package scanutil
import (
"errors"
"strconv"
"strings"
"unicode"
)
type Matcher struct {
sc *Scanner
}
func (m *Matcher) Rune(ru rune) bool {
return m.sc.RewindOnFalse(func() bool {
return m.sc.ReadRune() == ru
})
}
func (m *Matcher) End() bool {
return m.Rune(Eof) || m.Rune(readErr)
}
func (m *Matcher) ... | util/scanutil/matcher.go | 0.604516 | 0.448064 | matcher.go | starcoder |
package nitro
import (
"image"
"image/color"
"image/draw"
"math"
)
// BUG: these drawing routines may be incorrect when src and dst overlap
// DrawUnder aligns r.Min in dst with sp in src and replaces r with the result of (src over dst).
func drawUnder(dst draw.Image, r image.Rectangle, src image.Image, sp image... | nitro/draw.go | 0.556641 | 0.552359 | draw.go | starcoder |
package noarch
import (
"math"
)
// Signbitf ...
func Signbitf(x float32) int {
return BoolToInt(math.Signbit(float64(x)))
}
// Signbitd ...
func Signbitd(x float64) int {
return BoolToInt(math.Signbit(x))
}
// Signbitl ...
func Signbitl(x float64) int {
return BoolToInt(math.Signbit(x))
}
// IsNaN ...
func Is... | noarch/math.go | 0.905897 | 0.738127 | math.go | starcoder |
package querier
import (
"sort"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage"
"github.com/weaveworks/cortex/pkg/prom1/storage/metric"
)
// errSeriesSet implements storage.SeriesSet, just returning an error.
type errSeriesSet struct... | pkg/querier/series_set.go | 0.761804 | 0.522202 | series_set.go | starcoder |
package server
type L2MeasCellInfo struct {
// It indicates the packet discard rate in percentage of the downlink GBR traffic in a cell, as defined in ETSI TS 136 314 [i.11].
DlGbrPdrCell int32 `json:"dl_gbr_pdr_cell,omitempty"`
// It indicates the PRB usage for downlink GBR traffic, as defined in ETSI TS 136 314 [... | go-apps/meep-rnis/server/model_l2_meas_cell_info.go | 0.519034 | 0.560734 | model_l2_meas_cell_info.go | starcoder |
package entity
type LabelMap map[string]Label
func (m LabelMap) Get(name string) Label {
if result, ok := m[name]; ok {
return result
}
return *NewLabel(name, 0)
}
func (m LabelMap) Pointer(name string) *Label {
if result, ok := m[name]; ok {
return &result
}
return NewLabel(name, 0)
}
func (m LabelMap)... | internal/entity/label_fixtures.go | 0.625095 | 0.423756 | label_fixtures.go | starcoder |
package nlptools
import (
"crypto/md5"
"encoding/hex"
"github.com/broosaction/gotext/tokenizers"
stringUtils "github.com/broosaction/gotext/utils/strings"
"math"
)
/*
TFIDF is a Term Frequency- Inverse
Document Frequency model that is created
from a trained NaiveBayes model (they
are very similar so you can jus... | nlp/nlptools/tfidf.go | 0.601945 | 0.439988 | tfidf.go | starcoder |
package shape
import (
"fmt"
"io"
"math"
"github.com/gregoryv/go-design/xy"
)
func NewRect(title string) *Rect {
return &Rect{
Title: title,
Font: DefaultFont,
Pad: DefaultTextPad,
class: "rect",
}
}
type Rect struct {
X, Y int
Title string
Font Font
Pad Padding
class string
}
func (r *R... | shape/rect.go | 0.708918 | 0.406037 | rect.go | starcoder |
package lyft
// A non-guaranteed estimate of price
type CostEstimate struct {
RideType RideTypeEnum `json:"ride_type,omitempty"`
// A human readable description of the ride type
DisplayName string `json:"display_name,omitempty"`
// The ISO 4217 currency code for the amount (e.g. 'USD')
Currency string `json:"c... | lyft/cost_estimate.go | 0.800809 | 0.418935 | cost_estimate.go | starcoder |
package lookup
import (
"encoding/binary"
"errors"
"fmt"
)
// Epoch represents a time slot at a particular frequency level
type Epoch struct {
Time uint64 `json:"time"` // Time stores the time at which the update or lookup takes place
Level uint8 `json:"level"` // Level indicates the frequency level as the e... | vendor/github.com/ethereum/go-ethereum/swarm/storage/feed/lookup/epoch.go | 0.899998 | 0.428532 | epoch.go | starcoder |
package manifest
import "sort"
// LevelMetadata contains metadata for all of the files within
// a level of the LSM.
type LevelMetadata struct {
files []*FileMetadata
}
// Empty indicates whether there are any files in the level.
func (lm *LevelMetadata) Empty() bool {
return lm.Len() == 0
}
// Len returns the n... | internal/manifest/level_metadata.go | 0.652906 | 0.421254 | level_metadata.go | starcoder |
package maze
import (
"bytes"
"math/rand"
"time"
)
// Grid is an interface of grid.
type Grid interface {
Rows() int
Cols() int
Get(int, int) *Cell
Random() *Cell
Size() int
EachRow() [][]*Cell
EachCell() []*Cell
String() string
DeadEnds() []*Cell
Braid(float64)
}
// NormalGrid is a grid containing all ... | go/maze/grid.go | 0.860384 | 0.412412 | grid.go | starcoder |
package persist
import (
"errors"
)
// LogType is used to describe different types of log entries.
type LogType uint8
// Differents types of log entries.
const (
LogUnknown LogType = iota
// LogCommand is applied to the FSM.
LogCommand
// LogNoop is used to ensure the leadership for leader.
... | persist/log.go | 0.666388 | 0.429788 | log.go | starcoder |
package clipper
import (
"go/ast"
"go/parser"
"go/token"
"strings"
)
// GoNewImportPositionData stores data collected during a selection of a new import position.
type GoNewImportPositionData struct {
ShouldAddNewLine bool
OnlyURLNeeded bool
}
// GoBeforeFunctionReturnsPositionData stores data collected dur... | starport/pkg/clipper/goselection.go | 0.673836 | 0.618348 | goselection.go | starcoder |
package dlog
import (
"fmt"
"math"
"strconv"
"github.com/spf13/cobra"
"github.com/timebertt/grypto/modular"
)
func NewCommand() *cobra.Command {
var x, base, mod int32
cmd := &cobra.Command{
Use: "dlog [x] [base] [modulus]",
Short: "Calculate the discrete logarithm of x to the given base mo... | grypto/cmd/dlog/dlog.go | 0.801042 | 0.484136 | dlog.go | starcoder |
package dilithium
import (
"github.com/openziti/dilithium/util"
"github.com/pkg/errors"
)
/*
* ACK Encoding Format
*
* If the high-bit of the first byte of the ACK region is low, then this is a single int32 containing a sequence number.
*
* If the high-bit of the first byte of the ACK region is high, then we k... | ack.go | 0.640973 | 0.736211 | ack.go | starcoder |
package regression
import (
"math"
)
//Regression represents a queue of past points. Use New() to initialize.
type Regression struct {
xSum, ySum, xxSum, xySum, yySum, xDelta float64
lastSlopeCalc, lastInterceptCalc, lastStdErrorCalc float64
N int
//he... | v1/regression.go | 0.842507 | 0.650287 | regression.go | starcoder |
package main
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/jakecoffman/cp"
"github.com/jakecoffman/cpebiten"
"log"
"math"
)
const (
screenWidth = 600
screenHeight = 480
)
const (
PlayerVelocity = 500.0
PlayerGroundAccelTime = 0.1
PlayerGroundAccel = PlayerVelocity / PlayerGroundAccelTime
... | player/player.go | 0.598195 | 0.443781 | player.go | starcoder |
package swapi
// TestCharacters is a list of sample Character objects, taken mostly from
// https://swapi.dev/ and https://starwars.fandom.com/
var TestCharacters = []Character{
{
Name: "<NAME>",
Height: 172,
Mass: 77,
HairColor: "blond",
Gender: "male",
ForceSensi... | cli-experiments/cobra-k8s-selectors/pkg/swapi/data.go | 0.561215 | 0.446012 | data.go | starcoder |
package matrix
import "errors"
// Matrix is a square matrix.
// It`s underlying [][]int slice is guaranteed to be sliced from one
// linear backing array, which allows some copying optimizations.
type Matrix [][]int
// ConvertToMatrix converts raw [][]int slice to square matrix
func ConvertToMatrix(slice [][]int) Ma... | solver/matrix/matrix.go | 0.782579 | 0.567158 | matrix.go | starcoder |
package heldiamgo
import (
"image"
"image/color"
)
//绘图
//圆形 https://blog.golang.org/go-imagedraw-package
type Circle struct {
p image.Point
r int
}
//新建一个圆形,p为圆形中心点. r为半径
func NewCircle(p image.Point, r int) *Circle {
return &Circle{
p: p,
r: r,
}
}
func (c *Circle) ColorModel() color.Model {
return co... | image.go | 0.646349 | 0.412234 | image.go | starcoder |
package output
import (
"github.com/Jeffail/benthos/v3/internal/component/output"
"github.com/Jeffail/benthos/v3/internal/docs"
"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"
... | lib/output/aws_sqs.go | 0.782081 | 0.457985 | aws_sqs.go | starcoder |
// Package core contains a set of primitives, including but not limited to various
// elliptic curves, hashes, and commitment schemes. These primitives are used internally
// and can also be used independently on their own externally.
package core
import (
crand "crypto/rand"
"crypto/subtle"
"fmt"
"math/big"
"g... | pkg/core/mod.go | 0.852951 | 0.549036 | mod.go | starcoder |
package metric
import (
"math"
"github.com/emer/etable/etensor"
)
// ClosestRow32 returns the closest fit between probe pattern and patterns in
// an etensor.Float32 where the outer-most dimension is assumed to be a row
// (e.g., as a column in an etable), using the given metric function,
// *which must have the ... | metric/tensor.go | 0.867036 | 0.621541 | tensor.go | starcoder |
package raylib
//#include "raylib.h"
import "C"
import "unsafe"
/*
Rectangle Structure
author: Lachee
source: https://github.com/raysan5/raylib/blob/master/src/raylib.h
*/
type Rectangle struct {
X float32
Y float32
Width float32
Height float32
}
//NewRectangle creates a new rect
func NewRectangle(x,... | raylib/rectangle.go | 0.94281 | 0.789802 | rectangle.go | starcoder |
package characters
var (
RaceTraitArmored = &RaceTrait{
Name: "Armored",
Description: "The species possess thick fur, scales, a bony exoskeleton or other natural protection that gives it one point of natural armour. This works in the same way as normal armour.",
}
RaceTraitAquatic = &RaceTrait{
Name: ... | pkg/game/characters/racetraits.go | 0.574753 | 0.656982 | racetraits.go | starcoder |
package ast
import (
"bytes"
"github.com/cespare/xxhash/v2"
"github.com/jensneuse/graphql-go-tools/internal/pkg/unsafebytes"
)
// Index is a struct to easily look up objects in a document, e.g. find Nodes (type/interface/union definitions) by name
type Index struct {
// QueryTypeName is the name of the query ty... | pkg/ast/index.go | 0.563378 | 0.405508 | index.go | starcoder |
package trie
import (
"io"
"fmt"
"strings"
)
// treeNode provides an interface for node implementations
type treeNode interface {
// Child returns the child node for the given rune or nil if else
Child(r rune) treeNode
// AddChild adds a new child to the node
AddChild(r rune, n treeNode)
// Remove removes an ... | node.go | 0.725162 | 0.496643 | node.go | starcoder |
package ast
// Visitor is an interface for the structs which is used for traversing AST.
type Visitor interface {
// Visit defines the process when a node is visit.
// Visitor is a next visitor to use for visit.
// When wanting to stop visiting, return nil.
Visit(n Node) Visitor
}
// Visit visits the tree with th... | next/compiler/ast/visitor.go | 0.540196 | 0.520679 | visitor.go | starcoder |
package gander
import (
"fmt"
"math"
"sort"
)
// A Series represents a column of data in a DataFrame.
type Series struct {
Name string
Values []float64
categoricalLabels map[float64]string
categoricalValues map[string]float64
}
// NewSeries creates a new Series with the... | series.go | 0.791781 | 0.45181 | series.go | starcoder |
package sim
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
// InitCond implements filter.InitCond
type InitCond struct {
state *mat.VecDense
cov *mat.SymDense
}
// NewInitCond creates new InitCond and returns it
func NewInitCond(state mat.Vector, cov mat.Symmetric) *InitCond {
s := &mat.VecDense{}
s.CloneFromVec... | sim/model.go | 0.78789 | 0.483892 | model.go | starcoder |
package srcobj
import (
"io"
"strings"
)
type hardToAccessBinaryOperator struct {
operator string
operand1 Source
operand2 Source
}
func (h hardToAccessBinaryOperator) Dump(w io.Writer) error {
data := String(h.operand1)
data = strings.TrimRight(data, "\n")
if _, err := io.WriteString(w, data); err != nil {
... | internal/generator/gogen/internal/srcobj/operators.go | 0.558327 | 0.411554 | operators.go | starcoder |
package datetime
import (
"errors"
"time"
)
// A Week is a main package data type
type Week struct {
Days []time.Time
Year int
Number int
}
// NewWeek constructs new Week entity from given parameters (year and ISO-8601-compatible week number)
func NewWeek(params ...int) (*Week, error) {
if len(params) < 2 ... | utils/datetime/week.go | 0.646572 | 0.48749 | week.go | starcoder |
package detest
import (
"fmt"
"reflect"
"unsafe"
)
// StructComparer implements comparison of struct values.
type StructComparer struct {
with func(*StructTester)
}
// Struct takes a function which will be called to do further comparisons of
// the struct's contents. Note that you must pass a struct _pointer_ to... | pkg/detest/struct.go | 0.76921 | 0.501526 | struct.go | starcoder |
package commands
const initializeConfirmationText = `
You are about to initialize a major-version upgrade of Greenplum.
This should be done only during a downtime window.
gpupgrade initialize will perform a series of steps, including:
- Check disk space
- Create the target cluster
- Run pg_upgrade consistency che... | cli/commands/confirmation_text.go | 0.612078 | 0.555435 | confirmation_text.go | starcoder |
package cgo
// This file implements a parser of a subset of the C language, just enough to
// parse common #define statements to Go constant expressions.
import (
"fmt"
"go/ast"
"go/scanner"
"go/token"
"strings"
)
// parseConst parses the given string as a C constant.
func parseConst(pos token.Pos, fset *token.... | cgo/const.go | 0.693784 | 0.527256 | const.go | starcoder |
package tree
import "fmt"
var limit = 3 // maximum amount of childs for each nodes
type Tree struct {
root *Node
}
type Node struct {
parent *Node
child []*Node
data Data
}
type Data struct {
Id int
}
type Result struct {
Parent int
Child []int
Data Data
}
var treeIndex map[int]*Node
func addNode (pare... | tree.go | 0.55254 | 0.505005 | tree.go | starcoder |
package reflection
import (
"reflect"
)
// NewValue creates a reflection wrapper around given value.
func NewValue(v interface{}) Value {
return Value{
RVal: reflect.ValueOf(v),
}
}
// Value represents every value in parens.
type Value struct {
RVal reflect.Value
}
// To converts the value to requested kind i... | reflection/value.go | 0.776665 | 0.458652 | value.go | starcoder |
package iso20022
// Details about tax paid, or to be paid, to the government in accordance with the law, including pre-defined parameters such as thresholds and type of account.
type TaxInformation4 struct {
// Party on the credit side of the transaction to which the tax applies.
Creditor *TaxParty1 `xml:"Cdtr,omit... | TaxInformation4.go | 0.764012 | 0.53959 | TaxInformation4.go | starcoder |
package modelapi
import "github.com/heustis/tsp-solver-go/graph"
// PointGraph is the API representation of a single point in a graph.
// It references its neighbors by name, in an array, to avoid circular references and have consistent field names in its JSON representation.
type PointGraph struct {
Id string `json... | modelapi/pointgraph.go | 0.846356 | 0.510496 | pointgraph.go | starcoder |
package automaton
import (
"fmt"
"github.com/gzg1984/golucene/core/util"
"sort"
"unicode"
)
// util/automaton/Automaton.java
/*
Represents an automaton and all its states and transitions. States
are integers and must be created using {@link #createState}. Mark a
state as an accept state using {@link #setAccept}... | core/util/automaton/automaton.go | 0.711732 | 0.455744 | automaton.go | starcoder |
package histogram
// Bin represents a histogram bin
type Bin struct {
Key int
Count int
}
// Bin is a slice of bins
type Bins []Bin
// IsFull returns true if the bin is filled to capacity
func (b Bin) IsFull(h Histogram) bool {
return b.Count == h.BinCapacity
}
// Histogram is a structure composed of bins
type... | histogram/histogram.go | 0.866175 | 0.694905 | histogram.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.