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 |
|---|---|---|---|---|---|
%%%-------------------------------------------------------------------
%%% @author <NAME>, <NAME> <>
%%% @copyright (C) 2013, <NAME>, <NAME>, <NAME>
%%% @doc
%% Arithmetic Simplifications Core - Basic straightforward arithmetic simplifications. The following simplifications are covered:
%% <ul>
%%<li><b>Sum by zero</b... | src/symbolic_evaluation/core/core_arit_simpl.erl | 0.50293 | 0.516169 | core_arit_simpl.erl | starcoder |
%% @doc The `couchdb_mango' module contains functionality listed under CouchDB API
%% Reference section 1.3.6.
%%
%% Now let’s do something a little more useful: create databases. For the strict, CouchDB
%% is a database management system (DMS). That means it can hold multiple databases. A
%% database is a bucket tha... | src/sections/couchdb_databases/couchdb_databases.erl | 0.519765 | 0.4436 | couchdb_databases.erl | starcoder |
%%% @author <NAME> <<EMAIL>>
%%% @copyright (C) 2021, <NAME>
%%% @doc
%%% Basic associative network.
%%% @end
%%% Created : 20 Feb 2021 by <NAME> <<EMAIL>>
-module(network).
-export([empty/0, empty/1, from_edges/1, from_edges/2, ring/2]).
-export([neighbors/2, all_nodes/1, all_edges/1, foreach_node/2]).
-record(netw... | src/network.erl | 0.570331 | 0.545649 | network.erl | starcoder |
%%%
%%% Copyright 2020 RBKmoney
%%%
%%% 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 agr... | src/machinegun_hay.erl | 0.653901 | 0.446796 | machinegun_hay.erl | starcoder |
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2011-2018. All Rights Reserved.
%%
%% 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
%%
... | lib/compiler/src/beam_split.erl | 0.503662 | 0.48054 | beam_split.erl | starcoder |
-module(rstar_geometry).
-export([new/3, origin/1, point2d/3, point3d/4, bounding_box/1,
area/1, intersect/2, num_edges/1, margin/1, center/1,
distance/2, min_dist/2, value/1]).
-include("../include/rstar.hrl").
% Creates a new geometry record
-spec new(integer(), list({float(), float()}), any()) ->... | src/rstar_geometry.erl | 0.824285 | 0.754757 | rstar_geometry.erl | starcoder |
%% @copyright 2013-2017 Zuse Institute Berlin
% 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 ... | test/rbr_interleaving_SUITE.erl | 0.585338 | 0.42925 | rbr_interleaving_SUITE.erl | starcoder |
%%%------------------------------------------------------------------------
%% Copyright 2019, OpenTelemetry Authors
%% 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.o... | src/ot_meter.erl | 0.826151 | 0.445047 | ot_meter.erl | starcoder |
%% @doc
%% `rebar3_hex_organization' - Manage organizations
%%
%% Manages the list of authorized hex organizations.
%%
%% Note that all commands that require a `NAME' argument expect a qualified repository name for the
%% argument (i.e., `hexpm:my_org').
%%
%% == About Organizations ==
%%
%% Organizations are feature... | src/rebar3_hex_organization.erl | 0.613468 | 0.407569 | rebar3_hex_organization.erl | starcoder |
%%%-------------------------------------------------------------------
%%% @doc
%%% Utility functions for converting and viewing digraph graphs.
%%% @end
%%%-------------------------------------------------------------------
-module(digraph_export).
-define(TEMP_LABEL, (atom_to_list(?MODULE))).
-define(TEMP_FILE, "gra... | src/digraph_export.erl | 0.545286 | 0.463626 | digraph_export.erl | starcoder |
%% Copyright 2019-2020 Klarna Bank AB
%% Copyright 2021 snabbkaffe contributors
%%
%% 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
%%
%% ... | src/asciiart.erl | 0.702122 | 0.572573 | asciiart.erl | starcoder |
%%
%% Copyright (c) 2018 <NAME>. All Rights Reserved.
%%
%% This file is provided to you 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
%%
%% Unl... | src/op_lwwmap.erl | 0.670608 | 0.407864 | op_lwwmap.erl | starcoder |
-module(interval).
-export([new/2, length/1, contains/2, contains/3, split/2, split/3,
preceeds/2, adjacent/2, merge/2]).
-export_type([interval/0]).
-record(interval, {left :: rational:rational(),
right :: rational:rational()}).
-type interval() :: #interval{}.
%% @doc Create a new inte... | src/interval.erl | 0.831998 | 0.613584 | interval.erl | starcoder |
% Copyright 2007-2008 Konrad-Zuse-Zentrum für Informationstechnik Berlin
%
% 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
%
% Unle... | src/intervals.erl | 0.586523 | 0.4856 | intervals.erl | starcoder |
%%
%% @doc Implementation of RSA encryption functions.
%%
%% @reference [FSK1] Chapter 12. RSA
%%
-module(rsa).
-author("<NAME>").
-export([generate_rsa_key/1, generate_rsa_prime/1]).
-export([decrypt_random_key_with_rsa/2, encrypt_random_key_with_rsa/1]).
-export([msg_to_rsa_number/2, sign_with_rsa/2, verify_rsa_sign... | lib/ndpar/src/rsa.erl | 0.742328 | 0.679059 | rsa.erl | starcoder |
package perlin
import (
"math"
"math/rand"
)
// General constants
const (
B = 0x100
N = 0x1000
BM = 0xff
)
// Perlin is the noise generator
type Perlin struct {
alpha float64
beta float64
n int
p [B + B + 2]int
g3 [B + B + 2][3]float64
g2 [B + B + 2][2]float64
g1 [B + B + 2]float64
}
// NewPerl... | vendor/github.com/aquilax/go-perlin/perlin.go | 0.664323 | 0.480966 | perlin.go | starcoder |
package ql
import (
"bufio"
"bytes"
"io"
"strings"
)
// Scanner represents a lexical scanner.
type Scanner struct {
r *bufio.Reader
}
// NewScanner returns a new instance of Scanner.
func NewScanner(r io.Reader) *Scanner {
return &Scanner{r: bufio.NewReader(r)}
}
// Scan returns the next token and literal val... | plugins/data/parser/ql/ql/v1/scanner.go | 0.739986 | 0.425068 | scanner.go | starcoder |
package completion
import (
"context"
"go/ast"
"go/types"
)
// builtinArgKind determines the expected object kind for a builtin
// argument. It attempts to use the AST hints from builtin.go where
// possible.
func (c *completer) builtinArgKind(ctx context.Context, obj types.Object, call *ast.CallExpr) objKind {
... | internal/lsp/source/completion/builtin.go | 0.562177 | 0.409103 | builtin.go | starcoder |
package lib
import (
"regexp"
"strconv"
)
var regWordSep = regexp.MustCompile(`\d+`)
// AutoPattern auto generate a regexp to match the index of sequential file names.
// Algorithm:
// 1. Create a table, the row is each path, the column is the words of each path.
// 2. Create histogram of the words in each column.... | lib/auto_pattern.go | 0.683842 | 0.443118 | auto_pattern.go | starcoder |
package varis
// Neuron - interface for all Neuron
// Each Neuron must have coreNeuron and getCore() to get pointer for CoreNeuron
// Live method - for goroutine. All kind of Neurons implement functionality of his type
// changeWeight is the method for training
type Neuron interface {
live()
getCore() *CoreNeuron
c... | neuron.go | 0.752559 | 0.522994 | neuron.go | starcoder |
package mit
import (
"errors"
"time"
)
// ErrBadTermCode is reported when the given term code doesn't exist.
var ErrBadTermCode = errors.New("mit: unknown term code")
// A TermInfo struct contains information about an academic term.
type TermInfo struct {
Code string
FirstDayOfClasses time.Time
Las... | mit/term.go | 0.537284 | 0.515742 | term.go | starcoder |
package util
import (
"io"
)
// Size of the buffer used for calculating file chunks.
const chunksCalculationBufferSizeBytes = 4096
// FileChunk describes a chunk within a file with its starting position and end
// position in bytes. Both are given as bytes counted from the file's beginning.
// Also carries informa... | util/fileAnalyzer.go | 0.550366 | 0.431644 | fileAnalyzer.go | starcoder |
package metric
import (
"fmt"
"strings"
)
// SourceType defines the kind of data source. Based on this SourceType, metric
// package performs some calculations with it. Check below the description for
// each one.
type SourceType int
// Source types
// If any more SourceTypes are added update maps: SourcesTypeToNa... | vendor/github.com/newrelic/infra-integrations-sdk/v4/data/metric/source_type.go | 0.628293 | 0.472866 | source_type.go | starcoder |
package delete
import (
"bytes"
"testing"
"github.com/hpcng/singularity/e2e/internal/e2e"
"github.com/hpcng/singularity/e2e/internal/testhelper"
)
type ctx struct {
env e2e.TestEnv
}
func (c ctx) testDeleteCmd(t *testing.T) {
tests := []struct {
name string
args []string
agree string
... | e2e/delete/delete.go | 0.553747 | 0.482063 | delete.go | starcoder |
package main
import (
"encoding/xml"
"fmt"
"os"
"github.com/freddy33/graphml"
"github.com/sirupsen/logrus"
)
// NodeLabelID is the ID of the GraphML attribute used for the label of nodes in the graph
const NodeLabelID = "node-label"
// NodeLabelName is the name of the GraphML attribute used for the label of no... | graphmlutil.go | 0.591605 | 0.484197 | graphmlutil.go | starcoder |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "rand"
const Count = 1e5
func i64rand() int64 {
for {
a := int64(rand.Uint32())
a = (a << 32) | int64(rand.Uint32())
a >>= uint(r... | test/ken/modconst.go | 0.541651 | 0.495667 | modconst.go | starcoder |
package slice
import (
"fmt"
"sort"
)
type Ordered interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string
}
// Unique returns a new slice that is sorted with all the duplicate strings removed.
func Unique[T Ordered](ss []T) []T... | slice.go | 0.770551 | 0.447098 | slice.go | starcoder |
package primitives
import (
"fmt"
"math"
"github.com/FactomProject/factomd/common/constants"
"github.com/FactomProject/factomd/common/interfaces"
)
var _ = fmt.Println
// NextPowerOfTwo returns the next highest power of two from a given number if
// it is not already a power of two. This is a helper function ... | common/primitives/merkle.go | 0.658308 | 0.517937 | merkle.go | starcoder |
package chart
type Axes struct {
// A point on the Y axis at which the chart displays a horizontal line, indicating the max Y value of interest. Points with a Y value that exceeds the high water mark still appear.<br> **Notes:** * SignalFx only uses this value for time series charts. * Value must be less than or ... | chart/model_axes.go | 0.916367 | 0.800458 | model_axes.go | starcoder |
package main
import (
"sort"
"strings"
)
// copied from elsewhere in the codebase (migration shouldn't import from
// codebase)
func newUnionFind(pks []string) *unionFind {
ret := &unionFind{
parents: make(map[string]string, len(pks)),
ranks: make(map[string]int, len(pks)),
}
for _, pk := range pks {
re... | wifi/cloud/go/tools/migrations/m003_configurator/plugin/union.go | 0.654343 | 0.426083 | union.go | starcoder |
package xorfilter
import (
"errors"
"math"
"math/bits"
"sort"
)
type BinaryFuse8 struct {
Seed uint64
SegmentLength uint32
SegmentLengthMask uint32
SegmentCount uint32
SegmentCountLength uint32
Fingerprints []uint8
}
func calculateSegmentLength(arity uint32, size uint32) uint32 {... | binaryfusefilter.go | 0.619241 | 0.571946 | binaryfusefilter.go | starcoder |
// This file must be kept in sync with index_bound_checks.go.
//+build !bounds
package mat64
import "github.com/gonum/blas"
// At returns the element at row r, column c.
func (m *Dense) At(r, c int) float64 {
if r >= m.mat.Rows || r < 0 {
panic(ErrRowAccess)
}
if c >= m.mat.Cols || c < 0 {
panic(ErrColAcces... | vendor/github.com/gonum/matrix/mat64/index_no_bound_checks.go | 0.761538 | 0.512266 | index_no_bound_checks.go | starcoder |
package sc
// JPverb is a reverb effect from sc3-plugins.
// See https://github.com/supercollider/sc3-plugins
// and http://doc.sccode.org/Classes/JPverb.html
type JPverb struct {
// In is the input signal.
In Input
// T60 is time for the reverb to decay 60db.
// Does not effect early reflections. (0.1..60)
T60 ... | vendor/github.com/scgolang/sc/jpverb.go | 0.698227 | 0.490114 | jpverb.go | starcoder |
package cron
import (
"fmt"
"strings"
"time"
)
var (
_ Schedule = (*DailySchedule)(nil)
_ fmt.Stringer = (*DailySchedule)(nil)
)
// WeeklyAtUTC returns a schedule that fires on every of the given days at the given time by hour, minute and second in UTC.
func WeeklyAtUTC(hour, minute, second int, days ...tim... | cron/daily_schedule.go | 0.767864 | 0.617397 | daily_schedule.go | starcoder |
package semver
import (
"bytes"
"fmt"
"regexp"
"strings"
"github.com/blang/semver"
)
type queryOp int
// An arithmetic operation requires a hard version query.
// Placeholders are expanded to zero in these cases
const (
queryEq queryOp = 0
queryLt queryOp = 1
queryGt queryOp = 2
queryLe queryOp = 3
queryG... | pkg/npm/semver/query.go | 0.615088 | 0.495484 | query.go | starcoder |
package main
import (
"fmt"
)
type position struct {
X int
Y int
}
func (pos position) E() position {
return position{pos.X + 1, pos.Y}
}
func (pos position) SE() position {
return position{pos.X + 1, pos.Y + 1}
}
func (pos position) NE() position {
return position{pos.X + 1, pos.Y - 1}
}
func (pos position... | pos.go | 0.653459 | 0.651895 | pos.go | starcoder |
package model
import (
"time"
)
// AggregationsConfig is used to configure aggregation behaviour.
type AggregationsConfig struct {
// MemoryAggregationInterval is the length of a single interval, for
// which the peak memory usage is computed.
// Memory usage peaks are aggregated in multiples of this interval. In... | pkg/recommender/model/aggregations_config.go | 0.71113 | 0.412294 | aggregations_config.go | starcoder |
package packed
// Efficient sequential read/write of packed integers.
type BulkOperationPacked5 struct {
*BulkOperationPacked
}
func newBulkOperationPacked5() BulkOperation {
return &BulkOperationPacked5{newBulkOperationPacked(5)}
}
func (op *BulkOperationPacked5) decodeLongToInt(blocks []int64, values []int32, i... | core/util/packed/bulkOperation5.go | 0.55447 | 0.769384 | bulkOperation5.go | starcoder |
package hbook
import "sort"
// indices for the 2D-binning overflows
const (
BngNW int = 1 + iota
BngN
BngNE
BngE
BngSE
BngS
BngSW
BngW
)
type Binning2D struct {
Bins []Bin2D
Dist Dist2D
Outflows [8]Dist2D
XRange Range
YRange Range
Nx int
Ny int
XEdges []Bin1D
YEdges []Bi... | hbook/binning2d.go | 0.563378 | 0.562237 | binning2d.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// ExpressionEvaluationDetails
type ExpressionEvaluationDetails struct {
// Stores additional data not described in the OpenAPI description found when deseria... | models/expression_evaluation_details.go | 0.702428 | 0.491639 | expression_evaluation_details.go | starcoder |
package collections
import "fmt"
/*
Compare - This method will compare two collections to make sure they
are the same. The collection receiver is the master and represent the correct
data, the collection passed in as toTest represents the one we need to test.
*/
func (r *Collection) Compare(toTest *Collection) (bool... | objects/taxii/collections/compare.go | 0.78789 | 0.492066 | compare.go | starcoder |
package expect
import (
. "fmt"
"reflect"
)
type Have struct {
Else *Else
And *Have
t T
actual interface{}
assert bool
}
func newHave(t T, e *Else, actual interface{}, assert bool) *Have {
have := &Have{
Else: e,
t: t,
actual: actual,
assert: assert,
}
have.And = have
return have
... | have.go | 0.647241 | 0.554169 | have.go | starcoder |
package matcher
import (
"errors"
"fmt"
"reflect"
"regexp"
"github.com/stretchr/testify/assert"
"github.com/swaggest/assertjson"
)
// Matcher determines if the actual matches the expectation.
type Matcher interface {
Match(actual interface{}) (bool, error)
Expected() string
}
var _ Matcher = (*ExactMatcher)... | matcher.go | 0.866076 | 0.553204 | matcher.go | starcoder |
package main
import (
. "github.com/asuahsahua/advent2019/cmd/common"
"reflect"
"regexp"
"strconv"
)
// --- Day 12: The N-Body Problem ---
// The space near Jupiter is not a very safe place; you need to be careful of a
// big distracting red spot, extreme radiation, and a whole lot of moons
// swirling around.
... | cmd/day12/main.go | 0.737158 | 0.499939 | main.go | starcoder |
package main
import (
"fmt"
"image/color"
"log"
"github.com/alexdesi/collisions/detector"
"github.com/alexdesi/collisions/shapes2D"
"github.com/alexdesi/collisions/vectors"
"github.com/alexdesi/collisions/wren"
"github.com/hajimehoshi/ebiten/v2"
)
type Game struct{}
func (g *Game) Update() error {
// Actu... | main.go | 0.581184 | 0.436022 | main.go | starcoder |
package view
import (
"fmt"
"unicode/utf8"
termbox "github.com/nsf/termbox-go"
"github.com/borkshop/bork/internal/point"
)
// Grid represents a sized buffer of terminal cells.
type Grid struct {
Size point.Point
Data []termbox.Cell
}
// MakeGrid makes a new Grid with the given size.
func MakeGrid(sz point.Po... | internal/view/grid.go | 0.657868 | 0.428592 | grid.go | starcoder |
package ahocorasick
const (
TABLE_WIDTH = 1024
)
// A node in the trie structure used to implement Aho-Corasick
type node struct {
b []byte // The blice at this node
output bool // True means this node represents a blice that should
// be output when matching
index int // index into original dictionary if outp... | ahocorasick.go | 0.672009 | 0.496399 | ahocorasick.go | starcoder |
package gosfmt
// Int63r generates pseudo random int64 between low and high.
// Input:
// low -- lower limit
// high -- upper limit
// Output:
// random int64
func (r *Rand) Int63r(low, high int64) int64 {
return r.Int63()%(high-low+1) + low
}
// Int63s generates pseudo random integers between low and high.... | rand_gosl.go | 0.511229 | 0.531817 | rand_gosl.go | starcoder |
package main
import (
"fmt"
"math"
)
type world struct {
radius float64
}
func rad(deg float64) float64 {
return deg * math.Pi / 180
}
type location struct {
lat, long float64
}
type coordinate struct {
d, m, s float64
h rune
}
// distance calculation using the Spherical Law of Cosines.
func (w world... | lesson22/distance/distance.go | 0.792946 | 0.445831 | distance.go | starcoder |
// Package slicetype implements data types and utilities to describe
// Bigslice types: Slices, Frames, and Tasks all carry
// slicetype.Types.
package slicetype
import (
"fmt"
"reflect"
"strings"
)
// A Type is the type of a set of columns.
type Type interface {
// NumOut returns the number of columns.
NumOut(... | slicetype/slicetype.go | 0.581897 | 0.547948 | slicetype.go | starcoder |
package function
import (
"github.com/searKing/golang/go/error/exception"
"github.com/searKing/golang/go/util/class"
"github.com/searKing/golang/go/util/object"
)
/**
* Represents a function that accepts one argument and produces a result.
*
* <p>This is a <a href="package-summary.html">functional interface</a... | go/util/function/function.go | 0.853699 | 0.553807 | function.go | starcoder |
package core
import (
"bytes"
"reflect"
"strings"
"time"
)
type LogicalOperator int
type ComparisonOperator int
type Type int
const (
OR LogicalOperator = iota
AND
UnknownLogical
Equals ComparisonOperator = iota
NotEquals
LessThan
GreaterThan
LessThanOrEqual
GreaterThanOrEqual
Contains
NotContains
U... | core/condition.go | 0.628065 | 0.503723 | condition.go | starcoder |
package game
import (
"fmt"
"image/color"
"math"
"math/rand"
"github.com/hajimehoshi/ebiten/v2"
"gonum.org/v1/gonum/mat"
)
type TetrominoShape int
const (
ShapeI TetrominoShape = iota
ShapeJ
ShapeL
ShapeS
ShapeZ
ShapeT
ShapeO
)
// Tetromino represents the piece containing the individual tiles making u... | game/tetro.go | 0.773815 | 0.529446 | tetro.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/5_4_min_avg_two_slice/main.go | 0.605799 | 0.657098 | main.go | starcoder |
package man
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderMetaphorPage() string {
return RenderHtml("Programming metaphor", Render(metaphorBody, nil))
}
const metaphorBody = `
<h1>Programming metaphor </h1>
<p>The purpose of each circuit server is to host a collection of control
pri... | gocircuit.org/man/metaphor.go | 0.723895 | 0.64542 | metaphor.go | starcoder |
package main
import (
"encoding/json"
"errors"
"io/ioutil"
"strings"
"time"
"github.com/piquette/finance-go/quote"
)
// Portfolio instance variables must begin with capital letter to be exported by json
type Portfolio struct {
Name string
// Must contain `.json`
Directory string
// the sum Equity and Cash
... | src/portfolio.go | 0.600305 | 0.409044 | portfolio.go | starcoder |
package schema
const v2841 = `{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "VES Event Listener",
"type": "object",
"properties": {
"event": {
"$ref": "#/definitions/event"
},
"eventList": {
"$ref": "#/definitions/eventList"
}
},
"definitions": {
"schemaHeaderBlock": {
"desc... | govel/schema/v28_4_1.go | 0.634656 | 0.419797 | v28_4_1.go | starcoder |
package m32
// Quaternions
/*
Resources:
https://answers.unity.com/questions/467614/what-is-the-source-code-of-quaternionlookrotation.html
*/
import (
"github.com/go-gl/mathgl/mgl32"
)
type (
// Quat mgl32 alias
Quat = mgl32.Quat
)
// QuatBetweenVectors
// QuatLookAt implementation from GLM
// glm/gtc/quaterni... | m32/quat.go | 0.792464 | 0.455259 | quat.go | starcoder |
package iso20022
// Posting to an account that results in an increase or decrease to a balance.
type EntryTransaction1 struct {
// Set of elements providing the identification of the underlying transaction.
References *TransactionReferences1 `xml:"Refs,omitempty"`
// Set of elements providing details information ... | EntryTransaction1.go | 0.923342 | 0.658198 | EntryTransaction1.go | starcoder |
package text
import (
"image/color"
"math"
"github.com/gopherd/plot/font"
"github.com/gopherd/plot/vg"
)
// Handler parses, formats and renders text.
type Handler interface {
// Cache returns the cache of fonts used by the text handler.
Cache() *font.Cache
// Extents returns the Extents of a font.
Extents(... | text/text.go | 0.821331 | 0.530115 | text.go | starcoder |
package permprom
import (
"regexp"
"strconv"
"strings"
)
// BillionDance returns the order of the programs after one billion dances
func BillionDance(content string, n int) string {
lines := strings.Split(content, ",")
moves := make([]Move, len(lines))
for _, line := range lines {
moves = append(moves, parseL... | permprom/permprom.go | 0.585457 | 0.515559 | permprom.go | starcoder |
package godel
import (
"github.com/go-gl/mathgl/mgl64"
"math"
)
type Projection interface {
Projection(wicth, height float64) mgl64.Mat4
}
type AutoPerspective struct {
Yfov float64
ZNear float64
ZFar float64
}
func NewAutoPerspective(yfov float64, ZNear float64, ZFar float64) *AutoPerspective {
return &AutoP... | iProjection.go | 0.85446 | 0.606324 | iProjection.go | starcoder |
package geotiff
// https://github.com/geotiffjs/geotiff.js/
import (
"fmt"
"os"
)
// GeoTIFF represent a GeoTIFF file
type GeoTIFF struct {
source *os.File //The datasource to read from.
littleEndian bool //Whether the image uses little endian.
bigTiff bool //Whether the image uses bigT... | pkg/geotiff/geotiff.go | 0.637934 | 0.456046 | geotiff.go | starcoder |
package imputation
import (
"errors"
"fmt"
"log"
"sort"
"time"
)
// TimeSeries stores a time series. Dates are expressed in ISO 8061 format as illustrated in the constants below.
type TimeSeries map[string]float64
// Assume 3 formattig for the dates: daily, monthly, and yearly.
const (
dayfmt = "2006-01-02"... | imputation/ts_impute.go | 0.503906 | 0.474327 | ts_impute.go | starcoder |
package gxqueue
const (
fastGrowThreshold = 1024
)
// CircularUnboundedQueue is a circular structure and will grow automatically if it exceeds the capacity.
// CircularUnboundedQueue is not thread-safe.
type CircularUnboundedQueue struct {
data []interface{}
head, tail int
icap int // initial capacity... | container/queue/circular_unbounded_queue.go | 0.773858 | 0.430686 | circular_unbounded_queue.go | starcoder |
package mnist
import (
"encoding/binary"
"fmt"
"os"
)
const (
// ImageWidth is a pixel width of image.
ImageWidth = 28
// ImageHeight is a pixel height of image.
ImageHeight = 28
// TrainSize is a size of training dataset.
TrainSize = 60000
// EvalSize is a size of evaluation dataset.
EvalSize = 10000
)... | mnist/mnist.go | 0.671471 | 0.430746 | mnist.go | starcoder |
package require
import "github.com/instana/testify/assert"
// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
// This is a wrapper for errors.As.
func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) {
if h, ok :... | require/require_go1.13.go | 0.637934 | 0.406037 | require_go1.13.go | starcoder |
package models
import (
"fmt"
"log"
"time"
gongsim_models "github.com/fullstack-lang/gongsim/go/models"
gosatellite "github.com/joshuaferrara/go-satellite"
)
// Satellite is a moving object
// swagger:model satellite
type Satellite struct {
MovingObject // concept
Line1 string
Line2 string
// Agent
// s... | go/models/satellite.go | 0.755907 | 0.532182 | satellite.go | starcoder |
package eqn
import (
"math"
)
func (*Time) Eval(t float64, x, c, s []float64) float64 { return t }
func (v *Var) Eval(t float64, x, c, s []float64) float64 { return x[v.P] }
func (dv *DVar) Eval(t float64, x, c, s []float64) float64 { return x[dv.I] }
func (cnst *Constant) Eval(t float64, x, c, s []float64) float... | evaluator/eqn/eval.go | 0.57344 | 0.502991 | eval.go | starcoder |
package servo
import (
"math"
"sync"
"time"
)
const floatEpsilon = 0.001
func distance(x0, y0, x1, y1 float64) float64 {
return math.Sqrt(math.Pow(x0-x1, 2) + math.Pow(y0-y1, 2))
}
//PercentPoint - a point percent values of XY
type PercentPoint struct {
X float64
Y float64
}
//FieldXY is a two-dimensional fi... | pkg/servo/fieldxy.go | 0.707506 | 0.496094 | fieldxy.go | starcoder |
package MailSlurpClient
import (
"time"
)
// WaitForConditions Conditions that a `waitForXEmails` endpoint operates on. The methods wait until given conditions are met or a timeout is reached. If the conditions are met without needing to wait the results will be returned immediately. Can include `unreadOnly` to ignore... | model_wait_for_conditions.go | 0.641085 | 0.454835 | model_wait_for_conditions.go | starcoder |
package fixed
import (
"encoding/binary"
"errors"
)
var ErrOverflow = errors.New("overflow")
func (x Fixed) String() string {
return x.format()
}
func New(val int) Fixed {
return fixed(int64(val))
}
func New64(val int64) Fixed {
return fixed(val)
}
func From(val float64) Fixed {
return from(val)
}
var One ... | fixed.go | 0.770724 | 0.405566 | fixed.go | starcoder |
package curves
import (
"math"
)
// EaseInQuad eases in a Quad transition.
// See http://jqueryui.com/easing/ for curve in action.
func EaseInQuad(completed float64) float64 {
return math.Pow(completed, 2)
}
// EaseOutQuad eases out a Quad transition.
// See http://jqueryui.com/easing/ for curve in action.
func Ea... | curves/ease.go | 0.902821 | 0.48249 | ease.go | starcoder |
package max
import (
"fmt"
"github.com/davecgh/go-spew/spew"
)
type entry struct {
value int32
index int
}
// window is a circular buffer which keeps track of the maximum value observed in a particular time.
// Based on the "ascending minima algorithm" (http://web.archive.org/web/20120805114719/http://home.tiac... | pkg/autoscaler/aggregation/max/window.go | 0.791821 | 0.453443 | window.go | starcoder |
package expr
import (
"reflect"
"time"
)
// ComparisonOperator is a comparison operator.
type ComparisonOperator uint8
const (
ComparisonNone ComparisonOperator = iota
ComparisonCustom
ComparisonEqual
ComparisonNotEqual
ComparisonLessThan
ComparisonGreaterThan
ComparisonLessThanOrEqualTo
ComparisonGrea... | expr/comparison.go | 0.888345 | 0.497253 | comparison.go | starcoder |
package models
// There are two decreasing phases in this pattern that use the same price calculations,
// so we are going to make an embeddable type for them.
type smallSpikeDecreasingBase struct {
phaseCoreAuto
}
func (phase *smallSpikeDecreasingBase) AdjustPriceMultiplier(
factor float32, isMin bool,
) float32 {... | models/phasesSmallSpike.go | 0.79546 | 0.509825 | phasesSmallSpike.go | starcoder |
package spec
import (
"bytes"
"encoding/json"
"fmt"
"math/big"
"github.com/attestantio/go-execution-client/types"
"github.com/pkg/errors"
)
// Transaction is a struct that covers all transaction types.
type Transaction struct {
Type TransactionType
Type0Transaction *Type0Transaction
Type1Transa... | spec/transaction.go | 0.736021 | 0.432243 | transaction.go | starcoder |
package day_02
const input = `
forward 1
forward 8
down 9
forward 3
down 6
down 1
down 1
forward 5
forward 5
forward 8
down 6
forward 7
down 3
down 4
up 1
forward 7
forward 5
forward 8
down 1
forward 9
forward 9
forward 7
up 8
forward 5
forward 9
down 3
forward 2
down 5
down 4
up 2
up 5
forward 3
forward 8
down 9
down... | adventofcode_2021/day_02/input.go | 0.805556 | 0.506897 | input.go | starcoder |
package ram
import "github.com/jameycribbs/hare/dberr"
// Ram is a struct that holds a map of all the
// tables in the datastore.
type Ram struct {
tables map[string]*table
}
// New takes a map of maps with seed data
// and returns a pointer to a Ram struct.
func New(seedData map[string]map[int]string) (*Ram, error... | datastores/ram/ram.go | 0.617167 | 0.471223 | ram.go | starcoder |
package expr
import (
"fmt"
"math"
"reflect"
)
type Env map[Var]interface{}
type runtimePanic string
func SafetyEvalBool(expr Expr, env Env) (value bool, err error) {
defer func() {
switch x := recover().(type) {
case nil:
// no panic
case runtimePanic:
value = false
err = fmt.Errorf("%s", x)
d... | app/service/live/broadcast-proxy/expr/eval.go | 0.571049 | 0.455259 | eval.go | starcoder |
package fp
func (a BoolArray) Find(p func(bool) bool) BoolOption {
for _, e := range a {
if p(e) { return MkBoolOption(e) }
}
return NoneBool}
func (a StringArray) Find(p func(string) bool) StringOption {
for _, e := range a {
if p(e) { return MkStringOption(e) }
}
return NoneString}
func (a IntA... | fp/bootstrap_array_find.go | 0.73782 | 0.446193 | bootstrap_array_find.go | starcoder |
package dali
import (
"database/sql"
"fmt"
"reflect"
)
// One executes the query that should return rows and loads the
// resulting data from the first row into dest which must be a struct.
// Only fields that match the column names (after filtering through
// the mapperFunc) are filled. One returns sql.ErrNoRows ... | loading.go | 0.551332 | 0.413063 | loading.go | starcoder |
package sql
import (
"github.com/liquidata-inc/dolt/go/store/types"
)
var DoltToSQLType = map[types.NomsKind]string{
types.StringKind: VARCHAR,
types.BoolKind: BOOL,
types.FloatKind: FLOAT_TYPE,
types.IntKind: INT,
types.UintKind: INT + " " + UNSIGNED,
types.UUIDKind: UUID,
}
// TypeConversionFn is... | go/libraries/doltcore/sql/sqltypes.go | 0.706292 | 0.498291 | sqltypes.go | starcoder |
package fwt
import (
"github.com/dolthub/dolt/go/libraries/doltcore/row"
"github.com/dolthub/dolt/go/libraries/doltcore/table/pipeline"
"github.com/dolthub/dolt/go/store/types"
)
// TooLongBehavior determines how the FWTTransformer should behave when it encounters a column that is longer than what
// it expected
... | go/libraries/doltcore/table/untyped/fwt/fwt_transform.go | 0.683314 | 0.418043 | fwt_transform.go | starcoder |
package iws
// AdrRecord is the container tag for the majority of the response data from DMDC's Identity Web Services: Real-time Broker Service REST API
type AdrRecord struct {
// The identifier that is used to represent the person within a Department of Defense Electronic Data Interchange. Externally the EDI-PI is r... | pkg/iws/adr_record.go | 0.611614 | 0.430686 | adr_record.go | starcoder |
package schema
import (
"k8s.io/gengo/types"
)
// Collection returns the type schema for a collection with given name and
// element type.
func Collection(name types.Name, elemType *types.Type) *types.Type {
sliceType := sliceType(elemType)
collectionType := collectionType(name)
collectionType.Methods = collectio... | internal/schema/schema.go | 0.555556 | 0.401688 | schema.go | starcoder |
package gorange
import (
"errors"
"fmt"
"math"
"strconv"
"strings"
)
// Range is a struct for representing infinite, open-ended, and finite ranges of values
type Range struct {
Start float64 `json:"start"`
End float64 `json:"end"`
}
// Equal tests if two ranges are identical
func (r Range) Equal(other Range... | range.go | 0.863046 | 0.667371 | range.go | starcoder |
package main
// Import packages
import ("image"; "image/color"; "image/png";
"os"
"log"
"math"; "math/cmplx";
"fmt")
// Converts a point on a canvas to a complex number
func toComplex(x, y int, zoom float64, center complex128) complex128 {
return center + complex(float64(x)/zoom, float64(y)/zoom)
}
// Iter... | fractal.go | 0.822046 | 0.422445 | fractal.go | starcoder |
// Variable package supplies generalised model variables that allow watchers of models to make decisions on those
// models by reacting the changes in model decision variables. Decision variables for a model are considered part of
// that model's public interface.
package variable
import (
"github.com/LindsayBradfor... | internal/pkg/model/variable/DecisionVariable.go | 0.794823 | 0.81119 | DecisionVariable.go | starcoder |
package gravity
import (
"github.com/go-gl/mathgl/mgl32"
)
// Transformer ...
type Transformer struct {
matrix mgl32.Mat4
rot mgl32.Quat
pos mgl32.Vec3
scale mgl32.Vec3
}
var (
xAxis = mgl32.Vec3{1, 0, 0}
yAxis = mgl32.Vec3{0, 1, 0}
zAxis = mgl32.Vec3{0, 0, 1}
)
// NewTransformer ...
func NewTransfor... | components.go | 0.691081 | 0.566378 | components.go | starcoder |
package mongo
import (
"github.com/globalsign/mgo/bson"
"github.com/shopspring/decimal"
)
type M map[string]interface{}
type Decimal decimal.Decimal
func NewDecimal(num int64, exp int32) Decimal {
return Decimal(decimal.New(num, exp))
}
func NewDecimalFromString(s string) (d Decimal, err error) {
var dec decim... | pkg/mongo/types.go | 0.724286 | 0.47859 | types.go | starcoder |
package common
//------------------------------------------------------------------------------
// UndefinedState indicates a component state is undefined
const UndefinedState string = "undefined"
// FailureState indicates a component related failure has occured
const FailureState string = "failure"
// InitialState... | src/tsai.eu/solar/controller/openstackController/common/controller.go | 0.63624 | 0.496948 | controller.go | starcoder |
package keyproof
import (
"github.com/privacybydesign/gabi/big"
"github.com/privacybydesign/gabi/internal/common"
)
type (
AlmostSafePrimeProductProof struct {
Nonce *big.Int
Commitments []*big.Int
Responses []*big.Int
}
almostSafePrimeProductCommit struct {
nonce *big.Int
commitments []... | keyproof/almostsafeprimeproduct.go | 0.535098 | 0.406214 | almostsafeprimeproduct.go | starcoder |
package containerruntimeconfig
// unionNode is a node in the union graph. In our case, it is a mirror host[:port].
type unionNode = string // An alias, so that the users don't have to explicitly cast data.
// internalUnionNode is the unionGraph representation of a node.
// There is exactly one instance of *internalUn... | pkg/controller/container-runtime-config/union.go | 0.803328 | 0.48499 | union.go | starcoder |
package cmd
import (
"fmt"
"strconv"
"strings"
"github.com/jaredbancroft/aoc2020/pkg/helpers"
"github.com/jaredbancroft/aoc2020/pkg/translator"
"github.com/spf13/cobra"
)
// day16Cmd represents the day16 command
var day16Cmd = &cobra.Command{
Use: "day16",
Short: "Advent of Code 2020 - Day16: Ticket Transl... | cmd/day16.go | 0.602997 | 0.463869 | day16.go | starcoder |
package opt
import (
"github.com/cpmech/gosl/fun"
"github.com/cpmech/gosl/io"
"github.com/cpmech/gosl/la"
"github.com/cpmech/gosl/plt"
"github.com/cpmech/gosl/utl"
)
// History holds history of optmization using directiors; e.g. for Debugging
type History struct {
Ndim int // dimension of x-vector
Hi... | opt/history.go | 0.570331 | 0.436742 | history.go | starcoder |
package util
import (
"fmt"
"reflect"
. "github.com/philc/gumshoedb/internal/github.com/cespare/a"
)
// DeepConvertibleEquals is a checker like DeepEqual which converts all numeric types to float64 before
// comparing. DeepConvertibleEquals only handles simple types, slices, and maps (but it is recursive).
// NOT... | internal/util/util.go | 0.696681 | 0.433802 | util.go | starcoder |
package g3
import (
"fmt"
)
// Represents a 4x4 Matrix
type Matrix4x4 struct {
M11, M12, M13, M14 float32
M21, M22, M23, M24 float32
M31, M32, M33, M34 float32
M41, M42, M43, M44 float32
}
func MakeMatrixFromSlice(m []float32) Matrix4x4 {
return Matrix4x4{
m[0], m[1], m[2], m[3],
m[4], m[5], m[6], m[7],
... | src/pkg/g3/matrix.go | 0.765462 | 0.523542 | matrix.go | starcoder |
package fractals
import (
"math"
"sync"
mgl "github.com/go-gl/mathgl/mgl32"
)
func UpdateKoch(vertices []float32) []float32 {
var wg sync.WaitGroup
flattenedVertices := []float32{}
verticesOrdered := make([](*[]float32), len(vertices)/5)
// For each line segment
for i := 0; i < len(vertices); i += 5 {
wg... | fractals/fractals.go | 0.553747 | 0.428951 | fractals.go | starcoder |
package rbo
// Go implementation of https://github.com/dlukes/rbo/blob/master/rbo.py
import (
"fmt"
"math"
"github.com/thedahv/keyword-cluster-finder/pkg/rankings"
)
// RBO calculates the rank-biased overlap of 2 SERPs
// p is the probability of looking for overlap at rank k + 1 after having
// examined rank k
f... | pkg/rbo/rbo.go | 0.862945 | 0.598899 | rbo.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.