Conversation
Add method modeler.get_objects_by_name to be consistent with modeler.get_objects_by_material
…_object' into fix/7257_improve_consistency_get_object
Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com>
Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com>
SMoraisAnsys
left a comment
There was a problem hiding this comment.
Should we rework the API to work differently ? Like having a single method to do both approaches ? We could allow different kind of matching mechanism, e.g. (exact, contains, start/endswith, regex), whille keeping the pattern argument (meaning varying depending on the matching mechanism) and en/disabling case sensitive.
Open to discussion
A file containing x,y datapoints can be assigned as a table to permeability.
…_object' into fix/7257_improve_consistency_get_object
|
Any thoughts on my comment @Devin-Crawford @Samuelopez-ansys @MaxJPRey (you reviewed, blame yourself for the ping :p) |
What do you mean @SMoraisAnsys ? get_objects_by_name and get_object_from_name? I would keep get_object_from_name which already exist, and I would add a new argument to specify if you want a perfect match (like now) or partial (with Sebastien's ideas). |
Thanks. Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com>
|
Co-authored-by: Devin <38879940+Devin-Crawford@users.noreply.github.com>
|
Hi @Devin-Crawford , could you please add a test for the new material case, where you pass a tab file? |
…and improve type validation
|
@SMoraisAnsys @Devin-Crawford I added with fnmatch what you suggested, now get_objects_by_name is very complete and accept the wildcard pattern *, like other Ansys tools: |
|
Before merging, @SMoraisAnsys could you please make a last review? |
SMoraisAnsys
left a comment
There was a problem hiding this comment.
Except for those minor comments, the PR seems fine. Thanks for the changes @Devin-Crawford
| old_bondwire = self.get_objects_by_name(assignment)[0] | ||
| if not old_bondwire: | ||
| return False |
There was a problem hiding this comment.
| old_bondwire = self.get_objects_by_name(assignment)[0] | |
| if not old_bondwire: | |
| return False | |
| bojects = self.get_objects_by_name(assignment) | |
| if objects: | |
| old_bondwire = objects[0] | |
| else: | |
| raise ValueError(f"Assignment {assignment} does not match an object.") |
If the returned list is empty, the code will return an exception.
| """Return the objects whose names match a wildcard pattern. | ||
|
|
||
| The ``*`` character acts as a wildcard that matches any sequence of | ||
| characters (including none). The matching mode is inferred |
There was a problem hiding this comment.
| characters (including none). The matching mode is inferred | |
| characters (including none). The matching mode is inferred |
| if assignment in self.object_names: | ||
| # object_id = self.get_obj_id(objname) | ||
| return self.objects[assignment] | ||
| return None |
There was a problem hiding this comment.
Not sure if this is required as, by default, every python function return None
| if len(val) == 4: | ||
| self._property_value[0].value = val | ||
| self._material._update_props(self.name, val, update_aedt=self._material._material_update) | ||
| elif isinstance(val, Path): |
There was a problem hiding this comment.
Maybe adding a check on the kind of file here ? Just to ensure that we call csv.reader() on a CSV file ?
Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com>
52b5610
Description
Add method
modeler.get_objects_by_nameto be consistent withmodeler.get_objects_by_materialIssue linked
Close #7257
Checklist