Skip to content

Commit

Permalink
Remove some forwarded Python functons (#268)
Browse files Browse the repository at this point in the history
* Remove extract and concat

* Document cat

* Remove make_ufunc and wrap_xarray_ufunc

* Remove from_cmdstan

* Remove from_cmdstan tests

* Increment version number

* Remove autocov and autocorr

* Update example to use `cat`

* Remove from_json

* Improve diagnostics docs

* Fix cat example

* Make sure diagnostics are documented on v1.9
  • Loading branch information
sethaxen authored Mar 3, 2023
1 parent 5e0434b commit 0a5db5b
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 224 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:

env:
PYTHON: "Conda" # use Julia's packaged Conda build for installing packages
CMDSTAN_VERSION: "2.31.0"
CMDSTAN_PATH: "${{ GITHUB.WORKSPACE }}/.cmdstan/"

jobs:
test:
Expand Down Expand Up @@ -41,23 +39,11 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Cache CmdStan
id: cache-cmdstan
uses: actions/cache@v2
with:
path: ${{ env.CMDSTAN_PATH }}
key: cmdstan-${{ env.CMDSTAN_VERSION }}-${{ runner.os }}
- name: Install wget for windows
if: matrix.os == 'windows-latest'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install wget
- name: Download and build CmdStan
if: steps.cache-cmdstan.outputs.cache-hit != 'true'
run: |
wget -P ${{ env.CMDSTAN_PATH }} https://github.com/stan-dev/cmdstan/releases/download/v${{ env.CMDSTAN_VERSION }}/cmdstan-${{ env.CMDSTAN_VERSION }}.tar.gz
tar -xzpf ${{ env.CMDSTAN_PATH }}/cmdstan-${{ env.CMDSTAN_VERSION }}.tar.gz -C ${{ env.CMDSTAN_PATH }}
make -C ${{ env.CMDSTAN_PATH }}/cmdstan-${{ env.CMDSTAN_VERSION }}/ build
- uses: julia-actions/julia-buildpkg@latest
- name: Install ArviZ dependencies
run: |
Expand All @@ -68,8 +54,6 @@ jobs:
ArviZ.initialize_pandas()
shell: julia --color=yes --project {0}
- uses: julia-actions/julia-runtest@latest
env:
JULIA_CMDSTAN_HOME: ${{ env.CMDSTAN_PATH }}/cmdstan-${{ env.CMDSTAN_VERSION }}/ # required by CmdStan.jl
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/futures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:

env:
PYTHON: "Conda" # use Julia's packaged Conda build for installing packages
CMDSTAN_VERSION: "2.25.0"
CMDSTAN_PATH: "${{ GITHUB.WORKSPACE }}/.cmdstan/"

jobs:
test:
Expand Down Expand Up @@ -43,19 +41,6 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Cache CmdStan
id: cache-cmdstan
uses: actions/cache@v2
with:
path: ${{ env.CMDSTAN_PATH }}
key: cmdstan-${{ env.CMDSTAN_VERSION }}-${{ runner.os }}
- name: Download and build CmdStan
if: steps.cache-cmdstan.outputs.cache-hit != 'true'
run: |
wget -P ${{ env.CMDSTAN_PATH }} https://github.com/stan-dev/cmdstan/releases/download/v${{ env.CMDSTAN_VERSION }}/cmdstan-${{ env.CMDSTAN_VERSION }}.tar.gz
tar -xzpf ${{ env.CMDSTAN_PATH }}/cmdstan-${{ env.CMDSTAN_VERSION }}.tar.gz -C ${{ env.CMDSTAN_PATH }}
make -C ${{ env.CMDSTAN_PATH }}/cmdstan-${{ env.CMDSTAN_VERSION }}/ build
shell: bash
- uses: julia-actions/julia-buildpkg@latest
if: matrix.arviz_version != 'main' || github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
- name: "Install arviz#main"
Expand All @@ -79,5 +64,3 @@ jobs:
ArviZ.initialize_pandas()
shell: julia --color=yes --project {0}
- uses: julia-actions/julia-runtest@latest
env:
JULIA_CMDSTAN_HOME: ${{ env.CMDSTAN_PATH }}/cmdstan-${{ env.CMDSTAN_VERSION }}/ # required by CmdStan.jl
27 changes: 18 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,24 @@ doctestfilters = [
r"\s+\"created_at\" => .*", # ignore timestamps in doctests
]

modules = [
ArviZ,
ArviZExampleData,
InferenceObjects,
InferenceObjectsNetCDF,
MCMCDiagnosticTools,
PSIS,
]
if isdefined(Base, :get_extension)
# using Requires, these docstrings are automatically loaded, but as an extension we need
# to manually specify the module
push!(
modules, Base.get_extension(InferenceObjects, :InferenceObjectsMCMCDiagnosticToolsExt)
)
end

makedocs(;
modules=[
ArviZ,
ArviZExampleData,
InferenceObjects,
InferenceObjectsNetCDF,
MCMCDiagnosticTools,
PSIS,
],
modules,
sitename="ArviZ.jl",
pages=[
"Home" => "index.md",
Expand All @@ -71,7 +80,7 @@ makedocs(;
sidebar_sitename=false,
canonical="stable",
),
doctestfilters=doctestfilters,
doctestfilters,
linkcheck=true,
analytics="G-W1G68W77YV",
)
Expand Down
9 changes: 0 additions & 9 deletions docs/src/api/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,17 @@ Pages = ["data.md"]
## Inference library converters

```@docs
from_cmdstan
from_mcmcchains
from_samplechains
```

## IO / Conversion

```@docs
from_json
from_netcdf
to_netcdf
```

## General functions

```@docs
concat
extract
```

## Example data

```@docs
Expand Down
23 changes: 19 additions & 4 deletions docs/src/api/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
Pages = ["diagnostics.md"]
```

## Reference
## [Bayesian fraction of missing information](@id bfmi)

```@docs
MCMCDiagnosticTools.bfmi
```

## [Effective sample size and $\widehat{R}$ diagnostic](@id ess_rhat)

```@docs
MCMCDiagnosticTools.ess
MCMCDiagnosticTools.ess_rhat
MCMCDiagnosticTools.mcse
MCMCDiagnosticTools.rhat
MCMCDiagnosticTools.rstar
MCMCDiagnosticTools.ess_rhat
```

The following autocovariance methods are supported:
Expand All @@ -22,3 +25,15 @@ MCMCDiagnosticTools.AutocovMethod
MCMCDiagnosticTools.FFTAutocovMethod
MCMCDiagnosticTools.BDAAutocovMethod
```

## [Monte Carlo standard error](@id mcse)

```@docs
MCMCDiagnosticTools.mcse
```

## [$R^*$ diagnostic](@id rstar)

```@docs
MCMCDiagnosticTools.rstar
```
6 changes: 3 additions & 3 deletions docs/src/working_with_inference_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ school_bis_idx = ["Deerfield", "Choate", "Lawrenceville"]
theta_school_diff[school=At(school_idx), school_bis=At(school_bis_idx)]
```

## Add new chains using `concat`
## Add new chains using `cat`

Suppose after checking the `mcse` and realizing you need more samples, you rerun the model with two chains and obtain an `idata_rerun` object.

```@example wwid
idata_rerun = InferenceData(; posterior=set(post[chain=At([0, 1])]; chain=[4, 5]))
```

You can combine the two using [`concat`](@ref).
You can combine the two using [`cat`](@ref).

```@example wwid
concat(idata[[:posterior]], idata_rerun; dim=:chain)
cat(idata[[:posterior]], idata_rerun; dims=:chain)
```
7 changes: 1 addition & 6 deletions src/ArviZ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ export summarystats, compare, hdi, loo, loo_pit, r2_score, waic
export MCMCDiagnosticTools, AutocovMethod, FFTAutocovMethod, BDAAutocovMethod
export bfmi, ess, ess_rhat, mcse, rhat, rstar

## Stats utils
export autocov, autocorr, make_ufunc, wrap_xarray_ufunc

## InferenceObjects
export InferenceObjects,
Dataset,
Expand All @@ -113,7 +110,7 @@ export InferenceObjectsNetCDF, from_netcdf, to_netcdf
export ArviZExampleData, describe_example_data, load_example_data

## Data
export extract, from_json, from_cmdstan, from_mcmcchains, from_samplechains, concat
export from_mcmcchains, from_samplechains

## rcParams
export rcParams, with_rc_context
Expand Down Expand Up @@ -149,9 +146,7 @@ end
include("utils.jl")
include("rcparams.jl")
include("xarray.jl")
include("data.jl")
include("plots.jl")
include("stats.jl")
include("stats_utils.jl")

end # module
23 changes: 0 additions & 23 deletions src/data.jl

This file was deleted.

9 changes: 0 additions & 9 deletions src/mcmcchains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,3 @@ function from_mcmcchains(

return all_idata
end

"""
from_cmdstan(posterior::Chains; kwargs...) -> InferenceData
Call [`from_mcmcchains`](@ref) on output of `CmdStan`.
"""
function from_cmdstan(posterior::Chains; kwargs...)
return from_mcmcchains(posterior; library="CmdStan", kwargs...)
end
4 changes: 0 additions & 4 deletions src/stats_utils.jl

This file was deleted.

2 changes: 0 additions & 2 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SampleChains = "754583d1-7fc4-4dab-93b5-5eaca5c9622e"
SampleChainsDynamicHMC = "6d9fd711-e8b2-4778-9c70-c1dfb499d4c4"
StanSample = "c1514b29-d3a0-5178-b312-660c88baa699"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Expand All @@ -23,4 +22,3 @@ PyCall = "1.91.2"
PyPlot = "2.8.2"
SampleChains = "0.5"
SampleChainsDynamicHMC = "0.3"
StanSample = "6, 7"
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ using Test
include("helpers.jl")
include("test_rcparams.jl")
include("test_utils.jl")
include("test_data.jl")
include("test_stats.jl")
include("test_plots.jl")
include("test_samplechains.jl")
Expand Down
32 changes: 0 additions & 32 deletions test/test_data.jl

This file was deleted.

Loading

0 comments on commit 0a5db5b

Please sign in to comment.