Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating numpy compatibility #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Tests
on:
push:
branches:
- master
- main
- checks
pull_request:
branches:
- master
- main

jobs:
changes:
Expand All @@ -34,27 +34,27 @@ 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:
python-version: ["3.6", "3.7"]
python-version: ["3.9", "3.10"]
fast-compile: [0]
float32: [0]
part:
Expand All @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -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: |
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 11 additions & 35 deletions theano/link/c/cmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import warnings
from io import BytesIO, StringIO

import numpy.distutils
import numpy as np

import theano

Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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 <bound method
# Popen.__del__ of <subprocess.Popen object at 0x21359d0>>
# 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:
Expand All @@ -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
Expand All @@ -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."
)
Expand Down Expand Up @@ -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
Expand All @@ -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":
Expand All @@ -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)

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion theano/scalar/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}"
Expand Down
3 changes: 1 addition & 2 deletions theano/tensor/blas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down