You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* `Unit converters <../examples/tutorial_unitconverters.ipynb>`__ (Default value = None)
"""
ifself.completed:
raiseRuntimeError(
"FieldSet has already been completed. Are you trying to add a Field after you've created the ParticleSet?"
)
name=field.nameifnameisNoneelsename
ifhasattr(self, name): # check if Field with same name already exists when adding new Field
raiseRuntimeError(f"FieldSet already has a Field with name '{name}'")
ifisinstance(field, NestedField):
setattr(self, name, field)
forfldinfield:
self.gridset.add_grid(fld)
fld.fieldset=self
else:
setattr(self, name, field)
self.gridset.add_grid(field)
field.fieldset=self
I don't like the current implementation of .add_field() calling set_attr(self, name, field). Programmatically storing these fields messes with static typecheckers, and it would be clearer if this was handled another way (either a list of fields, a dictionary, or something else). We can set __getattr__ so users can still do fieldset.U
The text was updated successfully, but these errors were encountered:
Ah yes, definitely would be impacted by unstructured grids. Might be worth refactoring ahead of time in prep for v4 (so that development is easier), but it's low on my to-do list
Parcels/parcels/fieldset.py
Lines 162 to 197 in 595b7a9
I don't like the current implementation of
.add_field()
callingset_attr(self, name, field)
. Programmatically storing these fields messes with static typecheckers, and it would be clearer if this was handled another way (either a list of fields, a dictionary, or something else). We can set__getattr__
so users can still dofieldset.U
The text was updated successfully, but these errors were encountered: