Skip to content

Commit

Permalink
Fix Julia 1.0 compatibility
Browse files Browse the repository at this point in the history
In Julia 1.0, `I` is UniformScaling{Bool}, whereas (at least) Julia 1.3 and
later have added `I(n)` as shorthand for `Diagonal{Bool,Array{Bool,1}}`.

If you encounter the error:
    LoadError: MethodError: objects of type UniformScaling{Bool} are not callable
this is a one possible reason for that.

Worked around by defining a custom `eye` function that creates a `Diagonal`
populated with ones.
  • Loading branch information
Technologicat committed Aug 11, 2020
1 parent 0f02699 commit c092ed0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/test_utilities.jl
Expand Up @@ -14,8 +14,9 @@ using Test, Tensors, LinearAlgebra
# Various tensors
let Z3 = zeros(3, 3),
O3 = ones(3, 3),
I3 = I(3)
@test isapprox(tovoigt(II()), I(6))
eye(n) = Diagonal([1 for _ in range(1, length=n)]), # TODO: in Julia 1.3 and later, we can just say I(n)
I3 = eye(3)
@test isapprox(tovoigt(II()), eye(6))
@test isapprox(tovoigt(IT()), [I3 Z3;
Z3 Z3])

Expand Down

0 comments on commit c092ed0

Please sign in to comment.