-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: support metric custom column ordering and sub-setting #178
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #178 +/- ##
==========================================
- Coverage 89.21% 89.20% -0.02%
==========================================
Files 18 18
Lines 2068 2084 +16
Branches 457 464 +7
==========================================
+ Hits 1845 1859 +14
- Misses 146 147 +1
- Partials 77 78 +1 ☔ View full report in Codecov by Sentry. |
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.
Additional test requested
fgpyo/util/metric.py
Outdated
return header | ||
|
||
@classmethod | ||
def _header(cls, field_types: Optional[List[FieldType]] = None) -> List[str]: |
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.
Could I suggest calling this something else - e.g. _fields_to_write()
? My reasoning:
- It's a little confusing to have
header()
and_header()
- More importantly, I might think this would allow me to provide a custom header that doesn't match field names (e.g.
[f.replace("_", " ") for f in in self.header()]
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.
Why is field_types
optional? Given this is a function called by the Metric
class itself, it feels like it should either always be provided, or be removed. How does the user who overrides this know whether or not they'll get a value?
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've changed
_header
to_fields_to_write
- This PR does not allow a customer header that doesn't match the field names, as we use the names returned from the
header()
method to look up attributes on the class (see theyield getattr(self, name)
in thevalues()
method) - I've made
field_types
not optional. Good catch, as this was a left-over from a previous attempt.
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.
Looks good!
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.
tick!
Fixes #177