Conversation
| # a. If the required Union contains no domains, return None; | ||
| # a. If the required Union contains no domains, return an empty tuple; | ||
| # b. If it contains a single domain, return the domain itself; | ||
| # c. If it contains multiple domains, create a Union object. | ||
| if not args: | ||
| obj = None | ||
| obj = () | ||
| elif len(args) == 1: | ||
| obj = args[0] | ||
| else: |
There was a problem hiding this comment.
I am not sure I understand why we need this change for the case of an empty Union, but not for a Union containing a single domain. If being able to iterate is really important, why not doing it for all cases?
There was a problem hiding this comment.
Indeed, single domain unions should be handled consistently.
I just wanted to see whether the modification for empty unions was passing the tests before looking at the case of a single element.
I have no idea whether "unions" should be iterable objects, I just saw that we iterate on them in some places and currently this raises an error when the union is empty.
There was a problem hiding this comment.
ps -- according to the mathematical usage, a "union" of domains (sets in Rd) is a priori a domain itself, so it's unclear what we should get when iterating over it: subdomains ? points ?
Maybe the issue comes from the fact that some objects expected to be iterable (like interiors, boundaries or interfaces ) are currently defined as "unions"...
There was a problem hiding this comment.
For now I'm turning this into a draft -- we should probably discuss in issue #183 how to better solve this problem
When a Union is created with no arguments, return an empty list instead of a None object. This should allow to iterate over empty "Union" objects.
Fixes #183