Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PythonCall to wrap Python ArviZ #5

Merged
merged 51 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3e41a06
Add CondaPkg.toml
sethaxen Aug 8, 2023
c0f5ffe
Replace PyCall packages with PythonCall equivalents
sethaxen Aug 8, 2023
bd86e92
Add LazyHelp utility
sethaxen Aug 8, 2023
7082198
Use LazyHelp utility for docs
sethaxen Aug 8, 2023
11c8ede
Update imports
sethaxen Aug 8, 2023
4c81013
Update utilities to use PythonCall
sethaxen Aug 8, 2023
a5d507d
Update conversion and styles
sethaxen Aug 8, 2023
fa36693
Update conversions to ELPDData
sethaxen Aug 8, 2023
247d260
Update plotting functions to use PythonCall
sethaxen Aug 8, 2023
63287aa
Update examples.md
sethaxen Aug 8, 2023
9fc42de
Update docs deps
sethaxen Aug 8, 2023
da276e6
Update docs
sethaxen Aug 8, 2023
3a2fb06
Remove PyCall-specific CI code
sethaxen Aug 8, 2023
c3d2d7c
Use simpler caching action
sethaxen Aug 8, 2023
e91aec7
Cache CondaPkg artifacts
sethaxen Aug 8, 2023
5c9cf5d
Remove futures workflow
sethaxen Aug 8, 2023
441a420
Run formatter
sethaxen Aug 8, 2023
4771594
Remove build fiile
sethaxen Aug 8, 2023
87ab9c2
Remove prefix
sethaxen Aug 8, 2023
180d8a1
Index axes from 0
sethaxen Aug 8, 2023
5f59b26
Use pywith in example
sethaxen Aug 8, 2023
7c20e6d
Overload Py methods
sethaxen Aug 9, 2023
eb9d075
Delete unused macro
sethaxen Aug 9, 2023
0ad5c9f
Add topytype
sethaxen Aug 9, 2023
35f2244
Simplify plotting functions
sethaxen Aug 9, 2023
23c867b
Don't import PyCall
sethaxen Aug 9, 2023
6d856a0
Run formatter
sethaxen Aug 9, 2023
7ff8968
Convert styles list
sethaxen Aug 9, 2023
4e3b0bd
Fixes for utils
sethaxen Aug 9, 2023
95ca4f8
Update some tests
sethaxen Aug 9, 2023
678d000
Enable strict docs building
sethaxen Aug 9, 2023
9af5a31
Remove setup code
sethaxen Aug 9, 2023
df7f470
Remove todataframes
sethaxen Aug 9, 2023
0b29283
Remove frompytype
sethaxen Aug 9, 2023
bdc4b61
Remove convert_result
sethaxen Aug 9, 2023
3f2f387
Remove unused topandas method
sethaxen Aug 9, 2023
a3742bf
Replace DataFrames with Tables
sethaxen Aug 9, 2023
5c3624e
Remove conversions from Py to InferenceObjects
sethaxen Aug 9, 2023
6f28cde
Simplify rcparams code
sethaxen Aug 9, 2023
ccccc34
Fix rcparams bugs
sethaxen Aug 9, 2023
1054cc2
Use topytype utility
sethaxen Aug 9, 2023
010190d
Run formatter
sethaxen Aug 9, 2023
524af8b
Fix topytype
sethaxen Aug 9, 2023
e121d40
Update tests
sethaxen Aug 9, 2023
e18faec
Increment lower Julia version bound
sethaxen Aug 9, 2023
2fac43c
Bump lower Julia version bound
sethaxen Aug 9, 2023
900ca23
Update docs
sethaxen Aug 9, 2023
ad769ec
Don't reexport ArviZ
sethaxen Aug 9, 2023
3569302
Update docs
sethaxen Aug 9, 2023
1066609
Increment ArviZ version bound
sethaxen Aug 9, 2023
34b155c
Also run CI on nightly
sethaxen Aug 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/workflows/Invalidations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PYTHON: "Conda" # use Julia's packaged Conda build for installing packages

jobs:
evaluate:
# Only run on PRs to the default branch.
Expand All @@ -24,17 +21,6 @@ jobs:
version: '1'
- uses: actions/checkout@v3
- uses: julia-actions/julia-buildpkg@v1
- name: Install Python ArviZ dependencies
run: |
using Pkg
Pkg.instantiate()
using Conda
# https://discourse.julialang.org/t/conda-not-installing-matplotlib-for-pyplot/96813/2
Conda.add("conda==23.1.0")
using ArviZPythonPlots
ArviZPythonPlots.initialize_arviz()
ArviZPythonPlots.initialize_pandas()
shell: julia --color=yes --project {0}
- uses: julia-actions/julia-invalidations@v1
id: invs_pr

Expand Down
31 changes: 1 addition & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
schedule:
- cron: "0 0 * * *"

env:
PYTHON: "Conda" # use Julia's packaged Conda build for installing packages

jobs:
test:
name: Julia ${{ matrix.julia-version }} - ${{ matrix.os }}
Expand All @@ -28,34 +25,8 @@ jobs:
with:
version: ${{ matrix.julia-version }}
arch: x64
- name: Cache Julia artifacts
uses: actions/cache@v2
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Install wget for windows
if: matrix.os == 'windows-latest'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install wget
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- name: Install Python ArviZ dependencies
run: |
using Pkg
Pkg.instantiate()
using Conda
# https://discourse.julialang.org/t/conda-not-installing-matplotlib-for-pyplot/96813/2
Conda.add("conda==23.1.0")
using ArviZPythonPlots
ArviZPythonPlots.initialize_arviz()
ArviZPythonPlots.initialize_pandas()
shell: julia --color=yes --project {0}
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
tags: [v*]
pull_request:

env:
PYTHON: "Conda" # use Julia's packaged Conda build for installing packages

jobs:
docs:
name: Documentation
Expand All @@ -16,14 +13,6 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/julia-buildpkg@latest
- name: Setup Conda
run: |
using Pkg
Pkg.instantiate()
using Conda
# https://discourse.julialang.org/t/conda-not-installing-matplotlib-for-pyplot/96813/2
Conda.add("conda==23.1.0")
shell: julia --color=yes --project {0}
- uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/futures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
schedule:
- cron: "0 0 * * *"

env:
PYTHON: "Conda" # use Julia's packaged Conda build for installing packages

jobs:
test:
name: Julia ${{ matrix.julia-version }} - ${{ matrix.arviz_version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/docs/build
/test/*.log
.DS_Store
.CondaPkg
5 changes: 5 additions & 0 deletions CondaPkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
pandas = ""
matplotlib = ""
xarray = ""
arviz = ">=0.14.0"
12 changes: 6 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ version = "0.1.0"

[deps]
ArviZ = "131c737c-5715-5e2e-ad31-c244f01c1dc7"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
PythonPlot = "274fc56d-3b97-40fa-a1cd-1b4a50311bf9"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

[compat]
ArviZ = "0.9"
ArviZExampleData = "0.1.5"
Conda = "1.0"
CondaPkg = "0.2"
DataFrames = "0.20, 0.21, 0.22, 1.0"
DimensionalData = "0.23, 0.24"
OrderedCollections = "1"
PyCall = "1.91.2"
PyPlot = "2.8.2"
PythonCall = "0.9"
PythonPlot = "1"
Reexport = "1"
julia = "1.6"

Expand Down
5 changes: 1 addition & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ ArviZExampleData = "2f96bb34-afd9-46ae-bcd0-9b2d4372fe3c"
ArviZPythonPlots = "4a6e88f0-2c8e-11ee-0601-e94153f0eada"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"

[compat]
ArviZExampleData = "0.1.5"
Distributions = "0.25"
Documenter = "0.27"
PyCall = "1.0"
PyPlot = "2.0"
53 changes: 53 additions & 0 deletions docs/lazyhelp.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Documenter, Markdown, PythonCall

# adapted from https://github.com/AtelierArith/Kyulacs.jl for PythonCall
# MIT License
# Copyright (c) 2022 Satoshi Terasaki <[email protected]> and contributors

function get_signature(f)
inspect = pyimport("inspect")
try
return pyconvert(String, inspect.signature(f))
catch e
return ""
end
end

function gendocstr(h::LazyHelp)
o = h.o
for k in h.keys
o = pygetattr(o, k)
end
fname = pyhasattr(o, "__name__") ? pyconvert(String, o.__name__) : ""
sig = pyhasattr(o, "__call__") ? get_signature(o) : ""
fdoc = pyhasattr(o, "__doc__") ? pyconvert(String, o.__doc__) : ""

if isnothing(fdoc)
return """
$(fname)$(sig)
"""
else
return """
$(fdoc)
"""
end
end

function Documenter.Writers.HTMLWriter.mdconvert(
h::LazyHelp,
parent;
kwargs...,
)
s = gendocstr(h)
# quote docstring `s` to prevent changing display result
m = Markdown.parse(
"""
```
$s
```
""",
)
Documenter.Writers.HTMLWriter.mdconvert(m, parent; kwargs...)
end

Documenter.Utilities.MDFlatten.mdflatten(::IOBuffer, ::LazyHelp, ::Markdown.MD) = nothing
4 changes: 4 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using ArviZPythonPlots, Documenter
using ArviZPythonPlots: LazyHelp

include("lazyhelp.jl")

makedocs(;
modules=[ArviZPythonPlots],
Expand All @@ -17,6 +20,7 @@ makedocs(;
format=Documenter.HTML(;
prettyurls=haskey(ENV, "CI"), sidebar_sitename=false, canonical="stable"
),
doctest=false,
linkcheck=true,
)

Expand Down
Loading