-
-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Hi I first reported this on Firedrake [https://github.com/firedrakeproject/firedrake/issues/4452] and the maintainers suggested here is the place.
Description
The behaviour of subdomain_id varies between the empty tuple case, None case, and no-argument cases.
fd.dx() ✅ # Equivalent to Measure('cell', subdomain_id='everywhere')
fd.dx(None) ✅ # Same as above
fd.dx(()) ❓ # Accepted, but becomes Measure('cell', subdomain_id=()), not 'everywhere'As a result, these two functions behave differently. Shouldn't passing None and empty container behave the same?
1. Implementation with empty tuples
def get_subdomains() -> tuple[int]:
"""Returns the fluid subdomains."""
result = fetch_result()
return result
fd.dx(get_subdomains())2. Implementation with the optional types
def get_subdomains() -> tuple[int] | None:
"""Returns the fluid subdomains."""
result = fetch_result()
if len(result) == 0:
return None
else:
return result
subdomains: tuple[int] | None = get_subdomains()
fd.dx(subdomains)Metadata
Metadata
Assignees
Labels
No labels