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

Close #511, replaced convert_to_boxes with geometry_type #514

Merged
merged 4 commits into from
Oct 16, 2023

Conversation

JSpencerPittman
Copy link
Contributor

This is just a simple swap with convert_to_boxes to with geometry_type to allow polygons to be used in the shape file further down the road. I also added some documentation regarding the handling of different geometries within the shape-file in the doc-strings body.

Copy link
Member

@ethanwhite ethanwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good @JSpencerPittman! Thanks for the contribution!

Other than a wording suggestion (included in-line) I have two suggestions:

  1. Let's add some argument checking code since geometry_type is now a string instead of a boolean. Given the structure of the code the easiest thing is probably an assert statement at the beginning on the function that checks that geometry_type is either boundingbox or point and throws an error informing that user that it needs to be one of those two if something else is passed.
  2. My one other thought (and I realize I'm suggesting we consider a change to my own wording from convert_to_boxes arg name in shapefile_to_annotations is poorly named #511), is to mirror pytorch's typical naming for "bounding boxes". A quick search suggest that "box"/"boxes" and "bbox" are both commonly used, so let's pick one of those for better consistency.

deepforest/utilities.py Outdated Show resolved Hide resolved
@JSpencerPittman
Copy link
Contributor Author

Just finished pushing the changes. The geometry_type should be more secure and understandable now.

Copy link
Member

@ethanwhite ethanwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fantastic @JSpencerPittman! We've got a style test failing. You can fix it by running:

yapf -i --recursive deepforest/ --style=.style.yapf

or manually making the change indicted in the tests:

-        raise ValueError(f"Invalid argument for 'geometry_type'. Expected 'point' or 'bbox'.")
+        raise ValueError(
+            f"Invalid argument for 'geometry_type'. Expected 'point' or 'bbox'.")

Since we need one more change anyway I've also noted one last docstring style change and then we can get this in.

Thanks for your work on this!

Args:
shapefile: Path to a shapefile on disk. If a label column is present, it will be used, else all labels are assumed to be "Tree"
rgb: Path to the RGB image on disk
savedir: Directory to save csv files
buffer_size: size of point to box expansion in map units of the target object, meters for projected data, pixels for unprojected data. The buffer_size is added to each side of the x,y point to create the box.
convert_to_boxes (False): If True, convert the point objects in the shapefile into bounding boxes with size 'buffer_size'.
geometry_type (bbox): Specifies the spatial representation used in the shapefile; can be "bbox" or "point"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop the (bbox) here for consistency. We should probably do a general docstring consistency cleanup here, but the old (False) isn't consistent with any of the major styles so let's just drop it here since we're changing it.

@JSpencerPittman
Copy link
Contributor Author

Alright, it should pass the style test now. I'm very new to Open Source Contributing. So, thank you for the help.

@ethanwhite
Copy link
Member

Thanks @JSpencerPittman! We're always happy to help out new contributors.

@ethanwhite ethanwhite merged commit ca81f64 into weecology:main Oct 16, 2023
3 checks passed
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.

2 participants