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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f7dfd62b5effc22b11650772a01893fb816bba2f7565cadbcf8c1b74e3addfb
4
- data.tar.gz: 17bdf86aff8dcff9bef87b7c48026bcf777371f6334c9785bc64b2c861f4396b
3
+ metadata.gz: 3b919404c064aa08c6766d3718c168f70ef422e32d66eebf6de84b901e244d2c
4
+ data.tar.gz: 70f11779bdb74a2d0ba2a95ba6ba37c05cd5e637422667474765f3bdbfca2efe
5
5
  SHA512:
6
- metadata.gz: 78bb7822a7e02d83b1141a67c9432ceaf1f08bd3a2aa0dbd81dd0edca8a105304c546b30b75fb9efd39fcf807ff088346ea748179125852d888c5e2142b6a5fa
7
- data.tar.gz: c1be456cc760a8785472386a7bdaabf8aade3ff6d5a6d06b2b60fcf74b9d38a08e96dad84e06d0f882edaf02a403ba27074530610eded5359774e670a43c49b3
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
@@ -1,6 +1,7 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2020, Andrew Kane
3
+ Copyright (c) 2019, Stan Developers and their Assignees
4
+ Copyright (c) 2020-2021, Andrew Kane
4
5
  All rights reserved.
5
6
 
6
7
  Redistribution and use in source and binary forms, with or without
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://travis-ci.org/ankane/cmdstan.svg?branch=master)](https://travis-ci.org/ankane/cmdstan) [![Build status](https://ci.appveyor.com/api/projects/status/n9sp7b34m6du5ltw/branch/master?svg=true)](https://ci.appveyor.com/project/ankane/cmdstan/branch/master)
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
 
@@ -3,8 +3,8 @@ require "fileutils"
3
3
  require "net/http"
4
4
  require "tmpdir"
5
5
 
6
- version = "2.22.1"
7
- checksum = "d12e46bda4bd3db9e8abe0554712b56e41f8e7843900338446d9a3b1acc2d0ce"
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", "-j"
64
+ system make_command, "build"
data/lib/cmdstan.rb CHANGED
@@ -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"
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/mle.rb CHANGED
@@ -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
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
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
@@ -1,3 +1,3 @@
1
1
  module CmdStan
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
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.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: 2020-04-10 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'
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.1.2
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: []