8000 Clean affine permutation by fchapoton · Pull Request #40034 · sagemath/sage · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Clean affine permutation #40034

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

Merged
merged 1 commit into from
Jun 1, 2025
Merged

Conversation

fchapoton
Copy link
Contributor
@fchapoton fchapoton commented May 1, 2025

pep8 cleanup

adding typing annotations, fixing some code details

but more importantly, using properly the _element_constructor_

📝 Checklist

  • The title is concise and informative.
  • 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 and checked the documentation preview.

Copy link
github-actions bot commented May 1, 2025

Documentation preview for this PR (built with commit 4f48259; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

Copy link
Collaborator
@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Note that the change to use _element_constructor_ is actually a (slight) regression as it involves an extra function call. If directly constructing the element is working (i.e., no special processing is done by _element_constructor_), then I don't think we should make the change. Hence, I don't quite understand your justification for the change.

@fchapoton
Copy link
Contributor Author

do you talk about this kind of change:

  •   return type(self)(self.parent(), inv, check=False)
    
  •   return self.parent()._element_constructor_(inv, check=False)
    

?

@tscrim
Copy link
Collaborator
tscrim commented May 19, 2025

Yes, that's right.

@tscrim
Copy link
Collaborator
tscrim commented May 19, 2025

PS - An alternative is self.__class__(self.parent(), inv, check=False) might be more clear, but it is surprisingly slower:

sage: R.<x> = QQ[]
sage: %timeit type(x)
7.91 ns ± 0.0631 ns per loop (mean ± std. dev. of 7 runs, 100,000,000 loops each)
sage: %timeit x.__class__
24.2 ns ± 0.386 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

although this likely makes no difference in practice...

@fchapoton
Copy link
Contributor Author

I have stepped back to using "type(self)"

Copy link
Collaborator
@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Thank you. LGTM.

vbraun pushed a commit to vbraun/sage that referenced this pull request May 24, 2025
sagemathgh-40034: Clean affine permutation
    
pep8 cleanup

adding typing annotations, fixing some code details

but more importantly, using properly the `_element_constructor_`

### 📝 Checklist

- [x] The title is concise and informative.
- [x] 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 and checked the documentation
preview.
    
URL: sagemath#40034
Reported by: Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request May 26, 2025
sagemathgh-40034: Clean affine permutation
    
pep8 cl
9A0E
eanup

adding typing annotations, fixing some code details

but more importantly, using properly the `_element_constructor_`

### 📝 Checklist

- [x] The title is concise and informative.
- [x] 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 and checked the documentation
preview.
    
URL: sagemath#40034
Reported by: Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request May 28, 2025
sagemathgh-40034: Clean affine permutation
    
pep8 cleanup

adding typing annotations, fixing some code details

but more importantly, using properly the `_element_constructor_`

### 📝 Checklist

- [x] The title is concise and informative.
- [x] 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 and checked the documentation
preview.
    
URL: sagemath#40034
Reported by: Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
@vbraun vbraun merged commit 1de082e into sagemath:develop Jun 1, 2025
15 of 22 checks passed
@fchapoton fchapoton deleted the clean_affine_permutation branch June 2, 2025 15:22
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.

3 participants
0