From 1e7537206826ce950a6ef840b3f698cff6facd95 Mon Sep 17 00:00:00 2001 From: kalmar Date: Mon, 5 Jun 2017 21:38:03 +0200 Subject: [PATCH] in setindex! perform coercion only when necessary --- src/GroupRings.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/GroupRings.jl b/src/GroupRings.jl index c8ffbc2..f02d6cf 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -173,8 +173,11 @@ end function setindex!(X::GroupRingElem, value, g::GroupElem) RG = parent(X) typeof(g) == elem_type(RG.group) || throw("$g is not an element of $(RG.group)") - g = (RG.group)(g) - X.coeffs[RG.basis_dict[g]] = value + if !(g in keys(RG.basis_dict)) + g = (RG.group)(g) + else + X.coeffs[RG.basis_dict[g]] = value + end end eltype(X::GroupRingElem) = eltype(X.coeffs)