cmdstan 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +2 -1
- data/README.md +1 -1
- data/ext/cmdstan/extconf.rb +3 -3
- data/lib/cmdstan.rb +1 -0
- data/lib/cmdstan/mcmc.rb +4 -3
- data/lib/cmdstan/mle.rb +1 -0
- data/lib/cmdstan/model.rb +2 -2
- data/lib/cmdstan/utils.rb +18 -1
- data/lib/cmdstan/version.rb +1 -1
- metadata +9 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b919404c064aa08c6766d3718c168f70ef422e32d66eebf6de84b901e244d2c
|
4
|
+
data.tar.gz: 70f11779bdb74a2d0ba2a95ba6ba37c05cd5e637422667474765f3bdbfca2efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1238805b583a22b5aef689a70ce0eba43a270e9a090ce531038ac8e93a2d386f202ff800ef80247cb118edf37ef06fe5a9230c9589070a8b6f5e463c6a19363d
|
7
|
+
data.tar.gz: 7e7c0cdf1b481a400844605eded2822d644eb441f85875bd65d9b91d856150dd40d9a83671d19d2693c28dbae4c17a4af3b07a336a133909c30f7fa9802b2b90
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## 0.1.6 (2021-02-08)
|
2
|
+
|
3
|
+
- Updated CmdStan to 2.26.0
|
4
|
+
|
5
|
+
## 0.1.5 (2020-11-21)
|
6
|
+
|
7
|
+
- Added `tbb` to path for Linux
|
8
|
+
|
9
|
+
## 0.1.4 (2020-11-01)
|
10
|
+
|
11
|
+
- Updated CmdStan to 2.25.0
|
12
|
+
|
13
|
+
## 0.1.3 (2020-05-29)
|
14
|
+
|
15
|
+
- Added `tempfile` dependency
|
16
|
+
- Use a single job for installation
|
17
|
+
|
18
|
+
## 0.1.2 (2020-04-10)
|
19
|
+
|
20
|
+
- Added `tbb` to path for Windows
|
21
|
+
|
1
22
|
## 0.1.1 (2020-04-09)
|
2
23
|
|
3
24
|
- Added support for Windows
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Bayesian inference for Ruby, powered by [CmdStan](https://github.com/stan-dev/cmdstan)
|
4
4
|
|
5
|
-
[![Build Status](https://
|
5
|
+
[![Build Status](https://github.com/ankane/cmdstan/workflows/build/badge.svg?branch=master)](https://github.com/ankane/cmdstan/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
data/ext/cmdstan/extconf.rb
CHANGED
@@ -3,8 +3,8 @@ require "fileutils"
|
|
3
3
|
require "net/http"
|
4
4
|
require "tmpdir"
|
5
5
|
|
6
|
-
version = "2.
|
7
|
-
checksum = "
|
6
|
+
version = "2.26.0"
|
7
|
+
checksum = "0bc5529a4818e70ef8181191a515ea5e1a6fce326dda41a040f99deb89bcb663"
|
8
8
|
url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}.tar.gz"
|
9
9
|
|
10
10
|
$stdout.sync = true
|
@@ -61,4 +61,4 @@ system "tar", "zxf", download_path, "-C", path, "--strip-components=1", *tar_arg
|
|
61
61
|
|
62
62
|
# build
|
63
63
|
make_command = Gem.win_platform? ? "mingw32-make" : "make"
|
64
|
-
system make_command, "build"
|
64
|
+
system make_command, "build"
|
data/lib/cmdstan.rb
CHANGED
data/lib/cmdstan/mcmc.rb
CHANGED
@@ -25,11 +25,12 @@ module CmdStan
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def summary
|
28
|
-
|
29
|
-
|
28
|
+
# add suffix since path can't already exist
|
29
|
+
path = "#{Tempfile.new.path}.csv"
|
30
|
+
run_command "#{CmdStan.path}/bin/stansummary#{extension}", "--csv_filename=#{path}", *@output_files.map(&:path)
|
30
31
|
|
31
32
|
result = {}
|
32
|
-
CSV.foreach(
|
33
|
+
CSV.foreach(path, headers: true, converters: :numeric) do |row|
|
33
34
|
value = row.to_h
|
34
35
|
name = value.delete("name")
|
35
36
|
result[name] = value if name == "lp__" || !name.end_with?("__")
|
data/lib/cmdstan/mle.rb
CHANGED
data/lib/cmdstan/model.rb
CHANGED
@@ -61,7 +61,7 @@ module CmdStan
|
|
61
61
|
args << "num_samples=#{sampling_iters.to_i}" if sampling_iters
|
62
62
|
args += ["algorithm=hmc", "adapt", "engaged=1"]
|
63
63
|
|
64
|
-
run_command
|
64
|
+
run_command(*args)
|
65
65
|
|
66
66
|
output_files << output_file
|
67
67
|
end
|
@@ -99,7 +99,7 @@ module CmdStan
|
|
99
99
|
args << "algorithm=#{algorithm.to_s.downcase}" if algorithm
|
100
100
|
args << "iter=#{iter.to_i}" if iter
|
101
101
|
|
102
|
-
run_command
|
102
|
+
run_command(*args)
|
103
103
|
|
104
104
|
MLE.new(output_file)
|
105
105
|
end
|
data/lib/cmdstan/utils.rb
CHANGED
@@ -3,9 +3,22 @@ module CmdStan
|
|
3
3
|
private
|
4
4
|
|
5
5
|
def run_command(*args)
|
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"]}"
|
17
|
+
end
|
18
|
+
|
6
19
|
# use an open3 method since it does escaping (like system)
|
7
20
|
# use capture2e so we don't need to worry about deadlocks
|
8
|
-
output, status = Open3.capture2e(*args)
|
21
|
+
output, status = Open3.capture2e(env, *args)
|
9
22
|
if status.exitstatus != 0
|
10
23
|
$stderr.puts output
|
11
24
|
raise Error, "Command failed"
|
@@ -20,6 +33,10 @@ module CmdStan
|
|
20
33
|
windows? ? ".exe" : ""
|
21
34
|
end
|
22
35
|
|
36
|
+
def mac?
|
37
|
+
RbConfig::CONFIG["host_os"] =~ /darwin/i
|
38
|
+
end
|
39
|
+
|
23
40
|
def windows?
|
24
41
|
Gem.win_platform?
|
25
42
|
end
|
data/lib/cmdstan/version.rb
CHANGED
metadata
CHANGED
@@ -1,59 +1,17 @@
|
|
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.6
|
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:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5'
|
55
|
-
description:
|
56
|
-
email: andrew@chartkick.com
|
11
|
+
date: 2021-02-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: andrew@ankane.org
|
57
15
|
executables: []
|
58
16
|
extensions:
|
59
17
|
- ext/cmdstan/extconf.rb
|
@@ -74,7 +32,7 @@ homepage: https://github.com/ankane/cmdstan
|
|
74
32
|
licenses:
|
75
33
|
- BSD-3-Clause
|
76
34
|
metadata: {}
|
77
|
-
post_install_message:
|
35
|
+
post_install_message:
|
78
36
|
rdoc_options: []
|
79
37
|
require_paths:
|
80
38
|
- lib
|
@@ -89,8 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
47
|
- !ruby/object:Gem::Version
|
90
48
|
version: '0'
|
91
49
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
-
signing_key:
|
50
|
+
rubygems_version: 3.2.3
|
51
|
+
signing_key:
|
94
52
|
specification_version: 4
|
95
53
|
summary: Bayesian inference for Ruby, powered by CmdStan
|
96
54
|
test_files: []
|