-
Notifications
You must be signed in to change notification settings - Fork 141
Closed
Description
summary(io::IO, a::AbstractArray{<:RingElem}) = oscar_array_summary(io, a, axes(a))
function oscar_array_summary(io::IO, a, inds::Tuple{Vararg{OneTo}})
print(io, Base.dims2string(length.(inds)), " ")
showarg(io, a, true)
end
Before:
julia> v
2-element Vector{AbstractAlgebra.Generic.MPoly{nf_elem}}:
x^2 - 3*y
1//4*x^2 - 1//2*sqrt(3)*x*y + 3//2*sqrt(3)*x + 3//4*y^2 + 3//2*y
Apply this hack (?):
function Base.showarg(io::IO, x::Vector{<:RingElem}, toplevel::Bool)
if toplevel
print(io, "Vector of ring elements")
return
end
# original code follows
toplevel || print(io, "::")
print(io, typeof(x))
end
After:
julia> v
2-element Vector of ring elements:
x^2 - 3*y
1//4*x^2 - 1//2*sqrt(3)*x*y + 3//2*sqrt(3)*x + 3//4*y^2 + 3//2*y
Of course one could do something similar for FieldElem
, ModuleElem
, etc.
and the output could be refined, e.g. it could print the parent (though I'd
not do this for now, as it raises many questions: handle empty vectors; should
it check that all entries have the same parent; and if not, what then? etc.)
Questions:
- Is this type piracy? Vector is not our type, but
RingElem
is... - Would this be useful for improving our printing situation?
- Where else is using
showarg
? If the above is too broad, we could also
instead overridesummary(io::IO, x::Vector{<:RingElem})
.
Metadata
Metadata
Assignees
Labels
No labels