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

Enable factor(::Rational) #1918

Merged
merged 1 commit into from
Nov 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
2 changes: 1 addition & 1 deletion src/Fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function gcdx(x::T, y::T) where {T <: FieldElem}
end
end

function factor(x::FieldElem)
function factor(x::FieldElement)
@req !is_zero(x) "Element must be non-zero"
return Fac(x, Dict{typeof(x), Int}())
end
2 changes: 1 addition & 1 deletion src/generic/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
return factor(f1)
end

function factor(R::Ring, f::FracElem)
function factor(R::Ring, f::Union{FracElem, Rational})

Check warning on line 31 in src/generic/Misc/Poly.jl

View check run for this annotation

Codecov / codecov/patch

src/generic/Misc/Poly.jl#L31

Added line #L31 was not covered by tests
fn = factor(R(numerator(f)))
fd = factor(R(denominator(f)))
fn.unit = divexact(fn.unit, fd.unit)
Expand Down
7 changes: 7 additions & 0 deletions test/generic/Fraction-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,11 @@ end
@test length(f) == 0
@test unit(f) == a
@test_throws ArgumentError factor(zero(F))

F = QQ
a = 28//15
f = factor(a)
@test length(f) == 0
@test unit(f) == a
@test_throws ArgumentError factor(zero(F))
end
Loading