From 4dcae8175456cf73316acba130b703cf755c3eae Mon Sep 17 00:00:00 2001 From: ndilalla Date: Mon, 29 Jun 2020 16:12:50 -0700 Subject: [PATCH 01/18] Wrapper updated to root6 [ci-skip]. --- threeML/minimizer/ROOT_minimizer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/threeML/minimizer/ROOT_minimizer.py b/threeML/minimizer/ROOT_minimizer.py index 8261fe2bc..087f9093a 100644 --- a/threeML/minimizer/ROOT_minimizer.py +++ b/threeML/minimizer/ROOT_minimizer.py @@ -36,10 +36,9 @@ } -class FuncWrapper(ROOT.TPyMultiGenFunction): - def __init__(self, function, dimensions): - - ROOT.TPyMultiGenFunction.__init__(self, self) +class FuncWrapper(ROOT.Math.IMultiGenFunction): + + def setup(self, function, dimensions): self.function = function self.dimensions = int(dimensions) @@ -47,10 +46,14 @@ def NDim(self): return self.dimensions def DoEval(self, args): - new_args = [args[i] for i in range(self.dimensions)] - return self.function(*new_args) + + def Clone(self): + f = FuncWrapper() + f.setup(f.function, f.dimensions) + ROOT.SetOwnership(f, False) + return f class ROOTMinimizer(LocalMinimizer): @@ -76,7 +79,8 @@ def _setup(self, user_setup_dict): # Setup the minimizer algorithm - self.functor = FuncWrapper(self.function, self.Npar) + self.functor = FuncWrapper() + self.functor.setup(self.function, self.Npar) self.minimizer = ROOT.Minuit2.Minuit2Minimizer("Minimize") self.minimizer.Clear() self.minimizer.SetMaxFunctionCalls(setup_dict["max_function_calls"]) From 3d4b4134edc3a58799574b17d38ecb7b3135be72 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 30 Jun 2020 16:30:34 -0700 Subject: [PATCH 02/18] Adding support for both root5 and root6 [ci skip]. --- threeML/minimizer/ROOT_minimizer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/threeML/minimizer/ROOT_minimizer.py b/threeML/minimizer/ROOT_minimizer.py index 087f9093a..6b1989b16 100644 --- a/threeML/minimizer/ROOT_minimizer.py +++ b/threeML/minimizer/ROOT_minimizer.py @@ -35,8 +35,13 @@ 300: "Covariance matrix is not positive defined", } +root_class = None +try: + root_class = ROOT.TPyMultiGenFunction +except AttributeError: + root_class = ROOT.Math.IMultiGenFunction -class FuncWrapper(ROOT.Math.IMultiGenFunction): +class FuncWrapper(root_class): def setup(self, function, dimensions): self.function = function From 189b931cccd49e00092d28e02908ee2a5608e285 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Oct 2020 11:28:14 -0700 Subject: [PATCH 03/18] Removing root5 compatibility [ci skip] --- threeML/minimizer/ROOT_minimizer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/threeML/minimizer/ROOT_minimizer.py b/threeML/minimizer/ROOT_minimizer.py index 6b1989b16..4b4a23b8e 100644 --- a/threeML/minimizer/ROOT_minimizer.py +++ b/threeML/minimizer/ROOT_minimizer.py @@ -35,13 +35,13 @@ 300: "Covariance matrix is not positive defined", } -root_class = None -try: - root_class = ROOT.TPyMultiGenFunction -except AttributeError: - root_class = ROOT.Math.IMultiGenFunction +#root_class = None +#try: +# root_class = ROOT.TPyMultiGenFunction +#except AttributeError: +# root_class = ROOT.Math.IMultiGenFunction -class FuncWrapper(root_class): +class FuncWrapper(root_math.IMultiGenFunction): def setup(self, function, dimensions): self.function = function From 06f093c76e6179e0a2406e5c52a9dbfb1ea6482d Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Oct 2020 11:28:46 -0700 Subject: [PATCH 04/18] File updated [ci skip]. --- build_local.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/build_local.sh b/build_local.sh index 5525b1846..be34e17f6 100755 --- a/build_local.sh +++ b/build_local.sh @@ -39,14 +39,14 @@ echo "Running on ${TRAVIS_OS_NAME}" TRAVIS_PYTHON_VERSION=3.7 export TRAVIS_BUILD_NUMBER=2 ENVNAME=threeML_test_$TRAVIS_PYTHON_VERSION -USE_LOCAL=false +USE_LOCAL=true # Environment libgfortranver="3.0" -NUMPYVER=1.15 +#NUMPYVER=1.15 MATPLOTLIBVER=2 UPDATE_CONDA=false -XSPECVER="6.22.1" +XSPECVER="6.25" xspec_channel=xspecmodels if [[ ${TRAVIS_OS_NAME} == "linux" ]]; @@ -74,7 +74,7 @@ echo "Python version: ${TRAVIS_PYTHON_VERSION}" echo "Use local is: ${USE_LOCAL}" if ${USE_LOCAL}; then - conda config --remove channels ${xspec_channel} + #conda config --remove channels ${xspec_channel} use_local="--use-local" else conda config --add channels ${xspec_channel} @@ -94,9 +94,10 @@ if [ -n "${XSPECVER}" ]; fi if [[ ${TRAVIS_PYTHON_VERSION} == 2.7 ]]; then - PKG="pytest<4 openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 ipopt<3.13 pygmo=2.11.4 emcee>=3 pandas>=0.23" + #PKG="pytest<4 openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 ipopt<3.13 pygmo=2.11.4 emcee>=3 pandas>=0.23 krb5=1.14.6" + PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23" else - PKG="pytest pandas>=0.23 ultranest interpolation>=2.1.5" + PKG="pytest>=3.6 pandas>=0.23 ultranest interpolation>=2.1.5" fi echo "dependencies: ${MATPLOTLIB} ${NUMPY} ${XSPEC}" @@ -112,13 +113,13 @@ conda config --add channels defaults conda config --add channels threeml -conda config --add channels conda-forge/label/cf201901 +#conda config --add channels conda-forge/label/cf201901 conda config --add channels conda-forge # Create test environment echo "Create test environment..." -conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy krb5=1.14.6 +conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy #openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 pygmo=2.11.4 "pytest<4" #libgfortran=${libgfortranver} @@ -127,8 +128,8 @@ conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PY # Activate test environment echo "Activate test environment..." -source $CONDA_PREFIX/etc/profile.d/conda.sh -#source $HOME/work/fermi/miniconda3/etc/profile.d/conda.sh +#source $CONDA_PREFIX/etc/profile.d/conda.sh +source $HOME/work/miniconda3/etc/profile.d/conda.sh conda activate $ENVNAME # Build package From 018e82fba62024dadd49408ccf77b5313ac225b8 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Oct 2020 11:29:30 -0700 Subject: [PATCH 05/18] Workaround to fix an issue with cfitsio/fermitools [ci skip] --- threeML/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/threeML/__init__.py b/threeML/__init__.py index 79e094210..1529c0d5c 100644 --- a/threeML/__init__.py +++ b/threeML/__init__.py @@ -17,6 +17,12 @@ mpl.use("Agg") +# Workaround to a CFITSIO issue +try: + import pyLikelihood +except ImportError: + pass + # Import version (this has to be placed before the import of serialization # since __version__ needs to be defined at that stage) from ._version import get_versions From 4850080eb9fab3ae8646449fe206aa5aac75c092 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Oct 2020 11:29:44 -0700 Subject: [PATCH 06/18] Moving towards pyyaml 5.1+ compatibility [ci skip] --- conda-dist/recipes/threeml/meta.yaml | 13 ++++++------- setup.cfg | 2 +- threeML/analysis_results.py | 2 +- threeML/config/config.py | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/conda-dist/recipes/threeml/meta.yaml b/conda-dist/recipes/threeml/meta.yaml index c9daa72fa..a7d94ae6c 100644 --- a/conda-dist/recipes/threeml/meta.yaml +++ b/conda-dist/recipes/threeml/meta.yaml @@ -29,7 +29,7 @@ requirements: #- astropy >=1.0.3 #- matplotlib - uncertainties - - pyyaml==3.13 + - pyyaml>=5.1 - dill - iminuit>=1.2 - astromodels @@ -50,22 +50,21 @@ requirements: #- ipython - ipyparallel - py - - tk==8.5.19 # [py2k] - - ipopt<3.13 # [py2k] + #- tk==8.5.19 # [py2k] + #- ipopt<3.13 # [py2k] - numdifftools - interpolation>=2.1.5 # [py3k] - run: - python - - numpy>=1.15,<1.16 # [py2k] + - numpy>=1.15 # [py2k] - numpy>=1.15 # [py3k] - scipy>=0.18 - emcee>=3 - astropy>=1.0.3 - matplotlib - uncertainties - - pyyaml==3.13 + - pyyaml>=5.1 - dill - iminuit>=1.2 - astromodels @@ -89,7 +88,7 @@ requirements: - pytest<4 # [py2k] - pytest # [py3k] - numexpr - - ipopt<3.13 # [py2k] + #- ipopt<3.13 # [py2k] - numdifftools #test: diff --git a/setup.cfg b/setup.cfg index 021ccbb92..848a31080 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ install_requires = astropy>=1.3.3 matplotlib uncertainties - pyyaml==3.13 + pyyaml>=5.1 dill iminuit>=1.2 astromodels diff --git a/threeML/analysis_results.py b/threeML/analysis_results.py index 30615b2af..339ee0c14 100644 --- a/threeML/analysis_results.py +++ b/threeML/analysis_results.py @@ -99,7 +99,7 @@ def _load_one_results(fits_extension): # Gather the optimized model serialized_model = _escape_back_yaml_from_fits(fits_extension.header.get("MODEL")) - model_dict = my_yaml.load(serialized_model) + model_dict = my_yaml.load(serialized_model, Loader=yaml.FullLoader) optimized_model = ModelParser(model_dict=model_dict).get_model() diff --git a/threeML/config/config.py b/threeML/config/config.py index e163d1309..6935bae8b 100644 --- a/threeML/config/config.py +++ b/threeML/config/config.py @@ -52,7 +52,7 @@ def __init__(self): try: - configuration = yaml.load(f) + configuration = yaml.load(f, Loader=yaml.FullLoader) except: @@ -87,7 +87,7 @@ def __init__(self): with open(user_config_path) as f: - configuration = yaml.load(f) + configuration = yaml.load(f, Loader=yaml.FullLoader) # Test if the local/configuration is ok From 06e6212878abf42a3adf5ec5507c9a192d24d83c Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Oct 2020 15:08:03 -0700 Subject: [PATCH 07/18] Typo fixed [ci skip] --- threeML/minimizer/ROOT_minimizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threeML/minimizer/ROOT_minimizer.py b/threeML/minimizer/ROOT_minimizer.py index 4b4a23b8e..e20909c38 100644 --- a/threeML/minimizer/ROOT_minimizer.py +++ b/threeML/minimizer/ROOT_minimizer.py @@ -41,7 +41,7 @@ #except AttributeError: # root_class = ROOT.Math.IMultiGenFunction -class FuncWrapper(root_math.IMultiGenFunction): +class FuncWrapper(ROOT.Math.IMultiGenFunction): def setup(self, function, dimensions): self.function = function From f1824407051c22c2a15e18a21b995e8cce290904 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Oct 2020 15:48:51 -0700 Subject: [PATCH 08/18] Trying to remove some requirement limit for py27 [ci skip] --- conda-dist/recipes/threeml/meta.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/conda-dist/recipes/threeml/meta.yaml b/conda-dist/recipes/threeml/meta.yaml index a7d94ae6c..56c4b96a4 100644 --- a/conda-dist/recipes/threeml/meta.yaml +++ b/conda-dist/recipes/threeml/meta.yaml @@ -22,8 +22,8 @@ requirements: - python #- setuptools #- toolchain - - numpy>=1.15,<1.16 # [py2k] - - numpy>=1.15 # [py3k] + #- numpy>=1.15,<1.16 # [py2k] + - numpy>=1.15 #- scipy >=0.18 - emcee>=3 #- astropy >=1.0.3 @@ -33,8 +33,8 @@ requirements: - dill - iminuit>=1.2 - astromodels - - astroquery<0.4 # [py2k] - - astroquery # [py3k] + #- astroquery<0.4 # [py2k] + - astroquery - corner>=1.0.2 #- corner #- pandas @@ -43,8 +43,8 @@ requirements: - pymultinest - ultranest # [py3k] - dynesty>=1 - - pygmo>=2.4,<=2.11.4 # [py2k] - - pygmo>=2.4 # [py3k] + #- pygmo>=2.4,<=2.11.4 # [py2k] + - pygmo>=2.4 - ipywidgets - numba #- ipython @@ -57,7 +57,7 @@ requirements: run: - python - - numpy>=1.15 # [py2k] + #- numpy>=1.15 # [py2k] - numpy>=1.15 # [py3k] - scipy>=0.18 - emcee>=3 @@ -68,8 +68,8 @@ requirements: - dill - iminuit>=1.2 - astromodels - - astroquery<0.4 # [py2k] - - astroquery # [py3k] + #- astroquery<0.4 # [py2k] + - astroquery - corner>=1.0.2 - pandas>=0.23 - requests @@ -77,8 +77,8 @@ requirements: - pymultinest - ultranest # [py3k] - dynesty>=1 - - pygmo>=2.4,<=2.11.4 # [py2k] - - pygmo>=2.4 # [py3k] + #- pygmo>=2.4,<=2.11.4 # [py2k] + - pygmo>=2.4 - ipywidgets - ipython - ipyparallel From 294e3cf56ea270234445b30627da4281e1702d1b Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Oct 2020 16:10:38 -0700 Subject: [PATCH 09/18] Reverting astroquery<4 dependency for py27 [ci skip] --- conda-dist/recipes/threeml/meta.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/conda-dist/recipes/threeml/meta.yaml b/conda-dist/recipes/threeml/meta.yaml index 56c4b96a4..3b4e68c29 100644 --- a/conda-dist/recipes/threeml/meta.yaml +++ b/conda-dist/recipes/threeml/meta.yaml @@ -22,7 +22,6 @@ requirements: - python #- setuptools #- toolchain - #- numpy>=1.15,<1.16 # [py2k] - numpy>=1.15 #- scipy >=0.18 - emcee>=3 @@ -33,8 +32,8 @@ requirements: - dill - iminuit>=1.2 - astromodels - #- astroquery<0.4 # [py2k] - - astroquery + - astroquery<0.4 # [py2k] + - astroquery # [py3k] - corner>=1.0.2 #- corner #- pandas @@ -51,13 +50,12 @@ requirements: - ipyparallel - py #- tk==8.5.19 # [py2k] - #- ipopt<3.13 # [py2k] + - ipopt<3.13 # [py2k] - numdifftools - interpolation>=2.1.5 # [py3k] run: - python - #- numpy>=1.15 # [py2k] - numpy>=1.15 # [py3k] - scipy>=0.18 - emcee>=3 @@ -68,8 +66,8 @@ requirements: - dill - iminuit>=1.2 - astromodels - #- astroquery<0.4 # [py2k] - - astroquery + - astroquery<0.4 # [py2k] + - astroquery # [py3k] - corner>=1.0.2 - pandas>=0.23 - requests @@ -88,7 +86,7 @@ requirements: - pytest<4 # [py2k] - pytest # [py3k] - numexpr - #- ipopt<3.13 # [py2k] + - ipopt<3.13 # [py2k] - numdifftools #test: From 0d51ef030d04a0c86858b0336ec8c8487ca4247f Mon Sep 17 00:00:00 2001 From: ndilalla Date: Thu, 15 Oct 2020 10:10:28 -0700 Subject: [PATCH 10/18] Minor [ci skip] --- build_local.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_local.sh b/build_local.sh index be34e17f6..7d3225bdf 100755 --- a/build_local.sh +++ b/build_local.sh @@ -128,8 +128,8 @@ conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PY # Activate test environment echo "Activate test environment..." -#source $CONDA_PREFIX/etc/profile.d/conda.sh -source $HOME/work/miniconda3/etc/profile.d/conda.sh +source $CONDA_PREFIX/etc/profile.d/conda.sh +#source $HOME/work/miniconda3/etc/profile.d/conda.sh conda activate $ENVNAME # Build package From 1ac02d87a7cd19e6780b24717eddc878c49ed298 Mon Sep 17 00:00:00 2001 From: omodei Date: Thu, 15 Oct 2020 14:23:53 -0700 Subject: [PATCH 11/18] fixed import for mac [ci skip] --- build_local.sh | 3 +-- threeML/__init__.py | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build_local.sh b/build_local.sh index 7d3225bdf..3c368f47f 100755 --- a/build_local.sh +++ b/build_local.sh @@ -56,10 +56,9 @@ then else # osx miniconda_os=MacOSX compilers="clang_osx-64 clangxx_osx-64 gfortran_osx-64" - # On macOS we also need the conda libx11 libraries used to build xspec # We also need to pin down ncurses, for now only on macos. - xorg="xorg-libx11 ncurses=5" + xorg="xorg-libx11" fi # Get the version in the __version__ environment variable diff --git a/threeML/__init__.py b/threeML/__init__.py index 1529c0d5c..16ecad476 100644 --- a/threeML/__init__.py +++ b/threeML/__init__.py @@ -18,6 +18,10 @@ mpl.use("Agg") # Workaround to a CFITSIO issue +try: + import ROOT +except ImportError: + pass try: import pyLikelihood except ImportError: From fc6bedd9842d79b2861de17c1d0e3e0c4ed340b9 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Thu, 15 Oct 2020 17:18:20 -0700 Subject: [PATCH 12/18] Sleep time increased to 10 sec [ci skip]. --- threeML/test/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threeML/test/conftest.py b/threeML/test/conftest.py index ef13bc4ff..9a3971cd7 100644 --- a/threeML/test/conftest.py +++ b/threeML/test/conftest.py @@ -21,7 +21,7 @@ def setup_ipcluster(): ipycluster_process = subprocess.Popen(["ipcluster", "start", "-n", "2"]) - time.sleep(5.0) + time.sleep(10.0) yield ipycluster_process From ca6cb47fa1f7da59cd618c99d81ecb105c91e8a1 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Thu, 15 Oct 2020 17:18:34 -0700 Subject: [PATCH 13/18] Script updated. --- ci/build_and_test.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ci/build_and_test.sh b/ci/build_and_test.sh index c8c2b1cf7..7581e4543 100755 --- a/ci/build_and_test.sh +++ b/ci/build_and_test.sh @@ -24,7 +24,7 @@ else # osx # On macOS we also need the conda libx11 libraries used to build xspec # We also need to pin down ncurses, for now only on macos. - xorg="xorg-libx11 ncurses=5" + xorg="xorg-libx11" fi @@ -39,10 +39,10 @@ echo "HOME= ${HOME}" echo "Building ${PKG_VERSION} ..." echo "Python version: ${TRAVIS_PYTHON_VERSION}" -libgfortranver="3.0" -NUMPYVER=1.15 +#libgfortranver="3.0" +#NUMPYVER=1.15 MATPLOTLIBVER=2 -XSPECVER="6.22.1" +XSPECVER="6.25" xspec_channel=xspecmodels echo "Building ${PKG_VERSION} ..." @@ -60,9 +60,9 @@ if [ -n "${XSPECVER}" ]; fi if [[ ${TRAVIS_PYTHON_VERSION} == 2.7 ]]; then - PKG="pytest<4 openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 ipopt<3.13 pygmo=2.11.4 emcee>=3 pandas>=0.23" + PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23" else - PKG="pytest pandas>=0.23 ultranest interpolation>=2.1.5" + PKG="pytest>=3.6 pandas>=0.23 ultranest interpolation>=2.1.5" fi echo "dependencies: ${MATPLOTLIB} ${NUMPY} ${XSPEC}" @@ -78,12 +78,12 @@ conda config --add channels defaults conda config --add channels threeml -conda config --add channels conda-forge/label/cf201901 +#conda config --add channels conda-forge/label/cf201901 conda config --add channels conda-forge # Create test environment -conda create --yes --name test_env -c conda-forge python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy krb5=1.14.6 +conda create --yes --name test_env -c conda-forge python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy if [[ "$TRAVIS_OS_NAME" == "removeme" ]]; then From a9d91a018c944df6c7a546c9246d23298c054045 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Fri, 16 Oct 2020 16:20:08 -0700 Subject: [PATCH 14/18] Script updated for py27. --- build_local.sh | 6 +++--- ci/build_and_test.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build_local.sh b/build_local.sh index 3c368f47f..ce15ee471 100755 --- a/build_local.sh +++ b/build_local.sh @@ -39,7 +39,7 @@ echo "Running on ${TRAVIS_OS_NAME}" TRAVIS_PYTHON_VERSION=3.7 export TRAVIS_BUILD_NUMBER=2 ENVNAME=threeML_test_$TRAVIS_PYTHON_VERSION -USE_LOCAL=true +USE_LOCAL=false # Environment libgfortranver="3.0" @@ -94,7 +94,7 @@ fi if [[ ${TRAVIS_PYTHON_VERSION} == 2.7 ]]; then #PKG="pytest<4 openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 ipopt<3.13 pygmo=2.11.4 emcee>=3 pandas>=0.23 krb5=1.14.6" - PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23" + PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23 ipopt<3.13 pyyaml=5.1" else PKG="pytest>=3.6 pandas>=0.23 ultranest interpolation>=2.1.5" fi @@ -118,7 +118,7 @@ conda config --add channels conda-forge # Create test environment echo "Create test environment..." -conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy +conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy numba #openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 pygmo=2.11.4 "pytest<4" #libgfortran=${libgfortranver} diff --git a/ci/build_and_test.sh b/ci/build_and_test.sh index 7581e4543..de971d8cc 100755 --- a/ci/build_and_test.sh +++ b/ci/build_and_test.sh @@ -60,7 +60,7 @@ if [ -n "${XSPECVER}" ]; fi if [[ ${TRAVIS_PYTHON_VERSION} == 2.7 ]]; then - PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23" + PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23 ipopt<3.13 pyyaml=5.1" else PKG="pytest>=3.6 pandas>=0.23 ultranest interpolation>=2.1.5" fi @@ -83,7 +83,7 @@ conda config --add channels threeml conda config --add channels conda-forge # Create test environment -conda create --yes --name test_env -c conda-forge python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy +conda create --yes --name test_env -c conda-forge python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy numba if [[ "$TRAVIS_OS_NAME" == "removeme" ]]; then From 78220b7cc110d97db7c51de149ec94cc512ce994 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Fri, 16 Oct 2020 16:54:47 -0700 Subject: [PATCH 15/18] Script updated for py27. --- build_local.sh | 4 ++-- ci/build_and_test.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build_local.sh b/build_local.sh index ce15ee471..4a1f364c0 100755 --- a/build_local.sh +++ b/build_local.sh @@ -94,7 +94,7 @@ fi if [[ ${TRAVIS_PYTHON_VERSION} == 2.7 ]]; then #PKG="pytest<4 openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 ipopt<3.13 pygmo=2.11.4 emcee>=3 pandas>=0.23 krb5=1.14.6" - PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23 ipopt<3.13 pyyaml=5.1" + PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23 ipopt<3.13 pyyaml" else PKG="pytest>=3.6 pandas>=0.23 ultranest interpolation>=2.1.5" fi @@ -118,7 +118,7 @@ conda config --add channels conda-forge # Create test environment echo "Create test environment..." -conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy numba +conda create --yes --name $ENVNAME -c conda-forge ${use_local} python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy #openblas-devel=0.3.6 tk=8.5.19 astroquery=0.3.10 pygmo=2.11.4 "pytest<4" #libgfortran=${libgfortranver} diff --git a/ci/build_and_test.sh b/ci/build_and_test.sh index de971d8cc..e49b43ef8 100755 --- a/ci/build_and_test.sh +++ b/ci/build_and_test.sh @@ -60,7 +60,7 @@ if [ -n "${XSPECVER}" ]; fi if [[ ${TRAVIS_PYTHON_VERSION} == 2.7 ]]; then - PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23 ipopt<3.13 pyyaml=5.1" + PKG="pytest<4 astroquery=0.3.10 pygmo=2.11.4 emcee>=3 pandas>=0.23 ipopt<3.13 pyyaml" else PKG="pytest>=3.6 pandas>=0.23 ultranest interpolation>=2.1.5" fi @@ -83,7 +83,7 @@ conda config --add channels threeml conda config --add channels conda-forge # Create test environment -conda create --yes --name test_env -c conda-forge python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy numba +conda create --yes --name test_env -c conda-forge python=$TRAVIS_PYTHON_VERSION ${PKG} codecov pytest-cov git ${MATPLOTLIB} ${NUMPY} ${XSPEC} astropy ${compilers} scipy if [[ "$TRAVIS_OS_NAME" == "removeme" ]]; then From 2cdd6df1e414b6a438e409fa1deceafb6c5336b7 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 20 Oct 2020 14:16:31 -0700 Subject: [PATCH 16/18] Added a flag to skip a couple of tests if ROOT is available. --- threeML/test/test__minimizers.py | 6 +++++- threeML/test/test_joint_likelihood_set.py | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/threeML/test/test__minimizers.py b/threeML/test/test__minimizers.py index e2ecfaeb3..38b21aaf1 100644 --- a/threeML/test/test__minimizers.py +++ b/threeML/test/test__minimizers.py @@ -38,6 +38,10 @@ not has_pygmo, reason="No pygmo available" ) +skip_if_ROOT_is_available = pytest.mark.skipif( + (not has_pygmo) or has_root, reason="ROOT is available. Skipping incompatible tests." +) + def check_results(fit_results): @@ -118,7 +122,7 @@ def test_pagmo(joint_likelihood_bn090217206_nai): do_analysis(joint_likelihood_bn090217206_nai, pagmo) -@skip_if_pygmo_is_not_available +@skip_if_ROOT_is_available def test_parallel_pagmo(joint_likelihood_bn090217206_nai): with parallel_computation(start_cluster=False): diff --git a/threeML/test/test_joint_likelihood_set.py b/threeML/test/test_joint_likelihood_set.py index 8356a7352..79d2c6420 100644 --- a/threeML/test/test_joint_likelihood_set.py +++ b/threeML/test/test_joint_likelihood_set.py @@ -2,6 +2,21 @@ from threeML import * from .conftest import get_grb_model +try: + + import ROOT + +except: + + has_root = False + +else: + + has_root = True + +skip_if_ROOT_is_available = pytest.mark.skipif( + has_root, reason="ROOT is available. Skipping incompatible tests." +) # Define a dummy function to return always the same model def get_model(id): @@ -19,7 +34,7 @@ def get_data(id): jlset.go(compute_covariance=False) - +@skip_if_ROOT_is_available def test_joint_likelihood_set_parallel(data_list_bn090217206_nai6): def get_data(id): return data_list_bn090217206_nai6 From a061e57e4318400d5635e9a3e27f8d98deaf323d Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 20 Oct 2020 14:48:34 -0700 Subject: [PATCH 17/18] Minor. --- conda-dist/recipes/threeml/meta.yaml | 4 ++-- threeML/test/test_joint_likelihood_set.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conda-dist/recipes/threeml/meta.yaml b/conda-dist/recipes/threeml/meta.yaml index 3b4e68c29..1396fce8c 100644 --- a/conda-dist/recipes/threeml/meta.yaml +++ b/conda-dist/recipes/threeml/meta.yaml @@ -31,7 +31,7 @@ requirements: - pyyaml>=5.1 - dill - iminuit>=1.2 - - astromodels + - astromodels>=2 - astroquery<0.4 # [py2k] - astroquery # [py3k] - corner>=1.0.2 @@ -65,7 +65,7 @@ requirements: - pyyaml>=5.1 - dill - iminuit>=1.2 - - astromodels + - astromodels>=2 - astroquery<0.4 # [py2k] - astroquery # [py3k] - corner>=1.0.2 diff --git a/threeML/test/test_joint_likelihood_set.py b/threeML/test/test_joint_likelihood_set.py index 79d2c6420..aa1266f43 100644 --- a/threeML/test/test_joint_likelihood_set.py +++ b/threeML/test/test_joint_likelihood_set.py @@ -1,4 +1,5 @@ from __future__ import print_function +import pytest from threeML import * from .conftest import get_grb_model From 2a97a35ca6a36a548daa4fec2d43c19885c32790 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Wed, 21 Oct 2020 10:20:45 -0700 Subject: [PATCH 18/18] Install script updated. --- ci/cron_install_and_test.sh | 28 ++++------------------------ install_3ML.sh | 32 +++++++++++--------------------- 2 files changed, 15 insertions(+), 45 deletions(-) diff --git a/ci/cron_install_and_test.sh b/ci/cron_install_and_test.sh index 8a8d9ea28..654b4d35e 100644 --- a/ci/cron_install_and_test.sh +++ b/ci/cron_install_and_test.sh @@ -22,34 +22,14 @@ elif (( $TRAVIS_BUILD_NUMBER % 4 == 1 )); then # Testing with xspec and root elif (( $TRAVIS_BUILD_NUMBER % 4 == 2 )); then - if [[ $TRAVIS_PYTHON_VERSION == "2.7" ]]; then - - echo "Testing with xspec-modelsonly and root with python $TRAVIS_PYTHON_VERSION" - bash install_3ML.sh --batch --with-xspec --with-root --python $TRAVIS_PYTHON_VERSION - - else - - echo "Root5 is not available for python 3." - echo "Cannot test with xspec-modelsonly and root. Exiting." - exit 0 - - fi + echo "Testing with xspec-modelsonly and root with python $TRAVIS_PYTHON_VERSION" + bash install_3ML.sh --batch --with-xspec --with-root --python $TRAVIS_PYTHON_VERSION # Testing with Fermi software else - if [[ $TRAVIS_PYTHON_VERSION == "2.7" ]]; then - - echo "Testing with xspec-modelsonly and Fermi software with python $TRAVIS_PYTHON_VERSION" - bash install_3ML.sh --batch --with-xspec --with-fermi --python $TRAVIS_PYTHON_VERSION - - else - - echo "Fermi tools are not available for python 3 yet." - echo "Cannot test with xspec-modelsonly and Fermi software. Exiting." - exit 0 - - fi + echo "Testing with xspec-modelsonly and Fermi software with python $TRAVIS_PYTHON_VERSION" + bash install_3ML.sh --batch --with-xspec --with-fermi --python $TRAVIS_PYTHON_VERSION fi diff --git a/install_3ML.sh b/install_3ML.sh index b71db2cb0..4b885fa44 100755 --- a/install_3ML.sh +++ b/install_3ML.sh @@ -264,35 +264,32 @@ conda config --add channels defaults conda config --add channels threeml -conda config --add channels conda-forge/label/cf201901 - conda config --add channels conda-forge -if [[ ${PYTHON_VERSION} == "2.7" ]]; then - conda config --add channels conda-forge/label/cf201901 -fi - -PACKAGES_TO_INSTALL="astromodels threeml" +PACKAGES_TO_INSTALL="astromodels>=2 threeml" if [[ "${INSTALL_XSPEC}" == "yes" ]]; then - PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} xspec-modelsonly=6.22.1" + PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} xspec-modelsonly=6.25" conda config --add channels xspecmodels fi if [[ "${INSTALL_ROOT}" == "yes" ]]; then - PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} root5" + PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} root" fi if [[ "${INSTALL_FERMI}" == "yes" ]]; then - PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} fermitools fermipy" - - #conda config --add channels conda-forge/label/cf201901 - conda config --add channels fermi + if [[ $PYTHON_VERSION == "2.7" ]]; then + conda config --add channels fermi/label/master + PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} clhep=2.4.1.0" + else + conda config --add channels fermi + fi + PACKAGES_TO_INSTALL="${PACKAGES_TO_INSTALL} fermitools" fi @@ -483,14 +480,7 @@ EOM conda activate ${ENV_NAME} # Fix needed to solve the "readinto" AttributeError due to older future package -conda install --yes -c conda-forge future - -# Workaround needed to meet the requirement on ccfits on linux systems -if [[ "$os_guessed" == "linux" ]] && [[ "${INSTALL_XSPEC}" == "yes" ]]; then - conda install --yes -c conda-forge ccfits=2.5 -elif [[ "$os_guessed" == "osx" ]] && [[ "${INSTALL_XSPEC}" == "yes" ]]; then - conda install --yes -c conda-forge/label/cf201901 ccfits=2.5 -fi +#conda install --yes -c conda-forge future mv activate.csh $CONDA_PREFIX/bin mv deactivate.csh $CONDA_PREFIX/bin