cmdstan 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -1
- data/ext/cmdstan/extconf.rb +6 -2
- data/lib/cmdstan/mcmc.rb +1 -1
- data/lib/cmdstan/model.rb +3 -3
- data/lib/cmdstan/utils.rb +18 -7
- data/lib/cmdstan/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f7dfd62b5effc22b11650772a01893fb816bba2f7565cadbcf8c1b74e3addfb
|
4
|
+
data.tar.gz: 17bdf86aff8dcff9bef87b7c48026bcf777371f6334c9785bc64b2c861f4396b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78bb7822a7e02d83b1141a67c9432ceaf1f08bd3a2aa0dbd81dd0edca8a105304c546b30b75fb9efd39fcf807ff088346ea748179125852d888c5e2142b6a5fa
|
7
|
+
data.tar.gz: c1be456cc760a8785472386a7bdaabf8aade3ff6d5a6d06b2b60fcf74b9d38a08e96dad84e06d0f882edaf02a403ba27074530610eded5359774e670a43c49b3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Bayesian inference for Ruby, powered by [CmdStan](https://github.com/stan-dev/cmdstan)
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/ankane/cmdstan.svg?branch=master)](https://travis-ci.org/ankane/cmdstan) [![Build status](https://ci.appveyor.com/api/projects/status/n9sp7b34m6du5ltw/branch/master?svg=true)](https://ci.appveyor.com/project/ankane/cmdstan/branch/master)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application’s Gemfile:
|
@@ -79,6 +81,6 @@ To get started with development:
|
|
79
81
|
git clone https://github.com/ankane/cmdstan.git
|
80
82
|
cd cmdstan
|
81
83
|
bundle install
|
82
|
-
ruby ext/cmdstan/extconf.rb
|
84
|
+
bundle exec ruby ext/cmdstan/extconf.rb
|
83
85
|
bundle exec rake test
|
84
86
|
```
|
data/ext/cmdstan/extconf.rb
CHANGED
@@ -7,6 +7,8 @@ version = "2.22.1"
|
|
7
7
|
checksum = "d12e46bda4bd3db9e8abe0554712b56e41f8e7843900338446d9a3b1acc2d0ce"
|
8
8
|
url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}.tar.gz"
|
9
9
|
|
10
|
+
$stdout.sync = true
|
11
|
+
|
10
12
|
def download_file(url, download_path, checksum)
|
11
13
|
uri = URI(url)
|
12
14
|
location = nil
|
@@ -54,7 +56,9 @@ path = ENV["CMDSTAN"] || File.expand_path("../../tmp/cmdstan", __dir__)
|
|
54
56
|
FileUtils.mkdir_p(path)
|
55
57
|
Dir.chdir(path)
|
56
58
|
# TODO use Gem::Package::TarReader from Rubygems
|
57
|
-
|
59
|
+
tar_args = Gem.win_platform? ? ["--force-local"] : []
|
60
|
+
system "tar", "zxf", download_path, "-C", path, "--strip-components=1", *tar_args
|
58
61
|
|
59
62
|
# build
|
60
|
-
|
63
|
+
make_command = Gem.win_platform? ? "mingw32-make" : "make"
|
64
|
+
system make_command, "build", "-j"
|
data/lib/cmdstan/mcmc.rb
CHANGED
@@ -26,7 +26,7 @@ module CmdStan
|
|
26
26
|
|
27
27
|
def summary
|
28
28
|
csv_file = Tempfile.new
|
29
|
-
run_command "#{CmdStan.path}/bin/stansummary", "--csv_file=#{csv_file.path}", *@output_files.map(&:path)
|
29
|
+
run_command "#{CmdStan.path}/bin/stansummary#{extension}", "--csv_file=#{csv_file.path}", *@output_files.map(&:path)
|
30
30
|
|
31
31
|
result = {}
|
32
32
|
CSV.foreach(csv_file.path, headers: true, converters: :numeric) do |row|
|
data/lib/cmdstan/model.rb
CHANGED
@@ -9,8 +9,8 @@ module CmdStan
|
|
9
9
|
stan_file = File.expand_path(stan_file) if stan_file
|
10
10
|
|
11
11
|
@stan_file = stan_file
|
12
|
-
@exe_file = exe_file || stan_file.sub(/.stan\z/,
|
13
|
-
@name = File.basename(@exe_file)
|
12
|
+
@exe_file = exe_file || stan_file.sub(/.stan\z/, extension)
|
13
|
+
@name = File.basename(@exe_file, extension)
|
14
14
|
|
15
15
|
if compile && !exe_file
|
16
16
|
self.compile
|
@@ -19,7 +19,7 @@ module CmdStan
|
|
19
19
|
|
20
20
|
def compile
|
21
21
|
Dir.chdir(CmdStan.path) do
|
22
|
-
run_command
|
22
|
+
run_command make_command, @exe_file
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/lib/cmdstan/utils.rb
CHANGED
@@ -3,14 +3,25 @@ module CmdStan
|
|
3
3
|
private
|
4
4
|
|
5
5
|
def run_command(*args)
|
6
|
-
# use
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
6
|
+
# use an open3 method since it does escaping (like system)
|
7
|
+
# use capture2e so we don't need to worry about deadlocks
|
8
|
+
output, status = Open3.capture2e(*args)
|
9
|
+
if status.exitstatus != 0
|
10
|
+
$stderr.puts output
|
11
|
+
raise Error, "Command failed"
|
13
12
|
end
|
14
13
|
end
|
14
|
+
|
15
|
+
def make_command
|
16
|
+
windows? ? "mingw32-make" : "make"
|
17
|
+
end
|
18
|
+
|
19
|
+
def extension
|
20
|
+
windows? ? ".exe" : ""
|
21
|
+
end
|
22
|
+
|
23
|
+
def windows?
|
24
|
+
Gem.win_platform?
|
25
|
+
end
|
15
26
|
end
|
16
27
|
end
|
data/lib/cmdstan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmdstan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|