Skip to content

Commit

Permalink
Merge pull request #410 from tlm-adjoint/jrmaddison/remove_code_gener…
Browse files Browse the repository at this point in the history
…ator

Remove _code_generator code
  • Loading branch information
jrmaddison authored Oct 16, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 914b2ce + a5f11ff commit f18914f
Showing 24 changed files with 3,882 additions and 268 deletions.
10 changes: 2 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -7,21 +7,15 @@

autoapi_type = "python"
autoapi_dirs = ["../../tlm_adjoint"]
autoapi_ignore = ["*/_code_generator/__init__.py",
"*/checkpoint_schedules/__init__.py",
autoapi_ignore = ["*/checkpoint_schedules/__init__.py",
"*/fenics/__init__.py",
"*/fenics/backend.py",
"*/fenics/backend_code_generator_interface.py",
"*/fenics/backend_interface.py",
"*/fenics/backend_overrides.py",
"*/firedrake/__init__.py",
"*/firedrake/backend.py",
"*/firedrake/backend_code_generator_interface.py",
"*/firedrake/backend_interface.py",
"*/firedrake/backend_overrides.py",
"*/numpy/__init__.py",
"*/numpy/backend.py",
"*/numpy/backend_interface.py"]
"*/firedrake/backend_overrides.py"]
autoapi_add_toctree_entry = False
autoapi_options = {"private-members": False}

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
url="https://github.com/tlm-adjoint/tlm_adjoint",
license="GNU LGPL version 3",
packages=["tlm_adjoint",
"tlm_adjoint._code_generator",
"tlm_adjoint.checkpoint_schedules",
"tlm_adjoint.fenics",
"tlm_adjoint.firedrake"],
5 changes: 4 additions & 1 deletion tests/fenics/test_block_system.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@
import mpi4py.MPI as MPI # noqa: N817
import numpy as np
import pytest
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl

pytestmark = pytest.mark.skipif(
MPI.COMM_WORLD.size not in {1, 4},
5 changes: 4 additions & 1 deletion tests/fenics/test_caches.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,10 @@

import numpy as np
import pytest
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl

pytestmark = pytest.mark.skipif(
DEFAULT_COMM.size not in {1, 4},
5 changes: 4 additions & 1 deletion tests/fenics/test_equations.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,10 @@
import numpy as np
import os
import pytest
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl

pytestmark = pytest.mark.skipif(
DEFAULT_COMM.size not in {1, 4},
5 changes: 4 additions & 1 deletion tests/fenics/test_gauss_newton.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,10 @@

import numpy as np
import pytest
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl

pytestmark = pytest.mark.skipif(
DEFAULT_COMM.size not in {1, 4},
5 changes: 4 additions & 1 deletion tests/fenics/test_hessian_system.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,10 @@

import numpy as np
import pytest
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl

pytestmark = pytest.mark.skipif(
DEFAULT_COMM.size not in {1, 4},
1 change: 0 additions & 1 deletion tlm_adjoint/_code_generator/__init__.py

This file was deleted.

31 changes: 0 additions & 31 deletions tlm_adjoint/fenics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import importlib
import sys

modules = [("backend", "tlm_adjoint.fenics"),
("functions", "tlm_adjoint._code_generator"),
("backend_code_generator_interface", "tlm_adjoint.fenics"),
("caches", "tlm_adjoint._code_generator"),
("equations", "tlm_adjoint._code_generator"),
("backend_interface", "tlm_adjoint.fenics"),
("backend_overrides", "tlm_adjoint.fenics"),
("fenics_equations", "tlm_adjoint.fenics"),
("block_system", "tlm_adjoint._code_generator"),
("hessian_system", "tlm_adjoint._code_generator")]

for module_name, package in modules:
if package == "tlm_adjoint._code_generator":
sys.modules[f"tlm_adjoint.fenics.{module_name:s}"] \
= importlib.import_module(f".{module_name:s}",
package="tlm_adjoint._code_generator")
else:
assert package == "tlm_adjoint.fenics"
sys.modules[f"tlm_adjoint._code_generator.{module_name:s}"] \
= importlib.import_module(f".{module_name:s}",
package="tlm_adjoint.fenics")

for module_name, package in modules:
del sys.modules[f"tlm_adjoint._code_generator.{module_name:s}"]
del sys.modules["tlm_adjoint._code_generator"]

del importlib, sys, modules, module_name, package

from .. import * # noqa: E402,F401
del adjoint, alias, cached_hessian, caches, checkpointing, \
eigendecomposition, equation, equations, fixed_point, functional, \
5 changes: 4 additions & 1 deletion tlm_adjoint/fenics/backend_code_generator_interface.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,10 @@
from collections.abc import Sequence
import ffc
import numpy as np
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl

__all__ = \
[
5 changes: 4 additions & 1 deletion tlm_adjoint/fenics/backend_interface.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,10 @@

import functools
import numpy as np
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl

__all__ = \
[
5 changes: 4 additions & 1 deletion tlm_adjoint/fenics/backend_overrides.py
Original file line number Diff line number Diff line change
@@ -24,7 +24,10 @@
from .functions import Constant, define_var_alias

import numpy as np
import ufl
try:
import ufl_legacy as ufl
except ImportError:
import ufl
import warnings
import weakref

Loading

0 comments on commit f18914f

Please sign in to comment.