@@ -114,21 +114,21 @@ end
114
114
115
115
function issue108! (y:: Vector{T1} , x:: Vector{T2} ) where {T1,T2}
116
116
@batch for i in eachindex (y)
117
- y[i] = sum (x[j] for j in 2 i- oneunit (i): 2 i)
117
+ y[i] = sum (x[j] for j = 2 i- oneunit (i): 2 i)
118
118
end
119
119
end
120
120
121
121
function issue108_comment! (data:: Vector{T} , functions) where {T}
122
122
@batch for i in eachindex (data)
123
123
for f in functions
124
- data[i] += f (data[i])
124
+ data[i] += f (data[i])
125
125
end
126
126
end
127
127
end
128
128
129
129
function issue116! (y:: Vector{T} , x:: Vector{T} ) where {T}
130
- @batch for i in 1 : length (x)
131
- y[i] = exp (x[i] + one (T))
130
+ @batch for i = 1 : length (x)
131
+ y[i] = exp (x[i] + one (T))
132
132
end
133
133
end
134
134
@@ -280,15 +280,15 @@ end
280
280
x = collect (1 : 12 )
281
281
y = zeros (6 )
282
282
issue108! (y, x)
283
- @test y == [sum (x[j] for j in 2 i- oneunit (i): 2 i) for i in 1 : 6 ]
284
-
285
- functions = [x -> n* x for n in 1 : 3 ]
283
+ @test y == [sum (x[j] for j = 2 i- oneunit (i): 2 i) for i = 1 : 6 ]
284
+
285
+ functions = [x -> n * x for n = 1 : 3 ]
286
286
data = rand (100 )
287
287
data1 = deepcopy (data)
288
288
issue108_comment! (data, functions)
289
289
for i in eachindex (data1)
290
290
for f in functions
291
- data1[i] += f (data1[i])
291
+ data1[i] += f (data1[i])
292
292
end
293
293
end
294
294
@test data == data1
467
467
end
468
468
local7, local8 = let
469
469
red = 0
470
- @batch minbatch = 100 stride = true reduction = (+ ,red) threadlocal = red for i = 0 : 9
470
+ @batch minbatch = 100 stride = true reduction = (+ , red) threadlocal = red for i = 0 : 9
471
471
red += 1
472
472
threadlocal += 1
473
473
end
@@ -480,11 +480,19 @@ end
480
480
end
481
481
red
482
482
end
483
- @test local1== local2== local3== local4== local5== local6== local7== local8== localsr
483
+ @test local1 ==
484
+ local2 ==
485
+ local3 ==
486
+ local4 ==
487
+ local5 ==
488
+ local6 ==
489
+ local7 ==
490
+ local8 ==
491
+ localsr
484
492
# check different operations
485
493
local9 = let
486
494
red = 1.0
487
- @batch reduction = (* ,red) for i = 1 : 100
495
+ @batch reduction = (* , red) for i = 1 : 100
488
496
red *= 4 i^ 2 / (4 i^ 2 - 1 )
489
497
end
490
498
2 red
495
503
red1 = 0
496
504
red2 = 0
497
505
red3 = 0
498
- @batch reduction = ((+ ,red1), (+ ,red2), (+ ,red3)) for i = 0 : 9
506
+ @batch reduction = ((+ , red1), (+ , red2), (+ , red3)) for i = 0 : 9
499
507
red1 += 1
500
508
red2 += 1
501
509
red3 -= 1
@@ -507,13 +515,19 @@ end
507
515
function f ()
508
516
n = 1000
509
517
threadlocal = 0
510
- @batch minbatch = 10 reduction = (+ ,threadlocal) for i = 1 : n
518
+ @batch minbatch = 10 reduction = (+ , threadlocal) for i = 1 : n
511
519
threadlocal += 1
512
520
end
513
521
return threadlocal
514
522
end
515
523
allocated (f:: F ) where {F} = @allocated f ()
516
- inferred (f:: F ) where {F} = try @inferred f (); true catch ; false end
524
+ inferred (f:: F ) where {F} =
525
+ try
526
+ @inferred f ()
527
+ true
528
+ catch
529
+ false
530
+ end
517
531
allocated (f)
518
532
@test allocated (f) == 0
519
533
@test inferred (f) == true
@@ -524,16 +538,20 @@ end
524
538
red2 = false
525
539
red3 = typemax (eltype (arr))
526
540
red4 = typemin (eltype (arr))
527
- @batch reduction = ((& ,red1), (| ,red2), (min,red3), (max,red4)) for x in arr
528
- red1 &= x > 0.5
529
- red2 |= x > 0.5
530
- red3 = min (red3, x)
531
- red4 = max (red4, x)
541
+ @batch reduction = ((& , red1), (| , red2), (min, red3), (max, red4)) for x in arr
542
+ red1 &= x > 0.5
543
+ red2 |= x > 0.5
544
+ red3 = min (red3, x)
545
+ red4 = max (red4, x)
532
546
end
533
547
red1, red2, red3, red4
534
548
end
535
- @test (local13, local14, local15, local16) ==
536
- (mapreduce (x-> x> 0.5 , & , arr), mapreduce (x-> x> 0.5 , | , arr), minimum (arr), maximum (arr))
549
+ @test (local13, local14, local15, local16) == (
550
+ mapreduce (x -> x > 0.5 , & , arr),
551
+ mapreduce (x -> x > 0.5 , | , arr),
552
+ minimum (arr),
553
+ maximum (arr),
554
+ )
537
555
end
538
556
539
557
@testset " locks and refvalues" begin
@@ -747,14 +765,26 @@ end
747
765
return any (find_call_to_nthreads, expr. args)
748
766
end
749
767
750
- expr = @macroexpand @batch for i in 1 : 100
768
+ expr = @macroexpand @batch for i = 1 : 100
751
769
a[i] = i
752
770
end
753
771
754
772
@test find_call_to_nthreads (expr)
755
773
end
756
774
775
+
776
+ function dummy_broadcast! (x)
777
+ @batch for i = 1 : 2
778
+ a = (1 ,) .+ (1 ,)
779
+ x[i] = only (a)
780
+ end
781
+ end
782
+ let x = Vector {Float64} (undef, 2 )
783
+ dummy_broadcast! (x)
784
+ @test x == fill (2.0 , 2 )
785
+ end
786
+
757
787
if VERSION ≥ v " 1.6"
758
788
println (" Package tests complete. Running `Aqua` checks." )
759
- Aqua. test_all (Polyester; deps_compat = (check_extras= false ,))
789
+ Aqua. test_all (Polyester; deps_compat = (check_extras = false ,))
760
790
end
0 commit comments