-
Notifications
You must be signed in to change notification settings - Fork 4
empty Unions as empty lists #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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