From 8be657cdd810ba6ef8f530bb86878c3b61217111 Mon Sep 17 00:00:00 2001 From: Markus Kurtz Date: Fri, 3 Nov 2023 10:36:25 +0100 Subject: [PATCH] Refactor `power_series_ring(R, weights, prec, s)` (#1486) Now use `power_series_ring(R, prec, s; weights)` --- src/generic/AbsMSeries.jl | 47 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/generic/AbsMSeries.jl b/src/generic/AbsMSeries.jl index 96b796e319..1dea210f87 100644 --- a/src/generic/AbsMSeries.jl +++ b/src/generic/AbsMSeries.jl @@ -716,37 +716,36 @@ end function power_series_ring(R::AbstractAlgebra.Ring, prec::Vector{Int}, s::Vector{Symbol}; cached::Bool=true, model=:capped_absolute) U = elem_type(R) - + S, _ = AbstractAlgebra.polynomial_ring(R, s) V = elem_type(S) - if model == :capped_absolute - parent_obj = AbsMSeriesRing{U, V}(S, prec, s, cached) - else - error("Unknown model") - end - - return tuple(parent_obj, gens(parent_obj)) + model === :capped_absolute || error("Unknown model") + + parent_obj = AbsMSeriesRing{U, V}(S, prec, s, cached) + + return parent_obj, gens(parent_obj) end -function power_series_ring(R::AbstractAlgebra.Ring, weights::Vector{Int}, prec::Int, - s::Vector{Symbol}; cached::Bool=true, model=:capped_absolute) - U = elem_type(R) +function power_series_ring(R::AbstractAlgebra.Ring, prec::Int, + s::Vector{Symbol}; weights::Union{Vector{Int}, Nothing}=nothing, + cached::Bool=true, model=:capped_absolute) + U = elem_type(R) - S, _ = AbstractAlgebra.polynomial_ring(R, s) - V = elem_type(S) + S, _ = AbstractAlgebra.polynomial_ring(R, s) + V = elem_type(S) - if model == :capped_absolute - parent_obj = AbsMSeriesRing{U, V}(S, weights, prec, s, cached) - else - error("Unknown model") - end + model === :capped_absolute || error("Unknown model") - return tuple(parent_obj, gens(parent_obj)) -end + if weights === nothing + parent_obj = AbsMSeriesRing{U, V}(S, [prec for _ in s], s, cached) + else + parent_obj = AbsMSeriesRing{U, V}(S, weights, prec, s, cached) + end -function power_series_ring(R::AbstractAlgebra.Ring, prec::Int, - s::Vector{Symbol}; cached::Bool=true, model=:capped_absolute) - prec_vec = [prec for v in s] - return power_series_ring(R, prec_vec, s; cached=cached, model=model) + return parent_obj, gens(parent_obj) end + +power_series_ring(R::AbstractAlgebra.Ring, weights::Vector{Int}, + prec::Int, s::Vector{Symbol}; kw... + ) = power_series_ring(R, prec, s; weights, kw...)