Skip to content

Commit 92ff9e9

Browse files
Fix ArviZ version on test environment (#4037)
* Added kwarg to pytest fixture * Removed main conda channel and added dill as pip dependency * Added kwargs to many more pytest fixtures * Removed strict conda channel priority setting in create_testenv * Add back strict channel priority in create_testenv * Remove conda uninstall arviz from travis yml * Add back conda uninstall arviz in travis yml * Add default channel in test env and use MKL * Removed add channels conda-forge from CLI * Explicitly add channel conda-forge from CLI * Use mamba instead of conda in test env * Removed conda update all from bash script * Fixed VI test * Use mamba instead of conda to uninstall arviz * Activate testenv in ArviZ compatibility job and raise tolerance in failing VI test * Switch back to conda to uninstall arviz in ArviZ compatibility job * Remove conda uninstall arviz from travis yml Co-authored-by: Adrian Seyboldt <[email protected]>
1 parent ee57bed commit 92ff9e9

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ jobs:
4848
stage: test
4949
install:
5050
- . ./scripts/create_testenv.sh
51-
- conda uninstall arviz -y
52-
# replace ArviZ with the lastest master
51+
- conda activate testenv
52+
# replace ArviZ with the latest master
5353
- pip install git+git://github.com/arviz-devs/arviz.git
5454
- pip install codecov
5555
- conda list && pip freeze

environment-dev.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ dependencies:
3636
- ipywidgets
3737
- dataclasses # python_version < 3.7
3838
- contextvars # python_version < 3.7
39+
- mkl-service
40+
- libblas=*=*mkl
3941
- pip:
4042
- black_nbconvert
43+
- dill

pymc3/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def strict_float32():
4444
yield
4545

4646

47-
@pytest.fixture('function', autouse=False)
47+
@pytest.fixture(scope='function', autouse=False)
4848
def seeded_test():
4949
# TODO: use this instead of SeededTest
5050
np.random.seed(42)

pymc3/tests/test_minibatches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __next__(self):
5151
next = __next__
5252

5353

54-
@pytest.fixture('module')
54+
@pytest.fixture(scope='module')
5555
def datagen():
5656
return _DataSampler(np.random.uniform(size=(1000, 10)))
5757

pymc3/tests/test_variational_inference.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_tracker_callback():
9696
tracker(None, None, 1)
9797

9898

99-
@pytest.fixture('module')
99+
@pytest.fixture(scope='module')
100100
def three_var_model():
101101
with pm.Model() as model:
102102
pm.HalfNormal('one', shape=(10, 2), total_size=100)
@@ -573,7 +573,7 @@ def test_elbo_beta_kl(aux_total_size):
573573

574574

575575
@pytest.fixture(
576-
'module',
576+
scope='module',
577577
params=[True, False],
578578
ids=['mini', 'full']
579579
)
@@ -617,7 +617,7 @@ def simple_model(simple_model_data):
617617
return model
618618

619619

620-
@pytest.fixture('module', params=[
620+
@pytest.fixture(scope='module', params=[
621621
dict(cls=NFVI, init=dict(flow='scale-loc')),
622622
dict(cls=ADVI, init=dict()),
623623
dict(cls=FullRankADVI, init=dict()),
@@ -642,13 +642,13 @@ def init_(**kw):
642642
return init_
643643

644644

645-
@pytest.fixture('function')
645+
@pytest.fixture(scope='function')
646646
def inference(inference_spec, simple_model):
647647
with simple_model:
648648
return inference_spec()
649649

650650

651-
@pytest.fixture('function')
651+
@pytest.fixture(scope='function')
652652
def fit_kwargs(inference, use_minibatch):
653653
_select = {
654654
(ADVI, 'full'): dict(
@@ -709,7 +709,7 @@ def test_fit_oo(inference,
709709
mu_post = simple_model_data['mu_post']
710710
d = simple_model_data['d']
711711
np.testing.assert_allclose(np.mean(trace['mu']), mu_post, rtol=0.05)
712-
np.testing.assert_allclose(np.std(trace['mu']), np.sqrt(1. / d), rtol=0.1)
712+
np.testing.assert_allclose(np.std(trace['mu']), np.sqrt(1. / d), rtol=0.2)
713713

714714

715715
def test_profile(inference):
@@ -747,7 +747,7 @@ def test_clear_cache():
747747
assert all(len(c) == 0 for c in inference_new.approx._cache.values())
748748

749749

750-
@pytest.fixture('module')
750+
@pytest.fixture(scope='module')
751751
def another_simple_model():
752752
_model = models.simple_model()[1]
753753
with _model:
@@ -798,7 +798,7 @@ def test_fit_fn_text(method, kwargs, error, another_simple_model):
798798
fit(10, method=method, **kwargs)
799799

800800

801-
@pytest.fixture('module')
801+
@pytest.fixture(scope='module')
802802
def aevb_model():
803803
with pm.Model() as model:
804804
pm.HalfNormal('x', shape=(2,), total_size=5)
@@ -871,7 +871,7 @@ def test_pickle_approx_aevb(three_var_aevb_approx):
871871
assert new.sample(1000)
872872

873873

874-
@pytest.fixture('module')
874+
@pytest.fixture(scope='module')
875875
def binomial_model():
876876
n_samples = 100
877877
xs = intX(np.random.binomial(n=1, p=0.2, size=n_samples))
@@ -881,7 +881,7 @@ def binomial_model():
881881
return model
882882

883883

884-
@pytest.fixture('module')
884+
@pytest.fixture(scope='module')
885885
def binomial_model_inference(binomial_model, inference_spec):
886886
with binomial_model:
887887
return inference_spec()
@@ -980,10 +980,10 @@ def test_var_replacement():
980980
def test_empirical_from_trace(another_simple_model):
981981
with another_simple_model:
982982
step = pm.Metropolis()
983-
trace = pm.sample(100, step=step, chains=1)
983+
trace = pm.sample(100, step=step, chains=1, tune=0)
984984
emp = Empirical(trace)
985985
assert emp.histogram.shape[0].eval() == 100
986-
trace = pm.sample(100, step=step, chains=4)
986+
trace = pm.sample(100, step=step, chains=4, tune=0)
987987
emp = Empirical(trace)
988988
assert emp.histogram.shape[0].eval() == 400
989989

scripts/create_testenv.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ if [ -z ${GLOBAL} ]; then
2727
else
2828
conda config --add channels conda-forge
2929
conda config --set channel_priority strict
30-
conda env create -f environment-dev.yml
30+
conda install -c conda-forge mamba --yes
31+
mamba env create -f environment-dev.yml
3132
fi
3233
source activate ${ENVNAME}
3334
fi
3435

35-
conda update --yes --all
36-
3736
# Install editable using the setup.py
3837
if [ -z ${NO_SETUP} ]; then
3938
python setup.py build_ext --inplace

0 commit comments

Comments
 (0)