Merge pull request #1073 from SheffieldML/1056-test-with-python-2-style-print-statements

remove python2-styled print statements
This commit is contained in:
Martin Bubel 2024-05-29 23:40:01 +02:00 committed by GitHub
commit 2932e9df2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 132 additions and 124 deletions

View file

@ -2,6 +2,8 @@
## Unreleased ## Unreleased
* remove python2-style print statements (#1056)
* update import in `.plotting.matplot_dep.defaults` due to change in matplotlib * update import in `.plotting.matplot_dep.defaults` due to change in matplotlib
* Correct dl_dm term in student t inference #1065 * Correct dl_dm term in student t inference #1065

View file

@ -23,11 +23,11 @@ infr = GPy.inference.latent_function_inference.VarDTC_minibatch(mpi_comm=comm)
m = GPy.models.BayesianGPLVM(data.T,1,mpi_comm=comm) m = GPy.models.BayesianGPLVM(data.T,1,mpi_comm=comm)
m.optimize(max_iters=10) m.optimize(max_iters=10)
if comm.rank==0: if comm.rank==0:
print float(m.objective_function()) print(float(m.objective_function()))
m.inference_method.mpi_comm=None m.inference_method.mpi_comm=None
m.mpi_comm=None m.mpi_comm=None
m._trigger_params_changed() m._trigger_params_changed()
print float(m.objective_function()) print(float(m.objective_function()))
""" """
with open("mpi_test__.py", "w") as f: with open("mpi_test__.py", "w") as f:
f.write(code) f.write(code)
@ -59,11 +59,11 @@ data = np.vstack([x,y])
m = GPy.models.SparseGPRegression(data[:1].T,data[1:2].T,mpi_comm=comm) m = GPy.models.SparseGPRegression(data[:1].T,data[1:2].T,mpi_comm=comm)
m.optimize(max_iters=10) m.optimize(max_iters=10)
if comm.rank==0: if comm.rank==0:
print float(m.objective_function()) print(float(m.objective_function()))
m.inference_method.mpi_comm=None m.inference_method.mpi_comm=None
m.mpi_comm=None m.mpi_comm=None
m._trigger_params_changed() m._trigger_params_changed()
print float(m.objective_function()) print(float(m.objective_function()))
""" """
with open("mpi_test__.py", "w") as f: with open("mpi_test__.py", "w") as f:
f.write(code) f.write(code)

View file

@ -1,11 +1,11 @@
import numpy as np import numpy as np
import GPy import GPy
from mpi4py import MPI from mpi4py import MPI
np.random.seed(123456) np.random.seed(123456)
comm = MPI.COMM_WORLD comm = MPI.COMM_WORLD
N = 100 N = 100
x = np.linspace(-6., 6., N) x = np.linspace(-6.0, 6.0, N)
y = np.sin(x) + np.random.randn(N) * 0.05 y = np.sin(x) + np.random.randn(N) * 0.05
comm.Bcast(y) comm.Bcast(y)
data = np.vstack([x, y]) data = np.vstack([x, y])
@ -13,9 +13,8 @@ data = np.vstack([x,y])
m = GPy.models.SparseGPRegression(data[:1].T, data[1:2].T, mpi_comm=comm) m = GPy.models.SparseGPRegression(data[:1].T, data[1:2].T, mpi_comm=comm)
m.optimize(max_iters=10) m.optimize(max_iters=10)
if comm.rank == 0: if comm.rank == 0:
print float(m.objective_function()) print(float(m.objective_function()))
m.inference_method.mpi_comm = None m.inference_method.mpi_comm = None
m.mpi_comm = None m.mpi_comm = None
m._trigger_params_changed() m._trigger_params_changed()
print float(m.objective_function()) print(float(m.objective_function()))

View file

@ -21,24 +21,26 @@ import shlex
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
# for p in os.walk('../../GPy'): # for p in os.walk('../../GPy'):
# sys.path.append(p[0]) # sys.path.append(p[0])
sys.path.insert(0, os.path.abspath('../../')) sys.path.insert(0, os.path.abspath("../../"))
sys.path.insert(0, os.path.abspath('../../GPy/')) sys.path.insert(0, os.path.abspath("../../GPy/"))
on_rtd = os.environ.get('READTHEDOCS', None) == 'True' on_rtd = os.environ.get("READTHEDOCS", None) == "True"
import sys import sys
from unittest.mock import MagicMock from unittest.mock import MagicMock
class Mock(MagicMock): class Mock(MagicMock):
@classmethod @classmethod
def __getattr__(cls, name): def __getattr__(cls, name):
return MagicMock() return MagicMock()
MOCK_MODULES = [ MOCK_MODULES = [
"GPy.util.linalg.linalg_cython", "GPy.util.linalg.linalg_cython",
"GPy.util.linalg_cython", "GPy.util.linalg_cython",
"sympy", "sympy",
'GPy.kern.stationary_cython', "GPy.kern.stationary_cython",
"sympy.utilities", "sympy.utilities",
"sympy.utilities.lambdify", "sympy.utilities.lambdify",
] ]
@ -64,7 +66,9 @@ if on_rtd:
print(out) print(out)
# Lets regenerate our rst files from the source, -P adds private modules (i.e kern._src) # Lets regenerate our rst files from the source, -P adds private modules (i.e kern._src)
proc = subprocess.Popen("sphinx-apidoc -M -P -f -o . ../../GPy", stdout=subprocess.PIPE, shell=True) proc = subprocess.Popen(
"sphinx-apidoc -M -P -f -o . ../../GPy", stdout=subprocess.PIPE, shell=True
)
(out, err) = proc.communicate() (out, err) = proc.communicate()
print("$ Apidoc:") print("$ Apidoc:")
print(out) print(out)
@ -79,12 +83,12 @@ if on_rtd:
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = [
'sphinx.ext.autodoc', "sphinx.ext.autodoc",
#'sphinx.ext.coverage', #'sphinx.ext.coverage',
'sphinx.ext.mathjax', "sphinx.ext.mathjax",
'sphinx.ext.viewcode', "sphinx.ext.viewcode",
'sphinx.ext.graphviz', "sphinx.ext.graphviz",
'sphinx.ext.inheritance_diagram', "sphinx.ext.inheritance_diagram",
] ]
# ---sphinx.ext.inheritance_diagram config # ---sphinx.ext.inheritance_diagram config
@ -107,14 +111,16 @@ inheritance_graph_attrs = dict(rankdir="LR", dpi=1200)
# #
import sphinx_rtd_theme import sphinx_rtd_theme
autodoc_default_flags = ['members', autodoc_default_flags = [
"members",
#'undoc-members', #'undoc-members',
#'private-members', #'private-members',
#'special-members', #'special-members',
#'inherited-members', #'inherited-members',
'show-inheritance'] "show-inheritance",
]
autodoc_member_order = 'groupwise' autodoc_member_order = "groupwise"
add_function_parentheses = False add_function_parentheses = False
add_module_names = False add_module_names = False
# modindex_common_prefix = ['GPy'] # modindex_common_prefix = ['GPy']
@ -122,35 +128,37 @@ show_authors = True
# ------ Sphinx # ------ Sphinx
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]#templates_path = ['_templates'] html_theme_path = [
sphinx_rtd_theme.get_html_theme_path()
] # templates_path = ['_templates']
# The suffix(es) of source filenames. # The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string: # You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md'] # source_suffix = ['.rst', '.md']
source_suffix = '.rst' source_suffix = ".rst"
# The encoding of source files. # The encoding of source files.
# source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = "index"
# General information about the project. # General information about the project.
project = u'GPy' project = "GPy"
# author = u'`Humans <https://github.com/SheffieldML/GPy/graphs/contributors>`_' # author = u'`Humans <https://github.com/SheffieldML/GPy/graphs/contributors>`_'
author = 'GPy Authors, see https://github.com/SheffieldML/GPy/graphs/contributors' author = "GPy Authors, see https://github.com/SheffieldML/GPy/graphs/contributors"
copyright = u'2020, '+author copyright = "2020, " + author
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
with open('../../GPy/__version__.py', 'r') as f: with open("../../GPy/__version__.py", "r") as f:
version = f.read() version = f.read()
release = version release = version
print version print(version)
# version = '0.8.8' # version = '0.8.8'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
@ -161,20 +169,22 @@ print version
# #
# This is also used if you do content translation via gettext catalogs. # This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases. # Usually you set "language" from the command line for these cases.
language = 'python' language = "python"
# autodoc: # autodoc:
autoclass_content = 'both' autoclass_content = "both"
autodoc_default_flags = ['members', autodoc_default_flags = [
"members",
#'undoc-members', #'undoc-members',
#'private-members', #'private-members',
#'special-members', #'special-members',
#'inherited-members', #'inherited-members',
'show-inheritance'] "show-inheritance",
autodoc_member_order = 'groupwise' ]
autodoc_member_order = "groupwise"
add_function_parentheses = False add_function_parentheses = False
add_module_names = False add_module_names = False
modindex_common_prefix = ['paramz'] modindex_common_prefix = ["paramz"]
show_authors = True show_authors = True
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
@ -203,7 +213,7 @@ exclude_patterns = []
# show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
# modindex_common_prefix = [] # modindex_common_prefix = []
@ -219,7 +229,7 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
html_theme = 'sphinx_rtd_theme' html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
@ -248,10 +258,10 @@ html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ["_static"]
html_css_files = [ html_css_files = [
'wide.css', "wide.css",
] ]
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
@ -317,22 +327,19 @@ html_show_sourcelink = True
# html_search_scorer = 'scorer.js' # html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'GPydoc' htmlhelp_basename = "GPydoc"
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper', "papersize": "a4paper",
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt', #'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#'preamble': '', #'preamble': '',
# Latex figure (float) alignment # Latex figure (float) alignment
'figure_align': 'htbp', "figure_align": "htbp",
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples