|
29 | 29 | @test min(Mag(1), Mag(2)) == Mag(1)
|
30 | 30 | @test max(Mag(1), Mag(2)) == Mag(2)
|
31 | 31 | @test minmax(Mag(1), Mag(2)) == minmax(Mag(2), Mag(1)) == (Mag(1), Mag(2))
|
32 |
| - @test minimum(Mag[10:20; 0:9]) == Mag(0) |
33 |
| - @test maximum(Mag[10:20; 0:9]) == Mag(20) |
34 |
| - @test extrema(Mag[10:20; 0:9]) == (Mag(0), Mag(20)) |
35 | 32 | end
|
36 | 33 |
|
37 | 34 | @testset "Arf" begin
|
|
74 | 71 | @test min(Arf(1), Arf(2)) == Arf(1)
|
75 | 72 | @test max(Arf(1), Arf(2)) == Arf(2)
|
76 | 73 | @test minmax(Arf(1), Arf(2)) == minmax(Arf(2), Arf(1)) == (Arf(1), Arf(2))
|
77 |
| - @test minimum(Arf[10:20; 0:9]) == Arf(0) |
78 |
| - @test maximum(Arf[10:20; 0:9]) == Arf(20) |
79 |
| - @test extrema(Arf[10:20; 0:9]) == (Arf(0), Arf(20)) |
80 | 74 | end
|
81 | 75 |
|
82 | 76 | @testset "$T" for T in [Arb, Acb]
|
|
188 | 182 | @test all(Arblib.contains.(minmax(Arb((0, 2)), Arb((-1, 3))), (-1, 0)))
|
189 | 183 | @test all(Arblib.contains.(minmax(Arb((0, 2)), Arb((-1, 3))), (2, 3)))
|
190 | 184 | @test all(.!Arblib.contains.(minmax(Arb((0, 2)), Arb((-1, 3))), (3, -1)))
|
191 |
| - @test minimum(Arb[10:20; 0:9]) == Arb(0) |
192 |
| - @test maximum(Arb[10:20; 0:9]) == Arb(20) |
193 |
| - @test extrema(Arb[10:20; 0:9]) == (Arb(0), Arb(20)) |
194 |
| - A = [Arb((i, i + 1)) for i = 0:10] |
195 |
| - @test Arblib.contains(minimum(A), Arb((0, 1))) |
196 |
| - @test Arblib.contains(minimum(reverse(A)), Arb((0, 1))) |
197 |
| - @test Arblib.contains(maximum(A), Arb((10, 11))) |
198 |
| - @test Arblib.contains(maximum(reverse(A)), Arb((10, 11))) |
199 |
| - @test all(Arblib.contains.(extrema(A), (Arb((0, 1)), Arb((10, 11))))) |
200 |
| - # These fails with the default implementation of minimum and maximum |
201 |
| - @test Arblib.contains( |
202 |
| - minimum([Arb((-i, -i + 1)) for i = 0:1000]), |
203 |
| - Arb((-1000, -999)), |
204 |
| - ) |
205 |
| - @test Arblib.contains(maximum([Arb((i, i + 1)) for i = 0:1000]), Arb((1000, 1001))) |
206 | 185 | end
|
207 | 186 |
|
208 | 187 | @testset "Acb - specific" begin
|
|
243 | 222 | @test abs(Acb(3, 4)) isa Arb
|
244 | 223 | @test abs(Acb(3, 4)) == Arb(5)
|
245 | 224 | end
|
| 225 | + |
| 226 | + @testset "minimum/maximum/extrema" begin |
| 227 | + # See https://github.com/JuliaLang/julia/issues/45932 for |
| 228 | + # discussions about the issues with the Base implementation |
| 229 | + |
| 230 | + # Currently there is no special implementation of extrema, the |
| 231 | + # default implementation works well. But to help find future |
| 232 | + # issues we test it here as well. |
| 233 | + |
| 234 | + A = Arb[10:20; 0:9] |
| 235 | + @test minimum(A) == 0 |
| 236 | + @test maximum(A) == 20 |
| 237 | + @test extrema(A) == (0, 20) |
| 238 | + |
| 239 | + A = [Arb((i, i + 1)) for i = 0:20] |
| 240 | + @test contains(minimum(A), Arb((0, 1))) |
| 241 | + @test contains(minimum(reverse(A)), Arb((0, 1))) |
| 242 | + @test contains(maximum(A), Arb((20, 21))) |
| 243 | + @test contains(maximum(reverse(A)), Arb((20, 21))) |
| 244 | + @test all(contains.(extrema(A), (Arb((0, 1)), Arb((20, 21))))) |
| 245 | + @test all(contains.(extrema(reverse(A)), (Arb((0, 1)), Arb((20, 21))))) |
| 246 | + |
| 247 | + # Fails in Julia version < 1.8 with default implementation due |
| 248 | + # to short circuiting in Base.mapreduce_impl |
| 249 | + A = [setball(Arb, 2, 1); zeros(Arb, 257)] |
| 250 | + @test iszero(minimum(A)) |
| 251 | + @test iszero(maximum(-A)) |
| 252 | + @test iszero(extrema(A)[1]) |
| 253 | + @test iszero(extrema(-A)[2]) |
| 254 | + # Before 1.8.0 these still fails and there is no real way to |
| 255 | + # overload them |
| 256 | + if VERSION < v"1.8.0-rc3" |
| 257 | + @test_broken iszero(minimum(identity, A)) |
| 258 | + @test_broken iszero(maximum(identity, -A)) |
| 259 | + else |
| 260 | + @test iszero(minimum(identity, A)) |
| 261 | + @test iszero(maximum(identity, -A)) |
| 262 | + end |
| 263 | + # These work |
| 264 | + @test iszero(extrema(identity, A)[1]) |
| 265 | + @test iszero(extrema(identity, -A)[2]) |
| 266 | + |
| 267 | + # Fails with default implementation due to Base._fast |
| 268 | + #A = [Arb(0); [setball(Arb, 0, i) for i in reverse(0:257)]] |
| 269 | + A = [setball(Arb, 0, i) for i = 0:257] |
| 270 | + @test contains(minimum(A), -257) |
| 271 | + @test contains(maximum(A), 257) |
| 272 | + @test contains(extrema(A)[1], -257) |
| 273 | + @test contains(extrema(A)[2], 257) |
| 274 | + @test contains(minimum(identity, A), -257) |
| 275 | + @test contains(maximum(identity, A), 257) |
| 276 | + @test contains(extrema(identity, A)[1], -257) |
| 277 | + @test contains(extrema(identity, A)[2], 257) |
| 278 | + |
| 279 | + # Fails with default implementation due to both short circuit |
| 280 | + # and Base._fast |
| 281 | + A = [setball(Arb, 0, i) for i = 0:1000] |
| 282 | + @test contains(minimum(A), -1000) |
| 283 | + @test contains(maximum(A), 1000) |
| 284 | + @test contains(extrema(A)[1], -1000) |
| 285 | + @test contains(extrema(A)[2], 1000) |
| 286 | + if VERSION < v"1.8.0-rc3" |
| 287 | + @test_broken contains(minimum(identity, A), -1000) |
| 288 | + @test_broken contains(maximum(identity, A), 1000) |
| 289 | + else |
| 290 | + @test contains(minimum(identity, A), -1000) |
| 291 | + @test contains(maximum(identity, A), 1000) |
| 292 | + end |
| 293 | + @test contains(extrema(identity, A)[1], -1000) |
| 294 | + @test contains(extrema(identity, A)[2], 1000) |
| 295 | + |
| 296 | + @test !Base.isbadzero(min, zero(Mag)) |
| 297 | + @test !Base.isbadzero(min, zero(Arf)) |
| 298 | + @test !Base.isbadzero(min, zero(Arb)) |
| 299 | + |
| 300 | + @test !Base.isbadzero(max, zero(Mag)) |
| 301 | + @test !Base.isbadzero(max, zero(Arf)) |
| 302 | + @test !Base.isbadzero(max, zero(Arb)) |
| 303 | + |
| 304 | + @test !Base.isgoodzero(min, zero(Mag)) |
| 305 | + @test !Base.isgoodzero(min, zero(Arf)) |
| 306 | + @test !Base.isgoodzero(min, zero(Arb)) |
| 307 | + |
| 308 | + @test !Base.isgoodzero(max, zero(Mag)) |
| 309 | + @test !Base.isgoodzero(max, zero(Arf)) |
| 310 | + @test !Base.isgoodzero(max, zero(Arb)) |
| 311 | + end |
246 | 312 | end
|
0 commit comments