-
Notifications
You must be signed in to change notification settings - Fork 169
Open
Labels
Description
Describe the current issue
Currently, fd.dx()
behaves inconsistently with common Python conventions when given empty containers.
fd.dx() ✅ # Equivalent to Measure('cell', subdomain_id='everywhere')
fd.dx(None) ✅ # Same as above
fd.dx([]) ❌ # Raises an error
fd.dx(()) ❓ # Accepted, but becomes Measure('cell', subdomain_id=()), not 'everywhere'
fd.dx(set()) ❌ # Raises an error
This inconsistency affects not only dx
but likely ds
and other measure-related APIs as well.
If these inconsistencies remain, how can I know which standard Python constructs are safe to use with Firedrake and which are not?
Shouldn't a Python API aim to be consistent with standard Python constructs to ensure intuitive and reliable usage?
Describe the solution you'd like
The API should treat empty containers consistent with both its own handling of None
and Python's standard behavior:
>>> sum([])
0
>>> sum(())
0
>>> sum(set())
0
>>> sum(list())
0
>>> sum(tuple())
0