From d170cd0a951f4b1ce87b1390fad8aeef938fb84f Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Wed, 18 May 2022 01:16:56 +0200 Subject: [PATCH 1/2] Add script for converting code from 3 to 4. --- scripts/pymc3_to_4.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/pymc3_to_4.sh diff --git a/scripts/pymc3_to_4.sh b/scripts/pymc3_to_4.sh new file mode 100644 index 00000000000..a18456b4932 --- /dev/null +++ b/scripts/pymc3_to_4.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ -z "$1" ] + then + echo "Usage: pymc3_to_4.sh " + exit 1 +fi + +declare -a replace_strings=( + "s/az.from_pymc3/pm.to_inference_data/g" + "s/arviz.from_pymc3/pm.to_inference_data/g" + "s/pymc3/pymc/g" + "s/PyMC3/PyMC/g" + "s/from theano import tensor as tt/import aesara.tensor as at/g" + "s/import theano\.tensor as tt/import aesara.tensor as at/g" + "s/tt\./at./g" + "s/aet/at/g" + "s/studenat/studentt/g" + "s/theano/aesara/g" + "s/Theano/Aesara/g" + "s/pm\.sample()/pm.sample(return_inferencedata=False)/g" + "s/, return_inferencedata\=True//g" + "s/return_inferencedata\=True, //g" + "s/return_inferencedata\=True//g" +) + +for replace in "${replace_strings[@]}"; do + find $1 -name "*.ipynb" -type f -exec sed -i -e "$replace" {} \; + find $1 -name "*.py" -type f -exec sed -i -e "$replace" {} \; +done From 8c12b7c6b44d2c00468c683ece2ec298303a1b7c Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Wed, 18 May 2022 01:18:18 +0200 Subject: [PATCH 2/2] Better description. --- scripts/pymc3_to_4.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pymc3_to_4.sh b/scripts/pymc3_to_4.sh index a18456b4932..c79b85f6100 100644 --- a/scripts/pymc3_to_4.sh +++ b/scripts/pymc3_to_4.sh @@ -2,6 +2,7 @@ if [ -z "$1" ] then + echo "Script to automatically convert code (*.py and *.ipynb) from PyMC3 to 4.0. Use with care." echo "Usage: pymc3_to_4.sh " exit 1 fi