cmdstan 0.1.5 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0438de041affa64ca7db73cd65f35b67a80a389d76ed70d73a294f877db0071
4
- data.tar.gz: 06da4d0a6ca5f5a84d05c442ef860efc2b0f0d619645139dede04a924564c5c6
3
+ metadata.gz: 86b23f06c13af5825711739c0fc3a66c141fabc38507fd6b4e3e067137422c38
4
+ data.tar.gz: 4921aae2623e273021f1a3f37f11bd16631902f0b6fb663b36a28d8412968abf
5
5
  SHA512:
6
- metadata.gz: 86c6687ba6802f658b865f8f94a56d7f2bdc24abc5dc5606dc389b5fba2558648b1dc41b3b3762c4d38478caed95d47e35ba15a6434379af5d8f9eb5a1173f74
7
- data.tar.gz: f52cc26a90504161e3f5df6848509a42341f0725e23936741447962f6777ea8706998870ee2d2b6e8c8efd50e08778678e45b9273ce4a7aabe848c54bbbd7ad2
6
+ metadata.gz: bfe6e78ce9194750c3ee8c89ac02eb9e1b5526c502f9e0908bd5a3c2f3296bb7650de0e0abc61381142a2888c3bb0dedac2d9c80db252084ccf51a7d7f91e41c
7
+ data.tar.gz: c6176782e0ffb1c9817ab4db949a0e208a143c87c2420ee1747de3149e3b590d6298b019052d5425dd8ec533f32acd190698dee8bb17fc291e96fd2770f0f1ed
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 0.1.9 (2022-02-07)
2
+
3
+ - Added support for Linux ARM
4
+ - Updated CmdStan to 2.28.2
5
+
6
+ ## 0.1.8 (2022-01-16)
7
+
8
+ - Updated CmdStan to 2.28.1
9
+
10
+ ## 0.1.7 (2021-08-23)
11
+
12
+ - Updated CmdStan to 2.27.0
13
+
14
+ ## 0.1.6 (2021-02-08)
15
+
16
+ - Updated CmdStan to 2.26.0
17
+
1
18
  ## 0.1.5 (2020-11-21)
2
19
 
3
20
  - Added `tbb` to path for Linux
data/LICENSE.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  BSD 3-Clause License
2
2
 
3
3
  Copyright (c) 2019, Stan Developers and their Assignees
4
- Copyright (c) 2020, Andrew Kane
4
+ Copyright (c) 2020-2022, Andrew Kane
5
5
  All rights reserved.
6
6
 
7
7
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  Bayesian inference for Ruby, powered by [CmdStan](https://github.com/stan-dev/cmdstan)
4
4
 
5
- [![Build Status](https://github.com/ankane/cmdstan/workflows/build/badge.svg?branch=master)](https://github.com/ankane/cmdstan/actions)
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
 
9
9
  Add this line to your application’s Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'cmdstan'
12
+ gem "cmdstan"
13
13
  ```
14
14
 
15
15
  Installation can take a few minutes as CmdStan downloads and builds.
@@ -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
@@ -3,13 +3,25 @@ require "fileutils"
3
3
  require "net/http"
4
4
  require "tmpdir"
5
5
 
6
- version = "2.25.0"
7
- checksum = "6bd90c6513d386f22007750f136c3f8db0132aa3e80c7298095516c68ab95a4a"
8
- url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}.tar.gz"
6
+ version = "2.28.2"
7
+ # TODO figure out Mac ARM
8
+ if RbConfig::CONFIG["host_os"] !~ /darwin/i && RbConfig::CONFIG["host_cpu"] =~ /arm|aarch64/i
9
+ checksum = "cd8f588a1267e3e36761b7bcdff1b7f36bf43b8ec119667654995bfa5f921fa4"
10
+ url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}-linux-arm64.tar.gz"
11
+ else
12
+ checksum = "4e6ed2685460d7f33ddbc81ccb1e59befa7efd91e46d5b040027aab8daec4526"
13
+ url = "https://github.com/stan-dev/cmdstan/releases/download/v#{version}/cmdstan-#{version}.tar.gz"
14
+ end
15
+
16
+ path = ENV["CMDSTAN"] || File.expand_path("../../tmp/cmdstan", __dir__)
17
+ FileUtils.mkdir_p(path)
18
+ raise "Directory not empty. Run: rake clean" unless Dir.empty?(path)
9
19
 
10
20
  $stdout.sync = true
11
21
 
12
- def download_file(url, download_path, checksum)
22
+ def download_file(url, download_path, checksum, redirects = 0)
23
+ raise "Too many redirects" if redirects > 10
24
+
13
25
  uri = URI(url)
14
26
  location = nil
15
27
 
@@ -35,7 +47,7 @@ def download_file(url, download_path, checksum)
35
47
  end
36
48
  puts # newline
37
49
 
38
- abort "Bad checksum" if digest.hexdigest != checksum
50
+ abort "Bad checksum: #{digest.hexdigest}" if digest.hexdigest != checksum
39
51
  else
40
52
  abort "Bad response"
41
53
  end
@@ -43,7 +55,7 @@ def download_file(url, download_path, checksum)
43
55
  end
44
56
 
45
57
  # outside of Net::HTTP block to close previous connection
46
- download_file(location, download_path, checksum) if location
58
+ download_file(location, download_path, checksum, redirects + 1) if location
47
59
  end
48
60
 
49
61
  # download
@@ -52,8 +64,6 @@ download_path = "#{Dir.tmpdir}/cmdstan-#{version}.tar.gz"
52
64
  download_file(url, download_path, checksum)
53
65
 
54
66
  # extract
55
- path = ENV["CMDSTAN"] || File.expand_path("../../tmp/cmdstan", __dir__)
56
- FileUtils.mkdir_p(path)
57
67
  Dir.chdir(path)
58
68
  # TODO use Gem::Package::TarReader from Rubygems
59
69
  tar_args = Gem.win_platform? ? ["--force-local"] : []
@@ -61,4 +71,5 @@ system "tar", "zxf", download_path, "-C", path, "--strip-components=1", *tar_arg
61
71
 
62
72
  # build
63
73
  make_command = Gem.win_platform? ? "mingw32-make" : "make"
64
- system make_command, "build"
74
+ success = system(make_command, "build")
75
+ raise "Build failed" unless success
data/lib/cmdstan/mcmc.rb CHANGED
@@ -25,11 +25,12 @@ module CmdStan
25
25
  end
26
26
 
27
27
  def summary
28
- csv_file = Tempfile.new
29
- run_command "#{CmdStan.path}/bin/stansummary#{extension}", "--csv_file=#{csv_file.path}", *@output_files.map(&:path)
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(csv_file.path, headers: true, converters: :numeric) do |row|
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 *args
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 *args
102
+ run_command(*args)
103
103
 
104
104
  MLE.new(output_file)
105
105
  end
@@ -1,3 +1,3 @@
1
1
  module CmdStan
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.9"
3
3
  end
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.5
4
+ version: 0.1.9
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-11-21 00:00:00.000000000 Z
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-02-07 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description:
56
- email: andrew@chartkick.com
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.1.4
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