-
Notifications
You must be signed in to change notification settings - Fork 3
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
Rhino compatibility #31
Conversation
I reviewed the commits. I think, it can be merged. I would maybe just keep Or, if we specify the type of print, then it would be good to have |
Hey @petrasvestartas! Thanks for reviewing. The
|
Asked ChatGPT which reminded me that in Python 2.x |
src/compas_model/model/model.py
Outdated
@@ -117,7 +116,7 @@ def __getitem__(self, index): | |||
# Info | |||
# ========================================================================== | |||
|
|||
def print(self): | |||
def print_model(self): |
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.
perhaps we should just switch to using __str__
and print with print(model)
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.
sounds good to me but would have to make changes in Tree.print_hierarchy
and InteractionGraph.print_interactions
as they internally call print
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.
btw I think we should generally avoid calls to print
in COMPAS, especially the parts that are more library-ish.
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.
Let's change to __str__
and then additional change will be needed for the tree
in compas and merge this pull request. Due to multiple other packages, still ironpython needs to be supported for some time.
@tomvanmele changed prints to |
@@ -84,7 +91,8 @@ def edge_interaction(self, edge): | |||
""" | |||
return self.edge_attribute(edge, "interaction") # type: ignore | |||
|
|||
def print_interactions(self): | |||
def interactions(self): |
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.
i dont' think this makes sense.InteractionGraph.interactions
should not return a string, but rather a list of interactions.
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.
agree that's weird, but this previously did the same just using print
. I renamed this to interactions_str
as it really just builds a string form of the interactions.
What would you have InteractionGraph.interactions
return? just a flat list of Interaction
s?
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.
yes, a flat list of all interaction objects for easy access. we do the same, for example, with elements in the model...
@@ -84,8 +91,16 @@ def edge_interaction(self, edge): | |||
""" | |||
return self.edge_attribute(edge, "interaction") # type: ignore | |||
|
|||
def print_interactions(self): | |||
"""Print the interactions contained in the graph.""" | |||
def interactions_str(self): |
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.
in my opinion this long string should be built by __str__
itself, or by some kind of private method, but not by a public API method, since it is basically a utility of __str__
...
@chenkasirer Invoke format and push once more. |
Could we merge and close this pull request? |
Some minor changes related to Rhino/Ironpython compatibility.
PlateElement
andPlateFeature
to second level importsWhat type of change is this?
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
).invoke test
).invoke lint
).compas.datastructures.Mesh
.