-
Notifications
You must be signed in to change notification settings - Fork 8
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 geometric helper functions #81
Conversation
Hi @cgohlke, I had the time to review the changes you implemented, which improve many areas that will benefit from the consistency and execution times of the optimizations you proposed. The ufuncs are an excelent incorporation to the tools available for developing other functions. I tested some of them, mainly for the cursors module in #48 and most of them can replace some of the functions, but I will raise the topic in the dedicated PR for the module. The modifications to the Regarding the topics you raised for discussion:
This can be a good idea, since it can be also useful for future collaborators to have a better understanding of this functions that can be of use for future implementations of higher level functions.
I think it would be good if it returned the artist so we don't need to use
Also this might be a good idea. I think we need to discuss the whole module, regarding the planned implementations an how to divide the functionalities in functions. Also the naming of the functions of the module is something we should discuss to add cohesion.
There is a paper vaguely describing the procedure, but I think it should be mentioned. Where should I add the reference to the paper? As a Note in the docstring of the function? I am not aware of the optimization of the number of steps and radius. We don't really know what parameters SimFCS use but Leonel thinks than it uses 100 steps, But is something we can discuss next meeting with Leonel, maybe we can find an optimal number of steps based on the radius. |
The numpy docstring standard has a section for references: https://numpydoc.readthedocs.io/en/latest/format.html#references. Let me know the reference and I can add it to this PR, or you can add it later.
OK, I'll look into it. I remember there were reasons for not returning artists regarding typing, documentation, and noise in interactive use. |
Excelent! This is the doi of the paper: |
I added the reference for the graphical method and changed some PhasorPlot methods to return line artists. |
@cgohlke I think it would be good to have these functionalities in the main to implement them in the masks functions. I think this is ready to be merged if you also think so. |
Yes, I'll add that to this PR. |
Hi @bruno-pannunzio : the changes to the cursors module turned out to be extensive. I decided to propose them in a different PR. Can you review this PR and approve it if it looks OK? |
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.
Sure @cgohlke, I think this is ready for merge, and if the changes to be implemented are extensive it's a good idea to make them in another PR, also so we can review them more easily.
Description
This PR adds geometric helper functions and addresses some issues and ideas raised during the discussion of #79, specifically #79 (comment):
Implement useful geometry functions as private ufuncs in the Cython module:
_distance_from_line
_distance_from_point
_distance_from_segment
_fraction_on_line
_fraction_on_segment
_intersection_circle_circle
_intersection_circle_line
_is_inside_circle
_is_inside_ellipse
and_is_inside_ellipse_
_is_inside_polar_rectangle
_is_inside_range
_is_inside_rectangle
_is_inside_stadium
, same as_is_near_segment
_is_near_line
_point_on_line
_point_on_segment
_segment_direction_and_length
Above ufuncs replace several helper functions from the
_utils
module (the tests were migrated):project_phasor_to_line
->_point_on_segment and _point_on_line
line_from_components
->_segment_direction_and_length
mask_cursor
->_is_inside_circle
mask_segment
->_is_inside_stadium
circle_circle_intersection
->_intersection_circle_circle
circle_line_intersection
->_intersection_circle_line
Remove second component output array from
two_fractions_from_phasor
since it can easily be calculated from the first component.Reimplement
two_fractions_from_phasor
as a thin wrapper of_fraction_on_segment
.Remove
fractions
output fromgraphical_component_analysis
and replace thesteps
parameter withfractions
, which can be the number of equidistant fractions or an array of fraction values.Use
_is_inside_circle
and_is_inside_stadium
ufuncs ingraphical_component_analysis
.Improve the components tutorial:
PhasorPlot
methods over matplotlib.Make the
PhasorPlot.plot
fmt
parameter position only in accordance with matplotlib.Add
PhasorPlot.dataunit_to_point
property to convert from data to point units.Add option to plot labels in
PhasorPlot.components
.There are still many areas for improvement, which could be discussed and/or addressed in this or future PRs:
_is_*
functions currently returnint16
values instead ofbool
because of issues in Cython._is_*
functions take amask
parameter, which is currently unused. It might or might not be useful in the future when combining masks.PhasorPlot._lines
property. Instead, thePhasorPlot
methods could return artists if possible, just like matplotlib functions.PhasorPlot.components
andPhasorPlot.cursors
. Those methods frequently requires changing the parameter defaults.graphical_component_analysis
could be split into two functions, for two and three components. That could simplify the API and documentation for two components.Release note
Summarize the changes in the code block below to be included in the
release notes:
Checklist