diff --git a/examples/multiple-meshes.py b/examples/multiple-meshes.py index d56b2a6b42bb8ea4a3b423d999d1ab920babf34d..a386689140f08aee5f1dbc6f8098e835ab7f9ad7 100644 --- a/examples/multiple-meshes.py +++ b/examples/multiple-meshes.py @@ -1,5 +1,3 @@ -from __future__ import division - import numpy as np # noqa import sys diff --git a/examples/plot-connectivity.py b/examples/plot-connectivity.py index 48e6be76b7033c4a3f04f55c6958c7efd856f0e0..0faaa9b3319aca1345da4b507b4eb31ab6ef78b4 100644 --- a/examples/plot-connectivity.py +++ b/examples/plot-connectivity.py @@ -1,5 +1,3 @@ -from __future__ import division - import numpy as np # noqa import pyopencl as cl from meshmode.array_context import PyOpenCLArrayContext diff --git a/examples/simple-dg.py b/examples/simple-dg.py index b945687758f172194d859560bc1723064d56971b..6c198d2d8256069f2b2165ce17cbd2afa9a8b29e 100644 --- a/examples/simple-dg.py +++ b/examples/simple-dg.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - __copyright__ = "Copyright (C) 2020 Andreas Kloeckner" __license__ = """ diff --git a/experiments/refinement-playground.py b/experiments/refinement-playground.py index a29c0db8f687440f3493015cb256d30926f6b4d8..9d43e71887c9aa8592405055cb0ceb381fb932f9 100644 --- a/experiments/refinement-playground.py +++ b/experiments/refinement-playground.py @@ -1,6 +1,5 @@ from __future__ import division, print_function -from six.moves import range import numpy as np # noqa import pyopencl as cl import random @@ -103,7 +102,7 @@ def get_corner_flags(mesh): def get_random_flags(mesh): flags = np.zeros(len(mesh.groups[0].vertex_indices)) for i in range(0, len(flags)): - flags[i] = random.randint(0, 1) + flags[i] = random.randint(0, 1) return flags diff --git a/meshmode/__init__.py b/meshmode/__init__.py index 9512b4a25aec6e3450e0a0bd2fc7ecc72452ca41..1e74a4be7e364bd0839066fdc398f48f7e2658e4 100644 --- a/meshmode/__init__.py +++ b/meshmode/__init__.py @@ -1,5 +1,3 @@ -from __future__ import division - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -29,8 +27,6 @@ __doc__ = """ .. exception:: FileExistsError """ -import six - class Error(RuntimeError): pass @@ -40,8 +36,4 @@ class DataUnavailable(Error): pass -if six.PY3: - from builtins import FileExistsError -else: - class FileExistsError(OSError): - pass +from builtins import FileExistsError # noqa: F401 diff --git a/meshmode/array_context.py b/meshmode/array_context.py index 0b1bd239c3a8837e063260785913e641073f5a75..43659c34af174a9355fb25ced296d5f3826c3c5f 100644 --- a/meshmode/array_context.py +++ b/meshmode/array_context.py @@ -1,5 +1,3 @@ -from __future__ import division - __copyright__ = "Copyright (C) 2020 Andreas Kloeckner" __license__ = """ @@ -361,7 +359,7 @@ def pytest_generate_tests_for_pyopencl_array_context(metafunc): class ArrayContextFactory(_ContextFactory): def __call__(self): - ctx = super(ArrayContextFactory, self).__call__() + ctx = super().__call__() return PyOpenCLArrayContext(cl.CommandQueue(ctx)) def __str__(self): diff --git a/meshmode/discretization/__init__.py b/meshmode/discretization/__init__.py index 7694eb9ece7545c14cbbc36b76b7d72d576400ba..d1ec5a6b50401252e36ceefa245e3e2c0108fb24 100644 --- a/meshmode/discretization/__init__.py +++ b/meshmode/discretization/__init__.py @@ -42,7 +42,7 @@ class NoninterpolatoryElementGroupError(TypeError): pass -class ElementGroupBase(object): +class ElementGroupBase: """Container for the :class:`Discretization` data corresponding to one :class:`meshmode.mesh.MeshElementGroup`. @@ -157,7 +157,7 @@ class InterpolatoryElementGroupBase(ElementGroupBase): # }}} -class Discretization(object): +class Discretization: """An unstructured composite discretization. .. attribute:: real_dtype diff --git a/meshmode/discretization/connection/__init__.py b/meshmode/discretization/connection/__init__.py index 4589deb1ecedb723ae7b75892fd5987a2ba9517d..c02097e73294e3ca29cda5697d4b59b02cc14440 100644 --- a/meshmode/discretization/connection/__init__.py +++ b/meshmode/discretization/connection/__init__.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function, absolute_import - __copyright__ = """ Copyright (C) 2014 Andreas Kloeckner Copyright (C) 2018 Alexandru Fikl diff --git a/meshmode/discretization/connection/chained.py b/meshmode/discretization/connection/chained.py index c9927a8a5aec2444c5fe4ea6eb27e7c4014f8b52..54bbd98ed1451f81524e812abebbbca720a40656 100644 --- a/meshmode/discretization/connection/chained.py +++ b/meshmode/discretization/connection/chained.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function, absolute_import - __copyright__ = """Copyright (C) 2018 Alexandru Fikl""" __license__ = """ @@ -58,7 +56,7 @@ class ChainedDiscretizationConnection(DiscretizationConnection): # It's an identity is_surjective = True - super(ChainedDiscretizationConnection, self).__init__( + super().__init__( from_discr, to_discr, is_surjective=is_surjective) self.connections = connections diff --git a/meshmode/discretization/connection/direct.py b/meshmode/discretization/connection/direct.py index 6ee46d99bd72248a4da9409119a57329352f8e5e..55820fe03c3efc4d97efb690fb0faeda3b66fc23 100644 --- a/meshmode/discretization/connection/direct.py +++ b/meshmode/discretization/connection/direct.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function, absolute_import - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -22,7 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from six.moves import range, zip import numpy as np @@ -33,7 +30,7 @@ from meshmode.array_context import ArrayContext, make_loopy_program # {{{ interpolation batch -class InterpolationBatch(object): +class InterpolationBatch: """One interpolation batch captures how a batch of elements *within* an element group should be an interpolated. Note that while it's possible that an interpolation batch takes care of interpolating an entire element group @@ -97,7 +94,7 @@ class InterpolationBatch(object): # {{{ connection element group -class DiscretizationConnectionElementGroup(object): +class DiscretizationConnectionElementGroup: """ .. attribute:: batches @@ -111,7 +108,7 @@ class DiscretizationConnectionElementGroup(object): # {{{ connection classes -class DiscretizationConnection(object): +class DiscretizationConnection: """Abstract interface for transporting a DOF vector from one :class:`meshmode.discretization.Discretization` to another. Possible applications include: @@ -174,7 +171,7 @@ class DirectDiscretizationConnection(DiscretizationConnection): """ def __init__(self, from_discr, to_discr, groups, is_surjective): - super(DirectDiscretizationConnection, self).__init__( + super().__init__( from_discr, to_discr, is_surjective) self.groups = groups diff --git a/meshmode/discretization/connection/face.py b/meshmode/discretization/connection/face.py index bac1ccc9e59ff82716fbd4e87213db1d48798e2d..9eddc07c77ef74c83d88c5c7d6daf74c0a596a7a 100644 --- a/meshmode/discretization/connection/face.py +++ b/meshmode/discretization/connection/face.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function, absolute_import - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -22,9 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import six -from six.moves import range, zip - from pytools import Record import numpy as np @@ -234,7 +229,7 @@ def make_face_restriction(actx, discr, group_factory, boundary_tag, group_boundary_faces = [] if boundary_tag is FACE_RESTR_INTERIOR: - for fagrp in six.itervalues(fagrp_map): + for fagrp in fagrp_map.values(): if fagrp.ineighbor_group is None: # boundary faces -> not looking for those continue diff --git a/meshmode/discretization/connection/opposite_face.py b/meshmode/discretization/connection/opposite_face.py index a957b03dcc95a3d0329a4a7916251783523e5de0..9bd13a1ec30f530d3f974c552247b852c2e24984 100644 --- a/meshmode/discretization/connection/opposite_face.py +++ b/meshmode/discretization/connection/opposite_face.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function, absolute_import - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -22,7 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from six.moves import range import numpy as np import numpy.linalg as la diff --git a/meshmode/discretization/connection/projection.py b/meshmode/discretization/connection/projection.py index 6d656e347c350044d78e9ffe37c7c3d1698c7757..fd3d96e519b7b5adad91399ddc6c24e0efd6375e 100644 --- a/meshmode/discretization/connection/projection.py +++ b/meshmode/discretization/connection/projection.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function, absolute_import - __copyright__ = """Copyright (C) 2018 Alexandru Fikl""" __license__ = """ @@ -74,7 +72,7 @@ class L2ProjectionInverseDiscretizationConnection(DiscretizationConnection): raise RuntimeError("`to_discr` must have an orthogonal basis") self.conn = conn - super(L2ProjectionInverseDiscretizationConnection, self).__init__( + super().__init__( from_discr=self.conn.to_discr, to_discr=self.conn.from_discr, is_surjective=is_surjective) diff --git a/meshmode/discretization/connection/refinement.py b/meshmode/discretization/connection/refinement.py index bed288186408677ff7df006e270e66a6ae2fdb74..1124e5ad9b4e8b78d4d9d6c61ba7d9c72cc0a381 100644 --- a/meshmode/discretization/connection/refinement.py +++ b/meshmode/discretization/connection/refinement.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import division, print_function, absolute_import - __copyright__ = "Copyright (C) 2016 Matt Wala" __license__ = """ diff --git a/meshmode/discretization/connection/same_mesh.py b/meshmode/discretization/connection/same_mesh.py index 355d534944e905974ca61ec210f64bb48e91bfcd..93f7933540ef6022bff4945d1349785ee40d38e3 100644 --- a/meshmode/discretization/connection/same_mesh.py +++ b/meshmode/discretization/connection/same_mesh.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function, absolute_import - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ diff --git a/meshmode/discretization/poly_element.py b/meshmode/discretization/poly_element.py index 39c3043b43a1b136e589e1ea82ec3ebc589c2906..3651a6707212aeb908977cd783f62b278502094b 100644 --- a/meshmode/discretization/poly_element.py +++ b/meshmode/discretization/poly_element.py @@ -1,5 +1,3 @@ -from __future__ import division - __copyright__ = "Copyright (C) 2013 Andreas Kloeckner" __license__ = """ @@ -365,7 +363,7 @@ class EquidistantTensorProductElementGroup( # {{{ group factories -class ElementGroupFactory(object): +class ElementGroupFactory: """ .. function:: __call__(mesh_ele_group, node_nr_base) """ diff --git a/meshmode/discretization/visualization.py b/meshmode/discretization/visualization.py index 0962068b1bddcfca6eff1decb222cdb549971c2c..8eac29f283ec6b5b8e007d0ad4663b7631d76f81 100644 --- a/meshmode/discretization/visualization.py +++ b/meshmode/discretization/visualization.py @@ -174,8 +174,8 @@ class VTKConnectivity: elif isinstance(grp.mesh_el_group, TensorProductElementGroup): node_tuples = list(gnitb(grp.order+1, grp.dim)) - node_tuple_to_index = dict( - (nt, i) for i, nt in enumerate(node_tuples)) + node_tuple_to_index = { + nt: i for i, nt in enumerate(node_tuples)} def add_tuple(a, b): return tuple(ai+bi for ai, bi in zip(a, b)) @@ -334,7 +334,7 @@ class VTKLagrangeConnectivity(VTKConnectivity): # {{{ visualizer -class Visualizer(object): +class Visualizer: """ .. automethod:: show_scalar_in_mayavi .. automethod:: show_scalar_in_matplotlib_3d diff --git a/meshmode/distributed.py b/meshmode/distributed.py index bcda88f9d8d021649925bc7572d5cb9e956f11fd..aaa8b1ccecd079eefb1b447174951d732b8a52b4 100644 --- a/meshmode/distributed.py +++ b/meshmode/distributed.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = """ Copyright (C) 2017 Ellis Hoag Copyright (C) 2017 Andreas Kloeckner @@ -51,7 +49,7 @@ __doc__ = """ # {{{ mesh distributor -class MPIMeshDistributor(object): +class MPIMeshDistributor: """ .. automethod:: is_mananger_rank .. automethod:: send_mesh_parts @@ -155,7 +153,7 @@ def make_remote_group_infos(actx, bdry_conn): for igrp in range(len(bdry_conn.from_discr.groups))] -class MPIBoundaryCommSetupHelper(object): +class MPIBoundaryCommSetupHelper: """ .. automethod:: __call__ .. automethod:: is_setup_ready diff --git a/meshmode/interop/firedrake/connection.py b/meshmode/interop/firedrake/connection.py index 991b3f2930778fe5956dc08f240690d0fd2bcef5..6786bd16276b294a40b7b3a1091599ac985a27e8 100644 --- a/meshmode/interop/firedrake/connection.py +++ b/meshmode/interop/firedrake/connection.py @@ -345,7 +345,7 @@ class FiredrakeConnection: raise ValueError(f"'{field_name}.shape' must be {shape}, not " f"'{field.shape}'") for multi_index, arr in np.ndenumerate(field): - arr_name = "%s[%s]" % (field_name, multi_index) + arr_name = f"{field_name}[{multi_index}]" try: check_dof_array(arr, arr_name) except TypeError as type_err: diff --git a/meshmode/mesh/__init__.py b/meshmode/mesh/__init__.py index dc087f1b8ce898518d73e44fdc644daa3aacad72..494d03c2557e9ca3ed77ef36dca17a860f289e50 100644 --- a/meshmode/mesh/__init__.py +++ b/meshmode/mesh/__init__.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import - __copyright__ = "Copyright (C) 2010,2012,2013 Andreas Kloeckner, Michael Tom" __license__ = """ @@ -22,9 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from six.moves import range -import six - import numpy as np import numpy.linalg as la @@ -61,12 +56,12 @@ Predefined Boundary tags # {{{ element tags -class BTAG_NONE(object): # noqa: N801 +class BTAG_NONE: # noqa: N801 """A boundary tag representing an empty boundary or volume.""" pass -class BTAG_ALL(object): # noqa: N801 +class BTAG_ALL: # noqa: N801 """A boundary tag representing the entire boundary or volume. In the case of the boundary, :class:`BTAG_ALL` does not include rank boundaries, @@ -80,7 +75,7 @@ class BTAG_ALL(object): # noqa: N801 pass -class BTAG_REALLY_ALL(object): # noqa: N801 +class BTAG_REALLY_ALL: # noqa: N801 """A boundary tag representing the entire boundary. Unlike :class:`BTAG_ALL`, this includes rank boundaries, @@ -94,7 +89,7 @@ class BTAG_REALLY_ALL(object): # noqa: N801 pass -class BTAG_NO_BOUNDARY(object): # noqa: N801 +class BTAG_NO_BOUNDARY: # noqa: N801 """A boundary tag indicating that this edge should not fall under :class:`BTAG_ALL`. Among other things, this is used to keep rank boundaries out of :class:`BTAG_ALL`. @@ -102,7 +97,7 @@ class BTAG_NO_BOUNDARY(object): # noqa: N801 pass -class BTAG_PARTITION(object): # noqa: N801 +class BTAG_PARTITION: # noqa: N801 """ A boundary tag indicating that this edge is adjacent to an element of another :class:`Mesh`. The partition number of the adjacent mesh @@ -128,7 +123,7 @@ class BTAG_PARTITION(object): # noqa: N801 return not self.__eq__(other) def __repr__(self): - return "<%s(%s)>" % (type(self).__name__, repr(self.part_nr)) + return "<{}({})>".format(type(self).__name__, repr(self.part_nr)) class BTAG_INDUCED_BOUNDARY(BTAG_NO_BOUNDARY): # noqa: N801 @@ -145,8 +140,8 @@ class BTAG_INDUCED_BOUNDARY(BTAG_NO_BOUNDARY): # noqa: N801 pass -SYSTEM_TAGS = set([BTAG_NONE, BTAG_ALL, BTAG_REALLY_ALL, BTAG_NO_BOUNDARY, - BTAG_PARTITION, BTAG_INDUCED_BOUNDARY]) +SYSTEM_TAGS = {BTAG_NONE, BTAG_ALL, BTAG_REALLY_ALL, BTAG_NO_BOUNDARY, + BTAG_PARTITION, BTAG_INDUCED_BOUNDARY} # }}} @@ -343,7 +338,7 @@ class SimplexElementGroup(MeshElementGroup): "element. expected: %d, got: %d" % (dims+1, vertex_indices.shape[-1])) - super(SimplexElementGroup, self).__init__(order, vertex_indices, nodes, + super().__init__(order, vertex_indices, nodes, element_nr_base, node_nr_base, unit_nodes, dim) @property @@ -413,7 +408,7 @@ class TensorProductElementGroup(MeshElementGroup): "element. expected: %d, got: %d" % (2**dims, vertex_indices.shape[-1])) - super(TensorProductElementGroup, self).__init__(order, vertex_indices, nodes, + super().__init__(order, vertex_indices, nodes, element_nr_base, node_nr_base, unit_nodes) def face_vertex_indices(self): @@ -783,8 +778,8 @@ class Mesh(Record): raise ValueError("too few bits in element_id_dtype to represent all " "boundary tags") - btag_to_index = dict( - (btag, i) for i, btag in enumerate(boundary_tags)) + btag_to_index = { + btag: i for i, btag in enumerate(boundary_tags)} # }}} @@ -838,7 +833,7 @@ class Mesh(Record): if facial_adjacency_groups: assert len(facial_adjacency_groups) == len(self.groups) for fagrp_map in facial_adjacency_groups: - for fagrp in six.itervalues(fagrp_map): + for fagrp in fagrp_map.values(): nfagrp_elements, = fagrp.elements.shape assert fagrp.element_faces.dtype == self.face_id_dtype @@ -1121,7 +1116,7 @@ def _compute_facial_adjacency_from_vertices(groups, boundary_tags, # maps tuples (igrp, ineighbor_group) to number of elements group_count = {} - for face_tuples in six.itervalues(face_map): + for face_tuples in face_map.values(): if len(face_tuples) == 2: (igrp, _, _), (inb_grp, _, _) = face_tuples group_count[igrp, inb_grp] = group_count.get((igrp, inb_grp), 0) + 1 @@ -1197,7 +1192,7 @@ def _compute_facial_adjacency_from_vertices(groups, boundary_tags, # maps tuples (igrp, ineighbor_group) to number of elements filled in group fill_count = {} - for face_tuples in six.itervalues(face_map): + for face_tuples in face_map.values(): if len(face_tuples) == 2: for (igroup, iel, iface), (ineighbor_group, inb_el, inb_face) in [ (face_tuples[0], face_tuples[1]), @@ -1244,7 +1239,7 @@ def _compute_facial_adjacency_from_vertices(groups, boundary_tags, # {{{ as_python def _numpy_array_as_python(array): - return "np.array(%s, dtype=np.%s)" % ( + return "np.array({}, dtype=np.{})".format( repr(array.tolist()), array.dtype.name) @@ -1274,7 +1269,7 @@ def as_python(mesh, function_name="make_mesh"): cg("") for group in mesh.groups: cg("import %s" % type(group).__module__) - cg("groups.append(%s.%s(" % ( + cg("groups.append({}.{}(".format( type(group).__module__, type(group).__name__)) cg(" order=%s," % group.order) @@ -1296,16 +1291,16 @@ def as_python(mesh, function_name="make_mesh"): "neighbors": _numpy_array_as_python(fagrp.neighbors), "neighbor_faces": _numpy_array_as_python(fagrp.neighbor_faces), } - return ",\n ".join("%s=%s" % (k, v) for k, v in six.iteritems(params)) + return ",\n ".join(f"{k}={v}" for k, v in params.items()) if mesh._facial_adjacency_groups: cg("facial_adjacency_groups = []") for igrp, fagrp_map in enumerate(mesh.facial_adjacency_groups): cg("facial_adjacency_groups.append({%s})" % ",\n ".join( - "%r: FacialAdjacencyGroup(%s)" % ( + "{!r}: FacialAdjacencyGroup({})".format( inb_grp, fagrp_params_str(fagrp)) - for inb_grp, fagrp in six.iteritems(fagrp_map))) + for inb_grp, fagrp in fagrp_map.items())) else: cg("facial_adjacency_groups = %r" % mesh._facial_adjacency_groups) @@ -1330,7 +1325,7 @@ def as_python(mesh, function_name="make_mesh"): cg(" element_id_dtype=np.%s," % mesh.element_id_dtype.name) if isinstance(mesh._nodal_adjacency, NodalAdjacency): - el_con_str = "(%s, %s)" % ( + el_con_str = "({}, {})".format( _numpy_array_as_python( mesh._nodal_adjacency.neighbors_starts), _numpy_array_as_python( diff --git a/meshmode/mesh/generation.py b/meshmode/mesh/generation.py index 8ee34cc2bd2e439ec17cc2e3363c784b9f070f4a..63986df666adeb4ac2ff1d378f32a1e9f510b8d7 100644 --- a/meshmode/mesh/generation.py +++ b/meshmode/mesh/generation.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import - __copyright__ = "Copyright (C) 2013 Andreas Kloeckner" __license__ = """ @@ -22,7 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from six.moves import range import numpy as np import numpy.linalg as la @@ -184,7 +181,7 @@ def apple(a, t): ]) -class WobblyCircle(object): +class WobblyCircle: """ .. automethod:: random .. automethod:: __call__ @@ -224,7 +221,7 @@ class NArmedStarfish(WobblyCircle): def __init__(self, n_arms, amplitude): coeffs = np.zeros(n_arms) coeffs[-1] = amplitude - super(NArmedStarfish, self).__init__(coeffs) + super().__init__(coeffs) starfish = NArmedStarfish(5, 0.25) diff --git a/meshmode/mesh/io.py b/meshmode/mesh/io.py index bfda552ed6bee47811ae3a73d058384c0b5182e5..d689ee5749892dba9cf6541aaf641da1388667bd 100644 --- a/meshmode/mesh/io.py +++ b/meshmode/mesh/io.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -22,8 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import six -from six.moves import range, zip import numpy as np from gmsh_interop.reader import ( # noqa @@ -131,7 +127,7 @@ class GmshMeshReceiver(GmshMeshReceiverBase): ambient_dim = self.points.shape[-1] mesh_bulk_dim = max( - el_type.dimensions for el_type in six.iterkeys(el_type_hist)) + el_type.dimensions for el_type in el_type_hist.keys()) # {{{ build vertex numbering @@ -161,7 +157,7 @@ class GmshMeshReceiver(GmshMeshReceiverBase): # {{{ build vertex array gmsh_vertex_indices, my_vertex_indices = \ - list(zip(*six.iteritems(vertex_gmsh_index_to_mine))) + list(zip(*vertex_gmsh_index_to_mine.items())) vertices = np.empty( (ambient_dim, len(vertex_gmsh_index_to_mine)), dtype=np.float64) vertices[:, np.array(my_vertex_indices, np.intp)] = \ @@ -174,7 +170,7 @@ class GmshMeshReceiver(GmshMeshReceiverBase): bulk_el_types = set() - for group_el_type, ngroup_elements in six.iteritems(el_type_hist): + for group_el_type, ngroup_elements in el_type_hist.items(): if group_el_type.dimensions != mesh_bulk_dim: continue @@ -217,9 +213,9 @@ class GmshMeshReceiver(GmshMeshReceiverBase): elif isinstance(group_el_type, GmshTensorProductElementBase): gmsh_vertex_tuples = type(group_el_type)(order=1).gmsh_node_tuples() - gmsh_vertex_tuples_loc_dict = dict( - (gvt, i) - for i, gvt in enumerate(gmsh_vertex_tuples)) + gmsh_vertex_tuples_loc_dict = { + gvt: i + for i, gvt in enumerate(gmsh_vertex_tuples)} from pytools import ( generate_nonnegative_integer_tuples_below as gnitb) @@ -453,10 +449,10 @@ def to_json(mesh): # not yet implemented "facial_adjacency_groups": None, "boundary_tags": [btag_to_json(btag) for btag in mesh.boundary_tags], - "btag_to_index": dict( - (btag_to_json(btag), value) + "btag_to_index": { + btag_to_json(btag): value - for btag, value in six.iteritems(mesh.btag_to_index)), + for btag, value in mesh.btag_to_index.items()}, "is_conforming": mesh.is_conforming, } diff --git a/meshmode/mesh/processing.py b/meshmode/mesh/processing.py index 0b2d29380e96e2eda89687aea0b1c97bd8986c50..10c0a62ddcb282bff0b9a6b8b34ac5f340692d43 100644 --- a/meshmode/mesh/processing.py +++ b/meshmode/mesh/processing.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -22,7 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from six.moves import range from functools import reduce import numpy as np diff --git a/meshmode/mesh/refinement/__init__.py b/meshmode/mesh/refinement/__init__.py index 5c2a56e22c94669e91026d2e2335056c01b4f01b..be101b4871b39b9af2d688c32083cd4143e071c3 100644 --- a/meshmode/mesh/refinement/__init__.py +++ b/meshmode/mesh/refinement/__init__.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - __copyright__ = "Copyright (C) 2014-6 Shivam Gupta" __license__ = """ @@ -25,7 +23,6 @@ THE SOFTWARE. import numpy as np import itertools -from six.moves import range from pytools import RecordWithoutPickling from meshmode.mesh.refinement.no_adjacency import ( # noqa: F401 RefinerWithoutAdjacency) @@ -41,7 +38,7 @@ __doc__ = """ """ -class TreeRayNode(object): +class TreeRayNode: """Describes a ray as a tree, this class represents each node in this tree .. attribute:: left Left child. @@ -83,7 +80,7 @@ class _GroupRefinementRecord(RecordWithoutPickling): tesselation=tesselation, element_mapping=element_mapping) -class Refiner(object): +class Refiner: """An older that mostly succeeds at preserving adjacency across non-conformal refinement. diff --git a/meshmode/mesh/refinement/no_adjacency.py b/meshmode/mesh/refinement/no_adjacency.py index b746eba250c569d80f0d12897b5a1c38bc72a727..adf1fc2f91d1146e5eb02f24702a871317cb1486 100644 --- a/meshmode/mesh/refinement/no_adjacency.py +++ b/meshmode/mesh/refinement/no_adjacency.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - __copyright__ = """ Copyright (C) 2018 Andreas Kloeckner Copyright (C) 2014-6 Shivam Gupta @@ -28,7 +26,6 @@ THE SOFTWARE. import numpy as np -from six.moves import range # noqa: F401 from pytools import RecordWithoutPickling from pytools import memoize_method @@ -58,7 +55,7 @@ class _GroupRefinementRecord(RecordWithoutPickling): tesselation=tesselation, element_mapping=element_mapping) -class RefinerWithoutAdjacency(object): +class RefinerWithoutAdjacency: """A refiner that may be applied to non-conforming :class:`meshmode.mesh.Mesh` instances. It does not generate adjacency information, and it is typically faster than @@ -97,9 +94,9 @@ class RefinerWithoutAdjacency(object): orig_vertex_tuples = [(0,) * dim] + [ (0,) * i + (2,) + (0,) * (dim-i-1) for i in range(dim)] - node_dict = dict( - (ituple, idx) - for idx, ituple in enumerate(ref_vertices)) + node_dict = { + ituple: idx + for idx, ituple in enumerate(ref_vertices)} orig_vertex_indices = [node_dict[vt] for vt in orig_vertex_tuples] from meshmode.mesh.refinement.resampler import SimplexResampler diff --git a/meshmode/mesh/refinement/resampler.py b/meshmode/mesh/refinement/resampler.py index 4631c9caa7220ee7a742670d10b0a7a5998003bd..fd6ae9396f46e6c2e7db4bff6625e6a0f1784ae3 100644 --- a/meshmode/mesh/refinement/resampler.py +++ b/meshmode/mesh/refinement/resampler.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = "Copyright (C) 2016 Matt Wala" __license__ = """ @@ -33,7 +31,7 @@ logger = logging.getLogger(__name__) # {{{ resampling simplex points for refinement # NOTE: Class internal to refiner: do not make documentation public. -class SimplexResampler(object): +class SimplexResampler: """ Resampling of points on simplex elements for refinement. @@ -128,10 +126,10 @@ class SimplexResampler(object): ambient_dim = len(group.nodes) nunit_nodes = len(group.unit_nodes[0]) - return dict((elem, + return {elem: resamp_unit_nodes[ielem].reshape( - (ambient_dim, -1, nunit_nodes))) - for ielem, elem in enumerate(elements)) + (ambient_dim, -1, nunit_nodes)) + for ielem, elem in enumerate(elements)} # }}} diff --git a/meshmode/mesh/refinement/tesselate.py b/meshmode/mesh/refinement/tesselate.py index ed80248cdbfffa34004c8bc218f0aa47f984f02d..211a87f083c52b0d893f3f14da38092dcd9cbc7e 100644 --- a/meshmode/mesh/refinement/tesselate.py +++ b/meshmode/mesh/refinement/tesselate.py @@ -1,5 +1,3 @@ -from __future__ import division, print_function - __copyright__ = """ Copyright (C) 2018 Andreas Kloeckner Copyright (C) 2014-6 Shivam Gupta @@ -54,9 +52,9 @@ def tesselatetri(): result = [] node_tuples = list(gnitstam(2, 2)) - node_dict = dict( - (ituple, idx) - for idx, ituple in enumerate(node_tuples)) + node_dict = { + ituple: idx + for idx, ituple in enumerate(node_tuples)} def try_add_tri(current, d1, d2, d3): try: @@ -83,9 +81,9 @@ def tesselatetri(): def tesselatetet(): node_tuples = list(gnitstam(2, 3)) - node_dict = dict( - (ituple, idx) - for idx, ituple in enumerate(node_tuples)) + node_dict = { + ituple: idx + for idx, ituple in enumerate(node_tuples)} def try_add_tet(current, d1, d2, d3, d4): try: diff --git a/meshmode/mesh/refinement/utils.py b/meshmode/mesh/refinement/utils.py index 2811d3ac155595751c742198ccccaad6cc9fcb60..be64eb07c8873edeecf011b988994b6a40bae116 100644 --- a/meshmode/mesh/refinement/utils.py +++ b/meshmode/mesh/refinement/utils.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = "Copyright (C) 2014-6 Shivam Gupta, Andreas Kloeckner" __license__ = """ diff --git a/meshmode/mesh/tools.py b/meshmode/mesh/tools.py index dd16d5b2b9914444cbd8287ffde632428b8e2af3..517ea92487b87fe6be93f8468d3f8185fc2d533c 100644 --- a/meshmode/mesh/tools.py +++ b/meshmode/mesh/tools.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import - __copyright__ = "Copyright (C) 2010,2012,2013 Andreas Kloeckner, Michael Tom" __license__ = """ @@ -25,7 +23,6 @@ THE SOFTWARE. import numpy as np import numpy.linalg as la from pytools.spatial_btree import SpatialBinaryTreeBucket -from six.moves import range # {{{ make_element_lookup_tree @@ -71,9 +68,9 @@ def nd_quad_submesh(node_tuples): from pytools import single_valued, add_tuples dims = single_valued(len(nt) for nt in node_tuples) - node_dict = dict( - (ituple, idx) - for idx, ituple in enumerate(node_tuples)) + node_dict = { + ituple: idx + for idx, ituple in enumerate(node_tuples)} from pytools import generate_nonnegative_integer_tuples_below as gnitb @@ -145,7 +142,7 @@ def rand_rotation_matrix(ambient_dim, deflection=1.0, randnums=None): # {{{ AffineMap -class AffineMap(object): +class AffineMap: """An affine map ``A@x+b``represented by a matrix *A* and an offset vector *b*. .. attribute:: matrix diff --git a/meshmode/mesh/visualization.py b/meshmode/mesh/visualization.py index 26588b1cfe8b022dac6869d3d3e7efd9ee9b892a..799aba36d4b9699ec23b3026e9bc0cfa9316684c 100644 --- a/meshmode/mesh/visualization.py +++ b/meshmode/mesh/visualization.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -23,7 +21,6 @@ THE SOFTWARE. """ import numpy as np -from six.moves import range __doc__ = """ .. autofunction:: draw_2d_mesh diff --git a/setup.py b/setup.py index 022737fa0b5d5b3e3996098918e927b868aa176e..d7ebe7a788c19a89ed3298215692d12ccc5969f9 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,6 @@ def main(): "numpy", "modepy", "gmsh_interop", - "six", "pytools>=2020.3", "pytest>=2.3", "loo.py>=2014.1", diff --git a/test/test_chained.py b/test/test_chained.py index 01a60788d29fb9359b69a7c2c63e8c9637d01490..773a55670698087e51c899426a7c404f2c4e9fb9 100644 --- a/test/test_chained.py +++ b/test/test_chained.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = "Copyright (C) 2018 Alexandru Fikl" __license__ = """ @@ -53,7 +51,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(f"unknown mesh name: {mesh_name}") elif ndim == 3: from meshmode.mesh.generation import generate_torus from meshmode.mesh.generation import generate_warped_rect_mesh @@ -67,9 +65,9 @@ def create_discretization(actx, ndim, elif mesh_name == "warp": mesh = generate_warped_rect_mesh(ndim, order=order, n=nelements) else: - raise ValueError("unknown mesh name: {}".format(mesh_name)) + raise ValueError(f"unknown mesh name: {mesh_name}") else: - raise ValueError("unsupported dimension: {}".format(ndim)) + raise ValueError(f"unsupported dimension: {ndim}") # create discretization from meshmode.discretization import Discretization @@ -236,7 +234,7 @@ def test_chained_full_resample_matrix(actx_factory, ndim, visualize=False): chained = ChainedDiscretizationConnection(connections) def f(x): - from six.moves import reduce + from functools import reduce return 0.1 * reduce(lambda x, y: x * actx.np.sin(5 * y), x) resample_mat = actx.to_numpy(make_full_resample_matrix(actx, chained)) @@ -303,7 +301,7 @@ def test_chained_to_direct(actx_factory, ndim, chain_type, assert np.min(to_element_indices) > 0 def f(x): - from six.moves import reduce + from functools import reduce return 0.1 * reduce(lambda x, y: x * actx.np.sin(5 * y), x) x = thaw(actx, connections[0].from_discr.nodes()) diff --git a/test/test_firedrake_interop.py b/test/test_firedrake_interop.py index 2c7ecf000212a64368a3dd6e341fb7e25ba2be7e..f8189f526621a48b1337ccc2edfc2e13a17a80e4 100644 --- a/test/test_firedrake_interop.py +++ b/test/test_firedrake_interop.py @@ -22,7 +22,6 @@ THE SOFTWARE. import numpy as np import pyopencl as cl -import six from pyopencl.tools import ( # noqa pytest_generate_tests_for_pyopencl @@ -128,7 +127,7 @@ def check_consistency(fdrake_fspace, discr, group_nr=0): cfspace = fdrake_mesh.coordinates.function_space() entity_dofs = cfspace.finat_element.entity_dofs()[0] fdrake_unit_vert_indices = [] - for _, local_node_nrs in sorted(six.iteritems(entity_dofs)): + for _, local_node_nrs in sorted(entity_dofs.items()): assert len(local_node_nrs) == 1 fdrake_unit_vert_indices.append(local_node_nrs[0]) @@ -242,7 +241,7 @@ def test_from_boundary_consistency(ctx_factory, cfspace = fdrake_mesh.coordinates.function_space() entity_dofs = cfspace.finat_element.entity_dofs()[0] fdrake_unit_vert_indices = [] - for _, local_node_nrs in sorted(six.iteritems(entity_dofs)): + for _, local_node_nrs in sorted(entity_dofs.items()): assert len(local_node_nrs) == 1 fdrake_unit_vert_indices.append(local_node_nrs[0]) fdrake_unit_vert_indices = np.array(fdrake_unit_vert_indices) @@ -314,7 +313,7 @@ def test_bdy_tags(square_or_cube_mesh, bdy_ids, coord_indices, coord_values, mm_mesh, orient = import_firedrake_mesh(square_or_cube_mesh, cells_to_use=cells_to_use) # Ensure meshmode required boundary tags are there - assert set([BTAG_ALL, BTAG_REALLY_ALL]) <= set(mm_mesh.boundary_tags) + assert {BTAG_ALL, BTAG_REALLY_ALL} <= set(mm_mesh.boundary_tags) # Check disjoint coverage of bdy ids and BTAG_ALL check_bc_coverage(mm_mesh, [BTAG_ALL]) check_bc_coverage(mm_mesh, bdy_ids) @@ -424,12 +423,12 @@ def test_from_fd_transfer(ctx_factory, fspace_degree, assert dim == 2 if fdrake_mesh_name == "blob2d-order1": from firedrake import Mesh - fdrake_mesh = Mesh("%s-h%s.msh" % (fdrake_mesh_name, mesh_par), + fdrake_mesh = Mesh(f"{fdrake_mesh_name}-h{mesh_par}.msh", dim=dim) else: from meshmode.mesh.io import read_gmsh from meshmode.interop.firedrake import export_mesh_to_firedrake - mm_mesh = read_gmsh("%s-h%s.msh" % (fdrake_mesh_name, mesh_par), + mm_mesh = read_gmsh(f"{fdrake_mesh_name}-h{mesh_par}.msh", force_ambient_dim=dim) fdrake_mesh, _, _ = export_mesh_to_firedrake(mm_mesh) h = float(mesh_par) @@ -490,7 +489,7 @@ def test_from_fd_transfer(ctx_factory, fspace_degree, eoc_recorders[(False, d)].add_data_point(h, err) # assert that order is correct or error is "low enough" - for ((fd2mm, d), eoc_rec) in six.iteritems(eoc_recorders): + for ((fd2mm, d), eoc_rec) in eoc_recorders.items(): print("\nfiredrake -> meshmode: %s\nvector *x* -> *sin(x[%s])*\n" % (fd2mm, d), eoc_rec) assert ( @@ -527,7 +526,7 @@ def test_to_fd_transfer(ctx_factory, fspace_degree, mesh_name, mesh_pars, dim): if mesh_name in ("blob2d-order1", "blob2d-order4"): assert dim == 2 from meshmode.mesh.io import read_gmsh - mm_mesh = read_gmsh("%s-h%s.msh" % (mesh_name, mesh_par), + mm_mesh = read_gmsh(f"{mesh_name}-h{mesh_par}.msh", force_ambient_dim=dim) h = float(mesh_par) elif mesh_name == "warp": @@ -563,7 +562,7 @@ def test_to_fd_transfer(ctx_factory, fspace_degree, mesh_name, mesh_pars, dim): eoc_recorders[d].add_data_point(h, err) # assert that order is correct or error is "low enough" - for d, eoc_rec in six.iteritems(eoc_recorders): + for d, eoc_rec in eoc_recorders.items(): print("\nvector *x* -> *x[%s]*\n" % d, eoc_rec) assert ( eoc_rec.order_estimate() >= fspace_degree diff --git a/test/test_meshmode.py b/test/test_meshmode.py index 258741a60a21dea5c7247a5baceec59f556f6a46..ce754b3970501ec9edfc98d058f4bf5c485070c3 100644 --- a/test/test_meshmode.py +++ b/test/test_meshmode.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = "Copyright (C) 2014 Andreas Kloeckner" __license__ = """ @@ -23,7 +21,6 @@ THE SOFTWARE. """ from functools import partial -from six.moves import range import numpy as np import numpy.linalg as la @@ -991,7 +988,7 @@ def test_sanity_balls(actx_factory, src_file, dim, mesh_order, visualize=False): bdry_vis = make_visualizer(actx, bdry_discr, 7) name = src_file.split("-")[0] - vol_vis.write_vtk_file("sanity_balls_volume_%s_%g.vtu" % (name, h), [ + vol_vis.write_vtk_file(f"sanity_balls_volume_{name}_{h:g}.vtu", [ ("f", vol_one), ("area_el", bind( vol_discr, @@ -999,7 +996,7 @@ def test_sanity_balls(actx_factory, src_file, dim, mesh_order, visualize=False): (actx)), ]) - bdry_vis.write_vtk_file("sanity_balls_boundary_%s_%g.vtu" % (name, h), [ + bdry_vis.write_vtk_file(f"sanity_balls_boundary_{name}_{h:g}.vtu", [ ("f", bdry_one) ]) @@ -1457,7 +1454,7 @@ def test_is_affine_group_check(mesh_name): is_affine = False mesh = generate_torus(10.0, 2.0, order=order) else: - raise ValueError("unknown mesh name: {}".format(mesh_name)) + raise ValueError(f"unknown mesh name: {mesh_name}") assert all(grp.is_affine for grp in mesh.groups) == is_affine diff --git a/test/test_partition.py b/test/test_partition.py index 5d1c57785325987a091fdc012c3f47685cd2ff07..93bb82239bb0d4381293701402591db51190ee43 100644 --- a/test/test_partition.py +++ b/test/test_partition.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = """ Copyright (C) 2017 Ellis Hoag Copyright (C) 2017 Andreas Kloeckner @@ -25,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from six.moves import range import numpy as np import pyopencl as cl diff --git a/test/test_refinement.py b/test/test_refinement.py index 0cb7b173969a9432416c8ef60e83d592a87d31df..e3362b135a16708e79ee08c08c76470ffb2491c2 100644 --- a/test/test_refinement.py +++ b/test/test_refinement.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - __copyright__ = "Copyright (C) 2014-6 Shivam Gupta, Andreas Kloeckner" __license__ = """