Skip to content

Commit d04b925

Browse files
committed
Fix coeff dict duplicate variable and function name issue
1 parent 0c15b58 commit d04b925

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/types.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,9 @@ ratio(x::Integer,y::Integer) = iszero(rem(x,y)) ? div(x,y) : x//y
463463
ratio(x::Rat,y::Rat) = x//y
464464
function maybe_intcoeff(x)
465465
if ismul(x)
466-
coeff = coeff(x)
467-
if coeff isa Rational && isone(denominator(coeff))
468-
_Mul(symtype(x), coeff.num, dict(x); metadata = x.metadata)
466+
coefficient = coeff(x)
467+
if coefficient isa Rational && isone(denominator(coefficient))
468+
_Mul(symtype(x), coefficient.num, dict(x); metadata = x.metadata)
469469
else
470470
x
471471
end
@@ -566,16 +566,16 @@ $(SIGNATURES)
566566
Any Muls inside an Add should always have a coeff of 1
567567
and the key (in Add) should instead be used to store the actual coefficient
568568
"""
569-
function makeadd(sign, coeff, xs...)
569+
function makeadd(sign, coefficient, xs...)
570570
d = Dict{BasicSymbolic, Any}()
571571
for x in xs
572572
if isadd(x)
573-
coeff += coeff(x)
573+
coefficient += coeff(x)
574574
_merge!(+, d, dict(x), filter = _iszero)
575575
continue
576576
end
577577
if x isa Number
578-
coeff += x
578+
coefficient += x
579579
continue
580580
end
581581
if ismul(x)
@@ -591,17 +591,17 @@ function makeadd(sign, coeff, xs...)
591591
d[k] = v
592592
end
593593
end
594-
coeff, d
594+
coefficient, d
595595
end
596596

597-
function makemul(coeff, xs...; d = Dict{BasicSymbolic, Any}())
597+
function makemul(coefficient, xs...; d = Dict{BasicSymbolic, Any}())
598598
for x in xs
599599
if ispow(x) && x.impl.exp isa Number
600600
d[x.impl.base] = x.impl.exp + get(d, x.impl.base, 0)
601601
elseif x isa Number
602-
coeff *= x
602+
coefficient *= x
603603
elseif ismul(x)
604-
coeff *= coeff(x)
604+
coefficient *= coeff(x)
605605
_merge!(+, d, dict(x), filter = _iszero)
606606
else
607607
v = 1 + get(d, x, 0)
@@ -612,7 +612,7 @@ function makemul(coeff, xs...; d = Dict{BasicSymbolic, Any}())
612612
end
613613
end
614614
end
615-
coeff, d
615+
coefficient, d
616616
end
617617

618618
unstable_pow(a, b) = a isa Integer && b isa Integer ? (a // 1)^b : a^b
@@ -1229,13 +1229,13 @@ function +(a::SN, b::SN)
12291229
return _Add(
12301230
add_t(a, b), coeff(a) + coeff(b), _merge(+, dict(a), dict(b), filter = _iszero))
12311231
elseif isadd(a)
1232-
coeff, dict = makeadd(1, 0, b)
1233-
return _Add(add_t(a, b), coeff(a) + coeff, _merge(+, dict(a), dict, filter = _iszero))
1232+
coefficient, dictionary = makeadd(1, 0, b)
1233+
return _Add(add_t(a, b), coeff(a) + coefficient, _merge(+, dict(a), dictionary, filter = _iszero))
12341234
elseif isadd(b)
12351235
return b + a
12361236
end
1237-
coeff, dict = makeadd(1, 0, a, b)
1238-
_Add(add_t(a, b), coeff, dict)
1237+
coefficient, dictionary = makeadd(1, 0, a, b)
1238+
_Add(add_t(a, b), coefficient, dictionary)
12391239
end
12401240
function +(a::Number, b::SN)
12411241
if isconst(b)
@@ -1354,9 +1354,9 @@ function ^(a::SN, b)
13541354
elseif b isa Number && b < 0
13551355
_Div(1, a^(-b))
13561356
elseif ismul(a) && b isa Number
1357-
coeff = unstable_pow(coeff(a), b)
1357+
coefficient = unstable_pow(coeff(a), b)
13581358
_Mul(promote_symtype(^, symtype(a), symtype(b)),
1359-
coeff, mapvalues((k, v) -> b * v, dict(a)))
1359+
coefficient, mapvalues((k, v) -> b * v, dict(a)))
13601360
else
13611361
_Pow(a, b)
13621362
end

0 commit comments

Comments
 (0)