Skip to content

Test on last release of PyMC instead of main #125

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

Merged
merged 4 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
mamba-version: "*"
activate-environment: pymc-test
activate-environment: pymc-experimental-test
channel-priority: strict
environment-file: conda-envs/environment-test.yml
python-version: ${{matrix.python-version}}
use-mamba: true
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Install-pymc
- name: Install pymc-experimental
run: |
conda activate pymc-test
conda activate pymc-experimental-test
pip install -e .
python --version
- name: Run tests
run: |
conda activate pymc-test
conda activate pymc-experimental-test
python -m pytest -vv --cov=pymc_experimental --cov-append --cov-report=xml --cov-report term --durations=50 $TEST_SUBSET
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
Expand Down Expand Up @@ -123,22 +123,22 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
mamba-version: "*"
activate-environment: pymc-test
activate-environment: pymc-experimental-test
channel-priority: strict
environment-file: conda-envs/windows-environment-test.yml
python-version: ${{matrix.python-version}}
use-mamba: true
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Install-pymc
- name: Install pymc-experimental
run: |
conda activate pymc-test
conda activate pymc-experimental-test
pip install -e .
python --version
- name: Run tests
# This job uses a cmd shell, therefore the environment variable syntax is different!
# The ">-" in the next line replaces newlines with spaces (see https://stackoverflow.com/a/66809682).
run: >-
conda activate pymc-test &&
conda activate pymc-experimental-test &&
python -m pytest -vv --cov=pymc_experimental --cov-append --cov-report=xml --cov-report term --durations=50 %TEST_SUBSET%
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
Expand Down
4 changes: 2 additions & 2 deletions conda-envs/environment-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pymc-test
name: pymc-experimental-test
channels:
- conda-forge
- defaults
Expand All @@ -9,5 +9,5 @@ dependencies:
- dask
- xhistogram
- pip:
- "git+https://github.com/pymc-devs/pymc.git@main"
- pymc>=5.1.2 # CI was failing to resolve
- blackjax
4 changes: 2 additions & 2 deletions conda-envs/windows-environment-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pymc-test
name: pymc-experimental-test
channels:
- conda-forge
- defaults
Expand All @@ -9,4 +9,4 @@ dependencies:
- dask
- xhistogram
- pip:
- "git+https://github.com/pymc-devs/pymc.git@main"
- pymc>=5.1.2 # CI was failing to resolve
8 changes: 0 additions & 8 deletions pymc_experimental/marginal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ def _delete_rv_mappings(self, rv: TensorVariable) -> None:
self.rvs_to_initial_values.pop(rv)
else:
self.observed_RVs.remove(rv)
if rv in self.rvs_to_total_sizes:
self.rvs_to_total_sizes.pop(rv)

def _transfer_rv_mappings(self, old_rv: TensorVariable, new_rv: TensorVariable) -> None:
"""Transfer model mappings from old_rv to new_rv"""
Expand Down Expand Up @@ -122,8 +120,6 @@ def _transfer_rv_mappings(self, old_rv: TensorVariable, new_rv: TensorVariable)
index = self.observed_RVs.index(old_rv)
self.observed_RVs.pop(index)
self.observed_RVs.insert(index, new_rv)
if old_rv in self.rvs_to_total_sizes:
self.rvs_to_total_sizes[new_rv] = self.rvs_to_total_sizes.pop(old_rv)

def _marginalize(self, user_warnings=False):
fg = FunctionGraph(outputs=self.basic_RVs + self.marginalized_rvs, clone=False)
Expand Down Expand Up @@ -212,10 +208,6 @@ def clone(self):
m.values_to_rvs = {i: vars_to_clone[rv] for i, rv in self.values_to_rvs.items()}
m.rvs_to_values = {vars_to_clone[rv]: i for rv, i in self.rvs_to_values.items()}
m.rvs_to_transforms = {vars_to_clone[rv]: i for rv, i in self.rvs_to_transforms.items()}
# Special logic due to bug in pm.Model
m.rvs_to_total_sizes = {
vars_to_clone[rv]: i for rv, i in self.rvs_to_total_sizes.items() if rv in vars_to_clone
}
m.rvs_to_initial_values = {
vars_to_clone[rv]: i for rv, i in self.rvs_to_initial_values.items()
}
Expand Down
4 changes: 2 additions & 2 deletions pymc_experimental/tests/distributions/test_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import scipy.stats.distributions as sp

# test support imports from pymc
from pymc.tests.distributions.util import (
from pymc.testing import (
BaseTestDistributionRandom,
Domain,
R,
Expand All @@ -30,8 +30,8 @@
check_logcdf,
check_logp,
seeded_scipy_distribution_builder,
select_by_precision,
)
from pymc.tests.helpers import select_by_precision

# the distributions to be tested
from pymc_experimental.distributions import GenExtreme
Expand Down
2 changes: 1 addition & 1 deletion pymc_experimental/tests/test_marginal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_nested_marginalized_rvs():
sigma = pm.HalfNormal("sigma")

idx = pm.Bernoulli("idx", p=0.75)
dep = pm.Normal("dep", mu=pt.switch(pt.eq(idx, 0), -1000, 1000), sigma=sigma)
dep = pm.Normal("dep", mu=pt.switch(pt.eq(idx, 0), -1000.0, 1000.0), sigma=sigma)

sub_idx = pm.Bernoulli("sub_idx", p=pt.switch(pt.eq(idx, 0), 0.15, 0.95), shape=(5,))
sub_dep = pm.Normal("sub_dep", mu=dep + sub_idx * 100, sigma=sigma, shape=(5,))
Expand Down
2 changes: 1 addition & 1 deletion pymc_experimental/tests/test_model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_predict():
assert "y_model" in pred
assert isinstance(pred, dict)
assert len(prediction_data.input.values) == len(pred["y_model"])
assert isinstance(pred["y_model"][0], float)
assert isinstance(pred["y_model"][0], (np.float32, np.float64))


def test_predict_posterior():
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pymc>=5.0.0
pymc>=5.1.2