|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license |
2 | 2 |
|
3 | | -using Statistics, Test, Random, LinearAlgebra, SparseArrays |
| 3 | +using Statistics, Test, Random, LinearAlgebra, SparseArrays, Dates |
4 | 4 | using Test: guardseed |
5 | 5 |
|
6 | 6 | Random.seed!(123) |
|
784 | 784 | @test issorted(quantile([1.0, 1.0+2eps(), 1.0+4eps(), 1.0+6eps()], range(0, 1, length=100))) |
785 | 785 | end |
786 | 786 |
|
| 787 | +@testset "quantiles with Date and DateTime" begin |
| 788 | + # this is the historical behavior |
| 789 | + @test quantile([Date(2023, 09, 02)], .1) == Date(2023, 09, 02) |
| 790 | + @test quantile([Date(2023, 09, 02), Date(2023, 09, 02)], .1) == Date(2023, 09, 02) |
| 791 | + @test_throws InexactError quantile([Date(2023, 09, 02), Date(2023, 09, 03)], .1) |
| 792 | + |
| 793 | + @test quantile([DateTime(2023, 09, 02)], .1) == DateTime(2023, 09, 02) |
| 794 | + @test quantile([DateTime(2023, 09, 02), DateTime(2023, 09, 02)], .1) == DateTime(2023, 09, 02) |
| 795 | + @test_throws InexactError quantile([DateTime(2023, 09, 02), DateTime(2023, 09, 03)], .1) |
| 796 | +end |
| 797 | + |
787 | 798 | @testset "variance of complex arrays (#13309)" begin |
788 | 799 | z = rand(ComplexF64, 10) |
789 | 800 | @test var(z) ≈ invoke(var, Tuple{Any}, z) ≈ cov(z) ≈ var(z,dims=1)[1] ≈ sum(abs2, z .- mean(z))/9 |
|
0 commit comments