diff --git a/doc/conf.py b/doc/conf.py index 8a0a6972bb0efeb0480dd2d3ed37b2b7153c4929..c21a31aeef74282c01a6b7e3b0b0c13e2cff40e0 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,44 +18,44 @@ import shlex # noqa # 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 ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +#needs_sphinx = "1.0" # Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# extensions coming with Sphinx (named "sphinx.ext.*") or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.mathjax', - 'sphinx.ext.viewcode', + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.intersphinx", + "sphinx.ext.mathjax", + "sphinx.ext.viewcode", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +# source_suffix = [".rst", ".md"] +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +#source_encoding = "utf-8-sig" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'grudge' -copyright = '2015, Andreas Kloeckner' -author = 'Andreas Kloeckner' +project = "grudge" +copyright = "2015, Andreas Kloeckner" +author = "Andreas Kloeckner" -# 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 # built documents. # @@ -66,10 +66,11 @@ def get_version(): conf = {} src = "../grudge/version.py" exec( - compile(open(src).read(), src, 'exec'), + compile(open(src).read(), src, "exec"), conf) return conf["VERSION_TEXT"] + version = get_version() # The full version, including alpha/beta/rc tags. @@ -84,19 +85,19 @@ language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +#today = "" # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +#today_fmt = "%B %d, %Y" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None -# If true, '()' will be appended to :func: etc. cross-reference text. +# If true, "()" will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description @@ -108,7 +109,7 @@ exclude_patterns = ['_build'] #show_authors = False # 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. #modindex_common_prefix = [] @@ -132,11 +133,11 @@ html_theme_options = { } html_sidebars = { - '**': [ - 'about.html', - 'navigation.html', - 'relations.html', - 'searchbox.html', + "**": [ + "about.html", + "navigation.html", + "relations.html", + "searchbox.html", ] } @@ -168,16 +169,16 @@ html_sidebars = { # 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"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# 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" # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. @@ -211,50 +212,50 @@ html_sidebars = { # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +#html_use_opensearch = "" # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -#html_search_language = 'en' +# "da", "de", "en", "es", "fi", "fr", "hu", "it", "ja" +# "nl", "no", "pt", "ro", "ru", "sv", "tr" +#html_search_language = "en" # A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -#html_search_options = {'type': 'default'} +# Now only "ja" uses this config value +#html_search_options = {"type": "default"} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' +#html_search_scorer = "scorer.js" # Output file base name for HTML help builder. -htmlhelp_basename = 'grudgedoc' +htmlhelp_basename = "grudgedoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', + # The paper size ("letterpaper" or "a4paper"). + #"papersize": "letterpaper", - # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', + # The font size ("10pt", "11pt" or "12pt"). + #"pointsize": "10pt", # Additional stuff for the LaTeX preamble. - #'preamble': '', + #"preamble": "", # Latex figure (float) alignment - #'figure_align': 'htbp', + #"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]). latex_documents = [ - (master_doc, 'grudge.tex', 'grudge Documentation', - 'Andreas Kloeckner', 'manual'), + (master_doc, "grudge.tex", "grudge Documentation", + "Andreas Kloeckner", "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -283,7 +284,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'grudge', 'grudge Documentation', + (master_doc, "grudge", "grudge Documentation", [author], 1) ] @@ -297,9 +298,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'grudge', 'grudge Documentation', - author, 'grudge', 'One line description of project.', - 'Miscellaneous'), + (master_doc, "grudge", "grudge Documentation", + author, "grudge", "One line description of project.", + "Miscellaneous"), ] # Documents to append as an appendix to all manuals. @@ -308,21 +309,21 @@ texinfo_documents = [ # If false, no module index is generated. #texinfo_domain_indices = True -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# How to display URL addresses: "footnote", "no", or "inline". +#texinfo_show_urls = "footnote" -# If true, do not generate a @detailmenu in the "Top" node's menu. +# If true, do not generate a @detailmenu in the "Top" node"s menu. #texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - 'https://docs.python.org/': None, - 'https://docs.scipy.org/doc/numpy/': None, - 'https://documen.tician.de/pyopencl/': None, - 'https://documen.tician.de/modepy/': None, - 'https://documen.tician.de/pymbolic/': None, - 'https://documen.tician.de/meshmode/': None, - 'http://documen.tician.de/loopy/': None, + "https://docs.python.org/": None, + "https://docs.scipy.org/doc/numpy/": None, + "https://documen.tician.de/pyopencl/": None, + "https://documen.tician.de/modepy/": None, + "https://documen.tician.de/pymbolic/": None, + "https://documen.tician.de/meshmode/": None, + "http://documen.tician.de/loopy/": None, } autoclass_content = "class" diff --git a/examples/advection/surface.py b/examples/advection/surface.py index 70f3a45b044ea4e0f2a8166a814bd07628fef467..2ab36d516416796c6760023000638ead0004fbda 100644 --- a/examples/advection/surface.py +++ b/examples/advection/surface.py @@ -73,8 +73,8 @@ class Plotter: ax = self.fig.gca() ax.grid() - ax.plot(self.x, u, '-') - ax.plot(self.x, u, 'k.') + ax.plot(self.x, u, "-") + ax.plot(self.x, u, "k.") ax.set_xlabel(r"$\theta$") ax.set_ylabel("$u$") ax.set_title(f"t = {evt.t:.2f}") diff --git a/examples/advection/var-velocity.py b/examples/advection/var-velocity.py index 0f90c37e941b0517a9140a244df50fa5856107ac..9aa4d5b5faf5535fd0b0b1dbd4c958a690fbfec0 100644 --- a/examples/advection/var-velocity.py +++ b/examples/advection/var-velocity.py @@ -70,8 +70,8 @@ class Plotter: raise FileExistsError("output file '%s' already exists" % filename) ax = self.fig.gca() - ax.plot(self.x, u, '-') - ax.plot(self.x, u, 'k.') + ax.plot(self.x, u, "-") + ax.plot(self.x, u, "k.") if self.ylim is not None: ax.set_ylim(self.ylim) diff --git a/examples/advection/weak.py b/examples/advection/weak.py index ebc91f2737326007b2a0933efd8cc62d736ae92b..6e4edd0170175f4fb705d235317c6d80f997c752 100644 --- a/examples/advection/weak.py +++ b/examples/advection/weak.py @@ -70,8 +70,8 @@ class Plotter: raise FileExistsError("output file '%s' already exists" % filename) ax = self.fig.gca() - ax.plot(self.x, u, '-') - ax.plot(self.x, u, 'k.') + ax.plot(self.x, u, "-") + ax.plot(self.x, u, "k.") if self.ylim is not None: ax.set_ylim(self.ylim) diff --git a/grudge/discretization.py b/grudge/discretization.py index f7b03a229bd71840dc3eb11562c60a17b0d166f3..ce130aef8dbad0cb165653774960ae96b722ea8c 100644 --- a/grudge/discretization.py +++ b/grudge/discretization.py @@ -20,8 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - -import six from pytools import memoize_method from grudge import sym import numpy as np # noqa: F401 diff --git a/grudge/models/em.py b/grudge/models/em.py index 6314ded204f6a3d5928828fb1435288e37b733b2..d8fbdb4ee0d967b8531530c9c6ff8c1752151f03 100644 --- a/grudge/models/em.py +++ b/grudge/models/em.py @@ -1,6 +1,5 @@ """grudge operators modelling electromagnetic phenomena.""" - __copyright__ = """ Copyright (C) 2007-2017 Andreas Kloeckner Copyright (C) 2010 David Powell @@ -184,7 +183,8 @@ class MaxwellOperator(HyperbolicOperator): ) def pec_bc(self, w): - "Construct part of the flux operator template for PEC boundary conditions" + """Construct part of the flux operator template for PEC boundary conditions + """ e, h = self.split_eh(w) pec_e = sym.cse(sym.project("vol", self.pec_tag)(e)) @@ -193,7 +193,8 @@ class MaxwellOperator(HyperbolicOperator): return flat_obj_array(-pec_e, pec_h) def pmc_bc(self, w): - "Construct part of the flux operator template for PMC boundary conditions" + """Construct part of the flux operator template for PMC boundary conditions + """ e, h = self.split_eh(w) pmc_e = sym.cse(sym.project("vol", self.pmc_tag)(e)) @@ -232,7 +233,7 @@ class MaxwellOperator(HyperbolicOperator): return bc def incident_bc(self, w): - "Flux terms for incident boundary conditions" + """Flux terms for incident boundary conditions""" # NOTE: Untested for inhomogeneous materials, but would usually be # physically meaningless anyway (are there exceptions to this?) @@ -300,7 +301,7 @@ class MaxwellOperator(HyperbolicOperator): [e_subset, h_subset])) def split_eh(self, w): - "Splits an array into E and H components" + """Splits an array into E and H components""" e_idx, h_idx = self.partial_to_eh_subsets() e, h = w[e_idx], w[h_idx] diff --git a/grudge/symbolic/compiler.py b/grudge/symbolic/compiler.py index fc698a540cabde2b2f047f5c6d6936ea439c2e4f..17d318458525eed5e73bb4efeb02fc07a7499179 100644 --- a/grudge/symbolic/compiler.py +++ b/grudge/symbolic/compiler.py @@ -325,8 +325,8 @@ def dot_dataflow_graph(code, max_node_label_length=30, node_names = {} result = [ - "initial [label=\"initial\"]" - "result [label=\"result\"]"] + 'initial [label="initial"]' + 'result [label="result"]'] for num, insn in enumerate(code.instructions): node_name = "node%d" % num @@ -344,7 +344,7 @@ def dot_dataflow_graph(code, max_node_label_length=30, node_label = node_label.replace("\n", "\\l") + "\\l" - result.append("%s [ label=\"p%d: %s\" shape=box ];" % ( + result.append('%s [ label="p%d: %s" shape=box ];' % ( node_name, insn.priority, node_label)) for assignee in insn.get_assignees(): @@ -358,7 +358,7 @@ def dot_dataflow_graph(code, max_node_label_length=30, return "initial" def gen_expr_arrow(expr, target_node): - result.append("%s -> %s [label=\"%s\"];" + result.append('%s -> %s [label="%s"];' % (get_orig_node(expr), target_node, expr)) for insn in code.instructions: @@ -493,10 +493,10 @@ class Code: from time import time start_time = time() if profile_data == {}: - profile_data['insn_eval_time'] = 0 - profile_data['future_eval_time'] = 0 - profile_data['busy_wait_time'] = 0 - profile_data['total_time'] = 0 + profile_data["insn_eval_time"] = 0 + profile_data["future_eval_time"] = 0 + profile_data["busy_wait_time"] = 0 + profile_data["total_time"] = 0 if log_quantities is not None: exec_sub_timer = log_quantities["exec_timer"].start_sub_timer() context = exec_mapper.context @@ -538,7 +538,7 @@ class Code: futures.extend(new_futures) if profile_data is not None: - profile_data['insn_eval_time'] += time() - insn_start_time + profile_data["insn_eval_time"] += time() - insn_start_time if log_quantities is not None: insn_sub_timer.stop().submit() except self.NoInstructionAvailable: @@ -558,7 +558,7 @@ class Code: for i in range(len(futures)): if futures[i].is_ready(): if profile_data is not None: - profile_data['busy_wait_time'] +=\ + profile_data["busy_wait_time"] +=\ time() - busy_wait_start_time future_start_time = time() if log_quantities is not None: @@ -579,7 +579,7 @@ class Code: did_eval_future = True if profile_data is not None: - profile_data['future_eval_time'] +=\ + profile_data["future_eval_time"] +=\ time() - future_start_time if log_quantities is not None: future_sub_timer.stop().submit() @@ -592,7 +592,7 @@ class Code: if log_quantities is not None: exec_sub_timer.stop().submit() if profile_data is not None: - profile_data['total_time'] = time() - start_time + profile_data["total_time"] = time() - start_time return (obj_array_vectorize(exec_mapper, self.result), profile_data) return obj_array_vectorize(exec_mapper, self.result) diff --git a/grudge/symbolic/mappers/__init__.py b/grudge/symbolic/mappers/__init__.py index 63091163afb527b98a9752d53c2954755e45a1cb..555b5ffe8358233bc1d10331a0d2f40f66c55c92 100644 --- a/grudge/symbolic/mappers/__init__.py +++ b/grudge/symbolic/mappers/__init__.py @@ -1,6 +1,5 @@ """Mappers to transform symbolic operators.""" - __copyright__ = "Copyright (C) 2008 Andreas Kloeckner" __license__ = """ @@ -23,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - -import six - import numpy as np import pymbolic.primitives import pymbolic.mapper.stringifier @@ -725,7 +721,9 @@ class StringifyMapper(pymbolic.mapper.stringifier.StringifyMapper): return result def _format_op_dd(self, op): - return ":{}->{}".format(self._format_dd(op.dd_in), self._format_dd(op.dd_out)) + return ":{}->{}".format( + self._format_dd(op.dd_in), + self._format_dd(op.dd_out)) # {{{ elementwise ops diff --git a/grudge/symbolic/operators.py b/grudge/symbolic/operators.py index 74a5e5d9e3315dc9e6e55c7c0d132a2f017791d3..3f9687ca3cdaf8ca7c022c511a39a65a711c24db 100644 --- a/grudge/symbolic/operators.py +++ b/grudge/symbolic/operators.py @@ -369,7 +369,7 @@ class RefStiffnessTOperator(RefDiffOperatorBase): grad_vand = (grad_vand,) weights = in_elem_grp.weights - return np.einsum('c,bz,acz->abc', weights, vand_inv_t, grad_vand) + return np.einsum("c,bz,acz->abc", weights, vand_inv_t, grad_vand) # }}} @@ -515,7 +515,7 @@ class RefMassOperator(RefMassOperatorBase): vand_inv_t = np.linalg.inv(vand).T weights = in_element_group.weights - return np.einsum('j,ik,jk->ij', weights, vand_inv_t, o_vand) + return np.einsum("j,ik,jk->ij", weights, vand_inv_t, o_vand) mapper_method = intern("map_ref_mass") diff --git a/grudge/symbolic/primitives.py b/grudge/symbolic/primitives.py index fce5d3ad589eca67d7d1d7718e7bf3c1e4c77d05..a02fd62fcc69c01b8de964e8da3863ae8d0a3f6d 100644 --- a/grudge/symbolic/primitives.py +++ b/grudge/symbolic/primitives.py @@ -274,7 +274,9 @@ class DOFDesc: else: return repr(s) - return "DOFDesc({}, {})".format(fmt(self.domain_tag), fmt(self.quadrature_tag)) + return "DOFDesc({}, {})".format( + fmt(self.domain_tag), + fmt(self.quadrature_tag)) DD_SCALAR = DOFDesc(DTAG_SCALAR, None) diff --git a/grudge/tools.py b/grudge/tools.py index 94c012700705225d8b241c1b5110a232bb8e23fc..4733f89535a51fa0c44e74ec12d308596cdc0458 100644 --- a/grudge/tools.py +++ b/grudge/tools.py @@ -28,7 +28,7 @@ from pytools import levi_civita def is_zero(x): - # DO NOT try to replace this with an attempted '== 0' comparison. + # DO NOT try to replace this with an attempted "== 0" comparison. # This will become an elementwise numpy operation and not do what # you want. @@ -184,15 +184,15 @@ class OrderedSet(MutableSet): def pop(self, last=True): if not self: - raise KeyError('set is empty') + raise KeyError("set is empty") key = self.end[1][0] if last else self.end[2][0] self.discard(key) return key def __repr__(self): if not self: - return f'{self.__class__.__name__}()' - return '{}({!r})'.format(self.__class__.__name__, list(self)) + return f"{self.__class__.__name__}()" + return "{}({!r})".format(self.__class__.__name__, list(self)) def __eq__(self, other): if isinstance(other, OrderedSet): diff --git a/setup.cfg b/setup.cfg index b2d98b73fe5e4ba7299a6e5aa4ce24b5e9591691..5f9aaced4125509fd33021d2ea20593288b09126 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,8 @@ exclude= grudge/models/diffusion.py, grudge/models/nd_calculus.py, grudge/dt_finding.py +inline-quotes = double +multiline-quotes = double [mypy] ignore_missing_imports = True diff --git a/test/mesh_data.py b/test/mesh_data.py index 6230cb85701a945b6aec0aba26c9f9e419114be2..14cee46d54aa1fbb823479d51ede6c5c1e419fe2 100644 --- a/test/mesh_data.py +++ b/test/mesh_data.py @@ -1,4 +1,3 @@ -import six import numpy as np diff --git a/test/test_mpi_communication.py b/test/test_mpi_communication.py index 54114669427c1f2be69b2ee04b7161a3f1ff3b2b..4ed9fdb2e0d58c7bfc3df069abea34ad097174b6 100644 --- a/test/test_mpi_communication.py +++ b/test/test_mpi_communication.py @@ -168,7 +168,7 @@ def mpi_communication_entrypoint(): IntervalTimer, EventCounter log_filename = None # NOTE: LogManager hangs when using a file on a shared directory. - # log_filename = 'grudge_log.dat' + # log_filename = "grudge_log.dat" logmgr = LogManager(log_filename, "w", comm) add_run_info(logmgr) add_general_quantities(logmgr) @@ -241,10 +241,10 @@ def mpi_communication_entrypoint(): \tBusy Wait: %g\n \tTotal: %g seconds""", i_local_rank, - data['insn_eval_time'] / data['total_time'] * 100, - data['future_eval_time'] / data['total_time'] * 100, - data['busy_wait_time'] / data['total_time'] * 100, - data['total_time']) + data["insn_eval_time"] / data["total_time"] * 100, + data["future_eval_time"] / data["total_time"] * 100, + data["busy_wait_time"] / data["total_time"] * 100, + data["total_time"]) print_profile_data(rhs.profile_data) logmgr.close()