fixing bug (#300)
Co-authored-by: Monthly Tag bot <mtbot@noreply.github.com>
This commit is contained in:
@@ -36,7 +36,7 @@ class CartesianDomain(Location):
|
|||||||
:return: Spatial variables defined in ``__init__()``
|
:return: Spatial variables defined in ``__init__()``
|
||||||
:rtype: list[str]
|
:rtype: list[str]
|
||||||
"""
|
"""
|
||||||
return list(self.fixed_.keys()) + list(self.range_.keys())
|
return sorted(list(self.fixed_.keys()) + list(self.range_.keys()))
|
||||||
|
|
||||||
def update(self, new_domain):
|
def update(self, new_domain):
|
||||||
"""Adding new dimensions on the ``CartesianDomain``
|
"""Adding new dimensions on the ``CartesianDomain``
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class EllipsoidDomain(Location):
|
|||||||
:return: Spatial variables defined in '__init__()'
|
:return: Spatial variables defined in '__init__()'
|
||||||
:rtype: list[str]
|
:rtype: list[str]
|
||||||
"""
|
"""
|
||||||
return list(self.fixed_.keys()) + list(self.range_.keys())
|
return sorted(list(self.fixed_.keys()) + list(self.range_.keys()))
|
||||||
|
|
||||||
def is_inside(self, point, check_border=False):
|
def is_inside(self, point, check_border=False):
|
||||||
"""Check if a point is inside the ellipsoid domain.
|
"""Check if a point is inside the ellipsoid domain.
|
||||||
@@ -279,7 +279,7 @@ class EllipsoidDomain(Location):
|
|||||||
return _single_points_sample(n, variables)
|
return _single_points_sample(n, variables)
|
||||||
|
|
||||||
if variables == "all":
|
if variables == "all":
|
||||||
variables = list(self.range_.keys()) + list(self.fixed_.keys())
|
variables = self.variables
|
||||||
|
|
||||||
if mode in ["random"]:
|
if mode in ["random"]:
|
||||||
return _Nd_sampler(n, mode, variables)
|
return _Nd_sampler(n, mode, variables)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class SimplexDomain(Location):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def variables(self):
|
def variables(self):
|
||||||
return self._vertices_matrix.labels
|
return sorted(self._vertices_matrix.labels)
|
||||||
|
|
||||||
def _build_cartesian(self, vertices):
|
def _build_cartesian(self, vertices):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -237,6 +237,9 @@ class AbstractProblem(metaclass=ABCMeta):
|
|||||||
self.input_variables
|
self.input_variables
|
||||||
):
|
):
|
||||||
self._have_sampled_points[location] = True
|
self._have_sampled_points[location] = True
|
||||||
|
self.input_pts[location] = self.input_pts[location].extract(
|
||||||
|
sorted(self.input_variables)
|
||||||
|
)
|
||||||
|
|
||||||
def add_points(self, new_points):
|
def add_points(self, new_points):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -67,12 +67,9 @@ class Poisson(SpatialProblem):
|
|||||||
truth_solution = poisson_sol
|
truth_solution = poisson_sol
|
||||||
|
|
||||||
|
|
||||||
# make the problem
|
|
||||||
poisson_problem = Poisson()
|
|
||||||
|
|
||||||
|
|
||||||
def test_discretise_domain():
|
def test_discretise_domain():
|
||||||
n = 10
|
n = 10
|
||||||
|
poisson_problem = Poisson()
|
||||||
boundaries = ['gamma1', 'gamma2', 'gamma3', 'gamma4']
|
boundaries = ['gamma1', 'gamma2', 'gamma3', 'gamma4']
|
||||||
poisson_problem.discretise_domain(n, 'grid', locations=boundaries)
|
poisson_problem.discretise_domain(n, 'grid', locations=boundaries)
|
||||||
for b in boundaries:
|
for b in boundaries:
|
||||||
@@ -95,6 +92,7 @@ def test_discretise_domain():
|
|||||||
|
|
||||||
def test_sampling_few_variables():
|
def test_sampling_few_variables():
|
||||||
n = 10
|
n = 10
|
||||||
|
poisson_problem = Poisson()
|
||||||
poisson_problem.discretise_domain(n,
|
poisson_problem.discretise_domain(n,
|
||||||
'grid',
|
'grid',
|
||||||
locations=['D'],
|
locations=['D'],
|
||||||
@@ -103,20 +101,33 @@ def test_sampling_few_variables():
|
|||||||
assert poisson_problem._have_sampled_points['D'] is False
|
assert poisson_problem._have_sampled_points['D'] is False
|
||||||
|
|
||||||
|
|
||||||
# def test_sampling_all_args():
|
def test_variables_correct_order_sampling():
|
||||||
# n = 10
|
n = 10
|
||||||
# poisson_problem.discretise_domain(n, 'grid', locations=['D'])
|
poisson_problem = Poisson()
|
||||||
|
poisson_problem.discretise_domain(n,
|
||||||
# def test_sampling_all_kwargs():
|
'grid',
|
||||||
# n = 10
|
locations=['D'],
|
||||||
# poisson_problem.discretise_domain(n=n, mode='latin', locations=['D'])
|
variables=['x'])
|
||||||
|
poisson_problem.discretise_domain(n,
|
||||||
# def test_sampling_dict():
|
'grid',
|
||||||
# n = 10
|
locations=['D'],
|
||||||
# poisson_problem.discretise_domain(
|
variables=['y'])
|
||||||
# {'variables': ['x', 'y'], 'mode': 'grid', 'n': n}, locations=['D'])
|
assert poisson_problem.input_pts['D'].labels == sorted(
|
||||||
|
poisson_problem.input_variables)
|
||||||
# def test_sampling_mixed_args_kwargs():
|
|
||||||
# n = 10
|
poisson_problem.discretise_domain(n,
|
||||||
# with pytest.raises(ValueError):
|
'grid',
|
||||||
# poisson_problem.discretise_domain(n, mode='latin', locations=['D'])
|
locations=['D'])
|
||||||
|
assert poisson_problem.input_pts['D'].labels == sorted(
|
||||||
|
poisson_problem.input_variables)
|
||||||
|
|
||||||
|
poisson_problem.discretise_domain(n,
|
||||||
|
'grid',
|
||||||
|
locations=['D'],
|
||||||
|
variables=['y'])
|
||||||
|
poisson_problem.discretise_domain(n,
|
||||||
|
'grid',
|
||||||
|
locations=['D'],
|
||||||
|
variables=['x'])
|
||||||
|
assert poisson_problem.input_pts['D'].labels == sorted(
|
||||||
|
poisson_problem.input_variables)
|
||||||
Reference in New Issue
Block a user