@@ -204,15 +204,16 @@ def plot(
204204 the loads, and the boundary conditions currently defined.
205205 Each representation can be deactivated with its respective boolean argument.
206206
207- Args:
208- mesh:
209- Whether to plot the mesh representation.
210- constructed_geometries:
211- Whether to plot the constructed geometries.
212- loads:
213- Whether to plot the loads.
214- boundary_conditions:
215- Whether to plot the boundary conditions.
207+ Parameters
208+ ----------
209+ mesh:
210+ Whether to plot the mesh representation.
211+ constructed_geometries:
212+ Whether to plot the constructed geometries.
213+ loads:
214+ Whether to plot the loads.
215+ boundary_conditions:
216+ Whether to plot the boundary conditions.
216217
217218 Returns
218219 -------
@@ -238,7 +239,7 @@ def plot(
238239 plt .show_figure ()
239240
240241 @property
241- def active_selection (self ) -> Selection :
242+ def active_selection (self ) -> Union [ Selection , None ] :
242243 """Active selection used by default for result queries.
243244
244245 Returns a :object:`ansys.dpf.post.selection.Selection` object.
@@ -249,13 +250,14 @@ def active_selection(self) -> Selection:
249250 >>> from ansys.dpf.post import examples
250251 >>> simulation = post.load_simulation(examples.static_rst)
251252 >>> selection = post.selection.Selection()
252- >>> simulation.activate_selection(selection= selection)
253+ >>> simulation.active_selection = selection
253254 >>> print(simulation.active_selection) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
254255 <ansys.dpf.post.selection.Selection object at ...>
255256 """
256257 return self ._active_selection
257258
258- def activate_selection (self , selection : Selection ):
259+ @active_selection .setter
260+ def active_selection (self , selection : Union [Selection , None ]):
259261 """Sets a selection as active on the simulation.
260262
261263 Activating a given selection on a simulation means it is used
@@ -267,11 +269,14 @@ def activate_selection(self, selection: Selection):
267269 >>> from ansys.dpf.post import examples
268270 >>> simulation = post.load_simulation(examples.static_rst)
269271 >>> selection = post.selection.Selection()
270- >>> simulation.activate_selection(selection= selection)
272+ >>> simulation.active_selection = selection
271273 >>> print(simulation.active_selection) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
272274 <ansys.dpf.post.selection.Selection object at ...>
273275 """
274- self ._active_selection = selection
276+ if selection is not None :
277+ self ._active_selection = selection
278+ else :
279+ self .deactivate_selection ()
275280
276281 def deactivate_selection (self ):
277282 """Deactivate the currently active selection.
@@ -282,7 +287,7 @@ def deactivate_selection(self):
282287 >>> from ansys.dpf.post import examples
283288 >>> simulation = post.load_simulation(examples.static_rst)
284289 >>> selection = post.selection.Selection()
285- >>> simulation.activate_selection(selection= selection)
290+ >>> simulation.active_selection = selection
286291 >>> print(simulation.active_selection) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
287292 <ansys.dpf.post.selection.Selection object at ...>
288293 >>> simulation.deactivate_selection()
@@ -360,7 +365,8 @@ def _build_components(self, base_name, components, component_names):
360365 for comp in components :
361366 if not (isinstance (comp , str ) or isinstance (comp , int )):
362367 raise ValueError (
363- "Argument 'components' can only contain integers and/or strings."
368+ "Argument 'components' can only contain integers and/or strings.\n "
369+ f"The provided component '{ comp } ' is not valid."
364370 )
365371 if isinstance (comp , int ):
366372 comp = str (comp )
@@ -611,8 +617,6 @@ def _build_selection(
611617 dpf .time_freq_scoping_factory .scoping_on_all_time_freqs (self ._model )
612618 )
613619 elif set_ids is not None :
614- if isinstance (set_ids , int ):
615- set_ids = [set_ids ]
616620 selection .select_time_freq_sets (time_freq_sets = set_ids )
617621
618622 elif times is not None :
0 commit comments