Skip to content

Commit f5665b3

Browse files
mbaumanararslan
authored andcommitted
Revert #190 and anticipate deprecating implicit scalar broadcasting in setindex! (#195)
* Revert "Remove deprecations (and coming deprecations) (#190)" This reverts commit 83374c1. * (Partially) Revert "Revert "Remove deprecations (and coming deprecations) (#190)"" This partially reverts commit 3d0426e, restoring the non-broadcasting related changes. * Anticipate deprecating implicit scalar broadcasting in setindex!
1 parent 313f35d commit f5665b3

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

src/array/subarray.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ function perf_lucompletepivCopy!(A)
1313
μ, λ = _maxind(As)
1414
μ += k-1; λ += k-1
1515
rowpiv[k] = μ
16-
A[[k,μ], 1:n] .= A[[μ,k], 1:n]
16+
A[[k,μ], 1:n] = A[[μ,k], 1:n]
1717
colpiv[k] = λ
18-
A[1:n, [k,λ]] .= A[1:n, [λ,k]]
18+
A[1:n, [k,λ]] = A[1:n, [λ,k]]
1919
if A[k,k] 0
2020
ρ = k+1:n
21-
A[ρ, k] ./= A[k, k]
22-
A[ρ, ρ] .-= A[ρ, k:k] .* A[k:k, ρ]
21+
A[ρ, k] = A[ρ, k]/A[k, k]
22+
A[ρ, ρ] = A[ρ, ρ] - A[ρ, k:k] * A[k:k, ρ]
2323
end
2424
end
2525
return (A, rowpiv, colpiv)
@@ -34,13 +34,13 @@ function perf_lucompletepivSub!(A)
3434
μ, λ = _maxind(As)
3535
μ += k-1; λ += k-1
3636
rowpiv[k] = μ
37-
A[[k,μ], 1:n] .= view(A, [μ,k], 1:n)
37+
A[[k,μ], 1:n] = view(A, [μ,k], 1:n)
3838
colpiv[k] = λ
39-
A[1:n, [k,λ]] .= view(A, 1:n, [λ,k])
39+
A[1:n, [k,λ]] = view(A, 1:n, [λ,k])
4040
if A[k,k] 0
4141
ρ = k+1:n
42-
A[ρ, k] ./= A[k, k]
43-
A[ρ, ρ] .-= view(A, ρ, k:k) .* view(A, k:k, ρ)
42+
A[ρ, k] = view(A, ρ, k)/A[k, k]
43+
A[ρ, ρ] = view(A, ρ, ρ) - view(A, ρ, k:k) * view(A, k:k, ρ)
4444
end
4545
end
4646
return (A, rowpiv, colpiv)

src/array/sumindex.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function perf_sumlogical(A)
7575
nrows = size(A, 1)
7676
ncols = size(A, 2)
7777
r = falses(nrows)
78-
r[1:4:end] = true
78+
r[1:4:end] .= true
7979
@simd for i = 1:ncols
8080
val = Base.unsafe_getindex(A, r, i)
8181
s += first(val)
@@ -151,7 +151,7 @@ function perf_sumlogical_view(A)
151151
nrows = size(A, 1)
152152
ncols = size(A, 2)
153153
r = falses(nrows)
154-
r[1:4:end] = true
154+
r[1:4:end] .= true
155155
@inbounds for i = 1:ncols
156156
val = view(A, r, i)
157157
s += first(val)
@@ -287,7 +287,7 @@ end
287287
function makearrays(::Type{T}, r::Integer, c::Integer) where T
288288
A = samerand(T, r, c)
289289
B = similar(A, r+1, c+1)
290-
B[1:r, 1:c] .= A
290+
B[1:r, 1:c] = A
291291
AS = ArrayLS(B)
292292
ASS = ArrayLSLS(B)
293293
AF = ArrayLF(A)

src/problem/GoGame.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ end
297297
# that will not happen.
298298
#
299299
function compute_final_status!(board::Board)
300-
board.final_status[:] = UNKNOWN
300+
fill!(board.final_status, UNKNOWN)
301301
for i = 1:board.size, j = 1:board.size
302302
if board[i, j] == EMPTY
303303
for k = 1:4
@@ -351,15 +351,15 @@ function generate_move(board::Board, color::Int)
351351
# Further require the move not to be suicide for the opponent...
352352
if !suicide(board, ai, aj, other_color(color))
353353
num_moves += 1
354-
moves[:,num_moves] .= (ai, aj)
354+
moves[:,num_moves] = [ai, aj]
355355
else
356356
# ...however, if the move captures at least one stone,
357357
# consider it anyway.
358358
for k = 1:4
359359
(bi, bj) = neighbor(ai, aj, k)
360360
if on_board(board, bi, bj) && board[bi, bj] == other_color(color)
361361
num_moves += 1
362-
moves[:,num_moves] .= (ai, aj)
362+
moves[:,num_moves] = [ai, aj]
363363
break
364364
end
365365
end
@@ -415,7 +415,7 @@ function perf_go_game(num_games_per_point::Int)
415415
passes = 0
416416
num_moves = 1
417417
color = WHITE
418-
board.board[:] = EMPTY # clear board
418+
fill!(board.board, EMPTY) # clear board
419419
play_move!(board, i, j, BLACK)
420420
while passes < 3 && num_moves < 600
421421
(movei, movej) = generate_move(board, color)

src/problem/Laplacian.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function ddx_spdiags(m)
3333
# Append new d[k]-th diagonal to compact form
3434
for k = 1:p
3535
i = max(1,1-d[k]):min(m,n-d[k])
36-
a[(len[k]+1):len[k+1],:] .= [i i.+d[k] B[i.+(m>=n)*d[k],k]]
36+
a[(len[k]+1):len[k+1],:] = [i i.+d[k] B[i.+(m>=n)*d[k],k]]
3737
end
3838

3939
return sparse(a[:,1], a[:,2], a[:,3], m, n)
@@ -62,7 +62,7 @@ end
6262

6363
function perf_laplace_iter_devec(N)
6464
u = zeros(N, N)
65-
u[1, :] = 1
65+
u[1, :] .= 1
6666
Niter = 2^10
6767
dx2 = 0.1*0.1
6868
dy2 = dx2
@@ -80,7 +80,7 @@ end
8080

8181
function perf_laplace_iter_vec(N)
8282
u = zeros(N, N)
83-
u[1,:] = 1
83+
u[1,:] .= 1
8484
Niter = 2^10
8585
dx2 = dy2 = 0.1*0.1
8686
for i = 1:Niter
@@ -91,7 +91,7 @@ end
9191

9292
function perf_laplace_iter_sub(N)
9393
u = zeros(N, N)
94-
u[1,:] = 1
94+
u[1,:] .= 1
9595
Niter = 2^10
9696
dx2 = dy2 = 0.1*0.1
9797
u0 = view(u, 2:N-1, 2:N-1)

src/problem/SparseFEM.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
2121
# get the list of boundary dof-indices
2222
function get_free(N)
2323
L = zeros(Int, N, N)
24-
L[2:N-1, 2:N-1] = 1
24+
L[2:N-1, 2:N-1] .= 1
2525
return findall(!iszero, L)
2626
end
2727

src/problem/StockCorr.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ function perf_stockcorr()
2020

2121
## Define storages
2222
SimulPriceA = zeros(T,n) # Simulated Price of Asset A
23-
SimulPriceA[1,:] = CurrentPrice[1]
23+
SimulPriceA[1,:] .= CurrentPrice[1]
2424
SimulPriceB = zeros(T,n) # Simulated Price of Asset B
25-
SimulPriceB[1,:] = CurrentPrice[2]
25+
SimulPriceB[1,:] .= CurrentPrice[2]
2626

2727
## Generating the paths of stock prices by Geometric Brownian Motion
2828
UpperTriangle=chol(Corr) # UpperTriangle Matrix by Cholesky decomposition

0 commit comments

Comments
 (0)