Skip to content

Commit

Permalink
did the same for Materials Exports and Traps
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Mar 28, 2024
1 parent e2a13bd commit 17dfe0c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
9 changes: 6 additions & 3 deletions festim/concentration/traps/traps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ class Traps(list):

def __init__(self, *args):
# checks that input is list
if not isinstance(*args, list):
raise TypeError("festim.Traps must be a list")
super().__init__(self._validate_trap(item) for item in args[0])
if len(args) == 0:
super().__init__()
else:
if not isinstance(*args, list):
raise TypeError("festim.Traps must be a list")
super().__init__(self._validate_trap(item) for item in args[0])

self.F = None
self.extrinsic_formulations = []
Expand Down
9 changes: 6 additions & 3 deletions festim/exports/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ class Exports(list):

def __init__(self, *args):
# checks that input is list
if not isinstance(*args, list):
raise TypeError("festim.Exports must be a list")
super().__init__(self._validate_export(item) for item in args[0])
if len(args) == 0:
super().__init__()
else:
if not isinstance(*args, list):
raise TypeError("festim.Exports must be a list")
super().__init__(self._validate_export(item) for item in args[0])

self.t = None
self.V_DG1 = None
Expand Down
9 changes: 6 additions & 3 deletions festim/materials/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class Materials(list):

def __init__(self, *args):
# checks that input is list
if not isinstance(*args, list):
raise TypeError("festim.Materials must be a list")
super().__init__(self._validate_material(item) for item in args[0])
if len(args) == 0:
super().__init__()
else:
if not isinstance(*args, list):
raise TypeError("festim.Materials must be a list")
super().__init__(self._validate_material(item) for item in args[0])

self.D = None
self.S = None
Expand Down
8 changes: 8 additions & 0 deletions test/unit/test_exports/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,11 @@ def test_set_exports_list_wrong_type(self):
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
"""
# define exports
festim.Exports()
8 changes: 8 additions & 0 deletions test/unit/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,11 @@ def test_set_materials_list_wrong_type(self):
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
"""
# define exports
F.Materials()
8 changes: 8 additions & 0 deletions test/unit/test_traps/test_traps.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,11 @@ def test_set_traps_list_wrong_type(self):
match="traps must be a list of festim.Trap",
):
self.my_traps.traps = [self.my_trap, 1]


def test_instanciate_with_no_elements():
"""
Test to catch bug described in issue #724
"""
# define exports
festim.Traps()

0 comments on commit 17dfe0c

Please sign in to comment.