cmdstan 0.1.4 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/LICENSE.txt +1 -1
- data/README.md +6 -6
- data/ext/cmdstan/extconf.rb +11 -7
- data/lib/cmdstan/mcmc.rb +4 -3
- data/lib/cmdstan/model.rb +2 -2
- data/lib/cmdstan/utils.rb +12 -2
- data/lib/cmdstan/version.rb +1 -1
- metadata +6 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30d42170e4611dc73b1c63623f02bed13c370ee3fa17545cc963714e76a81934
|
4
|
+
data.tar.gz: 8a3de92029db9d781846d8c78d1fe6731d9a2834fdea266889338bff8e138824
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd7fa71f754207f5638977b63c66b19386c7b9fe60a708b3edb5da015c87af89abdd6f3a92e9b342a4dff3ec4cfa9a0754718260240140404adcb4905aa0b4c7
|
7
|
+
data.tar.gz: 74b337113fcc1a34461b3086e62659b45719e8070b041bedc6f8ca442037be18a152bdedfaaaa747ca67ffca6e0ae2444a79d265e9a32807e0b6b5b8e5e41cd2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 0.1.8 (2022-01-16)
|
2
|
+
|
3
|
+
- Updated CmdStan to 2.28.1
|
4
|
+
|
5
|
+
## 0.1.7 (2021-08-23)
|
6
|
+
|
7
|
+
- Updated CmdStan to 2.27.0
|
8
|
+
|
9
|
+
## 0.1.6 (2021-02-08)
|
10
|
+
|
11
|
+
- Updated CmdStan to 2.26.0
|
12
|
+
|
13
|
+
## 0.1.5 (2020-11-21)
|
14
|
+
|
15
|
+
- Added `tbb` to path for Linux
|
16
|
+
|
1
17
|
## 0.1.4 (2020-11-01)
|
2
18
|
|
3
19
|
- Updated CmdStan to 2.25.0
|
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-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/cmdstan-ruby/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -64,22 +64,22 @@ This library is modeled after the [CmdStanPy API](https://github.com/stan-dev/cm
|
|
64
64
|
|
65
65
|
## History
|
66
66
|
|
67
|
-
View the [changelog](https://github.com/ankane/cmdstan/blob/master/CHANGELOG.md)
|
67
|
+
View the [changelog](https://github.com/ankane/cmdstan-ruby/blob/master/CHANGELOG.md)
|
68
68
|
|
69
69
|
## Contributing
|
70
70
|
|
71
71
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
72
72
|
|
73
|
-
- [Report bugs](https://github.com/ankane/cmdstan/issues)
|
74
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/cmdstan/pulls)
|
73
|
+
- [Report bugs](https://github.com/ankane/cmdstan-ruby/issues)
|
74
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/cmdstan-ruby/pulls)
|
75
75
|
- Write, clarify, or fix documentation
|
76
76
|
- Suggest or add new features
|
77
77
|
|
78
78
|
To get started with development:
|
79
79
|
|
80
80
|
```sh
|
81
|
-
git clone https://github.com/ankane/cmdstan.git
|
82
|
-
cd cmdstan
|
81
|
+
git clone https://github.com/ankane/cmdstan-ruby.git
|
82
|
+
cd cmdstan-ruby
|
83
83
|
bundle install
|
84
84
|
bundle exec ruby ext/cmdstan/extconf.rb
|
85
85
|
bundle exec rake test
|
data/ext/cmdstan/extconf.rb
CHANGED
@@ -3,13 +3,19 @@ require "fileutils"
|
|
3
3
|
require "net/http"
|
4
4
|
require "tmpdir"
|
5
5
|
|
6
|
-
version = "2.
|
7
|
-
checksum = "
|
6
|
+
version = "2.28.1"
|
7
|
+
checksum = "eacadb4a1ca6997c9858e301780e729e53a9b5207b19ae2616abc882677e7637"
|
8
8
|
url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}.tar.gz"
|
9
9
|
|
10
|
+
path = ENV["CMDSTAN"] || File.expand_path("../../tmp/cmdstan", __dir__)
|
11
|
+
FileUtils.mkdir_p(path)
|
12
|
+
raise "Directory not empty. Run: rake clean" unless Dir.empty?(path)
|
13
|
+
|
10
14
|
$stdout.sync = true
|
11
15
|
|
12
|
-
def download_file(url, download_path, checksum)
|
16
|
+
def download_file(url, download_path, checksum, redirects = 0)
|
17
|
+
raise "Too many redirects" if redirects > 10
|
18
|
+
|
13
19
|
uri = URI(url)
|
14
20
|
location = nil
|
15
21
|
|
@@ -35,7 +41,7 @@ def download_file(url, download_path, checksum)
|
|
35
41
|
end
|
36
42
|
puts # newline
|
37
43
|
|
38
|
-
abort "Bad checksum" if digest.hexdigest != checksum
|
44
|
+
abort "Bad checksum: #{digest.hexdigest}" if digest.hexdigest != checksum
|
39
45
|
else
|
40
46
|
abort "Bad response"
|
41
47
|
end
|
@@ -43,7 +49,7 @@ def download_file(url, download_path, checksum)
|
|
43
49
|
end
|
44
50
|
|
45
51
|
# outside of Net::HTTP block to close previous connection
|
46
|
-
download_file(location, download_path, checksum) if location
|
52
|
+
download_file(location, download_path, checksum, redirects + 1) if location
|
47
53
|
end
|
48
54
|
|
49
55
|
# download
|
@@ -52,8 +58,6 @@ download_path = "#{Dir.tmpdir}/cmdstan-#{version}.tar.gz"
|
|
52
58
|
download_file(url, download_path, checksum)
|
53
59
|
|
54
60
|
# extract
|
55
|
-
path = ENV["CMDSTAN"] || File.expand_path("../../tmp/cmdstan", __dir__)
|
56
|
-
FileUtils.mkdir_p(path)
|
57
61
|
Dir.chdir(path)
|
58
62
|
# TODO use Gem::Package::TarReader from Rubygems
|
59
63
|
tar_args = Gem.win_platform? ? ["--force-local"] : []
|
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/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
@@ -4,10 +4,16 @@ module CmdStan
|
|
4
4
|
|
5
5
|
def run_command(*args)
|
6
6
|
env = {}
|
7
|
+
# add tbb to path
|
8
|
+
tbblib = ENV["STAN_TBB"] || File.join(CmdStan.path, "stan", "lib", "stan_math", "lib", "tbb")
|
7
9
|
if windows?
|
8
|
-
#
|
9
|
-
|
10
|
+
# uses ; for separator
|
11
|
+
raise "Invalid TBB path" if tbblib.include?(";")
|
10
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"]}"
|
11
17
|
end
|
12
18
|
|
13
19
|
# use an open3 method since it does escaping (like system)
|
@@ -27,6 +33,10 @@ module CmdStan
|
|
27
33
|
windows? ? ".exe" : ""
|
28
34
|
end
|
29
35
|
|
36
|
+
def mac?
|
37
|
+
RbConfig::CONFIG["host_os"] =~ /darwin/i
|
38
|
+
end
|
39
|
+
|
30
40
|
def windows?
|
31
41
|
Gem.win_platform?
|
32
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
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'
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description:
|
56
|
-
email: andrew@
|
14
|
+
email: andrew@ankane.org
|
57
15
|
executables: []
|
58
16
|
extensions:
|
59
17
|
- ext/cmdstan/extconf.rb
|
@@ -70,7 +28,7 @@ files:
|
|
70
28
|
- lib/cmdstan/model.rb
|
71
29
|
- lib/cmdstan/utils.rb
|
72
30
|
- lib/cmdstan/version.rb
|
73
|
-
homepage: https://github.com/ankane/cmdstan
|
31
|
+
homepage: https://github.com/ankane/cmdstan-ruby
|
74
32
|
licenses:
|
75
33
|
- BSD-3-Clause
|
76
34
|
metadata: {}
|
@@ -89,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
47
|
- !ruby/object:Gem::Version
|
90
48
|
version: '0'
|
91
49
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
50
|
+
rubygems_version: 3.3.3
|
93
51
|
signing_key:
|
94
52
|
specification_version: 4
|
95
53
|
summary: Bayesian inference for Ruby, powered by CmdStan
|