-
Notifications
You must be signed in to change notification settings - Fork 37
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
Straight line edge conversion for (poly)lines and improved curve conversion #81
Conversation
Want to support polylines and multi segment curves Remove LinearRegression.py
Reviewer's Guide by SourceryThis pull request refactors the curve handling in the graphviz2drawio project to use complex numbers for start, end, and control points. It introduces new Bézier curve operations, updates edge handling and styling, and adds new test cases. The LinearRegression module has been removed in favor of a math-based linearity check. File-Level Changes
Tips
|
Warning Rate limit exceeded@hbmartin has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 0 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes encompass enhancements to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Hey @hbmartin - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Incorrect use of
p.real
andp.imag
(link) - Remove or replace the placeholder assertion (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
- Potential hard-coded secret found. (link)
Here's what I looked at during the review
- 🔴 General issues: 1 blocking issue, 7 other issues
- 🔴 Security: 9 blocking issues
- 🔴 Testing: 1 blocking issue, 3 other issues
- 🟢 Complexity: all looks good
- 🟡 Documentation: 1 issue found
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
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.
Actionable comments posted: 19
Outside diff range and nitpick comments (15)
graphviz2drawio/mx/CurveFactory.py (5)
1-2
: Remove unnecessary blank line.The blank line between the import statements is not necessary and can be removed for consistency.
- import cmath - + import cmath
7-7
: Prefer absolute imports over relative imports.Replace relative imports from parent modules with absolute imports for better readability and maintainability.
- from ..models.CoordsTranslate import CoordsTranslate + from graphviz2drawio.models.CoordsTranslate import CoordsTranslateTools
Ruff
7-7: Prefer absolute imports over relative imports from parent modules
Replace relative imports from parent modules with absolute imports
(TID252)
28-28
: Add trailing comma for consistency.Add a trailing comma after the last element in the list to maintain consistency.
- p.start, p.control1, p.control2, p.end + p.start, p.control1, p.control2, p.end,Tools
Ruff
28-28: Trailing comma missing
Add trailing comma
(COM812)
31-35
: Add trailing commas for consistency.Add trailing commas after the last element in the list to maintain consistency.
- approximate_cubic_bezier_as_quadratic(*cube)[1] + approximate_cubic_bezier_as_quadratic(*cube)[1],Tools
Ruff
31-35: Use a list comprehension to create a transformed list
(PERF401)
33-33: Trailing comma missing
Add trailing comma
(COM812)
34-34: Trailing comma missing
Add trailing comma
(COM812)
46-46
: Add trailing newline.Add a trailing newline at the end of the file for better readability and to follow best practices.
- return isinstance(p, CubicBezier) + return isinstance(p, CubicBezier) +Tools
Ruff
46-46: No newline at end of file
Add trailing newline
(W292)
README.md (1)
90-93
: Use asterisk for unordered list style.The unordered list style should be consistent. Replace the dash with an asterisk.
- - [ ] Ensure undirected graphs are not drawn with arrows - - [ ] Run ruff in CI - - [ ] Publish api docs to GH pages - - [ ] Restore codecov to test GHA + * [ ] Ensure undirected graphs are not drawn with arrows + * [ ] Run ruff in CI + * [ ] Publish api docs to GH pages + * [ ] Restore codecov to test GHATools
Markdownlint
90-90: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
91-91: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
92-92: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
93-93: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
test/test_graphs.py (1)
104-104
: Uncomment or add a TODO comment for the assertion.The commented-out assertion should either be uncommented or a TODO comment should be added to indicate the need for implementation.
- # assert False + # TODO: Implement assertion for test_polylines_curvedgraphviz2drawio/mx/MxGraph.py (3)
5-6
: Remove unnecessary blank line.The blank line between the import statements is not necessary and can be removed for consistency.
- from graphviz2drawio.mx.Edge import Edge - + from graphviz2drawio.mx.Edge import Edge
46-46
: Add a docstring for the method.The method lacks a docstring. Adding a docstring will improve readability and maintainability.
- def add_edge(self, edge: Edge) -> None: + def add_edge(self, edge: Edge) -> None: + """ + Add an edge to the graph. + """
117-117
: Add trailing comma for consistency.Add a trailing comma after the last element in the list to maintain consistency.
- element, MxConst.GEO, attrib={"as": "geometry", "relative": "1"} + element, MxConst.GEO, attrib={"as": "geometry", "relative": "1"},Tools
Ruff
117-117: Trailing comma missing
Add trailing comma
(COM812)
graphviz2drawio/mx/Curve.py (2)
17-17
: Add trailing comma.Add a trailing comma for consistency and to avoid syntax errors in future changes.
- self, start: complex, end: complex, is_bezier: bool, points: list[complex] + self, start: complex, end: complex, is_bezier: bool, points: list[complex],
128-128
: Add trailing comma.Add a trailing comma for consistency and to avoid syntax errors in future changes.
- def _lower_cubic_bezier_to_two_quadratics(P0: complex, P1: complex, P2: complex, P3: complex, t: float) -> tuple[list[complex], list[complex]]: + def _lower_cubic_bezier_to_two_quadratics(p0: complex, p1: complex, p2: complex, p3: complex, t: float,) -> tuple[list[complex], list[complex]]:Tools
Ruff
128-128: Argument name
P0
should be lowercase(N803)
128-128: Argument name
P1
should be lowercase(N803)
128-128: Argument name
P2
should be lowercase(N803)
128-128: Argument name
P3
should be lowercase(N803)
128-128: Trailing comma missing
Add trailing comma
(COM812)
graphviz2drawio/mx/bezier.py (3)
9-9
: Add trailing comma.Add a trailing comma for consistency and to avoid syntax errors in future changes.
- p1: complex, c1: complex, c2: complex, p2: complex, t: float + p1: complex, c1: complex, c2: complex, p2: complex, t: float,Tools
Ruff
9-9: Trailing comma missing
Add trailing comma
(COM812)
35-35
: Add trailing comma.Add a trailing comma for consistency and to avoid syntax errors in future changes.
- p1: complex, c1: complex, c2: complex, p2: complex, t: float + p1: complex, c1: complex, c2: complex, p2: complex, t: float,Tools
Ruff
35-35: Trailing comma missing
Add trailing comma
(COM812)
167-167
: Add trailing comma.Add a trailing comma for consistency and to avoid syntax errors in future changes.
- p0: complex, c1: complex, c2: complex, p2: complex + p0: complex, c1: complex, c2: complex, p2: complex,Tools
Ruff
167-167: Trailing comma missing
Add trailing comma
(COM812)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (15)
- .gitignore (1 hunks)
- README.md (1 hunks)
- graphviz2drawio/graphviz2drawio.py (1 hunks)
- graphviz2drawio/models/CoordsTranslate.py (1 hunks)
- graphviz2drawio/models/init.py (1 hunks)
- graphviz2drawio/mx/Curve.py (3 hunks)
- graphviz2drawio/mx/CurveFactory.py (1 hunks)
- graphviz2drawio/mx/Edge.py (2 hunks)
- graphviz2drawio/mx/MxConst.py (1 hunks)
- graphviz2drawio/mx/MxGraph.py (7 hunks)
- graphviz2drawio/mx/Styles.py (1 hunks)
- graphviz2drawio/mx/bezier.py (1 hunks)
- test/test_curve.py (1 hunks)
- test/test_graphs.py (1 hunks)
- test/undirected/polylines_curved.gv.txt (1 hunks)
Files skipped from review due to trivial changes (5)
- .gitignore
- graphviz2drawio/models/CoordsTranslate.py
- graphviz2drawio/mx/MxConst.py
- graphviz2drawio/mx/Styles.py
- test/undirected/polylines_curved.gv.txt
Additional context used
Ruff
graphviz2drawio/mx/CurveFactory.py
7-7: Prefer absolute imports over relative imports from parent modules
Replace relative imports from parent modules with absolute imports
(TID252)
28-28: Trailing comma missing
Add trailing comma
(COM812)
31-35: Use a list comprehension to create a transformed list
(PERF401)
33-33: Trailing comma missing
Add trailing comma
(COM812)
34-34: Trailing comma missing
Add trailing comma
(COM812)
46-46: No newline at end of file
Add trailing newline
(W292)
test/test_graphs.py
95-95: Assertion always fails, replace with
pytest.fail()
(PT015)
95-95: Do not
assert False
(python -O
removes these calls), raiseAssertionError()
Replace
assert False
(B011)
graphviz2drawio/mx/MxGraph.py
64-64: Unused static method argument:
source_node
(ARG004)
64-64: Unused static method argument:
target_node
(ARG004)
117-117: Trailing comma missing
Add trailing comma
(COM812)
graphviz2drawio/mx/Curve.py
2-2: Import from
collections.abc
instead:Callable
Import from
collections.abc
(UP035)
2-2:
typing.Any
imported but unusedRemove unused import:
typing.Any
(F401)
16-16: Boolean-typed positional argument in function definition
(FBT001)
16-16: Trailing comma missing
Add trailing comma
(COM812)
25-25: Found commented-out code
Remove commented-out code
(ERA001)
128-128: Argument name
P0
should be lowercase(N803)
128-128: Argument name
P1
should be lowercase(N803)
128-128: Argument name
P2
should be lowercase(N803)
128-128: Argument name
P3
should be lowercase(N803)
128-128: Trailing comma missing
Add trailing comma
(COM812)
130-131: 1 blank line required between summary line and description
(D205)
130-131: Multi-line docstring closing quotes should be on a separate line
Move closing quotes to new line
(D209)
130-131: First line of docstring should be in imperative mood: "Splits a cubic Bézier curve defined by control points P0-P3 at t,"
(D401)
132-132: Variable
Q0
in function should be lowercase(N806)
133-133: Variable
Q1
in function should be lowercase(N806)
134-134: Variable
Q2
in function should be lowercase(N806)
138-138: Variable
Q3
in function should be lowercase(N806)
151-164: Found useless expression. Either assign it to a variable or remove it.
(B018)
graphviz2drawio/mx/bezier.py
9-9: Trailing comma missing
Add trailing comma
(COM812)
15-15: Missing blank line after last section ("Returns")
Add blank line after "Returns"
(D413)
15-15: Missing dashed underline after section ("Returns")
Add dashed line under "Returns"
(D407)
15-15: Section name should end with a newline ("Returns")
Add newline after "Returns"
(D406)
35-35: Trailing comma missing
Add trailing comma
(COM812)
42-42: Missing blank line after last section ("Returns")
Add blank line after "Returns"
(D413)
42-42: Missing dashed underline after section ("Returns")
Add dashed line under "Returns"
(D407)
42-42: Section name should end with a newline ("Returns")
Add newline after "Returns"
(D406)
46-46: Exception must not use an f-string literal, assign to variable first
Assign to variable; remove f-string literal
(EM102)
56-56: Missing blank line after last section ("Returns")
Add blank line after "Returns"
(D413)
56-56: Missing dashed underline after section ("Returns")
Add dashed line under "Returns"
(D407)
56-56: Section name should end with a newline ("Returns")
Add newline after "Returns"
(D406)
100-100: Missing blank line after last section ("Returns")
Add blank line after "Returns"
(D413)
100-100: Missing dashed underline after section ("Returns")
Add dashed line under "Returns"
(D407)
100-100: Section name should end with a newline ("Returns")
Add newline after "Returns"
(D406)
134-134: Missing issue link on the line following this TODO
(TD003)
134-134: Line contains TODO, consider resolving the issue
(FIX002)
150-150: Missing issue link on the line following this TODO
(TD003)
150-150: Line contains TODO, consider resolving the issue
(FIX002)
167-167: Trailing comma missing
Add trailing comma
(COM812)
169-170: No blank lines allowed after function docstring (found 1)
Remove blank line(s) after function docstring
(D202)
169-170: 1 blank line required between summary line and description
(D205)
169-170: Multi-line docstring closing quotes should be on a separate line
Move closing quotes to new line
(D209)
Markdownlint
README.md
87-87: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
88-88: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
89-89: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
90-90: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
91-91: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
92-92: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
93-93: Expected: asterisk; Actual: dash
Unordered list style(MD004, ul-style)
Additional comments not posted (9)
graphviz2drawio/models/__init__.py (1)
Line range hint
4-4
: Changes approved.The removal of the import statement for
SvgParser
is appropriate and aligns with the updated import ingraphviz2drawio.py
.test/test_curve.py (3)
1-1
: Import statement looks good.The import statement for
_line
fromgraphviz2drawio.mx.Curve
is correct.
4-9
: Test for_line
function is well-implemented.The test covers the horizontal line case and verifies the function's output at different points.
11-13
: Test for vertical line case is appropriate.The test correctly handles the case where the line is vertical, ensuring the function returns
None
.graphviz2drawio/graphviz2drawio.py (2)
5-5
: Import statement updated correctly.The import statement has been updated to import
parse_nodes_edges_clusters
frommodels.SvgParser
, which is appropriate given the removal from__init__.py
.
Line range hint
8-29
: Changes inconvert
function look good.The function correctly uses the updated import and processes the graph as expected.
graphviz2drawio/mx/Edge.py (2)
20-20
: Attribute renaming is appropriate.The
style
attribute has been renamed toline_style
, which improves clarity.
37-37
: Reference update in__repr__
method is correct.The
__repr__
method correctly references the renamedline_style
attribute.graphviz2drawio/mx/bezier.py (1)
169-170
: Remove blank line after docstring.Remove the blank line after the function docstring to adhere to PEP 257.
- """Approximates a cubic Bézier curve (p0-p2) with a quadratic Bézier curve (Q0-Q2) - + """ + Approximates a cubic Bézier curve (p0-p2) with a quadratic Bézier curve (Q0-Q2)Likely invalid or redundant comment.
Tools
Ruff
169-170: No blank lines allowed after function docstring (found 1)
Remove blank line(s) after function docstring
(D202)
169-170: 1 blank line required between summary line and description
(D205)
169-170: Multi-line docstring closing quotes should be on a separate line
Move closing quotes to new line
(D209)
graphviz2drawio/mx/bezier.py
Outdated
"""Approximates a cubic Bézier curve (p0-p2) with a quadratic Bézier curve (Q0-Q2) | ||
using tangent intersection.""" |
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.
Fix docstring formatting.
Ensure proper formatting of docstrings for better readability and adherence to PEP 257.
- """Approximates a cubic Bézier curve (p0-p2) with a quadratic Bézier curve (Q0-Q2)
- using tangent intersection.
- """
+ """
+ Approximates a cubic Bézier curve (p0-p2) with a quadratic Bézier curve (Q0-Q2) using tangent intersection.
+ """
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"""Approximates a cubic Bézier curve (p0-p2) with a quadratic Bézier curve (Q0-Q2) | |
using tangent intersection.""" | |
""" | |
Approximates a cubic Bézier curve (p0-p2) with a quadratic Bézier curve (Q0-Q2) using tangent intersection. | |
""" |
Tools
Ruff
169-170: No blank lines allowed after function docstring (found 1)
Remove blank line(s) after function docstring
(D202)
169-170: 1 blank line required between summary line and description
(D205)
169-170: Multi-line docstring closing quotes should be on a separate line
Move closing quotes to new line
(D209)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- graphviz2drawio/mx/Curve.py (3 hunks)
Additional context used
Ruff
graphviz2drawio/mx/Curve.py
2-2: Import from
collections.abc
instead:Callable
Import from
collections.abc
(UP035)
2-2:
typing.Any
imported but unusedRemove unused import:
typing.Any
(F401)
16-16: Trailing comma missing
Add trailing comma
(COM812)
25-25: Found commented-out code
Remove commented-out code
(ERA001)
128-128: Argument name
P0
should be lowercase(N803)
128-128: Argument name
P1
should be lowercase(N803)
128-128: Argument name
P2
should be lowercase(N803)
128-128: Argument name
P3
should be lowercase(N803)
128-128: Trailing comma missing
Add trailing comma
(COM812)
130-131: 1 blank line required between summary line and description
(D205)
130-131: Multi-line docstring closing quotes should be on a separate line
Move closing quotes to new line
(D209)
130-131: First line of docstring should be in imperative mood: "Splits a cubic Bézier curve defined by control points P0-P3 at t,"
(D401)
132-132: Variable
Q0
in function should be lowercase(N806)
133-133: Variable
Q1
in function should be lowercase(N806)
134-134: Variable
Q2
in function should be lowercase(N806)
138-138: Variable
Q3
in function should be lowercase(N806)
151-164: Found useless expression. Either assign it to a variable or remove it.
(B018)
Additional comments not posted (11)
graphviz2drawio/mx/Curve.py (11)
8-13
: LGTM!The class docstring is clear and informative.
29-46
: Potential issue with_line
functionThe
_line
function might returnNone
if the start and end points have the same real part. Ensure this case is handled correctly.
39-41
: Consider makingrel_tol
a parameterThe relative tolerance value
rel_tol
is hardcoded. Consider making it a parameter to allow for more flexibility.
57-64
: LGTM!The
cubic_bezier_derivative
method calculates the derivative correctly.
80-81
: Incorrect use ofp.real
andp.imag
The
_cubic_bezier
function should use the list indices for control points instead ofp.real
andp.imag
.
87-100
: LGTM!The
_derivative_of_cubic_bezier
method calculates the derivative correctly.
33-35
: Potential issue with_line
functionThe
_line
function might returnNone
if the start and end points have the same real part. Ensure this case is handled correctly.
128-128
: Use lowercase argument names.Argument names should be lowercase to follow PEP 8 naming conventions.
- def _lower_cubic_bezier_to_two_quadratics(P0: complex, P1: complex, P2: complex, P3: complex, t: float) -> tuple[list[complex], list[complex]]: + def _lower_cubic_bezier_to_two_quadratics(p0: complex, p1: complex, p2: complex, p3: complex, t: float) -> tuple[list[complex], list[complex]]:Tools
Ruff
128-128: Argument name
P0
should be lowercase(N803)
128-128: Argument name
P1
should be lowercase(N803)
128-128: Argument name
P2
should be lowercase(N803)
128-128: Argument name
P3
should be lowercase(N803)
128-128: Trailing comma missing
Add trailing comma
(COM812)
130-131
: Fix docstring formatting.Ensure proper formatting of docstrings for better readability and adherence to PEP 257.
- """Splits a cubic Bézier curve defined by control points P0-P3 at t, - returning two new cubic Bézier curve segments.""" + """ + Split a cubic Bézier curve defined by control points p0-p3 at t, returning two new cubic Bézier curve segments. + + """Tools
Ruff
130-131: 1 blank line required between summary line and description
(D205)
130-131: Multi-line docstring closing quotes should be on a separate line
Move closing quotes to new line
(D209)
130-131: First line of docstring should be in imperative mood: "Splits a cubic Bézier curve defined by control points P0-P3 at t,"
(D401)
132-147
: Use lowercase variable names.Variable names should be lowercase to follow PEP 8 naming conventions.
- Q0 = P0 - Q1 = complex((1 - t) * P0.real + t * P1.real, (1 - t) * P0.imag + t * P1.imag) - Q2 = complex((1 - t) ** 2 * P0.real + 2 * (1 - t) * t * P1.real + t**2 * P2.real, (1 - t) ** 2 * P0.imag + 2 * (1 - t) * t * P1.imag + t**2 * P2.imag,) - Q3 = complex((1 - t) ** 3 * P0.real + 3 * (1 - t) ** 2 * t * P1.real + 3 * (1 - t) * t**2 * P2.real + t**3 * P3.real, (1 - t) ** 3 * P0.imag + 3 * (1 - t) ** 2 * t * P1.imag + 3 * (1 - t) * t**2 * P2.imag + t**3 * P3.imag,) - return [Q0, Q1, Q2], [Q2, Q3, P3] + q0 = p0 + q1 = complex((1 - t) * p0.real + t * p1.real, (1 - t) * p0.imag + t * p1.imag) + q2 = complex((1 - t) ** 2 * p0.real + 2 * (1 - t) * t * p1.real + t**2 * p2.real, (1 - t) ** 2 * p0.imag + 2 * (1 - t) * t * p1.imag + t**2 * p2.imag,) + q3 = complex((1 - t) ** 3 * p0.real + 3 * (1 - t) ** 2 * t * p1.real + 3 * (1 - t) * t**2 * p2.real + t**3 * p3.real, (1 - t) ** 3 * p0.imag + 3 * (1 - t) ** 2 * t * p1.imag + 3 * (1 - t) * t**2 * p2.imag + t**3 * p3.imag,) + return [q0, q1, q2], [q2, q3, p3]Tools
Ruff
132-132: Variable
Q0
in function should be lowercase(N806)
133-133: Variable
Q1
in function should be lowercase(N806)
134-134: Variable
Q2
in function should be lowercase(N806)
138-138: Variable
Q3
in function should be lowercase(N806)
151-164
: Remove useless expression.The expression at the end of the file is not assigned to any variable or used in any way.
- ( - ( - (2 + 2j), - (1.0956739766575936 + 3.808652046684813j), - (3.053667401045204 + 3.5727902021338993j), - (5.100619597768561 + 3.326212294969724j), - ), - ( - (5.100619597768561 + 3.326212294969724j), - (7.580690054131715 + 3.027460529428433j), - (10.191347953315187 + 2.7129780700272192j), - (8 + 6j), - ), - )Tools
Ruff
151-164: Found useless expression. Either assign it to a variable or remove it.
(B018)
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.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- graphviz2drawio/mx/Curve.py (1 hunks)
- graphviz2drawio/mx/CurveFactory.py (1 hunks)
- graphviz2drawio/mx/MxGraph.py (6 hunks)
- graphviz2drawio/mx/init.py (1 hunks)
- graphviz2drawio/mx/bezier.py (1 hunks)
- test/test_curve.py (1 hunks)
- test/test_graphs.py (1 hunks)
Files skipped from review due to trivial changes (1)
- graphviz2drawio/mx/init.py
Files skipped from review as they are similar to previous changes (4)
- graphviz2drawio/mx/MxGraph.py
- graphviz2drawio/mx/bezier.py
- test/test_curve.py
- test/test_graphs.py
Additional context used
Ruff
graphviz2drawio/mx/CurveFactory.py
5-5: Prefer absolute imports over relative imports from parent modules
Replace relative imports from parent modules with absolute imports
(TID252)
Additional comments not posted (8)
graphviz2drawio/mx/CurveFactory.py (3)
11-13
: LGTM! Initialization is correct.The
__init__
method correctly initializes thecoords
attribute.
16-48
: LGTM! The method correctly processes SVG paths.The
from_svg
method correctly handles SVG path parsing, coordinate translation, and cubic Bézier curve processing.
51-52
: LGTM! The function correctly identifies cubic Bézier segments.The
_is_cubic
function is straightforward and correctly identifies cubic Bézier segments.graphviz2drawio/mx/Curve.py (5)
17-29
: LGTM! Initialization is correct.The
__init__
method correctly initializes the curve's attributes.
31-33
: LGTM! The method correctly returns a string representation.The
__str__
method correctly returns a string representation of the curve.
35-52
: LGTM! The method correctly checks for linearity.The
is_linear
method correctly checks if a cubic Bézier curve is linear.
55-66
: LGTM! The function correctly calculates the slope and y-intercept.The
_line
function correctly calculates the slope and y-intercept of a line.
69-76
: LGTM! The function correctly reverses the imaginary and real parts.The
_rotate_bezier
function correctly reverses the imaginary and real parts for all components of a cubic Bézier curve.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary by Sourcery
This pull request introduces significant improvements to curve handling in the graphviz2drawio project. It adds support for straight line and cubic Bézier curve conversions, enhances the Curve and MxGraph classes for better flexibility and robustness, and includes new utility functions for cubic Bézier curve operations. Additionally, new tests have been added to ensure the correctness of these features, and unused code has been cleaned up.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
Refactor
Chores
.vscode
to.gitignore
to avoid unintentional commits of IDE-specific files.