Skip to content
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

Geometries should be immutable and hashable #128 #177

Merged
merged 4 commits into from
Oct 28, 2023

Conversation

cleder
Copy link
Owner

@cleder cleder commented Oct 28, 2023

workerB

@cleder cleder linked an issue Oct 28, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Oct 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (727bdff) 100.00% compared to head (e5e9e04) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop      #177   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         2244      2314   +70     
=========================================
+ Hits          2244      2314   +70     
Files Coverage Δ
pygeoif/geometry.py 100.00% <100.00%> (ø)
tests/test_base.py 100.00% <100.00%> (ø)
tests/test_geometrycollection.py 100.00% <100.00%> (ø)
tests/test_line.py 100.00% <100.00%> (ø)
tests/test_linear_ring.py 100.00% <100.00%> (ø)
tests/test_multiline.py 100.00% <100.00%> (ø)
tests/test_multipoint.py 100.00% <100.00%> (ø)
tests/test_multipolygon.py 100.00% <100.00%> (ø)
tests/test_point.py 100.00% <100.00%> (ø)
tests/test_polygon.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@what-the-diff
Copy link

what-the-diff bot commented Oct 28, 2023

PR Summary

  • Modification of Import Statement and Attribute Introduction in _Geometry Class
    An import instruction for the module typing has been added, providing predefined types aiding further development. An attribute named __slots__ was also introduced to reduce memory requirement.

  • Addition of Type Hints in _Geometry Class
    Type hints were attached to certain attributes and methods. By doing so, developers get clearer insights about the type of variables they are working with, preventing potential bugs due to mismatching data types.

  • Significant Refactoring in Point Property Methods
    The way Point class functions operate was fundamentally altered. Instead of using the older _coordinates attribute, they now utilize the _geoms attribute delivering the same functionality in a more efficient manner.

  • Changes to Several __init__ Methods in Multiple Classes
    In classes such as LineString, Polygon, MultiPolygon, GeometryCollection, MultiLineString, and MultiPoint, the method of setting the _geoms attribute now implements object.__setattr__, increasing code security and stability.

  • Update in Property Methods of Polygon and MultiPolygon Classes
    Methods like exterior, interiors, is_empty, and has_z in both Polygon and MultiPolygon classes now utilize _geoms attribute, aligning them with the previously mentioned refactoring.

  • Removal of test_centroid_invalid Function
    The test_centroid_invalid function in test_linear_ring.py file was removed, increasing the test suite's relevance.

  • Modifications in LinearRing Class
    Just like Point, LinearRing class underwent a similar change where the _geoms attribute replaced _coordinates in its properties and representational methods, making it more consistent with other classes.

@ghost
Copy link

ghost commented Oct 28, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@watermelon-copilot-for-code-review

WatermelonAI Summary

The 3 commits in this Pull Request focus on making geometries immutable and hashable. By making geometries immutable, it ensures that their state cannot be changed after creation. Making them hashable allows them to be used as keys in data structures like dictionaries. Additionally, tests have been added to verify the functionality of hash, get, and set attribute operations. This PR aims to improve the robustness and reliability of geometries within the business logic.

GitHub PRs

Click here to login to Jira
Click here to login to Confluence
Click here to login to Slack
Click here to login to Notion
Click here to login to Linear
Click here to login to Asana
pygeoif is an open repo and Watermelon will serve it for free.
🍉🫶

@cleder cleder merged commit 3561994 into develop Oct 28, 2023
31 of 32 checks passed
@cleder cleder deleted the 128-geometries-should-be-immutable-and-hashable branch October 28, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Geometries should be immutable and hashable
1 participant