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

fix percentile return error when only one element #47

Merged
merged 3 commits into from
Jul 9, 2019

Conversation

shiyan2016
Copy link
Contributor

Fix: #46

@coveralls
Copy link

coveralls commented Jul 9, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling f8c3d9d on shiyan2016:fix-percentile into 38304a2 on montanaflynn:master.

percentile.go Outdated
@@ -18,6 +18,10 @@ func Percentile(input Float64Data, percent float64) (percentile float64, err err
// Start by sorting a copy of the slice
c := sortedCopy(input)

if len(c) == 1 {
Copy link

Choose a reason for hiding this comment

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

It's really micro optimization but maybe better move this check before sorting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's really micro optimization but maybe better move this check before sorting?

done

@montanaflynn montanaflynn merged commit dfab42c into montanaflynn:master Jul 9, 2019
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.

Percentile return BoundsErr when the input is only one element
4 participants