cmdstan 0.1.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +1 -0
- data/README.md +3 -1
- data/ext/cmdstan/extconf.rb +8 -4
- data/lib/cmdstan.rb +1 -0
- data/lib/cmdstan/mcmc.rb +1 -1
- data/lib/cmdstan/mle.rb +1 -0
- data/lib/cmdstan/model.rb +3 -3
- data/lib/cmdstan/utils.rb +35 -7
- data/lib/cmdstan/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0438de041affa64ca7db73cd65f35b67a80a389d76ed70d73a294f877db0071
|
4
|
+
data.tar.gz: 06da4d0a6ca5f5a84d05c442ef860efc2b0f0d619645139dede04a924564c5c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c6687ba6802f658b865f8f94a56d7f2bdc24abc5dc5606dc389b5fba2558648b1dc41b3b3762c4d38478caed95d47e35ba15a6434379af5d8f9eb5a1173f74
|
7
|
+
data.tar.gz: f52cc26a90504161e3f5df6848509a42341f0725e23936741447962f6777ea8706998870ee2d2b6e8c8efd50e08778678e45b9273ce4a7aabe848c54bbbd7ad2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## 0.1.5 (2020-11-21)
|
2
|
+
|
3
|
+
- Added `tbb` to path for Linux
|
4
|
+
|
5
|
+
## 0.1.4 (2020-11-01)
|
6
|
+
|
7
|
+
- Updated CmdStan to 2.25.0
|
8
|
+
|
9
|
+
## 0.1.3 (2020-05-29)
|
10
|
+
|
11
|
+
- Added `tempfile` dependency
|
12
|
+
- Use a single job for installation
|
13
|
+
|
14
|
+
## 0.1.2 (2020-04-10)
|
15
|
+
|
16
|
+
- Added `tbb` to path for Windows
|
17
|
+
|
18
|
+
## 0.1.1 (2020-04-09)
|
19
|
+
|
20
|
+
- Added support for Windows
|
21
|
+
|
1
22
|
## 0.1.0 (2020-04-08)
|
2
23
|
|
3
24
|
- First release
|
data/LICENSE.txt
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
|
+
[](https://github.com/ankane/cmdstan/actions)
|
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
@@ -3,10 +3,12 @@ require "fileutils"
|
|
3
3
|
require "net/http"
|
4
4
|
require "tmpdir"
|
5
5
|
|
6
|
-
version = "2.
|
7
|
-
checksum = "
|
6
|
+
version = "2.25.0"
|
7
|
+
checksum = "6bd90c6513d386f22007750f136c3f8db0132aa3e80c7298095516c68ab95a4a"
|
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"
|
data/lib/cmdstan.rb
CHANGED
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/mle.rb
CHANGED
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,42 @@ module CmdStan
|
|
3
3
|
private
|
4
4
|
|
5
5
|
def run_command(*args)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
env = {}
|
7
|
+
# add tbb to path
|
8
|
+
tbblib = ENV["STAN_TBB"] || File.join(CmdStan.path, "stan", "lib", "stan_math", "lib", "tbb")
|
9
|
+
if windows?
|
10
|
+
# uses ; for separator
|
11
|
+
raise "Invalid TBB path" if tbblib.include?(";")
|
12
|
+
env["PATH"] = "#{tbblib};#{ENV["PATH"]}"
|
13
|
+
elsif !mac?
|
14
|
+
# uses : for separator
|
15
|
+
raise "Invalid TBB path" if tbblib.include?(":")
|
16
|
+
env["LD_LIBRARY_PATH"] = "#{tbblib}:#{ENV["LD_LIBRARY_PATH"]}"
|
13
17
|
end
|
18
|
+
|
19
|
+
# use an open3 method since it does escaping (like system)
|
20
|
+
# use capture2e so we don't need to worry about deadlocks
|
21
|
+
output, status = Open3.capture2e(env, *args)
|
22
|
+
if status.exitstatus != 0
|
23
|
+
$stderr.puts output
|
24
|
+
raise Error, "Command failed"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_command
|
29
|
+
windows? ? "mingw32-make" : "make"
|
30
|
+
end
|
31
|
+
|
32
|
+
def extension
|
33
|
+
windows? ? ".exe" : ""
|
34
|
+
end
|
35
|
+
|
36
|
+
def mac?
|
37
|
+
RbConfig::CONFIG["host_os"] =~ /darwin/i
|
38
|
+
end
|
39
|
+
|
40
|
+
def windows?
|
41
|
+
Gem.win_platform?
|
14
42
|
end
|
15
43
|
end
|
16
44
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email: andrew@chartkick.com
|
57
57
|
executables: []
|
58
58
|
extensions:
|
@@ -74,7 +74,7 @@ homepage: https://github.com/ankane/cmdstan
|
|
74
74
|
licenses:
|
75
75
|
- BSD-3-Clause
|
76
76
|
metadata: {}
|
77
|
-
post_install_message:
|
77
|
+
post_install_message:
|
78
78
|
rdoc_options: []
|
79
79
|
require_paths:
|
80
80
|
- lib
|
@@ -89,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
rubygems_version: 3.1.
|
93
|
-
signing_key:
|
92
|
+
rubygems_version: 3.1.4
|
93
|
+
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Bayesian inference for Ruby, powered by CmdStan
|
96
96
|
test_files: []
|