From 3b7356227a343ba696920b61d15daa58551a7509 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Fri, 19 Jan 2024 16:03:33 +0100 Subject: [PATCH] Cleanup --- .github/workflows/lint.yml | 2 +- doc/beam_wrapper.rst | 3 +- doc/conf.py | 158 +++++++++++++++---------------- doc/examples.rst | 3 +- doc/getting_started.rst | 3 +- otwrapy/__init__.py | 3 - otwrapy/_otwrapy.py | 3 - otwrapy/examples/beam/wrapper.py | 4 - setup.py | 6 +- tests/test_wrapper.py | 10 +- 10 files changed, 96 insertions(+), 99 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e39a359..e00e6ae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,5 +17,5 @@ jobs: - name: Run linter run: | flake8 otwrapy --ignore=W503 --max-line-length 130 - #doc8 doc/ --max-line-length=130 + doc8 doc/ --max-line-length=130 diff --git a/doc/beam_wrapper.rst b/doc/beam_wrapper.rst index 9fc43cc..e0840c7 100644 --- a/doc/beam_wrapper.rst +++ b/doc/beam_wrapper.rst @@ -16,4 +16,5 @@ Beam wrapper .. automethod:: _exec .. automethod:: _create_input_file .. automethod:: _call() - .. automethod:: _parse_output \ No newline at end of file + .. automethod:: _parse_output + diff --git a/doc/conf.py b/doc/conf.py index 8c01be4..2a0820d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,32 +1,27 @@ -# -*- coding: utf-8 -*- - +import alabaster import sys import os -from distutils.version import LooseVersion -import sphinx # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('../')) +sys.path.insert(0, os.path.abspath("../")) # -- General configuration ------------------------------------------------ extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.todo', - 'sphinx.ext.intersphinx', - 'sphinx.ext.autosummary', - 'numpydoc', + "sphinx.ext.autodoc", + "sphinx.ext.todo", + "sphinx.ext.intersphinx", + "sphinx.ext.autosummary", + "numpydoc", ] -if LooseVersion(sphinx.__version__) >= '1.8': - autodoc_default_options = {'members': None, 'inherited-members': None} -else: - autodoc_default_flags = ['members', 'inherited-members'] - +autodoc_default_options = {"members": None, "inherited-members": None} -intersphinx_mapping = {'openturns': ('http://openturns.github.io/openturns/latest/', None)} +intersphinx_mapping = { + "openturns": ("http://openturns.github.io/openturns/latest/", None) +} autosummary_generate = True numpydoc_show_class_members = True @@ -34,18 +29,17 @@ # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'otwrapy' -copyright = u'2015-2019 Phimeca' -author = u'Felipe Aguirre Martinez' +project = "otwrapy" +copyright = "2015-2024 Phimeca" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -57,7 +51,7 @@ add_module_names = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'friendly' +pygments_style = "friendly" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True @@ -65,106 +59,104 @@ # -- Options for HTML output ---------------------------------------------- -import alabaster html_theme_path = [alabaster.get_path()] -html_theme = 'alabaster' +html_theme = "alabaster" html_sidebars = { - '**': [ - 'about.html', - 'navigation.html', - 'relations.html', - 'searchbox.html', - 'donate.html', + "**": [ + "about.html", + "navigation.html", + "relations.html", + "searchbox.html", + "donate.html", ] } html_theme_options = { - 'logo': 'LogoPhiHaut.png', - 'logo_name': 'otwrapy', - 'description': 'Collection of tools that simplify the task of wrapping ' + - 'external codes in a Python environment. ' + - 'Proudly developed at ' + - 'Phimeca', - 'github_user': 'openturns', - 'github_repo': 'otwrapy', - 'github_banner': True, - 'show_related': True, - 'analytics_id': 'UA-76867657-1' + "logo": "LogoPhiHaut.png", + "logo_name": "otwrapy", + "description": "Collection of tools that simplify the task of wrapping " + + "external codes in a Python environment. " + + "Proudly developed at " + + 'Phimeca', + "github_user": "openturns", + "github_repo": "otwrapy", + "github_banner": True, + "show_related": True, + "analytics_id": "UA-76867657-1", } # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = '_static/Icon.ico' +html_favicon = "_static/Icon.ico" # 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, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -html_last_updated_fmt = '%b %d, %Y' +html_last_updated_fmt = "%b %d, %Y" # Output file base name for HTML help builder. -htmlhelp_basename = 'otwrapydoc' +htmlhelp_basename = "otwrapydoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -'papersize': 'a4paper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', - -# Latex figure (float) alignment -#'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + "papersize": "a4paper", + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). +# author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'otwrapydoc.tex', u'otwrapy Documentation', - u'Felipe Aguirre Martinez', 'manual'), + ( + master_doc, + "otwrapydoc.tex", + "otwrapy Documentation", + "Felipe Aguirre Martinez", + "manual", + ), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'otwrapydoc', u'otwrapy Documentation', - [author], 1) -] +# man_pages = [(master_doc, "otwrapydoc", "otwrapy Documentation", 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -172,20 +164,26 @@ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'otwrapydoc', u'otwrapy Documentation', - author, 'otwrapy', 'One line description of project.', - 'Miscellaneous'), -] +# texinfo_documents = [ +# ( +# master_doc, +# "otwrapydoc", +# "otwrapy Documentation", +# author, +# "otwrapy", +# "One line description of project.", +# "Miscellaneous", +# ), +# ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False diff --git a/doc/examples.rst b/doc/examples.rst index 3eb8752..6896fb1 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -8,4 +8,5 @@ Examples .. toctree:: :maxdepth: 3 - beam_wrapper.rst \ No newline at end of file + beam_wrapper.rst + diff --git a/doc/getting_started.rst b/doc/getting_started.rst index 3ac1f2f..c236b75 100644 --- a/doc/getting_started.rst +++ b/doc/getting_started.rst @@ -44,4 +44,5 @@ In which case, `model` will be your parallelized :py:class:`openturns.Function` machine (`n_cpus=-1`). For further information, refer to the :doc:`api`. -Or you can simply consider this as a cookbook and take what you consider useful. In which case, I suggest reading the :doc:`examples` section +Or you can simply consider this as a cookbook and take what you consider useful. +In which case, I suggest reading the :doc:`examples` section diff --git a/otwrapy/__init__.py b/otwrapy/__init__.py index 975c1d2..7a289b7 100644 --- a/otwrapy/__init__.py +++ b/otwrapy/__init__.py @@ -6,10 +6,7 @@ import os -__author__ = "Felipe Aguirre Martinez" -__copyright__ = "Copyright 2015-2024 Phimeca" __version__ = "0.12.1" -__email__ = "aguirre@phimeca.fr" base_dir = os.path.dirname(__file__) diff --git a/otwrapy/_otwrapy.py b/otwrapy/_otwrapy.py index 6288362..cce2b66 100644 --- a/otwrapy/_otwrapy.py +++ b/otwrapy/_otwrapy.py @@ -14,9 +14,6 @@ import numpy as np from tqdm import tqdm -__author__ = "Felipe Aguirre Martinez" -__copyright__ = "Copyright 2015-2019 Phimeca" -__email__ = "aguirre@phimeca.fr" __all__ = ['load_array', 'dump_array', '_exec_sample_joblib', '_exec_sample_multiprocessing', '_exec_sample_ipyparallel', '_exec_sample_pathos', '_exec_sample_dask', diff --git a/otwrapy/examples/beam/wrapper.py b/otwrapy/examples/beam/wrapper.py index fb4135d..46344c0 100644 --- a/otwrapy/examples/beam/wrapper.py +++ b/otwrapy/examples/beam/wrapper.py @@ -13,10 +13,6 @@ ot.ResourceMap.SetAsUnsignedInteger('Cache-MaxSize', int(1e6)) -__author__ = "Felipe Aguirre Martinez" -__copyright__ = "Copyright 2015-2019 Phimeca" -__version__ = "0.2" -__email__ = "aguirre@phimeca.fr" __all__ = ['Wrapper'] diff --git a/setup.py b/setup.py index 4a70b2e..c2a258f 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- from setuptools import setup, find_packages - # To use a consistent encoding +# To use a consistent encoding from codecs import open from os import path @@ -32,8 +31,7 @@ 'dask': ["dask>=2021.01.0", "asyncssh"] }, install_requires=["tqdm>=4.0.0"], - author="Felipe Aguirre Martinez", - author_email="aguirre@phimeca.com", + author="Phimeca", description="General purpose OpenTURNS python wrapper tools", long_description=long_description, setup_requires=['pytest-runner'], diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index c278b5f..20f32b2 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -4,6 +4,7 @@ import multiprocessing import pytest + def backendtest(backend): ot.RandomGenerator.SetSeed(0) n_cpu = multiprocessing.cpu_count() @@ -17,28 +18,35 @@ def backendtest(backend): dask_args = {'scheduler': 'localhost', 'workers': {'localhost': n_cpu}} else: dask_args = None - model_parallel = otw.Parallelizer(model, backend=backend, n_cpus=n_cpu, dask_args=dask_args) + model_parallel = otw.Parallelizer(model, backend=backend, + n_cpus=n_cpu, dask_args=dask_args) for size in sizes: X_sample = X_distribution.getSample(size) Y_ref = model(X_sample) Y_sample = ot.Sample(model_parallel(X_sample)) assert Y_ref == Y_sample, 'samples do not match' + def test_serial(): backendtest('serial') + def test_joblib(): backendtest('joblib') + def test_multiprocessing(): backendtest('multiprocessing') + def test_ipython(): backendtest('ipython') + def test_pathos(): backendtest('pathos') + @pytest.mark.skip(reason="needs passwordless ssh configuration") def test_dask(): backendtest('dask')