Skip to content

Commit d5d5d58

Browse files
committed
Replace direct dict field access with get_dict getter function
1 parent cbd12cb commit d5d5d58

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/Symbolics.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ using TermInterface
2929
import TermInterface: maketerm, iscall, operation, arguments, metadata
3030

3131
import SymbolicUtils: BasicSymbolic, FnType, @rule, Rewriters, substitute, symtype,
32-
promote_symtype, isadd, ismul, ispow, isterm, issym, isdiv, _Sym
32+
promote_symtype, isadd, ismul, ispow, isterm, issym, isdiv, _Sym,
33+
get_dict
3334

3435
using SymbolicUtils.Code
3536

src/diff.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function recursive_hasoperator(op, O)
139139
return true
140140
else
141141
if isadd(O) || ismul(O)
142-
any(recursive_hasoperator(op), keys(O.dict))
142+
any(recursive_hasoperator(op), keys(get_dict(O)))
143143
elseif ispow(O)
144144
recursive_hasoperator(op)(O.base) || recursive_hasoperator(op)(O.exp)
145145
elseif isdiv(O)

src/latexify_recipes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function _toexpr(O)
142142
denom = Any[]
143143

144144
# We need to iterate over each term in m, ignoring the numeric coefficient.
145-
# This iteration needs to be stable, so we can't iterate over m.dict.
145+
# This iteration needs to be stable, so we can't iterate over get_dict(m).
146146
for term in Iterators.drop(sorted_arguments(m), isone(m.coeff) ? 0 : 1)
147147
if !ispow(term)
148148
push!(numer, _toexpr(term))
@@ -260,7 +260,7 @@ function diffdenom(e)
260260
elseif ismul(e)
261261
LaTeXString(prod(
262262
"\\mathrm{d}$(k)$(isone(v) ? "" : "^{$v}")"
263-
for (k, v) in e.dict
263+
for (k, v) in get_dict(e)
264264
))
265265
else
266266
e

src/semipoly.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ end
6060
# return a dictionary of exponents with respect to variables
6161
function pdegrees(x)
6262
if ismul(x)
63-
return x.dict
63+
return get_dict(x)
6464
elseif isdiv(x)
6565
num_dict = pdegrees(x.num)
6666
den_dict = pdegrees(x.den)

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ function degree(p, sym=nothing)
279279
return Int(isequal(p, sym))
280280
end
281281
elseif ismul(p)
282-
return sum(degree(k^v, sym) for (k, v) in zip(keys(p.dict), values(p.dict)))
282+
return sum(degree(k^v, sym) for (k, v) in zip(keys(get_dict(p)), values(get_dict(p))))
283283
elseif isadd(p)
284-
return maximum(degree(key, sym) for key in keys(p.dict))
284+
return maximum(degree(key, sym) for key in keys(get_dict(p)))
285285
elseif ispow(p)
286286
return p.exp * degree(p.base, sym)
287287
elseif isdiv(p)
@@ -344,7 +344,7 @@ function coeff(p, sym=nothing)
344344
if sym===nothing
345345
p.coeff
346346
else
347-
sum(coeff(k, sym) * v for (k, v) in p.dict)
347+
sum(coeff(k, sym) * v for (k, v) in get_dict(p))
348348
end
349349
elseif ismul(p)
350350
args = arguments(p)

0 commit comments

Comments
 (0)