-
Notifications
You must be signed in to change notification settings - Fork 114
Extract nested class from plate vertical graph #50
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
Extract nested class from plate vertical graph #50
Conversation
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.
Thanks for the PR :) I'll merge as soon as you fix the comments I left.
public class PeakComparator implements Comparator<Peak> { | ||
private PlateVerticalGraph graphHandle = null; | ||
|
||
public PeakComparator(PlateVerticalGraph graph) { |
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.
Let's only pass yValues into this comparator. It will be easier to test and more encapsulated.
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.
Okay, will change it!
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.
Done :)
|
||
@Before | ||
public void setup() { | ||
PlateVerticalGraph plateVerticalGraph = mock(PlateVerticalGraph.class); |
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.
You don't need this mock after you change the parameters in the comparator.
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.
Okay, will change it!
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.
Done :)
|
||
@Override | ||
public int compare(Peak peak1, Peak peak2) { | ||
return Double.compare(getPeakValue(peak1), getPeakValue(peak2)); |
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.
There's a bug on this line - you reversed the order of peak1
and peak2
in the comparison. That's why the tests are failing. Also, fix your added test after you switch these.
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.
Sorry, will change it!
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.
Done :)
…it to PeakComparator and simplified compare method. Extracting PeakComparer also required extracting Peak from Graph. Changed Plate, CatSnapShot, Band and BandGraph to reflect this. Removed unused field handle from PlateVerticalGraph.
…t that). Made PeakComparator take a vector of floats instead of a PlateVerticalGraph in its constructor.
82b491d
to
8738dcd
Compare
Thanks for all the PRs @FridaTveit :) Merry Christmas 🎄 |
Merry Christmas! :) 🎄 |
Extracted Peak from Graph and extracted PeakComparer from PlateVerticalGraph. Added unit tests for PeakComparer (renamed to PeakComparator).