|
574 | 574 | end |
575 | 575 | end |
576 | 576 |
|
| 577 | +@testset "allequal and allunique" begin |
| 578 | + # General weights |
| 579 | + for f in (weights, aweights, fweights, pweights) |
| 580 | + @test allunique(f(Float64[])) |
| 581 | + @test allunique(f([0.4])) |
| 582 | + @test allunique(f([0.4, 0.3])) |
| 583 | + @test !allunique(f([0.4, 0.4])) |
| 584 | + @test allunique(f([0.4, 0.3, 0.5])) |
| 585 | + @test !allunique(f([0.4, 0.4, 0.5])) |
| 586 | + @test allunique(f([0.4, 0.3, 0.5, 0.35])) |
| 587 | + @test !allunique(f([0.4, 0.3, 0.5, 0.4])) |
| 588 | + |
| 589 | + if isdefined(Base, :allequal) |
| 590 | + @test allequal(f(Float64[])) |
| 591 | + @test allequal(f([0.4])) |
| 592 | + @test allequal(f([0.4, 0.4])) |
| 593 | + @test !allequal(f([0.4, 0.3])) |
| 594 | + @test allequal(f([0.4, 0.4, 0.4, 0.4])) |
| 595 | + @test !allunique(f([0.4, 0.4, 0.3, 0.4])) |
| 596 | + end |
| 597 | + end |
| 598 | + |
| 599 | + # Uniform weights |
| 600 | + @test allunique(uweights(0)) |
| 601 | + @test allunique(uweights(1)) |
| 602 | + @test !allunique(uweights(2)) |
| 603 | + @test !allunique(uweights(5)) |
| 604 | + |
| 605 | + if isdefined(Base, :allequal) |
| 606 | + @test allequal(uweights(0)) |
| 607 | + @test allequal(uweights(1)) |
| 608 | + @test allequal(uweights(2)) |
| 609 | + @test allequal(uweights(5)) |
| 610 | + end |
| 611 | +end |
| 612 | + |
577 | 613 | end # @testset StatsBase.Weights |
0 commit comments