Skip to content

Commit 940d784

Browse files
lucianopaztwiecki
authored andcommitted
Added minimal python3.5 test env (#3470)
* Added minimal python3.5 test env * Enforced python3.5 with matrix. Used different conda env in py35. * Reverted travis.yml matrix back to envs. Set default ENVNAME * Removed duplicate env * Try to pip uninstall conflicting numpy version before conda installing into the env * Confirm pip uninstall numpy * Try to uninstall numpy in install_miniconda * Try to not conda install numpy and hope pip does everything well * Fixed test error on py35 env * Fixed defects introduced to draw_values * Commented why we uninstall miniconda's numpy * Added python_requires to setup.py
1 parent ff7f047 commit 940d784

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ env:
3030
- FLOATX='float64' TESTCMD="--durations=10 --cov-append pymc3/tests/test_distributions_random.py pymc3/tests/test_shared.py pymc3/tests/test_smc.py pymc3/tests/test_sampling.py pymc3/tests/test_parallel_sampling.py pymc3/tests/test_dist_math.py pymc3/tests/test_distribution_defaults.py pymc3/tests/test_distributions_timeseries.py pymc3/tests/test_random.py"
3131
- FLOATX='float64' TESTCMD="--durations=10 --cov-append pymc3/tests/test_examples.py pymc3/tests/test_posteriors.py pymc3/tests/test_gp.py"
3232
- FLOATX='float64' TESTCMD="--durations=10 --cov-append pymc3/tests/test_variational_inference.py pymc3/tests/test_updates.py pymc3/tests/test_shape_handling.py"
33+
- PYTHON_VERSION=3.5 FLOATX='float64' ENVNAME="py35_testenv" TESTCMD="--cov-append pymc3/tests/test_sampling.py pymc3/tests/test_model_graph.py"
3334

3435
script:
3536
- . ./scripts/test.sh $TESTCMD

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
- Fixed an issue in `model_graph` that caused construction of the graph of the model for rendering to hang: replaced a search over the powerset of the nodes with a breadth-first search over the nodes. Fix for #3458.
4646
- Removed variable annotations from `model_graph` but left type hints (Fix for #3465). This means that we support `python>=3.5.4`.
4747
- Default `target_accept`for `HamiltonianMC` is now 0.65, as suggested in Beskos et. al. 2010 and Neal 2001.
48+
- Fixed bug in `draw_values` that lead to intermittent errors in python3.5. This happened with some deterministic nodes that were drawn but not added to `givens`.
4849

4950
### Deprecations
5051

pymc3/distributions/distribution.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,7 @@ def draw_values(params, point=None, size=None):
401401
# nodes in the `params` list.
402402
stack.extend([node for node in named_nodes_parents[next_]
403403
if node is not None and
404-
(node, size) not in drawn and
405-
node not in params])
404+
(node, size) not in drawn])
406405

407406
# the below makes sure the graph is evaluated in order
408407
# test_distributions_random::TestDrawValues::test_draw_order fails without it
@@ -420,6 +419,20 @@ def draw_values(params, point=None, size=None):
420419
evaluated[param_idx] = drawn[(param, size)]
421420
else:
422421
try: # might evaluate in a bad order,
422+
# Sometimes _draw_value recurrently calls draw_values.
423+
# This may set values for certain nodes in the drawn
424+
# dictionary, but they don't get added to the givens
425+
# dictionary. Here, we try to fix that.
426+
if param in named_nodes_children:
427+
for node in named_nodes_children[param]:
428+
if (
429+
node.name not in givens and
430+
(node, size) in drawn
431+
):
432+
givens[node.name] = (
433+
node,
434+
drawn[(node, size)]
435+
)
423436
value = _draw_value(param,
424437
point=point,
425438
givens=givens.values(),

scripts/create_testenv.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ command -v conda >/dev/null 2>&1 || {
2020
exit 1;
2121
}
2222

23-
ENVNAME="testenv"
23+
ENVNAME="${ENVNAME:-testenv}" # if no ENVNAME is specified, use testenv
2424
PYTHON_VERSION=${PYTHON_VERSION:-3.6} # if no python specified, use 3.6
2525

2626
if [ -z ${GLOBAL} ]
@@ -33,10 +33,11 @@ then
3333
fi
3434
source activate ${ENVNAME}
3535
fi
36-
conda install --yes numpy scipy mkl-service
36+
pip install --upgrade pip
37+
38+
conda install --yes mkl-service
3739
conda install --yes -c conda-forge python-graphviz
3840

39-
pip install --upgrade pip
4041

4142
# Install editable using the setup.py
4243

scripts/install_miniconda.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ fi
4646
export PATH="$INSTALL_FOLDER/bin:$PATH"
4747
echo "Adding $INSTALL_FOLDER to PATH. Consider adding it in your .rc file as well."
4848
conda update -q -y conda
49+
# Uninstalling miniconda's numpy to avoid conflicting versions when creating the test env
50+
pip uninstall -y numpy

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def get_version():
5959
package_data={'docs': ['*']},
6060
include_package_data=True,
6161
classifiers=classifiers,
62+
python_requires=">=3.5.4",
6263
install_requires=install_reqs,
6364
extras_require={
6465
"plots": ["arviz"],

0 commit comments

Comments
 (0)