-
Notifications
You must be signed in to change notification settings - Fork 30
Add name filter to attribute setter on Segment
#598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
541a74c
5cd77be
f1c5d71
8cc12c3
786184d
aae4436
713be0c
3f5a23e
0834629
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -587,25 +587,32 @@ def get_beam_attrs_along_segment( | |
| def set_attrs_on_every_element( | ||
| self, | ||
| filter_type: type[Element] | tuple[type[Element]] | None = None, | ||
| filter_name: str | None = None, | ||
|
jank324 marked this conversation as resolved.
|
||
| is_recursive: bool = True, | ||
| **kwargs: dict[str, Any], | ||
| ) -> None: | ||
| """ | ||
| Set attributes on every element of a specific type in the segment. | ||
|
|
||
| :param filter_type: Type of the elements to set the attributes for. | ||
| :param filter_name: Names of the elements to set the attributes for. | ||
|
jank324 marked this conversation as resolved.
Outdated
|
||
| :param is_recursive: If `True`, the this method is applied to nested `Segment`s | ||
|
jank324 marked this conversation as resolved.
Outdated
|
||
| as well. If `False`, only the elements directly in the top-level `Segment` | ||
| are considered. | ||
| :param kwargs: Attributes to set and their values. | ||
| """ | ||
| for element in self.elements: | ||
| if filter_type is None or isinstance(element, filter_type): | ||
| if (filter_type is None or isinstance(element, filter_type)) and ( | ||
| filter_name is None or element.name == filter_name | ||
| ): | ||
| for key, value in kwargs.items(): | ||
| setattr(element, key, value) | ||
| elif is_recursive and isinstance(element, Segment): | ||
| element.set_attrs_on_every_element( | ||
| filter_type=filter_type, is_recursive=True, **kwargs | ||
| filter_type=filter_type, | ||
| filter_name=filter_name, | ||
| is_recursive=True, | ||
| **kwargs, | ||
| ) | ||
|
Comment on lines
+591
to
651
|
||
|
|
||
| def plot( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be moved to new version