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

138 fix the metric for dataless formations #142

Merged
merged 5 commits into from
Feb 21, 2024

Conversation

deemp
Copy link
Member

@deemp deemp commented Feb 20, 2024

Closes #138


PR-Codex overview

This PR enhances the eo-phi-normalizer by improving metrics calculation and adding a new function for counting dataless formations.

Detailed summary

  • Increased dataless metric values in metrics.yaml
  • Added a new function countDataless to count dataless formations in bindings
  • Updated the inspection logic in Collect.hs to utilize the new function

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@deemp deemp linked an issue Feb 20, 2024 that may be closed by this pull request
@deemp deemp requested a review from fizruk February 21, 2024 09:00
countDataless :: (MonadState Metrics m) => [Binding] -> m ()
countDataless bindings = do
let countDeltas = count (\case DeltaBinding _ -> True; _ -> False)
deltas = countDeltas (bindings <> concatMap (\case AlphaBinding _ (Formation bindings') -> bindings'; _ -> []) bindings)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like a very bad case-oneliner. Why not introduce a helper properly?

count :: (a -> Bool) -> [a] -> Int
count x = length . filter x

countDataless :: (MonadState Metrics m) => [Binding] -> m ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function requires documentation and a doctest.

Copy link
Member Author

Choose a reason for hiding this comment

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

added in 2fa396e

@deemp deemp force-pushed the 138-fix-the-metric-for-dataless-formations branch from 4926ee0 to 2fa396e Compare February 21, 2024 16:21
countDataless :: (Num a) => [Binding] -> a
countDataless bindings =
let countDeltas = count (\case DeltaBinding _ -> True; _ -> False)
nestedBindings = concatMap (\case AlphaBinding _ (Formation bindings') -> bindings'; _ -> []) bindings
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one-line case is still terrible :)

Copy link
Member Author

@deemp deemp Feb 21, 2024

Choose a reason for hiding this comment

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

I see no issues with it as long as I have only two cases, where the second one is trivial. Please, feel free to suggest changes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes sense to factor out this case into a separate named helper function and use indentation, not ; for the cases. This is not critical, just a style thing.

@fizruk fizruk merged commit db435c1 into master Feb 21, 2024
5 checks passed
@fizruk fizruk deleted the 138-fix-the-metric-for-dataless-formations branch February 21, 2024 20:16
@fizruk fizruk mentioned this pull request Mar 26, 2024
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.

Fix the metric for dataless formations
2 participants