From 6f686f7e15399a9b2a408763611e8259aee19ddd Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 10 Dec 2025 18:06:00 +0100 Subject: [PATCH 1/3] empty Union as empty list --- sympde/topology/basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sympde/topology/basic.py b/sympde/topology/basic.py index bce622f3..73494efa 100644 --- a/sympde/topology/basic.py +++ b/sympde/topology/basic.py @@ -136,11 +136,11 @@ def __new__(cls, *args): # remove duplicates and sort domains by their string representation args = sorted(set(args), key=str) - # a. If the required Union contains no domains, return None; + # a. If the required Union contains no domains, return an empty list; # 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: From 2d92ce02bc2e63200b696c92333a95a894c9cfc0 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 10 Dec 2025 18:16:18 +0100 Subject: [PATCH 2/3] try with empty tuple --- sympde/topology/basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sympde/topology/basic.py b/sympde/topology/basic.py index 73494efa..bc04395a 100644 --- a/sympde/topology/basic.py +++ b/sympde/topology/basic.py @@ -136,11 +136,11 @@ def __new__(cls, *args): # remove duplicates and sort domains by their string representation args = sorted(set(args), key=str) - # a. If the required Union contains no domains, return an empty list; + # 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 = [] + obj = () elif len(args) == 1: obj = args[0] else: From 4f22ba13fc8ef59b4f137dc6855d6f27d8caf6c5 Mon Sep 17 00:00:00 2001 From: Martin Campos Pinto Date: Wed, 10 Dec 2025 18:33:13 +0100 Subject: [PATCH 3/3] test emptyness as None or () --- sympde/topology/domain.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sympde/topology/domain.py b/sympde/topology/domain.py index 12627ac8..fc1ea476 100644 --- a/sympde/topology/domain.py +++ b/sympde/topology/domain.py @@ -75,12 +75,12 @@ def __new__(cls, name : str, *, # ... # ... - if ( ( interiors is None ) and ( connectivity is None ) and ( dim is None) ): + if ( ( interiors in [None, ()] ) and ( connectivity in [None, ()] ) and ( dim is None) ): raise ValueError('> either interiors or connectivity must be given') # ... # ... - if not( interiors is None ): + if not( interiors in [None, ()] ): if not isinstance( interiors, (*iterable_types, InteriorDomain)): raise TypeError('> Expecting an iterable or a InteriorDomain') @@ -103,7 +103,7 @@ def __new__(cls, name : str, *, interiors = Tuple(*interiors) # ... - if not( boundaries is None ): + if not( boundaries in [None, ()] ): if not isinstance( boundaries, (*iterable_types, Boundary)): raise TypeError('> Expecting an iterable or a Boundary') @@ -119,7 +119,7 @@ def __new__(cls, name : str, *, boundaries = Tuple(*boundaries) - if not( connectivity is None ): + if not( connectivity in [None, ()] ): if not isinstance( connectivity, Connectivity ): raise TypeError('> Expecting a Connectivity') @@ -128,7 +128,7 @@ def __new__(cls, name : str, *, connectivity = Connectivity() # ... - if interiors is None and dim: + if interiors in [None, ()] and dim: interiors = [InteriorDomain(name, dim=dim)] if len(interiors) == 0 and dim is None: @@ -228,7 +228,7 @@ def interfaces(self) -> TypeUnion[Union, Interface, None]: @property def corners(self): corners = getattr(self,'_corners', None) - if corners is None: + if corners in [None, ()]: corners = self.get_shared_corners() self._corners = corners return corners @@ -540,7 +540,7 @@ def join(cls, patches, connectivity, name): # ... boundary boundaries = Union(*[b for p in patches for b in p.boundary]).complement(Union(*boundaries)) - if boundaries is None: + if boundaries in [None, ()]: boundaries = () else : boundaries = boundaries.as_tuple()