Skip to content

Commit

Permalink
Merge pull request festim-dev#725 from RemDelaporteMathurin/hotfix-1.2.1
Browse files Browse the repository at this point in the history
Hotfix 1.2.1
  • Loading branch information
RemDelaporteMathurin authored Mar 29, 2024
2 parents dfec377 + 17dfe0c commit be977a6
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 12 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/derived_quantities/derived_quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ def __init__(
nb_iterations_between_exports: int = None,
) -> None:
# checks that input is list
if not isinstance(*args, list):
raise TypeError("festim.DerivedQuantities must be a list")
super().__init__(self._validate_derived_quantity(item) for item in args[0])
if len(args) == 0:
super().__init__()
else:
if not isinstance(*args, list):
raise TypeError("festim.DerivedQuantities must be a list")
super().__init__(self._validate_derived_quantity(item) for item in args[0])

self.filename = filename
self.nb_iterations_between_compute = nb_iterations_between_compute
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
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,15 @@ def test_set_der_quants_list_wrong_type(self):
self.my_derived_quantity,
1,
]


def test_instanciate_with_no_derived_quantities():
"""
Test to catch bug described in issue #724
"""
# define exports
folder_results = "Results/"
DerivedQuantities(
filename=folder_results + "derived_quantities.csv",
nb_iterations_between_exports=1,
)
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 be977a6

Please sign in to comment.