Skip to content

Commit

Permalink
Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
ebc-2in2crc committed Jun 9, 2023
1 parent e967fd5 commit 11a039d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/percentile/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *CLI) Run() error {
sort.Float64s(numbers)

for _, v := range opt.pValues {
p := percentile.Get(numbers, v)
p := percentile.Calculate(numbers, v)
if opt.rValue {
_, _ = fmt.Fprintf(c.OutStream, "p%d: %.1f \n", v, p)
} else {
Expand Down
4 changes: 2 additions & 2 deletions percentile.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package percentile

// Get returns the percentile value of the given numbers.
func Get(numbers []float64, percent int) float64 {
// Calculate returns the percentile value of the given numbers.
func Calculate(numbers []float64, percent int) float64 {
if percent == 0 {
return numbers[0]
}
Expand Down
2 changes: 1 addition & 1 deletion percentile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestPercentile(t *testing.T) {
{percent: 99, expect: 99.5},
{percent: 100, expect: 100.0},
} {
actual := Get(numbers, v.percent)
actual := Calculate(numbers, v.percent)
if actual != v.expect {
t.Errorf("percentile(%d): Output = %f; want %f", v.percent, actual, v.expect)
}
Expand Down

0 comments on commit 11a039d

Please sign in to comment.