-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix(graph): Allow any Line subclass as edge_type in Graph/DiGraph #4251
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
Fix(graph): Allow any Line subclass as edge_type in Graph/DiGraph #4251
Conversation
manim/utils/file_ops.py
Outdated
@@ -198,7 +198,7 @@ def open_file(file_path: Path, in_browser: bool = False) -> None: | |||
if current_os == "Windows": | |||
# The method os.startfile is only available in Windows, | |||
# ignoring type error caused by this. | |||
os.startfile(file_path if not in_browser else file_path.parent) # type: ignore[attr-defined] |
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.
Was it really unused? Maybe some static analysis tool was using it?
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.
Anyway I think it should not belong to this PR. Lets keep things clean.
Just do git rebase and remove the commit, instead of doing revert commit.
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.
mypy
was failing due to this.
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.
Oh, I need to teach myself what is mypy :P
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.
mypy
is failing on my local system because I am using windows which can be ignored now that I think I would need to reintroduce the comment to pass the checks
I think this PR should not be solely about supporting Nice Work. |
Fix(graph): LabeledLine can now be used in _add_edge
…and DiGraph Fix(test_graph): Fixed test_graph_accepts_labeledline_as_edge_type() always failing.
4b264ae
to
fddf53a
Compare
I do understand that this PR fixes all the |
Testing every class from
I think it would be enough to just test few more classes inside btw. Accepting PR is not up to me and as such you might need to wait some time for main developers. |
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.
LGTM! Thanks for allowing the use of v0.19.0's new LabeledLine
in graphs.
Technically, the rest of Line
's subclasses, such as DashedLine
, Arrow
and DoubleArrow
, are fine, because their first parameters were also start
and end
. Regardless of that, it's always better to be more explicit.
If possible, could you please also add tests for some other Line
subclasses as mdrost suggested, just in case?
Ok I will do that and push the changes, thank you for reviewing. |
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.
Thank you very much!
Overview: What does this pull request change?
Fix #4250
More broadly, this fix allows any subclass of
Line
to be used as anedge_type
in theGraph
andDiGraph
, making the implementation more flexible and extensible.Motivation and Explanation: Why and how do your changes improve the library?
Previously, the
Graph
andDiGraph
classes assumed that theedge_type
will always have its first two arguments as start and end point.But, such is not true for subclasses of
Line
. This change lets user use any subclass ofLine
inGraph
andDiGraph
.Changes
Line
, not justLabeledLine
._add_edge
accordingly.LabeledLine
as edge types intest_graph.py
.Reviewer Checklist