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

feat: support metric custom column ordering and sub-setting #178

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nh13
Copy link
Member

@nh13 nh13 commented Aug 14, 2024

Fixes #177

@nh13 nh13 requested a review from ameynert August 14, 2024 18:47
@nh13 nh13 requested a review from tfenne as a code owner August 14, 2024 18:47
@nh13 nh13 temporarily deployed to github-actions-ci August 14, 2024 19:14 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci August 14, 2024 19:14 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci August 14, 2024 19:14 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci August 14, 2024 19:14 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci August 14, 2024 19:14 — with GitHub Actions Inactive
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.20%. Comparing base (d574e5a) to head (b06b986).
Report is 2 commits behind head on main.

Files Patch % Lines
fgpyo/util/metric.py 91.30% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link

@ameynert ameynert left a comment

Choose a reason for hiding this comment

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

Additional test requested

tests/fgpyo/util/test_metric.py Show resolved Hide resolved
return header

@classmethod
def _header(cls, field_types: Optional[List[FieldType]] = None) -> List[str]:
Copy link
Member

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:

  1. It's a little confusing to have header() and _header()
  2. 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()]

Copy link
Member

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?

@nh13 nh13 temporarily deployed to github-actions-ci August 15, 2024 20:58 — with GitHub Actions Inactive
Copy link
Member Author

@nh13 nh13 left a comment

Choose a reason for hiding this comment

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

@tfenne:

  1. I've changed _header to _fields_to_write
  2. 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 the yield getattr(self, name) in the values() method)
  3. I've made field_types not optional. Good catch, as this was a left-over from a previous attempt.

@nh13 nh13 temporarily deployed to github-actions-ci August 15, 2024 20:58 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci August 15, 2024 20:58 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci August 15, 2024 20:58 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci August 15, 2024 20:58 — with GitHub Actions Inactive
@nh13 nh13 requested review from tfenne and ameynert August 15, 2024 20:58
Copy link

@ameynert ameynert left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link

@ameynert ameynert left a comment

Choose a reason for hiding this comment

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

tick!

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.

Metric.write should support alternate ordering of fields
3 participants