Skip to content

Commit

Permalink
remove deprecated materials property and related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdark committed Jan 13, 2025
1 parent 098a613 commit 79f5d3e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
22 changes: 0 additions & 22 deletions festim/materials/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import festim
import fenics as f
from typing import Union
import warnings


class Materials(list):
Expand All @@ -29,27 +28,6 @@ def __init__(self, *args):
self.density = None
self.Q = None

@property
def materials(self):
warnings.warn(
"The materials attribute will be deprecated in a future release, please use festim.Materials as a list instead",
DeprecationWarning,
)
return self

@materials.setter
def materials(self, value):
warnings.warn(
"The materials attribute will be deprecated in a future release, please use festim.Materials as a list instead",
DeprecationWarning,
)
if isinstance(value, list):
if not all(isinstance(t, festim.Material) for t in value):
raise TypeError("materials must be a list of festim.Material")
super().__init__(value)
else:
raise TypeError("materials must be a list")

def __setitem__(self, index, item):
super().__setitem__(index, self._validate_material(item))

Expand Down
40 changes: 0 additions & 40 deletions test/unit/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,46 +402,6 @@ def test_assign_materials_wrong_type():
my_materials.insert(0, mat_combination)


class TestMaterialsPropertyDeprWarn:
"""
A temporary test to check DeprecationWarnings in F.Materials.materials
"""

my_mat = F.Material(id=1, E_D=1, D_0=1)
my_mats = F.Materials([])

def test_property_depr_warns(self):
with pytest.deprecated_call():
self.my_mats.materials

def test_property_setter_depr_warns(self):
with pytest.deprecated_call():
self.my_mats.materials = [self.my_mat]


class TestMaterialsPropertyRaiseError:
"""
A temporary test to check TypeErrors in F.Materials.materials
"""

my_mat = F.Material(id=1, E_D=1, D_0=1)
my_mats = F.Materials([])

def test_set_materials_wrong_type(self):
with pytest.raises(
TypeError,
match="materials must be a list",
):
self.my_mats.materials = self.my_mat

def test_set_materials_list_wrong_type(self):
with pytest.raises(
TypeError,
match="materials must be a list of festim.Material",
):
self.my_mats.materials = [self.my_mat, 1]


def test_instanciate_with_no_elements():
"""
Test to catch bug described in issue #724
Expand Down

0 comments on commit 79f5d3e

Please sign in to comment.