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

Change inheritance order in UniqueRepresentation #38203

Merged
merged 11 commits into from
Aug 3, 2024

Conversation

enriqueartal
Copy link
Contributor

@enriqueartal enriqueartal commented Jun 12, 2024

Currently in UniqueRepresentation, the MRO is constructed by
class UniqueRepresentation(CachedRepresentation, WithEqualityById):
However, in order to maximize the utility of the WithEqualityById class, in particular with subclasses of UniqueRepresentation, we should place it first in the MRO. This is useful in #37128, where this resolves MRO resolution issues and not having to reimplement (or set aliases) the behavior of WithEqualityById.

However, this change, while seemingly innocuous, does cause a problem with one doctest dealing with very old pickles (Sage version <= 4.0) in combinat/root_system/cartan_type.py concerning class CartanType_simple_finite:. Currently, it is unclear why this change is resulting in the error:

sage: from sage.misc.fpickle import unpickleModule
sage: pg_make_integer = unpickle_global('sage.rings.integer', 'make_integer')
sage: si2 = pg_make_integer('4')
sage: unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2})
Traceback (most recent call last):
  File "/sage/src/sage/doctest/forker.py", line 715, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/sage/src/sage/doctest/forker.py", line 1147, in compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple_finite.__setstate__[5]>", line 1, in <module>
    unpickle_build(si1, {'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A', si2], 'letter':'A', 'n':si2})
  File "/sage/src/sage/misc/explain_pickle.py", line 2442, in unpickle_build
    setstate(state)
  File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106, in __setstate__
    self.__class__ = T.__class__
TypeError: __class__ assignment: 'CartanType' object layout differs from 'CartanType_simple_finite'

However, since these are very old pickles and we cannot reproduce the failure otherwise, we feel that it is prudent to drop support for this and remove the corresponding class.

📝 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.

⌛ Dependencies

@enriqueartal
Copy link
Contributor Author

@tscrim, @miguelmarco, can you complete the description?

Copy link

github-actions bot commented Jun 12, 2024

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

@tscrim
Copy link
Collaborator

tscrim commented Jun 13, 2024

Changed.

You also need to remove the class here in order for the tests to pass.

@enriqueartal
Copy link
Contributor Author

After a merge there are a couple of failing tests for sage/categories/category_singleton.pyx and sage/categories/sets_cat.py which are the two files where the tests were changed. Before changing the tests, I wonder if the final order in that cases is what we want.

@tscrim
Copy link
Collaborator

tscrim commented Jul 9, 2024

The changed order looks like it is the correct thing given the change to the MRO we are making.

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.

Okay, then let this be so. Hopefully this will get merged into the next beta0 to get lots of testing. Sorry for being extremely slow with this!

@enriqueartal
Copy link
Contributor Author

Thanks, as you said, beta0 is the right place.

@enriqueartal
Copy link
Contributor Author

I understood that there was a positive review but the label has not been changed.

@tscrim
Copy link
Collaborator

tscrim commented Jul 21, 2024

Sorry, I thought I had changed it.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 25, 2024
    
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Currently in `UniqueRepresentation`, the MRO is constructed by
```class UniqueRepresentation(CachedRepresentation,
WithEqualityById):```
However, in order to maximize the utility of the `WithEqualityById`
class, in particular with subclasses of `UniqueRepresentation`, we
should place it *first* in the MRO. This is useful in sagemath#37128, where this
resolves MRO resolution issues and not having to reimplement (or set
aliases) the behavior of `WithEqualityById`.

However, this change, while seemingly innocuous, does cause a problem
with one doctest dealing with very old pickles (Sage version <= 4.0) in
`combinat/root_system/cartan_type.py` concerning `class
CartanType_simple_finite:`. Currently, it is unclear why this change is
resulting in the error:
```
sage: from sage.misc.fpickle import unpickleModule
sage: pg_make_integer = unpickle_global('sage.rings.integer',
'make_integer')
sage: si2 = pg_make_integer('4')
sage: unpickle_build(si1,
{'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A',
si2], 'letter':'A', 'n':si2})
Traceback (most recent call last):
  File "/sage/src/sage/doctest/forker.py", line 715, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/sage/src/sage/doctest/forker.py", line 1147, in
compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple
_finite.__setstate__[5]>", line 1, in <module>
    unpickle_build(si1,
{'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A',
si2], 'letter':'A', 'n':si2})
  File "/sage/src/sage/misc/explain_pickle.py", line 2442, in
unpickle_build
    setstate(state)
  File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106,
in __setstate__
    self.__class__ = T.__class__
TypeError: __class__ assignment: 'CartanType' object layout differs from
'CartanType_simple_finite'
```
However, since these are very old pickles and we cannot reproduce the
failure otherwise, we feel that it is prudent to drop support for this
and remove the corresponding class.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [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.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38203
Reported by: Enrique Manuel Artal Bartolo
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 31, 2024
    
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Currently in `UniqueRepresentation`, the MRO is constructed by
```class UniqueRepresentation(CachedRepresentation,
WithEqualityById):```
However, in order to maximize the utility of the `WithEqualityById`
class, in particular with subclasses of `UniqueRepresentation`, we
should place it *first* in the MRO. This is useful in sagemath#37128, where this
resolves MRO resolution issues and not having to reimplement (or set
aliases) the behavior of `WithEqualityById`.

However, this change, while seemingly innocuous, does cause a problem
with one doctest dealing with very old pickles (Sage version <= 4.0) in
`combinat/root_system/cartan_type.py` concerning `class
CartanType_simple_finite:`. Currently, it is unclear why this change is
resulting in the error:
```
sage: from sage.misc.fpickle import unpickleModule
sage: pg_make_integer = unpickle_global('sage.rings.integer',
'make_integer')
sage: si2 = pg_make_integer('4')
sage: unpickle_build(si1,
{'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A',
si2], 'letter':'A', 'n':si2})
Traceback (most recent call last):
  File "/sage/src/sage/doctest/forker.py", line 715, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/sage/src/sage/doctest/forker.py", line 1147, in
compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple
_finite.__setstate__[5]>", line 1, in <module>
    unpickle_build(si1,
{'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A',
si2], 'letter':'A', 'n':si2})
  File "/sage/src/sage/misc/explain_pickle.py", line 2442, in
unpickle_build
    setstate(state)
  File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106,
in __setstate__
    self.__class__ = T.__class__
TypeError: __class__ assignment: 'CartanType' object layout differs from
'CartanType_simple_finite'
```
However, since these are very old pickles and we cannot reproduce the
failure otherwise, we feel that it is prudent to drop support for this
and remove the corresponding class.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [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.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38203
Reported by: Enrique Manuel Artal Bartolo
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request Aug 2, 2024
    
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Currently in `UniqueRepresentation`, the MRO is constructed by
```class UniqueRepresentation(CachedRepresentation,
WithEqualityById):```
However, in order to maximize the utility of the `WithEqualityById`
class, in particular with subclasses of `UniqueRepresentation`, we
should place it *first* in the MRO. This is useful in sagemath#37128, where this
resolves MRO resolution issues and not having to reimplement (or set
aliases) the behavior of `WithEqualityById`.

However, this change, while seemingly innocuous, does cause a problem
with one doctest dealing with very old pickles (Sage version <= 4.0) in
`combinat/root_system/cartan_type.py` concerning `class
CartanType_simple_finite:`. Currently, it is unclear why this change is
resulting in the error:
```
sage: from sage.misc.fpickle import unpickleModule
sage: pg_make_integer = unpickle_global('sage.rings.integer',
'make_integer')
sage: si2 = pg_make_integer('4')
sage: unpickle_build(si1,
{'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A',
si2], 'letter':'A', 'n':si2})
Traceback (most recent call last):
  File "/sage/src/sage/doctest/forker.py", line 715, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/sage/src/sage/doctest/forker.py", line 1147, in
compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.combinat.root_system.cartan_type.CartanType_simple
_finite.__setstate__[5]>", line 1, in <module>
    unpickle_build(si1,
{'tools':unpickleModule('sage.combinat.root_system.type_A'), 't':['A',
si2], 'letter':'A', 'n':si2})
  File "/sage/src/sage/misc/explain_pickle.py", line 2442, in
unpickle_build
    setstate(state)
  File "/sage/src/sage/combinat/root_system/cartan_type.py", line 3106,
in __setstate__
    self.__class__ = T.__class__
TypeError: __class__ assignment: 'CartanType' object layout differs from
'CartanType_simple_finite'
```
However, since these are very old pickles and we cannot reproduce the
failure otherwise, we feel that it is prudent to drop support for this
and remove the corresponding class.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [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.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38203
Reported by: Enrique Manuel Artal Bartolo
Reviewer(s): Travis Scrimshaw
@vbraun vbraun merged commit 80285e2 into sagemath:develop Aug 3, 2024
19 of 20 checks passed
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