It would be really convenient sometimes to be able to say: if cell in model.geometry: or if cell in universe.
I propose that openmc.Geometry and openmc.Universe implement __contains__ for openmc.Cell. We could also do so for openmc.Surfaces I'm not sure if the latter has as much utility though
Alternatives
Users could instead do:
if cell in model.geometry.get_all_cells().values() This just feels very verbose and not pythonic.
Compatibility
This would add features and should not impact any existing methods.
Description
It would be really convenient sometimes to be able to say:
if cell in model.geometry:
or ifcell in universe
.I propose that
openmc.Geometry
andopenmc.Universe
implement__contains__
foropenmc.Cell
. We could also do so foropenmc.Surfaces
I'm not sure if the latter has as much utility thoughAlternatives
Users could instead do:
if cell in model.geometry.get_all_cells().values()
This just feels very verbose and not pythonic.Compatibility
This would add features and should not impact any existing methods.