-
Notifications
You must be signed in to change notification settings - Fork 11
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
Refactor utility functions #55
Conversation
cc @michaelbornholdt - I just gave you triage access to the repo, so that you are able to more effectively review this PR. Once you accept the invite, I will add you as a reviewer. Thanks! :) |
Codecov Report
@@ Coverage Diff @@
## master #55 +/- ##
==========================================
+ Coverage 98.38% 98.45% +0.06%
==========================================
Files 24 30 +6
Lines 867 905 +38
==========================================
+ Hits 853 891 +38
Misses 14 14
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
alright @michaelbornholdt - this is ready for your eyes. This blog post might be helpful to determine how to review. Personally, I find reviewing other PRs to be helpful for the times when it's me actually proposing the changes. For this reason (and for an independent reason: I think more eyes on code the better) I am requesting your review. Do you think you'll be able to do this in a timely fashion? Hopefully by tomorrow? FWIW, I think this PR is an easy one to start with. I'm not changing any functionality, just structure. |
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.
Overall very clear PR @gwaygenomics . I only have mini suggestions and questions.
I will run Black over all the code because I remember it having some issues and we can use this refactoring to solve those.
@@ -8,7 +8,7 @@ | |||
from typing import List, Union | |||
|
|||
from cytominer_eval.transform import metric_melt | |||
from cytominer_eval.transform.util import check_replicate_groups | |||
from cytominer_eval.utils.transform_utils import check_replicate_groups |
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.
For me, this line gives an error because utils are not imported here or in the init.py file. But I am unsure why the tests don't give that error?
This applies to all imports of util below
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.
oh interesting, what is the error?
Is it possible that your testing environment is out-of-date?
I also added a __init__.py
file inside cytominer_eval/utils
- so this might help. It should have been there in the first place, so thanks for making this note.
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.
Yea I know it works, for some reason pycharm is complaining about it. I think it's because if you run that file on its own, it won't find the util.
but all good
@@ -202,7 +208,9 @@ def test_evaluate_grit(): | |||
top_result = ( | |||
grit_results_df.sort_values(by="grit", ascending=False) | |||
.reset_index(drop=True) | |||
.iloc[0,] |
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.
Is this black?
it doesn't seem like a helpful change in code to me. Same goes for the lines below.
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.
Yep, it is, just checked it. I do not know why black is only modifying this now...
It is definitely a non-functional change, but it's also harmless. I think we can ignore it
get_grit_entry, | ||
calculate_grit, | ||
) | ||
|
||
|
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.
This is something we need to change for some other files, I will point out below where we are getting the two spacing incorrect. This line is correct, but other files are not
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.
nice! Weird that black didn't catch the other one. I wonder if it's a version thing.
These version differences could get annoying... I wondered if there is a way to automate black
, and it looks like there is via github actions! https://github.com/psf/black/actions/runs/17913292/workflow
I added #57 for us to track it there.
Thanks for adding the extra changes
|
||
from cytominer_eval.utils.availability_utils import get_available_grit_summary_methods | ||
|
||
random.seed(123) |
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.
To be really honest Greg, I think you should definitely change this to be seed(42) for everything 🤷 :)
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.
hahaha, yes, it is the answer to the universe after all. Feel free to fix in your next PR :)
And Black checks out with no errors! NICE |
Co-authored-by: Michael Bornholdt <[email protected]>
Co-authored-by: Michael Bornholdt <[email protected]>
Co-authored-by: Michael Bornholdt <[email protected]>
Fixing spaces after function import, docstring consistency, and a missing numpy builtin update Co-authored-by: Michael Bornholdt <[email protected]>
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 these comments. I've either made replies that require your followup or resolved the issue. I'll re-request your review.
The most important comment is for you to confirm that these updates work on your end. Although that is less important since they do seem to pass tests. Weird!
@@ -202,7 +208,9 @@ def test_evaluate_grit(): | |||
top_result = ( | |||
grit_results_df.sort_values(by="grit", ascending=False) | |||
.reset_index(drop=True) | |||
.iloc[0,] |
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.
Yep, it is, just checked it. I do not know why black is only modifying this now...
It is definitely a non-functional change, but it's also harmless. I think we can ignore it
get_grit_entry, | ||
calculate_grit, | ||
) | ||
|
||
|
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.
nice! Weird that black didn't catch the other one. I wonder if it's a version thing.
These version differences could get annoying... I wondered if there is a way to automate black
, and it looks like there is via github actions! https://github.com/psf/black/actions/runs/17913292/workflow
I added #57 for us to track it there.
Thanks for adding the extra changes
|
||
from cytominer_eval.utils.availability_utils import get_available_grit_summary_methods | ||
|
||
random.seed(123) |
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.
hahaha, yes, it is the answer to the universe after all. Feel free to fix in your next PR :)
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.
I'm fine with all of this.
Yes, should definitely set the exact config and version for black.
Ideally, you would also want to use pipenv instead of requirements.txt
You can merge yourself :)
@gwaygenomics |
Awesome, I will merge now. Thanks!
I am interested. Can you elaborate? Perhaps you can elaborate in a new github issue so we can possibly implement this enhancement in the future? |
The utility functions were getting clunky. I went to add new functionality to grit, but I struggled to figure out exactly where I should be adding it. This led me to this refactoring exercise.
No functionality was changed in this pull request. Only names and locations of python utility functions and tests. I also needed to modify several additional functions to fix import statements.
I also made super minor changes to formatting and
fixed a deprecated testing warning(reverted back, see #56 ).Note, I did fix a separate deprecation warning for numpy built-in types (see https://numpy.org/doc/stable/release/1.20.0-notes.html#deprecations)