From b60d4333506070968e8fde66631f3752f54a772f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 28 Sep 2020 12:24:10 -0500 Subject: [PATCH] Enable, fix quotes linting --- .github/workflows/ci.yml | 2 +- .gitlab-ci.yml | 2 +- examples/from_firedrake.py | 10 +++--- examples/multiple-meshes.py | 1 + examples/to_firedrake.py | 6 ++-- meshmode/discretization/connection/chained.py | 2 +- .../discretization/connection/projection.py | 4 +-- meshmode/discretization/visualization.py | 2 +- meshmode/distributed.py | 4 +-- meshmode/interop/firedrake/connection.py | 14 ++++---- meshmode/interop/firedrake/mesh.py | 2 +- meshmode/mesh/visualization.py | 6 ++-- setup.cfg | 4 +++ setup.py | 36 +++++++++---------- test/test_chained.py | 30 ++++++++-------- test/test_firedrake_interop.py | 22 ++++++------ test/test_meshmode.py | 18 +++++----- test/test_partition.py | 10 +++--- 18 files changed, 90 insertions(+), 85 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ad711b2..7ccf2775 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - name: "Main Script" run: | curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - . ./prepare-and-run-flake8.sh "$(basename $GITHUB_REPOSITORY)" ./test + . ./prepare-and-run-flake8.sh "$(basename $GITHUB_REPOSITORY)" test examples pytest3: name: Pytest Conda Py3 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 53e7d743..3c29f131 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -96,7 +96,7 @@ Documentation: Flake8: script: - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - - . ./prepare-and-run-flake8.sh "$CI_PROJECT_NAME" test + - . ./prepare-and-run-flake8.sh "$CI_PROJECT_NAME" test examples tags: - python3 except: diff --git a/examples/from_firedrake.py b/examples/from_firedrake.py index 624d1dc4..3041e8eb 100644 --- a/examples/from_firedrake.py +++ b/examples/from_firedrake.py @@ -43,7 +43,7 @@ def main(): # Create a firedrake mesh and interpolate cos(x+y) onto it fd_mesh = UnitSquareMesh(10, 10) - fd_fspace = FunctionSpace(fd_mesh, 'DG', 2) + fd_fspace = FunctionSpace(fd_mesh, "DG", 2) spatial_coord = SpatialCoordinate(fd_mesh) fd_fntn = Function(fd_fspace).interpolate(cos(sum(spatial_coord))) @@ -57,7 +57,7 @@ def main(): fd_bdy_connection = \ build_connection_from_firedrake(actx, fd_fspace, - restrict_to_boundary='on_boundary') + restrict_to_boundary="on_boundary") # Plot the meshmode meshes that the connections connect to import matplotlib.pyplot as plt @@ -84,16 +84,16 @@ def main(): field = fd_connection.from_firedrake(fd_fntn, actx=actx) fig = plt.figure() - ax1 = fig.add_subplot(1, 2, 1, projection='3d') + ax1 = fig.add_subplot(1, 2, 1, projection="3d") ax1.set_title("cos(x+y) in\nFiredrakeConnection") vis.show_scalar_in_matplotlib_3d(field, do_show=False) - # Now repeat using FiredrakeConnection restricted to 'on_boundary' + # Now repeat using FiredrakeConnection restricted to "on_boundary" bdy_discr = fd_bdy_connection.discr bdy_vis = make_visualizer(actx, bdy_discr, bdy_discr.groups[0].order+3) bdy_field = fd_bdy_connection.from_firedrake(fd_fntn, actx=actx) - ax2 = fig.add_subplot(1, 2, 2, projection='3d') + ax2 = fig.add_subplot(1, 2, 2, projection="3d") plt.sca(ax2) ax2.set_title("cos(x+y) in\nFiredrakeConnection 'on_boundary'") bdy_vis.show_scalar_in_matplotlib_3d(bdy_field, do_show=False) diff --git a/examples/multiple-meshes.py b/examples/multiple-meshes.py index 2dab3fab..d56b2a6b 100644 --- a/examples/multiple-meshes.py +++ b/examples/multiple-meshes.py @@ -26,5 +26,6 @@ def main(): else: pt.savefig("plot.pdf") + if __name__ == "__main__": main() diff --git a/examples/to_firedrake.py b/examples/to_firedrake.py index 30e86bcb..395211ca 100644 --- a/examples/to_firedrake.py +++ b/examples/to_firedrake.py @@ -97,7 +97,7 @@ def main(): # because it's easier to write down the variational problem, # we're going to project from our "DG" space # into a continuous one. - cfd_fspace = FunctionSpace(fd_fspace.mesh(), 'CG', order) + cfd_fspace = FunctionSpace(fd_fspace.mesh(), "CG", order) u = TrialFunction(cfd_fspace) v = TestFunction(cfd_fspace) sol = Function(cfd_fspace) @@ -105,8 +105,8 @@ def main(): a = inner(grad(u), grad(v)) * dx rhs = Constant(0.0) * v * dx bc_value = project(fd_candidate_sol, cfd_fspace) - bc = DirichletBC(cfd_fspace, bc_value, 'on_boundary') - params = {'ksp_monitor': None} + bc = DirichletBC(cfd_fspace, bc_value, "on_boundary") + params = {"ksp_monitor": None} solve(a == rhs, sol, bcs=[bc], solver_parameters=params) # project back into our "DG" space diff --git a/meshmode/discretization/connection/chained.py b/meshmode/discretization/connection/chained.py index 6a85a215..c9927a8a 100644 --- a/meshmode/discretization/connection/chained.py +++ b/meshmode/discretization/connection/chained.py @@ -200,7 +200,7 @@ def flatten_chained_connection(actx, connection): DiscretizationConnectionElementGroup, make_same_mesh_connection) - if not hasattr(connection, 'connections'): + if not hasattr(connection, "connections"): return connection if not connection.connections: diff --git a/meshmode/discretization/connection/projection.py b/meshmode/discretization/connection/projection.py index 575b07aa..6d656e34 100644 --- a/meshmode/discretization/connection/projection.py +++ b/meshmode/discretization/connection/projection.py @@ -153,7 +153,7 @@ class L2ProjectionInverseDiscretizationConnection(DiscretizationConnection): lp.ValueArg("n_to_elements", np.int32), lp.ValueArg("n_to_nodes", np.int32), lp.ValueArg("ibasis", np.int32), - '...' + "..." ], name="conn_projection_knl") @@ -172,7 +172,7 @@ class L2ProjectionInverseDiscretizationConnection(DiscretizationConnection): lp.GlobalArg("coefficients", None, shape=("nelements", "n_to_nodes")), lp.ValueArg("ibasis", np.int32), - '...' + "..." ], name="conn_evaluate_knl") diff --git a/meshmode/discretization/visualization.py b/meshmode/discretization/visualization.py index 11a156bf..0962068b 100644 --- a/meshmode/discretization/visualization.py +++ b/meshmode/discretization/visualization.py @@ -463,7 +463,7 @@ class Visualizer(object): raise ValueError("file_name_pattern must produce file names " "ending in '.vtu'") - par_manifest_filename = par_manifest_filename[:-4] + '.pvtu' + par_manifest_filename = par_manifest_filename[:-4] + ".pvtu" self.write_vtk_file( file_name=file_name_pattern.format(rank=rank), diff --git a/meshmode/distributed.py b/meshmode/distributed.py index 97dd9f58..bcda88f9 100644 --- a/meshmode/distributed.py +++ b/meshmode/distributed.py @@ -97,7 +97,7 @@ class MPIMeshDistributor(object): else: reqs.append(mpi_comm.isend(part, dest=r, tag=TAG_DISTRIBUTE_MESHES)) - logger.info('rank %d: sent all mesh partitions', rank) + logger.info("rank %d: sent all mesh partitions", rank) for req in reqs: req.wait() @@ -117,7 +117,7 @@ class MPIMeshDistributor(object): result = self.mpi_comm.recv( source=self.manager_rank, tag=TAG_DISTRIBUTE_MESHES, status=status) - logger.info('rank %d: received local mesh (size = %d)', rank, status.count) + logger.info("rank %d: received local mesh (size = %d)", rank, status.count) return result diff --git a/meshmode/interop/firedrake/connection.py b/meshmode/interop/firedrake/connection.py index 4c61113b..991b3f29 100644 --- a/meshmode/interop/firedrake/connection.py +++ b/meshmode/interop/firedrake/connection.py @@ -135,7 +135,7 @@ class FiredrakeConnection: :param discr: A :class:`meshmode.discretization.Discretization` :param fdrake_fspace: A :class:`firedrake.functionspaceimpl.WithGeometry`. - Must use ufl family ``'Discontinuous Lagrange'``. + Must use ufl family ``"Discontinuous Lagrange"``. :param mm2fd_node_mapping: Used as attribute :attr:`mm2fd_node_mapping`. A 2-D numpy integer array with the same dtype as ``fdrake_fspace.cell_node_list.dtype`` @@ -187,7 +187,7 @@ class FiredrakeConnection: raise TypeError("'discr.groups[group_nr]' must be of type " "InterpolatoryElementGroupBase" ", not '%s'." % type(element_grp)) - if fdrake_fspace.ufl_element().family() != 'Discontinuous Lagrange': + if fdrake_fspace.ufl_element().family() != "Discontinuous Lagrange": raise TypeError("'fdrake_fspace.ufl_element().family()' must be" "'Discontinuous Lagrange', not " f"'{fdrake_fspace.ufl_element().family()}'") @@ -581,7 +581,7 @@ def _get_cells_to_use(fdrake_mesh, bdy_id): cfspace = fdrake_mesh.coordinates.function_space() cell_node_list = cfspace.cell_node_list - boundary_nodes = cfspace.boundary_nodes(bdy_id, 'topological') + boundary_nodes = cfspace.boundary_nodes(bdy_id, "topological") # Reduce along each cell: Is a vertex of the cell in boundary nodes? cell_is_near_bdy = np.any(np.isin(cell_node_list, boundary_nodes), axis=1) @@ -611,7 +611,7 @@ def build_connection_from_firedrake(actx, fdrake_fspace, grp_factory=None, :class:`~meshmode.discretization.InterpolatoryElementGroupBase`. If *None*, and :mod:`recursivenodes` can be imported, a :class:`~meshmode.discretization.poly_element.\ -PolynomialRecursiveNodesGroupFactory` with ``'lgl'`` nodes is used. +PolynomialRecursiveNodesGroupFactory` with ``"lgl"`` nodes is used. Note that :mod:`recursivenodes` may not be importable as it uses :func:`math.comb`, which is new in Python 3.8. In the case that :mod:`recursivenodes` cannot be successfully @@ -634,7 +634,7 @@ PolynomialWarpAndBlendGroupFactory` is used. % type(fdrake_fspace)) ufl_elt = fdrake_fspace.ufl_element() - if ufl_elt.family() != 'Discontinuous Lagrange': + if ufl_elt.family() != "Discontinuous Lagrange": raise ValueError("the 'fdrake_fspace.ufl_element().family()' of " "must be be " "'Discontinuous Lagrange', not '%s'." @@ -662,7 +662,7 @@ PolynomialWarpAndBlendGroupFactory` is used. # it uses :func:`math.comb`, so need to check if it can # be imported import recursivenodes # noqa : F401 - family = 'lgl' # L-G-Legendre + family = "lgl" # L-G-Legendre grp_factory = PolynomialRecursiveNodesGroupFactory(degree, family) except ImportError: # If cannot be imported, uses warp-and-blend nodes @@ -751,7 +751,7 @@ InterpolatoryQuadratureSimplexElementGroup`. from firedrake.functionspace import FunctionSpace fd_mesh, fd_cell_order, perm2cells = \ export_mesh_to_firedrake(discr.mesh, group_nr, comm) - fspace = FunctionSpace(fd_mesh, 'DG', el_group.order) + fspace = FunctionSpace(fd_mesh, "DG", el_group.order) # get firedrake unit nodes and map onto meshmode reference element dim = fspace.mesh().topological_dimension() fd_ref_cell_to_mm = get_affine_reference_simplex_mapping(dim, True) diff --git a/meshmode/interop/firedrake/mesh.py b/meshmode/interop/firedrake/mesh.py index a4e62402..1ebdbd9d 100644 --- a/meshmode/interop/firedrake/mesh.py +++ b/meshmode/interop/firedrake/mesh.py @@ -902,7 +902,7 @@ def export_mesh_to_firedrake(mesh, group_nr=None, comm=None): with ProcessLogger(logger, "Building firedrake function " "space for mesh coordinates"): from firedrake import VectorFunctionSpace, Function - coords_fspace = VectorFunctionSpace(top, 'CG', group.order, + coords_fspace = VectorFunctionSpace(top, "CG", group.order, dim=mesh.ambient_dim) coords = Function(coords_fspace) diff --git a/meshmode/mesh/visualization.py b/meshmode/mesh/visualization.py index abc586af..26588b1c 100644 --- a/meshmode/mesh/visualization.py +++ b/meshmode/mesh/visualization.py @@ -78,13 +78,13 @@ def draw_2d_mesh(mesh, draw_vertex_numbers=True, draw_element_numbers=True, pt.text(centroid[0], centroid[1], el_label, fontsize=17, ha="center", va="center", - bbox=dict(facecolor='white', alpha=0.5, lw=0)) + bbox=dict(facecolor="white", alpha=0.5, lw=0)) if draw_vertex_numbers: for ivert, vert in enumerate(mesh.vertices.T): pt.text(vert[0], vert[1], str(ivert), fontsize=15, ha="center", va="center", color="blue", - bbox=dict(facecolor='white', alpha=0.5, lw=0)) + bbox=dict(facecolor="white", alpha=0.5, lw=0)) if draw_nodal_adjacency: def global_iel_to_group_and_iel(global_iel): @@ -135,7 +135,7 @@ def draw_2d_mesh(mesh, draw_vertex_numbers=True, draw_element_numbers=True, pt.text(face_center[0], face_center[1], str(iface), fontsize=12, ha="center", va="center", color="purple", - bbox=dict(facecolor='white', alpha=0.5, lw=0)) + bbox=dict(facecolor="white", alpha=0.5, lw=0)) if set_bounding_box: from meshmode.mesh.processing import find_bounding_box diff --git a/setup.cfg b/setup.cfg index 4abe1a05..7598bdad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,3 +2,7 @@ ignore = E126,E127,E128,E123,E226,E241,E242,E265,W503,E402 max-line-length=85 exclude=meshmode/mesh/refinement/__init__.py + +inline-quotes = " +docstring-quotes = """ +multiline-quotes = """ diff --git a/setup.py b/setup.py index 4362058c..022737fa 100644 --- a/setup.py +++ b/setup.py @@ -19,23 +19,23 @@ def main(): license="MIT", url="http://documen.tician.de/meshmode", classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Intended Audience :: Other Audience', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Information Analysis', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Visualization', - 'Topic :: Software Development :: Libraries', - 'Topic :: Utilities', + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Other Audience", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Mathematics", + "Topic :: Scientific/Engineering :: Visualization", + "Topic :: Software Development :: Libraries", + "Topic :: Utilities", ], packages=find_packages(), @@ -53,5 +53,5 @@ def main(): ) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/test/test_chained.py b/test/test_chained.py index 4d134e00..01a60788 100644 --- a/test/test_chained.py +++ b/test/test_chained.py @@ -53,7 +53,7 @@ def create_discretization(actx, ndim, elif mesh_name == "starfish": mesh = make_curve_mesh(starfish, t, order=order) else: - raise ValueError('unknown mesh name: {}'.format(mesh_name)) + raise ValueError("unknown mesh name: {}".format(mesh_name)) elif ndim == 3: from meshmode.mesh.generation import generate_torus from meshmode.mesh.generation import generate_warped_rect_mesh @@ -113,7 +113,7 @@ def create_face_connection(actx, discr): return connection -@pytest.mark.skip(reason='implementation detail') +@pytest.mark.skip(reason="implementation detail") @pytest.mark.parametrize("ndim", [2, 3]) def test_chained_batch_table(actx_factory, ndim, visualize=False): from meshmode.discretization.connection.chained import \ @@ -142,7 +142,7 @@ def test_chained_batch_table(actx_factory, ndim, visualize=False): assert np.min(el_table[igrp]) >= 0 -@pytest.mark.skip(reason='implementation detail') +@pytest.mark.skip(reason="implementation detail") @pytest.mark.parametrize("ndim", [2, 3]) def test_chained_new_group_table(actx_factory, ndim, visualize=False): from meshmode.discretization.connection.chained import \ @@ -179,13 +179,13 @@ def test_chained_new_group_table(actx_factory, ndim, visualize=False): to_unit_nodes = grp_info[mgroup][mbatch].result_unit_nodes if ndim == 2: - pt.plot(from_unit_nodes, 'o') - pt.plot(to_unit_nodes, '^') + pt.plot(from_unit_nodes, "o") + pt.plot(to_unit_nodes, "^") else: - pt.plot(from_unit_nodes[0], from_unit_nodes[1], 'o') - pt.plot(to_unit_nodes[0], to_unit_nodes[1], '^') + pt.plot(from_unit_nodes[0], from_unit_nodes[1], "o") + pt.plot(to_unit_nodes[0], to_unit_nodes[1], "^") - pt.savefig('test_grp_to_grp_{}d_{:05d}_{:05d}.png' + pt.savefig("test_grp_to_grp_{}d_{:05d}_{:05d}.png" .format(ndim, mgroup, mbatch), dpi=300) pt.clf() @@ -281,7 +281,7 @@ def test_chained_to_direct(actx_factory, ndim, chain_type, conn = create_face_connection(actx, conn.to_discr) connections.append(conn) else: - raise ValueError('unknown test case') + raise ValueError("unknown test case") from meshmode.discretization.connection import \ ChainedDiscretizationConnection @@ -291,7 +291,7 @@ def test_chained_to_direct(actx_factory, ndim, chain_type, direct = flatten_chained_connection(actx, chained) t_end = time.time() if visualize: - print('[TIME] Flatten: {:.5e}'.format(t_end - t_start)) + print("[TIME] Flatten: {:.5e}".format(t_end - t_start)) if chain_type < 3: to_element_indices = np.full(direct.to_discr.mesh.nelements, 0, @@ -313,23 +313,23 @@ def test_chained_to_direct(actx_factory, ndim, chain_type, f1 = actx.to_numpy(flatten(direct(fx))) t_end = time.time() if visualize: - print('[TIME] Direct: {:.5e}'.format(t_end - t_start)) + print("[TIME] Direct: {:.5e}".format(t_end - t_start)) t_start = time.time() f2 = actx.to_numpy(flatten(chained(fx))) t_end = time.time() if visualize: - print('[TIME] Chained: {:.5e}'.format(t_end - t_start)) + print("[TIME] Chained: {:.5e}".format(t_end - t_start)) if visualize and ndim == 2: import matplotlib.pyplot as pt pt.figure(figsize=(10, 8), dpi=300) - pt.plot(f1, label='Direct') - pt.plot(f2, label='Chained') + pt.plot(f1, label="Direct") + pt.plot(f2, label="Chained") pt.ylim([np.min(f2) - 0.1, np.max(f2) + 0.1]) pt.legend() - pt.savefig('test_chained_to_direct.png') + pt.savefig("test_chained_to_direct.png") pt.clf() assert np.allclose(f1, f2) diff --git a/test/test_firedrake_interop.py b/test/test_firedrake_interop.py index 17cabade..2c7ecf00 100644 --- a/test/test_firedrake_interop.py +++ b/test/test_firedrake_interop.py @@ -91,7 +91,7 @@ def fdrake_mesh(request): return UnitSquareMesh(10, 10) elif mesh_name == "FiredrakeUnitSquareMesh-order2": m = UnitSquareMesh(10, 10) - fspace = VectorFunctionSpace(m, 'CG', 2) + fspace = VectorFunctionSpace(m, "CG", 2) coords = Function(fspace).interpolate(SpatialCoordinate(m)) from firedrake.mesh import Mesh return Mesh(coords) @@ -173,7 +173,7 @@ def test_from_fd_consistency(ctx_factory, fdrake_mesh, fspace_degree): Check basic consistency with a FiredrakeConnection built from firedrake """ # make discretization from firedrake - fdrake_fspace = FunctionSpace(fdrake_mesh, 'DG', fspace_degree) + fdrake_fspace = FunctionSpace(fdrake_mesh, "DG", fspace_degree) cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) @@ -217,7 +217,7 @@ def test_from_boundary_consistency(ctx_factory, and that each boundary tag is associated to the same number of facets in the converted meshmode mesh as in the original firedrake mesh. """ - fdrake_fspace = FunctionSpace(fdrake_mesh, 'DG', fspace_degree) + fdrake_fspace = FunctionSpace(fdrake_mesh, "DG", fspace_degree) cl_ctx = ctx_factory() queue = cl.CommandQueue(cl_ctx) @@ -249,7 +249,7 @@ def test_from_boundary_consistency(ctx_factory, # only look at cells "near" bdy (with >= 1 vertex on) from meshmode.interop.firedrake.connection import _get_cells_to_use - cells_near_bdy = _get_cells_to_use(fdrake_mesh, 'on_boundary') + cells_near_bdy = _get_cells_to_use(fdrake_mesh, "on_boundary") # get the firedrake vertices of cells near the boundary, # in no particular order fdrake_vert_indices = \ @@ -310,7 +310,7 @@ def test_bdy_tags(square_or_cube_mesh, bdy_ids, coord_indices, coord_values, cells_to_use = None if only_convert_bdy: from meshmode.interop.firedrake.connection import _get_cells_to_use - cells_to_use = _get_cells_to_use(square_or_cube_mesh, 'on_boundary') + cells_to_use = _get_cells_to_use(square_or_cube_mesh, "on_boundary") mm_mesh, orient = import_firedrake_mesh(square_or_cube_mesh, cells_to_use=cells_to_use) # Ensure meshmode required boundary tags are there @@ -448,12 +448,12 @@ def test_from_fd_transfer(ctx_factory, fspace_degree, for mesh_par in fdrake_mesh_pars: fdrake_mesh, h = get_fdrake_mesh_and_h_from_par(mesh_par) # make function space and build connection - fdrake_fspace = FunctionSpace(fdrake_mesh, 'DG', fspace_degree) + fdrake_fspace = FunctionSpace(fdrake_mesh, "DG", fspace_degree) if only_convert_bdy: fdrake_connection = \ build_connection_from_firedrake(actx, fdrake_fspace, - restrict_to_boundary='on_boundary') + restrict_to_boundary="on_boundary") else: fdrake_connection = build_connection_from_firedrake(actx, fdrake_fspace) # get this for making functions in firedrake @@ -584,17 +584,17 @@ def test_from_fd_idempotency(ctx_factory, """ # Make a function space and a function with unique values at each node if fspace_type == "scalar": - fdrake_fspace = FunctionSpace(fdrake_mesh, 'DG', fspace_degree) + fdrake_fspace = FunctionSpace(fdrake_mesh, "DG", fspace_degree) # Just use the node nr fdrake_unique = Function(fdrake_fspace) fdrake_unique.dat.data[:] = np.arange(fdrake_unique.dat.data.shape[0]) elif fspace_type == "vector": - fdrake_fspace = VectorFunctionSpace(fdrake_mesh, 'DG', fspace_degree) + fdrake_fspace = VectorFunctionSpace(fdrake_mesh, "DG", fspace_degree) # use the coordinates xx = SpatialCoordinate(fdrake_fspace.mesh()) fdrake_unique = Function(fdrake_fspace).interpolate(xx) elif fspace_type == "tensor": - fdrake_fspace = TensorFunctionSpace(fdrake_mesh, 'DG', fspace_degree) + fdrake_fspace = TensorFunctionSpace(fdrake_mesh, "DG", fspace_degree) # use the coordinates, duplicated into the right tensor shape xx = SpatialCoordinate(fdrake_fspace.mesh()) dim = fdrake_fspace.mesh().geometric_dimension() @@ -616,7 +616,7 @@ def test_from_fd_idempotency(ctx_factory, fdrake_connection = \ build_connection_from_firedrake(actx, fdrake_fspace, - restrict_to_boundary='on_boundary') + restrict_to_boundary="on_boundary") temp = fdrake_connection.from_firedrake(fdrake_unique, actx=actx) fdrake_unique = fdrake_connection.from_meshmode(temp) else: diff --git a/test/test_meshmode.py b/test/test_meshmode.py index 763c5dfe..258741a6 100644 --- a/test/test_meshmode.py +++ b/test/test_meshmode.py @@ -208,10 +208,10 @@ def test_visualizers(actx_factory, dim): def test_boundary_tags(): from meshmode.mesh.io import read_gmsh # ensure tags are read in - mesh = read_gmsh('annulus.msh') - if not {'outer_bdy', 'inner_bdy'} <= set(mesh.boundary_tags): + mesh = read_gmsh("annulus.msh") + if not {"outer_bdy", "inner_bdy"} <= set(mesh.boundary_tags): print("Mesh boundary tags:", mesh.boundary_tags) - raise ValueError('Tags not saved by mesh') + raise ValueError("Tags not saved by mesh") # correct answers num_on_outer_bdy = 26 @@ -220,8 +220,8 @@ def test_boundary_tags(): # check how many elements are marked on each boundary num_marked_outer_bdy = 0 num_marked_inner_bdy = 0 - outer_btag_bit = mesh.boundary_tag_bit('outer_bdy') - inner_btag_bit = mesh.boundary_tag_bit('inner_bdy') + outer_btag_bit = mesh.boundary_tag_bit("outer_bdy") + inner_btag_bit = mesh.boundary_tag_bit("inner_bdy") for igrp in range(len(mesh.groups)): bdry_fagrp = mesh.facial_adjacency_groups[igrp].get(None, None) @@ -245,7 +245,7 @@ def test_boundary_tags(): # ensure boundary is covered from meshmode.mesh import check_bc_coverage - check_bc_coverage(mesh, ['inner_bdy', 'outer_bdy']) + check_bc_coverage(mesh, ["inner_bdy", "outer_bdy"]) # }}} @@ -297,7 +297,7 @@ def test_box_boundary_tags(dim, nelem, group_factory): assert not is_boundary_tag_empty(mesh, "btag_test_1") assert not is_boundary_tag_empty(mesh, "btag_test_2") - check_bc_coverage(mesh, ['btag_test_1', 'btag_test_2']) + check_bc_coverage(mesh, ["btag_test_1", "btag_test_2"]) # check how many elements are marked on each boundary num_marked_bdy_1 = 0 @@ -672,7 +672,7 @@ def test_element_orientation(): # {{{ element orientation: canned 3D meshes -# python test_meshmode.py 'test_sanity_balls(cl._csc, "disk-radius-1.step", 2, 2, visualize=True)' # noqa +# python test_meshmode.py "test_sanity_balls(cl._csc, "disk-radius-1.step", 2, 2, visualize=True)" # noqa @pytest.mark.parametrize(("what", "mesh_gen_func"), [ ("ball", lambda: mgen.generate_icosahedron(1, 1)), ("torus", lambda: mgen.generate_torus(5, 1)), @@ -911,7 +911,7 @@ def test_sanity_qhull_nd(actx_factory, dim, order): # {{{ sanity checks: ball meshes -# python test_meshmode.py 'test_sanity_balls(cl._csc, "disk-radius-1.step", 2, 2, visualize=True)' # noqa +# python test_meshmode.py "test_sanity_balls(cl._csc, "disk-radius-1.step", 2, 2, visualize=True)" # noqa @pytest.mark.parametrize(("src_file", "dim"), [ ("disk-radius-1.step", 2), ("ball-radius-1.step", 3), diff --git a/test/test_partition.py b/test/test_partition.py index b0f2a25c..5d1c5778 100644 --- a/test/test_partition.py +++ b/test/test_partition.py @@ -89,7 +89,7 @@ def test_partition_interpolation(actx_factory, dim, mesh_pars, if part_method == "random": part_per_element = np.random.randint(num_parts, size=mesh.nelements) else: - pytest.importorskip('pymetis') + pytest.importorskip("pymetis") from meshmode.distributed import get_partition_by_pymetis part_per_element = get_partition_by_pymetis(mesh, num_parts, @@ -165,7 +165,7 @@ def test_partition_interpolation(actx_factory, dim, mesh_pars, err = flat_norm(true_local_points - local_points, np.inf) # Can't currently expect exact results due to limitations of - # interpolation 'snapping' in DirectDiscretizationConnection's + # interpolation "snapping" in DirectDiscretizationConnection's # _resample_point_pick_indices assert err < 1e-11 @@ -199,7 +199,7 @@ def test_partition_mesh(mesh_size, num_parts, num_groups, dim, scramble_partitio if scramble_partitions: part_per_element = np.random.randint(num_parts, size=mesh.nelements) else: - pytest.importorskip('pymetis') + pytest.importorskip("pymetis") from meshmode.distributed import get_partition_by_pymetis part_per_element = get_partition_by_pymetis(mesh, num_parts) @@ -403,7 +403,7 @@ def _test_data_transfer(mpi_comm, actx, local_bdry_conns, def f(x): return 10*actx.np.sin(20.*x) - ''' + """ Here is a simplified example of what happens from the point of view of the local rank. @@ -419,7 +419,7 @@ def _test_data_transfer(mpi_comm, actx, local_bdry_conns, Local rank: 6. Receive local points from remote rank. 7. Check if local points are the same as the original local points. - ''' + """ # 1. send_reqs = [] -- GitLab