Skip to content

Commit d4f7a0e

Browse files
fix init
1 parent 572f086 commit d4f7a0e

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pina/domain/base_domain.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,32 @@ class BaseDomain(DomainInterface, metaclass=ABCMeta):
1919
# Define available sampling modes
2020
__AVAILABLE_MODES = ("random", "grid", "lh", "chebyshev", "latin")
2121

22-
def __init__(self, domain_dict):
22+
def __init__(self, domain_dict=None):
2323
"""
2424
Initialization of the :class:`BaseDomain` class.
2525
26-
:param dict domain_dict: A dictionary where the keys are the variable
26+
:param domain_dict: A dictionary where the keys are the variable
2727
names and the values are the domain extrema. The domain extrema can
2828
be either a list or tuple with two elements or a single number. If
2929
the domain extrema is a single number, the variable is fixed to that
3030
value.
31+
:type domain_dict: dict | None
3132
:raises TypeError: If the domain dictionary is not a dictionary.
3233
:raises ValueError: If the domain dictionary is empty.
3334
:raises ValueError: If the domain dictionary contains variables with
3435
invalid ranges.
3536
:raises ValueError: If the domain dictionary contains values that are
3637
neither numbers nor lists/tuples of numbers of length 2.
3738
"""
39+
# Initialize fixed and ranged variables
40+
self._fixed = {}
41+
self._range = {}
42+
invalid = []
43+
44+
# Skip checks if domain_dict is None -- SimplexDomain case
45+
if domain_dict is None:
46+
return
47+
3848
# Check domain_dict is a dictionary
3949
if not isinstance(domain_dict, dict):
4050
raise TypeError(
@@ -51,11 +61,6 @@ def __init__(self, domain_dict):
5161
for v in domain_dict.values():
5262
check_consistency(v, (int, float))
5363

54-
# Store
55-
self._fixed = {}
56-
self._range = {}
57-
invalid = []
58-
5964
# Iterate over domain_dict items
6065
for k, v in domain_dict.items():
6166

pina/domain/simplex_domain.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def __init__(self, simplex_matrix, sample_surface=False):
3838
:raises ValueError: If the number of vertices is not equal to the
3939
dimension of the simplex plus one.
4040
"""
41+
super().__init__()
42+
4143
# Initialization
4244
self.sample_modes = ["random"]
4345
self.sample_surface = sample_surface

0 commit comments

Comments
 (0)