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

Immutability of chart functions #30310

Closed
mjungmath opened this issue Aug 7, 2020 · 33 comments
Closed

Immutability of chart functions #30310

mjungmath opened this issue Aug 7, 2020 · 33 comments

Comments

@mjungmath
Copy link

Immutability of chart functions, see #30261.

Depends on #31181
Depends on #31182

CC: @egourgoulhon @tscrim @mkoeppe

Component: manifolds

Keywords: immutability

Author: Michael Jung

Branch/Commit: e855ebc

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/30310

@mjungmath mjungmath added this to the sage-9.2 milestone Aug 7, 2020
@mjungmath
Copy link
Author

@mjungmath

This comment has been minimized.

@mjungmath
Copy link
Author

Author: Michael Jung

@mjungmath
Copy link
Author

New commits:

286d3c6FreeModuleTensor, Vector: Subclass a new class ModuleElementWithMutability
9df3d22sage.tensor.modules: Make all zero() and one() elements immutable
4373ea2FreeModuleTensor: Replace special casing of the immutable zero by is_immutable
a2ee8beModuleElementWithMutability.is_immutable, is_mutable: Change def to cpdef
8600c2dMerge branch 't/30181/immutable_elements_of_freemoduletensor' into t/30310/immutability_of_chart_functions
76229bdTrac #30310: immutability of chart functions

@mjungmath
Copy link
Author

Commit: 76229bd

@mjungmath
Copy link
Author

Changed keywords from none to immutability

@mjungmath
Copy link
Author

Dependencies: #30181

@egourgoulhon
Copy link
Member

comment:4

Why is #30181 a dependency of this ticket? A priori chart functions are totally independent from tensor fields. They even exist on pure topological manifolds.

@mjungmath
Copy link
Author

comment:5

It is because of

-from sage.structure.element import AlgebraElement
+from sage.structure.element import AlgebraElement, ModuleElementWithMutability
...
-class ChartFunction(AlgebraElement):
+class ChartFunction(AlgebraElement, ModuleElementWithMutability):

@mjungmath
Copy link
Author

comment:6

ModuleElementWithMutability is first introduced in #30181.

@tscrim
Copy link
Collaborator

tscrim commented Aug 7, 2020

comment:7

I feel like the MultiCoordFunction should inherit from Mutability rather than copy the same code.

@mjungmath
Copy link
Author

comment:8

It'd be the same issue like we had for affine connections (#30280): __reduce__ (#30281).

@tscrim
Copy link
Collaborator

tscrim commented Aug 7, 2020

comment:9

I know, but as a stop-gap, you could instead implement a __reduce__. I don't really like this duplication. Hopefully this week I can get around to properly doing #30281...

@egourgoulhon
Copy link
Member

comment:10

Replying to @mjungmath:

It is because of

-from sage.structure.element import AlgebraElement
+from sage.structure.element import AlgebraElement, ModuleElementWithMutability
...
-class ChartFunction(AlgebraElement):
+class ChartFunction(AlgebraElement, ModuleElementWithMutability):

Ah yes, thanks.

@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Sep 5, 2020
@mjungmath
Copy link
Author

comment:12

I tried to remove the redundant code and inherit from Mutability after #30281. For some reason, I still get a pickling error during doctest.

Furthermore, the code seems broken: is_immutable does not return anything:

    def is_immutable(self):
        """
        ...
        """
        self._is_immutable

When did that happen?

@mjungmath
Copy link
Author

comment:14

I opened a ticket for the missing return: #31181.

Furthermore, I've opened a ticket for the still remaining pickling test error: #31182.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 7, 2021

Changed commit from 76229bd to 09086cf

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 7, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

09086cfTrac #30310: inherit from Mutability

@mjungmath
Copy link
Author

Changed dependencies from #30181 to #31181, #31182

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 21, 2021

Changed commit from 09086cf to 6c76b66

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 21, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

6c76b66Trac #30310: AssertionError -> ValueError

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 21, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

7247620Merge branch 'develop' into t/30310/immutability_of_chart_functions
5ecbf3aTrac #31181: return added
8b20fc4Merge branch 't/31181/mutability_class_does_not_return_is_immutable' into t/30310/immutability_of_chart_functions
4c33935Trac #31196: minor code improvements, py3 compatibility, documentation improved
e5228d3Trac #31196: cpdef require methods + example added
d957f73Trac #31196: unnecessary line in docstring removed
d6d6ba4Trac #31182: `__getstate__` and __setstate__
6cbd1fdTrac #31182: doctests added for `__setstate__` and __getstate__
848e96bMerge branch 't/31182/mutability_class_and_pickling' into t/30310/immutability_of_chart_functions

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 21, 2021

Changed commit from 6c76b66 to 848e96b

@mjungmath
Copy link
Author

comment:19

Green patchbot.

@tscrim
Copy link
Collaborator

tscrim commented Jan 21, 2021

comment:20

I think you are better off explicitly calling

ModuleElementWithMutability.__init__(self, parent)

@mjungmath
Copy link
Author

comment:21

Yes thanks, this should be better.

@mjungmath
Copy link
Author

comment:22

Pushed.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 21, 2021

Changed commit from 848e96b to e855ebc

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 21, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

e855ebcTrac #30310: init ModuleElementWithMutability directly

@tscrim
Copy link
Collaborator

tscrim commented Jan 22, 2021

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Jan 22, 2021

comment:24

Green bot => positive review.

@mjungmath
Copy link
Author

comment:26

Thank you.

@vbraun
Copy link
Member

vbraun commented Mar 9, 2021

Changed branch from u/gh-mjungmath/immutability_of_chart_functions to e855ebc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants