File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 1919# find symbols and their corresponding degrees
2020function get_degrees (expr)
2121 if issym (expr)
22- (nameof ( expr) => 1 ,)
22+ (( Symbol ( expr), ) => 1 ,)
2323 elseif istree (expr)
2424 op = operation (expr)
2525 args = arguments (expr)
@@ -34,8 +34,11 @@ function get_degrees(expr)
3434 ds = map (get_degrees, args)
3535 _, idx = findmax (x-> sum (last .(x), init= 0 ), ds)
3636 return ds[idx]
37+ elseif operation (expr) == (getindex)
38+ args = arguments (expr)
39+ return ((Symbol .(args)... ,) => 1 ,)
3740 else
38- return (Symbol (" zzzzzzz" , hash (expr)) => 1 ,)
41+ return (( Symbol (" zzzzzzz" , hash (expr)), ) => 1 ,)
3942 end
4043 else
4144 return ()
Original file line number Diff line number Diff line change @@ -189,11 +189,15 @@ end
189189end
190190
191191@testset " polynomial printing" begin
192- @syms a b c
192+ @syms a b c x[ 1 : 3 ]
193193 @test repr (b+ a) == " a + b"
194194 @test repr (b- a) == " -a + b"
195195 @test repr (2 a+ 1 + 3 a^ 2 ) == " 1 + 2a + 3(a^2)"
196196 @test repr (2 a+ 1 + 3 a^ 2 + 2 b+ 3 b^ 2 + 4 a* b) == " 1 + 2a + 2b + 3(a^2) + 4a*b + 3(b^2)"
197+
198+ @syms a b[1 : 3 ] c d[1 : 3 ]
199+ @test repr (a + b[3 ] + b[1 ] + d[2 ] + c) == " a + b[1] + b[3] + c + d[2]"
200+ @test repr (expand ((c + b[3 ] - d[1 ])^ 3 )) == " b[3]^3 + 3(b[3]^2)*c - 3(b[3]^2)*d[1] + 3b[3]*(c^2) - 6b[3]*c*d[1] + 3b[3]*(d[1]^2) + c^3 - 3(c^2)*d[1] + 3c*(d[1]^2) - (d[1]^3)"
197201end
198202
199203@testset " inspect" begin
You can’t perform that action at this time.
0 commit comments