tpaviot / pythonocc-core

Python package for 3D geometry CAD/BIM/CAM
GNU Lesser General Public License v3.0
1.39k stars 380 forks source link

Add hash/eq/neq for Standard_Transient and its derivatives #1382

Closed tpaviot closed 3 weeks ago

tpaviot commented 3 weeks ago

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:

sourcery-ai[bot] commented 3 weeks ago

Reviewer's Guide by Sourcery

This 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 derivatives

classDiagram
    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

Change Details Files
Added hash, equality, and inequality operators for Standard_Transient
  • Implemented eq method with type checking
  • Implemented ne method with type checking
  • Added hash method using opencascade::hash
  • Added new tests for TShape hash, equality, and inequality operators
src/SWIG_files/wrapper/Standard.i
test/test_core_wrapper_features.py
Improved code formatting and indentation across multiple wrapper files
  • Fixed indentation in equality and inequality operator implementations
  • Standardized spacing around operators
  • Cleaned up friend declarations
src/SWIG_files/wrapper/Graphic3d.i
src/SWIG_files/wrapper/TCollection.i
src/SWIG_files/wrapper/Quantity.i
src/SWIG_files/wrapper/BRepMesh.i
src/SWIG_files/wrapper/TopoDS.i
src/SWIG_files/wrapper/TDF.i
src/SWIG_files/wrapper/XCAFPrs.i
src/SWIG_files/wrapper/TopLoc.i
Removed Open method from RWPly_PlyWriterContext
  • Removed Open method implementation
  • Added methodnotwrapped decorator for Open method
src/SWIG_files/wrapper/RWPly.i

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
tpaviot commented 3 weeks ago

see the related commit at pythonocc-generator https://github.com/tpaviot/pythonocc-generator/commit/e8e3cbf048917f6bd55f69170519d8c5fa2de8ad