From eab8f4a9fa36f836c62008108a18a4db2b8195f1 Mon Sep 17 00:00:00 2001 From: Dan F-M Date: Wed, 26 Jul 2023 07:42:25 -0400 Subject: [PATCH 1/3] Updating numpy compatibility --- .github/workflows/test.yml | 4 ++-- setup.py | 12 +++++----- theano/link/c/cmodule.py | 46 +++++++++----------------------------- theano/scalar/basic.py | 2 +- theano/tensor/blas.py | 3 +-- 5 files changed, 21 insertions(+), 46 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1f0815fbd..ef6eac6a95 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,11 +3,11 @@ name: Tests on: push: branches: - - master + - main - checks pull_request: branches: - - master + - main jobs: changes: diff --git a/setup.py b/setup.py index 5415f1f259..b3831ff6f0 100755 --- a/setup.py +++ b/setup.py @@ -9,17 +9,17 @@ def read_file(filename): return buff.read() -NAME = "Theano-PyMC" -MAINTAINER = "PyMC developers" -MAINTAINER_EMAIL = "pymc-devs@gmail.com" +NAME = "theano-exoplanet" +MAINTAINER = "Dan Foreman-Mackey" +MAINTAINER_EMAIL = "dfm@dfm.io" DESCRIPTION = ( "Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs." ) LONG_DESCRIPTION = read_file("DESCRIPTION.txt") -URL = "http://deeplearning.net/software/theano/" +URL = "https://github.com/exoplanet-dev/theano-exoplanet" LICENSE = "BSD" -AUTHOR = "pymc-devs" -AUTHOR_EMAIL = "pymc-devs@gmail.com" +AUTHOR = "Dan Foreman-Mackey" +AUTHOR_EMAIL = "dfm@dfm.io" PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"] CLASSIFIERS = """\ Development Status :: 6 - Mature diff --git a/theano/link/c/cmodule.py b/theano/link/c/cmodule.py index ba1174ba11..aca9d14bc9 100644 --- a/theano/link/c/cmodule.py +++ b/theano/link/c/cmodule.py @@ -20,7 +20,7 @@ import warnings from io import BytesIO, StringIO -import numpy.distutils +import numpy as np import theano @@ -1632,7 +1632,7 @@ def get_gcc_shared_library_arg(): def std_include_dirs(): - numpy_inc_dirs = numpy.distutils.misc_util.get_numpy_include_dirs() + numpy_inc_dirs = [np.get_include()] py_inc = distutils.sysconfig.get_python_inc() py_plat_spec_inc = distutils.sysconfig.get_python_inc(plat_specific=True) python_inc_dirs = ( @@ -2611,32 +2611,9 @@ def default_blas_ldflags(): str """ - import numpy.distutils # noqa - warn_record = [] try: - if hasattr(numpy.distutils, "__config__") and numpy.distutils.__config__: - # If the old private interface is available use it as it - # don't print information to the user. - blas_info = numpy.distutils.__config__.blas_opt_info - else: - # We do this import only here, as in some setup, if we - # just import theano and exit, with the import at global - # scope, we get this error at exit: "Exception TypeError: - # "'NoneType' object is not callable" in > - # ignored" - - # This happen with Python 2.7.3 |EPD 7.3-1 and numpy 1.8.1 - # isort: off - import numpy.distutils.system_info # noqa - - # We need to catch warnings as in some cases NumPy print - # stuff that we don't want the user to see. - # I'm not able to remove all printed stuff - with warnings.catch_warnings(record=True): - numpy.distutils.system_info.system_info.verbosity = 0 - blas_info = numpy.distutils.system_info.get_info("blas_opt") + blas_info = np.__config__.get_info("blas_opt") # If we are in a EPD installation, mkl is available if "EPD" in sys.version: @@ -2648,7 +2625,7 @@ def default_blas_ldflags(): # Why on Windows, the library used are not the # same as what is in # blas_info['libraries']? - [f"-l{l}" for l in ["mk2_core", "mk2_intel_thread", "mk2_rt"]] + [f"-l{l}" for l in ("mk2_core", "mk2_intel_thread", "mk2_rt")] ) elif sys.platform == "darwin": # The env variable is needed to link with mkl @@ -2669,7 +2646,7 @@ def default_blas_ldflags(): "The environment variable " "'DYLD_FALLBACK_LIBRARY_PATH' does not contain " "the '{new_path}' path in its value. This will make " - "Theano use a slow version of BLAS. Update " + "Aesara use a slow version of BLAS. Update " "'DYLD_FALLBACK_LIBRARY_PATH' to contain the " "said value, this will disable this warning." ) @@ -2721,7 +2698,7 @@ def default_blas_ldflags(): + # Why on Windows, the library used are not the # same as what is in blas_info['libraries']? - [f"-l{l}" for l in ["mk2_core", "mk2_intel_thread", "mk2_rt"]] + [f"-l{l}" for l in ("mk2_core", "mk2_intel_thread", "mk2_rt")] ) # MKL @@ -2731,9 +2708,8 @@ def default_blas_ldflags(): # numpy and scipy. try: import mkl # noqa - except ImportError as e: - if any([m for m in ("conda", "Continuum") if m in sys.version]): - warn_record.append(f"install mkl with `conda install mkl-service`: {e}") + except ImportError: + pass else: # This branch is executed if no exception was raised if sys.platform == "win32": @@ -2749,13 +2725,13 @@ def default_blas_ldflags(): else: thr = "mkl_intel_thread" base_flags = list(flags) - flags += [f"-l{l}" for l in ["mkl_core", thr, "mkl_rt"]] + flags += [f"-l{l}" for l in ("mkl_core", thr, "mkl_rt")] res = try_blas_flag(flags) if not res and sys.platform == "win32" and thr == "mkl_gnu_thread": # Check if it would work for intel OpenMP on windows flags = base_flags + [ - f"-l{l}" for l in ["mkl_core", "mkl_intel_thread", "mkl_rt"] + f"-l{l}" for l in ("mkl_core", "mkl_intel_thread", "mkl_rt") ] res = try_blas_flag(flags) @@ -2767,7 +2743,7 @@ def default_blas_ldflags(): res = try_blas_flag(flags) if res: check_mkl_openmp() - theano.utils.maybe_add_to_os_environ_pathlist("PATH", lib_path[0]) + maybe_add_to_os_environ_pathlist("PATH", lib_path[0]) return res # to support path that includes spaces, we need to wrap it with double quotes on Windows diff --git a/theano/scalar/basic.py b/theano/scalar/basic.py index 9e27be4d88..62567b29e3 100644 --- a/theano/scalar/basic.py +++ b/theano/scalar/basic.py @@ -2409,7 +2409,7 @@ def __init__(self, o_type, name=None): raise TypeError(o_type) super().__init__(specific_out(o_type), name=name) self.o_type = o_type - self.ctor = getattr(np, o_type.dtype) + self.ctor = np.dtype(o_type.dtype).type def __str__(self): return f"{self.__class__.__name__}{{{self.o_type.dtype}}}" diff --git a/theano/tensor/blas.py b/theano/tensor/blas.py index 77d54e899f..76b903bb53 100644 --- a/theano/tensor/blas.py +++ b/theano/tensor/blas.py @@ -131,11 +131,10 @@ import time import numpy as np -import numpy.distutils try: - import numpy.distutils.__config__ # noqa + import numpy.__config__ # noqa except ImportError: pass From 1f21ffe3523018a91ca2f36a2aad708d96492945 Mon Sep 17 00:00:00 2001 From: Dan F-M Date: Wed, 26 Jul 2023 07:46:07 -0400 Subject: [PATCH 2/3] updating test workflow --- .github/workflows/test.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef6eac6a95..8014b7daec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,23 +34,23 @@ jobs: - 'requirements.txt' - '.coveragerc' - style: - name: Check code style - needs: changes - runs-on: ubuntu-latest - if: ${{ needs.changes.outputs.changes == 'true' }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.0 + # style: + # name: Check code style + # needs: changes + # runs-on: ubuntu-latest + # if: ${{ needs.changes.outputs.changes == 'true' }} + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-python@v2 + # - uses: pre-commit/action@v2.0.0 test: name: "Test py${{ matrix.python-version }}: ${{ matrix.part }}" needs: - changes - - style + # - style runs-on: ubuntu-latest - if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }} + # if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }} strategy: fail-fast: true matrix: @@ -151,10 +151,10 @@ jobs: if: ${{ always() }} runs-on: ubuntu-latest name: "All tests" - needs: [changes, style, test] + needs: [changes, test] steps: - name: Check build matrix status - if: ${{ needs.changes.outputs.changes == 'true' && (needs.style.result != 'success' || needs.test.result != 'success') }} + if: ${{ needs.changes.outputs.changes == 'true' && needs.test.result != 'success' }} run: exit 1 upload-coverage: From 52177c2b9f88ce44d38f6a0810920577449e33cd Mon Sep 17 00:00:00 2001 From: Dan F-M Date: Wed, 26 Jul 2023 07:48:41 -0400 Subject: [PATCH 3/3] updating python versions for tests --- .github/workflows/test.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8014b7daec..b02fe4f2c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.6", "3.7"] + python-version: ["3.9", "3.10"] fast-compile: [0] float32: [0] part: @@ -65,27 +65,27 @@ jobs: - "tests/tensor/nnet --ignore-glob='*/test_abstract_conv.py'" - "tests/tensor/nnet/test_abstract_conv.py" include: - - python-version: "3.7" + - python-version: "3.10" fast-compile: 1 float32: 1 part: "tests --ignore=tests/tensor/nnet --ignore=tests/tensor/signal" - - python-version: "3.7" + - python-version: "3.10" fast-compile: 1 float32: 0 part: "tests --ignore=tests/tensor/nnet --ignore=tests/tensor/signal" - - python-version: "3.7" + - python-version: "3.10" fast-compile: 1 float32: 1 part: "tests/tensor/nnet" - - python-version: "3.7" + - python-version: "3.10" fast-compile: 1 float32: 0 part: "tests/tensor/nnet" - - python-version: "3.7" + - python-version: "3.10" fast-compile: 1 float32: 1 part: "tests/tensor/signal" - - python-version: "3.7" + - python-version: "3.10" fast-compile: 1 float32: 0 part: "tests/tensor/signal" @@ -168,7 +168,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: "3.10" - name: Install dependencies run: |