Tutorial teaches creating blank grid fields
cmshobe opened this issue · 5 comments
But this seems not to be the preferred approach in polished Landlab components. The tutorial should reflect whichever approach (create a blank field, throw an error, whatever) is preferred.
@cmshobe: Sorry. Could you be a bit more specific? I'm not quite following. If you could provide an example of what one of the tutorials shows and what you think it should be, that would be great! Thanks!
@mcflugen Sorry about that; What I mean is that the tutorial shows checking of grid fields like this:
# Create fields...
# Elevation
if 'topographic__elevation' in grid.at_node:
self.elev = grid.at_node['topographic__elevation']
else:
self.elev = grid.add_zeros('node', 'topographic__elevation')
But either @SiccarPoint or @mcflugen commented in my component that it would be better to throw an error than create a blank field. I agree that throwing an error is probably better, but the tutorial makes it seem like creating a blank field is better.
Good catch. That's not ideal for the tutorial to be showing that. That's clearly fine for output fields, but errors should probably get raised for input fields (& I think mostly are for actual components now).
Also, note that there is no LL "official" preference between add_zeros('node', 'field')
and add_zeros('field', at='node')
. Eric much prefers the latter though.
I'll fix this.
Resolved.