Skip to content

Commit ec26062

Browse files
committed
Add whitespace around some operators and after commas
1 parent 70863e5 commit ec26062

File tree

17 files changed

+47
-47
lines changed

17 files changed

+47
-47
lines changed

src/atoms/affine/multiply_divide.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ function conic_form!(x::DotMultiplyAtom, unique_conic_forms::UniqueConicForms=Un
164164
# and that the sizes are compatible,
165165
# so if the sizes aren't equal the smaller one is size 1
166166
var = x.children[2]
167-
if size(var,1) < size(coeff,1)
168-
var = ones(size(coeff,1))*var
169-
elseif size(var,2) < size(coeff,2)
170-
var = var*ones(1,size(coeff,1))
167+
if size(var, 1) < size(coeff, 1)
168+
var = ones(size(coeff, 1)) * var
169+
elseif size(var, 2) < size(coeff, 2)
170+
var = var * ones(1, size(coeff, 1))
171171
end
172172

173173
const_multiplier = spdiagm(0 => vec(coeff))
@@ -180,10 +180,10 @@ end
180180
function broadcasted(::typeof(*), x::Constant, y::AbstractExpr)
181181
if x.size == (1, 1) || y.size == (1, 1)
182182
return x * y
183-
elseif size(y,1) < size(x,1) && size(y,1) == 1
184-
return DotMultiplyAtom(x, ones(size(x,1))*y)
185-
elseif size(y,2) < size(x,2) && size(y,2) == 1
186-
return DotMultiplyAtom(x, y*ones(1,size(x,1)))
183+
elseif size(y, 1) < size(x, 1) && size(y, 1) == 1
184+
return DotMultiplyAtom(x, ones(size(x, 1)) * y)
185+
elseif size(y, 2) < size(x, 2) && size(y, 2) == 1
186+
return DotMultiplyAtom(x, y * ones(1, size(x, 1)))
187187
else
188188
return DotMultiplyAtom(x, y)
189189
end

src/atoms/exp_cone/entropy.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mutable struct EntropyAtom <: AbstractExpr
2020
size::Tuple{Int, Int}
2121

2222
function EntropyAtom(x::AbstractExpr)
23-
if sign(x)==ComplexSign()
23+
if sign(x) == ComplexSign()
2424
error("The argument should be real but it's instead complex")
2525
else
2626
children = (x,)
@@ -53,9 +53,9 @@ function conic_form!(e::EntropyAtom, unique_conic_forms::UniqueConicForms=Unique
5353
t = Variable(e.size)
5454
x = e.children[1]
5555
objective = conic_form!(t, unique_conic_forms)
56-
for i=1:size(x,1)
57-
for j=1:size(x,2)
58-
conic_form!( ExpConstraint(t[i,j], x[i,j], 1), unique_conic_forms)
56+
for i = 1:size(x, 1)
57+
for j = 1:size(x, 2)
58+
conic_form!(ExpConstraint(t[i, j], x[i, j], 1), unique_conic_forms)
5959
end
6060
end
6161
cache_conic_form!(unique_conic_forms, e, objective)

src/atoms/exp_cone/exp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct ExpAtom <: AbstractExpr
1818
size::Tuple{Int, Int}
1919

2020
function ExpAtom(x::AbstractExpr)
21-
if sign(x)==ComplexSign()
21+
if sign(x) == ComplexSign()
2222
error("The argument should be real but it's instead complex")
2323
else
2424
children = (x,)

src/atoms/exp_cone/logsumexp.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct LogSumExpAtom <: AbstractExpr
1919
size::Tuple{Int, Int}
2020

2121
function LogSumExpAtom(x::AbstractExpr)
22-
if sign(x)==ComplexSign()
22+
if sign(x) == ComplexSign()
2323
error("The argument should be real but it's instead complex")
2424
else
2525
children = (x,)
@@ -48,7 +48,7 @@ logsumexp(x::AbstractExpr) = LogSumExpAtom(x)
4848

4949
function conic_form!(e::LogSumExpAtom, unique_conic_forms::UniqueConicForms=UniqueConicForms())
5050
if !has_conic_form(unique_conic_forms, e)
51-
# log(sum(exp(x))) <= t <=> sum(exp(x)) <= exp(t) <=> sum(exp(x - t)) <= 1
51+
# log(sum(exp(x))) <= t <=> sum(exp(x)) <= exp(t) <=> sum(exp(x - t)) <= 1
5252
t = Variable(e.size)
5353
z = sum(exp(e.children[1] - t))
5454
objective = conic_form!(t, unique_conic_forms)
@@ -62,8 +62,8 @@ end
6262

6363
function logisticloss(e::AbstractExpr)
6464
s = 0
65-
length(e)==1 && return logsumexp([e, 0])
66-
for i=1:length(e)
65+
length(e) == 1 && return logsumexp([e, 0])
66+
for i = 1:length(e)
6767
s += logsumexp([e[i]; 0])
6868
end
6969
return s

src/atoms/exp_cone/relative_entropy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct RelativeEntropyAtom <: AbstractExpr
1717
size::Tuple{Int, Int}
1818

1919
function RelativeEntropyAtom(x::AbstractExpr, y::AbstractExpr)
20-
if sign(x)==ComplexSign() || sign(y)==ComplexSign()
20+
if sign(x) == ComplexSign() || sign(y) == ComplexSign()
2121
error("Both the arguments should be real but these are instead $(sign(x)) and $(sign(y))")
2222
else
2323
children = (x, y)

src/atoms/lp_cone/abs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function conic_form!(x::AbsAtom, unique_conic_forms::UniqueConicForms=UniqueConi
4949
conic_form!(t[i]>=norm2([real(c[i]);imag(c[i])]), unique_conic_forms)
5050
end
5151
else
52-
conic_form!(c<=t, unique_conic_forms)
53-
conic_form!(c>=-t, unique_conic_forms)
52+
conic_form!(c <= t, unique_conic_forms)
53+
conic_form!(c >= -t, unique_conic_forms)
5454
end
5555
cache_conic_form!(unique_conic_forms, x, objective)
5656
end

src/atoms/lp_cone/dotsort.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct DotSortAtom <: AbstractExpr
1818
w::Value
1919

2020
function DotSortAtom(x::AbstractExpr, w::Value)
21-
if sign(x)==ComplexSign()
21+
if sign(x) == ComplexSign()
2222
error("Argument should be real instead it is $(sign(x))")
2323
else
2424
if !(length(w) == get_vectorized_size(x))
@@ -32,17 +32,17 @@ struct DotSortAtom <: AbstractExpr
3232
end
3333

3434
function sign(x::DotSortAtom)
35-
if all(x.w.>=0)
35+
if all(x.w .>= 0)
3636
return sign(x.children[1])
37-
elseif all(x.w.<=0)
37+
elseif all(x.w .<= 0)
3838
return sign(x.children[1])
3939
else
4040
return NoSign()
4141
end
4242
end
4343

4444
function monotonicity(x::DotSortAtom)
45-
if all(x.w.>=0)
45+
if all(x.w .>= 0)
4646
return (Nondecreasing(), )
4747
else
4848
return (NoMonotonicity(), )

src/atoms/lp_cone/max.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct MaxAtom <: AbstractExpr
1616
size::Tuple{Int, Int}
1717

1818
function MaxAtom(x::AbstractExpr, y::AbstractExpr)
19-
if sign(x)==ComplexSign() || sign(y)==ComplexSign()
19+
if sign(x) == ComplexSign() || sign(y) == ComplexSign()
2020
error("Both the arguments should be real instead they are $(sign(x)) and $(sign(y))")
2121
else
2222
if x.size == y.size

src/atoms/lp_cone/min.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct MinAtom <: AbstractExpr
1616
size::Tuple{Int, Int}
1717

1818
function MinAtom(x::AbstractExpr, y::AbstractExpr)
19-
if sign(x)==ComplexSign() || sign(y)==ComplexSign()
19+
if sign(x) == ComplexSign() || sign(y) == ComplexSign()
2020
error("Both the arguments should be real instead they are $(sign(x)) and $(sign(y))")
2121
else
2222
if x.size == y.size

src/atoms/lp_cone/minimum.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct MinimumAtom <: AbstractExpr
1515
size::Tuple{Int, Int}
1616

1717
function MinimumAtom(x::AbstractExpr)
18-
if sign(x)==ComplexSign()
18+
if sign(x) == ComplexSign()
1919
error("Argument should be real instead it is $(sign(x))")
2020
else
2121
children = (x,)

0 commit comments

Comments
 (0)