From 52b92749912654bdd533aab4ca0142a35c362452 Mon Sep 17 00:00:00 2001 From: Patrick O'Leary Date: Mon, 2 Apr 2012 23:20:27 -0500 Subject: [PATCH 1/5] Added detection for the Julia language. --- lib/linguist/languages.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index a470f579..8775510d 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -599,6 +599,13 @@ JavaScript: filenames: - Jakefile +Julia: + type: programming + lexer: Text only + primary_extension: .jl + extensions: + - .jl + Kotlin: type: programming lexer: Kotlin From 4f0b45728703ba2eb3ae895fcaf2c19c0f1bcb37 Mon Sep 17 00:00:00 2001 From: Patrick O'Leary Date: Wed, 4 Apr 2012 21:28:29 -0500 Subject: [PATCH 2/5] Updated Julia language with lexer and added tests --- lib/linguist/languages.yml | 2 +- test/fixtures/stockcorr.jl | 37 +++++++++++++++++++++++++++++++++++++ test/test_blob.rb | 4 ++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/stockcorr.jl diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 8775510d..54f786a0 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -601,7 +601,7 @@ JavaScript: Julia: type: programming - lexer: Text only + lexer: Julia primary_extension: .jl extensions: - .jl diff --git a/test/fixtures/stockcorr.jl b/test/fixtures/stockcorr.jl new file mode 100644 index 00000000..58ba80a5 --- /dev/null +++ b/test/fixtures/stockcorr.jl @@ -0,0 +1,37 @@ +## Test case from Issue #445 + +#STOCKCORR - The original, unoptimised code that simulates two correlated assets +function stockcorr() + + ## Correlated asset information + CurrentPrice = [78. 102.] # Initial Prices of the two stocks + Corr = [1. 0.4; 0.4 1.] # Correlation Matrix + T = 500 # Number of days to simulate = 2years = 500days + n = 100000 # Number of simulations + dt = 1/250 # Time step (1year = 250days) + Div=[0.01 0.01] # Dividend + Vol=[0.2 0.3] # Volatility + + ## Market Information + r = 0.03 # Risk-free rate + + ## Define storages + SimulPriceA = zeros(T,n) # Simulated Price of Asset A + SimulPriceA[1,:] = CurrentPrice[1] + SimulPriceB = zeros(T,n) # Simulated Price of Asset B + SimulPriceB[1,:] = CurrentPrice[2] + + ## Generating the paths of stock prices by Geometric Brownian Motion + UpperTriangle=chol(Corr) # UpperTriangle Matrix by Cholesky decomposition + + for i = 1:n + Wiener = randn(T-1,2) + CorrWiener = Wiener*UpperTriangle + for j = 2:T + SimulPriceA[j,i] = SimulPriceA[j-1,i]*exp((r-Div[1]-Vol[1]^2/2)*dt+Vol[1]*sqrt(dt)*CorrWiener[j-1,1]) + SimulPriceB[j,i] = SimulPriceB[j-1,i]*exp((r-Div[2]-Vol[2]^2/2)*dt+Vol[2]*sqrt(dt)*CorrWiener[j-1,2]) + end + end + + return (SimulPriceA, SimulPriceB) +end diff --git a/test/test_blob.rb b/test/test_blob.rb index 42df3221..2e31f784 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -427,6 +427,9 @@ class TestBlob < Test::Unit::TestCase # Kotlin assert_equal Language['Kotlin'], blob("Foo.kt").language + + # Julia: http://julialang.org/ + assert_equal Language['Julia'], blob("stockcorr.jl").language end def test_lexer @@ -438,6 +441,7 @@ class TestBlob < Test::Unit::TestCase assert_equal Lexer['Text only'], blob("README").lexer assert_equal Lexer['Tea'], blob("foo.tea").lexer assert_equal Lexer['vhdl'], blob("foo.vhd").lexer + assert_equal Lexer['Julia'], blob("stockcorr.jl").lexer end def test_shebang_script From 95ec95fdac36b54f5edce225890083747a4f164a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicent=20Mart=C3=AD?= Date: Sun, 8 Apr 2012 20:28:55 +0200 Subject: [PATCH 3/5] Add DCPU-16 assembly --- lib/linguist/languages.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 54f786a0..27b66c15 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -299,6 +299,15 @@ Delphi: - .lpr - .pas +DCPU-16 Assembly: + type: programming + lexer: dasm16 + aliases: + - dasm16 + extensions: + - .dasm16 + - .dasm + Diff: extensions: - .diff From 01c93453a75e023fdd85a75b38f4d19c78f52d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicent=20Mart=C3=AD?= Date: Mon, 9 Apr 2012 20:36:18 +0200 Subject: [PATCH 4/5] Bump the version of Pygments --- linguist.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linguist.gemspec b/linguist.gemspec index b6dd8b5b..23106946 100644 --- a/linguist.gemspec +++ b/linguist.gemspec @@ -11,6 +11,6 @@ Gem::Specification.new do |s| s.add_dependency 'charlock_holmes', '~> 0.6.6' s.add_dependency 'escape_utils', '~> 0.2.3' s.add_dependency 'mime-types', '~> 1.18' - s.add_dependency 'pygments.rb', '~> 0.2.8' + s.add_dependency 'pygments.rb', '~> 0.2.9' s.add_development_dependency 'rake' end From 633ef5213d273f9aa05649e941c69fc9f639f72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicent=20Mart=C3=AD?= Date: Mon, 9 Apr 2012 20:46:29 +0200 Subject: [PATCH 5/5] Sort extensions by name --- lib/linguist/languages.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 27b66c15..27764473 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -302,11 +302,12 @@ Delphi: DCPU-16 Assembly: type: programming lexer: dasm16 + primary_extension: .dasm16 + extensions: + - .dasm + - .dasm16 aliases: - dasm16 - extensions: - - .dasm16 - - .dasm Diff: extensions: