Skip to content

Commit

Permalink
exports no longer an attribute of exports
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdark committed Jan 13, 2025
1 parent f7e1652 commit 098a613
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 68 deletions.
28 changes: 0 additions & 28 deletions festim/exports/exports.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import festim
import fenics as f
import warnings


class Exports(list):
Expand All @@ -22,33 +21,6 @@ def __init__(self, *args):
self.final_time = None
self.nb_iterations = 0

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

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

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

Expand Down
40 changes: 0 additions & 40 deletions test/unit/test_exports/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,46 +94,6 @@ def test_assign_exports_wrong_type():
my_exports.insert(0, export_combination)


class TestExportsPropertyDeprWarn:
"""
A temporary test to check DeprecationWarnings in festim.Exports.exports
"""

my_export = festim.Export(field=0)
my_exports = festim.Exports([])

def test_property_depr_warns(self):
with pytest.deprecated_call():
self.my_exports.exports

def test_property_setter_depr_warns(self):
with pytest.deprecated_call():
self.my_exports.exports = [self.my_export]


class TestExportsPropertyRaiseError:
"""
A temporary test to check TypeErrors in festim.Exports.exports
"""

my_export = festim.Export(field=0)
my_exports = festim.Exports([])

def test_set_exports_wrong_type(self):
with pytest.raises(
TypeError,
match="exports must be a list",
):
self.my_exports.exports = self.my_export

def test_set_exports_list_wrong_type(self):
with pytest.raises(
TypeError,
match="exports must be a list of festim.Export",
):
self.my_exports.exports = [self.my_export, 1]


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

0 comments on commit 098a613

Please sign in to comment.