Skip to content

Commit

Permalink
Remove deprecations (#4024)
Browse files Browse the repository at this point in the history
* Remove ancient file

* Remove `.split()`
* Deprecate `.subfunctions` for function spaces in favour of
  `.subspaces`.

Co-authored-by: Josh Hope-Collins <[email protected]>

---------

Co-authored-by: Josh Hope-Collins <[email protected]>
  • Loading branch information
connorjward and JHopeCollins authored Feb 12, 2025
1 parent 26a335c commit 426a498
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 77 deletions.
1 change: 0 additions & 1 deletion firedrake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
from firedrake.mg.opencascade_mh import *
from firedrake.norms import *
from firedrake.nullspace import *
from firedrake.optimizer import *
from firedrake.parameters import *
from firedrake.parloops import *
from firedrake.projection import *
Expand Down
2 changes: 1 addition & 1 deletion firedrake/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def as_subspace(self, field, V, use_split):
if len(field) == 1:
W = V
else:
W = V.subfunctions[field_renumbering[index]] if use_split else V.sub(field_renumbering[index])
W = V.subspaces[field_renumbering[index]] if use_split else V.sub(field_renumbering[index])
if cmpt is not None:
W = W.sub(cmpt)
return W
Expand Down
6 changes: 0 additions & 6 deletions firedrake/cofunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ def subfunctions(self):
of this this :class:`Cofunction`'s :class:`.FunctionSpace`."""
return tuple(type(self)(fs, dat) for fs, dat in zip(self.function_space(), self.dat))

@FunctionMixin._ad_annotate_subfunctions
def split(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions

@utils.cached_property
def _components(self):
if self.function_space().rank == 0:
Expand Down
5 changes: 0 additions & 5 deletions firedrake/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,6 @@ def function_space(self):
def subfunctions(self):
return (self,)

def split(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions

def cell_node_map(self, bcs=None):
"""Return a null cell to node map."""
if bcs is not None:
Expand Down
12 changes: 0 additions & 12 deletions firedrake/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ def subfunctions(self):
for i, (fs, dat) in
enumerate(zip(self.function_space(), self.dat)))

@PETSc.Log.EventDecorator()
def split(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions

@utils.cached_property
def _components(self):
if self.function_space().rank == 0:
Expand Down Expand Up @@ -324,12 +318,6 @@ def subfunctions(self):
return tuple(type(self)(V, val)
for (V, val) in zip(self.function_space(), self.topological.subfunctions))

@FunctionMixin._ad_annotate_subfunctions
def split(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions

@utils.cached_property
def _components(self):
if self.function_space().rank == 0:
Expand Down
51 changes: 28 additions & 23 deletions firedrake/functionspaceimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,17 @@ def topological(self, val):
self.cargo.topological = val

@utils.cached_property
def subfunctions(self):
def subspaces(self):
r"""Split into a tuple of constituent spaces."""
return tuple(type(self).create(subspace, self.mesh())
for subspace in self.topological.subfunctions)
for subspace in self.topological.subspaces)

@property
def subfunctions(self):
import warnings
warnings.warn("The 'subfunctions' property is deprecated for function spaces, please use the "
"'subspaces' property instead", category=FutureWarning)
return self.subspaces

mesh = ufl.FunctionSpace.ufl_domain

Expand All @@ -168,24 +175,18 @@ def ufl_cell(self):
r"""The :class:`~ufl.classes.Cell` this FunctionSpace is defined on."""
return self.mesh().ufl_cell()

@PETSc.Log.EventDecorator()
def split(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions

@utils.cached_property
def _components(self):
if len(self) == 1:
return tuple(type(self).create(self.topological.sub(i), self.mesh())
for i in range(self.block_size))
else:
return self.subfunctions
return self.subspaces

@PETSc.Log.EventDecorator()
def sub(self, i):
mixed = type(self.ufl_element()) is finat.ufl.MixedElement
data = self.subfunctions if mixed else self._components
data = self.subspaces if mixed else self._components
return data[i]

@utils.cached_property
Expand Down Expand Up @@ -319,10 +320,10 @@ def __str__(self):
return "%s(%s, %s)" % (self.__class__.__name__, self.topological, self.mesh())

def __iter__(self):
return iter(self.subfunctions)
return iter(self.subspaces)

def __getitem__(self, i):
return self.subfunctions[i]
return self.subspaces[i]

def __mul__(self, other):
r"""Create a :class:`.MixedFunctionSpace` composed of this
Expand Down Expand Up @@ -641,14 +642,16 @@ def __str__(self):
return self.__repr__()

@utils.cached_property
def subfunctions(self):
r"""Split into a tuple of constituent spaces."""
return (self, )
def subspaces(self):
"""Split into a tuple of constituent spaces."""
return (self,)

def split(self):
@property
def subfunctions(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions
warnings.warn("The 'subfunctions' property is deprecated for function spaces, please use the "
"'subspaces' property instead", category=FutureWarning)
return self.subspaces

def __getitem__(self, i):
r"""Return the ith subspace."""
Expand All @@ -659,7 +662,7 @@ def __getitem__(self, i):
@utils.cached_property
def _components(self):
if self.rank == 0:
return self.subfunctions
return self.subspaces
else:
return tuple(ComponentFunctionSpace(self, i) for i in range(self.block_size))

Expand Down Expand Up @@ -1015,15 +1018,17 @@ def __hash__(self):
return hash(tuple(self))

@utils.cached_property
def subfunctions(self):
def subspaces(self):
r"""The list of :class:`FunctionSpace`\s of which this
:class:`MixedFunctionSpace` is composed."""
return self._spaces

def split(self):
@property
def subfunctions(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions
warnings.warn("The 'subfunctions' property is deprecated for function spaces, please use the "
"'subspaces' property instead", category=FutureWarning)
return self.subspaces

def sub(self, i):
r"""Return the `i`th :class:`FunctionSpace` in this
Expand Down
12 changes: 6 additions & 6 deletions firedrake/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def __init__(
missing_points_behaviour = MissingPointsBehaviour.ERROR

# setup
V_dest = V
V_dest = V.function_space() if isinstance(V, firedrake.Function) else V
src_mesh = extract_unique_domain(expr)
dest_mesh = as_domain(V_dest)
src_mesh_gdim = src_mesh.geometric_dimension()
Expand Down Expand Up @@ -573,24 +573,24 @@ def __init__(
# with arguments, as opposed to just being the argument.
expr_subfunctions = [
firedrake.TestFunction(V_src_sub_func)
for V_src_sub_func in self.expr.function_space().subfunctions
for V_src_sub_func in self.expr.function_space().subspaces
]
elif self.nargs > 1:
raise NotImplementedError(
"Can't yet create an interpolator from an expression with multiple arguments."
)
else:
expr_subfunctions = self.expr.subfunctions
if len(expr_subfunctions) != len(V_dest.subfunctions):
if len(expr_subfunctions) != len(V_dest.subspaces):
raise NotImplementedError(
"Can't interpolate from a non-mixed function space into a mixed function space."
)
for input_sub_func, target_sub_func in zip(
expr_subfunctions, V_dest.subfunctions
for input_sub_func, target_subspace in zip(
expr_subfunctions, V_dest.subspaces
):
sub_interpolator = type(self)(
input_sub_func,
target_sub_func,
target_subspace,
subset=subset,
freeze_expr=freeze_expr,
access=access,
Expand Down
18 changes: 0 additions & 18 deletions firedrake/optimizer.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/firedrake/extrusion/test_real_tensorproduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_real_tensorproduct_mixed(V):
Q = FunctionSpace(mesh, "P", 2)

W = V*Q
for (s_, s) in zip(W.subfunctions, (V, Q)):
for (s_, s) in zip(W.subspaces, (V, Q)):
assert s_.node_set is s.node_set
assert s_.dof_dset is s.dof_dset

Expand Down
4 changes: 2 additions & 2 deletions tests/firedrake/regression/test_function_spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ def test_function_space_vector_function_space_differ(mesh):
def test_indexed_function_space_index(fs):
assert [s.index for s in fs] == list(range(2))
# Create another mixed space in reverse order
fs0, fs1 = fs.subfunctions
fs0, fs1 = fs.subspaces
assert [s.index for s in (fs1 * fs0)] == list(range(2))
# Verify the indices of the original IndexedFunctionSpaces haven't changed
assert fs0.index == 0 and fs1.index == 1


def test_mixed_function_space_split(fs):
assert fs.subfunctions == tuple(fs)
assert fs.subspaces == tuple(fs)


def test_function_space_collapse(cg1):
Expand Down
2 changes: 1 addition & 1 deletion tests/firedrake/regression/test_mixed_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_mass_mixed_tensor(W):

a = (inner(u, v) + inner(p, q) + inner(s, t))*dx

V, Q, T = W.subfunctions
V, Q, T = W.subspaces

u = TrialFunction(V)
v = TestFunction(V)
Expand Down
2 changes: 1 addition & 1 deletion tests/firedrake/regression/test_patch_pc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_jacobi_sor_equivalence(mesh, problem_type, multiplicative):
a = (inner(f[i], f[i]) * inner(grad(u), grad(v)))*dx
L = inner(Constant(rhs), v)*dx
bcs = [DirichletBC(Q, 0, "on_boundary")
for Q in V.subfunctions]
for Q in V.subspaces]
else:
a = inner(grad(u), grad(v))*dx
L = inner(Constant(rhs), v)*dx
Expand Down

0 comments on commit 426a498

Please sign in to comment.