11"""Module for the Ellipsoid Domain."""
22
3- import torch
43from copy import deepcopy
4+ import torch
55from .base_domain import BaseDomain
66from ..label_tensor import LabelTensor
77from ..utils import check_consistency
@@ -43,16 +43,13 @@ def __init__(self, ellipsoid_dict, sample_surface=False):
4343 :raises ValueError: If the ellipsoid dictionary contains values that are
4444 neither numbers nor lists/tuples of numbers of length 2.
4545 """
46- # Check consistency
47- check_consistency (sample_surface , bool )
48-
4946 # Initialization
5047 super ().__init__ (domain_dict = ellipsoid_dict )
51- self ._sample_surface = sample_surface
48+ self .sample_surface = sample_surface
5249 self .sample_modes = ["random" ]
53- self ._compute_center_axes ()
50+ self .compute_center_axes ()
5451
55- def _compute_center_axes (self ):
52+ def compute_center_axes (self ):
5653 """
5754 Compute centers and axes for the ellipsoid.
5855 """
@@ -93,9 +90,7 @@ def is_inside(self, point, check_border=False):
9390
9491 # Fixed variable checks
9592 fixed_check = all (
96- bool ((point .extract ([k ]) == v ).all ())
97- for k , v in self ._fixed .items ()
98- if k in point .labels
93+ (point .extract ([k ]) == v ).all () for k , v in self ._fixed .items ()
9994 )
10095
10196 # If there are no range variables, return fixed variable check
@@ -116,7 +111,7 @@ def is_inside(self, point, check_border=False):
116111 # Range variable check in the volume
117112 range_check = (eqn <= 0 ) if check_border else (eqn < 0 )
118113
119- return fixed_check and bool ( range_check .item () )
114+ return fixed_check and range_check .item ()
120115
121116 def update (self , domain ):
122117 """
@@ -132,7 +127,7 @@ def update(self, domain):
132127 :rtype: EllipsoidDomain
133128 """
134129 updated = super ().update (domain )
135- updated ._compute_center_axes ()
130+ updated .compute_center_axes ()
136131
137132 return updated
138133
@@ -180,7 +175,7 @@ def sample(self, n, mode="random", variables="all"):
180175 return result
181176
182177 # Sample points
183- pts = self ._sample_range (n , mode , range_vars )
178+ pts = self ._sample_range (n , range_vars )
184179 labels = range_vars
185180
186181 # Add fixed vars
@@ -198,12 +193,11 @@ def sample(self, n, mode="random", variables="all"):
198193
199194 return pts [sorted (pts .labels )]
200195
201- def _sample_range (self , n , mode , variables ):
196+ def _sample_range (self , n , variables ):
202197 """
203198 Sample points and rescale to fit within the specified bounds.
204199
205200 :param int n: The number of points to sample.
206- :param str mode: The sampling method. Default is ``random``.
207201 :param list[str] variables: variables whose samples must be rescaled.
208202 :return: The rescaled sample points.
209203 :rtype: torch.Tensor
@@ -242,6 +236,29 @@ def partial(self):
242236 :rtype: EllipsoidDomain
243237 """
244238 boundary = deepcopy (self )
245- boundary ._sample_surface = True
239+ boundary .sample_surface = True
246240
247241 return boundary
242+
243+ @property
244+ def sample_surface (self ):
245+ """
246+ Whether only the surface of the ellipsoid is considered part of the
247+ domain.
248+
249+ :return: ``True`` if only the surface is considered part of the domain,
250+ ``False`` otherwise.
251+ :rtype: bool
252+ """
253+ return self ._sample_surface
254+
255+ @sample_surface .setter
256+ def sample_surface (self , value ):
257+ """
258+ Setter for the sample_surface property.
259+
260+ :param bool value: The new value for the sample_surface property.
261+ :raises ValueError: If ``value`` is not a boolean.
262+ """
263+ check_consistency (value , bool )
264+ self ._sample_surface = value
0 commit comments