code stringlengths 2 1.05M | repo_name stringlengths 5 101 | path stringlengths 4 991 | language stringclasses 3
values | license stringclasses 5
values | size int64 2 1.05M |
|---|---|---|---|---|---|
using Base.Test
include("roman-numerals.jl")
# HINT: There is no need to be able to convert numbers larger than about 3000.
samples = Dict(
1 => "I",
2 => "II",
3 => "III",
4 => "IV",
5 => "V",
6 => "VI",
9 => "IX",
27 => "XXVII",
48 => "XLVIII",
59 => "LIX",
93 => "XCIII",... | andrej-makarov-skrt/xjulia | exercises/roman-numerals/runtests.jl | Julia | mit | 773 |
# Binary heap
immutable MutableBinaryHeapNode{T}
value::T
handle::Int
end
#################################################
#
# core implementation
#
#################################################
function _heap_bubble_up!{Comp, T}(comp::Comp,
nodes::Vector{MutableBinaryHeapNode{T}}, nodemap::Vector... | JuliaPackageMirrors/DataStructures.jl | src/heaps/mutable_binary_heap.jl | Julia | mit | 6,012 |
__precompile__()
module NamedDimensions
using FunctionalData
export NamedDims, named, array, names, at
immutable NamedDims{T,N}
data::Array{T,N}
names::Array{Symbol}
function NamedDims(a, names...)
names = collect(names)
length(names) > ndims(a) && error("NamedDimensions: Got $(length(name... | JuliaPackageMirrors/NamedDimensions.jl | src/NamedDimensions.jl | Julia | mit | 8,923 |
function execute(config::Config, cmd::Cmd; dir::AbstractString="", name::AbstractString="")
init(config)
pg = PlaygroundConfig(config, dir, name)
set_envs(pg)
run(cmd)
end
| JuliaPackageMirrors/Playground.jl | src/execute.jl | Julia | mit | 190 |
# WAH Vectors
# ===========
#
# Definition of WAHVectors.
#
# This file is a part of BioJulia.
# License is MIT: https://github.com/BioJulia/WAHVectors.jl/blob/master/LICENSE.md
# Type definition
# ---------------
"""
The `WAHVector` type represents a bitmap encoded as a Word Aligned Hybrid
succinct data structure.
... | BioJulia/WAHVectors.jl | src/wah_vectors.jl | Julia | mit | 5,687 |
using PlasmoAlgorithms
using Test
include("fisher.jl")
δ = 0.5
maxnoimprove = 3
cpbound=1e6
heur(g) = 16
sg = lagrangeoptimize!(graph, update_method=:subgradient, lagrangeheuristic=heur, verbose=false)
@test sg.objval == 16
@test sg.bestbound == 16
@test sg.gap == 0
| bbrunaud/PlasmoAlgorithms.jl | test/test_lagrange_subgradient.jl | Julia | mit | 272 |
module TinyFarm
#This generates small 2d examples for datacubes, can be used for example plotting
using SurrogateCube
macro load_defaults()
esc(quote
Ncomp=2
Nvar=2
Ntime=300
Nlat=5
Nlon=5
kb=0.0
kn=0.0
ks=0.0
kw=0.0
b=[ConstantBaseline(0.0), ConstantBaseline(0.0)]
n=[White... | CAB-LAB/DataFarm | src/experiments/small2dfarm.jl | Julia | mit | 2,017 |
# define our own struct since LinearAlgebra.QR are restricted to Matrix
struct QR{Q,R,P}
Q::Q
R::R
p::P
end
# iteration for destructuring into components
Base.iterate(S::QR) = (S.Q, Val(:R))
Base.iterate(S::QR, ::Val{:R}) = (S.R, Val(:p))
Base.iterate(S::QR, ::Val{:p}) = (S.p, Val(:done))
Base.iterate(S::Q... | andyferris/StaticArrays.jl | src/qr.jl | Julia | mit | 6,945 |
@testset "PrimeIdealsSet" begin
Qx, x = FlintQQ["x"]
K, a = NumberField(x - 1, "a")
O = maximal_order(K)
S = @inferred PrimeIdealsSet(O, 2, 100)
@test @inferred length(collect(S)) == 25
S = @inferred PrimeIdealsSet(O, 2, 100, indexdivisors = false, ramified = false, degreebound = 100, coprimeto = 3*5*7)
... | thofma/hecke | test/NfOrd/Ideal/Prime.jl | Julia | bsd-2-clause | 2,220 |
@testset "AlgAssAbsOrd" begin
include("AlgAssAbsOrd/Order.jl")
include("AlgAssAbsOrd/Ideal.jl")
include("AlgAssAbsOrd/PicardGroup.jl")
include("AlgAssAbsOrd/LocallyFreeClassGroup.jl")
include("AlgAssAbsOrd/ICM.jl")
end
| thofma/hecke | test/AlgAssAbsOrd.jl | Julia | bsd-2-clause | 229 |
VERSION >= v"0.4.0-dev+6641" && __precompile__()
module Codecs
using Compat
export encode, decode, Base64, Zlib, BCD
abstract Codec
function encode{T <: Codec}(codec::Type{T}, s::String)
encode(codec, convert(Vector{Uint8}, s))
end
function decode{T <: Codec}(codec::Type{T}, s::String)
decode(codec, co... | ssfrr/Codecs.jl | src/Codecs.jl | Julia | mit | 9,413 |
using FactCheck
using FunctionalCollections
import FunctionalCollections: SparseBitmappedTrie, SparseNode, SparseLeaf,
bitpos, index, hasindex, arrayof, update
facts("Sparse Bitmapped Vector Tries") do
context("bitpos and index") do
l = SparseLeaf{Int}([6, 11, 16, 21, 26],
... | jbn/FunctionalCollections.jl | test/SparseBitmappedTrieTest.jl | Julia | mit | 2,632 |
type FakeScoringFunction <: ScoringFunction end
type FakeGraphSearchStrategy <: GraphSearchStrategy end
let
function test_disc_bn(bn::DiscreteBayesNet)
#=
│ Row │ A │ count │
├─────┼───┼───────┤
│ 1 │ 1 │ 4 │
│ 2 │ 2 │ 4 │
│ 3 │ 3 │ 4 │
=#
df_count = count(bn, :A, data)
@test size(... | JuliaPackageMirrors/BayesNets.jl | test/test_learning.jl | Julia | mit | 3,185 |
VERSION >= v"0.4.0-dev+6521" && __precompile__(true)
module Nervoso
import Base: ==, show, length, size, endof, getindex, setindex!,
start, next, done, tanh
include("utils.jl")
include("feedforward/layer.jl")
include("activation.jl")
include("cost.jl")
include("feedforward/network.jl")
include("feedforw... | prcastro/NeuralNetsLite.jl | src/Nervoso.jl | Julia | mit | 609 |
#########################################################################
# Helper functions for derivation tests
#########################################################################
# FIXME : remove calls to getSymbols and SubstSymbols
## error thresholds
DIFF_DELTA = 1e-9
ERROR_THRESHOLD = 2e-2
good_enough... | davidanthoff/Lora.jl | test/parsers/helper_diff.jl | Julia | mit | 3,340 |
using Cairo
function common_header()
## header to provide surface and context
c = CairoRGBSurface(256,256);
cr = CairoContext(c);
save(cr);
set_source_rgb(cr,0.8,0.8,0.8); # light gray
rectangle(cr,0.0,0.0,256.0,256.0); # background
fill(cr);
restore(cr);
return c,cr
end
func... | andrewcooke/Cairo.jl | samples/sample_copy_path.jl | Julia | mit | 1,741 |
using FunctionalData, QuickShiftClustering
data = @p map unstack(1:10) (x->10*randn(2,1).+randn(2,1000)) | flatten
@time a = quickshift(data)
Profile.clear_malloc_data()
@time a = quickshift(data)
exit()
| JuliaPackageMirrors/QuickShiftClustering.jl | src/memtest.jl | Julia | mit | 204 |
using Test
include("complex-numbers.jl")
@test ComplexNumber <: Number
@test ComplexNumber(0, 1)^2 == ComplexNumber(-1, 0)
@testset "Arithmetic" begin
@testset "Addition" begin
@test ComplexNumber(1, 0) + ComplexNumber(2, 0) == ComplexNumber(3, 0)
@test ComplexNumber(0, 1) + ComplexNumber(0, 2) ... | exercism/xjulia | exercises/practice/complex-numbers/runtests.jl | Julia | mit | 2,614 |
# code for working with expectations of nodes
# define an expectation method on Distributions
"Calculate the expected value of a Node x."
E(x) = x
E(x::Distribution) = mean(x)
V(x) = zero(x)
V(x::Distribution) = var(x)
C(x) = zero(x)
C(x::Distribution{Univariate}) = V(x)
C(x::AbstractMvNormal) = cov(x)
C(x::HMM) = cov... | jmxpearson/VinDsl.jl | src/expectations.jl | Julia | mit | 1,122 |
# Taken from https://github.com/JuliaLang/julia/blob/master/examples/ndgrid.jl
ndgrid(v::AbstractVector) = copy(v)
function ndgrid{T}(v1::AbstractVector{T}, v2::AbstractVector{T})
m, n = length(v1), length(v2)
v1 = reshape(v1, m, 1)
v2 = reshape(v2, 1, n)
(repmat(v1, 1, n), repmat(v2, m, 1))
end
func... | 1oly/PGFPlots.jl | src/ndgrid.jl | Julia | mit | 1,348 |
export simple_estimator, improved_estimator, default_estimator
@inline function simple_estimator(model, param::Parameter, _=nothing)
p = convert_parameter(model,param)
return simple_estimator(model, p..., nothing)
end
@inline function improved_estimator(model, param::Parameter, extra)
p = convert_paramete... | yomichi/SpinMonteCarlo.jl | src/API/estimator.jl | Julia | mit | 589 |
################################################################################
#
# Lattice enumeration for finding all vectors
#
################################################################################
################################################################################
#
# Pseudo cholesky deco... | thofma/hecke | src/QuadForm/Enumeration.jl | Julia | bsd-2-clause | 18,916 |
module TSne
# Numpy Math.sum => axis = 0 => sum down the columns. axis = 1 => sum along the rows
# Julia Base.sum => axis = 1 => sum down the columns. axis = 2 => sum along the rows
#
# tsne.jl
#
# This is a straight off Julia port of Laurens van der Maatens python implementation of tsne
export tsne, pca
function... | zhmz90/TSne.jl | src/TSne.jl | Julia | bsd-3-clause | 4,261 |
# Implementation of data structures that automatically
# perform copy-on-write after task copying.
# If current_task is an existing key in s, then return s[current_task].
# Otherwise, return s[current_task] = s[last_task].
immutable TArray{T,N} <: DenseArray{T,N}
ref :: Symbol # object_id
TArray() = new(gensym()... | xukai92/Turing.jl | src/trace/tarray.jl | Julia | mit | 2,965 |
function test_cross_validation_accuracy(v)
m = [v 3 v 1 2 1 v 4
1 2 v v 3 2 v 3
v v v v v v v v
v 2 3 3 v 5 v 1]
data = DataAccessor(isa(v, Unknown) ? m : sparse(m))
fold = 5
# MF(data, 2)
@test cross_validation(fold, MAE, MF, data, 2) <= 2.5
# UserMean(data)
@t... | takuti/Recommendation.jl | test/evaluation/test_cross_validation.jl | Julia | mit | 1,352 |
##################################################
## Classical derivative-based, iterative, root-finding algorithms
##
## If ri = f^(i-1)/f^(i), then these have an update step `xn - delta` where:
##
## * Newton: delta = r1 # order 2 if simple root (multiplicity 1)
## * Halley: delta = 2*r2/(2r2 - r1) * r1 # order 3 i... | JuliaLang/Roots.jl | src/newton.jl | Julia | mit | 9,581 |
function goldensection(f,n; dxmin=0.1, accel=golden, history=[], verbose=false)
function feval(x) # so we don't repeat function evaluations
for (k,v) in history
if isapprox(x,k)
return v
end
end
fx = f(x)
push!(history, (x,fx))
... | ozanarkancan/navigation | gsection.jl | Julia | mit | 1,448 |
type Tape
tape::Array{Int, 1}
pos::Int
function Tape()
new(zeros(Int, 1), 1)
end
end
inc(this::Tape) = (this.tape[this.pos] += 1)
dec(this::Tape) = (this.tape[this.pos] -= 1)
get(this::Tape) = this.tape[this.pos]
function advance(this::Tape)
this.pos += 1
if this.pos > length(this.tape)
push!(thi... | chalucha/benchmarks | brainfuck/brainfuck.jl | Julia | mit | 1,923 |
# Single embedding implementation of blstm
# 1:2*length(layerconfig) -> forward lstm
# 2*lenghth(layerconfig)+1:4*length(layerconfig) -> bacward lstm
# final 3 is embedding and final layer prediction parameters
function initparams(atype, layerconfig, embedsize, vocab, winit)
parameters = Array(Any, 4*length(layerco... | kirnap/bilstm-in-Knet8 | model3.jl | Julia | mit | 4,167 |
#### Caching
function CachedOperator{T}(io::InterlaceOperator{T,1};padding::Bool=false)
ds=domainspace(io)
rs=rangespace(io)
ind=find(op->isinf(size(op,1)),io.ops)
if length(ind) ≠ 1 || !isbanded(io.ops[ind[1]]) # is almost banded
return CachedOperator(io,Array(eltype(op),0,0))
end
i=... | JuliaPackageMirrors/ApproxFun.jl | src/Extras/fastcache.jl | Julia | bsd-3-clause | 17,736 |
# Try to approximate squared-exponential kernel:
using PyPlot
ntime = 1000
time = collect(linspace(0,10,ntime))
# If we want to approximate Gaussian, then we just get a cosine... that doesn't work well!
# How about sum of two? This I solved numerically with Mathematically, and unfortunately I find
# a growing solut... | ericagol/celerite | paper/approximate_kernels/kernel_approx.jl | Julia | mit | 3,902 |
function check_error(m, x0)
if length(x0) != dim(m)
throw(ArgumentError("initial variable must have same length as number of design variables"))
end
for j in 1:length(x0)
# x is not in box
if !(min(m, j) <= x0[j] <= max(m,j))
throw(ArgumentError("initial variable at inde... | KristofferC/MMA.jl | src/utils.jl | Julia | mit | 1,462 |
#-------------------------------------------------------------------
#* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
#*
#* This LIBRARY is free software; you can distribute it and/or modify
#* it under the therms of the ALSOC FREE LICENSE as available at
#* http://www.enq.ufrgs.br/alsoc.
#*
#* EMSO Copyrig... | DANA-Laboratory/EMSOModelLibrary.jl | JuliaEMSOModels/costs/HeatExchangerSimplified_cost/Shell_and_tubes_LMTD_cost.jl | Julia | mit | 4,034 |
function lseDataAssemble(equationData::EquationData,meshData::MeshData,deltaT::Float64)
# This function assembles the system matrix M and the right-hand side r
# of the LSE occurring in the P1-FEM (piecewise linear test functions on the given meshData)
# for the equation described by equationData.
# Determine... | gerhardtulzer/EllipticFEM.jl | src/LSEData/lseDataAssembleAndUpdate.jl | Julia | bsd-2-clause | 41,517 |
import Chipmunk
Cp = Chipmunk
import SFML
Sf = SFML
settings = Sf.ContextSettings()
settings.antialiasing_level = 3
window = Sf.RenderWindow(Sf.VideoMode(800, 600), "Shapes", settings, Sf.window_defaultstyle)
Sf.set_framerate_limit(window, 60)
event = Sf.Event()
gravity = Cp.Vect(0, -100)
space = Cp.Space()
Cp.set_g... | zyedidia/Chipmunk.jl | examples/shapes.jl | Julia | mit | 2,043 |
export ChebyshevT
"""
ChebyshevT{T, X}(coeffs::AbstractVector)
Chebyshev polynomial of the first kind.
Construct a polynomial from its coefficients `coeffs`, lowest order first, optionally in
terms of the given variable `var`, which can be a character, symbol, or string.
!!! note
`ChebyshevT` is not axis-aw... | Keno/Polynomials.jl | src/polynomials/ChebyshevT.jl | Julia | mit | 8,589 |
###############################################################################
# url file
function checkURL(features, metadata_path)
url_path = joinpath(metadata_path, "url")
features[:URL_EXISTS] = isfile(url_path)
gitpath = chomp(readall(url_path))
# Remove starting git:// or https://
if gitpath[1:3] == "g... | timholy/PackageEvaluator.jl | src/metadata.jl | Julia | mit | 1,647 |
"""
SeisPlot(d [, extent]; <keyword arguments>)
Plot time-space, frequency-wavenumber or amplitude-frequency 2D seismic data `d`
with color, wiggles or overlay.
# Arguments
* `d`: 2D data to plot.
* `extent`: extent of the data (optional).
# Keyword arguments
* `plot_type="TX"`: `"TX"` for time-space plot; `"FK"... | JuliaPackageMirrors/Seismic.jl | src/Plotting/SeisPlot.jl | Julia | mit | 8,256 |
using Snowball
@testset "Stemmer" begin
algs = stemmer_types()
@test !isempty(algs)
for alg in algs
stmr = Stemmer(alg)
Snowball.release(stmr)
end
test_cases = Dict{String, Any}(
"english" => Dict{AbstractString, AbstractString}(
"working" => "work",
... | johnmyleswhite/TextAnalysis.jl | test/stemmer.jl | Julia | mit | 583 |
# exercise estimating a linear model by iterative minimization,
# and verifying that OLS gives same results.
# If the data is missing, run BasicDataAnalysis.jl
# in the Examples/Julia directory
using CSV, DataFrames, StatsModels, Econometrics
# prepare the data
card = CSV.read("../Julia/cooked.csv", DataFrame)
display... | mcreel/Econometrics | Examples/NonlinearOptimization/EstimateCard.jl | Julia | mit | 859 |
@compat function popchart(; x::AbstractArray = Int[], y::AbstractArray = Int[], group::AbstractArray = [])
v = VegaVisualization()
add_data!(v, x = x, y = y, group = group)
v.scales = Array(VegaScale, 3)
v.scales[1] = VegaScale(name = "g", domain = [0,1], range = [340, 10])
v.scales[2] = VegaScale... | spencerlyon2/Vega.jl | src/derived/popchart.jl | Julia | mit | 3,003 |
#! /home/sci/dperry/build/julia/julia/julia
using MAT
using RandomFourierFeatures
using Kernel
using Sketch
X = []
Labels = []
name = "gaussian"
recompute = true
d = 0
n = 0
nt = 0
if name == "gaussian"
n = round(Int64,1e3)
d = round(Int64,1e2)
m = 50 # signal dimension
eta = 10 # signal to noise ratio... | daniel-perry/StreamingKPCA.jl | comparison_example.jl | Julia | mit | 21,019 |
function test_query(q, text)
res = run(q)
@fact res.query --> q
@fact isempty(res.scores) --> false
@fact isempty(res.matches) --> false
# Get the raw docstring.
doc = getdoc(res)
@fact doc --> text
end
getdoc(res) = data(docs(first(first(reverse(sort([(a, b) for (a, b) in res.scores])))... | MichaelHatherly/Lexicon.jl | test/facts/querying-results.jl | Julia | mit | 4,338 |
#Array test
## basics
@test length([1, 2, 3]) == 3
@test countnz([1, 2, 3]) == 3
a = ones(4)
b = a+a
@test b[1]==2. && b[2]==2. && b[3]==2. && b[4]==2.
@test length((1,)) == 1
@test length((1,2)) == 2
@test isequal(1.+[1,2,3], [2,3,4])
@test isequal([1,2,3].+1, [2,3,4])
@test isequal(1.-[1,2,3], [0,-1,-2])
@test i... | shubhamg31/columbus_julia | lib/julia/test/arrayops.jl | Julia | apache-2.0 | 25,051 |
# This is an example script demonstrating how PARDISO works on a small,
# sparse, real symmetric matrix. It computes the m solutions X to the
# collection of linear systems
#
# A * X = B
#
# using the PARDISO solver, where A is a symmetric n x n matrix, B is an
# n x m matrix, and X is another n x m matrix.
using Pa... | JuliaPackageMirrors/Pardiso.jl | examples/examplesym.jl | Julia | mit | 2,192 |
import Base: values, find
# when ############################
when{T,N}(ta::TimeArray{T,N}, period::Function, t::Int) = ta[find(period(ta.timestamp) .== t)]
when{T,N}(ta::TimeArray{T,N}, period::Function, t::ASCIIString) = ta[find(period(ta.timestamp) .== t)]
# from, to ######################
from{T,N,D}(t... | dourouc05/TimeSeries.jl | src/split.jl | Julia | mit | 1,026 |
using Compat
export AbstractCompositeDataFrame, CompositeDataFrame
abstract AbstractCompositeDataFrame <: AbstractDataFrame
function CompositeDataFrame(columns::Vector{Any},
cnames::Vector{Symbol} = gennames(length(columns)))
# TODO: length checks
typename = symbol("CompositeDF" *... | tkelman/DataFramesMeta.jl | src/compositedataframe.jl | Julia | mit | 3,894 |
######################################################
#
# MMAR Plot
#
# Date: 2014-11-13
# Author: Hessel Tuinhof
#
# Simulate and plot a Brownian Motion in multifractal
# trading time (also called MMAR).
#
# Required packages: PyPlot
# Required functions: MMAR.jl
#
################################################... | hesseltuinhof/masterthesis | plots/mmar.jl | Julia | mit | 767 |
using Base.Cartesian
import Base.getindex
Base.linearindexing{T<:AbstractInterpolation}(::Type{T}) = Base.LinearSlow()
function getindex_impl{T,N,TCoefs,IT<:DimSpec{BSpline},GT<:DimSpec{GridType},Pad}(itp::Type{BSplineInterpolation{T,N,TCoefs,IT,GT,Pad}})
meta = Expr(:meta, :inline)
quote
$meta
... | SloanLindsey/Interpolations.jl | src/b-splines/indexing.jl | Julia | mit | 2,469 |
using Interpolations
using Test, LinearAlgebra, StaticArrays
@testset "Scaling" begin
# Model linear interpolation of y = -3 + .5x by interpolating y=x
# and then scaling to the new x range
itp = interpolate(1:1.0:10, BSpline(Linear()))
sitp = @inferred(scale(itp, -3:.5:1.5))
@test typeof(sitp) <... | tlycken/Interpolations.jl | test/scaling/scaling.jl | Julia | mit | 4,222 |
#unit-unum.jl
#test that the Unum pseudo-constructor bifurcates the actual construction to
#"UnumSmall" and "UnumLarge" types
small_typetest = Unum{4,6}(z64, z64, z16, z16, z16)
large_typetest = Unum{4,7}(z64, [z64, z64], z16, z16, z16)
@test isa(small_typetest, Unum{4,6})
@test isa(small_typetest, Unums.UnumSmall{4,... | REX-Computing/unumjl | test/unit/unit-unum.jl | Julia | mit | 5,887 |
const Py_single_input = 256 # from Python.h
const Py_file_input = 257
const Py_eval_input = 258
const _namespaces = Dict{Module,PyDict{String,PyObject,true}}()
pynamespace(m::Module) =
get!(_namespaces, m) do
if m === Main
return PyDict{String,PyObject,true}(pyincref(@pycheckn ccall((@pysym :... | stevengj/PyCall.jl | src/pyeval.jl | Julia | mit | 9,666 |
#idx_gen
function idx_cost()
PW_LINEAR = 1;
POLYNOMIAL = 2;
## define the indices
MODEL = 1; ## cost model, 1 = piecewise linear, 2 = polynomial
STARTUP = 2; ## startup cost in US dollars
SHUTDOWN = 3; ## shutdown cost in US dollars
NCOST = 4; ## number breakpoints in piecewise linear... | psa-kmust/pste.jl | src/idx_cost.jl | Julia | mit | 1,139 |
using GLDraw
using Base.Test
# write your own tests here
@test 1 == 1
| JuliaGL/GLDraw.jl | test/runtests.jl | Julia | bsd-2-clause | 71 |
using MachineLearning
data_path = joinpath(ENV["DataPath"], "Kaggle", "digit-recognizer")
data, header = readcsv(joinpath(data_path, "train.csv"), Float64, has_header=true)
x_train = data[:,2:size(data,2)]
y_train = vec(data[:,1])
x_test, header = readcsv(joinpath(data_path, "test.csv"), Float64, has_header=true)
for... | benhamner/KaggleDigitRecognizer.jl | src/random_forest.jl | Julia | bsd-2-clause | 648 |
function generate(::Type{Event},
rates::EventRates{T},
time::Float64) where T <: EpidemicModel
totals = Weights([sum(rates[state]) for state in _state_progressions[T][2:end]])
if sum(totals) == Inf
new_state = sample(_state_progressions[T][2:end], totals)
id = sample(1:ra... | jangevaa/Pathogen.jl | src/simulation/generate.jl | Julia | mit | 1,586 |
# Direct Search with Probabilistic Descent as described in Gratton2014:
#
# S. Gratton, C. W. Royer, L. N. Vicente, and Z. Zhang, Direct search
# based on probabilistic descent, preprint 14-11, Dept. Mathematics, Univ. Coimbra.
# http://www.mat.uc.pt/~lnv/papers/ds-random.pdf
#
# Generate num random vectors on the ... | multidis/BlackBoxOptim.jl | src/direct_search_with_probabilistic_descent.jl | Julia | mit | 1,926 |
function linear_data(num_samples::Int, num_features::Int, noise::Float64=0.2)
xs = randn(num_samples, num_features)
model = randn(num_features)
ys = int(map(x->x>0.0, xs*model+noise*randn(num_samples)))
xs, ys
end | benhamner/MachineLearning.jl | test/linear_data.jl | Julia | bsd-2-clause | 229 |
using Base.Test
using Klara
fnames = (
:value,
:loglikelihood,
:logprior,
:logtarget,
:gradloglikelihood,
:gradlogprior,
:gradlogtarget,
:tensorloglikelihood,
:tensorlogprior,
:tensorlogtarget,
:dtensorloglikelihood,
:dtensorlogprior,
:dtensorlogtarget
)
println(" Testing ContUnvMarkovCha... | JuliaStats/MCMC.jl | test/ParameterNStates.jl | Julia | mit | 5,360 |
abstract Move
# note that we don't have to keep track of which player made a move on
# the move itself, since we can always figure out how to take the last
# move back from the global game state: whoever's turn it *isn't* made
# the move we're trying to take back
immutable WallPlacement <: Move
wall::Wall
end
sh... | porterjamesj/Quoridor.jl | src/move.jl | Julia | mit | 958 |
using Compat.Random
using Compat.Statistics
using Compat.Test
using PyCall
using Keras
using StatsBase
import Keras: metric
import Keras.Layers: Dense, Activation, LSTM
mse(actual, pred) = Statistics.mean(square(actual - pred))
mae(actual, pred) = Statistics.mean(abs(actual - pred))
rmse(actual, pred) = sqrt(mse(actu... | invenia/Keras.jl | test/runtests.jl | Julia | mit | 6,807 |
module TestFactorizationMachines
using FactorizationMachines
using Base.Test
matrix_dim = 4
X = eye(matrix_dim)
y = [.1, .2, .3, .4]
info("Solving system of equations with identity matrix")
fm = train(sparse(X), y, model_params = Models.gauss(k0 = false, k1 = true, num_factors = 0))
@test fm.model.w0 == 0
@test size... | btwardow/FactorizationMachines.jl | test/matrix_factorization/test_identity.jl | Julia | mit | 704 |
@doc raw"""
postproc(model::AshkinTeller, param::Parameter, obs::MCObservableSet)
# Observables to be calculated
In the following, $m$ is total magnetization per site and $\epsilon$ is total energy per site.
- `"Binder Ratio"`
- $R := \frac{\left \langle m^4 \right \rangle}{\left \langle m^2 \right\rangle^2}$... | yomichi/SpinMonteCarlo.jl | src/model/AshkinTeller/postproc.jl | Julia | mit | 2,232 |
#=
Copyright (c) 2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the followi... | JuliaPackageMirrors/CompilerTools.jl | test/test_loops_2.jl | Julia | bsd-2-clause | 2,149 |
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using JuliaFEM.Testing
using Logging
Logging.configure(level=DEBUG)
@testset "create and manipulate fields" begin
@testset "updating time dependent fields" begin
f = Field(0.0 =>... | ahojukka5/JuliaFEM.jl | test/test_fields.jl | Julia | mit | 1,549 |
include(joinpath(@__DIR__,"..","src","open_file.jl"))
using ArgParse, LibGit2
s = ArgParseSettings()
@add_arg_table! s begin
"--diff"
help = "print to STDOUT the output of `diff`"
action = :store_true
"--two"
help = "display both files"
action = :store_true
"--bw"
h... | dcjones/Gadfly.jl | test/compare_examples.jl | Julia | mit | 5,467 |
function eig_min!(linear_solver::abstract_linear_system_solver, K::SparseMatrixCSC{Float64,Int64}, x_0::Array{Float64,1}, n::Int64, m::Int64, tol::Float64)
# computes smallest magnitude eigenvalue and eigenvector viz inverse iteration
try
@assert(n + m == size(K,1))
@assert(size(K,1) == size(K,2))
@assert(n == ... | ohinder/Everest.jl | src/helpers/eigenvalues.jl | Julia | mit | 1,729 |
p = Optim.UnconstrainedProblems.examples["Rosenbrock"]
df = DifferentiableFunction(p.f, p.g!)
Optim.momentum_gradient_descent(df, [0.0, 0.0])
Optim.momentum_gradient_descent(df, [0.0, 0.0], mu = 0.1)
optimize(p.f, p.g!, [0.0, 0.0])
| KristofferC/Optim.jl | test/momentum_gradient_descent.jl | Julia | mit | 236 |
# BLAS
import LinearAlgebra: dot
import LinearAlgebra.BLAS: nrm2, blascopy!, axpy!, scal!
export copyaxpy!
nrm2(n :: Int, x :: Vector{T}) where T <: BLAS.BlasReal = BLAS.nrm2(n, x, 1)
nrm2(n :: Int, x :: AbstractVector{T}) where T <: Number = norm(x)
dot(n :: Int, x :: Vector{T}, y :: Vector{T}) where T <: BLAS.Blas... | JuliaOptimizers/Optimize.jl | src/auxiliary/blas.jl | Julia | mit | 1,417 |
using Test
using QuantumOptics
using LinearAlgebra
@testset "nlevel" begin
N = 3
b = NLevelBasis(N)
# Test basis equality
@test b == NLevelBasis(N)
@test b != NLevelBasis(N+1)
@test_throws DimensionMismatch NLevelBasis(0)
# Test transition operator
@test_throws BoundsError transition(b, 0, 1)
@test_throws BoundsErr... | bastikr/QuantumOptics.jl | test/test_nlevel.jl | Julia | mit | 824 |
using Test
@testset "NLModel" begin
include("NLModel.jl")
end
@testset "MOI" begin
include("MOI_wrapper.jl")
end
| JackDunnNZ/AmplNLWriter.jl | test/runtests.jl | Julia | mit | 123 |
#
# NA's
#
@assert isna(NAtype())
@assert isna(NA)
#
# DataVector's
#
dv = DataArray([1, 2, 3], falses(3))
@assert isequal(dv.data, [1, 2, 3])
@assert isequal(dv.na, falses(3))
@assert isequal(dv, DataArray([1, 2, 3], [false, false, false]))
@assert isequal(dv, DataArray([1, 2, 3]))
dv = DataArray(trues(3), falses(... | djreiss/DataFrames.jl | test/constructors.jl | Julia | mit | 5,560 |
import Winston
function plot1D(gp::GP; clim::(Float64, Float64)=(minimum(gp.x), maximum(gp.x)), CI::Float64=1.96, res::Int=1000)
sx = (clim[2]-clim[1])/(res-1)
x=[clim[1]:sx:clim[2]]
mu, Sigma = predict(gp, x)
conf = CI*sqrt(Sigma)
u = mu + conf
l = mu - conf
... | karenyyng/GaussianProcesses.jl | src/glue/Winston.jl | Julia | mit | 1,556 |
dataset(example::AbstractString, datafile::AbstractString, suffix::AbstractString="csv", header::Bool=true) =
readcsv(joinpath(dirname(@__FILE__), "..", "data", example, join([datafile, suffix], '.')), header=header)
function datasets(example::AbstractString)
fnames = readcsv(joinpath(dirname(@__FILE__), "..", "... | JuliaPackageMirrors/Lora.jl | src/data.jl | Julia | mit | 1,054 |
# check examples are running:
dirr = dirname(Base.source_path())
ls = split(readall(`ls $dirr`))
for l in ls
ll = joinpath(dirr,l)
if l[end-2:end]==".jl" && !(l=="runexamples.jl")
println("Running example: $l")
println("----------------")
include(ll)
println(" ")
println... | ScottPJones/Traits.jl | examples/runexamples.jl | Julia | mit | 414 |
using DataStructures, StringDistances
x = map(randstring, rand(5:25,100_000))
y = map(randstring, rand(5:25,100_000))
function f(out, t, x, y)
d = Array(out, length(x))
@inbounds for i in 1:length(x)
d[i] = evaluate(t, x[i], y[i])
end
end
# similar
@time f(Int, Levenshtein(), x, y)
@time f(Float6... | JuliaPackageMirrors/StringDistances.jl | benchmark/benchmark.jl | Julia | mit | 999 |
@stage_testset "stan" "stan-interface.jl" begin
using CmdStan
chn = sample(gdemo_default, 2000, 1000, false, 1,
CmdStan.Adapt(), CmdStan.Hmc(stepsize_jitter=0))
check_gdemo(chn)
end
| yebai/Turing.jl | test/utilities/stan-interface.jl | Julia | mit | 203 |
module JITTools
import Base: show, start, next, done
export load_descriptor, datadump, otool, dwarfdump, buffer, bufferr,
datapointer, datasize, datadumpr, dwarfdumpr,
# Reexport from ObjFileBase
readmeta
immutable jit_code_entry
next_entry::Ptr{jit_code_entry}
prev_entry::Ptr{jit_code_entry}
... | Keno/JITTools.jl | src/JITTools.jl | Julia | mit | 4,125 |
#!/usr/bin/env julia
#
# @license Apache-2.0
#
# Copyright (c) 2018 The Stdlib 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.org/licenses/LICENSE-2.0
#
# U... | stdlib-js/stdlib | lib/node_modules/@stdlib/stats/base/dists/hypergeometric/skewness/test/fixtures/julia/runner.jl | Julia | apache-2.0 | 1,896 |
using Strada
using Logging
include("mnist-net.jl");
include("load-mnist.jl")
# Strada.set_mode_gpu(net)
directory = joinpath(Pkg.dir("Strada"), "data")
(Xtrain, ytrain) = load_mnist(directory; data_set=:train)
(Xtest, ytest) = load_mnist(directory; data_set=:test)
data = minibatch_stream(Xtrain, ytrain; batchsize=... | pcmoritz/Strada.jl | examples/train-mnist.jl | Julia | bsd-2-clause | 661 |
# example 2: string hashing with a seed
include("../src/Murmur3.jl")
using Murmur3
value = "Hello world"
seed = 42
hash = Murmur3.x86.hash32(value, seed)
println("x86 32-bit (seed: $seed): \"$value\" => $(hex(hash))")
hash = Murmur3.x86.hash128(value, seed)
println("x86 128-bit (seed: $seed): \"$value\... | JuliaPackageMirrors/Murmur3.jl | examples/murmur3_example2.jl | Julia | mit | 452 |
# type aliases
const EuropeanOption = Option{EuropeanExercise}
const AmericanOption = Option{AmericanExercise}
const BermudanOption = Option{BermudanExercise}
mutable struct OptionResults # Greeks
delta::Float64
gamma::Float64
theta::Float64
vega::Float64
rho::Float64
dividendRho::Float64
deltaForward::F... | pazzo83/JQuantLib | src/instruments/option.jl | Julia | mit | 1,754 |
# Independent Component Analysis
#### FastICA type
type ICA
mean::Vector{Float64} # mean vector, of length m (or empty to indicate zero mean)
W::Matrix{Float64} # component coefficient matrix, of size (m, k)
end
indim(M::ICA) = size(M.W, 1)
outdim(M::ICA) = size(M.W, 2)
Base.mean(M::ICA) = fullmean(in... | JuliaPackageMirrors/MultivariateStats.jl | src/ica.jl | Julia | mit | 6,006 |
#####################################################################################################################
# MODULE : Adds a feature to the given feature set based on the given data and a loss function using multiple cores
#
# USAGE : A_new = add_feature(loss_func, A, fs, to_add)
#
# INPUT : loss_func: Fun... | shubhamg31/columbus_julia | modules/stepadd_multicore.jl | Julia | apache-2.0 | 1,734 |
# Julia wrapper for header: /opt/local/include/gdal_priv.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0
function GDALGetDataTypeSize(arg1::GDALDataType)
ccall((:GDALGetDataTypeSize,libgdal),Cint,(GDALDataType,),arg1)
end
function GDALDataTypeIsComplex(arg1::GDALDataType)
ccall((:GDALDataTyp... | meggart/GDALfuns.jl | src/gdal_priv.jl | Julia | mit | 58,446 |
using MathOptInterface
const MOI = MathOptInterface
# Simple evaluator for testing
struct ExprEvaluator <: MOI.AbstractNLPEvaluator
constraints::Vector{Expr}
end
function MOI.initialize(d::ExprEvaluator, requested_features::Vector{Symbol})
if requested_features != [:ExprGraph]
error("Only supports ex... | SCIP-Interfaces/SCIP.jl | test/MOI_nonlinear_exprs.jl | Julia | mit | 5,275 |
load("utils/req.jl")
req("utils/utils.jl")
# == split_fdef ===============================================================
function split_fdef(fdef::Expr)
@expect (fdef.head == :function) || (fdef.head == :(=))
@expect length(fdef.args) == 2
signature, body = tuple(fdef.args...)
@expect is_expr(sign... | toivoh/julia-kernels | utils/failexpect.jl | Julia | mit | 2,111 |
using IJulia
notebook()
| pabloferz/dotfiles | IJulia/IJulia.jl | Julia | mit | 24 |
#=
Copyright (c) 2015, Intel Corporation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaime... | IntelLabs/Latte.jl | test/stdlib/test_transform.jl | Julia | bsd-3-clause | 1,759 |
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: waf_regional
using AWS.Compat
using AWS.UUIDs
"""
associate_web_acl(resource_arn, web_aclid)
associate_web_acl(resource_arn, web_aclid, params::Dict{String,<:Any})
This is AWS WAF Classic Regional documentation. For more informa... | JuliaParallel/AWS.jl | src/services/waf_regional.jl | Julia | mit | 180,254 |
function dot(x::BitVector, y::BitVector)
# simplest way to mimic Array dot behavior
length(x) == length(y) || throw(DimensionMismatch(""))
s = 0
xc = x.chunks
yc = y.chunks
@inbounds for i = 1 : length(xc)
s += count_ones(xc[i] & yc[i])
end
s
end
## slower than the unpacked vers... | shubhamg31/columbus_julia | lib/julia/base/linalg/bitarray.jl | Julia | apache-2.0 | 5,078 |
#######################################################################
# Coverage.jl
# Take Julia test coverage results and bundle them up in JSONs
# https://github.com/IainNZ/Coverage.jl
#######################################################################
module Coverage
using Requests
using JSON
# pr... | simonster/Coverage.jl | test/data/Coverage.jl | Julia | mit | 2,576 |
immutable Float
s::Uint64
e::Int32
de::Int32
end
Float() = Float(0,0,0)
Float(x,y) = Float(x,y,int32(0))
Float(d::FloatingPoint) = Float(_significand(d), _exponent(d))
# Consts
const Float10MSBits = 0xFFC0000000000000 # used normalize(Float)
const FloatSignMask = 0x8000000000000000 # used in normalize(Flo... | quinnj/Grisu.jl | src/float.jl | Julia | mit | 7,818 |
using HTTPClient.HTTPC
lines = String[]
for index =[1:13]
url = "http://axe-level-1.herokuapp.com/lv2"
r = HTTPC.get(url, RequestOptions(query_params=collect({:page => index})))
@assert r.http_code == 200
html = bytestring(r.body)
pattern = r"<tr>\s*<td>(.*)</td>\s*<td>(.*)</td>\s*<td>(.*)</td>\s*</tr>"
substri... | zonble/axe_jl | axe2.jl | Julia | mit | 580 |
s = """
if VERSION < v"0.4-" && VERSION > v"0.1"
@lintpragma( "Info version 0.3")
@lintpragma( "Info version 0.4")
else
@lintpragma( "Info version 0.3")
@lintpragma( "Info version 0.4")
end
"""
msgs = lintstr( s )
@test contains( msgs[1].message, "Reachable by 0.3" )
@test contains( msgs[2].message, "Un... | tkelman/Lint.jl | test/versions.jl | Julia | mit | 2,420 |
module Radio
VERSION < v"0.4-" && using Docile
import DSP: FIRFilter, filt
abstract Modulation
include( "AGC.jl" )
include( "coding.jl" )
include( "PLL.jl" )
include( "PSK.jl" )
include( "QAM.jl" )
include( "Nyquist.jl" )
include( "Modem.jl" )
export
AGC,
Modem,
PSK,
QAM,
exec,
modulate,
... | JayKickliter/Radio.jl | src/Radio.jl | Julia | mit | 352 |
using RCall
#install.packages("rgexf", dependencies=TRUE)
R"library(igraph);library(rgexf)"
R"g = gexf.to.igraph(read.gexf('MCMPOSTER.gexf'))"
R"weights = E(g)$weight"
R"weights = (weights-min(weights))"
R"E(g)$weight= weights/max(weights)"
R"""undirected = function(x){
if (length(x)==1) { return(x[1])}
... | wolfiex/RopaJL | reaction_classify/gephiigraph.jl | Julia | mit | 2,084 |
N = 10
filenames = readdir(joinpath("test", "data"))
for filename in filenames
full_filename = Pkg.dir("DataFrames", "test", "data", filename)
df = benchmark(() -> read_table(full_filename),
"DataFrame I/O",
filename,
N... | nfoti/JuliaData | benchmarks/io.jl | Julia | mit | 398 |
# Walter O'Keefe 2015-01-12
# Project Euler, problem 09
# There exists exactly one Pythagorean triplet for which
# a + b + c = 1000. Find the product abc.
# because a + b + c = 1000
# a < b < c < 1000
# a^2 + b^2 = c^2
# regulate that a < b
# regulate that c^2 = a^2 + b^2
# ^ the above also guarantees that a ... | wtok/project-euler | solutions/julia/eul09.jl | Julia | cc0-1.0 | 1,275 |
module PRLegVotos
end
| Nosferican/PRLegVotos | src/PRLegVotos.jl | Julia | apache-2.0 | 22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.