File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,7 +42,10 @@ class FieldSet:
4242 """
4343
4444 def __init__ (self , fields : list [Field | VectorField ]):
45- # TODO Nick : Enforce fields to be list of Field or VectorField objects
45+ for field in fields :
46+ if not isinstance (field , (Field , VectorField )):
47+ raise ValueError (f"Expected `field` to be a Field or VectorField object. Got { field } " )
48+
4649 self .fields = {f .name : f for f in fields }
4750 self .constants = {}
4851
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ def fieldset() -> FieldSet:
2121 )
2222
2323
24+ def test_fieldset_init_wrong_types ():
25+ with pytest .raises (ValueError , match = "Expected `field` to be a Field or VectorField object. Got .*" ):
26+ FieldSet ([1.0 , 2.0 , 3.0 ])
27+
28+
2429def test_fieldset_add_constant (fieldset ):
2530 fieldset .add_constant ("test_constant" , 1.0 )
2631 assert fieldset .test_constant == 1.0
You can’t perform that action at this time.
0 commit comments