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 |
|---|---|---|---|---|---|
module RKHSFunctions
import ..NPGM.NodeBasis
import ..NPGM.EdgeBasis
#gaussian kernel
function GK{T<:FloatingPoint}(x::Vector{T}, y::Vector{T}, sigma::T)
return exp(-1/2/sigma^2 * vecdot(x-y, x-y) )
end
#general framework to compute \xi
function GK_Basis2_General{T<:FloatingPoint}(
data::Vector{T}, X::Array... | mlakolar/NPGM.jl | src/rkhsBasis.jl | Julia | mit | 4,804 |
# one parameter predicates
"""true iff midpoint(x) and radius(x) are zero"""
function iszero{P}(x::ArbFloat{P})
z = ccall(@libarb(arb_is_zero), Int, (Ptr{ArbFloat},), &x)
z != 0
end
iszero{T<:Real}(x::T) = (x == zero(T))
"""true iff midpoint(x) or radius(x) are not zero"""
function notzero{P}(x::ArbFloat{P})... | Jeffrey-Sarnoff/ArbFloats.jl | src/type/predicates.jl | Julia | mit | 6,009 |
using AMQPClient
const VIRTUALHOST = "/"
const HOST = "127.0.0.1"
function receive()
# 1. Create a connection to the localhost or 127.0.0.1 of virtualhost '/'
connection(; virtualhost=VIRTUALHOST, host=HOST) do conn
println("Connection established")
# 2. Create a channel to send messages
... | rabbitmq/rabbitmq-tutorials | julia/receive.jl | Julia | apache-2.0 | 1,372 |
len(n) = length(string(n))
c = 0
n = 1
while true
global c, n
if len(BigInt(9^n)) < n
break
end
for i = 0:9
maybe = BigInt(i^n)
if len(maybe) == n
println(i, "^", n, "=", maybe)
c += 1
end
end
n += 1
end
println(c) | pdbartlett/misc-stuff | euler/julia/Euler63.jl | Julia | apache-2.0 | 255 |
package java.util;
public class ArrayList implements Collection {
private Object[] objects;
private int size;
public ArrayList() {
objects = new Object[1];
size = 0;
}
public int indexOf(Object o) {
for (int i = 0; i < objects.length; i++) {
if (objects[i].equals(o)) {
return i;
}
... | HarvardPL/cryptoerase | sig-src/java/util/ArrayList.jl | Julia | bsd-3-clause | 1,843 |
type LinprogSolution
status
objval
sol
attrs
end
typealias InputVector{T<:Union{Real,Char}} Union{Vector{T},Real,Char}
function expandvec(x,len::Integer)
if isa(x,Vector)
if length(x) != len
error("Input size mismatch. Expected vector of length $len but got $(length(x))")
... | dpo/MathProgBase.jl | src/HighLevelInterface/linprog.jl | Julia | mit | 2,849 |
facts("Exchange responses for backtesting") do
context("Software-implemented limit order") do
plim = 150.0
buyord = TradingLogic.Order("buysome", 10, plim,
:buy, :limit, :pending, "aux")
sellord = TradingLogic.Order("sellsome", 10, plim,
:se... | JuliaQuant/TradingLogic.jl | test/exchange_backtest.jl | Julia | mit | 1,667 |
### File for the run! function for Stacks
# Compressed Stack structure is efficient within this run method
### Functions to run a CompressedStack similarly than for a classic stack
function run!(stack::CompressedStack)
while !eof(stack.input)
elt = readinput(stack)
while !isempty(stack) && stack.pop_conditio... | Azzaare/CompressedStacks.jl | src/run.jl | Julia | mit | 3,584 |
"""
A Solver takes a System and solves it.
"""
abstract Solver
" Should be overridden by the Solver implementations to initialize their data "
function initialize!(solver::Solver)
end
" Must be overriden by Solver implementations to actually do the solve "
function solve!(solver::Solver)
throw(MethodError(sol... | friedmud/MOOSE.jl | src/solvers/Solver.jl | Julia | mit | 1,579 |
#=
Compute the condition number given the initial graph and the preconditioner.
Uses cholfact, so, if the initial graph is not sdd or if inverse has a lot of nonzeros this fails.
=#
function condNumber{Tv,Ti}(la::SparseMatrixCSC{Tv,Ti}, prec::SparseMatrixCSC{Tv,Ti}; tol = 1e-5)
# cf = cholfact(prec)
n = la.n
ldl = ... | JuliaPackageMirrors/Laplacians.jl | src/condNumber.jl | Julia | mit | 3,591 |
using Gadfly
scatter = readdlm("scatter.dat")
scatter = [scatter; readdlm("scatter1.dat")]
w = 0.02
p = plot(
layer(
x = scatter[:,1].*(w/π),
y = scatter[:,2],
Geom.line,
Geom.point,
color = ["Transmission Probability"]
),
layer(
x = scatter[:,1].*(w/π),
... | stefco/g6080 | final/plot5.jl | Julia | mit | 631 |
# Ordinary metrics
###########################################################
#
# Metric types
#
###########################################################
type Euclidean <: Metric end
type SqEuclidean <: SemiMetric end
type Chebyshev <: Metric end
type Cityblock <: Metric end
type Minkowski <: Metric
p::Rea... | zhmz90/Distances.jl | src/metrics.jl | Julia | mit | 8,805 |
module Bio
abstract AbstractParser
abstract FileFormat
include("StringFields.jl")
include("Ragel.jl")
include("seq/Seq.jl")
include("intervals/Intervals.jl")
end # module Bio
| dcjones/Bio.jl | src/Bio.jl | Julia | mit | 178 |
module MAGMA
export device_reset,
MagmaVector, MagmaMatrix, get,
axpy!, dot,
gemv!
import Base: length,size,dot
using CUDArt
import CUDArt: device_reset
magmatypes = Union(Float32,Float64,Complex64,Complex128)
magmatypeslist = (Float32,Float64,Complex64,Complex128)
const typechar = [Float32=>... | mweastwood/MAGMA.jl | src/MAGMA.jl | Julia | bsd-2-clause | 3,545 |
################################################################################
#
# Abstract Jordan decomposition
#
################################################################################
# This holds invariants of a local Jordan decomposition
#
# L = L_1 \perp ... \perp L_r
#
# In the non-dyadic case we st... | thofma/hecke | src/QuadForm/Quad/Genus.jl | Julia | bsd-2-clause | 47,583 |
# Regular Expression
# ==================
#
# Regular expression sequence search tools.
#
# This file is a part of BioJulia.
# License is MIT: https://github.com/BioJulia/Bio.jl/blob/master/LICENSE.md
# String Decorators
# -----------------
macro biore_str(pat, opt...)
if isempty(opt)
error("symbol option... | richardreeve/Bio.jl | src/seq/search/re.jl | Julia | mit | 23,385 |
using Compat
import Compat.read
export PcapFileHeader, PcapRec, PcapOffline,
pcap_get_record
type PcapFileHeader
magic_number::UInt32
version_major::UInt16
version_minor::UInt16
thiszone::Int32
sigfigs::UInt32
snaplen::UInt32
network::UInt32
PcapFileHeader() = new(0,0,0,0,0,0,0)... | brandonkmiller/Pcap.jl | src/offline.jl | Julia | mit | 2,329 |
export CuVec
module CuVec
using ..Mocha
const THREADS_PER_BLOCK = 128
function cuda_geometry(len::Int)
x_block = round(Int64, ceil(convert(Float64, len)/THREADS_PER_BLOCK))
return (x_block, THREADS_PER_BLOCK)
end
for (ctype, dtype) in [(:float, Float32), (:double, Float64)]
# define add!, sub!, mul!, div!, div2... | chezou/Mocha.jl | src/cuda/utils/math.jl | Julia | mit | 3,350 |
using Roots
using Test
using JSON
using Printf
## testing/benchmarking derivative-free methods
mutable struct Func1
name::Symbol
val::Function
x0::Function
alpha # a value or values
params::Vector{Any}
end
function Base.show(io::IO, f::Func1)
@printf io "Func(%s)" f.name
end
#Construct a func... | JuliaLang/Roots.jl | test/test_derivative_free.jl | Julia | mit | 11,015 |
struct BoundingBox{P1 <: Vec, P2 <: Vec}
x0::P1
a::P2
end
BoundingBox(x0::P, width::T1, height::T2) where {P <: Vec2, T1 <: Measure, T2 <: Measure} =
BoundingBox{P, Tuple{T1, T2}}(x0, (width, height))
BoundingBox(x0::P, width::T1, height::T2, depth::T3) where {P <: Vec3, T1 <: Measure, T2 <: Measure, T3... | dcjones/Measures.jl | src/boundingbox.jl | Julia | mit | 1,907 |
##################################################################
# READ TROUBLESOME FILES WITH TOO MUCH WHITESPACE IN PLACES
##################################################################
read_and_unspace() = strip(replace(readline(), r"\s+", " "))
read_ints() = [parse(Int, x) for x in split(read_and_unspace(), "... | DarioFanucchi/CompetitionCode | algos.jl | Julia | mit | 19,047 |
module test_suite
using DomainSets, BasisFunctions, FrameFun, StaticArrays
using Test, Printf, LinearAlgebra, Random
FE = FrameFun
BA = BasisFunctions
## Settings
# Test fourier extensions for all parameters
Extensive = false
# Show matrix vector product timings
const show_mv_times = false
const verbose = true
tot... | daanhb/FrameFuns.jl | test/test_suite.jl | Julia | mit | 8,607 |
VERSION >= v"0.4.0-dev+6521" && __precompile__()
module Blosc
export compress, compress!, decompress, decompress!
using Compat
import Compat.String
const libblosc = joinpath(dirname(@__FILE__), "..", "deps", "libblosc")
function __init__()
ccall((:blosc_init,libblosc), Void, ())
atexit() do
ccall((:... | JuliaPackageMirrors/Blosc.jl | src/Blosc.jl | Julia | mit | 8,332 |
function shapefunc(geom::Int64,pospg::Array{Float64})
#=
This function computes the shape functions for Q2Q1-elements.
INPUT:
geom: The nodal geometry of the element (nen, nenP)
pospg: Position of the Gauss points on reference element
OUTPUT:
Nxi: Array of th... | Clemastecs/DynamTopo | shapefunc.jl | Julia | mit | 1,702 |
module TimeAxisArrays
using Reexport, Iterators
@reexport using AxisArrays
export TimeAxisArray, RegularTimeAxisArray,
timestamps, interval,
collapse, downsample, moving,
lead, lag, percentchange,
dropif, dropnan,
readtimeaxisarray, date, datetime
symbolize(x) = x |> string |> Symbol
defaultaxisnames = map(symbolize... | GordStephen/TimeAxisArrays.jl | src/TimeAxisArrays.jl | Julia | mit | 2,341 |
using MeshTools
data1 = randn(3, 20)
data2 = randn(3, 20)
data = hcat(data1, [100, 0, 0], data2)
v, ind = convexhull(data, true, 1e-8, true)
println("volume of hull: $(volume(v, ind))")
saveObj(v, ind, "output/rand.obj")
data = [1 1 1 1 0 0 0 0; 1 1 0 0 1 1 0 0; 1 0 1 0 1 0 1 0]
v, ind = convexhull(data)
println("vo... | ShnitzelKiller/MeshTools.jl | test/hulltest.jl | Julia | bsd-2-clause | 410 |
using Gadfly, DataFrames
plot(readtable(joinpath(dirname(@__FILE__), "issue120.csv")), x=:x1, y=:x2)
| JuliaPackageMirrors/Gadfly.jl | test/issue120.jl | Julia | mit | 102 |
# Depth-first visit / traversal
#################################################
#
# Depth-first visit
#
#################################################
mutable struct DepthFirst <: AbstractGraphVisitAlgorithm
end
function depth_first_visit_impl!(
graph::AbstractGraph{V,E}, # the graph
stack, ... | JuliaLang/Graphs.jl | src/depth_first_visit.jl | Julia | mit | 4,513 |
using FactCheck
inc(x) = x + 1
facts("Succeeding examples") do
@fact 1 --> 1
context("You can define contexts") do
@fact 1 --> 1
end
@fact_throws error("neat")
context("group facts") do
@fact 1 --> not(2)
@fact 2 --> not(isodd)
end
context("generating facts") d... | JuliaLang/FactCheck.jl | example/examples.jl | Julia | mit | 1,163 |
export frac_iso, is_frac_iso
"""
frac_iso(G,H)
Find a doubly stochastic matrix `S` so that `AS=SB` where `A` and `B`
are the adjacency matrices of `G` and `H` respectively.
"""
function frac_iso(G::SimpleGraph, H::SimpleGraph)
if deg(G) != deg(H) || degdeg(G) != degdeg(H) # quick basic check before LP
... | scheinerman/SimpleGraphAlgorithms.jl | src/frac_iso.jl | Julia | mit | 1,534 |
using Compose
import Colors
typealias ComposeColor Union(Colors.Color, Colors.AlphaColor, Colors.String)
@doc """
Given an adjacency matrix and two vectors of X and Y coordinates, returns
a Compose tree of the graph layout
Arguments:
adj_matrix Adjacency matrix of some type. Non-zero of the eltype
... | afternone/GraphLayout.jl | src/draw.jl | Julia | mit | 5,997 |
include("../linesearch/Linesearch.jl")
# Quasi-Newton-Method (BFGS), or Gradient-Descent, depending on parameter
function qn(x0, f, g,eps, maxiter, maxLSiter, maxzoomiter, c1, c2,ls, dir)
@printf("iter \t\t fval \t\t\t diff \t\t opt \t\t alp \t\t lsiter \n")
x_k = x0
x_old = x_k
oval = Inf
H_k = In... | zagazao/num-opt | src/opt/GradientDescent.jl | Julia | mit | 2,138 |
module Lexer
using Compat
import Base.UTF8proc
import Base: position
import ..Diagnostics: diag, Incomplete, before
using ..Tokens
using ..Tokens: √
export Token, TokenStream, next_token, set_token!, last_token,
put_back!, peek_token, take_token, require_token
const SYM_TRUE = Symbol("true")
const SYM_FALSE... | JuliaPackageMirrors/JuliaParser.jl | src/lexer.jl | Julia | mit | 33,774 |
using Compat
const snapsvgjs = joinpath(dirname(@__FILE__), "..", "data", "snap.svg-min.js")
# Packages can insert extra XML namespaces here to be defined in the output
# SVG.
const xmlns = Dict()
# Format a floating point number into a decimal string of reasonable precision.
function svg_fmt_float(x::Fractional)
... | darwindarak/Compose.jl | src/svg.jl | Julia | mit | 35,366 |
module ImageView
if VERSION < v"0.4.0-dev+3275"
using Base.Graphics
import Base.Graphics: width, height, fill, set_coords, xmin, xmax, ymin, ymax
else
using Graphics
import Graphics: width, height, fill, set_coords, xmin, xmax, ymin, ymax
end
using Cairo
using Tk
using Color
using Images
using Compat
... | rened/ImageView.jl | src/ImageView.jl | Julia | mit | 1,265 |
using JuMP, FactCheck, AmplNLWriter
## Solve test problem with sind and cosd functions
#
# min (7 - (3*cosd(x1) + 5*cosd(x2)))^2 + (0 - (3*sind(x1) + 5*sind(x2)))^2
# s.t. x1, x2 continuous
#
# The optimal objective value is 0
##
# Allow resolving the model from multiple starts after NLP changes in JuMP 0... | JuliaPackageMirrors/AmplNLWriter.jl | examples/jump_nltrig.jl | Julia | mit | 1,020 |
using Test
using LinearAlgebra
include("setupTests.jl")
@testset "jInv" begin
include("Mesh/runtests.jl")
include("ForwardShare/runtests.jl")
include("Utils/runtests.jl")
include("InverseSolve/runtests.jl")
include("LinearSolvers/runtests.jl")
end
| JuliaInv/jInv.jl | test/runtests.jl | Julia | mit | 255 |
## Analyzing memory allocation
immutable MallocInfo
bytes::Int
filename::UTF8String
linenumber::Int
end
sortbybytes(a::MallocInfo, b::MallocInfo) = a.bytes < b.bytes
function analyze_malloc_files(files)
bc = MallocInfo[]
for filename in files
open(filename) do file
for (i,ln) ... | jbn/Coverage.jl | src/memalloc.jl | Julia | mit | 1,561 |
# Dual number with multiple epsilon components.
# Fast inlined storage (will switch to tuples when they're fast)
# This is useful because we can avoid recomputing expensive functions and share computations across the epsilon components.
# Interface will improve, so not exported yet.
immutable Dual4{T<:Real} <: Number
... | JuliaPackageMirrors/DualNumbers.jl | src/dual_n.jl | Julia | mit | 6,919 |
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: textract
using AWS.Compat
using AWS.UUIDs
"""
analyze_document(document, feature_types)
analyze_document(document, feature_types, params::Dict{String,<:Any})
Analyzes an input document for relationships between detected items. T... | JuliaParallel/AWS.jl | src/services/textract.jl | Julia | mit | 27,953 |
using Plots
gr()
x = 1:10; y = rand(10) # These are the plotting data
plot(x,y)
annotate!([(0,0, text("this is #5\r\n asdf",16,:red,:center) ) ])
gui()
| nouyang/janson299r | wk11/tmp.jl | Julia | mit | 156 |
module T
type Entry
J::String ## Julia
M::String ## Matlab
P::String ## Python
R::String ## R
precond::String
end
type Input
var::String
vals::Array{String}
end
end
| gusl/Sorcetta | types.jl | Julia | mit | 196 |
function make_mat(dims=(3,4))
mat = PETSc.Mat(ST, dims...)
vt1 = RC(complex(3., 3.))
vt2 = RC(complex(5., 5.))
mat[1,1] = vt1
mat[1,2] = vt2
PETSc.assemble(mat)
return mat
end
@testset "Mat{$ST}" begin
@testset "Preallocator" begin
for mt in [PETSc.C.MATMPIAIJ,PETSc.C.MATMPIBAIJ,PETS... | stevengj/PETSc.jl | test/mat.jl | Julia | mit | 9,100 |
export
putstreamfunc,
putcallbackfunc
function msk_stream_callback_wrapper(userdata::Ptr{Nothing}, msg :: Ptr{UInt8})
f = unsafe_pointer_to_objref(userdata) :: Function
f(unsafe_string(msg))
convert(Int32,0)::Int32
end
"""
putstreamfunc(t::MSKtask, whichstream:: Streamtype, f :: Function)
Attach a log ... | JuliaOpt/Mosek.jl | src/msk_callback.jl | Julia | mit | 3,233 |
using Excavator
using Base.Test
# write your own tests here
@test 1 == 1
| JeremyRubin/Excavator.jl | test/runtests.jl | Julia | mit | 74 |
using EEG
using Base.Test
using Logging
using MAT, BDF
using SIUnits, SIUnits.ShortUnits
using FileFind
using Plots
using FactCheck
Logging.configure(level=DEBUG)
Logging.configure(output=open("logfile.log", "a"))
unicodeplots()
#
# Run all tests
#
tests = AbstractString[]
function add_test(fname)
global tests
... | JuliaPackageMirrors/EEG.jl | test/runtests.jl | Julia | mit | 533 |
## Binomial Example ####
## Note: Adapted from the Rate_4 example in Bayesian Cognitive Modeling
## https://github.com/stan-dev/example-models/tree/master/Bayesian_Cognitive_Modeling
using Mamba, Stan
ProjDir = dirname(@__FILE__)
cd(ProjDir) do
const binomialstanmodel = "
// Inferring a Rate
data {
int<lower=1> n... | JuliaPackageMirrors/Stan.jl | Examples/Binomial/binomial.jl | Julia | mit | 1,541 |
function rna(dna)
rna_str = ""
# Your code goes here
return rna_str
end
| project-lovelace/lovelace-website | src/static/code_stubs/julia/dna_transcription.jl | Julia | mit | 86 |
module Inv
const data_fl = "IntegerArray.txt"
function inv_main()
num_data = 100_000
data = Array{Int64,1}(num_data)
open(data_fl) do file
num_line = 0
while !eof(file)
num_line += 1
num = parse(Int64, strip(readline(file)))
data[num_line] = num
... | zhmz90/Algorithms_stanford | prog1/Inv.jl | Julia | mit | 2,605 |
function rectangle_filter(nb,nx,xx,yy)
bb = zeros(Float32,nx+nb)
ny = nx+nb-1
bb[1] = xx[1]
for i = 2 : nx
bb[i] = bb[i-1] + xx[i]
end
for i = nx+1 : ny
bb[i] = bb[i-1]
end
for i = 1 : nb
yy[i] = bb[i]
end
for i = nb+1 : ny
yy[i] = bb[i] - bb[i-nb]
end
for i = 1 : ny
yy[i] = yy[i] / nb
end
end
... | aaronstanton/Seismic.jl | src/Utils/Smoothing.jl | Julia | mit | 949 |
export PeriodicInterval
immutable PeriodicInterval{T<:Number} <: PeriodicDomain{T}
a::T
b::T
PeriodicInterval()=new(-convert(T,π),convert(T,π))
PeriodicInterval(a,b)=new(a,b)
end
PeriodicInterval()=PeriodicInterval{Float64}()
PeriodicInterval(a::Int,b::Int) = PeriodicInterval(Float64(a),Float64(b))... | yuyichao/ApproxFun.jl | src/Domains/PeriodicInterval.jl | Julia | bsd-3-clause | 2,286 |
procs = addprocs(1)
push!(LOAD_PATH,joinpath("..","src"))
push!(LOAD_PATH,joinpath("..","..","..","POMCP.jl","src"))
using Multilane
using POMCP
using POMDPToolbox
using GenerativeModels
using MCTS
using JLD
function POMCP.extract_belief(::POMDPToolbox.FastPreviousObservationUpdater{MLObs}, node::RootNode)
rand(M... | zsunberg/Multilane.jl | scratch_old/compare.jl | Julia | mit | 4,861 |
# This file is a part of AstroLib.jl. License is MIT "Expat".
# Copyright (C) 2016 Mosè Giordano.
function planck_wave(wavelength::T, temperature::T) where {T<:AbstractFloat}
c1 = 3.741771790075259e-16 # = 2*pi*h*c*c
c2 = 1.43877735382772e-2 # = h*c/k
return c1/(wavelength^5*(expm1(c2/wavelength/temper... | giordano/AstroLib.jl | src/planck_wave.jl | Julia | mit | 1,562 |
n = rand(2:10)
A = matrixdepot("wilkinson", n)
@test A == matrixdepot("wilkinson", Float64, n)
@test issym(full(A))
@test_approx_eq diag(full(A),1) ones(Float64, n - 1)
# symmetric along antidiagonal
@test issym(full(A)[n:-1:1,:])
println("'wilkinson' passed test...")
| jakebolewski/MatrixDepot.jl | test/test_wilkinson.jl | Julia | mit | 277 |
import HTTP
import HTTP.Request
export respond
# Utils
pre(f) = (app, req) -> app(f(req))
post(f) = (app, req) -> f(app(req))
# Request
using HTTP.URIs: URI
function todict(req::Request)
req′ = Dict()
req′[:method] = req.method
req′[:headers] = req.headers
req′[:data] = req.body
req′[:uri] = URI(req.... | one-more-minute/Mux.jl | src/basics.jl | Julia | mit | 2,617 |
char(x) = convert(Char, x)
char(x::FloatingPoint) = char(iround(x))
integer(x::Char) = int(x)
## char promotions ##
promote_rule(::Type{Char}, ::Type{Int8}) = Int32
promote_rule(::Type{Char}, ::Type{Uint8}) = Int32
promote_rule(::Type{Char}, ::Type{Int16}) = Int32
promote_rule(::Type{Char}, ::Type{Uint16}) =... | shubhamg31/columbus_julia | lib/julia/base/char.jl | Julia | apache-2.0 | 1,704 |
############################################################################################################
# MODULE : Drops a feature from the given feature set based on the given data and a loss function
#
# USAGE : A_new = drop_feature(loss_func, A, fs)
#
# INPUT : loss_func: Function to be used for measuring t... | shubhamg31/columbus_julia | modules/stepdrop.jl | Julia | apache-2.0 | 1,668 |
#Copyright (c) 2015 Rex Computing and Isaac Yonemoto
#see LICENSE.txt
#this work was supported in part by DARPA Contract D15PC00135
#profiling zero tests.
include ("../../unum.jl")
#run in unum{4,6} environment. 30% of the unums will have a ubit set.
#10% of the unums will be zero, 10% of them will be negative z... | REX-Computing/unumjl | profiling/profile-zero.jl | Julia | mit | 898 |
using IniFile
using Test
ini = Inifile()
read(ini, joinpath(dirname(@__FILE__),"test.ini"))
# section exists
@test has_section(ini, "not present") == false
@test has_section(ini, "section 1") == true
# get value or defaults
@test get(ini, "section 1", "strname1") == "section1name1"
@test get(ini, "section 1", "strna... | JuliaLang/IniFile.jl | test/runtests.jl | Julia | mit | 2,091 |
# an idea: create one method named pivots with kwargs
function floorpivots{T,N}(ohlc::TimeArray{T,N})
p = lag(typical(ohlc))
s1 = 2.*p .- lag(ohlc["High"])
r1 = 2.*p .- lag(ohlc["Low"])
s2 = p .- (r1 .- s1)
r2 = (p .- s1) .+ r1
s3 = p .- (r2 .- s1)
r3 = (p .- s1) .+ r2
TimeArra... | JuliaPackageMirrors/MarketTechnicals.jl | src/levels.jl | Julia | mit | 2,089 |
function add_constrs!(model::Model, cbegins::IVec, inds::IVec, coeffs::FVec, rel::CVec, rhs::FVec)
nnz = length(inds)
ncons = length(rhs)
(nnz == length(coeffs)) || error("Incompatible constraint argument dimensions.")
for k in 1:length(rel)
if rel[k] == UInt8('>')
rel[k] = conver... | JuliaPackageMirrors/CPLEX.jl | src/cpx_constrs.jl | Julia | mit | 13,794 |
using Split, DataFrames
using Base.Test
# Array test
a = [1,2,3,4,5]
# DataArray test data
da = @data([1,2,3,4,5])
(size_da,) = size(da)
indices_da = [1:size_da;]
# DataFrames test data
df = DataFrame(A = 1:5, B = ["A", "B", "C", "D", "E"])
# Test data
fraction = 0.5
seed = 1234
# Test that the shuffled input is d... | maarek/Split.jl | test/runtests.jl | Julia | mit | 1,063 |
using Gadfly, DataFrames, Dates
set_default_plot_size(6inch, 3inch)
a = collect(Date("2013-01-01"):Day(1):Date("2014-01-01"))
b = collect(Date("2012-01-01"):Day(1):Date("2016-01-01"))
ya = sin.(0.01 * Float64.(Dates.value.(a)))
yb = cos.(0.01 * Float64.(Dates.value.(b)))
df1 = DataFrame(
x = a,
y = ya,
l... | dcjones/Gadfly.jl | test/testscripts/timeseries_colorful.jl | Julia | mit | 473 |
# Tests for conditional entropy function
entropy1 = get_entropy(arr1)
entropy2 = get_entropy(arr2)
entropy12 = get_entropy(arr1, arr2)
# Test with 1 values array conditioned on itself
@test get_conditional_entropy(arr1, arr1) ≈ 0 atol = 0.05
println("Conditional entropy with 1 array passed.")
conditional_entropy = e... | Tchanders/EntropyEstimators | test/testConditionalEntropy.jl | Julia | mit | 667 |
module Lingua
export stem
function stem(word, lang)
word = lowercase(word)
chars = length(word)
if chars < 4
return word
end
if chars > 5
local stem = replace(word, r"ища$", "")
if stem != word
return stem
end
end
word = remove_article(word)
... | patch/lingua-jl | src/Lingua.jl | Julia | mit | 2,966 |
#-------------------------------------------------------------------
#* 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/mixers_splitters/splitter/splitter_column.jl | Julia | mit | 3,682 |
################################################################################
# _ _ ____ ___ ____ _ _ #
# |\/| | | | \ |___ |\/| #
# | | |__| |__/ |___ | | ... | JayKickliter/Radio.jl | src/Modem.jl | Julia | mit | 1,537 |
include("FunField/DegreeLocalization.jl")
include("FunField/Round2.jl")
include("FunField/Factor.jl")
include("FunField/HessQR.jl")
include("FunField/IntClsZx.jl")
| thofma/Hecke.jl | src/FunField.jl | Julia | bsd-2-clause | 164 |
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: budgets
using AWS.Compat
using AWS.UUIDs
"""
create_budget(account_id, budget)
create_budget(account_id, budget, params::Dict{String,<:Any})
Creates a budget and, if included, notifications and subscribers. Only one of BudgetLi... | JuliaParallel/AWS.jl | src/services/budgets.jl | Julia | mit | 36,085 |
# 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
@testset "polygon clip case 1" begin
S = Vector[
[0.375, 0.0, 0.5],
[0.6, 0.0, 0.5],
[0.5, 0.25, 0.5]]
M = Vector[
[0.50... | ahojukka5/JuliaFEM.jl | test/test_mortar_3d_polygon_clip.jl | Julia | mit | 1,008 |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | zhreshold/mxnet | julia/src/ndarray/array.jl | Julia | apache-2.0 | 20,268 |
function calc_rho( pw::PWGrid, psi::Array{ComplexF64,2} )
Ω = pw.Ω
Ns = pw.Ns
Npoints = prod(pw.Ns)
Nstates = size(psi)[2]
ρ = zeros(ComplexF64,Npoints) # FIXME: or use Float64 instead?
# Transform to real space
cpsi = zeros( ComplexF64, Npoints, Nstates )
cpsi[pw.gvecw.idx_gw2r,:] = p... | f-fathurrahman/ffr-ElectronicStructure.jl | PW/sch_02/calc_rho.jl | Julia | mit | 624 |
# Copyright 2014 Mitchell Kember. Subject to the MIT License.
# Project Euler: Problem 20
# Factorial digit sum
module problem_20
function solve()
sum(digits(factorial(big(100))))
end
end # module
| mk12/euler | julia/problem_20.jl | Julia | mit | 201 |
function besselroots(nu::Float64, n::Integer)
#BESSELROOTS The first N roots of the function J_v(x)
# DEVELOPERS NOTES:
# V = 0 --> Full double precision for N <= 20 (Wolfram Alpha), and very
# accurate approximations for N > 20 (McMahon's expansion)
# -1 <= V <= 5 : V ~= 0 --> 12 decimal figures for the 6 ... | ajt60gaibb/FastGaussQuadrature.jl | src/besselroots.jl | Julia | mit | 6,441 |
macro init(expr::Expr...)
isempty(expr) && error("@init format error")
esc(quote
global judi_config = Dict{Symbol, Array{Int, 1}}()
function init(judi_init_config, config)
merge!(judi_config, judi_init_config)
println("Init Module ", config[:name], "...")
$... | mogucpp/Judi | judi/base.jl | Julia | mit | 1,229 |
#!/usr/bin/env julia
# The MIT License (MIT)
#
# Copyright (c) 2014 Gil Gonçalves
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the righ... | LuRsT/hr.jl | hr.jl | Julia | mit | 1,581 |
using ChromNet
using JLD
using Base.Test
srand(1)
# create a sample network dataset to use
jldopen("data/small.ChromNet.jld", "w") do f
data = zeros(Int32, 4, 1000000)
data[:,:] = rand(0:100, 4, 1000000)
ids = ["A01", "B01", "C01", "D01"]
f["P"] = 4
f["N"] = 1000000
f["ids"] = ids
f["data"]... | slundberg/ChromNet.jl | test/runtests.jl | Julia | apache-2.0 | 1,935 |
@test sprint(show, h1) == "{5, 0} undirected graph"
@test sprint(show, h3) == "empty undirected graph"
@test Graph(g4) == g3
@test degree(g3, 1) == 1
# @test all_neighbors(g3, 3) == [2, 4]
@test density(g3) == 0.4
g = Graph(5)
@test add_edge!(g, 1, 2) == e1
e2 = add_edge!(g, 1, 3)
e3 = add_edge!(g, 1, 4)
e4 = add_ed... | jpfairbanks/LightGraphs.jl | test/graphdigraph.jl | Julia | bsd-2-clause | 1,404 |
include("ModAlgAss/ModAlgAss.jl")
include("ModAlgAss/MeatAxe.jl")
| thofma/hecke | src/ModAlgAss.jl | Julia | bsd-2-clause | 66 |
"""
```
pseudo_measurement(m::Model990{T}, TTT::Matrix{T}, RRR::Matrix{T},
CCC::Vector{T}; reg::Int = 1,
TTTs::Vector{<: AbstractMatrix{T}} = Matrix{T}[],
CCCs::Vector{<: AbstractVector{T}} = Vector{T}[],
information_set::UnitRange = reg:reg,
... | FRBNY-DSGE/DSGE.jl | src/models/representative/m990/pseudo_measurement.jl | Julia | bsd-3-clause | 3,641 |
#From TextAnalysis.jl Package.
function PrepCorpus(dirname::String,DocType::Type)
# Recursive descent of directory
# Add all non-hidden files to Corpus
docs = {}
function add_files(dirname::String)
if !isdir(dirname)
error("DirectoryCorpus() can only be called on directories")
... | abhijithch/JuliaTutorial.jl | src/PrepCorpus.jl | Julia | mit | 849 |
#################### TransformDistribution ####################
typealias TransformDistribution{T<:ContinuousUnivariateDistribution}
Union{T, Truncated{T}}
function link(d::TransformDistribution, x::Real)
a, b = minimum(d), maximum(d)
lowerbounded, upperbounded = isfinite(a), isfinite(b)
if lowerbounded && up... | JuliaPackageMirrors/Mamba.jl | src/distributions/transformdistribution.jl | Julia | mit | 2,413 |
convert(::Type{T}, r::RObject{S}) where {T, S<:Sxp} = rcopy(T, r.p)
convert(::Type{Any}, r::RObject{S}) where S<:Sxp = r
convert(::Type{RObject}, r::RObject{S}) where S<:Sxp = r
convert(::Type{RObject{S}}, r::RObject{S}) where S<:Sxp = r
# conversion between numbers which understands different NAs
function rcopy(::Typ... | JuliaStats/RCall.jl | src/convert/base.jl | Julia | mit | 9,051 |
export
add,
flush,
find_position
add( idarr::IdArray, thisString::AbstractString ) = ccall( (:idarray_Add, LIB_SMILE), Int32, (Ptr{Void},Ptr{UInt8}), idarr.ptr, bytestring(thisString) )
# String Arrays
find_position( idarr::IdArray, ofThisString::AbstractString) =
ccall( (:stringarray_FindPosition, LI... | sisl/Smile.jl | src/low_level/idarray.jl | Julia | mit | 503 |
export @class
function allocclass(name, super)
ptr = ccall(:objc_allocateClassPair, Ptr{Void}, (Ptr{Void}, Ptr{Cchar}, Csize_t),
super, name, 0)
ptr == C_NULL && error("Couldn't allocate class $name")
return Class(ptr)
end
function register(class::Class)
ccall(:objc_registerClassPair, Void, (Ptr... | JuliaPackageMirrors/ObjectiveC.jl | src/classes.jl | Julia | mit | 3,420 |
using Gadfly
set_default_plot_size(6inch, 6inch)
#plot(layer(x=[0, 1, 1, 0], y=[0, 1, 0, 1], ygroup=["A", "A", "B", "B"],
#Geom.subplot_grid(Geom.line), Theme(default_color=colorant"red")),
#layer(x=[0.5, 1.5, 1.5, 0.5], y=[0, 1, 0, 1], ygroup=["A", "A", "B", "B"],
#Geom.subplot_grid(Geom.l... | dcjones/Gadfly.jl | test/testscripts/layered_subplots.jl | Julia | mit | 650 |
strip_line_numbers!(arg) = arg
function strip_line_numbers!(ex::Expr)
keep = trues(length(ex.args))
for i = 1:length(ex.args)
if isa(ex.args[i], LineNumberNode)
keep[i] = false
end
isa(ex.args[i], Expr) || continue
if ex.args[i].head == :line
keep[i] = fal... | mdcfrancis/Clang.jl | test/strip_line_numbers.jl | Julia | mit | 452 |
using Compat, ClassicalLaminateTheory
forcesAndMoments =
@compat Dict(
:Nx => 0,
:Ny => 0,
:Nxy => 0,
:Mx => 0,
:My => 0,
:Mxy => 0)
materialProperties =@compat Dict(
:E1 => 20.0*10^6,
:E2 => 1.1*10^6,
:G12 => 0.65*10^6,
:ν12 => .21,
:alpha1 => 0.2e-6,
:alpha2 => 0.2e-4,
:bet... | goedman/ClassicalLaminateTheory.jl | Examples/CLT/clt6.5.1.jl | Julia | mit | 831 |
#-------------verlet.jl--------------------------------------------------------#
#
# Purpose: To implement the verlet force integrator
#
#------------------------------------------------------------------------------#
using Plots
# For this force integrator, we need the particle's current position and it's
# prev... | vchuravy/skillpill-julia | examples/force_integration/verlet.jl | Julia | mit | 837 |
######################################################################
# FactCheck.jl
# A testing framework for Julia
# http://github.com/JuliaLang/FactCheck.jl
# MIT Licensed
######################################################################
module FactCheck
using Compat
export @fact, @fact_throws, @pending,
... | tbreloff/FactCheck.jl | src/FactCheck.jl | Julia | mit | 12,817 |
# AbstractVector wrapper around PETSc Vec types
export Vec
typealias pVec Ptr{Void} # Vec arguments in Petsc are pointers
type Vec <: AbstractVector{PetscScalar}
p::pVec
assembling::Bool # whether we are in the middle of assemble(vec) do ..
insertmode::InsertMode # current mode for setindex!
function Ve... | jiahao/PETSc.jl | src/temp/vec.jl | Julia | mit | 11,022 |
function encode(s)
end
function decode(s)
end
| exercism/xjulia | exercises/practice/run-length-encoding/run-length-encoding.jl | Julia | mit | 49 |
function plotintersect(S::Session, c; its=20000, h=.05, rkonly=false)
local data
rk4((t,x)->S.core.f(t,[x;c]), .0, 10rand(3), h, predCount(its), init=()->(data=Array{Float64}(0,3)), callback=(t,y,f)->(data = [data;y']))
f = figure()
axes(projection="3d")
hold(true)
plot(data[end÷4:end,1], data[end÷4:end,2], data... | 285714/ncm | master/lib/ncmprojPLOTINTERSECT.jl | Julia | mit | 1,025 |
streamingops_spec =
[
(:_type, AbstractString, nothing),
(:signal, AbstractString, nothing),
(:field, AbstractString, nothing),
]
primitivefactory(:VegaStreamingOps, streamingops_spec) | slowbrain/Vega.jl | src/primitives/streamingops.jl | Julia | mit | 188 |
lyap(a::StaticMatrix, c::StaticMatrix) = _lyap(Size(a), Size(c), a, c)
_lyap(::Size{(1,1)}, ::Size{(1,1)}, a::StaticMatrix, c::StaticMatrix) = -c/(2a[1,1])
@inline function _lyap(::Size{(2,2)}, ::Size{(2,2)}, a::StaticMatrix, c::StaticMatrix)
d = det(a)
t = tr(a)
-(d*c + (a - t*I)*c*(a-t*I)')/(2*d*t)... | andyferris/StaticArrays.jl | src/lyap.jl | Julia | mit | 463 |
@testset "MultiQuad" begin
# include(joinpath(Hecke.pkgdir, "examples", "MultiQuad.jl"))
#
# c = MultiQuad.multi_quad(fmpz[3,5,7], 10)
# d = MultiQuad.simplify(c)
# @test MultiQuad.Hecke.class_group_get_pivot_info(d) == (4, BitSet([2, 4]))
# e = MultiQuad.saturate(d, 2)
# @test MultiQuad.Hecke.class_group_get_pi... | thofma/Hecke.jl | test/Examples/MultiQuad.jl | Julia | bsd-2-clause | 468 |
module TestLossFunctions
using FactCheck
importall GradientBoost.LossFunctions
type DummyLossFunction <: LossFunction; end
y_examples = {
[1,1],
[1,0],
[0,0],
[-1,1],
[-1,-1]
}
y_pred_examples = {
[1,1],
[1,1],
[1,1],
[1,1],
[1,1]
}
bern_y_examples = {
[1,1],
[1,0],
[0,1],
[0,0],
[0,0]
... | svs14/GradientBoost.jl | test/test_loss.jl | Julia | mit | 3,204 |
module LightTable
using JSON, Lazy, Jewel, LNR, Requires
import Jewel: lines
export server, ltprint, popup, notify
exit_on_sigint(on) = ccall(:jl_exit_on_sigint, Void, (Cint,), on)
const connect_notify = Condition()
function flushpipe(io)
@schedule begin
wait(connect_notify)
while true
ltprint(rea... | JuliaIDE/Jewel.jl | src/LightTable/LightTable.jl | Julia | mit | 2,305 |
# ## Basis Set Data
# Note use of curly braces here. Julia assumes that if you have square braces, you want
# things flattened as much as possible (to be as fast as possible, I guess). Curlys
# preserve the list structure the way I would expect from Python
# ## Basis function definitions
type PGBF
expn::Float64
x... | f-fathurrahman/ffr-ElectronicStructure.jl | LO_Gaussian/orig/basfun.jl | Julia | mit | 2,046 |
# Test of vbroadcast
using NumericExtensions
using Base.Test
#### 2D ####
x = randn(5, 6)
yr = rand(6) + 0.5
yrm = reshape(yr, 1, 6)
yc = rand(5) + 0.5
# badd
@test_approx_eq badd(x, yc, 1) x .+ yc
@test_approx_eq badd(x, yr, 2) x .+ yrm
r = copy(x); badd!(r, yc, 1)
@test_approx_eq r x .+ yc
r = copy(x); badd!(r... | lendle/NumericExtensions.jl | test/vbroadcast.jl | Julia | mit | 1,772 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.