Skip to content

Commit

Permalink
rm deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
suchen-sci committed Jan 13, 2024
1 parent 167a075 commit 498d2a6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 169 deletions.
45 changes: 0 additions & 45 deletions README.md
Expand Up @@ -32,15 +32,12 @@
- [gfn.DivMod](#gfndivmod)
- [gfn.Max](#gfnmax)
- [gfn.MaxBy](#gfnmaxby)
- [gfn.MaxFloat64 (Deprecated)](#gfnmaxfloat64-deprecated)
- [gfn.Mean](#gfnmean)
- [gfn.MeanBy](#gfnmeanby)
- [gfn.Min](#gfnmin)
- [gfn.MinBy](#gfnminby)
- [gfn.MinFloat64 (Deprecated)](#gfnminfloat64-deprecated)
- [gfn.MinMax](#gfnminmax)
- [gfn.MinMaxBy](#gfnminmaxby)
- [gfn.MinMaxFloat64 (Deprecated)](#gfnminmaxfloat64-deprecated)
- [gfn.Mode](#gfnmode)
- [gfn.ModeBy](#gfnmodeby)
- [gfn.Sum](#gfnsum)
Expand Down Expand Up @@ -309,20 +306,6 @@ p := gfn.MaxBy(products, func(p Product) int {
[back to top](#gfn)


### gfn.MaxFloat64 (Deprecated)
```go
func MaxFloat64(array ...float64) float64
```
Deprecated: MaxFloat64 returns the maximum value in the array. Use Max instead.

#### Example:
```go
gfn.MaxFloat64(1.1, math.NaN(), 2.2) // 2.2
gfn.MaxFloat64([]float64{math.NaN(), math.NaN(), math.NaN()}...) // NaN
```
[back to top](#gfn)


### gfn.Mean
```go
func Mean[T Int | Uint | Float](array ...T) float64
Expand Down Expand Up @@ -403,20 +386,6 @@ p := gfn.MinBy(products, func(p Product) int {
[back to top](#gfn)


### gfn.MinFloat64 (Deprecated)
```go
func MinFloat64(array ...float64) float64
```
Deprecated: MinFloat64 returns the minimum value in the array. Use Min instead.

#### Example:
```go
gfn.MinFloat64(1, -1, 10) // -1
gfn.MinFloat64([]float64{1.1, math.Inf(-1), math.NaN()}...) // math.Inf(-1)
```
[back to top](#gfn)


### gfn.MinMax
```go
func MinMax[T Int | Uint | Float | ~string](array ...T) (T, T)
Expand Down Expand Up @@ -459,20 +428,6 @@ gfn.MinMaxBy(products, func(p Product) int {
[back to top](#gfn)


### gfn.MinMaxFloat64 (Deprecated)
```go
func MinMaxFloat64(array ...float64) (float64, float64)
```
Deprecated: MinMaxFloat64 returns the minimum and maximum value in the array. Use MinMax instead.

#### Example:
```go
gfn.MinMaxFloat64(math.NaN(), 1.85, 2.2) // 1.85, 2.2
gfn.MinMaxFloat64(math.NaN(), math.NaN(), math.NaN()) // NaN, NaN
```
[back to top](#gfn)


### gfn.Mode
```go
func Mode[T comparable](array []T) T
Expand Down
30 changes: 0 additions & 30 deletions math.go
Expand Up @@ -65,16 +65,6 @@ func MaxBy[T any, U Int | Uint | Float | ~string](array []T, fn func(T) U) T {
return res
}

/* @example MaxFloat64
gfn.MaxFloat64(1.1, math.NaN(), 2.2) // 2.2
gfn.MaxFloat64([]float64{math.NaN(), math.NaN(), math.NaN()}...) // NaN
*/

// Deprecated: MaxFloat64 returns the maximum value in the array. Use Max instead.
func MaxFloat64(array ...float64) float64 {
return Max(array...)
}

/* @example Min
gfn.Min(1.1, 2.2, 3.3) // 1.1
gfn.Min([]int16{1, 5, 9, 10}...) // 1
Expand All @@ -101,16 +91,6 @@ func Min[T Int | Uint | Float | ~string](array ...T) T {
return res
}

/* @example MinFloat64
gfn.MinFloat64(1, -1, 10) // -1
gfn.MinFloat64([]float64{1.1, math.Inf(-1), math.NaN()}...) // math.Inf(-1)
*/

// Deprecated: MinFloat64 returns the minimum value in the array. Use Min instead.
func MinFloat64(array ...float64) float64 {
return Min(array...)
}

/* @example MinBy
type Product struct {
name string
Expand Down Expand Up @@ -292,16 +272,6 @@ func MinMax[T Int | Uint | Float | ~string](array ...T) (T, T) {
return minimum, maximum
}

/* @example MinMaxFloat64
gfn.MinMaxFloat64(math.NaN(), 1.85, 2.2) // 1.85, 2.2
gfn.MinMaxFloat64(math.NaN(), math.NaN(), math.NaN()) // NaN, NaN
*/

// Deprecated: MinMaxFloat64 returns the minimum and maximum value in the array. Use MinMax instead.
func MinMaxFloat64(array ...float64) (float64, float64) {
return MinMax(array...)
}

/* @example MinMaxBy
type Product struct {
name string
Expand Down
94 changes: 0 additions & 94 deletions math_test.go
Expand Up @@ -60,32 +60,6 @@ func TestMax(t *testing.T) {
}
}

func TestMaxFloat64(t *testing.T) {
AssertEqual(t, 2.2, MaxFloat64(math.NaN(), 1, 2.2))
AssertEqual(t, 2.8, MaxFloat64(1, -1, math.NaN(), 1, 2.8))
AssertEqual(t, math.Inf(1), MaxFloat64(1, -1, math.NaN(), 1, math.Inf(1)))
AssertEqual(t, math.Inf(1), MaxFloat64(1, -1, 1, math.Inf(1)))
AssertEqual(t, 1.9, MaxFloat64(1.9, -1, 1))
AssertTrue(t, math.IsNaN(MaxFloat64(math.NaN(), math.NaN(), math.NaN())))

// check empty array
AssertPanics(t, func() {
MaxFloat64()
})

// check array with many elements
{
array := make([]float64, 100000)
for i := 0; i < 100000; i++ {
array[i] = float64(i)
}
rand.Shuffle(len(array), func(i, j int) {
array[i], array[j] = array[j], array[i]
})
AssertEqual(t, float64(99999), MaxFloat64(array...))
}
}

func TestMin(t *testing.T) {
// ints
AssertEqual(t, 1, Min(1, 2, 3), "int")
Expand Down Expand Up @@ -138,32 +112,6 @@ func TestMin(t *testing.T) {
}
}

func TestMinFloat64(t *testing.T) {
AssertEqual(t, 1.85, MinFloat64(math.NaN(), 1.85, 2.2))
AssertEqual(t, -1, MinFloat64(1, -1, math.NaN(), 1, 2.8))
AssertEqual(t, math.Inf(-1), MinFloat64(1, -1, math.NaN(), 1, math.Inf(-1)))
AssertEqual(t, -1, MinFloat64(1, -1, 1, math.Inf(1)))
AssertEqual(t, -1, MinFloat64(1.9, -1, 1))
AssertTrue(t, math.IsNaN(MinFloat64(math.NaN(), math.NaN(), math.NaN())))

// check empty array
AssertPanics(t, func() {
MinFloat64()
})

// check array with many elements
{
array := make([]float64, 100000)
for i := 0; i < 100000; i++ {
array[i] = float64(i)
}
rand.Shuffle(len(array), func(i, j int) {
array[i], array[j] = array[j], array[i]
})
AssertEqual(t, float64(0), MinFloat64(array...))
}
}

func TestSum(t *testing.T) {
// ints
AssertEqual(t, 10, Sum(1, 2, 3, 4), "int")
Expand Down Expand Up @@ -419,48 +367,6 @@ func TestMinMax(t *testing.T) {
}
}

func TestMinMaxFloat64(t *testing.T) {
var minVal, maxVal float64
minVal, maxVal = MinMaxFloat64(math.NaN(), 1.85, 2.2)
AssertEqual(t, 1.85, minVal)
AssertEqual(t, 2.2, maxVal)

minVal, maxVal = MinMaxFloat64(1, -1, math.NaN(), 1, 2.8)
AssertEqual(t, -1, minVal)
AssertEqual(t, 2.8, maxVal)

minVal, maxVal = MinMaxFloat64(1, -1, math.NaN(), 1, math.Inf(-1))
AssertEqual(t, math.Inf(-1), minVal)
AssertEqual(t, 1, maxVal)

minVal, maxVal = MinMaxFloat64(1, -1, 1, math.Inf(1))
AssertEqual(t, -1, minVal)
AssertEqual(t, math.Inf(1), maxVal)

minVal, maxVal = MinMaxFloat64(math.NaN(), math.NaN(), math.NaN())
AssertTrue(t, math.IsNaN(minVal))
AssertTrue(t, math.IsNaN(maxVal))

// check empty array
AssertPanics(t, func() {
MinMaxFloat64()
})

// check array with many elements
{
array := make([]float64, 100000)
for i := 0; i < 100000; i++ {
array[i] = float64(i)
}
rand.Shuffle(len(array), func(i, j int) {
array[i], array[j] = array[j], array[i]
})
minVal, maxVal := MinMaxFloat64(array...)
AssertEqual(t, float64(0), minVal)
AssertEqual(t, float64(99999), maxVal)
}
}

func TestMinMaxBy(t *testing.T) {
type Product struct {
name string
Expand Down

0 comments on commit 498d2a6

Please sign in to comment.