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

Integer.{perfect_power,is_prime_power,is_irreducible}: Handle easy cases without PARI #35847

Merged

Conversation

mkoeppe
Copy link
Member

@mkoeppe mkoeppe commented Jun 27, 2023

📚 Description

Taking care of small primes and powers of two.

In particular, this allows us to set up GF(2) without pulling in PARI, and avoids many # optional tags in sage.combinat.designs and sage.combinat.posets.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

@mkoeppe mkoeppe force-pushed the is_prime_power_perfect_power_without_pari branch from ef8f5b7 to f01b0c2 Compare June 27, 2023 21:30
@mkoeppe mkoeppe changed the title Integer.{perfect_power,is_prime_power}: Handle easy cases without PARI Integer.{perfect_power,is_prime_power,is_irreducible}: Handle easy cases without PARI Jul 1, 2023
if n >= 4:
if not (n & 1):
if mpz_popcount(self.value) == 1:
return smallInteger(2), smallInteger(mpz_sizeinbase(self.value, 2) - 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer sanity tests for this.
It's so easy to get this wrong by +-1....

Copy link
Member Author

Choose a reason for hiding this comment

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

True. Added tests in d2c9c5e

src/sage/rings/integer.pyx Show resolved Hide resolved
@kliem
Copy link
Contributor

kliem commented Jul 2, 2023

LGTM.

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 2, 2023

Thank you!

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

Documentation preview for this PR (built with commit d2c9c5e; changes) is ready! 🎉

@vbraun vbraun merged commit c85882b into sagemath:develop Jul 9, 2023
14 checks passed
@mkoeppe mkoeppe added this to the sage-10.1 milestone Jul 9, 2023
vbraun pushed a commit that referenced this pull request Jul 20, 2023
… imports

    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

<!-- Describe your changes here in detail. -->
- Many `# optional` are removed because small prime finite fields no
longer need to be marked `# optional/needs sage.rings.finite_rings`
since #35847
- Other `# optional` are replaced by codeblock-scoped `# needs` tags
- Remaining `# optional` with standard features are replaced by `#
needs`
- Some import fixes needed for separate testing of **sagemath-modules**
or **sagemath-graphs**[modules] from #35095
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
This is:
- done with the help of `sage -fixdoctests` from #35749
- Part of: #29705
- Cherry-picked from: #35095
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35919
Reported by: Matthias Köppe
Reviewer(s): David Coudert, Matthias Köppe
vbraun pushed a commit that referenced this pull request Jul 30, 2023
…eds`

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

- Many `# optional` are removed because small prime finite fields no
longer need to be marked `# optional/needs sage.rings.finite_rings`
since #35847
- Other `# optional` are replaced by codeblock-scoped `# needs` tags
- Remaining `# optional` with standard features are replaced by `#
needs`
- Some import fixes needed for separate testing of **sagemath-graphs**
from #35095
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
This is:
- done with the help of `sage -fixdoctests` from #35749
- Part of: #29705
- Cherry-picked from: #35095

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35943
Reported by: Matthias Köppe
Reviewer(s): David Coudert, Matthias Köppe
vbraun pushed a commit that referenced this pull request Jul 30, 2023
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
- Many `# optional` are removed because small prime finite fields no
longer need to be marked `# optional/needs sage.rings.finite_rings`
since #35847
- Other `# optional` are replaced by codeblock-scoped `# needs` tags
- Remaining `# optional` with standard features are replaced by `#
needs`
- Some import fixes needed for separate testing of **sagemath-graphs**
from #35095
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
This is:
- done with the help of `sage -fixdoctests` from #35749
- Part of: #29705
- Cherry-picked from: #35095

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35957
Reported by: Matthias Köppe
Reviewer(s): David Coudert, Matthias Köppe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants