Skip to content

Commit 7987412

Browse files
authored
Merge pull request #1 from pymc-devs/docs
add config readthedocs and workflows
2 parents c766808 + 0aaf651 commit 7987412

File tree

6 files changed

+164
-6
lines changed

6 files changed

+164
-6
lines changed

.github/workflows/test.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: pytest
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
paths:
8+
- ".github/workflows/*"
9+
- "pymc_bart/**"
10+
- "setup.py"
11+
- "pyproject.toml"
12+
- "buildosx"
13+
- "conda-envs/**"
14+
- "codecov.yml"
15+
16+
jobs:
17+
ubuntu:
18+
strategy:
19+
matrix:
20+
os: [ubuntu-18.04]
21+
floatx: [float32, float64]
22+
fail-fast: false
23+
runs-on: ${{ matrix.os }}
24+
env:
25+
TEST_SUBSET: ${{ matrix.test-subset }}
26+
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
27+
defaults:
28+
run:
29+
shell: bash -l {0}
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Cache conda
33+
uses: actions/cache@v1
34+
env:
35+
# Increase this value to reset cache if environment-test-py38.yml has not changed
36+
CACHE_NUMBER: 0
37+
with:
38+
path: ~/conda_pkgs_dir
39+
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
40+
hashFiles('conda-envs/environment-test-py38.yml') }}
41+
- name: Cache multiple paths
42+
uses: actions/cache@v2
43+
env:
44+
# Increase this value to reset cache if requirements.txt has not changed
45+
CACHE_NUMBER: 0
46+
with:
47+
path: |
48+
~/.cache/pip
49+
$RUNNER_TOOL_CACHE/Python/*
50+
~\AppData\Local\pip\Cache
51+
key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{
52+
hashFiles('requirements.txt') }}
53+
- uses: conda-incubator/setup-miniconda@v2
54+
with:
55+
miniforge-variant: Mambaforge
56+
miniforge-version: latest
57+
mamba-version: "*"
58+
activate-environment: pymc-test-py38
59+
channel-priority: strict
60+
environment-file: conda-envs/environment-test-py38.yml
61+
use-mamba: true
62+
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
63+
- name: Install-pymc
64+
run: |
65+
conda activate pymc-test-py38
66+
pip install -e .
67+
python --version
68+
- name: Run tests
69+
run: |
70+
conda activate pymc-test-py38
71+
python -m pytest -vv --cov=pymc_bart --cov-append --cov-report=xml --cov-report term --durations=50 $TEST_SUBSET
72+
- name: Upload coverage to Codecov
73+
uses: codecov/codecov-action@v2
74+
with:
75+
env_vars: TEST_SUBSET
76+
name: ${{ matrix.os }} ${{ matrix.floatx }}
77+
fail_ci_if_error: false
78+
windows:
79+
strategy:
80+
matrix:
81+
os: [windows-latest]
82+
floatx: [float32, float64]
83+
fail-fast: false
84+
runs-on: ${{ matrix.os }}
85+
env:
86+
TEST_SUBSET: ${{ matrix.test-subset }}
87+
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
88+
defaults:
89+
run:
90+
shell: cmd
91+
steps:
92+
- uses: actions/checkout@v2
93+
- name: Cache conda
94+
uses: actions/cache@v1
95+
env:
96+
# Increase this value to reset cache if conda-envs/environment-test-py37.yml has not changed
97+
CACHE_NUMBER: 0
98+
with:
99+
path: ~/conda_pkgs_dir
100+
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
101+
hashFiles('conda-envs/windows-environment-test-py37.yml') }}
102+
- name: Cache multiple paths
103+
uses: actions/cache@v2
104+
env:
105+
# Increase this value to reset cache if requirements.txt has not changed
106+
CACHE_NUMBER: 0
107+
with:
108+
path: |
109+
~/.cache/pip
110+
$RUNNER_TOOL_CACHE/Python/*
111+
~\AppData\Local\pip\Cache
112+
key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{
113+
hashFiles('requirements.txt') }}
114+
- uses: conda-incubator/setup-miniconda@v2
115+
with:
116+
miniforge-variant: Mambaforge
117+
miniforge-version: latest
118+
mamba-version: "*"
119+
activate-environment: pymc-test-py37
120+
channel-priority: strict
121+
environment-file: conda-envs/windows-environment-test-py37.yml
122+
use-mamba: true
123+
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
124+
- name: Install-pymc
125+
run: |
126+
conda activate pymc-test-py37
127+
pip install -e .
128+
python --version
129+
- name: Run tests
130+
# This job uses a cmd shell, therefore the environment variable syntax is different!
131+
# The ">-" in the next line replaces newlines with spaces (see https://stackoverflow.com/a/66809682).
132+
run: >-
133+
conda activate pymc-test-py37 &&
134+
python -m pytest -vv --cov=pymc_bart --doctest-modules pymc_bart --cov-append --cov-report=xml --cov-report term --durations=50 %TEST_SUBSET%
135+
- name: Upload coverage to Codecov
136+
uses: codecov/codecov-action@v2
137+
with:
138+
env_vars: TEST_SUBSET
139+
name: ${{ matrix.os }} ${{ matrix.floatx }}
140+
fail_ci_if_error: false

.readthedocs.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
version: 2
4+
5+
build:
6+
os: ubuntu-20.04
7+
tools:
8+
python: "3.9"
9+
10+
python:
11+
install:
12+
- requirements: requirements-docs.txt
13+
- requirements: requirements.txt
14+
- method: pip
15+
path: .

buildosx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
export CFLAGS="-arch x86_64"
3+
export FFLAGS="-static -ff2c -arch x86_64"
4+
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch x86_64"
5+
rm -rf build
6+
python setupegg.py bdist_egg

pymc_bart/pgbart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class ParticleTree:
282282
"""Particle tree."""
283283

284284
def __init__(self, tree):
285-
self.tree = tree.copy() # keself.eps the tree that we care at the moment
285+
self.tree = tree.copy() # keeps the tree that we care at the moment
286286
self.expansion_nodes = [0]
287287
self.log_weight = 0
288288
self.old_likelihood_logp = 0

tests/test_bart.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import numpy as np
2+
import pymc as pm
23
import pytest
3-
44
from numpy.random import RandomState
55
from numpy.testing import assert_almost_equal, assert_array_equal
6+
from pymc.tests.distributions.util import assert_moment_is_expected
67

7-
import pymc as pm
88
import pymc_bart as pmb
99

10-
from pymc.tests.test_distributions_moments import assert_moment_is_expected
11-
12-
1310
def test_split_node():
1411
split_node = pmb.tree.SplitNode(index=5, idx_split_variable=2, split_value=3.0)
1512
assert split_node.index == 5

0 commit comments

Comments
 (0)