Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix is_power for e.g. ZZPolyRing#2241

Merged
fingolfin merged 1 commit into
masterNemocas/AbstractAlgebra.jl:masterfrom
mh/fix-is_powerNemocas/AbstractAlgebra.jl:mh/fix-is_powerCopy head branch name to clipboard
Dec 12, 2025
Merged

Fix is_power for e.g. ZZPolyRing#2241
fingolfin merged 1 commit into
masterNemocas/AbstractAlgebra.jl:masterfrom
mh/fix-is_powerNemocas/AbstractAlgebra.jl:mh/fix-is_powerCopy head branch name to clipboard

Conversation

@fingolfin

Copy link
Copy Markdown
Member

Without this, we get in Nemo:

julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
(true, 4*x)

With it, the correct result is produced:

julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
(true, 2*x)

Motivated by #2051 which also contains some tests for this, which requires implementing factorization for some rings in AA... I did not want to go to these lengths, so i run the above and a couple other tests in Nemo... That is:

ZZx, x = ZZ[:x]
#QQx, x = QQ[:x]

@test is_power(x, 2) == (false, x)
@test is_power(x, 3) == (false, x)
@test is_power(x^2, 2) == (true, x)
@test is_power(3 * x^2, 2) == (false, 3 * x^2)
@test is_power(2^2 * x^2, 2) == (true, 2 * x)
@test is_power(2^3 * x^3, 3) == (true, 2 * x)
@test is_power(3^4 * x^4, 2) == (true, 9 * x^2)
@test is_power(-3^4 * x^4, 2) == (false, -81 * x^4)
@test is_power(-3^3 * x^3, 3) == (true, -3 * x)
@test is_power(3^2 * (x + 1)^2 * x^2, 2) == (true, 3 * (x + 1) * x)
@test is_power(-3^2 * (x + 1)^2 * x^2, 2) == (false, -3^2 * (x + 1)^2 * x^2)

Once with the ring over ZZ and once with the one over QQ.

Without this, we get in Nemo:

    julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
    (true, 4*x)

With it, the correct result is produced:

    julia> ZZx, x = ZZ[:x];  is_power(2^2 * x^2, 2)
    (true, 2*x)
@fingolfin fingolfin changed the title Fix is_power for e.g. ZZPolyRing Fix is_power for e.g. ZZPolyRing Dec 10, 2025
@codecov

codecov Bot commented Dec 10, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.00%. Comparing base (bee81db) to head (aed9edf).
⚠️ Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
src/generic/Misc/Poly.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2241   +/-   ##
=======================================
  Coverage   88.00%   88.00%           
=======================================
  Files         127      127           
  Lines       31803    31803           
=======================================
  Hits        27989    27989           
  Misses       3814     3814           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SoongNoonien SoongNoonien left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fingolfin and I talked about this and this should be correct now.

@fingolfin
fingolfin merged commit 86dbbb3 into master Dec 12, 2025
25 of 27 checks passed
@fingolfin
fingolfin deleted the mh/fix-is_power branch December 12, 2025 09:42
@aaruni96 aaruni96 added bug Something isn't working release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Dec 17, 2025
fingolfin referenced this pull request Jan 9, 2026
Co-authored-by: Lars Göttgens <lars.goettgens@rwth-aachen.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.