Skip to content

Commit

Permalink
Fix some divexact methods to pass check as kwarg, not positional
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Dec 22, 2023
1 parent 473fe80 commit f73db83
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/AlgAssAbsOrd/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,26 +227,26 @@ function divexact(a::T, b::T, action::Symbol, check::Bool = true) where { T <: U
end

@doc raw"""
divexact_right(a::AlgAssAbsOrdElem, b::AlgAssAbsOrdElem, check::Bool = true)
divexact_right(a::AlgAssRelOrdElem, b::AlgAssRelOrdElem, check::Bool = true)
divexact_right(a::AlgAssAbsOrdElem, b::AlgAssAbsOrdElem; check::Bool = true)
divexact_right(a::AlgAssRelOrdElem, b::AlgAssRelOrdElem; check::Bool = true)
-> AlgAssRelOrdElem
Returns an element $c \in O$ such that $a = c \cdot b$ where $O$ is the order
containing $a$.
If `check` is `false`, it is not checked whether $c$ is an element of $O$.
"""
divexact_right(a::T, b::T, check::Bool = true) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } } = divexact(a, b, :right, check)
divexact_right(a::T, b::T; check::Bool = true) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } } = divexact(a, b, :right, check)

Check warning on line 238 in src/AlgAssAbsOrd/Elem.jl

View check run for this annotation

Codecov / codecov/patch

src/AlgAssAbsOrd/Elem.jl#L238

Added line #L238 was not covered by tests

@doc raw"""
divexact_left(a::AlgAssAbsOrdElem, b::AlgAssAbsOrdElem, check::Bool = true)
divexact_left(a::AlgAssRelOrdElem, b::AlgAssRelOrdElem, check::Bool = true)
divexact_left(a::AlgAssAbsOrdElem, b::AlgAssAbsOrdElem; check::Bool = true)
divexact_left(a::AlgAssRelOrdElem, b::AlgAssRelOrdElem; check::Bool = true)
-> AlgAssRelOrdElem
Returns an element $c \in O$ such that $a = b \cdot c$ where $O$ is the order
containing $a$.
If `check` is `false`, it is not checked whether $c$ is an element of $O$.
"""
divexact_left(a::T, b::T, check::Bool = true) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } } = divexact(a, b, :left, check)
divexact_left(a::T, b::T; check::Bool = true) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } } = divexact(a, b, :left, check)

Check warning on line 249 in src/AlgAssAbsOrd/Elem.jl

View check run for this annotation

Codecov / codecov/patch

src/AlgAssAbsOrd/Elem.jl#L249

Added line #L249 was not covered by tests

################################################################################
#
Expand Down
8 changes: 8 additions & 0 deletions src/Deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@

@deprecate field_of_fractions(O::GenOrd) function_field(O::GenOrd)

# Deprecated during 0.23.*

@deprecate divexact_right(a::T, b::T, check::Bool) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } } divexact(a, b, :right, check)
@deprecate divexact_left(a::T, b::T, check::Bool) where { T <: Union{ AlgAssAbsOrdElem, AlgAssRelOrdElem } } divexact(a, b, :left, check)
@deprecate divexact(a::NumFieldOrdElem, b::Integer, check::Bool) divexact(a, b; check=check)
@deprecate divexact(a::NumFieldOrdElem, b::ZZRingElem, check::Bool) divexact(a, b; check=check)
@deprecate divexact(x::T, y::T, check::Bool) where T <: NumFieldOrdElem divexact(x, y; check=check)

# Things that moved to Nemo

# > 0.18.1
Expand Down
4 changes: 2 additions & 2 deletions src/NumFieldOrd/NumFieldOrdElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function -(x::T, y::T) where T <: NumFieldOrdElem
return z
end

function divexact(x::T, y::T, check::Bool = true) where T <: NumFieldOrdElem
function divexact(x::T, y::T; check::Bool = true) where T <: NumFieldOrdElem
!check_parent(x, y) && error("Wrong parents")
a = divexact(x.elem_in_nf, y.elem_in_nf)
if check
Expand Down Expand Up @@ -174,7 +174,7 @@ for T in [Integer, ZZRingElem]
return z
end

function divexact(a::NumFieldOrdElem, b::$T, check::Bool = true)
function divexact(a::NumFieldOrdElem, b::$T; check::Bool = true)
t = divexact(a.elem_in_nf, b)
if check
if !in(t, parent(a))
Expand Down
8 changes: 4 additions & 4 deletions test/NfOrd/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@
c = @inferred divexact(O1(a1^2), O1(a1))
@test c == O1(a1)

c = @inferred divexact(O1(a1^2), O1(a1), true)
c = @inferred divexact(O1(a1^2), O1(a1); check=true)
@test c == O1(a1)

c = @inferred divexact(O1(a1^2), O1(a1), false)
c = @inferred divexact(O1(a1^2), O1(a1); check=false)
@test c == O1(a1)

@test_throws ErrorException divexact(O1(1), O1(2))
Expand Down Expand Up @@ -191,9 +191,9 @@
@test c == O1(a1)
c = @inferred divexact(b, ZZRingElem(2))
@test c == O1(a1)
c = @inferred divexact(b, ZZRingElem(2), true)
c = @inferred divexact(b, ZZRingElem(2); check=true)
@test c == O1(a1)
c = @inferred divexact(b, ZZRingElem(2), false)
c = @inferred divexact(b, ZZRingElem(2); check=false)
@test c == O1(a1)

@test_throws ErrorException divexact(b, O1(4*a1))
Expand Down

0 comments on commit f73db83

Please sign in to comment.