-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
Add hash/eq/neq for Standard_Transient and its derivatives #1382
Conversation
Reviewer's Guide by SourceryThis PR implements hash, equality, and inequality operators for Standard_Transient and its derivatives, along with code formatting improvements. The changes primarily focus on adding Python special methods (eq, ne, hash) to enable proper comparison and hashing of objects, while also cleaning up code indentation across multiple files. Class diagram for Standard_Transient and its derivativesclassDiagram
class Standard_Transient {
+__eq__(right)
+__ne__(right)
+__hash__()
+__eq_wrapper__(other)
+__ne_wrapper__(other)
}
class Standard_GUID {
+friend struct std::hash
}
class TDF_Label {
+friend struct std::hash
}
class XCAFPrs_Style {
+friend struct std::hash
}
note for Standard_Transient "Added Python special methods for comparison and hashing"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 @tpaviot - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
# Create a shape that differs from shape_2, but has the same TShape | ||
shape_3 = shape_2.Reversed() | ||
assert hash(shape_1.TShape()) == hash(shape_1.TShape()) | ||
assert not hash(shape_1.TShape()) == hash(shape_2.TShape()) |
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.
suggestion (code-quality): Simplify logical expression using De Morgan identities (de-morgan
)
assert not hash(shape_1.TShape()) == hash(shape_2.TShape()) | |
assert hash(shape_1.TShape()) != hash(shape_2.TShape()) |
assert not shape_1.TShape() == shape_2.TShape() | ||
assert shape_2.TShape() == shape_3.TShape() | ||
assert not shape_1.TShape() == "some_string" |
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.
issue (code-quality): Simplify logical expression using De Morgan identities [×2] (de-morgan
)
assert not shape_1.TShape() != shape_1.TShape() | ||
assert shape_1.TShape() != shape_2.TShape() | ||
assert not shape_2.TShape() != shape_3.TShape() |
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.
issue (code-quality): Simplify logical expression using De Morgan identities [×2] (de-morgan
)
see the related commit at pythonocc-generator tpaviot/pythonocc-generator@e8e3cbf |
and a couple other minor fixes
based on #1375
Summary by Sourcery
Add hash, equality, and inequality operators for Standard_Transient and its derivatives, enhancing object comparison capabilities. Refactor existing operator implementations for improved readability. Include new tests to verify the functionality of these operators.
New Features:
Enhancements:
Tests: