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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f52650c597cfa86c4e1bd0f095a2b321e906285df981f9f345bde5054fb8cc80
4
- data.tar.gz: 3c98b6ff5c800ad9ecd28e325ed6f97d576306567a4ac8530bb117f948c6c321
3
+ metadata.gz: f0438de041affa64ca7db73cd65f35b67a80a389d76ed70d73a294f877db0071
4
+ data.tar.gz: 06da4d0a6ca5f5a84d05c442ef860efc2b0f0d619645139dede04a924564c5c6
5
5
  SHA512:
6
- metadata.gz: ddab8b6b73175afcbee65f5653deee681b746fe2083015ec06b65866bc467ca2bb7ec6cc475a65bc83976ff4f13e8911ac08d999703c52e96d529f8b68408554
7
- data.tar.gz: c8316343f62159e1963f7835bb231114275b15ab7fd982f3ae58f50c7168aad08e6448c6c2fd6110910f061595f586f3882a7a38a9e377c332b8b5a381bc4acb
6
+ metadata.gz: 86c6687ba6802f658b865f8f94a56d7f2bdc24abc5dc5606dc389b5fba2558648b1dc41b3b3762c4d38478caed95d47e35ba15a6434379af5d8f9eb5a1173f74
7
+ data.tar.gz: f52cc26a90504161e3f5df6848509a42341f0725e23936741447962f6777ea8706998870ee2d2b6e8c8efd50e08778678e45b9273ce4a7aabe848c54bbbd7ad2
@@ -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
@@ -1,5 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
+ Copyright (c) 2019, Stan Developers and their Assignees
3
4
  Copyright (c) 2020, Andrew Kane
4
5
  All rights reserved.
5
6
 
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://github.com/ankane/cmdstan/workflows/build/badge.svg?branch=master)](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
  ```
@@ -3,10 +3,12 @@ require "fileutils"
3
3
  require "net/http"
4
4
  require "tmpdir"
5
5
 
6
- version = "2.22.1"
7
- checksum = "d12e46bda4bd3db9e8abe0554712b56e41f8e7843900338446d9a3b1acc2d0ce"
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
- system "tar", "zxvf", download_path, "-C", path, "--strip-components=1"
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
- system "make", "build", "-j"
63
+ make_command = Gem.win_platform? ? "mingw32-make" : "make"
64
+ system make_command, "build"
@@ -2,6 +2,7 @@
2
2
  require "csv"
3
3
  require "json"
4
4
  require "open3"
5
+ require "tempfile"
5
6
 
6
7
  # modules
7
8
  require "cmdstan/utils"
@@ -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|
@@ -12,6 +12,7 @@ module CmdStan
12
12
  CSV.foreach(@output_file.path, skip_lines: /^#/, headers: true, converters: :numeric) do |row|
13
13
  return row.to_h
14
14
  end
15
+ raise "Bug detected"
15
16
  end
16
17
 
17
18
  def column_names
@@ -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 "make", @exe_file
22
+ run_command make_command, @exe_file
23
23
  end
24
24
  end
25
25
 
@@ -3,14 +3,42 @@ module CmdStan
3
3
  private
4
4
 
5
5
  def run_command(*args)
6
- # use popen3 since it does escaping (like system)
7
- Open3.popen3(*args) do |i, o, e, t|
8
- if t.value.exitstatus != 0
9
- $stderr.puts o.read
10
- $stderr.puts e.read
11
- raise Error, "Command failed"
12
- end
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
@@ -1,3 +1,3 @@
1
1
  module CmdStan
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
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.0
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-04-09 00:00:00.000000000 Z
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.2
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: []