Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of kwargs in @polynomial_ring #1632

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/misc/VarNames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ function varnames_macro(f, args_count, opt_in)
# Keyword arguments after `;` end up in `kv`.
# Those without previous `;` get evaluated and end up in `kv2`.
# Note: one could work around evaluating the latter if necessary.
kv = Meta.isexpr(first(args), :parameters) ?
popfirst!(args).args : Expr(:parameters)
if Meta.isexpr(first(args), :parameters)
kv = first(args)
args = args[2:end]
else
kv = Expr(:parameters)
end

req(length(args) >= $args_count+1, "Not enough arguments")
base_args = args[1:$args_count]
Expand Down
11 changes: 11 additions & 0 deletions test/generic/MPoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@
QQxxx3 = @polynomial_ring(QQ, :x=>1:3)
@test QQxxx_ == (QQxxx3, [x1, x2, x3])

# test support of kwargs
QQxxx4 = @polynomial_ring(QQ, "x#" => 1:3; internal_ordering=:lex)
lgoettgens marked this conversation as resolved.
Show resolved Hide resolved
@test QQxxx_ == (QQxxx4, [x1, x2, x3])

QQxxx_deglex_ = @inferred polynomial_ring(QQ, "x#" => 1:3; internal_ordering=:deglex)
@test internal_ordering(QQxxx_deglex_[1]) == :deglex

QQxxx_deglex2 = @polynomial_ring(QQ, "x#" => 1:3; internal_ordering=:deglex)
@test internal_ordering(QQxxx_deglex2) == :deglex
@test QQxxx_deglex_ == (QQxxx_deglex2, [x1, x2, x3])

ZZxy_ = @inferred polynomial_ring(ZZ, :x => (1:2, 1:2), :y => 0:3)

ZZxy2_ = @inferred polynomial_ring(ZZ, :x => ["1, 1" "1, 2"; "2, 1" "2, 2"], :y => (0:3,))
Expand Down
Loading