Skip to content

Commit

Permalink
systematically add from future import annotations (jorgensd#87)
Browse files Browse the repository at this point in the history
for Python 3.8 annotation compatibility
  • Loading branch information
minrk authored Oct 30, 2023
1 parent 4655233 commit cec732f
Show file tree
Hide file tree
Showing 46 changed files with 55 additions and 15 deletions.
1 change: 1 addition & 0 deletions python/benchmarks/bench_contact_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# Multi point constraint problem for linear elasticity with slip conditions
# between two cubes.
from __future__ import annotations

import warnings
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
Expand Down
1 change: 1 addition & 0 deletions python/benchmarks/bench_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import resource
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
Expand Down
1 change: 1 addition & 0 deletions python/benchmarks/bench_elasticity_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import resource
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
Expand Down
2 changes: 1 addition & 1 deletion python/benchmarks/bench_periodic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# This file is part of DOLFINX_MPC.
#
# SPDX-License-Identifier: MIT

from __future__ import annotations

from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from pathlib import Path
Expand Down
2 changes: 2 additions & 0 deletions python/benchmarks/post_proc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt

Expand Down
1 change: 1 addition & 0 deletions python/benchmarks/ref_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import resource
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
Expand Down
3 changes: 1 addition & 2 deletions python/benchmarks/ref_periodic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# This demo program solves Poisson's equation
#
# - div grad u(x, y) = f(x, y)
Expand All @@ -15,7 +14,7 @@
# This file is part of DOLFINX_MPC.
#
# SPDX-License-Identifier: MIT

from __future__ import annotations

from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from pathlib import Path
Expand Down
2 changes: 2 additions & 0 deletions python/benchmarks/visualize_iterations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator, LogLocator, NullFormatter
import matplotlib.transforms as mtransforms
Expand Down
2 changes: 2 additions & 0 deletions python/demos/create_and_export_mesh.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from pathlib import Path
from typing import Dict, List, Sequence, Tuple, Union

Expand Down
2 changes: 1 addition & 1 deletion python/demos/demo_contact_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# A slip condition is implemented at the interface of the cube.
# Additional constraints to avoid tangential movement is
# added to the to left corner of the top cube.

from __future__ import annotations

import warnings
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
Expand Down
2 changes: 1 addition & 1 deletion python/demos/demo_contact_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Multi point constraint problem for linear elasticity with slip conditions
# between two cubes.

from __future__ import annotations

import warnings
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
Expand Down
2 changes: 2 additions & 0 deletions python/demos/demo_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from pathlib import Path

import dolfinx.fem as fem
Expand Down
2 changes: 1 addition & 1 deletion python/demos/demo_elasticity_disconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: MIT
#
# Create constraint between two bodies that are not in contact

from __future__ import annotations

from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions python/demos/demo_elasticity_disconnect_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: MIT
#
# Create constraint between two bodies that are not in contact
from __future__ import annotations

from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion python/demos/demo_periodic3d_topological.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# This demo program solves Poisson's equation
#
# - div grad u(x, y) = f(x, y)
Expand All @@ -15,6 +14,7 @@
# This file is part of DOLFINX_MPCX.
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from pathlib import Path
from typing import Dict, Union
Expand Down
3 changes: 2 additions & 1 deletion python/demos/demo_periodic_geometrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
# This file is part of DOLFINX_MPCX.
#
# SPDX-License-Identifier: MIT

from __future__ import annotations

from pathlib import Path
from typing import Union

import dolfinx.fem as fem
import numpy as np
import scipy.sparse.linalg
Expand Down
1 change: 1 addition & 0 deletions python/demos/demo_periodic_gep.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# where A and B are real symmetric positive definite matrices. The generalized
# eigenvalue problem is solved using SLEPc and the computed eigenvalues are
# compared to the exact ones.
from __future__ import annotations

from pathlib import Path
from typing import List, Tuple
Expand Down
2 changes: 2 additions & 0 deletions python/demos/demo_stokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# We start by the various modules required for this demo

# +
from __future__ import annotations

from pathlib import Path
from typing import Union

Expand Down
1 change: 1 addition & 0 deletions python/demos/demo_stokes_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# The demos solves the Stokes problem using the nest functionality to
# avoid using mixed function spaces. The demo also illustrates how to use
# block preconditioners with PETSc
from __future__ import annotations

from pathlib import Path

Expand Down
3 changes: 2 additions & 1 deletion python/dolfinx_mpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""Main module for DOLFINX_MPC"""

# flake8: noqa
from __future__ import annotations

import dolfinx_mpc.cpp

Expand All @@ -21,4 +22,4 @@
__all__ = ["assemble_matrix", "create_matrix_nest", "assemble_matrix_nest",
"assemble_vector", "apply_lifting", "assemble_vector_nest",
"create_vector_nest", "MultiPointConstraint", "LinearProblem",
"create_sparsity_pattern"]
"create_sparsity_pattern"]
1 change: 1 addition & 0 deletions python/dolfinx_mpc/assemble_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from typing import Optional, Sequence, Union

Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/assemble_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import contextlib
from typing import List, Optional, Sequence
Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/dictcondition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import typing

Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/multipointconstraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from typing import Callable, Dict, List, Optional, Tuple, Union

Expand Down
4 changes: 2 additions & 2 deletions python/dolfinx_mpc/numba/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""Numba extension for dolfinx_mpc"""

# flake8: noqa

from __future__ import annotations

try:
import numba
Expand All @@ -16,4 +16,4 @@
from .assemble_matrix import assemble_matrix
from .assemble_vector import assemble_vector

__all__ = ["assemble_matrix", "assemble_vector"]
__all__ = ["assemble_matrix", "assemble_vector"]
1 change: 1 addition & 0 deletions python/dolfinx_mpc/numba/assemble_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from typing import List, Optional, Tuple

Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/numba/assemble_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from typing import Optional, Tuple

Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/numba/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import numba
import numpy
Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/numba/numba_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import ctypes
import ctypes.util
Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This file is part of DOLFINx MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import typing

Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""Helper functions for tests in Dolfinx mpc"""

# flake8: noqa
from __future__ import annotations

from .test import (compare_CSR, compare_mpc_lhs, compare_mpc_rhs,
gather_constants, gather_PETScMatrix, gather_PETScVector,
Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/utils/mpc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from contextlib import ExitStack

Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/utils/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

__all__ = ["gather_PETScVector", "gather_PETScMatrix", "compare_mpc_lhs", "compare_mpc_rhs",
"gather_transformation_matrix", "compare_CSR"]
Expand Down
1 change: 1 addition & 0 deletions python/tests/mwe123.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from dolfinx.mesh import create_unit_square, locate_entities_boundary, meshtags
from dolfinx import default_scalar_type
from dolfinx import fem
Expand Down
1 change: 1 addition & 0 deletions python/tests/nitsche_ufl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (C) 2021 Jørgen S. Dokken and Sarah Roggendorf
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from typing import Dict, Tuple

Expand Down
1 change: 1 addition & 0 deletions python/tests/test_cube_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# Multi point constraint problem for linear elasticity with slip conditions
# between two cubes.
from __future__ import annotations

import dolfinx.fem as fem
import gmsh
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_integration_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT

from __future__ import annotations

import numpy as np
import pytest
Expand Down
1 change: 1 addition & 0 deletions python/tests/test_lifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

from dolfinx import fem
import dolfinx_mpc
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_linear_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT

from __future__ import annotations

import numpy as np
import pytest
Expand Down
1 change: 1 addition & 0 deletions python/tests/test_matrix_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import dolfinx.fem as fem
import dolfinx_mpc
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_mpc_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT

from __future__ import annotations

import numpy as np
import pytest
Expand Down
2 changes: 2 additions & 0 deletions python/tests/test_nonlinear_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import basix
import dolfinx
import dolfinx.fem.petsc
Expand Down
1 change: 1 addition & 0 deletions python/tests/test_rectangular_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import basix
import dolfinx
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_surface_integral.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT

from __future__ import annotations

import dolfinx.fem as fem
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions python/tests/test_vector_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of DOLFINX_MPC
#
# SPDX-License-Identifier: MIT
from __future__ import annotations

import dolfinx.fem as fem
import dolfinx_mpc
Expand Down
Loading

0 comments on commit cec732f

Please sign in to comment.