Skip to content

Commit fca2c3c

Browse files
authored
Initialize repository (#1)
* Add dependencies * Squashed 'deps/data/example_data/' content from commit 594a6ad git-subtree-dir: deps/data/example_data git-subtree-split: 594a6addd3aeddbd5d03e1a59300a1dcf0491a68 * Add more dependencies * Run JuliaFormatter * Define constants * Define metadata * Load metadata * Add data registration * Add data loading * Update documentation * Remove docs manifest from version history * Preserve order of datasets in file * Add function for listing example data * Print example datasets in docs * Update docstring * Update docs * Update CI workflow * Rename function * Replace show with describe * Check datasets are abstract dict * Depend on InferenceObjectsNetCDF * Add InferenceObjects as extras dep * Remove git subtree * Get example data from artifact
1 parent c4a5376 commit fca2c3c

20 files changed

+352
-123
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "blue"

.github/workflows/CI.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
- main
66
tags: ['*']
77
pull_request:
8+
schedule:
9+
- cron: "0 0 * * *"
810
concurrency:
911
# Skip intermediate builds: always.
1012
# Cancel intermediate builds: only if it is a pull request build.
@@ -18,13 +20,20 @@ jobs:
1820
fail-fast: false
1921
matrix:
2022
version:
21-
- '1.0'
22-
- '1.8'
23+
- '1.6'
24+
- '1'
2325
- 'nightly'
2426
os:
2527
- ubuntu-latest
2628
arch:
2729
- x64
30+
include:
31+
- version: '1'
32+
os: windows-latest
33+
arch: x64
34+
- version: '1'
35+
os: macOS-latest
36+
arch: x64
2837
steps:
2938
- uses: actions/checkout@v2
3039
- uses: julia-actions/setup-julia@v1

Artifacts.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[arviz_example_data]
2+
git-tree-sha1 = "1ea01419c2c0cd6cf2b2daffb235fc17091e30bc"
3+
4+
[[arviz_example_data.download]]
5+
sha256 = "eae35685807a0dcbbf405b21eaf5fa7aff6729c5a33f8f800f093c5a8318aa2b"
6+
url = "https://github.com/arviz-devs/arviz_example_data/archive/refs/tags/v0.1.0.tar.gz"

Project.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@ uuid = "2f96bb34-afd9-46ae-bcd0-9b2d4372fe3c"
33
authors = ["Seth Axen <seth.axen@gmail.com> and contributors"]
44
version = "0.1.0"
55

6+
[deps]
7+
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
8+
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
9+
InferenceObjectsNetCDF = "7cb6d088-77df-42c3-8f05-5ca8d42599d1"
10+
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
11+
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
12+
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
13+
614
[compat]
7-
julia = "1"
15+
DataDeps = "0.7"
16+
InferenceObjects = "0.1"
17+
InferenceObjectsNetCDF = "0.1"
18+
JSON3 = "1"
19+
OrderedCollections = "1"
20+
StructTypes = "1"
21+
julia = "1.6"
822

923
[extras]
24+
InferenceObjects = "b5cf5a8d-e756-4ee3-b014-01d49d192c00"
1025
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1126

1227
[targets]
13-
test = ["Test"]
28+
test = ["InferenceObjects", "Test"]

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# ArviZExampleData
22

3-
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://arviz-devs.github.io/ArviZExampleData.jl/stable/)
4-
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://arviz-devs.github.io/ArviZExampleData.jl/dev/)
3+
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://exampledata.julia.arviz.org/stable/)
4+
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://exampledata.julia.arviz.org/dev/)
55
[![Build Status](https://github.com/arviz-devs/ArviZExampleData.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/arviz-devs/ArviZExampleData.jl/actions/workflows/CI.yml?query=branch%3Amain)
66
[![Coverage](https://codecov.io/gh/arviz-devs/ArviZExampleData.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/arviz-devs/ArviZExampleData.jl)
77
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
88
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
9+
[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org)
10+
11+
Utilities for loading data include in the [`arviz_example_data`](https://github.com/arviz-devs/arviz_example_data) repository.
12+
The resulting objects are [InferenceObjects.jl](https://github.com/arviz-devs/InferenceObjects.jl)'s `InferenceData`, and these utilities are used in [ArviZ.jl](https://github.com/arviz-devs/ArviZ.jl).

docs/Manifest.toml

Lines changed: 0 additions & 103 deletions
This file was deleted.

docs/make.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using ArviZExampleData
22
using Documenter
33

4-
DocMeta.setdocmeta!(ArviZExampleData, :DocTestSetup, :(using ArviZExampleData); recursive=true)
4+
DocMeta.setdocmeta!(
5+
ArviZExampleData, :DocTestSetup, :(using ArviZExampleData); recursive=true
6+
)
57

68
makedocs(;
79
modules=[ArviZExampleData],
@@ -16,10 +18,10 @@ makedocs(;
1618
),
1719
pages=[
1820
"Home" => "index.md",
21+
"Datasets" => "datasets.md",
22+
"API" => "api.md",
23+
"For developers" => "for_developers.md",
1924
],
2025
)
2126

22-
deploydocs(;
23-
repo="github.com/arviz-devs/ArviZExampleData.jl",
24-
devbranch="main",
25-
)
27+
deploydocs(; repo="github.com/arviz-devs/ArviZExampleData.jl", devbranch="main")

docs/src/api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# API
2+
3+
```@autodocs
4+
Modules = [ArviZExampleData]
5+
Private = false
6+
```

docs/src/datasets.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Datasets
2+
3+
The following shows the currently available example datasets:
4+
5+
```@example
6+
using ArviZExampleData
7+
8+
println(describe_example_data())
9+
```

docs/src/for_developers.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# For developers
2+
3+
This package has [`arviz_example_data`](https://github.com/arviz-devs/arviz_example_data) as a data dependency, which is included as an [artifact](https://pkgdocs.julialang.org/v1/artifacts/).
4+
5+
When `arviz_example_data` is updated, and a new release is made, `Artifacts.toml` should be updated to point to the new tarball corresponding to the release:
6+
7+
```julia
8+
julia> using ArtifactUtils
9+
10+
julia> version = v"0.1.0";
11+
12+
julia> tarball_url = "https://github.com/arviz-devs/arviz_example_data/archive/refs/tags/v$version.tar.gz";
13+
14+
julia> add_artifact!("Artifacts.toml", "arviz_example_data", tarball_url; force=true);
15+
```

docs/src/index.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ CurrentModule = ArviZExampleData
44

55
# ArviZExampleData
66

7-
Documentation for [ArviZExampleData](https://github.com/arviz-devs/ArviZExampleData.jl).
7+
[![Build Status](https://github.com/arviz-devs/ArviZExampleData.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/arviz-devs/ArviZExampleData.jl/actions/workflows/CI.yml?query=branch%3Amain)
8+
[![Coverage](https://codecov.io/gh/arviz-devs/ArviZExampleData.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/arviz-devs/ArviZExampleData.jl)
9+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
10+
[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](https://numfocus.org)
811

9-
```@index
10-
```
11-
12-
```@autodocs
13-
Modules = [ArviZExampleData]
14-
```
12+
Utilities for loading data include in the [`arviz_example_data`](https://github.com/arviz-devs/arviz_example_data) repository.
13+
The resulting objects are [InferenceObjects.jl](https://github.com/arviz-devs/InferenceObjects.jl)'s `InferenceData`, and these utilities are used in [ArviZ.jl](https://github.com/arviz-devs/ArviZ.jl).

src/ArviZExampleData.jl

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
module ArviZExampleData
22

3-
# Write your package code here.
3+
using Artifacts: @artifact_str
4+
using DataDeps: DataDeps
5+
using InferenceObjectsNetCDF: InferenceObjectsNetCDF
6+
using JSON3: JSON3
7+
using OrderedCollections: OrderedDict
8+
using StructTypes: StructTypes
9+
10+
export describe_example_data, load_example_data
11+
12+
const EXAMPLE_DATA_DIR = only(readdir(artifact"arviz_example_data"; join=true))
13+
const LOCAL_DATA_DIR = joinpath(EXAMPLE_DATA_DIR, "data")
14+
const LOCAL_DATA_FILE = joinpath(EXAMPLE_DATA_DIR, "data_local.json")
15+
const REMOTE_DATA_FILE = joinpath(EXAMPLE_DATA_DIR, "data_remote.json")
16+
const DATA_HTTP_PROTOCOL = "https"
17+
18+
include("metadata.jl")
19+
20+
const LOCAL_EXAMPLE_DATA = OrderedDict(
21+
md.name => md for md in JSON3.read(read(LOCAL_DATA_FILE), Vector{LocalFileMetadata})
22+
)
23+
const REMOTE_EXAMPLE_DATA = OrderedDict(
24+
md.name => md for md in JSON3.read(read(REMOTE_DATA_FILE), Vector{RemoteFileMetadata})
25+
)
26+
27+
include("register.jl")
28+
include("load.jl")
29+
include("describe.jl")
30+
31+
function __init__()
32+
return register_all_data()
33+
end
434

535
end

src/describe.jl

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""
2+
describe_example_data() -> String
3+
4+
Return a string containing descriptions of all available datasets.
5+
6+
# Examples
7+
8+
```jldoctest
9+
julia> describe_example_data("radon") |> println
10+
radon
11+
=====
12+
13+
Radon is a radioactive gas that enters homes through contact points with the ground. It is a carcinogen that is the primary cause of lung cancer in non-smokers. Radon levels vary greatly from household to household.
14+
15+
This example uses an EPA study of radon levels in houses in Minnesota to construct a model with a hierarchy over households within a county. The model includes estimates (gamma) for contextual effects of the uranium per household.
16+
17+
See Gelman and Hill (2006) for details on the example, or https://docs.pymc.io/notebooks/multilevel_modeling.html by Chris Fonnesbeck for details on this implementation.
18+
19+
remote: http://ndownloader.figshare.com/files/24067472
20+
```
21+
"""
22+
function describe_example_data end
23+
function describe_example_data(name::AbstractString)
24+
haskey(LOCAL_EXAMPLE_DATA, name) && return describe(LOCAL_EXAMPLE_DATA[name])
25+
haskey(REMOTE_EXAMPLE_DATA, name) && return describe(REMOTE_EXAMPLE_DATA[name])
26+
throw(
27+
ArgumentError(
28+
"Dataset $name not found. Valid datasets are: $(keys(load_example_data()))"
29+
),
30+
)
31+
end
32+
function describe_example_data()
33+
data = load_example_data()
34+
return join(map(describe, values(data)), "\n\n")
35+
end
36+
37+
"""
38+
describe(md::AbstractFileMetadata) -> String
39+
40+
Return description of the metadata of a dataset.
41+
"""
42+
describe
43+
function describe(md::LocalFileMetadata)
44+
io = IOBuffer()
45+
println(io, md.name)
46+
println(io, repeat("=", length(md.name)))
47+
println(io)
48+
if md.description !== nothing
49+
println(io, md.description)
50+
println(io)
51+
end
52+
print(io, "local: ", joinpath(LOCAL_DATA_DIR, md.filename))
53+
return String(take!(io))
54+
end
55+
function describe(md::RemoteFileMetadata)
56+
io = IOBuffer()
57+
println(io, md.name)
58+
println(io, repeat("=", length(md.name)))
59+
println(io)
60+
if md.description !== nothing
61+
println(io, md.description)
62+
println(io)
63+
end
64+
print(io, "remote: ", md.url)
65+
return String(take!(io))
66+
end

0 commit comments

Comments
 (0)